markuno_lib 1.2.138 → 1.2.139
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/bin/markcad.js +1 -1
- package/package.json +1 -1
- package/types/markcad.d.ts +1 -1
package/bin/markcad.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as e from"three";import{ShaderMaterial as t,ShaderLib as n,UniformsUtils as i,Vector2 as r,UniformsLib as s,InstancedBufferGeometry as o,Float32BufferAttribute as a,InstancedInterleavedBuffer as A,InterleavedBufferAttribute as l,WireframeGeometry as c,Box3 as p,Sphere as h,Vector3 as u,Mesh as d,Vector4 as g,Line3 as f,Matrix4 as m,MathUtils as y,TrianglesDrawMode as b,TriangleFanDrawMode as I,TriangleStripDrawMode as x,BufferGeometry as C,BufferAttribute as B,Loader as E,LoaderUtils as w,FileLoader as v,MeshPhysicalMaterial as P,Color as T,LinearSRGBColorSpace as S,SRGBColorSpace as M,SpotLight as D,PointLight as L,DirectionalLight as _,Quaternion as F,InstancedMesh as k,InstancedBufferAttribute as R,Object3D as N,TextureLoader as O,ImageBitmapLoader as G,InterleavedBuffer as U,LinearMipmapLinearFilter as Y,NearestMipmapLinearFilter as z,LinearMipmapNearestFilter as H,NearestMipmapNearestFilter as X,LinearFilter as q,NearestFilter as j,RepeatWrapping as W,MirroredRepeatWrapping as J,ClampToEdgeWrapping as V,PointsMaterial as K,Material as Z,LineBasicMaterial as $,MeshStandardMaterial as ee,DoubleSide as te,MeshBasicMaterial as ne,PropertyBinding as ie,SkinnedMesh as re,LineSegments as se,Line as oe,LineLoop as ae,Points as Ae,Group as le,PerspectiveCamera as ce,OrthographicCamera as pe,Skeleton as he,AnimationClip as ue,Bone as de,InterpolateDiscrete as ge,InterpolateLinear as fe,Texture as me,VectorKeyframeTrack as ye,NumberKeyframeTrack as be,QuaternionKeyframeTrack as Ie,ColorManagement as xe,FrontSide as Ce,Interpolant as Be,CompressedCubeTexture as Ee,CompressedArrayTexture as we,CompressedTexture as ve,NoColorSpace as Qe,RGBA_PVRTC_2BPPV1_Format as Pe,RGBA_PVRTC_4BPPV1_Format as Te,RGBA_BPTC_Format as Se,RED_GREEN_RGTC2_Format as Me,SIGNED_RED_GREEN_RGTC2_Format as De,RED_RGTC1_Format as Le,SIGNED_RED_RGTC1_Format as _e,RGBA_S3TC_DXT3_Format as Fe,RGB_S3TC_DXT1_Format as ke,RGBA_S3TC_DXT1_Format as Re,RGBA_ASTC_6x6_Format as Ne,RGBA_ASTC_4x4_Format as Oe,SIGNED_RG11_EAC_Format as Ge,RG11_EAC_Format as Ue,SIGNED_R11_EAC_Format as Ye,R11_EAC_Format as ze,RGB_ETC2_Format as He,RGBA_ETC2_EAC_Format as Xe,RGBFormat as qe,RedFormat as je,RGFormat as We,RGBAFormat as Je,UnsignedByteType as Ve,HalfFloatType as Ke,UnsignedInt101111Type as Ze,UnsignedInt5999Type as $e,FloatType as et,DataTexture as tt,Data3DTexture as nt,RGB_PVRTC_4BPPV1_Format as it,RGB_ETC1_Format as rt,RGBA_S3TC_DXT5_Format as st,RGB_BPTC_UNSIGNED_Format as ot,MeshPhongMaterial as at,AdditiveBlending as At,Plane as lt,Triangle as ct,BackSide as pt,REVISION as ht,Ray as ut,Matrix3 as dt}from"three";class Matrix3D{constructor(){this.m=new Float32Array(16),this.st=[],this.init()}init(){return this.m.fill(0),this.m[0]=this.m[5]=this.m[10]=this.m[15]=1,this}atranslate(e,t,n){return this.m[12]+=e,this.m[13]+=t,this.m[14]+=n,this}translate(e,t,n){return e??=0,t??=0,n??=0,this.m[12]+=e*this.m[0]+t*this.m[4]+n*this.m[8],this.m[13]+=e*this.m[1]+t*this.m[5]+n*this.m[9],this.m[14]+=e*this.m[2]+t*this.m[6]+n*this.m[10],this.m[15]+=e*this.m[3]+t*this.m[7]+n*this.m[11],this}rotateX(e){if(e){const t=(e||0)*Math.PI/180,n=Math.sin(t),i=Math.cos(t),r=[...this.m];this.m[1]=r[1]*i+r[9]*n,this.m[2]=r[2]*i+r[10]*n,this.m[3]=r[3]*i+r[11]*n,this.m[9]=r[1]*-n+r[9]*i,this.m[10]=r[2]*-n+r[10]*i,this.m[11]=r[3]*-n+r[11]*i}return this}rotateY(e){if(e){const t=(e||0)*Math.PI/180,n=Math.sin(t),i=Math.cos(t),r=[...this.m];this.m[0]=r[0]*i+r[8]*n,this.m[1]=r[1]*i+r[9]*n,this.m[2]=r[2]*i+r[10]*n,this.m[3]=r[3]*i+r[11]*n,this.m[8]=r[0]*-n+r[8]*i,this.m[9]=r[1]*-n+r[9]*i,this.m[10]=r[2]*-n+r[10]*i,this.m[11]=r[3]*-n+r[11]*i}return this}rotateZ(e){if(e){const t=(e||0)*Math.PI/180,n=Math.sin(t),i=Math.cos(t),r=[...this.m];this.m[0]=r[0]*i+r[4]*n,this.m[1]=r[1]*i+r[5]*n,this.m[2]=r[2]*i+r[6]*n,this.m[3]=r[3]*i+r[7]*n,this.m[4]=r[0]*-n+r[4]*i,this.m[5]=r[1]*-n+r[5]*i,this.m[6]=r[2]*-n+r[6]*i,this.m[7]=r[3]*-n+r[7]*i}return this}getdati(){return Array.from(this.m)}setdati(e){if(e&&16===e.length){for(let t=0;t<16;t++)this.m[t]=Number(e[t])||0;return this}this.init()}push(){return this.st.push(new Float32Array(this.m)),this}pop(){return this.st.length>0&&(this.m=this.st.pop()),this}transform(e,t,n=0){return{x:e*this.m[0]+t*this.m[4]+n*this.m[8]+this.m[12],y:e*this.m[1]+t*this.m[5]+n*this.m[9]+this.m[13],z:e*this.m[2]+t*this.m[6]+n*this.m[10]+this.m[14]}}invert(){const e=this.m,t=new Matrix3D,n=this.determinant();return Math.abs(n)<1e-8?null:(t.m[0]=(e[5]*e[10]*e[15]+e[9]*e[14]*e[7]+e[13]*e[6]*e[11]-e[5]*e[14]*e[11]-e[9]*e[6]*e[15]-e[13]*e[10]*e[7])/n,t.m[1]=(e[1]*e[14]*e[11]+e[9]*e[2]*e[15]+e[13]*e[10]*e[3]-e[1]*e[10]*e[15]-e[9]*e[14]*e[3]-e[13]*e[2]*e[11])/n,t.m[2]=(e[1]*e[6]*e[15]+e[5]*e[14]*e[3]+e[13]*e[2]*e[7]-e[1]*e[14]*e[7]-e[5]*e[2]*e[15]-e[13]*e[6]*e[3])/n,t.m[3]=(e[1]*e[10]*e[7]+e[5]*e[2]*e[11]+e[9]*e[6]*e[3]-e[1]*e[6]*e[11]-e[5]*e[10]*e[3]-e[9]*e[2]*e[7])/n,t.m[4]=(e[4]*e[14]*e[11]+e[8]*e[6]*e[15]+e[12]*e[10]*e[7]-e[4]*e[10]*e[15]-e[8]*e[14]*e[7]-e[12]*e[6]*e[11])/n,t.m[5]=(e[0]*e[10]*e[15]+e[8]*e[14]*e[3]+e[12]*e[2]*e[11]-e[0]*e[14]*e[11]-e[8]*e[2]*e[15]-e[12]*e[10]*e[3])/n,t.m[6]=(e[0]*e[14]*e[7]+e[4]*e[2]*e[15]+e[12]*e[6]*e[3]-e[0]*e[6]*e[15]-e[4]*e[14]*e[3]-e[12]*e[2]*e[7])/n,t.m[7]=(e[0]*e[6]*e[11]+e[4]*e[10]*e[3]+e[8]*e[2]*e[7]-e[0]*e[10]*e[7]-e[4]*e[2]*e[11]-e[8]*e[6]*e[3])/n,t.m[8]=(e[4]*e[9]*e[15]+e[8]*e[13]*e[7]+e[12]*e[5]*e[11]-e[4]*e[13]*e[11]-e[8]*e[5]*e[15]-e[12]*e[9]*e[7])/n,t.m[9]=(e[0]*e[13]*e[11]+e[8]*e[1]*e[15]+e[12]*e[9]*e[3]-e[0]*e[9]*e[15]-e[8]*e[13]*e[3]-e[12]*e[1]*e[11])/n,t.m[10]=(e[0]*e[5]*e[15]+e[4]*e[13]*e[3]+e[12]*e[1]*e[7]-e[0]*e[13]*e[7]-e[4]*e[1]*e[15]-e[12]*e[5]*e[3])/n,t.m[11]=(e[0]*e[9]*e[7]+e[4]*e[1]*e[11]+e[8]*e[5]*e[3]-e[0]*e[5]*e[11]-e[4]*e[9]*e[3]-e[8]*e[1]*e[7])/n,t.m[12]=(e[4]*e[13]*e[10]+e[8]*e[5]*e[14]+e[12]*e[9]*e[6]-e[4]*e[9]*e[14]-e[8]*e[13]*e[6]-e[12]*e[5]*e[10])/n,t.m[13]=(e[0]*e[9]*e[14]+e[8]*e[13]*e[2]+e[12]*e[1]*e[10]-e[0]*e[13]*e[10]-e[8]*e[1]*e[14]-e[12]*e[9]*e[2])/n,t.m[14]=(e[0]*e[13]*e[6]+e[4]*e[1]*e[14]+e[12]*e[5]*e[2]-e[0]*e[5]*e[14]-e[4]*e[13]*e[2]-e[12]*e[1]*e[6])/n,t.m[15]=(e[0]*e[5]*e[10]+e[4]*e[9]*e[2]+e[8]*e[1]*e[6]-e[0]*e[9]*e[6]-e[4]*e[1]*e[10]-e[8]*e[5]*e[2])/n,t)}determinant(){const e=this.m;return e[0]*(e[5]*e[10]*e[15]+e[9]*e[14]*e[7]+e[13]*e[6]*e[11]-e[5]*e[14]*e[11]-e[9]*e[6]*e[15]-e[13]*e[10]*e[7])-e[4]*(e[1]*e[10]*e[15]+e[9]*e[14]*e[3]+e[13]*e[2]*e[11]-e[1]*e[14]*e[11]-e[9]*e[2]*e[15]-e[13]*e[10]*e[3])+e[8]*(e[1]*e[6]*e[15]+e[5]*e[14]*e[3]+e[13]*e[2]*e[7]-e[1]*e[14]*e[7]-e[5]*e[2]*e[15]-e[13]*e[6]*e[3])-e[12]*(e[1]*e[6]*e[11]+e[5]*e[10]*e[3]+e[9]*e[2]*e[7]-e[1]*e[10]*e[7]-e[5]*e[2]*e[11]-e[9]*e[6]*e[3])}multiply(e){const t=[...this.m],n=e.m;return this.m[0]=t[0]*n[0]+t[4]*n[1]+t[8]*n[2]+t[12]*n[3],this.m[1]=t[1]*n[0]+t[5]*n[1]+t[9]*n[2]+t[13]*n[3],this.m[2]=t[2]*n[0]+t[6]*n[1]+t[10]*n[2]+t[14]*n[3],this.m[3]=t[3]*n[0]+t[7]*n[1]+t[11]*n[2]+t[15]*n[3],this.m[4]=t[0]*n[4]+t[4]*n[5]+t[8]*n[6]+t[12]*n[7],this.m[5]=t[1]*n[4]+t[5]*n[5]+t[9]*n[6]+t[13]*n[7],this.m[6]=t[2]*n[4]+t[6]*n[5]+t[10]*n[6]+t[14]*n[7],this.m[7]=t[3]*n[4]+t[7]*n[5]+t[11]*n[6]+t[15]*n[7],this.m[8]=t[0]*n[8]+t[4]*n[9]+t[8]*n[10]+t[12]*n[11],this.m[9]=t[1]*n[8]+t[5]*n[9]+t[9]*n[10]+t[13]*n[11],this.m[10]=t[2]*n[8]+t[6]*n[9]+t[10]*n[10]+t[14]*n[11],this.m[11]=t[3]*n[8]+t[7]*n[9]+t[11]*n[10]+t[15]*n[11],this.m[12]=t[0]*n[12]+t[4]*n[13]+t[8]*n[14]+t[12]*n[15],this.m[13]=t[1]*n[12]+t[5]*n[13]+t[9]*n[14]+t[13]*n[15],this.m[14]=t[2]*n[12]+t[6]*n[13]+t[10]*n[14]+t[14]*n[15],this.m[15]=t[3]*n[12]+t[7]*n[13]+t[11]*n[14]+t[15]*n[15],this}}const gt=.001;class Punto2{constructor(e,t){Array.isArray(e)?(this.x=e[0]||0,this.y=e[1]||0):e&&"object"==typeof e?(this.x=e.x||0,this.y=e.y||0):(this.x=e||0,this.y=t||0)}get dump(){return`{${this.x.toFixed(1)},${this.y.toFixed(1)}}`}get len2(){return this.x*this.x+this.y*this.y}get len(){return Math.sqrt(this.len2)}get angle(){return Math.atan2(this.y,this.x)}dir(){let e=this.len;return e?new Punto2(this.x/e,this.y/e):this}puntosucerchio(e=0,t=0){const n=t*Math.PI/180;return new Punto2(this.x+e*Math.cos(n),this.y+e*Math.sin(n))}tangentesucerchio(e=0,t=0,n=100){const i=t*Math.PI/180,r=this.x+e*Math.cos(i),s=this.y+e*Math.sin(i),o=i+Math.PI/2,a=r+n*Math.cos(o),A=s+n*Math.sin(o);return new Linea2(r,s,a,A)}angolo3p(e,t){let n=this;const i=e.x-n.x,r=e.y-n.y,s=t.x-n.x,o=t.y-n.y,a=i*s+r*o,A=Math.hypot(i,r),l=Math.hypot(s,o);if(!A||!l)return 0;let c=180*Math.acos(a/(A*l))/Math.PI;return c>180&&(c=360-c),c}distanza(e){return new Punto2(e.x-this.x,e.y-this.y).len}}class Linea2{constructor(e,t,n=null,i=null){"number"==typeof e&&"number"==typeof t&&null!==n&&null!==i?(this.p1=new Punto2({x:e,y:t}),this.p2=new Punto2({x:n,y:i})):e&&t?(this.p1=new Punto2(e),this.p2=new Punto2(t)):(this.p1=new Punto2(0,0),this.p2=new Punto2(1,0))}get dump(){return`${this.p1.dump}-${this.p2.dump}`}get dx(){return this.p2.x-this.p1.x}get dy(){return this.p2.y-this.p1.y}get len2(){let{dx:e,dy:t}=this;return e*e+t*t}get len(){return Math.sqrt(this.len2)}get angle(){return this.angolo()}estendi(e){if("number"==typeof e){if(!e)return this;let{p1:t,p2:n,dx:i,dy:r,len:s}=this;return s?(i/=s,r/=s,e>0?new Linea2(t,new Punto2(n.x+i*e,n.y+r*e)):new Linea2(new Punto2(t.x+i*e,t.y+r*e),n)):this}if(e instanceof Linea2){const t=this.interseca(e);if(!t)return this;return(t.x-this.p1.x)**2+(t.y-this.p1.y)**2<(t.x-this.p2.x)**2+(t.y-this.p2.y)**2?new Linea2(t,this.p2):new Linea2(this.p1,t)}}puntot(e){return new Punto2(this.p1.x+(this.p2.x-this.p1.x)*e,this.p1.y+(this.p2.y-this.p1.y)*e)}setlunghezza(e){let t=this.len;if(t&&e){let n=e/t,i=this.puntot(n);this.p2=i}}proiezionet(e){const{p1:t,dx:n,dy:i,len2:r}=this;if(r<gt)return;const s=((e.x-t.x)*n+(e.y-t.y)*i)/r;return{p:new Punto2(t.x+s*n,t.y+s*i),t:s}}proiezione(e){const t=this.proiezionet(e);return t?t.p:void 0}get direzione(){let{dx:e,dy:t,len:n}=this;return n?new Punto2(e/n,t/n):new Punto2(0,0)}get normale(){let{dx:e,dy:t,len:n}=this;return n?new Punto2(-t/n,e/n):new Punto2(0,1)}perpendicolare(e=null,t=0){const{normale:n,len:i,p1:r}=this;if(i<1e-9)return;const s=t||i,o=e?new Punto2(e):this.p1;return new Linea2(o,new Punto2(o.x+n.x*s,o.y+n.y*s))}perpendicolaret(e,t=0){const{normale:n,len:i,p1:r,p2:s}=this;if(i<1e-9)return;const o=t||i,a=new Punto2(r.x+(s.x-r.x)*e,r.y+(s.y-r.y)*e);return new Linea2(a,new Punto2(a.x+n.x*o,a.y+n.y*o))}rotatedonp1(e){const t=e*Math.PI/180,n=this.p2.x-this.p1.x,i=this.p2.y-this.p1.y,r=Math.cos(t),s=Math.sin(t),o=this.p1.x+n*r-i*s,a=this.p1.y+n*s+i*r;return new Linea2(this.p1,{x:o,y:a})}rotatedonp2(e){const t=e*Math.PI/180,n=this.p1.x-this.p2.x,i=this.p1.y-this.p2.y,r=Math.cos(t),s=Math.sin(t),o=this.p2.x+n*r-i*s,a=this.p2.y+n*s+i*r;return new Linea2(this.p2,{x:o,y:a})}ruotata(e=Math.PI/2,t=0,n=!1){const{p1:i,p2:r,direzione:s,len:o}=this;if(t=t||o,o<1e-9)return;const a=Math.abs(e%(2*Math.PI));if(!(a<1e-9||Math.abs(a-Math.PI)<1e-9)){if("boolean"==typeof n){const o=(s.x*Math.cos(e)-s.y*Math.sin(e))*t,a=(s.x*Math.sin(e)+s.y*Math.cos(e))*t;return n?new Linea2(i,new Punto2(i.x+o,i.y+a)):new Linea2(r,new Punto2(r.x+o,r.y+a))}{let i=new Punto2(n);const r=s.x*Math.cos(e)-s.y*Math.sin(e),o=s.x*Math.sin(e)+s.y*Math.cos(e);new Punto2(r,o);const a=new Linea2(i,new Punto2(i.x+r,i.y+o)),A=this.interseca(a);if(!A)return;const l=new Punto2(A.x+r*t,A.y+o*t);return new Linea2(A,l)}}}puntosudirezione(e,t){let{direzione:n}=this;return new Punto2(e.x+n.x*t,e.y+n.y*t)}parallela(e,t){let{direzione:n}=this;return new Linea2(e,this.puntosudirezione(e,t))}intersezione(e){return this.interseca(e)}interseca(e){const{p1:t,p2:n}=this,{p1:i,p2:r}=e,s=(n.x-t.x)*(r.y-i.y)-(n.y-t.y)*(r.x-i.x);if(Math.abs(s)<gt)return null;const o=((i.x-t.x)*(r.y-i.y)-(i.y-t.y)*(r.x-i.x))/s;return new Punto2(t.x+o*(n.x-t.x),t.y+o*(n.y-t.y))}onsegment(e,t=1e-9){const{p1:n,p2:i}=this,r=i.x-n.x,s=i.y-n.y,o=e.x-n.x,a=e.y-n.y;if(Math.abs(r*a-s*o)>t)return!1;const A=o*r+a*s;if(A<-t)return!1;return!(A>r*r+s*s+t)}distanzaPunto(e){const t=this.proiezione(e);if(!t)return 1e9;const n=e.x-t.x,i=e.y-t.y;return Math.hypot(n,i)}isparallela(e){const t=this.dx*e.dy-this.dy*e.dx;return Math.abs(t)<1}lunghezzatotale(e){const t=this.p2.x-this.p1.x,n=this.p2.y-this.p1.y,i=Math.hypot(t,n);if(!i)return 0;const r=1/i,proj=e=>(e.x*t+e.y*n)*r,s=proj(this.p1),o=proj(this.p2),a=proj(e.p1),A=proj(e.p2),l=s<o?s:o,c=s>o?s:o,p=a<A?a:A,h=a>A?a:A;return Math.round(100*(Math.max(c,h)-Math.min(l,p)))/100}infoquad(e){if(!this.isparallela(e))return;const{p1:t,p2:n,normale:i}=this;let{p1:r,p2:s}=e;const distance2=(e,t)=>(e.x-t.x)**2+(e.y-t.y)**2;function wrapToPi(e){return e>Math.PI?e-=2*Math.PI:e<-Math.PI&&(e+=2*Math.PI),e}function getangle(e,t){return Math.atan2(t.y-e.y,t.x-e.x)}distance2(t,r)>distance2(t,s)&&([r,s]=[s,r]);const o=getangle(t,n);function toDeg(e){return Math.round(18e4*e/Math.PI)/1e3}const a=toDeg(wrapToPi(getangle(t,r)-o)),A=toDeg(wrapToPi(getangle(n,s)-o)),l=Math.round(100*this.len)/100,c=r.x-t.x,p=r.y-t.y,h=Math.round(100*Math.abs(c*i.x+p*i.y))/100;let u=this.lunghezzatotale(e);return{angle:toDeg(o),aini:a,afin:A,l:l,ltot:u,distanza:h,sx:Math.round(100*t.x)/100,sy:Math.round(100*t.y)/100}}isperpendicolare(e){const t=this.dx*e.dx+this.dy*e.dy;return Math.abs(t)<gt}offset(e){const t=this.normale,n=new Punto2(this.p1.x+t.x*e,this.p1.y+t.y*e),i=new Punto2(this.p2.x+t.x*e,this.p2.y+t.y*e);return new Linea2(n,i)}angolo(e){const{dx:t,dy:n}=this;let i;if(e){const{dx:r,dy:s}=e,o=Math.atan2(n,t);i=Math.atan2(s,r)-o}else i=Math.atan2(n,t);return i>Math.PI?i-=2*Math.PI:i<-Math.PI&&(i+=2*Math.PI),i}ortopt(e){let{p1:t,dx:n,dy:i}=this;const r=Math.hypot(n,i);if(r<gt)return;const s=-i/r,o=n/r;return{x:t.x+s*e,y:t.y+o*e}}offsetline(e){let{p1:t,p2:n,dx:i,dy:r}=this;const s=Math.hypot(i,r);if(s<gt)return;const o=-r/s,a=i/s;return new Linea2({x:t.x+o*e,y:t.y+a*e},{x:n.x+o*e,y:n.y+a*e})}distanzaSegmentiParalleli(e){if(!this.isparallela(e))return 1e9;const{p1:t,normale:n}=this,i=e.p1.x-t.x,r=e.p1.y-t.y,s=Math.abs(i*n.x+r*n.y);return Math.abs(s)<gt?0:s}isCollineare(e,t=!1){if(!this.isparallela(e))return!1;const n=this.distanzaSegmentiParalleli(e);if(Math.abs(n)>gt)return!1;if(t){function isPointBetween(e,t,n,i=gt){const r=(n.x-t.x)*(e.y-t.y)-(n.y-t.y)*(e.x-t.x);return!(Math.abs(r)>i)&&(Math.min(t.x,n.x)-i<=e.x&&e.x<=Math.max(t.x,n.x)+i&&Math.min(t.y,n.y)-i<=e.y&&e.y<=Math.max(t.y,n.y)+i)}const{p1:i,p2:r}=this,{p1:s,p2:o}=e;return isPointBetween(s,i,r)||isPointBetween(o,i,r)||isPointBetween(i,s,o)||isPointBetween(r,s,o)}return!0}clone(){return new Linea2(this.p1.x,this.p1.y,this.p2.x,this.p2.y)}rotate(e){if(!e)return this;const t=e*Math.PI/180,n=Math.cos(t),i=Math.sin(t);function rotate(e){return new Punto2(e.x*n-e.y*i,e.x*i+e.y*n)}return this.p1=rotate(this.p1),this.p2=rotate(this.p2),this}move(e=0,t=0){return"object"==typeof e&&e.x&&(t=e.y||0,e=e.x),this.p1.x+=e,this.p1.y+=t,this.p2.x+=e,this.p2.y+=t,this}}function getptsoffset(e,t,n){let i,r,s,o,a=-1,A=-1,l=e.length,c=t.length,p=[],h=new Linea2(e[0],e[1]),u=new Linea2(e[l-2],e[l-1]),d=h.offset(n),g=u.offset(n);for(let e=0;e<c;e++){let n=new Linea2(t[e%c],t[(e+1)%c]);d.isparallela(n)&&d.isCollineare(n,!0)&&(a=e),g.isparallela(n)&&g.isCollineare(n,!0)&&(A=e)}if(a>=0&&A>=0){a>A?(i=a-A+2,r=A+c-a+2,i<r?(s=A,o=a+1):(s=a,o=A+c+1)):(i=A-a+2,r=a+c-A+2,i<r?(s=a,o=A+1):(s=A,o=a+c+1));for(let e=s;e<=o;e++)p.push(t[e%c])}return p}async function errorescript(e,t,n){let i,r,s,o=(t.stack||"").match(/user-script\.js:(\d+):(\d+)/);if(o||(o=(t.toString()||"").match(/user-script\.js:(\d+):(\d+)/)),o&&([,i,r]=o.map(Number),i-=2),(!i||!r)&&t instanceof SyntaxError){window.acorn||(await new Promise(((e,t)=>{const n=document.createElement("script");n.src="https://cdn.jsdelivr.net/npm/acorn@8.15.0/dist/acorn.js",n.onload=e,n.onerror=t,document.head.appendChild(n)})),console.log("caricato acorn"));try{window.acorn.parse(e,{ecmaVersion:"latest"})}catch(e){e.loc&&(i=e.loc.line,r=e.loc.column+1)}}if(i&&r)s=`ERRORE:${n?" f:"+n:""} ${t.message.replace}\n`+function extractContext(e,t,n,i=1){const r=e.split(/\r?\n/),s=t-1,o=Math.max(0,s-i),a=Math.min(r.length,s+i+1);return r.slice(o,a).map(((e,i)=>o+i+1===t?e+"\n"+" ".repeat(n-1)+"^":e)).join("\n")}(e,i,r);else{let e=t.stack?.toString()||t.message||"";e=e.replace("Error: ","").replaceAll("\n\n","\n"),s=`ERRORE:${n?" f:"+n:""} ${e}`}return s}function seedarray(e,t){if(e&&e.length){let n=[];for(let t=0;t<e.length;t++){let i=e[t];if(i.p)for(let e=0;e<i.p;e++)n.push(t);else n.push(t)}return e[n[seeder(n.length,t)]]}}function seeder(e,t="seed42"){const n=function mulberry32(e){return function(){e=(e|=0)+1831565813|0;let t=Math.imul(e^e>>>15,1|e);return t=t+Math.imul(t^t>>>7,61|t)^t,((t^t>>>14)>>>0)/4294967296}}(function xmur3(e){let t=1779033703^e.length;for(let n=0;n<e.length;n++)t=Math.imul(t^e.charCodeAt(n),3432918353),t=t<<13|t>>>19;return function(){return t=Math.imul(t^t>>>16,2246822507),t=Math.imul(t^t>>>13,3266489909),(t^=t>>>16)>>>0}}(String(t))());return Math.floor(n()*e)}function hash(e){let t="";if("string"==typeof e||"number"==typeof e)t=e+"";else if("object"==typeof e&&e){const n=Object.keys(e).sort(),i="\0";t=n.map((t=>`${t}${i}${String(e[t])}`)).join(i)}let n=2166136261,i=2218511855;for(let e=0;e<t.length;e++){const r=t.charCodeAt(e);n^=r,n+=n<<5^2779096485,i^=n,i=((i<<3)+r^2134516169)>>>0}return n>>>=0,n.toString(16)+i.toString(16)}function clean(e,t=!1){return t?(e||"").trim().toLowerCase():(e||"").trim()}function getcouple(e,t="=",n=!0){const i=(e=e||"").indexOf(t);return i>=0?{v:clean(e.substring(0,i),n),o:e.substring(i+t.length).trim(),fl:!0}:{v:clean(e,n),o:"",fl:!1}}function clamp(e,t=-1/0,n=1/0){return(e=Number(e)||0)<t&&(e=t),e>n&&(e=n),e}function getcolonne(e,t=!1){e=String(e||"");const n=/^(\d*)\.\.(\d*)$/.exec(e);if(n){let e=parseInt(n[1])||0,t=parseInt(n[2])||0;const i=[];for(let n=e;n<=t;n++)i.push(n+"");return i}if(!/["({[]/.test(e))return e.split(/[,;]/).map((e=>e.trim()));const i=[];let r="",s=0,o=!1;for(let t=0;t<e.length;t++){const n=e[t];if(0===s&&'"'===n&&(0!==t&&"\\"===e[t-1]||(o=!o)),o||("("===n||"["===n||"{"===n?s++:")"!==n&&"]"!==n&&"}"!==n||(s=Math.max(0,s-1))),","!==n&&";"!==n||0!==s||o)r+=n;else{const e=r.trim();i.push(e),r=""}}const a=r.trim();return a&&i.push(a),i.map((e=>(e=e.trim(),!t&&(e.startsWith('"')&&e.endsWith('"')||e.startsWith("(")&&e.endsWith(")"))?e.slice(1,-1):e)))}new class Errori{constructor(){this.azzera()}azzera(){this.err=[]}add(e,t){this.err.push({msg:e,row:t})}get(){return this.err}get length(){return this.err.length}toString(){const e=[];for(const t of this.err){const n="object"==typeof t.msg?JSON.stringify(t.msg):t.msg||"";e.push(`${t.row?t.row+":":""}${n}`)}return e.join("\n")}};const round=(e,t=-1)=>{const n="string"==typeof e?parseFloat(e)||0:e;if(t<0)return Math.round(n||0);const i=Math.pow(10,t);return Math.round(n*i)/i||0};function muClComments(e,t){const n=(i=e,i.replace(/("(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*')|\/\*[\s\S]*?\*\//g,((e,t)=>t||""))).split(/\r?\n/);var i;const r=[];let s="";for(const e of n){let t=e;if(/(^|[^:])\/\/.*/.test(t)&&(t=t.replace(/(^|[^:])\/\/.*/,((e,t)=>t.trim()))),t=t.trim(),0!==t.length)if(s.length>0&&(t=s+" "+t,s=""),t.endsWith("\\")){t=t.slice(0,-1);const e=t.lastIndexOf("//");-1!==e&&(t=t.slice(0,e).trim()),s=t}else r.push(t)}return r}const ft=Math.PI/180;function TODEG(e,t=1){let n=10**t;return Math.round(180*e*n/Math.PI)/n}function TORAD(e,t=3){let n=10**t;return Math.round(e*ft*n)/n}const mt={window:void 0,self:void 0,globalThis:void 0,document:void 0,Function:void 0,eval:void 0,fetch:void 0,XMLHttpRequest:void 0};function getOggetto(e,t=[]){if(Array.isArray(e))return e.map((e=>getOggetto(e,t)));if(e&&"object"==typeof e){const n={};for(const[i,r]of Object.entries(e))"function"==typeof r||t&&t.includes(i)||(n[i]=getOggetto(r,t));return n}return e}function getSqDist(e,t){let n=e.x-t.x,i=e.y-t.y;return n*n+i*i}function getSqSegDist(e,t,n){let i=t.x,r=t.y,s=n.x-i,o=n.y-r;if(0!==s||0!==o){let t=((e.x-i)*s+(e.y-r)*o)/(s*s+o*o);t>1?(i=n.x,r=n.y):t>0&&(i+=s*t,r+=o*t)}return s=e.x-i,o=e.y-r,s*s+o*o}function simplifyDPStep(e,t,n,i,r){let s,o=i;for(let i=t+1;i<n;i++){let r=getSqSegDist(e[i],e[t],e[n]);r>o&&(s=i,o=r)}o>i&&(s-t>1&&simplifyDPStep(e,t,s,i,r),r.push(e[s]),n-s>1&&simplifyDPStep(e,s,n,i,r))}function simplifyDouglasPeucker(e,t){let n=e.length-1,i=[e[0]];return simplifyDPStep(e,0,n,t,i),i.push(e[n]),i}function simplify(e,t,n){if(e.length<=2)return e;let i=void 0!==t?t*t:1;return e=n?e:function simplifyRadialDist(e,t){let n,i=e[0],r=[i];for(let s=1,o=e.length;s<o;s++)n=e[s],getSqDist(n,i)>t&&(r.push(n),i=n);return i!==n&&r.push(n),r}(e,i),e=simplifyDouglasPeucker(e,i)}function mapvertices(e,t){const dist2=(e,t)=>(e.x-t.x)**2+(e.y-t.y)**2;let n=e.length,i=t.length;if(n<2||i<2)return[];let r=[[0,0]];if(n===i){for(let e=1;e<n;e++)r.push([e,e]);return r}if(n>i)for(let s=1,o=0;s<n-1;s++){if(o+1<i){const n=e[s],i=dist2(n,t[o]);dist2(n,t[o+1])<=i&&o++}r.push([s,o])}else for(let s=1,o=0;s<i-1;s++){if(o+1<n){const n=t[s],i=dist2(n,e[o]);dist2(n,e[o+1])<=i&&o++}r.push([o,s])}return r.push([n-1,i-1]),r}function dxfbulge(e,t,n,i=0){const r=[];if(!n||Math.abs(n)<1e-10||0===i)return r;const s=4*Math.atan(n);if(s<0)return dxfbulge(t,e,-n,i).reverse();const o=t.x-e.x,a=t.y-e.y,A=Math.hypot(o,a),l=A/(2*Math.sin(s/2)),c=(e.x+t.x)/2,p=(e.y+t.y)/2,h=-a/A,u=o/A,d=l*Math.cos(s/2),g=n>=0?1:-1,f=c+g*h*d,m=p+g*u*d;let y=Math.atan2(e.y-m,e.x-f);for(let e=1;e<=i;e++){const t=y+e/(i+1)*s,n=f+l*Math.cos(t),o=m+l*Math.sin(t);r.push({x:n,y:o})}return r}function raccordabezier(e,t,n,i,r=10){const s=function getIntersection(e,t,n,i){const r=(e.x-t.x)*(n.y-i.y)-(e.y-t.y)*(n.x-i.x);return 0===r?null:{x:((e.x*t.y-e.y*t.x)*(n.x-i.x)-(e.x-t.x)*(n.x*i.y-n.y*i.x))/r,y:((e.x*t.y-e.y*t.x)*(n.y-i.y)-(e.y-t.y)*(n.x*i.y-n.y*i.x))/r}}(e,t,n,i);if(!s)return[{x:t.x,y:t.y},{x:n.x,y:n.y}];const o=s;if(0===r)return[{x:t.x,y:t.y},{x:n.x,y:n.y}];const a=[];for(let e=0;e<=r;e++){const i=e/r,s=1-i,A=s*s*t.x+2*s*i*o.x+i*i*n.x,l=s*s*t.y+2*s*i*o.y+i*i*n.y;a.push({x:A,y:l})}return a}function raccordabezier3(e,t,n,i,r=10){const s=t.x-e.x,o=t.y-e.y,a=n.x-t.x,A=n.y-t.y,l=Math.sqrt(s*s+o*o),c=Math.sqrt(a*a+A*A);if(i>l||i>c)return[e,t,n];i!=l&&i!=c||(i-=.01);const p=(l-i)/l,h=i/c;return raccordabezier(e,{x:e.x+s*p,y:e.y+o*p},{x:t.x+a*h,y:t.y+A*h},n,r)}function normal2(e,t){const n=t.x-e.x;let i=-(t.y-e.y),r=n;const s=Math.sqrt(i*i+r*r);return 0===s?{nx:0,ny:0}:{nx:i/s,ny:r/s}}function angle3point(e,t,n){const i=t.x-e.x,r=t.y-e.y,s=n.x-t.x,o=n.y-t.y,a=i*s+r*o,A=i*o-r*s,l=Math.sqrt(i**2+r**2),c=Math.sqrt(s**2+o**2);return l&&c?Math.atan2(A,a):0}function angle2vec(e,t){const n=e.x*t.x+e.y*t.y,i=Math.sqrt(e.x*e.x+e.y*e.y),r=Math.sqrt(t.x*t.x+t.y*t.y);if(0===i||0===r)return 0;let s=n/(i*r);s=Math.max(-1,Math.min(1,s));return Math.acos(s)/ft}function removeduplicate(e,t=.005){if(!Array.isArray(e)||0===e.length)return[];const n=[],i=e.length;for(let t=0;t<i;t++){const r=e[t],s=e[(t+1)%i];n.push({x:r.x,y:r.y}),s.x,r.x,s.y,r.y}const r=n[0],s=n[n.length-1];return r.x,s.x,r.y,s.y,n}function infocircle(e,t,n,i,r,s){let o,a,A;"object"==typeof e?(o=e,a=t,A=n):(o=new Punto2(e,t),a=new Punto2(n,i),A=new Punto2(r,s));const l=(o.x+a.x)/2,c=(o.y+a.y)/2,p=(a.x+A.x)/2,h=(a.y+A.y)/2,u=a.x-o.x,d=a.y-o.y,g=A.x-a.x,f=-d,m=-(A.y-a.y),y=f*g-u*m;if(!y)return null;const b=((p-l)*g-(h-c)*m)/y,I=l+b*f,x=c+b*u,C=Math.hypot(o.x-I,o.y-x),B=180/Math.PI;let E=Math.atan2(o.y-x,o.x-I),w=Math.atan2(A.y-x,A.x-I);const v=Math.atan2(a.y-x,a.x-I);return w<E&&(w+=2*Math.PI),v<E&&(E+=2*Math.PI),v>w&&(w+=2*Math.PI),E*=B,w*=B,E=(E%360+360)%360,w=(w%360+360)%360,{center:new Punto2(round(I,1),round(x,1)),r:round(C,1),ang1:round(E,1),ang2:round(w,1)}}function intersectcircle(e,t,n,i,r){const s=r.x-i.x,o=r.y-i.y,a=i.x-e,A=i.y-t,l=s*s+o*o,c=2*(a*s+A*o),p=c*c-4*l*(a*a+A*A-n*n);if(p<=0)return null;const h=Math.sqrt(p),u=(-c-h)/(2*l),d=(-c+h)/(2*l),g=i.x+u*s,f=i.y+u*o,m=i.x+d*s,y=i.y+d*o,b=180/Math.PI;let I=Math.atan2(f-t,g-e)*b,x=Math.atan2(y-t,m-e)*b;return I=(I%360+360)%360,x=(x%360+360)%360,[I,x]}function getshape(){let e=[];function orientation(){if(!e.length)return 0;let t=0;const n=e.length;for(let i=0;i<n;i++){const r=e[i],s=e[(i+1)%n];t+=r.x*s.y-s.x*r.y}return t>0?1:t<0?-1:0}function tovec(){return e.flatMap((e=>[e.x,e.y]))}function move(t=0,n=0){"object"==typeof t&&t.x&&(n=t.y||0,t=t.x);for(let i of e)i.x+=t,i.y+=n;return this}function selezionaprimo(t){return(t%=e.length)>0&&(e=[...e.slice(t),...e.slice(0,t)]),this}function _addvec(t){for(let n=0;n<t.length;n+=2)e.push({x:t[n],y:t[n+1]})}function fromstr(t){return e=removeduplicate(function processTokens(e){const t=[];for(let n=0;n<e.length;n++){const i=e[n];if("point"===i.type)t.push(i.point);else if("command"===i.type)switch(i.cmd){case"x":{const r=t[t.length-1],s="point"===e[n+1]?.type?e[n+1].point:t[0],o=parseFloat(i.params[0])||5;{const e=1;let n=s.x-r.x,i=s.y-r.y,a=Math.hypot(n,i);a>1&&t.push(...dxfbulge(r,s,o,Math.floor((a-e)/(e+2))+1))}break}case"b":{if(t.length<2)continue;const r=parseInt(i.params[0])||5,s=t[t.length-2],o=t[t.length-1];let a="point"===e[n+1]?.type?e[n+1].point:void 0,A="point"===e[n+2]?.type?e[n+2].point:void 0;a?A||(A=t[0]):(a=t[0],A=t[1]);const l=raccordabezier(s,o,a,A,r);t.push(...l),n+=1;break}case"r":{if(t.length<1)continue;const r=parseFloat(i.params[0])||0;if(r>0){const s=parseInt(i.params[1])||Math.min(r,10),o=t[t.length-1];let a="point"===e[n+1]?.type?e[n+1].point:void 0,A="point"===e[n+2]?.type?e[n+2].point:"point"===e[n+3]?.type?e[n+3].point:void 0;a?A||(A=t[0]):(a=t[0],A=t[1],t.splice(0,1));const l=raccordabezier3(o,a,A,r,s);t.push(...l),n+=1}break}case"c":{let r,s;if(i.params[0].includes("/")){let e=i.params[0].split("/");r=parseFloat(e[0])||50,s=parseFloat(e[1])||r||50}else r=parseFloat(i.params[0])||50,s=r;let o=(parseFloat(i.params[2])||0)*ft,a=(parseFloat(i.params[3])||0)*ft;const A=parseInt(i.params[1])||12,l="point"===e[n+1]?.type?e[n+1].point:new Punto2(0,0);for(let e=0;e<=A;e++){let n,i;if(o||a){let t=a-o;n=r*Math.cos(e/A*t+o),i=s*Math.sin(e/A*t+o)}else n=r*Math.cos(e/A*Math.PI*2+Math.PI),i=s*Math.sin(e/A*Math.PI*2+Math.PI);t.push(new Punto2(l.x+n,l.y+i))}n+=1;break}case"a":{let r,s="point"===e[n+1]?.type?e[n+1].point:void 0,o="point"===e[n+2]?.type?e[n+2].point:void 0,a="point"===e[n+3]?.type?e[n+3].point:void 0;if(!s||!a)continue;if(o)if(i.params[0])r=clamp(parseInt(i.params[0]),1,40);else{const e=Math.hypot(a.x-s.x,a.y-s.y),t=Math.abs((o.x-s.x)*(a.y-s.y)-(a.x-s.x)*(o.y-s.y))/(2*e);r=Math.round(e*Math.sqrt(t/(e+.1))*10),r=clamp(r,1,24),r=1}else o=a,r=0;const A=arcfrom3point(r,s,o,a);t.push(...A),n+=3;break}}}return t}(function tokenize(e){const t=[],n=e.replace(/[\n\r,;]/g," ").replace(/\s+/g," ").toLowerCase().trim().split(" ").filter((e=>e.length>0));let i=0;for(;i<n.length;){const e=n[i];/^[brcax]/.test(e)?(t.push({type:"command",cmd:e[0],params:e.slice(1).split(":")}),i++):i<n.length-1&&/^-?\d+(\.\d+)?$/.test(n[i])&&/^-?\d+(\.\d+)?$/.test(n[i+1])?(t.push({type:"point",point:new Punto2(parseFloat(n[i]),parseFloat(n[i+1]))}),i+=2):i++}return t}(t))),this}function dims(e){let{p1:t,p2:n}=e.reduce(((e,t)=>(e.p1.x=Math.min(e.p1.x,t.x),e.p2.x=Math.max(e.p2.x,t.x),e.p1.y=Math.min(e.p1.y,t.y),e.p2.y=Math.max(e.p2.y,t.y),e)),{p1:new Punto2(1/0,1/0),p2:new Punto2(-1/0,-1/0)}),i=!1;if(4==e.length){const r=.001;function findpunto(t,n){return!!e.find((e=>Math.abs(e.x-t)<r&&Math.abs(e.y-n)<r))}findpunto(t.x,t.y)&&findpunto(t.x,n.y)&&findpunto(n.x,t.y)&&findpunto(n.x,n.y)&&(i=!0)}return{p1:t,p2:n,isrect:i,width:n.x-t.x,height:n.y-t.y}}return{get key(){return hash(tovec().join("\t"))},orienta:function orienta(t,n){if(!t||!n)return null;const i=n.x-t.x,r=n.y-t.y,s=180*Math.atan2(r,i)/Math.PI,o=new Matrix3D;o.rotateZ(-s),o.translate(-t.x,-t.y,0);const a=e.map((e=>o.transform(e.x,e.y)));let A=a.reduce(((e,t)=>(e.p1.x=Math.min(e.p1.x,t.x),e.p2.x=Math.max(e.p2.x,t.x),e.p1.y=Math.min(e.p1.y,t.y),e.p2.y=Math.max(e.p2.y,t.y),e)),{p1:new Punto2(1/0,1/0),p2:new Punto2(-1/0,-1/0)});return{shape:getshape().frompt(a),origine:new Punto2(t.x,t.y),angolo:s,mm:A,width:A.p2.x-A.p1.x,height:A.p2.y-A.p1.y}},rebase:function rebase(t,n=!1,i=0,r=0){const s=new Matrix3D;s.rotateZ(-t);let o=e.map((e=>s.transform(e.x,e.y))),{p1:a,p2:A,width:l,height:c}=dims(o);return n||(i=a.x,r=a.y),o=o.map((e=>new Punto2(e.x-i,e.y-r))),{shape:getshape().frompt(o),origine:new Punto2(i,r),angolo:t,width:l,height:c}},fromstr:fromstr,move:move,infocircle:infocircle,intersectcircle:intersectcircle,get pt(){return e},set pt(t){Array.isArray(t)&&(e=t)},get npt(){return e?.length||0},get vec(){return tovec()},toJSON:()=>({vec:tovec(),orient:orientation()}),get orient(){return orientation()},corners:(t=45)=>function sharpCorners(e,t=45){const n=[],i=e.length;if(i<3)return n;for(let r=0;r<i;r++){const s=e[(r-1+i)%i],o=e[r],a=e[(r+1)%i],A=o.x-s.x,l=o.y-s.y,c=a.x-o.x,p=a.y-o.y,h=Math.hypot(A,l),u=Math.hypot(c,p);if(0===h||0===u)continue;let d=(A*c+l*p)/(h*u);d=Math.max(-1,Math.min(1,d));const g=180*Math.acos(d)/Math.PI;g>t&&n.push({i:r,x:o.x,y:o.y,a:g})}return n}(e,45),clone:()=>getshape().frompt(e),dims(){let t=dims(e),n=0;for(let t=0;t<e.length;t++){let i=(t+1)%e.length;const r=e[t].x-e[i].x,s=e[t].y-e[i].y;n+=Math.sqrt(r*r+s*s)}return t.lung=n,t},get area(){return Math.abs(e.reduce(((t,n,i)=>{const r=e[(i+1)%e.length];return t+(n.x*r.y-r.x*n.y)}),0)/2)},pointslink(t){let n=mapvertices(e,t.pt),i=[];for(let e of n)i[e[0]]=t.pt[e[1]];return i},alignline(t,n){return e=function stretchShapeToLine(e,t,n){if(!e?.length||!t||!n)return[];const i=e[0],r=e[e.length-1],s=r.x-i.x,o=r.y-i.y,a=Math.atan2(o,s);let A=e.map((e=>({x:e.x-i.x,y:e.y-i.y}))).map((e=>({x:e.x*Math.cos(-a)-e.y*Math.sin(-a),y:e.x*Math.sin(-a)+e.y*Math.cos(-a)})));const l={dx:n.x-t.x,dy:n.y-t.y},c=Math.sqrt(l.dx*l.dx+l.dy*l.dy)/(A[A.length-1].x||1e-8);let p=A.map((e=>({x:e.x*c,y:e.y})));const h=Math.atan2(l.dy,l.dx);return p.map((e=>({x:e.x*Math.cos(h)-e.y*Math.sin(h),y:e.x*Math.sin(h)+e.y*Math.cos(h)}))).map((e=>({x:e.x+t.x,y:e.y+t.y})))}(e,t,n),this},rotate(t){if(!t)return this;const n=t*Math.PI/180,i=Math.cos(n),r=Math.sin(n);for(let t of e){const e=t.x*i-t.y*r,n=t.x*r+t.y*i;t.x=e,t.y=n}return this},selezionaprimo:selezionaprimo,segment(t,n=!1){let i=e.length;return t<0&&(t+=i),new Linea2(e[t%i],e[(t+(n?-1:1))%i])},lineoffset(t,n,i){if((t=(t||0)%e.length)!=(n=(n||0)%e.length)){let r=new Linea2(e[t],e[n]);if(r){return r=r.offsetline(-i),this.intersectline(r)}}},orientasplitter(){-1!=orientation()&&e.reverse();let t=e.length;for(let n=0;n<t;n++){let i=new Linea2(e[(t+n-1)%t],e[n]);if(Math.abs(Math.abs(i.angle)-Math.PI)<.001){n&&selezionaprimo(n);break}}return this},mirrorx(t=0){for(let n of e)n.x=2*t-n.x;return this},mirrory(t=0){for(let n of e)n.y=2*t-n.y;return this},simplify(t,n){return e=simplify(e,t,n),this},fromclip(t){e=[];for(let n of t)e.push({x:n.x/1e3,y:n.y/1e3});return this},infosegmento(t,n=!1){const i=e.length;function clampIndex(e){return(e+i)%i}function angle(e,t){return Math.atan2(t.y-e.y,t.x-e.x)}function angleDiff(e,t){let n=e-t;for(;n>Math.PI;)n-=2*Math.PI;for(;n<-Math.PI;)n+=2*Math.PI;return n}const r=e[t];let s,o,a;if(n)if(0===t){const t=e[1].x-e[0].x,n=e[1].y-e[0].y;s={x:e[0].x-t,y:e[0].y-n},o=e[1],a=2==i?{x:e[1].x+t,y:e[1].y+n}:e[2]}else if(t===i-1){const t=e[i-1].x-e[i-2].x,n=e[i-1].y-e[i-2].y;s=e[i-2],o={x:e[i-1].x+t,y:e[i-1].y+n},a={x:o.x+t,y:o.y+n}}else s=e[t-1],o=e[t+1],a=t+2<i?e[t+2]:{x:e[t+1].x+(e[t+1].x-e[t].x),y:e[t+1].y+(e[t+1].y-e[t].y)};else{const n=clampIndex(t-1),i=clampIndex(t+1),r=clampIndex(t+2);s=e[n],o=e[i],a=e[r]}const A=angle(r,o),l=angle(s,r),c=angle(o,a);return{x:r.x,y:r.y,l:function length(e,t){const n=t.x-e.x,i=t.y-e.y;return Math.sqrt(n*n+i*i)}(r,o),ang:A/ft,a1:angleDiff(A,l)/ft,a2:angleDiff(c,A)/ft}},swapxy(){for(let t=0;t<e.length;t++){let n=e[t].x;e[t].x=-e[t].y,e[t].y=-n}return this},fromvec(t){return e=[],_addvec(t),this},addvec(e){return _addvec(e),this},frompt(t){return e=[...t],e=removeduplicate(e),this},fromdxfvec(t){let n=[];if(t&&t.length)for(let e=0;e<t.length;e++){let{x:i,y:r,bulge:s}=t[e];if(n.push({x:i,y:r}),s){const o=1;let a={x:i,y:r},A=t[(e+1)%t.length],l=A.x-a.x,c=A.y-a.y,p=Math.hypot(l,c);p>o&&n.push(...dxfbulge(a,A,s,Math.floor((p-o)/o)+1))}}return e=n.map((e=>({x:Math.round(10*e.x)/10,y:Math.round(10*e.y)/10}))),e=removeduplicate(e),this},monotona(){let t=dims(e),n=e.map((e=>({x:e.x-t.p2.x,y:e.y}))),i=[];i.push(n[0]);let r=n[0].y,s=1e-4;for(let e=1;e<n.length;e++)if(n[e].y>r+s||e==n.length-1)i.push(n[e]),r=n[e].y;else{const t=r+s;i.push({x:n[e].x,y:t}),r=t}return{sh:getshape().frompt(i),...t}},offsetshape(e){let t=[],n=this;for(let i=0;i<n.npt-1;i++){let r=n.segment(i).offset(e);t.push(r)}let i=n.segment(0).perpendicolare(),r=n.segment(n.npt-2),s=r.perpendicolare(r.p2),o=[i.interseca(t[0])];for(let e=0;e<t.length-1;e++){let n=t[e].interseca(t[e+1]);n&&o.push(n)}return o.push(t[t.length-1].interseca(s)),getshape().frompt(o)},sliceony(t){let n=t.pt.map((e=>e.y)).slice(1,-1);const i=[],r=e.length;let s=0,o=e[0].y;for(let t=1;t<r;t++)e[t].y<o&&(o=e[t].y,s=t);const a=[...e.slice(s),...e.slice(0,s)],A=a.length,l=new Map;for(let e=0;e<A;e++)for(let t of n)Math.abs(a[e].y-t)<1e-5&&(l.has(t)?l.get(t).i2=e:l.set(t,{i1:e,i2:e}));const c=n.map((e=>l.get(e))).filter((e=>e&&e.i1>=0&&e.i2>=0));c.length>0&&c[0].i1>0&&i.push([...a.slice(0,c[0].i1+1),...a.slice(c[0].i2,c[0].length)]);for(let e=0;e<c.length-1;e++){const t=c[e],n=c[e+1];i.push([...a.slice(t.i1,n.i1+1),...a.slice(n.i2,t.i2+1)])}const p=c[c.length-1];p.i2>p.i1&&i.push(a.slice(p.i1,p.i2+1));return i.filter((e=>e.length>0))},splitvert:function splitvert(e,t=!0){const n=t?this.intersectline(new Linea2(e,-100,e,100)):this.intersectline(new Linea2(-100,e,100,e));if(!n)return null;let i=n.p1,r=n.p2;const findIndex=e=>this.pt.findIndex(((t,n)=>new Linea2(t,this.pt[(n+1)%this.pt.length]).onsegment(e)));let s=findIndex(i),o=findIndex(r);if(s<0||o<0)return null;if(s>o){let e=s;s=o,o=e,e=i,i=r,r=e}const a=this.pt.length;let A=[],l=[];for(let e=0;e<a;e++)A.push(this.pt[e]),e==s&&(A.push(i),A.push(r),e=o);t?(l.push(r),l.push(i)):l.push(i);for(let e=s+1;e<=o;e++)l.push(this.pt[e]);return t||l.push(r),{sx:getshape().frompt(A),dx:getshape().frompt(l),linea:n}},splitoriz(e){return this.splitvert(e,!1)},splitshape(e,t=!0){const n=100,i=t?{x:e.x,y:e.y-n}:{x:e.x-n,y:e.y},r=t?{x:e.x,y:e.y+n}:{x:e.x+n,y:e.y},s=this.intersectline(new Linea2(i,r));if(!s)return null;const o=s.p1,a=s.p2,findIndex=e=>this.pt.findIndex(((t,n)=>new Linea2(t,this.pt[(n+1)%this.pt.length]).onsegment(e))),A=findIndex(o),l=findIndex(a);if(A<0||l<0)return null;const c=this.pt.length,loop=(e,t,n,i)=>{const r=[];for(let n=e;n!==t;n=(n+1)%c)r.push(this.pt[(n+1)%c]);return r},p=getshape().frompt(loop(A,l));return{sx:getshape().frompt(loop(l,A)),dx:p,linea:s}},xfromy(e,t=0,n=!0){const i=[],r=this.pt.length;for(let t=0;t<r-1;t++){const r=this.pt[t],s=this.pt[t+1];if(r.y<=e&&s.y>=e||s.y<=e&&r.y>=e){const t=s.y-r.y,n=t?(e-r.y)/t:0,o=r.x+n*(s.x-r.x);i.push(o)}else r.y===e&&s.y===e&&i.push(n?Math.max(r.x,s.x):Math.min(r.x,s.x))}return i.length?n?Math.max(...i):Math.min(...i):t},yfromx(e,t=0,n=!0){const i=[],r=this.pt.length;for(let t=0;t<r-1;t++){const r=this.pt[t],s=this.pt[t+1];if(r.x<=e&&s.x>=e||s.x<=e&&r.x>=e){const t=s.x-r.x,n=t?(e-r.x)/t:0,o=r.y+n*(s.y-r.y);i.push(o)}else r.x===e&&s.x===e&&i.push(n?Math.max(r.y,s.y):Math.min(r.y,s.y))}return i.length?n?Math.max(...i):Math.min(...i):t},forcevalues(t,n=!0,i=1e-6){const r=[...new Set(t.pt.map((e=>n?e.y:e.x)))].sort(((e,t)=>e-t)),s=[],o=e.length;for(let t=0;t<o;t++){const a=e[t],A=e[(t+1)%o];s.push({...a});let l=n?a.y:a.x,c=n?A.y:A.x;if(l===c)continue;const p=c>l?r.filter((e=>e>l+i&&e<c-i)):r.filter((e=>e<l-i&&e>c+i)).reverse();for(const e of p){const t=(e-l)/(c-l),n={x:a.x+t*(A.x-a.x),y:a.y+t*(A.y-a.y)};s.push(n)}}return e=s,this},fromrrect(e,t,n=10,i=0,r=0){return(n>=e/2||n>=t/2&&n<=0)&&(n=Math.round(Math.min(e/3,t/3))),fromstr(`0,0,r${n},${e},0,r${n},${e},${t},r${n},0,${t},r${n}`),(i||r)&&move(i,r),this},fromrect(t,n,i,r,s){t||(t=10),n||(n=10),s||(s=0),s=Math.min(Math.abs(s),Math.abs(.4*t),Math.abs(.4*n));let o=t>0?s:-s,a=n>0?s:-s;return e=s?[{x:o,y:0},{x:t-o,y:0},{x:t,y:a},{x:t,y:n-a},{x:t-o,y:n},{x:o,y:n},{x:0,y:n-a},{x:0,y:a}]:[{x:0,y:0},{x:t,y:0},{x:t,y:n},{x:0,y:n}],this},intersectline:t=>function _intersectline(e,t,n){let i=e.length,r=new Linea2(t,n);const s=[];for(let t=0;t<e.length;t++){let n=new Linea2(e[t],e[(t+1)%i]),o=n.interseca(r);o&&n.onsegment(o)&&s.push(o)}if(s.length<2)return null;const{dx:o,dy:a}=r;s.sort(((e,n)=>(e.x-t.x)*o+(e.y-t.y)*a-((n.x-t.x)*o+(n.y-t.y)*a)));let A=new Punto2(s[0].x,s[0].y),l=new Punto2(s[s.length-1].x,s[s.length-1].y);const c=l.x-A.x,p=l.y-A.y;return c*o+p*a<0&&([A,l]=[l,A]),new Linea2(A,l)}(e,t.p1,t.p2),tostr(t=2){let n=10**t,pstr=e=>String(Math.round(e*n)/n),i=e.map((e=>`${pstr(e.x)};${pstr(e.y)};`)).join("");return i&&i.length?i.slice(0,-1).match(/.{1,80}(;|$)/g).map((e=>e.trim())).join("\n"):""},addpt(t){return t?(Array.isArray(t)||(t=[t]),e=removeduplicate([...e,...t]),this):this},addracc(t,n,i=2,r=!0){if(Array.isArray(t)&&(n={x:t[2]||0,y:t[3]||0},t={x:t[0]||0,y:t[1]||0}),e.length>=2){let s=raccordabezier(e[e.length-2],e[e.length-1],t,n,i);e=[...e,...s],r&&(e.push(t),e.push(n))}return e=removeduplicate(e),this},setorient(t){let n=orientation();return(1==n&&-1==t||-1==n&&1==t)&&e.reverse(),this},reverse(){return e.reverse(),this},pointinshape:t=>function isPointInPolygon(t){let n=t.x,i=t.y,r=!1;for(let t=0,s=e.length-1;t<e.length;s=t++){let o=e[t].x,a=e[t].y,A=e[s].x,l=e[s].y;a>i!=l>i&&n<(A-o)*(i-a)/(l-a)+o&&(r=!r)}return r}(t),azzera(){return e=[],this},truncatebefore:function truncatebefore(t){let n=new Linea2(e[0],e[1]),i=t.interseca(n);if(i){let t=e[0],n=e[1],r=n.x-t.x,s=n.y-t.y,o=r*r+s*s;if(o){if(((i.x-t.x)*r+(i.y-t.y)*s)/o<=1)return e[0]=i,this}}for(let n=1;n<e.length-1;n++){let i=new Linea2(e[n],e[n+1]),r=t.interseca(i);if(r&&i.onsegment(r))return e=e.slice(n),e[0]=r,this}return this},truncateafter:function truncateafter(t){let n=e.length,i=new Linea2(e[n-2],e[n-1]),r=t.interseca(i);if(r){let t=e[n-2],i=e[n-1],s=i.x-t.x,o=i.y-t.y,a=s*s+o*o;if(a){if(((r.x-t.x)*s+(r.y-t.y)*o)/a>=0)return e[n-1]=r,this}}for(let i=n-3;i>=0;i--){let n=new Linea2(e[i],e[i+1]),r=t.interseca(n);if(r&&n.onsegment(r))return e=e.slice(0,i+1),e.push(r),this}return this},removeduplicate(t=.005){return e=removeduplicate(e,t),this},to3d(t,n=0,i=0,r=0,s=!1,o=null,a=!1){let A=function to3dcoor(e,t){let{currentU:n=0,c:i=0,a:r=0,b:s=0,anglemin:o=30,open:a=!1,sh:A=null,invert:l=!1}=t;const c=[],p=e.length;for(let t=0;t<p;t++){const a=e[(t-1+p)%p],h=e[t],u=e[(t+1)%p],d={x:h.x-a.x,y:h.y-a.y},g={x:u.x-h.x,y:u.y-h.y},f=normal2(a,h),m=normal2(h,u),y=angle2vec(d,g);let b=r*h.x+s*h.y+i;if(A){let e=A.xfromy(h.y,0,!0);l?b+=e:b-=e}Math.abs(y-180)<=o?(f.nx,m.nx,f.ny,m.ny,c.push({x:h.x,y:-h.y,z:b,u:n,v:b})):(c.push({x:h.x,y:-h.y,z:b,u:n,v:b}),c.push({x:h.x,y:-h.y,z:b,u:n,v:b}));const I=u.x-h.x,x=u.y-h.y;n+=Math.sqrt(I*I+x*x)}if(!a){let e=c[0],t=c[c.length-1];e.x==t.x&&e.y==t.y||c.push({x:e.x,y:e.y,z:e.z,nx:e.nx,ny:e.ny,nz:e.nz,u:n,v:e.z})}return c}(e,{open:s,currentU:t,c:n,a:i,b:r,anglemin:30,sh:o,invert:a});return A},getboundbox:()=>e.length?e.reduce(((e,t)=>(e.p1.x=Math.min(e.p1.x,t.x),e.p1.y=Math.min(e.p1.y,t.y),e.p2.x=Math.max(e.p2.x,t.x),e.p2.y=Math.max(e.p2.y,t.y),e)),{p1:new Punto2(1/0,1/0),p2:new Punto2(-1/0,-1/0)}):{p1:new Punto2(0,0),p2:new Punto2(0,0)},fittobox(t,n){if(!e.length)return this;const i=this.getboundbox(),r=i.p2.x-i.p1.x,s=i.p2.y-i.p1.y,o=n.x-t.x,a=n.y-t.y,A=Math.min(o/(r||1),a/(s||1));for(let n of e)n.x=(n.x-i.p1.x)*A,n.y=(n.y-i.p1.y)*A,n.x+=t.x,n.y+=t.y;return this}}}function arcfrom3point(e,t,n,i){if(e<=0)return[t,i];if(1===e)return[t,n,i];const r=function findCircleCenter(e,t,n){const i=t.x*t.x+t.y*t.y,r=(e.x*e.x+e.y*e.y-i)/2,s=(i-n.x*n.x-n.y*n.y)/2,o=(e.x-t.x)*(t.y-n.y)-(t.x-n.x)*(e.y-t.y);return Math.abs(o)<1e-10?null:new Punto2((r*(t.y-n.y)-s*(e.y-t.y))/o,((e.x-t.x)*s-(t.x-n.x)*r)/o)}(t,n,i);if(!r){const n=[];for(let r=0;r<=e;r++){const s=r/e;n.push(new Punto2(t.x+(i.x-t.x)*s,t.y+(i.y-t.y)*s))}return n}let s=Math.atan2(t.y-r.y,t.x-r.x);Math.atan2(n.y-r.y,n.x-r.x);let o=Math.atan2(i.y-r.y,i.x-r.x);const a=(n.x-t.x)*(i.y-t.y)-(n.y-t.y)*(i.x-t.x),norm=e=>(e+2*Math.PI)%(2*Math.PI);s=norm(s),o=norm(o),a>0?o<s&&(o+=2*Math.PI):o>s&&(o-=2*Math.PI);const A=Math.hypot(t.x-r.x,t.y-r.y),l=(o-s)/e,c=[];for(let t=0;t<=e;t++){const e=s+l*t;c.push(new Punto2(r.x+A*Math.cos(e),r.y+A*Math.sin(e)))}return c}function getDefaultExportFromCjs(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var yt,bt={exports:{}};yt=bt,function(){var e,t={version:"6.4.2.2",use_lines:!0,use_xyz:!1},n=!1;if(yt.exports?(yt.exports=t,n=!0):"undefined"!=typeof document?window.ClipperLib=t:self.ClipperLib=t,n)i="chrome",e="Netscape";else{var i=navigator.userAgent.toString().toLowerCase();e=navigator.appName}var r,s={};function BigInteger(e,n,i){t.biginteger_used=1,null!=e&&("number"==typeof e&&void 0===n?this.fromInt(e):"number"==typeof e?this.fromNumber(e,n,i):null==n&&"string"!=typeof e?this.fromString(e,256):this.fromString(e,n))}function nbi(){return new BigInteger(null,void 0,void 0)}-1!=i.indexOf("chrome")&&-1==i.indexOf("chromium")?s.chrome=1:s.chrome=0,-1!=i.indexOf("chromium")?s.chromium=1:s.chromium=0,-1!=i.indexOf("safari")&&-1==i.indexOf("chrome")&&-1==i.indexOf("chromium")?s.safari=1:s.safari=0,-1!=i.indexOf("firefox")?s.firefox=1:s.firefox=0,-1!=i.indexOf("firefox/17")?s.firefox17=1:s.firefox17=0,-1!=i.indexOf("firefox/15")?s.firefox15=1:s.firefox15=0,-1!=i.indexOf("firefox/3")?s.firefox3=1:s.firefox3=0,-1!=i.indexOf("opera")?s.opera=1:s.opera=0,-1!=i.indexOf("msie 10")?s.msie10=1:s.msie10=0,-1!=i.indexOf("msie 9")?s.msie9=1:s.msie9=0,-1!=i.indexOf("msie 8")?s.msie8=1:s.msie8=0,-1!=i.indexOf("msie 7")?s.msie7=1:s.msie7=0,-1!=i.indexOf("msie ")?s.msie=1:s.msie=0,t.biginteger_used=null,"Microsoft Internet Explorer"==e?(BigInteger.prototype.am=function am2(e,t,n,i,r,s){for(var o=32767&t,a=t>>15;--s>=0;){var A=32767&this[e],l=this[e++]>>15,c=a*A+l*o;r=((A=o*A+((32767&c)<<15)+n[i]+(1073741823&r))>>>30)+(c>>>15)+a*l+(r>>>30),n[i++]=1073741823&A}return r},r=30):"Netscape"!=e?(BigInteger.prototype.am=function am1(e,t,n,i,r,s){for(;--s>=0;){var o=t*this[e++]+n[i]+r;r=Math.floor(o/67108864),n[i++]=67108863&o}return r},r=26):(BigInteger.prototype.am=function am3(e,t,n,i,r,s){for(var o=16383&t,a=t>>14;--s>=0;){var A=16383&this[e],l=this[e++]>>14,c=a*A+l*o;r=((A=o*A+((16383&c)<<14)+n[i]+r)>>28)+(c>>14)+a*l,n[i++]=268435455&A}return r},r=28),BigInteger.prototype.DB=r,BigInteger.prototype.DM=(1<<r)-1,BigInteger.prototype.DV=1<<r,BigInteger.prototype.FV=Math.pow(2,52),BigInteger.prototype.F1=52-r,BigInteger.prototype.F2=2*r-52;var o,a,A=new Array;for(o="0".charCodeAt(0),a=0;a<=9;++a)A[o++]=a;for(o="a".charCodeAt(0),a=10;a<36;++a)A[o++]=a;for(o="A".charCodeAt(0),a=10;a<36;++a)A[o++]=a;function int2char(e){return"0123456789abcdefghijklmnopqrstuvwxyz".charAt(e)}function intAt(e,t){var n=A[e.charCodeAt(t)];return null==n?-1:n}function nbv(e){var t=nbi();return t.fromInt(e),t}function nbits(e){var t,n=1;return 0!=(t=e>>>16)&&(e=t,n+=16),0!=(t=e>>8)&&(e=t,n+=8),0!=(t=e>>4)&&(e=t,n+=4),0!=(t=e>>2)&&(e=t,n+=2),0!=(t=e>>1)&&(e=t,n+=1),n}function Classic(e){this.m=e}function Montgomery(e){this.m=e,this.mp=e.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<<e.DB-15)-1,this.mt2=2*e.t}function op_and(e,t){return e&t}function op_or(e,t){return e|t}function op_xor(e,t){return e^t}function op_andnot(e,t){return e&~t}function lbit(e){if(0==e)return-1;var t=0;return 65535&e||(e>>=16,t+=16),255&e||(e>>=8,t+=8),15&e||(e>>=4,t+=4),3&e||(e>>=2,t+=2),1&e||++t,t}function cbit(e){for(var t=0;0!=e;)e&=e-1,++t;return t}function NullExp(){}function nNop(e){return e}function Barrett(e){this.r2=nbi(),this.q3=nbi(),BigInteger.ONE.dlShiftTo(2*e.t,this.r2),this.mu=this.r2.divide(e),this.m=e}Classic.prototype.convert=function cConvert(e){return e.s<0||e.compareTo(this.m)>=0?e.mod(this.m):e},Classic.prototype.revert=function cRevert(e){return e},Classic.prototype.reduce=function cReduce(e){e.divRemTo(this.m,null,e)},Classic.prototype.mulTo=function cMulTo(e,t,n){e.multiplyTo(t,n),this.reduce(n)},Classic.prototype.sqrTo=function cSqrTo(e,t){e.squareTo(t),this.reduce(t)},Montgomery.prototype.convert=function montConvert(e){var t=nbi();return e.abs().dlShiftTo(this.m.t,t),t.divRemTo(this.m,null,t),e.s<0&&t.compareTo(BigInteger.ZERO)>0&&this.m.subTo(t,t),t},Montgomery.prototype.revert=function montRevert(e){var t=nbi();return e.copyTo(t),this.reduce(t),t},Montgomery.prototype.reduce=function montReduce(e){for(;e.t<=this.mt2;)e[e.t++]=0;for(var t=0;t<this.m.t;++t){var n=32767&e[t],i=n*this.mpl+((n*this.mph+(e[t]>>15)*this.mpl&this.um)<<15)&e.DM;for(e[n=t+this.m.t]+=this.m.am(0,i,e,t,0,this.m.t);e[n]>=e.DV;)e[n]-=e.DV,e[++n]++}e.clamp(),e.drShiftTo(this.m.t,e),e.compareTo(this.m)>=0&&e.subTo(this.m,e)},Montgomery.prototype.mulTo=function montMulTo(e,t,n){e.multiplyTo(t,n),this.reduce(n)},Montgomery.prototype.sqrTo=function montSqrTo(e,t){e.squareTo(t),this.reduce(t)},BigInteger.prototype.copyTo=function bnpCopyTo(e){for(var t=this.t-1;t>=0;--t)e[t]=this[t];e.t=this.t,e.s=this.s},BigInteger.prototype.fromInt=function bnpFromInt(e){this.t=1,this.s=e<0?-1:0,e>0?this[0]=e:e<-1?this[0]=e+this.DV:this.t=0},BigInteger.prototype.fromString=function bnpFromString(e,t){var n;if(16==t)n=4;else if(8==t)n=3;else if(256==t)n=8;else if(2==t)n=1;else if(32==t)n=5;else{if(4!=t)return void this.fromRadix(e,t);n=2}this.t=0,this.s=0;for(var i=e.length,r=!1,s=0;--i>=0;){var o=8==n?255&e[i]:intAt(e,i);o<0?"-"==e.charAt(i)&&(r=!0):(r=!1,0==s?this[this.t++]=o:s+n>this.DB?(this[this.t-1]|=(o&(1<<this.DB-s)-1)<<s,this[this.t++]=o>>this.DB-s):this[this.t-1]|=o<<s,(s+=n)>=this.DB&&(s-=this.DB))}8==n&&128&e[0]&&(this.s=-1,s>0&&(this[this.t-1]|=(1<<this.DB-s)-1<<s)),this.clamp(),r&&BigInteger.ZERO.subTo(this,this)},BigInteger.prototype.clamp=function bnpClamp(){for(var e=this.s&this.DM;this.t>0&&this[this.t-1]==e;)--this.t},BigInteger.prototype.dlShiftTo=function bnpDLShiftTo(e,t){var n;for(n=this.t-1;n>=0;--n)t[n+e]=this[n];for(n=e-1;n>=0;--n)t[n]=0;t.t=this.t+e,t.s=this.s},BigInteger.prototype.drShiftTo=function bnpDRShiftTo(e,t){for(var n=e;n<this.t;++n)t[n-e]=this[n];t.t=Math.max(this.t-e,0),t.s=this.s},BigInteger.prototype.lShiftTo=function bnpLShiftTo(e,t){var n,i=e%this.DB,r=this.DB-i,s=(1<<r)-1,o=Math.floor(e/this.DB),a=this.s<<i&this.DM;for(n=this.t-1;n>=0;--n)t[n+o+1]=this[n]>>r|a,a=(this[n]&s)<<i;for(n=o-1;n>=0;--n)t[n]=0;t[o]=a,t.t=this.t+o+1,t.s=this.s,t.clamp()},BigInteger.prototype.rShiftTo=function bnpRShiftTo(e,t){t.s=this.s;var n=Math.floor(e/this.DB);if(n>=this.t)t.t=0;else{var i=e%this.DB,r=this.DB-i,s=(1<<i)-1;t[0]=this[n]>>i;for(var o=n+1;o<this.t;++o)t[o-n-1]|=(this[o]&s)<<r,t[o-n]=this[o]>>i;i>0&&(t[this.t-n-1]|=(this.s&s)<<r),t.t=this.t-n,t.clamp()}},BigInteger.prototype.subTo=function bnpSubTo(e,t){for(var n=0,i=0,r=Math.min(e.t,this.t);n<r;)i+=this[n]-e[n],t[n++]=i&this.DM,i>>=this.DB;if(e.t<this.t){for(i-=e.s;n<this.t;)i+=this[n],t[n++]=i&this.DM,i>>=this.DB;i+=this.s}else{for(i+=this.s;n<e.t;)i-=e[n],t[n++]=i&this.DM,i>>=this.DB;i-=e.s}t.s=i<0?-1:0,i<-1?t[n++]=this.DV+i:i>0&&(t[n++]=i),t.t=n,t.clamp()},BigInteger.prototype.multiplyTo=function bnpMultiplyTo(e,t){var n=this.abs(),i=e.abs(),r=n.t;for(t.t=r+i.t;--r>=0;)t[r]=0;for(r=0;r<i.t;++r)t[r+n.t]=n.am(0,i[r],t,r,0,n.t);t.s=0,t.clamp(),this.s!=e.s&&BigInteger.ZERO.subTo(t,t)},BigInteger.prototype.squareTo=function bnpSquareTo(e){for(var t=this.abs(),n=e.t=2*t.t;--n>=0;)e[n]=0;for(n=0;n<t.t-1;++n){var i=t.am(n,t[n],e,2*n,0,1);(e[n+t.t]+=t.am(n+1,2*t[n],e,2*n+1,i,t.t-n-1))>=t.DV&&(e[n+t.t]-=t.DV,e[n+t.t+1]=1)}e.t>0&&(e[e.t-1]+=t.am(n,t[n],e,2*n,0,1)),e.s=0,e.clamp()},BigInteger.prototype.divRemTo=function bnpDivRemTo(e,t,n){var i=e.abs();if(!(i.t<=0)){var r=this.abs();if(r.t<i.t)return null!=t&&t.fromInt(0),void(null!=n&&this.copyTo(n));null==n&&(n=nbi());var s=nbi(),o=this.s,a=e.s,A=this.DB-nbits(i[i.t-1]);A>0?(i.lShiftTo(A,s),r.lShiftTo(A,n)):(i.copyTo(s),r.copyTo(n));var l=s.t,c=s[l-1];if(0!=c){var p=c*(1<<this.F1)+(l>1?s[l-2]>>this.F2:0),h=this.FV/p,u=(1<<this.F1)/p,d=1<<this.F2,g=n.t,f=g-l,m=null==t?nbi():t;for(s.dlShiftTo(f,m),n.compareTo(m)>=0&&(n[n.t++]=1,n.subTo(m,n)),BigInteger.ONE.dlShiftTo(l,m),m.subTo(s,s);s.t<l;)s[s.t++]=0;for(;--f>=0;){var y=n[--g]==c?this.DM:Math.floor(n[g]*h+(n[g-1]+d)*u);if((n[g]+=s.am(0,y,n,f,0,l))<y)for(s.dlShiftTo(f,m),n.subTo(m,n);n[g]<--y;)n.subTo(m,n)}null!=t&&(n.drShiftTo(l,t),o!=a&&BigInteger.ZERO.subTo(t,t)),n.t=l,n.clamp(),A>0&&n.rShiftTo(A,n),o<0&&BigInteger.ZERO.subTo(n,n)}}},BigInteger.prototype.invDigit=function bnpInvDigit(){if(this.t<1)return 0;var e=this[0];if(!(1&e))return 0;var t=3&e;return(t=(t=(t=(t=t*(2-(15&e)*t)&15)*(2-(255&e)*t)&255)*(2-((65535&e)*t&65535))&65535)*(2-e*t%this.DV)%this.DV)>0?this.DV-t:-t},BigInteger.prototype.isEven=function bnpIsEven(){return 0==(this.t>0?1&this[0]:this.s)},BigInteger.prototype.exp=function bnpExp(e,t){if(e>4294967295||e<1)return BigInteger.ONE;var n=nbi(),i=nbi(),r=t.convert(this),s=nbits(e)-1;for(r.copyTo(n);--s>=0;)if(t.sqrTo(n,i),(e&1<<s)>0)t.mulTo(i,r,n);else{var o=n;n=i,i=o}return t.revert(n)},BigInteger.prototype.toString=function bnToString(e){if(this.s<0)return"-"+this.negate().toString(e);var t;if(16==e)t=4;else if(8==e)t=3;else if(2==e)t=1;else if(32==e)t=5;else{if(4!=e)return this.toRadix(e);t=2}var n,i=(1<<t)-1,r=!1,s="",o=this.t,a=this.DB-o*this.DB%t;if(o-- >0)for(a<this.DB&&(n=this[o]>>a)>0&&(r=!0,s=int2char(n));o>=0;)a<t?(n=(this[o]&(1<<a)-1)<<t-a,n|=this[--o]>>(a+=this.DB-t)):(n=this[o]>>(a-=t)&i,a<=0&&(a+=this.DB,--o)),n>0&&(r=!0),r&&(s+=int2char(n));return r?s:"0"},BigInteger.prototype.negate=function bnNegate(){var e=nbi();return BigInteger.ZERO.subTo(this,e),e},BigInteger.prototype.abs=function bnAbs(){return this.s<0?this.negate():this},BigInteger.prototype.compareTo=function bnCompareTo(e){var t=this.s-e.s;if(0!=t)return t;var n=this.t;if(0!=(t=n-e.t))return this.s<0?-t:t;for(;--n>=0;)if(0!=(t=this[n]-e[n]))return t;return 0},BigInteger.prototype.bitLength=function bnBitLength(){return this.t<=0?0:this.DB*(this.t-1)+nbits(this[this.t-1]^this.s&this.DM)},BigInteger.prototype.mod=function bnMod(e){var t=nbi();return this.abs().divRemTo(e,null,t),this.s<0&&t.compareTo(BigInteger.ZERO)>0&&e.subTo(t,t),t},BigInteger.prototype.modPowInt=function bnModPowInt(e,t){var n;return n=e<256||t.isEven()?new Classic(t):new Montgomery(t),this.exp(e,n)},BigInteger.ZERO=nbv(0),BigInteger.ONE=nbv(1),NullExp.prototype.convert=nNop,NullExp.prototype.revert=nNop,NullExp.prototype.mulTo=function nMulTo(e,t,n){e.multiplyTo(t,n)},NullExp.prototype.sqrTo=function nSqrTo(e,t){e.squareTo(t)},Barrett.prototype.convert=function barrettConvert(e){if(e.s<0||e.t>2*this.m.t)return e.mod(this.m);if(e.compareTo(this.m)<0)return e;var t=nbi();return e.copyTo(t),this.reduce(t),t},Barrett.prototype.revert=function barrettRevert(e){return e},Barrett.prototype.reduce=function barrettReduce(e){for(e.drShiftTo(this.m.t-1,this.r2),e.t>this.m.t+1&&(e.t=this.m.t+1,e.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);e.compareTo(this.r2)<0;)e.dAddOffset(1,this.m.t+1);for(e.subTo(this.r2,e);e.compareTo(this.m)>=0;)e.subTo(this.m,e)},Barrett.prototype.mulTo=function barrettMulTo(e,t,n){e.multiplyTo(t,n),this.reduce(n)},Barrett.prototype.sqrTo=function barrettSqrTo(e,t){e.squareTo(t),this.reduce(t)};var l=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],c=(1<<26)/l[l.length-1];BigInteger.prototype.chunkSize=function bnpChunkSize(e){return Math.floor(Math.LN2*this.DB/Math.log(e))},BigInteger.prototype.toRadix=function bnpToRadix(e){if(null==e&&(e=10),0==this.signum()||e<2||e>36)return"0";var t=this.chunkSize(e),n=Math.pow(e,t),i=nbv(n),r=nbi(),s=nbi(),o="";for(this.divRemTo(i,r,s);r.signum()>0;)o=(n+s.intValue()).toString(e).substr(1)+o,r.divRemTo(i,r,s);return s.intValue().toString(e)+o},BigInteger.prototype.fromRadix=function bnpFromRadix(e,t){this.fromInt(0),null==t&&(t=10);for(var n=this.chunkSize(t),i=Math.pow(t,n),r=!1,s=0,o=0,a=0;a<e.length;++a){var A=intAt(e,a);A<0?"-"==e.charAt(a)&&0==this.signum()&&(r=!0):(o=t*o+A,++s>=n&&(this.dMultiply(i),this.dAddOffset(o,0),s=0,o=0))}s>0&&(this.dMultiply(Math.pow(t,s)),this.dAddOffset(o,0)),r&&BigInteger.ZERO.subTo(this,this)},BigInteger.prototype.fromNumber=function bnpFromNumber(e,t,n){if("number"==typeof t)if(e<2)this.fromInt(1);else for(this.fromNumber(e,n),this.testBit(e-1)||this.bitwiseTo(BigInteger.ONE.shiftLeft(e-1),op_or,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(t);)this.dAddOffset(2,0),this.bitLength()>e&&this.subTo(BigInteger.ONE.shiftLeft(e-1),this);else{var i=new Array,r=7&e;i.length=1+(e>>3),t.nextBytes(i),r>0?i[0]&=(1<<r)-1:i[0]=0,this.fromString(i,256)}},BigInteger.prototype.bitwiseTo=function bnpBitwiseTo(e,t,n){var i,r,s=Math.min(e.t,this.t);for(i=0;i<s;++i)n[i]=t(this[i],e[i]);if(e.t<this.t){for(r=e.s&this.DM,i=s;i<this.t;++i)n[i]=t(this[i],r);n.t=this.t}else{for(r=this.s&this.DM,i=s;i<e.t;++i)n[i]=t(r,e[i]);n.t=e.t}n.s=t(this.s,e.s),n.clamp()},BigInteger.prototype.changeBit=function bnpChangeBit(e,t){var n=BigInteger.ONE.shiftLeft(e);return this.bitwiseTo(n,t,n),n},BigInteger.prototype.addTo=function bnpAddTo(e,t){for(var n=0,i=0,r=Math.min(e.t,this.t);n<r;)i+=this[n]+e[n],t[n++]=i&this.DM,i>>=this.DB;if(e.t<this.t){for(i+=e.s;n<this.t;)i+=this[n],t[n++]=i&this.DM,i>>=this.DB;i+=this.s}else{for(i+=this.s;n<e.t;)i+=e[n],t[n++]=i&this.DM,i>>=this.DB;i+=e.s}t.s=i<0?-1:0,i>0?t[n++]=i:i<-1&&(t[n++]=this.DV+i),t.t=n,t.clamp()},BigInteger.prototype.dMultiply=function bnpDMultiply(e){this[this.t]=this.am(0,e-1,this,0,0,this.t),++this.t,this.clamp()},BigInteger.prototype.dAddOffset=function bnpDAddOffset(e,t){if(0!=e){for(;this.t<=t;)this[this.t++]=0;for(this[t]+=e;this[t]>=this.DV;)this[t]-=this.DV,++t>=this.t&&(this[this.t++]=0),++this[t]}},BigInteger.prototype.multiplyLowerTo=function bnpMultiplyLowerTo(e,t,n){var i,r=Math.min(this.t+e.t,t);for(n.s=0,n.t=r;r>0;)n[--r]=0;for(i=n.t-this.t;r<i;++r)n[r+this.t]=this.am(0,e[r],n,r,0,this.t);for(i=Math.min(e.t,t);r<i;++r)this.am(0,e[r],n,r,0,t-r);n.clamp()},BigInteger.prototype.multiplyUpperTo=function bnpMultiplyUpperTo(e,t,n){--t;var i=n.t=this.t+e.t-t;for(n.s=0;--i>=0;)n[i]=0;for(i=Math.max(t-this.t,0);i<e.t;++i)n[this.t+i-t]=this.am(t-i,e[i],n,0,0,this.t+i-t);n.clamp(),n.drShiftTo(1,n)},BigInteger.prototype.modInt=function bnpModInt(e){if(e<=0)return 0;var t=this.DV%e,n=this.s<0?e-1:0;if(this.t>0)if(0==t)n=this[0]%e;else for(var i=this.t-1;i>=0;--i)n=(t*n+this[i])%e;return n},BigInteger.prototype.millerRabin=function bnpMillerRabin(e){var t=this.subtract(BigInteger.ONE),n=t.getLowestSetBit();if(n<=0)return!1;var i=t.shiftRight(n);(e=e+1>>1)>l.length&&(e=l.length);for(var r=nbi(),s=0;s<e;++s){r.fromInt(l[Math.floor(Math.random()*l.length)]);var o=r.modPow(i,this);if(0!=o.compareTo(BigInteger.ONE)&&0!=o.compareTo(t)){for(var a=1;a++<n&&0!=o.compareTo(t);)if(0==(o=o.modPowInt(2,this)).compareTo(BigInteger.ONE))return!1;if(0!=o.compareTo(t))return!1}}return!0},BigInteger.prototype.clone=function bnClone(){var e=nbi();return this.copyTo(e),e},BigInteger.prototype.intValue=function bnIntValue(){if(this.s<0){if(1==this.t)return this[0]-this.DV;if(0==this.t)return-1}else{if(1==this.t)return this[0];if(0==this.t)return 0}return(this[1]&(1<<32-this.DB)-1)<<this.DB|this[0]},BigInteger.prototype.byteValue=function bnByteValue(){return 0==this.t?this.s:this[0]<<24>>24},BigInteger.prototype.shortValue=function bnShortValue(){return 0==this.t?this.s:this[0]<<16>>16},BigInteger.prototype.signum=function bnSigNum(){return this.s<0?-1:this.t<=0||1==this.t&&this[0]<=0?0:1},BigInteger.prototype.toByteArray=function bnToByteArray(){var e=this.t,t=new Array;t[0]=this.s;var n,i=this.DB-e*this.DB%8,r=0;if(e-- >0)for(i<this.DB&&(n=this[e]>>i)!=(this.s&this.DM)>>i&&(t[r++]=n|this.s<<this.DB-i);e>=0;)i<8?(n=(this[e]&(1<<i)-1)<<8-i,n|=this[--e]>>(i+=this.DB-8)):(n=this[e]>>(i-=8)&255,i<=0&&(i+=this.DB,--e)),128&n&&(n|=-256),0==r&&(128&this.s)!=(128&n)&&++r,(r>0||n!=this.s)&&(t[r++]=n);return t},BigInteger.prototype.equals=function bnEquals(e){return 0==this.compareTo(e)},BigInteger.prototype.min=function bnMin(e){return this.compareTo(e)<0?this:e},BigInteger.prototype.max=function bnMax(e){return this.compareTo(e)>0?this:e},BigInteger.prototype.and=function bnAnd(e){var t=nbi();return this.bitwiseTo(e,op_and,t),t},BigInteger.prototype.or=function bnOr(e){var t=nbi();return this.bitwiseTo(e,op_or,t),t},BigInteger.prototype.xor=function bnXor(e){var t=nbi();return this.bitwiseTo(e,op_xor,t),t},BigInteger.prototype.andNot=function bnAndNot(e){var t=nbi();return this.bitwiseTo(e,op_andnot,t),t},BigInteger.prototype.not=function bnNot(){for(var e=nbi(),t=0;t<this.t;++t)e[t]=this.DM&~this[t];return e.t=this.t,e.s=~this.s,e},BigInteger.prototype.shiftLeft=function bnShiftLeft(e){var t=nbi();return e<0?this.rShiftTo(-e,t):this.lShiftTo(e,t),t},BigInteger.prototype.shiftRight=function bnShiftRight(e){var t=nbi();return e<0?this.lShiftTo(-e,t):this.rShiftTo(e,t),t},BigInteger.prototype.getLowestSetBit=function bnGetLowestSetBit(){for(var e=0;e<this.t;++e)if(0!=this[e])return e*this.DB+lbit(this[e]);return this.s<0?this.t*this.DB:-1},BigInteger.prototype.bitCount=function bnBitCount(){for(var e=0,t=this.s&this.DM,n=0;n<this.t;++n)e+=cbit(this[n]^t);return e},BigInteger.prototype.testBit=function bnTestBit(e){var t=Math.floor(e/this.DB);return t>=this.t?0!=this.s:!!(this[t]&1<<e%this.DB)},BigInteger.prototype.setBit=function bnSetBit(e){return this.changeBit(e,op_or)},BigInteger.prototype.clearBit=function bnClearBit(e){return this.changeBit(e,op_andnot)},BigInteger.prototype.flipBit=function bnFlipBit(e){return this.changeBit(e,op_xor)},BigInteger.prototype.add=function bnAdd(e){var t=nbi();return this.addTo(e,t),t},BigInteger.prototype.subtract=function bnSubtract(e){var t=nbi();return this.subTo(e,t),t},BigInteger.prototype.multiply=function bnMultiply(e){var t=nbi();return this.multiplyTo(e,t),t},BigInteger.prototype.divide=function bnDivide(e){var t=nbi();return this.divRemTo(e,t,null),t},BigInteger.prototype.remainder=function bnRemainder(e){var t=nbi();return this.divRemTo(e,null,t),t},BigInteger.prototype.divideAndRemainder=function bnDivideAndRemainder(e){var t=nbi(),n=nbi();return this.divRemTo(e,t,n),new Array(t,n)},BigInteger.prototype.modPow=function bnModPow(e,t){var n,i,r=e.bitLength(),s=nbv(1);if(r<=0)return s;n=r<18?1:r<48?3:r<144?4:r<768?5:6,i=r<8?new Classic(t):t.isEven()?new Barrett(t):new Montgomery(t);var o=new Array,a=3,A=n-1,l=(1<<n)-1;if(o[1]=i.convert(this),n>1){var c=nbi();for(i.sqrTo(o[1],c);a<=l;)o[a]=nbi(),i.mulTo(c,o[a-2],o[a]),a+=2}var p,h,u=e.t-1,d=!0,g=nbi();for(r=nbits(e[u])-1;u>=0;){for(r>=A?p=e[u]>>r-A&l:(p=(e[u]&(1<<r+1)-1)<<A-r,u>0&&(p|=e[u-1]>>this.DB+r-A)),a=n;!(1&p);)p>>=1,--a;if((r-=a)<0&&(r+=this.DB,--u),d)o[p].copyTo(s),d=!1;else{for(;a>1;)i.sqrTo(s,g),i.sqrTo(g,s),a-=2;a>0?i.sqrTo(s,g):(h=s,s=g,g=h),i.mulTo(g,o[p],s)}for(;u>=0&&!(e[u]&1<<r);)i.sqrTo(s,g),h=s,s=g,g=h,--r<0&&(r=this.DB-1,--u)}return i.revert(s)},BigInteger.prototype.modInverse=function bnModInverse(e){var t=e.isEven();if(this.isEven()&&t||0==e.signum())return BigInteger.ZERO;for(var n=e.clone(),i=this.clone(),r=nbv(1),s=nbv(0),o=nbv(0),a=nbv(1);0!=n.signum();){for(;n.isEven();)n.rShiftTo(1,n),t?(r.isEven()&&s.isEven()||(r.addTo(this,r),s.subTo(e,s)),r.rShiftTo(1,r)):s.isEven()||s.subTo(e,s),s.rShiftTo(1,s);for(;i.isEven();)i.rShiftTo(1,i),t?(o.isEven()&&a.isEven()||(o.addTo(this,o),a.subTo(e,a)),o.rShiftTo(1,o)):a.isEven()||a.subTo(e,a),a.rShiftTo(1,a);n.compareTo(i)>=0?(n.subTo(i,n),t&&r.subTo(o,r),s.subTo(a,s)):(i.subTo(n,i),t&&o.subTo(r,o),a.subTo(s,a))}return 0!=i.compareTo(BigInteger.ONE)?BigInteger.ZERO:a.compareTo(e)>=0?a.subtract(e):a.signum()<0?(a.addTo(e,a),a.signum()<0?a.add(e):a):a},BigInteger.prototype.pow=function bnPow(e){return this.exp(e,new NullExp)},BigInteger.prototype.gcd=function bnGCD(e){var t=this.s<0?this.negate():this.clone(),n=e.s<0?e.negate():e.clone();if(t.compareTo(n)<0){var i=t;t=n,n=i}var r=t.getLowestSetBit(),s=n.getLowestSetBit();if(s<0)return t;for(r<s&&(s=r),s>0&&(t.rShiftTo(s,t),n.rShiftTo(s,n));t.signum()>0;)(r=t.getLowestSetBit())>0&&t.rShiftTo(r,t),(r=n.getLowestSetBit())>0&&n.rShiftTo(r,n),t.compareTo(n)>=0?(t.subTo(n,t),t.rShiftTo(1,t)):(n.subTo(t,n),n.rShiftTo(1,n));return s>0&&n.lShiftTo(s,n),n},BigInteger.prototype.isProbablePrime=function bnIsProbablePrime(e){var t,n=this.abs();if(1==n.t&&n[0]<=l[l.length-1]){for(t=0;t<l.length;++t)if(n[0]==l[t])return!0;return!1}if(n.isEven())return!1;for(t=1;t<l.length;){for(var i=l[t],r=t+1;r<l.length&&i<c;)i*=l[r++];for(i=n.modInt(i);t<r;)if(i%l[t++]==0)return!1}return n.millerRabin(e)},BigInteger.prototype.square=function bnSquare(){var e=nbi();return this.squareTo(e),e};var p=BigInteger;p.prototype.IsNegative=function(){return-1==this.compareTo(p.ZERO)},p.op_Equality=function(e,t){return 0==e.compareTo(t)},p.op_Inequality=function(e,t){return 0!=e.compareTo(t)},p.op_GreaterThan=function(e,t){return e.compareTo(t)>0},p.op_LessThan=function(e,t){return e.compareTo(t)<0},p.op_Addition=function(e,t){return new p(e,void 0,void 0).add(new p(t,void 0,void 0))},p.op_Subtraction=function(e,t){return new p(e,void 0,void 0).subtract(new p(t,void 0,void 0))},p.Int128Mul=function(e,t){return new p(e,void 0,void 0).multiply(new p(t,void 0,void 0))},p.op_Division=function(e,t){return e.divide(t)},p.prototype.ToDouble=function(){return parseFloat(this.toString())};var Inherit=function(e,t){var n;if(void 0===Object.getOwnPropertyNames){for(n in t.prototype)void 0!==e.prototype[n]&&e.prototype[n]!==Object.prototype[n]||(e.prototype[n]=t.prototype[n]);for(n in t)void 0===e[n]&&(e[n]=t[n]);e.$baseCtor=t}else{for(var i=Object.getOwnPropertyNames(t.prototype),r=0;r<i.length;r++)void 0===Object.getOwnPropertyDescriptor(e.prototype,i[r])&&Object.defineProperty(e.prototype,i[r],Object.getOwnPropertyDescriptor(t.prototype,i[r]));for(n in t)void 0===e[n]&&(e[n]=t[n]);e.$baseCtor=t}};t.Path=function(){return[]},t.Path.prototype.push=Array.prototype.push,t.Paths=function(){return[]},t.Paths.prototype.push=Array.prototype.push,t.DoublePoint=function(){var e=arguments;this.X=0,this.Y=0,1===e.length?(this.X=e[0].X,this.Y=e[0].Y):2===e.length&&(this.X=e[0],this.Y=e[1])},t.DoublePoint0=function(){this.X=0,this.Y=0},t.DoublePoint0.prototype=t.DoublePoint.prototype,t.DoublePoint1=function(e){this.X=e.X,this.Y=e.Y},t.DoublePoint1.prototype=t.DoublePoint.prototype,t.DoublePoint2=function(e,t){this.X=e,this.Y=t},t.DoublePoint2.prototype=t.DoublePoint.prototype,t.PolyNode=function(){this.m_Parent=null,this.m_polygon=new t.Path,this.m_Index=0,this.m_jointype=0,this.m_endtype=0,this.m_Childs=[],this.IsOpen=!1},t.PolyNode.prototype.IsHoleNode=function(){for(var e=!0,t=this.m_Parent;null!==t;)e=!e,t=t.m_Parent;return e},t.PolyNode.prototype.ChildCount=function(){return this.m_Childs.length},t.PolyNode.prototype.Contour=function(){return this.m_polygon},t.PolyNode.prototype.AddChild=function(e){var t=this.m_Childs.length;this.m_Childs.push(e),e.m_Parent=this,e.m_Index=t},t.PolyNode.prototype.GetNext=function(){return this.m_Childs.length>0?this.m_Childs[0]:this.GetNextSiblingUp()},t.PolyNode.prototype.GetNextSiblingUp=function(){return null===this.m_Parent?null:this.m_Index===this.m_Parent.m_Childs.length-1?this.m_Parent.GetNextSiblingUp():this.m_Parent.m_Childs[this.m_Index+1]},t.PolyNode.prototype.Childs=function(){return this.m_Childs},t.PolyNode.prototype.Parent=function(){return this.m_Parent},t.PolyNode.prototype.IsHole=function(){return this.IsHoleNode()},t.PolyTree=function(){this.m_AllPolys=[],t.PolyNode.call(this)},t.PolyTree.prototype.Clear=function(){for(var e=0,t=this.m_AllPolys.length;e<t;e++)this.m_AllPolys[e]=null;this.m_AllPolys.length=0,this.m_Childs.length=0},t.PolyTree.prototype.GetFirst=function(){return this.m_Childs.length>0?this.m_Childs[0]:null},t.PolyTree.prototype.Total=function(){var e=this.m_AllPolys.length;return e>0&&this.m_Childs[0]!==this.m_AllPolys[0]&&e--,e},Inherit(t.PolyTree,t.PolyNode),t.Math_Abs_Int64=t.Math_Abs_Int32=t.Math_Abs_Double=function(e){return Math.abs(e)},t.Math_Max_Int32_Int32=function(e,t){return Math.max(e,t)},s.msie||s.opera||s.safari?t.Cast_Int32=function(e){return 0|e}:t.Cast_Int32=function(e){return~~e},void 0===Number.toInteger&&(Number.toInteger=null),s.chrome?t.Cast_Int64=function(e){return e<-2147483648||e>2147483647?e<0?Math.ceil(e):Math.floor(e):~~e}:s.firefox&&"function"==typeof Number.toInteger?t.Cast_Int64=function(e){return Number.toInteger(e)}:s.msie7||s.msie8?t.Cast_Int64=function(e){return parseInt(e,10)}:s.msie?t.Cast_Int64=function(e){return e<-2147483648||e>2147483647?e<0?Math.ceil(e):Math.floor(e):0|e}:t.Cast_Int64=function(e){return e<0?Math.ceil(e):Math.floor(e)},t.Clear=function(e){e.length=0},t.PI=3.141592653589793,t.PI2=6.283185307179586,t.IntPoint=function(){var e=arguments,n=e.length;if(this.X=0,this.Y=0,t.use_xyz)if(this.Z=0,3===n)this.X=e[0],this.Y=e[1],this.Z=e[2];else if(2===n)this.X=e[0],this.Y=e[1],this.Z=0;else if(1===n)if(e[0]instanceof t.DoublePoint){var i=e[0];this.X=t.Clipper.Round(i.X),this.Y=t.Clipper.Round(i.Y),this.Z=0}else void 0===(r=e[0]).Z&&(r.Z=0),this.X=r.X,this.Y=r.Y,this.Z=r.Z;else this.X=0,this.Y=0,this.Z=0;else if(2===n)this.X=e[0],this.Y=e[1];else if(1===n)if(e[0]instanceof t.DoublePoint)i=e[0],this.X=t.Clipper.Round(i.X),this.Y=t.Clipper.Round(i.Y);else{var r=e[0];this.X=r.X,this.Y=r.Y}else this.X=0,this.Y=0},t.IntPoint.op_Equality=function(e,t){return e.X===t.X&&e.Y===t.Y},t.IntPoint.op_Inequality=function(e,t){return e.X!==t.X||e.Y!==t.Y},t.IntPoint0=function(){this.X=0,this.Y=0,t.use_xyz&&(this.Z=0)},t.IntPoint0.prototype=t.IntPoint.prototype,t.IntPoint1=function(e){this.X=e.X,this.Y=e.Y,t.use_xyz&&(void 0===e.Z?this.Z=0:this.Z=e.Z)},t.IntPoint1.prototype=t.IntPoint.prototype,t.IntPoint1dp=function(e){this.X=t.Clipper.Round(e.X),this.Y=t.Clipper.Round(e.Y),t.use_xyz&&(this.Z=0)},t.IntPoint1dp.prototype=t.IntPoint.prototype,t.IntPoint2=function(e,n,i){this.X=e,this.Y=n,t.use_xyz&&(this.Z=void 0===i?0:i)},t.IntPoint2.prototype=t.IntPoint.prototype,t.IntRect=function(){var e=arguments,t=e.length;if(4===t)this.left=e[0],this.top=e[1],this.right=e[2],this.bottom=e[3];else if(1===t){var n=e[0];this.left=n.left,this.top=n.top,this.right=n.right,this.bottom=n.bottom}else this.left=0,this.top=0,this.right=0,this.bottom=0},t.IntRect0=function(){this.left=0,this.top=0,this.right=0,this.bottom=0},t.IntRect0.prototype=t.IntRect.prototype,t.IntRect1=function(e){this.left=e.left,this.top=e.top,this.right=e.right,this.bottom=e.bottom},t.IntRect1.prototype=t.IntRect.prototype,t.IntRect4=function(e,t,n,i){this.left=e,this.top=t,this.right=n,this.bottom=i},t.IntRect4.prototype=t.IntRect.prototype,t.ClipType={ctIntersection:0,ctUnion:1,ctDifference:2,ctXor:3},t.PolyType={ptSubject:0,ptClip:1},t.PolyFillType={pftEvenOdd:0,pftNonZero:1,pftPositive:2,pftNegative:3},t.JoinType={jtSquare:0,jtRound:1,jtMiter:2},t.EndType={etOpenSquare:0,etOpenRound:1,etOpenButt:2,etClosedLine:3,etClosedPolygon:4},t.EdgeSide={esLeft:0,esRight:1},t.Direction={dRightToLeft:0,dLeftToRight:1},t.TEdge=function(){this.Bot=new t.IntPoint0,this.Curr=new t.IntPoint0,this.Top=new t.IntPoint0,this.Delta=new t.IntPoint0,this.Dx=0,this.PolyTyp=t.PolyType.ptSubject,this.Side=t.EdgeSide.esLeft,this.WindDelta=0,this.WindCnt=0,this.WindCnt2=0,this.OutIdx=0,this.Next=null,this.Prev=null,this.NextInLML=null,this.NextInAEL=null,this.PrevInAEL=null,this.NextInSEL=null,this.PrevInSEL=null},t.IntersectNode=function(){this.Edge1=null,this.Edge2=null,this.Pt=new t.IntPoint0},t.MyIntersectNodeSort=function(){},t.MyIntersectNodeSort.Compare=function(e,t){var n=t.Pt.Y-e.Pt.Y;return n>0?1:n<0?-1:0},t.LocalMinima=function(){this.Y=0,this.LeftBound=null,this.RightBound=null,this.Next=null},t.Scanbeam=function(){this.Y=0,this.Next=null},t.Maxima=function(){this.X=0,this.Next=null,this.Prev=null},t.OutRec=function(){this.Idx=0,this.IsHole=!1,this.IsOpen=!1,this.FirstLeft=null,this.Pts=null,this.BottomPt=null,this.PolyNode=null},t.OutPt=function(){this.Idx=0,this.Pt=new t.IntPoint0,this.Next=null,this.Prev=null},t.Join=function(){this.OutPt1=null,this.OutPt2=null,this.OffPt=new t.IntPoint0},t.ClipperBase=function(){this.m_MinimaList=null,this.m_CurrentLM=null,this.m_edges=new Array,this.m_UseFullRange=!1,this.m_HasOpenPaths=!1,this.PreserveCollinear=!1,this.m_Scanbeam=null,this.m_PolyOuts=null,this.m_ActiveEdges=null},t.ClipperBase.horizontal=-9007199254740992,t.ClipperBase.Skip=-2,t.ClipperBase.Unassigned=-1,t.ClipperBase.tolerance=1e-20,t.ClipperBase.loRange=47453132,t.ClipperBase.hiRange=0xfffffffffffff,t.ClipperBase.near_zero=function(e){return e>-t.ClipperBase.tolerance&&e<t.ClipperBase.tolerance},t.ClipperBase.IsHorizontal=function(e){return 0===e.Delta.Y},t.ClipperBase.prototype.PointIsVertex=function(e,n){var i=n;do{if(t.IntPoint.op_Equality(i.Pt,e))return!0;i=i.Next}while(i!==n);return!1},t.ClipperBase.prototype.PointOnLineSegment=function(e,t,n,i){return i?e.X===t.X&&e.Y===t.Y||e.X===n.X&&e.Y===n.Y||e.X>t.X==e.X<n.X&&e.Y>t.Y==e.Y<n.Y&&p.op_Equality(p.Int128Mul(e.X-t.X,n.Y-t.Y),p.Int128Mul(n.X-t.X,e.Y-t.Y)):e.X===t.X&&e.Y===t.Y||e.X===n.X&&e.Y===n.Y||e.X>t.X==e.X<n.X&&e.Y>t.Y==e.Y<n.Y&&(e.X-t.X)*(n.Y-t.Y)==(n.X-t.X)*(e.Y-t.Y)},t.ClipperBase.prototype.PointOnPolygon=function(e,t,n){for(var i=t;;){if(this.PointOnLineSegment(e,i.Pt,i.Next.Pt,n))return!0;if((i=i.Next)===t)break}return!1},t.ClipperBase.prototype.SlopesEqual=t.ClipperBase.SlopesEqual=function(){var e,n,i,r,s,o,a=arguments,A=a.length;return 3===A?(e=a[0],n=a[1],a[2]?p.op_Equality(p.Int128Mul(e.Delta.Y,n.Delta.X),p.Int128Mul(e.Delta.X,n.Delta.Y)):t.Cast_Int64(e.Delta.Y*n.Delta.X)===t.Cast_Int64(e.Delta.X*n.Delta.Y)):4===A?(i=a[0],r=a[1],s=a[2],a[3]?p.op_Equality(p.Int128Mul(i.Y-r.Y,r.X-s.X),p.Int128Mul(i.X-r.X,r.Y-s.Y)):t.Cast_Int64((i.Y-r.Y)*(r.X-s.X))-t.Cast_Int64((i.X-r.X)*(r.Y-s.Y))==0):(i=a[0],r=a[1],s=a[2],o=a[3],a[4]?p.op_Equality(p.Int128Mul(i.Y-r.Y,s.X-o.X),p.Int128Mul(i.X-r.X,s.Y-o.Y)):t.Cast_Int64((i.Y-r.Y)*(s.X-o.X))-t.Cast_Int64((i.X-r.X)*(s.Y-o.Y))==0)},t.ClipperBase.SlopesEqual3=function(e,n,i){return i?p.op_Equality(p.Int128Mul(e.Delta.Y,n.Delta.X),p.Int128Mul(e.Delta.X,n.Delta.Y)):t.Cast_Int64(e.Delta.Y*n.Delta.X)===t.Cast_Int64(e.Delta.X*n.Delta.Y)},t.ClipperBase.SlopesEqual4=function(e,n,i,r){return r?p.op_Equality(p.Int128Mul(e.Y-n.Y,n.X-i.X),p.Int128Mul(e.X-n.X,n.Y-i.Y)):t.Cast_Int64((e.Y-n.Y)*(n.X-i.X))-t.Cast_Int64((e.X-n.X)*(n.Y-i.Y))==0},t.ClipperBase.SlopesEqual5=function(e,n,i,r,s){return s?p.op_Equality(p.Int128Mul(e.Y-n.Y,i.X-r.X),p.Int128Mul(e.X-n.X,i.Y-r.Y)):t.Cast_Int64((e.Y-n.Y)*(i.X-r.X))-t.Cast_Int64((e.X-n.X)*(i.Y-r.Y))==0},t.ClipperBase.prototype.Clear=function(){this.DisposeLocalMinimaList();for(var e=0,n=this.m_edges.length;e<n;++e){for(var i=0,r=this.m_edges[e].length;i<r;++i)this.m_edges[e][i]=null;t.Clear(this.m_edges[e])}t.Clear(this.m_edges),this.m_UseFullRange=!1,this.m_HasOpenPaths=!1},t.ClipperBase.prototype.DisposeLocalMinimaList=function(){for(;null!==this.m_MinimaList;){var e=this.m_MinimaList.Next;this.m_MinimaList=null,this.m_MinimaList=e}this.m_CurrentLM=null},t.ClipperBase.prototype.RangeTest=function(e,n){n.Value?(e.X>t.ClipperBase.hiRange||e.Y>t.ClipperBase.hiRange||-e.X>t.ClipperBase.hiRange||-e.Y>t.ClipperBase.hiRange)&&t.Error("Coordinate outside allowed range in RangeTest()."):(e.X>t.ClipperBase.loRange||e.Y>t.ClipperBase.loRange||-e.X>t.ClipperBase.loRange||-e.Y>t.ClipperBase.loRange)&&(n.Value=!0,this.RangeTest(e,n))},t.ClipperBase.prototype.InitEdge=function(e,n,i,r){e.Next=n,e.Prev=i,e.Curr.X=r.X,e.Curr.Y=r.Y,t.use_xyz&&(e.Curr.Z=r.Z),e.OutIdx=-1},t.ClipperBase.prototype.InitEdge2=function(e,n){e.Curr.Y>=e.Next.Curr.Y?(e.Bot.X=e.Curr.X,e.Bot.Y=e.Curr.Y,t.use_xyz&&(e.Bot.Z=e.Curr.Z),e.Top.X=e.Next.Curr.X,e.Top.Y=e.Next.Curr.Y,t.use_xyz&&(e.Top.Z=e.Next.Curr.Z)):(e.Top.X=e.Curr.X,e.Top.Y=e.Curr.Y,t.use_xyz&&(e.Top.Z=e.Curr.Z),e.Bot.X=e.Next.Curr.X,e.Bot.Y=e.Next.Curr.Y,t.use_xyz&&(e.Bot.Z=e.Next.Curr.Z)),this.SetDx(e),e.PolyTyp=n},t.ClipperBase.prototype.FindNextLocMin=function(e){for(var n;;){for(;t.IntPoint.op_Inequality(e.Bot,e.Prev.Bot)||t.IntPoint.op_Equality(e.Curr,e.Top);)e=e.Next;if(e.Dx!==t.ClipperBase.horizontal&&e.Prev.Dx!==t.ClipperBase.horizontal)break;for(;e.Prev.Dx===t.ClipperBase.horizontal;)e=e.Prev;for(n=e;e.Dx===t.ClipperBase.horizontal;)e=e.Next;if(e.Top.Y!==e.Prev.Bot.Y){n.Prev.Bot.X<e.Bot.X&&(e=n);break}}return e},t.ClipperBase.prototype.ProcessBound=function(e,n){var i,r,s=e;if(s.OutIdx===t.ClipperBase.Skip){if(e=s,n){for(;e.Top.Y===e.Next.Bot.Y;)e=e.Next;for(;e!==s&&e.Dx===t.ClipperBase.horizontal;)e=e.Prev}else{for(;e.Top.Y===e.Prev.Bot.Y;)e=e.Prev;for(;e!==s&&e.Dx===t.ClipperBase.horizontal;)e=e.Next}if(e===s)s=n?e.Next:e.Prev;else{e=n?s.Next:s.Prev;var o=new t.LocalMinima;o.Next=null,o.Y=e.Bot.Y,o.LeftBound=null,o.RightBound=e,e.WindDelta=0,s=this.ProcessBound(e,n),this.InsertLocalMinima(o)}return s}if(e.Dx===t.ClipperBase.horizontal&&((i=n?e.Prev:e.Next).Dx===t.ClipperBase.horizontal?i.Bot.X!==e.Bot.X&&i.Top.X!==e.Bot.X&&this.ReverseHorizontal(e):i.Bot.X!==e.Bot.X&&this.ReverseHorizontal(e)),i=e,n){for(;s.Top.Y===s.Next.Bot.Y&&s.Next.OutIdx!==t.ClipperBase.Skip;)s=s.Next;if(s.Dx===t.ClipperBase.horizontal&&s.Next.OutIdx!==t.ClipperBase.Skip){for(r=s;r.Prev.Dx===t.ClipperBase.horizontal;)r=r.Prev;r.Prev.Top.X>s.Next.Top.X&&(s=r.Prev)}for(;e!==s;)e.NextInLML=e.Next,e.Dx===t.ClipperBase.horizontal&&e!==i&&e.Bot.X!==e.Prev.Top.X&&this.ReverseHorizontal(e),e=e.Next;e.Dx===t.ClipperBase.horizontal&&e!==i&&e.Bot.X!==e.Prev.Top.X&&this.ReverseHorizontal(e),s=s.Next}else{for(;s.Top.Y===s.Prev.Bot.Y&&s.Prev.OutIdx!==t.ClipperBase.Skip;)s=s.Prev;if(s.Dx===t.ClipperBase.horizontal&&s.Prev.OutIdx!==t.ClipperBase.Skip){for(r=s;r.Next.Dx===t.ClipperBase.horizontal;)r=r.Next;(r.Next.Top.X===s.Prev.Top.X||r.Next.Top.X>s.Prev.Top.X)&&(s=r.Next)}for(;e!==s;)e.NextInLML=e.Prev,e.Dx===t.ClipperBase.horizontal&&e!==i&&e.Bot.X!==e.Next.Top.X&&this.ReverseHorizontal(e),e=e.Prev;e.Dx===t.ClipperBase.horizontal&&e!==i&&e.Bot.X!==e.Next.Top.X&&this.ReverseHorizontal(e),s=s.Prev}return s},t.ClipperBase.prototype.AddPath=function(e,n,i){t.use_lines?i||n!==t.PolyType.ptClip||t.Error("AddPath: Open paths must be subject."):i||t.Error("AddPath: Open paths have been disabled.");var r=e.length-1;if(i)for(;r>0&&t.IntPoint.op_Equality(e[r],e[0]);)--r;for(;r>0&&t.IntPoint.op_Equality(e[r],e[r-1]);)--r;if(i&&r<2||!i&&r<1)return!1;for(var s=new Array,o=0;o<=r;o++)s.push(new t.TEdge);var a=!0;s[1].Curr.X=e[1].X,s[1].Curr.Y=e[1].Y,t.use_xyz&&(s[1].Curr.Z=e[1].Z);var A={Value:this.m_UseFullRange};for(this.RangeTest(e[0],A),this.m_UseFullRange=A.Value,A.Value=this.m_UseFullRange,this.RangeTest(e[r],A),this.m_UseFullRange=A.Value,this.InitEdge(s[0],s[1],s[r],e[0]),this.InitEdge(s[r],s[0],s[r-1],e[r]),o=r-1;o>=1;--o)A.Value=this.m_UseFullRange,this.RangeTest(e[o],A),this.m_UseFullRange=A.Value,this.InitEdge(s[o],s[o+1],s[o-1],e[o]);for(var l,c=s[0],p=c,h=c;;)if(p.Curr!==p.Next.Curr||!i&&p.Next===c){if(p.Prev===p.Next)break;if(!i||!t.ClipperBase.SlopesEqual4(p.Prev.Curr,p.Curr,p.Next.Curr,this.m_UseFullRange)||this.PreserveCollinear&&this.Pt2IsBetweenPt1AndPt3(p.Prev.Curr,p.Curr,p.Next.Curr)){if((p=p.Next)===h||!i&&p.Next===c)break}else p===c&&(c=p.Next),h=p=(p=this.RemoveEdge(p)).Prev}else{if(p===p.Next)break;p===c&&(c=p.Next),h=p=this.RemoveEdge(p)}if(!i&&p===p.Next||i&&p.Prev===p.Next)return!1;i||(this.m_HasOpenPaths=!0,c.Prev.OutIdx=t.ClipperBase.Skip),p=c;do{this.InitEdge2(p,n),p=p.Next,a&&p.Curr.Y!==c.Curr.Y&&(a=!1)}while(p!==c);if(a){if(i)return!1;for(p.Prev.OutIdx=t.ClipperBase.Skip,(d=new t.LocalMinima).Next=null,d.Y=p.Bot.Y,d.LeftBound=null,d.RightBound=p,d.RightBound.Side=t.EdgeSide.esRight,d.RightBound.WindDelta=0;p.Bot.X!==p.Prev.Top.X&&this.ReverseHorizontal(p),p.Next.OutIdx!==t.ClipperBase.Skip;)p.NextInLML=p.Next,p=p.Next;return this.InsertLocalMinima(d),this.m_edges.push(s),!0}this.m_edges.push(s);var u=null;for(t.IntPoint.op_Equality(p.Prev.Bot,p.Prev.Top)&&(p=p.Next);(p=this.FindNextLocMin(p))!==u;){var d;null===u&&(u=p),(d=new t.LocalMinima).Next=null,d.Y=p.Bot.Y,p.Dx<p.Prev.Dx?(d.LeftBound=p.Prev,d.RightBound=p,l=!1):(d.LeftBound=p,d.RightBound=p.Prev,l=!0),d.LeftBound.Side=t.EdgeSide.esLeft,d.RightBound.Side=t.EdgeSide.esRight,i?d.LeftBound.Next===d.RightBound?d.LeftBound.WindDelta=-1:d.LeftBound.WindDelta=1:d.LeftBound.WindDelta=0,d.RightBound.WindDelta=-d.LeftBound.WindDelta,(p=this.ProcessBound(d.LeftBound,l)).OutIdx===t.ClipperBase.Skip&&(p=this.ProcessBound(p,l));var g=this.ProcessBound(d.RightBound,!l);g.OutIdx===t.ClipperBase.Skip&&(g=this.ProcessBound(g,!l)),d.LeftBound.OutIdx===t.ClipperBase.Skip?d.LeftBound=null:d.RightBound.OutIdx===t.ClipperBase.Skip&&(d.RightBound=null),this.InsertLocalMinima(d),l||(p=g)}return!0},t.ClipperBase.prototype.AddPaths=function(e,t,n){for(var i=!1,r=0,s=e.length;r<s;++r)this.AddPath(e[r],t,n)&&(i=!0);return i},t.ClipperBase.prototype.Pt2IsBetweenPt1AndPt3=function(e,n,i){return!(t.IntPoint.op_Equality(e,i)||t.IntPoint.op_Equality(e,n)||t.IntPoint.op_Equality(i,n))&&(e.X!==i.X?n.X>e.X==n.X<i.X:n.Y>e.Y==n.Y<i.Y)},t.ClipperBase.prototype.RemoveEdge=function(e){e.Prev.Next=e.Next,e.Next.Prev=e.Prev;var t=e.Next;return e.Prev=null,t},t.ClipperBase.prototype.SetDx=function(e){e.Delta.X=e.Top.X-e.Bot.X,e.Delta.Y=e.Top.Y-e.Bot.Y,0===e.Delta.Y?e.Dx=t.ClipperBase.horizontal:e.Dx=e.Delta.X/e.Delta.Y},t.ClipperBase.prototype.InsertLocalMinima=function(e){if(null===this.m_MinimaList)this.m_MinimaList=e;else if(e.Y>=this.m_MinimaList.Y)e.Next=this.m_MinimaList,this.m_MinimaList=e;else{for(var t=this.m_MinimaList;null!==t.Next&&e.Y<t.Next.Y;)t=t.Next;e.Next=t.Next,t.Next=e}},t.ClipperBase.prototype.PopLocalMinima=function(e,t){return t.v=this.m_CurrentLM,null!==this.m_CurrentLM&&this.m_CurrentLM.Y===e&&(this.m_CurrentLM=this.m_CurrentLM.Next,!0)},t.ClipperBase.prototype.ReverseHorizontal=function(e){var n=e.Top.X;e.Top.X=e.Bot.X,e.Bot.X=n,t.use_xyz&&(n=e.Top.Z,e.Top.Z=e.Bot.Z,e.Bot.Z=n)},t.ClipperBase.prototype.Reset=function(){if(this.m_CurrentLM=this.m_MinimaList,null!==this.m_CurrentLM){this.m_Scanbeam=null;for(var e=this.m_MinimaList;null!==e;){this.InsertScanbeam(e.Y);var n=e.LeftBound;null!==n&&(n.Curr.X=n.Bot.X,n.Curr.Y=n.Bot.Y,t.use_xyz&&(n.Curr.Z=n.Bot.Z),n.OutIdx=t.ClipperBase.Unassigned),null!==(n=e.RightBound)&&(n.Curr.X=n.Bot.X,n.Curr.Y=n.Bot.Y,t.use_xyz&&(n.Curr.Z=n.Bot.Z),n.OutIdx=t.ClipperBase.Unassigned),e=e.Next}this.m_ActiveEdges=null}},t.ClipperBase.prototype.InsertScanbeam=function(e){if(null===this.m_Scanbeam)this.m_Scanbeam=new t.Scanbeam,this.m_Scanbeam.Next=null,this.m_Scanbeam.Y=e;else if(e>this.m_Scanbeam.Y){var n=new t.Scanbeam;n.Y=e,n.Next=this.m_Scanbeam,this.m_Scanbeam=n}else{for(var i=this.m_Scanbeam;null!==i.Next&&e<=i.Next.Y;)i=i.Next;if(e===i.Y)return;var r=new t.Scanbeam;r.Y=e,r.Next=i.Next,i.Next=r}},t.ClipperBase.prototype.PopScanbeam=function(e){return null===this.m_Scanbeam?(e.v=0,!1):(e.v=this.m_Scanbeam.Y,this.m_Scanbeam=this.m_Scanbeam.Next,!0)},t.ClipperBase.prototype.LocalMinimaPending=function(){return null!==this.m_CurrentLM},t.ClipperBase.prototype.CreateOutRec=function(){var e=new t.OutRec;return e.Idx=t.ClipperBase.Unassigned,e.IsHole=!1,e.IsOpen=!1,e.FirstLeft=null,e.Pts=null,e.BottomPt=null,e.PolyNode=null,this.m_PolyOuts.push(e),e.Idx=this.m_PolyOuts.length-1,e},t.ClipperBase.prototype.DisposeOutRec=function(e){var t=this.m_PolyOuts[e];t.Pts=null,t=null,this.m_PolyOuts[e]=null},t.ClipperBase.prototype.UpdateEdgeIntoAEL=function(e){null===e.NextInLML&&t.Error("UpdateEdgeIntoAEL: invalid call");var n=e.PrevInAEL,i=e.NextInAEL;return e.NextInLML.OutIdx=e.OutIdx,null!==n?n.NextInAEL=e.NextInLML:this.m_ActiveEdges=e.NextInLML,null!==i&&(i.PrevInAEL=e.NextInLML),e.NextInLML.Side=e.Side,e.NextInLML.WindDelta=e.WindDelta,e.NextInLML.WindCnt=e.WindCnt,e.NextInLML.WindCnt2=e.WindCnt2,(e=e.NextInLML).Curr.X=e.Bot.X,e.Curr.Y=e.Bot.Y,e.PrevInAEL=n,e.NextInAEL=i,t.ClipperBase.IsHorizontal(e)||this.InsertScanbeam(e.Top.Y),e},t.ClipperBase.prototype.SwapPositionsInAEL=function(e,t){if(e.NextInAEL!==e.PrevInAEL&&t.NextInAEL!==t.PrevInAEL){if(e.NextInAEL===t){var n=t.NextInAEL;null!==n&&(n.PrevInAEL=e);var i=e.PrevInAEL;null!==i&&(i.NextInAEL=t),t.PrevInAEL=i,t.NextInAEL=e,e.PrevInAEL=t,e.NextInAEL=n}else if(t.NextInAEL===e){var r=e.NextInAEL;null!==r&&(r.PrevInAEL=t);var s=t.PrevInAEL;null!==s&&(s.NextInAEL=e),e.PrevInAEL=s,e.NextInAEL=t,t.PrevInAEL=e,t.NextInAEL=r}else{var o=e.NextInAEL,a=e.PrevInAEL;e.NextInAEL=t.NextInAEL,null!==e.NextInAEL&&(e.NextInAEL.PrevInAEL=e),e.PrevInAEL=t.PrevInAEL,null!==e.PrevInAEL&&(e.PrevInAEL.NextInAEL=e),t.NextInAEL=o,null!==t.NextInAEL&&(t.NextInAEL.PrevInAEL=t),t.PrevInAEL=a,null!==t.PrevInAEL&&(t.PrevInAEL.NextInAEL=t)}null===e.PrevInAEL?this.m_ActiveEdges=e:null===t.PrevInAEL&&(this.m_ActiveEdges=t)}},t.ClipperBase.prototype.DeleteFromAEL=function(e){var t=e.PrevInAEL,n=e.NextInAEL;null===t&&null===n&&e!==this.m_ActiveEdges||(null!==t?t.NextInAEL=n:this.m_ActiveEdges=n,null!==n&&(n.PrevInAEL=t),e.NextInAEL=null,e.PrevInAEL=null)},t.Clipper=function(e){void 0===e&&(e=0),this.m_PolyOuts=null,this.m_ClipType=t.ClipType.ctIntersection,this.m_Scanbeam=null,this.m_Maxima=null,this.m_ActiveEdges=null,this.m_SortedEdges=null,this.m_IntersectList=null,this.m_IntersectNodeComparer=null,this.m_ExecuteLocked=!1,this.m_ClipFillType=t.PolyFillType.pftEvenOdd,this.m_SubjFillType=t.PolyFillType.pftEvenOdd,this.m_Joins=null,this.m_GhostJoins=null,this.m_UsingPolyTree=!1,this.ReverseSolution=!1,this.StrictlySimple=!1,t.ClipperBase.call(this),this.m_Scanbeam=null,this.m_Maxima=null,this.m_ActiveEdges=null,this.m_SortedEdges=null,this.m_IntersectList=new Array,this.m_IntersectNodeComparer=t.MyIntersectNodeSort.Compare,this.m_ExecuteLocked=!1,this.m_UsingPolyTree=!1,this.m_PolyOuts=new Array,this.m_Joins=new Array,this.m_GhostJoins=new Array,this.ReverseSolution=!!(1&e),this.StrictlySimple=!!(2&e),this.PreserveCollinear=!!(4&e),t.use_xyz&&(this.ZFillFunction=null)},t.Clipper.ioReverseSolution=1,t.Clipper.ioStrictlySimple=2,t.Clipper.ioPreserveCollinear=4,t.Clipper.prototype.Clear=function(){0!==this.m_edges.length&&(this.DisposeAllPolyPts(),t.ClipperBase.prototype.Clear.call(this))},t.Clipper.prototype.InsertMaxima=function(e){var n=new t.Maxima;if(n.X=e,null===this.m_Maxima)this.m_Maxima=n,this.m_Maxima.Next=null,this.m_Maxima.Prev=null;else if(e<this.m_Maxima.X)n.Next=this.m_Maxima,n.Prev=null,this.m_Maxima=n;else{for(var i=this.m_Maxima;null!==i.Next&&e>=i.Next.X;)i=i.Next;if(e===i.X)return;n.Next=i.Next,n.Prev=i,null!==i.Next&&(i.Next.Prev=n),i.Next=n}},t.Clipper.prototype.Execute=function(){var e=arguments,n=e.length,i=e[1]instanceof t.PolyTree;if(4===n&&!i){var r=e[0],s=e[1],o=e[2],a=e[3];if(this.m_ExecuteLocked)return!1;this.m_HasOpenPaths&&t.Error("Error: PolyTree struct is needed for open path clipping."),this.m_ExecuteLocked=!0,t.Clear(s),this.m_SubjFillType=o,this.m_ClipFillType=a,this.m_ClipType=r,this.m_UsingPolyTree=!1;try{(l=this.ExecuteInternal())&&this.BuildResult(s)}finally{this.DisposeAllPolyPts(),this.m_ExecuteLocked=!1}return l}if(4===n&&i){r=e[0];var A=e[1];if(o=e[2],a=e[3],this.m_ExecuteLocked)return!1;this.m_ExecuteLocked=!0,this.m_SubjFillType=o,this.m_ClipFillType=a,this.m_ClipType=r,this.m_UsingPolyTree=!0;try{var l;(l=this.ExecuteInternal())&&this.BuildResult2(A)}finally{this.DisposeAllPolyPts(),this.m_ExecuteLocked=!1}return l}return 2!==n||i?2===n&&i?(r=e[0],A=e[1],this.Execute(r,A,t.PolyFillType.pftEvenOdd,t.PolyFillType.pftEvenOdd)):void 0:(r=e[0],s=e[1],this.Execute(r,s,t.PolyFillType.pftEvenOdd,t.PolyFillType.pftEvenOdd))},t.Clipper.prototype.FixHoleLinkage=function(e){if(null!==e.FirstLeft&&(e.IsHole===e.FirstLeft.IsHole||null===e.FirstLeft.Pts)){for(var t=e.FirstLeft;null!==t&&(t.IsHole===e.IsHole||null===t.Pts);)t=t.FirstLeft;e.FirstLeft=t}},t.Clipper.prototype.ExecuteInternal=function(){try{this.Reset(),this.m_SortedEdges=null,this.m_Maxima=null;var e,t,n,i={},r={};if(!this.PopScanbeam(i))return!1;for(this.InsertLocalMinimaIntoAEL(i.v);this.PopScanbeam(r)||this.LocalMinimaPending();){if(this.ProcessHorizontals(),this.m_GhostJoins.length=0,!this.ProcessIntersections(r.v))return!1;this.ProcessEdgesAtTopOfScanbeam(r.v),i.v=r.v,this.InsertLocalMinimaIntoAEL(i.v)}for(t=0,n=this.m_PolyOuts.length;t<n;t++)null===(e=this.m_PolyOuts[t]).Pts||e.IsOpen||(e.IsHole^this.ReverseSolution)==this.Area$1(e)>0&&this.ReversePolyPtLinks(e.Pts);for(this.JoinCommonEdges(),t=0,n=this.m_PolyOuts.length;t<n;t++)null!==(e=this.m_PolyOuts[t]).Pts&&(e.IsOpen?this.FixupOutPolyline(e):this.FixupOutPolygon(e));return this.StrictlySimple&&this.DoSimplePolygons(),!0}finally{this.m_Joins.length=0,this.m_GhostJoins.length=0}},t.Clipper.prototype.DisposeAllPolyPts=function(){for(var e=0,n=this.m_PolyOuts.length;e<n;++e)this.DisposeOutRec(e);t.Clear(this.m_PolyOuts)},t.Clipper.prototype.AddJoin=function(e,n,i){var r=new t.Join;r.OutPt1=e,r.OutPt2=n,r.OffPt.X=i.X,r.OffPt.Y=i.Y,t.use_xyz&&(r.OffPt.Z=i.Z),this.m_Joins.push(r)},t.Clipper.prototype.AddGhostJoin=function(e,n){var i=new t.Join;i.OutPt1=e,i.OffPt.X=n.X,i.OffPt.Y=n.Y,t.use_xyz&&(i.OffPt.Z=n.Z),this.m_GhostJoins.push(i)},t.Clipper.prototype.SetZ=function(e,n,i){if(null!==this.ZFillFunction){if(0!==e.Z||null===this.ZFillFunction)return;t.IntPoint.op_Equality(e,n.Bot)?e.Z=n.Bot.Z:t.IntPoint.op_Equality(e,n.Top)?e.Z=n.Top.Z:t.IntPoint.op_Equality(e,i.Bot)?e.Z=i.Bot.Z:t.IntPoint.op_Equality(e,i.Top)?e.Z=i.Top.Z:this.ZFillFunction(n.Bot,n.Top,i.Bot,i.Top,e)}},t.Clipper.prototype.InsertLocalMinimaIntoAEL=function(e){for(var n,i,r={};this.PopLocalMinima(e,r);){n=r.v.LeftBound,i=r.v.RightBound;var s=null;if(null===n?(this.InsertEdgeIntoAEL(i,null),this.SetWindingCount(i),this.IsContributing(i)&&(s=this.AddOutPt(i,i.Bot))):null===i?(this.InsertEdgeIntoAEL(n,null),this.SetWindingCount(n),this.IsContributing(n)&&(s=this.AddOutPt(n,n.Bot)),this.InsertScanbeam(n.Top.Y)):(this.InsertEdgeIntoAEL(n,null),this.InsertEdgeIntoAEL(i,n),this.SetWindingCount(n),i.WindCnt=n.WindCnt,i.WindCnt2=n.WindCnt2,this.IsContributing(n)&&(s=this.AddLocalMinPoly(n,i,n.Bot)),this.InsertScanbeam(n.Top.Y)),null!==i&&(t.ClipperBase.IsHorizontal(i)?(null!==i.NextInLML&&this.InsertScanbeam(i.NextInLML.Top.Y),this.AddEdgeToSEL(i)):this.InsertScanbeam(i.Top.Y)),null!==n&&null!==i){if(null!==s&&t.ClipperBase.IsHorizontal(i)&&this.m_GhostJoins.length>0&&0!==i.WindDelta)for(var o=0,a=this.m_GhostJoins.length;o<a;o++){var A=this.m_GhostJoins[o];this.HorzSegmentsOverlap(A.OutPt1.Pt.X,A.OffPt.X,i.Bot.X,i.Top.X)&&this.AddJoin(A.OutPt1,s,A.OffPt)}if(n.OutIdx>=0&&null!==n.PrevInAEL&&n.PrevInAEL.Curr.X===n.Bot.X&&n.PrevInAEL.OutIdx>=0&&t.ClipperBase.SlopesEqual5(n.PrevInAEL.Curr,n.PrevInAEL.Top,n.Curr,n.Top,this.m_UseFullRange)&&0!==n.WindDelta&&0!==n.PrevInAEL.WindDelta){var l=this.AddOutPt(n.PrevInAEL,n.Bot);this.AddJoin(s,l,n.Top)}if(n.NextInAEL!==i){i.OutIdx>=0&&i.PrevInAEL.OutIdx>=0&&t.ClipperBase.SlopesEqual5(i.PrevInAEL.Curr,i.PrevInAEL.Top,i.Curr,i.Top,this.m_UseFullRange)&&0!==i.WindDelta&&0!==i.PrevInAEL.WindDelta&&(l=this.AddOutPt(i.PrevInAEL,i.Bot),this.AddJoin(s,l,i.Top));var c=n.NextInAEL;if(null!==c)for(;c!==i;)this.IntersectEdges(i,c,n.Curr),c=c.NextInAEL}}}},t.Clipper.prototype.InsertEdgeIntoAEL=function(e,t){if(null===this.m_ActiveEdges)e.PrevInAEL=null,e.NextInAEL=null,this.m_ActiveEdges=e;else if(null===t&&this.E2InsertsBeforeE1(this.m_ActiveEdges,e))e.PrevInAEL=null,e.NextInAEL=this.m_ActiveEdges,this.m_ActiveEdges.PrevInAEL=e,this.m_ActiveEdges=e;else{for(null===t&&(t=this.m_ActiveEdges);null!==t.NextInAEL&&!this.E2InsertsBeforeE1(t.NextInAEL,e);)t=t.NextInAEL;e.NextInAEL=t.NextInAEL,null!==t.NextInAEL&&(t.NextInAEL.PrevInAEL=e),e.PrevInAEL=t,t.NextInAEL=e}},t.Clipper.prototype.E2InsertsBeforeE1=function(e,n){return n.Curr.X===e.Curr.X?n.Top.Y>e.Top.Y?n.Top.X<t.Clipper.TopX(e,n.Top.Y):e.Top.X>t.Clipper.TopX(n,e.Top.Y):n.Curr.X<e.Curr.X},t.Clipper.prototype.IsEvenOddFillType=function(e){return e.PolyTyp===t.PolyType.ptSubject?this.m_SubjFillType===t.PolyFillType.pftEvenOdd:this.m_ClipFillType===t.PolyFillType.pftEvenOdd},t.Clipper.prototype.IsEvenOddAltFillType=function(e){return e.PolyTyp===t.PolyType.ptSubject?this.m_ClipFillType===t.PolyFillType.pftEvenOdd:this.m_SubjFillType===t.PolyFillType.pftEvenOdd},t.Clipper.prototype.IsContributing=function(e){var n,i;switch(e.PolyTyp===t.PolyType.ptSubject?(n=this.m_SubjFillType,i=this.m_ClipFillType):(n=this.m_ClipFillType,i=this.m_SubjFillType),n){case t.PolyFillType.pftEvenOdd:if(0===e.WindDelta&&1!==e.WindCnt)return!1;break;case t.PolyFillType.pftNonZero:if(1!==Math.abs(e.WindCnt))return!1;break;case t.PolyFillType.pftPositive:if(1!==e.WindCnt)return!1;break;default:if(-1!==e.WindCnt)return!1}switch(this.m_ClipType){case t.ClipType.ctIntersection:switch(i){case t.PolyFillType.pftEvenOdd:case t.PolyFillType.pftNonZero:return 0!==e.WindCnt2;case t.PolyFillType.pftPositive:return e.WindCnt2>0;default:return e.WindCnt2<0}case t.ClipType.ctUnion:switch(i){case t.PolyFillType.pftEvenOdd:case t.PolyFillType.pftNonZero:return 0===e.WindCnt2;case t.PolyFillType.pftPositive:return e.WindCnt2<=0;default:return e.WindCnt2>=0}case t.ClipType.ctDifference:if(e.PolyTyp===t.PolyType.ptSubject)switch(i){case t.PolyFillType.pftEvenOdd:case t.PolyFillType.pftNonZero:return 0===e.WindCnt2;case t.PolyFillType.pftPositive:return e.WindCnt2<=0;default:return e.WindCnt2>=0}else switch(i){case t.PolyFillType.pftEvenOdd:case t.PolyFillType.pftNonZero:return 0!==e.WindCnt2;case t.PolyFillType.pftPositive:return e.WindCnt2>0;default:return e.WindCnt2<0}case t.ClipType.ctXor:if(0!==e.WindDelta)return!0;switch(i){case t.PolyFillType.pftEvenOdd:case t.PolyFillType.pftNonZero:return 0===e.WindCnt2;case t.PolyFillType.pftPositive:return e.WindCnt2<=0;default:return e.WindCnt2>=0}}return!0},t.Clipper.prototype.SetWindingCount=function(e){for(var n=e.PrevInAEL;null!==n&&(n.PolyTyp!==e.PolyTyp||0===n.WindDelta);)n=n.PrevInAEL;if(null===n){var i=e.PolyTyp===t.PolyType.ptSubject?this.m_SubjFillType:this.m_ClipFillType;0===e.WindDelta?e.WindCnt=i===t.PolyFillType.pftNegative?-1:1:e.WindCnt=e.WindDelta,e.WindCnt2=0,n=this.m_ActiveEdges}else if(0===e.WindDelta&&this.m_ClipType!==t.ClipType.ctUnion)e.WindCnt=1,e.WindCnt2=n.WindCnt2,n=n.NextInAEL;else if(this.IsEvenOddFillType(e)){if(0===e.WindDelta){for(var r=!0,s=n.PrevInAEL;null!==s;)s.PolyTyp===n.PolyTyp&&0!==s.WindDelta&&(r=!r),s=s.PrevInAEL;e.WindCnt=r?0:1}else e.WindCnt=e.WindDelta;e.WindCnt2=n.WindCnt2,n=n.NextInAEL}else n.WindCnt*n.WindDelta<0?Math.abs(n.WindCnt)>1?n.WindDelta*e.WindDelta<0?e.WindCnt=n.WindCnt:e.WindCnt=n.WindCnt+e.WindDelta:e.WindCnt=0===e.WindDelta?1:e.WindDelta:0===e.WindDelta?e.WindCnt=n.WindCnt<0?n.WindCnt-1:n.WindCnt+1:n.WindDelta*e.WindDelta<0?e.WindCnt=n.WindCnt:e.WindCnt=n.WindCnt+e.WindDelta,e.WindCnt2=n.WindCnt2,n=n.NextInAEL;if(this.IsEvenOddAltFillType(e))for(;n!==e;)0!==n.WindDelta&&(e.WindCnt2=0===e.WindCnt2?1:0),n=n.NextInAEL;else for(;n!==e;)e.WindCnt2+=n.WindDelta,n=n.NextInAEL},t.Clipper.prototype.AddEdgeToSEL=function(e){null===this.m_SortedEdges?(this.m_SortedEdges=e,e.PrevInSEL=null,e.NextInSEL=null):(e.NextInSEL=this.m_SortedEdges,e.PrevInSEL=null,this.m_SortedEdges.PrevInSEL=e,this.m_SortedEdges=e)},t.Clipper.prototype.PopEdgeFromSEL=function(e){if(e.v=this.m_SortedEdges,null===e.v)return!1;var t=e.v;return this.m_SortedEdges=e.v.NextInSEL,null!==this.m_SortedEdges&&(this.m_SortedEdges.PrevInSEL=null),t.NextInSEL=null,t.PrevInSEL=null,!0},t.Clipper.prototype.CopyAELToSEL=function(){var e=this.m_ActiveEdges;for(this.m_SortedEdges=e;null!==e;)e.PrevInSEL=e.PrevInAEL,e.NextInSEL=e.NextInAEL,e=e.NextInAEL},t.Clipper.prototype.SwapPositionsInSEL=function(e,t){if(!(null===e.NextInSEL&&null===e.PrevInSEL||null===t.NextInSEL&&null===t.PrevInSEL)){if(e.NextInSEL===t)null!==(n=t.NextInSEL)&&(n.PrevInSEL=e),null!==(i=e.PrevInSEL)&&(i.NextInSEL=t),t.PrevInSEL=i,t.NextInSEL=e,e.PrevInSEL=t,e.NextInSEL=n;else if(t.NextInSEL===e)null!==(n=e.NextInSEL)&&(n.PrevInSEL=t),null!==(i=t.PrevInSEL)&&(i.NextInSEL=e),e.PrevInSEL=i,e.NextInSEL=t,t.PrevInSEL=e,t.NextInSEL=n;else{var n=e.NextInSEL,i=e.PrevInSEL;e.NextInSEL=t.NextInSEL,null!==e.NextInSEL&&(e.NextInSEL.PrevInSEL=e),e.PrevInSEL=t.PrevInSEL,null!==e.PrevInSEL&&(e.PrevInSEL.NextInSEL=e),t.NextInSEL=n,null!==t.NextInSEL&&(t.NextInSEL.PrevInSEL=t),t.PrevInSEL=i,null!==t.PrevInSEL&&(t.PrevInSEL.NextInSEL=t)}null===e.PrevInSEL?this.m_SortedEdges=e:null===t.PrevInSEL&&(this.m_SortedEdges=t)}},t.Clipper.prototype.AddLocalMaxPoly=function(e,t,n){this.AddOutPt(e,n),0===t.WindDelta&&this.AddOutPt(t,n),e.OutIdx===t.OutIdx?(e.OutIdx=-1,t.OutIdx=-1):e.OutIdx<t.OutIdx?this.AppendPolygon(e,t):this.AppendPolygon(t,e)},t.Clipper.prototype.AddLocalMinPoly=function(e,n,i){var r,s,o;if(t.ClipperBase.IsHorizontal(n)||e.Dx>n.Dx?(r=this.AddOutPt(e,i),n.OutIdx=e.OutIdx,e.Side=t.EdgeSide.esLeft,n.Side=t.EdgeSide.esRight,o=(s=e).PrevInAEL===n?n.PrevInAEL:s.PrevInAEL):(r=this.AddOutPt(n,i),e.OutIdx=n.OutIdx,e.Side=t.EdgeSide.esRight,n.Side=t.EdgeSide.esLeft,o=(s=n).PrevInAEL===e?e.PrevInAEL:s.PrevInAEL),null!==o&&o.OutIdx>=0&&o.Top.Y<i.Y&&s.Top.Y<i.Y){var a=t.Clipper.TopX(o,i.Y),A=t.Clipper.TopX(s,i.Y);if(a===A&&0!==s.WindDelta&&0!==o.WindDelta&&t.ClipperBase.SlopesEqual5(new t.IntPoint2(a,i.Y),o.Top,new t.IntPoint2(A,i.Y),s.Top,this.m_UseFullRange)){var l=this.AddOutPt(o,i);this.AddJoin(r,l,s.Top)}}return r},t.Clipper.prototype.AddOutPt=function(e,n){if(e.OutIdx<0){(r=this.CreateOutRec()).IsOpen=0===e.WindDelta;var i=new t.OutPt;return r.Pts=i,i.Idx=r.Idx,i.Pt.X=n.X,i.Pt.Y=n.Y,t.use_xyz&&(i.Pt.Z=n.Z),i.Next=i,i.Prev=i,r.IsOpen||this.SetHoleState(e,r),e.OutIdx=r.Idx,i}var r,s=(r=this.m_PolyOuts[e.OutIdx]).Pts,o=e.Side===t.EdgeSide.esLeft;return o&&t.IntPoint.op_Equality(n,s.Pt)?s:!o&&t.IntPoint.op_Equality(n,s.Prev.Pt)?s.Prev:((i=new t.OutPt).Idx=r.Idx,i.Pt.X=n.X,i.Pt.Y=n.Y,t.use_xyz&&(i.Pt.Z=n.Z),i.Next=s,i.Prev=s.Prev,i.Prev.Next=i,s.Prev=i,o&&(r.Pts=i),i)},t.Clipper.prototype.GetLastOutPt=function(e){var n=this.m_PolyOuts[e.OutIdx];return e.Side===t.EdgeSide.esLeft?n.Pts:n.Pts.Prev},t.Clipper.prototype.SwapPoints=function(e,n){var i=new t.IntPoint1(e.Value);e.Value.X=n.Value.X,e.Value.Y=n.Value.Y,t.use_xyz&&(e.Value.Z=n.Value.Z),n.Value.X=i.X,n.Value.Y=i.Y,t.use_xyz&&(n.Value.Z=i.Z)},t.Clipper.prototype.HorzSegmentsOverlap=function(e,t,n,i){var r;return e>t&&(r=e,e=t,t=r),n>i&&(r=n,n=i,i=r),e<i&&n<t},t.Clipper.prototype.SetHoleState=function(e,t){for(var n=e.PrevInAEL,i=null;null!==n;)n.OutIdx>=0&&0!==n.WindDelta&&(null===i?i=n:i.OutIdx===n.OutIdx&&(i=null)),n=n.PrevInAEL;null===i?(t.FirstLeft=null,t.IsHole=!1):(t.FirstLeft=this.m_PolyOuts[i.OutIdx],t.IsHole=!t.FirstLeft.IsHole)},t.Clipper.prototype.GetDx=function(e,n){return e.Y===n.Y?t.ClipperBase.horizontal:(n.X-e.X)/(n.Y-e.Y)},t.Clipper.prototype.FirstIsBottomPt=function(e,n){for(var i=e.Prev;t.IntPoint.op_Equality(i.Pt,e.Pt)&&i!==e;)i=i.Prev;var r=Math.abs(this.GetDx(e.Pt,i.Pt));for(i=e.Next;t.IntPoint.op_Equality(i.Pt,e.Pt)&&i!==e;)i=i.Next;var s=Math.abs(this.GetDx(e.Pt,i.Pt));for(i=n.Prev;t.IntPoint.op_Equality(i.Pt,n.Pt)&&i!==n;)i=i.Prev;var o=Math.abs(this.GetDx(n.Pt,i.Pt));for(i=n.Next;t.IntPoint.op_Equality(i.Pt,n.Pt)&&i!==n;)i=i.Next;var a=Math.abs(this.GetDx(n.Pt,i.Pt));return Math.max(r,s)===Math.max(o,a)&&Math.min(r,s)===Math.min(o,a)?this.Area(e)>0:r>=o&&r>=a||s>=o&&s>=a},t.Clipper.prototype.GetBottomPt=function(e){for(var n=null,i=e.Next;i!==e;)i.Pt.Y>e.Pt.Y?(e=i,n=null):i.Pt.Y===e.Pt.Y&&i.Pt.X<=e.Pt.X&&(i.Pt.X<e.Pt.X?(n=null,e=i):i.Next!==e&&i.Prev!==e&&(n=i)),i=i.Next;if(null!==n)for(;n!==i;)for(this.FirstIsBottomPt(i,n)||(e=n),n=n.Next;t.IntPoint.op_Inequality(n.Pt,e.Pt);)n=n.Next;return e},t.Clipper.prototype.GetLowermostRec=function(e,t){null===e.BottomPt&&(e.BottomPt=this.GetBottomPt(e.Pts)),null===t.BottomPt&&(t.BottomPt=this.GetBottomPt(t.Pts));var n=e.BottomPt,i=t.BottomPt;return n.Pt.Y>i.Pt.Y?e:n.Pt.Y<i.Pt.Y?t:n.Pt.X<i.Pt.X?e:n.Pt.X>i.Pt.X||n.Next===n?t:i.Next===i||this.FirstIsBottomPt(n,i)?e:t},t.Clipper.prototype.OutRec1RightOfOutRec2=function(e,t){do{if((e=e.FirstLeft)===t)return!0}while(null!==e);return!1},t.Clipper.prototype.GetOutRec=function(e){for(var t=this.m_PolyOuts[e];t!==this.m_PolyOuts[t.Idx];)t=this.m_PolyOuts[t.Idx];return t},t.Clipper.prototype.AppendPolygon=function(e,n){var i,r=this.m_PolyOuts[e.OutIdx],s=this.m_PolyOuts[n.OutIdx];i=this.OutRec1RightOfOutRec2(r,s)?s:this.OutRec1RightOfOutRec2(s,r)?r:this.GetLowermostRec(r,s);var o=r.Pts,a=o.Prev,A=s.Pts,l=A.Prev;e.Side===t.EdgeSide.esLeft?n.Side===t.EdgeSide.esLeft?(this.ReversePolyPtLinks(A),A.Next=o,o.Prev=A,a.Next=l,l.Prev=a,r.Pts=l):(l.Next=o,o.Prev=l,A.Prev=a,a.Next=A,r.Pts=A):n.Side===t.EdgeSide.esRight?(this.ReversePolyPtLinks(A),a.Next=l,l.Prev=a,A.Next=o,o.Prev=A):(a.Next=A,A.Prev=a,o.Prev=l,l.Next=o),r.BottomPt=null,i===s&&(s.FirstLeft!==r&&(r.FirstLeft=s.FirstLeft),r.IsHole=s.IsHole),s.Pts=null,s.BottomPt=null,s.FirstLeft=r;var c=e.OutIdx,p=n.OutIdx;e.OutIdx=-1,n.OutIdx=-1;for(var h=this.m_ActiveEdges;null!==h;){if(h.OutIdx===p){h.OutIdx=c,h.Side=e.Side;break}h=h.NextInAEL}s.Idx=r.Idx},t.Clipper.prototype.ReversePolyPtLinks=function(e){if(null!==e){var t,n;t=e;do{n=t.Next,t.Next=t.Prev,t.Prev=n,t=n}while(t!==e)}},t.Clipper.SwapSides=function(e,t){var n=e.Side;e.Side=t.Side,t.Side=n},t.Clipper.SwapPolyIndexes=function(e,t){var n=e.OutIdx;e.OutIdx=t.OutIdx,t.OutIdx=n},t.Clipper.prototype.IntersectEdges=function(e,n,i){var r=e.OutIdx>=0,s=n.OutIdx>=0;if(t.use_xyz&&this.SetZ(i,e,n),!t.use_lines||0!==e.WindDelta&&0!==n.WindDelta){if(e.PolyTyp===n.PolyTyp)if(this.IsEvenOddFillType(e)){var o=e.WindCnt;e.WindCnt=n.WindCnt,n.WindCnt=o}else e.WindCnt+n.WindDelta===0?e.WindCnt=-e.WindCnt:e.WindCnt+=n.WindDelta,n.WindCnt-e.WindDelta==0?n.WindCnt=-n.WindCnt:n.WindCnt-=e.WindDelta;else this.IsEvenOddFillType(n)?e.WindCnt2=0===e.WindCnt2?1:0:e.WindCnt2+=n.WindDelta,this.IsEvenOddFillType(e)?n.WindCnt2=0===n.WindCnt2?1:0:n.WindCnt2-=e.WindDelta;var a,A,l,c,p,h;switch(e.PolyTyp===t.PolyType.ptSubject?(a=this.m_SubjFillType,l=this.m_ClipFillType):(a=this.m_ClipFillType,l=this.m_SubjFillType),n.PolyTyp===t.PolyType.ptSubject?(A=this.m_SubjFillType,c=this.m_ClipFillType):(A=this.m_ClipFillType,c=this.m_SubjFillType),a){case t.PolyFillType.pftPositive:p=e.WindCnt;break;case t.PolyFillType.pftNegative:p=-e.WindCnt;break;default:p=Math.abs(e.WindCnt)}switch(A){case t.PolyFillType.pftPositive:h=n.WindCnt;break;case t.PolyFillType.pftNegative:h=-n.WindCnt;break;default:h=Math.abs(n.WindCnt)}if(r&&s)0!==p&&1!==p||0!==h&&1!==h||e.PolyTyp!==n.PolyTyp&&this.m_ClipType!==t.ClipType.ctXor?this.AddLocalMaxPoly(e,n,i):(this.AddOutPt(e,i),this.AddOutPt(n,i),t.Clipper.SwapSides(e,n),t.Clipper.SwapPolyIndexes(e,n));else if(r)0!==h&&1!==h||(this.AddOutPt(e,i),t.Clipper.SwapSides(e,n),t.Clipper.SwapPolyIndexes(e,n));else if(s)0!==p&&1!==p||(this.AddOutPt(n,i),t.Clipper.SwapSides(e,n),t.Clipper.SwapPolyIndexes(e,n));else if(!(0!==p&&1!==p||0!==h&&1!==h)){var u,d;switch(l){case t.PolyFillType.pftPositive:u=e.WindCnt2;break;case t.PolyFillType.pftNegative:u=-e.WindCnt2;break;default:u=Math.abs(e.WindCnt2)}switch(c){case t.PolyFillType.pftPositive:d=n.WindCnt2;break;case t.PolyFillType.pftNegative:d=-n.WindCnt2;break;default:d=Math.abs(n.WindCnt2)}if(e.PolyTyp!==n.PolyTyp)this.AddLocalMinPoly(e,n,i);else if(1===p&&1===h)switch(this.m_ClipType){case t.ClipType.ctIntersection:u>0&&d>0&&this.AddLocalMinPoly(e,n,i);break;case t.ClipType.ctUnion:u<=0&&d<=0&&this.AddLocalMinPoly(e,n,i);break;case t.ClipType.ctDifference:(e.PolyTyp===t.PolyType.ptClip&&u>0&&d>0||e.PolyTyp===t.PolyType.ptSubject&&u<=0&&d<=0)&&this.AddLocalMinPoly(e,n,i);break;case t.ClipType.ctXor:this.AddLocalMinPoly(e,n,i)}else t.Clipper.SwapSides(e,n)}}else{if(0===e.WindDelta&&0===n.WindDelta)return;e.PolyTyp===n.PolyTyp&&e.WindDelta!==n.WindDelta&&this.m_ClipType===t.ClipType.ctUnion?0===e.WindDelta?s&&(this.AddOutPt(e,i),r&&(e.OutIdx=-1)):r&&(this.AddOutPt(n,i),s&&(n.OutIdx=-1)):e.PolyTyp!==n.PolyTyp&&(0!==e.WindDelta||1!==Math.abs(n.WindCnt)||this.m_ClipType===t.ClipType.ctUnion&&0!==n.WindCnt2?0!==n.WindDelta||1!==Math.abs(e.WindCnt)||this.m_ClipType===t.ClipType.ctUnion&&0!==e.WindCnt2||(this.AddOutPt(n,i),s&&(n.OutIdx=-1)):(this.AddOutPt(e,i),r&&(e.OutIdx=-1)))}},t.Clipper.prototype.DeleteFromSEL=function(e){var t=e.PrevInSEL,n=e.NextInSEL;null===t&&null===n&&e!==this.m_SortedEdges||(null!==t?t.NextInSEL=n:this.m_SortedEdges=n,null!==n&&(n.PrevInSEL=t),e.NextInSEL=null,e.PrevInSEL=null)},t.Clipper.prototype.ProcessHorizontals=function(){for(var e={};this.PopEdgeFromSEL(e);)this.ProcessHorizontal(e.v)},t.Clipper.prototype.GetHorzDirection=function(e,n){e.Bot.X<e.Top.X?(n.Left=e.Bot.X,n.Right=e.Top.X,n.Dir=t.Direction.dLeftToRight):(n.Left=e.Top.X,n.Right=e.Bot.X,n.Dir=t.Direction.dRightToLeft)},t.Clipper.prototype.ProcessHorizontal=function(e){var n={Dir:null,Left:null,Right:null};this.GetHorzDirection(e,n);for(var i=n.Dir,r=n.Left,s=n.Right,o=0===e.WindDelta,a=e,A=null;null!==a.NextInLML&&t.ClipperBase.IsHorizontal(a.NextInLML);)a=a.NextInLML;null===a.NextInLML&&(A=this.GetMaximaPair(a));var l=this.m_Maxima;if(null!==l)if(i===t.Direction.dLeftToRight){for(;null!==l&&l.X<=e.Bot.X;)l=l.Next;null!==l&&l.X>=a.Top.X&&(l=null)}else{for(;null!==l.Next&&l.Next.X<e.Bot.X;)l=l.Next;l.X<=a.Top.X&&(l=null)}for(var c=null;;){for(var p=e===a,h=this.GetNextInAEL(e,i);null!==h;){if(null!==l)if(i===t.Direction.dLeftToRight)for(;null!==l&&l.X<h.Curr.X;)e.OutIdx>=0&&!o&&this.AddOutPt(e,new t.IntPoint2(l.X,e.Bot.Y)),l=l.Next;else for(;null!==l&&l.X>h.Curr.X;)e.OutIdx>=0&&!o&&this.AddOutPt(e,new t.IntPoint2(l.X,e.Bot.Y)),l=l.Prev;if(i===t.Direction.dLeftToRight&&h.Curr.X>s||i===t.Direction.dRightToLeft&&h.Curr.X<r)break;if(h.Curr.X===e.Top.X&&null!==e.NextInLML&&h.Dx<e.NextInLML.Dx)break;if(e.OutIdx>=0&&!o){t.use_xyz&&(i===t.Direction.dLeftToRight?this.SetZ(h.Curr,e,h):this.SetZ(h.Curr,h,e)),c=this.AddOutPt(e,h.Curr);for(var u=this.m_SortedEdges;null!==u;){if(u.OutIdx>=0&&this.HorzSegmentsOverlap(e.Bot.X,e.Top.X,u.Bot.X,u.Top.X)){var d=this.GetLastOutPt(u);this.AddJoin(d,c,u.Top)}u=u.NextInSEL}this.AddGhostJoin(c,e.Bot)}if(h===A&&p)return e.OutIdx>=0&&this.AddLocalMaxPoly(e,A,e.Top),this.DeleteFromAEL(e),void this.DeleteFromAEL(A);if(i===t.Direction.dLeftToRight){var g=new t.IntPoint2(h.Curr.X,e.Curr.Y);this.IntersectEdges(e,h,g)}else g=new t.IntPoint2(h.Curr.X,e.Curr.Y),this.IntersectEdges(h,e,g);var f=this.GetNextInAEL(h,i);this.SwapPositionsInAEL(e,h),h=f}if(null===e.NextInLML||!t.ClipperBase.IsHorizontal(e.NextInLML))break;(e=this.UpdateEdgeIntoAEL(e)).OutIdx>=0&&this.AddOutPt(e,e.Bot),n={Dir:i,Left:r,Right:s},this.GetHorzDirection(e,n),i=n.Dir,r=n.Left,s=n.Right}if(e.OutIdx>=0&&null===c){for(c=this.GetLastOutPt(e),u=this.m_SortedEdges;null!==u;)u.OutIdx>=0&&this.HorzSegmentsOverlap(e.Bot.X,e.Top.X,u.Bot.X,u.Top.X)&&(d=this.GetLastOutPt(u),this.AddJoin(d,c,u.Top)),u=u.NextInSEL;this.AddGhostJoin(c,e.Top)}if(null!==e.NextInLML)if(e.OutIdx>=0){if(c=this.AddOutPt(e,e.Top),0===(e=this.UpdateEdgeIntoAEL(e)).WindDelta)return;var m=e.PrevInAEL;f=e.NextInAEL,null!==m&&m.Curr.X===e.Bot.X&&m.Curr.Y===e.Bot.Y&&0===m.WindDelta&&m.OutIdx>=0&&m.Curr.Y>m.Top.Y&&t.ClipperBase.SlopesEqual3(e,m,this.m_UseFullRange)?(d=this.AddOutPt(m,e.Bot),this.AddJoin(c,d,e.Top)):null!==f&&f.Curr.X===e.Bot.X&&f.Curr.Y===e.Bot.Y&&0!==f.WindDelta&&f.OutIdx>=0&&f.Curr.Y>f.Top.Y&&t.ClipperBase.SlopesEqual3(e,f,this.m_UseFullRange)&&(d=this.AddOutPt(f,e.Bot),this.AddJoin(c,d,e.Top))}else e=this.UpdateEdgeIntoAEL(e);else e.OutIdx>=0&&this.AddOutPt(e,e.Top),this.DeleteFromAEL(e)},t.Clipper.prototype.GetNextInAEL=function(e,n){return n===t.Direction.dLeftToRight?e.NextInAEL:e.PrevInAEL},t.Clipper.prototype.IsMinima=function(e){return null!==e&&e.Prev.NextInLML!==e&&e.Next.NextInLML!==e},t.Clipper.prototype.IsMaxima=function(e,t){return null!==e&&e.Top.Y===t&&null===e.NextInLML},t.Clipper.prototype.IsIntermediate=function(e,t){return e.Top.Y===t&&null!==e.NextInLML},t.Clipper.prototype.GetMaximaPair=function(e){return t.IntPoint.op_Equality(e.Next.Top,e.Top)&&null===e.Next.NextInLML?e.Next:t.IntPoint.op_Equality(e.Prev.Top,e.Top)&&null===e.Prev.NextInLML?e.Prev:null},t.Clipper.prototype.GetMaximaPairEx=function(e){var n=this.GetMaximaPair(e);return null===n||n.OutIdx===t.ClipperBase.Skip||n.NextInAEL===n.PrevInAEL&&!t.ClipperBase.IsHorizontal(n)?null:n},t.Clipper.prototype.ProcessIntersections=function(e){if(null===this.m_ActiveEdges)return!0;try{if(this.BuildIntersectList(e),0===this.m_IntersectList.length)return!0;if(1!==this.m_IntersectList.length&&!this.FixupIntersectionOrder())return!1;this.ProcessIntersectList()}catch(e){this.m_SortedEdges=null,this.m_IntersectList.length=0,t.Error("ProcessIntersections error")}return this.m_SortedEdges=null,!0},t.Clipper.prototype.BuildIntersectList=function(e){if(null!==this.m_ActiveEdges){var n=this.m_ActiveEdges;for(this.m_SortedEdges=n;null!==n;)n.PrevInSEL=n.PrevInAEL,n.NextInSEL=n.NextInAEL,n.Curr.X=t.Clipper.TopX(n,e),n=n.NextInAEL;for(var i=!0;i&&null!==this.m_SortedEdges;){for(i=!1,n=this.m_SortedEdges;null!==n.NextInSEL;){var r=n.NextInSEL,s=new t.IntPoint0;if(n.Curr.X>r.Curr.X){this.IntersectPoint(n,r,s),s.Y<e&&(s=new t.IntPoint2(t.Clipper.TopX(n,e),e));var o=new t.IntersectNode;o.Edge1=n,o.Edge2=r,o.Pt.X=s.X,o.Pt.Y=s.Y,t.use_xyz&&(o.Pt.Z=s.Z),this.m_IntersectList.push(o),this.SwapPositionsInSEL(n,r),i=!0}else n=r}if(null===n.PrevInSEL)break;n.PrevInSEL.NextInSEL=null}this.m_SortedEdges=null}},t.Clipper.prototype.EdgesAdjacent=function(e){return e.Edge1.NextInSEL===e.Edge2||e.Edge1.PrevInSEL===e.Edge2},t.Clipper.IntersectNodeSort=function(e,t){return t.Pt.Y-e.Pt.Y},t.Clipper.prototype.FixupIntersectionOrder=function(){this.m_IntersectList.sort(this.m_IntersectNodeComparer),this.CopyAELToSEL();for(var e=this.m_IntersectList.length,t=0;t<e;t++){if(!this.EdgesAdjacent(this.m_IntersectList[t])){for(var n=t+1;n<e&&!this.EdgesAdjacent(this.m_IntersectList[n]);)n++;if(n===e)return!1;var i=this.m_IntersectList[t];this.m_IntersectList[t]=this.m_IntersectList[n],this.m_IntersectList[n]=i}this.SwapPositionsInSEL(this.m_IntersectList[t].Edge1,this.m_IntersectList[t].Edge2)}return!0},t.Clipper.prototype.ProcessIntersectList=function(){for(var e=0,t=this.m_IntersectList.length;e<t;e++){var n=this.m_IntersectList[e];this.IntersectEdges(n.Edge1,n.Edge2,n.Pt),this.SwapPositionsInAEL(n.Edge1,n.Edge2)}this.m_IntersectList.length=0},s.msie?t.Clipper.Round=function(e){return e<0?Math.ceil(e-.5):Math.round(e)}:s.chromium?t.Clipper.Round=function(e){return e<0?-Math.round(Math.abs(e)):Math.round(e)}:s.safari?t.Clipper.Round=function(e){return e<0?(e-=.5)<-2147483648?Math.ceil(e):0|e:(e+=.5)>2147483647?Math.floor(e):0|e}:t.Clipper.Round=function(e){return e<0?Math.ceil(e-.5):Math.floor(e+.5)},t.Clipper.TopX=function(e,n){return n===e.Top.Y?e.Top.X:e.Bot.X+t.Clipper.Round(e.Dx*(n-e.Bot.Y))},t.Clipper.prototype.IntersectPoint=function(e,n,i){var r,s;if(i.X=0,i.Y=0,e.Dx===n.Dx)return i.Y=e.Curr.Y,void(i.X=t.Clipper.TopX(e,i.Y));if(0===e.Delta.X)i.X=e.Bot.X,t.ClipperBase.IsHorizontal(n)?i.Y=n.Bot.Y:(s=n.Bot.Y-n.Bot.X/n.Dx,i.Y=t.Clipper.Round(i.X/n.Dx+s));else if(0===n.Delta.X)i.X=n.Bot.X,t.ClipperBase.IsHorizontal(e)?i.Y=e.Bot.Y:(r=e.Bot.Y-e.Bot.X/e.Dx,i.Y=t.Clipper.Round(i.X/e.Dx+r));else{r=e.Bot.X-e.Bot.Y*e.Dx;var o=((s=n.Bot.X-n.Bot.Y*n.Dx)-r)/(e.Dx-n.Dx);i.Y=t.Clipper.Round(o),Math.abs(e.Dx)<Math.abs(n.Dx)?i.X=t.Clipper.Round(e.Dx*o+r):i.X=t.Clipper.Round(n.Dx*o+s)}if(i.Y<e.Top.Y||i.Y<n.Top.Y){if(e.Top.Y>n.Top.Y)return i.Y=e.Top.Y,i.X=t.Clipper.TopX(n,e.Top.Y),i.X<e.Top.X;i.Y=n.Top.Y,Math.abs(e.Dx)<Math.abs(n.Dx)?i.X=t.Clipper.TopX(e,i.Y):i.X=t.Clipper.TopX(n,i.Y)}i.Y>e.Curr.Y&&(i.Y=e.Curr.Y,Math.abs(e.Dx)>Math.abs(n.Dx)?i.X=t.Clipper.TopX(n,i.Y):i.X=t.Clipper.TopX(e,i.Y))},t.Clipper.prototype.ProcessEdgesAtTopOfScanbeam=function(e){for(var n=this.m_ActiveEdges;null!==n;){var i=this.IsMaxima(n,e);if(i){var r=this.GetMaximaPairEx(n);i=null===r||!t.ClipperBase.IsHorizontal(r)}if(i){this.StrictlySimple&&this.InsertMaxima(n.Top.X);var s=n.PrevInAEL;this.DoMaxima(n),n=null===s?this.m_ActiveEdges:s.NextInAEL}else{if(this.IsIntermediate(n,e)&&t.ClipperBase.IsHorizontal(n.NextInLML)?((n=this.UpdateEdgeIntoAEL(n)).OutIdx>=0&&this.AddOutPt(n,n.Bot),this.AddEdgeToSEL(n)):(n.Curr.X=t.Clipper.TopX(n,e),n.Curr.Y=e),t.use_xyz&&(n.Top.Y===e?n.Curr.Z=n.Top.Z:n.Bot.Y===e?n.Curr.Z=n.Bot.Z:n.Curr.Z=0),this.StrictlySimple&&(s=n.PrevInAEL,n.OutIdx>=0&&0!==n.WindDelta&&null!==s&&s.OutIdx>=0&&s.Curr.X===n.Curr.X&&0!==s.WindDelta)){var o=new t.IntPoint1(n.Curr);t.use_xyz&&this.SetZ(o,s,n);var a=this.AddOutPt(s,o),A=this.AddOutPt(n,o);this.AddJoin(a,A,o)}n=n.NextInAEL}}for(this.ProcessHorizontals(),this.m_Maxima=null,n=this.m_ActiveEdges;null!==n;){if(this.IsIntermediate(n,e)){a=null,n.OutIdx>=0&&(a=this.AddOutPt(n,n.Top)),s=(n=this.UpdateEdgeIntoAEL(n)).PrevInAEL;var l=n.NextInAEL;null!==s&&s.Curr.X===n.Bot.X&&s.Curr.Y===n.Bot.Y&&null!==a&&s.OutIdx>=0&&s.Curr.Y===s.Top.Y&&t.ClipperBase.SlopesEqual5(n.Curr,n.Top,s.Curr,s.Top,this.m_UseFullRange)&&0!==n.WindDelta&&0!==s.WindDelta?(A=this.AddOutPt(ePrev2,n.Bot),this.AddJoin(a,A,n.Top)):null!==l&&l.Curr.X===n.Bot.X&&l.Curr.Y===n.Bot.Y&&null!==a&&l.OutIdx>=0&&l.Curr.Y===l.Top.Y&&t.ClipperBase.SlopesEqual5(n.Curr,n.Top,l.Curr,l.Top,this.m_UseFullRange)&&0!==n.WindDelta&&0!==l.WindDelta&&(A=this.AddOutPt(l,n.Bot),this.AddJoin(a,A,n.Top))}n=n.NextInAEL}},t.Clipper.prototype.DoMaxima=function(e){var n=this.GetMaximaPairEx(e);if(null===n)return e.OutIdx>=0&&this.AddOutPt(e,e.Top),void this.DeleteFromAEL(e);for(var i=e.NextInAEL;null!==i&&i!==n;)this.IntersectEdges(e,i,e.Top),this.SwapPositionsInAEL(e,i),i=e.NextInAEL;-1===e.OutIdx&&-1===n.OutIdx?(this.DeleteFromAEL(e),this.DeleteFromAEL(n)):e.OutIdx>=0&&n.OutIdx>=0?(e.OutIdx>=0&&this.AddLocalMaxPoly(e,n,e.Top),this.DeleteFromAEL(e),this.DeleteFromAEL(n)):t.use_lines&&0===e.WindDelta?(e.OutIdx>=0&&(this.AddOutPt(e,e.Top),e.OutIdx=t.ClipperBase.Unassigned),this.DeleteFromAEL(e),n.OutIdx>=0&&(this.AddOutPt(n,e.Top),n.OutIdx=t.ClipperBase.Unassigned),this.DeleteFromAEL(n)):t.Error("DoMaxima error")},t.Clipper.ReversePaths=function(e){for(var t=0,n=e.length;t<n;t++)e[t].reverse()},t.Clipper.Orientation=function(e){return t.Clipper.Area(e)>=0},t.Clipper.prototype.PointCount=function(e){if(null===e)return 0;var t=0,n=e;do{t++,n=n.Next}while(n!==e);return t},t.Clipper.prototype.BuildResult=function(e){t.Clear(e);for(var n=0,i=this.m_PolyOuts.length;n<i;n++){var r=this.m_PolyOuts[n];if(null!==r.Pts){var s=r.Pts.Prev,o=this.PointCount(s);if(!(o<2)){for(var a=new Array(o),A=0;A<o;A++)a[A]=s.Pt,s=s.Prev;e.push(a)}}}},t.Clipper.prototype.BuildResult2=function(e){e.Clear();for(var n=0,i=this.m_PolyOuts.length;n<i;n++){var r=this.m_PolyOuts[n],s=this.PointCount(r.Pts);if(!(r.IsOpen&&s<2||!r.IsOpen&&s<3)){this.FixHoleLinkage(r);var o=new t.PolyNode;e.m_AllPolys.push(o),r.PolyNode=o,o.m_polygon.length=s;for(var a=r.Pts.Prev,A=0;A<s;A++)o.m_polygon[A]=a.Pt,a=a.Prev}}for(n=0,i=this.m_PolyOuts.length;n<i;n++)null!==(r=this.m_PolyOuts[n]).PolyNode&&(r.IsOpen?(r.PolyNode.IsOpen=!0,e.AddChild(r.PolyNode)):null!==r.FirstLeft&&null!==r.FirstLeft.PolyNode?r.FirstLeft.PolyNode.AddChild(r.PolyNode):e.AddChild(r.PolyNode))},t.Clipper.prototype.FixupOutPolyline=function(e){for(var n=e.Pts,i=n.Prev;n!==i;)if(n=n.Next,t.IntPoint.op_Equality(n.Pt,n.Prev.Pt)){n===i&&(i=n.Prev);var r=n.Prev;r.Next=n.Next,n.Next.Prev=r,n=r}n===n.Prev&&(e.Pts=null)},t.Clipper.prototype.FixupOutPolygon=function(e){var n=null;e.BottomPt=null;for(var i=e.Pts,r=this.PreserveCollinear||this.StrictlySimple;;){if(i.Prev===i||i.Prev===i.Next)return void(e.Pts=null);if(t.IntPoint.op_Equality(i.Pt,i.Next.Pt)||t.IntPoint.op_Equality(i.Pt,i.Prev.Pt)||t.ClipperBase.SlopesEqual4(i.Prev.Pt,i.Pt,i.Next.Pt,this.m_UseFullRange)&&(!r||!this.Pt2IsBetweenPt1AndPt3(i.Prev.Pt,i.Pt,i.Next.Pt)))n=null,i.Prev.Next=i.Next,i.Next.Prev=i.Prev,i=i.Prev;else{if(i===n)break;null===n&&(n=i),i=i.Next}}e.Pts=i},t.Clipper.prototype.DupOutPt=function(e,n){var i=new t.OutPt;return i.Pt.X=e.Pt.X,i.Pt.Y=e.Pt.Y,t.use_xyz&&(i.Pt.Z=e.Pt.Z),i.Idx=e.Idx,n?(i.Next=e.Next,i.Prev=e,e.Next.Prev=i,e.Next=i):(i.Prev=e.Prev,i.Next=e,e.Prev.Next=i,e.Prev=i),i},t.Clipper.prototype.GetOverlap=function(e,t,n,i,r){return e<t?n<i?(r.Left=Math.max(e,n),r.Right=Math.min(t,i)):(r.Left=Math.max(e,i),r.Right=Math.min(t,n)):n<i?(r.Left=Math.max(t,n),r.Right=Math.min(e,i)):(r.Left=Math.max(t,i),r.Right=Math.min(e,n)),r.Left<r.Right},t.Clipper.prototype.JoinHorz=function(e,n,i,r,s,o){var a=e.Pt.X>n.Pt.X?t.Direction.dRightToLeft:t.Direction.dLeftToRight,A=i.Pt.X>r.Pt.X?t.Direction.dRightToLeft:t.Direction.dLeftToRight;if(a===A)return!1;if(a===t.Direction.dLeftToRight){for(;e.Next.Pt.X<=s.X&&e.Next.Pt.X>=e.Pt.X&&e.Next.Pt.Y===s.Y;)e=e.Next;o&&e.Pt.X!==s.X&&(e=e.Next),n=this.DupOutPt(e,!o),t.IntPoint.op_Inequality(n.Pt,s)&&((e=n).Pt.X=s.X,e.Pt.Y=s.Y,t.use_xyz&&(e.Pt.Z=s.Z),n=this.DupOutPt(e,!o))}else{for(;e.Next.Pt.X>=s.X&&e.Next.Pt.X<=e.Pt.X&&e.Next.Pt.Y===s.Y;)e=e.Next;o||e.Pt.X===s.X||(e=e.Next),n=this.DupOutPt(e,o),t.IntPoint.op_Inequality(n.Pt,s)&&((e=n).Pt.X=s.X,e.Pt.Y=s.Y,t.use_xyz&&(e.Pt.Z=s.Z),n=this.DupOutPt(e,o))}if(A===t.Direction.dLeftToRight){for(;i.Next.Pt.X<=s.X&&i.Next.Pt.X>=i.Pt.X&&i.Next.Pt.Y===s.Y;)i=i.Next;o&&i.Pt.X!==s.X&&(i=i.Next),r=this.DupOutPt(i,!o),t.IntPoint.op_Inequality(r.Pt,s)&&((i=r).Pt.X=s.X,i.Pt.Y=s.Y,t.use_xyz&&(i.Pt.Z=s.Z),r=this.DupOutPt(i,!o))}else{for(;i.Next.Pt.X>=s.X&&i.Next.Pt.X<=i.Pt.X&&i.Next.Pt.Y===s.Y;)i=i.Next;o||i.Pt.X===s.X||(i=i.Next),r=this.DupOutPt(i,o),t.IntPoint.op_Inequality(r.Pt,s)&&((i=r).Pt.X=s.X,i.Pt.Y=s.Y,t.use_xyz&&(i.Pt.Z=s.Z),r=this.DupOutPt(i,o))}return a===t.Direction.dLeftToRight===o?(e.Prev=i,i.Next=e,n.Next=r,r.Prev=n):(e.Next=i,i.Prev=e,n.Prev=r,r.Next=n),!0},t.Clipper.prototype.JoinPoints=function(e,n,i){var r=e.OutPt1,s=new t.OutPt,o=e.OutPt2,a=new t.OutPt,A=e.OutPt1.Pt.Y===e.OffPt.Y;if(A&&t.IntPoint.op_Equality(e.OffPt,e.OutPt1.Pt)&&t.IntPoint.op_Equality(e.OffPt,e.OutPt2.Pt)){if(n!==i)return!1;for(s=e.OutPt1.Next;s!==r&&t.IntPoint.op_Equality(s.Pt,e.OffPt);)s=s.Next;var l=s.Pt.Y>e.OffPt.Y;for(a=e.OutPt2.Next;a!==o&&t.IntPoint.op_Equality(a.Pt,e.OffPt);)a=a.Next;return l!==a.Pt.Y>e.OffPt.Y&&(l?(s=this.DupOutPt(r,!1),a=this.DupOutPt(o,!0),r.Prev=o,o.Next=r,s.Next=a,a.Prev=s,e.OutPt1=r,e.OutPt2=s,!0):(s=this.DupOutPt(r,!0),a=this.DupOutPt(o,!1),r.Next=o,o.Prev=r,s.Prev=a,a.Next=s,e.OutPt1=r,e.OutPt2=s,!0))}if(A){for(s=r;r.Prev.Pt.Y===r.Pt.Y&&r.Prev!==s&&r.Prev!==o;)r=r.Prev;for(;s.Next.Pt.Y===s.Pt.Y&&s.Next!==r&&s.Next!==o;)s=s.Next;if(s.Next===r||s.Next===o)return!1;for(a=o;o.Prev.Pt.Y===o.Pt.Y&&o.Prev!==a&&o.Prev!==s;)o=o.Prev;for(;a.Next.Pt.Y===a.Pt.Y&&a.Next!==o&&a.Next!==r;)a=a.Next;if(a.Next===o||a.Next===r)return!1;var c={Left:null,Right:null};if(!this.GetOverlap(r.Pt.X,s.Pt.X,o.Pt.X,a.Pt.X,c))return!1;var p,h=c.Left,u=c.Right,d=new t.IntPoint0;return r.Pt.X>=h&&r.Pt.X<=u?(d.X=r.Pt.X,d.Y=r.Pt.Y,t.use_xyz&&(d.Z=r.Pt.Z),p=r.Pt.X>s.Pt.X):o.Pt.X>=h&&o.Pt.X<=u?(d.X=o.Pt.X,d.Y=o.Pt.Y,t.use_xyz&&(d.Z=o.Pt.Z),p=o.Pt.X>a.Pt.X):s.Pt.X>=h&&s.Pt.X<=u?(d.X=s.Pt.X,d.Y=s.Pt.Y,t.use_xyz&&(d.Z=s.Pt.Z),p=s.Pt.X>r.Pt.X):(d.X=a.Pt.X,d.Y=a.Pt.Y,t.use_xyz&&(d.Z=a.Pt.Z),p=a.Pt.X>o.Pt.X),e.OutPt1=r,e.OutPt2=o,this.JoinHorz(r,s,o,a,d,p)}for(s=r.Next;t.IntPoint.op_Equality(s.Pt,r.Pt)&&s!==r;)s=s.Next;var g=s.Pt.Y>r.Pt.Y||!t.ClipperBase.SlopesEqual4(r.Pt,s.Pt,e.OffPt,this.m_UseFullRange);if(g){for(s=r.Prev;t.IntPoint.op_Equality(s.Pt,r.Pt)&&s!==r;)s=s.Prev;if(s.Pt.Y>r.Pt.Y||!t.ClipperBase.SlopesEqual4(r.Pt,s.Pt,e.OffPt,this.m_UseFullRange))return!1}for(a=o.Next;t.IntPoint.op_Equality(a.Pt,o.Pt)&&a!==o;)a=a.Next;var f=a.Pt.Y>o.Pt.Y||!t.ClipperBase.SlopesEqual4(o.Pt,a.Pt,e.OffPt,this.m_UseFullRange);if(f){for(a=o.Prev;t.IntPoint.op_Equality(a.Pt,o.Pt)&&a!==o;)a=a.Prev;if(a.Pt.Y>o.Pt.Y||!t.ClipperBase.SlopesEqual4(o.Pt,a.Pt,e.OffPt,this.m_UseFullRange))return!1}return!(s===r||a===o||s===a||n===i&&g===f||(g?(s=this.DupOutPt(r,!1),a=this.DupOutPt(o,!0),r.Prev=o,o.Next=r,s.Next=a,a.Prev=s,e.OutPt1=r,e.OutPt2=s,0):(s=this.DupOutPt(r,!0),a=this.DupOutPt(o,!1),r.Next=o,o.Prev=r,s.Prev=a,a.Next=s,e.OutPt1=r,e.OutPt2=s,0)))},t.Clipper.GetBounds=function(e){for(var n=0,i=e.length;n<i&&0===e[n].length;)n++;if(n===i)return new t.IntRect(0,0,0,0);var r=new t.IntRect;for(r.left=e[n][0].X,r.right=r.left,r.top=e[n][0].Y,r.bottom=r.top;n<i;n++)for(var s=0,o=e[n].length;s<o;s++)e[n][s].X<r.left?r.left=e[n][s].X:e[n][s].X>r.right&&(r.right=e[n][s].X),e[n][s].Y<r.top?r.top=e[n][s].Y:e[n][s].Y>r.bottom&&(r.bottom=e[n][s].Y);return r},t.Clipper.prototype.GetBounds2=function(e){var n=e,i=new t.IntRect;for(i.left=e.Pt.X,i.right=e.Pt.X,i.top=e.Pt.Y,i.bottom=e.Pt.Y,e=e.Next;e!==n;)e.Pt.X<i.left&&(i.left=e.Pt.X),e.Pt.X>i.right&&(i.right=e.Pt.X),e.Pt.Y<i.top&&(i.top=e.Pt.Y),e.Pt.Y>i.bottom&&(i.bottom=e.Pt.Y),e=e.Next;return i},t.Clipper.PointInPolygon=function(e,t){var n=0,i=t.length;if(i<3)return 0;for(var r=t[0],s=1;s<=i;++s){var o=s===i?t[0]:t[s];if(o.Y===e.Y&&(o.X===e.X||r.Y===e.Y&&o.X>e.X==r.X<e.X))return-1;if(r.Y<e.Y!=o.Y<e.Y)if(r.X>=e.X)if(o.X>e.X)n=1-n;else{if(0==(a=(r.X-e.X)*(o.Y-e.Y)-(o.X-e.X)*(r.Y-e.Y)))return-1;a>0==o.Y>r.Y&&(n=1-n)}else if(o.X>e.X){var a;if(0==(a=(r.X-e.X)*(o.Y-e.Y)-(o.X-e.X)*(r.Y-e.Y)))return-1;a>0==o.Y>r.Y&&(n=1-n)}r=o}return n},t.Clipper.prototype.PointInPolygon=function(e,t){var n=0,i=t,r=e.X,s=e.Y,o=t.Pt.X,a=t.Pt.Y;do{var A=(t=t.Next).Pt.X,l=t.Pt.Y;if(l===s&&(A===r||a===s&&A>r==o<r))return-1;if(a<s!=l<s)if(o>=r)if(A>r)n=1-n;else{if(0==(c=(o-r)*(l-s)-(A-r)*(a-s)))return-1;c>0==l>a&&(n=1-n)}else if(A>r){var c;if(0==(c=(o-r)*(l-s)-(A-r)*(a-s)))return-1;c>0==l>a&&(n=1-n)}o=A,a=l}while(i!==t);return n},t.Clipper.prototype.Poly2ContainsPoly1=function(e,t){var n=e;do{var i=this.PointInPolygon(n.Pt,t);if(i>=0)return i>0;n=n.Next}while(n!==e);return!0},t.Clipper.prototype.FixupFirstLefts1=function(e,n){for(var i,r,s=0,o=this.m_PolyOuts.length;s<o;s++)i=this.m_PolyOuts[s],r=t.Clipper.ParseFirstLeft(i.FirstLeft),null!==i.Pts&&r===e&&this.Poly2ContainsPoly1(i.Pts,n.Pts)&&(i.FirstLeft=n)},t.Clipper.prototype.FixupFirstLefts2=function(e,n){for(var i,r,s=n.FirstLeft,o=0,a=this.m_PolyOuts.length;o<a;o++)null!==(i=this.m_PolyOuts[o]).Pts&&i!==n&&i!==e&&((r=t.Clipper.ParseFirstLeft(i.FirstLeft))!==s&&r!==e&&r!==n||(this.Poly2ContainsPoly1(i.Pts,e.Pts)?i.FirstLeft=e:this.Poly2ContainsPoly1(i.Pts,n.Pts)?i.FirstLeft=n:i.FirstLeft!==e&&i.FirstLeft!==n||(i.FirstLeft=s)))},t.Clipper.prototype.FixupFirstLefts3=function(e,n){for(var i,r,s=0,o=this.m_PolyOuts.length;s<o;s++)i=this.m_PolyOuts[s],r=t.Clipper.ParseFirstLeft(i.FirstLeft),null!==i.Pts&&r===e&&(i.FirstLeft=n)},t.Clipper.ParseFirstLeft=function(e){for(;null!==e&&null===e.Pts;)e=e.FirstLeft;return e},t.Clipper.prototype.JoinCommonEdges=function(){for(var e=0,t=this.m_Joins.length;e<t;e++){var n,i=this.m_Joins[e],r=this.GetOutRec(i.OutPt1.Idx),s=this.GetOutRec(i.OutPt2.Idx);null!==r.Pts&&null!==s.Pts&&(r.IsOpen||s.IsOpen||(n=r===s?r:this.OutRec1RightOfOutRec2(r,s)?s:this.OutRec1RightOfOutRec2(s,r)?r:this.GetLowermostRec(r,s),this.JoinPoints(i,r,s)&&(r===s?(r.Pts=i.OutPt1,r.BottomPt=null,(s=this.CreateOutRec()).Pts=i.OutPt2,this.UpdateOutPtIdxs(s),this.Poly2ContainsPoly1(s.Pts,r.Pts)?(s.IsHole=!r.IsHole,s.FirstLeft=r,this.m_UsingPolyTree&&this.FixupFirstLefts2(s,r),(s.IsHole^this.ReverseSolution)==this.Area$1(s)>0&&this.ReversePolyPtLinks(s.Pts)):this.Poly2ContainsPoly1(r.Pts,s.Pts)?(s.IsHole=r.IsHole,r.IsHole=!s.IsHole,s.FirstLeft=r.FirstLeft,r.FirstLeft=s,this.m_UsingPolyTree&&this.FixupFirstLefts2(r,s),(r.IsHole^this.ReverseSolution)==this.Area$1(r)>0&&this.ReversePolyPtLinks(r.Pts)):(s.IsHole=r.IsHole,s.FirstLeft=r.FirstLeft,this.m_UsingPolyTree&&this.FixupFirstLefts1(r,s))):(s.Pts=null,s.BottomPt=null,s.Idx=r.Idx,r.IsHole=n.IsHole,n===s&&(r.FirstLeft=s.FirstLeft),s.FirstLeft=r,this.m_UsingPolyTree&&this.FixupFirstLefts3(s,r)))))}},t.Clipper.prototype.UpdateOutPtIdxs=function(e){var t=e.Pts;do{t.Idx=e.Idx,t=t.Prev}while(t!==e.Pts)},t.Clipper.prototype.DoSimplePolygons=function(){for(var e=0;e<this.m_PolyOuts.length;){var n=this.m_PolyOuts[e++],i=n.Pts;if(null!==i&&!n.IsOpen)do{for(var r=i.Next;r!==n.Pts;){if(t.IntPoint.op_Equality(i.Pt,r.Pt)&&r.Next!==i&&r.Prev!==i){var s=i.Prev,o=r.Prev;i.Prev=o,o.Next=i,r.Prev=s,s.Next=r,n.Pts=i;var a=this.CreateOutRec();a.Pts=r,this.UpdateOutPtIdxs(a),this.Poly2ContainsPoly1(a.Pts,n.Pts)?(a.IsHole=!n.IsHole,a.FirstLeft=n,this.m_UsingPolyTree&&this.FixupFirstLefts2(a,n)):this.Poly2ContainsPoly1(n.Pts,a.Pts)?(a.IsHole=n.IsHole,n.IsHole=!a.IsHole,a.FirstLeft=n.FirstLeft,n.FirstLeft=a,this.m_UsingPolyTree&&this.FixupFirstLefts2(n,a)):(a.IsHole=n.IsHole,a.FirstLeft=n.FirstLeft,this.m_UsingPolyTree&&this.FixupFirstLefts1(n,a)),r=i}r=r.Next}i=i.Next}while(i!==n.Pts)}},t.Clipper.Area=function(e){if(!Array.isArray(e))return 0;var t=e.length;if(t<3)return 0;for(var n=0,i=0,r=t-1;i<t;++i)n+=(e[r].X+e[i].X)*(e[r].Y-e[i].Y),r=i;return.5*-n},t.Clipper.prototype.Area=function(e){var t=e;if(null===e)return 0;var n=0;do{n+=(e.Prev.Pt.X+e.Pt.X)*(e.Prev.Pt.Y-e.Pt.Y),e=e.Next}while(e!==t);return.5*n},t.Clipper.prototype.Area$1=function(e){return this.Area(e.Pts)},t.Clipper.SimplifyPolygon=function(e,n){var i=new Array,r=new t.Clipper(0);return r.StrictlySimple=!0,r.AddPath(e,t.PolyType.ptSubject,!0),r.Execute(t.ClipType.ctUnion,i,n,n),i},t.Clipper.SimplifyPolygons=function(e,n){void 0===n&&(n=t.PolyFillType.pftEvenOdd);var i=new Array,r=new t.Clipper(0);return r.StrictlySimple=!0,r.AddPaths(e,t.PolyType.ptSubject,!0),r.Execute(t.ClipType.ctUnion,i,n,n),i},t.Clipper.DistanceSqrd=function(e,t){var n=e.X-t.X,i=e.Y-t.Y;return n*n+i*i},t.Clipper.DistanceFromLineSqrd=function(e,t,n){var i=t.Y-n.Y,r=n.X-t.X,s=i*t.X+r*t.Y;return(s=i*e.X+r*e.Y-s)*s/(i*i+r*r)},t.Clipper.SlopesNearCollinear=function(e,n,i,r){return Math.abs(e.X-n.X)>Math.abs(e.Y-n.Y)?e.X>n.X==e.X<i.X?t.Clipper.DistanceFromLineSqrd(e,n,i)<r:n.X>e.X==n.X<i.X?t.Clipper.DistanceFromLineSqrd(n,e,i)<r:t.Clipper.DistanceFromLineSqrd(i,e,n)<r:e.Y>n.Y==e.Y<i.Y?t.Clipper.DistanceFromLineSqrd(e,n,i)<r:n.Y>e.Y==n.Y<i.Y?t.Clipper.DistanceFromLineSqrd(n,e,i)<r:t.Clipper.DistanceFromLineSqrd(i,e,n)<r},t.Clipper.PointsAreClose=function(e,t,n){var i=e.X-t.X,r=e.Y-t.Y;return i*i+r*r<=n},t.Clipper.ExcludeOp=function(e){var t=e.Prev;return t.Next=e.Next,e.Next.Prev=t,t.Idx=0,t},t.Clipper.CleanPolygon=function(e,n){void 0===n&&(n=1.415);var i=e.length;if(0===i)return new Array;for(var r=new Array(i),s=0;s<i;++s)r[s]=new t.OutPt;for(s=0;s<i;++s)r[s].Pt=e[s],r[s].Next=r[(s+1)%i],r[s].Next.Prev=r[s],r[s].Idx=0;for(var o=n*n,a=r[0];0===a.Idx&&a.Next!==a.Prev;)t.Clipper.PointsAreClose(a.Pt,a.Prev.Pt,o)?(a=t.Clipper.ExcludeOp(a),i--):t.Clipper.PointsAreClose(a.Prev.Pt,a.Next.Pt,o)?(t.Clipper.ExcludeOp(a.Next),a=t.Clipper.ExcludeOp(a),i-=2):t.Clipper.SlopesNearCollinear(a.Prev.Pt,a.Pt,a.Next.Pt,o)?(a=t.Clipper.ExcludeOp(a),i--):(a.Idx=1,a=a.Next);i<3&&(i=0);var A=new Array(i);for(s=0;s<i;++s)A[s]=new t.IntPoint1(a.Pt),a=a.Next;return r=null,A},t.Clipper.CleanPolygons=function(e,n){for(var i=new Array(e.length),r=0,s=e.length;r<s;r++)i[r]=t.Clipper.CleanPolygon(e[r],n);return i},t.Clipper.Minkowski=function(e,n,i,r){var s=r?1:0,o=e.length,a=n.length,A=new Array;if(i)for(var l=0;l<a;l++){for(var c=new Array(o),p=0,h=e.length,u=e[p];p<h;u=e[++p])c[p]=new t.IntPoint2(n[l].X+u.X,n[l].Y+u.Y);A.push(c)}else for(l=0;l<a;l++){for(c=new Array(o),p=0,h=e.length,u=e[p];p<h;u=e[++p])c[p]=new t.IntPoint2(n[l].X-u.X,n[l].Y-u.Y);A.push(c)}var d=new Array;for(l=0;l<a-1+s;l++)for(p=0;p<o;p++){var g=new Array;g.push(A[l%a][p%o]),g.push(A[(l+1)%a][p%o]),g.push(A[(l+1)%a][(p+1)%o]),g.push(A[l%a][(p+1)%o]),t.Clipper.Orientation(g)||g.reverse(),d.push(g)}return d},t.Clipper.MinkowskiSum=function(e,n,i){if(n[0]instanceof Array){l=n;for(var r=new t.Paths,s=(a=new t.Clipper,0);s<l.length;++s){var o=t.Clipper.Minkowski(e,l[s],!0,i);a.AddPaths(o,t.PolyType.ptSubject,!0),i&&(A=t.Clipper.TranslatePath(l[s],e[0]),a.AddPath(A,t.PolyType.ptClip,!0))}return a.Execute(t.ClipType.ctUnion,r,t.PolyFillType.pftNonZero,t.PolyFillType.pftNonZero),r}var a,A=n,l=t.Clipper.Minkowski(e,A,!0,i);return(a=new t.Clipper).AddPaths(l,t.PolyType.ptSubject,!0),a.Execute(t.ClipType.ctUnion,l,t.PolyFillType.pftNonZero,t.PolyFillType.pftNonZero),l},t.Clipper.TranslatePath=function(e,n){for(var i=new t.Path,r=0;r<e.length;r++)i.push(new t.IntPoint2(e[r].X+n.X,e[r].Y+n.Y));return i},t.Clipper.MinkowskiDiff=function(e,n){var i=t.Clipper.Minkowski(e,n,!1,!0),r=new t.Clipper;return r.AddPaths(i,t.PolyType.ptSubject,!0),r.Execute(t.ClipType.ctUnion,i,t.PolyFillType.pftNonZero,t.PolyFillType.pftNonZero),i},t.Clipper.PolyTreeToPaths=function(e){var n=new Array;return t.Clipper.AddPolyNodeToPaths(e,t.Clipper.NodeType.ntAny,n),n},t.Clipper.AddPolyNodeToPaths=function(e,n,i){var r=!0;switch(n){case t.Clipper.NodeType.ntOpen:return;case t.Clipper.NodeType.ntClosed:r=!e.IsOpen}e.m_polygon.length>0&&r&&i.push(e.m_polygon);for(var s=0,o=e.Childs(),a=o.length,A=o[s];s<a;A=o[++s])t.Clipper.AddPolyNodeToPaths(A,n,i)},t.Clipper.OpenPathsFromPolyTree=function(e){for(var n=new t.Paths,i=0,r=e.ChildCount();i<r;i++)e.Childs()[i].IsOpen&&n.push(e.Childs()[i].m_polygon);return n},t.Clipper.ClosedPathsFromPolyTree=function(e){var n=new t.Paths;return t.Clipper.AddPolyNodeToPaths(e,t.Clipper.NodeType.ntClosed,n),n},Inherit(t.Clipper,t.ClipperBase),t.Clipper.NodeType={ntAny:0,ntOpen:1,ntClosed:2},t.ClipperOffset=function(e,n){void 0===e&&(e=2),void 0===n&&(n=t.ClipperOffset.def_arc_tolerance),this.m_destPolys=new t.Paths,this.m_srcPoly=new t.Path,this.m_destPoly=new t.Path,this.m_normals=new Array,this.m_delta=0,this.m_sinA=0,this.m_sin=0,this.m_cos=0,this.m_miterLim=0,this.m_StepsPerRad=0,this.m_lowest=new t.IntPoint0,this.m_polyNodes=new t.PolyNode,this.MiterLimit=e,this.ArcTolerance=n,this.m_lowest.X=-1},t.ClipperOffset.two_pi=6.28318530717959,t.ClipperOffset.def_arc_tolerance=.25,t.ClipperOffset.prototype.Clear=function(){t.Clear(this.m_polyNodes.Childs()),this.m_lowest.X=-1},t.ClipperOffset.Round=t.Clipper.Round,t.ClipperOffset.prototype.AddPath=function(e,n,i){var r=e.length-1;if(!(r<0)){var s=new t.PolyNode;if(s.m_jointype=n,s.m_endtype=i,i===t.EndType.etClosedLine||i===t.EndType.etClosedPolygon)for(;r>0&&t.IntPoint.op_Equality(e[0],e[r]);)r--;s.m_polygon.push(e[0]);for(var o=0,a=0,A=1;A<=r;A++)t.IntPoint.op_Inequality(s.m_polygon[o],e[A])&&(o++,s.m_polygon.push(e[A]),(e[A].Y>s.m_polygon[a].Y||e[A].Y===s.m_polygon[a].Y&&e[A].X<s.m_polygon[a].X)&&(a=o));if(!(i===t.EndType.etClosedPolygon&&o<2)&&(this.m_polyNodes.AddChild(s),i===t.EndType.etClosedPolygon))if(this.m_lowest.X<0)this.m_lowest=new t.IntPoint2(this.m_polyNodes.ChildCount()-1,a);else{var l=this.m_polyNodes.Childs()[this.m_lowest.X].m_polygon[this.m_lowest.Y];(s.m_polygon[a].Y>l.Y||s.m_polygon[a].Y===l.Y&&s.m_polygon[a].X<l.X)&&(this.m_lowest=new t.IntPoint2(this.m_polyNodes.ChildCount()-1,a))}}},t.ClipperOffset.prototype.AddPaths=function(e,t,n){for(var i=0,r=e.length;i<r;i++)this.AddPath(e[i],t,n)},t.ClipperOffset.prototype.FixOrientations=function(){if(this.m_lowest.X>=0&&!t.Clipper.Orientation(this.m_polyNodes.Childs()[this.m_lowest.X].m_polygon))for(var e=0;e<this.m_polyNodes.ChildCount();e++)((n=this.m_polyNodes.Childs()[e]).m_endtype===t.EndType.etClosedPolygon||n.m_endtype===t.EndType.etClosedLine&&t.Clipper.Orientation(n.m_polygon))&&n.m_polygon.reverse();else for(e=0;e<this.m_polyNodes.ChildCount();e++){var n;(n=this.m_polyNodes.Childs()[e]).m_endtype!==t.EndType.etClosedLine||t.Clipper.Orientation(n.m_polygon)||n.m_polygon.reverse()}},t.ClipperOffset.GetUnitNormal=function(e,n){var i=n.X-e.X,r=n.Y-e.Y;if(0===i&&0===r)return new t.DoublePoint2(0,0);var s=1/Math.sqrt(i*i+r*r);return i*=s,r*=s,new t.DoublePoint2(r,-i)},t.ClipperOffset.prototype.DoOffset=function(e){if(this.m_destPolys=new Array,this.m_delta=e,t.ClipperBase.near_zero(e))for(var n=0;n<this.m_polyNodes.ChildCount();n++)(s=this.m_polyNodes.Childs()[n]).m_endtype===t.EndType.etClosedPolygon&&this.m_destPolys.push(s.m_polygon);else{var i;this.MiterLimit>2?this.m_miterLim=2/(this.MiterLimit*this.MiterLimit):this.m_miterLim=.5,i=this.ArcTolerance<=0?t.ClipperOffset.def_arc_tolerance:this.ArcTolerance>Math.abs(e)*t.ClipperOffset.def_arc_tolerance?Math.abs(e)*t.ClipperOffset.def_arc_tolerance:this.ArcTolerance;var r=3.14159265358979/Math.acos(1-i/Math.abs(e));for(this.m_sin=Math.sin(t.ClipperOffset.two_pi/r),this.m_cos=Math.cos(t.ClipperOffset.two_pi/r),this.m_StepsPerRad=r/t.ClipperOffset.two_pi,e<0&&(this.m_sin=-this.m_sin),n=0;n<this.m_polyNodes.ChildCount();n++){var s=this.m_polyNodes.Childs()[n];this.m_srcPoly=s.m_polygon;var o=this.m_srcPoly.length;if(!(0===o||e<=0&&(o<3||s.m_endtype!==t.EndType.etClosedPolygon)))if(this.m_destPoly=new Array,1!==o){for(this.m_normals.length=0,h=0;h<o-1;h++)this.m_normals.push(t.ClipperOffset.GetUnitNormal(this.m_srcPoly[h],this.m_srcPoly[h+1]));if(s.m_endtype===t.EndType.etClosedLine||s.m_endtype===t.EndType.etClosedPolygon?this.m_normals.push(t.ClipperOffset.GetUnitNormal(this.m_srcPoly[o-1],this.m_srcPoly[0])):this.m_normals.push(new t.DoublePoint1(this.m_normals[o-2])),s.m_endtype===t.EndType.etClosedPolygon){var a=o-1;for(h=0;h<o;h++)a=this.OffsetPoint(h,a,s.m_jointype);this.m_destPolys.push(this.m_destPoly)}else if(s.m_endtype===t.EndType.etClosedLine){for(a=o-1,h=0;h<o;h++)a=this.OffsetPoint(h,a,s.m_jointype);this.m_destPolys.push(this.m_destPoly),this.m_destPoly=new Array;var A=this.m_normals[o-1];for(h=o-1;h>0;h--)this.m_normals[h]=new t.DoublePoint2(-this.m_normals[h-1].X,-this.m_normals[h-1].Y);for(this.m_normals[0]=new t.DoublePoint2(-A.X,-A.Y),a=0,h=o-1;h>=0;h--)a=this.OffsetPoint(h,a,s.m_jointype);this.m_destPolys.push(this.m_destPoly)}else{var l;for(a=0,h=1;h<o-1;++h)a=this.OffsetPoint(h,a,s.m_jointype);for(s.m_endtype===t.EndType.etOpenButt?(h=o-1,l=new t.IntPoint2(t.ClipperOffset.Round(this.m_srcPoly[h].X+this.m_normals[h].X*e),t.ClipperOffset.Round(this.m_srcPoly[h].Y+this.m_normals[h].Y*e)),this.m_destPoly.push(l),l=new t.IntPoint2(t.ClipperOffset.Round(this.m_srcPoly[h].X-this.m_normals[h].X*e),t.ClipperOffset.Round(this.m_srcPoly[h].Y-this.m_normals[h].Y*e)),this.m_destPoly.push(l)):(h=o-1,a=o-2,this.m_sinA=0,this.m_normals[h]=new t.DoublePoint2(-this.m_normals[h].X,-this.m_normals[h].Y),s.m_endtype===t.EndType.etOpenSquare?this.DoSquare(h,a):this.DoRound(h,a)),h=o-1;h>0;h--)this.m_normals[h]=new t.DoublePoint2(-this.m_normals[h-1].X,-this.m_normals[h-1].Y);for(this.m_normals[0]=new t.DoublePoint2(-this.m_normals[1].X,-this.m_normals[1].Y),h=(a=o-1)-1;h>0;--h)a=this.OffsetPoint(h,a,s.m_jointype);s.m_endtype===t.EndType.etOpenButt?(l=new t.IntPoint2(t.ClipperOffset.Round(this.m_srcPoly[0].X-this.m_normals[0].X*e),t.ClipperOffset.Round(this.m_srcPoly[0].Y-this.m_normals[0].Y*e)),this.m_destPoly.push(l),l=new t.IntPoint2(t.ClipperOffset.Round(this.m_srcPoly[0].X+this.m_normals[0].X*e),t.ClipperOffset.Round(this.m_srcPoly[0].Y+this.m_normals[0].Y*e)),this.m_destPoly.push(l)):(a=1,this.m_sinA=0,s.m_endtype===t.EndType.etOpenSquare?this.DoSquare(0,1):this.DoRound(0,1)),this.m_destPolys.push(this.m_destPoly)}}else{if(s.m_jointype===t.JoinType.jtRound)for(var c=1,p=0,h=1;h<=r;h++){this.m_destPoly.push(new t.IntPoint2(t.ClipperOffset.Round(this.m_srcPoly[0].X+c*e),t.ClipperOffset.Round(this.m_srcPoly[0].Y+p*e)));var u=c;c=c*this.m_cos-this.m_sin*p,p=u*this.m_sin+p*this.m_cos}else{c=-1,p=-1;for(var h=0;h<4;++h)this.m_destPoly.push(new t.IntPoint2(t.ClipperOffset.Round(this.m_srcPoly[0].X+c*e),t.ClipperOffset.Round(this.m_srcPoly[0].Y+p*e))),c<0?c=1:p<0?p=1:c=-1}this.m_destPolys.push(this.m_destPoly)}}}},t.ClipperOffset.prototype.Execute=function(){var e=arguments;if(e[0]instanceof t.PolyTree)if(o=e[1],(s=e[0]).Clear(),this.FixOrientations(),this.DoOffset(o),(r=new t.Clipper(0)).AddPaths(this.m_destPolys,t.PolyType.ptSubject,!0),o>0)r.Execute(t.ClipType.ctUnion,s,t.PolyFillType.pftPositive,t.PolyFillType.pftPositive);else if(A=t.Clipper.GetBounds(this.m_destPolys),(a=new t.Path).push(new t.IntPoint2(A.left-10,A.bottom+10)),a.push(new t.IntPoint2(A.right+10,A.bottom+10)),a.push(new t.IntPoint2(A.right+10,A.top-10)),a.push(new t.IntPoint2(A.left-10,A.top-10)),r.AddPath(a,t.PolyType.ptSubject,!0),r.ReverseSolution=!0,r.Execute(t.ClipType.ctUnion,s,t.PolyFillType.pftNegative,t.PolyFillType.pftNegative),1===s.ChildCount()&&s.Childs()[0].ChildCount()>0){var n=s.Childs()[0];s.Childs()[0]=n.Childs()[0],s.Childs()[0].m_Parent=s;for(var i=1;i<n.ChildCount();i++)s.AddChild(n.Childs()[i])}else s.Clear();else{var r,s=e[0],o=e[1];if(t.Clear(s),this.FixOrientations(),this.DoOffset(o),(r=new t.Clipper(0)).AddPaths(this.m_destPolys,t.PolyType.ptSubject,!0),o>0)r.Execute(t.ClipType.ctUnion,s,t.PolyFillType.pftPositive,t.PolyFillType.pftPositive);else{var a,A=t.Clipper.GetBounds(this.m_destPolys);(a=new t.Path).push(new t.IntPoint2(A.left-10,A.bottom+10)),a.push(new t.IntPoint2(A.right+10,A.bottom+10)),a.push(new t.IntPoint2(A.right+10,A.top-10)),a.push(new t.IntPoint2(A.left-10,A.top-10)),r.AddPath(a,t.PolyType.ptSubject,!0),r.ReverseSolution=!0,r.Execute(t.ClipType.ctUnion,s,t.PolyFillType.pftNegative,t.PolyFillType.pftNegative),s.length>0&&s.splice(0,1)}}},t.ClipperOffset.prototype.OffsetPoint=function(e,n,i){if(this.m_sinA=this.m_normals[n].X*this.m_normals[e].Y-this.m_normals[e].X*this.m_normals[n].Y,Math.abs(this.m_sinA*this.m_delta)<1){if(this.m_normals[n].X*this.m_normals[e].X+this.m_normals[e].Y*this.m_normals[n].Y>0)return this.m_destPoly.push(new t.IntPoint2(t.ClipperOffset.Round(this.m_srcPoly[e].X+this.m_normals[n].X*this.m_delta),t.ClipperOffset.Round(this.m_srcPoly[e].Y+this.m_normals[n].Y*this.m_delta))),n}else this.m_sinA>1?this.m_sinA=1:this.m_sinA<-1&&(this.m_sinA=-1);if(this.m_sinA*this.m_delta<0)this.m_destPoly.push(new t.IntPoint2(t.ClipperOffset.Round(this.m_srcPoly[e].X+this.m_normals[n].X*this.m_delta),t.ClipperOffset.Round(this.m_srcPoly[e].Y+this.m_normals[n].Y*this.m_delta))),this.m_destPoly.push(new t.IntPoint1(this.m_srcPoly[e])),this.m_destPoly.push(new t.IntPoint2(t.ClipperOffset.Round(this.m_srcPoly[e].X+this.m_normals[e].X*this.m_delta),t.ClipperOffset.Round(this.m_srcPoly[e].Y+this.m_normals[e].Y*this.m_delta)));else switch(i){case t.JoinType.jtMiter:var r=this.m_normals[e].X*this.m_normals[n].X+this.m_normals[e].Y*this.m_normals[n].Y+1;r>=this.m_miterLim?this.DoMiter(e,n,r):this.DoSquare(e,n);break;case t.JoinType.jtSquare:this.DoSquare(e,n);break;case t.JoinType.jtRound:this.DoRound(e,n)}return n=e},t.ClipperOffset.prototype.DoSquare=function(e,n){var i=Math.tan(Math.atan2(this.m_sinA,this.m_normals[n].X*this.m_normals[e].X+this.m_normals[n].Y*this.m_normals[e].Y)/4);this.m_destPoly.push(new t.IntPoint2(t.ClipperOffset.Round(this.m_srcPoly[e].X+this.m_delta*(this.m_normals[n].X-this.m_normals[n].Y*i)),t.ClipperOffset.Round(this.m_srcPoly[e].Y+this.m_delta*(this.m_normals[n].Y+this.m_normals[n].X*i)))),this.m_destPoly.push(new t.IntPoint2(t.ClipperOffset.Round(this.m_srcPoly[e].X+this.m_delta*(this.m_normals[e].X+this.m_normals[e].Y*i)),t.ClipperOffset.Round(this.m_srcPoly[e].Y+this.m_delta*(this.m_normals[e].Y-this.m_normals[e].X*i))))},t.ClipperOffset.prototype.DoMiter=function(e,n,i){var r=this.m_delta/i;this.m_destPoly.push(new t.IntPoint2(t.ClipperOffset.Round(this.m_srcPoly[e].X+(this.m_normals[n].X+this.m_normals[e].X)*r),t.ClipperOffset.Round(this.m_srcPoly[e].Y+(this.m_normals[n].Y+this.m_normals[e].Y)*r)))},t.ClipperOffset.prototype.DoRound=function(e,n){for(var i,r=Math.atan2(this.m_sinA,this.m_normals[n].X*this.m_normals[e].X+this.m_normals[n].Y*this.m_normals[e].Y),s=Math.max(t.Cast_Int32(t.ClipperOffset.Round(this.m_StepsPerRad*Math.abs(r))),1),o=this.m_normals[n].X,a=this.m_normals[n].Y,A=0;A<s;++A)this.m_destPoly.push(new t.IntPoint2(t.ClipperOffset.Round(this.m_srcPoly[e].X+o*this.m_delta),t.ClipperOffset.Round(this.m_srcPoly[e].Y+a*this.m_delta))),i=o,o=o*this.m_cos-this.m_sin*a,a=i*this.m_sin+a*this.m_cos;this.m_destPoly.push(new t.IntPoint2(t.ClipperOffset.Round(this.m_srcPoly[e].X+this.m_normals[e].X*this.m_delta),t.ClipperOffset.Round(this.m_srcPoly[e].Y+this.m_normals[e].Y*this.m_delta)))},t.Error=function(e){try{throw new Error(e)}catch(e){alert(e.message)}},t.JS={},t.JS.AreaOfPolygon=function(e,n){return n||(n=1),t.Clipper.Area(e)/(n*n)},t.JS.AreaOfPolygons=function(e,n){n||(n=1);for(var i=0,r=0;r<e.length;r++)i+=t.Clipper.Area(e[r]);return i/(n*n)},t.JS.BoundsOfPath=function(e,n){return t.JS.BoundsOfPaths([e],n)},t.JS.BoundsOfPaths=function(e,n){n||(n=1);var i=t.Clipper.GetBounds(e);return i.left/=n,i.bottom/=n,i.right/=n,i.top/=n,i},t.JS.Clean=function(e,n){if(!(e instanceof Array))return[];var i=e[0]instanceof Array;if(e=t.JS.Clone(e),"number"!=typeof n||null===n)return t.Error("Delta is not a number in Clean()."),e;if(0===e.length||1===e.length&&0===e[0].length||n<0)return e;i||(e=[e]);for(var r,s,o,a,A,l,c,p=e.length,h=[],u=0;u<p;u++)if(0!==(r=(s=e[u]).length))if(r<3)o=s,h.push(o);else{for(o=s,a=n*n,A=s[0],l=1,c=1;c<r;c++)(s[c].X-A.X)*(s[c].X-A.X)+(s[c].Y-A.Y)*(s[c].Y-A.Y)<=a||(o[l]=s[c],A=s[c],l++);A=s[l-1],(s[0].X-A.X)*(s[0].X-A.X)+(s[0].Y-A.Y)*(s[0].Y-A.Y)<=a&&l--,l<r&&o.splice(l,r-l),o.length&&h.push(o)}return!i&&h.length?h=h[0]:i||0!==h.length?i&&0===h.length&&(h=[[]]):h=[],h},t.JS.Clone=function(e){if(!(e instanceof Array))return[];if(0===e.length)return[];if(1===e.length&&0===e[0].length)return[[]];var t=e[0]instanceof Array;t||(e=[e]);var n,i,r,s,o=e.length,a=new Array(o);for(i=0;i<o;i++){for(n=e[i].length,s=new Array(n),r=0;r<n;r++)s[r]={X:e[i][r].X,Y:e[i][r].Y};a[i]=s}return t||(a=a[0]),a},t.JS.Lighten=function(e,n){if(!(e instanceof Array))return[];if("number"!=typeof n||null===n)return t.Error("Tolerance is not a number in Lighten()."),t.JS.Clone(e);if(0===e.length||1===e.length&&0===e[0].length||n<0)return t.JS.Clone(e);var i,r,s,o,a,A,l,c,p,h,u,d,g,f,m,y,b=e[0]instanceof Array;b||(e=[e]);var I=e.length,x=n*n,C=[];for(i=0;i<I;i++)if(0!==(A=(s=e[i]).length)){for(o=0;o<1e6;o++){for(a=[],s[(A=s.length)-1].X!==s[0].X||s[A-1].Y!==s[0].Y?(u=1,s.push({X:s[0].X,Y:s[0].Y}),A=s.length):u=0,h=[],r=0;r<A-2;r++)l=s[r],p=s[r+1],c=s[r+2],m=l.X,y=l.Y,d=c.X-m,g=c.Y-y,0===d&&0===g||((f=((p.X-m)*d+(p.Y-y)*g)/(d*d+g*g))>1?(m=c.X,y=c.Y):f>0&&(m+=d*f,y+=g*f)),(d=p.X-m)*d+(g=p.Y-y)*g<=x&&(h[r+1]=1,r++);for(a.push({X:s[0].X,Y:s[0].Y}),r=1;r<A-1;r++)h[r]||a.push({X:s[r].X,Y:s[r].Y});if(a.push({X:s[A-1].X,Y:s[A-1].Y}),u&&s.pop(),!h.length)break;s=a}a[(A=a.length)-1].X===a[0].X&&a[A-1].Y===a[0].Y&&a.pop(),a.length>2&&C.push(a)}return b||(C=C[0]),void 0===C&&(C=[]),C},t.JS.PerimeterOfPath=function(e,t,n){if(void 0===e)return 0;var i,r,s=Math.sqrt,o=0,a=0,A=0,l=0,c=0,p=e.length;if(p<2)return 0;for(t&&(e[p]=e[0],p++);--p;)a=(i=e[p]).X,A=i.Y,o+=s((a-(l=(r=e[p-1]).X))*(a-l)+(A-(c=r.Y))*(A-c));return t&&e.pop(),o/n},t.JS.PerimeterOfPaths=function(e,n,i){i||(i=1);for(var r=0,s=0;s<e.length;s++)r+=t.JS.PerimeterOfPath(e[s],n,i);return r},t.JS.ScaleDownPath=function(e,t){var n,i;for(t||(t=1),n=e.length;n--;)(i=e[n]).X=i.X/t,i.Y=i.Y/t},t.JS.ScaleDownPaths=function(e,t){var n,i,r;for(t||(t=1),n=e.length;n--;)for(i=e[n].length;i--;)(r=e[n][i]).X=r.X/t,r.Y=r.Y/t},t.JS.ScaleUpPath=function(e,t){var n,i,r=Math.round;for(t||(t=1),n=e.length;n--;)(i=e[n]).X=r(i.X*t),i.Y=r(i.Y*t)},t.JS.ScaleUpPaths=function(e,t){var n,i,r,s=Math.round;for(t||(t=1),n=e.length;n--;)for(i=e[n].length;i--;)(r=e[n][i]).X=s(r.X*t),r.Y=s(r.Y*t)},t.ExPolygons=function(){return[]},t.ExPolygon=function(){this.outer=null,this.holes=null},t.JS.AddOuterPolyNodeToExPolygons=function(e,n){var i=new t.ExPolygon;i.outer=e.Contour();var r,s,o,a,A,l,c=e.Childs(),p=c.length;for(i.holes=new Array(p),o=0;o<p;o++)for(r=c[o],i.holes[o]=r.Contour(),a=0,l=(A=r.Childs()).length;a<l;a++)s=A[a],t.JS.AddOuterPolyNodeToExPolygons(s,n);n.push(i)},t.JS.ExPolygonsToPaths=function(e){var n,i,r,s,o=new t.Paths;for(n=0,r=e.length;n<r;n++)for(o.push(e[n].outer),i=0,s=e[n].holes.length;i<s;i++)o.push(e[n].holes[i]);return o},t.JS.PolyTreeToExPolygons=function(e){var n,i,r,s,o=new t.ExPolygons;for(i=0,s=(r=e.Childs()).length;i<s;i++)n=r[i],t.JS.AddOuterPolyNodeToExPolygons(n,o);return o}}();var It=getDefaultExportFromCjs(bt.exports);function alignByMinDist(e,t,n){const i=e.length,r=t.length;if(i<1||r<1)return t.slice();let s=0,o=1/0;for(let a=0;a<r;a++){const A=e[0],l=t[a%r],c=A.x-l.x,p=A.y-l.y,h=e[i-1],u=t[n?Math.min(a+i-1,r-1):(a+i-1)%r],d=h.x-u.x,g=h.y-u.y,f=c*c+p*p+d*d+g*g;f<o&&(o=f,s=a)}return[...t.slice(s),...t.slice(0,s)]}function shapeclip(){const e=1e4;function toclipformat(t){let n=t.map((t=>({X:Math.round(t.x*e),Y:Math.round(t.y*e)})));return ensureOrientation(n)}function fromclipformat(t){return t.map((t=>({x:t.X/e,y:t.Y/e})))}const ensureOrientation=e=>It.Clipper.Orientation(e)?e:e.slice().reverse();function orientation(e){if(!e.length)return 0;let t=0;const n=e.length;for(let i=0;i<n;i++){const r=e[i],s=e[(i+1)%n];t+=r.X*s.Y-s.X*r.Y}return t>0?1:t<0?-1:0}const _inflate=(e,t,n=!1)=>{const i=new It.ClipperOffset;i.MiterLimit=4,i.AddPath(e,It.JoinType.jtMiter,n||2==e.length?It.EndType.etOpenButt:It.EndType.etClosedPolygon);const r=new It.Paths;return i.Execute(r,t),r};function _inflateopen(t,n){const i=new It.ClipperOffset;i.MiterLimit=4,i.ArcTolerance=.25;const r=n*e,s=toclipformat(t);i.AddPath(s,It.JoinType.jtMiter,It.EndType.etClosedPolygon);const o=new It.Paths;i.Execute(o,r);let a=fromclipformat(o[0]);return getshape().frompt(a)}return{offset(t,n){const i=new It.ClipperOffset;i.MiterLimit=4,i.ArcTolerance=.25;const r=Math.abs(n)*e,s=toclipformat(t.pt);i.AddPath(s,It.JoinType.jtMiter,It.EndType.etOpenButt);const o=new It.Paths;i.Execute(o,r);let a=fromclipformat(o[0]);return getshape().frompt(a)},inflate:function inflate(t,n=2,i=!1,r=0){let s=toclipformat(t.pt),o=_inflate(s,n*e);if(!o||!o.length)return getshape().frompt([]);let a=getshape().frompt(fromclipformat(o[0]));if(i){a.orient!=t.orient&&a.reverse();let A=alignByMinDist(t.pt,a.pt,r);if(a.frompt(A),r>0&&t.pt.length>=3){function estendi1(e,t){let n=e.segment(0).ruotata(-Math.PI/2,200,!0),i=e.segment(-2).ruotata(-Math.PI/2,200),r=t.segment(-2).interseca(i),s=t.segment(0).interseca(n);s&&(t.pt[0]=s),r&&(t.pt[t.pt.length-1]=r)}function estendi2(e,t){let n=e.segment(-1),i=t.segment(0),r=n.interseca(i);r&&(t.pt[0]=r),i=t.segment(-2);let s=n.interseca(i);s&&(t.pt[t.pt.length-1]=s)}1==r?estendi1(t,a):estendi2(t,a)}}return a},inflateopen:_inflateopen,inflateclose(e,t){let n=_inflateopen(e.pt,t);n.orient!=e.orient&&n.reverse();let i=alignByMinDist(e.pt,n.pt,0);return n.frompt(i),n},inflatecornici(e,t=2,n,i){let r,s=e.npt;if(2==s){let n=e.segment(0).offset(t);r=getshape().frompt([n.p1,n.p2])}else if(3==s){let n=e.segment(0).offset(t),i=e.segment(1).offset(t);if(n.isparallela(i))r=getshape().frompt([n.p1,i.p2]);else{let e=n.interseca(i);r=getshape().frompt([n.p1,e,i.p2])}}else{let s=new Linea2(e.pt[0],e.pt[e.npt-1]),o=s.len,a=s.perpendicolare(s.p1,o),A=s.perpendicolare(s.p2,o);a.isparallela(e.segment(0))&&(a=s.perpendicolare(s.puntot(.1),o)),A.isparallela(e.segment(e.npt-2))&&(A=s.perpendicolare(s.puntot(.9),o));let l=Math.floor(e.npt/2),{t:c}=a.proiezionet(e.pt[l]),p=2*(c>0?-1:1),h=a.puntot(p),u=A.puntot(p);r=_inflateopen([...e.pt,u,h],t);let d=r.pt.reduce(((e,t,n)=>(t.x-h.x)**2+(t.y-h.y)**2<(r.pt[e].x-h.x)**2+(r.pt[e].y-h.y)**2?n:e),0);r.pt=r.pt.slice(d+2).concat(r.pt.slice(0,d)),r.orient!=e.orient&&r.reverse(),n&&(e.truncatebefore(n),r.truncatebefore(n)),i&&(r.truncateafter(i),e.truncateafter(i))}return r},intersecasplitter(e,t){const n=new It.Clipper,i=[toclipformat(t.pt)],r=[toclipformat(e.pt)];n.AddPaths(i,It.PolyType.ptSubject,!0),n.AddPaths(r,It.PolyType.ptClip,!0);const s=new It.Paths;let o;if(n.Execute(It.ClipType.ctIntersection,s,It.PolyFillType.pftNonZero,It.PolyFillType.pftNonZero)&&s.length>0){const e=s[0];if(1===orientation(e)){o=getshape().frompt(fromclipformat(e)),o.orient!=t.orient&&o.reverse();for(let e=0;e<t.pt.length;e++){let n=t.pt[e],i=o.pt.findIndex((e=>Math.abs(e.x-n.x)<.01&&Math.abs(e.y-n.y)<.01));if(i>0){i-=e,0!=i&&o.selezionaprimo(i);break}}}}return o},offsetpts(t,n=.01){const i=e*n;let r=_inflate(toclipformat(t),i);if(r&&r.length)return fromclipformat(r[0])},areesplitter(e,t,n=!0){if(!Array.isArray(e)||e.length<3)return;if(!t||0==t.length)return[e];const i=new It.Paths,r=new It.Paths;let s=n?_inflate(toclipformat(e),-100):[toclipformat(e)],o=n?t.flatMap((e=>_inflate(toclipformat(e),100))):t.map((e=>toclipformat(e)));for(let e of s)i.push(e);for(let e of o)r.push(e);const a=new It.Clipper;a.AddPaths(i,It.PolyType.ptSubject,!0),a.AddPaths(r,It.PolyType.ptClip,!0);const A=new It.Paths;if(!a.Execute(It.ClipType.ctDifference,A,It.PolyFillType.pftNonZero,It.PolyFillType.pftNonZero))return;let l=[];for(let e of A)if(n){const t=_inflate(e,100);for(const e of t)1===orientation(e)&&l.push(fromclipformat(e))}else if(e.length>4&&1==orientation(e)){const t=_inflate(e,-100);if(t.length>0)for(let e of t){const t=_inflate(e,100);for(const e of t)1===orientation(e)&&l.push(fromclipformat(e))}}else 1==orientation(e)&&l.push(fromclipformat(e));return l},unisci(e,t,n){const i=new It.Paths,r=new It.Paths;for(let t of e){let e=[toclipformat(t.pt)];for(let t of e)i.push(t)}if(t&&t.length)for(let e of t){let t=toclipformat(e.pt);r.push(t)}if(n&&n.length)for(let e of n){let t=toclipformat(e.pt),n=_inflate(t,1,!0);for(let e of n)r.push(e)}const s=new It.Clipper;s.AddPaths(i,It.PolyType.ptSubject,!0),s.AddPaths(r,It.PolyType.ptClip,!0);const o=new It.Paths;if(s.Execute(It.ClipType.ctDifference,o,It.PolyFillType.pftNonZero,It.PolyFillType.pftNonZero)){let e=[],t=[];for(let n of o)if(1==orientation(n)){let t=[n];for(let n of t)e.push({shape:getshape().frompt(fromclipformat(n)),holes:[]})}else t.push(getshape().frompt(fromclipformat(n)));for(let n of t)for(let t of e)if(t.shape.pointinshape(n.pt[0])){t.holes.push(n);break}return e}return[]}}}class Vscene{constructor(e,t,n={}){this.x=e,this.y=t,this.info=n,this.clear()}addrow(e){e||(e={}),e.id=function newid(e){let t=0;for(let n of e)+n.id>t&&(t=+n.id);return t+1}(this.rows);let t=new Vobject(e);return this.rows.push(t),t}clear(){this.curlayer=0,this.rows=[],this.clines=[]}fromjson(e){let t,n;e||(e={info:{}}),this.clear(),this.x=e.x||4e3,this.y=e.y||3e3,this.info=e.info||{},this.curlayer=e.curlayer,e.clines&&(t=e.clines.map((e=>new Linea2(e.p1,e.p2))));let i=this.x,r=this.y;n=[new Linea2(0,0,100,0),new Linea2(i,0,i,100),new Linea2(i,r,i-100,r),new Linea2(0,r,0,r-100)],this.clines=[...n,...t],e.rows&&(this.rows=e.rows.map((e=>new Vobject(e))))}tojson(){let{x:e,y:t,info:n,curlayer:i,xrows:r,xclines:s}=this,o=r.map((e=>e.tojson())),a=s.map((e=>({p1:e.p1,p2:e.p2})));return a=a.slice(4),{x:e,y:t,curlayer:i,rows:o,clines:a}}}class Vobject{constructor(e){e||(e={}),this.fromjson(e)}get lines(){if(this._lines&&this._lines.length)return this._lines;{let{x:e,y:t}=this;return e||(e=100),t||(t=100),[new Linea2(0,0,0,t),new Linea2(e,0,e,t)]}}fromjson(e){let t;this.id=e.id??1,this.layer=e.layer||0,this.hidden=!!e.hidden,this.x=e.x||100,this.y=e.y||100,this.pc=e.pc||{x:0,y:0},e.shape?this.shape=getshape().frompt(e.shape):this.shape=void 0,e.lines&&e.lines.length&&(t=e.lines.map((e=>new Linea2(e.p1,e.p2)))),this._lines=t,this.draw=new Vis2d(`d:${e.id}`),e.draw&&this.draw.fromjson(e.draw),this.info=e.info||{},this.pos=e.pos||{x:0,y:0,rot:0}}tojson(){let{id:e,layer:t,x:n,y:i,pc:r,shape:s,hidden:o,_lines:a,info:A,pos:l}=this;return a=a&&a.length?a.map((e=>({p1:e.p1,p2:e.p2}))):void 0,s=s?s.pt:void 0,{id:e,layer:t,x:n,y:i,pc:r,shape:s,lines:a,hidden:o,info:A,pos:l,draw:this.draw.tojson()}}}class Vis2d{constructor(e,t,n,i){this.name=e,this.visible=t,this.des=n,this.inverse=i,this.clear()}clear(){return this.vec=[],this.gr={},this}tojson(){let e={};for(let t in this.gr)e[t]=this.gr[t].tojson();let{name:t,visible:n,des:i,vec:r,inverse:s}=this;return{name:t,visible:n,des:i,inverse:s,vec:[...r],groups:e}}fromjson(e){if(!(e&&e.name&&e.vec))throw new Error("wrong data JSON");this.clear(),this.name=e.name,this.visible=e.visilbe,this.des=e.des,this.inverse=e.inverse,this.vec=[...e.vec];for(let t in e.groups)this.gr[t]=new Vis2d(t).fromjson(e.groups[t])}creategr(e="grp"){return this.gr[e]||(this.gr[e]=new Vis2d(e)),this.gr[e]}push(e=0,t=0,n={}){"number"==typeof n&&(n={rot:n}),n||(n={}),this.vec.push({type:"push",x:e,y:t,op:n})}pop(){this.vec.push({type:"pop"})}randomcolor(e="100%"){return`hsl(${Math.floor(360*Math.random())}, 50%, 40%,${e})`}addgr(e){let t=e;e?.name&&(t=e.name),this.gr[t]?this.vec.push({type:"group",name:t}):this.vec.push({type:"err",err:`addgroup: ${t} => missing`})}addtext(e,t,n,i,r="black",s="white"){this.vec.push({type:"text",x:e,y:t,text:n,color:r,fill:s,scalafont:i})}addquota(e,t,n,i,r=0,s="",o=1,a=.25){this.vec.push({type:"quota",x1:e,y1:t,x2:n,y2:i,d:r,text:s,spessore:a,color:"black",scalafont:o})}addqpunto(e,t,n,i,r=0,s="",o=1,a=.25){this.vec.push({type:"qpunto",x1:e,y1:t,x2:n,y2:i,d:r,text:s,spessore:a,color:"black",scalafont:o})}addpoint(e,t=-1,n="red",i=8){return e&&this.vec.push({type:"point",p:e,id:t,color:n,spessore:1*i}),this}addline(e,t=-1,n=void 0,i=1){return e&&this.vec.push({type:"line",l:e,id:t,color:n,spessore:1*i}),this}addspace(e){return e&&this.vec.push({type:"space",l:e}),this}addrect(e,t=void 0,n=1,i=void 0){return e&&this.vec.push({type:"rect",l:e,color:t,spessore:1*n,fill:i}),this}addimg(e,t){return e&&this.vec.push({type:"img",l:e,img:t}),this}addrecta(e,t=void 0,n=void 0){return e&&this.vec.push({type:"recta",l:e,color:t,spessore:0,fill:n}),this}addshape(e,t=void 0,n=1,i=void 0){return e&&this.vec.push({type:"shape",s:e,color:t||this.randomcolor(),spessore:1*n,fill:i}),this}addshapelin(e,t=void 0,n=1){return e&&this.vec.push({type:"shapelin",s:e,color:t||this.randomcolor(),spessore:1*n}),this}addarea(e,t=void 0){return e&&this.vec.push({type:"area",s:e,color:t||this.randomcolor()}),this}addoffset(e,t){return this.vec.push({type:"offset",x:e||0,y:t||0}),this}}function checkoggetto(e,t,n,i){if("h"==t&&(t="o"),e||(e=[]),"number"==typeof n&&!["a","as"].includes(t))return{cod:"__",macro:"",sps:n};let r=e.find((e=>e.tipo.includes(t)&&e.cod==n&&(e.isshape||i||"a"!=t)));return r||(r=e.find((e=>e.tipo.includes(t)&&(e.isshape||i||"a"!=t)))),r||(r={cod:"__",macro:"",sps:0}),"a"!=t&&"as"!=t||"__"==r.cod||r.color||(r.color=`hsl(${function stringToHue(e){let t=0;for(let n=0;n<e.length;n++)t=31*t+e.charCodeAt(n)>>>0;return Math.floor(.6180339887*t%1*360)}(r.cod)}, 95%, 97%`),r}function getbordi(e,t){let n,i=!1;if(Array.isArray(t)){t.length=4;let r=t[0]||"";n=t.map((t=>checkoggetto(e,"b",t||r))),i=n.every((e=>e.sps===n[0].sps))}else{let r=checkoggetto(e,"b",t);n=[r,r,r,r],i=!0}return{bordi:n,uguali:i,senza:!(n[0].sps||n[1].sps||n[2].sps||n[3].sps),bl:n[0].sps,bt:n[1].sps,br:n[2].sps,bb:n[3].sps}}function elaborapercorso(e,t,n,i,r=0){let s,o,a,A,l,c,p,h,u,d,g,f,m,y,b,I,x=[],C=[];function eseguipezzo(e,t,n,i){let s=e.infoquad(t);if(s&&s.distanza){let o=getshape().frompt(i||[e.p1,e.p2,t.p2,t.p1]),a=o.clone();(s.sx||s.sy)&&a.move(-s.sx||0,-s.sy||0),s.angle&&a.rotate(-s.angle||0);let A={id:++r,type:`b${n}`,info:s};i&&(A.shape=a.pt),C.push({type:`b${n}`,pt:o.pt}),x.push(A)}}r=r||0;let B=e.pt.length,E=B-1;i||(i=[]);let{bordi:w,uguali:v,senza:P}=getbordi(i,t);if(v)if(P||!w[0].sps)s=e.clone();else{let t=w[0].sps;s=shapeclip().inflate(e,-t,!0)}else{let t,n=[],i=[];for(let i=0;i<B;i++){t=0==i?w[0].sps:i==E-1?w[2].sps:i==E?w[3].sps:w[1].sps,"number"!=typeof t&&(t=0);let r=e.segment(i).offset(-t);n.push(r)}for(let e=0;e<B;e++){let t=n[e].interseca(n[(e-1+B)%B]);i.push(t)}s=getshape().frompt(i)}if(!P){a=s.segment(E).interseca(e.segment(0)),A=s.segment(1).interseca(e.segment(0)),l=e.segment(E-1).interseca(s.segment(E-2)),c=e.segment(E-1).interseca(s.segment(E)),p=e.segment(E).interseca(s.segment(0)),h=e.segment(1).interseca(s.segment(0)),u=e.segment(E-2).interseca(s.segment(E-1)),d=e.segment(E).interseca(s.segment(E-1)),b=1,I=E-2,m=s.segment(0),y=s.segment(E-1);for(let t=1;t<E-1;t++){let n=e.segment(t),i=n.interseca(m);i&&n.onsegment(i)&&(b=t,h=i),i=n.interseca(y),i&&n.onsegment(i)&&(I=t,u=i)}b-=1,I=E-2-I;let i=e.pt[0],r=s.pt[0],x=s.pt[E],C=e.pt[E];switch(n[0]){case"v":eseguipezzo(new Linea2(d,p),s.segment(E),3),r=p,x=d;break;case"o":eseguipezzo(e.segment(E),new Linea2(c,a),3),i=a,C=c;break;default:eseguipezzo(e.segment(E),s.segment(E),3)}switch(g=e.pt.slice(1,E),f=s.pt.slice(1,E),n[1]){case"v":eseguipezzo(new Linea2(i,e.pt[1]),new Linea2(r,h),0),eseguipezzo(new Linea2(e.pt[E-1],C),new Linea2(u,x),2),b&&(g=g.slice(b)),I&&(g=g.slice(0,-I)),g[0]=h,g[g.length-1]=u;break;case"o":eseguipezzo(new Linea2(i,A),new Linea2(r,s.pt[1]),0),eseguipezzo(new Linea2(l,C),new Linea2(s.pt[E-1],x),2),f[0]=A,f[f.length-1]=l;break;default:eseguipezzo(new Linea2(i,e.pt[1]),new Linea2(r,s.pt[1]),0),eseguipezzo(new Linea2(e.pt[E-1],C),new Linea2(s.pt[E-1],x),2)}if(o=getshape().frompt(f),g.length<8&&g.length==f.length)for(let e=0;e<g.length-1;e++)eseguipezzo(new Linea2(g[e],g[e+1]),new Linea2(f[e],f[e+1]),1);else{let e=getshape().frompt([...g,...f.reverse()]),n=new Linea2(g[0],g[g.length-1]),i=n.offset(-t[1]);eseguipezzo(n,i,1,e.pt)}}return{countid:r,shape2:s,shapetop:o,bordi:w,dati:x,draws:C}}function creaprofiloesterno(e,t){let n,{x:i,y:r,tipo:s,bordo:o,taglio:a,h1:A,h2:l,l1:c,l2:p,forma:h}=e;i=i<50?50:i,r=r<50?50:r,c=c||0,p=p||0,A=A||0,l=l||0;let u=[0,0];switch(s){case"i":case"d":u.push(c>0&&c<i?c:0,A>0&&A<r?r-A:r),u.push(p>0&&p<i-c?i-p:i,l>0&&l<r&&l!=A?r-l:r);break;case"a":if(h){let e=getshape().fromstr(h);e.alignline({x:c,y:r-A},{x:i-p,y:r-l}),u.push(...e.vec)}else if((A||l)&&A>=0&&A<Math.min(r,i/2)&&l>=0&&l<Math.min(r,i/2)){let e=getshape().fromstr(`a30;${c||0};${r-A};${i/2};${r};${i-p};${r-l}`);u.push(...e.vec)}else u.push(0,r,i,r);break;case"s":c>0&&A>0?u.push(0,r-A,c,r):u.push(0,r),p&&p<i-c&&l>0&&l<r?u.push(i-p,r,i,r-l):u.push(i,r);break;default:u.push(0,r,i,r)}u.push(i,0),e.countid=0,n=getshape().fromvec(u);let{countid:d,shape2:g,shapetop:f,bordi:m,dati:y,draws:b}=elaborapercorso(n,o,a,t,e.countid);return e.countid=d,{shape:n,internalshape:g,shape2:g,shapetop:f,bordi:m,dati:y,draws:b}}const xt={x:"normale",s:"smussato",i:"inclinato",a:"arco/sagomato",d:"diagonali"},Ct={dd:"diagonale",vv:"verticale",oo:"orizzontale",vo:"verticale+orizzontale",vd:"verticale+diagonale",ov:"orizzontale+verticale",od:"orizzontale+diagonale"},Bt={d:"dist. positiva","d-":"dist. negativa",p:"perc. positiva","p-":"perc negativa"},Et={l:"sinistra",c:"centro",r:"destra"};function findareacod(e,t,n){let i=1/0,r="";for(let s of e){let e=(s.x-t)**2+(s.y-n)**2;e<i&&(i=e,r=s.k)}return r}function generatesegments(e,t,n=!1,i=!1){let r=[];if(e?.length>=2){if(i){let t=[];for(let n of e)t.push({a:n.a,b:n.a}),n.a!=n.b&&t.push({a:n.b,b:n.b});e=t}if(e=e.sort(((e,t)=>e.a-t.a)),t?.length){let i=0;for(let s=1;s<e.length;s++){const o=1e-6;if(t.find((t=>t>e[s-1].b+o&&t<e[s].a-o))){if(s-1>i){let t;t=n?{a:e[i].b,b:e[s-1].a}:{a:e[i].a,b:e[s-1].b},r.push(t)}i=s}}i<e.length-1&&(n?r.push({a:e[i].b,b:e[e.length-1].a}):r.push({a:e[i].a,b:e[e.length-1].b}))}else r.push({a:e[0].b,b:e[e.length-1].a})}return r}function makedivisions(e,t,n){delete e.arre;let i=[],r=[],s=[],o=[],{x:a,y:A,oriz:l,vert:c,tipo:p,minvano:h,minvanox:u,minvanoy:d}=e,{bb:g,bt:f,bl:m,br:y}=getbordi(n,e.bordo);u=u||h||50,d=d||h||50;let{dati:b,punti:I}=ordinabase(n,"o",l,A,d,g,f,p),{dati:x,punti:C}=ordinabase(n,"v",c,a,u,m,y),B=t.clone();function adddatilin(e,t,a,A,l,c){if("l"==e)r.push([a.p1,a.p2]),o.push([a.p1.x,a.p1.y,a.p2.x,a.p2.y]);else{let p=[a.p1,a.p2,A.p2,A.p1];r.push(p);let h=getshape().frompt(p);if(B?.pt&&(h.orient!=B.orient&&h.reverse(),h=shapeclip().intersecasplitter(B,h)),h){h.pt.length>=4&&(a.p1=h.pt[0],a.p2=h.pt[1],A.p1=h.pt[h.pt.length-1],A.p2=h.pt[h.pt.length-2]),o.push([a.p1.x+("v"==e?l:0),a.p1.y+("v"!=e?l:0),a.p2.x+("v"==e?l:0),a.p2.y+("v"!=e?l:0)]);let r=a.infoquad(A);if(r&&r.distanza){let o=h.clone(),a=checkoggetto(n,e,t);(r.sx||r.sy)&&o.move(-r.sx||0,-r.sy||0),r.angle&&o.rotate(-r.angle||0);let A={id:c,type:e,cod:t,c2:a,shape:o.pt,info:r};s.push(A),A?.shape&&i.push({type:e,sx:A.info.sx,sy:A.info.sy,rot:A.info.angle,pt:A.shape})}}}}function isinseg(e,t){return!!e.find((e=>e.a<=t&&e.b>=t))}x.forEach(((e,t)=>{e.segs=generatesegments(I,e.cuts,!0),e.segs.forEach(((t,n)=>{let i=new Linea2({x:e.x,y:t.a},{x:e.x,y:t.b}),r=new Linea2({x:e.x+e.sp,y:t.a},{x:e.x+e.sp,y:t.b});adddatilin(e.sp?"v":"l",e.cod,i,r,e.sp/2,e.id)}))}));for(let e of b){let t=[...e.cuts],n=[...C];for(let i of x)n.push({a:i.x,b:i.x+i.sp}),isinseg(i.segs,e.x+e.sp/2)&&t.push(i.x+i.sp/2);e.segs=generatesegments(n,t,!0,!0),e.segs=e.segs.filter((e=>Math.abs(e.a-e.b)>40));for(let t of e.segs){let n=new Linea2({x:t.b,y:e.x+e.sp},{x:t.a,y:e.x+e.sp}),i=new Linea2({x:t.b,y:e.x},{x:t.a,y:e.x});adddatilin(e.sp?"o":"l",e.cod,i,n,e.sp,e.id)}}let E=shapeclip().areesplitter(t.pt,r),w=function getareacodes(e){let t,n,i,r,s=[];for(let o=0;o<=e.vert.length;o++){if(0==o)t="v0",n=0;else{let i=e.vert[o-1];t=`${i.dir}${i.id}`,n=i._v}for(let o=0;o<=e.oriz.length;o++){if(0==o)i="o0",r=0;else{let t=e.oriz[o-1];i=`${t.dir}${t.id}`,r=t._v}s.push({k:t+i,x:n,y:r})}}return s}(e);for(let t of E){let r=getshape().frompt(t),{p1:o,width:a,height:A,isrect:l}=r.dims(),c=findareacod(w,o.x,o.y),p=e.aree[c]||e.area||"",h=checkoggetto(n,"a",p,l),u=r.pt.findIndex((e=>Math.abs(e.x-o.x)<.001&&Math.abs(e.y-o.y)<.001));u>0&&r.selezionaprimo(u),r.pt.length&&(r.move(-o.x,-o.y),1==r.orient&&r.reverse()),s.push({id:c,cod:p,c2:h,type:"a",shape:l?null:r.pt,info:{isrect:l?1:0,sx:o.x,sy:o.y,rot:0,width:a,height:A}}),i.push({type:l?"a":"as",sx:o.x,sy:o.y,dx:a,dy:A,id:c,cod:p,rot:0,pt:r.pt,color:h.color})}return{ff:e,h1:b,ph:I,v1:x,pv:C,draws:i,lines:o,dati:s}}function ordinabase(e,t,n,i,r,s,o,a){let A=[];if(n){for(let r of n){let n=checkoggetto(e,t,r.cod).sps||0,a=0;switch(r.tipo){case"d-":a=i-r.v;break;case"p":a=i*r.v/100;break;case"p-":a=i*(100-r.v)/100;break;default:a=r.v}if(n&&"c"==r.align?a-=n/2:n&&"r"==r.align&&(a-=n),a=Math.round(10*a)/10,r._x0=a,r._x1=a+n,r._v=a+n/2,r._valid=a>0&&a<i,a>s&&a<i-o){let e=[];r.cuts&&r.cuts.length&&r.cuts.forEach((t=>{e.push(t<0?i+t:t)})),A.push({id:r.id,x:a,sp:n,cuts:e,cod:r.cod})}}A.sort(((e,t)=>e.x-t.x))}let l=[],c=s;"a"==a&&(i*=1.3);for(let e=0;e<A.length;e++){let t=A[e];t.x>=c+r&&t.x+t.sp<=i-o-r&&(t.min=c+r,t.max=i-o-r,l.length>0&&(l[l.length-1].max=t.x-r),l.push(t),c=t.x+t.sp)}let p=[];p.push({a:s,b:s});for(let e of l)p.push({a:e.x,b:e.x+e.sp});return p.push({a:i-o,b:i-o}),{dati:l,punti:p}}function check(e){let{x:t,y:n,area:i,bordo:r,gvert:s,goriz:o,priority:a,minvano:A,taglio:l,tipo:c,h1:p,h2:h,l1:u,l2:d,d1:g,x1:f,y1:m,d2:y,x2:b,y2:I,vert:x,oriz:C,aree:B,forma:E,countid:w}=e;return t=t||1e3,t<20&&(t=20),n=n||1e3,n<20&&(n=20),p=p||m||0,h=h||I||0,u=u||g||f||0,d=d||y||b||0,p<0&&p>n-10&&(p=0),h<0&&h>n-10&&(h=0),(d<0||d>t-u)&&(d=0),(u<0||u>t-d)&&(u=0),A=A||10,E&&(c="a"),i=i||"__",r=r||"__",a=a||"v",l=Ct[l]?l:"dd",c=xt[c]?c:"x",x=x||[],C=C||[],B=B||{},o=o||void 0,s=s||void 0,w=w||1,{x:t,y:n,area:i,bordo:r,gvert:s,goriz:o,priority:a,minvano:A,taglio:l,tipo:c,h1:p,h2:h,l1:u,l2:d,vert:x,oriz:C,aree:B,countid:w}}function addtaglio(e,t,n,i,r,s="c",o=[],a){return a||(console.log("manca id a addtaglio"),a=0),{dir:t,id:a,tipo:Bt[n]?n:"d",align:Et[s]?s:"c",v:i,cod:r,cuts:o||[]}}function addoriz(e,t,n,i,r,s){let o=Array.isArray(e.bordo)?e.bordo[0]:e.bordo;i||(i=e.goriz||o||"__"),Array.isArray(r)&&(s=r,r="c"),e.oriz||(e.oriz=[]);let a=addtaglio(0,"o",t,n,i,r,s,(e.oriz.length?Math.max(...e.oriz.map((e=>e.id))):0)+1);return e.oriz.push(a),e}var wt=Object.freeze({__proto__:null,addhoriz:function addhoriz(e,t,n,i,r,s){return addoriz(e,t,n,i,r,s)},addoriz:addoriz,addvert:function addvert(e,t,n,i,r,s){let o=Array.isArray(e.bordo)?e.bordo[0]:e.bordo;i||(i=e.gvert||o||"__"),Array.isArray(r)&&(s=r,r="c"),e.vert||(e.vert=[]);let a=addtaglio(0,"v",t,n,i,r,s,(e.vert.length?Math.max(...e.vert.map((e=>e.id))):0)+1);return e.vert.push(a),e},calcoladivisioni:function calcoladivisioni(e,t,n,i){return makedivisions(e,n,i)},check:check,checkoggetto:checkoggetto,creaprofiloesterno:creaprofiloesterno,create:function create(e,t,n,i){i||(i={});let{minvano:r,priority:s,taglio:o,tipo:a,h1:A,h2:l,d1:c,d2:p,l1:h,l2:u,x1:d,x2:g,y1:f,y2:m,gvert:y,goriz:b,forma:I,area:x}=i,C=check({x:e,y:t,area:x,bordo:n,gvert:y,goriz:b,priority:s,minvano:r,taglio:o,tipo:a,h1:A,h2:l,l1:h,l2:u,d1:c,x1:d,y1:f,d2:p,x2:g,y2:m});return C.forma=I,C},elaborapercorso:elaborapercorso,getbordi:getbordi,makedivisions:makedivisions,makeshape:function makeshape(e,t){return creaprofiloesterno(e,t)},priorita:{v:"verticale",h:"orizzontale"},tagli:Ct,tipi:xt,tipilocks:[{cod:"diml",des:"Larghezza"},{cod:"dima",des:"Altezza"},{cod:"etipo",des:"Modifica Tipo"},{cod:"etaglio",des:"Modifica Taglio"},{cod:"ebordi",des:"Modifica Bordi"},{cod:"esag",des:"Shape"},{cod:"vcrea",des:"Crea Div. Verticale"},{cod:"ocrea",des:"Crea Div. Orizzontale"},{cod:"vmov",des:"Sposta Div. Verticale"},{cod:"omov",des:"Sposta Div. Orizzontale"},{cod:"vedit",des:"Modifica Div. Verticale"},{cod:"oedit",des:"Modifica Div. Orizzontale"},{cod:"emods",des:"Modificatori Orizzontali/Verticali"},{cod:"ecuts",des:"Modifica/Aggiungi Cuts"},{cod:"earee",des:"Modifica Aree"}],tipoalign:Et,tipocut:Bt});async function exportSceneImage(e,t,n){n||(n={});let i,{name:r="image",png:s,width:o,height:a,zoom:A,zoomatutto:l,scene:c,imposta:p,frustumSize:h=10}=n;p&&(i=p.fakeshadow,p.fakeshadow=!1);const u=e.domElement.width,d=e.domElement.height,g=e.getPixelRatio(),f=t.isOrthographicCamera,m=f?{left:t.left,right:t.right,top:t.top,bottom:t.bottom,zoom:t.zoom}:{aspect:t.aspect};if(o&&a){if(e.setSize(o,a,!1),f){const e=o/a;t.left=-h*e/2,t.right=h*e/2,t.top=h/2,t.bottom=-h/2,t.updateProjectionMatrix()}else t.aspect=o/a,t.updateProjectionMatrix();if(A&&l){l(c.getObjectByName("boxes"),t,void 0,o,a)}}await new Promise((e=>requestAnimationFrame((()=>{requestAnimationFrame(e)}))));const y=await new Promise((t=>{e.domElement.toBlob(t,s?"image/png":"image/webp")}));return o&&a&&(e.setSize(u,d,!1),f?(t.left=m.left,t.right=m.right,t.top=m.top,t.bottom=m.bottom,t.zoom=m.zoom,t.updateProjectionMatrix()):(t.aspect=m.aspect,t.updateProjectionMatrix()),e.setPixelRatio(g)),p&&(p.fakeshadow=i),new File([y],`${r}.${s?"png":"webp"}`,{type:s?"image/png":"image/webp"})}function handleMovimenti(e,t={}){let{container:n,width:i,height:r,camera:s,scene:o,raycaster:a}=t;if(!n)return;const A=n.getBoundingClientRect(),l={x:(e.clientX-A.left)/i*2-1,y:-(e.clientY-A.top)/r*2+1};a.setFromCamera(l,s),a.layers.enable(0),a.layers.enable(1);const c=[];o.traverse((e=>{"Mesh"===e.type&&e.visible&&e.geometry&&e.material&&!e.material.transparent&&c.push(e)}));let p=a.intersectObjects(c,!1);if(p?.length){let e=p[0].object;for(;e&&(!e.userData?.mov||e.userData.mov.hidesel);){if(!e.parent){e=null;break}e=e.parent}if(e){let{mov:t}=e.userData;t.inmov?(t.inmov=!1,e.position.set(0,0,0),e.scale.set(1,1,1),e.rotation.set(0,0,0)):(t.dtstart=performance.now(),t.inmov=!0),e.traverse((n=>{if(n!==e&&n.userData&&n.userData.mov&&n.userData.mov.hidesel){let e=n.userData.mov;t.inmov?e._f.reset(n):(e.dtstart=t.dtstart,e.inmov=!0)}}))}}}function resethover(e,t=void 0){for(let n of e)n!==t&&n.userData?._mat&&(n.material=n.userData._mat,delete n.userData._mat)}function checkhoverables(e,t=!1,n={}){let{container:i,width:r,height:s,camera:o,scene:a,raycaster:A,emit:l,hoverables:c}=n;if(!i)return;if(!c||!c.length)return;const p=i.getBoundingClientRect(),h={x:(e.clientX-p.left)/r*2-1,y:-(e.clientY-p.top)/s*2+1};A.setFromCamera(h,o);const u=A.intersectObjects(c,!0);if(u&&u.length){let e=u[0].object;return resethover(c,e),e.userData.matover&&e.userData.matover!=e.material&&(e.userData._mat=e.material,e.material=e.userData.matover),e.userData.tooltip}resethover(c)}function handlePick(e,t={}){let{container:n,width:i,height:r,camera:s,scene:o,raycaster:a,emit:A,hoverables:l}=t;if(!n)return;const c=n.getBoundingClientRect(),p={x:(e.clientX-c.left)/i*2-1,y:-(e.clientY-c.top)/r*2+1},h=[],u=[];if(a.setFromCamera(p,s),l&&l.length){resethover(l);const t=a.intersectObjects(l,!0);if(t&&t.length){let n=t[0].object;return void A("variant",{x:e.clientX,y:e.clientY,node:n})}}if(s.layers.set(0),o.traverse((e=>{e.userData?.marker&&e.visible?u.push(e):"Mesh"===e.type&&e.material&&e.geometry&&e.visible&&(e.userData._lay=e.layers.mask,e.layers.set(0),h.push(e))})),u.length){const t=a.intersectObjects(u,!0);if(t&&t.length){let n=t[0].object;for(let t=0;t<10;t++){if(n.userData?.marker)return void A("marker",{node:n,x:e.clientX,y:e.clientY});if(n=n.parent,!n)break}}}const d=a.intersectObjects(h,!0);for(let e of h)e.layers.mask=e.userData._lay,delete e.userData._lay;if(d.length>0){let e=d[0].object;for(;e&&!e.userData.INFO;)e=e.parent;e?A("selected",{id:e.name}):A("deselect")}else A("deselect")}const vt={idle:{id:"idle"},movimenti:{id:"movimenti",onMouseDown(e,t){e.stopPropagation(),e.preventDefault(),handleMovimenti(e,t)}},select:{id:"select",onMouseDown(e,t){handlePick(e,t)}},move:{id:"move",onMouseDown(e,t){e.stopPropagation(),e.preventDefault()},onMouseMove(e,t){}}};function picker(e){function creaAsse(t,n=1){let i;switch(t){case"x":i=16711680;break;case"y":i=65280;break;case"z":i=255;break;default:throw new Error("asse non valido")}const r=new e.Group;r.name=`picker_axis_${t}`,r.userData.type="move",r.userData.axis=t;const s=new e.CylinderGeometry(.025*n,.025*n,.7*n,8),o=new e.MeshBasicMaterial({color:i,depthTest:!1,depthWrite:!1}),a=new e.Mesh(s,o);a.position.y=.35*n,a.userData.parentType="move",r.add(a);const A=new e.ConeGeometry(.06*n,.18*n,12),l=new e.MeshBasicMaterial({color:i,depthTest:!1,depthWrite:!1}),c=new e.Mesh(A,l);return c.position.y=.7*n+.09*n,c.userData.parentType="move",r.add(c),"x"===t&&(r.rotation.z=-Math.PI/2),"z"===t&&(r.rotation.x=Math.PI/2),r.visible=!1,r}function creaCorner(){const t=new e.BoxGeometry(.1,.1,.1),n=new e.MeshBasicMaterial({color:"black",depthTest:!1,depthWrite:!1}),i=new e.Mesh(t,n);return i.name="picker_corner",i.userData.type="corner",i.visible=!1,i}function creaRotateHandler(t="y",n=1){const i={x:16711680,y:65280,z:255}[t]||16776960,r=new e.TorusGeometry(n,.02*n,12,64,2*Math.PI),s=new e.MeshBasicMaterial({color:i,transparent:!0,opacity:.7,depthTest:!1,depthWrite:!1}),o=new e.Mesh(r,s);return o.name=`picker_rotate_${t}`,o.userData.type="rotate",o.userData.axis=t,"x"===t&&(o.rotation.z=Math.PI/2),"z"===t&&(o.rotation.x=Math.PI/2),o.visible=!1,o}function creaDragger(t,n=.22,i=.11){const r={x:16711935,y:65535,z:16776960}[t]||16777215,s=new e.CylinderGeometry(0,i,n,3),o=new e.MeshBasicMaterial({color:r,transparent:!0,opacity:.85,depthTest:!1,depthWrite:!1}),a=new e.Mesh(s,o);return a.name=`picker_dragger_${t}`,a.userData.type="resize",a.userData.axis=t,"x"===t?a.rotation.z=-Math.PI/2:"z"===t&&(a.rotation.x=Math.PI/2),a.visible=!1,a}return{Picker:class Picker{constructor(t){this.grp=new e.Group,this.grp.name="_picker",t.add(this.grp),this.grpAssi=new e.Group,this.grpAssi.name="_picker_assi",this.asseX=creaAsse("x"),this.asseY=creaAsse("y"),this.asseZ=creaAsse("z"),this.grpAssi.add(this.asseX,this.asseY,this.asseZ),this.grp.add(this.grpAssi),this.grpRotate=new e.Group,this.grpRotate.name="_picker_rotate",this.rotateHandler=creaRotateHandler("z"),this.grpRotate.add(this.rotateHandler),this.grp.add(this.grpRotate),this.corners=[creaCorner(),creaCorner(),creaCorner(),creaCorner(),creaCorner(),creaCorner(),creaCorner(),creaCorner()],this.corners.forEach((e=>this.grp.add(e))),this.draggerZ=creaDragger("z"),this.draggerY=creaDragger("y"),this.draggerX=creaDragger("x"),this.grp.add(this.draggerZ,this.draggerY,this.draggerX),function forceAlwaysOnTop(e){e.traverse((e=>{e.isMesh&&(e.renderOrder=999,e.material&&(e.material.depthTest=!1,e.material.depthWrite=!1,e.material.transparent=!0))}))}(this.grp),this.clear()}clear(){this.grp.position.set(0,0,0),this.grp.rotation.set(0,0,0),this.grp.scale.set(1,1,1),this.grpAssi.position.set(0,0,0),this.grpAssi.rotation.set(0,0,0),this.grpRotate.position.set(0,0,0),this.grpRotate.rotation.set(0,0,0),this.asseX.visible=!1,this.asseY.visible=!1,this.asseZ.visible=!1,this.rotateHandler.visible=!1,this.corners.forEach((e=>{e.visible=!1,e.position.set(0,0,0)})),this.draggerZ.visible=!1,this.draggerY.visible=!1,this.draggerX.visible=!1}attiva(t){if(this.clear(),!t)return;t.updateMatrixWorld(!0);const n=(new e.Box3).setFromObject(t),i=n.min,r=n.max;this.grp.position.copy(i);const s=new e.Quaternion;t.getWorldQuaternion(s),this.grp.setRotationFromQuaternion(s);const o=t.userData&&t.userData.pick?String(t.userData.pick):"",a=o.trim()?function parsePickerShort(e){const t={};return e.split(";").forEach((e=>{let n=e.trim();if(!n)return;let[i,r]=n.split(":");switch(i=i.trim().toLowerCase(),r=r?r.trim().toLowerCase():"",i){case"a":t.axis=r?r.split(""):["x","y","z"];break;case"d":t.drag=r?r.split(""):["x","y","z"];break;case"r":t.rotate={enabled:!0,step:r&&!isNaN(Number(r))?Number(r):null};break;case"c":t.corners=!r||r.split("")}})),t}(o):{axis:["x","y","z"]},A=a.axis||[];if(A.includes("x")&&(this.asseX.visible=!0),A.includes("y")&&(this.asseY.visible=!0),A.includes("z")&&(this.asseZ.visible=!0),a.rotate&&a.rotate.enabled&&(this.rotateHandler.visible=!0),a.corners){let t={r:16711680,g:65280,b:255}[a?.corners[0]??"y"]??255;this.corners.forEach(((n,s)=>{const o=new e.Vector3(1&s?r.x:i.x,2&s?r.y:i.y,4&s?r.z:i.z);n.position.copy(o.clone().sub(i)),n.material.color.set(t),n.visible=!0}))}const l=a.drag||[];if(l.includes("z")){const t=new e.Vector3((i.x+r.x)/2-i.x,0,r.z-i.z);this.draggerZ.position.copy(t),this.draggerZ.visible=!0}if(l.includes("y")){const t=new e.Vector3(0,0,(i.z+r.z)/2-i.z);this.draggerY.position.copy(t),this.draggerY.visible=!0}if(l.includes("x")){const t=new e.Vector3(r.x-i.x,0,(i.z+r.z)/2-i.z);this.draggerX.position.copy(t),this.draggerX.visible=!0}}update(t){if(!t)return;const n=new e.Vector3;this.grp.getWorldPosition(n);const i=new e.Vector3;t.getWorldPosition(i);let r=i.distanceTo(n);const s=.05*r,o=.06*r,a=.07*r,A=.04*r;this.asseX.scale.set(s,s,s),this.asseY.scale.set(s,s,s),this.asseZ.scale.set(s,s,s),this.rotateHandler.scale.set(A,A,A),this.corners.forEach((e=>e.scale.set(o,o,o))),this.draggerX.scale.set(a,a,a),this.draggerY.scale.set(a,a,a),this.draggerZ.scale.set(a,a,a)}},creaDragger:creaDragger,creaRotateHandler:creaRotateHandler,creaCorner:creaCorner,creaAsse:creaAsse}}function d3dview(e={}){const{THREE:t,post:n,GLTFExporter:i,RGBELoader:r,KTX2Loader:s,SAOPass:o}=e,{createSAOPass:a,updateSAOPass:A}=function ssao(e){return{createSAOPass:function createSAOPass({composer:t,scene:n,camera:i,renderer:r}){const s=new e(n,i,!1,!0);return s.enabled=!1,s.params.output=0,s.params.saoBias=.06,s.params.saoIntensity=.18,s.params.saoScale=2,s.params.saoKernelRadius=4,s.params.saoMinResolution=0,s.params.saoBlur=!0,s.params.saoBlurRadius=11,s.params.saoBlurStdDev=4,s.params.saoBlurDepthCutoff=.0015,t.addPass(s),s},updateSAOPass:function updateSAOPass(e,t){const n=t/2;e.params.saoScale=4*n,e.params.saoKernelRadius=6*n}}}(o),{Picker:l,creaDragger:c,creaRotateHandler:p,creaCorner:h,creaAsse:u}=picker(t),{initHdri:d,setHdri:g,removeHdri:f,disposeHdri:m,refreshScene:y}=function hdri(e,t,n,i){let r,s,o=null,a=null;return{refreshScene:function refreshScene(t,n,r,s,o,a){if(!o)return;if(n.length=0,r.length=0,o.traverse((e=>{e.userData.pickvariant&&n.push(e),e.userData.hideable&&r.push(e),e.isMesh&&(e.castShadow=a,e.receiveShadow=a,e.material?.isMeshStandardMaterial&&null==e.material.envMapIntensity&&(e.material.envMapIntensity=.6),e.layers.enable(0),e.layers.enable(1),e.layers.enable(2),e.layers.enable(9))})),s){const t=(new e.Box3).setFromObject(o);if(!t.isEmpty()){const n=t.getSize(new e.Vector3);i(s,Math.max(n.x,n.y,n.z))}}const A=t?.userData?.dirLight;A&&a&&(A.shadow.needsUpdate=!0)},disposeHdri:function disposeHdri(){r&&(r.dispose(),r=null),s=null},removeHdri:function removeHdri(e){e&&(e.environment=null),o&&(o.dispose(),o=null),a&&(a.dispose(),a=null)},setHdri:async function setHdri(t,i){if(!(t&&i&&r&&s))return;let A;A=n._cdn?`${n._cdn}__/hdr/${t}.ktx2`:n.fullget("mufiles/gethdr",{name:`${t}.ktx2`});const l=await new Promise((t=>{s.load(A,(n=>{n.mapping=e.EquirectangularReflectionMapping,n.colorSpace=e.LinearSRGBColorSpace;const i=r.fromEquirectangular(n),s=i.texture;n.dispose(),t({envMap:s,rt:i})}),void 0,(()=>t(null)))}));l&&(o&&o.dispose(),a&&a.dispose(),o=l.envMap,a=l.rt,i.environment=o,i.backgroundBlurriness=.4)},initHdri:function initHdri(n,i){if(r&&r.dispose(),r=new e.PMREMGenerator(n),r.compileEquirectangularShader(),s||(s=new t,s.setTranscoderPath("/basis/"),s.detectSupport(n)),i){const t=new e.DirectionalLight(16777215,.8);t.position.set(-20,10,20),t.castShadow=!0,t.shadow.mapSize.set(1024,1024),t.shadow.bias=-1e-4,t.shadow.normalBias=.02;const n=20;t.shadow.camera.left=-20,t.shadow.camera.right=n,t.shadow.camera.top=n,t.shadow.camera.bottom=-20,t.shadow.camera.near=.5,t.shadow.camera.far=50,i.add(t);const r=new e.AmbientLight(16777215,.1);i.add(r),i.userData.dirLight=t,i.userData.ambLight=r}}}}(t,s,n,A),{destroyFakeShadow:b,initFakeShadow:I,refreshFakeShadow:x}=function ombraterra(e){return{destroyFakeShadow:function destroyFakeShadow(e){e&&(e.shadowRT?.dispose?.(),e.shadowPlane?.geometry?.dispose?.(),e.shadowPlane?.material?.dispose?.(),e.shadowScene?.traverse((e=>{e.geometry?.dispose?.(),e.material?.dispose?.()})))},initFakeShadow:function initFakeShadow(t){if(!t)return null;const n=(new e.Box3).setFromObject(t),i=new e.Vector3;n.getSize(i);const r=new e.Vector3;n.getCenter(r);const s=new e.OrthographicCamera(-i.x/2,i.x/2,i.z/2,-i.z/2,.001,50);s.position.set(r.x,10,r.z),s.up.set(0,0,-1),s.lookAt(r);const o=new e.WebGLRenderTarget(256,256,{minFilter:e.LinearFilter,magFilter:e.LinearFilter,format:e.RGBAFormat}),a=t.clone(!0);a.traverse((t=>{t.isMesh&&(t.material=new e.MeshBasicMaterial({color:0,transparent:!1}))})),a.scale.y*=-1;const A=(new e.Box3).setFromObject(a);a.position.y-=A.min.y;const l=new e.Scene;l.add(a);const c=new e.PlaneGeometry(1.15*i.x,1.15*i.z),p=new e.Mesh(c,new e.MeshBasicMaterial({map:o.texture,transparent:!0,opacity:.35}));return p.rotation.x=-Math.PI/2,p.position.set(r.x,n.min.y+.001,r.z),p.name="_fakeshadow",p.material=new e.MeshBasicMaterial({map:o.texture,color:0,transparent:!0,opacity:.45,blending:e.MultiplyBlending,depthWrite:!1}),p.material.needsUpdate=!0,a.traverse((t=>{t.isMesh&&(t.material=new e.MeshBasicMaterial({color:0,side:e.DoubleSide,transparent:!1}))})),{shadowPlane:p,shadowRT:o,shadowCam:s,shadowScene:l}},refreshFakeShadow:function refreshFakeShadow(t,{shadowRT:n,shadowCam:i,shadowScene:r}){if(!t||!n)return;r.updateMatrixWorld(!0);const s=new e.Color;t.getClearColor(s);const o=t.getClearAlpha?.()??1;t.setRenderTarget(n),t.setClearColor(16777215,1),t.clear(!0,!0,!0),t.render(r,i),t.setRenderTarget(null),t.setClearColor(s,o)}}}(t),{computebbox:C,zoomatutto:B,resetCameraView:E}=function camera(e,t){function computebbox(t){if(!t)return;const n=new e.Box3;return t.updateWorldMatrix(!0,!0),function visita(e){if(!e.userData?.ignoreTraverse&&!1!==e.visible){(e.isMesh||e.isLine||e.isLine2)&&n.expandByObject(e);for(const t of e.children)visita(t)}}(t),n.isEmpty()?null:n}return{computebbox:computebbox,zoomatutto:function zoomatutto(n,i,r,s=100,o=100,a=void 0){if(!n)return;const A=computebbox(n);if(!A)return;if(A.isEmpty())return;const l=A.getCenter(new e.Vector3),c=A.getSize(new e.Vector3),p=s/o;if(a){const e=Math.max(c.x,c.y,c.z);t(a,e)}if(i.isPerspectiveCamera){let t;const n=e.MathUtils.degToRad(i.fov),s=2*Math.atan(Math.tan(n/2)*p),o=(new e.Vector3).subVectors(i.position,l).normalize(),a=i.up.clone().normalize(),c=(new e.Vector3).crossVectors(o,a).normalize(),h=[new e.Vector3(A.min.x,A.min.y,A.min.z),new e.Vector3(A.min.x,A.min.y,A.max.z),new e.Vector3(A.min.x,A.max.y,A.min.z),new e.Vector3(A.min.x,A.max.y,A.max.z),new e.Vector3(A.max.x,A.min.y,A.min.z),new e.Vector3(A.max.x,A.min.y,A.max.z),new e.Vector3(A.max.x,A.max.y,A.min.z),new e.Vector3(A.max.x,A.max.y,A.max.z)];let u=0,d=1/0,g=-1/0;for(const t of h){const i=(new e.Vector3).subVectors(t,l),r=i.dot(a),A=i.dot(c),p=i.dot(o),h=Math.abs(r)/Math.tan(n/2),f=Math.abs(A)/Math.tan(s/2),m=Math.max(h,f)+Math.abs(p);m>u&&(u=m),p<d&&(d=p),p>g&&(g=p)}t=1*u;const f=.5*Math.max(.001,g-d);i.position.copy(l).addScaledVector(o,t);const m=8;i.near=.01,i.far=Math.max(1,t+1.2*f+m),i.updateProjectionMatrix(),r.minDistance=i.near,r.maxDistance=i.far-4,i.lookAt(l)}else if(i.isOrthographicCamera){let e=1*c.x,t=1*c.y;e/t<p?e=t*p:t=e/p,i.left=-e/2,i.right=e/2,i.top=t/2,i.bottom=-t/2,i.zoom=1,i.updateProjectionMatrix(),i.position.set(l.x,l.y,i.position.z),i.lookAt(l.x,l.y,l.z)}r&&(r.target.copy(l),r.update())},resetCameraView:function resetCameraView(t,n,i,r,s,o="top"){if(!t)return;const a=computebbox(t),A=new e.Vector3,l=new e.Vector3;a.getCenter(A),a.getSize(l);let c,p,h=new e.Vector3,u=new e.Vector3;switch(o){case"top":case"bottom":c=l.x,p=l.z,h.set(A.x,a.max.y+("top"==o?10:-10),A.z),u.set(0,0,"top"==o?-1:1);break;case"front":case"back":c=l.x,p=l.y,h.set(A.x,A.y,a.max.z+("front"==o?10:-10)),u.set(0,1,0);break;case"left":case"right":c=l.z,p=l.y,h.set(a.max.x+("right"==o?10:-10),A.y,A.z),u.set(0,1,0);break;case o.startsWith("angle:")&&o:{const t=parseFloat(o.split(":")[1]);if(isNaN(t))return void console.warn("Angolo non valido:",o);const n=e.MathUtils.degToRad(t+180),i=new e.Vector3(Math.sin(n),0,-Math.cos(n)),r=2*Math.max(l.x,l.y,l.z);h.copy(A).addScaledVector(i,r),u.set(0,1,0),c=l.x,p=l.y;break}default:return void console.warn("Vista non riconosciuta:",o)}const d=r/(1.05*c),g=s/(1.05*p),f=Math.min(d,g),m=r/(2*f),y=s/(2*f);n.left=-m,n.right=m,n.top=y,n.bottom=-y,n.near=.1,n.far=100,n.zoom=1,n.updateProjectionMatrix(),n.position.copy(h),n.up.copy(u),n.lookAt(A),i.object=n,i.target.copy(A),i.update()}}}(t,A),{exportGLB:w}=function exportscene(e,t){return{exportGLB:async function exportGLB(n,i,r={}){if(!n)return;i||(i="scena.glb");const s=new t,o=new e.Layers;o.enable(0),o.enable(1),o.enable(2);const a=function cloneFiltered(e){if(!o.test(e.layers))return null;const t=e.clone(!1);t.userData={};for(let n of e.children){const e=cloneFiltered(n);e&&t.add(e)}return t}(n);if(!a)return;const A={binary:!0,embedImages:!0,onlyVisible:!0,userData:!1,...r};try{const e=await new Promise(((e,t)=>{s.parse(a,e,t,A)})),t=new Blob([e],{type:"application/octet-stream"}),n=URL.createObjectURL(t),r=document.createElement("a");r.href=n,r.download=i,r.click(),URL.revokeObjectURL(n)}catch(e){console.error("Errore durante l’esportazione:",e)}},extractPathTracingScene:function extractPathTracingScene(t){const n=new e.Scene;t.updateMatrixWorld(!0),t.environment&&(n.environment=t.environment);const i=new e.Layers;return i.enable(0),i.enable(1),i.enable(2),t.traverse((t=>{if(i.test(t.layers)&&t.isMesh&&i.test(t.layers)&&(Array.isArray(t.material)?t.material.every((e=>e.isMeshStandardMaterial||e.isMeshPhysicalMaterial)):t.material.isMeshStandardMaterial||t.material.isMeshPhysicalMaterial)){const i=t.geometry.clone(),r=Array.isArray(t.material)?t.material.map((e=>e.clone())):t.material.clone(),s=new e.Mesh(i,r);t.updateWorldMatrix(!0,!1),t.getWorldPosition(s.position),t.getWorldQuaternion(s.quaternion),t.getWorldScale(s.scale),n.add(s)}})),n}}}(t,i);return{createSAOPass:a,updateSAOPass:A,resetCameraView:E,computebbox:C,zoomatutto:B,exportSceneImage:exportSceneImage,exportGLB:w,stati:vt,handleMovimenti:handleMovimenti,handlePick:handlePick,checkhoverables:checkhoverables,Picker:l,creaDragger:c,creaRotateHandler:p,creaCorner:h,creaAsse:u,initHdri:d,setHdri:g,removeHdri:f,disposeHdri:m,refreshScene:y,destroyFakeShadow:b,initFakeShadow:I,refreshFakeShadow:x}}function joinlinestoshapes(e){let t=[];for(let n of e)for(let e of n.lines){let i=new Linea2(e.p1,e.p2);i.rotate(-n.ang),i.move(n.pos.x,n.pos.z),i.valid=!0,t.push(i)}const n=.1;function samepoint(e,t){return Math.abs(e.x-t.x)+Math.abs(e.y-t.y)<n}for(let e=0;e<t.length;e++){if(!t[e].valid)continue;if(t[e].len<n){t[e].valid=!1;continue}const i=t[e];for(let r=e+1;r<t.length;r++){const e=t[r];if(!e.valid)continue;if(!i.isparallela(e))continue;if(!i.isCollineare(e))continue;i.a1b=e.onsegment(i.p1,n),i.a2b=e.onsegment(i.p2,n),i.b1a=i.onsegment(e.p1,n),i.b2a=i.onsegment(e.p2,n);const{x:s,y:o}=i.direzione,{x:a,y:A}=e.direzione;if(s*a+o*A>0)if(i.b1a&&i.b2a)e.valid=!1;else{if(i.a1b&&i.a2b){i.valid=!1;break}if(i.a1b&&i.b2a){let n=new Linea2(e.p1,i.p2);n.valid=!0,t.push(n),i.valid=!1,e.valid=!1;break}if(i.a2b&&i.b1a){let n=new Linea2(i.p1,e.p2);n.valid=!0,t.push(n),i.valid=!1,e.valid=!1;break}}else{const r=i.proiezionet(i.p1).t,s=i.proiezionet(i.p2).t,o=i.proiezionet(e.p1).t,a=i.proiezionet(e.p2).t,A=Math.min(r,s),l=Math.max(r,s),c=Math.min(o,a),p=Math.max(o,a),h=Math.max(A,c),u=Math.min(l,p);if(u>h+n){if(A<h){let e=new Linea2(i.puntot(A),i.puntot(h));e.valid=!0,t.push(e)}if(l>u){let e=new Linea2(i.puntot(l),i.puntot(u));e.valid=!0,t.push(e)}if(c<h){let e=new Linea2(i.puntot(c),i.puntot(h));e.valid=!0,t.push(e)}if(p>u){let e=new Linea2(i.puntot(p),i.puntot(u));e.valid=!0,t.push(e)}i.valid=!1,e.valid=!1;break}}}}t=t.filter((e=>e.valid)).map((e=>getshape().frompt([e.p1,e.p2])));for(let e=0;e<t.length;e++){let n=t[e],i=!0;for(;i;){i=!1;for(let r=e+1;r<t.length;){let e=t[r];samepoint(n.pt[0],e.pt[0])?(e.pt.reverse(),n.pt.unshift(...e.pt.slice(0,-1)),t.splice(r,1),i=!0):samepoint(n.pt[n.pt.length-1],e.pt[e.pt.length-1])?(e.pt.reverse(),n.pt.push(...e.pt.slice(1)),t.splice(r,1),i=!0):samepoint(n.pt[0],e.pt[e.pt.length-1])?(n.pt.unshift(...e.pt.slice(0,-1)),t.splice(r,1),i=!0):samepoint(n.pt[n.pt.length-1],e.pt[0])?(n.pt.push(...e.pt.slice(1)),t.splice(r,1),i=!0):r++}}}return t}function compattaqta(e){let t={};for(let n of e){let e=getdim(n.l,n.a,n.p,n.al,n.aa,n.ap),i=`${n.note}|${e}|${n.vars}`.trim().toLocaleLowerCase();t[i]||(t[i]={note:n.note,vars:n.vars,qt:0,dm:e}),t[i].qt+=n.qt}return Object.values(t)}function getdim(e,t,n,i,r,s,o,a,A){let l,c=[];function getsingledim(e,t,n){return e||(e=t),e=Math.round(10*(e||0))/10,t?"X"==(n=(n||"_").trim().toLowerCase())&&e!=t?e+"*":"M"==n?e+"M":e:e}return l=getsingledim(e,i,o),l&&c.push(l),l=getsingledim(t,r,a),l&&c.push(l),l=getsingledim(n,s,A),l&&c.push(l),c.join("x")}function calcolatotali(e,t){return e.reduce(((e,n)=>(n.qt=n.qt||1,e.tot+=n.qt*(t?n.prc:n.pr)||0,e.area+=n.area*n.qt||0,e.peson+=n.peson*n.qt||0,e.pesol+=n.pesol*n.qt||0,e.volume+=n.volume*n.qt||0,e.perimetro+=n.perimetro*n.qt||0,e.item+=n.qt||1,e)),{tot:0,area:0,perimetro:0,peson:0,pesol:0,volume:0,items:0})}function compattadistinta(e,t){let n=[],i={};if(e&&e.length){for(let t of e)if(["l","x","p"].includes(t.lev)){let e=`${t.cod}|${t.des}`;i[e]||(i[e]={cod:t.cod,des:t.des,rows:[]}),i[e].rows.push(t)}n=Object.values(i).sort(((e,t)=>e.cod.localeCompare(t.cod)));for(let e=0;e<n.length;e++){let i=calcolatotali(n[e].rows,t);n[e].rows=compattaqta(n[e].rows),n[e]={...n[e],...i}}}return n}function checkmovedata(e,t,n){return{l:e((t=(t||"").split(","))[0]),a:e(t[1]),p:e(t[2]),rot:e(t[3]),annulla:e(t[4]),pars:n?.spars||""}}async function valutagrafica(e,t,n,i,r){let{getcolonne:s,muCalc:o,muEval:a,tipifree:A}=e.muvalutatore;n||(n={});for(let n of["l","a","p"]){!e.vari.var(n)&&t.dims&&e.vari.add(n,String(t.dims[n].val||100))}let l=new Set;const c=["sl","sa","sp","ax","ay","az","scx","scy","scz","scale"];let p,h=!1,u=await a(e,t,t.codice,{leveleval:0,checkheader:e=>{let{variante:n}=e;if(Array.isArray(t.head)){let e=t.head.find((e=>e.cod==n));h=!!e}},grafica:async t=>{let r,s,A,l,p,{id:h,pars:u,parametri:d,macro:g,options:f,vari:m}=t,y=!!(g&&g.head&&g.head.length),b={l:e.vari.var("l"),a:e.vari.var("a"),p:e.vari.var("p")};const I=["l","a","p","#d",...c];for(let t of I){let n=e.vari.dictionary[t];n&&(b[t]=n)}async function _parsepars(t,n){let i,a,c=/^#(d|des|descrizione)\s*=\s*(.*)\s*$/im.exec(t);if(c)i="#d",a=await e.vari.valuta(c[2]);else{let e=await m.parametrokeyval(t);i=e.k,a=e.v}i&&!p[i]&&(p[i]=!0,I.includes(i)?"#d"==i?l=a:("string"==typeof a&&(a=o(a)),["l","a","p"].includes(i)&&e.vari.add(i,String(a)),s[i]=a,A=!0):"string"==typeof a?r.push(`${i}=${a}`):e.vari.add(i,a))}let x,C;if(r=[],s={},A=!1,l="",p={},i&&i.keys&&i.keys[h]&&(x=i.keys[h].pars,x))for(let t in x){let n=e.vari.dictionary[t];n&&(b[t]=n),await _parsepars(`${t}=${x[t]}`)}if(u&&u.length)for(const e of u)await _parsepars(e);if(d&&d.length)for(const e of d)await _parsepars(e);if(g&&g.head&&g.head.length){C=g.head.find((e=>"_move"==e.cod));let e=g.head.filter((e=>!["g","p"].includes(e.t)&&"_move"!=e.cod));for(const t of e)await _parsepars(t.cod)}let B={iscad:A,isheader:y,name:g.name,des:l,leveleval:f.leveleval};y&&h&&(B.id=h),A&&(s.l?e.vari.add("l",String(s.l)):s.l=o(e.vari.var("l")),s.a?e.vari.add("a",String(s.a)):s.a=o(e.vari.var("a")),s.p?e.vari.add("p",String(s.p)):s.p=o(e.vari.var("p")),B.cadv=s),await g.impostaparametri(d,r,!0,x);let E=n[h];h&&y&&E&&E.pars&&(B.pars=E.pars,f.leveleval++,await g.setparametri(E.pars));let w=e.vari.var("_rootnode");if(e.vari.add("_rootnode","0"),B.rows=await a(e,g,g.codice,f),e.vari.add("_rootnode",w),h&&y&&(B.spars=g.getparametri()),A){C?B.cadv.move=checkmovedata(o,e.vari.var("_move"),C):delete B.cadv.move;for(let t in b)e.vari.dictionary[t]=b[t]}return B},parsefnpunto:async e=>{let{dati:t,vari:n,id:i,output:r}=e;t=t.trim();let a=t.indexOf(" "),A=t.indexOf(",");A>0&&a>0&&A<a&&(a=A);let p,h,u={},d={};a>1?(p=t.slice(1,a),h=s(t.slice(a+1))):(p=t.slice(1),h=[]),l.has(p)||l.add(p);for(let e of h){let{k:t,v:i}=await n.parametrokeyval(e);t&&/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(t)&&(u[t]=i||"")}for(let e of["l","a","p"])u[e]||(u[e]=n.var(e));let g=Object.keys(u);for(let e of c)g.includes(e)&&(d[e]=o(u[e]),d[e]&&(u[e]=d[e]));r.push({t:"fn",fn:p,id:i,pars:u,p2:d})}});for(let n of["l","a","p"])if(t.dims&&t.dims[n].val!=parseFloat(e.vari.var(n))){p=!0;break}return(h||p&&"function"==typeof r)&&await r(p,h),{oo:u,vari:e.vari.dump(!0),fnlist:[...l]}}function ismacro(e){return"object"==typeof e&&e?.name&&e.rows}function isfn(e){return"object"==typeof e&&"fn"==e?.t}function getnodebyid(e,t){let n;return t&&t.rows&&function _getnode(t){for(let i of t){if(ismacro(i)){if(i.id==e)return void(n=i);i.rows&&_getnode(i.rows)}if(n)return}}(t.rows),n}function getsubrules(e){let t=[];return t.push({id:"",level:0,name:"home"}),function _xfiltrati(e,n){if(e.rows&&e.rows.length)for(let i of e.rows)ismacro(i)&&(i.id&&i.isheader?(t.push({id:i.id,name:i.name,des:i.des||"",spec:i.pars?1:0,level:n}),_xfiltrati(i,n+1)):_xfiltrati(i,n))}(e,1),t}function getdumpmacro(e){let t=[];return function _dumpnodo(e){if(e.rows&&e.rows.length)for(let n of e.rows)if(ismacro(n)){n.name;let e=[];if(n.iscad&&n.cadv)for(let t in n.cadv){let i=n.cadv[t];"number"==typeof i&&i&&e.push(`${t}=${i}`)}if(n.pars)for(let t in n.pars){let i=n.pars[t];e.push(`${t}=${i}`)}e.length&&t.push(`--\x3e ${n.name} ${e.join(",")}`),_dumpnodo(n),e.length&&t.push("<--")}else isfn(n)?t.push(`FN: ${n.fn} ${JSON.stringify(n.pars)}`):"string"==typeof n&&n.length&&t.push(n)}(e),t.join("\n")}function getgalleryvariants(e){let t=[],n=e.keys;function parsespars(e,i,r){if(!e)return;let s=n[i]?.pars;Object.entries(e).forEach((([e,n])=>{["l","a","p","_move"].includes(e)||"string"!=typeof n||(s&&s[e],t.push({id:i||"/",des:r,k:e,v:n,force:0}))}))}return parsespars(e.pars,"","/"),function parserows(e){if(e&&e.length)for(let t of e){if(t.iscad&&t.isheader){let e=t.id;parsespars(t.spars,e,t.des)}t.rows&&t.rows.length&&parserows(t.rows)}}(e.rows),t}async function getdettvarstampa(e,t){let{getcolonne:n,getcouple:i}=e.muvalutatore,r={},s=[];const o="_varstampa";let a=n(t.pars[o])[0];if(a){let A=await e.getvariante(o),l=A?.rows?A.rows[a]?.v:"";if(l&&l[2]&&(s=l[2].split("*"),r[`${o}=${a}`]=["",...l]),s.length){async function saveparsv(t){for(let n in t)if(s.includes(n)){let i=t[n],s=`${n}=${i}`;if(!r[s]){let t=await e.getvariante(n),o=[i];if(t&&t.rows){let e=t.rows[i];e?.v&&(o=e.v)}r[s]=[t?.des||"",...o]}}}if(await saveparsv(t.pars),t.DB&&t.DB.length)for(let c of t.DB)if(c.vars){let p=n(c.vars.trim().toLowerCase()),h={};for(let u of p){let{v:d,o:g}=i(u);d&&g&&(h[d]=g)}await saveparsv(h)}if(t.keys)for(let f in t.keys){let m=t.keys[f];m&&m.pars&&await saveparsv(m.pars)}}}return r}function konvautils(e){function renderizzaSuLayer(t,n,i,{inverse:r=!0,height:s=600,strokescale:o=2,fontsize:a=2,attivo:A=!0,opacita_inattivo:l=.35}={}){if(!i||!i.vec||!i.vec.length)return;"boolean"==typeof i.attivo&&(A=i.attivo);let c,p=!1,h=!0,u=0;if(r){const f=new e.Group({scaleY:-1,y:s});n.add(f),c=f}else h=!1,c=new e.Group;n.add(c),c.opacity(A?1:l);const d=[c];let g=[];function getTesto(t,n,i,r,s,o,a,A){const l=new e.Text({scaleY:r?A?-1:1:A?1:-1,scaleX:i?-1:1,x:0,y:0,text:t,fontSize:6*n,fill:s||"black"}),c=l.width(),p=l.height(),h=function findFreeY(e,t,n,i){let r=t,s=0;for(;g.some((t=>Math.abs(e-t.x)<n&&Math.abs(r-t.y)<i))&&(r-=1.01*i,!(++s>10)););return g.push({x:e,y:r,width:n,height:i}),r}(o,a,c,p);return l.x(o),l.y(h),A||l.offset({x:c/2,y:p/2}),l}for(let m of[0,1]){function drawobjects(n,i){for(const s of n)switch(s.type){case"group":if(i?.[s.name]){let e=i[s.name];e.vec?.length&&++u<20&&(drawobjects(e.vec,e.gr),u--)}break;case"push":{const{op:t}=s;let n={x:s.x||0,y:s.y||0,rotation:s.rot||t.rot||0,scaleX:t.mirrorx?-1:t.scalex||t.scale||1,scaleY:t.mirrory?-1:t.scaley||t.scale||1};n.scaleX<0&&(p=!p),n.scaleY<0&&(h=!h);const i=new e.Group(n);c.add(i),d.push(i),c=i;break}case"pop":if(d.length>1){const e=d.pop();e.getAttr("scaleX")<0&&(p=!p),e.getAttr("scaleY")<0&&(h=!h),c=d[d.length-1]}break;case"img":if(0===m){const{x:n,y:i}=s.l.p1,o=s.l.p2.x-n,a=s.l.p2.y-i;let A=t.get(s.img);if(!A){A=new window.Image,A.src=s.img,t.set(s.img,A);const l=c,p=n,h=i,u=o,d=a,g=r;A.addEventListener("load",(()=>{let t=l.findOne(".img");t?(t.image(A),t.setAttrs({x:p,y:g?h+d:h,width:u,height:d,scaleY:g?-1:1})):l.add(new e.Image({name:"img",x:p,y:g?h+d:h,image:A,width:u,height:d,scaleY:g?-1:1,listening:!1})),l.getLayer().batchDraw()}))}if(A.complete){let t=c.findOne(".img");t?(t.image(A),t.setAttrs({x:n,y:r?i+a:i,width:o,height:a,scaleY:r?-1:1})):c.add(new e.Image({name:"img",x:n,y:r?i+a:i,image:A,width:o,height:a,scaleY:r?-1:1,listening:!1}))}}break;case"line":if(0===m)c.add(new e.Line({points:[s.l.p1.x,s.l.p1.y,s.l.p2.x,s.l.p2.y],stroke:s.color||"black",strokeWidth:(s.spessore||1)*o}));else if(s.id&&-1!=s.id){const e=(s.l.p1.x+s.l.p2.x)/2,t=(s.l.p1.y+s.l.p2.y)/2+6*a;c.add(getTesto(s.id,4*a,p,h,"black",e,t,r))}break;case"rect":case"space":case"recta":if(0===m){const{x:t,y:n}=s.l.p1,i=s.l.p2.x-t,r=s.l.p2.y-n;c.add("space"==s.type?new e.Rect({x:t,y:n,width:i,height:r,stroke:null,fill:null,listening:!1,hitStrokeWidth:0}):new e.Rect({x:t,y:n,width:i,height:r,stroke:"rect"===s.type?s.color||"black":void 0,fill:"recta"===s.type?s.color||"rgba(0,0,255,0.2)":s.fill,strokeWidth:(s.spessore||1)*o}))}break;case"point":if(1===m&&(c.add(new e.Circle({x:s.p.x,y:s.p.y,radius:s.spessore||8,fill:s.color||"black"})),s.id&&-1!=s.id)){const e=4*a;c.add(getTesto(s.id,e,p,h,s.color||"black",s.p.x+2*e,s.p.y+2*e,r))}break;case"shapelin":case"shape":case"area":0===m&&s.s?.length&&c.add(new e.Line({points:s.s.flatMap((e=>[e.x,e.y])),closed:"shapelin"!==s.type,fill:"area"===s.type?s.color||"rgba(0,0,255,0.2)":s.fill,stroke:s.color||"black",strokeWidth:(s.spessore||1)*o}));break;case"text":if(1===m&&s.text){const e=(s.scalafont||1)*a,t=s.color||"black";c.add(testo(s.x,s.y,s.text,e,t,s.fill,p,h))}break;case"quota":{let e=(s.scalafont||1)*a;s.text||(s.text=Math.sqrt((s.x2-s.x1)**2+(s.y2-s.y1)**2).toFixed(1)),c.add(quotalineare(s.x1,s.y1,s.x2,s.y2,s.d,s.text+"",e,s.color,s.spessore,p,h));break}case"qpunto":{let e=(s.scalafont||1)*a;c.add(quotapunto(s.x1,s.y1,s.text,s.d,e,s.color,s.spessore));break}}}drawobjects(i.vec,i.gr)}}function testo(t,n,i,r,s="black",o="white",a,A,l){const c=new e.Group;try{const l=new e.Text({scaleY:A?-1:1,scaleX:a?-1:1,x:t,y:n,text:i,fontSize:6*r,fill:s,align:"center",verticalAlign:"middle",lineHeight:1.2}),p=l.getTextWidth();l.width(p);const h=l.getHeight();l.offsetX(p/2),l.offsetY(h/2),o&&c.add(new e.Rect({x:t,y:n,width:p+8,height:h,fill:o,cornerRadius:4,offsetX:p/2+4,offsetY:h/2,listening:!1,scaleY:A?-1:1,scaleX:a?-1:1})),c.add(l)}catch(e){console.log(e.message)}return c}function quotalineare(t,n,i,r,s,o,a,A="black",l=1,c,p){const h=i-t,u=r-n,d=Math.sqrt(h*h+u*u);if(0===d)return new e.Group;const g=-u/d*s,f=h/d*s,m=[t+g,n+f],y=[i+g,r+f],b=(m[0]+y[0])/2,I=(m[1]+y[1])/2,x=new e.Group;x.add(new e.Line({points:[t,n,t+1.2*g,n+1.2*f],stroke:A,strokeWidth:l})),x.add(new e.Line({points:[i,r,i+1.2*g,r+1.2*f],stroke:A,strokeWidth:l})),x.add(new e.Line({points:[...m,...y],stroke:A,strokeWidth:l}));const C=o.length*a*4,B=6*a,E=180*Math.atan2(u,h)/Math.PI;return x.add(new e.Rect({x:b,y:I,width:C,height:B,fill:"white",offsetX:C/2,offsetY:B/2,rotation:E,listening:!1,scaleY:p?-1:1,scaleX:c?-1:1})),x.add(new e.Text({scaleY:p?-1:1,scaleX:c?-1:1,x:b,y:I,text:o,fontSize:6*a,fill:A,align:"center",verticalAlign:"middle",width:C,height:B,offsetX:C/2,offsetY:B/2,rotation:E})),x}function quotapunto(t,n,i,r,s,o="black",a=1,A,l){const c=t+r,p=n+r,h=new e.Group;return h.add(new e.Line({points:[t,n,c,p],stroke:o,strokeWidth:a})),h.add(new e.Text({x:c,y:p,text:i,fontSize:6*s,fill:o,offsetX:i.length*s*2,offsetY:3*s})),h}return{renderizzaSuLayer:renderizzaSuLayer,saveimg_konva:async function saveimg_konva(t,n,i,r,s,o=10,a=1,A=2){let l=`${t}${i.name}`;const c=document.createElement("div");c.style.position="absolute",c.style.left="-10000px",c.style.top="-10000px",c.style.width=r+"px",c.style.height=s+"px",document.body.appendChild(c),console.log(i);const p=new e.Stage({container:c,width:r,height:s}),h=new e.Layer;p.add(h),renderizzaSuLayer(n,h,i,{height:s,strokescale:a,fontsize:A}),h.draw();const u=h.children[0].getClientRect({skipTransform:!1}),d=(r-2*o)/u.width,g=(s-2*o)/u.height,f=Math.min(d,g),m=-u.x*f+o+(r-u.width*f-2*o)/2,y=-u.y*f+o+(s-u.height*f-2*o)/2;p.scale({x:f,y:f}),p.position({x:m,y:y}),h.draw();const b=p.toDataURL({pixelRatio:1,mimeType:"image/webp",quality:.95});p.destroy(),document.body.removeChild(c);{const e=b.split(","),t=e[0].match(/:(.*?);/)[1],n=atob(e[1]),i=new Uint8Array(n.length);for(let e=0;e<n.length;e++)i[e]=n.charCodeAt(e);return new File([i],`${l}.webp`,{type:t})}}}}var Qt=class Handle{static seed=0;static next(){return(++Handle.seed).toString(16).toUpperCase()}static peek(){return(Handle.seed+1).toString(16).toUpperCase()}};const Pt=Qt;var Tt=class DatabaseObject{constructor(e=null){this.handle=Pt.next(),this.ownerObjectHandle="0",this.subclassMarkers=[],e&&(Array.isArray(e)?this.subclassMarkers.push(...e):this.subclassMarkers.push(e))}tags(e){e.push(5,this.handle),e.push(330,this.ownerObjectHandle);for(const t of this.subclassMarkers)e.push(100,t)}};const St=Tt;var Mt=class LineType extends St{constructor(e,t,n){super(["AcDbSymbolTableRecord","AcDbLinetypeTableRecord"]),this.name=e,this.description=t,this.elements=n}tags(e){e.push(0,"LTYPE"),super.tags(e),e.push(2,this.name),e.push(3,this.description),e.push(70,0),e.push(72,65),e.push(73,this.elements.length),e.push(40,this.getElementsSum()),this.elements.forEach((t=>{e.push(49,t),e.push(74,0)}))}getElementsSum(){return this.elements.reduce(((e,t)=>e+Math.abs(t)),0)}};const Dt=Tt;var Lt=class Layer extends Dt{constructor(e,t,n=null){super(["AcDbSymbolTableRecord","AcDbLayerTableRecord"]),this.name=e,this.colorNumber=t,this.lineTypeName=n,this.shapes=[],this.trueColor=-1}tags(e){e.push(0,"LAYER"),super.tags(e),e.push(2,this.name),-1!==this.trueColor?e.push(420,this.trueColor):e.push(62,this.colorNumber),e.push(70,0),this.lineTypeName&&e.push(6,this.lineTypeName),e.push(390,1)}setTrueColor(e){this.trueColor=e}addShape(e){this.shapes.push(e),e.layer=this}getShapes(){return this.shapes}shapesTags(e,t){for(const n of this.shapes)n.ownerObjectHandle=e.handle,n.tags(t)}};const _t=Tt;var Ft=class Table extends _t{constructor(e){super("AcDbSymbolTable"),this.name=e,this.elements=[]}add(e){e.ownerObjectHandle=this.handle,this.elements.push(e)}tags(e){e.push(0,"TABLE"),e.push(2,this.name),super.tags(e),e.push(70,this.elements.length),this.elements.forEach((t=>{t.tags(e)})),e.push(0,"ENDTAB")}};const kt=Tt,Rt=Ft;var Nt=class DimStyleTable extends Rt{constructor(e){super(e),this.subclassMarkers.push("AcDbDimStyleTable")}tags(e){e.push(0,"TABLE"),e.push(2,this.name),kt.prototype.tags.call(this,e),e.push(70,this.elements.length),e.push(71,1);for(const t of this.elements)t.tags(e);e.push(0,"ENDTAB")}};const Ot=Tt;var Gt=class TextStyle extends Ot{fontFileName="txt";constructor(e){super(["AcDbSymbolTableRecord","AcDbTextStyleTableRecord"]),this.name=e}tags(e){e.push(0,"STYLE"),super.tags(e),e.push(2,this.name),e.push(70,0),e.push(40,0),e.push(41,1),e.push(50,0),e.push(71,0),e.push(42,1),e.push(3,this.fontFileName),e.push(4,"")}};const Ut=Tt;var Yt=class Viewport extends Ut{constructor(e,t){super(["AcDbSymbolTableRecord","AcDbViewportTableRecord"]),this.name=e,this.height=t}tags(e){e.push(0,"VPORT"),super.tags(e),e.push(2,this.name),e.push(40,this.height),e.push(70,0)}};const zt=Tt;var Ht=class AppId extends zt{constructor(e){super(["AcDbSymbolTableRecord","AcDbRegAppTableRecord"]),this.name=e}tags(e){e.push(0,"APPID"),super.tags(e),e.push(2,this.name),e.push(70,0)}};const Xt=Tt;var qt=class Block extends Xt{constructor(e){super(["AcDbEntity","AcDbBlockBegin"]),this.name=e,this.end=new Xt(["AcDbEntity","AcDbBlockEnd"]),this.recordHandle=null}tags(e){e.push(0,"BLOCK"),super.tags(e),e.push(2,this.name),e.push(70,0),e.point(0,0),e.push(3,this.name),e.push(1,""),e.push(0,"ENDBLK"),this.end.tags(e)}};const jt=Tt;var Wt=class BlockRecord extends jt{constructor(e){super(["AcDbSymbolTableRecord","AcDbBlockTableRecord"]),this.name=e}tags(e){e.push(0,"BLOCK_RECORD"),super.tags(e),e.push(2,this.name),e.push(70,0),e.push(280,0),e.push(281,1)}};const Jt=Tt;var Vt=class Dictionary extends Jt{constructor(){super("AcDbDictionary"),this.children={}}addChildDictionary(e,t){t.ownerObjectHandle=this.handle,this.children[e]=t}tags(e){e.push(0,"DICTIONARY"),super.tags(e),e.push(281,1);const t=Object.entries(this.children);for(const n of t){const[t,i]=n;e.push(3,t),e.push(350,i.handle)}const n=Object.values(this.children);for(const t of n)t.tags(e)}};const Kt=Tt;var Zt=class Line extends Kt{constructor(e,t,n,i){super(["AcDbEntity","AcDbLine"]),this.x1=e,this.y1=t,this.x2=n,this.y2=i}tags(e){e.push(0,"LINE"),super.tags(e),e.push(8,this.layer.name),e.point(this.x1,this.y1),e.push(11,this.x2),e.push(21,this.y2),e.push(31,0)}};const $t=Tt;var en=class Line3d extends $t{constructor(e,t,n,i,r,s){super(["AcDbEntity","AcDbLine"]),this.x1=e,this.y1=t,this.z1=n,this.x2=i,this.y2=r,this.z2=s}tags(e){e.push(0,"LINE"),super.tags(e),e.push(8,this.layer.name),e.point(this.x1,this.y1,this.z1),e.push(11,this.x2),e.push(21,this.y2),e.push(31,this.z2)}};const tn=Tt;var nn=class Arc extends tn{constructor(e,t,n,i,r){super(["AcDbEntity","AcDbCircle"]),this.x=e,this.y=t,this.r=n,this.startAngle=i,this.endAngle=r}tags(e){e.push(0,"ARC"),super.tags(e),e.push(8,this.layer.name),e.point(this.x,this.y),e.push(40,this.r),e.push(100,"AcDbArc"),e.push(50,this.startAngle),e.push(51,this.endAngle)}};const rn=Tt;var sn=class Circle extends rn{constructor(e,t,n){super(["AcDbEntity","AcDbCircle"]),this.x=e,this.y=t,this.r=n}tags(e){e.push(0,"CIRCLE"),super.tags(e),e.push(8,this.layer.name),e.point(this.x,this.y),e.push(40,this.r)}};const on=Tt;var an=class Cylinder extends on{constructor(e,t,n,i,r,s,o,a){super(["AcDbEntity","AcDbCircle"]),this.x=e,this.y=t,this.z=n,this.r=i,this.thickness=r,this.extrusionDirectionX=s,this.extrusionDirectionY=o,this.extrusionDirectionZ=a}tags(e){e.push(0,"CIRCLE"),super.tags(e),e.push(8,this.layer.name),e.point(this.x,this.y,this.z),e.push(40,this.r),e.push(39,this.thickness),e.push(210,this.extrusionDirectionX),e.push(220,this.extrusionDirectionY),e.push(230,this.extrusionDirectionZ)}};const An=Tt,ln=["left","center","right"],cn=["baseline","bottom","middle","top"];var pn=class Text extends An{constructor(e,t,n,i,r,s="left",o="baseline"){super(["AcDbEntity","AcDbText"]),this.x=e,this.y=t,this.height=n,this.rotation=i,this.value=r,this.hAlign=s,this.vAlign=o}tags(e){e.push(0,"TEXT"),super.tags(e),e.push(8,this.layer.name),e.point(this.x,this.y),e.push(40,this.height),e.push(1,this.value),e.push(50,this.rotation),ln.includes(this.hAlign,1)||cn.includes(this.vAlign,1)?(e.push(72,Math.max(ln.indexOf(this.hAlign),0)),e.push(11,this.x),e.push(21,this.y),e.push(31,0),e.push(100,"AcDbText"),e.push(73,Math.max(cn.indexOf(this.vAlign),0))):e.push(100,"AcDbText")}};const hn=Tt;var un=class Polyline extends hn{constructor(e,t=!1,n=0,i=0){super(["AcDbEntity","AcDbPolyline"]),this.points=e,this.closed=t,this.startWidth=n,this.endWidth=i}tags(e){e.push(0,"LWPOLYLINE"),super.tags(e),e.push(8,this.layer.name),e.push(6,"ByLayer"),e.push(62,256),e.push(370,-1),e.push(90,this.points.length),e.push(70,this.closed?1:0),this.points.forEach((t=>{const[n,i,r]=t;e.push(10,n),e.push(20,i),0===this.startWidth&&0===this.endWidth||(e.push(40,this.startWidth),e.push(41,this.endWidth)),void 0!==r&&e.push(42,r)}))}};const dn=Tt;var gn=class Vertex extends dn{constructor(e,t,n){super(["AcDbEntity","AcDbVertex","AcDb3dPolylineVertex"]),this.x=e,this.y=t,this.z=n}tags(e){e.push(0,"VERTEX"),super.tags(e),e.push(8,this.layer.name),e.point(this.x,this.y,this.z),e.push(70,32)}};const fn=Tt,mn=Qt,yn=gn;var bn=class Polyline3d extends fn{constructor(e){super(["AcDbEntity","AcDb3dPolyline"]),this.verticies=e.map((e=>{const[t,n,i]=e,r=new yn(t,n,i);return r.ownerObjectHandle=this.handle,r})),this.seqendHandle=mn.next()}tags(e){e.push(0,"POLYLINE"),super.tags(e),e.push(8,this.layer.name),e.push(66,1),e.push(70,0),e.point(0,0),this.verticies.forEach((t=>{t.layer=this.layer,t.tags(e)})),e.push(0,"SEQEND"),e.push(5,this.seqendHandle),e.push(100,"AcDbEntity"),e.push(8,this.layer.name)}};const In=Tt;var xn=class Face extends In{constructor(e,t,n,i,r,s,o,a,A,l,c,p){super(["AcDbEntity","AcDbFace"]),this.x1=e,this.y1=t,this.z1=n,this.x2=i,this.y2=r,this.z2=s,this.x3=o,this.y3=a,this.z3=A,this.x4=l,this.y4=c,this.z4=p}tags(e){e.push(0,"3DFACE"),super.tags(e),e.push(8,this.layer.name),e.point(this.x1,this.y1,this.z1),e.push(11,this.x2),e.push(21,this.y2),e.push(31,this.z2),e.push(12,this.x3),e.push(22,this.y3),e.push(32,this.z3),e.push(13,this.x4),e.push(23,this.y4),e.push(33,this.z4)}};const Cn=Tt;var Bn=class Point extends Cn{constructor(e,t){super(["AcDbEntity","AcDbPoint"]),this.x=e,this.y=t}tags(e){e.push(0,"POINT"),super.tags(e),e.push(8,this.layer.name),e.point(this.x,this.y)}};const En=Tt;var wn=class Spline extends En{constructor(e,t=3,n=null,i=null,r=[]){if(super(["AcDbEntity","AcDbSpline"]),e.length<t+1)throw new Error(`For degree ${t} spline, expected at least ${t+1} control points, but received only ${e.length}`);if(null==n){n=[];for(let e=0;e<t+1;e++)n.push(0);for(let i=1;i<e.length-t;i++)n.push(i);for(let i=0;i<t+1;i++)n.push(e.length-t)}if(n.length!==e.length+t+1)throw new Error(`Invalid knot vector length. Expected ${e.length+t+1} but received ${n.length}.`);this.controlPoints=e,this.knots=n,this.fitPoints=r,this.degree=t,this.weights=i;const s=this.weights?1:0;this.type=0+4*s+8+0}tags(e){e.push(0,"SPLINE"),super.tags(e),e.push(8,this.layer.name),e.push(210,0),e.push(220,0),e.push(230,1),e.push(70,this.type),e.push(71,this.degree),e.push(72,this.knots.length),e.push(73,this.controlPoints.length),e.push(74,this.fitPoints.length),e.push(42,1e-7),e.push(43,1e-7),e.push(44,1e-10),this.knots.forEach((t=>{e.push(40,t)})),this.weights&&this.weights.forEach((t=>{e.push(41,t)})),this.controlPoints.forEach((t=>{e.point(t[0],t[1])}))}};const vn=Tt;var Qn=class Ellipse extends vn{constructor(e,t,n,i,r,s,o){super(["AcDbEntity","AcDbEllipse"]),this.x=e,this.y=t,this.majorAxisX=n,this.majorAxisY=i,this.axisRatio=r,this.startAngle=s,this.endAngle=o}tags(e){e.push(0,"ELLIPSE"),super.tags(e),e.push(8,this.layer.name),e.point(this.x,this.y),e.push(11,this.majorAxisX),e.push(21,this.majorAxisY),e.push(31,0),e.push(40,this.axisRatio),e.push(41,this.startAngle),e.push(42,this.endAngle)}};var Pn=class TagsManager{constructor(){this.lines=[]}point(e,t,n=0){this.push(10,e),this.push(20,t),this.push(30,n)}start(e){this.push(0,"SECTION"),this.push(2,e)}end(){this.push(0,"ENDSEC")}addHeaderVariable(e,t){this.push(9,`$${e}`),t.forEach((e=>{this.push(e[0],e[1])}))}push(e,t){this.lines.push(e,t)}toDxfString(){return this.lines.join("\n")}};const Tn=Mt,Sn=Lt,Mn=Ft,Dn=Nt,Ln=Gt,_n=Yt,Fn=Ht,kn=qt,Rn=Wt,Nn=Vt,On=Zt,Gn=en,Un=nn,Yn=sn,zn=an,Hn=pn,Xn=un,qn=bn,jn=xn,Wn=Bn,Jn=wn,Vn=Qn,Kn=Pn,Zn=Qt;class Drawing{constructor(){this.layers={},this.activeLayer=null,this.lineTypes={},this.headers={},this.tables={},this.blocks={},this.dictionary=new Nn,this.setUnits("Unitless");for(const e of Drawing.LINE_TYPES)this.addLineType(e.name,e.description,e.elements);for(const e of Drawing.LAYERS)this.addLayer(e.name,e.colorNumber,e.lineTypeName);this.setActiveLayer("0"),this.generateAutocadExtras()}addLineType(e,t,n){return this.lineTypes[e]=new Tn(e,t,n),this}addLayer(e,t,n){return this.layers[e]=new Sn(e,t,n),this}setActiveLayer(e){return this.activeLayer=this.layers[e],this}addTable(e){const t=new Mn(e);return this.tables[e]=t,t}addBlock(e){const t=new kn(e);return this.blocks[e]=t,t}drawLine(e,t,n,i){return this.activeLayer.addShape(new On(e,t,n,i)),this}drawLine3d(e,t,n,i,r,s){return this.activeLayer.addShape(new Gn(e,t,n,i,r,s)),this}drawPoint(e,t){return this.activeLayer.addShape(new Wn(e,t)),this}drawRect(e,t,n,i,r,s){const o=n-e,a=i-t;s=s||0;let A=null;return A=new Xn(r?[[e+o-r,t,s],[e+o,t+r],[e+o,t+a-r,s],[e+o-r,t+a],[e+r,t+a,s],[e,t+a-r],[e,t+r,s],[e+r,t]]:[[e,t],[e,t+a],[e+o,t+a],[e+o,t]],!0),this.activeLayer.addShape(A),this}drawPolygon(e,t,n,i,r=0,s=!1){const o=2*Math.PI/n,a=[];let A=i;const l=r*Math.PI/180;s&&(A=i/Math.cos(Math.PI/n));for(let i=0;i<n;i++)a.push([e+A*Math.sin(l+i*o),t+A*Math.cos(l+i*o)]);return this.activeLayer.addShape(new Xn(a,!0)),this}drawArc(e,t,n,i,r){return this.activeLayer.addShape(new Un(e,t,n,i,r)),this}drawCircle(e,t,n){return this.activeLayer.addShape(new Yn(e,t,n)),this}drawCylinder(e,t,n,i,r,s,o,a){return this.activeLayer.addShape(new zn(e,t,n,i,r,s,o,a)),this}drawText(e,t,n,i,r,s="left",o="baseline"){return this.activeLayer.addShape(new Hn(e,t,n,i,r,s,o)),this}drawPolyline(e,t=!1,n=0,i=0){return this.activeLayer.addShape(new Xn(e,t,n,i)),this}drawPolyline3d(e){return e.forEach((e=>{if(3!==e.length)throw"Require 3D coordinates"})),this.activeLayer.addShape(new qn(e)),this}setTrueColor(e){return this.activeLayer.setTrueColor(e),this}drawSpline(e,t=3,n=null,i=null,r=[]){return this.activeLayer.addShape(new Jn(e,t,n,i,r)),this}drawEllipse(e,t,n,i,r,s=0,o=2*Math.PI){return this.activeLayer.addShape(new Vn(e,t,n,i,r,s,o)),this}drawFace(e,t,n,i,r,s,o,a,A,l,c,p){return this.activeLayer.addShape(new jn(e,t,n,i,r,s,o,a,A,l,c,p)),this}_ltypeTable(){const e=new Mn("LTYPE"),t=Object.values(this.lineTypes);for(const n of t)e.add(n);return e}_layerTable(e){const t=new Mn("LAYER"),n=Object.values(this.layers);for(const e of n)t.add(e);return t}header(e,t){return this.headers[e]=t,this}setUnits(e){return void 0!==Drawing.UNITS[e]?Drawing.UNITS[e]:Drawing.UNITS.Unitless,this.header("INSUNITS",[[70,Drawing.UNITS[e]]]),this}generateAutocadExtras(){this.headers.ACADVER||this.header("ACADVER",[[1,"AC1021"]]),this.lineTypes.ByBlock||this.addLineType("ByBlock","",[]),this.lineTypes.ByLayer||this.addLineType("ByLayer","",[]);let e=this.tables.VPORT;e||(e=this.addTable("VPORT"));let t=this.tables.STYLE;t||(t=this.addTable("STYLE")),this.tables.VIEW||this.addTable("VIEW"),this.tables.UCS||this.addTable("UCS");let n=this.tables.APPID;if(n||(n=this.addTable("APPID")),!this.tables.DIMSTYLE){const e=new Dn("DIMSTYLE");this.tables.DIMSTYLE=e}e.add(new _n("*ACTIVE",1e3)),t.add(new Ln("standard")),n.add(new Fn("ACAD")),this.modelSpace=this.addBlock("*Model_Space"),this.addBlock("*Paper_Space");const i=new Nn;this.dictionary.addChildDictionary("ACAD_GROUP",i)}_tagsManager(){const e=new Kn,t=new Mn("BLOCK_RECORD"),n=Object.values(this.blocks);for(const e of n){const n=new Rn(e.name);t.add(n)}const i=this._ltypeTable(),r=this._layerTable();e.start("HEADER"),e.addHeaderVariable("HANDSEED",[[5,Zn.peek()]]);const s=Object.entries(this.headers);for(const t of s){const[n,i]=t;e.addHeaderVariable(n,i)}e.end(),e.start("CLASSES"),e.end(),e.start("TABLES"),i.tags(e),r.tags(e);const o=Object.values(this.tables);for(const t of o)t.tags(e);t.tags(e),e.end(),e.start("BLOCKS");for(const t of n)t.tags(e);e.end(),e.start("ENTITIES");const a=Object.values(this.layers);for(const t of a)t.shapesTags(this.modelSpace,e);return e.end(),e.start("OBJECTS"),this.dictionary.tags(e),e.end(),e.push(0,"EOF"),e}toDxfString(){return this._tagsManager().toDxfString()}}Drawing.ACI={LAYER:0,RED:1,YELLOW:2,GREEN:3,CYAN:4,BLUE:5,MAGENTA:6,WHITE:7},Drawing.LINE_TYPES=[{name:"CONTINUOUS",description:"______",elements:[]},{name:"DASHED",description:"_ _ _ ",elements:[5,-5]},{name:"DOTTED",description:". . . ",elements:[0,-5]}],Drawing.LAYERS=[{name:"0",colorNumber:Drawing.ACI.WHITE,lineTypeName:"CONTINUOUS"}],Drawing.UNITS={Unitless:0,Inches:1,Feet:2,Miles:3,Millimeters:4,Centimeters:5,Meters:6,Kilometers:7,Microinches:8,Mils:9,Yards:10,Angstroms:11,Nanometers:12,Microns:13,Decimeters:14,Decameters:15,Hectometers:16,Gigameters:17,"Astronomical units":18,"Light years":19,Parsecs:20};var $n=getDefaultExportFromCjs(Drawing);const ei={black:[0,0,0],white:[255,255,255],red:[255,0,0],green:[0,255,0],blue:[0,0,255],yellow:[255,255,0],cyan:[0,255,255],magenta:[255,0,255],gray:[128,128,128],grey:[128,128,128]},ti={};function col2aci(e){if(!e)return 0;if("number"==typeof e)return e;const t=e.trim().toLowerCase();if(ti[t])return ti[t];if(ei[t]){const[e,n,i]=ei[t];return ti[t]=rgb2aci(e,n,i)}if(t.startsWith("#")){let e=t;4===e.length&&(e="#"+e[1]+e[1]+e[2]+e[2]+e[3]+e[3]);const n=parseInt(e.slice(1,3),16),i=parseInt(e.slice(3,5),16),r=parseInt(e.slice(5,7),16);return ti[t]=rgb2aci(n,i,r)}if(t.startsWith("rgb")){const e=t.match(/\d+/g).map(Number);return ti[t]=rgb2aci(e[0],e[1],e[2])}return ti[t]=0}function rgb2aci(e,t,n){return Math.abs(e-t)<10&&Math.abs(t-n)<10?8:e>t&&e>n?1:t>e&&t>n?3:n>e&&n>t?5:e>200&&t>200?2:t>200&&n>200?4:e>200&&n>200?6:7}function exportdxf(e){const t=new $n,n=new Matrix3D;for(const i of e.vec)switch(i.type){case"push":n.push(),(i.x||i.y)&&n.translate(i.x||0,i.y||0,0),i.rot&&n.rotateZ(i.rot);break;case"pop":n.pop();break;case"offset":n.translate(i.x||0,i.y||0,0);break;case"point":{const e=n.transform(i.p.x,i.p.y,0),r=col2aci(i.color);t.setActiveLayer("0",r),t.drawPoint(e.x,e.y),i.id&&t.drawText(e.x+2,e.y+2,6,0,i.id);break}case"line":{const e=n.transform(i.l.p1.x,i.l.p1.y,0),r=n.transform(i.l.p2.x,i.l.p2.y,0),s=col2aci(i.color);if(t.setActiveLayer("0",s),t.drawLine(e.x,e.y,r.x,r.y),i.id){const n=(e.x+r.x)/2,s=(e.y+r.y)/2;t.drawText(n,s,6,0,i.id)}break}case"rect":case"recta":{const e=n.transform(i.l.p1.x,i.l.p1.y,0),r=n.transform(i.l.p2.x,i.l.p2.y,0),s=col2aci(i.color);t.setActiveLayer("0",s);const o="recta"===i.type;t.drawPolyline([[e.x,e.y],[r.x,e.y],[r.x,r.y],[e.x,r.y]],o);break}case"shape":case"shapelin":case"area":{if(!i.s?.length)break;const e=i.s.map((e=>{const t=n.transform(e.x,e.y,0);return[t.x,t.y]})),r="shapelin"!==i.type,s=col2aci(i.color);t.setActiveLayer("0",s),t.drawPolyline(e,r);break}case"text":{const e=col2aci(i.color);t.setActiveLayer("0",e);const r=n.transform(i.x||0,i.y||0,0),s=6*(i.scalafont||1);t.drawText(r.x,r.y,s,0,i.text);break}}return t.toDxfString()}s.line={worldUnits:{value:1},linewidth:{value:1},resolution:{value:new r(1,1)},dashOffset:{value:0},dashScale:{value:1},dashSize:{value:1},gapSize:{value:1}},n.line={uniforms:i.merge([s.common,s.fog,s.line]),vertexShader:"\n\t\t#include <common>\n\t\t#include <color_pars_vertex>\n\t\t#include <fog_pars_vertex>\n\t\t#include <logdepthbuf_pars_vertex>\n\t\t#include <clipping_planes_pars_vertex>\n\n\t\tuniform float linewidth;\n\t\tuniform vec2 resolution;\n\n\t\tattribute vec3 instanceStart;\n\t\tattribute vec3 instanceEnd;\n\n\t\tattribute vec3 instanceColorStart;\n\t\tattribute vec3 instanceColorEnd;\n\n\t\t#ifdef WORLD_UNITS\n\n\t\t\tvarying vec4 worldPos;\n\t\t\tvarying vec3 worldStart;\n\t\t\tvarying vec3 worldEnd;\n\n\t\t\t#ifdef USE_DASH\n\n\t\t\t\tvarying vec2 vUv;\n\n\t\t\t#endif\n\n\t\t#else\n\n\t\t\tvarying vec2 vUv;\n\n\t\t#endif\n\n\t\t#ifdef USE_DASH\n\n\t\t\tuniform float dashScale;\n\t\t\tattribute float instanceDistanceStart;\n\t\t\tattribute float instanceDistanceEnd;\n\t\t\tvarying float vLineDistance;\n\n\t\t#endif\n\n\t\tvoid trimSegment( const in vec4 start, inout vec4 end ) {\n\n\t\t\t// trim end segment so it terminates between the camera plane and the near plane\n\n\t\t\t// conservative estimate of the near plane\n\t\t\tfloat a = projectionMatrix[ 2 ][ 2 ]; // 3nd entry in 3th column\n\t\t\tfloat b = projectionMatrix[ 3 ][ 2 ]; // 3nd entry in 4th column\n\t\t\tfloat nearEstimate = - 0.5 * b / a;\n\n\t\t\tfloat alpha = ( nearEstimate - start.z ) / ( end.z - start.z );\n\n\t\t\tend.xyz = mix( start.xyz, end.xyz, alpha );\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\t#ifdef USE_COLOR\n\n\t\t\t\tvColor.xyz = ( position.y < 0.5 ) ? instanceColorStart : instanceColorEnd;\n\n\t\t\t#endif\n\n\t\t\t#ifdef USE_DASH\n\n\t\t\t\tvLineDistance = ( position.y < 0.5 ) ? dashScale * instanceDistanceStart : dashScale * instanceDistanceEnd;\n\t\t\t\tvUv = uv;\n\n\t\t\t#endif\n\n\t\t\tfloat aspect = resolution.x / resolution.y;\n\n\t\t\t// camera space\n\t\t\tvec4 start = modelViewMatrix * vec4( instanceStart, 1.0 );\n\t\t\tvec4 end = modelViewMatrix * vec4( instanceEnd, 1.0 );\n\n\t\t\t#ifdef WORLD_UNITS\n\n\t\t\t\tworldStart = start.xyz;\n\t\t\t\tworldEnd = end.xyz;\n\n\t\t\t#else\n\n\t\t\t\tvUv = uv;\n\n\t\t\t#endif\n\n\t\t\t// special case for perspective projection, and segments that terminate either in, or behind, the camera plane\n\t\t\t// clearly the gpu firmware has a way of addressing this issue when projecting into ndc space\n\t\t\t// but we need to perform ndc-space calculations in the shader, so we must address this issue directly\n\t\t\t// perhaps there is a more elegant solution -- WestLangley\n\n\t\t\tbool perspective = ( projectionMatrix[ 2 ][ 3 ] == - 1.0 ); // 4th entry in the 3rd column\n\n\t\t\tif ( perspective ) {\n\n\t\t\t\tif ( start.z < 0.0 && end.z >= 0.0 ) {\n\n\t\t\t\t\ttrimSegment( start, end );\n\n\t\t\t\t} else if ( end.z < 0.0 && start.z >= 0.0 ) {\n\n\t\t\t\t\ttrimSegment( end, start );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\t// clip space\n\t\t\tvec4 clipStart = projectionMatrix * start;\n\t\t\tvec4 clipEnd = projectionMatrix * end;\n\n\t\t\t// ndc space\n\t\t\tvec3 ndcStart = clipStart.xyz / clipStart.w;\n\t\t\tvec3 ndcEnd = clipEnd.xyz / clipEnd.w;\n\n\t\t\t// direction\n\t\t\tvec2 dir = ndcEnd.xy - ndcStart.xy;\n\n\t\t\t// account for clip-space aspect ratio\n\t\t\tdir.x *= aspect;\n\t\t\tdir = normalize( dir );\n\n\t\t\t#ifdef WORLD_UNITS\n\n\t\t\t\tvec3 worldDir = normalize( end.xyz - start.xyz );\n\t\t\t\tvec3 tmpFwd = normalize( mix( start.xyz, end.xyz, 0.5 ) );\n\t\t\t\tvec3 worldUp = normalize( cross( worldDir, tmpFwd ) );\n\t\t\t\tvec3 worldFwd = cross( worldDir, worldUp );\n\t\t\t\tworldPos = position.y < 0.5 ? start: end;\n\n\t\t\t\t// height offset\n\t\t\t\tfloat hw = linewidth * 0.5;\n\t\t\t\tworldPos.xyz += position.x < 0.0 ? hw * worldUp : - hw * worldUp;\n\n\t\t\t\t// don't extend the line if we're rendering dashes because we\n\t\t\t\t// won't be rendering the endcaps\n\t\t\t\t#ifndef USE_DASH\n\n\t\t\t\t\t// cap extension\n\t\t\t\t\tworldPos.xyz += position.y < 0.5 ? - hw * worldDir : hw * worldDir;\n\n\t\t\t\t\t// add width to the box\n\t\t\t\t\tworldPos.xyz += worldFwd * hw;\n\n\t\t\t\t\t// endcaps\n\t\t\t\t\tif ( position.y > 1.0 || position.y < 0.0 ) {\n\n\t\t\t\t\t\tworldPos.xyz -= worldFwd * 2.0 * hw;\n\n\t\t\t\t\t}\n\n\t\t\t\t#endif\n\n\t\t\t\t// project the worldpos\n\t\t\t\tvec4 clip = projectionMatrix * worldPos;\n\n\t\t\t\t// shift the depth of the projected points so the line\n\t\t\t\t// segments overlap neatly\n\t\t\t\tvec3 clipPose = ( position.y < 0.5 ) ? ndcStart : ndcEnd;\n\t\t\t\tclip.z = clipPose.z * clip.w;\n\n\t\t\t#else\n\n\t\t\t\tvec2 offset = vec2( dir.y, - dir.x );\n\t\t\t\t// undo aspect ratio adjustment\n\t\t\t\tdir.x /= aspect;\n\t\t\t\toffset.x /= aspect;\n\n\t\t\t\t// sign flip\n\t\t\t\tif ( position.x < 0.0 ) offset *= - 1.0;\n\n\t\t\t\t// endcaps\n\t\t\t\tif ( position.y < 0.0 ) {\n\n\t\t\t\t\toffset += - dir;\n\n\t\t\t\t} else if ( position.y > 1.0 ) {\n\n\t\t\t\t\toffset += dir;\n\n\t\t\t\t}\n\n\t\t\t\t// adjust for linewidth\n\t\t\t\toffset *= linewidth;\n\n\t\t\t\t// adjust for clip-space to screen-space conversion // maybe resolution should be based on viewport ...\n\t\t\t\toffset /= resolution.y;\n\n\t\t\t\t// select end\n\t\t\t\tvec4 clip = ( position.y < 0.5 ) ? clipStart : clipEnd;\n\n\t\t\t\t// back to clip space\n\t\t\t\toffset *= clip.w;\n\n\t\t\t\tclip.xy += offset;\n\n\t\t\t#endif\n\n\t\t\tgl_Position = clip;\n\n\t\t\tvec4 mvPosition = ( position.y < 0.5 ) ? start : end; // this is an approximation\n\n\t\t\t#include <logdepthbuf_vertex>\n\t\t\t#include <clipping_planes_vertex>\n\t\t\t#include <fog_vertex>\n\n\t\t}\n\t\t",fragmentShader:"\n\t\tuniform vec3 diffuse;\n\t\tuniform float opacity;\n\t\tuniform float linewidth;\n\n\t\t#ifdef USE_DASH\n\n\t\t\tuniform float dashOffset;\n\t\t\tuniform float dashSize;\n\t\t\tuniform float gapSize;\n\n\t\t#endif\n\n\t\tvarying float vLineDistance;\n\n\t\t#ifdef WORLD_UNITS\n\n\t\t\tvarying vec4 worldPos;\n\t\t\tvarying vec3 worldStart;\n\t\t\tvarying vec3 worldEnd;\n\n\t\t\t#ifdef USE_DASH\n\n\t\t\t\tvarying vec2 vUv;\n\n\t\t\t#endif\n\n\t\t#else\n\n\t\t\tvarying vec2 vUv;\n\n\t\t#endif\n\n\t\t#include <common>\n\t\t#include <color_pars_fragment>\n\t\t#include <fog_pars_fragment>\n\t\t#include <logdepthbuf_pars_fragment>\n\t\t#include <clipping_planes_pars_fragment>\n\n\t\tvec2 closestLineToLine(vec3 p1, vec3 p2, vec3 p3, vec3 p4) {\n\n\t\t\tfloat mua;\n\t\t\tfloat mub;\n\n\t\t\tvec3 p13 = p1 - p3;\n\t\t\tvec3 p43 = p4 - p3;\n\n\t\t\tvec3 p21 = p2 - p1;\n\n\t\t\tfloat d1343 = dot( p13, p43 );\n\t\t\tfloat d4321 = dot( p43, p21 );\n\t\t\tfloat d1321 = dot( p13, p21 );\n\t\t\tfloat d4343 = dot( p43, p43 );\n\t\t\tfloat d2121 = dot( p21, p21 );\n\n\t\t\tfloat denom = d2121 * d4343 - d4321 * d4321;\n\n\t\t\tfloat numer = d1343 * d4321 - d1321 * d4343;\n\n\t\t\tmua = numer / denom;\n\t\t\tmua = clamp( mua, 0.0, 1.0 );\n\t\t\tmub = ( d1343 + d4321 * ( mua ) ) / d4343;\n\t\t\tmub = clamp( mub, 0.0, 1.0 );\n\n\t\t\treturn vec2( mua, mub );\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tfloat alpha = opacity;\n\t\t\tvec4 diffuseColor = vec4( diffuse, alpha );\n\n\t\t\t#include <clipping_planes_fragment>\n\n\t\t\t#ifdef USE_DASH\n\n\t\t\t\tif ( vUv.y < - 1.0 || vUv.y > 1.0 ) discard; // discard endcaps\n\n\t\t\t\tif ( mod( vLineDistance + dashOffset, dashSize + gapSize ) > dashSize ) discard; // todo - FIX\n\n\t\t\t#endif\n\n\t\t\t#ifdef WORLD_UNITS\n\n\t\t\t\t// Find the closest points on the view ray and the line segment\n\t\t\t\tvec3 rayEnd = normalize( worldPos.xyz ) * 1e5;\n\t\t\t\tvec3 lineDir = worldEnd - worldStart;\n\t\t\t\tvec2 params = closestLineToLine( worldStart, worldEnd, vec3( 0.0, 0.0, 0.0 ), rayEnd );\n\n\t\t\t\tvec3 p1 = worldStart + lineDir * params.x;\n\t\t\t\tvec3 p2 = rayEnd * params.y;\n\t\t\t\tvec3 delta = p1 - p2;\n\t\t\t\tfloat len = length( delta );\n\t\t\t\tfloat norm = len / linewidth;\n\n\t\t\t\t#ifndef USE_DASH\n\n\t\t\t\t\t#ifdef USE_ALPHA_TO_COVERAGE\n\n\t\t\t\t\t\tfloat dnorm = fwidth( norm );\n\t\t\t\t\t\talpha = 1.0 - smoothstep( 0.5 - dnorm, 0.5 + dnorm, norm );\n\n\t\t\t\t\t#else\n\n\t\t\t\t\t\tif ( norm > 0.5 ) {\n\n\t\t\t\t\t\t\tdiscard;\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t#endif\n\n\t\t\t\t#endif\n\n\t\t\t#else\n\n\t\t\t\t#ifdef USE_ALPHA_TO_COVERAGE\n\n\t\t\t\t\t// artifacts appear on some hardware if a derivative is taken within a conditional\n\t\t\t\t\tfloat a = vUv.x;\n\t\t\t\t\tfloat b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;\n\t\t\t\t\tfloat len2 = a * a + b * b;\n\t\t\t\t\tfloat dlen = fwidth( len2 );\n\n\t\t\t\t\tif ( abs( vUv.y ) > 1.0 ) {\n\n\t\t\t\t\t\talpha = 1.0 - smoothstep( 1.0 - dlen, 1.0 + dlen, len2 );\n\n\t\t\t\t\t}\n\n\t\t\t\t#else\n\n\t\t\t\t\tif ( abs( vUv.y ) > 1.0 ) {\n\n\t\t\t\t\t\tfloat a = vUv.x;\n\t\t\t\t\t\tfloat b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;\n\t\t\t\t\t\tfloat len2 = a * a + b * b;\n\n\t\t\t\t\t\tif ( len2 > 1.0 ) discard;\n\n\t\t\t\t\t}\n\n\t\t\t\t#endif\n\n\t\t\t#endif\n\n\t\t\t#include <logdepthbuf_fragment>\n\t\t\t#include <color_fragment>\n\n\t\t\tgl_FragColor = vec4( diffuseColor.rgb, alpha );\n\n\t\t\t#include <tonemapping_fragment>\n\t\t\t#include <colorspace_fragment>\n\t\t\t#include <fog_fragment>\n\t\t\t#include <premultiplied_alpha_fragment>\n\n\t\t}\n\t\t"};class LineMaterial extends t{constructor(e){super({type:"LineMaterial",uniforms:i.clone(n.line.uniforms),vertexShader:n.line.vertexShader,fragmentShader:n.line.fragmentShader,clipping:!0}),this.isLineMaterial=!0,this.setValues(e)}get color(){return this.uniforms.diffuse.value}set color(e){this.uniforms.diffuse.value=e}get worldUnits(){return"WORLD_UNITS"in this.defines}set worldUnits(e){!0===e?this.defines.WORLD_UNITS="":delete this.defines.WORLD_UNITS}get linewidth(){return this.uniforms.linewidth.value}set linewidth(e){this.uniforms.linewidth&&(this.uniforms.linewidth.value=e)}get dashed(){return"USE_DASH"in this.defines}set dashed(e){!0===e!==this.dashed&&(this.needsUpdate=!0),!0===e?this.defines.USE_DASH="":delete this.defines.USE_DASH}get dashScale(){return this.uniforms.dashScale.value}set dashScale(e){this.uniforms.dashScale.value=e}get dashSize(){return this.uniforms.dashSize.value}set dashSize(e){this.uniforms.dashSize.value=e}get dashOffset(){return this.uniforms.dashOffset.value}set dashOffset(e){this.uniforms.dashOffset.value=e}get gapSize(){return this.uniforms.gapSize.value}set gapSize(e){this.uniforms.gapSize.value=e}get opacity(){return this.uniforms.opacity.value}set opacity(e){this.uniforms&&(this.uniforms.opacity.value=e)}get resolution(){return this.uniforms.resolution.value}set resolution(e){this.uniforms.resolution.value.copy(e)}get alphaToCoverage(){return"USE_ALPHA_TO_COVERAGE"in this.defines}set alphaToCoverage(e){this.defines&&(!0===e!==this.alphaToCoverage&&(this.needsUpdate=!0),!0===e?this.defines.USE_ALPHA_TO_COVERAGE="":delete this.defines.USE_ALPHA_TO_COVERAGE)}}const ni=new p,ii=new u;class LineSegmentsGeometry extends o{constructor(){super(),this.isLineSegmentsGeometry=!0,this.type="LineSegmentsGeometry";this.setIndex([0,2,1,2,3,1,2,4,3,4,5,3,4,6,5,6,7,5]),this.setAttribute("position",new a([-1,2,0,1,2,0,-1,1,0,1,1,0,-1,0,0,1,0,0,-1,-1,0,1,-1,0],3)),this.setAttribute("uv",new a([-1,2,1,2,-1,1,1,1,-1,-1,1,-1,-1,-2,1,-2],2))}applyMatrix4(e){const t=this.attributes.instanceStart,n=this.attributes.instanceEnd;return void 0!==t&&(t.applyMatrix4(e),n.applyMatrix4(e),t.needsUpdate=!0),null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this}setPositions(e){let t;e instanceof Float32Array?t=e:Array.isArray(e)&&(t=new Float32Array(e));const n=new A(t,6,1);return this.setAttribute("instanceStart",new l(n,3,0)),this.setAttribute("instanceEnd",new l(n,3,3)),this.instanceCount=this.attributes.instanceStart.count,this.computeBoundingBox(),this.computeBoundingSphere(),this}setColors(e){let t;e instanceof Float32Array?t=e:Array.isArray(e)&&(t=new Float32Array(e));const n=new A(t,6,1);return this.setAttribute("instanceColorStart",new l(n,3,0)),this.setAttribute("instanceColorEnd",new l(n,3,3)),this}fromWireframeGeometry(e){return this.setPositions(e.attributes.position.array),this}fromEdgesGeometry(e){return this.setPositions(e.attributes.position.array),this}fromMesh(e){return this.fromWireframeGeometry(new c(e.geometry)),this}fromLineSegments(e){const t=e.geometry;return this.setPositions(t.attributes.position.array),this}computeBoundingBox(){null===this.boundingBox&&(this.boundingBox=new p);const e=this.attributes.instanceStart,t=this.attributes.instanceEnd;void 0!==e&&void 0!==t&&(this.boundingBox.setFromBufferAttribute(e),ni.setFromBufferAttribute(t),this.boundingBox.union(ni))}computeBoundingSphere(){null===this.boundingSphere&&(this.boundingSphere=new h),null===this.boundingBox&&this.computeBoundingBox();const e=this.attributes.instanceStart,t=this.attributes.instanceEnd;if(void 0!==e&&void 0!==t){const n=this.boundingSphere.center;this.boundingBox.getCenter(n);let i=0;for(let r=0,s=e.count;r<s;r++)ii.fromBufferAttribute(e,r),i=Math.max(i,n.distanceToSquared(ii)),ii.fromBufferAttribute(t,r),i=Math.max(i,n.distanceToSquared(ii));this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&console.error("THREE.LineSegmentsGeometry.computeBoundingSphere(): Computed radius is NaN. The instanced position data is likely to have NaN values.",this)}}toJSON(){}}const ri=new g,si=new u,oi=new u,ai=new g,Ai=new g,li=new g,ci=new u,pi=new m,hi=new f,ui=new u,di=new p,gi=new h,fi=new g;let mi,yi;function getWorldSpaceHalfWidth(e,t,n){return fi.set(0,0,-t,1).applyMatrix4(e.projectionMatrix),fi.multiplyScalar(1/fi.w),fi.x=yi/n.width,fi.y=yi/n.height,fi.applyMatrix4(e.projectionMatrixInverse),fi.multiplyScalar(1/fi.w),Math.abs(Math.max(fi.x,fi.y))}class LineSegments2 extends d{constructor(e=new LineSegmentsGeometry,t=new LineMaterial({color:16777215*Math.random()})){super(e,t),this.isLineSegments2=!0,this.type="LineSegments2"}computeLineDistances(){const e=this.geometry,t=e.attributes.instanceStart,n=e.attributes.instanceEnd,i=new Float32Array(2*t.count);for(let e=0,r=0,s=t.count;e<s;e++,r+=2)si.fromBufferAttribute(t,e),oi.fromBufferAttribute(n,e),i[r]=0===r?0:i[r-1],i[r+1]=i[r]+si.distanceTo(oi);const r=new A(i,2,1);return e.setAttribute("instanceDistanceStart",new l(r,1,0)),e.setAttribute("instanceDistanceEnd",new l(r,1,1)),this}raycast(e,t){const n=this.material.worldUnits,i=e.camera;null!==i||n||console.error('LineSegments2: "Raycaster.camera" needs to be set in order to raycast against LineSegments2 while worldUnits is set to false.');const r=void 0!==e.params.Line2&&e.params.Line2.threshold||0;mi=e.ray;const s=this.matrixWorld,o=this.geometry,a=this.material;let A,l;if(yi=a.linewidth+r,null===o.boundingSphere&&o.computeBoundingSphere(),gi.copy(o.boundingSphere).applyMatrix4(s),n)A=.5*yi;else{A=getWorldSpaceHalfWidth(i,Math.max(i.near,gi.distanceToPoint(mi.origin)),a.resolution)}if(gi.radius+=A,!1!==mi.intersectsSphere(gi)){if(null===o.boundingBox&&o.computeBoundingBox(),di.copy(o.boundingBox).applyMatrix4(s),n)l=.5*yi;else{l=getWorldSpaceHalfWidth(i,Math.max(i.near,di.distanceToPoint(mi.origin)),a.resolution)}di.expandByScalar(l),!1!==mi.intersectsBox(di)&&(n?function raycastWorldUnits(e,t){const n=e.matrixWorld,i=e.geometry,r=i.attributes.instanceStart,s=i.attributes.instanceEnd;for(let o=0,a=Math.min(i.instanceCount,r.count);o<a;o++){hi.start.fromBufferAttribute(r,o),hi.end.fromBufferAttribute(s,o),hi.applyMatrix4(n);const i=new u,a=new u;mi.distanceSqToSegment(hi.start,hi.end,a,i),a.distanceTo(i)<.5*yi&&t.push({point:a,pointOnLine:i,distance:mi.origin.distanceTo(a),object:e,face:null,faceIndex:o,uv:null,uv1:null})}}(this,t):function raycastScreenSpace(e,t,n){const i=t.projectionMatrix,r=e.material.resolution,s=e.matrixWorld,o=e.geometry,a=o.attributes.instanceStart,A=o.attributes.instanceEnd,l=Math.min(o.instanceCount,a.count),c=-t.near;mi.at(1,li),li.w=1,li.applyMatrix4(t.matrixWorldInverse),li.applyMatrix4(i),li.multiplyScalar(1/li.w),li.x*=r.x/2,li.y*=r.y/2,li.z=0,ci.copy(li),pi.multiplyMatrices(t.matrixWorldInverse,s);for(let t=0,o=l;t<o;t++){if(ai.fromBufferAttribute(a,t),Ai.fromBufferAttribute(A,t),ai.w=1,Ai.w=1,ai.applyMatrix4(pi),Ai.applyMatrix4(pi),ai.z>c&&Ai.z>c)continue;if(ai.z>c){const e=ai.z-Ai.z,t=(ai.z-c)/e;ai.lerp(Ai,t)}else if(Ai.z>c){const e=Ai.z-ai.z,t=(Ai.z-c)/e;Ai.lerp(ai,t)}ai.applyMatrix4(i),Ai.applyMatrix4(i),ai.multiplyScalar(1/ai.w),Ai.multiplyScalar(1/Ai.w),ai.x*=r.x/2,ai.y*=r.y/2,Ai.x*=r.x/2,Ai.y*=r.y/2,hi.start.copy(ai),hi.start.z=0,hi.end.copy(Ai),hi.end.z=0;const o=hi.closestPointToPointParameter(ci,!0);hi.at(o,ui);const l=y.lerp(ai.z,Ai.z,o),p=l>=-1&&l<=1,h=ci.distanceTo(ui)<.5*yi;if(p&&h){hi.start.fromBufferAttribute(a,t),hi.end.fromBufferAttribute(A,t),hi.start.applyMatrix4(s),hi.end.applyMatrix4(s);const i=new u,r=new u;mi.distanceSqToSegment(hi.start,hi.end,r,i),n.push({point:r,pointOnLine:i,distance:mi.origin.distanceTo(r),object:e,face:null,faceIndex:t,uv:null,uv1:null})}}}(this,i,t))}}onBeforeRender(e){const t=this.material.uniforms;t&&t.resolution&&(e.getViewport(ri),this.material.uniforms.resolution.value.set(ri.z,ri.w))}}class LineGeometry extends LineSegmentsGeometry{constructor(){super(),this.isLineGeometry=!0,this.type="LineGeometry"}setPositions(e){const t=e.length-3,n=new Float32Array(2*t);for(let i=0;i<t;i+=3)n[2*i]=e[i],n[2*i+1]=e[i+1],n[2*i+2]=e[i+2],n[2*i+3]=e[i+3],n[2*i+4]=e[i+4],n[2*i+5]=e[i+5];return super.setPositions(n),this}setColors(e){const t=e.length-3,n=new Float32Array(2*t);for(let i=0;i<t;i+=3)n[2*i]=e[i],n[2*i+1]=e[i+1],n[2*i+2]=e[i+2],n[2*i+3]=e[i+3],n[2*i+4]=e[i+4],n[2*i+5]=e[i+5];return super.setColors(n),this}setFromPoints(e){const t=e.length-1,n=new Float32Array(6*t);for(let i=0;i<t;i++)n[6*i]=e[i].x,n[6*i+1]=e[i].y,n[6*i+2]=e[i].z||0,n[6*i+3]=e[i+1].x,n[6*i+4]=e[i+1].y,n[6*i+5]=e[i+1].z||0;return super.setPositions(n),this}fromLine(e){const t=e.geometry;return this.setPositions(t.attributes.position.array),this}}class Line2 extends LineSegments2{constructor(e=new LineGeometry,t=new LineMaterial({color:16777215*Math.random()})){super(e,t),this.isLine2=!0,this.type="Line2"}}const bi=new e.MeshStandardMaterial({color:36864,roughness:.5,metalness:.4,side:e.DoubleSide});function getorientate(e,t,n,i){switch(t=t||0,n=n||0,i=i||0,e.trim().toLowerCase()){case"alp":return{x:n,y:t,z:i};case"apl":return{x:n,y:i,z:t};case"pla":return{x:i,y:t,z:n};case"pal":return{x:i,y:n,z:t};case"lpa":return{x:t,y:i,z:n};default:return{x:t,y:n,z:i}}}const Ii={lpa:"sdbarf",lap:"sdrfba",pal:"rfsdba",pla:"rfbasd",apl:"basdrf",alp:"barfsd"};function parselavs(e,t,n=0,i=0,r=0,s="",o="",a=""){let A=muClComments(s);e=e.trim().toLowerCase();let l=[];for(let s of A){let a=/^([({}):$\w.\\/]+)[\s;,]*(.*)?$/im.exec(s);if(a&&a[1]){let s={name:a[1].trim().toLowerCase(),...getorientate(e,n,i,r),id:t,facce:o};if(a[2]){let e=getcolonne(a[2]);for(let t of e){let e=t.indexOf("=");e>0&&(s[t.slice(0,e).trim()]=t.slice(e+1).trim())}}l.push(s)}}return!l.length&&a&&l.push({name:a,...getorientate(e,n,i,r),id:t,facce:o}),l}function getemitter(t){let{d:n,name:i,x:r,y:s,z:o,lavs:a="",ids:A="",faces:l=null,size:c=5}=t;A=getcolonne(clean(A,!0));const p=new e.Object3D;if(p.position.set(r,s,o),p.userData={emitter:!0,lavs:a,ids:A,faces:l,size:c,name:i},n){const t=new e.SphereGeometry(c||5,8,8),n=new e.MeshBasicMaterial({color:16711680}),i=new e.Mesh(t,n);p.add(i)}return p.layers.set(29),p}function getreceiver(t,n){t.gmats.__istask=1;let{d:i,ori:r="LAP",x:s=0,y:o=0,z:a=0,sx:A=0,sy:l=0,sz:c=0,tipo:p="",start:h="",end:u=""}=n;p=clean(p,!0);const d=new e.Object3D;if(d.position.set(s/2+(A||0),o/2+(l||0),a/2+(c||0)),d.userData={receiver:!0,ori:(r||"").trim().toLowerCase(),x:s,y:o,z:a,tipo:p,start:h,end:u},i){const t=new e.BoxGeometry(s,o,a),n=new e.Mesh(t,bi);n.position.set(0,0,0),d.add(n)}return d.layers.set(29),d}function calcolatasks(t){const n=new WeakMap,i=new WeakMap;function boxBoxIntersects(e,t,n,i,r){return e.x+t>0&&e.x-t<n&&e.y+t>0&&e.y-t<i&&e.z+t>0&&e.z-t<r}function getFacceToccate(e,t,n,i,r,s,o){const a=[];function addfaccia(e){o&&!o.includes(e)||a.push(e)}return Math.abs(t.y-0)<n&&addfaccia(e[0]),Math.abs(t.y-r)<n&&addfaccia(e[1]),Math.abs(t.x-0)<n&&addfaccia(e[2]),Math.abs(t.x-i)<n&&addfaccia(e[3]),Math.abs(t.z-0)<n&&addfaccia(e[4]),Math.abs(t.z-s)<n&&addfaccia(e[5]),a.join("")}function getEmitterWorldPosition(t){if(!n.has(t)){const i=new e.Vector3;t.getWorldPosition(i),n.set(t,i)}return n.get(t)}function getReceiverWorldMatrixInverse(e){if(!i.has(e)){const t=e.matrixWorld.clone().invert();i.set(e,t)}return i.get(e)}t.updateMatrixWorld(!0);const r=[],s=[];!function scan(e){e.userData?.receiver&&r.push(e),e.userData?.emitter&&s.push(e),e.children&&e.children.forEach(scan)}(t);let o=[];for(const t of r){let{mat:n,ori:i,x:r,y:a,z:A,start:l,end:c,tipo:p,size:h}=t.userData,u=Ii[i];u||(i="apl",u=Ii[i]);let d={id:n,...getorientate(i,r,a,A),tipo:p,ori:i,lavs:[]};l&&d.lavs.push(...parselavs(i,"_start",0,0,0,l,"",""));const g=getReceiverWorldMatrixInverse(t);for(const t of s){if("string"==typeof p&&""!==p){const e=t.userData.ids;if(Array.isArray(e)&&e.length>0&&!e.includes("*")&&!e.includes(p))continue}const n=getEmitterWorldPosition(t).clone().applyMatrix4(g).clone().add(new e.Vector3(r/2,a/2,A/2));if(!boxBoxIntersects(n,t.userData.size??0,r,a,A))continue;const s=getFacceToccate(u,n,t.userData.soglia??2,r,a,A,t.userData.faces);s&&s.length&&d.lavs.push(...parselavs(i,t.userData.name,n.x,n.y,n.z,t.userData.lavs,s,"nd"))}c&&d.lavs.push(...parselavs(i,"_end",0,0,0,c,"","")),d.lavs.length&&o.push(d)}return o}function getbb(t,n=!1){if(!n&&t.userData.bb)return t.userData._boundingbox;const i=(new e.Box3).setFromObject(t);return t.userData._boundingbox=i,i}function setorigine(t,n=0,i=0,r=0){const s=getbb(t).min,o=new e.Group;return o.add(t),t.position.sub(new e.Vector3(s.x+n,s.y+i,s.z+r)),o}function scalaoggetto(t,n,i={}){const r=getbb(n),s=new e.Vector3;r.getSize(s);const o=r.min,a=["x","y","z","u","v"],A={};for(let e of a){let t=i[e];if(void 0===t)A[e]={s:1};else if("number"==typeof t)A[e]={s:t};else if("object"==typeof t){let n=t.s??1,i="x"===e?s.x:"y"===e?s.y:s.z,r="x"===e?o.x:"y"===e?o.y:o.z;void 0!==t.distperc&&(t.dist=i*t.distperc),void 0!==t.dist&&(n=(i+t.dist)/i);let a=t.p1?t.p1+r:void 0,l=t.p2?t.p2+r:void 0;void 0!==t.p1perc&&(a=r+i*t.p1perc),void 0!==t.p2perc&&(l=r+i*t.p2perc),A[e]={s:n,p1:a,p2:l}}}if(a.every((e=>void 0===A[e].p1||void 0===A[e].p2))){if(1===A.x.s&&1===A.y.s&&1===A.z.s)return n;const t=new e.Group;return t.scale.set(A.x.s,A.y.s,A.z.s),t.add(n),t}const l=hash(`${n.uuid}|${JSON.stringify(A)}`);if(t.meshes[l])return t.meshes[l];const c={};a.forEach((e=>{const{s:t,p1:n,p2:i}=A[e];c[e]=!(1===t&&void 0===n&&void 0===i)}));const p=n.clone(!0);return delete p?.userData._boundingbox,p.traverse((e=>{if(e.isMesh){const t=e.scale.clone();e.geometry=e.geometry.clone();const n=e.geometry.attributes.position,i=e.geometry.attributes.uv,trasf=(e,t)=>{if(!c[t])return e;const{s:n,p1:i,p2:r}=A[t];if(void 0===i||void 0===r)return e*n;const s=r*n-r;if(e<i)return e;if(e>=r)return e+s;return i+(e-i)*((r-i+s)/(r-i))};if(n&&(c.x||c.y||c.z)){const t=n.array;for(let e=0;e<t.length;e+=3)c.x&&(t[e]=trasf(t[e],"x")),c.y&&(t[e+1]=trasf(t[e+1],"y")),c.z&&(t[e+2]=trasf(t[e+2],"z"));n.needsUpdate=!0,e.geometry.computeVertexNormals()}if(i&&(c.u||c.v)){const e=i.array;for(let t=0;t<e.length;t+=2)c.u&&(e[t]=trasf(e[t],"u")),c.v&&(e[t+1]=trasf(e[t+1],"v"));i.needsUpdate=!0}e.scale.set(t.x*A.x.s,t.y*A.y.s,t.z*A.z.s)}})),t.meshes[l]=p,p}function posiziona(t,n={}){let i=new e.Group;if(t){let r=function deepclone(e){if(!e)return null;const t=e.clone();return function checkchildren(e,t){if(e.onBeforeRender&&(t.onBeforeRender=e.onBeforeRender),e.onAfterRender&&(t.onAfterRender=e.onAfterRender),e.userData&&(t.userData={...e.userData}),e.children||e.children.length)for(let n=0;n<e.children.length;n++)checkchildren(e.children[n],t.children[n])}(e,t),t}(t),s=r,{marker:o="",markerid:a="",sl:A=0,sa:l=0,sp:c=0,ax:p=0,ay:h=0,az:u=0,scale:d=1,scx:g=d,scy:f=d,scz:m=d,emitters:y,emittersname:b,order:I,move:x}=n;if("number"==typeof I&&r.traverse((e=>{e.isMesh&&(e.renderOrder=I)})),i.position.set(A,l,c),i.rotation.set(p*ft,h*ft,u*ft),i.scale.set(g,f,m),!x?.annulla){if(x){function managemove(t,n){let{l:i=0,a:r=0,p:s=0,rot:o=0}=t,a=new e.Group;return a.position.set(i,r,s),a.rotation.set(0,o*ft,0),a.add(n),a.userData.ismove=!0,a.userData.move=t,a}s=managemove(x,r)}i.add(s)}if(o&&a&&(i.userData.marker=o,i.userData.markerid=`#mk_${a||""}`),y&&y.length)for(let C of y)C.name=C.name||b,i.add(getemitter(C));for(let B of["hideable","origin","markdel","markkey","pars","noingombro","ignoreTraverse"])n[B]&&(i.userData[B]=n[B])}return i.updateMatrixWorld(!0),i}const xi=e.DoubleSide;let Bi=new e.LineBasicMaterial({color:16711680,transparent:!1,opacity:1}),Ei=new e.LineBasicMaterial({color:11579568,transparent:!1,opacity:1});const wi=new e.MeshStandardMaterial({color:16777215,roughness:.5,metalness:.4,side:xi}),vi=new e.MeshStandardMaterial({color:8421504,roughness:.5,metalness:.4,side:xi}),Qi=new e.MeshStandardMaterial({color:11579568,roughness:.5,metalness:.4,side:xi}),Pi=new e.MeshStandardMaterial({color:16711680,roughness:.5,metalness:.4,side:xi}),Ti=new e.MeshStandardMaterial({color:1982639,roughness:.5,metalness:.4,side:xi}),Di=new e.MeshStandardMaterial({color:36864,roughness:.5,metalness:.4,side:xi}),Li=new e.MeshStandardMaterial({color:0,roughness:.5,metalness:.4,side:xi}),_i=.001;function groupfromgeometry(t,n,i,r,s,o,a){let A=new e.Group;A.position.set(i,r,s),A.name=o;const l=new e.Mesh(t,n);l.name=o,l.castShadow=!0,l.receiveShadow=!0,l.layers.set(a);const c=new e.EdgesGeometry(t),p=new e.LineSegments(c,Bi);return p.layers.set(30),A.add(l),A.add(p),A}function edgesfromgeometry(t,n=40,i=30){return getlinesgeom(new e.EdgesGeometry(t,n),i)}function getlinesgeom(t,n=30){const i=new e.LineSegments(t,Bi);return i.layers.set(n),i}function getmesh(t,n,i=1,r=!1){let s=new e.Mesh(t,r?n.clone():n);return s.castShadow=!0,s.receiveShadow=!0,s.layers.set(i),s}function get3dshape(t,n,i){if(!t||t.length<3)return new e.BufferGeometry;const r=[];for(let e=0;e<t.length;e++){const n=t[e],i=t[(e+1)%t.length];r.push(n.x,0,n.y),r.push(i.x,0,i.y)}const s=new e.BufferGeometry;s.setAttribute("position",new e.Float32BufferAttribute(r,3));let o=new e.LineSegments(s,n);return o.layers.set(i),o}function creategroup(t,n={}){let{ignoreTraverse:i}=n,r=new e.Group;return r.name=t||"$$",i&&(r.userData.ignoreTraverse=!0),r}function svuotanodo(e){!function _dispose(e){if(e.children.length){[...e.children].forEach((t=>{_dispose(t),e.remove(t)}))}e.geometry&&e.geometry.dispose(),e.material&&(Array.isArray(e.material)?e.material.forEach((e=>e.dispose())):e.material.dispose())}(e)}function deletegroup(e,t){if(!e?.children)return;let n=e.children.find((e=>e.name==t));if(n){for(;n.children.length>0;){const e=n.children[0];n.remove(e)}n.parent&&n.parent.remove(n),n=null}}function randombasemat(){const t=new e.LineBasicMaterial,n=new e.Color;return n.setHSL(Math.random(),.7,.4),t.color=n,t}function getspriteid(t,n=5,i="#000"){const r=document.createElement("canvas"),s=r.getContext("2d");s.font="48px sans-serif";const o=Math.ceil(s.measureText(t).width)+16;r.width=o,r.height=64,s.font="48px sans-serif",s.textBaseline="middle",s.fillStyle="rgba(0,0,0,0)",s.fillRect(0,0,o,64),s.fillStyle=i,s.fillText(t,8,32);const a=new e.CanvasTexture(r);a.needsUpdate=!0,a.minFilter=e.LinearFilter;const A=new e.SpriteMaterial({map:a,transparent:!0}),l=new e.Sprite(A),c=n/20;return l.scale.set(o*c,64*c,1),l}function getline(t,n,i=null){const r=(new e.BufferGeometry).setFromPoints([new e.Vector3(t.p1.x,0,t.p1.y),new e.Vector3(t.p2.x,0,t.p2.y)]);let s=new e.Line(r,i||randombasemat());if(n){let e=getspriteid(n||"",8,"#F00");e.position.set((t.p1.x+t.p2.x)/2,0,(t.p1.y+t.p2.y)/2),s.add(e)}return s}function getpoint(t,n,i=null,r=5){let s;const o=new e.SphereGeometry(r,8,8);if(s=new e.Mesh(o,i||randombasemat()),n){let e=getspriteid(n||"",r);e.position.set(1.2*r,0,1.2*r),s.add(e)}return s.position.set(t.x,0,t.y),s}async function smat(t,n,i={}){i||(i={});let r=hash(n+JSON.stringify(i));return t.smats[r]||(i.glass?t.smats[r]=await async function smatglass(t,n={}){let i;try{i=new e.Color(t)}catch(t){i=new e.Color("#080808ff"),console.log(t)}let{roughness:r=.15,envMapIntensity:s=1,opacity:o=.25,metalness:a=.6,ior:A,transmission:l,specularIntensity:c,specularColor:p,thickness:h,clearcoat:u,clearcoatRoughness:d,dispersion:g}=n;if(!l||l<=0)return new e.MeshStandardMaterial({color:i,metalness:a,roughness:r,envMapIntensity:s,opacity:o,transparent:!0,side:e.FrontSide});return new e.MeshPhysicalMaterial({color:i,metalness:a,roughness:r,ior:A,envMapIntensity:s,transmission:l,specularIntensity:c,specularColor:p,opacity:o,thickness:h,clearcoat:u,clearcoatRoughness:d,dispersion:g,transparent:!0,side:e.FrontSide})}(n,i):t.smats[r]=await async function smat0(t,n,i={}){let r=n,s="",o=!1;if(!n)return wi;function getFilesToLoad(e,t){let n=[],i=t.match(/^([^(]+)\((([a-zA-Z0-9_\-/]+)_([a-z]+)|([a-z]+))\)$/);if(!i)return{base:t,files:n};let r=i[1],s=!1,o=i[3]||r,a=i[4]||i[5]||"";!a.includes("h")&&e||n.push({suff:"",file:`${o}.webp`,cs:!0});for(let e of a)"t"==e?(s=!0,i[3]&&ki[e]&&n.push({suff:e,file:`${o}_${e}.webp`,cs:!1})):"h"!=e&&ki[e]&&n.push({suff:e,file:`${o}_${e}.webp`,cs:!!["","e"].includes(e)});return{base:r,files:n,transparent:s}}n.startsWith("#")&&(o=!0,/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})(?=$|[[(])/.test(n)||(n=n.slice(1)));let a=n;const A=n.match(/^(.*)\[([^\]]+)\]$/);A&&(a=A[1],s=A[2]);const l={};s&&s.split(/[,;]/).forEach((e=>{let[t,n]=e.split("=").map((e=>e.trim()));void 0!==n&&(["e"].includes(t)?l[t]=n.startsWith("0x")?parseInt(n):parseFloat(n):isNaN(parseFloat(n))?l[t]=n:l[t]=parseFloat(n))}));let c=i.rot,p=parseFloat(i.s)||1;delete i.s;let h={...i};for(let e in l)if(Fi[e])for(let t of Fi[e])h[t]=l[e];let u=!!h?.transparent,d=(h.sx??h.s??l.sx??l.s??1)*p,g=(h.sy??h.s??l.sy??l.s??1)*p,f=Number((l.rot??0)+(c??0))*ft;try{let i={roughness:h.roughness??.5,metalness:h.metalness??0,side:e.DoubleSide,envMapIntensity:h.env??1};if(void 0!==h.normalScale){let t=Number(h.normalScale);isNaN(t)||0===t||(i.normalScale=new e.Vector2(t,t))}let r=!1,s=!1;if(n.includes("(")||o){let{base:n,files:A,transparent:l}=getFilesToLoad(o,a);if(u=l,A.some((e=>"n"===e.suff))&&(A=A.filter((e=>"h"!==e.suff))),0===h.roughness&&(A=A.filter((e=>"r"!==e.suff))),0===h.metalness&&(A=A.filter((e=>"m"!==e.suff))),0===h.emissiveIntensity&&(A=A.filter((e=>"e"!==e.suff))),A&&A.length){let n=await Promise.all(A.map((e=>t.tex(e.file,d,g,f).catch((()=>null)))));for(let t=0;t<A.length;t++){let o=n[t];if(!o)continue;o.isTexture&&(o.colorSpace=A[t].cs?e.SRGBColorSpace:e.LinearSRGBColorSpace);let a=A[t].suff,{prop:l,extra:c}=ki[a];i[l]=o,"map"===l&&(i._hasMap=!0),"normalMap"===c?(r=!0,i.normalMap=o,delete o.colorSpace,o.needsUpdate=!0,i.normalScale=i.normalScale??new e.Vector2(1,1)):"bumpScale"===c?(s=!0,i.bumpMap=o):Array.isArray(c)&&c.includes("emissive")&&void 0!==h.emissiveIntensity&&0!==h.emissiveIntensity&&(i.emissive=h.emissive||16777215,i.emissiveIntensity=h.emissiveIntensity??1)}}o&&(i.color=new e.Color(n),i._hasColor=!0)}else if(a.includes(".")){let e=await t.tex(a,d,g,f);if(!e)return wi;i.map=e,i._hasMap=!0}if(r&&s?delete i.bumpMap:s&&(i.bumpScale=h.bumpScale??.03),i.transparent=!!u,i.transparent&&(i.depthWrite=!1,i.opacity=h?.opacity??1),void 0!==h.brightness){let t=Number(h.brightness);!isNaN(t)&&t>0&&1!==t&&(i.color||(i.color=new e.Color(1,1,1)),i.color.multiplyScalar(t))}return i._hasMap&&!i._hasColor&&(i.color=new e.Color(1,1,1)),i._hasColor&&!i._hasMap&&delete i.map,delete i._hasColor,delete i._hasMap,new e.MeshStandardMaterial(i)}catch(e){return console.log("errore mat:",e.message,r),wi}}(t,n,i)),t.smats[r]}const Fi={s:["sx","sy"],sx:["sx"],sy:["sy"],rot:["rot"],br:["brightness"],r:["roughness"],m:["metalness"],h:["bumpScale"],n:["normalScale"],d:["bumpScale"],b:["bumpScale"],e:["emissiveIntensity"],ec:["emissive"],env:["envMapIntensity"],o:["opacity"],t:["transparent"],at:["alphaTest"]},ki={"":{prop:"map",extra:null},h:{},n:{prop:"normalMap",extra:null},a:{prop:"aoMap",extra:"aoMapIntensity"},r:{prop:"roughnessMap",extra:null},t:{prop:"alphaMap",extra:null},m:{prop:"metalnessMap",extra:null},e:{prop:"emissiveMap",extra:["emissive","emissiveIntensity"]}};async function extractTextures(e,t){const n={},i=[];function getName(e){n[e]=(n[e]||0)+1;let i=t;return e&&(i+=`_${e}`),n[e]>1&&(i+=n[e]),`${i}.webp`}return e.traverse((e=>{if(e.material){const t=Array.isArray(e.material)?e.material:[e.material];for(const e of t)for(const[t,{prop:n}]of Object.entries(ki)){const r=e[n];if(r&&r.image&&!r._extracted){r._extracted=!0;let e,n=r.image;if(n.toBlob)e=new Promise((e=>n.toBlob(e,"image/webp")));else if(n instanceof ImageBitmap){const t=document.createElement("canvas");t.width=n.width,t.height=n.height;t.getContext("2d").drawImage(n,0,0),e=new Promise((e=>t.toBlob(e,"image/webp")))}else{if(!(n instanceof HTMLImageElement))continue;{const t=document.createElement("canvas");t.width=n.naturalWidth||n.width,t.height=n.naturalHeight||n.height;t.getContext("2d").drawImage(n,0,0),e=new Promise((e=>t.toBlob(e,"image/webp")))}}i.push(e.then((e=>new File([e],getName(t),{type:"image/webp"}))))}}}})),e.traverse((e=>{if(e.material){const t=Array.isArray(e.material)?e.material:[e.material];for(const e of t)for(const{prop:t}of Object.values(ki)){const n=e[t];n&&n._extracted&&delete n._extracted}}})),Promise.all(i)}function uvswap(e,t=!1,n=!0){if(e&&e.attributes){const i=n?_i:1,r=e.attributes.uv;if(r){const e=r.array;for(let r=0,s=e.length;r<s;r+=2)if(t){const t=e[r];e[r]=e[r+1]*i,e[r+1]=t*i}else n&&(e[r]*=i,e[r+1]*=i);r.needsUpdate=t||n}const s=e.attributes.uv2;if(s){const e=s.array;for(let n=0,r=e.length;n<r;n+=2)if(t){const t=e[n];e[n]=e[n+1]*i,e[n+1]=t*i}else e[n]*=i,e[n+1]*=i;s.needsUpdate=!0}e.index&&e.attributes?.position&&e.attributes?.normal&&e.attributes?.uv&&e.computeTangents()}}function linea3d(e,t,n=!1){if(e&&e.length>1){const i=e.flatMap((e=>[e.x,e.y,0]));n&&i.push(e[0].x,e[0].y,0);const r=new LineGeometry;r.setPositions(i);const s=new Line2(r,t);return s.computeLineDistances(),s}}function transformfn(t={},n={}){const i=1e-6,r=new e.Vector3(t.sl||0,t.sa||0,t.sp||0),s=new e.Vector3(n.sl||0,n.sa||0,n.sp||0),o=new e.Vector3(t.scx??t.scale??1,t.scy??t.scale??1,t.scz??t.scale??1),a=new e.Vector3(n.scx??n.scale??1,n.scy??n.scale??1,n.scz??n.scale??1),A=(new e.Quaternion).setFromEuler(new e.Euler(e.MathUtils.degToRad(t.ax||0),e.MathUtils.degToRad(t.ay||0),e.MathUtils.degToRad(t.az||0),"XYZ")),l=(new e.Quaternion).setFromEuler(new e.Euler(e.MathUtils.degToRad(n.ax||0),e.MathUtils.degToRad(n.ay||0),e.MathUtils.degToRad(n.az||0),"XYZ")),c=o.clone().multiply(a),p=A.clone().multiply(l).normalize(),h=s.clone().multiply(o).applyQuaternion(A).add(r),u={},sig=(e,t=2)=>Math.round(e*10**t)/10**t;Math.abs(h.x)>i&&(u.sl=sig(h.x)),Math.abs(h.y)>i&&(u.sa=sig(h.y)),Math.abs(h.z)>i&&(u.sp=sig(h.z)),Math.abs(c.x-c.y)<i&&Math.abs(c.x-c.z)<i?Math.abs(c.x-1)>i&&(u.scale=c.x):(Math.abs(c.x-1)>i&&(u.scx=c.x),Math.abs(c.y-1)>i&&(u.scy=c.y),Math.abs(c.z-1)>i&&(u.scz=c.z));const d=(new e.Euler).setFromQuaternion(p,"XYZ"),g=e.MathUtils.radToDeg(d.x),f=e.MathUtils.radToDeg(d.y),m=e.MathUtils.radToDeg(d.z);return Math.abs(g)>i&&(u.ax=sig(g,1)),Math.abs(f)>i&&(u.ay=sig(f,1)),Math.abs(m)>i&&(u.az=sig(m,1)),u}function getfakeshadow2(t,n,i){const r=(new e.Shape).moveTo(0,0).lineTo(t,0).lineTo(t,n).lineTo(0,n).lineTo(0,0),s=new e.ShapeGeometry(r),o=s.attributes.position,a=new Float32Array(2*o.count);for(let e=0;e<o.count;e++)a[2*e]=o.getX(e)/t,a[2*e+1]=o.getY(e)/n;s.setAttribute("uv",new e.BufferAttribute(a,2));const A=new e.MeshBasicMaterial({map:i,transparent:!0,alphaTest:.01,depthWrite:!1,side:e.DoubleSide}),l=new e.Mesh(s,A);return l.layers.set(9),l.rotation.x=Math.PI/2,l}function getfakeshadow(t,n,i){let r=`fk${n.key}${i}`,{p1:s,width:o,height:a}=n.dims();t.texture||(t.texture={});let A=t.texture[r];A||(A=function createBlurredShadowTextureFromPoints(t,n=256,i=32,r=.2,s,o,a){if(!o||!a||!t.pt||t.pt.length<2)return;const A=s.x,l=s.y,c=o,p=a,h=t.pt,u=2*i,d=document.createElement("canvas");d.width=n+2*u,d.height=n+2*u;const g=d.getContext("2d");g.save(),g.translate(u,u),g.scale(n/c,n/p),g.translate(-A,-l),g.filter=`blur(${i}px)`,g.beginPath(),g.moveTo(h[0].x,h[0].y);for(let e=1;e<h.length;e++)g.lineTo(h[e].x,h[e].y);g.closePath(),g.fillStyle=`rgba(0,0,0,${r})`,g.fill(),g.restore();const f=new e.CanvasTexture(d);return f.needsUpdate=!0,f}(n,256,32,i,s,o,a),t.texture[r]=A);const l=function pointsToShape(t){const n=new e.Shape;n.moveTo(t[0].x,t[0].y);for(let e=1;e<t.length;e++)n.lineTo(t[e].x,t[e].y);return n}(n.pt),c=new e.ShapeGeometry(l);!function applyUVtoShapeGeometry(t,n,i,r,s){const o=t.attributes.position,a=[];for(let e=0;e<o.count;e++){const t=o.getX(e),A=o.getY(e);a.push((t-n)/r,(A-i)/s)}t.setAttribute("uv",new e.Float32BufferAttribute(a,2))}(c,s.x,s.y,o,a);const p=new e.MeshBasicMaterial({map:A,transparent:!0,depthWrite:!1,side:e.DoubleSide});let h=new e.Mesh(c,p);return h.layers.set(9),h.rotation.x=Math.PI/2,h}function addmovpivot(t,n,i,r={},s=0,o=0,a=0){if(i=clean(i,!0),!t.movs[i])return n;t.movs[i];const A=new e.Vector3(s,o,a),l=0===A.lengthSq(),c=new e.Group;c.name=`pivot_${i}`;const p=new e.Group;if(p.name=`mov_${i}`,l)c.position.copy(n.position),c.quaternion.copy(n.quaternion),n.position.set(0,0,0),n.rotation.set(0,0,0);else{const t=A.clone().applyMatrix4(n.matrixWorld);c.position.copy(t);const i=A.clone().negate();n.position.add(i),c.quaternion.copy(n.getWorldQuaternion(new e.Quaternion)),n.rotation.set(0,0,0)}return p.add(n),c.add(p),r||(r={}),r.inmov=!1,r.key=i,r.dt=0,r.dtstart=!1,p.userData.mov={...r},c}function getmovimento(e,t=[]){let n=0,i=[];const _cleartimeline=()=>{i=[],n=0},_add=(e,t={})=>{e&&i.push({...t,time:e}),n=i.reduce(((e,t)=>e+(t.time||0)),0)};_cleartimeline(),t&&t.length&&t.forEach((e=>_add(e.time,e)));const _resetmov=e=>{const{mov:t}=e?.userData||{};t&&(t.inmov=!1,e.position.set(0,0,0),e.scale.set(1,1,1),e.rotation.set(0,0,0))};return{get tline(){return n},clear:_cleartimeline,add:_add,key:e,step:(e,t)=>{if(!e||!e.userData?.mov||!n)return;const{mov:r}=e.userData;if(!r.inmov)return;let s=r.dt-r.dtstart;if(r.ripeti)s%=n;else if(s>n)return void _resetmov(e);let o=0,a=0,A=0,l=0,c=0,p=0,h=1,u=1,d=1,g=null,f=0;for(let e of i){if(f+=e.time,s<f){const t=e.time>0?(s-(f-e.time))/e.time:1,_calc=(e,n=0)=>"function"==typeof e?e(r)*t:(e||n)*t;o+=_calc(e.x),a+=_calc(e.y),A+=_calc(e.z),h*=1+_calc(e.sx??e.s,0),u*=1+_calc(e.sy??e.s,0),d*=1+_calc(e.sz??e.s,0),l+=_calc(e.ax)*ft,c+=_calc(e.ay)*ft,p+=_calc(e.az)*ft,void 0!==e.t&&(g="function"==typeof e.t?e.t(r)*t:e.t*t);break}{const _calc=(e,t=0)=>"function"==typeof e?e(r):e||t;o+=_calc(e.x),a+=_calc(e.y),A+=_calc(e.z),h*=1+_calc(e.sx??e.s,0),u*=1+_calc(e.sy??e.s,0),d*=1+_calc(e.sz??e.s,0),l+=_calc(e.ax)*ft,c+=_calc(e.ay)*ft,p+=_calc(e.az)*ft,void 0!==e.t&&(g="function"==typeof e.t?e.t(r):e.t)}}e.position.set(o,a,A),e.scale.set(h,u,d),e.rotation.set(l,c,p),null!==g&&e.traverse((e=>{if(e.material){(Array.isArray(e.material)?e.material:[e.material]).forEach((e=>{e.transparent&&(e.opacity=1-g)}))}})),t&&t(e,s)},reset:_resetmov}}let Ri=null,Ni=null;function getriferimento(t,n=0,i=0,r=0,s="rif"){"string"==typeof t&&(t={testo:t});let o=new e.Object3D;return o.position.set(n,i,r),s&&(o.name=s),o.userData={tipo:"rif",...t},o}function gettarghetta(t,n,i=100,r={}){const{noSfondo:s=!1,forcey:o=!1,coloreSfondo:a="white",coloreBordo:A="gray",spessoreBordo:l=2,padding:c=8,layer:p=21,size:h=24,hideable:u=!0,fontFamily:d="Arial",raggioAngoli:g=10,order:f=0,variant:m,tooltip:y,billboard:b=!1}=r;n=(n||"").replaceAll("\\n","\n");let I=hash(`T:${a}|${A}|${d}|${c}|${l}|${g}|${s}|${n}|${m}|${b}`);const x=h??24;n=n.split("\n").map((e=>{let t=x,n=!1,i=!1,r="black";e=e.trim();let s=/^\s*#(\w)([bi]?)([\d.]*)[,;](.*)$/.exec(e);if(s)switch(t=parseFloat(s[3]||1)*x,"b"===s[2]&&(n=!0),"i"===s[2]&&(i=!0),e=s[4],s[1].toLowerCase()){case"r":r="red";break;case"g":r="green";break;case"b":r="blue";break;case"w":r="white";break;case"c":r="cyan"}return{testo:e,size:t,color:r,bold:n,italic:i}})).filter((e=>e.testo));const{canvas:C,context:B}=function getGlobalCanvas(){return Ri||(Ri=document.createElement("canvas"),Ni=Ri.getContext("2d",{willReadFrequently:!0})),{canvas:Ri,context:Ni}}();let E=0,w=2*c;n.forEach(((e,t)=>{const{testo:i,size:r=12}=e,s=2*r;B.font=`${s}px ${d}`;const o=B.measureText(i).width,a=s*(t==n.length-1?1:1.2);E=Math.max(E,o),w+=a})),E+=2*c;const v=w/E||1;let P,T;if(o?(T=i,P=Math.ceil(T/v)):(P=i,T=Math.ceil(P*v)),!t.textures[I]){const i=Math.floor(E+2*l),r=Math.floor(w+2*l);(C.width<i||C.height<r)&&(C.width=Math.max(C.width,i),C.height=Math.max(C.height,r)),B.clearRect(0,0,i,r);const o=new e.Color(a),p=`rgb(${Math.floor(255*o.r)}, ${Math.floor(255*o.g)}, ${Math.floor(255*o.b)})`,h=new e.Color(A),u=`rgb(${Math.floor(255*h.r)}, ${Math.floor(255*h.g)}, ${Math.floor(255*h.b)})`,f=g;B.beginPath(),s||(drawRoundedRect(B,0,0,i,r,f+l/2),B.fillStyle=u,B.fill(),B.beginPath(),drawRoundedRect(B,l,l,i-2*l,r-2*l,f-l/2),B.fillStyle=p,B.fill());let m=c+l;n.forEach((e=>{const{testo:t,size:n=12,color:r="black",bold:s,italic:o}=e,a=2*n;B.font=`${s?"bold ":o?"italic ":""}${a}px ${d}`,B.fillStyle=r,B.textAlign="center",B.textBaseline="top",B.fillText(t,i/2,m),m+=1.2*a}));const y=B.getImageData(0,0,i,r),b=new e.DataTexture(y.data,y.width,y.height,e.RGBAFormat);b.needsUpdate=!0,b.flipY=!0,b.minFilter=e.LinearFilter,b.magFilter=e.LinearFilter,t.textures[I]=b}const S=new e.MeshBasicMaterial({map:t.textures[I],transparent:!0,alphaTest:.5,side:xi}),M=new e.PlaneGeometry(P,T),D=new e.Mesh(M,S);return D.layers.set(p),D.renderOrder=f,D.userData={dimx:P,dimy:T,noingombro:!0,hideable:u},m&&(D.userData.pickvariant=!0,D.userData.variant=m,D.userData.tooltip=y),b&&(D.up.set(0,0,1),D.layers.set(21),D.onBeforeRender=(e,t,n)=>{D.quaternion.copy(n.quaternion)}),D}function drawRoundedRect(e,t,n,i,r,s){s=Math.min(s,Math.min(i/2,r/2)),e.moveTo(t+s,n),e.lineTo(t+i-s,n),e.quadraticCurveTo(t+i,n,t+i,n+s),e.lineTo(t+i,n+r-s),e.quadraticCurveTo(t+i,n+r,t+i-s,n+r),e.lineTo(t+s,n+r),e.quadraticCurveTo(t,n+r,t,n+r-s),e.lineTo(t,n+s),e.quadraticCurveTo(t,n,t+s,n),e.closePath()}function getquota(t,n,i,r,s,o,a={}){const{altezza:A=30,offset:l=0,piano:c="xy",hideable:p=!0,layer:h=22,delta:u=5,spessoreLinea:d=3}=a,pp=(e,t)=>"xz"===c?[e,0,t]:"yz"===c?[0,e,t]:[e,t,0],g=new e.Group;g.name="quota",g.userData.hideable=!0;const f=s-i,m=o-r,y=Math.sqrt(f*f+m*m),b=Math.atan2(m,f);n||(n="$$"),n.includes("$$")&&(n=n.replace("$$",`${y.toFixed(1)}`));let I=n.split("\n").length;const x=-Math.sin(b)*l,C=Math.cos(b)*l,B=gettarghetta(t,n,2*A*I,{noSfondo:!0,layer:h,forcey:!0}),{dimx:E,dimy:w}=B.userData;function getCilindro(n,i,r){const s=(new e.Vector3).subVectors(i,n),o=s.length();let a,A=hash(`c:${r}|${o}`);t.geo[A]?a=t.geo[A]:(a=new e.CylinderGeometry(r/2,r/2,o,3,1,!0),t.geo[A]=a);const l=new e.Mesh(a,Li);l.position.copy(n).add(s.multiplyScalar(.5));const c=(new e.Vector3).copy(i);return l.lookAt(c),l.rotateX(Math.PI/2),l}if(E>y-u){B.position.set(y/2,2*A,0);const t=getCilindro(new e.Vector3(...pp(0,0)),new e.Vector3(...pp(y,0)),d);g.add(t)}else{const t=E+u,n=(y-t)/2,i=n+t,r=getCilindro(new e.Vector3(...pp(0,0)),new e.Vector3(...pp(n,0)),d);g.add(r);const s=getCilindro(new e.Vector3(...pp(i,0)),new e.Vector3(...pp(y,0)),d);g.add(s),B.position.set(...pp(y/2,0))}const v=l>A/2?-l:-A/2,P=-l>A/2?-l:A/2,T=new e.Vector3(...pp(0,v)),S=new e.Vector3(...pp(0,P)),M=new e.Vector3(...pp(y,v)),D=new e.Vector3(...pp(y,P)),L=getCilindro(T,S,d);g.add(L);const _=getCilindro(M,D,d);return g.add(_),B.userData.updateOrientation=function(e){e&&this.quaternion.copy(e.quaternion)},g.add(B),g.userData.noingombro=!0,"xy"===c?(g.position.set(i+x,r+C,0),g.rotation.z=b):"xz"===c?(g.position.set(i+x,0,r+C),g.rotation.y=-b):"yz"===c&&(g.position.set(0,i+x,r+C),g.rotation.x=b),g.layers.set(h||22),g}function creagizmo(t={}){const n=100*(t.size??1),i=t.picksize??1.6,r={x:t?.colors?.x??16711680,y:t?.colors?.y??65280,z:t?.colors?.z??255,plane:t?.colors?.plane??8388736,rot:t?.colors?.rot??8421504},s=new e.Group;s.name="gizmo";const mat=(t,n=1)=>new e.MeshBasicMaterial({color:t,transparent:n<1,opacity:n,depthWrite:!1,toneMapped:!1,depthTest:!1});function makeaxis(t,r){const s=new e.Group;s.name="ax_"+t;const o=new e.Mesh(new e.CylinderGeometry(.02*n,.02*n,.8*n,8),mat(r));o.position.y=.4*n;const a=new e.Mesh(new e.ConeGeometry(.05*n,.2*n,12),mat(r));a.position.y=n;const A=new e.Mesh(new e.CylinderGeometry(.08*n*i,.08*n*i,1.2*n,6),mat(r,0));return A.position.y=.6*n,s.add(o,a,A),"x"===t&&(s.rotation.z=-Math.PI/2),"z"===t&&(s.rotation.x=Math.PI/2),s.userData={kind:"gizmo-handle",type:"axis",axis:t},s}const o=makeaxis("x",r.x),a=makeaxis("y",r.y),A=makeaxis("z",r.z),l=function makeplane(){const t=new e.Group;t.name="pl_xz";const i=.6*n,s=.25*i,o=.4*n,a=.4*-n,A=new e.Shape;A.moveTo(o-i/2+s,a-i/2),A.lineTo(o+i/2-s,a-i/2),A.quadraticCurveTo(o+i/2,a-i/2,o+i/2,a-i/2+s),A.lineTo(o+i/2,a+i/2-s),A.quadraticCurveTo(o+i/2,a+i/2,o+i/2-s,a+i/2),A.lineTo(o-i/2+s,a+i/2),A.quadraticCurveTo(o-i/2,a+i/2,o-i/2,a+i/2-s),A.lineTo(o-i/2,a-i/2+s),A.quadraticCurveTo(o-i/2,a-i/2,o-i/2+s,a-i/2);const l=new e.ShapeGeometry(A),c=new e.Mesh(l,mat(r.plane,.35));c.rotation.x=-Math.PI/2,c.position.y=.001;const p=new e.Mesh(l,mat(r.plane,0));return p.rotation.copy(c.rotation),p.position.copy(c.position),t.add(c,p),t.userData={kind:"gizmo-handle",type:"plane",plane:"xz"},t}(),c=function makerot(){const t=new e.Group;t.name="rot_y";const i=.9*n*1.5,s=.025*n,o=new e.Mesh(new e.TorusGeometry(i,s,8,32,Math.PI/3),mat(r.rot));o.rotation.x=Math.PI/2;const a=Math.PI/3,A=new e.Mesh(new e.ConeGeometry(.06*n,.15*n,10),mat(r.rot));A.position.set(i*Math.cos(0),0,i*Math.sin(0));let l=new e.Vector3(-Math.sin(0),0,Math.cos(0)).normalize().negate();A.quaternion.setFromUnitVectors(new e.Vector3(0,1,0),l);const c=new e.Mesh(new e.ConeGeometry(.06*n,.15*n,10),mat(r.rot));c.position.set(i*Math.cos(a),0,i*Math.sin(a));let p=new e.Vector3(-Math.sin(a),0,Math.cos(a)).normalize();c.quaternion.setFromUnitVectors(new e.Vector3(0,1,0),p);const h=new e.Mesh(new e.TorusGeometry(i,4*s,6,16,Math.PI/3),mat(r.rot,0));return h.rotation.copy(o.rotation),t.add(o,A,c,h),t.userData={kind:"gizmo-handle",type:"rot",axis:"y"},t.rotation.y=-.08333333333333333*Math.PI,t}();return s.add(o,a,A,l,c),s.userData={kind:"gizmo",handles:{x:o,y:a,z:A,xz:l,roty:c}},s.setpos=e=>s.position.copy(e),s.setvisible=(e={})=>{void 0!==e.x&&(o.visible=e.x),void 0!==e.y&&(a.visible=e.y),void 0!==e.z&&(A.visible=e.z),void 0!==e.xz&&(l.visible=e.xz),void 0!==e.roty&&(c.visible=e.roty)},s}function fillNoise(t,n,i={}){let{scale:r=8,octaves:s=3,persistence:o=.5,seed:a=0,contrast:A=1,color1:l="#000000",color2:c="#ffffff",alpha1:p=1,alpha2:h=1}=i;const u=new e.Color(l),d=new e.Color(c),fade=e=>e*e*e*(e*(6*e-15)+10),lerp=(e,t,n)=>e+(t-e)*n,g=n,f=new Uint16Array(2*g);let m=0|Math.floor(65536*a);for(let e=0;e<g;e++)f[e]=e;for(let e=0;e<g;e++){const t=Math.floor((m^=m<<13,m^=m>>17,m^=m<<5,(m<0?1+~m:m)%65536/65536*g));[f[e],f[t]]=[f[t],f[e]]}for(let e=0;e<g;e++)f[g+e]=f[e];const y=[[1,1],[-1,1],[1,-1],[-1,-1],[1,0],[-1,0],[0,1],[0,-1]];function grad(e,t){const n=f[(f[e%g]+t)%g]%8;return y[n]}function perlin(e,t,n,i){const r=Math.floor(e)%n,s=Math.floor(t)%i,o=e-Math.floor(e),a=t-Math.floor(t),A=grad(r,s),l=grad(r+1,s),c=grad(r,s+1),p=grad(r+1,s+1),h=A[0]*o+A[1]*a,u=l[0]*(o-1)+l[1]*a,d=c[0]*o+c[1]*(a-1),g=p[0]*(o-1)+p[1]*(a-1),f=fade(o),m=fade(a);return lerp(lerp(h,u,f),lerp(d,g,f),m)}let b=1/0,I=-1/0;const x=new Float32Array(n*n);for(let e=0;e<n;e++)for(let t=0;t<n;t++){let i=t/n*r,a=e/n*r,A=1,l=1,c=0,p=0;for(let e=0;e<s;e++){c+=perlin(i*l,a*l,g/l,g/l)*A,p+=A,A*=o,l*=2}let h=c/p;x[e*n+t]=h,h<b&&(b=h),h>I&&(I=h)}const C=1/(I-b);for(let e=0;e<n;e++)for(let i=0;i<n;i++){let r=(x[e*n+i]-b)*C;r=Math.pow(r,A);const s=u.r+(d.r-u.r)*r,o=u.g+(d.g-u.g)*r,a=u.b+(d.b-u.b)*r,l=0,c=4*(e*n+i);t[c]=Math.floor(255*s),t[c+1]=Math.floor(255*o),t[c+2]=Math.floor(255*a),t[c+3]=Math.floor(255*l)}}function texgen(t,n,i=256,r={}){[16,32,64,128,256,512,1024].includes(i)||(i=256);let s=hash(`gen|${n}|${i}|${JSON.stringify(r)}`);if(!t[s]){const o=new Uint8Array(i*i*4);switch(n){case"wood":{let e={...r};e.scale=6+seeder(40,r.seed+"a")/10,e.octaves=r.octaves||3,e.persistence=.5+seeder(50,r.seed+"b")/100,e.rings=2+seeder(200,r.seed+"c")/100,e.distortion=.3+seeder(100,r.seed+"d")/300,e.color1=r.color1||"#442200",e.color2=r.color2||"#ffe0a0",fillNoise(o,i,e)}break;case"marble":{let e={...r};e.scale=r.scale||10,e.octaves=r.octaves||3,e.persistence=r.persistence||.6,e.rings=r.rings||1+seeder(100,r.seed+"m3")/50,e.distortion=r.distortion||.8+seeder(200,r.seed+"m4")/200,e.contrast=r.contrast||1.2,e.color1=r.color1||"#e0e0e0",e.color2=r.color2||"#909090",fillNoise(o,i,e)}break;case"glass":{let e={...r};e.scale=r.scale||32,e.octaves=r.octaves||2,e.persistence=r.persistence||.8,e.contrast=r.contrast||1,e.color1=r.color1||"rgba(255,255,255,0.2)",e.color2=r.color2||"rgba(255,255,255,0.6)",fillNoise(o,i,e)}break;case"gradient":case"pattern":break;default:fillNoise(o,i,r)}const a=new e.DataTexture(o,i,i,e.RGBAFormat);a.needsUpdate=!0,a.wrapS=a.wrapT=e.RepeatWrapping,a.repeat.set(.002,.002),a.center.set(.5,.5),t[s]=a}return t[s]}function getcilindro(t,n,i,r,s,o=wi,a){a||(a={}),Array.isArray(o)||(o=[o]);const A=function cylgeometry(t,n,i,r,s=16){if(!i||!n)return null;let o=hash(`cy${n}|${i}|${r||i}|${s}`);if(!t.geo[o]){const a=new e.CylinderGeometry(r||i,i,n,s);t.geo[o]=a}return t.geo[o]}(t,i,r,s,a.sides||16);let l=new e.Group;switch((n||"").trim().toUpperCase()){case"X":case"L":l.position.set(i/2,0,0),l.rotation.z=Math.PI/2;break;case"Z":case"P":l.position.set(0,0,i/2),l.rotation.x=Math.PI/2;break;default:l.position.set(0,i/2,0)}if(A){if(!a.nolines){let e=edgesfromgeometry(A);l.add(e)}uvswap(A,a.uvswap,!1);const e=o[0]||wi,t=o[1]||e,n=o[2]||e;l.add(getmesh(A,[e,t,n]))}return l}function facesettile(e,t,n,i){if(t>1||n>1){let r=i%(t=t??1);const s=1/t,o=1/(n=n??1),a=r*s,A=1-((i-r)/t+1)*o,l=a+s,c=A+o,p=e.geometry.attributes.uv,h=[[a,c],[l,c],[a,A],[l,A]];for(let e=0;e<p.count;e++)p.setXY(e,h[e][0],h[e][1]);p.needsUpdate=!0}}function pickvariant(e,t,n,i,r,s,o={}){let a,{mat:A,testo:l,matover:c}=o;return A?(a=getface(e,t,n,A,o),c&&(c=c.clone(),c.depthTest=!1,c.depthWrite=!1,a.userData.matover=c)):(l=l||"xx",a=gettarghetta(e,l,t,o)),a.layers.disableAll(),a.layers.set(30),a.userData.pickvariant=!0,a.userData.variant=i,a.userData.value=r,a.userData.tooltip=s,a}function getface(t,n,i,r,s={}){let{repeat:o,order:a,center:A=!1,base:l=!1,billboard:c=!1}=s;const p=hash(`f:${n}|${i}|${o?1:0}|${l?1:0}`);if(!t.geo[p]){const r=new e.PlaneGeometry(n,i);let s=l?-.5:0;const a=r.attributes.uv;if(o)for(let e=0;e<a.count;e++)a.setXY(e,a.getX(e)*n/1e3,a.getY(e)*i/1e3);else{const e=[[0,1],[1,1],[0,0],[1,0]];for(let t=0;t<a.count;t++){const n=e[t];a.setXY(t,n[0]-s,n[1]-s)}}a.needsUpdate=!0,t.geo[p]=r}c&&((r=r.clone()).depthTest=!1,r.depthWrite=!1);const h=new e.Mesh(t.geo[p],r);if(h.name=c?"billboard":"face","number"==typeof a&&(h.renderOrder=a),A||h.position.set(n/2,i/2,0),r?.transparent&&h.layers.set(2),c){h.layers.disableAll(),h.layers.set(30),h.userData.billboard=!0;let t=new e.Quaternion,n=new e.Quaternion;h.onBeforeRender=function(e,i,r){this.getWorldQuaternion(t),this.parent?.getWorldQuaternion(n),this.quaternion.copy(r.quaternion),this.quaternion.premultiply(n.invert())}}return h}function getbox(t,n,i,r,s,o){s&&s.isMaterial||o||(o=s,s=void 0),o||(o={});let{center:a=!1,nolines:A=!1,centerbase:l=!1,px:c=0,py:p=0,pz:h=0}=o;const u=new e.BoxGeometry(n,i,r),d=new e.Group;if(l?d.position.set(0,i/2,0):c||p||h?d.position.set(c||0,p||0,h||0):a||d.position.set(n/2,i/2,r/2),!A||!s){let e=edgesfromgeometry(u);A&&(e.opacity=.1),d.add(e)}return s&&d.add(getmesh(u,s)),d}function getcyl(t,n,i,r,s){s||(s={});let{center:o=!1,nolines:a=!1,segments:A=16,top:l=-1,bottom:c=-1,heightSegments:p=1,openEnded:h=!1,thetaStart:u=0,thetaLength:d=2*Math.PI}=s;l<0&&(l=i),c<0&&(c=i);const g=new e.CylinderGeometry(l,c,n,A,p,h,u,d);uvswap(g,s.uvswap,!1);const f=getmesh(g,r||wi),m=new e.Group;if(m.add(f),m.position.set(0,o?0:n/2,0),!a){let e=edgesfromgeometry(g);m.add(e)}return m}function getsphere(t,n,i,r){r||(r={});let{nolines:s,segmenti:o=16}=r,a=new e.Group;const A=new e.SphereGeometry(n,2*o,o);if(!s){let e=edgesfromgeometry(A);a.add(e)}return a.add(getmesh(A,i||wi)),a}function makeShape(t){const n=new e.Shape;n.moveTo(t[0].x,t[0].y);for(let e=1;e<t.length;e++)n.lineTo(t[e].x,t[e].y);return n.closePath(),n}function getextrude(t,n,i=10,r=[],s=void 0,o={}){s&&s.isMaterial||(o=s,s=void 0),o=o??{};let{stonda:a,sx:A,sy:l,round:c,nolines:p}=o,h=hash(`${JSON.stringify(n)}|${i}|${JSON.stringify(o)}|${JSON.stringify(r)}`);A=A??a??0,l=l??a??0;let u=t.geo[h];if(!u){const s=makeShape(n);r.forEach((t=>s.holes.push(function makePath(t){const n=new e.Path;n.moveTo(t[0].x,t[0].y);for(let e=1;e<t.length;e++)n.lineTo(t[e].x,t[e].y);return n.closePath(),n}(t))));const a=A>0&&l>0;u=new e.ExtrudeGeometry(s,{depth:i,bevelEnabled:a,bevelSize:A,bevelThickness:l,bevelSegments:a?c?3:1:0,curveSegments:a?10:1}),t.geo[h]=u,uvswap(u,o.uvswap,!0)}let d=new e.Group;return d.add(new e.Mesh(u,s||wi)),p||function extrudelines(t,n,i,r,s=3){const makeloop=(t,n)=>{if(!t||t.length<2)return null;const i=t.length,r=new Float32Array(3*(i+1));for(let e=0;e<=i;e++){const s=t[e%i],o=3*e;r[o]=s.x,r[o+1]=s.y,r[o+2]=n}const s=new e.BufferGeometry;return s.setAttribute("position",new e.BufferAttribute(r,3)),new e.Line(s,Bi)},addring=e=>{let n=makeloop(e,-s);n&&(n.layers.set(30),t.add(n)),n=makeloop(e,r+s),n&&(n.layers.set(30),t.add(n))};addring(n);for(const e of i)addring(e)}(d,n,r,i,l),d}function getthorus(t,n,i=.2,r,s){s||(s={});let{center:o,nolines:a,segmenti:A=16,tubi:l=12}=s,c=new e.Group;const p=new e.TorusGeometry(n,i,l,2*A);if(c.position.set(0,o?0:n,0),!a){let e=edgesfromgeometry(p);c.add(e)}return c.add(getmesh(p,r||wi)),c}function getluce(t,n,i="#ffffff",r=1){const s=n.pt;if(!s||!s.length)return null;const o=hash(`${n.key}|${i}|${r}`);if(!t.meshes[o]){const n=makeShape(s),a=new e.ShapeGeometry(n),A=new e.MeshStandardMaterial({color:new e.Color(i),emissive:new e.Color(i),emissiveIntensity:r,toneMapped:!1,transparent:!0,depthWrite:!1,side:e.DoubleSide,polygonOffset:!0,polygonOffsetFactor:-2,polygonOffsetUnits:1}),l=new e.Mesh(a,A);l.layers.set(8),l.userData.isBloom=!0,t.meshes[o]=l,t.mustlight=!0}return t.meshes[o]}function getmarker(t,n,i,r,s,o,a={}){if(n&&i){a||(a={});let{billboard:A,xl:l=0,xa:c=0,xp:p=0,origin:h=0}=a;a.markerid=n,a.marker=i,a.noingombro=!0,a.hideable=!0,a.origin=h||0;let u=new e.Group,d=getface(t,r,s,o,{order:1}),g=n;g.length>7&&(g=".."+g.slice(-6));let f=gettarghetta(t,`#w,${g}`,50,{noSfondo:!0,layer:11,billboard:A,forcey:!0});return d.add(posiziona(f,{sp:11,order:2})),u.add(posiziona(d,{sl:l,sa:c,sp:p})),u.layers.set(28),u.userData.hideable=!0,posiziona(u,a)}}function mergeAttributes(e){let t,n,i,r=-1,s=0;for(let o=0;o<e.length;++o){const a=e[o];if(void 0===t&&(t=a.array.constructor),t!==a.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(void 0===n&&(n=a.itemSize),n!==a.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(void 0===i&&(i=a.normalized),i!==a.normalized)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;if(-1===r&&(r=a.gpuType),r!==a.gpuType)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes."),null;s+=a.count*n}const o=new t(s),a=new B(o,n,i);let A=0;for(let t=0;t<e.length;++t){const i=e[t];if(i.isInterleavedBufferAttribute){const e=A/n;for(let t=0,r=i.count;t<r;t++)for(let r=0;r<n;r++){const n=i.getComponent(t,r);a.setComponent(t+e,r,n)}}else o.set(i.array,A);A+=i.count*n}return void 0!==r&&(a.gpuType=r),a}function mergeVertices(e,t=1e-4){t=Math.max(t,Number.EPSILON);const n={},i=e.getIndex(),r=e.getAttribute("position"),s=i?i.count:r.count;let o=0;const a=Object.keys(e.attributes),A={},l={},c=[],p=["getX","getY","getZ","getW"],h=["setX","setY","setZ","setW"];for(let t=0,n=a.length;t<n;t++){const n=a[t],i=e.attributes[n];A[n]=new i.constructor(new i.array.constructor(i.count*i.itemSize),i.itemSize,i.normalized);const r=e.morphAttributes[n];r&&(l[n]||(l[n]=[]),r.forEach(((e,t)=>{const i=new e.array.constructor(e.count*e.itemSize);l[n][t]=new e.constructor(i,e.itemSize,e.normalized)})))}const u=.5*t,d=Math.log10(1/t),g=Math.pow(10,d),f=u*g;for(let t=0;t<s;t++){const r=i?i.getX(t):t;let s="";for(let t=0,n=a.length;t<n;t++){const n=a[t],i=e.getAttribute(n),o=i.itemSize;for(let e=0;e<o;e++)s+=~~(i[p[e]](r)*g+f)+","}if(s in n)c.push(n[s]);else{for(let t=0,n=a.length;t<n;t++){const n=a[t],i=e.getAttribute(n),s=e.morphAttributes[n],c=i.itemSize,u=A[n],d=l[n];for(let e=0;e<c;e++){const t=p[e],n=h[e];if(u[n](o,i[t](r)),s)for(let e=0,i=s.length;e<i;e++)d[e][n](o,s[e][t](r))}}n[s]=o,c.push(o),o++}}const m=e.clone();for(const t in e.attributes){const e=A[t];if(m.setAttribute(t,new e.constructor(e.array.slice(0,o*e.itemSize),e.itemSize,e.normalized)),t in l)for(let e=0;e<l[t].length;e++){const n=l[t][e];m.morphAttributes[t][e]=new n.constructor(n.array.slice(0,o*n.itemSize),n.itemSize,n.normalized)}}return m.setIndex(c),m}function toTrianglesDrawMode(e,t){if(t===b)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),e;if(t===I||t===x){let n=e.getIndex();if(null===n){const t=[],i=e.getAttribute("position");if(void 0===i)return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),e;for(let e=0;e<i.count;e++)t.push(e);e.setIndex(t),n=e.getIndex()}const i=n.count-2,r=[];if(t===I)for(let e=1;e<=i;e++)r.push(n.getX(0)),r.push(n.getX(e)),r.push(n.getX(e+1));else for(let e=0;e<i;e++)e%2==0?(r.push(n.getX(e)),r.push(n.getX(e+1)),r.push(n.getX(e+2))):(r.push(n.getX(e+2)),r.push(n.getX(e+1)),r.push(n.getX(e)));r.length/3!==i&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const s=e.clone();return s.setIndex(r),s.clearGroups(),s}return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",t),e}function getpannello(t,n,i,r,s,o,a,A){A||(A={});let l,c,p,{r:h,r1:u,r2:d,r3:g,r4:f,b:m,npt:y}=A;u=u||h||0,d=d||h||0,g=g||h||0,f=f||h||0,y=y||2,m=m||0,(m>=i/2||m>=r/2||m>=s/2)&&(m=0),l="L"==(n=n.trim().toUpperCase())[0]?i:"A"==n[0]?r:s,c="L"==n[1]?i:"A"==n[1]?r:s,p="L"==n[2]?i:"A"==n[2]?r:s;let b=new e.Group;if(!A.nolines){let t=edgesfromgeometry(new e.BoxGeometry(i,r,s));t.position.set(i/2,r/2,s/2),b.add(t)}let I=function pannellogeometry(t,n,i,r,s=0,o=0,a=0,A=0,l=0,c=2,p=!1){let h=hash(`pg--${n}|${i}|${r}|${s}|${o}|${a}|${A}|${l}|${c}|${p?1:0}`);if(n-=.01,i-=.01,r-=.01,!t.geo[h]){n-=2*l,i-=2*l,r-=2*l;let u=getshape();const d=[{x:A,y:0},{x:i-s,y:0},{x:i,y:s},{x:i,y:r-o},{x:i-o,y:r},{x:a,y:r},{x:0,y:r-a},{x:0,y:A}];u.addpt(d[0]),u.addpt(d[1]),s&&u.addpt(raccordabezier(d[0],d[1],d[2],d[3],c)),u.addpt(d[2]),u.addpt(d[3]),o&&u.addpt(raccordabezier(d[2],d[3],d[4],d[5],c)),u.addpt(d[4]),u.addpt(d[5]),a&&u.addpt(raccordabezier(d[4],d[5],d[6],d[7],c)),u.addpt(d[6]),u.addpt(d[7]),o&&u.addpt(raccordabezier(d[6],d[7],d[0],d[1],c)),u.removeduplicate(.01);let g=u.pt;const f=new e.Shape;f.moveTo(g[0].x,g[0].y);for(let e=1;e<g.length;e++)f.lineTo(g[e].x,g[e].y);f.lineTo(g[0].x,g[0].y);const m={depth:n,bevelEnabled:l>0,bevelThickness:l,bevelSize:l,bevelSegments:1};let y=new e.ExtrudeGeometry(f,m);y=mergeVertices(y),uvswap(y,p,!0),t.geo[h]=y}return t.geo[h]}(t,l,c,p,u,d,g,f,m,y,!A.uvswap),x=getmesh(I,[a||o||Di,o||Pi]);x.name="pannello",x.layers.set(1);let C=x;return m&&(x.position.set(m,m,m),C=new e.Group,C.add(x)),x=function meshrotate(e,t,n=0,i=0,r=0){switch(e.trim().toUpperCase()){case"LPA":t.rotation.y=Math.PI/2,t.rotation.x=Math.PI,t.position.set(0,r,0);break;case"ALP":t.rotation.x=Math.PI/2,t.position.set(0,n,0);break;case"APL":t.rotation.x=-Math.PI/2,t.rotation.z=-Math.PI/2;break;case"PLA":break;case"PAL":t.rotation.z=Math.PI/2,t.position.set(r,0,0);break;case"LAP":t.rotation.y=Math.PI/2,t.rotation.z=Math.PI/2}return t}(n,C,l,c,p),b.add(x),b}async function getpannello2(e,t,n,i,r,s,o=0){let a;switch((o<0||o>Math.max(n,i,r)/3)&&(o=0),t){case"lap":a=getextrude(e,getshape().fromrect(n-2*o,i-2*o).pt,r-2*o,[],s,{round:o,stonda:o}),a.position.x=o,a.position.z=r-o,a.position.y=i-o,a.rotation.x=Math.PI;break;case"alp":a=getextrude(e,getshape().fromrect(i-2*o,n-2*o).pt,r-2*o,[],s,{round:o,stonda:o}),a.position.x=o,a.position.z=o,a.position.y=i-o,a.rotation.z=-Math.PI/2;break;case"apl":a=getextrude(e,getshape().fromrect(i-2*o,r-2*o).pt,n-2*o,[],s,{round:o,stonda:o}),a.position.x=o,a.position.z=o,a.position.y=o,a.rotation.y=Math.PI/2,a.rotation.z=Math.PI/2;break;case"pal":a=getextrude(e,getshape().fromrect(r-2*o,i-2*o).pt,n-2*o,[],s,{round:o,stonda:o}),a.position.x=o,a.position.z=r-o,a.position.y=o,a.rotation.y=Math.PI/2;break;case"pla":a=getextrude(e,getshape().fromrect(r-2*o,n-2*o).pt,i-2*o,[],s,{round:o,stonda:o}),a.rotation.z=-Math.PI/2,a.rotation.x=-Math.PI/2,a.position.x=o,a.position.z=o,a.position.y=o;break;default:a=getextrude(e,getshape().fromrect(n-2*o,r-2*o).pt,i-2*o,[],s,{round:o,stonda:o}),a.position.x=o,a.position.z=o,a.rotation.x=Math.PI/2,a.position.y=i-o}return a}function earcut(e,t,n=2){const i=t&&t.length,r=i?t[0]*n:e.length;let s=linkedList(e,0,r,n,!0);const o=[];if(!s||s.next===s.prev)return o;let a,A,l;if(i&&(s=function eliminateHoles(e,t,n,i){const r=[];for(let n=0,s=t.length;n<s;n++){const o=linkedList(e,t[n]*i,n<s-1?t[n+1]*i:e.length,i,!1);o===o.next&&(o.steiner=!0),r.push(getLeftmost(o))}r.sort(compareXYSlope);for(let e=0;e<r.length;e++)n=eliminateHole(r[e],n);return n}(e,t,s,n)),e.length>80*n){a=1/0,A=1/0;let t=-1/0,i=-1/0;for(let s=n;s<r;s+=n){const n=e[s],r=e[s+1];n<a&&(a=n),r<A&&(A=r),n>t&&(t=n),r>i&&(i=r)}l=Math.max(t-a,i-A),l=0!==l?32767/l:0}return earcutLinked(s,o,n,a,A,l,0),o}function linkedList(e,t,n,i,r){let s;if(r===function signedArea(e,t,n,i){let r=0;for(let s=t,o=n-i;s<n;s+=i)r+=(e[o]-e[s])*(e[s+1]+e[o+1]),o=s;return r}(e,t,n,i)>0)for(let r=t;r<n;r+=i)s=insertNode(r/i|0,e[r],e[r+1],s);else for(let r=n-i;r>=t;r-=i)s=insertNode(r/i|0,e[r],e[r+1],s);return s&&equals(s,s.next)&&(removeNode(s),s=s.next),s}function filterPoints(e,t){if(!e)return e;t||(t=e);let n,i=e;do{if(n=!1,i.steiner||!equals(i,i.next)&&0!==area(i.prev,i,i.next))i=i.next;else{if(removeNode(i),i=t=i.prev,i===i.next)break;n=!0}}while(n||i!==t);return t}function earcutLinked(e,t,n,i,r,s,o){if(!e)return;!o&&s&&function indexCurve(e,t,n,i){let r=e;do{0===r.z&&(r.z=zOrder(r.x,r.y,t,n,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==e);r.prevZ.nextZ=null,r.prevZ=null,function sortLinked(e){let t,n=1;do{let i,r=e;e=null;let s=null;for(t=0;r;){t++;let o=r,a=0;for(let e=0;e<n&&(a++,o=o.nextZ,o);e++);let A=n;for(;a>0||A>0&&o;)0!==a&&(0===A||!o||r.z<=o.z)?(i=r,r=r.nextZ,a--):(i=o,o=o.nextZ,A--),s?s.nextZ=i:e=i,i.prevZ=s,s=i;r=o}s.nextZ=null,n*=2}while(t>1);return e}(r)}(e,i,r,s);let a=e;for(;e.prev!==e.next;){const A=e.prev,l=e.next;if(s?isEarHashed(e,i,r,s):isEar(e))t.push(A.i,e.i,l.i),removeNode(e),e=l.next,a=l.next;else if((e=l)===a){o?1===o?earcutLinked(e=cureLocalIntersections(filterPoints(e),t),t,n,i,r,s,2):2===o&&splitEarcut(e,t,n,i,r,s):earcutLinked(filterPoints(e),t,n,i,r,s,1);break}}}function isEar(e){const t=e.prev,n=e,i=e.next;if(area(t,n,i)>=0)return!1;const r=t.x,s=n.x,o=i.x,a=t.y,A=n.y,l=i.y,c=Math.min(r,s,o),p=Math.min(a,A,l),h=Math.max(r,s,o),u=Math.max(a,A,l);let d=i.next;for(;d!==t;){if(d.x>=c&&d.x<=h&&d.y>=p&&d.y<=u&&pointInTriangleExceptFirst(r,a,s,A,o,l,d.x,d.y)&&area(d.prev,d,d.next)>=0)return!1;d=d.next}return!0}function isEarHashed(e,t,n,i){const r=e.prev,s=e,o=e.next;if(area(r,s,o)>=0)return!1;const a=r.x,A=s.x,l=o.x,c=r.y,p=s.y,h=o.y,u=Math.min(a,A,l),d=Math.min(c,p,h),g=Math.max(a,A,l),f=Math.max(c,p,h),m=zOrder(u,d,t,n,i),y=zOrder(g,f,t,n,i);let b=e.prevZ,I=e.nextZ;for(;b&&b.z>=m&&I&&I.z<=y;){if(b.x>=u&&b.x<=g&&b.y>=d&&b.y<=f&&b!==r&&b!==o&&pointInTriangleExceptFirst(a,c,A,p,l,h,b.x,b.y)&&area(b.prev,b,b.next)>=0)return!1;if(b=b.prevZ,I.x>=u&&I.x<=g&&I.y>=d&&I.y<=f&&I!==r&&I!==o&&pointInTriangleExceptFirst(a,c,A,p,l,h,I.x,I.y)&&area(I.prev,I,I.next)>=0)return!1;I=I.nextZ}for(;b&&b.z>=m;){if(b.x>=u&&b.x<=g&&b.y>=d&&b.y<=f&&b!==r&&b!==o&&pointInTriangleExceptFirst(a,c,A,p,l,h,b.x,b.y)&&area(b.prev,b,b.next)>=0)return!1;b=b.prevZ}for(;I&&I.z<=y;){if(I.x>=u&&I.x<=g&&I.y>=d&&I.y<=f&&I!==r&&I!==o&&pointInTriangleExceptFirst(a,c,A,p,l,h,I.x,I.y)&&area(I.prev,I,I.next)>=0)return!1;I=I.nextZ}return!0}function cureLocalIntersections(e,t){let n=e;do{const i=n.prev,r=n.next.next;!equals(i,r)&&intersects(i,n,n.next,r)&&locallyInside(i,r)&&locallyInside(r,i)&&(t.push(i.i,n.i,r.i),removeNode(n),removeNode(n.next),n=e=r),n=n.next}while(n!==e);return filterPoints(n)}function splitEarcut(e,t,n,i,r,s){let o=e;do{let e=o.next.next;for(;e!==o.prev;){if(o.i!==e.i&&isValidDiagonal(o,e)){let a=splitPolygon(o,e);return o=filterPoints(o,o.next),a=filterPoints(a,a.next),earcutLinked(o,t,n,i,r,s,0),void earcutLinked(a,t,n,i,r,s,0)}e=e.next}o=o.next}while(o!==e)}function compareXYSlope(e,t){let n=e.x-t.x;if(0===n&&(n=e.y-t.y,0===n)){n=(e.next.y-e.y)/(e.next.x-e.x)-(t.next.y-t.y)/(t.next.x-t.x)}return n}function eliminateHole(e,t){const n=function findHoleBridge(e,t){let n=t;const i=e.x,r=e.y;let s,o=-1/0;if(equals(e,n))return n;do{if(equals(e,n.next))return n.next;if(r<=n.y&&r>=n.next.y&&n.next.y!==n.y){const e=n.x+(r-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(e<=i&&e>o&&(o=e,s=n.x<n.next.x?n:n.next,e===i))return s}n=n.next}while(n!==t);if(!s)return null;const a=s,A=s.x,l=s.y;let c=1/0;n=s;do{if(i>=n.x&&n.x>=A&&i!==n.x&&pointInTriangle(r<l?i:o,r,A,l,r<l?o:i,r,n.x,n.y)){const t=Math.abs(r-n.y)/(i-n.x);locallyInside(n,e)&&(t<c||t===c&&(n.x>s.x||n.x===s.x&§orContainsSector(s,n)))&&(s=n,c=t)}n=n.next}while(n!==a);return s}(e,t);if(!n)return t;const i=splitPolygon(n,e);return filterPoints(i,i.next),filterPoints(n,n.next)}function sectorContainsSector(e,t){return area(e.prev,e,t.prev)<0&&area(t.next,e,e.next)<0}function zOrder(e,t,n,i,r){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-n)*r|0)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-i)*r|0)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function getLeftmost(e){let t=e,n=e;do{(t.x<n.x||t.x===n.x&&t.y<n.y)&&(n=t),t=t.next}while(t!==e);return n}function pointInTriangle(e,t,n,i,r,s,o,a){return(r-o)*(t-a)>=(e-o)*(s-a)&&(e-o)*(i-a)>=(n-o)*(t-a)&&(n-o)*(s-a)>=(r-o)*(i-a)}function pointInTriangleExceptFirst(e,t,n,i,r,s,o,a){return!(e===o&&t===a)&&pointInTriangle(e,t,n,i,r,s,o,a)}function isValidDiagonal(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function intersectsPolygon(e,t){let n=e;do{if(n.i!==e.i&&n.next.i!==e.i&&n.i!==t.i&&n.next.i!==t.i&&intersects(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}(e,t)&&(locallyInside(e,t)&&locallyInside(t,e)&&function middleInside(e,t){let n=e,i=!1;const r=(e.x+t.x)/2,s=(e.y+t.y)/2;do{n.y>s!=n.next.y>s&&n.next.y!==n.y&&r<(n.next.x-n.x)*(s-n.y)/(n.next.y-n.y)+n.x&&(i=!i),n=n.next}while(n!==e);return i}(e,t)&&(area(e.prev,e,t.prev)||area(e,t.prev,t))||equals(e,t)&&area(e.prev,e,e.next)>0&&area(t.prev,t,t.next)>0)}function area(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function equals(e,t){return e.x===t.x&&e.y===t.y}function intersects(e,t,n,i){const r=sign(area(e,t,n)),s=sign(area(e,t,i)),o=sign(area(n,i,e)),a=sign(area(n,i,t));return r!==s&&o!==a||(!(0!==r||!onSegment(e,n,t))||(!(0!==s||!onSegment(e,i,t))||(!(0!==o||!onSegment(n,e,i))||!(0!==a||!onSegment(n,t,i)))))}function onSegment(e,t,n){return t.x<=Math.max(e.x,n.x)&&t.x>=Math.min(e.x,n.x)&&t.y<=Math.max(e.y,n.y)&&t.y>=Math.min(e.y,n.y)}function sign(e){return e>0?1:e<0?-1:0}function locallyInside(e,t){return area(e.prev,e,e.next)<0?area(e,t,e.next)>=0&&area(e,e.prev,t)>=0:area(e,t,e.prev)<0||area(e,e.next,t)<0}function splitPolygon(e,t){const n=createNode(e.i,e.x,e.y),i=createNode(t.i,t.x,t.y),r=e.next,s=t.prev;return e.next=t,t.prev=e,n.next=r,r.prev=n,i.next=n,n.prev=i,s.next=i,i.prev=s,i}function insertNode(e,t,n,i){const r=createNode(e,t,n);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function removeNode(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function createNode(e,t,n){return{i:e,x:t,y:n,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function unifyVertices(e,t,n){const i=new Map,r=[],s=[],o=[];for(let a=0;a<n.length;a++){const A=n[a],l=e[3*A+0],c=e[3*A+1],p=e[3*A+2],h=t[2*A+0],u=t[2*A+1],d=`${l},${c},${p}|${h},${u}`;if(i.has(d))o.push(i.get(d));else{const e=r.length/3;i.set(d,e),r.push(l,c,p),s.push(h,u),o.push(e)}}return{vertices:r,uvs:s,indices:o}}function infoestrudi(e,t,n,i,r){i||(i={}),n||(n=[]);let s=i.p0||0,o=Math.tan(i.coeffbase1*ft||0),a=Math.tan(i.coeffbase2*ft||0),A=t||i.p1||20,l=Math.tan(i.coefftop1*ft||0),c=Math.tan(i.coefftop2*ft||0),{mi:p,ma:h}=e.pt.reduce(((e,t)=>(e.mi.x=Math.min(e.mi.x,t.x),e.mi.y=Math.min(e.mi.y,t.y),e.ma.x=Math.max(e.ma.x,t.x),e.ma.y=Math.max(e.ma.y,t.y),e)),{mi:{x:1e9,y:1e9},ma:{x:-1e9,y:-1e9}}),u=0,d=1e9;function getpars(e){e.z1=getzeta(e.x,e.y,s,o,a,r),e.z2=getzeta(e.x,e.y,A,l,c,r),e.l=Math.abs(e.z2-e.z1)}for(let e of n)getpars(e);getpars(p),getpars(h);let g=[{x:p.x,y:p.y},{x:h.x,y:p.y},{x:h.x,y:h.y},{x:p.x,y:h.y}];for(let e of g)getpars(e),e.l>u&&(u=e.l),e.l<d&&(d=e.l);return{aini:i.coeffbase1||0,aini2:i.coeffbase2||0,afin:i.coefftop1||0,afin2:i.coefftop2||0,pts:n,mi:p,ma:h,rect:g,dimx:h.x-p.x,dimy:h.y-p.y,lnom:A-s,lmax:u,lmin:d,lmed:(u+d)/2}}function getzeta(e,t,n,i,r,s,o=!1){let a=e*i+t*r+n;if(s){let e=s.xfromy(-t,0,!0);o?a-=e:a=e}return a}function sidegeomfromshapes(t,n,i,r,s=!1,o=!1,a=!1){if(i&&r){if(i.length!==r.length)throw new Error("shapes with different length");if(i.length<2)throw new Error("I percorsi devono contenere almeno due punti ciascuno.");if(!t.geo[n]){const A=[],l=[],c=[],p=i.length,addpts=e=>{for(const t of e)A.push(t.x,t.y,t.z),a?l.push(t.v/1e3,t.u/1e3):l.push(t.u/1e3,t.v/1e3)},equalpos=(e,t)=>e.x===t.x&&e.y===t.y&&e.z===t.z,addindexquad=(e,t,n,i)=>{s?c.push(e,n,t,n,i,t):c.push(e,t,n,n,t,i)};addpts(i),addpts(r);for(let e=0;e<p-1;e++){const t=e+1;equalpos(i[e],i[t])||addindexquad(e,t,e+p,t+p)}const h=new e.BufferGeometry;if(o){let t=unifyVertices(A,l,c);h.setAttribute("position",new e.Float32BufferAttribute(t.vertices,3)),h.setAttribute("uv",new e.Float32BufferAttribute(t.uvs,2)),h.setIndex(t.indices)}else h.setAttribute("position",new e.Float32BufferAttribute(A,3)),h.setAttribute("uv",new e.Float32BufferAttribute(l,2)),h.setIndex(c);h.computeVertexNormals(),h.computeTangents?.(),t.geo[n]=h}return t.geo[n]}}function bottomgeomfromshape(t,n,i,r,s=0,o=0,a=0,A=null,l=!1,c=!1){let p=`bg:${s}|${o}${a}|${i.key}|${n}|${A?.key||""}|${c?1:0}`;for(let h of r)p=`${p}|${h.key}`;if(p=hash(p),!t.geo[p]){let u,d=[],g=[],f=i.pt.length;d=i.vec;const m=new e.BufferGeometry,y=[],b=[],I=[];function addvertexes(e,t){let i=y.length/3;for(let i=0;i<e.length;i++){const r=e[i],l=t[2*r],p=-t[2*r+1],h=getzeta(l,p,s,o,a,A,n);y.push(l,p,h),c?b.push(p/1e3,l/1e3):b.push(l/1e3,p/1e3)}for(let t=0;t<e.length;t+=3)n?I.push(t+i,t+i+2,t+i+1):I.push(t+i,t+i+1,t+i+2)}if(A){let x=i.sliceony(A);for(let C of x){let B=C.flatMap((e=>[e.x,e.y]));addvertexes(earcut(B,[]),B)}}else if(Array.isArray(r)&&r.length){for(let E of r)g.push(f),f+=E.pt.length,d=[...d,...E.vec];u=earcut(d,g),addvertexes(u,d)}else u=earcut(d),addvertexes(u,d);if(l){let w=unifyVertices(y,b,I);m.setAttribute("position",new e.Float32BufferAttribute(w.vertices,3)),m.setAttribute("uv",new e.Float32BufferAttribute(w.uvs,2)),m.setIndex(w.indices)}else m.setAttribute("position",new e.Float32BufferAttribute(y,3)),m.setAttribute("uv",new e.Float32BufferAttribute(b,2)),m.setIndex(I);m.computeVertexNormals(),m.computeTangents?.(),t.geo[p]=m}return t.geo[p]}function estrusorotate(e,t,n=0){switch(e.trim().toUpperCase().slice(0,1)){case"A":t.rotation.x=-Math.PI/2;break;case"L":t.rotation.y=Math.PI/2,t.rotation.z=Math.PI;break;case"P":t.rotation.z=Math.PI/2}return t}function estruso(t,n,i,r,s,o,a){a||(a={}),o||(o=[]),Array.isArray(o)||(o=[o,o,o]);let A=a.p0||0,l=Math.tan(a.coeffbase1*ft||0),c=Math.tan(a.coeffbase2*ft||0),p=i||a.p1||20,h=Math.tan(a.coefftop1*ft||0),u=Math.tan(a.coefftop2*ft||0),d=a.shapetop,g=a.shapebase||a.shapebottom;d&&(u=0),g&&(u=0);let f=g?g.key:"",m=d?d.key:"",y=a.notopholes||!1,b=a.nobottomholes||a.nobaseholes||!1,I=a.invert||!1,x=a.open||!1,C=new e.Group;if(r){if(!a.nobase){let e=s;b&&(e=Array.isArray(b)?e.filter(((e,t)=>!b[t])):[]);let n=bottomgeomfromshape(t,!a.notop,r,x?[]:e,A,l,c,g,!1,a.uvswap);a.nolines||C.add(edgesfromgeometry(n)),C.add(getmesh(n,o[0]||wi))}if(!a.notop){let e=s;y&&(e=Array.isArray(y)?e.filter(((e,t)=>!y[t])):[]);let n=bottomgeomfromshape(t,!1,r,x?[]:e,p,h,u,d,!1,a.uvswap);C.add(getmesh(n,o[1]||o[0]||wi)),a.nolines||C.add(edgesfromgeometry(n))}if(!a.nosides){let e=r.to3d(0,A,l,-c,x,g,!I),n=r.to3d(1,p,h,-u,x,d,I),i=`${r.key}${I?1:0}|${A}|${p}|${l}|${c||f}|${h}|${u||m}|${x}|${a.wvswap?1:0}`,B=sidegeomfromshapes(t,i,e,n,!1,!1,a.uvswap);if(a.nolines||a.nosidelines||C.add(edgesfromgeometry(B)),C.add(getmesh(B,o[2]||o[0]||wi)),s&&!x)for(let r=0;r<s.length;r++){let d=s[r];if(Array.isArray(y)){if(y[r])continue}else if(y)continue;if(Array.isArray(b)){if(b[r])continue}else if(b)continue;e=d.to3d(0,A,l,c),n=d.to3d(0,p,h,u),i=`${d.key}|${A}|${p}|${l}|${c}|${h}|${u}`;let g=sidegeomfromshapes(t,i,e,n,!0);a.nolines||a.nosidelines||C.add(edgesfromgeometry(g)),C.add(getmesh(g,o[3]||o[0]||wi))}}return estrusorotate(n,C,i)}return C}function revolve(t,n,i,r,s){s||(s={});let o=s.segmenti??12,a=hash(`rev|${n.key}|${i}|${o}|${s?.uvswap}`),A=t.geo[a],l=new e.Group;if(!A){const i=n.pt.map((t=>new e.Vector2(t.x,t.y)));A=new e.LatheGeometry(i,o,0,2*Math.PI),uvswap(A,s.uvswap,!0),t.geo[a]=A}const c=new e.Mesh(A,r);return l.add(c),s.nolines||s.nosidelines||l.add(edgesfromgeometry(A)),l}function estrusopat(t,n,i,r,s,o,a){a||(a={});let A=a.invert;o||(o=[]);let l=a.open,c=a.closepat;if(!i.pt?.length)return;let p=s.to3d(0,0,0,0,l),h=new e.Group;if(!a.nobase&&!a.open&&!c){let n=new e.Group,A=angle3point(r[0],i.pt[0],i.pt[1])+Math.PI/2,l=bottomgeomfromshape(t,!1,s,[],0,-Math.tan(A),0,null,!1,a.uvswap);n.add(getmesh(l,o[0]||wi)),n.add(edgesfromgeometry(l));let c=i.infosegmento(0,!0);h.add(posiziona(n,{sl:c.x,sp:c.y,sa:0,ay:90-c.ang}))}if(!a.notop&&!a.open&&!c){let n=new e.Group,A=-(angle3point(i.pt[i.npt-2],i.pt[i.npt-1],r[i.npt-1])+Math.PI/2),l=bottomgeomfromshape(t,!0,s,[],0,-Math.tan(A),0,null,!1,a.uvswap);n.add(getmesh(l,o[1]||o[0]||wi)),n.add(edgesfromgeometry(l));let c=i.infosegmento(i.pt.length-1,!0);h.add(posiziona(n,{sl:c.x,sp:c.y,sa:0,ay:90-c.ang}))}if(!a.nosides){const n=function sidegeomfrompat(t,n,i,r,s,o,a=!1){let A=`bsg:${n.key}|${i.key}|${s}|${o}|${a}`;if(i.npt==r.length){if(A=hash(A),!t.geo[A]){const l=[],c=[],p=[],h=n.length,equalpos=(e,t)=>e.x===t.x&&e.y===t.y&&e.z===t.z;let u=0,d=i.pt,g=i.npt;const f=.001,addpts=(t,n,i,r)=>{for(const s of t){let t=new e.Vector3(s.x,s.y,s.x*r);t.applyMatrix4(n),l.push(t.x,t.y,t.z),a?c.push(s.u*f,(s.v+i)*f):c.push((s.v+i)*f,s.u*f)}};let m=g;for(let t=0;t<g;t++){let s;s=t<g-1?angle3point(r[t],d[t],d[t+1])+Math.PI/2:-(angle3point(d[t-1],d[t],r[t])+Math.PI/2);let o=-Math.tan(s),a=i.infosegmento(t,!0),A=new e.Object3D;A.position.set(a.x,0,a.y),A.rotation.set(0,(90-a.ang)*ft,0),A.updateMatrix(),addpts(n,A.matrix,u,o),u+=a.l}if(s){let t=i.infosegmento(0,!0),s=new e.Object3D;s.position.set(t.x,0,t.y),s.rotation.set(0,(90-t.ang)*ft,0);let o=angle3point(d[g-1],d[0],r[0])+Math.PI/2,a=-Math.tan(o);s.updateMatrix(),addpts(n,s.matrix,u,a),u+=t.l,m++}for(let e=0;e<m-1;e++)for(let t=0;t<h-1;t++){const addindexquad=(e,t,n,i)=>{o?p.push(e,n,t,n,i,t):p.push(e,t,n,n,t,i)},i=t+1;equalpos(n[t],n[i])||addindexquad(t+e*h,i+e*h,t+(e+1)*h,i+(e+1)*h)}const y=new e.BufferGeometry;y.setAttribute("position",new e.Float32BufferAttribute(l,3)),y.setAttribute("uv",new e.Float32BufferAttribute(c,2)),y.setIndex(p),y.computeVertexNormals(),y.computeTangents?.(),t[A]=y}return t[A]}}(t,p,i,r,c?1:0,A?1:0,a.uvswap);n&&(a.nolines||a.nosidelines||h.add(edgesfromgeometry(n)),h.add(getmesh(n,o[2]||o[0]||wi)))}return estrusorotate(n,h,0)}async function spritemat(t,n){try{let i={transparent:!0,depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1};if(n.startsWith("#"))i.color=n;else{let e=await t.tex(n,1e3,1e3);e?i.map=e:i.color="black"}return new e.SpriteMaterial(i)}catch(e){return wi}}function getsprite0(t,n,i,r,s,o={}){o||(o={});let{size:a=50,pick:A=!1,screen:l=!1,sizex:c,sizey:p}=o;const h=new e.Sprite(s);h.position.set(0,0,0),h.userData.issprite=!0,h.userData.ispunto=t,h.userData.ispick=A,h.userData.isScreen=l,h.renderOrder=999,h.layers.set(29),h.name=t?"_punto":"_sprite";let u=new e.Group;return u.position.set(n,i,r),u.scale.set(c||a,p||c||a,1),u.add(h),u.traverse((e=>{e.material&&(e.material.depthTest=!1,e.material.depthWrite=!1)})),u.renderOrder=999,u}async function getpunto(t,n,i,r,s="yellow",o){o||(o={size:20}),o.screen=!0;const a=await function createCircleTexture(t,n=64,i="rgba(255,0,0,1)"){const r=`ct|${n}|${i}`;if(!t.textures[r]){const s=document.createElement("canvas");s.width=s.height=n;const o=s.getContext("2d"),a=n/2;o.clearRect(0,0,n,n),o.fillStyle=i,o.beginPath(),o.arc(a,a,a,0,2*Math.PI),o.fill();const A=new e.CanvasTexture(s);A.needsUpdate=!0,t.textures[r]=A}return t.textures[r]}(t,64,s);return getsprite0(!0,n,i,r,new e.SpriteMaterial({map:a,transparent:!0,fog:!1,toneMapped:!1}),o)}function getsprite(e,t,n,i,r,s={}){return getsprite0(!1,t,n,i,r,s)}class GLTFLoader extends E{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register((function(e){return new GLTFMaterialsClearcoatExtension(e)})),this.register((function(e){return new GLTFMaterialsDispersionExtension(e)})),this.register((function(e){return new GLTFTextureBasisUExtension(e)})),this.register((function(e){return new GLTFTextureWebPExtension(e)})),this.register((function(e){return new GLTFTextureAVIFExtension(e)})),this.register((function(e){return new GLTFMaterialsSheenExtension(e)})),this.register((function(e){return new GLTFMaterialsTransmissionExtension(e)})),this.register((function(e){return new GLTFMaterialsVolumeExtension(e)})),this.register((function(e){return new GLTFMaterialsIorExtension(e)})),this.register((function(e){return new GLTFMaterialsEmissiveStrengthExtension(e)})),this.register((function(e){return new GLTFMaterialsSpecularExtension(e)})),this.register((function(e){return new GLTFMaterialsIridescenceExtension(e)})),this.register((function(e){return new GLTFMaterialsAnisotropyExtension(e)})),this.register((function(e){return new GLTFMaterialsBumpExtension(e)})),this.register((function(e){return new GLTFLightsExtension(e)})),this.register((function(e){return new GLTFMeshoptCompression(e)})),this.register((function(e){return new GLTFMeshGpuInstancing(e)}))}load(e,t,n,i){const r=this;let s;if(""!==this.resourcePath)s=this.resourcePath;else if(""!==this.path){const t=w.extractUrlBase(e);s=w.resolveURL(t,this.path)}else s=w.extractUrlBase(e);this.manager.itemStart(e);const _onError=function(t){i?i(t):console.error(t),r.manager.itemError(e),r.manager.itemEnd(e)},o=new v(this.manager);o.setPath(this.path),o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,(function(n){try{r.parse(n,s,(function(n){t(n),r.manager.itemEnd(e)}),_onError)}catch(e){_onError(e)}}),n,_onError)}setDRACOLoader(e){return this.dracoLoader=e,this}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return-1===this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.push(e),this}unregister(e){return-1!==this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,n,i){let r;const s={},o={},a=new TextDecoder;if("string"==typeof e)r=JSON.parse(e);else if(e instanceof ArrayBuffer){if(a.decode(new Uint8Array(e,0,4))===Gi){try{s[Oi.KHR_BINARY_GLTF]=new GLTFBinaryExtension(e)}catch(e){return void(i&&i(e))}r=JSON.parse(s[Oi.KHR_BINARY_GLTF].content)}else r=JSON.parse(a.decode(e))}else r=e;if(void 0===r.asset||r.asset.version[0]<2)return void(i&&i(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported.")));const A=new GLTFParser(r,{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 e=0;e<this.pluginCallbacks.length;e++){const t=this.pluginCallbacks[e](A);t.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),o[t.name]=t,s[t.name]=!0}if(r.extensionsUsed)for(let e=0;e<r.extensionsUsed.length;++e){const t=r.extensionsUsed[e],n=r.extensionsRequired||[];switch(t){case Oi.KHR_MATERIALS_UNLIT:s[t]=new GLTFMaterialsUnlitExtension;break;case Oi.KHR_DRACO_MESH_COMPRESSION:s[t]=new GLTFDracoMeshCompressionExtension(r,this.dracoLoader);break;case Oi.KHR_TEXTURE_TRANSFORM:s[t]=new GLTFTextureTransformExtension;break;case Oi.KHR_MESH_QUANTIZATION:s[t]=new GLTFMeshQuantizationExtension;break;default:n.indexOf(t)>=0&&void 0===o[t]&&console.warn('THREE.GLTFLoader: Unknown extension "'+t+'".')}}A.setExtensions(s),A.setPlugins(o),A.parse(n,i)}parseAsync(e,t){const n=this;return new Promise((function(i,r){n.parse(e,t,i,r)}))}}function GLTFRegistry(){let e={};return{get:function(t){return e[t]},add:function(t,n){e[t]=n},remove:function(t){delete e[t]},removeAll:function(){e={}}}}const Oi={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class GLTFLightsExtension{constructor(e){this.parser=e,this.name=Oi.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let n=0,i=t.length;n<i;n++){const i=t[n];i.extensions&&i.extensions[this.name]&&void 0!==i.extensions[this.name].light&&e._addNodeRef(this.cache,i.extensions[this.name].light)}}_loadLight(e){const t=this.parser,n="light:"+e;let i=t.cache.get(n);if(i)return i;const r=t.json,s=((r.extensions&&r.extensions[this.name]||{}).lights||[])[e];let o;const a=new T(16777215);void 0!==s.color&&a.setRGB(s.color[0],s.color[1],s.color[2],S);const A=void 0!==s.range?s.range:0;switch(s.type){case"directional":o=new _(a),o.target.position.set(0,0,-1),o.add(o.target);break;case"point":o=new L(a),o.distance=A;break;case"spot":o=new D(a),o.distance=A,s.spot=s.spot||{},s.spot.innerConeAngle=void 0!==s.spot.innerConeAngle?s.spot.innerConeAngle:0,s.spot.outerConeAngle=void 0!==s.spot.outerConeAngle?s.spot.outerConeAngle:Math.PI/4,o.angle=s.spot.outerConeAngle,o.penumbra=1-s.spot.innerConeAngle/s.spot.outerConeAngle,o.target.position.set(0,0,-1),o.add(o.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+s.type)}return o.position.set(0,0,0),assignExtrasToUserData(o,s),void 0!==s.intensity&&(o.intensity=s.intensity),o.name=t.createUniqueName(s.name||"light_"+e),i=Promise.resolve(o),t.cache.add(n,i),i}getDependency(e,t){if("light"===e)return this._loadLight(t)}createNodeAttachment(e){const t=this,n=this.parser,i=n.json.nodes[e],r=(i.extensions&&i.extensions[this.name]||{}).light;return void 0===r?null:this._loadLight(r).then((function(e){return n._getNodeRef(t.cache,r,e)}))}}class GLTFMaterialsUnlitExtension{constructor(){this.name=Oi.KHR_MATERIALS_UNLIT}getMaterialType(){return ne}extendParams(e,t,n){const i=[];e.color=new T(1,1,1),e.opacity=1;const r=t.pbrMetallicRoughness;if(r){if(Array.isArray(r.baseColorFactor)){const t=r.baseColorFactor;e.color.setRGB(t[0],t[1],t[2],S),e.opacity=t[3]}void 0!==r.baseColorTexture&&i.push(n.assignTexture(e,"map",r.baseColorTexture,M))}return Promise.all(i)}}class GLTFMaterialsEmissiveStrengthExtension{constructor(e){this.parser=e,this.name=Oi.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const n=this.parser.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=n.extensions[this.name].emissiveStrength;return void 0!==i&&(t.emissiveIntensity=i),Promise.resolve()}}class GLTFMaterialsClearcoatExtension{constructor(e){this.parser=e,this.name=Oi.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?P:null}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],o=i.extensions[this.name];if(void 0!==o.clearcoatFactor&&(t.clearcoat=o.clearcoatFactor),void 0!==o.clearcoatTexture&&s.push(n.assignTexture(t,"clearcoatMap",o.clearcoatTexture)),void 0!==o.clearcoatRoughnessFactor&&(t.clearcoatRoughness=o.clearcoatRoughnessFactor),void 0!==o.clearcoatRoughnessTexture&&s.push(n.assignTexture(t,"clearcoatRoughnessMap",o.clearcoatRoughnessTexture)),void 0!==o.clearcoatNormalTexture&&(s.push(n.assignTexture(t,"clearcoatNormalMap",o.clearcoatNormalTexture)),void 0!==o.clearcoatNormalTexture.scale)){const e=o.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new r(e,e)}return Promise.all(s)}}class GLTFMaterialsDispersionExtension{constructor(e){this.parser=e,this.name=Oi.KHR_MATERIALS_DISPERSION}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?P:null}extendMaterialParams(e,t){const n=this.parser.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=n.extensions[this.name];return t.dispersion=void 0!==i.dispersion?i.dispersion:0,Promise.resolve()}}class GLTFMaterialsIridescenceExtension{constructor(e){this.parser=e,this.name=Oi.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?P:null}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[],s=i.extensions[this.name];return void 0!==s.iridescenceFactor&&(t.iridescence=s.iridescenceFactor),void 0!==s.iridescenceTexture&&r.push(n.assignTexture(t,"iridescenceMap",s.iridescenceTexture)),void 0!==s.iridescenceIor&&(t.iridescenceIOR=s.iridescenceIor),void 0===t.iridescenceThicknessRange&&(t.iridescenceThicknessRange=[100,400]),void 0!==s.iridescenceThicknessMinimum&&(t.iridescenceThicknessRange[0]=s.iridescenceThicknessMinimum),void 0!==s.iridescenceThicknessMaximum&&(t.iridescenceThicknessRange[1]=s.iridescenceThicknessMaximum),void 0!==s.iridescenceThicknessTexture&&r.push(n.assignTexture(t,"iridescenceThicknessMap",s.iridescenceThicknessTexture)),Promise.all(r)}}class GLTFMaterialsSheenExtension{constructor(e){this.parser=e,this.name=Oi.KHR_MATERIALS_SHEEN}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?P:null}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[];t.sheenColor=new T(0,0,0),t.sheenRoughness=0,t.sheen=1;const s=i.extensions[this.name];if(void 0!==s.sheenColorFactor){const e=s.sheenColorFactor;t.sheenColor.setRGB(e[0],e[1],e[2],S)}return void 0!==s.sheenRoughnessFactor&&(t.sheenRoughness=s.sheenRoughnessFactor),void 0!==s.sheenColorTexture&&r.push(n.assignTexture(t,"sheenColorMap",s.sheenColorTexture,M)),void 0!==s.sheenRoughnessTexture&&r.push(n.assignTexture(t,"sheenRoughnessMap",s.sheenRoughnessTexture)),Promise.all(r)}}class GLTFMaterialsTransmissionExtension{constructor(e){this.parser=e,this.name=Oi.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?P:null}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[],s=i.extensions[this.name];return void 0!==s.transmissionFactor&&(t.transmission=s.transmissionFactor),void 0!==s.transmissionTexture&&r.push(n.assignTexture(t,"transmissionMap",s.transmissionTexture)),Promise.all(r)}}class GLTFMaterialsVolumeExtension{constructor(e){this.parser=e,this.name=Oi.KHR_MATERIALS_VOLUME}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?P:null}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[],s=i.extensions[this.name];t.thickness=void 0!==s.thicknessFactor?s.thicknessFactor:0,void 0!==s.thicknessTexture&&r.push(n.assignTexture(t,"thicknessMap",s.thicknessTexture)),t.attenuationDistance=s.attenuationDistance||1/0;const o=s.attenuationColor||[1,1,1];return t.attenuationColor=(new T).setRGB(o[0],o[1],o[2],S),Promise.all(r)}}class GLTFMaterialsIorExtension{constructor(e){this.parser=e,this.name=Oi.KHR_MATERIALS_IOR}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?P:null}extendMaterialParams(e,t){const n=this.parser.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=n.extensions[this.name];return t.ior=void 0!==i.ior?i.ior:1.5,Promise.resolve()}}class GLTFMaterialsSpecularExtension{constructor(e){this.parser=e,this.name=Oi.KHR_MATERIALS_SPECULAR}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?P:null}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[],s=i.extensions[this.name];t.specularIntensity=void 0!==s.specularFactor?s.specularFactor:1,void 0!==s.specularTexture&&r.push(n.assignTexture(t,"specularIntensityMap",s.specularTexture));const o=s.specularColorFactor||[1,1,1];return t.specularColor=(new T).setRGB(o[0],o[1],o[2],S),void 0!==s.specularColorTexture&&r.push(n.assignTexture(t,"specularColorMap",s.specularColorTexture,M)),Promise.all(r)}}class GLTFMaterialsBumpExtension{constructor(e){this.parser=e,this.name=Oi.EXT_MATERIALS_BUMP}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?P:null}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[],s=i.extensions[this.name];return t.bumpScale=void 0!==s.bumpFactor?s.bumpFactor:1,void 0!==s.bumpTexture&&r.push(n.assignTexture(t,"bumpMap",s.bumpTexture)),Promise.all(r)}}class GLTFMaterialsAnisotropyExtension{constructor(e){this.parser=e,this.name=Oi.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?P:null}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[],s=i.extensions[this.name];return void 0!==s.anisotropyStrength&&(t.anisotropy=s.anisotropyStrength),void 0!==s.anisotropyRotation&&(t.anisotropyRotation=s.anisotropyRotation),void 0!==s.anisotropyTexture&&r.push(n.assignTexture(t,"anisotropyMap",s.anisotropyTexture)),Promise.all(r)}}class GLTFTextureBasisUExtension{constructor(e){this.parser=e,this.name=Oi.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,n=t.json,i=n.textures[e];if(!i.extensions||!i.extensions[this.name])return null;const r=i.extensions[this.name],s=t.options.ktx2Loader;if(!s){if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,r.source,s)}}class GLTFTextureWebPExtension{constructor(e){this.parser=e,this.name=Oi.EXT_TEXTURE_WEBP}loadTexture(e){const t=this.name,n=this.parser,i=n.json,r=i.textures[e];if(!r.extensions||!r.extensions[t])return null;const s=r.extensions[t],o=i.images[s.source];let a=n.textureLoader;if(o.uri){const e=n.options.manager.getHandler(o.uri);null!==e&&(a=e)}return n.loadTextureImage(e,s.source,a)}}class GLTFTextureAVIFExtension{constructor(e){this.parser=e,this.name=Oi.EXT_TEXTURE_AVIF}loadTexture(e){const t=this.name,n=this.parser,i=n.json,r=i.textures[e];if(!r.extensions||!r.extensions[t])return null;const s=r.extensions[t],o=i.images[s.source];let a=n.textureLoader;if(o.uri){const e=n.options.manager.getHandler(o.uri);null!==e&&(a=e)}return n.loadTextureImage(e,s.source,a)}}class GLTFMeshoptCompression{constructor(e){this.name=Oi.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 e=n.extensions[this.name],i=this.parser.getDependency("buffer",e.buffer),r=this.parser.options.meshoptDecoder;if(!r||!r.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 i.then((function(t){const n=e.byteOffset||0,i=e.byteLength||0,s=e.count,o=e.byteStride,a=new Uint8Array(t,n,i);return r.decodeGltfBufferAsync?r.decodeGltfBufferAsync(s,o,a,e.mode,e.filter).then((function(e){return e.buffer})):r.ready.then((function(){const t=new ArrayBuffer(s*o);return r.decodeGltfBuffer(new Uint8Array(t),s,o,a,e.mode,e.filter),t}))}))}return null}}class GLTFMeshGpuInstancing{constructor(e){this.name=Oi.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]||void 0===n.mesh)return null;const i=t.meshes[n.mesh];for(const e of i.primitives)if(e.mode!==Hi.TRIANGLES&&e.mode!==Hi.TRIANGLE_STRIP&&e.mode!==Hi.TRIANGLE_FAN&&void 0!==e.mode)return null;const r=n.extensions[this.name].attributes,s=[],o={};for(const e in r)s.push(this.parser.getDependency("accessor",r[e]).then((t=>(o[e]=t,o[e]))));return s.length<1?null:(s.push(this.parser.createNodeMesh(e)),Promise.all(s).then((e=>{const t=e.pop(),n=t.isGroup?t.children:[t],i=e[0].count,r=[];for(const e of n){const t=new m,n=new u,s=new F,a=new u(1,1,1),A=new k(e.geometry,e.material,i);for(let e=0;e<i;e++)o.TRANSLATION&&n.fromBufferAttribute(o.TRANSLATION,e),o.ROTATION&&s.fromBufferAttribute(o.ROTATION,e),o.SCALE&&a.fromBufferAttribute(o.SCALE,e),A.setMatrixAt(e,t.compose(n,s,a));for(const t in o)if("_COLOR_0"===t){const e=o[t];A.instanceColor=new R(e.array,e.itemSize,e.normalized)}else"TRANSLATION"!==t&&"ROTATION"!==t&&"SCALE"!==t&&e.geometry.setAttribute(t,o[t]);N.prototype.copy.call(A,e),this.parser.assignFinalMaterial(A),r.push(A)}return t.isGroup?(t.clear(),t.add(...r),t):r[0]})))}}const Gi="glTF",Ui=1313821514,Yi=5130562;class GLTFBinaryExtension{constructor(e){this.name=Oi.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,12),n=new TextDecoder;if(this.header={magic:n.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==Gi)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const i=this.header.length-12,r=new DataView(e,12);let s=0;for(;s<i;){const t=r.getUint32(s,!0);s+=4;const i=r.getUint32(s,!0);if(s+=4,i===Ui){const i=new Uint8Array(e,12+s,t);this.content=n.decode(i)}else if(i===Yi){const n=12+s;this.body=e.slice(n,n+t)}s+=t}if(null===this.content)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class GLTFDracoMeshCompressionExtension{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=Oi.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const n=this.json,i=this.dracoLoader,r=e.extensions[this.name].bufferView,s=e.extensions[this.name].attributes,o={},a={},A={};for(const e in s){const t=Ji[e]||e.toLowerCase();o[t]=s[e]}for(const t in e.attributes){const i=Ji[t]||t.toLowerCase();if(void 0!==s[t]){const r=n.accessors[e.attributes[t]],s=Xi[r.componentType];A[i]=s.name,a[i]=!0===r.normalized}}return t.getDependency("bufferView",r).then((function(e){return new Promise((function(t,n){i.decodeDracoFile(e,(function(e){for(const t in e.attributes){const n=e.attributes[t],i=a[t];void 0!==i&&(n.normalized=i)}t(e)}),o,A,S,n)}))}))}}class GLTFTextureTransformExtension{constructor(){this.name=Oi.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){return void 0!==t.texCoord&&t.texCoord!==e.channel||void 0!==t.offset||void 0!==t.rotation||void 0!==t.scale?(e=e.clone(),void 0!==t.texCoord&&(e.channel=t.texCoord),void 0!==t.offset&&e.offset.fromArray(t.offset),void 0!==t.rotation&&(e.rotation=t.rotation),void 0!==t.scale&&e.repeat.fromArray(t.scale),e.needsUpdate=!0,e):e}}class GLTFMeshQuantizationExtension{constructor(){this.name=Oi.KHR_MESH_QUANTIZATION}}class GLTFCubicSplineInterpolant extends Be{constructor(e,t,n,i){super(e,t,n,i)}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,r=e*i*3+i;for(let e=0;e!==i;e++)t[e]=n[r+e];return t}interpolate_(e,t,n,i){const r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=2*o,A=3*o,l=i-t,c=(n-t)/l,p=c*c,h=p*c,u=e*A,d=u-A,g=-2*h+3*p,f=h-p,m=1-g,y=f-p+c;for(let e=0;e!==o;e++){const t=s[d+e+o],n=s[d+e+a]*l,i=s[u+e+o],A=s[u+e]*l;r[e]=m*t+y*n+g*i+f*A}return r}}const zi=new F;class GLTFCubicSplineQuaternionInterpolant extends GLTFCubicSplineInterpolant{interpolate_(e,t,n,i){const r=super.interpolate_(e,t,n,i);return zi.fromArray(r).normalize().toArray(r),r}}const Hi={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},Xi={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},qi={9728:j,9729:q,9984:X,9985:H,9986:z,9987:Y},ji={33071:V,33648:J,10497:W},Wi={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Ji={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},Vi={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},Ki={CUBICSPLINE:void 0,LINEAR:fe,STEP:ge},Zi="OPAQUE",$i="MASK",er="BLEND";function addUnknownExtensionsToUserData(e,t,n){for(const i in n.extensions)void 0===e[i]&&(t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[i]=n.extensions[i])}function assignExtrasToUserData(e,t){void 0!==t.extras&&("object"==typeof t.extras?Object.assign(e.userData,t.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+t.extras))}function updateMorphTargets(e,t){if(e.updateMorphTargets(),void 0!==t.weights)for(let n=0,i=t.weights.length;n<i;n++)e.morphTargetInfluences[n]=t.weights[n];if(t.extras&&Array.isArray(t.extras.targetNames)){const n=t.extras.targetNames;if(e.morphTargetInfluences.length===n.length){e.morphTargetDictionary={};for(let t=0,i=n.length;t<i;t++)e.morphTargetDictionary[n[t]]=t}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function createPrimitiveKey(e){let t;const n=e.extensions&&e.extensions[Oi.KHR_DRACO_MESH_COMPRESSION];if(t=n?"draco:"+n.bufferView+":"+n.indices+":"+createAttributesKey(n.attributes):e.indices+":"+createAttributesKey(e.attributes)+":"+e.mode,void 0!==e.targets)for(let n=0,i=e.targets.length;n<i;n++)t+=":"+createAttributesKey(e.targets[n]);return t}function createAttributesKey(e){let t="";const n=Object.keys(e).sort();for(let i=0,r=n.length;i<r;i++)t+=n[i]+":"+e[n[i]]+";";return t}function getNormalizedComponentScale(e){switch(e){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}const tr=new m;class GLTFParser{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new GLTFRegistry,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let n=!1,i=-1,r=!1,s=-1;if("undefined"!=typeof navigator){const e=navigator.userAgent;n=!0===/^((?!chrome|android).)*safari/i.test(e);const t=e.match(/Version\/(\d+)/);i=n&&t?parseInt(t[1],10):-1,r=e.indexOf("Firefox")>-1,s=r?e.match(/Firefox\/([0-9]+)\./)[1]:-1}"undefined"==typeof createImageBitmap||n&&i<17||r&&s<98?this.textureLoader=new O(this.options.manager):this.textureLoader=new G(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new v(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),"use-credentials"===this.options.crossOrigin&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const n=this,i=this.json,r=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll((function(e){return e._markDefs&&e._markDefs()})),Promise.all(this._invokeAll((function(e){return e.beforeRoot&&e.beforeRoot()}))).then((function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])})).then((function(t){const s={scene:t[0][i.scene||0],scenes:t[0],animations:t[1],cameras:t[2],asset:i.asset,parser:n,userData:{}};return addUnknownExtensionsToUserData(r,s,i),assignExtrasToUserData(s,i),Promise.all(n._invokeAll((function(e){return e.afterRoot&&e.afterRoot(s)}))).then((function(){for(const e of s.scenes)e.updateMatrixWorld();e(s)}))})).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let n=0,i=t.length;n<i;n++){const i=t[n].joints;for(let t=0,n=i.length;t<n;t++)e[i[t]].isBone=!0}for(let t=0,i=e.length;t<i;t++){const i=e[t];void 0!==i.mesh&&(this._addNodeRef(this.meshCache,i.mesh),void 0!==i.skin&&(n[i.mesh].isSkinnedMesh=!0)),void 0!==i.camera&&this._addNodeRef(this.cameraCache,i.camera)}}_addNodeRef(e,t){void 0!==t&&(void 0===e.refs[t]&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,n){if(e.refs[t]<=1)return n;const i=n.clone(),updateMappings=(e,t)=>{const n=this.associations.get(e);null!=n&&this.associations.set(t,n);for(const[n,i]of e.children.entries())updateMappings(i,t.children[n])};return updateMappings(n,i),i.name+="_instance_"+e.uses[t]++,i}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let n=0;n<t.length;n++){const i=e(t[n]);if(i)return i}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const n=[];for(let i=0;i<t.length;i++){const r=e(t[i]);r&&n.push(r)}return n}getDependency(e,t){const n=e+":"+t;let i=this.cache.get(n);if(!i){switch(e){case"scene":i=this.loadScene(t);break;case"node":i=this._invokeOne((function(e){return e.loadNode&&e.loadNode(t)}));break;case"mesh":i=this._invokeOne((function(e){return e.loadMesh&&e.loadMesh(t)}));break;case"accessor":i=this.loadAccessor(t);break;case"bufferView":i=this._invokeOne((function(e){return e.loadBufferView&&e.loadBufferView(t)}));break;case"buffer":i=this.loadBuffer(t);break;case"material":i=this._invokeOne((function(e){return e.loadMaterial&&e.loadMaterial(t)}));break;case"texture":i=this._invokeOne((function(e){return e.loadTexture&&e.loadTexture(t)}));break;case"skin":i=this.loadSkin(t);break;case"animation":i=this._invokeOne((function(e){return e.loadAnimation&&e.loadAnimation(t)}));break;case"camera":i=this.loadCamera(t);break;default:if(i=this._invokeOne((function(n){return n!=this&&n.getDependency&&n.getDependency(e,t)})),!i)throw new Error("Unknown type: "+e)}this.cache.add(n,i)}return i}getDependencies(e){let t=this.cache.get(e);if(!t){const n=this,i=this.json[e+("mesh"===e?"es":"s")]||[];t=Promise.all(i.map((function(t,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&&"arraybuffer"!==t.type)throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(void 0===t.uri&&0===e)return Promise.resolve(this.extensions[Oi.KHR_BINARY_GLTF].body);const i=this.options;return new Promise((function(e,r){n.load(w.resolveURL(t.uri,i.path),e,void 0,(function(){r(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(e){const n=t.byteLength||0,i=t.byteOffset||0;return e.slice(i,i+n)}))}loadAccessor(e){const t=this,n=this.json,i=this.json.accessors[e];if(void 0===i.bufferView&&void 0===i.sparse){const e=Wi[i.type],t=Xi[i.componentType],n=!0===i.normalized,r=new t(i.count*e);return Promise.resolve(new B(r,e,n))}const r=[];return void 0!==i.bufferView?r.push(this.getDependency("bufferView",i.bufferView)):r.push(null),void 0!==i.sparse&&(r.push(this.getDependency("bufferView",i.sparse.indices.bufferView)),r.push(this.getDependency("bufferView",i.sparse.values.bufferView))),Promise.all(r).then((function(e){const r=e[0],s=Wi[i.type],o=Xi[i.componentType],a=o.BYTES_PER_ELEMENT,A=a*s,c=i.byteOffset||0,p=void 0!==i.bufferView?n.bufferViews[i.bufferView].byteStride:void 0,h=!0===i.normalized;let u,d;if(p&&p!==A){const e=Math.floor(c/p),n="InterleavedBuffer:"+i.bufferView+":"+i.componentType+":"+e+":"+i.count;let A=t.cache.get(n);A||(u=new o(r,e*p,i.count*p/a),A=new U(u,p/a),t.cache.add(n,A)),d=new l(A,s,c%p/a,h)}else u=null===r?new o(i.count*s):new o(r,c,i.count*s),d=new B(u,s,h);if(void 0!==i.sparse){const t=Wi.SCALAR,n=Xi[i.sparse.indices.componentType],a=i.sparse.indices.byteOffset||0,A=i.sparse.values.byteOffset||0,l=new n(e[1],a,i.sparse.count*t),c=new o(e[2],A,i.sparse.count*s);null!==r&&(d=new B(d.array.slice(),d.itemSize,d.normalized)),d.normalized=!1;for(let e=0,t=l.length;e<t;e++){const t=l[e];if(d.setX(t,c[e*s]),s>=2&&d.setY(t,c[e*s+1]),s>=3&&d.setZ(t,c[e*s+2]),s>=4&&d.setW(t,c[e*s+3]),s>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}d.normalized=h}return d}))}loadTexture(e){const t=this.json,n=this.options,i=t.textures[e].source,r=t.images[i];let s=this.textureLoader;if(r.uri){const e=n.manager.getHandler(r.uri);null!==e&&(s=e)}return this.loadTextureImage(e,i,s)}loadTextureImage(e,t,n){const i=this,r=this.json,s=r.textures[e],o=r.images[t],a=(o.uri||o.bufferView)+":"+s.sampler;if(this.textureCache[a])return this.textureCache[a];const A=this.loadImageSource(t,n).then((function(t){t.flipY=!1,t.name=s.name||o.name||"",""===t.name&&"string"==typeof o.uri&&!1===o.uri.startsWith("data:image/")&&(t.name=o.uri);const n=(r.samplers||{})[s.sampler]||{};return t.magFilter=qi[n.magFilter]||q,t.minFilter=qi[n.minFilter]||Y,t.wrapS=ji[n.wrapS]||W,t.wrapT=ji[n.wrapT]||W,t.generateMipmaps=!t.isCompressedTexture&&t.minFilter!==j&&t.minFilter!==q,i.associations.set(t,{textures:e}),t})).catch((function(){return null}));return this.textureCache[a]=A,A}loadImageSource(e,t){const n=this,i=this.json,r=this.options;if(void 0!==this.sourceCache[e])return this.sourceCache[e].then((e=>e.clone()));const s=i.images[e],o=self.URL||self.webkitURL;let a=s.uri||"",A=!1;if(void 0!==s.bufferView)a=n.getDependency("bufferView",s.bufferView).then((function(e){A=!0;const t=new Blob([e],{type:s.mimeType});return a=o.createObjectURL(t),a}));else if(void 0===s.uri)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const l=Promise.resolve(a).then((function(e){return new Promise((function(n,i){let s=n;!0===t.isImageBitmapLoader&&(s=function(e){const t=new me(e);t.needsUpdate=!0,n(t)}),t.load(w.resolveURL(e,r.path),s,void 0,i)}))})).then((function(e){return!0===A&&o.revokeObjectURL(a),assignExtrasToUserData(e,s),e.userData.mimeType=s.mimeType||function getImageURIMimeType(e){return e.search(/\.jpe?g($|\?)/i)>0||0===e.search(/^data\:image\/jpeg/)?"image/jpeg":e.search(/\.webp($|\?)/i)>0||0===e.search(/^data\:image\/webp/)?"image/webp":e.search(/\.ktx2($|\?)/i)>0||0===e.search(/^data\:image\/ktx2/)?"image/ktx2":"image/png"}(s.uri),e})).catch((function(e){throw console.error("THREE.GLTFLoader: Couldn't load texture",a),e}));return this.sourceCache[e]=l,l}assignTexture(e,t,n,i){const r=this;return this.getDependency("texture",n.index).then((function(s){if(!s)return null;if(void 0!==n.texCoord&&n.texCoord>0&&((s=s.clone()).channel=n.texCoord),r.extensions[Oi.KHR_TEXTURE_TRANSFORM]){const e=void 0!==n.extensions?n.extensions[Oi.KHR_TEXTURE_TRANSFORM]:void 0;if(e){const t=r.associations.get(s);s=r.extensions[Oi.KHR_TEXTURE_TRANSFORM].extendTexture(s,e),r.associations.set(s,t)}}return void 0!==i&&(s.colorSpace=i),e[t]=s,s}))}assignFinalMaterial(e){const t=e.geometry;let n=e.material;const i=void 0===t.attributes.tangent,r=void 0!==t.attributes.color,s=void 0===t.attributes.normal;if(e.isPoints){const e="PointsMaterial:"+n.uuid;let t=this.cache.get(e);t||(t=new K,Z.prototype.copy.call(t,n),t.color.copy(n.color),t.map=n.map,t.sizeAttenuation=!1,this.cache.add(e,t)),n=t}else if(e.isLine){const e="LineBasicMaterial:"+n.uuid;let t=this.cache.get(e);t||(t=new $,Z.prototype.copy.call(t,n),t.color.copy(n.color),t.map=n.map,this.cache.add(e,t)),n=t}if(i||r||s){let e="ClonedMaterial:"+n.uuid+":";i&&(e+="derivative-tangents:"),r&&(e+="vertex-colors:"),s&&(e+="flat-shading:");let t=this.cache.get(e);t||(t=n.clone(),r&&(t.vertexColors=!0),s&&(t.flatShading=!0),i&&(t.normalScale&&(t.normalScale.y*=-1),t.clearcoatNormalScale&&(t.clearcoatNormalScale.y*=-1)),this.cache.add(e,t),this.associations.set(t,this.associations.get(n))),n=t}e.material=n}getMaterialType(){return ee}loadMaterial(e){const t=this,n=this.json,i=this.extensions,s=n.materials[e];let o;const a={},A=[];if((s.extensions||{})[Oi.KHR_MATERIALS_UNLIT]){const e=i[Oi.KHR_MATERIALS_UNLIT];o=e.getMaterialType(),A.push(e.extendParams(a,s,t))}else{const n=s.pbrMetallicRoughness||{};if(a.color=new T(1,1,1),a.opacity=1,Array.isArray(n.baseColorFactor)){const e=n.baseColorFactor;a.color.setRGB(e[0],e[1],e[2],S),a.opacity=e[3]}void 0!==n.baseColorTexture&&A.push(t.assignTexture(a,"map",n.baseColorTexture,M)),a.metalness=void 0!==n.metallicFactor?n.metallicFactor:1,a.roughness=void 0!==n.roughnessFactor?n.roughnessFactor:1,void 0!==n.metallicRoughnessTexture&&(A.push(t.assignTexture(a,"metalnessMap",n.metallicRoughnessTexture)),A.push(t.assignTexture(a,"roughnessMap",n.metallicRoughnessTexture))),o=this._invokeOne((function(t){return t.getMaterialType&&t.getMaterialType(e)})),A.push(Promise.all(this._invokeAll((function(t){return t.extendMaterialParams&&t.extendMaterialParams(e,a)}))))}!0===s.doubleSided&&(a.side=te);const l=s.alphaMode||Zi;if(l===er?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,l===$i&&(a.alphaTest=void 0!==s.alphaCutoff?s.alphaCutoff:.5)),void 0!==s.normalTexture&&o!==ne&&(A.push(t.assignTexture(a,"normalMap",s.normalTexture)),a.normalScale=new r(1,1),void 0!==s.normalTexture.scale)){const e=s.normalTexture.scale;a.normalScale.set(e,e)}if(void 0!==s.occlusionTexture&&o!==ne&&(A.push(t.assignTexture(a,"aoMap",s.occlusionTexture)),void 0!==s.occlusionTexture.strength&&(a.aoMapIntensity=s.occlusionTexture.strength)),void 0!==s.emissiveFactor&&o!==ne){const e=s.emissiveFactor;a.emissive=(new T).setRGB(e[0],e[1],e[2],S)}return void 0!==s.emissiveTexture&&o!==ne&&A.push(t.assignTexture(a,"emissiveMap",s.emissiveTexture,M)),Promise.all(A).then((function(){const n=new o(a);return s.name&&(n.name=s.name),assignExtrasToUserData(n,s),t.associations.set(n,{materials:e}),s.extensions&&addUnknownExtensionsToUserData(i,n,s),n}))}createUniqueName(e){const t=ie.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,n=this.extensions,i=this.primitiveCache;function createDracoPrimitive(e){return n[Oi.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(e,t).then((function(n){return addPrimitiveAttributes(n,e,t)}))}const r=[];for(let n=0,s=e.length;n<s;n++){const s=e[n],o=createPrimitiveKey(s),a=i[o];if(a)r.push(a.promise);else{let e;e=s.extensions&&s.extensions[Oi.KHR_DRACO_MESH_COMPRESSION]?createDracoPrimitive(s):addPrimitiveAttributes(new C,s,t),i[o]={primitive:s,promise:e},r.push(e)}}return Promise.all(r)}loadMesh(e){const t=this,n=this.json,i=this.extensions,r=n.meshes[e],s=r.primitives,o=[];for(let e=0,t=s.length;e<t;e++){const t=void 0===s[e].material?(void 0===(a=this.cache).DefaultMaterial&&(a.DefaultMaterial=new ee({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:Ce})),a.DefaultMaterial):this.getDependency("material",s[e].material);o.push(t)}var a;return o.push(t.loadGeometries(s)),Promise.all(o).then((function(n){const o=n.slice(0,n.length-1),a=n[n.length-1],A=[];for(let n=0,l=a.length;n<l;n++){const l=a[n],c=s[n];let p;const h=o[n];if(c.mode===Hi.TRIANGLES||c.mode===Hi.TRIANGLE_STRIP||c.mode===Hi.TRIANGLE_FAN||void 0===c.mode)p=!0===r.isSkinnedMesh?new re(l,h):new d(l,h),!0===p.isSkinnedMesh&&p.normalizeSkinWeights(),c.mode===Hi.TRIANGLE_STRIP?p.geometry=toTrianglesDrawMode(p.geometry,x):c.mode===Hi.TRIANGLE_FAN&&(p.geometry=toTrianglesDrawMode(p.geometry,I));else if(c.mode===Hi.LINES)p=new se(l,h);else if(c.mode===Hi.LINE_STRIP)p=new oe(l,h);else if(c.mode===Hi.LINE_LOOP)p=new ae(l,h);else{if(c.mode!==Hi.POINTS)throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+c.mode);p=new Ae(l,h)}Object.keys(p.geometry.morphAttributes).length>0&&updateMorphTargets(p,r),p.name=t.createUniqueName(r.name||"mesh_"+e),assignExtrasToUserData(p,r),c.extensions&&addUnknownExtensionsToUserData(i,p,c),t.assignFinalMaterial(p),A.push(p)}for(let n=0,i=A.length;n<i;n++)t.associations.set(A[n],{meshes:e,primitives:n});if(1===A.length)return r.extensions&&addUnknownExtensionsToUserData(i,A[0],r),A[0];const l=new le;r.extensions&&addUnknownExtensionsToUserData(i,l,r),t.associations.set(l,{meshes:e});for(let e=0,t=A.length;e<t;e++)l.add(A[e]);return l}))}loadCamera(e){let t;const n=this.json.cameras[e],i=n[n.type];if(i)return"perspective"===n.type?t=new ce(y.radToDeg(i.yfov),i.aspectRatio||1,i.znear||1,i.zfar||2e6):"orthographic"===n.type&&(t=new pe(-i.xmag,i.xmag,i.ymag,-i.ymag,i.znear,i.zfar)),n.name&&(t.name=this.createUniqueName(n.name)),assignExtrasToUserData(t,n),Promise.resolve(t);console.warn("THREE.GLTFLoader: Missing camera parameters.")}loadSkin(e){const t=this.json.skins[e],n=[];for(let e=0,i=t.joints.length;e<i;e++)n.push(this._loadNodeShallow(t.joints[e]));return void 0!==t.inverseBindMatrices?n.push(this.getDependency("accessor",t.inverseBindMatrices)):n.push(null),Promise.all(n).then((function(e){const n=e.pop(),i=e,r=[],s=[];for(let e=0,o=i.length;e<o;e++){const o=i[e];if(o){r.push(o);const t=new m;null!==n&&t.fromArray(n.array,16*e),s.push(t)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[e])}return new he(r,s)}))}loadAnimation(e){const t=this.json,n=this,i=t.animations[e],r=i.name?i.name:"animation_"+e,s=[],o=[],a=[],A=[],l=[];for(let e=0,t=i.channels.length;e<t;e++){const t=i.channels[e],n=i.samplers[t.sampler],r=t.target,c=r.node,p=void 0!==i.parameters?i.parameters[n.input]:n.input,h=void 0!==i.parameters?i.parameters[n.output]:n.output;void 0!==r.node&&(s.push(this.getDependency("node",c)),o.push(this.getDependency("accessor",p)),a.push(this.getDependency("accessor",h)),A.push(n),l.push(r))}return Promise.all([Promise.all(s),Promise.all(o),Promise.all(a),Promise.all(A),Promise.all(l)]).then((function(e){const t=e[0],s=e[1],o=e[2],a=e[3],A=e[4],l=[];for(let e=0,i=t.length;e<i;e++){const i=t[e],r=s[e],c=o[e],p=a[e],h=A[e];if(void 0===i)continue;i.updateMatrix&&i.updateMatrix();const u=n._createAnimationTracks(i,r,c,p,h);if(u)for(let e=0;e<u.length;e++)l.push(u[e])}const c=new ue(r,void 0,l);return assignExtrasToUserData(c,i),c}))}createNodeMesh(e){const t=this.json,n=this,i=t.nodes[e];return void 0===i.mesh?null:n.getDependency("mesh",i.mesh).then((function(e){const t=n._getNodeRef(n.meshCache,i.mesh,e);return void 0!==i.weights&&t.traverse((function(e){if(e.isMesh)for(let t=0,n=i.weights.length;t<n;t++)e.morphTargetInfluences[t]=i.weights[t]})),t}))}loadNode(e){const t=this,n=this.json.nodes[e],i=t._loadNodeShallow(e),r=[],s=n.children||[];for(let e=0,n=s.length;e<n;e++)r.push(t.getDependency("node",s[e]));const o=void 0===n.skin?Promise.resolve(null):t.getDependency("skin",n.skin);return Promise.all([i,Promise.all(r),o]).then((function(e){const t=e[0],n=e[1],i=e[2];null!==i&&t.traverse((function(e){e.isSkinnedMesh&&e.bind(i,tr)}));for(let e=0,i=n.length;e<i;e++)t.add(n[e]);return t}))}_loadNodeShallow(e){const t=this.json,n=this.extensions,i=this;if(void 0!==this.nodeCache[e])return this.nodeCache[e];const r=t.nodes[e],s=r.name?i.createUniqueName(r.name):"",o=[],a=i._invokeOne((function(t){return t.createNodeMesh&&t.createNodeMesh(e)}));return a&&o.push(a),void 0!==r.camera&&o.push(i.getDependency("camera",r.camera).then((function(e){return i._getNodeRef(i.cameraCache,r.camera,e)}))),i._invokeAll((function(t){return t.createNodeAttachment&&t.createNodeAttachment(e)})).forEach((function(e){o.push(e)})),this.nodeCache[e]=Promise.all(o).then((function(t){let o;if(o=!0===r.isBone?new de:t.length>1?new le:1===t.length?t[0]:new N,o!==t[0])for(let e=0,n=t.length;e<n;e++)o.add(t[e]);if(r.name&&(o.userData.name=r.name,o.name=s),assignExtrasToUserData(o,r),r.extensions&&addUnknownExtensionsToUserData(n,o,r),void 0!==r.matrix){const e=new m;e.fromArray(r.matrix),o.applyMatrix4(e)}else void 0!==r.translation&&o.position.fromArray(r.translation),void 0!==r.rotation&&o.quaternion.fromArray(r.rotation),void 0!==r.scale&&o.scale.fromArray(r.scale);if(i.associations.has(o)){if(void 0!==r.mesh&&i.meshCache.refs[r.mesh]>1){const e=i.associations.get(o);i.associations.set(o,{...e})}}else i.associations.set(o,{});return i.associations.get(o).nodes=e,o})),this.nodeCache[e]}loadScene(e){const t=this.extensions,n=this.json.scenes[e],i=this,r=new le;n.name&&(r.name=i.createUniqueName(n.name)),assignExtrasToUserData(r,n),n.extensions&&addUnknownExtensionsToUserData(t,r,n);const s=n.nodes||[],o=[];for(let e=0,t=s.length;e<t;e++)o.push(i.getDependency("node",s[e]));return Promise.all(o).then((function(e){for(let t=0,n=e.length;t<n;t++)r.add(e[t]);return i.associations=(e=>{const t=new Map;for(const[e,n]of i.associations)(e instanceof Z||e instanceof me)&&t.set(e,n);return e.traverse((e=>{const n=i.associations.get(e);null!=n&&t.set(e,n)})),t})(r),r}))}_createAnimationTracks(e,t,n,i,r){const s=[],o=e.name?e.name:e.uuid,a=[];let A;switch(Vi[r.path]===Vi.weights?e.traverse((function(e){e.morphTargetInfluences&&a.push(e.name?e.name:e.uuid)})):a.push(o),Vi[r.path]){case Vi.weights:A=be;break;case Vi.rotation:A=Ie;break;case Vi.translation:case Vi.scale:A=ye;break;default:if(1===n.itemSize)A=be;else A=ye}const l=void 0!==i.interpolation?Ki[i.interpolation]:fe,c=this._getArrayFromAccessor(n);for(let e=0,n=a.length;e<n;e++){const n=new A(a[e]+"."+Vi[r.path],t.array,c,l);"CUBICSPLINE"===i.interpolation&&this._createCubicSplineTrackInterpolant(n),s.push(n)}return s}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const e=getNormalizedComponentScale(t.constructor),n=new Float32Array(t.length);for(let i=0,r=t.length;i<r;i++)n[i]=t[i]*e;t=n}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function InterpolantFactoryMethodGLTFCubicSpline(e){return new(this instanceof Ie?GLTFCubicSplineQuaternionInterpolant:GLTFCubicSplineInterpolant)(this.times,this.values,this.getValueSize()/3,e)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function addPrimitiveAttributes(e,t,n){const i=t.attributes,r=[];function assignAttributeAccessor(t,i){return n.getDependency("accessor",t).then((function(t){e.setAttribute(i,t)}))}for(const t in i){const n=Ji[t]||t.toLowerCase();n in e.attributes||r.push(assignAttributeAccessor(i[t],n))}if(void 0!==t.indices&&!e.index){const i=n.getDependency("accessor",t.indices).then((function(t){e.setIndex(t)}));r.push(i)}return xe.workingColorSpace!==S&&"COLOR_0"in i&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${xe.workingColorSpace}" not supported.`),assignExtrasToUserData(e,t),function computeBounds(e,t,n){const i=t.attributes,r=new p;if(void 0===i.POSITION)return;{const e=n.json.accessors[i.POSITION],t=e.min,s=e.max;if(void 0===t||void 0===s)return void console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");if(r.set(new u(t[0],t[1],t[2]),new u(s[0],s[1],s[2])),e.normalized){const t=getNormalizedComponentScale(Xi[e.componentType]);r.min.multiplyScalar(t),r.max.multiplyScalar(t)}}const s=t.targets;if(void 0!==s){const e=new u,t=new u;for(let i=0,r=s.length;i<r;i++){const r=s[i];if(void 0!==r.POSITION){const i=n.json.accessors[r.POSITION],s=i.min,o=i.max;if(void 0!==s&&void 0!==o){if(t.setX(Math.max(Math.abs(s[0]),Math.abs(o[0]))),t.setY(Math.max(Math.abs(s[1]),Math.abs(o[1]))),t.setZ(Math.max(Math.abs(s[2]),Math.abs(o[2]))),i.normalized){const e=getNormalizedComponentScale(Xi[i.componentType]);t.multiplyScalar(e)}e.max(t)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}r.expandByVector(e)}e.boundingBox=r;const o=new h;r.getCenter(o.center),o.radius=r.min.distanceTo(r.max)/2,e.boundingSphere=o}(e,t,n),Promise.all(r).then((function(){return void 0!==t.targets?function addMorphTargets(e,t,n){let i=!1,r=!1,s=!1;for(let e=0,n=t.length;e<n;e++){const n=t[e];if(void 0!==n.POSITION&&(i=!0),void 0!==n.NORMAL&&(r=!0),void 0!==n.COLOR_0&&(s=!0),i&&r&&s)break}if(!i&&!r&&!s)return Promise.resolve(e);const o=[],a=[],A=[];for(let l=0,c=t.length;l<c;l++){const c=t[l];if(i){const t=void 0!==c.POSITION?n.getDependency("accessor",c.POSITION):e.attributes.position;o.push(t)}if(r){const t=void 0!==c.NORMAL?n.getDependency("accessor",c.NORMAL):e.attributes.normal;a.push(t)}if(s){const t=void 0!==c.COLOR_0?n.getDependency("accessor",c.COLOR_0):e.attributes.color;A.push(t)}}return Promise.all([Promise.all(o),Promise.all(a),Promise.all(A)]).then((function(t){const n=t[0],o=t[1],a=t[2];return i&&(e.morphAttributes.position=n),r&&(e.morphAttributes.normal=o),s&&(e.morphAttributes.color=a),e.morphTargetsRelative=!0,e}))}(e,t.targets,n):e}))}const nr=new WeakMap;class DRACOLoader extends E{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,i){const r=new v(this.manager);r.setPath(this.path),r.setResponseType("arraybuffer"),r.setRequestHeader(this.requestHeader),r.setWithCredentials(this.withCredentials),r.load(e,(e=>{this.parse(e,t,i)}),n,i)}parse(e,t,n=()=>{}){this.decodeDracoFile(e,t,null,null,M,n).catch(n)}decodeDracoFile(e,t,n,i,r=S,s=()=>{}){const o={attributeIDs:n||this.defaultAttributeIDs,attributeTypes:i||this.defaultAttributeTypes,useUniqueIDs:!!n,vertexColorSpace:r};return this.decodeGeometry(e,o).then(t).catch(s)}decodeGeometry(e,t){const n=JSON.stringify(t);if(nr.has(e)){const t=nr.get(e);if(t.key===n)return t.promise;if(0===e.byteLength)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let i;const r=this.workerNextTaskID++,s=e.byteLength,o=this._getWorker(r,s).then((n=>(i=n,new Promise(((n,s)=>{i._callbacks[r]={resolve:n,reject:s},i.postMessage({type:"decode",id:r,taskConfig:t,buffer:e},[e])}))))).then((e=>this._createGeometry(e.geometry)));return o.catch((()=>!0)).then((()=>{i&&r&&this._releaseTask(i,r)})),nr.set(e,{key:n,promise:o}),o}_createGeometry(e){const t=new C;e.index&&t.setIndex(new B(e.index.array,1));for(let n=0;n<e.attributes.length;n++){const{name:i,array:r,itemSize:s,stride:o,vertexColorSpace:a}=e.attributes[n];let A;if(s===o)A=new B(r,s);else{const e=new U(r,o);A=new l(e,s,0)}"color"===i&&(this._assignVertexColorSpace(A,a),A.normalized=r instanceof Float32Array==!1),t.setAttribute(i,A)}return t}_assignVertexColorSpace(e,t){if(t!==M)return;const n=new T;for(let t=0,i=e.count;t<i;t++)n.fromBufferAttribute(e,t),xe.colorSpaceToWorking(n,M),e.setXYZ(t,n.r,n.g,n.b)}_loadLibrary(e,t){const n=new v(this.manager);return n.setPath(this.decoderPath),n.setResponseType(t),n.setWithCredentials(this.withCredentials),new Promise(((t,i)=>{n.load(e,t,void 0,i)}))}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;const e="object"!=typeof WebAssembly||"js"===this.decoderConfig.type,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((t=>{const n=t[0];e||(this.decoderConfig.wasmBinary=t[1]);const i=DRACOWorker.toString(),r=["/* draco decoder */",n,"","/* worker */",i.substring(i.indexOf("{")+1,i.lastIndexOf("}"))].join("\n");this.workerSourceURL=URL.createObjectURL(new Blob([r]))})),this.decoderPending}_getWorker(e,t){return this._initDecoder().then((()=>{if(this.workerPool.length<this.workerLimit){const e=new Worker(this.workerSourceURL);e._callbacks={},e._taskCosts={},e._taskLoad=0,e.postMessage({type:"init",decoderConfig:this.decoderConfig}),e.onmessage=function(t){const n=t.data;switch(n.type){case"decode":e._callbacks[n.id].resolve(n);break;case"error":e._callbacks[n.id].reject(n);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+n.type+'"')}},this.workerPool.push(e)}else this.workerPool.sort((function(e,t){return e._taskLoad>t._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.workerSourceURL&&URL.revokeObjectURL(this.workerSourceURL),this}}function DRACOWorker(){let e,t;function decodeAttribute(e,t,n,i,r,s){const o=n.num_points(),a=s.num_components(),A=function getDracoDataType(e,t){switch(t){case Float32Array:return e.DT_FLOAT32;case Int8Array:return e.DT_INT8;case Int16Array:return e.DT_INT16;case Int32Array:return e.DT_INT32;case Uint8Array:return e.DT_UINT8;case Uint16Array:return e.DT_UINT16;case Uint32Array:return e.DT_UINT32}}(e,r),l=a*r.BYTES_PER_ELEMENT,c=4*Math.ceil(l/4),p=c/r.BYTES_PER_ELEMENT,h=o*l,u=o*c,d=e._malloc(h);t.GetAttributeDataArrayForAllPoints(n,s,A,h,d);const g=new r(e.HEAPF32.buffer,d,h/r.BYTES_PER_ELEMENT);let f;if(l===c)f=g.slice();else{f=new r(u/r.BYTES_PER_ELEMENT);let e=0;for(let t=0,n=g.length;t<n;t++){for(let n=0;n<a;n++)f[e+n]=g[t*a+n];e+=p}}return e._free(d),{name:i,count:o,itemSize:a,array:f,stride:p}}onmessage=function(n){const i=n.data;switch(i.type){case"init":e=i.decoderConfig,t=new Promise((function(t){e.onModuleLoaded=function(e){t({draco:e})},DracoDecoderModule(e)}));break;case"decode":const n=i.buffer,r=i.taskConfig;t.then((e=>{const t=e.draco,s=new t.Decoder;try{const e=function decodeGeometry(e,t,n,i){const r=i.attributeIDs,s=i.attributeTypes;let o,a;const A=t.GetEncodedGeometryType(n);if(A===e.TRIANGULAR_MESH)o=new e.Mesh,a=t.DecodeArrayToMesh(n,n.byteLength,o);else{if(A!==e.POINT_CLOUD)throw new Error("THREE.DRACOLoader: Unexpected geometry type.");o=new e.PointCloud,a=t.DecodeArrayToPointCloud(n,n.byteLength,o)}if(!a.ok()||0===o.ptr)throw new Error("THREE.DRACOLoader: Decoding failed: "+a.error_msg());const l={index:null,attributes:[]};for(const n in r){const a=self[s[n]];let A,c;if(i.useUniqueIDs)c=r[n],A=t.GetAttributeByUniqueId(o,c);else{if(c=t.GetAttributeId(o,e[r[n]]),-1===c)continue;A=t.GetAttribute(o,c)}const p=decodeAttribute(e,t,o,n,a,A);"color"===n&&(p.vertexColorSpace=i.vertexColorSpace),l.attributes.push(p)}A===e.TRIANGULAR_MESH&&(l.index=function decodeIndex(e,t,n){const i=n.num_faces(),r=3*i,s=4*r,o=e._malloc(s);t.GetTrianglesUInt32Array(n,s,o);const a=new Uint32Array(e.HEAPF32.buffer,o,r).slice();return e._free(o),{array:a,itemSize:1}}(e,t,o));return e.destroy(o),l}(t,s,new Int8Array(n),r),o=e.attributes.map((e=>e.array.buffer));e.index&&o.push(e.index.array.buffer),self.postMessage({type:"decode",id:i.id,geometry:e},o)}catch(e){console.error(e),self.postMessage({type:"error",id:i.id,error:e.message})}finally{t.destroy(s)}}))}}}class WorkerPool{constructor(e=4){this.pool=e,this.queue=[],this.workers=[],this.workersResolve=[],this.workerStatus=0,this.workerCreator=null}_initWorker(e){if(!this.workers[e]){const t=this.workerCreator();t.addEventListener("message",this._onMessage.bind(this,e)),this.workers[e]=t}}_getIdleWorker(){for(let e=0;e<this.pool;e++)if(!(this.workerStatus&1<<e))return e;return-1}_onMessage(e,t){const n=this.workersResolve[e];if(n&&n(t),this.queue.length){const{resolve:t,msg:n,transfer:i}=this.queue.shift();this.workersResolve[e]=t,this.workers[e].postMessage(n,i)}else this.workerStatus^=1<<e}setWorkerCreator(e){this.workerCreator=e}setWorkerLimit(e){this.pool=e}postMessage(e,t){return new Promise((n=>{const i=this._getIdleWorker();-1!==i?(this._initWorker(i),this.workerStatus|=1<<i,this.workersResolve[i]=n,this.workers[i].postMessage(e,t)):this.queue.push({resolve:n,msg:e,transfer:t})}))}dispose(){this.workers.forEach((e=>e.terminate())),this.workersResolve.length=0,this.workers.length=0,this.queue.length=0,this.workerStatus=0}}const ir=9,rr=15,sr=16,or=22,ar=37,Ar=43,lr=76,cr=83,pr=97,hr=100,ur=103,dr=109,gr=122,fr=123,mr=131,yr=132,br=133,Ir=134,xr=137,Cr=138,Br=139,Er=140,wr=141,vr=142,Qr=145,Pr=146,Tr=148,Sr=152,Mr=153,Dr=154,Lr=155,_r=156,Fr=157,kr=158,Rr=165,Nr=166,Or=1000054e3,Gr=1000054001,Ur=1000054004,Yr=1000054005,zr=1000066e3,Hr=1000066004;class Ci{constructor(e,t,n,i){this._dataView=void 0,this._littleEndian=void 0,this._offset=void 0,this._dataView=new DataView(e.buffer,e.byteOffset+t,n),this._littleEndian=i,this._offset=0}_nextUint8(){const e=this._dataView.getUint8(this._offset);return this._offset+=1,e}_nextUint16(){const e=this._dataView.getUint16(this._offset,this._littleEndian);return this._offset+=2,e}_nextUint32(){const e=this._dataView.getUint32(this._offset,this._littleEndian);return this._offset+=4,e}_nextUint64(){const e=this._dataView.getUint32(this._offset,this._littleEndian)+2**32*this._dataView.getUint32(this._offset+4,this._littleEndian);return this._offset+=8,e}_nextInt32(){const e=this._dataView.getInt32(this._offset,this._littleEndian);return this._offset+=4,e}_nextUint8Array(e){const t=new Uint8Array(this._dataView.buffer,this._dataView.byteOffset+this._offset,e);return this._offset+=e,t}_skip(e){return this._offset+=e,this}_scan(e,t=0){const n=this._offset;let i=0;for(;this._dataView.getUint8(this._offset)!==t&&i<e;)i++,this._offset++;return i<e&&this._offset++,new Uint8Array(this._dataView.buffer,this._dataView.byteOffset+n,i)}}const Xr=[171,75,84,88,32,50,48,187,13,10,26,10];function Si(e){return(new TextDecoder).decode(e)}let qr,jr,Wr;const Jr={env:{emscripten_notify_memory_growth:function(e){Wr=new Uint8Array(jr.exports.memory.buffer)}}};class Q{init(){return qr||(qr="undefined"!=typeof fetch?fetch("data:application/wasm;base64,"+Vr).then((e=>e.arrayBuffer())).then((e=>WebAssembly.instantiate(e,Jr))).then(this._init):WebAssembly.instantiate(Buffer.from(Vr,"base64"),Jr).then(this._init),qr)}_init(e){jr=e.instance,Jr.env.emscripten_notify_memory_growth(0)}decode(e,t=0){if(!jr)throw new Error("ZSTDDecoder: Await .init() before decoding.");const n=e.byteLength,i=jr.exports.malloc(n);Wr.set(e,i),t=t||Number(jr.exports.ZSTD_findDecompressedSize(i,n));const r=jr.exports.malloc(t),s=jr.exports.ZSTD_decompress(r,t,i,n),o=Wr.slice(r,r+s);return jr.exports.free(i),jr.exports.free(r),o}}const Vr="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IAMNACAEQQNxBEADQCACRQ0FIAAgAkF/aiICaiIDIAEgAmotAAA6AAAgA0EDcQ0ACwsgAkEDTQ0AA0AgACACQXxqIgJqIAEgAmooAgA2AgAgAkEDSw0ACwsgAkUNAgNAIAAgAkF/aiICaiABIAJqLQAAOgAAIAINAAsMAgsgAkEDTQ0AIAIhBANAIAMgASgCADYCACABQQRqIQEgA0EEaiEDIARBfGoiBEEDSw0ACyACQQNxIQILIAJFDQADQCADIAEtAAA6AAAgA0EBaiEDIAFBAWohASACQX9qIgINAAsLIAAL8wICAn8BfgJAIAJFDQAgACACaiIDQX9qIAE6AAAgACABOgAAIAJBA0kNACADQX5qIAE6AAAgACABOgABIANBfWogAToAACAAIAE6AAIgAkEHSQ0AIANBfGogAToAACAAIAE6AAMgAkEJSQ0AIABBACAAa0EDcSIEaiIDIAFB/wFxQYGChAhsIgE2AgAgAyACIARrQXxxIgRqIgJBfGogATYCACAEQQlJDQAgAyABNgIIIAMgATYCBCACQXhqIAE2AgAgAkF0aiABNgIAIARBGUkNACADIAE2AhggAyABNgIUIAMgATYCECADIAE2AgwgAkFwaiABNgIAIAJBbGogATYCACACQWhqIAE2AgAgAkFkaiABNgIAIAQgA0EEcUEYciIEayICQSBJDQAgAa0iBUIghiAFhCEFIAMgBGohAQNAIAEgBTcDGCABIAU3AxAgASAFNwMIIAEgBTcDACABQSBqIQEgAkFgaiICQR9LDQALCyAACy8BAn8gACgCBCAAKAIAQQJ0aiICLQACIQMgACACLwEAIAEgAi0AAxAIajYCACADCy8BAn8gACgCBCAAKAIAQQJ0aiICLQACIQMgACACLwEAIAEgAi0AAxAFajYCACADCx8AIAAgASACKAIEEAg2AgAgARAEGiAAIAJBCGo2AgQLCAAgAGdBH3MLugUBDX8jAEEQayIKJAACfyAEQQNNBEAgCkEANgIMIApBDGogAyAEEAsaIAAgASACIApBDGpBBBAVIgBBbCAAEAMbIAAgACAESxsMAQsgAEEAIAEoAgBBAXRBAmoQECENQVQgAygAACIGQQ9xIgBBCksNABogAiAAQQVqNgIAIAMgBGoiAkF8aiEMIAJBeWohDiACQXtqIRAgAEEGaiELQQQh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ASIDNgLE4AEgACgCvOABIQQgACABNgK84AEgACABIAJqNgK44AEgACABIAQgA2tqNgLA4AELpgEBAX8gACAAKALs4QEQFjYCyOABIABCADcD+OABIABCADcDuOABIABBwOABakIANwMAIABBqNAAaiIBQYyAgOAANgIAIABBADYCmOIBIABCADcDiOEBIABCAzcDgOEBIABBrNABakHgEikCADcCACAAQbTQAWpB6BIoAgA2AgAgACABNgIMIAAgAEGYIGo2AgggACAAQaAwajYCBCAAIABBEGo2AgALYQEBf0G4fyEDAkAgAUEDSQ0AIAIgABAhIgFBA3YiADYCCCACIAFBAXE2AgQgAiABQQF2QQNxIgM2AgACQCADQX9qIgFBAksNAAJAIAFBAWsOAgEAAgtBbA8LIAAhAwsgAwsMACAAIAEgAkEAEC4LiAQCA38CfiADEBYhBCAAQQBBKBAQIQAgBCACSwRAIAQPCyABRQRAQX8PCwJAAkAgA0EBRg0AIAEoAAAiBkGo6r5pRg0AQXYhAyAGQXBxQdDUtMIBRw0BQQghAyACQQhJDQEgAEEAQSgQECEAIAEoAAQhASAAQQE2AhQgACABrTcDAEEADwsgASACIAMQLyIDIAJLDQAgACADNgIYQXIhAyABIARqIgVBf2otAAAiAkEIcQ0AIAJBIHEiBkUEQEFwIQMgBS0AACIFQacBSw0BIAVBB3GtQgEgBUEDdkEKaq2GIgdCA4h+IAd8IQggBEEBaiEECyACQQZ2IQMgAkECdiEFAkAgAkEDcUF/aiICQQJLBEBBACECDAELAkACQAJAIAJBAWsOAgECAAsgASAEai0AACECIARBAWohBAwCCyABIARqLwAAIQIgBEECaiEEDAELIAEgBGooAAAhAiAEQQRqIQQLIAVBAXEhBQJ+AkACQAJAIANBf2oiA0ECTQRAIANBAWsOAgIDAQtCfyAGRQ0DGiABIARqMQAADAMLIAEgBGovAACtQoACfAwCCyABIARqKAAArQwBCyABIARqKQAACyEHIAAgBTYCICAAIAI2AhwgACAHNwMAQQAhAyAAQQA2AhQgACAHIAggBhsiBzcDCCAAIAdCgIAIIAdCgIAIVBs+AhALIAMLWwEBf0G4fyEDIAIQFiICIAFNBH8gACACakF/ai0AACIAQQNxQQJ0QaAeaigC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C0Egak8NAQsgByAHKQNoNwMQIAcgBykDYDcDCCAEIA0gB0EIaiAHQdwAaiAPIA4gESAQEB4hCwwBCyACIARqIQggBCAKEAcgAkERTwRAIARBEGohAgNAIAIgCkEQaiIKEAcgAkEQaiICIAhJDQALCyAIIAlrIQIgByATNgJcIAkgCCAOa0sEQCAJIAggEWtLBEBBbCELDAILIBAgAiAOayICaiIKIANqIBBNBEAgCCAKIAMQDxoMAgsgCCAKQQAgAmsQDyEIIAcgAiADaiIDNgJkIAggAmshCCAOIQILIAlBEE8EQCADIAhqIQMDQCAIIAIQByACQRBqIQIgCEEQaiIIIANJDQALDAELAkAgCUEHTQRAIAggAi0AADoAACAIIAItAAE6AAEgCCACLQACOgACIAggAi0AAzoAAyAIQQRqIAIgCUECdCIDQcAeaigCAGoiAhAXIAIgA0HgHmooAgBrIQIgBygCZCEDDAELIAggAhAMCyADQQlJDQAgAyAIaiEDIAhBCGoiCCACQQhqIgJrQQ9MBEADQCAIIAIQDCACQQhqIQIgCEEIaiIIIANJDQAMAgALAAsDQCAIIAIQByACQRBqIQIgCEEQaiIIIANJDQALCyAHQRhqEAQaIAsgDCALEAMiAhshDCAEIAQgC2ogAhshBCAFQX9qIgUNAAsgDBADDQFBbCEMIAdBGGoQBEECSQ0BQQAhCANAIAhBA0cEQCAAIAhBAnQiAmpBrNABaiACIAdqKAJENgIAIAhBAWohCAwBCwsgBygCXCEIC0G6fyEMIA8gCGsiACANIARrSw0AIAQEfyAEIAggABALIABqBUEACyABayEMCyAHQfAAaiQAIAwLkRcCFn8FfiMAQdABayIHJAAgByAAKALw4QEiCDYCvAEgASACaiESIAggACgCgOIBaiETAkACQCAFRQRAIAEhAwwBCyAAKALE4AEhESAAKALA4AEhFSAAKAK84AEhDyAAQQE2AozhAUEAIQgDQCAIQQNHBEAgByAIQQJ0IgJqIAAgAmpBrNABaigCADYCVCAIQQFqIQgMAQsLIAcgETYCZCAHIA82AmAgByABIA9rNgJoQWwhECAHQShqIAMgBBAGEAMNASAFQQQgBUEESBshFyAHQTxqIAdBKGogACgCABATIAdBxABqIAdBKGogACgCCBATIAdBzABqIAdB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IAdB0AFqJAAgEAslACAAQgA3AgAgAEEAOwEIIABBADoACyAAIAE2AgwgACACOgAKC7QFAQN/IwBBMGsiBCQAIABB/wFqIgVBfWohBgJAIAMvAQIEQCAEQRhqIAEgAhAGIgIQAw0BIARBEGogBEEYaiADEBwgBEEIaiAEQRhqIAMQHCAAIQMDQAJAIARBGGoQBCADIAZPckUEQCADIARBEGogBEEYahASOgAAIAMgBEEIaiAEQRhqEBI6AAEgBEEYahAERQ0BIANBAmohAwsgBUF+aiEFAn8DQEG6fyECIAMiASAFSw0FIAEgBEEQaiAEQRhqEBI6AAAgAUEBaiEDIARBGGoQBEEDRgRAQQIhAiAEQQhqDAILIAMgBUsNBSABIARBCGogBEEYahASOgABIAFBAmohA0EDIQIgBEEYahAEQQNHDQALIARBEGoLIQUgAyAFIARBGGoQEjoAACABIAJqIABrIQIMAwsgAyAEQRBqIARBGGoQEjoAAiADIARBCGogBEEYahASOgADIANBBGohAwwAAAsACyAEQRhqIAEgAhAGIgIQAw0AIARBEGogBEEYaiADEBwgBEEIaiAEQRhqIAMQHCAAIQMDQAJAIARBGGoQBCADIAZPckUEQCADIARBEGogBEEYahAROgAAIAMgBEEIaiAEQRhqEBE6AAEgBEEYahAERQ0BIANBAmohAwsgBUF+aiEFAn8DQEG6fyECIAMiASAFSw0EIAEgBEEQaiAEQRhqEBE6AAAgAUEBaiEDIARBGGoQBEEDRgRAQQIhAiAEQQhqDAILIAMgBUsNBCABIARBCGogBEEYahAROgABIAFBAmohA0EDIQIgBEEYahAEQQNHDQALIARBEGoLIQUgAyAFIARBGGoQEToAACABIAJqIABrIQIMAgsgAyAEQRBqIARBGGoQEToAAiADIARBCGogBEEYahAROgADIANBBGohAwwAAAsACyAEQTBqJAAgAgtpAQF/An8CQAJAIAJBB00NACABKAAAQbfIwuF+Rw0AIAAgASgABDYCmOIBQWIgAEEQaiABIAIQPiIDEAMNAhogAEKBgICAEDcDiOEBIAAgASADaiACIANrECoMAQsgACABIAIQKgtBAAsLrQMBBn8jAEGAAWsiAyQAQWIhCAJAIAJBCUkNACAAQZjQAGogAUEIaiIEIAJBeGogAEGY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wOABCwutAgIEfwF+IwBBQGoiBCQAAkACQCACQQhJDQAgASgAAEFwcUHQ1LTCAUcNACABIAIQIiEBIABCADcDCCAAQQA2AgQgACABNgIADAELIARBGGogASACEC0iAxADBEAgACADEBoMAQsgAwRAIABBuH8QGgwBCyACIAQoAjAiA2shAiABIANqIQMDQAJAIAAgAyACIARBCGoQLCIFEAMEfyAFBSACIAVBA2oiBU8NAUG4fwsQGgwCCyAGQQFqIQYgAiAFayECIAMgBWohAyAEKAIMRQ0ACyAEKAI4BEAgAkEDTQRAIABBuH8QGgwCCyADQQRqIQMLIAQoAighAiAEKQMYIQcgAEEANgIEIAAgAyABazYCACAAIAIgBmytIAcgB0J/URs3AwgLIARBQGskAAslAQF/IwBBEGsiAiQAIAIgACABEFEgAigCACEAIAJBEGokACAAC30BBH8jAEGQBGsiBCQAIARB/wE2AggCQCAEQRBqIARBCGogBEEMaiABIAIQFSIGEAMEQCAGIQUMAQtBVCEFIAQoAgwiB0EGSw0AIAMgBEEQaiAEKAIIIAcQQSIFEAMNACAAIAEgBmogAiAGayADEDwhBQsgBEGQBGokACAFC4cBAgJ/An5BABAWIQMCQANAIAEgA08EQAJAIAAoAABBcHFB0NS0wgFGBEAgACABECIiAhADRQ0BQn4PCyAAIAEQVSIEQn1WDQMgBCAFfCIFIARUIQJCfiEEIAINAyAAIAEQUiICEAMNAwsgASACayEBIAAgAmohAAwBCwtCfiAFIAEbIQQLIAQLPwIBfwF+IwBBMGsiAiQAAn5CfiACQQhqIAAgARAtDQAaQgAgAigCHEEBRg0AGiACKQMICyEDIAJBMGokACADC40BAQJ/IwBBMGsiASQAAkAgAEUNACAAKAKI4gENACABIABB/OEBaigCADYCKCABIAApAvThATcDICAAEDAgACgCqOIBIQIgASABKAIoNgIYIAEgASkDIDcDECACIAFBEGoQGyAAQQA2AqjiASABIAEoAig2AgggASABKQMgNwMAIAAgARAbCyABQTBqJAALKgECfyMAQRBrIgAkACAAQQA2AgggAEIANwMAIAAQWCEBIABBEGokACABC4cBAQN/IwBBEGsiAiQAAkAgACgCAEUgACgCBEVzDQAgAiAAKAIINgIIIAIgACkCADcDAAJ/IAIoAgAiAQRAIAIoAghBqOMJIAERBQAMAQtBqOMJECgLIgFFDQAgASAAKQIANwL04QEgAUH84QFqIAAoAgg2AgAgARBZIAEhAwsgAkEQaiQAIAMLywEBAn8jAEEgayIBJAAgAEGBgIDAADYCtOIBIABBADYCiOIBIABBADYC7OEBIABCADcDkOIBIABBADYCpOMJIABBADYC3OIBIABCADcCzOIBIABBADYCvOIBIABBADYCxOABIABCADcCnOIBIABBpOIBakIANwIAIABBrOIBakEANgIAIAFCADcCECABQgA3AhggASABKQMYNwMIIAEgASkDEDcDACABKAIIQQh2QQFxIQIgAEEANgLg4gEgACACNgKM4gEgAUEgaiQAC3YBA38jAEEwayIBJAAgAARAIAEgAEHE0AFqIgIoAgA2AiggASAAKQK80AE3AyAgACgCACEDIAEgAigCADYCGCABIAApArzQATcDECADIAFBEGoQGyABIAEoAig2AgggASABKQMgNwMAIAAgARAbCyABQTBqJAALzAEBAX8gACABKAK00AE2ApjiASAAIAEoAgQiAjYCwOABIAAgAjYCvOABIAAgAiABKAIIaiICNgK44AEgACACNgLE4AEgASgCuNABBEAgAEKBgICAEDcDiOEBIAAgAUGk0ABqNgIMIAAgAUGUIGo2AgggACABQZwwajYCBCAAIAFBDGo2AgAgAEGs0AFqIAFBqNABaigCADYCACAAQbDQAWogAUGs0AFqKAIANgIAIABBtNABaiABQbDQAWooAgA2AgAPCyAAQgA3A4jhAQs7ACACRQRAQbp/DwsgBEUEQEFsDwsgAiAEEGAEQCAAIAEgAiADIAQgBRBhDwsgACABIAIgAyAEIAUQZQtGAQF/IwBBEGsiBSQAIAVBCGogBBAOAn8gBS0ACQRAIAAgASACIAMgBBAyDAELIAAgASACIAMgBBA0CyEAIAVBEGokACAACzQAIAAgAyAEIAUQNiIFEAMEQCAFDwsgBSAESQR/IAEgAiADIAVqIAQgBWsgABA1BUG4fwsLRgEBfyMAQRBrIgUkACAFQQhqIAQQDgJ/IAUtAAkEQCAAIAEgAiADIAQQYgwBCyAAIAEgAiADIAQQNQshACAFQRBqJAAgAAtZAQF/QQ8hAiABIABJBEAgAUEE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";xe.spaces[M];const Kr=new WeakMap;let Zr,$r=0;class KTX2Loader extends E{constructor(e){super(e),this.transcoderPath="",this.transcoderBinary=null,this.transcoderPending=null,this.workerPool=new WorkerPool,this.workerSourceURL="",this.workerConfig=null,"undefined"!=typeof MSC_TRANSCODER&&console.warn('THREE.KTX2Loader: Please update to latest "basis_transcoder". "msc_basis_transcoder" is no longer supported in three.js r125+.')}setTranscoderPath(e){return this.transcoderPath=e,this}setWorkerLimit(e){return this.workerPool.setWorkerLimit(e),this}async detectSupportAsync(e){return console.warn('KTX2Loader: "detectSupportAsync()" has been deprecated. Use "detectSupport()" and "await renderer.init();" when creating the renderer.'),await e.init(),this.detectSupport(e)}detectSupport(e){return!0===e.isWebGPURenderer?this.workerConfig={astcSupported:e.hasFeature("texture-compression-astc"),astcHDRSupported:!1,etc1Supported:e.hasFeature("texture-compression-etc1"),etc2Supported:e.hasFeature("texture-compression-etc2"),dxtSupported:e.hasFeature("texture-compression-s3tc"),bptcSupported:e.hasFeature("texture-compression-bc"),pvrtcSupported:e.hasFeature("texture-compression-pvrtc")}:(this.workerConfig={astcSupported:e.extensions.has("WEBGL_compressed_texture_astc"),astcHDRSupported:e.extensions.has("WEBGL_compressed_texture_astc")&&e.extensions.get("WEBGL_compressed_texture_astc").getSupportedProfiles().includes("hdr"),etc1Supported:e.extensions.has("WEBGL_compressed_texture_etc1"),etc2Supported:e.extensions.has("WEBGL_compressed_texture_etc"),dxtSupported:e.extensions.has("WEBGL_compressed_texture_s3tc"),bptcSupported:e.extensions.has("EXT_texture_compression_bptc"),pvrtcSupported:e.extensions.has("WEBGL_compressed_texture_pvrtc")||e.extensions.has("WEBKIT_WEBGL_compressed_texture_pvrtc")},"undefined"!=typeof navigator&&navigator.platform.indexOf("Linux")>=0&&navigator.userAgent.indexOf("Firefox")>=0&&this.workerConfig.astcSupported&&this.workerConfig.etc2Supported&&this.workerConfig.bptcSupported&&this.workerConfig.dxtSupported&&(this.workerConfig.astcSupported=!1,this.workerConfig.etc2Supported=!1)),this}init(){if(!this.transcoderPending){const e=new v(this.manager);e.setPath(this.transcoderPath),e.setWithCredentials(this.withCredentials);const t=e.loadAsync("basis_transcoder.js"),n=new v(this.manager);n.setPath(this.transcoderPath),n.setResponseType("arraybuffer"),n.setWithCredentials(this.withCredentials);const i=n.loadAsync("basis_transcoder.wasm");this.transcoderPending=Promise.all([t,i]).then((([e,t])=>{const n=KTX2Loader.BasisWorker.toString(),i=["/* constants */","let _EngineFormat = "+JSON.stringify(KTX2Loader.EngineFormat),"let _EngineType = "+JSON.stringify(KTX2Loader.EngineType),"let _TranscoderFormat = "+JSON.stringify(KTX2Loader.TranscoderFormat),"let _BasisFormat = "+JSON.stringify(KTX2Loader.BasisFormat),"/* basis_transcoder.js */",e,"/* worker */",n.substring(n.indexOf("{")+1,n.lastIndexOf("}"))].join("\n");this.workerSourceURL=URL.createObjectURL(new Blob([i])),this.transcoderBinary=t,this.workerPool.setWorkerCreator((()=>{const e=new Worker(this.workerSourceURL),t=this.transcoderBinary.slice(0);return e.postMessage({type:"init",config:this.workerConfig,transcoderBinary:t},[t]),e}))})),$r>0&&console.warn("THREE.KTX2Loader: Multiple active KTX2 loaders may cause performance issues. Use a single KTX2Loader instance, or call .dispose() on old instances."),$r++}return this.transcoderPending}load(e,t,n,i){if(null===this.workerConfig)throw new Error("THREE.KTX2Loader: Missing initialization with `.detectSupport( renderer )`.");const r=new v(this.manager);r.setPath(this.path),r.setCrossOrigin(this.crossOrigin),r.setWithCredentials(this.withCredentials),r.setRequestHeader(this.requestHeader),r.setResponseType("arraybuffer"),r.load(e,(e=>{this.parse(e,t,i)}),n,i)}parse(e,t,n){if(null===this.workerConfig)throw new Error("THREE.KTX2Loader: Missing initialization with `.detectSupport( renderer )`.");if(Kr.has(e)){return Kr.get(e).promise.then(t).catch(n)}this._createTexture(e).then((e=>t?t(e):null)).catch(n)}_createTextureFrom(e,t){const{type:n,error:i,data:{faces:r,width:s,height:o,format:a,type:A,dfdFlags:l}}=e;if("error"===n)return Promise.reject(i);let c;if(6===t.faceCount)c=new Ee(r,a,A);else{const e=r[0].mipmaps;c=t.layerCount>1?new we(e,s,o,t.layerCount,a,A):new ve(e,s,o,a,A)}return c.minFilter=1===r[0].mipmaps.length?q:Y,c.magFilter=q,c.generateMipmaps=!1,c.needsUpdate=!0,c.colorSpace=parseColorSpace(t),c.premultiplyAlpha=!!(1&l),c}async _createTexture(e,t={}){const n=function Mi(e){const t=new Uint8Array(e.buffer,e.byteOffset,Xr.length);if(t[0]!==Xr[0]||t[1]!==Xr[1]||t[2]!==Xr[2]||t[3]!==Xr[3]||t[4]!==Xr[4]||t[5]!==Xr[5]||t[6]!==Xr[6]||t[7]!==Xr[7]||t[8]!==Xr[8]||t[9]!==Xr[9]||t[10]!==Xr[10]||t[11]!==Xr[11])throw new Error("Missing KTX 2.0 identifier.");const n={vkFormat:0,typeSize:1,pixelWidth:0,pixelHeight:0,pixelDepth:0,layerCount:0,faceCount:1,levelCount:0,supercompressionScheme:0,levels:[],dataFormatDescriptor:[{vendorId:0,descriptorType:0,versionNumber:2,colorModel:0,colorPrimaries:1,transferFunction:2,flags:0,texelBlockDimension:[0,0,0,0],bytesPlane:[0,0,0,0,0,0,0,0],samples:[]}],keyValue:{},globalData:null},i=17*Uint32Array.BYTES_PER_ELEMENT,r=new Ci(e,Xr.length,i,!0);n.vkFormat=r._nextUint32(),n.typeSize=r._nextUint32(),n.pixelWidth=r._nextUint32(),n.pixelHeight=r._nextUint32(),n.pixelDepth=r._nextUint32(),n.layerCount=r._nextUint32(),n.faceCount=r._nextUint32(),n.levelCount=r._nextUint32(),n.supercompressionScheme=r._nextUint32();const s=r._nextUint32(),o=r._nextUint32(),a=r._nextUint32(),A=r._nextUint32(),l=r._nextUint64(),c=r._nextUint64(),p=3*Math.max(n.levelCount,1)*8,h=new Ci(e,Xr.length+i,p,!0);for(let t=0,i=Math.max(n.levelCount,1);t<i;t++)n.levels.push({levelData:new Uint8Array(e.buffer,e.byteOffset+h._nextUint64(),h._nextUint64()),uncompressedByteLength:h._nextUint64()});const u=new Ci(e,s,o,!0);u._skip(4);const d=u._nextUint16(),g=u._nextUint16(),f=u._nextUint16(),m=u._nextUint16(),y={vendorId:d,descriptorType:g,versionNumber:f,colorModel:u._nextUint8(),colorPrimaries:u._nextUint8(),transferFunction:u._nextUint8(),flags:u._nextUint8(),texelBlockDimension:[u._nextUint8(),u._nextUint8(),u._nextUint8(),u._nextUint8()],bytesPlane:[u._nextUint8(),u._nextUint8(),u._nextUint8(),u._nextUint8(),u._nextUint8(),u._nextUint8(),u._nextUint8(),u._nextUint8()],samples:[]},b=(m/4-6)/4;for(let e=0;e<b;e++){const t={bitOffset:u._nextUint16(),bitLength:u._nextUint8(),channelType:u._nextUint8(),samplePosition:[u._nextUint8(),u._nextUint8(),u._nextUint8(),u._nextUint8()],sampleLower:Number.NEGATIVE_INFINITY,sampleUpper:Number.POSITIVE_INFINITY};64&t.channelType?(t.sampleLower=u._nextInt32(),t.sampleUpper=u._nextInt32()):(t.sampleLower=u._nextUint32(),t.sampleUpper=u._nextUint32()),y.samples[e]=t}n.dataFormatDescriptor.length=0,n.dataFormatDescriptor.push(y);const I=new Ci(e,a,A,!0);for(;I._offset<A;){const e=I._nextUint32(),t=I._scan(e),i=Si(t);if(n.keyValue[i]=I._nextUint8Array(e-t.byteLength-1),i.match(/^ktx/i)){const e=Si(n.keyValue[i]);n.keyValue[i]=e.substring(0,e.lastIndexOf("\0"))}I._skip(e%4?4-e%4:0)}if(c<=0)return n;const x=new Ci(e,l,c,!0),C=x._nextUint16(),B=x._nextUint16(),E=x._nextUint32(),w=x._nextUint32(),v=x._nextUint32(),P=x._nextUint32(),T=[];for(let e=0,t=Math.max(n.levelCount,1);e<t;e++)T.push({imageFlags:x._nextUint32(),rgbSliceByteOffset:x._nextUint32(),rgbSliceByteLength:x._nextUint32(),alphaSliceByteOffset:x._nextUint32(),alphaSliceByteLength:x._nextUint32()});const S=l+x._offset,M=S+E,D=M+w,L=D+v,_=new Uint8Array(e.buffer,e.byteOffset+S,E),F=new Uint8Array(e.buffer,e.byteOffset+M,w),k=new Uint8Array(e.buffer,e.byteOffset+D,v),R=new Uint8Array(e.buffer,e.byteOffset+L,P);return n.globalData={endpointCount:C,selectorCount:B,imageDescs:T,endpointsData:_,selectorsData:F,tablesData:k,extendedData:R},n}(new Uint8Array(e)),i=n.vkFormat===zr&&167===n.dataFormatDescriptor[0].colorModel;if(!(0===n.vkFormat||i&&!this.workerConfig.astcHDRSupported))return async function createRawTexture(e){const{vkFormat:t}=e;if(void 0===ts[t])throw new Error("THREE.KTX2Loader: Unsupported vkFormat: "+t);void 0===ns[t]&&console.warn('THREE.KTX2Loader: Missing ".type" for vkFormat: '+t);let n;2===e.supercompressionScheme&&(Zr||(Zr=new Promise((async e=>{const t=new Q;await t.init(),e(t)}))),n=await Zr);const i=[];for(let r=0;r<e.levels.length;r++){const s=Math.max(1,e.pixelWidth>>r),o=Math.max(1,e.pixelHeight>>r),a=e.pixelDepth?Math.max(1,e.pixelDepth>>r):0,A=e.levels[r];let l,c;if(0===e.supercompressionScheme)l=A.levelData;else{if(2!==e.supercompressionScheme)throw new Error("THREE.KTX2Loader: Unsupported supercompressionScheme.");l=n.decode(A.levelData,A.uncompressedByteLength)}c=ns[t]===et?new Float32Array(l.buffer,l.byteOffset,l.byteLength/Float32Array.BYTES_PER_ELEMENT):ns[t]===Ke?new Uint16Array(l.buffer,l.byteOffset,l.byteLength/Uint16Array.BYTES_PER_ELEMENT):ns[t]===$e||ns[t]===Ze?new Uint32Array(l.buffer,l.byteOffset,l.byteLength/Uint32Array.BYTES_PER_ELEMENT):l,i.push({data:c,width:s,height:o,depth:a})}const r=0===e.levelCount||i.length>1;let s;if(es.has(ts[t]))s=0===e.pixelDepth?new tt(i[0].data,e.pixelWidth,e.pixelHeight):new nt(i[0].data,e.pixelWidth,e.pixelHeight,e.pixelDepth),s.minFilter=r?X:j,s.magFilter=j,s.generateMipmaps=0===e.levelCount;else{if(e.pixelDepth>0)throw new Error("THREE.KTX2Loader: Unsupported pixelDepth.");s=new ve(i,e.pixelWidth,e.pixelHeight),s.minFilter=r?Y:q,s.magFilter=q}return s.mipmaps=i,s.type=ns[t],s.format=ts[t],s.colorSpace=parseColorSpace(e),s.needsUpdate=!0,Promise.resolve(s)}(n);const r=t,s=this.init().then((()=>this.workerPool.postMessage({type:"transcode",buffer:e,taskConfig:r},[e]))).then((e=>this._createTextureFrom(e.data,n)));return Kr.set(e,{promise:s}),s}dispose(){this.workerPool.dispose(),this.workerSourceURL&&URL.revokeObjectURL(this.workerSourceURL),$r--}}KTX2Loader.BasisFormat={ETC1S:0,UASTC:1,UASTC_HDR:2},KTX2Loader.TranscoderFormat={ETC1:0,ETC2:1,BC1:2,BC3:3,BC4:4,BC5:5,BC7_M6_OPAQUE_ONLY:6,BC7_M5:7,PVRTC1_4_RGB:8,PVRTC1_4_RGBA:9,ASTC_4x4:10,ATC_RGB:11,ATC_RGBA_INTERPOLATED_ALPHA:12,RGBA32:13,RGB565:14,BGR565:15,RGBA4444:16,BC6H:22,RGB_HALF:24,RGBA_HALF:25},KTX2Loader.EngineFormat={RGBAFormat:Je,RGBA_ASTC_4x4_Format:Oe,RGB_BPTC_UNSIGNED_Format:ot,RGBA_BPTC_Format:Se,RGBA_ETC2_EAC_Format:Xe,RGBA_PVRTC_4BPPV1_Format:Te,RGBA_S3TC_DXT5_Format:st,RGB_ETC1_Format:rt,RGB_ETC2_Format:He,RGB_PVRTC_4BPPV1_Format:it,RGBA_S3TC_DXT1_Format:Re},KTX2Loader.EngineType={UnsignedByteType:Ve,HalfFloatType:Ke,FloatType:et},KTX2Loader.BasisWorker=function(){let e,t,n;const i=_EngineFormat,r=_EngineType,s=_TranscoderFormat,o=_BasisFormat;self.addEventListener("message",(function(i){const s=i.data;switch(s.type){case"init":e=s.config,function init(e){t=new Promise((t=>{n={wasmBinary:e,onRuntimeInitialized:t},BASIS(n)})).then((()=>{n.initializeBasis(),void 0===n.KTX2File&&console.warn("THREE.KTX2Loader: Please update Basis Universal transcoder.")}))}(s.transcoderBinary);break;case"transcode":t.then((()=>{try{const{faces:t,buffers:i,width:a,height:l,hasAlpha:c,format:p,type:h,dfdFlags:u}=function transcode(t){const i=new n.KTX2File(new Uint8Array(t));function cleanup(){i.close(),i.delete()}if(!i.isValid())throw cleanup(),new Error("THREE.KTX2Loader:\tInvalid or unsupported .ktx2 file");let s;if(i.isUASTC())s=o.UASTC;else if(i.isETC1S())s=o.ETC1S;else{if(!i.isHDR())throw new Error("THREE.KTX2Loader: Unknown Basis encoding");s=o.UASTC_HDR}const a=i.getWidth(),l=i.getHeight(),c=i.getLayers()||1,p=i.getLevels(),h=i.getFaces(),u=i.getHasAlpha(),d=i.getDFDFlags(),{transcoderFormat:g,engineFormat:f,engineType:m}=function getTranscoderFormat(t,n,i,r){const s=A[t];for(let o=0;o<s.length;o++){const a=s[o];if(a.if&&!e[a.if])continue;if(!a.basisFormat.includes(t))continue;if(r&&a.transcoderFormat.length<2)continue;if(a.needsPowerOfTwo&&(!isPowerOfTwo(n)||!isPowerOfTwo(i)))continue;return{transcoderFormat:a.transcoderFormat[r?1:0],engineFormat:a.engineFormat[r?1:0],engineType:a.engineType[0]}}throw new Error("THREE.KTX2Loader: Failed to identify transcoding target.")}(s,a,l,u);if(!a||!l||!p)throw cleanup(),new Error("THREE.KTX2Loader:\tInvalid texture");if(!i.startTranscoding())throw cleanup(),new Error("THREE.KTX2Loader: .startTranscoding failed");const y=[],b=[];for(let e=0;e<h;e++){const t=[];for(let n=0;n<p;n++){const s=[];let o,a;for(let t=0;t<c;t++){const A=i.getImageLevelInfo(n,t,e);0!==e||0!==n||0!==t||A.origWidth%4==0&&A.origHeight%4==0||console.warn("THREE.KTX2Loader: ETC1S and UASTC textures should use multiple-of-four dimensions."),p>1?(o=A.origWidth,a=A.origHeight):(o=A.width,a=A.height);let l=new Uint8Array(i.getImageTranscodedSizeInBytes(n,t,0,g));const c=i.transcodeImage(l,n,t,e,g,0,-1,-1);if(m===r.HalfFloatType&&(l=new Uint16Array(l.buffer,l.byteOffset,l.byteLength/Uint16Array.BYTES_PER_ELEMENT)),!c)throw cleanup(),new Error("THREE.KTX2Loader: .transcodeImage failed.");s.push(l)}const A=concat(s);t.push({data:A,width:o,height:a}),b.push(A.buffer)}y.push({mipmaps:t,width:a,height:l,format:f,type:m})}return cleanup(),{faces:y,buffers:b,width:a,height:l,hasAlpha:u,dfdFlags:d,format:f,type:m}}(s.buffer);self.postMessage({type:"transcode",id:s.id,data:{faces:t,width:a,height:l,hasAlpha:c,format:p,type:h,dfdFlags:u}},i)}catch(e){console.error(e),self.postMessage({type:"error",id:s.id,error:e.message})}}))}}));const a=[{if:"astcSupported",basisFormat:[o.UASTC],transcoderFormat:[s.ASTC_4x4,s.ASTC_4x4],engineFormat:[i.RGBA_ASTC_4x4_Format,i.RGBA_ASTC_4x4_Format],engineType:[r.UnsignedByteType],priorityETC1S:1/0,priorityUASTC:1,needsPowerOfTwo:!1},{if:"bptcSupported",basisFormat:[o.ETC1S,o.UASTC],transcoderFormat:[s.BC7_M5,s.BC7_M5],engineFormat:[i.RGBA_BPTC_Format,i.RGBA_BPTC_Format],engineType:[r.UnsignedByteType],priorityETC1S:3,priorityUASTC:2,needsPowerOfTwo:!1},{if:"dxtSupported",basisFormat:[o.ETC1S,o.UASTC],transcoderFormat:[s.BC1,s.BC3],engineFormat:[i.RGBA_S3TC_DXT1_Format,i.RGBA_S3TC_DXT5_Format],engineType:[r.UnsignedByteType],priorityETC1S:4,priorityUASTC:5,needsPowerOfTwo:!1},{if:"etc2Supported",basisFormat:[o.ETC1S,o.UASTC],transcoderFormat:[s.ETC1,s.ETC2],engineFormat:[i.RGB_ETC2_Format,i.RGBA_ETC2_EAC_Format],engineType:[r.UnsignedByteType],priorityETC1S:1,priorityUASTC:3,needsPowerOfTwo:!1},{if:"etc1Supported",basisFormat:[o.ETC1S,o.UASTC],transcoderFormat:[s.ETC1],engineFormat:[i.RGB_ETC1_Format],engineType:[r.UnsignedByteType],priorityETC1S:2,priorityUASTC:4,needsPowerOfTwo:!1},{if:"pvrtcSupported",basisFormat:[o.ETC1S,o.UASTC],transcoderFormat:[s.PVRTC1_4_RGB,s.PVRTC1_4_RGBA],engineFormat:[i.RGB_PVRTC_4BPPV1_Format,i.RGBA_PVRTC_4BPPV1_Format],engineType:[r.UnsignedByteType],priorityETC1S:5,priorityUASTC:6,needsPowerOfTwo:!0},{if:"bptcSupported",basisFormat:[o.UASTC_HDR],transcoderFormat:[s.BC6H],engineFormat:[i.RGB_BPTC_UNSIGNED_Format],engineType:[r.HalfFloatType],priorityHDR:1,needsPowerOfTwo:!1},{basisFormat:[o.ETC1S,o.UASTC],transcoderFormat:[s.RGBA32,s.RGBA32],engineFormat:[i.RGBAFormat,i.RGBAFormat],engineType:[r.UnsignedByteType,r.UnsignedByteType],priorityETC1S:100,priorityUASTC:100,needsPowerOfTwo:!1},{basisFormat:[o.UASTC_HDR],transcoderFormat:[s.RGBA_HALF],engineFormat:[i.RGBAFormat],engineType:[r.HalfFloatType],priorityHDR:100,needsPowerOfTwo:!1}],A={[o.ETC1S]:a.filter((e=>e.basisFormat.includes(o.ETC1S))).sort(((e,t)=>e.priorityETC1S-t.priorityETC1S)),[o.UASTC]:a.filter((e=>e.basisFormat.includes(o.UASTC))).sort(((e,t)=>e.priorityUASTC-t.priorityUASTC)),[o.UASTC_HDR]:a.filter((e=>e.basisFormat.includes(o.UASTC_HDR))).sort(((e,t)=>e.priorityHDR-t.priorityHDR))};function isPowerOfTwo(e){return e<=2||!(e&e-1)&&0!==e}function concat(e){if(1===e.length)return e[0];let t=0;for(let n=0;n<e.length;n++){t+=e[n].byteLength}const n=new Uint8Array(t);let i=0;for(let t=0;t<e.length;t++){const r=e[t];n.set(r,i),i+=r.byteLength}return n}};const es=new Set([Je,qe,We,je]),ts={[dr]:Je,[ur]:We,[hr]:je,[pr]:Je,[cr]:We,[lr]:je,[Ar]:Je,[ar]:Je,[or]:We,[sr]:We,[rr]:je,[ir]:je,[fr]:qe,[gr]:qe,[Sr]:Xe,[Tr]:He,[Mr]:ze,[Dr]:Ye,[Lr]:Ue,[_r]:Ge,[zr]:Oe,[kr]:Oe,[Fr]:Oe,[Hr]:Ne,[Nr]:Ne,[Rr]:Ne,[Ir]:Re,[br]:Re,[yr]:ke,[mr]:ke,[Cr]:Fe,[xr]:Fe,[Er]:_e,[Br]:Le,[vr]:De,[wr]:Me,[Pr]:Se,[Qr]:Se,[Yr]:Te,[Gr]:Te,[Ur]:Pe,[Or]:Pe},ns={[dr]:et,[ur]:et,[hr]:et,[pr]:Ke,[cr]:Ke,[lr]:Ke,[Ar]:Ve,[ar]:Ve,[or]:Ve,[sr]:Ve,[rr]:Ve,[ir]:Ve,[fr]:$e,[gr]:Ze,[Sr]:Ve,[Tr]:Ve,[Mr]:Ve,[Mr]:Ve,[Lr]:Ve,[Lr]:Ve,[zr]:Ke,[kr]:Ve,[Fr]:Ve,[Hr]:Ke,[Nr]:Ve,[Rr]:Ve,[Ir]:Ve,[br]:Ve,[yr]:Ve,[mr]:Ve,[Cr]:Ve,[xr]:Ve,[Er]:Ve,[Br]:Ve,[vr]:Ve,[wr]:Ve,[Pr]:Ve,[Qr]:Ve,[Yr]:Ve,[Gr]:Ve,[Ur]:Ve,[Or]:Ve};function parseColorSpace(e){const t=e.dataFormatDescriptor[0];return 1===t.colorPrimaries?2===t.transferFunction?M:S:10===t.colorPrimaries?2===t.transferFunction?"display-p3":"display-p3-linear":(0===t.colorPrimaries||console.warn(`THREE.KTX2Loader: Unsupported color primaries, "${t.colorPrimaries}"`),Qe)}var is=function(){var e=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,3,2,0,0,5,3,1,0,1,12,1,0,10,22,2,12,0,65,0,65,0,65,0,252,10,0,0,11,7,0,65,0,253,15,26,11]),t=new Uint8Array([32,0,65,2,1,106,34,33,3,128,11,4,13,64,6,253,10,7,15,116,127,5,8,12,40,16,19,54,20,9,27,255,113,17,42,67,24,23,146,148,18,14,22,45,70,69,56,114,101,21,25,63,75,136,108,28,118,29,73,115]);if("object"!=typeof WebAssembly)return{supported:!1};var n,i=WebAssembly.validate(e)?unpack("b9H79TebbbeKl9Gbb9Gvuuuuueu9Giuuub9Geueuikqbbebeedddilve9Weeeviebeoweuec:q:6dkr;leDo9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bb8A9TW79O9V9Wt9F9KW9J9V9KW9wWVtW949c919M9MWVbdY9TW79O9V9Wt9F9KW9J9V9KW69U9KW949c919M9MWVblE9TW79O9V9Wt9F9KW9J9V9KW69U9KW949tWG91W9U9JWbvL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9p9JtboK9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9r919HtbrL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVT949Wbwl79IV9RbDq:p9sqlbzik9:evu8Jjjjjbcz9Rhbcbheincbhdcbhiinabcwfadfaicjuaead4ceGglE86bbaialfhiadcefgdcw9hmbkaec:q:yjjbfai86bbaecitc:q1jjbfab8Piw83ibaecefgecjd9hmbkk:N8JlHud97euo978Jjjjjbcj;kb9Rgv8Kjjjjbc9:hodnadcefal0mbcuhoaiRbbc:Ge9hmbavaialfgrad9Rad;8qbbcj;abad9UhlaicefhodnaeTmbadTmbalc;WFbGglcjdalcjd6EhwcbhDinawaeaD9RaDawfae6Egqcsfglc9WGgkci2hxakcethmalcl4cifcd4hPabaDad2fhsakc;ab6hzcbhHincbhOaohAdndninaraA9RaP6meavcj;cbfaOak2fhCaAaPfhocbhidnazmbarao9Rc;Gb6mbcbhlinaCalfhidndndndndnaAalco4fRbbgXciGPlbedibkaipxbbbbbbbbbbbbbbbbpklbxikaiaopbblaopbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklbaoclfaYpQbfaKc:q:yjjbfRbbfhoxdkaiaopbbwaopbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklbaocwfaYpQbfaKc:q:yjjbfRbbfhoxekaiaopbbbpklbaoczfhokdndndndndnaXcd4ciGPlbedibkaipxbbbbbbbbbbbbbbbbpklzxikaiaopbblaopbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklzaoclfaYpQbfaKc:q:yjjbfRbbfhoxdkaiaopbbwaopbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklzaocwfaYpQbfaKc:q:yjjbfRbbfhoxekaiaopbbbpklzaoczfhokdndndndndnaXcl4ciGPlbedibkaipxbbbbbbbbbbbbbbbbpklaxikaiaopbblaopbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklaaoclfaYpQbfaKc:q:yjjbfRbbfhoxdkaiaopbbwaopbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklaaocwfaYpQbfaKc:q:yjjbfRbbfhoxekaiaopbbbpklaaoczfhokdndndndndnaXco4Plbedibkaipxbbbbbbbbbbbbbbbbpkl8WxikaiaopbblaopbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgXcitc:q1jjbfpbibaXc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgXcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spkl8WaoclfaYpQbfaXc:q:yjjbfRbbfhoxdkaiaopbbwaopbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgXcitc:q1jjbfpbibaXc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgXcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spkl8WaocwfaYpQbfaXc:q:yjjbfRbbfhoxekaiaopbbbpkl8Waoczfhokalc;abfhialcjefak0meaihlarao9Rc;Fb0mbkkdnaiak9pmbaici4hlinarao9RcK6miaCaifhXdndndndndnaAaico4fRbbalcoG4ciGPlbedibkaXpxbbbbbbbbbbbbbbbbpkbbxikaXaopbblaopbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spkbbaoclfaYpQbfaKc:q:yjjbfRbbfhoxdkaXaopbbwaopbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spkbbaocwfaYpQbfaKc:q:yjjbfRbbfhoxekaXaopbbbpkbbaoczfhokalcdfhlaiczfgiak6mbkkaoTmeaohAaOcefgOclSmdxbkkc9:hoxlkdnakTmbavcjdfaHfhiavaHfpbdbhYcbhXinaiavcj;cbfaXfglpblbgLcep9TaLpxeeeeeeeeeeeeeeeegQp9op9Hp9rgLalakfpblbg8Acep9Ta8AaQp9op9Hp9rg8ApmbzeHdOiAlCvXoQrLgEalamfpblbg3cep9Ta3aQp9op9Hp9rg3alaxfpblbg5cep9Ta5aQp9op9Hp9rg5pmbzeHdOiAlCvXoQrLg8EpmbezHdiOAlvCXorQLgQaQpmbedibedibedibediaYp9UgYp9AdbbaiadfglaYaQaQpmlvorlvorlvorlvorp9UgYp9AdbbaladfglaYaQaQpmwDqkwDqkwDqkwDqkp9UgYp9AdbbaladfglaYaQaQpmxmPsxmPsxmPsxmPsp9UgYp9AdbbaladfglaYaEa8EpmwDKYqk8AExm35Ps8E8FgQaQpmbedibedibedibedip9UgYp9AdbbaladfglaYaQaQpmlvorlvorlvorlvorp9UgYp9AdbbaladfglaYaQaQpmwDqkwDqkwDqkwDqkp9UgYp9AdbbaladfglaYaQaQpmxmPsxmPsxmPsxmPsp9UgYp9AdbbaladfglaYaLa8ApmwKDYq8AkEx3m5P8Es8FgLa3a5pmwKDYq8AkEx3m5P8Es8Fg8ApmbezHdiOAlvCXorQLgQaQpmbedibedibedibedip9UgYp9AdbbaladfglaYaQaQpmlvorlvorlvorlvorp9UgYp9AdbbaladfglaYaQaQpmwDqkwDqkwDqkwDqkp9UgYp9AdbbaladfglaYaQaQpmxmPsxmPsxmPsxmPsp9UgYp9AdbbaladfglaYaLa8ApmwDKYqk8AExm35Ps8E8FgQaQpmbedibedibedibedip9UgYp9AdbbaladfglaYaQaQpmlvorlvorlvorlvorp9UgYp9AdbbaladfglaYaQaQpmwDqkwDqkwDqkwDqkp9UgYp9AdbbaladfglaYaQaQpmxmPsxmPsxmPsxmPsp9UgYp9AdbbaladfhiaXczfgXak6mbkkaHclfgHad6mbkasavcjdfaqad2;8qbbavavcjdfaqcufad2fad;8qbbaqaDfgDae6mbkkcbc99arao9Radcaadca0ESEhokavcj;kbf8Kjjjjbaokwbz:bjjjbk::seHu8Jjjjjbc;ae9Rgv8Kjjjjbc9:hodnaeci9UgrcHfal0mbcuhoaiRbbgwc;WeGc;Ge9hmbawcsGgwce0mbavc;abfcFecje;8kbavcUf9cu83ibavc8Wf9cu83ibavcyf9cu83ibavcaf9cu83ibavcKf9cu83ibavczf9cu83ibav9cu83iwav9cu83ibaialfc9WfhDaicefgqarfhidnaeTmbcmcsawceSEhkcbhxcbhmcbhPcbhwcbhlindnaiaD9nmbc9:hoxikdndnaqRbbgoc;Ve0mbavc;abfalaocu7gscl4fcsGcitfgzydlhrazydbhzdnaocsGgHak9pmbavawasfcsGcdtfydbaxaHEhoaHThsdndnadcd9hmbabaPcetfgHaz87ebaHclfao87ebaHcdfar87ebxekabaPcdtfgHazBdbaHcwfaoBdbaHclfarBdbkaxasfhxcdhHavawcdtfaoBdbawasfhwcehsalhOxdkdndnaHcsSmbaHc987aHamffcefhoxekaicefhoai8SbbgHcFeGhsdndnaHcu9mmbaohixekaicvfhiascFbGhscrhHdninao8SbbgOcFbGaHtasVhsaOcu9kmeaocefhoaHcrfgHc8J9hmbxdkkaocefhikasce4cbasceG9R7amfhokdndnadcd9hmbabaPcetfgHaz87ebaHclfao87ebaHcdfar87ebxekabaPcdtfgHazBdbaHcwfaoBdbaHclfarBdbkcdhHavawcdtfaoBdbcehsawcefhwalhOaohmxekdnaocpe0mbaxcefgHavawaDaocsGfRbbgocl49RcsGcdtfydbaocz6gzEhravawao9RcsGcdtfydbaHazfgAaocsGgHEhoaHThCdndnadcd9hmbabaPcetfgHax87ebaHclfao87ebaHcdfar87ebxekabaPcdtfgHaxBdbaHcwfaoBdbaHclfarBdbkcdhsavawcdtfaxBdbavawcefgwcsGcdtfarBdbcihHavc;abfalcitfgOaxBdlaOarBdbavawazfgwcsGcdtfaoBdbalcefcsGhOawaCfhwaxhzaAaCfhxxekaxcbaiRbbgOEgzaoc;:eSgHfhraOcsGhCaOcl4hAdndnaOcs0mbarcefhoxekarhoavawaA9RcsGcdtfydbhrkdndnaCmbaocefhxxekaohxavawaO9RcsGcdtfydbhokdndnaHTmbaicefhHxekaicdfhHai8SbegscFeGhzdnascu9kmbaicofhXazcFbGhzcrhidninaH8SbbgscFbGaitazVhzascu9kmeaHcefhHaicrfgic8J9hmbkaXhHxekaHcefhHkazce4cbazceG9R7amfgmhzkdndnaAcsSmbaHhsxekaHcefhsaH8SbbgicFeGhrdnaicu9kmbaHcvfhXarcFbGhrcrhidninas8SbbgHcFbGaitarVhraHcu9kmeascefhsaicrfgic8J9hmbkaXhsxekascefhskarce4cbarceG9R7amfgmhrkdndnaCcsSmbashixekascefhias8SbbgocFeGhHdnaocu9kmbascvfhXaHcFbGhHcrhodninai8SbbgscFbGaotaHVhHascu9kmeaicefhiaocrfgoc8J9hmbkaXhixekaicefhikaHce4cbaHceG9R7amfgmhokdndnadcd9hmbabaPcetfgHaz87ebaHclfao87ebaHcdfar87ebxekabaPcdtfgHazBdbaHcwfaoBdbaHclfarBdbkcdhsavawcdtfazBdbavawcefgwcsGcdtfarBdbcihHavc;abfalcitfgXazBdlaXarBdbavawaOcz6aAcsSVfgwcsGcdtfaoBdbawaCTaCcsSVfhwalcefcsGhOkaqcefhqavc;abfaOcitfgOarBdlaOaoBdbavc;abfalasfcsGcitfgraoBdlarazBdbawcsGhwalaHfcsGhlaPcifgPae6mbkkcbc99aiaDSEhokavc;aef8Kjjjjbaok:flevu8Jjjjjbcz9Rhvc9:hodnaecvfal0mbcuhoaiRbbc;:eGc;qe9hmbav9cb83iwaicefhraialfc98fhwdnaeTmbdnadcdSmbcbhDindnaraw6mbc9:skarcefhoar8SbbglcFeGhidndnalcu9mmbaohrxekarcvfhraicFbGhicrhldninao8SbbgdcFbGaltaiVhiadcu9kmeaocefhoalcrfglc8J9hmbxdkkaocefhrkabaDcdtfaic8Etc8F91aicd47avcwfaiceGcdtVgoydbfglBdbaoalBdbaDcefgDae9hmbxdkkcbhDindnaraw6mbc9:skarcefhoar8SbbglcFeGhidndnalcu9mmbaohrxekarcvfhraicFbGhicrhldninao8SbbgdcFbGaltaiVhiadcu9kmeaocefhoalcrfglc8J9hmbxdkkaocefhrkabaDcetfaic8Etc8F91aicd47avcwfaiceGcdtVgoydbfgl87ebaoalBdbaDcefgDae9hmbkkcbc99arawSEhokaok:wPliuo97eue978Jjjjjbca9Rhiaec98Ghldndnadcl9hmbdnalTmbcbhvabhdinadadpbbbgocKp:RecKp:Sep;6egraocwp:RecKp:Sep;6earp;Geaoczp:RecKp:Sep;6egwp;Gep;Kep;LegDpxbbbbbbbbbbbbbbbbp:2egqarpxbbbjbbbjbbbjbbbjgkp9op9rp;Kegrpxbb;:9cbb;:9cbb;:9cbb;:9cararp;MeaDaDp;Meawaqawakp9op9rp;Kegrarp;Mep;Kep;Kep;Jep;Negwp;Mepxbbn0bbn0bbn0bbn0gqp;KepxFbbbFbbbFbbbFbbbp9oaopxbbbFbbbFbbbFbbbFp9op9qarawp;Meaqp;Kecwp:RepxbFbbbFbbbFbbbFbbp9op9qaDawp;Meaqp;Keczp:RepxbbFbbbFbbbFbbbFbp9op9qpkbbadczfhdavclfgval6mbkkalaeSmeaipxbbbbbbbbbbbbbbbbgqpklbaiabalcdtfgdaeciGglcdtgv;8qbbdnalTmbaiaipblbgocKp:RecKp:Sep;6egraocwp:RecKp:Sep;6earp;Geaoczp:RecKp:Sep;6egwp;Gep;Kep;LegDaqp:2egqarpxbbbjbbbjbbbjbbbjgkp9op9rp;Kegrpxbb;:9cbb;:9cbb;:9cbb;:9cararp;MeaDaDp;Meawaqawakp9op9rp;Kegrarp;Mep;Kep;Kep;Jep;Negwp;Mepxbbn0bbn0bbn0bbn0gqp;KepxFbbbFbbbFbbbFbbbp9oaopxbbbFbbbFbbbFbbbFp9op9qarawp;Meaqp;Kecwp:RepxbFbbbFbbbFbbbFbbp9op9qaDawp;Meaqp;Keczp:RepxbbFbbbFbbbFbbbFbp9op9qpklbkadaiav;8qbbskdnalTmbcbhvabhdinadczfgxaxpbbbgopxbbbbbbFFbbbbbbFFgkp9oadpbbbgDaopmbediwDqkzHOAKY8AEgwczp:Reczp:Sep;6egraDaopmlvorxmPsCXQL358E8FpxFubbFubbFubbFubbp9op;6eawczp:Sep;6egwp;Gearp;Gep;Kep;Legopxbbbbbbbbbbbbbbbbp:2egqarpxbbbjbbbjbbbjbbbjgmp9op9rp;Kegrpxb;:FSb;:FSb;:FSb;:FSararp;Meaoaop;Meawaqawamp9op9rp;Kegrarp;Mep;Kep;Kep;Jep;Negwp;Mepxbbn0bbn0bbn0bbn0gqp;KepxFFbbFFbbFFbbFFbbp9oaoawp;Meaqp;Keczp:Rep9qgoarawp;Meaqp;KepxFFbbFFbbFFbbFFbbp9ogrpmwDKYqk8AExm35Ps8E8Fp9qpkbbadaDakp9oaoarpmbezHdiOAlvCXorQLp9qpkbbadcafhdavclfgval6mbkkalaeSmbaiaeciGgvcitgdfcbcaad9R;8kbaiabalcitfglad;8qbbdnavTmbaiaipblzgopxbbbbbbFFbbbbbbFFgkp9oaipblbgDaopmbediwDqkzHOAKY8AEgwczp:Reczp:Sep;6egraDaopmlvorxmPsCXQL358E8FpxFubbFubbFubbFubbp9op;6eawczp:Sep;6egwp;Gearp;Gep;Kep;Legopxbbbbbbbbbbbbbbbbp:2egqarpxbbbjbbbjbbbjbbbjgmp9op9rp;Kegrpxb;:FSb;:FSb;:FSb;:FSararp;Meaoaop;Meawaqawamp9op9rp;Kegrarp;Mep;Kep;Kep;Jep;Negwp;Mepxbbn0bbn0bbn0bbn0gqp;KepxFFbbFFbbFFbbFFbbp9oaoawp;Meaqp;Keczp:Rep9qgoarawp;Meaqp;KepxFFbbFFbbFFbbFFbbp9ogrpmwDKYqk8AExm35Ps8E8Fp9qpklzaiaDakp9oaoarpmbezHdiOAlvCXorQLp9qpklbkalaiad;8qbbkk;4wllue97euv978Jjjjjbc8W9Rhidnaec98GglTmbcbhvabhoinaiaopbbbgraoczfgwpbbbgDpmlvorxmPsCXQL358E8Fgqczp:Segkclp:RepklbaopxbbjZbbjZbbjZbbjZpx;Zl81Z;Zl81Z;Zl81Z;Zl81Zakpxibbbibbbibbbibbbp9qp;6ep;NegkaraDpmbediwDqkzHOAKY8AEgrczp:Reczp:Sep;6ep;MegDaDp;Meakarczp:Sep;6ep;Megxaxp;Meakaqczp:Reczp:Sep;6ep;Megqaqp;Mep;Kep;Kep;Lepxbbbbbbbbbbbbbbbbp:4ep;Jepxb;:FSb;:FSb;:FSb;:FSgkp;Mepxbbn0bbn0bbn0bbn0grp;KepxFFbbFFbbFFbbFFbbgmp9oaxakp;Mearp;Keczp:Rep9qgxaDakp;Mearp;Keamp9oaqakp;Mearp;Keczp:Rep9qgkpmbezHdiOAlvCXorQLgrp5baipblbpEb:T:j83ibaocwfarp5eaipblbpEe:T:j83ibawaxakpmwDKYqk8AExm35Ps8E8Fgkp5baipblbpEd:T:j83ibaocKfakp5eaipblbpEi:T:j83ibaocafhoavclfgval6mbkkdnalaeSmbaiaeciGgvcitgofcbcaao9R;8kbaiabalcitfgwao;8qbbdnavTmbaiaipblbgraipblzgDpmlvorxmPsCXQL358E8Fgqczp:Segkclp:RepklaaipxbbjZbbjZbbjZbbjZpx;Zl81Z;Zl81Z;Zl81Z;Zl81Zakpxibbbibbbibbbibbbp9qp;6ep;NegkaraDpmbediwDqkzHOAKY8AEgrczp:Reczp:Sep;6ep;MegDaDp;Meakarczp:Sep;6ep;Megxaxp;Meakaqczp:Reczp:Sep;6ep;Megqaqp;Mep;Kep;Kep;Lepxbbbbbbbbbbbbbbbbp:4ep;Jepxb;:FSb;:FSb;:FSb;:FSgkp;Mepxbbn0bbn0bbn0bbn0grp;KepxFFbbFFbbFFbbFFbbgmp9oaxakp;Mearp;Keczp:Rep9qgxaDakp;Mearp;Keamp9oaqakp;Mearp;Keczp:Rep9qgkpmbezHdiOAlvCXorQLgrp5baipblapEb:T:j83ibaiarp5eaipblapEe:T:j83iwaiaxakpmwDKYqk8AExm35Ps8E8Fgkp5baipblapEd:T:j83izaiakp5eaipblapEi:T:j83iKkawaiao;8qbbkk:Pddiue978Jjjjjbc;ab9Rhidnadcd4ae2glc98GgvTmbcbheabhdinadadpbbbgocwp:Recwp:Sep;6eaocep:SepxbbjFbbjFbbjFbbjFp9opxbbjZbbjZbbjZbbjZp:Uep;Mepkbbadczfhdaeclfgeav6mbkkdnavalSmbaialciGgecdtgdVcbc;abad9R;8kbaiabavcdtfgvad;8qbbdnaeTmbaiaipblbgocwp:Recwp:Sep;6eaocep:SepxbbjFbbjFbbjFbbjFp9opxbbjZbbjZbbjZbbjZp:Uep;Mepklbkavaiad;8qbbkk9teiucbcbydj1jjbgeabcifc98GfgbBdj1jjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaikkkebcjwklz:Dbb"):unpack("b9H79Tebbbe8Fv9Gbb9Gvuuuuueu9Giuuub9Geueu9Giuuueuikqbeeedddillviebeoweuec:q:Odkr;leDo9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bb8A9TW79O9V9Wt9F9KW9J9V9KW9wWVtW949c919M9MWVbeY9TW79O9V9Wt9F9KW9J9V9KW69U9KW949c919M9MWVbdE9TW79O9V9Wt9F9KW9J9V9KW69U9KW949tWG91W9U9JWbiL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9p9JtblK9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9r919HtbvL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVT949Wbol79IV9Rbrq;w8Wqdbk;esezu8Jjjjjbcj;eb9Rgv8Kjjjjbc9:hodnadcefal0mbcuhoaiRbbc:Ge9hmbavaialfgrad9Radz1jjjbhwcj;abad9Uc;WFbGgocjdaocjd6EhDaicefhocbhqdnindndndnaeaq9nmbaDaeaq9RaqaDfae6Egkcsfglcl4cifcd4hxalc9WGgmTmecbhPawcjdfhsaohzinaraz9Rax6mvarazaxfgo9RcK6mvczhlcbhHinalgic9WfgOawcj;cbffhldndndndndnazaOco4fRbbaHcoG4ciGPlbedibkal9cb83ibalcwf9cb83ibxikalaoRblaoRbbgOco4gAaAciSgAE86bbawcj;cbfaifglcGfaoclfaAfgARbbaOcl4ciGgCaCciSgCE86bbalcVfaAaCfgARbbaOcd4ciGgCaCciSgCE86bbalc7faAaCfgARbbaOciGgOaOciSgOE86bbalctfaAaOfgARbbaoRbegOco4gCaCciSgCE86bbalc91faAaCfgARbbaOcl4ciGgCaCciSgCE86bbalc4faAaCfgARbbaOcd4ciGgCaCciSgCE86bbalc93faAaCfgARbbaOciGgOaOciSgOE86bbalc94faAaOfgARbbaoRbdgOco4gCaCciSgCE86bbalc95faAaCfgARbbaOcl4ciGgCaCciSgCE86bbalc96faAaCfgARbbaOcd4ciGgCaCciSgCE86bbalc97faAaCfgARbbaOciGgOaOciSgOE86bbalc98faAaOfgORbbaoRbigoco4gAaAciSgAE86bbalc99faOaAfgORbbaocl4ciGgAaAciSgAE86bbalc9:faOaAfgORbbaocd4ciGgAaAciSgAE86bbalcufaOaAfglRbbaociGgoaociSgoE86bbalaofhoxdkalaoRbwaoRbbgOcl4gAaAcsSgAE86bbawcj;cbfaifglcGfaocwfaAfgARbbaOcsGgOaOcsSgOE86bbalcVfaAaOfgORbbaoRbegAcl4gCaCcsSgCE86bbalc7faOaCfgORbbaAcsGgAaAcsSgAE86bbalctfaOaAfgORbbaoRbdgAcl4gCaCcsSgCE86bbalc91faOaCfgORbbaAcsGgAaAcsSgAE86bbalc4faOaAfgORbbaoRbigAcl4gCaCcsSgCE86bbalc93faOaCfgORbbaAcsGgAaAcsSgAE86bbalc94faOaAfgORbbaoRblgAcl4gCaCcsSgCE86bbalc95faOaCfgORbbaAcsGgAaAcsSgAE86bbalc96faOaAfgORbbaoRbvgAcl4gCaCcsSgCE86bbalc97faOaCfgORbbaAcsGgAaAcsSgAE86bbalc98faOaAfgORbbaoRbogAcl4gCaCcsSgCE86bbalc99faOaCfgORbbaAcsGgAaAcsSgAE86bbalc9:faOaAfgORbbaoRbrgocl4gAaAcsSgAE86bbalcufaOaAfglRbbaocsGgoaocsSgoE86bbalaofhoxekalao8Pbb83bbalcwfaocwf8Pbb83bbaoczfhokdnaiam9pmbaHcdfhHaiczfhlarao9RcL0mekkaiam6mvaoTmvdnakTmbawaPfRbbhHawcj;cbfhlashiakhOinaialRbbgzce4cbazceG9R7aHfgH86bbaiadfhialcefhlaOcufgOmbkkascefhsaohzaPcefgPad9hmbxikkcbc99arao9Radcaadca0ESEhoxlkaoaxad2fhCdnakmbadhlinaoTmlarao9Rax6mlaoaxfhoalcufglmbkaChoxekcbhmawcjdfhAinarao9Rax6miawamfRbbhHawcj;cbfhlaAhiakhOinaialRbbgzce4cbazceG9R7aHfgH86bbaiadfhialcefhlaOcufgOmbkaAcefhAaoaxfhoamcefgmad9hmbkaChokabaqad2fawcjdfakad2z1jjjb8Aawawcjdfakcufad2fadz1jjjb8Aakaqfhqaombkc9:hoxekc9:hokavcj;ebf8Kjjjjbaok;cseHu8Jjjjjbc;ae9Rgv8Kjjjjbc9:hodnaeci9UgrcHfal0mbcuhoaiRbbgwc;WeGc;Ge9hmbawcsGgwce0mbavc;abfcFecjez:jjjjb8AavcUf9cu83ibavc8Wf9cu83ibavcyf9cu83ibavcaf9cu83ibavcKf9cu83ibavczf9cu83ibav9cu83iwav9cu83ibaialfc9WfhDaicefgqarfhidnaeTmbcmcsawceSEhkcbhxcbhmcbhPcbhwcbhlindnaiaD9nmbc9:hoxikdndnaqRbbgoc;Ve0mbavc;abfalaocu7gscl4fcsGcitfgzydlhrazydbhzdnaocsGgHak9pmbavawasfcsGcdtfydbaxaHEhoaHThsdndnadcd9hmbabaPcetfgHaz87ebaHclfao87ebaHcdfar87ebxekabaPcdtfgHazBdbaHcwfaoBdbaHclfarBdbkaxasfhxcdhHavawcdtfaoBdbawasfhwcehsalhOxdkdndnaHcsSmbaHc987aHamffcefhoxekaicefhoai8SbbgHcFeGhsdndnaHcu9mmbaohixekaicvfhiascFbGhscrhHdninao8SbbgOcFbGaHtasVhsaOcu9kmeaocefhoaHcrfgHc8J9hmbxdkkaocefhikasce4cbasceG9R7amfhokdndnadcd9hmbabaPcetfgHaz87ebaHclfao87ebaHcdfar87ebxekabaPcdtfgHazBdbaHcwfaoBdbaHclfarBdbkcdhHavawcdtfaoBdbcehsawcefhwalhOaohmxekdnaocpe0mbaxcefgHavawaDaocsGfRbbgocl49RcsGcdtfydbaocz6gzEhravawao9RcsGcdtfydbaHazfgAaocsGgHEhoaHThCdndnadcd9hmbabaPcetfgHax87ebaHclfao87ebaHcdfar87ebxekabaPcdtfgHaxBdbaHcwfaoBdbaHclfarBdbkcdhsavawcdtfaxBdbavawcefgwcsGcdtfarBdbcihHavc;abfalcitfgOaxBdlaOarBdbavawazfgwcsGcdtfaoBdbalcefcsGhOawaCfhwaxhzaAaCfhxxekaxcbaiRbbgOEgzaoc;:eSgHfhraOcsGhCaOcl4hAdndnaOcs0mbarcefhoxekarhoavawaA9RcsGcdtfydbhrkdndnaCmbaocefhxxekaohxavawaO9RcsGcdtfydbhokdndnaHTmbaicefhHxekaicdfhHai8SbegscFeGhzdnascu9kmbaicofhXazcFbGhzcrhidninaH8SbbgscFbGaitazVhzascu9kmeaHcefhHaicrfgic8J9hmbkaXhHxekaHcefhHkazce4cbazceG9R7amfgmhzkdndnaAcsSmbaHhsxekaHcefhsaH8SbbgicFeGhrdnaicu9kmbaHcvfhXarcFbGhrcrhidninas8SbbgHcFbGaitarVhraHcu9kmeascefhsaicrfgic8J9hmbkaXhsxekascefhskarce4cbarceG9R7amfgmhrkdndnaCcsSmbashixekascefhias8SbbgocFeGhHdnaocu9kmbascvfhXaHcFbGhHcrhodninai8SbbgscFbGaotaHVhHascu9kmeaicefhiaocrfgoc8J9hmbkaXhixekaicefhikaHce4cbaHceG9R7amfgmhokdndnadcd9hmbabaPcetfgHaz87ebaHclfao87ebaHcdfar87ebxekabaPcdtfgHazBdbaHcwfaoBdbaHclfarBdbkcdhsavawcdtfazBdbavawcefgwcsGcdtfarBdbcihHavc;abfalcitfgXazBdlaXarBdbavawaOcz6aAcsSVfgwcsGcdtfaoBdbawaCTaCcsSVfhwalcefcsGhOkaqcefhqavc;abfaOcitfgOarBdlaOaoBdbavc;abfalasfcsGcitfgraoBdlarazBdbawcsGhwalaHfcsGhlaPcifgPae6mbkkcbc99aiaDSEhokavc;aef8Kjjjjbaok:flevu8Jjjjjbcz9Rhvc9:hodnaecvfal0mbcuhoaiRbbc;:eGc;qe9hmbav9cb83iwaicefhraialfc98fhwdnaeTmbdnadcdSmbcbhDindnaraw6mbc9:skarcefhoar8SbbglcFeGhidndnalcu9mmbaohrxekarcvfhraicFbGhicrhldninao8SbbgdcFbGaltaiVhiadcu9kmeaocefhoalcrfglc8J9hmbxdkkaocefhrkabaDcdtfaic8Etc8F91aicd47avcwfaiceGcdtVgoydbfglBdbaoalBdbaDcefgDae9hmbxdkkcbhDindnaraw6mbc9:skarcefhoar8SbbglcFeGhidndnalcu9mmbaohrxekarcvfhraicFbGhicrhldninao8SbbgdcFbGaltaiVhiadcu9kmeaocefhoalcrfglc8J9hmbxdkkaocefhrkabaDcetfaic8Etc8F91aicd47avcwfaiceGcdtVgoydbfgl87ebaoalBdbaDcefgDae9hmbkkcbc99arawSEhokaok:Lvoeue99dud99eud99dndnadcl9hmbaeTmeindndnabcdfgd8Sbb:Yab8Sbbgi:Ygl:l:tabcefgv8Sbbgo:Ygr:l:tgwJbb;:9cawawNJbbbbawawJbbbb9GgDEgq:mgkaqaicb9iEalMgwawNakaqaocb9iEarMgqaqNMM:r:vglNJbbbZJbbb:;aDEMgr:lJbbb9p9DTmbar:Ohixekcjjjj94hikadai86bbdndnaqalNJbbbZJbbb:;aqJbbbb9GEMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkavad86bbdndnawalNJbbbZJbbb:;awJbbbb9GEMgw:lJbbb9p9DTmbaw:Ohdxekcjjjj94hdkabad86bbabclfhbaecufgembxdkkaeTmbindndnabclfgd8Ueb:Yab8Uebgi:Ygl:l:tabcdfgv8Uebgo:Ygr:l:tgwJb;:FSawawNJbbbbawawJbbbb9GgDEgq:mgkaqaicb9iEalMgwawNakaqaocb9iEarMgqaqNMM:r:vglNJbbbZJbbb:;aDEMgr:lJbbb9p9DTmbar:Ohixekcjjjj94hikadai87ebdndnaqalNJbbbZJbbb:;aqJbbbb9GEMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkavad87ebdndnawalNJbbbZJbbb:;awJbbbb9GEMgw:lJbbb9p9DTmbaw:Ohdxekcjjjj94hdkabad87ebabcwfhbaecufgembkkk;oiliui99iue99dnaeTmbcbhiabhlindndnJ;Zl81Zalcof8UebgvciV:Y:vgoal8Ueb:YNgrJb;:FSNJbbbZJbbb:;arJbbbb9GEMgw:lJbbb9p9DTmbaw:OhDxekcjjjj94hDkalclf8Uebhqalcdf8UebhkabaiavcefciGfcetfaD87ebdndnaoak:YNgwJb;:FSNJbbbZJbbb:;awJbbbb9GEMgx:lJbbb9p9DTmbax:OhDxekcjjjj94hDkabaiavciGfgkcd7cetfaD87ebdndnaoaq:YNgoJb;:FSNJbbbZJbbb:;aoJbbbb9GEMgx:lJbbb9p9DTmbax:OhDxekcjjjj94hDkabaiavcufciGfcetfaD87ebdndnJbbjZararN:tawawN:taoaoN:tgrJbbbbarJbbbb9GE:rJb;:FSNJbbbZMgr:lJbbb9p9DTmbar:Ohvxekcjjjj94hvkabakcetfav87ebalcwfhlaiclfhiaecufgembkkk9mbdnadcd4ae2gdTmbinababydbgecwtcw91:Yaece91cjjj98Gcjjj;8if::NUdbabclfhbadcufgdmbkkk9teiucbcbydj1jjbgeabcifc98GfgbBdj1jjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaik;LeeeudndnaeabVciGTmbabhixekdndnadcz9pmbabhixekabhiinaiaeydbBdbaiclfaeclfydbBdbaicwfaecwfydbBdbaicxfaecxfydbBdbaeczfheaiczfhiadc9Wfgdcs0mbkkadcl6mbinaiaeydbBdbaeclfheaiclfhiadc98fgdci0mbkkdnadTmbinaiaeRbb86bbaicefhiaecefheadcufgdmbkkabk;aeedudndnabciGTmbabhixekaecFeGc:b:c:ew2hldndnadcz9pmbabhixekabhiinaialBdbaicxfalBdbaicwfalBdbaiclfalBdbaiczfhiadc9Wfgdcs0mbkkadcl6mbinaialBdbaiclfhiadc98fgdci0mbkkdnadTmbinaiae86bbaicefhiadcufgdmbkkabkkkebcjwklzNbb"),r=WebAssembly.instantiate(i,{}).then((function(e){(n=e.instance).exports.__wasm_call_ctors()}));function unpack(e){for(var n=new Uint8Array(e.length),i=0;i<e.length;++i){var r=e.charCodeAt(i);n[i]=r>96?r-97:r>64?r-39:r+4}var s=0;for(i=0;i<e.length;++i)n[s++]=n[i]<60?t[n[i]]:64*(n[i]-60)+n[++i];return n.buffer.slice(0,s)}function decode(e,t,n,i,r,s,o){var a=e.exports.sbrk,A=i+3&-4,l=a(A*r),c=a(s.length),p=new Uint8Array(e.exports.memory.buffer);p.set(s,c);var h=t(l,i,r,c,s.length);if(0==h&&o&&o(l,A,r),n.set(p.subarray(l,l+i*r)),a(l-a(0)),0!=h)throw new Error("Malformed buffer data: "+h)}var s={NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},o={ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"},a=[],A=0;function createWorker(e){var t={object:new Worker(e),pending:0,requests:{}};return t.object.onmessage=function(e){var n=e.data;t.pending-=n.count,t.requests[n.id][n.action](n.value),delete t.requests[n.id]},t}function workerProcess(e){var t=e.data;if(!t.id)return self.close();self.ready.then((function(e){try{var n=new Uint8Array(t.count*t.size);decode(e,e.exports[t.mode],n,t.count,t.size,t.source,e.exports[t.filter]),self.postMessage({id:t.id,count:t.count,action:"resolve",value:n},[n.buffer])}catch(e){self.postMessage({id:t.id,count:t.count,action:"reject",value:e})}}))}return{ready:r,supported:!0,useWorkers:function(e){!function initWorkers(e){for(var t="self.ready = WebAssembly.instantiate(new Uint8Array(["+new Uint8Array(i)+"]), {}).then(function(result) { result.instance.exports.__wasm_call_ctors(); return result.instance; });self.onmessage = "+workerProcess.name+";"+decode.toString()+workerProcess.toString(),n=new Blob([t],{type:"text/javascript"}),r=URL.createObjectURL(n),s=a.length;s<e;++s)a[s]=createWorker(r);for(s=e;s<a.length;++s)a[s].object.postMessage({});a.length=e,URL.revokeObjectURL(r)}(e)},decodeVertexBuffer:function(e,t,i,r,o){decode(n,n.exports.meshopt_decodeVertexBuffer,e,t,i,r,n.exports[s[o]])},decodeIndexBuffer:function(e,t,i,r){decode(n,n.exports.meshopt_decodeIndexBuffer,e,t,i,r)},decodeIndexSequence:function(e,t,i,r){decode(n,n.exports.meshopt_decodeIndexSequence,e,t,i,r)},decodeGltfBuffer:function(e,t,i,r,a,A){decode(n,n.exports[o[a]],e,t,i,r,n.exports[s[A]])},decodeGltfBufferAsync:function(e,t,i,l,c){return a.length>0?function decodeWorker(e,t,n,i,r){for(var s=a[0],o=1;o<a.length;++o)a[o].pending<s.pending&&(s=a[o]);return new Promise((function(o,a){var l=new Uint8Array(n),c=++A;s.pending+=e,s.requests[c]={resolve:o,reject:a},s.object.postMessage({id:c,count:e,size:t,source:l,mode:i,filter:r},[l.buffer])}))}(e,t,i,o[l],s[c]):r.then((function(){var r=new Uint8Array(e*t);return decode(n,n.exports[o[l]],r,e,t,i,n.exports[s[c]]),r}))}}}();class TDSLoader extends E{constructor(e){super(e),this.debug=!1,this.group=null,this.materials=[],this.meshes=[]}load(e,t,n,i){const r=this,s=""===this.path?w.extractUrlBase(e):this.path,o=new v(this.manager);o.setPath(this.path),o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,(function(n){try{t(r.parse(n,s))}catch(t){i?i(t):console.error(t),r.manager.itemError(e)}}),n,i)}parse(e,t){this.group=new le,this.materials=[],this.meshes=[],this.readFile(e,t);for(let e=0;e<this.meshes.length;e++)this.group.add(this.meshes[e]);return this.group}readFile(e,t){const n=new DataView(e),i=new Chunk(n,0,this.debugMessage);if(i.id===ss||i.id===os||i.id===rs){let e=i.readChunk();for(;e;){if(e.id===as){const t=e.readDWord();this.debugMessage("3DS file version: "+t)}else e.id===ds?this.readMeshData(e,t):this.debugMessage("Unknown main chunk: "+e.hexId);e=i.readChunk()}}this.debugMessage("Parsed "+this.meshes.length+" meshes")}readMeshData(e,t){let n=e.readChunk();for(;n;){if(n.id===gs){const e=+n.readDWord();this.debugMessage("Mesh Version: "+e)}else if(n.id===fs){const e=n.readFloat();this.debugMessage("Master scale: "+e),this.group.scale.set(e,e,e)}else n.id===Rs?(this.debugMessage("Named Object"),this.readNamedObject(n)):n.id===ms?(this.debugMessage("Material"),this.readMaterialEntry(n,t)):this.debugMessage("Unknown MDATA chunk: "+n.hexId);n=e.readChunk()}}readNamedObject(e){const t=e.readString();let n=e.readChunk();for(;n;){if(n.id===Ns){const e=this.readMesh(n);e.name=t,this.meshes.push(e)}else this.debugMessage("Unknown named object chunk: "+n.hexId);n=e.readChunk()}}readMaterialEntry(e,t){let n=e.readChunk();const i=new at;for(;n;){if(n.id===ys)i.name=n.readString(),this.debugMessage(" Name: "+i.name);else if(n.id===vs)this.debugMessage(" Wireframe"),i.wireframe=!0;else if(n.id===Qs){const e=n.readByte();i.wireframeLinewidth=e,this.debugMessage(" Wireframe Thickness: "+e)}else if(n.id===Es)i.side=te,this.debugMessage(" DoubleSided");else if(n.id===ws)this.debugMessage(" Additive Blending"),i.blending=At;else if(n.id===Is)this.debugMessage(" Diffuse Color"),i.color=this.readColor(n);else if(n.id===xs)this.debugMessage(" Specular Color"),i.specular=this.readColor(n);else if(n.id===bs)this.debugMessage(" Ambient color"),i.color=this.readColor(n);else if(n.id===Cs){const e=this.readPercentage(n);i.shininess=100*e,this.debugMessage(" Shininess : "+e)}else if(n.id===Bs){const e=this.readPercentage(n);i.opacity=1-e,this.debugMessage(" Transparency : "+e),i.transparent=i.opacity<1}else n.id===Ps?(this.debugMessage(" ColorMap"),i.map=this.readMap(n,t)):n.id===Ss?(this.debugMessage(" BumpMap"),i.bumpMap=this.readMap(n,t)):n.id===Ts?(this.debugMessage(" OpacityMap"),i.alphaMap=this.readMap(n,t)):n.id===Ms?(this.debugMessage(" SpecularMap"),i.specularMap=this.readMap(n,t)):this.debugMessage(" Unknown material chunk: "+n.hexId);n=e.readChunk()}this.materials[i.name]=i}readMesh(e){let t=e.readChunk();const n=new C,i=new at,r=new d(n,i);for(r.name="mesh";t;){if(t.id===Os){const e=t.readWord();this.debugMessage(" Vertex: "+e);const i=[];for(let n=0;n<e;n++)i.push(t.readFloat()),i.push(t.readFloat()),i.push(t.readFloat());n.setAttribute("position",new a(i,3))}else if(t.id===Gs)this.readFaceArray(t,r);else if(t.id===Ys){const e=t.readWord();this.debugMessage(" UV: "+e);const i=[];for(let n=0;n<e;n++)i.push(t.readFloat()),i.push(t.readFloat());n.setAttribute("uv",new a(i,2))}else if(t.id===zs){this.debugMessage(" Tranformation Matrix (TODO)");const e=[];for(let n=0;n<12;n++)e[n]=t.readFloat();const i=new m;i.elements[0]=e[0],i.elements[1]=e[6],i.elements[2]=e[3],i.elements[3]=e[9],i.elements[4]=e[2],i.elements[5]=e[8],i.elements[6]=e[5],i.elements[7]=e[11],i.elements[8]=e[1],i.elements[9]=e[7],i.elements[10]=e[4],i.elements[11]=e[10],i.elements[12]=0,i.elements[13]=0,i.elements[14]=0,i.elements[15]=1,i.transpose();const s=new m;s.copy(i).invert(),n.applyMatrix4(s),i.decompose(r.position,r.quaternion,r.scale)}else this.debugMessage(" Unknown mesh chunk: "+t.hexId);t=e.readChunk()}return n.computeVertexNormals(),r}readFaceArray(e,t){const n=e.readWord();this.debugMessage(" Faces: "+n);const i=[];for(let t=0;t<n;++t)i.push(e.readWord(),e.readWord(),e.readWord()),e.readWord();t.geometry.setIndex(i);let r=0,s=0;for(;!e.endOfChunk;){const n=e.readChunk();if(n.id===Us){this.debugMessage(" Material Group");const e=this.readMaterialGroup(n),i=3*e.index.length;t.geometry.addGroup(s,i,r),s+=i,r++;const o=this.materials[e.name];!1===Array.isArray(t.material)&&(t.material=[]),void 0!==o&&t.material.push(o)}else this.debugMessage(" Unknown face array chunk: "+n.hexId)}1===t.material.length&&(t.material=t.material[0])}readMap(e,t){let n=e.readChunk(),i={};const r=new O(this.manager);for(r.setPath(this.resourcePath||t).setCrossOrigin(this.crossOrigin);n;){if(n.id===Ds){const e=n.readString();i=r.load(e),i.userData.name=e.split(".").slice(0,-1).join("."),this.debugMessage(" File: "+t+e)}else n.id===Fs?(i.offset.x=n.readFloat(),this.debugMessage(" OffsetX: "+i.offset.x)):n.id===ks?(i.offset.y=n.readFloat(),this.debugMessage(" OffsetY: "+i.offset.y)):n.id===Ls?(i.repeat.x=n.readFloat(),this.debugMessage(" RepeatX: "+i.repeat.x)):n.id===_s?(i.repeat.y=n.readFloat(),this.debugMessage(" RepeatY: "+i.repeat.y)):this.debugMessage(" Unknown map chunk: "+n.hexId);n=e.readChunk()}return i}readMaterialGroup(e){const t=e.readString(),n=e.readWord();this.debugMessage(" Name: "+t),this.debugMessage(" Faces: "+n);const i=[];for(let t=0;t<n;++t)i.push(e.readWord());return{name:t,index:i}}readColor(e){const t=e.readChunk(),n=new T;if(t.id===ls||t.id===cs){const e=t.readByte(),i=t.readByte(),r=t.readByte();n.setRGB(e/255,i/255,r/255),this.debugMessage(" Color: "+n.r+", "+n.g+", "+n.b)}else if(t.id===As||t.id===ps){const e=t.readFloat(),i=t.readFloat(),r=t.readFloat();n.setRGB(e,i,r),this.debugMessage(" Color: "+n.r+", "+n.g+", "+n.b)}else this.debugMessage(" Unknown color chunk: "+t.hexId);return n}readPercentage(e){const t=e.readChunk();switch(t.id){case hs:return t.readShort()/100;case us:return t.readFloat();default:return this.debugMessage(" Unknown percentage chunk: "+t.hexId),0}}debugMessage(e){this.debug&&console.log(e)}}class Chunk{constructor(e,t,n){this.data=e,this.offset=t,this.position=t,this.debugMessage=n,this.debugMessage instanceof Function&&(this.debugMessage=function(){}),this.id=this.readWord(),this.size=this.readDWord(),this.end=this.offset+this.size,this.end>e.byteLength&&this.debugMessage("Bad chunk size for chunk at "+t)}readChunk(){if(this.endOfChunk)return null;try{const e=new Chunk(this.data,this.position,this.debugMessage);return this.position+=e.size,e}catch(e){return this.debugMessage("Unable to read chunk at "+this.position),null}}get hexId(){return this.id.toString(16)}get endOfChunk(){return this.position>=this.end}readByte(){const e=this.data.getUint8(this.position,!0);return this.position+=1,e}readFloat(){try{const e=this.data.getFloat32(this.position,!0);return this.position+=4,e}catch(e){return this.debugMessage(e+" "+this.position+" "+this.data.byteLength),0}}readInt(){const e=this.data.getInt32(this.position,!0);return this.position+=4,e}readShort(){const e=this.data.getInt16(this.position,!0);return this.position+=2,e}readDWord(){const e=this.data.getUint32(this.position,!0);return this.position+=4,e}readWord(){const e=this.data.getUint16(this.position,!0);return this.position+=2,e}readString(){let e="",t=this.readByte();for(;t;)e+=String.fromCharCode(t),t=this.readByte();return e}}const rs=19789,ss=15786,os=49725,as=2,As=16,ls=17,cs=18,ps=19,hs=48,us=49,ds=15677,gs=15678,fs=256,ms=45055,ys=40960,bs=40976,Is=40992,xs=41008,Cs=41024,Bs=41040,Es=41089,ws=41091,vs=41093,Qs=41095,Ps=41472,Ts=41488,Ss=41520,Ms=41476,Ds=41728,Ls=41812,_s=41814,Fs=41816,ks=41818,Rs=16384,Ns=16640,Os=16656,Gs=16672,Us=16688,Ys=16704,zs=16736;const to_std=(t,n)=>{if(!t||"MeshPhongMaterial"!==t.type)return t;if(n){const e=n.get(t);if(e)return e}const i=1-("number"==typeof t.shininess?Math.min(Math.max(t.shininess,0),100):30)/100,r=new e.MeshStandardMaterial({name:t.name,color:t.color,map:t.map,normalMap:t.normalMap,emissive:t.emissive,emissiveMap:t.emissiveMap,envMap:t.envMap,envMapIntensity:t.envMapIntensity??1,lightMap:t.lightMap,lightMapIntensity:t.lightMapIntensity,alphaTest:t.alphaTest,depthWrite:t.depthWrite,depthTest:t.depthTest,wireframe:t.wireframe,transparent:t.transparent,opacity:t.opacity,side:t.side,roughness:i,metalness:0});return n&&n.set(t,r),"function"==typeof t.dispose&&(t.dispose(),t.userData=t.userData||{},t.userData._replaced=!0),r.needsUpdate=!0,r};function newgcad(t,n,i,r=!0){let s={},o={},a={},A={},l={};const c=new Map;let p={},h={},u=[],d=new e.TextureLoader,g=new GLTFLoader,f=new TDSLoader;const m=new DRACOLoader;m.setDecoderPath("https://www.gstatic.com/draco/versioned/decoders/1.5.6/"),g.setDRACOLoader(m);const y=new KTX2Loader;y.setTranscoderPath("https://unpkg.com/three@0.159.0/examples/jsm/libs/basis/"),g.setKTX2Loader(y),g.setMeshoptDecoder(is);let b=[i],getcat=()=>b[b.length-1],I={};async function clearmat(){for(const e in o)if(o[e]){const t=await o[e];t?.dispose()}for(const e in p)p[e]&&p[e]?.dispose();for(const[e,t]of c.entries()){const e=t instanceof Promise?await t:t;e?.dispose&&e.dispose()}c.clear(),o={},p={}}function getdims(t,n=!1){let i=new e.Box3,n2=e=>Math.round(100*e)/100;return t.updateWorldMatrix(!0,!0),n?t.traverse((e=>{e.visible&&e.isMesh&&e.geometry&&(e.geometry.computeBoundingBox(),i.union(e.geometry.boundingBox.clone().applyMatrix4(e.matrixWorld)))})):i.setFromObject(t),{zero:{x:n2(-i.min.x),y:n2(-i.min.y),z:n2(-i.min.z)},dim:{x:n2(i.max.x-i.min.x),y:n2(i.max.y-i.min.y),z:n2(i.max.z-i.min.z)},position:t.position,rotation:{x:t.rotation.x,y:t.rotation.y,z:t.rotation.z},scale:t.scale}}async function get3ds(n,i=!1){n.endsWith(".3ds")&&(n=n.slice(0,-4));const r=hash(`${getcat()}|${n}.3ds`);if(a[r])return a[r];let s=await new Promise(((e,i)=>{let s,o="";n.startsWith("https://")?(s=`${n}.3ds`,o=s):t._cdn?(s=`${t._cdn}${getcat()}/3d/${n}.3ds`,o=`${t._cdn}${getcat()}/3d/${n}/`):(s=t.fullget("mufiles/getfile",{id:getcat(),subfolder:"3d",name:n,ext:".3ds"}),o=s+"&tex="),f.setResourcePath(o),f.load(s,(t=>{const n=new WeakMap;t.traverse((e=>{e.isMesh&&e.material&&(e.material=Array.isArray(e.material)?e.material.map((e=>to_std(e,n))):to_std(e.material,n))})),t.userData||(t.userData={}),t.userData._ky=r,e(t)}),void 0,(t=>{console.log(t),delete a[r],e(void 0)}))}));if(i){let t=new e.Group;t.rotation.x=-Math.PI/2,t.add(s),a[r]=t}else a[r]=s;return a[r]}async function getglb(e){const n=".glb";e.endsWith(n)&&(e=e.slice(0,-4)),e.startsWith("https://")||(e=e.replace(/\//g,"+"));let i=(e=e.split("+"))[1];e=e[0];const r=hash(`${getcat()}|${e}${n}`);a[r]||(a[r]=await new Promise(((i,s)=>{let o;o=e.startsWith("https://")?`${e}.glb`:t._cdn?`${t._cdn}${getcat()}/3d/${e}.glb`:t.fullget("mufiles/getfile",{id:getcat(),subfolder:"3d",name:e,ext:n}),g.setPath(""),g.setResourcePath((e=>(console.log("risorsa",e),`${o}&tex=${e}`))),g.load(o,(async e=>{const t=e.scene;t.userData||(t.userData={}),t.userData._ky=r,i(t)}),void 0,(e=>{console.log(e),delete a[r],i(void 0)}))})));let s=a[r];if(i){let e=s?.getObjectByName(i);e&&(s=e)}return s}return{clearmatricole:()=>{I={},u=[]},P:t,bus:n,tex:async function tex(n,i=1,r,s){let a;return r||(r=i),s||(s=0),"__alpha"==n?(a=n,o[a]||(o[a]=function getfortransparent(){const t=new e.CanvasTexture(function generateTexture(){const e=document.createElement("canvas");e.width=2,e.height=2;const t=e.getContext("2d");return t.fillStyle="white",t.fillRect(0,1,2,1),e}());return t.magFilter=e.NearestFilter,t.wrapT=e.RepeatWrapping,t.wrapS=e.RepeatWrapping,t.repeat.set(1,3.5),t}()),o[a]):(a=hash(`${getcat()}|${n}|${i}|${r}|${s}`),o[a]||(o[a]=new Promise(((A,l)=>{let p;if(n.startsWith("https://"))p=n;else if(t._cdn)if(n.includes("/")){let e=n.split("/");p=`${t._cdn}${e[0]}/textures/${e[1]}`}else p=`${t._cdn}${getcat()}/textures/${n}`;else p=t.fullget("mufiles/getfile",{id:getcat(),subfolder:"textures",name:n,force:1});if(c.has(p)){const t=c.get(p).clone();return t.wrapS=e.RepeatWrapping,t.wrapT=e.RepeatWrapping,t.center.set(.5,.5),t.repeat.set(i,r),t.rotation=s,void A(t)}d.load(p,(t=>{c.set(p,t),t.wrapS=e.RepeatWrapping,t.wrapT=e.RepeatWrapping,t.repeat.set(i,r),t.center.set(.5,.5),t.rotation=s,A(t)}),void 0,(e=>{console.log(`Manca Texture ${n}!. questo rallenta molto il processo`),delete o[a],A(void 0)}))}))),o[a])},getglb:getglb,get3ds:get3ds,replacemats:function replacemats(e,t,n){if(!Array.isArray(t)||0==t.length)return e;const leggi_slot=e=>{if(!e)return-1;let t=(e?.map?.name||e?.name||e?.map?.userData?.name||"").toString().trim();if(n){const i=n(t,e);void 0!==i&&(t=i)}if(t.includes("_")&&(t=t.split("_").pop()),!t)return-1;const i=parseInt(t,10);return i>=1&&i<=9?i:-1};let i=!1,r=String(e.userData?._ky||"");if(e.traverse((e=>{if(!e.isMesh)return;const n=Array.isArray(e.material)?e.material:[e.material];for(const e of n){const n=leggi_slot(e);n>0&&t[n-1]&&(i=!0,r+="|"+(t[n-1].name||t[n-1].uuid))}})),i){if(r=hash(r),a[r])return a[r];const n=e.clone(!0);n.traverse((e=>{if(e.isMesh)if(Array.isArray(e.material))e.material=e.material.map((e=>{if(!e)return e;const n=leggi_slot(e);if(n>0&&t[n-1]){const e=t[n-1];return e.needsUpdate=!0,e}return e}));else{const n=e.material,i=leggi_slot(n);e.material=i>0&&t[i-1]?(t[i-1].needsUpdate=!0,t[i-1]):n}})),n.userData=n.userData||{},n.userData._ky=r,a[r]=n,e=n}return e},islog:r,clear:async function clear(){function destroymesh(e){function disposeMaterial(e){e.map&&e.map.dispose(),e.lightMap&&e.lightMap.dispose(),e.bumpMap&&e.bumpMap.dispose(),e.normalMap&&e.normalMap.dispose(),e.specularMap&&e.specularMap.dispose(),e.envMap&&e.envMap.dispose(),e.alphaMap&&e.alphaMap.dispose(),e.dispose()}e&&e.traverse((e=>{e.isMesh&&(e.onBeforeRender&&(e.onBeforeRender=null),e.onAfterRender&&(e.onAfterRender=null),e.geometry?.dispose&&e.geometry.dispose(),e.material&&(Array.isArray(e.material)?e.material.forEach(disposeMaterial):disposeMaterial(e.material)))}))}I={},l={},e.Cache.clear();for(const e in A)A[e]?.dispose();for(const e in a)if(a[e]){destroymesh(await a[e])}await clearmat(),s={},o={},a={},A={},p={},h={}},clearmat:clearmat,getdims:getdims,hidenodes:function hidenodes(e,t){let n=new Set;return e.traverse((e=>{(e.isMesh||e.isGroup)&&e.name&&(n.add(e.name),e.visible=!(t&&t.length&&t.includes(e.name.toLowerCase())))})),[...n]},info3d:async function info3d(e,t=1,n=0,i=0){let r=(e||"").endsWith(".3ds")?await get3ds(e):await getglb(e);if(r)return t&&1!=t&&(r.scale.set(t||1,n||t||1,i||t||1),r.needsUpdate=!0),getdims(r)},getScript:async function getScript(e){e.endsWith(".custom")?e=e.slice(0,-7):e.endsWith(".js")&&(e=e.slice(0,-3));let n=hash(`${getcat()}|${e}`);if(!h[n]){let i;try{i=await t.fetch("mufiles/customfn",{id:getcat(),name:e,ispar:1})}catch(t){i=`log('undefined ${getcat()}/${e}: ${t.message}');`}h[n]=i}return h[n]},checkScripts:async function checkScripts(e){let n=[];if(!e||!Array.isArray(e))return;let i=getcat();e=[...e,"_ricalcolatop","_ricalcolaaltri","_ricalcolalinee"];for(let t of e){let e=hash(`${i}|${t}`);h[e]||n.push(t)}if(n?.length){let e=await t.fetch("mufiles/customfn",{id:i,name:n,ispar:1});if(e)for(let t of e){let e=hash(`${i}|${t.n}`);h[e]=t.v}}},get loaderGLTF(){return g},get BTNS(){return u},get gmats(){return I},scripts:()=>Object.keys(h),get geo(){return A},get movs(){return s},get textures(){return o},get smats(){return p},get meshes(){return a},get cacheFns(){return l},dump(){console.log(`SMATS:\n${Object.keys(p).join(" - ")};\nGEOMS:\n${Object.keys(A).join(" - ")};\nTEX:\n${Object.keys(o).join(" - ")};\nMESH:\n${Object.keys(a).join(" - ")};\n`)},get cat(){return getcat()},pushcat(e){b.push(e)},popcat:()=>(b.length>1&&b.length--,getcat())}}const Hs=new Map;function salvaMaterialiOriginali(e){e.traverse((e=>{if(!e.isMesh||e.layers.mask>1<<20)return;const t=e.material;if(!t)return;const n=Array.isArray(t)?t:[t];Hs.has(e)||Hs.set(e,n)}))}function ripristinaMaterialiOriginali(){for(let[e,t]of Hs.entries())e.material=Array.isArray(t)?[...t]:t;Hs.clear()}function applicaEvidenziazione(e,t,n,i){!function ricorsiva(e,r,s){const o=!!r||!!t&&t.includes(e?.userData?.mat),a=s||e.userData?.evidenziaMap;if(e.isMesh&&e.layers.mask<=1<<20){const t=Hs.get(e);if(!t)return;const r=t.map((e=>{const t=(o?i:n).clone();return a&&e.map&&(t.map=e.map),t.transparent=e.transparent,t.opacity=e.opacity,t}));e.material=Array.isArray(e.material)?r:r[0]}e.children.forEach((e=>ricorsiva(e,o,a)))}(e,!1,!1)}async function evidenziaColli(t,n,i){salvaMaterialiOriginali(t);const r=e.DoubleSide,s=new e.MeshStandardMaterial({color:16777215,roughness:.5,metalness:.4,side:r}),o=new e.MeshStandardMaterial({color:36864,roughness:.5,metalness:.4,side:r});let a=0;try{for(let e of n)a++,e.name||(e.name=`collo_${a}`),applicaEvidenziazione(t,e.mats,s,o),await i(e)}catch(e){console.error("Errore durante evidenzia:",e)}finally{ripristinaMaterialiOriginali()}}const Xs=1.25,qs=32,js=Math.pow(2,-24),Ws=Symbol("SKIP_GENERATION"),Js={strategy:0,maxDepth:40,maxLeafSize:10,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,indirect:!1,verbose:!0,range:null,[Ws]:!1};function arrayToBox(e,t,n){return n.min.x=t[e],n.min.y=t[e+1],n.min.z=t[e+2],n.max.x=t[e+3],n.max.y=t[e+4],n.max.z=t[e+5],n}function getLongestEdgeIndex(e){let t=-1,n=-1/0;for(let i=0;i<3;i++){const r=e[i+3]-e[i];r>n&&(n=r,t=i)}return t}function copyBounds(e,t){t.set(e)}function unionBounds(e,t,n){let i,r;for(let s=0;s<3;s++){const o=s+3;i=e[s],r=t[s],n[s]=i<r?i:r,i=e[o],r=t[o],n[o]=i>r?i:r}}function expandByPrimitiveBounds(e,t,n){for(let i=0;i<3;i++){const r=t[e+2*i],s=t[e+2*i+1],o=r-s,a=r+s;o<n[i]&&(n[i]=o),a>n[i+3]&&(n[i+3]=a)}}function computeSurfaceArea(e){const t=e[3]-e[0],n=e[4]-e[1],i=e[5]-e[2];return 2*(t*n+n*i+i*t)}function IS_LEAF(e,t){return 65535===t[e+15]}function OFFSET(e,t){return t[e+6]}function COUNT(e,t){return t[e+14]}function LEFT_NODE(e){return e+8}function RIGHT_NODE(e,t){return e+8*t[e+6]}function SPLIT_AXIS(e,t){return t[e+7]}function getBounds(e,t,n,i,r){let s=1/0,o=1/0,a=1/0,A=-1/0,l=-1/0,c=-1/0,p=1/0,h=1/0,u=1/0,d=-1/0,g=-1/0,f=-1/0;const m=e.offset||0;for(let i=6*(t-m),r=6*(t+n-m);i<r;i+=6){const t=e[i+0],n=e[i+1],r=t-n,m=t+n;r<s&&(s=r),m>A&&(A=m),t<p&&(p=t),t>d&&(d=t);const y=e[i+2],b=e[i+3],I=y-b,x=y+b;I<o&&(o=I),x>l&&(l=x),y<h&&(h=y),y>g&&(g=y);const C=e[i+4],B=e[i+5],E=C-B,w=C+B;E<a&&(a=E),w>c&&(c=w),C<u&&(u=C),C>f&&(f=C)}i[0]=s,i[1]=o,i[2]=a,i[3]=A,i[4]=l,i[5]=c,r[0]=p,r[1]=h,r[2]=u,r[3]=d,r[4]=g,r[5]=f}const Vs=32,binsSort=(e,t)=>e.candidate-t.candidate,Ks=new Array(Vs).fill().map((()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0}))),Zs=new Float32Array(6);class BVHNode{constructor(){this.boundingData=new Float32Array(6)}}let $s,eo,to,no;const io=Math.pow(2,32);function countNodes(e){return"count"in e?1:1+countNodes(e.left)+countNodes(e.right)}function populateBuffer(e,t,n){return $s=new Float32Array(n),eo=new Uint32Array(n),to=new Uint16Array(n),no=new Uint8Array(n),_populateBuffer(e,t)}function _populateBuffer(e,t){const n=e/4,i=e/2,r="count"in t,s=t.boundingData;for(let e=0;e<6;e++)$s[n+e]=s[e];if(r)return t.buffer?(no.set(new Uint8Array(t.buffer),e),e+t.buffer.byteLength):(eo[n+6]=t.offset,to[i+14]=t.count,to[i+15]=65535,e+qs);{const{left:i,right:r,splitAxis:s}=t;let o=_populateBuffer(e+qs,i);const a=o/qs-e/qs;if(a>io)throw new Error("MeshBVH: Cannot store relative child node offset greater than 32 bits.");return eo[n+6]=a,eo[n+7]=s,_populateBuffer(o,r)}}function buildTree(e,t,n,i,r){const{maxDepth:s,verbose:o,maxLeafSize:a,strategy:A,onProgress:l}=r,c=e.primitiveBuffer,p=e.primitiveBufferStride,h=new Float32Array(6);let u=!1;const d=new BVHNode;return getBounds(t,n,i,d.boundingData,h),function splitNode(e,n,i,r=null,l=0){!u&&l>=s&&(u=!0,o&&console.warn(`BVH: Max depth of ${s} reached when generating BVH. Consider increasing maxDepth.`));if(i<=a||l>=s)return triggerProgress(n+i),e.offset=n,e.count=i,e;const d=function getOptimalSplit(e,t,n,i,r,s){let o=-1,a=0;if(0===s)o=getLongestEdgeIndex(t),-1!==o&&(a=(t[o]+t[o+3])/2);else if(1===s)o=getLongestEdgeIndex(e),-1!==o&&(a=function getAverage(e,t,n,i){let r=0;const s=e.offset;for(let o=t,a=t+n;o<a;o++)r+=e[6*(o-s)+2*i];return r/n}(n,i,r,o));else if(2===s){const s=computeSurfaceArea(e);let A=Xs*r;const l=n.offset||0,c=6*(i-l),p=6*(i+r-l);for(let e=0;e<3;e++){const i=t[e],l=(t[e+3]-i)/Vs;if(r<8){const t=[...Ks];t.length=r;let i=0;for(let r=c;r<p;r+=6,i++){const s=t[i];s.candidate=n[r+2*e],s.count=0;const{bounds:o,leftCacheBounds:a,rightCacheBounds:A}=s;for(let e=0;e<3;e++)A[e]=1/0,A[e+3]=-1/0,a[e]=1/0,a[e+3]=-1/0,o[e]=1/0,o[e+3]=-1/0;expandByPrimitiveBounds(r,n,o)}t.sort(binsSort);let l=r;for(let e=0;e<l;e++){const n=t[e];for(;e+1<l&&t[e+1].candidate===n.candidate;)t.splice(e+1,1),l--}for(let i=c;i<p;i+=6){const r=n[i+2*e];for(let e=0;e<l;e++){const s=t[e];r>=s.candidate?expandByPrimitiveBounds(i,n,s.rightCacheBounds):(expandByPrimitiveBounds(i,n,s.leftCacheBounds),s.count++)}}for(let n=0;n<l;n++){const i=t[n],l=i.count,c=r-i.count,p=i.leftCacheBounds,h=i.rightCacheBounds;let u=0;0!==l&&(u=computeSurfaceArea(p)/s);let d=0;0!==c&&(d=computeSurfaceArea(h)/s);const g=1+Xs*(u*l+d*c);g<A&&(o=e,A=g,a=i.candidate)}}else{for(let e=0;e<Vs;e++){const t=Ks[e];t.count=0,t.candidate=i+l+e*l;const n=t.bounds;for(let e=0;e<3;e++)n[e]=1/0,n[e+3]=-1/0}for(let t=c;t<p;t+=6){let r=~~((n[t+2*e]-i)/l);r>=Vs&&(r=31);const s=Ks[r];s.count++,expandByPrimitiveBounds(t,n,s.bounds)}const t=Ks[31];copyBounds(t.bounds,t.rightCacheBounds);for(let e=30;e>=0;e--){const t=Ks[e],n=Ks[e+1];unionBounds(t.bounds,n.rightCacheBounds,t.rightCacheBounds)}let h=0;for(let t=0;t<31;t++){const n=Ks[t],i=n.count,l=n.bounds,c=Ks[t+1].rightCacheBounds;0!==i&&(0===h?copyBounds(l,Zs):unionBounds(l,Zs,Zs)),h+=i;let p=0,u=0;0!==h&&(p=computeSurfaceArea(Zs)/s);const d=r-h;0!==d&&(u=computeSurfaceArea(c)/s);const g=1+Xs*(p*h+u*d);g<A&&(o=e,A=g,a=n.candidate)}}}}else console.warn(`BVH: Invalid build strategy value ${s} used.`);return{axis:o,pos:a}}(e.boundingData,r,t,n,i,A);if(-1===d.axis)return triggerProgress(n+i),e.offset=n,e.count=i,e;const g=function partition(e,t,n,i,r,s){let o=i,a=i+r-1;const A=s.pos,l=2*s.axis,c=n.offset||0;for(;;){for(;o<=a&&n[6*(o-c)+l]<A;)o++;for(;o<=a&&n[6*(a-c)+l]>=A;)a--;if(!(o<a))return o;for(let n=0;n<t;n++){let i=e[o*t+n];e[o*t+n]=e[a*t+n],e[a*t+n]=i}for(let e=0;e<6;e++){const t=o-c,i=a-c,r=n[6*t+e];n[6*t+e]=n[6*i+e],n[6*i+e]=r}o++,a--}}(c,p,t,n,i,d);if(g===n||g===n+i)triggerProgress(n+i),e.offset=n,e.count=i;else{e.splitAxis=d.axis;const r=new BVHNode,s=n,o=g-n;e.left=r,getBounds(t,s,o,r.boundingData,h),splitNode(r,s,o,h,l+1);const a=new BVHNode,A=g,c=i-o;e.right=a,getBounds(t,A,c,a.boundingData,h),splitNode(a,A,c,h,l+1)}return e}(d,n,i,h),d;function triggerProgress(e){l&&l(e/i)}}function buildPackedTree(e,t){const n=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,i=e.getRootRanges(t.range),r=i[0],s=i[i.length-1],o={offset:r.offset,count:s.offset+s.count-r.offset},a=new Float32Array(6*o.count);a.offset=o.offset,e.computePrimitiveBounds(o.offset,o.count,a),e._roots=i.map((i=>{const r=buildTree(e,a,i.offset,i.count,t),s=countNodes(r),o=new n(qs*s);return populateBuffer(0,r,o),o}))}class PrimitivePool{constructor(e){this._getNewPrimitive=e,this._primitives=[]}getPrimitive(){const e=this._primitives;return 0===e.length?this._getNewPrimitive():e.pop()}releasePrimitive(e){this._primitives.push(e)}}class _BufferStack{constructor(){this.float32Array=null,this.uint16Array=null,this.uint32Array=null;const e=[];let t=null;this.setBuffer=n=>{t&&e.push(t),t=n,this.float32Array=new Float32Array(n),this.uint16Array=new Uint16Array(n),this.uint32Array=new Uint32Array(n)},this.clearBuffer=()=>{t=null,this.float32Array=null,this.uint16Array=null,this.uint32Array=null,0!==e.length&&this.setBuffer(e.pop())}}}const ro=new _BufferStack;let so,oo;const ao=[],Ao=new PrimitivePool((()=>new p));function shapecast(e,t,n,i,r,s){so=Ao.getPrimitive(),oo=Ao.getPrimitive(),ao.push(so,oo),ro.setBuffer(e._roots[t]);const o=shapecastTraverse(0,e.geometry,n,i,r,s);ro.clearBuffer(),Ao.releasePrimitive(so),Ao.releasePrimitive(oo),ao.pop(),ao.pop();const a=ao.length;return a>0&&(oo=ao[a-1],so=ao[a-2]),o}function shapecastTraverse(e,t,n,i,r=null,s=0,o=0){const{float32Array:a,uint16Array:A,uint32Array:l}=ro;let c=2*e;if(IS_LEAF(c,A)){const p=OFFSET(e,l),h=COUNT(c,A);return arrayToBox(e,a,so),i(p,h,!1,o,s+e/8,so)}{const u=LEFT_NODE(e),d=RIGHT_NODE(e,l);let g,f,m,y,b=u,I=d;if(r&&(m=so,y=oo,arrayToBox(b,a,m),arrayToBox(I,a,y),g=r(m),f=r(y),f<g)){b=d,I=u;const w=g;g=f,f=w,m=y}m||(m=so,arrayToBox(b,a,m));const x=n(m,IS_LEAF(2*b,A),g,o+1,s+b/8);let C;if(2===x){const v=getLeftOffset(b);C=i(v,getRightEndOffset(b)-v,!0,o+1,s+b/8,m)}else C=x&&shapecastTraverse(b,t,n,i,r,s,o+1);if(C)return!0;y=oo,arrayToBox(I,a,y);const B=n(y,IS_LEAF(2*I,A),f,o+1,s+I/8);let E;if(2===B){const P=getLeftOffset(I);E=i(P,getRightEndOffset(I)-P,!0,o+1,s+I/8,y)}else E=B&&shapecastTraverse(I,t,n,i,r,s,o+1);return!!E;function getLeftOffset(e){const{uint16Array:t,uint32Array:n}=ro;let i=2*e;for(;!IS_LEAF(i,t);)i=2*(e=LEFT_NODE(e));return OFFSET(e,n)}function getRightEndOffset(e){const{uint16Array:t,uint32Array:n}=ro;let i=2*e;for(;!IS_LEAF(i,t);)i=2*(e=RIGHT_NODE(e,n));return OFFSET(e,n)+COUNT(i,t)}}}function getVertexCount$1(e){return e.index?e.index.count:e.attributes.position.count}function getTriCount$1(e){return getVertexCount$1(e)/3}function ensureIndex$1(e,t){if(!e.index){const n=e.attributes.position.count,i=function getIndexArray$1(e,t=ArrayBuffer){return e>65535?new Uint32Array(new t(4*e)):new Uint16Array(new t(2*e))}(n,t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer);e.setIndex(new B(i,1));for(let e=0;e<n;e++)i[e]=e}}function getRootPrimitiveRanges(e,t,n){const i=function getFullPrimitiveRange(e,t,n){const i=getVertexCount$1(e)/n,r=t||e.drawRange,s=r.start/n,o=(r.start+r.count)/n,a=Math.max(0,s),A=Math.min(i,o)-a;return{offset:Math.floor(a),count:Math.floor(A)}}(e,t,n),r=function getPrimitiveGroupRanges(e,t){return e.groups.map((e=>({offset:e.start/t,count:e.count/t})))}(e,n);if(!r.length)return[i];const s=[],o=i.offset,a=i.offset+i.count,A=getVertexCount$1(e)/n,l=[];for(const e of r){const{offset:t,count:n}=e,i=t,r=t+(isFinite(n)?n:A-t);i<a&&r>o&&(l.push({pos:Math.max(o,i),isStart:!0}),l.push({pos:Math.min(a,r),isStart:!1}))}l.sort(((e,t)=>e.pos!==t.pos?e.pos-t.pos:"end"===e.type?-1:1));let c=0,p=null;for(const e of l){const t=e.pos;0!==c&&t!==p&&s.push({offset:p,count:t-p}),c+=e.isStart?1:-1,p=t}return s}const lo=new p;class BVH{constructor(){this._roots=null,this.primitiveBuffer=null,this.primitiveBufferStride=null}init(e){buildPackedTree(this,e={...Js,...e})}getRootRanges(e){return getRootPrimitiveRanges(this.geometry,e,this.primitiveStride)}raycastObject3D(){throw new Error("BVH: raycastObject3D() not implemented")}shiftPrimitiveOffsets(e){const t=this._indirectBuffer;if(t)for(let n=0,i=t.length;n<i;n++)t[n]+=e;else{const t=this._roots;for(let n=0;n<t.length;n++){const i=t[n],r=new Uint32Array(i),s=new Uint16Array(i),o=i.byteLength/qs;for(let t=0;t<o;t++){const n=8*t;IS_LEAF(2*n,s)&&(r[n+6]+=e)}}}}traverse(e,t=0){const n=this._roots[t],i=new Uint32Array(n),r=new Uint16Array(n);!function _traverse(t,s=0){const o=2*t,a=IS_LEAF(o,r);if(a){const A=i[t+6],l=r[o+14];e(s,a,new Float32Array(n,4*t,6),A,l)}else{const r=LEFT_NODE(t),o=RIGHT_NODE(t,i),A=SPLIT_AXIS(t,i);e(s,a,new Float32Array(n,4*t,6),A)||(_traverse(r,s+1),_traverse(o,s+1))}}(0)}getBoundingBox(e){e.makeEmpty();return this._roots.forEach((t=>{arrayToBox(0,new Float32Array(t),lo),e.union(lo)})),e}shapecast(e){let{boundsTraverseOrder:t,intersectsBounds:n,intersectsRange:i,intersectsPrimitive:r,scratchPrimitive:s,iterate:o}=e;if(i&&r){const e=i;i=(t,n,i,a,A)=>!!e(t,n,i,a,A)||o(t,n,this,r,i,a,s)}else i||(i=r?(e,t,n,i)=>o(e,t,this,r,n,i,s):(e,t,n)=>n);let a=!1,A=0;const l=this._roots;for(let e=0,r=l.length;e<r;e++){const r=l[e];if(a=shapecast(this,e,n,i,t,A),a)break;A+=r.byteLength/qs}return a}}class SeparatingAxisBounds{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(e,t){let n=1/0,i=-1/0;for(let r=0,s=e.length;r<s;r++){const s=e[r][t];n=s<n?s:n,i=s>i?s:i}this.min=n,this.max=i}setFromPoints(e,t){let n=1/0,i=-1/0;for(let r=0,s=t.length;r<s;r++){const s=t[r],o=e.dot(s);n=o<n?o:n,i=o>i?o:i}this.min=n,this.max=i}isSeparated(e){return this.min>e.max||e.min>this.max}}SeparatingAxisBounds.prototype.setFromBox=function(){const e=new u;return function setFromBox(t,n){const i=n.min,r=n.max;let s=1/0,o=-1/0;for(let n=0;n<=1;n++)for(let a=0;a<=1;a++)for(let A=0;A<=1;A++){e.x=i.x*n+r.x*(1-n),e.y=i.y*a+r.y*(1-a),e.z=i.z*A+r.z*(1-A);const l=t.dot(e);s=Math.min(l,s),o=Math.max(l,o)}this.min=s,this.max=o}}();const co=function(){const e=new u,t=new u,n=new u;return function closestPointLineToLine(i,r,s){const o=i.start,a=e,A=r.start,l=t;n.subVectors(o,A),e.subVectors(i.end,i.start),t.subVectors(r.end,r.start);const c=n.dot(l),p=l.dot(a),h=l.dot(l),u=n.dot(a),d=a.dot(a)*h-p*p;let g,f;g=0!==d?(c*p-u*h)/d:0,f=(c+g*p)/h,s.x=g,s.y=f}}(),po=function(){const e=new r,t=new u,n=new u;return function closestPointsSegmentToSegment(i,r,s,o){co(i,r,e);let a=e.x,A=e.y;if(a>=0&&a<=1&&A>=0&&A<=1)return i.at(a,s),void r.at(A,o);if(a>=0&&a<=1)return A<0?r.at(0,o):r.at(1,o),void i.closestPointToPoint(o,!0,s);if(A>=0&&A<=1)return a<0?i.at(0,s):i.at(1,s),void r.closestPointToPoint(s,!0,o);{let e,l;e=a<0?i.start:i.end,l=A<0?r.start:r.end;const c=t,p=n;return i.closestPointToPoint(l,!0,t),r.closestPointToPoint(e,!0,n),c.distanceToSquared(l)<=p.distanceToSquared(e)?(s.copy(c),void o.copy(l)):(s.copy(e),void o.copy(p))}}}(),ho=function(){const e=new u,t=new u,n=new lt,i=new f;return function sphereIntersectTriangle(r,s){const{radius:o,center:a}=r,{a:A,b:l,c:c}=s;i.start=A,i.end=l;if(i.closestPointToPoint(a,!0,e).distanceTo(a)<=o)return!0;i.start=A,i.end=c;if(i.closestPointToPoint(a,!0,e).distanceTo(a)<=o)return!0;i.start=l,i.end=c;if(i.closestPointToPoint(a,!0,e).distanceTo(a)<=o)return!0;const p=s.getPlane(n);if(Math.abs(p.distanceToPoint(a))<=o){const e=p.projectPoint(a,t);if(s.containsPoint(e))return!0}return!1}}(),uo=["x","y","z"],go=1e-15;function isNearZero(e){return Math.abs(e)<go}class ExtendedTriangle extends ct{constructor(...e){super(...e),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map((()=>new u)),this.satBounds=new Array(4).fill().map((()=>new SeparatingAxisBounds)),this.points=[this.a,this.b,this.c],this.plane=new lt,this.isDegenerateIntoSegment=!1,this.isDegenerateIntoPoint=!1,this.degenerateSegment=new f,this.needsUpdate=!0}intersectsSphere(e){return ho(e,this)}update(){const e=this.a,t=this.b,n=this.c,i=this.points,r=this.satAxes,s=this.satBounds,o=r[0],a=s[0];this.getNormal(o),a.setFromPoints(o,i);const A=r[1],l=s[1];A.subVectors(e,t),l.setFromPoints(A,i);const c=r[2],p=s[2];c.subVectors(t,n),p.setFromPoints(c,i);const h=r[3],u=s[3];h.subVectors(n,e),u.setFromPoints(h,i);const d=A.length(),g=c.length(),f=h.length();this.isDegenerateIntoPoint=!1,this.isDegenerateIntoSegment=!1,d<go?g<go||f<go?this.isDegenerateIntoPoint=!0:(this.isDegenerateIntoSegment=!0,this.degenerateSegment.start.copy(e),this.degenerateSegment.end.copy(n)):g<go?f<go?this.isDegenerateIntoPoint=!0:(this.isDegenerateIntoSegment=!0,this.degenerateSegment.start.copy(t),this.degenerateSegment.end.copy(e)):f<go&&(this.isDegenerateIntoSegment=!0,this.degenerateSegment.start.copy(n),this.degenerateSegment.end.copy(t)),this.plane.setFromNormalAndCoplanarPoint(o,e),this.needsUpdate=!1}}ExtendedTriangle.prototype.closestPointToSegment=function(){const e=new u,t=new u,n=new f;return function distanceToSegment(i,r=null,s=null){const{start:o,end:a}=i,A=this.points;let l,c=1/0;for(let o=0;o<3;o++){const a=(o+1)%3;n.start.copy(A[o]),n.end.copy(A[a]),po(n,i,e,t),l=e.distanceToSquared(t),l<c&&(c=l,r&&r.copy(e),s&&s.copy(t))}return this.closestPointToPoint(o,e),l=o.distanceToSquared(e),l<c&&(c=l,r&&r.copy(e),s&&s.copy(o)),this.closestPointToPoint(a,e),l=a.distanceToSquared(e),l<c&&(c=l,r&&r.copy(e),s&&s.copy(a)),Math.sqrt(c)}}(),ExtendedTriangle.prototype.intersectsTriangle=function(){const e=new ExtendedTriangle,t=new SeparatingAxisBounds,n=new SeparatingAxisBounds,i=new u,s=new u,o=new u,a=new u,A=new f,l=new f,c=new u,p=new r,h=new r;function coplanarIntersectsTriangle(e,r,s,o){const A=i;e.isDegenerateIntoPoint||e.isDegenerateIntoSegment?A.copy(r.plane.normal):A.copy(e.plane.normal);const l=e.satBounds,c=e.satAxes;for(let i=1;i<4;i++){const s=l[i],o=c[i];if(t.setFromPoints(o,r.points),s.isSeparated(t))return!1;if(a.copy(A).cross(o),t.setFromPoints(a,e.points),n.setFromPoints(a,r.points),t.isSeparated(n))return!1}const p=r.satBounds,h=r.satAxes;for(let i=1;i<4;i++){const s=p[i],o=h[i];if(t.setFromPoints(o,e.points),s.isSeparated(t))return!1;if(a.crossVectors(A,o),t.setFromPoints(a,e.points),n.setFromPoints(a,r.points),t.isSeparated(n))return!1}return s&&(o||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),s.start.set(0,0,0),s.end.set(0,0,0)),!0}function findSingleBounds(e,t,n,i,r,s,o,a,A,l,c){let p=o/(o-a);l.x=i+(r-i)*p,c.start.subVectors(t,e).multiplyScalar(p).add(e),p=o/(o-A),l.y=i+(s-i)*p,c.end.subVectors(n,e).multiplyScalar(p).add(e)}function findIntersectionLineBounds(e,t,n,i,r,s,o,a,A,l,c){if(r>0)findSingleBounds(e.c,e.a,e.b,i,t,n,A,o,a,l,c);else if(s>0)findSingleBounds(e.b,e.a,e.c,n,t,i,a,o,A,l,c);else if(a*A>0||0!=o)findSingleBounds(e.a,e.b,e.c,t,n,i,o,a,A,l,c);else if(0!=a)findSingleBounds(e.b,e.a,e.c,n,t,i,a,o,A,l,c);else{if(0==A)return!0;findSingleBounds(e.c,e.a,e.b,i,t,n,A,o,a,l,c)}return!1}function intersectTriangleSegment(e,t,n,r){const s=t.degenerateSegment,o=e.plane.distanceToPoint(s.start),a=e.plane.distanceToPoint(s.end);return isNearZero(o)?isNearZero(a)?coplanarIntersectsTriangle(e,t,n,r):(n&&(n.start.copy(s.start),n.end.copy(s.start)),e.containsPoint(s.start)):isNearZero(a)?(n&&(n.start.copy(s.end),n.end.copy(s.end)),e.containsPoint(s.end)):null!=e.plane.intersectLine(s,i)&&(n&&(n.start.copy(i),n.end.copy(i)),e.containsPoint(i))}function intersectTrianglePoint(e,t,n){const i=t.a;return!(!isNearZero(e.plane.distanceToPoint(i))||!e.containsPoint(i))&&(n&&(n.start.copy(i),n.end.copy(i)),!0)}function intersectSegmentPoint(e,t,n){const r=e.degenerateSegment,s=t.a;return r.closestPointToPoint(s,!0,i),s.distanceToSquared(i)<1e-30&&(n&&(n.start.copy(s),n.end.copy(s)),!0)}return function intersectsTriangle(t,n=null,r=!1){this.needsUpdate&&this.update(),t.isExtendedTriangle?t.needsUpdate&&t.update():(e.copy(t),e.update(),t=e);const a=function handleDegenerateCases(e,t,n,r){if(e.isDegenerateIntoSegment){if(t.isDegenerateIntoSegment){const r=e.degenerateSegment,a=t.degenerateSegment,A=s,l=o;r.delta(A),a.delta(l);const c=i.subVectors(a.start,r.start),p=A.x*l.y-A.y*l.x;if(isNearZero(p))return!1;const h=(c.x*l.y-c.y*l.x)/p,u=-(A.x*c.y-A.y*c.x)/p;return!(h<0||h>1||u<0||u>1)&&(!!isNearZero(r.start.z+A.z*h-(a.start.z+l.z*u))&&(n&&(n.start.copy(r.start).addScaledVector(A,h),n.end.copy(r.start).addScaledVector(A,h)),!0))}return t.isDegenerateIntoPoint?intersectSegmentPoint(e,t,n):intersectTriangleSegment(t,e,n,r)}return e.isDegenerateIntoPoint?t.isDegenerateIntoPoint?t.a.distanceToSquared(e.a)<1e-30&&(n&&(n.start.copy(e.a),n.end.copy(e.a)),!0):t.isDegenerateIntoSegment?intersectSegmentPoint(t,e,n):intersectTrianglePoint(t,e,n):t.isDegenerateIntoPoint?intersectTrianglePoint(e,t,n):t.isDegenerateIntoSegment?intersectTriangleSegment(e,t,n,r):void 0}(this,t,n,r);if(void 0!==a)return a;const u=this.plane,d=t.plane;let g=d.distanceToPoint(this.a),f=d.distanceToPoint(this.b),m=d.distanceToPoint(this.c);isNearZero(g)&&(g=0),isNearZero(f)&&(f=0),isNearZero(m)&&(m=0);const y=g*f,b=g*m;if(y>0&&b>0)return!1;let I=u.distanceToPoint(t.a),x=u.distanceToPoint(t.b),C=u.distanceToPoint(t.c);isNearZero(I)&&(I=0),isNearZero(x)&&(x=0),isNearZero(C)&&(C=0);const B=I*x,E=I*C;if(B>0&&E>0)return!1;s.copy(u.normal),o.copy(d.normal);const w=s.cross(o);let v=0,P=Math.abs(w.x);const T=Math.abs(w.y);T>P&&(P=T,v=1);Math.abs(w.z)>P&&(v=2);const S=uo[v],M=this.a[S],D=this.b[S],L=this.c[S],_=t.a[S],F=t.b[S],k=t.c[S];if(findIntersectionLineBounds(this,M,D,L,y,b,g,f,m,p,A))return coplanarIntersectsTriangle(this,t,n,r);if(findIntersectionLineBounds(t,_,F,k,B,E,I,x,C,h,l))return coplanarIntersectsTriangle(this,t,n,r);if(p.y<p.x){const e=p.y;p.y=p.x,p.x=e,c.copy(A.start),A.start.copy(A.end),A.end.copy(c)}if(h.y<h.x){const e=h.y;h.y=h.x,h.x=e,c.copy(l.start),l.start.copy(l.end),l.end.copy(c)}return!(p.y<h.x||h.y<p.x)&&(n&&(h.x>p.x?n.start.copy(l.start):n.start.copy(A.start),h.y<p.y?n.end.copy(l.end):n.end.copy(A.end)),!0)}}(),ExtendedTriangle.prototype.distanceToPoint=function(){const e=new u;return function distanceToPoint(t){return this.closestPointToPoint(t,e),t.distanceTo(e)}}(),ExtendedTriangle.prototype.distanceToTriangle=function(){const e=new u,t=new u,n=["a","b","c"],i=new f,r=new f;return function distanceToTriangle(s,o=null,a=null){const A=o||a?i:null;if(this.intersectsTriangle(s,A))return(o||a)&&(o&&A.getCenter(o),a&&A.getCenter(a)),0;let l=1/0;for(let t=0;t<3;t++){let i;const r=n[t],A=s[r];this.closestPointToPoint(A,e),i=A.distanceToSquared(e),i<l&&(l=i,o&&o.copy(e),a&&a.copy(A));const c=this[r];s.closestPointToPoint(c,e),i=c.distanceToSquared(e),i<l&&(l=i,o&&o.copy(c),a&&a.copy(e))}for(let A=0;A<3;A++){const c=n[A],p=n[(A+1)%3];i.set(this[c],this[p]);for(let A=0;A<3;A++){const c=n[A],p=n[(A+1)%3];r.set(s[c],s[p]),po(i,r,e,t);const h=e.distanceToSquared(t);h<l&&(l=h,o&&o.copy(e),a&&a.copy(t))}}return Math.sqrt(l)}}();class OrientedBox{constructor(e,t,n){this.isOrientedBox=!0,this.min=new u,this.max=new u,this.matrix=new m,this.invMatrix=new m,this.points=new Array(8).fill().map((()=>new u)),this.satAxes=new Array(3).fill().map((()=>new u)),this.satBounds=new Array(3).fill().map((()=>new SeparatingAxisBounds)),this.alignedSatBounds=new Array(3).fill().map((()=>new SeparatingAxisBounds)),this.needsUpdate=!1,e&&this.min.copy(e),t&&this.max.copy(t),n&&this.matrix.copy(n)}set(e,t,n){this.min.copy(e),this.max.copy(t),this.matrix.copy(n),this.needsUpdate=!0}copy(e){this.min.copy(e.min),this.max.copy(e.max),this.matrix.copy(e.matrix),this.needsUpdate=!0}}OrientedBox.prototype.update=function update(){const e=this.matrix,t=this.min,n=this.max,i=this.points;for(let r=0;r<=1;r++)for(let s=0;s<=1;s++)for(let o=0;o<=1;o++){const a=i[1*r|2*s|4*o];a.x=r?n.x:t.x,a.y=s?n.y:t.y,a.z=o?n.z:t.z,a.applyMatrix4(e)}const r=this.satBounds,s=this.satAxes,o=i[0];for(let e=0;e<3;e++){const t=s[e],n=r[e],a=i[1<<e];t.subVectors(o,a),n.setFromPoints(t,i)}const a=this.alignedSatBounds;a[0].setFromPointsField(i,"x"),a[1].setFromPointsField(i,"y"),a[2].setFromPointsField(i,"z"),this.invMatrix.copy(this.matrix).invert(),this.needsUpdate=!1},OrientedBox.prototype.intersectsBox=function(){const e=new SeparatingAxisBounds;return function intersectsBox(t){this.needsUpdate&&this.update();const n=t.min,i=t.max,r=this.satBounds,s=this.satAxes,o=this.alignedSatBounds;if(e.min=n.x,e.max=i.x,o[0].isSeparated(e))return!1;if(e.min=n.y,e.max=i.y,o[1].isSeparated(e))return!1;if(e.min=n.z,e.max=i.z,o[2].isSeparated(e))return!1;for(let n=0;n<3;n++){const i=s[n],o=r[n];if(e.setFromBox(i,t),o.isSeparated(e))return!1}return!0}}(),OrientedBox.prototype.intersectsTriangle=function(){const e=new ExtendedTriangle,t=new Array(3),n=new SeparatingAxisBounds,i=new SeparatingAxisBounds,r=new u;return function intersectsTriangle(s){this.needsUpdate&&this.update(),s.isExtendedTriangle?s.needsUpdate&&s.update():(e.copy(s),e.update(),s=e);const o=this.satBounds,a=this.satAxes;t[0]=s.a,t[1]=s.b,t[2]=s.c;for(let e=0;e<3;e++){const i=o[e],r=a[e];if(n.setFromPoints(r,t),i.isSeparated(n))return!1}const A=s.satBounds,l=s.satAxes,c=this.points;for(let e=0;e<3;e++){const t=A[e],i=l[e];if(n.setFromPoints(i,c),t.isSeparated(n))return!1}for(let e=0;e<3;e++){const s=a[e];for(let e=0;e<4;e++){const o=l[e];if(r.crossVectors(s,o),n.setFromPoints(r,t),i.setFromPoints(r,c),n.isSeparated(i))return!1}}return!0}}(),OrientedBox.prototype.closestPointToPoint=function closestPointToPoint(e,t){return this.needsUpdate&&this.update(),t.copy(e).applyMatrix4(this.invMatrix).clamp(this.min,this.max).applyMatrix4(this.matrix),t},OrientedBox.prototype.distanceToPoint=function(){const e=new u;return function distanceToPoint(t){return this.closestPointToPoint(t,e),t.distanceTo(e)}}(),OrientedBox.prototype.distanceToBox=function(){const e=["x","y","z"],t=new Array(12).fill().map((()=>new f)),n=new Array(12).fill().map((()=>new f)),i=new u,r=new u;return function distanceToBox(s,o=0,a=null,A=null){if(this.needsUpdate&&this.update(),this.intersectsBox(s))return(a||A)&&(s.getCenter(r),this.closestPointToPoint(r,i),s.closestPointToPoint(i,r),a&&a.copy(i),A&&A.copy(r)),0;const l=o*o,c=s.min,p=s.max,h=this.points;let u=1/0;for(let e=0;e<8;e++){const t=h[e];r.copy(t).clamp(c,p);const n=t.distanceToSquared(r);if(n<u&&(u=n,a&&a.copy(t),A&&A.copy(r),n<l))return Math.sqrt(n)}let d=0;for(let i=0;i<3;i++)for(let r=0;r<=1;r++)for(let s=0;s<=1;s++){const o=(i+1)%3,a=(i+2)%3,A=1<<i|r<<o|s<<a,l=h[r<<o|s<<a],u=h[A];t[d].set(l,u);const g=e[i],f=e[o],m=e[a],y=n[d],b=y.start,I=y.end;b[g]=c[g],b[f]=r?c[f]:p[f],b[m]=s?c[m]:p[f],I[g]=p[g],I[f]=r?c[f]:p[f],I[m]=s?c[m]:p[f],d++}for(let e=0;e<=1;e++)for(let t=0;t<=1;t++)for(let n=0;n<=1;n++){r.x=e?p.x:c.x,r.y=t?p.y:c.y,r.z=n?p.z:c.z,this.closestPointToPoint(r,i);const s=r.distanceToSquared(i);if(s<u&&(u=s,a&&a.copy(i),A&&A.copy(r),s<l))return Math.sqrt(s)}for(let e=0;e<12;e++){const s=t[e];for(let e=0;e<12;e++){const t=n[e];po(s,t,i,r);const o=i.distanceToSquared(r);if(o<u&&(u=o,a&&a.copy(i),A&&A.copy(r),o<l))return Math.sqrt(o)}}return Math.sqrt(u)}}();class ExtendedTrianglePoolBase extends PrimitivePool{constructor(){super((()=>new ExtendedTriangle))}}const fo=new ExtendedTrianglePoolBase,mo=new u,yo=new u;const bo=parseInt(ht)>=169,Io=parseInt(ht)<=161,xo=new u,Co=new u,Bo=new u,Eo=new r,wo=new r,vo=new r,Qo=new u,Po=new u,To=new u,So=new u;function checkBufferGeometryIntersection(e,t,n,i,s,o,a,A,l,c,p){xo.fromBufferAttribute(t,o),Co.fromBufferAttribute(t,a),Bo.fromBufferAttribute(t,A);const h=function checkIntersection(e,t,n,i,r,s,o,a){let A;if(A=s===pt?e.intersectTriangle(i,n,t,!0,r):e.intersectTriangle(t,n,i,s!==te,r),null===A)return null;const l=e.origin.distanceTo(r);return l<o||l>a?null:{distance:l,point:r.clone()}}(e,xo,Co,Bo,So,l,c,p);if(h){if(i){Eo.fromBufferAttribute(i,o),wo.fromBufferAttribute(i,a),vo.fromBufferAttribute(i,A),h.uv=new r;const e=ct.getInterpolation(So,xo,Co,Bo,Eo,wo,vo,h.uv);bo||(h.uv=e)}if(s){Eo.fromBufferAttribute(s,o),wo.fromBufferAttribute(s,a),vo.fromBufferAttribute(s,A),h.uv1=new r;const e=ct.getInterpolation(So,xo,Co,Bo,Eo,wo,vo,h.uv1);bo||(h.uv1=e),Io&&(h.uv2=h.uv1)}if(n){Qo.fromBufferAttribute(n,o),Po.fromBufferAttribute(n,a),To.fromBufferAttribute(n,A),h.normal=new u;const t=ct.getInterpolation(So,xo,Co,Bo,Qo,Po,To,h.normal);h.normal.dot(e.direction)>0&&h.normal.multiplyScalar(-1),bo||(h.normal=t)}const t={a:o,b:a,c:A,normal:new u,materialIndex:0};if(ct.getNormal(xo,Co,Bo,t.normal),h.face=t,h.faceIndex=o,bo){const e=new u;ct.getBarycoord(So,xo,Co,Bo,e),h.barycoord=e}}return h}function getSide(e){return e&&e.isMaterial?e.side:e}function intersectTri(e,t,n,i,r,s,o){const a=3*i;let A=a+0,l=a+1,c=a+2;const{index:p,groups:h}=e;e.index&&(A=p.getX(A),l=p.getX(l),c=p.getX(c));const{position:u,normal:d,uv:g,uv1:f}=e.attributes;if(Array.isArray(t)){const e=3*i;for(let a=0,p=h.length;a<p;a++){const{start:p,count:m,materialIndex:y}=h[a];if(e>=p&&e<p+m){const e=checkBufferGeometryIntersection(n,u,d,g,f,A,l,c,getSide(t[y]),s,o);if(e){if(e.faceIndex=i,e.face.materialIndex=y,!r)return e;r.push(e)}}}}else{const e=checkBufferGeometryIntersection(n,u,d,g,f,A,l,c,getSide(t),s,o);if(e){if(e.faceIndex=i,e.face.materialIndex=0,!r)return e;r.push(e)}}return null}function setTriangle(e,t,n,i){const r=e.a,s=e.b,o=e.c;let a=t,A=t+1,l=t+2;n&&(a=n.getX(a),A=n.getX(A),l=n.getX(l)),r.x=i.getX(a),r.y=i.getY(a),r.z=i.getZ(a),s.x=i.getX(A),s.y=i.getY(A),s.z=i.getZ(A),o.x=i.getX(l),o.y=i.getY(l),o.z=i.getZ(l)}function iterateOverTriangles(e,t,n,i,r,s,o){const{geometry:a}=n,{index:A}=a,l=a.attributes.position;for(let n=e,a=t+e;n<a;n++){let e;if(e=n,setTriangle(o,3*e,A,l),o.needsUpdate=!0,i(o,e,r,s))return!0}return!1}function refit(e,t=null){t&&Array.isArray(t)&&(t=new Set(t));const n=e.geometry,i=n.index?n.index.array:null,r=n.attributes.position;let s,o,a,A,l=0;const c=e._roots;for(let e=0,t=c.length;e<t;e++)s=c[e],o=new Uint32Array(s),a=new Uint16Array(s),A=new Float32Array(s),_traverse(0,l),l+=s.byteLength;function _traverse(e,n,s=!1){const l=2*e;if(IS_LEAF(l,a)){const t=o[e+6];let n=1/0,s=1/0,c=1/0,p=-1/0,h=-1/0,u=-1/0;for(let e=3*t,o=3*(t+a[l+14]);e<o;e++){let t=i[e];const o=r.getX(t),a=r.getY(t),A=r.getZ(t);o<n&&(n=o),o>p&&(p=o),a<s&&(s=a),a>h&&(h=a),A<c&&(c=A),A>u&&(u=A)}return(A[e+0]!==n||A[e+1]!==s||A[e+2]!==c||A[e+3]!==p||A[e+4]!==h||A[e+5]!==u)&&(A[e+0]=n,A[e+1]=s,A[e+2]=c,A[e+3]=p,A[e+4]=h,A[e+5]=u,!0)}{const i=LEFT_NODE(e),r=RIGHT_NODE(e,o);let a=s,l=!1,c=!1;if(t){if(!a){const e=i/8+n/qs,s=r/8+n/qs;l=t.has(e),c=t.has(s),a=!l&&!c}}else l=!0,c=!0;const p=a||c;let h=!1;(a||l)&&(h=_traverse(i,n,a));let u=!1;p&&(u=_traverse(r,n,a));const d=h||u;if(d)for(let t=0;t<3;t++){const n=i+t,s=r+t,o=A[n],a=A[n+3],l=A[s],c=A[s+3];A[e+t]=o<l?o:l,A[e+t+3]=a>c?a:c}return d}}}function intersectRay(e,t,n,i,r){let s,o,a,A,l,c;const p=1/n.direction.x,h=1/n.direction.y,u=1/n.direction.z,d=n.origin.x,g=n.origin.y,f=n.origin.z;let m=t[e],y=t[e+3],b=t[e+1],I=t[e+3+1],x=t[e+2],C=t[e+3+2];return p>=0?(s=(m-d)*p,o=(y-d)*p):(s=(y-d)*p,o=(m-d)*p),h>=0?(a=(b-g)*h,A=(I-g)*h):(a=(I-g)*h,A=(b-g)*h),!(s>A||a>o)&&((a>s||isNaN(s))&&(s=a),(A<o||isNaN(o))&&(o=A),u>=0?(l=(x-f)*u,c=(C-f)*u):(l=(C-f)*u,c=(x-f)*u),!(s>c||l>o)&&((l>s||s!=s)&&(s=l),(c<o||o!=o)&&(o=c),s<=r&&o>=i))}function iterateOverTriangles_indirect(e,t,n,i,r,s,o){const{geometry:a}=n,{index:A}=a,l=a.attributes.position;for(let a=e,c=t+e;a<c;a++){let e;if(e=n.resolveTriangleIndex(a),setTriangle(o,3*e,A,l),o.needsUpdate=!0,i(o,e,r,s))return!0}return!1}function raycast(e,t,n,i,r,s,o){ro.setBuffer(e._roots[t]),_raycast$1(0,e,n,i,r,s,o),ro.clearBuffer()}function _raycast$1(e,t,n,i,r,s,o){const{float32Array:a,uint16Array:A,uint32Array:l}=ro,c=2*e;if(IS_LEAF(c,A)){!function intersectTris(e,t,n,i,r,s,o,a){const{geometry:A,_indirectBuffer:l}=e;for(let e=i,l=i+r;e<l;e++)intersectTri(A,t,n,e,s,o,a)}(t,n,i,OFFSET(e,l),COUNT(c,A),r,s,o)}else{const A=LEFT_NODE(e);intersectRay(A,a,i,s,o)&&_raycast$1(A,t,n,i,r,s,o);const c=RIGHT_NODE(e,l);intersectRay(c,a,i,s,o)&&_raycast$1(c,t,n,i,r,s,o)}}const Mo=["x","y","z"];function raycastFirst(e,t,n,i,r,s){ro.setBuffer(e._roots[t]);const o=_raycastFirst$1(0,e,n,i,r,s);return ro.clearBuffer(),o}function _raycastFirst$1(e,t,n,i,r,s){const{float32Array:o,uint16Array:a,uint32Array:A}=ro;let l=2*e;if(IS_LEAF(l,a)){return function intersectClosestTri(e,t,n,i,r,s,o){const{geometry:a,_indirectBuffer:A}=e;let l=1/0,c=null;for(let e=i,A=i+r;e<A;e++){let i;i=intersectTri(a,t,n,e,null,s,o),i&&i.distance<l&&(c=i,l=i.distance)}return c}(t,n,i,OFFSET(e,A),COUNT(l,a),r,s)}{const a=SPLIT_AXIS(e,A),l=Mo[a],c=i.direction[l]>=0;let p,h;c?(p=LEFT_NODE(e),h=RIGHT_NODE(e,A)):(p=RIGHT_NODE(e,A),h=LEFT_NODE(e));const u=intersectRay(p,o,i,r,s)?_raycastFirst$1(p,t,n,i,r,s):null;if(u){const e=u.point[l];if(c?e<=o[h+a]:e>=o[h+a+3])return u}const d=intersectRay(h,o,i,r,s)?_raycastFirst$1(h,t,n,i,r,s):null;return u&&d?u.distance<=d.distance?u:d:u||d||null}}const Do=new p,Lo=new ExtendedTriangle,_o=new ExtendedTriangle,Fo=new m,ko=new OrientedBox,Ro=new OrientedBox;function intersectsGeometry(e,t,n,i){ro.setBuffer(e._roots[t]);const r=_intersectsGeometry$1(0,e,n,i);return ro.clearBuffer(),r}function _intersectsGeometry$1(e,t,n,i,r=null){const{float32Array:s,uint16Array:o,uint32Array:a}=ro;let A=2*e;null===r&&(n.boundingBox||n.computeBoundingBox(),ko.set(n.boundingBox.min,n.boundingBox.max,i),r=ko);if(!IS_LEAF(A,o)){const o=LEFT_NODE(e),A=RIGHT_NODE(e,a);arrayToBox(o,s,Do);if(r.intersectsBox(Do)&&_intersectsGeometry$1(o,t,n,i,r))return!0;arrayToBox(A,s,Do);return!!(r.intersectsBox(Do)&&_intersectsGeometry$1(A,t,n,i,r))}{const r=t.geometry,l=r.index,c=r.attributes.position,p=n.index,h=n.attributes.position,u=OFFSET(e,a),d=COUNT(A,o);if(Fo.copy(i).invert(),n.boundsTree){arrayToBox(e,s,Ro),Ro.matrix.copy(Fo),Ro.needsUpdate=!0;return n.boundsTree.shapecast({intersectsBounds:e=>Ro.intersectsBox(e),intersectsTriangle:e=>{e.a.applyMatrix4(i),e.b.applyMatrix4(i),e.c.applyMatrix4(i),e.needsUpdate=!0;for(let t=3*u,n=3*(d+u);t<n;t+=3)if(setTriangle(_o,t,l,c),_o.needsUpdate=!0,e.intersectsTriangle(_o))return!0;return!1}})}{const e=getTriCount$1(n);for(let t=3*u,n=3*(d+u);t<n;t+=3){setTriangle(Lo,t,l,c),Lo.a.applyMatrix4(Fo),Lo.b.applyMatrix4(Fo),Lo.c.applyMatrix4(Fo),Lo.needsUpdate=!0;for(let t=0,n=3*e;t<n;t+=3)if(setTriangle(_o,t,p,h),_o.needsUpdate=!0,Lo.intersectsTriangle(_o))return!0}}}}const No=new m,Oo=new OrientedBox,Go=new OrientedBox,Uo=new u,Yo=new u,zo=new u,Ho=new u;function closestPointToGeometry(e,t,n,i={},r={},s=0,o=1/0){t.boundingBox||t.computeBoundingBox(),Oo.set(t.boundingBox.min,t.boundingBox.max,n),Oo.needsUpdate=!0;const a=e.geometry,A=a.attributes.position,l=a.index,c=t.attributes.position,p=t.index,h=fo.getPrimitive(),u=fo.getPrimitive();let d=Uo,g=Yo,f=null,m=null;r&&(f=zo,m=Ho);let y=1/0,b=null,I=null;return No.copy(n).invert(),Go.matrix.copy(No),e.shapecast({boundsTraverseOrder:e=>Oo.distanceToBox(e),intersectsBounds:(e,t,n)=>n<y&&n<o&&(t&&(Go.min.copy(e.min),Go.max.copy(e.max),Go.needsUpdate=!0),!0),intersectsRange:(e,i)=>{if(t.boundsTree){return t.boundsTree.shapecast({boundsTraverseOrder:e=>Go.distanceToBox(e),intersectsBounds:(e,t,n)=>n<y&&n<o,intersectsRange:(t,r)=>{for(let o=t,a=t+r;o<a;o++){setTriangle(u,3*o,p,c),u.a.applyMatrix4(n),u.b.applyMatrix4(n),u.c.applyMatrix4(n),u.needsUpdate=!0;for(let t=e,n=e+i;t<n;t++){setTriangle(h,3*t,l,A),h.needsUpdate=!0;const e=h.distanceToTriangle(u,d,f);if(e<y&&(g.copy(d),m&&m.copy(f),y=e,b=t,I=o),e<s)return!0}}}})}for(let r=0,o=getTriCount$1(t);r<o;r++){setTriangle(u,3*r,p,c),u.a.applyMatrix4(n),u.b.applyMatrix4(n),u.c.applyMatrix4(n),u.needsUpdate=!0;for(let t=e,n=e+i;t<n;t++){setTriangle(h,3*t,l,A),h.needsUpdate=!0;const e=h.distanceToTriangle(u,d,f);if(e<y&&(g.copy(d),m&&m.copy(f),y=e,b=t,I=r),e<s)return!0}}}}),fo.releasePrimitive(h),fo.releasePrimitive(u),y===1/0?null:(i.point?i.point.copy(g):i.point=g.clone(),i.distance=y,i.faceIndex=b,r&&(r.point?r.point.copy(m):r.point=m.clone(),r.point.applyMatrix4(No),g.applyMatrix4(No),r.distance=g.sub(r.point).length(),r.faceIndex=I),i)}function refit_indirect(e,t=null){t&&Array.isArray(t)&&(t=new Set(t));const n=e.geometry,i=n.index?n.index.array:null,r=n.attributes.position;let s,o,a,A,l=0;const c=e._roots;for(let e=0,t=c.length;e<t;e++)s=c[e],o=new Uint32Array(s),a=new Uint16Array(s),A=new Float32Array(s),_traverse(0,l),l+=s.byteLength;function _traverse(n,s,l=!1){const c=2*n;if(IS_LEAF(c,a)){const t=o[n+6];let s=1/0,l=1/0,p=1/0,h=-1/0,u=-1/0,d=-1/0;for(let n=t,o=t+a[c+14];n<o;n++){const t=3*e.resolveTriangleIndex(n);for(let e=0;e<3;e++){let n=t+e;n=i?i[n]:n;const o=r.getX(n),a=r.getY(n),A=r.getZ(n);o<s&&(s=o),o>h&&(h=o),a<l&&(l=a),a>u&&(u=a),A<p&&(p=A),A>d&&(d=A)}}return(A[n+0]!==s||A[n+1]!==l||A[n+2]!==p||A[n+3]!==h||A[n+4]!==u||A[n+5]!==d)&&(A[n+0]=s,A[n+1]=l,A[n+2]=p,A[n+3]=h,A[n+4]=u,A[n+5]=d,!0)}{const e=LEFT_NODE(n),i=RIGHT_NODE(n,o);let r=l,a=!1,c=!1;if(t){if(!r){const n=e/8+s/qs,o=i/8+s/qs;a=t.has(n),c=t.has(o),r=!a&&!c}}else a=!0,c=!0;const p=r||c;let h=!1;(r||a)&&(h=_traverse(e,s,r));let u=!1;p&&(u=_traverse(i,s,r));const d=h||u;if(d)for(let t=0;t<3;t++){const r=e+t,s=i+t,o=A[r],a=A[r+3],l=A[s],c=A[s+3];A[n+t]=o<l?o:l,A[n+t+3]=a>c?a:c}return d}}}function raycast_indirect(e,t,n,i,r,s,o){ro.setBuffer(e._roots[t]),_raycast(0,e,n,i,r,s,o),ro.clearBuffer()}function _raycast(e,t,n,i,r,s,o){const{float32Array:a,uint16Array:A,uint32Array:l}=ro,c=2*e;if(IS_LEAF(c,A)){!function intersectTris_indirect(e,t,n,i,r,s,o,a){const{geometry:A,_indirectBuffer:l}=e;for(let e=i,c=i+r;e<c;e++)intersectTri(A,t,n,l?l[e]:e,s,o,a)}(t,n,i,OFFSET(e,l),COUNT(c,A),r,s,o)}else{const A=LEFT_NODE(e);intersectRay(A,a,i,s,o)&&_raycast(A,t,n,i,r,s,o);const c=RIGHT_NODE(e,l);intersectRay(c,a,i,s,o)&&_raycast(c,t,n,i,r,s,o)}}const Xo=["x","y","z"];function raycastFirst_indirect(e,t,n,i,r,s){ro.setBuffer(e._roots[t]);const o=_raycastFirst(0,e,n,i,r,s);return ro.clearBuffer(),o}function _raycastFirst(e,t,n,i,r,s){const{float32Array:o,uint16Array:a,uint32Array:A}=ro;let l=2*e;if(IS_LEAF(l,a)){return function intersectClosestTri_indirect(e,t,n,i,r,s,o){const{geometry:a,_indirectBuffer:A}=e;let l=1/0,c=null;for(let e=i,p=i+r;e<p;e++){let i;i=intersectTri(a,t,n,A?A[e]:e,null,s,o),i&&i.distance<l&&(c=i,l=i.distance)}return c}(t,n,i,OFFSET(e,A),COUNT(l,a),r,s)}{const a=SPLIT_AXIS(e,A),l=Xo[a],c=i.direction[l]>=0;let p,h;c?(p=LEFT_NODE(e),h=RIGHT_NODE(e,A)):(p=RIGHT_NODE(e,A),h=LEFT_NODE(e));const u=intersectRay(p,o,i,r,s)?_raycastFirst(p,t,n,i,r,s):null;if(u){const e=u.point[l];if(c?e<=o[h+a]:e>=o[h+a+3])return u}const d=intersectRay(h,o,i,r,s)?_raycastFirst(h,t,n,i,r,s):null;return u&&d?u.distance<=d.distance?u:d:u||d||null}}const qo=new p,jo=new ExtendedTriangle,Wo=new ExtendedTriangle,Jo=new m,Vo=new OrientedBox,Ko=new OrientedBox;function intersectsGeometry_indirect(e,t,n,i){ro.setBuffer(e._roots[t]);const r=_intersectsGeometry(0,e,n,i);return ro.clearBuffer(),r}function _intersectsGeometry(e,t,n,i,r=null){const{float32Array:s,uint16Array:o,uint32Array:a}=ro;let A=2*e;null===r&&(n.boundingBox||n.computeBoundingBox(),Vo.set(n.boundingBox.min,n.boundingBox.max,i),r=Vo);if(!IS_LEAF(A,o)){const o=LEFT_NODE(e),A=RIGHT_NODE(e,a);arrayToBox(o,s,qo);if(r.intersectsBox(qo)&&_intersectsGeometry(o,t,n,i,r))return!0;arrayToBox(A,s,qo);return!!(r.intersectsBox(qo)&&_intersectsGeometry(A,t,n,i,r))}{const r=t.geometry,l=r.index,c=r.attributes.position,p=n.index,h=n.attributes.position,u=OFFSET(e,a),d=COUNT(A,o);if(Jo.copy(i).invert(),n.boundsTree){arrayToBox(e,s,Ko),Ko.matrix.copy(Jo),Ko.needsUpdate=!0;return n.boundsTree.shapecast({intersectsBounds:e=>Ko.intersectsBox(e),intersectsTriangle:e=>{e.a.applyMatrix4(i),e.b.applyMatrix4(i),e.c.applyMatrix4(i),e.needsUpdate=!0;for(let n=u,i=d+u;n<i;n++)if(setTriangle(Wo,3*t.resolveTriangleIndex(n),l,c),Wo.needsUpdate=!0,e.intersectsTriangle(Wo))return!0;return!1}})}{const e=getTriCount$1(n);for(let n=u,i=d+u;n<i;n++){const i=t.resolveTriangleIndex(n);setTriangle(jo,3*i,l,c),jo.a.applyMatrix4(Jo),jo.b.applyMatrix4(Jo),jo.c.applyMatrix4(Jo),jo.needsUpdate=!0;for(let t=0,n=3*e;t<n;t+=3)if(setTriangle(Wo,t,p,h),Wo.needsUpdate=!0,jo.intersectsTriangle(Wo))return!0}}}}const Zo=new m,$o=new OrientedBox,ea=new OrientedBox,ta=new u,na=new u,ia=new u,ra=new u;function closestPointToGeometry_indirect(e,t,n,i={},r={},s=0,o=1/0){t.boundingBox||t.computeBoundingBox(),$o.set(t.boundingBox.min,t.boundingBox.max,n),$o.needsUpdate=!0;const a=e.geometry,A=a.attributes.position,l=a.index,c=t.attributes.position,p=t.index,h=fo.getPrimitive(),u=fo.getPrimitive();let d=ta,g=na,f=null,m=null;r&&(f=ia,m=ra);let y=1/0,b=null,I=null;return Zo.copy(n).invert(),ea.matrix.copy(Zo),e.shapecast({boundsTraverseOrder:e=>$o.distanceToBox(e),intersectsBounds:(e,t,n)=>n<y&&n<o&&(t&&(ea.min.copy(e.min),ea.max.copy(e.max),ea.needsUpdate=!0),!0),intersectsRange:(i,r)=>{if(t.boundsTree){const a=t.boundsTree;return a.shapecast({boundsTraverseOrder:e=>ea.distanceToBox(e),intersectsBounds:(e,t,n)=>n<y&&n<o,intersectsRange:(t,o)=>{for(let x=t,C=t+o;x<C;x++){const t=a.resolveTriangleIndex(x);setTriangle(u,3*t,p,c),u.a.applyMatrix4(n),u.b.applyMatrix4(n),u.c.applyMatrix4(n),u.needsUpdate=!0;for(let t=i,n=i+r;t<n;t++){const n=e.resolveTriangleIndex(t);setTriangle(h,3*n,l,A),h.needsUpdate=!0;const i=h.distanceToTriangle(u,d,f);if(i<y&&(g.copy(d),m&&m.copy(f),y=i,b=t,I=x),i<s)return!0}}}})}for(let o=0,a=getTriCount$1(t);o<a;o++){setTriangle(u,3*o,p,c),u.a.applyMatrix4(n),u.b.applyMatrix4(n),u.c.applyMatrix4(n),u.needsUpdate=!0;for(let t=i,n=i+r;t<n;t++){const n=e.resolveTriangleIndex(t);setTriangle(h,3*n,l,A),h.needsUpdate=!0;const i=h.distanceToTriangle(u,d,f);if(i<y&&(g.copy(d),m&&m.copy(f),y=i,b=t,I=o),i<s)return!0}}}}),fo.releasePrimitive(h),fo.releasePrimitive(u),y===1/0?null:(i.point?i.point.copy(g):i.point=g.clone(),i.distance=y,i.faceIndex=b,r&&(r.point?r.point.copy(m):r.point=m.clone(),r.point.applyMatrix4(Zo),g.applyMatrix4(Zo),r.distance=g.sub(r.point).length(),r.faceIndex=I),i)}const sa=new ro.constructor,oa=new ro.constructor,aa=new PrimitivePool((()=>new p)),Aa=new p,la=new p,ca=new p,pa=new p;let ha=!1;function _traverse(e,t,n,i,r,s=0,o=0,a=0,A=0,l=null,c=!1){let p,h;c?(p=oa,h=sa):(p=sa,h=oa);const u=p.float32Array,d=p.uint32Array,g=p.uint16Array,f=h.float32Array,m=h.uint32Array,y=h.uint16Array,b=2*t,I=IS_LEAF(2*e,g),x=IS_LEAF(b,y);let C=!1;if(x&&I)C=c?r(OFFSET(t,m),COUNT(2*t,y),OFFSET(e,d),COUNT(2*e,g),A,o+t/8,a,s+e/8):r(OFFSET(e,d),COUNT(2*e,g),OFFSET(t,m),COUNT(2*t,y),a,s+e/8,A,o+t/8);else if(x){const l=aa.getPrimitive();arrayToBox(t,f,l),l.applyMatrix4(n);const p=LEFT_NODE(e),h=RIGHT_NODE(e,d);arrayToBox(p,u,Aa),arrayToBox(h,u,la);const g=l.intersectsBox(Aa),m=l.intersectsBox(la);C=g&&_traverse(t,p,i,n,r,o,s,A,a+1,l,!c)||m&&_traverse(t,h,i,n,r,o,s,A,a+1,l,!c),aa.releasePrimitive(l)}else{const p=LEFT_NODE(t),h=RIGHT_NODE(t,m);arrayToBox(p,f,ca),arrayToBox(h,f,pa);const g=l.intersectsBox(ca),y=l.intersectsBox(pa);if(g&&y)C=_traverse(e,p,n,i,r,s,o,a,A+1,l,c)||_traverse(e,h,n,i,r,s,o,a,A+1,l,c);else if(g)if(I)C=_traverse(e,p,n,i,r,s,o,a,A+1,l,c);else{const t=aa.getPrimitive();t.copy(ca).applyMatrix4(n);const l=LEFT_NODE(e),h=RIGHT_NODE(e,d);arrayToBox(l,u,Aa),arrayToBox(h,u,la);const g=t.intersectsBox(Aa),f=t.intersectsBox(la);C=g&&_traverse(p,l,i,n,r,o,s,A,a+1,t,!c)||f&&_traverse(p,h,i,n,r,o,s,A,a+1,t,!c),aa.releasePrimitive(t)}else if(y)if(I)C=_traverse(e,h,n,i,r,s,o,a,A+1,l,c);else{const t=aa.getPrimitive();t.copy(pa).applyMatrix4(n);const l=LEFT_NODE(e),p=RIGHT_NODE(e,d);arrayToBox(l,u,Aa),arrayToBox(p,u,la);const g=t.intersectsBox(Aa),f=t.intersectsBox(la);C=g&&_traverse(h,l,i,n,r,o,s,A,a+1,t,!c)||f&&_traverse(h,p,i,n,r,o,s,A,a+1,t,!c),aa.releasePrimitive(t)}}return C}function convertRaycastIntersect(e,t,n){return null===e?null:(e.point.applyMatrix4(t.matrixWorld),e.distance=e.point.distanceTo(n.ray.origin),e.object=t,e)}class GeometryBVH extends BVH{get indirect(){return!!this._indirectBuffer}get primitiveStride(){return null}get primitiveBufferStride(){return this.indirect?1:this.primitiveStride}set primitiveBufferStride(e){}get primitiveBuffer(){return this.indirect?this._indirectBuffer:this.geometry.index.array}set primitiveBuffer(e){}constructor(e,t={}){if(!e.isBufferGeometry)throw new Error("BVH: Only BufferGeometries are supported.");if(e.index&&e.index.isInterleavedBufferAttribute)throw new Error("BVH: InterleavedBufferAttribute is not supported for the index attribute.");if(t.useSharedArrayBuffer&&!function isSharedArrayBufferSupported(){return"undefined"!=typeof SharedArrayBuffer}())throw new Error("BVH: SharedArrayBuffer is not available.");super(),this.geometry=e,this.resolvePrimitiveIndex=t.indirect?e=>this._indirectBuffer[e]:e=>e,this.primitiveBuffer=null,this.primitiveBufferStride=null,this._indirectBuffer=null,(t={...Js,...t})[Ws]||this.init(t)}init(e){const{geometry:t,primitiveStride:n}=this;if(e.indirect){const i=function generateIndirectBuffer(e,t){const n=e[e.length-1],i=n.offset+n.count>65536,r=e.reduce(((e,t)=>e+t.count),0),s=i?4:2,o=t?new SharedArrayBuffer(r*s):new ArrayBuffer(r*s),a=i?new Uint32Array(o):new Uint16Array(o);let A=0;for(let t=0;t<e.length;t++){const{offset:n,count:i}=e[t];for(let e=0;e<i;e++)a[A+e]=n+e;A+=i}return a}(getRootPrimitiveRanges(t,e.range,n),e.useSharedArrayBuffer);this._indirectBuffer=i}else ensureIndex$1(t,e);super.init(e),!t.boundingBox&&e.setBoundingBox&&(t.boundingBox=this.getBoundingBox(new p))}computePrimitiveBounds(){throw new Error("BVH: computePrimitiveBounds() not implemented")}getRootRanges(e){return this.indirect?[{offset:0,count:this._indirectBuffer.length}]:getRootPrimitiveRanges(this.geometry,e,this.primitiveStride)}raycastObject3D(){throw new Error("BVH: raycastObject3D() not implemented")}shapecast(e){let{iterateDirect:t,iterateIndirect:n,...i}=e;const r=this.indirect?n:t;return super.shapecast({...i,iterate:r})}}const ua=new OrientedBox,da=new ut,ga=new u,fa=new m,ma=new u;class MeshBVH extends GeometryBVH{static serialize(e,t={}){t={cloneBuffers:!0,...t};const n=e.geometry,i=e._roots,r=e._indirectBuffer,s=n.getIndex(),o={version:1,roots:null,index:null,indirectBuffer:null};return t.cloneBuffers?(o.roots=i.map((e=>e.slice())),o.index=s?s.array.slice():null,o.indirectBuffer=r?r.slice():null):(o.roots=i,o.index=s?s.array:null,o.indirectBuffer=r),o}static deserialize(e,t,n={}){n={setIndex:!0,indirect:Boolean(e.indirectBuffer),...n};const{index:i,roots:r,indirectBuffer:s}=e;e.version||(console.warn("MeshBVH.deserialize: Serialization format has been changed and will be fixed up. It is recommended to regenerate any stored serialized data."),function fixupVersion0(e){for(let t=0;t<e.length;t++){const n=e[t],i=new Uint32Array(n),r=new Uint16Array(n);for(let e=0,t=n.byteLength/qs;e<t;e++){const t=8*e;IS_LEAF(2*t,r)||(i[t+6]=i[t+6]/8-e)}}}(r));const o=new MeshBVH(t,{...n,[Ws]:!0});if(o._roots=r,o._indirectBuffer=s||null,n.setIndex){const n=t.getIndex();if(null===n){const n=new B(e.index,1,!1);t.setIndex(n)}else n.array!==i&&(n.array.set(i),n.needsUpdate=!0)}return o}get primitiveStride(){return 3}get resolveTriangleIndex(){return this.resolvePrimitiveIndex}constructor(e,t={}){t.maxLeafTris&&(t={...t,maxLeafSize:t.maxLeafTris}),super(e,t)}shiftTriangleOffsets(e){return super.shiftPrimitiveOffsets(e)}computePrimitiveBounds(e,t,n){const i=this.geometry,r=this._indirectBuffer,s=i.attributes.position,o=i.index?i.index.array:null,a=s.normalized;if(e<0||t+e-n.offset>n.length/6)throw new Error("MeshBVH: compute triangle bounds range is invalid.");const A=s.array,l=s.offset||0;let c=3;s.isInterleavedBufferAttribute&&(c=s.data.stride);const p=["getX","getY","getZ"],h=n.offset;for(let i=e,u=e+t;i<u;i++){const e=3*(r?r[i]:i),t=6*(i-h);let u=e+0,d=e+1,g=e+2;o&&(u=o[u],d=o[d],g=o[g]),a||(u=u*c+l,d=d*c+l,g=g*c+l);for(let e=0;e<3;e++){let i,r,o;a?(i=s[p[e]](u),r=s[p[e]](d),o=s[p[e]](g)):(i=A[u+e],r=A[d+e],o=A[g+e]);let l=i;r<l&&(l=r),o<l&&(l=o);let c=i;r>c&&(c=r),o>c&&(c=o);const h=(c-l)/2,f=2*e;n[t+f+0]=l+h,n[t+f+1]=h+(Math.abs(l)+h)*js}}return n}raycastObject3D(e,t,n=[]){const{material:i}=e;if(void 0===i)return;fa.copy(e.matrixWorld).invert(),da.copy(t.ray).applyMatrix4(fa),ma.setFromMatrixScale(e.matrixWorld),ga.copy(da.direction).multiply(ma);const r=ga.length(),s=t.near/r,o=t.far/r;if(!0===t.firstHitOnly){let r=this.raycastFirst(da,i,s,o);r=convertRaycastIntersect(r,e,t),r&&n.push(r)}else{const r=this.raycast(da,i,s,o);for(let i=0,s=r.length;i<s;i++){const s=convertRaycastIntersect(r[i],e,t);s&&n.push(s)}}return n}refit(e=null){return(this.indirect?refit_indirect:refit)(this,e)}raycast(e,t=Ce,n=0,i=1/0){const r=this._roots,s=[],o=this.indirect?raycast_indirect:raycast;for(let a=0,A=r.length;a<A;a++)o(this,a,t,e,s,n,i);return s}raycastFirst(e,t=Ce,n=0,i=1/0){const r=this._roots;let s=null;const o=this.indirect?raycastFirst_indirect:raycastFirst;for(let a=0,A=r.length;a<A;a++){const r=o(this,a,t,e,n,i);null!=r&&(null==s||r.distance<s.distance)&&(s=r)}return s}intersectsGeometry(e,t){let n=!1;const i=this._roots,r=this.indirect?intersectsGeometry_indirect:intersectsGeometry;for(let s=0,o=i.length;s<o&&(n=r(this,s,e,t),!n);s++);return n}shapecast(e){const t=fo.getPrimitive(),n=super.shapecast({...e,intersectsPrimitive:e.intersectsTriangle,scratchPrimitive:t,iterateDirect:iterateOverTriangles,iterateIndirect:iterateOverTriangles_indirect});return fo.releasePrimitive(t),n}bvhcast(e,t,n){let{intersectsRanges:i,intersectsTriangles:r}=n;const s=fo.getPrimitive(),o=this.geometry.index,a=this.geometry.attributes.position,A=this.indirect?e=>{const t=this.resolveTriangleIndex(e);setTriangle(s,3*t,o,a)}:e=>{setTriangle(s,3*e,o,a)},l=fo.getPrimitive(),c=e.geometry.index,p=e.geometry.attributes.position,h=e.indirect?t=>{const n=e.resolveTriangleIndex(t);setTriangle(l,3*n,c,p)}:e=>{setTriangle(l,3*e,c,p)};if(r){const iterateOverDoubleTriangles=(e,n,i,o,a,c,p,u)=>{for(let d=i,g=i+o;d<g;d++){h(d),l.a.applyMatrix4(t),l.b.applyMatrix4(t),l.c.applyMatrix4(t),l.needsUpdate=!0;for(let t=e,i=e+n;t<i;t++)if(A(t),s.needsUpdate=!0,r(s,l,t,d,a,c,p,u))return!0}return!1};if(i){const e=i;i=function(t,n,i,r,s,o,a,A){return!!e(t,n,i,r,s,o,a,A)||iterateOverDoubleTriangles(t,n,i,r,s,o,a,A)}}else i=iterateOverDoubleTriangles}return function bvhcast(e,t,n,i){if(ha)throw new Error("MeshBVH: Recursive calls to bvhcast not supported.");ha=!0;const r=e._roots,s=t._roots;let o,a=0,A=0;const l=(new m).copy(n).invert();for(let e=0,t=r.length;e<t;e++){sa.setBuffer(r[e]),A=0;const t=aa.getPrimitive();arrayToBox(0,sa.float32Array,t),t.applyMatrix4(l);for(let e=0,r=s.length;e<r&&(oa.setBuffer(s[e]),o=_traverse(0,0,n,l,i,a,A,0,0,t),oa.clearBuffer(),A+=s[e].byteLength/qs,!o);e++);if(aa.releasePrimitive(t),sa.clearBuffer(),a+=r[e].byteLength/qs,o)break}return ha=!1,o}(this,e,t,i)}intersectsBox(e,t){return ua.set(e.min,e.max,t),ua.needsUpdate=!0,this.shapecast({intersectsBounds:e=>ua.intersectsBox(e),intersectsTriangle:e=>ua.intersectsTriangle(e)})}intersectsSphere(e){return this.shapecast({intersectsBounds:t=>e.intersectsBox(t),intersectsTriangle:t=>t.intersectsSphere(e)})}closestPointToGeometry(e,t,n={},i={},r=0,s=1/0){return(this.indirect?closestPointToGeometry_indirect:closestPointToGeometry)(this,e,t,n,i,r,s)}closestPointToPoint(e,t={},n=0,i=1/0){return function closestPointToPoint(e,t,n={},i=0,r=1/0){const s=i*i,o=r*r;let a=1/0,A=null;if(e.shapecast({boundsTraverseOrder:e=>(mo.copy(t).clamp(e.min,e.max),mo.distanceToSquared(t)),intersectsBounds:(e,t,n)=>n<a&&n<o,intersectsTriangle:(e,n)=>{e.closestPointToPoint(t,mo);const i=t.distanceToSquared(mo);return i<a&&(yo.copy(mo),a=i,A=n),i<s}}),a===1/0)return null;const l=Math.sqrt(a);return n.point?n.point.copy(yo):n.point=yo.clone(),n.distance=l,n.faceIndex=A,n}(this,e,t,n,i)}}const ya=1e-6,ba=Math.pow(10,-Math.log10(ya)),Ia=5e-7*ba;function hashNumber(e){return~~(e*ba+Ia)}function hashVertex3(e){return`${hashNumber(e.x)},${hashNumber(e.y)},${hashNumber(e.z)}`}function hashVertex4(e){return`${hashNumber(e.x)},${hashNumber(e.y)},${hashNumber(e.z)},${hashNumber(e.w)}`}function toNormalizedRay(e,t,n){n.direction.subVectors(t,e).normalize();const i=e.dot(n.direction);return n.origin.copy(e).addScaledVector(n.direction,-i),n}function areSharedArrayBuffersSupported(){return"undefined"!=typeof SharedArrayBuffer}function convertToSharedArrayBuffer(e){if(e.buffer instanceof SharedArrayBuffer)return e;const t=e.constructor,n=e.buffer,i=new SharedArrayBuffer(n.byteLength),r=new Uint8Array(n);return new Uint8Array(i).set(r,0),new t(i)}function ensureIndex(e,t){if(!e.index){const n=e.attributes.position.count,i=function getIndexArray(e,t=ArrayBuffer){return e>65535?new Uint32Array(new t(4*e)):new Uint16Array(new t(2*e))}(n,t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer);e.setIndex(new B(i,1));for(let e=0;e<n;e++)i[e]=e}}function getTriCount(e){return function getVertexCount(e){return e.index?e.index.count:e.attributes.position.count}(e)/3}const xa=new u;function toEdgeIndex(e){return e%3}function sortEdgeFunc(e,t){return e.start-t.start}function getProjectedDistance(e,t){return xa.subVectors(t,e.origin).dot(e.direction)}const Ca=1e-5,Ba=1e-4;class RaySet{constructor(){this._rays=[]}addRay(e){this._rays.push(e)}findClosestRay(e){const t=this._rays,n=e.clone();n.direction.multiplyScalar(-1);let i=1/0,r=null;for(let s=0,o=t.length;s<o;s++){const o=t[s];if(skipRay(o,e)&&skipRay(o,n))continue;const a=scoreRays(o,e),A=scoreRays(o,n),l=Math.min(a,A);l<i&&(i=l,r=o)}return r;function skipRay(e,t){const n=e.origin.distanceTo(t.origin)>Ca;return e.direction.angleTo(t.direction)>Ba||n}function scoreRays(e,t){const n=e.origin.distanceTo(t.origin),i=e.direction.angleTo(t.direction);return n/Ca+i/Ba}}}const Ea=new u,wa=new u,va=new ut;function computeDisjointEdges(e,t,n){const i=e.attributes,r=e.index,s=i.position,o=new Map,a=new Map,A=Array.from(t),l=new RaySet;for(let e=0,t=A.length;e<t;e++){const t=A[e],n=~~(t/3),i=toEdgeIndex(t);let o,c=3*n+i,p=3*n+(i+1)%3;r&&(c=r.getX(c),p=r.getX(p)),Ea.fromBufferAttribute(s,c),wa.fromBufferAttribute(s,p),toNormalizedRay(Ea,wa,va);let h=l.findClosestRay(va);null===h&&(h=va.clone(),l.addRay(h)),a.has(h)||a.set(h,{forward:[],reverse:[],ray:h}),o=a.get(h);let u=getProjectedDistance(h,Ea),d=getProjectedDistance(h,wa);u>d&&([u,d]=[d,u]),va.direction.dot(h.direction)<0?o.reverse.push({start:u,end:d,index:t}):o.forward.push({start:u,end:d,index:t})}return a.forEach((({forward:e,reverse:t},i)=>{!function matchEdges(e,t,n,i=1e-8){e.sort(sortEdgeFunc),t.sort(sortEdgeFunc);for(let i=0;i<e.length;i++){const r=e[i];for(let s=0;s<t.length;s++){const o=t[s];if(o.start>r.end);else{if(r.end<o.start||o.end<r.start)continue;if(r.start<=o.start&&r.end>=o.end)areDistancesDegenerate(o.end,r.end)||e.splice(i+1,0,{start:o.end,end:r.end,index:r.index}),r.end=o.start,o.start=0,o.end=0;else if(r.start>=o.start&&r.end<=o.end)areDistancesDegenerate(r.end,o.end)||t.splice(s+1,0,{start:r.end,end:o.end,index:o.index}),o.end=r.start,r.start=0,r.end=0;else if(r.start<=o.start&&r.end<=o.end){const e=r.end;r.end=o.start,o.start=e}else{if(!(r.start>=o.start&&r.end>=o.end))throw new Error;{const e=o.end;o.end=r.start,r.start=e}}}if(n.has(r.index)||n.set(r.index,[]),n.has(o.index)||n.set(o.index,[]),n.get(r.index).push(o.index),n.get(o.index).push(r.index),isEdgeDegenerate(o)&&(t.splice(s,1),s--),isEdgeDegenerate(r)){e.splice(i,1),i--;break}}}function cleanUpEdgeSet(e){for(let t=0;t<e.length;t++)isEdgeDegenerate(e[t])&&(e.splice(t,1),t--)}function areDistancesDegenerate(e,t){return Math.abs(t-e)<i}function isEdgeDegenerate(e){return Math.abs(e.end-e.start)<i}cleanUpEdgeSet(e),cleanUpEdgeSet(t)}(e,t,o,n),0===e.length&&0===t.length&&a.delete(i)})),{disjointConnectivityMap:o,fragmentMap:a}}const Qa=new r,Pa=new u,Ta=new g,Sa=["","",""];class HalfEdgeMap{constructor(e=null){this.data=null,this.disjointConnections=null,this.unmatchedDisjointEdges=null,this.unmatchedEdges=-1,this.matchedEdges=-1,this.useDrawRange=!0,this.useAllAttributes=!1,this.matchDisjointEdges=!1,this.degenerateEpsilon=1e-8,e&&this.updateFrom(e)}getSiblingTriangleIndex(e,t){const n=this.data[3*e+t];return-1===n?-1:~~(n/3)}getSiblingEdgeIndex(e,t){const n=this.data[3*e+t];return-1===n?-1:n%3}getDisjointSiblingTriangleIndices(e,t){const n=3*e+t,i=this.disjointConnections.get(n);return i?i.map((e=>~~(e/3))):[]}getDisjointSiblingEdgeIndices(e,t){const n=3*e+t,i=this.disjointConnections.get(n);return i?i.map((e=>e%3)):[]}isFullyConnected(){return 0===this.unmatchedEdges}updateFrom(e){const{useAllAttributes:t,useDrawRange:n,matchDisjointEdges:i,degenerateEpsilon:r}=this,s=t?function hashAllAttributes(e){let t="";for(let i=0,r=A.length;i<r;i++){const r=a[A[i]];let s;switch(r.itemSize){case 1:s=hashNumber(r.getX(e));break;case 2:s=`${hashNumber((n=Qa.fromBufferAttribute(r,e)).x)},${hashNumber(n.y)}`;break;case 3:s=hashVertex3(Pa.fromBufferAttribute(r,e));break;case 4:s=hashVertex4(Ta.fromBufferAttribute(r,e))}""!==t&&(t+="|"),t+=s}var n;return t}:function hashPositionAttribute(e){return Pa.fromBufferAttribute(c,e),hashVertex3(Pa)},o=new Map,{attributes:a}=e,A=t?Object.keys(a):null,l=e.index,c=a.position;let p=getTriCount(e);const h=p;let u=0;n&&(u=e.drawRange.start,e.drawRange.count!==1/0&&(p=~~(e.drawRange.count/3)));let d=this.data;(!d||d.length<3*h)&&(d=new Int32Array(3*h)),d.fill(-1);let g=0,f=new Set;for(let e=u,t=3*p+u;e<t;e+=3){const t=e;for(let e=0;e<3;e++){let n=t+e;l&&(n=l.getX(n)),Sa[e]=s(n)}for(let e=0;e<3;e++){const n=(e+1)%3,i=Sa[e],r=Sa[n],s=`${r}_${i}`;if(o.has(s)){const n=t+e,i=o.get(s);d[n]=i,d[i]=n,o.delete(s),g+=2,f.delete(i)}else{const n=`${i}_${r}`,s=t+e;o.set(n,s),f.add(s)}}}if(i){const{fragmentMap:t,disjointConnectivityMap:n}=computeDisjointEdges(e,f,r);f.clear(),t.forEach((({forward:e,reverse:t})=>{e.forEach((({index:e})=>f.add(e))),t.forEach((({index:e})=>f.add(e)))})),this.unmatchedDisjointEdges=t,this.disjointConnections=n,g=3*p-f.size}this.matchedEdges=g,this.unmatchedEdges=f.size,this.data=d}}class Brush extends d{constructor(...e){super(...e),this.isBrush=!0,this._previousMatrix=new m,this._previousMatrix.elements.fill(0)}markUpdated(){this._previousMatrix.copy(this.matrix)}isDirty(){const{matrix:e,_previousMatrix:t}=this,n=e.elements,i=t.elements;for(let e=0;e<16;e++)if(n[e]!==i[e])return!0;return!1}prepareGeometry(){const e=this.geometry,t=e.attributes,n=areSharedArrayBuffersSupported();if(n)for(const e in t){const n=t[e];if(n.isInterleavedBufferAttribute)throw new Error("Brush: InterleavedBufferAttributes are not supported.");n.array=convertToSharedArrayBuffer(n.array)}if(e.boundsTree||(ensureIndex(e,{useSharedArrayBuffer:n}),e.boundsTree=new MeshBVH(e,{maxLeafTris:3,indirect:!0,useSharedArrayBuffer:n})),e.halfEdges||(e.halfEdges=new HalfEdgeMap(e)),!e.groupIndices){const t=getTriCount(e),n=new Uint16Array(t),i=e.groups;for(let e=0,t=i.length;e<t;e++){const{start:t,count:r}=i[e];for(let i=t/3,s=(t+r)/3;i<s;i++)n[i]=e}e.groupIndices=n}}disposeCacheData(){const{geometry:e}=this;e.halfEdges=null,e.boundsTree=null,e.groupIndices=null}}const Ma=new u,Da=new u,La=new u;function isTriDegenerate(e,t=1e-14){Ma.subVectors(e.b,e.a),Da.subVectors(e.c,e.a),La.subVectors(e.b,e.c);const n=Ma.angleTo(Da),i=Ma.angleTo(La),r=Math.PI-n-i;return Math.abs(n)<t||Math.abs(i)<t||Math.abs(r)<t||e.a.distanceToSquared(e.b)<t||e.a.distanceToSquared(e.c)<t||e.b.distanceToSquared(e.c)<t}const _a=1e-10,Fa=1e-10,ka=new f,Ra=new f,Na=new u,Oa=new u,Ga=new u,Ua=new lt,Ya=new ExtendedTriangle;class TrianglePool{constructor(){this._pool=[],this._index=0}getTriangle(){return this._index>=this._pool.length&&this._pool.push(new ct),this._pool[this._index++]}clear(){this._index=0}reset(){this._pool.length=0,this._index=0}}class TriangleSplitter{constructor(){this.trianglePool=new TrianglePool,this.triangles=[],this.normal=new u,this.coplanarTriangleUsed=!1}initialize(e){this.reset();const{triangles:t,trianglePool:n,normal:i}=this;if(Array.isArray(e))for(let r=0,s=e.length;r<s;r++){const s=e[r];if(0===r)s.getNormal(i);else if(Math.abs(1-s.getNormal(Na).dot(i))>_a)throw new Error("Triangle Splitter: Cannot initialize with triangles that have different normals.");const o=n.getTriangle();o.copy(s),t.push(o)}else{e.getNormal(i);const r=n.getTriangle();r.copy(e),t.push(r)}}splitByTriangle(e){const{normal:t,triangles:n}=this;if(e.getNormal(Oa).normalize(),Math.abs(1-Math.abs(Oa.dot(t)))<1e-10){this.coplanarTriangleUsed=!0;for(let e=0,t=n.length;e<t;e++){n[e].coplanarCount=0}const t=[e.a,e.b,e.c];for(let n=0;n<3;n++){const i=(n+1)%3,r=t[n],s=t[i];Na.subVectors(s,r).normalize(),Ga.crossVectors(Oa,Na),Ua.setFromNormalAndCoplanarPoint(Ga,r),this.splitByPlane(Ua,e)}}else e.getPlane(Ua),this.splitByPlane(Ua,e)}splitByPlane(e,t){const{triangles:n,trianglePool:i}=this;Ya.copy(t),Ya.needsUpdate=!0;for(let t=0,r=n.length;t<r;t++){const s=n[t];if(!Ya.intersectsTriangle(s,ka,!0))continue;const{a:o,b:a,c:A}=s;let l=0,c=-1,p=!1,h=[],u=[];const d=[o,a,A];for(let t=0;t<3;t++){const n=(t+1)%3;ka.start.copy(d[t]),ka.end.copy(d[n]);const i=e.distanceToPoint(ka.start),r=e.distanceToPoint(ka.end);if(Math.abs(i)<Fa&&Math.abs(r)<Fa){p=!0;break}if(i>0?h.push(t):u.push(t),Math.abs(i)<Fa)continue;let s=!!e.intersectLine(ka,Na);!s&&Math.abs(r)<Fa&&(Na.copy(ka.end),s=!0),!s||Na.distanceTo(ka.start)<_a||(Na.distanceTo(ka.end)<_a&&(c=t),0===l?Ra.start.copy(Na):Ra.end.copy(Na),l++)}if(!p&&2===l&&Ra.distance()>Fa)if(-1!==c){c=(c+1)%3;let e=0;e===c&&(e=(e+1)%3);let o=e+1;o===c&&(o=(o+1)%3);const a=i.getTriangle();a.a.copy(d[o]),a.b.copy(Ra.end),a.c.copy(Ra.start),isTriDegenerate(a)||n.push(a),s.a.copy(d[e]),s.b.copy(Ra.start),s.c.copy(Ra.end),isTriDegenerate(s)&&(n.splice(t,1),t--,r--)}else{const e=h.length>=2?u[0]:h[0];if(0===e){let e=Ra.start;Ra.start=Ra.end,Ra.end=e}const o=(e+1)%3,a=(e+2)%3,A=i.getTriangle(),l=i.getTriangle();d[o].distanceToSquared(Ra.start)<d[a].distanceToSquared(Ra.end)?(A.a.copy(d[o]),A.b.copy(Ra.start),A.c.copy(Ra.end),l.a.copy(d[o]),l.b.copy(d[a]),l.c.copy(Ra.start)):(A.a.copy(d[a]),A.b.copy(Ra.start),A.c.copy(Ra.end),l.a.copy(d[o]),l.b.copy(d[a]),l.c.copy(Ra.end)),s.a.copy(d[e]),s.b.copy(Ra.end),s.c.copy(Ra.start),isTriDegenerate(A)||n.push(A),isTriDegenerate(l)||n.push(l),isTriDegenerate(s)&&(n.splice(t,1),t--,r--)}else 3===l&&console.warn("TriangleClipper: Coplanar clip not handled")}}reset(){this.triangles.length=0,this.trianglePool.clear(),this.coplanarTriangleUsed=!1}}class TypeBackedArray{constructor(e,t=500){this.expansionFactor=1.5,this.type=e,this.length=0,this.array=null,this.setSize(t)}setType(e){if(0!==this.length)throw new Error("TypeBackedArray: Cannot change the type while there is used data in the buffer.");const t=this.array.buffer;this.array=new e(t),this.type=e}setSize(e){if(this.array&&e===this.array.length)return;const t=this.type,n=new t(new(areSharedArrayBuffersSupported()?SharedArrayBuffer:ArrayBuffer)(function ceilToFourByteStride(e){return 4+(e=~~e)-e%4}(e*t.BYTES_PER_ELEMENT)));this.array&&n.set(this.array,0),this.array=n}expand(){const{array:e,expansionFactor:t}=this;this.setSize(e.length*t)}push(...e){let{array:t,length:n}=this;n+e.length>t.length&&(this.expand(),t=this.array);for(let i=0,r=e.length;i<r;i++)t[n+i]=e[i];this.length+=e.length}clear(){this.length=0}}class TypedAttributeData{constructor(){this.groupAttributes=[{}],this.groupCount=0}getType(e){return this.groupAttributes[0][e].type}getItemSize(e){return this.groupAttributes[0][e].itemSize}getNormalized(e){return this.groupAttributes[0][e].normalized}getCount(e){if(this.groupCount<=e)return 0;const t=this.getGroupAttrArray("position",e);return t.length/t.itemSize}getTotalLength(e){const{groupCount:t,groupAttributes:n}=this;let i=0;for(let r=0;r<t;r++){i+=n[r][e].length}return i}getGroupAttrSet(e=0){const{groupAttributes:t}=this;if(t[e])return this.groupCount=Math.max(this.groupCount,e+1),t[e];const n=t[0];for(this.groupCount=Math.max(this.groupCount,e+1);e>=t.length;){const e={};t.push(e);for(const t in n){const i=n[t],r=new TypeBackedArray(i.type);r.itemSize=i.itemSize,r.normalized=i.normalized,e[t]=r}}return t[e]}getGroupAttrArray(e,t=0){const{groupAttributes:n}=this;if(!n[0][e])throw new Error(`TypedAttributeData: Attribute with "${e}" has not been initialized`);return this.getGroupAttrSet(t)[e]}initializeArray(e,t,n,i){const{groupAttributes:r}=this,s=r[0][e];if(s){if(s.type!==t)for(let s=0,o=r.length;s<o;s++){const o=r[s][e];o.setType(t),o.itemSize=n,o.normalized=i}}else for(let s=0,o=r.length;s<o;s++){const o=new TypeBackedArray(t);o.itemSize=n,o.normalized=i,r[s][e]=o}}clear(){this.groupCount=0;const{groupAttributes:e}=this;e.forEach((e=>{for(const t in e)e[t].clear()}))}delete(e){this.groupAttributes.forEach((t=>{delete t[e]}))}reset(){this.groupAttributes=[],this.groupCount=0}}class IntersectionMap{constructor(){this.intersectionSet={},this.ids=[]}add(e,t){const{intersectionSet:n,ids:i}=this;n[e]||(n[e]=[],i.push(e)),n[e].push(t)}}const za=new ut,Ha=new m,Xa=new ct,qa=new u,ja=new g,Wa=new g,Ja=new g,Va=new g,Ka=new g,Za=new g,$a=new f,eA=new u,tA=1e-8,nA=-1;let iA=null;function setDebugContext(e){iA=e}function getHitSide(e,t){e.getMidpoint(za.origin),e.getNormal(za.direction);const n=t.raycastFirst(za,te);return Boolean(n&&za.direction.dot(n.face.normal)>0)?nA:1}function getHitSideWithCoplanarCheck(e,t){function rand(){return Math.random()-.5}e.getNormal(eA),za.direction.copy(eA),e.getMidpoint(za.origin);let n=0,i=1/0;for(let e=0;e<3;e++){za.direction.x+=rand()*tA,za.direction.y+=rand()*tA,za.direction.z+=rand()*tA,za.direction.multiplyScalar(-1);const r=t.raycastFirst(za,te);if(Boolean(r&&za.direction.dot(r.face.normal)>0)&&n++,null!==r&&(i=Math.min(i,r.distance)),i<=1e-15)return r.face.normal.dot(eA)>0?2:-2;if(n/3>.5||(e-n+1)/3>.5)break}return n/3>.5?nA:1}function appendAttributeFromTriangle(e,t,n,i,r,s,o=!1){const a=n.attributes,A=n.index,l=3*e,c=A.getX(l+0),p=A.getX(l+1),h=A.getX(l+2);for(const e in s){const n=a[e],A=s[e];if(!(e in a))throw new Error(`CSG Operations: Attribute ${e} not available on geometry.`);const l=n.itemSize;"position"===e?(Xa.a.fromBufferAttribute(n,c).applyMatrix4(i),Xa.b.fromBufferAttribute(n,p).applyMatrix4(i),Xa.c.fromBufferAttribute(n,h).applyMatrix4(i),pushBarycoordInterpolatedValues(Xa.a,Xa.b,Xa.c,t,3,A,o)):"normal"===e?(Xa.a.fromBufferAttribute(n,c).applyNormalMatrix(r),Xa.b.fromBufferAttribute(n,p).applyNormalMatrix(r),Xa.c.fromBufferAttribute(n,h).applyNormalMatrix(r),o&&(Xa.a.multiplyScalar(-1),Xa.b.multiplyScalar(-1),Xa.c.multiplyScalar(-1)),pushBarycoordInterpolatedValues(Xa.a,Xa.b,Xa.c,t,3,A,o,!0)):(ja.fromBufferAttribute(n,c),Wa.fromBufferAttribute(n,p),Ja.fromBufferAttribute(n,h),pushBarycoordInterpolatedValues(ja,Wa,Ja,t,l,A,o))}}function appendAttributesFromIndices(e,t,n,i,r,s,o,a=!1){appendAttributeFromIndex(e,i,r,s,o,a),appendAttributeFromIndex(a?n:t,i,r,s,o,a),appendAttributeFromIndex(a?t:n,i,r,s,o,a)}function getOperationAction(e,t,n=!1){switch(e){case 0:if(1===t||2===t&&!n)return 1;break;case 1:if(n){if(t===nA)return 0}else if(1===t||-2===t)return 1;break;case 2:if(n){if(1===t||-2===t)return 1}else if(t===nA)return 0;break;case 4:if(t===nA)return 0;if(1===t)return 1;break;case 3:if(t===nA||2===t&&!n)return 1;break;case 5:if(!n&&(1===t||-2===t))return 1;break;case 6:if(!n&&(t===nA||2===t))return 1;break;default:throw new Error(`Unrecognized CSG operation enum "${e}".`)}return 2}function pushBarycoordInterpolatedValues(e,t,n,i,r,s,o=!1,a=!1){const addValues=e=>{s.push(e.x),r>1&&s.push(e.y),r>2&&s.push(e.z),r>3&&s.push(e.w)};Va.set(0,0,0,0).addScaledVector(e,i.a.x).addScaledVector(t,i.a.y).addScaledVector(n,i.a.z),Ka.set(0,0,0,0).addScaledVector(e,i.b.x).addScaledVector(t,i.b.y).addScaledVector(n,i.b.z),Za.set(0,0,0,0).addScaledVector(e,i.c.x).addScaledVector(t,i.c.y).addScaledVector(n,i.c.z),a&&(Va.normalize(),Ka.normalize(),Za.normalize()),addValues(Va),o?(addValues(Za),addValues(Ka)):(addValues(Ka),addValues(Za))}function appendAttributeFromIndex(e,t,n,i,r,s=!1){for(const o in r){const a=t[o],A=r[o];if(!(o in t))throw new Error(`CSG Operations: Attribute ${o} no available on geometry.`);const l=a.itemSize;"position"===o?(qa.fromBufferAttribute(a,e).applyMatrix4(n),A.push(qa.x,qa.y,qa.z)):"normal"===o?(qa.fromBufferAttribute(a,e).applyNormalMatrix(i),s&&qa.multiplyScalar(-1),A.push(qa.x,qa.y,qa.z)):(A.push(a.getX(e)),l>1&&A.push(a.getY(e)),l>2&&A.push(a.getZ(e)),l>3&&A.push(a.getW(e)))}}class TriangleIntersectData{constructor(e){this.triangle=(new ct).copy(e),this.intersects={}}addTriangle(e,t){this.intersects[e]=(new ct).copy(t)}getIntersectArray(){const e=[],{intersects:t}=this;for(const n in t)e.push(t[n]);return e}}class TriangleIntersectionSets{constructor(){this.data={}}addTriangleIntersection(e,t,n,i){const{data:r}=this;r[e]||(r[e]=new TriangleIntersectData(t)),r[e].addTriangle(n,i)}getTrianglesAsArray(e=null){const{data:t}=this,n=[];if(null!==e)e in t&&n.push(t[e].triangle);else for(const e in t)n.push(t[e].triangle);return n}getTriangleIndices(){return Object.keys(this.data).map((e=>parseInt(e)))}getIntersectionIndices(e){const{data:t}=this;return t[e]?Object.keys(t[e].intersects).map((e=>parseInt(e))):[]}getIntersectionsAsArray(e=null,t=null){const{data:n}=this,i=new Set,r=[],addTriangles=e=>{if(n[e])if(null!==t)n[e].intersects[t]&&r.push(n[e].intersects[t]);else{const t=n[e].intersects;for(const e in t)i.has(e)||(i.add(e),r.push(t[e]))}};if(null!==e)addTriangles(e);else for(const e in n)addTriangles(e);return r}reset(){this.data={}}}class OperationDebugData{constructor(){this.enabled=!1,this.triangleIntersectsA=new TriangleIntersectionSets,this.triangleIntersectsB=new TriangleIntersectionSets,this.intersectionEdges=[]}addIntersectingTriangles(e,t,n,i){const{triangleIntersectsA:r,triangleIntersectsB:s}=this;r.addTriangleIntersection(e,t,n,i),s.addTriangleIntersection(n,i,e,t)}addEdge(e){this.intersectionEdges.push(e.clone())}reset(){this.triangleIntersectsA.reset(),this.triangleIntersectsB.reset(),this.intersectionEdges=[]}init(){this.enabled&&(this.reset(),setDebugContext(this))}complete(){this.enabled&&setDebugContext(null)}}const rA=new m,sA=new dt,oA=new ct,aA=new ct,AA=new ct,lA=new ct,cA=[],pA=[];function getFirstIdFromSet(e){for(const t of e)return t}function performOperation(e,t,n,i,r,s={}){const{useGroups:o=!0}=s,{aIntersections:a,bIntersections:A}=function collectIntersectingTriangles(e,t){const n=new IntersectionMap,i=new IntersectionMap;return Ha.copy(e.matrixWorld).invert().multiply(t.matrixWorld),e.geometry.boundsTree.bvhcast(t.geometry.boundsTree,Ha,{intersectsTriangles(r,s,o,a){if(!isTriDegenerate(r)&&!isTriDegenerate(s)){let A=r.intersectsTriangle(s,$a,!0);if(!A){const e=r.plane,t=s.plane,n=e.normal,i=t.normal;1===n.dot(i)&&Math.abs(e.constant-t.constant)<1e-14&&(A=!0)}if(A){let A=e.geometry.boundsTree.resolveTriangleIndex(o),l=t.geometry.boundsTree.resolveTriangleIndex(a);n.add(A,l),i.add(l,A),iA&&(iA.addEdge($a),iA.addIntersectingTriangles(o,r,a,s))}}return!1}}),{aIntersections:n,bIntersections:i}}(e,t);let l;l=o?0:-1,performSplitTriangleOperations(e,t,a,n,!1,i,r,l),performWholeTriangleOperations(e,t,a,n,!1,r,l);return-1!==n.findIndex((e=>6!==e&&5!==e))&&(l=o?e.geometry.groups.length||1:-1,performSplitTriangleOperations(t,e,A,n,!0,i,r,l),performWholeTriangleOperations(t,e,A,n,!0,r,l)),cA.length=0,pA.length=0,{groups:[],materials:null}}function performSplitTriangleOperations(e,t,n,i,r,s,o,a=0){const A=e.matrixWorld.determinant()<0;rA.copy(t.matrixWorld).invert().multiply(e.matrixWorld),sA.getNormalMatrix(e.matrixWorld).multiplyScalar(A?-1:1);const l=e.geometry.groupIndices,c=e.geometry.index,p=e.geometry.attributes.position,h=t.geometry.boundsTree,u=t.geometry.index,d=t.geometry.attributes.position,g=n.ids,f=n.intersectionSet;for(let t=0,n=g.length;t<n;t++){const n=g[t],m=-1===a?0:l[n]+a,y=3*n,b=c.getX(y+0),I=c.getX(y+1),x=c.getX(y+2);oA.a.fromBufferAttribute(p,b).applyMatrix4(rA),oA.b.fromBufferAttribute(p,I).applyMatrix4(rA),oA.c.fromBufferAttribute(p,x).applyMatrix4(rA),s.reset(),s.initialize(oA);const C=f[n];for(let e=0,t=C.length;e<t;e++){const t=3*C[e],n=u.getX(t+0),i=u.getX(t+1),r=u.getX(t+2);aA.a.fromBufferAttribute(d,n),aA.b.fromBufferAttribute(d,i),aA.c.fromBufferAttribute(d,r),s.splitByTriangle(aA)}const B=s.triangles;for(let t=0,a=B.length;t<a;t++){const a=B[t],l=s.coplanarTriangleUsed?getHitSideWithCoplanarCheck(a,h):getHitSide(a,h);cA.length=0,pA.length=0;for(let e=0,t=i.length;e<t;e++){const t=getOperationAction(i[e],l,r);2!==t&&(pA.push(t),cA.push(o[e].getGroupAttrSet(m)))}if(0!==cA.length){oA.getBarycoord(a.a,lA.a),oA.getBarycoord(a.b,lA.b),oA.getBarycoord(a.c,lA.c);for(let t=0,i=cA.length;t<i;t++){const i=cA[t],r=0===pA[t];appendAttributeFromTriangle(n,lA,e.geometry,e.matrixWorld,sA,i,A!==r)}}}}return g.length}function performWholeTriangleOperations(e,t,n,i,r,s,o=0){const a=e.matrixWorld.determinant()<0;rA.copy(t.matrixWorld).invert().multiply(e.matrixWorld),sA.getNormalMatrix(e.matrixWorld).multiplyScalar(a?-1:1);const A=t.geometry.boundsTree,l=e.geometry.groupIndices,c=e.geometry.index,p=e.geometry.attributes,h=p.position,u=[],d=e.geometry.halfEdges,g=new Set;for(let t=0,i=getTriCount(e.geometry);t<i;t++)t in n.intersectionSet||g.add(t);for(;g.size>0;){const t=getFirstIdFromSet(g);g.delete(t),u.push(t);const n=3*t,f=c.getX(n+0),m=c.getX(n+1),y=c.getX(n+2);AA.a.fromBufferAttribute(h,f).applyMatrix4(rA),AA.b.fromBufferAttribute(h,m).applyMatrix4(rA),AA.c.fromBufferAttribute(h,y).applyMatrix4(rA);const b=getHitSide(AA,A);pA.length=0,cA.length=0;for(let e=0,t=i.length;e<t;e++){const t=getOperationAction(i[e],b,r);2!==t&&(pA.push(t),cA.push(s[e]))}for(;u.length>0;){const t=u.pop();for(let e=0;e<3;e++){const n=d.getSiblingTriangleIndex(t,e);-1!==n&&g.has(n)&&(u.push(n),g.delete(n))}if(0!==cA.length){const n=3*t,i=c.getX(n+0),r=c.getX(n+1),s=c.getX(n+2),A=-1===o?0:l[t]+o;if(AA.a.fromBufferAttribute(h,i),AA.b.fromBufferAttribute(h,r),AA.c.fromBufferAttribute(h,s),!isTriDegenerate(AA))for(let t=0,n=cA.length;t<n;t++){const n=pA[t],o=cA[t].getGroupAttrSet(A),l=0===n;appendAttributesFromIndices(i,r,s,p,e.matrixWorld,sA,o,l!==a)}}}}}function getMaterialList(e,t){let n=t;return Array.isArray(t)||(n=[],e.forEach((e=>{n[e.materialIndex]=t}))),n}class Evaluator{constructor(){this.triangleSplitter=new TriangleSplitter,this.attributeData=[],this.attributes=["position","uv","normal"],this.useGroups=!0,this.consolidateGroups=!0,this.debug=new OperationDebugData}getGroupRanges(e){return this.useGroups&&0!==e.groups.length?e.groups.map((e=>({...e}))):[{start:0,count:1/0,materialIndex:0}]}evaluate(e,t,n,i=new Brush){let r=!0;if(Array.isArray(n)||(n=[n]),Array.isArray(i)||(i=[i],r=!1),i.length!==n.length)throw new Error("Evaluator: operations and target array passed as different sizes.");e.prepareGeometry(),t.prepareGeometry();const{triangleSplitter:s,attributeData:o,attributes:a,useGroups:A,consolidateGroups:l,debug:c}=this;for(;o.length<i.length;)o.push(new TypedAttributeData);i.forEach(((t,n)=>{!function prepareAttributesData(e,t,n,i){n.clear();const r=e.attributes;for(let e=0,t=i.length;e<t;e++){const t=i[e],s=r[t];n.initializeArray(t,s.array.constructor,s.itemSize,s.normalized)}for(const e in n.attributes)i.includes(e)||n.delete(e);for(const e in t.attributes)i.includes(e)||(t.deleteAttribute(e),t.dispose())}(e.geometry,t.geometry,o[n],a)})),c.init(),performOperation(e,t,n,s,o,{useGroups:A}),c.complete();const p=this.getGroupRanges(e.geometry),h=getMaterialList(p,e.material),u=this.getGroupRanges(t.geometry),d=getMaterialList(u,t.material);u.forEach((e=>e.materialIndex+=h.length));let g=[...p,...u].map(((e,t)=>({...e,index:t})));if(A){const e=[...h,...d];l&&(g=g.map((t=>{const n=e[t.materialIndex];return t.materialIndex=e.indexOf(n),t})).sort(((e,t)=>e.materialIndex-t.materialIndex)));const t=[];for(let n=0,i=e.length;n<i;n++){let i=!1;for(let e=0,r=g.length;e<r;e++){const r=g[e];r.materialIndex===n&&(i=!0,r.materialIndex=t.length)}i&&t.push(e[n])}i.forEach((e=>{e.material=t}))}else g=[{start:0,count:1/0,index:0,materialIndex:0}],i.forEach((e=>{e.material=h[0]}));return i.forEach(((e,t)=>{const n=e.geometry;!function assignBufferData(e,t,n){let i=!1,r=-1;const s=e.attributes,o=t.groupAttributes[0];for(const a in o){const o=t.getTotalLength(a),A=t.getType(a),l=t.getItemSize(a),c=t.getNormalized(a);let p=s[a];(!p||p.array.length<o)&&(p=new B(new A(o),l,c),e.setAttribute(a,p),i=!0);let h=0;for(let e=0,i=Math.min(n.length,t.groupCount);e<i;e++){const i=n[e].index,{array:r,type:s,length:o}=t.groupAttributes[i][a],A=new s(r.buffer,0,o);p.array.set(A,h),h+=A.length}p.needsUpdate=!0,r=o/p.itemSize}if(e.index){const t=e.index.array;if(t.length<r)e.index=null,i=!0;else for(let e=0,n=t.length;e<n;e++)t[e]=e}let a=0;e.clearGroups();for(let i=0,r=Math.min(n.length,t.groupCount);i<r;i++){const{index:r,materialIndex:s}=n[i],o=t.getCount(r);0!==o&&(e.addGroup(a,o,s),a+=o)}e.setDrawRange(0,r),e.boundsTree=null,i&&e.dispose()}(n,o[t],g),l&&function joinGroups(e){for(let t=0;t<e.length-1;t++){const n=e[t],i=e[t+1];if(n.materialIndex===i.materialIndex){const r=n.start,s=i.start+i.count;i.start=r,i.count=s-r,e.splice(t,1),t--}}}(n.groups)})),r?i:i[0]}evaluateHierarchy(e,t=new Brush){e.updateMatrixWorld(!0);const flatTraverse=(e,t)=>{const n=e.children;for(let e=0,i=n.length;e<i;e++){const i=n[e];i.isOperationGroup?flatTraverse(i,t):t(i)}},traverse=e=>{const t=e.children;let n=!1;for(let e=0,i=t.length;e<i;e++){const i=t[e];n=traverse(i)||n}const i=e.isDirty();if(i&&e.markUpdated(),n&&!e.isOperationGroup){let t;return flatTraverse(e,(n=>{t=t?this.evaluate(t,n,n.operation):this.evaluate(e,n,n.operation)})),e._cachedGeometry=t.geometry,e._cachedMaterials=t.material,!0}return n||i};return traverse(e),t.geometry=e._cachedGeometry,t.material=e._cachedMaterials,t}reset(){this.triangleSplitter.reset()}}async function CSG(e,t,n=1){if(0!=n&&1!=n&&3!=n)throw new Error("Wrong CSG Operation");function groupToBrush(e){const t=[];e.updateMatrixWorld(!0),e.traverse((e=>{if(!e.isMesh)return;const n=e.geometry.clone();n.applyMatrix4(e.matrixWorld),t.push(n)}));const n=function mergeGeometries(e,t=!1){const n=null!==e[0].index,i=new Set(Object.keys(e[0].attributes)),r=new Set(Object.keys(e[0].morphAttributes)),s={},o={},a=e[0].morphTargetsRelative,A=new C;let l=0;for(let c=0;c<e.length;++c){const p=e[c];let h=0;if(n!==(null!==p.index))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(const e in p.attributes){if(!i.has(e))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+'. All geometries must have compatible attributes; make sure "'+e+'" attribute exists among all geometries, or in none of them.'),null;void 0===s[e]&&(s[e]=[]),s[e].push(p.attributes[e]),h++}if(h!==i.size)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". Make sure all geometries have the same number of attributes."),null;if(a!==p.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(const e in p.morphAttributes){if(!r.has(e))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". .morphAttributes must be consistent throughout all geometries."),null;void 0===o[e]&&(o[e]=[]),o[e].push(p.morphAttributes[e])}if(t){let e;if(n)e=p.index.count;else{if(void 0===p.attributes.position)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". The geometry must have either an index or a position attribute"),null;e=p.attributes.position.count}A.addGroup(l,e,c),l+=e}}if(n){let t=0;const n=[];for(let i=0;i<e.length;++i){const r=e[i].index;for(let e=0;e<r.count;++e)n.push(r.getX(e)+t);t+=e[i].attributes.position.count}A.setIndex(n)}for(const e in s){const t=mergeAttributes(s[e]);if(!t)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+e+" attribute."),null;A.setAttribute(e,t)}for(const e in o){const t=o[e][0].length;if(0===t)break;A.morphAttributes=A.morphAttributes||{},A.morphAttributes[e]=[];for(let n=0;n<t;++n){const t=[];for(let i=0;i<o[e].length;++i)t.push(o[e][i][n]);const i=mergeAttributes(t);if(!i)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+e+" morphAttribute."),null;A.morphAttributes[e].push(i)}}return A}(t,!1);return new Brush(n)}const i=groupToBrush(e),r=groupToBrush(t);return mergeVertices((new Evaluator).evaluate(i,r,n).geometry.clone(),1e-6)}async function runScript(t,n,i,r,s){let o=await t.getScript(n),a=o.script,A=[],l=function toCadPars(e){const t=muClComments(e),n=[];for(const e of t){const t=e.includes("(")||e.includes("[")?[e]:getcolonne(e,!0);let i=!1;for(const e of t)!e.startsWith('"')&&e.includes("=")?(n.push(e),i=!0):i&&(n[n.length-1]+=","+e)}const i={};for(const e of n){let{v:t,o:n}=getcouple(e,"=",!1);n=n||"",t&&(/^[-+]?\d*\.?\d+$/.test(n)&&(n=parseFloat(n)),i[t]=n)}return i}(o.pars+("string"==typeof r?"\n"+r:""));function setmatricola(e){return e?.userData&&(e.userData.mat=`${n}_${t.gmats[n]}`),e}r&&"object"==typeof r&&(l={...l,...r}),t.gmats[n]||(t.gmats[n]=0);let c=(new Date).valueOf(),p=c;try{function movimento(e,n=[]){return e=clean(e,!0),t.movs[e]||(t.movs[e]=getmovimento(e,n)),t.movs[e]}function addlog(...e){if(t?.islog){const t=e.map((e=>getOggetto(e)));console.log(...t),A.push(...t)}}function addwarning(e="msg",t=""){let n={lev:"w",cod:e,note:t};i.DB&&i.DB.push(n)}function dbadd(e,r,s,o={}){o||(o={}),t.gmats[n]++,"w"==e&&(e="l");let a=`${n}_${t.gmats[n]}`,{qt:A=1,l:l=0,a:c=0,p:p=0,vars:h="",tag:u,info:d,shape:g=null,model:f,lavs:m=null}=o;if(i.DB&&r){let t={lev:"string"==typeof e?clean(e,!0):"l"+(e+(i?._level??0)),mat:a,cod:r,note:s||"",qt:A,l:l,a:c,p:p,vars:h,tag:u,info:d};g&&(t.shape=g),m&&(t.lavs=m),f&&(t.model=f),i.DB.push(t)}return a}function getposfn(e,t){if(!(t.sl||t.sa||t.sp||t.scale||t.scx||t.scy||t.scz||t.ay||t.ax||t.az))return e;return transformfn(e,t)}function addtop(e,t,n={}){n||(n={});let r=getposfn(s,n);i.TOPS.push({key:e,shape:t,type:"top",op:n,posfn:r})}function addhole(e,t,n={}){n||(n={});let r=getposfn(s,n);i.TOPS.push({key:e,shape:t,type:"hole",op:n,posfn:r})}function addaltri(e,t={},n={}){n||(n={}),t={...t,...n};let r=getposfn(s,t);i.TOPS.push({key:e,data:t,type:"altri",posfn:r})}function addlines(e,t,n={}){if(n||(n={}),!t)return;Array.isArray(t)||(t=[t]);let r=getposfn(s,n);i.TOPS.push({key:e,lines:t,type:"lines",op:n,posfn:s,pn:r})}function dbdes(e,t){i.DES&&t&&i.DES.push({lev:e+(i?._level??0),description:t})}function geturltex(e){let n=t.cat;if(!e)return t.P.baseurl+"noimage.jpg";if(t.P._cdn){if(e.includes("/")){let t=e.split("/");n=t[0],e=t[1]}return e.endsWith(".webp")||e.endsWith(".png")||e.endsWith(".jpeg")||e.endsWith(".jpg")||(e+=".webp"),`${t.P._cdn}${n}/textures/${e}`}return t.P.fullget("mufiles/getfile",{id:n,subfolder:"textures",name:e})}l||(l={}),i||(i={});const h={GCAD:!0,...i,...l,THREE:e,TODEG:TODEG,TORAD:TORAD,dbadd:dbadd,addtop:addtop,addwarning:addwarning,addhole:addhole,addlines:addlines,addaltri:addaltri,dbdes:dbdes,posfn:s,ADD:0,SUB:1,INT:3,CSG:CSG,addpivot:(e,n,i={},r=0,s=0,o=0)=>setmatricola(addmovpivot(t,e,n,i,r,s,o)),movimento:movimento,Math:Math,facesettile:facesettile,info3d:t.info3d,round:round,gcad:t,SIDE:xi,seeder:seeder,seedarray:seedarray,baseurl:t.P.baseurl,Vis2d:Vis2d,joinlinestoshapes:joinlinestoshapes,groupfromgeometry:groupfromgeometry,creategroup:creategroup,deletegroup:deletegroup,Matrix3D:Matrix3D,geturltex:geturltex,clamp:clamp,Punto2:Punto2,Linea2:Linea2,getptsoffset:getptsoffset,hash:hash,PIF:ft,raccordabezier:raccordabezier,svuotanodo:svuotanodo,normal2:normal2,angle3point:angle3point,angle2vec:angle2vec,getshape:getshape,shapeclip:shapeclip,mgray1:vi,mgray2:Qi,mwhite:wi,mred:Pi,mgreen:Di,mblack:Li,mblue:Ti,materialline1:Bi,materialline2:Ei,scaleunit:_i,edgesfromgeometry:edgesfromgeometry,getmesh:getmesh,getcolonne:getcolonne,posiziona:posiziona,getbb:getbb,scalaoggetto:(e,n)=>scalaoggetto(t,e,n),setorigine:setorigine,SP:wt,elaborapercorso:elaborapercorso,gettarghetta:(e,n,i)=>gettarghetta(t,e,n,i),getquota:(e,n,i,r,s,o={})=>getquota(t,e,n,i,r,s,o),getsprite:(e,t,n,i,r)=>getsprite(0,e,t,n,i,r),getpunto:(e,n,i,r,s,o)=>getpunto(t,e,n,i,r,s),spritemat:e=>spritemat(t,e),getemitter:getemitter,getreceiver:e=>setmatricola(getreceiver(t,e)),getriferimento:getriferimento,get3dshape:get3dshape,getline:getline,getpoint:getpoint,randombasemat:randombasemat,infocircle:infocircle,intersectcircle:intersectcircle,creagizmo:creagizmo,linea3d:linea3d,texgen:(e,n=256,i={})=>texgen(t,e,n,i),getcilindro:(e,n,i,r,s=wi,o)=>setmatricola(getcilindro(t,e,n,i,r,s,o)),getbox:(e,t,n,i,r)=>setmatricola(getbox(0,e,t,n,i,r)),getsphere:(e,t,n)=>setmatricola(getsphere(0,e,t,n)),replacemats:t.replacemats,getluce:(e,n="#ffffff",i=1)=>getluce(t,e,n,i),getthorus:(e,t,n,i)=>setmatricola(getthorus(0,e,t,n,i)),getcyl:(e,t,n=wi,i)=>setmatricola(getcyl(0,e,t,n,i)),getpannello:(e,n,i,r,s,o,a)=>setmatricola(getpannello(t,e,n,i,r,s,o,a)),getpannello2:(e,n,i,r,s,o)=>setmatricola(getpannello2(t,e,n,i,r,s,o)),getface:(e,n,i,r)=>setmatricola(getface(t,e,n,i,r)),pickvariant:(e,n,i,r,s,o={})=>pickvariant(t,e,n,i,r,s,o),getmarker:(e,n,i,r,s,o={})=>getmarker(t,e,n,i,r,s,o),getglb:e=>setmatricola(t.getglb(e)),get3ds:(e,n=!1)=>setmatricola(t.get3ds(e,n)),getdims:(e,n)=>t.getdims(e,n),hidenodes:(e,n)=>t.hidenodes(e,n),estruso:(e,n,i,r,s,o)=>setmatricola(estruso(t,e,n,i,r,s,o)),getextrude:(e,n,i,r,s)=>setmatricola(getextrude(t,e,n,i,r,s)),estrusopat:(e,n,i,r,s,o)=>setmatricola(estrusopat(t,e,n,i,r,s,o)),infoestrudi:infoestrudi,getfakeshadow:(e,n)=>getfakeshadow(t,e,n),getfakeshadow2:getfakeshadow2,revolve:(e,n,i,r)=>setmatricola(revolve(t,e,n,i,r)),linemat:e=>async function linemat(e,t={}){t||(t={});let n=hash("lm"+JSON.stringify(t));return e.smats[n]||(e.smats[n]=new LineMaterial(t)),e.smats[n]}(t,e),smat:(e,n)=>smat(t,e,n),log:addlog,clean:clean,logtime:e=>{if(t?.islog){let t=(new Date).valueOf();addlog(`time: ${e} => ${t-p}ms / ${t-c}ms`),p=t}}},u=[...Object.keys(h),...Object.keys(mt)],d=[...Object.values(h),...Object.values(mt)],g=`//# sourceURL=${n}\n return (async () => {\n${a}\n })();`;try{let f=hash(n+JSON.stringify(Object.keys(l)));t.cacheFns[f]||(t.cacheFns[f]=new Function(...u,g));const m=t.cacheFns[f];return{res:await m(...d),LOGS:A}}catch(y){let b=await errorescript(`// errore\n async function script() {\n ${a}\n }`,y,n);t?.bus?.errore(b)}}catch(I){let x=I.stack?.toString()||I.message||"";x=x.replaceAll("\n\n","\n"),t?.bus?.errore(x),console.error(I)}}function rectsat(e,t){const n=(e.ang||0)*Math.PI/180,i=(t.ang||0)*Math.PI/180,r=Math.cos(n),s=Math.sin(n),o=Math.cos(i),a=Math.sin(i),A=e.x,l=e.z,c=t.x,p=t.z,h=e.posx||0,u=e.posz||0,d=t.posx||0,g=t.posz||0,f=[[h,u],[h+A*r,u+A*s],[h+A*r-l*s,u+A*s+l*r],[h-l*s,u+l*r]],m=[[d,g],[d+c*o,g+c*a],[d+c*o-p*a,g+c*a+p*o],[d-p*a,g+p*o]],y=[[f[1][0]-f[0][0],f[1][1]-f[0][1]],[f[3][0]-f[0][0],f[3][1]-f[0][1]],[m[1][0]-m[0][0],m[1][1]-m[0][1]],[m[3][0]-m[0][0],m[3][1]-m[0][1]]];for(let e=0;e<4;e++){const t=-y[e][1],n=y[e][0];let i=1/0,r=-1/0,s=1/0,o=-1/0;for(let e=0;e<4;e++){const a=f[e][0]*t+f[e][1]*n,A=m[e][0]*t+m[e][1]*n;a<i&&(i=a),a>r&&(r=a),A<s&&(s=A),A>o&&(o=A)}if(r<s||o<i)return!1}return!0}async function processatop(e,t,n){if(!t)return;let i=[],r=t.getObjectByName("_mtop");if(r)for(;r.children.length>0;)r.remove(r.children[0]);else r=creategroup("_mtop"),t.add(r);for(let e of n)e?.key?.includes("<")&&(e.key=e.key.replace(/<sl>/gi,e?.posfn?.sl??0).replace(/<sa>/gi,e?.posfn?.sa??0).replace(/<sp>/gi,e?.posfn?.sp??0).replace(/<ay>/gi,e?.posfn?.ay??0));let s=new Date;const uk=e=>`${e.key}|${Math.round(((e.ang||0)+180)%180)/5}|${e.pos.y}`;let o=shapeclip();const a=[...new Set(n.filter((e=>"top"==e.type)).map(uk))];let A=[],l=0;for(let t of a){let s=n.filter((e=>"top"==e.type&&uk(e)===t));if(s.length){let t=s[0],a=n.filter((e=>"hole"==e.type&&e.key==t.key)),c=[],p=[],h=[];for(let e of s)c.push(e.shape.clone().rotate(-e.ang).move(e.pos.x,e.pos.z));let u=[];for(let e of a){let t=e.op.ptrif,n=e.op.ptapplica,i=e.shape.dims();t=t?[i.p1,...t]:[i.p1,i.p2],n||(n=i.p1);let r=e.shape.clone().rotate(-e.ang).move(e.pos.x,e.pos.z),s=getshape().frompt(t).rotate(-e.ang).move(e.pos.x,e.pos.z);u.push({pt:s.pt,shape:r,op:e.op,width:i.width,height:i.height}),e.op?.hidden||p.push(r)}let d,g=o.unisci(c,p,h);for(let t of g){let n=s[0],o=t.shape.rebase(-n.ang),a=t.shape.dims(),c=getshape().fromrect(a.width,a.height,a.p1.x,a.p1.y);o.holes=[],o.cuts=[];for(let e of t.holes)o.holes.push(e.rebase(-n.ang,!0,o.origine.x,o.origine.y));const to2dec=e=>Math.round(100*(Number(e)||0))/100;let p=u.map((e=>{let t=getshape().frompt(e.pt),{shape:i}=t.rebase(-n.ang,!0,o.origine.x,o.origine.y);return{op:e.op,pt:i.pt,px:to2dec(i.pt[0].x),py:to2dec(i.pt[0].y),dx:to2dec(e.width),dy:to2dec(e.height)}})),h=p.filter((e=>{for(let t of e.pt)if(c.pointinshape(t))return!0;return!1}));h.forEach((e=>delete e.pt));let g=[];await runScript(e,"_ricalcolatop",{SHAPES:i,BOX:g,DB:A,TOPS:[],_level:800,processatop:{top:o,base:n,lavs:h,idt:l}},{}),l++;for(let e of g)d=posiziona(posiziona(e,{sa:n.pos.y||0,sl:o.origine.x,sp:o.origine.y}),{ay:n.ang}),r.add(d)}}}let c=new Date,p=n.filter((e=>"altri"==e.type)),h=p.filter((e=>e.data?.fuse));p=p.filter((e=>!e.data?.fuse));let u=function dofuse(e){const uk=e=>`${e.key}|${e.pos.y}`,t=[...new Set(e.map(uk))];let n=[];for(let i of t){let t=e.filter((e=>uk(e)==i)),r=new Array(t.length).fill(!1);for(let e=0;e<t.length;e++){if(r[e])continue;let i=[e],s=[];for(r[e]=!0;i.length;){let e=t[i.pop()];s.push(e);for(let n=0;n<t.length;n++){if(r[n])continue;let s=t[n];rectsat({x:e.data?.l||10,z:e.data?.p||10,ang:e.ang,posx:e.pos.x,posz:e.pos.z},{x:e.data?.l||10,z:e.data?.p||10,ang:s.ang,posx:s.pos.x,posz:s.pos.z})&&(r[n]=!0,i.push(n))}}n.push(s)}}return n}(h),d=new Date,g=[],f=await runScript(e,"_ricalcolaaltri",{SHAPES:i,BOX:g,DB:A,TOPS:[],_level:800,processatop:{altri:p,fused:u,idt:l}},{});f>l&&(l=f),l++;for(let e of g)r.add(e);let m=new Date;const uk1=e=>`${e.key}|${e.pos.y}`,y=n.filter((e=>"lines"==e.type)),b=[...new Set(y.map(uk1))];for(let t of b){const n=y.filter((e=>uk1(e)===t)),r=joinlinestoshapes(n);for(let s of r){let r={sh:s,key:t,data:n[0].op||{},idt:l};await runScript(e,"_ricalcolalinee",{SHAPES:i,BOX:g,DB:A,TOPS:[],_level:800,processatop:r,idt:l},{})}l++}for(let e of g)r.add(e);let I=new Date;return console.log("rictop",c-s,d-c,m-d,I-m,"tot",I-s),{DB:A,SHAPES:i}}function dumpscene(e,t={}){const{maxdepth:n=1/0}=t,r3=e=>Math.round(1e3*e)/1e3;function layerMaskToString(e){let t="";for(let n=0;n<32;n++)t=(e&1<<n?"x":"_")+t;return t}function filterUserData(e){if(!e)return{};const t={};for(const n in e){const i=e[n];if(null==i)continue;const r=typeof i;"string"!==r&&"number"!==r&&"boolean"!==r||(t[n]=i)}return t}return function scan(e,t=0){if(!e||t>n)return null;const i={type:e.type,name:e.name||"",layer:layerMaskToString(e.layers?.mask??0),userData:filterUserData(e.userData)};if(e.position&&function sigPos(e){return 0!==e.x||0!==e.y||0!==e.z}(e.position)&&(i.position={x:r3(e.position.x),y:r3(e.position.y),z:r3(e.position.z)}),e.rotation&&function sigRot(e){return 0!==e.x||0!==e.y||0!==e.z}(e.rotation)&&(i.rotation={x:r3(e.rotation.x),y:r3(e.rotation.y),z:r3(e.rotation.z)}),e.scale&&function sigScale(e){return 1!==e.x||1!==e.y||1!==e.z}(e.scale)&&(i.scale={x:r3(e.scale.x),y:r3(e.scale.y),z:r3(e.scale.z)}),e.isMesh&&e.geometry){i.geometry={type:e.geometry.type};const t=e.geometry.parameters;if(t)for(const e in t){const n=t[e];"number"==typeof n&&(i.geometry[e]=r3(n))}}return e.material&&(Array.isArray(e.material)?i.material=e.material.map((e=>e.type||e.name||"Material")):i.material=e.material.type||e.material.name||"Material"),e.children?.length&&(i.children=e.children.map((e=>scan(e,t+1))).filter(Boolean)),i}(e,0)}function neutralize(e,t){const n=e.parent,i=e.position.clone(),r=e.rotation.clone(),s=e.scale.clone();n?.remove(e),e.position.set(0,0,0),e.rotation.set(0,0,0),e.scale.set(1,1,1),e.updateMatrixWorld(!0),t&&t(e),e.position.copy(i),e.rotation.copy(r),e.scale.copy(s),n?.add(e),e.updateMatrixWorld(!0)}function traversehide(e,t,n=!1){e&&t?.length&&function visita(e){if(e.isGroup){if(e.userData?.markkey&&t.includes(e.userData?.markkey))return void(e.visible=n);for(const t of e.children)visita(t)}}(e)}async function processamarker(t){const n=new Map;function trovagenitorerif(e){for(;e&&!e.userData?.rifid;)e=e.parent;return e}neutralize(t,(function traverse(i){if(i.userData?.markerid)n.set(i.userData.markerid,i);else if(i.name?.startsWith("#mk_")){const r=i.name,s=n.get(r);if(!s)return void t.remove(i);{s.updateMatrixWorld(!0),i.updateMatrixWorld(!0);const t=i,n=trovagenitorerif(s)||s,r=trovagenitorerif(t)||t;if(!n||!r)return;n.updateMatrixWorld(!0),r.updateMatrixWorld(!0),t.updateMatrixWorld(!0);let o=s.matrixWorld.clone();const a=t.matrixWorld.clone(),A=r.matrixWorld.clone(),l=s.userData?.origin||0;if(0!==l){let n=function getlap(t){if(!t)return;const n=new e.Box3;t.updateWorldMatrix(!0,!0),function visita(e){if(!(e.userData?.ignoreTraverse||e.userData?.hideable||e.userData?.noingombro||!1===e.visible)){(e.isMesh||e.isLine||e.isLine2)&&n.expandByObject(e);for(const t of e.children)visita(t)}}(t);const i=new e.Vector3;return n.getSize(i),{l:i.x,a:i.y,p:i.z}}(t);if(n){const{l:i,a:r,p:s}=n;let a=0,A=0,c=0;if(l<10)a=1&l?i:0,A=2&l?r:0,c=4&l?s:0;else if(l>100){let e=l-100;const t=e%3,n=Math.floor(e/3)%3,o=Math.floor(e/9);a=0===t?0:1===t?i/2:i,A=0===n?0:1===n?r/2:r,c=0===o?0:1===o?s/2:s}const p=new e.Vector3(a,A,c),h=new e.Vector3(0,0,0).applyMatrix4(t.matrixWorld),u=p.clone().applyMatrix4(t.matrixWorld).sub(h),d=(new e.Vector3).setFromMatrixPosition(o).sub(u);o=(new e.Matrix4).setPosition(d).multiply((new e.Matrix4).extractRotation(o))}}const c=A.clone().invert().multiply(a),p=o.clone().multiply(c.clone().invert()),h=r.parent,u=(h?h.matrixWorld:new e.Matrix4).clone().invert().multiply(p),d=new e.Vector3,g=new e.Quaternion,f=new e.Vector3;if(u.decompose(d,g,f),r.position.copy(d),r.quaternion.copy(g),r.scale.copy(f),r.updateMatrixWorld(!0),s.visible=!1,s.userData.markdel){let e=s.userData.markdel.split(";");e&&e.length&&(traversehide(n.parent,e),traversehide(r,e))}}}for(const e of[...i.children])traverse(e)}))}async function processagruppo(e,t,n){n||(n=t),Object.assign(n.userData,{SHAPES:[],DB:[],TOPS:[]});for(let i of n.userData.INFO.rows)if("fn"==i?.t){let r=creategroup(),s=[];await runScript(e,i.fn,{BOX:s,SHAPES:t.userData.SHAPES,DB:n.userData.DB,TOPS:n.userData.TOPS,_level:n.userData._level},i.pars,i.p2),s.length&&(s.forEach((e=>r.add(e))),Object.keys(i.p2).length&&(r=posiziona(r,i.p2)),t.add(r))}else if(i?.rows&&i.rows.length){let n=creategroup();i.iscad&&(n=posiziona(n,i.cadv)),n.name=i.id,Object.assign(n.userData,{INFO:i,_level:t.userData._level+1});let r=n;n.children[0]&&n.children[0].userData.ismove&&(r=n.children[0]),i.cadv?.move?.annulla||await processagruppo(e,r,n),t.add(n)}}function getalldb(t,n){let i=[],r=[],s=[];return t&&neutralize(t,(function doit(t){t.traverse((t=>{let n=t;if(1==t.children?.length&&t.children[0].userData?.ismove&&(n=t.children[0]),!n.userData?.ismove||!n.userData.move?.annulla){if(t.userData?.DB&&Array.isArray(t.userData.DB)&&i.push(...t.userData.DB),t.userData?.TOPS&&t.userData.TOPS.length){n.updateMatrixWorld(!0);let i=new e.Vector3;n.getWorldPosition(i);let s=new e.Quaternion;n.getWorldQuaternion(s);let o=(new e.Euler).setFromQuaternion(s,"YXZ"),a=e.MathUtils.radToDeg(o.y);for(let n of t.userData.TOPS){let{sl:t=0,sa:s=0,sp:o=0,ay:A=0}=n.posfn||{};if(t||s||o||A){let l=e.MathUtils.degToRad(a),c=Math.cos(l),p=Math.sin(l),h=t*c-o*p,u=-(t*p+o*c),d=new e.Vector3(i.x+h,i.y+s,i.z+u),g=a+A;r.push({...n,pos:d,ang:g})}else r.push({...n,pos:i.clone(),ang:a})}}t.userData?.SHAPES&&Array.isArray(t.userData.SHAPES)&&t.userData.SHAPES.forEach((e=>{let t=e?.tojson();s.push(t)}))}}))})),n&&(n.DB=i,n.TOPS=r,s=s.filter((e=>e.visible)),n.SHAPES=s),{DB:i,TOPS:r,SHAPES:s}}async function evalcustomfunction(e,t,n,i){try{n||(n={}),i||(i={});const r={GCAD:!1,Vis2d:!1,...n,A:e,V:e.vari,amb:e,info3d:async function info3d(t,n=1,i=0,r=0){if(e.gcad)return await e.gcad.info3d(t,n,i,r)},gcad:e.gcad,log:function addlog(...e){const t=e.map((e=>getOggetto(e)));console.log(...t)},Math:Math,getcolonne:getcolonne,clean:clean,SP:wt,seeder:seeder,seedarray:seedarray,Punto2:Punto2,Linea2:Linea2,clamp:clamp,hash:hash,PIF:ft,getshape:getshape,shapeclip:shapeclip,...i},s=[...Object.keys(r),...Object.keys(mt)],o=[...Object.values(r),...Object.values(mt)],a=new Function(...s,`\n try {\n return (async () => {\n ${t}\n })();\n } catch (err) {\n err.stack = '[SCRIPT] ' + err.stack;\n throw err;\n }`);return await a(...o)}catch(e){throw console.error("Errore durante l'esecuzione:",e),e}}function setLineColorMode(e,t){e?(Bi.color.set(16777215),Ei.color.set(16777215)):t?(Bi.color.set(2501422),Ei.color.set(8421504)):(Bi.color.set(6316128),Ei.color.set(8421504)),Bi.needsUpdate=!0,Ei.needsUpdate=!0}export{Linea2,Matrix3D,ft as PIF,Punto2,xi as SIDE,wt as SP,TODEG,TORAD,Vis2d,Vobject,Vscene,addmovpivot,angle2vec,angle3point,mt as blocked,calcolatasks,checkmovedata,clamp,clean,compattadistinta,creagizmo,creategroup,d3dview,deletegroup,dumpscene,dxfbulge,edgesfromgeometry,elaborapercorso,errorescript,estruso,estrusopat,evalcustomfunction,evidenziaColli,exportdxf,extractTextures,facesettile,get3dshape,getOggetto,getalldb,getbb,getbordi,getbox,getcilindro,getcyl,getdettvarstampa,getdumpmacro,getemitter,getextrude,getface,getfakeshadow,getfakeshadow2,getgalleryvariants,getline,getlinesgeom,getluce,getmarker,getmesh,getmovimento,getnodebyid,getpannello,getpannello2,getpoint,getptsoffset,getpunto,getquota,getreceiver,getriferimento,getshape,getsphere,getsprite,getsubrules,gettarghetta,getthorus,groupfromgeometry,hash,infocircle,infoestrudi,intersectcircle,isfn,ismacro,joinlinestoshapes,konvautils,mapvertices,Bi as materialline1,Ei as materialline2,Li as mblack,Ti as mblue,vi as mgray1,Qi as mgray2,Di as mgreen,Pi as mred,wi as mwhite,newgcad,normal2,pickvariant,posiziona,processagruppo,processamarker,processatop,raccordabezier,randombasemat,revolve,ripristinaMaterialiOriginali,round,runScript,salvaMaterialiOriginali,scalaoggetto,_i as scaleunit,seedarray,seeder,setLineColorMode,setorigine,shapeclip,smat,spritemat,svuotanodo,texgen,transformfn,valutagrafica};
|
|
1
|
+
import*as e from"three";import{ShaderMaterial as t,ShaderLib as n,UniformsUtils as i,Vector2 as r,UniformsLib as s,InstancedBufferGeometry as o,Float32BufferAttribute as a,InstancedInterleavedBuffer as A,InterleavedBufferAttribute as l,WireframeGeometry as c,Box3 as p,Sphere as h,Vector3 as u,Mesh as d,Vector4 as g,Line3 as f,Matrix4 as m,MathUtils as y,TrianglesDrawMode as b,TriangleFanDrawMode as I,TriangleStripDrawMode as x,BufferGeometry as C,BufferAttribute as B,Loader as E,LoaderUtils as w,FileLoader as v,MeshPhysicalMaterial as P,Color as T,LinearSRGBColorSpace as S,SRGBColorSpace as M,SpotLight as D,PointLight as L,DirectionalLight as _,Quaternion as F,InstancedMesh as k,InstancedBufferAttribute as R,Object3D as N,TextureLoader as O,ImageBitmapLoader as G,InterleavedBuffer as U,LinearMipmapLinearFilter as Y,NearestMipmapLinearFilter as z,LinearMipmapNearestFilter as H,NearestMipmapNearestFilter as X,LinearFilter as q,NearestFilter as j,RepeatWrapping as W,MirroredRepeatWrapping as J,ClampToEdgeWrapping as V,PointsMaterial as K,Material as Z,LineBasicMaterial as $,MeshStandardMaterial as ee,DoubleSide as te,MeshBasicMaterial as ne,PropertyBinding as ie,SkinnedMesh as re,LineSegments as se,Line as oe,LineLoop as ae,Points as Ae,Group as le,PerspectiveCamera as ce,OrthographicCamera as pe,Skeleton as he,AnimationClip as ue,Bone as de,InterpolateDiscrete as ge,InterpolateLinear as fe,Texture as me,VectorKeyframeTrack as ye,NumberKeyframeTrack as be,QuaternionKeyframeTrack as Ie,ColorManagement as xe,FrontSide as Ce,Interpolant as Be,CompressedCubeTexture as Ee,CompressedArrayTexture as we,CompressedTexture as ve,NoColorSpace as Qe,RGBA_PVRTC_2BPPV1_Format as Pe,RGBA_PVRTC_4BPPV1_Format as Te,RGBA_BPTC_Format as Se,RED_GREEN_RGTC2_Format as Me,SIGNED_RED_GREEN_RGTC2_Format as De,RED_RGTC1_Format as Le,SIGNED_RED_RGTC1_Format as _e,RGBA_S3TC_DXT3_Format as Fe,RGB_S3TC_DXT1_Format as ke,RGBA_S3TC_DXT1_Format as Re,RGBA_ASTC_6x6_Format as Ne,RGBA_ASTC_4x4_Format as Oe,SIGNED_RG11_EAC_Format as Ge,RG11_EAC_Format as Ue,SIGNED_R11_EAC_Format as Ye,R11_EAC_Format as ze,RGB_ETC2_Format as He,RGBA_ETC2_EAC_Format as Xe,RGBFormat as qe,RedFormat as je,RGFormat as We,RGBAFormat as Je,UnsignedByteType as Ve,HalfFloatType as Ke,UnsignedInt101111Type as Ze,UnsignedInt5999Type as $e,FloatType as et,DataTexture as tt,Data3DTexture as nt,RGB_PVRTC_4BPPV1_Format as it,RGB_ETC1_Format as rt,RGBA_S3TC_DXT5_Format as st,RGB_BPTC_UNSIGNED_Format as ot,MeshPhongMaterial as at,AdditiveBlending as At,Plane as lt,Triangle as ct,BackSide as pt,REVISION as ht,Ray as ut,Matrix3 as dt}from"three";class Matrix3D{constructor(){this.m=new Float32Array(16),this.st=[],this.init()}init(){return this.m.fill(0),this.m[0]=this.m[5]=this.m[10]=this.m[15]=1,this}atranslate(e,t,n){return this.m[12]+=e,this.m[13]+=t,this.m[14]+=n,this}translate(e,t,n){return e??=0,t??=0,n??=0,this.m[12]+=e*this.m[0]+t*this.m[4]+n*this.m[8],this.m[13]+=e*this.m[1]+t*this.m[5]+n*this.m[9],this.m[14]+=e*this.m[2]+t*this.m[6]+n*this.m[10],this.m[15]+=e*this.m[3]+t*this.m[7]+n*this.m[11],this}rotateX(e){if(e){const t=(e||0)*Math.PI/180,n=Math.sin(t),i=Math.cos(t),r=[...this.m];this.m[1]=r[1]*i+r[9]*n,this.m[2]=r[2]*i+r[10]*n,this.m[3]=r[3]*i+r[11]*n,this.m[9]=r[1]*-n+r[9]*i,this.m[10]=r[2]*-n+r[10]*i,this.m[11]=r[3]*-n+r[11]*i}return this}rotateY(e){if(e){const t=(e||0)*Math.PI/180,n=Math.sin(t),i=Math.cos(t),r=[...this.m];this.m[0]=r[0]*i+r[8]*n,this.m[1]=r[1]*i+r[9]*n,this.m[2]=r[2]*i+r[10]*n,this.m[3]=r[3]*i+r[11]*n,this.m[8]=r[0]*-n+r[8]*i,this.m[9]=r[1]*-n+r[9]*i,this.m[10]=r[2]*-n+r[10]*i,this.m[11]=r[3]*-n+r[11]*i}return this}rotateZ(e){if(e){const t=(e||0)*Math.PI/180,n=Math.sin(t),i=Math.cos(t),r=[...this.m];this.m[0]=r[0]*i+r[4]*n,this.m[1]=r[1]*i+r[5]*n,this.m[2]=r[2]*i+r[6]*n,this.m[3]=r[3]*i+r[7]*n,this.m[4]=r[0]*-n+r[4]*i,this.m[5]=r[1]*-n+r[5]*i,this.m[6]=r[2]*-n+r[6]*i,this.m[7]=r[3]*-n+r[7]*i}return this}getdati(){return Array.from(this.m)}setdati(e){if(e&&16===e.length){for(let t=0;t<16;t++)this.m[t]=Number(e[t])||0;return this}this.init()}push(){return this.st.push(new Float32Array(this.m)),this}pop(){return this.st.length>0&&(this.m=this.st.pop()),this}transform(e,t,n=0){return{x:e*this.m[0]+t*this.m[4]+n*this.m[8]+this.m[12],y:e*this.m[1]+t*this.m[5]+n*this.m[9]+this.m[13],z:e*this.m[2]+t*this.m[6]+n*this.m[10]+this.m[14]}}invert(){const e=this.m,t=new Matrix3D,n=this.determinant();return Math.abs(n)<1e-8?null:(t.m[0]=(e[5]*e[10]*e[15]+e[9]*e[14]*e[7]+e[13]*e[6]*e[11]-e[5]*e[14]*e[11]-e[9]*e[6]*e[15]-e[13]*e[10]*e[7])/n,t.m[1]=(e[1]*e[14]*e[11]+e[9]*e[2]*e[15]+e[13]*e[10]*e[3]-e[1]*e[10]*e[15]-e[9]*e[14]*e[3]-e[13]*e[2]*e[11])/n,t.m[2]=(e[1]*e[6]*e[15]+e[5]*e[14]*e[3]+e[13]*e[2]*e[7]-e[1]*e[14]*e[7]-e[5]*e[2]*e[15]-e[13]*e[6]*e[3])/n,t.m[3]=(e[1]*e[10]*e[7]+e[5]*e[2]*e[11]+e[9]*e[6]*e[3]-e[1]*e[6]*e[11]-e[5]*e[10]*e[3]-e[9]*e[2]*e[7])/n,t.m[4]=(e[4]*e[14]*e[11]+e[8]*e[6]*e[15]+e[12]*e[10]*e[7]-e[4]*e[10]*e[15]-e[8]*e[14]*e[7]-e[12]*e[6]*e[11])/n,t.m[5]=(e[0]*e[10]*e[15]+e[8]*e[14]*e[3]+e[12]*e[2]*e[11]-e[0]*e[14]*e[11]-e[8]*e[2]*e[15]-e[12]*e[10]*e[3])/n,t.m[6]=(e[0]*e[14]*e[7]+e[4]*e[2]*e[15]+e[12]*e[6]*e[3]-e[0]*e[6]*e[15]-e[4]*e[14]*e[3]-e[12]*e[2]*e[7])/n,t.m[7]=(e[0]*e[6]*e[11]+e[4]*e[10]*e[3]+e[8]*e[2]*e[7]-e[0]*e[10]*e[7]-e[4]*e[2]*e[11]-e[8]*e[6]*e[3])/n,t.m[8]=(e[4]*e[9]*e[15]+e[8]*e[13]*e[7]+e[12]*e[5]*e[11]-e[4]*e[13]*e[11]-e[8]*e[5]*e[15]-e[12]*e[9]*e[7])/n,t.m[9]=(e[0]*e[13]*e[11]+e[8]*e[1]*e[15]+e[12]*e[9]*e[3]-e[0]*e[9]*e[15]-e[8]*e[13]*e[3]-e[12]*e[1]*e[11])/n,t.m[10]=(e[0]*e[5]*e[15]+e[4]*e[13]*e[3]+e[12]*e[1]*e[7]-e[0]*e[13]*e[7]-e[4]*e[1]*e[15]-e[12]*e[5]*e[3])/n,t.m[11]=(e[0]*e[9]*e[7]+e[4]*e[1]*e[11]+e[8]*e[5]*e[3]-e[0]*e[5]*e[11]-e[4]*e[9]*e[3]-e[8]*e[1]*e[7])/n,t.m[12]=(e[4]*e[13]*e[10]+e[8]*e[5]*e[14]+e[12]*e[9]*e[6]-e[4]*e[9]*e[14]-e[8]*e[13]*e[6]-e[12]*e[5]*e[10])/n,t.m[13]=(e[0]*e[9]*e[14]+e[8]*e[13]*e[2]+e[12]*e[1]*e[10]-e[0]*e[13]*e[10]-e[8]*e[1]*e[14]-e[12]*e[9]*e[2])/n,t.m[14]=(e[0]*e[13]*e[6]+e[4]*e[1]*e[14]+e[12]*e[5]*e[2]-e[0]*e[5]*e[14]-e[4]*e[13]*e[2]-e[12]*e[1]*e[6])/n,t.m[15]=(e[0]*e[5]*e[10]+e[4]*e[9]*e[2]+e[8]*e[1]*e[6]-e[0]*e[9]*e[6]-e[4]*e[1]*e[10]-e[8]*e[5]*e[2])/n,t)}determinant(){const e=this.m;return e[0]*(e[5]*e[10]*e[15]+e[9]*e[14]*e[7]+e[13]*e[6]*e[11]-e[5]*e[14]*e[11]-e[9]*e[6]*e[15]-e[13]*e[10]*e[7])-e[4]*(e[1]*e[10]*e[15]+e[9]*e[14]*e[3]+e[13]*e[2]*e[11]-e[1]*e[14]*e[11]-e[9]*e[2]*e[15]-e[13]*e[10]*e[3])+e[8]*(e[1]*e[6]*e[15]+e[5]*e[14]*e[3]+e[13]*e[2]*e[7]-e[1]*e[14]*e[7]-e[5]*e[2]*e[15]-e[13]*e[6]*e[3])-e[12]*(e[1]*e[6]*e[11]+e[5]*e[10]*e[3]+e[9]*e[2]*e[7]-e[1]*e[10]*e[7]-e[5]*e[2]*e[11]-e[9]*e[6]*e[3])}multiply(e){const t=[...this.m],n=e.m;return this.m[0]=t[0]*n[0]+t[4]*n[1]+t[8]*n[2]+t[12]*n[3],this.m[1]=t[1]*n[0]+t[5]*n[1]+t[9]*n[2]+t[13]*n[3],this.m[2]=t[2]*n[0]+t[6]*n[1]+t[10]*n[2]+t[14]*n[3],this.m[3]=t[3]*n[0]+t[7]*n[1]+t[11]*n[2]+t[15]*n[3],this.m[4]=t[0]*n[4]+t[4]*n[5]+t[8]*n[6]+t[12]*n[7],this.m[5]=t[1]*n[4]+t[5]*n[5]+t[9]*n[6]+t[13]*n[7],this.m[6]=t[2]*n[4]+t[6]*n[5]+t[10]*n[6]+t[14]*n[7],this.m[7]=t[3]*n[4]+t[7]*n[5]+t[11]*n[6]+t[15]*n[7],this.m[8]=t[0]*n[8]+t[4]*n[9]+t[8]*n[10]+t[12]*n[11],this.m[9]=t[1]*n[8]+t[5]*n[9]+t[9]*n[10]+t[13]*n[11],this.m[10]=t[2]*n[8]+t[6]*n[9]+t[10]*n[10]+t[14]*n[11],this.m[11]=t[3]*n[8]+t[7]*n[9]+t[11]*n[10]+t[15]*n[11],this.m[12]=t[0]*n[12]+t[4]*n[13]+t[8]*n[14]+t[12]*n[15],this.m[13]=t[1]*n[12]+t[5]*n[13]+t[9]*n[14]+t[13]*n[15],this.m[14]=t[2]*n[12]+t[6]*n[13]+t[10]*n[14]+t[14]*n[15],this.m[15]=t[3]*n[12]+t[7]*n[13]+t[11]*n[14]+t[15]*n[15],this}}const gt=.001;class Punto2{constructor(e,t){Array.isArray(e)?(this.x=e[0]||0,this.y=e[1]||0):e&&"object"==typeof e?(this.x=e.x||0,this.y=e.y||0):(this.x=e||0,this.y=t||0)}get dump(){return`{${this.x.toFixed(1)},${this.y.toFixed(1)}}`}get len2(){return this.x*this.x+this.y*this.y}get len(){return Math.sqrt(this.len2)}get angle(){return Math.atan2(this.y,this.x)}dir(){let e=this.len;return e?new Punto2(this.x/e,this.y/e):this}puntosucerchio(e=0,t=0){const n=t*Math.PI/180;return new Punto2(this.x+e*Math.cos(n),this.y+e*Math.sin(n))}tangentesucerchio(e=0,t=0,n=100){const i=t*Math.PI/180,r=this.x+e*Math.cos(i),s=this.y+e*Math.sin(i),o=i+Math.PI/2,a=r+n*Math.cos(o),A=s+n*Math.sin(o);return new Linea2(r,s,a,A)}angolo3p(e,t){let n=this;const i=e.x-n.x,r=e.y-n.y,s=t.x-n.x,o=t.y-n.y,a=i*s+r*o,A=Math.hypot(i,r),l=Math.hypot(s,o);if(!A||!l)return 0;let c=180*Math.acos(a/(A*l))/Math.PI;return c>180&&(c=360-c),c}distanza(e){return new Punto2(e.x-this.x,e.y-this.y).len}}class Linea2{constructor(e,t,n=null,i=null){"number"==typeof e&&"number"==typeof t&&null!==n&&null!==i?(this.p1=new Punto2({x:e,y:t}),this.p2=new Punto2({x:n,y:i})):e&&t?(this.p1=new Punto2(e),this.p2=new Punto2(t)):(this.p1=new Punto2(0,0),this.p2=new Punto2(1,0))}get dump(){return`${this.p1.dump}-${this.p2.dump}`}get dx(){return this.p2.x-this.p1.x}get dy(){return this.p2.y-this.p1.y}get len2(){let{dx:e,dy:t}=this;return e*e+t*t}get len(){return Math.sqrt(this.len2)}get angle(){return this.angolo()}estendi(e){if("number"==typeof e){if(!e)return this;let{p1:t,p2:n,dx:i,dy:r,len:s}=this;return s?(i/=s,r/=s,e>0?new Linea2(t,new Punto2(n.x+i*e,n.y+r*e)):new Linea2(new Punto2(t.x+i*e,t.y+r*e),n)):this}if(e instanceof Linea2){const t=this.interseca(e);if(!t)return this;return(t.x-this.p1.x)**2+(t.y-this.p1.y)**2<(t.x-this.p2.x)**2+(t.y-this.p2.y)**2?new Linea2(t,this.p2):new Linea2(this.p1,t)}}puntot(e){return new Punto2(this.p1.x+(this.p2.x-this.p1.x)*e,this.p1.y+(this.p2.y-this.p1.y)*e)}setlunghezza(e){let t=this.len;if(t&&e){let n=e/t,i=this.puntot(n);this.p2=i}}proiezionet(e){const{p1:t,dx:n,dy:i,len2:r}=this;if(r<gt)return;const s=((e.x-t.x)*n+(e.y-t.y)*i)/r;return{p:new Punto2(t.x+s*n,t.y+s*i),t:s}}proiezione(e){const t=this.proiezionet(e);return t?t.p:void 0}get direzione(){let{dx:e,dy:t,len:n}=this;return n?new Punto2(e/n,t/n):new Punto2(0,0)}get normale(){let{dx:e,dy:t,len:n}=this;return n?new Punto2(-t/n,e/n):new Punto2(0,1)}perpendicolare(e=null,t=0){const{normale:n,len:i,p1:r}=this;if(i<1e-9)return;const s=t||i,o=e?new Punto2(e):this.p1;return new Linea2(o,new Punto2(o.x+n.x*s,o.y+n.y*s))}perpendicolaret(e,t=0){const{normale:n,len:i,p1:r,p2:s}=this;if(i<1e-9)return;const o=t||i,a=new Punto2(r.x+(s.x-r.x)*e,r.y+(s.y-r.y)*e);return new Linea2(a,new Punto2(a.x+n.x*o,a.y+n.y*o))}rotatedonp1(e){const t=e*Math.PI/180,n=this.p2.x-this.p1.x,i=this.p2.y-this.p1.y,r=Math.cos(t),s=Math.sin(t),o=this.p1.x+n*r-i*s,a=this.p1.y+n*s+i*r;return new Linea2(this.p1,{x:o,y:a})}rotatedonp2(e){const t=e*Math.PI/180,n=this.p1.x-this.p2.x,i=this.p1.y-this.p2.y,r=Math.cos(t),s=Math.sin(t),o=this.p2.x+n*r-i*s,a=this.p2.y+n*s+i*r;return new Linea2(this.p2,{x:o,y:a})}ruotata(e=Math.PI/2,t=0,n=!1){const{p1:i,p2:r,direzione:s,len:o}=this;if(t=t||o,o<1e-9)return;const a=Math.abs(e%(2*Math.PI));if(!(a<1e-9||Math.abs(a-Math.PI)<1e-9)){if("boolean"==typeof n){const o=(s.x*Math.cos(e)-s.y*Math.sin(e))*t,a=(s.x*Math.sin(e)+s.y*Math.cos(e))*t;return n?new Linea2(i,new Punto2(i.x+o,i.y+a)):new Linea2(r,new Punto2(r.x+o,r.y+a))}{let i=new Punto2(n);const r=s.x*Math.cos(e)-s.y*Math.sin(e),o=s.x*Math.sin(e)+s.y*Math.cos(e);new Punto2(r,o);const a=new Linea2(i,new Punto2(i.x+r,i.y+o)),A=this.interseca(a);if(!A)return;const l=new Punto2(A.x+r*t,A.y+o*t);return new Linea2(A,l)}}}puntosudirezione(e,t){let{direzione:n}=this;return new Punto2(e.x+n.x*t,e.y+n.y*t)}parallela(e,t){let{direzione:n}=this;return new Linea2(e,this.puntosudirezione(e,t))}intersezione(e){return this.interseca(e)}interseca(e){const{p1:t,p2:n}=this,{p1:i,p2:r}=e,s=(n.x-t.x)*(r.y-i.y)-(n.y-t.y)*(r.x-i.x);if(Math.abs(s)<gt)return null;const o=((i.x-t.x)*(r.y-i.y)-(i.y-t.y)*(r.x-i.x))/s;return new Punto2(t.x+o*(n.x-t.x),t.y+o*(n.y-t.y))}onsegment(e,t=1e-9){const{p1:n,p2:i}=this,r=i.x-n.x,s=i.y-n.y,o=e.x-n.x,a=e.y-n.y;if(Math.abs(r*a-s*o)>t)return!1;const A=o*r+a*s;if(A<-t)return!1;return!(A>r*r+s*s+t)}distanzaPunto(e){const t=this.proiezione(e);if(!t)return 1e9;const n=e.x-t.x,i=e.y-t.y;return Math.hypot(n,i)}isparallela(e){const t=this.dx*e.dy-this.dy*e.dx;return Math.abs(t)<1}lunghezzatotale(e){const t=this.p2.x-this.p1.x,n=this.p2.y-this.p1.y,i=Math.hypot(t,n);if(!i)return 0;const r=1/i,proj=e=>(e.x*t+e.y*n)*r,s=proj(this.p1),o=proj(this.p2),a=proj(e.p1),A=proj(e.p2),l=s<o?s:o,c=s>o?s:o,p=a<A?a:A,h=a>A?a:A;return Math.round(100*(Math.max(c,h)-Math.min(l,p)))/100}infoquad(e){if(!this.isparallela(e))return;const{p1:t,p2:n,normale:i}=this;let{p1:r,p2:s}=e;const distance2=(e,t)=>(e.x-t.x)**2+(e.y-t.y)**2;function wrapToPi(e){return e>Math.PI?e-=2*Math.PI:e<-Math.PI&&(e+=2*Math.PI),e}function getangle(e,t){return Math.atan2(t.y-e.y,t.x-e.x)}distance2(t,r)>distance2(t,s)&&([r,s]=[s,r]);const o=getangle(t,n);function toDeg(e){return Math.round(18e4*e/Math.PI)/1e3}const a=toDeg(wrapToPi(getangle(t,r)-o)),A=toDeg(wrapToPi(getangle(n,s)-o)),l=Math.round(100*this.len)/100,c=r.x-t.x,p=r.y-t.y,h=Math.round(100*Math.abs(c*i.x+p*i.y))/100;let u=this.lunghezzatotale(e);return{angle:toDeg(o),aini:a,afin:A,l:l,ltot:u,distanza:h,sx:Math.round(100*t.x)/100,sy:Math.round(100*t.y)/100}}isperpendicolare(e){const t=this.dx*e.dx+this.dy*e.dy;return Math.abs(t)<gt}offset(e){const t=this.normale,n=new Punto2(this.p1.x+t.x*e,this.p1.y+t.y*e),i=new Punto2(this.p2.x+t.x*e,this.p2.y+t.y*e);return new Linea2(n,i)}angolo(e){const{dx:t,dy:n}=this;let i;if(e){const{dx:r,dy:s}=e,o=Math.atan2(n,t);i=Math.atan2(s,r)-o}else i=Math.atan2(n,t);return i>Math.PI?i-=2*Math.PI:i<-Math.PI&&(i+=2*Math.PI),i}ortopt(e){let{p1:t,dx:n,dy:i}=this;const r=Math.hypot(n,i);if(r<gt)return;const s=-i/r,o=n/r;return{x:t.x+s*e,y:t.y+o*e}}offsetline(e){let{p1:t,p2:n,dx:i,dy:r}=this;const s=Math.hypot(i,r);if(s<gt)return;const o=-r/s,a=i/s;return new Linea2({x:t.x+o*e,y:t.y+a*e},{x:n.x+o*e,y:n.y+a*e})}distanzaSegmentiParalleli(e){if(!this.isparallela(e))return 1e9;const{p1:t,normale:n}=this,i=e.p1.x-t.x,r=e.p1.y-t.y,s=Math.abs(i*n.x+r*n.y);return Math.abs(s)<gt?0:s}isCollineare(e,t=!1){if(!this.isparallela(e))return!1;const n=this.distanzaSegmentiParalleli(e);if(Math.abs(n)>gt)return!1;if(t){function isPointBetween(e,t,n,i=gt){const r=(n.x-t.x)*(e.y-t.y)-(n.y-t.y)*(e.x-t.x);return!(Math.abs(r)>i)&&(Math.min(t.x,n.x)-i<=e.x&&e.x<=Math.max(t.x,n.x)+i&&Math.min(t.y,n.y)-i<=e.y&&e.y<=Math.max(t.y,n.y)+i)}const{p1:i,p2:r}=this,{p1:s,p2:o}=e;return isPointBetween(s,i,r)||isPointBetween(o,i,r)||isPointBetween(i,s,o)||isPointBetween(r,s,o)}return!0}clone(){return new Linea2(this.p1.x,this.p1.y,this.p2.x,this.p2.y)}rotate(e){if(!e)return this;const t=e*Math.PI/180,n=Math.cos(t),i=Math.sin(t);function rotate(e){return new Punto2(e.x*n-e.y*i,e.x*i+e.y*n)}return this.p1=rotate(this.p1),this.p2=rotate(this.p2),this}move(e=0,t=0){return"object"==typeof e&&e.x&&(t=e.y||0,e=e.x),this.p1.x+=e,this.p1.y+=t,this.p2.x+=e,this.p2.y+=t,this}}function getptsoffset(e,t,n){let i,r,s,o,a=-1,A=-1,l=e.length,c=t.length,p=[],h=new Linea2(e[0],e[1]),u=new Linea2(e[l-2],e[l-1]),d=h.offset(n),g=u.offset(n);for(let e=0;e<c;e++){let n=new Linea2(t[e%c],t[(e+1)%c]);d.isparallela(n)&&d.isCollineare(n,!0)&&(a=e),g.isparallela(n)&&g.isCollineare(n,!0)&&(A=e)}if(a>=0&&A>=0){a>A?(i=a-A+2,r=A+c-a+2,i<r?(s=A,o=a+1):(s=a,o=A+c+1)):(i=A-a+2,r=a+c-A+2,i<r?(s=a,o=A+1):(s=A,o=a+c+1));for(let e=s;e<=o;e++)p.push(t[e%c])}return p}async function errorescript(e,t,n){let i,r,s,o=(t.stack||"").match(/user-script\.js:(\d+):(\d+)/);if(o||(o=(t.toString()||"").match(/user-script\.js:(\d+):(\d+)/)),o&&([,i,r]=o.map(Number),i-=2),(!i||!r)&&t instanceof SyntaxError){window.acorn||(await new Promise(((e,t)=>{const n=document.createElement("script");n.src="https://cdn.jsdelivr.net/npm/acorn@8.15.0/dist/acorn.js",n.onload=e,n.onerror=t,document.head.appendChild(n)})),console.log("caricato acorn"));try{window.acorn.parse(e,{ecmaVersion:"latest"})}catch(e){e.loc&&(i=e.loc.line,r=e.loc.column+1)}}if(i&&r)s=`ERRORE:${n?" f:"+n:""} ${t.message.replace}\n`+function extractContext(e,t,n,i=1){const r=e.split(/\r?\n/),s=t-1,o=Math.max(0,s-i),a=Math.min(r.length,s+i+1);return r.slice(o,a).map(((e,i)=>o+i+1===t?e+"\n"+" ".repeat(n-1)+"^":e)).join("\n")}(e,i,r);else{let e=t.stack?.toString()||t.message||"";e=e.replace("Error: ","").replaceAll("\n\n","\n"),s=`ERRORE:${n?" f:"+n:""} ${e}`}return s}function seedarray(e,t){if(e&&e.length){let n=[];for(let t=0;t<e.length;t++){let i=e[t];if(i.p)for(let e=0;e<i.p;e++)n.push(t);else n.push(t)}return e[n[seeder(n.length,t)]]}}function seeder(e,t="seed42"){const n=function mulberry32(e){return function(){e=(e|=0)+1831565813|0;let t=Math.imul(e^e>>>15,1|e);return t=t+Math.imul(t^t>>>7,61|t)^t,((t^t>>>14)>>>0)/4294967296}}(function xmur3(e){let t=1779033703^e.length;for(let n=0;n<e.length;n++)t=Math.imul(t^e.charCodeAt(n),3432918353),t=t<<13|t>>>19;return function(){return t=Math.imul(t^t>>>16,2246822507),t=Math.imul(t^t>>>13,3266489909),(t^=t>>>16)>>>0}}(String(t))());return Math.floor(n()*e)}function hash(e){let t="";if("string"==typeof e||"number"==typeof e)t=e+"";else if("object"==typeof e&&e){const n=Object.keys(e).sort(),i="\0";t=n.map((t=>`${t}${i}${String(e[t])}`)).join(i)}let n=2166136261,i=2218511855;for(let e=0;e<t.length;e++){const r=t.charCodeAt(e);n^=r,n+=n<<5^2779096485,i^=n,i=((i<<3)+r^2134516169)>>>0}return n>>>=0,n.toString(16)+i.toString(16)}function clean(e,t=!1){return t?(e||"").trim().toLowerCase():(e||"").trim()}function getcouple(e,t="=",n=!0){const i=(e=e||"").indexOf(t);return i>=0?{v:clean(e.substring(0,i),n),o:e.substring(i+t.length).trim(),fl:!0}:{v:clean(e,n),o:"",fl:!1}}function clamp(e,t=-1/0,n=1/0){return(e=Number(e)||0)<t&&(e=t),e>n&&(e=n),e}function getcolonne(e,t=!1){e=String(e||"");const n=/^(\d*)\.\.(\d*)$/.exec(e);if(n){let e=parseInt(n[1])||0,t=parseInt(n[2])||0;const i=[];for(let n=e;n<=t;n++)i.push(n+"");return i}if(!/["({[]/.test(e))return e.split(/[,;]/).map((e=>e.trim()));const i=[];let r="",s=0,o=!1;for(let t=0;t<e.length;t++){const n=e[t];if(0===s&&'"'===n&&(0!==t&&"\\"===e[t-1]||(o=!o)),o||("("===n||"["===n||"{"===n?s++:")"!==n&&"]"!==n&&"}"!==n||(s=Math.max(0,s-1))),","!==n&&";"!==n||0!==s||o)r+=n;else{const e=r.trim();i.push(e),r=""}}const a=r.trim();return a&&i.push(a),i.map((e=>(e=e.trim(),!t&&(e.startsWith('"')&&e.endsWith('"')||e.startsWith("(")&&e.endsWith(")"))?e.slice(1,-1):e)))}new class Errori{constructor(){this.azzera()}azzera(){this.err=[]}add(e,t){this.err.push({msg:e,row:t})}get(){return this.err}get length(){return this.err.length}toString(){const e=[];for(const t of this.err){const n="object"==typeof t.msg?JSON.stringify(t.msg):t.msg||"";e.push(`${t.row?t.row+":":""}${n}`)}return e.join("\n")}};const round=(e,t=-1)=>{const n="string"==typeof e?parseFloat(e)||0:e;if(t<0)return Math.round(n||0);const i=Math.pow(10,t);return Math.round(n*i)/i||0};function muClComments(e,t){const n=(i=e,i.replace(/("(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*')|\/\*[\s\S]*?\*\//g,((e,t)=>t||""))).split(/\r?\n/);var i;const r=[];let s="";for(const e of n){let t=e;if(/(^|[^:])\/\/.*/.test(t)&&(t=t.replace(/(^|[^:])\/\/.*/,((e,t)=>t.trim()))),t=t.trim(),0!==t.length)if(s.length>0&&(t=s+" "+t,s=""),t.endsWith("\\")){t=t.slice(0,-1);const e=t.lastIndexOf("//");-1!==e&&(t=t.slice(0,e).trim()),s=t}else r.push(t)}return r}const ft=Math.PI/180;function TODEG(e,t=1){let n=10**t;return Math.round(180*e*n/Math.PI)/n}function TORAD(e,t=3){let n=10**t;return Math.round(e*ft*n)/n}const mt={window:void 0,self:void 0,globalThis:void 0,document:void 0,Function:void 0,eval:void 0,fetch:void 0,XMLHttpRequest:void 0};function getOggetto(e,t=[]){if(Array.isArray(e))return e.map((e=>getOggetto(e,t)));if(e&&"object"==typeof e){const n={};for(const[i,r]of Object.entries(e))"function"==typeof r||t&&t.includes(i)||(n[i]=getOggetto(r,t));return n}return e}function getSqDist(e,t){let n=e.x-t.x,i=e.y-t.y;return n*n+i*i}function getSqSegDist(e,t,n){let i=t.x,r=t.y,s=n.x-i,o=n.y-r;if(0!==s||0!==o){let t=((e.x-i)*s+(e.y-r)*o)/(s*s+o*o);t>1?(i=n.x,r=n.y):t>0&&(i+=s*t,r+=o*t)}return s=e.x-i,o=e.y-r,s*s+o*o}function simplifyDPStep(e,t,n,i,r){let s,o=i;for(let i=t+1;i<n;i++){let r=getSqSegDist(e[i],e[t],e[n]);r>o&&(s=i,o=r)}o>i&&(s-t>1&&simplifyDPStep(e,t,s,i,r),r.push(e[s]),n-s>1&&simplifyDPStep(e,s,n,i,r))}function simplifyDouglasPeucker(e,t){let n=e.length-1,i=[e[0]];return simplifyDPStep(e,0,n,t,i),i.push(e[n]),i}function simplify(e,t,n){if(e.length<=2)return e;let i=void 0!==t?t*t:1;return e=n?e:function simplifyRadialDist(e,t){let n,i=e[0],r=[i];for(let s=1,o=e.length;s<o;s++)n=e[s],getSqDist(n,i)>t&&(r.push(n),i=n);return i!==n&&r.push(n),r}(e,i),e=simplifyDouglasPeucker(e,i)}function mapvertices(e,t){const dist2=(e,t)=>(e.x-t.x)**2+(e.y-t.y)**2;let n=e.length,i=t.length;if(n<2||i<2)return[];let r=[[0,0]];if(n===i){for(let e=1;e<n;e++)r.push([e,e]);return r}if(n>i)for(let s=1,o=0;s<n-1;s++){if(o+1<i){const n=e[s],i=dist2(n,t[o]);dist2(n,t[o+1])<=i&&o++}r.push([s,o])}else for(let s=1,o=0;s<i-1;s++){if(o+1<n){const n=t[s],i=dist2(n,e[o]);dist2(n,e[o+1])<=i&&o++}r.push([o,s])}return r.push([n-1,i-1]),r}function dxfbulge(e,t,n,i=0){const r=[];if(!n||Math.abs(n)<1e-10||0===i)return r;const s=4*Math.atan(n);if(s<0)return dxfbulge(t,e,-n,i).reverse();const o=t.x-e.x,a=t.y-e.y,A=Math.hypot(o,a),l=A/(2*Math.sin(s/2)),c=(e.x+t.x)/2,p=(e.y+t.y)/2,h=-a/A,u=o/A,d=l*Math.cos(s/2),g=n>=0?1:-1,f=c+g*h*d,m=p+g*u*d;let y=Math.atan2(e.y-m,e.x-f);for(let e=1;e<=i;e++){const t=y+e/(i+1)*s,n=f+l*Math.cos(t),o=m+l*Math.sin(t);r.push({x:n,y:o})}return r}function raccordabezier(e,t,n,i,r=10){const s=function getIntersection(e,t,n,i){const r=(e.x-t.x)*(n.y-i.y)-(e.y-t.y)*(n.x-i.x);return 0===r?null:{x:((e.x*t.y-e.y*t.x)*(n.x-i.x)-(e.x-t.x)*(n.x*i.y-n.y*i.x))/r,y:((e.x*t.y-e.y*t.x)*(n.y-i.y)-(e.y-t.y)*(n.x*i.y-n.y*i.x))/r}}(e,t,n,i);if(!s)return[{x:t.x,y:t.y},{x:n.x,y:n.y}];const o=s;if(0===r)return[{x:t.x,y:t.y},{x:n.x,y:n.y}];const a=[];for(let e=0;e<=r;e++){const i=e/r,s=1-i,A=s*s*t.x+2*s*i*o.x+i*i*n.x,l=s*s*t.y+2*s*i*o.y+i*i*n.y;a.push({x:A,y:l})}return a}function raccordabezier3(e,t,n,i,r=10){const s=t.x-e.x,o=t.y-e.y,a=n.x-t.x,A=n.y-t.y,l=Math.sqrt(s*s+o*o),c=Math.sqrt(a*a+A*A);if(i>l||i>c)return[e,t,n];i!=l&&i!=c||(i-=.01);const p=(l-i)/l,h=i/c;return raccordabezier(e,{x:e.x+s*p,y:e.y+o*p},{x:t.x+a*h,y:t.y+A*h},n,r)}function normal2(e,t){const n=t.x-e.x;let i=-(t.y-e.y),r=n;const s=Math.sqrt(i*i+r*r);return 0===s?{nx:0,ny:0}:{nx:i/s,ny:r/s}}function angle3point(e,t,n){const i=t.x-e.x,r=t.y-e.y,s=n.x-t.x,o=n.y-t.y,a=i*s+r*o,A=i*o-r*s,l=Math.sqrt(i**2+r**2),c=Math.sqrt(s**2+o**2);return l&&c?Math.atan2(A,a):0}function angle2vec(e,t){const n=e.x*t.x+e.y*t.y,i=Math.sqrt(e.x*e.x+e.y*e.y),r=Math.sqrt(t.x*t.x+t.y*t.y);if(0===i||0===r)return 0;let s=n/(i*r);s=Math.max(-1,Math.min(1,s));return Math.acos(s)/ft}function removeduplicate(e,t=.005){if(!Array.isArray(e)||0===e.length)return[];const n=[],i=e.length;for(let t=0;t<i;t++){const r=e[t],s=e[(t+1)%i];n.push({x:r.x,y:r.y}),s.x,r.x,s.y,r.y}const r=n[0],s=n[n.length-1];return r.x,s.x,r.y,s.y,n}function infocircle(e,t,n,i,r,s){let o,a,A;"object"==typeof e?(o=e,a=t,A=n):(o=new Punto2(e,t),a=new Punto2(n,i),A=new Punto2(r,s));const l=(o.x+a.x)/2,c=(o.y+a.y)/2,p=(a.x+A.x)/2,h=(a.y+A.y)/2,u=a.x-o.x,d=a.y-o.y,g=A.x-a.x,f=-d,m=-(A.y-a.y),y=f*g-u*m;if(!y)return null;const b=((p-l)*g-(h-c)*m)/y,I=l+b*f,x=c+b*u,C=Math.hypot(o.x-I,o.y-x),B=180/Math.PI;let E=Math.atan2(o.y-x,o.x-I),w=Math.atan2(A.y-x,A.x-I);const v=Math.atan2(a.y-x,a.x-I);return w<E&&(w+=2*Math.PI),v<E&&(E+=2*Math.PI),v>w&&(w+=2*Math.PI),E*=B,w*=B,E=(E%360+360)%360,w=(w%360+360)%360,{center:new Punto2(round(I,1),round(x,1)),r:round(C,1),ang1:round(E,1),ang2:round(w,1)}}function intersectcircle(e,t,n,i,r){const s=r.x-i.x,o=r.y-i.y,a=i.x-e,A=i.y-t,l=s*s+o*o,c=2*(a*s+A*o),p=c*c-4*l*(a*a+A*A-n*n);if(p<=0)return null;const h=Math.sqrt(p),u=(-c-h)/(2*l),d=(-c+h)/(2*l),g=i.x+u*s,f=i.y+u*o,m=i.x+d*s,y=i.y+d*o,b=180/Math.PI;let I=Math.atan2(f-t,g-e)*b,x=Math.atan2(y-t,m-e)*b;return I=(I%360+360)%360,x=(x%360+360)%360,[I,x]}function getshape(){let e=[];function orientation(){if(!e.length)return 0;let t=0;const n=e.length;for(let i=0;i<n;i++){const r=e[i],s=e[(i+1)%n];t+=r.x*s.y-s.x*r.y}return t>0?1:t<0?-1:0}function tovec(){return e.flatMap((e=>[e.x,e.y]))}function move(t=0,n=0){"object"==typeof t&&t.x&&(n=t.y||0,t=t.x);for(let i of e)i.x+=t,i.y+=n;return this}function selezionaprimo(t){return(t%=e.length)>0&&(e=[...e.slice(t),...e.slice(0,t)]),this}function _addvec(t){for(let n=0;n<t.length;n+=2)e.push({x:t[n],y:t[n+1]})}function fromstr(t){return e=removeduplicate(function processTokens(e){const t=[];for(let n=0;n<e.length;n++){const i=e[n];if("point"===i.type)t.push(i.point);else if("command"===i.type)switch(i.cmd){case"x":{const r=t[t.length-1],s="point"===e[n+1]?.type?e[n+1].point:t[0],o=parseFloat(i.params[0])||5;{const e=1;let n=s.x-r.x,i=s.y-r.y,a=Math.hypot(n,i);a>1&&t.push(...dxfbulge(r,s,o,Math.floor((a-e)/(e+2))+1))}break}case"b":{if(t.length<2)continue;const r=parseInt(i.params[0])||5,s=t[t.length-2],o=t[t.length-1];let a="point"===e[n+1]?.type?e[n+1].point:void 0,A="point"===e[n+2]?.type?e[n+2].point:void 0;a?A||(A=t[0]):(a=t[0],A=t[1]);const l=raccordabezier(s,o,a,A,r);t.push(...l),n+=1;break}case"r":{if(t.length<1)continue;const r=parseFloat(i.params[0])||0;if(r>0){const s=parseInt(i.params[1])||Math.min(r,10),o=t[t.length-1];let a="point"===e[n+1]?.type?e[n+1].point:void 0,A="point"===e[n+2]?.type?e[n+2].point:"point"===e[n+3]?.type?e[n+3].point:void 0;a?A||(A=t[0]):(a=t[0],A=t[1],t.splice(0,1));const l=raccordabezier3(o,a,A,r,s);t.push(...l),n+=1}break}case"c":{let r,s;if(i.params[0].includes("/")){let e=i.params[0].split("/");r=parseFloat(e[0])||50,s=parseFloat(e[1])||r||50}else r=parseFloat(i.params[0])||50,s=r;let o=(parseFloat(i.params[2])||0)*ft,a=(parseFloat(i.params[3])||0)*ft;const A=parseInt(i.params[1])||12,l="point"===e[n+1]?.type?e[n+1].point:new Punto2(0,0);for(let e=0;e<=A;e++){let n,i;if(o||a){let t=a-o;n=r*Math.cos(e/A*t+o),i=s*Math.sin(e/A*t+o)}else n=r*Math.cos(e/A*Math.PI*2+Math.PI),i=s*Math.sin(e/A*Math.PI*2+Math.PI);t.push(new Punto2(l.x+n,l.y+i))}n+=1;break}case"a":{let r,s="point"===e[n+1]?.type?e[n+1].point:void 0,o="point"===e[n+2]?.type?e[n+2].point:void 0,a="point"===e[n+3]?.type?e[n+3].point:void 0;if(!s||!a)continue;if(o)if(i.params[0])r=clamp(parseInt(i.params[0]),1,40);else{const e=Math.hypot(a.x-s.x,a.y-s.y),t=Math.abs((o.x-s.x)*(a.y-s.y)-(a.x-s.x)*(o.y-s.y))/(2*e);r=Math.round(e*Math.sqrt(t/(e+.1))*10),r=clamp(r,1,24),r=1}else o=a,r=0;const A=arcfrom3point(r,s,o,a);t.push(...A),n+=3;break}}}return t}(function tokenize(e){const t=[],n=e.replace(/[\n\r,;]/g," ").replace(/\s+/g," ").toLowerCase().trim().split(" ").filter((e=>e.length>0));let i=0;for(;i<n.length;){const e=n[i];/^[brcax]/.test(e)?(t.push({type:"command",cmd:e[0],params:e.slice(1).split(":")}),i++):i<n.length-1&&/^-?\d+(\.\d+)?$/.test(n[i])&&/^-?\d+(\.\d+)?$/.test(n[i+1])?(t.push({type:"point",point:new Punto2(parseFloat(n[i]),parseFloat(n[i+1]))}),i+=2):i++}return t}(t))),this}function dims(e){let{p1:t,p2:n}=e.reduce(((e,t)=>(e.p1.x=Math.min(e.p1.x,t.x),e.p2.x=Math.max(e.p2.x,t.x),e.p1.y=Math.min(e.p1.y,t.y),e.p2.y=Math.max(e.p2.y,t.y),e)),{p1:new Punto2(1/0,1/0),p2:new Punto2(-1/0,-1/0)}),i=!1;if(4==e.length){const r=.001;function findpunto(t,n){return!!e.find((e=>Math.abs(e.x-t)<r&&Math.abs(e.y-n)<r))}findpunto(t.x,t.y)&&findpunto(t.x,n.y)&&findpunto(n.x,t.y)&&findpunto(n.x,n.y)&&(i=!0)}return{p1:t,p2:n,isrect:i,width:n.x-t.x,height:n.y-t.y}}return{get key(){return hash(tovec().join("\t"))},orienta:function orienta(t,n){if(!t||!n)return null;const i=n.x-t.x,r=n.y-t.y,s=180*Math.atan2(r,i)/Math.PI,o=new Matrix3D;o.rotateZ(-s),o.translate(-t.x,-t.y,0);const a=e.map((e=>o.transform(e.x,e.y)));let A=a.reduce(((e,t)=>(e.p1.x=Math.min(e.p1.x,t.x),e.p2.x=Math.max(e.p2.x,t.x),e.p1.y=Math.min(e.p1.y,t.y),e.p2.y=Math.max(e.p2.y,t.y),e)),{p1:new Punto2(1/0,1/0),p2:new Punto2(-1/0,-1/0)});return{shape:getshape().frompt(a),origine:new Punto2(t.x,t.y),angolo:s,mm:A,width:A.p2.x-A.p1.x,height:A.p2.y-A.p1.y}},rebase:function rebase(t,n=!1,i=0,r=0){const s=new Matrix3D;s.rotateZ(-t);let o=e.map((e=>s.transform(e.x,e.y))),{p1:a,p2:A,width:l,height:c}=dims(o);return n||(i=a.x,r=a.y),o=o.map((e=>new Punto2(e.x-i,e.y-r))),{shape:getshape().frompt(o),origine:new Punto2(i,r),angolo:t,width:l,height:c}},fromstr:fromstr,move:move,infocircle:infocircle,intersectcircle:intersectcircle,get pt(){return e},set pt(t){Array.isArray(t)&&(e=t)},get npt(){return e?.length||0},get vec(){return tovec()},toJSON:()=>({vec:tovec(),orient:orientation()}),get orient(){return orientation()},corners:(t=45)=>function sharpCorners(e,t=45){const n=[],i=e.length;if(i<3)return n;for(let r=0;r<i;r++){const s=e[(r-1+i)%i],o=e[r],a=e[(r+1)%i],A=o.x-s.x,l=o.y-s.y,c=a.x-o.x,p=a.y-o.y,h=Math.hypot(A,l),u=Math.hypot(c,p);if(0===h||0===u)continue;let d=(A*c+l*p)/(h*u);d=Math.max(-1,Math.min(1,d));const g=180*Math.acos(d)/Math.PI;g>t&&n.push({i:r,x:o.x,y:o.y,a:g})}return n}(e,45),clone:()=>getshape().frompt(e),dims(){let t=dims(e),n=0;for(let t=0;t<e.length;t++){let i=(t+1)%e.length;const r=e[t].x-e[i].x,s=e[t].y-e[i].y;n+=Math.sqrt(r*r+s*s)}return t.lung=n,t},get area(){return Math.abs(e.reduce(((t,n,i)=>{const r=e[(i+1)%e.length];return t+(n.x*r.y-r.x*n.y)}),0)/2)},pointslink(t){let n=mapvertices(e,t.pt),i=[];for(let e of n)i[e[0]]=t.pt[e[1]];return i},alignline(t,n){return e=function stretchShapeToLine(e,t,n){if(!e?.length||!t||!n)return[];const i=e[0],r=e[e.length-1],s=r.x-i.x,o=r.y-i.y,a=Math.atan2(o,s);let A=e.map((e=>({x:e.x-i.x,y:e.y-i.y}))).map((e=>({x:e.x*Math.cos(-a)-e.y*Math.sin(-a),y:e.x*Math.sin(-a)+e.y*Math.cos(-a)})));const l={dx:n.x-t.x,dy:n.y-t.y},c=Math.sqrt(l.dx*l.dx+l.dy*l.dy)/(A[A.length-1].x||1e-8);let p=A.map((e=>({x:e.x*c,y:e.y})));const h=Math.atan2(l.dy,l.dx);return p.map((e=>({x:e.x*Math.cos(h)-e.y*Math.sin(h),y:e.x*Math.sin(h)+e.y*Math.cos(h)}))).map((e=>({x:e.x+t.x,y:e.y+t.y})))}(e,t,n),this},rotate(t){if(!t)return this;const n=t*Math.PI/180,i=Math.cos(n),r=Math.sin(n);for(let t of e){const e=t.x*i-t.y*r,n=t.x*r+t.y*i;t.x=e,t.y=n}return this},selezionaprimo:selezionaprimo,segment(t,n=!1){let i=e.length;return t<0&&(t+=i),new Linea2(e[t%i],e[(t+(n?-1:1))%i])},lineoffset(t,n,i){if((t=(t||0)%e.length)!=(n=(n||0)%e.length)){let r=new Linea2(e[t],e[n]);if(r){return r=r.offsetline(-i),this.intersectline(r)}}},orientasplitter(){-1!=orientation()&&e.reverse();let t=e.length;for(let n=0;n<t;n++){let i=new Linea2(e[(t+n-1)%t],e[n]);if(Math.abs(Math.abs(i.angle)-Math.PI)<.001){n&&selezionaprimo(n);break}}return this},mirrorx(t=0){for(let n of e)n.x=2*t-n.x;return this},mirrory(t=0){for(let n of e)n.y=2*t-n.y;return this},simplify(t,n){return e=simplify(e,t,n),this},fromclip(t){e=[];for(let n of t)e.push({x:n.x/1e3,y:n.y/1e3});return this},infosegmento(t,n=!1){const i=e.length;function clampIndex(e){return(e+i)%i}function angle(e,t){return Math.atan2(t.y-e.y,t.x-e.x)}function angleDiff(e,t){let n=e-t;for(;n>Math.PI;)n-=2*Math.PI;for(;n<-Math.PI;)n+=2*Math.PI;return n}const r=e[t];let s,o,a;if(n)if(0===t){const t=e[1].x-e[0].x,n=e[1].y-e[0].y;s={x:e[0].x-t,y:e[0].y-n},o=e[1],a=2==i?{x:e[1].x+t,y:e[1].y+n}:e[2]}else if(t===i-1){const t=e[i-1].x-e[i-2].x,n=e[i-1].y-e[i-2].y;s=e[i-2],o={x:e[i-1].x+t,y:e[i-1].y+n},a={x:o.x+t,y:o.y+n}}else s=e[t-1],o=e[t+1],a=t+2<i?e[t+2]:{x:e[t+1].x+(e[t+1].x-e[t].x),y:e[t+1].y+(e[t+1].y-e[t].y)};else{const n=clampIndex(t-1),i=clampIndex(t+1),r=clampIndex(t+2);s=e[n],o=e[i],a=e[r]}const A=angle(r,o),l=angle(s,r),c=angle(o,a);return{x:r.x,y:r.y,l:function length(e,t){const n=t.x-e.x,i=t.y-e.y;return Math.sqrt(n*n+i*i)}(r,o),ang:A/ft,a1:angleDiff(A,l)/ft,a2:angleDiff(c,A)/ft}},swapxy(){for(let t=0;t<e.length;t++){let n=e[t].x;e[t].x=-e[t].y,e[t].y=-n}return this},fromvec(t){return e=[],_addvec(t),this},addvec(e){return _addvec(e),this},frompt(t){return e=[...t],e=removeduplicate(e),this},fromdxfvec(t){let n=[];if(t&&t.length)for(let e=0;e<t.length;e++){let{x:i,y:r,bulge:s}=t[e];if(n.push({x:i,y:r}),s){const o=1;let a={x:i,y:r},A=t[(e+1)%t.length],l=A.x-a.x,c=A.y-a.y,p=Math.hypot(l,c);p>o&&n.push(...dxfbulge(a,A,s,Math.floor((p-o)/o)+1))}}return e=n.map((e=>({x:Math.round(10*e.x)/10,y:Math.round(10*e.y)/10}))),e=removeduplicate(e),this},monotona(){let t=dims(e),n=e.map((e=>({x:e.x-t.p2.x,y:e.y}))),i=[];i.push(n[0]);let r=n[0].y,s=1e-4;for(let e=1;e<n.length;e++)if(n[e].y>r+s||e==n.length-1)i.push(n[e]),r=n[e].y;else{const t=r+s;i.push({x:n[e].x,y:t}),r=t}return{sh:getshape().frompt(i),...t}},offsetshape(e){let t=[],n=this;for(let i=0;i<n.npt-1;i++){let r=n.segment(i).offset(e);t.push(r)}let i=n.segment(0).perpendicolare(),r=n.segment(n.npt-2),s=r.perpendicolare(r.p2),o=[i.interseca(t[0])];for(let e=0;e<t.length-1;e++){let n=t[e].interseca(t[e+1]);n&&o.push(n)}return o.push(t[t.length-1].interseca(s)),getshape().frompt(o)},sliceony(t){let n=t.pt.map((e=>e.y)).slice(1,-1);const i=[],r=e.length;let s=0,o=e[0].y;for(let t=1;t<r;t++)e[t].y<o&&(o=e[t].y,s=t);const a=[...e.slice(s),...e.slice(0,s)],A=a.length,l=new Map;for(let e=0;e<A;e++)for(let t of n)Math.abs(a[e].y-t)<1e-5&&(l.has(t)?l.get(t).i2=e:l.set(t,{i1:e,i2:e}));const c=n.map((e=>l.get(e))).filter((e=>e&&e.i1>=0&&e.i2>=0));c.length>0&&c[0].i1>0&&i.push([...a.slice(0,c[0].i1+1),...a.slice(c[0].i2,c[0].length)]);for(let e=0;e<c.length-1;e++){const t=c[e],n=c[e+1];i.push([...a.slice(t.i1,n.i1+1),...a.slice(n.i2,t.i2+1)])}const p=c[c.length-1];p.i2>p.i1&&i.push(a.slice(p.i1,p.i2+1));return i.filter((e=>e.length>0))},splitvert:function splitvert(e,t=!0){const n=t?this.intersectline(new Linea2(e,-100,e,100)):this.intersectline(new Linea2(-100,e,100,e));if(!n)return null;let i=n.p1,r=n.p2;const findIndex=e=>this.pt.findIndex(((t,n)=>new Linea2(t,this.pt[(n+1)%this.pt.length]).onsegment(e)));let s=findIndex(i),o=findIndex(r);if(s<0||o<0)return null;if(s>o){let e=s;s=o,o=e,e=i,i=r,r=e}const a=this.pt.length;let A=[],l=[];for(let e=0;e<a;e++)A.push(this.pt[e]),e==s&&(A.push(i),A.push(r),e=o);t?(l.push(r),l.push(i)):l.push(i);for(let e=s+1;e<=o;e++)l.push(this.pt[e]);return t||l.push(r),{sx:getshape().frompt(A),dx:getshape().frompt(l),linea:n}},splitoriz(e){return this.splitvert(e,!1)},splitshape(e,t=!0){const n=100,i=t?{x:e.x,y:e.y-n}:{x:e.x-n,y:e.y},r=t?{x:e.x,y:e.y+n}:{x:e.x+n,y:e.y},s=this.intersectline(new Linea2(i,r));if(!s)return null;const o=s.p1,a=s.p2,findIndex=e=>this.pt.findIndex(((t,n)=>new Linea2(t,this.pt[(n+1)%this.pt.length]).onsegment(e))),A=findIndex(o),l=findIndex(a);if(A<0||l<0)return null;const c=this.pt.length,loop=(e,t,n,i)=>{const r=[];for(let n=e;n!==t;n=(n+1)%c)r.push(this.pt[(n+1)%c]);return r},p=getshape().frompt(loop(A,l));return{sx:getshape().frompt(loop(l,A)),dx:p,linea:s}},xfromy(e,t=0,n=!0){const i=[],r=this.pt.length;for(let t=0;t<r-1;t++){const r=this.pt[t],s=this.pt[t+1];if(r.y<=e&&s.y>=e||s.y<=e&&r.y>=e){const t=s.y-r.y,n=t?(e-r.y)/t:0,o=r.x+n*(s.x-r.x);i.push(o)}else r.y===e&&s.y===e&&i.push(n?Math.max(r.x,s.x):Math.min(r.x,s.x))}return i.length?n?Math.max(...i):Math.min(...i):t},yfromx(e,t=0,n=!0){const i=[],r=this.pt.length;for(let t=0;t<r-1;t++){const r=this.pt[t],s=this.pt[t+1];if(r.x<=e&&s.x>=e||s.x<=e&&r.x>=e){const t=s.x-r.x,n=t?(e-r.x)/t:0,o=r.y+n*(s.y-r.y);i.push(o)}else r.x===e&&s.x===e&&i.push(n?Math.max(r.y,s.y):Math.min(r.y,s.y))}return i.length?n?Math.max(...i):Math.min(...i):t},forcevalues(t,n=!0,i=1e-6){const r=[...new Set(t.pt.map((e=>n?e.y:e.x)))].sort(((e,t)=>e-t)),s=[],o=e.length;for(let t=0;t<o;t++){const a=e[t],A=e[(t+1)%o];s.push({...a});let l=n?a.y:a.x,c=n?A.y:A.x;if(l===c)continue;const p=c>l?r.filter((e=>e>l+i&&e<c-i)):r.filter((e=>e<l-i&&e>c+i)).reverse();for(const e of p){const t=(e-l)/(c-l),n={x:a.x+t*(A.x-a.x),y:a.y+t*(A.y-a.y)};s.push(n)}}return e=s,this},fromrrect(e,t,n=10,i=0,r=0){return(n>=e/2||n>=t/2&&n<=0)&&(n=Math.round(Math.min(e/3,t/3))),fromstr(`0,0,r${n},${e},0,r${n},${e},${t},r${n},0,${t},r${n}`),(i||r)&&move(i,r),this},fromrect(t,n,i,r,s){t||(t=10),n||(n=10),s||(s=0),s=Math.min(Math.abs(s),Math.abs(.4*t),Math.abs(.4*n));let o=t>0?s:-s,a=n>0?s:-s;return e=s?[{x:o,y:0},{x:t-o,y:0},{x:t,y:a},{x:t,y:n-a},{x:t-o,y:n},{x:o,y:n},{x:0,y:n-a},{x:0,y:a}]:[{x:0,y:0},{x:t,y:0},{x:t,y:n},{x:0,y:n}],this},intersectline:t=>function _intersectline(e,t,n){let i=e.length,r=new Linea2(t,n);const s=[];for(let t=0;t<e.length;t++){let n=new Linea2(e[t],e[(t+1)%i]),o=n.interseca(r);o&&n.onsegment(o)&&s.push(o)}if(s.length<2)return null;const{dx:o,dy:a}=r;s.sort(((e,n)=>(e.x-t.x)*o+(e.y-t.y)*a-((n.x-t.x)*o+(n.y-t.y)*a)));let A=new Punto2(s[0].x,s[0].y),l=new Punto2(s[s.length-1].x,s[s.length-1].y);const c=l.x-A.x,p=l.y-A.y;return c*o+p*a<0&&([A,l]=[l,A]),new Linea2(A,l)}(e,t.p1,t.p2),tostr(t=2){let n=10**t,pstr=e=>String(Math.round(e*n)/n),i=e.map((e=>`${pstr(e.x)};${pstr(e.y)};`)).join("");return i&&i.length?i.slice(0,-1).match(/.{1,80}(;|$)/g).map((e=>e.trim())).join("\n"):""},addpt(t){return t?(Array.isArray(t)||(t=[t]),e=removeduplicate([...e,...t]),this):this},addracc(t,n,i=2,r=!0){if(Array.isArray(t)&&(n={x:t[2]||0,y:t[3]||0},t={x:t[0]||0,y:t[1]||0}),e.length>=2){let s=raccordabezier(e[e.length-2],e[e.length-1],t,n,i);e=[...e,...s],r&&(e.push(t),e.push(n))}return e=removeduplicate(e),this},setorient(t){let n=orientation();return(1==n&&-1==t||-1==n&&1==t)&&e.reverse(),this},reverse(){return e.reverse(),this},pointinshape:t=>function isPointInPolygon(t){let n=t.x,i=t.y,r=!1;for(let t=0,s=e.length-1;t<e.length;s=t++){let o=e[t].x,a=e[t].y,A=e[s].x,l=e[s].y;a>i!=l>i&&n<(A-o)*(i-a)/(l-a)+o&&(r=!r)}return r}(t),azzera(){return e=[],this},truncatebefore:function truncatebefore(t){let n=new Linea2(e[0],e[1]),i=t.interseca(n);if(i){let t=e[0],n=e[1],r=n.x-t.x,s=n.y-t.y,o=r*r+s*s;if(o){if(((i.x-t.x)*r+(i.y-t.y)*s)/o<=1)return e[0]=i,this}}for(let n=1;n<e.length-1;n++){let i=new Linea2(e[n],e[n+1]),r=t.interseca(i);if(r&&i.onsegment(r))return e=e.slice(n),e[0]=r,this}return this},truncateafter:function truncateafter(t){let n=e.length,i=new Linea2(e[n-2],e[n-1]),r=t.interseca(i);if(r){let t=e[n-2],i=e[n-1],s=i.x-t.x,o=i.y-t.y,a=s*s+o*o;if(a){if(((r.x-t.x)*s+(r.y-t.y)*o)/a>=0)return e[n-1]=r,this}}for(let i=n-3;i>=0;i--){let n=new Linea2(e[i],e[i+1]),r=t.interseca(n);if(r&&n.onsegment(r))return e=e.slice(0,i+1),e.push(r),this}return this},removeduplicate(t=.005){return e=removeduplicate(e,t),this},to3d(t,n=0,i=0,r=0,s=!1,o=null,a=!1){let A=function to3dcoor(e,t){let{currentU:n=0,c:i=0,a:r=0,b:s=0,anglemin:o=30,open:a=!1,sh:A=null,invert:l=!1}=t;const c=[],p=e.length;for(let t=0;t<p;t++){const a=e[(t-1+p)%p],h=e[t],u=e[(t+1)%p],d={x:h.x-a.x,y:h.y-a.y},g={x:u.x-h.x,y:u.y-h.y},f=normal2(a,h),m=normal2(h,u),y=angle2vec(d,g);let b=r*h.x+s*h.y+i;if(A){let e=A.xfromy(h.y,0,!0);l?b+=e:b-=e}Math.abs(y-180)<=o?(f.nx,m.nx,f.ny,m.ny,c.push({x:h.x,y:-h.y,z:b,u:n,v:b})):(c.push({x:h.x,y:-h.y,z:b,u:n,v:b}),c.push({x:h.x,y:-h.y,z:b,u:n,v:b}));const I=u.x-h.x,x=u.y-h.y;n+=Math.sqrt(I*I+x*x)}if(!a){let e=c[0],t=c[c.length-1];e.x==t.x&&e.y==t.y||c.push({x:e.x,y:e.y,z:e.z,nx:e.nx,ny:e.ny,nz:e.nz,u:n,v:e.z})}return c}(e,{open:s,currentU:t,c:n,a:i,b:r,anglemin:30,sh:o,invert:a});return A},getboundbox:()=>e.length?e.reduce(((e,t)=>(e.p1.x=Math.min(e.p1.x,t.x),e.p1.y=Math.min(e.p1.y,t.y),e.p2.x=Math.max(e.p2.x,t.x),e.p2.y=Math.max(e.p2.y,t.y),e)),{p1:new Punto2(1/0,1/0),p2:new Punto2(-1/0,-1/0)}):{p1:new Punto2(0,0),p2:new Punto2(0,0)},fittobox(t,n){if(!e.length)return this;const i=this.getboundbox(),r=i.p2.x-i.p1.x,s=i.p2.y-i.p1.y,o=n.x-t.x,a=n.y-t.y,A=Math.min(o/(r||1),a/(s||1));for(let n of e)n.x=(n.x-i.p1.x)*A,n.y=(n.y-i.p1.y)*A,n.x+=t.x,n.y+=t.y;return this}}}function arcfrom3point(e,t,n,i){if(e<=0)return[t,i];if(1===e)return[t,n,i];const r=function findCircleCenter(e,t,n){const i=t.x*t.x+t.y*t.y,r=(e.x*e.x+e.y*e.y-i)/2,s=(i-n.x*n.x-n.y*n.y)/2,o=(e.x-t.x)*(t.y-n.y)-(t.x-n.x)*(e.y-t.y);return Math.abs(o)<1e-10?null:new Punto2((r*(t.y-n.y)-s*(e.y-t.y))/o,((e.x-t.x)*s-(t.x-n.x)*r)/o)}(t,n,i);if(!r){const n=[];for(let r=0;r<=e;r++){const s=r/e;n.push(new Punto2(t.x+(i.x-t.x)*s,t.y+(i.y-t.y)*s))}return n}let s=Math.atan2(t.y-r.y,t.x-r.x);Math.atan2(n.y-r.y,n.x-r.x);let o=Math.atan2(i.y-r.y,i.x-r.x);const a=(n.x-t.x)*(i.y-t.y)-(n.y-t.y)*(i.x-t.x),norm=e=>(e+2*Math.PI)%(2*Math.PI);s=norm(s),o=norm(o),a>0?o<s&&(o+=2*Math.PI):o>s&&(o-=2*Math.PI);const A=Math.hypot(t.x-r.x,t.y-r.y),l=(o-s)/e,c=[];for(let t=0;t<=e;t++){const e=s+l*t;c.push(new Punto2(r.x+A*Math.cos(e),r.y+A*Math.sin(e)))}return c}function getDefaultExportFromCjs(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var yt,bt={exports:{}};yt=bt,function(){var e,t={version:"6.4.2.2",use_lines:!0,use_xyz:!1},n=!1;if(yt.exports?(yt.exports=t,n=!0):"undefined"!=typeof document?window.ClipperLib=t:self.ClipperLib=t,n)i="chrome",e="Netscape";else{var i=navigator.userAgent.toString().toLowerCase();e=navigator.appName}var r,s={};function BigInteger(e,n,i){t.biginteger_used=1,null!=e&&("number"==typeof e&&void 0===n?this.fromInt(e):"number"==typeof e?this.fromNumber(e,n,i):null==n&&"string"!=typeof e?this.fromString(e,256):this.fromString(e,n))}function nbi(){return new BigInteger(null,void 0,void 0)}-1!=i.indexOf("chrome")&&-1==i.indexOf("chromium")?s.chrome=1:s.chrome=0,-1!=i.indexOf("chromium")?s.chromium=1:s.chromium=0,-1!=i.indexOf("safari")&&-1==i.indexOf("chrome")&&-1==i.indexOf("chromium")?s.safari=1:s.safari=0,-1!=i.indexOf("firefox")?s.firefox=1:s.firefox=0,-1!=i.indexOf("firefox/17")?s.firefox17=1:s.firefox17=0,-1!=i.indexOf("firefox/15")?s.firefox15=1:s.firefox15=0,-1!=i.indexOf("firefox/3")?s.firefox3=1:s.firefox3=0,-1!=i.indexOf("opera")?s.opera=1:s.opera=0,-1!=i.indexOf("msie 10")?s.msie10=1:s.msie10=0,-1!=i.indexOf("msie 9")?s.msie9=1:s.msie9=0,-1!=i.indexOf("msie 8")?s.msie8=1:s.msie8=0,-1!=i.indexOf("msie 7")?s.msie7=1:s.msie7=0,-1!=i.indexOf("msie ")?s.msie=1:s.msie=0,t.biginteger_used=null,"Microsoft Internet Explorer"==e?(BigInteger.prototype.am=function am2(e,t,n,i,r,s){for(var o=32767&t,a=t>>15;--s>=0;){var A=32767&this[e],l=this[e++]>>15,c=a*A+l*o;r=((A=o*A+((32767&c)<<15)+n[i]+(1073741823&r))>>>30)+(c>>>15)+a*l+(r>>>30),n[i++]=1073741823&A}return r},r=30):"Netscape"!=e?(BigInteger.prototype.am=function am1(e,t,n,i,r,s){for(;--s>=0;){var o=t*this[e++]+n[i]+r;r=Math.floor(o/67108864),n[i++]=67108863&o}return r},r=26):(BigInteger.prototype.am=function am3(e,t,n,i,r,s){for(var o=16383&t,a=t>>14;--s>=0;){var A=16383&this[e],l=this[e++]>>14,c=a*A+l*o;r=((A=o*A+((16383&c)<<14)+n[i]+r)>>28)+(c>>14)+a*l,n[i++]=268435455&A}return r},r=28),BigInteger.prototype.DB=r,BigInteger.prototype.DM=(1<<r)-1,BigInteger.prototype.DV=1<<r,BigInteger.prototype.FV=Math.pow(2,52),BigInteger.prototype.F1=52-r,BigInteger.prototype.F2=2*r-52;var o,a,A=new Array;for(o="0".charCodeAt(0),a=0;a<=9;++a)A[o++]=a;for(o="a".charCodeAt(0),a=10;a<36;++a)A[o++]=a;for(o="A".charCodeAt(0),a=10;a<36;++a)A[o++]=a;function int2char(e){return"0123456789abcdefghijklmnopqrstuvwxyz".charAt(e)}function intAt(e,t){var n=A[e.charCodeAt(t)];return null==n?-1:n}function nbv(e){var t=nbi();return t.fromInt(e),t}function nbits(e){var t,n=1;return 0!=(t=e>>>16)&&(e=t,n+=16),0!=(t=e>>8)&&(e=t,n+=8),0!=(t=e>>4)&&(e=t,n+=4),0!=(t=e>>2)&&(e=t,n+=2),0!=(t=e>>1)&&(e=t,n+=1),n}function Classic(e){this.m=e}function Montgomery(e){this.m=e,this.mp=e.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<<e.DB-15)-1,this.mt2=2*e.t}function op_and(e,t){return e&t}function op_or(e,t){return e|t}function op_xor(e,t){return e^t}function op_andnot(e,t){return e&~t}function lbit(e){if(0==e)return-1;var t=0;return 65535&e||(e>>=16,t+=16),255&e||(e>>=8,t+=8),15&e||(e>>=4,t+=4),3&e||(e>>=2,t+=2),1&e||++t,t}function cbit(e){for(var t=0;0!=e;)e&=e-1,++t;return t}function NullExp(){}function nNop(e){return e}function Barrett(e){this.r2=nbi(),this.q3=nbi(),BigInteger.ONE.dlShiftTo(2*e.t,this.r2),this.mu=this.r2.divide(e),this.m=e}Classic.prototype.convert=function cConvert(e){return e.s<0||e.compareTo(this.m)>=0?e.mod(this.m):e},Classic.prototype.revert=function cRevert(e){return e},Classic.prototype.reduce=function cReduce(e){e.divRemTo(this.m,null,e)},Classic.prototype.mulTo=function cMulTo(e,t,n){e.multiplyTo(t,n),this.reduce(n)},Classic.prototype.sqrTo=function cSqrTo(e,t){e.squareTo(t),this.reduce(t)},Montgomery.prototype.convert=function montConvert(e){var t=nbi();return e.abs().dlShiftTo(this.m.t,t),t.divRemTo(this.m,null,t),e.s<0&&t.compareTo(BigInteger.ZERO)>0&&this.m.subTo(t,t),t},Montgomery.prototype.revert=function montRevert(e){var t=nbi();return e.copyTo(t),this.reduce(t),t},Montgomery.prototype.reduce=function montReduce(e){for(;e.t<=this.mt2;)e[e.t++]=0;for(var t=0;t<this.m.t;++t){var n=32767&e[t],i=n*this.mpl+((n*this.mph+(e[t]>>15)*this.mpl&this.um)<<15)&e.DM;for(e[n=t+this.m.t]+=this.m.am(0,i,e,t,0,this.m.t);e[n]>=e.DV;)e[n]-=e.DV,e[++n]++}e.clamp(),e.drShiftTo(this.m.t,e),e.compareTo(this.m)>=0&&e.subTo(this.m,e)},Montgomery.prototype.mulTo=function montMulTo(e,t,n){e.multiplyTo(t,n),this.reduce(n)},Montgomery.prototype.sqrTo=function montSqrTo(e,t){e.squareTo(t),this.reduce(t)},BigInteger.prototype.copyTo=function bnpCopyTo(e){for(var t=this.t-1;t>=0;--t)e[t]=this[t];e.t=this.t,e.s=this.s},BigInteger.prototype.fromInt=function bnpFromInt(e){this.t=1,this.s=e<0?-1:0,e>0?this[0]=e:e<-1?this[0]=e+this.DV:this.t=0},BigInteger.prototype.fromString=function bnpFromString(e,t){var n;if(16==t)n=4;else if(8==t)n=3;else if(256==t)n=8;else if(2==t)n=1;else if(32==t)n=5;else{if(4!=t)return void this.fromRadix(e,t);n=2}this.t=0,this.s=0;for(var i=e.length,r=!1,s=0;--i>=0;){var o=8==n?255&e[i]:intAt(e,i);o<0?"-"==e.charAt(i)&&(r=!0):(r=!1,0==s?this[this.t++]=o:s+n>this.DB?(this[this.t-1]|=(o&(1<<this.DB-s)-1)<<s,this[this.t++]=o>>this.DB-s):this[this.t-1]|=o<<s,(s+=n)>=this.DB&&(s-=this.DB))}8==n&&128&e[0]&&(this.s=-1,s>0&&(this[this.t-1]|=(1<<this.DB-s)-1<<s)),this.clamp(),r&&BigInteger.ZERO.subTo(this,this)},BigInteger.prototype.clamp=function bnpClamp(){for(var e=this.s&this.DM;this.t>0&&this[this.t-1]==e;)--this.t},BigInteger.prototype.dlShiftTo=function bnpDLShiftTo(e,t){var n;for(n=this.t-1;n>=0;--n)t[n+e]=this[n];for(n=e-1;n>=0;--n)t[n]=0;t.t=this.t+e,t.s=this.s},BigInteger.prototype.drShiftTo=function bnpDRShiftTo(e,t){for(var n=e;n<this.t;++n)t[n-e]=this[n];t.t=Math.max(this.t-e,0),t.s=this.s},BigInteger.prototype.lShiftTo=function bnpLShiftTo(e,t){var n,i=e%this.DB,r=this.DB-i,s=(1<<r)-1,o=Math.floor(e/this.DB),a=this.s<<i&this.DM;for(n=this.t-1;n>=0;--n)t[n+o+1]=this[n]>>r|a,a=(this[n]&s)<<i;for(n=o-1;n>=0;--n)t[n]=0;t[o]=a,t.t=this.t+o+1,t.s=this.s,t.clamp()},BigInteger.prototype.rShiftTo=function bnpRShiftTo(e,t){t.s=this.s;var n=Math.floor(e/this.DB);if(n>=this.t)t.t=0;else{var i=e%this.DB,r=this.DB-i,s=(1<<i)-1;t[0]=this[n]>>i;for(var o=n+1;o<this.t;++o)t[o-n-1]|=(this[o]&s)<<r,t[o-n]=this[o]>>i;i>0&&(t[this.t-n-1]|=(this.s&s)<<r),t.t=this.t-n,t.clamp()}},BigInteger.prototype.subTo=function bnpSubTo(e,t){for(var n=0,i=0,r=Math.min(e.t,this.t);n<r;)i+=this[n]-e[n],t[n++]=i&this.DM,i>>=this.DB;if(e.t<this.t){for(i-=e.s;n<this.t;)i+=this[n],t[n++]=i&this.DM,i>>=this.DB;i+=this.s}else{for(i+=this.s;n<e.t;)i-=e[n],t[n++]=i&this.DM,i>>=this.DB;i-=e.s}t.s=i<0?-1:0,i<-1?t[n++]=this.DV+i:i>0&&(t[n++]=i),t.t=n,t.clamp()},BigInteger.prototype.multiplyTo=function bnpMultiplyTo(e,t){var n=this.abs(),i=e.abs(),r=n.t;for(t.t=r+i.t;--r>=0;)t[r]=0;for(r=0;r<i.t;++r)t[r+n.t]=n.am(0,i[r],t,r,0,n.t);t.s=0,t.clamp(),this.s!=e.s&&BigInteger.ZERO.subTo(t,t)},BigInteger.prototype.squareTo=function bnpSquareTo(e){for(var t=this.abs(),n=e.t=2*t.t;--n>=0;)e[n]=0;for(n=0;n<t.t-1;++n){var i=t.am(n,t[n],e,2*n,0,1);(e[n+t.t]+=t.am(n+1,2*t[n],e,2*n+1,i,t.t-n-1))>=t.DV&&(e[n+t.t]-=t.DV,e[n+t.t+1]=1)}e.t>0&&(e[e.t-1]+=t.am(n,t[n],e,2*n,0,1)),e.s=0,e.clamp()},BigInteger.prototype.divRemTo=function bnpDivRemTo(e,t,n){var i=e.abs();if(!(i.t<=0)){var r=this.abs();if(r.t<i.t)return null!=t&&t.fromInt(0),void(null!=n&&this.copyTo(n));null==n&&(n=nbi());var s=nbi(),o=this.s,a=e.s,A=this.DB-nbits(i[i.t-1]);A>0?(i.lShiftTo(A,s),r.lShiftTo(A,n)):(i.copyTo(s),r.copyTo(n));var l=s.t,c=s[l-1];if(0!=c){var p=c*(1<<this.F1)+(l>1?s[l-2]>>this.F2:0),h=this.FV/p,u=(1<<this.F1)/p,d=1<<this.F2,g=n.t,f=g-l,m=null==t?nbi():t;for(s.dlShiftTo(f,m),n.compareTo(m)>=0&&(n[n.t++]=1,n.subTo(m,n)),BigInteger.ONE.dlShiftTo(l,m),m.subTo(s,s);s.t<l;)s[s.t++]=0;for(;--f>=0;){var y=n[--g]==c?this.DM:Math.floor(n[g]*h+(n[g-1]+d)*u);if((n[g]+=s.am(0,y,n,f,0,l))<y)for(s.dlShiftTo(f,m),n.subTo(m,n);n[g]<--y;)n.subTo(m,n)}null!=t&&(n.drShiftTo(l,t),o!=a&&BigInteger.ZERO.subTo(t,t)),n.t=l,n.clamp(),A>0&&n.rShiftTo(A,n),o<0&&BigInteger.ZERO.subTo(n,n)}}},BigInteger.prototype.invDigit=function bnpInvDigit(){if(this.t<1)return 0;var e=this[0];if(!(1&e))return 0;var t=3&e;return(t=(t=(t=(t=t*(2-(15&e)*t)&15)*(2-(255&e)*t)&255)*(2-((65535&e)*t&65535))&65535)*(2-e*t%this.DV)%this.DV)>0?this.DV-t:-t},BigInteger.prototype.isEven=function bnpIsEven(){return 0==(this.t>0?1&this[0]:this.s)},BigInteger.prototype.exp=function bnpExp(e,t){if(e>4294967295||e<1)return BigInteger.ONE;var n=nbi(),i=nbi(),r=t.convert(this),s=nbits(e)-1;for(r.copyTo(n);--s>=0;)if(t.sqrTo(n,i),(e&1<<s)>0)t.mulTo(i,r,n);else{var o=n;n=i,i=o}return t.revert(n)},BigInteger.prototype.toString=function bnToString(e){if(this.s<0)return"-"+this.negate().toString(e);var t;if(16==e)t=4;else if(8==e)t=3;else if(2==e)t=1;else if(32==e)t=5;else{if(4!=e)return this.toRadix(e);t=2}var n,i=(1<<t)-1,r=!1,s="",o=this.t,a=this.DB-o*this.DB%t;if(o-- >0)for(a<this.DB&&(n=this[o]>>a)>0&&(r=!0,s=int2char(n));o>=0;)a<t?(n=(this[o]&(1<<a)-1)<<t-a,n|=this[--o]>>(a+=this.DB-t)):(n=this[o]>>(a-=t)&i,a<=0&&(a+=this.DB,--o)),n>0&&(r=!0),r&&(s+=int2char(n));return r?s:"0"},BigInteger.prototype.negate=function bnNegate(){var e=nbi();return BigInteger.ZERO.subTo(this,e),e},BigInteger.prototype.abs=function bnAbs(){return this.s<0?this.negate():this},BigInteger.prototype.compareTo=function bnCompareTo(e){var t=this.s-e.s;if(0!=t)return t;var n=this.t;if(0!=(t=n-e.t))return this.s<0?-t:t;for(;--n>=0;)if(0!=(t=this[n]-e[n]))return t;return 0},BigInteger.prototype.bitLength=function bnBitLength(){return this.t<=0?0:this.DB*(this.t-1)+nbits(this[this.t-1]^this.s&this.DM)},BigInteger.prototype.mod=function bnMod(e){var t=nbi();return this.abs().divRemTo(e,null,t),this.s<0&&t.compareTo(BigInteger.ZERO)>0&&e.subTo(t,t),t},BigInteger.prototype.modPowInt=function bnModPowInt(e,t){var n;return n=e<256||t.isEven()?new Classic(t):new Montgomery(t),this.exp(e,n)},BigInteger.ZERO=nbv(0),BigInteger.ONE=nbv(1),NullExp.prototype.convert=nNop,NullExp.prototype.revert=nNop,NullExp.prototype.mulTo=function nMulTo(e,t,n){e.multiplyTo(t,n)},NullExp.prototype.sqrTo=function nSqrTo(e,t){e.squareTo(t)},Barrett.prototype.convert=function barrettConvert(e){if(e.s<0||e.t>2*this.m.t)return e.mod(this.m);if(e.compareTo(this.m)<0)return e;var t=nbi();return e.copyTo(t),this.reduce(t),t},Barrett.prototype.revert=function barrettRevert(e){return e},Barrett.prototype.reduce=function barrettReduce(e){for(e.drShiftTo(this.m.t-1,this.r2),e.t>this.m.t+1&&(e.t=this.m.t+1,e.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);e.compareTo(this.r2)<0;)e.dAddOffset(1,this.m.t+1);for(e.subTo(this.r2,e);e.compareTo(this.m)>=0;)e.subTo(this.m,e)},Barrett.prototype.mulTo=function barrettMulTo(e,t,n){e.multiplyTo(t,n),this.reduce(n)},Barrett.prototype.sqrTo=function barrettSqrTo(e,t){e.squareTo(t),this.reduce(t)};var l=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],c=(1<<26)/l[l.length-1];BigInteger.prototype.chunkSize=function bnpChunkSize(e){return Math.floor(Math.LN2*this.DB/Math.log(e))},BigInteger.prototype.toRadix=function bnpToRadix(e){if(null==e&&(e=10),0==this.signum()||e<2||e>36)return"0";var t=this.chunkSize(e),n=Math.pow(e,t),i=nbv(n),r=nbi(),s=nbi(),o="";for(this.divRemTo(i,r,s);r.signum()>0;)o=(n+s.intValue()).toString(e).substr(1)+o,r.divRemTo(i,r,s);return s.intValue().toString(e)+o},BigInteger.prototype.fromRadix=function bnpFromRadix(e,t){this.fromInt(0),null==t&&(t=10);for(var n=this.chunkSize(t),i=Math.pow(t,n),r=!1,s=0,o=0,a=0;a<e.length;++a){var A=intAt(e,a);A<0?"-"==e.charAt(a)&&0==this.signum()&&(r=!0):(o=t*o+A,++s>=n&&(this.dMultiply(i),this.dAddOffset(o,0),s=0,o=0))}s>0&&(this.dMultiply(Math.pow(t,s)),this.dAddOffset(o,0)),r&&BigInteger.ZERO.subTo(this,this)},BigInteger.prototype.fromNumber=function bnpFromNumber(e,t,n){if("number"==typeof t)if(e<2)this.fromInt(1);else for(this.fromNumber(e,n),this.testBit(e-1)||this.bitwiseTo(BigInteger.ONE.shiftLeft(e-1),op_or,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(t);)this.dAddOffset(2,0),this.bitLength()>e&&this.subTo(BigInteger.ONE.shiftLeft(e-1),this);else{var i=new Array,r=7&e;i.length=1+(e>>3),t.nextBytes(i),r>0?i[0]&=(1<<r)-1:i[0]=0,this.fromString(i,256)}},BigInteger.prototype.bitwiseTo=function bnpBitwiseTo(e,t,n){var i,r,s=Math.min(e.t,this.t);for(i=0;i<s;++i)n[i]=t(this[i],e[i]);if(e.t<this.t){for(r=e.s&this.DM,i=s;i<this.t;++i)n[i]=t(this[i],r);n.t=this.t}else{for(r=this.s&this.DM,i=s;i<e.t;++i)n[i]=t(r,e[i]);n.t=e.t}n.s=t(this.s,e.s),n.clamp()},BigInteger.prototype.changeBit=function bnpChangeBit(e,t){var n=BigInteger.ONE.shiftLeft(e);return this.bitwiseTo(n,t,n),n},BigInteger.prototype.addTo=function bnpAddTo(e,t){for(var n=0,i=0,r=Math.min(e.t,this.t);n<r;)i+=this[n]+e[n],t[n++]=i&this.DM,i>>=this.DB;if(e.t<this.t){for(i+=e.s;n<this.t;)i+=this[n],t[n++]=i&this.DM,i>>=this.DB;i+=this.s}else{for(i+=this.s;n<e.t;)i+=e[n],t[n++]=i&this.DM,i>>=this.DB;i+=e.s}t.s=i<0?-1:0,i>0?t[n++]=i:i<-1&&(t[n++]=this.DV+i),t.t=n,t.clamp()},BigInteger.prototype.dMultiply=function bnpDMultiply(e){this[this.t]=this.am(0,e-1,this,0,0,this.t),++this.t,this.clamp()},BigInteger.prototype.dAddOffset=function bnpDAddOffset(e,t){if(0!=e){for(;this.t<=t;)this[this.t++]=0;for(this[t]+=e;this[t]>=this.DV;)this[t]-=this.DV,++t>=this.t&&(this[this.t++]=0),++this[t]}},BigInteger.prototype.multiplyLowerTo=function bnpMultiplyLowerTo(e,t,n){var i,r=Math.min(this.t+e.t,t);for(n.s=0,n.t=r;r>0;)n[--r]=0;for(i=n.t-this.t;r<i;++r)n[r+this.t]=this.am(0,e[r],n,r,0,this.t);for(i=Math.min(e.t,t);r<i;++r)this.am(0,e[r],n,r,0,t-r);n.clamp()},BigInteger.prototype.multiplyUpperTo=function bnpMultiplyUpperTo(e,t,n){--t;var i=n.t=this.t+e.t-t;for(n.s=0;--i>=0;)n[i]=0;for(i=Math.max(t-this.t,0);i<e.t;++i)n[this.t+i-t]=this.am(t-i,e[i],n,0,0,this.t+i-t);n.clamp(),n.drShiftTo(1,n)},BigInteger.prototype.modInt=function bnpModInt(e){if(e<=0)return 0;var t=this.DV%e,n=this.s<0?e-1:0;if(this.t>0)if(0==t)n=this[0]%e;else for(var i=this.t-1;i>=0;--i)n=(t*n+this[i])%e;return n},BigInteger.prototype.millerRabin=function bnpMillerRabin(e){var t=this.subtract(BigInteger.ONE),n=t.getLowestSetBit();if(n<=0)return!1;var i=t.shiftRight(n);(e=e+1>>1)>l.length&&(e=l.length);for(var r=nbi(),s=0;s<e;++s){r.fromInt(l[Math.floor(Math.random()*l.length)]);var o=r.modPow(i,this);if(0!=o.compareTo(BigInteger.ONE)&&0!=o.compareTo(t)){for(var a=1;a++<n&&0!=o.compareTo(t);)if(0==(o=o.modPowInt(2,this)).compareTo(BigInteger.ONE))return!1;if(0!=o.compareTo(t))return!1}}return!0},BigInteger.prototype.clone=function bnClone(){var e=nbi();return this.copyTo(e),e},BigInteger.prototype.intValue=function bnIntValue(){if(this.s<0){if(1==this.t)return this[0]-this.DV;if(0==this.t)return-1}else{if(1==this.t)return this[0];if(0==this.t)return 0}return(this[1]&(1<<32-this.DB)-1)<<this.DB|this[0]},BigInteger.prototype.byteValue=function bnByteValue(){return 0==this.t?this.s:this[0]<<24>>24},BigInteger.prototype.shortValue=function bnShortValue(){return 0==this.t?this.s:this[0]<<16>>16},BigInteger.prototype.signum=function bnSigNum(){return this.s<0?-1:this.t<=0||1==this.t&&this[0]<=0?0:1},BigInteger.prototype.toByteArray=function bnToByteArray(){var e=this.t,t=new Array;t[0]=this.s;var n,i=this.DB-e*this.DB%8,r=0;if(e-- >0)for(i<this.DB&&(n=this[e]>>i)!=(this.s&this.DM)>>i&&(t[r++]=n|this.s<<this.DB-i);e>=0;)i<8?(n=(this[e]&(1<<i)-1)<<8-i,n|=this[--e]>>(i+=this.DB-8)):(n=this[e]>>(i-=8)&255,i<=0&&(i+=this.DB,--e)),128&n&&(n|=-256),0==r&&(128&this.s)!=(128&n)&&++r,(r>0||n!=this.s)&&(t[r++]=n);return t},BigInteger.prototype.equals=function bnEquals(e){return 0==this.compareTo(e)},BigInteger.prototype.min=function bnMin(e){return this.compareTo(e)<0?this:e},BigInteger.prototype.max=function bnMax(e){return this.compareTo(e)>0?this:e},BigInteger.prototype.and=function bnAnd(e){var t=nbi();return this.bitwiseTo(e,op_and,t),t},BigInteger.prototype.or=function bnOr(e){var t=nbi();return this.bitwiseTo(e,op_or,t),t},BigInteger.prototype.xor=function bnXor(e){var t=nbi();return this.bitwiseTo(e,op_xor,t),t},BigInteger.prototype.andNot=function bnAndNot(e){var t=nbi();return this.bitwiseTo(e,op_andnot,t),t},BigInteger.prototype.not=function bnNot(){for(var e=nbi(),t=0;t<this.t;++t)e[t]=this.DM&~this[t];return e.t=this.t,e.s=~this.s,e},BigInteger.prototype.shiftLeft=function bnShiftLeft(e){var t=nbi();return e<0?this.rShiftTo(-e,t):this.lShiftTo(e,t),t},BigInteger.prototype.shiftRight=function bnShiftRight(e){var t=nbi();return e<0?this.lShiftTo(-e,t):this.rShiftTo(e,t),t},BigInteger.prototype.getLowestSetBit=function bnGetLowestSetBit(){for(var e=0;e<this.t;++e)if(0!=this[e])return e*this.DB+lbit(this[e]);return this.s<0?this.t*this.DB:-1},BigInteger.prototype.bitCount=function bnBitCount(){for(var e=0,t=this.s&this.DM,n=0;n<this.t;++n)e+=cbit(this[n]^t);return e},BigInteger.prototype.testBit=function bnTestBit(e){var t=Math.floor(e/this.DB);return t>=this.t?0!=this.s:!!(this[t]&1<<e%this.DB)},BigInteger.prototype.setBit=function bnSetBit(e){return this.changeBit(e,op_or)},BigInteger.prototype.clearBit=function bnClearBit(e){return this.changeBit(e,op_andnot)},BigInteger.prototype.flipBit=function bnFlipBit(e){return this.changeBit(e,op_xor)},BigInteger.prototype.add=function bnAdd(e){var t=nbi();return this.addTo(e,t),t},BigInteger.prototype.subtract=function bnSubtract(e){var t=nbi();return this.subTo(e,t),t},BigInteger.prototype.multiply=function bnMultiply(e){var t=nbi();return this.multiplyTo(e,t),t},BigInteger.prototype.divide=function bnDivide(e){var t=nbi();return this.divRemTo(e,t,null),t},BigInteger.prototype.remainder=function bnRemainder(e){var t=nbi();return this.divRemTo(e,null,t),t},BigInteger.prototype.divideAndRemainder=function bnDivideAndRemainder(e){var t=nbi(),n=nbi();return this.divRemTo(e,t,n),new Array(t,n)},BigInteger.prototype.modPow=function bnModPow(e,t){var n,i,r=e.bitLength(),s=nbv(1);if(r<=0)return s;n=r<18?1:r<48?3:r<144?4:r<768?5:6,i=r<8?new Classic(t):t.isEven()?new Barrett(t):new Montgomery(t);var o=new Array,a=3,A=n-1,l=(1<<n)-1;if(o[1]=i.convert(this),n>1){var c=nbi();for(i.sqrTo(o[1],c);a<=l;)o[a]=nbi(),i.mulTo(c,o[a-2],o[a]),a+=2}var p,h,u=e.t-1,d=!0,g=nbi();for(r=nbits(e[u])-1;u>=0;){for(r>=A?p=e[u]>>r-A&l:(p=(e[u]&(1<<r+1)-1)<<A-r,u>0&&(p|=e[u-1]>>this.DB+r-A)),a=n;!(1&p);)p>>=1,--a;if((r-=a)<0&&(r+=this.DB,--u),d)o[p].copyTo(s),d=!1;else{for(;a>1;)i.sqrTo(s,g),i.sqrTo(g,s),a-=2;a>0?i.sqrTo(s,g):(h=s,s=g,g=h),i.mulTo(g,o[p],s)}for(;u>=0&&!(e[u]&1<<r);)i.sqrTo(s,g),h=s,s=g,g=h,--r<0&&(r=this.DB-1,--u)}return i.revert(s)},BigInteger.prototype.modInverse=function bnModInverse(e){var t=e.isEven();if(this.isEven()&&t||0==e.signum())return BigInteger.ZERO;for(var n=e.clone(),i=this.clone(),r=nbv(1),s=nbv(0),o=nbv(0),a=nbv(1);0!=n.signum();){for(;n.isEven();)n.rShiftTo(1,n),t?(r.isEven()&&s.isEven()||(r.addTo(this,r),s.subTo(e,s)),r.rShiftTo(1,r)):s.isEven()||s.subTo(e,s),s.rShiftTo(1,s);for(;i.isEven();)i.rShiftTo(1,i),t?(o.isEven()&&a.isEven()||(o.addTo(this,o),a.subTo(e,a)),o.rShiftTo(1,o)):a.isEven()||a.subTo(e,a),a.rShiftTo(1,a);n.compareTo(i)>=0?(n.subTo(i,n),t&&r.subTo(o,r),s.subTo(a,s)):(i.subTo(n,i),t&&o.subTo(r,o),a.subTo(s,a))}return 0!=i.compareTo(BigInteger.ONE)?BigInteger.ZERO:a.compareTo(e)>=0?a.subtract(e):a.signum()<0?(a.addTo(e,a),a.signum()<0?a.add(e):a):a},BigInteger.prototype.pow=function bnPow(e){return this.exp(e,new NullExp)},BigInteger.prototype.gcd=function bnGCD(e){var t=this.s<0?this.negate():this.clone(),n=e.s<0?e.negate():e.clone();if(t.compareTo(n)<0){var i=t;t=n,n=i}var r=t.getLowestSetBit(),s=n.getLowestSetBit();if(s<0)return t;for(r<s&&(s=r),s>0&&(t.rShiftTo(s,t),n.rShiftTo(s,n));t.signum()>0;)(r=t.getLowestSetBit())>0&&t.rShiftTo(r,t),(r=n.getLowestSetBit())>0&&n.rShiftTo(r,n),t.compareTo(n)>=0?(t.subTo(n,t),t.rShiftTo(1,t)):(n.subTo(t,n),n.rShiftTo(1,n));return s>0&&n.lShiftTo(s,n),n},BigInteger.prototype.isProbablePrime=function bnIsProbablePrime(e){var t,n=this.abs();if(1==n.t&&n[0]<=l[l.length-1]){for(t=0;t<l.length;++t)if(n[0]==l[t])return!0;return!1}if(n.isEven())return!1;for(t=1;t<l.length;){for(var i=l[t],r=t+1;r<l.length&&i<c;)i*=l[r++];for(i=n.modInt(i);t<r;)if(i%l[t++]==0)return!1}return n.millerRabin(e)},BigInteger.prototype.square=function bnSquare(){var e=nbi();return this.squareTo(e),e};var p=BigInteger;p.prototype.IsNegative=function(){return-1==this.compareTo(p.ZERO)},p.op_Equality=function(e,t){return 0==e.compareTo(t)},p.op_Inequality=function(e,t){return 0!=e.compareTo(t)},p.op_GreaterThan=function(e,t){return e.compareTo(t)>0},p.op_LessThan=function(e,t){return e.compareTo(t)<0},p.op_Addition=function(e,t){return new p(e,void 0,void 0).add(new p(t,void 0,void 0))},p.op_Subtraction=function(e,t){return new p(e,void 0,void 0).subtract(new p(t,void 0,void 0))},p.Int128Mul=function(e,t){return new p(e,void 0,void 0).multiply(new p(t,void 0,void 0))},p.op_Division=function(e,t){return e.divide(t)},p.prototype.ToDouble=function(){return parseFloat(this.toString())};var Inherit=function(e,t){var n;if(void 0===Object.getOwnPropertyNames){for(n in t.prototype)void 0!==e.prototype[n]&&e.prototype[n]!==Object.prototype[n]||(e.prototype[n]=t.prototype[n]);for(n in t)void 0===e[n]&&(e[n]=t[n]);e.$baseCtor=t}else{for(var i=Object.getOwnPropertyNames(t.prototype),r=0;r<i.length;r++)void 0===Object.getOwnPropertyDescriptor(e.prototype,i[r])&&Object.defineProperty(e.prototype,i[r],Object.getOwnPropertyDescriptor(t.prototype,i[r]));for(n in t)void 0===e[n]&&(e[n]=t[n]);e.$baseCtor=t}};t.Path=function(){return[]},t.Path.prototype.push=Array.prototype.push,t.Paths=function(){return[]},t.Paths.prototype.push=Array.prototype.push,t.DoublePoint=function(){var e=arguments;this.X=0,this.Y=0,1===e.length?(this.X=e[0].X,this.Y=e[0].Y):2===e.length&&(this.X=e[0],this.Y=e[1])},t.DoublePoint0=function(){this.X=0,this.Y=0},t.DoublePoint0.prototype=t.DoublePoint.prototype,t.DoublePoint1=function(e){this.X=e.X,this.Y=e.Y},t.DoublePoint1.prototype=t.DoublePoint.prototype,t.DoublePoint2=function(e,t){this.X=e,this.Y=t},t.DoublePoint2.prototype=t.DoublePoint.prototype,t.PolyNode=function(){this.m_Parent=null,this.m_polygon=new t.Path,this.m_Index=0,this.m_jointype=0,this.m_endtype=0,this.m_Childs=[],this.IsOpen=!1},t.PolyNode.prototype.IsHoleNode=function(){for(var e=!0,t=this.m_Parent;null!==t;)e=!e,t=t.m_Parent;return e},t.PolyNode.prototype.ChildCount=function(){return this.m_Childs.length},t.PolyNode.prototype.Contour=function(){return this.m_polygon},t.PolyNode.prototype.AddChild=function(e){var t=this.m_Childs.length;this.m_Childs.push(e),e.m_Parent=this,e.m_Index=t},t.PolyNode.prototype.GetNext=function(){return this.m_Childs.length>0?this.m_Childs[0]:this.GetNextSiblingUp()},t.PolyNode.prototype.GetNextSiblingUp=function(){return null===this.m_Parent?null:this.m_Index===this.m_Parent.m_Childs.length-1?this.m_Parent.GetNextSiblingUp():this.m_Parent.m_Childs[this.m_Index+1]},t.PolyNode.prototype.Childs=function(){return this.m_Childs},t.PolyNode.prototype.Parent=function(){return this.m_Parent},t.PolyNode.prototype.IsHole=function(){return this.IsHoleNode()},t.PolyTree=function(){this.m_AllPolys=[],t.PolyNode.call(this)},t.PolyTree.prototype.Clear=function(){for(var e=0,t=this.m_AllPolys.length;e<t;e++)this.m_AllPolys[e]=null;this.m_AllPolys.length=0,this.m_Childs.length=0},t.PolyTree.prototype.GetFirst=function(){return this.m_Childs.length>0?this.m_Childs[0]:null},t.PolyTree.prototype.Total=function(){var e=this.m_AllPolys.length;return e>0&&this.m_Childs[0]!==this.m_AllPolys[0]&&e--,e},Inherit(t.PolyTree,t.PolyNode),t.Math_Abs_Int64=t.Math_Abs_Int32=t.Math_Abs_Double=function(e){return Math.abs(e)},t.Math_Max_Int32_Int32=function(e,t){return Math.max(e,t)},s.msie||s.opera||s.safari?t.Cast_Int32=function(e){return 0|e}:t.Cast_Int32=function(e){return~~e},void 0===Number.toInteger&&(Number.toInteger=null),s.chrome?t.Cast_Int64=function(e){return e<-2147483648||e>2147483647?e<0?Math.ceil(e):Math.floor(e):~~e}:s.firefox&&"function"==typeof Number.toInteger?t.Cast_Int64=function(e){return Number.toInteger(e)}:s.msie7||s.msie8?t.Cast_Int64=function(e){return parseInt(e,10)}:s.msie?t.Cast_Int64=function(e){return e<-2147483648||e>2147483647?e<0?Math.ceil(e):Math.floor(e):0|e}:t.Cast_Int64=function(e){return e<0?Math.ceil(e):Math.floor(e)},t.Clear=function(e){e.length=0},t.PI=3.141592653589793,t.PI2=6.283185307179586,t.IntPoint=function(){var e=arguments,n=e.length;if(this.X=0,this.Y=0,t.use_xyz)if(this.Z=0,3===n)this.X=e[0],this.Y=e[1],this.Z=e[2];else if(2===n)this.X=e[0],this.Y=e[1],this.Z=0;else if(1===n)if(e[0]instanceof t.DoublePoint){var i=e[0];this.X=t.Clipper.Round(i.X),this.Y=t.Clipper.Round(i.Y),this.Z=0}else void 0===(r=e[0]).Z&&(r.Z=0),this.X=r.X,this.Y=r.Y,this.Z=r.Z;else this.X=0,this.Y=0,this.Z=0;else if(2===n)this.X=e[0],this.Y=e[1];else if(1===n)if(e[0]instanceof t.DoublePoint)i=e[0],this.X=t.Clipper.Round(i.X),this.Y=t.Clipper.Round(i.Y);else{var r=e[0];this.X=r.X,this.Y=r.Y}else this.X=0,this.Y=0},t.IntPoint.op_Equality=function(e,t){return e.X===t.X&&e.Y===t.Y},t.IntPoint.op_Inequality=function(e,t){return e.X!==t.X||e.Y!==t.Y},t.IntPoint0=function(){this.X=0,this.Y=0,t.use_xyz&&(this.Z=0)},t.IntPoint0.prototype=t.IntPoint.prototype,t.IntPoint1=function(e){this.X=e.X,this.Y=e.Y,t.use_xyz&&(void 0===e.Z?this.Z=0:this.Z=e.Z)},t.IntPoint1.prototype=t.IntPoint.prototype,t.IntPoint1dp=function(e){this.X=t.Clipper.Round(e.X),this.Y=t.Clipper.Round(e.Y),t.use_xyz&&(this.Z=0)},t.IntPoint1dp.prototype=t.IntPoint.prototype,t.IntPoint2=function(e,n,i){this.X=e,this.Y=n,t.use_xyz&&(this.Z=void 0===i?0:i)},t.IntPoint2.prototype=t.IntPoint.prototype,t.IntRect=function(){var e=arguments,t=e.length;if(4===t)this.left=e[0],this.top=e[1],this.right=e[2],this.bottom=e[3];else if(1===t){var n=e[0];this.left=n.left,this.top=n.top,this.right=n.right,this.bottom=n.bottom}else this.left=0,this.top=0,this.right=0,this.bottom=0},t.IntRect0=function(){this.left=0,this.top=0,this.right=0,this.bottom=0},t.IntRect0.prototype=t.IntRect.prototype,t.IntRect1=function(e){this.left=e.left,this.top=e.top,this.right=e.right,this.bottom=e.bottom},t.IntRect1.prototype=t.IntRect.prototype,t.IntRect4=function(e,t,n,i){this.left=e,this.top=t,this.right=n,this.bottom=i},t.IntRect4.prototype=t.IntRect.prototype,t.ClipType={ctIntersection:0,ctUnion:1,ctDifference:2,ctXor:3},t.PolyType={ptSubject:0,ptClip:1},t.PolyFillType={pftEvenOdd:0,pftNonZero:1,pftPositive:2,pftNegative:3},t.JoinType={jtSquare:0,jtRound:1,jtMiter:2},t.EndType={etOpenSquare:0,etOpenRound:1,etOpenButt:2,etClosedLine:3,etClosedPolygon:4},t.EdgeSide={esLeft:0,esRight:1},t.Direction={dRightToLeft:0,dLeftToRight:1},t.TEdge=function(){this.Bot=new t.IntPoint0,this.Curr=new t.IntPoint0,this.Top=new t.IntPoint0,this.Delta=new t.IntPoint0,this.Dx=0,this.PolyTyp=t.PolyType.ptSubject,this.Side=t.EdgeSide.esLeft,this.WindDelta=0,this.WindCnt=0,this.WindCnt2=0,this.OutIdx=0,this.Next=null,this.Prev=null,this.NextInLML=null,this.NextInAEL=null,this.PrevInAEL=null,this.NextInSEL=null,this.PrevInSEL=null},t.IntersectNode=function(){this.Edge1=null,this.Edge2=null,this.Pt=new t.IntPoint0},t.MyIntersectNodeSort=function(){},t.MyIntersectNodeSort.Compare=function(e,t){var n=t.Pt.Y-e.Pt.Y;return n>0?1:n<0?-1:0},t.LocalMinima=function(){this.Y=0,this.LeftBound=null,this.RightBound=null,this.Next=null},t.Scanbeam=function(){this.Y=0,this.Next=null},t.Maxima=function(){this.X=0,this.Next=null,this.Prev=null},t.OutRec=function(){this.Idx=0,this.IsHole=!1,this.IsOpen=!1,this.FirstLeft=null,this.Pts=null,this.BottomPt=null,this.PolyNode=null},t.OutPt=function(){this.Idx=0,this.Pt=new t.IntPoint0,this.Next=null,this.Prev=null},t.Join=function(){this.OutPt1=null,this.OutPt2=null,this.OffPt=new t.IntPoint0},t.ClipperBase=function(){this.m_MinimaList=null,this.m_CurrentLM=null,this.m_edges=new Array,this.m_UseFullRange=!1,this.m_HasOpenPaths=!1,this.PreserveCollinear=!1,this.m_Scanbeam=null,this.m_PolyOuts=null,this.m_ActiveEdges=null},t.ClipperBase.horizontal=-9007199254740992,t.ClipperBase.Skip=-2,t.ClipperBase.Unassigned=-1,t.ClipperBase.tolerance=1e-20,t.ClipperBase.loRange=47453132,t.ClipperBase.hiRange=0xfffffffffffff,t.ClipperBase.near_zero=function(e){return e>-t.ClipperBase.tolerance&&e<t.ClipperBase.tolerance},t.ClipperBase.IsHorizontal=function(e){return 0===e.Delta.Y},t.ClipperBase.prototype.PointIsVertex=function(e,n){var i=n;do{if(t.IntPoint.op_Equality(i.Pt,e))return!0;i=i.Next}while(i!==n);return!1},t.ClipperBase.prototype.PointOnLineSegment=function(e,t,n,i){return i?e.X===t.X&&e.Y===t.Y||e.X===n.X&&e.Y===n.Y||e.X>t.X==e.X<n.X&&e.Y>t.Y==e.Y<n.Y&&p.op_Equality(p.Int128Mul(e.X-t.X,n.Y-t.Y),p.Int128Mul(n.X-t.X,e.Y-t.Y)):e.X===t.X&&e.Y===t.Y||e.X===n.X&&e.Y===n.Y||e.X>t.X==e.X<n.X&&e.Y>t.Y==e.Y<n.Y&&(e.X-t.X)*(n.Y-t.Y)==(n.X-t.X)*(e.Y-t.Y)},t.ClipperBase.prototype.PointOnPolygon=function(e,t,n){for(var i=t;;){if(this.PointOnLineSegment(e,i.Pt,i.Next.Pt,n))return!0;if((i=i.Next)===t)break}return!1},t.ClipperBase.prototype.SlopesEqual=t.ClipperBase.SlopesEqual=function(){var e,n,i,r,s,o,a=arguments,A=a.length;return 3===A?(e=a[0],n=a[1],a[2]?p.op_Equality(p.Int128Mul(e.Delta.Y,n.Delta.X),p.Int128Mul(e.Delta.X,n.Delta.Y)):t.Cast_Int64(e.Delta.Y*n.Delta.X)===t.Cast_Int64(e.Delta.X*n.Delta.Y)):4===A?(i=a[0],r=a[1],s=a[2],a[3]?p.op_Equality(p.Int128Mul(i.Y-r.Y,r.X-s.X),p.Int128Mul(i.X-r.X,r.Y-s.Y)):t.Cast_Int64((i.Y-r.Y)*(r.X-s.X))-t.Cast_Int64((i.X-r.X)*(r.Y-s.Y))==0):(i=a[0],r=a[1],s=a[2],o=a[3],a[4]?p.op_Equality(p.Int128Mul(i.Y-r.Y,s.X-o.X),p.Int128Mul(i.X-r.X,s.Y-o.Y)):t.Cast_Int64((i.Y-r.Y)*(s.X-o.X))-t.Cast_Int64((i.X-r.X)*(s.Y-o.Y))==0)},t.ClipperBase.SlopesEqual3=function(e,n,i){return i?p.op_Equality(p.Int128Mul(e.Delta.Y,n.Delta.X),p.Int128Mul(e.Delta.X,n.Delta.Y)):t.Cast_Int64(e.Delta.Y*n.Delta.X)===t.Cast_Int64(e.Delta.X*n.Delta.Y)},t.ClipperBase.SlopesEqual4=function(e,n,i,r){return r?p.op_Equality(p.Int128Mul(e.Y-n.Y,n.X-i.X),p.Int128Mul(e.X-n.X,n.Y-i.Y)):t.Cast_Int64((e.Y-n.Y)*(n.X-i.X))-t.Cast_Int64((e.X-n.X)*(n.Y-i.Y))==0},t.ClipperBase.SlopesEqual5=function(e,n,i,r,s){return s?p.op_Equality(p.Int128Mul(e.Y-n.Y,i.X-r.X),p.Int128Mul(e.X-n.X,i.Y-r.Y)):t.Cast_Int64((e.Y-n.Y)*(i.X-r.X))-t.Cast_Int64((e.X-n.X)*(i.Y-r.Y))==0},t.ClipperBase.prototype.Clear=function(){this.DisposeLocalMinimaList();for(var e=0,n=this.m_edges.length;e<n;++e){for(var i=0,r=this.m_edges[e].length;i<r;++i)this.m_edges[e][i]=null;t.Clear(this.m_edges[e])}t.Clear(this.m_edges),this.m_UseFullRange=!1,this.m_HasOpenPaths=!1},t.ClipperBase.prototype.DisposeLocalMinimaList=function(){for(;null!==this.m_MinimaList;){var e=this.m_MinimaList.Next;this.m_MinimaList=null,this.m_MinimaList=e}this.m_CurrentLM=null},t.ClipperBase.prototype.RangeTest=function(e,n){n.Value?(e.X>t.ClipperBase.hiRange||e.Y>t.ClipperBase.hiRange||-e.X>t.ClipperBase.hiRange||-e.Y>t.ClipperBase.hiRange)&&t.Error("Coordinate outside allowed range in RangeTest()."):(e.X>t.ClipperBase.loRange||e.Y>t.ClipperBase.loRange||-e.X>t.ClipperBase.loRange||-e.Y>t.ClipperBase.loRange)&&(n.Value=!0,this.RangeTest(e,n))},t.ClipperBase.prototype.InitEdge=function(e,n,i,r){e.Next=n,e.Prev=i,e.Curr.X=r.X,e.Curr.Y=r.Y,t.use_xyz&&(e.Curr.Z=r.Z),e.OutIdx=-1},t.ClipperBase.prototype.InitEdge2=function(e,n){e.Curr.Y>=e.Next.Curr.Y?(e.Bot.X=e.Curr.X,e.Bot.Y=e.Curr.Y,t.use_xyz&&(e.Bot.Z=e.Curr.Z),e.Top.X=e.Next.Curr.X,e.Top.Y=e.Next.Curr.Y,t.use_xyz&&(e.Top.Z=e.Next.Curr.Z)):(e.Top.X=e.Curr.X,e.Top.Y=e.Curr.Y,t.use_xyz&&(e.Top.Z=e.Curr.Z),e.Bot.X=e.Next.Curr.X,e.Bot.Y=e.Next.Curr.Y,t.use_xyz&&(e.Bot.Z=e.Next.Curr.Z)),this.SetDx(e),e.PolyTyp=n},t.ClipperBase.prototype.FindNextLocMin=function(e){for(var n;;){for(;t.IntPoint.op_Inequality(e.Bot,e.Prev.Bot)||t.IntPoint.op_Equality(e.Curr,e.Top);)e=e.Next;if(e.Dx!==t.ClipperBase.horizontal&&e.Prev.Dx!==t.ClipperBase.horizontal)break;for(;e.Prev.Dx===t.ClipperBase.horizontal;)e=e.Prev;for(n=e;e.Dx===t.ClipperBase.horizontal;)e=e.Next;if(e.Top.Y!==e.Prev.Bot.Y){n.Prev.Bot.X<e.Bot.X&&(e=n);break}}return e},t.ClipperBase.prototype.ProcessBound=function(e,n){var i,r,s=e;if(s.OutIdx===t.ClipperBase.Skip){if(e=s,n){for(;e.Top.Y===e.Next.Bot.Y;)e=e.Next;for(;e!==s&&e.Dx===t.ClipperBase.horizontal;)e=e.Prev}else{for(;e.Top.Y===e.Prev.Bot.Y;)e=e.Prev;for(;e!==s&&e.Dx===t.ClipperBase.horizontal;)e=e.Next}if(e===s)s=n?e.Next:e.Prev;else{e=n?s.Next:s.Prev;var o=new t.LocalMinima;o.Next=null,o.Y=e.Bot.Y,o.LeftBound=null,o.RightBound=e,e.WindDelta=0,s=this.ProcessBound(e,n),this.InsertLocalMinima(o)}return s}if(e.Dx===t.ClipperBase.horizontal&&((i=n?e.Prev:e.Next).Dx===t.ClipperBase.horizontal?i.Bot.X!==e.Bot.X&&i.Top.X!==e.Bot.X&&this.ReverseHorizontal(e):i.Bot.X!==e.Bot.X&&this.ReverseHorizontal(e)),i=e,n){for(;s.Top.Y===s.Next.Bot.Y&&s.Next.OutIdx!==t.ClipperBase.Skip;)s=s.Next;if(s.Dx===t.ClipperBase.horizontal&&s.Next.OutIdx!==t.ClipperBase.Skip){for(r=s;r.Prev.Dx===t.ClipperBase.horizontal;)r=r.Prev;r.Prev.Top.X>s.Next.Top.X&&(s=r.Prev)}for(;e!==s;)e.NextInLML=e.Next,e.Dx===t.ClipperBase.horizontal&&e!==i&&e.Bot.X!==e.Prev.Top.X&&this.ReverseHorizontal(e),e=e.Next;e.Dx===t.ClipperBase.horizontal&&e!==i&&e.Bot.X!==e.Prev.Top.X&&this.ReverseHorizontal(e),s=s.Next}else{for(;s.Top.Y===s.Prev.Bot.Y&&s.Prev.OutIdx!==t.ClipperBase.Skip;)s=s.Prev;if(s.Dx===t.ClipperBase.horizontal&&s.Prev.OutIdx!==t.ClipperBase.Skip){for(r=s;r.Next.Dx===t.ClipperBase.horizontal;)r=r.Next;(r.Next.Top.X===s.Prev.Top.X||r.Next.Top.X>s.Prev.Top.X)&&(s=r.Next)}for(;e!==s;)e.NextInLML=e.Prev,e.Dx===t.ClipperBase.horizontal&&e!==i&&e.Bot.X!==e.Next.Top.X&&this.ReverseHorizontal(e),e=e.Prev;e.Dx===t.ClipperBase.horizontal&&e!==i&&e.Bot.X!==e.Next.Top.X&&this.ReverseHorizontal(e),s=s.Prev}return s},t.ClipperBase.prototype.AddPath=function(e,n,i){t.use_lines?i||n!==t.PolyType.ptClip||t.Error("AddPath: Open paths must be subject."):i||t.Error("AddPath: Open paths have been disabled.");var r=e.length-1;if(i)for(;r>0&&t.IntPoint.op_Equality(e[r],e[0]);)--r;for(;r>0&&t.IntPoint.op_Equality(e[r],e[r-1]);)--r;if(i&&r<2||!i&&r<1)return!1;for(var s=new Array,o=0;o<=r;o++)s.push(new t.TEdge);var a=!0;s[1].Curr.X=e[1].X,s[1].Curr.Y=e[1].Y,t.use_xyz&&(s[1].Curr.Z=e[1].Z);var A={Value:this.m_UseFullRange};for(this.RangeTest(e[0],A),this.m_UseFullRange=A.Value,A.Value=this.m_UseFullRange,this.RangeTest(e[r],A),this.m_UseFullRange=A.Value,this.InitEdge(s[0],s[1],s[r],e[0]),this.InitEdge(s[r],s[0],s[r-1],e[r]),o=r-1;o>=1;--o)A.Value=this.m_UseFullRange,this.RangeTest(e[o],A),this.m_UseFullRange=A.Value,this.InitEdge(s[o],s[o+1],s[o-1],e[o]);for(var l,c=s[0],p=c,h=c;;)if(p.Curr!==p.Next.Curr||!i&&p.Next===c){if(p.Prev===p.Next)break;if(!i||!t.ClipperBase.SlopesEqual4(p.Prev.Curr,p.Curr,p.Next.Curr,this.m_UseFullRange)||this.PreserveCollinear&&this.Pt2IsBetweenPt1AndPt3(p.Prev.Curr,p.Curr,p.Next.Curr)){if((p=p.Next)===h||!i&&p.Next===c)break}else p===c&&(c=p.Next),h=p=(p=this.RemoveEdge(p)).Prev}else{if(p===p.Next)break;p===c&&(c=p.Next),h=p=this.RemoveEdge(p)}if(!i&&p===p.Next||i&&p.Prev===p.Next)return!1;i||(this.m_HasOpenPaths=!0,c.Prev.OutIdx=t.ClipperBase.Skip),p=c;do{this.InitEdge2(p,n),p=p.Next,a&&p.Curr.Y!==c.Curr.Y&&(a=!1)}while(p!==c);if(a){if(i)return!1;for(p.Prev.OutIdx=t.ClipperBase.Skip,(d=new t.LocalMinima).Next=null,d.Y=p.Bot.Y,d.LeftBound=null,d.RightBound=p,d.RightBound.Side=t.EdgeSide.esRight,d.RightBound.WindDelta=0;p.Bot.X!==p.Prev.Top.X&&this.ReverseHorizontal(p),p.Next.OutIdx!==t.ClipperBase.Skip;)p.NextInLML=p.Next,p=p.Next;return this.InsertLocalMinima(d),this.m_edges.push(s),!0}this.m_edges.push(s);var u=null;for(t.IntPoint.op_Equality(p.Prev.Bot,p.Prev.Top)&&(p=p.Next);(p=this.FindNextLocMin(p))!==u;){var d;null===u&&(u=p),(d=new t.LocalMinima).Next=null,d.Y=p.Bot.Y,p.Dx<p.Prev.Dx?(d.LeftBound=p.Prev,d.RightBound=p,l=!1):(d.LeftBound=p,d.RightBound=p.Prev,l=!0),d.LeftBound.Side=t.EdgeSide.esLeft,d.RightBound.Side=t.EdgeSide.esRight,i?d.LeftBound.Next===d.RightBound?d.LeftBound.WindDelta=-1:d.LeftBound.WindDelta=1:d.LeftBound.WindDelta=0,d.RightBound.WindDelta=-d.LeftBound.WindDelta,(p=this.ProcessBound(d.LeftBound,l)).OutIdx===t.ClipperBase.Skip&&(p=this.ProcessBound(p,l));var g=this.ProcessBound(d.RightBound,!l);g.OutIdx===t.ClipperBase.Skip&&(g=this.ProcessBound(g,!l)),d.LeftBound.OutIdx===t.ClipperBase.Skip?d.LeftBound=null:d.RightBound.OutIdx===t.ClipperBase.Skip&&(d.RightBound=null),this.InsertLocalMinima(d),l||(p=g)}return!0},t.ClipperBase.prototype.AddPaths=function(e,t,n){for(var i=!1,r=0,s=e.length;r<s;++r)this.AddPath(e[r],t,n)&&(i=!0);return i},t.ClipperBase.prototype.Pt2IsBetweenPt1AndPt3=function(e,n,i){return!(t.IntPoint.op_Equality(e,i)||t.IntPoint.op_Equality(e,n)||t.IntPoint.op_Equality(i,n))&&(e.X!==i.X?n.X>e.X==n.X<i.X:n.Y>e.Y==n.Y<i.Y)},t.ClipperBase.prototype.RemoveEdge=function(e){e.Prev.Next=e.Next,e.Next.Prev=e.Prev;var t=e.Next;return e.Prev=null,t},t.ClipperBase.prototype.SetDx=function(e){e.Delta.X=e.Top.X-e.Bot.X,e.Delta.Y=e.Top.Y-e.Bot.Y,0===e.Delta.Y?e.Dx=t.ClipperBase.horizontal:e.Dx=e.Delta.X/e.Delta.Y},t.ClipperBase.prototype.InsertLocalMinima=function(e){if(null===this.m_MinimaList)this.m_MinimaList=e;else if(e.Y>=this.m_MinimaList.Y)e.Next=this.m_MinimaList,this.m_MinimaList=e;else{for(var t=this.m_MinimaList;null!==t.Next&&e.Y<t.Next.Y;)t=t.Next;e.Next=t.Next,t.Next=e}},t.ClipperBase.prototype.PopLocalMinima=function(e,t){return t.v=this.m_CurrentLM,null!==this.m_CurrentLM&&this.m_CurrentLM.Y===e&&(this.m_CurrentLM=this.m_CurrentLM.Next,!0)},t.ClipperBase.prototype.ReverseHorizontal=function(e){var n=e.Top.X;e.Top.X=e.Bot.X,e.Bot.X=n,t.use_xyz&&(n=e.Top.Z,e.Top.Z=e.Bot.Z,e.Bot.Z=n)},t.ClipperBase.prototype.Reset=function(){if(this.m_CurrentLM=this.m_MinimaList,null!==this.m_CurrentLM){this.m_Scanbeam=null;for(var e=this.m_MinimaList;null!==e;){this.InsertScanbeam(e.Y);var n=e.LeftBound;null!==n&&(n.Curr.X=n.Bot.X,n.Curr.Y=n.Bot.Y,t.use_xyz&&(n.Curr.Z=n.Bot.Z),n.OutIdx=t.ClipperBase.Unassigned),null!==(n=e.RightBound)&&(n.Curr.X=n.Bot.X,n.Curr.Y=n.Bot.Y,t.use_xyz&&(n.Curr.Z=n.Bot.Z),n.OutIdx=t.ClipperBase.Unassigned),e=e.Next}this.m_ActiveEdges=null}},t.ClipperBase.prototype.InsertScanbeam=function(e){if(null===this.m_Scanbeam)this.m_Scanbeam=new t.Scanbeam,this.m_Scanbeam.Next=null,this.m_Scanbeam.Y=e;else if(e>this.m_Scanbeam.Y){var n=new t.Scanbeam;n.Y=e,n.Next=this.m_Scanbeam,this.m_Scanbeam=n}else{for(var i=this.m_Scanbeam;null!==i.Next&&e<=i.Next.Y;)i=i.Next;if(e===i.Y)return;var r=new t.Scanbeam;r.Y=e,r.Next=i.Next,i.Next=r}},t.ClipperBase.prototype.PopScanbeam=function(e){return null===this.m_Scanbeam?(e.v=0,!1):(e.v=this.m_Scanbeam.Y,this.m_Scanbeam=this.m_Scanbeam.Next,!0)},t.ClipperBase.prototype.LocalMinimaPending=function(){return null!==this.m_CurrentLM},t.ClipperBase.prototype.CreateOutRec=function(){var e=new t.OutRec;return e.Idx=t.ClipperBase.Unassigned,e.IsHole=!1,e.IsOpen=!1,e.FirstLeft=null,e.Pts=null,e.BottomPt=null,e.PolyNode=null,this.m_PolyOuts.push(e),e.Idx=this.m_PolyOuts.length-1,e},t.ClipperBase.prototype.DisposeOutRec=function(e){var t=this.m_PolyOuts[e];t.Pts=null,t=null,this.m_PolyOuts[e]=null},t.ClipperBase.prototype.UpdateEdgeIntoAEL=function(e){null===e.NextInLML&&t.Error("UpdateEdgeIntoAEL: invalid call");var n=e.PrevInAEL,i=e.NextInAEL;return e.NextInLML.OutIdx=e.OutIdx,null!==n?n.NextInAEL=e.NextInLML:this.m_ActiveEdges=e.NextInLML,null!==i&&(i.PrevInAEL=e.NextInLML),e.NextInLML.Side=e.Side,e.NextInLML.WindDelta=e.WindDelta,e.NextInLML.WindCnt=e.WindCnt,e.NextInLML.WindCnt2=e.WindCnt2,(e=e.NextInLML).Curr.X=e.Bot.X,e.Curr.Y=e.Bot.Y,e.PrevInAEL=n,e.NextInAEL=i,t.ClipperBase.IsHorizontal(e)||this.InsertScanbeam(e.Top.Y),e},t.ClipperBase.prototype.SwapPositionsInAEL=function(e,t){if(e.NextInAEL!==e.PrevInAEL&&t.NextInAEL!==t.PrevInAEL){if(e.NextInAEL===t){var n=t.NextInAEL;null!==n&&(n.PrevInAEL=e);var i=e.PrevInAEL;null!==i&&(i.NextInAEL=t),t.PrevInAEL=i,t.NextInAEL=e,e.PrevInAEL=t,e.NextInAEL=n}else if(t.NextInAEL===e){var r=e.NextInAEL;null!==r&&(r.PrevInAEL=t);var s=t.PrevInAEL;null!==s&&(s.NextInAEL=e),e.PrevInAEL=s,e.NextInAEL=t,t.PrevInAEL=e,t.NextInAEL=r}else{var o=e.NextInAEL,a=e.PrevInAEL;e.NextInAEL=t.NextInAEL,null!==e.NextInAEL&&(e.NextInAEL.PrevInAEL=e),e.PrevInAEL=t.PrevInAEL,null!==e.PrevInAEL&&(e.PrevInAEL.NextInAEL=e),t.NextInAEL=o,null!==t.NextInAEL&&(t.NextInAEL.PrevInAEL=t),t.PrevInAEL=a,null!==t.PrevInAEL&&(t.PrevInAEL.NextInAEL=t)}null===e.PrevInAEL?this.m_ActiveEdges=e:null===t.PrevInAEL&&(this.m_ActiveEdges=t)}},t.ClipperBase.prototype.DeleteFromAEL=function(e){var t=e.PrevInAEL,n=e.NextInAEL;null===t&&null===n&&e!==this.m_ActiveEdges||(null!==t?t.NextInAEL=n:this.m_ActiveEdges=n,null!==n&&(n.PrevInAEL=t),e.NextInAEL=null,e.PrevInAEL=null)},t.Clipper=function(e){void 0===e&&(e=0),this.m_PolyOuts=null,this.m_ClipType=t.ClipType.ctIntersection,this.m_Scanbeam=null,this.m_Maxima=null,this.m_ActiveEdges=null,this.m_SortedEdges=null,this.m_IntersectList=null,this.m_IntersectNodeComparer=null,this.m_ExecuteLocked=!1,this.m_ClipFillType=t.PolyFillType.pftEvenOdd,this.m_SubjFillType=t.PolyFillType.pftEvenOdd,this.m_Joins=null,this.m_GhostJoins=null,this.m_UsingPolyTree=!1,this.ReverseSolution=!1,this.StrictlySimple=!1,t.ClipperBase.call(this),this.m_Scanbeam=null,this.m_Maxima=null,this.m_ActiveEdges=null,this.m_SortedEdges=null,this.m_IntersectList=new Array,this.m_IntersectNodeComparer=t.MyIntersectNodeSort.Compare,this.m_ExecuteLocked=!1,this.m_UsingPolyTree=!1,this.m_PolyOuts=new Array,this.m_Joins=new Array,this.m_GhostJoins=new Array,this.ReverseSolution=!!(1&e),this.StrictlySimple=!!(2&e),this.PreserveCollinear=!!(4&e),t.use_xyz&&(this.ZFillFunction=null)},t.Clipper.ioReverseSolution=1,t.Clipper.ioStrictlySimple=2,t.Clipper.ioPreserveCollinear=4,t.Clipper.prototype.Clear=function(){0!==this.m_edges.length&&(this.DisposeAllPolyPts(),t.ClipperBase.prototype.Clear.call(this))},t.Clipper.prototype.InsertMaxima=function(e){var n=new t.Maxima;if(n.X=e,null===this.m_Maxima)this.m_Maxima=n,this.m_Maxima.Next=null,this.m_Maxima.Prev=null;else if(e<this.m_Maxima.X)n.Next=this.m_Maxima,n.Prev=null,this.m_Maxima=n;else{for(var i=this.m_Maxima;null!==i.Next&&e>=i.Next.X;)i=i.Next;if(e===i.X)return;n.Next=i.Next,n.Prev=i,null!==i.Next&&(i.Next.Prev=n),i.Next=n}},t.Clipper.prototype.Execute=function(){var e=arguments,n=e.length,i=e[1]instanceof t.PolyTree;if(4===n&&!i){var r=e[0],s=e[1],o=e[2],a=e[3];if(this.m_ExecuteLocked)return!1;this.m_HasOpenPaths&&t.Error("Error: PolyTree struct is needed for open path clipping."),this.m_ExecuteLocked=!0,t.Clear(s),this.m_SubjFillType=o,this.m_ClipFillType=a,this.m_ClipType=r,this.m_UsingPolyTree=!1;try{(l=this.ExecuteInternal())&&this.BuildResult(s)}finally{this.DisposeAllPolyPts(),this.m_ExecuteLocked=!1}return l}if(4===n&&i){r=e[0];var A=e[1];if(o=e[2],a=e[3],this.m_ExecuteLocked)return!1;this.m_ExecuteLocked=!0,this.m_SubjFillType=o,this.m_ClipFillType=a,this.m_ClipType=r,this.m_UsingPolyTree=!0;try{var l;(l=this.ExecuteInternal())&&this.BuildResult2(A)}finally{this.DisposeAllPolyPts(),this.m_ExecuteLocked=!1}return l}return 2!==n||i?2===n&&i?(r=e[0],A=e[1],this.Execute(r,A,t.PolyFillType.pftEvenOdd,t.PolyFillType.pftEvenOdd)):void 0:(r=e[0],s=e[1],this.Execute(r,s,t.PolyFillType.pftEvenOdd,t.PolyFillType.pftEvenOdd))},t.Clipper.prototype.FixHoleLinkage=function(e){if(null!==e.FirstLeft&&(e.IsHole===e.FirstLeft.IsHole||null===e.FirstLeft.Pts)){for(var t=e.FirstLeft;null!==t&&(t.IsHole===e.IsHole||null===t.Pts);)t=t.FirstLeft;e.FirstLeft=t}},t.Clipper.prototype.ExecuteInternal=function(){try{this.Reset(),this.m_SortedEdges=null,this.m_Maxima=null;var e,t,n,i={},r={};if(!this.PopScanbeam(i))return!1;for(this.InsertLocalMinimaIntoAEL(i.v);this.PopScanbeam(r)||this.LocalMinimaPending();){if(this.ProcessHorizontals(),this.m_GhostJoins.length=0,!this.ProcessIntersections(r.v))return!1;this.ProcessEdgesAtTopOfScanbeam(r.v),i.v=r.v,this.InsertLocalMinimaIntoAEL(i.v)}for(t=0,n=this.m_PolyOuts.length;t<n;t++)null===(e=this.m_PolyOuts[t]).Pts||e.IsOpen||(e.IsHole^this.ReverseSolution)==this.Area$1(e)>0&&this.ReversePolyPtLinks(e.Pts);for(this.JoinCommonEdges(),t=0,n=this.m_PolyOuts.length;t<n;t++)null!==(e=this.m_PolyOuts[t]).Pts&&(e.IsOpen?this.FixupOutPolyline(e):this.FixupOutPolygon(e));return this.StrictlySimple&&this.DoSimplePolygons(),!0}finally{this.m_Joins.length=0,this.m_GhostJoins.length=0}},t.Clipper.prototype.DisposeAllPolyPts=function(){for(var e=0,n=this.m_PolyOuts.length;e<n;++e)this.DisposeOutRec(e);t.Clear(this.m_PolyOuts)},t.Clipper.prototype.AddJoin=function(e,n,i){var r=new t.Join;r.OutPt1=e,r.OutPt2=n,r.OffPt.X=i.X,r.OffPt.Y=i.Y,t.use_xyz&&(r.OffPt.Z=i.Z),this.m_Joins.push(r)},t.Clipper.prototype.AddGhostJoin=function(e,n){var i=new t.Join;i.OutPt1=e,i.OffPt.X=n.X,i.OffPt.Y=n.Y,t.use_xyz&&(i.OffPt.Z=n.Z),this.m_GhostJoins.push(i)},t.Clipper.prototype.SetZ=function(e,n,i){if(null!==this.ZFillFunction){if(0!==e.Z||null===this.ZFillFunction)return;t.IntPoint.op_Equality(e,n.Bot)?e.Z=n.Bot.Z:t.IntPoint.op_Equality(e,n.Top)?e.Z=n.Top.Z:t.IntPoint.op_Equality(e,i.Bot)?e.Z=i.Bot.Z:t.IntPoint.op_Equality(e,i.Top)?e.Z=i.Top.Z:this.ZFillFunction(n.Bot,n.Top,i.Bot,i.Top,e)}},t.Clipper.prototype.InsertLocalMinimaIntoAEL=function(e){for(var n,i,r={};this.PopLocalMinima(e,r);){n=r.v.LeftBound,i=r.v.RightBound;var s=null;if(null===n?(this.InsertEdgeIntoAEL(i,null),this.SetWindingCount(i),this.IsContributing(i)&&(s=this.AddOutPt(i,i.Bot))):null===i?(this.InsertEdgeIntoAEL(n,null),this.SetWindingCount(n),this.IsContributing(n)&&(s=this.AddOutPt(n,n.Bot)),this.InsertScanbeam(n.Top.Y)):(this.InsertEdgeIntoAEL(n,null),this.InsertEdgeIntoAEL(i,n),this.SetWindingCount(n),i.WindCnt=n.WindCnt,i.WindCnt2=n.WindCnt2,this.IsContributing(n)&&(s=this.AddLocalMinPoly(n,i,n.Bot)),this.InsertScanbeam(n.Top.Y)),null!==i&&(t.ClipperBase.IsHorizontal(i)?(null!==i.NextInLML&&this.InsertScanbeam(i.NextInLML.Top.Y),this.AddEdgeToSEL(i)):this.InsertScanbeam(i.Top.Y)),null!==n&&null!==i){if(null!==s&&t.ClipperBase.IsHorizontal(i)&&this.m_GhostJoins.length>0&&0!==i.WindDelta)for(var o=0,a=this.m_GhostJoins.length;o<a;o++){var A=this.m_GhostJoins[o];this.HorzSegmentsOverlap(A.OutPt1.Pt.X,A.OffPt.X,i.Bot.X,i.Top.X)&&this.AddJoin(A.OutPt1,s,A.OffPt)}if(n.OutIdx>=0&&null!==n.PrevInAEL&&n.PrevInAEL.Curr.X===n.Bot.X&&n.PrevInAEL.OutIdx>=0&&t.ClipperBase.SlopesEqual5(n.PrevInAEL.Curr,n.PrevInAEL.Top,n.Curr,n.Top,this.m_UseFullRange)&&0!==n.WindDelta&&0!==n.PrevInAEL.WindDelta){var l=this.AddOutPt(n.PrevInAEL,n.Bot);this.AddJoin(s,l,n.Top)}if(n.NextInAEL!==i){i.OutIdx>=0&&i.PrevInAEL.OutIdx>=0&&t.ClipperBase.SlopesEqual5(i.PrevInAEL.Curr,i.PrevInAEL.Top,i.Curr,i.Top,this.m_UseFullRange)&&0!==i.WindDelta&&0!==i.PrevInAEL.WindDelta&&(l=this.AddOutPt(i.PrevInAEL,i.Bot),this.AddJoin(s,l,i.Top));var c=n.NextInAEL;if(null!==c)for(;c!==i;)this.IntersectEdges(i,c,n.Curr),c=c.NextInAEL}}}},t.Clipper.prototype.InsertEdgeIntoAEL=function(e,t){if(null===this.m_ActiveEdges)e.PrevInAEL=null,e.NextInAEL=null,this.m_ActiveEdges=e;else if(null===t&&this.E2InsertsBeforeE1(this.m_ActiveEdges,e))e.PrevInAEL=null,e.NextInAEL=this.m_ActiveEdges,this.m_ActiveEdges.PrevInAEL=e,this.m_ActiveEdges=e;else{for(null===t&&(t=this.m_ActiveEdges);null!==t.NextInAEL&&!this.E2InsertsBeforeE1(t.NextInAEL,e);)t=t.NextInAEL;e.NextInAEL=t.NextInAEL,null!==t.NextInAEL&&(t.NextInAEL.PrevInAEL=e),e.PrevInAEL=t,t.NextInAEL=e}},t.Clipper.prototype.E2InsertsBeforeE1=function(e,n){return n.Curr.X===e.Curr.X?n.Top.Y>e.Top.Y?n.Top.X<t.Clipper.TopX(e,n.Top.Y):e.Top.X>t.Clipper.TopX(n,e.Top.Y):n.Curr.X<e.Curr.X},t.Clipper.prototype.IsEvenOddFillType=function(e){return e.PolyTyp===t.PolyType.ptSubject?this.m_SubjFillType===t.PolyFillType.pftEvenOdd:this.m_ClipFillType===t.PolyFillType.pftEvenOdd},t.Clipper.prototype.IsEvenOddAltFillType=function(e){return e.PolyTyp===t.PolyType.ptSubject?this.m_ClipFillType===t.PolyFillType.pftEvenOdd:this.m_SubjFillType===t.PolyFillType.pftEvenOdd},t.Clipper.prototype.IsContributing=function(e){var n,i;switch(e.PolyTyp===t.PolyType.ptSubject?(n=this.m_SubjFillType,i=this.m_ClipFillType):(n=this.m_ClipFillType,i=this.m_SubjFillType),n){case t.PolyFillType.pftEvenOdd:if(0===e.WindDelta&&1!==e.WindCnt)return!1;break;case t.PolyFillType.pftNonZero:if(1!==Math.abs(e.WindCnt))return!1;break;case t.PolyFillType.pftPositive:if(1!==e.WindCnt)return!1;break;default:if(-1!==e.WindCnt)return!1}switch(this.m_ClipType){case t.ClipType.ctIntersection:switch(i){case t.PolyFillType.pftEvenOdd:case t.PolyFillType.pftNonZero:return 0!==e.WindCnt2;case t.PolyFillType.pftPositive:return e.WindCnt2>0;default:return e.WindCnt2<0}case t.ClipType.ctUnion:switch(i){case t.PolyFillType.pftEvenOdd:case t.PolyFillType.pftNonZero:return 0===e.WindCnt2;case t.PolyFillType.pftPositive:return e.WindCnt2<=0;default:return e.WindCnt2>=0}case t.ClipType.ctDifference:if(e.PolyTyp===t.PolyType.ptSubject)switch(i){case t.PolyFillType.pftEvenOdd:case t.PolyFillType.pftNonZero:return 0===e.WindCnt2;case t.PolyFillType.pftPositive:return e.WindCnt2<=0;default:return e.WindCnt2>=0}else switch(i){case t.PolyFillType.pftEvenOdd:case t.PolyFillType.pftNonZero:return 0!==e.WindCnt2;case t.PolyFillType.pftPositive:return e.WindCnt2>0;default:return e.WindCnt2<0}case t.ClipType.ctXor:if(0!==e.WindDelta)return!0;switch(i){case t.PolyFillType.pftEvenOdd:case t.PolyFillType.pftNonZero:return 0===e.WindCnt2;case t.PolyFillType.pftPositive:return e.WindCnt2<=0;default:return e.WindCnt2>=0}}return!0},t.Clipper.prototype.SetWindingCount=function(e){for(var n=e.PrevInAEL;null!==n&&(n.PolyTyp!==e.PolyTyp||0===n.WindDelta);)n=n.PrevInAEL;if(null===n){var i=e.PolyTyp===t.PolyType.ptSubject?this.m_SubjFillType:this.m_ClipFillType;0===e.WindDelta?e.WindCnt=i===t.PolyFillType.pftNegative?-1:1:e.WindCnt=e.WindDelta,e.WindCnt2=0,n=this.m_ActiveEdges}else if(0===e.WindDelta&&this.m_ClipType!==t.ClipType.ctUnion)e.WindCnt=1,e.WindCnt2=n.WindCnt2,n=n.NextInAEL;else if(this.IsEvenOddFillType(e)){if(0===e.WindDelta){for(var r=!0,s=n.PrevInAEL;null!==s;)s.PolyTyp===n.PolyTyp&&0!==s.WindDelta&&(r=!r),s=s.PrevInAEL;e.WindCnt=r?0:1}else e.WindCnt=e.WindDelta;e.WindCnt2=n.WindCnt2,n=n.NextInAEL}else n.WindCnt*n.WindDelta<0?Math.abs(n.WindCnt)>1?n.WindDelta*e.WindDelta<0?e.WindCnt=n.WindCnt:e.WindCnt=n.WindCnt+e.WindDelta:e.WindCnt=0===e.WindDelta?1:e.WindDelta:0===e.WindDelta?e.WindCnt=n.WindCnt<0?n.WindCnt-1:n.WindCnt+1:n.WindDelta*e.WindDelta<0?e.WindCnt=n.WindCnt:e.WindCnt=n.WindCnt+e.WindDelta,e.WindCnt2=n.WindCnt2,n=n.NextInAEL;if(this.IsEvenOddAltFillType(e))for(;n!==e;)0!==n.WindDelta&&(e.WindCnt2=0===e.WindCnt2?1:0),n=n.NextInAEL;else for(;n!==e;)e.WindCnt2+=n.WindDelta,n=n.NextInAEL},t.Clipper.prototype.AddEdgeToSEL=function(e){null===this.m_SortedEdges?(this.m_SortedEdges=e,e.PrevInSEL=null,e.NextInSEL=null):(e.NextInSEL=this.m_SortedEdges,e.PrevInSEL=null,this.m_SortedEdges.PrevInSEL=e,this.m_SortedEdges=e)},t.Clipper.prototype.PopEdgeFromSEL=function(e){if(e.v=this.m_SortedEdges,null===e.v)return!1;var t=e.v;return this.m_SortedEdges=e.v.NextInSEL,null!==this.m_SortedEdges&&(this.m_SortedEdges.PrevInSEL=null),t.NextInSEL=null,t.PrevInSEL=null,!0},t.Clipper.prototype.CopyAELToSEL=function(){var e=this.m_ActiveEdges;for(this.m_SortedEdges=e;null!==e;)e.PrevInSEL=e.PrevInAEL,e.NextInSEL=e.NextInAEL,e=e.NextInAEL},t.Clipper.prototype.SwapPositionsInSEL=function(e,t){if(!(null===e.NextInSEL&&null===e.PrevInSEL||null===t.NextInSEL&&null===t.PrevInSEL)){if(e.NextInSEL===t)null!==(n=t.NextInSEL)&&(n.PrevInSEL=e),null!==(i=e.PrevInSEL)&&(i.NextInSEL=t),t.PrevInSEL=i,t.NextInSEL=e,e.PrevInSEL=t,e.NextInSEL=n;else if(t.NextInSEL===e)null!==(n=e.NextInSEL)&&(n.PrevInSEL=t),null!==(i=t.PrevInSEL)&&(i.NextInSEL=e),e.PrevInSEL=i,e.NextInSEL=t,t.PrevInSEL=e,t.NextInSEL=n;else{var n=e.NextInSEL,i=e.PrevInSEL;e.NextInSEL=t.NextInSEL,null!==e.NextInSEL&&(e.NextInSEL.PrevInSEL=e),e.PrevInSEL=t.PrevInSEL,null!==e.PrevInSEL&&(e.PrevInSEL.NextInSEL=e),t.NextInSEL=n,null!==t.NextInSEL&&(t.NextInSEL.PrevInSEL=t),t.PrevInSEL=i,null!==t.PrevInSEL&&(t.PrevInSEL.NextInSEL=t)}null===e.PrevInSEL?this.m_SortedEdges=e:null===t.PrevInSEL&&(this.m_SortedEdges=t)}},t.Clipper.prototype.AddLocalMaxPoly=function(e,t,n){this.AddOutPt(e,n),0===t.WindDelta&&this.AddOutPt(t,n),e.OutIdx===t.OutIdx?(e.OutIdx=-1,t.OutIdx=-1):e.OutIdx<t.OutIdx?this.AppendPolygon(e,t):this.AppendPolygon(t,e)},t.Clipper.prototype.AddLocalMinPoly=function(e,n,i){var r,s,o;if(t.ClipperBase.IsHorizontal(n)||e.Dx>n.Dx?(r=this.AddOutPt(e,i),n.OutIdx=e.OutIdx,e.Side=t.EdgeSide.esLeft,n.Side=t.EdgeSide.esRight,o=(s=e).PrevInAEL===n?n.PrevInAEL:s.PrevInAEL):(r=this.AddOutPt(n,i),e.OutIdx=n.OutIdx,e.Side=t.EdgeSide.esRight,n.Side=t.EdgeSide.esLeft,o=(s=n).PrevInAEL===e?e.PrevInAEL:s.PrevInAEL),null!==o&&o.OutIdx>=0&&o.Top.Y<i.Y&&s.Top.Y<i.Y){var a=t.Clipper.TopX(o,i.Y),A=t.Clipper.TopX(s,i.Y);if(a===A&&0!==s.WindDelta&&0!==o.WindDelta&&t.ClipperBase.SlopesEqual5(new t.IntPoint2(a,i.Y),o.Top,new t.IntPoint2(A,i.Y),s.Top,this.m_UseFullRange)){var l=this.AddOutPt(o,i);this.AddJoin(r,l,s.Top)}}return r},t.Clipper.prototype.AddOutPt=function(e,n){if(e.OutIdx<0){(r=this.CreateOutRec()).IsOpen=0===e.WindDelta;var i=new t.OutPt;return r.Pts=i,i.Idx=r.Idx,i.Pt.X=n.X,i.Pt.Y=n.Y,t.use_xyz&&(i.Pt.Z=n.Z),i.Next=i,i.Prev=i,r.IsOpen||this.SetHoleState(e,r),e.OutIdx=r.Idx,i}var r,s=(r=this.m_PolyOuts[e.OutIdx]).Pts,o=e.Side===t.EdgeSide.esLeft;return o&&t.IntPoint.op_Equality(n,s.Pt)?s:!o&&t.IntPoint.op_Equality(n,s.Prev.Pt)?s.Prev:((i=new t.OutPt).Idx=r.Idx,i.Pt.X=n.X,i.Pt.Y=n.Y,t.use_xyz&&(i.Pt.Z=n.Z),i.Next=s,i.Prev=s.Prev,i.Prev.Next=i,s.Prev=i,o&&(r.Pts=i),i)},t.Clipper.prototype.GetLastOutPt=function(e){var n=this.m_PolyOuts[e.OutIdx];return e.Side===t.EdgeSide.esLeft?n.Pts:n.Pts.Prev},t.Clipper.prototype.SwapPoints=function(e,n){var i=new t.IntPoint1(e.Value);e.Value.X=n.Value.X,e.Value.Y=n.Value.Y,t.use_xyz&&(e.Value.Z=n.Value.Z),n.Value.X=i.X,n.Value.Y=i.Y,t.use_xyz&&(n.Value.Z=i.Z)},t.Clipper.prototype.HorzSegmentsOverlap=function(e,t,n,i){var r;return e>t&&(r=e,e=t,t=r),n>i&&(r=n,n=i,i=r),e<i&&n<t},t.Clipper.prototype.SetHoleState=function(e,t){for(var n=e.PrevInAEL,i=null;null!==n;)n.OutIdx>=0&&0!==n.WindDelta&&(null===i?i=n:i.OutIdx===n.OutIdx&&(i=null)),n=n.PrevInAEL;null===i?(t.FirstLeft=null,t.IsHole=!1):(t.FirstLeft=this.m_PolyOuts[i.OutIdx],t.IsHole=!t.FirstLeft.IsHole)},t.Clipper.prototype.GetDx=function(e,n){return e.Y===n.Y?t.ClipperBase.horizontal:(n.X-e.X)/(n.Y-e.Y)},t.Clipper.prototype.FirstIsBottomPt=function(e,n){for(var i=e.Prev;t.IntPoint.op_Equality(i.Pt,e.Pt)&&i!==e;)i=i.Prev;var r=Math.abs(this.GetDx(e.Pt,i.Pt));for(i=e.Next;t.IntPoint.op_Equality(i.Pt,e.Pt)&&i!==e;)i=i.Next;var s=Math.abs(this.GetDx(e.Pt,i.Pt));for(i=n.Prev;t.IntPoint.op_Equality(i.Pt,n.Pt)&&i!==n;)i=i.Prev;var o=Math.abs(this.GetDx(n.Pt,i.Pt));for(i=n.Next;t.IntPoint.op_Equality(i.Pt,n.Pt)&&i!==n;)i=i.Next;var a=Math.abs(this.GetDx(n.Pt,i.Pt));return Math.max(r,s)===Math.max(o,a)&&Math.min(r,s)===Math.min(o,a)?this.Area(e)>0:r>=o&&r>=a||s>=o&&s>=a},t.Clipper.prototype.GetBottomPt=function(e){for(var n=null,i=e.Next;i!==e;)i.Pt.Y>e.Pt.Y?(e=i,n=null):i.Pt.Y===e.Pt.Y&&i.Pt.X<=e.Pt.X&&(i.Pt.X<e.Pt.X?(n=null,e=i):i.Next!==e&&i.Prev!==e&&(n=i)),i=i.Next;if(null!==n)for(;n!==i;)for(this.FirstIsBottomPt(i,n)||(e=n),n=n.Next;t.IntPoint.op_Inequality(n.Pt,e.Pt);)n=n.Next;return e},t.Clipper.prototype.GetLowermostRec=function(e,t){null===e.BottomPt&&(e.BottomPt=this.GetBottomPt(e.Pts)),null===t.BottomPt&&(t.BottomPt=this.GetBottomPt(t.Pts));var n=e.BottomPt,i=t.BottomPt;return n.Pt.Y>i.Pt.Y?e:n.Pt.Y<i.Pt.Y?t:n.Pt.X<i.Pt.X?e:n.Pt.X>i.Pt.X||n.Next===n?t:i.Next===i||this.FirstIsBottomPt(n,i)?e:t},t.Clipper.prototype.OutRec1RightOfOutRec2=function(e,t){do{if((e=e.FirstLeft)===t)return!0}while(null!==e);return!1},t.Clipper.prototype.GetOutRec=function(e){for(var t=this.m_PolyOuts[e];t!==this.m_PolyOuts[t.Idx];)t=this.m_PolyOuts[t.Idx];return t},t.Clipper.prototype.AppendPolygon=function(e,n){var i,r=this.m_PolyOuts[e.OutIdx],s=this.m_PolyOuts[n.OutIdx];i=this.OutRec1RightOfOutRec2(r,s)?s:this.OutRec1RightOfOutRec2(s,r)?r:this.GetLowermostRec(r,s);var o=r.Pts,a=o.Prev,A=s.Pts,l=A.Prev;e.Side===t.EdgeSide.esLeft?n.Side===t.EdgeSide.esLeft?(this.ReversePolyPtLinks(A),A.Next=o,o.Prev=A,a.Next=l,l.Prev=a,r.Pts=l):(l.Next=o,o.Prev=l,A.Prev=a,a.Next=A,r.Pts=A):n.Side===t.EdgeSide.esRight?(this.ReversePolyPtLinks(A),a.Next=l,l.Prev=a,A.Next=o,o.Prev=A):(a.Next=A,A.Prev=a,o.Prev=l,l.Next=o),r.BottomPt=null,i===s&&(s.FirstLeft!==r&&(r.FirstLeft=s.FirstLeft),r.IsHole=s.IsHole),s.Pts=null,s.BottomPt=null,s.FirstLeft=r;var c=e.OutIdx,p=n.OutIdx;e.OutIdx=-1,n.OutIdx=-1;for(var h=this.m_ActiveEdges;null!==h;){if(h.OutIdx===p){h.OutIdx=c,h.Side=e.Side;break}h=h.NextInAEL}s.Idx=r.Idx},t.Clipper.prototype.ReversePolyPtLinks=function(e){if(null!==e){var t,n;t=e;do{n=t.Next,t.Next=t.Prev,t.Prev=n,t=n}while(t!==e)}},t.Clipper.SwapSides=function(e,t){var n=e.Side;e.Side=t.Side,t.Side=n},t.Clipper.SwapPolyIndexes=function(e,t){var n=e.OutIdx;e.OutIdx=t.OutIdx,t.OutIdx=n},t.Clipper.prototype.IntersectEdges=function(e,n,i){var r=e.OutIdx>=0,s=n.OutIdx>=0;if(t.use_xyz&&this.SetZ(i,e,n),!t.use_lines||0!==e.WindDelta&&0!==n.WindDelta){if(e.PolyTyp===n.PolyTyp)if(this.IsEvenOddFillType(e)){var o=e.WindCnt;e.WindCnt=n.WindCnt,n.WindCnt=o}else e.WindCnt+n.WindDelta===0?e.WindCnt=-e.WindCnt:e.WindCnt+=n.WindDelta,n.WindCnt-e.WindDelta==0?n.WindCnt=-n.WindCnt:n.WindCnt-=e.WindDelta;else this.IsEvenOddFillType(n)?e.WindCnt2=0===e.WindCnt2?1:0:e.WindCnt2+=n.WindDelta,this.IsEvenOddFillType(e)?n.WindCnt2=0===n.WindCnt2?1:0:n.WindCnt2-=e.WindDelta;var a,A,l,c,p,h;switch(e.PolyTyp===t.PolyType.ptSubject?(a=this.m_SubjFillType,l=this.m_ClipFillType):(a=this.m_ClipFillType,l=this.m_SubjFillType),n.PolyTyp===t.PolyType.ptSubject?(A=this.m_SubjFillType,c=this.m_ClipFillType):(A=this.m_ClipFillType,c=this.m_SubjFillType),a){case t.PolyFillType.pftPositive:p=e.WindCnt;break;case t.PolyFillType.pftNegative:p=-e.WindCnt;break;default:p=Math.abs(e.WindCnt)}switch(A){case t.PolyFillType.pftPositive:h=n.WindCnt;break;case t.PolyFillType.pftNegative:h=-n.WindCnt;break;default:h=Math.abs(n.WindCnt)}if(r&&s)0!==p&&1!==p||0!==h&&1!==h||e.PolyTyp!==n.PolyTyp&&this.m_ClipType!==t.ClipType.ctXor?this.AddLocalMaxPoly(e,n,i):(this.AddOutPt(e,i),this.AddOutPt(n,i),t.Clipper.SwapSides(e,n),t.Clipper.SwapPolyIndexes(e,n));else if(r)0!==h&&1!==h||(this.AddOutPt(e,i),t.Clipper.SwapSides(e,n),t.Clipper.SwapPolyIndexes(e,n));else if(s)0!==p&&1!==p||(this.AddOutPt(n,i),t.Clipper.SwapSides(e,n),t.Clipper.SwapPolyIndexes(e,n));else if(!(0!==p&&1!==p||0!==h&&1!==h)){var u,d;switch(l){case t.PolyFillType.pftPositive:u=e.WindCnt2;break;case t.PolyFillType.pftNegative:u=-e.WindCnt2;break;default:u=Math.abs(e.WindCnt2)}switch(c){case t.PolyFillType.pftPositive:d=n.WindCnt2;break;case t.PolyFillType.pftNegative:d=-n.WindCnt2;break;default:d=Math.abs(n.WindCnt2)}if(e.PolyTyp!==n.PolyTyp)this.AddLocalMinPoly(e,n,i);else if(1===p&&1===h)switch(this.m_ClipType){case t.ClipType.ctIntersection:u>0&&d>0&&this.AddLocalMinPoly(e,n,i);break;case t.ClipType.ctUnion:u<=0&&d<=0&&this.AddLocalMinPoly(e,n,i);break;case t.ClipType.ctDifference:(e.PolyTyp===t.PolyType.ptClip&&u>0&&d>0||e.PolyTyp===t.PolyType.ptSubject&&u<=0&&d<=0)&&this.AddLocalMinPoly(e,n,i);break;case t.ClipType.ctXor:this.AddLocalMinPoly(e,n,i)}else t.Clipper.SwapSides(e,n)}}else{if(0===e.WindDelta&&0===n.WindDelta)return;e.PolyTyp===n.PolyTyp&&e.WindDelta!==n.WindDelta&&this.m_ClipType===t.ClipType.ctUnion?0===e.WindDelta?s&&(this.AddOutPt(e,i),r&&(e.OutIdx=-1)):r&&(this.AddOutPt(n,i),s&&(n.OutIdx=-1)):e.PolyTyp!==n.PolyTyp&&(0!==e.WindDelta||1!==Math.abs(n.WindCnt)||this.m_ClipType===t.ClipType.ctUnion&&0!==n.WindCnt2?0!==n.WindDelta||1!==Math.abs(e.WindCnt)||this.m_ClipType===t.ClipType.ctUnion&&0!==e.WindCnt2||(this.AddOutPt(n,i),s&&(n.OutIdx=-1)):(this.AddOutPt(e,i),r&&(e.OutIdx=-1)))}},t.Clipper.prototype.DeleteFromSEL=function(e){var t=e.PrevInSEL,n=e.NextInSEL;null===t&&null===n&&e!==this.m_SortedEdges||(null!==t?t.NextInSEL=n:this.m_SortedEdges=n,null!==n&&(n.PrevInSEL=t),e.NextInSEL=null,e.PrevInSEL=null)},t.Clipper.prototype.ProcessHorizontals=function(){for(var e={};this.PopEdgeFromSEL(e);)this.ProcessHorizontal(e.v)},t.Clipper.prototype.GetHorzDirection=function(e,n){e.Bot.X<e.Top.X?(n.Left=e.Bot.X,n.Right=e.Top.X,n.Dir=t.Direction.dLeftToRight):(n.Left=e.Top.X,n.Right=e.Bot.X,n.Dir=t.Direction.dRightToLeft)},t.Clipper.prototype.ProcessHorizontal=function(e){var n={Dir:null,Left:null,Right:null};this.GetHorzDirection(e,n);for(var i=n.Dir,r=n.Left,s=n.Right,o=0===e.WindDelta,a=e,A=null;null!==a.NextInLML&&t.ClipperBase.IsHorizontal(a.NextInLML);)a=a.NextInLML;null===a.NextInLML&&(A=this.GetMaximaPair(a));var l=this.m_Maxima;if(null!==l)if(i===t.Direction.dLeftToRight){for(;null!==l&&l.X<=e.Bot.X;)l=l.Next;null!==l&&l.X>=a.Top.X&&(l=null)}else{for(;null!==l.Next&&l.Next.X<e.Bot.X;)l=l.Next;l.X<=a.Top.X&&(l=null)}for(var c=null;;){for(var p=e===a,h=this.GetNextInAEL(e,i);null!==h;){if(null!==l)if(i===t.Direction.dLeftToRight)for(;null!==l&&l.X<h.Curr.X;)e.OutIdx>=0&&!o&&this.AddOutPt(e,new t.IntPoint2(l.X,e.Bot.Y)),l=l.Next;else for(;null!==l&&l.X>h.Curr.X;)e.OutIdx>=0&&!o&&this.AddOutPt(e,new t.IntPoint2(l.X,e.Bot.Y)),l=l.Prev;if(i===t.Direction.dLeftToRight&&h.Curr.X>s||i===t.Direction.dRightToLeft&&h.Curr.X<r)break;if(h.Curr.X===e.Top.X&&null!==e.NextInLML&&h.Dx<e.NextInLML.Dx)break;if(e.OutIdx>=0&&!o){t.use_xyz&&(i===t.Direction.dLeftToRight?this.SetZ(h.Curr,e,h):this.SetZ(h.Curr,h,e)),c=this.AddOutPt(e,h.Curr);for(var u=this.m_SortedEdges;null!==u;){if(u.OutIdx>=0&&this.HorzSegmentsOverlap(e.Bot.X,e.Top.X,u.Bot.X,u.Top.X)){var d=this.GetLastOutPt(u);this.AddJoin(d,c,u.Top)}u=u.NextInSEL}this.AddGhostJoin(c,e.Bot)}if(h===A&&p)return e.OutIdx>=0&&this.AddLocalMaxPoly(e,A,e.Top),this.DeleteFromAEL(e),void this.DeleteFromAEL(A);if(i===t.Direction.dLeftToRight){var g=new t.IntPoint2(h.Curr.X,e.Curr.Y);this.IntersectEdges(e,h,g)}else g=new t.IntPoint2(h.Curr.X,e.Curr.Y),this.IntersectEdges(h,e,g);var f=this.GetNextInAEL(h,i);this.SwapPositionsInAEL(e,h),h=f}if(null===e.NextInLML||!t.ClipperBase.IsHorizontal(e.NextInLML))break;(e=this.UpdateEdgeIntoAEL(e)).OutIdx>=0&&this.AddOutPt(e,e.Bot),n={Dir:i,Left:r,Right:s},this.GetHorzDirection(e,n),i=n.Dir,r=n.Left,s=n.Right}if(e.OutIdx>=0&&null===c){for(c=this.GetLastOutPt(e),u=this.m_SortedEdges;null!==u;)u.OutIdx>=0&&this.HorzSegmentsOverlap(e.Bot.X,e.Top.X,u.Bot.X,u.Top.X)&&(d=this.GetLastOutPt(u),this.AddJoin(d,c,u.Top)),u=u.NextInSEL;this.AddGhostJoin(c,e.Top)}if(null!==e.NextInLML)if(e.OutIdx>=0){if(c=this.AddOutPt(e,e.Top),0===(e=this.UpdateEdgeIntoAEL(e)).WindDelta)return;var m=e.PrevInAEL;f=e.NextInAEL,null!==m&&m.Curr.X===e.Bot.X&&m.Curr.Y===e.Bot.Y&&0===m.WindDelta&&m.OutIdx>=0&&m.Curr.Y>m.Top.Y&&t.ClipperBase.SlopesEqual3(e,m,this.m_UseFullRange)?(d=this.AddOutPt(m,e.Bot),this.AddJoin(c,d,e.Top)):null!==f&&f.Curr.X===e.Bot.X&&f.Curr.Y===e.Bot.Y&&0!==f.WindDelta&&f.OutIdx>=0&&f.Curr.Y>f.Top.Y&&t.ClipperBase.SlopesEqual3(e,f,this.m_UseFullRange)&&(d=this.AddOutPt(f,e.Bot),this.AddJoin(c,d,e.Top))}else e=this.UpdateEdgeIntoAEL(e);else e.OutIdx>=0&&this.AddOutPt(e,e.Top),this.DeleteFromAEL(e)},t.Clipper.prototype.GetNextInAEL=function(e,n){return n===t.Direction.dLeftToRight?e.NextInAEL:e.PrevInAEL},t.Clipper.prototype.IsMinima=function(e){return null!==e&&e.Prev.NextInLML!==e&&e.Next.NextInLML!==e},t.Clipper.prototype.IsMaxima=function(e,t){return null!==e&&e.Top.Y===t&&null===e.NextInLML},t.Clipper.prototype.IsIntermediate=function(e,t){return e.Top.Y===t&&null!==e.NextInLML},t.Clipper.prototype.GetMaximaPair=function(e){return t.IntPoint.op_Equality(e.Next.Top,e.Top)&&null===e.Next.NextInLML?e.Next:t.IntPoint.op_Equality(e.Prev.Top,e.Top)&&null===e.Prev.NextInLML?e.Prev:null},t.Clipper.prototype.GetMaximaPairEx=function(e){var n=this.GetMaximaPair(e);return null===n||n.OutIdx===t.ClipperBase.Skip||n.NextInAEL===n.PrevInAEL&&!t.ClipperBase.IsHorizontal(n)?null:n},t.Clipper.prototype.ProcessIntersections=function(e){if(null===this.m_ActiveEdges)return!0;try{if(this.BuildIntersectList(e),0===this.m_IntersectList.length)return!0;if(1!==this.m_IntersectList.length&&!this.FixupIntersectionOrder())return!1;this.ProcessIntersectList()}catch(e){this.m_SortedEdges=null,this.m_IntersectList.length=0,t.Error("ProcessIntersections error")}return this.m_SortedEdges=null,!0},t.Clipper.prototype.BuildIntersectList=function(e){if(null!==this.m_ActiveEdges){var n=this.m_ActiveEdges;for(this.m_SortedEdges=n;null!==n;)n.PrevInSEL=n.PrevInAEL,n.NextInSEL=n.NextInAEL,n.Curr.X=t.Clipper.TopX(n,e),n=n.NextInAEL;for(var i=!0;i&&null!==this.m_SortedEdges;){for(i=!1,n=this.m_SortedEdges;null!==n.NextInSEL;){var r=n.NextInSEL,s=new t.IntPoint0;if(n.Curr.X>r.Curr.X){this.IntersectPoint(n,r,s),s.Y<e&&(s=new t.IntPoint2(t.Clipper.TopX(n,e),e));var o=new t.IntersectNode;o.Edge1=n,o.Edge2=r,o.Pt.X=s.X,o.Pt.Y=s.Y,t.use_xyz&&(o.Pt.Z=s.Z),this.m_IntersectList.push(o),this.SwapPositionsInSEL(n,r),i=!0}else n=r}if(null===n.PrevInSEL)break;n.PrevInSEL.NextInSEL=null}this.m_SortedEdges=null}},t.Clipper.prototype.EdgesAdjacent=function(e){return e.Edge1.NextInSEL===e.Edge2||e.Edge1.PrevInSEL===e.Edge2},t.Clipper.IntersectNodeSort=function(e,t){return t.Pt.Y-e.Pt.Y},t.Clipper.prototype.FixupIntersectionOrder=function(){this.m_IntersectList.sort(this.m_IntersectNodeComparer),this.CopyAELToSEL();for(var e=this.m_IntersectList.length,t=0;t<e;t++){if(!this.EdgesAdjacent(this.m_IntersectList[t])){for(var n=t+1;n<e&&!this.EdgesAdjacent(this.m_IntersectList[n]);)n++;if(n===e)return!1;var i=this.m_IntersectList[t];this.m_IntersectList[t]=this.m_IntersectList[n],this.m_IntersectList[n]=i}this.SwapPositionsInSEL(this.m_IntersectList[t].Edge1,this.m_IntersectList[t].Edge2)}return!0},t.Clipper.prototype.ProcessIntersectList=function(){for(var e=0,t=this.m_IntersectList.length;e<t;e++){var n=this.m_IntersectList[e];this.IntersectEdges(n.Edge1,n.Edge2,n.Pt),this.SwapPositionsInAEL(n.Edge1,n.Edge2)}this.m_IntersectList.length=0},s.msie?t.Clipper.Round=function(e){return e<0?Math.ceil(e-.5):Math.round(e)}:s.chromium?t.Clipper.Round=function(e){return e<0?-Math.round(Math.abs(e)):Math.round(e)}:s.safari?t.Clipper.Round=function(e){return e<0?(e-=.5)<-2147483648?Math.ceil(e):0|e:(e+=.5)>2147483647?Math.floor(e):0|e}:t.Clipper.Round=function(e){return e<0?Math.ceil(e-.5):Math.floor(e+.5)},t.Clipper.TopX=function(e,n){return n===e.Top.Y?e.Top.X:e.Bot.X+t.Clipper.Round(e.Dx*(n-e.Bot.Y))},t.Clipper.prototype.IntersectPoint=function(e,n,i){var r,s;if(i.X=0,i.Y=0,e.Dx===n.Dx)return i.Y=e.Curr.Y,void(i.X=t.Clipper.TopX(e,i.Y));if(0===e.Delta.X)i.X=e.Bot.X,t.ClipperBase.IsHorizontal(n)?i.Y=n.Bot.Y:(s=n.Bot.Y-n.Bot.X/n.Dx,i.Y=t.Clipper.Round(i.X/n.Dx+s));else if(0===n.Delta.X)i.X=n.Bot.X,t.ClipperBase.IsHorizontal(e)?i.Y=e.Bot.Y:(r=e.Bot.Y-e.Bot.X/e.Dx,i.Y=t.Clipper.Round(i.X/e.Dx+r));else{r=e.Bot.X-e.Bot.Y*e.Dx;var o=((s=n.Bot.X-n.Bot.Y*n.Dx)-r)/(e.Dx-n.Dx);i.Y=t.Clipper.Round(o),Math.abs(e.Dx)<Math.abs(n.Dx)?i.X=t.Clipper.Round(e.Dx*o+r):i.X=t.Clipper.Round(n.Dx*o+s)}if(i.Y<e.Top.Y||i.Y<n.Top.Y){if(e.Top.Y>n.Top.Y)return i.Y=e.Top.Y,i.X=t.Clipper.TopX(n,e.Top.Y),i.X<e.Top.X;i.Y=n.Top.Y,Math.abs(e.Dx)<Math.abs(n.Dx)?i.X=t.Clipper.TopX(e,i.Y):i.X=t.Clipper.TopX(n,i.Y)}i.Y>e.Curr.Y&&(i.Y=e.Curr.Y,Math.abs(e.Dx)>Math.abs(n.Dx)?i.X=t.Clipper.TopX(n,i.Y):i.X=t.Clipper.TopX(e,i.Y))},t.Clipper.prototype.ProcessEdgesAtTopOfScanbeam=function(e){for(var n=this.m_ActiveEdges;null!==n;){var i=this.IsMaxima(n,e);if(i){var r=this.GetMaximaPairEx(n);i=null===r||!t.ClipperBase.IsHorizontal(r)}if(i){this.StrictlySimple&&this.InsertMaxima(n.Top.X);var s=n.PrevInAEL;this.DoMaxima(n),n=null===s?this.m_ActiveEdges:s.NextInAEL}else{if(this.IsIntermediate(n,e)&&t.ClipperBase.IsHorizontal(n.NextInLML)?((n=this.UpdateEdgeIntoAEL(n)).OutIdx>=0&&this.AddOutPt(n,n.Bot),this.AddEdgeToSEL(n)):(n.Curr.X=t.Clipper.TopX(n,e),n.Curr.Y=e),t.use_xyz&&(n.Top.Y===e?n.Curr.Z=n.Top.Z:n.Bot.Y===e?n.Curr.Z=n.Bot.Z:n.Curr.Z=0),this.StrictlySimple&&(s=n.PrevInAEL,n.OutIdx>=0&&0!==n.WindDelta&&null!==s&&s.OutIdx>=0&&s.Curr.X===n.Curr.X&&0!==s.WindDelta)){var o=new t.IntPoint1(n.Curr);t.use_xyz&&this.SetZ(o,s,n);var a=this.AddOutPt(s,o),A=this.AddOutPt(n,o);this.AddJoin(a,A,o)}n=n.NextInAEL}}for(this.ProcessHorizontals(),this.m_Maxima=null,n=this.m_ActiveEdges;null!==n;){if(this.IsIntermediate(n,e)){a=null,n.OutIdx>=0&&(a=this.AddOutPt(n,n.Top)),s=(n=this.UpdateEdgeIntoAEL(n)).PrevInAEL;var l=n.NextInAEL;null!==s&&s.Curr.X===n.Bot.X&&s.Curr.Y===n.Bot.Y&&null!==a&&s.OutIdx>=0&&s.Curr.Y===s.Top.Y&&t.ClipperBase.SlopesEqual5(n.Curr,n.Top,s.Curr,s.Top,this.m_UseFullRange)&&0!==n.WindDelta&&0!==s.WindDelta?(A=this.AddOutPt(ePrev2,n.Bot),this.AddJoin(a,A,n.Top)):null!==l&&l.Curr.X===n.Bot.X&&l.Curr.Y===n.Bot.Y&&null!==a&&l.OutIdx>=0&&l.Curr.Y===l.Top.Y&&t.ClipperBase.SlopesEqual5(n.Curr,n.Top,l.Curr,l.Top,this.m_UseFullRange)&&0!==n.WindDelta&&0!==l.WindDelta&&(A=this.AddOutPt(l,n.Bot),this.AddJoin(a,A,n.Top))}n=n.NextInAEL}},t.Clipper.prototype.DoMaxima=function(e){var n=this.GetMaximaPairEx(e);if(null===n)return e.OutIdx>=0&&this.AddOutPt(e,e.Top),void this.DeleteFromAEL(e);for(var i=e.NextInAEL;null!==i&&i!==n;)this.IntersectEdges(e,i,e.Top),this.SwapPositionsInAEL(e,i),i=e.NextInAEL;-1===e.OutIdx&&-1===n.OutIdx?(this.DeleteFromAEL(e),this.DeleteFromAEL(n)):e.OutIdx>=0&&n.OutIdx>=0?(e.OutIdx>=0&&this.AddLocalMaxPoly(e,n,e.Top),this.DeleteFromAEL(e),this.DeleteFromAEL(n)):t.use_lines&&0===e.WindDelta?(e.OutIdx>=0&&(this.AddOutPt(e,e.Top),e.OutIdx=t.ClipperBase.Unassigned),this.DeleteFromAEL(e),n.OutIdx>=0&&(this.AddOutPt(n,e.Top),n.OutIdx=t.ClipperBase.Unassigned),this.DeleteFromAEL(n)):t.Error("DoMaxima error")},t.Clipper.ReversePaths=function(e){for(var t=0,n=e.length;t<n;t++)e[t].reverse()},t.Clipper.Orientation=function(e){return t.Clipper.Area(e)>=0},t.Clipper.prototype.PointCount=function(e){if(null===e)return 0;var t=0,n=e;do{t++,n=n.Next}while(n!==e);return t},t.Clipper.prototype.BuildResult=function(e){t.Clear(e);for(var n=0,i=this.m_PolyOuts.length;n<i;n++){var r=this.m_PolyOuts[n];if(null!==r.Pts){var s=r.Pts.Prev,o=this.PointCount(s);if(!(o<2)){for(var a=new Array(o),A=0;A<o;A++)a[A]=s.Pt,s=s.Prev;e.push(a)}}}},t.Clipper.prototype.BuildResult2=function(e){e.Clear();for(var n=0,i=this.m_PolyOuts.length;n<i;n++){var r=this.m_PolyOuts[n],s=this.PointCount(r.Pts);if(!(r.IsOpen&&s<2||!r.IsOpen&&s<3)){this.FixHoleLinkage(r);var o=new t.PolyNode;e.m_AllPolys.push(o),r.PolyNode=o,o.m_polygon.length=s;for(var a=r.Pts.Prev,A=0;A<s;A++)o.m_polygon[A]=a.Pt,a=a.Prev}}for(n=0,i=this.m_PolyOuts.length;n<i;n++)null!==(r=this.m_PolyOuts[n]).PolyNode&&(r.IsOpen?(r.PolyNode.IsOpen=!0,e.AddChild(r.PolyNode)):null!==r.FirstLeft&&null!==r.FirstLeft.PolyNode?r.FirstLeft.PolyNode.AddChild(r.PolyNode):e.AddChild(r.PolyNode))},t.Clipper.prototype.FixupOutPolyline=function(e){for(var n=e.Pts,i=n.Prev;n!==i;)if(n=n.Next,t.IntPoint.op_Equality(n.Pt,n.Prev.Pt)){n===i&&(i=n.Prev);var r=n.Prev;r.Next=n.Next,n.Next.Prev=r,n=r}n===n.Prev&&(e.Pts=null)},t.Clipper.prototype.FixupOutPolygon=function(e){var n=null;e.BottomPt=null;for(var i=e.Pts,r=this.PreserveCollinear||this.StrictlySimple;;){if(i.Prev===i||i.Prev===i.Next)return void(e.Pts=null);if(t.IntPoint.op_Equality(i.Pt,i.Next.Pt)||t.IntPoint.op_Equality(i.Pt,i.Prev.Pt)||t.ClipperBase.SlopesEqual4(i.Prev.Pt,i.Pt,i.Next.Pt,this.m_UseFullRange)&&(!r||!this.Pt2IsBetweenPt1AndPt3(i.Prev.Pt,i.Pt,i.Next.Pt)))n=null,i.Prev.Next=i.Next,i.Next.Prev=i.Prev,i=i.Prev;else{if(i===n)break;null===n&&(n=i),i=i.Next}}e.Pts=i},t.Clipper.prototype.DupOutPt=function(e,n){var i=new t.OutPt;return i.Pt.X=e.Pt.X,i.Pt.Y=e.Pt.Y,t.use_xyz&&(i.Pt.Z=e.Pt.Z),i.Idx=e.Idx,n?(i.Next=e.Next,i.Prev=e,e.Next.Prev=i,e.Next=i):(i.Prev=e.Prev,i.Next=e,e.Prev.Next=i,e.Prev=i),i},t.Clipper.prototype.GetOverlap=function(e,t,n,i,r){return e<t?n<i?(r.Left=Math.max(e,n),r.Right=Math.min(t,i)):(r.Left=Math.max(e,i),r.Right=Math.min(t,n)):n<i?(r.Left=Math.max(t,n),r.Right=Math.min(e,i)):(r.Left=Math.max(t,i),r.Right=Math.min(e,n)),r.Left<r.Right},t.Clipper.prototype.JoinHorz=function(e,n,i,r,s,o){var a=e.Pt.X>n.Pt.X?t.Direction.dRightToLeft:t.Direction.dLeftToRight,A=i.Pt.X>r.Pt.X?t.Direction.dRightToLeft:t.Direction.dLeftToRight;if(a===A)return!1;if(a===t.Direction.dLeftToRight){for(;e.Next.Pt.X<=s.X&&e.Next.Pt.X>=e.Pt.X&&e.Next.Pt.Y===s.Y;)e=e.Next;o&&e.Pt.X!==s.X&&(e=e.Next),n=this.DupOutPt(e,!o),t.IntPoint.op_Inequality(n.Pt,s)&&((e=n).Pt.X=s.X,e.Pt.Y=s.Y,t.use_xyz&&(e.Pt.Z=s.Z),n=this.DupOutPt(e,!o))}else{for(;e.Next.Pt.X>=s.X&&e.Next.Pt.X<=e.Pt.X&&e.Next.Pt.Y===s.Y;)e=e.Next;o||e.Pt.X===s.X||(e=e.Next),n=this.DupOutPt(e,o),t.IntPoint.op_Inequality(n.Pt,s)&&((e=n).Pt.X=s.X,e.Pt.Y=s.Y,t.use_xyz&&(e.Pt.Z=s.Z),n=this.DupOutPt(e,o))}if(A===t.Direction.dLeftToRight){for(;i.Next.Pt.X<=s.X&&i.Next.Pt.X>=i.Pt.X&&i.Next.Pt.Y===s.Y;)i=i.Next;o&&i.Pt.X!==s.X&&(i=i.Next),r=this.DupOutPt(i,!o),t.IntPoint.op_Inequality(r.Pt,s)&&((i=r).Pt.X=s.X,i.Pt.Y=s.Y,t.use_xyz&&(i.Pt.Z=s.Z),r=this.DupOutPt(i,!o))}else{for(;i.Next.Pt.X>=s.X&&i.Next.Pt.X<=i.Pt.X&&i.Next.Pt.Y===s.Y;)i=i.Next;o||i.Pt.X===s.X||(i=i.Next),r=this.DupOutPt(i,o),t.IntPoint.op_Inequality(r.Pt,s)&&((i=r).Pt.X=s.X,i.Pt.Y=s.Y,t.use_xyz&&(i.Pt.Z=s.Z),r=this.DupOutPt(i,o))}return a===t.Direction.dLeftToRight===o?(e.Prev=i,i.Next=e,n.Next=r,r.Prev=n):(e.Next=i,i.Prev=e,n.Prev=r,r.Next=n),!0},t.Clipper.prototype.JoinPoints=function(e,n,i){var r=e.OutPt1,s=new t.OutPt,o=e.OutPt2,a=new t.OutPt,A=e.OutPt1.Pt.Y===e.OffPt.Y;if(A&&t.IntPoint.op_Equality(e.OffPt,e.OutPt1.Pt)&&t.IntPoint.op_Equality(e.OffPt,e.OutPt2.Pt)){if(n!==i)return!1;for(s=e.OutPt1.Next;s!==r&&t.IntPoint.op_Equality(s.Pt,e.OffPt);)s=s.Next;var l=s.Pt.Y>e.OffPt.Y;for(a=e.OutPt2.Next;a!==o&&t.IntPoint.op_Equality(a.Pt,e.OffPt);)a=a.Next;return l!==a.Pt.Y>e.OffPt.Y&&(l?(s=this.DupOutPt(r,!1),a=this.DupOutPt(o,!0),r.Prev=o,o.Next=r,s.Next=a,a.Prev=s,e.OutPt1=r,e.OutPt2=s,!0):(s=this.DupOutPt(r,!0),a=this.DupOutPt(o,!1),r.Next=o,o.Prev=r,s.Prev=a,a.Next=s,e.OutPt1=r,e.OutPt2=s,!0))}if(A){for(s=r;r.Prev.Pt.Y===r.Pt.Y&&r.Prev!==s&&r.Prev!==o;)r=r.Prev;for(;s.Next.Pt.Y===s.Pt.Y&&s.Next!==r&&s.Next!==o;)s=s.Next;if(s.Next===r||s.Next===o)return!1;for(a=o;o.Prev.Pt.Y===o.Pt.Y&&o.Prev!==a&&o.Prev!==s;)o=o.Prev;for(;a.Next.Pt.Y===a.Pt.Y&&a.Next!==o&&a.Next!==r;)a=a.Next;if(a.Next===o||a.Next===r)return!1;var c={Left:null,Right:null};if(!this.GetOverlap(r.Pt.X,s.Pt.X,o.Pt.X,a.Pt.X,c))return!1;var p,h=c.Left,u=c.Right,d=new t.IntPoint0;return r.Pt.X>=h&&r.Pt.X<=u?(d.X=r.Pt.X,d.Y=r.Pt.Y,t.use_xyz&&(d.Z=r.Pt.Z),p=r.Pt.X>s.Pt.X):o.Pt.X>=h&&o.Pt.X<=u?(d.X=o.Pt.X,d.Y=o.Pt.Y,t.use_xyz&&(d.Z=o.Pt.Z),p=o.Pt.X>a.Pt.X):s.Pt.X>=h&&s.Pt.X<=u?(d.X=s.Pt.X,d.Y=s.Pt.Y,t.use_xyz&&(d.Z=s.Pt.Z),p=s.Pt.X>r.Pt.X):(d.X=a.Pt.X,d.Y=a.Pt.Y,t.use_xyz&&(d.Z=a.Pt.Z),p=a.Pt.X>o.Pt.X),e.OutPt1=r,e.OutPt2=o,this.JoinHorz(r,s,o,a,d,p)}for(s=r.Next;t.IntPoint.op_Equality(s.Pt,r.Pt)&&s!==r;)s=s.Next;var g=s.Pt.Y>r.Pt.Y||!t.ClipperBase.SlopesEqual4(r.Pt,s.Pt,e.OffPt,this.m_UseFullRange);if(g){for(s=r.Prev;t.IntPoint.op_Equality(s.Pt,r.Pt)&&s!==r;)s=s.Prev;if(s.Pt.Y>r.Pt.Y||!t.ClipperBase.SlopesEqual4(r.Pt,s.Pt,e.OffPt,this.m_UseFullRange))return!1}for(a=o.Next;t.IntPoint.op_Equality(a.Pt,o.Pt)&&a!==o;)a=a.Next;var f=a.Pt.Y>o.Pt.Y||!t.ClipperBase.SlopesEqual4(o.Pt,a.Pt,e.OffPt,this.m_UseFullRange);if(f){for(a=o.Prev;t.IntPoint.op_Equality(a.Pt,o.Pt)&&a!==o;)a=a.Prev;if(a.Pt.Y>o.Pt.Y||!t.ClipperBase.SlopesEqual4(o.Pt,a.Pt,e.OffPt,this.m_UseFullRange))return!1}return!(s===r||a===o||s===a||n===i&&g===f||(g?(s=this.DupOutPt(r,!1),a=this.DupOutPt(o,!0),r.Prev=o,o.Next=r,s.Next=a,a.Prev=s,e.OutPt1=r,e.OutPt2=s,0):(s=this.DupOutPt(r,!0),a=this.DupOutPt(o,!1),r.Next=o,o.Prev=r,s.Prev=a,a.Next=s,e.OutPt1=r,e.OutPt2=s,0)))},t.Clipper.GetBounds=function(e){for(var n=0,i=e.length;n<i&&0===e[n].length;)n++;if(n===i)return new t.IntRect(0,0,0,0);var r=new t.IntRect;for(r.left=e[n][0].X,r.right=r.left,r.top=e[n][0].Y,r.bottom=r.top;n<i;n++)for(var s=0,o=e[n].length;s<o;s++)e[n][s].X<r.left?r.left=e[n][s].X:e[n][s].X>r.right&&(r.right=e[n][s].X),e[n][s].Y<r.top?r.top=e[n][s].Y:e[n][s].Y>r.bottom&&(r.bottom=e[n][s].Y);return r},t.Clipper.prototype.GetBounds2=function(e){var n=e,i=new t.IntRect;for(i.left=e.Pt.X,i.right=e.Pt.X,i.top=e.Pt.Y,i.bottom=e.Pt.Y,e=e.Next;e!==n;)e.Pt.X<i.left&&(i.left=e.Pt.X),e.Pt.X>i.right&&(i.right=e.Pt.X),e.Pt.Y<i.top&&(i.top=e.Pt.Y),e.Pt.Y>i.bottom&&(i.bottom=e.Pt.Y),e=e.Next;return i},t.Clipper.PointInPolygon=function(e,t){var n=0,i=t.length;if(i<3)return 0;for(var r=t[0],s=1;s<=i;++s){var o=s===i?t[0]:t[s];if(o.Y===e.Y&&(o.X===e.X||r.Y===e.Y&&o.X>e.X==r.X<e.X))return-1;if(r.Y<e.Y!=o.Y<e.Y)if(r.X>=e.X)if(o.X>e.X)n=1-n;else{if(0==(a=(r.X-e.X)*(o.Y-e.Y)-(o.X-e.X)*(r.Y-e.Y)))return-1;a>0==o.Y>r.Y&&(n=1-n)}else if(o.X>e.X){var a;if(0==(a=(r.X-e.X)*(o.Y-e.Y)-(o.X-e.X)*(r.Y-e.Y)))return-1;a>0==o.Y>r.Y&&(n=1-n)}r=o}return n},t.Clipper.prototype.PointInPolygon=function(e,t){var n=0,i=t,r=e.X,s=e.Y,o=t.Pt.X,a=t.Pt.Y;do{var A=(t=t.Next).Pt.X,l=t.Pt.Y;if(l===s&&(A===r||a===s&&A>r==o<r))return-1;if(a<s!=l<s)if(o>=r)if(A>r)n=1-n;else{if(0==(c=(o-r)*(l-s)-(A-r)*(a-s)))return-1;c>0==l>a&&(n=1-n)}else if(A>r){var c;if(0==(c=(o-r)*(l-s)-(A-r)*(a-s)))return-1;c>0==l>a&&(n=1-n)}o=A,a=l}while(i!==t);return n},t.Clipper.prototype.Poly2ContainsPoly1=function(e,t){var n=e;do{var i=this.PointInPolygon(n.Pt,t);if(i>=0)return i>0;n=n.Next}while(n!==e);return!0},t.Clipper.prototype.FixupFirstLefts1=function(e,n){for(var i,r,s=0,o=this.m_PolyOuts.length;s<o;s++)i=this.m_PolyOuts[s],r=t.Clipper.ParseFirstLeft(i.FirstLeft),null!==i.Pts&&r===e&&this.Poly2ContainsPoly1(i.Pts,n.Pts)&&(i.FirstLeft=n)},t.Clipper.prototype.FixupFirstLefts2=function(e,n){for(var i,r,s=n.FirstLeft,o=0,a=this.m_PolyOuts.length;o<a;o++)null!==(i=this.m_PolyOuts[o]).Pts&&i!==n&&i!==e&&((r=t.Clipper.ParseFirstLeft(i.FirstLeft))!==s&&r!==e&&r!==n||(this.Poly2ContainsPoly1(i.Pts,e.Pts)?i.FirstLeft=e:this.Poly2ContainsPoly1(i.Pts,n.Pts)?i.FirstLeft=n:i.FirstLeft!==e&&i.FirstLeft!==n||(i.FirstLeft=s)))},t.Clipper.prototype.FixupFirstLefts3=function(e,n){for(var i,r,s=0,o=this.m_PolyOuts.length;s<o;s++)i=this.m_PolyOuts[s],r=t.Clipper.ParseFirstLeft(i.FirstLeft),null!==i.Pts&&r===e&&(i.FirstLeft=n)},t.Clipper.ParseFirstLeft=function(e){for(;null!==e&&null===e.Pts;)e=e.FirstLeft;return e},t.Clipper.prototype.JoinCommonEdges=function(){for(var e=0,t=this.m_Joins.length;e<t;e++){var n,i=this.m_Joins[e],r=this.GetOutRec(i.OutPt1.Idx),s=this.GetOutRec(i.OutPt2.Idx);null!==r.Pts&&null!==s.Pts&&(r.IsOpen||s.IsOpen||(n=r===s?r:this.OutRec1RightOfOutRec2(r,s)?s:this.OutRec1RightOfOutRec2(s,r)?r:this.GetLowermostRec(r,s),this.JoinPoints(i,r,s)&&(r===s?(r.Pts=i.OutPt1,r.BottomPt=null,(s=this.CreateOutRec()).Pts=i.OutPt2,this.UpdateOutPtIdxs(s),this.Poly2ContainsPoly1(s.Pts,r.Pts)?(s.IsHole=!r.IsHole,s.FirstLeft=r,this.m_UsingPolyTree&&this.FixupFirstLefts2(s,r),(s.IsHole^this.ReverseSolution)==this.Area$1(s)>0&&this.ReversePolyPtLinks(s.Pts)):this.Poly2ContainsPoly1(r.Pts,s.Pts)?(s.IsHole=r.IsHole,r.IsHole=!s.IsHole,s.FirstLeft=r.FirstLeft,r.FirstLeft=s,this.m_UsingPolyTree&&this.FixupFirstLefts2(r,s),(r.IsHole^this.ReverseSolution)==this.Area$1(r)>0&&this.ReversePolyPtLinks(r.Pts)):(s.IsHole=r.IsHole,s.FirstLeft=r.FirstLeft,this.m_UsingPolyTree&&this.FixupFirstLefts1(r,s))):(s.Pts=null,s.BottomPt=null,s.Idx=r.Idx,r.IsHole=n.IsHole,n===s&&(r.FirstLeft=s.FirstLeft),s.FirstLeft=r,this.m_UsingPolyTree&&this.FixupFirstLefts3(s,r)))))}},t.Clipper.prototype.UpdateOutPtIdxs=function(e){var t=e.Pts;do{t.Idx=e.Idx,t=t.Prev}while(t!==e.Pts)},t.Clipper.prototype.DoSimplePolygons=function(){for(var e=0;e<this.m_PolyOuts.length;){var n=this.m_PolyOuts[e++],i=n.Pts;if(null!==i&&!n.IsOpen)do{for(var r=i.Next;r!==n.Pts;){if(t.IntPoint.op_Equality(i.Pt,r.Pt)&&r.Next!==i&&r.Prev!==i){var s=i.Prev,o=r.Prev;i.Prev=o,o.Next=i,r.Prev=s,s.Next=r,n.Pts=i;var a=this.CreateOutRec();a.Pts=r,this.UpdateOutPtIdxs(a),this.Poly2ContainsPoly1(a.Pts,n.Pts)?(a.IsHole=!n.IsHole,a.FirstLeft=n,this.m_UsingPolyTree&&this.FixupFirstLefts2(a,n)):this.Poly2ContainsPoly1(n.Pts,a.Pts)?(a.IsHole=n.IsHole,n.IsHole=!a.IsHole,a.FirstLeft=n.FirstLeft,n.FirstLeft=a,this.m_UsingPolyTree&&this.FixupFirstLefts2(n,a)):(a.IsHole=n.IsHole,a.FirstLeft=n.FirstLeft,this.m_UsingPolyTree&&this.FixupFirstLefts1(n,a)),r=i}r=r.Next}i=i.Next}while(i!==n.Pts)}},t.Clipper.Area=function(e){if(!Array.isArray(e))return 0;var t=e.length;if(t<3)return 0;for(var n=0,i=0,r=t-1;i<t;++i)n+=(e[r].X+e[i].X)*(e[r].Y-e[i].Y),r=i;return.5*-n},t.Clipper.prototype.Area=function(e){var t=e;if(null===e)return 0;var n=0;do{n+=(e.Prev.Pt.X+e.Pt.X)*(e.Prev.Pt.Y-e.Pt.Y),e=e.Next}while(e!==t);return.5*n},t.Clipper.prototype.Area$1=function(e){return this.Area(e.Pts)},t.Clipper.SimplifyPolygon=function(e,n){var i=new Array,r=new t.Clipper(0);return r.StrictlySimple=!0,r.AddPath(e,t.PolyType.ptSubject,!0),r.Execute(t.ClipType.ctUnion,i,n,n),i},t.Clipper.SimplifyPolygons=function(e,n){void 0===n&&(n=t.PolyFillType.pftEvenOdd);var i=new Array,r=new t.Clipper(0);return r.StrictlySimple=!0,r.AddPaths(e,t.PolyType.ptSubject,!0),r.Execute(t.ClipType.ctUnion,i,n,n),i},t.Clipper.DistanceSqrd=function(e,t){var n=e.X-t.X,i=e.Y-t.Y;return n*n+i*i},t.Clipper.DistanceFromLineSqrd=function(e,t,n){var i=t.Y-n.Y,r=n.X-t.X,s=i*t.X+r*t.Y;return(s=i*e.X+r*e.Y-s)*s/(i*i+r*r)},t.Clipper.SlopesNearCollinear=function(e,n,i,r){return Math.abs(e.X-n.X)>Math.abs(e.Y-n.Y)?e.X>n.X==e.X<i.X?t.Clipper.DistanceFromLineSqrd(e,n,i)<r:n.X>e.X==n.X<i.X?t.Clipper.DistanceFromLineSqrd(n,e,i)<r:t.Clipper.DistanceFromLineSqrd(i,e,n)<r:e.Y>n.Y==e.Y<i.Y?t.Clipper.DistanceFromLineSqrd(e,n,i)<r:n.Y>e.Y==n.Y<i.Y?t.Clipper.DistanceFromLineSqrd(n,e,i)<r:t.Clipper.DistanceFromLineSqrd(i,e,n)<r},t.Clipper.PointsAreClose=function(e,t,n){var i=e.X-t.X,r=e.Y-t.Y;return i*i+r*r<=n},t.Clipper.ExcludeOp=function(e){var t=e.Prev;return t.Next=e.Next,e.Next.Prev=t,t.Idx=0,t},t.Clipper.CleanPolygon=function(e,n){void 0===n&&(n=1.415);var i=e.length;if(0===i)return new Array;for(var r=new Array(i),s=0;s<i;++s)r[s]=new t.OutPt;for(s=0;s<i;++s)r[s].Pt=e[s],r[s].Next=r[(s+1)%i],r[s].Next.Prev=r[s],r[s].Idx=0;for(var o=n*n,a=r[0];0===a.Idx&&a.Next!==a.Prev;)t.Clipper.PointsAreClose(a.Pt,a.Prev.Pt,o)?(a=t.Clipper.ExcludeOp(a),i--):t.Clipper.PointsAreClose(a.Prev.Pt,a.Next.Pt,o)?(t.Clipper.ExcludeOp(a.Next),a=t.Clipper.ExcludeOp(a),i-=2):t.Clipper.SlopesNearCollinear(a.Prev.Pt,a.Pt,a.Next.Pt,o)?(a=t.Clipper.ExcludeOp(a),i--):(a.Idx=1,a=a.Next);i<3&&(i=0);var A=new Array(i);for(s=0;s<i;++s)A[s]=new t.IntPoint1(a.Pt),a=a.Next;return r=null,A},t.Clipper.CleanPolygons=function(e,n){for(var i=new Array(e.length),r=0,s=e.length;r<s;r++)i[r]=t.Clipper.CleanPolygon(e[r],n);return i},t.Clipper.Minkowski=function(e,n,i,r){var s=r?1:0,o=e.length,a=n.length,A=new Array;if(i)for(var l=0;l<a;l++){for(var c=new Array(o),p=0,h=e.length,u=e[p];p<h;u=e[++p])c[p]=new t.IntPoint2(n[l].X+u.X,n[l].Y+u.Y);A.push(c)}else for(l=0;l<a;l++){for(c=new Array(o),p=0,h=e.length,u=e[p];p<h;u=e[++p])c[p]=new t.IntPoint2(n[l].X-u.X,n[l].Y-u.Y);A.push(c)}var d=new Array;for(l=0;l<a-1+s;l++)for(p=0;p<o;p++){var g=new Array;g.push(A[l%a][p%o]),g.push(A[(l+1)%a][p%o]),g.push(A[(l+1)%a][(p+1)%o]),g.push(A[l%a][(p+1)%o]),t.Clipper.Orientation(g)||g.reverse(),d.push(g)}return d},t.Clipper.MinkowskiSum=function(e,n,i){if(n[0]instanceof Array){l=n;for(var r=new t.Paths,s=(a=new t.Clipper,0);s<l.length;++s){var o=t.Clipper.Minkowski(e,l[s],!0,i);a.AddPaths(o,t.PolyType.ptSubject,!0),i&&(A=t.Clipper.TranslatePath(l[s],e[0]),a.AddPath(A,t.PolyType.ptClip,!0))}return a.Execute(t.ClipType.ctUnion,r,t.PolyFillType.pftNonZero,t.PolyFillType.pftNonZero),r}var a,A=n,l=t.Clipper.Minkowski(e,A,!0,i);return(a=new t.Clipper).AddPaths(l,t.PolyType.ptSubject,!0),a.Execute(t.ClipType.ctUnion,l,t.PolyFillType.pftNonZero,t.PolyFillType.pftNonZero),l},t.Clipper.TranslatePath=function(e,n){for(var i=new t.Path,r=0;r<e.length;r++)i.push(new t.IntPoint2(e[r].X+n.X,e[r].Y+n.Y));return i},t.Clipper.MinkowskiDiff=function(e,n){var i=t.Clipper.Minkowski(e,n,!1,!0),r=new t.Clipper;return r.AddPaths(i,t.PolyType.ptSubject,!0),r.Execute(t.ClipType.ctUnion,i,t.PolyFillType.pftNonZero,t.PolyFillType.pftNonZero),i},t.Clipper.PolyTreeToPaths=function(e){var n=new Array;return t.Clipper.AddPolyNodeToPaths(e,t.Clipper.NodeType.ntAny,n),n},t.Clipper.AddPolyNodeToPaths=function(e,n,i){var r=!0;switch(n){case t.Clipper.NodeType.ntOpen:return;case t.Clipper.NodeType.ntClosed:r=!e.IsOpen}e.m_polygon.length>0&&r&&i.push(e.m_polygon);for(var s=0,o=e.Childs(),a=o.length,A=o[s];s<a;A=o[++s])t.Clipper.AddPolyNodeToPaths(A,n,i)},t.Clipper.OpenPathsFromPolyTree=function(e){for(var n=new t.Paths,i=0,r=e.ChildCount();i<r;i++)e.Childs()[i].IsOpen&&n.push(e.Childs()[i].m_polygon);return n},t.Clipper.ClosedPathsFromPolyTree=function(e){var n=new t.Paths;return t.Clipper.AddPolyNodeToPaths(e,t.Clipper.NodeType.ntClosed,n),n},Inherit(t.Clipper,t.ClipperBase),t.Clipper.NodeType={ntAny:0,ntOpen:1,ntClosed:2},t.ClipperOffset=function(e,n){void 0===e&&(e=2),void 0===n&&(n=t.ClipperOffset.def_arc_tolerance),this.m_destPolys=new t.Paths,this.m_srcPoly=new t.Path,this.m_destPoly=new t.Path,this.m_normals=new Array,this.m_delta=0,this.m_sinA=0,this.m_sin=0,this.m_cos=0,this.m_miterLim=0,this.m_StepsPerRad=0,this.m_lowest=new t.IntPoint0,this.m_polyNodes=new t.PolyNode,this.MiterLimit=e,this.ArcTolerance=n,this.m_lowest.X=-1},t.ClipperOffset.two_pi=6.28318530717959,t.ClipperOffset.def_arc_tolerance=.25,t.ClipperOffset.prototype.Clear=function(){t.Clear(this.m_polyNodes.Childs()),this.m_lowest.X=-1},t.ClipperOffset.Round=t.Clipper.Round,t.ClipperOffset.prototype.AddPath=function(e,n,i){var r=e.length-1;if(!(r<0)){var s=new t.PolyNode;if(s.m_jointype=n,s.m_endtype=i,i===t.EndType.etClosedLine||i===t.EndType.etClosedPolygon)for(;r>0&&t.IntPoint.op_Equality(e[0],e[r]);)r--;s.m_polygon.push(e[0]);for(var o=0,a=0,A=1;A<=r;A++)t.IntPoint.op_Inequality(s.m_polygon[o],e[A])&&(o++,s.m_polygon.push(e[A]),(e[A].Y>s.m_polygon[a].Y||e[A].Y===s.m_polygon[a].Y&&e[A].X<s.m_polygon[a].X)&&(a=o));if(!(i===t.EndType.etClosedPolygon&&o<2)&&(this.m_polyNodes.AddChild(s),i===t.EndType.etClosedPolygon))if(this.m_lowest.X<0)this.m_lowest=new t.IntPoint2(this.m_polyNodes.ChildCount()-1,a);else{var l=this.m_polyNodes.Childs()[this.m_lowest.X].m_polygon[this.m_lowest.Y];(s.m_polygon[a].Y>l.Y||s.m_polygon[a].Y===l.Y&&s.m_polygon[a].X<l.X)&&(this.m_lowest=new t.IntPoint2(this.m_polyNodes.ChildCount()-1,a))}}},t.ClipperOffset.prototype.AddPaths=function(e,t,n){for(var i=0,r=e.length;i<r;i++)this.AddPath(e[i],t,n)},t.ClipperOffset.prototype.FixOrientations=function(){if(this.m_lowest.X>=0&&!t.Clipper.Orientation(this.m_polyNodes.Childs()[this.m_lowest.X].m_polygon))for(var e=0;e<this.m_polyNodes.ChildCount();e++)((n=this.m_polyNodes.Childs()[e]).m_endtype===t.EndType.etClosedPolygon||n.m_endtype===t.EndType.etClosedLine&&t.Clipper.Orientation(n.m_polygon))&&n.m_polygon.reverse();else for(e=0;e<this.m_polyNodes.ChildCount();e++){var n;(n=this.m_polyNodes.Childs()[e]).m_endtype!==t.EndType.etClosedLine||t.Clipper.Orientation(n.m_polygon)||n.m_polygon.reverse()}},t.ClipperOffset.GetUnitNormal=function(e,n){var i=n.X-e.X,r=n.Y-e.Y;if(0===i&&0===r)return new t.DoublePoint2(0,0);var s=1/Math.sqrt(i*i+r*r);return i*=s,r*=s,new t.DoublePoint2(r,-i)},t.ClipperOffset.prototype.DoOffset=function(e){if(this.m_destPolys=new Array,this.m_delta=e,t.ClipperBase.near_zero(e))for(var n=0;n<this.m_polyNodes.ChildCount();n++)(s=this.m_polyNodes.Childs()[n]).m_endtype===t.EndType.etClosedPolygon&&this.m_destPolys.push(s.m_polygon);else{var i;this.MiterLimit>2?this.m_miterLim=2/(this.MiterLimit*this.MiterLimit):this.m_miterLim=.5,i=this.ArcTolerance<=0?t.ClipperOffset.def_arc_tolerance:this.ArcTolerance>Math.abs(e)*t.ClipperOffset.def_arc_tolerance?Math.abs(e)*t.ClipperOffset.def_arc_tolerance:this.ArcTolerance;var r=3.14159265358979/Math.acos(1-i/Math.abs(e));for(this.m_sin=Math.sin(t.ClipperOffset.two_pi/r),this.m_cos=Math.cos(t.ClipperOffset.two_pi/r),this.m_StepsPerRad=r/t.ClipperOffset.two_pi,e<0&&(this.m_sin=-this.m_sin),n=0;n<this.m_polyNodes.ChildCount();n++){var s=this.m_polyNodes.Childs()[n];this.m_srcPoly=s.m_polygon;var o=this.m_srcPoly.length;if(!(0===o||e<=0&&(o<3||s.m_endtype!==t.EndType.etClosedPolygon)))if(this.m_destPoly=new Array,1!==o){for(this.m_normals.length=0,h=0;h<o-1;h++)this.m_normals.push(t.ClipperOffset.GetUnitNormal(this.m_srcPoly[h],this.m_srcPoly[h+1]));if(s.m_endtype===t.EndType.etClosedLine||s.m_endtype===t.EndType.etClosedPolygon?this.m_normals.push(t.ClipperOffset.GetUnitNormal(this.m_srcPoly[o-1],this.m_srcPoly[0])):this.m_normals.push(new t.DoublePoint1(this.m_normals[o-2])),s.m_endtype===t.EndType.etClosedPolygon){var a=o-1;for(h=0;h<o;h++)a=this.OffsetPoint(h,a,s.m_jointype);this.m_destPolys.push(this.m_destPoly)}else if(s.m_endtype===t.EndType.etClosedLine){for(a=o-1,h=0;h<o;h++)a=this.OffsetPoint(h,a,s.m_jointype);this.m_destPolys.push(this.m_destPoly),this.m_destPoly=new Array;var A=this.m_normals[o-1];for(h=o-1;h>0;h--)this.m_normals[h]=new t.DoublePoint2(-this.m_normals[h-1].X,-this.m_normals[h-1].Y);for(this.m_normals[0]=new t.DoublePoint2(-A.X,-A.Y),a=0,h=o-1;h>=0;h--)a=this.OffsetPoint(h,a,s.m_jointype);this.m_destPolys.push(this.m_destPoly)}else{var l;for(a=0,h=1;h<o-1;++h)a=this.OffsetPoint(h,a,s.m_jointype);for(s.m_endtype===t.EndType.etOpenButt?(h=o-1,l=new t.IntPoint2(t.ClipperOffset.Round(this.m_srcPoly[h].X+this.m_normals[h].X*e),t.ClipperOffset.Round(this.m_srcPoly[h].Y+this.m_normals[h].Y*e)),this.m_destPoly.push(l),l=new t.IntPoint2(t.ClipperOffset.Round(this.m_srcPoly[h].X-this.m_normals[h].X*e),t.ClipperOffset.Round(this.m_srcPoly[h].Y-this.m_normals[h].Y*e)),this.m_destPoly.push(l)):(h=o-1,a=o-2,this.m_sinA=0,this.m_normals[h]=new t.DoublePoint2(-this.m_normals[h].X,-this.m_normals[h].Y),s.m_endtype===t.EndType.etOpenSquare?this.DoSquare(h,a):this.DoRound(h,a)),h=o-1;h>0;h--)this.m_normals[h]=new t.DoublePoint2(-this.m_normals[h-1].X,-this.m_normals[h-1].Y);for(this.m_normals[0]=new t.DoublePoint2(-this.m_normals[1].X,-this.m_normals[1].Y),h=(a=o-1)-1;h>0;--h)a=this.OffsetPoint(h,a,s.m_jointype);s.m_endtype===t.EndType.etOpenButt?(l=new t.IntPoint2(t.ClipperOffset.Round(this.m_srcPoly[0].X-this.m_normals[0].X*e),t.ClipperOffset.Round(this.m_srcPoly[0].Y-this.m_normals[0].Y*e)),this.m_destPoly.push(l),l=new t.IntPoint2(t.ClipperOffset.Round(this.m_srcPoly[0].X+this.m_normals[0].X*e),t.ClipperOffset.Round(this.m_srcPoly[0].Y+this.m_normals[0].Y*e)),this.m_destPoly.push(l)):(a=1,this.m_sinA=0,s.m_endtype===t.EndType.etOpenSquare?this.DoSquare(0,1):this.DoRound(0,1)),this.m_destPolys.push(this.m_destPoly)}}else{if(s.m_jointype===t.JoinType.jtRound)for(var c=1,p=0,h=1;h<=r;h++){this.m_destPoly.push(new t.IntPoint2(t.ClipperOffset.Round(this.m_srcPoly[0].X+c*e),t.ClipperOffset.Round(this.m_srcPoly[0].Y+p*e)));var u=c;c=c*this.m_cos-this.m_sin*p,p=u*this.m_sin+p*this.m_cos}else{c=-1,p=-1;for(var h=0;h<4;++h)this.m_destPoly.push(new t.IntPoint2(t.ClipperOffset.Round(this.m_srcPoly[0].X+c*e),t.ClipperOffset.Round(this.m_srcPoly[0].Y+p*e))),c<0?c=1:p<0?p=1:c=-1}this.m_destPolys.push(this.m_destPoly)}}}},t.ClipperOffset.prototype.Execute=function(){var e=arguments;if(e[0]instanceof t.PolyTree)if(o=e[1],(s=e[0]).Clear(),this.FixOrientations(),this.DoOffset(o),(r=new t.Clipper(0)).AddPaths(this.m_destPolys,t.PolyType.ptSubject,!0),o>0)r.Execute(t.ClipType.ctUnion,s,t.PolyFillType.pftPositive,t.PolyFillType.pftPositive);else if(A=t.Clipper.GetBounds(this.m_destPolys),(a=new t.Path).push(new t.IntPoint2(A.left-10,A.bottom+10)),a.push(new t.IntPoint2(A.right+10,A.bottom+10)),a.push(new t.IntPoint2(A.right+10,A.top-10)),a.push(new t.IntPoint2(A.left-10,A.top-10)),r.AddPath(a,t.PolyType.ptSubject,!0),r.ReverseSolution=!0,r.Execute(t.ClipType.ctUnion,s,t.PolyFillType.pftNegative,t.PolyFillType.pftNegative),1===s.ChildCount()&&s.Childs()[0].ChildCount()>0){var n=s.Childs()[0];s.Childs()[0]=n.Childs()[0],s.Childs()[0].m_Parent=s;for(var i=1;i<n.ChildCount();i++)s.AddChild(n.Childs()[i])}else s.Clear();else{var r,s=e[0],o=e[1];if(t.Clear(s),this.FixOrientations(),this.DoOffset(o),(r=new t.Clipper(0)).AddPaths(this.m_destPolys,t.PolyType.ptSubject,!0),o>0)r.Execute(t.ClipType.ctUnion,s,t.PolyFillType.pftPositive,t.PolyFillType.pftPositive);else{var a,A=t.Clipper.GetBounds(this.m_destPolys);(a=new t.Path).push(new t.IntPoint2(A.left-10,A.bottom+10)),a.push(new t.IntPoint2(A.right+10,A.bottom+10)),a.push(new t.IntPoint2(A.right+10,A.top-10)),a.push(new t.IntPoint2(A.left-10,A.top-10)),r.AddPath(a,t.PolyType.ptSubject,!0),r.ReverseSolution=!0,r.Execute(t.ClipType.ctUnion,s,t.PolyFillType.pftNegative,t.PolyFillType.pftNegative),s.length>0&&s.splice(0,1)}}},t.ClipperOffset.prototype.OffsetPoint=function(e,n,i){if(this.m_sinA=this.m_normals[n].X*this.m_normals[e].Y-this.m_normals[e].X*this.m_normals[n].Y,Math.abs(this.m_sinA*this.m_delta)<1){if(this.m_normals[n].X*this.m_normals[e].X+this.m_normals[e].Y*this.m_normals[n].Y>0)return this.m_destPoly.push(new t.IntPoint2(t.ClipperOffset.Round(this.m_srcPoly[e].X+this.m_normals[n].X*this.m_delta),t.ClipperOffset.Round(this.m_srcPoly[e].Y+this.m_normals[n].Y*this.m_delta))),n}else this.m_sinA>1?this.m_sinA=1:this.m_sinA<-1&&(this.m_sinA=-1);if(this.m_sinA*this.m_delta<0)this.m_destPoly.push(new t.IntPoint2(t.ClipperOffset.Round(this.m_srcPoly[e].X+this.m_normals[n].X*this.m_delta),t.ClipperOffset.Round(this.m_srcPoly[e].Y+this.m_normals[n].Y*this.m_delta))),this.m_destPoly.push(new t.IntPoint1(this.m_srcPoly[e])),this.m_destPoly.push(new t.IntPoint2(t.ClipperOffset.Round(this.m_srcPoly[e].X+this.m_normals[e].X*this.m_delta),t.ClipperOffset.Round(this.m_srcPoly[e].Y+this.m_normals[e].Y*this.m_delta)));else switch(i){case t.JoinType.jtMiter:var r=this.m_normals[e].X*this.m_normals[n].X+this.m_normals[e].Y*this.m_normals[n].Y+1;r>=this.m_miterLim?this.DoMiter(e,n,r):this.DoSquare(e,n);break;case t.JoinType.jtSquare:this.DoSquare(e,n);break;case t.JoinType.jtRound:this.DoRound(e,n)}return n=e},t.ClipperOffset.prototype.DoSquare=function(e,n){var i=Math.tan(Math.atan2(this.m_sinA,this.m_normals[n].X*this.m_normals[e].X+this.m_normals[n].Y*this.m_normals[e].Y)/4);this.m_destPoly.push(new t.IntPoint2(t.ClipperOffset.Round(this.m_srcPoly[e].X+this.m_delta*(this.m_normals[n].X-this.m_normals[n].Y*i)),t.ClipperOffset.Round(this.m_srcPoly[e].Y+this.m_delta*(this.m_normals[n].Y+this.m_normals[n].X*i)))),this.m_destPoly.push(new t.IntPoint2(t.ClipperOffset.Round(this.m_srcPoly[e].X+this.m_delta*(this.m_normals[e].X+this.m_normals[e].Y*i)),t.ClipperOffset.Round(this.m_srcPoly[e].Y+this.m_delta*(this.m_normals[e].Y-this.m_normals[e].X*i))))},t.ClipperOffset.prototype.DoMiter=function(e,n,i){var r=this.m_delta/i;this.m_destPoly.push(new t.IntPoint2(t.ClipperOffset.Round(this.m_srcPoly[e].X+(this.m_normals[n].X+this.m_normals[e].X)*r),t.ClipperOffset.Round(this.m_srcPoly[e].Y+(this.m_normals[n].Y+this.m_normals[e].Y)*r)))},t.ClipperOffset.prototype.DoRound=function(e,n){for(var i,r=Math.atan2(this.m_sinA,this.m_normals[n].X*this.m_normals[e].X+this.m_normals[n].Y*this.m_normals[e].Y),s=Math.max(t.Cast_Int32(t.ClipperOffset.Round(this.m_StepsPerRad*Math.abs(r))),1),o=this.m_normals[n].X,a=this.m_normals[n].Y,A=0;A<s;++A)this.m_destPoly.push(new t.IntPoint2(t.ClipperOffset.Round(this.m_srcPoly[e].X+o*this.m_delta),t.ClipperOffset.Round(this.m_srcPoly[e].Y+a*this.m_delta))),i=o,o=o*this.m_cos-this.m_sin*a,a=i*this.m_sin+a*this.m_cos;this.m_destPoly.push(new t.IntPoint2(t.ClipperOffset.Round(this.m_srcPoly[e].X+this.m_normals[e].X*this.m_delta),t.ClipperOffset.Round(this.m_srcPoly[e].Y+this.m_normals[e].Y*this.m_delta)))},t.Error=function(e){try{throw new Error(e)}catch(e){alert(e.message)}},t.JS={},t.JS.AreaOfPolygon=function(e,n){return n||(n=1),t.Clipper.Area(e)/(n*n)},t.JS.AreaOfPolygons=function(e,n){n||(n=1);for(var i=0,r=0;r<e.length;r++)i+=t.Clipper.Area(e[r]);return i/(n*n)},t.JS.BoundsOfPath=function(e,n){return t.JS.BoundsOfPaths([e],n)},t.JS.BoundsOfPaths=function(e,n){n||(n=1);var i=t.Clipper.GetBounds(e);return i.left/=n,i.bottom/=n,i.right/=n,i.top/=n,i},t.JS.Clean=function(e,n){if(!(e instanceof Array))return[];var i=e[0]instanceof Array;if(e=t.JS.Clone(e),"number"!=typeof n||null===n)return t.Error("Delta is not a number in Clean()."),e;if(0===e.length||1===e.length&&0===e[0].length||n<0)return e;i||(e=[e]);for(var r,s,o,a,A,l,c,p=e.length,h=[],u=0;u<p;u++)if(0!==(r=(s=e[u]).length))if(r<3)o=s,h.push(o);else{for(o=s,a=n*n,A=s[0],l=1,c=1;c<r;c++)(s[c].X-A.X)*(s[c].X-A.X)+(s[c].Y-A.Y)*(s[c].Y-A.Y)<=a||(o[l]=s[c],A=s[c],l++);A=s[l-1],(s[0].X-A.X)*(s[0].X-A.X)+(s[0].Y-A.Y)*(s[0].Y-A.Y)<=a&&l--,l<r&&o.splice(l,r-l),o.length&&h.push(o)}return!i&&h.length?h=h[0]:i||0!==h.length?i&&0===h.length&&(h=[[]]):h=[],h},t.JS.Clone=function(e){if(!(e instanceof Array))return[];if(0===e.length)return[];if(1===e.length&&0===e[0].length)return[[]];var t=e[0]instanceof Array;t||(e=[e]);var n,i,r,s,o=e.length,a=new Array(o);for(i=0;i<o;i++){for(n=e[i].length,s=new Array(n),r=0;r<n;r++)s[r]={X:e[i][r].X,Y:e[i][r].Y};a[i]=s}return t||(a=a[0]),a},t.JS.Lighten=function(e,n){if(!(e instanceof Array))return[];if("number"!=typeof n||null===n)return t.Error("Tolerance is not a number in Lighten()."),t.JS.Clone(e);if(0===e.length||1===e.length&&0===e[0].length||n<0)return t.JS.Clone(e);var i,r,s,o,a,A,l,c,p,h,u,d,g,f,m,y,b=e[0]instanceof Array;b||(e=[e]);var I=e.length,x=n*n,C=[];for(i=0;i<I;i++)if(0!==(A=(s=e[i]).length)){for(o=0;o<1e6;o++){for(a=[],s[(A=s.length)-1].X!==s[0].X||s[A-1].Y!==s[0].Y?(u=1,s.push({X:s[0].X,Y:s[0].Y}),A=s.length):u=0,h=[],r=0;r<A-2;r++)l=s[r],p=s[r+1],c=s[r+2],m=l.X,y=l.Y,d=c.X-m,g=c.Y-y,0===d&&0===g||((f=((p.X-m)*d+(p.Y-y)*g)/(d*d+g*g))>1?(m=c.X,y=c.Y):f>0&&(m+=d*f,y+=g*f)),(d=p.X-m)*d+(g=p.Y-y)*g<=x&&(h[r+1]=1,r++);for(a.push({X:s[0].X,Y:s[0].Y}),r=1;r<A-1;r++)h[r]||a.push({X:s[r].X,Y:s[r].Y});if(a.push({X:s[A-1].X,Y:s[A-1].Y}),u&&s.pop(),!h.length)break;s=a}a[(A=a.length)-1].X===a[0].X&&a[A-1].Y===a[0].Y&&a.pop(),a.length>2&&C.push(a)}return b||(C=C[0]),void 0===C&&(C=[]),C},t.JS.PerimeterOfPath=function(e,t,n){if(void 0===e)return 0;var i,r,s=Math.sqrt,o=0,a=0,A=0,l=0,c=0,p=e.length;if(p<2)return 0;for(t&&(e[p]=e[0],p++);--p;)a=(i=e[p]).X,A=i.Y,o+=s((a-(l=(r=e[p-1]).X))*(a-l)+(A-(c=r.Y))*(A-c));return t&&e.pop(),o/n},t.JS.PerimeterOfPaths=function(e,n,i){i||(i=1);for(var r=0,s=0;s<e.length;s++)r+=t.JS.PerimeterOfPath(e[s],n,i);return r},t.JS.ScaleDownPath=function(e,t){var n,i;for(t||(t=1),n=e.length;n--;)(i=e[n]).X=i.X/t,i.Y=i.Y/t},t.JS.ScaleDownPaths=function(e,t){var n,i,r;for(t||(t=1),n=e.length;n--;)for(i=e[n].length;i--;)(r=e[n][i]).X=r.X/t,r.Y=r.Y/t},t.JS.ScaleUpPath=function(e,t){var n,i,r=Math.round;for(t||(t=1),n=e.length;n--;)(i=e[n]).X=r(i.X*t),i.Y=r(i.Y*t)},t.JS.ScaleUpPaths=function(e,t){var n,i,r,s=Math.round;for(t||(t=1),n=e.length;n--;)for(i=e[n].length;i--;)(r=e[n][i]).X=s(r.X*t),r.Y=s(r.Y*t)},t.ExPolygons=function(){return[]},t.ExPolygon=function(){this.outer=null,this.holes=null},t.JS.AddOuterPolyNodeToExPolygons=function(e,n){var i=new t.ExPolygon;i.outer=e.Contour();var r,s,o,a,A,l,c=e.Childs(),p=c.length;for(i.holes=new Array(p),o=0;o<p;o++)for(r=c[o],i.holes[o]=r.Contour(),a=0,l=(A=r.Childs()).length;a<l;a++)s=A[a],t.JS.AddOuterPolyNodeToExPolygons(s,n);n.push(i)},t.JS.ExPolygonsToPaths=function(e){var n,i,r,s,o=new t.Paths;for(n=0,r=e.length;n<r;n++)for(o.push(e[n].outer),i=0,s=e[n].holes.length;i<s;i++)o.push(e[n].holes[i]);return o},t.JS.PolyTreeToExPolygons=function(e){var n,i,r,s,o=new t.ExPolygons;for(i=0,s=(r=e.Childs()).length;i<s;i++)n=r[i],t.JS.AddOuterPolyNodeToExPolygons(n,o);return o}}();var It=getDefaultExportFromCjs(bt.exports);function alignByMinDist(e,t,n){const i=e.length,r=t.length;if(i<1||r<1)return t.slice();let s=0,o=1/0;for(let a=0;a<r;a++){const A=e[0],l=t[a%r],c=A.x-l.x,p=A.y-l.y,h=e[i-1],u=t[n?Math.min(a+i-1,r-1):(a+i-1)%r],d=h.x-u.x,g=h.y-u.y,f=c*c+p*p+d*d+g*g;f<o&&(o=f,s=a)}return[...t.slice(s),...t.slice(0,s)]}function shapeclip(){const e=1e4;function toclipformat(t){let n=t.map((t=>({X:Math.round(t.x*e),Y:Math.round(t.y*e)})));return ensureOrientation(n)}function fromclipformat(t){return t.map((t=>({x:t.X/e,y:t.Y/e})))}const ensureOrientation=e=>It.Clipper.Orientation(e)?e:e.slice().reverse();function orientation(e){if(!e.length)return 0;let t=0;const n=e.length;for(let i=0;i<n;i++){const r=e[i],s=e[(i+1)%n];t+=r.X*s.Y-s.X*r.Y}return t>0?1:t<0?-1:0}const _inflate=(e,t,n=!1)=>{const i=new It.ClipperOffset;i.MiterLimit=4,i.AddPath(e,It.JoinType.jtMiter,n||2==e.length?It.EndType.etOpenButt:It.EndType.etClosedPolygon);const r=new It.Paths;return i.Execute(r,t),r};function _inflateopen(t,n){const i=new It.ClipperOffset;i.MiterLimit=4,i.ArcTolerance=.25;const r=n*e,s=toclipformat(t);i.AddPath(s,It.JoinType.jtMiter,It.EndType.etClosedPolygon);const o=new It.Paths;i.Execute(o,r);let a=fromclipformat(o[0]);return getshape().frompt(a)}return{offset(t,n){const i=new It.ClipperOffset;i.MiterLimit=4,i.ArcTolerance=.25;const r=Math.abs(n)*e,s=toclipformat(t.pt);i.AddPath(s,It.JoinType.jtMiter,It.EndType.etOpenButt);const o=new It.Paths;i.Execute(o,r);let a=fromclipformat(o[0]);return getshape().frompt(a)},inflate:function inflate(t,n=2,i=!1,r=0){let s=toclipformat(t.pt),o=_inflate(s,n*e);if(!o||!o.length)return getshape().frompt([]);let a=getshape().frompt(fromclipformat(o[0]));if(i){a.orient!=t.orient&&a.reverse();let A=alignByMinDist(t.pt,a.pt,r);if(a.frompt(A),r>0&&t.pt.length>=3){function estendi1(e,t){let n=e.segment(0).ruotata(-Math.PI/2,200,!0),i=e.segment(-2).ruotata(-Math.PI/2,200),r=t.segment(-2).interseca(i),s=t.segment(0).interseca(n);s&&(t.pt[0]=s),r&&(t.pt[t.pt.length-1]=r)}function estendi2(e,t){let n=e.segment(-1),i=t.segment(0),r=n.interseca(i);r&&(t.pt[0]=r),i=t.segment(-2);let s=n.interseca(i);s&&(t.pt[t.pt.length-1]=s)}1==r?estendi1(t,a):estendi2(t,a)}}return a},inflateopen:_inflateopen,inflateclose(e,t){let n=_inflateopen(e.pt,t);n.orient!=e.orient&&n.reverse();let i=alignByMinDist(e.pt,n.pt,0);return n.frompt(i),n},inflatecornici(e,t=2,n,i){let r,s=e.npt;if(2==s){let n=e.segment(0).offset(t);r=getshape().frompt([n.p1,n.p2])}else if(3==s){let n=e.segment(0).offset(t),i=e.segment(1).offset(t);if(n.isparallela(i))r=getshape().frompt([n.p1,i.p2]);else{let e=n.interseca(i);r=getshape().frompt([n.p1,e,i.p2])}}else{let s=new Linea2(e.pt[0],e.pt[e.npt-1]),o=s.len,a=s.perpendicolare(s.p1,o),A=s.perpendicolare(s.p2,o);a.isparallela(e.segment(0))&&(a=s.perpendicolare(s.puntot(.1),o)),A.isparallela(e.segment(e.npt-2))&&(A=s.perpendicolare(s.puntot(.9),o));let l=Math.floor(e.npt/2),{t:c}=a.proiezionet(e.pt[l]),p=2*(c>0?-1:1),h=a.puntot(p),u=A.puntot(p);r=_inflateopen([...e.pt,u,h],t);let d=r.pt.reduce(((e,t,n)=>(t.x-h.x)**2+(t.y-h.y)**2<(r.pt[e].x-h.x)**2+(r.pt[e].y-h.y)**2?n:e),0);r.pt=r.pt.slice(d+2).concat(r.pt.slice(0,d)),r.orient!=e.orient&&r.reverse(),n&&(e.truncatebefore(n),r.truncatebefore(n)),i&&(r.truncateafter(i),e.truncateafter(i))}return r},intersecasplitter(e,t){const n=new It.Clipper,i=[toclipformat(t.pt)],r=[toclipformat(e.pt)];n.AddPaths(i,It.PolyType.ptSubject,!0),n.AddPaths(r,It.PolyType.ptClip,!0);const s=new It.Paths;let o;if(n.Execute(It.ClipType.ctIntersection,s,It.PolyFillType.pftNonZero,It.PolyFillType.pftNonZero)&&s.length>0){const e=s[0];if(1===orientation(e)){o=getshape().frompt(fromclipformat(e)),o.orient!=t.orient&&o.reverse();for(let e=0;e<t.pt.length;e++){let n=t.pt[e],i=o.pt.findIndex((e=>Math.abs(e.x-n.x)<.01&&Math.abs(e.y-n.y)<.01));if(i>0){i-=e,0!=i&&o.selezionaprimo(i);break}}}}return o},offsetpts(t,n=.01){const i=e*n;let r=_inflate(toclipformat(t),i);if(r&&r.length)return fromclipformat(r[0])},areesplitter(e,t,n=!0){if(!Array.isArray(e)||e.length<3)return;if(!t||0==t.length)return[e];const i=new It.Paths,r=new It.Paths;let s=n?_inflate(toclipformat(e),-100):[toclipformat(e)],o=n?t.flatMap((e=>_inflate(toclipformat(e),100))):t.map((e=>toclipformat(e)));for(let e of s)i.push(e);for(let e of o)r.push(e);const a=new It.Clipper;a.AddPaths(i,It.PolyType.ptSubject,!0),a.AddPaths(r,It.PolyType.ptClip,!0);const A=new It.Paths;if(!a.Execute(It.ClipType.ctDifference,A,It.PolyFillType.pftNonZero,It.PolyFillType.pftNonZero))return;let l=[];for(let e of A)if(n){const t=_inflate(e,100);for(const e of t)1===orientation(e)&&l.push(fromclipformat(e))}else if(e.length>4&&1==orientation(e)){const t=_inflate(e,-100);if(t.length>0)for(let e of t){const t=_inflate(e,100);for(const e of t)1===orientation(e)&&l.push(fromclipformat(e))}}else 1==orientation(e)&&l.push(fromclipformat(e));return l},unisci(e,t,n){const i=new It.Paths,r=new It.Paths;for(let t of e){let e=[toclipformat(t.pt)];for(let t of e)i.push(t)}if(t&&t.length)for(let e of t){let t=toclipformat(e.pt);r.push(t)}if(n&&n.length)for(let e of n){let t=toclipformat(e.pt),n=_inflate(t,1,!0);for(let e of n)r.push(e)}const s=new It.Clipper;s.AddPaths(i,It.PolyType.ptSubject,!0),s.AddPaths(r,It.PolyType.ptClip,!0);const o=new It.Paths;if(s.Execute(It.ClipType.ctDifference,o,It.PolyFillType.pftNonZero,It.PolyFillType.pftNonZero)){let e=[],t=[];for(let n of o)if(1==orientation(n)){let t=[n];for(let n of t)e.push({shape:getshape().frompt(fromclipformat(n)),holes:[]})}else t.push(getshape().frompt(fromclipformat(n)));for(let n of t)for(let t of e)if(t.shape.pointinshape(n.pt[0])){t.holes.push(n);break}return e}return[]}}}class Vscene{constructor(e,t,n={}){this.x=e,this.y=t,this.info=n,this.clear()}addrow(e){e||(e={}),e.id=function newid(e){let t=0;for(let n of e)+n.id>t&&(t=+n.id);return t+1}(this.rows);let t=new Vobject(e);return this.rows.push(t),t}clear(){this.curlayer=0,this.rows=[],this.clines=[]}fromjson(e){let t,n;e||(e={info:{}}),this.clear(),this.x=e.x||4e3,this.y=e.y||3e3,this.info=e.info||{},this.curlayer=e.curlayer,e.clines&&(t=e.clines.map((e=>new Linea2(e.p1,e.p2))));let i=this.x,r=this.y;n=[new Linea2(0,0,100,0),new Linea2(i,0,i,100),new Linea2(i,r,i-100,r),new Linea2(0,r,0,r-100)],this.clines=[...n,...t],e.rows&&(this.rows=e.rows.map((e=>new Vobject(e))))}tojson(){let{x:e,y:t,info:n,curlayer:i,xrows:r,xclines:s}=this,o=r.map((e=>e.tojson())),a=s.map((e=>({p1:e.p1,p2:e.p2})));return a=a.slice(4),{x:e,y:t,curlayer:i,rows:o,clines:a}}}class Vobject{constructor(e){e||(e={}),this.fromjson(e)}get lines(){if(this._lines&&this._lines.length)return this._lines;{let{x:e,y:t}=this;return e||(e=100),t||(t=100),[new Linea2(0,0,0,t),new Linea2(e,0,e,t)]}}fromjson(e){let t;this.id=e.id??1,this.layer=e.layer||0,this.hidden=!!e.hidden,this.x=e.x||100,this.y=e.y||100,this.pc=e.pc||{x:0,y:0},e.shape?this.shape=getshape().frompt(e.shape):this.shape=void 0,e.lines&&e.lines.length&&(t=e.lines.map((e=>new Linea2(e.p1,e.p2)))),this._lines=t,this.draw=new Vis2d(`d:${e.id}`),e.draw&&this.draw.fromjson(e.draw),this.info=e.info||{},this.pos=e.pos||{x:0,y:0,rot:0}}tojson(){let{id:e,layer:t,x:n,y:i,pc:r,shape:s,hidden:o,_lines:a,info:A,pos:l}=this;return a=a&&a.length?a.map((e=>({p1:e.p1,p2:e.p2}))):void 0,s=s?s.pt:void 0,{id:e,layer:t,x:n,y:i,pc:r,shape:s,lines:a,hidden:o,info:A,pos:l,draw:this.draw.tojson()}}}class Vis2d{constructor(e,t,n,i){this.name=e,this.visible=t,this.des=n,this.inverse=i,this.clear()}clear(){return this.vec=[],this.gr={},this}tojson(){let e={};for(let t in this.gr)e[t]=this.gr[t].tojson();let{name:t,visible:n,des:i,vec:r,inverse:s}=this;return{name:t,visible:n,des:i,inverse:s,vec:[...r],groups:e}}fromjson(e){if(!(e&&e.name&&e.vec))throw new Error("wrong data JSON");this.clear(),this.name=e.name,this.visible=e.visilbe,this.des=e.des,this.inverse=e.inverse,this.vec=[...e.vec];for(let t in e.groups)this.gr[t]=new Vis2d(t).fromjson(e.groups[t])}creategr(e="grp"){return this.gr[e]||(this.gr[e]=new Vis2d(e)),this.gr[e]}push(e=0,t=0,n={}){"number"==typeof n&&(n={rot:n}),n||(n={}),this.vec.push({type:"push",x:e,y:t,op:n})}pop(){this.vec.push({type:"pop"})}randomcolor(e="100%"){return`hsl(${Math.floor(360*Math.random())}, 50%, 40%,${e})`}addgr(e){let t=e;e?.name&&(t=e.name),this.gr[t]?this.vec.push({type:"group",name:t}):this.vec.push({type:"err",err:`addgroup: ${t} => missing`})}addtext(e,t,n,i,r="black",s="white"){this.vec.push({type:"text",x:e,y:t,text:n,color:r,fill:s,scalafont:i})}addquota(e,t,n,i,r=0,s="",o=1,a=.25){this.vec.push({type:"quota",x1:e,y1:t,x2:n,y2:i,d:r,text:s,spessore:a,color:"black",scalafont:o})}addqpunto(e,t,n,i,r=0,s="",o=1,a=.25){this.vec.push({type:"qpunto",x1:e,y1:t,x2:n,y2:i,d:r,text:s,spessore:a,color:"black",scalafont:o})}addpoint(e,t=-1,n="red",i=8){return e&&this.vec.push({type:"point",p:e,id:t,color:n,spessore:1*i}),this}addline(e,t=-1,n=void 0,i=1){return e&&this.vec.push({type:"line",l:e,id:t,color:n,spessore:1*i}),this}addspace(e){return e&&this.vec.push({type:"space",l:e}),this}addrect(e,t=void 0,n=1,i=void 0){return e&&this.vec.push({type:"rect",l:e,color:t,spessore:1*n,fill:i}),this}addimg(e,t){return e&&this.vec.push({type:"img",l:e,img:t}),this}addrecta(e,t=void 0,n=void 0){return e&&this.vec.push({type:"recta",l:e,color:t,spessore:0,fill:n}),this}addshape(e,t=void 0,n=1,i=void 0){return e&&this.vec.push({type:"shape",s:e,color:t||this.randomcolor(),spessore:1*n,fill:i}),this}addshapelin(e,t=void 0,n=1){return e&&this.vec.push({type:"shapelin",s:e,color:t||this.randomcolor(),spessore:1*n}),this}addarea(e,t=void 0){return e&&this.vec.push({type:"area",s:e,color:t||this.randomcolor()}),this}addoffset(e,t){return this.vec.push({type:"offset",x:e||0,y:t||0}),this}}function checkoggetto(e,t,n,i){if("h"==t&&(t="o"),e||(e=[]),"number"==typeof n&&!["a","as"].includes(t))return{cod:"__",macro:"",sps:n};let r=e.find((e=>e.tipo.includes(t)&&e.cod==n&&(e.isshape||i||"a"!=t)));return r||(r=e.find((e=>e.tipo.includes(t)&&(e.isshape||i||"a"!=t)))),r||(r={cod:"__",macro:"",sps:0}),"a"!=t&&"as"!=t||"__"==r.cod||r.color||(r.color=`hsl(${function stringToHue(e){let t=0;for(let n=0;n<e.length;n++)t=31*t+e.charCodeAt(n)>>>0;return Math.floor(.6180339887*t%1*360)}(r.cod)}, 95%, 97%`),r}function getbordi(e,t){let n,i=!1;if(Array.isArray(t)){t.length=4;let r=t[0]||"";n=t.map((t=>checkoggetto(e,"b",t||r))),i=n.every((e=>e.sps===n[0].sps))}else{let r=checkoggetto(e,"b",t);n=[r,r,r,r],i=!0}return{bordi:n,uguali:i,senza:!(n[0].sps||n[1].sps||n[2].sps||n[3].sps),bl:n[0].sps,bt:n[1].sps,br:n[2].sps,bb:n[3].sps}}function elaborapercorso(e,t,n,i,r=0){let s,o,a,A,l,c,p,h,u,d,g,f,m,y,b,I,x=[],C=[];function eseguipezzo(e,t,n,i){let s=e.infoquad(t);if(s&&s.distanza){let o=getshape().frompt(i||[e.p1,e.p2,t.p2,t.p1]),a=o.clone();(s.sx||s.sy)&&a.move(-s.sx||0,-s.sy||0),s.angle&&a.rotate(-s.angle||0);let A={id:++r,type:`b${n}`,info:s};i&&(A.shape=a.pt),C.push({type:`b${n}`,pt:o.pt}),x.push(A)}}r=r||0;let B=e.pt.length,E=B-1;i||(i=[]);let{bordi:w,uguali:v,senza:P}=getbordi(i,t);if(v)if(P||!w[0].sps)s=e.clone();else{let t=w[0].sps;s=shapeclip().inflate(e,-t,!0)}else{let t,n=[],i=[];for(let i=0;i<B;i++){t=0==i?w[0].sps:i==E-1?w[2].sps:i==E?w[3].sps:w[1].sps,"number"!=typeof t&&(t=0);let r=e.segment(i).offset(-t);n.push(r)}for(let e=0;e<B;e++){let t=n[e].interseca(n[(e-1+B)%B]);i.push(t)}s=getshape().frompt(i)}if(!P){a=s.segment(E).interseca(e.segment(0)),A=s.segment(1).interseca(e.segment(0)),l=e.segment(E-1).interseca(s.segment(E-2)),c=e.segment(E-1).interseca(s.segment(E)),p=e.segment(E).interseca(s.segment(0)),h=e.segment(1).interseca(s.segment(0)),u=e.segment(E-2).interseca(s.segment(E-1)),d=e.segment(E).interseca(s.segment(E-1)),b=1,I=E-2,m=s.segment(0),y=s.segment(E-1);for(let t=1;t<E-1;t++){let n=e.segment(t),i=n.interseca(m);i&&n.onsegment(i)&&(b=t,h=i),i=n.interseca(y),i&&n.onsegment(i)&&(I=t,u=i)}b-=1,I=E-2-I;let i=e.pt[0],r=s.pt[0],x=s.pt[E],C=e.pt[E];switch(n[0]){case"v":eseguipezzo(new Linea2(d,p),s.segment(E),3),r=p,x=d;break;case"o":eseguipezzo(e.segment(E),new Linea2(c,a),3),i=a,C=c;break;default:eseguipezzo(e.segment(E),s.segment(E),3)}switch(g=e.pt.slice(1,E),f=s.pt.slice(1,E),n[1]){case"v":eseguipezzo(new Linea2(i,e.pt[1]),new Linea2(r,h),0),eseguipezzo(new Linea2(e.pt[E-1],C),new Linea2(u,x),2),b&&(g=g.slice(b)),I&&(g=g.slice(0,-I)),g[0]=h,g[g.length-1]=u;break;case"o":eseguipezzo(new Linea2(i,A),new Linea2(r,s.pt[1]),0),eseguipezzo(new Linea2(l,C),new Linea2(s.pt[E-1],x),2),f[0]=A,f[f.length-1]=l;break;default:eseguipezzo(new Linea2(i,e.pt[1]),new Linea2(r,s.pt[1]),0),eseguipezzo(new Linea2(e.pt[E-1],C),new Linea2(s.pt[E-1],x),2)}if(o=getshape().frompt(f),g.length<8&&g.length==f.length)for(let e=0;e<g.length-1;e++)eseguipezzo(new Linea2(g[e],g[e+1]),new Linea2(f[e],f[e+1]),1);else{let e=getshape().frompt([...g,...f.reverse()]),n=new Linea2(g[0],g[g.length-1]),i=n.offset(-t[1]);eseguipezzo(n,i,1,e.pt)}}return{countid:r,shape2:s,shapetop:o,bordi:w,dati:x,draws:C}}function creaprofiloesterno(e,t){let n,{x:i,y:r,tipo:s,bordo:o,taglio:a,h1:A,h2:l,l1:c,l2:p,forma:h}=e;i=i<50?50:i,r=r<50?50:r,c=c||0,p=p||0,A=A||0,l=l||0;let u=[0,0];switch(s){case"i":case"d":u.push(c>0&&c<i?c:0,A>0&&A<r?r-A:r),u.push(p>0&&p<i-c?i-p:i,l>0&&l<r&&l!=A?r-l:r);break;case"a":if(h){let e=getshape().fromstr(h);e.alignline({x:c,y:r-A},{x:i-p,y:r-l}),u.push(...e.vec)}else if((A||l)&&A>=0&&A<Math.min(r,i/2)&&l>=0&&l<Math.min(r,i/2)){let e=getshape().fromstr(`a30;${c||0};${r-A};${i/2};${r};${i-p};${r-l}`);u.push(...e.vec)}else u.push(0,r,i,r);break;case"s":c>0&&A>0?u.push(0,r-A,c,r):u.push(0,r),p&&p<i-c&&l>0&&l<r?u.push(i-p,r,i,r-l):u.push(i,r);break;default:u.push(0,r,i,r)}u.push(i,0),e.countid=0,n=getshape().fromvec(u);let{countid:d,shape2:g,shapetop:f,bordi:m,dati:y,draws:b}=elaborapercorso(n,o,a,t,e.countid);return e.countid=d,{shape:n,internalshape:g,shape2:g,shapetop:f,bordi:m,dati:y,draws:b}}const xt={x:"normale",s:"smussato",i:"inclinato",a:"arco/sagomato",d:"diagonali"},Ct={dd:"diagonale",vv:"verticale",oo:"orizzontale",vo:"verticale+orizzontale",vd:"verticale+diagonale",ov:"orizzontale+verticale",od:"orizzontale+diagonale"},Bt={d:"dist. positiva","d-":"dist. negativa",p:"perc. positiva","p-":"perc negativa"},Et={l:"sinistra",c:"centro",r:"destra"};function findareacod(e,t,n){let i=1/0,r="";for(let s of e){let e=(s.x-t)**2+(s.y-n)**2;e<i&&(i=e,r=s.k)}return r}function generatesegments(e,t,n=!1,i=!1){let r=[];if(e?.length>=2){if(i){let t=[];for(let n of e)t.push({a:n.a,b:n.a}),n.a!=n.b&&t.push({a:n.b,b:n.b});e=t}if(e=e.sort(((e,t)=>e.a-t.a)),t?.length){let i=0;for(let s=1;s<e.length;s++){const o=1e-6;if(t.find((t=>t>e[s-1].b+o&&t<e[s].a-o))){if(s-1>i){let t;t=n?{a:e[i].b,b:e[s-1].a}:{a:e[i].a,b:e[s-1].b},r.push(t)}i=s}}i<e.length-1&&(n?r.push({a:e[i].b,b:e[e.length-1].a}):r.push({a:e[i].a,b:e[e.length-1].b}))}else r.push({a:e[0].b,b:e[e.length-1].a})}return r}function makedivisions(e,t,n){delete e.arre;let i=[],r=[],s=[],o=[],{x:a,y:A,oriz:l,vert:c,tipo:p,minvano:h,minvanox:u,minvanoy:d}=e,{bb:g,bt:f,bl:m,br:y}=getbordi(n,e.bordo);u=u||h||50,d=d||h||50;let{dati:b,punti:I}=ordinabase(n,"o",l,A,d,g,f,p),{dati:x,punti:C}=ordinabase(n,"v",c,a,u,m,y),B=t.clone();function adddatilin(e,t,a,A,l,c){if("l"==e)r.push([a.p1,a.p2]),o.push([a.p1.x,a.p1.y,a.p2.x,a.p2.y]);else{let p=[a.p1,a.p2,A.p2,A.p1];r.push(p);let h=getshape().frompt(p);if(B?.pt&&(h.orient!=B.orient&&h.reverse(),h=shapeclip().intersecasplitter(B,h)),h){h.pt.length>=4&&(a.p1=h.pt[0],a.p2=h.pt[1],A.p1=h.pt[h.pt.length-1],A.p2=h.pt[h.pt.length-2]),o.push([a.p1.x+("v"==e?l:0),a.p1.y+("v"!=e?l:0),a.p2.x+("v"==e?l:0),a.p2.y+("v"!=e?l:0)]);let r=a.infoquad(A);if(r&&r.distanza){let o=h.clone(),a=checkoggetto(n,e,t);(r.sx||r.sy)&&o.move(-r.sx||0,-r.sy||0),r.angle&&o.rotate(-r.angle||0);let A={id:c,type:e,cod:t,c2:a,shape:o.pt,info:r};s.push(A),A?.shape&&i.push({type:e,sx:A.info.sx,sy:A.info.sy,rot:A.info.angle,pt:A.shape})}}}}function isinseg(e,t){return!!e.find((e=>e.a<=t&&e.b>=t))}x.forEach(((e,t)=>{e.segs=generatesegments(I,e.cuts,!0),e.segs.forEach(((t,n)=>{let i=new Linea2({x:e.x,y:t.a},{x:e.x,y:t.b}),r=new Linea2({x:e.x+e.sp,y:t.a},{x:e.x+e.sp,y:t.b});adddatilin(e.sp?"v":"l",e.cod,i,r,e.sp/2,e.id)}))}));for(let e of b){let t=[...e.cuts],n=[...C];for(let i of x)n.push({a:i.x,b:i.x+i.sp}),isinseg(i.segs,e.x+e.sp/2)&&t.push(i.x+i.sp/2);e.segs=generatesegments(n,t,!0,!0),e.segs=e.segs.filter((e=>Math.abs(e.a-e.b)>40));for(let t of e.segs){let n=new Linea2({x:t.b,y:e.x+e.sp},{x:t.a,y:e.x+e.sp}),i=new Linea2({x:t.b,y:e.x},{x:t.a,y:e.x});adddatilin(e.sp?"o":"l",e.cod,i,n,e.sp,e.id)}}let E=shapeclip().areesplitter(t.pt,r),w=function getareacodes(e){let t,n,i,r,s=[];for(let o=0;o<=e.vert.length;o++){if(0==o)t="v0",n=0;else{let i=e.vert[o-1];t=`${i.dir}${i.id}`,n=i._v}for(let o=0;o<=e.oriz.length;o++){if(0==o)i="o0",r=0;else{let t=e.oriz[o-1];i=`${t.dir}${t.id}`,r=t._v}s.push({k:t+i,x:n,y:r})}}return s}(e);for(let t of E){let r=getshape().frompt(t),{p1:o,width:a,height:A,isrect:l}=r.dims(),c=findareacod(w,o.x,o.y),p=e.aree[c]||e.area||"",h=checkoggetto(n,"a",p,l),u=r.pt.findIndex((e=>Math.abs(e.x-o.x)<.001&&Math.abs(e.y-o.y)<.001));u>0&&r.selezionaprimo(u),r.pt.length&&(r.move(-o.x,-o.y),1==r.orient&&r.reverse()),s.push({id:c,cod:p,c2:h,type:"a",shape:l?null:r.pt,info:{isrect:l?1:0,sx:o.x,sy:o.y,rot:0,width:a,height:A}}),i.push({type:l?"a":"as",sx:o.x,sy:o.y,dx:a,dy:A,id:c,cod:p,rot:0,pt:r.pt,color:h.color})}return{ff:e,h1:b,ph:I,v1:x,pv:C,draws:i,lines:o,dati:s}}function ordinabase(e,t,n,i,r,s,o,a){let A=[];if(n){for(let r of n){let n=checkoggetto(e,t,r.cod).sps||0,a=0;switch(r.tipo){case"d-":a=i-r.v;break;case"p":a=i*r.v/100;break;case"p-":a=i*(100-r.v)/100;break;default:a=r.v}if(n&&"c"==r.align?a-=n/2:n&&"r"==r.align&&(a-=n),a=Math.round(10*a)/10,r._x0=a,r._x1=a+n,r._v=a+n/2,r._valid=a>0&&a<i,a>s&&a<i-o){let e=[];r.cuts&&r.cuts.length&&r.cuts.forEach((t=>{e.push(t<0?i+t:t)})),A.push({id:r.id,x:a,sp:n,cuts:e,cod:r.cod})}}A.sort(((e,t)=>e.x-t.x))}let l=[],c=s;"a"==a&&(i*=1.3);for(let e=0;e<A.length;e++){let t=A[e];t.x>=c+r&&t.x+t.sp<=i-o-r&&(t.min=c+r,t.max=i-o-r,l.length>0&&(l[l.length-1].max=t.x-r),l.push(t),c=t.x+t.sp)}let p=[];p.push({a:s,b:s});for(let e of l)p.push({a:e.x,b:e.x+e.sp});return p.push({a:i-o,b:i-o}),{dati:l,punti:p}}function check(e){let{x:t,y:n,area:i,bordo:r,gvert:s,goriz:o,priority:a,minvano:A,taglio:l,tipo:c,h1:p,h2:h,l1:u,l2:d,d1:g,x1:f,y1:m,d2:y,x2:b,y2:I,vert:x,oriz:C,aree:B,forma:E,countid:w}=e;return t=t||1e3,t<20&&(t=20),n=n||1e3,n<20&&(n=20),p=p||m||0,h=h||I||0,u=u||g||f||0,d=d||y||b||0,p<0&&p>n-10&&(p=0),h<0&&h>n-10&&(h=0),(d<0||d>t-u)&&(d=0),(u<0||u>t-d)&&(u=0),A=A||10,E&&(c="a"),i=i||"__",r=r||"__",a=a||"v",l=Ct[l]?l:"dd",c=xt[c]?c:"x",x=x||[],C=C||[],B=B||{},o=o||void 0,s=s||void 0,w=w||1,{x:t,y:n,area:i,bordo:r,gvert:s,goriz:o,priority:a,minvano:A,taglio:l,tipo:c,h1:p,h2:h,l1:u,l2:d,vert:x,oriz:C,aree:B,countid:w}}function addtaglio(e,t,n,i,r,s="c",o=[],a){return a||(console.log("manca id a addtaglio"),a=0),{dir:t,id:a,tipo:Bt[n]?n:"d",align:Et[s]?s:"c",v:i,cod:r,cuts:o||[]}}function addoriz(e,t,n,i,r,s){let o=Array.isArray(e.bordo)?e.bordo[0]:e.bordo;i||(i=e.goriz||o||"__"),Array.isArray(r)&&(s=r,r="c"),e.oriz||(e.oriz=[]);let a=addtaglio(0,"o",t,n,i,r,s,(e.oriz.length?Math.max(...e.oriz.map((e=>e.id))):0)+1);return e.oriz.push(a),e}var wt=Object.freeze({__proto__:null,addhoriz:function addhoriz(e,t,n,i,r,s){return addoriz(e,t,n,i,r,s)},addoriz:addoriz,addvert:function addvert(e,t,n,i,r,s){let o=Array.isArray(e.bordo)?e.bordo[0]:e.bordo;i||(i=e.gvert||o||"__"),Array.isArray(r)&&(s=r,r="c"),e.vert||(e.vert=[]);let a=addtaglio(0,"v",t,n,i,r,s,(e.vert.length?Math.max(...e.vert.map((e=>e.id))):0)+1);return e.vert.push(a),e},calcoladivisioni:function calcoladivisioni(e,t,n,i){return makedivisions(e,n,i)},check:check,checkoggetto:checkoggetto,creaprofiloesterno:creaprofiloesterno,create:function create(e,t,n,i){i||(i={});let{minvano:r,priority:s,taglio:o,tipo:a,h1:A,h2:l,d1:c,d2:p,l1:h,l2:u,x1:d,x2:g,y1:f,y2:m,gvert:y,goriz:b,forma:I,area:x}=i,C=check({x:e,y:t,area:x,bordo:n,gvert:y,goriz:b,priority:s,minvano:r,taglio:o,tipo:a,h1:A,h2:l,l1:h,l2:u,d1:c,x1:d,y1:f,d2:p,x2:g,y2:m});return C.forma=I,C},elaborapercorso:elaborapercorso,getbordi:getbordi,makedivisions:makedivisions,makeshape:function makeshape(e,t){return creaprofiloesterno(e,t)},priorita:{v:"verticale",h:"orizzontale"},tagli:Ct,tipi:xt,tipilocks:[{cod:"diml",des:"Larghezza"},{cod:"dima",des:"Altezza"},{cod:"etipo",des:"Modifica Tipo"},{cod:"etaglio",des:"Modifica Taglio"},{cod:"ebordi",des:"Modifica Bordi"},{cod:"esag",des:"Shape"},{cod:"vcrea",des:"Crea Div. Verticale"},{cod:"ocrea",des:"Crea Div. Orizzontale"},{cod:"vmov",des:"Sposta Div. Verticale"},{cod:"omov",des:"Sposta Div. Orizzontale"},{cod:"vedit",des:"Modifica Div. Verticale"},{cod:"oedit",des:"Modifica Div. Orizzontale"},{cod:"emods",des:"Modificatori Orizzontali/Verticali"},{cod:"ecuts",des:"Modifica/Aggiungi Cuts"},{cod:"earee",des:"Modifica Aree"}],tipoalign:Et,tipocut:Bt});async function exportSceneImage(e,t,n){n||(n={});let i,{name:r="image",png:s,width:o,height:a,zoom:A,zoomatutto:l,scene:c,imposta:p,frustumSize:h=10}=n;p&&(i=p.fakeshadow,p.fakeshadow=!1);const u=e.domElement.width,d=e.domElement.height,g=e.getPixelRatio(),f=t.isOrthographicCamera,m=f?{left:t.left,right:t.right,top:t.top,bottom:t.bottom,zoom:t.zoom}:{aspect:t.aspect};if(o&&a){if(e.setSize(o,a,!1),f){const e=o/a;t.left=-h*e/2,t.right=h*e/2,t.top=h/2,t.bottom=-h/2,t.updateProjectionMatrix()}else t.aspect=o/a,t.updateProjectionMatrix();if(A&&l){l(c.getObjectByName("boxes"),t,void 0,o,a)}}await new Promise((e=>requestAnimationFrame((()=>{requestAnimationFrame(e)}))));const y=await new Promise((t=>{e.domElement.toBlob(t,s?"image/png":"image/webp")}));return o&&a&&(e.setSize(u,d,!1),f?(t.left=m.left,t.right=m.right,t.top=m.top,t.bottom=m.bottom,t.zoom=m.zoom,t.updateProjectionMatrix()):(t.aspect=m.aspect,t.updateProjectionMatrix()),e.setPixelRatio(g)),p&&(p.fakeshadow=i),new File([y],`${r}.${s?"png":"webp"}`,{type:s?"image/png":"image/webp"})}function handleMovimenti(e,t={}){let{container:n,width:i,height:r,camera:s,scene:o,raycaster:a}=t;if(!n)return;const A=n.getBoundingClientRect(),l={x:(e.clientX-A.left)/i*2-1,y:-(e.clientY-A.top)/r*2+1};a.setFromCamera(l,s),a.layers.enable(0),a.layers.enable(1);const c=[];o.traverse((e=>{"Mesh"===e.type&&e.visible&&e.geometry&&e.material&&!e.material.transparent&&c.push(e)}));let p=a.intersectObjects(c,!1);if(p?.length){let e=p[0].object;for(;e&&(!e.userData?.mov||e.userData.mov.hidesel);){if(!e.parent){e=null;break}e=e.parent}if(e){let{mov:t}=e.userData;t.inmov?(t.inmov=!1,e.position.set(0,0,0),e.scale.set(1,1,1),e.rotation.set(0,0,0)):(t.dtstart=performance.now(),t.inmov=!0),e.traverse((n=>{if(n!==e&&n.userData&&n.userData.mov&&n.userData.mov.hidesel){let e=n.userData.mov;t.inmov?e._f.reset(n):(e.dtstart=t.dtstart,e.inmov=!0)}}))}}}function resethover(e,t=void 0){for(let n of e)n!==t&&n.userData?._mat&&(n.material=n.userData._mat,delete n.userData._mat)}function checkhoverables(e,t=!1,n={}){let{container:i,width:r,height:s,camera:o,scene:a,raycaster:A,emit:l,hoverables:c}=n;if(!i)return;if(!c||!c.length)return;const p=i.getBoundingClientRect(),h={x:(e.clientX-p.left)/r*2-1,y:-(e.clientY-p.top)/s*2+1};A.setFromCamera(h,o);const u=A.intersectObjects(c,!0);if(u&&u.length){let e=u[0].object;return resethover(c,e),e.userData.matover&&e.userData.matover!=e.material&&(e.userData._mat=e.material,e.material=e.userData.matover),e.userData.tooltip}resethover(c)}function handlePick(e,t={}){let{container:n,width:i,height:r,camera:s,scene:o,raycaster:a,emit:A,hoverables:l}=t;if(!n)return;const c=n.getBoundingClientRect(),p={x:(e.clientX-c.left)/i*2-1,y:-(e.clientY-c.top)/r*2+1},h=[],u=[];if(a.setFromCamera(p,s),l&&l.length){resethover(l);const t=a.intersectObjects(l,!0);if(t&&t.length){let n=t[0].object;return void A("variant",{x:e.clientX,y:e.clientY,node:n})}}if(s.layers.set(0),o.traverse((e=>{e.userData?.marker&&e.visible?u.push(e):"Mesh"===e.type&&e.material&&e.geometry&&e.visible&&(e.userData._lay=e.layers.mask,e.layers.set(0),h.push(e))})),u.length){const t=a.intersectObjects(u,!0);if(t&&t.length){let n=t[0].object;for(let t=0;t<10;t++){if(n.userData?.marker)return void A("marker",{node:n,x:e.clientX,y:e.clientY});if(n=n.parent,!n)break}}}const d=a.intersectObjects(h,!0);for(let e of h)e.layers.mask=e.userData._lay,delete e.userData._lay;if(d.length>0){let e=d[0].object;for(;e&&!e.userData.INFO;)e=e.parent;e?A("selected",{id:e.name}):A("deselect")}else A("deselect")}const vt={idle:{id:"idle"},movimenti:{id:"movimenti",onMouseDown(e,t){e.stopPropagation(),e.preventDefault(),handleMovimenti(e,t)}},select:{id:"select",onMouseDown(e,t){handlePick(e,t)}},move:{id:"move",onMouseDown(e,t){e.stopPropagation(),e.preventDefault()},onMouseMove(e,t){}}};function picker(e){function creaAsse(t,n=1){let i;switch(t){case"x":i=16711680;break;case"y":i=65280;break;case"z":i=255;break;default:throw new Error("asse non valido")}const r=new e.Group;r.name=`picker_axis_${t}`,r.userData.type="move",r.userData.axis=t;const s=new e.CylinderGeometry(.025*n,.025*n,.7*n,8),o=new e.MeshBasicMaterial({color:i,depthTest:!1,depthWrite:!1}),a=new e.Mesh(s,o);a.position.y=.35*n,a.userData.parentType="move",r.add(a);const A=new e.ConeGeometry(.06*n,.18*n,12),l=new e.MeshBasicMaterial({color:i,depthTest:!1,depthWrite:!1}),c=new e.Mesh(A,l);return c.position.y=.7*n+.09*n,c.userData.parentType="move",r.add(c),"x"===t&&(r.rotation.z=-Math.PI/2),"z"===t&&(r.rotation.x=Math.PI/2),r.visible=!1,r}function creaCorner(){const t=new e.BoxGeometry(.1,.1,.1),n=new e.MeshBasicMaterial({color:"black",depthTest:!1,depthWrite:!1}),i=new e.Mesh(t,n);return i.name="picker_corner",i.userData.type="corner",i.visible=!1,i}function creaRotateHandler(t="y",n=1){const i={x:16711680,y:65280,z:255}[t]||16776960,r=new e.TorusGeometry(n,.02*n,12,64,2*Math.PI),s=new e.MeshBasicMaterial({color:i,transparent:!0,opacity:.7,depthTest:!1,depthWrite:!1}),o=new e.Mesh(r,s);return o.name=`picker_rotate_${t}`,o.userData.type="rotate",o.userData.axis=t,"x"===t&&(o.rotation.z=Math.PI/2),"z"===t&&(o.rotation.x=Math.PI/2),o.visible=!1,o}function creaDragger(t,n=.22,i=.11){const r={x:16711935,y:65535,z:16776960}[t]||16777215,s=new e.CylinderGeometry(0,i,n,3),o=new e.MeshBasicMaterial({color:r,transparent:!0,opacity:.85,depthTest:!1,depthWrite:!1}),a=new e.Mesh(s,o);return a.name=`picker_dragger_${t}`,a.userData.type="resize",a.userData.axis=t,"x"===t?a.rotation.z=-Math.PI/2:"z"===t&&(a.rotation.x=Math.PI/2),a.visible=!1,a}return{Picker:class Picker{constructor(t){this.grp=new e.Group,this.grp.name="_picker",t.add(this.grp),this.grpAssi=new e.Group,this.grpAssi.name="_picker_assi",this.asseX=creaAsse("x"),this.asseY=creaAsse("y"),this.asseZ=creaAsse("z"),this.grpAssi.add(this.asseX,this.asseY,this.asseZ),this.grp.add(this.grpAssi),this.grpRotate=new e.Group,this.grpRotate.name="_picker_rotate",this.rotateHandler=creaRotateHandler("z"),this.grpRotate.add(this.rotateHandler),this.grp.add(this.grpRotate),this.corners=[creaCorner(),creaCorner(),creaCorner(),creaCorner(),creaCorner(),creaCorner(),creaCorner(),creaCorner()],this.corners.forEach((e=>this.grp.add(e))),this.draggerZ=creaDragger("z"),this.draggerY=creaDragger("y"),this.draggerX=creaDragger("x"),this.grp.add(this.draggerZ,this.draggerY,this.draggerX),function forceAlwaysOnTop(e){e.traverse((e=>{e.isMesh&&(e.renderOrder=999,e.material&&(e.material.depthTest=!1,e.material.depthWrite=!1,e.material.transparent=!0))}))}(this.grp),this.clear()}clear(){this.grp.position.set(0,0,0),this.grp.rotation.set(0,0,0),this.grp.scale.set(1,1,1),this.grpAssi.position.set(0,0,0),this.grpAssi.rotation.set(0,0,0),this.grpRotate.position.set(0,0,0),this.grpRotate.rotation.set(0,0,0),this.asseX.visible=!1,this.asseY.visible=!1,this.asseZ.visible=!1,this.rotateHandler.visible=!1,this.corners.forEach((e=>{e.visible=!1,e.position.set(0,0,0)})),this.draggerZ.visible=!1,this.draggerY.visible=!1,this.draggerX.visible=!1}attiva(t){if(this.clear(),!t)return;t.updateMatrixWorld(!0);const n=(new e.Box3).setFromObject(t),i=n.min,r=n.max;this.grp.position.copy(i);const s=new e.Quaternion;t.getWorldQuaternion(s),this.grp.setRotationFromQuaternion(s);const o=t.userData&&t.userData.pick?String(t.userData.pick):"",a=o.trim()?function parsePickerShort(e){const t={};return e.split(";").forEach((e=>{let n=e.trim();if(!n)return;let[i,r]=n.split(":");switch(i=i.trim().toLowerCase(),r=r?r.trim().toLowerCase():"",i){case"a":t.axis=r?r.split(""):["x","y","z"];break;case"d":t.drag=r?r.split(""):["x","y","z"];break;case"r":t.rotate={enabled:!0,step:r&&!isNaN(Number(r))?Number(r):null};break;case"c":t.corners=!r||r.split("")}})),t}(o):{axis:["x","y","z"]},A=a.axis||[];if(A.includes("x")&&(this.asseX.visible=!0),A.includes("y")&&(this.asseY.visible=!0),A.includes("z")&&(this.asseZ.visible=!0),a.rotate&&a.rotate.enabled&&(this.rotateHandler.visible=!0),a.corners){let t={r:16711680,g:65280,b:255}[a?.corners[0]??"y"]??255;this.corners.forEach(((n,s)=>{const o=new e.Vector3(1&s?r.x:i.x,2&s?r.y:i.y,4&s?r.z:i.z);n.position.copy(o.clone().sub(i)),n.material.color.set(t),n.visible=!0}))}const l=a.drag||[];if(l.includes("z")){const t=new e.Vector3((i.x+r.x)/2-i.x,0,r.z-i.z);this.draggerZ.position.copy(t),this.draggerZ.visible=!0}if(l.includes("y")){const t=new e.Vector3(0,0,(i.z+r.z)/2-i.z);this.draggerY.position.copy(t),this.draggerY.visible=!0}if(l.includes("x")){const t=new e.Vector3(r.x-i.x,0,(i.z+r.z)/2-i.z);this.draggerX.position.copy(t),this.draggerX.visible=!0}}update(t){if(!t)return;const n=new e.Vector3;this.grp.getWorldPosition(n);const i=new e.Vector3;t.getWorldPosition(i);let r=i.distanceTo(n);const s=.05*r,o=.06*r,a=.07*r,A=.04*r;this.asseX.scale.set(s,s,s),this.asseY.scale.set(s,s,s),this.asseZ.scale.set(s,s,s),this.rotateHandler.scale.set(A,A,A),this.corners.forEach((e=>e.scale.set(o,o,o))),this.draggerX.scale.set(a,a,a),this.draggerY.scale.set(a,a,a),this.draggerZ.scale.set(a,a,a)}},creaDragger:creaDragger,creaRotateHandler:creaRotateHandler,creaCorner:creaCorner,creaAsse:creaAsse}}function d3dview(e={}){const{THREE:t,post:n,GLTFExporter:i,RGBELoader:r,KTX2Loader:s,SAOPass:o}=e,{createSAOPass:a,updateSAOPass:A}=function ssao(e){return{createSAOPass:function createSAOPass({composer:t,scene:n,camera:i,renderer:r}){const s=new e(n,i,!1,!0);return s.enabled=!1,s.params.output=0,s.params.saoBias=.06,s.params.saoIntensity=.18,s.params.saoScale=2,s.params.saoKernelRadius=4,s.params.saoMinResolution=0,s.params.saoBlur=!0,s.params.saoBlurRadius=11,s.params.saoBlurStdDev=4,s.params.saoBlurDepthCutoff=.0015,t.addPass(s),s},updateSAOPass:function updateSAOPass(e,t){const n=t/2;e.params.saoScale=4*n,e.params.saoKernelRadius=6*n}}}(o),{Picker:l,creaDragger:c,creaRotateHandler:p,creaCorner:h,creaAsse:u}=picker(t),{initHdri:d,setHdri:g,removeHdri:f,disposeHdri:m,refreshScene:y}=function hdri(e,t,n,i){let r,s,o=null,a=null;return{refreshScene:function refreshScene(t,n,r,s,o,a){if(!o)return;if(n.length=0,r.length=0,o.traverse((e=>{e.userData.pickvariant&&n.push(e),e.userData.hideable&&r.push(e),e.isMesh&&(e.castShadow=a,e.receiveShadow=a,e.material?.isMeshStandardMaterial&&null==e.material.envMapIntensity&&(e.material.envMapIntensity=.6),e.layers.enable(0),e.layers.enable(1),e.layers.enable(2),e.layers.enable(9))})),s){const t=(new e.Box3).setFromObject(o);if(!t.isEmpty()){const n=t.getSize(new e.Vector3);i(s,Math.max(n.x,n.y,n.z))}}const A=t?.userData?.dirLight;A&&a&&(A.shadow.needsUpdate=!0)},disposeHdri:function disposeHdri(){r&&(r.dispose(),r=null),s=null},removeHdri:function removeHdri(e){e&&(e.environment=null),o&&(o.dispose(),o=null),a&&(a.dispose(),a=null)},setHdri:async function setHdri(t,i){if(!(t&&i&&r&&s))return;let A;A=n._cdn?`${n._cdn}__/hdr/${t}.ktx2`:n.fullget("mufiles/gethdr",{name:`${t}.ktx2`});const l=await new Promise((t=>{s.load(A,(n=>{n.mapping=e.EquirectangularReflectionMapping,n.colorSpace=e.LinearSRGBColorSpace;const i=r.fromEquirectangular(n),s=i.texture;n.dispose(),t({envMap:s,rt:i})}),void 0,(()=>t(null)))}));l&&(o&&o.dispose(),a&&a.dispose(),o=l.envMap,a=l.rt,i.environment=o,i.backgroundBlurriness=.4)},initHdri:function initHdri(n,i){if(r&&r.dispose(),r=new e.PMREMGenerator(n),r.compileEquirectangularShader(),s||(s=new t,s.setTranscoderPath("/basis/"),s.detectSupport(n)),i){const t=new e.DirectionalLight(16777215,.8);t.position.set(-20,10,20),t.castShadow=!0,t.shadow.mapSize.set(1024,1024),t.shadow.bias=-1e-4,t.shadow.normalBias=.02;const n=20;t.shadow.camera.left=-20,t.shadow.camera.right=n,t.shadow.camera.top=n,t.shadow.camera.bottom=-20,t.shadow.camera.near=.5,t.shadow.camera.far=50,i.add(t);const r=new e.AmbientLight(16777215,.1);i.add(r),i.userData.dirLight=t,i.userData.ambLight=r}}}}(t,s,n,A),{destroyFakeShadow:b,initFakeShadow:I,refreshFakeShadow:x}=function ombraterra(e){return{destroyFakeShadow:function destroyFakeShadow(e){e&&(e.shadowRT?.dispose?.(),e.shadowPlane?.geometry?.dispose?.(),e.shadowPlane?.material?.dispose?.(),e.shadowScene?.traverse((e=>{e.geometry?.dispose?.(),e.material?.dispose?.()})))},initFakeShadow:function initFakeShadow(t){if(!t)return null;const n=(new e.Box3).setFromObject(t),i=new e.Vector3;n.getSize(i);const r=new e.Vector3;n.getCenter(r);const s=new e.OrthographicCamera(-i.x/2,i.x/2,i.z/2,-i.z/2,.001,50);s.position.set(r.x,10,r.z),s.up.set(0,0,-1),s.lookAt(r);const o=new e.WebGLRenderTarget(256,256,{minFilter:e.LinearFilter,magFilter:e.LinearFilter,format:e.RGBAFormat}),a=t.clone(!0);a.traverse((t=>{t.isMesh&&(t.material=new e.MeshBasicMaterial({color:0,transparent:!1}))})),a.scale.y*=-1;const A=(new e.Box3).setFromObject(a);a.position.y-=A.min.y;const l=new e.Scene;l.add(a);const c=new e.PlaneGeometry(1.15*i.x,1.15*i.z),p=new e.Mesh(c,new e.MeshBasicMaterial({map:o.texture,transparent:!0,opacity:.35}));return p.rotation.x=-Math.PI/2,p.position.set(r.x,n.min.y+.001,r.z),p.name="_fakeshadow",p.material=new e.MeshBasicMaterial({map:o.texture,color:0,transparent:!0,opacity:.45,blending:e.MultiplyBlending,depthWrite:!1}),p.material.needsUpdate=!0,a.traverse((t=>{t.isMesh&&(t.material=new e.MeshBasicMaterial({color:0,side:e.DoubleSide,transparent:!1}))})),{shadowPlane:p,shadowRT:o,shadowCam:s,shadowScene:l}},refreshFakeShadow:function refreshFakeShadow(t,{shadowRT:n,shadowCam:i,shadowScene:r}){if(!t||!n)return;r.updateMatrixWorld(!0);const s=new e.Color;t.getClearColor(s);const o=t.getClearAlpha?.()??1;t.setRenderTarget(n),t.setClearColor(16777215,1),t.clear(!0,!0,!0),t.render(r,i),t.setRenderTarget(null),t.setClearColor(s,o)}}}(t),{computebbox:C,zoomatutto:B,resetCameraView:E}=function camera(e,t){function computebbox(t){if(!t)return;const n=new e.Box3;return t.updateWorldMatrix(!0,!0),function visita(e){if(!e.userData?.ignoreTraverse&&!1!==e.visible){(e.isMesh||e.isLine||e.isLine2)&&n.expandByObject(e);for(const t of e.children)visita(t)}}(t),n.isEmpty()?null:n}return{computebbox:computebbox,zoomatutto:function zoomatutto(n,i,r,s=100,o=100,a=void 0){if(!n)return;const A=computebbox(n);if(!A)return;if(A.isEmpty())return;const l=A.getCenter(new e.Vector3),c=A.getSize(new e.Vector3),p=s/o;if(a){const e=Math.max(c.x,c.y,c.z);t(a,e)}if(i.isPerspectiveCamera){let t;const n=e.MathUtils.degToRad(i.fov),s=2*Math.atan(Math.tan(n/2)*p),o=(new e.Vector3).subVectors(i.position,l).normalize(),a=i.up.clone().normalize(),c=(new e.Vector3).crossVectors(o,a).normalize(),h=[new e.Vector3(A.min.x,A.min.y,A.min.z),new e.Vector3(A.min.x,A.min.y,A.max.z),new e.Vector3(A.min.x,A.max.y,A.min.z),new e.Vector3(A.min.x,A.max.y,A.max.z),new e.Vector3(A.max.x,A.min.y,A.min.z),new e.Vector3(A.max.x,A.min.y,A.max.z),new e.Vector3(A.max.x,A.max.y,A.min.z),new e.Vector3(A.max.x,A.max.y,A.max.z)];let u=0,d=1/0,g=-1/0;for(const t of h){const i=(new e.Vector3).subVectors(t,l),r=i.dot(a),A=i.dot(c),p=i.dot(o),h=Math.abs(r)/Math.tan(n/2),f=Math.abs(A)/Math.tan(s/2),m=Math.max(h,f)+Math.abs(p);m>u&&(u=m),p<d&&(d=p),p>g&&(g=p)}t=1*u;const f=.5*Math.max(.001,g-d);i.position.copy(l).addScaledVector(o,t);const m=8;i.near=.01,i.far=Math.max(1,t+1.2*f+m),i.updateProjectionMatrix(),r.minDistance=i.near,r.maxDistance=i.far-4,i.lookAt(l)}else if(i.isOrthographicCamera){let e=1*c.x,t=1*c.y;e/t<p?e=t*p:t=e/p,i.near=.001,i.left=-e/2,i.right=e/2,i.top=t/2,i.bottom=-t/2,i.zoom=1,i.updateProjectionMatrix()}r&&(r.target.copy(l),r.update())},resetCameraView:function resetCameraView(t,n,i,r,s,o="top"){if(!t)return;const a=computebbox(t),A=new e.Vector3,l=new e.Vector3;a.getCenter(A),a.getSize(l);let c,p,h=new e.Vector3,u=new e.Vector3;switch(o){case"top":case"bottom":c=l.x,p=l.z,h.set(A.x,a.max.y+("top"==o?10:-10),A.z),u.set(0,0,"top"==o?-1:1);break;case"front":case"back":c=l.x,p=l.y,h.set(A.x,A.y,a.max.z+("front"==o?10:-10)),u.set(0,1,0);break;case"left":case"right":c=l.z,p=l.y,h.set(a.max.x+("right"==o?10:-10),A.y,A.z),u.set(0,1,0);break;case o.startsWith("angle:")&&o:{const t=parseFloat(o.split(":")[1])||0,n=parseFloat(o.split(":")[2])||0;if(isNaN(t))return void console.warn("Angolo non valido:",o);const i=e.MathUtils.degToRad(t+180),r=Math.cos(n),s=new e.Vector3(r*Math.sin(i),Math.sin(n),-r*Math.cos(i)),a=2*Math.max(l.x,l.y,l.z);h.copy(A).addScaledVector(s,a),u.set(0,1,0),c=l.x,p=l.y;break}default:return void console.warn("Vista non riconosciuta:",o)}const d=r/(1.05*c),g=s/(1.05*p),f=Math.min(d,g),m=r/(2*f),y=s/(2*f);n.left=-m,n.right=m,n.top=y,n.bottom=-y,n.near=.1,n.far=100,n.zoom=1,n.updateProjectionMatrix(),n.position.copy(h),n.up.copy(u),n.lookAt(A),i.object=n,i.target.copy(A),i.update()}}}(t,A),{exportGLB:w}=function exportscene(e,t){return{exportGLB:async function exportGLB(n,i,r={}){if(!n)return;i||(i="scena.glb");const s=new t,o=new e.Layers;o.enable(0),o.enable(1),o.enable(2);const a=function cloneFiltered(e){if(!o.test(e.layers))return null;const t=e.clone(!1);t.userData={};for(let n of e.children){const e=cloneFiltered(n);e&&t.add(e)}return t}(n);if(!a)return;const A={binary:!0,embedImages:!0,onlyVisible:!0,userData:!1,...r};try{const e=await new Promise(((e,t)=>{s.parse(a,e,t,A)})),t=new Blob([e],{type:"application/octet-stream"}),n=URL.createObjectURL(t),r=document.createElement("a");r.href=n,r.download=i,r.click(),URL.revokeObjectURL(n)}catch(e){console.error("Errore durante l’esportazione:",e)}},extractPathTracingScene:function extractPathTracingScene(t){const n=new e.Scene;t.updateMatrixWorld(!0),t.environment&&(n.environment=t.environment);const i=new e.Layers;return i.enable(0),i.enable(1),i.enable(2),t.traverse((t=>{if(i.test(t.layers)&&t.isMesh&&i.test(t.layers)&&(Array.isArray(t.material)?t.material.every((e=>e.isMeshStandardMaterial||e.isMeshPhysicalMaterial)):t.material.isMeshStandardMaterial||t.material.isMeshPhysicalMaterial)){const i=t.geometry.clone(),r=Array.isArray(t.material)?t.material.map((e=>e.clone())):t.material.clone(),s=new e.Mesh(i,r);t.updateWorldMatrix(!0,!1),t.getWorldPosition(s.position),t.getWorldQuaternion(s.quaternion),t.getWorldScale(s.scale),n.add(s)}})),n}}}(t,i);return{createSAOPass:a,updateSAOPass:A,resetCameraView:E,computebbox:C,zoomatutto:B,exportSceneImage:exportSceneImage,exportGLB:w,stati:vt,handleMovimenti:handleMovimenti,handlePick:handlePick,checkhoverables:checkhoverables,Picker:l,creaDragger:c,creaRotateHandler:p,creaCorner:h,creaAsse:u,initHdri:d,setHdri:g,removeHdri:f,disposeHdri:m,refreshScene:y,destroyFakeShadow:b,initFakeShadow:I,refreshFakeShadow:x}}function joinlinestoshapes(e){let t=[];for(let n of e)for(let e of n.lines){let i=new Linea2(e.p1,e.p2);i.rotate(-n.ang),i.move(n.pos.x,n.pos.z),i.valid=!0,t.push(i)}const n=.1;function samepoint(e,t){return Math.abs(e.x-t.x)+Math.abs(e.y-t.y)<n}for(let e=0;e<t.length;e++){if(!t[e].valid)continue;if(t[e].len<n){t[e].valid=!1;continue}const i=t[e];for(let r=e+1;r<t.length;r++){const e=t[r];if(!e.valid)continue;if(!i.isparallela(e))continue;if(!i.isCollineare(e))continue;i.a1b=e.onsegment(i.p1,n),i.a2b=e.onsegment(i.p2,n),i.b1a=i.onsegment(e.p1,n),i.b2a=i.onsegment(e.p2,n);const{x:s,y:o}=i.direzione,{x:a,y:A}=e.direzione;if(s*a+o*A>0)if(i.b1a&&i.b2a)e.valid=!1;else{if(i.a1b&&i.a2b){i.valid=!1;break}if(i.a1b&&i.b2a){let n=new Linea2(e.p1,i.p2);n.valid=!0,t.push(n),i.valid=!1,e.valid=!1;break}if(i.a2b&&i.b1a){let n=new Linea2(i.p1,e.p2);n.valid=!0,t.push(n),i.valid=!1,e.valid=!1;break}}else{const r=i.proiezionet(i.p1).t,s=i.proiezionet(i.p2).t,o=i.proiezionet(e.p1).t,a=i.proiezionet(e.p2).t,A=Math.min(r,s),l=Math.max(r,s),c=Math.min(o,a),p=Math.max(o,a),h=Math.max(A,c),u=Math.min(l,p);if(u>h+n){if(A<h){let e=new Linea2(i.puntot(A),i.puntot(h));e.valid=!0,t.push(e)}if(l>u){let e=new Linea2(i.puntot(l),i.puntot(u));e.valid=!0,t.push(e)}if(c<h){let e=new Linea2(i.puntot(c),i.puntot(h));e.valid=!0,t.push(e)}if(p>u){let e=new Linea2(i.puntot(p),i.puntot(u));e.valid=!0,t.push(e)}i.valid=!1,e.valid=!1;break}}}}t=t.filter((e=>e.valid)).map((e=>getshape().frompt([e.p1,e.p2])));for(let e=0;e<t.length;e++){let n=t[e],i=!0;for(;i;){i=!1;for(let r=e+1;r<t.length;){let e=t[r];samepoint(n.pt[0],e.pt[0])?(e.pt.reverse(),n.pt.unshift(...e.pt.slice(0,-1)),t.splice(r,1),i=!0):samepoint(n.pt[n.pt.length-1],e.pt[e.pt.length-1])?(e.pt.reverse(),n.pt.push(...e.pt.slice(1)),t.splice(r,1),i=!0):samepoint(n.pt[0],e.pt[e.pt.length-1])?(n.pt.unshift(...e.pt.slice(0,-1)),t.splice(r,1),i=!0):samepoint(n.pt[n.pt.length-1],e.pt[0])?(n.pt.push(...e.pt.slice(1)),t.splice(r,1),i=!0):r++}}}return t}function compattaqta(e){let t={};for(let n of e){let e=getdim(n.l,n.a,n.p,n.al,n.aa,n.ap),i=`${n.note}|${e}|${n.vars}`.trim().toLocaleLowerCase();t[i]||(t[i]={note:n.note,vars:n.vars,qt:0,dm:e}),t[i].qt+=n.qt}return Object.values(t)}function getdim(e,t,n,i,r,s,o,a,A){let l,c=[];function getsingledim(e,t,n){return e||(e=t),e=Math.round(10*(e||0))/10,t?"X"==(n=(n||"_").trim().toLowerCase())&&e!=t?e+"*":"M"==n?e+"M":e:e}return l=getsingledim(e,i,o),l&&c.push(l),l=getsingledim(t,r,a),l&&c.push(l),l=getsingledim(n,s,A),l&&c.push(l),c.join("x")}function calcolatotali(e,t){return e.reduce(((e,n)=>(n.qt=n.qt||1,e.tot+=n.qt*(t?n.prc:n.pr)||0,e.area+=n.area*n.qt||0,e.peson+=n.peson*n.qt||0,e.pesol+=n.pesol*n.qt||0,e.volume+=n.volume*n.qt||0,e.perimetro+=n.perimetro*n.qt||0,e.item+=n.qt||1,e)),{tot:0,area:0,perimetro:0,peson:0,pesol:0,volume:0,items:0})}function compattadistinta(e,t){let n=[],i={};if(e&&e.length){for(let t of e)if(["l","x","p"].includes(t.lev)){let e=`${t.cod}|${t.des}`;i[e]||(i[e]={cod:t.cod,des:t.des,rows:[]}),i[e].rows.push(t)}n=Object.values(i).sort(((e,t)=>e.cod.localeCompare(t.cod)));for(let e=0;e<n.length;e++){let i=calcolatotali(n[e].rows,t);n[e].rows=compattaqta(n[e].rows),n[e]={...n[e],...i}}}return n}function checkmovedata(e,t,n){return{l:e((t=(t||"").split(","))[0]),a:e(t[1]),p:e(t[2]),rot:e(t[3]),annulla:e(t[4]),pars:n?.spars||""}}async function valutagrafica(e,t,n,i,r){let{getcolonne:s,muCalc:o,muEval:a,tipifree:A}=e.muvalutatore;n||(n={});for(let n of["l","a","p"]){!e.vari.var(n)&&t.dims&&e.vari.add(n,String(t.dims[n].val||100))}let l=new Set;const c=["sl","sa","sp","ax","ay","az","scx","scy","scz","scale"];let p,h=!1,u=await a(e,t,t.codice,{leveleval:0,checkheader:e=>{let{variante:n}=e;if(Array.isArray(t.head)){let e=t.head.find((e=>e.cod==n));h=!!e}},grafica:async t=>{let r,s,A,l,p,{id:h,pars:u,parametri:d,macro:g,options:f,vari:m}=t,y=!!(g&&g.head&&g.head.length),b={l:e.vari.var("l"),a:e.vari.var("a"),p:e.vari.var("p")};const I=["l","a","p","#d",...c];for(let t of I){let n=e.vari.dictionary[t];n&&(b[t]=n)}async function _parsepars(t,n){let i,a,c=/^#(d|des|descrizione)\s*=\s*(.*)\s*$/im.exec(t);if(c)i="#d",a=await e.vari.valuta(c[2]);else{let e=await m.parametrokeyval(t);i=e.k,a=e.v}i&&!p[i]&&(p[i]=!0,I.includes(i)?"#d"==i?l=a:("string"==typeof a&&(a=o(a)),["l","a","p"].includes(i)&&e.vari.add(i,String(a)),s[i]=a,A=!0):"string"==typeof a?r.push(`${i}=${a}`):e.vari.add(i,a))}let x,C;if(r=[],s={},A=!1,l="",p={},i&&i.keys&&i.keys[h]&&(x=i.keys[h].pars,x))for(let t in x){let n=e.vari.dictionary[t];n&&(b[t]=n),await _parsepars(`${t}=${x[t]}`)}if(u&&u.length)for(const e of u)await _parsepars(e);if(d&&d.length)for(const e of d)await _parsepars(e);if(g&&g.head&&g.head.length){C=g.head.find((e=>"_move"==e.cod));let e=g.head.filter((e=>!["g","p"].includes(e.t)&&"_move"!=e.cod));for(const t of e)await _parsepars(t.cod)}let B={iscad:A,isheader:y,name:g.name,des:l,leveleval:f.leveleval};y&&h&&(B.id=h),A&&(s.l?e.vari.add("l",String(s.l)):s.l=o(e.vari.var("l")),s.a?e.vari.add("a",String(s.a)):s.a=o(e.vari.var("a")),s.p?e.vari.add("p",String(s.p)):s.p=o(e.vari.var("p")),B.cadv=s),await g.impostaparametri(d,r,!0,x);let E=n[h];h&&y&&E&&E.pars&&(B.pars=E.pars,f.leveleval++,await g.setparametri(E.pars));let w=e.vari.var("_rootnode");if(e.vari.add("_rootnode","0"),B.rows=await a(e,g,g.codice,f),e.vari.add("_rootnode",w),h&&y&&(B.spars=g.getparametri()),A){C?B.cadv.move=checkmovedata(o,e.vari.var("_move"),C):delete B.cadv.move;for(let t in b)e.vari.dictionary[t]=b[t]}return B},parsefnpunto:async e=>{let{dati:t,vari:n,id:i,output:r}=e;t=t.trim();let a=t.indexOf(" "),A=t.indexOf(",");A>0&&a>0&&A<a&&(a=A);let p,h,u={},d={};a>1?(p=t.slice(1,a),h=s(t.slice(a+1))):(p=t.slice(1),h=[]),l.has(p)||l.add(p);for(let e of h){let{k:t,v:i}=await n.parametrokeyval(e);t&&/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(t)&&(u[t]=i||"")}for(let e of["l","a","p"])u[e]||(u[e]=n.var(e));let g=Object.keys(u);for(let e of c)g.includes(e)&&(d[e]=o(u[e]),d[e]&&(u[e]=d[e]));r.push({t:"fn",fn:p,id:i,pars:u,p2:d})}});for(let n of["l","a","p"])if(t.dims&&t.dims[n].val!=parseFloat(e.vari.var(n))){p=!0;break}return(h||p&&"function"==typeof r)&&await r(p,h),{oo:u,vari:e.vari.dump(!0),fnlist:[...l]}}function ismacro(e){return"object"==typeof e&&e?.name&&e.rows}function isfn(e){return"object"==typeof e&&"fn"==e?.t}function getnodebyid(e,t){let n;return t&&t.rows&&function _getnode(t){for(let i of t){if(ismacro(i)){if(i.id==e)return void(n=i);i.rows&&_getnode(i.rows)}if(n)return}}(t.rows),n}function getsubrules(e){let t=[];return t.push({id:"",level:0,name:"home"}),function _xfiltrati(e,n){if(e.rows&&e.rows.length)for(let i of e.rows)ismacro(i)&&(i.id&&i.isheader?(t.push({id:i.id,name:i.name,des:i.des||"",spec:i.pars?1:0,level:n}),_xfiltrati(i,n+1)):_xfiltrati(i,n))}(e,1),t}function getdumpmacro(e){let t=[];return function _dumpnodo(e){if(e.rows&&e.rows.length)for(let n of e.rows)if(ismacro(n)){n.name;let e=[];if(n.iscad&&n.cadv)for(let t in n.cadv){let i=n.cadv[t];"number"==typeof i&&i&&e.push(`${t}=${i}`)}if(n.pars)for(let t in n.pars){let i=n.pars[t];e.push(`${t}=${i}`)}e.length&&t.push(`--\x3e ${n.name} ${e.join(",")}`),_dumpnodo(n),e.length&&t.push("<--")}else isfn(n)?t.push(`FN: ${n.fn} ${JSON.stringify(n.pars)}`):"string"==typeof n&&n.length&&t.push(n)}(e),t.join("\n")}function getgalleryvariants(e){let t=[],n=e.keys;function parsespars(e,i,r){if(!e)return;let s=n[i]?.pars;Object.entries(e).forEach((([e,n])=>{["l","a","p","_move"].includes(e)||"string"!=typeof n||(s&&s[e],t.push({id:i||"/",des:r,k:e,v:n,force:0}))}))}return parsespars(e.pars,"","/"),function parserows(e){if(e&&e.length)for(let t of e){if(t.iscad&&t.isheader){let e=t.id;parsespars(t.spars,e,t.des)}t.rows&&t.rows.length&&parserows(t.rows)}}(e.rows),t}async function getdettvarstampa(e,t,n){let{getcolonne:i,getcouple:r}=e.muvalutatore,s={},o=[];const a="_varstampa";let A=i(n.pars[a])[0];if(A){let l=await e.getvariante(a),c=l?.rows?l.rows[A]?.v:"";if(c&&c[2]&&(o=c[2].split("*"),s[`${a}=${A}`]=["",...c]),o.length){async function saveparsv(n){for(let i in n)if(o.includes(i)){let r=n[i],o=`${i}=${r}`;if(!s[o]){let n=await e.getvariante(i),a=[r],A=n?.des||i;if(t&&t.head){let e=t.head.find((e=>e.cod==i));e&&(A=e.des||A)}if(n&&n.rows){let e=n.rows[r];e?.v&&(a=e.v)}s[o]=[A,...a]}}}if(await saveparsv(n.pars),n.DB&&n.DB.length)for(let p of n.DB)if(p.vars){let h=i(p.vars.trim().toLowerCase()),u={};for(let d of h){let{v:g,o:f}=r(d);g&&f&&(u[g]=f)}await saveparsv(u)}if(n.keys)for(let m in n.keys){let y=n.keys[m];y&&y.pars&&await saveparsv(y.pars)}}}return s}function konvautils(e){function renderizzaSuLayer(t,n,i,{inverse:r=!0,height:s=600,strokescale:o=2,fontsize:a=2,attivo:A=!0,opacita_inattivo:l=.35}={}){if(!i||!i.vec||!i.vec.length)return;"boolean"==typeof i.attivo&&(A=i.attivo);let c,p=!1,h=!0,u=0;if(r){const f=new e.Group({scaleY:-1,y:s});n.add(f),c=f}else h=!1,c=new e.Group;n.add(c),c.opacity(A?1:l);const d=[c];let g=[];function getTesto(t,n,i,r,s,o,a,A){const l=new e.Text({scaleY:r?A?-1:1:A?1:-1,scaleX:i?-1:1,x:0,y:0,text:t,fontSize:6*n,fill:s||"black"}),c=l.width(),p=l.height(),h=function findFreeY(e,t,n,i){let r=t,s=0;for(;g.some((t=>Math.abs(e-t.x)<n&&Math.abs(r-t.y)<i))&&(r-=1.01*i,!(++s>10)););return g.push({x:e,y:r,width:n,height:i}),r}(o,a,c,p);return l.x(o),l.y(h),A||l.offset({x:c/2,y:p/2}),l}for(let m of[0,1]){function drawobjects(n,i){for(const s of n)switch(s.type){case"group":if(i?.[s.name]){let e=i[s.name];e.vec?.length&&++u<20&&(drawobjects(e.vec,e.gr),u--)}break;case"push":{const{op:t}=s;let n={x:s.x||0,y:s.y||0,rotation:s.rot||t.rot||0,scaleX:t.mirrorx?-1:t.scalex||t.scale||1,scaleY:t.mirrory?-1:t.scaley||t.scale||1};n.scaleX<0&&(p=!p),n.scaleY<0&&(h=!h);const i=new e.Group(n);c.add(i),d.push(i),c=i;break}case"pop":if(d.length>1){const e=d.pop();e.getAttr("scaleX")<0&&(p=!p),e.getAttr("scaleY")<0&&(h=!h),c=d[d.length-1]}break;case"img":if(0===m){const{x:n,y:i}=s.l.p1,o=s.l.p2.x-n,a=s.l.p2.y-i;let A=t.get(s.img);if(!A){A=new window.Image,A.src=s.img,t.set(s.img,A);const l=c,p=n,h=i,u=o,d=a,g=r;A.addEventListener("load",(()=>{let t=l.findOne(".img");t?(t.image(A),t.setAttrs({x:p,y:g?h+d:h,width:u,height:d,scaleY:g?-1:1})):l.add(new e.Image({name:"img",x:p,y:g?h+d:h,image:A,width:u,height:d,scaleY:g?-1:1,listening:!1})),l.getLayer().batchDraw()}))}if(A.complete){let t=c.findOne(".img");t?(t.image(A),t.setAttrs({x:n,y:r?i+a:i,width:o,height:a,scaleY:r?-1:1})):c.add(new e.Image({name:"img",x:n,y:r?i+a:i,image:A,width:o,height:a,scaleY:r?-1:1,listening:!1}))}}break;case"line":if(0===m)c.add(new e.Line({points:[s.l.p1.x,s.l.p1.y,s.l.p2.x,s.l.p2.y],stroke:s.color||"black",strokeWidth:(s.spessore||1)*o}));else if(s.id&&-1!=s.id){const e=(s.l.p1.x+s.l.p2.x)/2,t=(s.l.p1.y+s.l.p2.y)/2+6*a;c.add(getTesto(s.id,4*a,p,h,"black",e,t,r))}break;case"rect":case"space":case"recta":if(0===m){const{x:t,y:n}=s.l.p1,i=s.l.p2.x-t,r=s.l.p2.y-n;c.add("space"==s.type?new e.Rect({x:t,y:n,width:i,height:r,stroke:null,fill:null,listening:!1,hitStrokeWidth:0}):new e.Rect({x:t,y:n,width:i,height:r,stroke:"rect"===s.type?s.color||"black":void 0,fill:"recta"===s.type?s.color||"rgba(0,0,255,0.2)":s.fill,strokeWidth:(s.spessore||1)*o}))}break;case"point":if(1===m&&(c.add(new e.Circle({x:s.p.x,y:s.p.y,radius:s.spessore||8,fill:s.color||"black"})),s.id&&-1!=s.id)){const e=4*a;c.add(getTesto(s.id,e,p,h,s.color||"black",s.p.x+2*e,s.p.y+2*e,r))}break;case"shapelin":case"shape":case"area":0===m&&s.s?.length&&c.add(new e.Line({points:s.s.flatMap((e=>[e.x,e.y])),closed:"shapelin"!==s.type,fill:"area"===s.type?s.color||"rgba(0,0,255,0.2)":s.fill,stroke:s.color||"black",strokeWidth:(s.spessore||1)*o}));break;case"text":if(1===m&&s.text){const e=(s.scalafont||1)*a,t=s.color||"black";c.add(testo(s.x,s.y,s.text,e,t,s.fill,p,h))}break;case"quota":{let e=(s.scalafont||1)*a;s.text||(s.text=Math.sqrt((s.x2-s.x1)**2+(s.y2-s.y1)**2).toFixed(1)),c.add(quotalineare(s.x1,s.y1,s.x2,s.y2,s.d,s.text+"",e,s.color,s.spessore,p,h));break}case"qpunto":{let e=(s.scalafont||1)*a;c.add(quotapunto(s.x1,s.y1,s.text,s.d,e,s.color,s.spessore));break}}}drawobjects(i.vec,i.gr)}}function testo(t,n,i,r,s="black",o="white",a,A,l){const c=new e.Group;try{const l=new e.Text({scaleY:A?-1:1,scaleX:a?-1:1,x:t,y:n,text:i,fontSize:6*r,fill:s,align:"center",verticalAlign:"middle",lineHeight:1.2}),p=l.getTextWidth();l.width(p);const h=l.getHeight();l.offsetX(p/2),l.offsetY(h/2),o&&c.add(new e.Rect({x:t,y:n,width:p+8,height:h,fill:o,cornerRadius:4,offsetX:p/2+4,offsetY:h/2,listening:!1,scaleY:A?-1:1,scaleX:a?-1:1})),c.add(l)}catch(e){console.log(e.message)}return c}function quotalineare(t,n,i,r,s,o,a,A="black",l=1,c,p){const h=i-t,u=r-n,d=Math.sqrt(h*h+u*u);if(0===d)return new e.Group;const g=-u/d*s,f=h/d*s,m=[t+g,n+f],y=[i+g,r+f],b=(m[0]+y[0])/2,I=(m[1]+y[1])/2,x=new e.Group;x.add(new e.Line({points:[t,n,t+1.2*g,n+1.2*f],stroke:A,strokeWidth:l})),x.add(new e.Line({points:[i,r,i+1.2*g,r+1.2*f],stroke:A,strokeWidth:l})),x.add(new e.Line({points:[...m,...y],stroke:A,strokeWidth:l}));const C=o.length*a*4,B=6*a,E=180*Math.atan2(u,h)/Math.PI;return x.add(new e.Rect({x:b,y:I,width:C,height:B,fill:"white",offsetX:C/2,offsetY:B/2,rotation:E,listening:!1,scaleY:p?-1:1,scaleX:c?-1:1})),x.add(new e.Text({scaleY:p?-1:1,scaleX:c?-1:1,x:b,y:I,text:o,fontSize:6*a,fill:A,align:"center",verticalAlign:"middle",width:C,height:B,offsetX:C/2,offsetY:B/2,rotation:E})),x}function quotapunto(t,n,i,r,s,o="black",a=1,A,l){const c=t+r,p=n+r,h=new e.Group;return h.add(new e.Line({points:[t,n,c,p],stroke:o,strokeWidth:a})),h.add(new e.Text({x:c,y:p,text:i,fontSize:6*s,fill:o,offsetX:i.length*s*2,offsetY:3*s})),h}return{renderizzaSuLayer:renderizzaSuLayer,saveimg_konva:async function saveimg_konva(t,n,i,r,s,o=10,a=1,A=2){let l=`${t}${i.name}`;const c=document.createElement("div");c.style.position="absolute",c.style.left="-10000px",c.style.top="-10000px",c.style.width=r+"px",c.style.height=s+"px",document.body.appendChild(c),console.log(i);const p=new e.Stage({container:c,width:r,height:s}),h=new e.Layer;p.add(h),renderizzaSuLayer(n,h,i,{height:s,strokescale:a,fontsize:A}),h.draw();const u=h.children[0].getClientRect({skipTransform:!1}),d=(r-2*o)/u.width,g=(s-2*o)/u.height,f=Math.min(d,g),m=-u.x*f+o+(r-u.width*f-2*o)/2,y=-u.y*f+o+(s-u.height*f-2*o)/2;p.scale({x:f,y:f}),p.position({x:m,y:y}),h.draw();const b=p.toDataURL({pixelRatio:1,mimeType:"image/webp",quality:.95});p.destroy(),document.body.removeChild(c);{const e=b.split(","),t=e[0].match(/:(.*?);/)[1],n=atob(e[1]),i=new Uint8Array(n.length);for(let e=0;e<n.length;e++)i[e]=n.charCodeAt(e);return new File([i],`${l}.webp`,{type:t})}}}}var Qt=class Handle{static seed=0;static next(){return(++Handle.seed).toString(16).toUpperCase()}static peek(){return(Handle.seed+1).toString(16).toUpperCase()}};const Pt=Qt;var Tt=class DatabaseObject{constructor(e=null){this.handle=Pt.next(),this.ownerObjectHandle="0",this.subclassMarkers=[],e&&(Array.isArray(e)?this.subclassMarkers.push(...e):this.subclassMarkers.push(e))}tags(e){e.push(5,this.handle),e.push(330,this.ownerObjectHandle);for(const t of this.subclassMarkers)e.push(100,t)}};const St=Tt;var Mt=class LineType extends St{constructor(e,t,n){super(["AcDbSymbolTableRecord","AcDbLinetypeTableRecord"]),this.name=e,this.description=t,this.elements=n}tags(e){e.push(0,"LTYPE"),super.tags(e),e.push(2,this.name),e.push(3,this.description),e.push(70,0),e.push(72,65),e.push(73,this.elements.length),e.push(40,this.getElementsSum()),this.elements.forEach((t=>{e.push(49,t),e.push(74,0)}))}getElementsSum(){return this.elements.reduce(((e,t)=>e+Math.abs(t)),0)}};const Dt=Tt;var Lt=class Layer extends Dt{constructor(e,t,n=null){super(["AcDbSymbolTableRecord","AcDbLayerTableRecord"]),this.name=e,this.colorNumber=t,this.lineTypeName=n,this.shapes=[],this.trueColor=-1}tags(e){e.push(0,"LAYER"),super.tags(e),e.push(2,this.name),-1!==this.trueColor?e.push(420,this.trueColor):e.push(62,this.colorNumber),e.push(70,0),this.lineTypeName&&e.push(6,this.lineTypeName),e.push(390,1)}setTrueColor(e){this.trueColor=e}addShape(e){this.shapes.push(e),e.layer=this}getShapes(){return this.shapes}shapesTags(e,t){for(const n of this.shapes)n.ownerObjectHandle=e.handle,n.tags(t)}};const _t=Tt;var Ft=class Table extends _t{constructor(e){super("AcDbSymbolTable"),this.name=e,this.elements=[]}add(e){e.ownerObjectHandle=this.handle,this.elements.push(e)}tags(e){e.push(0,"TABLE"),e.push(2,this.name),super.tags(e),e.push(70,this.elements.length),this.elements.forEach((t=>{t.tags(e)})),e.push(0,"ENDTAB")}};const kt=Tt,Rt=Ft;var Nt=class DimStyleTable extends Rt{constructor(e){super(e),this.subclassMarkers.push("AcDbDimStyleTable")}tags(e){e.push(0,"TABLE"),e.push(2,this.name),kt.prototype.tags.call(this,e),e.push(70,this.elements.length),e.push(71,1);for(const t of this.elements)t.tags(e);e.push(0,"ENDTAB")}};const Ot=Tt;var Gt=class TextStyle extends Ot{fontFileName="txt";constructor(e){super(["AcDbSymbolTableRecord","AcDbTextStyleTableRecord"]),this.name=e}tags(e){e.push(0,"STYLE"),super.tags(e),e.push(2,this.name),e.push(70,0),e.push(40,0),e.push(41,1),e.push(50,0),e.push(71,0),e.push(42,1),e.push(3,this.fontFileName),e.push(4,"")}};const Ut=Tt;var Yt=class Viewport extends Ut{constructor(e,t){super(["AcDbSymbolTableRecord","AcDbViewportTableRecord"]),this.name=e,this.height=t}tags(e){e.push(0,"VPORT"),super.tags(e),e.push(2,this.name),e.push(40,this.height),e.push(70,0)}};const zt=Tt;var Ht=class AppId extends zt{constructor(e){super(["AcDbSymbolTableRecord","AcDbRegAppTableRecord"]),this.name=e}tags(e){e.push(0,"APPID"),super.tags(e),e.push(2,this.name),e.push(70,0)}};const Xt=Tt;var qt=class Block extends Xt{constructor(e){super(["AcDbEntity","AcDbBlockBegin"]),this.name=e,this.end=new Xt(["AcDbEntity","AcDbBlockEnd"]),this.recordHandle=null}tags(e){e.push(0,"BLOCK"),super.tags(e),e.push(2,this.name),e.push(70,0),e.point(0,0),e.push(3,this.name),e.push(1,""),e.push(0,"ENDBLK"),this.end.tags(e)}};const jt=Tt;var Wt=class BlockRecord extends jt{constructor(e){super(["AcDbSymbolTableRecord","AcDbBlockTableRecord"]),this.name=e}tags(e){e.push(0,"BLOCK_RECORD"),super.tags(e),e.push(2,this.name),e.push(70,0),e.push(280,0),e.push(281,1)}};const Jt=Tt;var Vt=class Dictionary extends Jt{constructor(){super("AcDbDictionary"),this.children={}}addChildDictionary(e,t){t.ownerObjectHandle=this.handle,this.children[e]=t}tags(e){e.push(0,"DICTIONARY"),super.tags(e),e.push(281,1);const t=Object.entries(this.children);for(const n of t){const[t,i]=n;e.push(3,t),e.push(350,i.handle)}const n=Object.values(this.children);for(const t of n)t.tags(e)}};const Kt=Tt;var Zt=class Line extends Kt{constructor(e,t,n,i){super(["AcDbEntity","AcDbLine"]),this.x1=e,this.y1=t,this.x2=n,this.y2=i}tags(e){e.push(0,"LINE"),super.tags(e),e.push(8,this.layer.name),e.point(this.x1,this.y1),e.push(11,this.x2),e.push(21,this.y2),e.push(31,0)}};const $t=Tt;var en=class Line3d extends $t{constructor(e,t,n,i,r,s){super(["AcDbEntity","AcDbLine"]),this.x1=e,this.y1=t,this.z1=n,this.x2=i,this.y2=r,this.z2=s}tags(e){e.push(0,"LINE"),super.tags(e),e.push(8,this.layer.name),e.point(this.x1,this.y1,this.z1),e.push(11,this.x2),e.push(21,this.y2),e.push(31,this.z2)}};const tn=Tt;var nn=class Arc extends tn{constructor(e,t,n,i,r){super(["AcDbEntity","AcDbCircle"]),this.x=e,this.y=t,this.r=n,this.startAngle=i,this.endAngle=r}tags(e){e.push(0,"ARC"),super.tags(e),e.push(8,this.layer.name),e.point(this.x,this.y),e.push(40,this.r),e.push(100,"AcDbArc"),e.push(50,this.startAngle),e.push(51,this.endAngle)}};const rn=Tt;var sn=class Circle extends rn{constructor(e,t,n){super(["AcDbEntity","AcDbCircle"]),this.x=e,this.y=t,this.r=n}tags(e){e.push(0,"CIRCLE"),super.tags(e),e.push(8,this.layer.name),e.point(this.x,this.y),e.push(40,this.r)}};const on=Tt;var an=class Cylinder extends on{constructor(e,t,n,i,r,s,o,a){super(["AcDbEntity","AcDbCircle"]),this.x=e,this.y=t,this.z=n,this.r=i,this.thickness=r,this.extrusionDirectionX=s,this.extrusionDirectionY=o,this.extrusionDirectionZ=a}tags(e){e.push(0,"CIRCLE"),super.tags(e),e.push(8,this.layer.name),e.point(this.x,this.y,this.z),e.push(40,this.r),e.push(39,this.thickness),e.push(210,this.extrusionDirectionX),e.push(220,this.extrusionDirectionY),e.push(230,this.extrusionDirectionZ)}};const An=Tt,ln=["left","center","right"],cn=["baseline","bottom","middle","top"];var pn=class Text extends An{constructor(e,t,n,i,r,s="left",o="baseline"){super(["AcDbEntity","AcDbText"]),this.x=e,this.y=t,this.height=n,this.rotation=i,this.value=r,this.hAlign=s,this.vAlign=o}tags(e){e.push(0,"TEXT"),super.tags(e),e.push(8,this.layer.name),e.point(this.x,this.y),e.push(40,this.height),e.push(1,this.value),e.push(50,this.rotation),ln.includes(this.hAlign,1)||cn.includes(this.vAlign,1)?(e.push(72,Math.max(ln.indexOf(this.hAlign),0)),e.push(11,this.x),e.push(21,this.y),e.push(31,0),e.push(100,"AcDbText"),e.push(73,Math.max(cn.indexOf(this.vAlign),0))):e.push(100,"AcDbText")}};const hn=Tt;var un=class Polyline extends hn{constructor(e,t=!1,n=0,i=0){super(["AcDbEntity","AcDbPolyline"]),this.points=e,this.closed=t,this.startWidth=n,this.endWidth=i}tags(e){e.push(0,"LWPOLYLINE"),super.tags(e),e.push(8,this.layer.name),e.push(6,"ByLayer"),e.push(62,256),e.push(370,-1),e.push(90,this.points.length),e.push(70,this.closed?1:0),this.points.forEach((t=>{const[n,i,r]=t;e.push(10,n),e.push(20,i),0===this.startWidth&&0===this.endWidth||(e.push(40,this.startWidth),e.push(41,this.endWidth)),void 0!==r&&e.push(42,r)}))}};const dn=Tt;var gn=class Vertex extends dn{constructor(e,t,n){super(["AcDbEntity","AcDbVertex","AcDb3dPolylineVertex"]),this.x=e,this.y=t,this.z=n}tags(e){e.push(0,"VERTEX"),super.tags(e),e.push(8,this.layer.name),e.point(this.x,this.y,this.z),e.push(70,32)}};const fn=Tt,mn=Qt,yn=gn;var bn=class Polyline3d extends fn{constructor(e){super(["AcDbEntity","AcDb3dPolyline"]),this.verticies=e.map((e=>{const[t,n,i]=e,r=new yn(t,n,i);return r.ownerObjectHandle=this.handle,r})),this.seqendHandle=mn.next()}tags(e){e.push(0,"POLYLINE"),super.tags(e),e.push(8,this.layer.name),e.push(66,1),e.push(70,0),e.point(0,0),this.verticies.forEach((t=>{t.layer=this.layer,t.tags(e)})),e.push(0,"SEQEND"),e.push(5,this.seqendHandle),e.push(100,"AcDbEntity"),e.push(8,this.layer.name)}};const In=Tt;var xn=class Face extends In{constructor(e,t,n,i,r,s,o,a,A,l,c,p){super(["AcDbEntity","AcDbFace"]),this.x1=e,this.y1=t,this.z1=n,this.x2=i,this.y2=r,this.z2=s,this.x3=o,this.y3=a,this.z3=A,this.x4=l,this.y4=c,this.z4=p}tags(e){e.push(0,"3DFACE"),super.tags(e),e.push(8,this.layer.name),e.point(this.x1,this.y1,this.z1),e.push(11,this.x2),e.push(21,this.y2),e.push(31,this.z2),e.push(12,this.x3),e.push(22,this.y3),e.push(32,this.z3),e.push(13,this.x4),e.push(23,this.y4),e.push(33,this.z4)}};const Cn=Tt;var Bn=class Point extends Cn{constructor(e,t){super(["AcDbEntity","AcDbPoint"]),this.x=e,this.y=t}tags(e){e.push(0,"POINT"),super.tags(e),e.push(8,this.layer.name),e.point(this.x,this.y)}};const En=Tt;var wn=class Spline extends En{constructor(e,t=3,n=null,i=null,r=[]){if(super(["AcDbEntity","AcDbSpline"]),e.length<t+1)throw new Error(`For degree ${t} spline, expected at least ${t+1} control points, but received only ${e.length}`);if(null==n){n=[];for(let e=0;e<t+1;e++)n.push(0);for(let i=1;i<e.length-t;i++)n.push(i);for(let i=0;i<t+1;i++)n.push(e.length-t)}if(n.length!==e.length+t+1)throw new Error(`Invalid knot vector length. Expected ${e.length+t+1} but received ${n.length}.`);this.controlPoints=e,this.knots=n,this.fitPoints=r,this.degree=t,this.weights=i;const s=this.weights?1:0;this.type=0+4*s+8+0}tags(e){e.push(0,"SPLINE"),super.tags(e),e.push(8,this.layer.name),e.push(210,0),e.push(220,0),e.push(230,1),e.push(70,this.type),e.push(71,this.degree),e.push(72,this.knots.length),e.push(73,this.controlPoints.length),e.push(74,this.fitPoints.length),e.push(42,1e-7),e.push(43,1e-7),e.push(44,1e-10),this.knots.forEach((t=>{e.push(40,t)})),this.weights&&this.weights.forEach((t=>{e.push(41,t)})),this.controlPoints.forEach((t=>{e.point(t[0],t[1])}))}};const vn=Tt;var Qn=class Ellipse extends vn{constructor(e,t,n,i,r,s,o){super(["AcDbEntity","AcDbEllipse"]),this.x=e,this.y=t,this.majorAxisX=n,this.majorAxisY=i,this.axisRatio=r,this.startAngle=s,this.endAngle=o}tags(e){e.push(0,"ELLIPSE"),super.tags(e),e.push(8,this.layer.name),e.point(this.x,this.y),e.push(11,this.majorAxisX),e.push(21,this.majorAxisY),e.push(31,0),e.push(40,this.axisRatio),e.push(41,this.startAngle),e.push(42,this.endAngle)}};var Pn=class TagsManager{constructor(){this.lines=[]}point(e,t,n=0){this.push(10,e),this.push(20,t),this.push(30,n)}start(e){this.push(0,"SECTION"),this.push(2,e)}end(){this.push(0,"ENDSEC")}addHeaderVariable(e,t){this.push(9,`$${e}`),t.forEach((e=>{this.push(e[0],e[1])}))}push(e,t){this.lines.push(e,t)}toDxfString(){return this.lines.join("\n")}};const Tn=Mt,Sn=Lt,Mn=Ft,Dn=Nt,Ln=Gt,_n=Yt,Fn=Ht,kn=qt,Rn=Wt,Nn=Vt,On=Zt,Gn=en,Un=nn,Yn=sn,zn=an,Hn=pn,Xn=un,qn=bn,jn=xn,Wn=Bn,Jn=wn,Vn=Qn,Kn=Pn,Zn=Qt;class Drawing{constructor(){this.layers={},this.activeLayer=null,this.lineTypes={},this.headers={},this.tables={},this.blocks={},this.dictionary=new Nn,this.setUnits("Unitless");for(const e of Drawing.LINE_TYPES)this.addLineType(e.name,e.description,e.elements);for(const e of Drawing.LAYERS)this.addLayer(e.name,e.colorNumber,e.lineTypeName);this.setActiveLayer("0"),this.generateAutocadExtras()}addLineType(e,t,n){return this.lineTypes[e]=new Tn(e,t,n),this}addLayer(e,t,n){return this.layers[e]=new Sn(e,t,n),this}setActiveLayer(e){return this.activeLayer=this.layers[e],this}addTable(e){const t=new Mn(e);return this.tables[e]=t,t}addBlock(e){const t=new kn(e);return this.blocks[e]=t,t}drawLine(e,t,n,i){return this.activeLayer.addShape(new On(e,t,n,i)),this}drawLine3d(e,t,n,i,r,s){return this.activeLayer.addShape(new Gn(e,t,n,i,r,s)),this}drawPoint(e,t){return this.activeLayer.addShape(new Wn(e,t)),this}drawRect(e,t,n,i,r,s){const o=n-e,a=i-t;s=s||0;let A=null;return A=new Xn(r?[[e+o-r,t,s],[e+o,t+r],[e+o,t+a-r,s],[e+o-r,t+a],[e+r,t+a,s],[e,t+a-r],[e,t+r,s],[e+r,t]]:[[e,t],[e,t+a],[e+o,t+a],[e+o,t]],!0),this.activeLayer.addShape(A),this}drawPolygon(e,t,n,i,r=0,s=!1){const o=2*Math.PI/n,a=[];let A=i;const l=r*Math.PI/180;s&&(A=i/Math.cos(Math.PI/n));for(let i=0;i<n;i++)a.push([e+A*Math.sin(l+i*o),t+A*Math.cos(l+i*o)]);return this.activeLayer.addShape(new Xn(a,!0)),this}drawArc(e,t,n,i,r){return this.activeLayer.addShape(new Un(e,t,n,i,r)),this}drawCircle(e,t,n){return this.activeLayer.addShape(new Yn(e,t,n)),this}drawCylinder(e,t,n,i,r,s,o,a){return this.activeLayer.addShape(new zn(e,t,n,i,r,s,o,a)),this}drawText(e,t,n,i,r,s="left",o="baseline"){return this.activeLayer.addShape(new Hn(e,t,n,i,r,s,o)),this}drawPolyline(e,t=!1,n=0,i=0){return this.activeLayer.addShape(new Xn(e,t,n,i)),this}drawPolyline3d(e){return e.forEach((e=>{if(3!==e.length)throw"Require 3D coordinates"})),this.activeLayer.addShape(new qn(e)),this}setTrueColor(e){return this.activeLayer.setTrueColor(e),this}drawSpline(e,t=3,n=null,i=null,r=[]){return this.activeLayer.addShape(new Jn(e,t,n,i,r)),this}drawEllipse(e,t,n,i,r,s=0,o=2*Math.PI){return this.activeLayer.addShape(new Vn(e,t,n,i,r,s,o)),this}drawFace(e,t,n,i,r,s,o,a,A,l,c,p){return this.activeLayer.addShape(new jn(e,t,n,i,r,s,o,a,A,l,c,p)),this}_ltypeTable(){const e=new Mn("LTYPE"),t=Object.values(this.lineTypes);for(const n of t)e.add(n);return e}_layerTable(e){const t=new Mn("LAYER"),n=Object.values(this.layers);for(const e of n)t.add(e);return t}header(e,t){return this.headers[e]=t,this}setUnits(e){return void 0!==Drawing.UNITS[e]?Drawing.UNITS[e]:Drawing.UNITS.Unitless,this.header("INSUNITS",[[70,Drawing.UNITS[e]]]),this}generateAutocadExtras(){this.headers.ACADVER||this.header("ACADVER",[[1,"AC1021"]]),this.lineTypes.ByBlock||this.addLineType("ByBlock","",[]),this.lineTypes.ByLayer||this.addLineType("ByLayer","",[]);let e=this.tables.VPORT;e||(e=this.addTable("VPORT"));let t=this.tables.STYLE;t||(t=this.addTable("STYLE")),this.tables.VIEW||this.addTable("VIEW"),this.tables.UCS||this.addTable("UCS");let n=this.tables.APPID;if(n||(n=this.addTable("APPID")),!this.tables.DIMSTYLE){const e=new Dn("DIMSTYLE");this.tables.DIMSTYLE=e}e.add(new _n("*ACTIVE",1e3)),t.add(new Ln("standard")),n.add(new Fn("ACAD")),this.modelSpace=this.addBlock("*Model_Space"),this.addBlock("*Paper_Space");const i=new Nn;this.dictionary.addChildDictionary("ACAD_GROUP",i)}_tagsManager(){const e=new Kn,t=new Mn("BLOCK_RECORD"),n=Object.values(this.blocks);for(const e of n){const n=new Rn(e.name);t.add(n)}const i=this._ltypeTable(),r=this._layerTable();e.start("HEADER"),e.addHeaderVariable("HANDSEED",[[5,Zn.peek()]]);const s=Object.entries(this.headers);for(const t of s){const[n,i]=t;e.addHeaderVariable(n,i)}e.end(),e.start("CLASSES"),e.end(),e.start("TABLES"),i.tags(e),r.tags(e);const o=Object.values(this.tables);for(const t of o)t.tags(e);t.tags(e),e.end(),e.start("BLOCKS");for(const t of n)t.tags(e);e.end(),e.start("ENTITIES");const a=Object.values(this.layers);for(const t of a)t.shapesTags(this.modelSpace,e);return e.end(),e.start("OBJECTS"),this.dictionary.tags(e),e.end(),e.push(0,"EOF"),e}toDxfString(){return this._tagsManager().toDxfString()}}Drawing.ACI={LAYER:0,RED:1,YELLOW:2,GREEN:3,CYAN:4,BLUE:5,MAGENTA:6,WHITE:7},Drawing.LINE_TYPES=[{name:"CONTINUOUS",description:"______",elements:[]},{name:"DASHED",description:"_ _ _ ",elements:[5,-5]},{name:"DOTTED",description:". . . ",elements:[0,-5]}],Drawing.LAYERS=[{name:"0",colorNumber:Drawing.ACI.WHITE,lineTypeName:"CONTINUOUS"}],Drawing.UNITS={Unitless:0,Inches:1,Feet:2,Miles:3,Millimeters:4,Centimeters:5,Meters:6,Kilometers:7,Microinches:8,Mils:9,Yards:10,Angstroms:11,Nanometers:12,Microns:13,Decimeters:14,Decameters:15,Hectometers:16,Gigameters:17,"Astronomical units":18,"Light years":19,Parsecs:20};var $n=getDefaultExportFromCjs(Drawing);const ei={black:[0,0,0],white:[255,255,255],red:[255,0,0],green:[0,255,0],blue:[0,0,255],yellow:[255,255,0],cyan:[0,255,255],magenta:[255,0,255],gray:[128,128,128],grey:[128,128,128]},ti={};function col2aci(e){if(!e)return 0;if("number"==typeof e)return e;const t=e.trim().toLowerCase();if(ti[t])return ti[t];if(ei[t]){const[e,n,i]=ei[t];return ti[t]=rgb2aci(e,n,i)}if(t.startsWith("#")){let e=t;4===e.length&&(e="#"+e[1]+e[1]+e[2]+e[2]+e[3]+e[3]);const n=parseInt(e.slice(1,3),16),i=parseInt(e.slice(3,5),16),r=parseInt(e.slice(5,7),16);return ti[t]=rgb2aci(n,i,r)}if(t.startsWith("rgb")){const e=t.match(/\d+/g).map(Number);return ti[t]=rgb2aci(e[0],e[1],e[2])}return ti[t]=0}function rgb2aci(e,t,n){return Math.abs(e-t)<10&&Math.abs(t-n)<10?8:e>t&&e>n?1:t>e&&t>n?3:n>e&&n>t?5:e>200&&t>200?2:t>200&&n>200?4:e>200&&n>200?6:7}function exportdxf(e){const t=new $n,n=new Matrix3D;for(const i of e.vec)switch(i.type){case"push":n.push(),(i.x||i.y)&&n.translate(i.x||0,i.y||0,0),i.rot&&n.rotateZ(i.rot);break;case"pop":n.pop();break;case"offset":n.translate(i.x||0,i.y||0,0);break;case"point":{const e=n.transform(i.p.x,i.p.y,0),r=col2aci(i.color);t.setActiveLayer("0",r),t.drawPoint(e.x,e.y),i.id&&t.drawText(e.x+2,e.y+2,6,0,i.id);break}case"line":{const e=n.transform(i.l.p1.x,i.l.p1.y,0),r=n.transform(i.l.p2.x,i.l.p2.y,0),s=col2aci(i.color);if(t.setActiveLayer("0",s),t.drawLine(e.x,e.y,r.x,r.y),i.id){const n=(e.x+r.x)/2,s=(e.y+r.y)/2;t.drawText(n,s,6,0,i.id)}break}case"rect":case"recta":{const e=n.transform(i.l.p1.x,i.l.p1.y,0),r=n.transform(i.l.p2.x,i.l.p2.y,0),s=col2aci(i.color);t.setActiveLayer("0",s);const o="recta"===i.type;t.drawPolyline([[e.x,e.y],[r.x,e.y],[r.x,r.y],[e.x,r.y]],o);break}case"shape":case"shapelin":case"area":{if(!i.s?.length)break;const e=i.s.map((e=>{const t=n.transform(e.x,e.y,0);return[t.x,t.y]})),r="shapelin"!==i.type,s=col2aci(i.color);t.setActiveLayer("0",s),t.drawPolyline(e,r);break}case"text":{const e=col2aci(i.color);t.setActiveLayer("0",e);const r=n.transform(i.x||0,i.y||0,0),s=6*(i.scalafont||1);t.drawText(r.x,r.y,s,0,i.text);break}}return t.toDxfString()}s.line={worldUnits:{value:1},linewidth:{value:1},resolution:{value:new r(1,1)},dashOffset:{value:0},dashScale:{value:1},dashSize:{value:1},gapSize:{value:1}},n.line={uniforms:i.merge([s.common,s.fog,s.line]),vertexShader:"\n\t\t#include <common>\n\t\t#include <color_pars_vertex>\n\t\t#include <fog_pars_vertex>\n\t\t#include <logdepthbuf_pars_vertex>\n\t\t#include <clipping_planes_pars_vertex>\n\n\t\tuniform float linewidth;\n\t\tuniform vec2 resolution;\n\n\t\tattribute vec3 instanceStart;\n\t\tattribute vec3 instanceEnd;\n\n\t\tattribute vec3 instanceColorStart;\n\t\tattribute vec3 instanceColorEnd;\n\n\t\t#ifdef WORLD_UNITS\n\n\t\t\tvarying vec4 worldPos;\n\t\t\tvarying vec3 worldStart;\n\t\t\tvarying vec3 worldEnd;\n\n\t\t\t#ifdef USE_DASH\n\n\t\t\t\tvarying vec2 vUv;\n\n\t\t\t#endif\n\n\t\t#else\n\n\t\t\tvarying vec2 vUv;\n\n\t\t#endif\n\n\t\t#ifdef USE_DASH\n\n\t\t\tuniform float dashScale;\n\t\t\tattribute float instanceDistanceStart;\n\t\t\tattribute float instanceDistanceEnd;\n\t\t\tvarying float vLineDistance;\n\n\t\t#endif\n\n\t\tvoid trimSegment( const in vec4 start, inout vec4 end ) {\n\n\t\t\t// trim end segment so it terminates between the camera plane and the near plane\n\n\t\t\t// conservative estimate of the near plane\n\t\t\tfloat a = projectionMatrix[ 2 ][ 2 ]; // 3nd entry in 3th column\n\t\t\tfloat b = projectionMatrix[ 3 ][ 2 ]; // 3nd entry in 4th column\n\t\t\tfloat nearEstimate = - 0.5 * b / a;\n\n\t\t\tfloat alpha = ( nearEstimate - start.z ) / ( end.z - start.z );\n\n\t\t\tend.xyz = mix( start.xyz, end.xyz, alpha );\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\t#ifdef USE_COLOR\n\n\t\t\t\tvColor.xyz = ( position.y < 0.5 ) ? instanceColorStart : instanceColorEnd;\n\n\t\t\t#endif\n\n\t\t\t#ifdef USE_DASH\n\n\t\t\t\tvLineDistance = ( position.y < 0.5 ) ? dashScale * instanceDistanceStart : dashScale * instanceDistanceEnd;\n\t\t\t\tvUv = uv;\n\n\t\t\t#endif\n\n\t\t\tfloat aspect = resolution.x / resolution.y;\n\n\t\t\t// camera space\n\t\t\tvec4 start = modelViewMatrix * vec4( instanceStart, 1.0 );\n\t\t\tvec4 end = modelViewMatrix * vec4( instanceEnd, 1.0 );\n\n\t\t\t#ifdef WORLD_UNITS\n\n\t\t\t\tworldStart = start.xyz;\n\t\t\t\tworldEnd = end.xyz;\n\n\t\t\t#else\n\n\t\t\t\tvUv = uv;\n\n\t\t\t#endif\n\n\t\t\t// special case for perspective projection, and segments that terminate either in, or behind, the camera plane\n\t\t\t// clearly the gpu firmware has a way of addressing this issue when projecting into ndc space\n\t\t\t// but we need to perform ndc-space calculations in the shader, so we must address this issue directly\n\t\t\t// perhaps there is a more elegant solution -- WestLangley\n\n\t\t\tbool perspective = ( projectionMatrix[ 2 ][ 3 ] == - 1.0 ); // 4th entry in the 3rd column\n\n\t\t\tif ( perspective ) {\n\n\t\t\t\tif ( start.z < 0.0 && end.z >= 0.0 ) {\n\n\t\t\t\t\ttrimSegment( start, end );\n\n\t\t\t\t} else if ( end.z < 0.0 && start.z >= 0.0 ) {\n\n\t\t\t\t\ttrimSegment( end, start );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\t// clip space\n\t\t\tvec4 clipStart = projectionMatrix * start;\n\t\t\tvec4 clipEnd = projectionMatrix * end;\n\n\t\t\t// ndc space\n\t\t\tvec3 ndcStart = clipStart.xyz / clipStart.w;\n\t\t\tvec3 ndcEnd = clipEnd.xyz / clipEnd.w;\n\n\t\t\t// direction\n\t\t\tvec2 dir = ndcEnd.xy - ndcStart.xy;\n\n\t\t\t// account for clip-space aspect ratio\n\t\t\tdir.x *= aspect;\n\t\t\tdir = normalize( dir );\n\n\t\t\t#ifdef WORLD_UNITS\n\n\t\t\t\tvec3 worldDir = normalize( end.xyz - start.xyz );\n\t\t\t\tvec3 tmpFwd = normalize( mix( start.xyz, end.xyz, 0.5 ) );\n\t\t\t\tvec3 worldUp = normalize( cross( worldDir, tmpFwd ) );\n\t\t\t\tvec3 worldFwd = cross( worldDir, worldUp );\n\t\t\t\tworldPos = position.y < 0.5 ? start: end;\n\n\t\t\t\t// height offset\n\t\t\t\tfloat hw = linewidth * 0.5;\n\t\t\t\tworldPos.xyz += position.x < 0.0 ? hw * worldUp : - hw * worldUp;\n\n\t\t\t\t// don't extend the line if we're rendering dashes because we\n\t\t\t\t// won't be rendering the endcaps\n\t\t\t\t#ifndef USE_DASH\n\n\t\t\t\t\t// cap extension\n\t\t\t\t\tworldPos.xyz += position.y < 0.5 ? - hw * worldDir : hw * worldDir;\n\n\t\t\t\t\t// add width to the box\n\t\t\t\t\tworldPos.xyz += worldFwd * hw;\n\n\t\t\t\t\t// endcaps\n\t\t\t\t\tif ( position.y > 1.0 || position.y < 0.0 ) {\n\n\t\t\t\t\t\tworldPos.xyz -= worldFwd * 2.0 * hw;\n\n\t\t\t\t\t}\n\n\t\t\t\t#endif\n\n\t\t\t\t// project the worldpos\n\t\t\t\tvec4 clip = projectionMatrix * worldPos;\n\n\t\t\t\t// shift the depth of the projected points so the line\n\t\t\t\t// segments overlap neatly\n\t\t\t\tvec3 clipPose = ( position.y < 0.5 ) ? ndcStart : ndcEnd;\n\t\t\t\tclip.z = clipPose.z * clip.w;\n\n\t\t\t#else\n\n\t\t\t\tvec2 offset = vec2( dir.y, - dir.x );\n\t\t\t\t// undo aspect ratio adjustment\n\t\t\t\tdir.x /= aspect;\n\t\t\t\toffset.x /= aspect;\n\n\t\t\t\t// sign flip\n\t\t\t\tif ( position.x < 0.0 ) offset *= - 1.0;\n\n\t\t\t\t// endcaps\n\t\t\t\tif ( position.y < 0.0 ) {\n\n\t\t\t\t\toffset += - dir;\n\n\t\t\t\t} else if ( position.y > 1.0 ) {\n\n\t\t\t\t\toffset += dir;\n\n\t\t\t\t}\n\n\t\t\t\t// adjust for linewidth\n\t\t\t\toffset *= linewidth;\n\n\t\t\t\t// adjust for clip-space to screen-space conversion // maybe resolution should be based on viewport ...\n\t\t\t\toffset /= resolution.y;\n\n\t\t\t\t// select end\n\t\t\t\tvec4 clip = ( position.y < 0.5 ) ? clipStart : clipEnd;\n\n\t\t\t\t// back to clip space\n\t\t\t\toffset *= clip.w;\n\n\t\t\t\tclip.xy += offset;\n\n\t\t\t#endif\n\n\t\t\tgl_Position = clip;\n\n\t\t\tvec4 mvPosition = ( position.y < 0.5 ) ? start : end; // this is an approximation\n\n\t\t\t#include <logdepthbuf_vertex>\n\t\t\t#include <clipping_planes_vertex>\n\t\t\t#include <fog_vertex>\n\n\t\t}\n\t\t",fragmentShader:"\n\t\tuniform vec3 diffuse;\n\t\tuniform float opacity;\n\t\tuniform float linewidth;\n\n\t\t#ifdef USE_DASH\n\n\t\t\tuniform float dashOffset;\n\t\t\tuniform float dashSize;\n\t\t\tuniform float gapSize;\n\n\t\t#endif\n\n\t\tvarying float vLineDistance;\n\n\t\t#ifdef WORLD_UNITS\n\n\t\t\tvarying vec4 worldPos;\n\t\t\tvarying vec3 worldStart;\n\t\t\tvarying vec3 worldEnd;\n\n\t\t\t#ifdef USE_DASH\n\n\t\t\t\tvarying vec2 vUv;\n\n\t\t\t#endif\n\n\t\t#else\n\n\t\t\tvarying vec2 vUv;\n\n\t\t#endif\n\n\t\t#include <common>\n\t\t#include <color_pars_fragment>\n\t\t#include <fog_pars_fragment>\n\t\t#include <logdepthbuf_pars_fragment>\n\t\t#include <clipping_planes_pars_fragment>\n\n\t\tvec2 closestLineToLine(vec3 p1, vec3 p2, vec3 p3, vec3 p4) {\n\n\t\t\tfloat mua;\n\t\t\tfloat mub;\n\n\t\t\tvec3 p13 = p1 - p3;\n\t\t\tvec3 p43 = p4 - p3;\n\n\t\t\tvec3 p21 = p2 - p1;\n\n\t\t\tfloat d1343 = dot( p13, p43 );\n\t\t\tfloat d4321 = dot( p43, p21 );\n\t\t\tfloat d1321 = dot( p13, p21 );\n\t\t\tfloat d4343 = dot( p43, p43 );\n\t\t\tfloat d2121 = dot( p21, p21 );\n\n\t\t\tfloat denom = d2121 * d4343 - d4321 * d4321;\n\n\t\t\tfloat numer = d1343 * d4321 - d1321 * d4343;\n\n\t\t\tmua = numer / denom;\n\t\t\tmua = clamp( mua, 0.0, 1.0 );\n\t\t\tmub = ( d1343 + d4321 * ( mua ) ) / d4343;\n\t\t\tmub = clamp( mub, 0.0, 1.0 );\n\n\t\t\treturn vec2( mua, mub );\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tfloat alpha = opacity;\n\t\t\tvec4 diffuseColor = vec4( diffuse, alpha );\n\n\t\t\t#include <clipping_planes_fragment>\n\n\t\t\t#ifdef USE_DASH\n\n\t\t\t\tif ( vUv.y < - 1.0 || vUv.y > 1.0 ) discard; // discard endcaps\n\n\t\t\t\tif ( mod( vLineDistance + dashOffset, dashSize + gapSize ) > dashSize ) discard; // todo - FIX\n\n\t\t\t#endif\n\n\t\t\t#ifdef WORLD_UNITS\n\n\t\t\t\t// Find the closest points on the view ray and the line segment\n\t\t\t\tvec3 rayEnd = normalize( worldPos.xyz ) * 1e5;\n\t\t\t\tvec3 lineDir = worldEnd - worldStart;\n\t\t\t\tvec2 params = closestLineToLine( worldStart, worldEnd, vec3( 0.0, 0.0, 0.0 ), rayEnd );\n\n\t\t\t\tvec3 p1 = worldStart + lineDir * params.x;\n\t\t\t\tvec3 p2 = rayEnd * params.y;\n\t\t\t\tvec3 delta = p1 - p2;\n\t\t\t\tfloat len = length( delta );\n\t\t\t\tfloat norm = len / linewidth;\n\n\t\t\t\t#ifndef USE_DASH\n\n\t\t\t\t\t#ifdef USE_ALPHA_TO_COVERAGE\n\n\t\t\t\t\t\tfloat dnorm = fwidth( norm );\n\t\t\t\t\t\talpha = 1.0 - smoothstep( 0.5 - dnorm, 0.5 + dnorm, norm );\n\n\t\t\t\t\t#else\n\n\t\t\t\t\t\tif ( norm > 0.5 ) {\n\n\t\t\t\t\t\t\tdiscard;\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t#endif\n\n\t\t\t\t#endif\n\n\t\t\t#else\n\n\t\t\t\t#ifdef USE_ALPHA_TO_COVERAGE\n\n\t\t\t\t\t// artifacts appear on some hardware if a derivative is taken within a conditional\n\t\t\t\t\tfloat a = vUv.x;\n\t\t\t\t\tfloat b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;\n\t\t\t\t\tfloat len2 = a * a + b * b;\n\t\t\t\t\tfloat dlen = fwidth( len2 );\n\n\t\t\t\t\tif ( abs( vUv.y ) > 1.0 ) {\n\n\t\t\t\t\t\talpha = 1.0 - smoothstep( 1.0 - dlen, 1.0 + dlen, len2 );\n\n\t\t\t\t\t}\n\n\t\t\t\t#else\n\n\t\t\t\t\tif ( abs( vUv.y ) > 1.0 ) {\n\n\t\t\t\t\t\tfloat a = vUv.x;\n\t\t\t\t\t\tfloat b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;\n\t\t\t\t\t\tfloat len2 = a * a + b * b;\n\n\t\t\t\t\t\tif ( len2 > 1.0 ) discard;\n\n\t\t\t\t\t}\n\n\t\t\t\t#endif\n\n\t\t\t#endif\n\n\t\t\t#include <logdepthbuf_fragment>\n\t\t\t#include <color_fragment>\n\n\t\t\tgl_FragColor = vec4( diffuseColor.rgb, alpha );\n\n\t\t\t#include <tonemapping_fragment>\n\t\t\t#include <colorspace_fragment>\n\t\t\t#include <fog_fragment>\n\t\t\t#include <premultiplied_alpha_fragment>\n\n\t\t}\n\t\t"};class LineMaterial extends t{constructor(e){super({type:"LineMaterial",uniforms:i.clone(n.line.uniforms),vertexShader:n.line.vertexShader,fragmentShader:n.line.fragmentShader,clipping:!0}),this.isLineMaterial=!0,this.setValues(e)}get color(){return this.uniforms.diffuse.value}set color(e){this.uniforms.diffuse.value=e}get worldUnits(){return"WORLD_UNITS"in this.defines}set worldUnits(e){!0===e?this.defines.WORLD_UNITS="":delete this.defines.WORLD_UNITS}get linewidth(){return this.uniforms.linewidth.value}set linewidth(e){this.uniforms.linewidth&&(this.uniforms.linewidth.value=e)}get dashed(){return"USE_DASH"in this.defines}set dashed(e){!0===e!==this.dashed&&(this.needsUpdate=!0),!0===e?this.defines.USE_DASH="":delete this.defines.USE_DASH}get dashScale(){return this.uniforms.dashScale.value}set dashScale(e){this.uniforms.dashScale.value=e}get dashSize(){return this.uniforms.dashSize.value}set dashSize(e){this.uniforms.dashSize.value=e}get dashOffset(){return this.uniforms.dashOffset.value}set dashOffset(e){this.uniforms.dashOffset.value=e}get gapSize(){return this.uniforms.gapSize.value}set gapSize(e){this.uniforms.gapSize.value=e}get opacity(){return this.uniforms.opacity.value}set opacity(e){this.uniforms&&(this.uniforms.opacity.value=e)}get resolution(){return this.uniforms.resolution.value}set resolution(e){this.uniforms.resolution.value.copy(e)}get alphaToCoverage(){return"USE_ALPHA_TO_COVERAGE"in this.defines}set alphaToCoverage(e){this.defines&&(!0===e!==this.alphaToCoverage&&(this.needsUpdate=!0),!0===e?this.defines.USE_ALPHA_TO_COVERAGE="":delete this.defines.USE_ALPHA_TO_COVERAGE)}}const ni=new p,ii=new u;class LineSegmentsGeometry extends o{constructor(){super(),this.isLineSegmentsGeometry=!0,this.type="LineSegmentsGeometry";this.setIndex([0,2,1,2,3,1,2,4,3,4,5,3,4,6,5,6,7,5]),this.setAttribute("position",new a([-1,2,0,1,2,0,-1,1,0,1,1,0,-1,0,0,1,0,0,-1,-1,0,1,-1,0],3)),this.setAttribute("uv",new a([-1,2,1,2,-1,1,1,1,-1,-1,1,-1,-1,-2,1,-2],2))}applyMatrix4(e){const t=this.attributes.instanceStart,n=this.attributes.instanceEnd;return void 0!==t&&(t.applyMatrix4(e),n.applyMatrix4(e),t.needsUpdate=!0),null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this}setPositions(e){let t;e instanceof Float32Array?t=e:Array.isArray(e)&&(t=new Float32Array(e));const n=new A(t,6,1);return this.setAttribute("instanceStart",new l(n,3,0)),this.setAttribute("instanceEnd",new l(n,3,3)),this.instanceCount=this.attributes.instanceStart.count,this.computeBoundingBox(),this.computeBoundingSphere(),this}setColors(e){let t;e instanceof Float32Array?t=e:Array.isArray(e)&&(t=new Float32Array(e));const n=new A(t,6,1);return this.setAttribute("instanceColorStart",new l(n,3,0)),this.setAttribute("instanceColorEnd",new l(n,3,3)),this}fromWireframeGeometry(e){return this.setPositions(e.attributes.position.array),this}fromEdgesGeometry(e){return this.setPositions(e.attributes.position.array),this}fromMesh(e){return this.fromWireframeGeometry(new c(e.geometry)),this}fromLineSegments(e){const t=e.geometry;return this.setPositions(t.attributes.position.array),this}computeBoundingBox(){null===this.boundingBox&&(this.boundingBox=new p);const e=this.attributes.instanceStart,t=this.attributes.instanceEnd;void 0!==e&&void 0!==t&&(this.boundingBox.setFromBufferAttribute(e),ni.setFromBufferAttribute(t),this.boundingBox.union(ni))}computeBoundingSphere(){null===this.boundingSphere&&(this.boundingSphere=new h),null===this.boundingBox&&this.computeBoundingBox();const e=this.attributes.instanceStart,t=this.attributes.instanceEnd;if(void 0!==e&&void 0!==t){const n=this.boundingSphere.center;this.boundingBox.getCenter(n);let i=0;for(let r=0,s=e.count;r<s;r++)ii.fromBufferAttribute(e,r),i=Math.max(i,n.distanceToSquared(ii)),ii.fromBufferAttribute(t,r),i=Math.max(i,n.distanceToSquared(ii));this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&console.error("THREE.LineSegmentsGeometry.computeBoundingSphere(): Computed radius is NaN. The instanced position data is likely to have NaN values.",this)}}toJSON(){}}const ri=new g,si=new u,oi=new u,ai=new g,Ai=new g,li=new g,ci=new u,pi=new m,hi=new f,ui=new u,di=new p,gi=new h,fi=new g;let mi,yi;function getWorldSpaceHalfWidth(e,t,n){return fi.set(0,0,-t,1).applyMatrix4(e.projectionMatrix),fi.multiplyScalar(1/fi.w),fi.x=yi/n.width,fi.y=yi/n.height,fi.applyMatrix4(e.projectionMatrixInverse),fi.multiplyScalar(1/fi.w),Math.abs(Math.max(fi.x,fi.y))}class LineSegments2 extends d{constructor(e=new LineSegmentsGeometry,t=new LineMaterial({color:16777215*Math.random()})){super(e,t),this.isLineSegments2=!0,this.type="LineSegments2"}computeLineDistances(){const e=this.geometry,t=e.attributes.instanceStart,n=e.attributes.instanceEnd,i=new Float32Array(2*t.count);for(let e=0,r=0,s=t.count;e<s;e++,r+=2)si.fromBufferAttribute(t,e),oi.fromBufferAttribute(n,e),i[r]=0===r?0:i[r-1],i[r+1]=i[r]+si.distanceTo(oi);const r=new A(i,2,1);return e.setAttribute("instanceDistanceStart",new l(r,1,0)),e.setAttribute("instanceDistanceEnd",new l(r,1,1)),this}raycast(e,t){const n=this.material.worldUnits,i=e.camera;null!==i||n||console.error('LineSegments2: "Raycaster.camera" needs to be set in order to raycast against LineSegments2 while worldUnits is set to false.');const r=void 0!==e.params.Line2&&e.params.Line2.threshold||0;mi=e.ray;const s=this.matrixWorld,o=this.geometry,a=this.material;let A,l;if(yi=a.linewidth+r,null===o.boundingSphere&&o.computeBoundingSphere(),gi.copy(o.boundingSphere).applyMatrix4(s),n)A=.5*yi;else{A=getWorldSpaceHalfWidth(i,Math.max(i.near,gi.distanceToPoint(mi.origin)),a.resolution)}if(gi.radius+=A,!1!==mi.intersectsSphere(gi)){if(null===o.boundingBox&&o.computeBoundingBox(),di.copy(o.boundingBox).applyMatrix4(s),n)l=.5*yi;else{l=getWorldSpaceHalfWidth(i,Math.max(i.near,di.distanceToPoint(mi.origin)),a.resolution)}di.expandByScalar(l),!1!==mi.intersectsBox(di)&&(n?function raycastWorldUnits(e,t){const n=e.matrixWorld,i=e.geometry,r=i.attributes.instanceStart,s=i.attributes.instanceEnd;for(let o=0,a=Math.min(i.instanceCount,r.count);o<a;o++){hi.start.fromBufferAttribute(r,o),hi.end.fromBufferAttribute(s,o),hi.applyMatrix4(n);const i=new u,a=new u;mi.distanceSqToSegment(hi.start,hi.end,a,i),a.distanceTo(i)<.5*yi&&t.push({point:a,pointOnLine:i,distance:mi.origin.distanceTo(a),object:e,face:null,faceIndex:o,uv:null,uv1:null})}}(this,t):function raycastScreenSpace(e,t,n){const i=t.projectionMatrix,r=e.material.resolution,s=e.matrixWorld,o=e.geometry,a=o.attributes.instanceStart,A=o.attributes.instanceEnd,l=Math.min(o.instanceCount,a.count),c=-t.near;mi.at(1,li),li.w=1,li.applyMatrix4(t.matrixWorldInverse),li.applyMatrix4(i),li.multiplyScalar(1/li.w),li.x*=r.x/2,li.y*=r.y/2,li.z=0,ci.copy(li),pi.multiplyMatrices(t.matrixWorldInverse,s);for(let t=0,o=l;t<o;t++){if(ai.fromBufferAttribute(a,t),Ai.fromBufferAttribute(A,t),ai.w=1,Ai.w=1,ai.applyMatrix4(pi),Ai.applyMatrix4(pi),ai.z>c&&Ai.z>c)continue;if(ai.z>c){const e=ai.z-Ai.z,t=(ai.z-c)/e;ai.lerp(Ai,t)}else if(Ai.z>c){const e=Ai.z-ai.z,t=(Ai.z-c)/e;Ai.lerp(ai,t)}ai.applyMatrix4(i),Ai.applyMatrix4(i),ai.multiplyScalar(1/ai.w),Ai.multiplyScalar(1/Ai.w),ai.x*=r.x/2,ai.y*=r.y/2,Ai.x*=r.x/2,Ai.y*=r.y/2,hi.start.copy(ai),hi.start.z=0,hi.end.copy(Ai),hi.end.z=0;const o=hi.closestPointToPointParameter(ci,!0);hi.at(o,ui);const l=y.lerp(ai.z,Ai.z,o),p=l>=-1&&l<=1,h=ci.distanceTo(ui)<.5*yi;if(p&&h){hi.start.fromBufferAttribute(a,t),hi.end.fromBufferAttribute(A,t),hi.start.applyMatrix4(s),hi.end.applyMatrix4(s);const i=new u,r=new u;mi.distanceSqToSegment(hi.start,hi.end,r,i),n.push({point:r,pointOnLine:i,distance:mi.origin.distanceTo(r),object:e,face:null,faceIndex:t,uv:null,uv1:null})}}}(this,i,t))}}onBeforeRender(e){const t=this.material.uniforms;t&&t.resolution&&(e.getViewport(ri),this.material.uniforms.resolution.value.set(ri.z,ri.w))}}class LineGeometry extends LineSegmentsGeometry{constructor(){super(),this.isLineGeometry=!0,this.type="LineGeometry"}setPositions(e){const t=e.length-3,n=new Float32Array(2*t);for(let i=0;i<t;i+=3)n[2*i]=e[i],n[2*i+1]=e[i+1],n[2*i+2]=e[i+2],n[2*i+3]=e[i+3],n[2*i+4]=e[i+4],n[2*i+5]=e[i+5];return super.setPositions(n),this}setColors(e){const t=e.length-3,n=new Float32Array(2*t);for(let i=0;i<t;i+=3)n[2*i]=e[i],n[2*i+1]=e[i+1],n[2*i+2]=e[i+2],n[2*i+3]=e[i+3],n[2*i+4]=e[i+4],n[2*i+5]=e[i+5];return super.setColors(n),this}setFromPoints(e){const t=e.length-1,n=new Float32Array(6*t);for(let i=0;i<t;i++)n[6*i]=e[i].x,n[6*i+1]=e[i].y,n[6*i+2]=e[i].z||0,n[6*i+3]=e[i+1].x,n[6*i+4]=e[i+1].y,n[6*i+5]=e[i+1].z||0;return super.setPositions(n),this}fromLine(e){const t=e.geometry;return this.setPositions(t.attributes.position.array),this}}class Line2 extends LineSegments2{constructor(e=new LineGeometry,t=new LineMaterial({color:16777215*Math.random()})){super(e,t),this.isLine2=!0,this.type="Line2"}}const bi=new e.MeshStandardMaterial({color:36864,roughness:.5,metalness:.4,side:e.DoubleSide});function getorientate(e,t,n,i){switch(t=t||0,n=n||0,i=i||0,e.trim().toLowerCase()){case"alp":return{x:n,y:t,z:i};case"apl":return{x:n,y:i,z:t};case"pla":return{x:i,y:t,z:n};case"pal":return{x:i,y:n,z:t};case"lpa":return{x:t,y:i,z:n};default:return{x:t,y:n,z:i}}}const Ii={lpa:"sdbarf",lap:"sdrfba",pal:"rfsdba",pla:"rfbasd",apl:"basdrf",alp:"barfsd"};function parselavs(e,t,n=0,i=0,r=0,s="",o="",a=""){let A=muClComments(s);e=e.trim().toLowerCase();let l=[];for(let s of A){let a=/^([({}):$\w.\\/]+)[\s;,]*(.*)?$/im.exec(s);if(a&&a[1]){let s={name:a[1].trim().toLowerCase(),...getorientate(e,n,i,r),id:t,facce:o};if(a[2]){let e=getcolonne(a[2]);for(let t of e){let e=t.indexOf("=");e>0&&(s[t.slice(0,e).trim()]=t.slice(e+1).trim())}}l.push(s)}}return!l.length&&a&&l.push({name:a,...getorientate(e,n,i,r),id:t,facce:o}),l}function getemitter(t){let{d:n,name:i,x:r,y:s,z:o,lavs:a="",ids:A="",faces:l=null,size:c=5}=t;A=getcolonne(clean(A,!0));const p=new e.Object3D;if(p.position.set(r,s,o),p.userData={emitter:!0,lavs:a,ids:A,faces:l,size:c,name:i},n){const t=new e.SphereGeometry(c||5,8,8),n=new e.MeshBasicMaterial({color:16711680}),i=new e.Mesh(t,n);p.add(i)}return p.layers.set(29),p}function getreceiver(t,n){t.gmats.__istask=1;let{d:i,ori:r="LAP",x:s=0,y:o=0,z:a=0,sx:A=0,sy:l=0,sz:c=0,tipo:p="",start:h="",end:u=""}=n;p=clean(p,!0);const d=new e.Object3D;if(d.position.set(s/2+(A||0),o/2+(l||0),a/2+(c||0)),d.userData={receiver:!0,ori:(r||"").trim().toLowerCase(),x:s,y:o,z:a,tipo:p,start:h,end:u},i){const t=new e.BoxGeometry(s,o,a),n=new e.Mesh(t,bi);n.position.set(0,0,0),d.add(n)}return d.layers.set(29),d}function calcolatasks(t){const n=new WeakMap,i=new WeakMap;function boxBoxIntersects(e,t,n,i,r){return e.x+t>0&&e.x-t<n&&e.y+t>0&&e.y-t<i&&e.z+t>0&&e.z-t<r}function getFacceToccate(e,t,n,i,r,s,o){const a=[];function addfaccia(e){o&&!o.includes(e)||a.push(e)}return Math.abs(t.y-0)<n&&addfaccia(e[0]),Math.abs(t.y-r)<n&&addfaccia(e[1]),Math.abs(t.x-0)<n&&addfaccia(e[2]),Math.abs(t.x-i)<n&&addfaccia(e[3]),Math.abs(t.z-0)<n&&addfaccia(e[4]),Math.abs(t.z-s)<n&&addfaccia(e[5]),a.join("")}function getEmitterWorldPosition(t){if(!n.has(t)){const i=new e.Vector3;t.getWorldPosition(i),n.set(t,i)}return n.get(t)}function getReceiverWorldMatrixInverse(e){if(!i.has(e)){const t=e.matrixWorld.clone().invert();i.set(e,t)}return i.get(e)}t.updateMatrixWorld(!0);const r=[],s=[];!function scan(e){e.userData?.receiver&&r.push(e),e.userData?.emitter&&s.push(e),e.children&&e.children.forEach(scan)}(t);let o=[];for(const t of r){let{mat:n,ori:i,x:r,y:a,z:A,start:l,end:c,tipo:p,size:h}=t.userData,u=Ii[i];u||(i="apl",u=Ii[i]);let d={id:n,...getorientate(i,r,a,A),tipo:p,ori:i,lavs:[]};l&&d.lavs.push(...parselavs(i,"_start",0,0,0,l,"",""));const g=getReceiverWorldMatrixInverse(t);for(const t of s){if("string"==typeof p&&""!==p){const e=t.userData.ids;if(Array.isArray(e)&&e.length>0&&!e.includes("*")&&!e.includes(p))continue}const n=getEmitterWorldPosition(t).clone().applyMatrix4(g).clone().add(new e.Vector3(r/2,a/2,A/2));if(!boxBoxIntersects(n,t.userData.size??0,r,a,A))continue;const s=getFacceToccate(u,n,t.userData.soglia??2,r,a,A,t.userData.faces);s&&s.length&&d.lavs.push(...parselavs(i,t.userData.name,n.x,n.y,n.z,t.userData.lavs,s,"nd"))}c&&d.lavs.push(...parselavs(i,"_end",0,0,0,c,"","")),d.lavs.length&&o.push(d)}return o}function getbb(t,n=!1){if(!n&&t.userData.bb)return t.userData._boundingbox;const i=(new e.Box3).setFromObject(t);return t.userData._boundingbox=i,i}function setorigine(t,n=0,i=0,r=0){const s=getbb(t).min,o=new e.Group;return o.add(t),t.position.sub(new e.Vector3(s.x+n,s.y+i,s.z+r)),o}function scalaoggetto(t,n,i={}){const r=getbb(n),s=new e.Vector3;r.getSize(s);const o=r.min,a=["x","y","z","u","v"],A={};for(let e of a){let t=i[e];if(void 0===t)A[e]={s:1};else if("number"==typeof t)A[e]={s:t};else if("object"==typeof t){let n=t.s??1,i="x"===e?s.x:"y"===e?s.y:s.z,r="x"===e?o.x:"y"===e?o.y:o.z;void 0!==t.distperc&&(t.dist=i*t.distperc),void 0!==t.dist&&(n=(i+t.dist)/i);let a=t.p1?t.p1+r:void 0,l=t.p2?t.p2+r:void 0;void 0!==t.p1perc&&(a=r+i*t.p1perc),void 0!==t.p2perc&&(l=r+i*t.p2perc),A[e]={s:n,p1:a,p2:l}}}if(a.every((e=>void 0===A[e].p1||void 0===A[e].p2))){if(1===A.x.s&&1===A.y.s&&1===A.z.s)return n;const t=new e.Group;return t.scale.set(A.x.s,A.y.s,A.z.s),t.add(n),t}const l=hash(`${n.uuid}|${JSON.stringify(A)}`);if(t.meshes[l])return t.meshes[l];const c={};a.forEach((e=>{const{s:t,p1:n,p2:i}=A[e];c[e]=!(1===t&&void 0===n&&void 0===i)}));const p=n.clone(!0);return delete p?.userData._boundingbox,p.traverse((e=>{if(e.isMesh){const t=e.scale.clone();e.geometry=e.geometry.clone();const n=e.geometry.attributes.position,i=e.geometry.attributes.uv,trasf=(e,t)=>{if(!c[t])return e;const{s:n,p1:i,p2:r}=A[t];if(void 0===i||void 0===r)return e*n;const s=r*n-r;if(e<i)return e;if(e>=r)return e+s;return i+(e-i)*((r-i+s)/(r-i))};if(n&&(c.x||c.y||c.z)){const t=n.array;for(let e=0;e<t.length;e+=3)c.x&&(t[e]=trasf(t[e],"x")),c.y&&(t[e+1]=trasf(t[e+1],"y")),c.z&&(t[e+2]=trasf(t[e+2],"z"));n.needsUpdate=!0,e.geometry.computeVertexNormals()}if(i&&(c.u||c.v)){const e=i.array;for(let t=0;t<e.length;t+=2)c.u&&(e[t]=trasf(e[t],"u")),c.v&&(e[t+1]=trasf(e[t+1],"v"));i.needsUpdate=!0}e.scale.set(t.x*A.x.s,t.y*A.y.s,t.z*A.z.s)}})),t.meshes[l]=p,p}function posiziona(t,n={}){let i=new e.Group;if(t){let r=function deepclone(e){if(!e)return null;const t=e.clone();return function checkchildren(e,t){if(e.onBeforeRender&&(t.onBeforeRender=e.onBeforeRender),e.onAfterRender&&(t.onAfterRender=e.onAfterRender),e.userData&&(t.userData={...e.userData}),e.children||e.children.length)for(let n=0;n<e.children.length;n++)checkchildren(e.children[n],t.children[n])}(e,t),t}(t),s=r,{marker:o="",markerid:a="",sl:A=0,sa:l=0,sp:c=0,ax:p=0,ay:h=0,az:u=0,scale:d=1,scx:g=d,scy:f=d,scz:m=d,emitters:y,emittersname:b,order:I,move:x}=n;if("number"==typeof I&&r.traverse((e=>{e.isMesh&&(e.renderOrder=I)})),i.position.set(A,l,c),i.rotation.set(p*ft,h*ft,u*ft),i.scale.set(g,f,m),!x?.annulla){if(x){function managemove(t,n){let{l:i=0,a:r=0,p:s=0,rot:o=0}=t,a=new e.Group;return a.position.set(i,r,s),a.rotation.set(0,o*ft,0),a.add(n),a.userData.ismove=!0,a.userData.move=t,a}s=managemove(x,r)}i.add(s)}if(o&&a&&(i.userData.marker=o,i.userData.markerid=`#mk_${a||""}`),y&&y.length)for(let C of y)C.name=C.name||b,i.add(getemitter(C));for(let B of["hideable","origin","markdel","markkey","pars","noingombro","ignoreTraverse"])n[B]&&(i.userData[B]=n[B])}return i.updateMatrixWorld(!0),i}const xi=e.DoubleSide;let Bi=new e.LineBasicMaterial({color:16711680,transparent:!1,opacity:1}),Ei=new e.LineBasicMaterial({color:11579568,transparent:!1,opacity:1});const wi=new e.MeshStandardMaterial({color:16777215,roughness:.5,metalness:.4,side:xi}),vi=new e.MeshStandardMaterial({color:8421504,roughness:.5,metalness:.4,side:xi}),Qi=new e.MeshStandardMaterial({color:11579568,roughness:.5,metalness:.4,side:xi}),Pi=new e.MeshStandardMaterial({color:16711680,roughness:.5,metalness:.4,side:xi}),Ti=new e.MeshStandardMaterial({color:1982639,roughness:.5,metalness:.4,side:xi}),Di=new e.MeshStandardMaterial({color:36864,roughness:.5,metalness:.4,side:xi}),Li=new e.MeshStandardMaterial({color:0,roughness:.5,metalness:.4,side:xi}),_i=.001;function groupfromgeometry(t,n,i,r,s,o,a){let A=new e.Group;A.position.set(i,r,s),A.name=o;const l=new e.Mesh(t,n);l.name=o,l.castShadow=!0,l.receiveShadow=!0,l.layers.set(a);const c=new e.EdgesGeometry(t),p=new e.LineSegments(c,Bi);return p.layers.set(30),A.add(l),A.add(p),A}function edgesfromgeometry(t,n=40,i=30){return getlinesgeom(new e.EdgesGeometry(t,n),i)}function getlinesgeom(t,n=30){const i=new e.LineSegments(t,Bi);return i.layers.set(n),i}function getmesh(t,n,i=1,r=!1){let s=new e.Mesh(t,r?n.clone():n);return s.castShadow=!0,s.receiveShadow=!0,s.layers.set(i),s}function get3dshape(t,n,i){if(!t||t.length<3)return new e.BufferGeometry;const r=[];for(let e=0;e<t.length;e++){const n=t[e],i=t[(e+1)%t.length];r.push(n.x,0,n.y),r.push(i.x,0,i.y)}const s=new e.BufferGeometry;s.setAttribute("position",new e.Float32BufferAttribute(r,3));let o=new e.LineSegments(s,n);return o.layers.set(i),o}function creategroup(t,n={}){let{ignoreTraverse:i}=n,r=new e.Group;return r.name=t||"$$",i&&(r.userData.ignoreTraverse=!0),r}function svuotanodo(e){!function _dispose(e){if(e.children.length){[...e.children].forEach((t=>{_dispose(t),e.remove(t)}))}e.geometry&&e.geometry.dispose(),e.material&&(Array.isArray(e.material)?e.material.forEach((e=>e.dispose())):e.material.dispose())}(e)}function deletegroup(e,t){if(!e?.children)return;let n=e.children.find((e=>e.name==t));if(n){for(;n.children.length>0;){const e=n.children[0];n.remove(e)}n.parent&&n.parent.remove(n),n=null}}function randombasemat(){const t=new e.LineBasicMaterial,n=new e.Color;return n.setHSL(Math.random(),.7,.4),t.color=n,t}function getspriteid(t,n=5,i="#000"){const r=document.createElement("canvas"),s=r.getContext("2d");s.font="48px sans-serif";const o=Math.ceil(s.measureText(t).width)+16;r.width=o,r.height=64,s.font="48px sans-serif",s.textBaseline="middle",s.fillStyle="rgba(0,0,0,0)",s.fillRect(0,0,o,64),s.fillStyle=i,s.fillText(t,8,32);const a=new e.CanvasTexture(r);a.needsUpdate=!0,a.minFilter=e.LinearFilter;const A=new e.SpriteMaterial({map:a,transparent:!0}),l=new e.Sprite(A),c=n/20;return l.scale.set(o*c,64*c,1),l}function getline(t,n,i=null){const r=(new e.BufferGeometry).setFromPoints([new e.Vector3(t.p1.x,0,t.p1.y),new e.Vector3(t.p2.x,0,t.p2.y)]);let s=new e.Line(r,i||randombasemat());if(n){let e=getspriteid(n||"",8,"#F00");e.position.set((t.p1.x+t.p2.x)/2,0,(t.p1.y+t.p2.y)/2),s.add(e)}return s}function getpoint(t,n,i=null,r=5){let s;const o=new e.SphereGeometry(r,8,8);if(s=new e.Mesh(o,i||randombasemat()),n){let e=getspriteid(n||"",r);e.position.set(1.2*r,0,1.2*r),s.add(e)}return s.position.set(t.x,0,t.y),s}async function smat(t,n,i={}){i||(i={});let r=hash(n+JSON.stringify(i));return t.smats[r]||(i.glass?t.smats[r]=await async function smatglass(t,n={}){let i;try{i=new e.Color(t)}catch(t){i=new e.Color("#080808ff"),console.log(t)}let{roughness:r=.15,envMapIntensity:s=1,opacity:o=.25,metalness:a=.6,ior:A,transmission:l,specularIntensity:c,specularColor:p,thickness:h,clearcoat:u,clearcoatRoughness:d,dispersion:g}=n;if(!l||l<=0)return new e.MeshStandardMaterial({color:i,metalness:a,roughness:r,envMapIntensity:s,opacity:o,transparent:!0,side:e.FrontSide});return new e.MeshPhysicalMaterial({color:i,metalness:a,roughness:r,ior:A,envMapIntensity:s,transmission:l,specularIntensity:c,specularColor:p,opacity:o,thickness:h,clearcoat:u,clearcoatRoughness:d,dispersion:g,transparent:!0,side:e.FrontSide})}(n,i):t.smats[r]=await async function smat0(t,n,i={}){let r=n,s="",o=!1;if(!n)return wi;function getFilesToLoad(e,t){let n=[],i=t.match(/^([^(]+)\((([a-zA-Z0-9_\-/]+)_([a-z]+)|([a-z]+))\)$/);if(!i)return{base:t,files:n};let r=i[1],s=!1,o=i[3]||r,a=i[4]||i[5]||"";!a.includes("h")&&e||n.push({suff:"",file:`${o}.webp`,cs:!0});for(let e of a)"t"==e?(s=!0,i[3]&&ki[e]&&n.push({suff:e,file:`${o}_${e}.webp`,cs:!1})):"h"!=e&&ki[e]&&n.push({suff:e,file:`${o}_${e}.webp`,cs:!!["","e"].includes(e)});return{base:r,files:n,transparent:s}}n.startsWith("#")&&(o=!0,/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})(?=$|[[(])/.test(n)||(n=n.slice(1)));let a=n;const A=n.match(/^(.*)\[([^\]]+)\]$/);A&&(a=A[1],s=A[2]);const l={};s&&s.split(/[,;]/).forEach((e=>{let[t,n]=e.split("=").map((e=>e.trim()));void 0!==n&&(["e"].includes(t)?l[t]=n.startsWith("0x")?parseInt(n):parseFloat(n):isNaN(parseFloat(n))?l[t]=n:l[t]=parseFloat(n))}));let c=i.rot,p=parseFloat(i.s)||1;delete i.s;let h={...i};for(let e in l)if(Fi[e])for(let t of Fi[e])h[t]=l[e];let u=!!h?.transparent,d=(h.sx??h.s??l.sx??l.s??1)*p,g=(h.sy??h.s??l.sy??l.s??1)*p,f=Number((l.rot??0)+(c??0))*ft;try{let i={roughness:h.roughness??.5,metalness:h.metalness??0,side:e.DoubleSide,envMapIntensity:h.env??1};if(void 0!==h.normalScale){let t=Number(h.normalScale);isNaN(t)||0===t||(i.normalScale=new e.Vector2(t,t))}let r=!1,s=!1;if(n.includes("(")||o){let{base:n,files:A,transparent:l}=getFilesToLoad(o,a);if(u=l,A.some((e=>"n"===e.suff))&&(A=A.filter((e=>"h"!==e.suff))),0===h.roughness&&(A=A.filter((e=>"r"!==e.suff))),0===h.metalness&&(A=A.filter((e=>"m"!==e.suff))),0===h.emissiveIntensity&&(A=A.filter((e=>"e"!==e.suff))),A&&A.length){let n=await Promise.all(A.map((e=>t.tex(e.file,d,g,f).catch((()=>null)))));for(let t=0;t<A.length;t++){let o=n[t];if(!o)continue;o.isTexture&&(o.colorSpace=A[t].cs?e.SRGBColorSpace:e.LinearSRGBColorSpace);let a=A[t].suff,{prop:l,extra:c}=ki[a];i[l]=o,"map"===l&&(i._hasMap=!0),"normalMap"===c?(r=!0,i.normalMap=o,delete o.colorSpace,o.needsUpdate=!0,i.normalScale=i.normalScale??new e.Vector2(1,1)):"bumpScale"===c?(s=!0,i.bumpMap=o):Array.isArray(c)&&c.includes("emissive")&&void 0!==h.emissiveIntensity&&0!==h.emissiveIntensity&&(i.emissive=h.emissive||16777215,i.emissiveIntensity=h.emissiveIntensity??1)}}o&&(i.color=new e.Color(n),i._hasColor=!0)}else if(a.includes(".")){let e=await t.tex(a,d,g,f);if(!e)return wi;i.map=e,i._hasMap=!0}if(r&&s?delete i.bumpMap:s&&(i.bumpScale=h.bumpScale??.03),i.transparent=!!u,i.transparent&&(i.depthWrite=!1,i.opacity=h?.opacity??1),void 0!==h.brightness){let t=Number(h.brightness);!isNaN(t)&&t>0&&1!==t&&(i.color||(i.color=new e.Color(1,1,1)),i.color.multiplyScalar(t))}return i._hasMap&&!i._hasColor&&(i.color=new e.Color(1,1,1)),i._hasColor&&!i._hasMap&&delete i.map,delete i._hasColor,delete i._hasMap,new e.MeshStandardMaterial(i)}catch(e){return console.log("errore mat:",e.message,r),wi}}(t,n,i)),t.smats[r]}const Fi={s:["sx","sy"],sx:["sx"],sy:["sy"],rot:["rot"],br:["brightness"],r:["roughness"],m:["metalness"],h:["bumpScale"],n:["normalScale"],d:["bumpScale"],b:["bumpScale"],e:["emissiveIntensity"],ec:["emissive"],env:["envMapIntensity"],o:["opacity"],t:["transparent"],at:["alphaTest"]},ki={"":{prop:"map",extra:null},h:{},n:{prop:"normalMap",extra:null},a:{prop:"aoMap",extra:"aoMapIntensity"},r:{prop:"roughnessMap",extra:null},t:{prop:"alphaMap",extra:null},m:{prop:"metalnessMap",extra:null},e:{prop:"emissiveMap",extra:["emissive","emissiveIntensity"]}};async function extractTextures(e,t){const n={},i=[];function getName(e){n[e]=(n[e]||0)+1;let i=t;return e&&(i+=`_${e}`),n[e]>1&&(i+=n[e]),`${i}.webp`}return e.traverse((e=>{if(e.material){const t=Array.isArray(e.material)?e.material:[e.material];for(const e of t)for(const[t,{prop:n}]of Object.entries(ki)){const r=e[n];if(r&&r.image&&!r._extracted){r._extracted=!0;let e,n=r.image;if(n.toBlob)e=new Promise((e=>n.toBlob(e,"image/webp")));else if(n instanceof ImageBitmap){const t=document.createElement("canvas");t.width=n.width,t.height=n.height;t.getContext("2d").drawImage(n,0,0),e=new Promise((e=>t.toBlob(e,"image/webp")))}else{if(!(n instanceof HTMLImageElement))continue;{const t=document.createElement("canvas");t.width=n.naturalWidth||n.width,t.height=n.naturalHeight||n.height;t.getContext("2d").drawImage(n,0,0),e=new Promise((e=>t.toBlob(e,"image/webp")))}}i.push(e.then((e=>new File([e],getName(t),{type:"image/webp"}))))}}}})),e.traverse((e=>{if(e.material){const t=Array.isArray(e.material)?e.material:[e.material];for(const e of t)for(const{prop:t}of Object.values(ki)){const n=e[t];n&&n._extracted&&delete n._extracted}}})),Promise.all(i)}function uvswap(e,t=!1,n=!0){if(e&&e.attributes){const i=n?_i:1,r=e.attributes.uv;if(r){const e=r.array;for(let r=0,s=e.length;r<s;r+=2)if(t){const t=e[r];e[r]=e[r+1]*i,e[r+1]=t*i}else n&&(e[r]*=i,e[r+1]*=i);r.needsUpdate=t||n}const s=e.attributes.uv2;if(s){const e=s.array;for(let n=0,r=e.length;n<r;n+=2)if(t){const t=e[n];e[n]=e[n+1]*i,e[n+1]=t*i}else e[n]*=i,e[n+1]*=i;s.needsUpdate=!0}e.index&&e.attributes?.position&&e.attributes?.normal&&e.attributes?.uv&&e.computeTangents()}}function linea3d(e,t,n=!1){if(e&&e.length>1){const i=e.flatMap((e=>[e.x,e.y,0]));n&&i.push(e[0].x,e[0].y,0);const r=new LineGeometry;r.setPositions(i);const s=new Line2(r,t);return s.computeLineDistances(),s}}function transformfn(t={},n={}){const i=1e-6,r=new e.Vector3(t.sl||0,t.sa||0,t.sp||0),s=new e.Vector3(n.sl||0,n.sa||0,n.sp||0),o=new e.Vector3(t.scx??t.scale??1,t.scy??t.scale??1,t.scz??t.scale??1),a=new e.Vector3(n.scx??n.scale??1,n.scy??n.scale??1,n.scz??n.scale??1),A=(new e.Quaternion).setFromEuler(new e.Euler(e.MathUtils.degToRad(t.ax||0),e.MathUtils.degToRad(t.ay||0),e.MathUtils.degToRad(t.az||0),"XYZ")),l=(new e.Quaternion).setFromEuler(new e.Euler(e.MathUtils.degToRad(n.ax||0),e.MathUtils.degToRad(n.ay||0),e.MathUtils.degToRad(n.az||0),"XYZ")),c=o.clone().multiply(a),p=A.clone().multiply(l).normalize(),h=s.clone().multiply(o).applyQuaternion(A).add(r),u={},sig=(e,t=2)=>Math.round(e*10**t)/10**t;Math.abs(h.x)>i&&(u.sl=sig(h.x)),Math.abs(h.y)>i&&(u.sa=sig(h.y)),Math.abs(h.z)>i&&(u.sp=sig(h.z)),Math.abs(c.x-c.y)<i&&Math.abs(c.x-c.z)<i?Math.abs(c.x-1)>i&&(u.scale=c.x):(Math.abs(c.x-1)>i&&(u.scx=c.x),Math.abs(c.y-1)>i&&(u.scy=c.y),Math.abs(c.z-1)>i&&(u.scz=c.z));const d=(new e.Euler).setFromQuaternion(p,"XYZ"),g=e.MathUtils.radToDeg(d.x),f=e.MathUtils.radToDeg(d.y),m=e.MathUtils.radToDeg(d.z);return Math.abs(g)>i&&(u.ax=sig(g,1)),Math.abs(f)>i&&(u.ay=sig(f,1)),Math.abs(m)>i&&(u.az=sig(m,1)),u}function getfakeshadow2(t,n,i){const r=(new e.Shape).moveTo(0,0).lineTo(t,0).lineTo(t,n).lineTo(0,n).lineTo(0,0),s=new e.ShapeGeometry(r),o=s.attributes.position,a=new Float32Array(2*o.count);for(let e=0;e<o.count;e++)a[2*e]=o.getX(e)/t,a[2*e+1]=o.getY(e)/n;s.setAttribute("uv",new e.BufferAttribute(a,2));const A=new e.MeshBasicMaterial({map:i,transparent:!0,alphaTest:.01,depthWrite:!1,side:e.DoubleSide}),l=new e.Mesh(s,A);return l.layers.set(9),l.rotation.x=Math.PI/2,l}function getfakeshadow(t,n,i){let r=`fk${n.key}${i}`,{p1:s,width:o,height:a}=n.dims();t.texture||(t.texture={});let A=t.texture[r];A||(A=function createBlurredShadowTextureFromPoints(t,n=256,i=32,r=.2,s,o,a){if(!o||!a||!t.pt||t.pt.length<2)return;const A=s.x,l=s.y,c=o,p=a,h=t.pt,u=2*i,d=document.createElement("canvas");d.width=n+2*u,d.height=n+2*u;const g=d.getContext("2d");g.save(),g.translate(u,u),g.scale(n/c,n/p),g.translate(-A,-l),g.filter=`blur(${i}px)`,g.beginPath(),g.moveTo(h[0].x,h[0].y);for(let e=1;e<h.length;e++)g.lineTo(h[e].x,h[e].y);g.closePath(),g.fillStyle=`rgba(0,0,0,${r})`,g.fill(),g.restore();const f=new e.CanvasTexture(d);return f.needsUpdate=!0,f}(n,256,32,i,s,o,a),t.texture[r]=A);const l=function pointsToShape(t){const n=new e.Shape;n.moveTo(t[0].x,t[0].y);for(let e=1;e<t.length;e++)n.lineTo(t[e].x,t[e].y);return n}(n.pt),c=new e.ShapeGeometry(l);!function applyUVtoShapeGeometry(t,n,i,r,s){const o=t.attributes.position,a=[];for(let e=0;e<o.count;e++){const t=o.getX(e),A=o.getY(e);a.push((t-n)/r,(A-i)/s)}t.setAttribute("uv",new e.Float32BufferAttribute(a,2))}(c,s.x,s.y,o,a);const p=new e.MeshBasicMaterial({map:A,transparent:!0,depthWrite:!1,side:e.DoubleSide});let h=new e.Mesh(c,p);return h.layers.set(9),h.rotation.x=Math.PI/2,h}function addmovpivot(t,n,i,r={},s=0,o=0,a=0){if(i=clean(i,!0),!t.movs[i])return n;t.movs[i];const A=new e.Vector3(s,o,a),l=0===A.lengthSq(),c=new e.Group;c.name=`pivot_${i}`;const p=new e.Group;if(p.name=`mov_${i}`,l)c.position.copy(n.position),c.quaternion.copy(n.quaternion),n.position.set(0,0,0),n.rotation.set(0,0,0);else{const t=A.clone().applyMatrix4(n.matrixWorld);c.position.copy(t);const i=A.clone().negate();n.position.add(i),c.quaternion.copy(n.getWorldQuaternion(new e.Quaternion)),n.rotation.set(0,0,0)}return p.add(n),c.add(p),r||(r={}),r.inmov=!1,r.key=i,r.dt=0,r.dtstart=!1,p.userData.mov={...r},c}function getmovimento(e,t=[]){let n=0,i=[];const _cleartimeline=()=>{i=[],n=0},_add=(e,t={})=>{e&&i.push({...t,time:e}),n=i.reduce(((e,t)=>e+(t.time||0)),0)};_cleartimeline(),t&&t.length&&t.forEach((e=>_add(e.time,e)));const _resetmov=e=>{const{mov:t}=e?.userData||{};t&&(t.inmov=!1,e.position.set(0,0,0),e.scale.set(1,1,1),e.rotation.set(0,0,0))};return{get tline(){return n},clear:_cleartimeline,add:_add,key:e,step:(e,t)=>{if(!e||!e.userData?.mov||!n)return;const{mov:r}=e.userData;if(!r.inmov)return;let s=r.dt-r.dtstart;if(r.ripeti)s%=n;else if(s>n)return void _resetmov(e);let o=0,a=0,A=0,l=0,c=0,p=0,h=1,u=1,d=1,g=null,f=0;for(let e of i){if(f+=e.time,s<f){const t=e.time>0?(s-(f-e.time))/e.time:1,_calc=(e,n=0)=>"function"==typeof e?e(r)*t:(e||n)*t;o+=_calc(e.x),a+=_calc(e.y),A+=_calc(e.z),h*=1+_calc(e.sx??e.s,0),u*=1+_calc(e.sy??e.s,0),d*=1+_calc(e.sz??e.s,0),l+=_calc(e.ax)*ft,c+=_calc(e.ay)*ft,p+=_calc(e.az)*ft,void 0!==e.t&&(g="function"==typeof e.t?e.t(r)*t:e.t*t);break}{const _calc=(e,t=0)=>"function"==typeof e?e(r):e||t;o+=_calc(e.x),a+=_calc(e.y),A+=_calc(e.z),h*=1+_calc(e.sx??e.s,0),u*=1+_calc(e.sy??e.s,0),d*=1+_calc(e.sz??e.s,0),l+=_calc(e.ax)*ft,c+=_calc(e.ay)*ft,p+=_calc(e.az)*ft,void 0!==e.t&&(g="function"==typeof e.t?e.t(r):e.t)}}e.position.set(o,a,A),e.scale.set(h,u,d),e.rotation.set(l,c,p),null!==g&&e.traverse((e=>{if(e.material){(Array.isArray(e.material)?e.material:[e.material]).forEach((e=>{e.transparent&&(e.opacity=1-g)}))}})),t&&t(e,s)},reset:_resetmov}}let Ri=null,Ni=null;function getriferimento(t,n=0,i=0,r=0,s="rif"){"string"==typeof t&&(t={testo:t});let o=new e.Object3D;return o.position.set(n,i,r),s&&(o.name=s),o.userData={tipo:"rif",...t},o}function gettarghetta(t,n,i=100,r={}){const{noSfondo:s=!1,forcey:o=!1,coloreSfondo:a="white",coloreBordo:A="gray",spessoreBordo:l=2,padding:c=8,layer:p=21,size:h=24,hideable:u=!0,fontFamily:d="Arial",raggioAngoli:g=10,order:f=0,variant:m,tooltip:y,billboard:b=!1}=r;n=(n||"").replaceAll("\\n","\n");let I=hash(`T:${a}|${A}|${d}|${c}|${l}|${g}|${s}|${n}|${m}|${b}`);const x=h??24;n=n.split("\n").map((e=>{let t=x,n=!1,i=!1,r="black";e=e.trim();let s=/^\s*#(\w)([bi]?)([\d.]*)[,;](.*)$/.exec(e);if(s)switch(t=parseFloat(s[3]||1)*x,"b"===s[2]&&(n=!0),"i"===s[2]&&(i=!0),e=s[4],s[1].toLowerCase()){case"r":r="red";break;case"g":r="green";break;case"b":r="blue";break;case"w":r="white";break;case"c":r="cyan"}return{testo:e,size:t,color:r,bold:n,italic:i}})).filter((e=>e.testo));const{canvas:C,context:B}=function getGlobalCanvas(){return Ri||(Ri=document.createElement("canvas"),Ni=Ri.getContext("2d",{willReadFrequently:!0})),{canvas:Ri,context:Ni}}();let E=0,w=2*c;n.forEach(((e,t)=>{const{testo:i,size:r=12}=e,s=2*r;B.font=`${s}px ${d}`;const o=B.measureText(i).width,a=s*(t==n.length-1?1:1.2);E=Math.max(E,o),w+=a})),E+=2*c;const v=w/E||1;let P,T;if(o?(T=i,P=Math.ceil(T/v)):(P=i,T=Math.ceil(P*v)),!t.textures[I]){const i=Math.floor(E+2*l),r=Math.floor(w+2*l);(C.width<i||C.height<r)&&(C.width=Math.max(C.width,i),C.height=Math.max(C.height,r)),B.clearRect(0,0,i,r);const o=new e.Color(a),p=`rgb(${Math.floor(255*o.r)}, ${Math.floor(255*o.g)}, ${Math.floor(255*o.b)})`,h=new e.Color(A),u=`rgb(${Math.floor(255*h.r)}, ${Math.floor(255*h.g)}, ${Math.floor(255*h.b)})`,f=g;B.beginPath(),s||(drawRoundedRect(B,0,0,i,r,f+l/2),B.fillStyle=u,B.fill(),B.beginPath(),drawRoundedRect(B,l,l,i-2*l,r-2*l,f-l/2),B.fillStyle=p,B.fill());let m=c+l;n.forEach((e=>{const{testo:t,size:n=12,color:r="black",bold:s,italic:o}=e,a=2*n;B.font=`${s?"bold ":o?"italic ":""}${a}px ${d}`,B.fillStyle=r,B.textAlign="center",B.textBaseline="top",B.fillText(t,i/2,m),m+=1.2*a}));const y=B.getImageData(0,0,i,r),b=new e.DataTexture(y.data,y.width,y.height,e.RGBAFormat);b.needsUpdate=!0,b.flipY=!0,b.minFilter=e.LinearFilter,b.magFilter=e.LinearFilter,t.textures[I]=b}const S=new e.MeshBasicMaterial({map:t.textures[I],transparent:!0,alphaTest:.5,side:xi}),M=new e.PlaneGeometry(P,T),D=new e.Mesh(M,S);return D.layers.set(p),D.renderOrder=f,D.userData={dimx:P,dimy:T,noingombro:!0,hideable:u},m&&(D.userData.pickvariant=!0,D.userData.variant=m,D.userData.tooltip=y),b&&(D.up.set(0,0,1),D.layers.set(21),D.onBeforeRender=(e,t,n)=>{D.quaternion.copy(n.quaternion)}),D}function drawRoundedRect(e,t,n,i,r,s){s=Math.min(s,Math.min(i/2,r/2)),e.moveTo(t+s,n),e.lineTo(t+i-s,n),e.quadraticCurveTo(t+i,n,t+i,n+s),e.lineTo(t+i,n+r-s),e.quadraticCurveTo(t+i,n+r,t+i-s,n+r),e.lineTo(t+s,n+r),e.quadraticCurveTo(t,n+r,t,n+r-s),e.lineTo(t,n+s),e.quadraticCurveTo(t,n,t+s,n),e.closePath()}function getquota(t,n,i,r,s,o,a={}){const{altezza:A=30,offset:l=0,piano:c="xy",hideable:p=!0,layer:h=22,delta:u=5,spessoreLinea:d=3}=a,pp=(e,t)=>"xz"===c?[e,0,t]:"yz"===c?[0,e,t]:[e,t,0],g=new e.Group;g.name="quota",g.userData.hideable=!0;const f=s-i,m=o-r,y=Math.sqrt(f*f+m*m),b=Math.atan2(m,f);n||(n="$$"),n.includes("$$")&&(n=n.replace("$$",`${y.toFixed(1)}`));let I=n.split("\n").length;const x=-Math.sin(b)*l,C=Math.cos(b)*l,B=gettarghetta(t,n,2*A*I,{noSfondo:!0,layer:h,forcey:!0}),{dimx:E,dimy:w}=B.userData;function getCilindro(n,i,r){const s=(new e.Vector3).subVectors(i,n),o=s.length();let a,A=hash(`c:${r}|${o}`);t.geo[A]?a=t.geo[A]:(a=new e.CylinderGeometry(r/2,r/2,o,3,1,!0),t.geo[A]=a);const l=new e.Mesh(a,Li);l.position.copy(n).add(s.multiplyScalar(.5));const c=(new e.Vector3).copy(i);return l.lookAt(c),l.rotateX(Math.PI/2),l}if(E>y-u){B.position.set(y/2,2*A,0);const t=getCilindro(new e.Vector3(...pp(0,0)),new e.Vector3(...pp(y,0)),d);g.add(t)}else{const t=E+u,n=(y-t)/2,i=n+t,r=getCilindro(new e.Vector3(...pp(0,0)),new e.Vector3(...pp(n,0)),d);g.add(r);const s=getCilindro(new e.Vector3(...pp(i,0)),new e.Vector3(...pp(y,0)),d);g.add(s),B.position.set(...pp(y/2,0))}const v=l>A/2?-l:-A/2,P=-l>A/2?-l:A/2,T=new e.Vector3(...pp(0,v)),S=new e.Vector3(...pp(0,P)),M=new e.Vector3(...pp(y,v)),D=new e.Vector3(...pp(y,P)),L=getCilindro(T,S,d);g.add(L);const _=getCilindro(M,D,d);return g.add(_),B.userData.updateOrientation=function(e){e&&this.quaternion.copy(e.quaternion)},g.add(B),g.userData.noingombro=!0,"xy"===c?(g.position.set(i+x,r+C,0),g.rotation.z=b):"xz"===c?(g.position.set(i+x,0,r+C),g.rotation.y=-b):"yz"===c&&(g.position.set(0,i+x,r+C),g.rotation.x=b),g.layers.set(h||22),g}function creagizmo(t={}){const n=100*(t.size??1),i=t.picksize??1.6,r={x:t?.colors?.x??16711680,y:t?.colors?.y??65280,z:t?.colors?.z??255,plane:t?.colors?.plane??8388736,rot:t?.colors?.rot??8421504},s=new e.Group;s.name="gizmo";const mat=(t,n=1)=>new e.MeshBasicMaterial({color:t,transparent:n<1,opacity:n,depthWrite:!1,toneMapped:!1,depthTest:!1});function makeaxis(t,r){const s=new e.Group;s.name="ax_"+t;const o=new e.Mesh(new e.CylinderGeometry(.02*n,.02*n,.8*n,8),mat(r));o.position.y=.4*n;const a=new e.Mesh(new e.ConeGeometry(.05*n,.2*n,12),mat(r));a.position.y=n;const A=new e.Mesh(new e.CylinderGeometry(.08*n*i,.08*n*i,1.2*n,6),mat(r,0));return A.position.y=.6*n,s.add(o,a,A),"x"===t&&(s.rotation.z=-Math.PI/2),"z"===t&&(s.rotation.x=Math.PI/2),s.userData={kind:"gizmo-handle",type:"axis",axis:t},s}const o=makeaxis("x",r.x),a=makeaxis("y",r.y),A=makeaxis("z",r.z),l=function makeplane(){const t=new e.Group;t.name="pl_xz";const i=.6*n,s=.25*i,o=.4*n,a=.4*-n,A=new e.Shape;A.moveTo(o-i/2+s,a-i/2),A.lineTo(o+i/2-s,a-i/2),A.quadraticCurveTo(o+i/2,a-i/2,o+i/2,a-i/2+s),A.lineTo(o+i/2,a+i/2-s),A.quadraticCurveTo(o+i/2,a+i/2,o+i/2-s,a+i/2),A.lineTo(o-i/2+s,a+i/2),A.quadraticCurveTo(o-i/2,a+i/2,o-i/2,a+i/2-s),A.lineTo(o-i/2,a-i/2+s),A.quadraticCurveTo(o-i/2,a-i/2,o-i/2+s,a-i/2);const l=new e.ShapeGeometry(A),c=new e.Mesh(l,mat(r.plane,.35));c.rotation.x=-Math.PI/2,c.position.y=.001;const p=new e.Mesh(l,mat(r.plane,0));return p.rotation.copy(c.rotation),p.position.copy(c.position),t.add(c,p),t.userData={kind:"gizmo-handle",type:"plane",plane:"xz"},t}(),c=function makerot(){const t=new e.Group;t.name="rot_y";const i=.9*n*1.5,s=.025*n,o=new e.Mesh(new e.TorusGeometry(i,s,8,32,Math.PI/3),mat(r.rot));o.rotation.x=Math.PI/2;const a=Math.PI/3,A=new e.Mesh(new e.ConeGeometry(.06*n,.15*n,10),mat(r.rot));A.position.set(i*Math.cos(0),0,i*Math.sin(0));let l=new e.Vector3(-Math.sin(0),0,Math.cos(0)).normalize().negate();A.quaternion.setFromUnitVectors(new e.Vector3(0,1,0),l);const c=new e.Mesh(new e.ConeGeometry(.06*n,.15*n,10),mat(r.rot));c.position.set(i*Math.cos(a),0,i*Math.sin(a));let p=new e.Vector3(-Math.sin(a),0,Math.cos(a)).normalize();c.quaternion.setFromUnitVectors(new e.Vector3(0,1,0),p);const h=new e.Mesh(new e.TorusGeometry(i,4*s,6,16,Math.PI/3),mat(r.rot,0));return h.rotation.copy(o.rotation),t.add(o,A,c,h),t.userData={kind:"gizmo-handle",type:"rot",axis:"y"},t.rotation.y=-.08333333333333333*Math.PI,t}();return s.add(o,a,A,l,c),s.userData={kind:"gizmo",handles:{x:o,y:a,z:A,xz:l,roty:c}},s.setpos=e=>s.position.copy(e),s.setvisible=(e={})=>{void 0!==e.x&&(o.visible=e.x),void 0!==e.y&&(a.visible=e.y),void 0!==e.z&&(A.visible=e.z),void 0!==e.xz&&(l.visible=e.xz),void 0!==e.roty&&(c.visible=e.roty)},s}function fillNoise(t,n,i={}){let{scale:r=8,octaves:s=3,persistence:o=.5,seed:a=0,contrast:A=1,color1:l="#000000",color2:c="#ffffff",alpha1:p=1,alpha2:h=1}=i;const u=new e.Color(l),d=new e.Color(c),fade=e=>e*e*e*(e*(6*e-15)+10),lerp=(e,t,n)=>e+(t-e)*n,g=n,f=new Uint16Array(2*g);let m=0|Math.floor(65536*a);for(let e=0;e<g;e++)f[e]=e;for(let e=0;e<g;e++){const t=Math.floor((m^=m<<13,m^=m>>17,m^=m<<5,(m<0?1+~m:m)%65536/65536*g));[f[e],f[t]]=[f[t],f[e]]}for(let e=0;e<g;e++)f[g+e]=f[e];const y=[[1,1],[-1,1],[1,-1],[-1,-1],[1,0],[-1,0],[0,1],[0,-1]];function grad(e,t){const n=f[(f[e%g]+t)%g]%8;return y[n]}function perlin(e,t,n,i){const r=Math.floor(e)%n,s=Math.floor(t)%i,o=e-Math.floor(e),a=t-Math.floor(t),A=grad(r,s),l=grad(r+1,s),c=grad(r,s+1),p=grad(r+1,s+1),h=A[0]*o+A[1]*a,u=l[0]*(o-1)+l[1]*a,d=c[0]*o+c[1]*(a-1),g=p[0]*(o-1)+p[1]*(a-1),f=fade(o),m=fade(a);return lerp(lerp(h,u,f),lerp(d,g,f),m)}let b=1/0,I=-1/0;const x=new Float32Array(n*n);for(let e=0;e<n;e++)for(let t=0;t<n;t++){let i=t/n*r,a=e/n*r,A=1,l=1,c=0,p=0;for(let e=0;e<s;e++){c+=perlin(i*l,a*l,g/l,g/l)*A,p+=A,A*=o,l*=2}let h=c/p;x[e*n+t]=h,h<b&&(b=h),h>I&&(I=h)}const C=1/(I-b);for(let e=0;e<n;e++)for(let i=0;i<n;i++){let r=(x[e*n+i]-b)*C;r=Math.pow(r,A);const s=u.r+(d.r-u.r)*r,o=u.g+(d.g-u.g)*r,a=u.b+(d.b-u.b)*r,l=0,c=4*(e*n+i);t[c]=Math.floor(255*s),t[c+1]=Math.floor(255*o),t[c+2]=Math.floor(255*a),t[c+3]=Math.floor(255*l)}}function texgen(t,n,i=256,r={}){[16,32,64,128,256,512,1024].includes(i)||(i=256);let s=hash(`gen|${n}|${i}|${JSON.stringify(r)}`);if(!t[s]){const o=new Uint8Array(i*i*4);switch(n){case"wood":{let e={...r};e.scale=6+seeder(40,r.seed+"a")/10,e.octaves=r.octaves||3,e.persistence=.5+seeder(50,r.seed+"b")/100,e.rings=2+seeder(200,r.seed+"c")/100,e.distortion=.3+seeder(100,r.seed+"d")/300,e.color1=r.color1||"#442200",e.color2=r.color2||"#ffe0a0",fillNoise(o,i,e)}break;case"marble":{let e={...r};e.scale=r.scale||10,e.octaves=r.octaves||3,e.persistence=r.persistence||.6,e.rings=r.rings||1+seeder(100,r.seed+"m3")/50,e.distortion=r.distortion||.8+seeder(200,r.seed+"m4")/200,e.contrast=r.contrast||1.2,e.color1=r.color1||"#e0e0e0",e.color2=r.color2||"#909090",fillNoise(o,i,e)}break;case"glass":{let e={...r};e.scale=r.scale||32,e.octaves=r.octaves||2,e.persistence=r.persistence||.8,e.contrast=r.contrast||1,e.color1=r.color1||"rgba(255,255,255,0.2)",e.color2=r.color2||"rgba(255,255,255,0.6)",fillNoise(o,i,e)}break;case"gradient":case"pattern":break;default:fillNoise(o,i,r)}const a=new e.DataTexture(o,i,i,e.RGBAFormat);a.needsUpdate=!0,a.wrapS=a.wrapT=e.RepeatWrapping,a.repeat.set(.002,.002),a.center.set(.5,.5),t[s]=a}return t[s]}function getcilindro(t,n,i,r,s,o=wi,a){a||(a={}),Array.isArray(o)||(o=[o]);const A=function cylgeometry(t,n,i,r,s=16){if(!i||!n)return null;let o=hash(`cy${n}|${i}|${r||i}|${s}`);if(!t.geo[o]){const a=new e.CylinderGeometry(r||i,i,n,s);t.geo[o]=a}return t.geo[o]}(t,i,r,s,a.sides||16);let l=new e.Group;switch((n||"").trim().toUpperCase()){case"X":case"L":l.position.set(i/2,0,0),l.rotation.z=Math.PI/2;break;case"Z":case"P":l.position.set(0,0,i/2),l.rotation.x=Math.PI/2;break;default:l.position.set(0,i/2,0)}if(A){if(!a.nolines){let e=edgesfromgeometry(A);l.add(e)}uvswap(A,a.uvswap,!1);const e=o[0]||wi,t=o[1]||e,n=o[2]||e;l.add(getmesh(A,[e,t,n]))}return l}function facesettile(e,t,n,i){if(t>1||n>1){let r=i%(t=t??1);const s=1/t,o=1/(n=n??1),a=r*s,A=1-((i-r)/t+1)*o,l=a+s,c=A+o,p=e.geometry.attributes.uv,h=[[a,c],[l,c],[a,A],[l,A]];for(let e=0;e<p.count;e++)p.setXY(e,h[e][0],h[e][1]);p.needsUpdate=!0}}function pickvariant(e,t,n,i,r,s,o={}){let a,{mat:A,testo:l,matover:c}=o;return A?(a=getface(e,t,n,A,o),c&&(c=c.clone(),c.depthTest=!1,c.depthWrite=!1,a.userData.matover=c)):(l=l||"xx",a=gettarghetta(e,l,t,o)),a.layers.disableAll(),a.layers.set(30),a.userData.pickvariant=!0,a.userData.variant=i,a.userData.value=r,a.userData.tooltip=s,a}function getface(t,n,i,r,s={}){let{repeat:o,order:a,center:A=!1,base:l=!1,billboard:c=!1}=s;const p=hash(`f:${n}|${i}|${o?1:0}|${l?1:0}`);if(!t.geo[p]){const r=new e.PlaneGeometry(n,i);let s=l?-.5:0;const a=r.attributes.uv;if(o)for(let e=0;e<a.count;e++)a.setXY(e,a.getX(e)*n/1e3,a.getY(e)*i/1e3);else{const e=[[0,1],[1,1],[0,0],[1,0]];for(let t=0;t<a.count;t++){const n=e[t];a.setXY(t,n[0]-s,n[1]-s)}}a.needsUpdate=!0,t.geo[p]=r}c&&((r=r.clone()).depthTest=!1,r.depthWrite=!1);const h=new e.Mesh(t.geo[p],r);if(h.name=c?"billboard":"face","number"==typeof a&&(h.renderOrder=a),A||h.position.set(n/2,i/2,0),r?.transparent&&h.layers.set(2),c){h.layers.disableAll(),h.layers.set(30),h.userData.billboard=!0;let t=new e.Quaternion,n=new e.Quaternion;h.onBeforeRender=function(e,i,r){this.getWorldQuaternion(t),this.parent?.getWorldQuaternion(n),this.quaternion.copy(r.quaternion),this.quaternion.premultiply(n.invert())}}return h}function getbox(t,n,i,r,s,o){s&&s.isMaterial||o||(o=s,s=void 0),o||(o={});let{center:a=!1,nolines:A=!1,centerbase:l=!1,px:c=0,py:p=0,pz:h=0}=o;const u=new e.BoxGeometry(n,i,r),d=new e.Group;if(l?d.position.set(0,i/2,0):c||p||h?d.position.set(c||0,p||0,h||0):a||d.position.set(n/2,i/2,r/2),!A||!s){let e=edgesfromgeometry(u);A&&(e.opacity=.1),d.add(e)}return s&&d.add(getmesh(u,s)),d}function getcyl(t,n,i,r,s){s||(s={});let{center:o=!1,nolines:a=!1,segments:A=16,top:l=-1,bottom:c=-1,heightSegments:p=1,openEnded:h=!1,thetaStart:u=0,thetaLength:d=2*Math.PI}=s;l<0&&(l=i),c<0&&(c=i);const g=new e.CylinderGeometry(l,c,n,A,p,h,u,d);uvswap(g,s.uvswap,!1);const f=getmesh(g,r||wi),m=new e.Group;if(m.add(f),m.position.set(0,o?0:n/2,0),!a){let e=edgesfromgeometry(g);m.add(e)}return m}function getsphere(t,n,i,r){r||(r={});let{nolines:s,segmenti:o=16}=r,a=new e.Group;const A=new e.SphereGeometry(n,2*o,o);if(!s){let e=edgesfromgeometry(A);a.add(e)}return a.add(getmesh(A,i||wi)),a}function makeShape(t){const n=new e.Shape;n.moveTo(t[0].x,t[0].y);for(let e=1;e<t.length;e++)n.lineTo(t[e].x,t[e].y);return n.closePath(),n}function getextrude(t,n,i=10,r=[],s=void 0,o={}){s&&s.isMaterial||(o=s,s=void 0),o=o??{};let{stonda:a,sx:A,sy:l,round:c,nolines:p}=o,h=hash(`${JSON.stringify(n)}|${i}|${JSON.stringify(o)}|${JSON.stringify(r)}`);A=A??a??0,l=l??a??0;let u=t.geo[h];if(!u){const s=makeShape(n);r.forEach((t=>s.holes.push(function makePath(t){const n=new e.Path;n.moveTo(t[0].x,t[0].y);for(let e=1;e<t.length;e++)n.lineTo(t[e].x,t[e].y);return n.closePath(),n}(t))));const a=A>0&&l>0;u=new e.ExtrudeGeometry(s,{depth:i,bevelEnabled:a,bevelSize:A,bevelThickness:l,bevelSegments:a?c?3:1:0,curveSegments:a?10:1}),t.geo[h]=u,uvswap(u,o.uvswap,!0)}let d=new e.Group;return d.add(new e.Mesh(u,s||wi)),p||function extrudelines(t,n,i,r,s=3){const makeloop=(t,n)=>{if(!t||t.length<2)return null;const i=t.length,r=new Float32Array(3*(i+1));for(let e=0;e<=i;e++){const s=t[e%i],o=3*e;r[o]=s.x,r[o+1]=s.y,r[o+2]=n}const s=new e.BufferGeometry;return s.setAttribute("position",new e.BufferAttribute(r,3)),new e.Line(s,Bi)},addring=e=>{let n=makeloop(e,-s);n&&(n.layers.set(30),t.add(n)),n=makeloop(e,r+s),n&&(n.layers.set(30),t.add(n))};addring(n);for(const e of i)addring(e)}(d,n,r,i,l),d}function getthorus(t,n,i=.2,r,s){s||(s={});let{center:o,nolines:a,segmenti:A=16,tubi:l=12}=s,c=new e.Group;const p=new e.TorusGeometry(n,i,l,2*A);if(c.position.set(0,o?0:n,0),!a){let e=edgesfromgeometry(p);c.add(e)}return c.add(getmesh(p,r||wi)),c}function getluce(t,n,i="#ffffff",r=1){const s=n.pt;if(!s||!s.length)return null;const o=hash(`${n.key}|${i}|${r}`);if(!t.meshes[o]){const n=makeShape(s),a=new e.ShapeGeometry(n),A=new e.MeshStandardMaterial({color:new e.Color(i),emissive:new e.Color(i),emissiveIntensity:r,toneMapped:!1,transparent:!0,depthWrite:!1,side:e.DoubleSide,polygonOffset:!0,polygonOffsetFactor:-2,polygonOffsetUnits:1}),l=new e.Mesh(a,A);l.layers.set(8),l.userData.isBloom=!0,t.meshes[o]=l,t.mustlight=!0}return t.meshes[o]}function getmarker(t,n,i,r,s,o,a={}){if(n&&i){a||(a={});let{billboard:A,xl:l=0,xa:c=0,xp:p=0,origin:h=0}=a;a.markerid=n,a.marker=i,a.noingombro=!0,a.hideable=!0,a.origin=h||0;let u=new e.Group,d=getface(t,r,s,o,{order:1}),g=n;g.length>7&&(g=".."+g.slice(-6));let f=gettarghetta(t,`#w,${g}`,50,{noSfondo:!0,layer:11,billboard:A,forcey:!0});return d.add(posiziona(f,{sp:11,order:2})),u.add(posiziona(d,{sl:l,sa:c,sp:p})),u.layers.set(28),u.userData.hideable=!0,posiziona(u,a)}}function mergeAttributes(e){let t,n,i,r=-1,s=0;for(let o=0;o<e.length;++o){const a=e[o];if(void 0===t&&(t=a.array.constructor),t!==a.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(void 0===n&&(n=a.itemSize),n!==a.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(void 0===i&&(i=a.normalized),i!==a.normalized)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;if(-1===r&&(r=a.gpuType),r!==a.gpuType)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes."),null;s+=a.count*n}const o=new t(s),a=new B(o,n,i);let A=0;for(let t=0;t<e.length;++t){const i=e[t];if(i.isInterleavedBufferAttribute){const e=A/n;for(let t=0,r=i.count;t<r;t++)for(let r=0;r<n;r++){const n=i.getComponent(t,r);a.setComponent(t+e,r,n)}}else o.set(i.array,A);A+=i.count*n}return void 0!==r&&(a.gpuType=r),a}function mergeVertices(e,t=1e-4){t=Math.max(t,Number.EPSILON);const n={},i=e.getIndex(),r=e.getAttribute("position"),s=i?i.count:r.count;let o=0;const a=Object.keys(e.attributes),A={},l={},c=[],p=["getX","getY","getZ","getW"],h=["setX","setY","setZ","setW"];for(let t=0,n=a.length;t<n;t++){const n=a[t],i=e.attributes[n];A[n]=new i.constructor(new i.array.constructor(i.count*i.itemSize),i.itemSize,i.normalized);const r=e.morphAttributes[n];r&&(l[n]||(l[n]=[]),r.forEach(((e,t)=>{const i=new e.array.constructor(e.count*e.itemSize);l[n][t]=new e.constructor(i,e.itemSize,e.normalized)})))}const u=.5*t,d=Math.log10(1/t),g=Math.pow(10,d),f=u*g;for(let t=0;t<s;t++){const r=i?i.getX(t):t;let s="";for(let t=0,n=a.length;t<n;t++){const n=a[t],i=e.getAttribute(n),o=i.itemSize;for(let e=0;e<o;e++)s+=~~(i[p[e]](r)*g+f)+","}if(s in n)c.push(n[s]);else{for(let t=0,n=a.length;t<n;t++){const n=a[t],i=e.getAttribute(n),s=e.morphAttributes[n],c=i.itemSize,u=A[n],d=l[n];for(let e=0;e<c;e++){const t=p[e],n=h[e];if(u[n](o,i[t](r)),s)for(let e=0,i=s.length;e<i;e++)d[e][n](o,s[e][t](r))}}n[s]=o,c.push(o),o++}}const m=e.clone();for(const t in e.attributes){const e=A[t];if(m.setAttribute(t,new e.constructor(e.array.slice(0,o*e.itemSize),e.itemSize,e.normalized)),t in l)for(let e=0;e<l[t].length;e++){const n=l[t][e];m.morphAttributes[t][e]=new n.constructor(n.array.slice(0,o*n.itemSize),n.itemSize,n.normalized)}}return m.setIndex(c),m}function toTrianglesDrawMode(e,t){if(t===b)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),e;if(t===I||t===x){let n=e.getIndex();if(null===n){const t=[],i=e.getAttribute("position");if(void 0===i)return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),e;for(let e=0;e<i.count;e++)t.push(e);e.setIndex(t),n=e.getIndex()}const i=n.count-2,r=[];if(t===I)for(let e=1;e<=i;e++)r.push(n.getX(0)),r.push(n.getX(e)),r.push(n.getX(e+1));else for(let e=0;e<i;e++)e%2==0?(r.push(n.getX(e)),r.push(n.getX(e+1)),r.push(n.getX(e+2))):(r.push(n.getX(e+2)),r.push(n.getX(e+1)),r.push(n.getX(e)));r.length/3!==i&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const s=e.clone();return s.setIndex(r),s.clearGroups(),s}return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",t),e}function getpannello(t,n,i,r,s,o,a,A){A||(A={});let l,c,p,{r:h,r1:u,r2:d,r3:g,r4:f,b:m,npt:y}=A;u=u||h||0,d=d||h||0,g=g||h||0,f=f||h||0,y=y||2,m=m||0,(m>=i/2||m>=r/2||m>=s/2)&&(m=0),l="L"==(n=n.trim().toUpperCase())[0]?i:"A"==n[0]?r:s,c="L"==n[1]?i:"A"==n[1]?r:s,p="L"==n[2]?i:"A"==n[2]?r:s;let b=new e.Group;if(!A.nolines){let t=edgesfromgeometry(new e.BoxGeometry(i,r,s));t.position.set(i/2,r/2,s/2),b.add(t)}let I=function pannellogeometry(t,n,i,r,s=0,o=0,a=0,A=0,l=0,c=2,p=!1){let h=hash(`pg--${n}|${i}|${r}|${s}|${o}|${a}|${A}|${l}|${c}|${p?1:0}`);if(n-=.01,i-=.01,r-=.01,!t.geo[h]){n-=2*l,i-=2*l,r-=2*l;let u=getshape();const d=[{x:A,y:0},{x:i-s,y:0},{x:i,y:s},{x:i,y:r-o},{x:i-o,y:r},{x:a,y:r},{x:0,y:r-a},{x:0,y:A}];u.addpt(d[0]),u.addpt(d[1]),s&&u.addpt(raccordabezier(d[0],d[1],d[2],d[3],c)),u.addpt(d[2]),u.addpt(d[3]),o&&u.addpt(raccordabezier(d[2],d[3],d[4],d[5],c)),u.addpt(d[4]),u.addpt(d[5]),a&&u.addpt(raccordabezier(d[4],d[5],d[6],d[7],c)),u.addpt(d[6]),u.addpt(d[7]),o&&u.addpt(raccordabezier(d[6],d[7],d[0],d[1],c)),u.removeduplicate(.01);let g=u.pt;const f=new e.Shape;f.moveTo(g[0].x,g[0].y);for(let e=1;e<g.length;e++)f.lineTo(g[e].x,g[e].y);f.lineTo(g[0].x,g[0].y);const m={depth:n,bevelEnabled:l>0,bevelThickness:l,bevelSize:l,bevelSegments:1};let y=new e.ExtrudeGeometry(f,m);y=mergeVertices(y),uvswap(y,p,!0),t.geo[h]=y}return t.geo[h]}(t,l,c,p,u,d,g,f,m,y,!A.uvswap),x=getmesh(I,[a||o||Di,o||Pi]);x.name="pannello",x.layers.set(1);let C=x;return m&&(x.position.set(m,m,m),C=new e.Group,C.add(x)),x=function meshrotate(e,t,n=0,i=0,r=0){switch(e.trim().toUpperCase()){case"LPA":t.rotation.y=Math.PI/2,t.rotation.x=Math.PI,t.position.set(0,r,0);break;case"ALP":t.rotation.x=Math.PI/2,t.position.set(0,n,0);break;case"APL":t.rotation.x=-Math.PI/2,t.rotation.z=-Math.PI/2;break;case"PLA":break;case"PAL":t.rotation.z=Math.PI/2,t.position.set(r,0,0);break;case"LAP":t.rotation.y=Math.PI/2,t.rotation.z=Math.PI/2}return t}(n,C,l,c,p),b.add(x),b}async function getpannello2(e,t,n,i,r,s,o=0){let a;switch((o<0||o>Math.max(n,i,r)/3)&&(o=0),t){case"lap":a=getextrude(e,getshape().fromrect(n-2*o,i-2*o).pt,r-2*o,[],s,{round:o,stonda:o}),a.position.x=o,a.position.z=r-o,a.position.y=i-o,a.rotation.x=Math.PI;break;case"alp":a=getextrude(e,getshape().fromrect(i-2*o,n-2*o).pt,r-2*o,[],s,{round:o,stonda:o}),a.position.x=o,a.position.z=o,a.position.y=i-o,a.rotation.z=-Math.PI/2;break;case"apl":a=getextrude(e,getshape().fromrect(i-2*o,r-2*o).pt,n-2*o,[],s,{round:o,stonda:o}),a.position.x=o,a.position.z=o,a.position.y=o,a.rotation.y=Math.PI/2,a.rotation.z=Math.PI/2;break;case"pal":a=getextrude(e,getshape().fromrect(r-2*o,i-2*o).pt,n-2*o,[],s,{round:o,stonda:o}),a.position.x=o,a.position.z=r-o,a.position.y=o,a.rotation.y=Math.PI/2;break;case"pla":a=getextrude(e,getshape().fromrect(r-2*o,n-2*o).pt,i-2*o,[],s,{round:o,stonda:o}),a.rotation.z=-Math.PI/2,a.rotation.x=-Math.PI/2,a.position.x=o,a.position.z=o,a.position.y=o;break;default:a=getextrude(e,getshape().fromrect(n-2*o,r-2*o).pt,i-2*o,[],s,{round:o,stonda:o}),a.position.x=o,a.position.z=o,a.rotation.x=Math.PI/2,a.position.y=i-o}return a}function earcut(e,t,n=2){const i=t&&t.length,r=i?t[0]*n:e.length;let s=linkedList(e,0,r,n,!0);const o=[];if(!s||s.next===s.prev)return o;let a,A,l;if(i&&(s=function eliminateHoles(e,t,n,i){const r=[];for(let n=0,s=t.length;n<s;n++){const o=linkedList(e,t[n]*i,n<s-1?t[n+1]*i:e.length,i,!1);o===o.next&&(o.steiner=!0),r.push(getLeftmost(o))}r.sort(compareXYSlope);for(let e=0;e<r.length;e++)n=eliminateHole(r[e],n);return n}(e,t,s,n)),e.length>80*n){a=1/0,A=1/0;let t=-1/0,i=-1/0;for(let s=n;s<r;s+=n){const n=e[s],r=e[s+1];n<a&&(a=n),r<A&&(A=r),n>t&&(t=n),r>i&&(i=r)}l=Math.max(t-a,i-A),l=0!==l?32767/l:0}return earcutLinked(s,o,n,a,A,l,0),o}function linkedList(e,t,n,i,r){let s;if(r===function signedArea(e,t,n,i){let r=0;for(let s=t,o=n-i;s<n;s+=i)r+=(e[o]-e[s])*(e[s+1]+e[o+1]),o=s;return r}(e,t,n,i)>0)for(let r=t;r<n;r+=i)s=insertNode(r/i|0,e[r],e[r+1],s);else for(let r=n-i;r>=t;r-=i)s=insertNode(r/i|0,e[r],e[r+1],s);return s&&equals(s,s.next)&&(removeNode(s),s=s.next),s}function filterPoints(e,t){if(!e)return e;t||(t=e);let n,i=e;do{if(n=!1,i.steiner||!equals(i,i.next)&&0!==area(i.prev,i,i.next))i=i.next;else{if(removeNode(i),i=t=i.prev,i===i.next)break;n=!0}}while(n||i!==t);return t}function earcutLinked(e,t,n,i,r,s,o){if(!e)return;!o&&s&&function indexCurve(e,t,n,i){let r=e;do{0===r.z&&(r.z=zOrder(r.x,r.y,t,n,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==e);r.prevZ.nextZ=null,r.prevZ=null,function sortLinked(e){let t,n=1;do{let i,r=e;e=null;let s=null;for(t=0;r;){t++;let o=r,a=0;for(let e=0;e<n&&(a++,o=o.nextZ,o);e++);let A=n;for(;a>0||A>0&&o;)0!==a&&(0===A||!o||r.z<=o.z)?(i=r,r=r.nextZ,a--):(i=o,o=o.nextZ,A--),s?s.nextZ=i:e=i,i.prevZ=s,s=i;r=o}s.nextZ=null,n*=2}while(t>1);return e}(r)}(e,i,r,s);let a=e;for(;e.prev!==e.next;){const A=e.prev,l=e.next;if(s?isEarHashed(e,i,r,s):isEar(e))t.push(A.i,e.i,l.i),removeNode(e),e=l.next,a=l.next;else if((e=l)===a){o?1===o?earcutLinked(e=cureLocalIntersections(filterPoints(e),t),t,n,i,r,s,2):2===o&&splitEarcut(e,t,n,i,r,s):earcutLinked(filterPoints(e),t,n,i,r,s,1);break}}}function isEar(e){const t=e.prev,n=e,i=e.next;if(area(t,n,i)>=0)return!1;const r=t.x,s=n.x,o=i.x,a=t.y,A=n.y,l=i.y,c=Math.min(r,s,o),p=Math.min(a,A,l),h=Math.max(r,s,o),u=Math.max(a,A,l);let d=i.next;for(;d!==t;){if(d.x>=c&&d.x<=h&&d.y>=p&&d.y<=u&&pointInTriangleExceptFirst(r,a,s,A,o,l,d.x,d.y)&&area(d.prev,d,d.next)>=0)return!1;d=d.next}return!0}function isEarHashed(e,t,n,i){const r=e.prev,s=e,o=e.next;if(area(r,s,o)>=0)return!1;const a=r.x,A=s.x,l=o.x,c=r.y,p=s.y,h=o.y,u=Math.min(a,A,l),d=Math.min(c,p,h),g=Math.max(a,A,l),f=Math.max(c,p,h),m=zOrder(u,d,t,n,i),y=zOrder(g,f,t,n,i);let b=e.prevZ,I=e.nextZ;for(;b&&b.z>=m&&I&&I.z<=y;){if(b.x>=u&&b.x<=g&&b.y>=d&&b.y<=f&&b!==r&&b!==o&&pointInTriangleExceptFirst(a,c,A,p,l,h,b.x,b.y)&&area(b.prev,b,b.next)>=0)return!1;if(b=b.prevZ,I.x>=u&&I.x<=g&&I.y>=d&&I.y<=f&&I!==r&&I!==o&&pointInTriangleExceptFirst(a,c,A,p,l,h,I.x,I.y)&&area(I.prev,I,I.next)>=0)return!1;I=I.nextZ}for(;b&&b.z>=m;){if(b.x>=u&&b.x<=g&&b.y>=d&&b.y<=f&&b!==r&&b!==o&&pointInTriangleExceptFirst(a,c,A,p,l,h,b.x,b.y)&&area(b.prev,b,b.next)>=0)return!1;b=b.prevZ}for(;I&&I.z<=y;){if(I.x>=u&&I.x<=g&&I.y>=d&&I.y<=f&&I!==r&&I!==o&&pointInTriangleExceptFirst(a,c,A,p,l,h,I.x,I.y)&&area(I.prev,I,I.next)>=0)return!1;I=I.nextZ}return!0}function cureLocalIntersections(e,t){let n=e;do{const i=n.prev,r=n.next.next;!equals(i,r)&&intersects(i,n,n.next,r)&&locallyInside(i,r)&&locallyInside(r,i)&&(t.push(i.i,n.i,r.i),removeNode(n),removeNode(n.next),n=e=r),n=n.next}while(n!==e);return filterPoints(n)}function splitEarcut(e,t,n,i,r,s){let o=e;do{let e=o.next.next;for(;e!==o.prev;){if(o.i!==e.i&&isValidDiagonal(o,e)){let a=splitPolygon(o,e);return o=filterPoints(o,o.next),a=filterPoints(a,a.next),earcutLinked(o,t,n,i,r,s,0),void earcutLinked(a,t,n,i,r,s,0)}e=e.next}o=o.next}while(o!==e)}function compareXYSlope(e,t){let n=e.x-t.x;if(0===n&&(n=e.y-t.y,0===n)){n=(e.next.y-e.y)/(e.next.x-e.x)-(t.next.y-t.y)/(t.next.x-t.x)}return n}function eliminateHole(e,t){const n=function findHoleBridge(e,t){let n=t;const i=e.x,r=e.y;let s,o=-1/0;if(equals(e,n))return n;do{if(equals(e,n.next))return n.next;if(r<=n.y&&r>=n.next.y&&n.next.y!==n.y){const e=n.x+(r-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(e<=i&&e>o&&(o=e,s=n.x<n.next.x?n:n.next,e===i))return s}n=n.next}while(n!==t);if(!s)return null;const a=s,A=s.x,l=s.y;let c=1/0;n=s;do{if(i>=n.x&&n.x>=A&&i!==n.x&&pointInTriangle(r<l?i:o,r,A,l,r<l?o:i,r,n.x,n.y)){const t=Math.abs(r-n.y)/(i-n.x);locallyInside(n,e)&&(t<c||t===c&&(n.x>s.x||n.x===s.x&§orContainsSector(s,n)))&&(s=n,c=t)}n=n.next}while(n!==a);return s}(e,t);if(!n)return t;const i=splitPolygon(n,e);return filterPoints(i,i.next),filterPoints(n,n.next)}function sectorContainsSector(e,t){return area(e.prev,e,t.prev)<0&&area(t.next,e,e.next)<0}function zOrder(e,t,n,i,r){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-n)*r|0)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-i)*r|0)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function getLeftmost(e){let t=e,n=e;do{(t.x<n.x||t.x===n.x&&t.y<n.y)&&(n=t),t=t.next}while(t!==e);return n}function pointInTriangle(e,t,n,i,r,s,o,a){return(r-o)*(t-a)>=(e-o)*(s-a)&&(e-o)*(i-a)>=(n-o)*(t-a)&&(n-o)*(s-a)>=(r-o)*(i-a)}function pointInTriangleExceptFirst(e,t,n,i,r,s,o,a){return!(e===o&&t===a)&&pointInTriangle(e,t,n,i,r,s,o,a)}function isValidDiagonal(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function intersectsPolygon(e,t){let n=e;do{if(n.i!==e.i&&n.next.i!==e.i&&n.i!==t.i&&n.next.i!==t.i&&intersects(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}(e,t)&&(locallyInside(e,t)&&locallyInside(t,e)&&function middleInside(e,t){let n=e,i=!1;const r=(e.x+t.x)/2,s=(e.y+t.y)/2;do{n.y>s!=n.next.y>s&&n.next.y!==n.y&&r<(n.next.x-n.x)*(s-n.y)/(n.next.y-n.y)+n.x&&(i=!i),n=n.next}while(n!==e);return i}(e,t)&&(area(e.prev,e,t.prev)||area(e,t.prev,t))||equals(e,t)&&area(e.prev,e,e.next)>0&&area(t.prev,t,t.next)>0)}function area(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function equals(e,t){return e.x===t.x&&e.y===t.y}function intersects(e,t,n,i){const r=sign(area(e,t,n)),s=sign(area(e,t,i)),o=sign(area(n,i,e)),a=sign(area(n,i,t));return r!==s&&o!==a||(!(0!==r||!onSegment(e,n,t))||(!(0!==s||!onSegment(e,i,t))||(!(0!==o||!onSegment(n,e,i))||!(0!==a||!onSegment(n,t,i)))))}function onSegment(e,t,n){return t.x<=Math.max(e.x,n.x)&&t.x>=Math.min(e.x,n.x)&&t.y<=Math.max(e.y,n.y)&&t.y>=Math.min(e.y,n.y)}function sign(e){return e>0?1:e<0?-1:0}function locallyInside(e,t){return area(e.prev,e,e.next)<0?area(e,t,e.next)>=0&&area(e,e.prev,t)>=0:area(e,t,e.prev)<0||area(e,e.next,t)<0}function splitPolygon(e,t){const n=createNode(e.i,e.x,e.y),i=createNode(t.i,t.x,t.y),r=e.next,s=t.prev;return e.next=t,t.prev=e,n.next=r,r.prev=n,i.next=n,n.prev=i,s.next=i,i.prev=s,i}function insertNode(e,t,n,i){const r=createNode(e,t,n);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function removeNode(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function createNode(e,t,n){return{i:e,x:t,y:n,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function unifyVertices(e,t,n){const i=new Map,r=[],s=[],o=[];for(let a=0;a<n.length;a++){const A=n[a],l=e[3*A+0],c=e[3*A+1],p=e[3*A+2],h=t[2*A+0],u=t[2*A+1],d=`${l},${c},${p}|${h},${u}`;if(i.has(d))o.push(i.get(d));else{const e=r.length/3;i.set(d,e),r.push(l,c,p),s.push(h,u),o.push(e)}}return{vertices:r,uvs:s,indices:o}}function infoestrudi(e,t,n,i,r){i||(i={}),n||(n=[]);let s=i.p0||0,o=Math.tan(i.coeffbase1*ft||0),a=Math.tan(i.coeffbase2*ft||0),A=t||i.p1||20,l=Math.tan(i.coefftop1*ft||0),c=Math.tan(i.coefftop2*ft||0),{mi:p,ma:h}=e.pt.reduce(((e,t)=>(e.mi.x=Math.min(e.mi.x,t.x),e.mi.y=Math.min(e.mi.y,t.y),e.ma.x=Math.max(e.ma.x,t.x),e.ma.y=Math.max(e.ma.y,t.y),e)),{mi:{x:1e9,y:1e9},ma:{x:-1e9,y:-1e9}}),u=0,d=1e9;function getpars(e){e.z1=getzeta(e.x,e.y,s,o,a,r),e.z2=getzeta(e.x,e.y,A,l,c,r),e.l=Math.abs(e.z2-e.z1)}for(let e of n)getpars(e);getpars(p),getpars(h);let g=[{x:p.x,y:p.y},{x:h.x,y:p.y},{x:h.x,y:h.y},{x:p.x,y:h.y}];for(let e of g)getpars(e),e.l>u&&(u=e.l),e.l<d&&(d=e.l);return{aini:i.coeffbase1||0,aini2:i.coeffbase2||0,afin:i.coefftop1||0,afin2:i.coefftop2||0,pts:n,mi:p,ma:h,rect:g,dimx:h.x-p.x,dimy:h.y-p.y,lnom:A-s,lmax:u,lmin:d,lmed:(u+d)/2}}function getzeta(e,t,n,i,r,s,o=!1){let a=e*i+t*r+n;if(s){let e=s.xfromy(-t,0,!0);o?a-=e:a=e}return a}function sidegeomfromshapes(t,n,i,r,s=!1,o=!1,a=!1){if(i&&r){if(i.length!==r.length)throw new Error("shapes with different length");if(i.length<2)throw new Error("I percorsi devono contenere almeno due punti ciascuno.");if(!t.geo[n]){const A=[],l=[],c=[],p=i.length,addpts=e=>{for(const t of e)A.push(t.x,t.y,t.z),a?l.push(t.v/1e3,t.u/1e3):l.push(t.u/1e3,t.v/1e3)},equalpos=(e,t)=>e.x===t.x&&e.y===t.y&&e.z===t.z,addindexquad=(e,t,n,i)=>{s?c.push(e,n,t,n,i,t):c.push(e,t,n,n,t,i)};addpts(i),addpts(r);for(let e=0;e<p-1;e++){const t=e+1;equalpos(i[e],i[t])||addindexquad(e,t,e+p,t+p)}const h=new e.BufferGeometry;if(o){let t=unifyVertices(A,l,c);h.setAttribute("position",new e.Float32BufferAttribute(t.vertices,3)),h.setAttribute("uv",new e.Float32BufferAttribute(t.uvs,2)),h.setIndex(t.indices)}else h.setAttribute("position",new e.Float32BufferAttribute(A,3)),h.setAttribute("uv",new e.Float32BufferAttribute(l,2)),h.setIndex(c);h.computeVertexNormals(),h.computeTangents?.(),t.geo[n]=h}return t.geo[n]}}function bottomgeomfromshape(t,n,i,r,s=0,o=0,a=0,A=null,l=!1,c=!1){let p=`bg:${s}|${o}${a}|${i.key}|${n}|${A?.key||""}|${c?1:0}`;for(let h of r)p=`${p}|${h.key}`;if(p=hash(p),!t.geo[p]){let u,d=[],g=[],f=i.pt.length;d=i.vec;const m=new e.BufferGeometry,y=[],b=[],I=[];function addvertexes(e,t){let i=y.length/3;for(let i=0;i<e.length;i++){const r=e[i],l=t[2*r],p=-t[2*r+1],h=getzeta(l,p,s,o,a,A,n);y.push(l,p,h),c?b.push(p/1e3,l/1e3):b.push(l/1e3,p/1e3)}for(let t=0;t<e.length;t+=3)n?I.push(t+i,t+i+2,t+i+1):I.push(t+i,t+i+1,t+i+2)}if(A){let x=i.sliceony(A);for(let C of x){let B=C.flatMap((e=>[e.x,e.y]));addvertexes(earcut(B,[]),B)}}else if(Array.isArray(r)&&r.length){for(let E of r)g.push(f),f+=E.pt.length,d=[...d,...E.vec];u=earcut(d,g),addvertexes(u,d)}else u=earcut(d),addvertexes(u,d);if(l){let w=unifyVertices(y,b,I);m.setAttribute("position",new e.Float32BufferAttribute(w.vertices,3)),m.setAttribute("uv",new e.Float32BufferAttribute(w.uvs,2)),m.setIndex(w.indices)}else m.setAttribute("position",new e.Float32BufferAttribute(y,3)),m.setAttribute("uv",new e.Float32BufferAttribute(b,2)),m.setIndex(I);m.computeVertexNormals(),m.computeTangents?.(),t.geo[p]=m}return t.geo[p]}function estrusorotate(e,t,n=0){switch(e.trim().toUpperCase().slice(0,1)){case"A":t.rotation.x=-Math.PI/2;break;case"L":t.rotation.y=Math.PI/2,t.rotation.z=Math.PI;break;case"P":t.rotation.z=Math.PI/2}return t}function estruso(t,n,i,r,s,o,a){a||(a={}),o||(o=[]),Array.isArray(o)||(o=[o,o,o]);let A=a.p0||0,l=Math.tan(a.coeffbase1*ft||0),c=Math.tan(a.coeffbase2*ft||0),p=i||a.p1||20,h=Math.tan(a.coefftop1*ft||0),u=Math.tan(a.coefftop2*ft||0),d=a.shapetop,g=a.shapebase||a.shapebottom;d&&(u=0),g&&(u=0);let f=g?g.key:"",m=d?d.key:"",y=a.notopholes||!1,b=a.nobottomholes||a.nobaseholes||!1,I=a.invert||!1,x=a.open||!1,C=new e.Group;if(r){if(!a.nobase){let e=s;b&&(e=Array.isArray(b)?e.filter(((e,t)=>!b[t])):[]);let n=bottomgeomfromshape(t,!a.notop,r,x?[]:e,A,l,c,g,!1,a.uvswap);a.nolines||C.add(edgesfromgeometry(n)),C.add(getmesh(n,o[0]||wi))}if(!a.notop){let e=s;y&&(e=Array.isArray(y)?e.filter(((e,t)=>!y[t])):[]);let n=bottomgeomfromshape(t,!1,r,x?[]:e,p,h,u,d,!1,a.uvswap);C.add(getmesh(n,o[1]||o[0]||wi)),a.nolines||C.add(edgesfromgeometry(n))}if(!a.nosides){let e=r.to3d(0,A,l,-c,x,g,!I),n=r.to3d(1,p,h,-u,x,d,I),i=`${r.key}${I?1:0}|${A}|${p}|${l}|${c||f}|${h}|${u||m}|${x}|${a.wvswap?1:0}`,B=sidegeomfromshapes(t,i,e,n,!1,!1,a.uvswap);if(a.nolines||a.nosidelines||C.add(edgesfromgeometry(B)),C.add(getmesh(B,o[2]||o[0]||wi)),s&&!x)for(let r=0;r<s.length;r++){let d=s[r];if(Array.isArray(y)){if(y[r])continue}else if(y)continue;if(Array.isArray(b)){if(b[r])continue}else if(b)continue;e=d.to3d(0,A,l,c),n=d.to3d(0,p,h,u),i=`${d.key}|${A}|${p}|${l}|${c}|${h}|${u}`;let g=sidegeomfromshapes(t,i,e,n,!0);a.nolines||a.nosidelines||C.add(edgesfromgeometry(g)),C.add(getmesh(g,o[3]||o[0]||wi))}}return estrusorotate(n,C,i)}return C}function revolve(t,n,i,r,s){s||(s={});let o=s.segmenti??12,a=hash(`rev|${n.key}|${i}|${o}|${s?.uvswap}`),A=t.geo[a],l=new e.Group;if(!A){const i=n.pt.map((t=>new e.Vector2(t.x,t.y)));A=new e.LatheGeometry(i,o,0,2*Math.PI),uvswap(A,s.uvswap,!0),t.geo[a]=A}const c=new e.Mesh(A,r);return l.add(c),s.nolines||s.nosidelines||l.add(edgesfromgeometry(A)),l}function estrusopat(t,n,i,r,s,o,a){a||(a={});let A=a.invert;o||(o=[]);let l=a.open,c=a.closepat;if(!i.pt?.length)return;let p=s.to3d(0,0,0,0,l),h=new e.Group;if(!a.nobase&&!a.open&&!c){let n=new e.Group,A=angle3point(r[0],i.pt[0],i.pt[1])+Math.PI/2,l=bottomgeomfromshape(t,!1,s,[],0,-Math.tan(A),0,null,!1,a.uvswap);n.add(getmesh(l,o[0]||wi)),n.add(edgesfromgeometry(l));let c=i.infosegmento(0,!0);h.add(posiziona(n,{sl:c.x,sp:c.y,sa:0,ay:90-c.ang}))}if(!a.notop&&!a.open&&!c){let n=new e.Group,A=-(angle3point(i.pt[i.npt-2],i.pt[i.npt-1],r[i.npt-1])+Math.PI/2),l=bottomgeomfromshape(t,!0,s,[],0,-Math.tan(A),0,null,!1,a.uvswap);n.add(getmesh(l,o[1]||o[0]||wi)),n.add(edgesfromgeometry(l));let c=i.infosegmento(i.pt.length-1,!0);h.add(posiziona(n,{sl:c.x,sp:c.y,sa:0,ay:90-c.ang}))}if(!a.nosides){const n=function sidegeomfrompat(t,n,i,r,s,o,a=!1){let A=`bsg:${n.key}|${i.key}|${s}|${o}|${a}`;if(i.npt==r.length){if(A=hash(A),!t.geo[A]){const l=[],c=[],p=[],h=n.length,equalpos=(e,t)=>e.x===t.x&&e.y===t.y&&e.z===t.z;let u=0,d=i.pt,g=i.npt;const f=.001,addpts=(t,n,i,r)=>{for(const s of t){let t=new e.Vector3(s.x,s.y,s.x*r);t.applyMatrix4(n),l.push(t.x,t.y,t.z),a?c.push(s.u*f,(s.v+i)*f):c.push((s.v+i)*f,s.u*f)}};let m=g;for(let t=0;t<g;t++){let s;s=t<g-1?angle3point(r[t],d[t],d[t+1])+Math.PI/2:-(angle3point(d[t-1],d[t],r[t])+Math.PI/2);let o=-Math.tan(s),a=i.infosegmento(t,!0),A=new e.Object3D;A.position.set(a.x,0,a.y),A.rotation.set(0,(90-a.ang)*ft,0),A.updateMatrix(),addpts(n,A.matrix,u,o),u+=a.l}if(s){let t=i.infosegmento(0,!0),s=new e.Object3D;s.position.set(t.x,0,t.y),s.rotation.set(0,(90-t.ang)*ft,0);let o=angle3point(d[g-1],d[0],r[0])+Math.PI/2,a=-Math.tan(o);s.updateMatrix(),addpts(n,s.matrix,u,a),u+=t.l,m++}for(let e=0;e<m-1;e++)for(let t=0;t<h-1;t++){const addindexquad=(e,t,n,i)=>{o?p.push(e,n,t,n,i,t):p.push(e,t,n,n,t,i)},i=t+1;equalpos(n[t],n[i])||addindexquad(t+e*h,i+e*h,t+(e+1)*h,i+(e+1)*h)}const y=new e.BufferGeometry;y.setAttribute("position",new e.Float32BufferAttribute(l,3)),y.setAttribute("uv",new e.Float32BufferAttribute(c,2)),y.setIndex(p),y.computeVertexNormals(),y.computeTangents?.(),t[A]=y}return t[A]}}(t,p,i,r,c?1:0,A?1:0,a.uvswap);n&&(a.nolines||a.nosidelines||h.add(edgesfromgeometry(n)),h.add(getmesh(n,o[2]||o[0]||wi)))}return estrusorotate(n,h,0)}async function spritemat(t,n){try{let i={transparent:!0,depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1};if(n.startsWith("#"))i.color=n;else{let e=await t.tex(n,1e3,1e3);e?i.map=e:i.color="black"}return new e.SpriteMaterial(i)}catch(e){return wi}}function getsprite0(t,n,i,r,s,o={}){o||(o={});let{size:a=50,pick:A=!1,screen:l=!1,sizex:c,sizey:p}=o;const h=new e.Sprite(s);h.position.set(0,0,0),h.userData.issprite=!0,h.userData.ispunto=t,h.userData.ispick=A,h.userData.isScreen=l,h.renderOrder=999,h.layers.set(29),h.name=t?"_punto":"_sprite";let u=new e.Group;return u.position.set(n,i,r),u.scale.set(c||a,p||c||a,1),u.add(h),u.traverse((e=>{e.material&&(e.material.depthTest=!1,e.material.depthWrite=!1)})),u.renderOrder=999,u}async function getpunto(t,n,i,r,s="yellow",o){o||(o={size:20}),o.screen=!0;const a=await function createCircleTexture(t,n=64,i="rgba(255,0,0,1)"){const r=`ct|${n}|${i}`;if(!t.textures[r]){const s=document.createElement("canvas");s.width=s.height=n;const o=s.getContext("2d"),a=n/2;o.clearRect(0,0,n,n),o.fillStyle=i,o.beginPath(),o.arc(a,a,a,0,2*Math.PI),o.fill();const A=new e.CanvasTexture(s);A.needsUpdate=!0,t.textures[r]=A}return t.textures[r]}(t,64,s);return getsprite0(!0,n,i,r,new e.SpriteMaterial({map:a,transparent:!0,fog:!1,toneMapped:!1}),o)}function getsprite(e,t,n,i,r,s={}){return getsprite0(!1,t,n,i,r,s)}class GLTFLoader extends E{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register((function(e){return new GLTFMaterialsClearcoatExtension(e)})),this.register((function(e){return new GLTFMaterialsDispersionExtension(e)})),this.register((function(e){return new GLTFTextureBasisUExtension(e)})),this.register((function(e){return new GLTFTextureWebPExtension(e)})),this.register((function(e){return new GLTFTextureAVIFExtension(e)})),this.register((function(e){return new GLTFMaterialsSheenExtension(e)})),this.register((function(e){return new GLTFMaterialsTransmissionExtension(e)})),this.register((function(e){return new GLTFMaterialsVolumeExtension(e)})),this.register((function(e){return new GLTFMaterialsIorExtension(e)})),this.register((function(e){return new GLTFMaterialsEmissiveStrengthExtension(e)})),this.register((function(e){return new GLTFMaterialsSpecularExtension(e)})),this.register((function(e){return new GLTFMaterialsIridescenceExtension(e)})),this.register((function(e){return new GLTFMaterialsAnisotropyExtension(e)})),this.register((function(e){return new GLTFMaterialsBumpExtension(e)})),this.register((function(e){return new GLTFLightsExtension(e)})),this.register((function(e){return new GLTFMeshoptCompression(e)})),this.register((function(e){return new GLTFMeshGpuInstancing(e)}))}load(e,t,n,i){const r=this;let s;if(""!==this.resourcePath)s=this.resourcePath;else if(""!==this.path){const t=w.extractUrlBase(e);s=w.resolveURL(t,this.path)}else s=w.extractUrlBase(e);this.manager.itemStart(e);const _onError=function(t){i?i(t):console.error(t),r.manager.itemError(e),r.manager.itemEnd(e)},o=new v(this.manager);o.setPath(this.path),o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,(function(n){try{r.parse(n,s,(function(n){t(n),r.manager.itemEnd(e)}),_onError)}catch(e){_onError(e)}}),n,_onError)}setDRACOLoader(e){return this.dracoLoader=e,this}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return-1===this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.push(e),this}unregister(e){return-1!==this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,n,i){let r;const s={},o={},a=new TextDecoder;if("string"==typeof e)r=JSON.parse(e);else if(e instanceof ArrayBuffer){if(a.decode(new Uint8Array(e,0,4))===Gi){try{s[Oi.KHR_BINARY_GLTF]=new GLTFBinaryExtension(e)}catch(e){return void(i&&i(e))}r=JSON.parse(s[Oi.KHR_BINARY_GLTF].content)}else r=JSON.parse(a.decode(e))}else r=e;if(void 0===r.asset||r.asset.version[0]<2)return void(i&&i(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported.")));const A=new GLTFParser(r,{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 e=0;e<this.pluginCallbacks.length;e++){const t=this.pluginCallbacks[e](A);t.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),o[t.name]=t,s[t.name]=!0}if(r.extensionsUsed)for(let e=0;e<r.extensionsUsed.length;++e){const t=r.extensionsUsed[e],n=r.extensionsRequired||[];switch(t){case Oi.KHR_MATERIALS_UNLIT:s[t]=new GLTFMaterialsUnlitExtension;break;case Oi.KHR_DRACO_MESH_COMPRESSION:s[t]=new GLTFDracoMeshCompressionExtension(r,this.dracoLoader);break;case Oi.KHR_TEXTURE_TRANSFORM:s[t]=new GLTFTextureTransformExtension;break;case Oi.KHR_MESH_QUANTIZATION:s[t]=new GLTFMeshQuantizationExtension;break;default:n.indexOf(t)>=0&&void 0===o[t]&&console.warn('THREE.GLTFLoader: Unknown extension "'+t+'".')}}A.setExtensions(s),A.setPlugins(o),A.parse(n,i)}parseAsync(e,t){const n=this;return new Promise((function(i,r){n.parse(e,t,i,r)}))}}function GLTFRegistry(){let e={};return{get:function(t){return e[t]},add:function(t,n){e[t]=n},remove:function(t){delete e[t]},removeAll:function(){e={}}}}const Oi={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class GLTFLightsExtension{constructor(e){this.parser=e,this.name=Oi.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let n=0,i=t.length;n<i;n++){const i=t[n];i.extensions&&i.extensions[this.name]&&void 0!==i.extensions[this.name].light&&e._addNodeRef(this.cache,i.extensions[this.name].light)}}_loadLight(e){const t=this.parser,n="light:"+e;let i=t.cache.get(n);if(i)return i;const r=t.json,s=((r.extensions&&r.extensions[this.name]||{}).lights||[])[e];let o;const a=new T(16777215);void 0!==s.color&&a.setRGB(s.color[0],s.color[1],s.color[2],S);const A=void 0!==s.range?s.range:0;switch(s.type){case"directional":o=new _(a),o.target.position.set(0,0,-1),o.add(o.target);break;case"point":o=new L(a),o.distance=A;break;case"spot":o=new D(a),o.distance=A,s.spot=s.spot||{},s.spot.innerConeAngle=void 0!==s.spot.innerConeAngle?s.spot.innerConeAngle:0,s.spot.outerConeAngle=void 0!==s.spot.outerConeAngle?s.spot.outerConeAngle:Math.PI/4,o.angle=s.spot.outerConeAngle,o.penumbra=1-s.spot.innerConeAngle/s.spot.outerConeAngle,o.target.position.set(0,0,-1),o.add(o.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+s.type)}return o.position.set(0,0,0),assignExtrasToUserData(o,s),void 0!==s.intensity&&(o.intensity=s.intensity),o.name=t.createUniqueName(s.name||"light_"+e),i=Promise.resolve(o),t.cache.add(n,i),i}getDependency(e,t){if("light"===e)return this._loadLight(t)}createNodeAttachment(e){const t=this,n=this.parser,i=n.json.nodes[e],r=(i.extensions&&i.extensions[this.name]||{}).light;return void 0===r?null:this._loadLight(r).then((function(e){return n._getNodeRef(t.cache,r,e)}))}}class GLTFMaterialsUnlitExtension{constructor(){this.name=Oi.KHR_MATERIALS_UNLIT}getMaterialType(){return ne}extendParams(e,t,n){const i=[];e.color=new T(1,1,1),e.opacity=1;const r=t.pbrMetallicRoughness;if(r){if(Array.isArray(r.baseColorFactor)){const t=r.baseColorFactor;e.color.setRGB(t[0],t[1],t[2],S),e.opacity=t[3]}void 0!==r.baseColorTexture&&i.push(n.assignTexture(e,"map",r.baseColorTexture,M))}return Promise.all(i)}}class GLTFMaterialsEmissiveStrengthExtension{constructor(e){this.parser=e,this.name=Oi.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const n=this.parser.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=n.extensions[this.name].emissiveStrength;return void 0!==i&&(t.emissiveIntensity=i),Promise.resolve()}}class GLTFMaterialsClearcoatExtension{constructor(e){this.parser=e,this.name=Oi.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?P:null}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],o=i.extensions[this.name];if(void 0!==o.clearcoatFactor&&(t.clearcoat=o.clearcoatFactor),void 0!==o.clearcoatTexture&&s.push(n.assignTexture(t,"clearcoatMap",o.clearcoatTexture)),void 0!==o.clearcoatRoughnessFactor&&(t.clearcoatRoughness=o.clearcoatRoughnessFactor),void 0!==o.clearcoatRoughnessTexture&&s.push(n.assignTexture(t,"clearcoatRoughnessMap",o.clearcoatRoughnessTexture)),void 0!==o.clearcoatNormalTexture&&(s.push(n.assignTexture(t,"clearcoatNormalMap",o.clearcoatNormalTexture)),void 0!==o.clearcoatNormalTexture.scale)){const e=o.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new r(e,e)}return Promise.all(s)}}class GLTFMaterialsDispersionExtension{constructor(e){this.parser=e,this.name=Oi.KHR_MATERIALS_DISPERSION}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?P:null}extendMaterialParams(e,t){const n=this.parser.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=n.extensions[this.name];return t.dispersion=void 0!==i.dispersion?i.dispersion:0,Promise.resolve()}}class GLTFMaterialsIridescenceExtension{constructor(e){this.parser=e,this.name=Oi.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?P:null}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[],s=i.extensions[this.name];return void 0!==s.iridescenceFactor&&(t.iridescence=s.iridescenceFactor),void 0!==s.iridescenceTexture&&r.push(n.assignTexture(t,"iridescenceMap",s.iridescenceTexture)),void 0!==s.iridescenceIor&&(t.iridescenceIOR=s.iridescenceIor),void 0===t.iridescenceThicknessRange&&(t.iridescenceThicknessRange=[100,400]),void 0!==s.iridescenceThicknessMinimum&&(t.iridescenceThicknessRange[0]=s.iridescenceThicknessMinimum),void 0!==s.iridescenceThicknessMaximum&&(t.iridescenceThicknessRange[1]=s.iridescenceThicknessMaximum),void 0!==s.iridescenceThicknessTexture&&r.push(n.assignTexture(t,"iridescenceThicknessMap",s.iridescenceThicknessTexture)),Promise.all(r)}}class GLTFMaterialsSheenExtension{constructor(e){this.parser=e,this.name=Oi.KHR_MATERIALS_SHEEN}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?P:null}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[];t.sheenColor=new T(0,0,0),t.sheenRoughness=0,t.sheen=1;const s=i.extensions[this.name];if(void 0!==s.sheenColorFactor){const e=s.sheenColorFactor;t.sheenColor.setRGB(e[0],e[1],e[2],S)}return void 0!==s.sheenRoughnessFactor&&(t.sheenRoughness=s.sheenRoughnessFactor),void 0!==s.sheenColorTexture&&r.push(n.assignTexture(t,"sheenColorMap",s.sheenColorTexture,M)),void 0!==s.sheenRoughnessTexture&&r.push(n.assignTexture(t,"sheenRoughnessMap",s.sheenRoughnessTexture)),Promise.all(r)}}class GLTFMaterialsTransmissionExtension{constructor(e){this.parser=e,this.name=Oi.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?P:null}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[],s=i.extensions[this.name];return void 0!==s.transmissionFactor&&(t.transmission=s.transmissionFactor),void 0!==s.transmissionTexture&&r.push(n.assignTexture(t,"transmissionMap",s.transmissionTexture)),Promise.all(r)}}class GLTFMaterialsVolumeExtension{constructor(e){this.parser=e,this.name=Oi.KHR_MATERIALS_VOLUME}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?P:null}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[],s=i.extensions[this.name];t.thickness=void 0!==s.thicknessFactor?s.thicknessFactor:0,void 0!==s.thicknessTexture&&r.push(n.assignTexture(t,"thicknessMap",s.thicknessTexture)),t.attenuationDistance=s.attenuationDistance||1/0;const o=s.attenuationColor||[1,1,1];return t.attenuationColor=(new T).setRGB(o[0],o[1],o[2],S),Promise.all(r)}}class GLTFMaterialsIorExtension{constructor(e){this.parser=e,this.name=Oi.KHR_MATERIALS_IOR}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?P:null}extendMaterialParams(e,t){const n=this.parser.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=n.extensions[this.name];return t.ior=void 0!==i.ior?i.ior:1.5,Promise.resolve()}}class GLTFMaterialsSpecularExtension{constructor(e){this.parser=e,this.name=Oi.KHR_MATERIALS_SPECULAR}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?P:null}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[],s=i.extensions[this.name];t.specularIntensity=void 0!==s.specularFactor?s.specularFactor:1,void 0!==s.specularTexture&&r.push(n.assignTexture(t,"specularIntensityMap",s.specularTexture));const o=s.specularColorFactor||[1,1,1];return t.specularColor=(new T).setRGB(o[0],o[1],o[2],S),void 0!==s.specularColorTexture&&r.push(n.assignTexture(t,"specularColorMap",s.specularColorTexture,M)),Promise.all(r)}}class GLTFMaterialsBumpExtension{constructor(e){this.parser=e,this.name=Oi.EXT_MATERIALS_BUMP}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?P:null}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[],s=i.extensions[this.name];return t.bumpScale=void 0!==s.bumpFactor?s.bumpFactor:1,void 0!==s.bumpTexture&&r.push(n.assignTexture(t,"bumpMap",s.bumpTexture)),Promise.all(r)}}class GLTFMaterialsAnisotropyExtension{constructor(e){this.parser=e,this.name=Oi.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?P:null}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[],s=i.extensions[this.name];return void 0!==s.anisotropyStrength&&(t.anisotropy=s.anisotropyStrength),void 0!==s.anisotropyRotation&&(t.anisotropyRotation=s.anisotropyRotation),void 0!==s.anisotropyTexture&&r.push(n.assignTexture(t,"anisotropyMap",s.anisotropyTexture)),Promise.all(r)}}class GLTFTextureBasisUExtension{constructor(e){this.parser=e,this.name=Oi.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,n=t.json,i=n.textures[e];if(!i.extensions||!i.extensions[this.name])return null;const r=i.extensions[this.name],s=t.options.ktx2Loader;if(!s){if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,r.source,s)}}class GLTFTextureWebPExtension{constructor(e){this.parser=e,this.name=Oi.EXT_TEXTURE_WEBP}loadTexture(e){const t=this.name,n=this.parser,i=n.json,r=i.textures[e];if(!r.extensions||!r.extensions[t])return null;const s=r.extensions[t],o=i.images[s.source];let a=n.textureLoader;if(o.uri){const e=n.options.manager.getHandler(o.uri);null!==e&&(a=e)}return n.loadTextureImage(e,s.source,a)}}class GLTFTextureAVIFExtension{constructor(e){this.parser=e,this.name=Oi.EXT_TEXTURE_AVIF}loadTexture(e){const t=this.name,n=this.parser,i=n.json,r=i.textures[e];if(!r.extensions||!r.extensions[t])return null;const s=r.extensions[t],o=i.images[s.source];let a=n.textureLoader;if(o.uri){const e=n.options.manager.getHandler(o.uri);null!==e&&(a=e)}return n.loadTextureImage(e,s.source,a)}}class GLTFMeshoptCompression{constructor(e){this.name=Oi.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 e=n.extensions[this.name],i=this.parser.getDependency("buffer",e.buffer),r=this.parser.options.meshoptDecoder;if(!r||!r.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 i.then((function(t){const n=e.byteOffset||0,i=e.byteLength||0,s=e.count,o=e.byteStride,a=new Uint8Array(t,n,i);return r.decodeGltfBufferAsync?r.decodeGltfBufferAsync(s,o,a,e.mode,e.filter).then((function(e){return e.buffer})):r.ready.then((function(){const t=new ArrayBuffer(s*o);return r.decodeGltfBuffer(new Uint8Array(t),s,o,a,e.mode,e.filter),t}))}))}return null}}class GLTFMeshGpuInstancing{constructor(e){this.name=Oi.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]||void 0===n.mesh)return null;const i=t.meshes[n.mesh];for(const e of i.primitives)if(e.mode!==Hi.TRIANGLES&&e.mode!==Hi.TRIANGLE_STRIP&&e.mode!==Hi.TRIANGLE_FAN&&void 0!==e.mode)return null;const r=n.extensions[this.name].attributes,s=[],o={};for(const e in r)s.push(this.parser.getDependency("accessor",r[e]).then((t=>(o[e]=t,o[e]))));return s.length<1?null:(s.push(this.parser.createNodeMesh(e)),Promise.all(s).then((e=>{const t=e.pop(),n=t.isGroup?t.children:[t],i=e[0].count,r=[];for(const e of n){const t=new m,n=new u,s=new F,a=new u(1,1,1),A=new k(e.geometry,e.material,i);for(let e=0;e<i;e++)o.TRANSLATION&&n.fromBufferAttribute(o.TRANSLATION,e),o.ROTATION&&s.fromBufferAttribute(o.ROTATION,e),o.SCALE&&a.fromBufferAttribute(o.SCALE,e),A.setMatrixAt(e,t.compose(n,s,a));for(const t in o)if("_COLOR_0"===t){const e=o[t];A.instanceColor=new R(e.array,e.itemSize,e.normalized)}else"TRANSLATION"!==t&&"ROTATION"!==t&&"SCALE"!==t&&e.geometry.setAttribute(t,o[t]);N.prototype.copy.call(A,e),this.parser.assignFinalMaterial(A),r.push(A)}return t.isGroup?(t.clear(),t.add(...r),t):r[0]})))}}const Gi="glTF",Ui=1313821514,Yi=5130562;class GLTFBinaryExtension{constructor(e){this.name=Oi.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,12),n=new TextDecoder;if(this.header={magic:n.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==Gi)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const i=this.header.length-12,r=new DataView(e,12);let s=0;for(;s<i;){const t=r.getUint32(s,!0);s+=4;const i=r.getUint32(s,!0);if(s+=4,i===Ui){const i=new Uint8Array(e,12+s,t);this.content=n.decode(i)}else if(i===Yi){const n=12+s;this.body=e.slice(n,n+t)}s+=t}if(null===this.content)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class GLTFDracoMeshCompressionExtension{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=Oi.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const n=this.json,i=this.dracoLoader,r=e.extensions[this.name].bufferView,s=e.extensions[this.name].attributes,o={},a={},A={};for(const e in s){const t=Ji[e]||e.toLowerCase();o[t]=s[e]}for(const t in e.attributes){const i=Ji[t]||t.toLowerCase();if(void 0!==s[t]){const r=n.accessors[e.attributes[t]],s=Xi[r.componentType];A[i]=s.name,a[i]=!0===r.normalized}}return t.getDependency("bufferView",r).then((function(e){return new Promise((function(t,n){i.decodeDracoFile(e,(function(e){for(const t in e.attributes){const n=e.attributes[t],i=a[t];void 0!==i&&(n.normalized=i)}t(e)}),o,A,S,n)}))}))}}class GLTFTextureTransformExtension{constructor(){this.name=Oi.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){return void 0!==t.texCoord&&t.texCoord!==e.channel||void 0!==t.offset||void 0!==t.rotation||void 0!==t.scale?(e=e.clone(),void 0!==t.texCoord&&(e.channel=t.texCoord),void 0!==t.offset&&e.offset.fromArray(t.offset),void 0!==t.rotation&&(e.rotation=t.rotation),void 0!==t.scale&&e.repeat.fromArray(t.scale),e.needsUpdate=!0,e):e}}class GLTFMeshQuantizationExtension{constructor(){this.name=Oi.KHR_MESH_QUANTIZATION}}class GLTFCubicSplineInterpolant extends Be{constructor(e,t,n,i){super(e,t,n,i)}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,r=e*i*3+i;for(let e=0;e!==i;e++)t[e]=n[r+e];return t}interpolate_(e,t,n,i){const r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=2*o,A=3*o,l=i-t,c=(n-t)/l,p=c*c,h=p*c,u=e*A,d=u-A,g=-2*h+3*p,f=h-p,m=1-g,y=f-p+c;for(let e=0;e!==o;e++){const t=s[d+e+o],n=s[d+e+a]*l,i=s[u+e+o],A=s[u+e]*l;r[e]=m*t+y*n+g*i+f*A}return r}}const zi=new F;class GLTFCubicSplineQuaternionInterpolant extends GLTFCubicSplineInterpolant{interpolate_(e,t,n,i){const r=super.interpolate_(e,t,n,i);return zi.fromArray(r).normalize().toArray(r),r}}const Hi={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},Xi={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},qi={9728:j,9729:q,9984:X,9985:H,9986:z,9987:Y},ji={33071:V,33648:J,10497:W},Wi={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Ji={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},Vi={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},Ki={CUBICSPLINE:void 0,LINEAR:fe,STEP:ge},Zi="OPAQUE",$i="MASK",er="BLEND";function addUnknownExtensionsToUserData(e,t,n){for(const i in n.extensions)void 0===e[i]&&(t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[i]=n.extensions[i])}function assignExtrasToUserData(e,t){void 0!==t.extras&&("object"==typeof t.extras?Object.assign(e.userData,t.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+t.extras))}function updateMorphTargets(e,t){if(e.updateMorphTargets(),void 0!==t.weights)for(let n=0,i=t.weights.length;n<i;n++)e.morphTargetInfluences[n]=t.weights[n];if(t.extras&&Array.isArray(t.extras.targetNames)){const n=t.extras.targetNames;if(e.morphTargetInfluences.length===n.length){e.morphTargetDictionary={};for(let t=0,i=n.length;t<i;t++)e.morphTargetDictionary[n[t]]=t}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function createPrimitiveKey(e){let t;const n=e.extensions&&e.extensions[Oi.KHR_DRACO_MESH_COMPRESSION];if(t=n?"draco:"+n.bufferView+":"+n.indices+":"+createAttributesKey(n.attributes):e.indices+":"+createAttributesKey(e.attributes)+":"+e.mode,void 0!==e.targets)for(let n=0,i=e.targets.length;n<i;n++)t+=":"+createAttributesKey(e.targets[n]);return t}function createAttributesKey(e){let t="";const n=Object.keys(e).sort();for(let i=0,r=n.length;i<r;i++)t+=n[i]+":"+e[n[i]]+";";return t}function getNormalizedComponentScale(e){switch(e){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}const tr=new m;class GLTFParser{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new GLTFRegistry,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let n=!1,i=-1,r=!1,s=-1;if("undefined"!=typeof navigator){const e=navigator.userAgent;n=!0===/^((?!chrome|android).)*safari/i.test(e);const t=e.match(/Version\/(\d+)/);i=n&&t?parseInt(t[1],10):-1,r=e.indexOf("Firefox")>-1,s=r?e.match(/Firefox\/([0-9]+)\./)[1]:-1}"undefined"==typeof createImageBitmap||n&&i<17||r&&s<98?this.textureLoader=new O(this.options.manager):this.textureLoader=new G(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new v(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),"use-credentials"===this.options.crossOrigin&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const n=this,i=this.json,r=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll((function(e){return e._markDefs&&e._markDefs()})),Promise.all(this._invokeAll((function(e){return e.beforeRoot&&e.beforeRoot()}))).then((function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])})).then((function(t){const s={scene:t[0][i.scene||0],scenes:t[0],animations:t[1],cameras:t[2],asset:i.asset,parser:n,userData:{}};return addUnknownExtensionsToUserData(r,s,i),assignExtrasToUserData(s,i),Promise.all(n._invokeAll((function(e){return e.afterRoot&&e.afterRoot(s)}))).then((function(){for(const e of s.scenes)e.updateMatrixWorld();e(s)}))})).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let n=0,i=t.length;n<i;n++){const i=t[n].joints;for(let t=0,n=i.length;t<n;t++)e[i[t]].isBone=!0}for(let t=0,i=e.length;t<i;t++){const i=e[t];void 0!==i.mesh&&(this._addNodeRef(this.meshCache,i.mesh),void 0!==i.skin&&(n[i.mesh].isSkinnedMesh=!0)),void 0!==i.camera&&this._addNodeRef(this.cameraCache,i.camera)}}_addNodeRef(e,t){void 0!==t&&(void 0===e.refs[t]&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,n){if(e.refs[t]<=1)return n;const i=n.clone(),updateMappings=(e,t)=>{const n=this.associations.get(e);null!=n&&this.associations.set(t,n);for(const[n,i]of e.children.entries())updateMappings(i,t.children[n])};return updateMappings(n,i),i.name+="_instance_"+e.uses[t]++,i}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let n=0;n<t.length;n++){const i=e(t[n]);if(i)return i}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const n=[];for(let i=0;i<t.length;i++){const r=e(t[i]);r&&n.push(r)}return n}getDependency(e,t){const n=e+":"+t;let i=this.cache.get(n);if(!i){switch(e){case"scene":i=this.loadScene(t);break;case"node":i=this._invokeOne((function(e){return e.loadNode&&e.loadNode(t)}));break;case"mesh":i=this._invokeOne((function(e){return e.loadMesh&&e.loadMesh(t)}));break;case"accessor":i=this.loadAccessor(t);break;case"bufferView":i=this._invokeOne((function(e){return e.loadBufferView&&e.loadBufferView(t)}));break;case"buffer":i=this.loadBuffer(t);break;case"material":i=this._invokeOne((function(e){return e.loadMaterial&&e.loadMaterial(t)}));break;case"texture":i=this._invokeOne((function(e){return e.loadTexture&&e.loadTexture(t)}));break;case"skin":i=this.loadSkin(t);break;case"animation":i=this._invokeOne((function(e){return e.loadAnimation&&e.loadAnimation(t)}));break;case"camera":i=this.loadCamera(t);break;default:if(i=this._invokeOne((function(n){return n!=this&&n.getDependency&&n.getDependency(e,t)})),!i)throw new Error("Unknown type: "+e)}this.cache.add(n,i)}return i}getDependencies(e){let t=this.cache.get(e);if(!t){const n=this,i=this.json[e+("mesh"===e?"es":"s")]||[];t=Promise.all(i.map((function(t,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&&"arraybuffer"!==t.type)throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(void 0===t.uri&&0===e)return Promise.resolve(this.extensions[Oi.KHR_BINARY_GLTF].body);const i=this.options;return new Promise((function(e,r){n.load(w.resolveURL(t.uri,i.path),e,void 0,(function(){r(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(e){const n=t.byteLength||0,i=t.byteOffset||0;return e.slice(i,i+n)}))}loadAccessor(e){const t=this,n=this.json,i=this.json.accessors[e];if(void 0===i.bufferView&&void 0===i.sparse){const e=Wi[i.type],t=Xi[i.componentType],n=!0===i.normalized,r=new t(i.count*e);return Promise.resolve(new B(r,e,n))}const r=[];return void 0!==i.bufferView?r.push(this.getDependency("bufferView",i.bufferView)):r.push(null),void 0!==i.sparse&&(r.push(this.getDependency("bufferView",i.sparse.indices.bufferView)),r.push(this.getDependency("bufferView",i.sparse.values.bufferView))),Promise.all(r).then((function(e){const r=e[0],s=Wi[i.type],o=Xi[i.componentType],a=o.BYTES_PER_ELEMENT,A=a*s,c=i.byteOffset||0,p=void 0!==i.bufferView?n.bufferViews[i.bufferView].byteStride:void 0,h=!0===i.normalized;let u,d;if(p&&p!==A){const e=Math.floor(c/p),n="InterleavedBuffer:"+i.bufferView+":"+i.componentType+":"+e+":"+i.count;let A=t.cache.get(n);A||(u=new o(r,e*p,i.count*p/a),A=new U(u,p/a),t.cache.add(n,A)),d=new l(A,s,c%p/a,h)}else u=null===r?new o(i.count*s):new o(r,c,i.count*s),d=new B(u,s,h);if(void 0!==i.sparse){const t=Wi.SCALAR,n=Xi[i.sparse.indices.componentType],a=i.sparse.indices.byteOffset||0,A=i.sparse.values.byteOffset||0,l=new n(e[1],a,i.sparse.count*t),c=new o(e[2],A,i.sparse.count*s);null!==r&&(d=new B(d.array.slice(),d.itemSize,d.normalized)),d.normalized=!1;for(let e=0,t=l.length;e<t;e++){const t=l[e];if(d.setX(t,c[e*s]),s>=2&&d.setY(t,c[e*s+1]),s>=3&&d.setZ(t,c[e*s+2]),s>=4&&d.setW(t,c[e*s+3]),s>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}d.normalized=h}return d}))}loadTexture(e){const t=this.json,n=this.options,i=t.textures[e].source,r=t.images[i];let s=this.textureLoader;if(r.uri){const e=n.manager.getHandler(r.uri);null!==e&&(s=e)}return this.loadTextureImage(e,i,s)}loadTextureImage(e,t,n){const i=this,r=this.json,s=r.textures[e],o=r.images[t],a=(o.uri||o.bufferView)+":"+s.sampler;if(this.textureCache[a])return this.textureCache[a];const A=this.loadImageSource(t,n).then((function(t){t.flipY=!1,t.name=s.name||o.name||"",""===t.name&&"string"==typeof o.uri&&!1===o.uri.startsWith("data:image/")&&(t.name=o.uri);const n=(r.samplers||{})[s.sampler]||{};return t.magFilter=qi[n.magFilter]||q,t.minFilter=qi[n.minFilter]||Y,t.wrapS=ji[n.wrapS]||W,t.wrapT=ji[n.wrapT]||W,t.generateMipmaps=!t.isCompressedTexture&&t.minFilter!==j&&t.minFilter!==q,i.associations.set(t,{textures:e}),t})).catch((function(){return null}));return this.textureCache[a]=A,A}loadImageSource(e,t){const n=this,i=this.json,r=this.options;if(void 0!==this.sourceCache[e])return this.sourceCache[e].then((e=>e.clone()));const s=i.images[e],o=self.URL||self.webkitURL;let a=s.uri||"",A=!1;if(void 0!==s.bufferView)a=n.getDependency("bufferView",s.bufferView).then((function(e){A=!0;const t=new Blob([e],{type:s.mimeType});return a=o.createObjectURL(t),a}));else if(void 0===s.uri)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const l=Promise.resolve(a).then((function(e){return new Promise((function(n,i){let s=n;!0===t.isImageBitmapLoader&&(s=function(e){const t=new me(e);t.needsUpdate=!0,n(t)}),t.load(w.resolveURL(e,r.path),s,void 0,i)}))})).then((function(e){return!0===A&&o.revokeObjectURL(a),assignExtrasToUserData(e,s),e.userData.mimeType=s.mimeType||function getImageURIMimeType(e){return e.search(/\.jpe?g($|\?)/i)>0||0===e.search(/^data\:image\/jpeg/)?"image/jpeg":e.search(/\.webp($|\?)/i)>0||0===e.search(/^data\:image\/webp/)?"image/webp":e.search(/\.ktx2($|\?)/i)>0||0===e.search(/^data\:image\/ktx2/)?"image/ktx2":"image/png"}(s.uri),e})).catch((function(e){throw console.error("THREE.GLTFLoader: Couldn't load texture",a),e}));return this.sourceCache[e]=l,l}assignTexture(e,t,n,i){const r=this;return this.getDependency("texture",n.index).then((function(s){if(!s)return null;if(void 0!==n.texCoord&&n.texCoord>0&&((s=s.clone()).channel=n.texCoord),r.extensions[Oi.KHR_TEXTURE_TRANSFORM]){const e=void 0!==n.extensions?n.extensions[Oi.KHR_TEXTURE_TRANSFORM]:void 0;if(e){const t=r.associations.get(s);s=r.extensions[Oi.KHR_TEXTURE_TRANSFORM].extendTexture(s,e),r.associations.set(s,t)}}return void 0!==i&&(s.colorSpace=i),e[t]=s,s}))}assignFinalMaterial(e){const t=e.geometry;let n=e.material;const i=void 0===t.attributes.tangent,r=void 0!==t.attributes.color,s=void 0===t.attributes.normal;if(e.isPoints){const e="PointsMaterial:"+n.uuid;let t=this.cache.get(e);t||(t=new K,Z.prototype.copy.call(t,n),t.color.copy(n.color),t.map=n.map,t.sizeAttenuation=!1,this.cache.add(e,t)),n=t}else if(e.isLine){const e="LineBasicMaterial:"+n.uuid;let t=this.cache.get(e);t||(t=new $,Z.prototype.copy.call(t,n),t.color.copy(n.color),t.map=n.map,this.cache.add(e,t)),n=t}if(i||r||s){let e="ClonedMaterial:"+n.uuid+":";i&&(e+="derivative-tangents:"),r&&(e+="vertex-colors:"),s&&(e+="flat-shading:");let t=this.cache.get(e);t||(t=n.clone(),r&&(t.vertexColors=!0),s&&(t.flatShading=!0),i&&(t.normalScale&&(t.normalScale.y*=-1),t.clearcoatNormalScale&&(t.clearcoatNormalScale.y*=-1)),this.cache.add(e,t),this.associations.set(t,this.associations.get(n))),n=t}e.material=n}getMaterialType(){return ee}loadMaterial(e){const t=this,n=this.json,i=this.extensions,s=n.materials[e];let o;const a={},A=[];if((s.extensions||{})[Oi.KHR_MATERIALS_UNLIT]){const e=i[Oi.KHR_MATERIALS_UNLIT];o=e.getMaterialType(),A.push(e.extendParams(a,s,t))}else{const n=s.pbrMetallicRoughness||{};if(a.color=new T(1,1,1),a.opacity=1,Array.isArray(n.baseColorFactor)){const e=n.baseColorFactor;a.color.setRGB(e[0],e[1],e[2],S),a.opacity=e[3]}void 0!==n.baseColorTexture&&A.push(t.assignTexture(a,"map",n.baseColorTexture,M)),a.metalness=void 0!==n.metallicFactor?n.metallicFactor:1,a.roughness=void 0!==n.roughnessFactor?n.roughnessFactor:1,void 0!==n.metallicRoughnessTexture&&(A.push(t.assignTexture(a,"metalnessMap",n.metallicRoughnessTexture)),A.push(t.assignTexture(a,"roughnessMap",n.metallicRoughnessTexture))),o=this._invokeOne((function(t){return t.getMaterialType&&t.getMaterialType(e)})),A.push(Promise.all(this._invokeAll((function(t){return t.extendMaterialParams&&t.extendMaterialParams(e,a)}))))}!0===s.doubleSided&&(a.side=te);const l=s.alphaMode||Zi;if(l===er?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,l===$i&&(a.alphaTest=void 0!==s.alphaCutoff?s.alphaCutoff:.5)),void 0!==s.normalTexture&&o!==ne&&(A.push(t.assignTexture(a,"normalMap",s.normalTexture)),a.normalScale=new r(1,1),void 0!==s.normalTexture.scale)){const e=s.normalTexture.scale;a.normalScale.set(e,e)}if(void 0!==s.occlusionTexture&&o!==ne&&(A.push(t.assignTexture(a,"aoMap",s.occlusionTexture)),void 0!==s.occlusionTexture.strength&&(a.aoMapIntensity=s.occlusionTexture.strength)),void 0!==s.emissiveFactor&&o!==ne){const e=s.emissiveFactor;a.emissive=(new T).setRGB(e[0],e[1],e[2],S)}return void 0!==s.emissiveTexture&&o!==ne&&A.push(t.assignTexture(a,"emissiveMap",s.emissiveTexture,M)),Promise.all(A).then((function(){const n=new o(a);return s.name&&(n.name=s.name),assignExtrasToUserData(n,s),t.associations.set(n,{materials:e}),s.extensions&&addUnknownExtensionsToUserData(i,n,s),n}))}createUniqueName(e){const t=ie.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,n=this.extensions,i=this.primitiveCache;function createDracoPrimitive(e){return n[Oi.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(e,t).then((function(n){return addPrimitiveAttributes(n,e,t)}))}const r=[];for(let n=0,s=e.length;n<s;n++){const s=e[n],o=createPrimitiveKey(s),a=i[o];if(a)r.push(a.promise);else{let e;e=s.extensions&&s.extensions[Oi.KHR_DRACO_MESH_COMPRESSION]?createDracoPrimitive(s):addPrimitiveAttributes(new C,s,t),i[o]={primitive:s,promise:e},r.push(e)}}return Promise.all(r)}loadMesh(e){const t=this,n=this.json,i=this.extensions,r=n.meshes[e],s=r.primitives,o=[];for(let e=0,t=s.length;e<t;e++){const t=void 0===s[e].material?(void 0===(a=this.cache).DefaultMaterial&&(a.DefaultMaterial=new ee({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:Ce})),a.DefaultMaterial):this.getDependency("material",s[e].material);o.push(t)}var a;return o.push(t.loadGeometries(s)),Promise.all(o).then((function(n){const o=n.slice(0,n.length-1),a=n[n.length-1],A=[];for(let n=0,l=a.length;n<l;n++){const l=a[n],c=s[n];let p;const h=o[n];if(c.mode===Hi.TRIANGLES||c.mode===Hi.TRIANGLE_STRIP||c.mode===Hi.TRIANGLE_FAN||void 0===c.mode)p=!0===r.isSkinnedMesh?new re(l,h):new d(l,h),!0===p.isSkinnedMesh&&p.normalizeSkinWeights(),c.mode===Hi.TRIANGLE_STRIP?p.geometry=toTrianglesDrawMode(p.geometry,x):c.mode===Hi.TRIANGLE_FAN&&(p.geometry=toTrianglesDrawMode(p.geometry,I));else if(c.mode===Hi.LINES)p=new se(l,h);else if(c.mode===Hi.LINE_STRIP)p=new oe(l,h);else if(c.mode===Hi.LINE_LOOP)p=new ae(l,h);else{if(c.mode!==Hi.POINTS)throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+c.mode);p=new Ae(l,h)}Object.keys(p.geometry.morphAttributes).length>0&&updateMorphTargets(p,r),p.name=t.createUniqueName(r.name||"mesh_"+e),assignExtrasToUserData(p,r),c.extensions&&addUnknownExtensionsToUserData(i,p,c),t.assignFinalMaterial(p),A.push(p)}for(let n=0,i=A.length;n<i;n++)t.associations.set(A[n],{meshes:e,primitives:n});if(1===A.length)return r.extensions&&addUnknownExtensionsToUserData(i,A[0],r),A[0];const l=new le;r.extensions&&addUnknownExtensionsToUserData(i,l,r),t.associations.set(l,{meshes:e});for(let e=0,t=A.length;e<t;e++)l.add(A[e]);return l}))}loadCamera(e){let t;const n=this.json.cameras[e],i=n[n.type];if(i)return"perspective"===n.type?t=new ce(y.radToDeg(i.yfov),i.aspectRatio||1,i.znear||1,i.zfar||2e6):"orthographic"===n.type&&(t=new pe(-i.xmag,i.xmag,i.ymag,-i.ymag,i.znear,i.zfar)),n.name&&(t.name=this.createUniqueName(n.name)),assignExtrasToUserData(t,n),Promise.resolve(t);console.warn("THREE.GLTFLoader: Missing camera parameters.")}loadSkin(e){const t=this.json.skins[e],n=[];for(let e=0,i=t.joints.length;e<i;e++)n.push(this._loadNodeShallow(t.joints[e]));return void 0!==t.inverseBindMatrices?n.push(this.getDependency("accessor",t.inverseBindMatrices)):n.push(null),Promise.all(n).then((function(e){const n=e.pop(),i=e,r=[],s=[];for(let e=0,o=i.length;e<o;e++){const o=i[e];if(o){r.push(o);const t=new m;null!==n&&t.fromArray(n.array,16*e),s.push(t)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[e])}return new he(r,s)}))}loadAnimation(e){const t=this.json,n=this,i=t.animations[e],r=i.name?i.name:"animation_"+e,s=[],o=[],a=[],A=[],l=[];for(let e=0,t=i.channels.length;e<t;e++){const t=i.channels[e],n=i.samplers[t.sampler],r=t.target,c=r.node,p=void 0!==i.parameters?i.parameters[n.input]:n.input,h=void 0!==i.parameters?i.parameters[n.output]:n.output;void 0!==r.node&&(s.push(this.getDependency("node",c)),o.push(this.getDependency("accessor",p)),a.push(this.getDependency("accessor",h)),A.push(n),l.push(r))}return Promise.all([Promise.all(s),Promise.all(o),Promise.all(a),Promise.all(A),Promise.all(l)]).then((function(e){const t=e[0],s=e[1],o=e[2],a=e[3],A=e[4],l=[];for(let e=0,i=t.length;e<i;e++){const i=t[e],r=s[e],c=o[e],p=a[e],h=A[e];if(void 0===i)continue;i.updateMatrix&&i.updateMatrix();const u=n._createAnimationTracks(i,r,c,p,h);if(u)for(let e=0;e<u.length;e++)l.push(u[e])}const c=new ue(r,void 0,l);return assignExtrasToUserData(c,i),c}))}createNodeMesh(e){const t=this.json,n=this,i=t.nodes[e];return void 0===i.mesh?null:n.getDependency("mesh",i.mesh).then((function(e){const t=n._getNodeRef(n.meshCache,i.mesh,e);return void 0!==i.weights&&t.traverse((function(e){if(e.isMesh)for(let t=0,n=i.weights.length;t<n;t++)e.morphTargetInfluences[t]=i.weights[t]})),t}))}loadNode(e){const t=this,n=this.json.nodes[e],i=t._loadNodeShallow(e),r=[],s=n.children||[];for(let e=0,n=s.length;e<n;e++)r.push(t.getDependency("node",s[e]));const o=void 0===n.skin?Promise.resolve(null):t.getDependency("skin",n.skin);return Promise.all([i,Promise.all(r),o]).then((function(e){const t=e[0],n=e[1],i=e[2];null!==i&&t.traverse((function(e){e.isSkinnedMesh&&e.bind(i,tr)}));for(let e=0,i=n.length;e<i;e++)t.add(n[e]);return t}))}_loadNodeShallow(e){const t=this.json,n=this.extensions,i=this;if(void 0!==this.nodeCache[e])return this.nodeCache[e];const r=t.nodes[e],s=r.name?i.createUniqueName(r.name):"",o=[],a=i._invokeOne((function(t){return t.createNodeMesh&&t.createNodeMesh(e)}));return a&&o.push(a),void 0!==r.camera&&o.push(i.getDependency("camera",r.camera).then((function(e){return i._getNodeRef(i.cameraCache,r.camera,e)}))),i._invokeAll((function(t){return t.createNodeAttachment&&t.createNodeAttachment(e)})).forEach((function(e){o.push(e)})),this.nodeCache[e]=Promise.all(o).then((function(t){let o;if(o=!0===r.isBone?new de:t.length>1?new le:1===t.length?t[0]:new N,o!==t[0])for(let e=0,n=t.length;e<n;e++)o.add(t[e]);if(r.name&&(o.userData.name=r.name,o.name=s),assignExtrasToUserData(o,r),r.extensions&&addUnknownExtensionsToUserData(n,o,r),void 0!==r.matrix){const e=new m;e.fromArray(r.matrix),o.applyMatrix4(e)}else void 0!==r.translation&&o.position.fromArray(r.translation),void 0!==r.rotation&&o.quaternion.fromArray(r.rotation),void 0!==r.scale&&o.scale.fromArray(r.scale);if(i.associations.has(o)){if(void 0!==r.mesh&&i.meshCache.refs[r.mesh]>1){const e=i.associations.get(o);i.associations.set(o,{...e})}}else i.associations.set(o,{});return i.associations.get(o).nodes=e,o})),this.nodeCache[e]}loadScene(e){const t=this.extensions,n=this.json.scenes[e],i=this,r=new le;n.name&&(r.name=i.createUniqueName(n.name)),assignExtrasToUserData(r,n),n.extensions&&addUnknownExtensionsToUserData(t,r,n);const s=n.nodes||[],o=[];for(let e=0,t=s.length;e<t;e++)o.push(i.getDependency("node",s[e]));return Promise.all(o).then((function(e){for(let t=0,n=e.length;t<n;t++)r.add(e[t]);return i.associations=(e=>{const t=new Map;for(const[e,n]of i.associations)(e instanceof Z||e instanceof me)&&t.set(e,n);return e.traverse((e=>{const n=i.associations.get(e);null!=n&&t.set(e,n)})),t})(r),r}))}_createAnimationTracks(e,t,n,i,r){const s=[],o=e.name?e.name:e.uuid,a=[];let A;switch(Vi[r.path]===Vi.weights?e.traverse((function(e){e.morphTargetInfluences&&a.push(e.name?e.name:e.uuid)})):a.push(o),Vi[r.path]){case Vi.weights:A=be;break;case Vi.rotation:A=Ie;break;case Vi.translation:case Vi.scale:A=ye;break;default:if(1===n.itemSize)A=be;else A=ye}const l=void 0!==i.interpolation?Ki[i.interpolation]:fe,c=this._getArrayFromAccessor(n);for(let e=0,n=a.length;e<n;e++){const n=new A(a[e]+"."+Vi[r.path],t.array,c,l);"CUBICSPLINE"===i.interpolation&&this._createCubicSplineTrackInterpolant(n),s.push(n)}return s}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const e=getNormalizedComponentScale(t.constructor),n=new Float32Array(t.length);for(let i=0,r=t.length;i<r;i++)n[i]=t[i]*e;t=n}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function InterpolantFactoryMethodGLTFCubicSpline(e){return new(this instanceof Ie?GLTFCubicSplineQuaternionInterpolant:GLTFCubicSplineInterpolant)(this.times,this.values,this.getValueSize()/3,e)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function addPrimitiveAttributes(e,t,n){const i=t.attributes,r=[];function assignAttributeAccessor(t,i){return n.getDependency("accessor",t).then((function(t){e.setAttribute(i,t)}))}for(const t in i){const n=Ji[t]||t.toLowerCase();n in e.attributes||r.push(assignAttributeAccessor(i[t],n))}if(void 0!==t.indices&&!e.index){const i=n.getDependency("accessor",t.indices).then((function(t){e.setIndex(t)}));r.push(i)}return xe.workingColorSpace!==S&&"COLOR_0"in i&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${xe.workingColorSpace}" not supported.`),assignExtrasToUserData(e,t),function computeBounds(e,t,n){const i=t.attributes,r=new p;if(void 0===i.POSITION)return;{const e=n.json.accessors[i.POSITION],t=e.min,s=e.max;if(void 0===t||void 0===s)return void console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");if(r.set(new u(t[0],t[1],t[2]),new u(s[0],s[1],s[2])),e.normalized){const t=getNormalizedComponentScale(Xi[e.componentType]);r.min.multiplyScalar(t),r.max.multiplyScalar(t)}}const s=t.targets;if(void 0!==s){const e=new u,t=new u;for(let i=0,r=s.length;i<r;i++){const r=s[i];if(void 0!==r.POSITION){const i=n.json.accessors[r.POSITION],s=i.min,o=i.max;if(void 0!==s&&void 0!==o){if(t.setX(Math.max(Math.abs(s[0]),Math.abs(o[0]))),t.setY(Math.max(Math.abs(s[1]),Math.abs(o[1]))),t.setZ(Math.max(Math.abs(s[2]),Math.abs(o[2]))),i.normalized){const e=getNormalizedComponentScale(Xi[i.componentType]);t.multiplyScalar(e)}e.max(t)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}r.expandByVector(e)}e.boundingBox=r;const o=new h;r.getCenter(o.center),o.radius=r.min.distanceTo(r.max)/2,e.boundingSphere=o}(e,t,n),Promise.all(r).then((function(){return void 0!==t.targets?function addMorphTargets(e,t,n){let i=!1,r=!1,s=!1;for(let e=0,n=t.length;e<n;e++){const n=t[e];if(void 0!==n.POSITION&&(i=!0),void 0!==n.NORMAL&&(r=!0),void 0!==n.COLOR_0&&(s=!0),i&&r&&s)break}if(!i&&!r&&!s)return Promise.resolve(e);const o=[],a=[],A=[];for(let l=0,c=t.length;l<c;l++){const c=t[l];if(i){const t=void 0!==c.POSITION?n.getDependency("accessor",c.POSITION):e.attributes.position;o.push(t)}if(r){const t=void 0!==c.NORMAL?n.getDependency("accessor",c.NORMAL):e.attributes.normal;a.push(t)}if(s){const t=void 0!==c.COLOR_0?n.getDependency("accessor",c.COLOR_0):e.attributes.color;A.push(t)}}return Promise.all([Promise.all(o),Promise.all(a),Promise.all(A)]).then((function(t){const n=t[0],o=t[1],a=t[2];return i&&(e.morphAttributes.position=n),r&&(e.morphAttributes.normal=o),s&&(e.morphAttributes.color=a),e.morphTargetsRelative=!0,e}))}(e,t.targets,n):e}))}const nr=new WeakMap;class DRACOLoader extends E{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,i){const r=new v(this.manager);r.setPath(this.path),r.setResponseType("arraybuffer"),r.setRequestHeader(this.requestHeader),r.setWithCredentials(this.withCredentials),r.load(e,(e=>{this.parse(e,t,i)}),n,i)}parse(e,t,n=()=>{}){this.decodeDracoFile(e,t,null,null,M,n).catch(n)}decodeDracoFile(e,t,n,i,r=S,s=()=>{}){const o={attributeIDs:n||this.defaultAttributeIDs,attributeTypes:i||this.defaultAttributeTypes,useUniqueIDs:!!n,vertexColorSpace:r};return this.decodeGeometry(e,o).then(t).catch(s)}decodeGeometry(e,t){const n=JSON.stringify(t);if(nr.has(e)){const t=nr.get(e);if(t.key===n)return t.promise;if(0===e.byteLength)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let i;const r=this.workerNextTaskID++,s=e.byteLength,o=this._getWorker(r,s).then((n=>(i=n,new Promise(((n,s)=>{i._callbacks[r]={resolve:n,reject:s},i.postMessage({type:"decode",id:r,taskConfig:t,buffer:e},[e])}))))).then((e=>this._createGeometry(e.geometry)));return o.catch((()=>!0)).then((()=>{i&&r&&this._releaseTask(i,r)})),nr.set(e,{key:n,promise:o}),o}_createGeometry(e){const t=new C;e.index&&t.setIndex(new B(e.index.array,1));for(let n=0;n<e.attributes.length;n++){const{name:i,array:r,itemSize:s,stride:o,vertexColorSpace:a}=e.attributes[n];let A;if(s===o)A=new B(r,s);else{const e=new U(r,o);A=new l(e,s,0)}"color"===i&&(this._assignVertexColorSpace(A,a),A.normalized=r instanceof Float32Array==!1),t.setAttribute(i,A)}return t}_assignVertexColorSpace(e,t){if(t!==M)return;const n=new T;for(let t=0,i=e.count;t<i;t++)n.fromBufferAttribute(e,t),xe.colorSpaceToWorking(n,M),e.setXYZ(t,n.r,n.g,n.b)}_loadLibrary(e,t){const n=new v(this.manager);return n.setPath(this.decoderPath),n.setResponseType(t),n.setWithCredentials(this.withCredentials),new Promise(((t,i)=>{n.load(e,t,void 0,i)}))}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;const e="object"!=typeof WebAssembly||"js"===this.decoderConfig.type,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((t=>{const n=t[0];e||(this.decoderConfig.wasmBinary=t[1]);const i=DRACOWorker.toString(),r=["/* draco decoder */",n,"","/* worker */",i.substring(i.indexOf("{")+1,i.lastIndexOf("}"))].join("\n");this.workerSourceURL=URL.createObjectURL(new Blob([r]))})),this.decoderPending}_getWorker(e,t){return this._initDecoder().then((()=>{if(this.workerPool.length<this.workerLimit){const e=new Worker(this.workerSourceURL);e._callbacks={},e._taskCosts={},e._taskLoad=0,e.postMessage({type:"init",decoderConfig:this.decoderConfig}),e.onmessage=function(t){const n=t.data;switch(n.type){case"decode":e._callbacks[n.id].resolve(n);break;case"error":e._callbacks[n.id].reject(n);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+n.type+'"')}},this.workerPool.push(e)}else this.workerPool.sort((function(e,t){return e._taskLoad>t._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.workerSourceURL&&URL.revokeObjectURL(this.workerSourceURL),this}}function DRACOWorker(){let e,t;function decodeAttribute(e,t,n,i,r,s){const o=n.num_points(),a=s.num_components(),A=function getDracoDataType(e,t){switch(t){case Float32Array:return e.DT_FLOAT32;case Int8Array:return e.DT_INT8;case Int16Array:return e.DT_INT16;case Int32Array:return e.DT_INT32;case Uint8Array:return e.DT_UINT8;case Uint16Array:return e.DT_UINT16;case Uint32Array:return e.DT_UINT32}}(e,r),l=a*r.BYTES_PER_ELEMENT,c=4*Math.ceil(l/4),p=c/r.BYTES_PER_ELEMENT,h=o*l,u=o*c,d=e._malloc(h);t.GetAttributeDataArrayForAllPoints(n,s,A,h,d);const g=new r(e.HEAPF32.buffer,d,h/r.BYTES_PER_ELEMENT);let f;if(l===c)f=g.slice();else{f=new r(u/r.BYTES_PER_ELEMENT);let e=0;for(let t=0,n=g.length;t<n;t++){for(let n=0;n<a;n++)f[e+n]=g[t*a+n];e+=p}}return e._free(d),{name:i,count:o,itemSize:a,array:f,stride:p}}onmessage=function(n){const i=n.data;switch(i.type){case"init":e=i.decoderConfig,t=new Promise((function(t){e.onModuleLoaded=function(e){t({draco:e})},DracoDecoderModule(e)}));break;case"decode":const n=i.buffer,r=i.taskConfig;t.then((e=>{const t=e.draco,s=new t.Decoder;try{const e=function decodeGeometry(e,t,n,i){const r=i.attributeIDs,s=i.attributeTypes;let o,a;const A=t.GetEncodedGeometryType(n);if(A===e.TRIANGULAR_MESH)o=new e.Mesh,a=t.DecodeArrayToMesh(n,n.byteLength,o);else{if(A!==e.POINT_CLOUD)throw new Error("THREE.DRACOLoader: Unexpected geometry type.");o=new e.PointCloud,a=t.DecodeArrayToPointCloud(n,n.byteLength,o)}if(!a.ok()||0===o.ptr)throw new Error("THREE.DRACOLoader: Decoding failed: "+a.error_msg());const l={index:null,attributes:[]};for(const n in r){const a=self[s[n]];let A,c;if(i.useUniqueIDs)c=r[n],A=t.GetAttributeByUniqueId(o,c);else{if(c=t.GetAttributeId(o,e[r[n]]),-1===c)continue;A=t.GetAttribute(o,c)}const p=decodeAttribute(e,t,o,n,a,A);"color"===n&&(p.vertexColorSpace=i.vertexColorSpace),l.attributes.push(p)}A===e.TRIANGULAR_MESH&&(l.index=function decodeIndex(e,t,n){const i=n.num_faces(),r=3*i,s=4*r,o=e._malloc(s);t.GetTrianglesUInt32Array(n,s,o);const a=new Uint32Array(e.HEAPF32.buffer,o,r).slice();return e._free(o),{array:a,itemSize:1}}(e,t,o));return e.destroy(o),l}(t,s,new Int8Array(n),r),o=e.attributes.map((e=>e.array.buffer));e.index&&o.push(e.index.array.buffer),self.postMessage({type:"decode",id:i.id,geometry:e},o)}catch(e){console.error(e),self.postMessage({type:"error",id:i.id,error:e.message})}finally{t.destroy(s)}}))}}}class WorkerPool{constructor(e=4){this.pool=e,this.queue=[],this.workers=[],this.workersResolve=[],this.workerStatus=0,this.workerCreator=null}_initWorker(e){if(!this.workers[e]){const t=this.workerCreator();t.addEventListener("message",this._onMessage.bind(this,e)),this.workers[e]=t}}_getIdleWorker(){for(let e=0;e<this.pool;e++)if(!(this.workerStatus&1<<e))return e;return-1}_onMessage(e,t){const n=this.workersResolve[e];if(n&&n(t),this.queue.length){const{resolve:t,msg:n,transfer:i}=this.queue.shift();this.workersResolve[e]=t,this.workers[e].postMessage(n,i)}else this.workerStatus^=1<<e}setWorkerCreator(e){this.workerCreator=e}setWorkerLimit(e){this.pool=e}postMessage(e,t){return new Promise((n=>{const i=this._getIdleWorker();-1!==i?(this._initWorker(i),this.workerStatus|=1<<i,this.workersResolve[i]=n,this.workers[i].postMessage(e,t)):this.queue.push({resolve:n,msg:e,transfer:t})}))}dispose(){this.workers.forEach((e=>e.terminate())),this.workersResolve.length=0,this.workers.length=0,this.queue.length=0,this.workerStatus=0}}const ir=9,rr=15,sr=16,or=22,ar=37,Ar=43,lr=76,cr=83,pr=97,hr=100,ur=103,dr=109,gr=122,fr=123,mr=131,yr=132,br=133,Ir=134,xr=137,Cr=138,Br=139,Er=140,wr=141,vr=142,Qr=145,Pr=146,Tr=148,Sr=152,Mr=153,Dr=154,Lr=155,_r=156,Fr=157,kr=158,Rr=165,Nr=166,Or=1000054e3,Gr=1000054001,Ur=1000054004,Yr=1000054005,zr=1000066e3,Hr=1000066004;class Ci{constructor(e,t,n,i){this._dataView=void 0,this._littleEndian=void 0,this._offset=void 0,this._dataView=new DataView(e.buffer,e.byteOffset+t,n),this._littleEndian=i,this._offset=0}_nextUint8(){const e=this._dataView.getUint8(this._offset);return this._offset+=1,e}_nextUint16(){const e=this._dataView.getUint16(this._offset,this._littleEndian);return this._offset+=2,e}_nextUint32(){const e=this._dataView.getUint32(this._offset,this._littleEndian);return this._offset+=4,e}_nextUint64(){const e=this._dataView.getUint32(this._offset,this._littleEndian)+2**32*this._dataView.getUint32(this._offset+4,this._littleEndian);return this._offset+=8,e}_nextInt32(){const e=this._dataView.getInt32(this._offset,this._littleEndian);return this._offset+=4,e}_nextUint8Array(e){const t=new Uint8Array(this._dataView.buffer,this._dataView.byteOffset+this._offset,e);return this._offset+=e,t}_skip(e){return this._offset+=e,this}_scan(e,t=0){const n=this._offset;let i=0;for(;this._dataView.getUint8(this._offset)!==t&&i<e;)i++,this._offset++;return i<e&&this._offset++,new Uint8Array(this._dataView.buffer,this._dataView.byteOffset+n,i)}}const Xr=[171,75,84,88,32,50,48,187,13,10,26,10];function Si(e){return(new TextDecoder).decode(e)}let qr,jr,Wr;const Jr={env:{emscripten_notify_memory_growth:function(e){Wr=new Uint8Array(jr.exports.memory.buffer)}}};class Q{init(){return qr||(qr="undefined"!=typeof fetch?fetch("data:application/wasm;base64,"+Vr).then((e=>e.arrayBuffer())).then((e=>WebAssembly.instantiate(e,Jr))).then(this._init):WebAssembly.instantiate(Buffer.from(Vr,"base64"),Jr).then(this._init),qr)}_init(e){jr=e.instance,Jr.env.emscripten_notify_memory_growth(0)}decode(e,t=0){if(!jr)throw new Error("ZSTDDecoder: Await .init() before decoding.");const n=e.byteLength,i=jr.exports.malloc(n);Wr.set(e,i),t=t||Number(jr.exports.ZSTD_findDecompressedSize(i,n));const r=jr.exports.malloc(t),s=jr.exports.ZSTD_decompress(r,t,i,n),o=Wr.slice(r,r+s);return jr.exports.free(i),jr.exports.free(r),o}}const Vr="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IAMNACAEQQNxBEADQCACRQ0FIAAgAkF/aiICaiIDIAEgAmotAAA6AAAgA0EDcQ0ACwsgAkEDTQ0AA0AgACACQXxqIgJqIAEgAmooAgA2AgAgAkEDSw0ACwsgAkUNAgNAIAAgAkF/aiICaiABIAJqLQAAOgAAIAINAAsMAgsgAkEDTQ0AIAIhBANAIAMgASgCADYCACABQQRqIQEgA0EEaiEDIARBfGoiBEEDSw0ACyACQQNxIQILIAJFDQADQCADIAEtAAA6AAAgA0EBaiEDIAFBAWohASACQX9qIgINAAsLIAAL8wICAn8BfgJAIAJFDQAgACACaiIDQX9qIAE6AAAgACABOgAAIAJBA0kNACADQX5qIAE6AAAgACABOgABIANBfWogAToAACAAIAE6AAIgAkEHSQ0AIANBfGogAToAACAAIAE6AAMgAkEJSQ0AIABBACAAa0EDcSIEaiIDIAFB/wFxQYGChAhsIgE2AgAgAyACIARrQXxxIgRqIgJBfGogATYCACAEQQlJDQAgAyABNgIIIAMgATYCBCACQXhqIAE2AgAgAkF0aiABNgIAIARBGUkNACADIAE2AhggAyABNgIUIAMgATYCECADIAE2AgwgAkFwaiABNgIAIAJBbGogATYCACACQWhqIAE2AgAgAkFkaiABNgIAIAQgA0EEcUEYciIEayICQSBJDQAgAa0iBUIghiAFhCEFIAMgBGohAQNAIAEgBTcDGCABIAU3AxAgASAFNwMIIAEgBTcDACABQSBqIQEgAkFgaiICQR9LDQALCyAACy8BAn8gACgCBCAAKAIAQQJ0aiICLQACIQMgACACLwEAIAEgAi0AAxAIajYCACADCy8BAn8gACgCBCAAKAIAQQJ0aiICLQACIQMgACACLwEAIAEgAi0AAxAFajYCACADCx8AIAAgASACKAIEEAg2AgAgARAEGiAAIAJBCGo2AgQLCAAgAGdBH3MLugUBDX8jAEEQayIKJAACfyAEQQNNBEAgCkEANgIMIApBDGogAyAEEAsaIAAgASACIApBDGpBBBAVIgBBbCAAEAMbIAAgACAESxsMAQsgAEEAIAEoAgBBAXRBAmoQECENQVQgAygAACIGQQ9xIgBBCksNABogAiAAQQVqNgIAIAMgBGoiAkF8aiEMIAJBeWohDiACQXtqIRAgAEEGaiELQQQh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ASIDNgLE4AEgACgCvOABIQQgACABNgK84AEgACABIAJqNgK44AEgACABIAQgA2tqNgLA4AELpgEBAX8gACAAKALs4QEQFjYCyOABIABCADcD+OABIABCADcDuOABIABBwOABakIANwMAIABBqNAAaiIBQYyAgOAANgIAIABBADYCmOIBIABCADcDiOEBIABCAzcDgOEBIABBrNABakHgEikCADcCACAAQbTQAWpB6BIoAgA2AgAgACABNgIMIAAgAEGYIGo2AgggACAAQaAwajYCBCAAIABBEGo2AgALYQEBf0G4fyEDAkAgAUEDSQ0AIAIgABAhIgFBA3YiADYCCCACIAFBAXE2AgQgAiABQQF2QQNxIgM2AgACQCADQX9qIgFBAksNAAJAIAFBAWsOAgEAAgtBbA8LIAAhAwsgAwsMACAAIAEgAkEAEC4LiAQCA38CfiADEBYhBCAAQQBBKBAQIQAgBCACSwRAIAQPCyABRQRAQX8PCwJAAkAgA0EBRg0AIAEoAAAiBkGo6r5pRg0AQXYhAyAGQXBxQdDUtMIBRw0BQQghAyACQQhJDQEgAEEAQSgQECEAIAEoAAQhASAAQQE2AhQgACABrTcDAEEADwsgASACIAMQLyIDIAJLDQAgACADNgIYQXIhAyABIARqIgVBf2otAAAiAkEIcQ0AIAJBIHEiBkUEQEFwIQMgBS0AACIFQacBSw0BIAVBB3GtQgEgBUEDdkEKaq2GIgdCA4h+IAd8IQggBEEBaiEECyACQQZ2IQMgAkECdiEFAkAgAkEDcUF/aiICQQJLBEBBACECDAELAkACQAJAIAJBAWsOAgECAAsgASAEai0AACECIARBAWohBAwCCyABIARqLwAAIQIgBEECaiEEDAELIAEgBGooAAAhAiAEQQRqIQQLIAVBAXEhBQJ+AkACQAJAIANBf2oiA0ECTQRAIANBAWsOAgIDAQtCfyAGRQ0DGiABIARqMQAADAMLIAEgBGovAACtQoACfAwCCyABIARqKAAArQwBCyABIARqKQAACyEHIAAgBTYCICAAIAI2AhwgACAHNwMAQQAhAyAAQQA2AhQgACAHIAggBhsiBzcDCCAAIAdCgIAIIAdCgIAIVBs+AhALIAMLWwEBf0G4fyEDIAIQFiICIAFNBH8gACACakF/ai0AACIAQQNxQQJ0QaAeaigC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C0Egak8NAQsgByAHKQNoNwMQIAcgBykDYDcDCCAEIA0gB0EIaiAHQdwAaiAPIA4gESAQEB4hCwwBCyACIARqIQggBCAKEAcgAkERTwRAIARBEGohAgNAIAIgCkEQaiIKEAcgAkEQaiICIAhJDQALCyAIIAlrIQIgByATNgJcIAkgCCAOa0sEQCAJIAggEWtLBEBBbCELDAILIBAgAiAOayICaiIKIANqIBBNBEAgCCAKIAMQDxoMAgsgCCAKQQAgAmsQDyEIIAcgAiADaiIDNgJkIAggAmshCCAOIQILIAlBEE8EQCADIAhqIQMDQCAIIAIQByACQRBqIQIgCEEQaiIIIANJDQALDAELAkAgCUEHTQRAIAggAi0AADoAACAIIAItAAE6AAEgCCACLQACOgACIAggAi0AAzoAAyAIQQRqIAIgCUECdCIDQcAeaigCAGoiAhAXIAIgA0HgHmooAgBrIQIgBygCZCEDDAELIAggAhAMCyADQQlJDQAgAyAIaiEDIAhBCGoiCCACQQhqIgJrQQ9MBEADQCAIIAIQDCACQQhqIQIgCEEIaiIIIANJDQAMAgALAAsDQCAIIAIQByACQRBqIQIgCEEQaiIIIANJDQALCyAHQRhqEAQaIAsgDCALEAMiAhshDCAEIAQgC2ogAhshBCAFQX9qIgUNAAsgDBADDQFBbCEMIAdBGGoQBEECSQ0BQQAhCANAIAhBA0cEQCAAIAhBAnQiAmpBrNABaiACIAdqKAJENgIAIAhBAWohCAwBCwsgBygCXCEIC0G6fyEMIA8gCGsiACANIARrSw0AIAQEfyAEIAggABALIABqBUEACyABayEMCyAHQfAAaiQAIAwLkRcCFn8FfiMAQdABayIHJAAgByAAKALw4QEiCDYCvAEgASACaiESIAggACgCgOIBaiETAkACQCAFRQRAIAEhAwwBCyAAKALE4AEhESAAKALA4AEhFSAAKAK84AEhDyAAQQE2AozhAUEAIQgDQCAIQQNHBEAgByAIQQJ0IgJqIAAgAmpBrNABaigCADYCVCAIQQFqIQgMAQsLIAcgETYCZCAHIA82AmAgByABIA9rNgJoQWwhECAHQShqIAMgBBAGEAMNASAFQQQgBUEESBshFyAHQTxqIAdBKGogACgCABATIAdBxABqIAdBKGogACgCCBATIAdBzABqIAdB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IAdB0AFqJAAgEAslACAAQgA3AgAgAEEAOwEIIABBADoACyAAIAE2AgwgACACOgAKC7QFAQN/IwBBMGsiBCQAIABB/wFqIgVBfWohBgJAIAMvAQIEQCAEQRhqIAEgAhAGIgIQAw0BIARBEGogBEEYaiADEBwgBEEIaiAEQRhqIAMQHCAAIQMDQAJAIARBGGoQBCADIAZPckUEQCADIARBEGogBEEYahASOgAAIAMgBEEIaiAEQRhqEBI6AAEgBEEYahAERQ0BIANBAmohAwsgBUF+aiEFAn8DQEG6fyECIAMiASAFSw0FIAEgBEEQaiAEQRhqEBI6AAAgAUEBaiEDIARBGGoQBEEDRgRAQQIhAiAEQQhqDAILIAMgBUsNBSABIARBCGogBEEYahASOgABIAFBAmohA0EDIQIgBEEYahAEQQNHDQALIARBEGoLIQUgAyAFIARBGGoQEjoAACABIAJqIABrIQIMAwsgAyAEQRBqIARBGGoQEjoAAiADIARBCGogBEEYahASOgADIANBBGohAwwAAAsACyAEQRhqIAEgAhAGIgIQAw0AIARBEGogBEEYaiADEBwgBEEIaiAEQRhqIAMQHCAAIQMDQAJAIARBGGoQBCADIAZPckUEQCADIARBEGogBEEYahAROgAAIAMgBEEIaiAEQRhqEBE6AAEgBEEYahAERQ0BIANBAmohAwsgBUF+aiEFAn8DQEG6fyECIAMiASAFSw0EIAEgBEEQaiAEQRhqEBE6AAAgAUEBaiEDIARBGGoQBEEDRgRAQQIhAiAEQQhqDAILIAMgBUsNBCABIARBCGogBEEYahAROgABIAFBAmohA0EDIQIgBEEYahAEQQNHDQALIARBEGoLIQUgAyAFIARBGGoQEToAACABIAJqIABrIQIMAgsgAyAEQRBqIARBGGoQEToAAiADIARBCGogBEEYahAROgADIANBBGohAwwAAAsACyAEQTBqJAAgAgtpAQF/An8CQAJAIAJBB00NACABKAAAQbfIwuF+Rw0AIAAgASgABDYCmOIBQWIgAEEQaiABIAIQPiIDEAMNAhogAEKBgICAEDcDiOEBIAAgASADaiACIANrECoMAQsgACABIAIQKgtBAAsLrQMBBn8jAEGAAWsiAyQAQWIhCAJAIAJBCUkNACAAQZjQAGogAUEIaiIEIAJBeGogAEGY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wOABCwutAgIEfwF+IwBBQGoiBCQAAkACQCACQQhJDQAgASgAAEFwcUHQ1LTCAUcNACABIAIQIiEBIABCADcDCCAAQQA2AgQgACABNgIADAELIARBGGogASACEC0iAxADBEAgACADEBoMAQsgAwRAIABBuH8QGgwBCyACIAQoAjAiA2shAiABIANqIQMDQAJAIAAgAyACIARBCGoQLCIFEAMEfyAFBSACIAVBA2oiBU8NAUG4fwsQGgwCCyAGQQFqIQYgAiAFayECIAMgBWohAyAEKAIMRQ0ACyAEKAI4BEAgAkEDTQRAIABBuH8QGgwCCyADQQRqIQMLIAQoAighAiAEKQMYIQcgAEEANgIEIAAgAyABazYCACAAIAIgBmytIAcgB0J/URs3AwgLIARBQGskAAslAQF/IwBBEGsiAiQAIAIgACABEFEgAigCACEAIAJBEGokACAAC30BBH8jAEGQBGsiBCQAIARB/wE2AggCQCAEQRBqIARBCGogBEEMaiABIAIQFSIGEAMEQCAGIQUMAQtBVCEFIAQoAgwiB0EGSw0AIAMgBEEQaiAEKAIIIAcQQSIFEAMNACAAIAEgBmogAiAGayADEDwhBQsgBEGQBGokACAFC4cBAgJ/An5BABAWIQMCQANAIAEgA08EQAJAIAAoAABBcHFB0NS0wgFGBEAgACABECIiAhADRQ0BQn4PCyAAIAEQVSIEQn1WDQMgBCAFfCIFIARUIQJCfiEEIAINAyAAIAEQUiICEAMNAwsgASACayEBIAAgAmohAAwBCwtCfiAFIAEbIQQLIAQLPwIBfwF+IwBBMGsiAiQAAn5CfiACQQhqIAAgARAtDQAaQgAgAigCHEEBRg0AGiACKQMICyEDIAJBMGokACADC40BAQJ/IwBBMGsiASQAAkAgAEUNACAAKAKI4gENACABIABB/OEBaigCADYCKCABIAApAvThATcDICAAEDAgACgCqOIBIQIgASABKAIoNgIYIAEgASkDIDcDECACIAFBEGoQGyAAQQA2AqjiASABIAEoAig2AgggASABKQMgNwMAIAAgARAbCyABQTBqJAALKgECfyMAQRBrIgAkACAAQQA2AgggAEIANwMAIAAQWCEBIABBEGokACABC4cBAQN/IwBBEGsiAiQAAkAgACgCAEUgACgCBEVzDQAgAiAAKAIINgIIIAIgACkCADcDAAJ/IAIoAgAiAQRAIAIoAghBqOMJIAERBQAMAQtBqOMJECgLIgFFDQAgASAAKQIANwL04QEgAUH84QFqIAAoAgg2AgAgARBZIAEhAwsgAkEQaiQAIAMLywEBAn8jAEEgayIBJAAgAEGBgIDAADYCtOIBIABBADYCiOIBIABBADYC7OEBIABCADcDkOIBIABBADYCpOMJIABBADYC3OIBIABCADcCzOIBIABBADYCvOIBIABBADYCxOABIABCADcCnOIBIABBpOIBakIANwIAIABBrOIBakEANgIAIAFCADcCECABQgA3AhggASABKQMYNwMIIAEgASkDEDcDACABKAIIQQh2QQFxIQIgAEEANgLg4gEgACACNgKM4gEgAUEgaiQAC3YBA38jAEEwayIBJAAgAARAIAEgAEHE0AFqIgIoAgA2AiggASAAKQK80AE3AyAgACgCACEDIAEgAigCADYCGCABIAApArzQATcDECADIAFBEGoQGyABIAEoAig2AgggASABKQMgNwMAIAAgARAbCyABQTBqJAALzAEBAX8gACABKAK00AE2ApjiASAAIAEoAgQiAjYCwOABIAAgAjYCvOABIAAgAiABKAIIaiICNgK44AEgACACNgLE4AEgASgCuNABBEAgAEKBgICAEDcDiOEBIAAgAUGk0ABqNgIMIAAgAUGUIGo2AgggACABQZwwajYCBCAAIAFBDGo2AgAgAEGs0AFqIAFBqNABaigCADYCACAAQbDQAWogAUGs0AFqKAIANgIAIABBtNABaiABQbDQAWooAgA2AgAPCyAAQgA3A4jhAQs7ACACRQRAQbp/DwsgBEUEQEFsDwsgAiAEEGAEQCAAIAEgAiADIAQgBRBhDwsgACABIAIgAyAEIAUQZQtGAQF/IwBBEGsiBSQAIAVBCGogBBAOAn8gBS0ACQRAIAAgASACIAMgBBAyDAELIAAgASACIAMgBBA0CyEAIAVBEGokACAACzQAIAAgAyAEIAUQNiIFEAMEQCAFDwsgBSAESQR/IAEgAiADIAVqIAQgBWsgABA1BUG4fwsLRgEBfyMAQRBrIgUkACAFQQhqIAQQDgJ/IAUtAAkEQCAAIAEgAiADIAQQYgwBCyAAIAEgAiADIAQQNQshACAFQRBqJAAgAAtZAQF/QQ8hAiABIABJBEAgAUEE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";xe.spaces[M];const Kr=new WeakMap;let Zr,$r=0;class KTX2Loader extends E{constructor(e){super(e),this.transcoderPath="",this.transcoderBinary=null,this.transcoderPending=null,this.workerPool=new WorkerPool,this.workerSourceURL="",this.workerConfig=null,"undefined"!=typeof MSC_TRANSCODER&&console.warn('THREE.KTX2Loader: Please update to latest "basis_transcoder". "msc_basis_transcoder" is no longer supported in three.js r125+.')}setTranscoderPath(e){return this.transcoderPath=e,this}setWorkerLimit(e){return this.workerPool.setWorkerLimit(e),this}async detectSupportAsync(e){return console.warn('KTX2Loader: "detectSupportAsync()" has been deprecated. Use "detectSupport()" and "await renderer.init();" when creating the renderer.'),await e.init(),this.detectSupport(e)}detectSupport(e){return!0===e.isWebGPURenderer?this.workerConfig={astcSupported:e.hasFeature("texture-compression-astc"),astcHDRSupported:!1,etc1Supported:e.hasFeature("texture-compression-etc1"),etc2Supported:e.hasFeature("texture-compression-etc2"),dxtSupported:e.hasFeature("texture-compression-s3tc"),bptcSupported:e.hasFeature("texture-compression-bc"),pvrtcSupported:e.hasFeature("texture-compression-pvrtc")}:(this.workerConfig={astcSupported:e.extensions.has("WEBGL_compressed_texture_astc"),astcHDRSupported:e.extensions.has("WEBGL_compressed_texture_astc")&&e.extensions.get("WEBGL_compressed_texture_astc").getSupportedProfiles().includes("hdr"),etc1Supported:e.extensions.has("WEBGL_compressed_texture_etc1"),etc2Supported:e.extensions.has("WEBGL_compressed_texture_etc"),dxtSupported:e.extensions.has("WEBGL_compressed_texture_s3tc"),bptcSupported:e.extensions.has("EXT_texture_compression_bptc"),pvrtcSupported:e.extensions.has("WEBGL_compressed_texture_pvrtc")||e.extensions.has("WEBKIT_WEBGL_compressed_texture_pvrtc")},"undefined"!=typeof navigator&&navigator.platform.indexOf("Linux")>=0&&navigator.userAgent.indexOf("Firefox")>=0&&this.workerConfig.astcSupported&&this.workerConfig.etc2Supported&&this.workerConfig.bptcSupported&&this.workerConfig.dxtSupported&&(this.workerConfig.astcSupported=!1,this.workerConfig.etc2Supported=!1)),this}init(){if(!this.transcoderPending){const e=new v(this.manager);e.setPath(this.transcoderPath),e.setWithCredentials(this.withCredentials);const t=e.loadAsync("basis_transcoder.js"),n=new v(this.manager);n.setPath(this.transcoderPath),n.setResponseType("arraybuffer"),n.setWithCredentials(this.withCredentials);const i=n.loadAsync("basis_transcoder.wasm");this.transcoderPending=Promise.all([t,i]).then((([e,t])=>{const n=KTX2Loader.BasisWorker.toString(),i=["/* constants */","let _EngineFormat = "+JSON.stringify(KTX2Loader.EngineFormat),"let _EngineType = "+JSON.stringify(KTX2Loader.EngineType),"let _TranscoderFormat = "+JSON.stringify(KTX2Loader.TranscoderFormat),"let _BasisFormat = "+JSON.stringify(KTX2Loader.BasisFormat),"/* basis_transcoder.js */",e,"/* worker */",n.substring(n.indexOf("{")+1,n.lastIndexOf("}"))].join("\n");this.workerSourceURL=URL.createObjectURL(new Blob([i])),this.transcoderBinary=t,this.workerPool.setWorkerCreator((()=>{const e=new Worker(this.workerSourceURL),t=this.transcoderBinary.slice(0);return e.postMessage({type:"init",config:this.workerConfig,transcoderBinary:t},[t]),e}))})),$r>0&&console.warn("THREE.KTX2Loader: Multiple active KTX2 loaders may cause performance issues. Use a single KTX2Loader instance, or call .dispose() on old instances."),$r++}return this.transcoderPending}load(e,t,n,i){if(null===this.workerConfig)throw new Error("THREE.KTX2Loader: Missing initialization with `.detectSupport( renderer )`.");const r=new v(this.manager);r.setPath(this.path),r.setCrossOrigin(this.crossOrigin),r.setWithCredentials(this.withCredentials),r.setRequestHeader(this.requestHeader),r.setResponseType("arraybuffer"),r.load(e,(e=>{this.parse(e,t,i)}),n,i)}parse(e,t,n){if(null===this.workerConfig)throw new Error("THREE.KTX2Loader: Missing initialization with `.detectSupport( renderer )`.");if(Kr.has(e)){return Kr.get(e).promise.then(t).catch(n)}this._createTexture(e).then((e=>t?t(e):null)).catch(n)}_createTextureFrom(e,t){const{type:n,error:i,data:{faces:r,width:s,height:o,format:a,type:A,dfdFlags:l}}=e;if("error"===n)return Promise.reject(i);let c;if(6===t.faceCount)c=new Ee(r,a,A);else{const e=r[0].mipmaps;c=t.layerCount>1?new we(e,s,o,t.layerCount,a,A):new ve(e,s,o,a,A)}return c.minFilter=1===r[0].mipmaps.length?q:Y,c.magFilter=q,c.generateMipmaps=!1,c.needsUpdate=!0,c.colorSpace=parseColorSpace(t),c.premultiplyAlpha=!!(1&l),c}async _createTexture(e,t={}){const n=function Mi(e){const t=new Uint8Array(e.buffer,e.byteOffset,Xr.length);if(t[0]!==Xr[0]||t[1]!==Xr[1]||t[2]!==Xr[2]||t[3]!==Xr[3]||t[4]!==Xr[4]||t[5]!==Xr[5]||t[6]!==Xr[6]||t[7]!==Xr[7]||t[8]!==Xr[8]||t[9]!==Xr[9]||t[10]!==Xr[10]||t[11]!==Xr[11])throw new Error("Missing KTX 2.0 identifier.");const n={vkFormat:0,typeSize:1,pixelWidth:0,pixelHeight:0,pixelDepth:0,layerCount:0,faceCount:1,levelCount:0,supercompressionScheme:0,levels:[],dataFormatDescriptor:[{vendorId:0,descriptorType:0,versionNumber:2,colorModel:0,colorPrimaries:1,transferFunction:2,flags:0,texelBlockDimension:[0,0,0,0],bytesPlane:[0,0,0,0,0,0,0,0],samples:[]}],keyValue:{},globalData:null},i=17*Uint32Array.BYTES_PER_ELEMENT,r=new Ci(e,Xr.length,i,!0);n.vkFormat=r._nextUint32(),n.typeSize=r._nextUint32(),n.pixelWidth=r._nextUint32(),n.pixelHeight=r._nextUint32(),n.pixelDepth=r._nextUint32(),n.layerCount=r._nextUint32(),n.faceCount=r._nextUint32(),n.levelCount=r._nextUint32(),n.supercompressionScheme=r._nextUint32();const s=r._nextUint32(),o=r._nextUint32(),a=r._nextUint32(),A=r._nextUint32(),l=r._nextUint64(),c=r._nextUint64(),p=3*Math.max(n.levelCount,1)*8,h=new Ci(e,Xr.length+i,p,!0);for(let t=0,i=Math.max(n.levelCount,1);t<i;t++)n.levels.push({levelData:new Uint8Array(e.buffer,e.byteOffset+h._nextUint64(),h._nextUint64()),uncompressedByteLength:h._nextUint64()});const u=new Ci(e,s,o,!0);u._skip(4);const d=u._nextUint16(),g=u._nextUint16(),f=u._nextUint16(),m=u._nextUint16(),y={vendorId:d,descriptorType:g,versionNumber:f,colorModel:u._nextUint8(),colorPrimaries:u._nextUint8(),transferFunction:u._nextUint8(),flags:u._nextUint8(),texelBlockDimension:[u._nextUint8(),u._nextUint8(),u._nextUint8(),u._nextUint8()],bytesPlane:[u._nextUint8(),u._nextUint8(),u._nextUint8(),u._nextUint8(),u._nextUint8(),u._nextUint8(),u._nextUint8(),u._nextUint8()],samples:[]},b=(m/4-6)/4;for(let e=0;e<b;e++){const t={bitOffset:u._nextUint16(),bitLength:u._nextUint8(),channelType:u._nextUint8(),samplePosition:[u._nextUint8(),u._nextUint8(),u._nextUint8(),u._nextUint8()],sampleLower:Number.NEGATIVE_INFINITY,sampleUpper:Number.POSITIVE_INFINITY};64&t.channelType?(t.sampleLower=u._nextInt32(),t.sampleUpper=u._nextInt32()):(t.sampleLower=u._nextUint32(),t.sampleUpper=u._nextUint32()),y.samples[e]=t}n.dataFormatDescriptor.length=0,n.dataFormatDescriptor.push(y);const I=new Ci(e,a,A,!0);for(;I._offset<A;){const e=I._nextUint32(),t=I._scan(e),i=Si(t);if(n.keyValue[i]=I._nextUint8Array(e-t.byteLength-1),i.match(/^ktx/i)){const e=Si(n.keyValue[i]);n.keyValue[i]=e.substring(0,e.lastIndexOf("\0"))}I._skip(e%4?4-e%4:0)}if(c<=0)return n;const x=new Ci(e,l,c,!0),C=x._nextUint16(),B=x._nextUint16(),E=x._nextUint32(),w=x._nextUint32(),v=x._nextUint32(),P=x._nextUint32(),T=[];for(let e=0,t=Math.max(n.levelCount,1);e<t;e++)T.push({imageFlags:x._nextUint32(),rgbSliceByteOffset:x._nextUint32(),rgbSliceByteLength:x._nextUint32(),alphaSliceByteOffset:x._nextUint32(),alphaSliceByteLength:x._nextUint32()});const S=l+x._offset,M=S+E,D=M+w,L=D+v,_=new Uint8Array(e.buffer,e.byteOffset+S,E),F=new Uint8Array(e.buffer,e.byteOffset+M,w),k=new Uint8Array(e.buffer,e.byteOffset+D,v),R=new Uint8Array(e.buffer,e.byteOffset+L,P);return n.globalData={endpointCount:C,selectorCount:B,imageDescs:T,endpointsData:_,selectorsData:F,tablesData:k,extendedData:R},n}(new Uint8Array(e)),i=n.vkFormat===zr&&167===n.dataFormatDescriptor[0].colorModel;if(!(0===n.vkFormat||i&&!this.workerConfig.astcHDRSupported))return async function createRawTexture(e){const{vkFormat:t}=e;if(void 0===ts[t])throw new Error("THREE.KTX2Loader: Unsupported vkFormat: "+t);void 0===ns[t]&&console.warn('THREE.KTX2Loader: Missing ".type" for vkFormat: '+t);let n;2===e.supercompressionScheme&&(Zr||(Zr=new Promise((async e=>{const t=new Q;await t.init(),e(t)}))),n=await Zr);const i=[];for(let r=0;r<e.levels.length;r++){const s=Math.max(1,e.pixelWidth>>r),o=Math.max(1,e.pixelHeight>>r),a=e.pixelDepth?Math.max(1,e.pixelDepth>>r):0,A=e.levels[r];let l,c;if(0===e.supercompressionScheme)l=A.levelData;else{if(2!==e.supercompressionScheme)throw new Error("THREE.KTX2Loader: Unsupported supercompressionScheme.");l=n.decode(A.levelData,A.uncompressedByteLength)}c=ns[t]===et?new Float32Array(l.buffer,l.byteOffset,l.byteLength/Float32Array.BYTES_PER_ELEMENT):ns[t]===Ke?new Uint16Array(l.buffer,l.byteOffset,l.byteLength/Uint16Array.BYTES_PER_ELEMENT):ns[t]===$e||ns[t]===Ze?new Uint32Array(l.buffer,l.byteOffset,l.byteLength/Uint32Array.BYTES_PER_ELEMENT):l,i.push({data:c,width:s,height:o,depth:a})}const r=0===e.levelCount||i.length>1;let s;if(es.has(ts[t]))s=0===e.pixelDepth?new tt(i[0].data,e.pixelWidth,e.pixelHeight):new nt(i[0].data,e.pixelWidth,e.pixelHeight,e.pixelDepth),s.minFilter=r?X:j,s.magFilter=j,s.generateMipmaps=0===e.levelCount;else{if(e.pixelDepth>0)throw new Error("THREE.KTX2Loader: Unsupported pixelDepth.");s=new ve(i,e.pixelWidth,e.pixelHeight),s.minFilter=r?Y:q,s.magFilter=q}return s.mipmaps=i,s.type=ns[t],s.format=ts[t],s.colorSpace=parseColorSpace(e),s.needsUpdate=!0,Promise.resolve(s)}(n);const r=t,s=this.init().then((()=>this.workerPool.postMessage({type:"transcode",buffer:e,taskConfig:r},[e]))).then((e=>this._createTextureFrom(e.data,n)));return Kr.set(e,{promise:s}),s}dispose(){this.workerPool.dispose(),this.workerSourceURL&&URL.revokeObjectURL(this.workerSourceURL),$r--}}KTX2Loader.BasisFormat={ETC1S:0,UASTC:1,UASTC_HDR:2},KTX2Loader.TranscoderFormat={ETC1:0,ETC2:1,BC1:2,BC3:3,BC4:4,BC5:5,BC7_M6_OPAQUE_ONLY:6,BC7_M5:7,PVRTC1_4_RGB:8,PVRTC1_4_RGBA:9,ASTC_4x4:10,ATC_RGB:11,ATC_RGBA_INTERPOLATED_ALPHA:12,RGBA32:13,RGB565:14,BGR565:15,RGBA4444:16,BC6H:22,RGB_HALF:24,RGBA_HALF:25},KTX2Loader.EngineFormat={RGBAFormat:Je,RGBA_ASTC_4x4_Format:Oe,RGB_BPTC_UNSIGNED_Format:ot,RGBA_BPTC_Format:Se,RGBA_ETC2_EAC_Format:Xe,RGBA_PVRTC_4BPPV1_Format:Te,RGBA_S3TC_DXT5_Format:st,RGB_ETC1_Format:rt,RGB_ETC2_Format:He,RGB_PVRTC_4BPPV1_Format:it,RGBA_S3TC_DXT1_Format:Re},KTX2Loader.EngineType={UnsignedByteType:Ve,HalfFloatType:Ke,FloatType:et},KTX2Loader.BasisWorker=function(){let e,t,n;const i=_EngineFormat,r=_EngineType,s=_TranscoderFormat,o=_BasisFormat;self.addEventListener("message",(function(i){const s=i.data;switch(s.type){case"init":e=s.config,function init(e){t=new Promise((t=>{n={wasmBinary:e,onRuntimeInitialized:t},BASIS(n)})).then((()=>{n.initializeBasis(),void 0===n.KTX2File&&console.warn("THREE.KTX2Loader: Please update Basis Universal transcoder.")}))}(s.transcoderBinary);break;case"transcode":t.then((()=>{try{const{faces:t,buffers:i,width:a,height:l,hasAlpha:c,format:p,type:h,dfdFlags:u}=function transcode(t){const i=new n.KTX2File(new Uint8Array(t));function cleanup(){i.close(),i.delete()}if(!i.isValid())throw cleanup(),new Error("THREE.KTX2Loader:\tInvalid or unsupported .ktx2 file");let s;if(i.isUASTC())s=o.UASTC;else if(i.isETC1S())s=o.ETC1S;else{if(!i.isHDR())throw new Error("THREE.KTX2Loader: Unknown Basis encoding");s=o.UASTC_HDR}const a=i.getWidth(),l=i.getHeight(),c=i.getLayers()||1,p=i.getLevels(),h=i.getFaces(),u=i.getHasAlpha(),d=i.getDFDFlags(),{transcoderFormat:g,engineFormat:f,engineType:m}=function getTranscoderFormat(t,n,i,r){const s=A[t];for(let o=0;o<s.length;o++){const a=s[o];if(a.if&&!e[a.if])continue;if(!a.basisFormat.includes(t))continue;if(r&&a.transcoderFormat.length<2)continue;if(a.needsPowerOfTwo&&(!isPowerOfTwo(n)||!isPowerOfTwo(i)))continue;return{transcoderFormat:a.transcoderFormat[r?1:0],engineFormat:a.engineFormat[r?1:0],engineType:a.engineType[0]}}throw new Error("THREE.KTX2Loader: Failed to identify transcoding target.")}(s,a,l,u);if(!a||!l||!p)throw cleanup(),new Error("THREE.KTX2Loader:\tInvalid texture");if(!i.startTranscoding())throw cleanup(),new Error("THREE.KTX2Loader: .startTranscoding failed");const y=[],b=[];for(let e=0;e<h;e++){const t=[];for(let n=0;n<p;n++){const s=[];let o,a;for(let t=0;t<c;t++){const A=i.getImageLevelInfo(n,t,e);0!==e||0!==n||0!==t||A.origWidth%4==0&&A.origHeight%4==0||console.warn("THREE.KTX2Loader: ETC1S and UASTC textures should use multiple-of-four dimensions."),p>1?(o=A.origWidth,a=A.origHeight):(o=A.width,a=A.height);let l=new Uint8Array(i.getImageTranscodedSizeInBytes(n,t,0,g));const c=i.transcodeImage(l,n,t,e,g,0,-1,-1);if(m===r.HalfFloatType&&(l=new Uint16Array(l.buffer,l.byteOffset,l.byteLength/Uint16Array.BYTES_PER_ELEMENT)),!c)throw cleanup(),new Error("THREE.KTX2Loader: .transcodeImage failed.");s.push(l)}const A=concat(s);t.push({data:A,width:o,height:a}),b.push(A.buffer)}y.push({mipmaps:t,width:a,height:l,format:f,type:m})}return cleanup(),{faces:y,buffers:b,width:a,height:l,hasAlpha:u,dfdFlags:d,format:f,type:m}}(s.buffer);self.postMessage({type:"transcode",id:s.id,data:{faces:t,width:a,height:l,hasAlpha:c,format:p,type:h,dfdFlags:u}},i)}catch(e){console.error(e),self.postMessage({type:"error",id:s.id,error:e.message})}}))}}));const a=[{if:"astcSupported",basisFormat:[o.UASTC],transcoderFormat:[s.ASTC_4x4,s.ASTC_4x4],engineFormat:[i.RGBA_ASTC_4x4_Format,i.RGBA_ASTC_4x4_Format],engineType:[r.UnsignedByteType],priorityETC1S:1/0,priorityUASTC:1,needsPowerOfTwo:!1},{if:"bptcSupported",basisFormat:[o.ETC1S,o.UASTC],transcoderFormat:[s.BC7_M5,s.BC7_M5],engineFormat:[i.RGBA_BPTC_Format,i.RGBA_BPTC_Format],engineType:[r.UnsignedByteType],priorityETC1S:3,priorityUASTC:2,needsPowerOfTwo:!1},{if:"dxtSupported",basisFormat:[o.ETC1S,o.UASTC],transcoderFormat:[s.BC1,s.BC3],engineFormat:[i.RGBA_S3TC_DXT1_Format,i.RGBA_S3TC_DXT5_Format],engineType:[r.UnsignedByteType],priorityETC1S:4,priorityUASTC:5,needsPowerOfTwo:!1},{if:"etc2Supported",basisFormat:[o.ETC1S,o.UASTC],transcoderFormat:[s.ETC1,s.ETC2],engineFormat:[i.RGB_ETC2_Format,i.RGBA_ETC2_EAC_Format],engineType:[r.UnsignedByteType],priorityETC1S:1,priorityUASTC:3,needsPowerOfTwo:!1},{if:"etc1Supported",basisFormat:[o.ETC1S,o.UASTC],transcoderFormat:[s.ETC1],engineFormat:[i.RGB_ETC1_Format],engineType:[r.UnsignedByteType],priorityETC1S:2,priorityUASTC:4,needsPowerOfTwo:!1},{if:"pvrtcSupported",basisFormat:[o.ETC1S,o.UASTC],transcoderFormat:[s.PVRTC1_4_RGB,s.PVRTC1_4_RGBA],engineFormat:[i.RGB_PVRTC_4BPPV1_Format,i.RGBA_PVRTC_4BPPV1_Format],engineType:[r.UnsignedByteType],priorityETC1S:5,priorityUASTC:6,needsPowerOfTwo:!0},{if:"bptcSupported",basisFormat:[o.UASTC_HDR],transcoderFormat:[s.BC6H],engineFormat:[i.RGB_BPTC_UNSIGNED_Format],engineType:[r.HalfFloatType],priorityHDR:1,needsPowerOfTwo:!1},{basisFormat:[o.ETC1S,o.UASTC],transcoderFormat:[s.RGBA32,s.RGBA32],engineFormat:[i.RGBAFormat,i.RGBAFormat],engineType:[r.UnsignedByteType,r.UnsignedByteType],priorityETC1S:100,priorityUASTC:100,needsPowerOfTwo:!1},{basisFormat:[o.UASTC_HDR],transcoderFormat:[s.RGBA_HALF],engineFormat:[i.RGBAFormat],engineType:[r.HalfFloatType],priorityHDR:100,needsPowerOfTwo:!1}],A={[o.ETC1S]:a.filter((e=>e.basisFormat.includes(o.ETC1S))).sort(((e,t)=>e.priorityETC1S-t.priorityETC1S)),[o.UASTC]:a.filter((e=>e.basisFormat.includes(o.UASTC))).sort(((e,t)=>e.priorityUASTC-t.priorityUASTC)),[o.UASTC_HDR]:a.filter((e=>e.basisFormat.includes(o.UASTC_HDR))).sort(((e,t)=>e.priorityHDR-t.priorityHDR))};function isPowerOfTwo(e){return e<=2||!(e&e-1)&&0!==e}function concat(e){if(1===e.length)return e[0];let t=0;for(let n=0;n<e.length;n++){t+=e[n].byteLength}const n=new Uint8Array(t);let i=0;for(let t=0;t<e.length;t++){const r=e[t];n.set(r,i),i+=r.byteLength}return n}};const es=new Set([Je,qe,We,je]),ts={[dr]:Je,[ur]:We,[hr]:je,[pr]:Je,[cr]:We,[lr]:je,[Ar]:Je,[ar]:Je,[or]:We,[sr]:We,[rr]:je,[ir]:je,[fr]:qe,[gr]:qe,[Sr]:Xe,[Tr]:He,[Mr]:ze,[Dr]:Ye,[Lr]:Ue,[_r]:Ge,[zr]:Oe,[kr]:Oe,[Fr]:Oe,[Hr]:Ne,[Nr]:Ne,[Rr]:Ne,[Ir]:Re,[br]:Re,[yr]:ke,[mr]:ke,[Cr]:Fe,[xr]:Fe,[Er]:_e,[Br]:Le,[vr]:De,[wr]:Me,[Pr]:Se,[Qr]:Se,[Yr]:Te,[Gr]:Te,[Ur]:Pe,[Or]:Pe},ns={[dr]:et,[ur]:et,[hr]:et,[pr]:Ke,[cr]:Ke,[lr]:Ke,[Ar]:Ve,[ar]:Ve,[or]:Ve,[sr]:Ve,[rr]:Ve,[ir]:Ve,[fr]:$e,[gr]:Ze,[Sr]:Ve,[Tr]:Ve,[Mr]:Ve,[Mr]:Ve,[Lr]:Ve,[Lr]:Ve,[zr]:Ke,[kr]:Ve,[Fr]:Ve,[Hr]:Ke,[Nr]:Ve,[Rr]:Ve,[Ir]:Ve,[br]:Ve,[yr]:Ve,[mr]:Ve,[Cr]:Ve,[xr]:Ve,[Er]:Ve,[Br]:Ve,[vr]:Ve,[wr]:Ve,[Pr]:Ve,[Qr]:Ve,[Yr]:Ve,[Gr]:Ve,[Ur]:Ve,[Or]:Ve};function parseColorSpace(e){const t=e.dataFormatDescriptor[0];return 1===t.colorPrimaries?2===t.transferFunction?M:S:10===t.colorPrimaries?2===t.transferFunction?"display-p3":"display-p3-linear":(0===t.colorPrimaries||console.warn(`THREE.KTX2Loader: Unsupported color primaries, "${t.colorPrimaries}"`),Qe)}var is=function(){var e=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,3,2,0,0,5,3,1,0,1,12,1,0,10,22,2,12,0,65,0,65,0,65,0,252,10,0,0,11,7,0,65,0,253,15,26,11]),t=new Uint8Array([32,0,65,2,1,106,34,33,3,128,11,4,13,64,6,253,10,7,15,116,127,5,8,12,40,16,19,54,20,9,27,255,113,17,42,67,24,23,146,148,18,14,22,45,70,69,56,114,101,21,25,63,75,136,108,28,118,29,73,115]);if("object"!=typeof WebAssembly)return{supported:!1};var n,i=WebAssembly.validate(e)?unpack("b9H79TebbbeKl9Gbb9Gvuuuuueu9Giuuub9Geueuikqbbebeedddilve9Weeeviebeoweuec:q:6dkr;leDo9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bb8A9TW79O9V9Wt9F9KW9J9V9KW9wWVtW949c919M9MWVbdY9TW79O9V9Wt9F9KW9J9V9KW69U9KW949c919M9MWVblE9TW79O9V9Wt9F9KW9J9V9KW69U9KW949tWG91W9U9JWbvL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9p9JtboK9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9r919HtbrL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVT949Wbwl79IV9RbDq:p9sqlbzik9:evu8Jjjjjbcz9Rhbcbheincbhdcbhiinabcwfadfaicjuaead4ceGglE86bbaialfhiadcefgdcw9hmbkaec:q:yjjbfai86bbaecitc:q1jjbfab8Piw83ibaecefgecjd9hmbkk:N8JlHud97euo978Jjjjjbcj;kb9Rgv8Kjjjjbc9:hodnadcefal0mbcuhoaiRbbc:Ge9hmbavaialfgrad9Rad;8qbbcj;abad9UhlaicefhodnaeTmbadTmbalc;WFbGglcjdalcjd6EhwcbhDinawaeaD9RaDawfae6Egqcsfglc9WGgkci2hxakcethmalcl4cifcd4hPabaDad2fhsakc;ab6hzcbhHincbhOaohAdndninaraA9RaP6meavcj;cbfaOak2fhCaAaPfhocbhidnazmbarao9Rc;Gb6mbcbhlinaCalfhidndndndndnaAalco4fRbbgXciGPlbedibkaipxbbbbbbbbbbbbbbbbpklbxikaiaopbblaopbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklbaoclfaYpQbfaKc:q:yjjbfRbbfhoxdkaiaopbbwaopbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklbaocwfaYpQbfaKc:q:yjjbfRbbfhoxekaiaopbbbpklbaoczfhokdndndndndnaXcd4ciGPlbedibkaipxbbbbbbbbbbbbbbbbpklzxikaiaopbblaopbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklzaoclfaYpQbfaKc:q:yjjbfRbbfhoxdkaiaopbbwaopbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklzaocwfaYpQbfaKc:q:yjjbfRbbfhoxekaiaopbbbpklzaoczfhokdndndndndnaXcl4ciGPlbedibkaipxbbbbbbbbbbbbbbbbpklaxikaiaopbblaopbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklaaoclfaYpQbfaKc:q:yjjbfRbbfhoxdkaiaopbbwaopbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklaaocwfaYpQbfaKc:q:yjjbfRbbfhoxekaiaopbbbpklaaoczfhokdndndndndnaXco4Plbedibkaipxbbbbbbbbbbbbbbbbpkl8WxikaiaopbblaopbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgXcitc:q1jjbfpbibaXc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgXcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spkl8WaoclfaYpQbfaXc:q:yjjbfRbbfhoxdkaiaopbbwaopbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgXcitc:q1jjbfpbibaXc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgXcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spkl8WaocwfaYpQbfaXc:q:yjjbfRbbfhoxekaiaopbbbpkl8Waoczfhokalc;abfhialcjefak0meaihlarao9Rc;Fb0mbkkdnaiak9pmbaici4hlinarao9RcK6miaCaifhXdndndndndnaAaico4fRbbalcoG4ciGPlbedibkaXpxbbbbbbbbbbbbbbbbpkbbxikaXaopbblaopbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spkbbaoclfaYpQbfaKc:q:yjjbfRbbfhoxdkaXaopbbwaopbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spkbbaocwfaYpQbfaKc:q:yjjbfRbbfhoxekaXaopbbbpkbbaoczfhokalcdfhlaiczfgiak6mbkkaoTmeaohAaOcefgOclSmdxbkkc9:hoxlkdnakTmbavcjdfaHfhiavaHfpbdbhYcbhXinaiavcj;cbfaXfglpblbgLcep9TaLpxeeeeeeeeeeeeeeeegQp9op9Hp9rgLalakfpblbg8Acep9Ta8AaQp9op9Hp9rg8ApmbzeHdOiAlCvXoQrLgEalamfpblbg3cep9Ta3aQp9op9Hp9rg3alaxfpblbg5cep9Ta5aQp9op9Hp9rg5pmbzeHdOiAlCvXoQrLg8EpmbezHdiOAlvCXorQLgQaQpmbedibedibedibediaYp9UgYp9AdbbaiadfglaYaQaQpmlvorlvorlvorlvorp9UgYp9AdbbaladfglaYaQaQpmwDqkwDqkwDqkwDqkp9UgYp9AdbbaladfglaYaQaQpmxmPsxmPsxmPsxmPsp9UgYp9AdbbaladfglaYaEa8EpmwDKYqk8AExm35Ps8E8FgQaQpmbedibedibedibedip9UgYp9AdbbaladfglaYaQaQpmlvorlvorlvorlvorp9UgYp9AdbbaladfglaYaQaQpmwDqkwDqkwDqkwDqkp9UgYp9AdbbaladfglaYaQaQpmxmPsxmPsxmPsxmPsp9UgYp9AdbbaladfglaYaLa8ApmwKDYq8AkEx3m5P8Es8FgLa3a5pmwKDYq8AkEx3m5P8Es8Fg8ApmbezHdiOAlvCXorQLgQaQpmbedibedibedibedip9UgYp9AdbbaladfglaYaQaQpmlvorlvorlvorlvorp9UgYp9AdbbaladfglaYaQaQpmwDqkwDqkwDqkwDqkp9UgYp9AdbbaladfglaYaQaQpmxmPsxmPsxmPsxmPsp9UgYp9AdbbaladfglaYaLa8ApmwDKYqk8AExm35Ps8E8FgQaQpmbedibedibedibedip9UgYp9AdbbaladfglaYaQaQpmlvorlvorlvorlvorp9UgYp9AdbbaladfglaYaQaQpmwDqkwDqkwDqkwDqkp9UgYp9AdbbaladfglaYaQaQpmxmPsxmPsxmPsxmPsp9UgYp9AdbbaladfhiaXczfgXak6mbkkaHclfgHad6mbkasavcjdfaqad2;8qbbavavcjdfaqcufad2fad;8qbbaqaDfgDae6mbkkcbc99arao9Radcaadca0ESEhokavcj;kbf8Kjjjjbaokwbz:bjjjbk::seHu8Jjjjjbc;ae9Rgv8Kjjjjbc9:hodnaeci9UgrcHfal0mbcuhoaiRbbgwc;WeGc;Ge9hmbawcsGgwce0mbavc;abfcFecje;8kbavcUf9cu83ibavc8Wf9cu83ibavcyf9cu83ibavcaf9cu83ibavcKf9cu83ibavczf9cu83ibav9cu83iwav9cu83ibaialfc9WfhDaicefgqarfhidnaeTmbcmcsawceSEhkcbhxcbhmcbhPcbhwcbhlindnaiaD9nmbc9:hoxikdndnaqRbbgoc;Ve0mbavc;abfalaocu7gscl4fcsGcitfgzydlhrazydbhzdnaocsGgHak9pmbavawasfcsGcdtfydbaxaHEhoaHThsdndnadcd9hmbabaPcetfgHaz87ebaHclfao87ebaHcdfar87ebxekabaPcdtfgHazBdbaHcwfaoBdbaHclfarBdbkaxasfhxcdhHavawcdtfaoBdbawasfhwcehsalhOxdkdndnaHcsSmbaHc987aHamffcefhoxekaicefhoai8SbbgHcFeGhsdndnaHcu9mmbaohixekaicvfhiascFbGhscrhHdninao8SbbgOcFbGaHtasVhsaOcu9kmeaocefhoaHcrfgHc8J9hmbxdkkaocefhikasce4cbasceG9R7amfhokdndnadcd9hmbabaPcetfgHaz87ebaHclfao87ebaHcdfar87ebxekabaPcdtfgHazBdbaHcwfaoBdbaHclfarBdbkcdhHavawcdtfaoBdbcehsawcefhwalhOaohmxekdnaocpe0mbaxcefgHavawaDaocsGfRbbgocl49RcsGcdtfydbaocz6gzEhravawao9RcsGcdtfydbaHazfgAaocsGgHEhoaHThCdndnadcd9hmbabaPcetfgHax87ebaHclfao87ebaHcdfar87ebxekabaPcdtfgHaxBdbaHcwfaoBdbaHclfarBdbkcdhsavawcdtfaxBdbavawcefgwcsGcdtfarBdbcihHavc;abfalcitfgOaxBdlaOarBdbavawazfgwcsGcdtfaoBdbalcefcsGhOawaCfhwaxhzaAaCfhxxekaxcbaiRbbgOEgzaoc;:eSgHfhraOcsGhCaOcl4hAdndnaOcs0mbarcefhoxekarhoavawaA9RcsGcdtfydbhrkdndnaCmbaocefhxxekaohxavawaO9RcsGcdtfydbhokdndnaHTmbaicefhHxekaicdfhHai8SbegscFeGhzdnascu9kmbaicofhXazcFbGhzcrhidninaH8SbbgscFbGaitazVhzascu9kmeaHcefhHaicrfgic8J9hmbkaXhHxekaHcefhHkazce4cbazceG9R7amfgmhzkdndnaAcsSmbaHhsxekaHcefhsaH8SbbgicFeGhrdnaicu9kmbaHcvfhXarcFbGhrcrhidninas8SbbgHcFbGaitarVhraHcu9kmeascefhsaicrfgic8J9hmbkaXhsxekascefhskarce4cbarceG9R7amfgmhrkdndnaCcsSmbashixekascefhias8SbbgocFeGhHdnaocu9kmbascvfhXaHcFbGhHcrhodninai8SbbgscFbGaotaHVhHascu9kmeaicefhiaocrfgoc8J9hmbkaXhixekaicefhikaHce4cbaHceG9R7amfgmhokdndnadcd9hmbabaPcetfgHaz87ebaHclfao87ebaHcdfar87ebxekabaPcdtfgHazBdbaHcwfaoBdbaHclfarBdbkcdhsavawcdtfazBdbavawcefgwcsGcdtfarBdbcihHavc;abfalcitfgXazBdlaXarBdbavawaOcz6aAcsSVfgwcsGcdtfaoBdbawaCTaCcsSVfhwalcefcsGhOkaqcefhqavc;abfaOcitfgOarBdlaOaoBdbavc;abfalasfcsGcitfgraoBdlarazBdbawcsGhwalaHfcsGhlaPcifgPae6mbkkcbc99aiaDSEhokavc;aef8Kjjjjbaok:flevu8Jjjjjbcz9Rhvc9:hodnaecvfal0mbcuhoaiRbbc;:eGc;qe9hmbav9cb83iwaicefhraialfc98fhwdnaeTmbdnadcdSmbcbhDindnaraw6mbc9:skarcefhoar8SbbglcFeGhidndnalcu9mmbaohrxekarcvfhraicFbGhicrhldninao8SbbgdcFbGaltaiVhiadcu9kmeaocefhoalcrfglc8J9hmbxdkkaocefhrkabaDcdtfaic8Etc8F91aicd47avcwfaiceGcdtVgoydbfglBdbaoalBdbaDcefgDae9hmbxdkkcbhDindnaraw6mbc9:skarcefhoar8SbbglcFeGhidndnalcu9mmbaohrxekarcvfhraicFbGhicrhldninao8SbbgdcFbGaltaiVhiadcu9kmeaocefhoalcrfglc8J9hmbxdkkaocefhrkabaDcetfaic8Etc8F91aicd47avcwfaiceGcdtVgoydbfgl87ebaoalBdbaDcefgDae9hmbkkcbc99arawSEhokaok:wPliuo97eue978Jjjjjbca9Rhiaec98Ghldndnadcl9hmbdnalTmbcbhvabhdinadadpbbbgocKp:RecKp:Sep;6egraocwp:RecKp:Sep;6earp;Geaoczp:RecKp:Sep;6egwp;Gep;Kep;LegDpxbbbbbbbbbbbbbbbbp:2egqarpxbbbjbbbjbbbjbbbjgkp9op9rp;Kegrpxbb;:9cbb;:9cbb;:9cbb;:9cararp;MeaDaDp;Meawaqawakp9op9rp;Kegrarp;Mep;Kep;Kep;Jep;Negwp;Mepxbbn0bbn0bbn0bbn0gqp;KepxFbbbFbbbFbbbFbbbp9oaopxbbbFbbbFbbbFbbbFp9op9qarawp;Meaqp;Kecwp:RepxbFbbbFbbbFbbbFbbp9op9qaDawp;Meaqp;Keczp:RepxbbFbbbFbbbFbbbFbp9op9qpkbbadczfhdavclfgval6mbkkalaeSmeaipxbbbbbbbbbbbbbbbbgqpklbaiabalcdtfgdaeciGglcdtgv;8qbbdnalTmbaiaipblbgocKp:RecKp:Sep;6egraocwp:RecKp:Sep;6earp;Geaoczp:RecKp:Sep;6egwp;Gep;Kep;LegDaqp:2egqarpxbbbjbbbjbbbjbbbjgkp9op9rp;Kegrpxbb;:9cbb;:9cbb;:9cbb;:9cararp;MeaDaDp;Meawaqawakp9op9rp;Kegrarp;Mep;Kep;Kep;Jep;Negwp;Mepxbbn0bbn0bbn0bbn0gqp;KepxFbbbFbbbFbbbFbbbp9oaopxbbbFbbbFbbbFbbbFp9op9qarawp;Meaqp;Kecwp:RepxbFbbbFbbbFbbbFbbp9op9qaDawp;Meaqp;Keczp:RepxbbFbbbFbbbFbbbFbp9op9qpklbkadaiav;8qbbskdnalTmbcbhvabhdinadczfgxaxpbbbgopxbbbbbbFFbbbbbbFFgkp9oadpbbbgDaopmbediwDqkzHOAKY8AEgwczp:Reczp:Sep;6egraDaopmlvorxmPsCXQL358E8FpxFubbFubbFubbFubbp9op;6eawczp:Sep;6egwp;Gearp;Gep;Kep;Legopxbbbbbbbbbbbbbbbbp:2egqarpxbbbjbbbjbbbjbbbjgmp9op9rp;Kegrpxb;:FSb;:FSb;:FSb;:FSararp;Meaoaop;Meawaqawamp9op9rp;Kegrarp;Mep;Kep;Kep;Jep;Negwp;Mepxbbn0bbn0bbn0bbn0gqp;KepxFFbbFFbbFFbbFFbbp9oaoawp;Meaqp;Keczp:Rep9qgoarawp;Meaqp;KepxFFbbFFbbFFbbFFbbp9ogrpmwDKYqk8AExm35Ps8E8Fp9qpkbbadaDakp9oaoarpmbezHdiOAlvCXorQLp9qpkbbadcafhdavclfgval6mbkkalaeSmbaiaeciGgvcitgdfcbcaad9R;8kbaiabalcitfglad;8qbbdnavTmbaiaipblzgopxbbbbbbFFbbbbbbFFgkp9oaipblbgDaopmbediwDqkzHOAKY8AEgwczp:Reczp:Sep;6egraDaopmlvorxmPsCXQL358E8FpxFubbFubbFubbFubbp9op;6eawczp:Sep;6egwp;Gearp;Gep;Kep;Legopxbbbbbbbbbbbbbbbbp:2egqarpxbbbjbbbjbbbjbbbjgmp9op9rp;Kegrpxb;:FSb;:FSb;:FSb;:FSararp;Meaoaop;Meawaqawamp9op9rp;Kegrarp;Mep;Kep;Kep;Jep;Negwp;Mepxbbn0bbn0bbn0bbn0gqp;KepxFFbbFFbbFFbbFFbbp9oaoawp;Meaqp;Keczp:Rep9qgoarawp;Meaqp;KepxFFbbFFbbFFbbFFbbp9ogrpmwDKYqk8AExm35Ps8E8Fp9qpklzaiaDakp9oaoarpmbezHdiOAlvCXorQLp9qpklbkalaiad;8qbbkk;4wllue97euv978Jjjjjbc8W9Rhidnaec98GglTmbcbhvabhoinaiaopbbbgraoczfgwpbbbgDpmlvorxmPsCXQL358E8Fgqczp:Segkclp:RepklbaopxbbjZbbjZbbjZbbjZpx;Zl81Z;Zl81Z;Zl81Z;Zl81Zakpxibbbibbbibbbibbbp9qp;6ep;NegkaraDpmbediwDqkzHOAKY8AEgrczp:Reczp:Sep;6ep;MegDaDp;Meakarczp:Sep;6ep;Megxaxp;Meakaqczp:Reczp:Sep;6ep;Megqaqp;Mep;Kep;Kep;Lepxbbbbbbbbbbbbbbbbp:4ep;Jepxb;:FSb;:FSb;:FSb;:FSgkp;Mepxbbn0bbn0bbn0bbn0grp;KepxFFbbFFbbFFbbFFbbgmp9oaxakp;Mearp;Keczp:Rep9qgxaDakp;Mearp;Keamp9oaqakp;Mearp;Keczp:Rep9qgkpmbezHdiOAlvCXorQLgrp5baipblbpEb:T:j83ibaocwfarp5eaipblbpEe:T:j83ibawaxakpmwDKYqk8AExm35Ps8E8Fgkp5baipblbpEd:T:j83ibaocKfakp5eaipblbpEi:T:j83ibaocafhoavclfgval6mbkkdnalaeSmbaiaeciGgvcitgofcbcaao9R;8kbaiabalcitfgwao;8qbbdnavTmbaiaipblbgraipblzgDpmlvorxmPsCXQL358E8Fgqczp:Segkclp:RepklaaipxbbjZbbjZbbjZbbjZpx;Zl81Z;Zl81Z;Zl81Z;Zl81Zakpxibbbibbbibbbibbbp9qp;6ep;NegkaraDpmbediwDqkzHOAKY8AEgrczp:Reczp:Sep;6ep;MegDaDp;Meakarczp:Sep;6ep;Megxaxp;Meakaqczp:Reczp:Sep;6ep;Megqaqp;Mep;Kep;Kep;Lepxbbbbbbbbbbbbbbbbp:4ep;Jepxb;:FSb;:FSb;:FSb;:FSgkp;Mepxbbn0bbn0bbn0bbn0grp;KepxFFbbFFbbFFbbFFbbgmp9oaxakp;Mearp;Keczp:Rep9qgxaDakp;Mearp;Keamp9oaqakp;Mearp;Keczp:Rep9qgkpmbezHdiOAlvCXorQLgrp5baipblapEb:T:j83ibaiarp5eaipblapEe:T:j83iwaiaxakpmwDKYqk8AExm35Ps8E8Fgkp5baipblapEd:T:j83izaiakp5eaipblapEi:T:j83iKkawaiao;8qbbkk:Pddiue978Jjjjjbc;ab9Rhidnadcd4ae2glc98GgvTmbcbheabhdinadadpbbbgocwp:Recwp:Sep;6eaocep:SepxbbjFbbjFbbjFbbjFp9opxbbjZbbjZbbjZbbjZp:Uep;Mepkbbadczfhdaeclfgeav6mbkkdnavalSmbaialciGgecdtgdVcbc;abad9R;8kbaiabavcdtfgvad;8qbbdnaeTmbaiaipblbgocwp:Recwp:Sep;6eaocep:SepxbbjFbbjFbbjFbbjFp9opxbbjZbbjZbbjZbbjZp:Uep;Mepklbkavaiad;8qbbkk9teiucbcbydj1jjbgeabcifc98GfgbBdj1jjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaikkkebcjwklz:Dbb"):unpack("b9H79Tebbbe8Fv9Gbb9Gvuuuuueu9Giuuub9Geueu9Giuuueuikqbeeedddillviebeoweuec:q:Odkr;leDo9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bb8A9TW79O9V9Wt9F9KW9J9V9KW9wWVtW949c919M9MWVbeY9TW79O9V9Wt9F9KW9J9V9KW69U9KW949c919M9MWVbdE9TW79O9V9Wt9F9KW9J9V9KW69U9KW949tWG91W9U9JWbiL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9p9JtblK9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9r919HtbvL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVT949Wbol79IV9Rbrq;w8Wqdbk;esezu8Jjjjjbcj;eb9Rgv8Kjjjjbc9:hodnadcefal0mbcuhoaiRbbc:Ge9hmbavaialfgrad9Radz1jjjbhwcj;abad9Uc;WFbGgocjdaocjd6EhDaicefhocbhqdnindndndnaeaq9nmbaDaeaq9RaqaDfae6Egkcsfglcl4cifcd4hxalc9WGgmTmecbhPawcjdfhsaohzinaraz9Rax6mvarazaxfgo9RcK6mvczhlcbhHinalgic9WfgOawcj;cbffhldndndndndnazaOco4fRbbaHcoG4ciGPlbedibkal9cb83ibalcwf9cb83ibxikalaoRblaoRbbgOco4gAaAciSgAE86bbawcj;cbfaifglcGfaoclfaAfgARbbaOcl4ciGgCaCciSgCE86bbalcVfaAaCfgARbbaOcd4ciGgCaCciSgCE86bbalc7faAaCfgARbbaOciGgOaOciSgOE86bbalctfaAaOfgARbbaoRbegOco4gCaCciSgCE86bbalc91faAaCfgARbbaOcl4ciGgCaCciSgCE86bbalc4faAaCfgARbbaOcd4ciGgCaCciSgCE86bbalc93faAaCfgARbbaOciGgOaOciSgOE86bbalc94faAaOfgARbbaoRbdgOco4gCaCciSgCE86bbalc95faAaCfgARbbaOcl4ciGgCaCciSgCE86bbalc96faAaCfgARbbaOcd4ciGgCaCciSgCE86bbalc97faAaCfgARbbaOciGgOaOciSgOE86bbalc98faAaOfgORbbaoRbigoco4gAaAciSgAE86bbalc99faOaAfgORbbaocl4ciGgAaAciSgAE86bbalc9:faOaAfgORbbaocd4ciGgAaAciSgAE86bbalcufaOaAfglRbbaociGgoaociSgoE86bbalaofhoxdkalaoRbwaoRbbgOcl4gAaAcsSgAE86bbawcj;cbfaifglcGfaocwfaAfgARbbaOcsGgOaOcsSgOE86bbalcVfaAaOfgORbbaoRbegAcl4gCaCcsSgCE86bbalc7faOaCfgORbbaAcsGgAaAcsSgAE86bbalctfaOaAfgORbbaoRbdgAcl4gCaCcsSgCE86bbalc91faOaCfgORbbaAcsGgAaAcsSgAE86bbalc4faOaAfgORbbaoRbigAcl4gCaCcsSgCE86bbalc93faOaCfgORbbaAcsGgAaAcsSgAE86bbalc94faOaAfgORbbaoRblgAcl4gCaCcsSgCE86bbalc95faOaCfgORbbaAcsGgAaAcsSgAE86bbalc96faOaAfgORbbaoRbvgAcl4gCaCcsSgCE86bbalc97faOaCfgORbbaAcsGgAaAcsSgAE86bbalc98faOaAfgORbbaoRbogAcl4gCaCcsSgCE86bbalc99faOaCfgORbbaAcsGgAaAcsSgAE86bbalc9:faOaAfgORbbaoRbrgocl4gAaAcsSgAE86bbalcufaOaAfglRbbaocsGgoaocsSgoE86bbalaofhoxekalao8Pbb83bbalcwfaocwf8Pbb83bbaoczfhokdnaiam9pmbaHcdfhHaiczfhlarao9RcL0mekkaiam6mvaoTmvdnakTmbawaPfRbbhHawcj;cbfhlashiakhOinaialRbbgzce4cbazceG9R7aHfgH86bbaiadfhialcefhlaOcufgOmbkkascefhsaohzaPcefgPad9hmbxikkcbc99arao9Radcaadca0ESEhoxlkaoaxad2fhCdnakmbadhlinaoTmlarao9Rax6mlaoaxfhoalcufglmbkaChoxekcbhmawcjdfhAinarao9Rax6miawamfRbbhHawcj;cbfhlaAhiakhOinaialRbbgzce4cbazceG9R7aHfgH86bbaiadfhialcefhlaOcufgOmbkaAcefhAaoaxfhoamcefgmad9hmbkaChokabaqad2fawcjdfakad2z1jjjb8Aawawcjdfakcufad2fadz1jjjb8Aakaqfhqaombkc9:hoxekc9:hokavcj;ebf8Kjjjjbaok;cseHu8Jjjjjbc;ae9Rgv8Kjjjjbc9:hodnaeci9UgrcHfal0mbcuhoaiRbbgwc;WeGc;Ge9hmbawcsGgwce0mbavc;abfcFecjez:jjjjb8AavcUf9cu83ibavc8Wf9cu83ibavcyf9cu83ibavcaf9cu83ibavcKf9cu83ibavczf9cu83ibav9cu83iwav9cu83ibaialfc9WfhDaicefgqarfhidnaeTmbcmcsawceSEhkcbhxcbhmcbhPcbhwcbhlindnaiaD9nmbc9:hoxikdndnaqRbbgoc;Ve0mbavc;abfalaocu7gscl4fcsGcitfgzydlhrazydbhzdnaocsGgHak9pmbavawasfcsGcdtfydbaxaHEhoaHThsdndnadcd9hmbabaPcetfgHaz87ebaHclfao87ebaHcdfar87ebxekabaPcdtfgHazBdbaHcwfaoBdbaHclfarBdbkaxasfhxcdhHavawcdtfaoBdbawasfhwcehsalhOxdkdndnaHcsSmbaHc987aHamffcefhoxekaicefhoai8SbbgHcFeGhsdndnaHcu9mmbaohixekaicvfhiascFbGhscrhHdninao8SbbgOcFbGaHtasVhsaOcu9kmeaocefhoaHcrfgHc8J9hmbxdkkaocefhikasce4cbasceG9R7amfhokdndnadcd9hmbabaPcetfgHaz87ebaHclfao87ebaHcdfar87ebxekabaPcdtfgHazBdbaHcwfaoBdbaHclfarBdbkcdhHavawcdtfaoBdbcehsawcefhwalhOaohmxekdnaocpe0mbaxcefgHavawaDaocsGfRbbgocl49RcsGcdtfydbaocz6gzEhravawao9RcsGcdtfydbaHazfgAaocsGgHEhoaHThCdndnadcd9hmbabaPcetfgHax87ebaHclfao87ebaHcdfar87ebxekabaPcdtfgHaxBdbaHcwfaoBdbaHclfarBdbkcdhsavawcdtfaxBdbavawcefgwcsGcdtfarBdbcihHavc;abfalcitfgOaxBdlaOarBdbavawazfgwcsGcdtfaoBdbalcefcsGhOawaCfhwaxhzaAaCfhxxekaxcbaiRbbgOEgzaoc;:eSgHfhraOcsGhCaOcl4hAdndnaOcs0mbarcefhoxekarhoavawaA9RcsGcdtfydbhrkdndnaCmbaocefhxxekaohxavawaO9RcsGcdtfydbhokdndnaHTmbaicefhHxekaicdfhHai8SbegscFeGhzdnascu9kmbaicofhXazcFbGhzcrhidninaH8SbbgscFbGaitazVhzascu9kmeaHcefhHaicrfgic8J9hmbkaXhHxekaHcefhHkazce4cbazceG9R7amfgmhzkdndnaAcsSmbaHhsxekaHcefhsaH8SbbgicFeGhrdnaicu9kmbaHcvfhXarcFbGhrcrhidninas8SbbgHcFbGaitarVhraHcu9kmeascefhsaicrfgic8J9hmbkaXhsxekascefhskarce4cbarceG9R7amfgmhrkdndnaCcsSmbashixekascefhias8SbbgocFeGhHdnaocu9kmbascvfhXaHcFbGhHcrhodninai8SbbgscFbGaotaHVhHascu9kmeaicefhiaocrfgoc8J9hmbkaXhixekaicefhikaHce4cbaHceG9R7amfgmhokdndnadcd9hmbabaPcetfgHaz87ebaHclfao87ebaHcdfar87ebxekabaPcdtfgHazBdbaHcwfaoBdbaHclfarBdbkcdhsavawcdtfazBdbavawcefgwcsGcdtfarBdbcihHavc;abfalcitfgXazBdlaXarBdbavawaOcz6aAcsSVfgwcsGcdtfaoBdbawaCTaCcsSVfhwalcefcsGhOkaqcefhqavc;abfaOcitfgOarBdlaOaoBdbavc;abfalasfcsGcitfgraoBdlarazBdbawcsGhwalaHfcsGhlaPcifgPae6mbkkcbc99aiaDSEhokavc;aef8Kjjjjbaok:flevu8Jjjjjbcz9Rhvc9:hodnaecvfal0mbcuhoaiRbbc;:eGc;qe9hmbav9cb83iwaicefhraialfc98fhwdnaeTmbdnadcdSmbcbhDindnaraw6mbc9:skarcefhoar8SbbglcFeGhidndnalcu9mmbaohrxekarcvfhraicFbGhicrhldninao8SbbgdcFbGaltaiVhiadcu9kmeaocefhoalcrfglc8J9hmbxdkkaocefhrkabaDcdtfaic8Etc8F91aicd47avcwfaiceGcdtVgoydbfglBdbaoalBdbaDcefgDae9hmbxdkkcbhDindnaraw6mbc9:skarcefhoar8SbbglcFeGhidndnalcu9mmbaohrxekarcvfhraicFbGhicrhldninao8SbbgdcFbGaltaiVhiadcu9kmeaocefhoalcrfglc8J9hmbxdkkaocefhrkabaDcetfaic8Etc8F91aicd47avcwfaiceGcdtVgoydbfgl87ebaoalBdbaDcefgDae9hmbkkcbc99arawSEhokaok:Lvoeue99dud99eud99dndnadcl9hmbaeTmeindndnabcdfgd8Sbb:Yab8Sbbgi:Ygl:l:tabcefgv8Sbbgo:Ygr:l:tgwJbb;:9cawawNJbbbbawawJbbbb9GgDEgq:mgkaqaicb9iEalMgwawNakaqaocb9iEarMgqaqNMM:r:vglNJbbbZJbbb:;aDEMgr:lJbbb9p9DTmbar:Ohixekcjjjj94hikadai86bbdndnaqalNJbbbZJbbb:;aqJbbbb9GEMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkavad86bbdndnawalNJbbbZJbbb:;awJbbbb9GEMgw:lJbbb9p9DTmbaw:Ohdxekcjjjj94hdkabad86bbabclfhbaecufgembxdkkaeTmbindndnabclfgd8Ueb:Yab8Uebgi:Ygl:l:tabcdfgv8Uebgo:Ygr:l:tgwJb;:FSawawNJbbbbawawJbbbb9GgDEgq:mgkaqaicb9iEalMgwawNakaqaocb9iEarMgqaqNMM:r:vglNJbbbZJbbb:;aDEMgr:lJbbb9p9DTmbar:Ohixekcjjjj94hikadai87ebdndnaqalNJbbbZJbbb:;aqJbbbb9GEMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkavad87ebdndnawalNJbbbZJbbb:;awJbbbb9GEMgw:lJbbb9p9DTmbaw:Ohdxekcjjjj94hdkabad87ebabcwfhbaecufgembkkk;oiliui99iue99dnaeTmbcbhiabhlindndnJ;Zl81Zalcof8UebgvciV:Y:vgoal8Ueb:YNgrJb;:FSNJbbbZJbbb:;arJbbbb9GEMgw:lJbbb9p9DTmbaw:OhDxekcjjjj94hDkalclf8Uebhqalcdf8UebhkabaiavcefciGfcetfaD87ebdndnaoak:YNgwJb;:FSNJbbbZJbbb:;awJbbbb9GEMgx:lJbbb9p9DTmbax:OhDxekcjjjj94hDkabaiavciGfgkcd7cetfaD87ebdndnaoaq:YNgoJb;:FSNJbbbZJbbb:;aoJbbbb9GEMgx:lJbbb9p9DTmbax:OhDxekcjjjj94hDkabaiavcufciGfcetfaD87ebdndnJbbjZararN:tawawN:taoaoN:tgrJbbbbarJbbbb9GE:rJb;:FSNJbbbZMgr:lJbbb9p9DTmbar:Ohvxekcjjjj94hvkabakcetfav87ebalcwfhlaiclfhiaecufgembkkk9mbdnadcd4ae2gdTmbinababydbgecwtcw91:Yaece91cjjj98Gcjjj;8if::NUdbabclfhbadcufgdmbkkk9teiucbcbydj1jjbgeabcifc98GfgbBdj1jjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaik;LeeeudndnaeabVciGTmbabhixekdndnadcz9pmbabhixekabhiinaiaeydbBdbaiclfaeclfydbBdbaicwfaecwfydbBdbaicxfaecxfydbBdbaeczfheaiczfhiadc9Wfgdcs0mbkkadcl6mbinaiaeydbBdbaeclfheaiclfhiadc98fgdci0mbkkdnadTmbinaiaeRbb86bbaicefhiaecefheadcufgdmbkkabk;aeedudndnabciGTmbabhixekaecFeGc:b:c:ew2hldndnadcz9pmbabhixekabhiinaialBdbaicxfalBdbaicwfalBdbaiclfalBdbaiczfhiadc9Wfgdcs0mbkkadcl6mbinaialBdbaiclfhiadc98fgdci0mbkkdnadTmbinaiae86bbaicefhiadcufgdmbkkabkkkebcjwklzNbb"),r=WebAssembly.instantiate(i,{}).then((function(e){(n=e.instance).exports.__wasm_call_ctors()}));function unpack(e){for(var n=new Uint8Array(e.length),i=0;i<e.length;++i){var r=e.charCodeAt(i);n[i]=r>96?r-97:r>64?r-39:r+4}var s=0;for(i=0;i<e.length;++i)n[s++]=n[i]<60?t[n[i]]:64*(n[i]-60)+n[++i];return n.buffer.slice(0,s)}function decode(e,t,n,i,r,s,o){var a=e.exports.sbrk,A=i+3&-4,l=a(A*r),c=a(s.length),p=new Uint8Array(e.exports.memory.buffer);p.set(s,c);var h=t(l,i,r,c,s.length);if(0==h&&o&&o(l,A,r),n.set(p.subarray(l,l+i*r)),a(l-a(0)),0!=h)throw new Error("Malformed buffer data: "+h)}var s={NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},o={ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"},a=[],A=0;function createWorker(e){var t={object:new Worker(e),pending:0,requests:{}};return t.object.onmessage=function(e){var n=e.data;t.pending-=n.count,t.requests[n.id][n.action](n.value),delete t.requests[n.id]},t}function workerProcess(e){var t=e.data;if(!t.id)return self.close();self.ready.then((function(e){try{var n=new Uint8Array(t.count*t.size);decode(e,e.exports[t.mode],n,t.count,t.size,t.source,e.exports[t.filter]),self.postMessage({id:t.id,count:t.count,action:"resolve",value:n},[n.buffer])}catch(e){self.postMessage({id:t.id,count:t.count,action:"reject",value:e})}}))}return{ready:r,supported:!0,useWorkers:function(e){!function initWorkers(e){for(var t="self.ready = WebAssembly.instantiate(new Uint8Array(["+new Uint8Array(i)+"]), {}).then(function(result) { result.instance.exports.__wasm_call_ctors(); return result.instance; });self.onmessage = "+workerProcess.name+";"+decode.toString()+workerProcess.toString(),n=new Blob([t],{type:"text/javascript"}),r=URL.createObjectURL(n),s=a.length;s<e;++s)a[s]=createWorker(r);for(s=e;s<a.length;++s)a[s].object.postMessage({});a.length=e,URL.revokeObjectURL(r)}(e)},decodeVertexBuffer:function(e,t,i,r,o){decode(n,n.exports.meshopt_decodeVertexBuffer,e,t,i,r,n.exports[s[o]])},decodeIndexBuffer:function(e,t,i,r){decode(n,n.exports.meshopt_decodeIndexBuffer,e,t,i,r)},decodeIndexSequence:function(e,t,i,r){decode(n,n.exports.meshopt_decodeIndexSequence,e,t,i,r)},decodeGltfBuffer:function(e,t,i,r,a,A){decode(n,n.exports[o[a]],e,t,i,r,n.exports[s[A]])},decodeGltfBufferAsync:function(e,t,i,l,c){return a.length>0?function decodeWorker(e,t,n,i,r){for(var s=a[0],o=1;o<a.length;++o)a[o].pending<s.pending&&(s=a[o]);return new Promise((function(o,a){var l=new Uint8Array(n),c=++A;s.pending+=e,s.requests[c]={resolve:o,reject:a},s.object.postMessage({id:c,count:e,size:t,source:l,mode:i,filter:r},[l.buffer])}))}(e,t,i,o[l],s[c]):r.then((function(){var r=new Uint8Array(e*t);return decode(n,n.exports[o[l]],r,e,t,i,n.exports[s[c]]),r}))}}}();class TDSLoader extends E{constructor(e){super(e),this.debug=!1,this.group=null,this.materials=[],this.meshes=[]}load(e,t,n,i){const r=this,s=""===this.path?w.extractUrlBase(e):this.path,o=new v(this.manager);o.setPath(this.path),o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,(function(n){try{t(r.parse(n,s))}catch(t){i?i(t):console.error(t),r.manager.itemError(e)}}),n,i)}parse(e,t){this.group=new le,this.materials=[],this.meshes=[],this.readFile(e,t);for(let e=0;e<this.meshes.length;e++)this.group.add(this.meshes[e]);return this.group}readFile(e,t){const n=new DataView(e),i=new Chunk(n,0,this.debugMessage);if(i.id===ss||i.id===os||i.id===rs){let e=i.readChunk();for(;e;){if(e.id===as){const t=e.readDWord();this.debugMessage("3DS file version: "+t)}else e.id===ds?this.readMeshData(e,t):this.debugMessage("Unknown main chunk: "+e.hexId);e=i.readChunk()}}this.debugMessage("Parsed "+this.meshes.length+" meshes")}readMeshData(e,t){let n=e.readChunk();for(;n;){if(n.id===gs){const e=+n.readDWord();this.debugMessage("Mesh Version: "+e)}else if(n.id===fs){const e=n.readFloat();this.debugMessage("Master scale: "+e),this.group.scale.set(e,e,e)}else n.id===Rs?(this.debugMessage("Named Object"),this.readNamedObject(n)):n.id===ms?(this.debugMessage("Material"),this.readMaterialEntry(n,t)):this.debugMessage("Unknown MDATA chunk: "+n.hexId);n=e.readChunk()}}readNamedObject(e){const t=e.readString();let n=e.readChunk();for(;n;){if(n.id===Ns){const e=this.readMesh(n);e.name=t,this.meshes.push(e)}else this.debugMessage("Unknown named object chunk: "+n.hexId);n=e.readChunk()}}readMaterialEntry(e,t){let n=e.readChunk();const i=new at;for(;n;){if(n.id===ys)i.name=n.readString(),this.debugMessage(" Name: "+i.name);else if(n.id===vs)this.debugMessage(" Wireframe"),i.wireframe=!0;else if(n.id===Qs){const e=n.readByte();i.wireframeLinewidth=e,this.debugMessage(" Wireframe Thickness: "+e)}else if(n.id===Es)i.side=te,this.debugMessage(" DoubleSided");else if(n.id===ws)this.debugMessage(" Additive Blending"),i.blending=At;else if(n.id===Is)this.debugMessage(" Diffuse Color"),i.color=this.readColor(n);else if(n.id===xs)this.debugMessage(" Specular Color"),i.specular=this.readColor(n);else if(n.id===bs)this.debugMessage(" Ambient color"),i.color=this.readColor(n);else if(n.id===Cs){const e=this.readPercentage(n);i.shininess=100*e,this.debugMessage(" Shininess : "+e)}else if(n.id===Bs){const e=this.readPercentage(n);i.opacity=1-e,this.debugMessage(" Transparency : "+e),i.transparent=i.opacity<1}else n.id===Ps?(this.debugMessage(" ColorMap"),i.map=this.readMap(n,t)):n.id===Ss?(this.debugMessage(" BumpMap"),i.bumpMap=this.readMap(n,t)):n.id===Ts?(this.debugMessage(" OpacityMap"),i.alphaMap=this.readMap(n,t)):n.id===Ms?(this.debugMessage(" SpecularMap"),i.specularMap=this.readMap(n,t)):this.debugMessage(" Unknown material chunk: "+n.hexId);n=e.readChunk()}this.materials[i.name]=i}readMesh(e){let t=e.readChunk();const n=new C,i=new at,r=new d(n,i);for(r.name="mesh";t;){if(t.id===Os){const e=t.readWord();this.debugMessage(" Vertex: "+e);const i=[];for(let n=0;n<e;n++)i.push(t.readFloat()),i.push(t.readFloat()),i.push(t.readFloat());n.setAttribute("position",new a(i,3))}else if(t.id===Gs)this.readFaceArray(t,r);else if(t.id===Ys){const e=t.readWord();this.debugMessage(" UV: "+e);const i=[];for(let n=0;n<e;n++)i.push(t.readFloat()),i.push(t.readFloat());n.setAttribute("uv",new a(i,2))}else if(t.id===zs){this.debugMessage(" Tranformation Matrix (TODO)");const e=[];for(let n=0;n<12;n++)e[n]=t.readFloat();const i=new m;i.elements[0]=e[0],i.elements[1]=e[6],i.elements[2]=e[3],i.elements[3]=e[9],i.elements[4]=e[2],i.elements[5]=e[8],i.elements[6]=e[5],i.elements[7]=e[11],i.elements[8]=e[1],i.elements[9]=e[7],i.elements[10]=e[4],i.elements[11]=e[10],i.elements[12]=0,i.elements[13]=0,i.elements[14]=0,i.elements[15]=1,i.transpose();const s=new m;s.copy(i).invert(),n.applyMatrix4(s),i.decompose(r.position,r.quaternion,r.scale)}else this.debugMessage(" Unknown mesh chunk: "+t.hexId);t=e.readChunk()}return n.computeVertexNormals(),r}readFaceArray(e,t){const n=e.readWord();this.debugMessage(" Faces: "+n);const i=[];for(let t=0;t<n;++t)i.push(e.readWord(),e.readWord(),e.readWord()),e.readWord();t.geometry.setIndex(i);let r=0,s=0;for(;!e.endOfChunk;){const n=e.readChunk();if(n.id===Us){this.debugMessage(" Material Group");const e=this.readMaterialGroup(n),i=3*e.index.length;t.geometry.addGroup(s,i,r),s+=i,r++;const o=this.materials[e.name];!1===Array.isArray(t.material)&&(t.material=[]),void 0!==o&&t.material.push(o)}else this.debugMessage(" Unknown face array chunk: "+n.hexId)}1===t.material.length&&(t.material=t.material[0])}readMap(e,t){let n=e.readChunk(),i={};const r=new O(this.manager);for(r.setPath(this.resourcePath||t).setCrossOrigin(this.crossOrigin);n;){if(n.id===Ds){const e=n.readString();i=r.load(e),i.userData.name=e.split(".").slice(0,-1).join("."),this.debugMessage(" File: "+t+e)}else n.id===Fs?(i.offset.x=n.readFloat(),this.debugMessage(" OffsetX: "+i.offset.x)):n.id===ks?(i.offset.y=n.readFloat(),this.debugMessage(" OffsetY: "+i.offset.y)):n.id===Ls?(i.repeat.x=n.readFloat(),this.debugMessage(" RepeatX: "+i.repeat.x)):n.id===_s?(i.repeat.y=n.readFloat(),this.debugMessage(" RepeatY: "+i.repeat.y)):this.debugMessage(" Unknown map chunk: "+n.hexId);n=e.readChunk()}return i}readMaterialGroup(e){const t=e.readString(),n=e.readWord();this.debugMessage(" Name: "+t),this.debugMessage(" Faces: "+n);const i=[];for(let t=0;t<n;++t)i.push(e.readWord());return{name:t,index:i}}readColor(e){const t=e.readChunk(),n=new T;if(t.id===ls||t.id===cs){const e=t.readByte(),i=t.readByte(),r=t.readByte();n.setRGB(e/255,i/255,r/255),this.debugMessage(" Color: "+n.r+", "+n.g+", "+n.b)}else if(t.id===As||t.id===ps){const e=t.readFloat(),i=t.readFloat(),r=t.readFloat();n.setRGB(e,i,r),this.debugMessage(" Color: "+n.r+", "+n.g+", "+n.b)}else this.debugMessage(" Unknown color chunk: "+t.hexId);return n}readPercentage(e){const t=e.readChunk();switch(t.id){case hs:return t.readShort()/100;case us:return t.readFloat();default:return this.debugMessage(" Unknown percentage chunk: "+t.hexId),0}}debugMessage(e){this.debug&&console.log(e)}}class Chunk{constructor(e,t,n){this.data=e,this.offset=t,this.position=t,this.debugMessage=n,this.debugMessage instanceof Function&&(this.debugMessage=function(){}),this.id=this.readWord(),this.size=this.readDWord(),this.end=this.offset+this.size,this.end>e.byteLength&&this.debugMessage("Bad chunk size for chunk at "+t)}readChunk(){if(this.endOfChunk)return null;try{const e=new Chunk(this.data,this.position,this.debugMessage);return this.position+=e.size,e}catch(e){return this.debugMessage("Unable to read chunk at "+this.position),null}}get hexId(){return this.id.toString(16)}get endOfChunk(){return this.position>=this.end}readByte(){const e=this.data.getUint8(this.position,!0);return this.position+=1,e}readFloat(){try{const e=this.data.getFloat32(this.position,!0);return this.position+=4,e}catch(e){return this.debugMessage(e+" "+this.position+" "+this.data.byteLength),0}}readInt(){const e=this.data.getInt32(this.position,!0);return this.position+=4,e}readShort(){const e=this.data.getInt16(this.position,!0);return this.position+=2,e}readDWord(){const e=this.data.getUint32(this.position,!0);return this.position+=4,e}readWord(){const e=this.data.getUint16(this.position,!0);return this.position+=2,e}readString(){let e="",t=this.readByte();for(;t;)e+=String.fromCharCode(t),t=this.readByte();return e}}const rs=19789,ss=15786,os=49725,as=2,As=16,ls=17,cs=18,ps=19,hs=48,us=49,ds=15677,gs=15678,fs=256,ms=45055,ys=40960,bs=40976,Is=40992,xs=41008,Cs=41024,Bs=41040,Es=41089,ws=41091,vs=41093,Qs=41095,Ps=41472,Ts=41488,Ss=41520,Ms=41476,Ds=41728,Ls=41812,_s=41814,Fs=41816,ks=41818,Rs=16384,Ns=16640,Os=16656,Gs=16672,Us=16688,Ys=16704,zs=16736;const to_std=(t,n)=>{if(!t||"MeshPhongMaterial"!==t.type)return t;if(n){const e=n.get(t);if(e)return e}const i=1-("number"==typeof t.shininess?Math.min(Math.max(t.shininess,0),100):30)/100,r=new e.MeshStandardMaterial({name:t.name,color:t.color,map:t.map,normalMap:t.normalMap,emissive:t.emissive,emissiveMap:t.emissiveMap,envMap:t.envMap,envMapIntensity:t.envMapIntensity??1,lightMap:t.lightMap,lightMapIntensity:t.lightMapIntensity,alphaTest:t.alphaTest,depthWrite:t.depthWrite,depthTest:t.depthTest,wireframe:t.wireframe,transparent:t.transparent,opacity:t.opacity,side:t.side,roughness:i,metalness:0});return n&&n.set(t,r),"function"==typeof t.dispose&&(t.dispose(),t.userData=t.userData||{},t.userData._replaced=!0),r.needsUpdate=!0,r};function newgcad(t,n,i,r=!0){let s={},o={},a={},A={},l={};const c=new Map;let p={},h={},u=[],d=new e.TextureLoader,g=new GLTFLoader,f=new TDSLoader;const m=new DRACOLoader;m.setDecoderPath("https://www.gstatic.com/draco/versioned/decoders/1.5.6/"),g.setDRACOLoader(m);const y=new KTX2Loader;y.setTranscoderPath("https://unpkg.com/three@0.159.0/examples/jsm/libs/basis/"),g.setKTX2Loader(y),g.setMeshoptDecoder(is);let b=[i],getcat=()=>b[b.length-1],I={};async function clearmat(){for(const e in o)if(o[e]){const t=await o[e];t?.dispose()}for(const e in p)p[e]&&p[e]?.dispose();for(const[e,t]of c.entries()){const e=t instanceof Promise?await t:t;e?.dispose&&e.dispose()}c.clear(),o={},p={}}function getdims(t,n=!1){let i=new e.Box3,n2=e=>Math.round(100*e)/100;return t.updateWorldMatrix(!0,!0),n?t.traverse((e=>{e.visible&&e.isMesh&&e.geometry&&(e.geometry.computeBoundingBox(),i.union(e.geometry.boundingBox.clone().applyMatrix4(e.matrixWorld)))})):i.setFromObject(t),{zero:{x:n2(-i.min.x),y:n2(-i.min.y),z:n2(-i.min.z)},dim:{x:n2(i.max.x-i.min.x),y:n2(i.max.y-i.min.y),z:n2(i.max.z-i.min.z)},position:t.position,rotation:{x:t.rotation.x,y:t.rotation.y,z:t.rotation.z},scale:t.scale}}async function get3ds(n,i=!1){n.endsWith(".3ds")&&(n=n.slice(0,-4));const r=hash(`${getcat()}|${n}.3ds`);if(a[r])return a[r];let s=await new Promise(((e,i)=>{let s,o="";n.startsWith("https://")?(s=`${n}.3ds`,o=s):t._cdn?(s=`${t._cdn}${getcat()}/3d/${n}.3ds`,o=`${t._cdn}${getcat()}/3d/${n}/`):(s=t.fullget("mufiles/getfile",{id:getcat(),subfolder:"3d",name:n,ext:".3ds"}),o=s+"&tex="),f.setResourcePath(o),f.load(s,(t=>{const n=new WeakMap;t.traverse((e=>{e.isMesh&&e.material&&(e.material=Array.isArray(e.material)?e.material.map((e=>to_std(e,n))):to_std(e.material,n))})),t.userData||(t.userData={}),t.userData._ky=r,e(t)}),void 0,(t=>{console.log(t),delete a[r],e(void 0)}))}));if(i){let t=new e.Group;t.rotation.x=-Math.PI/2,t.add(s),a[r]=t}else a[r]=s;return a[r]}async function getglb(e){const n=".glb";e.endsWith(n)&&(e=e.slice(0,-4)),e.startsWith("https://")||(e=e.replace(/\//g,"+"));let i=(e=e.split("+"))[1];e=e[0];const r=hash(`${getcat()}|${e}${n}`);a[r]||(a[r]=await new Promise(((i,s)=>{let o;o=e.startsWith("https://")?`${e}.glb`:t._cdn?`${t._cdn}${getcat()}/3d/${e}.glb`:t.fullget("mufiles/getfile",{id:getcat(),subfolder:"3d",name:e,ext:n}),g.setPath(""),g.setResourcePath((e=>(console.log("risorsa",e),`${o}&tex=${e}`))),g.load(o,(async e=>{const t=e.scene;t.userData||(t.userData={}),t.userData._ky=r,i(t)}),void 0,(e=>{console.log(e),delete a[r],i(void 0)}))})));let s=a[r];if(i){let e=s?.getObjectByName(i);e&&(s=e)}return s}return{clearmatricole:()=>{I={},u=[]},P:t,bus:n,tex:async function tex(n,i=1,r,s){let a;return r||(r=i),s||(s=0),"__alpha"==n?(a=n,o[a]||(o[a]=function getfortransparent(){const t=new e.CanvasTexture(function generateTexture(){const e=document.createElement("canvas");e.width=2,e.height=2;const t=e.getContext("2d");return t.fillStyle="white",t.fillRect(0,1,2,1),e}());return t.magFilter=e.NearestFilter,t.wrapT=e.RepeatWrapping,t.wrapS=e.RepeatWrapping,t.repeat.set(1,3.5),t}()),o[a]):(a=hash(`${getcat()}|${n}|${i}|${r}|${s}`),o[a]||(o[a]=new Promise(((A,l)=>{let p;if(n.startsWith("https://"))p=n;else if(t._cdn)if(n.includes("/")){let e=n.split("/");p=`${t._cdn}${e[0]}/textures/${e[1]}`}else p=`${t._cdn}${getcat()}/textures/${n}`;else p=t.fullget("mufiles/getfile",{id:getcat(),subfolder:"textures",name:n,force:1});if(c.has(p)){const t=c.get(p).clone();return t.wrapS=e.RepeatWrapping,t.wrapT=e.RepeatWrapping,t.center.set(.5,.5),t.repeat.set(i,r),t.rotation=s,void A(t)}d.load(p,(t=>{c.set(p,t),t.wrapS=e.RepeatWrapping,t.wrapT=e.RepeatWrapping,t.repeat.set(i,r),t.center.set(.5,.5),t.rotation=s,A(t)}),void 0,(e=>{console.log(`Manca Texture ${n}!. questo rallenta molto il processo`),delete o[a],A(void 0)}))}))),o[a])},getglb:getglb,get3ds:get3ds,replacemats:function replacemats(e,t,n){if(!Array.isArray(t)||0==t.length)return e;const leggi_slot=e=>{if(!e)return-1;let t=(e?.map?.name||e?.name||e?.map?.userData?.name||"").toString().trim();if(n){const i=n(t,e);void 0!==i&&(t=i)}if(t.includes("_")&&(t=t.split("_").pop()),!t)return-1;const i=parseInt(t,10);return i>=1&&i<=9?i:-1};let i=!1,r=String(e.userData?._ky||"");if(e.traverse((e=>{if(!e.isMesh)return;const n=Array.isArray(e.material)?e.material:[e.material];for(const e of n){const n=leggi_slot(e);n>0&&t[n-1]&&(i=!0,r+="|"+(t[n-1].name||t[n-1].uuid))}})),i){if(r=hash(r),a[r])return a[r];const n=e.clone(!0);n.traverse((e=>{if(e.isMesh)if(Array.isArray(e.material))e.material=e.material.map((e=>{if(!e)return e;const n=leggi_slot(e);if(n>0&&t[n-1]){const e=t[n-1];return e.needsUpdate=!0,e}return e}));else{const n=e.material,i=leggi_slot(n);e.material=i>0&&t[i-1]?(t[i-1].needsUpdate=!0,t[i-1]):n}})),n.userData=n.userData||{},n.userData._ky=r,a[r]=n,e=n}return e},islog:r,clear:async function clear(){function destroymesh(e){function disposeMaterial(e){e.map&&e.map.dispose(),e.lightMap&&e.lightMap.dispose(),e.bumpMap&&e.bumpMap.dispose(),e.normalMap&&e.normalMap.dispose(),e.specularMap&&e.specularMap.dispose(),e.envMap&&e.envMap.dispose(),e.alphaMap&&e.alphaMap.dispose(),e.dispose()}e&&e.traverse((e=>{e.isMesh&&(e.onBeforeRender&&(e.onBeforeRender=null),e.onAfterRender&&(e.onAfterRender=null),e.geometry?.dispose&&e.geometry.dispose(),e.material&&(Array.isArray(e.material)?e.material.forEach(disposeMaterial):disposeMaterial(e.material)))}))}I={},l={},e.Cache.clear();for(const e in A)A[e]?.dispose();for(const e in a)if(a[e]){destroymesh(await a[e])}await clearmat(),s={},o={},a={},A={},p={},h={}},clearmat:clearmat,getdims:getdims,hidenodes:function hidenodes(e,t){let n=new Set;return e.traverse((e=>{(e.isMesh||e.isGroup)&&e.name&&(n.add(e.name),e.visible=!(t&&t.length&&t.includes(e.name.toLowerCase())))})),[...n]},info3d:async function info3d(e,t=1,n=0,i=0){let r=(e||"").endsWith(".3ds")?await get3ds(e):await getglb(e);if(r)return t&&1!=t&&(r.scale.set(t||1,n||t||1,i||t||1),r.needsUpdate=!0),getdims(r)},getScript:async function getScript(e){e.endsWith(".custom")?e=e.slice(0,-7):e.endsWith(".js")&&(e=e.slice(0,-3));let n=hash(`${getcat()}|${e}`);if(!h[n]){let i;try{i=await t.fetch("mufiles/customfn",{id:getcat(),name:e,ispar:1})}catch(t){i=`log('undefined ${getcat()}/${e}: ${t.message}');`}h[n]=i}return h[n]},checkScripts:async function checkScripts(e){let n=[];if(!e||!Array.isArray(e))return;let i=getcat();e=[...e,"_ricalcolatop","_ricalcolaaltri","_ricalcolalinee","_ricalcolaviste"];for(let t of e){let e=hash(`${i}|${t}`);h[e]||n.push(t)}if(n?.length){let e=await t.fetch("mufiles/customfn",{id:i,name:n,ispar:1});if(e)for(let t of e){let e=hash(`${i}|${t.n}`);h[e]=t.v}}},get loaderGLTF(){return g},get BTNS(){return u},get gmats(){return I},scripts:()=>Object.keys(h),get geo(){return A},get movs(){return s},get textures(){return o},get smats(){return p},get meshes(){return a},get cacheFns(){return l},dump(){console.log(`SMATS:\n${Object.keys(p).join(" - ")};\nGEOMS:\n${Object.keys(A).join(" - ")};\nTEX:\n${Object.keys(o).join(" - ")};\nMESH:\n${Object.keys(a).join(" - ")};\n`)},get cat(){return getcat()},pushcat(e){b.push(e)},popcat:()=>(b.length>1&&b.length--,getcat())}}const Hs=new Map;function salvaMaterialiOriginali(e){e.traverse((e=>{if(!e.isMesh||e.layers.mask>1<<20)return;const t=e.material;if(!t)return;const n=Array.isArray(t)?t:[t];Hs.has(e)||Hs.set(e,n)}))}function ripristinaMaterialiOriginali(){for(let[e,t]of Hs.entries())e.material=Array.isArray(t)?[...t]:t;Hs.clear()}function applicaEvidenziazione(e,t,n,i){!function ricorsiva(e,r,s){const o=!!r||!!t&&t.includes(e?.userData?.mat),a=s||e.userData?.evidenziaMap;if(e.isMesh&&e.layers.mask<=1<<20){const t=Hs.get(e);if(!t)return;const r=t.map((e=>{const t=(o?i:n).clone();return a&&e.map&&(t.map=e.map),t.transparent=e.transparent,t.opacity=e.opacity,t}));e.material=Array.isArray(e.material)?r:r[0]}e.children.forEach((e=>ricorsiva(e,o,a)))}(e,!1,!1)}async function evidenziaColli(t,n,i){salvaMaterialiOriginali(t);const r=e.DoubleSide,s=new e.MeshStandardMaterial({color:16777215,roughness:.5,metalness:.4,side:r}),o=new e.MeshStandardMaterial({color:36864,roughness:.5,metalness:.4,side:r});let a=0;try{for(let e of n)a++,e.name||(e.name=`collo_${a}`),applicaEvidenziazione(t,e.mats,s,o),await i(e)}catch(e){console.error("Errore durante evidenzia:",e)}finally{ripristinaMaterialiOriginali()}}const Xs=1.25,qs=32,js=Math.pow(2,-24),Ws=Symbol("SKIP_GENERATION"),Js={strategy:0,maxDepth:40,maxLeafSize:10,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,indirect:!1,verbose:!0,range:null,[Ws]:!1};function arrayToBox(e,t,n){return n.min.x=t[e],n.min.y=t[e+1],n.min.z=t[e+2],n.max.x=t[e+3],n.max.y=t[e+4],n.max.z=t[e+5],n}function getLongestEdgeIndex(e){let t=-1,n=-1/0;for(let i=0;i<3;i++){const r=e[i+3]-e[i];r>n&&(n=r,t=i)}return t}function copyBounds(e,t){t.set(e)}function unionBounds(e,t,n){let i,r;for(let s=0;s<3;s++){const o=s+3;i=e[s],r=t[s],n[s]=i<r?i:r,i=e[o],r=t[o],n[o]=i>r?i:r}}function expandByPrimitiveBounds(e,t,n){for(let i=0;i<3;i++){const r=t[e+2*i],s=t[e+2*i+1],o=r-s,a=r+s;o<n[i]&&(n[i]=o),a>n[i+3]&&(n[i+3]=a)}}function computeSurfaceArea(e){const t=e[3]-e[0],n=e[4]-e[1],i=e[5]-e[2];return 2*(t*n+n*i+i*t)}function IS_LEAF(e,t){return 65535===t[e+15]}function OFFSET(e,t){return t[e+6]}function COUNT(e,t){return t[e+14]}function LEFT_NODE(e){return e+8}function RIGHT_NODE(e,t){return e+8*t[e+6]}function SPLIT_AXIS(e,t){return t[e+7]}function getBounds(e,t,n,i,r){let s=1/0,o=1/0,a=1/0,A=-1/0,l=-1/0,c=-1/0,p=1/0,h=1/0,u=1/0,d=-1/0,g=-1/0,f=-1/0;const m=e.offset||0;for(let i=6*(t-m),r=6*(t+n-m);i<r;i+=6){const t=e[i+0],n=e[i+1],r=t-n,m=t+n;r<s&&(s=r),m>A&&(A=m),t<p&&(p=t),t>d&&(d=t);const y=e[i+2],b=e[i+3],I=y-b,x=y+b;I<o&&(o=I),x>l&&(l=x),y<h&&(h=y),y>g&&(g=y);const C=e[i+4],B=e[i+5],E=C-B,w=C+B;E<a&&(a=E),w>c&&(c=w),C<u&&(u=C),C>f&&(f=C)}i[0]=s,i[1]=o,i[2]=a,i[3]=A,i[4]=l,i[5]=c,r[0]=p,r[1]=h,r[2]=u,r[3]=d,r[4]=g,r[5]=f}const Vs=32,binsSort=(e,t)=>e.candidate-t.candidate,Ks=new Array(Vs).fill().map((()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0}))),Zs=new Float32Array(6);class BVHNode{constructor(){this.boundingData=new Float32Array(6)}}let $s,eo,to,no;const io=Math.pow(2,32);function countNodes(e){return"count"in e?1:1+countNodes(e.left)+countNodes(e.right)}function populateBuffer(e,t,n){return $s=new Float32Array(n),eo=new Uint32Array(n),to=new Uint16Array(n),no=new Uint8Array(n),_populateBuffer(e,t)}function _populateBuffer(e,t){const n=e/4,i=e/2,r="count"in t,s=t.boundingData;for(let e=0;e<6;e++)$s[n+e]=s[e];if(r)return t.buffer?(no.set(new Uint8Array(t.buffer),e),e+t.buffer.byteLength):(eo[n+6]=t.offset,to[i+14]=t.count,to[i+15]=65535,e+qs);{const{left:i,right:r,splitAxis:s}=t;let o=_populateBuffer(e+qs,i);const a=o/qs-e/qs;if(a>io)throw new Error("MeshBVH: Cannot store relative child node offset greater than 32 bits.");return eo[n+6]=a,eo[n+7]=s,_populateBuffer(o,r)}}function buildTree(e,t,n,i,r){const{maxDepth:s,verbose:o,maxLeafSize:a,strategy:A,onProgress:l}=r,c=e.primitiveBuffer,p=e.primitiveBufferStride,h=new Float32Array(6);let u=!1;const d=new BVHNode;return getBounds(t,n,i,d.boundingData,h),function splitNode(e,n,i,r=null,l=0){!u&&l>=s&&(u=!0,o&&console.warn(`BVH: Max depth of ${s} reached when generating BVH. Consider increasing maxDepth.`));if(i<=a||l>=s)return triggerProgress(n+i),e.offset=n,e.count=i,e;const d=function getOptimalSplit(e,t,n,i,r,s){let o=-1,a=0;if(0===s)o=getLongestEdgeIndex(t),-1!==o&&(a=(t[o]+t[o+3])/2);else if(1===s)o=getLongestEdgeIndex(e),-1!==o&&(a=function getAverage(e,t,n,i){let r=0;const s=e.offset;for(let o=t,a=t+n;o<a;o++)r+=e[6*(o-s)+2*i];return r/n}(n,i,r,o));else if(2===s){const s=computeSurfaceArea(e);let A=Xs*r;const l=n.offset||0,c=6*(i-l),p=6*(i+r-l);for(let e=0;e<3;e++){const i=t[e],l=(t[e+3]-i)/Vs;if(r<8){const t=[...Ks];t.length=r;let i=0;for(let r=c;r<p;r+=6,i++){const s=t[i];s.candidate=n[r+2*e],s.count=0;const{bounds:o,leftCacheBounds:a,rightCacheBounds:A}=s;for(let e=0;e<3;e++)A[e]=1/0,A[e+3]=-1/0,a[e]=1/0,a[e+3]=-1/0,o[e]=1/0,o[e+3]=-1/0;expandByPrimitiveBounds(r,n,o)}t.sort(binsSort);let l=r;for(let e=0;e<l;e++){const n=t[e];for(;e+1<l&&t[e+1].candidate===n.candidate;)t.splice(e+1,1),l--}for(let i=c;i<p;i+=6){const r=n[i+2*e];for(let e=0;e<l;e++){const s=t[e];r>=s.candidate?expandByPrimitiveBounds(i,n,s.rightCacheBounds):(expandByPrimitiveBounds(i,n,s.leftCacheBounds),s.count++)}}for(let n=0;n<l;n++){const i=t[n],l=i.count,c=r-i.count,p=i.leftCacheBounds,h=i.rightCacheBounds;let u=0;0!==l&&(u=computeSurfaceArea(p)/s);let d=0;0!==c&&(d=computeSurfaceArea(h)/s);const g=1+Xs*(u*l+d*c);g<A&&(o=e,A=g,a=i.candidate)}}else{for(let e=0;e<Vs;e++){const t=Ks[e];t.count=0,t.candidate=i+l+e*l;const n=t.bounds;for(let e=0;e<3;e++)n[e]=1/0,n[e+3]=-1/0}for(let t=c;t<p;t+=6){let r=~~((n[t+2*e]-i)/l);r>=Vs&&(r=31);const s=Ks[r];s.count++,expandByPrimitiveBounds(t,n,s.bounds)}const t=Ks[31];copyBounds(t.bounds,t.rightCacheBounds);for(let e=30;e>=0;e--){const t=Ks[e],n=Ks[e+1];unionBounds(t.bounds,n.rightCacheBounds,t.rightCacheBounds)}let h=0;for(let t=0;t<31;t++){const n=Ks[t],i=n.count,l=n.bounds,c=Ks[t+1].rightCacheBounds;0!==i&&(0===h?copyBounds(l,Zs):unionBounds(l,Zs,Zs)),h+=i;let p=0,u=0;0!==h&&(p=computeSurfaceArea(Zs)/s);const d=r-h;0!==d&&(u=computeSurfaceArea(c)/s);const g=1+Xs*(p*h+u*d);g<A&&(o=e,A=g,a=n.candidate)}}}}else console.warn(`BVH: Invalid build strategy value ${s} used.`);return{axis:o,pos:a}}(e.boundingData,r,t,n,i,A);if(-1===d.axis)return triggerProgress(n+i),e.offset=n,e.count=i,e;const g=function partition(e,t,n,i,r,s){let o=i,a=i+r-1;const A=s.pos,l=2*s.axis,c=n.offset||0;for(;;){for(;o<=a&&n[6*(o-c)+l]<A;)o++;for(;o<=a&&n[6*(a-c)+l]>=A;)a--;if(!(o<a))return o;for(let n=0;n<t;n++){let i=e[o*t+n];e[o*t+n]=e[a*t+n],e[a*t+n]=i}for(let e=0;e<6;e++){const t=o-c,i=a-c,r=n[6*t+e];n[6*t+e]=n[6*i+e],n[6*i+e]=r}o++,a--}}(c,p,t,n,i,d);if(g===n||g===n+i)triggerProgress(n+i),e.offset=n,e.count=i;else{e.splitAxis=d.axis;const r=new BVHNode,s=n,o=g-n;e.left=r,getBounds(t,s,o,r.boundingData,h),splitNode(r,s,o,h,l+1);const a=new BVHNode,A=g,c=i-o;e.right=a,getBounds(t,A,c,a.boundingData,h),splitNode(a,A,c,h,l+1)}return e}(d,n,i,h),d;function triggerProgress(e){l&&l(e/i)}}function buildPackedTree(e,t){const n=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,i=e.getRootRanges(t.range),r=i[0],s=i[i.length-1],o={offset:r.offset,count:s.offset+s.count-r.offset},a=new Float32Array(6*o.count);a.offset=o.offset,e.computePrimitiveBounds(o.offset,o.count,a),e._roots=i.map((i=>{const r=buildTree(e,a,i.offset,i.count,t),s=countNodes(r),o=new n(qs*s);return populateBuffer(0,r,o),o}))}class PrimitivePool{constructor(e){this._getNewPrimitive=e,this._primitives=[]}getPrimitive(){const e=this._primitives;return 0===e.length?this._getNewPrimitive():e.pop()}releasePrimitive(e){this._primitives.push(e)}}class _BufferStack{constructor(){this.float32Array=null,this.uint16Array=null,this.uint32Array=null;const e=[];let t=null;this.setBuffer=n=>{t&&e.push(t),t=n,this.float32Array=new Float32Array(n),this.uint16Array=new Uint16Array(n),this.uint32Array=new Uint32Array(n)},this.clearBuffer=()=>{t=null,this.float32Array=null,this.uint16Array=null,this.uint32Array=null,0!==e.length&&this.setBuffer(e.pop())}}}const ro=new _BufferStack;let so,oo;const ao=[],Ao=new PrimitivePool((()=>new p));function shapecast(e,t,n,i,r,s){so=Ao.getPrimitive(),oo=Ao.getPrimitive(),ao.push(so,oo),ro.setBuffer(e._roots[t]);const o=shapecastTraverse(0,e.geometry,n,i,r,s);ro.clearBuffer(),Ao.releasePrimitive(so),Ao.releasePrimitive(oo),ao.pop(),ao.pop();const a=ao.length;return a>0&&(oo=ao[a-1],so=ao[a-2]),o}function shapecastTraverse(e,t,n,i,r=null,s=0,o=0){const{float32Array:a,uint16Array:A,uint32Array:l}=ro;let c=2*e;if(IS_LEAF(c,A)){const p=OFFSET(e,l),h=COUNT(c,A);return arrayToBox(e,a,so),i(p,h,!1,o,s+e/8,so)}{const u=LEFT_NODE(e),d=RIGHT_NODE(e,l);let g,f,m,y,b=u,I=d;if(r&&(m=so,y=oo,arrayToBox(b,a,m),arrayToBox(I,a,y),g=r(m),f=r(y),f<g)){b=d,I=u;const w=g;g=f,f=w,m=y}m||(m=so,arrayToBox(b,a,m));const x=n(m,IS_LEAF(2*b,A),g,o+1,s+b/8);let C;if(2===x){const v=getLeftOffset(b);C=i(v,getRightEndOffset(b)-v,!0,o+1,s+b/8,m)}else C=x&&shapecastTraverse(b,t,n,i,r,s,o+1);if(C)return!0;y=oo,arrayToBox(I,a,y);const B=n(y,IS_LEAF(2*I,A),f,o+1,s+I/8);let E;if(2===B){const P=getLeftOffset(I);E=i(P,getRightEndOffset(I)-P,!0,o+1,s+I/8,y)}else E=B&&shapecastTraverse(I,t,n,i,r,s,o+1);return!!E;function getLeftOffset(e){const{uint16Array:t,uint32Array:n}=ro;let i=2*e;for(;!IS_LEAF(i,t);)i=2*(e=LEFT_NODE(e));return OFFSET(e,n)}function getRightEndOffset(e){const{uint16Array:t,uint32Array:n}=ro;let i=2*e;for(;!IS_LEAF(i,t);)i=2*(e=RIGHT_NODE(e,n));return OFFSET(e,n)+COUNT(i,t)}}}function getVertexCount$1(e){return e.index?e.index.count:e.attributes.position.count}function getTriCount$1(e){return getVertexCount$1(e)/3}function ensureIndex$1(e,t){if(!e.index){const n=e.attributes.position.count,i=function getIndexArray$1(e,t=ArrayBuffer){return e>65535?new Uint32Array(new t(4*e)):new Uint16Array(new t(2*e))}(n,t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer);e.setIndex(new B(i,1));for(let e=0;e<n;e++)i[e]=e}}function getRootPrimitiveRanges(e,t,n){const i=function getFullPrimitiveRange(e,t,n){const i=getVertexCount$1(e)/n,r=t||e.drawRange,s=r.start/n,o=(r.start+r.count)/n,a=Math.max(0,s),A=Math.min(i,o)-a;return{offset:Math.floor(a),count:Math.floor(A)}}(e,t,n),r=function getPrimitiveGroupRanges(e,t){return e.groups.map((e=>({offset:e.start/t,count:e.count/t})))}(e,n);if(!r.length)return[i];const s=[],o=i.offset,a=i.offset+i.count,A=getVertexCount$1(e)/n,l=[];for(const e of r){const{offset:t,count:n}=e,i=t,r=t+(isFinite(n)?n:A-t);i<a&&r>o&&(l.push({pos:Math.max(o,i),isStart:!0}),l.push({pos:Math.min(a,r),isStart:!1}))}l.sort(((e,t)=>e.pos!==t.pos?e.pos-t.pos:"end"===e.type?-1:1));let c=0,p=null;for(const e of l){const t=e.pos;0!==c&&t!==p&&s.push({offset:p,count:t-p}),c+=e.isStart?1:-1,p=t}return s}const lo=new p;class BVH{constructor(){this._roots=null,this.primitiveBuffer=null,this.primitiveBufferStride=null}init(e){buildPackedTree(this,e={...Js,...e})}getRootRanges(e){return getRootPrimitiveRanges(this.geometry,e,this.primitiveStride)}raycastObject3D(){throw new Error("BVH: raycastObject3D() not implemented")}shiftPrimitiveOffsets(e){const t=this._indirectBuffer;if(t)for(let n=0,i=t.length;n<i;n++)t[n]+=e;else{const t=this._roots;for(let n=0;n<t.length;n++){const i=t[n],r=new Uint32Array(i),s=new Uint16Array(i),o=i.byteLength/qs;for(let t=0;t<o;t++){const n=8*t;IS_LEAF(2*n,s)&&(r[n+6]+=e)}}}}traverse(e,t=0){const n=this._roots[t],i=new Uint32Array(n),r=new Uint16Array(n);!function _traverse(t,s=0){const o=2*t,a=IS_LEAF(o,r);if(a){const A=i[t+6],l=r[o+14];e(s,a,new Float32Array(n,4*t,6),A,l)}else{const r=LEFT_NODE(t),o=RIGHT_NODE(t,i),A=SPLIT_AXIS(t,i);e(s,a,new Float32Array(n,4*t,6),A)||(_traverse(r,s+1),_traverse(o,s+1))}}(0)}getBoundingBox(e){e.makeEmpty();return this._roots.forEach((t=>{arrayToBox(0,new Float32Array(t),lo),e.union(lo)})),e}shapecast(e){let{boundsTraverseOrder:t,intersectsBounds:n,intersectsRange:i,intersectsPrimitive:r,scratchPrimitive:s,iterate:o}=e;if(i&&r){const e=i;i=(t,n,i,a,A)=>!!e(t,n,i,a,A)||o(t,n,this,r,i,a,s)}else i||(i=r?(e,t,n,i)=>o(e,t,this,r,n,i,s):(e,t,n)=>n);let a=!1,A=0;const l=this._roots;for(let e=0,r=l.length;e<r;e++){const r=l[e];if(a=shapecast(this,e,n,i,t,A),a)break;A+=r.byteLength/qs}return a}}class SeparatingAxisBounds{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(e,t){let n=1/0,i=-1/0;for(let r=0,s=e.length;r<s;r++){const s=e[r][t];n=s<n?s:n,i=s>i?s:i}this.min=n,this.max=i}setFromPoints(e,t){let n=1/0,i=-1/0;for(let r=0,s=t.length;r<s;r++){const s=t[r],o=e.dot(s);n=o<n?o:n,i=o>i?o:i}this.min=n,this.max=i}isSeparated(e){return this.min>e.max||e.min>this.max}}SeparatingAxisBounds.prototype.setFromBox=function(){const e=new u;return function setFromBox(t,n){const i=n.min,r=n.max;let s=1/0,o=-1/0;for(let n=0;n<=1;n++)for(let a=0;a<=1;a++)for(let A=0;A<=1;A++){e.x=i.x*n+r.x*(1-n),e.y=i.y*a+r.y*(1-a),e.z=i.z*A+r.z*(1-A);const l=t.dot(e);s=Math.min(l,s),o=Math.max(l,o)}this.min=s,this.max=o}}();const co=function(){const e=new u,t=new u,n=new u;return function closestPointLineToLine(i,r,s){const o=i.start,a=e,A=r.start,l=t;n.subVectors(o,A),e.subVectors(i.end,i.start),t.subVectors(r.end,r.start);const c=n.dot(l),p=l.dot(a),h=l.dot(l),u=n.dot(a),d=a.dot(a)*h-p*p;let g,f;g=0!==d?(c*p-u*h)/d:0,f=(c+g*p)/h,s.x=g,s.y=f}}(),po=function(){const e=new r,t=new u,n=new u;return function closestPointsSegmentToSegment(i,r,s,o){co(i,r,e);let a=e.x,A=e.y;if(a>=0&&a<=1&&A>=0&&A<=1)return i.at(a,s),void r.at(A,o);if(a>=0&&a<=1)return A<0?r.at(0,o):r.at(1,o),void i.closestPointToPoint(o,!0,s);if(A>=0&&A<=1)return a<0?i.at(0,s):i.at(1,s),void r.closestPointToPoint(s,!0,o);{let e,l;e=a<0?i.start:i.end,l=A<0?r.start:r.end;const c=t,p=n;return i.closestPointToPoint(l,!0,t),r.closestPointToPoint(e,!0,n),c.distanceToSquared(l)<=p.distanceToSquared(e)?(s.copy(c),void o.copy(l)):(s.copy(e),void o.copy(p))}}}(),ho=function(){const e=new u,t=new u,n=new lt,i=new f;return function sphereIntersectTriangle(r,s){const{radius:o,center:a}=r,{a:A,b:l,c:c}=s;i.start=A,i.end=l;if(i.closestPointToPoint(a,!0,e).distanceTo(a)<=o)return!0;i.start=A,i.end=c;if(i.closestPointToPoint(a,!0,e).distanceTo(a)<=o)return!0;i.start=l,i.end=c;if(i.closestPointToPoint(a,!0,e).distanceTo(a)<=o)return!0;const p=s.getPlane(n);if(Math.abs(p.distanceToPoint(a))<=o){const e=p.projectPoint(a,t);if(s.containsPoint(e))return!0}return!1}}(),uo=["x","y","z"],go=1e-15;function isNearZero(e){return Math.abs(e)<go}class ExtendedTriangle extends ct{constructor(...e){super(...e),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map((()=>new u)),this.satBounds=new Array(4).fill().map((()=>new SeparatingAxisBounds)),this.points=[this.a,this.b,this.c],this.plane=new lt,this.isDegenerateIntoSegment=!1,this.isDegenerateIntoPoint=!1,this.degenerateSegment=new f,this.needsUpdate=!0}intersectsSphere(e){return ho(e,this)}update(){const e=this.a,t=this.b,n=this.c,i=this.points,r=this.satAxes,s=this.satBounds,o=r[0],a=s[0];this.getNormal(o),a.setFromPoints(o,i);const A=r[1],l=s[1];A.subVectors(e,t),l.setFromPoints(A,i);const c=r[2],p=s[2];c.subVectors(t,n),p.setFromPoints(c,i);const h=r[3],u=s[3];h.subVectors(n,e),u.setFromPoints(h,i);const d=A.length(),g=c.length(),f=h.length();this.isDegenerateIntoPoint=!1,this.isDegenerateIntoSegment=!1,d<go?g<go||f<go?this.isDegenerateIntoPoint=!0:(this.isDegenerateIntoSegment=!0,this.degenerateSegment.start.copy(e),this.degenerateSegment.end.copy(n)):g<go?f<go?this.isDegenerateIntoPoint=!0:(this.isDegenerateIntoSegment=!0,this.degenerateSegment.start.copy(t),this.degenerateSegment.end.copy(e)):f<go&&(this.isDegenerateIntoSegment=!0,this.degenerateSegment.start.copy(n),this.degenerateSegment.end.copy(t)),this.plane.setFromNormalAndCoplanarPoint(o,e),this.needsUpdate=!1}}ExtendedTriangle.prototype.closestPointToSegment=function(){const e=new u,t=new u,n=new f;return function distanceToSegment(i,r=null,s=null){const{start:o,end:a}=i,A=this.points;let l,c=1/0;for(let o=0;o<3;o++){const a=(o+1)%3;n.start.copy(A[o]),n.end.copy(A[a]),po(n,i,e,t),l=e.distanceToSquared(t),l<c&&(c=l,r&&r.copy(e),s&&s.copy(t))}return this.closestPointToPoint(o,e),l=o.distanceToSquared(e),l<c&&(c=l,r&&r.copy(e),s&&s.copy(o)),this.closestPointToPoint(a,e),l=a.distanceToSquared(e),l<c&&(c=l,r&&r.copy(e),s&&s.copy(a)),Math.sqrt(c)}}(),ExtendedTriangle.prototype.intersectsTriangle=function(){const e=new ExtendedTriangle,t=new SeparatingAxisBounds,n=new SeparatingAxisBounds,i=new u,s=new u,o=new u,a=new u,A=new f,l=new f,c=new u,p=new r,h=new r;function coplanarIntersectsTriangle(e,r,s,o){const A=i;e.isDegenerateIntoPoint||e.isDegenerateIntoSegment?A.copy(r.plane.normal):A.copy(e.plane.normal);const l=e.satBounds,c=e.satAxes;for(let i=1;i<4;i++){const s=l[i],o=c[i];if(t.setFromPoints(o,r.points),s.isSeparated(t))return!1;if(a.copy(A).cross(o),t.setFromPoints(a,e.points),n.setFromPoints(a,r.points),t.isSeparated(n))return!1}const p=r.satBounds,h=r.satAxes;for(let i=1;i<4;i++){const s=p[i],o=h[i];if(t.setFromPoints(o,e.points),s.isSeparated(t))return!1;if(a.crossVectors(A,o),t.setFromPoints(a,e.points),n.setFromPoints(a,r.points),t.isSeparated(n))return!1}return s&&(o||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),s.start.set(0,0,0),s.end.set(0,0,0)),!0}function findSingleBounds(e,t,n,i,r,s,o,a,A,l,c){let p=o/(o-a);l.x=i+(r-i)*p,c.start.subVectors(t,e).multiplyScalar(p).add(e),p=o/(o-A),l.y=i+(s-i)*p,c.end.subVectors(n,e).multiplyScalar(p).add(e)}function findIntersectionLineBounds(e,t,n,i,r,s,o,a,A,l,c){if(r>0)findSingleBounds(e.c,e.a,e.b,i,t,n,A,o,a,l,c);else if(s>0)findSingleBounds(e.b,e.a,e.c,n,t,i,a,o,A,l,c);else if(a*A>0||0!=o)findSingleBounds(e.a,e.b,e.c,t,n,i,o,a,A,l,c);else if(0!=a)findSingleBounds(e.b,e.a,e.c,n,t,i,a,o,A,l,c);else{if(0==A)return!0;findSingleBounds(e.c,e.a,e.b,i,t,n,A,o,a,l,c)}return!1}function intersectTriangleSegment(e,t,n,r){const s=t.degenerateSegment,o=e.plane.distanceToPoint(s.start),a=e.plane.distanceToPoint(s.end);return isNearZero(o)?isNearZero(a)?coplanarIntersectsTriangle(e,t,n,r):(n&&(n.start.copy(s.start),n.end.copy(s.start)),e.containsPoint(s.start)):isNearZero(a)?(n&&(n.start.copy(s.end),n.end.copy(s.end)),e.containsPoint(s.end)):null!=e.plane.intersectLine(s,i)&&(n&&(n.start.copy(i),n.end.copy(i)),e.containsPoint(i))}function intersectTrianglePoint(e,t,n){const i=t.a;return!(!isNearZero(e.plane.distanceToPoint(i))||!e.containsPoint(i))&&(n&&(n.start.copy(i),n.end.copy(i)),!0)}function intersectSegmentPoint(e,t,n){const r=e.degenerateSegment,s=t.a;return r.closestPointToPoint(s,!0,i),s.distanceToSquared(i)<1e-30&&(n&&(n.start.copy(s),n.end.copy(s)),!0)}return function intersectsTriangle(t,n=null,r=!1){this.needsUpdate&&this.update(),t.isExtendedTriangle?t.needsUpdate&&t.update():(e.copy(t),e.update(),t=e);const a=function handleDegenerateCases(e,t,n,r){if(e.isDegenerateIntoSegment){if(t.isDegenerateIntoSegment){const r=e.degenerateSegment,a=t.degenerateSegment,A=s,l=o;r.delta(A),a.delta(l);const c=i.subVectors(a.start,r.start),p=A.x*l.y-A.y*l.x;if(isNearZero(p))return!1;const h=(c.x*l.y-c.y*l.x)/p,u=-(A.x*c.y-A.y*c.x)/p;return!(h<0||h>1||u<0||u>1)&&(!!isNearZero(r.start.z+A.z*h-(a.start.z+l.z*u))&&(n&&(n.start.copy(r.start).addScaledVector(A,h),n.end.copy(r.start).addScaledVector(A,h)),!0))}return t.isDegenerateIntoPoint?intersectSegmentPoint(e,t,n):intersectTriangleSegment(t,e,n,r)}return e.isDegenerateIntoPoint?t.isDegenerateIntoPoint?t.a.distanceToSquared(e.a)<1e-30&&(n&&(n.start.copy(e.a),n.end.copy(e.a)),!0):t.isDegenerateIntoSegment?intersectSegmentPoint(t,e,n):intersectTrianglePoint(t,e,n):t.isDegenerateIntoPoint?intersectTrianglePoint(e,t,n):t.isDegenerateIntoSegment?intersectTriangleSegment(e,t,n,r):void 0}(this,t,n,r);if(void 0!==a)return a;const u=this.plane,d=t.plane;let g=d.distanceToPoint(this.a),f=d.distanceToPoint(this.b),m=d.distanceToPoint(this.c);isNearZero(g)&&(g=0),isNearZero(f)&&(f=0),isNearZero(m)&&(m=0);const y=g*f,b=g*m;if(y>0&&b>0)return!1;let I=u.distanceToPoint(t.a),x=u.distanceToPoint(t.b),C=u.distanceToPoint(t.c);isNearZero(I)&&(I=0),isNearZero(x)&&(x=0),isNearZero(C)&&(C=0);const B=I*x,E=I*C;if(B>0&&E>0)return!1;s.copy(u.normal),o.copy(d.normal);const w=s.cross(o);let v=0,P=Math.abs(w.x);const T=Math.abs(w.y);T>P&&(P=T,v=1);Math.abs(w.z)>P&&(v=2);const S=uo[v],M=this.a[S],D=this.b[S],L=this.c[S],_=t.a[S],F=t.b[S],k=t.c[S];if(findIntersectionLineBounds(this,M,D,L,y,b,g,f,m,p,A))return coplanarIntersectsTriangle(this,t,n,r);if(findIntersectionLineBounds(t,_,F,k,B,E,I,x,C,h,l))return coplanarIntersectsTriangle(this,t,n,r);if(p.y<p.x){const e=p.y;p.y=p.x,p.x=e,c.copy(A.start),A.start.copy(A.end),A.end.copy(c)}if(h.y<h.x){const e=h.y;h.y=h.x,h.x=e,c.copy(l.start),l.start.copy(l.end),l.end.copy(c)}return!(p.y<h.x||h.y<p.x)&&(n&&(h.x>p.x?n.start.copy(l.start):n.start.copy(A.start),h.y<p.y?n.end.copy(l.end):n.end.copy(A.end)),!0)}}(),ExtendedTriangle.prototype.distanceToPoint=function(){const e=new u;return function distanceToPoint(t){return this.closestPointToPoint(t,e),t.distanceTo(e)}}(),ExtendedTriangle.prototype.distanceToTriangle=function(){const e=new u,t=new u,n=["a","b","c"],i=new f,r=new f;return function distanceToTriangle(s,o=null,a=null){const A=o||a?i:null;if(this.intersectsTriangle(s,A))return(o||a)&&(o&&A.getCenter(o),a&&A.getCenter(a)),0;let l=1/0;for(let t=0;t<3;t++){let i;const r=n[t],A=s[r];this.closestPointToPoint(A,e),i=A.distanceToSquared(e),i<l&&(l=i,o&&o.copy(e),a&&a.copy(A));const c=this[r];s.closestPointToPoint(c,e),i=c.distanceToSquared(e),i<l&&(l=i,o&&o.copy(c),a&&a.copy(e))}for(let A=0;A<3;A++){const c=n[A],p=n[(A+1)%3];i.set(this[c],this[p]);for(let A=0;A<3;A++){const c=n[A],p=n[(A+1)%3];r.set(s[c],s[p]),po(i,r,e,t);const h=e.distanceToSquared(t);h<l&&(l=h,o&&o.copy(e),a&&a.copy(t))}}return Math.sqrt(l)}}();class OrientedBox{constructor(e,t,n){this.isOrientedBox=!0,this.min=new u,this.max=new u,this.matrix=new m,this.invMatrix=new m,this.points=new Array(8).fill().map((()=>new u)),this.satAxes=new Array(3).fill().map((()=>new u)),this.satBounds=new Array(3).fill().map((()=>new SeparatingAxisBounds)),this.alignedSatBounds=new Array(3).fill().map((()=>new SeparatingAxisBounds)),this.needsUpdate=!1,e&&this.min.copy(e),t&&this.max.copy(t),n&&this.matrix.copy(n)}set(e,t,n){this.min.copy(e),this.max.copy(t),this.matrix.copy(n),this.needsUpdate=!0}copy(e){this.min.copy(e.min),this.max.copy(e.max),this.matrix.copy(e.matrix),this.needsUpdate=!0}}OrientedBox.prototype.update=function update(){const e=this.matrix,t=this.min,n=this.max,i=this.points;for(let r=0;r<=1;r++)for(let s=0;s<=1;s++)for(let o=0;o<=1;o++){const a=i[1*r|2*s|4*o];a.x=r?n.x:t.x,a.y=s?n.y:t.y,a.z=o?n.z:t.z,a.applyMatrix4(e)}const r=this.satBounds,s=this.satAxes,o=i[0];for(let e=0;e<3;e++){const t=s[e],n=r[e],a=i[1<<e];t.subVectors(o,a),n.setFromPoints(t,i)}const a=this.alignedSatBounds;a[0].setFromPointsField(i,"x"),a[1].setFromPointsField(i,"y"),a[2].setFromPointsField(i,"z"),this.invMatrix.copy(this.matrix).invert(),this.needsUpdate=!1},OrientedBox.prototype.intersectsBox=function(){const e=new SeparatingAxisBounds;return function intersectsBox(t){this.needsUpdate&&this.update();const n=t.min,i=t.max,r=this.satBounds,s=this.satAxes,o=this.alignedSatBounds;if(e.min=n.x,e.max=i.x,o[0].isSeparated(e))return!1;if(e.min=n.y,e.max=i.y,o[1].isSeparated(e))return!1;if(e.min=n.z,e.max=i.z,o[2].isSeparated(e))return!1;for(let n=0;n<3;n++){const i=s[n],o=r[n];if(e.setFromBox(i,t),o.isSeparated(e))return!1}return!0}}(),OrientedBox.prototype.intersectsTriangle=function(){const e=new ExtendedTriangle,t=new Array(3),n=new SeparatingAxisBounds,i=new SeparatingAxisBounds,r=new u;return function intersectsTriangle(s){this.needsUpdate&&this.update(),s.isExtendedTriangle?s.needsUpdate&&s.update():(e.copy(s),e.update(),s=e);const o=this.satBounds,a=this.satAxes;t[0]=s.a,t[1]=s.b,t[2]=s.c;for(let e=0;e<3;e++){const i=o[e],r=a[e];if(n.setFromPoints(r,t),i.isSeparated(n))return!1}const A=s.satBounds,l=s.satAxes,c=this.points;for(let e=0;e<3;e++){const t=A[e],i=l[e];if(n.setFromPoints(i,c),t.isSeparated(n))return!1}for(let e=0;e<3;e++){const s=a[e];for(let e=0;e<4;e++){const o=l[e];if(r.crossVectors(s,o),n.setFromPoints(r,t),i.setFromPoints(r,c),n.isSeparated(i))return!1}}return!0}}(),OrientedBox.prototype.closestPointToPoint=function closestPointToPoint(e,t){return this.needsUpdate&&this.update(),t.copy(e).applyMatrix4(this.invMatrix).clamp(this.min,this.max).applyMatrix4(this.matrix),t},OrientedBox.prototype.distanceToPoint=function(){const e=new u;return function distanceToPoint(t){return this.closestPointToPoint(t,e),t.distanceTo(e)}}(),OrientedBox.prototype.distanceToBox=function(){const e=["x","y","z"],t=new Array(12).fill().map((()=>new f)),n=new Array(12).fill().map((()=>new f)),i=new u,r=new u;return function distanceToBox(s,o=0,a=null,A=null){if(this.needsUpdate&&this.update(),this.intersectsBox(s))return(a||A)&&(s.getCenter(r),this.closestPointToPoint(r,i),s.closestPointToPoint(i,r),a&&a.copy(i),A&&A.copy(r)),0;const l=o*o,c=s.min,p=s.max,h=this.points;let u=1/0;for(let e=0;e<8;e++){const t=h[e];r.copy(t).clamp(c,p);const n=t.distanceToSquared(r);if(n<u&&(u=n,a&&a.copy(t),A&&A.copy(r),n<l))return Math.sqrt(n)}let d=0;for(let i=0;i<3;i++)for(let r=0;r<=1;r++)for(let s=0;s<=1;s++){const o=(i+1)%3,a=(i+2)%3,A=1<<i|r<<o|s<<a,l=h[r<<o|s<<a],u=h[A];t[d].set(l,u);const g=e[i],f=e[o],m=e[a],y=n[d],b=y.start,I=y.end;b[g]=c[g],b[f]=r?c[f]:p[f],b[m]=s?c[m]:p[f],I[g]=p[g],I[f]=r?c[f]:p[f],I[m]=s?c[m]:p[f],d++}for(let e=0;e<=1;e++)for(let t=0;t<=1;t++)for(let n=0;n<=1;n++){r.x=e?p.x:c.x,r.y=t?p.y:c.y,r.z=n?p.z:c.z,this.closestPointToPoint(r,i);const s=r.distanceToSquared(i);if(s<u&&(u=s,a&&a.copy(i),A&&A.copy(r),s<l))return Math.sqrt(s)}for(let e=0;e<12;e++){const s=t[e];for(let e=0;e<12;e++){const t=n[e];po(s,t,i,r);const o=i.distanceToSquared(r);if(o<u&&(u=o,a&&a.copy(i),A&&A.copy(r),o<l))return Math.sqrt(o)}}return Math.sqrt(u)}}();class ExtendedTrianglePoolBase extends PrimitivePool{constructor(){super((()=>new ExtendedTriangle))}}const fo=new ExtendedTrianglePoolBase,mo=new u,yo=new u;const bo=parseInt(ht)>=169,Io=parseInt(ht)<=161,xo=new u,Co=new u,Bo=new u,Eo=new r,wo=new r,vo=new r,Qo=new u,Po=new u,To=new u,So=new u;function checkBufferGeometryIntersection(e,t,n,i,s,o,a,A,l,c,p){xo.fromBufferAttribute(t,o),Co.fromBufferAttribute(t,a),Bo.fromBufferAttribute(t,A);const h=function checkIntersection(e,t,n,i,r,s,o,a){let A;if(A=s===pt?e.intersectTriangle(i,n,t,!0,r):e.intersectTriangle(t,n,i,s!==te,r),null===A)return null;const l=e.origin.distanceTo(r);return l<o||l>a?null:{distance:l,point:r.clone()}}(e,xo,Co,Bo,So,l,c,p);if(h){if(i){Eo.fromBufferAttribute(i,o),wo.fromBufferAttribute(i,a),vo.fromBufferAttribute(i,A),h.uv=new r;const e=ct.getInterpolation(So,xo,Co,Bo,Eo,wo,vo,h.uv);bo||(h.uv=e)}if(s){Eo.fromBufferAttribute(s,o),wo.fromBufferAttribute(s,a),vo.fromBufferAttribute(s,A),h.uv1=new r;const e=ct.getInterpolation(So,xo,Co,Bo,Eo,wo,vo,h.uv1);bo||(h.uv1=e),Io&&(h.uv2=h.uv1)}if(n){Qo.fromBufferAttribute(n,o),Po.fromBufferAttribute(n,a),To.fromBufferAttribute(n,A),h.normal=new u;const t=ct.getInterpolation(So,xo,Co,Bo,Qo,Po,To,h.normal);h.normal.dot(e.direction)>0&&h.normal.multiplyScalar(-1),bo||(h.normal=t)}const t={a:o,b:a,c:A,normal:new u,materialIndex:0};if(ct.getNormal(xo,Co,Bo,t.normal),h.face=t,h.faceIndex=o,bo){const e=new u;ct.getBarycoord(So,xo,Co,Bo,e),h.barycoord=e}}return h}function getSide(e){return e&&e.isMaterial?e.side:e}function intersectTri(e,t,n,i,r,s,o){const a=3*i;let A=a+0,l=a+1,c=a+2;const{index:p,groups:h}=e;e.index&&(A=p.getX(A),l=p.getX(l),c=p.getX(c));const{position:u,normal:d,uv:g,uv1:f}=e.attributes;if(Array.isArray(t)){const e=3*i;for(let a=0,p=h.length;a<p;a++){const{start:p,count:m,materialIndex:y}=h[a];if(e>=p&&e<p+m){const e=checkBufferGeometryIntersection(n,u,d,g,f,A,l,c,getSide(t[y]),s,o);if(e){if(e.faceIndex=i,e.face.materialIndex=y,!r)return e;r.push(e)}}}}else{const e=checkBufferGeometryIntersection(n,u,d,g,f,A,l,c,getSide(t),s,o);if(e){if(e.faceIndex=i,e.face.materialIndex=0,!r)return e;r.push(e)}}return null}function setTriangle(e,t,n,i){const r=e.a,s=e.b,o=e.c;let a=t,A=t+1,l=t+2;n&&(a=n.getX(a),A=n.getX(A),l=n.getX(l)),r.x=i.getX(a),r.y=i.getY(a),r.z=i.getZ(a),s.x=i.getX(A),s.y=i.getY(A),s.z=i.getZ(A),o.x=i.getX(l),o.y=i.getY(l),o.z=i.getZ(l)}function iterateOverTriangles(e,t,n,i,r,s,o){const{geometry:a}=n,{index:A}=a,l=a.attributes.position;for(let n=e,a=t+e;n<a;n++){let e;if(e=n,setTriangle(o,3*e,A,l),o.needsUpdate=!0,i(o,e,r,s))return!0}return!1}function refit(e,t=null){t&&Array.isArray(t)&&(t=new Set(t));const n=e.geometry,i=n.index?n.index.array:null,r=n.attributes.position;let s,o,a,A,l=0;const c=e._roots;for(let e=0,t=c.length;e<t;e++)s=c[e],o=new Uint32Array(s),a=new Uint16Array(s),A=new Float32Array(s),_traverse(0,l),l+=s.byteLength;function _traverse(e,n,s=!1){const l=2*e;if(IS_LEAF(l,a)){const t=o[e+6];let n=1/0,s=1/0,c=1/0,p=-1/0,h=-1/0,u=-1/0;for(let e=3*t,o=3*(t+a[l+14]);e<o;e++){let t=i[e];const o=r.getX(t),a=r.getY(t),A=r.getZ(t);o<n&&(n=o),o>p&&(p=o),a<s&&(s=a),a>h&&(h=a),A<c&&(c=A),A>u&&(u=A)}return(A[e+0]!==n||A[e+1]!==s||A[e+2]!==c||A[e+3]!==p||A[e+4]!==h||A[e+5]!==u)&&(A[e+0]=n,A[e+1]=s,A[e+2]=c,A[e+3]=p,A[e+4]=h,A[e+5]=u,!0)}{const i=LEFT_NODE(e),r=RIGHT_NODE(e,o);let a=s,l=!1,c=!1;if(t){if(!a){const e=i/8+n/qs,s=r/8+n/qs;l=t.has(e),c=t.has(s),a=!l&&!c}}else l=!0,c=!0;const p=a||c;let h=!1;(a||l)&&(h=_traverse(i,n,a));let u=!1;p&&(u=_traverse(r,n,a));const d=h||u;if(d)for(let t=0;t<3;t++){const n=i+t,s=r+t,o=A[n],a=A[n+3],l=A[s],c=A[s+3];A[e+t]=o<l?o:l,A[e+t+3]=a>c?a:c}return d}}}function intersectRay(e,t,n,i,r){let s,o,a,A,l,c;const p=1/n.direction.x,h=1/n.direction.y,u=1/n.direction.z,d=n.origin.x,g=n.origin.y,f=n.origin.z;let m=t[e],y=t[e+3],b=t[e+1],I=t[e+3+1],x=t[e+2],C=t[e+3+2];return p>=0?(s=(m-d)*p,o=(y-d)*p):(s=(y-d)*p,o=(m-d)*p),h>=0?(a=(b-g)*h,A=(I-g)*h):(a=(I-g)*h,A=(b-g)*h),!(s>A||a>o)&&((a>s||isNaN(s))&&(s=a),(A<o||isNaN(o))&&(o=A),u>=0?(l=(x-f)*u,c=(C-f)*u):(l=(C-f)*u,c=(x-f)*u),!(s>c||l>o)&&((l>s||s!=s)&&(s=l),(c<o||o!=o)&&(o=c),s<=r&&o>=i))}function iterateOverTriangles_indirect(e,t,n,i,r,s,o){const{geometry:a}=n,{index:A}=a,l=a.attributes.position;for(let a=e,c=t+e;a<c;a++){let e;if(e=n.resolveTriangleIndex(a),setTriangle(o,3*e,A,l),o.needsUpdate=!0,i(o,e,r,s))return!0}return!1}function raycast(e,t,n,i,r,s,o){ro.setBuffer(e._roots[t]),_raycast$1(0,e,n,i,r,s,o),ro.clearBuffer()}function _raycast$1(e,t,n,i,r,s,o){const{float32Array:a,uint16Array:A,uint32Array:l}=ro,c=2*e;if(IS_LEAF(c,A)){!function intersectTris(e,t,n,i,r,s,o,a){const{geometry:A,_indirectBuffer:l}=e;for(let e=i,l=i+r;e<l;e++)intersectTri(A,t,n,e,s,o,a)}(t,n,i,OFFSET(e,l),COUNT(c,A),r,s,o)}else{const A=LEFT_NODE(e);intersectRay(A,a,i,s,o)&&_raycast$1(A,t,n,i,r,s,o);const c=RIGHT_NODE(e,l);intersectRay(c,a,i,s,o)&&_raycast$1(c,t,n,i,r,s,o)}}const Mo=["x","y","z"];function raycastFirst(e,t,n,i,r,s){ro.setBuffer(e._roots[t]);const o=_raycastFirst$1(0,e,n,i,r,s);return ro.clearBuffer(),o}function _raycastFirst$1(e,t,n,i,r,s){const{float32Array:o,uint16Array:a,uint32Array:A}=ro;let l=2*e;if(IS_LEAF(l,a)){return function intersectClosestTri(e,t,n,i,r,s,o){const{geometry:a,_indirectBuffer:A}=e;let l=1/0,c=null;for(let e=i,A=i+r;e<A;e++){let i;i=intersectTri(a,t,n,e,null,s,o),i&&i.distance<l&&(c=i,l=i.distance)}return c}(t,n,i,OFFSET(e,A),COUNT(l,a),r,s)}{const a=SPLIT_AXIS(e,A),l=Mo[a],c=i.direction[l]>=0;let p,h;c?(p=LEFT_NODE(e),h=RIGHT_NODE(e,A)):(p=RIGHT_NODE(e,A),h=LEFT_NODE(e));const u=intersectRay(p,o,i,r,s)?_raycastFirst$1(p,t,n,i,r,s):null;if(u){const e=u.point[l];if(c?e<=o[h+a]:e>=o[h+a+3])return u}const d=intersectRay(h,o,i,r,s)?_raycastFirst$1(h,t,n,i,r,s):null;return u&&d?u.distance<=d.distance?u:d:u||d||null}}const Do=new p,Lo=new ExtendedTriangle,_o=new ExtendedTriangle,Fo=new m,ko=new OrientedBox,Ro=new OrientedBox;function intersectsGeometry(e,t,n,i){ro.setBuffer(e._roots[t]);const r=_intersectsGeometry$1(0,e,n,i);return ro.clearBuffer(),r}function _intersectsGeometry$1(e,t,n,i,r=null){const{float32Array:s,uint16Array:o,uint32Array:a}=ro;let A=2*e;null===r&&(n.boundingBox||n.computeBoundingBox(),ko.set(n.boundingBox.min,n.boundingBox.max,i),r=ko);if(!IS_LEAF(A,o)){const o=LEFT_NODE(e),A=RIGHT_NODE(e,a);arrayToBox(o,s,Do);if(r.intersectsBox(Do)&&_intersectsGeometry$1(o,t,n,i,r))return!0;arrayToBox(A,s,Do);return!!(r.intersectsBox(Do)&&_intersectsGeometry$1(A,t,n,i,r))}{const r=t.geometry,l=r.index,c=r.attributes.position,p=n.index,h=n.attributes.position,u=OFFSET(e,a),d=COUNT(A,o);if(Fo.copy(i).invert(),n.boundsTree){arrayToBox(e,s,Ro),Ro.matrix.copy(Fo),Ro.needsUpdate=!0;return n.boundsTree.shapecast({intersectsBounds:e=>Ro.intersectsBox(e),intersectsTriangle:e=>{e.a.applyMatrix4(i),e.b.applyMatrix4(i),e.c.applyMatrix4(i),e.needsUpdate=!0;for(let t=3*u,n=3*(d+u);t<n;t+=3)if(setTriangle(_o,t,l,c),_o.needsUpdate=!0,e.intersectsTriangle(_o))return!0;return!1}})}{const e=getTriCount$1(n);for(let t=3*u,n=3*(d+u);t<n;t+=3){setTriangle(Lo,t,l,c),Lo.a.applyMatrix4(Fo),Lo.b.applyMatrix4(Fo),Lo.c.applyMatrix4(Fo),Lo.needsUpdate=!0;for(let t=0,n=3*e;t<n;t+=3)if(setTriangle(_o,t,p,h),_o.needsUpdate=!0,Lo.intersectsTriangle(_o))return!0}}}}const No=new m,Oo=new OrientedBox,Go=new OrientedBox,Uo=new u,Yo=new u,zo=new u,Ho=new u;function closestPointToGeometry(e,t,n,i={},r={},s=0,o=1/0){t.boundingBox||t.computeBoundingBox(),Oo.set(t.boundingBox.min,t.boundingBox.max,n),Oo.needsUpdate=!0;const a=e.geometry,A=a.attributes.position,l=a.index,c=t.attributes.position,p=t.index,h=fo.getPrimitive(),u=fo.getPrimitive();let d=Uo,g=Yo,f=null,m=null;r&&(f=zo,m=Ho);let y=1/0,b=null,I=null;return No.copy(n).invert(),Go.matrix.copy(No),e.shapecast({boundsTraverseOrder:e=>Oo.distanceToBox(e),intersectsBounds:(e,t,n)=>n<y&&n<o&&(t&&(Go.min.copy(e.min),Go.max.copy(e.max),Go.needsUpdate=!0),!0),intersectsRange:(e,i)=>{if(t.boundsTree){return t.boundsTree.shapecast({boundsTraverseOrder:e=>Go.distanceToBox(e),intersectsBounds:(e,t,n)=>n<y&&n<o,intersectsRange:(t,r)=>{for(let o=t,a=t+r;o<a;o++){setTriangle(u,3*o,p,c),u.a.applyMatrix4(n),u.b.applyMatrix4(n),u.c.applyMatrix4(n),u.needsUpdate=!0;for(let t=e,n=e+i;t<n;t++){setTriangle(h,3*t,l,A),h.needsUpdate=!0;const e=h.distanceToTriangle(u,d,f);if(e<y&&(g.copy(d),m&&m.copy(f),y=e,b=t,I=o),e<s)return!0}}}})}for(let r=0,o=getTriCount$1(t);r<o;r++){setTriangle(u,3*r,p,c),u.a.applyMatrix4(n),u.b.applyMatrix4(n),u.c.applyMatrix4(n),u.needsUpdate=!0;for(let t=e,n=e+i;t<n;t++){setTriangle(h,3*t,l,A),h.needsUpdate=!0;const e=h.distanceToTriangle(u,d,f);if(e<y&&(g.copy(d),m&&m.copy(f),y=e,b=t,I=r),e<s)return!0}}}}),fo.releasePrimitive(h),fo.releasePrimitive(u),y===1/0?null:(i.point?i.point.copy(g):i.point=g.clone(),i.distance=y,i.faceIndex=b,r&&(r.point?r.point.copy(m):r.point=m.clone(),r.point.applyMatrix4(No),g.applyMatrix4(No),r.distance=g.sub(r.point).length(),r.faceIndex=I),i)}function refit_indirect(e,t=null){t&&Array.isArray(t)&&(t=new Set(t));const n=e.geometry,i=n.index?n.index.array:null,r=n.attributes.position;let s,o,a,A,l=0;const c=e._roots;for(let e=0,t=c.length;e<t;e++)s=c[e],o=new Uint32Array(s),a=new Uint16Array(s),A=new Float32Array(s),_traverse(0,l),l+=s.byteLength;function _traverse(n,s,l=!1){const c=2*n;if(IS_LEAF(c,a)){const t=o[n+6];let s=1/0,l=1/0,p=1/0,h=-1/0,u=-1/0,d=-1/0;for(let n=t,o=t+a[c+14];n<o;n++){const t=3*e.resolveTriangleIndex(n);for(let e=0;e<3;e++){let n=t+e;n=i?i[n]:n;const o=r.getX(n),a=r.getY(n),A=r.getZ(n);o<s&&(s=o),o>h&&(h=o),a<l&&(l=a),a>u&&(u=a),A<p&&(p=A),A>d&&(d=A)}}return(A[n+0]!==s||A[n+1]!==l||A[n+2]!==p||A[n+3]!==h||A[n+4]!==u||A[n+5]!==d)&&(A[n+0]=s,A[n+1]=l,A[n+2]=p,A[n+3]=h,A[n+4]=u,A[n+5]=d,!0)}{const e=LEFT_NODE(n),i=RIGHT_NODE(n,o);let r=l,a=!1,c=!1;if(t){if(!r){const n=e/8+s/qs,o=i/8+s/qs;a=t.has(n),c=t.has(o),r=!a&&!c}}else a=!0,c=!0;const p=r||c;let h=!1;(r||a)&&(h=_traverse(e,s,r));let u=!1;p&&(u=_traverse(i,s,r));const d=h||u;if(d)for(let t=0;t<3;t++){const r=e+t,s=i+t,o=A[r],a=A[r+3],l=A[s],c=A[s+3];A[n+t]=o<l?o:l,A[n+t+3]=a>c?a:c}return d}}}function raycast_indirect(e,t,n,i,r,s,o){ro.setBuffer(e._roots[t]),_raycast(0,e,n,i,r,s,o),ro.clearBuffer()}function _raycast(e,t,n,i,r,s,o){const{float32Array:a,uint16Array:A,uint32Array:l}=ro,c=2*e;if(IS_LEAF(c,A)){!function intersectTris_indirect(e,t,n,i,r,s,o,a){const{geometry:A,_indirectBuffer:l}=e;for(let e=i,c=i+r;e<c;e++)intersectTri(A,t,n,l?l[e]:e,s,o,a)}(t,n,i,OFFSET(e,l),COUNT(c,A),r,s,o)}else{const A=LEFT_NODE(e);intersectRay(A,a,i,s,o)&&_raycast(A,t,n,i,r,s,o);const c=RIGHT_NODE(e,l);intersectRay(c,a,i,s,o)&&_raycast(c,t,n,i,r,s,o)}}const Xo=["x","y","z"];function raycastFirst_indirect(e,t,n,i,r,s){ro.setBuffer(e._roots[t]);const o=_raycastFirst(0,e,n,i,r,s);return ro.clearBuffer(),o}function _raycastFirst(e,t,n,i,r,s){const{float32Array:o,uint16Array:a,uint32Array:A}=ro;let l=2*e;if(IS_LEAF(l,a)){return function intersectClosestTri_indirect(e,t,n,i,r,s,o){const{geometry:a,_indirectBuffer:A}=e;let l=1/0,c=null;for(let e=i,p=i+r;e<p;e++){let i;i=intersectTri(a,t,n,A?A[e]:e,null,s,o),i&&i.distance<l&&(c=i,l=i.distance)}return c}(t,n,i,OFFSET(e,A),COUNT(l,a),r,s)}{const a=SPLIT_AXIS(e,A),l=Xo[a],c=i.direction[l]>=0;let p,h;c?(p=LEFT_NODE(e),h=RIGHT_NODE(e,A)):(p=RIGHT_NODE(e,A),h=LEFT_NODE(e));const u=intersectRay(p,o,i,r,s)?_raycastFirst(p,t,n,i,r,s):null;if(u){const e=u.point[l];if(c?e<=o[h+a]:e>=o[h+a+3])return u}const d=intersectRay(h,o,i,r,s)?_raycastFirst(h,t,n,i,r,s):null;return u&&d?u.distance<=d.distance?u:d:u||d||null}}const qo=new p,jo=new ExtendedTriangle,Wo=new ExtendedTriangle,Jo=new m,Vo=new OrientedBox,Ko=new OrientedBox;function intersectsGeometry_indirect(e,t,n,i){ro.setBuffer(e._roots[t]);const r=_intersectsGeometry(0,e,n,i);return ro.clearBuffer(),r}function _intersectsGeometry(e,t,n,i,r=null){const{float32Array:s,uint16Array:o,uint32Array:a}=ro;let A=2*e;null===r&&(n.boundingBox||n.computeBoundingBox(),Vo.set(n.boundingBox.min,n.boundingBox.max,i),r=Vo);if(!IS_LEAF(A,o)){const o=LEFT_NODE(e),A=RIGHT_NODE(e,a);arrayToBox(o,s,qo);if(r.intersectsBox(qo)&&_intersectsGeometry(o,t,n,i,r))return!0;arrayToBox(A,s,qo);return!!(r.intersectsBox(qo)&&_intersectsGeometry(A,t,n,i,r))}{const r=t.geometry,l=r.index,c=r.attributes.position,p=n.index,h=n.attributes.position,u=OFFSET(e,a),d=COUNT(A,o);if(Jo.copy(i).invert(),n.boundsTree){arrayToBox(e,s,Ko),Ko.matrix.copy(Jo),Ko.needsUpdate=!0;return n.boundsTree.shapecast({intersectsBounds:e=>Ko.intersectsBox(e),intersectsTriangle:e=>{e.a.applyMatrix4(i),e.b.applyMatrix4(i),e.c.applyMatrix4(i),e.needsUpdate=!0;for(let n=u,i=d+u;n<i;n++)if(setTriangle(Wo,3*t.resolveTriangleIndex(n),l,c),Wo.needsUpdate=!0,e.intersectsTriangle(Wo))return!0;return!1}})}{const e=getTriCount$1(n);for(let n=u,i=d+u;n<i;n++){const i=t.resolveTriangleIndex(n);setTriangle(jo,3*i,l,c),jo.a.applyMatrix4(Jo),jo.b.applyMatrix4(Jo),jo.c.applyMatrix4(Jo),jo.needsUpdate=!0;for(let t=0,n=3*e;t<n;t+=3)if(setTriangle(Wo,t,p,h),Wo.needsUpdate=!0,jo.intersectsTriangle(Wo))return!0}}}}const Zo=new m,$o=new OrientedBox,ea=new OrientedBox,ta=new u,na=new u,ia=new u,ra=new u;function closestPointToGeometry_indirect(e,t,n,i={},r={},s=0,o=1/0){t.boundingBox||t.computeBoundingBox(),$o.set(t.boundingBox.min,t.boundingBox.max,n),$o.needsUpdate=!0;const a=e.geometry,A=a.attributes.position,l=a.index,c=t.attributes.position,p=t.index,h=fo.getPrimitive(),u=fo.getPrimitive();let d=ta,g=na,f=null,m=null;r&&(f=ia,m=ra);let y=1/0,b=null,I=null;return Zo.copy(n).invert(),ea.matrix.copy(Zo),e.shapecast({boundsTraverseOrder:e=>$o.distanceToBox(e),intersectsBounds:(e,t,n)=>n<y&&n<o&&(t&&(ea.min.copy(e.min),ea.max.copy(e.max),ea.needsUpdate=!0),!0),intersectsRange:(i,r)=>{if(t.boundsTree){const a=t.boundsTree;return a.shapecast({boundsTraverseOrder:e=>ea.distanceToBox(e),intersectsBounds:(e,t,n)=>n<y&&n<o,intersectsRange:(t,o)=>{for(let x=t,C=t+o;x<C;x++){const t=a.resolveTriangleIndex(x);setTriangle(u,3*t,p,c),u.a.applyMatrix4(n),u.b.applyMatrix4(n),u.c.applyMatrix4(n),u.needsUpdate=!0;for(let t=i,n=i+r;t<n;t++){const n=e.resolveTriangleIndex(t);setTriangle(h,3*n,l,A),h.needsUpdate=!0;const i=h.distanceToTriangle(u,d,f);if(i<y&&(g.copy(d),m&&m.copy(f),y=i,b=t,I=x),i<s)return!0}}}})}for(let o=0,a=getTriCount$1(t);o<a;o++){setTriangle(u,3*o,p,c),u.a.applyMatrix4(n),u.b.applyMatrix4(n),u.c.applyMatrix4(n),u.needsUpdate=!0;for(let t=i,n=i+r;t<n;t++){const n=e.resolveTriangleIndex(t);setTriangle(h,3*n,l,A),h.needsUpdate=!0;const i=h.distanceToTriangle(u,d,f);if(i<y&&(g.copy(d),m&&m.copy(f),y=i,b=t,I=o),i<s)return!0}}}}),fo.releasePrimitive(h),fo.releasePrimitive(u),y===1/0?null:(i.point?i.point.copy(g):i.point=g.clone(),i.distance=y,i.faceIndex=b,r&&(r.point?r.point.copy(m):r.point=m.clone(),r.point.applyMatrix4(Zo),g.applyMatrix4(Zo),r.distance=g.sub(r.point).length(),r.faceIndex=I),i)}const sa=new ro.constructor,oa=new ro.constructor,aa=new PrimitivePool((()=>new p)),Aa=new p,la=new p,ca=new p,pa=new p;let ha=!1;function _traverse(e,t,n,i,r,s=0,o=0,a=0,A=0,l=null,c=!1){let p,h;c?(p=oa,h=sa):(p=sa,h=oa);const u=p.float32Array,d=p.uint32Array,g=p.uint16Array,f=h.float32Array,m=h.uint32Array,y=h.uint16Array,b=2*t,I=IS_LEAF(2*e,g),x=IS_LEAF(b,y);let C=!1;if(x&&I)C=c?r(OFFSET(t,m),COUNT(2*t,y),OFFSET(e,d),COUNT(2*e,g),A,o+t/8,a,s+e/8):r(OFFSET(e,d),COUNT(2*e,g),OFFSET(t,m),COUNT(2*t,y),a,s+e/8,A,o+t/8);else if(x){const l=aa.getPrimitive();arrayToBox(t,f,l),l.applyMatrix4(n);const p=LEFT_NODE(e),h=RIGHT_NODE(e,d);arrayToBox(p,u,Aa),arrayToBox(h,u,la);const g=l.intersectsBox(Aa),m=l.intersectsBox(la);C=g&&_traverse(t,p,i,n,r,o,s,A,a+1,l,!c)||m&&_traverse(t,h,i,n,r,o,s,A,a+1,l,!c),aa.releasePrimitive(l)}else{const p=LEFT_NODE(t),h=RIGHT_NODE(t,m);arrayToBox(p,f,ca),arrayToBox(h,f,pa);const g=l.intersectsBox(ca),y=l.intersectsBox(pa);if(g&&y)C=_traverse(e,p,n,i,r,s,o,a,A+1,l,c)||_traverse(e,h,n,i,r,s,o,a,A+1,l,c);else if(g)if(I)C=_traverse(e,p,n,i,r,s,o,a,A+1,l,c);else{const t=aa.getPrimitive();t.copy(ca).applyMatrix4(n);const l=LEFT_NODE(e),h=RIGHT_NODE(e,d);arrayToBox(l,u,Aa),arrayToBox(h,u,la);const g=t.intersectsBox(Aa),f=t.intersectsBox(la);C=g&&_traverse(p,l,i,n,r,o,s,A,a+1,t,!c)||f&&_traverse(p,h,i,n,r,o,s,A,a+1,t,!c),aa.releasePrimitive(t)}else if(y)if(I)C=_traverse(e,h,n,i,r,s,o,a,A+1,l,c);else{const t=aa.getPrimitive();t.copy(pa).applyMatrix4(n);const l=LEFT_NODE(e),p=RIGHT_NODE(e,d);arrayToBox(l,u,Aa),arrayToBox(p,u,la);const g=t.intersectsBox(Aa),f=t.intersectsBox(la);C=g&&_traverse(h,l,i,n,r,o,s,A,a+1,t,!c)||f&&_traverse(h,p,i,n,r,o,s,A,a+1,t,!c),aa.releasePrimitive(t)}}return C}function convertRaycastIntersect(e,t,n){return null===e?null:(e.point.applyMatrix4(t.matrixWorld),e.distance=e.point.distanceTo(n.ray.origin),e.object=t,e)}class GeometryBVH extends BVH{get indirect(){return!!this._indirectBuffer}get primitiveStride(){return null}get primitiveBufferStride(){return this.indirect?1:this.primitiveStride}set primitiveBufferStride(e){}get primitiveBuffer(){return this.indirect?this._indirectBuffer:this.geometry.index.array}set primitiveBuffer(e){}constructor(e,t={}){if(!e.isBufferGeometry)throw new Error("BVH: Only BufferGeometries are supported.");if(e.index&&e.index.isInterleavedBufferAttribute)throw new Error("BVH: InterleavedBufferAttribute is not supported for the index attribute.");if(t.useSharedArrayBuffer&&!function isSharedArrayBufferSupported(){return"undefined"!=typeof SharedArrayBuffer}())throw new Error("BVH: SharedArrayBuffer is not available.");super(),this.geometry=e,this.resolvePrimitiveIndex=t.indirect?e=>this._indirectBuffer[e]:e=>e,this.primitiveBuffer=null,this.primitiveBufferStride=null,this._indirectBuffer=null,(t={...Js,...t})[Ws]||this.init(t)}init(e){const{geometry:t,primitiveStride:n}=this;if(e.indirect){const i=function generateIndirectBuffer(e,t){const n=e[e.length-1],i=n.offset+n.count>65536,r=e.reduce(((e,t)=>e+t.count),0),s=i?4:2,o=t?new SharedArrayBuffer(r*s):new ArrayBuffer(r*s),a=i?new Uint32Array(o):new Uint16Array(o);let A=0;for(let t=0;t<e.length;t++){const{offset:n,count:i}=e[t];for(let e=0;e<i;e++)a[A+e]=n+e;A+=i}return a}(getRootPrimitiveRanges(t,e.range,n),e.useSharedArrayBuffer);this._indirectBuffer=i}else ensureIndex$1(t,e);super.init(e),!t.boundingBox&&e.setBoundingBox&&(t.boundingBox=this.getBoundingBox(new p))}computePrimitiveBounds(){throw new Error("BVH: computePrimitiveBounds() not implemented")}getRootRanges(e){return this.indirect?[{offset:0,count:this._indirectBuffer.length}]:getRootPrimitiveRanges(this.geometry,e,this.primitiveStride)}raycastObject3D(){throw new Error("BVH: raycastObject3D() not implemented")}shapecast(e){let{iterateDirect:t,iterateIndirect:n,...i}=e;const r=this.indirect?n:t;return super.shapecast({...i,iterate:r})}}const ua=new OrientedBox,da=new ut,ga=new u,fa=new m,ma=new u;class MeshBVH extends GeometryBVH{static serialize(e,t={}){t={cloneBuffers:!0,...t};const n=e.geometry,i=e._roots,r=e._indirectBuffer,s=n.getIndex(),o={version:1,roots:null,index:null,indirectBuffer:null};return t.cloneBuffers?(o.roots=i.map((e=>e.slice())),o.index=s?s.array.slice():null,o.indirectBuffer=r?r.slice():null):(o.roots=i,o.index=s?s.array:null,o.indirectBuffer=r),o}static deserialize(e,t,n={}){n={setIndex:!0,indirect:Boolean(e.indirectBuffer),...n};const{index:i,roots:r,indirectBuffer:s}=e;e.version||(console.warn("MeshBVH.deserialize: Serialization format has been changed and will be fixed up. It is recommended to regenerate any stored serialized data."),function fixupVersion0(e){for(let t=0;t<e.length;t++){const n=e[t],i=new Uint32Array(n),r=new Uint16Array(n);for(let e=0,t=n.byteLength/qs;e<t;e++){const t=8*e;IS_LEAF(2*t,r)||(i[t+6]=i[t+6]/8-e)}}}(r));const o=new MeshBVH(t,{...n,[Ws]:!0});if(o._roots=r,o._indirectBuffer=s||null,n.setIndex){const n=t.getIndex();if(null===n){const n=new B(e.index,1,!1);t.setIndex(n)}else n.array!==i&&(n.array.set(i),n.needsUpdate=!0)}return o}get primitiveStride(){return 3}get resolveTriangleIndex(){return this.resolvePrimitiveIndex}constructor(e,t={}){t.maxLeafTris&&(t={...t,maxLeafSize:t.maxLeafTris}),super(e,t)}shiftTriangleOffsets(e){return super.shiftPrimitiveOffsets(e)}computePrimitiveBounds(e,t,n){const i=this.geometry,r=this._indirectBuffer,s=i.attributes.position,o=i.index?i.index.array:null,a=s.normalized;if(e<0||t+e-n.offset>n.length/6)throw new Error("MeshBVH: compute triangle bounds range is invalid.");const A=s.array,l=s.offset||0;let c=3;s.isInterleavedBufferAttribute&&(c=s.data.stride);const p=["getX","getY","getZ"],h=n.offset;for(let i=e,u=e+t;i<u;i++){const e=3*(r?r[i]:i),t=6*(i-h);let u=e+0,d=e+1,g=e+2;o&&(u=o[u],d=o[d],g=o[g]),a||(u=u*c+l,d=d*c+l,g=g*c+l);for(let e=0;e<3;e++){let i,r,o;a?(i=s[p[e]](u),r=s[p[e]](d),o=s[p[e]](g)):(i=A[u+e],r=A[d+e],o=A[g+e]);let l=i;r<l&&(l=r),o<l&&(l=o);let c=i;r>c&&(c=r),o>c&&(c=o);const h=(c-l)/2,f=2*e;n[t+f+0]=l+h,n[t+f+1]=h+(Math.abs(l)+h)*js}}return n}raycastObject3D(e,t,n=[]){const{material:i}=e;if(void 0===i)return;fa.copy(e.matrixWorld).invert(),da.copy(t.ray).applyMatrix4(fa),ma.setFromMatrixScale(e.matrixWorld),ga.copy(da.direction).multiply(ma);const r=ga.length(),s=t.near/r,o=t.far/r;if(!0===t.firstHitOnly){let r=this.raycastFirst(da,i,s,o);r=convertRaycastIntersect(r,e,t),r&&n.push(r)}else{const r=this.raycast(da,i,s,o);for(let i=0,s=r.length;i<s;i++){const s=convertRaycastIntersect(r[i],e,t);s&&n.push(s)}}return n}refit(e=null){return(this.indirect?refit_indirect:refit)(this,e)}raycast(e,t=Ce,n=0,i=1/0){const r=this._roots,s=[],o=this.indirect?raycast_indirect:raycast;for(let a=0,A=r.length;a<A;a++)o(this,a,t,e,s,n,i);return s}raycastFirst(e,t=Ce,n=0,i=1/0){const r=this._roots;let s=null;const o=this.indirect?raycastFirst_indirect:raycastFirst;for(let a=0,A=r.length;a<A;a++){const r=o(this,a,t,e,n,i);null!=r&&(null==s||r.distance<s.distance)&&(s=r)}return s}intersectsGeometry(e,t){let n=!1;const i=this._roots,r=this.indirect?intersectsGeometry_indirect:intersectsGeometry;for(let s=0,o=i.length;s<o&&(n=r(this,s,e,t),!n);s++);return n}shapecast(e){const t=fo.getPrimitive(),n=super.shapecast({...e,intersectsPrimitive:e.intersectsTriangle,scratchPrimitive:t,iterateDirect:iterateOverTriangles,iterateIndirect:iterateOverTriangles_indirect});return fo.releasePrimitive(t),n}bvhcast(e,t,n){let{intersectsRanges:i,intersectsTriangles:r}=n;const s=fo.getPrimitive(),o=this.geometry.index,a=this.geometry.attributes.position,A=this.indirect?e=>{const t=this.resolveTriangleIndex(e);setTriangle(s,3*t,o,a)}:e=>{setTriangle(s,3*e,o,a)},l=fo.getPrimitive(),c=e.geometry.index,p=e.geometry.attributes.position,h=e.indirect?t=>{const n=e.resolveTriangleIndex(t);setTriangle(l,3*n,c,p)}:e=>{setTriangle(l,3*e,c,p)};if(r){const iterateOverDoubleTriangles=(e,n,i,o,a,c,p,u)=>{for(let d=i,g=i+o;d<g;d++){h(d),l.a.applyMatrix4(t),l.b.applyMatrix4(t),l.c.applyMatrix4(t),l.needsUpdate=!0;for(let t=e,i=e+n;t<i;t++)if(A(t),s.needsUpdate=!0,r(s,l,t,d,a,c,p,u))return!0}return!1};if(i){const e=i;i=function(t,n,i,r,s,o,a,A){return!!e(t,n,i,r,s,o,a,A)||iterateOverDoubleTriangles(t,n,i,r,s,o,a,A)}}else i=iterateOverDoubleTriangles}return function bvhcast(e,t,n,i){if(ha)throw new Error("MeshBVH: Recursive calls to bvhcast not supported.");ha=!0;const r=e._roots,s=t._roots;let o,a=0,A=0;const l=(new m).copy(n).invert();for(let e=0,t=r.length;e<t;e++){sa.setBuffer(r[e]),A=0;const t=aa.getPrimitive();arrayToBox(0,sa.float32Array,t),t.applyMatrix4(l);for(let e=0,r=s.length;e<r&&(oa.setBuffer(s[e]),o=_traverse(0,0,n,l,i,a,A,0,0,t),oa.clearBuffer(),A+=s[e].byteLength/qs,!o);e++);if(aa.releasePrimitive(t),sa.clearBuffer(),a+=r[e].byteLength/qs,o)break}return ha=!1,o}(this,e,t,i)}intersectsBox(e,t){return ua.set(e.min,e.max,t),ua.needsUpdate=!0,this.shapecast({intersectsBounds:e=>ua.intersectsBox(e),intersectsTriangle:e=>ua.intersectsTriangle(e)})}intersectsSphere(e){return this.shapecast({intersectsBounds:t=>e.intersectsBox(t),intersectsTriangle:t=>t.intersectsSphere(e)})}closestPointToGeometry(e,t,n={},i={},r=0,s=1/0){return(this.indirect?closestPointToGeometry_indirect:closestPointToGeometry)(this,e,t,n,i,r,s)}closestPointToPoint(e,t={},n=0,i=1/0){return function closestPointToPoint(e,t,n={},i=0,r=1/0){const s=i*i,o=r*r;let a=1/0,A=null;if(e.shapecast({boundsTraverseOrder:e=>(mo.copy(t).clamp(e.min,e.max),mo.distanceToSquared(t)),intersectsBounds:(e,t,n)=>n<a&&n<o,intersectsTriangle:(e,n)=>{e.closestPointToPoint(t,mo);const i=t.distanceToSquared(mo);return i<a&&(yo.copy(mo),a=i,A=n),i<s}}),a===1/0)return null;const l=Math.sqrt(a);return n.point?n.point.copy(yo):n.point=yo.clone(),n.distance=l,n.faceIndex=A,n}(this,e,t,n,i)}}const ya=1e-6,ba=Math.pow(10,-Math.log10(ya)),Ia=5e-7*ba;function hashNumber(e){return~~(e*ba+Ia)}function hashVertex3(e){return`${hashNumber(e.x)},${hashNumber(e.y)},${hashNumber(e.z)}`}function hashVertex4(e){return`${hashNumber(e.x)},${hashNumber(e.y)},${hashNumber(e.z)},${hashNumber(e.w)}`}function toNormalizedRay(e,t,n){n.direction.subVectors(t,e).normalize();const i=e.dot(n.direction);return n.origin.copy(e).addScaledVector(n.direction,-i),n}function areSharedArrayBuffersSupported(){return"undefined"!=typeof SharedArrayBuffer}function convertToSharedArrayBuffer(e){if(e.buffer instanceof SharedArrayBuffer)return e;const t=e.constructor,n=e.buffer,i=new SharedArrayBuffer(n.byteLength),r=new Uint8Array(n);return new Uint8Array(i).set(r,0),new t(i)}function ensureIndex(e,t){if(!e.index){const n=e.attributes.position.count,i=function getIndexArray(e,t=ArrayBuffer){return e>65535?new Uint32Array(new t(4*e)):new Uint16Array(new t(2*e))}(n,t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer);e.setIndex(new B(i,1));for(let e=0;e<n;e++)i[e]=e}}function getTriCount(e){return function getVertexCount(e){return e.index?e.index.count:e.attributes.position.count}(e)/3}const xa=new u;function toEdgeIndex(e){return e%3}function sortEdgeFunc(e,t){return e.start-t.start}function getProjectedDistance(e,t){return xa.subVectors(t,e.origin).dot(e.direction)}const Ca=1e-5,Ba=1e-4;class RaySet{constructor(){this._rays=[]}addRay(e){this._rays.push(e)}findClosestRay(e){const t=this._rays,n=e.clone();n.direction.multiplyScalar(-1);let i=1/0,r=null;for(let s=0,o=t.length;s<o;s++){const o=t[s];if(skipRay(o,e)&&skipRay(o,n))continue;const a=scoreRays(o,e),A=scoreRays(o,n),l=Math.min(a,A);l<i&&(i=l,r=o)}return r;function skipRay(e,t){const n=e.origin.distanceTo(t.origin)>Ca;return e.direction.angleTo(t.direction)>Ba||n}function scoreRays(e,t){const n=e.origin.distanceTo(t.origin),i=e.direction.angleTo(t.direction);return n/Ca+i/Ba}}}const Ea=new u,wa=new u,va=new ut;function computeDisjointEdges(e,t,n){const i=e.attributes,r=e.index,s=i.position,o=new Map,a=new Map,A=Array.from(t),l=new RaySet;for(let e=0,t=A.length;e<t;e++){const t=A[e],n=~~(t/3),i=toEdgeIndex(t);let o,c=3*n+i,p=3*n+(i+1)%3;r&&(c=r.getX(c),p=r.getX(p)),Ea.fromBufferAttribute(s,c),wa.fromBufferAttribute(s,p),toNormalizedRay(Ea,wa,va);let h=l.findClosestRay(va);null===h&&(h=va.clone(),l.addRay(h)),a.has(h)||a.set(h,{forward:[],reverse:[],ray:h}),o=a.get(h);let u=getProjectedDistance(h,Ea),d=getProjectedDistance(h,wa);u>d&&([u,d]=[d,u]),va.direction.dot(h.direction)<0?o.reverse.push({start:u,end:d,index:t}):o.forward.push({start:u,end:d,index:t})}return a.forEach((({forward:e,reverse:t},i)=>{!function matchEdges(e,t,n,i=1e-8){e.sort(sortEdgeFunc),t.sort(sortEdgeFunc);for(let i=0;i<e.length;i++){const r=e[i];for(let s=0;s<t.length;s++){const o=t[s];if(o.start>r.end);else{if(r.end<o.start||o.end<r.start)continue;if(r.start<=o.start&&r.end>=o.end)areDistancesDegenerate(o.end,r.end)||e.splice(i+1,0,{start:o.end,end:r.end,index:r.index}),r.end=o.start,o.start=0,o.end=0;else if(r.start>=o.start&&r.end<=o.end)areDistancesDegenerate(r.end,o.end)||t.splice(s+1,0,{start:r.end,end:o.end,index:o.index}),o.end=r.start,r.start=0,r.end=0;else if(r.start<=o.start&&r.end<=o.end){const e=r.end;r.end=o.start,o.start=e}else{if(!(r.start>=o.start&&r.end>=o.end))throw new Error;{const e=o.end;o.end=r.start,r.start=e}}}if(n.has(r.index)||n.set(r.index,[]),n.has(o.index)||n.set(o.index,[]),n.get(r.index).push(o.index),n.get(o.index).push(r.index),isEdgeDegenerate(o)&&(t.splice(s,1),s--),isEdgeDegenerate(r)){e.splice(i,1),i--;break}}}function cleanUpEdgeSet(e){for(let t=0;t<e.length;t++)isEdgeDegenerate(e[t])&&(e.splice(t,1),t--)}function areDistancesDegenerate(e,t){return Math.abs(t-e)<i}function isEdgeDegenerate(e){return Math.abs(e.end-e.start)<i}cleanUpEdgeSet(e),cleanUpEdgeSet(t)}(e,t,o,n),0===e.length&&0===t.length&&a.delete(i)})),{disjointConnectivityMap:o,fragmentMap:a}}const Qa=new r,Pa=new u,Ta=new g,Sa=["","",""];class HalfEdgeMap{constructor(e=null){this.data=null,this.disjointConnections=null,this.unmatchedDisjointEdges=null,this.unmatchedEdges=-1,this.matchedEdges=-1,this.useDrawRange=!0,this.useAllAttributes=!1,this.matchDisjointEdges=!1,this.degenerateEpsilon=1e-8,e&&this.updateFrom(e)}getSiblingTriangleIndex(e,t){const n=this.data[3*e+t];return-1===n?-1:~~(n/3)}getSiblingEdgeIndex(e,t){const n=this.data[3*e+t];return-1===n?-1:n%3}getDisjointSiblingTriangleIndices(e,t){const n=3*e+t,i=this.disjointConnections.get(n);return i?i.map((e=>~~(e/3))):[]}getDisjointSiblingEdgeIndices(e,t){const n=3*e+t,i=this.disjointConnections.get(n);return i?i.map((e=>e%3)):[]}isFullyConnected(){return 0===this.unmatchedEdges}updateFrom(e){const{useAllAttributes:t,useDrawRange:n,matchDisjointEdges:i,degenerateEpsilon:r}=this,s=t?function hashAllAttributes(e){let t="";for(let i=0,r=A.length;i<r;i++){const r=a[A[i]];let s;switch(r.itemSize){case 1:s=hashNumber(r.getX(e));break;case 2:s=`${hashNumber((n=Qa.fromBufferAttribute(r,e)).x)},${hashNumber(n.y)}`;break;case 3:s=hashVertex3(Pa.fromBufferAttribute(r,e));break;case 4:s=hashVertex4(Ta.fromBufferAttribute(r,e))}""!==t&&(t+="|"),t+=s}var n;return t}:function hashPositionAttribute(e){return Pa.fromBufferAttribute(c,e),hashVertex3(Pa)},o=new Map,{attributes:a}=e,A=t?Object.keys(a):null,l=e.index,c=a.position;let p=getTriCount(e);const h=p;let u=0;n&&(u=e.drawRange.start,e.drawRange.count!==1/0&&(p=~~(e.drawRange.count/3)));let d=this.data;(!d||d.length<3*h)&&(d=new Int32Array(3*h)),d.fill(-1);let g=0,f=new Set;for(let e=u,t=3*p+u;e<t;e+=3){const t=e;for(let e=0;e<3;e++){let n=t+e;l&&(n=l.getX(n)),Sa[e]=s(n)}for(let e=0;e<3;e++){const n=(e+1)%3,i=Sa[e],r=Sa[n],s=`${r}_${i}`;if(o.has(s)){const n=t+e,i=o.get(s);d[n]=i,d[i]=n,o.delete(s),g+=2,f.delete(i)}else{const n=`${i}_${r}`,s=t+e;o.set(n,s),f.add(s)}}}if(i){const{fragmentMap:t,disjointConnectivityMap:n}=computeDisjointEdges(e,f,r);f.clear(),t.forEach((({forward:e,reverse:t})=>{e.forEach((({index:e})=>f.add(e))),t.forEach((({index:e})=>f.add(e)))})),this.unmatchedDisjointEdges=t,this.disjointConnections=n,g=3*p-f.size}this.matchedEdges=g,this.unmatchedEdges=f.size,this.data=d}}class Brush extends d{constructor(...e){super(...e),this.isBrush=!0,this._previousMatrix=new m,this._previousMatrix.elements.fill(0)}markUpdated(){this._previousMatrix.copy(this.matrix)}isDirty(){const{matrix:e,_previousMatrix:t}=this,n=e.elements,i=t.elements;for(let e=0;e<16;e++)if(n[e]!==i[e])return!0;return!1}prepareGeometry(){const e=this.geometry,t=e.attributes,n=areSharedArrayBuffersSupported();if(n)for(const e in t){const n=t[e];if(n.isInterleavedBufferAttribute)throw new Error("Brush: InterleavedBufferAttributes are not supported.");n.array=convertToSharedArrayBuffer(n.array)}if(e.boundsTree||(ensureIndex(e,{useSharedArrayBuffer:n}),e.boundsTree=new MeshBVH(e,{maxLeafTris:3,indirect:!0,useSharedArrayBuffer:n})),e.halfEdges||(e.halfEdges=new HalfEdgeMap(e)),!e.groupIndices){const t=getTriCount(e),n=new Uint16Array(t),i=e.groups;for(let e=0,t=i.length;e<t;e++){const{start:t,count:r}=i[e];for(let i=t/3,s=(t+r)/3;i<s;i++)n[i]=e}e.groupIndices=n}}disposeCacheData(){const{geometry:e}=this;e.halfEdges=null,e.boundsTree=null,e.groupIndices=null}}const Ma=new u,Da=new u,La=new u;function isTriDegenerate(e,t=1e-14){Ma.subVectors(e.b,e.a),Da.subVectors(e.c,e.a),La.subVectors(e.b,e.c);const n=Ma.angleTo(Da),i=Ma.angleTo(La),r=Math.PI-n-i;return Math.abs(n)<t||Math.abs(i)<t||Math.abs(r)<t||e.a.distanceToSquared(e.b)<t||e.a.distanceToSquared(e.c)<t||e.b.distanceToSquared(e.c)<t}const _a=1e-10,Fa=1e-10,ka=new f,Ra=new f,Na=new u,Oa=new u,Ga=new u,Ua=new lt,Ya=new ExtendedTriangle;class TrianglePool{constructor(){this._pool=[],this._index=0}getTriangle(){return this._index>=this._pool.length&&this._pool.push(new ct),this._pool[this._index++]}clear(){this._index=0}reset(){this._pool.length=0,this._index=0}}class TriangleSplitter{constructor(){this.trianglePool=new TrianglePool,this.triangles=[],this.normal=new u,this.coplanarTriangleUsed=!1}initialize(e){this.reset();const{triangles:t,trianglePool:n,normal:i}=this;if(Array.isArray(e))for(let r=0,s=e.length;r<s;r++){const s=e[r];if(0===r)s.getNormal(i);else if(Math.abs(1-s.getNormal(Na).dot(i))>_a)throw new Error("Triangle Splitter: Cannot initialize with triangles that have different normals.");const o=n.getTriangle();o.copy(s),t.push(o)}else{e.getNormal(i);const r=n.getTriangle();r.copy(e),t.push(r)}}splitByTriangle(e){const{normal:t,triangles:n}=this;if(e.getNormal(Oa).normalize(),Math.abs(1-Math.abs(Oa.dot(t)))<1e-10){this.coplanarTriangleUsed=!0;for(let e=0,t=n.length;e<t;e++){n[e].coplanarCount=0}const t=[e.a,e.b,e.c];for(let n=0;n<3;n++){const i=(n+1)%3,r=t[n],s=t[i];Na.subVectors(s,r).normalize(),Ga.crossVectors(Oa,Na),Ua.setFromNormalAndCoplanarPoint(Ga,r),this.splitByPlane(Ua,e)}}else e.getPlane(Ua),this.splitByPlane(Ua,e)}splitByPlane(e,t){const{triangles:n,trianglePool:i}=this;Ya.copy(t),Ya.needsUpdate=!0;for(let t=0,r=n.length;t<r;t++){const s=n[t];if(!Ya.intersectsTriangle(s,ka,!0))continue;const{a:o,b:a,c:A}=s;let l=0,c=-1,p=!1,h=[],u=[];const d=[o,a,A];for(let t=0;t<3;t++){const n=(t+1)%3;ka.start.copy(d[t]),ka.end.copy(d[n]);const i=e.distanceToPoint(ka.start),r=e.distanceToPoint(ka.end);if(Math.abs(i)<Fa&&Math.abs(r)<Fa){p=!0;break}if(i>0?h.push(t):u.push(t),Math.abs(i)<Fa)continue;let s=!!e.intersectLine(ka,Na);!s&&Math.abs(r)<Fa&&(Na.copy(ka.end),s=!0),!s||Na.distanceTo(ka.start)<_a||(Na.distanceTo(ka.end)<_a&&(c=t),0===l?Ra.start.copy(Na):Ra.end.copy(Na),l++)}if(!p&&2===l&&Ra.distance()>Fa)if(-1!==c){c=(c+1)%3;let e=0;e===c&&(e=(e+1)%3);let o=e+1;o===c&&(o=(o+1)%3);const a=i.getTriangle();a.a.copy(d[o]),a.b.copy(Ra.end),a.c.copy(Ra.start),isTriDegenerate(a)||n.push(a),s.a.copy(d[e]),s.b.copy(Ra.start),s.c.copy(Ra.end),isTriDegenerate(s)&&(n.splice(t,1),t--,r--)}else{const e=h.length>=2?u[0]:h[0];if(0===e){let e=Ra.start;Ra.start=Ra.end,Ra.end=e}const o=(e+1)%3,a=(e+2)%3,A=i.getTriangle(),l=i.getTriangle();d[o].distanceToSquared(Ra.start)<d[a].distanceToSquared(Ra.end)?(A.a.copy(d[o]),A.b.copy(Ra.start),A.c.copy(Ra.end),l.a.copy(d[o]),l.b.copy(d[a]),l.c.copy(Ra.start)):(A.a.copy(d[a]),A.b.copy(Ra.start),A.c.copy(Ra.end),l.a.copy(d[o]),l.b.copy(d[a]),l.c.copy(Ra.end)),s.a.copy(d[e]),s.b.copy(Ra.end),s.c.copy(Ra.start),isTriDegenerate(A)||n.push(A),isTriDegenerate(l)||n.push(l),isTriDegenerate(s)&&(n.splice(t,1),t--,r--)}else 3===l&&console.warn("TriangleClipper: Coplanar clip not handled")}}reset(){this.triangles.length=0,this.trianglePool.clear(),this.coplanarTriangleUsed=!1}}class TypeBackedArray{constructor(e,t=500){this.expansionFactor=1.5,this.type=e,this.length=0,this.array=null,this.setSize(t)}setType(e){if(0!==this.length)throw new Error("TypeBackedArray: Cannot change the type while there is used data in the buffer.");const t=this.array.buffer;this.array=new e(t),this.type=e}setSize(e){if(this.array&&e===this.array.length)return;const t=this.type,n=new t(new(areSharedArrayBuffersSupported()?SharedArrayBuffer:ArrayBuffer)(function ceilToFourByteStride(e){return 4+(e=~~e)-e%4}(e*t.BYTES_PER_ELEMENT)));this.array&&n.set(this.array,0),this.array=n}expand(){const{array:e,expansionFactor:t}=this;this.setSize(e.length*t)}push(...e){let{array:t,length:n}=this;n+e.length>t.length&&(this.expand(),t=this.array);for(let i=0,r=e.length;i<r;i++)t[n+i]=e[i];this.length+=e.length}clear(){this.length=0}}class TypedAttributeData{constructor(){this.groupAttributes=[{}],this.groupCount=0}getType(e){return this.groupAttributes[0][e].type}getItemSize(e){return this.groupAttributes[0][e].itemSize}getNormalized(e){return this.groupAttributes[0][e].normalized}getCount(e){if(this.groupCount<=e)return 0;const t=this.getGroupAttrArray("position",e);return t.length/t.itemSize}getTotalLength(e){const{groupCount:t,groupAttributes:n}=this;let i=0;for(let r=0;r<t;r++){i+=n[r][e].length}return i}getGroupAttrSet(e=0){const{groupAttributes:t}=this;if(t[e])return this.groupCount=Math.max(this.groupCount,e+1),t[e];const n=t[0];for(this.groupCount=Math.max(this.groupCount,e+1);e>=t.length;){const e={};t.push(e);for(const t in n){const i=n[t],r=new TypeBackedArray(i.type);r.itemSize=i.itemSize,r.normalized=i.normalized,e[t]=r}}return t[e]}getGroupAttrArray(e,t=0){const{groupAttributes:n}=this;if(!n[0][e])throw new Error(`TypedAttributeData: Attribute with "${e}" has not been initialized`);return this.getGroupAttrSet(t)[e]}initializeArray(e,t,n,i){const{groupAttributes:r}=this,s=r[0][e];if(s){if(s.type!==t)for(let s=0,o=r.length;s<o;s++){const o=r[s][e];o.setType(t),o.itemSize=n,o.normalized=i}}else for(let s=0,o=r.length;s<o;s++){const o=new TypeBackedArray(t);o.itemSize=n,o.normalized=i,r[s][e]=o}}clear(){this.groupCount=0;const{groupAttributes:e}=this;e.forEach((e=>{for(const t in e)e[t].clear()}))}delete(e){this.groupAttributes.forEach((t=>{delete t[e]}))}reset(){this.groupAttributes=[],this.groupCount=0}}class IntersectionMap{constructor(){this.intersectionSet={},this.ids=[]}add(e,t){const{intersectionSet:n,ids:i}=this;n[e]||(n[e]=[],i.push(e)),n[e].push(t)}}const za=new ut,Ha=new m,Xa=new ct,qa=new u,ja=new g,Wa=new g,Ja=new g,Va=new g,Ka=new g,Za=new g,$a=new f,eA=new u,tA=1e-8,nA=-1;let iA=null;function setDebugContext(e){iA=e}function getHitSide(e,t){e.getMidpoint(za.origin),e.getNormal(za.direction);const n=t.raycastFirst(za,te);return Boolean(n&&za.direction.dot(n.face.normal)>0)?nA:1}function getHitSideWithCoplanarCheck(e,t){function rand(){return Math.random()-.5}e.getNormal(eA),za.direction.copy(eA),e.getMidpoint(za.origin);let n=0,i=1/0;for(let e=0;e<3;e++){za.direction.x+=rand()*tA,za.direction.y+=rand()*tA,za.direction.z+=rand()*tA,za.direction.multiplyScalar(-1);const r=t.raycastFirst(za,te);if(Boolean(r&&za.direction.dot(r.face.normal)>0)&&n++,null!==r&&(i=Math.min(i,r.distance)),i<=1e-15)return r.face.normal.dot(eA)>0?2:-2;if(n/3>.5||(e-n+1)/3>.5)break}return n/3>.5?nA:1}function appendAttributeFromTriangle(e,t,n,i,r,s,o=!1){const a=n.attributes,A=n.index,l=3*e,c=A.getX(l+0),p=A.getX(l+1),h=A.getX(l+2);for(const e in s){const n=a[e],A=s[e];if(!(e in a))throw new Error(`CSG Operations: Attribute ${e} not available on geometry.`);const l=n.itemSize;"position"===e?(Xa.a.fromBufferAttribute(n,c).applyMatrix4(i),Xa.b.fromBufferAttribute(n,p).applyMatrix4(i),Xa.c.fromBufferAttribute(n,h).applyMatrix4(i),pushBarycoordInterpolatedValues(Xa.a,Xa.b,Xa.c,t,3,A,o)):"normal"===e?(Xa.a.fromBufferAttribute(n,c).applyNormalMatrix(r),Xa.b.fromBufferAttribute(n,p).applyNormalMatrix(r),Xa.c.fromBufferAttribute(n,h).applyNormalMatrix(r),o&&(Xa.a.multiplyScalar(-1),Xa.b.multiplyScalar(-1),Xa.c.multiplyScalar(-1)),pushBarycoordInterpolatedValues(Xa.a,Xa.b,Xa.c,t,3,A,o,!0)):(ja.fromBufferAttribute(n,c),Wa.fromBufferAttribute(n,p),Ja.fromBufferAttribute(n,h),pushBarycoordInterpolatedValues(ja,Wa,Ja,t,l,A,o))}}function appendAttributesFromIndices(e,t,n,i,r,s,o,a=!1){appendAttributeFromIndex(e,i,r,s,o,a),appendAttributeFromIndex(a?n:t,i,r,s,o,a),appendAttributeFromIndex(a?t:n,i,r,s,o,a)}function getOperationAction(e,t,n=!1){switch(e){case 0:if(1===t||2===t&&!n)return 1;break;case 1:if(n){if(t===nA)return 0}else if(1===t||-2===t)return 1;break;case 2:if(n){if(1===t||-2===t)return 1}else if(t===nA)return 0;break;case 4:if(t===nA)return 0;if(1===t)return 1;break;case 3:if(t===nA||2===t&&!n)return 1;break;case 5:if(!n&&(1===t||-2===t))return 1;break;case 6:if(!n&&(t===nA||2===t))return 1;break;default:throw new Error(`Unrecognized CSG operation enum "${e}".`)}return 2}function pushBarycoordInterpolatedValues(e,t,n,i,r,s,o=!1,a=!1){const addValues=e=>{s.push(e.x),r>1&&s.push(e.y),r>2&&s.push(e.z),r>3&&s.push(e.w)};Va.set(0,0,0,0).addScaledVector(e,i.a.x).addScaledVector(t,i.a.y).addScaledVector(n,i.a.z),Ka.set(0,0,0,0).addScaledVector(e,i.b.x).addScaledVector(t,i.b.y).addScaledVector(n,i.b.z),Za.set(0,0,0,0).addScaledVector(e,i.c.x).addScaledVector(t,i.c.y).addScaledVector(n,i.c.z),a&&(Va.normalize(),Ka.normalize(),Za.normalize()),addValues(Va),o?(addValues(Za),addValues(Ka)):(addValues(Ka),addValues(Za))}function appendAttributeFromIndex(e,t,n,i,r,s=!1){for(const o in r){const a=t[o],A=r[o];if(!(o in t))throw new Error(`CSG Operations: Attribute ${o} no available on geometry.`);const l=a.itemSize;"position"===o?(qa.fromBufferAttribute(a,e).applyMatrix4(n),A.push(qa.x,qa.y,qa.z)):"normal"===o?(qa.fromBufferAttribute(a,e).applyNormalMatrix(i),s&&qa.multiplyScalar(-1),A.push(qa.x,qa.y,qa.z)):(A.push(a.getX(e)),l>1&&A.push(a.getY(e)),l>2&&A.push(a.getZ(e)),l>3&&A.push(a.getW(e)))}}class TriangleIntersectData{constructor(e){this.triangle=(new ct).copy(e),this.intersects={}}addTriangle(e,t){this.intersects[e]=(new ct).copy(t)}getIntersectArray(){const e=[],{intersects:t}=this;for(const n in t)e.push(t[n]);return e}}class TriangleIntersectionSets{constructor(){this.data={}}addTriangleIntersection(e,t,n,i){const{data:r}=this;r[e]||(r[e]=new TriangleIntersectData(t)),r[e].addTriangle(n,i)}getTrianglesAsArray(e=null){const{data:t}=this,n=[];if(null!==e)e in t&&n.push(t[e].triangle);else for(const e in t)n.push(t[e].triangle);return n}getTriangleIndices(){return Object.keys(this.data).map((e=>parseInt(e)))}getIntersectionIndices(e){const{data:t}=this;return t[e]?Object.keys(t[e].intersects).map((e=>parseInt(e))):[]}getIntersectionsAsArray(e=null,t=null){const{data:n}=this,i=new Set,r=[],addTriangles=e=>{if(n[e])if(null!==t)n[e].intersects[t]&&r.push(n[e].intersects[t]);else{const t=n[e].intersects;for(const e in t)i.has(e)||(i.add(e),r.push(t[e]))}};if(null!==e)addTriangles(e);else for(const e in n)addTriangles(e);return r}reset(){this.data={}}}class OperationDebugData{constructor(){this.enabled=!1,this.triangleIntersectsA=new TriangleIntersectionSets,this.triangleIntersectsB=new TriangleIntersectionSets,this.intersectionEdges=[]}addIntersectingTriangles(e,t,n,i){const{triangleIntersectsA:r,triangleIntersectsB:s}=this;r.addTriangleIntersection(e,t,n,i),s.addTriangleIntersection(n,i,e,t)}addEdge(e){this.intersectionEdges.push(e.clone())}reset(){this.triangleIntersectsA.reset(),this.triangleIntersectsB.reset(),this.intersectionEdges=[]}init(){this.enabled&&(this.reset(),setDebugContext(this))}complete(){this.enabled&&setDebugContext(null)}}const rA=new m,sA=new dt,oA=new ct,aA=new ct,AA=new ct,lA=new ct,cA=[],pA=[];function getFirstIdFromSet(e){for(const t of e)return t}function performOperation(e,t,n,i,r,s={}){const{useGroups:o=!0}=s,{aIntersections:a,bIntersections:A}=function collectIntersectingTriangles(e,t){const n=new IntersectionMap,i=new IntersectionMap;return Ha.copy(e.matrixWorld).invert().multiply(t.matrixWorld),e.geometry.boundsTree.bvhcast(t.geometry.boundsTree,Ha,{intersectsTriangles(r,s,o,a){if(!isTriDegenerate(r)&&!isTriDegenerate(s)){let A=r.intersectsTriangle(s,$a,!0);if(!A){const e=r.plane,t=s.plane,n=e.normal,i=t.normal;1===n.dot(i)&&Math.abs(e.constant-t.constant)<1e-14&&(A=!0)}if(A){let A=e.geometry.boundsTree.resolveTriangleIndex(o),l=t.geometry.boundsTree.resolveTriangleIndex(a);n.add(A,l),i.add(l,A),iA&&(iA.addEdge($a),iA.addIntersectingTriangles(o,r,a,s))}}return!1}}),{aIntersections:n,bIntersections:i}}(e,t);let l;l=o?0:-1,performSplitTriangleOperations(e,t,a,n,!1,i,r,l),performWholeTriangleOperations(e,t,a,n,!1,r,l);return-1!==n.findIndex((e=>6!==e&&5!==e))&&(l=o?e.geometry.groups.length||1:-1,performSplitTriangleOperations(t,e,A,n,!0,i,r,l),performWholeTriangleOperations(t,e,A,n,!0,r,l)),cA.length=0,pA.length=0,{groups:[],materials:null}}function performSplitTriangleOperations(e,t,n,i,r,s,o,a=0){const A=e.matrixWorld.determinant()<0;rA.copy(t.matrixWorld).invert().multiply(e.matrixWorld),sA.getNormalMatrix(e.matrixWorld).multiplyScalar(A?-1:1);const l=e.geometry.groupIndices,c=e.geometry.index,p=e.geometry.attributes.position,h=t.geometry.boundsTree,u=t.geometry.index,d=t.geometry.attributes.position,g=n.ids,f=n.intersectionSet;for(let t=0,n=g.length;t<n;t++){const n=g[t],m=-1===a?0:l[n]+a,y=3*n,b=c.getX(y+0),I=c.getX(y+1),x=c.getX(y+2);oA.a.fromBufferAttribute(p,b).applyMatrix4(rA),oA.b.fromBufferAttribute(p,I).applyMatrix4(rA),oA.c.fromBufferAttribute(p,x).applyMatrix4(rA),s.reset(),s.initialize(oA);const C=f[n];for(let e=0,t=C.length;e<t;e++){const t=3*C[e],n=u.getX(t+0),i=u.getX(t+1),r=u.getX(t+2);aA.a.fromBufferAttribute(d,n),aA.b.fromBufferAttribute(d,i),aA.c.fromBufferAttribute(d,r),s.splitByTriangle(aA)}const B=s.triangles;for(let t=0,a=B.length;t<a;t++){const a=B[t],l=s.coplanarTriangleUsed?getHitSideWithCoplanarCheck(a,h):getHitSide(a,h);cA.length=0,pA.length=0;for(let e=0,t=i.length;e<t;e++){const t=getOperationAction(i[e],l,r);2!==t&&(pA.push(t),cA.push(o[e].getGroupAttrSet(m)))}if(0!==cA.length){oA.getBarycoord(a.a,lA.a),oA.getBarycoord(a.b,lA.b),oA.getBarycoord(a.c,lA.c);for(let t=0,i=cA.length;t<i;t++){const i=cA[t],r=0===pA[t];appendAttributeFromTriangle(n,lA,e.geometry,e.matrixWorld,sA,i,A!==r)}}}}return g.length}function performWholeTriangleOperations(e,t,n,i,r,s,o=0){const a=e.matrixWorld.determinant()<0;rA.copy(t.matrixWorld).invert().multiply(e.matrixWorld),sA.getNormalMatrix(e.matrixWorld).multiplyScalar(a?-1:1);const A=t.geometry.boundsTree,l=e.geometry.groupIndices,c=e.geometry.index,p=e.geometry.attributes,h=p.position,u=[],d=e.geometry.halfEdges,g=new Set;for(let t=0,i=getTriCount(e.geometry);t<i;t++)t in n.intersectionSet||g.add(t);for(;g.size>0;){const t=getFirstIdFromSet(g);g.delete(t),u.push(t);const n=3*t,f=c.getX(n+0),m=c.getX(n+1),y=c.getX(n+2);AA.a.fromBufferAttribute(h,f).applyMatrix4(rA),AA.b.fromBufferAttribute(h,m).applyMatrix4(rA),AA.c.fromBufferAttribute(h,y).applyMatrix4(rA);const b=getHitSide(AA,A);pA.length=0,cA.length=0;for(let e=0,t=i.length;e<t;e++){const t=getOperationAction(i[e],b,r);2!==t&&(pA.push(t),cA.push(s[e]))}for(;u.length>0;){const t=u.pop();for(let e=0;e<3;e++){const n=d.getSiblingTriangleIndex(t,e);-1!==n&&g.has(n)&&(u.push(n),g.delete(n))}if(0!==cA.length){const n=3*t,i=c.getX(n+0),r=c.getX(n+1),s=c.getX(n+2),A=-1===o?0:l[t]+o;if(AA.a.fromBufferAttribute(h,i),AA.b.fromBufferAttribute(h,r),AA.c.fromBufferAttribute(h,s),!isTriDegenerate(AA))for(let t=0,n=cA.length;t<n;t++){const n=pA[t],o=cA[t].getGroupAttrSet(A),l=0===n;appendAttributesFromIndices(i,r,s,p,e.matrixWorld,sA,o,l!==a)}}}}}function getMaterialList(e,t){let n=t;return Array.isArray(t)||(n=[],e.forEach((e=>{n[e.materialIndex]=t}))),n}class Evaluator{constructor(){this.triangleSplitter=new TriangleSplitter,this.attributeData=[],this.attributes=["position","uv","normal"],this.useGroups=!0,this.consolidateGroups=!0,this.debug=new OperationDebugData}getGroupRanges(e){return this.useGroups&&0!==e.groups.length?e.groups.map((e=>({...e}))):[{start:0,count:1/0,materialIndex:0}]}evaluate(e,t,n,i=new Brush){let r=!0;if(Array.isArray(n)||(n=[n]),Array.isArray(i)||(i=[i],r=!1),i.length!==n.length)throw new Error("Evaluator: operations and target array passed as different sizes.");e.prepareGeometry(),t.prepareGeometry();const{triangleSplitter:s,attributeData:o,attributes:a,useGroups:A,consolidateGroups:l,debug:c}=this;for(;o.length<i.length;)o.push(new TypedAttributeData);i.forEach(((t,n)=>{!function prepareAttributesData(e,t,n,i){n.clear();const r=e.attributes;for(let e=0,t=i.length;e<t;e++){const t=i[e],s=r[t];n.initializeArray(t,s.array.constructor,s.itemSize,s.normalized)}for(const e in n.attributes)i.includes(e)||n.delete(e);for(const e in t.attributes)i.includes(e)||(t.deleteAttribute(e),t.dispose())}(e.geometry,t.geometry,o[n],a)})),c.init(),performOperation(e,t,n,s,o,{useGroups:A}),c.complete();const p=this.getGroupRanges(e.geometry),h=getMaterialList(p,e.material),u=this.getGroupRanges(t.geometry),d=getMaterialList(u,t.material);u.forEach((e=>e.materialIndex+=h.length));let g=[...p,...u].map(((e,t)=>({...e,index:t})));if(A){const e=[...h,...d];l&&(g=g.map((t=>{const n=e[t.materialIndex];return t.materialIndex=e.indexOf(n),t})).sort(((e,t)=>e.materialIndex-t.materialIndex)));const t=[];for(let n=0,i=e.length;n<i;n++){let i=!1;for(let e=0,r=g.length;e<r;e++){const r=g[e];r.materialIndex===n&&(i=!0,r.materialIndex=t.length)}i&&t.push(e[n])}i.forEach((e=>{e.material=t}))}else g=[{start:0,count:1/0,index:0,materialIndex:0}],i.forEach((e=>{e.material=h[0]}));return i.forEach(((e,t)=>{const n=e.geometry;!function assignBufferData(e,t,n){let i=!1,r=-1;const s=e.attributes,o=t.groupAttributes[0];for(const a in o){const o=t.getTotalLength(a),A=t.getType(a),l=t.getItemSize(a),c=t.getNormalized(a);let p=s[a];(!p||p.array.length<o)&&(p=new B(new A(o),l,c),e.setAttribute(a,p),i=!0);let h=0;for(let e=0,i=Math.min(n.length,t.groupCount);e<i;e++){const i=n[e].index,{array:r,type:s,length:o}=t.groupAttributes[i][a],A=new s(r.buffer,0,o);p.array.set(A,h),h+=A.length}p.needsUpdate=!0,r=o/p.itemSize}if(e.index){const t=e.index.array;if(t.length<r)e.index=null,i=!0;else for(let e=0,n=t.length;e<n;e++)t[e]=e}let a=0;e.clearGroups();for(let i=0,r=Math.min(n.length,t.groupCount);i<r;i++){const{index:r,materialIndex:s}=n[i],o=t.getCount(r);0!==o&&(e.addGroup(a,o,s),a+=o)}e.setDrawRange(0,r),e.boundsTree=null,i&&e.dispose()}(n,o[t],g),l&&function joinGroups(e){for(let t=0;t<e.length-1;t++){const n=e[t],i=e[t+1];if(n.materialIndex===i.materialIndex){const r=n.start,s=i.start+i.count;i.start=r,i.count=s-r,e.splice(t,1),t--}}}(n.groups)})),r?i:i[0]}evaluateHierarchy(e,t=new Brush){e.updateMatrixWorld(!0);const flatTraverse=(e,t)=>{const n=e.children;for(let e=0,i=n.length;e<i;e++){const i=n[e];i.isOperationGroup?flatTraverse(i,t):t(i)}},traverse=e=>{const t=e.children;let n=!1;for(let e=0,i=t.length;e<i;e++){const i=t[e];n=traverse(i)||n}const i=e.isDirty();if(i&&e.markUpdated(),n&&!e.isOperationGroup){let t;return flatTraverse(e,(n=>{t=t?this.evaluate(t,n,n.operation):this.evaluate(e,n,n.operation)})),e._cachedGeometry=t.geometry,e._cachedMaterials=t.material,!0}return n||i};return traverse(e),t.geometry=e._cachedGeometry,t.material=e._cachedMaterials,t}reset(){this.triangleSplitter.reset()}}async function CSG(e,t,n=1){if(0!=n&&1!=n&&3!=n)throw new Error("Wrong CSG Operation");function groupToBrush(e){const t=[];e.updateMatrixWorld(!0),e.traverse((e=>{if(!e.isMesh)return;const n=e.geometry.clone();n.applyMatrix4(e.matrixWorld),t.push(n)}));const n=function mergeGeometries(e,t=!1){const n=null!==e[0].index,i=new Set(Object.keys(e[0].attributes)),r=new Set(Object.keys(e[0].morphAttributes)),s={},o={},a=e[0].morphTargetsRelative,A=new C;let l=0;for(let c=0;c<e.length;++c){const p=e[c];let h=0;if(n!==(null!==p.index))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(const e in p.attributes){if(!i.has(e))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+'. All geometries must have compatible attributes; make sure "'+e+'" attribute exists among all geometries, or in none of them.'),null;void 0===s[e]&&(s[e]=[]),s[e].push(p.attributes[e]),h++}if(h!==i.size)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". Make sure all geometries have the same number of attributes."),null;if(a!==p.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(const e in p.morphAttributes){if(!r.has(e))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". .morphAttributes must be consistent throughout all geometries."),null;void 0===o[e]&&(o[e]=[]),o[e].push(p.morphAttributes[e])}if(t){let e;if(n)e=p.index.count;else{if(void 0===p.attributes.position)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". The geometry must have either an index or a position attribute"),null;e=p.attributes.position.count}A.addGroup(l,e,c),l+=e}}if(n){let t=0;const n=[];for(let i=0;i<e.length;++i){const r=e[i].index;for(let e=0;e<r.count;++e)n.push(r.getX(e)+t);t+=e[i].attributes.position.count}A.setIndex(n)}for(const e in s){const t=mergeAttributes(s[e]);if(!t)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+e+" attribute."),null;A.setAttribute(e,t)}for(const e in o){const t=o[e][0].length;if(0===t)break;A.morphAttributes=A.morphAttributes||{},A.morphAttributes[e]=[];for(let n=0;n<t;++n){const t=[];for(let i=0;i<o[e].length;++i)t.push(o[e][i][n]);const i=mergeAttributes(t);if(!i)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+e+" morphAttribute."),null;A.morphAttributes[e].push(i)}}return A}(t,!1);return new Brush(n)}const i=groupToBrush(e),r=groupToBrush(t);return mergeVertices((new Evaluator).evaluate(i,r,n).geometry.clone(),1e-6)}async function runScript(t,n,i,r,s){let o=await t.getScript(n),a=o.script,A=[],l=function toCadPars(e){const t=muClComments(e),n=[];for(const e of t){const t=e.includes("(")||e.includes("[")?[e]:getcolonne(e,!0);let i=!1;for(const e of t)!e.startsWith('"')&&e.includes("=")?(n.push(e),i=!0):i&&(n[n.length-1]+=","+e)}const i={};for(const e of n){let{v:t,o:n}=getcouple(e,"=",!1);n=n||"",t&&(/^[-+]?\d*\.?\d+$/.test(n)&&(n=parseFloat(n)),i[t]=n)}return i}(o.pars+("string"==typeof r?"\n"+r:""));function setmatricola(e){return e?.userData&&(e.userData.mat=`${n}_${t.gmats[n]}`),e}r&&"object"==typeof r&&(l={...l,...r}),t.gmats[n]||(t.gmats[n]=0);let c=(new Date).valueOf(),p=c;try{function movimento(e,n=[]){return e=clean(e,!0),t.movs[e]||(t.movs[e]=getmovimento(e,n)),t.movs[e]}function addlog(...e){if(t?.islog){const t=e.map((e=>getOggetto(e)));console.log(...t),A.push(...t)}}function addwarning(e="msg",t=""){let n={lev:"w",cod:e,note:t};i.DB&&i.DB.push(n)}function dbadd(e,r,s,o={}){o||(o={}),t.gmats[n]++,"w"==e&&(e="l");let a=`${n}_${t.gmats[n]}`,{qt:A=1,l:l=0,a:c=0,p:p=0,vars:h="",tag:u,info:d,shape:g=null,model:f,lavs:m=null}=o;if(i.DB&&r){let t={lev:"string"==typeof e?clean(e,!0):"l"+(e+(i?._level??0)),mat:a,cod:r,note:s||"",qt:A,l:l,a:c,p:p,vars:h,tag:u,info:d};g&&(t.shape=g),m&&(t.lavs=m),f&&(t.model=f),i.DB.push(t)}return a}function getposfn(e,t){if(!(t.sl||t.sa||t.sp||t.scale||t.scx||t.scy||t.scz||t.ay||t.ax||t.az))return e;return transformfn(e,t)}function addtop(e,t,n={}){n||(n={});let r=getposfn(s,n);i.TOPS.push({key:e,shape:t,type:"top",op:n,posfn:r})}function addhole(e,t,n={}){n||(n={});let r=getposfn(s,n);i.TOPS.push({key:e,shape:t,type:"hole",op:n,posfn:r})}function addaltri(e,t={},n={}){n||(n={}),t={...t,...n};let r=getposfn(s,t);i.TOPS.push({key:e,data:t,type:"altri",posfn:r})}function addlines(e,t,n={}){if(n||(n={}),!t)return;Array.isArray(t)||(t=[t]);let r=getposfn(s,n);i.TOPS.push({key:e,lines:t,type:"lines",op:n,posfn:s,pn:r})}function dbdes(e,t){i.DES&&t&&i.DES.push({lev:e+(i?._level??0),description:t})}function geturltex(e){let n=t.cat;if(!e)return t.P.baseurl+"noimage.jpg";if(t.P._cdn){if(e.includes("/")){let t=e.split("/");n=t[0],e=t[1]}return e.endsWith(".webp")||e.endsWith(".png")||e.endsWith(".jpeg")||e.endsWith(".jpg")||(e+=".webp"),`${t.P._cdn}${n}/textures/${e}`}return t.P.fullget("mufiles/getfile",{id:n,subfolder:"textures",name:e})}l||(l={}),i||(i={});const h={GCAD:!0,...i,...l,THREE:e,TODEG:TODEG,TORAD:TORAD,dbadd:dbadd,addtop:addtop,addwarning:addwarning,addhole:addhole,addlines:addlines,addaltri:addaltri,dbdes:dbdes,posfn:s,ADD:0,SUB:1,INT:3,CSG:CSG,addpivot:(e,n,i={},r=0,s=0,o=0)=>setmatricola(addmovpivot(t,e,n,i,r,s,o)),movimento:movimento,Math:Math,facesettile:facesettile,info3d:t.info3d,round:round,gcad:t,SIDE:xi,seeder:seeder,seedarray:seedarray,baseurl:t.P.baseurl,Vis2d:Vis2d,joinlinestoshapes:joinlinestoshapes,groupfromgeometry:groupfromgeometry,creategroup:creategroup,deletegroup:deletegroup,Matrix3D:Matrix3D,geturltex:geturltex,clamp:clamp,Punto2:Punto2,Linea2:Linea2,getptsoffset:getptsoffset,hash:hash,PIF:ft,raccordabezier:raccordabezier,svuotanodo:svuotanodo,normal2:normal2,angle3point:angle3point,angle2vec:angle2vec,getshape:getshape,shapeclip:shapeclip,mgray1:vi,mgray2:Qi,mwhite:wi,mred:Pi,mgreen:Di,mblack:Li,mblue:Ti,materialline1:Bi,materialline2:Ei,scaleunit:_i,edgesfromgeometry:edgesfromgeometry,getmesh:getmesh,getcolonne:getcolonne,posiziona:posiziona,getbb:getbb,scalaoggetto:(e,n)=>scalaoggetto(t,e,n),setorigine:setorigine,SP:wt,elaborapercorso:elaborapercorso,gettarghetta:(e,n,i)=>gettarghetta(t,e,n,i),getquota:(e,n,i,r,s,o={})=>getquota(t,e,n,i,r,s,o),getsprite:(e,t,n,i,r)=>getsprite(0,e,t,n,i,r),getpunto:(e,n,i,r,s,o)=>getpunto(t,e,n,i,r,s),spritemat:e=>spritemat(t,e),getemitter:getemitter,getreceiver:e=>setmatricola(getreceiver(t,e)),getriferimento:getriferimento,get3dshape:get3dshape,getline:getline,getpoint:getpoint,randombasemat:randombasemat,infocircle:infocircle,intersectcircle:intersectcircle,creagizmo:creagizmo,linea3d:linea3d,texgen:(e,n=256,i={})=>texgen(t,e,n,i),getcilindro:(e,n,i,r,s=wi,o)=>setmatricola(getcilindro(t,e,n,i,r,s,o)),getbox:(e,t,n,i,r)=>setmatricola(getbox(0,e,t,n,i,r)),getsphere:(e,t,n)=>setmatricola(getsphere(0,e,t,n)),replacemats:t.replacemats,getluce:(e,n="#ffffff",i=1)=>getluce(t,e,n,i),getthorus:(e,t,n,i)=>setmatricola(getthorus(0,e,t,n,i)),getcyl:(e,t,n=wi,i)=>setmatricola(getcyl(0,e,t,n,i)),getpannello:(e,n,i,r,s,o,a)=>setmatricola(getpannello(t,e,n,i,r,s,o,a)),getpannello2:(e,n,i,r,s,o)=>setmatricola(getpannello2(t,e,n,i,r,s,o)),getface:(e,n,i,r)=>setmatricola(getface(t,e,n,i,r)),pickvariant:(e,n,i,r,s,o={})=>pickvariant(t,e,n,i,r,s,o),getmarker:(e,n,i,r,s,o={})=>getmarker(t,e,n,i,r,s,o),getglb:e=>setmatricola(t.getglb(e)),get3ds:(e,n=!1)=>setmatricola(t.get3ds(e,n)),getdims:(e,n)=>t.getdims(e,n),hidenodes:(e,n)=>t.hidenodes(e,n),estruso:(e,n,i,r,s,o)=>setmatricola(estruso(t,e,n,i,r,s,o)),getextrude:(e,n,i,r,s)=>setmatricola(getextrude(t,e,n,i,r,s)),estrusopat:(e,n,i,r,s,o)=>setmatricola(estrusopat(t,e,n,i,r,s,o)),infoestrudi:infoestrudi,getfakeshadow:(e,n)=>getfakeshadow(t,e,n),getfakeshadow2:getfakeshadow2,revolve:(e,n,i,r)=>setmatricola(revolve(t,e,n,i,r)),linemat:e=>async function linemat(e,t={}){t||(t={});let n=hash("lm"+JSON.stringify(t));return e.smats[n]||(e.smats[n]=new LineMaterial(t)),e.smats[n]}(t,e),smat:(e,n)=>smat(t,e,n),log:addlog,clean:clean,logtime:e=>{if(t?.islog){let t=(new Date).valueOf();addlog(`time: ${e} => ${t-p}ms / ${t-c}ms`),p=t}}},u=[...Object.keys(h),...Object.keys(mt)],d=[...Object.values(h),...Object.values(mt)],g=`//# sourceURL=${n}\n return (async () => {\n${a}\n })();`;try{let f=hash(n+JSON.stringify(Object.keys(l)));t.cacheFns[f]||(t.cacheFns[f]=new Function(...u,g));const m=t.cacheFns[f];return{res:await m(...d),LOGS:A}}catch(y){let b=await errorescript(`// errore\n async function script() {\n ${a}\n }`,y,n);t?.bus?.errore(b)}}catch(I){let x=I.stack?.toString()||I.message||"";x=x.replaceAll("\n\n","\n"),t?.bus?.errore(x),console.error(I)}}function rectsat(e,t){const n=(e.ang||0)*Math.PI/180,i=(t.ang||0)*Math.PI/180,r=Math.cos(n),s=Math.sin(n),o=Math.cos(i),a=Math.sin(i),A=e.x,l=e.z,c=t.x,p=t.z,h=e.posx||0,u=e.posz||0,d=t.posx||0,g=t.posz||0,f=[[h,u],[h+A*r,u+A*s],[h+A*r-l*s,u+A*s+l*r],[h-l*s,u+l*r]],m=[[d,g],[d+c*o,g+c*a],[d+c*o-p*a,g+c*a+p*o],[d-p*a,g+p*o]],y=[[f[1][0]-f[0][0],f[1][1]-f[0][1]],[f[3][0]-f[0][0],f[3][1]-f[0][1]],[m[1][0]-m[0][0],m[1][1]-m[0][1]],[m[3][0]-m[0][0],m[3][1]-m[0][1]]];for(let e=0;e<4;e++){const t=-y[e][1],n=y[e][0];let i=1/0,r=-1/0,s=1/0,o=-1/0;for(let e=0;e<4;e++){const a=f[e][0]*t+f[e][1]*n,A=m[e][0]*t+m[e][1]*n;a<i&&(i=a),a>r&&(r=a),A<s&&(s=A),A>o&&(o=A)}if(r<s||o<i)return!1}return!0}async function processatop(e,t,n){if(!t)return;let i=[],r=t.getObjectByName("_mtop");if(r)for(;r.children.length>0;)r.remove(r.children[0]);else r=creategroup("_mtop"),t.add(r);for(let e of n)e?.key?.includes("<")&&(e.key=e.key.replace(/<sl>/gi,e?.posfn?.sl??0).replace(/<sa>/gi,e?.posfn?.sa??0).replace(/<sp>/gi,e?.posfn?.sp??0).replace(/<ay>/gi,e?.posfn?.ay??0));let s=new Date;const uk=e=>`${e.key}|${Math.round(((e.ang||0)+180)%180)/5}|${e.pos.y}`;let o=shapeclip();const a=[...new Set(n.filter((e=>"top"==e.type)).map(uk))];let A=[],l=0;for(let t of a){let s=n.filter((e=>"top"==e.type&&uk(e)===t));if(s.length){let t=s[0],a=n.filter((e=>"hole"==e.type&&e.key==t.key)),c=[],p=[],h=[];for(let e of s)c.push(e.shape.clone().rotate(-e.ang).move(e.pos.x,e.pos.z));let u=[];for(let e of a){let t=e.op.ptrif,n=e.op.ptapplica,i=e.shape.dims();t=t?[i.p1,...t]:[i.p1,i.p2],n||(n=i.p1);let r=e.shape.clone().rotate(-e.ang).move(e.pos.x,e.pos.z),s=getshape().frompt(t).rotate(-e.ang).move(e.pos.x,e.pos.z);u.push({pt:s.pt,shape:r,op:e.op,width:i.width,height:i.height}),e.op?.hidden||p.push(r)}let d,g=o.unisci(c,p,h);for(let t of g){let n=s[0],o=t.shape.rebase(-n.ang),a=t.shape.dims(),c=getshape().fromrect(a.width,a.height,a.p1.x,a.p1.y);o.holes=[],o.cuts=[];for(let e of t.holes)o.holes.push(e.rebase(-n.ang,!0,o.origine.x,o.origine.y));const to2dec=e=>Math.round(100*(Number(e)||0))/100;let p=u.map((e=>{let t=getshape().frompt(e.pt),{shape:i}=t.rebase(-n.ang,!0,o.origine.x,o.origine.y);return{op:e.op,pt:i.pt,px:to2dec(i.pt[0].x),py:to2dec(i.pt[0].y),dx:to2dec(e.width),dy:to2dec(e.height)}})),h=p.filter((e=>{for(let t of e.pt)if(c.pointinshape(t))return!0;return!1}));h.forEach((e=>delete e.pt));let g=[];await runScript(e,"_ricalcolatop",{SHAPES:i,BOX:g,DB:A,TOPS:[],_level:800,processatop:{top:o,base:n,lavs:h,idt:l}},{}),l++;for(let e of g)d=posiziona(posiziona(e,{sa:n.pos.y||0,sl:o.origine.x,sp:o.origine.y}),{ay:n.ang}),r.add(d)}}}let c=new Date,p=n.filter((e=>"altri"==e.type)),h=p.filter((e=>e.data?.fuse));p=p.filter((e=>!e.data?.fuse));let u=function dofuse(e){const uk=e=>`${e.key}|${e.pos.y}`,t=[...new Set(e.map(uk))];let n=[];for(let i of t){let t=e.filter((e=>uk(e)==i)),r=new Array(t.length).fill(!1);for(let e=0;e<t.length;e++){if(r[e])continue;let i=[e],s=[];for(r[e]=!0;i.length;){let e=t[i.pop()];s.push(e);for(let n=0;n<t.length;n++){if(r[n])continue;let s=t[n];rectsat({x:e.data?.l||10,z:e.data?.p||10,ang:e.ang,posx:e.pos.x,posz:e.pos.z},{x:e.data?.l||10,z:e.data?.p||10,ang:s.ang,posx:s.pos.x,posz:s.pos.z})&&(r[n]=!0,i.push(n))}}n.push(s)}}return n}(h),d=new Date,g=[],f=await runScript(e,"_ricalcolaaltri",{SHAPES:i,BOX:g,DB:A,TOPS:[],_level:800,processatop:{altri:p,fused:u,idt:l}},{});f>l&&(l=f),l++;for(let e of g)r.add(e);let m=new Date;const uk1=e=>`${e.key}|${e.pos.y}`,y=n.filter((e=>"lines"==e.type)),b=[...new Set(y.map(uk1))];for(let t of b){const n=y.filter((e=>uk1(e)===t)),r=joinlinestoshapes(n);for(let s of r){let r={sh:s,key:t,data:n[0].op||{},idt:l};await runScript(e,"_ricalcolalinee",{SHAPES:i,BOX:g,DB:A,TOPS:[],_level:800,processatop:r,idt:l},{})}l++}for(let e of g)r.add(e);let I=new Date;return console.log("rictop",c-s,d-c,m-d,I-m,"tot",I-s),{DB:A,SHAPES:i}}function dumpscene(e,t={}){const{maxdepth:n=1/0}=t,r3=e=>Math.round(1e3*e)/1e3;function layerMaskToString(e){let t="";for(let n=0;n<32;n++)t=(e&1<<n?"x":"_")+t;return t}function filterUserData(e){if(!e)return{};const t={};for(const n in e){const i=e[n];if(null==i)continue;const r=typeof i;"string"!==r&&"number"!==r&&"boolean"!==r||(t[n]=i)}return t}return function scan(e,t=0){if(!e||t>n)return null;const i={type:e.type,name:e.name||"",layer:layerMaskToString(e.layers?.mask??0),userData:filterUserData(e.userData)};if(e.position&&function sigPos(e){return 0!==e.x||0!==e.y||0!==e.z}(e.position)&&(i.position={x:r3(e.position.x),y:r3(e.position.y),z:r3(e.position.z)}),e.rotation&&function sigRot(e){return 0!==e.x||0!==e.y||0!==e.z}(e.rotation)&&(i.rotation={x:r3(e.rotation.x),y:r3(e.rotation.y),z:r3(e.rotation.z)}),e.scale&&function sigScale(e){return 1!==e.x||1!==e.y||1!==e.z}(e.scale)&&(i.scale={x:r3(e.scale.x),y:r3(e.scale.y),z:r3(e.scale.z)}),e.isMesh&&e.geometry){i.geometry={type:e.geometry.type};const t=e.geometry.parameters;if(t)for(const e in t){const n=t[e];"number"==typeof n&&(i.geometry[e]=r3(n))}}return e.material&&(Array.isArray(e.material)?i.material=e.material.map((e=>e.type||e.name||"Material")):i.material=e.material.type||e.material.name||"Material"),e.children?.length&&(i.children=e.children.map((e=>scan(e,t+1))).filter(Boolean)),i}(e,0)}function neutralize(e,t){const n=e.parent,i=e.position.clone(),r=e.rotation.clone(),s=e.scale.clone();n?.remove(e),e.position.set(0,0,0),e.rotation.set(0,0,0),e.scale.set(1,1,1),e.updateMatrixWorld(!0),t&&t(e),e.position.copy(i),e.rotation.copy(r),e.scale.copy(s),n?.add(e),e.updateMatrixWorld(!0)}function traversehide(e,t,n=!1){e&&t?.length&&function visita(e){if(e.isGroup){if(e.userData?.markkey&&t.includes(e.userData?.markkey))return void(e.visible=n);for(const t of e.children)visita(t)}}(e)}async function processamarker(t){const n=new Map;function trovagenitorerif(e){for(;e&&!e.userData?.rifid;)e=e.parent;return e}neutralize(t,(function traverse(i){if(i.userData?.markerid)n.set(i.userData.markerid,i);else if(i.name?.startsWith("#mk_")){const r=i.name,s=n.get(r);if(!s)return void t.remove(i);{s.updateMatrixWorld(!0),i.updateMatrixWorld(!0);const t=i,n=trovagenitorerif(s)||s,r=trovagenitorerif(t)||t;if(!n||!r)return;n.updateMatrixWorld(!0),r.updateMatrixWorld(!0),t.updateMatrixWorld(!0);let o=s.matrixWorld.clone();const a=t.matrixWorld.clone(),A=r.matrixWorld.clone(),l=s.userData?.origin||0;if(0!==l){let n=function getlap(t){if(!t)return;const n=new e.Box3;t.updateWorldMatrix(!0,!0),function visita(e){if(!(e.userData?.ignoreTraverse||e.userData?.hideable||e.userData?.noingombro||!1===e.visible)){(e.isMesh||e.isLine||e.isLine2)&&n.expandByObject(e);for(const t of e.children)visita(t)}}(t);const i=new e.Vector3;return n.getSize(i),{l:i.x,a:i.y,p:i.z}}(t);if(n){const{l:i,a:r,p:s}=n;let a=0,A=0,c=0;if(l<10)a=1&l?i:0,A=2&l?r:0,c=4&l?s:0;else if(l>100){let e=l-100;const t=e%3,n=Math.floor(e/3)%3,o=Math.floor(e/9);a=0===t?0:1===t?i/2:i,A=0===n?0:1===n?r/2:r,c=0===o?0:1===o?s/2:s}const p=new e.Vector3(a,A,c),h=new e.Vector3(0,0,0).applyMatrix4(t.matrixWorld),u=p.clone().applyMatrix4(t.matrixWorld).sub(h),d=(new e.Vector3).setFromMatrixPosition(o).sub(u);o=(new e.Matrix4).setPosition(d).multiply((new e.Matrix4).extractRotation(o))}}const c=A.clone().invert().multiply(a),p=o.clone().multiply(c.clone().invert()),h=r.parent,u=(h?h.matrixWorld:new e.Matrix4).clone().invert().multiply(p),d=new e.Vector3,g=new e.Quaternion,f=new e.Vector3;if(u.decompose(d,g,f),r.position.copy(d),r.quaternion.copy(g),r.scale.copy(f),r.updateMatrixWorld(!0),s.visible=!1,s.userData.markdel){let e=s.userData.markdel.split(";");e&&e.length&&(traversehide(n.parent,e),traversehide(r,e))}}}for(const e of[...i.children])traverse(e)}))}async function processagruppo(e,t,n){n||(n=t),Object.assign(n.userData,{SHAPES:[],DB:[],TOPS:[]});for(let i of n.userData.INFO.rows)if("fn"==i?.t){let r=creategroup(),s=[];await runScript(e,i.fn,{BOX:s,SHAPES:t.userData.SHAPES,DB:n.userData.DB,TOPS:n.userData.TOPS,_level:n.userData._level},i.pars,i.p2),s.length&&(s.forEach((e=>r.add(e))),Object.keys(i.p2).length&&(r=posiziona(r,i.p2)),t.add(r))}else if(i?.rows&&i.rows.length){let n=creategroup();i.iscad&&(n=posiziona(n,i.cadv)),n.name=i.id,Object.assign(n.userData,{INFO:i,_level:t.userData._level+1});let r=n;n.children[0]&&n.children[0].userData.ismove&&(r=n.children[0]),i.cadv?.move?.annulla||await processagruppo(e,r,n),t.add(n)}}function getalldb(t,n){let i=[],r=[],s=[];return t&&neutralize(t,(function doit(t){t.traverse((t=>{let n=t;if(1==t.children?.length&&t.children[0].userData?.ismove&&(n=t.children[0]),!n.userData?.ismove||!n.userData.move?.annulla){if(t.userData?.DB&&Array.isArray(t.userData.DB)&&i.push(...t.userData.DB),t.userData?.TOPS&&t.userData.TOPS.length){n.updateMatrixWorld(!0);let i=new e.Vector3;n.getWorldPosition(i);let s=new e.Quaternion;n.getWorldQuaternion(s);let o=(new e.Euler).setFromQuaternion(s,"YXZ"),a=e.MathUtils.radToDeg(o.y);for(let n of t.userData.TOPS){let{sl:t=0,sa:s=0,sp:o=0,ay:A=0}=n.posfn||{};if(t||s||o||A){let l=e.MathUtils.degToRad(a),c=Math.cos(l),p=Math.sin(l),h=t*c-o*p,u=-(t*p+o*c),d=new e.Vector3(i.x+h,i.y+s,i.z+u),g=a+A;r.push({...n,pos:d,ang:g})}else r.push({...n,pos:i.clone(),ang:a})}}t.userData?.SHAPES&&Array.isArray(t.userData.SHAPES)&&t.userData.SHAPES.forEach((e=>{let t=e?.tojson();s.push(t)}))}}))})),n&&(n.DB=i,n.TOPS=r,s=s.filter((e=>e.visible)),n.SHAPES=s),{DB:i,TOPS:r,SHAPES:s}}async function evalcustomfunction(e,t,n,i){try{n||(n={}),i||(i={});const r={GCAD:!1,Vis2d:!1,...n,A:e,V:e.vari,amb:e,info3d:async function info3d(t,n=1,i=0,r=0){if(e.gcad)return await e.gcad.info3d(t,n,i,r)},gcad:e.gcad,log:function addlog(...e){const t=e.map((e=>getOggetto(e)));console.log(...t)},Math:Math,getcolonne:getcolonne,clean:clean,SP:wt,seeder:seeder,seedarray:seedarray,Punto2:Punto2,Linea2:Linea2,clamp:clamp,hash:hash,PIF:ft,getshape:getshape,shapeclip:shapeclip,...i},s=[...Object.keys(r),...Object.keys(mt)],o=[...Object.values(r),...Object.values(mt)],a=new Function(...s,`\n try {\n return (async () => {\n ${t}\n })();\n } catch (err) {\n err.stack = '[SCRIPT] ' + err.stack;\n throw err;\n }`);return await a(...o)}catch(e){throw console.error("Errore durante l'esecuzione:",e),e}}function setLineColorMode(e,t){e?(Bi.color.set(16777215),Ei.color.set(16777215)):t?(Bi.color.set(2501422),Ei.color.set(8421504)):(Bi.color.set(6316128),Ei.color.set(8421504)),Bi.needsUpdate=!0,Ei.needsUpdate=!0}export{Linea2,Matrix3D,ft as PIF,Punto2,xi as SIDE,wt as SP,TODEG,TORAD,Vis2d,Vobject,Vscene,addmovpivot,angle2vec,angle3point,mt as blocked,calcolatasks,checkmovedata,clamp,clean,compattadistinta,creagizmo,creategroup,d3dview,deletegroup,dumpscene,dxfbulge,edgesfromgeometry,elaborapercorso,errorescript,estruso,estrusopat,evalcustomfunction,evidenziaColli,exportdxf,extractTextures,facesettile,get3dshape,getOggetto,getalldb,getbb,getbordi,getbox,getcilindro,getcyl,getdettvarstampa,getdumpmacro,getemitter,getextrude,getface,getfakeshadow,getfakeshadow2,getgalleryvariants,getline,getlinesgeom,getluce,getmarker,getmesh,getmovimento,getnodebyid,getpannello,getpannello2,getpoint,getptsoffset,getpunto,getquota,getreceiver,getriferimento,getshape,getsphere,getsprite,getsubrules,gettarghetta,getthorus,groupfromgeometry,hash,infocircle,infoestrudi,intersectcircle,isfn,ismacro,joinlinestoshapes,konvautils,mapvertices,Bi as materialline1,Ei as materialline2,Li as mblack,Ti as mblue,vi as mgray1,Qi as mgray2,Di as mgreen,Pi as mred,wi as mwhite,newgcad,normal2,pickvariant,posiziona,processagruppo,processamarker,processatop,raccordabezier,randombasemat,revolve,ripristinaMaterialiOriginali,round,runScript,salvaMaterialiOriginali,scalaoggetto,_i as scaleunit,seedarray,seeder,setLineColorMode,setorigine,shapeclip,smat,spritemat,svuotanodo,texgen,transformfn,valutagrafica};
|