@splinetool/loader 1.12.87 → 1.12.88

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.
@@ -15,7 +15,7 @@ best distance: ${p.d}`);let g=[p.x,p.y];return g.distance=p.d,g.distance}functio
15
15
  }`}if(n){o=`${!1&&window.location.search.includes("api-dev")?"https://api-dev.spline.design/":"https://apis.spline.design/"}file/${i.proxy.fileId}/external-api/request?uuidexternalapi=${i.proxy.proxyId}`;let u;a!==void 0?u=a:i.method==="POST"&&i.body&&(u=Fl(JSON.parse(i.body),t)),u!==void 0&&(o+=`&data=${encodeURIComponent(u.replace(/(\r\n|\n|\r|\t)/gm,""))}`)}else i.integration?.type==="OpenAI"?r=a:i.method==="POST"&&i.body&&(r=Fl(JSON.parse(i.body),t));let s=await fetch(o,{method:n?"GET":i.method,headers:n?void 0:TI(i),signal:e.signal,body:r});if(!s.ok)throw new Error("status:"+s.status+"_:_"+s.statusText);if(i.integration?.type==="OpenAI"){let l=await s.json();return n&&(l=l.response),{content:l.choices[0].message.content}}else{let l=await s.json();return n&&(l=l.response),l}}var xb=(i,t)=>{if(typeof i=="string"){let e=t.getVariable(i);if(e)return xb(e,t)}return Ui.isBoolean(i)?Ui.getDisplayedValue(i).toLowerCase():Ui.getDisplayedValue(i)},Fl=(i,t)=>i.map((e,r)=>{if("text"in e)return e.text;if("type"in e){if(e.type==="paragraph")return(r>0?`
16
16
  `:"")+Fl(e.children,t);if(e.type==="variable"){let o=t.getVariable(e.variableId);if(o!==void 0)return xb(o,t)}}return""}).join("");var EI=new Ee.Matrix4,NI=new Ee.Matrix4;function DI(i,t,e){let r=[new Ee.Vector3,new Ee.Vector3,new Ee.Vector3],o=[new Ee.Vector3,new Ee.Vector3,new Ee.Vector3];return i.extractBasis(r[0],r[1],r[2]),t.extractBasis(o[0],o[1],o[2]),r.forEach((n,a)=>{let s=o[a],l=Ee.MathUtils.lerp(n.length(),s.length(),e);n.lerp(s,e).setLength(l)}),new Ee.Matrix4().makeBasis(r[0],r[1],r[2])}var bb=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,height:100,depth:1,subdivisions:12,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3},i.parameters),r=Math.abs(e.width),o=Math.abs(e.height??e.width),n=Math.abs(e.depth??0),a=t?.shapeData??rs.create({parameters:{...In,width:typeof In.width=="number"?In.width:100,height:typeof In.height=="number"?In.height:100}}).userData.shape;return{path:i.path??Va.defaultData(),parameters:Object.assign(e,{width:r,height:o,depth:n,extrusion:{...Pu,...e.extrusion}}),shapeData:a}}static build(i){if(i.path.points.length>=2){let e=new Qf(i);return Object.assign(e,{userData:{...i,type:"PathGeometry"}})}else return Object.assign(new Ee.BufferGeometry,{userData:{...i,type:"PathGeometry"}})}},Qf=class extends Ee.BufferGeometry{constructor(e){super();this.type="PathExtrusionGeometry",this.inputs=e,this.build()}_isGeometryClosed(){return this.inputs.path.isClosed&&this.inputs.parameters.extrusion.depth===1}_isOpenEnded(){let e=this.inputs.parameters.extrusion;return!(this.inputs.path.isClosed&&e.depth===1)||!yb(e.twist,0)||e.startScale!==e.endScale}build(){let e=this._extractPathPoints();if(e.length<2)return;let r=this._computeBasisMatrices(e),{depth:o,offset:n}=this.inputs.parameters.extrusion;o=Math.max(0,Math.min(o,1)),n=Math.max(0,Math.min(n,1));let a=this.inputs.path.isClosed?e.length:e.length-1,s=Math.floor(n*a),l=this.inputs.path.isClosed?Math.ceil((o+n)*a):Math.ceil(Math.min(1,o+n)*a),c=Math.min(Math.max(2,l-s+1),a+2),u=[],d=[];for(let j=0;j<c;j++){let F=this.inputs.path.isClosed?(j+s)%e.length:Math.min(j+s,e.length-1);u.push(e[F].clone()),d.push(r[F].clone())}let p=(j,F,H)=>{u[j]=u[j].clone().lerp(u[F],H),d[j]=DI(d[j],d[F],H)},f=0,h=n*a%1;(!this.inputs.path.isClosed||o<=1)&&(h||n===0)&&(f=h,p(0,1,f));let m=0,y=(n+o)*a%1;if((this.inputs.path.isClosed&&o<=1||!this.inputs.path.isClosed&&n+o<1)&&y&&(m=y,p(u.length-1,u.length-2,1-m)),o===0){let j=u.length-1;u[j].copy(u[0]),d[j].copy(d[0])}this._applyPathModifiers(d,f,m);let{bevel:g,bevelSides:b}=this.inputs.parameters.extrusion,w=g>0?this.inputs.parameters.extrusion.capType:"flat",P=5;this.inputs.parameters.extrusion.shape.type==="Custom"&&(P=this.inputs.parameters.extrusion.shape.shapeQuality==="low"?5:12);let{regions:S,infos:T,vertices:A}=this._computeShapePoints(P),x=0,N;w==="round"&&(N=new $i(this.inputs.shapeData,2*g,g,P,b,void 0,!0),x=N.getAttribute("position").count);let E=0,M=0;T.sort((j,F)=>j.start-F.start),T.forEach(j=>{j.verticesStart=E,j.verticesCount=j.continuous.reduce((F,H,W)=>F+(W===0||!H?2:1),0),M+=j.verticesCount,E=M});let D=M*c,_,R=0;if(this._isOpenEnded()&&w==="flat"){try{_=fo({windingRule:Xe.ODD,elementType:Pt.POLYGONS,polySize:3,vertexSize:2,strict:!0,contours:S})}catch{_=Uf}R=_.vertexCount}let V=D+2*R+x*2,U=D+2*R,B={positions:new Float32Array(V*3),normals:new Float32Array(V*3),uvs:new Float32Array(V*2)},q=[];if(T.forEach(j=>{this._extrudeRegion(j,A,d,u,B,q,this._isGeometryClosed()&&!this._isOpenEnded())}),_&&(this._closeEnd(_,D,q,B,d[0],u[0],!1),this._closeEnd(_,D+R,q,B,d[d.length-1],u[u.length-1],!0)),N){B.positions.set(N.getAttribute("position").array,U*3),B.normals.set(N.getAttribute("normal").array,U*3),B.uvs.set(N.getAttribute("uv").array,U*2);for(let W=U;W<U+x;W++)B.uvs[W*2+1]=1e-4;let j=q.length;q.push(...N.getIndex().array.map(W=>W+U)),U+=x,B.positions.set(N.getAttribute("position").array,U*3),B.normals.set(N.getAttribute("normal").array,U*3),B.uvs.set(N.getAttribute("uv").array,U*2);let F=q.length;q.push(...N.getIndex().array.map(W=>W+U)),this.setAttribute("position",new Ee.BufferAttribute(B.positions,3)),this.setAttribute("normal",new Ee.BufferAttribute(B.normals,3)),this.setAttribute("uv",new Ee.BufferAttribute(B.uvs,2)),this.setIndex(q);let H=EI;H.copy(d[d.length-1]).setPosition(u[u.length-1]),this.applyMatrix4OnRange(H,U,V),H.copy(d[0]).setPosition(u[0]).multiply(NI.makeScale(1,1,-1)),this.applyMatrix4OnRange(H,U-x,U),this.reverseIndicesOnRange(j,F)}else this.setAttribute("position",new Ee.BufferAttribute(B.positions,3)),this.setAttribute("normal",new Ee.BufferAttribute(B.normals,3)),this.setAttribute("uv",new Ee.BufferAttribute(B.uvs,2)),this.setIndex(q)}_extractPathPoints(){let e=$u(this.inputs.path),r=this.inputs.path.subdivisions,o=this.inputs.path.subdivisionMode==="uniform"?e.getSpacedPoints(r*4):e.getPoints(r);if(o.length<2)return[];let n=[o[0]];return o.forEach(s=>{n[n.length-1].distanceToSquared(s)>.001&&n.push(s)}),this.inputs.path.isClosed&&n[n.length-1].distanceTo(n[0])<.001&&n.pop(),n}_computeBasisMatrices(e){let r=[],o=e.length,n=this.inputs.path.isClosed,a=new Ee.Vector3,s=new Ee.Vector3,l=new Ee.Vector3,c=new Ee.Vector3,u=new Ee.Vector3(0,1,0);for(let y=0;y<o;y++){let g=e[y],b;y===0?b=n?e[e.length-2]:g.clone().multiplyScalar(2).sub(e[1]):b=e[y-1];let w;y===o-1?w=n?e[1]:g.clone().multiplyScalar(2).sub(e[y-1]):w=e[y+1];let P=g.clone().sub(b).normalize(),S=w.clone().sub(g).normalize(),T=P.clone().add(S).normalize();l.copy(T),y===0&&(T.equals(u)||T.clone().negate().equals(u))&&u.set(0,0,1);let A=u.clone().cross(T).normalize(),x=T.clone().cross(A).normalize();u.copy(x),c.copy(A),y===0&&(a.copy(x),s.copy(T));let N=new Ee.Matrix4().makeBasis(A,x,T);r.push(N)}let d=n?s:l,p=n?a:new Ee.Vector3(0,1,0),f=d.clone().cross(c).normalize(),h=Math.acos(p.dot(f));if(isNaN(h))return r;let m=p.clone().cross(f);d.dot(m)>0&&(h*=-1);for(let y=1;y<r.length;y++){let g=new Ee.Matrix4().makeRotationZ(h*y/r.length);r[y].multiply(g)}return r}_applyPathModifiers(e,r,o){let n=e.length,{angle:a,twist:s,startScale:l,endScale:c}=this.inputs.parameters.extrusion,u=new Ee.Matrix4,d=new Ee.Matrix4;return e.forEach((p,f)=>{let h=f===0?0:f===n-1?1:(f-r)/(n-(o===0?0:1)-(r+(1-o)));u.makeRotationZ(Ee.MathUtils.lerp(a,a+s,h)*Ee.MathUtils.DEG2RAD);let m=Ee.MathUtils.lerp(l,c,h);d.makeScale(m,m,m),p.multiply(u).multiply(d)}),e}_computeShapePoints(e=12,r=Xe.ODD){let o=this.inputs.shapeData,n=o.extractShapePointsToFlatArray([],e),a=o.shapeHoles.map(m=>{let y=m.extractShapePointsToFlatArray([],e),g=[];for(let b=y.length-1;b>=1;b-=2){let w=y[b-1],P=y[b-0];g.push(w,P)}return g}),s;try{s=fo({windingRule:r,elementType:Pt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[n]})}catch{s=Bl}let l;try{l=fo({windingRule:Xe.ODD,elementType:Pt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...a]})}catch{l=jf}if(!s)throw new Error("error generating geometry");let c=s.elementCount;if(l){s.elementCount+=l.elementCount;for(let m=0;m<l.elements.length;m++){let y=l.elements[m],g=m%2===0?s.vertexCount:0;s.elements.push(y+g)}for(let m=0;m<l.vertexIndices.length;m++){let y=l.vertexIndices[m],g=s.vertexCount;s.vertexIndices.push(y+g)}for(let m=0;m<l.vertices.length;m++){let y=l.vertices[m];s.vertices.push(y)}}let u=1/0,d=-1/0,p=1/0,f=-1/0;for(let m=0,y=s.vertexCount;m<y;m++){let g=m*2,b=s.vertices[g+0],w=s.vertices[g+1];b<u&&(u=b),b>d&&(d=b),w<p&&(p=w),w>f&&(f=w)}let h=[];for(let m=s.elementCount-1;m>=0;m--){let y=m>=c,g=m*2,b=s.elements[g+0],w=s.elements[g+1],P=b+w,S={start:b,count:w,normals:[],isHole:y,continuous:[],verticesStart:0,verticesCount:0};h.push(S);let T=b,A=P-1,x=b+1,N=o.roundedCurves.length;do{let E=T-b,M=s.vertices[A*2+0],D=s.vertices[A*2+1],_=s.vertices[T*2+0],R=s.vertices[T*2+1],V=s.vertices[x*2+0],U=s.vertices[x*2+1],B=_-M,q=R-D,j=Math.sqrt(B*B+q*q);B/=j,q/=j;let F=_-V,H=R-U,W=Math.sqrt(F*F+H*H);F/=W,H/=W,S.normals[E*2+0]=-H,S.normals[E*2+1]=F;let ee=s.vertexIndices[T];if(Array.isArray(ee))S.continuous[E]=!1;else{let[te,Y]=o.getCurveIndexFromVertexId(ee-1,!0);if(Y>0&&Y<1)S.continuous[E]=!0;else{let re=Y===1?te+1:te-1;re=(re+N)%N;let K=Y===1?0:1,J=o.roundedCurves[te].getTangent(Y),Q=o.roundedCurves[re].getTangent(K);S.continuous[E]=J.dot(Q)>.95}}y&&(S.normals[E*2+0]*=-1,S.normals[E*2+1]*=-1),[A,T,x]=[T,x,x+1],x>=P&&(x-=w)}while(x!==b+1)}return{regions:[n,...a],infos:h,vertices:s.vertices}}_insertVertex(e,r,o,n,a){let s=r*2,l=r*3;e.positions[l+0]=o.x,e.positions[l+1]=o.y,e.positions[l+2]=o.z,e.normals[l+0]=n.x,e.normals[l+1]=n.y,e.normals[l+2]=n.z,e.uvs[s+0]=a.x,e.uvs[s+1]=a.y}_extrudeRegion(e,r,o,n,a,s,l){let c=new Ee.Vector3,u=new Ee.Vector3,d=new Ee.Vector3,p=new Ee.Vector3,f=new Ee.Vector2;o.forEach((m,y)=>{let g=n[y],b=e.verticesStart*o.length+e.verticesCount*y;for(let w=0;w<e.count;w++){let P=(e.start+w)*2;if(c.set(r[P+0],r[P+1],0),d.copy(c).applyMatrix4(m).add(g),e.continuous[w])p.set(e.normals[w*2+0],e.normals[w*2+1],0);else{let S=w===0?(e.start+e.count-1)*2:P-2;u.set(r[S+0],r[S+1],0),p.copy(c).sub(u),p.set(-p.y,p.x,0),e.isHole||p.negate()}if(p.applyMatrix4(m).normalize(),f.set(w===0?1:w/e.count,y/(o.length-1)),this._insertVertex(a,b,d,p,f),b++,!e.continuous[w]||w===0){if(w===0)p.set(e.normals[w*2+0],e.normals[w*2+1],0),f.set(0,y/(o.length-1));else{let S=w===e.count-1?e.start*2:P+2;u.set(r[S+0],r[S+1],0),p.copy(u).sub(c),p.set(-p.y,p.x,0),e.isHole||p.negate()}p.applyMatrix4(m).normalize(),this._insertVertex(a,b,d,p,f),b++}}});let h=o.length-1;for(let m=0;m<h;m++){let y=e.verticesStart*o.length+e.verticesCount*m,g=e.verticesStart*o.length+e.verticesCount*(m+1),b=0;for(let w=0;w<e.count;w++){(!e.continuous[w]||w===0)&&b++;let P=w===e.count-1?0:b+1,S=y+b,T=y+P,A=g+P,x=g+b;e.isHole?s.push(S,A,T,S,x,A):s.push(S,T,A,S,A,x),b++}}}_closeEnd(e,r,o,n,a,s,l){let c=e.vertexCount,u=new Ee.Vector3(0,0,l?-1:1).applyMatrix4(a),d=new Ee.Vector3,p=new Ee.Vector2;for(let h=0;h<c;h++){let m=2*h;d.set(e.vertices[m+0],e.vertices[m+1],0).applyMatrix4(a).add(s),this._insertVertex(n,r+h,d,u,p)}let f=e.elements;for(let h=0;h<e.elementCount;h++){let m=3*h,y=f[m+0]+r,g=f[m+(l?1:2)]+r,b=f[m+(l?2:1)]+r;o.push(y,g,b)}}applyMatrix4OnRange(e,r,o){let n=e.elements,a=new Ee.Matrix3().getNormalMatrix(e).elements,s,l,c,u,d=this.attributes.position,p=this.attributes.normal;if(!d||!p)return;let f=d.array,h=p.array,m=d.itemSize;for(let y=r*m,g=o*m;y<g;y+=m){if(y===r)debugger;s=f[y+0],l=f[y+1],c=f[y+2],u=1/(n[3]*s+n[7]*l+n[11]*c+n[15]),f[y+0]=(n[0]*s+n[4]*l+n[8]*c+n[12])*u,f[y+1]=(n[1]*s+n[5]*l+n[9]*c+n[13])*u,f[y+2]=(n[2]*s+n[6]*l+n[10]*c+n[14])*u,s=h[y+0],l=h[y+1],c=h[y+2],h[y+0]=a[0]*s+a[3]*l+a[6]*c,h[y+1]=a[1]*s+a[4]*l+a[7]*c,h[y+2]=a[2]*s+a[5]*l+a[8]*c}d.needsUpdate=!0,p.needsUpdate=!0}reverseIndicesOnRange(e,r){let o=this.index;if(o){for(let n=e;n<r;n+=3){let a=o.getX(n),s=o.getX(n+1),l=o.getX(n+2);o.setXYZ(n,l,s,a)}o.needsUpdate=!0}}};var Bn=require("three"),vb=require("three/examples/jsm/utils/BufferGeometryUtils.js");function Sb(){let i=new Bn.BufferGeometry;return i.setAttribute("position",new Bn.BufferAttribute(new Float32Array([]),3)),i.setIndex(new Bn.BufferAttribute(new Uint16Array([]),1)),i}var RI=Sb().attributes,LI=12,BI=1,Vn=class extends Bn.BufferGeometry{constructor(e,r){super();this.charWidths=[];this.charCoords=[];this.wrappedText=[];this.isLowResolution=!1;this.vectorShapes=[];Object.assign(this.attributes,RI),this.userData={parameters:e,type:"TextGeometry"};let o=r.getFont(e.font);o?.isLoaded?(this.font=o,this.update(e,r)):this.updateFont(e.font,r).then(()=>{this.update(e,r),r?.requestRender()})}async updateFont(e,r){let o=r.getFont(e);o&&(this.font=o,await o.loadingPromise)}update(e,r){let o=this.font;if(this.userData={parameters:e,type:"TextGeometry"},!o?.isLoaded){console.warn("Cannot update text because its font is not loaded");return}let{width:n,height:a,depth:s,extrudeBevelSize:l,extrudeBevelSegments:c,text:u,textTransform:d}=e,p=Ui.getDisplayedValue(u),f=d===2?p.toUpperCase():d===3?p.toLowerCase():p,h=VI(e,o,f,r),{shapes:m,charWidths:y,charCoords:g}=o.generateShapes(h,e,r),b=(typeof n=="number"?n:Number(r.getVariable(n)))*.5,w=(typeof a=="number"?a:Number(r.getVariable(a)))*.5,P=m.map(A=>new Ye().fromShape(A,!0));this.vectorShapes=P;let S=P.map(A=>Tr.create({shape:A,parameters:{depth:s,extrudeBevelSegments:c,extrudeBevelSize:l,windingRule:s<=0?Xe.NONZERO:Xe.ODD,subdivisions:this.isLowResolution&&s>0?BI:LI}})),T=S.length?(0,vb.mergeBufferGeometries)(S):Sb();T.translate(-b,w,0),this.dispose(),this.wrappedText=h,this.charCoords=g,this.charWidths=y,this.deleteAttribute("extrudeNormal"),Object.entries(T.attributes).forEach(([A,x])=>{this.setAttribute(A,x)}),this.setIndex(T.index),this.computeBoundingSphere()}clone(){let e=Wt(new Bn.BufferGeometry,Vn.prototype);return e.copy(this),console.log("CloneGeometry",this,e),e}copy(e){return Object.entries(e.attributes).forEach(([r,o])=>{this.setAttribute(r,o)}),this.setIndex(e.index),this.userData={parameters:{...e.userData.parameters},type:"TextGeometry"},this}async setText(e,r){this.font&&await this.font.loadingPromise,await this.update({...this.userData.parameters,text:{textValue:e}},r)}get text(){return this.userData.parameters.text??""}};function VI(i,t,e,r){let o=typeof i.width=="string"?Number(r.getVariable(i.width)):i.width,n=[""],a="";for(let s of e)a+=s,s===" "||s===`
17
17
  `?(n[n.length-1]+=a,a="",s===`
18
- `&&n.push("")):t.getTextWidth(n[n.length-1]+a,i)>o&&(n[n.length-1].length&&n.push(""),t.getTextWidth(n[n.length-1]+a,i)>o&&(a.length===1?(n[n.length-1]+=a,a=""):(n[n.length-1]+=a.slice(0,-1),a=a[a.length-1],n.push(""))));return n[n.length-1]+=a,n}var lt=require("three");var Pb,cd=new Promise(i=>{Pb=i}),wb=!1;var ld;function Ob(i){if(wb)return;if(ld)return ld;async function t(){let r=i??(!1?".":"https://unpkg.com/@splinetool/modelling-wasm@1.12.87/build"),n=import("./process.js"),[a,s]=await Promise.all([n,fetch(`${r}/process.wasm`).then(u=>u.arrayBuffer())]),l=a.default,c=await l({wasmBinary:s});Pb(c),wb=!0}return ld=t(),ld}var Tb=require("three");var zI=["font"];function Go(i,t,e,r){let o,n,a;i.type==="PathGeometry"?(n=JSON.parse(JSON.stringify(i)),a=[[],["extrusion"]]):(n={...i},a=[[]]);for(let c of a){let u=n;for(let d of c)u=u[d];for(o in u){let d=u[o];rf(d)&&!zI.includes(o)&&(u[o]=t.getVariable(d,[r.uuid,"geometry",...c,o]),rf(u[o])&&(u[o]=1))}}let s={parameters:n,type:n.type};if(n.type==="PathGeometry")s.path=n.path;else if(n.type==="VectorGeometry"){let c=Ye.createFromState(n.shape,n.width,n.height);s.shape=c}else if(n.type==="NonParametricGeometry"){if(n.data.groups&&n.data.groups?.forEach(c=>c.materialIndex=Math.max(c.materialIndex??0,0)),s.geometry=new Tb.BufferGeometryLoader().parse(n),s.geometry.groups.length===0){let c=s.geometry;c.addGroup(0,Math.max(c.getIndex()?.count??0,c.getAttribute("position").count),0)}}else if(n.type==="SubdivGeometry"){let c=new zt(n,e);return c.data=i,c}else{if(n.type==="TextGeometry")return new Vn(n,t);if(n.type==="InputGeometry")return new Vn(n,t);if(n.type==="UIGeometry")return ns.create({parameters:{width:n.width,height:n.height,cornerRadius:n.cornerRadius,cornerType:n.cornerType}})}let l;try{l=Zf(s)}catch(c){console.error(c),console.error(`Error generating geometry with inputs: ${s}`);let u=Ye.createFromState(Ba.defaultData(),100,100);s.shape=u,s.type="VectorGeometry",l=Zf(s)}return l}var Cb=require("three"),GI=new Cb.Matrix4;function jl(i,t,e,r){let o=i.position.array,n=i.normal.array,a=GI.makeScale(t,e,r).invert().elements,s,l,c;for(var u=0,d=o.length;u<d;u+=3)o[u]*=t,o[u+1]*=e,o[u+2]*=r,s=n[u],l=n[u+1],c=n[u+2],n[u]=a[0]*s+a[4]*l+a[8]*c,n[u+1]=a[1]*s+a[5]*l+a[9]*c,n[u+2]=a[2]*s+a[6]*l+a[10]*c;i.position.needsUpdate=!0,i.normal.needsUpdate=!0}var ud=new lt.Box3,ss=new lt.Vector3,Oe;cd.then(i=>{Oe=i});var Ab=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),Mb=new Uint32Array([0,1,2,3]),Ib=new Uint8Array([4]),zt=class extends lt.BufferGeometry{constructor(e,r){super();this.data=e;this.flatShading=r;this.subdivPointer=0;this.rebuild(),this.freeSubdivPointer()}mutateDirectlyScaleBaked(e,r){this.freeSubdivPointer();let o=this.data.scaleBaked.map(l=>typeof l=="number"?l:1),n=Bi.div(r.map(l=>typeof l=="number"?l:0),o);if(n.every(l=>l===1))return;this.subdividedGeometry&&jl(this.subdividedGeometry.attributes,...n),this.originalGeometry&&jl(this.originalGeometry.attributes,...n),this.data=e;let a=this.userData.parameters;this.userData.parameters={width:a.width*n[0],height:a.height*n[1],depth:a.depth*n[2]},this.originalGeometry.boundingSphere.center.multiply(ss.fromArray(n));let s=ss.set(a.width,a.height,a.depth).length();this.originalGeometry.boundingSphere.radius=s/2}ensureSubdivPointer(){return this.subdivPointer===0&&this.rebuild(),this.subdivPointer}rebuild(){let e,r,o;try{({originalGeometry:e,subdividedGeometry:r,subdivPointer:o}=zt.build(this.data,void 0,!this.flatShading,void 0))}catch{e=new lt.BoxGeometry(100,100,100),o=0}this.subdivPointer=o,this.originalGeometry=e,this.subdividedGeometry=r??void 0;let n=this.subdividedGeometry??this.originalGeometry;Object.assign(this,n),this.calcBoundingBox()}freeSubdivPointer(){this.subdivPointer&&(zt.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new lt.Sphere,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let r=e.attributes.position,o=e.boundingSphere.center;ud.setFromBufferAttribute(r),ud.getCenter(o),e.boundingSphere.radius=o.distanceTo(ud.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),ud.getSize(ss);let n={width:ss.x,height:ss.y,depth:ss.z};return this.userData.parameters=n,n}static build(e,r,o,n){let a,s,l,c=e?.phongAngle??35;o===!1&&(c=-1),r&&(Oe.free_bvh(r),Oe.free_subdivision_surface(r));try{a=zt.allocate(e,n)}catch(u){console.error(u,e),a=zt.allocate({positionWASM:Ab,indexWASM:Mb,verticesPerFaceWASM:Ib},n)}if(Oe.set_destination_refinement_level(a,0),s=zt.buildLevel(a,!0,c),e.subdivisions>0)try{Oe.set_destination_refinement_level(a,e.subdivisions),l=zt.buildLevel(a,!1,c)}catch{try{Oe.set_destination_refinement_level(a,e.subdivisions-1),l=zt.buildLevel(a,!1,c)}catch{l=null}}else l=null;return{subdivPointer:a,originalGeometry:s,subdividedGeometry:l}}static primitiveToQuads(e,r,o){e.widthSegments>16&&(e.widthSegments=16),e.heightSegments>16&&(e.heightSegments=16),e.depthSegments>16&&(e.depthSegments=16),e.radialSegments>16&&(e.radialSegments=16),e.type==="DodecahedronGeometry"&&(e.detail=0);let n=e.shape!==void 0||e.path!==void 0?r.geometry:Go(e,o,!1,r),a;e.type==="TorusGeometry"&&e.arc===Math.PI*2?a=n.getClosedTorusIndicesForBooleanOrSubdiv():a=n.getIndex();let s,l,c,u;({positions:s,triIndices:u}=rh(n.getAttribute("position"),a));let d;if(e.type==="CylinderGeometry"&&e.cornerRadius===0&&e.hollow===0&&e.openEnded===!1){let p=e.radialSegments*e.heightSegments*3*2,f=p+e.radialSegments*3;d=[p,f]}return{indices:l,verticesPerFace:c}=oh(s,u,n,d),{positions:s,indices:l,verticesPerFace:c}}static allocate(e,r){let o,n,a,s=[],l=[];e.positionWASM&&e.positionWASM.length>0?(o=e.positionWASM,n=e.indexWASM,a=e.verticesPerFaceWASM):(o=Ab,n=Mb,a=Ib);let c=o.length,u=n.length,d=a.length,p=o.length+s.length+l.length,f=n.length+a.length,h=p*Float32Array.BYTES_PER_ELEMENT+f*Uint32Array.BYTES_PER_ELEMENT,m=p*Float32Array.BYTES_PER_ELEMENT,y=Oe._malloc(h),g=new Float32Array(Oe.HEAPF32.buffer,y,p),b=new Uint32Array(Oe.HEAPU32.buffer,y+m,f);g.set(o,0),g.set(s,o.length),g.set(l,o.length+s.length),b.set(n,0),b.set(a,n.length);let w;e?.scaleBaked?.some(S=>S!==1)&&(w=new lt.Matrix4().makeScale(...e.scaleBaked.map(S=>typeof S=="number"?S:1))),r&&(w?w.premultiply(r):w=r);let P=w?Oe.alloc_subdivision_surface2(y,c,y+m,u,y+m+n.length*Uint32Array.BYTES_PER_ELEMENT,d,w.elements):Oe.alloc_subdivision_surface(y,c,y+m,u,y+m+n.length*Uint32Array.BYTES_PER_ELEMENT,d);return Oe._free(y),P}static buildLevel(e,r,o,n,a){let s=a?Oe.get_mesh_data2(e,r?Oe.Level.CONTROL:Oe.Level.REFINED,o,a.elements):Oe.get_mesh_data(e,r?Oe.Level.CONTROL:Oe.Level.REFINED,o),l=8,c=Oe.HEAPU32.subarray(s>>2,(s>>2)+l),u=c.subarray(4,4+4),d=0,p=Oe.HEAPU32[c[d]>>2],f=Oe.HEAPF32.subarray(p>>2,(p>>2)+u[d]);d++;let h=Oe.HEAPU32[c[d]>>2],m=Oe.HEAPF32.subarray(h>>2,(h>>2)+u[d]);d++;let y=Oe.HEAPU32[c[d]>>2],g=Oe.HEAPU32.subarray(y>>2,(y>>2)+u[d]);d++;let b=Oe.HEAPU32[c[d]>>2],w=Oe.HEAPU32.subarray(b>>2,(b>>2)+u[d]);if(d++,n===void 0){let P=new lt.BufferGeometry;if(P.setIndex(new lt.Uint32BufferAttribute(w,1)),P.setAttribute("position",new lt.Float32BufferAttribute(f,3)),P.setAttribute("normal",new lt.Float32BufferAttribute(m,3)),r){P.setAttribute("faceMap",new lt.Uint32BufferAttribute(g,1));let S=new Float32Array(m.length/3*4).fill(0);P.setAttribute("color",new lt.BufferAttribute(S,4))}return Oe.free_mesh_data(s),P.userData.type="SubdivGeometry",P}n.getAttribute("position").copyArray(f),n.getAttribute("normal").copyArray(m),n.attributes.position.needsUpdate=!0,n.attributes.normal.needsUpdate=!0,Oe.free_mesh_data(s)}static freeSubdivPointer(e){Oe.free_bvh(e),Oe.free_subdivision_surface(e)}static buildControlCageWireframe(e,r,o){let n=Oe.get_wireframe_data_for_base_level(e),a=4,s=Oe.HEAPU32.subarray(n>>2,(n>>2)+a),l=s.subarray(2,2+2),c=0,u=Oe.HEAPU32[s[c]>>2],d=Oe.HEAPF32.subarray(u>>2,(u>>2)+l[c]);c++;let p=Oe.HEAPU32[s[c]>>2],f=Oe.HEAPU32.subarray(p>>2,(p>>2)+l[c]);if(r===void 0){let h=new lt.BufferGeometry;h.setAttribute("position",new lt.Float32BufferAttribute(d,3));let m=new Float32Array(d.length);for(let y=0,g=d.length;y<g;)m[y++]=o.r,m[y++]=o.g,m[y++]=o.b;return h.setAttribute("color",new lt.BufferAttribute(m,3)),h.setIndex(new lt.Uint32BufferAttribute(f,1)),Oe.free_wireframe_data_for_base_level(n),h}r.getAttribute("position").copyArray(d),r.attributes.position.needsUpdate=!0,Oe.free_wireframe_data_for_base_level(n)}static updateCollabMesh(e,r,o){let n=r===0;n||Oe.set_destination_refinement_level(e,r);let a=o?Oe.get_topological_data2(e,n?Oe.Level.CONTROL:Oe.Level.REFINED,o.elements):Oe.get_topological_data(e,n?Oe.Level.CONTROL:Oe.Level.REFINED),s=6,l=Oe.HEAPU32.subarray(a>>2,(a>>2)+s),c=l.subarray(3,3+3),u=0,d=Oe.HEAPU32[l[u]>>2],p=new Float32Array(Oe.HEAPF32.subarray(d>>2,(d>>2)+c[u]));u++;let f=Oe.HEAPU32[l[u]>>2],h=new Uint32Array(Oe.HEAPU32.subarray(f>>2,(f>>2)+c[u]));u++;let m=Oe.HEAPU32[l[u]>>2],y=new Uint8Array(Oe.HEAPU32.subarray(m>>2,(m>>2)+c[u]));return Oe.free_topological_data(a),{positions:p,indices:h,verticesPerFace:y}}};var Eb=["getX","getY","getZ"];function rh(i,t){let e={},r=t?t.count:i.count,o=0,n=[],a=[],s=1e4;for(let c=0;c<r;c++){let u=t?t.getX(c):c,d="";for(let p=0;p<3;p++)d+=`${~~(i[Eb[p]](u)*s)},`;if(d in e)n.push(e[d]);else{for(let p=0;p<3;p++)a.push(i[Eb[p]](u));e[d]=o,n.push(o),o++}}let l=[];for(let c=0;c<n.length;c+=3)n[c]===n[c+1]||n[c]===n[c+2]||n[c+1]===n[c+2]||l.push(n[c],n[c+1],n[c+2]);return{positions:a,triIndices:l}}var dd=new lt.Vector3,Jf=new lt.Vector3,eh=new lt.Vector3,th=new lt.Vector3;function oh(i,t,e,r){let o=[],n=[];if(e.userData.shape!==void 0&&e.userData.parameters.depth===0&&e.userData.shape.shapeHoles.length===0){let l=e.userData.shape.extractShapePointsToFlatArray([]),c=e.userData.parameters.spikes;if(e.userData.type==="EllipseGeometry"&&c<=24&&c%4===0&&e.userData.parameters.angle>=360){let p=l.length/2/c;l=l.filter((f,h)=>Math.floor(h/2)%p===0)}let u=0;for(let p=0;p<l.length;p+=2)u+=(l[p]-l[(p===0?l.length:p)-2])*(l[p+1]+l[(p===0?l.length:p)-1]);i.length=0;let d=0;if(u<0)for(let p=0;p<l.length;p+=2)i.push(l[p],l[p+1],0),o.push(d++);else for(let p=l.length-2;p>=0;p-=2)i.push(l[p],l[p+1],0),o.push(d++);return n.push(d),{indices:o,verticesPerFace:n}}let a=new Float32Array([e.userData.parameters.depth])[0],s=0;for(;s<t.length;){if(e.useNgonForTopBottomFaceDuringBake){let l=0;if((i[t[s]*3+2]===a||i[t[s]*3+2]===0)&&l++,(i[t[s+1]*3+2]===a||i[t[s+1]*3+2]===0)&&l++,(i[t[s+2]*3+2]===a||i[t[s+2]*3+2]===0)&&l++,l===3)break}if(t[s+1]===t[s+3]&&t[s+2]===t[s+5]||t[s+0]===t[s+3]&&t[s+2]===t[s+4]){dd.set(i[t[s]*3],i[t[s]*3+1],i[t[s]*3+2]),Jf.set(i[t[s+1]*3],i[t[s+1]*3+1],i[t[s+1]*3+2]),eh.set(i[t[s+4]*3],i[t[s+4]*3+1],i[t[s+4]*3+2]),th.set(i[t[s+5]*3],i[t[s+5]*3+1],i[t[s+5]*3+2]),Jf.sub(dd).normalize(),eh.sub(dd).normalize(),th.sub(dd).normalize();let l=Jf.cross(eh).dot(th),c=s;Math.abs(l)>.005||r&&r.some((u,d)=>d%2===1?!1:c>=r[d]&&c<r[d+1])?(o.push(t[s],t[s+1],t[s+2]),n.push(3),s+=3):(o.push(t[s],t[s+1],t[s+4],t[s+5]),n.push(4),s+=6)}else o.push(t[s],t[s+1],t[s+2]),n.push(3),s+=3}if(e.useNgonForTopBottomFaceDuringBake){let l=[],c=[],u=0;for(let d=0,p=0;d<i.length;d+=3,p++)i[d+2]===0&&(l.push(p),u++),i[d+2]===a&&c.push(p);if(e.userData.parameters.extrudeBevelSize===0){let d=c[0];c[0]=c[1],c[1]=d}l.reverse(),o.push(...l,...c),n.push(u,u)}return{indices:o,verticesPerFace:n}}var Xr={};xm(Xr,{calcBoolean:()=>kI,calcBooleanTopological:()=>UI,freeMeshSet:()=>$I,getMeshSet:()=>HI,hasOpenEdges:()=>WI,transformMeshSet:()=>qI});var FI,Nb=new Promise(i=>{FI=i});var Ul=require("three");var ke,ls;Nb.then(i=>ke=i);function jI(i,t,e){let r,o;i.userData.parameters.type==="TorusGeometry"&&i.userData.parameters.arc===Math.PI*2?o=i.getClosedTorusIndicesForBooleanOrSubdiv():o=i.getIndex();let{positions:n,triIndices:a}=rh(i.getAttribute("position"),o),s;if(t&&e){let{indices:l,verticesPerFace:c}=oh(n,a,i);s=c.length,r=[];for(let u=0,d=0;u<s;u++){r.push(c[u]);for(let p=0;p<c[u];p++)r.push(l[d++])}}else{let l=a.length;r=Array(l+l/3),s=0;for(let c=0,u=0;u<r.length;)r[u++]=3,s++,r[u++]=a[c++],r[u++]=a[c++],r[u++]=a[c++]}return{positions:n,faceIndices:r,nFaces:s}}function Db(i){let t=i.length,e=t*Uint32Array.BYTES_PER_ELEMENT,r=t*Float32Array.BYTES_PER_ELEMENT,o=Number.isInteger(i[0])?e:r,n=ke._malloc(o);return(Number.isInteger(i[0])?new Uint32Array(ke.HEAPU32.buffer,n,t):new Float32Array(ke.HEAPF32.buffer,n,t)).set(i,0),n}function _b(i){switch(i){case 0:return ke.OP.UNION;case 1:return ke.OP.INTERSECTION;case 2:return ke.OP.A_MINUS_B;default:throw new Error("Unknown boolean operation "+i)}}function UI(i,t){ls===void 0&&(ls=ke.init_csg());let e=Db(i),r=ke.csg_calc_topological(ls,e,i.length,_b(t));ke._free(e);let o=6,n=ke.HEAPU32.subarray(r>>2,(r>>2)+o),a=n.subarray(3,3+3),s=0,l=ke.HEAPU32[n[s]>>2],c=new Float32Array(ke.HEAPF32.subarray(l>>2,(l>>2)+a[s]));s++;let u=ke.HEAPU32[n[s]>>2],d=new Uint32Array(ke.HEAPU32.subarray(u>>2,(u>>2)+a[s]));s++;let p=ke.HEAPU32[n[s]>>2],f=new Uint8Array(ke.HEAPU32.subarray(p>>2,(p>>2)+a[s]));return ke.free_mesh_data(r),{positions:c,indices:d,verticesPerFace:f}}function kI(i,t,e,r){ls===void 0&&(ls=ke.init_csg());let o=Db(i),n=ke.csg_calc(ls,o,i.length,r,_b(t));ke._free(o);let a=5,s=ke.HEAPU32.subarray(n>>2,(n>>2)+a),l=s.subarray(2,2+3),c=0,u=ke.HEAPU32[s[c]>>2],d=ke.HEAPF32.subarray(u>>2,(u>>2)+l[c]);c++;let p=ke.HEAPU32[s[c]>>2],f=ke.HEAPF32.subarray(p>>2,(p>>2)+l[c]);c++;let h=l[c];e.setAttribute("position",new Ul.Float32BufferAttribute(d,3)),e.setAttribute("normal",new Ul.Float32BufferAttribute(f,3));let m=ke.HEAPF32.subarray((n>>2)+5,(n>>2)+5+6);return e.boundingSphere===null&&(e.boundingSphere=new Ul.Sphere),e.boundingSphere.center.set(m[0],m[1],m[2]),e.boundingSphere.radius=(m[3]**2+m[4]**2+m[5]**2)**.5,e.userData.parameters={width:m[3]*2,height:m[4]*2,depth:m[5]*2},ke.free_mesh_data(n),h}function HI(i,t,e){if(ke===void 0)return-1;let r,o,n;if(t&&i.userData.positions!==void 0){let g=i.userData;n=g.verticesPerFace.length,r=g.positions,o=Array(g.verticesPerFace.reduce((b,w)=>b+w,0)+n);for(let b=0,w=0,P=0;b<g.verticesPerFace.length;b++){o[P++]=g.verticesPerFace[b];for(let S=0;S<g.verticesPerFace[b];S++)o[P++]=g.indices[w++]}}else({positions:r,faceIndices:o,nFaces:n}=jI(i,t,e));let a=r.length,s=o.length,l=r.length,c=o.length,u=l*Float32Array.BYTES_PER_ELEMENT+c*Uint32Array.BYTES_PER_ELEMENT,d=l*Float32Array.BYTES_PER_ELEMENT,p=c*Uint32Array.BYTES_PER_ELEMENT,f=ke._malloc(u),h=new Float32Array(ke.HEAPF32.buffer,f,l),m=new Uint32Array(ke.HEAPU32.buffer,f+d,c);h.set(r,0),m.set(o,0);let y=ke.get_csg_mesh(f,a,f+d,s,n);return ke._free(f),y}function WI(i){return ke.has_open_edges(i)}function qI(i,t){ke.transform_csg_mesh(i,t.elements)}function $I(i){ke.free_csg_mesh(i)}var XI={ConeGeometry:Px,CubeGeometry:Ox,CylinderGeometry:wx,DodecahedronGeometry:Cx,EllipseGeometry:rs,HelixGeometry:Qx,IcosahedronGeometry:Jx,LatheGeometry:eb,NonParametricGeometry:ib,PolygonGeometry:nd,PyramidGeometry:nb,RectangleGeometry:ns,SphereGeometry:ab,PlaneGeometry:lb,BackdropGeometry:cb,StarGeometry:ad,TextFrameGeometry:db,TorusGeometry:pb,TorusKnotGeometry:hb,TriangleGeometry:mb,PathGeometry:bb,VectorGeometry:Tr},Zf=i=>XI[i.type].create(i);function cs(i){return i!==null&&"booleanOp"in i}var us=class extends Xa(pd.Mesh){constructor(){super(...arguments);this.booleanMeshSetAddress=-1;this.booleanWasTransformed=!1;this.booleanMatrixInvOld=new pd.Matrix4}updateVisible(e){super.updateVisible(e),this.visible=!cs(this.parent)&&this.visible,cs(this.parent)&&this.parent.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(Xr.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(e=!1){return e?this.booleanWasTransformed=!0:this.freeBooleanPointer(),cs(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)e instanceof us&&(e.freeBooleanPointer(),cs(e)&&e.invalidateUpstreamBooleanData())}updateTransformState(e,r){let o=super.updateTransformState(e,r);return o&&cs(this.parent)&&this.invalidateDownstreamBooleanData(!0),o}onVariableUpdate(e=!1){super.onVariableUpdate(e),cs(this.parent)&&this.invalidateDownstreamBooleanData(!0)}};var fd=new ds.Box3;function kl(i,t=0,e=i.count,r,o){let n=1/0,a=1/0,s=1/0,l=-1/0,c=-1/0,u=-1/0;for(let d=t;d<e;d++){let p=i.getX(d),f=i.getY(d),h=i.getZ(d);p<n&&(n=p),f<a&&(a=f),h<s&&(s=h),p>l&&(l=p),f>c&&(c=f),h>u&&(u=h)}fd.min.set(n,a,s),fd.max.set(l,c,u),fd.getCenter(r),fd.getSize(o).multiplyScalar(.5)}var YI=new ds.BufferGeometry,KI=new ds.MeshBasicMaterial,$t=class extends us{constructor(t,e){super(YI,KI),this.super_Entity(t,e)}updateState(t,e){this.updateState_Entity(t,e)}updateEntityBoxSize(t,e){let r=this.geometry.getAttribute("position");r!==void 0?kl(r,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:r.count,t,e):super.updateEntityBoxSize(t,e)}};var vi=require("three");var Gr=require("three");var Ad=require("three");var mi=class{constructor(t){this.hashProperties=void 0;this.isNode=!0;this.shortcuts={};if(mi.uuidContext===null)throw new Error("plz startContext");mi.uuidContext===mi.globalContext?this.uuid="_gid"+mi.uuidContext.nodeContextUuid++:this.uuid="_uid"+mi.uuidContext.nodeContextUuid++,this.type=t,this.name=""}static startContext(t){this.uuidContext===null||this.uuidContext===mi.globalContext?this.uuidContext=t:console.error("Can't start context twice")}static endContext(t){this.uuidContext!==t&&console.error("Can't end context twice"),this.uuidContext=null}analyze(t,e){e=e??{},t.analyzing=!0,this.build(t.addFlow(e.slot,e.cache,e.context),"v4"),t.clearVertexNodeCode(),t.clearFragmentNodeCode(),t.removeFlow(),t.analyzing=!1}analyzeAndFlow(t,e,r){return r=r??{},this.analyze(t,r),this.flow(t,e,r)}flow(t,e,r){r=r??{},t.addFlow(r.slot,r.cache,r.context);let o={result:this.build(t,e),code:t.clearNodeCode(),extra:t.context.extra};return t.removeFlow(),o}build(t,e,r){e=e??this.getType(t,e);let o=t.getNodeData(r??this);return t.analyzing&&this.appendDepsNode(t,o,e),t.nodes.indexOf(this)===-1&&t.nodes.push(this),this.updateFrame!==void 0&&t.updaters.indexOf(this)===-1&&t.updaters.push(this),this.generate(t,e,r)}updateFrame(t){}generateReadonly(t,e,r,o,n,a){return""}generate(t,e,r,o,n){return""}parse(t,e,r,o){}appendDepsNode(t,e,r){e.deps=(e.deps||0)+1;let o=t.getTypeLength(r);(o>(e.outputMax||0)||this.getType(t,r))&&(e.outputMax=o,e.output=r)}setName(t){this.name=t}getName(){return this.name}getType(t,e){return e==="sampler2D"||e==="samplerCube"?e:this.type}},ot=mi;ot.globalContext={nodeContextUuid:0},ot.uuidContext=mi.globalContext;var xo=require("three");var Hl=class{constructor(t){t=t??{},this.name=t.name,this.type=t.type,this.node=t.node,this.size=t.size,this.needsUpdate=t.needsUpdate}get value(){return this.node.value}set value(t){this.node.value=t}};var ih=class{constructor(){this.nodes={};this.keywords={}}add(t){this.nodes[t.name]=t}addKeyword(t,e,r){r=r!==void 0?r:!0,this.keywords[t]={callback:e,cache:r}}remove(t){delete this.nodes[t.name]}removeKeyword(t){delete this.keywords[t]}get(t){return this.nodes[t]}getKeyword(t,e){return this.keywords[t].callback(e)}getKeywordData(t){return this.keywords[t]}contains(t){return this.nodes[t]!==void 0}containsKeyword(t){return this.keywords[t]!==void 0}},Xt=new ih;var nh=require("three");var Rb=require("three"),be=class extends ot{constructor(e,r){super(e);this.scope="";r=r??{},this.shared=r.shared!==void 0?r.shared:!0,this.unique=r.unique!==void 0?r.unique:!1}build(e,r,o,n){if(r=r??this.getType(e),this.getShared(e,r)){let a=this.getUnique(e,r);a&&this.uuid===void 0&&(this.uuid=Rb.MathUtils.generateUUID()),o=e.getUUID(o??this.getUUID(),!a);let s=e.getNodeData(o),l=s.output||this.getType(e);if(e.analyzing)return(s.deps||0)>0||this.getLabel()?(this.appendDepsNode(e,s,r),this.generate(e,r,o)):super.build(e,r,o);if(a)return s.name=s.name||super.build(e,r,o),s.name;if(!this.getLabel()&&(!this.getShared(e,l)||e.context.ignoreCache||s.deps===1))return super.build(e,r,o);o=this.getUUID(!1);let c=this.getTemp(e,o);if(c)return e.format(c,l,r);{c=super.generate(e,r,o,s.output,n);let u=this.generate(e,l,o);return e.addNodeCode(c+" = "+u+";"),e.format(c,l,r)}}return super.build(e,r,o)}getShared(e,r){return r!=="sampler2D"&&r!=="samplerCube"&&this.shared}getUnique(e,r){return this.unique}setLabel(e){return this.label=e,this}getLabel(){return this.label}getUUID(e){let r=this.uuid;return typeof this.scope=="string"&&(r=this.scope+"-"+r),r}getTemp(e,r){r=r||this.uuid;let o=e.getVars()[r];return o?o.name:void 0}generate(e,r,o,n,a){return this.getShared(e,r)||console.error("TempNode is not shared"),o=o??this.uuid,e.getTempVar(o,n??this.getType(e),a,this.getLabel()).name}};var it=class extends be{constructor(e,r){r=r??{},r.shared=r.shared!==void 0?r.shared:!1;super(e,r);this.readonly=!1}setReadonly(e){return this.readonly=e,this.hashProperties=this.readonly?["value"]:void 0,this}getReadonly(){return this.readonly}generate(e,r,o,n,a,s){o=e.getUUID(o??this.getUUID()),n=n??this.getType(e);let l=e.getNodeData(o);return this.getReadonly()&&this.generateReadonly!==void 0?this.generateReadonly(e,r,o,n,a,s):e.isShader("vertex")?(l.vertex||(l.vertex=e.createVertexUniform(n,this,a,s,this.getLabel())),e.format(l.vertex.name,n,r)):(l.fragment||(l.fragment=e.createFragmentUniform(n,this,a,s,this.getLabel())),e.format(l.fragment.name,n,r))}};var Ot=class extends it{constructor(e=0,r){super("v2");this.nodeType="Vector2";this.value=e instanceof nh.Vector2?e:new nh.Vector2(e,r)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}generateReadonly(e,r,o,n,a,s){return e.format("vec2("+this.value.x+", "+this.value.y+")",n,r)}};var ah=require("three");var ar=class extends it{constructor(e=0,r,o){super("v3");this.nodeType="Vector3";this.value=e instanceof ah.Vector3?e:new ah.Vector3(e,r,o)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}get z(){return this.value.z}set z(e){this.value.z=e}generateReadonly(e,r,o,n,a,s){return e.format("vec3("+this.value.x+", "+this.value.y+", "+this.value.z+")",n,r)}};var Lb=require("three"),Yt=class extends Lb.Color{constructor(e,r,o,n){super(e,r,o);this.isColorA=!0;this.a=n}setRGBA(e,r,o,n){super.setRGB(e,r,o),this.a=n}copy(e){return super.copy(e),this.a="a"in e?e.a:1,this}clone(){return new this.constructor(this.r,this.g,this.b,this.a)}equals(e){return super.equals(e)&&this.a===e.a}setStyle(e,r="srgb"){let o;if(e==="transparent")return this.setRGBA(0,0,0,0),this;if(o=/^((?:rgb|hsl)a?)\(([^)]*)\)/.exec(e)){let n,a=o[1],s=o[2];switch(a){case"rgb":case"rgba":if(n=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return this.a=a==="rgba"?parseFloat(n[4]):1,super.setStyle(e,r);break;case"hsl":case"hsla":if(n=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)%\s*,\s*(\d*\.?\d+)%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return this.a=a==="hsla"?parseFloat(n[4]):1,super.setStyle(e,r);break}}return super.setStyle(e,r)}get x(){return this.r}get y(){return this.g}get z(){return this.b}get w(){return this.a}set x(e){this.r=e}set y(e){this.g=e}set z(e){this.b=e}set w(e){this.a=e}};var Cr=class extends it{constructor(e){super("v4");this.nodeType="Vector4";this.value=e instanceof Yt?e:new Yt(e.r,e.g,e.b,e.a)}generateReadonly(e,r,o,n,a,s){return e.format("vec4("+this.value.r+", "+this.value.g+", "+this.value.b+", "+this.value.a+")",n,r)}};var QI=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,Bb=/[a-z_0-9]+/gi,Z=class extends be{constructor(e,r,o,n,a){super(a);this.src="";this.nodeType="Function";this.useKeywords=!0;this.includes=[];this.extensions={};this.keywords={};this.isMethod=a===void 0,this.isInterface=!1,this.parse(e,r,o,n)}getShared(e,r){return!this.isMethod}getType(e){return e.getTypeByFormat(this.type)}getInputByName(e){if(this.inputs){let r=this.inputs.length;for(;r--;)if(this.inputs[r].name===e)return this.inputs[r]}}getIncludeByName(e){if(this.includes){let r=this.includes.length;for(;r--;)if(this.includes[r].name===e)return this.includes[r]}}generate(e,r,o,n,a){let s,l=0,c=this.src;if(this.includes)for(let d=0;d<this.includes.length;d++)e.include(this.includes[d],this);for(let d in this.extensions)e.extensions[d]=!0;let u=[];for(;s=Bb.exec(this.src);)u.push(s);for(let d=0;d<u.length;d++){let p=u[d],f=p[0],h=this.isMethod?!this.getInputByName(f):!0,m=f;if(this.keywords[f]||this.useKeywords&&h&&Xt.containsKeyword(f)){let y=this.keywords[f];if(!y){let g=Xt.getKeywordData(f);g.cache&&(y=e.keywords[f]),y=y||Xt.getKeyword(f,e),g.cache&&(e.keywords[f]=y)}m=y.build(e)}f!==m&&c[p.index+l-1]!=="."&&(c=c.substring(0,p.index+l)+m+c.substring(p.index+f.length+l),l+=m.length-f.length),this.getIncludeByName(m)===void 0&&Xt.contains(m)&&e.include(Xt.get(m))}return r==="source"?c:this.isMethod?(this.isInterface||e.include(this,void 0,c),this.name):e.format("( "+c+" )",this.getType(e),r)}parse(e,r,o,n){if(this.src=e||"",this.includes=r??[],this.extensions=o??{},this.keywords=n??{},this.isMethod){let a=QI.exec(this.src);if(this.inputs=[],a&&a.length==4){this.type=a[1],this.name=a[2];let s=a[3].match(Bb);if(s){let l=0;for(;l<s.length;){let c=s[l++],u;c==="in"||c==="out"||c==="inout"?u=s[l++]:(u=c,c="");let d=s[l++];this.inputs.push({name:d,type:u,qualifier:c})}}this.isInterface=this.src.indexOf("{")===-1}else this.type="",this.name=""}}};var ZI=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,sh=class extends be{constructor(e="",r){super();this.src="";this.useDefine=!1;this.nodeType="Const";this.parse(e||sh.PI,void 0,void 0,void 0,r)}getType(e){return e.getTypeByFormat(this.type)}parse(e,r,o,n,a){this.src=e||"";let s,l,c="",u=ZI.exec(e);this.useDefine=a??this.src.charAt(0)==="#",u&&u.length>1?(l=u[1],s=u[2],c=u[3]):(s=this.src,l="f"),this.name=s,this.type=l,this.value=c}build(e,r){if(r==="source"){if(this.value)return this.useDefine?"#define "+this.name+" "+this.value:"const "+this.type+" "+this.name+" = "+this.value+";";if(this.useDefine)return this.src}return e.include(this),e.format(this.name,this.getType(e),r)}generate(e,r,o,n,a){return e.format(this.name,this.getType(e),r)}},$e=sh;$e.PI="PI",$e.PI2="PI2",$e.RECIPROCAL_PI="RECIPROCAL_PI",$e.RECIPROCAL_PI2="RECIPROCAL_PI2",$e.LOG2="LOG2",$e.EPSILON="EPSILON";var JI=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
18
+ `&&n.push("")):t.getTextWidth(n[n.length-1]+a,i)>o&&(n[n.length-1].length&&n.push(""),t.getTextWidth(n[n.length-1]+a,i)>o&&(a.length===1?(n[n.length-1]+=a,a=""):(n[n.length-1]+=a.slice(0,-1),a=a[a.length-1],n.push(""))));return n[n.length-1]+=a,n}var lt=require("three");var Pb,cd=new Promise(i=>{Pb=i}),wb=!1;var ld;function Ob(i){if(wb)return;if(ld)return ld;async function t(){let r=i??(!1?".":"https://unpkg.com/@splinetool/modelling-wasm@1.12.88/build"),n=import("./process.js"),[a,s]=await Promise.all([n,fetch(`${r}/process.wasm`).then(u=>u.arrayBuffer())]),l=a.default,c=await l({wasmBinary:s});Pb(c),wb=!0}return ld=t(),ld}var Tb=require("three");var zI=["font"];function Go(i,t,e,r){let o,n,a;i.type==="PathGeometry"?(n=JSON.parse(JSON.stringify(i)),a=[[],["extrusion"]]):(n={...i},a=[[]]);for(let c of a){let u=n;for(let d of c)u=u[d];for(o in u){let d=u[o];rf(d)&&!zI.includes(o)&&(u[o]=t.getVariable(d,[r.uuid,"geometry",...c,o]),rf(u[o])&&(u[o]=1))}}let s={parameters:n,type:n.type};if(n.type==="PathGeometry")s.path=n.path;else if(n.type==="VectorGeometry"){let c=Ye.createFromState(n.shape,n.width,n.height);s.shape=c}else if(n.type==="NonParametricGeometry"){if(n.data.groups&&n.data.groups?.forEach(c=>c.materialIndex=Math.max(c.materialIndex??0,0)),s.geometry=new Tb.BufferGeometryLoader().parse(n),s.geometry.groups.length===0){let c=s.geometry;c.addGroup(0,Math.max(c.getIndex()?.count??0,c.getAttribute("position").count),0)}}else if(n.type==="SubdivGeometry"){let c=new zt(n,e);return c.data=i,c}else{if(n.type==="TextGeometry")return new Vn(n,t);if(n.type==="InputGeometry")return new Vn(n,t);if(n.type==="UIGeometry")return ns.create({parameters:{width:n.width,height:n.height,cornerRadius:n.cornerRadius,cornerType:n.cornerType}})}let l;try{l=Zf(s)}catch(c){console.error(c),console.error(`Error generating geometry with inputs: ${s}`);let u=Ye.createFromState(Ba.defaultData(),100,100);s.shape=u,s.type="VectorGeometry",l=Zf(s)}return l}var Cb=require("three"),GI=new Cb.Matrix4;function jl(i,t,e,r){let o=i.position.array,n=i.normal.array,a=GI.makeScale(t,e,r).invert().elements,s,l,c;for(var u=0,d=o.length;u<d;u+=3)o[u]*=t,o[u+1]*=e,o[u+2]*=r,s=n[u],l=n[u+1],c=n[u+2],n[u]=a[0]*s+a[4]*l+a[8]*c,n[u+1]=a[1]*s+a[5]*l+a[9]*c,n[u+2]=a[2]*s+a[6]*l+a[10]*c;i.position.needsUpdate=!0,i.normal.needsUpdate=!0}var ud=new lt.Box3,ss=new lt.Vector3,Oe;cd.then(i=>{Oe=i});var Ab=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),Mb=new Uint32Array([0,1,2,3]),Ib=new Uint8Array([4]),zt=class extends lt.BufferGeometry{constructor(e,r){super();this.data=e;this.flatShading=r;this.subdivPointer=0;this.rebuild(),this.freeSubdivPointer()}mutateDirectlyScaleBaked(e,r){this.freeSubdivPointer();let o=this.data.scaleBaked.map(l=>typeof l=="number"?l:1),n=Bi.div(r.map(l=>typeof l=="number"?l:0),o);if(n.every(l=>l===1))return;this.subdividedGeometry&&jl(this.subdividedGeometry.attributes,...n),this.originalGeometry&&jl(this.originalGeometry.attributes,...n),this.data=e;let a=this.userData.parameters;this.userData.parameters={width:a.width*n[0],height:a.height*n[1],depth:a.depth*n[2]},this.originalGeometry.boundingSphere.center.multiply(ss.fromArray(n));let s=ss.set(a.width,a.height,a.depth).length();this.originalGeometry.boundingSphere.radius=s/2}ensureSubdivPointer(){return this.subdivPointer===0&&this.rebuild(),this.subdivPointer}rebuild(){let e,r,o;try{({originalGeometry:e,subdividedGeometry:r,subdivPointer:o}=zt.build(this.data,void 0,!this.flatShading,void 0))}catch{e=new lt.BoxGeometry(100,100,100),o=0}this.subdivPointer=o,this.originalGeometry=e,this.subdividedGeometry=r??void 0;let n=this.subdividedGeometry??this.originalGeometry;Object.assign(this,n),this.calcBoundingBox()}freeSubdivPointer(){this.subdivPointer&&(zt.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new lt.Sphere,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let r=e.attributes.position,o=e.boundingSphere.center;ud.setFromBufferAttribute(r),ud.getCenter(o),e.boundingSphere.radius=o.distanceTo(ud.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),ud.getSize(ss);let n={width:ss.x,height:ss.y,depth:ss.z};return this.userData.parameters=n,n}static build(e,r,o,n){let a,s,l,c=e?.phongAngle??35;o===!1&&(c=-1),r&&(Oe.free_bvh(r),Oe.free_subdivision_surface(r));try{a=zt.allocate(e,n)}catch(u){console.error(u,e),a=zt.allocate({positionWASM:Ab,indexWASM:Mb,verticesPerFaceWASM:Ib},n)}if(Oe.set_destination_refinement_level(a,0),s=zt.buildLevel(a,!0,c),e.subdivisions>0)try{Oe.set_destination_refinement_level(a,e.subdivisions),l=zt.buildLevel(a,!1,c)}catch{try{Oe.set_destination_refinement_level(a,e.subdivisions-1),l=zt.buildLevel(a,!1,c)}catch{l=null}}else l=null;return{subdivPointer:a,originalGeometry:s,subdividedGeometry:l}}static primitiveToQuads(e,r,o){e.widthSegments>16&&(e.widthSegments=16),e.heightSegments>16&&(e.heightSegments=16),e.depthSegments>16&&(e.depthSegments=16),e.radialSegments>16&&(e.radialSegments=16),e.type==="DodecahedronGeometry"&&(e.detail=0);let n=e.shape!==void 0||e.path!==void 0?r.geometry:Go(e,o,!1,r),a;e.type==="TorusGeometry"&&e.arc===Math.PI*2?a=n.getClosedTorusIndicesForBooleanOrSubdiv():a=n.getIndex();let s,l,c,u;({positions:s,triIndices:u}=rh(n.getAttribute("position"),a));let d;if(e.type==="CylinderGeometry"&&e.cornerRadius===0&&e.hollow===0&&e.openEnded===!1){let p=e.radialSegments*e.heightSegments*3*2,f=p+e.radialSegments*3;d=[p,f]}return{indices:l,verticesPerFace:c}=oh(s,u,n,d),{positions:s,indices:l,verticesPerFace:c}}static allocate(e,r){let o,n,a,s=[],l=[];e.positionWASM&&e.positionWASM.length>0?(o=e.positionWASM,n=e.indexWASM,a=e.verticesPerFaceWASM):(o=Ab,n=Mb,a=Ib);let c=o.length,u=n.length,d=a.length,p=o.length+s.length+l.length,f=n.length+a.length,h=p*Float32Array.BYTES_PER_ELEMENT+f*Uint32Array.BYTES_PER_ELEMENT,m=p*Float32Array.BYTES_PER_ELEMENT,y=Oe._malloc(h),g=new Float32Array(Oe.HEAPF32.buffer,y,p),b=new Uint32Array(Oe.HEAPU32.buffer,y+m,f);g.set(o,0),g.set(s,o.length),g.set(l,o.length+s.length),b.set(n,0),b.set(a,n.length);let w;e?.scaleBaked?.some(S=>S!==1)&&(w=new lt.Matrix4().makeScale(...e.scaleBaked.map(S=>typeof S=="number"?S:1))),r&&(w?w.premultiply(r):w=r);let P=w?Oe.alloc_subdivision_surface2(y,c,y+m,u,y+m+n.length*Uint32Array.BYTES_PER_ELEMENT,d,w.elements):Oe.alloc_subdivision_surface(y,c,y+m,u,y+m+n.length*Uint32Array.BYTES_PER_ELEMENT,d);return Oe._free(y),P}static buildLevel(e,r,o,n,a){let s=a?Oe.get_mesh_data2(e,r?Oe.Level.CONTROL:Oe.Level.REFINED,o,a.elements):Oe.get_mesh_data(e,r?Oe.Level.CONTROL:Oe.Level.REFINED,o),l=8,c=Oe.HEAPU32.subarray(s>>2,(s>>2)+l),u=c.subarray(4,4+4),d=0,p=Oe.HEAPU32[c[d]>>2],f=Oe.HEAPF32.subarray(p>>2,(p>>2)+u[d]);d++;let h=Oe.HEAPU32[c[d]>>2],m=Oe.HEAPF32.subarray(h>>2,(h>>2)+u[d]);d++;let y=Oe.HEAPU32[c[d]>>2],g=Oe.HEAPU32.subarray(y>>2,(y>>2)+u[d]);d++;let b=Oe.HEAPU32[c[d]>>2],w=Oe.HEAPU32.subarray(b>>2,(b>>2)+u[d]);if(d++,n===void 0){let P=new lt.BufferGeometry;if(P.setIndex(new lt.Uint32BufferAttribute(w,1)),P.setAttribute("position",new lt.Float32BufferAttribute(f,3)),P.setAttribute("normal",new lt.Float32BufferAttribute(m,3)),r){P.setAttribute("faceMap",new lt.Uint32BufferAttribute(g,1));let S=new Float32Array(m.length/3*4).fill(0);P.setAttribute("color",new lt.BufferAttribute(S,4))}return Oe.free_mesh_data(s),P.userData.type="SubdivGeometry",P}n.getAttribute("position").copyArray(f),n.getAttribute("normal").copyArray(m),n.attributes.position.needsUpdate=!0,n.attributes.normal.needsUpdate=!0,Oe.free_mesh_data(s)}static freeSubdivPointer(e){Oe.free_bvh(e),Oe.free_subdivision_surface(e)}static buildControlCageWireframe(e,r,o){let n=Oe.get_wireframe_data_for_base_level(e),a=4,s=Oe.HEAPU32.subarray(n>>2,(n>>2)+a),l=s.subarray(2,2+2),c=0,u=Oe.HEAPU32[s[c]>>2],d=Oe.HEAPF32.subarray(u>>2,(u>>2)+l[c]);c++;let p=Oe.HEAPU32[s[c]>>2],f=Oe.HEAPU32.subarray(p>>2,(p>>2)+l[c]);if(r===void 0){let h=new lt.BufferGeometry;h.setAttribute("position",new lt.Float32BufferAttribute(d,3));let m=new Float32Array(d.length);for(let y=0,g=d.length;y<g;)m[y++]=o.r,m[y++]=o.g,m[y++]=o.b;return h.setAttribute("color",new lt.BufferAttribute(m,3)),h.setIndex(new lt.Uint32BufferAttribute(f,1)),Oe.free_wireframe_data_for_base_level(n),h}r.getAttribute("position").copyArray(d),r.attributes.position.needsUpdate=!0,Oe.free_wireframe_data_for_base_level(n)}static updateCollabMesh(e,r,o){let n=r===0;n||Oe.set_destination_refinement_level(e,r);let a=o?Oe.get_topological_data2(e,n?Oe.Level.CONTROL:Oe.Level.REFINED,o.elements):Oe.get_topological_data(e,n?Oe.Level.CONTROL:Oe.Level.REFINED),s=6,l=Oe.HEAPU32.subarray(a>>2,(a>>2)+s),c=l.subarray(3,3+3),u=0,d=Oe.HEAPU32[l[u]>>2],p=new Float32Array(Oe.HEAPF32.subarray(d>>2,(d>>2)+c[u]));u++;let f=Oe.HEAPU32[l[u]>>2],h=new Uint32Array(Oe.HEAPU32.subarray(f>>2,(f>>2)+c[u]));u++;let m=Oe.HEAPU32[l[u]>>2],y=new Uint8Array(Oe.HEAPU32.subarray(m>>2,(m>>2)+c[u]));return Oe.free_topological_data(a),{positions:p,indices:h,verticesPerFace:y}}};var Eb=["getX","getY","getZ"];function rh(i,t){let e={},r=t?t.count:i.count,o=0,n=[],a=[],s=1e4;for(let c=0;c<r;c++){let u=t?t.getX(c):c,d="";for(let p=0;p<3;p++)d+=`${~~(i[Eb[p]](u)*s)},`;if(d in e)n.push(e[d]);else{for(let p=0;p<3;p++)a.push(i[Eb[p]](u));e[d]=o,n.push(o),o++}}let l=[];for(let c=0;c<n.length;c+=3)n[c]===n[c+1]||n[c]===n[c+2]||n[c+1]===n[c+2]||l.push(n[c],n[c+1],n[c+2]);return{positions:a,triIndices:l}}var dd=new lt.Vector3,Jf=new lt.Vector3,eh=new lt.Vector3,th=new lt.Vector3;function oh(i,t,e,r){let o=[],n=[];if(e.userData.shape!==void 0&&e.userData.parameters.depth===0&&e.userData.shape.shapeHoles.length===0){let l=e.userData.shape.extractShapePointsToFlatArray([]),c=e.userData.parameters.spikes;if(e.userData.type==="EllipseGeometry"&&c<=24&&c%4===0&&e.userData.parameters.angle>=360){let p=l.length/2/c;l=l.filter((f,h)=>Math.floor(h/2)%p===0)}let u=0;for(let p=0;p<l.length;p+=2)u+=(l[p]-l[(p===0?l.length:p)-2])*(l[p+1]+l[(p===0?l.length:p)-1]);i.length=0;let d=0;if(u<0)for(let p=0;p<l.length;p+=2)i.push(l[p],l[p+1],0),o.push(d++);else for(let p=l.length-2;p>=0;p-=2)i.push(l[p],l[p+1],0),o.push(d++);return n.push(d),{indices:o,verticesPerFace:n}}let a=new Float32Array([e.userData.parameters.depth])[0],s=0;for(;s<t.length;){if(e.useNgonForTopBottomFaceDuringBake){let l=0;if((i[t[s]*3+2]===a||i[t[s]*3+2]===0)&&l++,(i[t[s+1]*3+2]===a||i[t[s+1]*3+2]===0)&&l++,(i[t[s+2]*3+2]===a||i[t[s+2]*3+2]===0)&&l++,l===3)break}if(t[s+1]===t[s+3]&&t[s+2]===t[s+5]||t[s+0]===t[s+3]&&t[s+2]===t[s+4]){dd.set(i[t[s]*3],i[t[s]*3+1],i[t[s]*3+2]),Jf.set(i[t[s+1]*3],i[t[s+1]*3+1],i[t[s+1]*3+2]),eh.set(i[t[s+4]*3],i[t[s+4]*3+1],i[t[s+4]*3+2]),th.set(i[t[s+5]*3],i[t[s+5]*3+1],i[t[s+5]*3+2]),Jf.sub(dd).normalize(),eh.sub(dd).normalize(),th.sub(dd).normalize();let l=Jf.cross(eh).dot(th),c=s;Math.abs(l)>.005||r&&r.some((u,d)=>d%2===1?!1:c>=r[d]&&c<r[d+1])?(o.push(t[s],t[s+1],t[s+2]),n.push(3),s+=3):(o.push(t[s],t[s+1],t[s+4],t[s+5]),n.push(4),s+=6)}else o.push(t[s],t[s+1],t[s+2]),n.push(3),s+=3}if(e.useNgonForTopBottomFaceDuringBake){let l=[],c=[],u=0;for(let d=0,p=0;d<i.length;d+=3,p++)i[d+2]===0&&(l.push(p),u++),i[d+2]===a&&c.push(p);if(e.userData.parameters.extrudeBevelSize===0){let d=c[0];c[0]=c[1],c[1]=d}l.reverse(),o.push(...l,...c),n.push(u,u)}return{indices:o,verticesPerFace:n}}var Xr={};xm(Xr,{calcBoolean:()=>kI,calcBooleanTopological:()=>UI,freeMeshSet:()=>$I,getMeshSet:()=>HI,hasOpenEdges:()=>WI,transformMeshSet:()=>qI});var FI,Nb=new Promise(i=>{FI=i});var Ul=require("three");var ke,ls;Nb.then(i=>ke=i);function jI(i,t,e){let r,o;i.userData.parameters.type==="TorusGeometry"&&i.userData.parameters.arc===Math.PI*2?o=i.getClosedTorusIndicesForBooleanOrSubdiv():o=i.getIndex();let{positions:n,triIndices:a}=rh(i.getAttribute("position"),o),s;if(t&&e){let{indices:l,verticesPerFace:c}=oh(n,a,i);s=c.length,r=[];for(let u=0,d=0;u<s;u++){r.push(c[u]);for(let p=0;p<c[u];p++)r.push(l[d++])}}else{let l=a.length;r=Array(l+l/3),s=0;for(let c=0,u=0;u<r.length;)r[u++]=3,s++,r[u++]=a[c++],r[u++]=a[c++],r[u++]=a[c++]}return{positions:n,faceIndices:r,nFaces:s}}function Db(i){let t=i.length,e=t*Uint32Array.BYTES_PER_ELEMENT,r=t*Float32Array.BYTES_PER_ELEMENT,o=Number.isInteger(i[0])?e:r,n=ke._malloc(o);return(Number.isInteger(i[0])?new Uint32Array(ke.HEAPU32.buffer,n,t):new Float32Array(ke.HEAPF32.buffer,n,t)).set(i,0),n}function _b(i){switch(i){case 0:return ke.OP.UNION;case 1:return ke.OP.INTERSECTION;case 2:return ke.OP.A_MINUS_B;default:throw new Error("Unknown boolean operation "+i)}}function UI(i,t){ls===void 0&&(ls=ke.init_csg());let e=Db(i),r=ke.csg_calc_topological(ls,e,i.length,_b(t));ke._free(e);let o=6,n=ke.HEAPU32.subarray(r>>2,(r>>2)+o),a=n.subarray(3,3+3),s=0,l=ke.HEAPU32[n[s]>>2],c=new Float32Array(ke.HEAPF32.subarray(l>>2,(l>>2)+a[s]));s++;let u=ke.HEAPU32[n[s]>>2],d=new Uint32Array(ke.HEAPU32.subarray(u>>2,(u>>2)+a[s]));s++;let p=ke.HEAPU32[n[s]>>2],f=new Uint8Array(ke.HEAPU32.subarray(p>>2,(p>>2)+a[s]));return ke.free_mesh_data(r),{positions:c,indices:d,verticesPerFace:f}}function kI(i,t,e,r){ls===void 0&&(ls=ke.init_csg());let o=Db(i),n=ke.csg_calc(ls,o,i.length,r,_b(t));ke._free(o);let a=5,s=ke.HEAPU32.subarray(n>>2,(n>>2)+a),l=s.subarray(2,2+3),c=0,u=ke.HEAPU32[s[c]>>2],d=ke.HEAPF32.subarray(u>>2,(u>>2)+l[c]);c++;let p=ke.HEAPU32[s[c]>>2],f=ke.HEAPF32.subarray(p>>2,(p>>2)+l[c]);c++;let h=l[c];e.setAttribute("position",new Ul.Float32BufferAttribute(d,3)),e.setAttribute("normal",new Ul.Float32BufferAttribute(f,3));let m=ke.HEAPF32.subarray((n>>2)+5,(n>>2)+5+6);return e.boundingSphere===null&&(e.boundingSphere=new Ul.Sphere),e.boundingSphere.center.set(m[0],m[1],m[2]),e.boundingSphere.radius=(m[3]**2+m[4]**2+m[5]**2)**.5,e.userData.parameters={width:m[3]*2,height:m[4]*2,depth:m[5]*2},ke.free_mesh_data(n),h}function HI(i,t,e){if(ke===void 0)return-1;let r,o,n;if(t&&i.userData.positions!==void 0){let g=i.userData;n=g.verticesPerFace.length,r=g.positions,o=Array(g.verticesPerFace.reduce((b,w)=>b+w,0)+n);for(let b=0,w=0,P=0;b<g.verticesPerFace.length;b++){o[P++]=g.verticesPerFace[b];for(let S=0;S<g.verticesPerFace[b];S++)o[P++]=g.indices[w++]}}else({positions:r,faceIndices:o,nFaces:n}=jI(i,t,e));let a=r.length,s=o.length,l=r.length,c=o.length,u=l*Float32Array.BYTES_PER_ELEMENT+c*Uint32Array.BYTES_PER_ELEMENT,d=l*Float32Array.BYTES_PER_ELEMENT,p=c*Uint32Array.BYTES_PER_ELEMENT,f=ke._malloc(u),h=new Float32Array(ke.HEAPF32.buffer,f,l),m=new Uint32Array(ke.HEAPU32.buffer,f+d,c);h.set(r,0),m.set(o,0);let y=ke.get_csg_mesh(f,a,f+d,s,n);return ke._free(f),y}function WI(i){return ke.has_open_edges(i)}function qI(i,t){ke.transform_csg_mesh(i,t.elements)}function $I(i){ke.free_csg_mesh(i)}var XI={ConeGeometry:Px,CubeGeometry:Ox,CylinderGeometry:wx,DodecahedronGeometry:Cx,EllipseGeometry:rs,HelixGeometry:Qx,IcosahedronGeometry:Jx,LatheGeometry:eb,NonParametricGeometry:ib,PolygonGeometry:nd,PyramidGeometry:nb,RectangleGeometry:ns,SphereGeometry:ab,PlaneGeometry:lb,BackdropGeometry:cb,StarGeometry:ad,TextFrameGeometry:db,TorusGeometry:pb,TorusKnotGeometry:hb,TriangleGeometry:mb,PathGeometry:bb,VectorGeometry:Tr},Zf=i=>XI[i.type].create(i);function cs(i){return i!==null&&"booleanOp"in i}var us=class extends Xa(pd.Mesh){constructor(){super(...arguments);this.booleanMeshSetAddress=-1;this.booleanWasTransformed=!1;this.booleanMatrixInvOld=new pd.Matrix4}updateVisible(e){super.updateVisible(e),this.visible=!cs(this.parent)&&this.visible,cs(this.parent)&&this.parent.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(Xr.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(e=!1){return e?this.booleanWasTransformed=!0:this.freeBooleanPointer(),cs(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)e instanceof us&&(e.freeBooleanPointer(),cs(e)&&e.invalidateUpstreamBooleanData())}updateTransformState(e,r){let o=super.updateTransformState(e,r);return o&&cs(this.parent)&&this.invalidateDownstreamBooleanData(!0),o}onVariableUpdate(e=!1){super.onVariableUpdate(e),cs(this.parent)&&this.invalidateDownstreamBooleanData(!0)}};var fd=new ds.Box3;function kl(i,t=0,e=i.count,r,o){let n=1/0,a=1/0,s=1/0,l=-1/0,c=-1/0,u=-1/0;for(let d=t;d<e;d++){let p=i.getX(d),f=i.getY(d),h=i.getZ(d);p<n&&(n=p),f<a&&(a=f),h<s&&(s=h),p>l&&(l=p),f>c&&(c=f),h>u&&(u=h)}fd.min.set(n,a,s),fd.max.set(l,c,u),fd.getCenter(r),fd.getSize(o).multiplyScalar(.5)}var YI=new ds.BufferGeometry,KI=new ds.MeshBasicMaterial,$t=class extends us{constructor(t,e){super(YI,KI),this.super_Entity(t,e)}updateState(t,e){this.updateState_Entity(t,e)}updateEntityBoxSize(t,e){let r=this.geometry.getAttribute("position");r!==void 0?kl(r,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:r.count,t,e):super.updateEntityBoxSize(t,e)}};var vi=require("three");var Gr=require("three");var Ad=require("three");var mi=class{constructor(t){this.hashProperties=void 0;this.isNode=!0;this.shortcuts={};if(mi.uuidContext===null)throw new Error("plz startContext");mi.uuidContext===mi.globalContext?this.uuid="_gid"+mi.uuidContext.nodeContextUuid++:this.uuid="_uid"+mi.uuidContext.nodeContextUuid++,this.type=t,this.name=""}static startContext(t){this.uuidContext===null||this.uuidContext===mi.globalContext?this.uuidContext=t:console.error("Can't start context twice")}static endContext(t){this.uuidContext!==t&&console.error("Can't end context twice"),this.uuidContext=null}analyze(t,e){e=e??{},t.analyzing=!0,this.build(t.addFlow(e.slot,e.cache,e.context),"v4"),t.clearVertexNodeCode(),t.clearFragmentNodeCode(),t.removeFlow(),t.analyzing=!1}analyzeAndFlow(t,e,r){return r=r??{},this.analyze(t,r),this.flow(t,e,r)}flow(t,e,r){r=r??{},t.addFlow(r.slot,r.cache,r.context);let o={result:this.build(t,e),code:t.clearNodeCode(),extra:t.context.extra};return t.removeFlow(),o}build(t,e,r){e=e??this.getType(t,e);let o=t.getNodeData(r??this);return t.analyzing&&this.appendDepsNode(t,o,e),t.nodes.indexOf(this)===-1&&t.nodes.push(this),this.updateFrame!==void 0&&t.updaters.indexOf(this)===-1&&t.updaters.push(this),this.generate(t,e,r)}updateFrame(t){}generateReadonly(t,e,r,o,n,a){return""}generate(t,e,r,o,n){return""}parse(t,e,r,o){}appendDepsNode(t,e,r){e.deps=(e.deps||0)+1;let o=t.getTypeLength(r);(o>(e.outputMax||0)||this.getType(t,r))&&(e.outputMax=o,e.output=r)}setName(t){this.name=t}getName(){return this.name}getType(t,e){return e==="sampler2D"||e==="samplerCube"?e:this.type}},ot=mi;ot.globalContext={nodeContextUuid:0},ot.uuidContext=mi.globalContext;var xo=require("three");var Hl=class{constructor(t){t=t??{},this.name=t.name,this.type=t.type,this.node=t.node,this.size=t.size,this.needsUpdate=t.needsUpdate}get value(){return this.node.value}set value(t){this.node.value=t}};var ih=class{constructor(){this.nodes={};this.keywords={}}add(t){this.nodes[t.name]=t}addKeyword(t,e,r){r=r!==void 0?r:!0,this.keywords[t]={callback:e,cache:r}}remove(t){delete this.nodes[t.name]}removeKeyword(t){delete this.keywords[t]}get(t){return this.nodes[t]}getKeyword(t,e){return this.keywords[t].callback(e)}getKeywordData(t){return this.keywords[t]}contains(t){return this.nodes[t]!==void 0}containsKeyword(t){return this.keywords[t]!==void 0}},Xt=new ih;var nh=require("three");var Rb=require("three"),be=class extends ot{constructor(e,r){super(e);this.scope="";r=r??{},this.shared=r.shared!==void 0?r.shared:!0,this.unique=r.unique!==void 0?r.unique:!1}build(e,r,o,n){if(r=r??this.getType(e),this.getShared(e,r)){let a=this.getUnique(e,r);a&&this.uuid===void 0&&(this.uuid=Rb.MathUtils.generateUUID()),o=e.getUUID(o??this.getUUID(),!a);let s=e.getNodeData(o),l=s.output||this.getType(e);if(e.analyzing)return(s.deps||0)>0||this.getLabel()?(this.appendDepsNode(e,s,r),this.generate(e,r,o)):super.build(e,r,o);if(a)return s.name=s.name||super.build(e,r,o),s.name;if(!this.getLabel()&&(!this.getShared(e,l)||e.context.ignoreCache||s.deps===1))return super.build(e,r,o);o=this.getUUID(!1);let c=this.getTemp(e,o);if(c)return e.format(c,l,r);{c=super.generate(e,r,o,s.output,n);let u=this.generate(e,l,o);return e.addNodeCode(c+" = "+u+";"),e.format(c,l,r)}}return super.build(e,r,o)}getShared(e,r){return r!=="sampler2D"&&r!=="samplerCube"&&this.shared}getUnique(e,r){return this.unique}setLabel(e){return this.label=e,this}getLabel(){return this.label}getUUID(e){let r=this.uuid;return typeof this.scope=="string"&&(r=this.scope+"-"+r),r}getTemp(e,r){r=r||this.uuid;let o=e.getVars()[r];return o?o.name:void 0}generate(e,r,o,n,a){return this.getShared(e,r)||console.error("TempNode is not shared"),o=o??this.uuid,e.getTempVar(o,n??this.getType(e),a,this.getLabel()).name}};var it=class extends be{constructor(e,r){r=r??{},r.shared=r.shared!==void 0?r.shared:!1;super(e,r);this.readonly=!1}setReadonly(e){return this.readonly=e,this.hashProperties=this.readonly?["value"]:void 0,this}getReadonly(){return this.readonly}generate(e,r,o,n,a,s){o=e.getUUID(o??this.getUUID()),n=n??this.getType(e);let l=e.getNodeData(o);return this.getReadonly()&&this.generateReadonly!==void 0?this.generateReadonly(e,r,o,n,a,s):e.isShader("vertex")?(l.vertex||(l.vertex=e.createVertexUniform(n,this,a,s,this.getLabel())),e.format(l.vertex.name,n,r)):(l.fragment||(l.fragment=e.createFragmentUniform(n,this,a,s,this.getLabel())),e.format(l.fragment.name,n,r))}};var Ot=class extends it{constructor(e=0,r){super("v2");this.nodeType="Vector2";this.value=e instanceof nh.Vector2?e:new nh.Vector2(e,r)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}generateReadonly(e,r,o,n,a,s){return e.format("vec2("+this.value.x+", "+this.value.y+")",n,r)}};var ah=require("three");var ar=class extends it{constructor(e=0,r,o){super("v3");this.nodeType="Vector3";this.value=e instanceof ah.Vector3?e:new ah.Vector3(e,r,o)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}get z(){return this.value.z}set z(e){this.value.z=e}generateReadonly(e,r,o,n,a,s){return e.format("vec3("+this.value.x+", "+this.value.y+", "+this.value.z+")",n,r)}};var Lb=require("three"),Yt=class extends Lb.Color{constructor(e,r,o,n){super(e,r,o);this.isColorA=!0;this.a=n}setRGBA(e,r,o,n){super.setRGB(e,r,o),this.a=n}copy(e){return super.copy(e),this.a="a"in e?e.a:1,this}clone(){return new this.constructor(this.r,this.g,this.b,this.a)}equals(e){return super.equals(e)&&this.a===e.a}setStyle(e,r="srgb"){let o;if(e==="transparent")return this.setRGBA(0,0,0,0),this;if(o=/^((?:rgb|hsl)a?)\(([^)]*)\)/.exec(e)){let n,a=o[1],s=o[2];switch(a){case"rgb":case"rgba":if(n=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return this.a=a==="rgba"?parseFloat(n[4]):1,super.setStyle(e,r);break;case"hsl":case"hsla":if(n=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)%\s*,\s*(\d*\.?\d+)%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return this.a=a==="hsla"?parseFloat(n[4]):1,super.setStyle(e,r);break}}return super.setStyle(e,r)}get x(){return this.r}get y(){return this.g}get z(){return this.b}get w(){return this.a}set x(e){this.r=e}set y(e){this.g=e}set z(e){this.b=e}set w(e){this.a=e}};var Cr=class extends it{constructor(e){super("v4");this.nodeType="Vector4";this.value=e instanceof Yt?e:new Yt(e.r,e.g,e.b,e.a)}generateReadonly(e,r,o,n,a,s){return e.format("vec4("+this.value.r+", "+this.value.g+", "+this.value.b+", "+this.value.a+")",n,r)}};var QI=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,Bb=/[a-z_0-9]+/gi,Z=class extends be{constructor(e,r,o,n,a){super(a);this.src="";this.nodeType="Function";this.useKeywords=!0;this.includes=[];this.extensions={};this.keywords={};this.isMethod=a===void 0,this.isInterface=!1,this.parse(e,r,o,n)}getShared(e,r){return!this.isMethod}getType(e){return e.getTypeByFormat(this.type)}getInputByName(e){if(this.inputs){let r=this.inputs.length;for(;r--;)if(this.inputs[r].name===e)return this.inputs[r]}}getIncludeByName(e){if(this.includes){let r=this.includes.length;for(;r--;)if(this.includes[r].name===e)return this.includes[r]}}generate(e,r,o,n,a){let s,l=0,c=this.src;if(this.includes)for(let d=0;d<this.includes.length;d++)e.include(this.includes[d],this);for(let d in this.extensions)e.extensions[d]=!0;let u=[];for(;s=Bb.exec(this.src);)u.push(s);for(let d=0;d<u.length;d++){let p=u[d],f=p[0],h=this.isMethod?!this.getInputByName(f):!0,m=f;if(this.keywords[f]||this.useKeywords&&h&&Xt.containsKeyword(f)){let y=this.keywords[f];if(!y){let g=Xt.getKeywordData(f);g.cache&&(y=e.keywords[f]),y=y||Xt.getKeyword(f,e),g.cache&&(e.keywords[f]=y)}m=y.build(e)}f!==m&&c[p.index+l-1]!=="."&&(c=c.substring(0,p.index+l)+m+c.substring(p.index+f.length+l),l+=m.length-f.length),this.getIncludeByName(m)===void 0&&Xt.contains(m)&&e.include(Xt.get(m))}return r==="source"?c:this.isMethod?(this.isInterface||e.include(this,void 0,c),this.name):e.format("( "+c+" )",this.getType(e),r)}parse(e,r,o,n){if(this.src=e||"",this.includes=r??[],this.extensions=o??{},this.keywords=n??{},this.isMethod){let a=QI.exec(this.src);if(this.inputs=[],a&&a.length==4){this.type=a[1],this.name=a[2];let s=a[3].match(Bb);if(s){let l=0;for(;l<s.length;){let c=s[l++],u;c==="in"||c==="out"||c==="inout"?u=s[l++]:(u=c,c="");let d=s[l++];this.inputs.push({name:d,type:u,qualifier:c})}}this.isInterface=this.src.indexOf("{")===-1}else this.type="",this.name=""}}};var ZI=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,sh=class extends be{constructor(e="",r){super();this.src="";this.useDefine=!1;this.nodeType="Const";this.parse(e||sh.PI,void 0,void 0,void 0,r)}getType(e){return e.getTypeByFormat(this.type)}parse(e,r,o,n,a){this.src=e||"";let s,l,c="",u=ZI.exec(e);this.useDefine=a??this.src.charAt(0)==="#",u&&u.length>1?(l=u[1],s=u[2],c=u[3]):(s=this.src,l="f"),this.name=s,this.type=l,this.value=c}build(e,r){if(r==="source"){if(this.value)return this.useDefine?"#define "+this.name+" "+this.value:"const "+this.type+" "+this.name+" = "+this.value+";";if(this.useDefine)return this.src}return e.include(this),e.format(this.name,this.getType(e),r)}generate(e,r,o,n,a){return e.format(this.name,this.getType(e),r)}},$e=sh;$e.PI="PI",$e.PI2="PI2",$e.RECIPROCAL_PI="RECIPROCAL_PI",$e.RECIPROCAL_PI2="RECIPROCAL_PI2",$e.LOG2="LOG2",$e.EPSILON="EPSILON";var JI=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
19
19
  )*?)}`,"gim"),e3=new RegExp("s*(w*?)s*(w*?)(=|;)","gim"),ps=class extends be{constructor(e=""){super();this.inputs=[];this.src="";this.nodeType="Struct";this.parse(e)}getType(e){return e.getTypeByFormat(this.name)}getInputByName(e){let r=this.inputs.length;for(;r--;)if(this.inputs[r].name===e)return this.inputs[r]}generate(e,r,o,n,a){return r==="source"?this.src+";":e.format("( "+this.src+" )",this.getType(e),r)}parse(e=""){this.src=e,this.inputs=[];let r=JI.exec(e);if(r){let o=r[2],n;for(;n=e3.exec(o);)this.inputs.push({type:n[1],name:n[2]});this.name=r[1]}else this.name="";this.type=this.name}};var fs=class extends be{constructor(e){super("v2",{shared:!1});this.nodeType="UV";this.index=e??0}generate(e,r){e.requires.uv[this.index]=!0;let o=this.index>0?this.index+1:"",n=e.isShader("vertex")?"uv"+o:"vUv"+o;return e.format(n,this.getType(e),r)}};Xt.addKeyword("uv",function(){return new fs});Xt.addKeyword("uv2",function(){return new fs(1)});var hd=require("three");var zn=class extends be{constructor(e,r){super("v4");this.nodeType="ColorSpace";this.input=e,this.method=r??zn.LINEAR_TO_LINEAR,this.hashProperties=["method"]}static getEncodingComponents(e){switch(e){case hd.LinearEncoding:return["Linear"];case hd.sRGBEncoding:return["sRGB"];default:return[]}}generate(e,r){let o=this.input.build(e,"v4"),n=this.getType(e),a=zn.Nodes[this.method],s=e.include(a);if(s===zn.LINEAR_TO_LINEAR)return e.format(o,n,r);if(a.inputs?.length===2){let l=this.factor.build(e,"f");return e.format(s+"( "+o+", "+l+" )",n,r)}else return e.format(s+"( "+o+" )",n,r)}fromEncoding(e){let r=zn.getEncodingComponents(e);this.method="LinearTo"+r[0],this.factor=r[1]}fromDecoding(e){let r=zn.getEncodingComponents(e);this.method=r[0]+"ToLinear",this.factor=r[1]}},yr=zn;yr.Nodes={LinearToLinear:new Z(["vec4 LinearToLinear( in vec4 value ) {"," return value;","}"].join(`
20
20
  `)),sRGBToLinear:new Z(["vec4 sRGBToLinear( in vec4 value ) {"," return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.w );","}"].join(`
21
21
  `)),LinearTosRGB:new Z(["vec4 LinearTosRGB( in vec4 value ) {"," return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.w );","}"].join(`
@@ -1873,7 +1873,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
1873
1873
  vec3 distorted2 = nearby2 + normal * displacementMapTexture(tex, crop, uv, mat, vec2(neighbor_offset)) * intensity;
1874
1874
  displaced_normal = normalize(cross(distorted1 - displaced_position, distorted2 - displaced_position));
1875
1875
  return displaced_position;
1876
- }`,[e,r])}}();var _e={normalRenderTarget:new gr,normalRenderTargetDepth:new gr,transmissionRenderTarget:new gr,aspectRatio:new Ot,transmissionSize:new Ot(2048,2048),transmissionRenderTargetDepth:new gr,aoRenderTarget:new gr,aoEnabled:new Tt,pixelRatioNode:new se(1),resolution:new Ot,penumbraSize:new bo(5,.5),frameIndex:new je(0),transmissionLod:new je(2),taaEnabled:new Tt(!0)};for(let i of Object.values(_e))i.isRenderGlobal=!0;var Zb={skiaWasmUrl:"https://unpkg.com/@splinetool/ui-wasm@1.12.87/build/ui.wasm"};var yi=class extends ot{constructor(){super("basic");this.nodeType="Basic";this.color=new et(Bt),this.shadingAlpha=new se(1),this.shadingBlend=new je(0),this.previousModelViewMatrix=new sr,this.previouseProjectionMatrix=new sr}get category(){return"phong"}generate(e){let r;if(e.isShader("vertex")){let o=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform({frameIndex:_e.frameIndex}),e.mergeUniform({resolution:_e.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(bd.UniformsUtils.merge([bd.UniformsLib.fog])),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","#include <fog_pars_vertex>","#include <skinning_pars_vertex>","#include <normal_pars_vertex>","#include <morphtarget_pars_vertex>"].join(`
1876
+ }`,[e,r])}}();var _e={normalRenderTarget:new gr,normalRenderTargetDepth:new gr,transmissionRenderTarget:new gr,aspectRatio:new Ot,transmissionSize:new Ot(2048,2048),transmissionRenderTargetDepth:new gr,aoRenderTarget:new gr,aoEnabled:new Tt,pixelRatioNode:new se(1),resolution:new Ot,penumbraSize:new bo(5,.5),frameIndex:new je(0),transmissionLod:new je(2),taaEnabled:new Tt(!0)};for(let i of Object.values(_e))i.isRenderGlobal=!0;var Zb={skiaWasmUrl:"https://unpkg.com/@splinetool/ui-wasm@1.12.88/build/ui.wasm"};var yi=class extends ot{constructor(){super("basic");this.nodeType="Basic";this.color=new et(Bt),this.shadingAlpha=new se(1),this.shadingBlend=new je(0),this.previousModelViewMatrix=new sr,this.previouseProjectionMatrix=new sr}get category(){return"phong"}generate(e){let r;if(e.isShader("vertex")){let o=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform({frameIndex:_e.frameIndex}),e.mergeUniform({resolution:_e.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(bd.UniformsUtils.merge([bd.UniformsLib.fog])),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","#include <fog_pars_vertex>","#include <skinning_pars_vertex>","#include <normal_pars_vertex>","#include <morphtarget_pars_vertex>"].join(`
1877
1877
  `));let n=["#include <beginnormal_vertex>","#include <morphnormal_vertex>",`
1878
1878
  #include <skinbase_vertex>
1879
1879
  #include <skinnormal_vertex>
@@ -4376,4 +4376,4 @@ void main() {
4376
4376
  A = exp(A) * vColor.a;
4377
4377
  gl_FragColor = vec4(color.rgb, A);
4378
4378
  gVelocity = vec4(0.0); // so it is ignored by TAA
4379
- }`,n={covariancesTexture:{type:"t",value:null},centersColorsTexture:{type:"t",value:null},meshIndexIntervals:{value:e},meshMatrixWorldsTexture:{type:"t",value:null},focal:{type:"v2",value:new Ce.Vector2},viewport:{type:"v2",value:new Ce.Vector2},basisViewport:{type:"v2",value:new Ce.Vector2},debugColor:{type:"v3",value:new Ce.Color},covariancesTextureSize:{type:"v2",value:new Ce.Vector2(1024,1024)},centersColorsTextureSize:{type:"v2",value:new Ce.Vector2(1024,1024)},orthoZoom:{type:"f",value:-1}};return new Ce.ShaderMaterial({uniforms:n,vertexShader:r,fragmentShader:o,transparent:!0,alphaTest:1,blending:Ce.NormalBlending,depthTest:!0,depthWrite:!1,side:Ce.DoubleSide})}static buildGeomtery(e){let r=new Ce.BufferGeometry;r.setIndex([0,1,2,0,2,3]);let o=new Float32Array(4*3),n=new Ce.BufferAttribute(o,3);r.setAttribute("position",n),n.setXYZ(0,-1,-1,0),n.setXYZ(1,-1,1,0),n.setXYZ(2,1,1,0),n.setXYZ(3,1,-1,0),n.needsUpdate=!0;let a=new Ce.InstancedBufferGeometry().copy(r),s=new Uint32Array(e),l=new Ce.InstancedBufferAttribute(s,1,!1);return l.setUsage(Ce.DynamicDrawUsage),a.setAttribute("splatIndex",l),a.instanceCount=e,a}resetLocalSplatDataAndTexturesFromSplatBuffer(){this.updateLocalSplatDataFromSplatBuffer(),this.allocateAndStoreLocalSplatDataInTextures()}updateLocalSplatDataFromSplatBuffer(){this.splatBuffers.forEach(n=>n.buildPreComputedBuffers()),this.covariances=new Float32Array(this.splatCount*6),this.colors=new Uint8Array(this.splatCount*4),this.centers=new Float32Array(this.splatCount*3);let e=0,r=0,o=0;for(let n of this.splatBuffers){let a=n.nsplats;this.colors.subarray(e,e+a*4).set(n.colorsA),e+=a*4,this.centers.subarray(r,r+a*3).set(n.decoded.xyz.denormDequant().data),r+=a*3,this.covariances.subarray(o,o+a*6).set(new Float32Array(n.precomputedCovarianceBufferData)),o+=a*6}}allocateAndStoreLocalSplatDataInTextures(){let o=this.splatCount,n=new Ce.Vector2(4096,1024);for(;n.x*n.y*2<o*6;)n.y*=2;let a=new Ce.Vector2(4096,1024);for(;a.x*a.y*4<o*4;)a.y*=2;let s,l;if(this.halfPrecisionCovariancesOnGPU){l=new Uint16Array(n.x*n.y*2);for(let h=0;h<this.covariances.length;h++)l[h]=Ce.DataUtils.toHalfFloat(this.covariances[h]);s=new Ce.DataTexture(l,n.x,n.y,Ce.RGFormat,Ce.HalfFloatType)}else l=new Float32Array(n.x*n.y*2),l.set(this.covariances),s=new Ce.DataTexture(l,n.x,n.y,Ce.RGFormat,Ce.FloatType);s.needsUpdate=!0,this.material.uniforms.covariancesTexture.value=s,this.material.uniforms.covariancesTextureSize.value.copy(n);let c=new Uint32Array(a.x*a.y*4);for(let h=0;h<o;h++){let m=h*4,y=h*3,g=h*4;c[g]=nS(this.colors[m],this.colors[m+1],this.colors[m+2],this.colors[m+3]),c[g+1]=fp(this.centers[y]),c[g+2]=fp(this.centers[y+1]),c[g+3]=fp(this.centers[y+2])}let u=new Ce.DataTexture(c,a.x,a.y,Ce.RGBAIntegerFormat,Ce.UnsignedIntType);u.internalFormat="RGBA32UI",u.needsUpdate=!0,this.material.uniforms.centersColorsTexture.value=u,this.material.uniforms.centersColorsTextureSize.value.copy(a);let d=256*4,p=new Float32Array(256*16);for(let h=0;h<this.meshMatrixWorlds.length;h++)p.set(this.meshMatrixWorlds[h].elements,h*16);let f=new Ce.DataTexture(p,d,1,Ce.RGBAFormat,Ce.FloatType);f.needsUpdate=!0,this.material.uniforms.meshMatrixWorldsTexture.value=f,this.material.uniformsNeedUpdate=!0,this.splatDataTextures={covariances:{data:l,texture:s,size:n},centerColors:{data:c,texture:u,size:a},meshMatrixWorlds:{data:p,texture:f}}}updateIndexes(e){let r=this.geometry;r.attributes.splatIndex.set(e),r.attributes.splatIndex.needsUpdate=!0,r.instanceCount=e.length}updateUniforms(e,r,o,n){this.splatCount>0&&(hp.set(e.x*this.devicePixelRatio,e.y*this.devicePixelRatio),this.material.uniforms.viewport.value.copy(hp),this.material.uniforms.basisViewport.value.set(2/hp.x,2/hp.y),this.material.uniforms.focal.value.set(r,o),this.material.uniforms.orthoZoom.value=n,this.material.uniformsNeedUpdate=!0)}getSplatDataTextures(){return this.splatDataTextures}getSplatCount(){return this.splatCount}getCenters(){return this.centers}getColors(){return this.colors}getCovariances(){return this.covariances}dispose(){this.geometry.dispose(),this.material.dispose(),this.splatDataTextures&&(this.splatDataTextures.covariances.texture.dispose(),this.splatDataTextures.centerColors.texture.dispose(),this.splatDataTextures.meshMatrixWorlds.texture.dispose()),this.removeFromParent()}};var sS,sm=new Promise(i=>{sS=i}),aS=!1;var yp;function lm(){if(aS)return;if(yp)return yp;async function i(){let e=await import("./gaussian-splat-compression.js");sS(e),aS=!0}return yp=i(),yp}var lS;sm.then(i=>lS=i);var Sc=class{constructor(t={}){wn(this,"updateView",function(){let t=new vr.Matrix4,e=[],r=new vr.Vector3(0,0,-1),o=new vr.Vector3(0,0,-1),n=new vr.Vector3,a=new vr.Vector3;return function(s=!1,l){let c=this.updateMatrixWorldsInWorkerIfNeeded(),u=this.cropsChanged();if(!s){o.set(0,0,-1).applyQuaternion(l.quaternion);let p=!1,f=!1;if(o.dot(r)<=.95&&(p=!0),a.copy(l.position).sub(n).length()>=1&&(f=!0),!p&&!f&&!c&&!u&&!this.needsInitialRender)return}this.needsInitialRender=!1,n.copy(l.position),r.copy(o),t.copy(l.matrixWorld).invert(),t.premultiply(this.dummyPerspectiveMatrix),e[0]=l.position.x,e[1]=l.position.y,e[2]=l.position.z;let d={sort:{view:t.elements,cameraPosition:e,splatRenderCount:this.splatRenderCount,splatSortCount:this.splatRenderCount},...c?{newMatrixWorlds:this.meshMatrixWorlds}:{},...u?{newCropsArray:this.cropsArray}:{}};this.sortRunning?this.queuedMessage=d:(this.queuedMessage=null,this.sortRunning=!0,this.sortWorker.postMessage(d))}}());this.scene=t.scene,this.currentPage=null,this.devicePixelRatio=window.devicePixelRatio,this.sortWorker=null,this.splatRenderCount=0,this.splatSortCount=0,this.splatMesh=null,this.sortRunning=!1,this.meshMatrixWorlds=null,this.meshMatrixWorldsOld=null,this.cropsArray=null,this.splatEntries=null,this.queuedMessage=null,this.needsInitialRender=!0,this.dummyPerspectiveMatrix=new vr.Matrix4().makePerspective(-1,1,-1,1,.1,1e3)}updateSplatMeshUniforms(t,e){let r=new vr.Vector2;if(this.splatMesh===null)return;this.splatMesh.getSplatCount()>0&&(t.getSize(r),this.cameraFocalLengthX=e.projectionMatrix.elements[0]*this.devicePixelRatio*r.x*.45,this.cameraFocalLengthY=e.projectionMatrix.elements[5]*this.devicePixelRatio*r.y*.45,this.splatMesh.updateUniforms(r,this.cameraFocalLengthX,this.cameraFocalLengthY,e.isPerspectiveCamera?-1:e.zoom*this.devicePixelRatio))}loadSplat(t={}){this.activePage=this.scene.activePage,t.position&&(t.position=new vr.Vector3().fromArray(t.position)),t.orientation&&(t.orientation=new vr.Quaternion().fromArray(t.orientation)),t.halfPrecisionCovariances=!!t.halfPrecisionCovariances;let e=[];if(this.splatEntries=e,this.activePage.traverseVisibleEntity(a=>{a.data.type==="Splat"&&e.push(a)}),this.splatMesh&&this.splatMesh.dispose(),e.length===0)return this.splatMesh=null,!1;this.meshMatrixWorlds=e.map(a=>a.matrixWorld),this.meshMatrixWorldsOld=e.map(a=>a.matrixWorld.clone()),this.cropsArray=e.map(a=>a.data.crops.map(s=>s.data));let r=e.map(a=>new lS.GSplineBuffer(new Uint8Array(a.data.buffer).buffer)),o=0,n=[0];for(let a of r)o+=a.getSplatCount(),n.push(o);return this.setupSplatMesh(r,o,t.position,t.orientation,t.halfPrecisionCovariances,this.devicePixelRatio,n,this.meshMatrixWorlds),this.setupSortWorker(o),!0}updateMatrixWorldsInWorkerIfNeeded(){let t=this.splatDataTextures.meshMatrixWorlds.data;for(let e=0;e<this.meshMatrixWorlds.length;e++)t.set(this.meshMatrixWorlds[e].elements,e*16);return this.splatDataTextures.meshMatrixWorlds.texture.needsUpdate=!0,this.meshMatrixWorlds.every((e,r)=>e.equals(this.meshMatrixWorldsOld[r]))?!1:(this.meshMatrixWorldsOld=this.meshMatrixWorlds.map(e=>e.clone()),!0)}cropsChanged(){let t=!1;return this.splatEntries.forEach((e,r)=>{e.data.crops.forEach((o,n)=>{this.cropsArray[r][n]===void 0?(t=!0,this.cropsArray[r][n]=o.data):Object.entries(o.data).forEach(([a,s])=>{Array.isArray(s)&&s.some((l,c)=>l!==this.cropsArray[r][n][a][c])?(t=!0,this.cropsArray[r][n][a]=s):s!==this.cropsArray[r][n]?.[a]&&(t=!0,this.cropsArray[r][n][a]=s)})}),e.data.crops.length!==this.cropsArray[r]?.length&&(this.cropsArray[r].length=e.data.crops.length,t=!0)}),t}setupSplatMesh(t,e,r=new vr.Vector3,o=new vr.Quaternion,n=!1,a=1,s,l){this.splatMesh=yn.buildMesh(t,e,n,a,s,l),this.splatMesh.position.copy(r),this.splatMesh.quaternion.copy(o),this.splatMesh.frustumCulled=!1,this.splatMesh.renderOrder=99999,this.splatRenderCount=e,this.splatMesh.onBeforeRender=(c,u,d)=>this.update(c,d)}setupSortWorker(t){this.sortWorker=iS(t),this.sortWorker.onmessage=e=>{e.data.sortDone?(this.sortRunning=!1,this.splatMesh?.updateIndexes(new Uint32Array(e.data.indexesBuffer)),this.lastSortTime=e.data.sortTime,this.queuedMessage&&(this.sortWorker.postMessage(this.queuedMessage),this.queuedMessage=null)):e.data.sortCanceled?this.sortRunning=!1:e.data.sortSetupPhase1Complete?this.sortWorker.postMessage({positions:this.splatMesh.getCenters().buffer,meshMatrixWorlds:this.splatMesh.meshMatrixWorlds,meshIndexIntervals:this.splatMesh.meshIndexIntervals,cropsArray:this.cropsArray}):e.data.sortSetupComplete&&(this.splatDataTextures=this.splatMesh.getSplatDataTextures(),this.scene.activePage.add(this.splatMesh),this.needsInitialRender=!0)}}update(t,e){this.splatMesh!==null&&(this.updateSplatMeshUniforms(t,e),this.updateView(!1,e))}getSplatMesh(){return this.splatMesh}};var VE=new oo.MeshBasicMaterial;VE.wireframe=!0;var cS=new oo.Vector3,gp=class extends oo.Scene{constructor(e,r){super();this.data=e;this.sharedAssets=r;this.enableHelpers=!1;this.wireframeState=!1;this.needsTransmissionDirty=!0;this.needsNormalDirty=!0;this._needsTransmission=!1;this._needsNormal=!1;this.geometryCacheChanged=!1;this.splatViewer=null;this.shapeBlendIntances=[];this.entityByUuid={};this.entityIdentityToEntity={};this.toExpandCloner=new Set;this.toUpdateCloner=new Set;this.pendingCommands=[];this.pathConstraints=new pp;this.invisibleObjects=new ln("jflkdsafjasdifjaslk",{...Du.defaultData,visible:!1,name:"buildin invisible"});this.needsRecomputeInstances=!1;this.init(e,r),this.matrixAutoUpdate=!1,this.errorPage=new to("fdasfa",{...ni.defaultData,name:""},{shared:r,scene:this})}markGeometryCacheDirty(){this.geometryCacheChanged=!0}markNeedsUpdateRendererDirty(){this.needsTransmissionDirty=!0,this.needsNormalDirty=!0}needsTransmission(){return this.needsTransmissionDirty&&(this._needsTransmission=rS(this),this.needsTransmissionDirty=!1),this._needsTransmission}needsNormal(){return this.needsNormalDirty&&(this._needsNormal=tS(this),this.needsNormalDirty=!1),this._needsNormal}registerInstanceAndSetUuid(e){let r=e.identity.join("-"),o=this.entityIdentityToEntity[r];o&&(e.uuid=o.uuid),this.entityIdentityToEntity[r]=e,this.entityByUuid[e.uuid]=e}markPenumbraSizeDirty(){for(let e of this.children)e instanceof to&&(e.penumbraSizeArrayCache=null)}findInstance(e){return this.entityIdentityToEntity[e.join("-")]}get bgColor(){return this.activePage.bgColor}get postprocessing(){return this.activePage.data.postprocessing}getWithSortKey(e){let r=this.find(e);if(r===void 0)return;let o=[],n=r;for(;n!==this;){let a=n;n=n.parent;let s=n.children.indexOf(a);o.splice(0,0,s)}return{entity:r,sortKey:o}}getAllSorted(e){let r=[];for(let o of e){let n=this.getWithSortKey(o.id);n!==void 0&&r.push(n)}return r.sort((o,n)=>Au(o.sortKey,n.sortKey)),r.map(o=>o.entity)}nonExistOrDescendantOf(e,r){let o=this.find(e);if(o===void 0)return!0;for(;o;){if(o.uuid===r)return!0;o=o.parent}return!1}find(e){if(this.activePage&&this.activePage.personalCamera.parent){if(e==="f23858d0-4a3b-4bd8-8173-66ed0af7f6fb-personalCamera")return this.activePage.personalCamera;if(e===zi)return this.activePage.personalCamera}if(e===""||e===void 0)return;let r=this.entityByUuid[e];return r===void 0?this.getObjectByProperty("uuid",e):r}find2D(e){for(let r of this.children)if(r instanceof to&&r.uiScene){let o=r.uiScene.find(e);if(o)return o}}findScene2DfromObject2D(e){for(let r of this.children)if(r instanceof to&&r.uiScene&&r.uiScene.find(e))return r.uiScene}find2DInUIObjects(e){let r;return this.traverseEntity(o=>{r===void 0&&o instanceof Zn&&(r=o.uiCanvas.find(e))}),r}traverse2D(e){for(let r of this.children)r instanceof to&&r.uiScene&&r.uiScene.traverse(e)}debugEnsureEntity(e){let r=this.find(e);if(r){if(Array.isArray(r.identity)&&this.findInstance(r.identity)===void 0){console.error("not found instance");debugger}}else{console.error("not found");debugger}}addPendingExpandCloner(e){this.toExpandCloner.add(e)}addPendingUpdateCloner(e){this.toUpdateCloner.add(e)}markToExpandCloner(e){this.toExpandCloner.add(e),e.traverseEntityAncestors(r=>{this.toExpandCloner.add(r)})}doPendingExpandCloner(e){this.toExpandCloner.forEach(r=>{r.expandCloner(e)}),this.toExpandCloner.clear()}doPendingUpdateCloner(e){this.toUpdateCloner.forEach(r=>{r.cloner?.update(e)}),this.toUpdateCloner.clear()}doPendingUpdates(e){this.doPendingExpandCloner(e),this.doPendingUpdateCloner(e),this.applyPendingCommands()}addPendingCommand(e){this.pendingCommands.push(e)}applyPendingCommands(){this.pendingCommands.forEach(e=>e()),this.pendingCommands.length=0}updateByLibOp(e,r){e.path.length===1&&e.path[0]==="components"&&e.type===1&&this.createChildrenObjects([{...e.data.asset,id:e.id}],this.invisibleObjects,r)}updateTreeByOp(e,r){if(e.path.length===0&&e.type===7){let o=e.parent===null?this:this.find(e.parent);if(o===void 0)throw new Error("unexpected");let n=this.createObject(e.id,e.data,e.children,o,e.localIndex,r);n.updateVisible(this),n.resetBBoxNeedsUpdate(),sn(n)&&dc(n.parent)&&(n.invalidateUpstreamBooleanData(),n.parent.invalidateDownstreamBooleanData().recomputeBoolean()),this.markNeedsRecomputeInstancesForAncessors(o),this.markNeedsRecomputeInstancesForChildren(n),this.markToExpandCloner(n),this.markPenumbraSizeDirty(),n.updatePathSnapping()}else if(e.path.length===0&&e.type===8){let o=this.find(e.id);if(o===void 0)throw new Error("unexpected");o.traverseEntity(a=>{a instanceof fn&&(this.shapeBlendIntances=this.shapeBlendIntances.filter(s=>s!==a))}),this.markToExpandCloner(o),o.resetBBoxNeedsUpdate(),this.unregisterObject(o);let n=o.parent;this.markNeedsRecomputeInstancesForAncessors(n),this.markNeedsRecomputeInstancesForChildren(o),this.markPenumbraSizeDirty(),o.parent.remove(o),dc(o.parent)&&(o.parent.invalidateUpstreamBooleanData(),o.parent.invalidateDownstreamBooleanData().recomputeBoolean()),sn(o)&&(o.freeBooleanPointer(),n instanceof Nr&&n.invalidateDownstreamBooleanData().recomputeBoolean()),o instanceof Qs&&o.detachShape(),this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(o),this.pathConstraints.removeDependencies(o.uuid),o.updatePathSnapping()}else if(e.path.length===0&&e.type===9){let o=this.find(e.id);if(o===void 0)throw new Error("unexpected");this.markNeedsRecomputeInstancesForChildren(o);let n=o.parent;this.markNeedsRecomputeInstancesForAncessors(n),o.cloner?.resetOnMove(),this.markToExpandCloner(o);let a=e.parent===null?this:this.find(e.parent);if(a===void 0)throw new Error("unexpected");a.add(o),this.markNeedsRecomputeInstancesForAncessors(a),this.markToExpandCloner(o),o.invalidateClonerTransform(o),o.updateVisible(this),o.resetBBoxNeedsUpdate(),this.markPenumbraSizeDirty();let s=e.localIndex;a.children.splice(s,0,a.children.pop()),sn(o)&&(o.invalidateUpstreamBooleanData(),dc(o.parent)?o.parent.invalidateDownstreamBooleanData().recomputeBoolean():n instanceof Nr&&n.invalidateDownstreamBooleanData().recomputeBoolean()),o.updatePathSnapping()}this.markNeedsUpdateRendererDirty(),this.markGeometryCacheDirty()}get playPage(){return this.find(this.data.publish.playPage)??this.errorPage}updatePage(e){this.activePage&&this.activePage.onDeactive(),this.activePage=this.errorPage;for(let r of this.children)r instanceof to&&(r.visible=r.uuid===e,r.visible&&(this.activePage=r,this.activePage.onActive(this)));this.activePage!==this.splatViewer?.activePage&&this.reloadSplats()}updateEntityByOp(e,r,o,n){if(r.type===0){if(("overrides"in r.props||"component"in r.props)&&this.markNeedsRecomputeInstances(),"visible"in r.props&&this.markPenumbraSizeDirty(),r.path.includes("overrides")&&"states"in r.props){let{rest:s}=r.props;r={...r,props:s},this.markNeedsRecomputeInstances()}r.path[0]==="pathSnapping"&&r.props.pathId!==void 0&&this.pathConstraints.setConstraint(e,r.props.pathId)}let a=this.find(e);if(a)try{Y1(a,r,o,{scene:this,shared:n}),a instanceof ht&&a.updateGeometryGroupsIfNeeded()}catch(s){console.error(s)}}updateEntity2DByOp(e,r,o,n,a,s=[]){e.updateEntityByOp(r,o,n,a),this.traverseEntity(l=>{(l instanceof Zn||l instanceof to)&&(s.includes(l.frameId??"")||l.frameId===r)&&l.updateEntity2DByOp(r,o,n,a)})}get activeCamera(){return this.activePage.activeCamera}switchActiveCamera(e){this.activePage.switchActiveCamera(e)}isInvisibleObjects(e){return e===this.invisibleObjects||e.hasAnccestor(this.invisibleObjects)}init(e,r){let o=Object.entries(r.data.lib.components).map((n,a)=>({data:n[1].asset.data,children:n[1].asset.children,id:n[0],fi:a}));this.invisibleObjects.updateState(this.invisibleObjects.data,{scene:this,shared:r}),this.add(this.invisibleObjects),this.createChildrenObjects(o,this.invisibleObjects,r),this.createChildrenObjects(e.objects,this,r),this.updatePage(e.publish.playPage),this.activePage.switchToPlayCamera(),this.expandInstances(r,!0),this.traverseEntity(n=>{n instanceof Si&&n.updateUp()}),this.doPendingExpandCloner({scene:this,shared:r}),this.applyPendingCommands()}markNeedsRecomputeInstances(){this.needsRecomputeInstances=!0}markNeedsRecomputeInstancesForChildren(e){e.traverseEntity(r=>{(r.data.type==="Component"||r.data.type==="Instance")&&this.markNeedsRecomputeInstances()})}markNeedsRecomputeInstancesForAncessors(e){Ge.is(e)&&(e.data.type==="Component"&&this.markNeedsRecomputeInstances(),e.traverseAncestors(r=>{Ge.is(r)&&r.data.type==="Component"&&this.markNeedsRecomputeInstances()}))}relativeizeInner(e,r,o,n,a,s,l){if(e){let c=n.find(e);c&&c!==n&&a.forInstancesRec(u=>{u.data=Di(u.data,d=>{let p=d.events.data(l.id),f=u.goUp(s);if(f){let h=[...Cu(f.identity),e].join("-"),m=this.entityIdentityToEntity[h];if(m){let y=m.uuid,g=dt.zoom(p,r);g[o]=y}else{if(!1)debugger;console.warn("cannot find instance")}}}).data})}}rewriteActions(e,r,o,n,a,s){e.forEach(l=>{l.data.type==="Transition"?this.relativeizeInner(l.data.object,[...r,l.id],"object",o,n,a,s):l.data.type==="Animation"?this.relativeizeInner(l.data.object,[...r,l.id],"object",o,n,a,s):l.data.type==="Conditional"&&(this.rewriteActions(l.data.ifActions,[...r,l.id,"ifActions"],o,n,a,s),this.rewriteActions(l.data.elseActions,[...r,l.id,"elseActions"],o,n,a,s))})}rewriteEventsBeforeGoToPlayMode(){this.traverseEntity(e=>{if(e instanceof Oi&&typeof e.identity=="string"&&e.data.type==="Component")return e.traverseEntity((r,o)=>{r.data.events.forEach(n=>{if(n.data.type==="GameControl"){let a=!1;if(r.forInstancesRec(s=>{s.data=Di(s.data,l=>{s.isInstanceRoot||(l.events.delete(n.id),a=!0)}).data}),a===!1)for(let s of Bu.list)this.rewriteActions(n.data.gameActions[s],["gameActions",s],e,r,o,n)}else n.data.type==="Conditional"?(n.data.condition.type==="Distance"?(this.relativeizeInner(n.data.condition.fromObject,["condition"],"fromObject",e,r,o,n),this.relativeizeInner(n.data.condition.toObject,["condition"],"toObject",e,r,o,n)):n.data.condition.type==="State"?this.relativeizeInner(n.data.condition.object,["condition"],"object",e,r,o,n):n.data.condition.type==="Comparison"&&(n.data.condition.lOperand.type==="Property"&&this.relativeizeInner(n.data.condition.lOperand.value[0],["condition","lOperand","value"],0,e,r,o,n),n.data.condition.rOperand.type==="Property"&&this.relativeizeInner(n.data.condition.rOperand.value[0],["condition","rOperand","value"],0,e,r,o,n)),this.rewriteActions(n.data.inActions,["inActions"],e,r,o,n),this.rewriteActions(n.data.outActions,["outActions"],e,r,o,n)):"actions"in n.data&&this.rewriteActions(n.data.actions,["actions"],e,r,o,n)})}),!0})}expandInstances(e,r,o){let n=new Set;this.traverseEntity(a=>{if(a instanceof Oi&&a.isInstanceRoot)return a.expandInstanceChildren({scene:this,shared:e,pendingDeletes:n}),r||a.resetBBoxNeedsUpdate(),o&&a.traverseEntity(s=>{o.addClip(s)}),!0});for(let a of n)this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(a),np(a)}recomputeInstances(e,r){this.needsRecomputeInstances&&(this.needsRecomputeInstances=!1,this.traverseEntity(o=>{o instanceof Oi&&o.isInstanceRoot&&(o.component=void 0)}),this.expandInstances(e,!1,r))}disposeAndUnregisterEntityRecursivelyIfNotReregistered(e){e.traverseEntity(r=>{let o=typeof r.identity=="string"?r.identity:r.identity.join("-");this.entityIdentityToEntity[o]===r&&(delete this.entityByUuid[r.uuid],delete this.entityIdentityToEntity[o]),r.dispose()})}clearScene(){for(let e of this.children)Ge.is(e)&&e.disposeRecursively();this.children.length=0}resetAfterClear(e,r){this.init(e,r)}raycast(e){return this.raycast1(e,!1)}raycast1(e,r){let o=[],n=a=>{for(let s of a.children){let l=s.cloner;if(Ge.is(s)&&!s.raycastLock&&(s.visible||l?.object.data.visible))if(r===!0&&s.isInstanceRoot){let c=[];if(e.intersectObject(s,!0,c),c.length){let u=c[0];u.object=s,u.point.applyMatrix4(u.object.matrixWorld);let d=s.matrixWorld.clone().invert();u.point.applyMatrix4(d),o.push(u)}}else(sn(s)||pc(s)&&this.enableHelpers&&s.objectHelper.visible)&&(e.intersectObject(s,!1,o),bc(s,e,o)),n(s)}};return n(this.activePage),o}raycastWithClones(e){let r=[],o=n=>{for(let a of n.children){let s=a.cloner;Ge.is(a)&&(a.visible||s?.object.data.visible)&&((sn(a)||pc(a)&&this.enableHelpers&&a.objectHelper.visible)&&(e.intersectObject(a,!1,r),bc(a,e,r,!0)),o(a))}};return o(this),r}forEachEntity(e){for(let r of this.children)Ge.is(r)&&e(r)}traverseConcreteEntity(e){for(let r of this.children)Ge.is(r)&&r.isConcreteEntity&&r.traverseEntity(e)}traverseEntity(e){for(let r of this.children)Ge.is(r)&&r.traverseEntity(e)}updateFont(e,r){this.traverseEntity(o=>{if(o instanceof ht&&o.data.type==="Mesh"&&(o.data.geometry.type==="TextGeometry"||o.data.geometry.type==="InputGeometry")&&o.data.geometry.font===e){let n=o.geometry,a=o.data.geometry;n.updateFont(e,r).then(()=>{n.update(a,r);let s=o.invalidateDownstreamBooleanData();dc(s)&&s.recomputeBoolean()})}})}traverseObject(e){for(let r of this.children)di.is(r)&&r.traverseObject(e)}traverseVisibleEntity(e){for(let r of this.children)Ge.is(r)&&r.visible&&r.traverseVisibleEntity(e)}dispose(){this.clearScene()}createChildrenObjects(e,r,o){let n=0;for(let a of e)this.createObject(a.id,a.data,a.children,r,n,o),n+=1}registerObjectCreatedInLegacy(e){this.entityByUuid[e.uuid]=e}unregisterObject(e){delete this.entityByUuid[e.uuid];for(let r of e.children)this.unregisterObject(r)}createObject(e,r,o,n,a,s){let l={scene:this,shared:s},c=cp(e,r,l);return c instanceof fn&&this.shapeBlendIntances.push(c),c&&(this.entityByUuid[e]=c,n.add(c),n.children.splice(a,0,n.children.pop()),o.length>0&&(c.isInstanceRoot?console.error("instance should not have children!"):this.createChildrenObjects(o,c,s)),c.updateState(r,l),c instanceof ht&&c.updateGeometryGroupsIfNeeded(),c.updateVisible(this),c.cloner&&this.toExpandCloner.add(c),r.pathSnapping?.pathId&&this.pathConstraints.setConstraint(e,r.pathSnapping.pathId)),r.type==="Empty"&&r.animations&&c.traverseEntity(u=>{let d=u.dataPatched;if(u instanceof ht&&d.bones&&d.boneInverses){let p=d.bones.map(m=>this.find(m)),f=d.boneInverses.map(m=>new oo.Matrix4().fromArray(m)),h=new oo.Skeleton(p,f);u.bind(h,u.bindMatrix)}else u.matrixAutoUpdate=!0}),c}getCenter(e){let r=[];for(let n=0,a=e.length;n<a;++n){let{id:s,recursive:l}=e[n],c=this.find(s),u=l?c.recursiveBBox:c.singleBBox;r.push(...u.vertices)}let o=new oo.Box3;return o.setFromPoints(r),o.getCenter(cS),cS}copyMatrixWorld(e,r){if(e===null){r.identity();return}let o=this.find(e);o?r.copy(o.matrixWorld):r.identity()}copyParentMatrixWorld(e,r){if(e===null){r.identity();return}let o=this.find(e)?.parent;o?r.copy(o.matrixWorld):r.identity()}traverseMaterial(e){this.traverseEntity(r=>{if(r instanceof $t)if(Array.isArray(r.material))for(let o=0;o<r.material.length;o++)r.material[o]instanceof Ir&&e(r.material[o]);else r.material instanceof Ir&&e(r.material)})}updateViewPlaneSize(e,r,o=!1){this.traverseConcreteEntity(n=>{n instanceof Si&&n.setViewplaneSize(e,r,o)})}initializeSplatViewer(){this.splatViewer=new Sc({scene:this}),this.reloadSplats()}reloadSplats(){this.splatViewer?.loadSplat()}};var uS=require("three/examples/jsm/loaders/DRACOLoader.js");var gn;function dS(i){return gn||(gn=new uS.DRACOLoader,gn.setDecoderPath(i!==void 0?`${i}/`:"https://www.gstatic.com/draco/versioned/decoders/1.5.2/").preload()),gn.decoderPending}async function zE(i){if(gn){let t={attributeIDs:gn.defaultAttributeIDs,attributeTypes:gn.defaultAttributeTypes,useUniqueIDs:!1},e;try{e=await gn.decodeGeometry(new Int8Array(i).buffer,t)}catch(r){console.error(r)}if(e)return{index:e.index?{array:e.index.array}:void 0,attributes:Object.entries(e.attributes).map(([r,o])=>({name:r,itemSize:o.itemSize,array:o.array}))}}return null}async function pS(i,t){let[e,r]=kp(yu.deserialize(new Uint8Array(i)));return Gu(e),t&&t(e),r.result().data}function fS(i){let t=[];return i.scene.objects.traverse((e,r)=>{r.type==="Mesh"&&r.geometry.type==="NonParametricGeometry"&&r.geometry.data.draco!==void 0&&t.push(r)}),t}async function hS(i){for(let t of i){let e=await zE(t.geometry.data.draco);if(e){let r=t.geometry.data;e.index&&(r.index={array:e.index.array,itemSize:1,normalized:!1,type:"Uint32Array"});let o={};e.attributes.forEach(({name:n,array:a,itemSize:s})=>{o[n]={array:a,itemSize:s,type:"Float32Array",normalized:!1}}),r.attributes=o,r.draco=void 0}}}var GE=require("three"),FE=require("three/examples/jsm/utils/BufferGeometryUtils.js");function mS(i){let t;if(!!i.index)for(let e=0;e<i.index.array.length;e+=3)t=i.index.array[e],i.index.array[e]=i.index.array[e+2],i.index.array[e+2]=t}var wc=require("three");function yS(i){let t=new Set;return i.traverse(e=>{if(e instanceof Er)if(Mt(e.material))e.material.forEach(r=>{let o=r;t.has(o)||t.add(o)});else{let r=e.material;t.has(r)||t.add(r)}}),t.forEach(e=>{if(e instanceof Array)return;let r=e.onBeforeCompile.bind(e);if(jE(e)){Object.assign(e,{isMeshStandardMaterial:!0,isMeshPhysicalMaterial:!0,transmission:1,attenuationColor:new wc.Color,specularColor:new wc.Color});let o=0;e.onBeforeCompile=(n,a)=>{r&&r(n,a),n.uniforms=Object.assign({},wc.ShaderLib.physical.uniforms,n.uniforms),e.getLayersOfType("transmission").forEach(s=>{if(n.uniforms.transmissionSamplerMap.value){let l=s.color;l&&(l.transmissionSamplerMap.value=n.uniforms.transmissionSamplerMap.value,l.transmissionSamplerSize.value=n.uniforms.transmissionSamplerSize.value,l.aspectRatio.value=Qb(window.innerWidth,window.innerHeight),e.defines.IS_THREEJS_EXPORT=!0)}else o++,o<2&&(e.needsUpdate=!0)})}}else UE(e)||(e.onBeforeCompile=(o,n)=>{r&&r(o,n),e.transparent=!1})}),i}function jE(i){return i.getLayersOfType("transmission").length>0}function UE(i){let t=0;for(let e of i.layers){if(e.data.type!=="displace"&&e.data.isMask)return!0;if(e.type!=="light"&&e.type!=="fresnel"){let o=e.uniforms["f"+e.id+"_alpha"];o&&(t+=(1-t)*o.value)}}return t<1}function gS(i){return i.traverse(t=>{if(t.type==="Camera"){let e=t;e.type=e.cameraType}}),i}function xS(i){let t=[],e=(r,o=0)=>{let n=o>0?r+o:r;return t.includes(n)?e(r,o+1):n};return i.traverse(r=>{if(t.includes(r.name)){let o=r.name,n=e(r.name);if(r.name=n,r.isMesh){let a=r;a.material instanceof Array?a.material.forEach(s=>{s.name=s.name.replace(o,n)}):a.material.isAsset||(a.material.name=a.material.name.replace(o,n))}}t.push(r.name)}),i}var bS=require("three/examples/jsm/utils/BufferGeometryUtils.js");function vS(i){let t=[];return i.traverse(e=>{e instanceof nn&&t.push(e)}),t.forEach(e=>{let r=e.object,a=[...e.children.map(s=>{s.updateMatrix();let l;if(s.geometry!==void 0)try{l=s.geometry.clone().applyMatrix4(s.matrix)}catch(c){console.error(c)}return l!==void 0&&s.matrix.determinant()<0&&mS(l),l}).filter(s=>s!==void 0)];if(!e.parameters.hideBase&&r instanceof $t&&a.unshift(r.geometry),a.length){let s=(0,bS.mergeBufferGeometries)(a);r instanceof $t&&(r.geometry=s)}e.removeFromParent(),r.setFromClonerState(null,{scene:i,shared:mv})}),i}function SS(i){return i.traverse(t=>{t.matrixAutoUpdate=!0}),i}function wS(i){Object.values(i.shared.materials).forEach(t=>{cm(t)}),i.scene.objects.traverse((t,e)=>{"material"in e?cm(e.material):"materials"in e&&e.materials.forEach(r=>{cm(r)})})}function cm(i){if(typeof i=="string")return;let t=[];i.layers.forEach((e,r)=>{e.type==="outline"&&t.push(r)}),t.reverse().forEach(e=>{i.layers.delete(e)}),t.length&&console.warn("The Spline Loader currently does not support the outline layer.")}var CS=ll(OS(),1);var TS="The SplineLoader only accepts .splinecode files that are generated from Spline export panel.",xp=class extends bp.Loader{load(t,e,r,o=console.error){let n=new bp.FileLoader(this.manager);n.setPath(this.path),n.setResponseType("arraybuffer"),n.setRequestHeader(this.requestHeader),n.setWithCredentials(this.withCredentials),t.endsWith(".spline")?console.warn(TS+" The .spline files are only meant to be used by the Editor."):t.endsWith(".splinecode")||console.warn(TS),n.load(t,async a=>{try{if(typeof a=="string")throw new Error("The .spline file is not binary!");let s=await this.parse(a);e(s)}catch(s){o(s)}},r,o)}async parse(t){let e=await pS(t,wS),r=fS(e);e.version&&(0,CS.default)(e.version,"1.12.87")>0&&console.warn("Your .splinecode file is more recent than the library. Please upgrade @splinetool/loader to the latest version."),await Promise.allSettled([r.length&&dS(),vv(e)&&Ob(),Ev(e)&&lv(),u1(e)&&s1(),mp(e)&&lm()].filter(Boolean)),r.length&&await hS(r);let o=!1,n=new $n(e.shared,{},o);Object.values(n.getMaterials()).forEach(l=>Object.assign(l,{isAsset:!0}));let a=new gp(e.scene,n);mp(e)&&a.initializeSplatViewer();let s=a.activeCamera;return s&&Object.assign(s,{makeDefault:!0}),a=vS(a),a=yS(a),a=gS(a),a=xS(a),a=SS(a),a}};
4379
+ }`,n={covariancesTexture:{type:"t",value:null},centersColorsTexture:{type:"t",value:null},meshIndexIntervals:{value:e},meshMatrixWorldsTexture:{type:"t",value:null},focal:{type:"v2",value:new Ce.Vector2},viewport:{type:"v2",value:new Ce.Vector2},basisViewport:{type:"v2",value:new Ce.Vector2},debugColor:{type:"v3",value:new Ce.Color},covariancesTextureSize:{type:"v2",value:new Ce.Vector2(1024,1024)},centersColorsTextureSize:{type:"v2",value:new Ce.Vector2(1024,1024)},orthoZoom:{type:"f",value:-1}};return new Ce.ShaderMaterial({uniforms:n,vertexShader:r,fragmentShader:o,transparent:!0,alphaTest:1,blending:Ce.NormalBlending,depthTest:!0,depthWrite:!1,side:Ce.DoubleSide})}static buildGeomtery(e){let r=new Ce.BufferGeometry;r.setIndex([0,1,2,0,2,3]);let o=new Float32Array(4*3),n=new Ce.BufferAttribute(o,3);r.setAttribute("position",n),n.setXYZ(0,-1,-1,0),n.setXYZ(1,-1,1,0),n.setXYZ(2,1,1,0),n.setXYZ(3,1,-1,0),n.needsUpdate=!0;let a=new Ce.InstancedBufferGeometry().copy(r),s=new Uint32Array(e),l=new Ce.InstancedBufferAttribute(s,1,!1);return l.setUsage(Ce.DynamicDrawUsage),a.setAttribute("splatIndex",l),a.instanceCount=e,a}resetLocalSplatDataAndTexturesFromSplatBuffer(){this.updateLocalSplatDataFromSplatBuffer(),this.allocateAndStoreLocalSplatDataInTextures()}updateLocalSplatDataFromSplatBuffer(){this.splatBuffers.forEach(n=>n.buildPreComputedBuffers()),this.covariances=new Float32Array(this.splatCount*6),this.colors=new Uint8Array(this.splatCount*4),this.centers=new Float32Array(this.splatCount*3);let e=0,r=0,o=0;for(let n of this.splatBuffers){let a=n.nsplats;this.colors.subarray(e,e+a*4).set(n.colorsA),e+=a*4,this.centers.subarray(r,r+a*3).set(n.decoded.xyz.denormDequant().data),r+=a*3,this.covariances.subarray(o,o+a*6).set(new Float32Array(n.precomputedCovarianceBufferData)),o+=a*6}}allocateAndStoreLocalSplatDataInTextures(){let o=this.splatCount,n=new Ce.Vector2(4096,1024);for(;n.x*n.y*2<o*6;)n.y*=2;let a=new Ce.Vector2(4096,1024);for(;a.x*a.y*4<o*4;)a.y*=2;let s,l;if(this.halfPrecisionCovariancesOnGPU){l=new Uint16Array(n.x*n.y*2);for(let h=0;h<this.covariances.length;h++)l[h]=Ce.DataUtils.toHalfFloat(this.covariances[h]);s=new Ce.DataTexture(l,n.x,n.y,Ce.RGFormat,Ce.HalfFloatType)}else l=new Float32Array(n.x*n.y*2),l.set(this.covariances),s=new Ce.DataTexture(l,n.x,n.y,Ce.RGFormat,Ce.FloatType);s.needsUpdate=!0,this.material.uniforms.covariancesTexture.value=s,this.material.uniforms.covariancesTextureSize.value.copy(n);let c=new Uint32Array(a.x*a.y*4);for(let h=0;h<o;h++){let m=h*4,y=h*3,g=h*4;c[g]=nS(this.colors[m],this.colors[m+1],this.colors[m+2],this.colors[m+3]),c[g+1]=fp(this.centers[y]),c[g+2]=fp(this.centers[y+1]),c[g+3]=fp(this.centers[y+2])}let u=new Ce.DataTexture(c,a.x,a.y,Ce.RGBAIntegerFormat,Ce.UnsignedIntType);u.internalFormat="RGBA32UI",u.needsUpdate=!0,this.material.uniforms.centersColorsTexture.value=u,this.material.uniforms.centersColorsTextureSize.value.copy(a);let d=256*4,p=new Float32Array(256*16);for(let h=0;h<this.meshMatrixWorlds.length;h++)p.set(this.meshMatrixWorlds[h].elements,h*16);let f=new Ce.DataTexture(p,d,1,Ce.RGBAFormat,Ce.FloatType);f.needsUpdate=!0,this.material.uniforms.meshMatrixWorldsTexture.value=f,this.material.uniformsNeedUpdate=!0,this.splatDataTextures={covariances:{data:l,texture:s,size:n},centerColors:{data:c,texture:u,size:a},meshMatrixWorlds:{data:p,texture:f}}}updateIndexes(e){let r=this.geometry;r.attributes.splatIndex.set(e),r.attributes.splatIndex.needsUpdate=!0,r.instanceCount=e.length}updateUniforms(e,r,o,n){this.splatCount>0&&(hp.set(e.x*this.devicePixelRatio,e.y*this.devicePixelRatio),this.material.uniforms.viewport.value.copy(hp),this.material.uniforms.basisViewport.value.set(2/hp.x,2/hp.y),this.material.uniforms.focal.value.set(r,o),this.material.uniforms.orthoZoom.value=n,this.material.uniformsNeedUpdate=!0)}getSplatDataTextures(){return this.splatDataTextures}getSplatCount(){return this.splatCount}getCenters(){return this.centers}getColors(){return this.colors}getCovariances(){return this.covariances}dispose(){this.geometry.dispose(),this.material.dispose(),this.splatDataTextures&&(this.splatDataTextures.covariances.texture.dispose(),this.splatDataTextures.centerColors.texture.dispose(),this.splatDataTextures.meshMatrixWorlds.texture.dispose()),this.removeFromParent()}};var sS,sm=new Promise(i=>{sS=i}),aS=!1;var yp;function lm(){if(aS)return;if(yp)return yp;async function i(){let e=await import("./gaussian-splat-compression.js");sS(e),aS=!0}return yp=i(),yp}var lS;sm.then(i=>lS=i);var Sc=class{constructor(t={}){wn(this,"updateView",function(){let t=new vr.Matrix4,e=[],r=new vr.Vector3(0,0,-1),o=new vr.Vector3(0,0,-1),n=new vr.Vector3,a=new vr.Vector3;return function(s=!1,l){let c=this.updateMatrixWorldsInWorkerIfNeeded(),u=this.cropsChanged();if(!s){o.set(0,0,-1).applyQuaternion(l.quaternion);let p=!1,f=!1;if(o.dot(r)<=.95&&(p=!0),a.copy(l.position).sub(n).length()>=1&&(f=!0),!p&&!f&&!c&&!u&&!this.needsInitialRender)return}this.needsInitialRender=!1,n.copy(l.position),r.copy(o),t.copy(l.matrixWorld).invert(),t.premultiply(this.dummyPerspectiveMatrix),e[0]=l.position.x,e[1]=l.position.y,e[2]=l.position.z;let d={sort:{view:t.elements,cameraPosition:e,splatRenderCount:this.splatRenderCount,splatSortCount:this.splatRenderCount},...c?{newMatrixWorlds:this.meshMatrixWorlds}:{},...u?{newCropsArray:this.cropsArray}:{}};this.sortRunning?this.queuedMessage=d:(this.queuedMessage=null,this.sortRunning=!0,this.sortWorker.postMessage(d))}}());this.scene=t.scene,this.currentPage=null,this.devicePixelRatio=window.devicePixelRatio,this.sortWorker=null,this.splatRenderCount=0,this.splatSortCount=0,this.splatMesh=null,this.sortRunning=!1,this.meshMatrixWorlds=null,this.meshMatrixWorldsOld=null,this.cropsArray=null,this.splatEntries=null,this.queuedMessage=null,this.needsInitialRender=!0,this.dummyPerspectiveMatrix=new vr.Matrix4().makePerspective(-1,1,-1,1,.1,1e3)}updateSplatMeshUniforms(t,e){let r=new vr.Vector2;if(this.splatMesh===null)return;this.splatMesh.getSplatCount()>0&&(t.getSize(r),this.cameraFocalLengthX=e.projectionMatrix.elements[0]*this.devicePixelRatio*r.x*.45,this.cameraFocalLengthY=e.projectionMatrix.elements[5]*this.devicePixelRatio*r.y*.45,this.splatMesh.updateUniforms(r,this.cameraFocalLengthX,this.cameraFocalLengthY,e.isPerspectiveCamera?-1:e.zoom*this.devicePixelRatio))}loadSplat(t={}){this.activePage=this.scene.activePage,t.position&&(t.position=new vr.Vector3().fromArray(t.position)),t.orientation&&(t.orientation=new vr.Quaternion().fromArray(t.orientation)),t.halfPrecisionCovariances=!!t.halfPrecisionCovariances;let e=[];if(this.splatEntries=e,this.activePage.traverseVisibleEntity(a=>{a.data.type==="Splat"&&e.push(a)}),this.splatMesh&&this.splatMesh.dispose(),e.length===0)return this.splatMesh=null,!1;this.meshMatrixWorlds=e.map(a=>a.matrixWorld),this.meshMatrixWorldsOld=e.map(a=>a.matrixWorld.clone()),this.cropsArray=e.map(a=>a.data.crops.map(s=>s.data));let r=e.map(a=>new lS.GSplineBuffer(new Uint8Array(a.data.buffer).buffer)),o=0,n=[0];for(let a of r)o+=a.getSplatCount(),n.push(o);return this.setupSplatMesh(r,o,t.position,t.orientation,t.halfPrecisionCovariances,this.devicePixelRatio,n,this.meshMatrixWorlds),this.setupSortWorker(o),!0}updateMatrixWorldsInWorkerIfNeeded(){let t=this.splatDataTextures.meshMatrixWorlds.data;for(let e=0;e<this.meshMatrixWorlds.length;e++)t.set(this.meshMatrixWorlds[e].elements,e*16);return this.splatDataTextures.meshMatrixWorlds.texture.needsUpdate=!0,this.meshMatrixWorlds.every((e,r)=>e.equals(this.meshMatrixWorldsOld[r]))?!1:(this.meshMatrixWorldsOld=this.meshMatrixWorlds.map(e=>e.clone()),!0)}cropsChanged(){let t=!1;return this.splatEntries.forEach((e,r)=>{e.data.crops.forEach((o,n)=>{this.cropsArray[r][n]===void 0?(t=!0,this.cropsArray[r][n]=o.data):Object.entries(o.data).forEach(([a,s])=>{Array.isArray(s)&&s.some((l,c)=>l!==this.cropsArray[r][n][a][c])?(t=!0,this.cropsArray[r][n][a]=s):s!==this.cropsArray[r][n]?.[a]&&(t=!0,this.cropsArray[r][n][a]=s)})}),e.data.crops.length!==this.cropsArray[r]?.length&&(this.cropsArray[r].length=e.data.crops.length,t=!0)}),t}setupSplatMesh(t,e,r=new vr.Vector3,o=new vr.Quaternion,n=!1,a=1,s,l){this.splatMesh=yn.buildMesh(t,e,n,a,s,l),this.splatMesh.position.copy(r),this.splatMesh.quaternion.copy(o),this.splatMesh.frustumCulled=!1,this.splatMesh.renderOrder=99999,this.splatRenderCount=e,this.splatMesh.onBeforeRender=(c,u,d)=>this.update(c,d)}setupSortWorker(t){this.sortWorker=iS(t),this.sortWorker.onmessage=e=>{e.data.sortDone?(this.sortRunning=!1,this.splatMesh?.updateIndexes(new Uint32Array(e.data.indexesBuffer)),this.lastSortTime=e.data.sortTime,this.queuedMessage&&(this.sortWorker.postMessage(this.queuedMessage),this.queuedMessage=null)):e.data.sortCanceled?this.sortRunning=!1:e.data.sortSetupPhase1Complete?this.sortWorker.postMessage({positions:this.splatMesh.getCenters().buffer,meshMatrixWorlds:this.splatMesh.meshMatrixWorlds,meshIndexIntervals:this.splatMesh.meshIndexIntervals,cropsArray:this.cropsArray}):e.data.sortSetupComplete&&(this.splatDataTextures=this.splatMesh.getSplatDataTextures(),this.scene.activePage.add(this.splatMesh),this.needsInitialRender=!0)}}update(t,e){this.splatMesh!==null&&(this.updateSplatMeshUniforms(t,e),this.updateView(!1,e))}getSplatMesh(){return this.splatMesh}};var VE=new oo.MeshBasicMaterial;VE.wireframe=!0;var cS=new oo.Vector3,gp=class extends oo.Scene{constructor(e,r){super();this.data=e;this.sharedAssets=r;this.enableHelpers=!1;this.wireframeState=!1;this.needsTransmissionDirty=!0;this.needsNormalDirty=!0;this._needsTransmission=!1;this._needsNormal=!1;this.geometryCacheChanged=!1;this.splatViewer=null;this.shapeBlendIntances=[];this.entityByUuid={};this.entityIdentityToEntity={};this.toExpandCloner=new Set;this.toUpdateCloner=new Set;this.pendingCommands=[];this.pathConstraints=new pp;this.invisibleObjects=new ln("jflkdsafjasdifjaslk",{...Du.defaultData,visible:!1,name:"buildin invisible"});this.needsRecomputeInstances=!1;this.init(e,r),this.matrixAutoUpdate=!1,this.errorPage=new to("fdasfa",{...ni.defaultData,name:""},{shared:r,scene:this})}markGeometryCacheDirty(){this.geometryCacheChanged=!0}markNeedsUpdateRendererDirty(){this.needsTransmissionDirty=!0,this.needsNormalDirty=!0}needsTransmission(){return this.needsTransmissionDirty&&(this._needsTransmission=rS(this),this.needsTransmissionDirty=!1),this._needsTransmission}needsNormal(){return this.needsNormalDirty&&(this._needsNormal=tS(this),this.needsNormalDirty=!1),this._needsNormal}registerInstanceAndSetUuid(e){let r=e.identity.join("-"),o=this.entityIdentityToEntity[r];o&&(e.uuid=o.uuid),this.entityIdentityToEntity[r]=e,this.entityByUuid[e.uuid]=e}markPenumbraSizeDirty(){for(let e of this.children)e instanceof to&&(e.penumbraSizeArrayCache=null)}findInstance(e){return this.entityIdentityToEntity[e.join("-")]}get bgColor(){return this.activePage.bgColor}get postprocessing(){return this.activePage.data.postprocessing}getWithSortKey(e){let r=this.find(e);if(r===void 0)return;let o=[],n=r;for(;n!==this;){let a=n;n=n.parent;let s=n.children.indexOf(a);o.splice(0,0,s)}return{entity:r,sortKey:o}}getAllSorted(e){let r=[];for(let o of e){let n=this.getWithSortKey(o.id);n!==void 0&&r.push(n)}return r.sort((o,n)=>Au(o.sortKey,n.sortKey)),r.map(o=>o.entity)}nonExistOrDescendantOf(e,r){let o=this.find(e);if(o===void 0)return!0;for(;o;){if(o.uuid===r)return!0;o=o.parent}return!1}find(e){if(this.activePage&&this.activePage.personalCamera.parent){if(e==="f23858d0-4a3b-4bd8-8173-66ed0af7f6fb-personalCamera")return this.activePage.personalCamera;if(e===zi)return this.activePage.personalCamera}if(e===""||e===void 0)return;let r=this.entityByUuid[e];return r===void 0?this.getObjectByProperty("uuid",e):r}find2D(e){for(let r of this.children)if(r instanceof to&&r.uiScene){let o=r.uiScene.find(e);if(o)return o}}findScene2DfromObject2D(e){for(let r of this.children)if(r instanceof to&&r.uiScene&&r.uiScene.find(e))return r.uiScene}find2DInUIObjects(e){let r;return this.traverseEntity(o=>{r===void 0&&o instanceof Zn&&(r=o.uiCanvas.find(e))}),r}traverse2D(e){for(let r of this.children)r instanceof to&&r.uiScene&&r.uiScene.traverse(e)}debugEnsureEntity(e){let r=this.find(e);if(r){if(Array.isArray(r.identity)&&this.findInstance(r.identity)===void 0){console.error("not found instance");debugger}}else{console.error("not found");debugger}}addPendingExpandCloner(e){this.toExpandCloner.add(e)}addPendingUpdateCloner(e){this.toUpdateCloner.add(e)}markToExpandCloner(e){this.toExpandCloner.add(e),e.traverseEntityAncestors(r=>{this.toExpandCloner.add(r)})}doPendingExpandCloner(e){this.toExpandCloner.forEach(r=>{r.expandCloner(e)}),this.toExpandCloner.clear()}doPendingUpdateCloner(e){this.toUpdateCloner.forEach(r=>{r.cloner?.update(e)}),this.toUpdateCloner.clear()}doPendingUpdates(e){this.doPendingExpandCloner(e),this.doPendingUpdateCloner(e),this.applyPendingCommands()}addPendingCommand(e){this.pendingCommands.push(e)}applyPendingCommands(){this.pendingCommands.forEach(e=>e()),this.pendingCommands.length=0}updateByLibOp(e,r){e.path.length===1&&e.path[0]==="components"&&e.type===1&&this.createChildrenObjects([{...e.data.asset,id:e.id}],this.invisibleObjects,r)}updateTreeByOp(e,r){if(e.path.length===0&&e.type===7){let o=e.parent===null?this:this.find(e.parent);if(o===void 0)throw new Error("unexpected");let n=this.createObject(e.id,e.data,e.children,o,e.localIndex,r);n.updateVisible(this),n.resetBBoxNeedsUpdate(),sn(n)&&dc(n.parent)&&(n.invalidateUpstreamBooleanData(),n.parent.invalidateDownstreamBooleanData().recomputeBoolean()),this.markNeedsRecomputeInstancesForAncessors(o),this.markNeedsRecomputeInstancesForChildren(n),this.markToExpandCloner(n),this.markPenumbraSizeDirty(),n.updatePathSnapping()}else if(e.path.length===0&&e.type===8){let o=this.find(e.id);if(o===void 0)throw new Error("unexpected");o.traverseEntity(a=>{a instanceof fn&&(this.shapeBlendIntances=this.shapeBlendIntances.filter(s=>s!==a))}),this.markToExpandCloner(o),o.resetBBoxNeedsUpdate(),this.unregisterObject(o);let n=o.parent;this.markNeedsRecomputeInstancesForAncessors(n),this.markNeedsRecomputeInstancesForChildren(o),this.markPenumbraSizeDirty(),o.parent.remove(o),dc(o.parent)&&(o.parent.invalidateUpstreamBooleanData(),o.parent.invalidateDownstreamBooleanData().recomputeBoolean()),sn(o)&&(o.freeBooleanPointer(),n instanceof Nr&&n.invalidateDownstreamBooleanData().recomputeBoolean()),o instanceof Qs&&o.detachShape(),this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(o),this.pathConstraints.removeDependencies(o.uuid),o.updatePathSnapping()}else if(e.path.length===0&&e.type===9){let o=this.find(e.id);if(o===void 0)throw new Error("unexpected");this.markNeedsRecomputeInstancesForChildren(o);let n=o.parent;this.markNeedsRecomputeInstancesForAncessors(n),o.cloner?.resetOnMove(),this.markToExpandCloner(o);let a=e.parent===null?this:this.find(e.parent);if(a===void 0)throw new Error("unexpected");a.add(o),this.markNeedsRecomputeInstancesForAncessors(a),this.markToExpandCloner(o),o.invalidateClonerTransform(o),o.updateVisible(this),o.resetBBoxNeedsUpdate(),this.markPenumbraSizeDirty();let s=e.localIndex;a.children.splice(s,0,a.children.pop()),sn(o)&&(o.invalidateUpstreamBooleanData(),dc(o.parent)?o.parent.invalidateDownstreamBooleanData().recomputeBoolean():n instanceof Nr&&n.invalidateDownstreamBooleanData().recomputeBoolean()),o.updatePathSnapping()}this.markNeedsUpdateRendererDirty(),this.markGeometryCacheDirty()}get playPage(){return this.find(this.data.publish.playPage)??this.errorPage}updatePage(e){this.activePage&&this.activePage.onDeactive(),this.activePage=this.errorPage;for(let r of this.children)r instanceof to&&(r.visible=r.uuid===e,r.visible&&(this.activePage=r,this.activePage.onActive(this)));this.activePage!==this.splatViewer?.activePage&&this.reloadSplats()}updateEntityByOp(e,r,o,n){if(r.type===0){if(("overrides"in r.props||"component"in r.props)&&this.markNeedsRecomputeInstances(),"visible"in r.props&&this.markPenumbraSizeDirty(),r.path.includes("overrides")&&"states"in r.props){let{rest:s}=r.props;r={...r,props:s},this.markNeedsRecomputeInstances()}r.path[0]==="pathSnapping"&&r.props.pathId!==void 0&&this.pathConstraints.setConstraint(e,r.props.pathId)}let a=this.find(e);if(a)try{Y1(a,r,o,{scene:this,shared:n}),a instanceof ht&&a.updateGeometryGroupsIfNeeded()}catch(s){console.error(s)}}updateEntity2DByOp(e,r,o,n,a,s=[]){e.updateEntityByOp(r,o,n,a),this.traverseEntity(l=>{(l instanceof Zn||l instanceof to)&&(s.includes(l.frameId??"")||l.frameId===r)&&l.updateEntity2DByOp(r,o,n,a)})}get activeCamera(){return this.activePage.activeCamera}switchActiveCamera(e){this.activePage.switchActiveCamera(e)}isInvisibleObjects(e){return e===this.invisibleObjects||e.hasAnccestor(this.invisibleObjects)}init(e,r){let o=Object.entries(r.data.lib.components).map((n,a)=>({data:n[1].asset.data,children:n[1].asset.children,id:n[0],fi:a}));this.invisibleObjects.updateState(this.invisibleObjects.data,{scene:this,shared:r}),this.add(this.invisibleObjects),this.createChildrenObjects(o,this.invisibleObjects,r),this.createChildrenObjects(e.objects,this,r),this.updatePage(e.publish.playPage),this.activePage.switchToPlayCamera(),this.expandInstances(r,!0),this.traverseEntity(n=>{n instanceof Si&&n.updateUp()}),this.doPendingExpandCloner({scene:this,shared:r}),this.applyPendingCommands()}markNeedsRecomputeInstances(){this.needsRecomputeInstances=!0}markNeedsRecomputeInstancesForChildren(e){e.traverseEntity(r=>{(r.data.type==="Component"||r.data.type==="Instance")&&this.markNeedsRecomputeInstances()})}markNeedsRecomputeInstancesForAncessors(e){Ge.is(e)&&(e.data.type==="Component"&&this.markNeedsRecomputeInstances(),e.traverseAncestors(r=>{Ge.is(r)&&r.data.type==="Component"&&this.markNeedsRecomputeInstances()}))}relativeizeInner(e,r,o,n,a,s,l){if(e){let c=n.find(e);c&&c!==n&&a.forInstancesRec(u=>{u.data=Di(u.data,d=>{let p=d.events.data(l.id),f=u.goUp(s);if(f){let h=[...Cu(f.identity),e].join("-"),m=this.entityIdentityToEntity[h];if(m){let y=m.uuid,g=dt.zoom(p,r);g[o]=y}else{if(!1)debugger;console.warn("cannot find instance")}}}).data})}}rewriteActions(e,r,o,n,a,s){e.forEach(l=>{l.data.type==="Transition"?this.relativeizeInner(l.data.object,[...r,l.id],"object",o,n,a,s):l.data.type==="Animation"?this.relativeizeInner(l.data.object,[...r,l.id],"object",o,n,a,s):l.data.type==="Conditional"&&(this.rewriteActions(l.data.ifActions,[...r,l.id,"ifActions"],o,n,a,s),this.rewriteActions(l.data.elseActions,[...r,l.id,"elseActions"],o,n,a,s))})}rewriteEventsBeforeGoToPlayMode(){this.traverseEntity(e=>{if(e instanceof Oi&&typeof e.identity=="string"&&e.data.type==="Component")return e.traverseEntity((r,o)=>{r.data.events.forEach(n=>{if(n.data.type==="GameControl"){let a=!1;if(r.forInstancesRec(s=>{s.data=Di(s.data,l=>{s.isInstanceRoot||(l.events.delete(n.id),a=!0)}).data}),a===!1)for(let s of Bu.list)this.rewriteActions(n.data.gameActions[s],["gameActions",s],e,r,o,n)}else n.data.type==="Conditional"?(n.data.condition.type==="Distance"?(this.relativeizeInner(n.data.condition.fromObject,["condition"],"fromObject",e,r,o,n),this.relativeizeInner(n.data.condition.toObject,["condition"],"toObject",e,r,o,n)):n.data.condition.type==="State"?this.relativeizeInner(n.data.condition.object,["condition"],"object",e,r,o,n):n.data.condition.type==="Comparison"&&(n.data.condition.lOperand.type==="Property"&&this.relativeizeInner(n.data.condition.lOperand.value[0],["condition","lOperand","value"],0,e,r,o,n),n.data.condition.rOperand.type==="Property"&&this.relativeizeInner(n.data.condition.rOperand.value[0],["condition","rOperand","value"],0,e,r,o,n)),this.rewriteActions(n.data.inActions,["inActions"],e,r,o,n),this.rewriteActions(n.data.outActions,["outActions"],e,r,o,n)):"actions"in n.data&&this.rewriteActions(n.data.actions,["actions"],e,r,o,n)})}),!0})}expandInstances(e,r,o){let n=new Set;this.traverseEntity(a=>{if(a instanceof Oi&&a.isInstanceRoot)return a.expandInstanceChildren({scene:this,shared:e,pendingDeletes:n}),r||a.resetBBoxNeedsUpdate(),o&&a.traverseEntity(s=>{o.addClip(s)}),!0});for(let a of n)this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(a),np(a)}recomputeInstances(e,r){this.needsRecomputeInstances&&(this.needsRecomputeInstances=!1,this.traverseEntity(o=>{o instanceof Oi&&o.isInstanceRoot&&(o.component=void 0)}),this.expandInstances(e,!1,r))}disposeAndUnregisterEntityRecursivelyIfNotReregistered(e){e.traverseEntity(r=>{let o=typeof r.identity=="string"?r.identity:r.identity.join("-");this.entityIdentityToEntity[o]===r&&(delete this.entityByUuid[r.uuid],delete this.entityIdentityToEntity[o]),r.dispose()})}clearScene(){for(let e of this.children)Ge.is(e)&&e.disposeRecursively();this.children.length=0}resetAfterClear(e,r){this.init(e,r)}raycast(e){return this.raycast1(e,!1)}raycast1(e,r){let o=[],n=a=>{for(let s of a.children){let l=s.cloner;if(Ge.is(s)&&!s.raycastLock&&(s.visible||l?.object.data.visible))if(r===!0&&s.isInstanceRoot){let c=[];if(e.intersectObject(s,!0,c),c.length){let u=c[0];u.object=s,u.point.applyMatrix4(u.object.matrixWorld);let d=s.matrixWorld.clone().invert();u.point.applyMatrix4(d),o.push(u)}}else(sn(s)||pc(s)&&this.enableHelpers&&s.objectHelper.visible)&&(e.intersectObject(s,!1,o),bc(s,e,o)),n(s)}};return n(this.activePage),o}raycastWithClones(e){let r=[],o=n=>{for(let a of n.children){let s=a.cloner;Ge.is(a)&&(a.visible||s?.object.data.visible)&&((sn(a)||pc(a)&&this.enableHelpers&&a.objectHelper.visible)&&(e.intersectObject(a,!1,r),bc(a,e,r,!0)),o(a))}};return o(this),r}forEachEntity(e){for(let r of this.children)Ge.is(r)&&e(r)}traverseConcreteEntity(e){for(let r of this.children)Ge.is(r)&&r.isConcreteEntity&&r.traverseEntity(e)}traverseEntity(e){for(let r of this.children)Ge.is(r)&&r.traverseEntity(e)}updateFont(e,r){this.traverseEntity(o=>{if(o instanceof ht&&o.data.type==="Mesh"&&(o.data.geometry.type==="TextGeometry"||o.data.geometry.type==="InputGeometry")&&o.data.geometry.font===e){let n=o.geometry,a=o.data.geometry;n.updateFont(e,r).then(()=>{n.update(a,r);let s=o.invalidateDownstreamBooleanData();dc(s)&&s.recomputeBoolean()})}})}traverseObject(e){for(let r of this.children)di.is(r)&&r.traverseObject(e)}traverseVisibleEntity(e){for(let r of this.children)Ge.is(r)&&r.visible&&r.traverseVisibleEntity(e)}dispose(){this.clearScene()}createChildrenObjects(e,r,o){let n=0;for(let a of e)this.createObject(a.id,a.data,a.children,r,n,o),n+=1}registerObjectCreatedInLegacy(e){this.entityByUuid[e.uuid]=e}unregisterObject(e){delete this.entityByUuid[e.uuid];for(let r of e.children)this.unregisterObject(r)}createObject(e,r,o,n,a,s){let l={scene:this,shared:s},c=cp(e,r,l);return c instanceof fn&&this.shapeBlendIntances.push(c),c&&(this.entityByUuid[e]=c,n.add(c),n.children.splice(a,0,n.children.pop()),o.length>0&&(c.isInstanceRoot?console.error("instance should not have children!"):this.createChildrenObjects(o,c,s)),c.updateState(r,l),c instanceof ht&&c.updateGeometryGroupsIfNeeded(),c.updateVisible(this),c.cloner&&this.toExpandCloner.add(c),r.pathSnapping?.pathId&&this.pathConstraints.setConstraint(e,r.pathSnapping.pathId)),r.type==="Empty"&&r.animations&&c.traverseEntity(u=>{let d=u.dataPatched;if(u instanceof ht&&d.bones&&d.boneInverses){let p=d.bones.map(m=>this.find(m)),f=d.boneInverses.map(m=>new oo.Matrix4().fromArray(m)),h=new oo.Skeleton(p,f);u.bind(h,u.bindMatrix)}else u.matrixAutoUpdate=!0}),c}getCenter(e){let r=[];for(let n=0,a=e.length;n<a;++n){let{id:s,recursive:l}=e[n],c=this.find(s),u=l?c.recursiveBBox:c.singleBBox;r.push(...u.vertices)}let o=new oo.Box3;return o.setFromPoints(r),o.getCenter(cS),cS}copyMatrixWorld(e,r){if(e===null){r.identity();return}let o=this.find(e);o?r.copy(o.matrixWorld):r.identity()}copyParentMatrixWorld(e,r){if(e===null){r.identity();return}let o=this.find(e)?.parent;o?r.copy(o.matrixWorld):r.identity()}traverseMaterial(e){this.traverseEntity(r=>{if(r instanceof $t)if(Array.isArray(r.material))for(let o=0;o<r.material.length;o++)r.material[o]instanceof Ir&&e(r.material[o]);else r.material instanceof Ir&&e(r.material)})}updateViewPlaneSize(e,r,o=!1){this.traverseConcreteEntity(n=>{n instanceof Si&&n.setViewplaneSize(e,r,o)})}initializeSplatViewer(){this.splatViewer=new Sc({scene:this}),this.reloadSplats()}reloadSplats(){this.splatViewer?.loadSplat()}};var uS=require("three/examples/jsm/loaders/DRACOLoader.js");var gn;function dS(i){return gn||(gn=new uS.DRACOLoader,gn.setDecoderPath(i!==void 0?`${i}/`:"https://www.gstatic.com/draco/versioned/decoders/1.5.2/").preload()),gn.decoderPending}async function zE(i){if(gn){let t={attributeIDs:gn.defaultAttributeIDs,attributeTypes:gn.defaultAttributeTypes,useUniqueIDs:!1},e;try{e=await gn.decodeGeometry(new Int8Array(i).buffer,t)}catch(r){console.error(r)}if(e)return{index:e.index?{array:e.index.array}:void 0,attributes:Object.entries(e.attributes).map(([r,o])=>({name:r,itemSize:o.itemSize,array:o.array}))}}return null}async function pS(i,t){let[e,r]=kp(yu.deserialize(new Uint8Array(i)));return Gu(e),t&&t(e),r.result().data}function fS(i){let t=[];return i.scene.objects.traverse((e,r)=>{r.type==="Mesh"&&r.geometry.type==="NonParametricGeometry"&&r.geometry.data.draco!==void 0&&t.push(r)}),t}async function hS(i){for(let t of i){let e=await zE(t.geometry.data.draco);if(e){let r=t.geometry.data;e.index&&(r.index={array:e.index.array,itemSize:1,normalized:!1,type:"Uint32Array"});let o={};e.attributes.forEach(({name:n,array:a,itemSize:s})=>{o[n]={array:a,itemSize:s,type:"Float32Array",normalized:!1}}),r.attributes=o,r.draco=void 0}}}var GE=require("three"),FE=require("three/examples/jsm/utils/BufferGeometryUtils.js");function mS(i){let t;if(!!i.index)for(let e=0;e<i.index.array.length;e+=3)t=i.index.array[e],i.index.array[e]=i.index.array[e+2],i.index.array[e+2]=t}var wc=require("three");function yS(i){let t=new Set;return i.traverse(e=>{if(e instanceof Er)if(Mt(e.material))e.material.forEach(r=>{let o=r;t.has(o)||t.add(o)});else{let r=e.material;t.has(r)||t.add(r)}}),t.forEach(e=>{if(e instanceof Array)return;let r=e.onBeforeCompile.bind(e);if(jE(e)){Object.assign(e,{isMeshStandardMaterial:!0,isMeshPhysicalMaterial:!0,transmission:1,attenuationColor:new wc.Color,specularColor:new wc.Color});let o=0;e.onBeforeCompile=(n,a)=>{r&&r(n,a),n.uniforms=Object.assign({},wc.ShaderLib.physical.uniforms,n.uniforms),e.getLayersOfType("transmission").forEach(s=>{if(n.uniforms.transmissionSamplerMap.value){let l=s.color;l&&(l.transmissionSamplerMap.value=n.uniforms.transmissionSamplerMap.value,l.transmissionSamplerSize.value=n.uniforms.transmissionSamplerSize.value,l.aspectRatio.value=Qb(window.innerWidth,window.innerHeight),e.defines.IS_THREEJS_EXPORT=!0)}else o++,o<2&&(e.needsUpdate=!0)})}}else UE(e)||(e.onBeforeCompile=(o,n)=>{r&&r(o,n),e.transparent=!1})}),i}function jE(i){return i.getLayersOfType("transmission").length>0}function UE(i){let t=0;for(let e of i.layers){if(e.data.type!=="displace"&&e.data.isMask)return!0;if(e.type!=="light"&&e.type!=="fresnel"){let o=e.uniforms["f"+e.id+"_alpha"];o&&(t+=(1-t)*o.value)}}return t<1}function gS(i){return i.traverse(t=>{if(t.type==="Camera"){let e=t;e.type=e.cameraType}}),i}function xS(i){let t=[],e=(r,o=0)=>{let n=o>0?r+o:r;return t.includes(n)?e(r,o+1):n};return i.traverse(r=>{if(t.includes(r.name)){let o=r.name,n=e(r.name);if(r.name=n,r.isMesh){let a=r;a.material instanceof Array?a.material.forEach(s=>{s.name=s.name.replace(o,n)}):a.material.isAsset||(a.material.name=a.material.name.replace(o,n))}}t.push(r.name)}),i}var bS=require("three/examples/jsm/utils/BufferGeometryUtils.js");function vS(i){let t=[];return i.traverse(e=>{e instanceof nn&&t.push(e)}),t.forEach(e=>{let r=e.object,a=[...e.children.map(s=>{s.updateMatrix();let l;if(s.geometry!==void 0)try{l=s.geometry.clone().applyMatrix4(s.matrix)}catch(c){console.error(c)}return l!==void 0&&s.matrix.determinant()<0&&mS(l),l}).filter(s=>s!==void 0)];if(!e.parameters.hideBase&&r instanceof $t&&a.unshift(r.geometry),a.length){let s=(0,bS.mergeBufferGeometries)(a);r instanceof $t&&(r.geometry=s)}e.removeFromParent(),r.setFromClonerState(null,{scene:i,shared:mv})}),i}function SS(i){return i.traverse(t=>{t.matrixAutoUpdate=!0}),i}function wS(i){Object.values(i.shared.materials).forEach(t=>{cm(t)}),i.scene.objects.traverse((t,e)=>{"material"in e?cm(e.material):"materials"in e&&e.materials.forEach(r=>{cm(r)})})}function cm(i){if(typeof i=="string")return;let t=[];i.layers.forEach((e,r)=>{e.type==="outline"&&t.push(r)}),t.reverse().forEach(e=>{i.layers.delete(e)}),t.length&&console.warn("The Spline Loader currently does not support the outline layer.")}var CS=ll(OS(),1);var TS="The SplineLoader only accepts .splinecode files that are generated from Spline export panel.",xp=class extends bp.Loader{load(t,e,r,o=console.error){let n=new bp.FileLoader(this.manager);n.setPath(this.path),n.setResponseType("arraybuffer"),n.setRequestHeader(this.requestHeader),n.setWithCredentials(this.withCredentials),t.endsWith(".spline")?console.warn(TS+" The .spline files are only meant to be used by the Editor."):t.endsWith(".splinecode")||console.warn(TS),n.load(t,async a=>{try{if(typeof a=="string")throw new Error("The .spline file is not binary!");let s=await this.parse(a);e(s)}catch(s){o(s)}},r,o)}async parse(t){let e=await pS(t,wS),r=fS(e);e.version&&(0,CS.default)(e.version,"1.12.88")>0&&console.warn("Your .splinecode file is more recent than the library. Please upgrade @splinetool/loader to the latest version."),await Promise.allSettled([r.length&&dS(),vv(e)&&Ob(),Ev(e)&&lv(),u1(e)&&s1(),mp(e)&&lm()].filter(Boolean)),r.length&&await hS(r);let o=!1,n=new $n(e.shared,{},o);Object.values(n.getMaterials()).forEach(l=>Object.assign(l,{isAsset:!0}));let a=new gp(e.scene,n);mp(e)&&a.initializeSplatViewer();let s=a.activeCamera;return s&&Object.assign(s,{makeDefault:!0}),a=vS(a),a=yS(a),a=gS(a),a=xS(a),a=SS(a),a}};
@@ -15,7 +15,7 @@ best distance: ${p.d}`);let g=[p.x,p.y];return g.distance=p.d,g.distance}functio
15
15
  }`}if(n){o=`${!1&&window.location.search.includes("api-dev")?"https://api-dev.spline.design/":"https://apis.spline.design/"}file/${i.proxy.fileId}/external-api/request?uuidexternalapi=${i.proxy.proxyId}`;let u;a!==void 0?u=a:i.method==="POST"&&i.body&&(u=ml(JSON.parse(i.body),t)),u!==void 0&&(o+=`&data=${encodeURIComponent(u.replace(/(\r\n|\n|\r|\t)/gm,""))}`)}else i.integration?.type==="OpenAI"?r=a:i.method==="POST"&&i.body&&(r=ml(JSON.parse(i.body),t));let s=await fetch(o,{method:n?"GET":i.method,headers:n?void 0:aE(i),signal:e.signal,body:r});if(!s.ok)throw new Error("status:"+s.status+"_:_"+s.statusText);if(i.integration?.type==="OpenAI"){let l=await s.json();return n&&(l=l.response),{content:l.choices[0].message.content}}else{let l=await s.json();return n&&(l=l.response),l}}var Db=(i,t)=>{if(typeof i=="string"){let e=t.getVariable(i);if(e)return Db(e,t)}return vi.isBoolean(i)?vi.getDisplayedValue(i).toLowerCase():vi.getDisplayedValue(i)},ml=(i,t)=>i.map((e,r)=>{if("text"in e)return e.text;if("type"in e){if(e.type==="paragraph")return(r>0?`
16
16
  `:"")+ml(e.children,t);if(e.type==="variable"){let o=t.getVariable(e.variableId);if(o!==void 0)return Db(o,t)}}return""}).join("");var pE=new pn,fE=new pn;function hE(i,t,e){let r=[new Lt,new Lt,new Lt],o=[new Lt,new Lt,new Lt];return i.extractBasis(r[0],r[1],r[2]),t.extractBasis(o[0],o[1],o[2]),r.forEach((n,a)=>{let s=o[a],l=ju.lerp(n.length(),s.length(),e);n.lerp(s,e).setLength(l)}),new pn().makeBasis(r[0],r[1],r[2])}var Lb=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,height:100,depth:1,subdivisions:12,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3},i.parameters),r=Math.abs(e.width),o=Math.abs(e.height??e.width),n=Math.abs(e.depth??0),a=t?.shapeData??Ba.create({parameters:{...nn,width:typeof nn.width=="number"?nn.width:100,height:typeof nn.height=="number"?nn.height:100}}).userData.shape;return{path:i.path??ga.defaultData(),parameters:Object.assign(e,{width:r,height:o,depth:n,extrusion:{...Xc,...e.extrusion}}),shapeData:a}}static build(i){if(i.path.points.length>=2){let e=new Uf(i);return Object.assign(e,{userData:{...i,type:"PathGeometry"}})}else return Object.assign(new Rb,{userData:{...i,type:"PathGeometry"}})}},Uf=class extends Rb{constructor(e){super();this.type="PathExtrusionGeometry",this.inputs=e,this.build()}_isGeometryClosed(){return this.inputs.path.isClosed&&this.inputs.parameters.extrusion.depth===1}_isOpenEnded(){let e=this.inputs.parameters.extrusion;return!(this.inputs.path.isClosed&&e.depth===1)||!Eb(e.twist,0)||e.startScale!==e.endScale}build(){let e=this._extractPathPoints();if(e.length<2)return;let r=this._computeBasisMatrices(e),{depth:o,offset:n}=this.inputs.parameters.extrusion;o=Math.max(0,Math.min(o,1)),n=Math.max(0,Math.min(n,1));let a=this.inputs.path.isClosed?e.length:e.length-1,s=Math.floor(n*a),l=this.inputs.path.isClosed?Math.ceil((o+n)*a):Math.ceil(Math.min(1,o+n)*a),c=Math.min(Math.max(2,l-s+1),a+2),u=[],d=[];for(let j=0;j<c;j++){let F=this.inputs.path.isClosed?(j+s)%e.length:Math.min(j+s,e.length-1);u.push(e[F].clone()),d.push(r[F].clone())}let p=(j,F,H)=>{u[j]=u[j].clone().lerp(u[F],H),d[j]=hE(d[j],d[F],H)},f=0,h=n*a%1;(!this.inputs.path.isClosed||o<=1)&&(h||n===0)&&(f=h,p(0,1,f));let m=0,y=(n+o)*a%1;if((this.inputs.path.isClosed&&o<=1||!this.inputs.path.isClosed&&n+o<1)&&y&&(m=y,p(u.length-1,u.length-2,1-m)),o===0){let j=u.length-1;u[j].copy(u[0]),d[j].copy(d[0])}this._applyPathModifiers(d,f,m);let{bevel:g,bevelSides:b}=this.inputs.parameters.extrusion,w=g>0?this.inputs.parameters.extrusion.capType:"flat",P=5;this.inputs.parameters.extrusion.shape.type==="Custom"&&(P=this.inputs.parameters.extrusion.shape.shapeQuality==="low"?5:12);let{regions:S,infos:T,vertices:A}=this._computeShapePoints(P),x=0,N;w==="round"&&(N=new Oi(this.inputs.shapeData,2*g,g,P,b,void 0,!0),x=N.getAttribute("position").count);let E=0,M=0;T.sort((j,F)=>j.start-F.start),T.forEach(j=>{j.verticesStart=E,j.verticesCount=j.continuous.reduce((F,H,W)=>F+(W===0||!H?2:1),0),M+=j.verticesCount,E=M});let D=M*c,_,R=0;if(this._isOpenEnded()&&w==="flat"){try{_=kr({windingRule:je.ODD,elementType:ct.POLYGONS,polySize:3,vertexSize:2,strict:!0,contours:S})}catch{_=Af}R=_.vertexCount}let V=D+2*R+x*2,U=D+2*R,B={positions:new Float32Array(V*3),normals:new Float32Array(V*3),uvs:new Float32Array(V*2)},q=[];if(T.forEach(j=>{this._extrudeRegion(j,A,d,u,B,q,this._isGeometryClosed()&&!this._isOpenEnded())}),_&&(this._closeEnd(_,D,q,B,d[0],u[0],!1),this._closeEnd(_,D+R,q,B,d[d.length-1],u[u.length-1],!0)),N){B.positions.set(N.getAttribute("position").array,U*3),B.normals.set(N.getAttribute("normal").array,U*3),B.uvs.set(N.getAttribute("uv").array,U*2);for(let W=U;W<U+x;W++)B.uvs[W*2+1]=1e-4;let j=q.length;q.push(...N.getIndex().array.map(W=>W+U)),U+=x,B.positions.set(N.getAttribute("position").array,U*3),B.normals.set(N.getAttribute("normal").array,U*3),B.uvs.set(N.getAttribute("uv").array,U*2);let F=q.length;q.push(...N.getIndex().array.map(W=>W+U)),this.setAttribute("position",new ja(B.positions,3)),this.setAttribute("normal",new ja(B.normals,3)),this.setAttribute("uv",new ja(B.uvs,2)),this.setIndex(q);let H=pE;H.copy(d[d.length-1]).setPosition(u[u.length-1]),this.applyMatrix4OnRange(H,U,V),H.copy(d[0]).setPosition(u[0]).multiply(fE.makeScale(1,1,-1)),this.applyMatrix4OnRange(H,U-x,U),this.reverseIndicesOnRange(j,F)}else this.setAttribute("position",new ja(B.positions,3)),this.setAttribute("normal",new ja(B.normals,3)),this.setAttribute("uv",new ja(B.uvs,2)),this.setIndex(q)}_extractPathPoints(){let e=bu(this.inputs.path),r=this.inputs.path.subdivisions,o=this.inputs.path.subdivisionMode==="uniform"?e.getSpacedPoints(r*4):e.getPoints(r);if(o.length<2)return[];let n=[o[0]];return o.forEach(s=>{n[n.length-1].distanceToSquared(s)>.001&&n.push(s)}),this.inputs.path.isClosed&&n[n.length-1].distanceTo(n[0])<.001&&n.pop(),n}_computeBasisMatrices(e){let r=[],o=e.length,n=this.inputs.path.isClosed,a=new Lt,s=new Lt,l=new Lt,c=new Lt,u=new Lt(0,1,0);for(let y=0;y<o;y++){let g=e[y],b;y===0?b=n?e[e.length-2]:g.clone().multiplyScalar(2).sub(e[1]):b=e[y-1];let w;y===o-1?w=n?e[1]:g.clone().multiplyScalar(2).sub(e[y-1]):w=e[y+1];let P=g.clone().sub(b).normalize(),S=w.clone().sub(g).normalize(),T=P.clone().add(S).normalize();l.copy(T),y===0&&(T.equals(u)||T.clone().negate().equals(u))&&u.set(0,0,1);let A=u.clone().cross(T).normalize(),x=T.clone().cross(A).normalize();u.copy(x),c.copy(A),y===0&&(a.copy(x),s.copy(T));let N=new pn().makeBasis(A,x,T);r.push(N)}let d=n?s:l,p=n?a:new Lt(0,1,0),f=d.clone().cross(c).normalize(),h=Math.acos(p.dot(f));if(isNaN(h))return r;let m=p.clone().cross(f);d.dot(m)>0&&(h*=-1);for(let y=1;y<r.length;y++){let g=new pn().makeRotationZ(h*y/r.length);r[y].multiply(g)}return r}_applyPathModifiers(e,r,o){let n=e.length,{angle:a,twist:s,startScale:l,endScale:c}=this.inputs.parameters.extrusion,u=new pn,d=new pn;return e.forEach((p,f)=>{let h=f===0?0:f===n-1?1:(f-r)/(n-(o===0?0:1)-(r+(1-o)));u.makeRotationZ(ju.lerp(a,a+s,h)*ju.DEG2RAD);let m=ju.lerp(l,c,h);d.makeScale(m,m,m),p.multiply(u).multiply(d)}),e}_computeShapePoints(e=12,r=je.ODD){let o=this.inputs.shapeData,n=o.extractShapePointsToFlatArray([],e),a=o.shapeHoles.map(m=>{let y=m.extractShapePointsToFlatArray([],e),g=[];for(let b=y.length-1;b>=1;b-=2){let w=y[b-1],P=y[b-0];g.push(w,P)}return g}),s;try{s=kr({windingRule:r,elementType:ct.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[n]})}catch{s=ul}let l;try{l=kr({windingRule:je.ODD,elementType:ct.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...a]})}catch{l=Cf}if(!s)throw new Error("error generating geometry");let c=s.elementCount;if(l){s.elementCount+=l.elementCount;for(let m=0;m<l.elements.length;m++){let y=l.elements[m],g=m%2===0?s.vertexCount:0;s.elements.push(y+g)}for(let m=0;m<l.vertexIndices.length;m++){let y=l.vertexIndices[m],g=s.vertexCount;s.vertexIndices.push(y+g)}for(let m=0;m<l.vertices.length;m++){let y=l.vertices[m];s.vertices.push(y)}}let u=1/0,d=-1/0,p=1/0,f=-1/0;for(let m=0,y=s.vertexCount;m<y;m++){let g=m*2,b=s.vertices[g+0],w=s.vertices[g+1];b<u&&(u=b),b>d&&(d=b),w<p&&(p=w),w>f&&(f=w)}let h=[];for(let m=s.elementCount-1;m>=0;m--){let y=m>=c,g=m*2,b=s.elements[g+0],w=s.elements[g+1],P=b+w,S={start:b,count:w,normals:[],isHole:y,continuous:[],verticesStart:0,verticesCount:0};h.push(S);let T=b,A=P-1,x=b+1,N=o.roundedCurves.length;do{let E=T-b,M=s.vertices[A*2+0],D=s.vertices[A*2+1],_=s.vertices[T*2+0],R=s.vertices[T*2+1],V=s.vertices[x*2+0],U=s.vertices[x*2+1],B=_-M,q=R-D,j=Math.sqrt(B*B+q*q);B/=j,q/=j;let F=_-V,H=R-U,W=Math.sqrt(F*F+H*H);F/=W,H/=W,S.normals[E*2+0]=-H,S.normals[E*2+1]=F;let ee=s.vertexIndices[T];if(Array.isArray(ee))S.continuous[E]=!1;else{let[te,Y]=o.getCurveIndexFromVertexId(ee-1,!0);if(Y>0&&Y<1)S.continuous[E]=!0;else{let re=Y===1?te+1:te-1;re=(re+N)%N;let K=Y===1?0:1,J=o.roundedCurves[te].getTangent(Y),Q=o.roundedCurves[re].getTangent(K);S.continuous[E]=J.dot(Q)>.95}}y&&(S.normals[E*2+0]*=-1,S.normals[E*2+1]*=-1),[A,T,x]=[T,x,x+1],x>=P&&(x-=w)}while(x!==b+1)}return{regions:[n,...a],infos:h,vertices:s.vertices}}_insertVertex(e,r,o,n,a){let s=r*2,l=r*3;e.positions[l+0]=o.x,e.positions[l+1]=o.y,e.positions[l+2]=o.z,e.normals[l+0]=n.x,e.normals[l+1]=n.y,e.normals[l+2]=n.z,e.uvs[s+0]=a.x,e.uvs[s+1]=a.y}_extrudeRegion(e,r,o,n,a,s,l){let c=new Lt,u=new Lt,d=new Lt,p=new Lt,f=new _b;o.forEach((m,y)=>{let g=n[y],b=e.verticesStart*o.length+e.verticesCount*y;for(let w=0;w<e.count;w++){let P=(e.start+w)*2;if(c.set(r[P+0],r[P+1],0),d.copy(c).applyMatrix4(m).add(g),e.continuous[w])p.set(e.normals[w*2+0],e.normals[w*2+1],0);else{let S=w===0?(e.start+e.count-1)*2:P-2;u.set(r[S+0],r[S+1],0),p.copy(c).sub(u),p.set(-p.y,p.x,0),e.isHole||p.negate()}if(p.applyMatrix4(m).normalize(),f.set(w===0?1:w/e.count,y/(o.length-1)),this._insertVertex(a,b,d,p,f),b++,!e.continuous[w]||w===0){if(w===0)p.set(e.normals[w*2+0],e.normals[w*2+1],0),f.set(0,y/(o.length-1));else{let S=w===e.count-1?e.start*2:P+2;u.set(r[S+0],r[S+1],0),p.copy(u).sub(c),p.set(-p.y,p.x,0),e.isHole||p.negate()}p.applyMatrix4(m).normalize(),this._insertVertex(a,b,d,p,f),b++}}});let h=o.length-1;for(let m=0;m<h;m++){let y=e.verticesStart*o.length+e.verticesCount*m,g=e.verticesStart*o.length+e.verticesCount*(m+1),b=0;for(let w=0;w<e.count;w++){(!e.continuous[w]||w===0)&&b++;let P=w===e.count-1?0:b+1,S=y+b,T=y+P,A=g+P,x=g+b;e.isHole?s.push(S,A,T,S,x,A):s.push(S,T,A,S,A,x),b++}}}_closeEnd(e,r,o,n,a,s,l){let c=e.vertexCount,u=new Lt(0,0,l?-1:1).applyMatrix4(a),d=new Lt,p=new _b;for(let h=0;h<c;h++){let m=2*h;d.set(e.vertices[m+0],e.vertices[m+1],0).applyMatrix4(a).add(s),this._insertVertex(n,r+h,d,u,p)}let f=e.elements;for(let h=0;h<e.elementCount;h++){let m=3*h,y=f[m+0]+r,g=f[m+(l?1:2)]+r,b=f[m+(l?2:1)]+r;o.push(y,g,b)}}applyMatrix4OnRange(e,r,o){let n=e.elements,a=new dE().getNormalMatrix(e).elements,s,l,c,u,d=this.attributes.position,p=this.attributes.normal;if(!d||!p)return;let f=d.array,h=p.array,m=d.itemSize;for(let y=r*m,g=o*m;y<g;y+=m){if(y===r)debugger;s=f[y+0],l=f[y+1],c=f[y+2],u=1/(n[3]*s+n[7]*l+n[11]*c+n[15]),f[y+0]=(n[0]*s+n[4]*l+n[8]*c+n[12])*u,f[y+1]=(n[1]*s+n[5]*l+n[9]*c+n[13])*u,f[y+2]=(n[2]*s+n[6]*l+n[10]*c+n[14])*u,s=h[y+0],l=h[y+1],c=h[y+2],h[y+0]=a[0]*s+a[3]*l+a[6]*c,h[y+1]=a[1]*s+a[4]*l+a[7]*c,h[y+2]=a[2]*s+a[5]*l+a[8]*c}d.needsUpdate=!0,p.needsUpdate=!0}reverseIndicesOnRange(e,r){let o=this.index;if(o){for(let n=e;n<r;n+=3){let a=o.getX(n),s=o.getX(n+1),l=o.getX(n+2);o.setXYZ(n,l,s,a)}o.needsUpdate=!0}}};import{BufferAttribute as Bb,BufferGeometry as kf}from"three";import{mergeBufferGeometries as yE}from"three/examples/jsm/utils/BufferGeometryUtils.js";function Vb(){let i=new kf;return i.setAttribute("position",new Bb(new Float32Array([]),3)),i.setIndex(new Bb(new Uint16Array([]),1)),i}var gE=Vb().attributes,xE=12,bE=1,fn=class extends kf{constructor(e,r){super();this.charWidths=[];this.charCoords=[];this.wrappedText=[];this.isLowResolution=!1;this.vectorShapes=[];Object.assign(this.attributes,gE),this.userData={parameters:e,type:"TextGeometry"};let o=r.getFont(e.font);o?.isLoaded?(this.font=o,this.update(e,r)):this.updateFont(e.font,r).then(()=>{this.update(e,r),r?.requestRender()})}async updateFont(e,r){let o=r.getFont(e);o&&(this.font=o,await o.loadingPromise)}update(e,r){let o=this.font;if(this.userData={parameters:e,type:"TextGeometry"},!o?.isLoaded){console.warn("Cannot update text because its font is not loaded");return}let{width:n,height:a,depth:s,extrudeBevelSize:l,extrudeBevelSegments:c,text:u,textTransform:d}=e,p=vi.getDisplayedValue(u),f=d===2?p.toUpperCase():d===3?p.toLowerCase():p,h=vE(e,o,f,r),{shapes:m,charWidths:y,charCoords:g}=o.generateShapes(h,e,r),b=(typeof n=="number"?n:Number(r.getVariable(n)))*.5,w=(typeof a=="number"?a:Number(r.getVariable(a)))*.5,P=m.map(A=>new Ue().fromShape(A,!0));this.vectorShapes=P;let S=P.map(A=>rr.create({shape:A,parameters:{depth:s,extrudeBevelSegments:c,extrudeBevelSize:l,windingRule:s<=0?je.NONZERO:je.ODD,subdivisions:this.isLowResolution&&s>0?bE:xE}})),T=S.length?yE(S):Vb();T.translate(-b,w,0),this.dispose(),this.wrappedText=h,this.charCoords=g,this.charWidths=y,this.deleteAttribute("extrudeNormal"),Object.entries(T.attributes).forEach(([A,x])=>{this.setAttribute(A,x)}),this.setIndex(T.index),this.computeBoundingSphere()}clone(){let e=At(new kf,fn.prototype);return e.copy(this),console.log("CloneGeometry",this,e),e}copy(e){return Object.entries(e.attributes).forEach(([r,o])=>{this.setAttribute(r,o)}),this.setIndex(e.index),this.userData={parameters:{...e.userData.parameters},type:"TextGeometry"},this}async setText(e,r){this.font&&await this.font.loadingPromise,await this.update({...this.userData.parameters,text:{textValue:e}},r)}get text(){return this.userData.parameters.text??""}};function vE(i,t,e,r){let o=typeof i.width=="string"?Number(r.getVariable(i.width)):i.width,n=[""],a="";for(let s of e)a+=s,s===" "||s===`
17
17
  `?(n[n.length-1]+=a,a="",s===`
18
- `&&n.push("")):t.getTextWidth(n[n.length-1]+a,i)>o&&(n[n.length-1].length&&n.push(""),t.getTextWidth(n[n.length-1]+a,i)>o&&(a.length===1?(n[n.length-1]+=a,a=""):(n[n.length-1]+=a.slice(0,-1),a=a[a.length-1],n.push(""))));return n[n.length-1]+=a,n}import{BufferGeometry as Wf,BufferAttribute as jb,Uint32BufferAttribute as qf,Float32BufferAttribute as $f,Matrix4 as TE,Vector3 as gl,Sphere as CE,Box3 as AE,BoxGeometry as ME}from"three";var Gb,ku=new Promise(i=>{Gb=i}),zb=!1;var Uu;function Fb(i){if(zb)return;if(Uu)return Uu;async function t(){let r=i??(!1?".":"https://unpkg.com/@splinetool/modelling-wasm@1.12.87/build"),n=import("./process.js"),[a,s]=await Promise.all([n,fetch(`${r}/process.wasm`).then(u=>u.arrayBuffer())]),l=a.default,c=await l({wasmBinary:s});Gb(c),zb=!0}return Uu=t(),Uu}import{BufferGeometryLoader as SE}from"three";var wE=["font"];function mo(i,t,e,r){let o,n,a;i.type==="PathGeometry"?(n=JSON.parse(JSON.stringify(i)),a=[[],["extrusion"]]):(n={...i},a=[[]]);for(let c of a){let u=n;for(let d of c)u=u[d];for(o in u){let d=u[o];Dp(d)&&!wE.includes(o)&&(u[o]=t.getVariable(d,[r.uuid,"geometry",...c,o]),Dp(u[o])&&(u[o]=1))}}let s={parameters:n,type:n.type};if(n.type==="PathGeometry")s.path=n.path;else if(n.type==="VectorGeometry"){let c=Ue.createFromState(n.shape,n.width,n.height);s.shape=c}else if(n.type==="NonParametricGeometry"){if(n.data.groups&&n.data.groups?.forEach(c=>c.materialIndex=Math.max(c.materialIndex??0,0)),s.geometry=new SE().parse(n),s.geometry.groups.length===0){let c=s.geometry;c.addGroup(0,Math.max(c.getIndex()?.count??0,c.getAttribute("position").count),0)}}else if(n.type==="SubdivGeometry"){let c=new St(n,e);return c.data=i,c}else{if(n.type==="TextGeometry")return new fn(n,t);if(n.type==="InputGeometry")return new fn(n,t);if(n.type==="UIGeometry")return Fa.create({parameters:{width:n.width,height:n.height,cornerRadius:n.cornerRadius,cornerType:n.cornerType}})}let l;try{l=Hf(s)}catch(c){console.error(c),console.error(`Error generating geometry with inputs: ${s}`);let u=Ue.createFromState(ya.defaultData(),100,100);s.shape=u,s.type="VectorGeometry",l=Hf(s)}return l}import{Matrix4 as PE}from"three";var OE=new PE;function yl(i,t,e,r){let o=i.position.array,n=i.normal.array,a=OE.makeScale(t,e,r).invert().elements,s,l,c;for(var u=0,d=o.length;u<d;u+=3)o[u]*=t,o[u+1]*=e,o[u+2]*=r,s=n[u],l=n[u+1],c=n[u+2],n[u]=a[0]*s+a[4]*l+a[8]*c,n[u+1]=a[1]*s+a[5]*l+a[9]*c,n[u+2]=a[2]*s+a[6]*l+a[10]*c;i.position.needsUpdate=!0,i.normal.needsUpdate=!0}var Hu=new AE,Ua=new gl,we;ku.then(i=>{we=i});var Ub=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),kb=new Uint32Array([0,1,2,3]),Hb=new Uint8Array([4]),St=class extends Wf{constructor(e,r){super();this.data=e;this.flatShading=r;this.subdivPointer=0;this.rebuild(),this.freeSubdivPointer()}mutateDirectlyScaleBaked(e,r){this.freeSubdivPointer();let o=this.data.scaleBaked.map(l=>typeof l=="number"?l:1),n=hi.div(r.map(l=>typeof l=="number"?l:0),o);if(n.every(l=>l===1))return;this.subdividedGeometry&&yl(this.subdividedGeometry.attributes,...n),this.originalGeometry&&yl(this.originalGeometry.attributes,...n),this.data=e;let a=this.userData.parameters;this.userData.parameters={width:a.width*n[0],height:a.height*n[1],depth:a.depth*n[2]},this.originalGeometry.boundingSphere.center.multiply(Ua.fromArray(n));let s=Ua.set(a.width,a.height,a.depth).length();this.originalGeometry.boundingSphere.radius=s/2}ensureSubdivPointer(){return this.subdivPointer===0&&this.rebuild(),this.subdivPointer}rebuild(){let e,r,o;try{({originalGeometry:e,subdividedGeometry:r,subdivPointer:o}=St.build(this.data,void 0,!this.flatShading,void 0))}catch{e=new ME(100,100,100),o=0}this.subdivPointer=o,this.originalGeometry=e,this.subdividedGeometry=r??void 0;let n=this.subdividedGeometry??this.originalGeometry;Object.assign(this,n),this.calcBoundingBox()}freeSubdivPointer(){this.subdivPointer&&(St.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new CE,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let r=e.attributes.position,o=e.boundingSphere.center;Hu.setFromBufferAttribute(r),Hu.getCenter(o),e.boundingSphere.radius=o.distanceTo(Hu.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),Hu.getSize(Ua);let n={width:Ua.x,height:Ua.y,depth:Ua.z};return this.userData.parameters=n,n}static build(e,r,o,n){let a,s,l,c=e?.phongAngle??35;o===!1&&(c=-1),r&&(we.free_bvh(r),we.free_subdivision_surface(r));try{a=St.allocate(e,n)}catch(u){console.error(u,e),a=St.allocate({positionWASM:Ub,indexWASM:kb,verticesPerFaceWASM:Hb},n)}if(we.set_destination_refinement_level(a,0),s=St.buildLevel(a,!0,c),e.subdivisions>0)try{we.set_destination_refinement_level(a,e.subdivisions),l=St.buildLevel(a,!1,c)}catch{try{we.set_destination_refinement_level(a,e.subdivisions-1),l=St.buildLevel(a,!1,c)}catch{l=null}}else l=null;return{subdivPointer:a,originalGeometry:s,subdividedGeometry:l}}static primitiveToQuads(e,r,o){e.widthSegments>16&&(e.widthSegments=16),e.heightSegments>16&&(e.heightSegments=16),e.depthSegments>16&&(e.depthSegments=16),e.radialSegments>16&&(e.radialSegments=16),e.type==="DodecahedronGeometry"&&(e.detail=0);let n=e.shape!==void 0||e.path!==void 0?r.geometry:mo(e,o,!1,r),a;e.type==="TorusGeometry"&&e.arc===Math.PI*2?a=n.getClosedTorusIndicesForBooleanOrSubdiv():a=n.getIndex();let s,l,c,u;({positions:s,triIndices:u}=Qf(n.getAttribute("position"),a));let d;if(e.type==="CylinderGeometry"&&e.cornerRadius===0&&e.hollow===0&&e.openEnded===!1){let p=e.radialSegments*e.heightSegments*3*2,f=p+e.radialSegments*3;d=[p,f]}return{indices:l,verticesPerFace:c}=Zf(s,u,n,d),{positions:s,indices:l,verticesPerFace:c}}static allocate(e,r){let o,n,a,s=[],l=[];e.positionWASM&&e.positionWASM.length>0?(o=e.positionWASM,n=e.indexWASM,a=e.verticesPerFaceWASM):(o=Ub,n=kb,a=Hb);let c=o.length,u=n.length,d=a.length,p=o.length+s.length+l.length,f=n.length+a.length,h=p*Float32Array.BYTES_PER_ELEMENT+f*Uint32Array.BYTES_PER_ELEMENT,m=p*Float32Array.BYTES_PER_ELEMENT,y=we._malloc(h),g=new Float32Array(we.HEAPF32.buffer,y,p),b=new Uint32Array(we.HEAPU32.buffer,y+m,f);g.set(o,0),g.set(s,o.length),g.set(l,o.length+s.length),b.set(n,0),b.set(a,n.length);let w;e?.scaleBaked?.some(S=>S!==1)&&(w=new TE().makeScale(...e.scaleBaked.map(S=>typeof S=="number"?S:1))),r&&(w?w.premultiply(r):w=r);let P=w?we.alloc_subdivision_surface2(y,c,y+m,u,y+m+n.length*Uint32Array.BYTES_PER_ELEMENT,d,w.elements):we.alloc_subdivision_surface(y,c,y+m,u,y+m+n.length*Uint32Array.BYTES_PER_ELEMENT,d);return we._free(y),P}static buildLevel(e,r,o,n,a){let s=a?we.get_mesh_data2(e,r?we.Level.CONTROL:we.Level.REFINED,o,a.elements):we.get_mesh_data(e,r?we.Level.CONTROL:we.Level.REFINED,o),l=8,c=we.HEAPU32.subarray(s>>2,(s>>2)+l),u=c.subarray(4,4+4),d=0,p=we.HEAPU32[c[d]>>2],f=we.HEAPF32.subarray(p>>2,(p>>2)+u[d]);d++;let h=we.HEAPU32[c[d]>>2],m=we.HEAPF32.subarray(h>>2,(h>>2)+u[d]);d++;let y=we.HEAPU32[c[d]>>2],g=we.HEAPU32.subarray(y>>2,(y>>2)+u[d]);d++;let b=we.HEAPU32[c[d]>>2],w=we.HEAPU32.subarray(b>>2,(b>>2)+u[d]);if(d++,n===void 0){let P=new Wf;if(P.setIndex(new qf(w,1)),P.setAttribute("position",new $f(f,3)),P.setAttribute("normal",new $f(m,3)),r){P.setAttribute("faceMap",new qf(g,1));let S=new Float32Array(m.length/3*4).fill(0);P.setAttribute("color",new jb(S,4))}return we.free_mesh_data(s),P.userData.type="SubdivGeometry",P}n.getAttribute("position").copyArray(f),n.getAttribute("normal").copyArray(m),n.attributes.position.needsUpdate=!0,n.attributes.normal.needsUpdate=!0,we.free_mesh_data(s)}static freeSubdivPointer(e){we.free_bvh(e),we.free_subdivision_surface(e)}static buildControlCageWireframe(e,r,o){let n=we.get_wireframe_data_for_base_level(e),a=4,s=we.HEAPU32.subarray(n>>2,(n>>2)+a),l=s.subarray(2,2+2),c=0,u=we.HEAPU32[s[c]>>2],d=we.HEAPF32.subarray(u>>2,(u>>2)+l[c]);c++;let p=we.HEAPU32[s[c]>>2],f=we.HEAPU32.subarray(p>>2,(p>>2)+l[c]);if(r===void 0){let h=new Wf;h.setAttribute("position",new $f(d,3));let m=new Float32Array(d.length);for(let y=0,g=d.length;y<g;)m[y++]=o.r,m[y++]=o.g,m[y++]=o.b;return h.setAttribute("color",new jb(m,3)),h.setIndex(new qf(f,1)),we.free_wireframe_data_for_base_level(n),h}r.getAttribute("position").copyArray(d),r.attributes.position.needsUpdate=!0,we.free_wireframe_data_for_base_level(n)}static updateCollabMesh(e,r,o){let n=r===0;n||we.set_destination_refinement_level(e,r);let a=o?we.get_topological_data2(e,n?we.Level.CONTROL:we.Level.REFINED,o.elements):we.get_topological_data(e,n?we.Level.CONTROL:we.Level.REFINED),s=6,l=we.HEAPU32.subarray(a>>2,(a>>2)+s),c=l.subarray(3,3+3),u=0,d=we.HEAPU32[l[u]>>2],p=new Float32Array(we.HEAPF32.subarray(d>>2,(d>>2)+c[u]));u++;let f=we.HEAPU32[l[u]>>2],h=new Uint32Array(we.HEAPU32.subarray(f>>2,(f>>2)+c[u]));u++;let m=we.HEAPU32[l[u]>>2],y=new Uint8Array(we.HEAPU32.subarray(m>>2,(m>>2)+c[u]));return we.free_topological_data(a),{positions:p,indices:h,verticesPerFace:y}}};var Wb=["getX","getY","getZ"];function Qf(i,t){let e={},r=t?t.count:i.count,o=0,n=[],a=[],s=1e4;for(let c=0;c<r;c++){let u=t?t.getX(c):c,d="";for(let p=0;p<3;p++)d+=`${~~(i[Wb[p]](u)*s)},`;if(d in e)n.push(e[d]);else{for(let p=0;p<3;p++)a.push(i[Wb[p]](u));e[d]=o,n.push(o),o++}}let l=[];for(let c=0;c<n.length;c+=3)n[c]===n[c+1]||n[c]===n[c+2]||n[c+1]===n[c+2]||l.push(n[c],n[c+1],n[c+2]);return{positions:a,triIndices:l}}var Wu=new gl,Xf=new gl,Yf=new gl,Kf=new gl;function Zf(i,t,e,r){let o=[],n=[];if(e.userData.shape!==void 0&&e.userData.parameters.depth===0&&e.userData.shape.shapeHoles.length===0){let l=e.userData.shape.extractShapePointsToFlatArray([]),c=e.userData.parameters.spikes;if(e.userData.type==="EllipseGeometry"&&c<=24&&c%4===0&&e.userData.parameters.angle>=360){let p=l.length/2/c;l=l.filter((f,h)=>Math.floor(h/2)%p===0)}let u=0;for(let p=0;p<l.length;p+=2)u+=(l[p]-l[(p===0?l.length:p)-2])*(l[p+1]+l[(p===0?l.length:p)-1]);i.length=0;let d=0;if(u<0)for(let p=0;p<l.length;p+=2)i.push(l[p],l[p+1],0),o.push(d++);else for(let p=l.length-2;p>=0;p-=2)i.push(l[p],l[p+1],0),o.push(d++);return n.push(d),{indices:o,verticesPerFace:n}}let a=new Float32Array([e.userData.parameters.depth])[0],s=0;for(;s<t.length;){if(e.useNgonForTopBottomFaceDuringBake){let l=0;if((i[t[s]*3+2]===a||i[t[s]*3+2]===0)&&l++,(i[t[s+1]*3+2]===a||i[t[s+1]*3+2]===0)&&l++,(i[t[s+2]*3+2]===a||i[t[s+2]*3+2]===0)&&l++,l===3)break}if(t[s+1]===t[s+3]&&t[s+2]===t[s+5]||t[s+0]===t[s+3]&&t[s+2]===t[s+4]){Wu.set(i[t[s]*3],i[t[s]*3+1],i[t[s]*3+2]),Xf.set(i[t[s+1]*3],i[t[s+1]*3+1],i[t[s+1]*3+2]),Yf.set(i[t[s+4]*3],i[t[s+4]*3+1],i[t[s+4]*3+2]),Kf.set(i[t[s+5]*3],i[t[s+5]*3+1],i[t[s+5]*3+2]),Xf.sub(Wu).normalize(),Yf.sub(Wu).normalize(),Kf.sub(Wu).normalize();let l=Xf.cross(Yf).dot(Kf),c=s;Math.abs(l)>.005||r&&r.some((u,d)=>d%2===1?!1:c>=r[d]&&c<r[d+1])?(o.push(t[s],t[s+1],t[s+2]),n.push(3),s+=3):(o.push(t[s],t[s+1],t[s+4],t[s+5]),n.push(4),s+=6)}else o.push(t[s],t[s+1],t[s+2]),n.push(3),s+=3}if(e.useNgonForTopBottomFaceDuringBake){let l=[],c=[],u=0;for(let d=0,p=0;d<i.length;d+=3,p++)i[d+2]===0&&(l.push(p),u++),i[d+2]===a&&c.push(p);if(e.userData.parameters.extrudeBevelSize===0){let d=c[0];c[0]=c[1],c[1]=d}l.reverse(),o.push(...l,...c),n.push(u,u)}return{indices:o,verticesPerFace:n}}var Or={};Cw(Or,{calcBoolean:()=>_E,calcBooleanTopological:()=>DE,freeMeshSet:()=>VE,getMeshSet:()=>RE,hasOpenEdges:()=>LE,transformMeshSet:()=>BE});var IE,qb=new Promise(i=>{IE=i});import{Float32BufferAttribute as $b,Sphere as EE}from"three";var Ve,ka;qb.then(i=>Ve=i);function NE(i,t,e){let r,o;i.userData.parameters.type==="TorusGeometry"&&i.userData.parameters.arc===Math.PI*2?o=i.getClosedTorusIndicesForBooleanOrSubdiv():o=i.getIndex();let{positions:n,triIndices:a}=Qf(i.getAttribute("position"),o),s;if(t&&e){let{indices:l,verticesPerFace:c}=Zf(n,a,i);s=c.length,r=[];for(let u=0,d=0;u<s;u++){r.push(c[u]);for(let p=0;p<c[u];p++)r.push(l[d++])}}else{let l=a.length;r=Array(l+l/3),s=0;for(let c=0,u=0;u<r.length;)r[u++]=3,s++,r[u++]=a[c++],r[u++]=a[c++],r[u++]=a[c++]}return{positions:n,faceIndices:r,nFaces:s}}function Xb(i){let t=i.length,e=t*Uint32Array.BYTES_PER_ELEMENT,r=t*Float32Array.BYTES_PER_ELEMENT,o=Number.isInteger(i[0])?e:r,n=Ve._malloc(o);return(Number.isInteger(i[0])?new Uint32Array(Ve.HEAPU32.buffer,n,t):new Float32Array(Ve.HEAPF32.buffer,n,t)).set(i,0),n}function Yb(i){switch(i){case 0:return Ve.OP.UNION;case 1:return Ve.OP.INTERSECTION;case 2:return Ve.OP.A_MINUS_B;default:throw new Error("Unknown boolean operation "+i)}}function DE(i,t){ka===void 0&&(ka=Ve.init_csg());let e=Xb(i),r=Ve.csg_calc_topological(ka,e,i.length,Yb(t));Ve._free(e);let o=6,n=Ve.HEAPU32.subarray(r>>2,(r>>2)+o),a=n.subarray(3,3+3),s=0,l=Ve.HEAPU32[n[s]>>2],c=new Float32Array(Ve.HEAPF32.subarray(l>>2,(l>>2)+a[s]));s++;let u=Ve.HEAPU32[n[s]>>2],d=new Uint32Array(Ve.HEAPU32.subarray(u>>2,(u>>2)+a[s]));s++;let p=Ve.HEAPU32[n[s]>>2],f=new Uint8Array(Ve.HEAPU32.subarray(p>>2,(p>>2)+a[s]));return Ve.free_mesh_data(r),{positions:c,indices:d,verticesPerFace:f}}function _E(i,t,e,r){ka===void 0&&(ka=Ve.init_csg());let o=Xb(i),n=Ve.csg_calc(ka,o,i.length,r,Yb(t));Ve._free(o);let a=5,s=Ve.HEAPU32.subarray(n>>2,(n>>2)+a),l=s.subarray(2,2+3),c=0,u=Ve.HEAPU32[s[c]>>2],d=Ve.HEAPF32.subarray(u>>2,(u>>2)+l[c]);c++;let p=Ve.HEAPU32[s[c]>>2],f=Ve.HEAPF32.subarray(p>>2,(p>>2)+l[c]);c++;let h=l[c];e.setAttribute("position",new $b(d,3)),e.setAttribute("normal",new $b(f,3));let m=Ve.HEAPF32.subarray((n>>2)+5,(n>>2)+5+6);return e.boundingSphere===null&&(e.boundingSphere=new EE),e.boundingSphere.center.set(m[0],m[1],m[2]),e.boundingSphere.radius=(m[3]**2+m[4]**2+m[5]**2)**.5,e.userData.parameters={width:m[3]*2,height:m[4]*2,depth:m[5]*2},Ve.free_mesh_data(n),h}function RE(i,t,e){if(Ve===void 0)return-1;let r,o,n;if(t&&i.userData.positions!==void 0){let g=i.userData;n=g.verticesPerFace.length,r=g.positions,o=Array(g.verticesPerFace.reduce((b,w)=>b+w,0)+n);for(let b=0,w=0,P=0;b<g.verticesPerFace.length;b++){o[P++]=g.verticesPerFace[b];for(let S=0;S<g.verticesPerFace[b];S++)o[P++]=g.indices[w++]}}else({positions:r,faceIndices:o,nFaces:n}=NE(i,t,e));let a=r.length,s=o.length,l=r.length,c=o.length,u=l*Float32Array.BYTES_PER_ELEMENT+c*Uint32Array.BYTES_PER_ELEMENT,d=l*Float32Array.BYTES_PER_ELEMENT,p=c*Uint32Array.BYTES_PER_ELEMENT,f=Ve._malloc(u),h=new Float32Array(Ve.HEAPF32.buffer,f,l),m=new Uint32Array(Ve.HEAPU32.buffer,f+d,c);h.set(r,0),m.set(o,0);let y=Ve.get_csg_mesh(f,a,f+d,s,n);return Ve._free(f),y}function LE(i){return Ve.has_open_edges(i)}function BE(i,t){Ve.transform_csg_mesh(i,t.elements)}function VE(i){Ve.free_csg_mesh(i)}var zE={ConeGeometry:Ex,CubeGeometry:Nx,CylinderGeometry:Ix,DodecahedronGeometry:Dx,EllipseGeometry:Ba,HelixGeometry:lb,IcosahedronGeometry:cb,LatheGeometry:ub,NonParametricGeometry:vb,PolygonGeometry:zu,PyramidGeometry:Sb,RectangleGeometry:Fa,SphereGeometry:Pb,PlaneGeometry:Ob,BackdropGeometry:Tb,StarGeometry:Gu,TextFrameGeometry:Cb,TorusGeometry:Ab,TorusKnotGeometry:Mb,TriangleGeometry:Ib,PathGeometry:Lb,VectorGeometry:rr},Hf=i=>zE[i.type].create(i);function Ha(i){return i!==null&&"booleanOp"in i}var Wa=class extends Ma(FE){constructor(){super(...arguments);this.booleanMeshSetAddress=-1;this.booleanWasTransformed=!1;this.booleanMatrixInvOld=new GE}updateVisible(e){super.updateVisible(e),this.visible=!Ha(this.parent)&&this.visible,Ha(this.parent)&&this.parent.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(Or.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(e=!1){return e?this.booleanWasTransformed=!0:this.freeBooleanPointer(),Ha(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)e instanceof Wa&&(e.freeBooleanPointer(),Ha(e)&&e.invalidateUpstreamBooleanData())}updateTransformState(e,r){let o=super.updateTransformState(e,r);return o&&Ha(this.parent)&&this.invalidateDownstreamBooleanData(!0),o}onVariableUpdate(e=!1){super.onVariableUpdate(e),Ha(this.parent)&&this.invalidateDownstreamBooleanData(!0)}};var qu=new jE;function xl(i,t=0,e=i.count,r,o){let n=1/0,a=1/0,s=1/0,l=-1/0,c=-1/0,u=-1/0;for(let d=t;d<e;d++){let p=i.getX(d),f=i.getY(d),h=i.getZ(d);p<n&&(n=p),f<a&&(a=f),h<s&&(s=h),p>l&&(l=p),f>c&&(c=f),h>u&&(u=h)}qu.min.set(n,a,s),qu.max.set(l,c,u),qu.getCenter(r),qu.getSize(o).multiplyScalar(.5)}var HE=new UE,WE=new kE,It=class extends Wa{constructor(t,e){super(HE,WE),this.super_Entity(t,e)}updateState(t,e){this.updateState_Entity(t,e)}updateEntityBoxSize(t,e){let r=this.geometry.getAttribute("position");r!==void 0?xl(r,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:r.count,t,e):super.updateEntityBoxSize(t,e)}};import{Box3 as mD,Matrix4 as yD,Sphere as Uv,Vector3 as gD}from"three";import{BufferAttribute as pD,Float32BufferAttribute as jv,MathUtils as Ah,Vector3 as Mh}from"three";import{ShaderMaterial as kN,Texture as HN}from"three";var Wo=class{constructor(t){this.hashProperties=void 0;this.isNode=!0;this.shortcuts={};if(Wo.uuidContext===null)throw new Error("plz startContext");Wo.uuidContext===Wo.globalContext?this.uuid="_gid"+Wo.uuidContext.nodeContextUuid++:this.uuid="_uid"+Wo.uuidContext.nodeContextUuid++,this.type=t,this.name=""}static startContext(t){this.uuidContext===null||this.uuidContext===Wo.globalContext?this.uuidContext=t:console.error("Can't start context twice")}static endContext(t){this.uuidContext!==t&&console.error("Can't end context twice"),this.uuidContext=null}analyze(t,e){e=e??{},t.analyzing=!0,this.build(t.addFlow(e.slot,e.cache,e.context),"v4"),t.clearVertexNodeCode(),t.clearFragmentNodeCode(),t.removeFlow(),t.analyzing=!1}analyzeAndFlow(t,e,r){return r=r??{},this.analyze(t,r),this.flow(t,e,r)}flow(t,e,r){r=r??{},t.addFlow(r.slot,r.cache,r.context);let o={result:this.build(t,e),code:t.clearNodeCode(),extra:t.context.extra};return t.removeFlow(),o}build(t,e,r){e=e??this.getType(t,e);let o=t.getNodeData(r??this);return t.analyzing&&this.appendDepsNode(t,o,e),t.nodes.indexOf(this)===-1&&t.nodes.push(this),this.updateFrame!==void 0&&t.updaters.indexOf(this)===-1&&t.updaters.push(this),this.generate(t,e,r)}updateFrame(t){}generateReadonly(t,e,r,o,n,a){return""}generate(t,e,r,o,n){return""}parse(t,e,r,o){}appendDepsNode(t,e,r){e.deps=(e.deps||0)+1;let o=t.getTypeLength(r);(o>(e.outputMax||0)||this.getType(t,r))&&(e.outputMax=o,e.output=r)}setName(t){this.name=t}getName(){return this.name}getType(t,e){return e==="sampler2D"||e==="samplerCube"?e:this.type}},Xe=Wo;Xe.globalContext={nodeContextUuid:0},Xe.uuidContext=Wo.globalContext;import{CubeReflectionMapping as rN,CubeRefractionMapping as oN,CubeUVReflectionMapping as iN,LinearEncoding as nv,sRGBEncoding as nN}from"three";var bl=class{constructor(t){t=t??{},this.name=t.name,this.type=t.type,this.node=t.node,this.size=t.size,this.needsUpdate=t.needsUpdate}get value(){return this.node.value}set value(t){this.node.value=t}};var Jf=class{constructor(){this.nodes={};this.keywords={}}add(t){this.nodes[t.name]=t}addKeyword(t,e,r){r=r!==void 0?r:!0,this.keywords[t]={callback:e,cache:r}}remove(t){delete this.nodes[t.name]}removeKeyword(t){delete this.keywords[t]}get(t){return this.nodes[t]}getKeyword(t,e){return this.keywords[t].callback(e)}getKeywordData(t){return this.keywords[t]}contains(t){return this.nodes[t]!==void 0}containsKeyword(t){return this.keywords[t]!==void 0}},Et=new Jf;import{Vector2 as Kb}from"three";import{MathUtils as qE}from"three";var ge=class extends Xe{constructor(e,r){super(e);this.scope="";r=r??{},this.shared=r.shared!==void 0?r.shared:!0,this.unique=r.unique!==void 0?r.unique:!1}build(e,r,o,n){if(r=r??this.getType(e),this.getShared(e,r)){let a=this.getUnique(e,r);a&&this.uuid===void 0&&(this.uuid=qE.generateUUID()),o=e.getUUID(o??this.getUUID(),!a);let s=e.getNodeData(o),l=s.output||this.getType(e);if(e.analyzing)return(s.deps||0)>0||this.getLabel()?(this.appendDepsNode(e,s,r),this.generate(e,r,o)):super.build(e,r,o);if(a)return s.name=s.name||super.build(e,r,o),s.name;if(!this.getLabel()&&(!this.getShared(e,l)||e.context.ignoreCache||s.deps===1))return super.build(e,r,o);o=this.getUUID(!1);let c=this.getTemp(e,o);if(c)return e.format(c,l,r);{c=super.generate(e,r,o,s.output,n);let u=this.generate(e,l,o);return e.addNodeCode(c+" = "+u+";"),e.format(c,l,r)}}return super.build(e,r,o)}getShared(e,r){return r!=="sampler2D"&&r!=="samplerCube"&&this.shared}getUnique(e,r){return this.unique}setLabel(e){return this.label=e,this}getLabel(){return this.label}getUUID(e){let r=this.uuid;return typeof this.scope=="string"&&(r=this.scope+"-"+r),r}getTemp(e,r){r=r||this.uuid;let o=e.getVars()[r];return o?o.name:void 0}generate(e,r,o,n,a){return this.getShared(e,r)||console.error("TempNode is not shared"),o=o??this.uuid,e.getTempVar(o,n??this.getType(e),a,this.getLabel()).name}};var Ye=class extends ge{constructor(e,r){r=r??{},r.shared=r.shared!==void 0?r.shared:!1;super(e,r);this.readonly=!1}setReadonly(e){return this.readonly=e,this.hashProperties=this.readonly?["value"]:void 0,this}getReadonly(){return this.readonly}generate(e,r,o,n,a,s){o=e.getUUID(o??this.getUUID()),n=n??this.getType(e);let l=e.getNodeData(o);return this.getReadonly()&&this.generateReadonly!==void 0?this.generateReadonly(e,r,o,n,a,s):e.isShader("vertex")?(l.vertex||(l.vertex=e.createVertexUniform(n,this,a,s,this.getLabel())),e.format(l.vertex.name,n,r)):(l.fragment||(l.fragment=e.createFragmentUniform(n,this,a,s,this.getLabel())),e.format(l.fragment.name,n,r))}};var ut=class extends Ye{constructor(e=0,r){super("v2");this.nodeType="Vector2";this.value=e instanceof Kb?e:new Kb(e,r)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}generateReadonly(e,r,o,n,a,s){return e.format("vec2("+this.value.x+", "+this.value.y+")",n,r)}};import{Vector3 as Qb}from"three";var jt=class extends Ye{constructor(e=0,r,o){super("v3");this.nodeType="Vector3";this.value=e instanceof Qb?e:new Qb(e,r,o)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}get z(){return this.value.z}set z(e){this.value.z=e}generateReadonly(e,r,o,n,a,s){return e.format("vec3("+this.value.x+", "+this.value.y+", "+this.value.z+")",n,r)}};import{Color as $E}from"three";var Nt=class extends $E{constructor(e,r,o,n){super(e,r,o);this.isColorA=!0;this.a=n}setRGBA(e,r,o,n){super.setRGB(e,r,o),this.a=n}copy(e){return super.copy(e),this.a="a"in e?e.a:1,this}clone(){return new this.constructor(this.r,this.g,this.b,this.a)}equals(e){return super.equals(e)&&this.a===e.a}setStyle(e,r="srgb"){let o;if(e==="transparent")return this.setRGBA(0,0,0,0),this;if(o=/^((?:rgb|hsl)a?)\(([^)]*)\)/.exec(e)){let n,a=o[1],s=o[2];switch(a){case"rgb":case"rgba":if(n=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return this.a=a==="rgba"?parseFloat(n[4]):1,super.setStyle(e,r);break;case"hsl":case"hsla":if(n=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)%\s*,\s*(\d*\.?\d+)%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return this.a=a==="hsla"?parseFloat(n[4]):1,super.setStyle(e,r);break}}return super.setStyle(e,r)}get x(){return this.r}get y(){return this.g}get z(){return this.b}get w(){return this.a}set x(e){this.r=e}set y(e){this.g=e}set z(e){this.b=e}set w(e){this.a=e}};var or=class extends Ye{constructor(e){super("v4");this.nodeType="Vector4";this.value=e instanceof Nt?e:new Nt(e.r,e.g,e.b,e.a)}generateReadonly(e,r,o,n,a,s){return e.format("vec4("+this.value.r+", "+this.value.g+", "+this.value.b+", "+this.value.a+")",n,r)}};var XE=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,Zb=/[a-z_0-9]+/gi,Z=class extends ge{constructor(e,r,o,n,a){super(a);this.src="";this.nodeType="Function";this.useKeywords=!0;this.includes=[];this.extensions={};this.keywords={};this.isMethod=a===void 0,this.isInterface=!1,this.parse(e,r,o,n)}getShared(e,r){return!this.isMethod}getType(e){return e.getTypeByFormat(this.type)}getInputByName(e){if(this.inputs){let r=this.inputs.length;for(;r--;)if(this.inputs[r].name===e)return this.inputs[r]}}getIncludeByName(e){if(this.includes){let r=this.includes.length;for(;r--;)if(this.includes[r].name===e)return this.includes[r]}}generate(e,r,o,n,a){let s,l=0,c=this.src;if(this.includes)for(let d=0;d<this.includes.length;d++)e.include(this.includes[d],this);for(let d in this.extensions)e.extensions[d]=!0;let u=[];for(;s=Zb.exec(this.src);)u.push(s);for(let d=0;d<u.length;d++){let p=u[d],f=p[0],h=this.isMethod?!this.getInputByName(f):!0,m=f;if(this.keywords[f]||this.useKeywords&&h&&Et.containsKeyword(f)){let y=this.keywords[f];if(!y){let g=Et.getKeywordData(f);g.cache&&(y=e.keywords[f]),y=y||Et.getKeyword(f,e),g.cache&&(e.keywords[f]=y)}m=y.build(e)}f!==m&&c[p.index+l-1]!=="."&&(c=c.substring(0,p.index+l)+m+c.substring(p.index+f.length+l),l+=m.length-f.length),this.getIncludeByName(m)===void 0&&Et.contains(m)&&e.include(Et.get(m))}return r==="source"?c:this.isMethod?(this.isInterface||e.include(this,void 0,c),this.name):e.format("( "+c+" )",this.getType(e),r)}parse(e,r,o,n){if(this.src=e||"",this.includes=r??[],this.extensions=o??{},this.keywords=n??{},this.isMethod){let a=XE.exec(this.src);if(this.inputs=[],a&&a.length==4){this.type=a[1],this.name=a[2];let s=a[3].match(Zb);if(s){let l=0;for(;l<s.length;){let c=s[l++],u;c==="in"||c==="out"||c==="inout"?u=s[l++]:(u=c,c="");let d=s[l++];this.inputs.push({name:d,type:u,qualifier:c})}}this.isInterface=this.src.indexOf("{")===-1}else this.type="",this.name=""}}};var YE=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,eh=class extends ge{constructor(e="",r){super();this.src="";this.useDefine=!1;this.nodeType="Const";this.parse(e||eh.PI,void 0,void 0,void 0,r)}getType(e){return e.getTypeByFormat(this.type)}parse(e,r,o,n,a){this.src=e||"";let s,l,c="",u=YE.exec(e);this.useDefine=a??this.src.charAt(0)==="#",u&&u.length>1?(l=u[1],s=u[2],c=u[3]):(s=this.src,l="f"),this.name=s,this.type=l,this.value=c}build(e,r){if(r==="source"){if(this.value)return this.useDefine?"#define "+this.name+" "+this.value:"const "+this.type+" "+this.name+" = "+this.value+";";if(this.useDefine)return this.src}return e.include(this),e.format(this.name,this.getType(e),r)}generate(e,r,o,n,a){return e.format(this.name,this.getType(e),r)}},Fe=eh;Fe.PI="PI",Fe.PI2="PI2",Fe.RECIPROCAL_PI="RECIPROCAL_PI",Fe.RECIPROCAL_PI2="RECIPROCAL_PI2",Fe.LOG2="LOG2",Fe.EPSILON="EPSILON";var KE=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
18
+ `&&n.push("")):t.getTextWidth(n[n.length-1]+a,i)>o&&(n[n.length-1].length&&n.push(""),t.getTextWidth(n[n.length-1]+a,i)>o&&(a.length===1?(n[n.length-1]+=a,a=""):(n[n.length-1]+=a.slice(0,-1),a=a[a.length-1],n.push(""))));return n[n.length-1]+=a,n}import{BufferGeometry as Wf,BufferAttribute as jb,Uint32BufferAttribute as qf,Float32BufferAttribute as $f,Matrix4 as TE,Vector3 as gl,Sphere as CE,Box3 as AE,BoxGeometry as ME}from"three";var Gb,ku=new Promise(i=>{Gb=i}),zb=!1;var Uu;function Fb(i){if(zb)return;if(Uu)return Uu;async function t(){let r=i??(!1?".":"https://unpkg.com/@splinetool/modelling-wasm@1.12.88/build"),n=import("./process.js"),[a,s]=await Promise.all([n,fetch(`${r}/process.wasm`).then(u=>u.arrayBuffer())]),l=a.default,c=await l({wasmBinary:s});Gb(c),zb=!0}return Uu=t(),Uu}import{BufferGeometryLoader as SE}from"three";var wE=["font"];function mo(i,t,e,r){let o,n,a;i.type==="PathGeometry"?(n=JSON.parse(JSON.stringify(i)),a=[[],["extrusion"]]):(n={...i},a=[[]]);for(let c of a){let u=n;for(let d of c)u=u[d];for(o in u){let d=u[o];Dp(d)&&!wE.includes(o)&&(u[o]=t.getVariable(d,[r.uuid,"geometry",...c,o]),Dp(u[o])&&(u[o]=1))}}let s={parameters:n,type:n.type};if(n.type==="PathGeometry")s.path=n.path;else if(n.type==="VectorGeometry"){let c=Ue.createFromState(n.shape,n.width,n.height);s.shape=c}else if(n.type==="NonParametricGeometry"){if(n.data.groups&&n.data.groups?.forEach(c=>c.materialIndex=Math.max(c.materialIndex??0,0)),s.geometry=new SE().parse(n),s.geometry.groups.length===0){let c=s.geometry;c.addGroup(0,Math.max(c.getIndex()?.count??0,c.getAttribute("position").count),0)}}else if(n.type==="SubdivGeometry"){let c=new St(n,e);return c.data=i,c}else{if(n.type==="TextGeometry")return new fn(n,t);if(n.type==="InputGeometry")return new fn(n,t);if(n.type==="UIGeometry")return Fa.create({parameters:{width:n.width,height:n.height,cornerRadius:n.cornerRadius,cornerType:n.cornerType}})}let l;try{l=Hf(s)}catch(c){console.error(c),console.error(`Error generating geometry with inputs: ${s}`);let u=Ue.createFromState(ya.defaultData(),100,100);s.shape=u,s.type="VectorGeometry",l=Hf(s)}return l}import{Matrix4 as PE}from"three";var OE=new PE;function yl(i,t,e,r){let o=i.position.array,n=i.normal.array,a=OE.makeScale(t,e,r).invert().elements,s,l,c;for(var u=0,d=o.length;u<d;u+=3)o[u]*=t,o[u+1]*=e,o[u+2]*=r,s=n[u],l=n[u+1],c=n[u+2],n[u]=a[0]*s+a[4]*l+a[8]*c,n[u+1]=a[1]*s+a[5]*l+a[9]*c,n[u+2]=a[2]*s+a[6]*l+a[10]*c;i.position.needsUpdate=!0,i.normal.needsUpdate=!0}var Hu=new AE,Ua=new gl,we;ku.then(i=>{we=i});var Ub=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),kb=new Uint32Array([0,1,2,3]),Hb=new Uint8Array([4]),St=class extends Wf{constructor(e,r){super();this.data=e;this.flatShading=r;this.subdivPointer=0;this.rebuild(),this.freeSubdivPointer()}mutateDirectlyScaleBaked(e,r){this.freeSubdivPointer();let o=this.data.scaleBaked.map(l=>typeof l=="number"?l:1),n=hi.div(r.map(l=>typeof l=="number"?l:0),o);if(n.every(l=>l===1))return;this.subdividedGeometry&&yl(this.subdividedGeometry.attributes,...n),this.originalGeometry&&yl(this.originalGeometry.attributes,...n),this.data=e;let a=this.userData.parameters;this.userData.parameters={width:a.width*n[0],height:a.height*n[1],depth:a.depth*n[2]},this.originalGeometry.boundingSphere.center.multiply(Ua.fromArray(n));let s=Ua.set(a.width,a.height,a.depth).length();this.originalGeometry.boundingSphere.radius=s/2}ensureSubdivPointer(){return this.subdivPointer===0&&this.rebuild(),this.subdivPointer}rebuild(){let e,r,o;try{({originalGeometry:e,subdividedGeometry:r,subdivPointer:o}=St.build(this.data,void 0,!this.flatShading,void 0))}catch{e=new ME(100,100,100),o=0}this.subdivPointer=o,this.originalGeometry=e,this.subdividedGeometry=r??void 0;let n=this.subdividedGeometry??this.originalGeometry;Object.assign(this,n),this.calcBoundingBox()}freeSubdivPointer(){this.subdivPointer&&(St.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new CE,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let r=e.attributes.position,o=e.boundingSphere.center;Hu.setFromBufferAttribute(r),Hu.getCenter(o),e.boundingSphere.radius=o.distanceTo(Hu.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),Hu.getSize(Ua);let n={width:Ua.x,height:Ua.y,depth:Ua.z};return this.userData.parameters=n,n}static build(e,r,o,n){let a,s,l,c=e?.phongAngle??35;o===!1&&(c=-1),r&&(we.free_bvh(r),we.free_subdivision_surface(r));try{a=St.allocate(e,n)}catch(u){console.error(u,e),a=St.allocate({positionWASM:Ub,indexWASM:kb,verticesPerFaceWASM:Hb},n)}if(we.set_destination_refinement_level(a,0),s=St.buildLevel(a,!0,c),e.subdivisions>0)try{we.set_destination_refinement_level(a,e.subdivisions),l=St.buildLevel(a,!1,c)}catch{try{we.set_destination_refinement_level(a,e.subdivisions-1),l=St.buildLevel(a,!1,c)}catch{l=null}}else l=null;return{subdivPointer:a,originalGeometry:s,subdividedGeometry:l}}static primitiveToQuads(e,r,o){e.widthSegments>16&&(e.widthSegments=16),e.heightSegments>16&&(e.heightSegments=16),e.depthSegments>16&&(e.depthSegments=16),e.radialSegments>16&&(e.radialSegments=16),e.type==="DodecahedronGeometry"&&(e.detail=0);let n=e.shape!==void 0||e.path!==void 0?r.geometry:mo(e,o,!1,r),a;e.type==="TorusGeometry"&&e.arc===Math.PI*2?a=n.getClosedTorusIndicesForBooleanOrSubdiv():a=n.getIndex();let s,l,c,u;({positions:s,triIndices:u}=Qf(n.getAttribute("position"),a));let d;if(e.type==="CylinderGeometry"&&e.cornerRadius===0&&e.hollow===0&&e.openEnded===!1){let p=e.radialSegments*e.heightSegments*3*2,f=p+e.radialSegments*3;d=[p,f]}return{indices:l,verticesPerFace:c}=Zf(s,u,n,d),{positions:s,indices:l,verticesPerFace:c}}static allocate(e,r){let o,n,a,s=[],l=[];e.positionWASM&&e.positionWASM.length>0?(o=e.positionWASM,n=e.indexWASM,a=e.verticesPerFaceWASM):(o=Ub,n=kb,a=Hb);let c=o.length,u=n.length,d=a.length,p=o.length+s.length+l.length,f=n.length+a.length,h=p*Float32Array.BYTES_PER_ELEMENT+f*Uint32Array.BYTES_PER_ELEMENT,m=p*Float32Array.BYTES_PER_ELEMENT,y=we._malloc(h),g=new Float32Array(we.HEAPF32.buffer,y,p),b=new Uint32Array(we.HEAPU32.buffer,y+m,f);g.set(o,0),g.set(s,o.length),g.set(l,o.length+s.length),b.set(n,0),b.set(a,n.length);let w;e?.scaleBaked?.some(S=>S!==1)&&(w=new TE().makeScale(...e.scaleBaked.map(S=>typeof S=="number"?S:1))),r&&(w?w.premultiply(r):w=r);let P=w?we.alloc_subdivision_surface2(y,c,y+m,u,y+m+n.length*Uint32Array.BYTES_PER_ELEMENT,d,w.elements):we.alloc_subdivision_surface(y,c,y+m,u,y+m+n.length*Uint32Array.BYTES_PER_ELEMENT,d);return we._free(y),P}static buildLevel(e,r,o,n,a){let s=a?we.get_mesh_data2(e,r?we.Level.CONTROL:we.Level.REFINED,o,a.elements):we.get_mesh_data(e,r?we.Level.CONTROL:we.Level.REFINED,o),l=8,c=we.HEAPU32.subarray(s>>2,(s>>2)+l),u=c.subarray(4,4+4),d=0,p=we.HEAPU32[c[d]>>2],f=we.HEAPF32.subarray(p>>2,(p>>2)+u[d]);d++;let h=we.HEAPU32[c[d]>>2],m=we.HEAPF32.subarray(h>>2,(h>>2)+u[d]);d++;let y=we.HEAPU32[c[d]>>2],g=we.HEAPU32.subarray(y>>2,(y>>2)+u[d]);d++;let b=we.HEAPU32[c[d]>>2],w=we.HEAPU32.subarray(b>>2,(b>>2)+u[d]);if(d++,n===void 0){let P=new Wf;if(P.setIndex(new qf(w,1)),P.setAttribute("position",new $f(f,3)),P.setAttribute("normal",new $f(m,3)),r){P.setAttribute("faceMap",new qf(g,1));let S=new Float32Array(m.length/3*4).fill(0);P.setAttribute("color",new jb(S,4))}return we.free_mesh_data(s),P.userData.type="SubdivGeometry",P}n.getAttribute("position").copyArray(f),n.getAttribute("normal").copyArray(m),n.attributes.position.needsUpdate=!0,n.attributes.normal.needsUpdate=!0,we.free_mesh_data(s)}static freeSubdivPointer(e){we.free_bvh(e),we.free_subdivision_surface(e)}static buildControlCageWireframe(e,r,o){let n=we.get_wireframe_data_for_base_level(e),a=4,s=we.HEAPU32.subarray(n>>2,(n>>2)+a),l=s.subarray(2,2+2),c=0,u=we.HEAPU32[s[c]>>2],d=we.HEAPF32.subarray(u>>2,(u>>2)+l[c]);c++;let p=we.HEAPU32[s[c]>>2],f=we.HEAPU32.subarray(p>>2,(p>>2)+l[c]);if(r===void 0){let h=new Wf;h.setAttribute("position",new $f(d,3));let m=new Float32Array(d.length);for(let y=0,g=d.length;y<g;)m[y++]=o.r,m[y++]=o.g,m[y++]=o.b;return h.setAttribute("color",new jb(m,3)),h.setIndex(new qf(f,1)),we.free_wireframe_data_for_base_level(n),h}r.getAttribute("position").copyArray(d),r.attributes.position.needsUpdate=!0,we.free_wireframe_data_for_base_level(n)}static updateCollabMesh(e,r,o){let n=r===0;n||we.set_destination_refinement_level(e,r);let a=o?we.get_topological_data2(e,n?we.Level.CONTROL:we.Level.REFINED,o.elements):we.get_topological_data(e,n?we.Level.CONTROL:we.Level.REFINED),s=6,l=we.HEAPU32.subarray(a>>2,(a>>2)+s),c=l.subarray(3,3+3),u=0,d=we.HEAPU32[l[u]>>2],p=new Float32Array(we.HEAPF32.subarray(d>>2,(d>>2)+c[u]));u++;let f=we.HEAPU32[l[u]>>2],h=new Uint32Array(we.HEAPU32.subarray(f>>2,(f>>2)+c[u]));u++;let m=we.HEAPU32[l[u]>>2],y=new Uint8Array(we.HEAPU32.subarray(m>>2,(m>>2)+c[u]));return we.free_topological_data(a),{positions:p,indices:h,verticesPerFace:y}}};var Wb=["getX","getY","getZ"];function Qf(i,t){let e={},r=t?t.count:i.count,o=0,n=[],a=[],s=1e4;for(let c=0;c<r;c++){let u=t?t.getX(c):c,d="";for(let p=0;p<3;p++)d+=`${~~(i[Wb[p]](u)*s)},`;if(d in e)n.push(e[d]);else{for(let p=0;p<3;p++)a.push(i[Wb[p]](u));e[d]=o,n.push(o),o++}}let l=[];for(let c=0;c<n.length;c+=3)n[c]===n[c+1]||n[c]===n[c+2]||n[c+1]===n[c+2]||l.push(n[c],n[c+1],n[c+2]);return{positions:a,triIndices:l}}var Wu=new gl,Xf=new gl,Yf=new gl,Kf=new gl;function Zf(i,t,e,r){let o=[],n=[];if(e.userData.shape!==void 0&&e.userData.parameters.depth===0&&e.userData.shape.shapeHoles.length===0){let l=e.userData.shape.extractShapePointsToFlatArray([]),c=e.userData.parameters.spikes;if(e.userData.type==="EllipseGeometry"&&c<=24&&c%4===0&&e.userData.parameters.angle>=360){let p=l.length/2/c;l=l.filter((f,h)=>Math.floor(h/2)%p===0)}let u=0;for(let p=0;p<l.length;p+=2)u+=(l[p]-l[(p===0?l.length:p)-2])*(l[p+1]+l[(p===0?l.length:p)-1]);i.length=0;let d=0;if(u<0)for(let p=0;p<l.length;p+=2)i.push(l[p],l[p+1],0),o.push(d++);else for(let p=l.length-2;p>=0;p-=2)i.push(l[p],l[p+1],0),o.push(d++);return n.push(d),{indices:o,verticesPerFace:n}}let a=new Float32Array([e.userData.parameters.depth])[0],s=0;for(;s<t.length;){if(e.useNgonForTopBottomFaceDuringBake){let l=0;if((i[t[s]*3+2]===a||i[t[s]*3+2]===0)&&l++,(i[t[s+1]*3+2]===a||i[t[s+1]*3+2]===0)&&l++,(i[t[s+2]*3+2]===a||i[t[s+2]*3+2]===0)&&l++,l===3)break}if(t[s+1]===t[s+3]&&t[s+2]===t[s+5]||t[s+0]===t[s+3]&&t[s+2]===t[s+4]){Wu.set(i[t[s]*3],i[t[s]*3+1],i[t[s]*3+2]),Xf.set(i[t[s+1]*3],i[t[s+1]*3+1],i[t[s+1]*3+2]),Yf.set(i[t[s+4]*3],i[t[s+4]*3+1],i[t[s+4]*3+2]),Kf.set(i[t[s+5]*3],i[t[s+5]*3+1],i[t[s+5]*3+2]),Xf.sub(Wu).normalize(),Yf.sub(Wu).normalize(),Kf.sub(Wu).normalize();let l=Xf.cross(Yf).dot(Kf),c=s;Math.abs(l)>.005||r&&r.some((u,d)=>d%2===1?!1:c>=r[d]&&c<r[d+1])?(o.push(t[s],t[s+1],t[s+2]),n.push(3),s+=3):(o.push(t[s],t[s+1],t[s+4],t[s+5]),n.push(4),s+=6)}else o.push(t[s],t[s+1],t[s+2]),n.push(3),s+=3}if(e.useNgonForTopBottomFaceDuringBake){let l=[],c=[],u=0;for(let d=0,p=0;d<i.length;d+=3,p++)i[d+2]===0&&(l.push(p),u++),i[d+2]===a&&c.push(p);if(e.userData.parameters.extrudeBevelSize===0){let d=c[0];c[0]=c[1],c[1]=d}l.reverse(),o.push(...l,...c),n.push(u,u)}return{indices:o,verticesPerFace:n}}var Or={};Cw(Or,{calcBoolean:()=>_E,calcBooleanTopological:()=>DE,freeMeshSet:()=>VE,getMeshSet:()=>RE,hasOpenEdges:()=>LE,transformMeshSet:()=>BE});var IE,qb=new Promise(i=>{IE=i});import{Float32BufferAttribute as $b,Sphere as EE}from"three";var Ve,ka;qb.then(i=>Ve=i);function NE(i,t,e){let r,o;i.userData.parameters.type==="TorusGeometry"&&i.userData.parameters.arc===Math.PI*2?o=i.getClosedTorusIndicesForBooleanOrSubdiv():o=i.getIndex();let{positions:n,triIndices:a}=Qf(i.getAttribute("position"),o),s;if(t&&e){let{indices:l,verticesPerFace:c}=Zf(n,a,i);s=c.length,r=[];for(let u=0,d=0;u<s;u++){r.push(c[u]);for(let p=0;p<c[u];p++)r.push(l[d++])}}else{let l=a.length;r=Array(l+l/3),s=0;for(let c=0,u=0;u<r.length;)r[u++]=3,s++,r[u++]=a[c++],r[u++]=a[c++],r[u++]=a[c++]}return{positions:n,faceIndices:r,nFaces:s}}function Xb(i){let t=i.length,e=t*Uint32Array.BYTES_PER_ELEMENT,r=t*Float32Array.BYTES_PER_ELEMENT,o=Number.isInteger(i[0])?e:r,n=Ve._malloc(o);return(Number.isInteger(i[0])?new Uint32Array(Ve.HEAPU32.buffer,n,t):new Float32Array(Ve.HEAPF32.buffer,n,t)).set(i,0),n}function Yb(i){switch(i){case 0:return Ve.OP.UNION;case 1:return Ve.OP.INTERSECTION;case 2:return Ve.OP.A_MINUS_B;default:throw new Error("Unknown boolean operation "+i)}}function DE(i,t){ka===void 0&&(ka=Ve.init_csg());let e=Xb(i),r=Ve.csg_calc_topological(ka,e,i.length,Yb(t));Ve._free(e);let o=6,n=Ve.HEAPU32.subarray(r>>2,(r>>2)+o),a=n.subarray(3,3+3),s=0,l=Ve.HEAPU32[n[s]>>2],c=new Float32Array(Ve.HEAPF32.subarray(l>>2,(l>>2)+a[s]));s++;let u=Ve.HEAPU32[n[s]>>2],d=new Uint32Array(Ve.HEAPU32.subarray(u>>2,(u>>2)+a[s]));s++;let p=Ve.HEAPU32[n[s]>>2],f=new Uint8Array(Ve.HEAPU32.subarray(p>>2,(p>>2)+a[s]));return Ve.free_mesh_data(r),{positions:c,indices:d,verticesPerFace:f}}function _E(i,t,e,r){ka===void 0&&(ka=Ve.init_csg());let o=Xb(i),n=Ve.csg_calc(ka,o,i.length,r,Yb(t));Ve._free(o);let a=5,s=Ve.HEAPU32.subarray(n>>2,(n>>2)+a),l=s.subarray(2,2+3),c=0,u=Ve.HEAPU32[s[c]>>2],d=Ve.HEAPF32.subarray(u>>2,(u>>2)+l[c]);c++;let p=Ve.HEAPU32[s[c]>>2],f=Ve.HEAPF32.subarray(p>>2,(p>>2)+l[c]);c++;let h=l[c];e.setAttribute("position",new $b(d,3)),e.setAttribute("normal",new $b(f,3));let m=Ve.HEAPF32.subarray((n>>2)+5,(n>>2)+5+6);return e.boundingSphere===null&&(e.boundingSphere=new EE),e.boundingSphere.center.set(m[0],m[1],m[2]),e.boundingSphere.radius=(m[3]**2+m[4]**2+m[5]**2)**.5,e.userData.parameters={width:m[3]*2,height:m[4]*2,depth:m[5]*2},Ve.free_mesh_data(n),h}function RE(i,t,e){if(Ve===void 0)return-1;let r,o,n;if(t&&i.userData.positions!==void 0){let g=i.userData;n=g.verticesPerFace.length,r=g.positions,o=Array(g.verticesPerFace.reduce((b,w)=>b+w,0)+n);for(let b=0,w=0,P=0;b<g.verticesPerFace.length;b++){o[P++]=g.verticesPerFace[b];for(let S=0;S<g.verticesPerFace[b];S++)o[P++]=g.indices[w++]}}else({positions:r,faceIndices:o,nFaces:n}=NE(i,t,e));let a=r.length,s=o.length,l=r.length,c=o.length,u=l*Float32Array.BYTES_PER_ELEMENT+c*Uint32Array.BYTES_PER_ELEMENT,d=l*Float32Array.BYTES_PER_ELEMENT,p=c*Uint32Array.BYTES_PER_ELEMENT,f=Ve._malloc(u),h=new Float32Array(Ve.HEAPF32.buffer,f,l),m=new Uint32Array(Ve.HEAPU32.buffer,f+d,c);h.set(r,0),m.set(o,0);let y=Ve.get_csg_mesh(f,a,f+d,s,n);return Ve._free(f),y}function LE(i){return Ve.has_open_edges(i)}function BE(i,t){Ve.transform_csg_mesh(i,t.elements)}function VE(i){Ve.free_csg_mesh(i)}var zE={ConeGeometry:Ex,CubeGeometry:Nx,CylinderGeometry:Ix,DodecahedronGeometry:Dx,EllipseGeometry:Ba,HelixGeometry:lb,IcosahedronGeometry:cb,LatheGeometry:ub,NonParametricGeometry:vb,PolygonGeometry:zu,PyramidGeometry:Sb,RectangleGeometry:Fa,SphereGeometry:Pb,PlaneGeometry:Ob,BackdropGeometry:Tb,StarGeometry:Gu,TextFrameGeometry:Cb,TorusGeometry:Ab,TorusKnotGeometry:Mb,TriangleGeometry:Ib,PathGeometry:Lb,VectorGeometry:rr},Hf=i=>zE[i.type].create(i);function Ha(i){return i!==null&&"booleanOp"in i}var Wa=class extends Ma(FE){constructor(){super(...arguments);this.booleanMeshSetAddress=-1;this.booleanWasTransformed=!1;this.booleanMatrixInvOld=new GE}updateVisible(e){super.updateVisible(e),this.visible=!Ha(this.parent)&&this.visible,Ha(this.parent)&&this.parent.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(Or.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(e=!1){return e?this.booleanWasTransformed=!0:this.freeBooleanPointer(),Ha(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)e instanceof Wa&&(e.freeBooleanPointer(),Ha(e)&&e.invalidateUpstreamBooleanData())}updateTransformState(e,r){let o=super.updateTransformState(e,r);return o&&Ha(this.parent)&&this.invalidateDownstreamBooleanData(!0),o}onVariableUpdate(e=!1){super.onVariableUpdate(e),Ha(this.parent)&&this.invalidateDownstreamBooleanData(!0)}};var qu=new jE;function xl(i,t=0,e=i.count,r,o){let n=1/0,a=1/0,s=1/0,l=-1/0,c=-1/0,u=-1/0;for(let d=t;d<e;d++){let p=i.getX(d),f=i.getY(d),h=i.getZ(d);p<n&&(n=p),f<a&&(a=f),h<s&&(s=h),p>l&&(l=p),f>c&&(c=f),h>u&&(u=h)}qu.min.set(n,a,s),qu.max.set(l,c,u),qu.getCenter(r),qu.getSize(o).multiplyScalar(.5)}var HE=new UE,WE=new kE,It=class extends Wa{constructor(t,e){super(HE,WE),this.super_Entity(t,e)}updateState(t,e){this.updateState_Entity(t,e)}updateEntityBoxSize(t,e){let r=this.geometry.getAttribute("position");r!==void 0?xl(r,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:r.count,t,e):super.updateEntityBoxSize(t,e)}};import{Box3 as mD,Matrix4 as yD,Sphere as Uv,Vector3 as gD}from"three";import{BufferAttribute as pD,Float32BufferAttribute as jv,MathUtils as Ah,Vector3 as Mh}from"three";import{ShaderMaterial as kN,Texture as HN}from"three";var Wo=class{constructor(t){this.hashProperties=void 0;this.isNode=!0;this.shortcuts={};if(Wo.uuidContext===null)throw new Error("plz startContext");Wo.uuidContext===Wo.globalContext?this.uuid="_gid"+Wo.uuidContext.nodeContextUuid++:this.uuid="_uid"+Wo.uuidContext.nodeContextUuid++,this.type=t,this.name=""}static startContext(t){this.uuidContext===null||this.uuidContext===Wo.globalContext?this.uuidContext=t:console.error("Can't start context twice")}static endContext(t){this.uuidContext!==t&&console.error("Can't end context twice"),this.uuidContext=null}analyze(t,e){e=e??{},t.analyzing=!0,this.build(t.addFlow(e.slot,e.cache,e.context),"v4"),t.clearVertexNodeCode(),t.clearFragmentNodeCode(),t.removeFlow(),t.analyzing=!1}analyzeAndFlow(t,e,r){return r=r??{},this.analyze(t,r),this.flow(t,e,r)}flow(t,e,r){r=r??{},t.addFlow(r.slot,r.cache,r.context);let o={result:this.build(t,e),code:t.clearNodeCode(),extra:t.context.extra};return t.removeFlow(),o}build(t,e,r){e=e??this.getType(t,e);let o=t.getNodeData(r??this);return t.analyzing&&this.appendDepsNode(t,o,e),t.nodes.indexOf(this)===-1&&t.nodes.push(this),this.updateFrame!==void 0&&t.updaters.indexOf(this)===-1&&t.updaters.push(this),this.generate(t,e,r)}updateFrame(t){}generateReadonly(t,e,r,o,n,a){return""}generate(t,e,r,o,n){return""}parse(t,e,r,o){}appendDepsNode(t,e,r){e.deps=(e.deps||0)+1;let o=t.getTypeLength(r);(o>(e.outputMax||0)||this.getType(t,r))&&(e.outputMax=o,e.output=r)}setName(t){this.name=t}getName(){return this.name}getType(t,e){return e==="sampler2D"||e==="samplerCube"?e:this.type}},Xe=Wo;Xe.globalContext={nodeContextUuid:0},Xe.uuidContext=Wo.globalContext;import{CubeReflectionMapping as rN,CubeRefractionMapping as oN,CubeUVReflectionMapping as iN,LinearEncoding as nv,sRGBEncoding as nN}from"three";var bl=class{constructor(t){t=t??{},this.name=t.name,this.type=t.type,this.node=t.node,this.size=t.size,this.needsUpdate=t.needsUpdate}get value(){return this.node.value}set value(t){this.node.value=t}};var Jf=class{constructor(){this.nodes={};this.keywords={}}add(t){this.nodes[t.name]=t}addKeyword(t,e,r){r=r!==void 0?r:!0,this.keywords[t]={callback:e,cache:r}}remove(t){delete this.nodes[t.name]}removeKeyword(t){delete this.keywords[t]}get(t){return this.nodes[t]}getKeyword(t,e){return this.keywords[t].callback(e)}getKeywordData(t){return this.keywords[t]}contains(t){return this.nodes[t]!==void 0}containsKeyword(t){return this.keywords[t]!==void 0}},Et=new Jf;import{Vector2 as Kb}from"three";import{MathUtils as qE}from"three";var ge=class extends Xe{constructor(e,r){super(e);this.scope="";r=r??{},this.shared=r.shared!==void 0?r.shared:!0,this.unique=r.unique!==void 0?r.unique:!1}build(e,r,o,n){if(r=r??this.getType(e),this.getShared(e,r)){let a=this.getUnique(e,r);a&&this.uuid===void 0&&(this.uuid=qE.generateUUID()),o=e.getUUID(o??this.getUUID(),!a);let s=e.getNodeData(o),l=s.output||this.getType(e);if(e.analyzing)return(s.deps||0)>0||this.getLabel()?(this.appendDepsNode(e,s,r),this.generate(e,r,o)):super.build(e,r,o);if(a)return s.name=s.name||super.build(e,r,o),s.name;if(!this.getLabel()&&(!this.getShared(e,l)||e.context.ignoreCache||s.deps===1))return super.build(e,r,o);o=this.getUUID(!1);let c=this.getTemp(e,o);if(c)return e.format(c,l,r);{c=super.generate(e,r,o,s.output,n);let u=this.generate(e,l,o);return e.addNodeCode(c+" = "+u+";"),e.format(c,l,r)}}return super.build(e,r,o)}getShared(e,r){return r!=="sampler2D"&&r!=="samplerCube"&&this.shared}getUnique(e,r){return this.unique}setLabel(e){return this.label=e,this}getLabel(){return this.label}getUUID(e){let r=this.uuid;return typeof this.scope=="string"&&(r=this.scope+"-"+r),r}getTemp(e,r){r=r||this.uuid;let o=e.getVars()[r];return o?o.name:void 0}generate(e,r,o,n,a){return this.getShared(e,r)||console.error("TempNode is not shared"),o=o??this.uuid,e.getTempVar(o,n??this.getType(e),a,this.getLabel()).name}};var Ye=class extends ge{constructor(e,r){r=r??{},r.shared=r.shared!==void 0?r.shared:!1;super(e,r);this.readonly=!1}setReadonly(e){return this.readonly=e,this.hashProperties=this.readonly?["value"]:void 0,this}getReadonly(){return this.readonly}generate(e,r,o,n,a,s){o=e.getUUID(o??this.getUUID()),n=n??this.getType(e);let l=e.getNodeData(o);return this.getReadonly()&&this.generateReadonly!==void 0?this.generateReadonly(e,r,o,n,a,s):e.isShader("vertex")?(l.vertex||(l.vertex=e.createVertexUniform(n,this,a,s,this.getLabel())),e.format(l.vertex.name,n,r)):(l.fragment||(l.fragment=e.createFragmentUniform(n,this,a,s,this.getLabel())),e.format(l.fragment.name,n,r))}};var ut=class extends Ye{constructor(e=0,r){super("v2");this.nodeType="Vector2";this.value=e instanceof Kb?e:new Kb(e,r)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}generateReadonly(e,r,o,n,a,s){return e.format("vec2("+this.value.x+", "+this.value.y+")",n,r)}};import{Vector3 as Qb}from"three";var jt=class extends Ye{constructor(e=0,r,o){super("v3");this.nodeType="Vector3";this.value=e instanceof Qb?e:new Qb(e,r,o)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}get z(){return this.value.z}set z(e){this.value.z=e}generateReadonly(e,r,o,n,a,s){return e.format("vec3("+this.value.x+", "+this.value.y+", "+this.value.z+")",n,r)}};import{Color as $E}from"three";var Nt=class extends $E{constructor(e,r,o,n){super(e,r,o);this.isColorA=!0;this.a=n}setRGBA(e,r,o,n){super.setRGB(e,r,o),this.a=n}copy(e){return super.copy(e),this.a="a"in e?e.a:1,this}clone(){return new this.constructor(this.r,this.g,this.b,this.a)}equals(e){return super.equals(e)&&this.a===e.a}setStyle(e,r="srgb"){let o;if(e==="transparent")return this.setRGBA(0,0,0,0),this;if(o=/^((?:rgb|hsl)a?)\(([^)]*)\)/.exec(e)){let n,a=o[1],s=o[2];switch(a){case"rgb":case"rgba":if(n=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return this.a=a==="rgba"?parseFloat(n[4]):1,super.setStyle(e,r);break;case"hsl":case"hsla":if(n=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)%\s*,\s*(\d*\.?\d+)%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return this.a=a==="hsla"?parseFloat(n[4]):1,super.setStyle(e,r);break}}return super.setStyle(e,r)}get x(){return this.r}get y(){return this.g}get z(){return this.b}get w(){return this.a}set x(e){this.r=e}set y(e){this.g=e}set z(e){this.b=e}set w(e){this.a=e}};var or=class extends Ye{constructor(e){super("v4");this.nodeType="Vector4";this.value=e instanceof Nt?e:new Nt(e.r,e.g,e.b,e.a)}generateReadonly(e,r,o,n,a,s){return e.format("vec4("+this.value.r+", "+this.value.g+", "+this.value.b+", "+this.value.a+")",n,r)}};var XE=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,Zb=/[a-z_0-9]+/gi,Z=class extends ge{constructor(e,r,o,n,a){super(a);this.src="";this.nodeType="Function";this.useKeywords=!0;this.includes=[];this.extensions={};this.keywords={};this.isMethod=a===void 0,this.isInterface=!1,this.parse(e,r,o,n)}getShared(e,r){return!this.isMethod}getType(e){return e.getTypeByFormat(this.type)}getInputByName(e){if(this.inputs){let r=this.inputs.length;for(;r--;)if(this.inputs[r].name===e)return this.inputs[r]}}getIncludeByName(e){if(this.includes){let r=this.includes.length;for(;r--;)if(this.includes[r].name===e)return this.includes[r]}}generate(e,r,o,n,a){let s,l=0,c=this.src;if(this.includes)for(let d=0;d<this.includes.length;d++)e.include(this.includes[d],this);for(let d in this.extensions)e.extensions[d]=!0;let u=[];for(;s=Zb.exec(this.src);)u.push(s);for(let d=0;d<u.length;d++){let p=u[d],f=p[0],h=this.isMethod?!this.getInputByName(f):!0,m=f;if(this.keywords[f]||this.useKeywords&&h&&Et.containsKeyword(f)){let y=this.keywords[f];if(!y){let g=Et.getKeywordData(f);g.cache&&(y=e.keywords[f]),y=y||Et.getKeyword(f,e),g.cache&&(e.keywords[f]=y)}m=y.build(e)}f!==m&&c[p.index+l-1]!=="."&&(c=c.substring(0,p.index+l)+m+c.substring(p.index+f.length+l),l+=m.length-f.length),this.getIncludeByName(m)===void 0&&Et.contains(m)&&e.include(Et.get(m))}return r==="source"?c:this.isMethod?(this.isInterface||e.include(this,void 0,c),this.name):e.format("( "+c+" )",this.getType(e),r)}parse(e,r,o,n){if(this.src=e||"",this.includes=r??[],this.extensions=o??{},this.keywords=n??{},this.isMethod){let a=XE.exec(this.src);if(this.inputs=[],a&&a.length==4){this.type=a[1],this.name=a[2];let s=a[3].match(Zb);if(s){let l=0;for(;l<s.length;){let c=s[l++],u;c==="in"||c==="out"||c==="inout"?u=s[l++]:(u=c,c="");let d=s[l++];this.inputs.push({name:d,type:u,qualifier:c})}}this.isInterface=this.src.indexOf("{")===-1}else this.type="",this.name=""}}};var YE=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,eh=class extends ge{constructor(e="",r){super();this.src="";this.useDefine=!1;this.nodeType="Const";this.parse(e||eh.PI,void 0,void 0,void 0,r)}getType(e){return e.getTypeByFormat(this.type)}parse(e,r,o,n,a){this.src=e||"";let s,l,c="",u=YE.exec(e);this.useDefine=a??this.src.charAt(0)==="#",u&&u.length>1?(l=u[1],s=u[2],c=u[3]):(s=this.src,l="f"),this.name=s,this.type=l,this.value=c}build(e,r){if(r==="source"){if(this.value)return this.useDefine?"#define "+this.name+" "+this.value:"const "+this.type+" "+this.name+" = "+this.value+";";if(this.useDefine)return this.src}return e.include(this),e.format(this.name,this.getType(e),r)}generate(e,r,o,n,a){return e.format(this.name,this.getType(e),r)}},Fe=eh;Fe.PI="PI",Fe.PI2="PI2",Fe.RECIPROCAL_PI="RECIPROCAL_PI",Fe.RECIPROCAL_PI2="RECIPROCAL_PI2",Fe.LOG2="LOG2",Fe.EPSILON="EPSILON";var KE=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
19
19
  )*?)}`,"gim"),QE=new RegExp("s*(w*?)s*(w*?)(=|;)","gim"),qa=class extends ge{constructor(e=""){super();this.inputs=[];this.src="";this.nodeType="Struct";this.parse(e)}getType(e){return e.getTypeByFormat(this.name)}getInputByName(e){let r=this.inputs.length;for(;r--;)if(this.inputs[r].name===e)return this.inputs[r]}generate(e,r,o,n,a){return r==="source"?this.src+";":e.format("( "+this.src+" )",this.getType(e),r)}parse(e=""){this.src=e,this.inputs=[];let r=KE.exec(e);if(r){let o=r[2],n;for(;n=QE.exec(o);)this.inputs.push({type:n[1],name:n[2]});this.name=r[1]}else this.name="";this.type=this.name}};var $a=class extends ge{constructor(e){super("v2",{shared:!1});this.nodeType="UV";this.index=e??0}generate(e,r){e.requires.uv[this.index]=!0;let o=this.index>0?this.index+1:"",n=e.isShader("vertex")?"uv"+o:"vUv"+o;return e.format(n,this.getType(e),r)}};Et.addKeyword("uv",function(){return new $a});Et.addKeyword("uv2",function(){return new $a(1)});import{LinearEncoding as ZE,sRGBEncoding as JE}from"three";var hn=class extends ge{constructor(e,r){super("v4");this.nodeType="ColorSpace";this.input=e,this.method=r??hn.LINEAR_TO_LINEAR,this.hashProperties=["method"]}static getEncodingComponents(e){switch(e){case ZE:return["Linear"];case JE:return["sRGB"];default:return[]}}generate(e,r){let o=this.input.build(e,"v4"),n=this.getType(e),a=hn.Nodes[this.method],s=e.include(a);if(s===hn.LINEAR_TO_LINEAR)return e.format(o,n,r);if(a.inputs?.length===2){let l=this.factor.build(e,"f");return e.format(s+"( "+o+", "+l+" )",n,r)}else return e.format(s+"( "+o+" )",n,r)}fromEncoding(e){let r=hn.getEncodingComponents(e);this.method="LinearTo"+r[0],this.factor=r[1]}fromDecoding(e){let r=hn.getEncodingComponents(e);this.method=r[0]+"ToLinear",this.factor=r[1]}},Kt=hn;Kt.Nodes={LinearToLinear:new Z(["vec4 LinearToLinear( in vec4 value ) {"," return value;","}"].join(`
20
20
  `)),sRGBToLinear:new Z(["vec4 sRGBToLinear( in vec4 value ) {"," return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.w );","}"].join(`
21
21
  `)),LinearTosRGB:new Z(["vec4 LinearTosRGB( in vec4 value ) {"," return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.w );","}"].join(`
@@ -1873,7 +1873,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
1873
1873
  vec3 distorted2 = nearby2 + normal * displacementMapTexture(tex, crop, uv, mat, vec2(neighbor_offset)) * intensity;
1874
1874
  displaced_normal = normalize(cross(distorted1 - displaced_position, distorted2 - displaced_position));
1875
1875
  return displaced_position;
1876
- }`,[e,r])}}();var Me={normalRenderTarget:new Qt,normalRenderTargetDepth:new Qt,transmissionRenderTarget:new Qt,aspectRatio:new ut,transmissionSize:new ut(2048,2048),transmissionRenderTargetDepth:new Qt,aoRenderTarget:new Qt,aoEnabled:new dt,pixelRatioNode:new se(1),resolution:new ut,penumbraSize:new Wr(5,.5),frameIndex:new Le(0),transmissionLod:new Le(2),taaEnabled:new dt(!0)};for(let i of Object.values(Me))i.isRenderGlobal=!0;var fv={skiaWasmUrl:"https://unpkg.com/@splinetool/ui-wasm@1.12.87/build/ui.wasm"};var qo=class extends Xe{constructor(){super("basic");this.nodeType="Basic";this.color=new qe(bt),this.shadingAlpha=new se(1),this.shadingBlend=new Le(0),this.previousModelViewMatrix=new Ut,this.previouseProjectionMatrix=new Ut}get category(){return"phong"}generate(e){let r;if(e.isShader("vertex")){let o=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform({frameIndex:Me.frameIndex}),e.mergeUniform({resolution:Me.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(mN.merge([hN.fog])),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","#include <fog_pars_vertex>","#include <skinning_pars_vertex>","#include <normal_pars_vertex>","#include <morphtarget_pars_vertex>"].join(`
1876
+ }`,[e,r])}}();var Me={normalRenderTarget:new Qt,normalRenderTargetDepth:new Qt,transmissionRenderTarget:new Qt,aspectRatio:new ut,transmissionSize:new ut(2048,2048),transmissionRenderTargetDepth:new Qt,aoRenderTarget:new Qt,aoEnabled:new dt,pixelRatioNode:new se(1),resolution:new ut,penumbraSize:new Wr(5,.5),frameIndex:new Le(0),transmissionLod:new Le(2),taaEnabled:new dt(!0)};for(let i of Object.values(Me))i.isRenderGlobal=!0;var fv={skiaWasmUrl:"https://unpkg.com/@splinetool/ui-wasm@1.12.88/build/ui.wasm"};var qo=class extends Xe{constructor(){super("basic");this.nodeType="Basic";this.color=new qe(bt),this.shadingAlpha=new se(1),this.shadingBlend=new Le(0),this.previousModelViewMatrix=new Ut,this.previouseProjectionMatrix=new Ut}get category(){return"phong"}generate(e){let r;if(e.isShader("vertex")){let o=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform({frameIndex:Me.frameIndex}),e.mergeUniform({resolution:Me.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(mN.merge([hN.fog])),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","#include <fog_pars_vertex>","#include <skinning_pars_vertex>","#include <normal_pars_vertex>","#include <morphtarget_pars_vertex>"].join(`
1877
1877
  `));let n=["#include <beginnormal_vertex>","#include <morphnormal_vertex>",`
1878
1878
  #include <skinbase_vertex>
1879
1879
  #include <skinnormal_vertex>
@@ -4376,4 +4376,4 @@ void main() {
4376
4376
  A = exp(A) * vColor.a;
4377
4377
  gl_FragColor = vec4(color.rgb, A);
4378
4378
  gVelocity = vec4(0.0); // so it is ignored by TAA
4379
- }`,n={covariancesTexture:{type:"t",value:null},centersColorsTexture:{type:"t",value:null},meshIndexIntervals:{value:e},meshMatrixWorldsTexture:{type:"t",value:null},focal:{type:"v2",value:new Hi},viewport:{type:"v2",value:new Hi},basisViewport:{type:"v2",value:new Hi},debugColor:{type:"v3",value:new JR},covariancesTextureSize:{type:"v2",value:new Hi(1024,1024)},centersColorsTextureSize:{type:"v2",value:new Hi(1024,1024)},orthoZoom:{type:"f",value:-1}};return new uL({uniforms:n,vertexShader:r,fragmentShader:o,transparent:!0,alphaTest:1,blending:sL,depthTest:!0,depthWrite:!1,side:tL})}static buildGeomtery(e){let r=new ZR;r.setIndex([0,1,2,0,2,3]);let o=new Float32Array(4*3),n=new QR(o,3);r.setAttribute("position",n),n.setXYZ(0,-1,-1,0),n.setXYZ(1,-1,1,0),n.setXYZ(2,1,1,0),n.setXYZ(3,1,-1,0),n.needsUpdate=!0;let a=new nL().copy(r),s=new Uint32Array(e),l=new iL(s,1,!1);return l.setUsage(rL),a.setAttribute("splatIndex",l),a.instanceCount=e,a}resetLocalSplatDataAndTexturesFromSplatBuffer(){this.updateLocalSplatDataFromSplatBuffer(),this.allocateAndStoreLocalSplatDataInTextures()}updateLocalSplatDataFromSplatBuffer(){this.splatBuffers.forEach(n=>n.buildPreComputedBuffers()),this.covariances=new Float32Array(this.splatCount*6),this.colors=new Uint8Array(this.splatCount*4),this.centers=new Float32Array(this.splatCount*3);let e=0,r=0,o=0;for(let n of this.splatBuffers){let a=n.nsplats;this.colors.subarray(e,e+a*4).set(n.colorsA),e+=a*4,this.centers.subarray(r,r+a*3).set(n.decoded.xyz.denormDequant().data),r+=a*3,this.covariances.subarray(o,o+a*6).set(new Float32Array(n.precomputedCovarianceBufferData)),o+=a*6}}allocateAndStoreLocalSplatDataInTextures(){let o=this.splatCount,n=new Hi(4096,1024);for(;n.x*n.y*2<o*6;)n.y*=2;let a=new Hi(4096,1024);for(;a.x*a.y*4<o*4;)a.y*=2;let s,l;if(this.halfPrecisionCovariancesOnGPU){l=new Uint16Array(n.x*n.y*2);for(let h=0;h<this.covariances.length;h++)l[h]=eL.toHalfFloat(this.covariances[h]);s=new Wd(l,n.x,n.y,LS,oL)}else l=new Float32Array(n.x*n.y*2),l.set(this.covariances),s=new Wd(l,n.x,n.y,LS,RS);s.needsUpdate=!0,this.material.uniforms.covariancesTexture.value=s,this.material.uniforms.covariancesTextureSize.value.copy(n);let c=new Uint32Array(a.x*a.y*4);for(let h=0;h<o;h++){let m=h*4,y=h*3,g=h*4;c[g]=_S(this.colors[m],this.colors[m+1],this.colors[m+2],this.colors[m+3]),c[g+1]=Hd(this.centers[y]),c[g+2]=Hd(this.centers[y+1]),c[g+3]=Hd(this.centers[y+2])}let u=new Wd(c,a.x,a.y,cL,dL);u.internalFormat="RGBA32UI",u.needsUpdate=!0,this.material.uniforms.centersColorsTexture.value=u,this.material.uniforms.centersColorsTextureSize.value.copy(a);let d=256*4,p=new Float32Array(256*16);for(let h=0;h<this.meshMatrixWorlds.length;h++)p.set(this.meshMatrixWorlds[h].elements,h*16);let f=new Wd(p,d,1,lL,RS);f.needsUpdate=!0,this.material.uniforms.meshMatrixWorldsTexture.value=f,this.material.uniformsNeedUpdate=!0,this.splatDataTextures={covariances:{data:l,texture:s,size:n},centerColors:{data:c,texture:u,size:a},meshMatrixWorlds:{data:p,texture:f}}}updateIndexes(e){let r=this.geometry;r.attributes.splatIndex.set(e),r.attributes.splatIndex.needsUpdate=!0,r.instanceCount=e.length}updateUniforms(e,r,o,n){this.splatCount>0&&(qd.set(e.x*this.devicePixelRatio,e.y*this.devicePixelRatio),this.material.uniforms.viewport.value.copy(qd),this.material.uniforms.basisViewport.value.set(2/qd.x,2/qd.y),this.material.uniforms.focal.value.set(r,o),this.material.uniforms.orthoZoom.value=n,this.material.uniformsNeedUpdate=!0)}getSplatDataTextures(){return this.splatDataTextures}getSplatCount(){return this.splatCount}getCenters(){return this.centers}getColors(){return this.colors}getCovariances(){return this.covariances}dispose(){this.geometry.dispose(),this.material.dispose(),this.splatDataTextures&&(this.splatDataTextures.covariances.texture.dispose(),this.splatDataTextures.centerColors.texture.dispose(),this.splatDataTextures.meshMatrixWorlds.texture.dispose()),this.removeFromParent()}};var VS,mm=new Promise(i=>{VS=i}),BS=!1;var Xd;function ym(){if(BS)return;if(Xd)return Xd;async function i(){let e=await import("./gaussian-splat-compression.js");VS(e),BS=!0}return Xd=i(),Xd}var FS;mm.then(i=>FS=i);var ql=class{constructor(t={}){Qi(this,"updateView",function(){let t=new zS,e=[],r=new _s(0,0,-1),o=new _s(0,0,-1),n=new _s,a=new _s;return function(s=!1,l){let c=this.updateMatrixWorldsInWorkerIfNeeded(),u=this.cropsChanged();if(!s){o.set(0,0,-1).applyQuaternion(l.quaternion);let p=!1,f=!1;if(o.dot(r)<=.95&&(p=!0),a.copy(l.position).sub(n).length()>=1&&(f=!0),!p&&!f&&!c&&!u&&!this.needsInitialRender)return}this.needsInitialRender=!1,n.copy(l.position),r.copy(o),t.copy(l.matrixWorld).invert(),t.premultiply(this.dummyPerspectiveMatrix),e[0]=l.position.x,e[1]=l.position.y,e[2]=l.position.z;let d={sort:{view:t.elements,cameraPosition:e,splatRenderCount:this.splatRenderCount,splatSortCount:this.splatRenderCount},...c?{newMatrixWorlds:this.meshMatrixWorlds}:{},...u?{newCropsArray:this.cropsArray}:{}};this.sortRunning?this.queuedMessage=d:(this.queuedMessage=null,this.sortRunning=!0,this.sortWorker.postMessage(d))}}());this.scene=t.scene,this.currentPage=null,this.devicePixelRatio=window.devicePixelRatio,this.sortWorker=null,this.splatRenderCount=0,this.splatSortCount=0,this.splatMesh=null,this.sortRunning=!1,this.meshMatrixWorlds=null,this.meshMatrixWorldsOld=null,this.cropsArray=null,this.splatEntries=null,this.queuedMessage=null,this.needsInitialRender=!0,this.dummyPerspectiveMatrix=new zS().makePerspective(-1,1,-1,1,.1,1e3)}updateSplatMeshUniforms(t,e){let r=new pL;if(this.splatMesh===null)return;this.splatMesh.getSplatCount()>0&&(t.getSize(r),this.cameraFocalLengthX=e.projectionMatrix.elements[0]*this.devicePixelRatio*r.x*.45,this.cameraFocalLengthY=e.projectionMatrix.elements[5]*this.devicePixelRatio*r.y*.45,this.splatMesh.updateUniforms(r,this.cameraFocalLengthX,this.cameraFocalLengthY,e.isPerspectiveCamera?-1:e.zoom*this.devicePixelRatio))}loadSplat(t={}){this.activePage=this.scene.activePage,t.position&&(t.position=new _s().fromArray(t.position)),t.orientation&&(t.orientation=new GS().fromArray(t.orientation)),t.halfPrecisionCovariances=!!t.halfPrecisionCovariances;let e=[];if(this.splatEntries=e,this.activePage.traverseVisibleEntity(a=>{a.data.type==="Splat"&&e.push(a)}),this.splatMesh&&this.splatMesh.dispose(),e.length===0)return this.splatMesh=null,!1;this.meshMatrixWorlds=e.map(a=>a.matrixWorld),this.meshMatrixWorldsOld=e.map(a=>a.matrixWorld.clone()),this.cropsArray=e.map(a=>a.data.crops.map(s=>s.data));let r=e.map(a=>new FS.GSplineBuffer(new Uint8Array(a.data.buffer).buffer)),o=0,n=[0];for(let a of r)o+=a.getSplatCount(),n.push(o);return this.setupSplatMesh(r,o,t.position,t.orientation,t.halfPrecisionCovariances,this.devicePixelRatio,n,this.meshMatrixWorlds),this.setupSortWorker(o),!0}updateMatrixWorldsInWorkerIfNeeded(){let t=this.splatDataTextures.meshMatrixWorlds.data;for(let e=0;e<this.meshMatrixWorlds.length;e++)t.set(this.meshMatrixWorlds[e].elements,e*16);return this.splatDataTextures.meshMatrixWorlds.texture.needsUpdate=!0,this.meshMatrixWorlds.every((e,r)=>e.equals(this.meshMatrixWorldsOld[r]))?!1:(this.meshMatrixWorldsOld=this.meshMatrixWorlds.map(e=>e.clone()),!0)}cropsChanged(){let t=!1;return this.splatEntries.forEach((e,r)=>{e.data.crops.forEach((o,n)=>{this.cropsArray[r][n]===void 0?(t=!0,this.cropsArray[r][n]=o.data):Object.entries(o.data).forEach(([a,s])=>{Array.isArray(s)&&s.some((l,c)=>l!==this.cropsArray[r][n][a][c])?(t=!0,this.cropsArray[r][n][a]=s):s!==this.cropsArray[r][n]?.[a]&&(t=!0,this.cropsArray[r][n][a]=s)})}),e.data.crops.length!==this.cropsArray[r]?.length&&(this.cropsArray[r].length=e.data.crops.length,t=!0)}),t}setupSplatMesh(t,e,r=new _s,o=new GS,n=!1,a=1,s,l){this.splatMesh=Wi.buildMesh(t,e,n,a,s,l),this.splatMesh.position.copy(r),this.splatMesh.quaternion.copy(o),this.splatMesh.frustumCulled=!1,this.splatMesh.renderOrder=99999,this.splatRenderCount=e,this.splatMesh.onBeforeRender=(c,u,d)=>this.update(c,d)}setupSortWorker(t){this.sortWorker=DS(t),this.sortWorker.onmessage=e=>{e.data.sortDone?(this.sortRunning=!1,this.splatMesh?.updateIndexes(new Uint32Array(e.data.indexesBuffer)),this.lastSortTime=e.data.sortTime,this.queuedMessage&&(this.sortWorker.postMessage(this.queuedMessage),this.queuedMessage=null)):e.data.sortCanceled?this.sortRunning=!1:e.data.sortSetupPhase1Complete?this.sortWorker.postMessage({positions:this.splatMesh.getCenters().buffer,meshMatrixWorlds:this.splatMesh.meshMatrixWorlds,meshIndexIntervals:this.splatMesh.meshIndexIntervals,cropsArray:this.cropsArray}):e.data.sortSetupComplete&&(this.splatDataTextures=this.splatMesh.getSplatDataTextures(),this.scene.activePage.add(this.splatMesh),this.needsInitialRender=!0)}}update(t,e){this.splatMesh!==null&&(this.updateSplatMeshUniforms(t,e),this.updateView(!1,e))}getSplatMesh(){return this.splatMesh}};var bL=new gL;bL.wireframe=!0;var jS=new hL,Yd=class extends fL{constructor(e,r){super();this.data=e;this.sharedAssets=r;this.enableHelpers=!1;this.wireframeState=!1;this.needsTransmissionDirty=!0;this.needsNormalDirty=!0;this._needsTransmission=!1;this._needsNormal=!1;this.geometryCacheChanged=!1;this.splatViewer=null;this.shapeBlendIntances=[];this.entityByUuid={};this.entityIdentityToEntity={};this.toExpandCloner=new Set;this.toUpdateCloner=new Set;this.pendingCommands=[];this.pathConstraints=new kd;this.invisibleObjects=new Bi("jflkdsafjasdifjaslk",{...ou.defaultData,visible:!1,name:"buildin invisible"});this.needsRecomputeInstances=!1;this.init(e,r),this.matrixAutoUpdate=!1,this.errorPage=new Er("fdasfa",{...Lo.defaultData,name:""},{shared:r,scene:this})}markGeometryCacheDirty(){this.geometryCacheChanged=!0}markNeedsUpdateRendererDirty(){this.needsTransmissionDirty=!0,this.needsNormalDirty=!0}needsTransmission(){return this.needsTransmissionDirty&&(this._needsTransmission=ES(this),this.needsTransmissionDirty=!1),this._needsTransmission}needsNormal(){return this.needsNormalDirty&&(this._needsNormal=IS(this),this.needsNormalDirty=!1),this._needsNormal}registerInstanceAndSetUuid(e){let r=e.identity.join("-"),o=this.entityIdentityToEntity[r];o&&(e.uuid=o.uuid),this.entityIdentityToEntity[r]=e,this.entityByUuid[e.uuid]=e}markPenumbraSizeDirty(){for(let e of this.children)e instanceof Er&&(e.penumbraSizeArrayCache=null)}findInstance(e){return this.entityIdentityToEntity[e.join("-")]}get bgColor(){return this.activePage.bgColor}get postprocessing(){return this.activePage.data.postprocessing}getWithSortKey(e){let r=this.find(e);if(r===void 0)return;let o=[],n=r;for(;n!==this;){let a=n;n=n.parent;let s=n.children.indexOf(a);o.splice(0,0,s)}return{entity:r,sortKey:o}}getAllSorted(e){let r=[];for(let o of e){let n=this.getWithSortKey(o.id);n!==void 0&&r.push(n)}return r.sort((o,n)=>Zc(o.sortKey,n.sortKey)),r.map(o=>o.entity)}nonExistOrDescendantOf(e,r){let o=this.find(e);if(o===void 0)return!0;for(;o;){if(o.uuid===r)return!0;o=o.parent}return!1}find(e){if(this.activePage&&this.activePage.personalCamera.parent){if(e==="f23858d0-4a3b-4bd8-8173-66ed0af7f6fb-personalCamera")return this.activePage.personalCamera;if(e===yi)return this.activePage.personalCamera}if(e===""||e===void 0)return;let r=this.entityByUuid[e];return r===void 0?this.getObjectByProperty("uuid",e):r}find2D(e){for(let r of this.children)if(r instanceof Er&&r.uiScene){let o=r.uiScene.find(e);if(o)return o}}findScene2DfromObject2D(e){for(let r of this.children)if(r instanceof Er&&r.uiScene&&r.uiScene.find(e))return r.uiScene}find2DInUIObjects(e){let r;return this.traverseEntity(o=>{r===void 0&&o instanceof Dn&&(r=o.uiCanvas.find(e))}),r}traverse2D(e){for(let r of this.children)r instanceof Er&&r.uiScene&&r.uiScene.traverse(e)}debugEnsureEntity(e){let r=this.find(e);if(r){if(Array.isArray(r.identity)&&this.findInstance(r.identity)===void 0){console.error("not found instance");debugger}}else{console.error("not found");debugger}}addPendingExpandCloner(e){this.toExpandCloner.add(e)}addPendingUpdateCloner(e){this.toUpdateCloner.add(e)}markToExpandCloner(e){this.toExpandCloner.add(e),e.traverseEntityAncestors(r=>{this.toExpandCloner.add(r)})}doPendingExpandCloner(e){this.toExpandCloner.forEach(r=>{r.expandCloner(e)}),this.toExpandCloner.clear()}doPendingUpdateCloner(e){this.toUpdateCloner.forEach(r=>{r.cloner?.update(e)}),this.toUpdateCloner.clear()}doPendingUpdates(e){this.doPendingExpandCloner(e),this.doPendingUpdateCloner(e),this.applyPendingCommands()}addPendingCommand(e){this.pendingCommands.push(e)}applyPendingCommands(){this.pendingCommands.forEach(e=>e()),this.pendingCommands.length=0}updateByLibOp(e,r){e.path.length===1&&e.path[0]==="components"&&e.type===1&&this.createChildrenObjects([{...e.data.asset,id:e.id}],this.invisibleObjects,r)}updateTreeByOp(e,r){if(e.path.length===0&&e.type===7){let o=e.parent===null?this:this.find(e.parent);if(o===void 0)throw new Error("unexpected");let n=this.createObject(e.id,e.data,e.children,o,e.localIndex,r);n.updateVisible(this),n.resetBBoxNeedsUpdate(),Li(n)&&Ll(n.parent)&&(n.invalidateUpstreamBooleanData(),n.parent.invalidateDownstreamBooleanData().recomputeBoolean()),this.markNeedsRecomputeInstancesForAncessors(o),this.markNeedsRecomputeInstancesForChildren(n),this.markToExpandCloner(n),this.markPenumbraSizeDirty(),n.updatePathSnapping()}else if(e.path.length===0&&e.type===8){let o=this.find(e.id);if(o===void 0)throw new Error("unexpected");o.traverseEntity(a=>{a instanceof ji&&(this.shapeBlendIntances=this.shapeBlendIntances.filter(s=>s!==a))}),this.markToExpandCloner(o),o.resetBBoxNeedsUpdate(),this.unregisterObject(o);let n=o.parent;this.markNeedsRecomputeInstancesForAncessors(n),this.markNeedsRecomputeInstancesForChildren(o),this.markPenumbraSizeDirty(),o.parent.remove(o),Ll(o.parent)&&(o.parent.invalidateUpstreamBooleanData(),o.parent.invalidateDownstreamBooleanData().recomputeBoolean()),Li(o)&&(o.freeBooleanPointer(),n instanceof lr&&n.invalidateDownstreamBooleanData().recomputeBoolean()),o instanceof As&&o.detachShape(),this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(o),this.pathConstraints.removeDependencies(o.uuid),o.updatePathSnapping()}else if(e.path.length===0&&e.type===9){let o=this.find(e.id);if(o===void 0)throw new Error("unexpected");this.markNeedsRecomputeInstancesForChildren(o);let n=o.parent;this.markNeedsRecomputeInstancesForAncessors(n),o.cloner?.resetOnMove(),this.markToExpandCloner(o);let a=e.parent===null?this:this.find(e.parent);if(a===void 0)throw new Error("unexpected");a.add(o),this.markNeedsRecomputeInstancesForAncessors(a),this.markToExpandCloner(o),o.invalidateClonerTransform(o),o.updateVisible(this),o.resetBBoxNeedsUpdate(),this.markPenumbraSizeDirty();let s=e.localIndex;a.children.splice(s,0,a.children.pop()),Li(o)&&(o.invalidateUpstreamBooleanData(),Ll(o.parent)?o.parent.invalidateDownstreamBooleanData().recomputeBoolean():n instanceof lr&&n.invalidateDownstreamBooleanData().recomputeBoolean()),o.updatePathSnapping()}this.markNeedsUpdateRendererDirty(),this.markGeometryCacheDirty()}get playPage(){return this.find(this.data.publish.playPage)??this.errorPage}updatePage(e){this.activePage&&this.activePage.onDeactive(),this.activePage=this.errorPage;for(let r of this.children)r instanceof Er&&(r.visible=r.uuid===e,r.visible&&(this.activePage=r,this.activePage.onActive(this)));this.activePage!==this.splatViewer?.activePage&&this.reloadSplats()}updateEntityByOp(e,r,o,n){if(r.type===0){if(("overrides"in r.props||"component"in r.props)&&this.markNeedsRecomputeInstances(),"visible"in r.props&&this.markPenumbraSizeDirty(),r.path.includes("overrides")&&"states"in r.props){let{rest:s}=r.props;r={...r,props:s},this.markNeedsRecomputeInstances()}r.path[0]==="pathSnapping"&&r.props.pathId!==void 0&&this.pathConstraints.setConstraint(e,r.props.pathId)}let a=this.find(e);if(a)try{xS(a,r,o,{scene:this,shared:n}),a instanceof tt&&a.updateGeometryGroupsIfNeeded()}catch(s){console.error(s)}}updateEntity2DByOp(e,r,o,n,a,s=[]){e.updateEntityByOp(r,o,n,a),this.traverseEntity(l=>{(l instanceof Dn||l instanceof Er)&&(s.includes(l.frameId??"")||l.frameId===r)&&l.updateEntity2DByOp(r,o,n,a)})}get activeCamera(){return this.activePage.activeCamera}switchActiveCamera(e){this.activePage.switchActiveCamera(e)}isInvisibleObjects(e){return e===this.invisibleObjects||e.hasAnccestor(this.invisibleObjects)}init(e,r){let o=Object.entries(r.data.lib.components).map((n,a)=>({data:n[1].asset.data,children:n[1].asset.children,id:n[0],fi:a}));this.invisibleObjects.updateState(this.invisibleObjects.data,{scene:this,shared:r}),this.add(this.invisibleObjects),this.createChildrenObjects(o,this.invisibleObjects,r),this.createChildrenObjects(e.objects,this,r),this.updatePage(e.publish.playPage),this.activePage.switchToPlayCamera(),this.expandInstances(r,!0),this.traverseEntity(n=>{n instanceof Zo&&n.updateUp()}),this.doPendingExpandCloner({scene:this,shared:r}),this.applyPendingCommands()}markNeedsRecomputeInstances(){this.needsRecomputeInstances=!0}markNeedsRecomputeInstancesForChildren(e){e.traverseEntity(r=>{(r.data.type==="Component"||r.data.type==="Instance")&&this.markNeedsRecomputeInstances()})}markNeedsRecomputeInstancesForAncessors(e){_e.is(e)&&(e.data.type==="Component"&&this.markNeedsRecomputeInstances(),e.traverseAncestors(r=>{_e.is(r)&&r.data.type==="Component"&&this.markNeedsRecomputeInstances()}))}relativeizeInner(e,r,o,n,a,s,l){if(e){let c=n.find(e);c&&c!==n&&a.forInstancesRec(u=>{u.data=ui(u.data,d=>{let p=d.events.data(l.id),f=u.goUp(s);if(f){let h=[...Qc(f.identity),e].join("-"),m=this.entityIdentityToEntity[h];if(m){let y=m.uuid,g=Je.zoom(p,r);g[o]=y}else{if(!1)debugger;console.warn("cannot find instance")}}}).data})}}rewriteActions(e,r,o,n,a,s){e.forEach(l=>{l.data.type==="Transition"?this.relativeizeInner(l.data.object,[...r,l.id],"object",o,n,a,s):l.data.type==="Animation"?this.relativeizeInner(l.data.object,[...r,l.id],"object",o,n,a,s):l.data.type==="Conditional"&&(this.rewriteActions(l.data.ifActions,[...r,l.id,"ifActions"],o,n,a,s),this.rewriteActions(l.data.elseActions,[...r,l.id,"elseActions"],o,n,a,s))})}rewriteEventsBeforeGoToPlayMode(){this.traverseEntity(e=>{if(e instanceof ti&&typeof e.identity=="string"&&e.data.type==="Component")return e.traverseEntity((r,o)=>{r.data.events.forEach(n=>{if(n.data.type==="GameControl"){let a=!1;if(r.forInstancesRec(s=>{s.data=ui(s.data,l=>{s.isInstanceRoot||(l.events.delete(n.id),a=!0)}).data}),a===!1)for(let s of su.list)this.rewriteActions(n.data.gameActions[s],["gameActions",s],e,r,o,n)}else n.data.type==="Conditional"?(n.data.condition.type==="Distance"?(this.relativeizeInner(n.data.condition.fromObject,["condition"],"fromObject",e,r,o,n),this.relativeizeInner(n.data.condition.toObject,["condition"],"toObject",e,r,o,n)):n.data.condition.type==="State"?this.relativeizeInner(n.data.condition.object,["condition"],"object",e,r,o,n):n.data.condition.type==="Comparison"&&(n.data.condition.lOperand.type==="Property"&&this.relativeizeInner(n.data.condition.lOperand.value[0],["condition","lOperand","value"],0,e,r,o,n),n.data.condition.rOperand.type==="Property"&&this.relativeizeInner(n.data.condition.rOperand.value[0],["condition","rOperand","value"],0,e,r,o,n)),this.rewriteActions(n.data.inActions,["inActions"],e,r,o,n),this.rewriteActions(n.data.outActions,["outActions"],e,r,o,n)):"actions"in n.data&&this.rewriteActions(n.data.actions,["actions"],e,r,o,n)})}),!0})}expandInstances(e,r,o){let n=new Set;this.traverseEntity(a=>{if(a instanceof ti&&a.isInstanceRoot)return a.expandInstanceChildren({scene:this,shared:e,pendingDeletes:n}),r||a.resetBBoxNeedsUpdate(),o&&a.traverseEntity(s=>{o.addClip(s)}),!0});for(let a of n)this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(a),Rd(a)}recomputeInstances(e,r){this.needsRecomputeInstances&&(this.needsRecomputeInstances=!1,this.traverseEntity(o=>{o instanceof ti&&o.isInstanceRoot&&(o.component=void 0)}),this.expandInstances(e,!1,r))}disposeAndUnregisterEntityRecursivelyIfNotReregistered(e){e.traverseEntity(r=>{let o=typeof r.identity=="string"?r.identity:r.identity.join("-");this.entityIdentityToEntity[o]===r&&(delete this.entityByUuid[r.uuid],delete this.entityIdentityToEntity[o]),r.dispose()})}clearScene(){for(let e of this.children)_e.is(e)&&e.disposeRecursively();this.children.length=0}resetAfterClear(e,r){this.init(e,r)}raycast(e){return this.raycast1(e,!1)}raycast1(e,r){let o=[],n=a=>{for(let s of a.children){let l=s.cloner;if(_e.is(s)&&!s.raycastLock&&(s.visible||l?.object.data.visible))if(r===!0&&s.isInstanceRoot){let c=[];if(e.intersectObject(s,!0,c),c.length){let u=c[0];u.object=s,u.point.applyMatrix4(u.object.matrixWorld);let d=s.matrixWorld.clone().invert();u.point.applyMatrix4(d),o.push(u)}}else(Li(s)||Bl(s)&&this.enableHelpers&&s.objectHelper.visible)&&(e.intersectObject(s,!1,o),kl(s,e,o)),n(s)}};return n(this.activePage),o}raycastWithClones(e){let r=[],o=n=>{for(let a of n.children){let s=a.cloner;_e.is(a)&&(a.visible||s?.object.data.visible)&&((Li(a)||Bl(a)&&this.enableHelpers&&a.objectHelper.visible)&&(e.intersectObject(a,!1,r),kl(a,e,r,!0)),o(a))}};return o(this),r}forEachEntity(e){for(let r of this.children)_e.is(r)&&e(r)}traverseConcreteEntity(e){for(let r of this.children)_e.is(r)&&r.isConcreteEntity&&r.traverseEntity(e)}traverseEntity(e){for(let r of this.children)_e.is(r)&&r.traverseEntity(e)}updateFont(e,r){this.traverseEntity(o=>{if(o instanceof tt&&o.data.type==="Mesh"&&(o.data.geometry.type==="TextGeometry"||o.data.geometry.type==="InputGeometry")&&o.data.geometry.font===e){let n=o.geometry,a=o.data.geometry;n.updateFont(e,r).then(()=>{n.update(a,r);let s=o.invalidateDownstreamBooleanData();Ll(s)&&s.recomputeBoolean()})}})}traverseObject(e){for(let r of this.children)jo.is(r)&&r.traverseObject(e)}traverseVisibleEntity(e){for(let r of this.children)_e.is(r)&&r.visible&&r.traverseVisibleEntity(e)}dispose(){this.clearScene()}createChildrenObjects(e,r,o){let n=0;for(let a of e)this.createObject(a.id,a.data,a.children,r,n,o),n+=1}registerObjectCreatedInLegacy(e){this.entityByUuid[e.uuid]=e}unregisterObject(e){delete this.entityByUuid[e.uuid];for(let r of e.children)this.unregisterObject(r)}createObject(e,r,o,n,a,s){let l={scene:this,shared:s},c=zd(e,r,l);return c instanceof ji&&this.shapeBlendIntances.push(c),c&&(this.entityByUuid[e]=c,n.add(c),n.children.splice(a,0,n.children.pop()),o.length>0&&(c.isInstanceRoot?console.error("instance should not have children!"):this.createChildrenObjects(o,c,s)),c.updateState(r,l),c instanceof tt&&c.updateGeometryGroupsIfNeeded(),c.updateVisible(this),c.cloner&&this.toExpandCloner.add(c),r.pathSnapping?.pathId&&this.pathConstraints.setConstraint(e,r.pathSnapping.pathId)),r.type==="Empty"&&r.animations&&c.traverseEntity(u=>{let d=u.dataPatched;if(u instanceof tt&&d.bones&&d.boneInverses){let p=d.bones.map(m=>this.find(m)),f=d.boneInverses.map(m=>new mL().fromArray(m)),h=new xL(p,f);u.bind(h,u.bindMatrix)}else u.matrixAutoUpdate=!0}),c}getCenter(e){let r=[];for(let n=0,a=e.length;n<a;++n){let{id:s,recursive:l}=e[n],c=this.find(s),u=l?c.recursiveBBox:c.singleBBox;r.push(...u.vertices)}let o=new yL;return o.setFromPoints(r),o.getCenter(jS),jS}copyMatrixWorld(e,r){if(e===null){r.identity();return}let o=this.find(e);o?r.copy(o.matrixWorld):r.identity()}copyParentMatrixWorld(e,r){if(e===null){r.identity();return}let o=this.find(e)?.parent;o?r.copy(o.matrixWorld):r.identity()}traverseMaterial(e){this.traverseEntity(r=>{if(r instanceof It)if(Array.isArray(r.material))for(let o=0;o<r.material.length;o++)r.material[o]instanceof ar&&e(r.material[o]);else r.material instanceof ar&&e(r.material)})}updateViewPlaneSize(e,r,o=!1){this.traverseConcreteEntity(n=>{n instanceof Zo&&n.setViewplaneSize(e,r,o)})}initializeSplatViewer(){this.splatViewer=new ql({scene:this}),this.reloadSplats()}reloadSplats(){this.splatViewer?.loadSplat()}};import{DRACOLoader as vL}from"three/examples/jsm/loaders/DRACOLoader.js";var qi;function US(i){return qi||(qi=new vL,qi.setDecoderPath(i!==void 0?`${i}/`:"https://www.gstatic.com/draco/versioned/decoders/1.5.2/").preload()),qi.decoderPending}async function SL(i){if(qi){let t={attributeIDs:qi.defaultAttributeIDs,attributeTypes:qi.defaultAttributeTypes,useUniqueIDs:!1},e;try{e=await qi.decodeGeometry(new Int8Array(i).buffer,t)}catch(r){console.error(r)}if(e)return{index:e.index?{array:e.index.array}:void 0,attributes:Object.entries(e.attributes).map(([r,o])=>({name:r,itemSize:o.itemSize,array:o.array}))}}return null}async function kS(i,t){let[e,r]=bp(jc.deserialize(new Uint8Array(i)));return du(e),t&&t(e),r.result().data}function HS(i){let t=[];return i.scene.objects.traverse((e,r)=>{r.type==="Mesh"&&r.geometry.type==="NonParametricGeometry"&&r.geometry.data.draco!==void 0&&t.push(r)}),t}async function WS(i){for(let t of i){let e=await SL(t.geometry.data.draco);if(e){let r=t.geometry.data;e.index&&(r.index={array:e.index.array,itemSize:1,normalized:!1,type:"Uint32Array"});let o={};e.attributes.forEach(({name:n,array:a,itemSize:s})=>{o[n]={array:a,itemSize:s,type:"Float32Array",normalized:!1}}),r.attributes=o,r.draco=void 0}}}import{Mesh as rye}from"three";import{mergeBufferGeometries as nye}from"three/examples/jsm/utils/BufferGeometryUtils.js";function qS(i){let t;if(!!i.index)for(let e=0;e<i.index.array.length;e+=3)t=i.index.array[e],i.index.array[e]=i.index.array[e+2],i.index.array[e+2]=t}import{Color as $S,ShaderLib as wL}from"three";function XS(i){let t=new Set;return i.traverse(e=>{if(e instanceof sr)if(ht(e.material))e.material.forEach(r=>{let o=r;t.has(o)||t.add(o)});else{let r=e.material;t.has(r)||t.add(r)}}),t.forEach(e=>{if(e instanceof Array)return;let r=e.onBeforeCompile.bind(e);if(PL(e)){Object.assign(e,{isMeshStandardMaterial:!0,isMeshPhysicalMaterial:!0,transmission:1,attenuationColor:new $S,specularColor:new $S});let o=0;e.onBeforeCompile=(n,a)=>{r&&r(n,a),n.uniforms=Object.assign({},wL.physical.uniforms,n.uniforms),e.getLayersOfType("transmission").forEach(s=>{if(n.uniforms.transmissionSamplerMap.value){let l=s.color;l&&(l.transmissionSamplerMap.value=n.uniforms.transmissionSamplerMap.value,l.transmissionSamplerSize.value=n.uniforms.transmissionSamplerSize.value,l.aspectRatio.value=pv(window.innerWidth,window.innerHeight),e.defines.IS_THREEJS_EXPORT=!0)}else o++,o<2&&(e.needsUpdate=!0)})}}else OL(e)||(e.onBeforeCompile=(o,n)=>{r&&r(o,n),e.transparent=!1})}),i}function PL(i){return i.getLayersOfType("transmission").length>0}function OL(i){let t=0;for(let e of i.layers){if(e.data.type!=="displace"&&e.data.isMask)return!0;if(e.type!=="light"&&e.type!=="fresnel"){let o=e.uniforms["f"+e.id+"_alpha"];o&&(t+=(1-t)*o.value)}}return t<1}function YS(i){return i.traverse(t=>{if(t.type==="Camera"){let e=t;e.type=e.cameraType}}),i}function KS(i){let t=[],e=(r,o=0)=>{let n=o>0?r+o:r;return t.includes(n)?e(r,o+1):n};return i.traverse(r=>{if(t.includes(r.name)){let o=r.name,n=e(r.name);if(r.name=n,r.isMesh){let a=r;a.material instanceof Array?a.material.forEach(s=>{s.name=s.name.replace(o,n)}):a.material.isAsset||(a.material.name=a.material.name.replace(o,n))}}t.push(r.name)}),i}import{mergeBufferGeometries as TL}from"three/examples/jsm/utils/BufferGeometryUtils.js";function QS(i){let t=[];return i.traverse(e=>{e instanceof Ri&&t.push(e)}),t.forEach(e=>{let r=e.object,a=[...e.children.map(s=>{s.updateMatrix();let l;if(s.geometry!==void 0)try{l=s.geometry.clone().applyMatrix4(s.matrix)}catch(c){console.error(c)}return l!==void 0&&s.matrix.determinant()<0&&qS(l),l}).filter(s=>s!==void 0)];if(!e.parameters.hideBase&&r instanceof It&&a.unshift(r.geometry),a.length){let s=TL(a);r instanceof It&&(r.geometry=s)}e.removeFromParent(),r.setFromClonerState(null,{scene:i,shared:Lv})}),i}function ZS(i){return i.traverse(t=>{t.matrixAutoUpdate=!0}),i}function JS(i){Object.values(i.shared.materials).forEach(t=>{gm(t)}),i.scene.objects.traverse((t,e)=>{"material"in e?gm(e.material):"materials"in e&&e.materials.forEach(r=>{gm(r)})})}function gm(i){if(typeof i=="string")return;let t=[];i.layers.forEach((e,r)=>{e.type==="outline"&&t.push(r)}),t.reverse().forEach(e=>{i.layers.delete(e)}),t.length&&console.warn("The Spline Loader currently does not support the outline layer.")}var ow=Bs(tw(),1);var rw="The SplineLoader only accepts .splinecode files that are generated from Spline export panel.",xm=class extends AL{load(t,e,r,o=console.error){let n=new CL(this.manager);n.setPath(this.path),n.setResponseType("arraybuffer"),n.setRequestHeader(this.requestHeader),n.setWithCredentials(this.withCredentials),t.endsWith(".spline")?console.warn(rw+" The .spline files are only meant to be used by the Editor."):t.endsWith(".splinecode")||console.warn(rw),n.load(t,async a=>{try{if(typeof a=="string")throw new Error("The .spline file is not binary!");let s=await this.parse(a);e(s)}catch(s){o(s)}},r,o)}async parse(t){let e=await kS(t,JS),r=HS(e);e.version&&(0,ow.default)(e.version,"1.12.87")>0&&console.warn("Your .splinecode file is more recent than the library. Please upgrade @splinetool/loader to the latest version."),await Promise.allSettled([r.length&&US(),kv(e)&&Fb(),Jv(e)&&Av(),B1(e)&&_1(),$d(e)&&ym()].filter(Boolean)),r.length&&await WS(r);let o=!1,n=new Tn(e.shared,{},o);Object.values(n.getMaterials()).forEach(l=>Object.assign(l,{isAsset:!0}));let a=new Yd(e.scene,n);$d(e)&&a.initializeSplatViewer();let s=a.activeCamera;return s&&Object.assign(s,{makeDefault:!0}),a=QS(a),a=XS(a),a=YS(a),a=KS(a),a=ZS(a),a}};export{xm as default};
4379
+ }`,n={covariancesTexture:{type:"t",value:null},centersColorsTexture:{type:"t",value:null},meshIndexIntervals:{value:e},meshMatrixWorldsTexture:{type:"t",value:null},focal:{type:"v2",value:new Hi},viewport:{type:"v2",value:new Hi},basisViewport:{type:"v2",value:new Hi},debugColor:{type:"v3",value:new JR},covariancesTextureSize:{type:"v2",value:new Hi(1024,1024)},centersColorsTextureSize:{type:"v2",value:new Hi(1024,1024)},orthoZoom:{type:"f",value:-1}};return new uL({uniforms:n,vertexShader:r,fragmentShader:o,transparent:!0,alphaTest:1,blending:sL,depthTest:!0,depthWrite:!1,side:tL})}static buildGeomtery(e){let r=new ZR;r.setIndex([0,1,2,0,2,3]);let o=new Float32Array(4*3),n=new QR(o,3);r.setAttribute("position",n),n.setXYZ(0,-1,-1,0),n.setXYZ(1,-1,1,0),n.setXYZ(2,1,1,0),n.setXYZ(3,1,-1,0),n.needsUpdate=!0;let a=new nL().copy(r),s=new Uint32Array(e),l=new iL(s,1,!1);return l.setUsage(rL),a.setAttribute("splatIndex",l),a.instanceCount=e,a}resetLocalSplatDataAndTexturesFromSplatBuffer(){this.updateLocalSplatDataFromSplatBuffer(),this.allocateAndStoreLocalSplatDataInTextures()}updateLocalSplatDataFromSplatBuffer(){this.splatBuffers.forEach(n=>n.buildPreComputedBuffers()),this.covariances=new Float32Array(this.splatCount*6),this.colors=new Uint8Array(this.splatCount*4),this.centers=new Float32Array(this.splatCount*3);let e=0,r=0,o=0;for(let n of this.splatBuffers){let a=n.nsplats;this.colors.subarray(e,e+a*4).set(n.colorsA),e+=a*4,this.centers.subarray(r,r+a*3).set(n.decoded.xyz.denormDequant().data),r+=a*3,this.covariances.subarray(o,o+a*6).set(new Float32Array(n.precomputedCovarianceBufferData)),o+=a*6}}allocateAndStoreLocalSplatDataInTextures(){let o=this.splatCount,n=new Hi(4096,1024);for(;n.x*n.y*2<o*6;)n.y*=2;let a=new Hi(4096,1024);for(;a.x*a.y*4<o*4;)a.y*=2;let s,l;if(this.halfPrecisionCovariancesOnGPU){l=new Uint16Array(n.x*n.y*2);for(let h=0;h<this.covariances.length;h++)l[h]=eL.toHalfFloat(this.covariances[h]);s=new Wd(l,n.x,n.y,LS,oL)}else l=new Float32Array(n.x*n.y*2),l.set(this.covariances),s=new Wd(l,n.x,n.y,LS,RS);s.needsUpdate=!0,this.material.uniforms.covariancesTexture.value=s,this.material.uniforms.covariancesTextureSize.value.copy(n);let c=new Uint32Array(a.x*a.y*4);for(let h=0;h<o;h++){let m=h*4,y=h*3,g=h*4;c[g]=_S(this.colors[m],this.colors[m+1],this.colors[m+2],this.colors[m+3]),c[g+1]=Hd(this.centers[y]),c[g+2]=Hd(this.centers[y+1]),c[g+3]=Hd(this.centers[y+2])}let u=new Wd(c,a.x,a.y,cL,dL);u.internalFormat="RGBA32UI",u.needsUpdate=!0,this.material.uniforms.centersColorsTexture.value=u,this.material.uniforms.centersColorsTextureSize.value.copy(a);let d=256*4,p=new Float32Array(256*16);for(let h=0;h<this.meshMatrixWorlds.length;h++)p.set(this.meshMatrixWorlds[h].elements,h*16);let f=new Wd(p,d,1,lL,RS);f.needsUpdate=!0,this.material.uniforms.meshMatrixWorldsTexture.value=f,this.material.uniformsNeedUpdate=!0,this.splatDataTextures={covariances:{data:l,texture:s,size:n},centerColors:{data:c,texture:u,size:a},meshMatrixWorlds:{data:p,texture:f}}}updateIndexes(e){let r=this.geometry;r.attributes.splatIndex.set(e),r.attributes.splatIndex.needsUpdate=!0,r.instanceCount=e.length}updateUniforms(e,r,o,n){this.splatCount>0&&(qd.set(e.x*this.devicePixelRatio,e.y*this.devicePixelRatio),this.material.uniforms.viewport.value.copy(qd),this.material.uniforms.basisViewport.value.set(2/qd.x,2/qd.y),this.material.uniforms.focal.value.set(r,o),this.material.uniforms.orthoZoom.value=n,this.material.uniformsNeedUpdate=!0)}getSplatDataTextures(){return this.splatDataTextures}getSplatCount(){return this.splatCount}getCenters(){return this.centers}getColors(){return this.colors}getCovariances(){return this.covariances}dispose(){this.geometry.dispose(),this.material.dispose(),this.splatDataTextures&&(this.splatDataTextures.covariances.texture.dispose(),this.splatDataTextures.centerColors.texture.dispose(),this.splatDataTextures.meshMatrixWorlds.texture.dispose()),this.removeFromParent()}};var VS,mm=new Promise(i=>{VS=i}),BS=!1;var Xd;function ym(){if(BS)return;if(Xd)return Xd;async function i(){let e=await import("./gaussian-splat-compression.js");VS(e),BS=!0}return Xd=i(),Xd}var FS;mm.then(i=>FS=i);var ql=class{constructor(t={}){Qi(this,"updateView",function(){let t=new zS,e=[],r=new _s(0,0,-1),o=new _s(0,0,-1),n=new _s,a=new _s;return function(s=!1,l){let c=this.updateMatrixWorldsInWorkerIfNeeded(),u=this.cropsChanged();if(!s){o.set(0,0,-1).applyQuaternion(l.quaternion);let p=!1,f=!1;if(o.dot(r)<=.95&&(p=!0),a.copy(l.position).sub(n).length()>=1&&(f=!0),!p&&!f&&!c&&!u&&!this.needsInitialRender)return}this.needsInitialRender=!1,n.copy(l.position),r.copy(o),t.copy(l.matrixWorld).invert(),t.premultiply(this.dummyPerspectiveMatrix),e[0]=l.position.x,e[1]=l.position.y,e[2]=l.position.z;let d={sort:{view:t.elements,cameraPosition:e,splatRenderCount:this.splatRenderCount,splatSortCount:this.splatRenderCount},...c?{newMatrixWorlds:this.meshMatrixWorlds}:{},...u?{newCropsArray:this.cropsArray}:{}};this.sortRunning?this.queuedMessage=d:(this.queuedMessage=null,this.sortRunning=!0,this.sortWorker.postMessage(d))}}());this.scene=t.scene,this.currentPage=null,this.devicePixelRatio=window.devicePixelRatio,this.sortWorker=null,this.splatRenderCount=0,this.splatSortCount=0,this.splatMesh=null,this.sortRunning=!1,this.meshMatrixWorlds=null,this.meshMatrixWorldsOld=null,this.cropsArray=null,this.splatEntries=null,this.queuedMessage=null,this.needsInitialRender=!0,this.dummyPerspectiveMatrix=new zS().makePerspective(-1,1,-1,1,.1,1e3)}updateSplatMeshUniforms(t,e){let r=new pL;if(this.splatMesh===null)return;this.splatMesh.getSplatCount()>0&&(t.getSize(r),this.cameraFocalLengthX=e.projectionMatrix.elements[0]*this.devicePixelRatio*r.x*.45,this.cameraFocalLengthY=e.projectionMatrix.elements[5]*this.devicePixelRatio*r.y*.45,this.splatMesh.updateUniforms(r,this.cameraFocalLengthX,this.cameraFocalLengthY,e.isPerspectiveCamera?-1:e.zoom*this.devicePixelRatio))}loadSplat(t={}){this.activePage=this.scene.activePage,t.position&&(t.position=new _s().fromArray(t.position)),t.orientation&&(t.orientation=new GS().fromArray(t.orientation)),t.halfPrecisionCovariances=!!t.halfPrecisionCovariances;let e=[];if(this.splatEntries=e,this.activePage.traverseVisibleEntity(a=>{a.data.type==="Splat"&&e.push(a)}),this.splatMesh&&this.splatMesh.dispose(),e.length===0)return this.splatMesh=null,!1;this.meshMatrixWorlds=e.map(a=>a.matrixWorld),this.meshMatrixWorldsOld=e.map(a=>a.matrixWorld.clone()),this.cropsArray=e.map(a=>a.data.crops.map(s=>s.data));let r=e.map(a=>new FS.GSplineBuffer(new Uint8Array(a.data.buffer).buffer)),o=0,n=[0];for(let a of r)o+=a.getSplatCount(),n.push(o);return this.setupSplatMesh(r,o,t.position,t.orientation,t.halfPrecisionCovariances,this.devicePixelRatio,n,this.meshMatrixWorlds),this.setupSortWorker(o),!0}updateMatrixWorldsInWorkerIfNeeded(){let t=this.splatDataTextures.meshMatrixWorlds.data;for(let e=0;e<this.meshMatrixWorlds.length;e++)t.set(this.meshMatrixWorlds[e].elements,e*16);return this.splatDataTextures.meshMatrixWorlds.texture.needsUpdate=!0,this.meshMatrixWorlds.every((e,r)=>e.equals(this.meshMatrixWorldsOld[r]))?!1:(this.meshMatrixWorldsOld=this.meshMatrixWorlds.map(e=>e.clone()),!0)}cropsChanged(){let t=!1;return this.splatEntries.forEach((e,r)=>{e.data.crops.forEach((o,n)=>{this.cropsArray[r][n]===void 0?(t=!0,this.cropsArray[r][n]=o.data):Object.entries(o.data).forEach(([a,s])=>{Array.isArray(s)&&s.some((l,c)=>l!==this.cropsArray[r][n][a][c])?(t=!0,this.cropsArray[r][n][a]=s):s!==this.cropsArray[r][n]?.[a]&&(t=!0,this.cropsArray[r][n][a]=s)})}),e.data.crops.length!==this.cropsArray[r]?.length&&(this.cropsArray[r].length=e.data.crops.length,t=!0)}),t}setupSplatMesh(t,e,r=new _s,o=new GS,n=!1,a=1,s,l){this.splatMesh=Wi.buildMesh(t,e,n,a,s,l),this.splatMesh.position.copy(r),this.splatMesh.quaternion.copy(o),this.splatMesh.frustumCulled=!1,this.splatMesh.renderOrder=99999,this.splatRenderCount=e,this.splatMesh.onBeforeRender=(c,u,d)=>this.update(c,d)}setupSortWorker(t){this.sortWorker=DS(t),this.sortWorker.onmessage=e=>{e.data.sortDone?(this.sortRunning=!1,this.splatMesh?.updateIndexes(new Uint32Array(e.data.indexesBuffer)),this.lastSortTime=e.data.sortTime,this.queuedMessage&&(this.sortWorker.postMessage(this.queuedMessage),this.queuedMessage=null)):e.data.sortCanceled?this.sortRunning=!1:e.data.sortSetupPhase1Complete?this.sortWorker.postMessage({positions:this.splatMesh.getCenters().buffer,meshMatrixWorlds:this.splatMesh.meshMatrixWorlds,meshIndexIntervals:this.splatMesh.meshIndexIntervals,cropsArray:this.cropsArray}):e.data.sortSetupComplete&&(this.splatDataTextures=this.splatMesh.getSplatDataTextures(),this.scene.activePage.add(this.splatMesh),this.needsInitialRender=!0)}}update(t,e){this.splatMesh!==null&&(this.updateSplatMeshUniforms(t,e),this.updateView(!1,e))}getSplatMesh(){return this.splatMesh}};var bL=new gL;bL.wireframe=!0;var jS=new hL,Yd=class extends fL{constructor(e,r){super();this.data=e;this.sharedAssets=r;this.enableHelpers=!1;this.wireframeState=!1;this.needsTransmissionDirty=!0;this.needsNormalDirty=!0;this._needsTransmission=!1;this._needsNormal=!1;this.geometryCacheChanged=!1;this.splatViewer=null;this.shapeBlendIntances=[];this.entityByUuid={};this.entityIdentityToEntity={};this.toExpandCloner=new Set;this.toUpdateCloner=new Set;this.pendingCommands=[];this.pathConstraints=new kd;this.invisibleObjects=new Bi("jflkdsafjasdifjaslk",{...ou.defaultData,visible:!1,name:"buildin invisible"});this.needsRecomputeInstances=!1;this.init(e,r),this.matrixAutoUpdate=!1,this.errorPage=new Er("fdasfa",{...Lo.defaultData,name:""},{shared:r,scene:this})}markGeometryCacheDirty(){this.geometryCacheChanged=!0}markNeedsUpdateRendererDirty(){this.needsTransmissionDirty=!0,this.needsNormalDirty=!0}needsTransmission(){return this.needsTransmissionDirty&&(this._needsTransmission=ES(this),this.needsTransmissionDirty=!1),this._needsTransmission}needsNormal(){return this.needsNormalDirty&&(this._needsNormal=IS(this),this.needsNormalDirty=!1),this._needsNormal}registerInstanceAndSetUuid(e){let r=e.identity.join("-"),o=this.entityIdentityToEntity[r];o&&(e.uuid=o.uuid),this.entityIdentityToEntity[r]=e,this.entityByUuid[e.uuid]=e}markPenumbraSizeDirty(){for(let e of this.children)e instanceof Er&&(e.penumbraSizeArrayCache=null)}findInstance(e){return this.entityIdentityToEntity[e.join("-")]}get bgColor(){return this.activePage.bgColor}get postprocessing(){return this.activePage.data.postprocessing}getWithSortKey(e){let r=this.find(e);if(r===void 0)return;let o=[],n=r;for(;n!==this;){let a=n;n=n.parent;let s=n.children.indexOf(a);o.splice(0,0,s)}return{entity:r,sortKey:o}}getAllSorted(e){let r=[];for(let o of e){let n=this.getWithSortKey(o.id);n!==void 0&&r.push(n)}return r.sort((o,n)=>Zc(o.sortKey,n.sortKey)),r.map(o=>o.entity)}nonExistOrDescendantOf(e,r){let o=this.find(e);if(o===void 0)return!0;for(;o;){if(o.uuid===r)return!0;o=o.parent}return!1}find(e){if(this.activePage&&this.activePage.personalCamera.parent){if(e==="f23858d0-4a3b-4bd8-8173-66ed0af7f6fb-personalCamera")return this.activePage.personalCamera;if(e===yi)return this.activePage.personalCamera}if(e===""||e===void 0)return;let r=this.entityByUuid[e];return r===void 0?this.getObjectByProperty("uuid",e):r}find2D(e){for(let r of this.children)if(r instanceof Er&&r.uiScene){let o=r.uiScene.find(e);if(o)return o}}findScene2DfromObject2D(e){for(let r of this.children)if(r instanceof Er&&r.uiScene&&r.uiScene.find(e))return r.uiScene}find2DInUIObjects(e){let r;return this.traverseEntity(o=>{r===void 0&&o instanceof Dn&&(r=o.uiCanvas.find(e))}),r}traverse2D(e){for(let r of this.children)r instanceof Er&&r.uiScene&&r.uiScene.traverse(e)}debugEnsureEntity(e){let r=this.find(e);if(r){if(Array.isArray(r.identity)&&this.findInstance(r.identity)===void 0){console.error("not found instance");debugger}}else{console.error("not found");debugger}}addPendingExpandCloner(e){this.toExpandCloner.add(e)}addPendingUpdateCloner(e){this.toUpdateCloner.add(e)}markToExpandCloner(e){this.toExpandCloner.add(e),e.traverseEntityAncestors(r=>{this.toExpandCloner.add(r)})}doPendingExpandCloner(e){this.toExpandCloner.forEach(r=>{r.expandCloner(e)}),this.toExpandCloner.clear()}doPendingUpdateCloner(e){this.toUpdateCloner.forEach(r=>{r.cloner?.update(e)}),this.toUpdateCloner.clear()}doPendingUpdates(e){this.doPendingExpandCloner(e),this.doPendingUpdateCloner(e),this.applyPendingCommands()}addPendingCommand(e){this.pendingCommands.push(e)}applyPendingCommands(){this.pendingCommands.forEach(e=>e()),this.pendingCommands.length=0}updateByLibOp(e,r){e.path.length===1&&e.path[0]==="components"&&e.type===1&&this.createChildrenObjects([{...e.data.asset,id:e.id}],this.invisibleObjects,r)}updateTreeByOp(e,r){if(e.path.length===0&&e.type===7){let o=e.parent===null?this:this.find(e.parent);if(o===void 0)throw new Error("unexpected");let n=this.createObject(e.id,e.data,e.children,o,e.localIndex,r);n.updateVisible(this),n.resetBBoxNeedsUpdate(),Li(n)&&Ll(n.parent)&&(n.invalidateUpstreamBooleanData(),n.parent.invalidateDownstreamBooleanData().recomputeBoolean()),this.markNeedsRecomputeInstancesForAncessors(o),this.markNeedsRecomputeInstancesForChildren(n),this.markToExpandCloner(n),this.markPenumbraSizeDirty(),n.updatePathSnapping()}else if(e.path.length===0&&e.type===8){let o=this.find(e.id);if(o===void 0)throw new Error("unexpected");o.traverseEntity(a=>{a instanceof ji&&(this.shapeBlendIntances=this.shapeBlendIntances.filter(s=>s!==a))}),this.markToExpandCloner(o),o.resetBBoxNeedsUpdate(),this.unregisterObject(o);let n=o.parent;this.markNeedsRecomputeInstancesForAncessors(n),this.markNeedsRecomputeInstancesForChildren(o),this.markPenumbraSizeDirty(),o.parent.remove(o),Ll(o.parent)&&(o.parent.invalidateUpstreamBooleanData(),o.parent.invalidateDownstreamBooleanData().recomputeBoolean()),Li(o)&&(o.freeBooleanPointer(),n instanceof lr&&n.invalidateDownstreamBooleanData().recomputeBoolean()),o instanceof As&&o.detachShape(),this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(o),this.pathConstraints.removeDependencies(o.uuid),o.updatePathSnapping()}else if(e.path.length===0&&e.type===9){let o=this.find(e.id);if(o===void 0)throw new Error("unexpected");this.markNeedsRecomputeInstancesForChildren(o);let n=o.parent;this.markNeedsRecomputeInstancesForAncessors(n),o.cloner?.resetOnMove(),this.markToExpandCloner(o);let a=e.parent===null?this:this.find(e.parent);if(a===void 0)throw new Error("unexpected");a.add(o),this.markNeedsRecomputeInstancesForAncessors(a),this.markToExpandCloner(o),o.invalidateClonerTransform(o),o.updateVisible(this),o.resetBBoxNeedsUpdate(),this.markPenumbraSizeDirty();let s=e.localIndex;a.children.splice(s,0,a.children.pop()),Li(o)&&(o.invalidateUpstreamBooleanData(),Ll(o.parent)?o.parent.invalidateDownstreamBooleanData().recomputeBoolean():n instanceof lr&&n.invalidateDownstreamBooleanData().recomputeBoolean()),o.updatePathSnapping()}this.markNeedsUpdateRendererDirty(),this.markGeometryCacheDirty()}get playPage(){return this.find(this.data.publish.playPage)??this.errorPage}updatePage(e){this.activePage&&this.activePage.onDeactive(),this.activePage=this.errorPage;for(let r of this.children)r instanceof Er&&(r.visible=r.uuid===e,r.visible&&(this.activePage=r,this.activePage.onActive(this)));this.activePage!==this.splatViewer?.activePage&&this.reloadSplats()}updateEntityByOp(e,r,o,n){if(r.type===0){if(("overrides"in r.props||"component"in r.props)&&this.markNeedsRecomputeInstances(),"visible"in r.props&&this.markPenumbraSizeDirty(),r.path.includes("overrides")&&"states"in r.props){let{rest:s}=r.props;r={...r,props:s},this.markNeedsRecomputeInstances()}r.path[0]==="pathSnapping"&&r.props.pathId!==void 0&&this.pathConstraints.setConstraint(e,r.props.pathId)}let a=this.find(e);if(a)try{xS(a,r,o,{scene:this,shared:n}),a instanceof tt&&a.updateGeometryGroupsIfNeeded()}catch(s){console.error(s)}}updateEntity2DByOp(e,r,o,n,a,s=[]){e.updateEntityByOp(r,o,n,a),this.traverseEntity(l=>{(l instanceof Dn||l instanceof Er)&&(s.includes(l.frameId??"")||l.frameId===r)&&l.updateEntity2DByOp(r,o,n,a)})}get activeCamera(){return this.activePage.activeCamera}switchActiveCamera(e){this.activePage.switchActiveCamera(e)}isInvisibleObjects(e){return e===this.invisibleObjects||e.hasAnccestor(this.invisibleObjects)}init(e,r){let o=Object.entries(r.data.lib.components).map((n,a)=>({data:n[1].asset.data,children:n[1].asset.children,id:n[0],fi:a}));this.invisibleObjects.updateState(this.invisibleObjects.data,{scene:this,shared:r}),this.add(this.invisibleObjects),this.createChildrenObjects(o,this.invisibleObjects,r),this.createChildrenObjects(e.objects,this,r),this.updatePage(e.publish.playPage),this.activePage.switchToPlayCamera(),this.expandInstances(r,!0),this.traverseEntity(n=>{n instanceof Zo&&n.updateUp()}),this.doPendingExpandCloner({scene:this,shared:r}),this.applyPendingCommands()}markNeedsRecomputeInstances(){this.needsRecomputeInstances=!0}markNeedsRecomputeInstancesForChildren(e){e.traverseEntity(r=>{(r.data.type==="Component"||r.data.type==="Instance")&&this.markNeedsRecomputeInstances()})}markNeedsRecomputeInstancesForAncessors(e){_e.is(e)&&(e.data.type==="Component"&&this.markNeedsRecomputeInstances(),e.traverseAncestors(r=>{_e.is(r)&&r.data.type==="Component"&&this.markNeedsRecomputeInstances()}))}relativeizeInner(e,r,o,n,a,s,l){if(e){let c=n.find(e);c&&c!==n&&a.forInstancesRec(u=>{u.data=ui(u.data,d=>{let p=d.events.data(l.id),f=u.goUp(s);if(f){let h=[...Qc(f.identity),e].join("-"),m=this.entityIdentityToEntity[h];if(m){let y=m.uuid,g=Je.zoom(p,r);g[o]=y}else{if(!1)debugger;console.warn("cannot find instance")}}}).data})}}rewriteActions(e,r,o,n,a,s){e.forEach(l=>{l.data.type==="Transition"?this.relativeizeInner(l.data.object,[...r,l.id],"object",o,n,a,s):l.data.type==="Animation"?this.relativeizeInner(l.data.object,[...r,l.id],"object",o,n,a,s):l.data.type==="Conditional"&&(this.rewriteActions(l.data.ifActions,[...r,l.id,"ifActions"],o,n,a,s),this.rewriteActions(l.data.elseActions,[...r,l.id,"elseActions"],o,n,a,s))})}rewriteEventsBeforeGoToPlayMode(){this.traverseEntity(e=>{if(e instanceof ti&&typeof e.identity=="string"&&e.data.type==="Component")return e.traverseEntity((r,o)=>{r.data.events.forEach(n=>{if(n.data.type==="GameControl"){let a=!1;if(r.forInstancesRec(s=>{s.data=ui(s.data,l=>{s.isInstanceRoot||(l.events.delete(n.id),a=!0)}).data}),a===!1)for(let s of su.list)this.rewriteActions(n.data.gameActions[s],["gameActions",s],e,r,o,n)}else n.data.type==="Conditional"?(n.data.condition.type==="Distance"?(this.relativeizeInner(n.data.condition.fromObject,["condition"],"fromObject",e,r,o,n),this.relativeizeInner(n.data.condition.toObject,["condition"],"toObject",e,r,o,n)):n.data.condition.type==="State"?this.relativeizeInner(n.data.condition.object,["condition"],"object",e,r,o,n):n.data.condition.type==="Comparison"&&(n.data.condition.lOperand.type==="Property"&&this.relativeizeInner(n.data.condition.lOperand.value[0],["condition","lOperand","value"],0,e,r,o,n),n.data.condition.rOperand.type==="Property"&&this.relativeizeInner(n.data.condition.rOperand.value[0],["condition","rOperand","value"],0,e,r,o,n)),this.rewriteActions(n.data.inActions,["inActions"],e,r,o,n),this.rewriteActions(n.data.outActions,["outActions"],e,r,o,n)):"actions"in n.data&&this.rewriteActions(n.data.actions,["actions"],e,r,o,n)})}),!0})}expandInstances(e,r,o){let n=new Set;this.traverseEntity(a=>{if(a instanceof ti&&a.isInstanceRoot)return a.expandInstanceChildren({scene:this,shared:e,pendingDeletes:n}),r||a.resetBBoxNeedsUpdate(),o&&a.traverseEntity(s=>{o.addClip(s)}),!0});for(let a of n)this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(a),Rd(a)}recomputeInstances(e,r){this.needsRecomputeInstances&&(this.needsRecomputeInstances=!1,this.traverseEntity(o=>{o instanceof ti&&o.isInstanceRoot&&(o.component=void 0)}),this.expandInstances(e,!1,r))}disposeAndUnregisterEntityRecursivelyIfNotReregistered(e){e.traverseEntity(r=>{let o=typeof r.identity=="string"?r.identity:r.identity.join("-");this.entityIdentityToEntity[o]===r&&(delete this.entityByUuid[r.uuid],delete this.entityIdentityToEntity[o]),r.dispose()})}clearScene(){for(let e of this.children)_e.is(e)&&e.disposeRecursively();this.children.length=0}resetAfterClear(e,r){this.init(e,r)}raycast(e){return this.raycast1(e,!1)}raycast1(e,r){let o=[],n=a=>{for(let s of a.children){let l=s.cloner;if(_e.is(s)&&!s.raycastLock&&(s.visible||l?.object.data.visible))if(r===!0&&s.isInstanceRoot){let c=[];if(e.intersectObject(s,!0,c),c.length){let u=c[0];u.object=s,u.point.applyMatrix4(u.object.matrixWorld);let d=s.matrixWorld.clone().invert();u.point.applyMatrix4(d),o.push(u)}}else(Li(s)||Bl(s)&&this.enableHelpers&&s.objectHelper.visible)&&(e.intersectObject(s,!1,o),kl(s,e,o)),n(s)}};return n(this.activePage),o}raycastWithClones(e){let r=[],o=n=>{for(let a of n.children){let s=a.cloner;_e.is(a)&&(a.visible||s?.object.data.visible)&&((Li(a)||Bl(a)&&this.enableHelpers&&a.objectHelper.visible)&&(e.intersectObject(a,!1,r),kl(a,e,r,!0)),o(a))}};return o(this),r}forEachEntity(e){for(let r of this.children)_e.is(r)&&e(r)}traverseConcreteEntity(e){for(let r of this.children)_e.is(r)&&r.isConcreteEntity&&r.traverseEntity(e)}traverseEntity(e){for(let r of this.children)_e.is(r)&&r.traverseEntity(e)}updateFont(e,r){this.traverseEntity(o=>{if(o instanceof tt&&o.data.type==="Mesh"&&(o.data.geometry.type==="TextGeometry"||o.data.geometry.type==="InputGeometry")&&o.data.geometry.font===e){let n=o.geometry,a=o.data.geometry;n.updateFont(e,r).then(()=>{n.update(a,r);let s=o.invalidateDownstreamBooleanData();Ll(s)&&s.recomputeBoolean()})}})}traverseObject(e){for(let r of this.children)jo.is(r)&&r.traverseObject(e)}traverseVisibleEntity(e){for(let r of this.children)_e.is(r)&&r.visible&&r.traverseVisibleEntity(e)}dispose(){this.clearScene()}createChildrenObjects(e,r,o){let n=0;for(let a of e)this.createObject(a.id,a.data,a.children,r,n,o),n+=1}registerObjectCreatedInLegacy(e){this.entityByUuid[e.uuid]=e}unregisterObject(e){delete this.entityByUuid[e.uuid];for(let r of e.children)this.unregisterObject(r)}createObject(e,r,o,n,a,s){let l={scene:this,shared:s},c=zd(e,r,l);return c instanceof ji&&this.shapeBlendIntances.push(c),c&&(this.entityByUuid[e]=c,n.add(c),n.children.splice(a,0,n.children.pop()),o.length>0&&(c.isInstanceRoot?console.error("instance should not have children!"):this.createChildrenObjects(o,c,s)),c.updateState(r,l),c instanceof tt&&c.updateGeometryGroupsIfNeeded(),c.updateVisible(this),c.cloner&&this.toExpandCloner.add(c),r.pathSnapping?.pathId&&this.pathConstraints.setConstraint(e,r.pathSnapping.pathId)),r.type==="Empty"&&r.animations&&c.traverseEntity(u=>{let d=u.dataPatched;if(u instanceof tt&&d.bones&&d.boneInverses){let p=d.bones.map(m=>this.find(m)),f=d.boneInverses.map(m=>new mL().fromArray(m)),h=new xL(p,f);u.bind(h,u.bindMatrix)}else u.matrixAutoUpdate=!0}),c}getCenter(e){let r=[];for(let n=0,a=e.length;n<a;++n){let{id:s,recursive:l}=e[n],c=this.find(s),u=l?c.recursiveBBox:c.singleBBox;r.push(...u.vertices)}let o=new yL;return o.setFromPoints(r),o.getCenter(jS),jS}copyMatrixWorld(e,r){if(e===null){r.identity();return}let o=this.find(e);o?r.copy(o.matrixWorld):r.identity()}copyParentMatrixWorld(e,r){if(e===null){r.identity();return}let o=this.find(e)?.parent;o?r.copy(o.matrixWorld):r.identity()}traverseMaterial(e){this.traverseEntity(r=>{if(r instanceof It)if(Array.isArray(r.material))for(let o=0;o<r.material.length;o++)r.material[o]instanceof ar&&e(r.material[o]);else r.material instanceof ar&&e(r.material)})}updateViewPlaneSize(e,r,o=!1){this.traverseConcreteEntity(n=>{n instanceof Zo&&n.setViewplaneSize(e,r,o)})}initializeSplatViewer(){this.splatViewer=new ql({scene:this}),this.reloadSplats()}reloadSplats(){this.splatViewer?.loadSplat()}};import{DRACOLoader as vL}from"three/examples/jsm/loaders/DRACOLoader.js";var qi;function US(i){return qi||(qi=new vL,qi.setDecoderPath(i!==void 0?`${i}/`:"https://www.gstatic.com/draco/versioned/decoders/1.5.2/").preload()),qi.decoderPending}async function SL(i){if(qi){let t={attributeIDs:qi.defaultAttributeIDs,attributeTypes:qi.defaultAttributeTypes,useUniqueIDs:!1},e;try{e=await qi.decodeGeometry(new Int8Array(i).buffer,t)}catch(r){console.error(r)}if(e)return{index:e.index?{array:e.index.array}:void 0,attributes:Object.entries(e.attributes).map(([r,o])=>({name:r,itemSize:o.itemSize,array:o.array}))}}return null}async function kS(i,t){let[e,r]=bp(jc.deserialize(new Uint8Array(i)));return du(e),t&&t(e),r.result().data}function HS(i){let t=[];return i.scene.objects.traverse((e,r)=>{r.type==="Mesh"&&r.geometry.type==="NonParametricGeometry"&&r.geometry.data.draco!==void 0&&t.push(r)}),t}async function WS(i){for(let t of i){let e=await SL(t.geometry.data.draco);if(e){let r=t.geometry.data;e.index&&(r.index={array:e.index.array,itemSize:1,normalized:!1,type:"Uint32Array"});let o={};e.attributes.forEach(({name:n,array:a,itemSize:s})=>{o[n]={array:a,itemSize:s,type:"Float32Array",normalized:!1}}),r.attributes=o,r.draco=void 0}}}import{Mesh as rye}from"three";import{mergeBufferGeometries as nye}from"three/examples/jsm/utils/BufferGeometryUtils.js";function qS(i){let t;if(!!i.index)for(let e=0;e<i.index.array.length;e+=3)t=i.index.array[e],i.index.array[e]=i.index.array[e+2],i.index.array[e+2]=t}import{Color as $S,ShaderLib as wL}from"three";function XS(i){let t=new Set;return i.traverse(e=>{if(e instanceof sr)if(ht(e.material))e.material.forEach(r=>{let o=r;t.has(o)||t.add(o)});else{let r=e.material;t.has(r)||t.add(r)}}),t.forEach(e=>{if(e instanceof Array)return;let r=e.onBeforeCompile.bind(e);if(PL(e)){Object.assign(e,{isMeshStandardMaterial:!0,isMeshPhysicalMaterial:!0,transmission:1,attenuationColor:new $S,specularColor:new $S});let o=0;e.onBeforeCompile=(n,a)=>{r&&r(n,a),n.uniforms=Object.assign({},wL.physical.uniforms,n.uniforms),e.getLayersOfType("transmission").forEach(s=>{if(n.uniforms.transmissionSamplerMap.value){let l=s.color;l&&(l.transmissionSamplerMap.value=n.uniforms.transmissionSamplerMap.value,l.transmissionSamplerSize.value=n.uniforms.transmissionSamplerSize.value,l.aspectRatio.value=pv(window.innerWidth,window.innerHeight),e.defines.IS_THREEJS_EXPORT=!0)}else o++,o<2&&(e.needsUpdate=!0)})}}else OL(e)||(e.onBeforeCompile=(o,n)=>{r&&r(o,n),e.transparent=!1})}),i}function PL(i){return i.getLayersOfType("transmission").length>0}function OL(i){let t=0;for(let e of i.layers){if(e.data.type!=="displace"&&e.data.isMask)return!0;if(e.type!=="light"&&e.type!=="fresnel"){let o=e.uniforms["f"+e.id+"_alpha"];o&&(t+=(1-t)*o.value)}}return t<1}function YS(i){return i.traverse(t=>{if(t.type==="Camera"){let e=t;e.type=e.cameraType}}),i}function KS(i){let t=[],e=(r,o=0)=>{let n=o>0?r+o:r;return t.includes(n)?e(r,o+1):n};return i.traverse(r=>{if(t.includes(r.name)){let o=r.name,n=e(r.name);if(r.name=n,r.isMesh){let a=r;a.material instanceof Array?a.material.forEach(s=>{s.name=s.name.replace(o,n)}):a.material.isAsset||(a.material.name=a.material.name.replace(o,n))}}t.push(r.name)}),i}import{mergeBufferGeometries as TL}from"three/examples/jsm/utils/BufferGeometryUtils.js";function QS(i){let t=[];return i.traverse(e=>{e instanceof Ri&&t.push(e)}),t.forEach(e=>{let r=e.object,a=[...e.children.map(s=>{s.updateMatrix();let l;if(s.geometry!==void 0)try{l=s.geometry.clone().applyMatrix4(s.matrix)}catch(c){console.error(c)}return l!==void 0&&s.matrix.determinant()<0&&qS(l),l}).filter(s=>s!==void 0)];if(!e.parameters.hideBase&&r instanceof It&&a.unshift(r.geometry),a.length){let s=TL(a);r instanceof It&&(r.geometry=s)}e.removeFromParent(),r.setFromClonerState(null,{scene:i,shared:Lv})}),i}function ZS(i){return i.traverse(t=>{t.matrixAutoUpdate=!0}),i}function JS(i){Object.values(i.shared.materials).forEach(t=>{gm(t)}),i.scene.objects.traverse((t,e)=>{"material"in e?gm(e.material):"materials"in e&&e.materials.forEach(r=>{gm(r)})})}function gm(i){if(typeof i=="string")return;let t=[];i.layers.forEach((e,r)=>{e.type==="outline"&&t.push(r)}),t.reverse().forEach(e=>{i.layers.delete(e)}),t.length&&console.warn("The Spline Loader currently does not support the outline layer.")}var ow=Bs(tw(),1);var rw="The SplineLoader only accepts .splinecode files that are generated from Spline export panel.",xm=class extends AL{load(t,e,r,o=console.error){let n=new CL(this.manager);n.setPath(this.path),n.setResponseType("arraybuffer"),n.setRequestHeader(this.requestHeader),n.setWithCredentials(this.withCredentials),t.endsWith(".spline")?console.warn(rw+" The .spline files are only meant to be used by the Editor."):t.endsWith(".splinecode")||console.warn(rw),n.load(t,async a=>{try{if(typeof a=="string")throw new Error("The .spline file is not binary!");let s=await this.parse(a);e(s)}catch(s){o(s)}},r,o)}async parse(t){let e=await kS(t,JS),r=HS(e);e.version&&(0,ow.default)(e.version,"1.12.88")>0&&console.warn("Your .splinecode file is more recent than the library. Please upgrade @splinetool/loader to the latest version."),await Promise.allSettled([r.length&&US(),kv(e)&&Fb(),Jv(e)&&Av(),B1(e)&&_1(),$d(e)&&ym()].filter(Boolean)),r.length&&await WS(r);let o=!1,n=new Tn(e.shared,{},o);Object.values(n.getMaterials()).forEach(l=>Object.assign(l,{isAsset:!0}));let a=new Yd(e.scene,n);$d(e)&&a.initializeSplatViewer();let s=a.activeCamera;return s&&Object.assign(s,{makeDefault:!0}),a=QS(a),a=XS(a),a=YS(a),a=KS(a),a=ZS(a),a}};export{xm as default};
package/build/ui.js CHANGED
@@ -1,3 +1,3 @@
1
- var Qr=(ae=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(ae,{get:(ge,m)=>(typeof require<"u"?require:ge)[m]}):ae)(function(ae){if(typeof require<"u")return require.apply(this,arguments);throw new Error('Dynamic require of "'+ae+'" is not supported')});var Kn=(ae,ge)=>()=>(ge||ae((ge={exports:{}}).exports,ge),ge.exports);var Jn=Kn((zr,Kt)=>{var Zr=(()=>{var ae=typeof document<"u"&&document.currentScript?document.currentScript.src:void 0;return typeof __filename<"u"&&(ae=ae||__filename),function(ge={}){var m=ge,Jt,et;m.ready=new Promise((e,t)=>{Jt=e,et=t}),function(e){e.Id=e.Id||[],e.Id.push(function(){e.MakeSWCanvasSurface=function(t){var r=t,i=typeof OffscreenCanvas<"u"&&r instanceof OffscreenCanvas;if(!(typeof HTMLCanvasElement<"u"&&r instanceof HTMLCanvasElement||i||(r=document.getElementById(t),r)))throw"Canvas with id "+t+" was not found";return(t=e.MakeSurface(r.width,r.height))&&(t.ie=r),t},e.MakeCanvasSurface||(e.MakeCanvasSurface=e.MakeSWCanvasSurface),e.MakeSurface=function(t,r){var i={width:t,height:r,colorType:e.ColorType.RGBA_8888,alphaType:e.AlphaType.Unpremul,colorSpace:e.ColorSpace.SRGB},o=t*r*4,s=e._malloc(o);return(i=e.Surface._makeRasterDirect(i,s,4*t))&&(i.ie=null,i.Pe=t,i.Me=r,i.Ne=o,i.re=s,i.getCanvas().clear(e.TRANSPARENT)),i},e.MakeRasterDirectSurface=function(t,r,i){return e.Surface._makeRasterDirect(t,r.byteOffset,i)},e.Surface.prototype.flush=function(t){if(e.Fd(this.Ed),this._flush(),this.ie){var r=new Uint8ClampedArray(e.HEAPU8.buffer,this.re,this.Ne);r=new ImageData(r,this.Pe,this.Me),t?this.ie.getContext("2d").putImageData(r,0,0,t[0],t[1],t[2]-t[0],t[3]-t[1]):this.ie.getContext("2d").putImageData(r,0,0)}},e.Surface.prototype.dispose=function(){this.re&&e._free(this.re),this.delete()},e.Fd=e.Fd||function(){},e.je=e.je||function(){return null}})}(m),function(e){e.Id=e.Id||[],e.Id.push(function(){function t(f,h,g){return f&&f.hasOwnProperty(h)?f[h]:g}function r(f){var h=ke(re);return re[h]=f,h}function i(f){return f.naturalHeight||f.videoHeight||f.displayHeight||f.height}function o(f){return f.naturalWidth||f.videoWidth||f.displayWidth||f.width}function s(f,h,g,P){return f.bindTexture(f.TEXTURE_2D,h),P||g.alphaType!==e.AlphaType.Premul||f.pixelStorei(f.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0),h}function l(f,h,g){g||h.alphaType!==e.AlphaType.Premul||f.pixelStorei(f.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),f.bindTexture(f.TEXTURE_2D,null)}e.GetWebGLContext=function(f,h){if(!f)throw"null canvas passed into makeWebGLContext";var g={alpha:t(h,"alpha",1),depth:t(h,"depth",1),stencil:t(h,"stencil",8),antialias:t(h,"antialias",0),premultipliedAlpha:t(h,"premultipliedAlpha",1),preserveDrawingBuffer:t(h,"preserveDrawingBuffer",0),preferLowPowerToHighPerformance:t(h,"preferLowPowerToHighPerformance",0),failIfMajorPerformanceCaveat:t(h,"failIfMajorPerformanceCaveat",0),enableExtensionsByDefault:t(h,"enableExtensionsByDefault",1),explicitSwapControl:t(h,"explicitSwapControl",0),renderViaOffscreenBackBuffer:t(h,"renderViaOffscreenBackBuffer",0)};if(g.majorVersion=h&&h.majorVersion?h.majorVersion:typeof WebGL2RenderingContext<"u"?2:1,g.explicitSwapControl)throw"explicitSwapControl is not supported";return f=Mn(f,g),f?(Ir(f),B.Qd.getExtension("WEBGL_debug_renderer_info"),f):0},e.deleteContext=function(f){B===me[f]&&(B=null),typeof JSEvents=="object"&&JSEvents.tf(me[f].Qd.canvas),me[f]&&me[f].Qd.canvas&&(me[f].Qd.canvas.Ke=void 0),me[f]=null},e._setTextureCleanup({deleteTexture:function(f,h){var g=re[h];g&&me[f].Qd.deleteTexture(g),re[h]=null}}),e.MakeWebGLContext=function(f){if(!this.Fd(f))return null;var h=this._MakeGrContext();if(!h)return null;h.Ed=f;var g=h.delete.bind(h);return h.delete=function(){e.Fd(this.Ed),g()}.bind(h),B.te=h},e.MakeGrContext=e.MakeWebGLContext,e.GrDirectContext.prototype.getResourceCacheLimitBytes=function(){e.Fd(this.Ed),this._getResourceCacheLimitBytes()},e.GrDirectContext.prototype.getResourceCacheUsageBytes=function(){e.Fd(this.Ed),this._getResourceCacheUsageBytes()},e.GrDirectContext.prototype.releaseResourcesAndAbandonContext=function(){e.Fd(this.Ed),this._releaseResourcesAndAbandonContext()},e.GrDirectContext.prototype.setResourceCacheLimitBytes=function(f){e.Fd(this.Ed),this._setResourceCacheLimitBytes(f)},e.MakeOnScreenGLSurface=function(f,h,g,P,E,T){return!this.Fd(f.Ed)||(h=E===void 0||T===void 0?this._MakeOnScreenGLSurface(f,h,g,P):this._MakeOnScreenGLSurface(f,h,g,P,E,T),!h)?null:(h.Ed=f.Ed,h)},e.MakeRenderTarget=function(){var f=arguments[0];if(!this.Fd(f.Ed))return null;if(arguments.length===3){var h=this._MakeRenderTargetWH(f,arguments[1],arguments[2]);if(!h)return null}else if(arguments.length===2){if(h=this._MakeRenderTargetII(f,arguments[1]),!h)return null}else return null;return h.Ed=f.Ed,h},e.MakeWebGLCanvasSurface=function(f,h,g){h=h||null;var P=f,E=typeof OffscreenCanvas<"u"&&P instanceof OffscreenCanvas;if(!(typeof HTMLCanvasElement<"u"&&P instanceof HTMLCanvasElement||E||(P=document.getElementById(f),P)))throw"Canvas with id "+f+" was not found";if(f=this.GetWebGLContext(P,g),!f||0>f)throw"failed to create webgl context: err "+f;return f=this.MakeWebGLContext(f),h=this.MakeOnScreenGLSurface(f,P.width,P.height,h),h||(h=P.cloneNode(!0),P.parentNode.replaceChild(h,P),h.classList.add("ck-replaced"),e.MakeSWCanvasSurface(h))},e.MakeCanvasSurface=e.MakeWebGLCanvasSurface,e.Surface.prototype.makeImageFromTexture=function(f,h){return e.Fd(this.Ed),f=r(f),(h=this._makeImageFromTexture(this.Ed,f,h))&&(h.de=f),h},e.Surface.prototype.makeImageFromTextureSource=function(f,h,g){h||(h={height:i(f),width:o(f),colorType:e.ColorType.RGBA_8888,alphaType:g?e.AlphaType.Premul:e.AlphaType.Unpremul}),h.colorSpace||(h.colorSpace=e.ColorSpace.SRGB),e.Fd(this.Ed);var P=B.Qd;return g=s(P,P.createTexture(),h,g),B.version===2?P.texImage2D(P.TEXTURE_2D,0,P.RGBA,h.width,h.height,0,P.RGBA,P.UNSIGNED_BYTE,f):P.texImage2D(P.TEXTURE_2D,0,P.RGBA,P.RGBA,P.UNSIGNED_BYTE,f),l(P,h),this._resetContext(),this.makeImageFromTexture(g,h)},e.Surface.prototype.updateTextureFromSource=function(f,h,g){if(f.de){e.Fd(this.Ed);var P=f.getImageInfo(),E=B.Qd,T=s(E,re[f.de],P,g);B.version===2?E.texImage2D(E.TEXTURE_2D,0,E.RGBA,o(h),i(h),0,E.RGBA,E.UNSIGNED_BYTE,h):E.texImage2D(E.TEXTURE_2D,0,E.RGBA,E.RGBA,E.UNSIGNED_BYTE,h),l(E,P,g),this._resetContext(),re[f.de]=null,f.de=r(T),P.colorSpace=f.getColorSpace(),h=this._makeImageFromTexture(this.Ed,f.de,P),g=f.Dd.Hd,E=f.Dd.Ld,f.Dd.Hd=h.Dd.Hd,f.Dd.Ld=h.Dd.Ld,h.Dd.Hd=g,h.Dd.Ld=E,h.delete(),P.colorSpace.delete()}},e.MakeLazyImageFromTextureSource=function(f,h,g){h||(h={height:i(f),width:o(f),colorType:e.ColorType.RGBA_8888,alphaType:g?e.AlphaType.Premul:e.AlphaType.Unpremul}),h.colorSpace||(h.colorSpace=e.ColorSpace.SRGB);var P={makeTexture:function(){var E=B,T=E.Qd,v=s(T,T.createTexture(),h,g);return E.version===2?T.texImage2D(T.TEXTURE_2D,0,T.RGBA,h.width,h.height,0,T.RGBA,T.UNSIGNED_BYTE,f):T.texImage2D(T.TEXTURE_2D,0,T.RGBA,T.RGBA,T.UNSIGNED_BYTE,f),l(T,h,g),r(v)},freeSrc:function(){}};return f.constructor.name==="VideoFrame"&&(P.freeSrc=function(){f.close()}),e.Image._makeFromGenerator(h,P)},e.Fd=function(f){return f?Ir(f):!1},e.je=function(){return B&&B.te&&!B.te.isDeleted()?B.te:null}})}(m),function(e){function t(a){return(o(255*a[3])<<24|o(255*a[0])<<16|o(255*a[1])<<8|o(255*a[2])<<0)>>>0}function r(a){if(a&&a._ck)return a;if(a instanceof Float32Array){for(var n=Math.floor(a.length/4),u=new Uint32Array(n),c=0;c<n;c++)u[c]=t(a.slice(4*c,4*(c+1)));return u}if(a instanceof Uint32Array)return a;if(a instanceof Array&&a[0]instanceof Float32Array)return a.map(t)}function i(a){if(a===void 0)return 1;var n=parseFloat(a);return a&&a.indexOf("%")!==-1?n/100:n}function o(a){return Math.round(Math.max(0,Math.min(a||0,255)))}function s(a,n){n&&n._ck||e._free(a)}function l(a,n,u){if(!a||!a.length)return L;if(a&&a._ck)return a.byteOffset;var c=e[n].BYTES_PER_ELEMENT;return u||(u=e._malloc(a.length*c)),e[n].set(a,u/c),u}function f(a){var n={Nd:L,count:a.length,colorType:e.ColorType.RGBA_F32};if(a instanceof Float32Array)n.Nd=l(a,"HEAPF32"),n.count=a.length/4;else if(a instanceof Uint32Array)n.Nd=l(a,"HEAPU32"),n.colorType=e.ColorType.RGBA_8888;else if(a instanceof Array){if(a&&a.length){for(var u=e._malloc(16*a.length),c=0,y=u/4,_=0;_<a.length;_++)for(var C=0;4>C;C++)e.HEAPF32[y+c]=a[_][C],c++;a=u}else a=L;n.Nd=a}else throw"Invalid argument to copyFlexibleColorArray, Not a color array "+typeof a;return n}function h(a){if(!a)return L;var n=W.toTypedArray();if(a.length){if(a.length===6||a.length===9)return l(a,"HEAPF32",x),a.length===6&&e.HEAPF32.set(Xn,6+x/4),x;if(a.length===16)return n[0]=a[0],n[1]=a[1],n[2]=a[3],n[3]=a[4],n[4]=a[5],n[5]=a[7],n[6]=a[12],n[7]=a[13],n[8]=a[15],x;throw"invalid matrix size"}if(a.m11===void 0)throw"invalid matrix argument";return n[0]=a.m11,n[1]=a.m21,n[2]=a.m41,n[3]=a.m12,n[4]=a.m22,n[5]=a.m42,n[6]=a.m14,n[7]=a.m24,n[8]=a.m44,x}function g(a){if(!a)return L;var n=Y.toTypedArray();if(a.length){if(a.length!==16&&a.length!==6&&a.length!==9)throw"invalid matrix size";return a.length===16?l(a,"HEAPF32",J):(n.fill(0),n[0]=a[0],n[1]=a[1],n[3]=a[2],n[4]=a[3],n[5]=a[4],n[7]=a[5],n[10]=1,n[12]=a[6],n[13]=a[7],n[15]=a[8],a.length===6&&(n[12]=0,n[13]=0,n[15]=1),J)}if(a.m11===void 0)throw"invalid matrix argument";return n[0]=a.m11,n[1]=a.m21,n[2]=a.m31,n[3]=a.m41,n[4]=a.m12,n[5]=a.m22,n[6]=a.m32,n[7]=a.m42,n[8]=a.m13,n[9]=a.m23,n[10]=a.m33,n[11]=a.m43,n[12]=a.m14,n[13]=a.m24,n[14]=a.m34,n[15]=a.m44,J}function P(a,n){return l(a,"HEAPF32",n||_e)}function E(a,n,u,c){var y=Ue.toTypedArray();return y[0]=a,y[1]=n,y[2]=u,y[3]=c,_e}function T(a){for(var n=new Float32Array(4),u=0;4>u;u++)n[u]=e.HEAPF32[a/4+u];return n}function v(a,n){return l(a,"HEAPF32",n||N)}function M(a,n){return l(a,"HEAPF32",n||Nt)}e.Color=function(a,n,u,c){return c===void 0&&(c=1),e.Color4f(o(a)/255,o(n)/255,o(u)/255,c)},e.ColorAsInt=function(a,n,u,c){return c===void 0&&(c=255),(o(c)<<24|o(a)<<16|o(n)<<8|o(u)<<0&268435455)>>>0},e.Color4f=function(a,n,u,c){return c===void 0&&(c=1),Float32Array.of(a,n,u,c)},Object.defineProperty(e,"TRANSPARENT",{get:function(){return e.Color4f(0,0,0,0)}}),Object.defineProperty(e,"BLACK",{get:function(){return e.Color4f(0,0,0,1)}}),Object.defineProperty(e,"WHITE",{get:function(){return e.Color4f(1,1,1,1)}}),Object.defineProperty(e,"RED",{get:function(){return e.Color4f(1,0,0,1)}}),Object.defineProperty(e,"GREEN",{get:function(){return e.Color4f(0,1,0,1)}}),Object.defineProperty(e,"BLUE",{get:function(){return e.Color4f(0,0,1,1)}}),Object.defineProperty(e,"YELLOW",{get:function(){return e.Color4f(1,1,0,1)}}),Object.defineProperty(e,"CYAN",{get:function(){return e.Color4f(0,1,1,1)}}),Object.defineProperty(e,"MAGENTA",{get:function(){return e.Color4f(1,0,1,1)}}),e.getColorComponents=function(a){return[Math.floor(255*a[0]),Math.floor(255*a[1]),Math.floor(255*a[2]),a[3]]},e.parseColorString=function(a,n){if(a=a.toLowerCase(),a.startsWith("#")){switch(n=255,a.length){case 9:n=parseInt(a.slice(7,9),16);case 7:var u=parseInt(a.slice(1,3),16),c=parseInt(a.slice(3,5),16),y=parseInt(a.slice(5,7),16);break;case 5:n=17*parseInt(a.slice(4,5),16);case 4:u=17*parseInt(a.slice(1,2),16),c=17*parseInt(a.slice(2,3),16),y=17*parseInt(a.slice(3,4),16)}return e.Color(u,c,y,n/255)}return a.startsWith("rgba")?(a=a.slice(5,-1),a=a.split(","),e.Color(+a[0],+a[1],+a[2],i(a[3]))):a.startsWith("rgb")?(a=a.slice(4,-1),a=a.split(","),e.Color(+a[0],+a[1],+a[2],i(a[3]))):a.startsWith("gray(")||a.startsWith("hsl")||!n||(a=n[a],a===void 0)?e.BLACK:a},e.multiplyByAlpha=function(a,n){return a=a.slice(),a[3]=Math.max(0,Math.min(a[3]*n,1)),a},e.Malloc=function(a,n){var u=e._malloc(n*a.BYTES_PER_ELEMENT);return{_ck:!0,length:n,byteOffset:u,Xd:null,subarray:function(c,y){return c=this.toTypedArray().subarray(c,y),c._ck=!0,c},toTypedArray:function(){return this.Xd&&this.Xd.length?this.Xd:(this.Xd=new a(e.HEAPU8.buffer,u,n),this.Xd._ck=!0,this.Xd)}}},e.Free=function(a){e._free(a.byteOffset),a.byteOffset=L,a.toTypedArray=null,a.Xd=null};var x=L,W,J=L,Y,_e=L,Ue,de,N=L,Sr,Fe=L,Vr,St=L,Nr,Vt=L,Et,ze=L,Yr,Nt=L,Xr,Kr=L,Xn=Float32Array.of(0,0,1),L=0;e.onRuntimeInitialized=function(){function a(n,u,c,y,_,C,F){C||(C=4*y.width,y.colorType===e.ColorType.RGBA_F16?C*=2:y.colorType===e.ColorType.RGBA_F32&&(C*=4));var D=C*y.height,I=_?_.byteOffset:e._malloc(D);if(F?!n._readPixels(y,I,C,u,c,F):!n._readPixels(y,I,C,u,c))return _||e._free(I),null;if(_)return _.toTypedArray();switch(y.colorType){case e.ColorType.RGBA_8888:case e.ColorType.RGBA_F16:n=new Uint8Array(e.HEAPU8.buffer,I,D).slice();break;case e.ColorType.RGBA_F32:n=new Float32Array(e.HEAPU8.buffer,I,D).slice();break;default:return null}return e._free(I),n}Ue=e.Malloc(Float32Array,4),_e=Ue.byteOffset,Y=e.Malloc(Float32Array,16),J=Y.byteOffset,W=e.Malloc(Float32Array,9),x=W.byteOffset,Yr=e.Malloc(Float32Array,12),Nt=Yr.byteOffset,Xr=e.Malloc(Float32Array,12),Kr=Xr.byteOffset,de=e.Malloc(Float32Array,4),N=de.byteOffset,Sr=e.Malloc(Float32Array,4),Fe=Sr.byteOffset,Vr=e.Malloc(Float32Array,3),St=Vr.byteOffset,Nr=e.Malloc(Float32Array,3),Vt=Nr.byteOffset,Et=e.Malloc(Int32Array,4),ze=Et.byteOffset,e.ColorSpace.SRGB=e.ColorSpace._MakeSRGB(),e.ColorSpace.DISPLAY_P3=e.ColorSpace._MakeDisplayP3(),e.ColorSpace.ADOBE_RGB=e.ColorSpace._MakeAdobeRGB(),e.GlyphRunFlags={IsWhiteSpace:e._GlyphRunFlags_isWhiteSpace},e.Path.MakeFromCmds=function(n){var u=l(n,"HEAPF32"),c=e.Path._MakeFromCmds(u,n.length);return s(u,n),c},e.Path.MakeFromVerbsPointsWeights=function(n,u,c){var y=l(n,"HEAPU8"),_=l(u,"HEAPF32"),C=l(c,"HEAPF32"),F=e.Path._MakeFromVerbsPointsWeights(y,n.length,_,u.length,C,c&&c.length||0);return s(y,n),s(_,u),s(C,c),F},e.Path.prototype.addArc=function(n,u,c){return n=v(n),this._addArc(n,u,c),this},e.Path.prototype.addCircle=function(n,u,c,y){return this._addCircle(n,u,c,!!y),this},e.Path.prototype.addOval=function(n,u,c){return c===void 0&&(c=1),n=v(n),this._addOval(n,!!u,c),this},e.Path.prototype.addPath=function(){var n=Array.prototype.slice.call(arguments),u=n[0],c=!1;if(typeof n[n.length-1]=="boolean"&&(c=n.pop()),n.length===1)this._addPath(u,1,0,0,0,1,0,0,0,1,c);else if(n.length===2)n=n[1],this._addPath(u,n[0],n[1],n[2],n[3],n[4],n[5],n[6]||0,n[7]||0,n[8]||1,c);else if(n.length===7||n.length===10)this._addPath(u,n[1],n[2],n[3],n[4],n[5],n[6],n[7]||0,n[8]||0,n[9]||1,c);else return null;return this},e.Path.prototype.addPoly=function(n,u){var c=l(n,"HEAPF32");return this._addPoly(c,n.length/2,u),s(c,n),this},e.Path.prototype.addRect=function(n,u){return n=v(n),this._addRect(n,!!u),this},e.Path.prototype.addRRect=function(n,u){return n=M(n),this._addRRect(n,!!u),this},e.Path.prototype.addVerbsPointsWeights=function(n,u,c){var y=l(n,"HEAPU8"),_=l(u,"HEAPF32"),C=l(c,"HEAPF32");this._addVerbsPointsWeights(y,n.length,_,u.length,C,c&&c.length||0),s(y,n),s(_,u),s(C,c)},e.Path.prototype.arc=function(n,u,c,y,_,C){return n=e.LTRBRect(n-c,u-c,n+c,u+c),_=(_-y)/Math.PI*180-360*!!C,C=new e.Path,C.addArc(n,y/Math.PI*180,_),this.addPath(C,!0),C.delete(),this},e.Path.prototype.arcToOval=function(n,u,c,y){return n=v(n),this._arcToOval(n,u,c,y),this},e.Path.prototype.arcToRotated=function(n,u,c,y,_,C,F){return this._arcToRotated(n,u,c,!!y,!!_,C,F),this},e.Path.prototype.arcToTangent=function(n,u,c,y,_){return this._arcToTangent(n,u,c,y,_),this},e.Path.prototype.close=function(){return this._close(),this},e.Path.prototype.conicTo=function(n,u,c,y,_){return this._conicTo(n,u,c,y,_),this},e.Path.prototype.computeTightBounds=function(n){this._computeTightBounds(N);var u=de.toTypedArray();return n?(n.set(u),n):u.slice()},e.Path.prototype.cubicTo=function(n,u,c,y,_,C){return this._cubicTo(n,u,c,y,_,C),this},e.Path.prototype.dash=function(n,u,c){return this._dash(n,u,c)?this:null},e.Path.prototype.getBounds=function(n){this._getBounds(N);var u=de.toTypedArray();return n?(n.set(u),n):u.slice()},e.Path.prototype.lineTo=function(n,u){return this._lineTo(n,u),this},e.Path.prototype.moveTo=function(n,u){return this._moveTo(n,u),this},e.Path.prototype.offset=function(n,u){return this._transform(1,0,n,0,1,u,0,0,1),this},e.Path.prototype.quadTo=function(n,u,c,y){return this._quadTo(n,u,c,y),this},e.Path.prototype.rArcTo=function(n,u,c,y,_,C,F){return this._rArcTo(n,u,c,y,_,C,F),this},e.Path.prototype.rConicTo=function(n,u,c,y,_){return this._rConicTo(n,u,c,y,_),this},e.Path.prototype.rCubicTo=function(n,u,c,y,_,C){return this._rCubicTo(n,u,c,y,_,C),this},e.Path.prototype.rLineTo=function(n,u){return this._rLineTo(n,u),this},e.Path.prototype.rMoveTo=function(n,u){return this._rMoveTo(n,u),this},e.Path.prototype.rQuadTo=function(n,u,c,y){return this._rQuadTo(n,u,c,y),this},e.Path.prototype.stroke=function(n){return n=n||{},n.width=n.width||1,n.miter_limit=n.miter_limit||4,n.cap=n.cap||e.StrokeCap.Butt,n.join=n.join||e.StrokeJoin.Miter,n.precision=n.precision||1,this._stroke(n)?this:null},e.Path.prototype.transform=function(){if(arguments.length===1){var n=arguments[0];this._transform(n[0],n[1],n[2],n[3],n[4],n[5],n[6]||0,n[7]||0,n[8]||1)}else if(arguments.length===6||arguments.length===9)n=arguments,this._transform(n[0],n[1],n[2],n[3],n[4],n[5],n[6]||0,n[7]||0,n[8]||1);else throw"transform expected to take 1 or 9 arguments. Got "+arguments.length;return this},e.Path.prototype.trim=function(n,u,c){return this._trim(n,u,!!c)?this:null},e.Image.prototype.encodeToBytes=function(n,u){var c=e.je();return n=n||e.ImageFormat.PNG,u=u||100,c?this._encodeToBytes(n,u,c):this._encodeToBytes(n,u)},e.Image.prototype.makeShaderCubic=function(n,u,c,y,_){return _=h(_),this._makeShaderCubic(n,u,c,y,_)},e.Image.prototype.makeShaderOptions=function(n,u,c,y,_){return _=h(_),this._makeShaderOptions(n,u,c,y,_)},e.Image.prototype.readPixels=function(n,u,c,y,_){var C=e.je();return a(this,n,u,c,y,_,C)},e.Canvas.prototype.clear=function(n){e.Fd(this.Ed),n=P(n),this._clear(n)},e.Canvas.prototype.clipRRect=function(n,u,c){e.Fd(this.Ed),n=M(n),this._clipRRect(n,u,c)},e.Canvas.prototype.clipRect=function(n,u,c){e.Fd(this.Ed),n=v(n),this._clipRect(n,u,c)},e.Canvas.prototype.concat=function(n){e.Fd(this.Ed),n=g(n),this._concat(n)},e.Canvas.prototype.drawArc=function(n,u,c,y,_){e.Fd(this.Ed),n=v(n),this._drawArc(n,u,c,y,_)},e.Canvas.prototype.drawAtlas=function(n,u,c,y,_,C,F){if(n&&y&&u&&c&&u.length===c.length){e.Fd(this.Ed),_||(_=e.BlendMode.SrcOver);var D=l(u,"HEAPF32"),I=l(c,"HEAPF32"),$=c.length/4,V=l(r(C),"HEAPU32");if(F&&"B"in F&&"C"in F)this._drawAtlasCubic(n,I,D,V,$,_,F.B,F.C,y);else{let d=e.FilterMode.Linear,A=e.MipmapMode.None;F&&(d=F.filter,"mipmap"in F&&(A=F.mipmap)),this._drawAtlasOptions(n,I,D,V,$,_,d,A,y)}s(D,u),s(I,c),s(V,C)}},e.Canvas.prototype.drawCircle=function(n,u,c,y){e.Fd(this.Ed),this._drawCircle(n,u,c,y)},e.Canvas.prototype.drawColor=function(n,u){e.Fd(this.Ed),n=P(n),u!==void 0?this._drawColor(n,u):this._drawColor(n)},e.Canvas.prototype.drawColorInt=function(n,u){e.Fd(this.Ed),this._drawColorInt(n,u||e.BlendMode.SrcOver)},e.Canvas.prototype.drawColorComponents=function(n,u,c,y,_){e.Fd(this.Ed),n=E(n,u,c,y),_!==void 0?this._drawColor(n,_):this._drawColor(n)},e.Canvas.prototype.drawDRRect=function(n,u,c){e.Fd(this.Ed),n=M(n,Nt),u=M(u,Kr),this._drawDRRect(n,u,c)},e.Canvas.prototype.drawImage=function(n,u,c,y){e.Fd(this.Ed),this._drawImage(n,u,c,y||null)},e.Canvas.prototype.drawImageCubic=function(n,u,c,y,_,C){e.Fd(this.Ed),this._drawImageCubic(n,u,c,y,_,C||null)},e.Canvas.prototype.drawImageOptions=function(n,u,c,y,_,C){e.Fd(this.Ed),this._drawImageOptions(n,u,c,y,_,C||null)},e.Canvas.prototype.drawImageNine=function(n,u,c,y,_){e.Fd(this.Ed),u=l(u,"HEAP32",ze),c=v(c),this._drawImageNine(n,u,c,y,_||null)},e.Canvas.prototype.drawImageRect=function(n,u,c,y,_){e.Fd(this.Ed),v(u,N),v(c,Fe),this._drawImageRect(n,N,Fe,y,!!_)},e.Canvas.prototype.drawImageRectCubic=function(n,u,c,y,_,C){e.Fd(this.Ed),v(u,N),v(c,Fe),this._drawImageRectCubic(n,N,Fe,y,_,C||null)},e.Canvas.prototype.drawImageRectOptions=function(n,u,c,y,_,C){e.Fd(this.Ed),v(u,N),v(c,Fe),this._drawImageRectOptions(n,N,Fe,y,_,C||null)},e.Canvas.prototype.drawLine=function(n,u,c,y,_){e.Fd(this.Ed),this._drawLine(n,u,c,y,_)},e.Canvas.prototype.drawOval=function(n,u){e.Fd(this.Ed),n=v(n),this._drawOval(n,u)},e.Canvas.prototype.drawPaint=function(n){e.Fd(this.Ed),this._drawPaint(n)},e.Canvas.prototype.drawParagraph=function(n,u,c){e.Fd(this.Ed),this._drawParagraph(n,u,c)},e.Canvas.prototype.drawPatch=function(n,u,c,y,_){if(24>n.length)throw"Need 12 cubic points";if(u&&4>u.length)throw"Need 4 colors";if(c&&8>c.length)throw"Need 4 shader coordinates";e.Fd(this.Ed);let C=l(n,"HEAPF32"),F=u?l(r(u),"HEAPU32"):L,D=c?l(c,"HEAPF32"):L;y||(y=e.BlendMode.Modulate),this._drawPatch(C,F,D,y,_),s(D,c),s(F,u),s(C,n)},e.Canvas.prototype.drawPath=function(n,u){e.Fd(this.Ed),this._drawPath(n,u)},e.Canvas.prototype.drawPicture=function(n){e.Fd(this.Ed),this._drawPicture(n)},e.Canvas.prototype.drawPoints=function(n,u,c){e.Fd(this.Ed);var y=l(u,"HEAPF32");this._drawPoints(n,y,u.length/2,c),s(y,u)},e.Canvas.prototype.drawRRect=function(n,u){e.Fd(this.Ed),n=M(n),this._drawRRect(n,u)},e.Canvas.prototype.drawRect=function(n,u){e.Fd(this.Ed),n=v(n),this._drawRect(n,u)},e.Canvas.prototype.drawRect4f=function(n,u,c,y,_){e.Fd(this.Ed),this._drawRect4f(n,u,c,y,_)},e.Canvas.prototype.drawShadow=function(n,u,c,y,_,C,F){e.Fd(this.Ed);var D=l(_,"HEAPF32"),I=l(C,"HEAPF32");u=l(u,"HEAPF32",St),c=l(c,"HEAPF32",Vt),this._drawShadow(n,u,c,y,D,I,F),s(D,_),s(I,C)},e.getShadowLocalBounds=function(n,u,c,y,_,C,F){return n=h(n),c=l(c,"HEAPF32",St),y=l(y,"HEAPF32",Vt),this._getShadowLocalBounds(n,u,c,y,_,C,N)?(u=de.toTypedArray(),F?(F.set(u),F):u.slice()):null},e.Canvas.prototype.drawTextBlob=function(n,u,c,y){e.Fd(this.Ed),this._drawTextBlob(n,u,c,y)},e.Canvas.prototype.drawVertices=function(n,u,c){e.Fd(this.Ed),this._drawVertices(n,u,c)},e.Canvas.prototype.getDeviceClipBounds=function(n){this._getDeviceClipBounds(ze);var u=Et.toTypedArray();return n?n.set(u):n=u.slice(),n},e.Canvas.prototype.getLocalToDevice=function(){this._getLocalToDevice(J);for(var n=J,u=Array(16),c=0;16>c;c++)u[c]=e.HEAPF32[n/4+c];return u},e.Canvas.prototype.getTotalMatrix=function(){this._getTotalMatrix(x);for(var n=Array(9),u=0;9>u;u++)n[u]=e.HEAPF32[x/4+u];return n},e.Canvas.prototype.makeSurface=function(n){return n=this._makeSurface(n),n.Ed=this.Ed,n},e.Canvas.prototype.readPixels=function(n,u,c,y,_){return e.Fd(this.Ed),a(this,n,u,c,y,_)},e.Canvas.prototype.saveLayer=function(n,u,c,y){return u=v(u),this._saveLayer(n||null,u,c||null,y||0)},e.Canvas.prototype.writePixels=function(n,u,c,y,_,C,F,D){if(n.byteLength%(u*c))throw"pixels length must be a multiple of the srcWidth * srcHeight";e.Fd(this.Ed);var I=n.byteLength/(u*c);C=C||e.AlphaType.Unpremul,F=F||e.ColorType.RGBA_8888,D=D||e.ColorSpace.SRGB;var $=I*u;return I=l(n,"HEAPU8"),u=this._writePixels({width:u,height:c,colorType:F,alphaType:C,colorSpace:D},I,$,y,_),s(I,n),u},e.ColorFilter.MakeBlend=function(n,u,c){return n=P(n),c=c||e.ColorSpace.SRGB,e.ColorFilter._MakeBlend(n,u,c)},e.ColorFilter.MakeMatrix=function(n){if(!n||n.length!==20)throw"invalid color matrix";var u=l(n,"HEAPF32"),c=e.ColorFilter._makeMatrix(u);return s(u,n),c},e.ContourMeasure.prototype.getPosTan=function(n,u){return this._getPosTan(n,N),n=de.toTypedArray(),u?(u.set(n),u):n.slice()},e.ImageFilter.prototype.getOutputBounds=function(n,u,c){return n=v(n,N),u=h(u),this._getOutputBounds(n,u,ze),u=Et.toTypedArray(),c?(c.set(u),c):u.slice()},e.ImageFilter.MakeDropShadow=function(n,u,c,y,_,C){return _=P(_,_e),e.ImageFilter._MakeDropShadow(n,u,c,y,_,C)},e.ImageFilter.MakeDropShadowOnly=function(n,u,c,y,_,C){return _=P(_,_e),e.ImageFilter._MakeDropShadowOnly(n,u,c,y,_,C)},e.ImageFilter.MakeImage=function(n,u,c,y){if(c=v(c,N),y=v(y,Fe),"B"in u&&"C"in u)return e.ImageFilter._MakeImageCubic(n,u.B,u.C,c,y);let _=u.filter,C=e.MipmapMode.None;return"mipmap"in u&&(C=u.mipmap),e.ImageFilter._MakeImageOptions(n,_,C,c,y)},e.ImageFilter.MakeMatrixTransform=function(n,u,c){if(n=h(n),"B"in u&&"C"in u)return e.ImageFilter._MakeMatrixTransformCubic(n,u.B,u.C,c);let y=u.filter,_=e.MipmapMode.None;return"mipmap"in u&&(_=u.mipmap),e.ImageFilter._MakeMatrixTransformOptions(n,y,_,c)},e.Paint.prototype.getColor=function(){return this._getColor(_e),T(_e)},e.Paint.prototype.setColor=function(n,u){u=u||null,n=P(n),this._setColor(n,u)},e.Paint.prototype.setColorComponents=function(n,u,c,y,_){_=_||null,n=E(n,u,c,y),this._setColor(n,_)},e.Path.prototype.getPoint=function(n,u){return this._getPoint(n,N),n=de.toTypedArray(),u?(u[0]=n[0],u[1]=n[1],u):n.slice(0,2)},e.Picture.prototype.makeShader=function(n,u,c,y,_){return y=h(y),_=v(_),this._makeShader(n,u,c,y,_)},e.Picture.prototype.cullRect=function(n){this._cullRect(N);var u=de.toTypedArray();return n?(n.set(u),n):u.slice()},e.PictureRecorder.prototype.beginRecording=function(n,u){return n=v(n),this._beginRecording(n,!!u)},e.Surface.prototype.getCanvas=function(){var n=this._getCanvas();return n.Ed=this.Ed,n},e.Surface.prototype.makeImageSnapshot=function(n){return e.Fd(this.Ed),n=l(n,"HEAP32",ze),this._makeImageSnapshot(n)},e.Surface.prototype.makeSurface=function(n){return e.Fd(this.Ed),n=this._makeSurface(n),n.Ed=this.Ed,n},e.Surface.prototype.Oe=function(n,u){return this.ce||(this.ce=this.getCanvas()),requestAnimationFrame(function(){e.Fd(this.Ed),n(this.ce),this.flush(u)}.bind(this))},e.Surface.prototype.requestAnimationFrame||(e.Surface.prototype.requestAnimationFrame=e.Surface.prototype.Oe),e.Surface.prototype.Le=function(n,u){this.ce||(this.ce=this.getCanvas()),requestAnimationFrame(function(){e.Fd(this.Ed),n(this.ce),this.flush(u),this.dispose()}.bind(this))},e.Surface.prototype.drawOnce||(e.Surface.prototype.drawOnce=e.Surface.prototype.Le),e.PathEffect.MakeDash=function(n,u){if(u||(u=0),!n.length||n.length%2===1)throw"Intervals array must have even length";var c=l(n,"HEAPF32");return u=e.PathEffect._MakeDash(c,n.length,u),s(c,n),u},e.PathEffect.MakeLine2D=function(n,u){return u=h(u),e.PathEffect._MakeLine2D(n,u)},e.PathEffect.MakePath2D=function(n,u){return n=h(n),e.PathEffect._MakePath2D(n,u)},e.Shader.MakeColor=function(n,u){return u=u||null,n=P(n),e.Shader._MakeColor(n,u)},e.Shader.Blend=e.Shader.MakeBlend,e.Shader.Color=e.Shader.MakeColor,e.Shader.MakeLinearGradient=function(n,u,c,y,_,C,F,D){D=D||null;var I=f(c),$=l(y,"HEAPF32");F=F||0,C=h(C);var V=de.toTypedArray();return V.set(n),V.set(u,2),n=e.Shader._MakeLinearGradient(N,I.Nd,I.colorType,$,I.count,_,F,C,D),s(I.Nd,c),y&&s($,y),n},e.Shader.MakeRadialGradient=function(n,u,c,y,_,C,F,D){D=D||null;var I=f(c),$=l(y,"HEAPF32");return F=F||0,C=h(C),n=e.Shader._MakeRadialGradient(n[0],n[1],u,I.Nd,I.colorType,$,I.count,_,F,C,D),s(I.Nd,c),y&&s($,y),n},e.Shader.MakeSweepGradient=function(n,u,c,y,_,C,F,D,I,$){$=$||null;var V=f(c),d=l(y,"HEAPF32");return F=F||0,D=D||0,I=I||360,C=h(C),n=e.Shader._MakeSweepGradient(n,u,V.Nd,V.colorType,d,V.count,_,D,I,F,C,$),s(V.Nd,c),y&&s(d,y),n},e.Shader.MakeTwoPointConicalGradient=function(n,u,c,y,_,C,F,D,I,$){$=$||null;var V=f(_),d=l(C,"HEAPF32");I=I||0,D=h(D);var A=de.toTypedArray();return A.set(n),A.set(c,2),n=e.Shader._MakeTwoPointConicalGradient(N,u,y,V.Nd,V.colorType,d,V.count,F,I,D,$),s(V.Nd,_),C&&s(d,C),n},e.Vertices.prototype.bounds=function(n){this._bounds(N);var u=de.toTypedArray();return n?(n.set(u),n):u.slice()},e.Id&&e.Id.forEach(function(n){n()})},e.computeTonalColors=function(a){var n=l(a.ambient,"HEAPF32"),u=l(a.spot,"HEAPF32");this._computeTonalColors(n,u);var c={ambient:T(n),spot:T(u)};return s(n,a.ambient),s(u,a.spot),c},e.LTRBRect=function(a,n,u,c){return Float32Array.of(a,n,u,c)},e.XYWHRect=function(a,n,u,c){return Float32Array.of(a,n,a+u,n+c)},e.LTRBiRect=function(a,n,u,c){return Int32Array.of(a,n,u,c)},e.XYWHiRect=function(a,n,u,c){return Int32Array.of(a,n,a+u,n+c)},e.RRectXY=function(a,n,u){return Float32Array.of(a[0],a[1],a[2],a[3],n,u,n,u,n,u,n,u)},e.MakeAnimatedImageFromEncoded=function(a){a=new Uint8Array(a);var n=e._malloc(a.byteLength);return e.HEAPU8.set(a,n),(a=e._decodeAnimatedImage(n,a.byteLength))?a:null},e.MakeImageFromEncoded=function(a){a=new Uint8Array(a);var n=e._malloc(a.byteLength);return e.HEAPU8.set(a,n),(a=e._decodeImage(n,a.byteLength))?a:null};var qe=null;e.MakeImageFromCanvasImageSource=function(a){var n=a.width,u=a.height;qe||(qe=document.createElement("canvas")),qe.width=n,qe.height=u;var c=qe.getContext("2d",{willReadFrequently:!0});return c.drawImage(a,0,0),a=c.getImageData(0,0,n,u),e.MakeImage({width:n,height:u,alphaType:e.AlphaType.Unpremul,colorType:e.ColorType.RGBA_8888,colorSpace:e.ColorSpace.SRGB},a.data,4*n)},e.MakeImage=function(a,n,u){var c=e._malloc(n.length);return e.HEAPU8.set(n,c),e._MakeImage(a,c,n.length,u)},e.MakeVertices=function(a,n,u,c,y,_){var C=y&&y.length||0,F=0;return u&&u.length&&(F|=1),c&&c.length&&(F|=2),_===void 0||_||(F|=4),a=new e._VerticesBuilder(a,n.length/2,C,F),l(n,"HEAPF32",a.positions()),a.texCoords()&&l(u,"HEAPF32",a.texCoords()),a.colors()&&l(r(c),"HEAPU32",a.colors()),a.indices()&&l(y,"HEAPU16",a.indices()),a.detach()},function(a){a.Id=a.Id||[],a.Id.push(function(){function n(d){return d&&(d.dir=d.dir===0?a.TextDirection.RTL:a.TextDirection.LTR),d}function u(d){if(!d||!d.length)return[];for(var A=[],U=0;U<d.length;U+=5){var X=a.LTRBRect(d[U],d[U+1],d[U+2],d[U+3]),Ce=a.TextDirection.LTR;d[U+4]===0&&(Ce=a.TextDirection.RTL),A.push({rect:X,dir:Ce})}return a._free(d.byteOffset),A}function c(d){return d=d||{},d.weight===void 0&&(d.weight=a.FontWeight.Normal),d.width=d.width||a.FontWidth.Normal,d.slant=d.slant||a.FontSlant.Upright,d}function y(d){if(!d||!d.length)return L;for(var A=[],U=0;U<d.length;U++){var X=_(d[U]);A.push(X)}return l(A,"HEAPU32")}function _(d){if(D[d])return D[d];var A=le(d)+1,U=a._malloc(A);return se(d,G,U,A),D[d]=U}function C(d){if(d._colorPtr=P(d.color),d._foregroundColorPtr=L,d._backgroundColorPtr=L,d._decorationColorPtr=L,d.foregroundColor&&(d._foregroundColorPtr=P(d.foregroundColor,I)),d.backgroundColor&&(d._backgroundColorPtr=P(d.backgroundColor,$)),d.decorationColor&&(d._decorationColorPtr=P(d.decorationColor,V)),Array.isArray(d.fontFamilies)&&d.fontFamilies.length?(d._fontFamiliesPtr=y(d.fontFamilies),d._fontFamiliesLen=d.fontFamilies.length):(d._fontFamiliesPtr=L,d._fontFamiliesLen=0),d.locale){var A=d.locale;d._localePtr=_(A),d._localeLen=le(A)+1}else d._localePtr=L,d._localeLen=0;if(Array.isArray(d.shadows)&&d.shadows.length){A=d.shadows;var U=A.map(function(he){return he.color||a.BLACK}),X=A.map(function(he){return he.blurRadius||0});d._shadowLen=A.length;for(var Ce=a._malloc(8*A.length),Yt=Ce/4,Xt=0;Xt<A.length;Xt++){var Jr=A[Xt].offset||[0,0];a.HEAPF32[Yt]=Jr[0],a.HEAPF32[Yt+1]=Jr[1],Yt+=2}d._shadowColorsPtr=f(U).Nd,d._shadowOffsetsPtr=Ce,d._shadowBlurRadiiPtr=l(X,"HEAPF32")}else d._shadowLen=0,d._shadowColorsPtr=L,d._shadowOffsetsPtr=L,d._shadowBlurRadiiPtr=L;Array.isArray(d.fontFeatures)&&d.fontFeatures.length?(A=d.fontFeatures,U=A.map(function(he){return he.name}),X=A.map(function(he){return he.value}),d._fontFeatureLen=A.length,d._fontFeatureNamesPtr=y(U),d._fontFeatureValuesPtr=l(X,"HEAPU32")):(d._fontFeatureLen=0,d._fontFeatureNamesPtr=L,d._fontFeatureValuesPtr=L),Array.isArray(d.fontVariations)&&d.fontVariations.length?(A=d.fontVariations,U=A.map(function(he){return he.axis}),X=A.map(function(he){return he.value}),d._fontVariationLen=A.length,d._fontVariationAxesPtr=y(U),d._fontVariationValuesPtr=l(X,"HEAPF32")):(d._fontVariationLen=0,d._fontVariationAxesPtr=L,d._fontVariationValuesPtr=L)}function F(d){a._free(d._fontFamiliesPtr),a._free(d._shadowColorsPtr),a._free(d._shadowOffsetsPtr),a._free(d._shadowBlurRadiiPtr),a._free(d._fontFeatureNamesPtr),a._free(d._fontFeatureValuesPtr),a._free(d._fontVariationAxesPtr),a._free(d._fontVariationValuesPtr)}a.Paragraph.prototype.getRectsForRange=function(d,A,U,X){return d=this._getRectsForRange(d,A,U,X),u(d)},a.Paragraph.prototype.getRectsForPlaceholders=function(){var d=this._getRectsForPlaceholders();return u(d)},a.Paragraph.prototype.getGlyphInfoAt=function(d){return n(this._getGlyphInfoAt(d))},a.Paragraph.prototype.getClosestGlyphInfoAtCoordinate=function(d,A){return n(this._getClosestGlyphInfoAtCoordinate(d,A))},a.TypefaceFontProvider.prototype.registerFont=function(d,A){if(d=a.Typeface.MakeFreeTypeFaceFromData(d),!d)return null;A=_(A),this._registerFont(d,A)},a.ParagraphStyle=function(d){if(d.disableHinting=d.disableHinting||!1,d.ellipsis){var A=d.ellipsis;d._ellipsisPtr=_(A),d._ellipsisLen=le(A)+1}else d._ellipsisPtr=L,d._ellipsisLen=0;return d.heightMultiplier==null&&(d.heightMultiplier=-1),d.maxLines=d.maxLines||0,d.replaceTabCharacters=d.replaceTabCharacters||!1,A=(A=d.strutStyle)||{},A.strutEnabled=A.strutEnabled||!1,A.strutEnabled&&Array.isArray(A.fontFamilies)&&A.fontFamilies.length?(A._fontFamiliesPtr=y(A.fontFamilies),A._fontFamiliesLen=A.fontFamilies.length):(A._fontFamiliesPtr=L,A._fontFamiliesLen=0),A.fontStyle=c(A.fontStyle),A.fontSize==null&&(A.fontSize=-1),A.heightMultiplier==null&&(A.heightMultiplier=-1),A.halfLeading=A.halfLeading||!1,A.leading=A.leading||0,A.forceStrutHeight=A.forceStrutHeight||!1,d.strutStyle=A,d.textAlign=d.textAlign||a.TextAlign.Start,d.textDirection=d.textDirection||a.TextDirection.LTR,d.textHeightBehavior=d.textHeightBehavior||a.TextHeightBehavior.All,d.textStyle=a.TextStyle(d.textStyle),d.applyRoundingHack=d.applyRoundingHack!==!1,d},a.TextStyle=function(d){return d.color||(d.color=a.BLACK),d.decoration=d.decoration||0,d.decorationThickness=d.decorationThickness||0,d.decorationStyle=d.decorationStyle||a.DecorationStyle.Solid,d.textBaseline=d.textBaseline||a.TextBaseline.Alphabetic,d.fontSize==null&&(d.fontSize=-1),d.letterSpacing=d.letterSpacing||0,d.wordSpacing=d.wordSpacing||0,d.heightMultiplier==null&&(d.heightMultiplier=-1),d.halfLeading=d.halfLeading||!1,d.fontStyle=c(d.fontStyle),d};var D={},I=a._malloc(16),$=a._malloc(16),V=a._malloc(16);a.ParagraphBuilder.Make=function(d,A){return C(d.textStyle),A=a.ParagraphBuilder._Make(d,A),F(d.textStyle),A},a.ParagraphBuilder.MakeFromFontProvider=function(d,A){return C(d.textStyle),A=a.ParagraphBuilder._MakeFromFontProvider(d,A),F(d.textStyle),A},a.ParagraphBuilder.MakeFromFontCollection=function(d,A){return C(d.textStyle),A=a.ParagraphBuilder._MakeFromFontCollection(d,A),F(d.textStyle),A},a.ParagraphBuilder.ShapeText=function(d,A,U){let X=0;for(let Ce of A)X+=Ce.length;if(X!==d.length)throw"Accumulated block lengths must equal text.length";return a.ParagraphBuilder._ShapeText(d,A,U)},a.ParagraphBuilder.prototype.pushStyle=function(d){C(d),this._pushStyle(d),F(d)},a.ParagraphBuilder.prototype.pushPaintStyle=function(d,A,U){C(d),this._pushPaintStyle(d,A,U),F(d)},a.ParagraphBuilder.prototype.addPlaceholder=function(d,A,U,X,Ce){U=U||a.PlaceholderAlignment.Baseline,X=X||a.TextBaseline.Alphabetic,this._addPlaceholder(d||0,A||0,U,X,Ce||0)},a.ParagraphBuilder.prototype.setWordsUtf8=function(d){var A=l(d,"HEAPU32");this._setWordsUtf8(A,d&&d.length||0),s(A,d)},a.ParagraphBuilder.prototype.setWordsUtf16=function(d){var A=l(d,"HEAPU32");this._setWordsUtf16(A,d&&d.length||0),s(A,d)},a.ParagraphBuilder.prototype.setGraphemeBreaksUtf8=function(d){var A=l(d,"HEAPU32");this._setGraphemeBreaksUtf8(A,d&&d.length||0),s(A,d)},a.ParagraphBuilder.prototype.setGraphemeBreaksUtf16=function(d){var A=l(d,"HEAPU32");this._setGraphemeBreaksUtf16(A,d&&d.length||0),s(A,d)},a.ParagraphBuilder.prototype.setLineBreaksUtf8=function(d){var A=l(d,"HEAPU32");this._setLineBreaksUtf8(A,d&&d.length||0),s(A,d)},a.ParagraphBuilder.prototype.setLineBreaksUtf16=function(d){var A=l(d,"HEAPU32");this._setLineBreaksUtf16(A,d&&d.length||0),s(A,d)}})}(m),e.Id=e.Id||[],e.Id.push(function(){e.Path.prototype.op=function(a,n){return this._op(a,n)?this:null},e.Path.prototype.simplify=function(){return this._simplify()?this:null}}),e.Id=e.Id||[],e.Id.push(function(){e.Canvas.prototype.drawText=function(a,n,u,c,y){var _=le(a),C=e._malloc(_+1);se(a,G,C,_+1),this._drawSimpleText(C,_,n,u,y,c),e._free(C)},e.Canvas.prototype.drawGlyphs=function(a,n,u,c,y,_){if(!(2*a.length<=n.length))throw"Not enough positions for the array of gyphs";e.Fd(this.Ed);let C=l(a,"HEAPU16"),F=l(n,"HEAPF32");this._drawGlyphs(a.length,C,F,u,c,y,_),s(F,n),s(C,a)},e.Font.prototype.getGlyphBounds=function(a,n,u){var c=l(a,"HEAPU16"),y=e._malloc(16*a.length);return this._getGlyphWidthBounds(c,a.length,L,y,n||null),n=new Float32Array(e.HEAPU8.buffer,y,4*a.length),s(c,a),u?(u.set(n),e._free(y),u):(a=Float32Array.from(n),e._free(y),a)},e.Font.prototype.getGlyphIDs=function(a,n,u){n||(n=a.length);var c=le(a)+1,y=e._malloc(c);return se(a,G,y,c),a=e._malloc(2*n),n=this._getGlyphIDs(y,c-1,n,a),e._free(y),0>n?(e._free(a),null):(y=new Uint16Array(e.HEAPU8.buffer,a,n),u?(u.set(y),e._free(a),u):(u=Uint16Array.from(y),e._free(a),u))},e.Font.prototype.getGlyphIntercepts=function(a,n,u,c){var y=l(a,"HEAPU16"),_=l(n,"HEAPF32");return this._getGlyphIntercepts(y,a.length,!(a&&a._ck),_,n.length,!(n&&n._ck),u,c)},e.Font.prototype.getGlyphWidths=function(a,n,u){var c=l(a,"HEAPU16"),y=e._malloc(4*a.length);return this._getGlyphWidthBounds(c,a.length,y,L,n||null),n=new Float32Array(e.HEAPU8.buffer,y,a.length),s(c,a),u?(u.set(n),e._free(y),u):(a=Float32Array.from(n),e._free(y),a)},e.FontMgr.FromData=function(){if(!arguments.length)return null;var a=arguments;if(a.length===1&&Array.isArray(a[0])&&(a=arguments[0]),!a.length)return null;for(var n=[],u=[],c=0;c<a.length;c++){var y=new Uint8Array(a[c]),_=l(y,"HEAPU8");n.push(_),u.push(y.byteLength)}return n=l(n,"HEAPU32"),u=l(u,"HEAPU32"),a=e.FontMgr._fromData(n,u,a.length),e._free(n),e._free(u),a},e.Typeface.MakeFreeTypeFaceFromData=function(a){a=new Uint8Array(a);var n=l(a,"HEAPU8");return(a=e.Typeface._MakeFreeTypeFaceFromData(n,a.byteLength))?a:null},e.Typeface.prototype.getGlyphIDs=function(a,n,u){n||(n=a.length);var c=le(a)+1,y=e._malloc(c);return se(a,G,y,c),a=e._malloc(2*n),n=this._getGlyphIDs(y,c-1,n,a),e._free(y),0>n?(e._free(a),null):(y=new Uint16Array(e.HEAPU8.buffer,a,n),u?(u.set(y),e._free(a),u):(u=Uint16Array.from(y),e._free(a),u))},e.TextBlob.MakeOnPath=function(a,n,u,c){if(a&&a.length&&n&&n.countPoints()){if(n.countPoints()===1)return this.MakeFromText(a,u);c||(c=0);var y=u.getGlyphIDs(a);y=u.getGlyphWidths(y);var _=[];n=new e.ContourMeasureIter(n,!1,1);for(var C=n.next(),F=new Float32Array(4),D=0;D<a.length&&C;D++){var I=y[D];if(c+=I/2,c>C.length()){if(C.delete(),C=n.next(),!C){a=a.substring(0,D);break}c=I/2}C.getPosTan(c,F);var $=F[2],V=F[3];_.push($,V,F[0]-I/2*$,F[1]-I/2*V),c+=I/2}return a=this.MakeFromRSXform(a,_,u),C&&C.delete(),n.delete(),a}},e.TextBlob.MakeFromRSXform=function(a,n,u){var c=le(a)+1,y=e._malloc(c);return se(a,G,y,c),a=l(n,"HEAPF32"),u=e.TextBlob._MakeFromRSXform(y,c-1,a,u),e._free(y),u||null},e.TextBlob.MakeFromRSXformGlyphs=function(a,n,u){var c=l(a,"HEAPU16");return n=l(n,"HEAPF32"),u=e.TextBlob._MakeFromRSXformGlyphs(c,2*a.length,n,u),s(c,a),u||null},e.TextBlob.MakeFromGlyphs=function(a,n){var u=l(a,"HEAPU16");return n=e.TextBlob._MakeFromGlyphs(u,2*a.length,n),s(u,a),n||null},e.TextBlob.MakeFromText=function(a,n){var u=le(a)+1,c=e._malloc(u);return se(a,G,c,u),a=e.TextBlob._MakeFromText(c,u-1,n),e._free(c),a||null},e.MallocGlyphIDs=function(a){return e.Malloc(Uint16Array,a)}}),e.Id=e.Id||[],e.Id.push(function(){e.MakePicture=function(a){a=new Uint8Array(a);var n=e._malloc(a.byteLength);return e.HEAPU8.set(a,n),(a=e._MakePicture(n,a.byteLength))?a:null}}),e.Id=e.Id||[],e.Id.push(function(){e.RuntimeEffect.Make=function(a,n){return e.RuntimeEffect._Make(a,{onError:n||function(u){console.log("RuntimeEffect error",u)}})},e.RuntimeEffect.MakeForBlender=function(a,n){return e.RuntimeEffect._MakeForBlender(a,{onError:n||function(u){console.log("RuntimeEffect error",u)}})},e.RuntimeEffect.prototype.makeShader=function(a,n){var u=!a._ck,c=l(a,"HEAPF32");return n=h(n),this._makeShader(c,4*a.length,u,n)},e.RuntimeEffect.prototype.makeShaderWithChildren=function(a,n,u){var c=!a._ck,y=l(a,"HEAPF32");u=h(u);for(var _=[],C=0;C<n.length;C++)_.push(n[C].Dd.Hd);return n=l(_,"HEAPU32"),this._makeShaderWithChildren(y,4*a.length,c,n,_.length,u)},e.RuntimeEffect.prototype.makeBlender=function(a){var n=!a._ck,u=l(a,"HEAPF32");return this._makeBlender(u,4*a.length,n)}})}(m);var Qt=Object.assign({},m),wt="./this.program",Zt=typeof window=="object",Oe=typeof importScripts=="function",zt=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string",z="",Tt,tt,rt;if(zt){var qt=Qr("fs"),Ft=Qr("path");z=Oe?Ft.dirname(z)+"/":__dirname+"/",Tt=(e,t)=>(e=e.startsWith("file://")?new URL(e):Ft.normalize(e),qt.readFileSync(e,t?void 0:"utf8")),rt=e=>(e=Tt(e,!0),e.buffer||(e=new Uint8Array(e)),e),tt=(e,t,r,i=!0)=>{e=e.startsWith("file://")?new URL(e):Ft.normalize(e),qt.readFile(e,i?void 0:"utf8",(o,s)=>{o?r(o):t(i?s.buffer:s)})},!m.thisProgram&&1<process.argv.length&&(wt=process.argv[1].replace(/\\/g,"/")),process.argv.slice(2),m.inspect=()=>"[Emscripten Module object]"}else(Zt||Oe)&&(Oe?z=self.location.href:typeof document<"u"&&document.currentScript&&(z=document.currentScript.src),ae&&(z=ae),z.indexOf("blob:")!==0?z=z.substr(0,z.replace(/[?#].*/,"").lastIndexOf("/")+1):z="",Tt=e=>{var t=new XMLHttpRequest;return t.open("GET",e,!1),t.send(null),t.responseText},Oe&&(rt=e=>{var t=new XMLHttpRequest;return t.open("GET",e,!1),t.responseType="arraybuffer",t.send(null),new Uint8Array(t.response)}),tt=(e,t,r)=>{var i=new XMLHttpRequest;i.open("GET",e,!0),i.responseType="arraybuffer",i.onload=()=>{i.status==200||i.status==0&&i.response?t(i.response):r()},i.onerror=r,i.send(null)});var qr=m.print||console.log.bind(console),Ae=m.printErr||console.error.bind(console);Object.assign(m,Qt),Qt=null,m.thisProgram&&(wt=m.thisProgram);var je;m.wasmBinary&&(je=m.wasmBinary);var Qn=m.noExitRuntime||!0;typeof WebAssembly!="object"&&Rt("no native wasm support detected");var nt,b,er=!1,pe,G,Ee,Be,w,O,R,tr;function rr(){var e=nt.buffer;m.HEAP8=pe=new Int8Array(e),m.HEAP16=Ee=new Int16Array(e),m.HEAP32=w=new Int32Array(e),m.HEAPU8=G=new Uint8Array(e),m.HEAPU16=Be=new Uint16Array(e),m.HEAPU32=O=new Uint32Array(e),m.HEAPF32=R=new Float32Array(e),m.HEAPF64=tr=new Float64Array(e)}var Q,nr=[],ir=[],or=[];function en(){var e=m.preRun.shift();nr.unshift(e)}var Me=0,Mt=null,We=null;function Rt(e){throw m.onAbort&&m.onAbort(e),e="Aborted("+e+")",Ae(e),er=!0,e=new WebAssembly.RuntimeError(e+". Build with -sASSERTIONS for more info."),et(e),e}function ar(e){return e.startsWith("data:application/octet-stream;base64,")}var Ge;if(Ge="canvaskit.wasm",!ar(Ge)){var ur=Ge;Ge=m.locateFile?m.locateFile(ur,z):z+ur}function sr(e){if(e==Ge&&je)return new Uint8Array(je);if(rt)return rt(e);throw"both async and sync fetching of the wasm failed"}function tn(e){if(!je&&(Zt||Oe)){if(typeof fetch=="function"&&!e.startsWith("file://"))return fetch(e,{credentials:"same-origin"}).then(t=>{if(!t.ok)throw"failed to load wasm binary file at '"+e+"'";return t.arrayBuffer()}).catch(()=>sr(e));if(tt)return new Promise((t,r)=>{tt(e,i=>t(new Uint8Array(i)),r)})}return Promise.resolve().then(()=>sr(e))}function lr(e,t,r){return tn(e).then(i=>WebAssembly.instantiate(i,t)).then(i=>i).then(r,i=>{Ae("failed to asynchronously prepare wasm: "+i),Rt(i)})}function rn(e,t){var r=Ge;return je||typeof WebAssembly.instantiateStreaming!="function"||ar(r)||r.startsWith("file://")||zt||typeof fetch!="function"?lr(r,e,t):fetch(r,{credentials:"same-origin"}).then(i=>WebAssembly.instantiateStreaming(i,e).then(t,function(o){return Ae("wasm streaming compile failed: "+o),Ae("falling back to ArrayBuffer instantiation"),lr(r,e,t)}))}var xt=e=>{for(;0<e.length;)e.shift()(m)},fr=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0,Re=(e,t,r)=>{var i=t+r;for(r=t;e[r]&&!(r>=i);)++r;if(16<r-t&&e.buffer&&fr)return fr.decode(e.subarray(t,r));for(i="";t<r;){var o=e[t++];if(o&128){var s=e[t++]&63;if((o&224)==192)i+=String.fromCharCode((o&31)<<6|s);else{var l=e[t++]&63;o=(o&240)==224?(o&15)<<12|s<<6|l:(o&7)<<18|s<<12|l<<6|e[t++]&63,65536>o?i+=String.fromCharCode(o):(o-=65536,i+=String.fromCharCode(55296|o>>10,56320|o&1023))}}else i+=String.fromCharCode(o)}return i},it={};function It(e){for(;e.length;){var t=e.pop();e.pop()(t)}}function $e(e){return this.fromWireType(w[e>>2])}var Le={},xe={},ot={},cr=void 0;function at(e){throw new cr(e)}function ue(e,t,r){function i(f){f=r(f),f.length!==e.length&&at("Mismatched type converter count");for(var h=0;h<e.length;++h)ye(e[h],f[h])}e.forEach(function(f){ot[f]=t});var o=Array(t.length),s=[],l=0;t.forEach((f,h)=>{xe.hasOwnProperty(f)?o[h]=xe[f]:(s.push(f),Le.hasOwnProperty(f)||(Le[f]=[]),Le[f].push(()=>{o[h]=xe[f],++l,l===s.length&&i(o)}))}),s.length===0&&i(o)}function ut(e){switch(e){case 1:return 0;case 2:return 1;case 4:return 2;case 8:return 3;default:throw new TypeError(`Unknown type size: ${e}`)}}var dr=void 0;function S(e){for(var t="";G[e];)t+=dr[G[e++]];return t}var be=void 0;function k(e){throw new be(e)}function nn(e,t,r={}){var i=t.name;if(e||k(`type "${i}" must have a positive integer typeid pointer`),xe.hasOwnProperty(e)){if(r.af)return;k(`Cannot register type '${i}' twice`)}xe[e]=t,delete ot[e],Le.hasOwnProperty(e)&&(t=Le[e],delete Le[e],t.forEach(o=>o()))}function ye(e,t,r={}){if(!("argPackAdvance"in t))throw new TypeError("registerType registeredInstance requires argPackAdvance");nn(e,t,r)}function Dt(e){k(e.Dd.Jd.Gd.name+" instance already deleted")}var Bt=!1;function hr(){}function pr(e){--e.count.value,e.count.value===0&&(e.Ld?e.Pd.Td(e.Ld):e.Jd.Gd.Td(e.Hd))}function yr(e,t,r){return t===r?e:r.Md===void 0?null:(e=yr(e,t,r.Md),e===null?null:r.Te(e))}var vr={},Se=[];function Gt(){for(;Se.length;){var e=Se.pop();e.Dd.$d=!1,e.delete()}}var Ve=void 0,Ne={};function on(e,t){for(t===void 0&&k("ptr should not be undefined");e.Md;)t=e.ge(t),e=e.Md;return Ne[t]}function st(e,t){return t.Jd&&t.Hd||at("makeClassHandle requires ptr and ptrType"),!!t.Pd!=!!t.Ld&&at("Both smartPtrType and smartPtr must be specified"),t.count={value:1},Ye(Object.create(e,{Dd:{value:t}}))}function Ye(e){return typeof FinalizationRegistry>"u"?(Ye=t=>t,e):(Bt=new FinalizationRegistry(t=>{pr(t.Dd)}),Ye=t=>{var r=t.Dd;return r.Ld&&Bt.register(t,{Dd:r},t),t},hr=t=>{Bt.unregister(t)},Ye(e))}function we(){}function mr(e){if(e===void 0)return"_unknown";e=e.replace(/[^a-zA-Z0-9_]/g,"$");var t=e.charCodeAt(0);return 48<=t&&57>=t?`_${e}`:e}function Lt(e,t){return e=mr(e),{[e]:function(){return t.apply(this,arguments)}}[e]}function bt(e,t,r){if(e[t].Kd===void 0){var i=e[t];e[t]=function(){return e[t].Kd.hasOwnProperty(arguments.length)||k(`Function '${r}' called with an invalid number of arguments (${arguments.length}) - expects one of (${e[t].Kd})!`),e[t].Kd[arguments.length].apply(this,arguments)},e[t].Kd=[],e[t].Kd[i.Yd]=i}}function kt(e,t,r){m.hasOwnProperty(e)?((r===void 0||m[e].Kd!==void 0&&m[e].Kd[r]!==void 0)&&k(`Cannot register public name '${e}' twice`),bt(m,e,e),m.hasOwnProperty(r)&&k(`Cannot register multiple overloads of a function with the same number of arguments (${r})!`),m[e].Kd[r]=t):(m[e]=t,r!==void 0&&(m[e].sf=r))}function an(e,t,r,i,o,s,l,f){this.name=e,this.constructor=t,this.ae=r,this.Td=i,this.Md=o,this.We=s,this.ge=l,this.Te=f,this.ef=[]}function Ht(e,t,r){for(;t!==r;)t.ge||k(`Expected null or instance of ${r.name}, got an instance of ${t.name}`),e=t.ge(e),t=t.Md;return e}function un(e,t){return t===null?(this.ue&&k(`null is not a valid ${this.name}`),0):(t.Dd||k(`Cannot pass "${Ot(t)}" as a ${this.name}`),t.Dd.Hd||k(`Cannot pass deleted object as a pointer of type ${this.name}`),Ht(t.Dd.Hd,t.Dd.Jd.Gd,this.Gd))}function sn(e,t){if(t===null){if(this.ue&&k(`null is not a valid ${this.name}`),this.le){var r=this.ve();return e!==null&&e.push(this.Td,r),r}return 0}if(t.Dd||k(`Cannot pass "${Ot(t)}" as a ${this.name}`),t.Dd.Hd||k(`Cannot pass deleted object as a pointer of type ${this.name}`),!this.ke&&t.Dd.Jd.ke&&k(`Cannot convert argument of type ${t.Dd.Pd?t.Dd.Pd.name:t.Dd.Jd.name} to parameter type ${this.name}`),r=Ht(t.Dd.Hd,t.Dd.Jd.Gd,this.Gd),this.le)switch(t.Dd.Ld===void 0&&k("Passing raw pointer to smart pointer is illegal"),this.kf){case 0:t.Dd.Pd===this?r=t.Dd.Ld:k(`Cannot convert argument of type ${t.Dd.Pd?t.Dd.Pd.name:t.Dd.Jd.name} to parameter type ${this.name}`);break;case 1:r=t.Dd.Ld;break;case 2:if(t.Dd.Pd===this)r=t.Dd.Ld;else{var i=t.clone();r=this.ff(r,te(function(){i.delete()})),e!==null&&e.push(this.Td,r)}break;default:k("Unsupporting sharing policy")}return r}function ln(e,t){return t===null?(this.ue&&k(`null is not a valid ${this.name}`),0):(t.Dd||k(`Cannot pass "${Ot(t)}" as a ${this.name}`),t.Dd.Hd||k(`Cannot pass deleted object as a pointer of type ${this.name}`),t.Dd.Jd.ke&&k(`Cannot convert argument of type ${t.Dd.Jd.name} to parameter type ${this.name}`),Ht(t.Dd.Hd,t.Dd.Jd.Gd,this.Gd))}function ve(e,t,r,i,o,s,l,f,h,g,P){this.name=e,this.Gd=t,this.ue=r,this.ke=i,this.le=o,this.df=s,this.kf=l,this.Ee=f,this.ve=h,this.ff=g,this.Td=P,o||t.Md!==void 0?this.toWireType=sn:(this.toWireType=i?un:ln,this.Od=null)}function _r(e,t,r){m.hasOwnProperty(e)||at("Replacing nonexistant public symbol"),m[e].Kd!==void 0&&r!==void 0?m[e].Kd[r]=t:(m[e]=t,m[e].Yd=r)}var fn=(e,t)=>{var r=[];return function(){if(r.length=0,Object.assign(r,arguments),e.includes("j")){var i=m["dynCall_"+e];i=r&&r.length?i.apply(null,[t].concat(r)):i.call(null,t)}else i=Q.get(t).apply(null,r);return i}};function K(e,t){e=S(e);var r=e.includes("j")?fn(e,t):Q.get(t);return typeof r!="function"&&k(`unknown function pointer with signature ${e}: ${t}`),r}var gr=void 0;function Pr(e){e=Wr(e);var t=S(e);return Pe(e),t}function Xe(e,t){function r(s){o[s]||xe[s]||(ot[s]?ot[s].forEach(r):(i.push(s),o[s]=!0))}var i=[],o={};throw t.forEach(r),new gr(`${e}: `+i.map(Pr).join([", "]))}function lt(e,t,r,i,o){var s=t.length;2>s&&k("argTypes array size mismatch! Must at least get return value and 'this' types!");var l=t[1]!==null&&r!==null,f=!1;for(r=1;r<t.length;++r)if(t[r]!==null&&t[r].Od===void 0){f=!0;break}var h=t[0].name!=="void",g=s-2,P=Array(g),E=[],T=[];return function(){if(arguments.length!==g&&k(`function ${e} called with ${arguments.length} arguments, expected ${g} args!`),T.length=0,E.length=l?2:1,E[0]=o,l){var v=t[1].toWireType(T,this);E[1]=v}for(var M=0;M<g;++M)P[M]=t[M+2].toWireType(T,arguments[M]),E.push(P[M]);if(M=i.apply(null,E),f)It(T);else for(var x=l?1:2;x<t.length;x++){var W=x===1?v:P[x-2];t[x].Od!==null&&t[x].Od(W)}return v=h?t[0].fromWireType(M):void 0,v}}function ft(e,t){for(var r=[],i=0;i<e;i++)r.push(O[t+4*i>>2]);return r}function Cr(){this.Sd=[void 0],this.Ce=[]}var q=new Cr;function Ut(e){e>=q.be&&--q.get(e).Fe===0&&q.Je(e)}var ee=e=>(e||k("Cannot use deleted val. handle = "+e),q.get(e).value),te=e=>{switch(e){case void 0:return 1;case null:return 2;case!0:return 3;case!1:return 4;default:return q.Ie({Fe:1,value:e})}};function cn(e,t,r){switch(t){case 0:return function(i){return this.fromWireType((r?pe:G)[i])};case 1:return function(i){return this.fromWireType((r?Ee:Be)[i>>1])};case 2:return function(i){return this.fromWireType((r?w:O)[i>>2])};default:throw new TypeError("Unknown integer type: "+e)}}function Ke(e,t){var r=xe[e];return r===void 0&&k(t+" has unknown type "+Pr(e)),r}function Ot(e){if(e===null)return"null";var t=typeof e;return t==="object"||t==="array"||t==="function"?e.toString():""+e}function dn(e,t){switch(t){case 2:return function(r){return this.fromWireType(R[r>>2])};case 3:return function(r){return this.fromWireType(tr[r>>3])};default:throw new TypeError("Unknown float type: "+e)}}function hn(e,t,r){switch(t){case 0:return r?function(i){return pe[i]}:function(i){return G[i]};case 1:return r?function(i){return Ee[i>>1]}:function(i){return Be[i>>1]};case 2:return r?function(i){return w[i>>2]}:function(i){return O[i>>2]};default:throw new TypeError("Unknown integer type: "+e)}}var se=(e,t,r,i)=>{if(!(0<i))return 0;var o=r;i=r+i-1;for(var s=0;s<e.length;++s){var l=e.charCodeAt(s);if(55296<=l&&57343>=l){var f=e.charCodeAt(++s);l=65536+((l&1023)<<10)|f&1023}if(127>=l){if(r>=i)break;t[r++]=l}else{if(2047>=l){if(r+1>=i)break;t[r++]=192|l>>6}else{if(65535>=l){if(r+2>=i)break;t[r++]=224|l>>12}else{if(r+3>=i)break;t[r++]=240|l>>18,t[r++]=128|l>>12&63}t[r++]=128|l>>6&63}t[r++]=128|l&63}}return t[r]=0,r-o},le=e=>{for(var t=0,r=0;r<e.length;++r){var i=e.charCodeAt(r);127>=i?t++:2047>=i?t+=2:55296<=i&&57343>=i?(t+=4,++r):t+=3}return t},Ar=typeof TextDecoder<"u"?new TextDecoder("utf-16le"):void 0,pn=(e,t)=>{for(var r=e>>1,i=r+t/2;!(r>=i)&&Be[r];)++r;if(r<<=1,32<r-e&&Ar)return Ar.decode(G.subarray(e,r));for(r="",i=0;!(i>=t/2);++i){var o=Ee[e+2*i>>1];if(o==0)break;r+=String.fromCharCode(o)}return r},yn=(e,t,r)=>{if(r===void 0&&(r=2147483647),2>r)return 0;r-=2;var i=t;r=r<2*e.length?r/2:e.length;for(var o=0;o<r;++o)Ee[t>>1]=e.charCodeAt(o),t+=2;return Ee[t>>1]=0,t-i},vn=e=>2*e.length,mn=(e,t)=>{for(var r=0,i="";!(r>=t/4);){var o=w[e+4*r>>2];if(o==0)break;++r,65536<=o?(o-=65536,i+=String.fromCharCode(55296|o>>10,56320|o&1023)):i+=String.fromCharCode(o)}return i},_n=(e,t,r)=>{if(r===void 0&&(r=2147483647),4>r)return 0;var i=t;r=i+r-4;for(var o=0;o<e.length;++o){var s=e.charCodeAt(o);if(55296<=s&&57343>=s){var l=e.charCodeAt(++o);s=65536+((s&1023)<<10)|l&1023}if(w[t>>2]=s,t+=4,t+4>r)break}return w[t>>2]=0,t-i},gn=e=>{for(var t=0,r=0;r<e.length;++r){var i=e.charCodeAt(r);55296<=i&&57343>=i&&++r,t+=4}return t},Pn={};function ct(e){var t=Pn[e];return t===void 0?S(e):t}var dt=[];function Er(){function e(t){t.$$$embind_global$$$=t;var r=typeof $$$embind_global$$$=="object"&&t.$$$embind_global$$$==t;return r||delete t.$$$embind_global$$$,r}if(typeof globalThis=="object")return globalThis;if(typeof $$$embind_global$$$=="object"||(typeof global=="object"&&e(global)?$$$embind_global$$$=global:typeof self=="object"&&e(self)&&($$$embind_global$$$=self),typeof $$$embind_global$$$=="object"))return $$$embind_global$$$;throw Error("unable to get global object.")}function Cn(e){var t=dt.length;return dt.push(e),t}function An(e,t){for(var r=Array(e),i=0;i<e;++i)r[i]=Ke(O[t+4*i>>2],"parameter "+i);return r}var wr=[];function En(e){var t=Array(e+1);return function(r,i,o){t[0]=r;for(var s=0;s<e;++s){var l=Ke(O[i+4*s>>2],"parameter "+s);t[s+1]=l.readValueFromPointer(o),o+=l.argPackAdvance}return r=new(r.bind.apply(r,t)),te(r)}}var Tr={};function wn(e){var t=e.getExtension("ANGLE_instanced_arrays");t&&(e.vertexAttribDivisor=function(r,i){t.vertexAttribDivisorANGLE(r,i)},e.drawArraysInstanced=function(r,i,o,s){t.drawArraysInstancedANGLE(r,i,o,s)},e.drawElementsInstanced=function(r,i,o,s,l){t.drawElementsInstancedANGLE(r,i,o,s,l)})}function Tn(e){var t=e.getExtension("OES_vertex_array_object");t&&(e.createVertexArray=function(){return t.createVertexArrayOES()},e.deleteVertexArray=function(r){t.deleteVertexArrayOES(r)},e.bindVertexArray=function(r){t.bindVertexArrayOES(r)},e.isVertexArray=function(r){return t.isVertexArrayOES(r)})}function Fn(e){var t=e.getExtension("WEBGL_draw_buffers");t&&(e.drawBuffers=function(r,i){t.drawBuffersWEBGL(r,i)})}var Fr=1,ht=[],fe=[],pt=[],Je=[],re=[],ce=[],yt=[],me=[],Ie=[],De=[],Mr={},Rr={},xr=4;function j(e){vt||(vt=e)}function ke(e){for(var t=Fr++,r=e.length;r<t;r++)e[r]=null;return t}function Mn(e,t){e.be||(e.be=e.getContext,e.getContext=function(i,o){return o=e.be(i,o),i=="webgl"==o instanceof WebGLRenderingContext?o:null});var r=1<t.majorVersion?e.getContext("webgl2",t):e.getContext("webgl",t);return r?Rn(r,t):0}function Rn(e,t){var r=ke(me),i={handle:r,attributes:t,version:t.majorVersion,Qd:e};return e.canvas&&(e.canvas.Ke=i),me[r]=i,(typeof t.Ue>"u"||t.Ue)&&xn(i),r}function Ir(e){return B=me[e],m.qf=p=B&&B.Qd,!(e&&!p)}function xn(e){if(e||(e=B),!e.bf){e.bf=!0;var t=e.Qd;wn(t),Tn(t),Fn(t),t.ze=t.getExtension("WEBGL_draw_instanced_base_vertex_base_instance"),t.De=t.getExtension("WEBGL_multi_draw_instanced_base_vertex_base_instance"),2<=e.version&&(t.Ae=t.getExtension("EXT_disjoint_timer_query_webgl2")),(2>e.version||!t.Ae)&&(t.Ae=t.getExtension("EXT_disjoint_timer_query")),t.rf=t.getExtension("WEBGL_multi_draw"),(t.getSupportedExtensions()||[]).forEach(function(r){r.includes("lose_context")||r.includes("debug")||t.getExtension(r)})}}var B,vt,jt={},Dr=()=>{if(!Wt){var e={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:(typeof navigator=="object"&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_:wt||"./this.program"},t;for(t in jt)jt[t]===void 0?delete e[t]:e[t]=jt[t];var r=[];for(t in e)r.push(`${t}=${e[t]}`);Wt=r}return Wt},Wt,In=[null,[],[]];function Br(e){p.bindVertexArray(yt[e])}function Gr(e,t){for(var r=0;r<e;r++){var i=w[t+4*r>>2];p.deleteVertexArray(yt[i]),yt[i]=null}}var mt=[];function Lr(e,t,r,i){p.drawElements(e,t,r,i)}function He(e,t,r,i){for(var o=0;o<e;o++){var s=p[r](),l=s&&ke(i);s?(s.name=l,i[l]=s):j(1282),w[t+4*o>>2]=l}}function br(e,t){He(e,t,"createVertexArray",yt)}function kr(e,t,r){if(t){var i=void 0;switch(e){case 36346:i=1;break;case 36344:r!=0&&r!=1&&j(1280);return;case 34814:case 36345:i=0;break;case 34466:var o=p.getParameter(34467);i=o?o.length:0;break;case 33309:if(2>B.version){j(1282);return}i=2*(p.getSupportedExtensions()||[]).length;break;case 33307:case 33308:if(2>B.version){j(1280);return}i=e==33307?3:0}if(i===void 0)switch(o=p.getParameter(e),typeof o){case"number":i=o;break;case"boolean":i=o?1:0;break;case"string":j(1280);return;case"object":if(o===null)switch(e){case 34964:case 35725:case 34965:case 36006:case 36007:case 32873:case 34229:case 36662:case 36663:case 35053:case 35055:case 36010:case 35097:case 35869:case 32874:case 36389:case 35983:case 35368:case 34068:i=0;break;default:j(1280);return}else{if(o instanceof Float32Array||o instanceof Uint32Array||o instanceof Int32Array||o instanceof Array){for(e=0;e<o.length;++e)switch(r){case 0:w[t+4*e>>2]=o[e];break;case 2:R[t+4*e>>2]=o[e];break;case 4:pe[t+e>>0]=o[e]?1:0}return}try{i=o.name|0}catch(s){j(1280),Ae("GL_INVALID_ENUM in glGet"+r+"v: Unknown object returned from WebGL getParameter("+e+")! (error: "+s+")");return}}break;default:j(1280),Ae("GL_INVALID_ENUM in glGet"+r+"v: Native code calling glGet"+r+"v("+e+") and it returns "+o+" of type "+typeof o+"!");return}switch(r){case 1:r=i,O[t>>2]=r,O[t+4>>2]=(r-O[t>>2])/4294967296;break;case 0:w[t>>2]=i;break;case 2:R[t>>2]=i;break;case 4:pe[t>>0]=i?1:0}}else j(1281)}var Qe=e=>{var t=le(e)+1,r=Ct(t);return r&&se(e,G,r,t),r};function Hr(e){return e.slice(-1)=="]"&&e.lastIndexOf("[")}function _t(e){return e-=5120,e==0?pe:e==1?G:e==2?Ee:e==4?w:e==6?R:e==5||e==28922||e==28520||e==30779||e==30782?O:Be}function $t(e,t,r,i,o){e=_t(e);var s=31-Math.clz32(e.BYTES_PER_ELEMENT),l=xr;return e.subarray(o>>s,o+i*(r*({5:3,6:4,8:2,29502:3,29504:4,26917:2,26918:2,29846:3,29847:4}[t-6402]||1)*(1<<s)+l-1&-l)>>s)}function H(e){var t=p.Re;if(t){var r=t.fe[e];return typeof r=="number"&&(t.fe[e]=r=p.getUniformLocation(t,t.Ge[e]+(0<r?"["+r+"]":""))),r}j(1282)}var Te=[],Ze=[],gt=e=>e%4===0&&(e%100!==0||e%400===0),Ur=[31,29,31,30,31,30,31,31,30,31,30,31],Or=[31,28,31,30,31,30,31,31,30,31,30,31];function Dn(e){var t=Array(le(e)+1);return se(e,t,0,t.length),t}var Bn=(e,t,r,i)=>{function o(v,M,x){for(v=typeof v=="number"?v.toString():v||"";v.length<M;)v=x[0]+v;return v}function s(v,M){return o(v,M,"0")}function l(v,M){function x(J){return 0>J?-1:0<J?1:0}var W;return(W=x(v.getFullYear()-M.getFullYear()))===0&&(W=x(v.getMonth()-M.getMonth()))===0&&(W=x(v.getDate()-M.getDate())),W}function f(v){switch(v.getDay()){case 0:return new Date(v.getFullYear()-1,11,29);case 1:return v;case 2:return new Date(v.getFullYear(),0,3);case 3:return new Date(v.getFullYear(),0,2);case 4:return new Date(v.getFullYear(),0,1);case 5:return new Date(v.getFullYear()-1,11,31);case 6:return new Date(v.getFullYear()-1,11,30)}}function h(v){var M=v.Vd;for(v=new Date(new Date(v.Wd+1900,0,1).getTime());0<M;){var x=v.getMonth(),W=(gt(v.getFullYear())?Ur:Or)[x];if(M>W-v.getDate())M-=W-v.getDate()+1,v.setDate(1),11>x?v.setMonth(x+1):(v.setMonth(0),v.setFullYear(v.getFullYear()+1));else{v.setDate(v.getDate()+M);break}}return x=new Date(v.getFullYear()+1,0,4),M=f(new Date(v.getFullYear(),0,4)),x=f(x),0>=l(M,v)?0>=l(x,v)?v.getFullYear()+1:v.getFullYear():v.getFullYear()-1}var g=w[i+40>>2];i={nf:w[i>>2],mf:w[i+4>>2],pe:w[i+8>>2],we:w[i+12>>2],qe:w[i+16>>2],Wd:w[i+20>>2],Rd:w[i+24>>2],Vd:w[i+28>>2],uf:w[i+32>>2],lf:w[i+36>>2],pf:g&&g?Re(G,g):""},r=r?Re(G,r):"",g={"%c":"%a %b %d %H:%M:%S %Y","%D":"%m/%d/%y","%F":"%Y-%m-%d","%h":"%b","%r":"%I:%M:%S %p","%R":"%H:%M","%T":"%H:%M:%S","%x":"%m/%d/%y","%X":"%H:%M:%S","%Ec":"%c","%EC":"%C","%Ex":"%m/%d/%y","%EX":"%H:%M:%S","%Ey":"%y","%EY":"%Y","%Od":"%d","%Oe":"%e","%OH":"%H","%OI":"%I","%Om":"%m","%OM":"%M","%OS":"%S","%Ou":"%u","%OU":"%U","%OV":"%V","%Ow":"%w","%OW":"%W","%Oy":"%y"};for(var P in g)r=r.replace(new RegExp(P,"g"),g[P]);var E="Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" "),T="January February March April May June July August September October November December".split(" ");g={"%a":v=>E[v.Rd].substring(0,3),"%A":v=>E[v.Rd],"%b":v=>T[v.qe].substring(0,3),"%B":v=>T[v.qe],"%C":v=>s((v.Wd+1900)/100|0,2),"%d":v=>s(v.we,2),"%e":v=>o(v.we,2," "),"%g":v=>h(v).toString().substring(2),"%G":v=>h(v),"%H":v=>s(v.pe,2),"%I":v=>(v=v.pe,v==0?v=12:12<v&&(v-=12),s(v,2)),"%j":v=>{for(var M=0,x=0;x<=v.qe-1;M+=(gt(v.Wd+1900)?Ur:Or)[x++]);return s(v.we+M,3)},"%m":v=>s(v.qe+1,2),"%M":v=>s(v.mf,2),"%n":()=>`
2
- `,"%p":v=>0<=v.pe&&12>v.pe?"AM":"PM","%S":v=>s(v.nf,2),"%t":()=>" ","%u":v=>v.Rd||7,"%U":v=>s(Math.floor((v.Vd+7-v.Rd)/7),2),"%V":v=>{var M=Math.floor((v.Vd+7-(v.Rd+6)%7)/7);if(2>=(v.Rd+371-v.Vd-2)%7&&M++,M)M==53&&(x=(v.Rd+371-v.Vd)%7,x==4||x==3&&gt(v.Wd)||(M=1));else{M=52;var x=(v.Rd+7-v.Vd-1)%7;(x==4||x==5&&gt(v.Wd%400-1))&&M++}return s(M,2)},"%w":v=>v.Rd,"%W":v=>s(Math.floor((v.Vd+7-(v.Rd+6)%7)/7),2),"%y":v=>(v.Wd+1900).toString().substring(2),"%Y":v=>v.Wd+1900,"%z":v=>{v=v.lf;var M=0<=v;return v=Math.abs(v)/60,(M?"+":"-")+String("0000"+(v/60*100+v%60)).slice(-4)},"%Z":v=>v.pf,"%%":()=>"%"},r=r.replace(/%%/g,"\0\0");for(P in g)r.includes(P)&&(r=r.replace(new RegExp(P,"g"),g[P](i)));return r=r.replace(/\0\0/g,"%"),P=Dn(r),P.length>t?0:(pe.set(P,e),P.length-1)};cr=m.InternalError=class extends Error{constructor(e){super(e),this.name="InternalError"}};for(var jr=Array(256),Pt=0;256>Pt;++Pt)jr[Pt]=String.fromCharCode(Pt);dr=jr,be=m.BindingError=class extends Error{constructor(e){super(e),this.name="BindingError"}},we.prototype.isAliasOf=function(e){if(!(this instanceof we&&e instanceof we))return!1;var t=this.Dd.Jd.Gd,r=this.Dd.Hd,i=e.Dd.Jd.Gd;for(e=e.Dd.Hd;t.Md;)r=t.ge(r),t=t.Md;for(;i.Md;)e=i.ge(e),i=i.Md;return t===i&&r===e},we.prototype.clone=function(){if(this.Dd.Hd||Dt(this),this.Dd.ee)return this.Dd.count.value+=1,this;var e=Ye,t=Object,r=t.create,i=Object.getPrototypeOf(this),o=this.Dd;return e=e(r.call(t,i,{Dd:{value:{count:o.count,$d:o.$d,ee:o.ee,Hd:o.Hd,Jd:o.Jd,Ld:o.Ld,Pd:o.Pd}}})),e.Dd.count.value+=1,e.Dd.$d=!1,e},we.prototype.delete=function(){this.Dd.Hd||Dt(this),this.Dd.$d&&!this.Dd.ee&&k("Object already scheduled for deletion"),hr(this),pr(this.Dd),this.Dd.ee||(this.Dd.Ld=void 0,this.Dd.Hd=void 0)},we.prototype.isDeleted=function(){return!this.Dd.Hd},we.prototype.deleteLater=function(){return this.Dd.Hd||Dt(this),this.Dd.$d&&!this.Dd.ee&&k("Object already scheduled for deletion"),Se.push(this),Se.length===1&&Ve&&Ve(Gt),this.Dd.$d=!0,this},m.getInheritedInstanceCount=function(){return Object.keys(Ne).length},m.getLiveInheritedInstances=function(){var e=[],t;for(t in Ne)Ne.hasOwnProperty(t)&&e.push(Ne[t]);return e},m.flushPendingDeletes=Gt,m.setDelayFunction=function(e){Ve=e,Se.length&&Ve&&Ve(Gt)},ve.prototype.Xe=function(e){return this.Ee&&(e=this.Ee(e)),e},ve.prototype.ye=function(e){this.Td&&this.Td(e)},ve.prototype.argPackAdvance=8,ve.prototype.readValueFromPointer=$e,ve.prototype.deleteObject=function(e){e!==null&&e.delete()},ve.prototype.fromWireType=function(e){function t(){return this.le?st(this.Gd.ae,{Jd:this.df,Hd:r,Pd:this,Ld:e}):st(this.Gd.ae,{Jd:this,Hd:e})}var r=this.Xe(e);if(!r)return this.ye(e),null;var i=on(this.Gd,r);if(i!==void 0)return i.Dd.count.value===0?(i.Dd.Hd=r,i.Dd.Ld=e,i.clone()):(i=i.clone(),this.ye(e),i);if(i=this.Gd.We(r),i=vr[i],!i)return t.call(this);i=this.ke?i.Qe:i.pointerType;var o=yr(r,this.Gd,i.Gd);return o===null?t.call(this):this.le?st(i.Gd.ae,{Jd:i,Hd:o,Pd:this,Ld:e}):st(i.Gd.ae,{Jd:i,Hd:o})},gr=m.UnboundTypeError=function(e,t){var r=Lt(t,function(i){this.name=t,this.message=i,i=Error(i).stack,i!==void 0&&(this.stack=this.toString()+`
3
- `+i.replace(/^Error(:[^\n]*)?\n/,""))});return r.prototype=Object.create(e.prototype),r.prototype.constructor=r,r.prototype.toString=function(){return this.message===void 0?this.name:`${this.name}: ${this.message}`},r}(Error,"UnboundTypeError"),Object.assign(Cr.prototype,{get(e){return this.Sd[e]},has(e){return this.Sd[e]!==void 0},Ie(e){var t=this.Ce.pop()||this.Sd.length;return this.Sd[t]=e,t},Je(e){this.Sd[e]=void 0,this.Ce.push(e)}}),q.Sd.push({value:void 0},{value:null},{value:!0},{value:!1}),q.be=q.Sd.length,m.count_emval_handles=function(){for(var e=0,t=q.be;t<q.Sd.length;++t)q.Sd[t]!==void 0&&++e;return e};for(var p,Z=0;32>Z;++Z)mt.push(Array(Z));var Gn=new Float32Array(288);for(Z=0;288>Z;++Z)Te[Z]=Gn.subarray(0,Z+1);var Ln=new Int32Array(288);for(Z=0;288>Z;++Z)Ze[Z]=Ln.subarray(0,Z+1);var bn={Q:function(){return 0},Ab:()=>{},Cb:function(){return 0},xb:()=>{},yb:()=>{},R:function(){},zb:()=>{},v:function(e){var t=it[e];delete it[e];var r=t.ve,i=t.Td,o=t.Be,s=o.map(l=>l.$e).concat(o.map(l=>l.hf));ue([e],s,l=>{var f={};return o.forEach((h,g)=>{var P=l[g],E=h.Ye,T=h.Ze,v=l[g+o.length],M=h.gf,x=h.jf;f[h.Ve]={read:W=>P.fromWireType(E(T,W)),write:(W,J)=>{var Y=[];M(x,W,v.toWireType(Y,J)),It(Y)}}}),[{name:t.name,fromWireType:function(h){var g={},P;for(P in f)g[P]=f[P].read(h);return i(h),g},toWireType:function(h,g){for(var P in f)if(!(P in g))throw new TypeError(`Missing field: "${P}"`);var E=r();for(P in f)f[P].write(E,g[P]);return h!==null&&h.push(i,E),E},argPackAdvance:8,readValueFromPointer:$e,Od:i}]})},pb:function(){},Gb:function(e,t,r,i,o){var s=ut(r);t=S(t),ye(e,{name:t,fromWireType:function(l){return!!l},toWireType:function(l,f){return f?i:o},argPackAdvance:8,readValueFromPointer:function(l){if(r===1)var f=pe;else if(r===2)f=Ee;else if(r===4)f=w;else throw new TypeError("Unknown boolean type size: "+t);return this.fromWireType(f[l>>s])},Od:null})},k:function(e,t,r,i,o,s,l,f,h,g,P,E,T){P=S(P),s=K(o,s),f&&(f=K(l,f)),g&&(g=K(h,g)),T=K(E,T);var v=mr(P);kt(v,function(){Xe(`Cannot construct ${P} due to unbound types`,[i])}),ue([e,t,r],i?[i]:[],function(M){if(M=M[0],i)var x=M.Gd,W=x.ae;else W=we.prototype;M=Lt(v,function(){if(Object.getPrototypeOf(this)!==J)throw new be("Use 'new' to construct "+P);if(Y.Ud===void 0)throw new be(P+" has no accessible constructor");var Ue=Y.Ud[arguments.length];if(Ue===void 0)throw new be(`Tried to invoke ctor of ${P} with invalid number of parameters (${arguments.length}) - expected (${Object.keys(Y.Ud).toString()}) parameters instead!`);return Ue.apply(this,arguments)});var J=Object.create(W,{constructor:{value:M}});M.prototype=J;var Y=new an(P,M,J,T,x,s,f,g);Y.Md&&(Y.Md.he===void 0&&(Y.Md.he=[]),Y.Md.he.push(Y)),x=new ve(P,Y,!0,!1,!1),W=new ve(P+"*",Y,!1,!1,!1);var _e=new ve(P+" const*",Y,!1,!0,!1);return vr[e]={pointerType:W,Qe:_e},_r(v,M),[x,W,_e]})},f:function(e,t,r,i,o,s,l){var f=ft(r,i);t=S(t),s=K(o,s),ue([],[e],function(h){function g(){Xe(`Cannot call ${P} due to unbound types`,f)}h=h[0];var P=`${h.name}.${t}`;t.startsWith("@@")&&(t=Symbol[t.substring(2)]);var E=h.Gd.constructor;return E[t]===void 0?(g.Yd=r-1,E[t]=g):(bt(E,t,P),E[t].Kd[r-1]=g),ue([],f,function(T){if(T=[T[0],null].concat(T.slice(1)),T=lt(P,T,null,s,l),E[t].Kd===void 0?(T.Yd=r-1,E[t]=T):E[t].Kd[r-1]=T,h.Gd.he)for(let v of h.Gd.he)v.constructor.hasOwnProperty(t)||(v.constructor[t]=T);return[]}),[]})},t:function(e,t,r,i,o,s){var l=ft(t,r);o=K(i,o),ue([],[e],function(f){f=f[0];var h=`constructor ${f.name}`;if(f.Gd.Ud===void 0&&(f.Gd.Ud=[]),f.Gd.Ud[t-1]!==void 0)throw new be(`Cannot register multiple constructors with identical number of parameters (${t-1}) for class '${f.name}'! Overload resolution is currently only performed using the parameter count, not actual type info!`);return f.Gd.Ud[t-1]=()=>{Xe(`Cannot construct ${f.name} due to unbound types`,l)},ue([],l,function(g){return g.splice(1,0,null),f.Gd.Ud[t-1]=lt(h,g,null,o,s),[]}),[]})},b:function(e,t,r,i,o,s,l,f){var h=ft(r,i);t=S(t),s=K(o,s),ue([],[e],function(g){function P(){Xe(`Cannot call ${E} due to unbound types`,h)}g=g[0];var E=`${g.name}.${t}`;t.startsWith("@@")&&(t=Symbol[t.substring(2)]),f&&g.Gd.ef.push(t);var T=g.Gd.ae,v=T[t];return v===void 0||v.Kd===void 0&&v.className!==g.name&&v.Yd===r-2?(P.Yd=r-2,P.className=g.name,T[t]=P):(bt(T,t,E),T[t].Kd[r-2]=P),ue([],h,function(M){return M=lt(E,M,g,s,l),T[t].Kd===void 0?(M.Yd=r-2,T[t]=M):T[t].Kd[r-2]=M,[]}),[]})},o:function(e,t,r){e=S(e),ue([],[t],function(i){return i=i[0],m[e]=i.fromWireType(r),[]})},Fb:function(e,t){t=S(t),ye(e,{name:t,fromWireType:function(r){var i=ee(r);return Ut(r),i},toWireType:function(r,i){return te(i)},argPackAdvance:8,readValueFromPointer:$e,Od:null})},j:function(e,t,r,i){function o(){}r=ut(r),t=S(t),o.values={},ye(e,{name:t,constructor:o,fromWireType:function(s){return this.constructor.values[s]},toWireType:function(s,l){return l.value},argPackAdvance:8,readValueFromPointer:cn(t,r,i),Od:null}),kt(t,o)},c:function(e,t,r){var i=Ke(e,"enum");t=S(t),e=i.constructor,i=Object.create(i.constructor.prototype,{value:{value:r},constructor:{value:Lt(`${i.name}_${t}`,function(){})}}),e.values[r]=i,e[t]=i},T:function(e,t,r){r=ut(r),t=S(t),ye(e,{name:t,fromWireType:function(i){return i},toWireType:function(i,o){return o},argPackAdvance:8,readValueFromPointer:dn(t,r),Od:null})},r:function(e,t,r,i,o,s){var l=ft(t,r);e=S(e),o=K(i,o),kt(e,function(){Xe(`Cannot call ${e} due to unbound types`,l)},t-1),ue([],l,function(f){return f=[f[0],null].concat(f.slice(1)),_r(e,lt(e,f,null,o,s),t-1),[]})},x:function(e,t,r,i,o){t=S(t),o===-1&&(o=4294967295),o=ut(r);var s=f=>f;if(i===0){var l=32-8*r;s=f=>f<<l>>>l}r=t.includes("unsigned")?function(f,h){return h>>>0}:function(f,h){return h},ye(e,{name:t,fromWireType:s,toWireType:r,argPackAdvance:8,readValueFromPointer:hn(t,o,i!==0),Od:null})},n:function(e,t,r){function i(s){s>>=2;var l=O;return new o(l.buffer,l[s+1],l[s])}var o=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array][t];r=S(r),ye(e,{name:r,fromWireType:i,argPackAdvance:8,readValueFromPointer:i},{af:!0})},m:function(e,t,r,i,o,s,l,f,h,g,P,E){r=S(r),s=K(o,s),f=K(l,f),g=K(h,g),E=K(P,E),ue([e],[t],function(T){return T=T[0],[new ve(r,T.Gd,!1,!1,!0,T,i,s,f,g,E)]})},S:function(e,t){t=S(t);var r=t==="std::string";ye(e,{name:t,fromWireType:function(i){var o=O[i>>2],s=i+4;if(r)for(var l=s,f=0;f<=o;++f){var h=s+f;if(f==o||G[h]==0){if(l=l?Re(G,l,h-l):"",g===void 0)var g=l;else g+=String.fromCharCode(0),g+=l;l=h+1}}else{for(g=Array(o),f=0;f<o;++f)g[f]=String.fromCharCode(G[s+f]);g=g.join("")}return Pe(i),g},toWireType:function(i,o){o instanceof ArrayBuffer&&(o=new Uint8Array(o));var s=typeof o=="string";s||o instanceof Uint8Array||o instanceof Uint8ClampedArray||o instanceof Int8Array||k("Cannot pass non-string to std::string");var l=r&&s?le(o):o.length,f=Ct(4+l+1),h=f+4;if(O[f>>2]=l,r&&s)se(o,G,h,l+1);else if(s)for(s=0;s<l;++s){var g=o.charCodeAt(s);255<g&&(Pe(h),k("String has UTF-16 code units that do not fit in 8 bits")),G[h+s]=g}else for(s=0;s<l;++s)G[h+s]=o[s];return i!==null&&i.push(Pe,f),f},argPackAdvance:8,readValueFromPointer:$e,Od:function(i){Pe(i)}})},K:function(e,t,r){if(r=S(r),t===2)var i=pn,o=yn,s=vn,l=()=>Be,f=1;else t===4&&(i=mn,o=_n,s=gn,l=()=>O,f=2);ye(e,{name:r,fromWireType:function(h){for(var g=O[h>>2],P=l(),E,T=h+4,v=0;v<=g;++v){var M=h+4+v*t;(v==g||P[M>>f]==0)&&(T=i(T,M-T),E===void 0?E=T:(E+=String.fromCharCode(0),E+=T),T=M+t)}return Pe(h),E},toWireType:function(h,g){typeof g!="string"&&k(`Cannot pass non-string to C++ string type ${r}`);var P=s(g),E=Ct(4+P+t);return O[E>>2]=P>>f,o(g,E+4,P+t),h!==null&&h.push(Pe,E),E},argPackAdvance:8,readValueFromPointer:$e,Od:function(h){Pe(h)}})},w:function(e,t,r,i,o,s){it[e]={name:S(t),ve:K(r,i),Td:K(o,s),Be:[]}},e:function(e,t,r,i,o,s,l,f,h,g){it[e].Be.push({Ve:S(t),$e:r,Ye:K(i,o),Ze:s,hf:l,gf:K(f,h),jf:g})},Hb:function(e,t){t=S(t),ye(e,{cf:!0,name:t,argPackAdvance:0,fromWireType:function(){},toWireType:function(){}})},Eb:()=>!0,tb:()=>{throw 1/0},y:function(e,t,r){e=ee(e),t=Ke(t,"emval::as");var i=[],o=te(i);return O[r>>2]=o,t.toWireType(i,e)},Y:function(e,t,r,i,o){e=dt[e],t=ee(t),r=ct(r);var s=[];return O[i>>2]=te(s),e(t,r,s,o)},q:function(e,t,r,i){e=dt[e],t=ee(t),r=ct(r),e(t,r,null,i)},d:Ut,H:function(e){return e===0?te(Er()):(e=ct(e),te(Er()[e]))},p:function(e,t){var r=An(e,t),i=r[0];t=i.name+"_$"+r.slice(1).map(function(l){return l.name}).join("_")+"$";var o=wr[t];if(o!==void 0)return o;var s=Array(e-1);return o=Cn((l,f,h,g)=>{for(var P=0,E=0;E<e-1;++E)s[E]=r[E+1].readValueFromPointer(g+P),P+=r[E+1].argPackAdvance;for(l=l[f].apply(l,s),E=0;E<e-1;++E)r[E+1].Se&&r[E+1].Se(s[E]);if(!i.cf)return i.toWireType(h,l)}),wr[t]=o},s:function(e,t){return e=ee(e),t=ee(t),te(e[t])},l:function(e){4<e&&(q.get(e).Fe+=1)},G:function(e,t,r,i){e=ee(e);var o=Tr[t];return o||(o=En(t),Tr[t]=o),o(e,r,i)},C:function(){return te([])},g:function(e){return te(ct(e))},z:function(){return te({})},jb:function(e){return e=ee(e),!e},u:function(e){var t=ee(e);It(t),Ut(e)},i:function(e,t,r){e=ee(e),t=ee(t),r=ee(r),e[t]=r},h:function(e,t){return e=Ke(e,"_emval_take_value"),e=e.readValueFromPointer(t),te(e)},mb:function(){return-52},nb:function(){},a:()=>{Rt("")},Db:()=>performance.now(),ub:e=>{var t=G.length;if(e>>>=0,2147483648<e)return!1;for(var r=1;4>=r;r*=2){var i=t*(1+.2/r);i=Math.min(i,e+100663296);var o=Math;i=Math.max(e,i);e:{o=o.min.call(o,2147483648,i+(65536-i%65536)%65536)-nt.buffer.byteLength+65535>>>16;try{nt.grow(o),rr();var s=1;break e}catch{}s=void 0}if(s)return!0}return!1},kb:function(){return B?B.handle:0},vb:(e,t)=>{var r=0;return Dr().forEach(function(i,o){var s=t+r;for(o=O[e+4*o>>2]=s,s=0;s<i.length;++s)pe[o++>>0]=i.charCodeAt(s);pe[o>>0]=0,r+=i.length+1}),0},wb:(e,t)=>{var r=Dr();O[e>>2]=r.length;var i=0;return r.forEach(function(o){i+=o.length+1}),O[t>>2]=i,0},J:()=>52,lb:function(){return 52},Bb:()=>52,ob:function(){return 70},P:(e,t,r,i)=>{for(var o=0,s=0;s<r;s++){var l=O[t>>2],f=O[t+4>>2];t+=8;for(var h=0;h<f;h++){var g=G[l+h],P=In[e];g===0||g===10?((e===1?qr:Ae)(Re(P,0)),P.length=0):P.push(g)}o+=f}return O[i>>2]=o,0},$:function(e){p.activeTexture(e)},aa:function(e,t){p.attachShader(fe[e],ce[t])},ba:function(e,t,r){p.bindAttribLocation(fe[e],t,r?Re(G,r):"")},ca:function(e,t){e==35051?p.se=t:e==35052&&(p.Zd=t),p.bindBuffer(e,ht[t])},_:function(e,t){p.bindFramebuffer(e,pt[t])},ac:function(e,t){p.bindRenderbuffer(e,Je[t])},Mb:function(e,t){p.bindSampler(e,Ie[t])},da:function(e,t){p.bindTexture(e,re[t])},uc:Br,xc:Br,ea:function(e,t,r,i){p.blendColor(e,t,r,i)},fa:function(e){p.blendEquation(e)},ga:function(e,t){p.blendFunc(e,t)},Wb:function(e,t,r,i,o,s,l,f,h,g){p.blitFramebuffer(e,t,r,i,o,s,l,f,h,g)},ha:function(e,t,r,i){2<=B.version?r&&t?p.bufferData(e,G,i,r,t):p.bufferData(e,t,i):p.bufferData(e,r?G.subarray(r,r+t):t,i)},ia:function(e,t,r,i){2<=B.version?r&&p.bufferSubData(e,t,G,i,r):p.bufferSubData(e,t,G.subarray(i,i+r))},bc:function(e){return p.checkFramebufferStatus(e)},N:function(e){p.clear(e)},Z:function(e,t,r,i){p.clearColor(e,t,r,i)},O:function(e){p.clearStencil(e)},rb:function(e,t,r,i){return p.clientWaitSync(De[e],t,(r>>>0)+4294967296*i)},ja:function(e,t,r,i){p.colorMask(!!e,!!t,!!r,!!i)},ka:function(e){p.compileShader(ce[e])},la:function(e,t,r,i,o,s,l,f){2<=B.version?p.Zd||!l?p.compressedTexImage2D(e,t,r,i,o,s,l,f):p.compressedTexImage2D(e,t,r,i,o,s,G,f,l):p.compressedTexImage2D(e,t,r,i,o,s,f?G.subarray(f,f+l):null)},ma:function(e,t,r,i,o,s,l,f,h){2<=B.version?p.Zd||!f?p.compressedTexSubImage2D(e,t,r,i,o,s,l,f,h):p.compressedTexSubImage2D(e,t,r,i,o,s,l,G,h,f):p.compressedTexSubImage2D(e,t,r,i,o,s,l,h?G.subarray(h,h+f):null)},Ub:function(e,t,r,i,o){p.copyBufferSubData(e,t,r,i,o)},na:function(e,t,r,i,o,s,l,f){p.copyTexSubImage2D(e,t,r,i,o,s,l,f)},oa:function(){var e=ke(fe),t=p.createProgram();return t.name=e,t.oe=t.me=t.ne=0,t.xe=1,fe[e]=t,e},pa:function(e){var t=ke(ce);return ce[t]=p.createShader(e),t},qa:function(e){p.cullFace(e)},ra:function(e,t){for(var r=0;r<e;r++){var i=w[t+4*r>>2],o=ht[i];o&&(p.deleteBuffer(o),o.name=0,ht[i]=null,i==p.se&&(p.se=0),i==p.Zd&&(p.Zd=0))}},cc:function(e,t){for(var r=0;r<e;++r){var i=w[t+4*r>>2],o=pt[i];o&&(p.deleteFramebuffer(o),o.name=0,pt[i]=null)}},sa:function(e){if(e){var t=fe[e];t?(p.deleteProgram(t),t.name=0,fe[e]=null):j(1281)}},dc:function(e,t){for(var r=0;r<e;r++){var i=w[t+4*r>>2],o=Je[i];o&&(p.deleteRenderbuffer(o),o.name=0,Je[i]=null)}},Nb:function(e,t){for(var r=0;r<e;r++){var i=w[t+4*r>>2],o=Ie[i];o&&(p.deleteSampler(o),o.name=0,Ie[i]=null)}},ta:function(e){if(e){var t=ce[e];t?(p.deleteShader(t),ce[e]=null):j(1281)}},Vb:function(e){if(e){var t=De[e];t?(p.deleteSync(t),t.name=0,De[e]=null):j(1281)}},ua:function(e,t){for(var r=0;r<e;r++){var i=w[t+4*r>>2],o=re[i];o&&(p.deleteTexture(o),o.name=0,re[i]=null)}},vc:Gr,yc:Gr,va:function(e){p.depthMask(!!e)},wa:function(e){p.disable(e)},xa:function(e){p.disableVertexAttribArray(e)},ya:function(e,t,r){p.drawArrays(e,t,r)},sc:function(e,t,r,i){p.drawArraysInstanced(e,t,r,i)},qc:function(e,t,r,i,o){p.ze.drawArraysInstancedBaseInstanceWEBGL(e,t,r,i,o)},oc:function(e,t){for(var r=mt[e],i=0;i<e;i++)r[i]=w[t+4*i>>2];p.drawBuffers(r)},za:Lr,tc:function(e,t,r,i,o){p.drawElementsInstanced(e,t,r,i,o)},rc:function(e,t,r,i,o,s,l){p.ze.drawElementsInstancedBaseVertexBaseInstanceWEBGL(e,t,r,i,o,s,l)},ic:function(e,t,r,i,o,s){Lr(e,i,o,s)},Aa:function(e){p.enable(e)},Ba:function(e){p.enableVertexAttribArray(e)},Sb:function(e,t){return(e=p.fenceSync(e,t))?(t=ke(De),e.name=t,De[t]=e,t):0},Ca:function(){p.finish()},Da:function(){p.flush()},ec:function(e,t,r,i){p.framebufferRenderbuffer(e,t,r,Je[i])},fc:function(e,t,r,i,o){p.framebufferTexture2D(e,t,r,re[i],o)},Ea:function(e){p.frontFace(e)},Fa:function(e,t){He(e,t,"createBuffer",ht)},gc:function(e,t){He(e,t,"createFramebuffer",pt)},hc:function(e,t){He(e,t,"createRenderbuffer",Je)},Ob:function(e,t){He(e,t,"createSampler",Ie)},Ga:function(e,t){He(e,t,"createTexture",re)},wc:br,zc:br,Yb:function(e){p.generateMipmap(e)},Ha:function(e,t,r){r?w[r>>2]=p.getBufferParameter(e,t):j(1281)},Ia:function(){var e=p.getError()||vt;return vt=0,e},Ja:function(e,t){kr(e,t,2)},Zb:function(e,t,r,i){e=p.getFramebufferAttachmentParameter(e,t,r),(e instanceof WebGLRenderbuffer||e instanceof WebGLTexture)&&(e=e.name|0),w[i>>2]=e},I:function(e,t){kr(e,t,0)},Ka:function(e,t,r,i){e=p.getProgramInfoLog(fe[e]),e===null&&(e="(unknown error)"),t=0<t&&i?se(e,G,i,t):0,r&&(w[r>>2]=t)},La:function(e,t,r){if(r)if(e>=Fr)j(1281);else if(e=fe[e],t==35716)e=p.getProgramInfoLog(e),e===null&&(e="(unknown error)"),w[r>>2]=e.length+1;else if(t==35719){if(!e.oe)for(t=0;t<p.getProgramParameter(e,35718);++t)e.oe=Math.max(e.oe,p.getActiveUniform(e,t).name.length+1);w[r>>2]=e.oe}else if(t==35722){if(!e.me)for(t=0;t<p.getProgramParameter(e,35721);++t)e.me=Math.max(e.me,p.getActiveAttrib(e,t).name.length+1);w[r>>2]=e.me}else if(t==35381){if(!e.ne)for(t=0;t<p.getProgramParameter(e,35382);++t)e.ne=Math.max(e.ne,p.getActiveUniformBlockName(e,t).length+1);w[r>>2]=e.ne}else w[r>>2]=p.getProgramParameter(e,t);else j(1281)},_b:function(e,t,r){r?w[r>>2]=p.getRenderbufferParameter(e,t):j(1281)},Ma:function(e,t,r,i){e=p.getShaderInfoLog(ce[e]),e===null&&(e="(unknown error)"),t=0<t&&i?se(e,G,i,t):0,r&&(w[r>>2]=t)},Jb:function(e,t,r,i){e=p.getShaderPrecisionFormat(e,t),w[r>>2]=e.rangeMin,w[r+4>>2]=e.rangeMax,w[i>>2]=e.precision},Na:function(e,t,r){r?t==35716?(e=p.getShaderInfoLog(ce[e]),e===null&&(e="(unknown error)"),w[r>>2]=e?e.length+1:0):t==35720?(e=p.getShaderSource(ce[e]),w[r>>2]=e?e.length+1:0):w[r>>2]=p.getShaderParameter(ce[e],t):j(1281)},M:function(e){var t=Mr[e];if(!t){switch(e){case 7939:t=p.getSupportedExtensions()||[],t=t.concat(t.map(function(i){return"GL_"+i})),t=Qe(t.join(" "));break;case 7936:case 7937:case 37445:case 37446:(t=p.getParameter(e))||j(1280),t=t&&Qe(t);break;case 7938:t=p.getParameter(7938),t=2<=B.version?"OpenGL ES 3.0 ("+t+")":"OpenGL ES 2.0 ("+t+")",t=Qe(t);break;case 35724:t=p.getParameter(35724);var r=t.match(/^WebGL GLSL ES ([0-9]\.[0-9][0-9]?)(?:$| .*)/);r!==null&&(r[1].length==3&&(r[1]+="0"),t="OpenGL ES GLSL ES "+r[1]+" ("+t+")"),t=Qe(t);break;default:j(1280)}Mr[e]=t}return t},ib:function(e,t){if(2>B.version)return j(1282),0;var r=Rr[e];if(r)return 0>t||t>=r.length?(j(1281),0):r[t];switch(e){case 7939:return r=p.getSupportedExtensions()||[],r=r.concat(r.map(function(i){return"GL_"+i})),r=r.map(function(i){return Qe(i)}),r=Rr[e]=r,0>t||t>=r.length?(j(1281),0):r[t];default:return j(1280),0}},Oa:function(e,t){if(t=t?Re(G,t):"",e=fe[e]){var r=e,i=r.fe,o=r.He,s;if(!i)for(r.fe=i={},r.Ge={},s=0;s<p.getProgramParameter(r,35718);++s){var l=p.getActiveUniform(r,s),f=l.name;l=l.size;var h=Hr(f);h=0<h?f.slice(0,h):f;var g=r.xe;for(r.xe+=l,o[h]=[l,g],f=0;f<l;++f)i[g]=f,r.Ge[g++]=h}if(r=e.fe,i=0,o=t,s=Hr(t),0<s&&(i=parseInt(t.slice(s+1))>>>0,o=t.slice(0,s)),(o=e.He[o])&&i<o[0]&&(i+=o[1],r[i]=r[i]||p.getUniformLocation(e,t)))return i}else j(1281);return-1},Kb:function(e,t,r){for(var i=mt[t],o=0;o<t;o++)i[o]=w[r+4*o>>2];p.invalidateFramebuffer(e,i)},Lb:function(e,t,r,i,o,s,l){for(var f=mt[t],h=0;h<t;h++)f[h]=w[r+4*h>>2];p.invalidateSubFramebuffer(e,f,i,o,s,l)},Tb:function(e){return p.isSync(De[e])},Pa:function(e){return(e=re[e])?p.isTexture(e):0},Qa:function(e){p.lineWidth(e)},Ra:function(e){e=fe[e],p.linkProgram(e),e.fe=0,e.He={}},mc:function(e,t,r,i,o,s){p.De.multiDrawArraysInstancedBaseInstanceWEBGL(e,w,t>>2,w,r>>2,w,i>>2,O,o>>2,s)},nc:function(e,t,r,i,o,s,l,f){p.De.multiDrawElementsInstancedBaseVertexBaseInstanceWEBGL(e,w,t>>2,r,w,i>>2,w,o>>2,w,s>>2,O,l>>2,f)},Sa:function(e,t){e==3317&&(xr=t),p.pixelStorei(e,t)},pc:function(e){p.readBuffer(e)},Ta:function(e,t,r,i,o,s,l){if(2<=B.version)if(p.se)p.readPixels(e,t,r,i,o,s,l);else{var f=_t(s);p.readPixels(e,t,r,i,o,s,f,l>>31-Math.clz32(f.BYTES_PER_ELEMENT))}else(l=$t(s,o,r,i,l))?p.readPixels(e,t,r,i,o,s,l):j(1280)},$b:function(e,t,r,i){p.renderbufferStorage(e,t,r,i)},Xb:function(e,t,r,i,o){p.renderbufferStorageMultisample(e,t,r,i,o)},Pb:function(e,t,r){p.samplerParameterf(Ie[e],t,r)},Qb:function(e,t,r){p.samplerParameteri(Ie[e],t,r)},Rb:function(e,t,r){p.samplerParameteri(Ie[e],t,w[r>>2])},Ua:function(e,t,r,i){p.scissor(e,t,r,i)},Va:function(e,t,r,i){for(var o="",s=0;s<t;++s){var l=i?w[i+4*s>>2]:-1,f=w[r+4*s>>2];l=f?Re(G,f,0>l?void 0:l):"",o+=l}p.shaderSource(ce[e],o)},Wa:function(e,t,r){p.stencilFunc(e,t,r)},Xa:function(e,t,r,i){p.stencilFuncSeparate(e,t,r,i)},Ya:function(e){p.stencilMask(e)},Za:function(e,t){p.stencilMaskSeparate(e,t)},_a:function(e,t,r){p.stencilOp(e,t,r)},$a:function(e,t,r,i){p.stencilOpSeparate(e,t,r,i)},ab:function(e,t,r,i,o,s,l,f,h){if(2<=B.version)if(p.Zd)p.texImage2D(e,t,r,i,o,s,l,f,h);else if(h){var g=_t(f);p.texImage2D(e,t,r,i,o,s,l,f,g,h>>31-Math.clz32(g.BYTES_PER_ELEMENT))}else p.texImage2D(e,t,r,i,o,s,l,f,null);else p.texImage2D(e,t,r,i,o,s,l,f,h?$t(f,l,i,o,h):null)},bb:function(e,t,r){p.texParameterf(e,t,r)},cb:function(e,t,r){p.texParameterf(e,t,R[r>>2])},db:function(e,t,r){p.texParameteri(e,t,r)},eb:function(e,t,r){p.texParameteri(e,t,w[r>>2])},jc:function(e,t,r,i,o){p.texStorage2D(e,t,r,i,o)},fb:function(e,t,r,i,o,s,l,f,h){if(2<=B.version)if(p.Zd)p.texSubImage2D(e,t,r,i,o,s,l,f,h);else if(h){var g=_t(f);p.texSubImage2D(e,t,r,i,o,s,l,f,g,h>>31-Math.clz32(g.BYTES_PER_ELEMENT))}else p.texSubImage2D(e,t,r,i,o,s,l,f,null);else g=null,h&&(g=$t(f,l,o,s,h)),p.texSubImage2D(e,t,r,i,o,s,l,f,g)},gb:function(e,t){p.uniform1f(H(e),t)},hb:function(e,t,r){if(2<=B.version)t&&p.uniform1fv(H(e),R,r>>2,t);else{if(288>=t)for(var i=Te[t-1],o=0;o<t;++o)i[o]=R[r+4*o>>2];else i=R.subarray(r>>2,r+4*t>>2);p.uniform1fv(H(e),i)}},Uc:function(e,t){p.uniform1i(H(e),t)},Vc:function(e,t,r){if(2<=B.version)t&&p.uniform1iv(H(e),w,r>>2,t);else{if(288>=t)for(var i=Ze[t-1],o=0;o<t;++o)i[o]=w[r+4*o>>2];else i=w.subarray(r>>2,r+4*t>>2);p.uniform1iv(H(e),i)}},Wc:function(e,t,r){p.uniform2f(H(e),t,r)},Xc:function(e,t,r){if(2<=B.version)t&&p.uniform2fv(H(e),R,r>>2,2*t);else{if(144>=t)for(var i=Te[2*t-1],o=0;o<2*t;o+=2)i[o]=R[r+4*o>>2],i[o+1]=R[r+(4*o+4)>>2];else i=R.subarray(r>>2,r+8*t>>2);p.uniform2fv(H(e),i)}},Tc:function(e,t,r){p.uniform2i(H(e),t,r)},Sc:function(e,t,r){if(2<=B.version)t&&p.uniform2iv(H(e),w,r>>2,2*t);else{if(144>=t)for(var i=Ze[2*t-1],o=0;o<2*t;o+=2)i[o]=w[r+4*o>>2],i[o+1]=w[r+(4*o+4)>>2];else i=w.subarray(r>>2,r+8*t>>2);p.uniform2iv(H(e),i)}},Rc:function(e,t,r,i){p.uniform3f(H(e),t,r,i)},Qc:function(e,t,r){if(2<=B.version)t&&p.uniform3fv(H(e),R,r>>2,3*t);else{if(96>=t)for(var i=Te[3*t-1],o=0;o<3*t;o+=3)i[o]=R[r+4*o>>2],i[o+1]=R[r+(4*o+4)>>2],i[o+2]=R[r+(4*o+8)>>2];else i=R.subarray(r>>2,r+12*t>>2);p.uniform3fv(H(e),i)}},Pc:function(e,t,r,i){p.uniform3i(H(e),t,r,i)},Oc:function(e,t,r){if(2<=B.version)t&&p.uniform3iv(H(e),w,r>>2,3*t);else{if(96>=t)for(var i=Ze[3*t-1],o=0;o<3*t;o+=3)i[o]=w[r+4*o>>2],i[o+1]=w[r+(4*o+4)>>2],i[o+2]=w[r+(4*o+8)>>2];else i=w.subarray(r>>2,r+12*t>>2);p.uniform3iv(H(e),i)}},Nc:function(e,t,r,i,o){p.uniform4f(H(e),t,r,i,o)},Mc:function(e,t,r){if(2<=B.version)t&&p.uniform4fv(H(e),R,r>>2,4*t);else{if(72>=t){var i=Te[4*t-1],o=R;r>>=2;for(var s=0;s<4*t;s+=4){var l=r+s;i[s]=o[l],i[s+1]=o[l+1],i[s+2]=o[l+2],i[s+3]=o[l+3]}}else i=R.subarray(r>>2,r+16*t>>2);p.uniform4fv(H(e),i)}},Ac:function(e,t,r,i,o){p.uniform4i(H(e),t,r,i,o)},Bc:function(e,t,r){if(2<=B.version)t&&p.uniform4iv(H(e),w,r>>2,4*t);else{if(72>=t)for(var i=Ze[4*t-1],o=0;o<4*t;o+=4)i[o]=w[r+4*o>>2],i[o+1]=w[r+(4*o+4)>>2],i[o+2]=w[r+(4*o+8)>>2],i[o+3]=w[r+(4*o+12)>>2];else i=w.subarray(r>>2,r+16*t>>2);p.uniform4iv(H(e),i)}},Cc:function(e,t,r,i){if(2<=B.version)t&&p.uniformMatrix2fv(H(e),!!r,R,i>>2,4*t);else{if(72>=t)for(var o=Te[4*t-1],s=0;s<4*t;s+=4)o[s]=R[i+4*s>>2],o[s+1]=R[i+(4*s+4)>>2],o[s+2]=R[i+(4*s+8)>>2],o[s+3]=R[i+(4*s+12)>>2];else o=R.subarray(i>>2,i+16*t>>2);p.uniformMatrix2fv(H(e),!!r,o)}},Dc:function(e,t,r,i){if(2<=B.version)t&&p.uniformMatrix3fv(H(e),!!r,R,i>>2,9*t);else{if(32>=t)for(var o=Te[9*t-1],s=0;s<9*t;s+=9)o[s]=R[i+4*s>>2],o[s+1]=R[i+(4*s+4)>>2],o[s+2]=R[i+(4*s+8)>>2],o[s+3]=R[i+(4*s+12)>>2],o[s+4]=R[i+(4*s+16)>>2],o[s+5]=R[i+(4*s+20)>>2],o[s+6]=R[i+(4*s+24)>>2],o[s+7]=R[i+(4*s+28)>>2],o[s+8]=R[i+(4*s+32)>>2];else o=R.subarray(i>>2,i+36*t>>2);p.uniformMatrix3fv(H(e),!!r,o)}},Ec:function(e,t,r,i){if(2<=B.version)t&&p.uniformMatrix4fv(H(e),!!r,R,i>>2,16*t);else{if(18>=t){var o=Te[16*t-1],s=R;i>>=2;for(var l=0;l<16*t;l+=16){var f=i+l;o[l]=s[f],o[l+1]=s[f+1],o[l+2]=s[f+2],o[l+3]=s[f+3],o[l+4]=s[f+4],o[l+5]=s[f+5],o[l+6]=s[f+6],o[l+7]=s[f+7],o[l+8]=s[f+8],o[l+9]=s[f+9],o[l+10]=s[f+10],o[l+11]=s[f+11],o[l+12]=s[f+12],o[l+13]=s[f+13],o[l+14]=s[f+14],o[l+15]=s[f+15]}}else o=R.subarray(i>>2,i+64*t>>2);p.uniformMatrix4fv(H(e),!!r,o)}},Fc:function(e){e=fe[e],p.useProgram(e),p.Re=e},Gc:function(e,t){p.vertexAttrib1f(e,t)},Hc:function(e,t){p.vertexAttrib2f(e,R[t>>2],R[t+4>>2])},Ic:function(e,t){p.vertexAttrib3f(e,R[t>>2],R[t+4>>2],R[t+8>>2])},Jc:function(e,t){p.vertexAttrib4f(e,R[t>>2],R[t+4>>2],R[t+8>>2],R[t+12>>2])},kc:function(e,t){p.vertexAttribDivisor(e,t)},lc:function(e,t,r,i,o){p.vertexAttribIPointer(e,t,r,i,o)},Kc:function(e,t,r,i,o,s){p.vertexAttribPointer(e,t,r,!!i,o,s)},Lc:function(e,t,r,i){p.viewport(e,t,r,i)},qb:function(e,t,r,i){p.waitSync(De[e],t,(r>>>0)+4294967296*i)},W:jn,F:Hn,E:Wn,X:Un,Ib:Nn,V:Sn,U:Yn,A:Vn,B:$n,D:On,L:kn,sb:(e,t,r,i)=>Bn(e,t,r,i)};(function(){function e(r){if(b=r=r.exports,nt=b.Yc,rr(),Q=b._c,ir.unshift(b.Zc),Me--,m.monitorRunDependencies&&m.monitorRunDependencies(Me),Me==0&&(Mt!==null&&(clearInterval(Mt),Mt=null),We)){var i=We;We=null,i()}return r}var t={a:bn};if(Me++,m.monitorRunDependencies&&m.monitorRunDependencies(Me),m.instantiateWasm)try{return m.instantiateWasm(t,e)}catch(r){Ae("Module.instantiateWasm callback failed with error: "+r),et(r)}return rn(t,function(r){e(r.instance)}).catch(et),{}})();var Pe=m._free=e=>(Pe=m._free=b.$c)(e),Ct=m._malloc=e=>(Ct=m._malloc=b.ad)(e),Wr=e=>(Wr=b.bd)(e);m.__embind_initialize_bindings=()=>(m.__embind_initialize_bindings=b.cd)();var ne=(e,t)=>(ne=b.dd)(e,t),ie=()=>(ie=b.ed)(),oe=e=>(oe=b.fd)(e);m.dynCall_viji=(e,t,r,i,o)=>(m.dynCall_viji=b.gd)(e,t,r,i,o),m.dynCall_vijiii=(e,t,r,i,o,s,l)=>(m.dynCall_vijiii=b.hd)(e,t,r,i,o,s,l),m.dynCall_viiiiij=(e,t,r,i,o,s,l,f)=>(m.dynCall_viiiiij=b.id)(e,t,r,i,o,s,l,f),m.dynCall_jii=(e,t,r)=>(m.dynCall_jii=b.jd)(e,t,r),m.dynCall_vij=(e,t,r,i)=>(m.dynCall_vij=b.kd)(e,t,r,i),m.dynCall_iiij=(e,t,r,i,o)=>(m.dynCall_iiij=b.ld)(e,t,r,i,o),m.dynCall_iiiij=(e,t,r,i,o,s)=>(m.dynCall_iiiij=b.md)(e,t,r,i,o,s),m.dynCall_viij=(e,t,r,i,o)=>(m.dynCall_viij=b.nd)(e,t,r,i,o),m.dynCall_viiij=(e,t,r,i,o,s)=>(m.dynCall_viiij=b.od)(e,t,r,i,o,s),m.dynCall_ji=(e,t)=>(m.dynCall_ji=b.pd)(e,t),m.dynCall_iij=(e,t,r,i)=>(m.dynCall_iij=b.qd)(e,t,r,i),m.dynCall_jiiiiii=(e,t,r,i,o,s,l)=>(m.dynCall_jiiiiii=b.rd)(e,t,r,i,o,s,l),m.dynCall_jiiiiji=(e,t,r,i,o,s,l,f)=>(m.dynCall_jiiiiji=b.sd)(e,t,r,i,o,s,l,f),m.dynCall_iijj=(e,t,r,i,o,s)=>(m.dynCall_iijj=b.td)(e,t,r,i,o,s),m.dynCall_iiiji=(e,t,r,i,o,s)=>(m.dynCall_iiiji=b.ud)(e,t,r,i,o,s),m.dynCall_iiji=(e,t,r,i,o)=>(m.dynCall_iiji=b.vd)(e,t,r,i,o),m.dynCall_iijjiii=(e,t,r,i,o,s,l,f,h)=>(m.dynCall_iijjiii=b.wd)(e,t,r,i,o,s,l,f,h),m.dynCall_vijjjii=(e,t,r,i,o,s,l,f,h,g)=>(m.dynCall_vijjjii=b.xd)(e,t,r,i,o,s,l,f,h,g),m.dynCall_jiji=(e,t,r,i,o)=>(m.dynCall_jiji=b.yd)(e,t,r,i,o),m.dynCall_viijii=(e,t,r,i,o,s,l)=>(m.dynCall_viijii=b.zd)(e,t,r,i,o,s,l),m.dynCall_iiiiij=(e,t,r,i,o,s,l)=>(m.dynCall_iiiiij=b.Ad)(e,t,r,i,o,s,l),m.dynCall_iiiiijj=(e,t,r,i,o,s,l,f,h)=>(m.dynCall_iiiiijj=b.Bd)(e,t,r,i,o,s,l,f,h),m.dynCall_iiiiiijj=(e,t,r,i,o,s,l,f,h,g)=>(m.dynCall_iiiiiijj=b.Cd)(e,t,r,i,o,s,l,f,h,g);function kn(e,t,r,i,o){var s=ie();try{Q.get(e)(t,r,i,o)}catch(l){if(oe(s),l!==l+0)throw l;ne(1,0)}}function Hn(e,t,r){var i=ie();try{return Q.get(e)(t,r)}catch(o){if(oe(i),o!==o+0)throw o;ne(1,0)}}function Un(e,t,r,i,o){var s=ie();try{return Q.get(e)(t,r,i,o)}catch(l){if(oe(s),l!==l+0)throw l;ne(1,0)}}function On(e,t,r,i){var o=ie();try{Q.get(e)(t,r,i)}catch(s){if(oe(o),s!==s+0)throw s;ne(1,0)}}function jn(e,t){var r=ie();try{return Q.get(e)(t)}catch(i){if(oe(r),i!==i+0)throw i;ne(1,0)}}function Wn(e,t,r,i){var o=ie();try{return Q.get(e)(t,r,i)}catch(s){if(oe(o),s!==s+0)throw s;ne(1,0)}}function $n(e,t,r){var i=ie();try{Q.get(e)(t,r)}catch(o){if(oe(i),o!==o+0)throw o;ne(1,0)}}function Sn(e,t,r,i,o,s,l,f,h,g){var P=ie();try{return Q.get(e)(t,r,i,o,s,l,f,h,g)}catch(E){if(oe(P),E!==E+0)throw E;ne(1,0)}}function Vn(e,t){var r=ie();try{Q.get(e)(t)}catch(i){if(oe(r),i!==i+0)throw i;ne(1,0)}}function Nn(e,t,r,i,o,s,l){var f=ie();try{return Q.get(e)(t,r,i,o,s,l)}catch(h){if(oe(f),h!==h+0)throw h;ne(1,0)}}function Yn(e){var t=ie();try{Q.get(e)()}catch(r){if(oe(t),r!==r+0)throw r;ne(1,0)}}var At;We=function e(){At||$r(),At||(We=e)};function $r(){function e(){if(!At&&(At=!0,m.calledRun=!0,!er)){if(xt(ir),Jt(m),m.onRuntimeInitialized&&m.onRuntimeInitialized(),m.postRun)for(typeof m.postRun=="function"&&(m.postRun=[m.postRun]);m.postRun.length;){var t=m.postRun.shift();or.unshift(t)}xt(or)}}if(!(0<Me)){if(m.preRun)for(typeof m.preRun=="function"&&(m.preRun=[m.preRun]);m.preRun.length;)en();xt(nr),0<Me||(m.setStatus?(m.setStatus("Running..."),setTimeout(function(){setTimeout(function(){m.setStatus("")},1),e()},1)):e())}}if(m.preInit)for(typeof m.preInit=="function"&&(m.preInit=[m.preInit]);0<m.preInit.length;)m.preInit.pop()();return $r(),ge.ready}})();typeof zr=="object"&&typeof Kt=="object"?Kt.exports=Zr:typeof define=="function"&&define.amd&&define([],()=>Zr)});export default Jn();
1
+ var Un=(ze,Te)=>()=>(Te||ze((Te={exports:{}}).exports,Te),Te.exports);var jn=Un((Sr,Wt)=>{var Wr=(()=>{var ze=typeof document<"u"&&document.currentScript?document.currentScript.src:void 0;return function(Te={}){var _=Te,St,qe;_.ready=new Promise((e,t)=>{St=e,qe=t}),function(e){e.Id=e.Id||[],e.Id.push(function(){e.MakeSWCanvasSurface=function(t){var r=t,i=typeof OffscreenCanvas<"u"&&r instanceof OffscreenCanvas;if(!(typeof HTMLCanvasElement<"u"&&r instanceof HTMLCanvasElement||i||(r=document.getElementById(t),r)))throw"Canvas with id "+t+" was not found";return(t=e.MakeSurface(r.width,r.height))&&(t.ie=r),t},e.MakeCanvasSurface||(e.MakeCanvasSurface=e.MakeSWCanvasSurface),e.MakeSurface=function(t,r){var i={width:t,height:r,colorType:e.ColorType.RGBA_8888,alphaType:e.AlphaType.Unpremul,colorSpace:e.ColorSpace.SRGB},o=t*r*4,s=e._malloc(o);return(i=e.Surface._makeRasterDirect(i,s,4*t))&&(i.ie=null,i.Pe=t,i.Me=r,i.Ne=o,i.re=s,i.getCanvas().clear(e.TRANSPARENT)),i},e.MakeRasterDirectSurface=function(t,r,i){return e.Surface._makeRasterDirect(t,r.byteOffset,i)},e.Surface.prototype.flush=function(t){if(e.Fd(this.Ed),this._flush(),this.ie){var r=new Uint8ClampedArray(e.HEAPU8.buffer,this.re,this.Ne);r=new ImageData(r,this.Pe,this.Me),t?this.ie.getContext("2d").putImageData(r,0,0,t[0],t[1],t[2]-t[0],t[3]-t[1]):this.ie.getContext("2d").putImageData(r,0,0)}},e.Surface.prototype.dispose=function(){this.re&&e._free(this.re),this.delete()},e.Fd=e.Fd||function(){},e.je=e.je||function(){return null}})}(_),function(e){e.Id=e.Id||[],e.Id.push(function(){function t(c,h,g){return c&&c.hasOwnProperty(h)?c[h]:g}function r(c){var h=ke(te);return te[h]=c,h}function i(c){return c.naturalHeight||c.videoHeight||c.displayHeight||c.height}function o(c){return c.naturalWidth||c.videoWidth||c.displayWidth||c.width}function s(c,h,g,P){return c.bindTexture(c.TEXTURE_2D,h),P||g.alphaType!==e.AlphaType.Premul||c.pixelStorei(c.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0),h}function l(c,h,g){g||h.alphaType!==e.AlphaType.Premul||c.pixelStorei(c.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),c.bindTexture(c.TEXTURE_2D,null)}e.GetWebGLContext=function(c,h){if(!c)throw"null canvas passed into makeWebGLContext";var g={alpha:t(h,"alpha",1),depth:t(h,"depth",1),stencil:t(h,"stencil",8),antialias:t(h,"antialias",0),premultipliedAlpha:t(h,"premultipliedAlpha",1),preserveDrawingBuffer:t(h,"preserveDrawingBuffer",0),preferLowPowerToHighPerformance:t(h,"preferLowPowerToHighPerformance",0),failIfMajorPerformanceCaveat:t(h,"failIfMajorPerformanceCaveat",0),enableExtensionsByDefault:t(h,"enableExtensionsByDefault",1),explicitSwapControl:t(h,"explicitSwapControl",0),renderViaOffscreenBackBuffer:t(h,"renderViaOffscreenBackBuffer",0)};if(g.majorVersion=h&&h.majorVersion?h.majorVersion:typeof WebGL2RenderingContext<"u"?2:1,g.explicitSwapControl)throw"explicitSwapControl is not supported";return c=_n(c,g),c?(wr(c),B.Qd.getExtension("WEBGL_debug_renderer_info"),c):0},e.deleteContext=function(c){B===ye[c]&&(B=null),typeof JSEvents=="object"&&JSEvents.tf(ye[c].Qd.canvas),ye[c]&&ye[c].Qd.canvas&&(ye[c].Qd.canvas.Ke=void 0),ye[c]=null},e._setTextureCleanup({deleteTexture:function(c,h){var g=te[h];g&&ye[c].Qd.deleteTexture(g),te[h]=null}}),e.MakeWebGLContext=function(c){if(!this.Fd(c))return null;var h=this._MakeGrContext();if(!h)return null;h.Ed=c;var g=h.delete.bind(h);return h.delete=function(){e.Fd(this.Ed),g()}.bind(h),B.te=h},e.MakeGrContext=e.MakeWebGLContext,e.GrDirectContext.prototype.getResourceCacheLimitBytes=function(){e.Fd(this.Ed),this._getResourceCacheLimitBytes()},e.GrDirectContext.prototype.getResourceCacheUsageBytes=function(){e.Fd(this.Ed),this._getResourceCacheUsageBytes()},e.GrDirectContext.prototype.releaseResourcesAndAbandonContext=function(){e.Fd(this.Ed),this._releaseResourcesAndAbandonContext()},e.GrDirectContext.prototype.setResourceCacheLimitBytes=function(c){e.Fd(this.Ed),this._setResourceCacheLimitBytes(c)},e.MakeOnScreenGLSurface=function(c,h,g,P,A,T){return!this.Fd(c.Ed)||(h=A===void 0||T===void 0?this._MakeOnScreenGLSurface(c,h,g,P):this._MakeOnScreenGLSurface(c,h,g,P,A,T),!h)?null:(h.Ed=c.Ed,h)},e.MakeRenderTarget=function(){var c=arguments[0];if(!this.Fd(c.Ed))return null;if(arguments.length===3){var h=this._MakeRenderTargetWH(c,arguments[1],arguments[2]);if(!h)return null}else if(arguments.length===2){if(h=this._MakeRenderTargetII(c,arguments[1]),!h)return null}else return null;return h.Ed=c.Ed,h},e.MakeWebGLCanvasSurface=function(c,h,g){h=h||null;var P=c,A=typeof OffscreenCanvas<"u"&&P instanceof OffscreenCanvas;if(!(typeof HTMLCanvasElement<"u"&&P instanceof HTMLCanvasElement||A||(P=document.getElementById(c),P)))throw"Canvas with id "+c+" was not found";if(c=this.GetWebGLContext(P,g),!c||0>c)throw"failed to create webgl context: err "+c;return c=this.MakeWebGLContext(c),h=this.MakeOnScreenGLSurface(c,P.width,P.height,h),h||(h=P.cloneNode(!0),P.parentNode.replaceChild(h,P),h.classList.add("ck-replaced"),e.MakeSWCanvasSurface(h))},e.MakeCanvasSurface=e.MakeWebGLCanvasSurface,e.Surface.prototype.makeImageFromTexture=function(c,h){return e.Fd(this.Ed),c=r(c),(h=this._makeImageFromTexture(this.Ed,c,h))&&(h.de=c),h},e.Surface.prototype.makeImageFromTextureSource=function(c,h,g){h||(h={height:i(c),width:o(c),colorType:e.ColorType.RGBA_8888,alphaType:g?e.AlphaType.Premul:e.AlphaType.Unpremul}),h.colorSpace||(h.colorSpace=e.ColorSpace.SRGB),e.Fd(this.Ed);var P=B.Qd;return g=s(P,P.createTexture(),h,g),B.version===2?P.texImage2D(P.TEXTURE_2D,0,P.RGBA,h.width,h.height,0,P.RGBA,P.UNSIGNED_BYTE,c):P.texImage2D(P.TEXTURE_2D,0,P.RGBA,P.RGBA,P.UNSIGNED_BYTE,c),l(P,h),this._resetContext(),this.makeImageFromTexture(g,h)},e.Surface.prototype.updateTextureFromSource=function(c,h,g){if(c.de){e.Fd(this.Ed);var P=c.getImageInfo(),A=B.Qd,T=s(A,te[c.de],P,g);B.version===2?A.texImage2D(A.TEXTURE_2D,0,A.RGBA,o(h),i(h),0,A.RGBA,A.UNSIGNED_BYTE,h):A.texImage2D(A.TEXTURE_2D,0,A.RGBA,A.RGBA,A.UNSIGNED_BYTE,h),l(A,P,g),this._resetContext(),te[c.de]=null,c.de=r(T),P.colorSpace=c.getColorSpace(),h=this._makeImageFromTexture(this.Ed,c.de,P),g=c.Dd.Hd,A=c.Dd.Ld,c.Dd.Hd=h.Dd.Hd,c.Dd.Ld=h.Dd.Ld,h.Dd.Hd=g,h.Dd.Ld=A,h.delete(),P.colorSpace.delete()}},e.MakeLazyImageFromTextureSource=function(c,h,g){h||(h={height:i(c),width:o(c),colorType:e.ColorType.RGBA_8888,alphaType:g?e.AlphaType.Premul:e.AlphaType.Unpremul}),h.colorSpace||(h.colorSpace=e.ColorSpace.SRGB);var P={makeTexture:function(){var A=B,T=A.Qd,v=s(T,T.createTexture(),h,g);return A.version===2?T.texImage2D(T.TEXTURE_2D,0,T.RGBA,h.width,h.height,0,T.RGBA,T.UNSIGNED_BYTE,c):T.texImage2D(T.TEXTURE_2D,0,T.RGBA,T.RGBA,T.UNSIGNED_BYTE,c),l(T,h,g),r(v)},freeSrc:function(){}};return c.constructor.name==="VideoFrame"&&(P.freeSrc=function(){c.close()}),e.Image._makeFromGenerator(h,P)},e.Fd=function(c){return c?wr(c):!1},e.je=function(){return B&&B.te&&!B.te.isDeleted()?B.te:null}})}(_),function(e){function t(a){return(o(255*a[3])<<24|o(255*a[0])<<16|o(255*a[1])<<8|o(255*a[2])<<0)>>>0}function r(a){if(a&&a._ck)return a;if(a instanceof Float32Array){for(var n=Math.floor(a.length/4),u=new Uint32Array(n),f=0;f<n;f++)u[f]=t(a.slice(4*f,4*(f+1)));return u}if(a instanceof Uint32Array)return a;if(a instanceof Array&&a[0]instanceof Float32Array)return a.map(t)}function i(a){if(a===void 0)return 1;var n=parseFloat(a);return a&&a.indexOf("%")!==-1?n/100:n}function o(a){return Math.round(Math.max(0,Math.min(a||0,255)))}function s(a,n){n&&n._ck||e._free(a)}function l(a,n,u){if(!a||!a.length)return L;if(a&&a._ck)return a.byteOffset;var f=e[n].BYTES_PER_ELEMENT;return u||(u=e._malloc(a.length*f)),e[n].set(a,u/f),u}function c(a){var n={Nd:L,count:a.length,colorType:e.ColorType.RGBA_F32};if(a instanceof Float32Array)n.Nd=l(a,"HEAPF32"),n.count=a.length/4;else if(a instanceof Uint32Array)n.Nd=l(a,"HEAPU32"),n.colorType=e.ColorType.RGBA_8888;else if(a instanceof Array){if(a&&a.length){for(var u=e._malloc(16*a.length),f=0,y=u/4,m=0;m<a.length;m++)for(var C=0;4>C;C++)e.HEAPF32[y+f]=a[m][C],f++;a=u}else a=L;n.Nd=a}else throw"Invalid argument to copyFlexibleColorArray, Not a color array "+typeof a;return n}function h(a){if(!a)return L;var n=$.toTypedArray();if(a.length){if(a.length===6||a.length===9)return l(a,"HEAPF32",x),a.length===6&&e.HEAPF32.set(On,6+x/4),x;if(a.length===16)return n[0]=a[0],n[1]=a[1],n[2]=a[3],n[3]=a[4],n[4]=a[5],n[5]=a[7],n[6]=a[12],n[7]=a[13],n[8]=a[15],x;throw"invalid matrix size"}if(a.m11===void 0)throw"invalid matrix argument";return n[0]=a.m11,n[1]=a.m21,n[2]=a.m41,n[3]=a.m12,n[4]=a.m22,n[5]=a.m42,n[6]=a.m14,n[7]=a.m24,n[8]=a.m44,x}function g(a){if(!a)return L;var n=Y.toTypedArray();if(a.length){if(a.length!==16&&a.length!==6&&a.length!==9)throw"invalid matrix size";return a.length===16?l(a,"HEAPF32",J):(n.fill(0),n[0]=a[0],n[1]=a[1],n[3]=a[2],n[4]=a[3],n[5]=a[4],n[7]=a[5],n[10]=1,n[12]=a[6],n[13]=a[7],n[15]=a[8],a.length===6&&(n[12]=0,n[13]=0,n[15]=1),J)}if(a.m11===void 0)throw"invalid matrix argument";return n[0]=a.m11,n[1]=a.m21,n[2]=a.m31,n[3]=a.m41,n[4]=a.m12,n[5]=a.m22,n[6]=a.m32,n[7]=a.m42,n[8]=a.m13,n[9]=a.m23,n[10]=a.m33,n[11]=a.m43,n[12]=a.m14,n[13]=a.m24,n[14]=a.m34,n[15]=a.m44,J}function P(a,n){return l(a,"HEAPF32",n||ve)}function A(a,n,u,f){var y=He.toTypedArray();return y[0]=a,y[1]=n,y[2]=u,y[3]=f,ve}function T(a){for(var n=new Float32Array(4),u=0;4>u;u++)n[u]=e.HEAPF32[a/4+u];return n}function v(a,n){return l(a,"HEAPF32",n||V)}function M(a,n){return l(a,"HEAPF32",n||Ut)}e.Color=function(a,n,u,f){return f===void 0&&(f=1),e.Color4f(o(a)/255,o(n)/255,o(u)/255,f)},e.ColorAsInt=function(a,n,u,f){return f===void 0&&(f=255),(o(f)<<24|o(a)<<16|o(n)<<8|o(u)<<0&268435455)>>>0},e.Color4f=function(a,n,u,f){return f===void 0&&(f=1),Float32Array.of(a,n,u,f)},Object.defineProperty(e,"TRANSPARENT",{get:function(){return e.Color4f(0,0,0,0)}}),Object.defineProperty(e,"BLACK",{get:function(){return e.Color4f(0,0,0,1)}}),Object.defineProperty(e,"WHITE",{get:function(){return e.Color4f(1,1,1,1)}}),Object.defineProperty(e,"RED",{get:function(){return e.Color4f(1,0,0,1)}}),Object.defineProperty(e,"GREEN",{get:function(){return e.Color4f(0,1,0,1)}}),Object.defineProperty(e,"BLUE",{get:function(){return e.Color4f(0,0,1,1)}}),Object.defineProperty(e,"YELLOW",{get:function(){return e.Color4f(1,1,0,1)}}),Object.defineProperty(e,"CYAN",{get:function(){return e.Color4f(0,1,1,1)}}),Object.defineProperty(e,"MAGENTA",{get:function(){return e.Color4f(1,0,1,1)}}),e.getColorComponents=function(a){return[Math.floor(255*a[0]),Math.floor(255*a[1]),Math.floor(255*a[2]),a[3]]},e.parseColorString=function(a,n){if(a=a.toLowerCase(),a.startsWith("#")){switch(n=255,a.length){case 9:n=parseInt(a.slice(7,9),16);case 7:var u=parseInt(a.slice(1,3),16),f=parseInt(a.slice(3,5),16),y=parseInt(a.slice(5,7),16);break;case 5:n=17*parseInt(a.slice(4,5),16);case 4:u=17*parseInt(a.slice(1,2),16),f=17*parseInt(a.slice(2,3),16),y=17*parseInt(a.slice(3,4),16)}return e.Color(u,f,y,n/255)}return a.startsWith("rgba")?(a=a.slice(5,-1),a=a.split(","),e.Color(+a[0],+a[1],+a[2],i(a[3]))):a.startsWith("rgb")?(a=a.slice(4,-1),a=a.split(","),e.Color(+a[0],+a[1],+a[2],i(a[3]))):a.startsWith("gray(")||a.startsWith("hsl")||!n||(a=n[a],a===void 0)?e.BLACK:a},e.multiplyByAlpha=function(a,n){return a=a.slice(),a[3]=Math.max(0,Math.min(a[3]*n,1)),a},e.Malloc=function(a,n){var u=e._malloc(n*a.BYTES_PER_ELEMENT);return{_ck:!0,length:n,byteOffset:u,Xd:null,subarray:function(f,y){return f=this.toTypedArray().subarray(f,y),f._ck=!0,f},toTypedArray:function(){return this.Xd&&this.Xd.length?this.Xd:(this.Xd=new a(e.HEAPU8.buffer,u,n),this.Xd._ck=!0,this.Xd)}}},e.Free=function(a){e._free(a.byteOffset),a.byteOffset=L,a.toTypedArray=null,a.Xd=null};var x=L,$,J=L,Y,ve=L,He,ce,V=L,kr,Ee=L,br,Ht=L,Hr,Ot=L,Pt,Qe=L,Or,Ut=L,Ur,jr=L,On=Float32Array.of(0,0,1),L=0;e.onRuntimeInitialized=function(){function a(n,u,f,y,m,C,F){C||(C=4*y.width,y.colorType===e.ColorType.RGBA_F16?C*=2:y.colorType===e.ColorType.RGBA_F32&&(C*=4));var D=C*y.height,I=m?m.byteOffset:e._malloc(D);if(F?!n._readPixels(y,I,C,u,f,F):!n._readPixels(y,I,C,u,f))return m||e._free(I),null;if(m)return m.toTypedArray();switch(y.colorType){case e.ColorType.RGBA_8888:case e.ColorType.RGBA_F16:n=new Uint8Array(e.HEAPU8.buffer,I,D).slice();break;case e.ColorType.RGBA_F32:n=new Float32Array(e.HEAPU8.buffer,I,D).slice();break;default:return null}return e._free(I),n}He=e.Malloc(Float32Array,4),ve=He.byteOffset,Y=e.Malloc(Float32Array,16),J=Y.byteOffset,$=e.Malloc(Float32Array,9),x=$.byteOffset,Or=e.Malloc(Float32Array,12),Ut=Or.byteOffset,Ur=e.Malloc(Float32Array,12),jr=Ur.byteOffset,ce=e.Malloc(Float32Array,4),V=ce.byteOffset,kr=e.Malloc(Float32Array,4),Ee=kr.byteOffset,br=e.Malloc(Float32Array,3),Ht=br.byteOffset,Hr=e.Malloc(Float32Array,3),Ot=Hr.byteOffset,Pt=e.Malloc(Int32Array,4),Qe=Pt.byteOffset,e.ColorSpace.SRGB=e.ColorSpace._MakeSRGB(),e.ColorSpace.DISPLAY_P3=e.ColorSpace._MakeDisplayP3(),e.ColorSpace.ADOBE_RGB=e.ColorSpace._MakeAdobeRGB(),e.GlyphRunFlags={IsWhiteSpace:e._GlyphRunFlags_isWhiteSpace},e.Path.MakeFromCmds=function(n){var u=l(n,"HEAPF32"),f=e.Path._MakeFromCmds(u,n.length);return s(u,n),f},e.Path.MakeFromVerbsPointsWeights=function(n,u,f){var y=l(n,"HEAPU8"),m=l(u,"HEAPF32"),C=l(f,"HEAPF32"),F=e.Path._MakeFromVerbsPointsWeights(y,n.length,m,u.length,C,f&&f.length||0);return s(y,n),s(m,u),s(C,f),F},e.Path.prototype.addArc=function(n,u,f){return n=v(n),this._addArc(n,u,f),this},e.Path.prototype.addCircle=function(n,u,f,y){return this._addCircle(n,u,f,!!y),this},e.Path.prototype.addOval=function(n,u,f){return f===void 0&&(f=1),n=v(n),this._addOval(n,!!u,f),this},e.Path.prototype.addPath=function(){var n=Array.prototype.slice.call(arguments),u=n[0],f=!1;if(typeof n[n.length-1]=="boolean"&&(f=n.pop()),n.length===1)this._addPath(u,1,0,0,0,1,0,0,0,1,f);else if(n.length===2)n=n[1],this._addPath(u,n[0],n[1],n[2],n[3],n[4],n[5],n[6]||0,n[7]||0,n[8]||1,f);else if(n.length===7||n.length===10)this._addPath(u,n[1],n[2],n[3],n[4],n[5],n[6],n[7]||0,n[8]||0,n[9]||1,f);else return null;return this},e.Path.prototype.addPoly=function(n,u){var f=l(n,"HEAPF32");return this._addPoly(f,n.length/2,u),s(f,n),this},e.Path.prototype.addRect=function(n,u){return n=v(n),this._addRect(n,!!u),this},e.Path.prototype.addRRect=function(n,u){return n=M(n),this._addRRect(n,!!u),this},e.Path.prototype.addVerbsPointsWeights=function(n,u,f){var y=l(n,"HEAPU8"),m=l(u,"HEAPF32"),C=l(f,"HEAPF32");this._addVerbsPointsWeights(y,n.length,m,u.length,C,f&&f.length||0),s(y,n),s(m,u),s(C,f)},e.Path.prototype.arc=function(n,u,f,y,m,C){return n=e.LTRBRect(n-f,u-f,n+f,u+f),m=(m-y)/Math.PI*180-360*!!C,C=new e.Path,C.addArc(n,y/Math.PI*180,m),this.addPath(C,!0),C.delete(),this},e.Path.prototype.arcToOval=function(n,u,f,y){return n=v(n),this._arcToOval(n,u,f,y),this},e.Path.prototype.arcToRotated=function(n,u,f,y,m,C,F){return this._arcToRotated(n,u,f,!!y,!!m,C,F),this},e.Path.prototype.arcToTangent=function(n,u,f,y,m){return this._arcToTangent(n,u,f,y,m),this},e.Path.prototype.close=function(){return this._close(),this},e.Path.prototype.conicTo=function(n,u,f,y,m){return this._conicTo(n,u,f,y,m),this},e.Path.prototype.computeTightBounds=function(n){this._computeTightBounds(V);var u=ce.toTypedArray();return n?(n.set(u),n):u.slice()},e.Path.prototype.cubicTo=function(n,u,f,y,m,C){return this._cubicTo(n,u,f,y,m,C),this},e.Path.prototype.dash=function(n,u,f){return this._dash(n,u,f)?this:null},e.Path.prototype.getBounds=function(n){this._getBounds(V);var u=ce.toTypedArray();return n?(n.set(u),n):u.slice()},e.Path.prototype.lineTo=function(n,u){return this._lineTo(n,u),this},e.Path.prototype.moveTo=function(n,u){return this._moveTo(n,u),this},e.Path.prototype.offset=function(n,u){return this._transform(1,0,n,0,1,u,0,0,1),this},e.Path.prototype.quadTo=function(n,u,f,y){return this._quadTo(n,u,f,y),this},e.Path.prototype.rArcTo=function(n,u,f,y,m,C,F){return this._rArcTo(n,u,f,y,m,C,F),this},e.Path.prototype.rConicTo=function(n,u,f,y,m){return this._rConicTo(n,u,f,y,m),this},e.Path.prototype.rCubicTo=function(n,u,f,y,m,C){return this._rCubicTo(n,u,f,y,m,C),this},e.Path.prototype.rLineTo=function(n,u){return this._rLineTo(n,u),this},e.Path.prototype.rMoveTo=function(n,u){return this._rMoveTo(n,u),this},e.Path.prototype.rQuadTo=function(n,u,f,y){return this._rQuadTo(n,u,f,y),this},e.Path.prototype.stroke=function(n){return n=n||{},n.width=n.width||1,n.miter_limit=n.miter_limit||4,n.cap=n.cap||e.StrokeCap.Butt,n.join=n.join||e.StrokeJoin.Miter,n.precision=n.precision||1,this._stroke(n)?this:null},e.Path.prototype.transform=function(){if(arguments.length===1){var n=arguments[0];this._transform(n[0],n[1],n[2],n[3],n[4],n[5],n[6]||0,n[7]||0,n[8]||1)}else if(arguments.length===6||arguments.length===9)n=arguments,this._transform(n[0],n[1],n[2],n[3],n[4],n[5],n[6]||0,n[7]||0,n[8]||1);else throw"transform expected to take 1 or 9 arguments. Got "+arguments.length;return this},e.Path.prototype.trim=function(n,u,f){return this._trim(n,u,!!f)?this:null},e.Image.prototype.encodeToBytes=function(n,u){var f=e.je();return n=n||e.ImageFormat.PNG,u=u||100,f?this._encodeToBytes(n,u,f):this._encodeToBytes(n,u)},e.Image.prototype.makeShaderCubic=function(n,u,f,y,m){return m=h(m),this._makeShaderCubic(n,u,f,y,m)},e.Image.prototype.makeShaderOptions=function(n,u,f,y,m){return m=h(m),this._makeShaderOptions(n,u,f,y,m)},e.Image.prototype.readPixels=function(n,u,f,y,m){var C=e.je();return a(this,n,u,f,y,m,C)},e.Canvas.prototype.clear=function(n){e.Fd(this.Ed),n=P(n),this._clear(n)},e.Canvas.prototype.clipRRect=function(n,u,f){e.Fd(this.Ed),n=M(n),this._clipRRect(n,u,f)},e.Canvas.prototype.clipRect=function(n,u,f){e.Fd(this.Ed),n=v(n),this._clipRect(n,u,f)},e.Canvas.prototype.concat=function(n){e.Fd(this.Ed),n=g(n),this._concat(n)},e.Canvas.prototype.drawArc=function(n,u,f,y,m){e.Fd(this.Ed),n=v(n),this._drawArc(n,u,f,y,m)},e.Canvas.prototype.drawAtlas=function(n,u,f,y,m,C,F){if(n&&y&&u&&f&&u.length===f.length){e.Fd(this.Ed),m||(m=e.BlendMode.SrcOver);var D=l(u,"HEAPF32"),I=l(f,"HEAPF32"),W=f.length/4,N=l(r(C),"HEAPU32");if(F&&"B"in F&&"C"in F)this._drawAtlasCubic(n,I,D,N,W,m,F.B,F.C,y);else{let d=e.FilterMode.Linear,w=e.MipmapMode.None;F&&(d=F.filter,"mipmap"in F&&(w=F.mipmap)),this._drawAtlasOptions(n,I,D,N,W,m,d,w,y)}s(D,u),s(I,f),s(N,C)}},e.Canvas.prototype.drawCircle=function(n,u,f,y){e.Fd(this.Ed),this._drawCircle(n,u,f,y)},e.Canvas.prototype.drawColor=function(n,u){e.Fd(this.Ed),n=P(n),u!==void 0?this._drawColor(n,u):this._drawColor(n)},e.Canvas.prototype.drawColorInt=function(n,u){e.Fd(this.Ed),this._drawColorInt(n,u||e.BlendMode.SrcOver)},e.Canvas.prototype.drawColorComponents=function(n,u,f,y,m){e.Fd(this.Ed),n=A(n,u,f,y),m!==void 0?this._drawColor(n,m):this._drawColor(n)},e.Canvas.prototype.drawDRRect=function(n,u,f){e.Fd(this.Ed),n=M(n,Ut),u=M(u,jr),this._drawDRRect(n,u,f)},e.Canvas.prototype.drawImage=function(n,u,f,y){e.Fd(this.Ed),this._drawImage(n,u,f,y||null)},e.Canvas.prototype.drawImageCubic=function(n,u,f,y,m,C){e.Fd(this.Ed),this._drawImageCubic(n,u,f,y,m,C||null)},e.Canvas.prototype.drawImageOptions=function(n,u,f,y,m,C){e.Fd(this.Ed),this._drawImageOptions(n,u,f,y,m,C||null)},e.Canvas.prototype.drawImageNine=function(n,u,f,y,m){e.Fd(this.Ed),u=l(u,"HEAP32",Qe),f=v(f),this._drawImageNine(n,u,f,y,m||null)},e.Canvas.prototype.drawImageRect=function(n,u,f,y,m){e.Fd(this.Ed),v(u,V),v(f,Ee),this._drawImageRect(n,V,Ee,y,!!m)},e.Canvas.prototype.drawImageRectCubic=function(n,u,f,y,m,C){e.Fd(this.Ed),v(u,V),v(f,Ee),this._drawImageRectCubic(n,V,Ee,y,m,C||null)},e.Canvas.prototype.drawImageRectOptions=function(n,u,f,y,m,C){e.Fd(this.Ed),v(u,V),v(f,Ee),this._drawImageRectOptions(n,V,Ee,y,m,C||null)},e.Canvas.prototype.drawLine=function(n,u,f,y,m){e.Fd(this.Ed),this._drawLine(n,u,f,y,m)},e.Canvas.prototype.drawOval=function(n,u){e.Fd(this.Ed),n=v(n),this._drawOval(n,u)},e.Canvas.prototype.drawPaint=function(n){e.Fd(this.Ed),this._drawPaint(n)},e.Canvas.prototype.drawParagraph=function(n,u,f){e.Fd(this.Ed),this._drawParagraph(n,u,f)},e.Canvas.prototype.drawPatch=function(n,u,f,y,m){if(24>n.length)throw"Need 12 cubic points";if(u&&4>u.length)throw"Need 4 colors";if(f&&8>f.length)throw"Need 4 shader coordinates";e.Fd(this.Ed);let C=l(n,"HEAPF32"),F=u?l(r(u),"HEAPU32"):L,D=f?l(f,"HEAPF32"):L;y||(y=e.BlendMode.Modulate),this._drawPatch(C,F,D,y,m),s(D,f),s(F,u),s(C,n)},e.Canvas.prototype.drawPath=function(n,u){e.Fd(this.Ed),this._drawPath(n,u)},e.Canvas.prototype.drawPicture=function(n){e.Fd(this.Ed),this._drawPicture(n)},e.Canvas.prototype.drawPoints=function(n,u,f){e.Fd(this.Ed);var y=l(u,"HEAPF32");this._drawPoints(n,y,u.length/2,f),s(y,u)},e.Canvas.prototype.drawRRect=function(n,u){e.Fd(this.Ed),n=M(n),this._drawRRect(n,u)},e.Canvas.prototype.drawRect=function(n,u){e.Fd(this.Ed),n=v(n),this._drawRect(n,u)},e.Canvas.prototype.drawRect4f=function(n,u,f,y,m){e.Fd(this.Ed),this._drawRect4f(n,u,f,y,m)},e.Canvas.prototype.drawShadow=function(n,u,f,y,m,C,F){e.Fd(this.Ed);var D=l(m,"HEAPF32"),I=l(C,"HEAPF32");u=l(u,"HEAPF32",Ht),f=l(f,"HEAPF32",Ot),this._drawShadow(n,u,f,y,D,I,F),s(D,m),s(I,C)},e.getShadowLocalBounds=function(n,u,f,y,m,C,F){return n=h(n),f=l(f,"HEAPF32",Ht),y=l(y,"HEAPF32",Ot),this._getShadowLocalBounds(n,u,f,y,m,C,V)?(u=ce.toTypedArray(),F?(F.set(u),F):u.slice()):null},e.Canvas.prototype.drawTextBlob=function(n,u,f,y){e.Fd(this.Ed),this._drawTextBlob(n,u,f,y)},e.Canvas.prototype.drawVertices=function(n,u,f){e.Fd(this.Ed),this._drawVertices(n,u,f)},e.Canvas.prototype.getDeviceClipBounds=function(n){this._getDeviceClipBounds(Qe);var u=Pt.toTypedArray();return n?n.set(u):n=u.slice(),n},e.Canvas.prototype.getLocalToDevice=function(){this._getLocalToDevice(J);for(var n=J,u=Array(16),f=0;16>f;f++)u[f]=e.HEAPF32[n/4+f];return u},e.Canvas.prototype.getTotalMatrix=function(){this._getTotalMatrix(x);for(var n=Array(9),u=0;9>u;u++)n[u]=e.HEAPF32[x/4+u];return n},e.Canvas.prototype.makeSurface=function(n){return n=this._makeSurface(n),n.Ed=this.Ed,n},e.Canvas.prototype.readPixels=function(n,u,f,y,m){return e.Fd(this.Ed),a(this,n,u,f,y,m)},e.Canvas.prototype.saveLayer=function(n,u,f,y){return u=v(u),this._saveLayer(n||null,u,f||null,y||0)},e.Canvas.prototype.writePixels=function(n,u,f,y,m,C,F,D){if(n.byteLength%(u*f))throw"pixels length must be a multiple of the srcWidth * srcHeight";e.Fd(this.Ed);var I=n.byteLength/(u*f);C=C||e.AlphaType.Unpremul,F=F||e.ColorType.RGBA_8888,D=D||e.ColorSpace.SRGB;var W=I*u;return I=l(n,"HEAPU8"),u=this._writePixels({width:u,height:f,colorType:F,alphaType:C,colorSpace:D},I,W,y,m),s(I,n),u},e.ColorFilter.MakeBlend=function(n,u,f){return n=P(n),f=f||e.ColorSpace.SRGB,e.ColorFilter._MakeBlend(n,u,f)},e.ColorFilter.MakeMatrix=function(n){if(!n||n.length!==20)throw"invalid color matrix";var u=l(n,"HEAPF32"),f=e.ColorFilter._makeMatrix(u);return s(u,n),f},e.ContourMeasure.prototype.getPosTan=function(n,u){return this._getPosTan(n,V),n=ce.toTypedArray(),u?(u.set(n),u):n.slice()},e.ImageFilter.prototype.getOutputBounds=function(n,u,f){return n=v(n,V),u=h(u),this._getOutputBounds(n,u,Qe),u=Pt.toTypedArray(),f?(f.set(u),f):u.slice()},e.ImageFilter.MakeDropShadow=function(n,u,f,y,m,C){return m=P(m,ve),e.ImageFilter._MakeDropShadow(n,u,f,y,m,C)},e.ImageFilter.MakeDropShadowOnly=function(n,u,f,y,m,C){return m=P(m,ve),e.ImageFilter._MakeDropShadowOnly(n,u,f,y,m,C)},e.ImageFilter.MakeImage=function(n,u,f,y){if(f=v(f,V),y=v(y,Ee),"B"in u&&"C"in u)return e.ImageFilter._MakeImageCubic(n,u.B,u.C,f,y);let m=u.filter,C=e.MipmapMode.None;return"mipmap"in u&&(C=u.mipmap),e.ImageFilter._MakeImageOptions(n,m,C,f,y)},e.ImageFilter.MakeMatrixTransform=function(n,u,f){if(n=h(n),"B"in u&&"C"in u)return e.ImageFilter._MakeMatrixTransformCubic(n,u.B,u.C,f);let y=u.filter,m=e.MipmapMode.None;return"mipmap"in u&&(m=u.mipmap),e.ImageFilter._MakeMatrixTransformOptions(n,y,m,f)},e.Paint.prototype.getColor=function(){return this._getColor(ve),T(ve)},e.Paint.prototype.setColor=function(n,u){u=u||null,n=P(n),this._setColor(n,u)},e.Paint.prototype.setColorComponents=function(n,u,f,y,m){m=m||null,n=A(n,u,f,y),this._setColor(n,m)},e.Path.prototype.getPoint=function(n,u){return this._getPoint(n,V),n=ce.toTypedArray(),u?(u[0]=n[0],u[1]=n[1],u):n.slice(0,2)},e.Picture.prototype.makeShader=function(n,u,f,y,m){return y=h(y),m=v(m),this._makeShader(n,u,f,y,m)},e.Picture.prototype.cullRect=function(n){this._cullRect(V);var u=ce.toTypedArray();return n?(n.set(u),n):u.slice()},e.PictureRecorder.prototype.beginRecording=function(n,u){return n=v(n),this._beginRecording(n,!!u)},e.Surface.prototype.getCanvas=function(){var n=this._getCanvas();return n.Ed=this.Ed,n},e.Surface.prototype.makeImageSnapshot=function(n){return e.Fd(this.Ed),n=l(n,"HEAP32",Qe),this._makeImageSnapshot(n)},e.Surface.prototype.makeSurface=function(n){return e.Fd(this.Ed),n=this._makeSurface(n),n.Ed=this.Ed,n},e.Surface.prototype.Oe=function(n,u){return this.ce||(this.ce=this.getCanvas()),requestAnimationFrame(function(){e.Fd(this.Ed),n(this.ce),this.flush(u)}.bind(this))},e.Surface.prototype.requestAnimationFrame||(e.Surface.prototype.requestAnimationFrame=e.Surface.prototype.Oe),e.Surface.prototype.Le=function(n,u){this.ce||(this.ce=this.getCanvas()),requestAnimationFrame(function(){e.Fd(this.Ed),n(this.ce),this.flush(u),this.dispose()}.bind(this))},e.Surface.prototype.drawOnce||(e.Surface.prototype.drawOnce=e.Surface.prototype.Le),e.PathEffect.MakeDash=function(n,u){if(u||(u=0),!n.length||n.length%2===1)throw"Intervals array must have even length";var f=l(n,"HEAPF32");return u=e.PathEffect._MakeDash(f,n.length,u),s(f,n),u},e.PathEffect.MakeLine2D=function(n,u){return u=h(u),e.PathEffect._MakeLine2D(n,u)},e.PathEffect.MakePath2D=function(n,u){return n=h(n),e.PathEffect._MakePath2D(n,u)},e.Shader.MakeColor=function(n,u){return u=u||null,n=P(n),e.Shader._MakeColor(n,u)},e.Shader.Blend=e.Shader.MakeBlend,e.Shader.Color=e.Shader.MakeColor,e.Shader.MakeLinearGradient=function(n,u,f,y,m,C,F,D){D=D||null;var I=c(f),W=l(y,"HEAPF32");F=F||0,C=h(C);var N=ce.toTypedArray();return N.set(n),N.set(u,2),n=e.Shader._MakeLinearGradient(V,I.Nd,I.colorType,W,I.count,m,F,C,D),s(I.Nd,f),y&&s(W,y),n},e.Shader.MakeRadialGradient=function(n,u,f,y,m,C,F,D){D=D||null;var I=c(f),W=l(y,"HEAPF32");return F=F||0,C=h(C),n=e.Shader._MakeRadialGradient(n[0],n[1],u,I.Nd,I.colorType,W,I.count,m,F,C,D),s(I.Nd,f),y&&s(W,y),n},e.Shader.MakeSweepGradient=function(n,u,f,y,m,C,F,D,I,W){W=W||null;var N=c(f),d=l(y,"HEAPF32");return F=F||0,D=D||0,I=I||360,C=h(C),n=e.Shader._MakeSweepGradient(n,u,N.Nd,N.colorType,d,N.count,m,D,I,F,C,W),s(N.Nd,f),y&&s(d,y),n},e.Shader.MakeTwoPointConicalGradient=function(n,u,f,y,m,C,F,D,I,W){W=W||null;var N=c(m),d=l(C,"HEAPF32");I=I||0,D=h(D);var w=ce.toTypedArray();return w.set(n),w.set(f,2),n=e.Shader._MakeTwoPointConicalGradient(V,u,y,N.Nd,N.colorType,d,N.count,F,I,D,W),s(N.Nd,m),C&&s(d,C),n},e.Vertices.prototype.bounds=function(n){this._bounds(V);var u=ce.toTypedArray();return n?(n.set(u),n):u.slice()},e.Id&&e.Id.forEach(function(n){n()})},e.computeTonalColors=function(a){var n=l(a.ambient,"HEAPF32"),u=l(a.spot,"HEAPF32");this._computeTonalColors(n,u);var f={ambient:T(n),spot:T(u)};return s(n,a.ambient),s(u,a.spot),f},e.LTRBRect=function(a,n,u,f){return Float32Array.of(a,n,u,f)},e.XYWHRect=function(a,n,u,f){return Float32Array.of(a,n,a+u,n+f)},e.LTRBiRect=function(a,n,u,f){return Int32Array.of(a,n,u,f)},e.XYWHiRect=function(a,n,u,f){return Int32Array.of(a,n,a+u,n+f)},e.RRectXY=function(a,n,u){return Float32Array.of(a[0],a[1],a[2],a[3],n,u,n,u,n,u,n,u)},e.MakeAnimatedImageFromEncoded=function(a){a=new Uint8Array(a);var n=e._malloc(a.byteLength);return e.HEAPU8.set(a,n),(a=e._decodeAnimatedImage(n,a.byteLength))?a:null},e.MakeImageFromEncoded=function(a){a=new Uint8Array(a);var n=e._malloc(a.byteLength);return e.HEAPU8.set(a,n),(a=e._decodeImage(n,a.byteLength))?a:null};var Ze=null;e.MakeImageFromCanvasImageSource=function(a){var n=a.width,u=a.height;Ze||(Ze=document.createElement("canvas")),Ze.width=n,Ze.height=u;var f=Ze.getContext("2d",{willReadFrequently:!0});return f.drawImage(a,0,0),a=f.getImageData(0,0,n,u),e.MakeImage({width:n,height:u,alphaType:e.AlphaType.Unpremul,colorType:e.ColorType.RGBA_8888,colorSpace:e.ColorSpace.SRGB},a.data,4*n)},e.MakeImage=function(a,n,u){var f=e._malloc(n.length);return e.HEAPU8.set(n,f),e._MakeImage(a,f,n.length,u)},e.MakeVertices=function(a,n,u,f,y,m){var C=y&&y.length||0,F=0;return u&&u.length&&(F|=1),f&&f.length&&(F|=2),m===void 0||m||(F|=4),a=new e._VerticesBuilder(a,n.length/2,C,F),l(n,"HEAPF32",a.positions()),a.texCoords()&&l(u,"HEAPF32",a.texCoords()),a.colors()&&l(r(f),"HEAPU32",a.colors()),a.indices()&&l(y,"HEAPU16",a.indices()),a.detach()},function(a){a.Id=a.Id||[],a.Id.push(function(){function n(d){return d&&(d.dir=d.dir===0?a.TextDirection.RTL:a.TextDirection.LTR),d}function u(d){if(!d||!d.length)return[];for(var w=[],O=0;O<d.length;O+=5){var X=a.LTRBRect(d[O],d[O+1],d[O+2],d[O+3]),ge=a.TextDirection.LTR;d[O+4]===0&&(ge=a.TextDirection.RTL),w.push({rect:X,dir:ge})}return a._free(d.byteOffset),w}function f(d){return d=d||{},d.weight===void 0&&(d.weight=a.FontWeight.Normal),d.width=d.width||a.FontWidth.Normal,d.slant=d.slant||a.FontSlant.Upright,d}function y(d){if(!d||!d.length)return L;for(var w=[],O=0;O<d.length;O++){var X=m(d[O]);w.push(X)}return l(w,"HEAPU32")}function m(d){if(D[d])return D[d];var w=ue(d)+1,O=a._malloc(w);return ae(d,G,O,w),D[d]=O}function C(d){if(d._colorPtr=P(d.color),d._foregroundColorPtr=L,d._backgroundColorPtr=L,d._decorationColorPtr=L,d.foregroundColor&&(d._foregroundColorPtr=P(d.foregroundColor,I)),d.backgroundColor&&(d._backgroundColorPtr=P(d.backgroundColor,W)),d.decorationColor&&(d._decorationColorPtr=P(d.decorationColor,N)),Array.isArray(d.fontFamilies)&&d.fontFamilies.length?(d._fontFamiliesPtr=y(d.fontFamilies),d._fontFamiliesLen=d.fontFamilies.length):(d._fontFamiliesPtr=L,d._fontFamiliesLen=0),d.locale){var w=d.locale;d._localePtr=m(w),d._localeLen=ue(w)+1}else d._localePtr=L,d._localeLen=0;if(Array.isArray(d.shadows)&&d.shadows.length){w=d.shadows;var O=w.map(function(fe){return fe.color||a.BLACK}),X=w.map(function(fe){return fe.blurRadius||0});d._shadowLen=w.length;for(var ge=a._malloc(8*w.length),jt=ge/4,$t=0;$t<w.length;$t++){var $r=w[$t].offset||[0,0];a.HEAPF32[jt]=$r[0],a.HEAPF32[jt+1]=$r[1],jt+=2}d._shadowColorsPtr=c(O).Nd,d._shadowOffsetsPtr=ge,d._shadowBlurRadiiPtr=l(X,"HEAPF32")}else d._shadowLen=0,d._shadowColorsPtr=L,d._shadowOffsetsPtr=L,d._shadowBlurRadiiPtr=L;Array.isArray(d.fontFeatures)&&d.fontFeatures.length?(w=d.fontFeatures,O=w.map(function(fe){return fe.name}),X=w.map(function(fe){return fe.value}),d._fontFeatureLen=w.length,d._fontFeatureNamesPtr=y(O),d._fontFeatureValuesPtr=l(X,"HEAPU32")):(d._fontFeatureLen=0,d._fontFeatureNamesPtr=L,d._fontFeatureValuesPtr=L),Array.isArray(d.fontVariations)&&d.fontVariations.length?(w=d.fontVariations,O=w.map(function(fe){return fe.axis}),X=w.map(function(fe){return fe.value}),d._fontVariationLen=w.length,d._fontVariationAxesPtr=y(O),d._fontVariationValuesPtr=l(X,"HEAPF32")):(d._fontVariationLen=0,d._fontVariationAxesPtr=L,d._fontVariationValuesPtr=L)}function F(d){a._free(d._fontFamiliesPtr),a._free(d._shadowColorsPtr),a._free(d._shadowOffsetsPtr),a._free(d._shadowBlurRadiiPtr),a._free(d._fontFeatureNamesPtr),a._free(d._fontFeatureValuesPtr),a._free(d._fontVariationAxesPtr),a._free(d._fontVariationValuesPtr)}a.Paragraph.prototype.getRectsForRange=function(d,w,O,X){return d=this._getRectsForRange(d,w,O,X),u(d)},a.Paragraph.prototype.getRectsForPlaceholders=function(){var d=this._getRectsForPlaceholders();return u(d)},a.Paragraph.prototype.getGlyphInfoAt=function(d){return n(this._getGlyphInfoAt(d))},a.Paragraph.prototype.getClosestGlyphInfoAtCoordinate=function(d,w){return n(this._getClosestGlyphInfoAtCoordinate(d,w))},a.TypefaceFontProvider.prototype.registerFont=function(d,w){if(d=a.Typeface.MakeFreeTypeFaceFromData(d),!d)return null;w=m(w),this._registerFont(d,w)},a.ParagraphStyle=function(d){if(d.disableHinting=d.disableHinting||!1,d.ellipsis){var w=d.ellipsis;d._ellipsisPtr=m(w),d._ellipsisLen=ue(w)+1}else d._ellipsisPtr=L,d._ellipsisLen=0;return d.heightMultiplier==null&&(d.heightMultiplier=-1),d.maxLines=d.maxLines||0,d.replaceTabCharacters=d.replaceTabCharacters||!1,w=(w=d.strutStyle)||{},w.strutEnabled=w.strutEnabled||!1,w.strutEnabled&&Array.isArray(w.fontFamilies)&&w.fontFamilies.length?(w._fontFamiliesPtr=y(w.fontFamilies),w._fontFamiliesLen=w.fontFamilies.length):(w._fontFamiliesPtr=L,w._fontFamiliesLen=0),w.fontStyle=f(w.fontStyle),w.fontSize==null&&(w.fontSize=-1),w.heightMultiplier==null&&(w.heightMultiplier=-1),w.halfLeading=w.halfLeading||!1,w.leading=w.leading||0,w.forceStrutHeight=w.forceStrutHeight||!1,d.strutStyle=w,d.textAlign=d.textAlign||a.TextAlign.Start,d.textDirection=d.textDirection||a.TextDirection.LTR,d.textHeightBehavior=d.textHeightBehavior||a.TextHeightBehavior.All,d.textStyle=a.TextStyle(d.textStyle),d.applyRoundingHack=d.applyRoundingHack!==!1,d},a.TextStyle=function(d){return d.color||(d.color=a.BLACK),d.decoration=d.decoration||0,d.decorationThickness=d.decorationThickness||0,d.decorationStyle=d.decorationStyle||a.DecorationStyle.Solid,d.textBaseline=d.textBaseline||a.TextBaseline.Alphabetic,d.fontSize==null&&(d.fontSize=-1),d.letterSpacing=d.letterSpacing||0,d.wordSpacing=d.wordSpacing||0,d.heightMultiplier==null&&(d.heightMultiplier=-1),d.halfLeading=d.halfLeading||!1,d.fontStyle=f(d.fontStyle),d};var D={},I=a._malloc(16),W=a._malloc(16),N=a._malloc(16);a.ParagraphBuilder.Make=function(d,w){return C(d.textStyle),w=a.ParagraphBuilder._Make(d,w),F(d.textStyle),w},a.ParagraphBuilder.MakeFromFontProvider=function(d,w){return C(d.textStyle),w=a.ParagraphBuilder._MakeFromFontProvider(d,w),F(d.textStyle),w},a.ParagraphBuilder.MakeFromFontCollection=function(d,w){return C(d.textStyle),w=a.ParagraphBuilder._MakeFromFontCollection(d,w),F(d.textStyle),w},a.ParagraphBuilder.ShapeText=function(d,w,O){let X=0;for(let ge of w)X+=ge.length;if(X!==d.length)throw"Accumulated block lengths must equal text.length";return a.ParagraphBuilder._ShapeText(d,w,O)},a.ParagraphBuilder.prototype.pushStyle=function(d){C(d),this._pushStyle(d),F(d)},a.ParagraphBuilder.prototype.pushPaintStyle=function(d,w,O){C(d),this._pushPaintStyle(d,w,O),F(d)},a.ParagraphBuilder.prototype.addPlaceholder=function(d,w,O,X,ge){O=O||a.PlaceholderAlignment.Baseline,X=X||a.TextBaseline.Alphabetic,this._addPlaceholder(d||0,w||0,O,X,ge||0)},a.ParagraphBuilder.prototype.setWordsUtf8=function(d){var w=l(d,"HEAPU32");this._setWordsUtf8(w,d&&d.length||0),s(w,d)},a.ParagraphBuilder.prototype.setWordsUtf16=function(d){var w=l(d,"HEAPU32");this._setWordsUtf16(w,d&&d.length||0),s(w,d)},a.ParagraphBuilder.prototype.setGraphemeBreaksUtf8=function(d){var w=l(d,"HEAPU32");this._setGraphemeBreaksUtf8(w,d&&d.length||0),s(w,d)},a.ParagraphBuilder.prototype.setGraphemeBreaksUtf16=function(d){var w=l(d,"HEAPU32");this._setGraphemeBreaksUtf16(w,d&&d.length||0),s(w,d)},a.ParagraphBuilder.prototype.setLineBreaksUtf8=function(d){var w=l(d,"HEAPU32");this._setLineBreaksUtf8(w,d&&d.length||0),s(w,d)},a.ParagraphBuilder.prototype.setLineBreaksUtf16=function(d){var w=l(d,"HEAPU32");this._setLineBreaksUtf16(w,d&&d.length||0),s(w,d)}})}(_),e.Id=e.Id||[],e.Id.push(function(){e.Path.prototype.op=function(a,n){return this._op(a,n)?this:null},e.Path.prototype.simplify=function(){return this._simplify()?this:null}}),e.Id=e.Id||[],e.Id.push(function(){e.Canvas.prototype.drawText=function(a,n,u,f,y){var m=ue(a),C=e._malloc(m+1);ae(a,G,C,m+1),this._drawSimpleText(C,m,n,u,y,f),e._free(C)},e.Canvas.prototype.drawGlyphs=function(a,n,u,f,y,m){if(!(2*a.length<=n.length))throw"Not enough positions for the array of gyphs";e.Fd(this.Ed);let C=l(a,"HEAPU16"),F=l(n,"HEAPF32");this._drawGlyphs(a.length,C,F,u,f,y,m),s(F,n),s(C,a)},e.Font.prototype.getGlyphBounds=function(a,n,u){var f=l(a,"HEAPU16"),y=e._malloc(16*a.length);return this._getGlyphWidthBounds(f,a.length,L,y,n||null),n=new Float32Array(e.HEAPU8.buffer,y,4*a.length),s(f,a),u?(u.set(n),e._free(y),u):(a=Float32Array.from(n),e._free(y),a)},e.Font.prototype.getGlyphIDs=function(a,n,u){n||(n=a.length);var f=ue(a)+1,y=e._malloc(f);return ae(a,G,y,f),a=e._malloc(2*n),n=this._getGlyphIDs(y,f-1,n,a),e._free(y),0>n?(e._free(a),null):(y=new Uint16Array(e.HEAPU8.buffer,a,n),u?(u.set(y),e._free(a),u):(u=Uint16Array.from(y),e._free(a),u))},e.Font.prototype.getGlyphIntercepts=function(a,n,u,f){var y=l(a,"HEAPU16"),m=l(n,"HEAPF32");return this._getGlyphIntercepts(y,a.length,!(a&&a._ck),m,n.length,!(n&&n._ck),u,f)},e.Font.prototype.getGlyphWidths=function(a,n,u){var f=l(a,"HEAPU16"),y=e._malloc(4*a.length);return this._getGlyphWidthBounds(f,a.length,y,L,n||null),n=new Float32Array(e.HEAPU8.buffer,y,a.length),s(f,a),u?(u.set(n),e._free(y),u):(a=Float32Array.from(n),e._free(y),a)},e.FontMgr.FromData=function(){if(!arguments.length)return null;var a=arguments;if(a.length===1&&Array.isArray(a[0])&&(a=arguments[0]),!a.length)return null;for(var n=[],u=[],f=0;f<a.length;f++){var y=new Uint8Array(a[f]),m=l(y,"HEAPU8");n.push(m),u.push(y.byteLength)}return n=l(n,"HEAPU32"),u=l(u,"HEAPU32"),a=e.FontMgr._fromData(n,u,a.length),e._free(n),e._free(u),a},e.Typeface.MakeFreeTypeFaceFromData=function(a){a=new Uint8Array(a);var n=l(a,"HEAPU8");return(a=e.Typeface._MakeFreeTypeFaceFromData(n,a.byteLength))?a:null},e.Typeface.prototype.getGlyphIDs=function(a,n,u){n||(n=a.length);var f=ue(a)+1,y=e._malloc(f);return ae(a,G,y,f),a=e._malloc(2*n),n=this._getGlyphIDs(y,f-1,n,a),e._free(y),0>n?(e._free(a),null):(y=new Uint16Array(e.HEAPU8.buffer,a,n),u?(u.set(y),e._free(a),u):(u=Uint16Array.from(y),e._free(a),u))},e.TextBlob.MakeOnPath=function(a,n,u,f){if(a&&a.length&&n&&n.countPoints()){if(n.countPoints()===1)return this.MakeFromText(a,u);f||(f=0);var y=u.getGlyphIDs(a);y=u.getGlyphWidths(y);var m=[];n=new e.ContourMeasureIter(n,!1,1);for(var C=n.next(),F=new Float32Array(4),D=0;D<a.length&&C;D++){var I=y[D];if(f+=I/2,f>C.length()){if(C.delete(),C=n.next(),!C){a=a.substring(0,D);break}f=I/2}C.getPosTan(f,F);var W=F[2],N=F[3];m.push(W,N,F[0]-I/2*W,F[1]-I/2*N),f+=I/2}return a=this.MakeFromRSXform(a,m,u),C&&C.delete(),n.delete(),a}},e.TextBlob.MakeFromRSXform=function(a,n,u){var f=ue(a)+1,y=e._malloc(f);return ae(a,G,y,f),a=l(n,"HEAPF32"),u=e.TextBlob._MakeFromRSXform(y,f-1,a,u),e._free(y),u||null},e.TextBlob.MakeFromRSXformGlyphs=function(a,n,u){var f=l(a,"HEAPU16");return n=l(n,"HEAPF32"),u=e.TextBlob._MakeFromRSXformGlyphs(f,2*a.length,n,u),s(f,a),u||null},e.TextBlob.MakeFromGlyphs=function(a,n){var u=l(a,"HEAPU16");return n=e.TextBlob._MakeFromGlyphs(u,2*a.length,n),s(u,a),n||null},e.TextBlob.MakeFromText=function(a,n){var u=ue(a)+1,f=e._malloc(u);return ae(a,G,f,u),a=e.TextBlob._MakeFromText(f,u-1,n),e._free(f),a||null},e.MallocGlyphIDs=function(a){return e.Malloc(Uint16Array,a)}}),e.Id=e.Id||[],e.Id.push(function(){e.MakePicture=function(a){a=new Uint8Array(a);var n=e._malloc(a.byteLength);return e.HEAPU8.set(a,n),(a=e._MakePicture(n,a.byteLength))?a:null}}),e.Id=e.Id||[],e.Id.push(function(){e.RuntimeEffect.Make=function(a,n){return e.RuntimeEffect._Make(a,{onError:n||function(u){console.log("RuntimeEffect error",u)}})},e.RuntimeEffect.MakeForBlender=function(a,n){return e.RuntimeEffect._MakeForBlender(a,{onError:n||function(u){console.log("RuntimeEffect error",u)}})},e.RuntimeEffect.prototype.makeShader=function(a,n){var u=!a._ck,f=l(a,"HEAPF32");return n=h(n),this._makeShader(f,4*a.length,u,n)},e.RuntimeEffect.prototype.makeShaderWithChildren=function(a,n,u){var f=!a._ck,y=l(a,"HEAPF32");u=h(u);for(var m=[],C=0;C<n.length;C++)m.push(n[C].Dd.Hd);return n=l(m,"HEAPU32"),this._makeShaderWithChildren(y,4*a.length,f,n,m.length,u)},e.RuntimeEffect.prototype.makeBlender=function(a){var n=!a._ck,u=l(a,"HEAPF32");return this._makeBlender(u,4*a.length,n)}})}(_);var Nt=Object.assign({},_),Vt="./this.program",me="";typeof document<"u"&&document.currentScript&&(me=document.currentScript.src),ze&&(me=ze),me.indexOf("blob:")!==0?me=me.substr(0,me.replace(/[?#].*/,"").lastIndexOf("/")+1):me="";var Nr=_.print||console.log.bind(console),Pe=_.printErr||console.error.bind(console);Object.assign(_,Nt),Nt=null,_.thisProgram&&(Vt=_.thisProgram);var Oe;_.wasmBinary&&(Oe=_.wasmBinary);var $n=_.noExitRuntime||!0;typeof WebAssembly!="object"&&wt("no native wasm support detected");var et,k,Yt=!1,de,G,Ce,De,E,U,R,Xt;function Kt(){var e=et.buffer;_.HEAP8=de=new Int8Array(e),_.HEAP16=Ce=new Int16Array(e),_.HEAP32=E=new Int32Array(e),_.HEAPU8=G=new Uint8Array(e),_.HEAPU16=De=new Uint16Array(e),_.HEAPU32=U=new Uint32Array(e),_.HEAPF32=R=new Float32Array(e),_.HEAPF64=Xt=new Float64Array(e)}var Q,Jt=[],Qt=[],Zt=[];function Vr(){var e=_.preRun.shift();Jt.unshift(e)}var Fe=0,Ct=null,Ue=null;function wt(e){throw _.onAbort&&_.onAbort(e),e="Aborted("+e+")",Pe(e),Yt=!0,e=new WebAssembly.RuntimeError(e+". Build with -sASSERTIONS for more info."),qe(e),e}function zt(e){return e.startsWith("data:application/octet-stream;base64,")}var Be;if(Be="canvaskit.wasm",!zt(Be)){var qt=Be;Be=_.locateFile?_.locateFile(qt,me):me+qt}function er(e){if(e==Be&&Oe)return new Uint8Array(Oe);throw"both async and sync fetching of the wasm failed"}function Yr(e){return Oe||typeof fetch!="function"?Promise.resolve().then(()=>er(e)):fetch(e,{credentials:"same-origin"}).then(t=>{if(!t.ok)throw"failed to load wasm binary file at '"+e+"'";return t.arrayBuffer()}).catch(()=>er(e))}function tr(e,t,r){return Yr(e).then(i=>WebAssembly.instantiate(i,t)).then(i=>i).then(r,i=>{Pe("failed to asynchronously prepare wasm: "+i),wt(i)})}function Xr(e,t){var r=Be;return Oe||typeof WebAssembly.instantiateStreaming!="function"||zt(r)||typeof fetch!="function"?tr(r,e,t):fetch(r,{credentials:"same-origin"}).then(i=>WebAssembly.instantiateStreaming(i,e).then(t,function(o){return Pe("wasm streaming compile failed: "+o),Pe("falling back to ArrayBuffer instantiation"),tr(r,e,t)}))}var At=e=>{for(;0<e.length;)e.shift()(_)},rr=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0,Me=(e,t,r)=>{var i=t+r;for(r=t;e[r]&&!(r>=i);)++r;if(16<r-t&&e.buffer&&rr)return rr.decode(e.subarray(t,r));for(i="";t<r;){var o=e[t++];if(o&128){var s=e[t++]&63;if((o&224)==192)i+=String.fromCharCode((o&31)<<6|s);else{var l=e[t++]&63;o=(o&240)==224?(o&15)<<12|s<<6|l:(o&7)<<18|s<<12|l<<6|e[t++]&63,65536>o?i+=String.fromCharCode(o):(o-=65536,i+=String.fromCharCode(55296|o>>10,56320|o&1023))}}else i+=String.fromCharCode(o)}return i},tt={};function Et(e){for(;e.length;){var t=e.pop();e.pop()(t)}}function je(e){return this.fromWireType(E[e>>2])}var Ge={},Re={},rt={},nr=void 0;function nt(e){throw new nr(e)}function oe(e,t,r){function i(c){c=r(c),c.length!==e.length&&nt("Mismatched type converter count");for(var h=0;h<e.length;++h)he(e[h],c[h])}e.forEach(function(c){rt[c]=t});var o=Array(t.length),s=[],l=0;t.forEach((c,h)=>{Re.hasOwnProperty(c)?o[h]=Re[c]:(s.push(c),Ge.hasOwnProperty(c)||(Ge[c]=[]),Ge[c].push(()=>{o[h]=Re[c],++l,l===s.length&&i(o)}))}),s.length===0&&i(o)}function it(e){switch(e){case 1:return 0;case 2:return 1;case 4:return 2;case 8:return 3;default:throw new TypeError(`Unknown type size: ${e}`)}}var ir=void 0;function S(e){for(var t="";G[e];)t+=ir[G[e++]];return t}var Le=void 0;function b(e){throw new Le(e)}function Kr(e,t,r={}){var i=t.name;if(e||b(`type "${i}" must have a positive integer typeid pointer`),Re.hasOwnProperty(e)){if(r.af)return;b(`Cannot register type '${i}' twice`)}Re[e]=t,delete rt[e],Ge.hasOwnProperty(e)&&(t=Ge[e],delete Ge[e],t.forEach(o=>o()))}function he(e,t,r={}){if(!("argPackAdvance"in t))throw new TypeError("registerType registeredInstance requires argPackAdvance");Kr(e,t,r)}function Tt(e){b(e.Dd.Jd.Gd.name+" instance already deleted")}var Ft=!1;function or(){}function ar(e){--e.count.value,e.count.value===0&&(e.Ld?e.Pd.Td(e.Ld):e.Jd.Gd.Td(e.Hd))}function ur(e,t,r){return t===r?e:r.Md===void 0?null:(e=ur(e,t,r.Md),e===null?null:r.Te(e))}var sr={},$e=[];function Mt(){for(;$e.length;){var e=$e.pop();e.Dd.$d=!1,e.delete()}}var We=void 0,Se={};function Jr(e,t){for(t===void 0&&b("ptr should not be undefined");e.Md;)t=e.ge(t),e=e.Md;return Se[t]}function ot(e,t){return t.Jd&&t.Hd||nt("makeClassHandle requires ptr and ptrType"),!!t.Pd!=!!t.Ld&&nt("Both smartPtrType and smartPtr must be specified"),t.count={value:1},Ne(Object.create(e,{Dd:{value:t}}))}function Ne(e){return typeof FinalizationRegistry>"u"?(Ne=t=>t,e):(Ft=new FinalizationRegistry(t=>{ar(t.Dd)}),Ne=t=>{var r=t.Dd;return r.Ld&&Ft.register(t,{Dd:r},t),t},or=t=>{Ft.unregister(t)},Ne(e))}function we(){}function lr(e){if(e===void 0)return"_unknown";e=e.replace(/[^a-zA-Z0-9_]/g,"$");var t=e.charCodeAt(0);return 48<=t&&57>=t?`_${e}`:e}function Rt(e,t){return e=lr(e),{[e]:function(){return t.apply(this,arguments)}}[e]}function xt(e,t,r){if(e[t].Kd===void 0){var i=e[t];e[t]=function(){return e[t].Kd.hasOwnProperty(arguments.length)||b(`Function '${r}' called with an invalid number of arguments (${arguments.length}) - expects one of (${e[t].Kd})!`),e[t].Kd[arguments.length].apply(this,arguments)},e[t].Kd=[],e[t].Kd[i.Yd]=i}}function It(e,t,r){_.hasOwnProperty(e)?((r===void 0||_[e].Kd!==void 0&&_[e].Kd[r]!==void 0)&&b(`Cannot register public name '${e}' twice`),xt(_,e,e),_.hasOwnProperty(r)&&b(`Cannot register multiple overloads of a function with the same number of arguments (${r})!`),_[e].Kd[r]=t):(_[e]=t,r!==void 0&&(_[e].sf=r))}function Qr(e,t,r,i,o,s,l,c){this.name=e,this.constructor=t,this.ae=r,this.Td=i,this.Md=o,this.We=s,this.ge=l,this.Te=c,this.ef=[]}function Dt(e,t,r){for(;t!==r;)t.ge||b(`Expected null or instance of ${r.name}, got an instance of ${t.name}`),e=t.ge(e),t=t.Md;return e}function Zr(e,t){return t===null?(this.ue&&b(`null is not a valid ${this.name}`),0):(t.Dd||b(`Cannot pass "${Gt(t)}" as a ${this.name}`),t.Dd.Hd||b(`Cannot pass deleted object as a pointer of type ${this.name}`),Dt(t.Dd.Hd,t.Dd.Jd.Gd,this.Gd))}function zr(e,t){if(t===null){if(this.ue&&b(`null is not a valid ${this.name}`),this.le){var r=this.ve();return e!==null&&e.push(this.Td,r),r}return 0}if(t.Dd||b(`Cannot pass "${Gt(t)}" as a ${this.name}`),t.Dd.Hd||b(`Cannot pass deleted object as a pointer of type ${this.name}`),!this.ke&&t.Dd.Jd.ke&&b(`Cannot convert argument of type ${t.Dd.Pd?t.Dd.Pd.name:t.Dd.Jd.name} to parameter type ${this.name}`),r=Dt(t.Dd.Hd,t.Dd.Jd.Gd,this.Gd),this.le)switch(t.Dd.Ld===void 0&&b("Passing raw pointer to smart pointer is illegal"),this.kf){case 0:t.Dd.Pd===this?r=t.Dd.Ld:b(`Cannot convert argument of type ${t.Dd.Pd?t.Dd.Pd.name:t.Dd.Jd.name} to parameter type ${this.name}`);break;case 1:r=t.Dd.Ld;break;case 2:if(t.Dd.Pd===this)r=t.Dd.Ld;else{var i=t.clone();r=this.ff(r,ee(function(){i.delete()})),e!==null&&e.push(this.Td,r)}break;default:b("Unsupporting sharing policy")}return r}function qr(e,t){return t===null?(this.ue&&b(`null is not a valid ${this.name}`),0):(t.Dd||b(`Cannot pass "${Gt(t)}" as a ${this.name}`),t.Dd.Hd||b(`Cannot pass deleted object as a pointer of type ${this.name}`),t.Dd.Jd.ke&&b(`Cannot convert argument of type ${t.Dd.Jd.name} to parameter type ${this.name}`),Dt(t.Dd.Hd,t.Dd.Jd.Gd,this.Gd))}function pe(e,t,r,i,o,s,l,c,h,g,P){this.name=e,this.Gd=t,this.ue=r,this.ke=i,this.le=o,this.df=s,this.kf=l,this.Ee=c,this.ve=h,this.ff=g,this.Td=P,o||t.Md!==void 0?this.toWireType=zr:(this.toWireType=i?Zr:qr,this.Od=null)}function cr(e,t,r){_.hasOwnProperty(e)||nt("Replacing nonexistant public symbol"),_[e].Kd!==void 0&&r!==void 0?_[e].Kd[r]=t:(_[e]=t,_[e].Yd=r)}var en=(e,t)=>{var r=[];return function(){if(r.length=0,Object.assign(r,arguments),e.includes("j")){var i=_["dynCall_"+e];i=r&&r.length?i.apply(null,[t].concat(r)):i.call(null,t)}else i=Q.get(t).apply(null,r);return i}};function K(e,t){e=S(e);var r=e.includes("j")?en(e,t):Q.get(t);return typeof r!="function"&&b(`unknown function pointer with signature ${e}: ${t}`),r}var fr=void 0;function dr(e){e=Gr(e);var t=S(e);return _e(e),t}function Ve(e,t){function r(s){o[s]||Re[s]||(rt[s]?rt[s].forEach(r):(i.push(s),o[s]=!0))}var i=[],o={};throw t.forEach(r),new fr(`${e}: `+i.map(dr).join([", "]))}function at(e,t,r,i,o){var s=t.length;2>s&&b("argTypes array size mismatch! Must at least get return value and 'this' types!");var l=t[1]!==null&&r!==null,c=!1;for(r=1;r<t.length;++r)if(t[r]!==null&&t[r].Od===void 0){c=!0;break}var h=t[0].name!=="void",g=s-2,P=Array(g),A=[],T=[];return function(){if(arguments.length!==g&&b(`function ${e} called with ${arguments.length} arguments, expected ${g} args!`),T.length=0,A.length=l?2:1,A[0]=o,l){var v=t[1].toWireType(T,this);A[1]=v}for(var M=0;M<g;++M)P[M]=t[M+2].toWireType(T,arguments[M]),A.push(P[M]);if(M=i.apply(null,A),c)Et(T);else for(var x=l?1:2;x<t.length;x++){var $=x===1?v:P[x-2];t[x].Od!==null&&t[x].Od($)}return v=h?t[0].fromWireType(M):void 0,v}}function ut(e,t){for(var r=[],i=0;i<e;i++)r.push(U[t+4*i>>2]);return r}function hr(){this.Sd=[void 0],this.Ce=[]}var z=new hr;function Bt(e){e>=z.be&&--z.get(e).Fe===0&&z.Je(e)}var q=e=>(e||b("Cannot use deleted val. handle = "+e),z.get(e).value),ee=e=>{switch(e){case void 0:return 1;case null:return 2;case!0:return 3;case!1:return 4;default:return z.Ie({Fe:1,value:e})}};function tn(e,t,r){switch(t){case 0:return function(i){return this.fromWireType((r?de:G)[i])};case 1:return function(i){return this.fromWireType((r?Ce:De)[i>>1])};case 2:return function(i){return this.fromWireType((r?E:U)[i>>2])};default:throw new TypeError("Unknown integer type: "+e)}}function Ye(e,t){var r=Re[e];return r===void 0&&b(t+" has unknown type "+dr(e)),r}function Gt(e){if(e===null)return"null";var t=typeof e;return t==="object"||t==="array"||t==="function"?e.toString():""+e}function rn(e,t){switch(t){case 2:return function(r){return this.fromWireType(R[r>>2])};case 3:return function(r){return this.fromWireType(Xt[r>>3])};default:throw new TypeError("Unknown float type: "+e)}}function nn(e,t,r){switch(t){case 0:return r?function(i){return de[i]}:function(i){return G[i]};case 1:return r?function(i){return Ce[i>>1]}:function(i){return De[i>>1]};case 2:return r?function(i){return E[i>>2]}:function(i){return U[i>>2]};default:throw new TypeError("Unknown integer type: "+e)}}var ae=(e,t,r,i)=>{if(!(0<i))return 0;var o=r;i=r+i-1;for(var s=0;s<e.length;++s){var l=e.charCodeAt(s);if(55296<=l&&57343>=l){var c=e.charCodeAt(++s);l=65536+((l&1023)<<10)|c&1023}if(127>=l){if(r>=i)break;t[r++]=l}else{if(2047>=l){if(r+1>=i)break;t[r++]=192|l>>6}else{if(65535>=l){if(r+2>=i)break;t[r++]=224|l>>12}else{if(r+3>=i)break;t[r++]=240|l>>18,t[r++]=128|l>>12&63}t[r++]=128|l>>6&63}t[r++]=128|l&63}}return t[r]=0,r-o},ue=e=>{for(var t=0,r=0;r<e.length;++r){var i=e.charCodeAt(r);127>=i?t++:2047>=i?t+=2:55296<=i&&57343>=i?(t+=4,++r):t+=3}return t},pr=typeof TextDecoder<"u"?new TextDecoder("utf-16le"):void 0,on=(e,t)=>{for(var r=e>>1,i=r+t/2;!(r>=i)&&De[r];)++r;if(r<<=1,32<r-e&&pr)return pr.decode(G.subarray(e,r));for(r="",i=0;!(i>=t/2);++i){var o=Ce[e+2*i>>1];if(o==0)break;r+=String.fromCharCode(o)}return r},an=(e,t,r)=>{if(r===void 0&&(r=2147483647),2>r)return 0;r-=2;var i=t;r=r<2*e.length?r/2:e.length;for(var o=0;o<r;++o)Ce[t>>1]=e.charCodeAt(o),t+=2;return Ce[t>>1]=0,t-i},un=e=>2*e.length,sn=(e,t)=>{for(var r=0,i="";!(r>=t/4);){var o=E[e+4*r>>2];if(o==0)break;++r,65536<=o?(o-=65536,i+=String.fromCharCode(55296|o>>10,56320|o&1023)):i+=String.fromCharCode(o)}return i},ln=(e,t,r)=>{if(r===void 0&&(r=2147483647),4>r)return 0;var i=t;r=i+r-4;for(var o=0;o<e.length;++o){var s=e.charCodeAt(o);if(55296<=s&&57343>=s){var l=e.charCodeAt(++o);s=65536+((s&1023)<<10)|l&1023}if(E[t>>2]=s,t+=4,t+4>r)break}return E[t>>2]=0,t-i},cn=e=>{for(var t=0,r=0;r<e.length;++r){var i=e.charCodeAt(r);55296<=i&&57343>=i&&++r,t+=4}return t},fn={};function st(e){var t=fn[e];return t===void 0?S(e):t}var lt=[];function yr(){function e(t){t.$$$embind_global$$$=t;var r=typeof $$$embind_global$$$=="object"&&t.$$$embind_global$$$==t;return r||delete t.$$$embind_global$$$,r}if(typeof globalThis=="object")return globalThis;if(typeof $$$embind_global$$$=="object"||(typeof global=="object"&&e(global)?$$$embind_global$$$=global:typeof self=="object"&&e(self)&&($$$embind_global$$$=self),typeof $$$embind_global$$$=="object"))return $$$embind_global$$$;throw Error("unable to get global object.")}function dn(e){var t=lt.length;return lt.push(e),t}function hn(e,t){for(var r=Array(e),i=0;i<e;++i)r[i]=Ye(U[t+4*i>>2],"parameter "+i);return r}var vr=[];function pn(e){var t=Array(e+1);return function(r,i,o){t[0]=r;for(var s=0;s<e;++s){var l=Ye(U[i+4*s>>2],"parameter "+s);t[s+1]=l.readValueFromPointer(o),o+=l.argPackAdvance}return r=new(r.bind.apply(r,t)),ee(r)}}var mr={};function yn(e){var t=e.getExtension("ANGLE_instanced_arrays");t&&(e.vertexAttribDivisor=function(r,i){t.vertexAttribDivisorANGLE(r,i)},e.drawArraysInstanced=function(r,i,o,s){t.drawArraysInstancedANGLE(r,i,o,s)},e.drawElementsInstanced=function(r,i,o,s,l){t.drawElementsInstancedANGLE(r,i,o,s,l)})}function vn(e){var t=e.getExtension("OES_vertex_array_object");t&&(e.createVertexArray=function(){return t.createVertexArrayOES()},e.deleteVertexArray=function(r){t.deleteVertexArrayOES(r)},e.bindVertexArray=function(r){t.bindVertexArrayOES(r)},e.isVertexArray=function(r){return t.isVertexArrayOES(r)})}function mn(e){var t=e.getExtension("WEBGL_draw_buffers");t&&(e.drawBuffers=function(r,i){t.drawBuffersWEBGL(r,i)})}var _r=1,ct=[],se=[],ft=[],Xe=[],te=[],le=[],dt=[],ye=[],xe=[],Ie=[],gr={},Pr={},Cr=4;function j(e){ht||(ht=e)}function ke(e){for(var t=_r++,r=e.length;r<t;r++)e[r]=null;return t}function _n(e,t){e.be||(e.be=e.getContext,e.getContext=function(i,o){return o=e.be(i,o),i=="webgl"==o instanceof WebGLRenderingContext?o:null});var r=1<t.majorVersion?e.getContext("webgl2",t):e.getContext("webgl",t);return r?gn(r,t):0}function gn(e,t){var r=ke(ye),i={handle:r,attributes:t,version:t.majorVersion,Qd:e};return e.canvas&&(e.canvas.Ke=i),ye[r]=i,(typeof t.Ue>"u"||t.Ue)&&Pn(i),r}function wr(e){return B=ye[e],_.qf=p=B&&B.Qd,!(e&&!p)}function Pn(e){if(e||(e=B),!e.bf){e.bf=!0;var t=e.Qd;yn(t),vn(t),mn(t),t.ze=t.getExtension("WEBGL_draw_instanced_base_vertex_base_instance"),t.De=t.getExtension("WEBGL_multi_draw_instanced_base_vertex_base_instance"),2<=e.version&&(t.Ae=t.getExtension("EXT_disjoint_timer_query_webgl2")),(2>e.version||!t.Ae)&&(t.Ae=t.getExtension("EXT_disjoint_timer_query")),t.rf=t.getExtension("WEBGL_multi_draw"),(t.getSupportedExtensions()||[]).forEach(function(r){r.includes("lose_context")||r.includes("debug")||t.getExtension(r)})}}var B,ht,Lt={},Ar=()=>{if(!kt){var e={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:(typeof navigator=="object"&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_:Vt||"./this.program"},t;for(t in Lt)Lt[t]===void 0?delete e[t]:e[t]=Lt[t];var r=[];for(t in e)r.push(`${t}=${e[t]}`);kt=r}return kt},kt,Cn=[null,[],[]];function Er(e){p.bindVertexArray(dt[e])}function Tr(e,t){for(var r=0;r<e;r++){var i=E[t+4*r>>2];p.deleteVertexArray(dt[i]),dt[i]=null}}var pt=[];function Fr(e,t,r,i){p.drawElements(e,t,r,i)}function be(e,t,r,i){for(var o=0;o<e;o++){var s=p[r](),l=s&&ke(i);s?(s.name=l,i[l]=s):j(1282),E[t+4*o>>2]=l}}function Mr(e,t){be(e,t,"createVertexArray",dt)}function Rr(e,t,r){if(t){var i=void 0;switch(e){case 36346:i=1;break;case 36344:r!=0&&r!=1&&j(1280);return;case 34814:case 36345:i=0;break;case 34466:var o=p.getParameter(34467);i=o?o.length:0;break;case 33309:if(2>B.version){j(1282);return}i=2*(p.getSupportedExtensions()||[]).length;break;case 33307:case 33308:if(2>B.version){j(1280);return}i=e==33307?3:0}if(i===void 0)switch(o=p.getParameter(e),typeof o){case"number":i=o;break;case"boolean":i=o?1:0;break;case"string":j(1280);return;case"object":if(o===null)switch(e){case 34964:case 35725:case 34965:case 36006:case 36007:case 32873:case 34229:case 36662:case 36663:case 35053:case 35055:case 36010:case 35097:case 35869:case 32874:case 36389:case 35983:case 35368:case 34068:i=0;break;default:j(1280);return}else{if(o instanceof Float32Array||o instanceof Uint32Array||o instanceof Int32Array||o instanceof Array){for(e=0;e<o.length;++e)switch(r){case 0:E[t+4*e>>2]=o[e];break;case 2:R[t+4*e>>2]=o[e];break;case 4:de[t+e>>0]=o[e]?1:0}return}try{i=o.name|0}catch(s){j(1280),Pe("GL_INVALID_ENUM in glGet"+r+"v: Unknown object returned from WebGL getParameter("+e+")! (error: "+s+")");return}}break;default:j(1280),Pe("GL_INVALID_ENUM in glGet"+r+"v: Native code calling glGet"+r+"v("+e+") and it returns "+o+" of type "+typeof o+"!");return}switch(r){case 1:r=i,U[t>>2]=r,U[t+4>>2]=(r-U[t>>2])/4294967296;break;case 0:E[t>>2]=i;break;case 2:R[t>>2]=i;break;case 4:de[t>>0]=i?1:0}}else j(1281)}var Ke=e=>{var t=ue(e)+1,r=_t(t);return r&&ae(e,G,r,t),r};function xr(e){return e.slice(-1)=="]"&&e.lastIndexOf("[")}function yt(e){return e-=5120,e==0?de:e==1?G:e==2?Ce:e==4?E:e==6?R:e==5||e==28922||e==28520||e==30779||e==30782?U:De}function bt(e,t,r,i,o){e=yt(e);var s=31-Math.clz32(e.BYTES_PER_ELEMENT),l=Cr;return e.subarray(o>>s,o+i*(r*({5:3,6:4,8:2,29502:3,29504:4,26917:2,26918:2,29846:3,29847:4}[t-6402]||1)*(1<<s)+l-1&-l)>>s)}function H(e){var t=p.Re;if(t){var r=t.fe[e];return typeof r=="number"&&(t.fe[e]=r=p.getUniformLocation(t,t.Ge[e]+(0<r?"["+r+"]":""))),r}j(1282)}var Ae=[],Je=[],vt=e=>e%4===0&&(e%100!==0||e%400===0),Ir=[31,29,31,30,31,30,31,31,30,31,30,31],Dr=[31,28,31,30,31,30,31,31,30,31,30,31];function wn(e){var t=Array(ue(e)+1);return ae(e,t,0,t.length),t}var An=(e,t,r,i)=>{function o(v,M,x){for(v=typeof v=="number"?v.toString():v||"";v.length<M;)v=x[0]+v;return v}function s(v,M){return o(v,M,"0")}function l(v,M){function x(J){return 0>J?-1:0<J?1:0}var $;return($=x(v.getFullYear()-M.getFullYear()))===0&&($=x(v.getMonth()-M.getMonth()))===0&&($=x(v.getDate()-M.getDate())),$}function c(v){switch(v.getDay()){case 0:return new Date(v.getFullYear()-1,11,29);case 1:return v;case 2:return new Date(v.getFullYear(),0,3);case 3:return new Date(v.getFullYear(),0,2);case 4:return new Date(v.getFullYear(),0,1);case 5:return new Date(v.getFullYear()-1,11,31);case 6:return new Date(v.getFullYear()-1,11,30)}}function h(v){var M=v.Vd;for(v=new Date(new Date(v.Wd+1900,0,1).getTime());0<M;){var x=v.getMonth(),$=(vt(v.getFullYear())?Ir:Dr)[x];if(M>$-v.getDate())M-=$-v.getDate()+1,v.setDate(1),11>x?v.setMonth(x+1):(v.setMonth(0),v.setFullYear(v.getFullYear()+1));else{v.setDate(v.getDate()+M);break}}return x=new Date(v.getFullYear()+1,0,4),M=c(new Date(v.getFullYear(),0,4)),x=c(x),0>=l(M,v)?0>=l(x,v)?v.getFullYear()+1:v.getFullYear():v.getFullYear()-1}var g=E[i+40>>2];i={nf:E[i>>2],mf:E[i+4>>2],pe:E[i+8>>2],we:E[i+12>>2],qe:E[i+16>>2],Wd:E[i+20>>2],Rd:E[i+24>>2],Vd:E[i+28>>2],uf:E[i+32>>2],lf:E[i+36>>2],pf:g&&g?Me(G,g):""},r=r?Me(G,r):"",g={"%c":"%a %b %d %H:%M:%S %Y","%D":"%m/%d/%y","%F":"%Y-%m-%d","%h":"%b","%r":"%I:%M:%S %p","%R":"%H:%M","%T":"%H:%M:%S","%x":"%m/%d/%y","%X":"%H:%M:%S","%Ec":"%c","%EC":"%C","%Ex":"%m/%d/%y","%EX":"%H:%M:%S","%Ey":"%y","%EY":"%Y","%Od":"%d","%Oe":"%e","%OH":"%H","%OI":"%I","%Om":"%m","%OM":"%M","%OS":"%S","%Ou":"%u","%OU":"%U","%OV":"%V","%Ow":"%w","%OW":"%W","%Oy":"%y"};for(var P in g)r=r.replace(new RegExp(P,"g"),g[P]);var A="Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" "),T="January February March April May June July August September October November December".split(" ");g={"%a":v=>A[v.Rd].substring(0,3),"%A":v=>A[v.Rd],"%b":v=>T[v.qe].substring(0,3),"%B":v=>T[v.qe],"%C":v=>s((v.Wd+1900)/100|0,2),"%d":v=>s(v.we,2),"%e":v=>o(v.we,2," "),"%g":v=>h(v).toString().substring(2),"%G":v=>h(v),"%H":v=>s(v.pe,2),"%I":v=>(v=v.pe,v==0?v=12:12<v&&(v-=12),s(v,2)),"%j":v=>{for(var M=0,x=0;x<=v.qe-1;M+=(vt(v.Wd+1900)?Ir:Dr)[x++]);return s(v.we+M,3)},"%m":v=>s(v.qe+1,2),"%M":v=>s(v.mf,2),"%n":()=>`
2
+ `,"%p":v=>0<=v.pe&&12>v.pe?"AM":"PM","%S":v=>s(v.nf,2),"%t":()=>" ","%u":v=>v.Rd||7,"%U":v=>s(Math.floor((v.Vd+7-v.Rd)/7),2),"%V":v=>{var M=Math.floor((v.Vd+7-(v.Rd+6)%7)/7);if(2>=(v.Rd+371-v.Vd-2)%7&&M++,M)M==53&&(x=(v.Rd+371-v.Vd)%7,x==4||x==3&&vt(v.Wd)||(M=1));else{M=52;var x=(v.Rd+7-v.Vd-1)%7;(x==4||x==5&&vt(v.Wd%400-1))&&M++}return s(M,2)},"%w":v=>v.Rd,"%W":v=>s(Math.floor((v.Vd+7-(v.Rd+6)%7)/7),2),"%y":v=>(v.Wd+1900).toString().substring(2),"%Y":v=>v.Wd+1900,"%z":v=>{v=v.lf;var M=0<=v;return v=Math.abs(v)/60,(M?"+":"-")+String("0000"+(v/60*100+v%60)).slice(-4)},"%Z":v=>v.pf,"%%":()=>"%"},r=r.replace(/%%/g,"\0\0");for(P in g)r.includes(P)&&(r=r.replace(new RegExp(P,"g"),g[P](i)));return r=r.replace(/\0\0/g,"%"),P=wn(r),P.length>t?0:(de.set(P,e),P.length-1)};nr=_.InternalError=class extends Error{constructor(e){super(e),this.name="InternalError"}};for(var Br=Array(256),mt=0;256>mt;++mt)Br[mt]=String.fromCharCode(mt);ir=Br,Le=_.BindingError=class extends Error{constructor(e){super(e),this.name="BindingError"}},we.prototype.isAliasOf=function(e){if(!(this instanceof we&&e instanceof we))return!1;var t=this.Dd.Jd.Gd,r=this.Dd.Hd,i=e.Dd.Jd.Gd;for(e=e.Dd.Hd;t.Md;)r=t.ge(r),t=t.Md;for(;i.Md;)e=i.ge(e),i=i.Md;return t===i&&r===e},we.prototype.clone=function(){if(this.Dd.Hd||Tt(this),this.Dd.ee)return this.Dd.count.value+=1,this;var e=Ne,t=Object,r=t.create,i=Object.getPrototypeOf(this),o=this.Dd;return e=e(r.call(t,i,{Dd:{value:{count:o.count,$d:o.$d,ee:o.ee,Hd:o.Hd,Jd:o.Jd,Ld:o.Ld,Pd:o.Pd}}})),e.Dd.count.value+=1,e.Dd.$d=!1,e},we.prototype.delete=function(){this.Dd.Hd||Tt(this),this.Dd.$d&&!this.Dd.ee&&b("Object already scheduled for deletion"),or(this),ar(this.Dd),this.Dd.ee||(this.Dd.Ld=void 0,this.Dd.Hd=void 0)},we.prototype.isDeleted=function(){return!this.Dd.Hd},we.prototype.deleteLater=function(){return this.Dd.Hd||Tt(this),this.Dd.$d&&!this.Dd.ee&&b("Object already scheduled for deletion"),$e.push(this),$e.length===1&&We&&We(Mt),this.Dd.$d=!0,this},_.getInheritedInstanceCount=function(){return Object.keys(Se).length},_.getLiveInheritedInstances=function(){var e=[],t;for(t in Se)Se.hasOwnProperty(t)&&e.push(Se[t]);return e},_.flushPendingDeletes=Mt,_.setDelayFunction=function(e){We=e,$e.length&&We&&We(Mt)},pe.prototype.Xe=function(e){return this.Ee&&(e=this.Ee(e)),e},pe.prototype.ye=function(e){this.Td&&this.Td(e)},pe.prototype.argPackAdvance=8,pe.prototype.readValueFromPointer=je,pe.prototype.deleteObject=function(e){e!==null&&e.delete()},pe.prototype.fromWireType=function(e){function t(){return this.le?ot(this.Gd.ae,{Jd:this.df,Hd:r,Pd:this,Ld:e}):ot(this.Gd.ae,{Jd:this,Hd:e})}var r=this.Xe(e);if(!r)return this.ye(e),null;var i=Jr(this.Gd,r);if(i!==void 0)return i.Dd.count.value===0?(i.Dd.Hd=r,i.Dd.Ld=e,i.clone()):(i=i.clone(),this.ye(e),i);if(i=this.Gd.We(r),i=sr[i],!i)return t.call(this);i=this.ke?i.Qe:i.pointerType;var o=ur(r,this.Gd,i.Gd);return o===null?t.call(this):this.le?ot(i.Gd.ae,{Jd:i,Hd:o,Pd:this,Ld:e}):ot(i.Gd.ae,{Jd:i,Hd:o})},fr=_.UnboundTypeError=function(e,t){var r=Rt(t,function(i){this.name=t,this.message=i,i=Error(i).stack,i!==void 0&&(this.stack=this.toString()+`
3
+ `+i.replace(/^Error(:[^\n]*)?\n/,""))});return r.prototype=Object.create(e.prototype),r.prototype.constructor=r,r.prototype.toString=function(){return this.message===void 0?this.name:`${this.name}: ${this.message}`},r}(Error,"UnboundTypeError"),Object.assign(hr.prototype,{get(e){return this.Sd[e]},has(e){return this.Sd[e]!==void 0},Ie(e){var t=this.Ce.pop()||this.Sd.length;return this.Sd[t]=e,t},Je(e){this.Sd[e]=void 0,this.Ce.push(e)}}),z.Sd.push({value:void 0},{value:null},{value:!0},{value:!1}),z.be=z.Sd.length,_.count_emval_handles=function(){for(var e=0,t=z.be;t<z.Sd.length;++t)z.Sd[t]!==void 0&&++e;return e};for(var p,Z=0;32>Z;++Z)pt.push(Array(Z));var En=new Float32Array(288);for(Z=0;288>Z;++Z)Ae[Z]=En.subarray(0,Z+1);var Tn=new Int32Array(288);for(Z=0;288>Z;++Z)Je[Z]=Tn.subarray(0,Z+1);var Fn={Q:function(){return 0},Ab:()=>{},Cb:function(){return 0},xb:()=>{},yb:()=>{},R:function(){},zb:()=>{},v:function(e){var t=tt[e];delete tt[e];var r=t.ve,i=t.Td,o=t.Be,s=o.map(l=>l.$e).concat(o.map(l=>l.hf));oe([e],s,l=>{var c={};return o.forEach((h,g)=>{var P=l[g],A=h.Ye,T=h.Ze,v=l[g+o.length],M=h.gf,x=h.jf;c[h.Ve]={read:$=>P.fromWireType(A(T,$)),write:($,J)=>{var Y=[];M(x,$,v.toWireType(Y,J)),Et(Y)}}}),[{name:t.name,fromWireType:function(h){var g={},P;for(P in c)g[P]=c[P].read(h);return i(h),g},toWireType:function(h,g){for(var P in c)if(!(P in g))throw new TypeError(`Missing field: "${P}"`);var A=r();for(P in c)c[P].write(A,g[P]);return h!==null&&h.push(i,A),A},argPackAdvance:8,readValueFromPointer:je,Od:i}]})},pb:function(){},Gb:function(e,t,r,i,o){var s=it(r);t=S(t),he(e,{name:t,fromWireType:function(l){return!!l},toWireType:function(l,c){return c?i:o},argPackAdvance:8,readValueFromPointer:function(l){if(r===1)var c=de;else if(r===2)c=Ce;else if(r===4)c=E;else throw new TypeError("Unknown boolean type size: "+t);return this.fromWireType(c[l>>s])},Od:null})},k:function(e,t,r,i,o,s,l,c,h,g,P,A,T){P=S(P),s=K(o,s),c&&(c=K(l,c)),g&&(g=K(h,g)),T=K(A,T);var v=lr(P);It(v,function(){Ve(`Cannot construct ${P} due to unbound types`,[i])}),oe([e,t,r],i?[i]:[],function(M){if(M=M[0],i)var x=M.Gd,$=x.ae;else $=we.prototype;M=Rt(v,function(){if(Object.getPrototypeOf(this)!==J)throw new Le("Use 'new' to construct "+P);if(Y.Ud===void 0)throw new Le(P+" has no accessible constructor");var He=Y.Ud[arguments.length];if(He===void 0)throw new Le(`Tried to invoke ctor of ${P} with invalid number of parameters (${arguments.length}) - expected (${Object.keys(Y.Ud).toString()}) parameters instead!`);return He.apply(this,arguments)});var J=Object.create($,{constructor:{value:M}});M.prototype=J;var Y=new Qr(P,M,J,T,x,s,c,g);Y.Md&&(Y.Md.he===void 0&&(Y.Md.he=[]),Y.Md.he.push(Y)),x=new pe(P,Y,!0,!1,!1),$=new pe(P+"*",Y,!1,!1,!1);var ve=new pe(P+" const*",Y,!1,!0,!1);return sr[e]={pointerType:$,Qe:ve},cr(v,M),[x,$,ve]})},f:function(e,t,r,i,o,s,l){var c=ut(r,i);t=S(t),s=K(o,s),oe([],[e],function(h){function g(){Ve(`Cannot call ${P} due to unbound types`,c)}h=h[0];var P=`${h.name}.${t}`;t.startsWith("@@")&&(t=Symbol[t.substring(2)]);var A=h.Gd.constructor;return A[t]===void 0?(g.Yd=r-1,A[t]=g):(xt(A,t,P),A[t].Kd[r-1]=g),oe([],c,function(T){if(T=[T[0],null].concat(T.slice(1)),T=at(P,T,null,s,l),A[t].Kd===void 0?(T.Yd=r-1,A[t]=T):A[t].Kd[r-1]=T,h.Gd.he)for(let v of h.Gd.he)v.constructor.hasOwnProperty(t)||(v.constructor[t]=T);return[]}),[]})},t:function(e,t,r,i,o,s){var l=ut(t,r);o=K(i,o),oe([],[e],function(c){c=c[0];var h=`constructor ${c.name}`;if(c.Gd.Ud===void 0&&(c.Gd.Ud=[]),c.Gd.Ud[t-1]!==void 0)throw new Le(`Cannot register multiple constructors with identical number of parameters (${t-1}) for class '${c.name}'! Overload resolution is currently only performed using the parameter count, not actual type info!`);return c.Gd.Ud[t-1]=()=>{Ve(`Cannot construct ${c.name} due to unbound types`,l)},oe([],l,function(g){return g.splice(1,0,null),c.Gd.Ud[t-1]=at(h,g,null,o,s),[]}),[]})},b:function(e,t,r,i,o,s,l,c){var h=ut(r,i);t=S(t),s=K(o,s),oe([],[e],function(g){function P(){Ve(`Cannot call ${A} due to unbound types`,h)}g=g[0];var A=`${g.name}.${t}`;t.startsWith("@@")&&(t=Symbol[t.substring(2)]),c&&g.Gd.ef.push(t);var T=g.Gd.ae,v=T[t];return v===void 0||v.Kd===void 0&&v.className!==g.name&&v.Yd===r-2?(P.Yd=r-2,P.className=g.name,T[t]=P):(xt(T,t,A),T[t].Kd[r-2]=P),oe([],h,function(M){return M=at(A,M,g,s,l),T[t].Kd===void 0?(M.Yd=r-2,T[t]=M):T[t].Kd[r-2]=M,[]}),[]})},o:function(e,t,r){e=S(e),oe([],[t],function(i){return i=i[0],_[e]=i.fromWireType(r),[]})},Fb:function(e,t){t=S(t),he(e,{name:t,fromWireType:function(r){var i=q(r);return Bt(r),i},toWireType:function(r,i){return ee(i)},argPackAdvance:8,readValueFromPointer:je,Od:null})},j:function(e,t,r,i){function o(){}r=it(r),t=S(t),o.values={},he(e,{name:t,constructor:o,fromWireType:function(s){return this.constructor.values[s]},toWireType:function(s,l){return l.value},argPackAdvance:8,readValueFromPointer:tn(t,r,i),Od:null}),It(t,o)},c:function(e,t,r){var i=Ye(e,"enum");t=S(t),e=i.constructor,i=Object.create(i.constructor.prototype,{value:{value:r},constructor:{value:Rt(`${i.name}_${t}`,function(){})}}),e.values[r]=i,e[t]=i},T:function(e,t,r){r=it(r),t=S(t),he(e,{name:t,fromWireType:function(i){return i},toWireType:function(i,o){return o},argPackAdvance:8,readValueFromPointer:rn(t,r),Od:null})},r:function(e,t,r,i,o,s){var l=ut(t,r);e=S(e),o=K(i,o),It(e,function(){Ve(`Cannot call ${e} due to unbound types`,l)},t-1),oe([],l,function(c){return c=[c[0],null].concat(c.slice(1)),cr(e,at(e,c,null,o,s),t-1),[]})},x:function(e,t,r,i,o){t=S(t),o===-1&&(o=4294967295),o=it(r);var s=c=>c;if(i===0){var l=32-8*r;s=c=>c<<l>>>l}r=t.includes("unsigned")?function(c,h){return h>>>0}:function(c,h){return h},he(e,{name:t,fromWireType:s,toWireType:r,argPackAdvance:8,readValueFromPointer:nn(t,o,i!==0),Od:null})},n:function(e,t,r){function i(s){s>>=2;var l=U;return new o(l.buffer,l[s+1],l[s])}var o=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array][t];r=S(r),he(e,{name:r,fromWireType:i,argPackAdvance:8,readValueFromPointer:i},{af:!0})},m:function(e,t,r,i,o,s,l,c,h,g,P,A){r=S(r),s=K(o,s),c=K(l,c),g=K(h,g),A=K(P,A),oe([e],[t],function(T){return T=T[0],[new pe(r,T.Gd,!1,!1,!0,T,i,s,c,g,A)]})},S:function(e,t){t=S(t);var r=t==="std::string";he(e,{name:t,fromWireType:function(i){var o=U[i>>2],s=i+4;if(r)for(var l=s,c=0;c<=o;++c){var h=s+c;if(c==o||G[h]==0){if(l=l?Me(G,l,h-l):"",g===void 0)var g=l;else g+=String.fromCharCode(0),g+=l;l=h+1}}else{for(g=Array(o),c=0;c<o;++c)g[c]=String.fromCharCode(G[s+c]);g=g.join("")}return _e(i),g},toWireType:function(i,o){o instanceof ArrayBuffer&&(o=new Uint8Array(o));var s=typeof o=="string";s||o instanceof Uint8Array||o instanceof Uint8ClampedArray||o instanceof Int8Array||b("Cannot pass non-string to std::string");var l=r&&s?ue(o):o.length,c=_t(4+l+1),h=c+4;if(U[c>>2]=l,r&&s)ae(o,G,h,l+1);else if(s)for(s=0;s<l;++s){var g=o.charCodeAt(s);255<g&&(_e(h),b("String has UTF-16 code units that do not fit in 8 bits")),G[h+s]=g}else for(s=0;s<l;++s)G[h+s]=o[s];return i!==null&&i.push(_e,c),c},argPackAdvance:8,readValueFromPointer:je,Od:function(i){_e(i)}})},K:function(e,t,r){if(r=S(r),t===2)var i=on,o=an,s=un,l=()=>De,c=1;else t===4&&(i=sn,o=ln,s=cn,l=()=>U,c=2);he(e,{name:r,fromWireType:function(h){for(var g=U[h>>2],P=l(),A,T=h+4,v=0;v<=g;++v){var M=h+4+v*t;(v==g||P[M>>c]==0)&&(T=i(T,M-T),A===void 0?A=T:(A+=String.fromCharCode(0),A+=T),T=M+t)}return _e(h),A},toWireType:function(h,g){typeof g!="string"&&b(`Cannot pass non-string to C++ string type ${r}`);var P=s(g),A=_t(4+P+t);return U[A>>2]=P>>c,o(g,A+4,P+t),h!==null&&h.push(_e,A),A},argPackAdvance:8,readValueFromPointer:je,Od:function(h){_e(h)}})},w:function(e,t,r,i,o,s){tt[e]={name:S(t),ve:K(r,i),Td:K(o,s),Be:[]}},e:function(e,t,r,i,o,s,l,c,h,g){tt[e].Be.push({Ve:S(t),$e:r,Ye:K(i,o),Ze:s,hf:l,gf:K(c,h),jf:g})},Hb:function(e,t){t=S(t),he(e,{cf:!0,name:t,argPackAdvance:0,fromWireType:function(){},toWireType:function(){}})},Eb:()=>!0,tb:()=>{throw 1/0},y:function(e,t,r){e=q(e),t=Ye(t,"emval::as");var i=[],o=ee(i);return U[r>>2]=o,t.toWireType(i,e)},Y:function(e,t,r,i,o){e=lt[e],t=q(t),r=st(r);var s=[];return U[i>>2]=ee(s),e(t,r,s,o)},q:function(e,t,r,i){e=lt[e],t=q(t),r=st(r),e(t,r,null,i)},d:Bt,H:function(e){return e===0?ee(yr()):(e=st(e),ee(yr()[e]))},p:function(e,t){var r=hn(e,t),i=r[0];t=i.name+"_$"+r.slice(1).map(function(l){return l.name}).join("_")+"$";var o=vr[t];if(o!==void 0)return o;var s=Array(e-1);return o=dn((l,c,h,g)=>{for(var P=0,A=0;A<e-1;++A)s[A]=r[A+1].readValueFromPointer(g+P),P+=r[A+1].argPackAdvance;for(l=l[c].apply(l,s),A=0;A<e-1;++A)r[A+1].Se&&r[A+1].Se(s[A]);if(!i.cf)return i.toWireType(h,l)}),vr[t]=o},s:function(e,t){return e=q(e),t=q(t),ee(e[t])},l:function(e){4<e&&(z.get(e).Fe+=1)},G:function(e,t,r,i){e=q(e);var o=mr[t];return o||(o=pn(t),mr[t]=o),o(e,r,i)},C:function(){return ee([])},g:function(e){return ee(st(e))},z:function(){return ee({})},jb:function(e){return e=q(e),!e},u:function(e){var t=q(e);Et(t),Bt(e)},i:function(e,t,r){e=q(e),t=q(t),r=q(r),e[t]=r},h:function(e,t){return e=Ye(e,"_emval_take_value"),e=e.readValueFromPointer(t),ee(e)},mb:function(){return-52},nb:function(){},a:()=>{wt("")},Db:()=>performance.now(),ub:e=>{var t=G.length;if(e>>>=0,2147483648<e)return!1;for(var r=1;4>=r;r*=2){var i=t*(1+.2/r);i=Math.min(i,e+100663296);var o=Math;i=Math.max(e,i);e:{o=o.min.call(o,2147483648,i+(65536-i%65536)%65536)-et.buffer.byteLength+65535>>>16;try{et.grow(o),Kt();var s=1;break e}catch{}s=void 0}if(s)return!0}return!1},kb:function(){return B?B.handle:0},vb:(e,t)=>{var r=0;return Ar().forEach(function(i,o){var s=t+r;for(o=U[e+4*o>>2]=s,s=0;s<i.length;++s)de[o++>>0]=i.charCodeAt(s);de[o>>0]=0,r+=i.length+1}),0},wb:(e,t)=>{var r=Ar();U[e>>2]=r.length;var i=0;return r.forEach(function(o){i+=o.length+1}),U[t>>2]=i,0},J:()=>52,lb:function(){return 52},Bb:()=>52,ob:function(){return 70},P:(e,t,r,i)=>{for(var o=0,s=0;s<r;s++){var l=U[t>>2],c=U[t+4>>2];t+=8;for(var h=0;h<c;h++){var g=G[l+h],P=Cn[e];g===0||g===10?((e===1?Nr:Pe)(Me(P,0)),P.length=0):P.push(g)}o+=c}return U[i>>2]=o,0},$:function(e){p.activeTexture(e)},aa:function(e,t){p.attachShader(se[e],le[t])},ba:function(e,t,r){p.bindAttribLocation(se[e],t,r?Me(G,r):"")},ca:function(e,t){e==35051?p.se=t:e==35052&&(p.Zd=t),p.bindBuffer(e,ct[t])},_:function(e,t){p.bindFramebuffer(e,ft[t])},ac:function(e,t){p.bindRenderbuffer(e,Xe[t])},Mb:function(e,t){p.bindSampler(e,xe[t])},da:function(e,t){p.bindTexture(e,te[t])},uc:Er,xc:Er,ea:function(e,t,r,i){p.blendColor(e,t,r,i)},fa:function(e){p.blendEquation(e)},ga:function(e,t){p.blendFunc(e,t)},Wb:function(e,t,r,i,o,s,l,c,h,g){p.blitFramebuffer(e,t,r,i,o,s,l,c,h,g)},ha:function(e,t,r,i){2<=B.version?r&&t?p.bufferData(e,G,i,r,t):p.bufferData(e,t,i):p.bufferData(e,r?G.subarray(r,r+t):t,i)},ia:function(e,t,r,i){2<=B.version?r&&p.bufferSubData(e,t,G,i,r):p.bufferSubData(e,t,G.subarray(i,i+r))},bc:function(e){return p.checkFramebufferStatus(e)},N:function(e){p.clear(e)},Z:function(e,t,r,i){p.clearColor(e,t,r,i)},O:function(e){p.clearStencil(e)},rb:function(e,t,r,i){return p.clientWaitSync(Ie[e],t,(r>>>0)+4294967296*i)},ja:function(e,t,r,i){p.colorMask(!!e,!!t,!!r,!!i)},ka:function(e){p.compileShader(le[e])},la:function(e,t,r,i,o,s,l,c){2<=B.version?p.Zd||!l?p.compressedTexImage2D(e,t,r,i,o,s,l,c):p.compressedTexImage2D(e,t,r,i,o,s,G,c,l):p.compressedTexImage2D(e,t,r,i,o,s,c?G.subarray(c,c+l):null)},ma:function(e,t,r,i,o,s,l,c,h){2<=B.version?p.Zd||!c?p.compressedTexSubImage2D(e,t,r,i,o,s,l,c,h):p.compressedTexSubImage2D(e,t,r,i,o,s,l,G,h,c):p.compressedTexSubImage2D(e,t,r,i,o,s,l,h?G.subarray(h,h+c):null)},Ub:function(e,t,r,i,o){p.copyBufferSubData(e,t,r,i,o)},na:function(e,t,r,i,o,s,l,c){p.copyTexSubImage2D(e,t,r,i,o,s,l,c)},oa:function(){var e=ke(se),t=p.createProgram();return t.name=e,t.oe=t.me=t.ne=0,t.xe=1,se[e]=t,e},pa:function(e){var t=ke(le);return le[t]=p.createShader(e),t},qa:function(e){p.cullFace(e)},ra:function(e,t){for(var r=0;r<e;r++){var i=E[t+4*r>>2],o=ct[i];o&&(p.deleteBuffer(o),o.name=0,ct[i]=null,i==p.se&&(p.se=0),i==p.Zd&&(p.Zd=0))}},cc:function(e,t){for(var r=0;r<e;++r){var i=E[t+4*r>>2],o=ft[i];o&&(p.deleteFramebuffer(o),o.name=0,ft[i]=null)}},sa:function(e){if(e){var t=se[e];t?(p.deleteProgram(t),t.name=0,se[e]=null):j(1281)}},dc:function(e,t){for(var r=0;r<e;r++){var i=E[t+4*r>>2],o=Xe[i];o&&(p.deleteRenderbuffer(o),o.name=0,Xe[i]=null)}},Nb:function(e,t){for(var r=0;r<e;r++){var i=E[t+4*r>>2],o=xe[i];o&&(p.deleteSampler(o),o.name=0,xe[i]=null)}},ta:function(e){if(e){var t=le[e];t?(p.deleteShader(t),le[e]=null):j(1281)}},Vb:function(e){if(e){var t=Ie[e];t?(p.deleteSync(t),t.name=0,Ie[e]=null):j(1281)}},ua:function(e,t){for(var r=0;r<e;r++){var i=E[t+4*r>>2],o=te[i];o&&(p.deleteTexture(o),o.name=0,te[i]=null)}},vc:Tr,yc:Tr,va:function(e){p.depthMask(!!e)},wa:function(e){p.disable(e)},xa:function(e){p.disableVertexAttribArray(e)},ya:function(e,t,r){p.drawArrays(e,t,r)},sc:function(e,t,r,i){p.drawArraysInstanced(e,t,r,i)},qc:function(e,t,r,i,o){p.ze.drawArraysInstancedBaseInstanceWEBGL(e,t,r,i,o)},oc:function(e,t){for(var r=pt[e],i=0;i<e;i++)r[i]=E[t+4*i>>2];p.drawBuffers(r)},za:Fr,tc:function(e,t,r,i,o){p.drawElementsInstanced(e,t,r,i,o)},rc:function(e,t,r,i,o,s,l){p.ze.drawElementsInstancedBaseVertexBaseInstanceWEBGL(e,t,r,i,o,s,l)},ic:function(e,t,r,i,o,s){Fr(e,i,o,s)},Aa:function(e){p.enable(e)},Ba:function(e){p.enableVertexAttribArray(e)},Sb:function(e,t){return(e=p.fenceSync(e,t))?(t=ke(Ie),e.name=t,Ie[t]=e,t):0},Ca:function(){p.finish()},Da:function(){p.flush()},ec:function(e,t,r,i){p.framebufferRenderbuffer(e,t,r,Xe[i])},fc:function(e,t,r,i,o){p.framebufferTexture2D(e,t,r,te[i],o)},Ea:function(e){p.frontFace(e)},Fa:function(e,t){be(e,t,"createBuffer",ct)},gc:function(e,t){be(e,t,"createFramebuffer",ft)},hc:function(e,t){be(e,t,"createRenderbuffer",Xe)},Ob:function(e,t){be(e,t,"createSampler",xe)},Ga:function(e,t){be(e,t,"createTexture",te)},wc:Mr,zc:Mr,Yb:function(e){p.generateMipmap(e)},Ha:function(e,t,r){r?E[r>>2]=p.getBufferParameter(e,t):j(1281)},Ia:function(){var e=p.getError()||ht;return ht=0,e},Ja:function(e,t){Rr(e,t,2)},Zb:function(e,t,r,i){e=p.getFramebufferAttachmentParameter(e,t,r),(e instanceof WebGLRenderbuffer||e instanceof WebGLTexture)&&(e=e.name|0),E[i>>2]=e},I:function(e,t){Rr(e,t,0)},Ka:function(e,t,r,i){e=p.getProgramInfoLog(se[e]),e===null&&(e="(unknown error)"),t=0<t&&i?ae(e,G,i,t):0,r&&(E[r>>2]=t)},La:function(e,t,r){if(r)if(e>=_r)j(1281);else if(e=se[e],t==35716)e=p.getProgramInfoLog(e),e===null&&(e="(unknown error)"),E[r>>2]=e.length+1;else if(t==35719){if(!e.oe)for(t=0;t<p.getProgramParameter(e,35718);++t)e.oe=Math.max(e.oe,p.getActiveUniform(e,t).name.length+1);E[r>>2]=e.oe}else if(t==35722){if(!e.me)for(t=0;t<p.getProgramParameter(e,35721);++t)e.me=Math.max(e.me,p.getActiveAttrib(e,t).name.length+1);E[r>>2]=e.me}else if(t==35381){if(!e.ne)for(t=0;t<p.getProgramParameter(e,35382);++t)e.ne=Math.max(e.ne,p.getActiveUniformBlockName(e,t).length+1);E[r>>2]=e.ne}else E[r>>2]=p.getProgramParameter(e,t);else j(1281)},_b:function(e,t,r){r?E[r>>2]=p.getRenderbufferParameter(e,t):j(1281)},Ma:function(e,t,r,i){e=p.getShaderInfoLog(le[e]),e===null&&(e="(unknown error)"),t=0<t&&i?ae(e,G,i,t):0,r&&(E[r>>2]=t)},Jb:function(e,t,r,i){e=p.getShaderPrecisionFormat(e,t),E[r>>2]=e.rangeMin,E[r+4>>2]=e.rangeMax,E[i>>2]=e.precision},Na:function(e,t,r){r?t==35716?(e=p.getShaderInfoLog(le[e]),e===null&&(e="(unknown error)"),E[r>>2]=e?e.length+1:0):t==35720?(e=p.getShaderSource(le[e]),E[r>>2]=e?e.length+1:0):E[r>>2]=p.getShaderParameter(le[e],t):j(1281)},M:function(e){var t=gr[e];if(!t){switch(e){case 7939:t=p.getSupportedExtensions()||[],t=t.concat(t.map(function(i){return"GL_"+i})),t=Ke(t.join(" "));break;case 7936:case 7937:case 37445:case 37446:(t=p.getParameter(e))||j(1280),t=t&&Ke(t);break;case 7938:t=p.getParameter(7938),t=2<=B.version?"OpenGL ES 3.0 ("+t+")":"OpenGL ES 2.0 ("+t+")",t=Ke(t);break;case 35724:t=p.getParameter(35724);var r=t.match(/^WebGL GLSL ES ([0-9]\.[0-9][0-9]?)(?:$| .*)/);r!==null&&(r[1].length==3&&(r[1]+="0"),t="OpenGL ES GLSL ES "+r[1]+" ("+t+")"),t=Ke(t);break;default:j(1280)}gr[e]=t}return t},ib:function(e,t){if(2>B.version)return j(1282),0;var r=Pr[e];if(r)return 0>t||t>=r.length?(j(1281),0):r[t];switch(e){case 7939:return r=p.getSupportedExtensions()||[],r=r.concat(r.map(function(i){return"GL_"+i})),r=r.map(function(i){return Ke(i)}),r=Pr[e]=r,0>t||t>=r.length?(j(1281),0):r[t];default:return j(1280),0}},Oa:function(e,t){if(t=t?Me(G,t):"",e=se[e]){var r=e,i=r.fe,o=r.He,s;if(!i)for(r.fe=i={},r.Ge={},s=0;s<p.getProgramParameter(r,35718);++s){var l=p.getActiveUniform(r,s),c=l.name;l=l.size;var h=xr(c);h=0<h?c.slice(0,h):c;var g=r.xe;for(r.xe+=l,o[h]=[l,g],c=0;c<l;++c)i[g]=c,r.Ge[g++]=h}if(r=e.fe,i=0,o=t,s=xr(t),0<s&&(i=parseInt(t.slice(s+1))>>>0,o=t.slice(0,s)),(o=e.He[o])&&i<o[0]&&(i+=o[1],r[i]=r[i]||p.getUniformLocation(e,t)))return i}else j(1281);return-1},Kb:function(e,t,r){for(var i=pt[t],o=0;o<t;o++)i[o]=E[r+4*o>>2];p.invalidateFramebuffer(e,i)},Lb:function(e,t,r,i,o,s,l){for(var c=pt[t],h=0;h<t;h++)c[h]=E[r+4*h>>2];p.invalidateSubFramebuffer(e,c,i,o,s,l)},Tb:function(e){return p.isSync(Ie[e])},Pa:function(e){return(e=te[e])?p.isTexture(e):0},Qa:function(e){p.lineWidth(e)},Ra:function(e){e=se[e],p.linkProgram(e),e.fe=0,e.He={}},mc:function(e,t,r,i,o,s){p.De.multiDrawArraysInstancedBaseInstanceWEBGL(e,E,t>>2,E,r>>2,E,i>>2,U,o>>2,s)},nc:function(e,t,r,i,o,s,l,c){p.De.multiDrawElementsInstancedBaseVertexBaseInstanceWEBGL(e,E,t>>2,r,E,i>>2,E,o>>2,E,s>>2,U,l>>2,c)},Sa:function(e,t){e==3317&&(Cr=t),p.pixelStorei(e,t)},pc:function(e){p.readBuffer(e)},Ta:function(e,t,r,i,o,s,l){if(2<=B.version)if(p.se)p.readPixels(e,t,r,i,o,s,l);else{var c=yt(s);p.readPixels(e,t,r,i,o,s,c,l>>31-Math.clz32(c.BYTES_PER_ELEMENT))}else(l=bt(s,o,r,i,l))?p.readPixels(e,t,r,i,o,s,l):j(1280)},$b:function(e,t,r,i){p.renderbufferStorage(e,t,r,i)},Xb:function(e,t,r,i,o){p.renderbufferStorageMultisample(e,t,r,i,o)},Pb:function(e,t,r){p.samplerParameterf(xe[e],t,r)},Qb:function(e,t,r){p.samplerParameteri(xe[e],t,r)},Rb:function(e,t,r){p.samplerParameteri(xe[e],t,E[r>>2])},Ua:function(e,t,r,i){p.scissor(e,t,r,i)},Va:function(e,t,r,i){for(var o="",s=0;s<t;++s){var l=i?E[i+4*s>>2]:-1,c=E[r+4*s>>2];l=c?Me(G,c,0>l?void 0:l):"",o+=l}p.shaderSource(le[e],o)},Wa:function(e,t,r){p.stencilFunc(e,t,r)},Xa:function(e,t,r,i){p.stencilFuncSeparate(e,t,r,i)},Ya:function(e){p.stencilMask(e)},Za:function(e,t){p.stencilMaskSeparate(e,t)},_a:function(e,t,r){p.stencilOp(e,t,r)},$a:function(e,t,r,i){p.stencilOpSeparate(e,t,r,i)},ab:function(e,t,r,i,o,s,l,c,h){if(2<=B.version)if(p.Zd)p.texImage2D(e,t,r,i,o,s,l,c,h);else if(h){var g=yt(c);p.texImage2D(e,t,r,i,o,s,l,c,g,h>>31-Math.clz32(g.BYTES_PER_ELEMENT))}else p.texImage2D(e,t,r,i,o,s,l,c,null);else p.texImage2D(e,t,r,i,o,s,l,c,h?bt(c,l,i,o,h):null)},bb:function(e,t,r){p.texParameterf(e,t,r)},cb:function(e,t,r){p.texParameterf(e,t,R[r>>2])},db:function(e,t,r){p.texParameteri(e,t,r)},eb:function(e,t,r){p.texParameteri(e,t,E[r>>2])},jc:function(e,t,r,i,o){p.texStorage2D(e,t,r,i,o)},fb:function(e,t,r,i,o,s,l,c,h){if(2<=B.version)if(p.Zd)p.texSubImage2D(e,t,r,i,o,s,l,c,h);else if(h){var g=yt(c);p.texSubImage2D(e,t,r,i,o,s,l,c,g,h>>31-Math.clz32(g.BYTES_PER_ELEMENT))}else p.texSubImage2D(e,t,r,i,o,s,l,c,null);else g=null,h&&(g=bt(c,l,o,s,h)),p.texSubImage2D(e,t,r,i,o,s,l,c,g)},gb:function(e,t){p.uniform1f(H(e),t)},hb:function(e,t,r){if(2<=B.version)t&&p.uniform1fv(H(e),R,r>>2,t);else{if(288>=t)for(var i=Ae[t-1],o=0;o<t;++o)i[o]=R[r+4*o>>2];else i=R.subarray(r>>2,r+4*t>>2);p.uniform1fv(H(e),i)}},Uc:function(e,t){p.uniform1i(H(e),t)},Vc:function(e,t,r){if(2<=B.version)t&&p.uniform1iv(H(e),E,r>>2,t);else{if(288>=t)for(var i=Je[t-1],o=0;o<t;++o)i[o]=E[r+4*o>>2];else i=E.subarray(r>>2,r+4*t>>2);p.uniform1iv(H(e),i)}},Wc:function(e,t,r){p.uniform2f(H(e),t,r)},Xc:function(e,t,r){if(2<=B.version)t&&p.uniform2fv(H(e),R,r>>2,2*t);else{if(144>=t)for(var i=Ae[2*t-1],o=0;o<2*t;o+=2)i[o]=R[r+4*o>>2],i[o+1]=R[r+(4*o+4)>>2];else i=R.subarray(r>>2,r+8*t>>2);p.uniform2fv(H(e),i)}},Tc:function(e,t,r){p.uniform2i(H(e),t,r)},Sc:function(e,t,r){if(2<=B.version)t&&p.uniform2iv(H(e),E,r>>2,2*t);else{if(144>=t)for(var i=Je[2*t-1],o=0;o<2*t;o+=2)i[o]=E[r+4*o>>2],i[o+1]=E[r+(4*o+4)>>2];else i=E.subarray(r>>2,r+8*t>>2);p.uniform2iv(H(e),i)}},Rc:function(e,t,r,i){p.uniform3f(H(e),t,r,i)},Qc:function(e,t,r){if(2<=B.version)t&&p.uniform3fv(H(e),R,r>>2,3*t);else{if(96>=t)for(var i=Ae[3*t-1],o=0;o<3*t;o+=3)i[o]=R[r+4*o>>2],i[o+1]=R[r+(4*o+4)>>2],i[o+2]=R[r+(4*o+8)>>2];else i=R.subarray(r>>2,r+12*t>>2);p.uniform3fv(H(e),i)}},Pc:function(e,t,r,i){p.uniform3i(H(e),t,r,i)},Oc:function(e,t,r){if(2<=B.version)t&&p.uniform3iv(H(e),E,r>>2,3*t);else{if(96>=t)for(var i=Je[3*t-1],o=0;o<3*t;o+=3)i[o]=E[r+4*o>>2],i[o+1]=E[r+(4*o+4)>>2],i[o+2]=E[r+(4*o+8)>>2];else i=E.subarray(r>>2,r+12*t>>2);p.uniform3iv(H(e),i)}},Nc:function(e,t,r,i,o){p.uniform4f(H(e),t,r,i,o)},Mc:function(e,t,r){if(2<=B.version)t&&p.uniform4fv(H(e),R,r>>2,4*t);else{if(72>=t){var i=Ae[4*t-1],o=R;r>>=2;for(var s=0;s<4*t;s+=4){var l=r+s;i[s]=o[l],i[s+1]=o[l+1],i[s+2]=o[l+2],i[s+3]=o[l+3]}}else i=R.subarray(r>>2,r+16*t>>2);p.uniform4fv(H(e),i)}},Ac:function(e,t,r,i,o){p.uniform4i(H(e),t,r,i,o)},Bc:function(e,t,r){if(2<=B.version)t&&p.uniform4iv(H(e),E,r>>2,4*t);else{if(72>=t)for(var i=Je[4*t-1],o=0;o<4*t;o+=4)i[o]=E[r+4*o>>2],i[o+1]=E[r+(4*o+4)>>2],i[o+2]=E[r+(4*o+8)>>2],i[o+3]=E[r+(4*o+12)>>2];else i=E.subarray(r>>2,r+16*t>>2);p.uniform4iv(H(e),i)}},Cc:function(e,t,r,i){if(2<=B.version)t&&p.uniformMatrix2fv(H(e),!!r,R,i>>2,4*t);else{if(72>=t)for(var o=Ae[4*t-1],s=0;s<4*t;s+=4)o[s]=R[i+4*s>>2],o[s+1]=R[i+(4*s+4)>>2],o[s+2]=R[i+(4*s+8)>>2],o[s+3]=R[i+(4*s+12)>>2];else o=R.subarray(i>>2,i+16*t>>2);p.uniformMatrix2fv(H(e),!!r,o)}},Dc:function(e,t,r,i){if(2<=B.version)t&&p.uniformMatrix3fv(H(e),!!r,R,i>>2,9*t);else{if(32>=t)for(var o=Ae[9*t-1],s=0;s<9*t;s+=9)o[s]=R[i+4*s>>2],o[s+1]=R[i+(4*s+4)>>2],o[s+2]=R[i+(4*s+8)>>2],o[s+3]=R[i+(4*s+12)>>2],o[s+4]=R[i+(4*s+16)>>2],o[s+5]=R[i+(4*s+20)>>2],o[s+6]=R[i+(4*s+24)>>2],o[s+7]=R[i+(4*s+28)>>2],o[s+8]=R[i+(4*s+32)>>2];else o=R.subarray(i>>2,i+36*t>>2);p.uniformMatrix3fv(H(e),!!r,o)}},Ec:function(e,t,r,i){if(2<=B.version)t&&p.uniformMatrix4fv(H(e),!!r,R,i>>2,16*t);else{if(18>=t){var o=Ae[16*t-1],s=R;i>>=2;for(var l=0;l<16*t;l+=16){var c=i+l;o[l]=s[c],o[l+1]=s[c+1],o[l+2]=s[c+2],o[l+3]=s[c+3],o[l+4]=s[c+4],o[l+5]=s[c+5],o[l+6]=s[c+6],o[l+7]=s[c+7],o[l+8]=s[c+8],o[l+9]=s[c+9],o[l+10]=s[c+10],o[l+11]=s[c+11],o[l+12]=s[c+12],o[l+13]=s[c+13],o[l+14]=s[c+14],o[l+15]=s[c+15]}}else o=R.subarray(i>>2,i+64*t>>2);p.uniformMatrix4fv(H(e),!!r,o)}},Fc:function(e){e=se[e],p.useProgram(e),p.Re=e},Gc:function(e,t){p.vertexAttrib1f(e,t)},Hc:function(e,t){p.vertexAttrib2f(e,R[t>>2],R[t+4>>2])},Ic:function(e,t){p.vertexAttrib3f(e,R[t>>2],R[t+4>>2],R[t+8>>2])},Jc:function(e,t){p.vertexAttrib4f(e,R[t>>2],R[t+4>>2],R[t+8>>2],R[t+12>>2])},kc:function(e,t){p.vertexAttribDivisor(e,t)},lc:function(e,t,r,i,o){p.vertexAttribIPointer(e,t,r,i,o)},Kc:function(e,t,r,i,o,s){p.vertexAttribPointer(e,t,r,!!i,o,s)},Lc:function(e,t,r,i){p.viewport(e,t,r,i)},qb:function(e,t,r,i){p.waitSync(Ie[e],t,(r>>>0)+4294967296*i)},W:Dn,F:Rn,E:Bn,X:xn,Ib:bn,V:Ln,U:Hn,A:kn,B:Gn,D:In,L:Mn,sb:(e,t,r,i)=>An(e,t,r,i)};(function(){function e(r){if(k=r=r.exports,et=k.Yc,Kt(),Q=k._c,Qt.unshift(k.Zc),Fe--,_.monitorRunDependencies&&_.monitorRunDependencies(Fe),Fe==0&&(Ct!==null&&(clearInterval(Ct),Ct=null),Ue)){var i=Ue;Ue=null,i()}return r}var t={a:Fn};if(Fe++,_.monitorRunDependencies&&_.monitorRunDependencies(Fe),_.instantiateWasm)try{return _.instantiateWasm(t,e)}catch(r){Pe("Module.instantiateWasm callback failed with error: "+r),qe(r)}return Xr(t,function(r){e(r.instance)}).catch(qe),{}})();var _e=_._free=e=>(_e=_._free=k.$c)(e),_t=_._malloc=e=>(_t=_._malloc=k.ad)(e),Gr=e=>(Gr=k.bd)(e);_.__embind_initialize_bindings=()=>(_.__embind_initialize_bindings=k.cd)();var re=(e,t)=>(re=k.dd)(e,t),ne=()=>(ne=k.ed)(),ie=e=>(ie=k.fd)(e);_.dynCall_viji=(e,t,r,i,o)=>(_.dynCall_viji=k.gd)(e,t,r,i,o),_.dynCall_vijiii=(e,t,r,i,o,s,l)=>(_.dynCall_vijiii=k.hd)(e,t,r,i,o,s,l),_.dynCall_viiiiij=(e,t,r,i,o,s,l,c)=>(_.dynCall_viiiiij=k.id)(e,t,r,i,o,s,l,c),_.dynCall_jii=(e,t,r)=>(_.dynCall_jii=k.jd)(e,t,r),_.dynCall_vij=(e,t,r,i)=>(_.dynCall_vij=k.kd)(e,t,r,i),_.dynCall_iiij=(e,t,r,i,o)=>(_.dynCall_iiij=k.ld)(e,t,r,i,o),_.dynCall_iiiij=(e,t,r,i,o,s)=>(_.dynCall_iiiij=k.md)(e,t,r,i,o,s),_.dynCall_viij=(e,t,r,i,o)=>(_.dynCall_viij=k.nd)(e,t,r,i,o),_.dynCall_viiij=(e,t,r,i,o,s)=>(_.dynCall_viiij=k.od)(e,t,r,i,o,s),_.dynCall_ji=(e,t)=>(_.dynCall_ji=k.pd)(e,t),_.dynCall_iij=(e,t,r,i)=>(_.dynCall_iij=k.qd)(e,t,r,i),_.dynCall_jiiiiii=(e,t,r,i,o,s,l)=>(_.dynCall_jiiiiii=k.rd)(e,t,r,i,o,s,l),_.dynCall_jiiiiji=(e,t,r,i,o,s,l,c)=>(_.dynCall_jiiiiji=k.sd)(e,t,r,i,o,s,l,c),_.dynCall_iijj=(e,t,r,i,o,s)=>(_.dynCall_iijj=k.td)(e,t,r,i,o,s),_.dynCall_iiiji=(e,t,r,i,o,s)=>(_.dynCall_iiiji=k.ud)(e,t,r,i,o,s),_.dynCall_iiji=(e,t,r,i,o)=>(_.dynCall_iiji=k.vd)(e,t,r,i,o),_.dynCall_iijjiii=(e,t,r,i,o,s,l,c,h)=>(_.dynCall_iijjiii=k.wd)(e,t,r,i,o,s,l,c,h),_.dynCall_vijjjii=(e,t,r,i,o,s,l,c,h,g)=>(_.dynCall_vijjjii=k.xd)(e,t,r,i,o,s,l,c,h,g),_.dynCall_jiji=(e,t,r,i,o)=>(_.dynCall_jiji=k.yd)(e,t,r,i,o),_.dynCall_viijii=(e,t,r,i,o,s,l)=>(_.dynCall_viijii=k.zd)(e,t,r,i,o,s,l),_.dynCall_iiiiij=(e,t,r,i,o,s,l)=>(_.dynCall_iiiiij=k.Ad)(e,t,r,i,o,s,l),_.dynCall_iiiiijj=(e,t,r,i,o,s,l,c,h)=>(_.dynCall_iiiiijj=k.Bd)(e,t,r,i,o,s,l,c,h),_.dynCall_iiiiiijj=(e,t,r,i,o,s,l,c,h,g)=>(_.dynCall_iiiiiijj=k.Cd)(e,t,r,i,o,s,l,c,h,g);function Mn(e,t,r,i,o){var s=ne();try{Q.get(e)(t,r,i,o)}catch(l){if(ie(s),l!==l+0)throw l;re(1,0)}}function Rn(e,t,r){var i=ne();try{return Q.get(e)(t,r)}catch(o){if(ie(i),o!==o+0)throw o;re(1,0)}}function xn(e,t,r,i,o){var s=ne();try{return Q.get(e)(t,r,i,o)}catch(l){if(ie(s),l!==l+0)throw l;re(1,0)}}function In(e,t,r,i){var o=ne();try{Q.get(e)(t,r,i)}catch(s){if(ie(o),s!==s+0)throw s;re(1,0)}}function Dn(e,t){var r=ne();try{return Q.get(e)(t)}catch(i){if(ie(r),i!==i+0)throw i;re(1,0)}}function Bn(e,t,r,i){var o=ne();try{return Q.get(e)(t,r,i)}catch(s){if(ie(o),s!==s+0)throw s;re(1,0)}}function Gn(e,t,r){var i=ne();try{Q.get(e)(t,r)}catch(o){if(ie(i),o!==o+0)throw o;re(1,0)}}function Ln(e,t,r,i,o,s,l,c,h,g){var P=ne();try{return Q.get(e)(t,r,i,o,s,l,c,h,g)}catch(A){if(ie(P),A!==A+0)throw A;re(1,0)}}function kn(e,t){var r=ne();try{Q.get(e)(t)}catch(i){if(ie(r),i!==i+0)throw i;re(1,0)}}function bn(e,t,r,i,o,s,l){var c=ne();try{return Q.get(e)(t,r,i,o,s,l)}catch(h){if(ie(c),h!==h+0)throw h;re(1,0)}}function Hn(e){var t=ne();try{Q.get(e)()}catch(r){if(ie(t),r!==r+0)throw r;re(1,0)}}var gt;Ue=function e(){gt||Lr(),gt||(Ue=e)};function Lr(){function e(){if(!gt&&(gt=!0,_.calledRun=!0,!Yt)){if(At(Qt),St(_),_.onRuntimeInitialized&&_.onRuntimeInitialized(),_.postRun)for(typeof _.postRun=="function"&&(_.postRun=[_.postRun]);_.postRun.length;){var t=_.postRun.shift();Zt.unshift(t)}At(Zt)}}if(!(0<Fe)){if(_.preRun)for(typeof _.preRun=="function"&&(_.preRun=[_.preRun]);_.preRun.length;)Vr();At(Jt),0<Fe||(_.setStatus?(_.setStatus("Running..."),setTimeout(function(){setTimeout(function(){_.setStatus("")},1),e()},1)):e())}}if(_.preInit)for(typeof _.preInit=="function"&&(_.preInit=[_.preInit]);0<_.preInit.length;)_.preInit.pop()();return Lr(),Te.ready}})();typeof Sr=="object"&&typeof Wt=="object"?Wt.exports=Wr:typeof define=="function"&&define.amd&&define([],()=>Wr)});export default jn();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@splinetool/loader",
3
- "version": "1.12.87",
3
+ "version": "1.12.88",
4
4
  "description": "Spline is a collaborative design platform for creating production-ready interactive experiences in multiple dimensions. © 2025 Spline, Inc.",
5
5
  "keywords": [
6
6
  "spline",