three-live 1.3.2 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -1
- package/dist/index.d.ts +190 -0
- package/dist/three-author-engine.js +171 -163
- package/dist/three-author.cjs +145 -163
- package/dist/three-author.d.ts +190 -0
- package/dist/three-author.js +145 -163
- package/dist/three-convert.cjs +142 -160
- package/dist/three-convert.d.ts +190 -0
- package/dist/three-convert.js +142 -160
- package/dist/three-live-ai.cjs +41 -0
- package/dist/three-live-ai.d.ts +759 -0
- package/dist/three-live-ai.js +41 -0
- package/dist/three-live-ai.min.js +41 -0
- package/dist/three-live-animation.cjs +6 -6
- package/dist/three-live-animation.d.ts +190 -0
- package/dist/three-live-animation.js +5 -5
- package/dist/three-live-animation.min.js +5 -5
- package/dist/three-live-cad.cjs +2 -2
- package/dist/three-live-cad.d.ts +190 -0
- package/dist/three-live-cad.js +2 -2
- package/dist/three-live-cad.min.js +2 -2
- package/dist/three-live-element.cjs +50 -85
- package/dist/three-live-element.d.ts +190 -0
- package/dist/three-live-element.js +50 -85
- package/dist/three-live-full.cjs +907 -189
- package/dist/three-live-full.js +907 -189
- package/dist/three-live-full.min.js +907 -189
- package/dist/three-live-procedural.cjs +16 -0
- package/dist/three-live-procedural.d.ts +759 -0
- package/dist/three-live-procedural.js +16 -0
- package/dist/three-live-procedural.min.js +16 -0
- package/dist/three-live-sandbox.html +11 -1
- package/dist/three-live-studio.cjs +72 -17
- package/dist/three-live-studio.d.ts +190 -0
- package/dist/three-live-studio.js +72 -17
- package/dist/three-live-studio.min.js +73 -18
- package/dist/three-live-tsl.cjs +103 -0
- package/dist/three-live-tsl.d.ts +759 -0
- package/dist/three-live-tsl.js +103 -0
- package/dist/three-live-tsl.min.js +103 -0
- package/dist/three-live-viewer.cjs +50 -85
- package/dist/three-live-viewer.d.ts +190 -0
- package/dist/three-live-viewer.js +50 -85
- package/dist/three-live-viewer.min.js +50 -85
- package/dist/three-live-webgpu.cjs +585 -0
- package/dist/three-live-webgpu.d.ts +759 -0
- package/dist/three-live-webgpu.js +585 -0
- package/dist/three-live-webgpu.min.js +585 -0
- package/dist/three-live.cjs +147 -165
- package/dist/three-live.js +147 -165
- package/dist/three-live.min.js +147 -165
- package/dist/three-view.cjs +49 -84
- package/dist/three-view.d.ts +190 -0
- package/dist/three-view.js +50 -85
- package/dist/three-xr.cjs +141 -159
- package/dist/three-xr.d.ts +190 -0
- package/dist/three-xr.js +140 -158
- package/package.json +21 -1
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/var ue="__THREE_LIVE_REGISTRY__";function me(){let B=typeof globalThis<"u"?globalThis:{};if(!B[ue]){let Q={plugins:[],decoders:new Map};try{Object.defineProperty(B,ue,{value:Q,writable:!1,configurable:!1,enumerable:!1})}catch{B[ue]=Q}}return B[ue]}var ls=me().plugins;function ns(B){let Q=me();Q.workerExtensionInstallers||(Q.workerExtensionInstallers=[]),Q.workerExtensionInstallers.includes(B)||Q.workerExtensionInstallers.push(B)}function hs(B){let Q=me().plugins;Q.some(P=>P.name===B.name)||Q.push(B),B.onRegister?.()}function ke(B,Q){if(!B||!B.Vector3||!B.BufferGeometry)return null;let P=B.Vector3,Et=B.Matrix4,ft=B.BufferGeometry;if(typeof P.prototype.distanceToSquared!="function"&&(P.prototype.distanceToSquared=function(s){let t=this.x-Number(s?.x??0),e=this.y-Number(s?.y??0),i=this.z-Number(s?.z??0);return t*t+e*e+i*i}),typeof P.prototype.addScalar!="function"&&(P.prototype.addScalar=function(s){let t=Number(s)||0;return this.set(this.x+t,this.y+t,this.z+t)}),typeof P.prototype.applyQuaternion!="function"&&(P.prototype.applyQuaternion=function(s){let t=this.x,e=this.y,i=this.z,r=Number(s?.x)||0,a=Number(s?.y)||0,n=Number(s?.z)||0,h=s?.w===void 0?1:Number(s.w)||0,l=2*(a*i-n*e),o=2*(n*t-r*i),c=2*(r*e-a*t);return this.set(t+h*l+(a*c-n*o),e+h*o+(n*l-r*c),i+h*c+(r*o-a*l))}),typeof P.prototype.min!="function"&&(P.prototype.min=function(s){return this.set(Math.min(this.x,s.x),Math.min(this.y,s.y),Math.min(this.z,s.z))}),typeof P.prototype.max!="function"&&(P.prototype.max=function(s){return this.set(Math.max(this.x,s.x),Math.max(this.y,s.y),Math.max(this.z,s.z))}),typeof P.prototype.clamp!="function"&&(P.prototype.clamp=function(s,t){return this.set(Math.max(s.x,Math.min(t.x,this.x)),Math.max(s.y,Math.min(t.y,this.y)),Math.max(s.z,Math.min(t.z,this.z)))}),typeof P.prototype.clampScalar!="function"&&(P.prototype.clampScalar=function(s,t){return this.set(Math.max(s,Math.min(t,this.x)),Math.max(s,Math.min(t,this.y)),Math.max(s,Math.min(t,this.z)))}),typeof P.prototype.negate!="function"&&(P.prototype.negate=function(){return this.multiplyScalar(-1)}),typeof P.prototype.equals!="function"&&(P.prototype.equals=function(s){return!!s&&s.x===this.x&&s.y===this.y&&s.z===this.z}),Et&&typeof Et.prototype.getMaxScaleOnAxis!="function"&&(Et.prototype.getMaxScaleOnAxis=function(){let s=this.elements;return Math.sqrt(Math.max(s[0]*s[0]+s[1]*s[1]+s[2]*s[2],s[4]*s[4]+s[5]*s[5]+s[6]*s[6],s[8]*s[8]+s[9]*s[9]+s[10]*s[10]))}),B.MathUtils&&typeof B.MathUtils=="object"){let s=1234567;try{typeof B.MathUtils.seededRandom!="function"&&(B.MathUtils.seededRandom=t=>{t!==void 0&&(s=Number.isFinite(t)?t|0:0);let e=s=s+1831565813|0;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}),typeof B.MathUtils.randInt!="function"&&(B.MathUtils.randInt=(t,e)=>t+Math.floor(Math.random()*(e-t+1))),typeof B.MathUtils.randFloatSpread!="function"&&(B.MathUtils.randFloatSpread=t=>t*(.5-Math.random()))}catch{}}class K{constructor(t,e){this.isBox3=!0,this.min=t!=null?new P(t.x,t.y,t.z):new P(1/0,1/0,1/0),this.max=e!=null?new P(e.x,e.y,e.z):new P(-1/0,-1/0,-1/0)}set(t,e){return this.min.copy(t),this.max.copy(e),this}makeEmpty(){return this.min.set(1/0,1/0,1/0),this.max.set(-1/0,-1/0,-1/0),this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}clone(){return new K(this.min,this.max)}copy(t){return t?(this.min.copy(t.min),this.max.copy(t.max),this):this}expandByPoint(t){if(!t)return this;let e=Number(t.x),i=Number(t.y),r=t.z===void 0?0:Number(t.z);return!Number.isFinite(e)||!Number.isFinite(i)||!Number.isFinite(r)?this:(e<this.min.x&&(this.min.x=e),i<this.min.y&&(this.min.y=i),r<this.min.z&&(this.min.z=r),e>this.max.x&&(this.max.x=e),i>this.max.y&&(this.max.y=i),r>this.max.z&&(this.max.z=r),this)}expandByVector(t){if(this.isEmpty()||!t)return this;let e=Number(t.x),i=Number(t.y),r=Number(t.z);return!Number.isFinite(e)||!Number.isFinite(i)||!Number.isFinite(r)?this:(this.min.set(this.min.x-e,this.min.y-i,this.min.z-r),this.max.set(this.max.x+e,this.max.y+i,this.max.z+r),this.isEmpty()&&this.makeEmpty(),this)}expandByScalar(t){let e=Number(t);return this.isEmpty()||!Number.isFinite(e)?this:(this.min.set(this.min.x-e,this.min.y-e,this.min.z-e),this.max.set(this.max.x+e,this.max.y+e,this.max.z+e),this.isEmpty()&&this.makeEmpty(),this)}setFromArray(t){if(this.makeEmpty(),!t)return this;for(let e=0,i=t.length-2;e<i;e+=3)this.expandByPoint({x:t[e],y:t[e+1],z:t[e+2]});return this}setFromBufferAttribute(t){if(this.makeEmpty(),!t||typeof t.count!="number")return this;for(let e=0;e<t.count;e++)this.expandByPoint({x:t.getX(e),y:t.getY(e),z:t.getZ(e)});return this}setFromPoints(t){if(this.makeEmpty(),Array.isArray(t))for(let e of t)this.expandByPoint(e);return this}setFromCenterAndSize(t,e){if(!t||!e)return this;let i=Math.abs(Number(e.x)||0)*.5,r=Math.abs(Number(e.y)||0)*.5,a=Math.abs(Number(e.z)||0)*.5,n=Number(t.x)||0,h=Number(t.y)||0,l=Number(t.z)||0;return this.min.set(n-i,h-r,l-a),this.max.set(n+i,h+r,l+a),this}setFromObject(t,e){return this.makeEmpty().expandByObject(t,!!e)}expandByObject(t,e){return xi(this,t,!!e),this}getCenter(t=new P){return this.isEmpty()?t.set(0,0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t=new P){return this.isEmpty()?t.set(0,0,0):t.subVectors(this.max,this.min)}getParameter(t,e=new P){let i=this.max.x-this.min.x,r=this.max.y-this.min.y,a=this.max.z-this.min.z;return e.set(i!==0?(t.x-this.min.x)/i:0,r!==0?(t.y-this.min.y)/r:0,a!==0?(t.z-this.min.z)/a:0)}containsPoint(t){return!!t&&!this.isEmpty()&&t.x>=this.min.x&&t.x<=this.max.x&&t.y>=this.min.y&&t.y<=this.max.y&&t.z>=this.min.z&&t.z<=this.max.z}containsBox(t){return!!t&&this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z}intersectsBox(t){return!!t&&t.max.x>=this.min.x&&t.min.x<=this.max.x&&t.max.y>=this.min.y&&t.min.y<=this.max.y&&t.max.z>=this.min.z&&t.min.z<=this.max.z}intersectsSphere(t){return!t||this.isEmpty()||t.isEmpty()?!1:this.clampPoint(t.center,new P).distanceToSquared(t.center)<=t.radius*t.radius}intersectsPlane(t){if(!t?.normal||this.isEmpty())return!1;let e=t.normal.x,i=t.normal.y,r=t.normal.z,a=Number(t.constant)||0,n=(e>0?e*this.min.x:e*this.max.x)+(i>0?i*this.min.y:i*this.max.y)+(r>0?r*this.min.z:r*this.max.z),h=(e>0?e*this.max.x:e*this.min.x)+(i>0?i*this.max.y:i*this.min.y)+(r>0?r*this.max.z:r*this.min.z);return n<=-a&&h>=-a}clampPoint(t,e=new P){return this.isEmpty()?e.copy(t):e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.isEmpty()?1/0:this.clampPoint(t,new P).distanceTo(t)}getBoundingSphere(t=new Bt){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=this.getSize(new P).length()*.5,t)}intersect(t){return t?(this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this):this}union(t){return!t||t.isEmpty()?this:this.isEmpty()?this.copy(t):(this.min.min(t.min),this.max.max(t.max),this)}applyMatrix4(t){if(this.isEmpty()||!t)return this;let e=this.min.x,i=this.min.y,r=this.min.z,a=this.max.x,n=this.max.y,h=this.max.z,l=new P;this.makeEmpty();for(let o=0;o<8;o++)l.set(o&1?a:e,o&2?n:i,o&4?h:r).applyMatrix4(t),this.expandByPoint(l);return this}translate(t){return this.isEmpty()||!t?this:(this.min.add(t),this.max.add(t),this)}equals(t){return!!t&&t.min.equals(this.min)&&t.max.equals(this.max)}}function xi(s,t,e){if(!t)return;t.updateMatrixWorld?.(!0);let i=new P,r=new K,a=new Et,n=new Et,h=new Set,l=new Map,o=(m,u)=>{let f=m?.attributes?.position;if(!(!f||!(f.count>0)))if(e)for(let p=0;p<f.count;p++)i.set(f.getX(p),f.getY(p),f.getZ(p)).applyMatrix4(u),s.expandByPoint(i);else{let p=l.get(m);p||(p=new K().setFromBufferAttribute(f),l.set(m,p)),p.isEmpty()||s.union(r.copy(p).applyMatrix4(u))}},c=m=>{if(!m||typeof m!="object"||h.has(m)||(h.add(m),Q?.materializeDeclarativeGeometry?.(m),m.isBoxHelper&&m!==t))return;(m.isSprite||m.isBox3Helper)&&m._bakeAuthorGeometry?.();let u=m._sourceGeo||m.geometry;if(u&&u.attributes?.position&&m.matrixWorld)if(m.isInstancedMesh&&typeof m.getMatrixAt=="function"){let f=Math.floor((m.instanceMatrix?.array?.length??0)/16),p=Math.min(Math.max(0,Math.floor(Number(m.count)||0)),f);for(let d=0;d<p;d++)m.getMatrixAt(d,a),n.multiplyMatrices(m.matrixWorld,a),o(u,n)}else o(u,m.matrixWorld);if(Array.isArray(m.children))for(let f of m.children)c(f)};c(t)}class Bt{constructor(t,e=-1){this.isSphere=!0,this.center=t!=null?new P(t.x,t.y,t.z):new P;let i=Number(e);this.radius=Number.isFinite(i)?i:-1}set(t,e){t&&this.center.copy(t);let i=Number(e);return this.radius=Number.isFinite(i)?i:-1,this}setFromPoints(t,e){if(!Array.isArray(t)||t.length===0)return this.makeEmpty();if(e)this.center.copy(e);else{let n=new K().setFromPoints(t);if(n.isEmpty())return this.makeEmpty();n.getCenter(this.center)}let i=0,r=!1,a=new P;for(let n of t){let h=Number(n?.x),l=Number(n?.y),o=n?.z===void 0?0:Number(n.z);Number.isFinite(h)&&Number.isFinite(l)&&Number.isFinite(o)&&(r=!0,i=Math.max(i,this.center.distanceToSquared(a.set(h,l,o))))}return r?(this.radius=Math.sqrt(i),this):this.makeEmpty()}copy(t){return t?(this.center.copy(t.center),this.radius=t.radius,this):this}clone(){return new Bt(this.center,this.radius)}isEmpty(){return!(this.radius>=0)||!Number.isFinite(this.radius)}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(t){return!!t&&!this.isEmpty()&&t.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(t){return this.isEmpty()?1/0:t.distanceTo(this.center)-this.radius}intersectsSphere(t){if(!t||this.isEmpty()||t.isEmpty())return!1;let e=this.radius+t.radius;return t.center.distanceToSquared(this.center)<=e*e}intersectsBox(t){return!!t&&t.intersectsSphere(this)}intersectsPlane(t){if(!t?.normal||this.isEmpty())return!1;let e=t.normal.dot(this.center)+(Number(t.constant)||0);return Math.abs(e)<=this.radius}clampPoint(t,e=new P){return e.copy(t),this.isEmpty()||this.center.distanceToSquared(t)>this.radius*this.radius&&e.sub(this.center).normalize().multiplyScalar(this.radius).add(this.center),e}getBoundingBox(t=new K){return this.isEmpty()?t.makeEmpty():(t.set(this.center,this.center),t.expandByScalar(this.radius),t)}applyMatrix4(t){if(this.isEmpty()||!t)return this;let e=t.getMaxScaleOnAxis();return Number.isFinite(e)?(this.center.applyMatrix4(t),this.radius*=e,this):this.makeEmpty()}translate(t){return!this.isEmpty()&&t&&this.center.add(t),this}expandByPoint(t){if(!t||!Number.isFinite(t.x)||!Number.isFinite(t.y)||!Number.isFinite(t.z))return this;if(this.isEmpty())return this.center.copy(t),this.radius=0,this;let e=this.center.distanceToSquared(t);if(e>this.radius*this.radius){let i=Math.sqrt(e),r=(this.radius+i)*.5;this.center.addScaledVector(new P().subVectors(t,this.center),(i-this.radius)/(2*i)),this.radius=r}return this}union(t){if(!t||t.isEmpty())return this;if(this.isEmpty())return this.copy(t);if(this.center.equals(t.center))return this.radius=Math.max(this.radius,t.radius),this;let e=new P().subVectors(t.center,this.center),i=e.length();if(i+t.radius<=this.radius)return this;if(i+this.radius<=t.radius)return this.copy(t);let r=(this.radius+i+t.radius)*.5;return this.center.addScaledVector(e,(r-this.radius)/i),this.radius=r,this}equals(t){return!!t&&t.center.equals(this.center)&&t.radius===this.radius}}ft.prototype.computeBoundingSphere=function(){(!this.boundingSphere||!this.boundingSphere.isSphere)&&(this.boundingSphere=new Bt);let s=this.attributes?.position;if(!s||!(s.count>0))return this.boundingSphere.makeEmpty();let t=new K().setFromBufferAttribute(s);if(t.isEmpty())return this.boundingSphere.makeEmpty();let e=t.getCenter(this.boundingSphere.center),i=0,r=new P;for(let a=0;a<s.count;a++){let n=s.getX(a),h=s.getY(a),l=s.getZ(a);Number.isFinite(n)&&Number.isFinite(h)&&Number.isFinite(l)&&(i=Math.max(i,e.distanceToSquared(r.set(n,h,l))))}return this.boundingSphere.radius=Math.sqrt(i),this.boundingSphere},ft.prototype.computeBoundingBox=function(){(!this.boundingBox||!this.boundingBox.isBox3)&&(this.boundingBox=new K);let s=this.attributes?.position;return s&&s.count>0?this.boundingBox.setFromBufferAttribute(s):this.boundingBox.makeEmpty(),this.boundingSphere&&this.computeBoundingSphere(),this.boundingBox};let kt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Yt=512,st=2048,_i=16384,vi=256,Pe="AAAAAAAAAF8AAAAHAAcAFH8UfxQkKn8qEiMTCGRiNklVIlAABQMAAAAcIkEAAEEiHAAUCD4IFAgIPggIAFAwAAAICAgICABgYAAAIBAIBAI+UUlFPgBCf0AAQmFRSUYhQUVLMRgUEn8QJ0VFRTk8SklJMAFxCQUDNklJSTYGSUkpHgA2NgAAAFY2AAAIFCJBABQUFBQUAEEiFAgCAVEJBjJJeUE+fhEREX5/SUlJNj5BQUEif0FBIhx/SUlJQX8JCQkBPkFJSXp/CAgIfwBBf0EAIEBBPwF/CBQiQX9AQEBAfwIMAn9/BAgQfz5BQUE+fwkJCQY+QVEhXn8JGSlGRklJSTEBAX8BAT9AQEA/HyBAIB8/QDhAP2MUCBRjBwhwCAdhUUlFQwB/QUEAAgQIECAAQUF/AAQCAQIEQEBAQEAAAQIEACBUVFR4f0hERDg4REREIDhEREh/OFRUVBgIfgkBAgxSUlI+fwgEBHgARH1AACBARD0AfxAoRAAAQX9AAHwEGAR4fAgEBHg4REREOHwUFBQICBQUGHx8CAQECEhUVFQgBD9EQCA8QEAgfBwgQCAcPEAwQDxEKBAoRAxQUFA8RGRUTEQACDZBAAAAfwAAAEE2CAAIBAgQCA==",Fe=new Int16Array(128).fill(-1);for(let s=0;s<64;s++)Fe[kt.charCodeAt(s)]=s;let wi=(()=>{let s=new Uint8Array(475),t=0,e=0,i=0;for(let r=0;r<Pe.length&&i<475;r++){let a=Pe.charCodeAt(r);if(a===61)break;let n=a<128?Fe[a]:-1;n<0||(t=t<<6|n,e+=6,e>=8&&(e-=8,s[i++]=t>>e&255))}return s})(),Ai=(()=>{let s=new Uint32Array(256);for(let t=0;t<256;t++){let e=t;for(let i=0;i<8;i++)e=e&1?3988292384^e>>>1:e>>>1;s[t]=e>>>0}return s})(),Ue=s=>{let t=4294967295;for(let e=0;e<s.length;e++)t=Ai[(t^s[e])&255]^t>>>8;return(t^4294967295)>>>0},ce=(()=>{let s=new Float32Array(256);for(let t=0;t<256;t++){let e=t/255;s[t]=e<=.04045?e/12.92:Math.pow((e+.055)/1.055,2.4)}return s})(),Te=typeof globalThis<"u"?globalThis.__three_live_native_encode_rgba_png__:void 0,Le={};for(let s of"black:000000,white:ffffff,red:ff0000,lime:00ff00,green:008000,blue:0000ff,yellow:ffff00,cyan:00ffff,aqua:00ffff,magenta:ff00ff,fuchsia:ff00ff,silver:c0c0c0,gray:808080,grey:808080,darkgray:a9a9a9,darkgrey:a9a9a9,dimgray:696969,dimgrey:696969,lightgray:d3d3d3,lightgrey:d3d3d3,slategray:708090,slategrey:708090,darkslategray:2f4f4f,darkslategrey:2f4f4f,maroon:800000,olive:808000,purple:800080,teal:008080,navy:000080,orange:ffa500,orangered:ff4500,gold:ffd700,coral:ff7f50,salmon:fa8072,tomato:ff6347,crimson:dc143c,pink:ffc0cb,hotpink:ff69b4,deeppink:ff1493,indigo:4b0082,violet:ee82ee,plum:dda0dd,orchid:da70d6,brown:a52a2a,saddlebrown:8b4513,sienna:a0522d,chocolate:d2691e,peru:cd853f,tan:d2b48c,wheat:f5deb3,beige:f5f5dc,ivory:fffff0,linen:faf0e6,snow:fffafa,khaki:f0e68c,skyblue:87ceeb,deepskyblue:00bfff,dodgerblue:1e90ff,royalblue:4169e1,steelblue:4682b4,turquoise:40e0d0,aquamarine:7fffd4,chartreuse:7fff00,forestgreen:228b22,seagreen:2e8b57".split(",")){let[t,e]=s.split(":");Le[t]=parseInt(e,16)}let ht=s=>s>0?s<255?s+.5|0:255:0,fe=s=>{let t=s.trim();return t.endsWith("%")?ht(parseFloat(t)*255/100):ht(parseFloat(t))},je=s=>{if(!s)return 255;let t=s.trim();if(!t)return 255;let e=t.endsWith("%")?parseFloat(t)/100:parseFloat(t);return Number.isFinite(e)?ht(Math.max(0,Math.min(1,e))*255):255},Ie=(s,t=[0,0,0,255])=>{if(typeof s!="string")return t;let e=s.trim().toLowerCase();if(!e)return t;if(e==="transparent")return[0,0,0,0];if(e.charCodeAt(0)===35){let d=e.slice(1);if(d.length===3||d.length===4){let b=parseInt(d[0]+d[0],16),M=parseInt(d[1]+d[1],16),g=parseInt(d[2]+d[2],16),y=d.length===4?parseInt(d[3]+d[3],16):255;if(Number.isFinite(b+M+g+y))return[b,M,g,y]}else if(d.length===6||d.length===8){let b=parseInt(d.slice(0,2),16),M=parseInt(d.slice(2,4),16),g=parseInt(d.slice(4,6),16),y=d.length===8?parseInt(d.slice(6,8),16):255;if(Number.isFinite(b+M+g+y))return[b,M,g,y]}return t}let i=Le[e];if(i!==void 0)return[i>>16&255,i>>8&255,i&255,255];let r=/^(rgba?|hsla?)\(([^)]+)\)$/.exec(e);if(!r)return t;let a=r[1],n=r[2].replace(/\//g," ").split(/[\s,]+/).filter(Boolean);if(n.length<3)return t;if(a.startsWith("rgb"))return[fe(n[0]),fe(n[1]),fe(n[2]),je(n[3])];let h=parseFloat(n[0]);if(!Number.isFinite(h))return t;n[0].endsWith("turn")?h*=360:n[0].endsWith("rad")&&(h=h*180/Math.PI);let l=(h%360+360)%360/360,o=Math.max(0,Math.min(1,(parseFloat(n[1])||0)/100)),c=Math.max(0,Math.min(1,(parseFloat(n[2])||0)/100)),m=je(n[3]);if(o===0){let d=ht(c*255);return[d,d,d,m]}let u=c<.5?c*(1+o):c+o-c*o,f=2*c-u,p=d=>{let b=d;return b<0&&(b+=1),b>1&&(b-=1),b<1/6?f+(u-f)*6*b:b<1/2?u:b<2/3?f+(u-f)*(2/3-b)*6:f};return[ht(p(l+1/3)*255),ht(p(l)*255),ht(p(l-1/3)*255),m]},Pt=(s,t,e,i,r,a=Yt)=>{if(!s||t<=0||e<=0||s.length<t*e*4)return{uri:"",avgColor:[1,1,1,1]};if(typeof Te=="function"){let N=Te(s,t,e,i,r,a);if(Array.isArray(N)&&typeof N[0]=="string")return{uri:N[0],avgColor:[N[1],N[2],N[3],N[4]]}}let n=t>a||e>a?a/Math.max(t,e):1,h=Math.max(1,Math.round(t*n)),l=Math.max(1,Math.round(e*n)),o=1+h*4,c=l*o,m=2+Math.max(1,Math.ceil(c/65535))*5+c+4,u=new Uint8Array(57+m),f=new DataView(u.buffer);f.setUint32(0,2303741511),f.setUint32(4,218765834),f.setUint32(8,13),f.setUint32(12,1229472850),f.setUint32(16,h),f.setUint32(20,l),u[24]=8,u[25]=6,f.setUint32(29,Ue(u.subarray(12,29))),f.setUint32(33,m),f.setUint32(37,1229209940),u[41]=120,u[42]=1;let p=new Uint8Array(c),d=0,b=1,M=0,g=0,y=0,x=0,_=0,w=h===t&&l===e;for(let N=0;N<l;N++){p[d++]=0,M=(M+b)%65521;let S=i?l-1-N:N,U=w?S:Math.floor(S*e/l),O=w?S+1:Math.max(U+1,Math.floor((S+1)*e/l));for(let L=0;L<h;L++){let T=0,R=0,H=0,j=0;if(w){let I=(U*t+L)*4;T=s[I]|0,R=s[I+1]|0,H=s[I+2]|0,j=s[I+3]|0}else{let I=Math.floor(L*t/h),V=Math.max(I+1,Math.floor((L+1)*t/h)),D=0;for(let W=U;W<O&&W<e;W++)for(let G=I;G<V&&G<t;G++){let J=(W*t+G)*4;T+=s[J]|0,R+=s[J+1]|0,H+=s[J+2]|0,j+=s[J+3]|0,D++}D>1&&(T=T/D+.5|0,R=R/D+.5|0,H=H/D+.5|0,j=j/D+.5|0)}p[d++]=T,b+=T,M+=b,p[d++]=R,b+=R,M+=b,p[d++]=H,b+=H,M+=b,p[d++]=j,b+=j,M+=b,g+=r?T/255:ce[T],y+=r?R/255:ce[R],x+=r?H/255:ce[H],_+=j/255}b%=65521,M%=65521}let A=43,C=c,z=0;for(;C>0||z===0;){let N=Math.min(65535,C),S=C-N===0?1:0;if(u[A++]=S,f.setUint16(A,N,!0),f.setUint16(A+2,~N&65535,!0),A+=4,N>0&&(u.set(p.subarray(z,z+N),A),A+=N,z+=N,C-=N),S)break}f.setUint32(A,(M<<16|b)>>>0),A+=4,f.setUint32(A,Ue(u.subarray(37,A))),A+=4,f.setUint32(A,0),f.setUint32(A+4,1229278788),f.setUint32(A+8,2923585666);let k=Math.max(1,h*l),E=[g/k,y/k,x/k,_/k],F=["data:image/png;base64,"];for(let N=0;N<u.length;N+=3){let S=u[N]<<16|(u[N+1]??0)<<8|(u[N+2]??0);F.push(kt[S>>18&63]+kt[S>>12&63]+(N+1<u.length?kt[S>>6&63]:"=")+(N+2<u.length?kt[S&63]:"="))}return{uri:F.join(""),avgColor:E}},gt=(s,t,e,i)=>(s&255|(t&255)<<8|(e&255)<<16|(i&255)<<24)>>>0,Ni=s=>{if(s._lut)return s._lut;let t=new Uint32Array(256),e=s.s;if(e.length===1){let i=e[0].c;t.fill(gt(i[0],i[1],i[2],i[3]))}else if(e.length>1){let i=0;for(let r=0;r<256;r++){let a=r/255;if(a<=e[0].o){let n=e[0].c;t[r]=gt(n[0],n[1],n[2],n[3])}else if(a>=e[e.length-1].o){let n=e[e.length-1].c;t[r]=gt(n[0],n[1],n[2],n[3])}else{for(;i<e.length-2&&a>e[i+1].o;)i++;let n=e[i],h=e[i+1],l=h.o-n.o,o=l>1e-9?(a-n.o)/l:0;t[r]=gt(n.c[0]+(h.c[0]-n.c[0])*o+.5|0,n.c[1]+(h.c[1]-n.c[1])*o+.5|0,n.c[2]+(h.c[2]-n.c[2])*o+.5|0,n.c[3]+(h.c[3]-n.c[3])*o+.5|0)}}}return s._lut=t,t},Ci=(s,t,e)=>{if(s.s.length===0)return 0;let i=Ni(s),r=0;if(s.rad){let n=s.x1-s.x0,h=s.y1-s.y0,l=s.r1-s.r0,o=t-s.x0,c=e-s.y0,m=n*n+h*h-l*l,u=-2*(o*n+c*h+s.r0*l),f=o*o+c*c-s.r0*s.r0;if(Math.abs(m)<1e-9)r=Math.abs(u)>1e-9?-f/u:0;else{let p=Math.sqrt(Math.max(0,u*u-4*m*f)),d=(-u+p)/(2*m),b=(-u-p)/(2*m);r=s.r0+d*l>=0?d:s.r0+b*l>=0?b:Math.max(d,b)}}else{let n=s.x1-s.x0,h=s.y1-s.y0,l=n*n+h*h;if(l<=1e-12)return i[255];r=((t-s.x0)*n+(e-s.y0)*h)/l}let a=r<=0?0:r>=1?255:r*255+.5|0;return i[a]};class pe{constructor(t,e,i,r,a,n,h){this._g=1,this.rad=t,this.x0=Number(e)||0,this.y0=Number(i)||0,this.r0=Math.max(0,Number(r)||0),this.x1=Number(a)||0,this.y1=Number(n)||0,this.r1=Math.max(0,Number(h)||0),this.s=[],this._lut=null}addColorStop(t,e){let i=Math.max(0,Math.min(1,Number(t)||0));this.s.push({o:i,c:Ie(e,[0,0,0,255]),i:this.s.length}),this.s.sort((r,a)=>r.o-a.o||r.i-a.i),this._lut=null}}class Oe{constructor(t,e,i,r){this._g=2,this.d=t,this.w=Math.max(1,e|0),this.h=Math.max(1,i|0);let a=(r||"repeat").toLowerCase();this.rx=a==="repeat"||a==="repeat-x",this.ry=a==="repeat"||a==="repeat-y"}}let zi=(s,t,e)=>{let i=Math.floor(t),r=Math.floor(e);if(s.rx)i=(i%s.w+s.w)%s.w;else if(i<0||i>=s.w)return 0;if(s.ry)r=(r%s.h+s.h)%s.h;else if(r<0||r>=s.h)return 0;let a=(r*s.w+i)*4;return gt(s.d[a],s.d[a+1],s.d[a+2],s.d[a+3])},Si=s=>s>=32&&s<=126?s:s===176?39:s===8226||s===183?42:s===8211||s===8212||s===8722?45:s===215?120:s===8216||s===8217?39:s===8220||s===8221?34:63,Re=new Array(190),Ei=(s,t)=>{let e=(s-32)*2+(t?1:0),i=Re[e];if(i)return i;let r=new Uint8Array(63),a=(s-32)*5;for(let h=0;h<5;h++){let l=wi[a+h]??0;for(let o=0;o<7;o++)l>>o&1&&(r[(o+1)*7+(h+1)]=1)}let n=new Uint8Array(140);for(let h=0;h<7;h++)for(let l=0;l<5;l++){let o=(h+1)*7+(l+1),c=r[o],m=r[o-7],u=r[o+1],f=r[o-1],p=r[o+7],d=h*2,b=l*2;n[d*10+b]=f===m&&f!==p&&m!==u?m:c,n[d*10+b+1]=m===u&&m!==f&&u!==p?u:c,n[(d+1)*10+b]=p===f&&p!==u&&f!==m?f:c,n[(d+1)*10+b+1]=u===p&&u!==m&&p!==f?p:c}if(t)for(let h=0;h<14;h++)for(let l=9;l>=1;l--)n[h*10+l-1]&&(n[h*10+l]=1);return Re[e]=n,n},Qe=s=>{let t=String(s||"10px sans-serif"),e=/\b(bold|bolder|[6-9]00)\b/i.test(t),i=/(\d+(?:\.\d+)?)\s*(px|pt|em|rem)\b/i.exec(t);if(!i)return{sizePx:10,bold:e};let r=parseFloat(i[1]),a=i[2].toLowerCase();return a==="pt"?r*=4/3:(a==="em"||a==="rem")&&(r*=16),{sizePx:Number.isFinite(r)&&r>0?Math.min(1024,r):10,bold:e}},He=s=>{s.fillStyle="#000000",s.strokeStyle="#000000",s.globalAlpha=1,s.globalCompositeOperation="source-over",s.lineWidth=1,s.lineCap="butt",s.lineJoin="miter",s.lineDashOffset=0,s.font="10px sans-serif",s.textAlign="start",s.textBaseline="alphabetic",s.shadowColor="rgba(0, 0, 0, 0)",s.shadowBlur=0,s.shadowOffsetX=0,s.shadowOffsetY=0,s._m=[1,0,0,1,0,0],s._dash=[],s._clip=null,s._stack=[],s._subs=[],s._cur=null,s._pts=0},q=(s,t,e)=>{let i=s._m;return[(i[0]*t+i[2]*e+i[4])*s.canvas._sx,(i[1]*t+i[3]*e+i[5])*s.canvas._sy]},Jt=s=>{let t=s.canvas._sx>0?1/s.canvas._sx:1,e=s.canvas._sy>0?1/s.canvas._sy:1,i=s._m,r=i[0]*i[3]-i[1]*i[2];if(Math.abs(r)<1e-12)return[0,0,0,0,0,0];let a=1/r;return[i[3]*t*a,-i[2]*e*a,(-i[3]*i[4]+i[2]*i[5])*a,-i[1]*t*a,i[0]*e*a,(i[1]*i[4]-i[0]*i[5])*a]},Bi=(s,t,e)=>{let[i,r,a,n,h,l]=Jt(s);return[i*t+r*e+a,n*t+h*e+l]},Ft=s=>{let t=String(s.globalCompositeOperation||"source-over").toLowerCase();return t==="source-over"?0:t==="copy"?1:t==="destination-out"?2:t==="lighter"||t==="add"?3:t==="multiply"?4:t==="screen"?5:0},ye=(s,t,e)=>{s._pts>=_i||!s._cur||(s._cur.pts.push([t,e]),s._pts++)},Xt=(s,t)=>{let e=Number(s.globalAlpha),i=Number.isFinite(e)?Math.max(0,Math.min(1,e)):1,r=Math.round(i*256);if(typeof t=="string"){let h=Ie(t,[0,0,0,255]),l=gt(h[0],h[1],h[2],h[3]*r+128>>8);return()=>l}let a=t?t._g:0;if(a===1||a===2){let[h,l,o,c,m,u]=Jt(s);return(f,p)=>{let d=h*f+l*p+o,b=c*f+m*p+u,M=a===1?Ci(t,d,b):zi(t,d,b);if(r>=256)return M;let g=(M>>>24)*r+128>>8&255;return(M&16777215|g<<24)>>>0}}let n=gt(0,0,0,255*r+128>>8);return()=>n},Nt=(s,t,e,i,r)=>{let a=s.canvas._bw,n=s.canvas._bh;if(e<0||e>=a||i<0||i>=n)return;let h=i*a+e;if(s._clip&&!s._clip[h])return;let l=s.canvas._data,o=h*4,c=r&255,m=r>>>8&255,u=r>>>16&255,f=r>>>24;if(t===1){l[o]=c,l[o+1]=m,l[o+2]=u,l[o+3]=f;return}if(f<=0)return;if(f>=255&&t===0){l[o]=c,l[o+1]=m,l[o+2]=u,l[o+3]=255;return}if(t===2){l[o+3]=(l[o+3]*(255-f)+127)/255|0,l[o+3]===0&&(l[o]=l[o+1]=l[o+2]=0);return}if(t===3){l[o]=Math.min(255,l[o]+((c*f+127)/255|0)),l[o+1]=Math.min(255,l[o+1]+((m*f+127)/255|0)),l[o+2]=Math.min(255,l[o+2]+((u*f+127)/255|0)),l[o+3]=Math.min(255,l[o+3]+f);return}let p=l[o+3],d=f/255,b=p/255,M=d+b*(1-d);if(M<=1e-6){l[o]=l[o+1]=l[o+2]=l[o+3]=0;return}let g=c,y=m,x=u;t===4&&p>0?(g=(g*l[o]+127)/255,y=(y*l[o+1]+127)/255,x=(x*l[o+2]+127)/255):t===5&&p>0&&(g=255-(255-g)*(255-l[o])/255,y=255-(255-y)*(255-l[o+1])/255,x=255-(255-x)*(255-l[o+2])/255),l[o]=ht((g*d+l[o]*b*(1-d))/M),l[o+1]=ht((y*d+l[o+1]*b*(1-d))/M),l[o+2]=ht((x*d+l[o+2]*b*(1-d))/M),l[o+3]=ht(M*255)},Ut=(s,t,e,i)=>{if(s.canvas.width<=0||s.canvas.height<=0)return;let r=s.canvas._bw,a=s.canvas._bh,n=[],h=a,l=-1;for(let p of t){let d=p.pts,b=d.length;if(!(b<2))for(let M=0;M<b;M++){let[g,y]=d[M],[x,_]=d[(M+1)%b];if(y===_)continue;let w=Math.min(y,_),A=Math.max(y,_);n.push([w,A,_>y?g:x,(_>y?x-g:g-x)/(A-w),_>y?1:-1]),w<h&&(h=w),A>l&&(l=A)}}if(n.length===0)return;let o=Math.max(0,Math.floor(h)),c=Math.min(a-1,Math.ceil(l)),m=e==="evenodd",u=(p,d,b)=>{for(let M=d;M<=b;M++)i(M,p)},f=[];for(let p=o;p<=c;p++){let d=p+.5;f.length=0;for(let b=0;b<n.length;b++){let M=n[b];M[0]<=d&&M[1]>d&&f.push([M[2]+(d-M[0])*M[3],M[4]])}if(!(f.length<2))if(f.sort((b,M)=>b[0]-M[0]),m)for(let b=0;b+1<f.length;b+=2)u(p,Math.max(0,Math.ceil(f[b][0]-.5)),Math.min(r-1,Math.floor(f[b+1][0]-.5)));else{let b=0,M=0;for(let g=0;g<f.length;g++){let y=b;b+=f[g][1],y===0&&b!==0?M=f[g][0]:y!==0&&b===0&&u(p,Math.max(0,Math.ceil(M-.5)),Math.min(r-1,Math.floor(f[g][0]-.5)))}}}},De=(s,t,e,i,r,a)=>{if(!Number.isFinite(e+i)||s.canvas.width<=0||s.canvas.height<=0)return;let n=String(t??"").slice(0,1024);if(!n)return;let h=Array.from(n),{sizePx:l,bold:o}=Qe(s.font),c=l,m=l*(o?.54:.5),u=l*(o?.64:.6),f=h.length*u-l*.1,p=1;if(r!==void 0&&Number.isFinite(r)){if(r<=0)return;f>r&&f>0&&(p=r/f)}let d=f*p,b=e;s.textAlign==="center"?b-=d*.5:(s.textAlign==="right"||s.textAlign==="end")&&(b-=d);let M=i,g=s.textBaseline;g==="middle"?M-=c*.5:g==="bottom"||g==="ideographic"?M-=c:g==="alphabetic"?M-=c*.82:g==="hanging"&&(M-=c*.08);let y=Xt(s,a?s.strokeStyle:s.fillStyle),x=Ft(s),[_,w,A,C,z,k]=Jt(s),E=s.canvas._bw,F=s.canvas._bh,N=new Uint8Array(E*F),S=m*p;if(S<=1e-6||c<=1e-6)return;let U=1/S,O=1/c;for(let L=0;L<h.length;L++){let T=Si(h[L].codePointAt(0)??32);if(T===32)continue;let R=b+L*u*p,H=Ei(T,o),j=q(s,R,M),I=q(s,R+S,M),V=q(s,R+S,M+c),D=q(s,R,M+c),W=Math.max(0,Math.floor(Math.min(j[0],I[0],V[0],D[0]))),G=Math.min(E-1,Math.ceil(Math.max(j[0],I[0],V[0],D[0]))),J=Math.max(0,Math.floor(Math.min(j[1],I[1],V[1],D[1]))),X=Math.min(F-1,Math.ceil(Math.max(j[1],I[1],V[1],D[1])));for(let nt=J;nt<=X;nt++){let tt=nt+.5;for(let yt=W;yt<=G;yt++){let St=nt*E+yt;if(N[St])continue;let At=yt+.5,Ht=_*At+w*tt+A,Dt=C*At+z*tt+k,dt=(Ht-R)*U,bt=(Dt-M)*O;if(dt<0||dt>=1||bt<0||bt>=1)continue;let et=Math.min(9,dt*10|0),it=Math.min(13,bt*14|0);H[it*10+et]===1&&(a&&et>0&&et<9&&it>0&&it<13&&H[it*10+et-1]&&H[it*10+et+1]&&H[(it-1)*10+et]&&H[(it+1)*10+et]||(N[St]=1,Nt(s,x,yt,nt,y(At,tt))))}}}s.canvas._ver++};class qe{constructor(t){this.canvas=t,He(this)}save(){this._stack.length>=vi||this._stack.push([this._m.slice(),this.fillStyle,this.strokeStyle,this.globalAlpha,this.globalCompositeOperation,this.lineWidth,this.lineCap,this.lineJoin,this._dash.slice(),this.lineDashOffset,this.font,this.textAlign,this.textBaseline,this.shadowColor,this.shadowBlur,this.shadowOffsetX,this.shadowOffsetY,this._clip?new Uint8Array(this._clip):null])}restore(){let t=this._stack.pop();t&&([this._m,this.fillStyle,this.strokeStyle,this.globalAlpha,this.globalCompositeOperation,this.lineWidth,this.lineCap,this.lineJoin,this._dash,this.lineDashOffset,this.font,this.textAlign,this.textBaseline,this.shadowColor,this.shadowBlur,this.shadowOffsetX,this.shadowOffsetY,this._clip]=t)}setLineDash(t){if(!Array.isArray(t))return;let e=[];for(let i=0;i<Math.min(64,t.length);i++){let r=Number(t[i]);if(!Number.isFinite(r)||r<0)return;e.push(r)}this._dash=e.length%2===1?[...e,...e]:e}getLineDash(){return[...this._dash]}resetTransform(){this._m=[1,0,0,1,0,0]}setTransform(t,e,i,r,a,n){if(t&&typeof t=="object"){this.setTransform(t.a??1,t.b??0,t.c??0,t.d??1,t.e??0,t.f??0);return}let h=Number(t??1),l=Number(e??0),o=Number(i??0),c=Number(r??1),m=Number(a??0),u=Number(n??0);Number.isFinite(h+l+o+c+m+u)&&(this._m=[h,l,o,c,m,u])}getTransform(){let t=this._m;return{a:t[0],b:t[1],c:t[2],d:t[3],e:t[4],f:t[5]}}transform(t,e,i,r,a,n){if(!Number.isFinite(t+e+i+r+a+n))return;let h=this._m;this._m=[h[0]*t+h[2]*e,h[1]*t+h[3]*e,h[0]*i+h[2]*r,h[1]*i+h[3]*r,h[0]*a+h[2]*n+h[4],h[1]*a+h[3]*n+h[5]]}translate(t,e){this.transform(1,0,0,1,t,e)}rotate(t){if(!Number.isFinite(t))return;let e=Math.cos(t),i=Math.sin(t);this.transform(e,i,-i,e,0,0)}scale(t,e){this.transform(t,0,0,e,0,0)}createLinearGradient(t,e,i,r){return new pe(!1,t,e,0,i,r,0)}createRadialGradient(t,e,i,r,a,n){return new pe(!0,t,e,i,r,a,n)}createPattern(t,e="repeat"){let i=Kt(t);return i?new Oe(i.data,i.width,i.height,e):null}beginPath(){this._subs.length=0,this._cur=null,this._pts=0}closePath(){if(this._cur&&this._cur.pts.length>0){this._cur.closed=!0;let t=this._cur.pts[0];this._cur={pts:[[t[0],t[1]]],closed:!1},this._subs.push(this._cur)}}moveTo(t,e){Number.isFinite(t+e)&&(this._cur={pts:[q(this,t,e)],closed:!1},this._subs.push(this._cur),this._pts++)}lineTo(t,e){if(!Number.isFinite(t+e))return;if(!this._cur||this._cur.pts.length===0){this.moveTo(t,e);return}let i=q(this,t,e);ye(this,i[0],i[1])}rect(t,e,i,r){Number.isFinite(t+e+i+r)&&(this.moveTo(t,e),this.lineTo(t+i,e),this.lineTo(t+i,e+r),this.lineTo(t,e+r),this.closePath())}roundRect(t,e,i,r,a){if(!Number.isFinite(t+e+i+r))return;i<0&&(t+=i,i=-i),r<0&&(e+=r,r=-r);let n=Array.isArray(a)?a:a!==void 0?[a]:[0],h=f=>{let p=Number(f&&typeof f=="object"?f.x??0:f??0);return Number.isFinite(p)?Math.max(0,p):0},l=h(n[0]),o=h(n[1]??n[0]),c=h(n[2]??n[0]),m=h(n[3]??n[1]??n[0]),u=Math.min(1,i/Math.max(1e-6,l+o),i/Math.max(1e-6,m+c),r/Math.max(1e-6,l+m),r/Math.max(1e-6,o+c));if(l*=u,o*=u,c*=u,m*=u,l+o+c+m<=1e-4){this.rect(t,e,i,r);return}this.moveTo(t+l,e),this.lineTo(t+i-o,e),o>0&&this.arc(t+i-o,e+o,o,-Math.PI/2,0),this.lineTo(t+i,e+r-c),c>0&&this.arc(t+i-c,e+r-c,c,0,Math.PI/2),this.lineTo(t+m,e+r),m>0&&this.arc(t+m,e+r-m,m,Math.PI/2,Math.PI),this.lineTo(t,e+l),l>0&&this.arc(t+l,e+l,l,Math.PI,Math.PI*3/2),this.closePath()}quadraticCurveTo(t,e,i,r){if(!Number.isFinite(t+e+i+r))return;(!this._cur||this._cur.pts.length===0)&&this.moveTo(t,e);let a=this._cur.pts,[n,h]=a[a.length-1],[l,o]=q(this,t,e),[c,m]=q(this,i,r),u=Math.max(4,Math.min(64,Math.ceil((Math.hypot(l-n,o-h)+Math.hypot(c-l,m-o))*.5)));for(let f=1;f<=u;f++){let p=f/u,d=1-p;ye(this,d*d*n+2*d*p*l+p*p*c,d*d*h+2*d*p*o+p*p*m)}}bezierCurveTo(t,e,i,r,a,n){if(!Number.isFinite(t+e+i+r+a+n))return;(!this._cur||this._cur.pts.length===0)&&this.moveTo(t,e);let h=this._cur.pts,[l,o]=h[h.length-1],[c,m]=q(this,t,e),[u,f]=q(this,i,r),[p,d]=q(this,a,n),b=Math.max(6,Math.min(64,Math.ceil((Math.hypot(c-l,m-o)+Math.hypot(u-c,f-m)+Math.hypot(p-u,d-f))*.4)));for(let M=1;M<=b;M++){let g=M/b,y=1-g,x=y*y,_=g*g;ye(this,x*y*l+3*x*g*c+3*y*_*u+_*g*p,x*y*o+3*x*g*m+3*y*_*f+_*g*d)}}ellipse(t,e,i,r,a=0,n=0,h=Math.PI*2,l=!1){if(!Number.isFinite(t+e+i+r+a+n+h))return;let o=Math.max(0,i),c=Math.max(0,r),m=Math.PI*2,u=h-n;if(!l)u>=m?u=m:u<0&&(u=(u%m+m)%m);else if(u<=-m)u=-m;else if(u>0){let M=u%m;u=M===0?0:M-m}let f=Math.cos(a),p=Math.sin(a),d=Math.hypot(this._m[0]*this.canvas._sx,this._m[1]*this.canvas._sy,this._m[2]*this.canvas._sx,this._m[3]*this.canvas._sy),b=Math.max(8,Math.min(96,Math.ceil(Math.abs(u)*Math.max(1,o,c)*d/3)));for(let M=0;M<=b;M++){let g=n+u*M/b,y=o*Math.cos(g),x=c*Math.sin(g),_=t+y*f-x*p,w=e+y*p+x*f;M===0&&(!this._cur||this._cur.pts.length===0)?this.moveTo(_,w):this.lineTo(_,w)}}arc(t,e,i,r,a,n=!1){this.ellipse(t,e,i,i,0,r,a,n)}arcTo(t,e,i,r,a){if(!Number.isFinite(t+e+i+r+a))return;let n=Math.max(0,a);if(!this._cur||this._cur.pts.length===0){this.moveTo(t,e);return}if(n<=1e-6){this.lineTo(t,e);return}let h=this._cur.pts,[l,o]=h[h.length-1],[c,m]=Bi(this,l,o),u=c-t,f=m-e,p=i-t,d=r-e,b=Math.hypot(u,f),M=Math.hypot(p,d);if(b<1e-6||M<1e-6){this.lineTo(t,e);return}let g=u/b,y=f/b,x=p/M,_=d/M,w=g*_-y*x;if(Math.abs(w)<1e-6){this.lineTo(t,e);return}let A=Math.acos(Math.max(-1,Math.min(1,g*x+y*_)))*.5,C=n/Math.tan(A),z=g+x,k=y+_,E=Math.hypot(z,k)||1,F=n/Math.sin(A),N=t+z/E*F,S=e+k/E*F;this.arc(N,S,n,Math.atan2(e+y*C-S,t+g*C-N),Math.atan2(e+_*C-S,t+x*C-N),w>0)}fill(t){if(this.canvas.width<=0||this.canvas.height<=0)return;let e=Xt(this,this.fillStyle),i=Ft(this);Ut(this,this._subs,typeof t=="string"?t:"nonzero",(r,a)=>Nt(this,i,r,a,e(r+.5,a+.5))),this.canvas._ver++}clip(t){let e=this.canvas._bw,i=this.canvas._bh,r=new Uint8Array(e*i);if(Ut(this,this._subs,typeof t=="string"?t:"nonzero",(a,n)=>{r[n*e+a]=1}),this._clip)for(let a=0;a<r.length;a++)r[a]&=this._clip[a];this._clip=r}stroke(){if(this.canvas.width<=0||this.canvas.height<=0)return;let t=this._m,e=(Math.hypot(t[0]*this.canvas._sx,t[1]*this.canvas._sy)+Math.hypot(t[2]*this.canvas._sx,t[3]*this.canvas._sy))*.5,i=Number(this.lineWidth),r=Number.isFinite(i)&&i>0?i:1,a=Math.max(.5,r*e*.5),n=a*a,h=this.lineCap,l=this.canvas._bw,o=this.canvas._bh,c=Xt(this,this.strokeStyle),m=Ft(this),u=new Uint8Array(l*o),f=0,p=[];for(let g=0;g<this._dash.length;g++){let y=this._dash[g]*e;p.push(y),f+=y}let d=(g,y,x,_,w,A)=>{let C=g,z=y,k=x,E=_,F=k-C,N=E-z,S=Math.hypot(F,N);if(h==="square"&&S>1e-6){let j=F/S*a,I=N/S*a;w&&(C-=j,z-=I),A&&(k+=j,E+=I),F=k-C,N=E-z}let U=F*F+N*N,O=a+.5,L=Math.max(0,Math.floor(Math.min(C,k)-O)),T=Math.min(l-1,Math.ceil(Math.max(C,k)+O)),R=Math.max(0,Math.floor(Math.min(z,E)-O)),H=Math.min(o-1,Math.ceil(Math.max(z,E)+O));for(let j=R;j<=H;j++){let I=j+.5;for(let V=L;V<=T;V++){let D=j*l+V;if(u[D])continue;let W=V+.5,G=U>1e-9?((W-C)*F+(I-z)*N)/U:0;if(h==="butt"&&(G<0&&w||G>1&&A))continue;G=Math.max(0,Math.min(1,G));let J=C+G*F,X=z+G*N;(W-J)*(W-J)+(I-X)*(I-X)<=n&&(u[D]=1,Nt(this,m,V,j,c(W,I)))}}},b=Number(this.lineDashOffset),M=Number.isFinite(b)?b:0;for(let g of this._subs){let y=g.pts,x=y.length;if(x<2)continue;let _=g.closed?x:x-1,w=f>1e-6?(M*e%f+f)%f:0;for(let A=0;A<_;A++){let[C,z]=y[A],[k,E]=y[(A+1)%x];if(f<=1e-6)d(C,z,k,E,!g.closed&&A===0,!g.closed&&A===_-1);else{let F=Math.hypot(k-C,E-z);if(F<=1e-6)continue;let N=0;for(;N<F;){let S=w,U=0;for(;U<p.length&&S>=p[U];)S-=p[U],U++;let O=Math.min(F-N,U<p.length?Math.max(.25,p[U]-S):F-N);if(U%2===0){let L=N/F,T=(N+O)/F;d(C+(k-C)*L,z+(E-z)*L,C+(k-C)*T,z+(E-z)*T,!0,!0)}N+=O,w=(w+O)%f}}}}this.canvas._ver++}clearRect(t,e,i,r){if(!Number.isFinite(t+e+i+r)||this.canvas.width<=0||this.canvas.height<=0)return;let a=this._m;if(a[0]===1&&a[1]===0&&a[2]===0&&a[3]===1&&a[4]===0&&a[5]===0&&!this._clip&&t<=0&&e<=0&&t+i>=this.canvas.width&&e+r>=this.canvas.height){this.canvas._data.fill(0),this.canvas._ver++;return}let n=this.canvas._data,h=this.canvas._bw,l=this._clip;Ut(this,[{pts:[q(this,t,e),q(this,t+i,e),q(this,t+i,e+r),q(this,t,e+r)],closed:!0}],"nonzero",(o,c)=>{let m=c*h+o;if(l&&!l[m])return;let u=m*4;n[u]=n[u+1]=n[u+2]=n[u+3]=0}),this.canvas._ver++}fillRect(t,e,i,r){if(!Number.isFinite(t+e+i+r)||i===0||r===0||this.canvas.width<=0||this.canvas.height<=0)return;let a=Xt(this,this.fillStyle),n=Ft(this),h=this._m;if(h[1]===0&&h[2]===0){let l=this.canvas._bw,o=this.canvas._bh,c=(h[0]*t+h[4])*this.canvas._sx,m=(h[0]*(t+i)+h[4])*this.canvas._sx,u=(h[3]*e+h[5])*this.canvas._sy,f=(h[3]*(e+r)+h[5])*this.canvas._sy,p=Math.max(0,Math.ceil(Math.min(c,m)-.5)),d=Math.min(l-1,Math.ceil(Math.max(c,m)-.5)-1),b=Math.max(0,Math.ceil(Math.min(u,f)-.5)),M=Math.min(o-1,Math.ceil(Math.max(u,f)-.5)-1);if(p<=d&&b<=M){if(!this._clip&&typeof this.fillStyle=="string"){let y=a(0,0),x=y>>>24;if(n===0&&x>=255||n===1){let _=new Uint32Array(new Uint8Array([y&255,y>>>8&255,y>>>16&255,x]).buffer)[0],w=this.canvas._data,A=new Uint32Array(w.buffer,w.byteOffset,l*o);if(p===0&&d===l-1)A.fill(_,b*l,(M+1)*l);else for(let C=b;C<=M;C++)A.fill(_,C*l+p,C*l+d+1);this.canvas._ver++;return}}let g=y=>{let x=y+.5;for(let _=p;_<=d;_++)Nt(this,n,_,y,a(_+.5,x))};for(let y=b;y<=M;y++)g(y)}this.canvas._ver++;return}Ut(this,[{pts:[q(this,t,e),q(this,t+i,e),q(this,t+i,e+r),q(this,t,e+r)],closed:!0}],"nonzero",(l,o)=>Nt(this,n,l,o,a(l+.5,o+.5))),this.canvas._ver++}strokeRect(t,e,i,r){if(!Number.isFinite(t+e+i+r)||i===0&&r===0)return;let a=this._subs,n=this._cur,h=this._pts;this._subs=[],this._cur=null,this._pts=0,this.rect(t,e,i,r),this.stroke(),this._subs=a,this._cur=n,this._pts=h}measureText(t){let{sizePx:e,bold:i}=Qe(this.font),r=Array.from(String(t??"")).length;return{width:r>0?r*e*(i?.64:.6)-e*.1:0,actualBoundingBoxAscent:e*.8,actualBoundingBoxDescent:e*.2,fontBoundingBoxAscent:e*.85,fontBoundingBoxDescent:e*.2}}fillText(t,e,i,r){De(this,t,e,i,r,!1)}strokeText(t,e,i,r){De(this,t,e,i,r,!0)}createImageData(t,e){let i=t&&typeof t=="object",r=Math.max(1,Math.min(st,Math.floor(Math.abs(Number(i?t.width:t))||1))),a=Math.max(1,Math.min(st,Math.floor(Math.abs(Number(i?t.height:e))||1)));return{data:new Uint8ClampedArray(r*a*4),width:r,height:a}}getImageData(t,e,i,r){let a=Math.floor(Number(t)||0),n=Math.floor(Number(e)||0),h=Math.floor(Number(i)||0),l=Math.floor(Number(r)||0);h<0&&(a+=h,h=-h),l<0&&(n+=l,l=-l),h=Math.max(1,Math.min(st,h)),l=Math.max(1,Math.min(st,l));let o=new Uint8ClampedArray(h*l*4);if(this.canvas.width<=0||this.canvas.height<=0)return{data:o,width:h,height:l};let c=this.canvas._bw,m=this.canvas._bh,u=this.canvas._sx,f=this.canvas._sy,p=this.canvas._data;for(let d=0;d<l;d++){let b=n+d;if(b<0||b>=this.canvas.height)continue;let M=Math.min(m-1,Math.floor((b+.5)*f));for(let g=0;g<h;g++){let y=a+g;if(y<0||y>=this.canvas.width)continue;let x=(M*c+Math.min(c-1,Math.floor((y+.5)*u)))*4,_=(d*h+g)*4;o[_]=p[x],o[_+1]=p[x+1],o[_+2]=p[x+2],o[_+3]=p[x+3]}}return{data:o,width:h,height:l}}putImageData(t,e,i,r=0,a=0,n,h){if(!t?.data||this.canvas.width<=0||this.canvas.height<=0)return;let l=Math.floor(Number(t.width)||0),o=Math.floor(Number(t.height)||0);if(l<=0||o<=0)return;let c=Math.floor(Number(r)||0),m=Math.floor(Number(a)||0),u=n!==void 0?Math.floor(Number(n)):l,f=h!==void 0?Math.floor(Number(h)):o;u<0&&(c+=u,u=-u),f<0&&(m+=f,f=-f);let p=Math.max(0,c),d=Math.max(0,m),b=Math.min(l,c+u),M=Math.min(o,m+f);if(p>=b||d>=M)return;let g=Math.floor(Number(e)||0),y=Math.floor(Number(i)||0),x=this.canvas._bw,_=this.canvas._bh,w=1/this.canvas._sx,A=1/this.canvas._sy,C=this.canvas._data,z=t.data,k=Math.max(0,Math.floor((g+p)*this.canvas._sx)),E=Math.min(x-1,Math.ceil((g+b)*this.canvas._sx)-1),F=Math.max(0,Math.floor((y+d)*this.canvas._sy)),N=Math.min(_-1,Math.ceil((y+M)*this.canvas._sy)-1);for(let S=F;S<=N;S++){let U=Math.floor((S+.5)*A)-y;if(!(U<d||U>=M))for(let O=k;O<=E;O++){let L=Math.floor((O+.5)*w)-g;if(L<p||L>=b)continue;let T=(U*l+L)*4,R=(S*x+O)*4;C[R]=z[T]|0,C[R+1]=z[T+1]|0,C[R+2]=z[T+2]|0,C[R+3]=z[T+3]|0}}this.canvas._ver++}drawImage(t,...e){let i=Kt(t);if(!i||i.width<=0||i.height<=0||this.canvas.width<=0||this.canvas.height<=0)return;let r=Number(t?.width)>0?Number(t.width):i.width,a=Number(t?.height)>0?Number(t.height):i.height,n=0,h=0,l=r,o=a,c=0,m=0,u=r,f=a;if(e.length>=8)[n,h,l,o,c,m,u,f]=e;else if(e.length>=4)[c,m,u,f]=e;else if(e.length>=2)[c,m]=e;else return;if(!Number.isFinite(n+h+l+o+c+m+u+f)||l===0||o===0||u===0||f===0)return;let p=Number(this.globalAlpha),d=Number.isFinite(p)?Math.max(0,Math.min(1,p)):1,b=Math.round(d*256),M=Ft(this),[g,y,x,_,w,A]=Jt(this),C=1/u,z=1/f,k=i.width/r,E=i.height/a;Ut(this,[{pts:[q(this,c,m),q(this,c+u,m),q(this,c+u,m+f),q(this,c,m+f)],closed:!0}],"nonzero",(F,N)=>{let S=F+.5,U=N+.5,O=g*S+y*U+x,L=_*S+w*U+A,T=(O-c)*C,R=(L-m)*z;if(T<0||T>=1||R<0||R>=1)return;let H=Math.floor((n+T*l)*k),j=Math.floor((h+R*o)*E);if(H<0||H>=i.width||j<0||j>=i.height)return;let I=(j*i.width+H)*4;Nt(this,M,F,N,gt(i.data[I],i.data[I+1],i.data[I+2],i.data[I+3]*b+128>>8))}),this.canvas._ver++}}let de=(s,t,e)=>{let i=Math.floor(Number(t)),r=Math.floor(Number(e));s._w=Number.isFinite(i)&&i>=0?i:0,s._h=Number.isFinite(r)&&r>=0?r:0,s._bw=s._w>0?Math.min(Yt,s._w):1,s._bh=s._h>0?Math.min(Yt,s._h):1,s._sx=s._w>0?s._bw/s._w:1,s._sy=s._h>0?s._bh/s._h:1,s._data=new Uint8ClampedArray(s._bw*s._bh*4),s._ctx2d&&He(s._ctx2d),s._ver++};class Tt{constructor(t=300,e=150){this._vc=!0,this._ver=1,this._ctx2d=null,this.style={},de(this,t,e)}get width(){return this._w}set width(t){de(this,t,this._h)}get height(){return this._h}set height(t){de(this,this._w,t)}getContext(t){return String(t).toLowerCase()!=="2d"?null:this._ctx2d??(this._ctx2d=new qe(this))}toDataURL(){return this._w<=0||this._h<=0||this._w>st||this._h>st?"":Pt(this._data,this._bw,this._bh,!1,!1).uri}addEventListener(){}removeEventListener(){}getBoundingClientRect(){return{left:0,top:0,width:this._w,height:this._h,right:this._w,bottom:this._h}}}function Kt(s){if(!s||typeof s!="object")return null;let t=s._vc?s:s.canvas?._vc?s.canvas:s.image?._vc?s.image:null;if(t)return{data:t._data,width:t._bw,height:t._bh,logicalW:t._w,logicalH:t._h,ver:t._ver};let e=s.image&&typeof s.image=="object"?s.image:s;if(e.data&&typeof e.data.length=="number"&&Number(e.width)>0&&Number(e.height)>0){let i=Math.floor(Number(e.width)),r=Math.floor(Number(e.height));return{data:e.data instanceof Uint8ClampedArray?e.data:new Uint8ClampedArray(e.data),width:i,height:r,logicalW:i,logicalH:r,ver:-1}}if(typeof e.getContext=="function"){let i=Math.floor(Number(e.width)||0),r=Math.floor(Number(e.height)||0);if(i>0&&r>0&&i<=st&&r<=st)try{let a=e.getContext("2d")?.getImageData?.(0,0,i,r);if(a?.data)return{data:a.data instanceof Uint8ClampedArray?a.data:new Uint8ClampedArray(a.data),width:i,height:r,logicalW:i,logicalH:r,ver:-1}}catch{}}return null}let ki=B.Texture??class{constructor(s=""){this.source=s,this.isTexture=!0,this.image=null,this.width=0,this.height=0}dispose(){}},Ge=s=>{let t=Kt(s.image);if(!t){s.width=Number(s.image?.width??0)||0,s.height=Number(s.image?.height??0)||0,s._cs="";return}if(s.width=t.logicalW,s.height=t.logicalH,t.logicalW<=0||t.logicalH<=0||t.logicalW>st||t.logicalH>st){s._cs="";return}let e=`${t.ver>=0?t.ver:s._fs}|${t.logicalW}x${t.logicalH}|${s.flipY?1:0}|${s.colorSpace}`;if(e===s._bk&&s._cs)return;s._bk=e;let i=Pt(t.data,t.width,t.height,s.flipY,s.colorSpace==="srgb-linear",Math.min(st,Number(s._pngDim)||Yt));s._cs=i.uri,s._ca=i.avgColor};class be extends ki{constructor(t=null,e,i=1001,r=1001,a=1006,n=1008,h=1023,l=1009,o=1,c="srgb"){super(""),delete this.source,this.isCanvasTexture=!0,this.isDataTexture=!0,this.image=t,this.width=Number(t?.width??0)||0,this.height=Number(t?.height??0)||0,this.wrapS=Number(i)||1001,this.wrapT=Number(r)||1001,this.magFilter=Number(a)||1006,this.minFilter=Number(n)||1008,this.format=Number(h)||1023,this.type=Number(l)||1009,this.flipY=!0,this.generateMipmaps=!0,this.unpackAlignment=4,this.colorSpace=c||"srgb",this._bk="",this._cs="",this._ca=[1,1,1,1],this._ms="",this._fs=1}get needsUpdate(){return!1}set needsUpdate(t){t&&(this._ms="",this._fs++,this.width=Number(this.image?.width??0)||0,this.height=Number(this.image?.height??0)||0)}get source(){return this._ms?this._ms:(Ge(this),this._cs)}set source(t){this._ms=typeof t=="string"?t:""}get avgColor(){return this._ms||Ge(this),this._ca}set avgColor(t){Array.isArray(t)&&t.length===4&&(this._ca=[t[0],t[1],t[2],t[3]])}}try{Object.freeze(pe.prototype),Object.freeze(Oe.prototype),Object.freeze(qe.prototype),Object.freeze(Tt.prototype)}catch{}let Pi=(s=300,t=150)=>new Tt(s,t);try{let s=typeof globalThis<"u"?globalThis:typeof self<"u"?self:void 0;if(s&&typeof s.HTMLCanvasElement>"u"){let t=e=>String(e).toLowerCase()==="canvas"?new Tt(300,150):{style:{},getContext:()=>null,addEventListener:()=>{},removeEventListener:()=>{},appendChild:()=>{},removeChild:()=>{},setAttribute:()=>{}};if(typeof s.document>"u"||s.document===null){let e=Object.freeze({appendChild:()=>{},removeChild:()=>{},style:{}}),i=Object.freeze({style:{}});s.document=Object.freeze({__threeLiveVirtualCanvas:!0,createElement:t,createTextNode:()=>({}),querySelectorAll:()=>[],querySelector:()=>null,getElementById:()=>null,head:e,body:e,documentElement:i,addEventListener:()=>{},removeEventListener:()=>{}})}else if(typeof s.document=="object"&&!s.document.__threeLiveVirtualCanvas){let e=typeof s.document.createElement=="function"?s.document.createElement.bind(s.document):null;try{s.document.__threeLiveVirtualCanvas=!0,s.document.createElement=i=>String(i).toLowerCase()==="canvas"?new Tt(300,150):e?e(i):t(i)}catch{}}}}catch{}let Ve=new Uint8Array([151,160,137,91,90,15,131,13,201,95,96,53,194,233,7,225,140,36,103,30,69,142,8,99,37,240,21,10,23,190,6,148,247,120,234,75,0,26,197,62,94,252,219,203,117,35,11,32,57,177,33,88,237,149,56,87,174,20,125,136,171,168,68,175,74,165,71,134,139,48,27,166,77,146,158,231,83,111,229,122,60,211,133,230,220,105,92,41,55,46,245,40,244,102,143,54,65,25,63,161,1,216,80,73,209,76,132,187,208,89,18,169,200,196,135,130,116,188,159,86,164,100,109,198,173,186,3,64,52,217,226,250,124,123,5,202,38,147,118,126,255,82,85,212,207,206,59,227,47,16,58,17,182,189,28,42,223,183,170,213,119,248,152,2,44,154,163,70,221,153,101,155,167,43,172,9,129,22,39,253,19,98,108,110,79,113,224,232,178,185,112,104,218,246,97,228,251,34,242,193,238,210,144,12,191,179,162,241,81,51,145,235,249,14,239,107,49,192,214,31,181,199,106,157,184,84,204,176,115,121,50,45,127,4,150,254,138,236,205,93,222,114,67,29,24,72,243,141,128,195,78,66,215,61,156,180]),Y=new Uint8Array(512);for(let s=0;s<256;s++)Y[s]=Ve[s],Y[s+256]=Ve[s];let ge=s=>s*s*s*(s*(s*6-15)+10),_t=(s,t,e)=>t+s*(e-t),Mt=(s,t,e,i)=>{let r=s&15,a=r<8?t:e,n=r<4?e:r===12||r===14?t:i;return((r&1)===0?a:-a)+((r&2)===0?n:-n)};class We{noise(t,e,i=0){let r=Number(t),a=Number(e),n=Number(i);if(!Number.isFinite(r)||!Number.isFinite(a)||!Number.isFinite(n))return 0;let h=Math.floor(r),l=Math.floor(a),o=Math.floor(n),c=h&255,m=l&255,u=o&255;r-=h,a-=l,n-=o;let f=r-1,p=a-1,d=n-1,b=ge(r),M=ge(a),g=ge(n),y=Y[c]+m,x=Y[y]+u,_=Y[y+1]+u,w=Y[c+1]+m,A=Y[w]+u,C=Y[w+1]+u;return _t(g,_t(M,_t(b,Mt(Y[x],r,a,n),Mt(Y[A],f,a,n)),_t(b,Mt(Y[_],r,p,n),Mt(Y[C],f,p,n))),_t(M,_t(b,Mt(Y[x+1],r,a,d),Mt(Y[A+1],f,a,d)),_t(b,Mt(Y[_+1],r,p,d),Mt(Y[C+1],f,p,d))))}}Object.freeze(We.prototype);let Lt=new Int8Array([1,1,0,-1,1,0,1,-1,0,-1,-1,0,1,0,1,-1,0,1,1,0,-1,-1,0,-1,0,1,1,0,-1,1,0,1,-1,0,-1,-1]),Zt=new Int8Array([0,1,1,1,0,1,1,-1,0,1,-1,1,0,1,-1,-1,0,-1,1,1,0,-1,1,-1,0,-1,-1,1,0,-1,-1,-1,1,0,1,1,1,0,1,-1,1,0,-1,1,1,0,-1,-1,-1,0,1,1,-1,0,1,-1,-1,0,-1,1,-1,0,-1,-1,1,1,0,1,1,1,0,-1,1,-1,0,1,1,-1,0,-1,-1,1,0,1,-1,1,0,-1,-1,-1,0,1,-1,-1,0,-1,1,1,1,0,1,1,-1,0,1,-1,1,0,1,-1,-1,0,-1,1,1,0,-1,1,-1,0,-1,-1,1,0,-1,-1,-1,0]),Fi=.5*(Math.sqrt(3)-1),jt=(3-Math.sqrt(3))/6,Ui=1/3,ot=1/6,Ti=(Math.sqrt(5)-1)/4,$=(5-Math.sqrt(5))/20,Me=(s,t,e)=>Lt[s]*t+Lt[s+1]*e,te=(s,t,e,i)=>Lt[s]*t+Lt[s+1]*e+Lt[s+2]*i,It=(s,t,e,i,r)=>Zt[s]*t+Zt[s+1]*e+Zt[s+2]*i+Zt[s+3]*r;function Li(s){let t=s===void 0?Math:s;if(typeof t=="function")return t;if(typeof t=="number"){let e=Number.isFinite(t)?t|0:0;return()=>{let i=e=e+1831565813|0;return i=Math.imul(i^i>>>15,i|1),i^=i+Math.imul(i^i>>>7,i|61),((i^i>>>14)>>>0)/4294967296}}return t&&typeof t=="object"&&typeof t.random=="function"?()=>t.random():Math.random}class $e{constructor(t){let e=Li(t),i=new Uint8Array(256);for(let n=0;n<256;n++){let h=Number(e()),l=Number.isFinite(h)?(h%1+1)%1:0;i[n]=Math.floor(l*256)&255}let r=new Uint8Array(512),a=new Uint8Array(512);for(let n=0;n<512;n++){let h=i[n&255];r[n]=h,a[n]=h%12}this.p=i,this.perm=r,this.permMod12=a}noise(t,e){let i=Number(t),r=Number(e);if(!Number.isFinite(i)||!Number.isFinite(r))return 0;let a=this.perm,n=this.permMod12,h=(i+r)*Fi,l=Math.floor(i+h),o=Math.floor(r+h),c=(l+o)*jt,m=l-c,u=o-c,f=i-m,p=r-u,d=f>p?1:0,b=f>p?0:1,M=f-d+jt,g=p-b+jt,y=f-1+2*jt,x=p-1+2*jt,_=l&255,w=o&255,A=n[_+a[w]]*3,C=n[_+d+a[w+b]]*3,z=n[_+1+a[w+1]]*3,k=0,E=.5-f*f-p*p;E>=0&&(E*=E,k=E*E*Me(A,f,p));let F=0,N=.5-M*M-g*g;N>=0&&(N*=N,F=N*N*Me(C,M,g));let S=0,U=.5-y*y-x*x;return U>=0&&(U*=U,S=U*U*Me(z,y,x)),70*(k+F+S)}noise3d(t,e,i){let r=Number(t),a=Number(e),n=Number(i);if(!Number.isFinite(r)||!Number.isFinite(a)||!Number.isFinite(n))return 0;let h=this.perm,l=this.permMod12,o=(r+a+n)*Ui,c=Math.floor(r+o),m=Math.floor(a+o),u=Math.floor(n+o),f=(c+m+u)*ot,p=r-(c-f),d=a-(m-f),b=n-(u-f),M,g,y,x,_,w;p>=d?d>=b?(M=1,g=0,y=0,x=1,_=1,w=0):p>=b?(M=1,g=0,y=0,x=1,_=0,w=1):(M=0,g=0,y=1,x=1,_=0,w=1):d<b?(M=0,g=0,y=1,x=0,_=1,w=1):p<b?(M=0,g=1,y=0,x=0,_=1,w=1):(M=0,g=1,y=0,x=1,_=1,w=0);let A=p-M+ot,C=d-g+ot,z=b-y+ot,k=p-x+2*ot,E=d-_+2*ot,F=b-w+2*ot,N=p-1+3*ot,S=d-1+3*ot,U=b-1+3*ot,O=c&255,L=m&255,T=u&255,R=l[O+h[L+h[T]]]*3,H=l[O+M+h[L+g+h[T+y]]]*3,j=l[O+x+h[L+_+h[T+w]]]*3,I=l[O+1+h[L+1+h[T+1]]]*3,V=0,D=.6-p*p-d*d-b*b;D>=0&&(D*=D,V=D*D*te(R,p,d,b));let W=0,G=.6-A*A-C*C-z*z;G>=0&&(G*=G,W=G*G*te(H,A,C,z));let J=0,X=.6-k*k-E*E-F*F;X>=0&&(X*=X,J=X*X*te(j,k,E,F));let nt=0,tt=.6-N*N-S*S-U*U;return tt>=0&&(tt*=tt,nt=tt*tt*te(I,N,S,U)),32*(V+W+J+nt)}noise4d(t,e,i,r){let a=Number(t),n=Number(e),h=Number(i),l=Number(r);if(!Number.isFinite(a)||!Number.isFinite(n)||!Number.isFinite(h)||!Number.isFinite(l))return 0;let o=this.perm,c=(a+n+h+l)*Ti,m=Math.floor(a+c),u=Math.floor(n+c),f=Math.floor(h+c),p=Math.floor(l+c),d=(m+u+f+p)*$,b=a-(m-d),M=n-(u-d),g=h-(f-d),y=l-(p-d),x=(b>M?1:0)+(b>g?1:0)+(b>y?1:0),_=(b<=M?1:0)+(M>g?1:0)+(M>y?1:0),w=(b<=g?1:0)+(M<=g?1:0)+(g>y?1:0),A=(b<=y?1:0)+(M<=y?1:0)+(g<=y?1:0),C=x>=3?1:0,z=_>=3?1:0,k=w>=3?1:0,E=A>=3?1:0,F=x>=2?1:0,N=_>=2?1:0,S=w>=2?1:0,U=A>=2?1:0,O=x>=1?1:0,L=_>=1?1:0,T=w>=1?1:0,R=A>=1?1:0,H=b-C+$,j=M-z+$,I=g-k+$,V=y-E+$,D=b-F+2*$,W=M-N+2*$,G=g-S+2*$,J=y-U+2*$,X=b-O+3*$,nt=M-L+3*$,tt=g-T+3*$,yt=y-R+3*$,St=b-1+4*$,At=M-1+4*$,Ht=g-1+4*$,Dt=y-1+4*$,dt=m&255,bt=u&255,et=f&255,it=p&255,es=(o[dt+o[bt+o[et+o[it]]]]&31)*4,is=(o[dt+C+o[bt+z+o[et+k+o[it+E]]]]&31)*4,ss=(o[dt+F+o[bt+N+o[et+S+o[it+U]]]]&31)*4,rs=(o[dt+O+o[bt+L+o[et+T+o[it+R]]]]&31)*4,as=(o[dt+1+o[bt+1+o[et+1+o[it+1]]]]&31)*4,pi=0,qt=.6-b*b-M*M-g*g-y*y;qt>=0&&(qt*=qt,pi=qt*qt*It(es,b,M,g,y));let yi=0,Gt=.6-H*H-j*j-I*I-V*V;Gt>=0&&(Gt*=Gt,yi=Gt*Gt*It(is,H,j,I,V));let di=0,Vt=.6-D*D-W*W-G*G-J*J;Vt>=0&&(Vt*=Vt,di=Vt*Vt*It(ss,D,W,G,J));let bi=0,Wt=.6-X*X-nt*nt-tt*tt-yt*yt;Wt>=0&&(Wt*=Wt,bi=Wt*Wt*It(rs,X,nt,tt,yt));let gi=0,$t=.6-St*St-At*At-Ht*Ht-Dt*Dt;return $t>=0&&($t*=$t,gi=$t*$t*It(as,St,At,Ht,Dt)),27*(pi+yi+di+bi+gi)}noise2D(t,e){return this.noise(t,e)}noise3D(t,e,i){return this.noise3d(t,e,i)}noise4D(t,e,i,r){return this.noise4d(t,e,i,r)}}Object.freeze($e.prototype);let xe=s=>{if(!s||typeof s!="object")return null;let t=s,e=t.image,i=Kt(e??t);if(i&&e?._vc)return{buf:i.data,w:i.width,h:i.height,ch:4,isFloat:!1,flipY:!!t.flipY};let r=e?.data,a=Number(e?.width??t.width)|0,n=Number(e?.height??t.height)|0;if(!r||!(a>0&&n>0)||!r.length)return null;let h=a*n,l=t.format,o=l===1021||l===1024||l===1028||r.length===h?1:l===1025||l===1030||r.length===h*2?2:l===1022||r.length===h*3?3:4;return{buf:r,w:a,h:n,ch:o,isFloat:t.type===1015||t.type===1016||r instanceof Float32Array||r instanceof Float64Array,flipY:!!t.flipY}},_e=(s,t,e,i)=>{let r=Math.min(s.w-1,Math.max(0,t*s.w|0)),a=Math.min(s.h-1,Math.max(0,e*s.h|0)),n=s.flipY?s.h-1-a:a,h=Number(s.buf[(n*s.w+r)*s.ch+Math.min(i,s.ch-1)]??0);if(!Number.isFinite(h))return 0;let l=s.isFloat&&h<=1?h*255:h;return l>0?l<255?l+.5|0:255:0},ve=B.MeshStandardMaterial?.prototype&&(Object.getPrototypeOf(B.MeshStandardMaterial.prototype)||B.MeshStandardMaterial.prototype);ve&&typeof ve._packPbr!="function"&&(ve._packPbr=function(){let s;if((this.roughnessMap||this.metalnessMap)&&this.roughnessMap!==this.metalnessMap){let i=xe(this.roughnessMap),r=xe(this.metalnessMap);if(i||r){let a=Math.min(128,Math.max(i?.w??1,r?.w??1)),n=Math.min(128,Math.max(i?.h??1,r?.h??1)),h=new Uint8ClampedArray(a*n*4);for(let l=0;l<n;l++){let o=(l+.5)/n;for(let c=0;c<a;c++){let m=(c+.5)/a,u=(l*a+c)*4;h[u]=255,h[u+1]=i?_e(i,m,o,1):255,h[u+2]=r?_e(r,m,o,2):255,h[u+3]=255}}s=Pt(h,a,n,!1,!0,128).uri}}let t,e;if(!this.normalMap&&this.bumpMap){let i=xe(this.bumpMap);if(i){let r=Number.isFinite(this.bumpScale)?this.bumpScale:1,a=Math.min(128,i.w),n=Math.min(128,i.h),h=new Uint8ClampedArray(a*n*4),l=(o,c)=>_e(i,((o%a+a)%a+.5)/a,((c%n+n)%n+.5)/n,0)/255;for(let o=0;o<n;o++)for(let c=0;c<a;c++){let m=(l(c+1,o)-l(c-1,o))*r*2,u=(l(c,o+1)-l(c,o-1))*r*2,f=1/Math.hypot(m,u,1),p=(o*a+c)*4;h[p]=(-m*f*.5+.5)*255+.5|0,h[p+1]=(u*f*.5+.5)*255+.5|0,h[p+2]=(f*.5+.5)*255+.5|0,h[p+3]=255}t=Pt(h,a,n,!1,!0,128).uri,e=1}}return{mrUri:s,normUri:t,normScale:e}});let Ye=0,Z=B.Vector2,Je=B.PlaneGeometry,Xe=B.Mesh,Ke=B.Material;class Ot extends Ke{constructor(t={}){super({roughness:.85,metalness:0,side:2,transparent:t.transparent??!0,...t}),this.isSpriteMaterial=!0;let e=Number(t.rotation);this.rotation=Number.isFinite(e)?e:0,this.sizeAttenuation=t.sizeAttenuation!==!1,t.emissive===void 0&&(this.emissive=this.color.clone(),this.emissiveIntensity=.35,this.map&&!this.emissiveMap&&(this.emissiveMap=this.map))}clone(){return new Ot({...this,emissive:this._em?this.emissive:void 0})}}class ee extends Xe{constructor(t){super(new Je(1,1),t instanceof Ke?t:new Ot(t||{})),this.isSprite=!0,this.center=new Z(.5,.5),this.userData={xr:{billboard:"spherical"}}}_cloneCustom(){let t=new ee(this.material);return t.center.copy(this.center),t._autoNamed=!!this._autoNamed,t._noBillboard=!!this._noBillboard,t}_bakeAuthorGeometry(){this._bakedOwner!==this?((!this.name||this._autoNamed)&&(this.name=`Sprite_${++Ye}`,this._autoNamed=!0),this._bakedOwner=this):this.name||(this.name=`Sprite_${++Ye}`,this._autoNamed=!0);let t=this.userData?.xr?.billboard;t===!1||t===null?(this._noBillboard=!0,delete this.userData.xr.billboard,Object.keys(this.userData.xr).length===0&&delete this.userData.xr):((typeof t=="string"||t===!0)&&(this._noBillboard=!1),this._noBillboard||(!this.userData||typeof this.userData!="object"?this.userData={xr:{billboard:"spherical"}}:!this.userData.xr||typeof this.userData.xr!="object"?this.userData.xr={billboard:"spherical"}:this.userData.xr.billboard===void 0&&(this.userData.xr.billboard="spherical")));let e=Number.isFinite(this.center?.x)?this.center.x:.5,i=Number.isFinite(this.center?.y)?this.center.y:.5,r=Number(this.material?.rotation),a=Number.isFinite(r)?r:0,n=`${e},${i},${a}`;if(this._bakedKey!==n&&(this._bakedKey!==void 0||e!==.5||i!==.5||a!==0)){let h=new Je(1,1),l=h.attributes.position?.array,o=.5-e,c=.5-i,m=Math.cos(a),u=Math.sin(a);if(l){for(let f=0;f<l.length;f+=3){let p=l[f]+o,d=l[f+1]+c;l[f]=p*m-d*u,l[f+1]=p*u+d*m}h.boundingBox=null,h.boundingSphere=null}h.__baked=!0,this._bakedKey=n,this.geometry=h}}}if(Object.freeze(Ot.prototype),Object.freeze(ee.prototype),Z?.prototype){let s=Z.prototype,t=(e,i)=>{typeof s[e]!="function"&&(s[e]=i)};t("length",function(){return Math.hypot(this.x,this.y)}),t("normalize",function(){return this.divideScalar(Math.hypot(this.x,this.y)||1)}),t("distanceTo",function(e){return Math.hypot(this.x-(e?.x||0),this.y-(e?.y||0))}),t("dot",function(e){return this.x*(e?.x||0)+this.y*(e?.y||0)}),t("lerp",function(e,i){let r=Number(i)||0;return this.set(this.x+((e?.x||0)-this.x)*r,this.y+((e?.y||0)-this.y)*r)}),t("lerpVectors",function(e,i,r){let a=Number(r)||0,n=e?.x||0,h=e?.y||0;return this.set(n+((i?.x||0)-n)*a,h+((i?.y||0)-h)*a)}),t("equals",function(e){return!!e&&e.x===this.x&&e.y===this.y})}let v=(s,t=0)=>{let e=Number(s);return Number.isFinite(e)?e:t},rt=s=>Math.max(0,Math.min(1,v(s,0))),lt=s=>new Z(v(s?.x),v(s?.y));class vt{constructor(t="Curve"){this.type=t,this.arcLengthDivisions=200,this._lenCache=null}getPoint(t,e=new Z){return e.set(0,0)}getPointAt(t,e){return this.getPoint(this.getUtoTMapping(t),e)}getPoints(t=5){let e=Math.max(1,Math.min(1024,Math.floor(v(t,5)))),i=[];for(let r=0;r<=e;r++)i.push(this.getPoint(r/e));return i}getSpacedPoints(t=5){let e=Math.max(1,Math.min(1024,Math.floor(v(t,5)))),i=[];for(let r=0;r<=e;r++)i.push(this.getPointAt(r/e));return i}getLength(){let t=this.getLengths();return t[t.length-1]||0}getLengths(t=this.arcLengthDivisions){let e=Math.max(1,Math.min(2048,Math.floor(v(t,200))));if(this._lenCache&&this._lenCache.length===e+1)return this._lenCache;let i=[0],r=0,a=this.getPoint(0);for(let n=1;n<=e;n++){let h=this.getPoint(n/e);r+=Math.hypot(v(h.x)-v(a.x),v(h.y)-v(a.y),v(h.z)-v(a.z)),i.push(r),a=h}return e===this.arcLengthDivisions&&(this._lenCache=i),i}updateArcLengths(){this._lenCache=null,this.getLengths()}getUtoTMapping(t,e){let i=this.getLengths(),r=i.length,a=i[r-1]||0;if(a<=0||r<2)return rt(t);let n=e!==void 0&&Number.isFinite(Number(e))?Math.max(0,Math.min(a,Number(e))):rt(t)*a,h=0,l=r-1;for(;h<=l;){let u=h+l>>1,f=i[u]-n;if(f<0)h=u+1;else if(f>0)l=u-1;else return u/(r-1)}let o=Math.max(0,h-1),c=i[o],m=(i[o+1]??a)-c;return(o+(m>1e-12?(n-c)/m:0))/(r-1)}getTangent(t,e){let i=rt(t),r=this.getPoint(Math.max(0,i-1e-4)),a=this.getPoint(Math.min(1,i+1e-4)),n=v(a.x)-v(r.x),h=v(a.y)-v(r.y);if("z"in r||e?.isVector3){let o=v(a.z)-v(r.z),c=Math.hypot(n,h,o)||1;return(e||new P).set(n/c,h/c,o/c)}let l=Math.hypot(n,h)||1;return(e||new Z).set(n/l,h/l)}getTangentAt(t,e){return this.getTangent(this.getUtoTMapping(t),e)}clone(){return new this.constructor().copy(this)}copy(t){if(!t||typeof t!="object")return this;let e=t,i=this;for(let r of Object.keys(e)){if(r==="type"||r.startsWith("is"))continue;if(r.startsWith("_")){i[r]=null;continue}let a=e[r];Array.isArray(a)?i[r]=a.map(n=>n?.clone?n.clone():n&&typeof n=="object"&&"x"in n?lt(n):n):a?.clone?i[r]=a.clone():a&&typeof a=="object"&&"x"in a?i[r]=lt(a):i[r]=a}return this}}class we extends vt{constructor(t,e){super("LineCurve"),this.isLineCurve=!0,this.v1=lt(t),this.v2=lt(e)}getPoint(t,e=new Z){let i=v(t,0),r=v(this.v1.x),a=v(this.v1.y);return i===1?e.set(v(this.v2.x),v(this.v2.y)):e.set(r+(v(this.v2.x)-r)*i,a+(v(this.v2.y)-a)*i)}getPointAt(t,e=new Z){return this.getPoint(rt(t),e)}}class Ze extends vt{constructor(t,e,i){super("QuadraticBezierCurve"),this.isQuadraticBezierCurve=!0,this.v0=lt(t),this.v1=lt(e),this.v2=lt(i)}getPoint(t,e=new Z){let i=rt(t),r=1-i;return e.set(r*r*v(this.v0.x)+2*r*i*v(this.v1.x)+i*i*v(this.v2.x),r*r*v(this.v0.y)+2*r*i*v(this.v1.y)+i*i*v(this.v2.y))}}class ti extends vt{constructor(t,e,i,r){super("CubicBezierCurve"),this.isCubicBezierCurve=!0,this.v0=lt(t),this.v1=lt(e),this.v2=lt(i),this.v3=lt(r)}getPoint(t,e=new Z){let i=rt(t),r=1-i,a=r*r,n=i*i;return e.set(a*r*v(this.v0.x)+3*a*i*v(this.v1.x)+3*r*n*v(this.v2.x)+n*i*v(this.v3.x),a*r*v(this.v0.y)+3*a*i*v(this.v1.y)+3*r*n*v(this.v2.y)+n*i*v(this.v3.y))}}class ei extends vt{constructor(t=[]){super("SplineCurve"),this.isSplineCurve=!0,this.points=Array.isArray(t)?t:[]}getPoint(t,e=new Z){let i=this.points,r=Array.isArray(i)?i.length:0;if(r===0)return e.set(0,0);if(r===1)return e.set(v(i[0]?.x),v(i[0]?.y));let a=(r-1)*rt(t),n=Math.floor(a),h=a-n;n>=r-1&&(n=r-2,h=1);let l=i[n===0?0:n-1],o=i[n],c=i[n+1],m=i[n>r-3?r-1:n+2],u=h*h,f=u*h,p=(d,b,M,g)=>.5*(2*b+(M-d)*h+(2*d-5*b+4*M-g)*u+(3*b-d-3*M+g)*f);return e.set(p(v(l?.x),v(o?.x),v(c?.x),v(m?.x)),p(v(l?.y),v(o?.y),v(c?.y),v(m?.y)))}}class Ae extends vt{constructor(t=0,e=0,i=1,r=1,a=0,n=Math.PI*2,h=!1,l=0){super("EllipseCurve"),this.isEllipseCurve=!0,this.aX=v(t,0),this.aY=v(e,0),this.xRadius=v(i,1),this.yRadius=v(r,1),this.aStartAngle=v(a,0),this.aEndAngle=v(n,Math.PI*2),this.aClockwise=!!h,this.aRotation=v(l,0)}getPoint(t,e=new Z){let i=Math.PI*2,r=v(this.aStartAngle,0),a=v(this.aEndAngle,i)-r;Math.abs(a)>=1e-9?(a=(a%i+i)%i,a<1e-9&&(a=i),this.aClockwise&&(a=a===i?-i:a-i)):a=0;let n=r+rt(t)*a,h=v(this.xRadius,1)*Math.cos(n),l=v(this.yRadius,1)*Math.sin(n),o=v(this.aRotation,0),c=Math.cos(o),m=Math.sin(o);return e.set(this.aX+h*c-l*m,this.aY+h*m+l*c)}}class ii extends Ae{constructor(t=0,e=0,i=1,r=0,a=Math.PI*2,n=!1){super(t,e,i,i,r,a,n,0),this.type="ArcCurve",this.isArcCurve=!0}}class si extends vt{constructor(){super("CurvePath"),this.isCurvePath=!0,this.curves=[],this.autoClose=!1,this._curveLens=null}add(t){return t&&typeof t.getPoint=="function"&&(this.curves.push(t),this._curveLens=null,this._lenCache=null),this}closePath(){if(this.curves.length===0)return this;let t=this.curves[0].getPoint(0),e=this.curves[this.curves.length-1].getPoint(1),i=!!(t&&("z"in t||t.isVector3));if(Math.hypot(v(t?.x)-v(e?.x),v(t?.y)-v(e?.y),i?v(t?.z)-v(e?.z):0)>1e-6){let r=B.LineCurve3;this.add(i&&r?new r(e,t):new we(e,t))}return this}getCurveLengths(){if(this._curveLens&&this._curveLens.length===this.curves.length)return this._curveLens;let t=[],e=0;for(let i of this.curves){let r=0;if(typeof i?.getLength=="function")r=v(i.getLength(),0);else if(typeof i?.getPoints=="function"){let a=i.getPoints(32);for(let n=1;n<a.length;n++)r+=Math.hypot(v(a[n]?.x)-v(a[n-1]?.x),v(a[n]?.y)-v(a[n-1]?.y),v(a[n]?.z)-v(a[n-1]?.z))}e+=r,t.push(e)}return this._curveLens=t,t}getLength(){let t=this.getCurveLengths();return t[t.length-1]||0}updateArcLengths(){this._curveLens=null,this._lenCache=null;for(let t of this.curves)t?.updateArcLengths?.();this.getCurveLengths()}getPoint(t,e){if(this.curves.length===0)return(e||new Z).set(0,0);let i=this.getCurveLengths(),r=i[i.length-1]||0;if(r<=1e-12)return this.curves[0].getPoint(0,e);let a=rt(t)*r;for(let n=0;n<i.length;n++)if(a<=i[n]||n===i.length-1){let h=n>0?i[n-1]:0,l=i[n]-h,o=l>1e-12?(a-h)/l:0,c=this.curves[n];return typeof c.getPointAt=="function"?c.getPointAt(o,e):c.getPoint(o,e)}return this.curves[this.curves.length-1].getPoint(1,e)}getPoints(t=12){let e=Math.max(1,Math.min(1024,Math.floor(v(t,12)))),i=[],r=null;for(let a of this.curves){let n=a?.isEllipseCurve?e*2:a?.isLineCurve||a instanceof(B.LineCurve3||Function)?1:a?.isSplineCurve&&Array.isArray(a.points)?e*Math.max(1,a.points.length):e;for(let h of a.getPoints(Math.min(1024,n)))r&&Math.hypot(v(r.x)-v(h.x),v(r.y)-v(h.y),v(r.z)-v(h.z))<1e-6||(i.push(h),r=h)}if(this.autoClose&&i.length>1){let a=i[0];Math.hypot(v(r.x)-v(a.x),v(r.y)-v(a.y),v(r.z)-v(a.z))>1e-6&&i.push(a.clone?a.clone():a)}return i}getSpacedPoints(t=40){let e=Math.max(1,Math.min(1024,Math.floor(v(t,40)))),i=[];for(let r=0;r<=e;r++)i.push(this.getPoint(r/e));return this.autoClose&&i.length>0&&i.push(i[0].clone?i[0].clone():i[0]),i}}let ri=B.BufferAttribute,ji=B.Object3D,Ii=B.Line,wt=B.LineSegments,xt=B.LineBasicMaterial,Oi=B.MeshBasicMaterial,Ri=B.ConeGeometry,ie=B.Color,Rt=(s,t,e,i)=>{s.name=t.name,s.position.copy(t.position),s.quaternion.copy(t.quaternion),s.scale.copy(t.scale),s.visible=t.visible,s.castShadow=t.castShadow,s.receiveShadow=t.receiveShadow;try{s.userData=JSON.parse(JSON.stringify(t.userData||{}))}catch{s.userData={...t.userData||{}}}if(i&&Array.isArray(t.children))for(let r=e;r<t.children.length;r++)s.add(t.children[r].clone(!0));return s},Ct=s=>{let t=new ft;return t.setAttribute("position",new ri(new Float32Array(s),3)),t.__isSegmentPairs=!0,t},Qi=[0,1,1,3,3,2,2,0,4,5,5,7,7,6,6,4,0,4,1,5,3,7,2,6],Ne=(s,t,e,i,r,a)=>{if(!Number.isFinite(s+t+e+i+r+a)||i<s||r<t||a<e)return new ft;let n=[];for(let h of Qi)n.push(h&1?i:s,h&2?r:t,h&4?a:e);return Ct(n)};class se extends wt{constructor(t=10,e=10,i=4473924,r=8947848){let a=Math.max(1e-4,Math.abs(v(t,10))),n=Math.max(1,Math.min(256,Math.floor(v(e,10)))),h=new ie(i??4473924),l=new ie(r??8947848),o=a*.5,c=a/n,m=n%2===0&&h.getHex()!==l.getHex()?n>>1:-1,u=[],f=[];for(let p=0,d=-o;p<=n;p++,d+=c)(p===m?f:u).push(-o,0,d,o,0,d,d,0,-o,d,0,o);if(super(Ct(u.length?u:f),new xt({color:u.length?l:h})),this.type="GridHelper",this.isGridHelper=!0,this._size=a,this._divisions=n,this._internalKids=0,f.length&&u.length){let p=new wt(Ct(f),new xt({color:h}));this._centerLines=p,this._internalKids=1,this.add(p)}}_bakeAuthorGeometry(){this._centerLines?.material&&this.material&&(this._centerLines.material.transparent=this.material.transparent,this._centerLines.material.opacity=this.material.opacity),super._bakeAuthorGeometry()}clone(t=!0){let e=new se(this._size,this._divisions,this._centerLines?this._centerLines.material.color:this.material.color,this.material.color);return e.material.transparent=this.material.transparent,e.material.opacity=this.material.opacity,Rt(e,this,this._internalKids,t)}dispose(){}}class re extends wt{constructor(t=1){let e=Math.max(1e-4,Math.abs(v(t,1)));super(Ct([0,0,0,e,0,0]),new xt({color:16724736})),this.type="AxesHelper",this.isAxesHelper=!0,this._size=e,this._yAxis=new wt(Ct([0,0,0,0,e,0]),new xt({color:3407616})),this._zAxis=new wt(Ct([0,0,0,0,0,e]),new xt({color:35071})),this.add(this._yAxis),this.add(this._zAxis)}setColors(t,e,i){return this.material.color.set(t),this._yAxis.material.color.set(e),this._zAxis.material.color.set(i),this}_bakeAuthorGeometry(){for(let t of[this._yAxis,this._zAxis])t?.material&&this.material&&(t.material.transparent=this.material.transparent,t.material.opacity=this.material.opacity);super._bakeAuthorGeometry()}clone(t=!0){let e=new re(this._size).setColors(this.material.color,this._yAxis.material.color,this._zAxis.material.color);return e.material.transparent=this.material.transparent,e.material.opacity=this.material.opacity,Rt(e,this,2,t)}dispose(){}}class ae extends ji{constructor(t=new P(0,0,1),e=new P(0,0,0),i=1,r=16776960,a,n){super(),this.type="ArrowHelper",this.isArrowHelper=!0,this.position.set(v(e?.x),v(e?.y),v(e?.z));let h=new ft;h.setAttribute("position",new ri(new Float32Array([0,0,0,0,1,0]),3)),this.line=new Ii(h,new xt({color:r})),this.cone=new Xe(new Ri(.5,1,8).translate(0,-.5,0),new Oi({color:r})),this.add(this.line),this.add(this.cone),this.setDirection(t).setLength(i,a,n)}setDirection(t){let e=v(t?.x,0),i=v(t?.y,0),r=v(t?.z,1),a=Math.hypot(e,i,r),n=a>1e-9?e/a:0,h=a>1e-9?i/a:1,l=a>1e-9?r/a:0;return h>.99999?this.quaternion.set(0,0,0,1):h<-.99999?this.quaternion.set(1,0,0,0):this.quaternion.setFromAxisAngle(new P(l,0,-n).normalize(),Math.acos(Math.max(-1,Math.min(1,h)))),this}setLength(t,e,i){let r=Math.max(1e-4,Math.abs(v(t,1))),a=e!==void 0&&Number.isFinite(Number(e))?Math.max(1e-4,Math.abs(Number(e))):.2*r,n=i!==void 0&&Number.isFinite(Number(i))?Math.max(1e-4,Math.abs(Number(i))):.2*a;return this.line.scale.set(1,Math.max(1e-4,r-a),1),this.line.updateMatrix?.(),this.cone.scale.set(n,a,n),this.cone.position.set(0,r,0),this.cone.updateMatrix?.(),this}setColor(t){return this.line.material.color.set(t),this.cone.material.color.set(t),this}clone(t=!0){let e=new ae;return e.line.scale.copy(this.line.scale),e.cone.scale.copy(this.cone.scale),e.cone.position.copy(this.cone.position),e.setColor(this.cone.material.color),e.line.material.transparent=this.line.material.transparent,e.line.material.opacity=this.line.material.opacity,e.cone.material.transparent=this.cone.material.transparent,e.cone.material.opacity=this.cone.material.opacity,Rt(e,this,2,t)}dispose(){}}class ne extends wt{constructor(t=new K,e=16776960){let i=t instanceof K?t:new K(t?.min,t?.max);super(i.isEmpty()?new ft:Ne(i.min.x,i.min.y,i.min.z,i.max.x,i.max.y,i.max.z),new xt({color:e})),this.type="Box3Helper",this.isBox3Helper=!0,this.box=i}_bakeAuthorGeometry(){let t=this.box,e=!t||t.isEmpty()?new ft:Ne(t.min.x,t.min.y,t.min.z,t.max.x,t.max.y,t.max.z);this._sourceGeo=e,this.geometry=e,super._bakeAuthorGeometry()}clone(t=!0){let e=new ne(this.box.clone(),this.material.color);return e.material.transparent=this.material.transparent,e.material.opacity=this.material.opacity,Rt(e,this,0,t)}dispose(){}}class he extends wt{constructor(t,e=16776960){super(new ft,new xt({color:e})),this.type="BoxHelper",this.isBoxHelper=!0,this.object=t,t&&this.update()}update(t){t!==void 0&&(this.object=t);let e=new K;this.object&&this.object!==this&&e.setFromObject(this.object);let i=e.isEmpty()?new ft:Ne(e.min.x,e.min.y,e.min.z,e.max.x,e.max.y,e.max.z);return this.position.set(0,0,0),this.quaternion.set(0,0,0,1),this.scale.set(1,1,1),this._sourceGeo=i,this.geometry=i,this}setFromObject(t){return this.update(t)}_bakeAuthorGeometry(){this.update(),super._bakeAuthorGeometry()}clone(t=!0){let e=new he(this.object,this.material.color);return e.material.transparent=this.material.transparent,e.material.opacity=this.material.opacity,Rt(e,this,0,t)}dispose(){}}for(let s of[vt,we,Ze,ti,ei,Ae,ii,si,se,re,ae,ne,he])Object.freeze(s.prototype);let zt=["checkerboard","grid","wood","marble","brushedMetal","carbonFiber","concrete","brick","fabric","leather","rust"],ai=[[8,3359061,14870768,.6],[8,16317180,6583435,.7],[10,9132587,0,.6],[3,15857145,4674921,.25],[1,12106946,0,.32],[8,2040616,0,.35],[4,10265519,0,.9],[8,10107694,13157048,.85],[32,3890060,0,.9],[12,5913128,0,.6],[4,9124378,9080985,.9]],Hi=(s,t,e)=>{let i=Math.imul(s,668265261)^Math.imul(t,374761393)^Math.imul(e,2654435769);return i^=i>>>15,i=Math.imul(i,2246822507),i^=i>>>13,i=Math.imul(i,3266489909),i^=i>>>16,i>>>0},pt=(s,t,e)=>Hi(s,t,e)/4294967296,ut=(s,t)=>(s%t+t)%t,ni=(s,t,e,i,r)=>{let a=Math.floor(s),n=Math.floor(t),h=s-a,l=t-n,o=ut(a,e),c=ut(n,i),m=(o+1)%e,u=(c+1)%i,f=h*h*(3-2*h),p=l*l*(3-2*l),d=pt(o,c,r),b=pt(m,c,r),M=pt(o,u,r),g=pt(m,u,r);return d+(b-d)*f+(M-d)*p+(d-b-M+g)*f*p},mt=(s,t,e,i,r,a)=>{let n=0,h=.5,l=0,o=1;for(let c=0;c<r;c++){let m=e*o,u=i*o;n+=h*ni(s*m,t*u,m,u,a+c>>>0),l+=h,h*=.5,o*=2}return n/l},Ce=s=>s-Math.floor(s),ze=s=>Math.abs(Ce(s)*2-1),Qt=(s,t,e)=>{let i=(e-s)/(t-s);return i<0?i=0:i>1&&(i=1),i*i*(3-2*i)},at=(s,t,e)=>s+(t-s)*e,ct=s=>s<=0?0:s>=1?255:Math.floor(s*255+.5),Di=(s,t,e,i,r,a,n,h,l,o,c)=>{let m=g=>[r[0]*g,r[1]*g,r[2]*g],u=(g,y,x)=>[at(g[0],y[0],x),at(g[1],y[1],x),at(g[2],y[2],x)];if(s===0){let g=ut(Math.floor(h*e)+Math.floor(l*e),2)===1?a:r;return[g[0],g[1],g[2],.5,n,0]}if(s===1){let g=Ce(h*e),y=Ce(l*e),x=Math.max(.035,e/t),_=1-Qt(x*.5,x,Math.min(g,1-g,y,1-y));return[...u(r,a,_),.3+.4*_,n,0]}if(s===2){let g=mt(h,l,4,4,4,i),y=ze(l*e+g*1.5),x=mt(h,l,2,96,2,i+7>>>0),_=y*.7+x*.3;return[...m(at(.55,1,_)),_,n+(1-_)*.15,0]}if(s===3){let g=mt(h,l,3,3,5,i),y=ze((h+l)*e+g*2.5),x=y*y,_=x*x,w=_*_,A=.92+.08*g,C=u(r,a,w*.85);return[C[0]*A,C[1]*A,C[2]*A,.5-w*.2,n+w*.1,0]}if(s===4){let g=mt(h,l,2,192*e,2,i),y=pt(o,c,i+3>>>0);return[...m(.85+.12*g+.03*y),.35+g*.3,n+(g-.5)*.12,1]}if(s===5){let g=e*2,y=h*g,x=l*g,_=y-Math.floor(y),w=x-Math.floor(x),A=ut(Math.floor(y)+Math.floor(x),2)===0,C=A?w*2-1:_*2-1,z=1-C*C,k=.08*ze(A?w*8:_*8),E=.6+.4*z;return[r[0]*E+k,r[1]*E+k,r[2]*E+k,z*.8,n+.1*(1-z),0]}if(s===6){let g=mt(h,l,e,e,5,i),y=pt(o,c,i+31>>>0),x=e*16,_=Qt(.82,.9,ni(h*x,l*x,x,x,i+17>>>0));return[...m((.82+.25*g+.06*(y-.5))*(1-.35*_)),.5+.25*(g-.5)-.3*_,n-.05*g,0]}if(s===7){let g=Math.floor(e/2),y=l*e,x=Math.floor(y),_=y-x,w=h*g+(ut(x,2)===1?.5:0),A=Math.floor(w),C=w-A,z=Math.min(Math.min(C,1-C)*2,Math.min(_,1-_)),k=Math.max(.06,1.5*e/t),E=1-Qt(k*.5,k,z),F=pt(ut(A,g),ut(x,e),i),N=mt(h,l,e,e,3,i+5>>>0),S=.8+.25*F+.15*(N-.5),U=.9+.1*N;return[at(r[0]*S,a[0]*U,E),at(r[1]*S,a[1]*U,E),at(r[2]*S,a[2]*U,E),(1-E)*(.75+.1*N)+E*.2,at(n,.95,E),0]}if(s===8){let g=h*e,y=l*e,x=(g-Math.floor(g))*2-1,_=(y-Math.floor(y))*2-1,w=ut(Math.floor(g)+Math.floor(y),2)===0?1-x*x:1-_*_,A=mt(h,l,4,4,2,i);return[...m((.75+.25*w)*(.95+.1*(A-.5))),w,n,0]}if(s===9){let g=h*e,y=l*e,x=Math.floor(g),_=Math.floor(y),w=1e9,A=1e9;for(let k=-1;k<=1;k++)for(let E=-1;E<=1;E++){let F=x+E,N=_+k,S=ut(F,e),U=ut(N,e),O=F+pt(S,U,i)-g,L=N+pt(S,U,i+1>>>0)-y,T=O*O+L*L;T<w?(A=w,w=T):T<A&&(A=T)}let C=1-Qt(0,.12,Math.sqrt(A)-Math.sqrt(w)),z=mt(h,l,4,4,3,i+3>>>0);return[...m((.85+.2*(z-.5))*(1-.3*C)),.6-.4*C+.1*(z-.5),n+.15*C,0]}let f=mt(h,l,e,e,5,i),p=Qt(.45,.6,f),d=mt(h,l,e*8,e*8,3,i+9>>>0),b=.9+.1*d,M=.7+.5*d;return[at(a[0]*b,r[0]*M,p),at(a[1]*b,r[1]*M,p),at(a[2]*b,r[2]*M,p),.4+.4*p*d+.1*p,at(.35,n,p),1-p]},qi=(s,t,e,i,r,a,n,h)=>{let l=globalThis.__three_live_native_material_preset__;if(typeof l=="function"){let u=l(s,t,e,i,...r,...a,n,h);if(Array.isArray(u)&&u.length===3)return u}let o=new Uint8Array(t*t*4),c=new Uint8Array(t*t*4),m=new Float64Array(t*t);for(let u=0;u<t;u++){let f=(u+.5)/t;for(let p=0;p<t;p++){let d=Di(s,t,e,i,r,a,n,(p+.5)/t,f,p,u),b=(u*t+p)*4;o[b]=ct(d[0]),o[b+1]=ct(d[1]),o[b+2]=ct(d[2]),o[b+3]=255,c[b]=255,c[b+1]=ct(d[4]),c[b+2]=ct(d[5]),c[b+3]=255,m[u*t+p]=d[3]}}return[o,hi(m,t,h),c]},hi=(s,t,e)=>{let i=new Uint8Array(t*t*4),r=e*t*.0625;for(let a=0;a<t;a++){let n=(a+t-1)%t,h=(a+1)%t;for(let l=0;l<t;l++){let o=-(s[a*t+(l+1)%t]-s[a*t+(l+t-1)%t])*r,c=(s[h*t+l]-s[n*t+l])*r,m=1/Math.sqrt(o*o+c*c+1),u=(a*t+l)*4;i[u]=ct(o*m*.5+.5),i[u+1]=ct(c*m*.5+.5),i[u+2]=ct(m*.5+.5),i[u+3]=255}}return i},li=(s,t)=>{let e=t;try{s!=null&&(e=new ie(s).getHex())}catch{}return[(e>>16&255)/255,(e>>8&255)/255,(e&255)/255]},le=new Map,Se=(s,t={})=>{let e=zt.indexOf(s);if(e<0)throw new TypeError(`THREE.ProceduralTexture: unknown preset '${s}' (use ${zt.join(", ")})`);let i=t&&typeof t=="object"?t:{},r=ai[e],a=Math.max(1,Math.min(256,Math.round(v(i.scale,r[0]))));(e===0||e===7||e===8)&&a%2===1&&a++;let n=Math.max(16,Math.min(512,Math.round(v(i.size,256)))),h=Math.round(Math.abs(v(i.seed,1)))>>>0,l=li(i.color,r[1]),o=li(i.color2,r[2]||r[1]),c=rt(v(i.roughness,r[3])),m=Math.max(0,Math.min(8,v(i.normalStrength,1))),u=[e,n,a,h,...l,...o,c,m].join(","),f=le.get(u);if(f)return{...f};let[p,d,b]=qi(e,n,a,h,l,o,c,m),M=(x,_)=>{let w=new Tt(n,n);w._data.set(x),w._ver++;let A=new be(w);return A.flipY=!1,A.colorSpace=_,A.name=`${s}_${_==="srgb"?"albedo":x===d?"normal":"orm"}`,A},g=M(b,"srgb-linear"),y={map:M(p,"srgb")};return m>0&&(y.normalMap=M(d,"srgb-linear")),y.roughnessMap=g,y.metalnessMap=g,le.size>=64&&le.clear(),le.set(u,y),{...y}},Ee={presets:Object.freeze(zt.slice()),create:(s,t)=>Se(String(s),t)};for(let s of zt)Ee[s]=t=>Se(s,t);Object.freeze(Ee);let Gi=500,Vi=s=>{if(typeof s!="string")return null;let t="",e=!1;for(let i=0;i<s.length;i++){let r=s.charCodeAt(i);if(r<=32||r===127){e=t.length>0;continue}e&&(t+=" ",e=!1),t+=s[i]}return t.length===0||t.length>Gi?null:t},Wi=s=>{let t=typeof s=="number"?s:NaN;return Number.isFinite(t)?t<=384?256:t<=768?512:1024:512},oi=s=>s>512&&s%2===0?s/2:s,$i=(s,t)=>{let e=t/2,i=new Uint8Array(e*e*4);for(let r=0;r<e;r++)for(let a=0;a<e;a++){let n=(2*r*t+2*a)*4,h=n+t*4,l=(r*e+a)*4;for(let o=0;o<4;o++)i[l+o]=s[n+o]+s[n+4+o]+s[h+o]+s[h+4+o]+2>>2}return i},Yi=s=>{let t=typeof s=="number"?s:NaN,e=Number.isFinite(t)?Math.abs(t):1;return Math.floor(e+.5)%4294967296},Ji=s=>{let t=[];for(let e=0;e<s.length;e++){let i=s.charCodeAt(e);if(i>=55296&&i<=56319&&e+1<s.length){let r=s.charCodeAt(e+1);r>=56320&&r<=57343?(i=65536+(i-55296<<10)+(r-56320),e++):i=65533}else i>=55296&&i<=57343&&(i=65533);i<128?t.push(i):i<2048?t.push(192|i>>6,128|i&63):i<65536?t.push(224|i>>12,128|i>>6&63,128|i&63):t.push(240|i>>18,128|i>>12&63,128|i>>6&63,128|i&63)}return t},Xi=(s,t,e)=>{let i=Ji(`three-live-texture1${s}${t}${e}`),r=3421674724,a=2216829733;for(let n of i){a=(a^n)>>>0;let h=a&65535,l=a>>>16,o=h*435,c=l*435+(o>>>16),m=(c&65535)<<16|o&65535,u=Math.floor(c/65536);r=Math.imul(r,435)+u+(a<<8>>>0)>>>0,a=m>>>0}return r.toString(16).padStart(8,"0")+a.toString(16).padStart(8,"0")},ui=s=>{let t=Vi(s?.prompt);if(t===null)return null;let e=Wi(s?.size),i=Yi(s?.seed);return{prompt:t,size:e,seed:i,key:Xi(t,e,i)}},Be=(s,t,e,i,r)=>{if(oi(t)!==t)return Be($i(s,t),t/2,e,i,r);let a=new Float64Array(t*t);for(let y=0;y<t*t;y++){let x=y*4;a[y]=2126*s[x]+7152*s[x+1]+722*s[x+2]}let n=Math.min(4,Math.floor((t-1)/2)),h=new Float64Array(t*t);for(let y=0;y<t;y++)for(let x=0;x<t;x++){let _=0;for(let w=0;w<=2*n;w++)_+=a[y*t+(x+t+w-n)%t];h[y*t+x]=_}let l=(2*n+1)*(2*n+1),o=new Float64Array(t*t),c=1/0,m=-1/0;for(let y=0;y<t;y++)for(let x=0;x<t;x++){let _=0;for(let A=0;A<=2*n;A++)_+=h[(y+t+A-n)%t*t+x];let w=l*a[y*t+x]-_;o[y*t+x]=w,w<c&&(c=w),w>m&&(m=w)}let u=m-c,f=new Float64Array(t*t);for(let y=0;y<t*t;y++)f[y]=u===0?.5:(o[y]-c)/u;let p=Number.isFinite(e)?Math.max(0,Math.min(8,e)):1,d=hi(f,t,p),b=Number.isFinite(i)?Math.max(0,Math.min(1,i)):0,M=ct(Number.isFinite(r)?Math.max(0,Math.min(1,r)):0),g=new Uint8Array(t*t*4);for(let y=0;y<t*t;y++){let x=y*4;g[x]=255,g[x+1]=ct(b+.35*(.5-f[y])),g[x+2]=M,g[x+3]=255}return[d,g]},oe=new Map,mi=new WeakMap,Ki=0,Zi=(s,t)=>{let e=ui(s);if(!e)return null;let{prompt:i,size:r,seed:a,key:n}=e,h=rt(v(s.roughness,t>=0?ai[t][3]:.8)),l=rt(v(s.metalness,0)),o=Math.max(0,Math.min(8,v(s.normalStrength,1))),c=globalThis,m=c.__three_live_native_texture_pack__,u=c.__three_live_texture_pack__,f=0;if(typeof m=="function"){let _=c.__three_live_native_texture_pack_token__;f=typeof _=="function"&&Number(_())||0}else u&&typeof u=="object"&&(f=mi.get(u)??0,f||mi.set(u,f=++Ki));let p=[f,n,o,h,l].join(","),d=f?oe.get(p):void 0;if(d)return{...d};let b=null;if(typeof m=="function"){let _=m(i,r,a,o,h,l);Array.isArray(_)&&_.length===3&&(b=_)}else{let _=u&&typeof u=="object"&&Object.prototype.hasOwnProperty.call(u,n)?u[n]:null;_&&_.size===r&&_.rgba instanceof Uint8Array&&_.rgba.length===r*r*4&&(b=[_.rgba,...Be(_.rgba,r,o,h,l)])}if(!b)return null;let M=(_,w,A,C)=>{let z=new be({data:new Uint8ClampedArray(_.buffer,_.byteOffset,w*w*4),width:w,height:w});return z.flipY=!1,z.colorSpace=A,z.name=`ai_${n}_${C}`,z._pngDim=w,z},g=oi(r),y=M(b[2],g,"srgb-linear","orm"),x={map:M(b[0],r,"srgb","albedo")};return o>0&&(x.normalMap=M(b[1],g,"srgb-linear","normal")),x.roughnessMap=y,x.metalnessMap=y,f&&(oe.size>=32&&oe.clear(),oe.set(p,x)),{...x}},ci=new Set,ts=s=>{let t=s?.userData?.xr?.material,e=s?.material;if(t==null||!e||typeof e!="object"||Array.isArray(e))return;let i=typeof t=="string"?{preset:t}:typeof t=="object"?t:null,r=String(i?.preset??i?.type??""),a=zt.indexOf(r),n=!!i&&i.prompt!==void 0&&i.prompt!==null,h=n?Zi(i,a):null;if(!i||a<0&&!h){!(n&&r==="")&&!ci.has(r)&&(ci.add(r),console.warn(`[three-live] userData.xr.material: unknown preset '${r}' (use ${zt.join(", ")}).`));return}e._presetTint===void 0&&(e._presetTint=e.color?.getHex?.()??16777215);let l="";try{l=JSON.stringify([i,e._presetTint])}catch{l=r}if(e._presetKey===l)return;if(e._presetOwner&&e._presetOwner!==s){let m=Object.assign(Object.create(Object.getPrototypeOf(e)),e);m.color=new ie(e._presetTint);for(let u of["_presetKey","_presetMaps","_presetOwner"])m[u]=void 0;for(let u of["map","normalMap","roughnessMap","metalnessMap"])e._presetMaps?.[u]&&m[u]===e._presetMaps[u]&&(m[u]=null);s.material=e=m}let o=h??Se(r,{...i,color:i.color??(e._presetTint===16777215?void 0:e._presetTint)}),c=e._presetMaps||{};for(let m of["map","normalMap","roughnessMap","metalnessMap"])(!e[m]||e[m]===c[m])&&(e[m]=o[m]??null,c[m]=o[m]??null);c.map===e.map&&e.color?.set?.(16777215),c.roughnessMap===e.roughnessMap&&(e.roughness=1),c.metalnessMap===e.metalnessMap&&(e.metalness=1),e._presetMaps=c,e._presetKey=l,e._presetOwner=s},fi={Box3:K,Sphere:Bt,CanvasTexture:be,ImprovedNoise:We,SimplexNoise:$e,SpriteMaterial:Ot,Sprite:ee,LineCurve:we,QuadraticBezierCurve:Ze,CubicBezierCurve:ti,SplineCurve:ei,EllipseCurve:Ae,ArcCurve:ii,CurvePath:si,GridHelper:se,AxesHelper:re,ArrowHelper:ae,Box3Helper:ne,BoxHelper:he,ProceduralTexture:Ee};return Q&&typeof Q=="object"&&(Q.authorNamespace||(Q.authorNamespace={}),Object.assign(Q.authorNamespace,fi),Q.createCanvas=Pi,Q._procMaterialize=ts,Q.canonicalTextureSpec=ui,Q.deriveTextureMaps=Be,Q.encodeRgbaPngDataUri=(s,t,e)=>Pt(s,t,e,!1,!1,st).uri,Q.materializeDeclarativeGeometry=s=>{Q._cadMaterialize?.(s),Q._lodMaterialize?.(s),Q._procMaterialize?.(s)}),fi}var Mi={name:"procedural",onRegister(){ns(ke);let B=me(),Q=B.threeNamespace??(typeof globalThis<"u"?globalThis.THREE:void 0);Q&&ke(Q,B)}};hs(Mi);export{ke as installProceduralExtension,Mi as proceduralPlugin};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/var ThreeLiveProcedural=(()=>{var ce=Object.defineProperty,vi=Object.getOwnPropertyDescriptor,wi=Object.getOwnPropertyNames,Ai=Object.prototype.hasOwnProperty,Ni=(z,U)=>{for(var P in U)ce(z,P,{get:U[P],enumerable:!0})},Ci=(z,U,P,gt)=>{if(U&&typeof U=="object"||typeof U=="function")for(let X of wi(U))!Ai.call(z,X)&&X!==P&&ce(z,X,{get:()=>U[X],enumerable:!(gt=vi(U,X))||gt.enumerable});return z},zi=z=>Ci(ce({},"__esModule",{value:!0}),z),Te={};Ni(Te,{installProceduralExtension:()=>fe,proceduralPlugin:()=>Se});var Yt="__THREE_LIVE_REGISTRY__";function Jt(){let z=typeof globalThis<"u"?globalThis:{};if(!z[Yt]){let U={plugins:[],decoders:new Map};try{Object.defineProperty(z,Yt,{value:U,writable:!1,configurable:!1,enumerable:!1})}catch{z[Yt]=U}}return z[Yt]}var ds=Jt().plugins;function Ei(z){let U=Jt();U.workerExtensionInstallers||(U.workerExtensionInstallers=[]),U.workerExtensionInstallers.includes(z)||U.workerExtensionInstallers.push(z)}function Fi(z){let U=Jt().plugins;U.some(P=>P.name===z.name)||U.push(z),z.onRegister?.()}function fe(z,U){if(!z||!z.Vector3||!z.BufferGeometry)return null;let P=z.Vector3,gt=z.Matrix4,X=z.BufferGeometry;if(typeof P.prototype.distanceToSquared!="function"&&(P.prototype.distanceToSquared=function(s){let t=this.x-Number(s?.x??0),e=this.y-Number(s?.y??0),i=this.z-Number(s?.z??0);return t*t+e*e+i*i}),typeof P.prototype.addScalar!="function"&&(P.prototype.addScalar=function(s){let t=Number(s)||0;return this.set(this.x+t,this.y+t,this.z+t)}),typeof P.prototype.applyQuaternion!="function"&&(P.prototype.applyQuaternion=function(s){let t=this.x,e=this.y,i=this.z,r=Number(s?.x)||0,a=Number(s?.y)||0,n=Number(s?.z)||0,h=s?.w===void 0?1:Number(s.w)||0,l=2*(a*i-n*e),o=2*(n*t-r*i),c=2*(r*e-a*t);return this.set(t+h*l+(a*c-n*o),e+h*o+(n*l-r*c),i+h*c+(r*o-a*l))}),typeof P.prototype.min!="function"&&(P.prototype.min=function(s){return this.set(Math.min(this.x,s.x),Math.min(this.y,s.y),Math.min(this.z,s.z))}),typeof P.prototype.max!="function"&&(P.prototype.max=function(s){return this.set(Math.max(this.x,s.x),Math.max(this.y,s.y),Math.max(this.z,s.z))}),typeof P.prototype.clamp!="function"&&(P.prototype.clamp=function(s,t){return this.set(Math.max(s.x,Math.min(t.x,this.x)),Math.max(s.y,Math.min(t.y,this.y)),Math.max(s.z,Math.min(t.z,this.z)))}),typeof P.prototype.clampScalar!="function"&&(P.prototype.clampScalar=function(s,t){return this.set(Math.max(s,Math.min(t,this.x)),Math.max(s,Math.min(t,this.y)),Math.max(s,Math.min(t,this.z)))}),typeof P.prototype.negate!="function"&&(P.prototype.negate=function(){return this.multiplyScalar(-1)}),typeof P.prototype.equals!="function"&&(P.prototype.equals=function(s){return!!s&&s.x===this.x&&s.y===this.y&&s.z===this.z}),gt&&typeof gt.prototype.getMaxScaleOnAxis!="function"&&(gt.prototype.getMaxScaleOnAxis=function(){let s=this.elements;return Math.sqrt(Math.max(s[0]*s[0]+s[1]*s[1]+s[2]*s[2],s[4]*s[4]+s[5]*s[5]+s[6]*s[6],s[8]*s[8]+s[9]*s[9]+s[10]*s[10]))}),z.MathUtils&&typeof z.MathUtils=="object"){let s=1234567;try{typeof z.MathUtils.seededRandom!="function"&&(z.MathUtils.seededRandom=t=>{t!==void 0&&(s=Number.isFinite(t)?t|0:0);let e=s=s+1831565813|0;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}),typeof z.MathUtils.randInt!="function"&&(z.MathUtils.randInt=(t,e)=>t+Math.floor(Math.random()*(e-t+1))),typeof z.MathUtils.randFloatSpread!="function"&&(z.MathUtils.randFloatSpread=t=>t*(.5-Math.random()))}catch{}}class Z{constructor(t,e){this.isBox3=!0,this.min=t!=null?new P(t.x,t.y,t.z):new P(1/0,1/0,1/0),this.max=e!=null?new P(e.x,e.y,e.z):new P(-1/0,-1/0,-1/0)}set(t,e){return this.min.copy(t),this.max.copy(e),this}makeEmpty(){return this.min.set(1/0,1/0,1/0),this.max.set(-1/0,-1/0,-1/0),this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}clone(){return new Z(this.min,this.max)}copy(t){return t?(this.min.copy(t.min),this.max.copy(t.max),this):this}expandByPoint(t){if(!t)return this;let e=Number(t.x),i=Number(t.y),r=t.z===void 0?0:Number(t.z);return!Number.isFinite(e)||!Number.isFinite(i)||!Number.isFinite(r)?this:(e<this.min.x&&(this.min.x=e),i<this.min.y&&(this.min.y=i),r<this.min.z&&(this.min.z=r),e>this.max.x&&(this.max.x=e),i>this.max.y&&(this.max.y=i),r>this.max.z&&(this.max.z=r),this)}expandByVector(t){if(this.isEmpty()||!t)return this;let e=Number(t.x),i=Number(t.y),r=Number(t.z);return!Number.isFinite(e)||!Number.isFinite(i)||!Number.isFinite(r)?this:(this.min.set(this.min.x-e,this.min.y-i,this.min.z-r),this.max.set(this.max.x+e,this.max.y+i,this.max.z+r),this.isEmpty()&&this.makeEmpty(),this)}expandByScalar(t){let e=Number(t);return this.isEmpty()||!Number.isFinite(e)?this:(this.min.set(this.min.x-e,this.min.y-e,this.min.z-e),this.max.set(this.max.x+e,this.max.y+e,this.max.z+e),this.isEmpty()&&this.makeEmpty(),this)}setFromArray(t){if(this.makeEmpty(),!t)return this;for(let e=0,i=t.length-2;e<i;e+=3)this.expandByPoint({x:t[e],y:t[e+1],z:t[e+2]});return this}setFromBufferAttribute(t){if(this.makeEmpty(),!t||typeof t.count!="number")return this;for(let e=0;e<t.count;e++)this.expandByPoint({x:t.getX(e),y:t.getY(e),z:t.getZ(e)});return this}setFromPoints(t){if(this.makeEmpty(),Array.isArray(t))for(let e of t)this.expandByPoint(e);return this}setFromCenterAndSize(t,e){if(!t||!e)return this;let i=Math.abs(Number(e.x)||0)*.5,r=Math.abs(Number(e.y)||0)*.5,a=Math.abs(Number(e.z)||0)*.5,n=Number(t.x)||0,h=Number(t.y)||0,l=Number(t.z)||0;return this.min.set(n-i,h-r,l-a),this.max.set(n+i,h+r,l+a),this}setFromObject(t,e){return this.makeEmpty().expandByObject(t,!!e)}expandByObject(t,e){return Bi(this,t,!!e),this}getCenter(t=new P){return this.isEmpty()?t.set(0,0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t=new P){return this.isEmpty()?t.set(0,0,0):t.subVectors(this.max,this.min)}getParameter(t,e=new P){let i=this.max.x-this.min.x,r=this.max.y-this.min.y,a=this.max.z-this.min.z;return e.set(i!==0?(t.x-this.min.x)/i:0,r!==0?(t.y-this.min.y)/r:0,a!==0?(t.z-this.min.z)/a:0)}containsPoint(t){return!!t&&!this.isEmpty()&&t.x>=this.min.x&&t.x<=this.max.x&&t.y>=this.min.y&&t.y<=this.max.y&&t.z>=this.min.z&&t.z<=this.max.z}containsBox(t){return!!t&&this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z}intersectsBox(t){return!!t&&t.max.x>=this.min.x&&t.min.x<=this.max.x&&t.max.y>=this.min.y&&t.min.y<=this.max.y&&t.max.z>=this.min.z&&t.min.z<=this.max.z}intersectsSphere(t){return!t||this.isEmpty()||t.isEmpty()?!1:this.clampPoint(t.center,new P).distanceToSquared(t.center)<=t.radius*t.radius}intersectsPlane(t){if(!t?.normal||this.isEmpty())return!1;let e=t.normal.x,i=t.normal.y,r=t.normal.z,a=Number(t.constant)||0,n=(e>0?e*this.min.x:e*this.max.x)+(i>0?i*this.min.y:i*this.max.y)+(r>0?r*this.min.z:r*this.max.z),h=(e>0?e*this.max.x:e*this.min.x)+(i>0?i*this.max.y:i*this.min.y)+(r>0?r*this.max.z:r*this.min.z);return n<=-a&&h>=-a}clampPoint(t,e=new P){return this.isEmpty()?e.copy(t):e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.isEmpty()?1/0:this.clampPoint(t,new P).distanceTo(t)}getBoundingSphere(t=new Bt){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=this.getSize(new P).length()*.5,t)}intersect(t){return t?(this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this):this}union(t){return!t||t.isEmpty()?this:this.isEmpty()?this.copy(t):(this.min.min(t.min),this.max.max(t.max),this)}applyMatrix4(t){if(this.isEmpty()||!t)return this;let e=this.min.x,i=this.min.y,r=this.min.z,a=this.max.x,n=this.max.y,h=this.max.z,l=new P;this.makeEmpty();for(let o=0;o<8;o++)l.set(o&1?a:e,o&2?n:i,o&4?h:r).applyMatrix4(t),this.expandByPoint(l);return this}translate(t){return this.isEmpty()||!t?this:(this.min.add(t),this.max.add(t),this)}equals(t){return!!t&&t.min.equals(this.min)&&t.max.equals(this.max)}}function Bi(s,t,e){if(!t)return;t.updateMatrixWorld?.(!0);let i=new P,r=new Z,a=new gt,n=new gt,h=new Set,l=new Map,o=(m,u)=>{let f=m?.attributes?.position;if(!(!f||!(f.count>0)))if(e)for(let p=0;p<f.count;p++)i.set(f.getX(p),f.getY(p),f.getZ(p)).applyMatrix4(u),s.expandByPoint(i);else{let p=l.get(m);p||(p=new Z().setFromBufferAttribute(f),l.set(m,p)),p.isEmpty()||s.union(r.copy(p).applyMatrix4(u))}},c=m=>{if(!m||typeof m!="object"||h.has(m)||(h.add(m),U?.materializeDeclarativeGeometry?.(m),m.isBoxHelper&&m!==t))return;(m.isSprite||m.isBox3Helper)&&m._bakeAuthorGeometry?.();let u=m._sourceGeo||m.geometry;if(u&&u.attributes?.position&&m.matrixWorld)if(m.isInstancedMesh&&typeof m.getMatrixAt=="function"){let f=Math.floor((m.instanceMatrix?.array?.length??0)/16),p=Math.min(Math.max(0,Math.floor(Number(m.count)||0)),f);for(let d=0;d<p;d++)m.getMatrixAt(d,a),n.multiplyMatrices(m.matrixWorld,a),o(u,n)}else o(u,m.matrixWorld);if(Array.isArray(m.children))for(let f of m.children)c(f)};c(t)}class Bt{constructor(t,e=-1){this.isSphere=!0,this.center=t!=null?new P(t.x,t.y,t.z):new P;let i=Number(e);this.radius=Number.isFinite(i)?i:-1}set(t,e){t&&this.center.copy(t);let i=Number(e);return this.radius=Number.isFinite(i)?i:-1,this}setFromPoints(t,e){if(!Array.isArray(t)||t.length===0)return this.makeEmpty();if(e)this.center.copy(e);else{let n=new Z().setFromPoints(t);if(n.isEmpty())return this.makeEmpty();n.getCenter(this.center)}let i=0,r=!1,a=new P;for(let n of t){let h=Number(n?.x),l=Number(n?.y),o=n?.z===void 0?0:Number(n.z);Number.isFinite(h)&&Number.isFinite(l)&&Number.isFinite(o)&&(r=!0,i=Math.max(i,this.center.distanceToSquared(a.set(h,l,o))))}return r?(this.radius=Math.sqrt(i),this):this.makeEmpty()}copy(t){return t?(this.center.copy(t.center),this.radius=t.radius,this):this}clone(){return new Bt(this.center,this.radius)}isEmpty(){return!(this.radius>=0)||!Number.isFinite(this.radius)}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(t){return!!t&&!this.isEmpty()&&t.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(t){return this.isEmpty()?1/0:t.distanceTo(this.center)-this.radius}intersectsSphere(t){if(!t||this.isEmpty()||t.isEmpty())return!1;let e=this.radius+t.radius;return t.center.distanceToSquared(this.center)<=e*e}intersectsBox(t){return!!t&&t.intersectsSphere(this)}intersectsPlane(t){if(!t?.normal||this.isEmpty())return!1;let e=t.normal.dot(this.center)+(Number(t.constant)||0);return Math.abs(e)<=this.radius}clampPoint(t,e=new P){return e.copy(t),this.isEmpty()||this.center.distanceToSquared(t)>this.radius*this.radius&&e.sub(this.center).normalize().multiplyScalar(this.radius).add(this.center),e}getBoundingBox(t=new Z){return this.isEmpty()?t.makeEmpty():(t.set(this.center,this.center),t.expandByScalar(this.radius),t)}applyMatrix4(t){if(this.isEmpty()||!t)return this;let e=t.getMaxScaleOnAxis();return Number.isFinite(e)?(this.center.applyMatrix4(t),this.radius*=e,this):this.makeEmpty()}translate(t){return!this.isEmpty()&&t&&this.center.add(t),this}expandByPoint(t){if(!t||!Number.isFinite(t.x)||!Number.isFinite(t.y)||!Number.isFinite(t.z))return this;if(this.isEmpty())return this.center.copy(t),this.radius=0,this;let e=this.center.distanceToSquared(t);if(e>this.radius*this.radius){let i=Math.sqrt(e),r=(this.radius+i)*.5;this.center.addScaledVector(new P().subVectors(t,this.center),(i-this.radius)/(2*i)),this.radius=r}return this}union(t){if(!t||t.isEmpty())return this;if(this.isEmpty())return this.copy(t);if(this.center.equals(t.center))return this.radius=Math.max(this.radius,t.radius),this;let e=new P().subVectors(t.center,this.center),i=e.length();if(i+t.radius<=this.radius)return this;if(i+this.radius<=t.radius)return this.copy(t);let r=(this.radius+i+t.radius)*.5;return this.center.addScaledVector(e,(r-this.radius)/i),this.radius=r,this}equals(t){return!!t&&t.center.equals(this.center)&&t.radius===this.radius}}X.prototype.computeBoundingSphere=function(){(!this.boundingSphere||!this.boundingSphere.isSphere)&&(this.boundingSphere=new Bt);let s=this.attributes?.position;if(!s||!(s.count>0))return this.boundingSphere.makeEmpty();let t=new Z().setFromBufferAttribute(s);if(t.isEmpty())return this.boundingSphere.makeEmpty();let e=t.getCenter(this.boundingSphere.center),i=0,r=new P;for(let a=0;a<s.count;a++){let n=s.getX(a),h=s.getY(a),l=s.getZ(a);Number.isFinite(n)&&Number.isFinite(h)&&Number.isFinite(l)&&(i=Math.max(i,e.distanceToSquared(r.set(n,h,l))))}return this.boundingSphere.radius=Math.sqrt(i),this.boundingSphere},X.prototype.computeBoundingBox=function(){(!this.boundingBox||!this.boundingBox.isBox3)&&(this.boundingBox=new Z);let s=this.attributes?.position;return s&&s.count>0?this.boundingBox.setFromBufferAttribute(s):this.boundingBox.makeEmpty(),this.boundingSphere&&this.computeBoundingSphere(),this.boundingBox};let Pt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Xt=512,rt=2048,Pi=16384,ki=256,Ue="AAAAAAAAAF8AAAAHAAcAFH8UfxQkKn8qEiMTCGRiNklVIlAABQMAAAAcIkEAAEEiHAAUCD4IFAgIPggIAFAwAAAICAgICABgYAAAIBAIBAI+UUlFPgBCf0AAQmFRSUYhQUVLMRgUEn8QJ0VFRTk8SklJMAFxCQUDNklJSTYGSUkpHgA2NgAAAFY2AAAIFCJBABQUFBQUAEEiFAgCAVEJBjJJeUE+fhEREX5/SUlJNj5BQUEif0FBIhx/SUlJQX8JCQkBPkFJSXp/CAgIfwBBf0EAIEBBPwF/CBQiQX9AQEBAfwIMAn9/BAgQfz5BQUE+fwkJCQY+QVEhXn8JGSlGRklJSTEBAX8BAT9AQEA/HyBAIB8/QDhAP2MUCBRjBwhwCAdhUUlFQwB/QUEAAgQIECAAQUF/AAQCAQIEQEBAQEAAAQIEACBUVFR4f0hERDg4REREIDhEREh/OFRUVBgIfgkBAgxSUlI+fwgEBHgARH1AACBARD0AfxAoRAAAQX9AAHwEGAR4fAgEBHg4REREOHwUFBQICBQUGHx8CAQECEhUVFQgBD9EQCA8QEAgfBwgQCAcPEAwQDxEKBAoRAxQUFA8RGRUTEQACDZBAAAAfwAAAEE2CAAIBAgQCA==",je=new Int16Array(128).fill(-1);for(let s=0;s<64;s++)je[Pt.charCodeAt(s)]=s;let Ti=(()=>{let s=new Uint8Array(475),t=0,e=0,i=0;for(let r=0;r<Ue.length&&i<475;r++){let a=Ue.charCodeAt(r);if(a===61)break;let n=a<128?je[a]:-1;n<0||(t=t<<6|n,e+=6,e>=8&&(e-=8,s[i++]=t>>e&255))}return s})(),Si=(()=>{let s=new Uint32Array(256);for(let t=0;t<256;t++){let e=t;for(let i=0;i<8;i++)e=e&1?3988292384^e>>>1:e>>>1;s[t]=e>>>0}return s})(),Oe=s=>{let t=4294967295;for(let e=0;e<s.length;e++)t=Si[(t^s[e])&255]^t>>>8;return(t^4294967295)>>>0},pe=(()=>{let s=new Float32Array(256);for(let t=0;t<256;t++){let e=t/255;s[t]=e<=.04045?e/12.92:Math.pow((e+.055)/1.055,2.4)}return s})(),Le=typeof globalThis<"u"?globalThis.__three_live_native_encode_rgba_png__:void 0,Ie={};for(let s of"black:000000,white:ffffff,red:ff0000,lime:00ff00,green:008000,blue:0000ff,yellow:ffff00,cyan:00ffff,aqua:00ffff,magenta:ff00ff,fuchsia:ff00ff,silver:c0c0c0,gray:808080,grey:808080,darkgray:a9a9a9,darkgrey:a9a9a9,dimgray:696969,dimgrey:696969,lightgray:d3d3d3,lightgrey:d3d3d3,slategray:708090,slategrey:708090,darkslategray:2f4f4f,darkslategrey:2f4f4f,maroon:800000,olive:808000,purple:800080,teal:008080,navy:000080,orange:ffa500,orangered:ff4500,gold:ffd700,coral:ff7f50,salmon:fa8072,tomato:ff6347,crimson:dc143c,pink:ffc0cb,hotpink:ff69b4,deeppink:ff1493,indigo:4b0082,violet:ee82ee,plum:dda0dd,orchid:da70d6,brown:a52a2a,saddlebrown:8b4513,sienna:a0522d,chocolate:d2691e,peru:cd853f,tan:d2b48c,wheat:f5deb3,beige:f5f5dc,ivory:fffff0,linen:faf0e6,snow:fffafa,khaki:f0e68c,skyblue:87ceeb,deepskyblue:00bfff,dodgerblue:1e90ff,royalblue:4169e1,steelblue:4682b4,turquoise:40e0d0,aquamarine:7fffd4,chartreuse:7fff00,forestgreen:228b22,seagreen:2e8b57".split(",")){let[t,e]=s.split(":");Ie[t]=parseInt(e,16)}let lt=s=>s>0?s<255?s+.5|0:255:0,ye=s=>{let t=s.trim();return t.endsWith("%")?lt(parseFloat(t)*255/100):lt(parseFloat(t))},De=s=>{if(!s)return 255;let t=s.trim();if(!t)return 255;let e=t.endsWith("%")?parseFloat(t)/100:parseFloat(t);return Number.isFinite(e)?lt(Math.max(0,Math.min(1,e))*255):255},Re=(s,t=[0,0,0,255])=>{if(typeof s!="string")return t;let e=s.trim().toLowerCase();if(!e)return t;if(e==="transparent")return[0,0,0,0];if(e.charCodeAt(0)===35){let d=e.slice(1);if(d.length===3||d.length===4){let b=parseInt(d[0]+d[0],16),M=parseInt(d[1]+d[1],16),g=parseInt(d[2]+d[2],16),y=d.length===4?parseInt(d[3]+d[3],16):255;if(Number.isFinite(b+M+g+y))return[b,M,g,y]}else if(d.length===6||d.length===8){let b=parseInt(d.slice(0,2),16),M=parseInt(d.slice(2,4),16),g=parseInt(d.slice(4,6),16),y=d.length===8?parseInt(d.slice(6,8),16):255;if(Number.isFinite(b+M+g+y))return[b,M,g,y]}return t}let i=Ie[e];if(i!==void 0)return[i>>16&255,i>>8&255,i&255,255];let r=/^(rgba?|hsla?)\(([^)]+)\)$/.exec(e);if(!r)return t;let a=r[1],n=r[2].replace(/\//g," ").split(/[\s,]+/).filter(Boolean);if(n.length<3)return t;if(a.startsWith("rgb"))return[ye(n[0]),ye(n[1]),ye(n[2]),De(n[3])];let h=parseFloat(n[0]);if(!Number.isFinite(h))return t;n[0].endsWith("turn")?h*=360:n[0].endsWith("rad")&&(h=h*180/Math.PI);let l=(h%360+360)%360/360,o=Math.max(0,Math.min(1,(parseFloat(n[1])||0)/100)),c=Math.max(0,Math.min(1,(parseFloat(n[2])||0)/100)),m=De(n[3]);if(o===0){let d=lt(c*255);return[d,d,d,m]}let u=c<.5?c*(1+o):c+o-c*o,f=2*c-u,p=d=>{let b=d;return b<0&&(b+=1),b>1&&(b-=1),b<1/6?f+(u-f)*6*b:b<1/2?u:b<2/3?f+(u-f)*(2/3-b)*6:f};return[lt(p(l+1/3)*255),lt(p(l)*255),lt(p(l-1/3)*255),m]},kt=(s,t,e,i,r,a=Xt)=>{if(!s||t<=0||e<=0||s.length<t*e*4)return{uri:"",avgColor:[1,1,1,1]};if(typeof Le=="function"){let N=Le(s,t,e,i,r,a);if(Array.isArray(N)&&typeof N[0]=="string")return{uri:N[0],avgColor:[N[1],N[2],N[3],N[4]]}}let n=t>a||e>a?a/Math.max(t,e):1,h=Math.max(1,Math.round(t*n)),l=Math.max(1,Math.round(e*n)),o=1+h*4,c=l*o,m=2+Math.max(1,Math.ceil(c/65535))*5+c+4,u=new Uint8Array(57+m),f=new DataView(u.buffer);f.setUint32(0,2303741511),f.setUint32(4,218765834),f.setUint32(8,13),f.setUint32(12,1229472850),f.setUint32(16,h),f.setUint32(20,l),u[24]=8,u[25]=6,f.setUint32(29,Oe(u.subarray(12,29))),f.setUint32(33,m),f.setUint32(37,1229209940),u[41]=120,u[42]=1;let p=new Uint8Array(c),d=0,b=1,M=0,g=0,y=0,x=0,_=0,w=h===t&&l===e;for(let N=0;N<l;N++){p[d++]=0,M=(M+b)%65521;let F=i?l-1-N:N,S=w?F:Math.floor(F*e/l),D=w?F+1:Math.max(S+1,Math.floor((F+1)*e/l));for(let O=0;O<h;O++){let j=0,R=0,Q=0,L=0;if(w){let I=(S*t+O)*4;j=s[I]|0,R=s[I+1]|0,Q=s[I+2]|0,L=s[I+3]|0}else{let I=Math.floor(O*t/h),V=Math.max(I+1,Math.floor((O+1)*t/h)),H=0;for(let W=S;W<D&&W<e;W++)for(let G=I;G<V&&G<t;G++){let J=(W*t+G)*4;j+=s[J]|0,R+=s[J+1]|0,Q+=s[J+2]|0,L+=s[J+3]|0,H++}H>1&&(j=j/H+.5|0,R=R/H+.5|0,Q=Q/H+.5|0,L=L/H+.5|0)}p[d++]=j,b+=j,M+=b,p[d++]=R,b+=R,M+=b,p[d++]=Q,b+=Q,M+=b,p[d++]=L,b+=L,M+=b,g+=r?j/255:pe[j],y+=r?R/255:pe[R],x+=r?Q/255:pe[Q],_+=L/255}b%=65521,M%=65521}let A=43,C=c,E=0;for(;C>0||E===0;){let N=Math.min(65535,C),F=C-N===0?1:0;if(u[A++]=F,f.setUint16(A,N,!0),f.setUint16(A+2,~N&65535,!0),A+=4,N>0&&(u.set(p.subarray(E,E+N),A),A+=N,E+=N,C-=N),F)break}f.setUint32(A,(M<<16|b)>>>0),A+=4,f.setUint32(A,Oe(u.subarray(37,A))),A+=4,f.setUint32(A,0),f.setUint32(A+4,1229278788),f.setUint32(A+8,2923585666);let k=Math.max(1,h*l),B=[g/k,y/k,x/k,_/k],T=["data:image/png;base64,"];for(let N=0;N<u.length;N+=3){let F=u[N]<<16|(u[N+1]??0)<<8|(u[N+2]??0);T.push(Pt[F>>18&63]+Pt[F>>12&63]+(N+1<u.length?Pt[F>>6&63]:"=")+(N+2<u.length?Pt[F&63]:"="))}return{uri:T.join(""),avgColor:B}},Mt=(s,t,e,i)=>(s&255|(t&255)<<8|(e&255)<<16|(i&255)<<24)>>>0,Ui=s=>{if(s._lut)return s._lut;let t=new Uint32Array(256),e=s.s;if(e.length===1){let i=e[0].c;t.fill(Mt(i[0],i[1],i[2],i[3]))}else if(e.length>1){let i=0;for(let r=0;r<256;r++){let a=r/255;if(a<=e[0].o){let n=e[0].c;t[r]=Mt(n[0],n[1],n[2],n[3])}else if(a>=e[e.length-1].o){let n=e[e.length-1].c;t[r]=Mt(n[0],n[1],n[2],n[3])}else{for(;i<e.length-2&&a>e[i+1].o;)i++;let n=e[i],h=e[i+1],l=h.o-n.o,o=l>1e-9?(a-n.o)/l:0;t[r]=Mt(n.c[0]+(h.c[0]-n.c[0])*o+.5|0,n.c[1]+(h.c[1]-n.c[1])*o+.5|0,n.c[2]+(h.c[2]-n.c[2])*o+.5|0,n.c[3]+(h.c[3]-n.c[3])*o+.5|0)}}}return s._lut=t,t},ji=(s,t,e)=>{if(s.s.length===0)return 0;let i=Ui(s),r=0;if(s.rad){let n=s.x1-s.x0,h=s.y1-s.y0,l=s.r1-s.r0,o=t-s.x0,c=e-s.y0,m=n*n+h*h-l*l,u=-2*(o*n+c*h+s.r0*l),f=o*o+c*c-s.r0*s.r0;if(Math.abs(m)<1e-9)r=Math.abs(u)>1e-9?-f/u:0;else{let p=Math.sqrt(Math.max(0,u*u-4*m*f)),d=(-u+p)/(2*m),b=(-u-p)/(2*m);r=s.r0+d*l>=0?d:s.r0+b*l>=0?b:Math.max(d,b)}}else{let n=s.x1-s.x0,h=s.y1-s.y0,l=n*n+h*h;if(l<=1e-12)return i[255];r=((t-s.x0)*n+(e-s.y0)*h)/l}let a=r<=0?0:r>=1?255:r*255+.5|0;return i[a]};class de{constructor(t,e,i,r,a,n,h){this._g=1,this.rad=t,this.x0=Number(e)||0,this.y0=Number(i)||0,this.r0=Math.max(0,Number(r)||0),this.x1=Number(a)||0,this.y1=Number(n)||0,this.r1=Math.max(0,Number(h)||0),this.s=[],this._lut=null}addColorStop(t,e){let i=Math.max(0,Math.min(1,Number(t)||0));this.s.push({o:i,c:Re(e,[0,0,0,255]),i:this.s.length}),this.s.sort((r,a)=>r.o-a.o||r.i-a.i),this._lut=null}}class Qe{constructor(t,e,i,r){this._g=2,this.d=t,this.w=Math.max(1,e|0),this.h=Math.max(1,i|0);let a=(r||"repeat").toLowerCase();this.rx=a==="repeat"||a==="repeat-x",this.ry=a==="repeat"||a==="repeat-y"}}let Oi=(s,t,e)=>{let i=Math.floor(t),r=Math.floor(e);if(s.rx)i=(i%s.w+s.w)%s.w;else if(i<0||i>=s.w)return 0;if(s.ry)r=(r%s.h+s.h)%s.h;else if(r<0||r>=s.h)return 0;let a=(r*s.w+i)*4;return Mt(s.d[a],s.d[a+1],s.d[a+2],s.d[a+3])},Li=s=>s>=32&&s<=126?s:s===176?39:s===8226||s===183?42:s===8211||s===8212||s===8722?45:s===215?120:s===8216||s===8217?39:s===8220||s===8221?34:63,He=new Array(190),Ii=(s,t)=>{let e=(s-32)*2+(t?1:0),i=He[e];if(i)return i;let r=new Uint8Array(63),a=(s-32)*5;for(let h=0;h<5;h++){let l=Ti[a+h]??0;for(let o=0;o<7;o++)l>>o&1&&(r[(o+1)*7+(h+1)]=1)}let n=new Uint8Array(140);for(let h=0;h<7;h++)for(let l=0;l<5;l++){let o=(h+1)*7+(l+1),c=r[o],m=r[o-7],u=r[o+1],f=r[o-1],p=r[o+7],d=h*2,b=l*2;n[d*10+b]=f===m&&f!==p&&m!==u?m:c,n[d*10+b+1]=m===u&&m!==f&&u!==p?u:c,n[(d+1)*10+b]=p===f&&p!==u&&f!==m?f:c,n[(d+1)*10+b+1]=u===p&&u!==m&&p!==f?p:c}if(t)for(let h=0;h<14;h++)for(let l=9;l>=1;l--)n[h*10+l-1]&&(n[h*10+l]=1);return He[e]=n,n},qe=s=>{let t=String(s||"10px sans-serif"),e=/\b(bold|bolder|[6-9]00)\b/i.test(t),i=/(\d+(?:\.\d+)?)\s*(px|pt|em|rem)\b/i.exec(t);if(!i)return{sizePx:10,bold:e};let r=parseFloat(i[1]),a=i[2].toLowerCase();return a==="pt"?r*=4/3:(a==="em"||a==="rem")&&(r*=16),{sizePx:Number.isFinite(r)&&r>0?Math.min(1024,r):10,bold:e}},Ge=s=>{s.fillStyle="#000000",s.strokeStyle="#000000",s.globalAlpha=1,s.globalCompositeOperation="source-over",s.lineWidth=1,s.lineCap="butt",s.lineJoin="miter",s.lineDashOffset=0,s.font="10px sans-serif",s.textAlign="start",s.textBaseline="alphabetic",s.shadowColor="rgba(0, 0, 0, 0)",s.shadowBlur=0,s.shadowOffsetX=0,s.shadowOffsetY=0,s._m=[1,0,0,1,0,0],s._dash=[],s._clip=null,s._stack=[],s._subs=[],s._cur=null,s._pts=0},q=(s,t,e)=>{let i=s._m;return[(i[0]*t+i[2]*e+i[4])*s.canvas._sx,(i[1]*t+i[3]*e+i[5])*s.canvas._sy]},Kt=s=>{let t=s.canvas._sx>0?1/s.canvas._sx:1,e=s.canvas._sy>0?1/s.canvas._sy:1,i=s._m,r=i[0]*i[3]-i[1]*i[2];if(Math.abs(r)<1e-12)return[0,0,0,0,0,0];let a=1/r;return[i[3]*t*a,-i[2]*e*a,(-i[3]*i[4]+i[2]*i[5])*a,-i[1]*t*a,i[0]*e*a,(i[1]*i[4]-i[0]*i[5])*a]},Di=(s,t,e)=>{let[i,r,a,n,h,l]=Kt(s);return[i*t+r*e+a,n*t+h*e+l]},Tt=s=>{let t=String(s.globalCompositeOperation||"source-over").toLowerCase();return t==="source-over"?0:t==="copy"?1:t==="destination-out"?2:t==="lighter"||t==="add"?3:t==="multiply"?4:t==="screen"?5:0},be=(s,t,e)=>{s._pts>=Pi||!s._cur||(s._cur.pts.push([t,e]),s._pts++)},Zt=(s,t)=>{let e=Number(s.globalAlpha),i=Number.isFinite(e)?Math.max(0,Math.min(1,e)):1,r=Math.round(i*256);if(typeof t=="string"){let h=Re(t,[0,0,0,255]),l=Mt(h[0],h[1],h[2],h[3]*r+128>>8);return()=>l}let a=t?t._g:0;if(a===1||a===2){let[h,l,o,c,m,u]=Kt(s);return(f,p)=>{let d=h*f+l*p+o,b=c*f+m*p+u,M=a===1?ji(t,d,b):Oi(t,d,b);if(r>=256)return M;let g=(M>>>24)*r+128>>8&255;return(M&16777215|g<<24)>>>0}}let n=Mt(0,0,0,255*r+128>>8);return()=>n},Ct=(s,t,e,i,r)=>{let a=s.canvas._bw,n=s.canvas._bh;if(e<0||e>=a||i<0||i>=n)return;let h=i*a+e;if(s._clip&&!s._clip[h])return;let l=s.canvas._data,o=h*4,c=r&255,m=r>>>8&255,u=r>>>16&255,f=r>>>24;if(t===1){l[o]=c,l[o+1]=m,l[o+2]=u,l[o+3]=f;return}if(f<=0)return;if(f>=255&&t===0){l[o]=c,l[o+1]=m,l[o+2]=u,l[o+3]=255;return}if(t===2){l[o+3]=(l[o+3]*(255-f)+127)/255|0,l[o+3]===0&&(l[o]=l[o+1]=l[o+2]=0);return}if(t===3){l[o]=Math.min(255,l[o]+((c*f+127)/255|0)),l[o+1]=Math.min(255,l[o+1]+((m*f+127)/255|0)),l[o+2]=Math.min(255,l[o+2]+((u*f+127)/255|0)),l[o+3]=Math.min(255,l[o+3]+f);return}let p=l[o+3],d=f/255,b=p/255,M=d+b*(1-d);if(M<=1e-6){l[o]=l[o+1]=l[o+2]=l[o+3]=0;return}let g=c,y=m,x=u;t===4&&p>0?(g=(g*l[o]+127)/255,y=(y*l[o+1]+127)/255,x=(x*l[o+2]+127)/255):t===5&&p>0&&(g=255-(255-g)*(255-l[o])/255,y=255-(255-y)*(255-l[o+1])/255,x=255-(255-x)*(255-l[o+2])/255),l[o]=lt((g*d+l[o]*b*(1-d))/M),l[o+1]=lt((y*d+l[o+1]*b*(1-d))/M),l[o+2]=lt((x*d+l[o+2]*b*(1-d))/M),l[o+3]=lt(M*255)},St=(s,t,e,i)=>{if(s.canvas.width<=0||s.canvas.height<=0)return;let r=s.canvas._bw,a=s.canvas._bh,n=[],h=a,l=-1;for(let p of t){let d=p.pts,b=d.length;if(!(b<2))for(let M=0;M<b;M++){let[g,y]=d[M],[x,_]=d[(M+1)%b];if(y===_)continue;let w=Math.min(y,_),A=Math.max(y,_);n.push([w,A,_>y?g:x,(_>y?x-g:g-x)/(A-w),_>y?1:-1]),w<h&&(h=w),A>l&&(l=A)}}if(n.length===0)return;let o=Math.max(0,Math.floor(h)),c=Math.min(a-1,Math.ceil(l)),m=e==="evenodd",u=(p,d,b)=>{for(let M=d;M<=b;M++)i(M,p)},f=[];for(let p=o;p<=c;p++){let d=p+.5;f.length=0;for(let b=0;b<n.length;b++){let M=n[b];M[0]<=d&&M[1]>d&&f.push([M[2]+(d-M[0])*M[3],M[4]])}if(!(f.length<2))if(f.sort((b,M)=>b[0]-M[0]),m)for(let b=0;b+1<f.length;b+=2)u(p,Math.max(0,Math.ceil(f[b][0]-.5)),Math.min(r-1,Math.floor(f[b+1][0]-.5)));else{let b=0,M=0;for(let g=0;g<f.length;g++){let y=b;b+=f[g][1],y===0&&b!==0?M=f[g][0]:y!==0&&b===0&&u(p,Math.max(0,Math.ceil(M-.5)),Math.min(r-1,Math.floor(f[g][0]-.5)))}}}},Ve=(s,t,e,i,r,a)=>{if(!Number.isFinite(e+i)||s.canvas.width<=0||s.canvas.height<=0)return;let n=String(t??"").slice(0,1024);if(!n)return;let h=Array.from(n),{sizePx:l,bold:o}=qe(s.font),c=l,m=l*(o?.54:.5),u=l*(o?.64:.6),f=h.length*u-l*.1,p=1;if(r!==void 0&&Number.isFinite(r)){if(r<=0)return;f>r&&f>0&&(p=r/f)}let d=f*p,b=e;s.textAlign==="center"?b-=d*.5:(s.textAlign==="right"||s.textAlign==="end")&&(b-=d);let M=i,g=s.textBaseline;g==="middle"?M-=c*.5:g==="bottom"||g==="ideographic"?M-=c:g==="alphabetic"?M-=c*.82:g==="hanging"&&(M-=c*.08);let y=Zt(s,a?s.strokeStyle:s.fillStyle),x=Tt(s),[_,w,A,C,E,k]=Kt(s),B=s.canvas._bw,T=s.canvas._bh,N=new Uint8Array(B*T),F=m*p;if(F<=1e-6||c<=1e-6)return;let S=1/F,D=1/c;for(let O=0;O<h.length;O++){let j=Li(h[O].codePointAt(0)??32);if(j===32)continue;let R=b+O*u*p,Q=Ii(j,o),L=q(s,R,M),I=q(s,R+F,M),V=q(s,R+F,M+c),H=q(s,R,M+c),W=Math.max(0,Math.floor(Math.min(L[0],I[0],V[0],H[0]))),G=Math.min(B-1,Math.ceil(Math.max(L[0],I[0],V[0],H[0]))),J=Math.max(0,Math.floor(Math.min(L[1],I[1],V[1],H[1]))),K=Math.min(T-1,Math.ceil(Math.max(L[1],I[1],V[1],H[1])));for(let ht=J;ht<=K;ht++){let et=ht+.5;for(let yt=W;yt<=G;yt++){let Ft=ht*B+yt;if(N[Ft])continue;let Nt=yt+.5,Qt=_*Nt+w*et+A,Ht=C*Nt+E*et+k,dt=(Qt-R)*S,bt=(Ht-M)*D;if(dt<0||dt>=1||bt<0||bt>=1)continue;let it=Math.min(9,dt*10|0),st=Math.min(13,bt*14|0);Q[st*10+it]===1&&(a&&it>0&&it<9&&st>0&&st<13&&Q[st*10+it-1]&&Q[st*10+it+1]&&Q[(st-1)*10+it]&&Q[(st+1)*10+it]||(N[Ft]=1,Ct(s,x,yt,ht,y(Nt,et))))}}}s.canvas._ver++};class We{constructor(t){this.canvas=t,Ge(this)}save(){this._stack.length>=ki||this._stack.push([this._m.slice(),this.fillStyle,this.strokeStyle,this.globalAlpha,this.globalCompositeOperation,this.lineWidth,this.lineCap,this.lineJoin,this._dash.slice(),this.lineDashOffset,this.font,this.textAlign,this.textBaseline,this.shadowColor,this.shadowBlur,this.shadowOffsetX,this.shadowOffsetY,this._clip?new Uint8Array(this._clip):null])}restore(){let t=this._stack.pop();t&&([this._m,this.fillStyle,this.strokeStyle,this.globalAlpha,this.globalCompositeOperation,this.lineWidth,this.lineCap,this.lineJoin,this._dash,this.lineDashOffset,this.font,this.textAlign,this.textBaseline,this.shadowColor,this.shadowBlur,this.shadowOffsetX,this.shadowOffsetY,this._clip]=t)}setLineDash(t){if(!Array.isArray(t))return;let e=[];for(let i=0;i<Math.min(64,t.length);i++){let r=Number(t[i]);if(!Number.isFinite(r)||r<0)return;e.push(r)}this._dash=e.length%2===1?[...e,...e]:e}getLineDash(){return[...this._dash]}resetTransform(){this._m=[1,0,0,1,0,0]}setTransform(t,e,i,r,a,n){if(t&&typeof t=="object"){this.setTransform(t.a??1,t.b??0,t.c??0,t.d??1,t.e??0,t.f??0);return}let h=Number(t??1),l=Number(e??0),o=Number(i??0),c=Number(r??1),m=Number(a??0),u=Number(n??0);Number.isFinite(h+l+o+c+m+u)&&(this._m=[h,l,o,c,m,u])}getTransform(){let t=this._m;return{a:t[0],b:t[1],c:t[2],d:t[3],e:t[4],f:t[5]}}transform(t,e,i,r,a,n){if(!Number.isFinite(t+e+i+r+a+n))return;let h=this._m;this._m=[h[0]*t+h[2]*e,h[1]*t+h[3]*e,h[0]*i+h[2]*r,h[1]*i+h[3]*r,h[0]*a+h[2]*n+h[4],h[1]*a+h[3]*n+h[5]]}translate(t,e){this.transform(1,0,0,1,t,e)}rotate(t){if(!Number.isFinite(t))return;let e=Math.cos(t),i=Math.sin(t);this.transform(e,i,-i,e,0,0)}scale(t,e){this.transform(t,0,0,e,0,0)}createLinearGradient(t,e,i,r){return new de(!1,t,e,0,i,r,0)}createRadialGradient(t,e,i,r,a,n){return new de(!0,t,e,i,r,a,n)}createPattern(t,e="repeat"){let i=te(t);return i?new Qe(i.data,i.width,i.height,e):null}beginPath(){this._subs.length=0,this._cur=null,this._pts=0}closePath(){if(this._cur&&this._cur.pts.length>0){this._cur.closed=!0;let t=this._cur.pts[0];this._cur={pts:[[t[0],t[1]]],closed:!1},this._subs.push(this._cur)}}moveTo(t,e){Number.isFinite(t+e)&&(this._cur={pts:[q(this,t,e)],closed:!1},this._subs.push(this._cur),this._pts++)}lineTo(t,e){if(!Number.isFinite(t+e))return;if(!this._cur||this._cur.pts.length===0){this.moveTo(t,e);return}let i=q(this,t,e);be(this,i[0],i[1])}rect(t,e,i,r){Number.isFinite(t+e+i+r)&&(this.moveTo(t,e),this.lineTo(t+i,e),this.lineTo(t+i,e+r),this.lineTo(t,e+r),this.closePath())}roundRect(t,e,i,r,a){if(!Number.isFinite(t+e+i+r))return;i<0&&(t+=i,i=-i),r<0&&(e+=r,r=-r);let n=Array.isArray(a)?a:a!==void 0?[a]:[0],h=f=>{let p=Number(f&&typeof f=="object"?f.x??0:f??0);return Number.isFinite(p)?Math.max(0,p):0},l=h(n[0]),o=h(n[1]??n[0]),c=h(n[2]??n[0]),m=h(n[3]??n[1]??n[0]),u=Math.min(1,i/Math.max(1e-6,l+o),i/Math.max(1e-6,m+c),r/Math.max(1e-6,l+m),r/Math.max(1e-6,o+c));if(l*=u,o*=u,c*=u,m*=u,l+o+c+m<=1e-4){this.rect(t,e,i,r);return}this.moveTo(t+l,e),this.lineTo(t+i-o,e),o>0&&this.arc(t+i-o,e+o,o,-Math.PI/2,0),this.lineTo(t+i,e+r-c),c>0&&this.arc(t+i-c,e+r-c,c,0,Math.PI/2),this.lineTo(t+m,e+r),m>0&&this.arc(t+m,e+r-m,m,Math.PI/2,Math.PI),this.lineTo(t,e+l),l>0&&this.arc(t+l,e+l,l,Math.PI,Math.PI*3/2),this.closePath()}quadraticCurveTo(t,e,i,r){if(!Number.isFinite(t+e+i+r))return;(!this._cur||this._cur.pts.length===0)&&this.moveTo(t,e);let a=this._cur.pts,[n,h]=a[a.length-1],[l,o]=q(this,t,e),[c,m]=q(this,i,r),u=Math.max(4,Math.min(64,Math.ceil((Math.hypot(l-n,o-h)+Math.hypot(c-l,m-o))*.5)));for(let f=1;f<=u;f++){let p=f/u,d=1-p;be(this,d*d*n+2*d*p*l+p*p*c,d*d*h+2*d*p*o+p*p*m)}}bezierCurveTo(t,e,i,r,a,n){if(!Number.isFinite(t+e+i+r+a+n))return;(!this._cur||this._cur.pts.length===0)&&this.moveTo(t,e);let h=this._cur.pts,[l,o]=h[h.length-1],[c,m]=q(this,t,e),[u,f]=q(this,i,r),[p,d]=q(this,a,n),b=Math.max(6,Math.min(64,Math.ceil((Math.hypot(c-l,m-o)+Math.hypot(u-c,f-m)+Math.hypot(p-u,d-f))*.4)));for(let M=1;M<=b;M++){let g=M/b,y=1-g,x=y*y,_=g*g;be(this,x*y*l+3*x*g*c+3*y*_*u+_*g*p,x*y*o+3*x*g*m+3*y*_*f+_*g*d)}}ellipse(t,e,i,r,a=0,n=0,h=Math.PI*2,l=!1){if(!Number.isFinite(t+e+i+r+a+n+h))return;let o=Math.max(0,i),c=Math.max(0,r),m=Math.PI*2,u=h-n;if(!l)u>=m?u=m:u<0&&(u=(u%m+m)%m);else if(u<=-m)u=-m;else if(u>0){let M=u%m;u=M===0?0:M-m}let f=Math.cos(a),p=Math.sin(a),d=Math.hypot(this._m[0]*this.canvas._sx,this._m[1]*this.canvas._sy,this._m[2]*this.canvas._sx,this._m[3]*this.canvas._sy),b=Math.max(8,Math.min(96,Math.ceil(Math.abs(u)*Math.max(1,o,c)*d/3)));for(let M=0;M<=b;M++){let g=n+u*M/b,y=o*Math.cos(g),x=c*Math.sin(g),_=t+y*f-x*p,w=e+y*p+x*f;M===0&&(!this._cur||this._cur.pts.length===0)?this.moveTo(_,w):this.lineTo(_,w)}}arc(t,e,i,r,a,n=!1){this.ellipse(t,e,i,i,0,r,a,n)}arcTo(t,e,i,r,a){if(!Number.isFinite(t+e+i+r+a))return;let n=Math.max(0,a);if(!this._cur||this._cur.pts.length===0){this.moveTo(t,e);return}if(n<=1e-6){this.lineTo(t,e);return}let h=this._cur.pts,[l,o]=h[h.length-1],[c,m]=Di(this,l,o),u=c-t,f=m-e,p=i-t,d=r-e,b=Math.hypot(u,f),M=Math.hypot(p,d);if(b<1e-6||M<1e-6){this.lineTo(t,e);return}let g=u/b,y=f/b,x=p/M,_=d/M,w=g*_-y*x;if(Math.abs(w)<1e-6){this.lineTo(t,e);return}let A=Math.acos(Math.max(-1,Math.min(1,g*x+y*_)))*.5,C=n/Math.tan(A),E=g+x,k=y+_,B=Math.hypot(E,k)||1,T=n/Math.sin(A),N=t+E/B*T,F=e+k/B*T;this.arc(N,F,n,Math.atan2(e+y*C-F,t+g*C-N),Math.atan2(e+_*C-F,t+x*C-N),w>0)}fill(t){if(this.canvas.width<=0||this.canvas.height<=0)return;let e=Zt(this,this.fillStyle),i=Tt(this);St(this,this._subs,typeof t=="string"?t:"nonzero",(r,a)=>Ct(this,i,r,a,e(r+.5,a+.5))),this.canvas._ver++}clip(t){let e=this.canvas._bw,i=this.canvas._bh,r=new Uint8Array(e*i);if(St(this,this._subs,typeof t=="string"?t:"nonzero",(a,n)=>{r[n*e+a]=1}),this._clip)for(let a=0;a<r.length;a++)r[a]&=this._clip[a];this._clip=r}stroke(){if(this.canvas.width<=0||this.canvas.height<=0)return;let t=this._m,e=(Math.hypot(t[0]*this.canvas._sx,t[1]*this.canvas._sy)+Math.hypot(t[2]*this.canvas._sx,t[3]*this.canvas._sy))*.5,i=Number(this.lineWidth),r=Number.isFinite(i)&&i>0?i:1,a=Math.max(.5,r*e*.5),n=a*a,h=this.lineCap,l=this.canvas._bw,o=this.canvas._bh,c=Zt(this,this.strokeStyle),m=Tt(this),u=new Uint8Array(l*o),f=0,p=[];for(let g=0;g<this._dash.length;g++){let y=this._dash[g]*e;p.push(y),f+=y}let d=(g,y,x,_,w,A)=>{let C=g,E=y,k=x,B=_,T=k-C,N=B-E,F=Math.hypot(T,N);if(h==="square"&&F>1e-6){let L=T/F*a,I=N/F*a;w&&(C-=L,E-=I),A&&(k+=L,B+=I),T=k-C,N=B-E}let S=T*T+N*N,D=a+.5,O=Math.max(0,Math.floor(Math.min(C,k)-D)),j=Math.min(l-1,Math.ceil(Math.max(C,k)+D)),R=Math.max(0,Math.floor(Math.min(E,B)-D)),Q=Math.min(o-1,Math.ceil(Math.max(E,B)+D));for(let L=R;L<=Q;L++){let I=L+.5;for(let V=O;V<=j;V++){let H=L*l+V;if(u[H])continue;let W=V+.5,G=S>1e-9?((W-C)*T+(I-E)*N)/S:0;if(h==="butt"&&(G<0&&w||G>1&&A))continue;G=Math.max(0,Math.min(1,G));let J=C+G*T,K=E+G*N;(W-J)*(W-J)+(I-K)*(I-K)<=n&&(u[H]=1,Ct(this,m,V,L,c(W,I)))}}},b=Number(this.lineDashOffset),M=Number.isFinite(b)?b:0;for(let g of this._subs){let y=g.pts,x=y.length;if(x<2)continue;let _=g.closed?x:x-1,w=f>1e-6?(M*e%f+f)%f:0;for(let A=0;A<_;A++){let[C,E]=y[A],[k,B]=y[(A+1)%x];if(f<=1e-6)d(C,E,k,B,!g.closed&&A===0,!g.closed&&A===_-1);else{let T=Math.hypot(k-C,B-E);if(T<=1e-6)continue;let N=0;for(;N<T;){let F=w,S=0;for(;S<p.length&&F>=p[S];)F-=p[S],S++;let D=Math.min(T-N,S<p.length?Math.max(.25,p[S]-F):T-N);if(S%2===0){let O=N/T,j=(N+D)/T;d(C+(k-C)*O,E+(B-E)*O,C+(k-C)*j,E+(B-E)*j,!0,!0)}N+=D,w=(w+D)%f}}}}this.canvas._ver++}clearRect(t,e,i,r){if(!Number.isFinite(t+e+i+r)||this.canvas.width<=0||this.canvas.height<=0)return;let a=this._m;if(a[0]===1&&a[1]===0&&a[2]===0&&a[3]===1&&a[4]===0&&a[5]===0&&!this._clip&&t<=0&&e<=0&&t+i>=this.canvas.width&&e+r>=this.canvas.height){this.canvas._data.fill(0),this.canvas._ver++;return}let n=this.canvas._data,h=this.canvas._bw,l=this._clip;St(this,[{pts:[q(this,t,e),q(this,t+i,e),q(this,t+i,e+r),q(this,t,e+r)],closed:!0}],"nonzero",(o,c)=>{let m=c*h+o;if(l&&!l[m])return;let u=m*4;n[u]=n[u+1]=n[u+2]=n[u+3]=0}),this.canvas._ver++}fillRect(t,e,i,r){if(!Number.isFinite(t+e+i+r)||i===0||r===0||this.canvas.width<=0||this.canvas.height<=0)return;let a=Zt(this,this.fillStyle),n=Tt(this),h=this._m;if(h[1]===0&&h[2]===0){let l=this.canvas._bw,o=this.canvas._bh,c=(h[0]*t+h[4])*this.canvas._sx,m=(h[0]*(t+i)+h[4])*this.canvas._sx,u=(h[3]*e+h[5])*this.canvas._sy,f=(h[3]*(e+r)+h[5])*this.canvas._sy,p=Math.max(0,Math.ceil(Math.min(c,m)-.5)),d=Math.min(l-1,Math.ceil(Math.max(c,m)-.5)-1),b=Math.max(0,Math.ceil(Math.min(u,f)-.5)),M=Math.min(o-1,Math.ceil(Math.max(u,f)-.5)-1);if(p<=d&&b<=M){if(!this._clip&&typeof this.fillStyle=="string"){let y=a(0,0),x=y>>>24;if(n===0&&x>=255||n===1){let _=new Uint32Array(new Uint8Array([y&255,y>>>8&255,y>>>16&255,x]).buffer)[0],w=this.canvas._data,A=new Uint32Array(w.buffer,w.byteOffset,l*o);if(p===0&&d===l-1)A.fill(_,b*l,(M+1)*l);else for(let C=b;C<=M;C++)A.fill(_,C*l+p,C*l+d+1);this.canvas._ver++;return}}let g=y=>{let x=y+.5;for(let _=p;_<=d;_++)Ct(this,n,_,y,a(_+.5,x))};for(let y=b;y<=M;y++)g(y)}this.canvas._ver++;return}St(this,[{pts:[q(this,t,e),q(this,t+i,e),q(this,t+i,e+r),q(this,t,e+r)],closed:!0}],"nonzero",(l,o)=>Ct(this,n,l,o,a(l+.5,o+.5))),this.canvas._ver++}strokeRect(t,e,i,r){if(!Number.isFinite(t+e+i+r)||i===0&&r===0)return;let a=this._subs,n=this._cur,h=this._pts;this._subs=[],this._cur=null,this._pts=0,this.rect(t,e,i,r),this.stroke(),this._subs=a,this._cur=n,this._pts=h}measureText(t){let{sizePx:e,bold:i}=qe(this.font),r=Array.from(String(t??"")).length;return{width:r>0?r*e*(i?.64:.6)-e*.1:0,actualBoundingBoxAscent:e*.8,actualBoundingBoxDescent:e*.2,fontBoundingBoxAscent:e*.85,fontBoundingBoxDescent:e*.2}}fillText(t,e,i,r){Ve(this,t,e,i,r,!1)}strokeText(t,e,i,r){Ve(this,t,e,i,r,!0)}createImageData(t,e){let i=t&&typeof t=="object",r=Math.max(1,Math.min(rt,Math.floor(Math.abs(Number(i?t.width:t))||1))),a=Math.max(1,Math.min(rt,Math.floor(Math.abs(Number(i?t.height:e))||1)));return{data:new Uint8ClampedArray(r*a*4),width:r,height:a}}getImageData(t,e,i,r){let a=Math.floor(Number(t)||0),n=Math.floor(Number(e)||0),h=Math.floor(Number(i)||0),l=Math.floor(Number(r)||0);h<0&&(a+=h,h=-h),l<0&&(n+=l,l=-l),h=Math.max(1,Math.min(rt,h)),l=Math.max(1,Math.min(rt,l));let o=new Uint8ClampedArray(h*l*4);if(this.canvas.width<=0||this.canvas.height<=0)return{data:o,width:h,height:l};let c=this.canvas._bw,m=this.canvas._bh,u=this.canvas._sx,f=this.canvas._sy,p=this.canvas._data;for(let d=0;d<l;d++){let b=n+d;if(b<0||b>=this.canvas.height)continue;let M=Math.min(m-1,Math.floor((b+.5)*f));for(let g=0;g<h;g++){let y=a+g;if(y<0||y>=this.canvas.width)continue;let x=(M*c+Math.min(c-1,Math.floor((y+.5)*u)))*4,_=(d*h+g)*4;o[_]=p[x],o[_+1]=p[x+1],o[_+2]=p[x+2],o[_+3]=p[x+3]}}return{data:o,width:h,height:l}}putImageData(t,e,i,r=0,a=0,n,h){if(!t?.data||this.canvas.width<=0||this.canvas.height<=0)return;let l=Math.floor(Number(t.width)||0),o=Math.floor(Number(t.height)||0);if(l<=0||o<=0)return;let c=Math.floor(Number(r)||0),m=Math.floor(Number(a)||0),u=n!==void 0?Math.floor(Number(n)):l,f=h!==void 0?Math.floor(Number(h)):o;u<0&&(c+=u,u=-u),f<0&&(m+=f,f=-f);let p=Math.max(0,c),d=Math.max(0,m),b=Math.min(l,c+u),M=Math.min(o,m+f);if(p>=b||d>=M)return;let g=Math.floor(Number(e)||0),y=Math.floor(Number(i)||0),x=this.canvas._bw,_=this.canvas._bh,w=1/this.canvas._sx,A=1/this.canvas._sy,C=this.canvas._data,E=t.data,k=Math.max(0,Math.floor((g+p)*this.canvas._sx)),B=Math.min(x-1,Math.ceil((g+b)*this.canvas._sx)-1),T=Math.max(0,Math.floor((y+d)*this.canvas._sy)),N=Math.min(_-1,Math.ceil((y+M)*this.canvas._sy)-1);for(let F=T;F<=N;F++){let S=Math.floor((F+.5)*A)-y;if(!(S<d||S>=M))for(let D=k;D<=B;D++){let O=Math.floor((D+.5)*w)-g;if(O<p||O>=b)continue;let j=(S*l+O)*4,R=(F*x+D)*4;C[R]=E[j]|0,C[R+1]=E[j+1]|0,C[R+2]=E[j+2]|0,C[R+3]=E[j+3]|0}}this.canvas._ver++}drawImage(t,...e){let i=te(t);if(!i||i.width<=0||i.height<=0||this.canvas.width<=0||this.canvas.height<=0)return;let r=Number(t?.width)>0?Number(t.width):i.width,a=Number(t?.height)>0?Number(t.height):i.height,n=0,h=0,l=r,o=a,c=0,m=0,u=r,f=a;if(e.length>=8)[n,h,l,o,c,m,u,f]=e;else if(e.length>=4)[c,m,u,f]=e;else if(e.length>=2)[c,m]=e;else return;if(!Number.isFinite(n+h+l+o+c+m+u+f)||l===0||o===0||u===0||f===0)return;let p=Number(this.globalAlpha),d=Number.isFinite(p)?Math.max(0,Math.min(1,p)):1,b=Math.round(d*256),M=Tt(this),[g,y,x,_,w,A]=Kt(this),C=1/u,E=1/f,k=i.width/r,B=i.height/a;St(this,[{pts:[q(this,c,m),q(this,c+u,m),q(this,c+u,m+f),q(this,c,m+f)],closed:!0}],"nonzero",(T,N)=>{let F=T+.5,S=N+.5,D=g*F+y*S+x,O=_*F+w*S+A,j=(D-c)*C,R=(O-m)*E;if(j<0||j>=1||R<0||R>=1)return;let Q=Math.floor((n+j*l)*k),L=Math.floor((h+R*o)*B);if(Q<0||Q>=i.width||L<0||L>=i.height)return;let I=(L*i.width+Q)*4;Ct(this,M,T,N,Mt(i.data[I],i.data[I+1],i.data[I+2],i.data[I+3]*b+128>>8))}),this.canvas._ver++}}let ge=(s,t,e)=>{let i=Math.floor(Number(t)),r=Math.floor(Number(e));s._w=Number.isFinite(i)&&i>=0?i:0,s._h=Number.isFinite(r)&&r>=0?r:0,s._bw=s._w>0?Math.min(Xt,s._w):1,s._bh=s._h>0?Math.min(Xt,s._h):1,s._sx=s._w>0?s._bw/s._w:1,s._sy=s._h>0?s._bh/s._h:1,s._data=new Uint8ClampedArray(s._bw*s._bh*4),s._ctx2d&&Ge(s._ctx2d),s._ver++};class Ut{constructor(t=300,e=150){this._vc=!0,this._ver=1,this._ctx2d=null,this.style={},ge(this,t,e)}get width(){return this._w}set width(t){ge(this,t,this._h)}get height(){return this._h}set height(t){ge(this,this._w,t)}getContext(t){return String(t).toLowerCase()!=="2d"?null:this._ctx2d??(this._ctx2d=new We(this))}toDataURL(){return this._w<=0||this._h<=0||this._w>rt||this._h>rt?"":kt(this._data,this._bw,this._bh,!1,!1).uri}addEventListener(){}removeEventListener(){}getBoundingClientRect(){return{left:0,top:0,width:this._w,height:this._h,right:this._w,bottom:this._h}}}function te(s){if(!s||typeof s!="object")return null;let t=s._vc?s:s.canvas?._vc?s.canvas:s.image?._vc?s.image:null;if(t)return{data:t._data,width:t._bw,height:t._bh,logicalW:t._w,logicalH:t._h,ver:t._ver};let e=s.image&&typeof s.image=="object"?s.image:s;if(e.data&&typeof e.data.length=="number"&&Number(e.width)>0&&Number(e.height)>0){let i=Math.floor(Number(e.width)),r=Math.floor(Number(e.height));return{data:e.data instanceof Uint8ClampedArray?e.data:new Uint8ClampedArray(e.data),width:i,height:r,logicalW:i,logicalH:r,ver:-1}}if(typeof e.getContext=="function"){let i=Math.floor(Number(e.width)||0),r=Math.floor(Number(e.height)||0);if(i>0&&r>0&&i<=rt&&r<=rt)try{let a=e.getContext("2d")?.getImageData?.(0,0,i,r);if(a?.data)return{data:a.data instanceof Uint8ClampedArray?a.data:new Uint8ClampedArray(a.data),width:i,height:r,logicalW:i,logicalH:r,ver:-1}}catch{}}return null}let Ri=z.Texture??class{constructor(s=""){this.source=s,this.isTexture=!0,this.image=null,this.width=0,this.height=0}dispose(){}},$e=s=>{let t=te(s.image);if(!t){s.width=Number(s.image?.width??0)||0,s.height=Number(s.image?.height??0)||0,s._cs="";return}if(s.width=t.logicalW,s.height=t.logicalH,t.logicalW<=0||t.logicalH<=0||t.logicalW>rt||t.logicalH>rt){s._cs="";return}let e=`${t.ver>=0?t.ver:s._fs}|${t.logicalW}x${t.logicalH}|${s.flipY?1:0}|${s.colorSpace}`;if(e===s._bk&&s._cs)return;s._bk=e;let i=kt(t.data,t.width,t.height,s.flipY,s.colorSpace==="srgb-linear",Math.min(rt,Number(s._pngDim)||Xt));s._cs=i.uri,s._ca=i.avgColor};class Me extends Ri{constructor(t=null,e,i=1001,r=1001,a=1006,n=1008,h=1023,l=1009,o=1,c="srgb"){super(""),delete this.source,this.isCanvasTexture=!0,this.isDataTexture=!0,this.image=t,this.width=Number(t?.width??0)||0,this.height=Number(t?.height??0)||0,this.wrapS=Number(i)||1001,this.wrapT=Number(r)||1001,this.magFilter=Number(a)||1006,this.minFilter=Number(n)||1008,this.format=Number(h)||1023,this.type=Number(l)||1009,this.flipY=!0,this.generateMipmaps=!0,this.unpackAlignment=4,this.colorSpace=c||"srgb",this._bk="",this._cs="",this._ca=[1,1,1,1],this._ms="",this._fs=1}get needsUpdate(){return!1}set needsUpdate(t){t&&(this._ms="",this._fs++,this.width=Number(this.image?.width??0)||0,this.height=Number(this.image?.height??0)||0)}get source(){return this._ms?this._ms:($e(this),this._cs)}set source(t){this._ms=typeof t=="string"?t:""}get avgColor(){return this._ms||$e(this),this._ca}set avgColor(t){Array.isArray(t)&&t.length===4&&(this._ca=[t[0],t[1],t[2],t[3]])}}try{Object.freeze(de.prototype),Object.freeze(Qe.prototype),Object.freeze(We.prototype),Object.freeze(Ut.prototype)}catch{}let Qi=(s=300,t=150)=>new Ut(s,t);try{let s=typeof globalThis<"u"?globalThis:typeof self<"u"?self:void 0;if(s&&typeof s.HTMLCanvasElement>"u"){let t=e=>String(e).toLowerCase()==="canvas"?new Ut(300,150):{style:{},getContext:()=>null,addEventListener:()=>{},removeEventListener:()=>{},appendChild:()=>{},removeChild:()=>{},setAttribute:()=>{}};if(typeof s.document>"u"||s.document===null){let e=Object.freeze({appendChild:()=>{},removeChild:()=>{},style:{}}),i=Object.freeze({style:{}});s.document=Object.freeze({__threeLiveVirtualCanvas:!0,createElement:t,createTextNode:()=>({}),querySelectorAll:()=>[],querySelector:()=>null,getElementById:()=>null,head:e,body:e,documentElement:i,addEventListener:()=>{},removeEventListener:()=>{}})}else if(typeof s.document=="object"&&!s.document.__threeLiveVirtualCanvas){let e=typeof s.document.createElement=="function"?s.document.createElement.bind(s.document):null;try{s.document.__threeLiveVirtualCanvas=!0,s.document.createElement=i=>String(i).toLowerCase()==="canvas"?new Ut(300,150):e?e(i):t(i)}catch{}}}}catch{}let Ye=new Uint8Array([151,160,137,91,90,15,131,13,201,95,96,53,194,233,7,225,140,36,103,30,69,142,8,99,37,240,21,10,23,190,6,148,247,120,234,75,0,26,197,62,94,252,219,203,117,35,11,32,57,177,33,88,237,149,56,87,174,20,125,136,171,168,68,175,74,165,71,134,139,48,27,166,77,146,158,231,83,111,229,122,60,211,133,230,220,105,92,41,55,46,245,40,244,102,143,54,65,25,63,161,1,216,80,73,209,76,132,187,208,89,18,169,200,196,135,130,116,188,159,86,164,100,109,198,173,186,3,64,52,217,226,250,124,123,5,202,38,147,118,126,255,82,85,212,207,206,59,227,47,16,58,17,182,189,28,42,223,183,170,213,119,248,152,2,44,154,163,70,221,153,101,155,167,43,172,9,129,22,39,253,19,98,108,110,79,113,224,232,178,185,112,104,218,246,97,228,251,34,242,193,238,210,144,12,191,179,162,241,81,51,145,235,249,14,239,107,49,192,214,31,181,199,106,157,184,84,204,176,115,121,50,45,127,4,150,254,138,236,205,93,222,114,67,29,24,72,243,141,128,195,78,66,215,61,156,180]),Y=new Uint8Array(512);for(let s=0;s<256;s++)Y[s]=Ye[s],Y[s+256]=Ye[s];let xe=s=>s*s*s*(s*(s*6-15)+10),vt=(s,t,e)=>t+s*(e-t),xt=(s,t,e,i)=>{let r=s&15,a=r<8?t:e,n=r<4?e:r===12||r===14?t:i;return((r&1)===0?a:-a)+((r&2)===0?n:-n)};class Je{noise(t,e,i=0){let r=Number(t),a=Number(e),n=Number(i);if(!Number.isFinite(r)||!Number.isFinite(a)||!Number.isFinite(n))return 0;let h=Math.floor(r),l=Math.floor(a),o=Math.floor(n),c=h&255,m=l&255,u=o&255;r-=h,a-=l,n-=o;let f=r-1,p=a-1,d=n-1,b=xe(r),M=xe(a),g=xe(n),y=Y[c]+m,x=Y[y]+u,_=Y[y+1]+u,w=Y[c+1]+m,A=Y[w]+u,C=Y[w+1]+u;return vt(g,vt(M,vt(b,xt(Y[x],r,a,n),xt(Y[A],f,a,n)),vt(b,xt(Y[_],r,p,n),xt(Y[C],f,p,n))),vt(M,vt(b,xt(Y[x+1],r,a,d),xt(Y[A+1],f,a,d)),vt(b,xt(Y[_+1],r,p,d),xt(Y[C+1],f,p,d))))}}Object.freeze(Je.prototype);let jt=new Int8Array([1,1,0,-1,1,0,1,-1,0,-1,-1,0,1,0,1,-1,0,1,1,0,-1,-1,0,-1,0,1,1,0,-1,1,0,1,-1,0,-1,-1]),ee=new Int8Array([0,1,1,1,0,1,1,-1,0,1,-1,1,0,1,-1,-1,0,-1,1,1,0,-1,1,-1,0,-1,-1,1,0,-1,-1,-1,1,0,1,1,1,0,1,-1,1,0,-1,1,1,0,-1,-1,-1,0,1,1,-1,0,1,-1,-1,0,-1,1,-1,0,-1,-1,1,1,0,1,1,1,0,-1,1,-1,0,1,1,-1,0,-1,-1,1,0,1,-1,1,0,-1,-1,-1,0,1,-1,-1,0,-1,1,1,1,0,1,1,-1,0,1,-1,1,0,1,-1,-1,0,-1,1,1,0,-1,1,-1,0,-1,-1,1,0,-1,-1,-1,0]),Hi=.5*(Math.sqrt(3)-1),Ot=(3-Math.sqrt(3))/6,qi=1/3,ut=1/6,Gi=(Math.sqrt(5)-1)/4,$=(5-Math.sqrt(5))/20,_e=(s,t,e)=>jt[s]*t+jt[s+1]*e,ie=(s,t,e,i)=>jt[s]*t+jt[s+1]*e+jt[s+2]*i,Lt=(s,t,e,i,r)=>ee[s]*t+ee[s+1]*e+ee[s+2]*i+ee[s+3]*r;function Vi(s){let t=s===void 0?Math:s;if(typeof t=="function")return t;if(typeof t=="number"){let e=Number.isFinite(t)?t|0:0;return()=>{let i=e=e+1831565813|0;return i=Math.imul(i^i>>>15,i|1),i^=i+Math.imul(i^i>>>7,i|61),((i^i>>>14)>>>0)/4294967296}}return t&&typeof t=="object"&&typeof t.random=="function"?()=>t.random():Math.random}class Xe{constructor(t){let e=Vi(t),i=new Uint8Array(256);for(let n=0;n<256;n++){let h=Number(e()),l=Number.isFinite(h)?(h%1+1)%1:0;i[n]=Math.floor(l*256)&255}let r=new Uint8Array(512),a=new Uint8Array(512);for(let n=0;n<512;n++){let h=i[n&255];r[n]=h,a[n]=h%12}this.p=i,this.perm=r,this.permMod12=a}noise(t,e){let i=Number(t),r=Number(e);if(!Number.isFinite(i)||!Number.isFinite(r))return 0;let a=this.perm,n=this.permMod12,h=(i+r)*Hi,l=Math.floor(i+h),o=Math.floor(r+h),c=(l+o)*Ot,m=l-c,u=o-c,f=i-m,p=r-u,d=f>p?1:0,b=f>p?0:1,M=f-d+Ot,g=p-b+Ot,y=f-1+2*Ot,x=p-1+2*Ot,_=l&255,w=o&255,A=n[_+a[w]]*3,C=n[_+d+a[w+b]]*3,E=n[_+1+a[w+1]]*3,k=0,B=.5-f*f-p*p;B>=0&&(B*=B,k=B*B*_e(A,f,p));let T=0,N=.5-M*M-g*g;N>=0&&(N*=N,T=N*N*_e(C,M,g));let F=0,S=.5-y*y-x*x;return S>=0&&(S*=S,F=S*S*_e(E,y,x)),70*(k+T+F)}noise3d(t,e,i){let r=Number(t),a=Number(e),n=Number(i);if(!Number.isFinite(r)||!Number.isFinite(a)||!Number.isFinite(n))return 0;let h=this.perm,l=this.permMod12,o=(r+a+n)*qi,c=Math.floor(r+o),m=Math.floor(a+o),u=Math.floor(n+o),f=(c+m+u)*ut,p=r-(c-f),d=a-(m-f),b=n-(u-f),M,g,y,x,_,w;p>=d?d>=b?(M=1,g=0,y=0,x=1,_=1,w=0):p>=b?(M=1,g=0,y=0,x=1,_=0,w=1):(M=0,g=0,y=1,x=1,_=0,w=1):d<b?(M=0,g=0,y=1,x=0,_=1,w=1):p<b?(M=0,g=1,y=0,x=0,_=1,w=1):(M=0,g=1,y=0,x=1,_=1,w=0);let A=p-M+ut,C=d-g+ut,E=b-y+ut,k=p-x+2*ut,B=d-_+2*ut,T=b-w+2*ut,N=p-1+3*ut,F=d-1+3*ut,S=b-1+3*ut,D=c&255,O=m&255,j=u&255,R=l[D+h[O+h[j]]]*3,Q=l[D+M+h[O+g+h[j+y]]]*3,L=l[D+x+h[O+_+h[j+w]]]*3,I=l[D+1+h[O+1+h[j+1]]]*3,V=0,H=.6-p*p-d*d-b*b;H>=0&&(H*=H,V=H*H*ie(R,p,d,b));let W=0,G=.6-A*A-C*C-E*E;G>=0&&(G*=G,W=G*G*ie(Q,A,C,E));let J=0,K=.6-k*k-B*B-T*T;K>=0&&(K*=K,J=K*K*ie(L,k,B,T));let ht=0,et=.6-N*N-F*F-S*S;return et>=0&&(et*=et,ht=et*et*ie(I,N,F,S)),32*(V+W+J+ht)}noise4d(t,e,i,r){let a=Number(t),n=Number(e),h=Number(i),l=Number(r);if(!Number.isFinite(a)||!Number.isFinite(n)||!Number.isFinite(h)||!Number.isFinite(l))return 0;let o=this.perm,c=(a+n+h+l)*Gi,m=Math.floor(a+c),u=Math.floor(n+c),f=Math.floor(h+c),p=Math.floor(l+c),d=(m+u+f+p)*$,b=a-(m-d),M=n-(u-d),g=h-(f-d),y=l-(p-d),x=(b>M?1:0)+(b>g?1:0)+(b>y?1:0),_=(b<=M?1:0)+(M>g?1:0)+(M>y?1:0),w=(b<=g?1:0)+(M<=g?1:0)+(g>y?1:0),A=(b<=y?1:0)+(M<=y?1:0)+(g<=y?1:0),C=x>=3?1:0,E=_>=3?1:0,k=w>=3?1:0,B=A>=3?1:0,T=x>=2?1:0,N=_>=2?1:0,F=w>=2?1:0,S=A>=2?1:0,D=x>=1?1:0,O=_>=1?1:0,j=w>=1?1:0,R=A>=1?1:0,Q=b-C+$,L=M-E+$,I=g-k+$,V=y-B+$,H=b-T+2*$,W=M-N+2*$,G=g-F+2*$,J=y-S+2*$,K=b-D+3*$,ht=M-O+3*$,et=g-j+3*$,yt=y-R+3*$,Ft=b-1+4*$,Nt=M-1+4*$,Qt=g-1+4*$,Ht=y-1+4*$,dt=m&255,bt=u&255,it=f&255,st=p&255,ms=(o[dt+o[bt+o[it+o[st]]]]&31)*4,cs=(o[dt+C+o[bt+E+o[it+k+o[st+B]]]]&31)*4,fs=(o[dt+T+o[bt+N+o[it+F+o[st+S]]]]&31)*4,ps=(o[dt+D+o[bt+O+o[it+j+o[st+R]]]]&31)*4,ys=(o[dt+1+o[bt+1+o[it+1+o[st+1]]]]&31)*4,bi=0,qt=.6-b*b-M*M-g*g-y*y;qt>=0&&(qt*=qt,bi=qt*qt*Lt(ms,b,M,g,y));let gi=0,Gt=.6-Q*Q-L*L-I*I-V*V;Gt>=0&&(Gt*=Gt,gi=Gt*Gt*Lt(cs,Q,L,I,V));let Mi=0,Vt=.6-H*H-W*W-G*G-J*J;Vt>=0&&(Vt*=Vt,Mi=Vt*Vt*Lt(fs,H,W,G,J));let xi=0,Wt=.6-K*K-ht*ht-et*et-yt*yt;Wt>=0&&(Wt*=Wt,xi=Wt*Wt*Lt(ps,K,ht,et,yt));let _i=0,$t=.6-Ft*Ft-Nt*Nt-Qt*Qt-Ht*Ht;return $t>=0&&($t*=$t,_i=$t*$t*Lt(ys,Ft,Nt,Qt,Ht)),27*(bi+gi+Mi+xi+_i)}noise2D(t,e){return this.noise(t,e)}noise3D(t,e,i){return this.noise3d(t,e,i)}noise4D(t,e,i,r){return this.noise4d(t,e,i,r)}}Object.freeze(Xe.prototype);let ve=s=>{if(!s||typeof s!="object")return null;let t=s,e=t.image,i=te(e??t);if(i&&e?._vc)return{buf:i.data,w:i.width,h:i.height,ch:4,isFloat:!1,flipY:!!t.flipY};let r=e?.data,a=Number(e?.width??t.width)|0,n=Number(e?.height??t.height)|0;if(!r||!(a>0&&n>0)||!r.length)return null;let h=a*n,l=t.format,o=l===1021||l===1024||l===1028||r.length===h?1:l===1025||l===1030||r.length===h*2?2:l===1022||r.length===h*3?3:4;return{buf:r,w:a,h:n,ch:o,isFloat:t.type===1015||t.type===1016||r instanceof Float32Array||r instanceof Float64Array,flipY:!!t.flipY}},we=(s,t,e,i)=>{let r=Math.min(s.w-1,Math.max(0,t*s.w|0)),a=Math.min(s.h-1,Math.max(0,e*s.h|0)),n=s.flipY?s.h-1-a:a,h=Number(s.buf[(n*s.w+r)*s.ch+Math.min(i,s.ch-1)]??0);if(!Number.isFinite(h))return 0;let l=s.isFloat&&h<=1?h*255:h;return l>0?l<255?l+.5|0:255:0},Ae=z.MeshStandardMaterial?.prototype&&(Object.getPrototypeOf(z.MeshStandardMaterial.prototype)||z.MeshStandardMaterial.prototype);Ae&&typeof Ae._packPbr!="function"&&(Ae._packPbr=function(){let s;if((this.roughnessMap||this.metalnessMap)&&this.roughnessMap!==this.metalnessMap){let i=ve(this.roughnessMap),r=ve(this.metalnessMap);if(i||r){let a=Math.min(128,Math.max(i?.w??1,r?.w??1)),n=Math.min(128,Math.max(i?.h??1,r?.h??1)),h=new Uint8ClampedArray(a*n*4);for(let l=0;l<n;l++){let o=(l+.5)/n;for(let c=0;c<a;c++){let m=(c+.5)/a,u=(l*a+c)*4;h[u]=255,h[u+1]=i?we(i,m,o,1):255,h[u+2]=r?we(r,m,o,2):255,h[u+3]=255}}s=kt(h,a,n,!1,!0,128).uri}}let t,e;if(!this.normalMap&&this.bumpMap){let i=ve(this.bumpMap);if(i){let r=Number.isFinite(this.bumpScale)?this.bumpScale:1,a=Math.min(128,i.w),n=Math.min(128,i.h),h=new Uint8ClampedArray(a*n*4),l=(o,c)=>we(i,((o%a+a)%a+.5)/a,((c%n+n)%n+.5)/n,0)/255;for(let o=0;o<n;o++)for(let c=0;c<a;c++){let m=(l(c+1,o)-l(c-1,o))*r*2,u=(l(c,o+1)-l(c,o-1))*r*2,f=1/Math.hypot(m,u,1),p=(o*a+c)*4;h[p]=(-m*f*.5+.5)*255+.5|0,h[p+1]=(u*f*.5+.5)*255+.5|0,h[p+2]=(f*.5+.5)*255+.5|0,h[p+3]=255}t=kt(h,a,n,!1,!0,128).uri,e=1}}return{mrUri:s,normUri:t,normScale:e}});let Ke=0,tt=z.Vector2,Ze=z.PlaneGeometry,ti=z.Mesh,ei=z.Material;class It extends ei{constructor(t={}){super({roughness:.85,metalness:0,side:2,transparent:t.transparent??!0,...t}),this.isSpriteMaterial=!0;let e=Number(t.rotation);this.rotation=Number.isFinite(e)?e:0,this.sizeAttenuation=t.sizeAttenuation!==!1,t.emissive===void 0&&(this.emissive=this.color.clone(),this.emissiveIntensity=.35,this.map&&!this.emissiveMap&&(this.emissiveMap=this.map))}clone(){return new It({...this,emissive:this._em?this.emissive:void 0})}}class se extends ti{constructor(t){super(new Ze(1,1),t instanceof ei?t:new It(t||{})),this.isSprite=!0,this.center=new tt(.5,.5),this.userData={xr:{billboard:"spherical"}}}_cloneCustom(){let t=new se(this.material);return t.center.copy(this.center),t._autoNamed=!!this._autoNamed,t._noBillboard=!!this._noBillboard,t}_bakeAuthorGeometry(){this._bakedOwner!==this?((!this.name||this._autoNamed)&&(this.name=`Sprite_${++Ke}`,this._autoNamed=!0),this._bakedOwner=this):this.name||(this.name=`Sprite_${++Ke}`,this._autoNamed=!0);let t=this.userData?.xr?.billboard;t===!1||t===null?(this._noBillboard=!0,delete this.userData.xr.billboard,Object.keys(this.userData.xr).length===0&&delete this.userData.xr):((typeof t=="string"||t===!0)&&(this._noBillboard=!1),this._noBillboard||(!this.userData||typeof this.userData!="object"?this.userData={xr:{billboard:"spherical"}}:!this.userData.xr||typeof this.userData.xr!="object"?this.userData.xr={billboard:"spherical"}:this.userData.xr.billboard===void 0&&(this.userData.xr.billboard="spherical")));let e=Number.isFinite(this.center?.x)?this.center.x:.5,i=Number.isFinite(this.center?.y)?this.center.y:.5,r=Number(this.material?.rotation),a=Number.isFinite(r)?r:0,n=`${e},${i},${a}`;if(this._bakedKey!==n&&(this._bakedKey!==void 0||e!==.5||i!==.5||a!==0)){let h=new Ze(1,1),l=h.attributes.position?.array,o=.5-e,c=.5-i,m=Math.cos(a),u=Math.sin(a);if(l){for(let f=0;f<l.length;f+=3){let p=l[f]+o,d=l[f+1]+c;l[f]=p*m-d*u,l[f+1]=p*u+d*m}h.boundingBox=null,h.boundingSphere=null}h.__baked=!0,this._bakedKey=n,this.geometry=h}}}if(Object.freeze(It.prototype),Object.freeze(se.prototype),tt?.prototype){let s=tt.prototype,t=(e,i)=>{typeof s[e]!="function"&&(s[e]=i)};t("length",function(){return Math.hypot(this.x,this.y)}),t("normalize",function(){return this.divideScalar(Math.hypot(this.x,this.y)||1)}),t("distanceTo",function(e){return Math.hypot(this.x-(e?.x||0),this.y-(e?.y||0))}),t("dot",function(e){return this.x*(e?.x||0)+this.y*(e?.y||0)}),t("lerp",function(e,i){let r=Number(i)||0;return this.set(this.x+((e?.x||0)-this.x)*r,this.y+((e?.y||0)-this.y)*r)}),t("lerpVectors",function(e,i,r){let a=Number(r)||0,n=e?.x||0,h=e?.y||0;return this.set(n+((i?.x||0)-n)*a,h+((i?.y||0)-h)*a)}),t("equals",function(e){return!!e&&e.x===this.x&&e.y===this.y})}let v=(s,t=0)=>{let e=Number(s);return Number.isFinite(e)?e:t},at=s=>Math.max(0,Math.min(1,v(s,0))),ot=s=>new tt(v(s?.x),v(s?.y));class wt{constructor(t="Curve"){this.type=t,this.arcLengthDivisions=200,this._lenCache=null}getPoint(t,e=new tt){return e.set(0,0)}getPointAt(t,e){return this.getPoint(this.getUtoTMapping(t),e)}getPoints(t=5){let e=Math.max(1,Math.min(1024,Math.floor(v(t,5)))),i=[];for(let r=0;r<=e;r++)i.push(this.getPoint(r/e));return i}getSpacedPoints(t=5){let e=Math.max(1,Math.min(1024,Math.floor(v(t,5)))),i=[];for(let r=0;r<=e;r++)i.push(this.getPointAt(r/e));return i}getLength(){let t=this.getLengths();return t[t.length-1]||0}getLengths(t=this.arcLengthDivisions){let e=Math.max(1,Math.min(2048,Math.floor(v(t,200))));if(this._lenCache&&this._lenCache.length===e+1)return this._lenCache;let i=[0],r=0,a=this.getPoint(0);for(let n=1;n<=e;n++){let h=this.getPoint(n/e);r+=Math.hypot(v(h.x)-v(a.x),v(h.y)-v(a.y),v(h.z)-v(a.z)),i.push(r),a=h}return e===this.arcLengthDivisions&&(this._lenCache=i),i}updateArcLengths(){this._lenCache=null,this.getLengths()}getUtoTMapping(t,e){let i=this.getLengths(),r=i.length,a=i[r-1]||0;if(a<=0||r<2)return at(t);let n=e!==void 0&&Number.isFinite(Number(e))?Math.max(0,Math.min(a,Number(e))):at(t)*a,h=0,l=r-1;for(;h<=l;){let u=h+l>>1,f=i[u]-n;if(f<0)h=u+1;else if(f>0)l=u-1;else return u/(r-1)}let o=Math.max(0,h-1),c=i[o],m=(i[o+1]??a)-c;return(o+(m>1e-12?(n-c)/m:0))/(r-1)}getTangent(t,e){let i=at(t),r=this.getPoint(Math.max(0,i-1e-4)),a=this.getPoint(Math.min(1,i+1e-4)),n=v(a.x)-v(r.x),h=v(a.y)-v(r.y);if("z"in r||e?.isVector3){let o=v(a.z)-v(r.z),c=Math.hypot(n,h,o)||1;return(e||new P).set(n/c,h/c,o/c)}let l=Math.hypot(n,h)||1;return(e||new tt).set(n/l,h/l)}getTangentAt(t,e){return this.getTangent(this.getUtoTMapping(t),e)}clone(){return new this.constructor().copy(this)}copy(t){if(!t||typeof t!="object")return this;let e=t,i=this;for(let r of Object.keys(e)){if(r==="type"||r.startsWith("is"))continue;if(r.startsWith("_")){i[r]=null;continue}let a=e[r];Array.isArray(a)?i[r]=a.map(n=>n?.clone?n.clone():n&&typeof n=="object"&&"x"in n?ot(n):n):a?.clone?i[r]=a.clone():a&&typeof a=="object"&&"x"in a?i[r]=ot(a):i[r]=a}return this}}class Ne extends wt{constructor(t,e){super("LineCurve"),this.isLineCurve=!0,this.v1=ot(t),this.v2=ot(e)}getPoint(t,e=new tt){let i=v(t,0),r=v(this.v1.x),a=v(this.v1.y);return i===1?e.set(v(this.v2.x),v(this.v2.y)):e.set(r+(v(this.v2.x)-r)*i,a+(v(this.v2.y)-a)*i)}getPointAt(t,e=new tt){return this.getPoint(at(t),e)}}class ii extends wt{constructor(t,e,i){super("QuadraticBezierCurve"),this.isQuadraticBezierCurve=!0,this.v0=ot(t),this.v1=ot(e),this.v2=ot(i)}getPoint(t,e=new tt){let i=at(t),r=1-i;return e.set(r*r*v(this.v0.x)+2*r*i*v(this.v1.x)+i*i*v(this.v2.x),r*r*v(this.v0.y)+2*r*i*v(this.v1.y)+i*i*v(this.v2.y))}}class si extends wt{constructor(t,e,i,r){super("CubicBezierCurve"),this.isCubicBezierCurve=!0,this.v0=ot(t),this.v1=ot(e),this.v2=ot(i),this.v3=ot(r)}getPoint(t,e=new tt){let i=at(t),r=1-i,a=r*r,n=i*i;return e.set(a*r*v(this.v0.x)+3*a*i*v(this.v1.x)+3*r*n*v(this.v2.x)+n*i*v(this.v3.x),a*r*v(this.v0.y)+3*a*i*v(this.v1.y)+3*r*n*v(this.v2.y)+n*i*v(this.v3.y))}}class ri extends wt{constructor(t=[]){super("SplineCurve"),this.isSplineCurve=!0,this.points=Array.isArray(t)?t:[]}getPoint(t,e=new tt){let i=this.points,r=Array.isArray(i)?i.length:0;if(r===0)return e.set(0,0);if(r===1)return e.set(v(i[0]?.x),v(i[0]?.y));let a=(r-1)*at(t),n=Math.floor(a),h=a-n;n>=r-1&&(n=r-2,h=1);let l=i[n===0?0:n-1],o=i[n],c=i[n+1],m=i[n>r-3?r-1:n+2],u=h*h,f=u*h,p=(d,b,M,g)=>.5*(2*b+(M-d)*h+(2*d-5*b+4*M-g)*u+(3*b-d-3*M+g)*f);return e.set(p(v(l?.x),v(o?.x),v(c?.x),v(m?.x)),p(v(l?.y),v(o?.y),v(c?.y),v(m?.y)))}}class Ce extends wt{constructor(t=0,e=0,i=1,r=1,a=0,n=Math.PI*2,h=!1,l=0){super("EllipseCurve"),this.isEllipseCurve=!0,this.aX=v(t,0),this.aY=v(e,0),this.xRadius=v(i,1),this.yRadius=v(r,1),this.aStartAngle=v(a,0),this.aEndAngle=v(n,Math.PI*2),this.aClockwise=!!h,this.aRotation=v(l,0)}getPoint(t,e=new tt){let i=Math.PI*2,r=v(this.aStartAngle,0),a=v(this.aEndAngle,i)-r;Math.abs(a)>=1e-9?(a=(a%i+i)%i,a<1e-9&&(a=i),this.aClockwise&&(a=a===i?-i:a-i)):a=0;let n=r+at(t)*a,h=v(this.xRadius,1)*Math.cos(n),l=v(this.yRadius,1)*Math.sin(n),o=v(this.aRotation,0),c=Math.cos(o),m=Math.sin(o);return e.set(this.aX+h*c-l*m,this.aY+h*m+l*c)}}class ai extends Ce{constructor(t=0,e=0,i=1,r=0,a=Math.PI*2,n=!1){super(t,e,i,i,r,a,n,0),this.type="ArcCurve",this.isArcCurve=!0}}class ni extends wt{constructor(){super("CurvePath"),this.isCurvePath=!0,this.curves=[],this.autoClose=!1,this._curveLens=null}add(t){return t&&typeof t.getPoint=="function"&&(this.curves.push(t),this._curveLens=null,this._lenCache=null),this}closePath(){if(this.curves.length===0)return this;let t=this.curves[0].getPoint(0),e=this.curves[this.curves.length-1].getPoint(1),i=!!(t&&("z"in t||t.isVector3));if(Math.hypot(v(t?.x)-v(e?.x),v(t?.y)-v(e?.y),i?v(t?.z)-v(e?.z):0)>1e-6){let r=z.LineCurve3;this.add(i&&r?new r(e,t):new Ne(e,t))}return this}getCurveLengths(){if(this._curveLens&&this._curveLens.length===this.curves.length)return this._curveLens;let t=[],e=0;for(let i of this.curves){let r=0;if(typeof i?.getLength=="function")r=v(i.getLength(),0);else if(typeof i?.getPoints=="function"){let a=i.getPoints(32);for(let n=1;n<a.length;n++)r+=Math.hypot(v(a[n]?.x)-v(a[n-1]?.x),v(a[n]?.y)-v(a[n-1]?.y),v(a[n]?.z)-v(a[n-1]?.z))}e+=r,t.push(e)}return this._curveLens=t,t}getLength(){let t=this.getCurveLengths();return t[t.length-1]||0}updateArcLengths(){this._curveLens=null,this._lenCache=null;for(let t of this.curves)t?.updateArcLengths?.();this.getCurveLengths()}getPoint(t,e){if(this.curves.length===0)return(e||new tt).set(0,0);let i=this.getCurveLengths(),r=i[i.length-1]||0;if(r<=1e-12)return this.curves[0].getPoint(0,e);let a=at(t)*r;for(let n=0;n<i.length;n++)if(a<=i[n]||n===i.length-1){let h=n>0?i[n-1]:0,l=i[n]-h,o=l>1e-12?(a-h)/l:0,c=this.curves[n];return typeof c.getPointAt=="function"?c.getPointAt(o,e):c.getPoint(o,e)}return this.curves[this.curves.length-1].getPoint(1,e)}getPoints(t=12){let e=Math.max(1,Math.min(1024,Math.floor(v(t,12)))),i=[],r=null;for(let a of this.curves){let n=a?.isEllipseCurve?e*2:a?.isLineCurve||a instanceof(z.LineCurve3||Function)?1:a?.isSplineCurve&&Array.isArray(a.points)?e*Math.max(1,a.points.length):e;for(let h of a.getPoints(Math.min(1024,n)))r&&Math.hypot(v(r.x)-v(h.x),v(r.y)-v(h.y),v(r.z)-v(h.z))<1e-6||(i.push(h),r=h)}if(this.autoClose&&i.length>1){let a=i[0];Math.hypot(v(r.x)-v(a.x),v(r.y)-v(a.y),v(r.z)-v(a.z))>1e-6&&i.push(a.clone?a.clone():a)}return i}getSpacedPoints(t=40){let e=Math.max(1,Math.min(1024,Math.floor(v(t,40)))),i=[];for(let r=0;r<=e;r++)i.push(this.getPoint(r/e));return this.autoClose&&i.length>0&&i.push(i[0].clone?i[0].clone():i[0]),i}}let hi=z.BufferAttribute,Wi=z.Object3D,$i=z.Line,At=z.LineSegments,_t=z.LineBasicMaterial,Yi=z.MeshBasicMaterial,Ji=z.ConeGeometry,re=z.Color,Dt=(s,t,e,i)=>{s.name=t.name,s.position.copy(t.position),s.quaternion.copy(t.quaternion),s.scale.copy(t.scale),s.visible=t.visible,s.castShadow=t.castShadow,s.receiveShadow=t.receiveShadow;try{s.userData=JSON.parse(JSON.stringify(t.userData||{}))}catch{s.userData={...t.userData||{}}}if(i&&Array.isArray(t.children))for(let r=e;r<t.children.length;r++)s.add(t.children[r].clone(!0));return s},zt=s=>{let t=new X;return t.setAttribute("position",new hi(new Float32Array(s),3)),t.__isSegmentPairs=!0,t},Xi=[0,1,1,3,3,2,2,0,4,5,5,7,7,6,6,4,0,4,1,5,3,7,2,6],ze=(s,t,e,i,r,a)=>{if(!Number.isFinite(s+t+e+i+r+a)||i<s||r<t||a<e)return new X;let n=[];for(let h of Xi)n.push(h&1?i:s,h&2?r:t,h&4?a:e);return zt(n)};class ae extends At{constructor(t=10,e=10,i=4473924,r=8947848){let a=Math.max(1e-4,Math.abs(v(t,10))),n=Math.max(1,Math.min(256,Math.floor(v(e,10)))),h=new re(i??4473924),l=new re(r??8947848),o=a*.5,c=a/n,m=n%2===0&&h.getHex()!==l.getHex()?n>>1:-1,u=[],f=[];for(let p=0,d=-o;p<=n;p++,d+=c)(p===m?f:u).push(-o,0,d,o,0,d,d,0,-o,d,0,o);if(super(zt(u.length?u:f),new _t({color:u.length?l:h})),this.type="GridHelper",this.isGridHelper=!0,this._size=a,this._divisions=n,this._internalKids=0,f.length&&u.length){let p=new At(zt(f),new _t({color:h}));this._centerLines=p,this._internalKids=1,this.add(p)}}_bakeAuthorGeometry(){this._centerLines?.material&&this.material&&(this._centerLines.material.transparent=this.material.transparent,this._centerLines.material.opacity=this.material.opacity),super._bakeAuthorGeometry()}clone(t=!0){let e=new ae(this._size,this._divisions,this._centerLines?this._centerLines.material.color:this.material.color,this.material.color);return e.material.transparent=this.material.transparent,e.material.opacity=this.material.opacity,Dt(e,this,this._internalKids,t)}dispose(){}}class ne extends At{constructor(t=1){let e=Math.max(1e-4,Math.abs(v(t,1)));super(zt([0,0,0,e,0,0]),new _t({color:16724736})),this.type="AxesHelper",this.isAxesHelper=!0,this._size=e,this._yAxis=new At(zt([0,0,0,0,e,0]),new _t({color:3407616})),this._zAxis=new At(zt([0,0,0,0,0,e]),new _t({color:35071})),this.add(this._yAxis),this.add(this._zAxis)}setColors(t,e,i){return this.material.color.set(t),this._yAxis.material.color.set(e),this._zAxis.material.color.set(i),this}_bakeAuthorGeometry(){for(let t of[this._yAxis,this._zAxis])t?.material&&this.material&&(t.material.transparent=this.material.transparent,t.material.opacity=this.material.opacity);super._bakeAuthorGeometry()}clone(t=!0){let e=new ne(this._size).setColors(this.material.color,this._yAxis.material.color,this._zAxis.material.color);return e.material.transparent=this.material.transparent,e.material.opacity=this.material.opacity,Dt(e,this,2,t)}dispose(){}}class he extends Wi{constructor(t=new P(0,0,1),e=new P(0,0,0),i=1,r=16776960,a,n){super(),this.type="ArrowHelper",this.isArrowHelper=!0,this.position.set(v(e?.x),v(e?.y),v(e?.z));let h=new X;h.setAttribute("position",new hi(new Float32Array([0,0,0,0,1,0]),3)),this.line=new $i(h,new _t({color:r})),this.cone=new ti(new Ji(.5,1,8).translate(0,-.5,0),new Yi({color:r})),this.add(this.line),this.add(this.cone),this.setDirection(t).setLength(i,a,n)}setDirection(t){let e=v(t?.x,0),i=v(t?.y,0),r=v(t?.z,1),a=Math.hypot(e,i,r),n=a>1e-9?e/a:0,h=a>1e-9?i/a:1,l=a>1e-9?r/a:0;return h>.99999?this.quaternion.set(0,0,0,1):h<-.99999?this.quaternion.set(1,0,0,0):this.quaternion.setFromAxisAngle(new P(l,0,-n).normalize(),Math.acos(Math.max(-1,Math.min(1,h)))),this}setLength(t,e,i){let r=Math.max(1e-4,Math.abs(v(t,1))),a=e!==void 0&&Number.isFinite(Number(e))?Math.max(1e-4,Math.abs(Number(e))):.2*r,n=i!==void 0&&Number.isFinite(Number(i))?Math.max(1e-4,Math.abs(Number(i))):.2*a;return this.line.scale.set(1,Math.max(1e-4,r-a),1),this.line.updateMatrix?.(),this.cone.scale.set(n,a,n),this.cone.position.set(0,r,0),this.cone.updateMatrix?.(),this}setColor(t){return this.line.material.color.set(t),this.cone.material.color.set(t),this}clone(t=!0){let e=new he;return e.line.scale.copy(this.line.scale),e.cone.scale.copy(this.cone.scale),e.cone.position.copy(this.cone.position),e.setColor(this.cone.material.color),e.line.material.transparent=this.line.material.transparent,e.line.material.opacity=this.line.material.opacity,e.cone.material.transparent=this.cone.material.transparent,e.cone.material.opacity=this.cone.material.opacity,Dt(e,this,2,t)}dispose(){}}class le extends At{constructor(t=new Z,e=16776960){let i=t instanceof Z?t:new Z(t?.min,t?.max);super(i.isEmpty()?new X:ze(i.min.x,i.min.y,i.min.z,i.max.x,i.max.y,i.max.z),new _t({color:e})),this.type="Box3Helper",this.isBox3Helper=!0,this.box=i}_bakeAuthorGeometry(){let t=this.box,e=!t||t.isEmpty()?new X:ze(t.min.x,t.min.y,t.min.z,t.max.x,t.max.y,t.max.z);this._sourceGeo=e,this.geometry=e,super._bakeAuthorGeometry()}clone(t=!0){let e=new le(this.box.clone(),this.material.color);return e.material.transparent=this.material.transparent,e.material.opacity=this.material.opacity,Dt(e,this,0,t)}dispose(){}}class oe extends At{constructor(t,e=16776960){super(new X,new _t({color:e})),this.type="BoxHelper",this.isBoxHelper=!0,this.object=t,t&&this.update()}update(t){t!==void 0&&(this.object=t);let e=new Z;this.object&&this.object!==this&&e.setFromObject(this.object);let i=e.isEmpty()?new X:ze(e.min.x,e.min.y,e.min.z,e.max.x,e.max.y,e.max.z);return this.position.set(0,0,0),this.quaternion.set(0,0,0,1),this.scale.set(1,1,1),this._sourceGeo=i,this.geometry=i,this}setFromObject(t){return this.update(t)}_bakeAuthorGeometry(){this.update(),super._bakeAuthorGeometry()}clone(t=!0){let e=new oe(this.object,this.material.color);return e.material.transparent=this.material.transparent,e.material.opacity=this.material.opacity,Dt(e,this,0,t)}dispose(){}}for(let s of[wt,Ne,ii,si,ri,Ce,ai,ni,ae,ne,he,le,oe])Object.freeze(s.prototype);let Et=["checkerboard","grid","wood","marble","brushedMetal","carbonFiber","concrete","brick","fabric","leather","rust"],li=[[8,3359061,14870768,.6],[8,16317180,6583435,.7],[10,9132587,0,.6],[3,15857145,4674921,.25],[1,12106946,0,.32],[8,2040616,0,.35],[4,10265519,0,.9],[8,10107694,13157048,.85],[32,3890060,0,.9],[12,5913128,0,.6],[4,9124378,9080985,.9]],Ki=(s,t,e)=>{let i=Math.imul(s,668265261)^Math.imul(t,374761393)^Math.imul(e,2654435769);return i^=i>>>15,i=Math.imul(i,2246822507),i^=i>>>13,i=Math.imul(i,3266489909),i^=i>>>16,i>>>0},pt=(s,t,e)=>Ki(s,t,e)/4294967296,mt=(s,t)=>(s%t+t)%t,oi=(s,t,e,i,r)=>{let a=Math.floor(s),n=Math.floor(t),h=s-a,l=t-n,o=mt(a,e),c=mt(n,i),m=(o+1)%e,u=(c+1)%i,f=h*h*(3-2*h),p=l*l*(3-2*l),d=pt(o,c,r),b=pt(m,c,r),M=pt(o,u,r),g=pt(m,u,r);return d+(b-d)*f+(M-d)*p+(d-b-M+g)*f*p},ct=(s,t,e,i,r,a)=>{let n=0,h=.5,l=0,o=1;for(let c=0;c<r;c++){let m=e*o,u=i*o;n+=h*oi(s*m,t*u,m,u,a+c>>>0),l+=h,h*=.5,o*=2}return n/l},Ee=s=>s-Math.floor(s),Fe=s=>Math.abs(Ee(s)*2-1),Rt=(s,t,e)=>{let i=(e-s)/(t-s);return i<0?i=0:i>1&&(i=1),i*i*(3-2*i)},nt=(s,t,e)=>s+(t-s)*e,ft=s=>s<=0?0:s>=1?255:Math.floor(s*255+.5),Zi=(s,t,e,i,r,a,n,h,l,o,c)=>{let m=g=>[r[0]*g,r[1]*g,r[2]*g],u=(g,y,x)=>[nt(g[0],y[0],x),nt(g[1],y[1],x),nt(g[2],y[2],x)];if(s===0){let g=mt(Math.floor(h*e)+Math.floor(l*e),2)===1?a:r;return[g[0],g[1],g[2],.5,n,0]}if(s===1){let g=Ee(h*e),y=Ee(l*e),x=Math.max(.035,e/t),_=1-Rt(x*.5,x,Math.min(g,1-g,y,1-y));return[...u(r,a,_),.3+.4*_,n,0]}if(s===2){let g=ct(h,l,4,4,4,i),y=Fe(l*e+g*1.5),x=ct(h,l,2,96,2,i+7>>>0),_=y*.7+x*.3;return[...m(nt(.55,1,_)),_,n+(1-_)*.15,0]}if(s===3){let g=ct(h,l,3,3,5,i),y=Fe((h+l)*e+g*2.5),x=y*y,_=x*x,w=_*_,A=.92+.08*g,C=u(r,a,w*.85);return[C[0]*A,C[1]*A,C[2]*A,.5-w*.2,n+w*.1,0]}if(s===4){let g=ct(h,l,2,192*e,2,i),y=pt(o,c,i+3>>>0);return[...m(.85+.12*g+.03*y),.35+g*.3,n+(g-.5)*.12,1]}if(s===5){let g=e*2,y=h*g,x=l*g,_=y-Math.floor(y),w=x-Math.floor(x),A=mt(Math.floor(y)+Math.floor(x),2)===0,C=A?w*2-1:_*2-1,E=1-C*C,k=.08*Fe(A?w*8:_*8),B=.6+.4*E;return[r[0]*B+k,r[1]*B+k,r[2]*B+k,E*.8,n+.1*(1-E),0]}if(s===6){let g=ct(h,l,e,e,5,i),y=pt(o,c,i+31>>>0),x=e*16,_=Rt(.82,.9,oi(h*x,l*x,x,x,i+17>>>0));return[...m((.82+.25*g+.06*(y-.5))*(1-.35*_)),.5+.25*(g-.5)-.3*_,n-.05*g,0]}if(s===7){let g=Math.floor(e/2),y=l*e,x=Math.floor(y),_=y-x,w=h*g+(mt(x,2)===1?.5:0),A=Math.floor(w),C=w-A,E=Math.min(Math.min(C,1-C)*2,Math.min(_,1-_)),k=Math.max(.06,1.5*e/t),B=1-Rt(k*.5,k,E),T=pt(mt(A,g),mt(x,e),i),N=ct(h,l,e,e,3,i+5>>>0),F=.8+.25*T+.15*(N-.5),S=.9+.1*N;return[nt(r[0]*F,a[0]*S,B),nt(r[1]*F,a[1]*S,B),nt(r[2]*F,a[2]*S,B),(1-B)*(.75+.1*N)+B*.2,nt(n,.95,B),0]}if(s===8){let g=h*e,y=l*e,x=(g-Math.floor(g))*2-1,_=(y-Math.floor(y))*2-1,w=mt(Math.floor(g)+Math.floor(y),2)===0?1-x*x:1-_*_,A=ct(h,l,4,4,2,i);return[...m((.75+.25*w)*(.95+.1*(A-.5))),w,n,0]}if(s===9){let g=h*e,y=l*e,x=Math.floor(g),_=Math.floor(y),w=1e9,A=1e9;for(let k=-1;k<=1;k++)for(let B=-1;B<=1;B++){let T=x+B,N=_+k,F=mt(T,e),S=mt(N,e),D=T+pt(F,S,i)-g,O=N+pt(F,S,i+1>>>0)-y,j=D*D+O*O;j<w?(A=w,w=j):j<A&&(A=j)}let C=1-Rt(0,.12,Math.sqrt(A)-Math.sqrt(w)),E=ct(h,l,4,4,3,i+3>>>0);return[...m((.85+.2*(E-.5))*(1-.3*C)),.6-.4*C+.1*(E-.5),n+.15*C,0]}let f=ct(h,l,e,e,5,i),p=Rt(.45,.6,f),d=ct(h,l,e*8,e*8,3,i+9>>>0),b=.9+.1*d,M=.7+.5*d;return[nt(a[0]*b,r[0]*M,p),nt(a[1]*b,r[1]*M,p),nt(a[2]*b,r[2]*M,p),.4+.4*p*d+.1*p,nt(.35,n,p),1-p]},ts=(s,t,e,i,r,a,n,h)=>{let l=globalThis.__three_live_native_material_preset__;if(typeof l=="function"){let u=l(s,t,e,i,...r,...a,n,h);if(Array.isArray(u)&&u.length===3)return u}let o=new Uint8Array(t*t*4),c=new Uint8Array(t*t*4),m=new Float64Array(t*t);for(let u=0;u<t;u++){let f=(u+.5)/t;for(let p=0;p<t;p++){let d=Zi(s,t,e,i,r,a,n,(p+.5)/t,f,p,u),b=(u*t+p)*4;o[b]=ft(d[0]),o[b+1]=ft(d[1]),o[b+2]=ft(d[2]),o[b+3]=255,c[b]=255,c[b+1]=ft(d[4]),c[b+2]=ft(d[5]),c[b+3]=255,m[u*t+p]=d[3]}}return[o,ui(m,t,h),c]},ui=(s,t,e)=>{let i=new Uint8Array(t*t*4),r=e*t*.0625;for(let a=0;a<t;a++){let n=(a+t-1)%t,h=(a+1)%t;for(let l=0;l<t;l++){let o=-(s[a*t+(l+1)%t]-s[a*t+(l+t-1)%t])*r,c=(s[h*t+l]-s[n*t+l])*r,m=1/Math.sqrt(o*o+c*c+1),u=(a*t+l)*4;i[u]=ft(o*m*.5+.5),i[u+1]=ft(c*m*.5+.5),i[u+2]=ft(m*.5+.5),i[u+3]=255}}return i},mi=(s,t)=>{let e=t;try{s!=null&&(e=new re(s).getHex())}catch{}return[(e>>16&255)/255,(e>>8&255)/255,(e&255)/255]},ue=new Map,Be=(s,t={})=>{let e=Et.indexOf(s);if(e<0)throw new TypeError(`THREE.ProceduralTexture: unknown preset '${s}' (use ${Et.join(", ")})`);let i=t&&typeof t=="object"?t:{},r=li[e],a=Math.max(1,Math.min(256,Math.round(v(i.scale,r[0]))));(e===0||e===7||e===8)&&a%2===1&&a++;let n=Math.max(16,Math.min(512,Math.round(v(i.size,256)))),h=Math.round(Math.abs(v(i.seed,1)))>>>0,l=mi(i.color,r[1]),o=mi(i.color2,r[2]||r[1]),c=at(v(i.roughness,r[3])),m=Math.max(0,Math.min(8,v(i.normalStrength,1))),u=[e,n,a,h,...l,...o,c,m].join(","),f=ue.get(u);if(f)return{...f};let[p,d,b]=ts(e,n,a,h,l,o,c,m),M=(x,_)=>{let w=new Ut(n,n);w._data.set(x),w._ver++;let A=new Me(w);return A.flipY=!1,A.colorSpace=_,A.name=`${s}_${_==="srgb"?"albedo":x===d?"normal":"orm"}`,A},g=M(b,"srgb-linear"),y={map:M(p,"srgb")};return m>0&&(y.normalMap=M(d,"srgb-linear")),y.roughnessMap=g,y.metalnessMap=g,ue.size>=64&&ue.clear(),ue.set(u,y),{...y}},Pe={presets:Object.freeze(Et.slice()),create:(s,t)=>Be(String(s),t)};for(let s of Et)Pe[s]=t=>Be(s,t);Object.freeze(Pe);let es=500,is=s=>{if(typeof s!="string")return null;let t="",e=!1;for(let i=0;i<s.length;i++){let r=s.charCodeAt(i);if(r<=32||r===127){e=t.length>0;continue}e&&(t+=" ",e=!1),t+=s[i]}return t.length===0||t.length>es?null:t},ss=s=>{let t=typeof s=="number"?s:NaN;return Number.isFinite(t)?t<=384?256:t<=768?512:1024:512},ci=s=>s>512&&s%2===0?s/2:s,rs=(s,t)=>{let e=t/2,i=new Uint8Array(e*e*4);for(let r=0;r<e;r++)for(let a=0;a<e;a++){let n=(2*r*t+2*a)*4,h=n+t*4,l=(r*e+a)*4;for(let o=0;o<4;o++)i[l+o]=s[n+o]+s[n+4+o]+s[h+o]+s[h+4+o]+2>>2}return i},as=s=>{let t=typeof s=="number"?s:NaN,e=Number.isFinite(t)?Math.abs(t):1;return Math.floor(e+.5)%4294967296},ns=s=>{let t=[];for(let e=0;e<s.length;e++){let i=s.charCodeAt(e);if(i>=55296&&i<=56319&&e+1<s.length){let r=s.charCodeAt(e+1);r>=56320&&r<=57343?(i=65536+(i-55296<<10)+(r-56320),e++):i=65533}else i>=55296&&i<=57343&&(i=65533);i<128?t.push(i):i<2048?t.push(192|i>>6,128|i&63):i<65536?t.push(224|i>>12,128|i>>6&63,128|i&63):t.push(240|i>>18,128|i>>12&63,128|i>>6&63,128|i&63)}return t},hs=(s,t,e)=>{let i=ns(`three-live-texture1${s}${t}${e}`),r=3421674724,a=2216829733;for(let n of i){a=(a^n)>>>0;let h=a&65535,l=a>>>16,o=h*435,c=l*435+(o>>>16),m=(c&65535)<<16|o&65535,u=Math.floor(c/65536);r=Math.imul(r,435)+u+(a<<8>>>0)>>>0,a=m>>>0}return r.toString(16).padStart(8,"0")+a.toString(16).padStart(8,"0")},fi=s=>{let t=is(s?.prompt);if(t===null)return null;let e=ss(s?.size),i=as(s?.seed);return{prompt:t,size:e,seed:i,key:hs(t,e,i)}},ke=(s,t,e,i,r)=>{if(ci(t)!==t)return ke(rs(s,t),t/2,e,i,r);let a=new Float64Array(t*t);for(let y=0;y<t*t;y++){let x=y*4;a[y]=2126*s[x]+7152*s[x+1]+722*s[x+2]}let n=Math.min(4,Math.floor((t-1)/2)),h=new Float64Array(t*t);for(let y=0;y<t;y++)for(let x=0;x<t;x++){let _=0;for(let w=0;w<=2*n;w++)_+=a[y*t+(x+t+w-n)%t];h[y*t+x]=_}let l=(2*n+1)*(2*n+1),o=new Float64Array(t*t),c=1/0,m=-1/0;for(let y=0;y<t;y++)for(let x=0;x<t;x++){let _=0;for(let A=0;A<=2*n;A++)_+=h[(y+t+A-n)%t*t+x];let w=l*a[y*t+x]-_;o[y*t+x]=w,w<c&&(c=w),w>m&&(m=w)}let u=m-c,f=new Float64Array(t*t);for(let y=0;y<t*t;y++)f[y]=u===0?.5:(o[y]-c)/u;let p=Number.isFinite(e)?Math.max(0,Math.min(8,e)):1,d=ui(f,t,p),b=Number.isFinite(i)?Math.max(0,Math.min(1,i)):0,M=ft(Number.isFinite(r)?Math.max(0,Math.min(1,r)):0),g=new Uint8Array(t*t*4);for(let y=0;y<t*t;y++){let x=y*4;g[x]=255,g[x+1]=ft(b+.35*(.5-f[y])),g[x+2]=M,g[x+3]=255}return[d,g]},me=new Map,pi=new WeakMap,ls=0,os=(s,t)=>{let e=fi(s);if(!e)return null;let{prompt:i,size:r,seed:a,key:n}=e,h=at(v(s.roughness,t>=0?li[t][3]:.8)),l=at(v(s.metalness,0)),o=Math.max(0,Math.min(8,v(s.normalStrength,1))),c=globalThis,m=c.__three_live_native_texture_pack__,u=c.__three_live_texture_pack__,f=0;if(typeof m=="function"){let _=c.__three_live_native_texture_pack_token__;f=typeof _=="function"&&Number(_())||0}else u&&typeof u=="object"&&(f=pi.get(u)??0,f||pi.set(u,f=++ls));let p=[f,n,o,h,l].join(","),d=f?me.get(p):void 0;if(d)return{...d};let b=null;if(typeof m=="function"){let _=m(i,r,a,o,h,l);Array.isArray(_)&&_.length===3&&(b=_)}else{let _=u&&typeof u=="object"&&Object.prototype.hasOwnProperty.call(u,n)?u[n]:null;_&&_.size===r&&_.rgba instanceof Uint8Array&&_.rgba.length===r*r*4&&(b=[_.rgba,...ke(_.rgba,r,o,h,l)])}if(!b)return null;let M=(_,w,A,C)=>{let E=new Me({data:new Uint8ClampedArray(_.buffer,_.byteOffset,w*w*4),width:w,height:w});return E.flipY=!1,E.colorSpace=A,E.name=`ai_${n}_${C}`,E._pngDim=w,E},g=ci(r),y=M(b[2],g,"srgb-linear","orm"),x={map:M(b[0],r,"srgb","albedo")};return o>0&&(x.normalMap=M(b[1],g,"srgb-linear","normal")),x.roughnessMap=y,x.metalnessMap=y,f&&(me.size>=32&&me.clear(),me.set(p,x)),{...x}},yi=new Set,us=s=>{let t=s?.userData?.xr?.material,e=s?.material;if(t==null||!e||typeof e!="object"||Array.isArray(e))return;let i=typeof t=="string"?{preset:t}:typeof t=="object"?t:null,r=String(i?.preset??i?.type??""),a=Et.indexOf(r),n=!!i&&i.prompt!==void 0&&i.prompt!==null,h=n?os(i,a):null;if(!i||a<0&&!h){!(n&&r==="")&&!yi.has(r)&&(yi.add(r),console.warn(`[three-live] userData.xr.material: unknown preset '${r}' (use ${Et.join(", ")}).`));return}e._presetTint===void 0&&(e._presetTint=e.color?.getHex?.()??16777215);let l="";try{l=JSON.stringify([i,e._presetTint])}catch{l=r}if(e._presetKey===l)return;if(e._presetOwner&&e._presetOwner!==s){let m=Object.assign(Object.create(Object.getPrototypeOf(e)),e);m.color=new re(e._presetTint);for(let u of["_presetKey","_presetMaps","_presetOwner"])m[u]=void 0;for(let u of["map","normalMap","roughnessMap","metalnessMap"])e._presetMaps?.[u]&&m[u]===e._presetMaps[u]&&(m[u]=null);s.material=e=m}let o=h??Be(r,{...i,color:i.color??(e._presetTint===16777215?void 0:e._presetTint)}),c=e._presetMaps||{};for(let m of["map","normalMap","roughnessMap","metalnessMap"])(!e[m]||e[m]===c[m])&&(e[m]=o[m]??null,c[m]=o[m]??null);c.map===e.map&&e.color?.set?.(16777215),c.roughnessMap===e.roughnessMap&&(e.roughness=1),c.metalnessMap===e.metalnessMap&&(e.metalness=1),e._presetMaps=c,e._presetKey=l,e._presetOwner=s},di={Box3:Z,Sphere:Bt,CanvasTexture:Me,ImprovedNoise:Je,SimplexNoise:Xe,SpriteMaterial:It,Sprite:se,LineCurve:Ne,QuadraticBezierCurve:ii,CubicBezierCurve:si,SplineCurve:ri,EllipseCurve:Ce,ArcCurve:ai,CurvePath:ni,GridHelper:ae,AxesHelper:ne,ArrowHelper:he,Box3Helper:le,BoxHelper:oe,ProceduralTexture:Pe};return U&&typeof U=="object"&&(U.authorNamespace||(U.authorNamespace={}),Object.assign(U.authorNamespace,di),U.createCanvas=Qi,U._procMaterialize=us,U.canonicalTextureSpec=fi,U.deriveTextureMaps=ke,U.encodeRgbaPngDataUri=(s,t,e)=>kt(s,t,e,!1,!1,rt).uri,U.materializeDeclarativeGeometry=s=>{U._cadMaterialize?.(s),U._lodMaterialize?.(s),U._procMaterialize?.(s)}),di}var Se={name:"procedural",onRegister(){Ei(fe);let z=Jt(),U=z.threeNamespace??(typeof globalThis<"u"?globalThis.THREE:void 0);U&&fe(U,z)}};return Fi(Se),zi(Te)})();
|
|
@@ -52,6 +52,10 @@
|
|
|
52
52
|
var nonce = data.nonce;
|
|
53
53
|
var script = typeof data.script === 'string' ? data.script : null;
|
|
54
54
|
var scriptUrl = typeof data.scriptUrl === 'string' ? data.scriptUrl : null;
|
|
55
|
+
var texturePack =
|
|
56
|
+
data.texturePack && typeof data.texturePack === 'object'
|
|
57
|
+
? data.texturePack
|
|
58
|
+
: null;
|
|
55
59
|
var lockedDown = false;
|
|
56
60
|
function ensureLockedDown() {
|
|
57
61
|
if (lockedDown) return;
|
|
@@ -116,10 +120,16 @@
|
|
|
116
120
|
type: 'EXECUTE_URL',
|
|
117
121
|
nonce: nonce,
|
|
118
122
|
scriptUrl: scriptUrl,
|
|
123
|
+
texturePack: texturePack,
|
|
119
124
|
});
|
|
120
125
|
} else {
|
|
121
126
|
ensureLockedDown();
|
|
122
|
-
worker.postMessage({
|
|
127
|
+
worker.postMessage({
|
|
128
|
+
type: 'EXECUTE',
|
|
129
|
+
nonce: nonce,
|
|
130
|
+
script: script,
|
|
131
|
+
texturePack: texturePack,
|
|
132
|
+
});
|
|
123
133
|
}
|
|
124
134
|
return;
|
|
125
135
|
}
|