Files
minsungandClaude Opus 5 c67a803e4d feat(viewer2d): render DWG lineweight in screen pixels
Every line was drawn 1px regardless of its CAD lineweight. Two causes:
the dwg-wasm parseResult never carried the field (acadrust reads
EntityCommon::line_weight but it was dropped in serialization), and the
renderer merged all segments into one LineSegments whose
LineBasicMaterial.linewidth WebGL ignores.

Resolve ByLayer/ByBlock/Default per entity and bucket segments by
dash|lineweight. Weighted buckets get their own LineSegments2 +
LineMaterial with worldUnits:false, so width stays constant in pixels
while zooming - AutoCAD LWDISPLAY semantics - at 8 px/mm (0.25mm = 2px).
Anything at or below the 0.25mm default stays in the hairline batch so
drawings that never assigned a weight render exactly as before.

Fat batches are instanced, so layer masking compacts the instance buffer
and lowers instanceCount instead of rewriting an index; slotOf tracks
where each segment moved so the selection highlight still finds its
vertices. Per-entity color spans (meta.spans) let the highlight repaint
across the hairline batch and every bucket it touched. Buckets past
400k segments fall back to hairline to bound GPU/heap cost.

Display follows the drawing's LWDISPLAY and can be forced from the
toolbar; the property panel now shows the entity lineweight.

Verified headless at a fixed camera on the 65k-entity road drawing:
cyan road edge 2px -> 5px, layer hide/restore returns the exact baseline
pixel counts, and a 0.35mm LWPOLYLINE selects and highlights.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-04 17:25:11 +09:00

5976 lines
1018 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
var X0=Object.defineProperty;var Y0=(n,e,t)=>e in n?X0(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var Lt=(n,e,t)=>Y0(n,typeof e!="symbol"?e+"":e,t);(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))i(s);new MutationObserver(s=>{for(const r of s)if(r.type==="childList")for(const a of r.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&i(a)}).observe(document,{childList:!0,subtree:!0});function t(s){const r={};return s.integrity&&(r.integrity=s.integrity),s.referrerPolicy&&(r.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?r.credentials="include":s.crossOrigin==="anonymous"?r.credentials="omit":r.credentials="same-origin",r}function i(s){if(s.ep)return;s.ep=!0;const r=t(s);fetch(s.href,r)}})();/**
* @license
* Copyright 2010-2026 Three.js Authors
* SPDX-License-Identifier: MIT
*/const hu="185",Mi={ROTATE:0,DOLLY:1,PAN:2},Xi={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},K0=0,Ju=1,q0=2,lo=1,$0=2,Ur=3,Zi=0,_n=1,Yt=2,Ai=0,er=1,ju=2,Qu=3,eh=4,Z0=5,ls=100,J0=101,j0=102,Q0=103,em=104,tm=200,nm=201,im=202,sm=203,nc=204,ic=205,rm=206,am=207,om=208,lm=209,cm=210,um=211,hm=212,dm=213,fm=214,sc=0,rc=1,ac=2,sr=3,oc=4,lc=5,cc=6,uc=7,Tf=0,pm=1,mm=2,li=0,Cf=1,wf=2,Rf=3,Lf=4,Df=5,If=6,Pf=7,Of=300,ms=301,rr=302,jo=303,Qo=304,Wo=306,hc=1e3,Si=1001,dc=1002,zt=1003,gm=1004,pa=1005,Jt=1006,el=1007,Yi=1008,wn=1009,Uf=1010,Nf=1011,Yr=1012,du=1013,di=1014,Gn=1015,Ci=1016,fu=1017,pu=1018,Kr=1020,kf=35902,Ff=35899,Bf=1021,Hf=1022,Ln=1023,wi=1026,ds=1027,zf=1028,mu=1029,gs=1030,gu=1031,_u=1033,co=33776,uo=33777,ho=33778,fo=33779,fc=35840,pc=35841,mc=35842,gc=35843,_c=36196,xc=37492,yc=37496,vc=37488,Sc=37489,yo=37490,bc=37491,Mc=37808,Ac=37809,Ec=37810,Tc=37811,Cc=37812,wc=37813,Rc=37814,Lc=37815,Dc=37816,Ic=37817,Pc=37818,Oc=37819,Uc=37820,Nc=37821,kc=36492,Fc=36494,Bc=36495,Hc=36283,zc=36284,vo=36285,Vc=36286,_m=3200,th=0,xm=1,vi="",Sn="srgb",So="srgb-linear",bo="linear",xt="srgb",Cs=7680,nh=519,ym=512,vm=513,Sm=514,xu=515,bm=516,Mm=517,yu=518,Am=519,Gc=35044,tl=35048,Wc="300 es",ri=2e3,Mo=2001;function Em(n){for(let e=n.length-1;e>=0;--e)if(n[e]>=65535)return!0;return!1}function Ao(n){return document.createElementNS("http://www.w3.org/1999/xhtml",n)}function Tm(){const n=Ao("canvas");return n.style.display="block",n}const ih={};function Eo(...n){const e="THREE."+n.shift();console.log(e,...n)}function Vf(n){const e=n[0];if(typeof e=="string"&&e.startsWith("TSL:")){const t=n[1];t&&t.isStackTrace?n[0]+=" "+t.getLocation():n[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return n}function $e(...n){n=Vf(n);const e="THREE."+n.shift();{const t=n[0];t&&t.isStackTrace?console.warn(t.getError(e)):console.warn(e,...n)}}function ut(...n){n=Vf(n);const e="THREE."+n.shift();{const t=n[0];t&&t.isStackTrace?console.error(t.getError(e)):console.error(e,...n)}}function tr(...n){const e=n.join(" ");e in ih||(ih[e]=!0,$e(...n))}function Cm(n,e,t){return new Promise(function(i,s){function r(){switch(n.clientWaitSync(e,n.SYNC_FLUSH_COMMANDS_BIT,0)){case n.WAIT_FAILED:s();break;case n.TIMEOUT_EXPIRED:setTimeout(r,t);break;default:i()}}setTimeout(r,t)})}const wm={[sc]:rc,[ac]:cc,[oc]:uc,[sr]:lc,[rc]:sc,[cc]:ac,[uc]:oc,[lc]:sr};class es{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const i=this._listeners;i[e]===void 0&&(i[e]=[]),i[e].indexOf(t)===-1&&i[e].push(t)}hasEventListener(e,t){const i=this._listeners;return i===void 0?!1:i[e]!==void 0&&i[e].indexOf(t)!==-1}removeEventListener(e,t){const i=this._listeners;if(i===void 0)return;const s=i[e];if(s!==void 0){const r=s.indexOf(t);r!==-1&&s.splice(r,1)}}dispatchEvent(e){const t=this._listeners;if(t===void 0)return;const i=t[e.type];if(i!==void 0){e.target=this;const s=i.slice(0);for(let r=0,a=s.length;r<a;r++)s[r].call(this,e);e.target=null}}}const en=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];let sh=1234567;const Br=Math.PI/180,qr=180/Math.PI;function ci(){const n=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return(en[n&255]+en[n>>8&255]+en[n>>16&255]+en[n>>24&255]+"-"+en[e&255]+en[e>>8&255]+"-"+en[e>>16&15|64]+en[e>>24&255]+"-"+en[t&63|128]+en[t>>8&255]+"-"+en[t>>16&255]+en[t>>24&255]+en[i&255]+en[i>>8&255]+en[i>>16&255]+en[i>>24&255]).toLowerCase()}function Qe(n,e,t){return Math.max(e,Math.min(t,n))}function vu(n,e){return(n%e+e)%e}function Rm(n,e,t,i,s){return i+(n-e)*(s-i)/(t-e)}function Lm(n,e,t){return n!==e?(t-n)/(e-n):0}function Hr(n,e,t){return(1-t)*n+t*e}function Dm(n,e,t,i){return Hr(n,e,1-Math.exp(-t*i))}function Im(n,e=1){return e-Math.abs(vu(n,e*2)-e)}function Pm(n,e,t){return n<=e?0:n>=t?1:(n=(n-e)/(t-e),n*n*(3-2*n))}function Om(n,e,t){return n<=e?0:n>=t?1:(n=(n-e)/(t-e),n*n*n*(n*(n*6-15)+10))}function Um(n,e){return n+Math.floor(Math.random()*(e-n+1))}function Nm(n,e){return n+Math.random()*(e-n)}function km(n){return n*(.5-Math.random())}function Fm(n){n!==void 0&&(sh=n);let e=sh+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function Bm(n){return n*Br}function Hm(n){return n*qr}function zm(n){return(n&n-1)===0&&n!==0}function Vm(n){return Math.pow(2,Math.ceil(Math.log(n)/Math.LN2))}function Gm(n){return Math.pow(2,Math.floor(Math.log(n)/Math.LN2))}function Wm(n,e,t,i,s){const r=Math.cos,a=Math.sin,o=r(t/2),l=a(t/2),c=r((e+i)/2),u=a((e+i)/2),h=r((e-i)/2),d=a((e-i)/2),f=r((i-e)/2),p=a((i-e)/2);switch(s){case"XYX":n.set(o*u,l*h,l*d,o*c);break;case"YZY":n.set(l*d,o*u,l*h,o*c);break;case"ZXZ":n.set(l*h,l*d,o*u,o*c);break;case"XZX":n.set(o*u,l*p,l*f,o*c);break;case"YXY":n.set(l*f,o*u,l*p,o*c);break;case"ZYZ":n.set(l*p,l*f,o*u,o*c);break;default:$e("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+s)}}function Vn(n,e){switch(e.constructor){case Float32Array:return n;case Uint32Array:return n/4294967295;case Uint16Array:return n/65535;case Uint8Array:return n/255;case Int32Array:return Math.max(n/2147483647,-1);case Int16Array:return Math.max(n/32767,-1);case Int8Array:return Math.max(n/127,-1);default:throw new Error("THREE.MathUtils: Invalid component type.")}}function yt(n,e){switch(e.constructor){case Float32Array:return n;case Uint32Array:return Math.round(n*4294967295);case Uint16Array:return Math.round(n*65535);case Uint8Array:return Math.round(n*255);case Int32Array:return Math.round(n*2147483647);case Int16Array:return Math.round(n*32767);case Int8Array:return Math.round(n*127);default:throw new Error("THREE.MathUtils: Invalid component type.")}}const Gf={DEG2RAD:Br,RAD2DEG:qr,generateUUID:ci,clamp:Qe,euclideanModulo:vu,mapLinear:Rm,inverseLerp:Lm,lerp:Hr,damp:Dm,pingpong:Im,smoothstep:Pm,smootherstep:Om,randInt:Um,randFloat:Nm,randFloatSpread:km,seededRandom:Fm,degToRad:Bm,radToDeg:Hm,isPowerOfTwo:zm,ceilPowerOfTwo:Vm,floorPowerOfTwo:Gm,setQuaternionFromProperEuler:Wm,normalize:yt,denormalize:Vn},Xu=class Xu{constructor(e=0,t=0){this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("THREE.Vector2: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("THREE.Vector2: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,i=this.y,s=e.elements;return this.x=s[0]*t+s[3]*i+s[6],this.y=s[1]*t+s[4]*i+s[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Qe(this.x,e.x,t.x),this.y=Qe(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=Qe(this.x,e,t),this.y=Qe(this.y,e,t),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Qe(i,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const i=this.dot(e)/t;return Math.acos(Qe(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,i=this.y-e.y;return t*t+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const i=Math.cos(t),s=Math.sin(t),r=this.x-e.x,a=this.y-e.y;return this.x=r*i-a*s+e.x,this.y=r*s+a*i+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}};Xu.prototype.isVector2=!0;let Le=Xu;class Ji{constructor(e=0,t=0,i=0,s=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=i,this._w=s}static slerpFlat(e,t,i,s,r,a,o){let l=i[s+0],c=i[s+1],u=i[s+2],h=i[s+3],d=r[a+0],f=r[a+1],p=r[a+2],_=r[a+3];if(h!==_||l!==d||c!==f||u!==p){let m=l*d+c*f+u*p+h*_;m<0&&(d=-d,f=-f,p=-p,_=-_,m=-m);let g=1-o;if(m<.9995){const v=Math.acos(m),b=Math.sin(v);g=Math.sin(g*v)/b,o=Math.sin(o*v)/b,l=l*g+d*o,c=c*g+f*o,u=u*g+p*o,h=h*g+_*o}else{l=l*g+d*o,c=c*g+f*o,u=u*g+p*o,h=h*g+_*o;const v=1/Math.sqrt(l*l+c*c+u*u+h*h);l*=v,c*=v,u*=v,h*=v}}e[t]=l,e[t+1]=c,e[t+2]=u,e[t+3]=h}static multiplyQuaternionsFlat(e,t,i,s,r,a){const o=i[s],l=i[s+1],c=i[s+2],u=i[s+3],h=r[a],d=r[a+1],f=r[a+2],p=r[a+3];return e[t]=o*p+u*h+l*f-c*d,e[t+1]=l*p+u*d+c*h-o*f,e[t+2]=c*p+u*f+o*d-l*h,e[t+3]=u*p-o*h-l*d-c*f,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,i,s){return this._x=e,this._y=t,this._z=i,this._w=s,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){const i=e._x,s=e._y,r=e._z,a=e._order,o=Math.cos,l=Math.sin,c=o(i/2),u=o(s/2),h=o(r/2),d=l(i/2),f=l(s/2),p=l(r/2);switch(a){case"XYZ":this._x=d*u*h+c*f*p,this._y=c*f*h-d*u*p,this._z=c*u*p+d*f*h,this._w=c*u*h-d*f*p;break;case"YXZ":this._x=d*u*h+c*f*p,this._y=c*f*h-d*u*p,this._z=c*u*p-d*f*h,this._w=c*u*h+d*f*p;break;case"ZXY":this._x=d*u*h-c*f*p,this._y=c*f*h+d*u*p,this._z=c*u*p+d*f*h,this._w=c*u*h-d*f*p;break;case"ZYX":this._x=d*u*h-c*f*p,this._y=c*f*h+d*u*p,this._z=c*u*p-d*f*h,this._w=c*u*h+d*f*p;break;case"YZX":this._x=d*u*h+c*f*p,this._y=c*f*h+d*u*p,this._z=c*u*p-d*f*h,this._w=c*u*h-d*f*p;break;case"XZY":this._x=d*u*h-c*f*p,this._y=c*f*h-d*u*p,this._z=c*u*p+d*f*h,this._w=c*u*h+d*f*p;break;default:$e("Quaternion: .setFromEuler() encountered an unknown order: "+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const i=t/2,s=Math.sin(i);return this._x=e.x*s,this._y=e.y*s,this._z=e.z*s,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,i=t[0],s=t[4],r=t[8],a=t[1],o=t[5],l=t[9],c=t[2],u=t[6],h=t[10],d=i+o+h;if(d>0){const f=.5/Math.sqrt(d+1);this._w=.25/f,this._x=(u-l)*f,this._y=(r-c)*f,this._z=(a-s)*f}else if(i>o&&i>h){const f=2*Math.sqrt(1+i-o-h);this._w=(u-l)/f,this._x=.25*f,this._y=(s+a)/f,this._z=(r+c)/f}else if(o>h){const f=2*Math.sqrt(1+o-i-h);this._w=(r-c)/f,this._x=(s+a)/f,this._y=.25*f,this._z=(l+u)/f}else{const f=2*Math.sqrt(1+h-i-o);this._w=(a-s)/f,this._x=(r+c)/f,this._y=(l+u)/f,this._z=.25*f}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let i=e.dot(t)+1;return i<1e-8?(i=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=i):(this._x=0,this._y=-e.z,this._z=e.y,this._w=i)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=i),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Qe(this.dot(e),-1,1)))}rotateTowards(e,t){const i=this.angleTo(e);if(i===0)return this;const s=Math.min(1,t/i);return this.slerp(e,s),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const i=e._x,s=e._y,r=e._z,a=e._w,o=t._x,l=t._y,c=t._z,u=t._w;return this._x=i*u+a*o+s*c-r*l,this._y=s*u+a*l+r*o-i*c,this._z=r*u+a*c+i*l-s*o,this._w=a*u-i*o-s*l-r*c,this._onChangeCallback(),this}slerp(e,t){let i=e._x,s=e._y,r=e._z,a=e._w,o=this.dot(e);o<0&&(i=-i,s=-s,r=-r,a=-a,o=-o);let l=1-t;if(o<.9995){const c=Math.acos(o),u=Math.sin(c);l=Math.sin(l*c)/u,t=Math.sin(t*c)/u,this._x=this._x*l+i*t,this._y=this._y*l+s*t,this._z=this._z*l+r*t,this._w=this._w*l+a*t,this._onChangeCallback()}else this._x=this._x*l+i*t,this._y=this._y*l+s*t,this._z=this._z*l+r*t,this._w=this._w*l+a*t,this.normalize();return this}slerpQuaternions(e,t,i){return this.copy(e).slerp(t,i)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),i=Math.random(),s=Math.sqrt(1-i),r=Math.sqrt(i);return this.set(s*Math.sin(e),s*Math.cos(e),r*Math.sin(t),r*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}const Yu=class Yu{constructor(e=0,t=0,i=0){this.x=e,this.y=t,this.z=i}set(e,t,i){return i===void 0&&(i=this.z),this.x=e,this.y=t,this.z=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("THREE.Vector3: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("THREE.Vector3: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(rh.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(rh.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,i=this.y,s=this.z,r=e.elements;return this.x=r[0]*t+r[3]*i+r[6]*s,this.y=r[1]*t+r[4]*i+r[7]*s,this.z=r[2]*t+r[5]*i+r[8]*s,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,i=this.y,s=this.z,r=e.elements,a=1/(r[3]*t+r[7]*i+r[11]*s+r[15]);return this.x=(r[0]*t+r[4]*i+r[8]*s+r[12])*a,this.y=(r[1]*t+r[5]*i+r[9]*s+r[13])*a,this.z=(r[2]*t+r[6]*i+r[10]*s+r[14])*a,this}applyQuaternion(e){const t=this.x,i=this.y,s=this.z,r=e.x,a=e.y,o=e.z,l=e.w,c=2*(a*s-o*i),u=2*(o*t-r*s),h=2*(r*i-a*t);return this.x=t+l*c+a*h-o*u,this.y=i+l*u+o*c-r*h,this.z=s+l*h+r*u-a*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,i=this.y,s=this.z,r=e.elements;return this.x=r[0]*t+r[4]*i+r[8]*s,this.y=r[1]*t+r[5]*i+r[9]*s,this.z=r[2]*t+r[6]*i+r[10]*s,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Qe(this.x,e.x,t.x),this.y=Qe(this.y,e.y,t.y),this.z=Qe(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=Qe(this.x,e,t),this.y=Qe(this.y,e,t),this.z=Qe(this.z,e,t),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Qe(i,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const i=e.x,s=e.y,r=e.z,a=t.x,o=t.y,l=t.z;return this.x=s*l-r*o,this.y=r*a-i*l,this.z=i*o-s*a,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const i=e.dot(this)/t;return this.copy(e).multiplyScalar(i)}projectOnPlane(e){return nl.copy(this).projectOnVector(e),this.sub(nl)}reflect(e){return this.sub(nl.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const i=this.dot(e)/t;return Math.acos(Qe(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,i=this.y-e.y,s=this.z-e.z;return t*t+i*i+s*s}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,i){const s=Math.sin(t)*e;return this.x=s*Math.sin(i),this.y=Math.cos(t)*e,this.z=s*Math.cos(i),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,i){return this.x=e*Math.sin(t),this.y=i,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),i=this.setFromMatrixColumn(e,1).length(),s=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=i,this.z=s,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,t=Math.random()*2-1,i=Math.sqrt(1-t*t);return this.x=i*Math.cos(e),this.y=t,this.z=i*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}};Yu.prototype.isVector3=!0;let k=Yu;const nl=new k,rh=new Ji,Ku=class Ku{constructor(e,t,i,s,r,a,o,l,c){this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,i,s,r,a,o,l,c)}set(e,t,i,s,r,a,o,l,c){const u=this.elements;return u[0]=e,u[1]=s,u[2]=o,u[3]=t,u[4]=r,u[5]=l,u[6]=i,u[7]=a,u[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],this}extractBasis(e,t,i){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),i.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const i=e.elements,s=t.elements,r=this.elements,a=i[0],o=i[3],l=i[6],c=i[1],u=i[4],h=i[7],d=i[2],f=i[5],p=i[8],_=s[0],m=s[3],g=s[6],v=s[1],b=s[4],x=s[7],E=s[2],S=s[5],A=s[8];return r[0]=a*_+o*v+l*E,r[3]=a*m+o*b+l*S,r[6]=a*g+o*x+l*A,r[1]=c*_+u*v+h*E,r[4]=c*m+u*b+h*S,r[7]=c*g+u*x+h*A,r[2]=d*_+f*v+p*E,r[5]=d*m+f*b+p*S,r[8]=d*g+f*x+p*A,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],i=e[1],s=e[2],r=e[3],a=e[4],o=e[5],l=e[6],c=e[7],u=e[8];return t*a*u-t*o*c-i*r*u+i*o*l+s*r*c-s*a*l}invert(){const e=this.elements,t=e[0],i=e[1],s=e[2],r=e[3],a=e[4],o=e[5],l=e[6],c=e[7],u=e[8],h=u*a-o*c,d=o*l-u*r,f=c*r-a*l,p=t*h+i*d+s*f;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);const _=1/p;return e[0]=h*_,e[1]=(s*c-u*i)*_,e[2]=(o*i-s*a)*_,e[3]=d*_,e[4]=(u*t-s*l)*_,e[5]=(s*r-o*t)*_,e[6]=f*_,e[7]=(i*l-c*t)*_,e[8]=(a*t-i*r)*_,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,i,s,r,a,o){const l=Math.cos(r),c=Math.sin(r);return this.set(i*l,i*c,-i*(l*a+c*o)+a+e,-s*c,s*l,-s*(-c*a+l*o)+o+t,0,0,1),this}scale(e,t){return tr("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(il.makeScale(e,t)),this}rotate(e){return tr("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(il.makeRotation(-e)),this}translate(e,t){return tr("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(il.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,i,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,i=e.elements;for(let s=0;s<9;s++)if(t[s]!==i[s])return!1;return!0}fromArray(e,t=0){for(let i=0;i<9;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){const i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e}clone(){return new this.constructor().fromArray(this.elements)}};Ku.prototype.isMatrix3=!0;let et=Ku;const il=new et,ah=new et().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),oh=new et().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function Xm(){const n={enabled:!0,workingColorSpace:So,spaces:{},convert:function(s,r,a){return this.enabled===!1||r===a||!r||!a||(this.spaces[r].transfer===xt&&(s.r=Ei(s.r),s.g=Ei(s.g),s.b=Ei(s.b)),this.spaces[r].primaries!==this.spaces[a].primaries&&(s.applyMatrix3(this.spaces[r].toXYZ),s.applyMatrix3(this.spaces[a].fromXYZ)),this.spaces[a].transfer===xt&&(s.r=nr(s.r),s.g=nr(s.g),s.b=nr(s.b))),s},workingToColorSpace:function(s,r){return this.convert(s,this.workingColorSpace,r)},colorSpaceToWorking:function(s,r){return this.convert(s,r,this.workingColorSpace)},getPrimaries:function(s){return this.spaces[s].primaries},getTransfer:function(s){return s===vi?bo:this.spaces[s].transfer},getToneMappingMode:function(s){return this.spaces[s].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(s,r=this.workingColorSpace){return s.fromArray(this.spaces[r].luminanceCoefficients)},define:function(s){Object.assign(this.spaces,s)},_getMatrix:function(s,r,a){return s.copy(this.spaces[r].toXYZ).multiply(this.spaces[a].fromXYZ)},_getDrawingBufferColorSpace:function(s){return this.spaces[s].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(s=this.workingColorSpace){return this.spaces[s].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(s,r){return tr("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),n.workingToColorSpace(s,r)},toWorkingColorSpace:function(s,r){return tr("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),n.colorSpaceToWorking(s,r)}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],i=[.3127,.329];return n.define({[So]:{primaries:e,whitePoint:i,transfer:bo,toXYZ:ah,fromXYZ:oh,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:Sn},outputColorSpaceConfig:{drawingBufferColorSpace:Sn}},[Sn]:{primaries:e,whitePoint:i,transfer:xt,toXYZ:ah,fromXYZ:oh,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:Sn}}}),n}const at=Xm();function Ei(n){return n<.04045?n*.0773993808:Math.pow(n*.9478672986+.0521327014,2.4)}function nr(n){return n<.0031308?n*12.92:1.055*Math.pow(n,.41666)-.055}let ws;class Ym{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let i;if(e instanceof HTMLCanvasElement)i=e;else{ws===void 0&&(ws=Ao("canvas")),ws.width=e.width,ws.height=e.height;const s=ws.getContext("2d");e instanceof ImageData?s.putImageData(e,0,0):s.drawImage(e,0,0,e.width,e.height),i=ws}return i.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const t=Ao("canvas");t.width=e.width,t.height=e.height;const i=t.getContext("2d");i.drawImage(e,0,0,e.width,e.height);const s=i.getImageData(0,0,e.width,e.height),r=s.data;for(let a=0;a<r.length;a++)r[a]=Ei(r[a]/255)*255;return i.putImageData(s,0,0),t}else if(e.data){const t=e.data.slice(0);for(let i=0;i<t.length;i++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[i]=Math.floor(Ei(t[i]/255)*255):t[i]=Ei(t[i]);return{data:t,width:e.width,height:e.height}}else return $e("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}let Km=0;class Su{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:Km++}),this.uuid=ci(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){const t=this.data;return typeof HTMLVideoElement<"u"&&t instanceof HTMLVideoElement?e.set(t.videoWidth,t.videoHeight,0):typeof VideoFrame<"u"&&t instanceof VideoFrame?e.set(t.displayWidth,t.displayHeight,0):t!==null?e.set(t.width,t.height,t.depth||0):e.set(0,0,0),e}set needsUpdate(e){e===!0&&this.version++}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];const i={uuid:this.uuid,url:""},s=this.data;if(s!==null){let r;if(Array.isArray(s)){r=[];for(let a=0,o=s.length;a<o;a++)s[a].isDataTexture?r.push(sl(s[a].image)):r.push(sl(s[a]))}else r=sl(s);i.url=r}return t||(e.images[this.uuid]=i),i}}function sl(n){return typeof HTMLImageElement<"u"&&n instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&n instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&n instanceof ImageBitmap?Ym.getDataURL(n):n.data?{data:Array.from(n.data),width:n.width,height:n.height,type:n.data.constructor.name}:($e("Texture: Unable to serialize Texture."),{})}let qm=0;const rl=new k;class sn extends es{constructor(e=sn.DEFAULT_IMAGE,t=sn.DEFAULT_MAPPING,i=Si,s=Si,r=Jt,a=Yi,o=Ln,l=wn,c=sn.DEFAULT_ANISOTROPY,u=vi){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:qm++}),this.uuid=ci(),this.name="",this.source=new Su(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=i,this.wrapT=s,this.magFilter=r,this.minFilter=a,this.anisotropy=c,this.format=o,this.internalFormat=null,this.type=l,this.offset=new Le(0,0),this.repeat=new Le(1,1),this.center=new Le(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new et,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=u,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(e&&e.depth&&e.depth>1),this.pmremVersion=0,this.normalized=!1}get width(){return this.source.getSize(rl).x}get height(){return this.source.getSize(rl).y}get depth(){return this.source.getSize(rl).z}get image(){return this.source.data}set image(e){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.normalized=e.normalized,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(const t in e){const i=e[t];if(i===void 0){$e(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}const s=this[t];if(s===void 0){$e(`Texture.setValues(): property '${t}' does not exist.`);continue}s&&i&&s.isVector2&&i.isVector2||s&&i&&s.isVector3&&i.isVector3||s&&i&&s.isMatrix3&&i.isMatrix3?s.copy(i):this[t]=i}}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const i={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,normalized:this.normalized,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(i.userData=this.userData),t||(e.textures[this.uuid]=i),i}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==Of)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case hc:e.x=e.x-Math.floor(e.x);break;case Si:e.x=e.x<0?0:1;break;case dc:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case hc:e.y=e.y-Math.floor(e.y);break;case Si:e.y=e.y<0?0:1;break;case dc:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}}sn.DEFAULT_IMAGE=null;sn.DEFAULT_MAPPING=Of;sn.DEFAULT_ANISOTROPY=1;const qu=class qu{constructor(e=0,t=0,i=0,s=1){this.x=e,this.y=t,this.z=i,this.w=s}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,i,s){return this.x=e,this.y=t,this.z=i,this.w=s,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("THREE.Vector4: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("THREE.Vector4: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const t=this.x,i=this.y,s=this.z,r=this.w,a=e.elements;return this.x=a[0]*t+a[4]*i+a[8]*s+a[12]*r,this.y=a[1]*t+a[5]*i+a[9]*s+a[13]*r,this.z=a[2]*t+a[6]*i+a[10]*s+a[14]*r,this.w=a[3]*t+a[7]*i+a[11]*s+a[15]*r,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,i,s,r;const l=e.elements,c=l[0],u=l[4],h=l[8],d=l[1],f=l[5],p=l[9],_=l[2],m=l[6],g=l[10];if(Math.abs(u-d)<.01&&Math.abs(h-_)<.01&&Math.abs(p-m)<.01){if(Math.abs(u+d)<.1&&Math.abs(h+_)<.1&&Math.abs(p+m)<.1&&Math.abs(c+f+g-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const b=(c+1)/2,x=(f+1)/2,E=(g+1)/2,S=(u+d)/4,A=(h+_)/4,y=(p+m)/4;return b>x&&b>E?b<.01?(i=0,s=.707106781,r=.707106781):(i=Math.sqrt(b),s=S/i,r=A/i):x>E?x<.01?(i=.707106781,s=0,r=.707106781):(s=Math.sqrt(x),i=S/s,r=y/s):E<.01?(i=.707106781,s=.707106781,r=0):(r=Math.sqrt(E),i=A/r,s=y/r),this.set(i,s,r,t),this}let v=Math.sqrt((m-p)*(m-p)+(h-_)*(h-_)+(d-u)*(d-u));return Math.abs(v)<.001&&(v=1),this.x=(m-p)/v,this.y=(h-_)/v,this.z=(d-u)/v,this.w=Math.acos((c+f+g-1)/2),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=Qe(this.x,e.x,t.x),this.y=Qe(this.y,e.y,t.y),this.z=Qe(this.z,e.z,t.z),this.w=Qe(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=Qe(this.x,e,t),this.y=Qe(this.y,e,t),this.z=Qe(this.z,e,t),this.w=Qe(this.w,e,t),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Qe(i,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this.w=e.w+(t.w-e.w)*i,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}};qu.prototype.isVector4=!0;let Et=qu;class $m extends es{constructor(e=1,t=1,i={}){super(),i=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Jt,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1,useArrayDepthTexture:!1},i),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=i.depth,this.scissor=new Et(0,0,e,t),this.scissorTest=!1,this.viewport=new Et(0,0,e,t),this.textures=[];const s={width:e,height:t,depth:i.depth},r=new sn(s),a=i.count;for(let o=0;o<a;o++)this.textures[o]=r.clone(),this.textures[o].isRenderTargetTexture=!0,this.textures[o].renderTarget=this;this._setTextureOptions(i),this.depthBuffer=i.depthBuffer,this.stencilBuffer=i.stencilBuffer,this.resolveDepthBuffer=i.resolveDepthBuffer,this.resolveStencilBuffer=i.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=i.depthTexture,this.samples=i.samples,this.multiview=i.multiview,this.useArrayDepthTexture=i.useArrayDepthTexture}_setTextureOptions(e={}){const t={minFilter:Jt,generateMipmaps:!1,flipY:!1,internalFormat:null};e.mapping!==void 0&&(t.mapping=e.mapping),e.wrapS!==void 0&&(t.wrapS=e.wrapS),e.wrapT!==void 0&&(t.wrapT=e.wrapT),e.wrapR!==void 0&&(t.wrapR=e.wrapR),e.magFilter!==void 0&&(t.magFilter=e.magFilter),e.minFilter!==void 0&&(t.minFilter=e.minFilter),e.format!==void 0&&(t.format=e.format),e.type!==void 0&&(t.type=e.type),e.anisotropy!==void 0&&(t.anisotropy=e.anisotropy),e.colorSpace!==void 0&&(t.colorSpace=e.colorSpace),e.flipY!==void 0&&(t.flipY=e.flipY),e.generateMipmaps!==void 0&&(t.generateMipmaps=e.generateMipmaps),e.internalFormat!==void 0&&(t.internalFormat=e.internalFormat);for(let i=0;i<this.textures.length;i++)this.textures[i].setValues(t)}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),e!==null&&(e.renderTarget=this),this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,t,i=1){if(this.width!==e||this.height!==t||this.depth!==i){this.width=e,this.height=t,this.depth=i;for(let s=0,r=this.textures.length;s<r;s++)this.textures[s].image.width=e,this.textures[s].image.height=t,this.textures[s].image.depth=i,this.textures[s].isData3DTexture!==!0&&(this.textures[s].isArrayTexture=this.textures[s].image.depth>1);this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,i=e.textures.length;t<i;t++){this.textures[t]=e.textures[t].clone(),this.textures[t].isRenderTargetTexture=!0,this.textures[t].renderTarget=this;const s=Object.assign({},e.textures[t].image);this.textures[t].source=new Su(s)}return this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this.multiview=e.multiview,this.useArrayDepthTexture=e.useArrayDepthTexture,this}dispose(){this.dispatchEvent({type:"dispose"})}}class ui extends $m{constructor(e=1,t=1,i={}){super(e,t,i),this.isWebGLRenderTarget=!0}}class Wf extends sn{constructor(e=null,t=1,i=1,s=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:i,depth:s},this.magFilter=zt,this.minFilter=zt,this.wrapR=Si,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class Zm extends sn{constructor(e=null,t=1,i=1,s=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:i,depth:s},this.magFilter=zt,this.minFilter=zt,this.wrapR=Si,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const Go=class Go{constructor(e,t,i,s,r,a,o,l,c,u,h,d,f,p,_,m){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,t,i,s,r,a,o,l,c,u,h,d,f,p,_,m)}set(e,t,i,s,r,a,o,l,c,u,h,d,f,p,_,m){const g=this.elements;return g[0]=e,g[4]=t,g[8]=i,g[12]=s,g[1]=r,g[5]=a,g[9]=o,g[13]=l,g[2]=c,g[6]=u,g[10]=h,g[14]=d,g[3]=f,g[7]=p,g[11]=_,g[15]=m,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new Go().fromArray(this.elements)}copy(e){const t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],t[9]=i[9],t[10]=i[10],t[11]=i[11],t[12]=i[12],t[13]=i[13],t[14]=i[14],t[15]=i[15],this}copyPosition(e){const t=this.elements,i=e.elements;return t[12]=i[12],t[13]=i[13],t[14]=i[14],this}setFromMatrix3(e){const t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,i){return this.determinantAffine()===0?(e.set(1,0,0),t.set(0,1,0),i.set(0,0,1),this):(e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this)}makeBasis(e,t,i){return this.set(e.x,t.x,i.x,0,e.y,t.y,i.y,0,e.z,t.z,i.z,0,0,0,0,1),this}extractRotation(e){if(e.determinantAffine()===0)return this.identity();const t=this.elements,i=e.elements,s=1/Rs.setFromMatrixColumn(e,0).length(),r=1/Rs.setFromMatrixColumn(e,1).length(),a=1/Rs.setFromMatrixColumn(e,2).length();return t[0]=i[0]*s,t[1]=i[1]*s,t[2]=i[2]*s,t[3]=0,t[4]=i[4]*r,t[5]=i[5]*r,t[6]=i[6]*r,t[7]=0,t[8]=i[8]*a,t[9]=i[9]*a,t[10]=i[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,i=e.x,s=e.y,r=e.z,a=Math.cos(i),o=Math.sin(i),l=Math.cos(s),c=Math.sin(s),u=Math.cos(r),h=Math.sin(r);if(e.order==="XYZ"){const d=a*u,f=a*h,p=o*u,_=o*h;t[0]=l*u,t[4]=-l*h,t[8]=c,t[1]=f+p*c,t[5]=d-_*c,t[9]=-o*l,t[2]=_-d*c,t[6]=p+f*c,t[10]=a*l}else if(e.order==="YXZ"){const d=l*u,f=l*h,p=c*u,_=c*h;t[0]=d+_*o,t[4]=p*o-f,t[8]=a*c,t[1]=a*h,t[5]=a*u,t[9]=-o,t[2]=f*o-p,t[6]=_+d*o,t[10]=a*l}else if(e.order==="ZXY"){const d=l*u,f=l*h,p=c*u,_=c*h;t[0]=d-_*o,t[4]=-a*h,t[8]=p+f*o,t[1]=f+p*o,t[5]=a*u,t[9]=_-d*o,t[2]=-a*c,t[6]=o,t[10]=a*l}else if(e.order==="ZYX"){const d=a*u,f=a*h,p=o*u,_=o*h;t[0]=l*u,t[4]=p*c-f,t[8]=d*c+_,t[1]=l*h,t[5]=_*c+d,t[9]=f*c-p,t[2]=-c,t[6]=o*l,t[10]=a*l}else if(e.order==="YZX"){const d=a*l,f=a*c,p=o*l,_=o*c;t[0]=l*u,t[4]=_-d*h,t[8]=p*h+f,t[1]=h,t[5]=a*u,t[9]=-o*u,t[2]=-c*u,t[6]=f*h+p,t[10]=d-_*h}else if(e.order==="XZY"){const d=a*l,f=a*c,p=o*l,_=o*c;t[0]=l*u,t[4]=-h,t[8]=c*u,t[1]=d*h+_,t[5]=a*u,t[9]=f*h-p,t[2]=p*h-f,t[6]=o*u,t[10]=_*h+d}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(Jm,e,jm)}lookAt(e,t,i){const s=this.elements;return yn.subVectors(e,t),yn.lengthSq()===0&&(yn.z=1),yn.normalize(),Oi.crossVectors(i,yn),Oi.lengthSq()===0&&(Math.abs(i.z)===1?yn.x+=1e-4:yn.z+=1e-4,yn.normalize(),Oi.crossVectors(i,yn)),Oi.normalize(),ma.crossVectors(yn,Oi),s[0]=Oi.x,s[4]=ma.x,s[8]=yn.x,s[1]=Oi.y,s[5]=ma.y,s[9]=yn.y,s[2]=Oi.z,s[6]=ma.z,s[10]=yn.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const i=e.elements,s=t.elements,r=this.elements,a=i[0],o=i[4],l=i[8],c=i[12],u=i[1],h=i[5],d=i[9],f=i[13],p=i[2],_=i[6],m=i[10],g=i[14],v=i[3],b=i[7],x=i[11],E=i[15],S=s[0],A=s[4],y=s[8],T=s[12],L=s[1],R=s[5],w=s[9],P=s[13],U=s[2],D=s[6],K=s[10],B=s[14],ie=s[3],F=s[7],se=s[11],V=s[15];return r[0]=a*S+o*L+l*U+c*ie,r[4]=a*A+o*R+l*D+c*F,r[8]=a*y+o*w+l*K+c*se,r[12]=a*T+o*P+l*B+c*V,r[1]=u*S+h*L+d*U+f*ie,r[5]=u*A+h*R+d*D+f*F,r[9]=u*y+h*w+d*K+f*se,r[13]=u*T+h*P+d*B+f*V,r[2]=p*S+_*L+m*U+g*ie,r[6]=p*A+_*R+m*D+g*F,r[10]=p*y+_*w+m*K+g*se,r[14]=p*T+_*P+m*B+g*V,r[3]=v*S+b*L+x*U+E*ie,r[7]=v*A+b*R+x*D+E*F,r[11]=v*y+b*w+x*K+E*se,r[15]=v*T+b*P+x*B+E*V,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){const e=this.elements,t=e[0],i=e[4],s=e[8],r=e[12],a=e[1],o=e[5],l=e[9],c=e[13],u=e[2],h=e[6],d=e[10],f=e[14],p=e[3],_=e[7],m=e[11],g=e[15],v=l*f-c*d,b=o*f-c*h,x=o*d-l*h,E=a*f-c*u,S=a*d-l*u,A=a*h-o*u;return t*(_*v-m*b+g*x)-i*(p*v-m*E+g*S)+s*(p*b-_*E+g*A)-r*(p*x-_*S+m*A)}determinantAffine(){const e=this.elements,t=e[0],i=e[4],s=e[8],r=e[1],a=e[5],o=e[9],l=e[2],c=e[6],u=e[10];return t*(a*u-o*c)-i*(r*u-o*l)+s*(r*c-a*l)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,i){const s=this.elements;return e.isVector3?(s[12]=e.x,s[13]=e.y,s[14]=e.z):(s[12]=e,s[13]=t,s[14]=i),this}invert(){const e=this.elements,t=e[0],i=e[1],s=e[2],r=e[3],a=e[4],o=e[5],l=e[6],c=e[7],u=e[8],h=e[9],d=e[10],f=e[11],p=e[12],_=e[13],m=e[14],g=e[15],v=t*o-i*a,b=t*l-s*a,x=t*c-r*a,E=i*l-s*o,S=i*c-r*o,A=s*c-r*l,y=u*_-h*p,T=u*m-d*p,L=u*g-f*p,R=h*m-d*_,w=h*g-f*_,P=d*g-f*m,U=v*P-b*w+x*R+E*L-S*T+A*y;if(U===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const D=1/U;return e[0]=(o*P-l*w+c*R)*D,e[1]=(s*w-i*P-r*R)*D,e[2]=(_*A-m*S+g*E)*D,e[3]=(d*S-h*A-f*E)*D,e[4]=(l*L-a*P-c*T)*D,e[5]=(t*P-s*L+r*T)*D,e[6]=(m*x-p*A-g*b)*D,e[7]=(u*A-d*x+f*b)*D,e[8]=(a*w-o*L+c*y)*D,e[9]=(i*L-t*w-r*y)*D,e[10]=(p*S-_*x+g*v)*D,e[11]=(h*x-u*S-f*v)*D,e[12]=(o*T-a*R-l*y)*D,e[13]=(t*R-i*T+s*y)*D,e[14]=(_*b-p*E-m*v)*D,e[15]=(u*E-h*b+d*v)*D,this}scale(e){const t=this.elements,i=e.x,s=e.y,r=e.z;return t[0]*=i,t[4]*=s,t[8]*=r,t[1]*=i,t[5]*=s,t[9]*=r,t[2]*=i,t[6]*=s,t[10]*=r,t[3]*=i,t[7]*=s,t[11]*=r,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],i=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],s=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,i,s))}makeTranslation(e,t,i){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,i,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),i=Math.sin(e);return this.set(1,0,0,0,0,t,-i,0,0,i,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,0,i,0,0,1,0,0,-i,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,0,i,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const i=Math.cos(t),s=Math.sin(t),r=1-i,a=e.x,o=e.y,l=e.z,c=r*a,u=r*o;return this.set(c*a+i,c*o-s*l,c*l+s*o,0,c*o+s*l,u*o+i,u*l-s*a,0,c*l-s*o,u*l+s*a,r*l*l+i,0,0,0,0,1),this}makeScale(e,t,i){return this.set(e,0,0,0,0,t,0,0,0,0,i,0,0,0,0,1),this}makeShear(e,t,i,s,r,a){return this.set(1,i,r,0,e,1,a,0,t,s,1,0,0,0,0,1),this}compose(e,t,i){const s=this.elements,r=t._x,a=t._y,o=t._z,l=t._w,c=r+r,u=a+a,h=o+o,d=r*c,f=r*u,p=r*h,_=a*u,m=a*h,g=o*h,v=l*c,b=l*u,x=l*h,E=i.x,S=i.y,A=i.z;return s[0]=(1-(_+g))*E,s[1]=(f+x)*E,s[2]=(p-b)*E,s[3]=0,s[4]=(f-x)*S,s[5]=(1-(d+g))*S,s[6]=(m+v)*S,s[7]=0,s[8]=(p+b)*A,s[9]=(m-v)*A,s[10]=(1-(d+_))*A,s[11]=0,s[12]=e.x,s[13]=e.y,s[14]=e.z,s[15]=1,this}decompose(e,t,i){const s=this.elements;e.x=s[12],e.y=s[13],e.z=s[14];const r=this.determinantAffine();if(r===0)return i.set(1,1,1),t.identity(),this;let a=Rs.set(s[0],s[1],s[2]).length();const o=Rs.set(s[4],s[5],s[6]).length(),l=Rs.set(s[8],s[9],s[10]).length();r<0&&(a=-a),kn.copy(this);const c=1/a,u=1/o,h=1/l;return kn.elements[0]*=c,kn.elements[1]*=c,kn.elements[2]*=c,kn.elements[4]*=u,kn.elements[5]*=u,kn.elements[6]*=u,kn.elements[8]*=h,kn.elements[9]*=h,kn.elements[10]*=h,t.setFromRotationMatrix(kn),i.x=a,i.y=o,i.z=l,this}makePerspective(e,t,i,s,r,a,o=ri,l=!1){const c=this.elements,u=2*r/(t-e),h=2*r/(i-s),d=(t+e)/(t-e),f=(i+s)/(i-s);let p,_;if(l)p=r/(a-r),_=a*r/(a-r);else if(o===ri)p=-(a+r)/(a-r),_=-2*a*r/(a-r);else if(o===Mo)p=-a/(a-r),_=-a*r/(a-r);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return c[0]=u,c[4]=0,c[8]=d,c[12]=0,c[1]=0,c[5]=h,c[9]=f,c[13]=0,c[2]=0,c[6]=0,c[10]=p,c[14]=_,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,t,i,s,r,a,o=ri,l=!1){const c=this.elements,u=2/(t-e),h=2/(i-s),d=-(t+e)/(t-e),f=-(i+s)/(i-s);let p,_;if(l)p=1/(a-r),_=a/(a-r);else if(o===ri)p=-2/(a-r),_=-(a+r)/(a-r);else if(o===Mo)p=-1/(a-r),_=-r/(a-r);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return c[0]=u,c[4]=0,c[8]=0,c[12]=d,c[1]=0,c[5]=h,c[9]=0,c[13]=f,c[2]=0,c[6]=0,c[10]=p,c[14]=_,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(e){const t=this.elements,i=e.elements;for(let s=0;s<16;s++)if(t[s]!==i[s])return!1;return!0}fromArray(e,t=0){for(let i=0;i<16;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){const i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e[t+9]=i[9],e[t+10]=i[10],e[t+11]=i[11],e[t+12]=i[12],e[t+13]=i[13],e[t+14]=i[14],e[t+15]=i[15],e}};Go.prototype.isMatrix4=!0;let Rt=Go;const Rs=new k,kn=new Rt,Jm=new k(0,0,0),jm=new k(1,1,1),Oi=new k,ma=new k,yn=new k,lh=new Rt,ch=new Ji;class _s{constructor(e=0,t=0,i=0,s=_s.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=i,this._order=s}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,i,s=this._order){return this._x=e,this._y=t,this._z=i,this._order=s,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,i=!0){const s=e.elements,r=s[0],a=s[4],o=s[8],l=s[1],c=s[5],u=s[9],h=s[2],d=s[6],f=s[10];switch(t){case"XYZ":this._y=Math.asin(Qe(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-u,f),this._z=Math.atan2(-a,r)):(this._x=Math.atan2(d,c),this._z=0);break;case"YXZ":this._x=Math.asin(-Qe(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(o,f),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-h,r),this._z=0);break;case"ZXY":this._x=Math.asin(Qe(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-h,f),this._z=Math.atan2(-a,c)):(this._y=0,this._z=Math.atan2(l,r));break;case"ZYX":this._y=Math.asin(-Qe(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(d,f),this._z=Math.atan2(l,r)):(this._x=0,this._z=Math.atan2(-a,c));break;case"YZX":this._z=Math.asin(Qe(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-u,c),this._y=Math.atan2(-h,r)):(this._x=0,this._y=Math.atan2(o,f));break;case"XZY":this._z=Math.asin(-Qe(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(d,c),this._y=Math.atan2(o,r)):(this._x=Math.atan2(-u,f),this._y=0);break;default:$e("Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,i===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,i){return lh.makeRotationFromQuaternion(e),this.setFromRotationMatrix(lh,t,i)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return ch.setFromEuler(this),this.setFromQuaternion(ch,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}_s.DEFAULT_ORDER="XYZ";class Xf{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!==0}}let Qm=0;const uh=new k,Ls=new Ji,mi=new Rt,ga=new k,br=new k,eg=new k,tg=new Ji,hh=new k(1,0,0),dh=new k(0,1,0),fh=new k(0,0,1),ph={type:"added"},ng={type:"removed"},Ds={type:"childadded",child:null},al={type:"childremoved",child:null};class hn extends es{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:Qm++}),this.uuid=ci(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=hn.DEFAULT_UP.clone();const e=new k,t=new _s,i=new Ji,s=new k(1,1,1);function r(){i.setFromEuler(t,!1)}function a(){t.setFromQuaternion(i,void 0,!1)}t._onChange(r),i._onChange(a),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:i},scale:{configurable:!0,enumerable:!0,value:s},modelViewMatrix:{value:new Rt},normalMatrix:{value:new et}}),this.matrix=new Rt,this.matrixWorld=new Rt,this.matrixAutoUpdate=hn.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=hn.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new Xf,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.static=!1,this.userData={},this.pivot=null}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return Ls.setFromAxisAngle(e,t),this.quaternion.multiply(Ls),this}rotateOnWorldAxis(e,t){return Ls.setFromAxisAngle(e,t),this.quaternion.premultiply(Ls),this}rotateX(e){return this.rotateOnAxis(hh,e)}rotateY(e){return this.rotateOnAxis(dh,e)}rotateZ(e){return this.rotateOnAxis(fh,e)}translateOnAxis(e,t){return uh.copy(e).applyQuaternion(this.quaternion),this.position.add(uh.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(hh,e)}translateY(e){return this.translateOnAxis(dh,e)}translateZ(e){return this.translateOnAxis(fh,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(mi.copy(this.matrixWorld).invert())}lookAt(e,t,i){e.isVector3?ga.copy(e):ga.set(e,t,i);const s=this.parent;this.updateWorldMatrix(!0,!1),br.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?mi.lookAt(br,ga,this.up):mi.lookAt(ga,br,this.up),this.quaternion.setFromRotationMatrix(mi),s&&(mi.extractRotation(s.matrixWorld),Ls.setFromRotationMatrix(mi),this.quaternion.premultiply(Ls.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(ut("Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(ph),Ds.child=e,this.dispatchEvent(Ds),Ds.child=null):ut("Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let i=0;i<arguments.length;i++)this.remove(arguments[i]);return this}const t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(ng),al.child=e,this.dispatchEvent(al),al.child=null),this}removeFromParent(){const e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),mi.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),mi.multiply(e.parent.matrixWorld)),e.applyMatrix4(mi),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(ph),Ds.child=e,this.dispatchEvent(Ds),Ds.child=null,this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let i=0,s=this.children.length;i<s;i++){const a=this.children[i].getObjectByProperty(e,t);if(a!==void 0)return a}}getObjectsByProperty(e,t,i=[]){this[e]===t&&i.push(this);const s=this.children;for(let r=0,a=s.length;r<a;r++)s[r].getObjectsByProperty(e,t,i);return i}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(br,e,eg),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(br,tg,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);const t=this.children;for(let i=0,s=t.length;i<s;i++)t[i].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const t=this.children;for(let i=0,s=t.length;i<s;i++)t[i].traverseVisible(e)}traverseAncestors(e){const t=this.parent;t!==null&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale);const e=this.pivot;if(e!==null){const t=e.x,i=e.y,s=e.z,r=this.matrix.elements;r[12]+=t-r[0]*t-r[4]*i-r[8]*s,r[13]+=i-r[1]*t-r[5]*i-r[9]*s,r[14]+=s-r[2]*t-r[6]*i-r[10]*s}this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);const t=this.children;for(let i=0,s=t.length;i<s;i++)t[i].updateMatrixWorld(e)}updateWorldMatrix(e,t,i=!1){const s=this.parent;if(e===!0&&s!==null&&s.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||i)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,i=!0),t===!0){const r=this.children;for(let a=0,o=r.length;a<o;a++)r[a].updateWorldMatrix(!1,!0,i)}}toJSON(e){const t=e===void 0||typeof e=="string",i={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},i.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});const s={};s.uuid=this.uuid,s.type=this.type,this.name!==""&&(s.name=this.name),this.castShadow===!0&&(s.castShadow=!0),this.receiveShadow===!0&&(s.receiveShadow=!0),this.visible===!1&&(s.visible=!1),this.frustumCulled===!1&&(s.frustumCulled=!1),this.renderOrder!==0&&(s.renderOrder=this.renderOrder),this.static!==!1&&(s.static=this.static),Object.keys(this.userData).length>0&&(s.userData=this.userData),s.layers=this.layers.mask,s.matrix=this.matrix.toArray(),s.up=this.up.toArray(),this.pivot!==null&&(s.pivot=this.pivot.toArray()),this.matrixAutoUpdate===!1&&(s.matrixAutoUpdate=!1),this.morphTargetDictionary!==void 0&&(s.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(s.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(s.type="InstancedMesh",s.count=this.count,s.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(s.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(s.type="BatchedMesh",s.perObjectFrustumCulled=this.perObjectFrustumCulled,s.sortObjects=this.sortObjects,s.drawRanges=this._drawRanges,s.reservedRanges=this._reservedRanges,s.geometryInfo=this._geometryInfo.map(o=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),s.instanceInfo=this._instanceInfo.map(o=>({...o})),s.availableInstanceIds=this._availableInstanceIds.slice(),s.availableGeometryIds=this._availableGeometryIds.slice(),s.nextIndexStart=this._nextIndexStart,s.nextVertexStart=this._nextVertexStart,s.geometryCount=this._geometryCount,s.maxInstanceCount=this._maxInstanceCount,s.maxVertexCount=this._maxVertexCount,s.maxIndexCount=this._maxIndexCount,s.geometryInitialized=this._geometryInitialized,s.matricesTexture=this._matricesTexture.toJSON(e),s.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(s.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(s.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(s.boundingBox=this.boundingBox.toJSON()));function r(o,l){return o[l.uuid]===void 0&&(o[l.uuid]=l.toJSON(e)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?s.background=this.background.toJSON():this.background.isTexture&&(s.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(s.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){s.geometry=r(e.geometries,this.geometry);const o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const l=o.shapes;if(Array.isArray(l))for(let c=0,u=l.length;c<u;c++){const h=l[c];r(e.shapes,h)}else r(e.shapes,l)}}if(this.isSkinnedMesh&&(s.bindMode=this.bindMode,s.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(r(e.skeletons,this.skeleton),s.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const o=[];for(let l=0,c=this.material.length;l<c;l++)o.push(r(e.materials,this.material[l]));s.material=o}else s.material=r(e.materials,this.material);if(this.children.length>0){s.children=[];for(let o=0;o<this.children.length;o++)s.children.push(this.children[o].toJSON(e).object)}if(this.animations.length>0){s.animations=[];for(let o=0;o<this.animations.length;o++){const l=this.animations[o];s.animations.push(r(e.animations,l))}}if(t){const o=a(e.geometries),l=a(e.materials),c=a(e.textures),u=a(e.images),h=a(e.shapes),d=a(e.skeletons),f=a(e.animations),p=a(e.nodes);o.length>0&&(i.geometries=o),l.length>0&&(i.materials=l),c.length>0&&(i.textures=c),u.length>0&&(i.images=u),h.length>0&&(i.shapes=h),d.length>0&&(i.skeletons=d),f.length>0&&(i.animations=f),p.length>0&&(i.nodes=p)}return i.object=s,i;function a(o){const l=[];for(const c in o){const u=o[c];delete u.metadata,l.push(u)}return l}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.pivot=e.pivot!==null?e.pivot.clone():null,this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.static=e.static,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let i=0;i<e.children.length;i++){const s=e.children[i];this.add(s.clone())}return this}}hn.DEFAULT_UP=new k(0,1,0);hn.DEFAULT_MATRIX_AUTO_UPDATE=!0;hn.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;class Nr extends hn{constructor(){super(),this.isGroup=!0,this.type="Group"}}const ig={type:"move"};class ol{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Nr,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new Nr,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new k,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new k),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Nr,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new k,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new k,this._grip.eventsEnabled=!1),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const t=this._hand;if(t)for(const i of e.hand.values())this._getHandJoint(t,i)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,i){let s=null,r=null,a=null;const o=this._targetRay,l=this._grip,c=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(c&&e.hand){a=!0;for(const _ of e.hand.values()){const m=t.getJointPose(_,i),g=this._getHandJoint(c,_);m!==null&&(g.matrix.fromArray(m.transform.matrix),g.matrix.decompose(g.position,g.rotation,g.scale),g.matrixWorldNeedsUpdate=!0,g.jointRadius=m.radius),g.visible=m!==null}const u=c.joints["index-finger-tip"],h=c.joints["thumb-tip"],d=u.position.distanceTo(h.position),f=.02,p=.005;c.inputState.pinching&&d>f+p?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&d<=f-p&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(r=t.getPose(e.gripSpace,i),r!==null&&(l.matrix.fromArray(r.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,r.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(r.linearVelocity)):l.hasLinearVelocity=!1,r.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(r.angularVelocity)):l.hasAngularVelocity=!1,l.eventsEnabled&&l.dispatchEvent({type:"gripUpdated",data:e,target:this})));o!==null&&(s=t.getPose(e.targetRaySpace,i),s===null&&r!==null&&(s=r),s!==null&&(o.matrix.fromArray(s.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,s.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(s.linearVelocity)):o.hasLinearVelocity=!1,s.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(s.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(ig)))}return o!==null&&(o.visible=s!==null),l!==null&&(l.visible=r!==null),c!==null&&(c.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const i=new Nr;i.matrixAutoUpdate=!1,i.visible=!1,e.joints[t.jointName]=i,e.add(i)}return e.joints[t.jointName]}}const Yf={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},Ui={h:0,s:0,l:0},_a={h:0,s:0,l:0};function ll(n,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?n+(e-n)*6*t:t<1/2?e:t<2/3?n+(e-n)*6*(2/3-t):n}class it{constructor(e,t,i){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,i)}set(e,t,i){if(t===void 0&&i===void 0){const s=e;s&&s.isColor?this.copy(s):typeof s=="number"?this.setHex(s):typeof s=="string"&&this.setStyle(s)}else this.setRGB(e,t,i);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=Sn){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,at.colorSpaceToWorking(this,t),this}setRGB(e,t,i,s=at.workingColorSpace){return this.r=e,this.g=t,this.b=i,at.colorSpaceToWorking(this,s),this}setHSL(e,t,i,s=at.workingColorSpace){if(e=vu(e,1),t=Qe(t,0,1),i=Qe(i,0,1),t===0)this.r=this.g=this.b=i;else{const r=i<=.5?i*(1+t):i+t-i*t,a=2*i-r;this.r=ll(a,r,e+1/3),this.g=ll(a,r,e),this.b=ll(a,r,e-1/3)}return at.colorSpaceToWorking(this,s),this}setStyle(e,t=Sn){function i(r){r!==void 0&&parseFloat(r)<1&&$e("Color: Alpha component of "+e+" will be ignored.")}let s;if(s=/^(\w+)\(([^\)]*)\)/.exec(e)){let r;const a=s[1],o=s[2];switch(a){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,t);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,t);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,t);break;default:$e("Color: Unknown color model "+e)}}else if(s=/^\#([A-Fa-f\d]+)$/.exec(e)){const r=s[1],a=r.length;if(a===3)return this.setRGB(parseInt(r.charAt(0),16)/15,parseInt(r.charAt(1),16)/15,parseInt(r.charAt(2),16)/15,t);if(a===6)return this.setHex(parseInt(r,16),t);$e("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=Sn){const i=Yf[e.toLowerCase()];return i!==void 0?this.setHex(i,t):$e("Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=Ei(e.r),this.g=Ei(e.g),this.b=Ei(e.b),this}copyLinearToSRGB(e){return this.r=nr(e.r),this.g=nr(e.g),this.b=nr(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Sn){return at.workingToColorSpace(tn.copy(this),e),Math.round(Qe(tn.r*255,0,255))*65536+Math.round(Qe(tn.g*255,0,255))*256+Math.round(Qe(tn.b*255,0,255))}getHexString(e=Sn){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=at.workingColorSpace){at.workingToColorSpace(tn.copy(this),t);const i=tn.r,s=tn.g,r=tn.b,a=Math.max(i,s,r),o=Math.min(i,s,r);let l,c;const u=(o+a)/2;if(o===a)l=0,c=0;else{const h=a-o;switch(c=u<=.5?h/(a+o):h/(2-a-o),a){case i:l=(s-r)/h+(s<r?6:0);break;case s:l=(r-i)/h+2;break;case r:l=(i-s)/h+4;break}l/=6}return e.h=l,e.s=c,e.l=u,e}getRGB(e,t=at.workingColorSpace){return at.workingToColorSpace(tn.copy(this),t),e.r=tn.r,e.g=tn.g,e.b=tn.b,e}getStyle(e=Sn){at.workingToColorSpace(tn.copy(this),e);const t=tn.r,i=tn.g,s=tn.b;return e!==Sn?`color(${e} ${t.toFixed(3)} ${i.toFixed(3)} ${s.toFixed(3)})`:`rgb(${Math.round(t*255)},${Math.round(i*255)},${Math.round(s*255)})`}offsetHSL(e,t,i){return this.getHSL(Ui),this.setHSL(Ui.h+e,Ui.s+t,Ui.l+i)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,i){return this.r=e.r+(t.r-e.r)*i,this.g=e.g+(t.g-e.g)*i,this.b=e.b+(t.b-e.b)*i,this}lerpHSL(e,t){this.getHSL(Ui),e.getHSL(_a);const i=Hr(Ui.h,_a.h,t),s=Hr(Ui.s,_a.s,t),r=Hr(Ui.l,_a.l,t);return this.setHSL(i,s,r),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const t=this.r,i=this.g,s=this.b,r=e.elements;return this.r=r[0]*t+r[3]*i+r[6]*s,this.g=r[1]*t+r[4]*i+r[7]*s,this.b=r[2]*t+r[5]*i+r[8]*s,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const tn=new it;it.NAMES=Yf;class sg extends hn{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new _s,this.environmentIntensity=1,this.environmentRotation=new _s,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}}const Fn=new k,gi=new k,cl=new k,_i=new k,Is=new k,Ps=new k,mh=new k,ul=new k,hl=new k,dl=new k,fl=new Et,pl=new Et,ml=new Et;class Rn{constructor(e=new k,t=new k,i=new k){this.a=e,this.b=t,this.c=i}static getNormal(e,t,i,s){s.subVectors(i,t),Fn.subVectors(e,t),s.cross(Fn);const r=s.lengthSq();return r>0?s.multiplyScalar(1/Math.sqrt(r)):s.set(0,0,0)}static getBarycoord(e,t,i,s,r){Fn.subVectors(s,t),gi.subVectors(i,t),cl.subVectors(e,t);const a=Fn.dot(Fn),o=Fn.dot(gi),l=Fn.dot(cl),c=gi.dot(gi),u=gi.dot(cl),h=a*c-o*o;if(h===0)return r.set(0,0,0),null;const d=1/h,f=(c*l-o*u)*d,p=(a*u-o*l)*d;return r.set(1-f-p,p,f)}static containsPoint(e,t,i,s){return this.getBarycoord(e,t,i,s,_i)===null?!1:_i.x>=0&&_i.y>=0&&_i.x+_i.y<=1}static getInterpolation(e,t,i,s,r,a,o,l){return this.getBarycoord(e,t,i,s,_i)===null?(l.x=0,l.y=0,"z"in l&&(l.z=0),"w"in l&&(l.w=0),null):(l.setScalar(0),l.addScaledVector(r,_i.x),l.addScaledVector(a,_i.y),l.addScaledVector(o,_i.z),l)}static getInterpolatedAttribute(e,t,i,s,r,a){return fl.setScalar(0),pl.setScalar(0),ml.setScalar(0),fl.fromBufferAttribute(e,t),pl.fromBufferAttribute(e,i),ml.fromBufferAttribute(e,s),a.setScalar(0),a.addScaledVector(fl,r.x),a.addScaledVector(pl,r.y),a.addScaledVector(ml,r.z),a}static isFrontFacing(e,t,i,s){return Fn.subVectors(i,t),gi.subVectors(e,t),Fn.cross(gi).dot(s)<0}set(e,t,i){return this.a.copy(e),this.b.copy(t),this.c.copy(i),this}setFromPointsAndIndices(e,t,i,s){return this.a.copy(e[t]),this.b.copy(e[i]),this.c.copy(e[s]),this}setFromAttributeAndIndices(e,t,i,s){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,i),this.c.fromBufferAttribute(e,s),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return Fn.subVectors(this.c,this.b),gi.subVectors(this.a,this.b),Fn.cross(gi).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Rn.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return Rn.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,i,s,r){return Rn.getInterpolation(e,this.a,this.b,this.c,t,i,s,r)}containsPoint(e){return Rn.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Rn.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const i=this.a,s=this.b,r=this.c;let a,o;Is.subVectors(s,i),Ps.subVectors(r,i),ul.subVectors(e,i);const l=Is.dot(ul),c=Ps.dot(ul);if(l<=0&&c<=0)return t.copy(i);hl.subVectors(e,s);const u=Is.dot(hl),h=Ps.dot(hl);if(u>=0&&h<=u)return t.copy(s);const d=l*h-u*c;if(d<=0&&l>=0&&u<=0)return a=l/(l-u),t.copy(i).addScaledVector(Is,a);dl.subVectors(e,r);const f=Is.dot(dl),p=Ps.dot(dl);if(p>=0&&f<=p)return t.copy(r);const _=f*c-l*p;if(_<=0&&c>=0&&p<=0)return o=c/(c-p),t.copy(i).addScaledVector(Ps,o);const m=u*p-f*h;if(m<=0&&h-u>=0&&f-p>=0)return mh.subVectors(r,s),o=(h-u)/(h-u+(f-p)),t.copy(s).addScaledVector(mh,o);const g=1/(m+_+d);return a=_*g,o=d*g,t.copy(i).addScaledVector(Is,a).addScaledVector(Ps,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}class mn{constructor(e=new k(1/0,1/0,1/0),t=new k(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t+=3)this.expandByPoint(Bn.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,i=e.count;t<i;t++)this.expandByPoint(Bn.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const i=Bn.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(i),this.max.copy(e).add(i),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);const i=e.geometry;if(i!==void 0){const r=i.getAttribute("position");if(t===!0&&r!==void 0&&e.isInstancedMesh!==!0)for(let a=0,o=r.count;a<o;a++)e.isMesh===!0?e.getVertexPosition(a,Bn):Bn.fromBufferAttribute(r,a),Bn.applyMatrix4(e.matrixWorld),this.expandByPoint(Bn);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),xa.copy(e.boundingBox)):(i.boundingBox===null&&i.computeBoundingBox(),xa.copy(i.boundingBox)),xa.applyMatrix4(e.matrixWorld),this.union(xa)}const s=e.children;for(let r=0,a=s.length;r<a;r++)this.expandByObject(s[r],t);return this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,Bn),Bn.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,i;return e.normal.x>0?(t=e.normal.x*this.min.x,i=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,i=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,i+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,i+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,i+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,i+=e.normal.z*this.min.z),t<=-e.constant&&i>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(Mr),ya.subVectors(this.max,Mr),Os.subVectors(e.a,Mr),Us.subVectors(e.b,Mr),Ns.subVectors(e.c,Mr),Ni.subVectors(Us,Os),ki.subVectors(Ns,Us),ns.subVectors(Os,Ns);let t=[0,-Ni.z,Ni.y,0,-ki.z,ki.y,0,-ns.z,ns.y,Ni.z,0,-Ni.x,ki.z,0,-ki.x,ns.z,0,-ns.x,-Ni.y,Ni.x,0,-ki.y,ki.x,0,-ns.y,ns.x,0];return!gl(t,Os,Us,Ns,ya)||(t=[1,0,0,0,1,0,0,0,1],!gl(t,Os,Us,Ns,ya))?!1:(va.crossVectors(Ni,ki),t=[va.x,va.y,va.z],gl(t,Os,Us,Ns,ya))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Bn).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Bn).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(xi[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),xi[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),xi[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),xi[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),xi[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),xi[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),xi[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),xi[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(xi),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}}const xi=[new k,new k,new k,new k,new k,new k,new k,new k],Bn=new k,xa=new mn,Os=new k,Us=new k,Ns=new k,Ni=new k,ki=new k,ns=new k,Mr=new k,ya=new k,va=new k,is=new k;function gl(n,e,t,i,s){for(let r=0,a=n.length-3;r<=a;r+=3){is.fromArray(n,r);const o=s.x*Math.abs(is.x)+s.y*Math.abs(is.y)+s.z*Math.abs(is.z),l=e.dot(is),c=t.dot(is),u=i.dot(is);if(Math.max(-Math.max(l,c,u),Math.min(l,c,u))>o)return!1}return!0}const kt=new k,Sa=new Le;let rg=0;class Dn extends es{constructor(e,t,i=!1){if(super(),Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:rg++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=i,this.usage=Gc,this.updateRanges=[],this.gpuType=Gn,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,i){e*=this.itemSize,i*=t.itemSize;for(let s=0,r=this.itemSize;s<r;s++)this.array[e+s]=t.array[i+s];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,i=this.count;t<i;t++)Sa.fromBufferAttribute(this,t),Sa.applyMatrix3(e),this.setXY(t,Sa.x,Sa.y);else if(this.itemSize===3)for(let t=0,i=this.count;t<i;t++)kt.fromBufferAttribute(this,t),kt.applyMatrix3(e),this.setXYZ(t,kt.x,kt.y,kt.z);return this}applyMatrix4(e){for(let t=0,i=this.count;t<i;t++)kt.fromBufferAttribute(this,t),kt.applyMatrix4(e),this.setXYZ(t,kt.x,kt.y,kt.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)kt.fromBufferAttribute(this,t),kt.applyNormalMatrix(e),this.setXYZ(t,kt.x,kt.y,kt.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)kt.fromBufferAttribute(this,t),kt.transformDirection(e),this.setXYZ(t,kt.x,kt.y,kt.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let i=this.array[e*this.itemSize+t];return this.normalized&&(i=Vn(i,this.array)),i}setComponent(e,t,i){return this.normalized&&(i=yt(i,this.array)),this.array[e*this.itemSize+t]=i,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=Vn(t,this.array)),t}setX(e,t){return this.normalized&&(t=yt(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=Vn(t,this.array)),t}setY(e,t){return this.normalized&&(t=yt(t,this.array)),this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];return this.normalized&&(t=Vn(t,this.array)),t}setZ(e,t){return this.normalized&&(t=yt(t,this.array)),this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];return this.normalized&&(t=Vn(t,this.array)),t}setW(e,t){return this.normalized&&(t=yt(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,i){return e*=this.itemSize,this.normalized&&(t=yt(t,this.array),i=yt(i,this.array)),this.array[e+0]=t,this.array[e+1]=i,this}setXYZ(e,t,i,s){return e*=this.itemSize,this.normalized&&(t=yt(t,this.array),i=yt(i,this.array),s=yt(s,this.array)),this.array[e+0]=t,this.array[e+1]=i,this.array[e+2]=s,this}setXYZW(e,t,i,s,r){return e*=this.itemSize,this.normalized&&(t=yt(t,this.array),i=yt(i,this.array),s=yt(s,this.array),r=yt(r,this.array)),this.array[e+0]=t,this.array[e+1]=i,this.array[e+2]=s,this.array[e+3]=r,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(e.name=this.name),this.usage!==Gc&&(e.usage=this.usage),e}dispose(){this.dispatchEvent({type:"dispose"})}}class Kf extends Dn{constructor(e,t,i){super(new Uint16Array(e),t,i)}}class qf extends Dn{constructor(e,t,i){super(new Uint32Array(e),t,i)}}class dt extends Dn{constructor(e,t,i){super(new Float32Array(e),t,i)}}const ag=new mn,Ar=new k,_l=new k;class pr{constructor(e=new k,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){const i=this.center;t!==void 0?i.copy(t):ag.setFromPoints(e).getCenter(i);let s=0;for(let r=0,a=e.length;r<a;r++)s=Math.max(s,i.distanceToSquared(e[r]));return this.radius=Math.sqrt(s),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){const t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){const i=this.center.distanceToSquared(e);return t.copy(e),i>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;Ar.subVectors(e,this.center);const t=Ar.lengthSq();if(t>this.radius*this.radius){const i=Math.sqrt(t),s=(i-this.radius)*.5;this.center.addScaledVector(Ar,s/i),this.radius+=s}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(_l.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Ar.copy(e.center).add(_l)),this.expandByPoint(Ar.copy(e.center).sub(_l))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}}let og=0;const Tn=new Rt,xl=new hn,ks=new k,vn=new mn,Er=new mn,Xt=new k;class wt extends es{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:og++}),this.uuid=ci(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={},this._transformed=!1}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(Em(e)?qf:Kf)(e,1):this.index=e,this}setIndirect(e,t=0){return this.indirect=e,this.indirectOffset=t,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,i=0){this.groups.push({start:e,count:t,materialIndex:i})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){const t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);const i=this.attributes.normal;if(i!==void 0){const r=new et().getNormalMatrix(e);i.applyNormalMatrix(r),i.needsUpdate=!0}const s=this.attributes.tangent;return s!==void 0&&(s.transformDirection(e),s.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this._transformed=!0,this}applyQuaternion(e){return Tn.makeRotationFromQuaternion(e),this.applyMatrix4(Tn),this}rotateX(e){return Tn.makeRotationX(e),this.applyMatrix4(Tn),this}rotateY(e){return Tn.makeRotationY(e),this.applyMatrix4(Tn),this}rotateZ(e){return Tn.makeRotationZ(e),this.applyMatrix4(Tn),this}translate(e,t,i){return Tn.makeTranslation(e,t,i),this.applyMatrix4(Tn),this}scale(e,t,i){return Tn.makeScale(e,t,i),this.applyMatrix4(Tn),this}lookAt(e){return xl.lookAt(e),xl.updateMatrix(),this.applyMatrix4(xl.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(ks).negate(),this.translate(ks.x,ks.y,ks.z),this}setFromPoints(e){const t=this.getAttribute("position");if(t===void 0){const i=[];for(let s=0,r=e.length;s<r;s++){const a=e[s];i.push(a.x,a.y,a.z||0)}this.setAttribute("position",new dt(i,3))}else{const i=Math.min(e.length,t.count);for(let s=0;s<i;s++){const r=e[s];t.setXYZ(s,r.x,r.y,r.z||0)}e.length>t.count&&$e("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new mn);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){ut("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new k(-1/0,-1/0,-1/0),new k(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let i=0,s=t.length;i<s;i++){const r=t[i];vn.setFromBufferAttribute(r),this.morphTargetsRelative?(Xt.addVectors(this.boundingBox.min,vn.min),this.boundingBox.expandByPoint(Xt),Xt.addVectors(this.boundingBox.max,vn.max),this.boundingBox.expandByPoint(Xt)):(this.boundingBox.expandByPoint(vn.min),this.boundingBox.expandByPoint(vn.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&ut('BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new pr);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){ut("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new k,1/0);return}if(e){const i=this.boundingSphere.center;if(vn.setFromBufferAttribute(e),t)for(let r=0,a=t.length;r<a;r++){const o=t[r];Er.setFromBufferAttribute(o),this.morphTargetsRelative?(Xt.addVectors(vn.min,Er.min),vn.expandByPoint(Xt),Xt.addVectors(vn.max,Er.max),vn.expandByPoint(Xt)):(vn.expandByPoint(Er.min),vn.expandByPoint(Er.max))}vn.getCenter(i);let s=0;for(let r=0,a=e.count;r<a;r++)Xt.fromBufferAttribute(e,r),s=Math.max(s,i.distanceToSquared(Xt));if(t)for(let r=0,a=t.length;r<a;r++){const o=t[r],l=this.morphTargetsRelative;for(let c=0,u=o.count;c<u;c++)Xt.fromBufferAttribute(o,c),l&&(ks.fromBufferAttribute(e,c),Xt.add(ks)),s=Math.max(s,i.distanceToSquared(Xt))}this.boundingSphere.radius=Math.sqrt(s),isNaN(this.boundingSphere.radius)&&ut('BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){ut("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const i=t.position,s=t.normal,r=t.uv;let a=this.getAttribute("tangent");(a===void 0||a.count!==i.count)&&(a=new Dn(new Float32Array(4*i.count),4),this.setAttribute("tangent",a));const o=[],l=[];for(let y=0;y<i.count;y++)o[y]=new k,l[y]=new k;const c=new k,u=new k,h=new k,d=new Le,f=new Le,p=new Le,_=new k,m=new k;function g(y,T,L){c.fromBufferAttribute(i,y),u.fromBufferAttribute(i,T),h.fromBufferAttribute(i,L),d.fromBufferAttribute(r,y),f.fromBufferAttribute(r,T),p.fromBufferAttribute(r,L),u.sub(c),h.sub(c),f.sub(d),p.sub(d);const R=1/(f.x*p.y-p.x*f.y);isFinite(R)&&(_.copy(u).multiplyScalar(p.y).addScaledVector(h,-f.y).multiplyScalar(R),m.copy(h).multiplyScalar(f.x).addScaledVector(u,-p.x).multiplyScalar(R),o[y].add(_),o[T].add(_),o[L].add(_),l[y].add(m),l[T].add(m),l[L].add(m))}let v=this.groups;v.length===0&&(v=[{start:0,count:e.count}]);for(let y=0,T=v.length;y<T;++y){const L=v[y],R=L.start,w=L.count;for(let P=R,U=R+w;P<U;P+=3)g(e.getX(P+0),e.getX(P+1),e.getX(P+2))}const b=new k,x=new k,E=new k,S=new k;function A(y){E.fromBufferAttribute(s,y),S.copy(E);const T=o[y];b.copy(T),b.sub(E.multiplyScalar(E.dot(T))).normalize(),x.crossVectors(S,T);const R=x.dot(l[y])<0?-1:1;a.setXYZW(y,b.x,b.y,b.z,R)}for(let y=0,T=v.length;y<T;++y){const L=v[y],R=L.start,w=L.count;for(let P=R,U=R+w;P<U;P+=3)A(e.getX(P+0)),A(e.getX(P+1)),A(e.getX(P+2))}this._transformed=!0}computeVertexNormals(){const e=this.index,t=this.getAttribute("position");if(t!==void 0){let i=this.getAttribute("normal");if(i===void 0||i.count!==t.count)i=new Dn(new Float32Array(t.count*3),3),this.setAttribute("normal",i);else for(let d=0,f=i.count;d<f;d++)i.setXYZ(d,0,0,0);const s=new k,r=new k,a=new k,o=new k,l=new k,c=new k,u=new k,h=new k;if(e)for(let d=0,f=e.count;d<f;d+=3){const p=e.getX(d+0),_=e.getX(d+1),m=e.getX(d+2);s.fromBufferAttribute(t,p),r.fromBufferAttribute(t,_),a.fromBufferAttribute(t,m),u.subVectors(a,r),h.subVectors(s,r),u.cross(h),o.fromBufferAttribute(i,p),l.fromBufferAttribute(i,_),c.fromBufferAttribute(i,m),o.add(u),l.add(u),c.add(u),i.setXYZ(p,o.x,o.y,o.z),i.setXYZ(_,l.x,l.y,l.z),i.setXYZ(m,c.x,c.y,c.z)}else for(let d=0,f=t.count;d<f;d+=3)s.fromBufferAttribute(t,d+0),r.fromBufferAttribute(t,d+1),a.fromBufferAttribute(t,d+2),u.subVectors(a,r),h.subVectors(s,r),u.cross(h),i.setXYZ(d+0,u.x,u.y,u.z),i.setXYZ(d+1,u.x,u.y,u.z),i.setXYZ(d+2,u.x,u.y,u.z);this.normalizeNormals(),i.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let t=0,i=e.count;t<i;t++)Xt.fromBufferAttribute(e,t),Xt.normalize(),e.setXYZ(t,Xt.x,Xt.y,Xt.z)}toNonIndexed(){function e(o,l){const c=o.array,u=o.itemSize,h=o.normalized,d=new c.constructor(l.length*u);let f=0,p=0;for(let _=0,m=l.length;_<m;_++){o.isInterleavedBufferAttribute?f=l[_]*o.data.stride+o.offset:f=l[_]*u;for(let g=0;g<u;g++)d[p++]=c[f++]}return new Dn(d,u,h)}if(this.index===null)return $e("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const t=new wt,i=this.index.array,s=this.attributes;for(const o in s){const l=s[o],c=e(l,i);t.setAttribute(o,c)}const r=this.morphAttributes;for(const o in r){const l=[],c=r[o];for(let u=0,h=c.length;u<h;u++){const d=c[u],f=e(d,i);l.push(f)}t.morphAttributes[o]=l}t.morphTargetsRelative=this.morphTargetsRelative;const a=this.groups;for(let o=0,l=a.length;o<l;o++){const c=a[o];t.addGroup(c.start,c.count,c.materialIndex)}return t}toJSON(){const e={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.parameters!==void 0&&this._transformed===!0?"BufferGeometry":this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0&&this._transformed!==!0){const l=this.parameters;for(const c in l)l[c]!==void 0&&(e[c]=l[c]);return e}e.data={attributes:{}};const t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const i=this.attributes;for(const l in i){const c=i[l];e.data.attributes[l]=c.toJSON(e.data)}const s={};let r=!1;for(const l in this.morphAttributes){const c=this.morphAttributes[l],u=[];for(let h=0,d=c.length;h<d;h++){const f=c[h];u.push(f.toJSON(e.data))}u.length>0&&(s[l]=u,r=!0)}r&&(e.data.morphAttributes=s,e.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));const o=this.boundingSphere;return o!==null&&(e.data.boundingSphere=o.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const i=e.index;i!==null&&this.setIndex(i.clone());const s=e.attributes;for(const c in s){const u=s[c];this.setAttribute(c,u.clone(t))}const r=e.morphAttributes;for(const c in r){const u=[],h=r[c];for(let d=0,f=h.length;d<f;d++)u.push(h[d].clone(t));this.morphAttributes[c]=u}this.morphTargetsRelative=e.morphTargetsRelative;const a=e.groups;for(let c=0,u=a.length;c<u;c++){const h=a[c];this.addGroup(h.start,h.count,h.materialIndex)}const o=e.boundingBox;o!==null&&(this.boundingBox=o.clone());const l=e.boundingSphere;return l!==null&&(this.boundingSphere=l.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this._transformed=e._transformed,this}dispose(){this.dispatchEvent({type:"dispose"})}}class $f{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=Gc,this.updateRanges=[],this.version=0,this.uuid=ci()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,i){e*=this.stride,i*=t.stride;for(let s=0,r=this.stride;s<r;s++)this.array[e+s]=t.array[i+s];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=ci()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),i=new this.constructor(t,this.stride);return i.setUsage(this.usage),i}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=ci()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}}const ln=new k;class ai{constructor(e,t,i,s=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=i,this.normalized=s}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,i=this.data.count;t<i;t++)ln.fromBufferAttribute(this,t),ln.applyMatrix4(e),this.setXYZ(t,ln.x,ln.y,ln.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)ln.fromBufferAttribute(this,t),ln.applyNormalMatrix(e),this.setXYZ(t,ln.x,ln.y,ln.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)ln.fromBufferAttribute(this,t),ln.transformDirection(e),this.setXYZ(t,ln.x,ln.y,ln.z);return this}getComponent(e,t){let i=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(i=Vn(i,this.array)),i}setComponent(e,t,i){return this.normalized&&(i=yt(i,this.array)),this.data.array[e*this.data.stride+this.offset+t]=i,this}setX(e,t){return this.normalized&&(t=yt(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=yt(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=yt(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=yt(t,this.array)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=Vn(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=Vn(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=Vn(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=Vn(t,this.array)),t}setXY(e,t,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=yt(t,this.array),i=yt(i,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this}setXYZ(e,t,i,s){return e=e*this.data.stride+this.offset,this.normalized&&(t=yt(t,this.array),i=yt(i,this.array),s=yt(s,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=s,this}setXYZW(e,t,i,s,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=yt(t,this.array),i=yt(i,this.array),s=yt(s,this.array),r=yt(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=s,this.data.array[e+3]=r,this}clone(e){if(e===void 0){Eo("InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let i=0;i<this.count;i++){const s=i*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)t.push(this.data.array[s+r])}return new Dn(new this.array.constructor(t),this.itemSize,this.normalized)}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new ai(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){Eo("InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let i=0;i<this.count;i++){const s=i*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)t.push(this.data.array[s+r])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}let lg=0;class mr extends es{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:lg++}),this.uuid=ci(),this.name="",this.type="Material",this.blending=er,this.side=Zi,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=nc,this.blendDst=ic,this.blendEquation=ls,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new it(0,0,0),this.blendAlpha=0,this.depthFunc=sr,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=nh,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Cs,this.stencilZFail=Cs,this.stencilZPass=Cs,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const t in e){const i=e[t];if(i===void 0){$e(`Material: parameter '${t}' has value of undefined.`);continue}const s=this[t];if(s===void 0){$e(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}s&&s.isColor?s.set(i):s&&s.isVector2&&i&&i.isVector2||s&&s.isEuler&&i&&i.isEuler||s&&s.isVector3&&i&&i.isVector3?s.copy(i):this[t]=i}}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});const i={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.color&&this.color.isColor&&(i.color=this.color.getHex()),this.roughness!==void 0&&(i.roughness=this.roughness),this.metalness!==void 0&&(i.metalness=this.metalness),this.sheen!==void 0&&(i.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(i.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(i.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(i.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(i.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(i.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(i.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(i.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(i.shininess=this.shininess),this.clearcoat!==void 0&&(i.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(i.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(i.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(i.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(i.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,i.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(i.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(i.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),this.dispersion!==void 0&&(i.dispersion=this.dispersion),this.iridescence!==void 0&&(i.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(i.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(i.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(i.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(i.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(i.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(i.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(i.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(i.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(i.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(i.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(i.lightMap=this.lightMap.toJSON(e).uuid,i.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(i.aoMap=this.aoMap.toJSON(e).uuid,i.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(i.bumpMap=this.bumpMap.toJSON(e).uuid,i.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(i.normalMap=this.normalMap.toJSON(e).uuid,i.normalMapType=this.normalMapType,i.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(i.displacementMap=this.displacementMap.toJSON(e).uuid,i.displacementScale=this.displacementScale,i.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(i.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(i.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(i.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(i.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(i.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(i.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(i.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(i.combine=this.combine)),this.envMapRotation!==void 0&&(i.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(i.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(i.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(i.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(i.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(i.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(i.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(i.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(i.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(i.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(i.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(i.size=this.size),this.shadowSide!==null&&(i.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(i.sizeAttenuation=this.sizeAttenuation),this.blending!==er&&(i.blending=this.blending),this.side!==Zi&&(i.side=this.side),this.vertexColors===!0&&(i.vertexColors=!0),this.opacity<1&&(i.opacity=this.opacity),this.transparent===!0&&(i.transparent=!0),this.blendSrc!==nc&&(i.blendSrc=this.blendSrc),this.blendDst!==ic&&(i.blendDst=this.blendDst),this.blendEquation!==ls&&(i.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(i.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(i.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(i.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(i.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(i.blendAlpha=this.blendAlpha),this.depthFunc!==sr&&(i.depthFunc=this.depthFunc),this.depthTest===!1&&(i.depthTest=this.depthTest),this.depthWrite===!1&&(i.depthWrite=this.depthWrite),this.colorWrite===!1&&(i.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(i.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==nh&&(i.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(i.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(i.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Cs&&(i.stencilFail=this.stencilFail),this.stencilZFail!==Cs&&(i.stencilZFail=this.stencilZFail),this.stencilZPass!==Cs&&(i.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(i.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(i.rotation=this.rotation),this.polygonOffset===!0&&(i.polygonOffset=!0),this.polygonOffsetFactor!==0&&(i.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(i.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(i.linewidth=this.linewidth),this.dashSize!==void 0&&(i.dashSize=this.dashSize),this.gapSize!==void 0&&(i.gapSize=this.gapSize),this.scale!==void 0&&(i.scale=this.scale),this.dithering===!0&&(i.dithering=!0),this.alphaTest>0&&(i.alphaTest=this.alphaTest),this.alphaHash===!0&&(i.alphaHash=!0),this.alphaToCoverage===!0&&(i.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(i.premultipliedAlpha=!0),this.forceSinglePass===!0&&(i.forceSinglePass=!0),this.allowOverride===!1&&(i.allowOverride=!1),this.wireframe===!0&&(i.wireframe=!0),this.wireframeLinewidth>1&&(i.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(i.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(i.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(i.flatShading=!0),this.visible===!1&&(i.visible=!1),this.toneMapped===!1&&(i.toneMapped=!1),this.fog===!1&&(i.fog=!1),Object.keys(this.userData).length>0&&(i.userData=this.userData);function s(r){const a=[];for(const o in r){const l=r[o];delete l.metadata,a.push(l)}return a}if(t){const r=s(e.textures),a=s(e.images);r.length>0&&(i.textures=r),a.length>0&&(i.images=a)}return i}fromJSON(e,t){if(e.uuid!==void 0&&(this.uuid=e.uuid),e.name!==void 0&&(this.name=e.name),e.color!==void 0&&this.color!==void 0&&this.color.setHex(e.color),e.roughness!==void 0&&(this.roughness=e.roughness),e.metalness!==void 0&&(this.metalness=e.metalness),e.sheen!==void 0&&(this.sheen=e.sheen),e.sheenColor!==void 0&&(this.sheenColor=new it().setHex(e.sheenColor)),e.sheenRoughness!==void 0&&(this.sheenRoughness=e.sheenRoughness),e.emissive!==void 0&&this.emissive!==void 0&&this.emissive.setHex(e.emissive),e.specular!==void 0&&this.specular!==void 0&&this.specular.setHex(e.specular),e.specularIntensity!==void 0&&(this.specularIntensity=e.specularIntensity),e.specularColor!==void 0&&this.specularColor!==void 0&&this.specularColor.setHex(e.specularColor),e.shininess!==void 0&&(this.shininess=e.shininess),e.clearcoat!==void 0&&(this.clearcoat=e.clearcoat),e.clearcoatRoughness!==void 0&&(this.clearcoatRoughness=e.clearcoatRoughness),e.dispersion!==void 0&&(this.dispersion=e.dispersion),e.iridescence!==void 0&&(this.iridescence=e.iridescence),e.iridescenceIOR!==void 0&&(this.iridescenceIOR=e.iridescenceIOR),e.iridescenceThicknessRange!==void 0&&(this.iridescenceThicknessRange=e.iridescenceThicknessRange),e.transmission!==void 0&&(this.transmission=e.transmission),e.thickness!==void 0&&(this.thickness=e.thickness),e.attenuationDistance!==void 0&&(this.attenuationDistance=e.attenuationDistance),e.attenuationColor!==void 0&&this.attenuationColor!==void 0&&this.attenuationColor.setHex(e.attenuationColor),e.anisotropy!==void 0&&(this.anisotropy=e.anisotropy),e.anisotropyRotation!==void 0&&(this.anisotropyRotation=e.anisotropyRotation),e.fog!==void 0&&(this.fog=e.fog),e.flatShading!==void 0&&(this.flatShading=e.flatShading),e.blending!==void 0&&(this.blending=e.blending),e.combine!==void 0&&(this.combine=e.combine),e.side!==void 0&&(this.side=e.side),e.shadowSide!==void 0&&(this.shadowSide=e.shadowSide),e.opacity!==void 0&&(this.opacity=e.opacity),e.transparent!==void 0&&(this.transparent=e.transparent),e.alphaTest!==void 0&&(this.alphaTest=e.alphaTest),e.alphaHash!==void 0&&(this.alphaHash=e.alphaHash),e.depthFunc!==void 0&&(this.depthFunc=e.depthFunc),e.depthTest!==void 0&&(this.depthTest=e.depthTest),e.depthWrite!==void 0&&(this.depthWrite=e.depthWrite),e.colorWrite!==void 0&&(this.colorWrite=e.colorWrite),e.blendSrc!==void 0&&(this.blendSrc=e.blendSrc),e.blendDst!==void 0&&(this.blendDst=e.blendDst),e.blendEquation!==void 0&&(this.blendEquation=e.blendEquation),e.blendSrcAlpha!==void 0&&(this.blendSrcAlpha=e.blendSrcAlpha),e.blendDstAlpha!==void 0&&(this.blendDstAlpha=e.blendDstAlpha),e.blendEquationAlpha!==void 0&&(this.blendEquationAlpha=e.blendEquationAlpha),e.blendColor!==void 0&&this.blendColor!==void 0&&this.blendColor.setHex(e.blendColor),e.blendAlpha!==void 0&&(this.blendAlpha=e.blendAlpha),e.stencilWriteMask!==void 0&&(this.stencilWriteMask=e.stencilWriteMask),e.stencilFunc!==void 0&&(this.stencilFunc=e.stencilFunc),e.stencilRef!==void 0&&(this.stencilRef=e.stencilRef),e.stencilFuncMask!==void 0&&(this.stencilFuncMask=e.stencilFuncMask),e.stencilFail!==void 0&&(this.stencilFail=e.stencilFail),e.stencilZFail!==void 0&&(this.stencilZFail=e.stencilZFail),e.stencilZPass!==void 0&&(this.stencilZPass=e.stencilZPass),e.stencilWrite!==void 0&&(this.stencilWrite=e.stencilWrite),e.wireframe!==void 0&&(this.wireframe=e.wireframe),e.wireframeLinewidth!==void 0&&(this.wireframeLinewidth=e.wireframeLinewidth),e.wireframeLinecap!==void 0&&(this.wireframeLinecap=e.wireframeLinecap),e.wireframeLinejoin!==void 0&&(this.wireframeLinejoin=e.wireframeLinejoin),e.rotation!==void 0&&(this.rotation=e.rotation),e.linewidth!==void 0&&(this.linewidth=e.linewidth),e.dashSize!==void 0&&(this.dashSize=e.dashSize),e.gapSize!==void 0&&(this.gapSize=e.gapSize),e.scale!==void 0&&(this.scale=e.scale),e.polygonOffset!==void 0&&(this.polygonOffset=e.polygonOffset),e.polygonOffsetFactor!==void 0&&(this.polygonOffsetFactor=e.polygonOffsetFactor),e.polygonOffsetUnits!==void 0&&(this.polygonOffsetUnits=e.polygonOffsetUnits),e.dithering!==void 0&&(this.dithering=e.dithering),e.alphaToCoverage!==void 0&&(this.alphaToCoverage=e.alphaToCoverage),e.premultipliedAlpha!==void 0&&(this.premultipliedAlpha=e.premultipliedAlpha),e.forceSinglePass!==void 0&&(this.forceSinglePass=e.forceSinglePass),e.allowOverride!==void 0&&(this.allowOverride=e.allowOverride),e.visible!==void 0&&(this.visible=e.visible),e.toneMapped!==void 0&&(this.toneMapped=e.toneMapped),e.userData!==void 0&&(this.userData=e.userData),e.vertexColors!==void 0&&(typeof e.vertexColors=="number"?this.vertexColors=e.vertexColors>0:this.vertexColors=e.vertexColors),e.size!==void 0&&(this.size=e.size),e.sizeAttenuation!==void 0&&(this.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(this.map=t[e.map]||null),e.matcap!==void 0&&(this.matcap=t[e.matcap]||null),e.alphaMap!==void 0&&(this.alphaMap=t[e.alphaMap]||null),e.bumpMap!==void 0&&(this.bumpMap=t[e.bumpMap]||null),e.bumpScale!==void 0&&(this.bumpScale=e.bumpScale),e.normalMap!==void 0&&(this.normalMap=t[e.normalMap]||null),e.normalMapType!==void 0&&(this.normalMapType=e.normalMapType),e.normalScale!==void 0){let i=e.normalScale;Array.isArray(i)===!1&&(i=[i,i]),this.normalScale=new Le().fromArray(i)}return e.displacementMap!==void 0&&(this.displacementMap=t[e.displacementMap]||null),e.displacementScale!==void 0&&(this.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(this.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(this.roughnessMap=t[e.roughnessMap]||null),e.metalnessMap!==void 0&&(this.metalnessMap=t[e.metalnessMap]||null),e.emissiveMap!==void 0&&(this.emissiveMap=t[e.emissiveMap]||null),e.emissiveIntensity!==void 0&&(this.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(this.specularMap=t[e.specularMap]||null),e.specularIntensityMap!==void 0&&(this.specularIntensityMap=t[e.specularIntensityMap]||null),e.specularColorMap!==void 0&&(this.specularColorMap=t[e.specularColorMap]||null),e.envMap!==void 0&&(this.envMap=t[e.envMap]||null),e.envMapRotation!==void 0&&this.envMapRotation.fromArray(e.envMapRotation),e.envMapIntensity!==void 0&&(this.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(this.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(this.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(this.lightMap=t[e.lightMap]||null),e.lightMapIntensity!==void 0&&(this.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(this.aoMap=t[e.aoMap]||null),e.aoMapIntensity!==void 0&&(this.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(this.gradientMap=t[e.gradientMap]||null),e.clearcoatMap!==void 0&&(this.clearcoatMap=t[e.clearcoatMap]||null),e.clearcoatRoughnessMap!==void 0&&(this.clearcoatRoughnessMap=t[e.clearcoatRoughnessMap]||null),e.clearcoatNormalMap!==void 0&&(this.clearcoatNormalMap=t[e.clearcoatNormalMap]||null),e.clearcoatNormalScale!==void 0&&(this.clearcoatNormalScale=new Le().fromArray(e.clearcoatNormalScale)),e.iridescenceMap!==void 0&&(this.iridescenceMap=t[e.iridescenceMap]||null),e.iridescenceThicknessMap!==void 0&&(this.iridescenceThicknessMap=t[e.iridescenceThicknessMap]||null),e.transmissionMap!==void 0&&(this.transmissionMap=t[e.transmissionMap]||null),e.thicknessMap!==void 0&&(this.thicknessMap=t[e.thicknessMap]||null),e.anisotropyMap!==void 0&&(this.anisotropyMap=t[e.anisotropyMap]||null),e.sheenColorMap!==void 0&&(this.sheenColorMap=t[e.sheenColorMap]||null),e.sheenRoughnessMap!==void 0&&(this.sheenRoughnessMap=t[e.sheenRoughnessMap]||null),this}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const t=e.clippingPlanes;let i=null;if(t!==null){const s=t.length;i=new Array(s);for(let r=0;r!==s;++r)i[r]=t[r].clone()}return this.clippingPlanes=i,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.allowOverride=e.allowOverride,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}}class Xc extends mr{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new it(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.rotation=e.rotation,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}let Fs;const Tr=new k,Bs=new k,Hs=new k,zs=new Le,Cr=new Le,Zf=new Rt,ba=new k,wr=new k,Ma=new k,gh=new Le,yl=new Le,_h=new Le;class xh extends hn{constructor(e=new Xc){if(super(),this.isSprite=!0,this.type="Sprite",Fs===void 0){Fs=new wt;const t=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),i=new $f(t,5);Fs.setIndex([0,1,2,0,2,3]),Fs.setAttribute("position",new ai(i,3,0,!1)),Fs.setAttribute("uv",new ai(i,2,3,!1))}this.geometry=Fs,this.material=e,this.center=new Le(.5,.5),this.count=1}raycast(e,t){e.camera===null&&ut('Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),Bs.setFromMatrixScale(this.matrixWorld),Zf.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),Hs.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&Bs.multiplyScalar(-Hs.z);const i=this.material.rotation;let s,r;i!==0&&(r=Math.cos(i),s=Math.sin(i));const a=this.center;Aa(ba.set(-.5,-.5,0),Hs,a,Bs,s,r),Aa(wr.set(.5,-.5,0),Hs,a,Bs,s,r),Aa(Ma.set(.5,.5,0),Hs,a,Bs,s,r),gh.set(0,0),yl.set(1,0),_h.set(1,1);let o=e.ray.intersectTriangle(ba,wr,Ma,!1,Tr);if(o===null&&(Aa(wr.set(-.5,.5,0),Hs,a,Bs,s,r),yl.set(0,1),o=e.ray.intersectTriangle(ba,Ma,wr,!1,Tr),o===null))return;const l=e.ray.origin.distanceTo(Tr);l<e.near||l>e.far||t.push({distance:l,point:Tr.clone(),uv:Rn.getInterpolation(Tr,ba,wr,Ma,gh,yl,_h,new Le),face:null,object:this})}copy(e,t){return super.copy(e,t),e.center!==void 0&&this.center.copy(e.center),this.material=e.material,this}}function Aa(n,e,t,i,s,r){zs.subVectors(n,t).addScalar(.5).multiply(i),s!==void 0?(Cr.x=r*zs.x-s*zs.y,Cr.y=s*zs.x+r*zs.y):Cr.copy(zs),n.copy(e),n.x+=Cr.x,n.y+=Cr.y,n.applyMatrix4(Zf)}const yi=new k,vl=new k,Ea=new k,Fi=new k,Sl=new k,Ta=new k,bl=new k;class bu{constructor(e=new k,t=new k(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,yi)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const i=t.dot(this.direction);return i<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,i)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=yi.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(yi.copy(this.origin).addScaledVector(this.direction,t),yi.distanceToSquared(e))}distanceSqToSegment(e,t,i,s){vl.copy(e).add(t).multiplyScalar(.5),Ea.copy(t).sub(e).normalize(),Fi.copy(this.origin).sub(vl);const r=e.distanceTo(t)*.5,a=-this.direction.dot(Ea),o=Fi.dot(this.direction),l=-Fi.dot(Ea),c=Fi.lengthSq(),u=Math.abs(1-a*a);let h,d,f,p;if(u>0)if(h=a*l-o,d=a*o-l,p=r*u,h>=0)if(d>=-p)if(d<=p){const _=1/u;h*=_,d*=_,f=h*(h+a*d+2*o)+d*(a*h+d+2*l)+c}else d=r,h=Math.max(0,-(a*d+o)),f=-h*h+d*(d+2*l)+c;else d=-r,h=Math.max(0,-(a*d+o)),f=-h*h+d*(d+2*l)+c;else d<=-p?(h=Math.max(0,-(-a*r+o)),d=h>0?-r:Math.min(Math.max(-r,-l),r),f=-h*h+d*(d+2*l)+c):d<=p?(h=0,d=Math.min(Math.max(-r,-l),r),f=d*(d+2*l)+c):(h=Math.max(0,-(a*r+o)),d=h>0?r:Math.min(Math.max(-r,-l),r),f=-h*h+d*(d+2*l)+c);else d=a>0?-r:r,h=Math.max(0,-(a*d+o)),f=-h*h+d*(d+2*l)+c;return i&&i.copy(this.origin).addScaledVector(this.direction,h),s&&s.copy(vl).addScaledVector(Ea,d),f}intersectSphere(e,t){yi.subVectors(e.center,this.origin);const i=yi.dot(this.direction),s=yi.dot(yi)-i*i,r=e.radius*e.radius;if(s>r)return null;const a=Math.sqrt(r-s),o=i-a,l=i+a;return l<0?null:o<0?this.at(l,t):this.at(o,t)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;const i=-(this.origin.dot(e.normal)+e.constant)/t;return i>=0?i:null}intersectPlane(e,t){const i=this.distanceToPlane(e);return i===null?null:this.at(i,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let i,s,r,a,o,l;const c=1/this.direction.x,u=1/this.direction.y,h=1/this.direction.z,d=this.origin;return c>=0?(i=(e.min.x-d.x)*c,s=(e.max.x-d.x)*c):(i=(e.max.x-d.x)*c,s=(e.min.x-d.x)*c),u>=0?(r=(e.min.y-d.y)*u,a=(e.max.y-d.y)*u):(r=(e.max.y-d.y)*u,a=(e.min.y-d.y)*u),i>a||r>s||((r>i||isNaN(i))&&(i=r),(a<s||isNaN(s))&&(s=a),h>=0?(o=(e.min.z-d.z)*h,l=(e.max.z-d.z)*h):(o=(e.max.z-d.z)*h,l=(e.min.z-d.z)*h),i>l||o>s)||((o>i||i!==i)&&(i=o),(l<s||s!==s)&&(s=l),s<0)?null:this.at(i>=0?i:s,t)}intersectsBox(e){return this.intersectBox(e,yi)!==null}intersectTriangle(e,t,i,s,r){Sl.subVectors(t,e),Ta.subVectors(i,e),bl.crossVectors(Sl,Ta);let a=this.direction.dot(bl),o;if(a>0){if(s)return null;o=1}else if(a<0)o=-1,a=-a;else return null;Fi.subVectors(this.origin,e);const l=o*this.direction.dot(Ta.crossVectors(Fi,Ta));if(l<0)return null;const c=o*this.direction.dot(Sl.cross(Fi));if(c<0||l+c>a)return null;const u=-o*Fi.dot(bl);return u<0?null:this.at(u/a,r)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class ti extends mr{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new it(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new _s,this.combine=Tf,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}const yh=new Rt,ss=new bu,Ca=new pr,vh=new k,wa=new k,Ra=new k,La=new k,Ml=new k,Da=new k,Sh=new k,Ia=new k;class Ht extends hn{constructor(e=new wt,t=new ti){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){const t=this.geometry.morphAttributes,i=Object.keys(t);if(i.length>0){const s=t[i[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=s.length;r<a;r++){const o=s[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}getVertexPosition(e,t){const i=this.geometry,s=i.attributes.position,r=i.morphAttributes.position,a=i.morphTargetsRelative;t.fromBufferAttribute(s,e);const o=this.morphTargetInfluences;if(r&&o){Da.set(0,0,0);for(let l=0,c=r.length;l<c;l++){const u=o[l],h=r[l];u!==0&&(Ml.fromBufferAttribute(h,e),a?Da.addScaledVector(Ml,u):Da.addScaledVector(Ml.sub(t),u))}t.add(Da)}return t}raycast(e,t){const i=this.geometry,s=this.material,r=this.matrixWorld;s!==void 0&&(i.boundingSphere===null&&i.computeBoundingSphere(),Ca.copy(i.boundingSphere),Ca.applyMatrix4(r),ss.copy(e.ray).recast(e.near),!(Ca.containsPoint(ss.origin)===!1&&(ss.intersectSphere(Ca,vh)===null||ss.origin.distanceToSquared(vh)>(e.far-e.near)**2))&&(yh.copy(r).invert(),ss.copy(e.ray).applyMatrix4(yh),!(i.boundingBox!==null&&ss.intersectsBox(i.boundingBox)===!1)&&this._computeIntersections(e,t,ss)))}_computeIntersections(e,t,i){let s;const r=this.geometry,a=this.material,o=r.index,l=r.attributes.position,c=r.attributes.uv,u=r.attributes.uv1,h=r.attributes.normal,d=r.groups,f=r.drawRange;if(o!==null)if(Array.isArray(a))for(let p=0,_=d.length;p<_;p++){const m=d[p],g=a[m.materialIndex],v=Math.max(m.start,f.start),b=Math.min(o.count,Math.min(m.start+m.count,f.start+f.count));for(let x=v,E=b;x<E;x+=3){const S=o.getX(x),A=o.getX(x+1),y=o.getX(x+2);s=Pa(this,g,e,i,c,u,h,S,A,y),s&&(s.faceIndex=Math.floor(x/3),s.face.materialIndex=m.materialIndex,t.push(s))}}else{const p=Math.max(0,f.start),_=Math.min(o.count,f.start+f.count);for(let m=p,g=_;m<g;m+=3){const v=o.getX(m),b=o.getX(m+1),x=o.getX(m+2);s=Pa(this,a,e,i,c,u,h,v,b,x),s&&(s.faceIndex=Math.floor(m/3),t.push(s))}}else if(l!==void 0)if(Array.isArray(a))for(let p=0,_=d.length;p<_;p++){const m=d[p],g=a[m.materialIndex],v=Math.max(m.start,f.start),b=Math.min(l.count,Math.min(m.start+m.count,f.start+f.count));for(let x=v,E=b;x<E;x+=3){const S=x,A=x+1,y=x+2;s=Pa(this,g,e,i,c,u,h,S,A,y),s&&(s.faceIndex=Math.floor(x/3),s.face.materialIndex=m.materialIndex,t.push(s))}}else{const p=Math.max(0,f.start),_=Math.min(l.count,f.start+f.count);for(let m=p,g=_;m<g;m+=3){const v=m,b=m+1,x=m+2;s=Pa(this,a,e,i,c,u,h,v,b,x),s&&(s.faceIndex=Math.floor(m/3),t.push(s))}}}}function cg(n,e,t,i,s,r,a,o){let l;if(e.side===_n?l=i.intersectTriangle(a,r,s,!0,o):l=i.intersectTriangle(s,r,a,e.side===Zi,o),l===null)return null;Ia.copy(o),Ia.applyMatrix4(n.matrixWorld);const c=t.ray.origin.distanceTo(Ia);return c<t.near||c>t.far?null:{distance:c,point:Ia.clone(),object:n}}function Pa(n,e,t,i,s,r,a,o,l,c){n.getVertexPosition(o,wa),n.getVertexPosition(l,Ra),n.getVertexPosition(c,La);const u=cg(n,e,t,i,wa,Ra,La,Sh);if(u){const h=new k;Rn.getBarycoord(Sh,wa,Ra,La,h),s&&(u.uv=Rn.getInterpolatedAttribute(s,o,l,c,h,new Le)),r&&(u.uv1=Rn.getInterpolatedAttribute(r,o,l,c,h,new Le)),a&&(u.normal=Rn.getInterpolatedAttribute(a,o,l,c,h,new k),u.normal.dot(i.direction)>0&&u.normal.multiplyScalar(-1));const d={a:o,b:l,c,normal:new k,materialIndex:0};Rn.getNormal(wa,Ra,La,d.normal),u.face=d,u.barycoord=h}return u}class Jf extends sn{constructor(e=null,t=1,i=1,s,r,a,o,l,c=zt,u=zt,h,d){super(null,a,o,l,c,u,s,r,h,d),this.isDataTexture=!0,this.image={data:e,width:t,height:i},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const Al=new k,ug=new k,hg=new et;class Vi{constructor(e=new k(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,i,s){return this.normal.set(e,t,i),this.constant=s,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,i){const s=Al.subVectors(i,t).cross(ug.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(s,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t,i=!0){const s=e.delta(Al),r=this.normal.dot(s);if(r===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;const a=-(e.start.dot(this.normal)+this.constant)/r;return i===!0&&(a<0||a>1)?null:t.copy(e.start).addScaledVector(s,a)}intersectsLine(e){const t=this.distanceToPoint(e.start),i=this.distanceToPoint(e.end);return t<0&&i>0||i<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const i=t||hg.getNormalMatrix(e),s=this.coplanarPoint(Al).applyMatrix4(e),r=this.normal.applyMatrix3(i).normalize();return this.constant=-s.dot(r),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}}const rs=new pr,dg=new Le(.5,.5),Oa=new k;class jf{constructor(e=new Vi,t=new Vi,i=new Vi,s=new Vi,r=new Vi,a=new Vi){this.planes=[e,t,i,s,r,a]}set(e,t,i,s,r,a){const o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(i),o[3].copy(s),o[4].copy(r),o[5].copy(a),this}copy(e){const t=this.planes;for(let i=0;i<6;i++)t[i].copy(e.planes[i]);return this}setFromProjectionMatrix(e,t=ri,i=!1){const s=this.planes,r=e.elements,a=r[0],o=r[1],l=r[2],c=r[3],u=r[4],h=r[5],d=r[6],f=r[7],p=r[8],_=r[9],m=r[10],g=r[11],v=r[12],b=r[13],x=r[14],E=r[15];if(s[0].setComponents(c-a,f-u,g-p,E-v).normalize(),s[1].setComponents(c+a,f+u,g+p,E+v).normalize(),s[2].setComponents(c+o,f+h,g+_,E+b).normalize(),s[3].setComponents(c-o,f-h,g-_,E-b).normalize(),i)s[4].setComponents(l,d,m,x).normalize(),s[5].setComponents(c-l,f-d,g-m,E-x).normalize();else if(s[4].setComponents(c-l,f-d,g-m,E-x).normalize(),t===ri)s[5].setComponents(c+l,f+d,g+m,E+x).normalize();else if(t===Mo)s[5].setComponents(l,d,m,x).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),rs.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),rs.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(rs)}intersectsSprite(e){rs.center.set(0,0,0);const t=dg.distanceTo(e.center);return rs.radius=.7071067811865476+t,rs.applyMatrix4(e.matrixWorld),this.intersectsSphere(rs)}intersectsSphere(e){const t=this.planes,i=e.center,s=-e.radius;for(let r=0;r<6;r++)if(t[r].distanceToPoint(i)<s)return!1;return!0}intersectsBox(e){const t=this.planes;for(let i=0;i<6;i++){const s=t[i];if(Oa.x=s.normal.x>0?e.max.x:e.min.x,Oa.y=s.normal.y>0?e.max.y:e.min.y,Oa.z=s.normal.z>0?e.max.z:e.min.z,s.distanceToPoint(Oa)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let i=0;i<6;i++)if(t[i].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}class js extends mr{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new it(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}const To=new k,Co=new k,bh=new Rt,Rr=new bu,Ua=new pr,El=new k,Mh=new k;let Qf=class extends hn{constructor(e=new wt,t=new js){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,i=[0];for(let s=1,r=t.count;s<r;s++)To.fromBufferAttribute(t,s-1),Co.fromBufferAttribute(t,s),i[s]=i[s-1],i[s]+=To.distanceTo(Co);e.setAttribute("lineDistance",new dt(i,1))}else $e("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){const i=this.geometry,s=this.matrixWorld,r=e.params.Line.threshold,a=i.drawRange;if(i.boundingSphere===null&&i.computeBoundingSphere(),Ua.copy(i.boundingSphere),Ua.applyMatrix4(s),Ua.radius+=r,e.ray.intersectsSphere(Ua)===!1)return;bh.copy(s).invert(),Rr.copy(e.ray).applyMatrix4(bh);const o=r/((this.scale.x+this.scale.y+this.scale.z)/3),l=o*o,c=this.isLineSegments?2:1,u=i.index,d=i.attributes.position;if(u!==null){const f=Math.max(0,a.start),p=Math.min(u.count,a.start+a.count);for(let _=f,m=p-1;_<m;_+=c){const g=u.getX(_),v=u.getX(_+1),b=Na(this,e,Rr,l,g,v,_);b&&t.push(b)}if(this.isLineLoop){const _=u.getX(p-1),m=u.getX(f),g=Na(this,e,Rr,l,_,m,p-1);g&&t.push(g)}}else{const f=Math.max(0,a.start),p=Math.min(d.count,a.start+a.count);for(let _=f,m=p-1;_<m;_+=c){const g=Na(this,e,Rr,l,_,_+1,_);g&&t.push(g)}if(this.isLineLoop){const _=Na(this,e,Rr,l,p-1,f,p-1);_&&t.push(_)}}}updateMorphTargets(){const t=this.geometry.morphAttributes,i=Object.keys(t);if(i.length>0){const s=t[i[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=s.length;r<a;r++){const o=s[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}};function Na(n,e,t,i,s,r,a){const o=n.geometry.attributes.position;if(To.fromBufferAttribute(o,s),Co.fromBufferAttribute(o,r),t.distanceSqToSegment(To,Co,El,Mh)>i)return;El.applyMatrix4(n.matrixWorld);const c=e.ray.origin.distanceTo(El);if(!(c<e.near||c>e.far))return{distance:c,point:Mh.clone().applyMatrix4(n.matrixWorld),index:a,face:null,faceIndex:null,barycoord:null,object:n}}const Ah=new k,Eh=new k;class ka extends Qf{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,i=[];for(let s=0,r=t.count;s<r;s+=2)Ah.fromBufferAttribute(t,s),Eh.fromBufferAttribute(t,s+1),i[s]=s===0?0:i[s-1],i[s+1]=i[s]+Ah.distanceTo(Eh);e.setAttribute("lineDistance",new dt(i,1))}else $e("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class ep extends sn{constructor(e=[],t=ms,i,s,r,a,o,l,c,u){super(e,t,i,s,r,a,o,l,c,u),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class Fa extends sn{constructor(e,t,i,s,r,a,o,l,c){super(e,t,i,s,r,a,o,l,c),this.isCanvasTexture=!0,this.needsUpdate=!0}}class ar extends sn{constructor(e,t,i=di,s,r,a,o=zt,l=zt,c,u=wi,h=1){if(u!==wi&&u!==ds)throw new Error("THREE.DepthTexture: format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const d={width:e,height:t,depth:h};super(d,s,r,a,o,l,u,i,c),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new Su(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){const t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}}class fg extends ar{constructor(e,t=di,i=ms,s,r,a=zt,o=zt,l,c=wi){const u={width:e,height:e,depth:1},h=[u,u,u,u,u,u];super(e,e,t,i,s,r,a,o,l,c),this.image=h,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}}class tp extends sn{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}class ia extends wt{constructor(e=1,t=1,i=1,s=1,r=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:i,widthSegments:s,heightSegments:r,depthSegments:a};const o=this;s=Math.floor(s),r=Math.floor(r),a=Math.floor(a);const l=[],c=[],u=[],h=[];let d=0,f=0;p("z","y","x",-1,-1,i,t,e,a,r,0),p("z","y","x",1,-1,i,t,-e,a,r,1),p("x","z","y",1,1,e,i,t,s,a,2),p("x","z","y",1,-1,e,i,-t,s,a,3),p("x","y","z",1,-1,e,t,i,s,r,4),p("x","y","z",-1,-1,e,t,-i,s,r,5),this.setIndex(l),this.setAttribute("position",new dt(c,3)),this.setAttribute("normal",new dt(u,3)),this.setAttribute("uv",new dt(h,2));function p(_,m,g,v,b,x,E,S,A,y,T){const L=x/A,R=E/y,w=x/2,P=E/2,U=S/2,D=A+1,K=y+1;let B=0,ie=0;const F=new k;for(let se=0;se<K;se++){const V=se*R-P;for(let oe=0;oe<D;oe++){const Ae=oe*L-w;F[_]=Ae*v,F[m]=V*b,F[g]=U,c.push(F.x,F.y,F.z),F[_]=0,F[m]=0,F[g]=S>0?1:-1,u.push(F.x,F.y,F.z),h.push(oe/A),h.push(1-se/y),B+=1}}for(let se=0;se<y;se++)for(let V=0;V<A;V++){const oe=d+V+D*se,Ae=d+V+D*(se+1),me=d+(V+1)+D*(se+1),ue=d+(V+1)+D*se;l.push(oe,Ae,ue),l.push(Ae,me,ue),ie+=6}o.addGroup(f,ie,T),f+=ie,d+=B}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new ia(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}class fi{constructor(){this.type="Curve",this.arcLengthDivisions=200,this.needsUpdate=!1,this.cacheArcLengths=null}getPoint(){$e("Curve: .getPoint() not implemented.")}getPointAt(e,t){const i=this.getUtoTmapping(e);return this.getPoint(i,t)}getPoints(e=5){const t=[];for(let i=0;i<=e;i++)t.push(this.getPoint(i/e));return t}getSpacedPoints(e=5){const t=[];for(let i=0;i<=e;i++)t.push(this.getPointAt(i/e));return t}getLength(){const e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const t=[];let i,s=this.getPoint(0),r=0;t.push(0);for(let a=1;a<=e;a++)i=this.getPoint(a/e),r+=i.distanceTo(s),t.push(r),s=i;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t=null){const i=this.getLengths();let s=0;const r=i.length;let a;t?a=t:a=e*i[r-1];let o=0,l=r-1,c;for(;o<=l;)if(s=Math.floor(o+(l-o)/2),c=i[s]-a,c<0)o=s+1;else if(c>0)l=s-1;else{l=s;break}if(s=l,i[s]===a)return s/(r-1);const u=i[s],d=i[s+1]-u,f=(a-u)/d;return(s+f)/(r-1)}getTangent(e,t){let s=e-1e-4,r=e+1e-4;s<0&&(s=0),r>1&&(r=1);const a=this.getPoint(s),o=this.getPoint(r),l=t||(a.isVector2?new Le:new k);return l.copy(o).sub(a).normalize(),l}getTangentAt(e,t){const i=this.getUtoTmapping(e);return this.getTangent(i,t)}computeFrenetFrames(e,t=!1){const i=new k,s=[],r=[],a=[],o=new k,l=new Rt;for(let f=0;f<=e;f++){const p=f/e;s[f]=this.getTangentAt(p,new k)}r[0]=new k,a[0]=new k;let c=Number.MAX_VALUE;const u=Math.abs(s[0].x),h=Math.abs(s[0].y),d=Math.abs(s[0].z);u<=c&&(c=u,i.set(1,0,0)),h<=c&&(c=h,i.set(0,1,0)),d<=c&&i.set(0,0,1),o.crossVectors(s[0],i).normalize(),r[0].crossVectors(s[0],o),a[0].crossVectors(s[0],r[0]);for(let f=1;f<=e;f++){if(r[f]=r[f-1].clone(),a[f]=a[f-1].clone(),o.crossVectors(s[f-1],s[f]),o.length()>Number.EPSILON){o.normalize();const p=Math.acos(Qe(s[f-1].dot(s[f]),-1,1));r[f].applyMatrix4(l.makeRotationAxis(o,p))}a[f].crossVectors(s[f],r[f])}if(t===!0){let f=Math.acos(Qe(r[0].dot(r[e]),-1,1));f/=e,s[0].dot(o.crossVectors(r[0],r[e]))>0&&(f=-f);for(let p=1;p<=e;p++)r[p].applyMatrix4(l.makeRotationAxis(s[p],f*p)),a[p].crossVectors(s[p],r[p])}return{tangents:s,normals:r,binormals:a}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){const e={metadata:{version:4.7,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}class Mu extends fi{constructor(e=0,t=0,i=1,s=1,r=0,a=Math.PI*2,o=!1,l=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=i,this.yRadius=s,this.aStartAngle=r,this.aEndAngle=a,this.aClockwise=o,this.aRotation=l}getPoint(e,t=new Le){const i=t,s=Math.PI*2;let r=this.aEndAngle-this.aStartAngle;const a=Math.abs(r)<Number.EPSILON;for(;r<0;)r+=s;for(;r>s;)r-=s;r<Number.EPSILON&&(a?r=0:r=s),this.aClockwise===!0&&!a&&(r===s?r=-s:r=r-s);const o=this.aStartAngle+e*r;let l=this.aX+this.xRadius*Math.cos(o),c=this.aY+this.yRadius*Math.sin(o);if(this.aRotation!==0){const u=Math.cos(this.aRotation),h=Math.sin(this.aRotation),d=l-this.aX,f=c-this.aY;l=d*u-f*h+this.aX,c=d*h+f*u+this.aY}return i.set(l,c)}copy(e){return super.copy(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}toJSON(){const e=super.toJSON();return e.aX=this.aX,e.aY=this.aY,e.xRadius=this.xRadius,e.yRadius=this.yRadius,e.aStartAngle=this.aStartAngle,e.aEndAngle=this.aEndAngle,e.aClockwise=this.aClockwise,e.aRotation=this.aRotation,e}fromJSON(e){return super.fromJSON(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}}class pg extends Mu{constructor(e,t,i,s,r,a){super(e,t,i,i,s,r,a),this.isArcCurve=!0,this.type="ArcCurve"}}function Au(){let n=0,e=0,t=0,i=0;function s(r,a,o,l){n=r,e=o,t=-3*r+3*a-2*o-l,i=2*r-2*a+o+l}return{initCatmullRom:function(r,a,o,l,c){s(a,o,c*(o-r),c*(l-a))},initNonuniformCatmullRom:function(r,a,o,l,c,u,h){let d=(a-r)/c-(o-r)/(c+u)+(o-a)/u,f=(o-a)/u-(l-a)/(u+h)+(l-o)/h;d*=u,f*=u,s(a,o,d,f)},calc:function(r){const a=r*r,o=a*r;return n+e*r+t*a+i*o}}}const Th=new k,Ch=new k,Tl=new Au,Cl=new Au,wl=new Au;class mg extends fi{constructor(e=[],t=!1,i="centripetal",s=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=e,this.closed=t,this.curveType=i,this.tension=s}getPoint(e,t=new k){const i=t,s=this.points,r=s.length,a=(r-(this.closed?0:1))*e;let o=Math.floor(a),l=a-o;this.closed?o+=o>0?0:(Math.floor(Math.abs(o)/r)+1)*r:l===0&&o===r-1&&(o=r-2,l=1);let c,u;this.closed||o>0?c=s[(o-1)%r]:(Ch.subVectors(s[0],s[1]).add(s[0]),c=Ch);const h=s[o%r],d=s[(o+1)%r];if(this.closed||o+2<r?u=s[(o+2)%r]:(Th.subVectors(s[r-1],s[r-2]).add(s[r-1]),u=Th),this.curveType==="centripetal"||this.curveType==="chordal"){const f=this.curveType==="chordal"?.5:.25;let p=Math.pow(c.distanceToSquared(h),f),_=Math.pow(h.distanceToSquared(d),f),m=Math.pow(d.distanceToSquared(u),f);_<1e-4&&(_=1),p<1e-4&&(p=_),m<1e-4&&(m=_),Tl.initNonuniformCatmullRom(c.x,h.x,d.x,u.x,p,_,m),Cl.initNonuniformCatmullRom(c.y,h.y,d.y,u.y,p,_,m),wl.initNonuniformCatmullRom(c.z,h.z,d.z,u.z,p,_,m)}else this.curveType==="catmullrom"&&(Tl.initCatmullRom(c.x,h.x,d.x,u.x,this.tension),Cl.initCatmullRom(c.y,h.y,d.y,u.y,this.tension),wl.initCatmullRom(c.z,h.z,d.z,u.z,this.tension));return i.set(Tl.calc(l),Cl.calc(l),wl.calc(l)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){const s=e.points[t];this.points.push(s.clone())}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}toJSON(){const e=super.toJSON();e.points=[];for(let t=0,i=this.points.length;t<i;t++){const s=this.points[t];e.points.push(s.toArray())}return e.closed=this.closed,e.curveType=this.curveType,e.tension=this.tension,e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){const s=e.points[t];this.points.push(new k().fromArray(s))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}}function wh(n,e,t,i,s){const r=(i-e)*.5,a=(s-t)*.5,o=n*n,l=n*o;return(2*t-2*i+r+a)*l+(-3*t+3*i-2*r-a)*o+r*n+t}function gg(n,e){const t=1-n;return t*t*e}function _g(n,e){return 2*(1-n)*n*e}function xg(n,e){return n*n*e}function zr(n,e,t,i){return gg(n,e)+_g(n,t)+xg(n,i)}function yg(n,e){const t=1-n;return t*t*t*e}function vg(n,e){const t=1-n;return 3*t*t*n*e}function Sg(n,e){return 3*(1-n)*n*n*e}function bg(n,e){return n*n*n*e}function Vr(n,e,t,i,s){return yg(n,e)+vg(n,t)+Sg(n,i)+bg(n,s)}class np extends fi{constructor(e=new Le,t=new Le,i=new Le,s=new Le){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=i,this.v3=s}getPoint(e,t=new Le){const i=t,s=this.v0,r=this.v1,a=this.v2,o=this.v3;return i.set(Vr(e,s.x,r.x,a.x,o.x),Vr(e,s.y,r.y,a.y,o.y)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}}class Mg extends fi{constructor(e=new k,t=new k,i=new k,s=new k){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=i,this.v3=s}getPoint(e,t=new k){const i=t,s=this.v0,r=this.v1,a=this.v2,o=this.v3;return i.set(Vr(e,s.x,r.x,a.x,o.x),Vr(e,s.y,r.y,a.y,o.y),Vr(e,s.z,r.z,a.z,o.z)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}}class ip extends fi{constructor(e=new Le,t=new Le){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new Le){const i=t;return e===1?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(e).add(this.v1)),i}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new Le){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class Ag extends fi{constructor(e=new k,t=new k){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=e,this.v2=t}getPoint(e,t=new k){const i=t;return e===1?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(e).add(this.v1)),i}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new k){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class sp extends fi{constructor(e=new Le,t=new Le,i=new Le){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new Le){const i=t,s=this.v0,r=this.v1,a=this.v2;return i.set(zr(e,s.x,r.x,a.x),zr(e,s.y,r.y,a.y)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class Eg extends fi{constructor(e=new k,t=new k,i=new k){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new k){const i=t,s=this.v0,r=this.v1,a=this.v2;return i.set(zr(e,s.x,r.x,a.x),zr(e,s.y,r.y,a.y),zr(e,s.z,r.z,a.z)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class rp extends fi{constructor(e=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=e}getPoint(e,t=new Le){const i=t,s=this.points,r=(s.length-1)*e,a=Math.floor(r),o=r-a,l=s[a===0?a:a-1],c=s[a],u=s[a>s.length-2?s.length-1:a+1],h=s[a>s.length-3?s.length-1:a+2];return i.set(wh(o,l.x,c.x,u.x,h.x),wh(o,l.y,c.y,u.y,h.y)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){const s=e.points[t];this.points.push(s.clone())}return this}toJSON(){const e=super.toJSON();e.points=[];for(let t=0,i=this.points.length;t<i;t++){const s=this.points[t];e.points.push(s.toArray())}return e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){const s=e.points[t];this.points.push(new Le().fromArray(s))}return this}}var Rh=Object.freeze({__proto__:null,ArcCurve:pg,CatmullRomCurve3:mg,CubicBezierCurve:np,CubicBezierCurve3:Mg,EllipseCurve:Mu,LineCurve:ip,LineCurve3:Ag,QuadraticBezierCurve:sp,QuadraticBezierCurve3:Eg,SplineCurve:rp});class Tg extends fi{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(e){this.curves.push(e)}closePath(){const e=this.curves[0].getPoint(0),t=this.curves[this.curves.length-1].getPoint(1);if(!e.equals(t)){const i=e.isVector2===!0?"LineCurve":"LineCurve3";this.curves.push(new Rh[i](t,e))}return this}getPoint(e,t){const i=e*this.getLength(),s=this.getCurveLengths();let r=0;for(;r<s.length;){if(s[r]>=i){const a=s[r]-i,o=this.curves[r],l=o.getLength(),c=l===0?0:1-a/l;return o.getPointAt(c,t)}r++}return null}getLength(){const e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const e=[];let t=0;for(let i=0,s=this.curves.length;i<s;i++)t+=this.curves[i].getLength(),e.push(t);return this.cacheLengths=e,e}getSpacedPoints(e=40){const t=[];for(let i=0;i<=e;i++)t.push(this.getPoint(i/e));return this.autoClose&&t.push(t[0]),t}getPoints(e=12){const t=[];let i;for(let s=0,r=this.curves;s<r.length;s++){const a=r[s],o=a.isEllipseCurve?e*2:a.isLineCurve||a.isLineCurve3?1:a.isSplineCurve?e*a.points.length:e,l=a.getPoints(o);for(let c=0;c<l.length;c++){const u=l[c];i&&i.equals(u)||(t.push(u),i=u)}}return this.autoClose&&t.length>1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,i=e.curves.length;t<i;t++){const s=e.curves[t];this.curves.push(s.clone())}return this.autoClose=e.autoClose,this}toJSON(){const e=super.toJSON();e.autoClose=this.autoClose,e.curves=[];for(let t=0,i=this.curves.length;t<i;t++){const s=this.curves[t];e.curves.push(s.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.autoClose=e.autoClose,this.curves=[];for(let t=0,i=e.curves.length;t<i;t++){const s=e.curves[t];this.curves.push(new Rh[s.type]().fromJSON(s))}return this}}let Lh=class extends Tg{constructor(e){super(),this.type="Path",this.currentPoint=new Le,e&&this.setFromPoints(e)}setFromPoints(e){this.moveTo(e[0].x,e[0].y);for(let t=1,i=e.length;t<i;t++)this.lineTo(e[t].x,e[t].y);return this}moveTo(e,t){return this.currentPoint.set(e,t),this}lineTo(e,t){const i=new ip(this.currentPoint.clone(),new Le(e,t));return this.curves.push(i),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,i,s){const r=new sp(this.currentPoint.clone(),new Le(e,t),new Le(i,s));return this.curves.push(r),this.currentPoint.set(i,s),this}bezierCurveTo(e,t,i,s,r,a){const o=new np(this.currentPoint.clone(),new Le(e,t),new Le(i,s),new Le(r,a));return this.curves.push(o),this.currentPoint.set(r,a),this}splineThru(e){const t=[this.currentPoint.clone()].concat(e),i=new rp(t);return this.curves.push(i),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,i,s,r,a){const o=this.currentPoint.x,l=this.currentPoint.y;return this.absarc(e+o,t+l,i,s,r,a),this}absarc(e,t,i,s,r,a){return this.absellipse(e,t,i,i,s,r,a),this}ellipse(e,t,i,s,r,a,o,l){const c=this.currentPoint.x,u=this.currentPoint.y;return this.absellipse(e+c,t+u,i,s,r,a,o,l),this}absellipse(e,t,i,s,r,a,o,l){const c=new Mu(e,t,i,s,r,a,o,l);if(this.curves.length>0){const h=c.getPoint(0);h.equals(this.currentPoint)||this.lineTo(h.x,h.y)}this.curves.push(c);const u=c.getPoint(1);return this.currentPoint.copy(u),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){const e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}};class ap extends Lh{constructor(e){super(e),this.uuid=ci(),this.type="Shape",this.holes=[]}getPointsHoles(e){const t=[];for(let i=0,s=this.holes.length;i<s;i++)t[i]=this.holes[i].getPoints(e);return t}extractPoints(e){return{shape:this.getPoints(e),holes:this.getPointsHoles(e)}}copy(e){super.copy(e),this.holes=[];for(let t=0,i=e.holes.length;t<i;t++){const s=e.holes[t];this.holes.push(s.clone())}return this}toJSON(){const e=super.toJSON();e.uuid=this.uuid,e.holes=[];for(let t=0,i=this.holes.length;t<i;t++){const s=this.holes[t];e.holes.push(s.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.uuid=e.uuid,this.holes=[];for(let t=0,i=e.holes.length;t<i;t++){const s=e.holes[t];this.holes.push(new Lh().fromJSON(s))}return this}}function Cg(n,e,t=2){const i=e&&e.length,s=i?e[0]*t:n.length;let r=op(n,0,s,t,!0);const a=[];if(!r||r.next===r.prev)return a;let o,l,c;if(i&&(r=Ig(n,e,r,t)),n.length>80*t){o=n[0],l=n[1];let u=o,h=l;for(let d=t;d<s;d+=t){const f=n[d],p=n[d+1];f<o&&(o=f),p<l&&(l=p),f>u&&(u=f),p>h&&(h=p)}c=Math.max(u-o,h-l),c=c!==0?32767/c:0}return $r(r,a,t,o,l,c,0),a}function op(n,e,t,i,s){let r;if(s===Gg(n,e,t,i)>0)for(let a=e;a<t;a+=i)r=Dh(a/i|0,n[a],n[a+1],r);else for(let a=t-i;a>=e;a-=i)r=Dh(a/i|0,n[a],n[a+1],r);return r&&or(r,r.next)&&(Jr(r),r=r.next),r}function xs(n,e){if(!n)return n;e||(e=n);let t=n,i;do if(i=!1,!t.steiner&&(or(t,t.next)||Dt(t.prev,t,t.next)===0)){if(Jr(t),t=e=t.prev,t===t.next)break;i=!0}else t=t.next;while(i||t!==e);return e}function $r(n,e,t,i,s,r,a){if(!n)return;!a&&r&&kg(n,i,s,r);let o=n;for(;n.prev!==n.next;){const l=n.prev,c=n.next;if(r?Rg(n,i,s,r):wg(n)){e.push(l.i,n.i,c.i),Jr(n),n=c.next,o=c.next;continue}if(n=c,n===o){a?a===1?(n=Lg(xs(n),e),$r(n,e,t,i,s,r,2)):a===2&&Dg(n,e,t,i,s,r):$r(xs(n),e,t,i,s,r,1);break}}}function wg(n){const e=n.prev,t=n,i=n.next;if(Dt(e,t,i)>=0)return!1;const s=e.x,r=t.x,a=i.x,o=e.y,l=t.y,c=i.y,u=Math.min(s,r,a),h=Math.min(o,l,c),d=Math.max(s,r,a),f=Math.max(o,l,c);let p=i.next;for(;p!==e;){if(p.x>=u&&p.x<=d&&p.y>=h&&p.y<=f&&kr(s,o,r,l,a,c,p.x,p.y)&&Dt(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function Rg(n,e,t,i){const s=n.prev,r=n,a=n.next;if(Dt(s,r,a)>=0)return!1;const o=s.x,l=r.x,c=a.x,u=s.y,h=r.y,d=a.y,f=Math.min(o,l,c),p=Math.min(u,h,d),_=Math.max(o,l,c),m=Math.max(u,h,d),g=Yc(f,p,e,t,i),v=Yc(_,m,e,t,i);let b=n.prevZ,x=n.nextZ;for(;b&&b.z>=g&&x&&x.z<=v;){if(b.x>=f&&b.x<=_&&b.y>=p&&b.y<=m&&b!==s&&b!==a&&kr(o,u,l,h,c,d,b.x,b.y)&&Dt(b.prev,b,b.next)>=0||(b=b.prevZ,x.x>=f&&x.x<=_&&x.y>=p&&x.y<=m&&x!==s&&x!==a&&kr(o,u,l,h,c,d,x.x,x.y)&&Dt(x.prev,x,x.next)>=0))return!1;x=x.nextZ}for(;b&&b.z>=g;){if(b.x>=f&&b.x<=_&&b.y>=p&&b.y<=m&&b!==s&&b!==a&&kr(o,u,l,h,c,d,b.x,b.y)&&Dt(b.prev,b,b.next)>=0)return!1;b=b.prevZ}for(;x&&x.z<=v;){if(x.x>=f&&x.x<=_&&x.y>=p&&x.y<=m&&x!==s&&x!==a&&kr(o,u,l,h,c,d,x.x,x.y)&&Dt(x.prev,x,x.next)>=0)return!1;x=x.nextZ}return!0}function Lg(n,e){let t=n;do{const i=t.prev,s=t.next.next;!or(i,s)&&cp(i,t,t.next,s)&&Zr(i,s)&&Zr(s,i)&&(e.push(i.i,t.i,s.i),Jr(t),Jr(t.next),t=n=s),t=t.next}while(t!==n);return xs(t)}function Dg(n,e,t,i,s,r){let a=n;do{let o=a.next.next;for(;o!==a.prev;){if(a.i!==o.i&&Hg(a,o)){let l=up(a,o);a=xs(a,a.next),l=xs(l,l.next),$r(a,e,t,i,s,r,0),$r(l,e,t,i,s,r,0);return}o=o.next}a=a.next}while(a!==n)}function Ig(n,e,t,i){const s=[];for(let r=0,a=e.length;r<a;r++){const o=e[r]*i,l=r<a-1?e[r+1]*i:n.length,c=op(n,o,l,i,!1);c===c.next&&(c.steiner=!0),s.push(Bg(c))}s.sort(Pg);for(let r=0;r<s.length;r++)t=Og(s[r],t);return t}function Pg(n,e){let t=n.x-e.x;if(t===0&&(t=n.y-e.y,t===0)){const i=(n.next.y-n.y)/(n.next.x-n.x),s=(e.next.y-e.y)/(e.next.x-e.x);t=i-s}return t}function Og(n,e){const t=Ug(n,e);if(!t)return e;const i=up(t,n);return xs(i,i.next),xs(t,t.next)}function Ug(n,e){let t=e;const i=n.x,s=n.y;let r=-1/0,a;if(or(n,t))return t;do{if(or(n,t.next))return t.next;if(s<=t.y&&s>=t.next.y&&t.next.y!==t.y){const h=t.x+(s-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(h<=i&&h>r&&(r=h,a=t.x<t.next.x?t:t.next,h===i))return a}t=t.next}while(t!==e);if(!a)return null;const o=a,l=a.x,c=a.y;let u=1/0;t=a;do{if(i>=t.x&&t.x>=l&&i!==t.x&&lp(s<c?i:r,s,l,c,s<c?r:i,s,t.x,t.y)){const h=Math.abs(s-t.y)/(i-t.x);Zr(t,n)&&(h<u||h===u&&(t.x>a.x||t.x===a.x&&Ng(a,t)))&&(a=t,u=h)}t=t.next}while(t!==o);return a}function Ng(n,e){return Dt(n.prev,n,e.prev)<0&&Dt(e.next,n,n.next)<0}function kg(n,e,t,i){let s=n;do s.z===0&&(s.z=Yc(s.x,s.y,e,t,i)),s.prevZ=s.prev,s.nextZ=s.next,s=s.next;while(s!==n);s.prevZ.nextZ=null,s.prevZ=null,Fg(s)}function Fg(n){let e,t=1;do{let i=n,s;n=null;let r=null;for(e=0;i;){e++;let a=i,o=0;for(let c=0;c<t&&(o++,a=a.nextZ,!!a);c++);let l=t;for(;o>0||l>0&&a;)o!==0&&(l===0||!a||i.z<=a.z)?(s=i,i=i.nextZ,o--):(s=a,a=a.nextZ,l--),r?r.nextZ=s:n=s,s.prevZ=r,r=s;i=a}r.nextZ=null,t*=2}while(e>1);return n}function Yc(n,e,t,i,s){return n=(n-t)*s|0,e=(e-i)*s|0,n=(n|n<<8)&16711935,n=(n|n<<4)&252645135,n=(n|n<<2)&858993459,n=(n|n<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,n|e<<1}function Bg(n){let e=n,t=n;do(e.x<t.x||e.x===t.x&&e.y<t.y)&&(t=e),e=e.next;while(e!==n);return t}function lp(n,e,t,i,s,r,a,o){return(s-a)*(e-o)>=(n-a)*(r-o)&&(n-a)*(i-o)>=(t-a)*(e-o)&&(t-a)*(r-o)>=(s-a)*(i-o)}function kr(n,e,t,i,s,r,a,o){return!(n===a&&e===o)&&lp(n,e,t,i,s,r,a,o)}function Hg(n,e){return n.next.i!==e.i&&n.prev.i!==e.i&&!zg(n,e)&&(Zr(n,e)&&Zr(e,n)&&Vg(n,e)&&(Dt(n.prev,n,e.prev)||Dt(n,e.prev,e))||or(n,e)&&Dt(n.prev,n,n.next)>0&&Dt(e.prev,e,e.next)>0)}function Dt(n,e,t){return(e.y-n.y)*(t.x-e.x)-(e.x-n.x)*(t.y-e.y)}function or(n,e){return n.x===e.x&&n.y===e.y}function cp(n,e,t,i){const s=Ha(Dt(n,e,t)),r=Ha(Dt(n,e,i)),a=Ha(Dt(t,i,n)),o=Ha(Dt(t,i,e));return!!(s!==r&&a!==o||s===0&&Ba(n,t,e)||r===0&&Ba(n,i,e)||a===0&&Ba(t,n,i)||o===0&&Ba(t,e,i))}function Ba(n,e,t){return e.x<=Math.max(n.x,t.x)&&e.x>=Math.min(n.x,t.x)&&e.y<=Math.max(n.y,t.y)&&e.y>=Math.min(n.y,t.y)}function Ha(n){return n>0?1:n<0?-1:0}function zg(n,e){let t=n;do{if(t.i!==n.i&&t.next.i!==n.i&&t.i!==e.i&&t.next.i!==e.i&&cp(t,t.next,n,e))return!0;t=t.next}while(t!==n);return!1}function Zr(n,e){return Dt(n.prev,n,n.next)<0?Dt(n,e,n.next)>=0&&Dt(n,n.prev,e)>=0:Dt(n,e,n.prev)<0||Dt(n,n.next,e)<0}function Vg(n,e){let t=n,i=!1;const s=(n.x+e.x)/2,r=(n.y+e.y)/2;do t.y>r!=t.next.y>r&&t.next.y!==t.y&&s<(t.next.x-t.x)*(r-t.y)/(t.next.y-t.y)+t.x&&(i=!i),t=t.next;while(t!==n);return i}function up(n,e){const t=Kc(n.i,n.x,n.y),i=Kc(e.i,e.x,e.y),s=n.next,r=e.prev;return n.next=e,e.prev=n,t.next=s,s.prev=t,i.next=t,t.prev=i,r.next=i,i.prev=r,i}function Dh(n,e,t,i){const s=Kc(n,e,t);return i?(s.next=i.next,s.prev=i,i.next.prev=s,i.next=s):(s.prev=s,s.next=s),s}function Jr(n){n.next.prev=n.prev,n.prev.next=n.next,n.prevZ&&(n.prevZ.nextZ=n.nextZ),n.nextZ&&(n.nextZ.prevZ=n.prevZ)}function Kc(n,e,t){return{i:n,x:e,y:t,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function Gg(n,e,t,i){let s=0;for(let r=e,a=t-i;r<t;r+=i)s+=(n[a]-n[r])*(n[r+1]+n[a+1]),a=r;return s}class Wg{static triangulate(e,t,i=2){return Cg(e,t,i)}}class Gr{static area(e){const t=e.length;let i=0;for(let s=t-1,r=0;r<t;s=r++)i+=e[s].x*e[r].y-e[r].x*e[s].y;return i*.5}static isClockWise(e){return Gr.area(e)<0}static triangulateShape(e,t){const i=[],s=[],r=[];Ih(e),Ph(i,e);let a=e.length;t.forEach(Ih);for(let l=0;l<t.length;l++)s.push(a),a+=t[l].length,Ph(i,t[l]);const o=Wg.triangulate(i,s);for(let l=0;l<o.length;l+=3)r.push(o.slice(l,l+3));return r}}function Ih(n){const e=n.length;e>2&&n[e-1].equals(n[0])&&n.pop()}function Ph(n,e){for(let t=0;t<e.length;t++)n.push(e[t].x),n.push(e[t].y)}class fs extends wt{constructor(e=1,t=1,i=1,s=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:i,heightSegments:s};const r=e/2,a=t/2,o=Math.floor(i),l=Math.floor(s),c=o+1,u=l+1,h=e/o,d=t/l,f=[],p=[],_=[],m=[];for(let g=0;g<u;g++){const v=g*d-a;for(let b=0;b<c;b++){const x=b*h-r;p.push(x,-v,0),_.push(0,0,1),m.push(b/o),m.push(1-g/l)}}for(let g=0;g<l;g++)for(let v=0;v<o;v++){const b=v+c*g,x=v+c*(g+1),E=v+1+c*(g+1),S=v+1+c*g;f.push(b,x,S),f.push(x,E,S)}this.setIndex(f),this.setAttribute("position",new dt(p,3)),this.setAttribute("normal",new dt(_,3)),this.setAttribute("uv",new dt(m,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new fs(e.width,e.height,e.widthSegments,e.heightSegments)}}class Eu extends wt{constructor(e=new ap([new Le(0,.5),new Le(-.5,-.5),new Le(.5,-.5)]),t=12){super(),this.type="ShapeGeometry",this.parameters={shapes:e,curveSegments:t};const i=[],s=[],r=[],a=[];let o=0,l=0;if(Array.isArray(e)===!1)c(e);else for(let u=0;u<e.length;u++)c(e[u]),this.addGroup(o,l,u),o+=l,l=0;this.setIndex(i),this.setAttribute("position",new dt(s,3)),this.setAttribute("normal",new dt(r,3)),this.setAttribute("uv",new dt(a,2));function c(u){const h=s.length/3,d=u.extractPoints(t);let f=d.shape;const p=d.holes;Gr.isClockWise(f)===!1&&(f=f.reverse());for(let m=0,g=p.length;m<g;m++){const v=p[m];Gr.isClockWise(v)===!0&&(p[m]=v.reverse())}const _=Gr.triangulateShape(f,p);for(let m=0,g=p.length;m<g;m++){const v=p[m];f=f.concat(v)}for(let m=0,g=f.length;m<g;m++){const v=f[m];s.push(v.x,v.y,0),r.push(0,0,1),a.push(v.x,v.y)}for(let m=0,g=_.length;m<g;m++){const v=_[m],b=v[0]+h,x=v[1]+h,E=v[2]+h;i.push(b,x,E),l+=3}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON(),t=this.parameters.shapes;return Xg(t,e)}static fromJSON(e,t){const i=[];for(let s=0,r=e.shapes.length;s<r;s++){const a=t[e.shapes[s]];i.push(a)}return new Eu(i,e.curveSegments)}}function Xg(n,e){if(e.shapes=[],Array.isArray(n))for(let t=0,i=n.length;t<i;t++){const s=n[t];e.shapes.push(s.uuid)}else e.shapes.push(n.uuid);return e}class Yg extends wt{constructor(e=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:e},e!==null){const t=[],i=new Set,s=new k,r=new k;if(e.index!==null){const a=e.attributes.position,o=e.index;let l=e.groups;l.length===0&&(l=[{start:0,count:o.count,materialIndex:0}]);for(let c=0,u=l.length;c<u;++c){const h=l[c],d=h.start,f=h.count;for(let p=d,_=d+f;p<_;p+=3)for(let m=0;m<3;m++){const g=o.getX(p+m),v=o.getX(p+(m+1)%3);s.fromBufferAttribute(a,g),r.fromBufferAttribute(a,v),Oh(s,r,i)===!0&&(t.push(s.x,s.y,s.z),t.push(r.x,r.y,r.z))}}}else{const a=e.attributes.position;for(let o=0,l=a.count/3;o<l;o++)for(let c=0;c<3;c++){const u=3*o+c,h=3*o+(c+1)%3;s.fromBufferAttribute(a,u),r.fromBufferAttribute(a,h),Oh(s,r,i)===!0&&(t.push(s.x,s.y,s.z),t.push(r.x,r.y,r.z))}}this.setAttribute("position",new dt(t,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}function Oh(n,e,t){const i=`${n.x},${n.y},${n.z}-${e.x},${e.y},${e.z}`,s=`${e.x},${e.y},${e.z}-${n.x},${n.y},${n.z}`;return t.has(i)===!0||t.has(s)===!0?!1:(t.add(i),t.add(s),!0)}function lr(n){const e={};for(const t in n){e[t]={};for(const i in n[t]){const s=n[t][i];if(Uh(s))s.isRenderTargetTexture?($e("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[t][i]=null):e[t][i]=s.clone();else if(Array.isArray(s))if(Uh(s[0])){const r=[];for(let a=0,o=s.length;a<o;a++)r[a]=s[a].clone();e[t][i]=r}else e[t][i]=s.slice();else e[t][i]=s}}return e}function un(n){const e={};for(let t=0;t<n.length;t++){const i=lr(n[t]);for(const s in i)e[s]=i[s]}return e}function Uh(n){return n&&(n.isColor||n.isMatrix3||n.isMatrix4||n.isVector2||n.isVector3||n.isVector4||n.isTexture||n.isQuaternion)}function Kg(n){const e=[];for(let t=0;t<n.length;t++)e.push(n[t].clone());return e}function hp(n){const e=n.getRenderTarget();return e===null?n.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:at.workingColorSpace}const Tu={clone:lr,merge:un};var qg=`void main() {
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}`,$g=`void main() {
gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
}`;class In extends mr{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=qg,this.fragmentShader=$g,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={clipCullDistance:!1,multiDraw:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,e!==void 0&&this.setValues(e)}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=lr(e.uniforms),this.uniformsGroups=Kg(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this.defaultAttributeValues=Object.assign({},e.defaultAttributeValues),this.index0AttributeName=e.index0AttributeName,this.uniformsNeedUpdate=e.uniformsNeedUpdate,this}toJSON(e){const t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(const s in this.uniforms){const a=this.uniforms[s].value;a&&a.isTexture?t.uniforms[s]={type:"t",value:a.toJSON(e).uuid}:a&&a.isColor?t.uniforms[s]={type:"c",value:a.getHex()}:a&&a.isVector2?t.uniforms[s]={type:"v2",value:a.toArray()}:a&&a.isVector3?t.uniforms[s]={type:"v3",value:a.toArray()}:a&&a.isVector4?t.uniforms[s]={type:"v4",value:a.toArray()}:a&&a.isMatrix3?t.uniforms[s]={type:"m3",value:a.toArray()}:a&&a.isMatrix4?t.uniforms[s]={type:"m4",value:a.toArray()}:t.uniforms[s]={value:a}}Object.keys(this.defines).length>0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;const i={};for(const s in this.extensions)this.extensions[s]===!0&&(i[s]=!0);return Object.keys(i).length>0&&(t.extensions=i),t}fromJSON(e,t){if(super.fromJSON(e,t),e.uniforms!==void 0)for(const i in e.uniforms){const s=e.uniforms[i];switch(this.uniforms[i]={},s.type){case"t":this.uniforms[i].value=t[s.value]||null;break;case"c":this.uniforms[i].value=new it().setHex(s.value);break;case"v2":this.uniforms[i].value=new Le().fromArray(s.value);break;case"v3":this.uniforms[i].value=new k().fromArray(s.value);break;case"v4":this.uniforms[i].value=new Et().fromArray(s.value);break;case"m3":this.uniforms[i].value=new et().fromArray(s.value);break;case"m4":this.uniforms[i].value=new Rt().fromArray(s.value);break;default:this.uniforms[i].value=s.value}}if(e.defines!==void 0&&(this.defines=e.defines),e.vertexShader!==void 0&&(this.vertexShader=e.vertexShader),e.fragmentShader!==void 0&&(this.fragmentShader=e.fragmentShader),e.glslVersion!==void 0&&(this.glslVersion=e.glslVersion),e.extensions!==void 0)for(const i in e.extensions)this.extensions[i]=e.extensions[i];return e.lights!==void 0&&(this.lights=e.lights),e.clipping!==void 0&&(this.clipping=e.clipping),this}}class Zg extends In{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class Jg extends mr{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=_m,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}}class jg extends mr{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}class Qg extends js{constructor(e){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}copy(e){return super.copy(e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}}const za=new k,Va=new Ji,$n=new k;class dp extends hn{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Rt,this.projectionMatrix=new Rt,this.projectionMatrixInverse=new Rt,this.coordinateSystem=ri,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorld.decompose(za,Va,$n),$n.x===1&&$n.y===1&&$n.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(za,Va,$n.set(1,1,1)).invert()}updateWorldMatrix(e,t,i=!1){super.updateWorldMatrix(e,t,i),this.matrixWorld.decompose(za,Va,$n),$n.x===1&&$n.y===1&&$n.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(za,Va,$n.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}}const Bi=new k,Nh=new Le,kh=new Le;class zn extends dp{constructor(e=50,t=1,i=.1,s=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=i,this.far=s,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){const t=.5*this.getFilmHeight()/e;this.fov=qr*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(Br*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return qr*2*Math.atan(Math.tan(Br*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,i){Bi.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(Bi.x,Bi.y).multiplyScalar(-e/Bi.z),Bi.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),i.set(Bi.x,Bi.y).multiplyScalar(-e/Bi.z)}getViewSize(e,t){return this.getViewBounds(e,Nh,kh),t.subVectors(kh,Nh)}setViewOffset(e,t,i,s,r,a){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=s,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(Br*.5*this.fov)/this.zoom,i=2*t,s=this.aspect*i,r=-.5*s;const a=this.view;if(this.view!==null&&this.view.enabled){const l=a.fullWidth,c=a.fullHeight;r+=a.offsetX*s/l,t-=a.offsetY*i/c,s*=a.width/l,i*=a.height/c}const o=this.filmOffset;o!==0&&(r+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+s,t,t-i,e,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}class Cu extends dp{constructor(e=-1,t=1,i=1,s=-1,r=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=i,this.bottom=s,this.near=r,this.far=a,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,i,s,r,a){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=s,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),i=(this.right+this.left)/2,s=(this.top+this.bottom)/2;let r=i-e,a=i+e,o=s+t,l=s-t;if(this.view!==null&&this.view.enabled){const c=(this.right-this.left)/this.view.fullWidth/this.zoom,u=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=c*this.view.offsetX,a=r+c*this.view.width,o-=u*this.view.offsetY,l=o-u*this.view.height}this.projectionMatrix.makeOrthographic(r,a,o,l,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}}class e_ extends wt{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(e){return super.copy(e),this.instanceCount=e.instanceCount,this}toJSON(){const e=super.toJSON();return e.instanceCount=this.instanceCount,e.isInstancedBufferGeometry=!0,e}}const Vs=-90,Gs=1;class t_ extends hn{constructor(e,t,i){super(),this.type="CubeCamera",this.renderTarget=i,this.coordinateSystem=null,this.activeMipmapLevel=0;const s=new zn(Vs,Gs,e,t);s.layers=this.layers,this.add(s);const r=new zn(Vs,Gs,e,t);r.layers=this.layers,this.add(r);const a=new zn(Vs,Gs,e,t);a.layers=this.layers,this.add(a);const o=new zn(Vs,Gs,e,t);o.layers=this.layers,this.add(o);const l=new zn(Vs,Gs,e,t);l.layers=this.layers,this.add(l);const c=new zn(Vs,Gs,e,t);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[i,s,r,a,o,l]=t;for(const c of t)this.remove(c);if(e===ri)i.up.set(0,1,0),i.lookAt(1,0,0),s.up.set(0,1,0),s.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),a.up.set(0,0,1),a.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),l.up.set(0,1,0),l.lookAt(0,0,-1);else if(e===Mo)i.up.set(0,-1,0),i.lookAt(-1,0,0),s.up.set(0,-1,0),s.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),a.up.set(0,0,-1),a.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),l.up.set(0,-1,0),l.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const c of t)this.add(c),c.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();const{renderTarget:i,activeMipmapLevel:s}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[r,a,o,l,c,u]=this.children,h=e.getRenderTarget(),d=e.getActiveCubeFace(),f=e.getActiveMipmapLevel(),p=e.xr.enabled;e.xr.enabled=!1;const _=i.texture.generateMipmaps;i.texture.generateMipmaps=!1;let m=!1;e.isWebGLRenderer===!0?m=e.state.buffers.depth.getReversed():m=e.reversedDepthBuffer,e.setRenderTarget(i,0,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,r),e.setRenderTarget(i,1,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,a),e.setRenderTarget(i,2,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,o),e.setRenderTarget(i,3,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,l),e.setRenderTarget(i,4,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,c),i.texture.generateMipmaps=_,e.setRenderTarget(i,5,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,u),e.setRenderTarget(h,d,f),e.xr.enabled=p,i.texture.needsPMREMUpdate=!0}}class n_ extends zn{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}class qc extends $f{constructor(e,t,i=1){super(e,t),this.isInstancedInterleavedBuffer=!0,this.meshPerAttribute=i}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}clone(e){const t=super.clone(e);return t.meshPerAttribute=this.meshPerAttribute,t}toJSON(e){const t=super.toJSON(e);return t.isInstancedInterleavedBuffer=!0,t.meshPerAttribute=this.meshPerAttribute,t}}class Fh{constructor(e=1,t=0,i=0){this.radius=e,this.phi=t,this.theta=i}set(e,t,i){return this.radius=e,this.phi=t,this.theta=i,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=Qe(this.phi,1e-6,Math.PI-1e-6),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,i){return this.radius=Math.sqrt(e*e+t*t+i*i),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,i),this.phi=Math.acos(Qe(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}const $u=class $u{constructor(e,t,i,s){this.elements=[1,0,0,1],e!==void 0&&this.set(e,t,i,s)}identity(){return this.set(1,0,0,1),this}fromArray(e,t=0){for(let i=0;i<4;i++)this.elements[i]=e[i+t];return this}set(e,t,i,s){const r=this.elements;return r[0]=e,r[2]=t,r[1]=i,r[3]=s,this}};$u.prototype.isMatrix2=!0;let Bh=$u;const Hh=new k,Ga=new k,Ws=new k,Xs=new k,Rl=new k,i_=new k,s_=new k;class r_{constructor(e=new k,t=new k){this.start=e,this.end=t}set(e,t){return this.start.copy(e),this.end.copy(t),this}copy(e){return this.start.copy(e.start),this.end.copy(e.end),this}getCenter(e){return e.addVectors(this.start,this.end).multiplyScalar(.5)}delta(e){return e.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(e,t){return this.delta(t).multiplyScalar(e).add(this.start)}closestPointToPointParameter(e,t){Hh.subVectors(e,this.start),Ga.subVectors(this.end,this.start);const i=Ga.dot(Ga);if(i===0)return 0;let r=Ga.dot(Hh)/i;return t&&(r=Qe(r,0,1)),r}closestPointToPoint(e,t,i){const s=this.closestPointToPointParameter(e,t);return this.delta(i).multiplyScalar(s).add(this.start)}distanceSqToLine3(e,t=i_,i=s_){const s=10000000000000001e-32;let r,a;const o=this.start,l=e.start,c=this.end,u=e.end;Ws.subVectors(c,o),Xs.subVectors(u,l),Rl.subVectors(o,l);const h=Ws.dot(Ws),d=Xs.dot(Xs),f=Xs.dot(Rl);if(h<=s&&d<=s)return t.copy(o),i.copy(l),t.sub(i),t.dot(t);if(h<=s)r=0,a=f/d,a=Qe(a,0,1);else{const p=Ws.dot(Rl);if(d<=s)a=0,r=Qe(-p/h,0,1);else{const _=Ws.dot(Xs),m=h*d-_*_;m!==0?r=Qe((_*f-p*d)/m,0,1):r=0,a=(_*r+f)/d,a<0?(a=0,r=Qe(-p/h,0,1)):a>1&&(a=1,r=Qe((_-p)/h,0,1))}}return t.copy(o).addScaledVector(Ws,r),i.copy(l).addScaledVector(Xs,a),t.distanceToSquared(i)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return new this.constructor().copy(this)}}class a_ extends es{constructor(e,t=null){super(),this.object=e,this.domElement=t,this.enabled=!0,this.state=-1,this.keys={},this.mouseButtons={LEFT:null,MIDDLE:null,RIGHT:null},this.touches={ONE:null,TWO:null}}connect(e){if(e===void 0){$e("Controls: connect() now requires an element.");return}this.domElement!==null&&this.disconnect(),this.domElement=e}disconnect(){}dispose(){}update(){}}function zh(n,e,t,i){const s=o_(i);switch(t){case Bf:return n*e;case zf:return n*e/s.components*s.byteLength;case mu:return n*e/s.components*s.byteLength;case gs:return n*e*2/s.components*s.byteLength;case gu:return n*e*2/s.components*s.byteLength;case Hf:return n*e*3/s.components*s.byteLength;case Ln:return n*e*4/s.components*s.byteLength;case _u:return n*e*4/s.components*s.byteLength;case co:case uo:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*8;case ho:case fo:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case pc:case gc:return Math.max(n,16)*Math.max(e,8)/4;case fc:case mc:return Math.max(n,8)*Math.max(e,8)/2;case _c:case xc:case vc:case Sc:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*8;case yc:case yo:case bc:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case Mc:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case Ac:return Math.floor((n+4)/5)*Math.floor((e+3)/4)*16;case Ec:return Math.floor((n+4)/5)*Math.floor((e+4)/5)*16;case Tc:return Math.floor((n+5)/6)*Math.floor((e+4)/5)*16;case Cc:return Math.floor((n+5)/6)*Math.floor((e+5)/6)*16;case wc:return Math.floor((n+7)/8)*Math.floor((e+4)/5)*16;case Rc:return Math.floor((n+7)/8)*Math.floor((e+5)/6)*16;case Lc:return Math.floor((n+7)/8)*Math.floor((e+7)/8)*16;case Dc:return Math.floor((n+9)/10)*Math.floor((e+4)/5)*16;case Ic:return Math.floor((n+9)/10)*Math.floor((e+5)/6)*16;case Pc:return Math.floor((n+9)/10)*Math.floor((e+7)/8)*16;case Oc:return Math.floor((n+9)/10)*Math.floor((e+9)/10)*16;case Uc:return Math.floor((n+11)/12)*Math.floor((e+9)/10)*16;case Nc:return Math.floor((n+11)/12)*Math.floor((e+11)/12)*16;case kc:case Fc:case Bc:return Math.ceil(n/4)*Math.ceil(e/4)*16;case Hc:case zc:return Math.ceil(n/4)*Math.ceil(e/4)*8;case vo:case Vc:return Math.ceil(n/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function o_(n){switch(n){case wn:case Uf:return{byteLength:1,components:1};case Yr:case Nf:case Ci:return{byteLength:2,components:1};case fu:case pu:return{byteLength:2,components:4};case di:case du:case Gn:return{byteLength:4,components:1};case kf:case Ff:return{byteLength:4,components:3}}throw new Error(`THREE.TextureUtils: Unknown texture type ${n}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:hu}}));typeof window<"u"&&(window.__THREE__?$e("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=hu);/**
* @license
* Copyright 2010-2026 Three.js Authors
* SPDX-License-Identifier: MIT
*/function fp(){let n=null,e=!1,t=null,i=null;function s(r,a){t(r,a),i=n.requestAnimationFrame(s)}return{start:function(){e!==!0&&t!==null&&n!==null&&(i=n.requestAnimationFrame(s),e=!0)},stop:function(){n!==null&&n.cancelAnimationFrame(i),e=!1},setAnimationLoop:function(r){t=r},setContext:function(r){n=r}}}function l_(n){const e=new WeakMap;function t(o,l){const c=o.array,u=o.usage,h=c.byteLength,d=n.createBuffer();n.bindBuffer(l,d),n.bufferData(l,c,u),o.onUploadCallback();let f;if(c instanceof Float32Array)f=n.FLOAT;else if(typeof Float16Array<"u"&&c instanceof Float16Array)f=n.HALF_FLOAT;else if(c instanceof Uint16Array)o.isFloat16BufferAttribute?f=n.HALF_FLOAT:f=n.UNSIGNED_SHORT;else if(c instanceof Int16Array)f=n.SHORT;else if(c instanceof Uint32Array)f=n.UNSIGNED_INT;else if(c instanceof Int32Array)f=n.INT;else if(c instanceof Int8Array)f=n.BYTE;else if(c instanceof Uint8Array)f=n.UNSIGNED_BYTE;else if(c instanceof Uint8ClampedArray)f=n.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+c);return{buffer:d,type:f,bytesPerElement:c.BYTES_PER_ELEMENT,version:o.version,size:h}}function i(o,l,c){const u=l.array,h=l.updateRanges;if(n.bindBuffer(c,o),h.length===0)n.bufferSubData(c,0,u);else{h.sort((f,p)=>f.start-p.start);let d=0;for(let f=1;f<h.length;f++){const p=h[d],_=h[f];_.start<=p.start+p.count+1?p.count=Math.max(p.count,_.start+_.count-p.start):(++d,h[d]=_)}h.length=d+1;for(let f=0,p=h.length;f<p;f++){const _=h[f];n.bufferSubData(c,_.start*u.BYTES_PER_ELEMENT,u,_.start,_.count)}l.clearUpdateRanges()}l.onUploadCallback()}function s(o){return o.isInterleavedBufferAttribute&&(o=o.data),e.get(o)}function r(o){o.isInterleavedBufferAttribute&&(o=o.data);const l=e.get(o);l&&(n.deleteBuffer(l.buffer),e.delete(o))}function a(o,l){if(o.isInterleavedBufferAttribute&&(o=o.data),o.isGLBufferAttribute){const u=e.get(o);(!u||u.version<o.version)&&e.set(o,{buffer:o.buffer,type:o.type,bytesPerElement:o.elementSize,version:o.version});return}const c=e.get(o);if(c===void 0)e.set(o,t(o,l));else if(c.version<o.version){if(c.size!==o.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");i(c.buffer,o,l),c.version=o.version}}return{get:s,remove:r,update:a}}var c_=`#ifdef USE_ALPHAHASH
if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
#endif`,u_=`#ifdef USE_ALPHAHASH
const float ALPHA_HASH_SCALE = 0.05;
float hash2D( vec2 value ) {
return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );
}
float hash3D( vec3 value ) {
return hash2D( vec2( hash2D( value.xy ), value.z ) );
}
float getAlphaHashThreshold( vec3 position ) {
float maxDeriv = max(
length( dFdx( position.xyz ) ),
length( dFdy( position.xyz ) )
);
float pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );
vec2 pixScales = vec2(
exp2( floor( log2( pixScale ) ) ),
exp2( ceil( log2( pixScale ) ) )
);
vec2 alpha = vec2(
hash3D( floor( pixScales.x * position.xyz ) ),
hash3D( floor( pixScales.y * position.xyz ) )
);
float lerpFactor = fract( log2( pixScale ) );
float x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;
float a = min( lerpFactor, 1.0 - lerpFactor );
vec3 cases = vec3(
x * x / ( 2.0 * a * ( 1.0 - a ) ),
( x - 0.5 * a ) / ( 1.0 - a ),
1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )
);
float threshold = ( x < ( 1.0 - a ) )
? ( ( x < a ) ? cases.x : cases.y )
: cases.z;
return clamp( threshold , 1.0e-6, 1.0 );
}
#endif`,h_=`#ifdef USE_ALPHAMAP
diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
#endif`,d_=`#ifdef USE_ALPHAMAP
uniform sampler2D alphaMap;
#endif`,f_=`#ifdef USE_ALPHATEST
#ifdef ALPHA_TO_COVERAGE
diffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );
if ( diffuseColor.a == 0.0 ) discard;
#else
if ( diffuseColor.a < alphaTest ) discard;
#endif
#endif`,p_=`#ifdef USE_ALPHATEST
uniform float alphaTest;
#endif`,m_=`#ifdef USE_AOMAP
float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
reflectedLight.indirectDiffuse *= ambientOcclusion;
#if defined( USE_CLEARCOAT )
clearcoatSpecularIndirect *= ambientOcclusion;
#endif
#if defined( USE_SHEEN )
sheenSpecularIndirect *= ambientOcclusion;
#endif
#if defined( USE_ENVMAP ) && defined( STANDARD )
float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
#endif
#endif`,g_=`#ifdef USE_AOMAP
uniform sampler2D aoMap;
uniform float aoMapIntensity;
#endif`,__=`#ifdef USE_BATCHING
#if ! defined( GL_ANGLE_multi_draw )
#define gl_DrawID _gl_DrawID
uniform int _gl_DrawID;
#endif
uniform highp sampler2D batchingTexture;
uniform highp usampler2D batchingIdTexture;
mat4 getBatchingMatrix( const in float i ) {
int size = textureSize( batchingTexture, 0 ).x;
int j = int( i ) * 4;
int x = j % size;
int y = j / size;
vec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );
vec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );
vec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );
vec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );
return mat4( v1, v2, v3, v4 );
}
float getIndirectIndex( const in int i ) {
int size = textureSize( batchingIdTexture, 0 ).x;
int x = i % size;
int y = i / size;
return float( texelFetch( batchingIdTexture, ivec2( x, y ), 0 ).r );
}
#endif
#ifdef USE_BATCHING_COLOR
uniform sampler2D batchingColorTexture;
vec4 getBatchingColor( const in float i ) {
int size = textureSize( batchingColorTexture, 0 ).x;
int j = int( i );
int x = j % size;
int y = j / size;
return texelFetch( batchingColorTexture, ivec2( x, y ), 0 );
}
#endif`,x_=`#ifdef USE_BATCHING
mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
#endif`,y_=`vec3 transformed = vec3( position );
#ifdef USE_ALPHAHASH
vPosition = vec3( position );
#endif`,v_=`vec3 objectNormal = vec3( normal );
#ifdef USE_TANGENT
vec3 objectTangent = vec3( tangent.xyz );
#endif`,S_=`float G_BlinnPhong_Implicit( ) {
return 0.25;
}
float D_BlinnPhong( const in float shininess, const in float dotNH ) {
return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );
}
vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {
vec3 halfDir = normalize( lightDir + viewDir );
float dotNH = saturate( dot( normal, halfDir ) );
float dotVH = saturate( dot( viewDir, halfDir ) );
vec3 F = F_Schlick( specularColor, 1.0, dotVH );
float G = G_BlinnPhong_Implicit( );
float D = D_BlinnPhong( shininess, dotNH );
return F * ( G * D );
} // validated`,b_=`#ifdef USE_IRIDESCENCE
const mat3 XYZ_TO_REC709 = mat3(
3.2404542, -0.9692660, 0.0556434,
-1.5371385, 1.8760108, -0.2040259,
-0.4985314, 0.0415560, 1.0572252
);
vec3 Fresnel0ToIor( vec3 fresnel0 ) {
vec3 sqrtF0 = sqrt( fresnel0 );
return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );
}
vec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {
return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );
}
float IorToFresnel0( float transmittedIor, float incidentIor ) {
return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));
}
vec3 evalSensitivity( float OPD, vec3 shift ) {
float phase = 2.0 * PI * OPD * 1.0e-9;
vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );
vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );
vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );
vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );
xyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) );
xyz /= 1.0685e-7;
vec3 rgb = XYZ_TO_REC709 * xyz;
return rgb;
}
vec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {
vec3 I;
float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );
float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );
float cosTheta2Sq = 1.0 - sinTheta2Sq;
if ( cosTheta2Sq < 0.0 ) {
return vec3( 1.0 );
}
float cosTheta2 = sqrt( cosTheta2Sq );
float R0 = IorToFresnel0( iridescenceIOR, outsideIOR );
float R12 = F_Schlick( R0, 1.0, cosTheta1 );
float T121 = 1.0 - R12;
float phi12 = 0.0;
if ( iridescenceIOR < outsideIOR ) phi12 = PI;
float phi21 = PI - phi12;
vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) ); vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );
vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );
vec3 phi23 = vec3( 0.0 );
if ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;
if ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;
if ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;
float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;
vec3 phi = vec3( phi21 ) + phi23;
vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );
vec3 r123 = sqrt( R123 );
vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );
vec3 C0 = R12 + Rs;
I = C0;
vec3 Cm = Rs - T121;
for ( int m = 1; m <= 2; ++ m ) {
Cm *= r123;
vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );
I += Cm * Sm;
}
return max( I, vec3( 0.0 ) );
}
#endif`,M_=`#ifdef USE_BUMPMAP
uniform sampler2D bumpMap;
uniform float bumpScale;
vec2 dHdxy_fwd() {
vec2 dSTdx = dFdx( vBumpMapUv );
vec2 dSTdy = dFdy( vBumpMapUv );
float Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;
float dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;
float dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;
return vec2( dBx, dBy );
}
vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {
vec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );
vec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );
vec3 vN = surf_norm;
vec3 R1 = cross( vSigmaY, vN );
vec3 R2 = cross( vN, vSigmaX );
float fDet = dot( vSigmaX, R1 ) * faceDirection;
vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
return normalize( abs( fDet ) * surf_norm - vGrad );
}
#endif`,A_=`#if NUM_CLIPPING_PLANES > 0
vec4 plane;
#ifdef ALPHA_TO_COVERAGE
float distanceToPlane, distanceGradient;
float clipOpacity = 1.0;
#pragma unroll_loop_start
for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
plane = clippingPlanes[ i ];
distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
distanceGradient = fwidth( distanceToPlane ) / 2.0;
clipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
if ( clipOpacity == 0.0 ) discard;
}
#pragma unroll_loop_end
#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
float unionClipOpacity = 1.0;
#pragma unroll_loop_start
for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
plane = clippingPlanes[ i ];
distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
distanceGradient = fwidth( distanceToPlane ) / 2.0;
unionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
}
#pragma unroll_loop_end
clipOpacity *= 1.0 - unionClipOpacity;
#endif
diffuseColor.a *= clipOpacity;
if ( diffuseColor.a == 0.0 ) discard;
#else
#pragma unroll_loop_start
for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
plane = clippingPlanes[ i ];
if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;
}
#pragma unroll_loop_end
#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
bool clipped = true;
#pragma unroll_loop_start
for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
plane = clippingPlanes[ i ];
clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;
}
#pragma unroll_loop_end
if ( clipped ) discard;
#endif
#endif
#endif`,E_=`#if NUM_CLIPPING_PLANES > 0
varying vec3 vClipPosition;
uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
#endif`,T_=`#if NUM_CLIPPING_PLANES > 0
varying vec3 vClipPosition;
#endif`,C_=`#if NUM_CLIPPING_PLANES > 0
vClipPosition = - mvPosition.xyz;
#endif`,w_=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
diffuseColor *= vColor;
#endif`,R_=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
varying vec4 vColor;
#endif`,L_=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
varying vec4 vColor;
#endif`,D_=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
vColor = vec4( 1.0 );
#endif
#ifdef USE_COLOR_ALPHA
vColor *= color;
#elif defined( USE_COLOR )
vColor.rgb *= color;
#endif
#ifdef USE_INSTANCING_COLOR
vColor.rgb *= instanceColor.rgb;
#endif
#ifdef USE_BATCHING_COLOR
vColor *= getBatchingColor( getIndirectIndex( gl_DrawID ) );
#endif`,I_=`#define PI 3.141592653589793
#define PI2 6.283185307179586
#define PI_HALF 1.5707963267948966
#define RECIPROCAL_PI 0.3183098861837907
#define RECIPROCAL_PI2 0.15915494309189535
#define EPSILON 1e-6
#ifndef saturate
#define saturate( a ) clamp( a, 0.0, 1.0 )
#endif
#define whiteComplement( a ) ( 1.0 - saturate( a ) )
float pow2( const in float x ) { return x*x; }
vec3 pow2( const in vec3 x ) { return x*x; }
float pow3( const in float x ) { return x*x*x; }
float pow4( const in float x ) { float x2 = x*x; return x2*x2; }
float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }
float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }
highp float rand( const in vec2 uv ) {
const highp float a = 12.9898, b = 78.233, c = 43758.5453;
highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );
return fract( sin( sn ) * c );
}
#ifdef HIGH_PRECISION
float precisionSafeLength( vec3 v ) { return length( v ); }
#else
float precisionSafeLength( vec3 v ) {
float maxComponent = max3( abs( v ) );
return length( v / maxComponent ) * maxComponent;
}
#endif
struct IncidentLight {
vec3 color;
vec3 direction;
bool visible;
};
struct ReflectedLight {
vec3 directDiffuse;
vec3 directSpecular;
vec3 indirectDiffuse;
vec3 indirectSpecular;
};
#ifdef USE_ALPHAHASH
varying vec3 vPosition;
#endif
vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
}
#define inverseTransformDirection transformDirectionByInverseViewMatrix
vec3 transformNormalByInverseViewMatrix( in vec3 normal, in mat4 viewMatrix ) {
return normalize( ( vec4( normal, 0.0 ) * viewMatrix ).xyz );
}
vec3 transformDirectionByInverseViewMatrix( in vec3 dir, in mat4 viewMatrix ) {
return normalize( ( vec4( dir, 0.0 ) * viewMatrix ).xyz );
}
bool isPerspectiveMatrix( mat4 m ) {
return m[ 2 ][ 3 ] == - 1.0;
}
vec2 equirectUv( in vec3 dir ) {
float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;
float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;
return vec2( u, v );
}
vec3 BRDF_Lambert( const in vec3 diffuseColor ) {
return RECIPROCAL_PI * diffuseColor;
}
vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
}
float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
} // validated`,P_=`#ifdef ENVMAP_TYPE_CUBE_UV
#define cubeUV_minMipLevel 4.0
#define cubeUV_minTileSize 16.0
float getFace( vec3 direction ) {
vec3 absDirection = abs( direction );
float face = - 1.0;
if ( absDirection.x > absDirection.z ) {
if ( absDirection.x > absDirection.y )
face = direction.x > 0.0 ? 0.0 : 3.0;
else
face = direction.y > 0.0 ? 1.0 : 4.0;
} else {
if ( absDirection.z > absDirection.y )
face = direction.z > 0.0 ? 2.0 : 5.0;
else
face = direction.y > 0.0 ? 1.0 : 4.0;
}
return face;
}
vec2 getUV( vec3 direction, float face ) {
vec2 uv;
if ( face == 0.0 ) {
uv = vec2( direction.z, direction.y ) / abs( direction.x );
} else if ( face == 1.0 ) {
uv = vec2( - direction.x, - direction.z ) / abs( direction.y );
} else if ( face == 2.0 ) {
uv = vec2( - direction.x, direction.y ) / abs( direction.z );
} else if ( face == 3.0 ) {
uv = vec2( - direction.z, direction.y ) / abs( direction.x );
} else if ( face == 4.0 ) {
uv = vec2( - direction.x, direction.z ) / abs( direction.y );
} else {
uv = vec2( direction.x, direction.y ) / abs( direction.z );
}
return 0.5 * ( uv + 1.0 );
}
vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {
float face = getFace( direction );
float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );
mipInt = max( mipInt, cubeUV_minMipLevel );
float faceSize = exp2( mipInt );
highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;
if ( face > 2.0 ) {
uv.y += faceSize;
face -= 3.0;
}
uv.x += face * faceSize;
uv.x += filterInt * 3.0 * cubeUV_minTileSize;
uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );
uv.x *= CUBEUV_TEXEL_WIDTH;
uv.y *= CUBEUV_TEXEL_HEIGHT;
#ifdef texture2DGradEXT
return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;
#else
return texture2D( envMap, uv ).rgb;
#endif
}
#define cubeUV_r0 1.0
#define cubeUV_m0 - 2.0
#define cubeUV_r1 0.8
#define cubeUV_m1 - 1.0
#define cubeUV_r4 0.4
#define cubeUV_m4 2.0
#define cubeUV_r5 0.305
#define cubeUV_m5 3.0
#define cubeUV_r6 0.21
#define cubeUV_m6 4.0
float roughnessToMip( float roughness ) {
float mip = 0.0;
if ( roughness >= cubeUV_r1 ) {
mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;
} else if ( roughness >= cubeUV_r4 ) {
mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;
} else if ( roughness >= cubeUV_r5 ) {
mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;
} else if ( roughness >= cubeUV_r6 ) {
mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;
} else {
mip = - 2.0 * log2( 1.16 * roughness ); }
return mip;
}
vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {
float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );
float mipF = fract( mip );
float mipInt = floor( mip );
vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );
if ( mipF == 0.0 ) {
return vec4( color0, 1.0 );
} else {
vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );
return vec4( mix( color0, color1, mipF ), 1.0 );
}
}
#endif`,O_=`vec3 transformedNormal = objectNormal;
#ifdef USE_TANGENT
vec3 transformedTangent = objectTangent;
#endif
#ifdef USE_BATCHING
mat3 bm = mat3( batchingMatrix );
transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );
transformedNormal = bm * transformedNormal;
#ifdef USE_TANGENT
transformedTangent = bm * transformedTangent;
#endif
#endif
#ifdef USE_INSTANCING
mat3 im = mat3( instanceMatrix );
transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );
transformedNormal = im * transformedNormal;
#ifdef USE_TANGENT
transformedTangent = im * transformedTangent;
#endif
#endif
transformedNormal = normalMatrix * transformedNormal;
#ifdef FLIP_SIDED
transformedNormal = - transformedNormal;
#endif
#ifdef USE_TANGENT
transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;
#endif`,U_=`#ifdef USE_DISPLACEMENTMAP
uniform sampler2D displacementMap;
uniform float displacementScale;
uniform float displacementBias;
#endif`,N_=`#ifdef USE_DISPLACEMENTMAP
transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
#endif`,k_=`#ifdef USE_EMISSIVEMAP
vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
#ifdef DECODE_VIDEO_TEXTURE_EMISSIVE
emissiveColor = sRGBTransferEOTF( emissiveColor );
#endif
totalEmissiveRadiance *= emissiveColor.rgb;
#endif`,F_=`#ifdef USE_EMISSIVEMAP
uniform sampler2D emissiveMap;
#endif`,B_="gl_FragColor = linearToOutputTexel( gl_FragColor );",H_=`vec4 LinearTransferOETF( in vec4 value ) {
return value;
}
vec4 sRGBTransferEOTF( in vec4 value ) {
return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );
}
vec4 sRGBTransferOETF( in vec4 value ) {
return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );
}`,z_=`#ifdef USE_ENVMAP
#ifdef ENV_WORLDPOS
vec3 cameraToFrag;
if ( isOrthographic ) {
cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
} else {
cameraToFrag = normalize( vWorldPosition - cameraPosition );
}
vec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix );
#ifdef ENVMAP_MODE_REFLECTION
vec3 reflectVec = reflect( cameraToFrag, worldNormal );
#else
vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );
#endif
#else
vec3 reflectVec = vReflect;
#endif
#ifdef ENVMAP_TYPE_CUBE
vec4 envColor = textureCube( envMap, envMapRotation * reflectVec );
#ifdef ENVMAP_BLENDING_MULTIPLY
outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );
#elif defined( ENVMAP_BLENDING_MIX )
outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );
#elif defined( ENVMAP_BLENDING_ADD )
outgoingLight += envColor.xyz * specularStrength * reflectivity;
#endif
#endif
#endif`,V_=`#ifdef USE_ENVMAP
uniform float envMapIntensity;
uniform mat3 envMapRotation;
#ifdef ENVMAP_TYPE_CUBE
uniform samplerCube envMap;
#else
uniform sampler2D envMap;
#endif
#endif`,G_=`#ifdef USE_ENVMAP
uniform float reflectivity;
#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
#define ENV_WORLDPOS
#endif
#ifdef ENV_WORLDPOS
varying vec3 vWorldPosition;
uniform float refractionRatio;
#else
varying vec3 vReflect;
#endif
#endif`,W_=`#ifdef USE_ENVMAP
#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
#define ENV_WORLDPOS
#endif
#ifdef ENV_WORLDPOS
varying vec3 vWorldPosition;
#else
varying vec3 vReflect;
uniform float refractionRatio;
#endif
#endif`,X_=`#ifdef USE_ENVMAP
#ifdef ENV_WORLDPOS
vWorldPosition = worldPosition.xyz;
#else
vec3 cameraToVertex;
if ( isOrthographic ) {
cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
} else {
cameraToVertex = normalize( worldPosition.xyz - cameraPosition );
}
vec3 worldNormal = transformNormalByInverseViewMatrix( transformedNormal, viewMatrix );
#ifdef ENVMAP_MODE_REFLECTION
vReflect = reflect( cameraToVertex, worldNormal );
#else
vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
#endif
#endif
#endif`,Y_=`#ifdef USE_FOG
vFogDepth = - mvPosition.z;
#endif`,K_=`#ifdef USE_FOG
varying float vFogDepth;
#endif`,q_=`#ifdef USE_FOG
#ifdef FOG_EXP2
float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
#else
float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
#endif
gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
#endif`,$_=`#ifdef USE_FOG
uniform vec3 fogColor;
varying float vFogDepth;
#ifdef FOG_EXP2
uniform float fogDensity;
#else
uniform float fogNear;
uniform float fogFar;
#endif
#endif`,Z_=`#ifdef USE_GRADIENTMAP
uniform sampler2D gradientMap;
#endif
vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
float dotNL = dot( normal, lightDirection );
vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );
#ifdef USE_GRADIENTMAP
return vec3( texture2D( gradientMap, coord ).r );
#else
vec2 fw = fwidth( coord ) * 0.5;
return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
#endif
}`,J_=`#ifdef USE_LIGHTMAP
uniform sampler2D lightMap;
uniform float lightMapIntensity;
#endif`,j_=`LambertMaterial material;
material.diffuseColor = diffuseColor.rgb;
material.specularStrength = specularStrength;`,Q_=`varying vec3 vViewPosition;
struct LambertMaterial {
vec3 diffuseColor;
float specularStrength;
};
void RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
vec3 irradiance = dotNL * directLight.color;
reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
#define RE_Direct RE_Direct_Lambert
#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,ex=`uniform bool receiveShadow;
uniform vec3 ambientLightColor;
#if defined( USE_LIGHT_PROBES )
uniform vec3 lightProbe[ 9 ];
#endif
vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {
float x = normal.x, y = normal.y, z = normal.z;
vec3 result = shCoefficients[ 0 ] * 0.886227;
result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;
result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;
result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;
result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;
result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;
result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );
result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;
result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );
return result;
}
vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {
vec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix );
vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );
return irradiance;
}
vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {
vec3 irradiance = ambientLightColor;
return irradiance;
}
float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {
float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );
if ( cutoffDistance > 0.0 ) {
distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );
}
return distanceFalloff;
}
float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {
return smoothstep( coneCosine, penumbraCosine, angleCosine );
}
#if NUM_DIR_LIGHTS > 0
struct DirectionalLight {
vec3 direction;
vec3 color;
};
uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];
void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {
light.color = directionalLight.color;
light.direction = directionalLight.direction;
light.visible = true;
}
#endif
#if NUM_POINT_LIGHTS > 0
struct PointLight {
vec3 position;
vec3 color;
float distance;
float decay;
};
uniform PointLight pointLights[ NUM_POINT_LIGHTS ];
void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {
vec3 lVector = pointLight.position - geometryPosition;
light.direction = normalize( lVector );
float lightDistance = length( lVector );
light.color = pointLight.color;
light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );
light.visible = ( light.color != vec3( 0.0 ) );
}
#endif
#if NUM_SPOT_LIGHTS > 0
struct SpotLight {
vec3 position;
vec3 direction;
vec3 color;
float distance;
float decay;
float coneCos;
float penumbraCos;
};
uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];
void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {
vec3 lVector = spotLight.position - geometryPosition;
light.direction = normalize( lVector );
float angleCos = dot( light.direction, spotLight.direction );
float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );
if ( spotAttenuation > 0.0 ) {
float lightDistance = length( lVector );
light.color = spotLight.color * spotAttenuation;
light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );
light.visible = ( light.color != vec3( 0.0 ) );
} else {
light.color = vec3( 0.0 );
light.visible = false;
}
}
#endif
#if NUM_RECT_AREA_LIGHTS > 0
struct RectAreaLight {
vec3 color;
vec3 position;
vec3 halfWidth;
vec3 halfHeight;
};
uniform sampler2D ltc_1; uniform sampler2D ltc_2;
uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];
#endif
#if NUM_HEMI_LIGHTS > 0
struct HemisphereLight {
vec3 direction;
vec3 skyColor;
vec3 groundColor;
};
uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];
vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {
float dotNL = dot( normal, hemiLight.direction );
float hemiDiffuseWeight = 0.5 * dotNL + 0.5;
vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
return irradiance;
}
#endif
#include <lightprobes_pars_fragment>`,tx=`#ifdef USE_ENVMAP
vec3 getIBLIrradiance( const in vec3 normal ) {
#ifdef ENVMAP_TYPE_CUBE_UV
vec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix );
vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 );
return PI * envMapColor.rgb * envMapIntensity;
#else
return vec3( 0.0 );
#endif
}
vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {
#ifdef ENVMAP_TYPE_CUBE_UV
vec3 reflectVec = reflect( - viewDir, normal );
reflectVec = normalize( mix( reflectVec, normal, pow4( roughness ) ) );
reflectVec = transformDirectionByInverseViewMatrix( reflectVec, viewMatrix );
vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );
return envMapColor.rgb * envMapIntensity;
#else
return vec3( 0.0 );
#endif
}
#ifdef USE_ANISOTROPY
vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {
#ifdef ENVMAP_TYPE_CUBE_UV
vec3 bentNormal = cross( bitangent, viewDir );
bentNormal = normalize( cross( bentNormal, bitangent ) );
bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );
return getIBLRadiance( viewDir, bentNormal, roughness );
#else
return vec3( 0.0 );
#endif
}
#endif
#endif`,nx=`ToonMaterial material;
material.diffuseColor = diffuseColor.rgb;`,ix=`varying vec3 vViewPosition;
struct ToonMaterial {
vec3 diffuseColor;
};
void RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;
reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
#define RE_Direct RE_Direct_Toon
#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,sx=`BlinnPhongMaterial material;
material.diffuseColor = diffuseColor.rgb;
material.specularColor = specular;
material.specularShininess = shininess;
material.specularStrength = specularStrength;`,rx=`varying vec3 vViewPosition;
struct BlinnPhongMaterial {
vec3 diffuseColor;
vec3 specularColor;
float specularShininess;
float specularStrength;
};
void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
vec3 irradiance = dotNL * directLight.color;
reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;
}
void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
#define RE_Direct RE_Direct_BlinnPhong
#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,ax=`PhysicalMaterial material;
material.diffuseColor = diffuseColor.rgb;
material.diffuseContribution = diffuseColor.rgb * ( 1.0 - metalnessFactor );
material.metalness = metalnessFactor;
vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );
float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;
material.roughness = min( material.roughness, 1.0 );
#ifdef IOR
material.ior = ior;
#ifdef USE_SPECULAR
float specularIntensityFactor = specularIntensity;
vec3 specularColorFactor = specularColor;
#ifdef USE_SPECULAR_COLORMAP
specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;
#endif
#ifdef USE_SPECULAR_INTENSITYMAP
specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;
#endif
material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );
#else
float specularIntensityFactor = 1.0;
vec3 specularColorFactor = vec3( 1.0 );
material.specularF90 = 1.0;
#endif
material.specularColor = min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor;
material.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor );
#else
material.specularColor = vec3( 0.04 );
material.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor );
material.specularF90 = 1.0;
#endif
#ifdef USE_CLEARCOAT
material.clearcoat = clearcoat;
material.clearcoatRoughness = clearcoatRoughness;
material.clearcoatF0 = vec3( 0.04 );
material.clearcoatF90 = 1.0;
#ifdef USE_CLEARCOATMAP
material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;
#endif
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;
#endif
material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );
material.clearcoatRoughness += geometryRoughness;
material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );
#endif
#ifdef USE_DISPERSION
material.dispersion = dispersion;
#endif
#ifdef USE_IRIDESCENCE
material.iridescence = iridescence;
material.iridescenceIOR = iridescenceIOR;
#ifdef USE_IRIDESCENCEMAP
material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;
#endif
#ifdef USE_IRIDESCENCE_THICKNESSMAP
material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;
#else
material.iridescenceThickness = iridescenceThicknessMaximum;
#endif
#endif
#ifdef USE_SHEEN
material.sheenColor = sheenColor;
#ifdef USE_SHEEN_COLORMAP
material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;
#endif
material.sheenRoughness = clamp( sheenRoughness, 0.0001, 1.0 );
#ifdef USE_SHEEN_ROUGHNESSMAP
material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;
#endif
#endif
#ifdef USE_ANISOTROPY
#ifdef USE_ANISOTROPYMAP
mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );
vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;
vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;
#else
vec2 anisotropyV = anisotropyVector;
#endif
material.anisotropy = length( anisotropyV );
if( material.anisotropy == 0.0 ) {
anisotropyV = vec2( 1.0, 0.0 );
} else {
anisotropyV /= material.anisotropy;
material.anisotropy = saturate( material.anisotropy );
}
material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
#endif`,ox=`uniform sampler2D dfgLUT;
struct PhysicalMaterial {
vec3 diffuseColor;
vec3 diffuseContribution;
vec3 specularColor;
vec3 specularColorBlended;
float roughness;
float metalness;
float specularF90;
float dispersion;
#ifdef USE_CLEARCOAT
float clearcoat;
float clearcoatRoughness;
vec3 clearcoatF0;
float clearcoatF90;
#endif
#ifdef USE_IRIDESCENCE
float iridescence;
float iridescenceIOR;
float iridescenceThickness;
vec3 iridescenceFresnel;
vec3 iridescenceF0;
vec3 iridescenceFresnelDielectric;
vec3 iridescenceFresnelMetallic;
#endif
#ifdef USE_SHEEN
vec3 sheenColor;
float sheenRoughness;
#endif
#ifdef IOR
float ior;
#endif
#ifdef USE_TRANSMISSION
float transmission;
float transmissionAlpha;
float thickness;
float attenuationDistance;
vec3 attenuationColor;
#endif
#ifdef USE_ANISOTROPY
float anisotropy;
float alphaT;
vec3 anisotropyT;
vec3 anisotropyB;
#endif
};
vec3 clearcoatSpecularDirect = vec3( 0.0 );
vec3 clearcoatSpecularIndirect = vec3( 0.0 );
vec3 sheenSpecularDirect = vec3( 0.0 );
vec3 sheenSpecularIndirect = vec3(0.0 );
vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {
float x = clamp( 1.0 - dotVH, 0.0, 1.0 );
float x2 = x * x;
float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );
return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );
}
float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {
float a2 = pow2( alpha );
float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );
return 0.5 / max( gv + gl, EPSILON );
}
float D_GGX( const in float alpha, const in float dotNH ) {
float a2 = pow2( alpha );
float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;
return RECIPROCAL_PI * a2 / pow2( denom );
}
#ifdef USE_ANISOTROPY
float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {
float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );
float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );
return 0.5 / max( gv + gl, EPSILON );
}
float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {
float a2 = alphaT * alphaB;
highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );
highp float v2 = dot( v, v );
float w2 = a2 / v2;
return RECIPROCAL_PI * a2 * pow2 ( w2 );
}
#endif
#ifdef USE_CLEARCOAT
vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {
vec3 f0 = material.clearcoatF0;
float f90 = material.clearcoatF90;
float roughness = material.clearcoatRoughness;
float alpha = pow2( roughness );
vec3 halfDir = normalize( lightDir + viewDir );
float dotNL = saturate( dot( normal, lightDir ) );
float dotNV = saturate( dot( normal, viewDir ) );
float dotNH = saturate( dot( normal, halfDir ) );
float dotVH = saturate( dot( viewDir, halfDir ) );
vec3 F = F_Schlick( f0, f90, dotVH );
float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
float D = D_GGX( alpha, dotNH );
return F * ( V * D );
}
#endif
vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
vec3 f0 = material.specularColorBlended;
float f90 = material.specularF90;
float roughness = material.roughness;
float alpha = pow2( roughness );
vec3 halfDir = normalize( lightDir + viewDir );
float dotNL = saturate( dot( normal, lightDir ) );
float dotNV = saturate( dot( normal, viewDir ) );
float dotNH = saturate( dot( normal, halfDir ) );
float dotVH = saturate( dot( viewDir, halfDir ) );
vec3 F = F_Schlick( f0, f90, dotVH );
#ifdef USE_IRIDESCENCE
F = mix( F, material.iridescenceFresnel, material.iridescence );
#endif
#ifdef USE_ANISOTROPY
float dotTL = dot( material.anisotropyT, lightDir );
float dotTV = dot( material.anisotropyT, viewDir );
float dotTH = dot( material.anisotropyT, halfDir );
float dotBL = dot( material.anisotropyB, lightDir );
float dotBV = dot( material.anisotropyB, viewDir );
float dotBH = dot( material.anisotropyB, halfDir );
float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );
float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );
#else
float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
float D = D_GGX( alpha, dotNH );
#endif
return F * ( V * D );
}
vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {
const float LUT_SIZE = 64.0;
const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;
const float LUT_BIAS = 0.5 / LUT_SIZE;
float dotNV = saturate( dot( N, V ) );
vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );
uv = uv * LUT_SCALE + LUT_BIAS;
return uv;
}
float LTC_ClippedSphereFormFactor( const in vec3 f ) {
float l = length( f );
return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );
}
vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {
float x = dot( v1, v2 );
float y = abs( x );
float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;
float b = 3.4175940 + ( 4.1616724 + y ) * y;
float v = a / b;
float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;
return cross( v1, v2 ) * theta_sintheta;
}
vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {
vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];
vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];
vec3 lightNormal = cross( v1, v2 );
if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );
vec3 T1, T2;
T1 = normalize( V - N * dot( V, N ) );
T2 = - cross( N, T1 );
mat3 mat = mInv * transpose( mat3( T1, T2, N ) );
vec3 coords[ 4 ];
coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );
coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );
coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );
coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );
coords[ 0 ] = normalize( coords[ 0 ] );
coords[ 1 ] = normalize( coords[ 1 ] );
coords[ 2 ] = normalize( coords[ 2 ] );
coords[ 3 ] = normalize( coords[ 3 ] );
vec3 vectorFormFactor = vec3( 0.0 );
vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );
vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );
vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );
vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );
float result = LTC_ClippedSphereFormFactor( vectorFormFactor );
return vec3( result );
}
#if defined( USE_SHEEN )
float D_Charlie( float roughness, float dotNH ) {
float alpha = pow2( roughness );
float invAlpha = 1.0 / alpha;
float cos2h = dotNH * dotNH;
float sin2h = max( 1.0 - cos2h, 0.0078125 );
return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );
}
float V_Neubelt( float dotNV, float dotNL ) {
return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );
}
vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {
vec3 halfDir = normalize( lightDir + viewDir );
float dotNL = saturate( dot( normal, lightDir ) );
float dotNV = saturate( dot( normal, viewDir ) );
float dotNH = saturate( dot( normal, halfDir ) );
float D = D_Charlie( sheenRoughness, dotNH );
float V = V_Neubelt( dotNV, dotNL );
return sheenColor * ( D * V );
}
#endif
float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
float dotNV = saturate( dot( normal, viewDir ) );
float r2 = roughness * roughness;
float rInv = 1.0 / ( roughness + 0.1 );
float a = -1.9362 + 1.0678 * roughness + 0.4573 * r2 - 0.8469 * rInv;
float b = -0.6014 + 0.5538 * roughness - 0.4670 * r2 - 0.1255 * rInv;
float DG = exp( a * dotNV + b );
return saturate( DG );
}
vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {
float dotNV = saturate( dot( normal, viewDir ) );
vec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg;
return specularColor * fab.x + specularF90 * fab.y;
}
#ifdef USE_IRIDESCENCE
void computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
#else
void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
#endif
float dotNV = saturate( dot( normal, viewDir ) );
vec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg;
#ifdef USE_IRIDESCENCE
vec3 Fr = mix( specularColor, iridescenceF0, iridescence );
#else
vec3 Fr = specularColor;
#endif
vec3 FssEss = Fr * fab.x + specularF90 * fab.y;
float Ess = fab.x + fab.y;
float Ems = 1.0 - Ess;
vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );
singleScatter += FssEss;
multiScatter += Fms * Ems;
}
vec3 BRDF_GGX_Multiscatter( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
vec3 singleScatter = BRDF_GGX( lightDir, viewDir, normal, material );
float dotNL = saturate( dot( normal, lightDir ) );
float dotNV = saturate( dot( normal, viewDir ) );
vec2 dfgV = texture2D( dfgLUT, vec2( material.roughness, dotNV ) ).rg;
vec2 dfgL = texture2D( dfgLUT, vec2( material.roughness, dotNL ) ).rg;
vec3 FssEss_V = material.specularColorBlended * dfgV.x + material.specularF90 * dfgV.y;
vec3 FssEss_L = material.specularColorBlended * dfgL.x + material.specularF90 * dfgL.y;
float Ess_V = dfgV.x + dfgV.y;
float Ess_L = dfgL.x + dfgL.y;
float Ems_V = 1.0 - Ess_V;
float Ems_L = 1.0 - Ess_L;
vec3 Favg = material.specularColorBlended + ( 1.0 - material.specularColorBlended ) * 0.047619;
vec3 Fms = FssEss_V * FssEss_L * Favg / ( 1.0 - Ems_V * Ems_L * Favg + EPSILON );
float compensationFactor = Ems_V * Ems_L;
vec3 multiScatter = Fms * compensationFactor;
return singleScatter + multiScatter;
}
#if NUM_RECT_AREA_LIGHTS > 0
void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
vec3 normal = geometryNormal;
vec3 viewDir = geometryViewDir;
vec3 position = geometryPosition;
vec3 lightPos = rectAreaLight.position;
vec3 halfWidth = rectAreaLight.halfWidth;
vec3 halfHeight = rectAreaLight.halfHeight;
vec3 lightColor = rectAreaLight.color;
float roughness = material.roughness;
vec3 rectCoords[ 4 ];
rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;
rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;
rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;
vec2 uv = LTC_Uv( normal, viewDir, roughness );
vec4 t1 = texture2D( ltc_1, uv );
vec4 t2 = texture2D( ltc_2, uv );
mat3 mInv = mat3(
vec3( t1.x, 0, t1.y ),
vec3( 0, 1, 0 ),
vec3( t1.z, 0, t1.w )
);
vec3 fresnel = ( material.specularColorBlended * t2.x + ( material.specularF90 - material.specularColorBlended ) * t2.y );
reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );
reflectedLight.directDiffuse += lightColor * material.diffuseContribution * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );
#ifdef USE_CLEARCOAT
vec3 Ncc = geometryClearcoatNormal;
vec2 uvClearcoat = LTC_Uv( Ncc, viewDir, material.clearcoatRoughness );
vec4 t1Clearcoat = texture2D( ltc_1, uvClearcoat );
vec4 t2Clearcoat = texture2D( ltc_2, uvClearcoat );
mat3 mInvClearcoat = mat3(
vec3( t1Clearcoat.x, 0, t1Clearcoat.y ),
vec3( 0, 1, 0 ),
vec3( t1Clearcoat.z, 0, t1Clearcoat.w )
);
vec3 fresnelClearcoat = material.clearcoatF0 * t2Clearcoat.x + ( material.clearcoatF90 - material.clearcoatF0 ) * t2Clearcoat.y;
clearcoatSpecularDirect += lightColor * fresnelClearcoat * LTC_Evaluate( Ncc, viewDir, position, mInvClearcoat, rectCoords );
#endif
}
#endif
void RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
vec3 irradiance = dotNL * directLight.color;
#ifdef USE_CLEARCOAT
float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );
vec3 ccIrradiance = dotNLcc * directLight.color;
clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );
#endif
#ifdef USE_SHEEN
sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );
float sheenAlbedoV = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
float sheenAlbedoL = IBLSheenBRDF( geometryNormal, directLight.direction, material.sheenRoughness );
float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * max( sheenAlbedoV, sheenAlbedoL );
irradiance *= sheenEnergyComp;
#endif
reflectedLight.directSpecular += irradiance * BRDF_GGX_Multiscatter( directLight.direction, geometryViewDir, geometryNormal, material );
reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseContribution );
}
void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
vec3 diffuse = irradiance * BRDF_Lambert( material.diffuseContribution );
#ifdef USE_SHEEN
float sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo;
diffuse *= sheenEnergyComp;
#endif
reflectedLight.indirectDiffuse += diffuse;
}
void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {
#ifdef USE_CLEARCOAT
clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
#endif
#ifdef USE_SHEEN
sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ) * RECIPROCAL_PI;
#endif
vec3 singleScatteringDielectric = vec3( 0.0 );
vec3 multiScatteringDielectric = vec3( 0.0 );
vec3 singleScatteringMetallic = vec3( 0.0 );
vec3 multiScatteringMetallic = vec3( 0.0 );
#ifdef USE_IRIDESCENCE
computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnelDielectric, material.roughness, singleScatteringDielectric, multiScatteringDielectric );
computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.iridescence, material.iridescenceFresnelMetallic, material.roughness, singleScatteringMetallic, multiScatteringMetallic );
#else
computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScatteringDielectric, multiScatteringDielectric );
computeMultiscattering( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.roughness, singleScatteringMetallic, multiScatteringMetallic );
#endif
vec3 singleScattering = mix( singleScatteringDielectric, singleScatteringMetallic, material.metalness );
vec3 multiScattering = mix( multiScatteringDielectric, multiScatteringMetallic, material.metalness );
vec3 totalScatteringDielectric = singleScatteringDielectric + multiScatteringDielectric;
vec3 diffuse = material.diffuseContribution * ( 1.0 - totalScatteringDielectric );
vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
vec3 indirectSpecular = radiance * singleScattering;
indirectSpecular += multiScattering * cosineWeightedIrradiance;
vec3 indirectDiffuse = diffuse * cosineWeightedIrradiance;
#ifdef USE_SHEEN
float sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo;
indirectSpecular *= sheenEnergyComp;
indirectDiffuse *= sheenEnergyComp;
#endif
reflectedLight.indirectSpecular += indirectSpecular;
reflectedLight.indirectDiffuse += indirectDiffuse;
}
#define RE_Direct RE_Direct_Physical
#define RE_Direct_RectArea RE_Direct_RectArea_Physical
#define RE_IndirectDiffuse RE_IndirectDiffuse_Physical
#define RE_IndirectSpecular RE_IndirectSpecular_Physical
float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
}`,lx=`
vec3 geometryPosition = - vViewPosition;
vec3 geometryNormal = normal;
vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
vec3 geometryClearcoatNormal = vec3( 0.0 );
#ifdef USE_CLEARCOAT
geometryClearcoatNormal = clearcoatNormal;
#endif
#ifdef USE_IRIDESCENCE
float dotNVi = saturate( dot( normal, geometryViewDir ) );
if ( material.iridescenceThickness == 0.0 ) {
material.iridescence = 0.0;
} else {
material.iridescence = saturate( material.iridescence );
}
if ( material.iridescence > 0.0 ) {
material.iridescenceFresnelDielectric = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );
material.iridescenceFresnelMetallic = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.diffuseColor );
material.iridescenceFresnel = mix( material.iridescenceFresnelDielectric, material.iridescenceFresnelMetallic, material.metalness );
material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );
}
#endif
IncidentLight directLight;
#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )
PointLight pointLight;
#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0
PointLightShadow pointLightShadow;
#endif
#pragma unroll_loop_start
for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
pointLight = pointLights[ i ];
getPointLightInfo( pointLight, geometryPosition, directLight );
#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS ) && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) )
pointLightShadow = pointLightShadows[ i ];
directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;
#endif
RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
}
#pragma unroll_loop_end
#endif
#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )
SpotLight spotLight;
vec4 spotColor;
vec3 spotLightCoord;
bool inSpotLightMap;
#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0
SpotLightShadow spotLightShadow;
#endif
#pragma unroll_loop_start
for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
spotLight = spotLights[ i ];
getSpotLightInfo( spotLight, geometryPosition, directLight );
#if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
#define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX
#elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
#define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS
#else
#define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
#endif
#if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )
spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;
inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );
spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );
directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;
#endif
#undef SPOT_LIGHT_MAP_INDEX
#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
spotLightShadow = spotLightShadows[ i ];
directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
#endif
RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
}
#pragma unroll_loop_end
#endif
#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )
DirectionalLight directionalLight;
#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0
DirectionalLightShadow directionalLightShadow;
#endif
#pragma unroll_loop_start
for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
directionalLight = directionalLights[ i ];
getDirectionalLightInfo( directionalLight, directLight );
#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )
directionalLightShadow = directionalLightShadows[ i ];
directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
#endif
RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
}
#pragma unroll_loop_end
#endif
#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )
RectAreaLight rectAreaLight;
#pragma unroll_loop_start
for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {
rectAreaLight = rectAreaLights[ i ];
RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
}
#pragma unroll_loop_end
#endif
#if defined( RE_IndirectDiffuse )
vec3 iblIrradiance = vec3( 0.0 );
vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );
#if defined( USE_LIGHT_PROBES )
irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );
#endif
#if ( NUM_HEMI_LIGHTS > 0 )
#pragma unroll_loop_start
for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );
}
#pragma unroll_loop_end
#endif
#ifdef USE_LIGHT_PROBES_GRID
vec3 probeWorldPos = ( ( vec4( geometryPosition, 1.0 ) - viewMatrix[ 3 ] ) * viewMatrix ).xyz;
vec3 probeWorldNormal = transformNormalByInverseViewMatrix( geometryNormal, viewMatrix );
irradiance += getLightProbeGridIrradiance( probeWorldPos, probeWorldNormal );
#endif
#endif
#if defined( RE_IndirectSpecular )
vec3 radiance = vec3( 0.0 );
vec3 clearcoatRadiance = vec3( 0.0 );
#endif`,cx=`#if defined( RE_IndirectDiffuse )
#ifdef USE_LIGHTMAP
vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
irradiance += lightMapIrradiance;
#endif
#if defined( USE_ENVMAP ) && defined( ENVMAP_TYPE_CUBE_UV )
#if defined( STANDARD ) || defined( LAMBERT ) || defined( PHONG )
iblIrradiance += getIBLIrradiance( geometryNormal );
#endif
#endif
#endif
#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )
#ifdef USE_ANISOTROPY
radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );
#else
radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );
#endif
#ifdef USE_CLEARCOAT
clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
#endif
#endif`,ux=`#if defined( RE_IndirectDiffuse )
#if defined( LAMBERT ) || defined( PHONG )
irradiance += iblIrradiance;
#endif
RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
#endif
#if defined( RE_IndirectSpecular )
RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
#endif`,hx=`#ifdef USE_LIGHT_PROBES_GRID
uniform highp sampler3D probesSH;
uniform vec3 probesMin;
uniform vec3 probesMax;
uniform vec3 probesResolution;
vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
vec3 res = probesResolution;
vec3 gridRange = probesMax - probesMin;
vec3 resMinusOne = res - 1.0;
vec3 probeSpacing = gridRange / resMinusOne;
vec3 samplePos = worldPos + worldNormal * probeSpacing * 0.5;
vec3 uvw = clamp( ( samplePos - probesMin ) / gridRange, 0.0, 1.0 );
uvw = uvw * resMinusOne / res + 0.5 / res;
float nz = res.z;
float paddedSlices = nz + 2.0;
float atlasDepth = 7.0 * paddedSlices;
float uvZBase = uvw.z * nz + 1.0;
vec4 s0 = texture( probesSH, vec3( uvw.xy, ( uvZBase ) / atlasDepth ) );
vec4 s1 = texture( probesSH, vec3( uvw.xy, ( uvZBase + paddedSlices ) / atlasDepth ) );
vec4 s2 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 2.0 * paddedSlices ) / atlasDepth ) );
vec4 s3 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 3.0 * paddedSlices ) / atlasDepth ) );
vec4 s4 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 4.0 * paddedSlices ) / atlasDepth ) );
vec4 s5 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 5.0 * paddedSlices ) / atlasDepth ) );
vec4 s6 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 6.0 * paddedSlices ) / atlasDepth ) );
vec3 c0 = s0.xyz;
vec3 c1 = vec3( s0.w, s1.xy );
vec3 c2 = vec3( s1.zw, s2.x );
vec3 c3 = s2.yzw;
vec3 c4 = s3.xyz;
vec3 c5 = vec3( s3.w, s4.xy );
vec3 c6 = vec3( s4.zw, s5.x );
vec3 c7 = s5.yzw;
vec3 c8 = s6.xyz;
float x = worldNormal.x, y = worldNormal.y, z = worldNormal.z;
vec3 result = c0 * 0.886227;
result += c1 * 2.0 * 0.511664 * y;
result += c2 * 2.0 * 0.511664 * z;
result += c3 * 2.0 * 0.511664 * x;
result += c4 * 2.0 * 0.429043 * x * y;
result += c5 * 2.0 * 0.429043 * y * z;
result += c6 * ( 0.743125 * z * z - 0.247708 );
result += c7 * 2.0 * 0.429043 * x * z;
result += c8 * 0.429043 * ( x * x - y * y );
return max( result, vec3( 0.0 ) );
}
#endif`,dx=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
#endif`,fx=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
uniform float logDepthBufFC;
varying float vFragDepth;
varying float vIsPerspective;
#endif`,px=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
varying float vFragDepth;
varying float vIsPerspective;
#endif`,mx=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
vFragDepth = 1.0 + gl_Position.w;
vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
#endif`,gx=`#ifdef USE_MAP
vec4 sampledDiffuseColor = texture2D( map, vMapUv );
#ifdef DECODE_VIDEO_TEXTURE
sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );
#endif
diffuseColor *= sampledDiffuseColor;
#endif`,_x=`#ifdef USE_MAP
uniform sampler2D map;
#endif`,xx=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
#if defined( USE_POINTS_UV )
vec2 uv = vUv;
#else
vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;
#endif
#endif
#ifdef USE_MAP
diffuseColor *= texture2D( map, uv );
#endif
#ifdef USE_ALPHAMAP
diffuseColor.a *= texture2D( alphaMap, uv ).g;
#endif`,yx=`#if defined( USE_POINTS_UV )
varying vec2 vUv;
#else
#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
uniform mat3 uvTransform;
#endif
#endif
#ifdef USE_MAP
uniform sampler2D map;
#endif
#ifdef USE_ALPHAMAP
uniform sampler2D alphaMap;
#endif`,vx=`float metalnessFactor = metalness;
#ifdef USE_METALNESSMAP
vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
metalnessFactor *= texelMetalness.b;
#endif`,Sx=`#ifdef USE_METALNESSMAP
uniform sampler2D metalnessMap;
#endif`,bx=`#ifdef USE_INSTANCING_MORPH
float morphTargetInfluences[ MORPHTARGETS_COUNT ];
float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;
}
#endif`,Mx=`#if defined( USE_MORPHCOLORS )
vColor *= morphTargetBaseInfluence;
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
#if defined( USE_COLOR_ALPHA )
if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];
#elif defined( USE_COLOR )
if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
#endif
}
#endif`,Ax=`#ifdef USE_MORPHNORMALS
objectNormal *= morphTargetBaseInfluence;
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
}
#endif`,Ex=`#ifdef USE_MORPHTARGETS
#ifndef USE_INSTANCING_MORPH
uniform float morphTargetBaseInfluence;
uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
#endif
uniform sampler2DArray morphTargetsTexture;
uniform ivec2 morphTargetsTextureSize;
vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {
int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;
int y = texelIndex / morphTargetsTextureSize.x;
int x = texelIndex - y * morphTargetsTextureSize.x;
ivec3 morphUV = ivec3( x, y, morphTargetIndex );
return texelFetch( morphTargetsTexture, morphUV, 0 );
}
#endif`,Tx=`#ifdef USE_MORPHTARGETS
transformed *= morphTargetBaseInfluence;
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
}
#endif`,Cx=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
#ifdef FLAT_SHADED
vec3 fdx = dFdx( vViewPosition );
vec3 fdy = dFdy( vViewPosition );
vec3 normal = normalize( cross( fdx, fdy ) );
#else
vec3 normal = normalize( vNormal );
#ifdef DOUBLE_SIDED
normal *= faceDirection;
#endif
#endif
#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )
#ifdef USE_TANGENT
mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
#else
mat3 tbn = getTangentFrame( - vViewPosition, normal,
#if defined( USE_NORMALMAP )
vNormalMapUv
#elif defined( USE_CLEARCOAT_NORMALMAP )
vClearcoatNormalMapUv
#else
vUv
#endif
);
#endif
#ifdef DOUBLE_SIDED
tbn[0] *= faceDirection;
tbn[1] *= faceDirection;
#endif
#endif
#ifdef USE_CLEARCOAT_NORMALMAP
#ifdef USE_TANGENT
mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
#else
mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );
#endif
#ifdef DOUBLE_SIDED
tbn2[0] *= faceDirection;
tbn2[1] *= faceDirection;
#endif
#endif
vec3 nonPerturbedNormal = normal;`,wx=`#ifdef USE_NORMALMAP_OBJECTSPACE
normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
#ifdef FLIP_SIDED
normal = - normal;
#endif
#ifdef DOUBLE_SIDED
normal = normal * faceDirection;
#endif
normal = normalize( normalMatrix * normal );
#elif defined( USE_NORMALMAP_TANGENTSPACE )
vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
#if defined( USE_PACKED_NORMALMAP )
mapN = vec3( mapN.xy, sqrt( saturate( 1.0 - dot( mapN.xy, mapN.xy ) ) ) );
#endif
mapN.xy *= normalScale;
normal = normalize( tbn * mapN );
#elif defined( USE_BUMPMAP )
normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
#endif`,Rx=`#ifndef FLAT_SHADED
varying vec3 vNormal;
#ifdef USE_TANGENT
varying vec3 vTangent;
varying vec3 vBitangent;
#endif
#endif`,Lx=`#ifndef FLAT_SHADED
varying vec3 vNormal;
#ifdef USE_TANGENT
varying vec3 vTangent;
varying vec3 vBitangent;
#endif
#endif`,Dx=`#ifndef FLAT_SHADED
vNormal = normalize( transformedNormal );
#ifdef USE_TANGENT
vTangent = normalize( transformedTangent );
vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
#ifdef FLIP_SIDED
vBitangent = - vBitangent;
#endif
#endif
#endif`,Ix=`#ifdef USE_NORMALMAP
uniform sampler2D normalMap;
uniform vec2 normalScale;
#endif
#ifdef USE_NORMALMAP_OBJECTSPACE
uniform mat3 normalMatrix;
#endif
#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )
mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {
vec3 q0 = dFdx( eye_pos.xyz );
vec3 q1 = dFdy( eye_pos.xyz );
vec2 st0 = dFdx( uv.st );
vec2 st1 = dFdy( uv.st );
vec3 N = surf_norm;
vec3 q1perp = cross( q1, N );
vec3 q0perp = cross( N, q0 );
vec3 T = q1perp * st0.x + q0perp * st1.x;
vec3 B = q1perp * st0.y + q0perp * st1.y;
float det = max( dot( T, T ), dot( B, B ) );
float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
return mat3( T * scale, B * scale, N );
}
#endif`,Px=`#ifdef USE_CLEARCOAT
vec3 clearcoatNormal = nonPerturbedNormal;
#endif`,Ox=`#ifdef USE_CLEARCOAT_NORMALMAP
vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
clearcoatMapN.xy *= clearcoatNormalScale;
clearcoatNormal = normalize( tbn2 * clearcoatMapN );
#endif`,Ux=`#ifdef USE_CLEARCOATMAP
uniform sampler2D clearcoatMap;
#endif
#ifdef USE_CLEARCOAT_NORMALMAP
uniform sampler2D clearcoatNormalMap;
uniform vec2 clearcoatNormalScale;
#endif
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
uniform sampler2D clearcoatRoughnessMap;
#endif`,Nx=`#ifdef USE_IRIDESCENCEMAP
uniform sampler2D iridescenceMap;
#endif
#ifdef USE_IRIDESCENCE_THICKNESSMAP
uniform sampler2D iridescenceThicknessMap;
#endif`,kx=`#ifdef OPAQUE
diffuseColor.a = 1.0;
#endif
#ifdef USE_TRANSMISSION
diffuseColor.a *= material.transmissionAlpha;
#endif
gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,Fx=`vec3 packNormalToRGB( const in vec3 normal ) {
return normalize( normal ) * 0.5 + 0.5;
}
vec3 unpackRGBToNormal( const in vec3 rgb ) {
return 2.0 * rgb.xyz - 1.0;
}
const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.;
const float Inv255 = 1. / 255.;
const vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 );
const vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g );
const vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b );
const vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a );
vec4 packDepthToRGBA( const in float v ) {
if( v <= 0.0 )
return vec4( 0., 0., 0., 0. );
if( v >= 1.0 )
return vec4( 1., 1., 1., 1. );
float vuf;
float af = modf( v * PackFactors.a, vuf );
float bf = modf( vuf * ShiftRight8, vuf );
float gf = modf( vuf * ShiftRight8, vuf );
return vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af );
}
vec3 packDepthToRGB( const in float v ) {
if( v <= 0.0 )
return vec3( 0., 0., 0. );
if( v >= 1.0 )
return vec3( 1., 1., 1. );
float vuf;
float bf = modf( v * PackFactors.b, vuf );
float gf = modf( vuf * ShiftRight8, vuf );
return vec3( vuf * Inv255, gf * PackUpscale, bf );
}
vec2 packDepthToRG( const in float v ) {
if( v <= 0.0 )
return vec2( 0., 0. );
if( v >= 1.0 )
return vec2( 1., 1. );
float vuf;
float gf = modf( v * 256., vuf );
return vec2( vuf * Inv255, gf );
}
float unpackRGBAToDepth( const in vec4 v ) {
return dot( v, UnpackFactors4 );
}
float unpackRGBToDepth( const in vec3 v ) {
return dot( v, UnpackFactors3 );
}
float unpackRGToDepth( const in vec2 v ) {
return v.r * UnpackFactors2.r + v.g * UnpackFactors2.g;
}
vec4 pack2HalfToRGBA( const in vec2 v ) {
vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );
return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );
}
vec2 unpackRGBATo2Half( const in vec4 v ) {
return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );
}
float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {
return ( viewZ + near ) / ( near - far );
}
float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {
#ifdef USE_REVERSED_DEPTH_BUFFER
return depth * ( far - near ) - far;
#else
return depth * ( near - far ) - near;
#endif
}
float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {
return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );
}
float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {
#ifdef USE_REVERSED_DEPTH_BUFFER
return ( near * far ) / ( ( near - far ) * depth - near );
#else
return ( near * far ) / ( ( far - near ) * depth - far );
#endif
}`,Bx=`#ifdef PREMULTIPLIED_ALPHA
gl_FragColor.rgb *= gl_FragColor.a;
#endif`,Hx=`vec4 mvPosition = vec4( transformed, 1.0 );
#ifdef USE_BATCHING
mvPosition = batchingMatrix * mvPosition;
#endif
#ifdef USE_INSTANCING
mvPosition = instanceMatrix * mvPosition;
#endif
mvPosition = modelViewMatrix * mvPosition;
gl_Position = projectionMatrix * mvPosition;`,zx=`#ifdef DITHERING
gl_FragColor.rgb = dithering( gl_FragColor.rgb );
#endif`,Vx=`#ifdef DITHERING
vec3 dithering( vec3 color ) {
float grid_position = rand( gl_FragCoord.xy );
vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
return color + dither_shift_RGB;
}
#endif`,Gx=`float roughnessFactor = roughness;
#ifdef USE_ROUGHNESSMAP
vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
roughnessFactor *= texelRoughness.g;
#endif`,Wx=`#ifdef USE_ROUGHNESSMAP
uniform sampler2D roughnessMap;
#endif`,Xx=`#if NUM_SPOT_LIGHT_COORDS > 0
varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
#endif
#if NUM_SPOT_LIGHT_MAPS > 0
uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];
#endif
#ifdef USE_SHADOWMAP
#if NUM_DIR_LIGHT_SHADOWS > 0
#if defined( SHADOWMAP_TYPE_PCF )
uniform sampler2DShadow directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
#else
uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
#endif
varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
struct DirectionalLightShadow {
float shadowIntensity;
float shadowBias;
float shadowNormalBias;
float shadowRadius;
vec2 shadowMapSize;
};
uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
#endif
#if NUM_SPOT_LIGHT_SHADOWS > 0
#if defined( SHADOWMAP_TYPE_PCF )
uniform sampler2DShadow spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
#else
uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
#endif
struct SpotLightShadow {
float shadowIntensity;
float shadowBias;
float shadowNormalBias;
float shadowRadius;
vec2 shadowMapSize;
};
uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
#endif
#if NUM_POINT_LIGHT_SHADOWS > 0
#if defined( SHADOWMAP_TYPE_PCF )
uniform samplerCubeShadow pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
#elif defined( SHADOWMAP_TYPE_BASIC )
uniform samplerCube pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
#endif
varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
struct PointLightShadow {
float shadowIntensity;
float shadowBias;
float shadowNormalBias;
float shadowRadius;
vec2 shadowMapSize;
float shadowCameraNear;
float shadowCameraFar;
};
uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
#endif
#if defined( SHADOWMAP_TYPE_PCF )
float interleavedGradientNoise( vec2 position ) {
return fract( 52.9829189 * fract( dot( position, vec2( 0.06711056, 0.00583715 ) ) ) );
}
vec2 vogelDiskSample( int sampleIndex, int samplesCount, float phi ) {
const float goldenAngle = 2.399963229728653;
float r = sqrt( ( float( sampleIndex ) + 0.5 ) / float( samplesCount ) );
float theta = float( sampleIndex ) * goldenAngle + phi;
return vec2( cos( theta ), sin( theta ) ) * r;
}
#endif
#if defined( SHADOWMAP_TYPE_PCF )
float getShadow( sampler2DShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
float shadow = 1.0;
shadowCoord.xyz /= shadowCoord.w;
shadowCoord.z += shadowBias;
bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
if ( frustumTest ) {
vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
float radius = shadowRadius * texelSize.x;
float phi = interleavedGradientNoise( gl_FragCoord.xy ) * PI2;
shadow = (
texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 0, 5, phi ) * radius, shadowCoord.z ) ) +
texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 1, 5, phi ) * radius, shadowCoord.z ) ) +
texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 2, 5, phi ) * radius, shadowCoord.z ) ) +
texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 3, 5, phi ) * radius, shadowCoord.z ) ) +
texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 4, 5, phi ) * radius, shadowCoord.z ) )
) * 0.2;
}
return mix( 1.0, shadow, shadowIntensity );
}
#elif defined( SHADOWMAP_TYPE_VSM )
float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
float shadow = 1.0;
shadowCoord.xyz /= shadowCoord.w;
#ifdef USE_REVERSED_DEPTH_BUFFER
shadowCoord.z -= shadowBias;
#else
shadowCoord.z += shadowBias;
#endif
bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
if ( frustumTest ) {
vec2 distribution = texture2D( shadowMap, shadowCoord.xy ).rg;
float mean = distribution.x;
float variance = distribution.y * distribution.y;
#ifdef USE_REVERSED_DEPTH_BUFFER
float hard_shadow = step( mean, shadowCoord.z );
#else
float hard_shadow = step( shadowCoord.z, mean );
#endif
if ( hard_shadow == 1.0 ) {
shadow = 1.0;
} else {
variance = max( variance, 0.0000001 );
float d = shadowCoord.z - mean;
float p_max = variance / ( variance + d * d );
p_max = clamp( ( p_max - 0.3 ) / 0.65, 0.0, 1.0 );
shadow = max( hard_shadow, p_max );
}
}
return mix( 1.0, shadow, shadowIntensity );
}
#else
float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
float shadow = 1.0;
shadowCoord.xyz /= shadowCoord.w;
#ifdef USE_REVERSED_DEPTH_BUFFER
shadowCoord.z -= shadowBias;
#else
shadowCoord.z += shadowBias;
#endif
bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
if ( frustumTest ) {
float depth = texture2D( shadowMap, shadowCoord.xy ).r;
#ifdef USE_REVERSED_DEPTH_BUFFER
shadow = step( depth, shadowCoord.z );
#else
shadow = step( shadowCoord.z, depth );
#endif
}
return mix( 1.0, shadow, shadowIntensity );
}
#endif
#if NUM_POINT_LIGHT_SHADOWS > 0
#if defined( SHADOWMAP_TYPE_PCF )
float getPointShadow( samplerCubeShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
float shadow = 1.0;
vec3 lightToPosition = shadowCoord.xyz;
vec3 bd3D = normalize( lightToPosition );
vec3 absVec = abs( lightToPosition );
float viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z );
if ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) {
#ifdef USE_REVERSED_DEPTH_BUFFER
float dp = ( shadowCameraNear * ( shadowCameraFar - viewSpaceZ ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) );
dp -= shadowBias;
#else
float dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) );
dp += shadowBias;
#endif
float texelSize = shadowRadius / shadowMapSize.x;
vec3 absDir = abs( bd3D );
vec3 tangent = absDir.x > absDir.z ? vec3( 0.0, 1.0, 0.0 ) : vec3( 1.0, 0.0, 0.0 );
tangent = normalize( cross( bd3D, tangent ) );
vec3 bitangent = cross( bd3D, tangent );
float phi = interleavedGradientNoise( gl_FragCoord.xy ) * PI2;
vec2 sample0 = vogelDiskSample( 0, 5, phi );
vec2 sample1 = vogelDiskSample( 1, 5, phi );
vec2 sample2 = vogelDiskSample( 2, 5, phi );
vec2 sample3 = vogelDiskSample( 3, 5, phi );
vec2 sample4 = vogelDiskSample( 4, 5, phi );
shadow = (
texture( shadowMap, vec4( bd3D + ( tangent * sample0.x + bitangent * sample0.y ) * texelSize, dp ) ) +
texture( shadowMap, vec4( bd3D + ( tangent * sample1.x + bitangent * sample1.y ) * texelSize, dp ) ) +
texture( shadowMap, vec4( bd3D + ( tangent * sample2.x + bitangent * sample2.y ) * texelSize, dp ) ) +
texture( shadowMap, vec4( bd3D + ( tangent * sample3.x + bitangent * sample3.y ) * texelSize, dp ) ) +
texture( shadowMap, vec4( bd3D + ( tangent * sample4.x + bitangent * sample4.y ) * texelSize, dp ) )
) * 0.2;
}
return mix( 1.0, shadow, shadowIntensity );
}
#elif defined( SHADOWMAP_TYPE_BASIC )
float getPointShadow( samplerCube shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
float shadow = 1.0;
vec3 lightToPosition = shadowCoord.xyz;
vec3 absVec = abs( lightToPosition );
float viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z );
if ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) {
float dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) );
dp += shadowBias;
vec3 bd3D = normalize( lightToPosition );
float depth = textureCube( shadowMap, bd3D ).r;
#ifdef USE_REVERSED_DEPTH_BUFFER
depth = 1.0 - depth;
#endif
shadow = step( dp, depth );
}
return mix( 1.0, shadow, shadowIntensity );
}
#endif
#endif
#endif`,Yx=`#if NUM_SPOT_LIGHT_COORDS > 0
uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
#endif
#ifdef USE_SHADOWMAP
#if NUM_DIR_LIGHT_SHADOWS > 0
uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];
varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
struct DirectionalLightShadow {
float shadowIntensity;
float shadowBias;
float shadowNormalBias;
float shadowRadius;
vec2 shadowMapSize;
};
uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
#endif
#if NUM_SPOT_LIGHT_SHADOWS > 0
struct SpotLightShadow {
float shadowIntensity;
float shadowBias;
float shadowNormalBias;
float shadowRadius;
vec2 shadowMapSize;
};
uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
#endif
#if NUM_POINT_LIGHT_SHADOWS > 0
uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];
varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
struct PointLightShadow {
float shadowIntensity;
float shadowBias;
float shadowNormalBias;
float shadowRadius;
vec2 shadowMapSize;
float shadowCameraNear;
float shadowCameraFar;
};
uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
#endif
#endif`,Kx=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
#ifdef HAS_NORMAL
vec3 shadowWorldNormal = transformNormalByInverseViewMatrix( transformedNormal, viewMatrix );
#else
vec3 shadowWorldNormal = vec3( 0.0 );
#endif
vec4 shadowWorldPosition;
#endif
#if defined( USE_SHADOWMAP )
#if NUM_DIR_LIGHT_SHADOWS > 0
#pragma unroll_loop_start
for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );
vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;
}
#pragma unroll_loop_end
#endif
#if NUM_POINT_LIGHT_SHADOWS > 0
#pragma unroll_loop_start
for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );
vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;
}
#pragma unroll_loop_end
#endif
#endif
#if NUM_SPOT_LIGHT_COORDS > 0
#pragma unroll_loop_start
for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {
shadowWorldPosition = worldPosition;
#if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;
#endif
vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
}
#pragma unroll_loop_end
#endif`,qx=`float getShadowMask() {
float shadow = 1.0;
#ifdef USE_SHADOWMAP
#if NUM_DIR_LIGHT_SHADOWS > 0
DirectionalLightShadow directionalLight;
#pragma unroll_loop_start
for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
directionalLight = directionalLightShadows[ i ];
shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
}
#pragma unroll_loop_end
#endif
#if NUM_SPOT_LIGHT_SHADOWS > 0
SpotLightShadow spotLight;
#pragma unroll_loop_start
for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {
spotLight = spotLightShadows[ i ];
shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
}
#pragma unroll_loop_end
#endif
#if NUM_POINT_LIGHT_SHADOWS > 0 && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) )
PointLightShadow pointLight;
#pragma unroll_loop_start
for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
pointLight = pointLightShadows[ i ];
shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;
}
#pragma unroll_loop_end
#endif
#endif
return shadow;
}`,$x=`#ifdef USE_SKINNING
mat4 boneMatX = getBoneMatrix( skinIndex.x );
mat4 boneMatY = getBoneMatrix( skinIndex.y );
mat4 boneMatZ = getBoneMatrix( skinIndex.z );
mat4 boneMatW = getBoneMatrix( skinIndex.w );
#endif`,Zx=`#ifdef USE_SKINNING
uniform mat4 bindMatrix;
uniform mat4 bindMatrixInverse;
uniform highp sampler2D boneTexture;
mat4 getBoneMatrix( const in float i ) {
int size = textureSize( boneTexture, 0 ).x;
int j = int( i ) * 4;
int x = j % size;
int y = j / size;
vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );
vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );
vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );
vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
return mat4( v1, v2, v3, v4 );
}
#endif`,Jx=`#ifdef USE_SKINNING
vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
vec4 skinned = vec4( 0.0 );
skinned += boneMatX * skinVertex * skinWeight.x;
skinned += boneMatY * skinVertex * skinWeight.y;
skinned += boneMatZ * skinVertex * skinWeight.z;
skinned += boneMatW * skinVertex * skinWeight.w;
transformed = ( bindMatrixInverse * skinned ).xyz;
#endif`,jx=`#ifdef USE_SKINNING
mat4 skinMatrix = mat4( 0.0 );
skinMatrix += skinWeight.x * boneMatX;
skinMatrix += skinWeight.y * boneMatY;
skinMatrix += skinWeight.z * boneMatZ;
skinMatrix += skinWeight.w * boneMatW;
skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;
objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;
#ifdef USE_TANGENT
objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
#endif
#endif`,Qx=`float specularStrength;
#ifdef USE_SPECULARMAP
vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
specularStrength = texelSpecular.r;
#else
specularStrength = 1.0;
#endif`,e1=`#ifdef USE_SPECULARMAP
uniform sampler2D specularMap;
#endif`,t1=`#if defined( TONE_MAPPING )
gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
#endif`,n1=`#ifndef saturate
#define saturate( a ) clamp( a, 0.0, 1.0 )
#endif
uniform float toneMappingExposure;
vec3 LinearToneMapping( vec3 color ) {
return saturate( toneMappingExposure * color );
}
vec3 ReinhardToneMapping( vec3 color ) {
color *= toneMappingExposure;
return saturate( color / ( vec3( 1.0 ) + color ) );
}
vec3 CineonToneMapping( vec3 color ) {
color *= toneMappingExposure;
color = max( vec3( 0.0 ), color - 0.004 );
return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );
}
vec3 RRTAndODTFit( vec3 v ) {
vec3 a = v * ( v + 0.0245786 ) - 0.000090537;
vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;
return a / b;
}
vec3 ACESFilmicToneMapping( vec3 color ) {
const mat3 ACESInputMat = mat3(
vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ),
vec3( 0.04823, 0.01566, 0.83777 )
);
const mat3 ACESOutputMat = mat3(
vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ),
vec3( -0.07367, -0.00605, 1.07602 )
);
color *= toneMappingExposure / 0.6;
color = ACESInputMat * color;
color = RRTAndODTFit( color );
color = ACESOutputMat * color;
return saturate( color );
}
const mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3(
vec3( 1.6605, - 0.1246, - 0.0182 ),
vec3( - 0.5876, 1.1329, - 0.1006 ),
vec3( - 0.0728, - 0.0083, 1.1187 )
);
const mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3(
vec3( 0.6274, 0.0691, 0.0164 ),
vec3( 0.3293, 0.9195, 0.0880 ),
vec3( 0.0433, 0.0113, 0.8956 )
);
vec3 agxDefaultContrastApprox( vec3 x ) {
vec3 x2 = x * x;
vec3 x4 = x2 * x2;
return + 15.5 * x4 * x2
- 40.14 * x4 * x
+ 31.96 * x4
- 6.868 * x2 * x
+ 0.4298 * x2
+ 0.1191 * x
- 0.00232;
}
vec3 AgXToneMapping( vec3 color ) {
const mat3 AgXInsetMatrix = mat3(
vec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),
vec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),
vec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )
);
const mat3 AgXOutsetMatrix = mat3(
vec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),
vec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),
vec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )
);
const float AgxMinEv = - 12.47393; const float AgxMaxEv = 4.026069;
color *= toneMappingExposure;
color = LINEAR_SRGB_TO_LINEAR_REC2020 * color;
color = AgXInsetMatrix * color;
color = max( color, 1e-10 ); color = log2( color );
color = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );
color = clamp( color, 0.0, 1.0 );
color = agxDefaultContrastApprox( color );
color = AgXOutsetMatrix * color;
color = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );
color = LINEAR_REC2020_TO_LINEAR_SRGB * color;
color = clamp( color, 0.0, 1.0 );
return color;
}
vec3 NeutralToneMapping( vec3 color ) {
const float StartCompression = 0.8 - 0.04;
const float Desaturation = 0.15;
color *= toneMappingExposure;
float x = min( color.r, min( color.g, color.b ) );
float offset = x < 0.08 ? x - 6.25 * x * x : 0.04;
color -= offset;
float peak = max( color.r, max( color.g, color.b ) );
if ( peak < StartCompression ) return color;
float d = 1. - StartCompression;
float newPeak = 1. - d * d / ( peak + d - StartCompression );
color *= newPeak / peak;
float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );
return mix( color, vec3( newPeak ), g );
}
vec3 CustomToneMapping( vec3 color ) { return color; }`,i1=`#ifdef USE_TRANSMISSION
material.transmission = transmission;
material.transmissionAlpha = 1.0;
material.thickness = thickness;
material.attenuationDistance = attenuationDistance;
material.attenuationColor = attenuationColor;
#ifdef USE_TRANSMISSIONMAP
material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;
#endif
#ifdef USE_THICKNESSMAP
material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;
#endif
vec3 pos = vWorldPosition;
vec3 v = normalize( cameraPosition - pos );
vec3 n = transformNormalByInverseViewMatrix( normal, viewMatrix );
vec4 transmitted = getIBLVolumeRefraction(
n, v, material.roughness, material.diffuseContribution, material.specularColorBlended, material.specularF90,
pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness,
material.attenuationColor, material.attenuationDistance );
material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
#endif`,s1=`#ifdef USE_TRANSMISSION
uniform float transmission;
uniform float thickness;
uniform float attenuationDistance;
uniform vec3 attenuationColor;
#ifdef USE_TRANSMISSIONMAP
uniform sampler2D transmissionMap;
#endif
#ifdef USE_THICKNESSMAP
uniform sampler2D thicknessMap;
#endif
uniform vec2 transmissionSamplerSize;
uniform sampler2D transmissionSamplerMap;
uniform mat4 modelMatrix;
uniform mat4 projectionMatrix;
varying vec3 vWorldPosition;
float w0( float a ) {
return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );
}
float w1( float a ) {
return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );
}
float w2( float a ){
return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );
}
float w3( float a ) {
return ( 1.0 / 6.0 ) * ( a * a * a );
}
float g0( float a ) {
return w0( a ) + w1( a );
}
float g1( float a ) {
return w2( a ) + w3( a );
}
float h0( float a ) {
return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );
}
float h1( float a ) {
return 1.0 + w3( a ) / ( w2( a ) + w3( a ) );
}
vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {
uv = uv * texelSize.zw + 0.5;
vec2 iuv = floor( uv );
vec2 fuv = fract( uv );
float g0x = g0( fuv.x );
float g1x = g1( fuv.x );
float h0x = h0( fuv.x );
float h1x = h1( fuv.x );
float h0y = h0( fuv.y );
float h1y = h1( fuv.y );
vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +
g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );
}
vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {
vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );
vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );
vec2 fLodSizeInv = 1.0 / fLodSize;
vec2 cLodSizeInv = 1.0 / cLodSize;
vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );
vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );
return mix( fSample, cSample, fract( lod ) );
}
vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {
vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );
vec3 modelScale;
modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );
modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );
modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );
return normalize( refractionVector ) * thickness * modelScale;
}
float applyIorToRoughness( const in float roughness, const in float ior ) {
return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );
}
vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {
float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );
return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );
}
vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {
if ( isinf( attenuationDistance ) ) {
return vec3( 1.0 );
} else {
vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;
vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance;
}
}
vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,
const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,
const in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness,
const in vec3 attenuationColor, const in float attenuationDistance ) {
vec4 transmittedLight;
vec3 transmittance;
#ifdef USE_DISPERSION
float halfSpread = ( ior - 1.0 ) * 0.025 * dispersion;
vec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread );
for ( int i = 0; i < 3; i ++ ) {
vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix );
vec3 refractedRayExit = position + transmissionRay;
vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
vec2 refractionCoords = ndcPos.xy / ndcPos.w;
refractionCoords += 1.0;
refractionCoords /= 2.0;
vec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] );
transmittedLight[ i ] = transmissionSample[ i ];
transmittedLight.a += transmissionSample.a;
transmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ];
}
transmittedLight.a /= 3.0;
#else
vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );
vec3 refractedRayExit = position + transmissionRay;
vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
vec2 refractionCoords = ndcPos.xy / ndcPos.w;
refractionCoords += 1.0;
refractionCoords /= 2.0;
transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );
transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );
#endif
vec3 attenuatedColor = transmittance * transmittedLight.rgb;
vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );
float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;
return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );
}
#endif`,r1=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
varying vec2 vUv;
#endif
#ifdef USE_MAP
varying vec2 vMapUv;
#endif
#ifdef USE_ALPHAMAP
varying vec2 vAlphaMapUv;
#endif
#ifdef USE_LIGHTMAP
varying vec2 vLightMapUv;
#endif
#ifdef USE_AOMAP
varying vec2 vAoMapUv;
#endif
#ifdef USE_BUMPMAP
varying vec2 vBumpMapUv;
#endif
#ifdef USE_NORMALMAP
varying vec2 vNormalMapUv;
#endif
#ifdef USE_EMISSIVEMAP
varying vec2 vEmissiveMapUv;
#endif
#ifdef USE_METALNESSMAP
varying vec2 vMetalnessMapUv;
#endif
#ifdef USE_ROUGHNESSMAP
varying vec2 vRoughnessMapUv;
#endif
#ifdef USE_ANISOTROPYMAP
varying vec2 vAnisotropyMapUv;
#endif
#ifdef USE_CLEARCOATMAP
varying vec2 vClearcoatMapUv;
#endif
#ifdef USE_CLEARCOAT_NORMALMAP
varying vec2 vClearcoatNormalMapUv;
#endif
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
varying vec2 vClearcoatRoughnessMapUv;
#endif
#ifdef USE_IRIDESCENCEMAP
varying vec2 vIridescenceMapUv;
#endif
#ifdef USE_IRIDESCENCE_THICKNESSMAP
varying vec2 vIridescenceThicknessMapUv;
#endif
#ifdef USE_SHEEN_COLORMAP
varying vec2 vSheenColorMapUv;
#endif
#ifdef USE_SHEEN_ROUGHNESSMAP
varying vec2 vSheenRoughnessMapUv;
#endif
#ifdef USE_SPECULARMAP
varying vec2 vSpecularMapUv;
#endif
#ifdef USE_SPECULAR_COLORMAP
varying vec2 vSpecularColorMapUv;
#endif
#ifdef USE_SPECULAR_INTENSITYMAP
varying vec2 vSpecularIntensityMapUv;
#endif
#ifdef USE_TRANSMISSIONMAP
uniform mat3 transmissionMapTransform;
varying vec2 vTransmissionMapUv;
#endif
#ifdef USE_THICKNESSMAP
uniform mat3 thicknessMapTransform;
varying vec2 vThicknessMapUv;
#endif`,a1=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
varying vec2 vUv;
#endif
#ifdef USE_MAP
uniform mat3 mapTransform;
varying vec2 vMapUv;
#endif
#ifdef USE_ALPHAMAP
uniform mat3 alphaMapTransform;
varying vec2 vAlphaMapUv;
#endif
#ifdef USE_LIGHTMAP
uniform mat3 lightMapTransform;
varying vec2 vLightMapUv;
#endif
#ifdef USE_AOMAP
uniform mat3 aoMapTransform;
varying vec2 vAoMapUv;
#endif
#ifdef USE_BUMPMAP
uniform mat3 bumpMapTransform;
varying vec2 vBumpMapUv;
#endif
#ifdef USE_NORMALMAP
uniform mat3 normalMapTransform;
varying vec2 vNormalMapUv;
#endif
#ifdef USE_DISPLACEMENTMAP
uniform mat3 displacementMapTransform;
varying vec2 vDisplacementMapUv;
#endif
#ifdef USE_EMISSIVEMAP
uniform mat3 emissiveMapTransform;
varying vec2 vEmissiveMapUv;
#endif
#ifdef USE_METALNESSMAP
uniform mat3 metalnessMapTransform;
varying vec2 vMetalnessMapUv;
#endif
#ifdef USE_ROUGHNESSMAP
uniform mat3 roughnessMapTransform;
varying vec2 vRoughnessMapUv;
#endif
#ifdef USE_ANISOTROPYMAP
uniform mat3 anisotropyMapTransform;
varying vec2 vAnisotropyMapUv;
#endif
#ifdef USE_CLEARCOATMAP
uniform mat3 clearcoatMapTransform;
varying vec2 vClearcoatMapUv;
#endif
#ifdef USE_CLEARCOAT_NORMALMAP
uniform mat3 clearcoatNormalMapTransform;
varying vec2 vClearcoatNormalMapUv;
#endif
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
uniform mat3 clearcoatRoughnessMapTransform;
varying vec2 vClearcoatRoughnessMapUv;
#endif
#ifdef USE_SHEEN_COLORMAP
uniform mat3 sheenColorMapTransform;
varying vec2 vSheenColorMapUv;
#endif
#ifdef USE_SHEEN_ROUGHNESSMAP
uniform mat3 sheenRoughnessMapTransform;
varying vec2 vSheenRoughnessMapUv;
#endif
#ifdef USE_IRIDESCENCEMAP
uniform mat3 iridescenceMapTransform;
varying vec2 vIridescenceMapUv;
#endif
#ifdef USE_IRIDESCENCE_THICKNESSMAP
uniform mat3 iridescenceThicknessMapTransform;
varying vec2 vIridescenceThicknessMapUv;
#endif
#ifdef USE_SPECULARMAP
uniform mat3 specularMapTransform;
varying vec2 vSpecularMapUv;
#endif
#ifdef USE_SPECULAR_COLORMAP
uniform mat3 specularColorMapTransform;
varying vec2 vSpecularColorMapUv;
#endif
#ifdef USE_SPECULAR_INTENSITYMAP
uniform mat3 specularIntensityMapTransform;
varying vec2 vSpecularIntensityMapUv;
#endif
#ifdef USE_TRANSMISSIONMAP
uniform mat3 transmissionMapTransform;
varying vec2 vTransmissionMapUv;
#endif
#ifdef USE_THICKNESSMAP
uniform mat3 thicknessMapTransform;
varying vec2 vThicknessMapUv;
#endif`,o1=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
vUv = vec3( uv, 1 ).xy;
#endif
#ifdef USE_MAP
vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;
#endif
#ifdef USE_ALPHAMAP
vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_LIGHTMAP
vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_AOMAP
vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_BUMPMAP
vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_NORMALMAP
vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_DISPLACEMENTMAP
vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_EMISSIVEMAP
vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_METALNESSMAP
vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_ROUGHNESSMAP
vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_ANISOTROPYMAP
vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_CLEARCOATMAP
vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_CLEARCOAT_NORMALMAP
vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_IRIDESCENCEMAP
vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_IRIDESCENCE_THICKNESSMAP
vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_SHEEN_COLORMAP
vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_SHEEN_ROUGHNESSMAP
vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_SPECULARMAP
vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_SPECULAR_COLORMAP
vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_SPECULAR_INTENSITYMAP
vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_TRANSMISSIONMAP
vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_THICKNESSMAP
vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
#endif`,l1=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
vec4 worldPosition = vec4( transformed, 1.0 );
#ifdef USE_BATCHING
worldPosition = batchingMatrix * worldPosition;
#endif
#ifdef USE_INSTANCING
worldPosition = instanceMatrix * worldPosition;
#endif
worldPosition = modelMatrix * worldPosition;
#endif`;const c1=`varying vec2 vUv;
uniform mat3 uvTransform;
void main() {
vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
gl_Position = vec4( position.xy, 1.0, 1.0 );
}`,u1=`uniform sampler2D t2D;
uniform float backgroundIntensity;
varying vec2 vUv;
void main() {
vec4 texColor = texture2D( t2D, vUv );
#ifdef DECODE_VIDEO_TEXTURE
texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w );
#endif
texColor.rgb *= backgroundIntensity;
gl_FragColor = texColor;
#include <tonemapping_fragment>
#include <colorspace_fragment>
}`,h1=`varying vec3 vWorldDirection;
#include <common>
void main() {
vWorldDirection = transformDirection( position, modelMatrix );
#include <begin_vertex>
#include <project_vertex>
gl_Position.z = gl_Position.w;
}`,d1=`#ifdef ENVMAP_TYPE_CUBE
uniform samplerCube envMap;
#elif defined( ENVMAP_TYPE_CUBE_UV )
uniform sampler2D envMap;
#endif
uniform float backgroundBlurriness;
uniform float backgroundIntensity;
uniform mat3 backgroundRotation;
varying vec3 vWorldDirection;
#include <cube_uv_reflection_fragment>
void main() {
#ifdef ENVMAP_TYPE_CUBE
vec4 texColor = textureCube( envMap, backgroundRotation * vWorldDirection );
#elif defined( ENVMAP_TYPE_CUBE_UV )
vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness );
#else
vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );
#endif
texColor.rgb *= backgroundIntensity;
gl_FragColor = texColor;
#include <tonemapping_fragment>
#include <colorspace_fragment>
}`,f1=`varying vec3 vWorldDirection;
#include <common>
void main() {
vWorldDirection = transformDirection( position, modelMatrix );
#include <begin_vertex>
#include <project_vertex>
gl_Position.z = gl_Position.w;
}`,p1=`uniform samplerCube tCube;
uniform float tFlip;
uniform float opacity;
varying vec3 vWorldDirection;
void main() {
vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );
gl_FragColor = texColor;
gl_FragColor.a *= opacity;
#include <tonemapping_fragment>
#include <colorspace_fragment>
}`,m1=`#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
varying vec2 vHighPrecisionZW;
void main() {
#include <uv_vertex>
#include <batching_vertex>
#include <skinbase_vertex>
#include <morphinstance_vertex>
#ifdef USE_DISPLACEMENTMAP
#include <beginnormal_vertex>
#include <morphnormal_vertex>
#include <skinnormal_vertex>
#endif
#include <begin_vertex>
#include <morphtarget_vertex>
#include <skinning_vertex>
#include <displacementmap_vertex>
#include <project_vertex>
#include <logdepthbuf_vertex>
#include <clipping_planes_vertex>
vHighPrecisionZW = gl_Position.zw;
}`,g1=`#if DEPTH_PACKING == 3200
uniform float opacity;
#endif
#include <common>
#include <packing>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
varying vec2 vHighPrecisionZW;
void main() {
vec4 diffuseColor = vec4( 1.0 );
#include <clipping_planes_fragment>
#if DEPTH_PACKING == 3200
diffuseColor.a = opacity;
#endif
#include <map_fragment>
#include <alphamap_fragment>
#include <alphatest_fragment>
#include <alphahash_fragment>
#include <logdepthbuf_fragment>
#ifdef USE_REVERSED_DEPTH_BUFFER
float fragCoordZ = vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ];
#else
float fragCoordZ = 0.5 * vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ] + 0.5;
#endif
#if DEPTH_PACKING == 3200
gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );
#elif DEPTH_PACKING == 3201
gl_FragColor = packDepthToRGBA( fragCoordZ );
#elif DEPTH_PACKING == 3202
gl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 );
#elif DEPTH_PACKING == 3203
gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );
#endif
}`,_1=`#define DISTANCE
varying vec3 vWorldPosition;
#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
#include <uv_vertex>
#include <batching_vertex>
#include <skinbase_vertex>
#include <morphinstance_vertex>
#ifdef USE_DISPLACEMENTMAP
#include <beginnormal_vertex>
#include <morphnormal_vertex>
#include <skinnormal_vertex>
#endif
#include <begin_vertex>
#include <morphtarget_vertex>
#include <skinning_vertex>
#include <displacementmap_vertex>
#include <project_vertex>
#include <worldpos_vertex>
#include <clipping_planes_vertex>
vWorldPosition = worldPosition.xyz;
}`,x1=`#define DISTANCE
uniform vec3 referencePosition;
uniform float nearDistance;
uniform float farDistance;
varying vec3 vWorldPosition;
#include <common>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
vec4 diffuseColor = vec4( 1.0 );
#include <clipping_planes_fragment>
#include <map_fragment>
#include <alphamap_fragment>
#include <alphatest_fragment>
#include <alphahash_fragment>
float dist = length( vWorldPosition - referencePosition );
dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
dist = saturate( dist );
gl_FragColor = vec4( dist, 0.0, 0.0, 1.0 );
}`,y1=`varying vec3 vWorldDirection;
#include <common>
void main() {
vWorldDirection = transformDirection( position, modelMatrix );
#include <begin_vertex>
#include <project_vertex>
}`,v1=`uniform sampler2D tEquirect;
varying vec3 vWorldDirection;
#include <common>
void main() {
vec3 direction = normalize( vWorldDirection );
vec2 sampleUV = equirectUv( direction );
gl_FragColor = texture2D( tEquirect, sampleUV );
#include <tonemapping_fragment>
#include <colorspace_fragment>
}`,S1=`uniform float scale;
attribute float lineDistance;
varying float vLineDistance;
#include <common>
#include <uv_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <morphtarget_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
vLineDistance = scale * lineDistance;
#include <uv_vertex>
#include <color_vertex>
#include <morphinstance_vertex>
#include <morphcolor_vertex>
#include <begin_vertex>
#include <morphtarget_vertex>
#include <project_vertex>
#include <logdepthbuf_vertex>
#include <clipping_planes_vertex>
#include <fog_vertex>
}`,b1=`uniform vec3 diffuse;
uniform float opacity;
uniform float dashSize;
uniform float totalSize;
varying float vLineDistance;
#include <common>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <fog_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
vec4 diffuseColor = vec4( diffuse, opacity );
#include <clipping_planes_fragment>
if ( mod( vLineDistance, totalSize ) > dashSize ) {
discard;
}
vec3 outgoingLight = vec3( 0.0 );
#include <logdepthbuf_fragment>
#include <map_fragment>
#include <color_fragment>
outgoingLight = diffuseColor.rgb;
#include <opaque_fragment>
#include <tonemapping_fragment>
#include <colorspace_fragment>
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
}`,M1=`#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <envmap_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
#include <uv_vertex>
#include <color_vertex>
#include <morphinstance_vertex>
#include <morphcolor_vertex>
#include <batching_vertex>
#if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )
#include <beginnormal_vertex>
#include <morphnormal_vertex>
#include <skinbase_vertex>
#include <skinnormal_vertex>
#include <defaultnormal_vertex>
#endif
#include <begin_vertex>
#include <morphtarget_vertex>
#include <skinning_vertex>
#include <project_vertex>
#include <logdepthbuf_vertex>
#include <clipping_planes_vertex>
#include <worldpos_vertex>
#include <envmap_vertex>
#include <fog_vertex>
}`,A1=`uniform vec3 diffuse;
uniform float opacity;
#ifndef FLAT_SHADED
varying vec3 vNormal;
#endif
#include <common>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <aomap_pars_fragment>
#include <lightmap_pars_fragment>
#include <envmap_common_pars_fragment>
#include <envmap_pars_fragment>
#include <fog_pars_fragment>
#include <specularmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
vec4 diffuseColor = vec4( diffuse, opacity );
#include <clipping_planes_fragment>
#include <logdepthbuf_fragment>
#include <map_fragment>
#include <color_fragment>
#include <alphamap_fragment>
#include <alphatest_fragment>
#include <alphahash_fragment>
#include <specularmap_fragment>
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
#ifdef USE_LIGHTMAP
vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;
#else
reflectedLight.indirectDiffuse += vec3( 1.0 );
#endif
#include <aomap_fragment>
reflectedLight.indirectDiffuse *= diffuseColor.rgb;
vec3 outgoingLight = reflectedLight.indirectDiffuse;
#include <envmap_fragment>
#include <opaque_fragment>
#include <tonemapping_fragment>
#include <colorspace_fragment>
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
#include <dithering_fragment>
}`,E1=`#define LAMBERT
varying vec3 vViewPosition;
#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <envmap_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <normal_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <shadowmap_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
#include <uv_vertex>
#include <color_vertex>
#include <morphinstance_vertex>
#include <morphcolor_vertex>
#include <batching_vertex>
#include <beginnormal_vertex>
#include <morphnormal_vertex>
#include <skinbase_vertex>
#include <skinnormal_vertex>
#include <defaultnormal_vertex>
#include <normal_vertex>
#include <begin_vertex>
#include <morphtarget_vertex>
#include <skinning_vertex>
#include <displacementmap_vertex>
#include <project_vertex>
#include <logdepthbuf_vertex>
#include <clipping_planes_vertex>
vViewPosition = - mvPosition.xyz;
#include <worldpos_vertex>
#include <envmap_vertex>
#include <shadowmap_vertex>
#include <fog_vertex>
}`,T1=`#define LAMBERT
uniform vec3 diffuse;
uniform vec3 emissive;
uniform float opacity;
#include <common>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <aomap_pars_fragment>
#include <lightmap_pars_fragment>
#include <emissivemap_pars_fragment>
#include <cube_uv_reflection_fragment>
#include <envmap_common_pars_fragment>
#include <envmap_pars_fragment>
#include <envmap_physical_pars_fragment>
#include <fog_pars_fragment>
#include <bsdfs>
#include <lights_pars_begin>
#include <normal_pars_fragment>
#include <lights_lambert_pars_fragment>
#include <shadowmap_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <specularmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
vec4 diffuseColor = vec4( diffuse, opacity );
#include <clipping_planes_fragment>
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
vec3 totalEmissiveRadiance = emissive;
#include <logdepthbuf_fragment>
#include <map_fragment>
#include <color_fragment>
#include <alphamap_fragment>
#include <alphatest_fragment>
#include <alphahash_fragment>
#include <specularmap_fragment>
#include <normal_fragment_begin>
#include <normal_fragment_maps>
#include <emissivemap_fragment>
#include <lights_lambert_fragment>
#include <lights_fragment_begin>
#include <lights_fragment_maps>
#include <lights_fragment_end>
#include <aomap_fragment>
vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
#include <envmap_fragment>
#include <opaque_fragment>
#include <tonemapping_fragment>
#include <colorspace_fragment>
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
#include <dithering_fragment>
}`,C1=`#define MATCAP
varying vec3 vViewPosition;
#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <color_pars_vertex>
#include <displacementmap_pars_vertex>
#include <fog_pars_vertex>
#include <normal_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
#include <uv_vertex>
#include <color_vertex>
#include <morphinstance_vertex>
#include <morphcolor_vertex>
#include <batching_vertex>
#include <beginnormal_vertex>
#include <morphnormal_vertex>
#include <skinbase_vertex>
#include <skinnormal_vertex>
#include <defaultnormal_vertex>
#include <normal_vertex>
#include <begin_vertex>
#include <morphtarget_vertex>
#include <skinning_vertex>
#include <displacementmap_vertex>
#include <project_vertex>
#include <logdepthbuf_vertex>
#include <clipping_planes_vertex>
#include <fog_vertex>
vViewPosition = - mvPosition.xyz;
}`,w1=`#define MATCAP
uniform vec3 diffuse;
uniform float opacity;
uniform sampler2D matcap;
varying vec3 vViewPosition;
#include <common>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <fog_pars_fragment>
#include <normal_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
vec4 diffuseColor = vec4( diffuse, opacity );
#include <clipping_planes_fragment>
#include <logdepthbuf_fragment>
#include <map_fragment>
#include <color_fragment>
#include <alphamap_fragment>
#include <alphatest_fragment>
#include <alphahash_fragment>
#include <normal_fragment_begin>
#include <normal_fragment_maps>
vec3 viewDir = normalize( vViewPosition );
vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
vec3 y = cross( viewDir, x );
vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;
#ifdef USE_MATCAP
vec4 matcapColor = texture2D( matcap, uv );
#else
vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );
#endif
vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;
#include <opaque_fragment>
#include <tonemapping_fragment>
#include <colorspace_fragment>
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
#include <dithering_fragment>
}`,R1=`#define NORMAL
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
varying vec3 vViewPosition;
#endif
#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <normal_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
#include <uv_vertex>
#include <batching_vertex>
#include <beginnormal_vertex>
#include <morphinstance_vertex>
#include <morphnormal_vertex>
#include <skinbase_vertex>
#include <skinnormal_vertex>
#include <defaultnormal_vertex>
#include <normal_vertex>
#include <begin_vertex>
#include <morphtarget_vertex>
#include <skinning_vertex>
#include <displacementmap_vertex>
#include <project_vertex>
#include <logdepthbuf_vertex>
#include <clipping_planes_vertex>
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
vViewPosition = - mvPosition.xyz;
#endif
}`,L1=`#define NORMAL
uniform float opacity;
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
varying vec3 vViewPosition;
#endif
#include <uv_pars_fragment>
#include <normal_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity );
#include <clipping_planes_fragment>
#include <logdepthbuf_fragment>
#include <normal_fragment_begin>
#include <normal_fragment_maps>
gl_FragColor = vec4( normalize( normal ) * 0.5 + 0.5, diffuseColor.a );
#ifdef OPAQUE
gl_FragColor.a = 1.0;
#endif
}`,D1=`#define PHONG
varying vec3 vViewPosition;
#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <envmap_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <normal_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <shadowmap_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
#include <uv_vertex>
#include <color_vertex>
#include <morphcolor_vertex>
#include <batching_vertex>
#include <beginnormal_vertex>
#include <morphinstance_vertex>
#include <morphnormal_vertex>
#include <skinbase_vertex>
#include <skinnormal_vertex>
#include <defaultnormal_vertex>
#include <normal_vertex>
#include <begin_vertex>
#include <morphtarget_vertex>
#include <skinning_vertex>
#include <displacementmap_vertex>
#include <project_vertex>
#include <logdepthbuf_vertex>
#include <clipping_planes_vertex>
vViewPosition = - mvPosition.xyz;
#include <worldpos_vertex>
#include <envmap_vertex>
#include <shadowmap_vertex>
#include <fog_vertex>
}`,I1=`#define PHONG
uniform vec3 diffuse;
uniform vec3 emissive;
uniform vec3 specular;
uniform float shininess;
uniform float opacity;
#include <common>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <aomap_pars_fragment>
#include <lightmap_pars_fragment>
#include <emissivemap_pars_fragment>
#include <cube_uv_reflection_fragment>
#include <envmap_common_pars_fragment>
#include <envmap_pars_fragment>
#include <envmap_physical_pars_fragment>
#include <fog_pars_fragment>
#include <bsdfs>
#include <lights_pars_begin>
#include <normal_pars_fragment>
#include <lights_phong_pars_fragment>
#include <shadowmap_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <specularmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
vec4 diffuseColor = vec4( diffuse, opacity );
#include <clipping_planes_fragment>
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
vec3 totalEmissiveRadiance = emissive;
#include <logdepthbuf_fragment>
#include <map_fragment>
#include <color_fragment>
#include <alphamap_fragment>
#include <alphatest_fragment>
#include <alphahash_fragment>
#include <specularmap_fragment>
#include <normal_fragment_begin>
#include <normal_fragment_maps>
#include <emissivemap_fragment>
#include <lights_phong_fragment>
#include <lights_fragment_begin>
#include <lights_fragment_maps>
#include <lights_fragment_end>
#include <aomap_fragment>
vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;
#include <envmap_fragment>
#include <opaque_fragment>
#include <tonemapping_fragment>
#include <colorspace_fragment>
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
#include <dithering_fragment>
}`,P1=`#define STANDARD
varying vec3 vViewPosition;
#ifdef USE_TRANSMISSION
varying vec3 vWorldPosition;
#endif
#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <normal_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <shadowmap_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
#include <uv_vertex>
#include <color_vertex>
#include <morphinstance_vertex>
#include <morphcolor_vertex>
#include <batching_vertex>
#include <beginnormal_vertex>
#include <morphnormal_vertex>
#include <skinbase_vertex>
#include <skinnormal_vertex>
#include <defaultnormal_vertex>
#include <normal_vertex>
#include <begin_vertex>
#include <morphtarget_vertex>
#include <skinning_vertex>
#include <displacementmap_vertex>
#include <project_vertex>
#include <logdepthbuf_vertex>
#include <clipping_planes_vertex>
vViewPosition = - mvPosition.xyz;
#include <worldpos_vertex>
#include <shadowmap_vertex>
#include <fog_vertex>
#ifdef USE_TRANSMISSION
vWorldPosition = worldPosition.xyz;
#endif
}`,O1=`#define STANDARD
#ifdef PHYSICAL
#define IOR
#define USE_SPECULAR
#endif
uniform vec3 diffuse;
uniform vec3 emissive;
uniform float roughness;
uniform float metalness;
uniform float opacity;
#ifdef IOR
uniform float ior;
#endif
#ifdef USE_SPECULAR
uniform float specularIntensity;
uniform vec3 specularColor;
#ifdef USE_SPECULAR_COLORMAP
uniform sampler2D specularColorMap;
#endif
#ifdef USE_SPECULAR_INTENSITYMAP
uniform sampler2D specularIntensityMap;
#endif
#endif
#ifdef USE_CLEARCOAT
uniform float clearcoat;
uniform float clearcoatRoughness;
#endif
#ifdef USE_DISPERSION
uniform float dispersion;
#endif
#ifdef USE_IRIDESCENCE
uniform float iridescence;
uniform float iridescenceIOR;
uniform float iridescenceThicknessMinimum;
uniform float iridescenceThicknessMaximum;
#endif
#ifdef USE_SHEEN
uniform vec3 sheenColor;
uniform float sheenRoughness;
#ifdef USE_SHEEN_COLORMAP
uniform sampler2D sheenColorMap;
#endif
#ifdef USE_SHEEN_ROUGHNESSMAP
uniform sampler2D sheenRoughnessMap;
#endif
#endif
#ifdef USE_ANISOTROPY
uniform vec2 anisotropyVector;
#ifdef USE_ANISOTROPYMAP
uniform sampler2D anisotropyMap;
#endif
#endif
varying vec3 vViewPosition;
#include <common>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <aomap_pars_fragment>
#include <lightmap_pars_fragment>
#include <emissivemap_pars_fragment>
#include <iridescence_fragment>
#include <cube_uv_reflection_fragment>
#include <envmap_common_pars_fragment>
#include <envmap_physical_pars_fragment>
#include <fog_pars_fragment>
#include <lights_pars_begin>
#include <normal_pars_fragment>
#include <lights_physical_pars_fragment>
#include <transmission_pars_fragment>
#include <shadowmap_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <clearcoat_pars_fragment>
#include <iridescence_pars_fragment>
#include <roughnessmap_pars_fragment>
#include <metalnessmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
vec4 diffuseColor = vec4( diffuse, opacity );
#include <clipping_planes_fragment>
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
vec3 totalEmissiveRadiance = emissive;
#include <logdepthbuf_fragment>
#include <map_fragment>
#include <color_fragment>
#include <alphamap_fragment>
#include <alphatest_fragment>
#include <alphahash_fragment>
#include <roughnessmap_fragment>
#include <metalnessmap_fragment>
#include <normal_fragment_begin>
#include <normal_fragment_maps>
#include <clearcoat_normal_fragment_begin>
#include <clearcoat_normal_fragment_maps>
#include <emissivemap_fragment>
#include <lights_physical_fragment>
#include <lights_fragment_begin>
#include <lights_fragment_maps>
#include <lights_fragment_end>
#include <aomap_fragment>
vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;
vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;
#include <transmission_fragment>
vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;
#ifdef USE_SHEEN
outgoingLight = outgoingLight + sheenSpecularDirect + sheenSpecularIndirect;
#endif
#ifdef USE_CLEARCOAT
float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );
vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );
outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;
#endif
#include <opaque_fragment>
#include <tonemapping_fragment>
#include <colorspace_fragment>
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
#include <dithering_fragment>
}`,U1=`#define TOON
varying vec3 vViewPosition;
#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <normal_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <shadowmap_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
#include <uv_vertex>
#include <color_vertex>
#include <morphinstance_vertex>
#include <morphcolor_vertex>
#include <batching_vertex>
#include <beginnormal_vertex>
#include <morphnormal_vertex>
#include <skinbase_vertex>
#include <skinnormal_vertex>
#include <defaultnormal_vertex>
#include <normal_vertex>
#include <begin_vertex>
#include <morphtarget_vertex>
#include <skinning_vertex>
#include <displacementmap_vertex>
#include <project_vertex>
#include <logdepthbuf_vertex>
#include <clipping_planes_vertex>
vViewPosition = - mvPosition.xyz;
#include <worldpos_vertex>
#include <shadowmap_vertex>
#include <fog_vertex>
}`,N1=`#define TOON
uniform vec3 diffuse;
uniform vec3 emissive;
uniform float opacity;
#include <common>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <aomap_pars_fragment>
#include <lightmap_pars_fragment>
#include <emissivemap_pars_fragment>
#include <gradientmap_pars_fragment>
#include <fog_pars_fragment>
#include <bsdfs>
#include <lights_pars_begin>
#include <normal_pars_fragment>
#include <lights_toon_pars_fragment>
#include <shadowmap_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
vec4 diffuseColor = vec4( diffuse, opacity );
#include <clipping_planes_fragment>
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
vec3 totalEmissiveRadiance = emissive;
#include <logdepthbuf_fragment>
#include <map_fragment>
#include <color_fragment>
#include <alphamap_fragment>
#include <alphatest_fragment>
#include <alphahash_fragment>
#include <normal_fragment_begin>
#include <normal_fragment_maps>
#include <emissivemap_fragment>
#include <lights_toon_fragment>
#include <lights_fragment_begin>
#include <lights_fragment_maps>
#include <lights_fragment_end>
#include <aomap_fragment>
vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
#include <opaque_fragment>
#include <tonemapping_fragment>
#include <colorspace_fragment>
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
#include <dithering_fragment>
}`,k1=`uniform float size;
uniform float scale;
#include <common>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <morphtarget_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
#ifdef USE_POINTS_UV
varying vec2 vUv;
uniform mat3 uvTransform;
#endif
void main() {
#ifdef USE_POINTS_UV
vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
#endif
#include <color_vertex>
#include <morphinstance_vertex>
#include <morphcolor_vertex>
#include <begin_vertex>
#include <morphtarget_vertex>
#include <project_vertex>
gl_PointSize = size;
#ifdef USE_SIZEATTENUATION
bool isPerspective = isPerspectiveMatrix( projectionMatrix );
if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );
#endif
#include <logdepthbuf_vertex>
#include <clipping_planes_vertex>
#include <worldpos_vertex>
#include <fog_vertex>
}`,F1=`uniform vec3 diffuse;
uniform float opacity;
#include <common>
#include <color_pars_fragment>
#include <map_particle_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <fog_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
vec4 diffuseColor = vec4( diffuse, opacity );
#include <clipping_planes_fragment>
vec3 outgoingLight = vec3( 0.0 );
#include <logdepthbuf_fragment>
#include <map_particle_fragment>
#include <color_fragment>
#include <alphatest_fragment>
#include <alphahash_fragment>
outgoingLight = diffuseColor.rgb;
#include <opaque_fragment>
#include <tonemapping_fragment>
#include <colorspace_fragment>
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
}`,B1=`#include <common>
#include <batching_pars_vertex>
#include <fog_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <shadowmap_pars_vertex>
void main() {
#include <batching_vertex>
#include <beginnormal_vertex>
#include <morphinstance_vertex>
#include <morphnormal_vertex>
#include <skinbase_vertex>
#include <skinnormal_vertex>
#include <defaultnormal_vertex>
#include <begin_vertex>
#include <morphtarget_vertex>
#include <skinning_vertex>
#include <project_vertex>
#include <logdepthbuf_vertex>
#include <worldpos_vertex>
#include <shadowmap_vertex>
#include <fog_vertex>
}`,H1=`uniform vec3 color;
uniform float opacity;
#include <common>
#include <fog_pars_fragment>
#include <bsdfs>
#include <lights_pars_begin>
#include <logdepthbuf_pars_fragment>
#include <shadowmap_pars_fragment>
#include <shadowmask_pars_fragment>
void main() {
#include <logdepthbuf_fragment>
gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );
#include <tonemapping_fragment>
#include <colorspace_fragment>
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
}`,z1=`uniform float rotation;
uniform vec2 center;
#include <common>
#include <uv_pars_vertex>
#include <fog_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
#include <uv_vertex>
vec4 mvPosition = modelViewMatrix[ 3 ];
vec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) );
#ifndef USE_SIZEATTENUATION
bool isPerspective = isPerspectiveMatrix( projectionMatrix );
if ( isPerspective ) scale *= - mvPosition.z;
#endif
vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;
vec2 rotatedPosition;
rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;
rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;
mvPosition.xy += rotatedPosition;
gl_Position = projectionMatrix * mvPosition;
#include <logdepthbuf_vertex>
#include <clipping_planes_vertex>
#include <fog_vertex>
}`,V1=`uniform vec3 diffuse;
uniform float opacity;
#include <common>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <fog_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
vec4 diffuseColor = vec4( diffuse, opacity );
#include <clipping_planes_fragment>
vec3 outgoingLight = vec3( 0.0 );
#include <logdepthbuf_fragment>
#include <map_fragment>
#include <alphamap_fragment>
#include <alphatest_fragment>
#include <alphahash_fragment>
outgoingLight = diffuseColor.rgb;
#include <opaque_fragment>
#include <tonemapping_fragment>
#include <colorspace_fragment>
#include <fog_fragment>
}`,tt={alphahash_fragment:c_,alphahash_pars_fragment:u_,alphamap_fragment:h_,alphamap_pars_fragment:d_,alphatest_fragment:f_,alphatest_pars_fragment:p_,aomap_fragment:m_,aomap_pars_fragment:g_,batching_pars_vertex:__,batching_vertex:x_,begin_vertex:y_,beginnormal_vertex:v_,bsdfs:S_,iridescence_fragment:b_,bumpmap_pars_fragment:M_,clipping_planes_fragment:A_,clipping_planes_pars_fragment:E_,clipping_planes_pars_vertex:T_,clipping_planes_vertex:C_,color_fragment:w_,color_pars_fragment:R_,color_pars_vertex:L_,color_vertex:D_,common:I_,cube_uv_reflection_fragment:P_,defaultnormal_vertex:O_,displacementmap_pars_vertex:U_,displacementmap_vertex:N_,emissivemap_fragment:k_,emissivemap_pars_fragment:F_,colorspace_fragment:B_,colorspace_pars_fragment:H_,envmap_fragment:z_,envmap_common_pars_fragment:V_,envmap_pars_fragment:G_,envmap_pars_vertex:W_,envmap_physical_pars_fragment:tx,envmap_vertex:X_,fog_vertex:Y_,fog_pars_vertex:K_,fog_fragment:q_,fog_pars_fragment:$_,gradientmap_pars_fragment:Z_,lightmap_pars_fragment:J_,lights_lambert_fragment:j_,lights_lambert_pars_fragment:Q_,lights_pars_begin:ex,lights_toon_fragment:nx,lights_toon_pars_fragment:ix,lights_phong_fragment:sx,lights_phong_pars_fragment:rx,lights_physical_fragment:ax,lights_physical_pars_fragment:ox,lights_fragment_begin:lx,lights_fragment_maps:cx,lights_fragment_end:ux,lightprobes_pars_fragment:hx,logdepthbuf_fragment:dx,logdepthbuf_pars_fragment:fx,logdepthbuf_pars_vertex:px,logdepthbuf_vertex:mx,map_fragment:gx,map_pars_fragment:_x,map_particle_fragment:xx,map_particle_pars_fragment:yx,metalnessmap_fragment:vx,metalnessmap_pars_fragment:Sx,morphinstance_vertex:bx,morphcolor_vertex:Mx,morphnormal_vertex:Ax,morphtarget_pars_vertex:Ex,morphtarget_vertex:Tx,normal_fragment_begin:Cx,normal_fragment_maps:wx,normal_pars_fragment:Rx,normal_pars_vertex:Lx,normal_vertex:Dx,normalmap_pars_fragment:Ix,clearcoat_normal_fragment_begin:Px,clearcoat_normal_fragment_maps:Ox,clearcoat_pars_fragment:Ux,iridescence_pars_fragment:Nx,opaque_fragment:kx,packing:Fx,premultiplied_alpha_fragment:Bx,project_vertex:Hx,dithering_fragment:zx,dithering_pars_fragment:Vx,roughnessmap_fragment:Gx,roughnessmap_pars_fragment:Wx,shadowmap_pars_fragment:Xx,shadowmap_pars_vertex:Yx,shadowmap_vertex:Kx,shadowmask_pars_fragment:qx,skinbase_vertex:$x,skinning_pars_vertex:Zx,skinning_vertex:Jx,skinnormal_vertex:jx,specularmap_fragment:Qx,specularmap_pars_fragment:e1,tonemapping_fragment:t1,tonemapping_pars_fragment:n1,transmission_fragment:i1,transmission_pars_fragment:s1,uv_pars_fragment:r1,uv_pars_vertex:a1,uv_vertex:o1,worldpos_vertex:l1,background_vert:c1,background_frag:u1,backgroundCube_vert:h1,backgroundCube_frag:d1,cube_vert:f1,cube_frag:p1,depth_vert:m1,depth_frag:g1,distance_vert:_1,distance_frag:x1,equirect_vert:y1,equirect_frag:v1,linedashed_vert:S1,linedashed_frag:b1,meshbasic_vert:M1,meshbasic_frag:A1,meshlambert_vert:E1,meshlambert_frag:T1,meshmatcap_vert:C1,meshmatcap_frag:w1,meshnormal_vert:R1,meshnormal_frag:L1,meshphong_vert:D1,meshphong_frag:I1,meshphysical_vert:P1,meshphysical_frag:O1,meshtoon_vert:U1,meshtoon_frag:N1,points_vert:k1,points_frag:F1,shadow_vert:B1,shadow_frag:H1,sprite_vert:z1,sprite_frag:V1},we={common:{diffuse:{value:new it(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new et},alphaMap:{value:null},alphaMapTransform:{value:new et},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new et}},envmap:{envMap:{value:null},envMapRotation:{value:new et},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new et}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new et}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new et},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new et},normalScale:{value:new Le(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new et},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new et}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new et}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new et}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new it(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null},probesSH:{value:null},probesMin:{value:new k},probesMax:{value:new k},probesResolution:{value:new k}},points:{diffuse:{value:new it(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new et},alphaTest:{value:0},uvTransform:{value:new et}},sprite:{diffuse:{value:new it(16777215)},opacity:{value:1},center:{value:new Le(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new et},alphaMap:{value:null},alphaMapTransform:{value:new et},alphaTest:{value:0}}},gn={basic:{uniforms:un([we.common,we.specularmap,we.envmap,we.aomap,we.lightmap,we.fog]),vertexShader:tt.meshbasic_vert,fragmentShader:tt.meshbasic_frag},lambert:{uniforms:un([we.common,we.specularmap,we.envmap,we.aomap,we.lightmap,we.emissivemap,we.bumpmap,we.normalmap,we.displacementmap,we.fog,we.lights,{emissive:{value:new it(0)},envMapIntensity:{value:1}}]),vertexShader:tt.meshlambert_vert,fragmentShader:tt.meshlambert_frag},phong:{uniforms:un([we.common,we.specularmap,we.envmap,we.aomap,we.lightmap,we.emissivemap,we.bumpmap,we.normalmap,we.displacementmap,we.fog,we.lights,{emissive:{value:new it(0)},specular:{value:new it(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:tt.meshphong_vert,fragmentShader:tt.meshphong_frag},standard:{uniforms:un([we.common,we.envmap,we.aomap,we.lightmap,we.emissivemap,we.bumpmap,we.normalmap,we.displacementmap,we.roughnessmap,we.metalnessmap,we.fog,we.lights,{emissive:{value:new it(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:tt.meshphysical_vert,fragmentShader:tt.meshphysical_frag},toon:{uniforms:un([we.common,we.aomap,we.lightmap,we.emissivemap,we.bumpmap,we.normalmap,we.displacementmap,we.gradientmap,we.fog,we.lights,{emissive:{value:new it(0)}}]),vertexShader:tt.meshtoon_vert,fragmentShader:tt.meshtoon_frag},matcap:{uniforms:un([we.common,we.bumpmap,we.normalmap,we.displacementmap,we.fog,{matcap:{value:null}}]),vertexShader:tt.meshmatcap_vert,fragmentShader:tt.meshmatcap_frag},points:{uniforms:un([we.points,we.fog]),vertexShader:tt.points_vert,fragmentShader:tt.points_frag},dashed:{uniforms:un([we.common,we.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:tt.linedashed_vert,fragmentShader:tt.linedashed_frag},depth:{uniforms:un([we.common,we.displacementmap]),vertexShader:tt.depth_vert,fragmentShader:tt.depth_frag},normal:{uniforms:un([we.common,we.bumpmap,we.normalmap,we.displacementmap,{opacity:{value:1}}]),vertexShader:tt.meshnormal_vert,fragmentShader:tt.meshnormal_frag},sprite:{uniforms:un([we.sprite,we.fog]),vertexShader:tt.sprite_vert,fragmentShader:tt.sprite_frag},background:{uniforms:{uvTransform:{value:new et},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:tt.background_vert,fragmentShader:tt.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new et}},vertexShader:tt.backgroundCube_vert,fragmentShader:tt.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:tt.cube_vert,fragmentShader:tt.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:tt.equirect_vert,fragmentShader:tt.equirect_frag},distance:{uniforms:un([we.common,we.displacementmap,{referencePosition:{value:new k},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:tt.distance_vert,fragmentShader:tt.distance_frag},shadow:{uniforms:un([we.lights,we.fog,{color:{value:new it(0)},opacity:{value:1}}]),vertexShader:tt.shadow_vert,fragmentShader:tt.shadow_frag}};gn.physical={uniforms:un([gn.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new et},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new et},clearcoatNormalScale:{value:new Le(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new et},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new et},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new et},sheen:{value:0},sheenColor:{value:new it(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new et},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new et},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new et},transmissionSamplerSize:{value:new Le},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new et},attenuationDistance:{value:0},attenuationColor:{value:new it(0)},specularColor:{value:new it(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new et},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new et},anisotropyVector:{value:new Le},anisotropyMap:{value:null},anisotropyMapTransform:{value:new et}}]),vertexShader:tt.meshphysical_vert,fragmentShader:tt.meshphysical_frag};const Wa={r:0,b:0,g:0},G1=new Rt,pp=new et;pp.set(-1,0,0,0,1,0,0,0,1);function W1(n,e,t,i,s,r){const a=new it(0);let o=s===!0?0:1,l,c,u=null,h=0,d=null;function f(v){let b=v.isScene===!0?v.background:null;if(b&&b.isTexture){const x=v.backgroundBlurriness>0;b=e.get(b,x)}return b}function p(v){let b=!1;const x=f(v);x===null?m(a,o):x&&x.isColor&&(m(x,1),b=!0);const E=n.xr.getEnvironmentBlendMode();E==="additive"?t.buffers.color.setClear(0,0,0,1,r):E==="alpha-blend"&&t.buffers.color.setClear(0,0,0,0,r),(n.autoClear||b)&&(t.buffers.depth.setTest(!0),t.buffers.depth.setMask(!0),t.buffers.color.setMask(!0),n.clear(n.autoClearColor,n.autoClearDepth,n.autoClearStencil))}function _(v,b){const x=f(b);x&&(x.isCubeTexture||x.mapping===Wo)?(c===void 0&&(c=new Ht(new ia(1,1,1),new In({name:"BackgroundCubeMaterial",uniforms:lr(gn.backgroundCube.uniforms),vertexShader:gn.backgroundCube.vertexShader,fragmentShader:gn.backgroundCube.fragmentShader,side:_n,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),c.geometry.deleteAttribute("uv"),c.onBeforeRender=function(E,S,A){this.matrixWorld.copyPosition(A.matrixWorld)},Object.defineProperty(c.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(c)),c.material.uniforms.envMap.value=x,c.material.uniforms.backgroundBlurriness.value=b.backgroundBlurriness,c.material.uniforms.backgroundIntensity.value=b.backgroundIntensity,c.material.uniforms.backgroundRotation.value.setFromMatrix4(G1.makeRotationFromEuler(b.backgroundRotation)).transpose(),x.isCubeTexture&&x.isRenderTargetTexture===!1&&c.material.uniforms.backgroundRotation.value.premultiply(pp),c.material.toneMapped=at.getTransfer(x.colorSpace)!==xt,(u!==x||h!==x.version||d!==n.toneMapping)&&(c.material.needsUpdate=!0,u=x,h=x.version,d=n.toneMapping),c.layers.enableAll(),v.unshift(c,c.geometry,c.material,0,0,null)):x&&x.isTexture&&(l===void 0&&(l=new Ht(new fs(2,2),new In({name:"BackgroundMaterial",uniforms:lr(gn.background.uniforms),vertexShader:gn.background.vertexShader,fragmentShader:gn.background.fragmentShader,side:Zi,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(l)),l.material.uniforms.t2D.value=x,l.material.uniforms.backgroundIntensity.value=b.backgroundIntensity,l.material.toneMapped=at.getTransfer(x.colorSpace)!==xt,x.matrixAutoUpdate===!0&&x.updateMatrix(),l.material.uniforms.uvTransform.value.copy(x.matrix),(u!==x||h!==x.version||d!==n.toneMapping)&&(l.material.needsUpdate=!0,u=x,h=x.version,d=n.toneMapping),l.layers.enableAll(),v.unshift(l,l.geometry,l.material,0,0,null))}function m(v,b){v.getRGB(Wa,hp(n)),t.buffers.color.setClear(Wa.r,Wa.g,Wa.b,b,r)}function g(){c!==void 0&&(c.geometry.dispose(),c.material.dispose(),c=void 0),l!==void 0&&(l.geometry.dispose(),l.material.dispose(),l=void 0)}return{getClearColor:function(){return a},setClearColor:function(v,b=1){a.set(v),o=b,m(a,o)},getClearAlpha:function(){return o},setClearAlpha:function(v){o=v,m(a,o)},render:p,addToRenderList:_,dispose:g}}function X1(n,e){const t=n.getParameter(n.MAX_VERTEX_ATTRIBS),i={},s=d(null);let r=s,a=!1;function o(R,w,P,U,D){let K=!1;const B=h(R,U,P,w);r!==B&&(r=B,c(r.object)),K=f(R,U,P,D),K&&p(R,U,P,D),D!==null&&e.update(D,n.ELEMENT_ARRAY_BUFFER),(K||a)&&(a=!1,x(R,w,P,U),D!==null&&n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,e.get(D).buffer))}function l(){return n.createVertexArray()}function c(R){return n.bindVertexArray(R)}function u(R){return n.deleteVertexArray(R)}function h(R,w,P,U){const D=U.wireframe===!0;let K=i[w.id];K===void 0&&(K={},i[w.id]=K);const B=R.isInstancedMesh===!0?R.id:0;let ie=K[B];ie===void 0&&(ie={},K[B]=ie);let F=ie[P.id];F===void 0&&(F={},ie[P.id]=F);let se=F[D];return se===void 0&&(se=d(l()),F[D]=se),se}function d(R){const w=[],P=[],U=[];for(let D=0;D<t;D++)w[D]=0,P[D]=0,U[D]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:w,enabledAttributes:P,attributeDivisors:U,object:R,attributes:{},index:null}}function f(R,w,P,U){const D=r.attributes,K=w.attributes;let B=0;const ie=P.getAttributes();for(const F in ie)if(ie[F].location>=0){const V=D[F];let oe=K[F];if(oe===void 0&&(F==="instanceMatrix"&&R.instanceMatrix&&(oe=R.instanceMatrix),F==="instanceColor"&&R.instanceColor&&(oe=R.instanceColor)),V===void 0||V.attribute!==oe||oe&&V.data!==oe.data)return!0;B++}return r.attributesNum!==B||r.index!==U}function p(R,w,P,U){const D={},K=w.attributes;let B=0;const ie=P.getAttributes();for(const F in ie)if(ie[F].location>=0){let V=K[F];V===void 0&&(F==="instanceMatrix"&&R.instanceMatrix&&(V=R.instanceMatrix),F==="instanceColor"&&R.instanceColor&&(V=R.instanceColor));const oe={};oe.attribute=V,V&&V.data&&(oe.data=V.data),D[F]=oe,B++}r.attributes=D,r.attributesNum=B,r.index=U}function _(){const R=r.newAttributes;for(let w=0,P=R.length;w<P;w++)R[w]=0}function m(R){g(R,0)}function g(R,w){const P=r.newAttributes,U=r.enabledAttributes,D=r.attributeDivisors;P[R]=1,U[R]===0&&(n.enableVertexAttribArray(R),U[R]=1),D[R]!==w&&(n.vertexAttribDivisor(R,w),D[R]=w)}function v(){const R=r.newAttributes,w=r.enabledAttributes;for(let P=0,U=w.length;P<U;P++)w[P]!==R[P]&&(n.disableVertexAttribArray(P),w[P]=0)}function b(R,w,P,U,D,K,B){B===!0?n.vertexAttribIPointer(R,w,P,D,K):n.vertexAttribPointer(R,w,P,U,D,K)}function x(R,w,P,U){_();const D=U.attributes,K=P.getAttributes(),B=w.defaultAttributeValues;for(const ie in K){const F=K[ie];if(F.location>=0){let se=D[ie];if(se===void 0&&(ie==="instanceMatrix"&&R.instanceMatrix&&(se=R.instanceMatrix),ie==="instanceColor"&&R.instanceColor&&(se=R.instanceColor)),se!==void 0){const V=se.normalized,oe=se.itemSize,Ae=e.get(se);if(Ae===void 0)continue;const me=Ae.buffer,ue=Ae.type,z=Ae.bytesPerElement,ee=ue===n.INT||ue===n.UNSIGNED_INT||se.gpuType===du;if(se.isInterleavedBufferAttribute){const Z=se.data,xe=Z.stride,be=se.offset;if(Z.isInstancedInterleavedBuffer){for(let Se=0;Se<F.locationSize;Se++)g(F.location+Se,Z.meshPerAttribute);R.isInstancedMesh!==!0&&U._maxInstanceCount===void 0&&(U._maxInstanceCount=Z.meshPerAttribute*Z.count)}else for(let Se=0;Se<F.locationSize;Se++)m(F.location+Se);n.bindBuffer(n.ARRAY_BUFFER,me);for(let Se=0;Se<F.locationSize;Se++)b(F.location+Se,oe/F.locationSize,ue,V,xe*z,(be+oe/F.locationSize*Se)*z,ee)}else{if(se.isInstancedBufferAttribute){for(let Z=0;Z<F.locationSize;Z++)g(F.location+Z,se.meshPerAttribute);R.isInstancedMesh!==!0&&U._maxInstanceCount===void 0&&(U._maxInstanceCount=se.meshPerAttribute*se.count)}else for(let Z=0;Z<F.locationSize;Z++)m(F.location+Z);n.bindBuffer(n.ARRAY_BUFFER,me);for(let Z=0;Z<F.locationSize;Z++)b(F.location+Z,oe/F.locationSize,ue,V,oe*z,oe/F.locationSize*Z*z,ee)}}else if(B!==void 0){const V=B[ie];if(V!==void 0)switch(V.length){case 2:n.vertexAttrib2fv(F.location,V);break;case 3:n.vertexAttrib3fv(F.location,V);break;case 4:n.vertexAttrib4fv(F.location,V);break;default:n.vertexAttrib1fv(F.location,V)}}}}v()}function E(){T();for(const R in i){const w=i[R];for(const P in w){const U=w[P];for(const D in U){const K=U[D];for(const B in K)u(K[B].object),delete K[B];delete U[D]}}delete i[R]}}function S(R){if(i[R.id]===void 0)return;const w=i[R.id];for(const P in w){const U=w[P];for(const D in U){const K=U[D];for(const B in K)u(K[B].object),delete K[B];delete U[D]}}delete i[R.id]}function A(R){for(const w in i){const P=i[w];for(const U in P){const D=P[U];if(D[R.id]===void 0)continue;const K=D[R.id];for(const B in K)u(K[B].object),delete K[B];delete D[R.id]}}}function y(R){for(const w in i){const P=i[w],U=R.isInstancedMesh===!0?R.id:0,D=P[U];if(D!==void 0){for(const K in D){const B=D[K];for(const ie in B)u(B[ie].object),delete B[ie];delete D[K]}delete P[U],Object.keys(P).length===0&&delete i[w]}}}function T(){L(),a=!0,r!==s&&(r=s,c(r.object))}function L(){s.geometry=null,s.program=null,s.wireframe=!1}return{setup:o,reset:T,resetDefaultState:L,dispose:E,releaseStatesOfGeometry:S,releaseStatesOfObject:y,releaseStatesOfProgram:A,initAttributes:_,enableAttribute:m,disableUnusedAttributes:v}}function Y1(n,e,t){let i;function s(l){i=l}function r(l,c){n.drawArrays(i,l,c),t.update(c,i,1)}function a(l,c,u){u!==0&&(n.drawArraysInstanced(i,l,c,u),t.update(c,i,u))}function o(l,c,u){if(u===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(i,l,0,c,0,u);let d=0;for(let f=0;f<u;f++)d+=c[f];t.update(d,i,1)}this.setMode=s,this.render=r,this.renderInstances=a,this.renderMultiDraw=o}function K1(n,e,t,i){let s;function r(){if(s!==void 0)return s;if(e.has("EXT_texture_filter_anisotropic")===!0){const A=e.get("EXT_texture_filter_anisotropic");s=n.getParameter(A.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else s=0;return s}function a(A){return!(A!==Ln&&i.convert(A)!==n.getParameter(n.IMPLEMENTATION_COLOR_READ_FORMAT))}function o(A){const y=A===Ci&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(A!==wn&&i.convert(A)!==n.getParameter(n.IMPLEMENTATION_COLOR_READ_TYPE)&&A!==Gn&&!y)}function l(A){if(A==="highp"){if(n.getShaderPrecisionFormat(n.VERTEX_SHADER,n.HIGH_FLOAT).precision>0&&n.getShaderPrecisionFormat(n.FRAGMENT_SHADER,n.HIGH_FLOAT).precision>0)return"highp";A="mediump"}return A==="mediump"&&n.getShaderPrecisionFormat(n.VERTEX_SHADER,n.MEDIUM_FLOAT).precision>0&&n.getShaderPrecisionFormat(n.FRAGMENT_SHADER,n.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let c=t.precision!==void 0?t.precision:"highp";const u=l(c);u!==c&&($e("WebGLRenderer:",c,"not supported, using",u,"instead."),c=u);const h=t.logarithmicDepthBuffer===!0,d=t.reversedDepthBuffer===!0&&e.has("EXT_clip_control");t.reversedDepthBuffer===!0&&d===!1&&$e("WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer.");const f=n.getParameter(n.MAX_TEXTURE_IMAGE_UNITS),p=n.getParameter(n.MAX_VERTEX_TEXTURE_IMAGE_UNITS),_=n.getParameter(n.MAX_TEXTURE_SIZE),m=n.getParameter(n.MAX_CUBE_MAP_TEXTURE_SIZE),g=n.getParameter(n.MAX_VERTEX_ATTRIBS),v=n.getParameter(n.MAX_VERTEX_UNIFORM_VECTORS),b=n.getParameter(n.MAX_VARYING_VECTORS),x=n.getParameter(n.MAX_FRAGMENT_UNIFORM_VECTORS),E=n.getParameter(n.MAX_SAMPLES),S=n.getParameter(n.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:r,getMaxPrecision:l,textureFormatReadable:a,textureTypeReadable:o,precision:c,logarithmicDepthBuffer:h,reversedDepthBuffer:d,maxTextures:f,maxVertexTextures:p,maxTextureSize:_,maxCubemapSize:m,maxAttributes:g,maxVertexUniforms:v,maxVaryings:b,maxFragmentUniforms:x,maxSamples:E,samples:S}}function q1(n){const e=this;let t=null,i=0,s=!1,r=!1;const a=new Vi,o=new et,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(h,d){const f=h.length!==0||d||i!==0||s;return s=d,i=h.length,f},this.beginShadows=function(){r=!0,u(null)},this.endShadows=function(){r=!1},this.setGlobalState=function(h,d){t=u(h,d,0)},this.setState=function(h,d,f){const p=h.clippingPlanes,_=h.clipIntersection,m=h.clipShadows,g=n.get(h);if(!s||p===null||p.length===0||r&&!m)r?u(null):c();else{const v=r?0:i,b=v*4;let x=g.clippingState||null;l.value=x,x=u(p,d,b,f);for(let E=0;E!==b;++E)x[E]=t[E];g.clippingState=x,this.numIntersection=_?this.numPlanes:0,this.numPlanes+=v}};function c(){l.value!==t&&(l.value=t,l.needsUpdate=i>0),e.numPlanes=i,e.numIntersection=0}function u(h,d,f,p){const _=h!==null?h.length:0;let m=null;if(_!==0){if(m=l.value,p!==!0||m===null){const g=f+_*4,v=d.matrixWorldInverse;o.getNormalMatrix(v),(m===null||m.length<g)&&(m=new Float32Array(g));for(let b=0,x=f;b!==_;++b,x+=4)a.copy(h[b]).applyMatrix4(v,o),a.normal.toArray(m,x),m[x+3]=a.constant}l.value=m,l.needsUpdate=!0}return e.numPlanes=_,e.numIntersection=0,m}}const Ki=4,Vh=[.125,.215,.35,.446,.526,.582],cs=20,$1=256,Lr=new Cu,Gh=new it;let Ll=null,Dl=0,Il=0,Pl=!1;const Z1=new k;class Wh{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._backgroundBox=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._blurMaterial=null,this._ggxMaterial=null}fromScene(e,t=0,i=.1,s=100,r={}){const{size:a=256,position:o=Z1}=r;Ll=this._renderer.getRenderTarget(),Dl=this._renderer.getActiveCubeFace(),Il=this._renderer.getActiveMipmapLevel(),Pl=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(a);const l=this._allocateTargets();return l.depthBuffer=!0,this._sceneToCubeUV(e,i,s,l,o),t>0&&this._blur(l,0,0,t),this._applyPMREM(l),this._cleanup(l),l}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=Kh(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=Yh(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._backgroundBox!==null&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._ggxMaterial!==null&&this._ggxMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodMeshes.length;e++)this._lodMeshes[e].geometry.dispose()}_cleanup(e){this._renderer.setRenderTarget(Ll,Dl,Il),this._renderer.xr.enabled=Pl,e.scissorTest=!1,Ys(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===ms||e.mapping===rr?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),Ll=this._renderer.getRenderTarget(),Dl=this._renderer.getActiveCubeFace(),Il=this._renderer.getActiveMipmapLevel(),Pl=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;const i=t||this._allocateTargets();return this._textureToCubeUV(e,i),this._applyPMREM(i),this._cleanup(i),i}_allocateTargets(){const e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,i={magFilter:Jt,minFilter:Jt,generateMipmaps:!1,type:Ci,format:Ln,colorSpace:So,depthBuffer:!1},s=Xh(e,t,i);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=Xh(e,t,i);const{_lodMax:r}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=J1(r)),this._blurMaterial=Q1(r,e,t),this._ggxMaterial=j1(r,e,t)}return s}_compileMaterial(e){const t=new Ht(new wt,e);this._renderer.compile(t,Lr)}_sceneToCubeUV(e,t,i,s,r){const l=new zn(90,1,t,i),c=[1,-1,1,1,1,1],u=[1,1,1,-1,-1,-1],h=this._renderer,d=h.autoClear,f=h.toneMapping;h.getClearColor(Gh),h.toneMapping=li,h.autoClear=!1,h.state.buffers.depth.getReversed()&&(h.setRenderTarget(s),h.clearDepth(),h.setRenderTarget(null)),this._backgroundBox===null&&(this._backgroundBox=new Ht(new ia,new ti({name:"PMREM.Background",side:_n,depthWrite:!1,depthTest:!1})));const _=this._backgroundBox,m=_.material;let g=!1;const v=e.background;v?v.isColor&&(m.color.copy(v),e.background=null,g=!0):(m.color.copy(Gh),g=!0);for(let b=0;b<6;b++){const x=b%3;x===0?(l.up.set(0,c[b],0),l.position.set(r.x,r.y,r.z),l.lookAt(r.x+u[b],r.y,r.z)):x===1?(l.up.set(0,0,c[b]),l.position.set(r.x,r.y,r.z),l.lookAt(r.x,r.y+u[b],r.z)):(l.up.set(0,c[b],0),l.position.set(r.x,r.y,r.z),l.lookAt(r.x,r.y,r.z+u[b]));const E=this._cubeSize;Ys(s,x*E,b>2?E:0,E,E),h.setRenderTarget(s),g&&h.render(_,l),h.render(e,l)}h.toneMapping=f,h.autoClear=d,e.background=v}_textureToCubeUV(e,t){const i=this._renderer,s=e.mapping===ms||e.mapping===rr;s?(this._cubemapMaterial===null&&(this._cubemapMaterial=Kh()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=Yh());const r=s?this._cubemapMaterial:this._equirectMaterial,a=this._lodMeshes[0];a.material=r;const o=r.uniforms;o.envMap.value=e;const l=this._cubeSize;Ys(t,0,0,3*l,2*l),i.setRenderTarget(t),i.render(a,Lr)}_applyPMREM(e){const t=this._renderer,i=t.autoClear;t.autoClear=!1;const s=this._lodMeshes.length;for(let r=1;r<s;r++)this._applyGGXFilter(e,r-1,r);t.autoClear=i}_applyGGXFilter(e,t,i){const s=this._renderer,r=this._pingPongRenderTarget,a=this._ggxMaterial,o=this._lodMeshes[i];o.material=a;const l=a.uniforms,c=i/(this._lodMeshes.length-1),u=t/(this._lodMeshes.length-1),h=Math.sqrt(c*c-u*u),d=0+c*1.25,f=h*d,{_lodMax:p}=this,_=this._sizeLods[i],m=3*_*(i>p-Ki?i-p+Ki:0),g=4*(this._cubeSize-_);l.envMap.value=e.texture,l.roughness.value=f,l.mipInt.value=p-t,Ys(r,m,g,3*_,2*_),s.setRenderTarget(r),s.render(o,Lr),l.envMap.value=r.texture,l.roughness.value=0,l.mipInt.value=p-i,Ys(e,m,g,3*_,2*_),s.setRenderTarget(e),s.render(o,Lr)}_blur(e,t,i,s,r){const a=this._pingPongRenderTarget;this._halfBlur(e,a,t,i,s,"latitudinal",r),this._halfBlur(a,e,i,i,s,"longitudinal",r)}_halfBlur(e,t,i,s,r,a,o){const l=this._renderer,c=this._blurMaterial;a!=="latitudinal"&&a!=="longitudinal"&&ut("blur direction must be either latitudinal or longitudinal!");const u=3,h=this._lodMeshes[s];h.material=c;const d=c.uniforms,f=this._sizeLods[i]-1,p=isFinite(r)?Math.PI/(2*f):2*Math.PI/(2*cs-1),_=r/p,m=isFinite(r)?1+Math.floor(u*_):cs;m>cs&&$e(`sigmaRadians, ${r}, is too large and will clip, as it requested ${m} samples when the maximum is set to ${cs}`);const g=[];let v=0;for(let A=0;A<cs;++A){const y=A/_,T=Math.exp(-y*y/2);g.push(T),A===0?v+=T:A<m&&(v+=2*T)}for(let A=0;A<g.length;A++)g[A]=g[A]/v;d.envMap.value=e.texture,d.samples.value=m,d.weights.value=g,d.latitudinal.value=a==="latitudinal",o&&(d.poleAxis.value=o);const{_lodMax:b}=this;d.dTheta.value=p,d.mipInt.value=b-i;const x=this._sizeLods[s],E=3*x*(s>b-Ki?s-b+Ki:0),S=4*(this._cubeSize-x);Ys(t,E,S,3*x,2*x),l.setRenderTarget(t),l.render(h,Lr)}}function J1(n){const e=[],t=[],i=[];let s=n;const r=n-Ki+1+Vh.length;for(let a=0;a<r;a++){const o=Math.pow(2,s);e.push(o);let l=1/o;a>n-Ki?l=Vh[a-n+Ki-1]:a===0&&(l=0),t.push(l);const c=1/(o-2),u=-c,h=1+c,d=[u,u,h,u,h,h,u,u,h,h,u,h],f=6,p=6,_=3,m=2,g=1,v=new Float32Array(_*p*f),b=new Float32Array(m*p*f),x=new Float32Array(g*p*f);for(let S=0;S<f;S++){const A=S%3*2/3-1,y=S>2?0:-1,T=[A,y,0,A+2/3,y,0,A+2/3,y+1,0,A,y,0,A+2/3,y+1,0,A,y+1,0];v.set(T,_*p*S),b.set(d,m*p*S);const L=[S,S,S,S,S,S];x.set(L,g*p*S)}const E=new wt;E.setAttribute("position",new Dn(v,_)),E.setAttribute("uv",new Dn(b,m)),E.setAttribute("faceIndex",new Dn(x,g)),i.push(new Ht(E,null)),s>Ki&&s--}return{lodMeshes:i,sizeLods:e,sigmas:t}}function Xh(n,e,t){const i=new ui(n,e,t);return i.texture.mapping=Wo,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function Ys(n,e,t,i,s){n.viewport.set(e,t,i,s),n.scissor.set(e,t,i,s)}function j1(n,e,t){return new In({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:$1,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${n}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:Xo(),fragmentShader:`
precision highp float;
precision highp int;
varying vec3 vOutputDirection;
uniform sampler2D envMap;
uniform float roughness;
uniform float mipInt;
#define ENVMAP_TYPE_CUBE_UV
#include <cube_uv_reflection_fragment>
#define PI 3.14159265359
// Van der Corput radical inverse
float radicalInverse_VdC(uint bits) {
bits = (bits << 16u) | (bits >> 16u);
bits = ((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u);
bits = ((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u);
bits = ((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u);
bits = ((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u);
return float(bits) * 2.3283064365386963e-10; // / 0x100000000
}
// Hammersley sequence
vec2 hammersley(uint i, uint N) {
return vec2(float(i) / float(N), radicalInverse_VdC(i));
}
// GGX VNDF importance sampling (Eric Heitz 2018)
// "Sampling the GGX Distribution of Visible Normals"
// https://jcgt.org/published/0007/04/01/
vec3 importanceSampleGGX_VNDF(vec2 Xi, vec3 V, float roughness) {
float alpha = roughness * roughness;
// Section 4.1: Orthonormal basis
vec3 T1 = vec3(1.0, 0.0, 0.0);
vec3 T2 = cross(V, T1);
// Section 4.2: Parameterization of projected area
float r = sqrt(Xi.x);
float phi = 2.0 * PI * Xi.y;
float t1 = r * cos(phi);
float t2 = r * sin(phi);
float s = 0.5 * (1.0 + V.z);
t2 = (1.0 - s) * sqrt(1.0 - t1 * t1) + s * t2;
// Section 4.3: Reprojection onto hemisphere
vec3 Nh = t1 * T1 + t2 * T2 + sqrt(max(0.0, 1.0 - t1 * t1 - t2 * t2)) * V;
// Section 3.4: Transform back to ellipsoid configuration
return normalize(vec3(alpha * Nh.x, alpha * Nh.y, max(0.0, Nh.z)));
}
void main() {
vec3 N = normalize(vOutputDirection);
vec3 V = N; // Assume view direction equals normal for pre-filtering
vec3 prefilteredColor = vec3(0.0);
float totalWeight = 0.0;
// For very low roughness, just sample the environment directly
if (roughness < 0.001) {
gl_FragColor = vec4(bilinearCubeUV(envMap, N, mipInt), 1.0);
return;
}
// Tangent space basis for VNDF sampling
vec3 up = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0);
vec3 tangent = normalize(cross(up, N));
vec3 bitangent = cross(N, tangent);
for(uint i = 0u; i < uint(GGX_SAMPLES); i++) {
vec2 Xi = hammersley(i, uint(GGX_SAMPLES));
// For PMREM, V = N, so in tangent space V is always (0, 0, 1)
vec3 H_tangent = importanceSampleGGX_VNDF(Xi, vec3(0.0, 0.0, 1.0), roughness);
// Transform H back to world space
vec3 H = normalize(tangent * H_tangent.x + bitangent * H_tangent.y + N * H_tangent.z);
vec3 L = normalize(2.0 * dot(V, H) * H - V);
float NdotL = max(dot(N, L), 0.0);
if(NdotL > 0.0) {
// Sample environment at fixed mip level
// VNDF importance sampling handles the distribution filtering
vec3 sampleColor = bilinearCubeUV(envMap, L, mipInt);
// Weight by NdotL for the split-sum approximation
// VNDF PDF naturally accounts for the visible microfacet distribution
prefilteredColor += sampleColor * NdotL;
totalWeight += NdotL;
}
}
if (totalWeight > 0.0) {
prefilteredColor = prefilteredColor / totalWeight;
}
gl_FragColor = vec4(prefilteredColor, 1.0);
}
`,blending:Ai,depthTest:!1,depthWrite:!1})}function Q1(n,e,t){const i=new Float32Array(cs),s=new k(0,1,0);return new In({name:"SphericalGaussianBlur",defines:{n:cs,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${n}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:i},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:s}},vertexShader:Xo(),fragmentShader:`
precision mediump float;
precision mediump int;
varying vec3 vOutputDirection;
uniform sampler2D envMap;
uniform int samples;
uniform float weights[ n ];
uniform bool latitudinal;
uniform float dTheta;
uniform float mipInt;
uniform vec3 poleAxis;
#define ENVMAP_TYPE_CUBE_UV
#include <cube_uv_reflection_fragment>
vec3 getSample( float theta, vec3 axis ) {
float cosTheta = cos( theta );
// Rodrigues' axis-angle rotation
vec3 sampleDirection = vOutputDirection * cosTheta
+ cross( axis, vOutputDirection ) * sin( theta )
+ axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );
return bilinearCubeUV( envMap, sampleDirection, mipInt );
}
void main() {
vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );
if ( all( equal( axis, vec3( 0.0 ) ) ) ) {
axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );
}
axis = normalize( axis );
gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );
gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );
for ( int i = 1; i < n; i++ ) {
if ( i >= samples ) {
break;
}
float theta = dTheta * float( i );
gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );
gl_FragColor.rgb += weights[ i ] * getSample( theta, axis );
}
}
`,blending:Ai,depthTest:!1,depthWrite:!1})}function Yh(){return new In({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:Xo(),fragmentShader:`
precision mediump float;
precision mediump int;
varying vec3 vOutputDirection;
uniform sampler2D envMap;
#include <common>
void main() {
vec3 outputDirection = normalize( vOutputDirection );
vec2 uv = equirectUv( outputDirection );
gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
}
`,blending:Ai,depthTest:!1,depthWrite:!1})}function Kh(){return new In({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Xo(),fragmentShader:`
precision mediump float;
precision mediump int;
uniform float flipEnvMap;
varying vec3 vOutputDirection;
uniform samplerCube envMap;
void main() {
gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
}
`,blending:Ai,depthTest:!1,depthWrite:!1})}function Xo(){return`
precision mediump float;
precision mediump int;
attribute float faceIndex;
varying vec3 vOutputDirection;
// RH coordinate system; PMREM face-indexing convention
vec3 getDirection( vec2 uv, float face ) {
uv = 2.0 * uv - 1.0;
vec3 direction = vec3( uv, 1.0 );
if ( face == 0.0 ) {
direction = direction.zyx; // ( 1, v, u ) pos x
} else if ( face == 1.0 ) {
direction = direction.xzy;
direction.xz *= -1.0; // ( -u, 1, -v ) pos y
} else if ( face == 2.0 ) {
direction.x *= -1.0; // ( -u, v, 1 ) pos z
} else if ( face == 3.0 ) {
direction = direction.zyx;
direction.xz *= -1.0; // ( -1, v, -u ) neg x
} else if ( face == 4.0 ) {
direction = direction.xzy;
direction.xy *= -1.0; // ( -u, -1, v ) neg y
} else if ( face == 5.0 ) {
direction.z *= -1.0; // ( u, v, -1 ) neg z
}
return direction;
}
void main() {
vOutputDirection = getDirection( uv, faceIndex );
gl_Position = vec4( position, 1.0 );
}
`}class mp extends ui{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const i={width:e,height:e,depth:1},s=[i,i,i,i,i,i];this.texture=new ep(s),this._setTextureOptions(t),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const i={uniforms:{tEquirect:{value:null}},vertexShader:`
varying vec3 vWorldDirection;
vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
}
void main() {
vWorldDirection = transformDirection( position, modelMatrix );
#include <begin_vertex>
#include <project_vertex>
}
`,fragmentShader:`
uniform sampler2D tEquirect;
varying vec3 vWorldDirection;
#include <common>
void main() {
vec3 direction = normalize( vWorldDirection );
vec2 sampleUV = equirectUv( direction );
gl_FragColor = texture2D( tEquirect, sampleUV );
}
`},s=new ia(5,5,5),r=new In({name:"CubemapFromEquirect",uniforms:lr(i.uniforms),vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,side:_n,blending:Ai});r.uniforms.tEquirect.value=t;const a=new Ht(s,r),o=t.minFilter;return t.minFilter===Yi&&(t.minFilter=Jt),new t_(1,10,this).update(e,a),t.minFilter=o,a.geometry.dispose(),a.material.dispose(),this}clear(e,t=!0,i=!0,s=!0){const r=e.getRenderTarget();for(let a=0;a<6;a++)e.setRenderTarget(this,a),e.clear(t,i,s);e.setRenderTarget(r)}}function ey(n){let e=new WeakMap,t=new WeakMap,i=null;function s(d,f=!1){return d==null?null:f?a(d):r(d)}function r(d){if(d&&d.isTexture){const f=d.mapping;if(f===jo||f===Qo)if(e.has(d)){const p=e.get(d).texture;return o(p,d.mapping)}else{const p=d.image;if(p&&p.height>0){const _=new mp(p.height);return _.fromEquirectangularTexture(n,d),e.set(d,_),d.addEventListener("dispose",c),o(_.texture,d.mapping)}else return null}}return d}function a(d){if(d&&d.isTexture){const f=d.mapping,p=f===jo||f===Qo,_=f===ms||f===rr;if(p||_){let m=t.get(d);const g=m!==void 0?m.texture.pmremVersion:0;if(d.isRenderTargetTexture&&d.pmremVersion!==g)return i===null&&(i=new Wh(n)),m=p?i.fromEquirectangular(d,m):i.fromCubemap(d,m),m.texture.pmremVersion=d.pmremVersion,t.set(d,m),m.texture;if(m!==void 0)return m.texture;{const v=d.image;return p&&v&&v.height>0||_&&v&&l(v)?(i===null&&(i=new Wh(n)),m=p?i.fromEquirectangular(d):i.fromCubemap(d),m.texture.pmremVersion=d.pmremVersion,t.set(d,m),d.addEventListener("dispose",u),m.texture):null}}}return d}function o(d,f){return f===jo?d.mapping=ms:f===Qo&&(d.mapping=rr),d}function l(d){let f=0;const p=6;for(let _=0;_<p;_++)d[_]!==void 0&&f++;return f===p}function c(d){const f=d.target;f.removeEventListener("dispose",c);const p=e.get(f);p!==void 0&&(e.delete(f),p.dispose())}function u(d){const f=d.target;f.removeEventListener("dispose",u);const p=t.get(f);p!==void 0&&(t.delete(f),p.dispose())}function h(){e=new WeakMap,t=new WeakMap,i!==null&&(i.dispose(),i=null)}return{get:s,dispose:h}}function ty(n){const e={};function t(i){if(e[i]!==void 0)return e[i];const s=n.getExtension(i);return e[i]=s,s}return{has:function(i){return t(i)!==null},init:function(){t("EXT_color_buffer_float"),t("WEBGL_clip_cull_distance"),t("OES_texture_float_linear"),t("EXT_color_buffer_half_float"),t("WEBGL_multisampled_render_to_texture"),t("WEBGL_render_shared_exponent")},get:function(i){const s=t(i);return s===null&&tr("WebGLRenderer: "+i+" extension not supported."),s}}}function ny(n,e,t,i){const s={},r=new WeakMap;function a(h){const d=h.target;d.index!==null&&e.remove(d.index);for(const p in d.attributes)e.remove(d.attributes[p]);d.removeEventListener("dispose",a),delete s[d.id];const f=r.get(d);f&&(e.remove(f),r.delete(d)),i.releaseStatesOfGeometry(d),d.isInstancedBufferGeometry===!0&&delete d._maxInstanceCount,t.memory.geometries--}function o(h,d){return s[d.id]===!0||(d.addEventListener("dispose",a),s[d.id]=!0,t.memory.geometries++),d}function l(h){const d=h.attributes;for(const f in d)e.update(d[f],n.ARRAY_BUFFER)}function c(h){const d=[],f=h.index,p=h.attributes.position;let _=0;if(p===void 0)return;if(f!==null){const v=f.array;_=f.version;for(let b=0,x=v.length;b<x;b+=3){const E=v[b+0],S=v[b+1],A=v[b+2];d.push(E,S,S,A,A,E)}}else{const v=p.array;_=p.version;for(let b=0,x=v.length/3-1;b<x;b+=3){const E=b+0,S=b+1,A=b+2;d.push(E,S,S,A,A,E)}}const m=new(p.count>=65535?qf:Kf)(d,1);m.version=_;const g=r.get(h);g&&e.remove(g),r.set(h,m)}function u(h){const d=r.get(h);if(d){const f=h.index;f!==null&&d.version<f.version&&c(h)}else c(h);return r.get(h)}return{get:o,update:l,getWireframeAttribute:u}}function iy(n,e,t){let i;function s(h){i=h}let r,a;function o(h){r=h.type,a=h.bytesPerElement}function l(h,d){n.drawElements(i,d,r,h*a),t.update(d,i,1)}function c(h,d,f){f!==0&&(n.drawElementsInstanced(i,d,r,h*a,f),t.update(d,i,f))}function u(h,d,f){if(f===0)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(i,d,0,r,h,0,f);let _=0;for(let m=0;m<f;m++)_+=d[m];t.update(_,i,1)}this.setMode=s,this.setIndex=o,this.render=l,this.renderInstances=c,this.renderMultiDraw=u}function sy(n){const e={geometries:0,textures:0},t={frame:0,calls:0,triangles:0,points:0,lines:0};function i(r,a,o){switch(t.calls++,a){case n.TRIANGLES:t.triangles+=o*(r/3);break;case n.LINES:t.lines+=o*(r/2);break;case n.LINE_STRIP:t.lines+=o*(r-1);break;case n.LINE_LOOP:t.lines+=o*r;break;case n.POINTS:t.points+=o*r;break;default:ut("WebGLInfo: Unknown draw mode:",a);break}}function s(){t.calls=0,t.triangles=0,t.points=0,t.lines=0}return{memory:e,render:t,programs:null,autoReset:!0,reset:s,update:i}}function ry(n,e,t){const i=new WeakMap,s=new Et;function r(a,o,l){const c=a.morphTargetInfluences,u=o.morphAttributes.position||o.morphAttributes.normal||o.morphAttributes.color,h=u!==void 0?u.length:0;let d=i.get(o);if(d===void 0||d.count!==h){let L=function(){y.dispose(),i.delete(o),o.removeEventListener("dispose",L)};var f=L;d!==void 0&&d.texture.dispose();const p=o.morphAttributes.position!==void 0,_=o.morphAttributes.normal!==void 0,m=o.morphAttributes.color!==void 0,g=o.morphAttributes.position||[],v=o.morphAttributes.normal||[],b=o.morphAttributes.color||[];let x=0;p===!0&&(x=1),_===!0&&(x=2),m===!0&&(x=3);let E=o.attributes.position.count*x,S=1;E>e.maxTextureSize&&(S=Math.ceil(E/e.maxTextureSize),E=e.maxTextureSize);const A=new Float32Array(E*S*4*h),y=new Wf(A,E,S,h);y.type=Gn,y.needsUpdate=!0;const T=x*4;for(let R=0;R<h;R++){const w=g[R],P=v[R],U=b[R],D=E*S*4*R;for(let K=0;K<w.count;K++){const B=K*T;p===!0&&(s.fromBufferAttribute(w,K),A[D+B+0]=s.x,A[D+B+1]=s.y,A[D+B+2]=s.z,A[D+B+3]=0),_===!0&&(s.fromBufferAttribute(P,K),A[D+B+4]=s.x,A[D+B+5]=s.y,A[D+B+6]=s.z,A[D+B+7]=0),m===!0&&(s.fromBufferAttribute(U,K),A[D+B+8]=s.x,A[D+B+9]=s.y,A[D+B+10]=s.z,A[D+B+11]=U.itemSize===4?s.w:1)}}d={count:h,texture:y,size:new Le(E,S)},i.set(o,d),o.addEventListener("dispose",L)}if(a.isInstancedMesh===!0&&a.morphTexture!==null)l.getUniforms().setValue(n,"morphTexture",a.morphTexture,t);else{let p=0;for(let m=0;m<c.length;m++)p+=c[m];const _=o.morphTargetsRelative?1:1-p;l.getUniforms().setValue(n,"morphTargetBaseInfluence",_),l.getUniforms().setValue(n,"morphTargetInfluences",c)}l.getUniforms().setValue(n,"morphTargetsTexture",d.texture,t),l.getUniforms().setValue(n,"morphTargetsTextureSize",d.size)}return{update:r}}function ay(n,e,t,i,s){let r=new WeakMap;function a(c){const u=s.render.frame,h=c.geometry,d=e.get(c,h);if(r.get(d)!==u&&(e.update(d),r.set(d,u)),c.isInstancedMesh&&(c.hasEventListener("dispose",l)===!1&&c.addEventListener("dispose",l),r.get(c)!==u&&(t.update(c.instanceMatrix,n.ARRAY_BUFFER),c.instanceColor!==null&&t.update(c.instanceColor,n.ARRAY_BUFFER),r.set(c,u))),c.isSkinnedMesh){const f=c.skeleton;r.get(f)!==u&&(f.update(),r.set(f,u))}return d}function o(){r=new WeakMap}function l(c){const u=c.target;u.removeEventListener("dispose",l),i.releaseStatesOfObject(u),t.remove(u.instanceMatrix),u.instanceColor!==null&&t.remove(u.instanceColor)}return{update:a,dispose:o}}const oy={[Cf]:"LINEAR_TONE_MAPPING",[wf]:"REINHARD_TONE_MAPPING",[Rf]:"CINEON_TONE_MAPPING",[Lf]:"ACES_FILMIC_TONE_MAPPING",[If]:"AGX_TONE_MAPPING",[Pf]:"NEUTRAL_TONE_MAPPING",[Df]:"CUSTOM_TONE_MAPPING"};function ly(n,e,t,i,s,r){const a=new ui(e,t,{type:n,depthBuffer:s,stencilBuffer:r,samples:i?4:0,depthTexture:s?new ar(e,t):void 0}),o=new ui(e,t,{type:Ci,depthBuffer:!1,stencilBuffer:!1}),l=new wt;l.setAttribute("position",new dt([-1,3,0,-1,-1,0,3,-1,0],3)),l.setAttribute("uv",new dt([0,2,0,0,2,0],2));const c=new Zg({uniforms:{tDiffuse:{value:null}},vertexShader:`
precision highp float;
uniform mat4 modelViewMatrix;
uniform mat4 projectionMatrix;
attribute vec3 position;
attribute vec2 uv;
varying vec2 vUv;
void main() {
vUv = uv;
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}`,fragmentShader:`
precision highp float;
uniform sampler2D tDiffuse;
varying vec2 vUv;
#include <tonemapping_pars_fragment>
#include <colorspace_pars_fragment>
void main() {
gl_FragColor = texture2D( tDiffuse, vUv );
#ifdef LINEAR_TONE_MAPPING
gl_FragColor.rgb = LinearToneMapping( gl_FragColor.rgb );
#elif defined( REINHARD_TONE_MAPPING )
gl_FragColor.rgb = ReinhardToneMapping( gl_FragColor.rgb );
#elif defined( CINEON_TONE_MAPPING )
gl_FragColor.rgb = CineonToneMapping( gl_FragColor.rgb );
#elif defined( ACES_FILMIC_TONE_MAPPING )
gl_FragColor.rgb = ACESFilmicToneMapping( gl_FragColor.rgb );
#elif defined( AGX_TONE_MAPPING )
gl_FragColor.rgb = AgXToneMapping( gl_FragColor.rgb );
#elif defined( NEUTRAL_TONE_MAPPING )
gl_FragColor.rgb = NeutralToneMapping( gl_FragColor.rgb );
#elif defined( CUSTOM_TONE_MAPPING )
gl_FragColor.rgb = CustomToneMapping( gl_FragColor.rgb );
#endif
#ifdef SRGB_TRANSFER
gl_FragColor = sRGBTransferOETF( gl_FragColor );
#endif
}`,depthTest:!1,depthWrite:!1}),u=new Ht(l,c),h=new Cu(-1,1,1,-1,0,1);let d=null,f=null,p=!1,_,m=null,g=[],v=!1;this.setSize=function(b,x){a.setSize(b,x),o.setSize(b,x);for(let E=0;E<g.length;E++){const S=g[E];S.setSize&&S.setSize(b,x)}},this.setEffects=function(b){g=b,v=g.length>0&&g[0].isRenderPass===!0;const x=a.width,E=a.height;for(let S=0;S<g.length;S++){const A=g[S];A.setSize&&A.setSize(x,E)}},this.begin=function(b,x){if(p||b.toneMapping===li&&g.length===0)return!1;if(m=x,x!==null){const E=x.width,S=x.height;(a.width!==E||a.height!==S)&&this.setSize(E,S)}return v===!1&&b.setRenderTarget(a),_=b.toneMapping,b.toneMapping=li,!0},this.hasRenderPass=function(){return v},this.end=function(b,x){b.toneMapping=_,p=!0;let E=a,S=o;for(let A=0;A<g.length;A++){const y=g[A];if(y.enabled!==!1&&(y.render(b,S,E,x),y.needsSwap!==!1)){const T=E;E=S,S=T}}if(d!==b.outputColorSpace||f!==b.toneMapping){d=b.outputColorSpace,f=b.toneMapping,c.defines={},at.getTransfer(d)===xt&&(c.defines.SRGB_TRANSFER="");const A=oy[f];A&&(c.defines[A]=""),c.needsUpdate=!0}c.uniforms.tDiffuse.value=E.texture,b.setRenderTarget(m),b.render(u,h),m=null,p=!1},this.isCompositing=function(){return p},this.dispose=function(){a.depthTexture&&a.depthTexture.dispose(),a.dispose(),o.dispose(),l.dispose(),c.dispose()}}const gp=new sn,$c=new ar(1,1),_p=new Wf,xp=new Zm,yp=new ep,qh=[],$h=[],Zh=new Float32Array(16),Jh=new Float32Array(9),jh=new Float32Array(4);function gr(n,e,t){const i=n[0];if(i<=0||i>0)return n;const s=e*t;let r=qh[s];if(r===void 0&&(r=new Float32Array(s),qh[s]=r),e!==0){i.toArray(r,0);for(let a=1,o=0;a!==e;++a)o+=t,n[a].toArray(r,o)}return r}function Vt(n,e){if(n.length!==e.length)return!1;for(let t=0,i=n.length;t<i;t++)if(n[t]!==e[t])return!1;return!0}function Gt(n,e){for(let t=0,i=e.length;t<i;t++)n[t]=e[t]}function Yo(n,e){let t=$h[e];t===void 0&&(t=new Int32Array(e),$h[e]=t);for(let i=0;i!==e;++i)t[i]=n.allocateTextureUnit();return t}function cy(n,e){const t=this.cache;t[0]!==e&&(n.uniform1f(this.addr,e),t[0]=e)}function uy(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(n.uniform2f(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(Vt(t,e))return;n.uniform2fv(this.addr,e),Gt(t,e)}}function hy(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(n.uniform3f(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else if(e.r!==void 0)(t[0]!==e.r||t[1]!==e.g||t[2]!==e.b)&&(n.uniform3f(this.addr,e.r,e.g,e.b),t[0]=e.r,t[1]=e.g,t[2]=e.b);else{if(Vt(t,e))return;n.uniform3fv(this.addr,e),Gt(t,e)}}function dy(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(n.uniform4f(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(Vt(t,e))return;n.uniform4fv(this.addr,e),Gt(t,e)}}function fy(n,e){const t=this.cache,i=e.elements;if(i===void 0){if(Vt(t,e))return;n.uniformMatrix2fv(this.addr,!1,e),Gt(t,e)}else{if(Vt(t,i))return;jh.set(i),n.uniformMatrix2fv(this.addr,!1,jh),Gt(t,i)}}function py(n,e){const t=this.cache,i=e.elements;if(i===void 0){if(Vt(t,e))return;n.uniformMatrix3fv(this.addr,!1,e),Gt(t,e)}else{if(Vt(t,i))return;Jh.set(i),n.uniformMatrix3fv(this.addr,!1,Jh),Gt(t,i)}}function my(n,e){const t=this.cache,i=e.elements;if(i===void 0){if(Vt(t,e))return;n.uniformMatrix4fv(this.addr,!1,e),Gt(t,e)}else{if(Vt(t,i))return;Zh.set(i),n.uniformMatrix4fv(this.addr,!1,Zh),Gt(t,i)}}function gy(n,e){const t=this.cache;t[0]!==e&&(n.uniform1i(this.addr,e),t[0]=e)}function _y(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(n.uniform2i(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(Vt(t,e))return;n.uniform2iv(this.addr,e),Gt(t,e)}}function xy(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(n.uniform3i(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(Vt(t,e))return;n.uniform3iv(this.addr,e),Gt(t,e)}}function yy(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(n.uniform4i(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(Vt(t,e))return;n.uniform4iv(this.addr,e),Gt(t,e)}}function vy(n,e){const t=this.cache;t[0]!==e&&(n.uniform1ui(this.addr,e),t[0]=e)}function Sy(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(n.uniform2ui(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(Vt(t,e))return;n.uniform2uiv(this.addr,e),Gt(t,e)}}function by(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(n.uniform3ui(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(Vt(t,e))return;n.uniform3uiv(this.addr,e),Gt(t,e)}}function My(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(n.uniform4ui(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(Vt(t,e))return;n.uniform4uiv(this.addr,e),Gt(t,e)}}function Ay(n,e,t){const i=this.cache,s=t.allocateTextureUnit();i[0]!==s&&(n.uniform1i(this.addr,s),i[0]=s);let r;this.type===n.SAMPLER_2D_SHADOW?($c.compareFunction=t.isReversedDepthBuffer()?yu:xu,r=$c):r=gp,t.setTexture2D(e||r,s)}function Ey(n,e,t){const i=this.cache,s=t.allocateTextureUnit();i[0]!==s&&(n.uniform1i(this.addr,s),i[0]=s),t.setTexture3D(e||xp,s)}function Ty(n,e,t){const i=this.cache,s=t.allocateTextureUnit();i[0]!==s&&(n.uniform1i(this.addr,s),i[0]=s),t.setTextureCube(e||yp,s)}function Cy(n,e,t){const i=this.cache,s=t.allocateTextureUnit();i[0]!==s&&(n.uniform1i(this.addr,s),i[0]=s),t.setTexture2DArray(e||_p,s)}function wy(n){switch(n){case 5126:return cy;case 35664:return uy;case 35665:return hy;case 35666:return dy;case 35674:return fy;case 35675:return py;case 35676:return my;case 5124:case 35670:return gy;case 35667:case 35671:return _y;case 35668:case 35672:return xy;case 35669:case 35673:return yy;case 5125:return vy;case 36294:return Sy;case 36295:return by;case 36296:return My;case 35678:case 36198:case 36298:case 36306:case 35682:return Ay;case 35679:case 36299:case 36307:return Ey;case 35680:case 36300:case 36308:case 36293:return Ty;case 36289:case 36303:case 36311:case 36292:return Cy}}function Ry(n,e){n.uniform1fv(this.addr,e)}function Ly(n,e){const t=gr(e,this.size,2);n.uniform2fv(this.addr,t)}function Dy(n,e){const t=gr(e,this.size,3);n.uniform3fv(this.addr,t)}function Iy(n,e){const t=gr(e,this.size,4);n.uniform4fv(this.addr,t)}function Py(n,e){const t=gr(e,this.size,4);n.uniformMatrix2fv(this.addr,!1,t)}function Oy(n,e){const t=gr(e,this.size,9);n.uniformMatrix3fv(this.addr,!1,t)}function Uy(n,e){const t=gr(e,this.size,16);n.uniformMatrix4fv(this.addr,!1,t)}function Ny(n,e){n.uniform1iv(this.addr,e)}function ky(n,e){n.uniform2iv(this.addr,e)}function Fy(n,e){n.uniform3iv(this.addr,e)}function By(n,e){n.uniform4iv(this.addr,e)}function Hy(n,e){n.uniform1uiv(this.addr,e)}function zy(n,e){n.uniform2uiv(this.addr,e)}function Vy(n,e){n.uniform3uiv(this.addr,e)}function Gy(n,e){n.uniform4uiv(this.addr,e)}function Wy(n,e,t){const i=this.cache,s=e.length,r=Yo(t,s);Vt(i,r)||(n.uniform1iv(this.addr,r),Gt(i,r));let a;this.type===n.SAMPLER_2D_SHADOW?a=$c:a=gp;for(let o=0;o!==s;++o)t.setTexture2D(e[o]||a,r[o])}function Xy(n,e,t){const i=this.cache,s=e.length,r=Yo(t,s);Vt(i,r)||(n.uniform1iv(this.addr,r),Gt(i,r));for(let a=0;a!==s;++a)t.setTexture3D(e[a]||xp,r[a])}function Yy(n,e,t){const i=this.cache,s=e.length,r=Yo(t,s);Vt(i,r)||(n.uniform1iv(this.addr,r),Gt(i,r));for(let a=0;a!==s;++a)t.setTextureCube(e[a]||yp,r[a])}function Ky(n,e,t){const i=this.cache,s=e.length,r=Yo(t,s);Vt(i,r)||(n.uniform1iv(this.addr,r),Gt(i,r));for(let a=0;a!==s;++a)t.setTexture2DArray(e[a]||_p,r[a])}function qy(n){switch(n){case 5126:return Ry;case 35664:return Ly;case 35665:return Dy;case 35666:return Iy;case 35674:return Py;case 35675:return Oy;case 35676:return Uy;case 5124:case 35670:return Ny;case 35667:case 35671:return ky;case 35668:case 35672:return Fy;case 35669:case 35673:return By;case 5125:return Hy;case 36294:return zy;case 36295:return Vy;case 36296:return Gy;case 35678:case 36198:case 36298:case 36306:case 35682:return Wy;case 35679:case 36299:case 36307:return Xy;case 35680:case 36300:case 36308:case 36293:return Yy;case 36289:case 36303:case 36311:case 36292:return Ky}}class $y{constructor(e,t,i){this.id=e,this.addr=i,this.cache=[],this.type=t.type,this.setValue=wy(t.type)}}class Zy{constructor(e,t,i){this.id=e,this.addr=i,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=qy(t.type)}}class Jy{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,i){const s=this.seq;for(let r=0,a=s.length;r!==a;++r){const o=s[r];o.setValue(e,t[o.id],i)}}}const Ol=/(\w+)(\])?(\[|\.)?/g;function Qh(n,e){n.seq.push(e),n.map[e.id]=e}function jy(n,e,t){const i=n.name,s=i.length;for(Ol.lastIndex=0;;){const r=Ol.exec(i),a=Ol.lastIndex;let o=r[1];const l=r[2]==="]",c=r[3];if(l&&(o=o|0),c===void 0||c==="["&&a+2===s){Qh(t,c===void 0?new $y(o,n,e):new Zy(o,n,e));break}else{let h=t.map[o];h===void 0&&(h=new Jy(o),Qh(t,h)),t=h}}}class po{constructor(e,t){this.seq=[],this.map={};const i=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let a=0;a<i;++a){const o=e.getActiveUniform(t,a),l=e.getUniformLocation(t,o.name);jy(o,l,this)}const s=[],r=[];for(const a of this.seq)a.type===e.SAMPLER_2D_SHADOW||a.type===e.SAMPLER_CUBE_SHADOW||a.type===e.SAMPLER_2D_ARRAY_SHADOW?s.push(a):r.push(a);s.length>0&&(this.seq=s.concat(r))}setValue(e,t,i,s){const r=this.map[t];r!==void 0&&r.setValue(e,i,s)}setOptional(e,t,i){const s=t[i];s!==void 0&&this.setValue(e,i,s)}static upload(e,t,i,s){for(let r=0,a=t.length;r!==a;++r){const o=t[r],l=i[o.id];l.needsUpdate!==!1&&o.setValue(e,l.value,s)}}static seqWithValue(e,t){const i=[];for(let s=0,r=e.length;s!==r;++s){const a=e[s];a.id in t&&i.push(a)}return i}}function ed(n,e,t){const i=n.createShader(e);return n.shaderSource(i,t),n.compileShader(i),i}const Qy=37297;let ev=0;function tv(n,e){const t=n.split(`
`),i=[],s=Math.max(e-6,0),r=Math.min(e+6,t.length);for(let a=s;a<r;a++){const o=a+1;i.push(`${o===e?">":" "} ${o}: ${t[a]}`)}return i.join(`
`)}const td=new et;function nv(n){at._getMatrix(td,at.workingColorSpace,n);const e=`mat3( ${td.elements.map(t=>t.toFixed(4))} )`;switch(at.getTransfer(n)){case bo:return[e,"LinearTransferOETF"];case xt:return[e,"sRGBTransferOETF"];default:return $e("WebGLProgram: Unsupported color space: ",n),[e,"LinearTransferOETF"]}}function nd(n,e,t){const i=n.getShaderParameter(e,n.COMPILE_STATUS),r=(n.getShaderInfoLog(e)||"").trim();if(i&&r==="")return"";const a=/ERROR: 0:(\d+)/.exec(r);if(a){const o=parseInt(a[1]);return t.toUpperCase()+`
`+r+`
`+tv(n.getShaderSource(e),o)}else return r}function iv(n,e){const t=nv(e);return[`vec4 ${n}( vec4 value ) {`,` return ${t[1]}( vec4( value.rgb * ${t[0]}, value.a ) );`,"}"].join(`
`)}const sv={[Cf]:"Linear",[wf]:"Reinhard",[Rf]:"Cineon",[Lf]:"ACESFilmic",[If]:"AgX",[Pf]:"Neutral",[Df]:"Custom"};function rv(n,e){const t=sv[e];return t===void 0?($e("WebGLProgram: Unsupported toneMapping:",e),"vec3 "+n+"( vec3 color ) { return LinearToneMapping( color ); }"):"vec3 "+n+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}const Xa=new k;function av(){at.getLuminanceCoefficients(Xa);const n=Xa.x.toFixed(4),e=Xa.y.toFixed(4),t=Xa.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${n}, ${e}, ${t} );`," return dot( weights, rgb );","}"].join(`
`)}function ov(n){return[n.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",n.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(Fr).join(`
`)}function lv(n){const e=[];for(const t in n){const i=n[t];i!==!1&&e.push("#define "+t+" "+i)}return e.join(`
`)}function cv(n,e){const t={},i=n.getProgramParameter(e,n.ACTIVE_ATTRIBUTES);for(let s=0;s<i;s++){const r=n.getActiveAttrib(e,s),a=r.name;let o=1;r.type===n.FLOAT_MAT2&&(o=2),r.type===n.FLOAT_MAT3&&(o=3),r.type===n.FLOAT_MAT4&&(o=4),t[a]={type:r.type,location:n.getAttribLocation(e,a),locationSize:o}}return t}function Fr(n){return n!==""}function id(n,e){const t=e.numSpotLightShadows+e.numSpotLightMaps-e.numSpotLightShadowsWithMaps;return n.replace(/NUM_DIR_LIGHTS/g,e.numDirLights).replace(/NUM_SPOT_LIGHTS/g,e.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,e.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,t).replace(/NUM_RECT_AREA_LIGHTS/g,e.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,e.numPointLights).replace(/NUM_HEMI_LIGHTS/g,e.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,e.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,e.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,e.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,e.numPointLightShadows)}function sd(n,e){return n.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const uv=/^[ \t]*#include +<([\w\d./]+)>/gm;function Zc(n){return n.replace(uv,dv)}const hv=new Map;function dv(n,e){let t=tt[e];if(t===void 0){const i=hv.get(e);if(i!==void 0)t=tt[i],$e('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,i);else throw new Error("THREE.WebGLProgram: Can not resolve #include <"+e+">")}return Zc(t)}const fv=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function rd(n){return n.replace(fv,pv)}function pv(n,e,t,i){let s="";for(let r=parseInt(e);r<parseInt(t);r++)s+=i.replace(/\[\s*i\s*\]/g,"[ "+r+" ]").replace(/UNROLLED_LOOP_INDEX/g,r);return s}function ad(n){let e=`precision ${n.precision} float;
precision ${n.precision} int;
precision ${n.precision} sampler2D;
precision ${n.precision} samplerCube;
precision ${n.precision} sampler3D;
precision ${n.precision} sampler2DArray;
precision ${n.precision} sampler2DShadow;
precision ${n.precision} samplerCubeShadow;
precision ${n.precision} sampler2DArrayShadow;
precision ${n.precision} isampler2D;
precision ${n.precision} isampler3D;
precision ${n.precision} isamplerCube;
precision ${n.precision} isampler2DArray;
precision ${n.precision} usampler2D;
precision ${n.precision} usampler3D;
precision ${n.precision} usamplerCube;
precision ${n.precision} usampler2DArray;
`;return n.precision==="highp"?e+=`
#define HIGH_PRECISION`:n.precision==="mediump"?e+=`
#define MEDIUM_PRECISION`:n.precision==="lowp"&&(e+=`
#define LOW_PRECISION`),e}const mv={[lo]:"SHADOWMAP_TYPE_PCF",[Ur]:"SHADOWMAP_TYPE_VSM"};function gv(n){return mv[n.shadowMapType]||"SHADOWMAP_TYPE_BASIC"}const _v={[ms]:"ENVMAP_TYPE_CUBE",[rr]:"ENVMAP_TYPE_CUBE",[Wo]:"ENVMAP_TYPE_CUBE_UV"};function xv(n){return n.envMap===!1?"ENVMAP_TYPE_CUBE":_v[n.envMapMode]||"ENVMAP_TYPE_CUBE"}const yv={[rr]:"ENVMAP_MODE_REFRACTION"};function vv(n){return n.envMap===!1?"ENVMAP_MODE_REFLECTION":yv[n.envMapMode]||"ENVMAP_MODE_REFLECTION"}const Sv={[Tf]:"ENVMAP_BLENDING_MULTIPLY",[pm]:"ENVMAP_BLENDING_MIX",[mm]:"ENVMAP_BLENDING_ADD"};function bv(n){return n.envMap===!1?"ENVMAP_BLENDING_NONE":Sv[n.combine]||"ENVMAP_BLENDING_NONE"}function Mv(n){const e=n.envMapCubeUVHeight;if(e===null)return null;const t=Math.log2(e)-2,i=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,t),7*16)),texelHeight:i,maxMip:t}}function Av(n,e,t,i){const s=n.getContext(),r=t.defines;let a=t.vertexShader,o=t.fragmentShader;const l=gv(t),c=xv(t),u=vv(t),h=bv(t),d=Mv(t),f=ov(t),p=lv(r),_=s.createProgram();let m,g,v=t.glslVersion?"#version "+t.glslVersion+`
`:"";t.isRawShaderMaterial?(m=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,p].filter(Fr).join(`
`),m.length>0&&(m+=`
`),g=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,p].filter(Fr).join(`
`),g.length>0&&(g+=`
`)):(m=[ad(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,p,t.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",t.batching?"#define USE_BATCHING":"",t.batchingColor?"#define USE_BATCHING_COLOR":"",t.instancing?"#define USE_INSTANCING":"",t.instancingColor?"#define USE_INSTANCING_COLOR":"",t.instancingMorph?"#define USE_INSTANCING_MORPH":"",t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+u:"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.displacementMap?"#define USE_DISPLACEMENTMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.mapUv?"#define MAP_UV "+t.mapUv:"",t.alphaMapUv?"#define ALPHAMAP_UV "+t.alphaMapUv:"",t.lightMapUv?"#define LIGHTMAP_UV "+t.lightMapUv:"",t.aoMapUv?"#define AOMAP_UV "+t.aoMapUv:"",t.emissiveMapUv?"#define EMISSIVEMAP_UV "+t.emissiveMapUv:"",t.bumpMapUv?"#define BUMPMAP_UV "+t.bumpMapUv:"",t.normalMapUv?"#define NORMALMAP_UV "+t.normalMapUv:"",t.displacementMapUv?"#define DISPLACEMENTMAP_UV "+t.displacementMapUv:"",t.metalnessMapUv?"#define METALNESSMAP_UV "+t.metalnessMapUv:"",t.roughnessMapUv?"#define ROUGHNESSMAP_UV "+t.roughnessMapUv:"",t.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+t.anisotropyMapUv:"",t.clearcoatMapUv?"#define CLEARCOATMAP_UV "+t.clearcoatMapUv:"",t.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+t.clearcoatNormalMapUv:"",t.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+t.clearcoatRoughnessMapUv:"",t.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+t.iridescenceMapUv:"",t.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+t.iridescenceThicknessMapUv:"",t.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+t.sheenColorMapUv:"",t.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+t.sheenRoughnessMapUv:"",t.specularMapUv?"#define SPECULARMAP_UV "+t.specularMapUv:"",t.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+t.specularColorMapUv:"",t.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+t.specularIntensityMapUv:"",t.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+t.transmissionMapUv:"",t.thicknessMapUv?"#define THICKNESSMAP_UV "+t.thicknessMapUv:"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexNormals?"#define HAS_NORMAL":"",t.vertexColors?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.flatShading?"#define FLAT_SHADED":"",t.skinning?"#define USE_SKINNING":"",t.morphTargets?"#define USE_MORPHTARGETS":"",t.morphNormals&&t.flatShading===!1?"#define USE_MORPHNORMALS":"",t.morphColors?"#define USE_MORPHCOLORS":"",t.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+t.morphTextureStride:"",t.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+t.morphTargetsCount:"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+l:"",t.sizeAttenuation?"#define USE_SIZEATTENUATION":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",t.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",`
`].filter(Fr).join(`
`),g=[ad(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,p,t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",t.map?"#define USE_MAP":"",t.matcap?"#define USE_MATCAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+c:"",t.envMap?"#define "+u:"",t.envMap?"#define "+h:"",d?"#define CUBEUV_TEXEL_WIDTH "+d.texelWidth:"",d?"#define CUBEUV_TEXEL_HEIGHT "+d.texelHeight:"",d?"#define CUBEUV_MAX_MIP "+d.maxMip+".0":"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.packedNormalMap?"#define USE_PACKED_NORMALMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoat?"#define USE_CLEARCOAT":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.dispersion?"#define USE_DISPERSION":"",t.iridescence?"#define USE_IRIDESCENCE":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaTest?"#define USE_ALPHATEST":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.sheen?"#define USE_SHEEN":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors||t.instancingColor?"#define USE_COLOR":"",t.vertexAlphas||t.batchingColor?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.gradientMap?"#define USE_GRADIENTMAP":"",t.flatShading?"#define FLAT_SHADED":"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+l:"",t.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.numLightProbeGrids>0?"#define USE_LIGHT_PROBES_GRID":"",t.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",t.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",t.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",t.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==li?"#define TONE_MAPPING":"",t.toneMapping!==li?tt.tonemapping_pars_fragment:"",t.toneMapping!==li?rv("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",tt.colorspace_pars_fragment,iv("linearToOutputTexel",t.outputColorSpace),av(),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",`
`].filter(Fr).join(`
`)),a=Zc(a),a=id(a,t),a=sd(a,t),o=Zc(o),o=id(o,t),o=sd(o,t),a=rd(a),o=rd(o),t.isRawShaderMaterial!==!0&&(v=`#version 300 es
`,m=[f,"#define attribute in","#define varying out","#define texture2D texture"].join(`
`)+`
`+m,g=["#define varying in",t.glslVersion===Wc?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===Wc?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join(`
`)+`
`+g);const b=v+m+a,x=v+g+o,E=ed(s,s.VERTEX_SHADER,b),S=ed(s,s.FRAGMENT_SHADER,x);s.attachShader(_,E),s.attachShader(_,S),t.index0AttributeName!==void 0?s.bindAttribLocation(_,0,t.index0AttributeName):t.hasPositionAttribute===!0&&s.bindAttribLocation(_,0,"position"),s.linkProgram(_);function A(R){if(n.debug.checkShaderErrors){const w=s.getProgramInfoLog(_)||"",P=s.getShaderInfoLog(E)||"",U=s.getShaderInfoLog(S)||"",D=w.trim(),K=P.trim(),B=U.trim();let ie=!0,F=!0;if(s.getProgramParameter(_,s.LINK_STATUS)===!1)if(ie=!1,typeof n.debug.onShaderError=="function")n.debug.onShaderError(s,_,E,S);else{const se=nd(s,E,"vertex"),V=nd(s,S,"fragment");ut("WebGLProgram: Shader Error "+s.getError()+" - VALIDATE_STATUS "+s.getProgramParameter(_,s.VALIDATE_STATUS)+`
Material Name: `+R.name+`
Material Type: `+R.type+`
Program Info Log: `+D+`
`+se+`
`+V)}else D!==""?$e("WebGLProgram: Program Info Log:",D):(K===""||B==="")&&(F=!1);F&&(R.diagnostics={runnable:ie,programLog:D,vertexShader:{log:K,prefix:m},fragmentShader:{log:B,prefix:g}})}s.deleteShader(E),s.deleteShader(S),y=new po(s,_),T=cv(s,_)}let y;this.getUniforms=function(){return y===void 0&&A(this),y};let T;this.getAttributes=function(){return T===void 0&&A(this),T};let L=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return L===!1&&(L=s.getProgramParameter(_,Qy)),L},this.destroy=function(){i.releaseStatesOfProgram(this),s.deleteProgram(_),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=ev++,this.cacheKey=e,this.usedTimes=1,this.program=_,this.vertexShader=E,this.fragmentShader=S,this}let Ev=0;class Tv{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e,t,i){const s=this._getShaderCacheForMaterial(e);return s.has(t)===!1&&(s.add(t),t.usedTimes++),s.has(i)===!1&&(s.add(i),i.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const i of t)i.usedTimes--,i.usedTimes===0&&this.shaderCache.delete(i.code);return this.materialCache.delete(e),this}getVertexShaderStage(e){return this._getShaderStage(e.vertexShader)}getFragmentShaderStage(e){return this._getShaderStage(e.fragmentShader)}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const t=this.materialCache;let i=t.get(e);return i===void 0&&(i=new Set,t.set(e,i)),i}_getShaderStage(e){const t=this.shaderCache;let i=t.get(e);return i===void 0&&(i=new Cv(e),t.set(e,i)),i}}class Cv{constructor(e){this.id=Ev++,this.code=e,this.usedTimes=0}}function wv(n){return n===gs||n===yo||n===vo}function Rv(n,e,t,i,s,r){const a=new Xf,o=new Tv,l=new Set,c=[],u=new Map,h=i.logarithmicDepthBuffer;let d=i.precision;const f={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distance",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function p(y){return l.add(y),y===0?"uv":`uv${y}`}function _(y,T,L,R,w,P){const U=R.fog,D=w.geometry,K=y.isMeshStandardMaterial||y.isMeshLambertMaterial||y.isMeshPhongMaterial?R.environment:null,B=y.isMeshStandardMaterial||y.isMeshLambertMaterial&&!y.envMap||y.isMeshPhongMaterial&&!y.envMap,ie=e.get(y.envMap||K,B),F=ie&&ie.mapping===Wo?ie.image.height:null,se=f[y.type];y.precision!==null&&(d=i.getMaxPrecision(y.precision),d!==y.precision&&$e("WebGLProgram.getParameters:",y.precision,"not supported, using",d,"instead."));const V=D.morphAttributes.position||D.morphAttributes.normal||D.morphAttributes.color,oe=V!==void 0?V.length:0;let Ae=0;D.morphAttributes.position!==void 0&&(Ae=1),D.morphAttributes.normal!==void 0&&(Ae=2),D.morphAttributes.color!==void 0&&(Ae=3);let me,ue,z,ee;if(se){const fe=gn[se];me=fe.vertexShader,ue=fe.fragmentShader}else{me=y.vertexShader,ue=y.fragmentShader;const fe=o.getVertexShaderStage(y),Ue=o.getFragmentShaderStage(y);o.update(y,fe,Ue),z=fe.id,ee=Ue.id}const Z=n.getRenderTarget(),xe=n.state.buffers.depth.getReversed(),be=w.isInstancedMesh===!0,Se=w.isBatchedMesh===!0,Oe=!!y.map,Ge=!!y.matcap,Ye=!!ie,Ke=!!y.aoMap,Be=!!y.lightMap,Pe=!!y.bumpMap&&y.wireframe===!1,st=!!y.normalMap,mt=!!y.displacementMap,gt=!!y.emissiveMap,ft=!!y.metalnessMap,_t=!!y.roughnessMap,G=y.anisotropy>0,nt=y.clearcoat>0,lt=y.dispersion>0,I=y.iridescence>0,M=y.sheen>0,q=y.transmission>0,te=G&&!!y.anisotropyMap,Q=nt&&!!y.clearcoatMap,he=nt&&!!y.clearcoatNormalMap,Te=nt&&!!y.clearcoatRoughnessMap,ce=I&&!!y.iridescenceMap,pe=I&&!!y.iridescenceThicknessMap,Ee=M&&!!y.sheenColorMap,We=M&&!!y.sheenRoughnessMap,H=!!y.specularMap,ne=!!y.specularColorMap,O=!!y.specularIntensityMap,De=q&&!!y.transmissionMap,ye=q&&!!y.thicknessMap,N=!!y.gradientMap,ge=!!y.alphaMap,le=y.alphaTest>0,W=!!y.alphaHash,ae=!!y.extensions;let $=li;y.toneMapped&&(Z===null||Z.isXRRenderTarget===!0)&&($=n.toneMapping);const de={shaderID:se,shaderType:y.type,shaderName:y.name,vertexShader:me,fragmentShader:ue,defines:y.defines,customVertexShaderID:z,customFragmentShaderID:ee,isRawShaderMaterial:y.isRawShaderMaterial===!0,glslVersion:y.glslVersion,precision:d,batching:Se,batchingColor:Se&&w._colorsTexture!==null,instancing:be,instancingColor:be&&w.instanceColor!==null,instancingMorph:be&&w.morphTexture!==null,outputColorSpace:Z===null?n.outputColorSpace:Z.isXRRenderTarget===!0?Z.texture.colorSpace:at.workingColorSpace,alphaToCoverage:!!y.alphaToCoverage,map:Oe,matcap:Ge,envMap:Ye,envMapMode:Ye&&ie.mapping,envMapCubeUVHeight:F,aoMap:Ke,lightMap:Be,bumpMap:Pe,normalMap:st,displacementMap:mt,emissiveMap:gt,normalMapObjectSpace:st&&y.normalMapType===xm,normalMapTangentSpace:st&&y.normalMapType===th,packedNormalMap:st&&y.normalMapType===th&&wv(y.normalMap.format),metalnessMap:ft,roughnessMap:_t,anisotropy:G,anisotropyMap:te,clearcoat:nt,clearcoatMap:Q,clearcoatNormalMap:he,clearcoatRoughnessMap:Te,dispersion:lt,iridescence:I,iridescenceMap:ce,iridescenceThicknessMap:pe,sheen:M,sheenColorMap:Ee,sheenRoughnessMap:We,specularMap:H,specularColorMap:ne,specularIntensityMap:O,transmission:q,transmissionMap:De,thicknessMap:ye,gradientMap:N,opaque:y.transparent===!1&&y.blending===er&&y.alphaToCoverage===!1,alphaMap:ge,alphaTest:le,alphaHash:W,combine:y.combine,mapUv:Oe&&p(y.map.channel),aoMapUv:Ke&&p(y.aoMap.channel),lightMapUv:Be&&p(y.lightMap.channel),bumpMapUv:Pe&&p(y.bumpMap.channel),normalMapUv:st&&p(y.normalMap.channel),displacementMapUv:mt&&p(y.displacementMap.channel),emissiveMapUv:gt&&p(y.emissiveMap.channel),metalnessMapUv:ft&&p(y.metalnessMap.channel),roughnessMapUv:_t&&p(y.roughnessMap.channel),anisotropyMapUv:te&&p(y.anisotropyMap.channel),clearcoatMapUv:Q&&p(y.clearcoatMap.channel),clearcoatNormalMapUv:he&&p(y.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:Te&&p(y.clearcoatRoughnessMap.channel),iridescenceMapUv:ce&&p(y.iridescenceMap.channel),iridescenceThicknessMapUv:pe&&p(y.iridescenceThicknessMap.channel),sheenColorMapUv:Ee&&p(y.sheenColorMap.channel),sheenRoughnessMapUv:We&&p(y.sheenRoughnessMap.channel),specularMapUv:H&&p(y.specularMap.channel),specularColorMapUv:ne&&p(y.specularColorMap.channel),specularIntensityMapUv:O&&p(y.specularIntensityMap.channel),transmissionMapUv:De&&p(y.transmissionMap.channel),thicknessMapUv:ye&&p(y.thicknessMap.channel),alphaMapUv:ge&&p(y.alphaMap.channel),vertexTangents:!!D.attributes.tangent&&(st||G),vertexNormals:!!D.attributes.normal,vertexColors:y.vertexColors,vertexAlphas:y.vertexColors===!0&&!!D.attributes.color&&D.attributes.color.itemSize===4,pointsUvs:w.isPoints===!0&&!!D.attributes.uv&&(Oe||ge),fog:!!U,useFog:y.fog===!0,fogExp2:!!U&&U.isFogExp2,flatShading:y.wireframe===!1&&(y.flatShading===!0||D.attributes.normal===void 0&&st===!1&&(y.isMeshLambertMaterial||y.isMeshPhongMaterial||y.isMeshStandardMaterial||y.isMeshPhysicalMaterial)),sizeAttenuation:y.sizeAttenuation===!0,logarithmicDepthBuffer:h,reversedDepthBuffer:xe,skinning:w.isSkinnedMesh===!0,hasPositionAttribute:D.attributes.position!==void 0,morphTargets:D.morphAttributes.position!==void 0,morphNormals:D.morphAttributes.normal!==void 0,morphColors:D.morphAttributes.color!==void 0,morphTargetsCount:oe,morphTextureStride:Ae,numDirLights:T.directional.length,numPointLights:T.point.length,numSpotLights:T.spot.length,numSpotLightMaps:T.spotLightMap.length,numRectAreaLights:T.rectArea.length,numHemiLights:T.hemi.length,numDirLightShadows:T.directionalShadowMap.length,numPointLightShadows:T.pointShadowMap.length,numSpotLightShadows:T.spotShadowMap.length,numSpotLightShadowsWithMaps:T.numSpotLightShadowsWithMaps,numLightProbes:T.numLightProbes,numLightProbeGrids:P.length,numClippingPlanes:r.numPlanes,numClipIntersection:r.numIntersection,dithering:y.dithering,shadowMapEnabled:n.shadowMap.enabled&&L.length>0,shadowMapType:n.shadowMap.type,toneMapping:$,decodeVideoTexture:Oe&&y.map.isVideoTexture===!0&&at.getTransfer(y.map.colorSpace)===xt,decodeVideoTextureEmissive:gt&&y.emissiveMap.isVideoTexture===!0&&at.getTransfer(y.emissiveMap.colorSpace)===xt,premultipliedAlpha:y.premultipliedAlpha,doubleSided:y.side===Yt,flipSided:y.side===_n,useDepthPacking:y.depthPacking>=0,depthPacking:y.depthPacking||0,index0AttributeName:y.index0AttributeName,extensionClipCullDistance:ae&&y.extensions.clipCullDistance===!0&&t.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(ae&&y.extensions.multiDraw===!0||Se)&&t.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:t.has("KHR_parallel_shader_compile"),customProgramCacheKey:y.customProgramCacheKey()};return de.vertexUv1s=l.has(1),de.vertexUv2s=l.has(2),de.vertexUv3s=l.has(3),l.clear(),de}function m(y){const T=[];if(y.shaderID?T.push(y.shaderID):(T.push(y.customVertexShaderID),T.push(y.customFragmentShaderID)),y.defines!==void 0)for(const L in y.defines)T.push(L),T.push(y.defines[L]);return y.isRawShaderMaterial===!1&&(g(T,y),v(T,y),T.push(n.outputColorSpace)),T.push(y.customProgramCacheKey),T.join()}function g(y,T){y.push(T.precision),y.push(T.outputColorSpace),y.push(T.envMapMode),y.push(T.envMapCubeUVHeight),y.push(T.mapUv),y.push(T.alphaMapUv),y.push(T.lightMapUv),y.push(T.aoMapUv),y.push(T.bumpMapUv),y.push(T.normalMapUv),y.push(T.displacementMapUv),y.push(T.emissiveMapUv),y.push(T.metalnessMapUv),y.push(T.roughnessMapUv),y.push(T.anisotropyMapUv),y.push(T.clearcoatMapUv),y.push(T.clearcoatNormalMapUv),y.push(T.clearcoatRoughnessMapUv),y.push(T.iridescenceMapUv),y.push(T.iridescenceThicknessMapUv),y.push(T.sheenColorMapUv),y.push(T.sheenRoughnessMapUv),y.push(T.specularMapUv),y.push(T.specularColorMapUv),y.push(T.specularIntensityMapUv),y.push(T.transmissionMapUv),y.push(T.thicknessMapUv),y.push(T.combine),y.push(T.fogExp2),y.push(T.sizeAttenuation),y.push(T.morphTargetsCount),y.push(T.morphAttributeCount),y.push(T.numDirLights),y.push(T.numPointLights),y.push(T.numSpotLights),y.push(T.numSpotLightMaps),y.push(T.numHemiLights),y.push(T.numRectAreaLights),y.push(T.numDirLightShadows),y.push(T.numPointLightShadows),y.push(T.numSpotLightShadows),y.push(T.numSpotLightShadowsWithMaps),y.push(T.numLightProbes),y.push(T.shadowMapType),y.push(T.toneMapping),y.push(T.numClippingPlanes),y.push(T.numClipIntersection),y.push(T.depthPacking)}function v(y,T){a.disableAll(),T.instancing&&a.enable(0),T.instancingColor&&a.enable(1),T.instancingMorph&&a.enable(2),T.matcap&&a.enable(3),T.envMap&&a.enable(4),T.normalMapObjectSpace&&a.enable(5),T.normalMapTangentSpace&&a.enable(6),T.clearcoat&&a.enable(7),T.iridescence&&a.enable(8),T.alphaTest&&a.enable(9),T.vertexColors&&a.enable(10),T.vertexAlphas&&a.enable(11),T.vertexUv1s&&a.enable(12),T.vertexUv2s&&a.enable(13),T.vertexUv3s&&a.enable(14),T.vertexTangents&&a.enable(15),T.anisotropy&&a.enable(16),T.alphaHash&&a.enable(17),T.batching&&a.enable(18),T.dispersion&&a.enable(19),T.batchingColor&&a.enable(20),T.gradientMap&&a.enable(21),T.packedNormalMap&&a.enable(22),T.vertexNormals&&a.enable(23),y.push(a.mask),a.disableAll(),T.fog&&a.enable(0),T.useFog&&a.enable(1),T.flatShading&&a.enable(2),T.logarithmicDepthBuffer&&a.enable(3),T.reversedDepthBuffer&&a.enable(4),T.skinning&&a.enable(5),T.morphTargets&&a.enable(6),T.morphNormals&&a.enable(7),T.morphColors&&a.enable(8),T.premultipliedAlpha&&a.enable(9),T.shadowMapEnabled&&a.enable(10),T.doubleSided&&a.enable(11),T.flipSided&&a.enable(12),T.useDepthPacking&&a.enable(13),T.dithering&&a.enable(14),T.transmission&&a.enable(15),T.sheen&&a.enable(16),T.opaque&&a.enable(17),T.pointsUvs&&a.enable(18),T.decodeVideoTexture&&a.enable(19),T.decodeVideoTextureEmissive&&a.enable(20),T.alphaToCoverage&&a.enable(21),T.numLightProbeGrids>0&&a.enable(22),T.hasPositionAttribute&&a.enable(23),y.push(a.mask)}function b(y){const T=f[y.type];let L;if(T){const R=gn[T];L=Tu.clone(R.uniforms)}else L=y.uniforms;return L}function x(y,T){let L=u.get(T);return L!==void 0?++L.usedTimes:(L=new Av(n,T,y,s),c.push(L),u.set(T,L)),L}function E(y){if(--y.usedTimes===0){const T=c.indexOf(y);c[T]=c[c.length-1],c.pop(),u.delete(y.cacheKey),y.destroy()}}function S(y){o.remove(y)}function A(){o.dispose()}return{getParameters:_,getProgramCacheKey:m,getUniforms:b,acquireProgram:x,releaseProgram:E,releaseShaderCache:S,programs:c,dispose:A}}function Lv(){let n=new WeakMap;function e(a){return n.has(a)}function t(a){let o=n.get(a);return o===void 0&&(o={},n.set(a,o)),o}function i(a){n.delete(a)}function s(a,o,l){n.get(a)[o]=l}function r(){n=new WeakMap}return{has:e,get:t,remove:i,update:s,dispose:r}}function Dv(n,e){return n.groupOrder!==e.groupOrder?n.groupOrder-e.groupOrder:n.renderOrder!==e.renderOrder?n.renderOrder-e.renderOrder:n.material.id!==e.material.id?n.material.id-e.material.id:n.materialVariant!==e.materialVariant?n.materialVariant-e.materialVariant:n.z!==e.z?n.z-e.z:n.id-e.id}function od(n,e){return n.groupOrder!==e.groupOrder?n.groupOrder-e.groupOrder:n.renderOrder!==e.renderOrder?n.renderOrder-e.renderOrder:n.z!==e.z?e.z-n.z:n.id-e.id}function ld(){const n=[];let e=0;const t=[],i=[],s=[];function r(){e=0,t.length=0,i.length=0,s.length=0}function a(d){let f=0;return d.isInstancedMesh&&(f+=2),d.isSkinnedMesh&&(f+=1),f}function o(d,f,p,_,m,g){let v=n[e];return v===void 0?(v={id:d.id,object:d,geometry:f,material:p,materialVariant:a(d),groupOrder:_,renderOrder:d.renderOrder,z:m,group:g},n[e]=v):(v.id=d.id,v.object=d,v.geometry=f,v.material=p,v.materialVariant=a(d),v.groupOrder=_,v.renderOrder=d.renderOrder,v.z=m,v.group=g),e++,v}function l(d,f,p,_,m,g){const v=o(d,f,p,_,m,g);p.transmission>0?i.push(v):p.transparent===!0?s.push(v):t.push(v)}function c(d,f,p,_,m,g){const v=o(d,f,p,_,m,g);p.transmission>0?i.unshift(v):p.transparent===!0?s.unshift(v):t.unshift(v)}function u(d,f,p){t.length>1&&t.sort(d||Dv),i.length>1&&i.sort(f||od),s.length>1&&s.sort(f||od),p&&(t.reverse(),i.reverse(),s.reverse())}function h(){for(let d=e,f=n.length;d<f;d++){const p=n[d];if(p.id===null)break;p.id=null,p.object=null,p.geometry=null,p.material=null,p.group=null}}return{opaque:t,transmissive:i,transparent:s,init:r,push:l,unshift:c,finish:h,sort:u}}function Iv(){let n=new WeakMap;function e(i,s){const r=n.get(i);let a;return r===void 0?(a=new ld,n.set(i,[a])):s>=r.length?(a=new ld,r.push(a)):a=r[s],a}function t(){n=new WeakMap}return{get:e,dispose:t}}function Pv(){const n={};return{get:function(e){if(n[e.id]!==void 0)return n[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new k,color:new it};break;case"SpotLight":t={position:new k,direction:new k,color:new it,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new k,color:new it,distance:0,decay:0};break;case"HemisphereLight":t={direction:new k,skyColor:new it,groundColor:new it};break;case"RectAreaLight":t={color:new it,position:new k,halfWidth:new k,halfHeight:new k};break}return n[e.id]=t,t}}}function Ov(){const n={};return{get:function(e){if(n[e.id]!==void 0)return n[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Le};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Le};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Le,shadowCameraNear:1,shadowCameraFar:1e3};break}return n[e.id]=t,t}}}let Uv=0;function Nv(n,e){return(e.castShadow?2:0)-(n.castShadow?2:0)+(e.map?1:0)-(n.map?1:0)}function kv(n){const e=new Pv,t=Ov(),i={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let c=0;c<9;c++)i.probe.push(new k);const s=new k,r=new Rt,a=new Rt;function o(c){let u=0,h=0,d=0;for(let T=0;T<9;T++)i.probe[T].set(0,0,0);let f=0,p=0,_=0,m=0,g=0,v=0,b=0,x=0,E=0,S=0,A=0;c.sort(Nv);for(let T=0,L=c.length;T<L;T++){const R=c[T],w=R.color,P=R.intensity,U=R.distance;let D=null;if(R.shadow&&R.shadow.map&&(R.shadow.map.texture.format===gs?D=R.shadow.map.texture:D=R.shadow.map.depthTexture||R.shadow.map.texture),R.isAmbientLight)u+=w.r*P,h+=w.g*P,d+=w.b*P;else if(R.isLightProbe){for(let K=0;K<9;K++)i.probe[K].addScaledVector(R.sh.coefficients[K],P);A++}else if(R.isDirectionalLight){const K=e.get(R);if(K.color.copy(R.color).multiplyScalar(R.intensity),R.castShadow){const B=R.shadow,ie=t.get(R);ie.shadowIntensity=B.intensity,ie.shadowBias=B.bias,ie.shadowNormalBias=B.normalBias,ie.shadowRadius=B.radius,ie.shadowMapSize=B.mapSize,i.directionalShadow[f]=ie,i.directionalShadowMap[f]=D,i.directionalShadowMatrix[f]=R.shadow.matrix,v++}i.directional[f]=K,f++}else if(R.isSpotLight){const K=e.get(R);K.position.setFromMatrixPosition(R.matrixWorld),K.color.copy(w).multiplyScalar(P),K.distance=U,K.coneCos=Math.cos(R.angle),K.penumbraCos=Math.cos(R.angle*(1-R.penumbra)),K.decay=R.decay,i.spot[_]=K;const B=R.shadow;if(R.map&&(i.spotLightMap[E]=R.map,E++,B.updateMatrices(R),R.castShadow&&S++),i.spotLightMatrix[_]=B.matrix,R.castShadow){const ie=t.get(R);ie.shadowIntensity=B.intensity,ie.shadowBias=B.bias,ie.shadowNormalBias=B.normalBias,ie.shadowRadius=B.radius,ie.shadowMapSize=B.mapSize,i.spotShadow[_]=ie,i.spotShadowMap[_]=D,x++}_++}else if(R.isRectAreaLight){const K=e.get(R);K.color.copy(w).multiplyScalar(P),K.halfWidth.set(R.width*.5,0,0),K.halfHeight.set(0,R.height*.5,0),i.rectArea[m]=K,m++}else if(R.isPointLight){const K=e.get(R);if(K.color.copy(R.color).multiplyScalar(R.intensity),K.distance=R.distance,K.decay=R.decay,R.castShadow){const B=R.shadow,ie=t.get(R);ie.shadowIntensity=B.intensity,ie.shadowBias=B.bias,ie.shadowNormalBias=B.normalBias,ie.shadowRadius=B.radius,ie.shadowMapSize=B.mapSize,ie.shadowCameraNear=B.camera.near,ie.shadowCameraFar=B.camera.far,i.pointShadow[p]=ie,i.pointShadowMap[p]=D,i.pointShadowMatrix[p]=R.shadow.matrix,b++}i.point[p]=K,p++}else if(R.isHemisphereLight){const K=e.get(R);K.skyColor.copy(R.color).multiplyScalar(P),K.groundColor.copy(R.groundColor).multiplyScalar(P),i.hemi[g]=K,g++}}m>0&&(n.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=we.LTC_FLOAT_1,i.rectAreaLTC2=we.LTC_FLOAT_2):(i.rectAreaLTC1=we.LTC_HALF_1,i.rectAreaLTC2=we.LTC_HALF_2)),i.ambient[0]=u,i.ambient[1]=h,i.ambient[2]=d;const y=i.hash;(y.directionalLength!==f||y.pointLength!==p||y.spotLength!==_||y.rectAreaLength!==m||y.hemiLength!==g||y.numDirectionalShadows!==v||y.numPointShadows!==b||y.numSpotShadows!==x||y.numSpotMaps!==E||y.numLightProbes!==A)&&(i.directional.length=f,i.spot.length=_,i.rectArea.length=m,i.point.length=p,i.hemi.length=g,i.directionalShadow.length=v,i.directionalShadowMap.length=v,i.pointShadow.length=b,i.pointShadowMap.length=b,i.spotShadow.length=x,i.spotShadowMap.length=x,i.directionalShadowMatrix.length=v,i.pointShadowMatrix.length=b,i.spotLightMatrix.length=x+E-S,i.spotLightMap.length=E,i.numSpotLightShadowsWithMaps=S,i.numLightProbes=A,y.directionalLength=f,y.pointLength=p,y.spotLength=_,y.rectAreaLength=m,y.hemiLength=g,y.numDirectionalShadows=v,y.numPointShadows=b,y.numSpotShadows=x,y.numSpotMaps=E,y.numLightProbes=A,i.version=Uv++)}function l(c,u){let h=0,d=0,f=0,p=0,_=0;const m=u.matrixWorldInverse;for(let g=0,v=c.length;g<v;g++){const b=c[g];if(b.isDirectionalLight){const x=i.directional[h];x.direction.setFromMatrixPosition(b.matrixWorld),s.setFromMatrixPosition(b.target.matrixWorld),x.direction.sub(s),x.direction.transformDirection(m),h++}else if(b.isSpotLight){const x=i.spot[f];x.position.setFromMatrixPosition(b.matrixWorld),x.position.applyMatrix4(m),x.direction.setFromMatrixPosition(b.matrixWorld),s.setFromMatrixPosition(b.target.matrixWorld),x.direction.sub(s),x.direction.transformDirection(m),f++}else if(b.isRectAreaLight){const x=i.rectArea[p];x.position.setFromMatrixPosition(b.matrixWorld),x.position.applyMatrix4(m),a.identity(),r.copy(b.matrixWorld),r.premultiply(m),a.extractRotation(r),x.halfWidth.set(b.width*.5,0,0),x.halfHeight.set(0,b.height*.5,0),x.halfWidth.applyMatrix4(a),x.halfHeight.applyMatrix4(a),p++}else if(b.isPointLight){const x=i.point[d];x.position.setFromMatrixPosition(b.matrixWorld),x.position.applyMatrix4(m),d++}else if(b.isHemisphereLight){const x=i.hemi[_];x.direction.setFromMatrixPosition(b.matrixWorld),x.direction.transformDirection(m),_++}}}return{setup:o,setupView:l,state:i}}function cd(n){const e=new kv(n),t=[],i=[],s=[];function r(d){h.camera=d,t.length=0,i.length=0,s.length=0}function a(d){t.push(d)}function o(d){i.push(d)}function l(d){s.push(d)}function c(){e.setup(t)}function u(d){e.setupView(t,d)}const h={lightsArray:t,shadowsArray:i,lightProbeGridArray:s,camera:null,lights:e,transmissionRenderTarget:{},textureUnits:0};return{init:r,state:h,setupLights:c,setupLightsView:u,pushLight:a,pushShadow:o,pushLightProbeGrid:l}}function Fv(n){let e=new WeakMap;function t(s,r=0){const a=e.get(s);let o;return a===void 0?(o=new cd(n),e.set(s,[o])):r>=a.length?(o=new cd(n),a.push(o)):o=a[r],o}function i(){e=new WeakMap}return{get:t,dispose:i}}const Bv=`void main() {
gl_Position = vec4( position, 1.0 );
}`,Hv=`uniform sampler2D shadow_pass;
uniform vec2 resolution;
uniform float radius;
void main() {
const float samples = float( VSM_SAMPLES );
float mean = 0.0;
float squared_mean = 0.0;
float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );
float uvStart = samples <= 1.0 ? 0.0 : - 1.0;
for ( float i = 0.0; i < samples; i ++ ) {
float uvOffset = uvStart + i * uvStride;
#ifdef HORIZONTAL_PASS
vec2 distribution = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ).rg;
mean += distribution.x;
squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;
#else
float depth = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ).r;
mean += depth;
squared_mean += depth * depth;
#endif
}
mean = mean / samples;
squared_mean = squared_mean / samples;
float std_dev = sqrt( max( 0.0, squared_mean - mean * mean ) );
gl_FragColor = vec4( mean, std_dev, 0.0, 1.0 );
}`,zv=[new k(1,0,0),new k(-1,0,0),new k(0,1,0),new k(0,-1,0),new k(0,0,1),new k(0,0,-1)],Vv=[new k(0,-1,0),new k(0,-1,0),new k(0,0,1),new k(0,0,-1),new k(0,-1,0),new k(0,-1,0)],ud=new Rt,Dr=new k,Ul=new k;function Gv(n,e,t){let i=new jf;const s=new Le,r=new Le,a=new Et,o=new Jg,l=new jg,c={},u=t.maxTextureSize,h={[Zi]:_n,[_n]:Zi,[Yt]:Yt},d=new In({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Le},radius:{value:4}},vertexShader:Bv,fragmentShader:Hv}),f=d.clone();f.defines.HORIZONTAL_PASS=1;const p=new wt;p.setAttribute("position",new Dn(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const _=new Ht(p,d),m=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=lo;let g=this.type;this.render=function(S,A,y){if(m.enabled===!1||m.autoUpdate===!1&&m.needsUpdate===!1||S.length===0)return;this.type===$0&&($e("WebGLShadowMap: PCFSoftShadowMap has been deprecated. Using PCFShadowMap instead."),this.type=lo);const T=n.getRenderTarget(),L=n.getActiveCubeFace(),R=n.getActiveMipmapLevel(),w=n.state;w.setBlending(Ai),w.buffers.depth.getReversed()===!0?w.buffers.color.setClear(0,0,0,0):w.buffers.color.setClear(1,1,1,1),w.buffers.depth.setTest(!0),w.setScissorTest(!1);const P=g!==this.type;P&&A.traverse(function(U){U.material&&(Array.isArray(U.material)?U.material.forEach(D=>D.needsUpdate=!0):U.material.needsUpdate=!0)});for(let U=0,D=S.length;U<D;U++){const K=S[U],B=K.shadow;if(B===void 0){$e("WebGLShadowMap:",K,"has no shadow.");continue}if(B.autoUpdate===!1&&B.needsUpdate===!1)continue;s.copy(B.mapSize);const ie=B.getFrameExtents();s.multiply(ie),r.copy(B.mapSize),(s.x>u||s.y>u)&&(s.x>u&&(r.x=Math.floor(u/ie.x),s.x=r.x*ie.x,B.mapSize.x=r.x),s.y>u&&(r.y=Math.floor(u/ie.y),s.y=r.y*ie.y,B.mapSize.y=r.y));const F=n.state.buffers.depth.getReversed();if(B.camera._reversedDepth=F,B.map===null||P===!0){if(B.map!==null&&(B.map.depthTexture!==null&&(B.map.depthTexture.dispose(),B.map.depthTexture=null),B.map.dispose()),this.type===Ur){if(K.isPointLight){$e("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}B.map=new ui(s.x,s.y,{format:gs,type:Ci,minFilter:Jt,magFilter:Jt,generateMipmaps:!1}),B.map.texture.name=K.name+".shadowMap",B.map.depthTexture=new ar(s.x,s.y,Gn),B.map.depthTexture.name=K.name+".shadowMapDepth",B.map.depthTexture.format=wi,B.map.depthTexture.compareFunction=null,B.map.depthTexture.minFilter=zt,B.map.depthTexture.magFilter=zt}else K.isPointLight?(B.map=new mp(s.x),B.map.depthTexture=new fg(s.x,di)):(B.map=new ui(s.x,s.y),B.map.depthTexture=new ar(s.x,s.y,di)),B.map.depthTexture.name=K.name+".shadowMap",B.map.depthTexture.format=wi,this.type===lo?(B.map.depthTexture.compareFunction=F?yu:xu,B.map.depthTexture.minFilter=Jt,B.map.depthTexture.magFilter=Jt):(B.map.depthTexture.compareFunction=null,B.map.depthTexture.minFilter=zt,B.map.depthTexture.magFilter=zt);B.camera.updateProjectionMatrix()}const se=B.map.isWebGLCubeRenderTarget?6:1;for(let V=0;V<se;V++){if(B.map.isWebGLCubeRenderTarget)n.setRenderTarget(B.map,V),n.clear();else{V===0&&(n.setRenderTarget(B.map),n.clear());const oe=B.getViewport(V);a.set(r.x*oe.x,r.y*oe.y,r.x*oe.z,r.y*oe.w),w.viewport(a)}if(K.isPointLight){const oe=B.camera,Ae=B.matrix,me=K.distance||oe.far;me!==oe.far&&(oe.far=me,oe.updateProjectionMatrix()),Dr.setFromMatrixPosition(K.matrixWorld),oe.position.copy(Dr),Ul.copy(oe.position),Ul.add(zv[V]),oe.up.copy(Vv[V]),oe.lookAt(Ul),oe.updateMatrixWorld(),Ae.makeTranslation(-Dr.x,-Dr.y,-Dr.z),ud.multiplyMatrices(oe.projectionMatrix,oe.matrixWorldInverse),B._frustum.setFromProjectionMatrix(ud,oe.coordinateSystem,oe.reversedDepth)}else B.updateMatrices(K);i=B.getFrustum(),x(A,y,B.camera,K,this.type)}B.isPointLightShadow!==!0&&this.type===Ur&&v(B,y),B.needsUpdate=!1}g=this.type,m.needsUpdate=!1,n.setRenderTarget(T,L,R)};function v(S,A){const y=e.update(_);d.defines.VSM_SAMPLES!==S.blurSamples&&(d.defines.VSM_SAMPLES=S.blurSamples,f.defines.VSM_SAMPLES=S.blurSamples,d.needsUpdate=!0,f.needsUpdate=!0),S.mapPass===null&&(S.mapPass=new ui(s.x,s.y,{format:gs,type:Ci})),d.uniforms.shadow_pass.value=S.map.depthTexture,d.uniforms.resolution.value=S.mapSize,d.uniforms.radius.value=S.radius,n.setRenderTarget(S.mapPass),n.clear(),n.renderBufferDirect(A,null,y,d,_,null),f.uniforms.shadow_pass.value=S.mapPass.texture,f.uniforms.resolution.value=S.mapSize,f.uniforms.radius.value=S.radius,n.setRenderTarget(S.map),n.clear(),n.renderBufferDirect(A,null,y,f,_,null)}function b(S,A,y,T){let L=null;const R=y.isPointLight===!0?S.customDistanceMaterial:S.customDepthMaterial;if(R!==void 0)L=R;else if(L=y.isPointLight===!0?l:o,n.localClippingEnabled&&A.clipShadows===!0&&Array.isArray(A.clippingPlanes)&&A.clippingPlanes.length!==0||A.displacementMap&&A.displacementScale!==0||A.alphaMap&&A.alphaTest>0||A.map&&A.alphaTest>0||A.alphaToCoverage===!0){const w=L.uuid,P=A.uuid;let U=c[w];U===void 0&&(U={},c[w]=U);let D=U[P];D===void 0&&(D=L.clone(),U[P]=D,A.addEventListener("dispose",E)),L=D}if(L.visible=A.visible,L.wireframe=A.wireframe,T===Ur?L.side=A.shadowSide!==null?A.shadowSide:A.side:L.side=A.shadowSide!==null?A.shadowSide:h[A.side],L.alphaMap=A.alphaMap,L.alphaTest=A.alphaToCoverage===!0?.5:A.alphaTest,L.map=A.map,L.clipShadows=A.clipShadows,L.clippingPlanes=A.clippingPlanes,L.clipIntersection=A.clipIntersection,L.displacementMap=A.displacementMap,L.displacementScale=A.displacementScale,L.displacementBias=A.displacementBias,L.wireframeLinewidth=A.wireframeLinewidth,L.linewidth=A.linewidth,y.isPointLight===!0&&L.isMeshDistanceMaterial===!0){const w=n.properties.get(L);w.light=y}return L}function x(S,A,y,T,L){if(S.visible===!1)return;if(S.layers.test(A.layers)&&(S.isMesh||S.isLine||S.isPoints)&&(S.castShadow||S.receiveShadow&&L===Ur)&&(!S.frustumCulled||i.intersectsObject(S))){S.modelViewMatrix.multiplyMatrices(y.matrixWorldInverse,S.matrixWorld);const P=e.update(S),U=S.material;if(Array.isArray(U)){const D=P.groups;for(let K=0,B=D.length;K<B;K++){const ie=D[K],F=U[ie.materialIndex];if(F&&F.visible){const se=b(S,F,T,L);S.onBeforeShadow(n,S,A,y,P,se,ie),n.renderBufferDirect(y,null,P,se,S,ie),S.onAfterShadow(n,S,A,y,P,se,ie)}}}else if(U.visible){const D=b(S,U,T,L);S.onBeforeShadow(n,S,A,y,P,D,null),n.renderBufferDirect(y,null,P,D,S,null),S.onAfterShadow(n,S,A,y,P,D,null)}}const w=S.children;for(let P=0,U=w.length;P<U;P++)x(w[P],A,y,T,L)}function E(S){S.target.removeEventListener("dispose",E);for(const y in c){const T=c[y],L=S.target.uuid;L in T&&(T[L].dispose(),delete T[L])}}}function Wv(n,e){function t(){let N=!1;const ge=new Et;let le=null;const W=new Et(0,0,0,0);return{setMask:function(ae){le!==ae&&!N&&(n.colorMask(ae,ae,ae,ae),le=ae)},setLocked:function(ae){N=ae},setClear:function(ae,$,de,fe,Ue){Ue===!0&&(ae*=fe,$*=fe,de*=fe),ge.set(ae,$,de,fe),W.equals(ge)===!1&&(n.clearColor(ae,$,de,fe),W.copy(ge))},reset:function(){N=!1,le=null,W.set(-1,0,0,0)}}}function i(){let N=!1,ge=!1,le=null,W=null,ae=null;return{setReversed:function($){if(ge!==$){const de=e.get("EXT_clip_control");$?de.clipControlEXT(de.LOWER_LEFT_EXT,de.ZERO_TO_ONE_EXT):de.clipControlEXT(de.LOWER_LEFT_EXT,de.NEGATIVE_ONE_TO_ONE_EXT),ge=$;const fe=ae;ae=null,this.setClear(fe)}},getReversed:function(){return ge},setTest:function($){$?Z(n.DEPTH_TEST):xe(n.DEPTH_TEST)},setMask:function($){le!==$&&!N&&(n.depthMask($),le=$)},setFunc:function($){if(ge&&($=wm[$]),W!==$){switch($){case sc:n.depthFunc(n.NEVER);break;case rc:n.depthFunc(n.ALWAYS);break;case ac:n.depthFunc(n.LESS);break;case sr:n.depthFunc(n.LEQUAL);break;case oc:n.depthFunc(n.EQUAL);break;case lc:n.depthFunc(n.GEQUAL);break;case cc:n.depthFunc(n.GREATER);break;case uc:n.depthFunc(n.NOTEQUAL);break;default:n.depthFunc(n.LEQUAL)}W=$}},setLocked:function($){N=$},setClear:function($){ae!==$&&(ae=$,ge&&($=1-$),n.clearDepth($))},reset:function(){N=!1,le=null,W=null,ae=null,ge=!1}}}function s(){let N=!1,ge=null,le=null,W=null,ae=null,$=null,de=null,fe=null,Ue=null;return{setTest:function(ve){N||(ve?Z(n.STENCIL_TEST):xe(n.STENCIL_TEST))},setMask:function(ve){ge!==ve&&!N&&(n.stencilMask(ve),ge=ve)},setFunc:function(ve,qe,ct){(le!==ve||W!==qe||ae!==ct)&&(n.stencilFunc(ve,qe,ct),le=ve,W=qe,ae=ct)},setOp:function(ve,qe,ct){($!==ve||de!==qe||fe!==ct)&&(n.stencilOp(ve,qe,ct),$=ve,de=qe,fe=ct)},setLocked:function(ve){N=ve},setClear:function(ve){Ue!==ve&&(n.clearStencil(ve),Ue=ve)},reset:function(){N=!1,ge=null,le=null,W=null,ae=null,$=null,de=null,fe=null,Ue=null}}}const r=new t,a=new i,o=new s,l=new WeakMap,c=new WeakMap;let u={},h={},d={},f=new WeakMap,p=[],_=null,m=!1,g=null,v=null,b=null,x=null,E=null,S=null,A=null,y=new it(0,0,0),T=0,L=!1,R=null,w=null,P=null,U=null,D=null;const K=n.getParameter(n.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let B=!1,ie=0;const F=n.getParameter(n.VERSION);F.indexOf("WebGL")!==-1?(ie=parseFloat(/^WebGL (\d)/.exec(F)[1]),B=ie>=1):F.indexOf("OpenGL ES")!==-1&&(ie=parseFloat(/^OpenGL ES (\d)/.exec(F)[1]),B=ie>=2);let se=null,V={};const oe=n.getParameter(n.SCISSOR_BOX),Ae=n.getParameter(n.VIEWPORT),me=new Et().fromArray(oe),ue=new Et().fromArray(Ae);function z(N,ge,le,W){const ae=new Uint8Array(4),$=n.createTexture();n.bindTexture(N,$),n.texParameteri(N,n.TEXTURE_MIN_FILTER,n.NEAREST),n.texParameteri(N,n.TEXTURE_MAG_FILTER,n.NEAREST);for(let de=0;de<le;de++)N===n.TEXTURE_3D||N===n.TEXTURE_2D_ARRAY?n.texImage3D(ge,0,n.RGBA,1,1,W,0,n.RGBA,n.UNSIGNED_BYTE,ae):n.texImage2D(ge+de,0,n.RGBA,1,1,0,n.RGBA,n.UNSIGNED_BYTE,ae);return $}const ee={};ee[n.TEXTURE_2D]=z(n.TEXTURE_2D,n.TEXTURE_2D,1),ee[n.TEXTURE_CUBE_MAP]=z(n.TEXTURE_CUBE_MAP,n.TEXTURE_CUBE_MAP_POSITIVE_X,6),ee[n.TEXTURE_2D_ARRAY]=z(n.TEXTURE_2D_ARRAY,n.TEXTURE_2D_ARRAY,1,1),ee[n.TEXTURE_3D]=z(n.TEXTURE_3D,n.TEXTURE_3D,1,1),r.setClear(0,0,0,1),a.setClear(1),o.setClear(0),Z(n.DEPTH_TEST),a.setFunc(sr),Pe(!1),st(Ju),Z(n.CULL_FACE),Ke(Ai);function Z(N){u[N]!==!0&&(n.enable(N),u[N]=!0)}function xe(N){u[N]!==!1&&(n.disable(N),u[N]=!1)}function be(N,ge){return d[N]!==ge?(n.bindFramebuffer(N,ge),d[N]=ge,N===n.DRAW_FRAMEBUFFER&&(d[n.FRAMEBUFFER]=ge),N===n.FRAMEBUFFER&&(d[n.DRAW_FRAMEBUFFER]=ge),!0):!1}function Se(N,ge){let le=p,W=!1;if(N){le=f.get(ge),le===void 0&&(le=[],f.set(ge,le));const ae=N.textures;if(le.length!==ae.length||le[0]!==n.COLOR_ATTACHMENT0){for(let $=0,de=ae.length;$<de;$++)le[$]=n.COLOR_ATTACHMENT0+$;le.length=ae.length,W=!0}}else le[0]!==n.BACK&&(le[0]=n.BACK,W=!0);W&&n.drawBuffers(le)}function Oe(N){return _!==N?(n.useProgram(N),_=N,!0):!1}const Ge={[ls]:n.FUNC_ADD,[J0]:n.FUNC_SUBTRACT,[j0]:n.FUNC_REVERSE_SUBTRACT};Ge[Q0]=n.MIN,Ge[em]=n.MAX;const Ye={[tm]:n.ZERO,[nm]:n.ONE,[im]:n.SRC_COLOR,[nc]:n.SRC_ALPHA,[cm]:n.SRC_ALPHA_SATURATE,[om]:n.DST_COLOR,[rm]:n.DST_ALPHA,[sm]:n.ONE_MINUS_SRC_COLOR,[ic]:n.ONE_MINUS_SRC_ALPHA,[lm]:n.ONE_MINUS_DST_COLOR,[am]:n.ONE_MINUS_DST_ALPHA,[um]:n.CONSTANT_COLOR,[hm]:n.ONE_MINUS_CONSTANT_COLOR,[dm]:n.CONSTANT_ALPHA,[fm]:n.ONE_MINUS_CONSTANT_ALPHA};function Ke(N,ge,le,W,ae,$,de,fe,Ue,ve){if(N===Ai){m===!0&&(xe(n.BLEND),m=!1);return}if(m===!1&&(Z(n.BLEND),m=!0),N!==Z0){if(N!==g||ve!==L){if((v!==ls||E!==ls)&&(n.blendEquation(n.FUNC_ADD),v=ls,E=ls),ve)switch(N){case er:n.blendFuncSeparate(n.ONE,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA);break;case ju:n.blendFunc(n.ONE,n.ONE);break;case Qu:n.blendFuncSeparate(n.ZERO,n.ONE_MINUS_SRC_COLOR,n.ZERO,n.ONE);break;case eh:n.blendFuncSeparate(n.DST_COLOR,n.ONE_MINUS_SRC_ALPHA,n.ZERO,n.ONE);break;default:ut("WebGLState: Invalid blending: ",N);break}else switch(N){case er:n.blendFuncSeparate(n.SRC_ALPHA,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA);break;case ju:n.blendFuncSeparate(n.SRC_ALPHA,n.ONE,n.ONE,n.ONE);break;case Qu:ut("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case eh:ut("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:ut("WebGLState: Invalid blending: ",N);break}b=null,x=null,S=null,A=null,y.set(0,0,0),T=0,g=N,L=ve}return}ae=ae||ge,$=$||le,de=de||W,(ge!==v||ae!==E)&&(n.blendEquationSeparate(Ge[ge],Ge[ae]),v=ge,E=ae),(le!==b||W!==x||$!==S||de!==A)&&(n.blendFuncSeparate(Ye[le],Ye[W],Ye[$],Ye[de]),b=le,x=W,S=$,A=de),(fe.equals(y)===!1||Ue!==T)&&(n.blendColor(fe.r,fe.g,fe.b,Ue),y.copy(fe),T=Ue),g=N,L=!1}function Be(N,ge){N.side===Yt?xe(n.CULL_FACE):Z(n.CULL_FACE);let le=N.side===_n;ge&&(le=!le),Pe(le),N.blending===er&&N.transparent===!1?Ke(Ai):Ke(N.blending,N.blendEquation,N.blendSrc,N.blendDst,N.blendEquationAlpha,N.blendSrcAlpha,N.blendDstAlpha,N.blendColor,N.blendAlpha,N.premultipliedAlpha),a.setFunc(N.depthFunc),a.setTest(N.depthTest),a.setMask(N.depthWrite),r.setMask(N.colorWrite);const W=N.stencilWrite;o.setTest(W),W&&(o.setMask(N.stencilWriteMask),o.setFunc(N.stencilFunc,N.stencilRef,N.stencilFuncMask),o.setOp(N.stencilFail,N.stencilZFail,N.stencilZPass)),gt(N.polygonOffset,N.polygonOffsetFactor,N.polygonOffsetUnits),N.alphaToCoverage===!0?Z(n.SAMPLE_ALPHA_TO_COVERAGE):xe(n.SAMPLE_ALPHA_TO_COVERAGE)}function Pe(N){R!==N&&(N?n.frontFace(n.CW):n.frontFace(n.CCW),R=N)}function st(N){N!==K0?(Z(n.CULL_FACE),N!==w&&(N===Ju?n.cullFace(n.BACK):N===q0?n.cullFace(n.FRONT):n.cullFace(n.FRONT_AND_BACK))):xe(n.CULL_FACE),w=N}function mt(N){N!==P&&(B&&n.lineWidth(N),P=N)}function gt(N,ge,le){N?(Z(n.POLYGON_OFFSET_FILL),(U!==ge||D!==le)&&(U=ge,D=le,a.getReversed()&&(ge=-ge),n.polygonOffset(ge,le))):xe(n.POLYGON_OFFSET_FILL)}function ft(N){N?Z(n.SCISSOR_TEST):xe(n.SCISSOR_TEST)}function _t(N){N===void 0&&(N=n.TEXTURE0+K-1),se!==N&&(n.activeTexture(N),se=N)}function G(N,ge,le){le===void 0&&(se===null?le=n.TEXTURE0+K-1:le=se);let W=V[le];W===void 0&&(W={type:void 0,texture:void 0},V[le]=W),(W.type!==N||W.texture!==ge)&&(se!==le&&(n.activeTexture(le),se=le),n.bindTexture(N,ge||ee[N]),W.type=N,W.texture=ge)}function nt(){const N=V[se];N!==void 0&&N.type!==void 0&&(n.bindTexture(N.type,null),N.type=void 0,N.texture=void 0)}function lt(){try{n.compressedTexImage2D(...arguments)}catch(N){ut("WebGLState:",N)}}function I(){try{n.compressedTexImage3D(...arguments)}catch(N){ut("WebGLState:",N)}}function M(){try{n.texSubImage2D(...arguments)}catch(N){ut("WebGLState:",N)}}function q(){try{n.texSubImage3D(...arguments)}catch(N){ut("WebGLState:",N)}}function te(){try{n.compressedTexSubImage2D(...arguments)}catch(N){ut("WebGLState:",N)}}function Q(){try{n.compressedTexSubImage3D(...arguments)}catch(N){ut("WebGLState:",N)}}function he(){try{n.texStorage2D(...arguments)}catch(N){ut("WebGLState:",N)}}function Te(){try{n.texStorage3D(...arguments)}catch(N){ut("WebGLState:",N)}}function ce(){try{n.texImage2D(...arguments)}catch(N){ut("WebGLState:",N)}}function pe(){try{n.texImage3D(...arguments)}catch(N){ut("WebGLState:",N)}}function Ee(N){return h[N]!==void 0?h[N]:n.getParameter(N)}function We(N,ge){h[N]!==ge&&(n.pixelStorei(N,ge),h[N]=ge)}function H(N){me.equals(N)===!1&&(n.scissor(N.x,N.y,N.z,N.w),me.copy(N))}function ne(N){ue.equals(N)===!1&&(n.viewport(N.x,N.y,N.z,N.w),ue.copy(N))}function O(N,ge){let le=c.get(ge);le===void 0&&(le=new WeakMap,c.set(ge,le));let W=le.get(N);W===void 0&&(W=n.getUniformBlockIndex(ge,N.name),le.set(N,W))}function De(N,ge){const W=c.get(ge).get(N);l.get(ge)!==W&&(n.uniformBlockBinding(ge,W,N.__bindingPointIndex),l.set(ge,W))}function ye(){n.disable(n.BLEND),n.disable(n.CULL_FACE),n.disable(n.DEPTH_TEST),n.disable(n.POLYGON_OFFSET_FILL),n.disable(n.SCISSOR_TEST),n.disable(n.STENCIL_TEST),n.disable(n.SAMPLE_ALPHA_TO_COVERAGE),n.blendEquation(n.FUNC_ADD),n.blendFunc(n.ONE,n.ZERO),n.blendFuncSeparate(n.ONE,n.ZERO,n.ONE,n.ZERO),n.blendColor(0,0,0,0),n.colorMask(!0,!0,!0,!0),n.clearColor(0,0,0,0),n.depthMask(!0),n.depthFunc(n.LESS),a.setReversed(!1),n.clearDepth(1),n.stencilMask(4294967295),n.stencilFunc(n.ALWAYS,0,4294967295),n.stencilOp(n.KEEP,n.KEEP,n.KEEP),n.clearStencil(0),n.cullFace(n.BACK),n.frontFace(n.CCW),n.polygonOffset(0,0),n.activeTexture(n.TEXTURE0),n.bindFramebuffer(n.FRAMEBUFFER,null),n.bindFramebuffer(n.DRAW_FRAMEBUFFER,null),n.bindFramebuffer(n.READ_FRAMEBUFFER,null),n.useProgram(null),n.lineWidth(1),n.scissor(0,0,n.canvas.width,n.canvas.height),n.viewport(0,0,n.canvas.width,n.canvas.height),n.pixelStorei(n.PACK_ALIGNMENT,4),n.pixelStorei(n.UNPACK_ALIGNMENT,4),n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,!1),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),n.pixelStorei(n.UNPACK_COLORSPACE_CONVERSION_WEBGL,n.BROWSER_DEFAULT_WEBGL),n.pixelStorei(n.PACK_ROW_LENGTH,0),n.pixelStorei(n.PACK_SKIP_PIXELS,0),n.pixelStorei(n.PACK_SKIP_ROWS,0),n.pixelStorei(n.UNPACK_ROW_LENGTH,0),n.pixelStorei(n.UNPACK_IMAGE_HEIGHT,0),n.pixelStorei(n.UNPACK_SKIP_PIXELS,0),n.pixelStorei(n.UNPACK_SKIP_ROWS,0),n.pixelStorei(n.UNPACK_SKIP_IMAGES,0),u={},h={},se=null,V={},d={},f=new WeakMap,p=[],_=null,m=!1,g=null,v=null,b=null,x=null,E=null,S=null,A=null,y=new it(0,0,0),T=0,L=!1,R=null,w=null,P=null,U=null,D=null,me.set(0,0,n.canvas.width,n.canvas.height),ue.set(0,0,n.canvas.width,n.canvas.height),r.reset(),a.reset(),o.reset()}return{buffers:{color:r,depth:a,stencil:o},enable:Z,disable:xe,bindFramebuffer:be,drawBuffers:Se,useProgram:Oe,setBlending:Ke,setMaterial:Be,setFlipSided:Pe,setCullFace:st,setLineWidth:mt,setPolygonOffset:gt,setScissorTest:ft,activeTexture:_t,bindTexture:G,unbindTexture:nt,compressedTexImage2D:lt,compressedTexImage3D:I,texImage2D:ce,texImage3D:pe,pixelStorei:We,getParameter:Ee,updateUBOMapping:O,uniformBlockBinding:De,texStorage2D:he,texStorage3D:Te,texSubImage2D:M,texSubImage3D:q,compressedTexSubImage2D:te,compressedTexSubImage3D:Q,scissor:H,viewport:ne,reset:ye}}function Xv(n,e,t,i,s,r,a){const o=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,l=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),c=new Le,u=new WeakMap,h=new Set;let d;const f=new WeakMap;let p=!1;try{p=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function _(I,M){return p?new OffscreenCanvas(I,M):Ao("canvas")}function m(I,M,q){let te=1;const Q=lt(I);if((Q.width>q||Q.height>q)&&(te=q/Math.max(Q.width,Q.height)),te<1)if(typeof HTMLImageElement<"u"&&I instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&I instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&I instanceof ImageBitmap||typeof VideoFrame<"u"&&I instanceof VideoFrame){const he=Math.floor(te*Q.width),Te=Math.floor(te*Q.height);d===void 0&&(d=_(he,Te));const ce=M?_(he,Te):d;return ce.width=he,ce.height=Te,ce.getContext("2d").drawImage(I,0,0,he,Te),$e("WebGLRenderer: Texture has been resized from ("+Q.width+"x"+Q.height+") to ("+he+"x"+Te+")."),ce}else return"data"in I&&$e("WebGLRenderer: Image in DataTexture is too big ("+Q.width+"x"+Q.height+")."),I;return I}function g(I){return I.generateMipmaps}function v(I){n.generateMipmap(I)}function b(I){return I.isWebGLCubeRenderTarget?n.TEXTURE_CUBE_MAP:I.isWebGL3DRenderTarget?n.TEXTURE_3D:I.isWebGLArrayRenderTarget||I.isCompressedArrayTexture?n.TEXTURE_2D_ARRAY:n.TEXTURE_2D}function x(I,M,q,te,Q,he=!1){if(I!==null){if(n[I]!==void 0)return n[I];$e("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+I+"'")}let Te;te&&(Te=e.get("EXT_texture_norm16"),Te||$e("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension"));let ce=M;if(M===n.RED&&(q===n.FLOAT&&(ce=n.R32F),q===n.HALF_FLOAT&&(ce=n.R16F),q===n.UNSIGNED_BYTE&&(ce=n.R8),q===n.UNSIGNED_SHORT&&Te&&(ce=Te.R16_EXT),q===n.SHORT&&Te&&(ce=Te.R16_SNORM_EXT)),M===n.RED_INTEGER&&(q===n.UNSIGNED_BYTE&&(ce=n.R8UI),q===n.UNSIGNED_SHORT&&(ce=n.R16UI),q===n.UNSIGNED_INT&&(ce=n.R32UI),q===n.BYTE&&(ce=n.R8I),q===n.SHORT&&(ce=n.R16I),q===n.INT&&(ce=n.R32I)),M===n.RG&&(q===n.FLOAT&&(ce=n.RG32F),q===n.HALF_FLOAT&&(ce=n.RG16F),q===n.UNSIGNED_BYTE&&(ce=n.RG8),q===n.UNSIGNED_SHORT&&Te&&(ce=Te.RG16_EXT),q===n.SHORT&&Te&&(ce=Te.RG16_SNORM_EXT)),M===n.RG_INTEGER&&(q===n.UNSIGNED_BYTE&&(ce=n.RG8UI),q===n.UNSIGNED_SHORT&&(ce=n.RG16UI),q===n.UNSIGNED_INT&&(ce=n.RG32UI),q===n.BYTE&&(ce=n.RG8I),q===n.SHORT&&(ce=n.RG16I),q===n.INT&&(ce=n.RG32I)),M===n.RGB_INTEGER&&(q===n.UNSIGNED_BYTE&&(ce=n.RGB8UI),q===n.UNSIGNED_SHORT&&(ce=n.RGB16UI),q===n.UNSIGNED_INT&&(ce=n.RGB32UI),q===n.BYTE&&(ce=n.RGB8I),q===n.SHORT&&(ce=n.RGB16I),q===n.INT&&(ce=n.RGB32I)),M===n.RGBA_INTEGER&&(q===n.UNSIGNED_BYTE&&(ce=n.RGBA8UI),q===n.UNSIGNED_SHORT&&(ce=n.RGBA16UI),q===n.UNSIGNED_INT&&(ce=n.RGBA32UI),q===n.BYTE&&(ce=n.RGBA8I),q===n.SHORT&&(ce=n.RGBA16I),q===n.INT&&(ce=n.RGBA32I)),M===n.RGB&&(q===n.UNSIGNED_SHORT&&Te&&(ce=Te.RGB16_EXT),q===n.SHORT&&Te&&(ce=Te.RGB16_SNORM_EXT),q===n.UNSIGNED_INT_5_9_9_9_REV&&(ce=n.RGB9_E5),q===n.UNSIGNED_INT_10F_11F_11F_REV&&(ce=n.R11F_G11F_B10F)),M===n.RGBA){const pe=he?bo:at.getTransfer(Q);q===n.FLOAT&&(ce=n.RGBA32F),q===n.HALF_FLOAT&&(ce=n.RGBA16F),q===n.UNSIGNED_BYTE&&(ce=pe===xt?n.SRGB8_ALPHA8:n.RGBA8),q===n.UNSIGNED_SHORT&&Te&&(ce=Te.RGBA16_EXT),q===n.SHORT&&Te&&(ce=Te.RGBA16_SNORM_EXT),q===n.UNSIGNED_SHORT_4_4_4_4&&(ce=n.RGBA4),q===n.UNSIGNED_SHORT_5_5_5_1&&(ce=n.RGB5_A1)}return(ce===n.R16F||ce===n.R32F||ce===n.RG16F||ce===n.RG32F||ce===n.RGBA16F||ce===n.RGBA32F)&&e.get("EXT_color_buffer_float"),ce}function E(I,M){let q;return I?M===null||M===di||M===Kr?q=n.DEPTH24_STENCIL8:M===Gn?q=n.DEPTH32F_STENCIL8:M===Yr&&(q=n.DEPTH24_STENCIL8,$e("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):M===null||M===di||M===Kr?q=n.DEPTH_COMPONENT24:M===Gn?q=n.DEPTH_COMPONENT32F:M===Yr&&(q=n.DEPTH_COMPONENT16),q}function S(I,M){return g(I)===!0||I.isFramebufferTexture&&I.minFilter!==zt&&I.minFilter!==Jt?Math.log2(Math.max(M.width,M.height))+1:I.mipmaps!==void 0&&I.mipmaps.length>0?I.mipmaps.length:I.isCompressedTexture&&Array.isArray(I.image)?M.mipmaps.length:1}function A(I){const M=I.target;M.removeEventListener("dispose",A),T(M),M.isVideoTexture&&u.delete(M),M.isHTMLTexture&&h.delete(M)}function y(I){const M=I.target;M.removeEventListener("dispose",y),R(M)}function T(I){const M=i.get(I);if(M.__webglInit===void 0)return;const q=I.source,te=f.get(q);if(te){const Q=te[M.__cacheKey];Q.usedTimes--,Q.usedTimes===0&&L(I),Object.keys(te).length===0&&f.delete(q)}i.remove(I)}function L(I){const M=i.get(I);n.deleteTexture(M.__webglTexture);const q=I.source,te=f.get(q);delete te[M.__cacheKey],a.memory.textures--}function R(I){const M=i.get(I);if(I.depthTexture&&(I.depthTexture.dispose(),i.remove(I.depthTexture)),I.isWebGLCubeRenderTarget)for(let te=0;te<6;te++){if(Array.isArray(M.__webglFramebuffer[te]))for(let Q=0;Q<M.__webglFramebuffer[te].length;Q++)n.deleteFramebuffer(M.__webglFramebuffer[te][Q]);else n.deleteFramebuffer(M.__webglFramebuffer[te]);M.__webglDepthbuffer&&n.deleteRenderbuffer(M.__webglDepthbuffer[te])}else{if(Array.isArray(M.__webglFramebuffer))for(let te=0;te<M.__webglFramebuffer.length;te++)n.deleteFramebuffer(M.__webglFramebuffer[te]);else n.deleteFramebuffer(M.__webglFramebuffer);if(M.__webglDepthbuffer&&n.deleteRenderbuffer(M.__webglDepthbuffer),M.__webglMultisampledFramebuffer&&n.deleteFramebuffer(M.__webglMultisampledFramebuffer),M.__webglColorRenderbuffer)for(let te=0;te<M.__webglColorRenderbuffer.length;te++)M.__webglColorRenderbuffer[te]&&n.deleteRenderbuffer(M.__webglColorRenderbuffer[te]);M.__webglDepthRenderbuffer&&n.deleteRenderbuffer(M.__webglDepthRenderbuffer)}const q=I.textures;for(let te=0,Q=q.length;te<Q;te++){const he=i.get(q[te]);he.__webglTexture&&(n.deleteTexture(he.__webglTexture),a.memory.textures--),i.remove(q[te])}i.remove(I)}let w=0;function P(){w=0}function U(){return w}function D(I){w=I}function K(){const I=w;return I>=s.maxTextures&&$e("WebGLTextures: Trying to use "+I+" texture units while this GPU supports only "+s.maxTextures),w+=1,I}function B(I){const M=[];return M.push(I.wrapS),M.push(I.wrapT),M.push(I.wrapR||0),M.push(I.magFilter),M.push(I.minFilter),M.push(I.anisotropy),M.push(I.internalFormat),M.push(I.format),M.push(I.type),M.push(I.generateMipmaps),M.push(I.premultiplyAlpha),M.push(I.flipY),M.push(I.unpackAlignment),M.push(I.colorSpace),M.join()}function ie(I,M){const q=i.get(I);if(I.isVideoTexture&&G(I),I.isRenderTargetTexture===!1&&I.isExternalTexture!==!0&&I.version>0&&q.__version!==I.version){const te=I.image;if(te===null)$e("WebGLRenderer: Texture marked for update but no image data found.");else if(te.complete===!1)$e("WebGLRenderer: Texture marked for update but image is incomplete");else{xe(q,I,M);return}}else I.isExternalTexture&&(q.__webglTexture=I.sourceTexture?I.sourceTexture:null);t.bindTexture(n.TEXTURE_2D,q.__webglTexture,n.TEXTURE0+M)}function F(I,M){const q=i.get(I);if(I.isRenderTargetTexture===!1&&I.version>0&&q.__version!==I.version){xe(q,I,M);return}else I.isExternalTexture&&(q.__webglTexture=I.sourceTexture?I.sourceTexture:null);t.bindTexture(n.TEXTURE_2D_ARRAY,q.__webglTexture,n.TEXTURE0+M)}function se(I,M){const q=i.get(I);if(I.isRenderTargetTexture===!1&&I.version>0&&q.__version!==I.version){xe(q,I,M);return}t.bindTexture(n.TEXTURE_3D,q.__webglTexture,n.TEXTURE0+M)}function V(I,M){const q=i.get(I);if(I.isCubeDepthTexture!==!0&&I.version>0&&q.__version!==I.version){be(q,I,M);return}t.bindTexture(n.TEXTURE_CUBE_MAP,q.__webglTexture,n.TEXTURE0+M)}const oe={[hc]:n.REPEAT,[Si]:n.CLAMP_TO_EDGE,[dc]:n.MIRRORED_REPEAT},Ae={[zt]:n.NEAREST,[gm]:n.NEAREST_MIPMAP_NEAREST,[pa]:n.NEAREST_MIPMAP_LINEAR,[Jt]:n.LINEAR,[el]:n.LINEAR_MIPMAP_NEAREST,[Yi]:n.LINEAR_MIPMAP_LINEAR},me={[ym]:n.NEVER,[Am]:n.ALWAYS,[vm]:n.LESS,[xu]:n.LEQUAL,[Sm]:n.EQUAL,[yu]:n.GEQUAL,[bm]:n.GREATER,[Mm]:n.NOTEQUAL};function ue(I,M){if(M.type===Gn&&e.has("OES_texture_float_linear")===!1&&(M.magFilter===Jt||M.magFilter===el||M.magFilter===pa||M.magFilter===Yi||M.minFilter===Jt||M.minFilter===el||M.minFilter===pa||M.minFilter===Yi)&&$e("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),n.texParameteri(I,n.TEXTURE_WRAP_S,oe[M.wrapS]),n.texParameteri(I,n.TEXTURE_WRAP_T,oe[M.wrapT]),(I===n.TEXTURE_3D||I===n.TEXTURE_2D_ARRAY)&&n.texParameteri(I,n.TEXTURE_WRAP_R,oe[M.wrapR]),n.texParameteri(I,n.TEXTURE_MAG_FILTER,Ae[M.magFilter]),n.texParameteri(I,n.TEXTURE_MIN_FILTER,Ae[M.minFilter]),M.compareFunction&&(n.texParameteri(I,n.TEXTURE_COMPARE_MODE,n.COMPARE_REF_TO_TEXTURE),n.texParameteri(I,n.TEXTURE_COMPARE_FUNC,me[M.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(M.magFilter===zt||M.minFilter!==pa&&M.minFilter!==Yi||M.type===Gn&&e.has("OES_texture_float_linear")===!1)return;if(M.anisotropy>1||i.get(M).__currentAnisotropy){const q=e.get("EXT_texture_filter_anisotropic");n.texParameterf(I,q.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(M.anisotropy,s.getMaxAnisotropy())),i.get(M).__currentAnisotropy=M.anisotropy}}}function z(I,M){let q=!1;I.__webglInit===void 0&&(I.__webglInit=!0,M.addEventListener("dispose",A));const te=M.source;let Q=f.get(te);Q===void 0&&(Q={},f.set(te,Q));const he=B(M);if(he!==I.__cacheKey){Q[he]===void 0&&(Q[he]={texture:n.createTexture(),usedTimes:0},a.memory.textures++,q=!0),Q[he].usedTimes++;const Te=Q[I.__cacheKey];Te!==void 0&&(Q[I.__cacheKey].usedTimes--,Te.usedTimes===0&&L(M)),I.__cacheKey=he,I.__webglTexture=Q[he].texture}return q}function ee(I,M,q){return Math.floor(Math.floor(I/q)/M)}function Z(I,M,q,te){const he=I.updateRanges;if(he.length===0)t.texSubImage2D(n.TEXTURE_2D,0,0,0,M.width,M.height,q,te,M.data);else{he.sort((We,H)=>We.start-H.start);let Te=0;for(let We=1;We<he.length;We++){const H=he[Te],ne=he[We],O=H.start+H.count,De=ee(ne.start,M.width,4),ye=ee(H.start,M.width,4);ne.start<=O+1&&De===ye&&ee(ne.start+ne.count-1,M.width,4)===De?H.count=Math.max(H.count,ne.start+ne.count-H.start):(++Te,he[Te]=ne)}he.length=Te+1;const ce=t.getParameter(n.UNPACK_ROW_LENGTH),pe=t.getParameter(n.UNPACK_SKIP_PIXELS),Ee=t.getParameter(n.UNPACK_SKIP_ROWS);t.pixelStorei(n.UNPACK_ROW_LENGTH,M.width);for(let We=0,H=he.length;We<H;We++){const ne=he[We],O=Math.floor(ne.start/4),De=Math.ceil(ne.count/4),ye=O%M.width,N=Math.floor(O/M.width),ge=De,le=1;t.pixelStorei(n.UNPACK_SKIP_PIXELS,ye),t.pixelStorei(n.UNPACK_SKIP_ROWS,N),t.texSubImage2D(n.TEXTURE_2D,0,ye,N,ge,le,q,te,M.data)}I.clearUpdateRanges(),t.pixelStorei(n.UNPACK_ROW_LENGTH,ce),t.pixelStorei(n.UNPACK_SKIP_PIXELS,pe),t.pixelStorei(n.UNPACK_SKIP_ROWS,Ee)}}function xe(I,M,q){let te=n.TEXTURE_2D;(M.isDataArrayTexture||M.isCompressedArrayTexture)&&(te=n.TEXTURE_2D_ARRAY),M.isData3DTexture&&(te=n.TEXTURE_3D);const Q=z(I,M),he=M.source;t.bindTexture(te,I.__webglTexture,n.TEXTURE0+q);const Te=i.get(he);if(he.version!==Te.__version||Q===!0){if(t.activeTexture(n.TEXTURE0+q),(typeof ImageBitmap<"u"&&M.image instanceof ImageBitmap)===!1){const le=at.getPrimaries(at.workingColorSpace),W=M.colorSpace===vi?null:at.getPrimaries(M.colorSpace),ae=M.colorSpace===vi||le===W?n.NONE:n.BROWSER_DEFAULT_WEBGL;t.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,M.flipY),t.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,M.premultiplyAlpha),t.pixelStorei(n.UNPACK_COLORSPACE_CONVERSION_WEBGL,ae)}t.pixelStorei(n.UNPACK_ALIGNMENT,M.unpackAlignment);let pe=m(M.image,!1,s.maxTextureSize);pe=nt(M,pe);const Ee=r.convert(M.format,M.colorSpace),We=r.convert(M.type);let H=x(M.internalFormat,Ee,We,M.normalized,M.colorSpace,M.isVideoTexture);ue(te,M);let ne;const O=M.mipmaps,De=M.isVideoTexture!==!0,ye=Te.__version===void 0||Q===!0,N=he.dataReady,ge=S(M,pe);if(M.isDepthTexture)H=E(M.format===ds,M.type),ye&&(De?t.texStorage2D(n.TEXTURE_2D,1,H,pe.width,pe.height):t.texImage2D(n.TEXTURE_2D,0,H,pe.width,pe.height,0,Ee,We,null));else if(M.isDataTexture)if(O.length>0){De&&ye&&t.texStorage2D(n.TEXTURE_2D,ge,H,O[0].width,O[0].height);for(let le=0,W=O.length;le<W;le++)ne=O[le],De?N&&t.texSubImage2D(n.TEXTURE_2D,le,0,0,ne.width,ne.height,Ee,We,ne.data):t.texImage2D(n.TEXTURE_2D,le,H,ne.width,ne.height,0,Ee,We,ne.data);M.generateMipmaps=!1}else De?(ye&&t.texStorage2D(n.TEXTURE_2D,ge,H,pe.width,pe.height),N&&Z(M,pe,Ee,We)):t.texImage2D(n.TEXTURE_2D,0,H,pe.width,pe.height,0,Ee,We,pe.data);else if(M.isCompressedTexture)if(M.isCompressedArrayTexture){De&&ye&&t.texStorage3D(n.TEXTURE_2D_ARRAY,ge,H,O[0].width,O[0].height,pe.depth);for(let le=0,W=O.length;le<W;le++)if(ne=O[le],M.format!==Ln)if(Ee!==null)if(De){if(N)if(M.layerUpdates.size>0){const ae=zh(ne.width,ne.height,M.format,M.type);for(const $ of M.layerUpdates){const de=ne.data.subarray($*ae/ne.data.BYTES_PER_ELEMENT,($+1)*ae/ne.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(n.TEXTURE_2D_ARRAY,le,0,0,$,ne.width,ne.height,1,Ee,de)}M.clearLayerUpdates()}else t.compressedTexSubImage3D(n.TEXTURE_2D_ARRAY,le,0,0,0,ne.width,ne.height,pe.depth,Ee,ne.data)}else t.compressedTexImage3D(n.TEXTURE_2D_ARRAY,le,H,ne.width,ne.height,pe.depth,0,ne.data,0,0);else $e("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else De?N&&t.texSubImage3D(n.TEXTURE_2D_ARRAY,le,0,0,0,ne.width,ne.height,pe.depth,Ee,We,ne.data):t.texImage3D(n.TEXTURE_2D_ARRAY,le,H,ne.width,ne.height,pe.depth,0,Ee,We,ne.data)}else{De&&ye&&t.texStorage2D(n.TEXTURE_2D,ge,H,O[0].width,O[0].height);for(let le=0,W=O.length;le<W;le++)ne=O[le],M.format!==Ln?Ee!==null?De?N&&t.compressedTexSubImage2D(n.TEXTURE_2D,le,0,0,ne.width,ne.height,Ee,ne.data):t.compressedTexImage2D(n.TEXTURE_2D,le,H,ne.width,ne.height,0,ne.data):$e("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):De?N&&t.texSubImage2D(n.TEXTURE_2D,le,0,0,ne.width,ne.height,Ee,We,ne.data):t.texImage2D(n.TEXTURE_2D,le,H,ne.width,ne.height,0,Ee,We,ne.data)}else if(M.isDataArrayTexture)if(De){if(ye&&t.texStorage3D(n.TEXTURE_2D_ARRAY,ge,H,pe.width,pe.height,pe.depth),N)if(M.layerUpdates.size>0){const le=zh(pe.width,pe.height,M.format,M.type);for(const W of M.layerUpdates){const ae=pe.data.subarray(W*le/pe.data.BYTES_PER_ELEMENT,(W+1)*le/pe.data.BYTES_PER_ELEMENT);t.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,W,pe.width,pe.height,1,Ee,We,ae)}M.clearLayerUpdates()}else t.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,0,pe.width,pe.height,pe.depth,Ee,We,pe.data)}else t.texImage3D(n.TEXTURE_2D_ARRAY,0,H,pe.width,pe.height,pe.depth,0,Ee,We,pe.data);else if(M.isData3DTexture)De?(ye&&t.texStorage3D(n.TEXTURE_3D,ge,H,pe.width,pe.height,pe.depth),N&&t.texSubImage3D(n.TEXTURE_3D,0,0,0,0,pe.width,pe.height,pe.depth,Ee,We,pe.data)):t.texImage3D(n.TEXTURE_3D,0,H,pe.width,pe.height,pe.depth,0,Ee,We,pe.data);else if(M.isFramebufferTexture){if(ye)if(De)t.texStorage2D(n.TEXTURE_2D,ge,H,pe.width,pe.height);else{let le=pe.width,W=pe.height;for(let ae=0;ae<ge;ae++)t.texImage2D(n.TEXTURE_2D,ae,H,le,W,0,Ee,We,null),le>>=1,W>>=1}}else if(M.isHTMLTexture){if("texElementImage2D"in n){const le=n.canvas;if(le.hasAttribute("layoutsubtree")||le.setAttribute("layoutsubtree","true"),pe.parentNode!==le){le.appendChild(pe),h.add(M),le.onpaint=W=>{const ae=W.changedElements;for(const $ of h)ae.includes($.image)&&($.needsUpdate=!0)},le.requestPaint();return}if(n.texElementImage2D.length===3)n.texElementImage2D(n.TEXTURE_2D,n.RGBA8,pe);else{const ae=n.RGBA,$=n.RGBA,de=n.UNSIGNED_BYTE;n.texElementImage2D(n.TEXTURE_2D,0,ae,$,de,pe)}n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,n.LINEAR),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,n.CLAMP_TO_EDGE),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,n.CLAMP_TO_EDGE)}}else if(O.length>0){if(De&&ye){const le=lt(O[0]);t.texStorage2D(n.TEXTURE_2D,ge,H,le.width,le.height)}for(let le=0,W=O.length;le<W;le++)ne=O[le],De?N&&t.texSubImage2D(n.TEXTURE_2D,le,0,0,Ee,We,ne):t.texImage2D(n.TEXTURE_2D,le,H,Ee,We,ne);M.generateMipmaps=!1}else if(De){if(ye){const le=lt(pe);t.texStorage2D(n.TEXTURE_2D,ge,H,le.width,le.height)}N&&t.texSubImage2D(n.TEXTURE_2D,0,0,0,Ee,We,pe)}else t.texImage2D(n.TEXTURE_2D,0,H,Ee,We,pe);g(M)&&v(te),Te.__version=he.version,M.onUpdate&&M.onUpdate(M)}I.__version=M.version}function be(I,M,q){if(M.image.length!==6)return;const te=z(I,M),Q=M.source;t.bindTexture(n.TEXTURE_CUBE_MAP,I.__webglTexture,n.TEXTURE0+q);const he=i.get(Q);if(Q.version!==he.__version||te===!0){t.activeTexture(n.TEXTURE0+q);const Te=at.getPrimaries(at.workingColorSpace),ce=M.colorSpace===vi?null:at.getPrimaries(M.colorSpace),pe=M.colorSpace===vi||Te===ce?n.NONE:n.BROWSER_DEFAULT_WEBGL;t.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,M.flipY),t.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,M.premultiplyAlpha),t.pixelStorei(n.UNPACK_ALIGNMENT,M.unpackAlignment),t.pixelStorei(n.UNPACK_COLORSPACE_CONVERSION_WEBGL,pe);const Ee=M.isCompressedTexture||M.image[0].isCompressedTexture,We=M.image[0]&&M.image[0].isDataTexture,H=[];for(let $=0;$<6;$++)!Ee&&!We?H[$]=m(M.image[$],!0,s.maxCubemapSize):H[$]=We?M.image[$].image:M.image[$],H[$]=nt(M,H[$]);const ne=H[0],O=r.convert(M.format,M.colorSpace),De=r.convert(M.type),ye=x(M.internalFormat,O,De,M.normalized,M.colorSpace),N=M.isVideoTexture!==!0,ge=he.__version===void 0||te===!0,le=Q.dataReady;let W=S(M,ne);ue(n.TEXTURE_CUBE_MAP,M);let ae;if(Ee){N&&ge&&t.texStorage2D(n.TEXTURE_CUBE_MAP,W,ye,ne.width,ne.height);for(let $=0;$<6;$++){ae=H[$].mipmaps;for(let de=0;de<ae.length;de++){const fe=ae[de];M.format!==Ln?O!==null?N?le&&t.compressedTexSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+$,de,0,0,fe.width,fe.height,O,fe.data):t.compressedTexImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+$,de,ye,fe.width,fe.height,0,fe.data):$e("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):N?le&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+$,de,0,0,fe.width,fe.height,O,De,fe.data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+$,de,ye,fe.width,fe.height,0,O,De,fe.data)}}}else{if(ae=M.mipmaps,N&&ge){ae.length>0&&W++;const $=lt(H[0]);t.texStorage2D(n.TEXTURE_CUBE_MAP,W,ye,$.width,$.height)}for(let $=0;$<6;$++)if(We){N?le&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+$,0,0,0,H[$].width,H[$].height,O,De,H[$].data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+$,0,ye,H[$].width,H[$].height,0,O,De,H[$].data);for(let de=0;de<ae.length;de++){const Ue=ae[de].image[$].image;N?le&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+$,de+1,0,0,Ue.width,Ue.height,O,De,Ue.data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+$,de+1,ye,Ue.width,Ue.height,0,O,De,Ue.data)}}else{N?le&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+$,0,0,0,O,De,H[$]):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+$,0,ye,O,De,H[$]);for(let de=0;de<ae.length;de++){const fe=ae[de];N?le&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+$,de+1,0,0,O,De,fe.image[$]):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+$,de+1,ye,O,De,fe.image[$])}}}g(M)&&v(n.TEXTURE_CUBE_MAP),he.__version=Q.version,M.onUpdate&&M.onUpdate(M)}I.__version=M.version}function Se(I,M,q,te,Q,he){const Te=r.convert(q.format,q.colorSpace),ce=r.convert(q.type),pe=x(q.internalFormat,Te,ce,q.normalized,q.colorSpace),Ee=i.get(M),We=i.get(q);if(We.__renderTarget=M,!Ee.__hasExternalTextures){const H=Math.max(1,M.width>>he),ne=Math.max(1,M.height>>he);Q===n.TEXTURE_3D||Q===n.TEXTURE_2D_ARRAY?t.texImage3D(Q,he,pe,H,ne,M.depth,0,Te,ce,null):t.texImage2D(Q,he,pe,H,ne,0,Te,ce,null)}t.bindFramebuffer(n.FRAMEBUFFER,I),_t(M)?o.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,te,Q,We.__webglTexture,0,ft(M)):(Q===n.TEXTURE_2D||Q>=n.TEXTURE_CUBE_MAP_POSITIVE_X&&Q<=n.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&n.framebufferTexture2D(n.FRAMEBUFFER,te,Q,We.__webglTexture,he),t.bindFramebuffer(n.FRAMEBUFFER,null)}function Oe(I,M,q){if(n.bindRenderbuffer(n.RENDERBUFFER,I),M.depthBuffer){const te=M.depthTexture,Q=te&&te.isDepthTexture?te.type:null,he=E(M.stencilBuffer,Q),Te=M.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT;_t(M)?o.renderbufferStorageMultisampleEXT(n.RENDERBUFFER,ft(M),he,M.width,M.height):q?n.renderbufferStorageMultisample(n.RENDERBUFFER,ft(M),he,M.width,M.height):n.renderbufferStorage(n.RENDERBUFFER,he,M.width,M.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,Te,n.RENDERBUFFER,I)}else{const te=M.textures;for(let Q=0;Q<te.length;Q++){const he=te[Q],Te=r.convert(he.format,he.colorSpace),ce=r.convert(he.type),pe=x(he.internalFormat,Te,ce,he.normalized,he.colorSpace);_t(M)?o.renderbufferStorageMultisampleEXT(n.RENDERBUFFER,ft(M),pe,M.width,M.height):q?n.renderbufferStorageMultisample(n.RENDERBUFFER,ft(M),pe,M.width,M.height):n.renderbufferStorage(n.RENDERBUFFER,pe,M.width,M.height)}}n.bindRenderbuffer(n.RENDERBUFFER,null)}function Ge(I,M,q){const te=M.isWebGLCubeRenderTarget===!0;if(t.bindFramebuffer(n.FRAMEBUFFER,I),!(M.depthTexture&&M.depthTexture.isDepthTexture))throw new Error("THREE.WebGLTextures: renderTarget.depthTexture must be an instance of THREE.DepthTexture.");const Q=i.get(M.depthTexture);if(Q.__renderTarget=M,(!Q.__webglTexture||M.depthTexture.image.width!==M.width||M.depthTexture.image.height!==M.height)&&(M.depthTexture.image.width=M.width,M.depthTexture.image.height=M.height,M.depthTexture.needsUpdate=!0),te){if(Q.__webglInit===void 0&&(Q.__webglInit=!0,M.depthTexture.addEventListener("dispose",A)),Q.__webglTexture===void 0){Q.__webglTexture=n.createTexture(),t.bindTexture(n.TEXTURE_CUBE_MAP,Q.__webglTexture),ue(n.TEXTURE_CUBE_MAP,M.depthTexture);const Ee=r.convert(M.depthTexture.format),We=r.convert(M.depthTexture.type);let H;M.depthTexture.format===wi?H=n.DEPTH_COMPONENT24:M.depthTexture.format===ds&&(H=n.DEPTH24_STENCIL8);for(let ne=0;ne<6;ne++)n.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+ne,0,H,M.width,M.height,0,Ee,We,null)}}else ie(M.depthTexture,0);const he=Q.__webglTexture,Te=ft(M),ce=te?n.TEXTURE_CUBE_MAP_POSITIVE_X+q:n.TEXTURE_2D,pe=M.depthTexture.format===ds?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT;if(M.depthTexture.format===wi)_t(M)?o.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,pe,ce,he,0,Te):n.framebufferTexture2D(n.FRAMEBUFFER,pe,ce,he,0);else if(M.depthTexture.format===ds)_t(M)?o.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,pe,ce,he,0,Te):n.framebufferTexture2D(n.FRAMEBUFFER,pe,ce,he,0);else throw new Error("THREE.WebGLTextures: Unknown depthTexture format.")}function Ye(I){const M=i.get(I),q=I.isWebGLCubeRenderTarget===!0;if(M.__boundDepthTexture!==I.depthTexture){const te=I.depthTexture;if(M.__depthDisposeCallback&&M.__depthDisposeCallback(),te){const Q=()=>{delete M.__boundDepthTexture,delete M.__depthDisposeCallback,te.removeEventListener("dispose",Q)};te.addEventListener("dispose",Q),M.__depthDisposeCallback=Q}M.__boundDepthTexture=te}if(I.depthTexture&&!M.__autoAllocateDepthBuffer)if(q)for(let te=0;te<6;te++)Ge(M.__webglFramebuffer[te],I,te);else{const te=I.texture.mipmaps;te&&te.length>0?Ge(M.__webglFramebuffer[0],I,0):Ge(M.__webglFramebuffer,I,0)}else if(q){M.__webglDepthbuffer=[];for(let te=0;te<6;te++)if(t.bindFramebuffer(n.FRAMEBUFFER,M.__webglFramebuffer[te]),M.__webglDepthbuffer[te]===void 0)M.__webglDepthbuffer[te]=n.createRenderbuffer(),Oe(M.__webglDepthbuffer[te],I,!1);else{const Q=I.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,he=M.__webglDepthbuffer[te];n.bindRenderbuffer(n.RENDERBUFFER,he),n.framebufferRenderbuffer(n.FRAMEBUFFER,Q,n.RENDERBUFFER,he)}}else{const te=I.texture.mipmaps;if(te&&te.length>0?t.bindFramebuffer(n.FRAMEBUFFER,M.__webglFramebuffer[0]):t.bindFramebuffer(n.FRAMEBUFFER,M.__webglFramebuffer),M.__webglDepthbuffer===void 0)M.__webglDepthbuffer=n.createRenderbuffer(),Oe(M.__webglDepthbuffer,I,!1);else{const Q=I.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,he=M.__webglDepthbuffer;n.bindRenderbuffer(n.RENDERBUFFER,he),n.framebufferRenderbuffer(n.FRAMEBUFFER,Q,n.RENDERBUFFER,he)}}t.bindFramebuffer(n.FRAMEBUFFER,null)}function Ke(I,M,q){const te=i.get(I);M!==void 0&&Se(te.__webglFramebuffer,I,I.texture,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,0),q!==void 0&&Ye(I)}function Be(I){const M=I.texture,q=i.get(I),te=i.get(M);I.addEventListener("dispose",y);const Q=I.textures,he=I.isWebGLCubeRenderTarget===!0,Te=Q.length>1;if(Te||(te.__webglTexture===void 0&&(te.__webglTexture=n.createTexture()),te.__version=M.version,a.memory.textures++),he){q.__webglFramebuffer=[];for(let ce=0;ce<6;ce++)if(M.mipmaps&&M.mipmaps.length>0){q.__webglFramebuffer[ce]=[];for(let pe=0;pe<M.mipmaps.length;pe++)q.__webglFramebuffer[ce][pe]=n.createFramebuffer()}else q.__webglFramebuffer[ce]=n.createFramebuffer()}else{if(M.mipmaps&&M.mipmaps.length>0){q.__webglFramebuffer=[];for(let ce=0;ce<M.mipmaps.length;ce++)q.__webglFramebuffer[ce]=n.createFramebuffer()}else q.__webglFramebuffer=n.createFramebuffer();if(Te)for(let ce=0,pe=Q.length;ce<pe;ce++){const Ee=i.get(Q[ce]);Ee.__webglTexture===void 0&&(Ee.__webglTexture=n.createTexture(),a.memory.textures++)}if(I.samples>0&&_t(I)===!1){q.__webglMultisampledFramebuffer=n.createFramebuffer(),q.__webglColorRenderbuffer=[],t.bindFramebuffer(n.FRAMEBUFFER,q.__webglMultisampledFramebuffer);for(let ce=0;ce<Q.length;ce++){const pe=Q[ce];q.__webglColorRenderbuffer[ce]=n.createRenderbuffer(),n.bindRenderbuffer(n.RENDERBUFFER,q.__webglColorRenderbuffer[ce]);const Ee=r.convert(pe.format,pe.colorSpace),We=r.convert(pe.type),H=x(pe.internalFormat,Ee,We,pe.normalized,pe.colorSpace,I.isXRRenderTarget===!0),ne=ft(I);n.renderbufferStorageMultisample(n.RENDERBUFFER,ne,H,I.width,I.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+ce,n.RENDERBUFFER,q.__webglColorRenderbuffer[ce])}n.bindRenderbuffer(n.RENDERBUFFER,null),I.depthBuffer&&(q.__webglDepthRenderbuffer=n.createRenderbuffer(),Oe(q.__webglDepthRenderbuffer,I,!0)),t.bindFramebuffer(n.FRAMEBUFFER,null)}}if(he){t.bindTexture(n.TEXTURE_CUBE_MAP,te.__webglTexture),ue(n.TEXTURE_CUBE_MAP,M);for(let ce=0;ce<6;ce++)if(M.mipmaps&&M.mipmaps.length>0)for(let pe=0;pe<M.mipmaps.length;pe++)Se(q.__webglFramebuffer[ce][pe],I,M,n.COLOR_ATTACHMENT0,n.TEXTURE_CUBE_MAP_POSITIVE_X+ce,pe);else Se(q.__webglFramebuffer[ce],I,M,n.COLOR_ATTACHMENT0,n.TEXTURE_CUBE_MAP_POSITIVE_X+ce,0);g(M)&&v(n.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(Te){for(let ce=0,pe=Q.length;ce<pe;ce++){const Ee=Q[ce],We=i.get(Ee);let H=n.TEXTURE_2D;(I.isWebGL3DRenderTarget||I.isWebGLArrayRenderTarget)&&(H=I.isWebGL3DRenderTarget?n.TEXTURE_3D:n.TEXTURE_2D_ARRAY),t.bindTexture(H,We.__webglTexture),ue(H,Ee),Se(q.__webglFramebuffer,I,Ee,n.COLOR_ATTACHMENT0+ce,H,0),g(Ee)&&v(H)}t.unbindTexture()}else{let ce=n.TEXTURE_2D;if((I.isWebGL3DRenderTarget||I.isWebGLArrayRenderTarget)&&(ce=I.isWebGL3DRenderTarget?n.TEXTURE_3D:n.TEXTURE_2D_ARRAY),t.bindTexture(ce,te.__webglTexture),ue(ce,M),M.mipmaps&&M.mipmaps.length>0)for(let pe=0;pe<M.mipmaps.length;pe++)Se(q.__webglFramebuffer[pe],I,M,n.COLOR_ATTACHMENT0,ce,pe);else Se(q.__webglFramebuffer,I,M,n.COLOR_ATTACHMENT0,ce,0);g(M)&&v(ce),t.unbindTexture()}I.depthBuffer&&Ye(I)}function Pe(I){const M=I.textures;for(let q=0,te=M.length;q<te;q++){const Q=M[q];if(g(Q)){const he=b(I),Te=i.get(Q).__webglTexture;t.bindTexture(he,Te),v(he),t.unbindTexture()}}}const st=[],mt=[];function gt(I){if(I.samples>0){if(_t(I)===!1){const M=I.textures,q=I.width,te=I.height;let Q=n.COLOR_BUFFER_BIT;const he=I.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,Te=i.get(I),ce=M.length>1;if(ce)for(let Ee=0;Ee<M.length;Ee++)t.bindFramebuffer(n.FRAMEBUFFER,Te.__webglMultisampledFramebuffer),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+Ee,n.RENDERBUFFER,null),t.bindFramebuffer(n.FRAMEBUFFER,Te.__webglFramebuffer),n.framebufferTexture2D(n.DRAW_FRAMEBUFFER,n.COLOR_ATTACHMENT0+Ee,n.TEXTURE_2D,null,0);t.bindFramebuffer(n.READ_FRAMEBUFFER,Te.__webglMultisampledFramebuffer);const pe=I.texture.mipmaps;pe&&pe.length>0?t.bindFramebuffer(n.DRAW_FRAMEBUFFER,Te.__webglFramebuffer[0]):t.bindFramebuffer(n.DRAW_FRAMEBUFFER,Te.__webglFramebuffer);for(let Ee=0;Ee<M.length;Ee++){if(I.resolveDepthBuffer&&(I.depthBuffer&&(Q|=n.DEPTH_BUFFER_BIT),I.stencilBuffer&&I.resolveStencilBuffer&&(Q|=n.STENCIL_BUFFER_BIT)),ce){n.framebufferRenderbuffer(n.READ_FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.RENDERBUFFER,Te.__webglColorRenderbuffer[Ee]);const We=i.get(M[Ee]).__webglTexture;n.framebufferTexture2D(n.DRAW_FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,We,0)}n.blitFramebuffer(0,0,q,te,0,0,q,te,Q,n.NEAREST),l===!0&&(st.length=0,mt.length=0,st.push(n.COLOR_ATTACHMENT0+Ee),I.depthBuffer&&I.resolveDepthBuffer===!1&&(st.push(he),mt.push(he),n.invalidateFramebuffer(n.DRAW_FRAMEBUFFER,mt)),n.invalidateFramebuffer(n.READ_FRAMEBUFFER,st))}if(t.bindFramebuffer(n.READ_FRAMEBUFFER,null),t.bindFramebuffer(n.DRAW_FRAMEBUFFER,null),ce)for(let Ee=0;Ee<M.length;Ee++){t.bindFramebuffer(n.FRAMEBUFFER,Te.__webglMultisampledFramebuffer),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+Ee,n.RENDERBUFFER,Te.__webglColorRenderbuffer[Ee]);const We=i.get(M[Ee]).__webglTexture;t.bindFramebuffer(n.FRAMEBUFFER,Te.__webglFramebuffer),n.framebufferTexture2D(n.DRAW_FRAMEBUFFER,n.COLOR_ATTACHMENT0+Ee,n.TEXTURE_2D,We,0)}t.bindFramebuffer(n.DRAW_FRAMEBUFFER,Te.__webglMultisampledFramebuffer)}else if(I.depthBuffer&&I.resolveDepthBuffer===!1&&l){const M=I.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT;n.invalidateFramebuffer(n.DRAW_FRAMEBUFFER,[M])}}}function ft(I){return Math.min(s.maxSamples,I.samples)}function _t(I){const M=i.get(I);return I.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&M.__useRenderToTexture!==!1}function G(I){const M=a.render.frame;u.get(I)!==M&&(u.set(I,M),I.update())}function nt(I,M){const q=I.colorSpace,te=I.format,Q=I.type;return I.isCompressedTexture===!0||I.isVideoTexture===!0||q!==So&&q!==vi&&(at.getTransfer(q)===xt?(te!==Ln||Q!==wn)&&$e("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):ut("WebGLTextures: Unsupported texture color space:",q)),M}function lt(I){return typeof HTMLImageElement<"u"&&I instanceof HTMLImageElement?(c.width=I.naturalWidth||I.width,c.height=I.naturalHeight||I.height):typeof VideoFrame<"u"&&I instanceof VideoFrame?(c.width=I.displayWidth,c.height=I.displayHeight):(c.width=I.width,c.height=I.height),c}this.allocateTextureUnit=K,this.resetTextureUnits=P,this.getTextureUnits=U,this.setTextureUnits=D,this.setTexture2D=ie,this.setTexture2DArray=F,this.setTexture3D=se,this.setTextureCube=V,this.rebindTextures=Ke,this.setupRenderTarget=Be,this.updateRenderTargetMipmap=Pe,this.updateMultisampleRenderTarget=gt,this.setupDepthRenderbuffer=Ye,this.setupFrameBufferTexture=Se,this.useMultisampledRTT=_t,this.isReversedDepthBuffer=function(){return t.buffers.depth.getReversed()}}function Yv(n,e){function t(i,s=vi){let r;const a=at.getTransfer(s);if(i===wn)return n.UNSIGNED_BYTE;if(i===fu)return n.UNSIGNED_SHORT_4_4_4_4;if(i===pu)return n.UNSIGNED_SHORT_5_5_5_1;if(i===kf)return n.UNSIGNED_INT_5_9_9_9_REV;if(i===Ff)return n.UNSIGNED_INT_10F_11F_11F_REV;if(i===Uf)return n.BYTE;if(i===Nf)return n.SHORT;if(i===Yr)return n.UNSIGNED_SHORT;if(i===du)return n.INT;if(i===di)return n.UNSIGNED_INT;if(i===Gn)return n.FLOAT;if(i===Ci)return n.HALF_FLOAT;if(i===Bf)return n.ALPHA;if(i===Hf)return n.RGB;if(i===Ln)return n.RGBA;if(i===wi)return n.DEPTH_COMPONENT;if(i===ds)return n.DEPTH_STENCIL;if(i===zf)return n.RED;if(i===mu)return n.RED_INTEGER;if(i===gs)return n.RG;if(i===gu)return n.RG_INTEGER;if(i===_u)return n.RGBA_INTEGER;if(i===co||i===uo||i===ho||i===fo)if(a===xt)if(r=e.get("WEBGL_compressed_texture_s3tc_srgb"),r!==null){if(i===co)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===uo)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===ho)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===fo)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(r=e.get("WEBGL_compressed_texture_s3tc"),r!==null){if(i===co)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===uo)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===ho)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===fo)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(i===fc||i===pc||i===mc||i===gc)if(r=e.get("WEBGL_compressed_texture_pvrtc"),r!==null){if(i===fc)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===pc)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===mc)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===gc)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(i===_c||i===xc||i===yc||i===vc||i===Sc||i===yo||i===bc)if(r=e.get("WEBGL_compressed_texture_etc"),r!==null){if(i===_c||i===xc)return a===xt?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(i===yc)return a===xt?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC;if(i===vc)return r.COMPRESSED_R11_EAC;if(i===Sc)return r.COMPRESSED_SIGNED_R11_EAC;if(i===yo)return r.COMPRESSED_RG11_EAC;if(i===bc)return r.COMPRESSED_SIGNED_RG11_EAC}else return null;if(i===Mc||i===Ac||i===Ec||i===Tc||i===Cc||i===wc||i===Rc||i===Lc||i===Dc||i===Ic||i===Pc||i===Oc||i===Uc||i===Nc)if(r=e.get("WEBGL_compressed_texture_astc"),r!==null){if(i===Mc)return a===xt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(i===Ac)return a===xt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(i===Ec)return a===xt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(i===Tc)return a===xt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(i===Cc)return a===xt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(i===wc)return a===xt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(i===Rc)return a===xt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(i===Lc)return a===xt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(i===Dc)return a===xt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(i===Ic)return a===xt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(i===Pc)return a===xt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(i===Oc)return a===xt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(i===Uc)return a===xt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(i===Nc)return a===xt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(i===kc||i===Fc||i===Bc)if(r=e.get("EXT_texture_compression_bptc"),r!==null){if(i===kc)return a===xt?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(i===Fc)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(i===Bc)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(i===Hc||i===zc||i===vo||i===Vc)if(r=e.get("EXT_texture_compression_rgtc"),r!==null){if(i===Hc)return r.COMPRESSED_RED_RGTC1_EXT;if(i===zc)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(i===vo)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(i===Vc)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return i===Kr?n.UNSIGNED_INT_24_8:n[i]!==void 0?n[i]:null}return{convert:t}}const Kv=`
void main() {
gl_Position = vec4( position, 1.0 );
}`,qv=`
uniform sampler2DArray depthColor;
uniform float depthWidth;
uniform float depthHeight;
void main() {
vec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight );
if ( coord.x >= 1.0 ) {
gl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r;
} else {
gl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r;
}
}`;class $v{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){const i=new tp(e.texture);(e.depthNear!==t.depthNear||e.depthFar!==t.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=i}}getMesh(e){if(this.texture!==null&&this.mesh===null){const t=e.cameras[0].viewport,i=new In({vertexShader:Kv,fragmentShader:qv,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new Ht(new fs(20,20),i)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class Zv extends es{constructor(e,t){super();const i=this;let s=null,r=1,a=null,o="local-floor",l=1,c=null,u=null,h=null,d=null,f=null,p=null;const _=typeof XRWebGLBinding<"u",m=new $v,g={},v=t.getContextAttributes();let b=null,x=null;const E=[],S=[],A=new Le;let y=null;const T=new zn;T.viewport=new Et;const L=new zn;L.viewport=new Et;const R=[T,L],w=new n_;let P=null,U=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(z){let ee=E[z];return ee===void 0&&(ee=new ol,E[z]=ee),ee.getTargetRaySpace()},this.getControllerGrip=function(z){let ee=E[z];return ee===void 0&&(ee=new ol,E[z]=ee),ee.getGripSpace()},this.getHand=function(z){let ee=E[z];return ee===void 0&&(ee=new ol,E[z]=ee),ee.getHandSpace()};function D(z){const ee=S.indexOf(z.inputSource);if(ee===-1)return;const Z=E[ee];Z!==void 0&&(Z.update(z.inputSource,z.frame,c||a),Z.dispatchEvent({type:z.type,data:z.inputSource}))}function K(){s.removeEventListener("select",D),s.removeEventListener("selectstart",D),s.removeEventListener("selectend",D),s.removeEventListener("squeeze",D),s.removeEventListener("squeezestart",D),s.removeEventListener("squeezeend",D),s.removeEventListener("end",K),s.removeEventListener("inputsourceschange",B);for(let z=0;z<E.length;z++){const ee=S[z];ee!==null&&(S[z]=null,E[z].disconnect(ee))}P=null,U=null,m.reset();for(const z in g)delete g[z];e.setRenderTarget(b),f=null,d=null,h=null,s=null,x=null,ue.stop(),i.isPresenting=!1,e.setPixelRatio(y),e.setSize(A.width,A.height,!1),i.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(z){r=z,i.isPresenting===!0&&$e("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(z){o=z,i.isPresenting===!0&&$e("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||a},this.setReferenceSpace=function(z){c=z},this.getBaseLayer=function(){return d!==null?d:f},this.getBinding=function(){return h===null&&_&&(h=new XRWebGLBinding(s,t)),h},this.getFrame=function(){return p},this.getSession=function(){return s},this.setSession=async function(z){if(s=z,s!==null){if(b=e.getRenderTarget(),s.addEventListener("select",D),s.addEventListener("selectstart",D),s.addEventListener("selectend",D),s.addEventListener("squeeze",D),s.addEventListener("squeezestart",D),s.addEventListener("squeezeend",D),s.addEventListener("end",K),s.addEventListener("inputsourceschange",B),v.xrCompatible!==!0&&await t.makeXRCompatible(),y=e.getPixelRatio(),e.getSize(A),_&&"createProjectionLayer"in XRWebGLBinding.prototype){let Z=null,xe=null,be=null;v.depth&&(be=v.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,Z=v.stencil?ds:wi,xe=v.stencil?Kr:di);const Se={colorFormat:t.RGBA8,depthFormat:be,scaleFactor:r};h=this.getBinding(),d=h.createProjectionLayer(Se),s.updateRenderState({layers:[d]}),e.setPixelRatio(1),e.setSize(d.textureWidth,d.textureHeight,!1),x=new ui(d.textureWidth,d.textureHeight,{format:Ln,type:wn,depthTexture:new ar(d.textureWidth,d.textureHeight,xe,void 0,void 0,void 0,void 0,void 0,void 0,Z),stencilBuffer:v.stencil,colorSpace:e.outputColorSpace,samples:v.antialias?4:0,resolveDepthBuffer:d.ignoreDepthValues===!1,resolveStencilBuffer:d.ignoreDepthValues===!1})}else{const Z={antialias:v.antialias,alpha:!0,depth:v.depth,stencil:v.stencil,framebufferScaleFactor:r};f=new XRWebGLLayer(s,t,Z),s.updateRenderState({baseLayer:f}),e.setPixelRatio(1),e.setSize(f.framebufferWidth,f.framebufferHeight,!1),x=new ui(f.framebufferWidth,f.framebufferHeight,{format:Ln,type:wn,colorSpace:e.outputColorSpace,stencilBuffer:v.stencil,resolveDepthBuffer:f.ignoreDepthValues===!1,resolveStencilBuffer:f.ignoreDepthValues===!1})}x.isXRRenderTarget=!0,this.setFoveation(l),c=null,a=await s.requestReferenceSpace(o),ue.setContext(s),ue.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(s!==null)return s.environmentBlendMode},this.getDepthTexture=function(){return m.getDepthTexture()};function B(z){for(let ee=0;ee<z.removed.length;ee++){const Z=z.removed[ee],xe=S.indexOf(Z);xe>=0&&(S[xe]=null,E[xe].disconnect(Z))}for(let ee=0;ee<z.added.length;ee++){const Z=z.added[ee];let xe=S.indexOf(Z);if(xe===-1){for(let Se=0;Se<E.length;Se++)if(Se>=S.length){S.push(Z),xe=Se;break}else if(S[Se]===null){S[Se]=Z,xe=Se;break}if(xe===-1)break}const be=E[xe];be&&be.connect(Z)}}const ie=new k,F=new k;function se(z,ee,Z){ie.setFromMatrixPosition(ee.matrixWorld),F.setFromMatrixPosition(Z.matrixWorld);const xe=ie.distanceTo(F),be=ee.projectionMatrix.elements,Se=Z.projectionMatrix.elements,Oe=be[14]/(be[10]-1),Ge=be[14]/(be[10]+1),Ye=(be[9]+1)/be[5],Ke=(be[9]-1)/be[5],Be=(be[8]-1)/be[0],Pe=(Se[8]+1)/Se[0],st=Oe*Be,mt=Oe*Pe,gt=xe/(-Be+Pe),ft=gt*-Be;if(ee.matrixWorld.decompose(z.position,z.quaternion,z.scale),z.translateX(ft),z.translateZ(gt),z.matrixWorld.compose(z.position,z.quaternion,z.scale),z.matrixWorldInverse.copy(z.matrixWorld).invert(),be[10]===-1)z.projectionMatrix.copy(ee.projectionMatrix),z.projectionMatrixInverse.copy(ee.projectionMatrixInverse);else{const _t=Oe+gt,G=Ge+gt,nt=st-ft,lt=mt+(xe-ft),I=Ye*Ge/G*_t,M=Ke*Ge/G*_t;z.projectionMatrix.makePerspective(nt,lt,I,M,_t,G),z.projectionMatrixInverse.copy(z.projectionMatrix).invert()}}function V(z,ee){ee===null?z.matrixWorld.copy(z.matrix):z.matrixWorld.multiplyMatrices(ee.matrixWorld,z.matrix),z.matrixWorldInverse.copy(z.matrixWorld).invert()}this.updateCamera=function(z){if(s===null)return;let ee=z.near,Z=z.far;m.texture!==null&&(m.depthNear>0&&(ee=m.depthNear),m.depthFar>0&&(Z=m.depthFar)),w.near=L.near=T.near=ee,w.far=L.far=T.far=Z,(P!==w.near||U!==w.far)&&(s.updateRenderState({depthNear:w.near,depthFar:w.far}),P=w.near,U=w.far),w.layers.mask=z.layers.mask|6,T.layers.mask=w.layers.mask&-5,L.layers.mask=w.layers.mask&-3;const xe=z.parent,be=w.cameras;V(w,xe);for(let Se=0;Se<be.length;Se++)V(be[Se],xe);be.length===2?se(w,T,L):w.projectionMatrix.copy(T.projectionMatrix),oe(z,w,xe)};function oe(z,ee,Z){Z===null?z.matrix.copy(ee.matrixWorld):(z.matrix.copy(Z.matrixWorld),z.matrix.invert(),z.matrix.multiply(ee.matrixWorld)),z.matrix.decompose(z.position,z.quaternion,z.scale),z.updateMatrixWorld(!0),z.projectionMatrix.copy(ee.projectionMatrix),z.projectionMatrixInverse.copy(ee.projectionMatrixInverse),z.isPerspectiveCamera&&(z.fov=qr*2*Math.atan(1/z.projectionMatrix.elements[5]),z.zoom=1)}this.getCamera=function(){return w},this.getFoveation=function(){if(!(d===null&&f===null))return l},this.setFoveation=function(z){l=z,d!==null&&(d.fixedFoveation=z),f!==null&&f.fixedFoveation!==void 0&&(f.fixedFoveation=z)},this.hasDepthSensing=function(){return m.texture!==null},this.getDepthSensingMesh=function(){return m.getMesh(w)},this.getCameraTexture=function(z){return g[z]};let Ae=null;function me(z,ee){if(u=ee.getViewerPose(c||a),p=ee,u!==null){const Z=u.views;f!==null&&(e.setRenderTargetFramebuffer(x,f.framebuffer),e.setRenderTarget(x));let xe=!1;Z.length!==w.cameras.length&&(w.cameras.length=0,xe=!0);for(let Ge=0;Ge<Z.length;Ge++){const Ye=Z[Ge];let Ke=null;if(f!==null)Ke=f.getViewport(Ye);else{const Pe=h.getViewSubImage(d,Ye);Ke=Pe.viewport,Ge===0&&(e.setRenderTargetTextures(x,Pe.colorTexture,Pe.depthStencilTexture),e.setRenderTarget(x))}let Be=R[Ge];Be===void 0&&(Be=new zn,Be.layers.enable(Ge),Be.viewport=new Et,R[Ge]=Be),Be.matrix.fromArray(Ye.transform.matrix),Be.matrix.decompose(Be.position,Be.quaternion,Be.scale),Be.projectionMatrix.fromArray(Ye.projectionMatrix),Be.projectionMatrixInverse.copy(Be.projectionMatrix).invert(),Be.viewport.set(Ke.x,Ke.y,Ke.width,Ke.height),Ge===0&&(w.matrix.copy(Be.matrix),w.matrix.decompose(w.position,w.quaternion,w.scale)),xe===!0&&w.cameras.push(Be)}const be=s.enabledFeatures;if(be&&be.includes("depth-sensing")&&s.depthUsage=="gpu-optimized"&&_){h=i.getBinding();const Ge=h.getDepthInformation(Z[0]);Ge&&Ge.isValid&&Ge.texture&&m.init(Ge,s.renderState)}if(be&&be.includes("camera-access")&&_){e.state.unbindTexture(),h=i.getBinding();for(let Ge=0;Ge<Z.length;Ge++){const Ye=Z[Ge].camera;if(Ye){let Ke=g[Ye];Ke||(Ke=new tp,g[Ye]=Ke);const Be=h.getCameraImage(Ye);Ke.sourceTexture=Be}}}}for(let Z=0;Z<E.length;Z++){const xe=S[Z],be=E[Z];xe!==null&&be!==void 0&&be.update(xe,ee,c||a)}Ae&&Ae(z,ee),ee.detectedPlanes&&i.dispatchEvent({type:"planesdetected",data:ee}),p=null}const ue=new fp;ue.setAnimationLoop(me),this.setAnimationLoop=function(z){Ae=z},this.dispose=function(){}}}const Jv=new Rt,vp=new et;vp.set(-1,0,0,0,1,0,0,0,1);function jv(n,e){function t(m,g){m.matrixAutoUpdate===!0&&m.updateMatrix(),g.value.copy(m.matrix)}function i(m,g){g.color.getRGB(m.fogColor.value,hp(n)),g.isFog?(m.fogNear.value=g.near,m.fogFar.value=g.far):g.isFogExp2&&(m.fogDensity.value=g.density)}function s(m,g,v,b,x){g.isNodeMaterial?g.uniformsNeedUpdate=!1:g.isMeshBasicMaterial?r(m,g):g.isMeshLambertMaterial?(r(m,g),g.envMap&&(m.envMapIntensity.value=g.envMapIntensity)):g.isMeshToonMaterial?(r(m,g),h(m,g)):g.isMeshPhongMaterial?(r(m,g),u(m,g),g.envMap&&(m.envMapIntensity.value=g.envMapIntensity)):g.isMeshStandardMaterial?(r(m,g),d(m,g),g.isMeshPhysicalMaterial&&f(m,g,x)):g.isMeshMatcapMaterial?(r(m,g),p(m,g)):g.isMeshDepthMaterial?r(m,g):g.isMeshDistanceMaterial?(r(m,g),_(m,g)):g.isMeshNormalMaterial?r(m,g):g.isLineBasicMaterial?(a(m,g),g.isLineDashedMaterial&&o(m,g)):g.isPointsMaterial?l(m,g,v,b):g.isSpriteMaterial?c(m,g):g.isShadowMaterial?(m.color.value.copy(g.color),m.opacity.value=g.opacity):g.isShaderMaterial&&(g.uniformsNeedUpdate=!1)}function r(m,g){m.opacity.value=g.opacity,g.color&&m.diffuse.value.copy(g.color),g.emissive&&m.emissive.value.copy(g.emissive).multiplyScalar(g.emissiveIntensity),g.map&&(m.map.value=g.map,t(g.map,m.mapTransform)),g.alphaMap&&(m.alphaMap.value=g.alphaMap,t(g.alphaMap,m.alphaMapTransform)),g.bumpMap&&(m.bumpMap.value=g.bumpMap,t(g.bumpMap,m.bumpMapTransform),m.bumpScale.value=g.bumpScale,g.side===_n&&(m.bumpScale.value*=-1)),g.normalMap&&(m.normalMap.value=g.normalMap,t(g.normalMap,m.normalMapTransform),m.normalScale.value.copy(g.normalScale),g.side===_n&&m.normalScale.value.negate()),g.displacementMap&&(m.displacementMap.value=g.displacementMap,t(g.displacementMap,m.displacementMapTransform),m.displacementScale.value=g.displacementScale,m.displacementBias.value=g.displacementBias),g.emissiveMap&&(m.emissiveMap.value=g.emissiveMap,t(g.emissiveMap,m.emissiveMapTransform)),g.specularMap&&(m.specularMap.value=g.specularMap,t(g.specularMap,m.specularMapTransform)),g.alphaTest>0&&(m.alphaTest.value=g.alphaTest);const v=e.get(g),b=v.envMap,x=v.envMapRotation;b&&(m.envMap.value=b,m.envMapRotation.value.setFromMatrix4(Jv.makeRotationFromEuler(x)).transpose(),b.isCubeTexture&&b.isRenderTargetTexture===!1&&m.envMapRotation.value.premultiply(vp),m.reflectivity.value=g.reflectivity,m.ior.value=g.ior,m.refractionRatio.value=g.refractionRatio),g.lightMap&&(m.lightMap.value=g.lightMap,m.lightMapIntensity.value=g.lightMapIntensity,t(g.lightMap,m.lightMapTransform)),g.aoMap&&(m.aoMap.value=g.aoMap,m.aoMapIntensity.value=g.aoMapIntensity,t(g.aoMap,m.aoMapTransform))}function a(m,g){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity,g.map&&(m.map.value=g.map,t(g.map,m.mapTransform))}function o(m,g){m.dashSize.value=g.dashSize,m.totalSize.value=g.dashSize+g.gapSize,m.scale.value=g.scale}function l(m,g,v,b){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity,m.size.value=g.size*v,m.scale.value=b*.5,g.map&&(m.map.value=g.map,t(g.map,m.uvTransform)),g.alphaMap&&(m.alphaMap.value=g.alphaMap,t(g.alphaMap,m.alphaMapTransform)),g.alphaTest>0&&(m.alphaTest.value=g.alphaTest)}function c(m,g){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity,m.rotation.value=g.rotation,g.map&&(m.map.value=g.map,t(g.map,m.mapTransform)),g.alphaMap&&(m.alphaMap.value=g.alphaMap,t(g.alphaMap,m.alphaMapTransform)),g.alphaTest>0&&(m.alphaTest.value=g.alphaTest)}function u(m,g){m.specular.value.copy(g.specular),m.shininess.value=Math.max(g.shininess,1e-4)}function h(m,g){g.gradientMap&&(m.gradientMap.value=g.gradientMap)}function d(m,g){m.metalness.value=g.metalness,g.metalnessMap&&(m.metalnessMap.value=g.metalnessMap,t(g.metalnessMap,m.metalnessMapTransform)),m.roughness.value=g.roughness,g.roughnessMap&&(m.roughnessMap.value=g.roughnessMap,t(g.roughnessMap,m.roughnessMapTransform)),g.envMap&&(m.envMapIntensity.value=g.envMapIntensity)}function f(m,g,v){m.ior.value=g.ior,g.sheen>0&&(m.sheenColor.value.copy(g.sheenColor).multiplyScalar(g.sheen),m.sheenRoughness.value=g.sheenRoughness,g.sheenColorMap&&(m.sheenColorMap.value=g.sheenColorMap,t(g.sheenColorMap,m.sheenColorMapTransform)),g.sheenRoughnessMap&&(m.sheenRoughnessMap.value=g.sheenRoughnessMap,t(g.sheenRoughnessMap,m.sheenRoughnessMapTransform))),g.clearcoat>0&&(m.clearcoat.value=g.clearcoat,m.clearcoatRoughness.value=g.clearcoatRoughness,g.clearcoatMap&&(m.clearcoatMap.value=g.clearcoatMap,t(g.clearcoatMap,m.clearcoatMapTransform)),g.clearcoatRoughnessMap&&(m.clearcoatRoughnessMap.value=g.clearcoatRoughnessMap,t(g.clearcoatRoughnessMap,m.clearcoatRoughnessMapTransform)),g.clearcoatNormalMap&&(m.clearcoatNormalMap.value=g.clearcoatNormalMap,t(g.clearcoatNormalMap,m.clearcoatNormalMapTransform),m.clearcoatNormalScale.value.copy(g.clearcoatNormalScale),g.side===_n&&m.clearcoatNormalScale.value.negate())),g.dispersion>0&&(m.dispersion.value=g.dispersion),g.iridescence>0&&(m.iridescence.value=g.iridescence,m.iridescenceIOR.value=g.iridescenceIOR,m.iridescenceThicknessMinimum.value=g.iridescenceThicknessRange[0],m.iridescenceThicknessMaximum.value=g.iridescenceThicknessRange[1],g.iridescenceMap&&(m.iridescenceMap.value=g.iridescenceMap,t(g.iridescenceMap,m.iridescenceMapTransform)),g.iridescenceThicknessMap&&(m.iridescenceThicknessMap.value=g.iridescenceThicknessMap,t(g.iridescenceThicknessMap,m.iridescenceThicknessMapTransform))),g.transmission>0&&(m.transmission.value=g.transmission,m.transmissionSamplerMap.value=v.texture,m.transmissionSamplerSize.value.set(v.width,v.height),g.transmissionMap&&(m.transmissionMap.value=g.transmissionMap,t(g.transmissionMap,m.transmissionMapTransform)),m.thickness.value=g.thickness,g.thicknessMap&&(m.thicknessMap.value=g.thicknessMap,t(g.thicknessMap,m.thicknessMapTransform)),m.attenuationDistance.value=g.attenuationDistance,m.attenuationColor.value.copy(g.attenuationColor)),g.anisotropy>0&&(m.anisotropyVector.value.set(g.anisotropy*Math.cos(g.anisotropyRotation),g.anisotropy*Math.sin(g.anisotropyRotation)),g.anisotropyMap&&(m.anisotropyMap.value=g.anisotropyMap,t(g.anisotropyMap,m.anisotropyMapTransform))),m.specularIntensity.value=g.specularIntensity,m.specularColor.value.copy(g.specularColor),g.specularColorMap&&(m.specularColorMap.value=g.specularColorMap,t(g.specularColorMap,m.specularColorMapTransform)),g.specularIntensityMap&&(m.specularIntensityMap.value=g.specularIntensityMap,t(g.specularIntensityMap,m.specularIntensityMapTransform))}function p(m,g){g.matcap&&(m.matcap.value=g.matcap)}function _(m,g){const v=e.get(g).light;m.referencePosition.value.setFromMatrixPosition(v.matrixWorld),m.nearDistance.value=v.shadow.camera.near,m.farDistance.value=v.shadow.camera.far}return{refreshFogUniforms:i,refreshMaterialUniforms:s}}function Qv(n,e,t,i){let s={},r={},a=[];const o=n.getParameter(n.MAX_UNIFORM_BUFFER_BINDINGS);function l(x,E){const S=E.program;i.uniformBlockBinding(x,S)}function c(x,E){let S=s[x.id];S===void 0&&(m(x),S=u(x),s[x.id]=S,x.addEventListener("dispose",v));const A=E.program;i.updateUBOMapping(x,A);const y=e.render.frame;r[x.id]!==y&&(d(x),r[x.id]=y)}function u(x){const E=h();x.__bindingPointIndex=E;const S=n.createBuffer(),A=x.__size,y=x.usage;return n.bindBuffer(n.UNIFORM_BUFFER,S),n.bufferData(n.UNIFORM_BUFFER,A,y),n.bindBuffer(n.UNIFORM_BUFFER,null),n.bindBufferBase(n.UNIFORM_BUFFER,E,S),S}function h(){for(let x=0;x<o;x++)if(a.indexOf(x)===-1)return a.push(x),x;return ut("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function d(x){const E=s[x.id],S=x.uniforms,A=x.__cache;n.bindBuffer(n.UNIFORM_BUFFER,E);for(let y=0,T=S.length;y<T;y++){const L=S[y];if(Array.isArray(L))for(let R=0,w=L.length;R<w;R++)f(L[R],y,R,A);else f(L,y,0,A)}n.bindBuffer(n.UNIFORM_BUFFER,null)}function f(x,E,S,A){if(_(x,E,S,A)===!0){const y=x.__offset,T=x.value;if(Array.isArray(T)){let L=0;for(let R=0;R<T.length;R++){const w=T[R],P=g(w);p(w,x.__data,L),typeof w!="number"&&typeof w!="boolean"&&!w.isMatrix3&&!ArrayBuffer.isView(w)&&(L+=P.storage/Float32Array.BYTES_PER_ELEMENT)}}else p(T,x.__data,0);n.bufferSubData(n.UNIFORM_BUFFER,y,x.__data)}}function p(x,E,S){typeof x=="number"||typeof x=="boolean"?E[0]=x:x.isMatrix3?(E[0]=x.elements[0],E[1]=x.elements[1],E[2]=x.elements[2],E[3]=0,E[4]=x.elements[3],E[5]=x.elements[4],E[6]=x.elements[5],E[7]=0,E[8]=x.elements[6],E[9]=x.elements[7],E[10]=x.elements[8],E[11]=0):ArrayBuffer.isView(x)?E.set(new x.constructor(x.buffer,x.byteOffset,E.length)):x.toArray(E,S)}function _(x,E,S,A){const y=x.value,T=E+"_"+S;if(A[T]===void 0)return typeof y=="number"||typeof y=="boolean"?A[T]=y:ArrayBuffer.isView(y)?A[T]=y.slice():A[T]=y.clone(),!0;{const L=A[T];if(typeof y=="number"||typeof y=="boolean"){if(L!==y)return A[T]=y,!0}else{if(ArrayBuffer.isView(y))return!0;if(L.equals(y)===!1)return L.copy(y),!0}}return!1}function m(x){const E=x.uniforms;let S=0;const A=16;for(let T=0,L=E.length;T<L;T++){const R=Array.isArray(E[T])?E[T]:[E[T]];for(let w=0,P=R.length;w<P;w++){const U=R[w],D=Array.isArray(U.value)?U.value:[U.value];for(let K=0,B=D.length;K<B;K++){const ie=D[K],F=g(ie),se=S%A,V=se%F.boundary,oe=se+V;S+=V,oe!==0&&A-oe<F.storage&&(S+=A-oe),U.__data=new Float32Array(F.storage/Float32Array.BYTES_PER_ELEMENT),U.__offset=S,S+=F.storage}}}const y=S%A;return y>0&&(S+=A-y),x.__size=S,x.__cache={},this}function g(x){const E={boundary:0,storage:0};return typeof x=="number"||typeof x=="boolean"?(E.boundary=4,E.storage=4):x.isVector2?(E.boundary=8,E.storage=8):x.isVector3||x.isColor?(E.boundary=16,E.storage=12):x.isVector4?(E.boundary=16,E.storage=16):x.isMatrix3?(E.boundary=48,E.storage=48):x.isMatrix4?(E.boundary=64,E.storage=64):x.isTexture?$e("WebGLRenderer: Texture samplers can not be part of an uniforms group."):ArrayBuffer.isView(x)?(E.boundary=16,E.storage=x.byteLength):$e("WebGLRenderer: Unsupported uniform value type.",x),E}function v(x){const E=x.target;E.removeEventListener("dispose",v);const S=a.indexOf(E.__bindingPointIndex);a.splice(S,1),n.deleteBuffer(s[E.id]),delete s[E.id],delete r[E.id]}function b(){for(const x in s)n.deleteBuffer(s[x]);a=[],s={},r={}}return{bind:l,update:c,dispose:b}}const eS=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,14942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]);let Zn=null;function tS(){return Zn===null&&(Zn=new Jf(eS,16,16,gs,Ci),Zn.name="DFG_LUT",Zn.minFilter=Jt,Zn.magFilter=Jt,Zn.wrapS=Si,Zn.wrapT=Si,Zn.generateMipmaps=!1,Zn.needsUpdate=!0),Zn}class nS{constructor(e={}){const{canvas:t=Tm(),context:i=null,depth:s=!0,stencil:r=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:u="default",failIfMajorPerformanceCaveat:h=!1,reversedDepthBuffer:d=!1,outputBufferType:f=wn}=e;this.isWebGLRenderer=!0;let p;if(i!==null){if(typeof WebGLRenderingContext<"u"&&i instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");p=i.getContextAttributes().alpha}else p=a;const _=f,m=new Set([_u,gu,mu]),g=new Set([wn,di,Yr,Kr,fu,pu]),v=new Uint32Array(4),b=new Int32Array(4),x=new k;let E=null,S=null;const A=[],y=[];let T=null;this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=li,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const L=this;let R=!1,w=null,P=null,U=null,D=null;this._outputColorSpace=Sn;let K=0,B=0,ie=null,F=-1,se=null;const V=new Et,oe=new Et;let Ae=null;const me=new it(0);let ue=0,z=t.width,ee=t.height,Z=1,xe=null,be=null;const Se=new Et(0,0,z,ee),Oe=new Et(0,0,z,ee);let Ge=!1;const Ye=new jf;let Ke=!1,Be=!1;const Pe=new Rt,st=new k,mt=new Et,gt={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let ft=!1;function _t(){return ie===null?Z:1}let G=i;function nt(C,X){return t.getContext(C,X)}try{const C={alpha:!0,depth:s,stencil:r,antialias:o,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:u,failIfMajorPerformanceCaveat:h};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${hu}`),t.addEventListener("webglcontextlost",Ue,!1),t.addEventListener("webglcontextrestored",ve,!1),t.addEventListener("webglcontextcreationerror",qe,!1),G===null){const X="webgl2";if(G=nt(X,C),G===null)throw nt(X)?new Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes."):new Error("THREE.WebGLRenderer: Error creating WebGL context.")}}catch(C){throw ut("WebGLRenderer: "+C.message),C}let lt,I,M,q,te,Q,he,Te,ce,pe,Ee,We,H,ne,O,De,ye,N,ge,le,W,ae,$;function de(){lt=new ty(G),lt.init(),W=new Yv(G,lt),I=new K1(G,lt,e,W),M=new Wv(G,lt),I.reversedDepthBuffer&&d&&M.buffers.depth.setReversed(!0),P=G.createFramebuffer(),U=G.createFramebuffer(),D=G.createFramebuffer(),q=new sy(G),te=new Lv,Q=new Xv(G,lt,M,te,I,W,q),he=new ey(L),Te=new l_(G),ae=new X1(G,Te),ce=new ny(G,Te,q,ae),pe=new ay(G,ce,Te,ae,q),N=new ry(G,I,Q),O=new q1(te),Ee=new Rv(L,he,lt,I,ae,O),We=new jv(L,te),H=new Iv,ne=new Fv(lt),ye=new W1(L,he,M,pe,p,l),De=new Gv(L,pe,I),$=new Qv(G,q,I,M),ge=new Y1(G,lt,q),le=new iy(G,lt,q),q.programs=Ee.programs,L.capabilities=I,L.extensions=lt,L.properties=te,L.renderLists=H,L.shadowMap=De,L.state=M,L.info=q}de(),_!==wn&&(T=new ly(_,t.width,t.height,o,s,r));const fe=new Zv(L,G);this.xr=fe,this.getContext=function(){return G},this.getContextAttributes=function(){return G.getContextAttributes()},this.forceContextLoss=function(){const C=lt.get("WEBGL_lose_context");C&&C.loseContext()},this.forceContextRestore=function(){const C=lt.get("WEBGL_lose_context");C&&C.restoreContext()},this.getPixelRatio=function(){return Z},this.setPixelRatio=function(C){C!==void 0&&(Z=C,this.setSize(z,ee,!1))},this.getSize=function(C){return C.set(z,ee)},this.setSize=function(C,X,re=!0){if(fe.isPresenting){$e("WebGLRenderer: Can't change size while VR device is presenting.");return}z=C,ee=X,t.width=Math.floor(C*Z),t.height=Math.floor(X*Z),re===!0&&(t.style.width=C+"px",t.style.height=X+"px"),T!==null&&T.setSize(t.width,t.height),this.setViewport(0,0,C,X)},this.getDrawingBufferSize=function(C){return C.set(z*Z,ee*Z).floor()},this.setDrawingBufferSize=function(C,X,re){z=C,ee=X,Z=re,t.width=Math.floor(C*re),t.height=Math.floor(X*re),this.setViewport(0,0,C,X)},this.setEffects=function(C){if(_===wn){ut("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(C){for(let X=0;X<C.length;X++)if(C[X].isOutputPass===!0){$e("WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}}T.setEffects(C||[])},this.getCurrentViewport=function(C){return C.copy(V)},this.getViewport=function(C){return C.copy(Se)},this.setViewport=function(C,X,re,J){C.isVector4?Se.set(C.x,C.y,C.z,C.w):Se.set(C,X,re,J),M.viewport(V.copy(Se).multiplyScalar(Z).round())},this.getScissor=function(C){return C.copy(Oe)},this.setScissor=function(C,X,re,J){C.isVector4?Oe.set(C.x,C.y,C.z,C.w):Oe.set(C,X,re,J),M.scissor(oe.copy(Oe).multiplyScalar(Z).round())},this.getScissorTest=function(){return Ge},this.setScissorTest=function(C){M.setScissorTest(Ge=C)},this.setOpaqueSort=function(C){xe=C},this.setTransparentSort=function(C){be=C},this.getClearColor=function(C){return C.copy(ye.getClearColor())},this.setClearColor=function(){ye.setClearColor(...arguments)},this.getClearAlpha=function(){return ye.getClearAlpha()},this.setClearAlpha=function(){ye.setClearAlpha(...arguments)},this.clear=function(C=!0,X=!0,re=!0){let J=0;if(C){let j=!1;if(ie!==null){const Me=ie.texture.format;j=m.has(Me)}if(j){const Me=ie.texture.type,Ne=g.has(Me),Re=ye.getClearColor(),He=ye.getClearAlpha(),ke=Re.r,Je=Re.g,je=Re.b;Ne?(v[0]=ke,v[1]=Je,v[2]=je,v[3]=He,G.clearBufferuiv(G.COLOR,0,v)):(b[0]=ke,b[1]=Je,b[2]=je,b[3]=He,G.clearBufferiv(G.COLOR,0,b))}else J|=G.COLOR_BUFFER_BIT}X&&(J|=G.DEPTH_BUFFER_BIT,this.state.buffers.depth.setMask(!0)),re&&(J|=G.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),J!==0&&G.clear(J)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.setNodesHandler=function(C){C.setRenderer(this),w=C},this.dispose=function(){t.removeEventListener("webglcontextlost",Ue,!1),t.removeEventListener("webglcontextrestored",ve,!1),t.removeEventListener("webglcontextcreationerror",qe,!1),ye.dispose(),H.dispose(),ne.dispose(),te.dispose(),he.dispose(),pe.dispose(),ae.dispose(),$.dispose(),Ee.dispose(),fe.dispose(),fe.removeEventListener("sessionstart",pi),fe.removeEventListener("sessionend",Ri),Kn.stop()};function Ue(C){C.preventDefault(),Eo("WebGLRenderer: Context Lost."),R=!0}function ve(){Eo("WebGLRenderer: Context Restored."),R=!1;const C=q.autoReset,X=De.enabled,re=De.autoUpdate,J=De.needsUpdate,j=De.type;de(),q.autoReset=C,De.enabled=X,De.autoUpdate=re,De.needsUpdate=J,De.type=j}function qe(C){ut("WebGLRenderer: A WebGL context could not be created. Reason: ",C.statusMessage)}function ct(C){const X=C.target;X.removeEventListener("dispose",ct),an(X)}function an(C){Ct(C),te.remove(C)}function Ct(C){const X=te.get(C).programs;X!==void 0&&(X.forEach(function(re){Ee.releaseProgram(re)}),C.isShaderMaterial&&Ee.releaseShaderCache(C))}this.renderBufferDirect=function(C,X,re,J,j,Me){X===null&&(X=gt);const Ne=j.isMesh&&j.matrixWorld.determinantAffine()<0,Re=da(C,X,re,J,j);M.setMaterial(J,Ne);let He=re.index,ke=1;if(J.wireframe===!0){if(He=ce.getWireframeAttribute(re),He===void 0)return;ke=2}const Je=re.drawRange,je=re.attributes.position;let Xe=Je.start*ke,St=(Je.start+Je.count)*ke;Me!==null&&(Xe=Math.max(Xe,Me.start*ke),St=Math.min(St,(Me.start+Me.count)*ke)),He!==null?(Xe=Math.max(Xe,0),St=Math.min(St,He.count)):je!=null&&(Xe=Math.max(Xe,0),St=Math.min(St,je.count));const Ot=St-Xe;if(Ot<0||Ot===1/0)return;ae.setup(j,J,Re,re,He);let It,Mt=ge;if(He!==null&&(It=Te.get(He),Mt=le,Mt.setIndex(It)),j.isMesh)J.wireframe===!0?(M.setLineWidth(J.wireframeLinewidth*_t()),Mt.setMode(G.LINES)):Mt.setMode(G.TRIANGLES);else if(j.isLine){let Qt=J.linewidth;Qt===void 0&&(Qt=1),M.setLineWidth(Qt*_t()),j.isLineSegments?Mt.setMode(G.LINES):j.isLineLoop?Mt.setMode(G.LINE_LOOP):Mt.setMode(G.LINE_STRIP)}else j.isPoints?Mt.setMode(G.POINTS):j.isSprite&&Mt.setMode(G.TRIANGLES);if(j.isBatchedMesh)if(lt.get("WEBGL_multi_draw"))Mt.renderMultiDraw(j._multiDrawStarts,j._multiDrawCounts,j._multiDrawCount);else{const Qt=j._multiDrawStarts,Fe=j._multiDrawCounts,xn=j._multiDrawCount,ht=He?Te.get(He).bytesPerElement:1,En=te.get(J).currentProgram.getUniforms();for(let qn=0;qn<xn;qn++)En.setValue(G,"_gl_DrawID",qn),Mt.render(Qt[qn]/ht,Fe[qn])}else if(j.isInstancedMesh)Mt.renderInstances(Xe,Ot,j.count);else if(re.isInstancedBufferGeometry){const Qt=re._maxInstanceCount!==void 0?re._maxInstanceCount:1/0,Fe=Math.min(re.instanceCount,Qt);Mt.renderInstances(Xe,Ot,Fe)}else Mt.render(Xe,Ot)};function On(C,X,re){C.transparent===!0&&C.side===Yt&&C.forceSinglePass===!1?(C.side=_n,C.needsUpdate=!0,vr(C,X,re),C.side=Zi,C.needsUpdate=!0,vr(C,X,re),C.side=Yt):vr(C,X,re)}this.compile=function(C,X,re=null){re===null&&(re=C),S=ne.get(re),S.init(X),y.push(S),re.traverseVisible(function(j){j.isLight&&j.layers.test(X.layers)&&(S.pushLight(j),j.castShadow&&S.pushShadow(j))}),C!==re&&C.traverseVisible(function(j){j.isLight&&j.layers.test(X.layers)&&(S.pushLight(j),j.castShadow&&S.pushShadow(j))}),S.setupLights();const J=new Set;return C.traverse(function(j){if(!(j.isMesh||j.isPoints||j.isLine||j.isSprite))return;const Me=j.material;if(Me)if(Array.isArray(Me))for(let Ne=0;Ne<Me.length;Ne++){const Re=Me[Ne];On(Re,re,j),J.add(Re)}else On(Me,re,j),J.add(Me)}),S=y.pop(),J},this.compileAsync=function(C,X,re=null){const J=this.compile(C,X,re);return new Promise(j=>{function Me(){if(J.forEach(function(Ne){te.get(Ne).currentProgram.isReady()&&J.delete(Ne)}),J.size===0){j(C);return}setTimeout(Me,10)}lt.get("KHR_parallel_shader_compile")!==null?Me():setTimeout(Me,10)})};let Un=null;function An(C){Un&&Un(C)}function pi(){Kn.stop()}function Ri(){Kn.start()}const Kn=new fp;Kn.setAnimationLoop(An),typeof self<"u"&&Kn.setContext(self),this.setAnimationLoop=function(C){Un=C,fe.setAnimationLoop(C),C===null?Kn.stop():Kn.start()},fe.addEventListener("sessionstart",pi),fe.addEventListener("sessionend",Ri),this.render=function(C,X){if(X!==void 0&&X.isCamera!==!0){ut("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(R===!0)return;w!==null&&w.renderStart(C,X);const re=fe.enabled===!0&&fe.isPresenting===!0,J=T!==null&&(ie===null||re)&&T.begin(L,ie);if(C.matrixWorldAutoUpdate===!0&&C.updateMatrixWorld(),X.parent===null&&X.matrixWorldAutoUpdate===!0&&X.updateMatrixWorld(),fe.enabled===!0&&fe.isPresenting===!0&&(T===null||T.isCompositing()===!1)&&(fe.cameraAutoUpdate===!0&&fe.updateCamera(X),X=fe.getCamera()),C.isScene===!0&&C.onBeforeRender(L,C,X,ie),S=ne.get(C,y.length),S.init(X),S.state.textureUnits=Q.getTextureUnits(),y.push(S),Pe.multiplyMatrices(X.projectionMatrix,X.matrixWorldInverse),Ye.setFromProjectionMatrix(Pe,ri,X.reversedDepth),Be=this.localClippingEnabled,Ke=O.init(this.clippingPlanes,Be),E=H.get(C,A.length),E.init(),A.push(E),fe.enabled===!0&&fe.isPresenting===!0){const Ne=L.xr.getDepthSensingMesh();Ne!==null&&yr(Ne,X,-1/0,L.sortObjects)}yr(C,X,0,L.sortObjects),E.finish(),L.sortObjects===!0&&E.sort(xe,be,X.reversedDepth),ft=fe.enabled===!1||fe.isPresenting===!1||fe.hasDepthSensing()===!1,ft&&ye.addToRenderList(E,C),this.info.render.frame++,this.info.autoReset===!0&&this.info.reset(),Ke===!0&&O.beginShadows();const j=S.state.shadowsArray;if(De.render(j,C,X),Ke===!0&&O.endShadows(),(J&&T.hasRenderPass())===!1){const Ne=E.opaque,Re=E.transmissive;if(S.setupLights(),X.isArrayCamera){const He=X.cameras;if(Re.length>0)for(let ke=0,Je=He.length;ke<Je;ke++){const je=He[ke];As(Ne,Re,C,je)}ft&&ye.render(C);for(let ke=0,Je=He.length;ke<Je;ke++){const je=He[ke];ua(E,C,je,je.viewport)}}else Re.length>0&&As(Ne,Re,C,X),ft&&ye.render(C),ua(E,C,X)}ie!==null&&B===0&&(Q.updateMultisampleRenderTarget(ie),Q.updateRenderTargetMipmap(ie)),J&&T.end(L),C.isScene===!0&&C.onAfterRender(L,C,X),ae.resetDefaultState(),F=-1,se=null,y.pop(),y.length>0?(S=y[y.length-1],Q.setTextureUnits(S.state.textureUnits),Ke===!0&&O.setGlobalState(L.clippingPlanes,S.state.camera)):S=null,A.pop(),A.length>0?E=A[A.length-1]:E=null,w!==null&&w.renderEnd()};function yr(C,X,re,J){if(C.visible===!1)return;if(C.layers.test(X.layers)){if(C.isGroup)re=C.renderOrder;else if(C.isLOD)C.autoUpdate===!0&&C.update(X);else if(C.isLightProbeGrid)S.pushLightProbeGrid(C);else if(C.isLight)S.pushLight(C),C.castShadow&&S.pushShadow(C);else if(C.isSprite){if(!C.frustumCulled||Ye.intersectsSprite(C)){J&&mt.setFromMatrixPosition(C.matrixWorld).applyMatrix4(Pe);const Ne=pe.update(C),Re=C.material;Re.visible&&E.push(C,Ne,Re,re,mt.z,null)}}else if((C.isMesh||C.isLine||C.isPoints)&&(!C.frustumCulled||Ye.intersectsObject(C))){const Ne=pe.update(C),Re=C.material;if(J&&(C.boundingSphere!==void 0?(C.boundingSphere===null&&C.computeBoundingSphere(),mt.copy(C.boundingSphere.center)):(Ne.boundingSphere===null&&Ne.computeBoundingSphere(),mt.copy(Ne.boundingSphere.center)),mt.applyMatrix4(C.matrixWorld).applyMatrix4(Pe)),Array.isArray(Re)){const He=Ne.groups;for(let ke=0,Je=He.length;ke<Je;ke++){const je=He[ke],Xe=Re[je.materialIndex];Xe&&Xe.visible&&E.push(C,Ne,Xe,re,mt.z,je)}}else Re.visible&&E.push(C,Ne,Re,re,mt.z,null)}}const Me=C.children;for(let Ne=0,Re=Me.length;Ne<Re;Ne++)yr(Me[Ne],X,re,J)}function ua(C,X,re,J){const{opaque:j,transmissive:Me,transparent:Ne}=C;S.setupLightsView(re),Ke===!0&&O.setGlobalState(L.clippingPlanes,re),J&&M.viewport(V.copy(J)),j.length>0&&on(j,X,re),Me.length>0&&on(Me,X,re),Ne.length>0&&on(Ne,X,re),M.buffers.depth.setTest(!0),M.buffers.depth.setMask(!0),M.buffers.color.setMask(!0),M.setPolygonOffset(!1)}function As(C,X,re,J){if((re.isScene===!0?re.overrideMaterial:null)!==null)return;if(S.state.transmissionRenderTarget[J.id]===void 0){const Xe=lt.has("EXT_color_buffer_half_float")||lt.has("EXT_color_buffer_float");S.state.transmissionRenderTarget[J.id]=new ui(1,1,{generateMipmaps:!0,type:Xe?Ci:wn,minFilter:Yi,samples:Math.max(4,I.samples),stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:at.workingColorSpace})}const Me=S.state.transmissionRenderTarget[J.id],Ne=J.viewport||V;Me.setSize(Ne.z*L.transmissionResolutionScale,Ne.w*L.transmissionResolutionScale);const Re=L.getRenderTarget(),He=L.getActiveCubeFace(),ke=L.getActiveMipmapLevel();L.setRenderTarget(Me),L.getClearColor(me),ue=L.getClearAlpha(),ue<1&&L.setClearColor(16777215,.5),L.clear(),ft&&ye.render(re);const Je=L.toneMapping;L.toneMapping=li;const je=J.viewport;if(J.viewport!==void 0&&(J.viewport=void 0),S.setupLightsView(J),Ke===!0&&O.setGlobalState(L.clippingPlanes,J),on(C,re,J),Q.updateMultisampleRenderTarget(Me),Q.updateRenderTargetMipmap(Me),lt.has("WEBGL_multisampled_render_to_texture")===!1){let Xe=!1;for(let St=0,Ot=X.length;St<Ot;St++){const It=X[St],{object:Mt,geometry:Qt,material:Fe,group:xn}=It;if(Fe.side===Yt&&Mt.layers.test(J.layers)){const ht=Fe.side;Fe.side=_n,Fe.needsUpdate=!0,ts(Mt,re,J,Qt,Fe,xn),Fe.side=ht,Fe.needsUpdate=!0,Xe=!0}}Xe===!0&&(Q.updateMultisampleRenderTarget(Me),Q.updateRenderTargetMipmap(Me))}L.setRenderTarget(Re,He,ke),L.setClearColor(me,ue),je!==void 0&&(J.viewport=je),L.toneMapping=Je}function on(C,X,re){const J=X.isScene===!0?X.overrideMaterial:null;for(let j=0,Me=C.length;j<Me;j++){const Ne=C[j],{object:Re,geometry:He,group:ke}=Ne;let Je=Ne.material;Je.allowOverride===!0&&J!==null&&(Je=J),Re.layers.test(re.layers)&&ts(Re,X,re,He,Je,ke)}}function ts(C,X,re,J,j,Me){C.onBeforeRender(L,X,re,J,j,Me),C.modelViewMatrix.multiplyMatrices(re.matrixWorldInverse,C.matrixWorld),C.normalMatrix.getNormalMatrix(C.modelViewMatrix),j.onBeforeRender(L,X,re,J,C,Me),j.transparent===!0&&j.side===Yt&&j.forceSinglePass===!1?(j.side=_n,j.needsUpdate=!0,L.renderBufferDirect(re,X,J,j,C,Me),j.side=Zi,j.needsUpdate=!0,L.renderBufferDirect(re,X,J,j,C,Me),j.side=Yt):L.renderBufferDirect(re,X,J,j,C,Me),C.onAfterRender(L,X,re,J,j,Me)}function vr(C,X,re){X.isScene!==!0&&(X=gt);const J=te.get(C),j=S.state.lights,Me=S.state.shadowsArray,Ne=j.state.version,Re=Ee.getParameters(C,j.state,Me,X,re,S.state.lightProbeGridArray),He=Ee.getProgramCacheKey(Re);let ke=J.programs;J.environment=C.isMeshStandardMaterial||C.isMeshLambertMaterial||C.isMeshPhongMaterial?X.environment:null,J.fog=X.fog;const Je=C.isMeshStandardMaterial||C.isMeshLambertMaterial&&!C.envMap||C.isMeshPhongMaterial&&!C.envMap;J.envMap=he.get(C.envMap||J.environment,Je),J.envMapRotation=J.environment!==null&&C.envMap===null?X.environmentRotation:C.envMapRotation,ke===void 0&&(C.addEventListener("dispose",ct),ke=new Map,J.programs=ke);let je=ke.get(He);if(je!==void 0){if(J.currentProgram===je&&J.lightsStateVersion===Ne)return Nn(C,Re),je}else Re.uniforms=Ee.getUniforms(C),w!==null&&C.isNodeMaterial&&w.build(C,re,Re),C.onBeforeCompile(Re,L),je=Ee.acquireProgram(Re,He),ke.set(He,je),J.uniforms=Re.uniforms;const Xe=J.uniforms;return(!C.isShaderMaterial&&!C.isRawShaderMaterial||C.clipping===!0)&&(Xe.clippingPlanes=O.uniform),Nn(C,Re),J.needsLights=fa(C),J.lightsStateVersion=Ne,J.needsLights&&(Xe.ambientLightColor.value=j.state.ambient,Xe.lightProbe.value=j.state.probe,Xe.directionalLights.value=j.state.directional,Xe.directionalLightShadows.value=j.state.directionalShadow,Xe.spotLights.value=j.state.spot,Xe.spotLightShadows.value=j.state.spotShadow,Xe.rectAreaLights.value=j.state.rectArea,Xe.ltc_1.value=j.state.rectAreaLTC1,Xe.ltc_2.value=j.state.rectAreaLTC2,Xe.pointLights.value=j.state.point,Xe.pointLightShadows.value=j.state.pointShadow,Xe.hemisphereLights.value=j.state.hemi,Xe.directionalShadowMatrix.value=j.state.directionalShadowMatrix,Xe.spotLightMatrix.value=j.state.spotLightMatrix,Xe.spotLightMap.value=j.state.spotLightMap,Xe.pointShadowMatrix.value=j.state.pointShadowMatrix),J.lightProbeGrid=S.state.lightProbeGridArray.length>0,J.currentProgram=je,J.uniformsList=null,je}function Sr(C){if(C.uniformsList===null){const X=C.currentProgram.getUniforms();C.uniformsList=po.seqWithValue(X.seq,C.uniforms)}return C.uniformsList}function Nn(C,X){const re=te.get(C);re.outputColorSpace=X.outputColorSpace,re.batching=X.batching,re.batchingColor=X.batchingColor,re.instancing=X.instancing,re.instancingColor=X.instancingColor,re.instancingMorph=X.instancingMorph,re.skinning=X.skinning,re.morphTargets=X.morphTargets,re.morphNormals=X.morphNormals,re.morphColors=X.morphColors,re.morphTargetsCount=X.morphTargetsCount,re.numClippingPlanes=X.numClippingPlanes,re.numIntersection=X.numClipIntersection,re.vertexAlphas=X.vertexAlphas,re.vertexTangents=X.vertexTangents,re.toneMapping=X.toneMapping}function ha(C,X){if(C.length===0)return null;if(C.length===1)return C[0].texture!==null?C[0]:null;x.setFromMatrixPosition(X.matrixWorld);for(let re=0,J=C.length;re<J;re++){const j=C[re];if(j.texture!==null&&j.boundingBox.containsPoint(x))return j}return null}function da(C,X,re,J,j){X.isScene!==!0&&(X=gt),Q.resetTextureUnits();const Me=X.fog,Ne=J.isMeshStandardMaterial||J.isMeshLambertMaterial||J.isMeshPhongMaterial?X.environment:null,Re=ie===null?L.outputColorSpace:ie.isXRRenderTarget===!0?ie.texture.colorSpace:at.workingColorSpace,He=J.isMeshStandardMaterial||J.isMeshLambertMaterial&&!J.envMap||J.isMeshPhongMaterial&&!J.envMap,ke=he.get(J.envMap||Ne,He),Je=J.vertexColors===!0&&!!re.attributes.color&&re.attributes.color.itemSize===4,je=!!re.attributes.tangent&&(!!J.normalMap||J.anisotropy>0),Xe=!!re.morphAttributes.position,St=!!re.morphAttributes.normal,Ot=!!re.morphAttributes.color;let It=li;J.toneMapped&&(ie===null||ie.isXRRenderTarget===!0)&&(It=L.toneMapping);const Mt=re.morphAttributes.position||re.morphAttributes.normal||re.morphAttributes.color,Qt=Mt!==void 0?Mt.length:0,Fe=te.get(J),xn=S.state.lights;if(Ke===!0&&(Be===!0||C!==se)){const Tt=C===se&&J.id===F;O.setState(J,C,Tt)}let ht=!1;J.version===Fe.__version?(Fe.needsLights&&Fe.lightsStateVersion!==xn.state.version||Fe.outputColorSpace!==Re||j.isBatchedMesh&&Fe.batching===!1||!j.isBatchedMesh&&Fe.batching===!0||j.isBatchedMesh&&Fe.batchingColor===!0&&j.colorTexture===null||j.isBatchedMesh&&Fe.batchingColor===!1&&j.colorTexture!==null||j.isInstancedMesh&&Fe.instancing===!1||!j.isInstancedMesh&&Fe.instancing===!0||j.isSkinnedMesh&&Fe.skinning===!1||!j.isSkinnedMesh&&Fe.skinning===!0||j.isInstancedMesh&&Fe.instancingColor===!0&&j.instanceColor===null||j.isInstancedMesh&&Fe.instancingColor===!1&&j.instanceColor!==null||j.isInstancedMesh&&Fe.instancingMorph===!0&&j.morphTexture===null||j.isInstancedMesh&&Fe.instancingMorph===!1&&j.morphTexture!==null||Fe.envMap!==ke||J.fog===!0&&Fe.fog!==Me||Fe.numClippingPlanes!==void 0&&(Fe.numClippingPlanes!==O.numPlanes||Fe.numIntersection!==O.numIntersection)||Fe.vertexAlphas!==Je||Fe.vertexTangents!==je||Fe.morphTargets!==Xe||Fe.morphNormals!==St||Fe.morphColors!==Ot||Fe.toneMapping!==It||Fe.morphTargetsCount!==Qt||!!Fe.lightProbeGrid!=S.state.lightProbeGridArray.length>0)&&(ht=!0):(ht=!0,Fe.__version=J.version);let En=Fe.currentProgram;ht===!0&&(En=vr(J,X,j),w&&J.isNodeMaterial&&w.onUpdateProgram(J,En,Fe));let qn=!1,Di=!1,Es=!1;const At=En.getUniforms(),Ut=Fe.uniforms;if(M.useProgram(En.program)&&(qn=!0,Di=!0,Es=!0),J.id!==F&&(F=J.id,Di=!0),Fe.needsLights){const Tt=ha(S.state.lightProbeGridArray,j);Fe.lightProbeGrid!==Tt&&(Fe.lightProbeGrid=Tt,Di=!0)}if(qn||se!==C){M.buffers.depth.getReversed()&&C.reversedDepth!==!0&&(C._reversedDepth=!0,C.updateProjectionMatrix()),At.setValue(G,"projectionMatrix",C.projectionMatrix),At.setValue(G,"viewMatrix",C.matrixWorldInverse);const Pi=At.map.cameraPosition;Pi!==void 0&&Pi.setValue(G,st.setFromMatrixPosition(C.matrixWorld)),I.logarithmicDepthBuffer&&At.setValue(G,"logDepthBufFC",2/(Math.log(C.far+1)/Math.LN2)),(J.isMeshPhongMaterial||J.isMeshToonMaterial||J.isMeshLambertMaterial||J.isMeshBasicMaterial||J.isMeshStandardMaterial||J.isShaderMaterial)&&At.setValue(G,"isOrthographic",C.isOrthographicCamera===!0),se!==C&&(se=C,Di=!0,Es=!0)}if(Fe.needsLights&&(xn.state.directionalShadowMap.length>0&&At.setValue(G,"directionalShadowMap",xn.state.directionalShadowMap,Q),xn.state.spotShadowMap.length>0&&At.setValue(G,"spotShadowMap",xn.state.spotShadowMap,Q),xn.state.pointShadowMap.length>0&&At.setValue(G,"pointShadowMap",xn.state.pointShadowMap,Q)),j.isSkinnedMesh){At.setOptional(G,j,"bindMatrix"),At.setOptional(G,j,"bindMatrixInverse");const Tt=j.skeleton;Tt&&(Tt.boneTexture===null&&Tt.computeBoneTexture(),At.setValue(G,"boneTexture",Tt.boneTexture,Q))}j.isBatchedMesh&&(At.setOptional(G,j,"batchingTexture"),At.setValue(G,"batchingTexture",j._matricesTexture,Q),At.setOptional(G,j,"batchingIdTexture"),At.setValue(G,"batchingIdTexture",j._indirectTexture,Q),At.setOptional(G,j,"batchingColorTexture"),j._colorsTexture!==null&&At.setValue(G,"batchingColorTexture",j._colorsTexture,Q));const Ii=re.morphAttributes;if((Ii.position!==void 0||Ii.normal!==void 0||Ii.color!==void 0)&&N.update(j,re,En),(Di||Fe.receiveShadow!==j.receiveShadow)&&(Fe.receiveShadow=j.receiveShadow,At.setValue(G,"receiveShadow",j.receiveShadow)),(J.isMeshStandardMaterial||J.isMeshLambertMaterial||J.isMeshPhongMaterial)&&J.envMap===null&&X.environment!==null&&(Ut.envMapIntensity.value=X.environmentIntensity),Ut.dfgLUT!==void 0&&(Ut.dfgLUT.value=tS()),Di){if(At.setValue(G,"toneMappingExposure",L.toneMappingExposure),Fe.needsLights&&Li(Ut,Es),Me&&J.fog===!0&&We.refreshFogUniforms(Ut,Me),We.refreshMaterialUniforms(Ut,J,Z,ee,S.state.transmissionRenderTarget[C.id]),Fe.needsLights&&Fe.lightProbeGrid){const Tt=Fe.lightProbeGrid;Ut.probesSH.value=Tt.texture,Ut.probesMin.value.copy(Tt.boundingBox.min),Ut.probesMax.value.copy(Tt.boundingBox.max),Ut.probesResolution.value.copy(Tt.resolution)}po.upload(G,Sr(Fe),Ut,Q)}if(J.isShaderMaterial&&J.uniformsNeedUpdate===!0&&(po.upload(G,Sr(Fe),Ut,Q),J.uniformsNeedUpdate=!1),J.isSpriteMaterial&&At.setValue(G,"center",j.center),At.setValue(G,"modelViewMatrix",j.modelViewMatrix),At.setValue(G,"normalMatrix",j.normalMatrix),At.setValue(G,"modelMatrix",j.matrixWorld),J.uniformsGroups!==void 0){const Tt=J.uniformsGroups;for(let Pi=0,Ts=Tt.length;Pi<Ts;Pi++){const Zu=Tt[Pi];$.update(Zu,En),$.bind(Zu,En)}}return En}function Li(C,X){C.ambientLightColor.needsUpdate=X,C.lightProbe.needsUpdate=X,C.directionalLights.needsUpdate=X,C.directionalLightShadows.needsUpdate=X,C.pointLights.needsUpdate=X,C.pointLightShadows.needsUpdate=X,C.spotLights.needsUpdate=X,C.spotLightShadows.needsUpdate=X,C.rectAreaLights.needsUpdate=X,C.hemisphereLights.needsUpdate=X}function fa(C){return C.isMeshLambertMaterial||C.isMeshToonMaterial||C.isMeshPhongMaterial||C.isMeshStandardMaterial||C.isShadowMaterial||C.isShaderMaterial&&C.lights===!0}this.getActiveCubeFace=function(){return K},this.getActiveMipmapLevel=function(){return B},this.getRenderTarget=function(){return ie},this.setRenderTargetTextures=function(C,X,re){const J=te.get(C);J.__autoAllocateDepthBuffer=C.resolveDepthBuffer===!1,J.__autoAllocateDepthBuffer===!1&&(J.__useRenderToTexture=!1),te.get(C.texture).__webglTexture=X,te.get(C.depthTexture).__webglTexture=J.__autoAllocateDepthBuffer?void 0:re,J.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(C,X){const re=te.get(C);re.__webglFramebuffer=X,re.__useDefaultFramebuffer=X===void 0},this.setRenderTarget=function(C,X=0,re=0){ie=C,K=X,B=re;let J=null,j=!1,Me=!1;if(C){const Re=te.get(C);if(Re.__useDefaultFramebuffer!==void 0){M.bindFramebuffer(G.FRAMEBUFFER,Re.__webglFramebuffer),V.copy(C.viewport),oe.copy(C.scissor),Ae=C.scissorTest,M.viewport(V),M.scissor(oe),M.setScissorTest(Ae),F=-1;return}else if(Re.__webglFramebuffer===void 0)Q.setupRenderTarget(C);else if(Re.__hasExternalTextures)Q.rebindTextures(C,te.get(C.texture).__webglTexture,te.get(C.depthTexture).__webglTexture);else if(C.depthBuffer){const Je=C.depthTexture;if(Re.__boundDepthTexture!==Je){if(Je!==null&&te.has(Je)&&(C.width!==Je.image.width||C.height!==Je.image.height))throw new Error("THREE.WebGLRenderer: Attached DepthTexture is initialized to the incorrect size.");Q.setupDepthRenderbuffer(C)}}const He=C.texture;(He.isData3DTexture||He.isDataArrayTexture||He.isCompressedArrayTexture)&&(Me=!0);const ke=te.get(C).__webglFramebuffer;C.isWebGLCubeRenderTarget?(Array.isArray(ke[X])?J=ke[X][re]:J=ke[X],j=!0):C.samples>0&&Q.useMultisampledRTT(C)===!1?J=te.get(C).__webglMultisampledFramebuffer:Array.isArray(ke)?J=ke[re]:J=ke,V.copy(C.viewport),oe.copy(C.scissor),Ae=C.scissorTest}else V.copy(Se).multiplyScalar(Z).floor(),oe.copy(Oe).multiplyScalar(Z).floor(),Ae=Ge;if(re!==0&&(J=P),M.bindFramebuffer(G.FRAMEBUFFER,J)&&M.drawBuffers(C,J),M.viewport(V),M.scissor(oe),M.setScissorTest(Ae),j){const Re=te.get(C.texture);G.framebufferTexture2D(G.FRAMEBUFFER,G.COLOR_ATTACHMENT0,G.TEXTURE_CUBE_MAP_POSITIVE_X+X,Re.__webglTexture,re)}else if(Me){const Re=X;for(let He=0;He<C.textures.length;He++){const ke=te.get(C.textures[He]);G.framebufferTextureLayer(G.FRAMEBUFFER,G.COLOR_ATTACHMENT0+He,ke.__webglTexture,re,Re)}}else if(C!==null&&re!==0){const Re=te.get(C.texture);G.framebufferTexture2D(G.FRAMEBUFFER,G.COLOR_ATTACHMENT0,G.TEXTURE_2D,Re.__webglTexture,re)}F=-1},this.readRenderTargetPixels=function(C,X,re,J,j,Me,Ne,Re=0){if(!(C&&C.isWebGLRenderTarget)){ut("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let He=te.get(C).__webglFramebuffer;if(C.isWebGLCubeRenderTarget&&Ne!==void 0&&(He=He[Ne]),He){M.bindFramebuffer(G.FRAMEBUFFER,He);try{const ke=C.textures[Re],Je=ke.format,je=ke.type;if(C.textures.length>1&&G.readBuffer(G.COLOR_ATTACHMENT0+Re),!I.textureFormatReadable(Je)){ut("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!I.textureTypeReadable(je)){ut("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}X>=0&&X<=C.width-J&&re>=0&&re<=C.height-j&&G.readPixels(X,re,J,j,W.convert(Je),W.convert(je),Me)}finally{const ke=ie!==null?te.get(ie).__webglFramebuffer:null;M.bindFramebuffer(G.FRAMEBUFFER,ke)}}},this.readRenderTargetPixelsAsync=async function(C,X,re,J,j,Me,Ne,Re=0){if(!(C&&C.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let He=te.get(C).__webglFramebuffer;if(C.isWebGLCubeRenderTarget&&Ne!==void 0&&(He=He[Ne]),He)if(X>=0&&X<=C.width-J&&re>=0&&re<=C.height-j){M.bindFramebuffer(G.FRAMEBUFFER,He);const ke=C.textures[Re],Je=ke.format,je=ke.type;if(C.textures.length>1&&G.readBuffer(G.COLOR_ATTACHMENT0+Re),!I.textureFormatReadable(Je))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!I.textureTypeReadable(je))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const Xe=G.createBuffer();G.bindBuffer(G.PIXEL_PACK_BUFFER,Xe),G.bufferData(G.PIXEL_PACK_BUFFER,Me.byteLength,G.STREAM_READ),G.readPixels(X,re,J,j,W.convert(Je),W.convert(je),0);const St=ie!==null?te.get(ie).__webglFramebuffer:null;M.bindFramebuffer(G.FRAMEBUFFER,St);const Ot=G.fenceSync(G.SYNC_GPU_COMMANDS_COMPLETE,0);return G.flush(),await Cm(G,Ot,4),G.bindBuffer(G.PIXEL_PACK_BUFFER,Xe),G.getBufferSubData(G.PIXEL_PACK_BUFFER,0,Me),G.deleteBuffer(Xe),G.deleteSync(Ot),Me}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(C,X=null,re=0){const J=Math.pow(2,-re),j=Math.floor(C.image.width*J),Me=Math.floor(C.image.height*J),Ne=X!==null?X.x:0,Re=X!==null?X.y:0;Q.setTexture2D(C,0),G.copyTexSubImage2D(G.TEXTURE_2D,re,0,0,Ne,Re,j,Me),M.unbindTexture()},this.copyTextureToTexture=function(C,X,re=null,J=null,j=0,Me=0){let Ne,Re,He,ke,Je,je,Xe,St,Ot;const It=C.isCompressedTexture?C.mipmaps[Me]:C.image;if(re!==null)Ne=re.max.x-re.min.x,Re=re.max.y-re.min.y,He=re.isBox3?re.max.z-re.min.z:1,ke=re.min.x,Je=re.min.y,je=re.isBox3?re.min.z:0;else{const Ut=Math.pow(2,-j);Ne=Math.floor(It.width*Ut),Re=Math.floor(It.height*Ut),C.isDataArrayTexture?He=It.depth:C.isData3DTexture?He=Math.floor(It.depth*Ut):He=1,ke=0,Je=0,je=0}J!==null?(Xe=J.x,St=J.y,Ot=J.z):(Xe=0,St=0,Ot=0);const Mt=W.convert(X.format),Qt=W.convert(X.type);let Fe;X.isData3DTexture?(Q.setTexture3D(X,0),Fe=G.TEXTURE_3D):X.isDataArrayTexture||X.isCompressedArrayTexture?(Q.setTexture2DArray(X,0),Fe=G.TEXTURE_2D_ARRAY):(Q.setTexture2D(X,0),Fe=G.TEXTURE_2D),M.activeTexture(G.TEXTURE0),M.pixelStorei(G.UNPACK_FLIP_Y_WEBGL,X.flipY),M.pixelStorei(G.UNPACK_PREMULTIPLY_ALPHA_WEBGL,X.premultiplyAlpha),M.pixelStorei(G.UNPACK_ALIGNMENT,X.unpackAlignment);const xn=M.getParameter(G.UNPACK_ROW_LENGTH),ht=M.getParameter(G.UNPACK_IMAGE_HEIGHT),En=M.getParameter(G.UNPACK_SKIP_PIXELS),qn=M.getParameter(G.UNPACK_SKIP_ROWS),Di=M.getParameter(G.UNPACK_SKIP_IMAGES);M.pixelStorei(G.UNPACK_ROW_LENGTH,It.width),M.pixelStorei(G.UNPACK_IMAGE_HEIGHT,It.height),M.pixelStorei(G.UNPACK_SKIP_PIXELS,ke),M.pixelStorei(G.UNPACK_SKIP_ROWS,Je),M.pixelStorei(G.UNPACK_SKIP_IMAGES,je);const Es=C.isDataArrayTexture||C.isData3DTexture,At=X.isDataArrayTexture||X.isData3DTexture;if(C.isDepthTexture){const Ut=te.get(C),Ii=te.get(X),Tt=te.get(Ut.__renderTarget),Pi=te.get(Ii.__renderTarget);M.bindFramebuffer(G.READ_FRAMEBUFFER,Tt.__webglFramebuffer),M.bindFramebuffer(G.DRAW_FRAMEBUFFER,Pi.__webglFramebuffer);for(let Ts=0;Ts<He;Ts++)Es&&(G.framebufferTextureLayer(G.READ_FRAMEBUFFER,G.COLOR_ATTACHMENT0,te.get(C).__webglTexture,j,je+Ts),G.framebufferTextureLayer(G.DRAW_FRAMEBUFFER,G.COLOR_ATTACHMENT0,te.get(X).__webglTexture,Me,Ot+Ts)),G.blitFramebuffer(ke,Je,Ne,Re,Xe,St,Ne,Re,G.DEPTH_BUFFER_BIT,G.NEAREST);M.bindFramebuffer(G.READ_FRAMEBUFFER,null),M.bindFramebuffer(G.DRAW_FRAMEBUFFER,null)}else if(j!==0||C.isRenderTargetTexture||te.has(C)){const Ut=te.get(C),Ii=te.get(X);M.bindFramebuffer(G.READ_FRAMEBUFFER,U),M.bindFramebuffer(G.DRAW_FRAMEBUFFER,D);for(let Tt=0;Tt<He;Tt++)Es?G.framebufferTextureLayer(G.READ_FRAMEBUFFER,G.COLOR_ATTACHMENT0,Ut.__webglTexture,j,je+Tt):G.framebufferTexture2D(G.READ_FRAMEBUFFER,G.COLOR_ATTACHMENT0,G.TEXTURE_2D,Ut.__webglTexture,j),At?G.framebufferTextureLayer(G.DRAW_FRAMEBUFFER,G.COLOR_ATTACHMENT0,Ii.__webglTexture,Me,Ot+Tt):G.framebufferTexture2D(G.DRAW_FRAMEBUFFER,G.COLOR_ATTACHMENT0,G.TEXTURE_2D,Ii.__webglTexture,Me),j!==0?G.blitFramebuffer(ke,Je,Ne,Re,Xe,St,Ne,Re,G.COLOR_BUFFER_BIT,G.NEAREST):At?G.copyTexSubImage3D(Fe,Me,Xe,St,Ot+Tt,ke,Je,Ne,Re):G.copyTexSubImage2D(Fe,Me,Xe,St,ke,Je,Ne,Re);M.bindFramebuffer(G.READ_FRAMEBUFFER,null),M.bindFramebuffer(G.DRAW_FRAMEBUFFER,null)}else At?C.isDataTexture||C.isData3DTexture?G.texSubImage3D(Fe,Me,Xe,St,Ot,Ne,Re,He,Mt,Qt,It.data):X.isCompressedArrayTexture?G.compressedTexSubImage3D(Fe,Me,Xe,St,Ot,Ne,Re,He,Mt,It.data):G.texSubImage3D(Fe,Me,Xe,St,Ot,Ne,Re,He,Mt,Qt,It):C.isDataTexture?G.texSubImage2D(G.TEXTURE_2D,Me,Xe,St,Ne,Re,Mt,Qt,It.data):C.isCompressedTexture?G.compressedTexSubImage2D(G.TEXTURE_2D,Me,Xe,St,It.width,It.height,Mt,It.data):G.texSubImage2D(G.TEXTURE_2D,Me,Xe,St,Ne,Re,Mt,Qt,It);M.pixelStorei(G.UNPACK_ROW_LENGTH,xn),M.pixelStorei(G.UNPACK_IMAGE_HEIGHT,ht),M.pixelStorei(G.UNPACK_SKIP_PIXELS,En),M.pixelStorei(G.UNPACK_SKIP_ROWS,qn),M.pixelStorei(G.UNPACK_SKIP_IMAGES,Di),Me===0&&X.generateMipmaps&&G.generateMipmap(Fe),M.unbindTexture()},this.initRenderTarget=function(C){te.get(C).__webglFramebuffer===void 0&&Q.setupRenderTarget(C)},this.initTexture=function(C){C.isCubeTexture?Q.setTextureCube(C,0):C.isData3DTexture?Q.setTexture3D(C,0):C.isDataArrayTexture||C.isCompressedArrayTexture?Q.setTexture2DArray(C,0):Q.setTexture2D(C,0),M.unbindTexture()},this.resetState=function(){K=0,B=0,ie=null,M.reset(),ae.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return ri}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const t=this.getContext();t.drawingBufferColorSpace=at._getDrawingBufferColorSpace(e),t.unpackColorSpace=at._getUnpackColorSpace()}}const hd={type:"change"},wu={type:"start"},Sp={type:"end"},Ya=new bu,dd=new Vi,iS=Math.cos(70*Gf.DEG2RAD),Bt=new k,fn=2*Math.PI,bt={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},Nl=1e-6;class sS extends a_{constructor(e,t=null){super(e,t),this.state=bt.NONE,this.target=new k,this.cursor=new k,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.keyRotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:Mi.ROTATE,MIDDLE:Mi.DOLLY,RIGHT:Mi.PAN},this.touches={ONE:Xi.ROTATE,TWO:Xi.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._cursorStyle="auto",this._domElementKeyEvents=null,this._lastPosition=new k,this._lastQuaternion=new Ji,this._lastTargetPosition=new k,this._quat=new Ji().setFromUnitVectors(e.up,new k(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new Fh,this._sphericalDelta=new Fh,this._scale=1,this._panOffset=new k,this._rotateStart=new Le,this._rotateEnd=new Le,this._rotateDelta=new Le,this._panStart=new Le,this._panEnd=new Le,this._panDelta=new Le,this._dollyStart=new Le,this._dollyEnd=new Le,this._dollyDelta=new Le,this._dollyDirection=new k,this._mouse=new Le,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=aS.bind(this),this._onPointerDown=rS.bind(this),this._onPointerUp=oS.bind(this),this._onContextMenu=pS.bind(this),this._onMouseWheel=uS.bind(this),this._onKeyDown=hS.bind(this),this._onTouchStart=dS.bind(this),this._onTouchMove=fS.bind(this),this._onMouseDown=lS.bind(this),this._onMouseMove=cS.bind(this),this._interceptControlDown=mS.bind(this),this._interceptControlUp=gS.bind(this),this.domElement!==null&&this.connect(this.domElement),this.update()}set cursorStyle(e){this._cursorStyle=e,e==="grab"?this.domElement.style.cursor="grab":this.domElement.style.cursor="auto"}get cursorStyle(){return this._cursorStyle}connect(e){super.connect(e),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointercancel",this._onPointerUp),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.addEventListener("wheel",this._onMouseWheel,{passive:!1}),this.domElement.getRootNode().addEventListener("keydown",this._interceptControlDown,{passive:!0,capture:!0}),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.ownerDocument.removeEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this._onPointerUp),this.domElement.removeEventListener("pointercancel",this._onPointerUp),this.domElement.removeEventListener("wheel",this._onMouseWheel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.stopListenToKeyEvents(),this.domElement.getRootNode().removeEventListener("keydown",this._interceptControlDown,{capture:!0}),this.domElement.style.touchAction=""}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(e){e.addEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=e}stopListenToKeyEvents(){this._domElementKeyEvents!==null&&(this._domElementKeyEvents.removeEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=null)}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(hd),this.update(),this.state=bt.NONE}pan(e,t){this._pan(e,t),this.update()}dollyIn(e){this._dollyIn(e),this.update()}dollyOut(e){this._dollyOut(e),this.update()}rotateLeft(e){this._rotateLeft(e),this.update()}rotateUp(e){this._rotateUp(e),this.update()}update(e=null){const t=this.object.position;Bt.copy(t).sub(this.target),Bt.applyQuaternion(this._quat),this._spherical.setFromVector3(Bt),this.autoRotate&&this.state===bt.NONE&&this._rotateLeft(this._getAutoRotationAngle(e)),this.enableDamping?(this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor):(this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi);let i=this.minAzimuthAngle,s=this.maxAzimuthAngle;isFinite(i)&&isFinite(s)&&(i<-Math.PI?i+=fn:i>Math.PI&&(i-=fn),s<-Math.PI?s+=fn:s>Math.PI&&(s-=fn),i<=s?this._spherical.theta=Math.max(i,Math.min(s,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(i+s)/2?Math.max(i,this._spherical.theta):Math.min(s,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let r=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const a=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),r=a!=this._spherical.radius}if(Bt.setFromSpherical(this._spherical),Bt.applyQuaternion(this._quatInverse),t.copy(this.target).add(Bt),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let a=null;if(this.object.isPerspectiveCamera){const o=Bt.length();a=this._clampDistance(o*this._scale);const l=o-a;this.object.position.addScaledVector(this._dollyDirection,l),this.object.updateMatrixWorld(),r=!!l}else if(this.object.isOrthographicCamera){const o=new k(this._mouse.x,this._mouse.y,0);o.unproject(this.object);const l=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),r=l!==this.object.zoom;const c=new k(this._mouse.x,this._mouse.y,0);c.unproject(this.object),this.object.position.sub(c).add(o),this.object.updateMatrixWorld(),a=Bt.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;a!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(a).add(this.object.position):(Ya.origin.copy(this.object.position),Ya.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(Ya.direction))<iS?this.object.lookAt(this.target):(dd.setFromNormalAndCoplanarPoint(this.object.up,this.target),Ya.intersectPlane(dd,this.target))))}else if(this.object.isOrthographicCamera){const a=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),a!==this.object.zoom&&(this.object.updateProjectionMatrix(),r=!0)}return this._scale=1,this._performCursorZoom=!1,r||this._lastPosition.distanceToSquared(this.object.position)>Nl||8*(1-this._lastQuaternion.dot(this.object.quaternion))>Nl||this._lastTargetPosition.distanceToSquared(this.target)>Nl?(this.dispatchEvent(hd),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?fn/60*this.autoRotateSpeed*e:fn/60/60*this.autoRotateSpeed}_getZoomScale(e){const t=Math.abs(e*.01);return Math.pow(.95,this.zoomSpeed*t)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,t){Bt.setFromMatrixColumn(t,0),Bt.multiplyScalar(-e),this._panOffset.add(Bt)}_panUp(e,t){this.screenSpacePanning===!0?Bt.setFromMatrixColumn(t,1):(Bt.setFromMatrixColumn(t,0),Bt.crossVectors(this.object.up,Bt)),Bt.multiplyScalar(e),this._panOffset.add(Bt)}_pan(e,t){const i=this.domElement;if(this.object.isPerspectiveCamera){const s=this.object.position;Bt.copy(s).sub(this.target);let r=Bt.length();r*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*r/i.clientHeight,this.object.matrix),this._panUp(2*t*r/i.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/i.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/i.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(e,t){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const i=this.domElement.getBoundingClientRect(),s=e-i.left,r=t-i.top,a=i.width,o=i.height;this._mouse.x=s/a*2-1,this._mouse.y=-(r/o)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(fn*this._rotateDelta.x/t.clientHeight),this._rotateUp(fn*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){this._dollyEnd.set(e.clientX,e.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(e){this._panEnd.set(e.clientX,e.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(e){this._updateZoomParameters(e.clientX,e.clientY),e.deltaY<0?this._dollyIn(this._getZoomScale(e.deltaY)):e.deltaY>0&&this._dollyOut(this._getZoomScale(e.deltaY)),this.update()}_handleKeyDown(e){let t=!1;switch(e.code){case this.keys.UP:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(fn*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,this.keyPanSpeed),t=!0;break;case this.keys.BOTTOM:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(-fn*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,-this.keyPanSpeed),t=!0;break;case this.keys.LEFT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(fn*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(this.keyPanSpeed,0),t=!0;break;case this.keys.RIGHT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(-fn*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),t=!0;break}t&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),i=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._rotateStart.set(i,s)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),i=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._panStart.set(i,s)}}_handleTouchStartDolly(e){const t=this._getSecondPointerPosition(e),i=e.pageX-t.x,s=e.pageY-t.y,r=Math.sqrt(i*i+s*s);this._dollyStart.set(0,r)}_handleTouchStartDollyPan(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enablePan&&this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enableRotate&&this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{const i=this._getSecondPointerPosition(e),s=.5*(e.pageX+i.x),r=.5*(e.pageY+i.y);this._rotateEnd.set(s,r)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(fn*this._rotateDelta.x/t.clientHeight),this._rotateUp(fn*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),i=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._panEnd.set(i,s)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){const t=this._getSecondPointerPosition(e),i=e.pageX-t.x,s=e.pageY-t.y,r=Math.sqrt(i*i+s*s);this._dollyEnd.set(0,r),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const a=(e.pageX+t.x)*.5,o=(e.pageY+t.y)*.5;this._updateZoomParameters(a,o)}_handleTouchMoveDollyPan(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enablePan&&this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enableRotate&&this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId){this._pointers.splice(t,1);return}}_isTrackingPointer(e){for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId)return!0;return!1}_trackPointer(e){let t=this._pointerPositions[e.pointerId];t===void 0&&(t=new Le,this._pointerPositions[e.pointerId]=t),t.set(e.pageX,e.pageY)}_getSecondPointerPosition(e){const t=e.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[t]}_customWheelEvent(e){const t=e.deltaMode,i={clientX:e.clientX,clientY:e.clientY,deltaY:e.deltaY};switch(t){case 1:i.deltaY*=16;break;case 2:i.deltaY*=100;break}return e.ctrlKey&&!this._controlActive&&(i.deltaY*=10),i}}function rS(n){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(n.pointerId),this.domElement.ownerDocument.addEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this._onPointerUp)),!this._isTrackingPointer(n)&&(this._addPointer(n),n.pointerType==="touch"?this._onTouchStart(n):this._onMouseDown(n),this._cursorStyle==="grab"&&(this.domElement.style.cursor="grabbing")))}function aS(n){this.enabled!==!1&&(n.pointerType==="touch"?this._onTouchMove(n):this._onMouseMove(n))}function oS(n){switch(this._removePointer(n),this._pointers.length){case 0:this.domElement.releasePointerCapture(n.pointerId),this.domElement.ownerDocument.removeEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(Sp),this.state=bt.NONE,this._cursorStyle==="grab"&&(this.domElement.style.cursor="grab");break;case 1:const e=this._pointers[0],t=this._pointerPositions[e];this._onTouchStart({pointerId:e,pageX:t.x,pageY:t.y});break}}function lS(n){let e;switch(n.button){case 0:e=this.mouseButtons.LEFT;break;case 1:e=this.mouseButtons.MIDDLE;break;case 2:e=this.mouseButtons.RIGHT;break;default:e=-1}switch(e){case Mi.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(n),this.state=bt.DOLLY;break;case Mi.ROTATE:if(n.ctrlKey||n.metaKey||n.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(n),this.state=bt.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(n),this.state=bt.ROTATE}break;case Mi.PAN:if(n.ctrlKey||n.metaKey||n.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(n),this.state=bt.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(n),this.state=bt.PAN}break;default:this.state=bt.NONE}this.state!==bt.NONE&&this.dispatchEvent(wu)}function cS(n){switch(this.state){case bt.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(n);break;case bt.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(n);break;case bt.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(n);break}}function uS(n){this.enabled===!1||this.enableZoom===!1||this.state!==bt.NONE||(n.preventDefault(),this.dispatchEvent(wu),this._handleMouseWheel(this._customWheelEvent(n)),this.dispatchEvent(Sp))}function hS(n){this.enabled!==!1&&this._handleKeyDown(n)}function dS(n){switch(this._trackPointer(n),this._pointers.length){case 1:switch(this.touches.ONE){case Xi.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(n),this.state=bt.TOUCH_ROTATE;break;case Xi.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(n),this.state=bt.TOUCH_PAN;break;default:this.state=bt.NONE}break;case 2:switch(this.touches.TWO){case Xi.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(n),this.state=bt.TOUCH_DOLLY_PAN;break;case Xi.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(n),this.state=bt.TOUCH_DOLLY_ROTATE;break;default:this.state=bt.NONE}break;default:this.state=bt.NONE}this.state!==bt.NONE&&this.dispatchEvent(wu)}function fS(n){switch(this._trackPointer(n),this.state){case bt.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(n),this.update();break;case bt.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(n),this.update();break;case bt.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(n),this.update();break;case bt.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(n),this.update();break;default:this.state=bt.NONE}}function pS(n){this.enabled!==!1&&n.preventDefault()}function mS(n){n.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function gS(n){n.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}const fd=new mn,Ka=new k;class bp extends e_{constructor(){super(),this.isLineSegmentsGeometry=!0,this.type="LineSegmentsGeometry";const e=[-1,2,0,1,2,0,-1,1,0,1,1,0,-1,0,0,1,0,0,-1,-1,0,1,-1,0],t=[-1,2,1,2,-1,1,1,1,-1,-1,1,-1,-1,-2,1,-2],i=[0,2,1,2,3,1,2,4,3,4,5,3,4,6,5,6,7,5];this.setIndex(i),this.setAttribute("position",new dt(e,3)),this.setAttribute("uv",new dt(t,2))}applyMatrix4(e){const t=this.attributes.instanceStart,i=this.attributes.instanceEnd;return t!==void 0&&(t.applyMatrix4(e),i.applyMatrix4(e),t.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}setPositions(e){let t;e instanceof Float32Array?t=e:Array.isArray(e)&&(t=new Float32Array(e));const i=new qc(t,6,1);return this.setAttribute("instanceStart",new ai(i,3,0)),this.setAttribute("instanceEnd",new ai(i,3,3)),this.instanceCount=this.attributes.instanceStart.count,this.computeBoundingBox(),this.computeBoundingSphere(),this}setColors(e){let t;e instanceof Float32Array?t=e:Array.isArray(e)&&(t=new Float32Array(e));const i=new qc(t,6,1);return this.setAttribute("instanceColorStart",new ai(i,3,0)),this.setAttribute("instanceColorEnd",new ai(i,3,3)),this}fromWireframeGeometry(e){return this.setPositions(e.attributes.position.array),this}fromEdgesGeometry(e){return this.setPositions(e.attributes.position.array),this}fromMesh(e){return this.fromWireframeGeometry(new Yg(e.geometry)),this}fromLineSegments(e){const t=e.geometry;return this.setPositions(t.attributes.position.array),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new mn);const e=this.attributes.instanceStart,t=this.attributes.instanceEnd;e!==void 0&&t!==void 0&&(this.boundingBox.setFromBufferAttribute(e),fd.setFromBufferAttribute(t),this.boundingBox.union(fd))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new pr),this.boundingBox===null&&this.computeBoundingBox();const e=this.attributes.instanceStart,t=this.attributes.instanceEnd;if(e!==void 0&&t!==void 0){const i=this.boundingSphere.center;this.boundingBox.getCenter(i);let s=0;for(let r=0,a=e.count;r<a;r++)Ka.fromBufferAttribute(e,r),s=Math.max(s,i.distanceToSquared(Ka)),Ka.fromBufferAttribute(t,r),s=Math.max(s,i.distanceToSquared(Ka));this.boundingSphere.radius=Math.sqrt(s),isNaN(this.boundingSphere.radius)&&console.error("THREE.LineSegmentsGeometry.computeBoundingSphere(): Computed radius is NaN. The instanced position data is likely to have NaN values.",this)}}toJSON(){}}we.line={worldUnits:{value:1},linewidth:{value:1},resolution:{value:new Le},dashOffset:{value:0},dashScale:{value:1},dashSize:{value:1},gapSize:{value:1}};gn.line={uniforms:Tu.merge([we.common,we.fog,we.line]),vertexShader:`
#include <common>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
uniform float linewidth;
uniform vec2 resolution;
attribute vec3 instanceStart;
attribute vec3 instanceEnd;
attribute vec3 instanceColorStart;
attribute vec3 instanceColorEnd;
#ifdef WORLD_UNITS
varying vec4 worldPos;
varying vec3 worldStart;
varying vec3 worldEnd;
#ifdef USE_DASH
varying vec2 vUv;
#endif
#else
varying vec2 vUv;
#endif
#ifdef USE_DASH
uniform float dashScale;
attribute float instanceDistanceStart;
attribute float instanceDistanceEnd;
varying float vLineDistance;
#endif
float trimSegmentAlpha( const in vec4 start, const in vec4 end ) {
// compute the interpolation factor needed to trim the segment so it terminates
// between the camera plane and the near plane
// conservative estimate of the near plane
float a = projectionMatrix[ 2 ][ 2 ]; // 3nd entry in 3th column
float b = projectionMatrix[ 3 ][ 2 ]; // 3nd entry in 4th column
// we need different nearEstimate formula for reversed and default depth buffer
// a is positive with a reversed depth buffer so it can be used for controlling the code flow
float nearEstimate = ( a > 0.0 ) ? ( - b / ( a + 1.0 ) ) : ( - 0.5 * b / a );
return ( nearEstimate - start.z ) / ( end.z - start.z );
}
void main() {
#ifdef USE_COLOR
vColor.xyz = ( position.y < 0.5 ) ? instanceColorStart : instanceColorEnd;
#endif
float aspect = resolution.x / resolution.y;
// camera space
vec4 start = modelViewMatrix * vec4( instanceStart, 1.0 );
vec4 end = modelViewMatrix * vec4( instanceEnd, 1.0 );
#ifdef USE_DASH
float lineDistanceStart = dashScale * instanceDistanceStart;
float lineDistanceEnd = dashScale * instanceDistanceEnd;
#endif
#ifdef WORLD_UNITS
worldStart = start.xyz;
worldEnd = end.xyz;
#else
vUv = uv;
#endif
// special case for perspective projection, and segments that terminate either in, or behind, the camera plane
// clearly the gpu firmware has a way of addressing this issue when projecting into ndc space
// but we need to perform ndc-space calculations in the shader, so we must address this issue directly
// perhaps there is a more elegant solution -- WestLangley
bool perspective = ( projectionMatrix[ 2 ][ 3 ] == - 1.0 ); // 4th entry in the 3rd column
if ( perspective ) {
if ( start.z < 0.0 && end.z >= 0.0 ) {
float alpha = trimSegmentAlpha( start, end );
end.xyz = mix( start.xyz, end.xyz, alpha );
#ifdef USE_DASH
lineDistanceEnd = mix( lineDistanceStart, lineDistanceEnd, alpha );
#endif
} else if ( end.z < 0.0 && start.z >= 0.0 ) {
float alpha = trimSegmentAlpha( end, start );
start.xyz = mix( end.xyz, start.xyz, alpha );
#ifdef USE_DASH
lineDistanceStart = mix( lineDistanceEnd, lineDistanceStart, alpha );
#endif
}
}
#ifdef USE_DASH
vLineDistance = ( position.y < 0.5 ) ? lineDistanceStart : lineDistanceEnd;
vUv = uv;
#endif
// clip space
vec4 clipStart = projectionMatrix * start;
vec4 clipEnd = projectionMatrix * end;
// ndc space
vec3 ndcStart = clipStart.xyz / clipStart.w;
vec3 ndcEnd = clipEnd.xyz / clipEnd.w;
// direction
vec2 dir = ndcEnd.xy - ndcStart.xy;
// account for clip-space aspect ratio
dir.x *= aspect;
dir = normalize( dir );
#ifdef WORLD_UNITS
vec3 worldDir = normalize( end.xyz - start.xyz );
vec3 tmpFwd = normalize( mix( start.xyz, end.xyz, 0.5 ) );
vec3 worldUp = normalize( cross( worldDir, tmpFwd ) );
vec3 worldFwd = cross( worldDir, worldUp );
worldPos = position.y < 0.5 ? start: end;
// height offset
float hw = linewidth * 0.5;
worldPos.xyz += position.x < 0.0 ? hw * worldUp : - hw * worldUp;
// don't extend the line if we're rendering dashes because we
// won't be rendering the endcaps
#ifndef USE_DASH
// cap extension
worldPos.xyz += position.y < 0.5 ? - hw * worldDir : hw * worldDir;
// add width to the box
worldPos.xyz += worldFwd * hw;
// endcaps
if ( position.y > 1.0 || position.y < 0.0 ) {
worldPos.xyz -= worldFwd * 2.0 * hw;
}
#endif
// project the worldpos
vec4 clip = projectionMatrix * worldPos;
// shift the depth of the projected points so the line
// segments overlap neatly
vec3 clipPose = ( position.y < 0.5 ) ? ndcStart : ndcEnd;
clip.z = clipPose.z * clip.w;
#else
vec2 offset = vec2( dir.y, - dir.x );
// undo aspect ratio adjustment
dir.x /= aspect;
offset.x /= aspect;
// sign flip
if ( position.x < 0.0 ) offset *= - 1.0;
// endcaps
if ( position.y < 0.0 ) {
offset += - dir;
} else if ( position.y > 1.0 ) {
offset += dir;
}
// adjust for linewidth
offset *= linewidth;
// adjust for clip-space to screen-space conversion // maybe resolution should be based on viewport ...
offset /= resolution.y;
// select end
vec4 clip = ( position.y < 0.5 ) ? clipStart : clipEnd;
// back to clip space
offset *= clip.w;
clip.xy += offset;
#endif
gl_Position = clip;
vec4 mvPosition = ( position.y < 0.5 ) ? start : end; // this is an approximation
#include <logdepthbuf_vertex>
#include <clipping_planes_vertex>
#include <fog_vertex>
}
`,fragmentShader:`
uniform vec3 diffuse;
uniform float opacity;
uniform float linewidth;
#ifdef USE_DASH
uniform float dashOffset;
uniform float dashSize;
uniform float gapSize;
#endif
varying float vLineDistance;
#ifdef WORLD_UNITS
varying vec4 worldPos;
varying vec3 worldStart;
varying vec3 worldEnd;
#ifdef USE_DASH
varying vec2 vUv;
#endif
#else
varying vec2 vUv;
#endif
#include <common>
#include <color_pars_fragment>
#include <fog_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
vec2 closestLineToLine(vec3 p1, vec3 p2, vec3 p3, vec3 p4) {
float mua;
float mub;
vec3 p13 = p1 - p3;
vec3 p43 = p4 - p3;
vec3 p21 = p2 - p1;
float d1343 = dot( p13, p43 );
float d4321 = dot( p43, p21 );
float d1321 = dot( p13, p21 );
float d4343 = dot( p43, p43 );
float d2121 = dot( p21, p21 );
float denom = d2121 * d4343 - d4321 * d4321;
float numer = d1343 * d4321 - d1321 * d4343;
mua = numer / denom;
mua = clamp( mua, 0.0, 1.0 );
mub = ( d1343 + d4321 * ( mua ) ) / d4343;
mub = clamp( mub, 0.0, 1.0 );
return vec2( mua, mub );
}
void main() {
float alpha = opacity;
vec4 diffuseColor = vec4( diffuse, alpha );
#include <clipping_planes_fragment>
#ifdef USE_DASH
if ( vUv.y < - 1.0 || vUv.y > 1.0 ) discard; // discard endcaps
if ( mod( vLineDistance + dashOffset, dashSize + gapSize ) > dashSize ) discard; // todo - FIX
#endif
#ifdef WORLD_UNITS
// Find the closest points on the view ray and the line segment
vec3 rayEnd = normalize( worldPos.xyz ) * 1e5;
vec3 lineDir = worldEnd - worldStart;
vec2 params = closestLineToLine( worldStart, worldEnd, vec3( 0.0, 0.0, 0.0 ), rayEnd );
vec3 p1 = worldStart + lineDir * params.x;
vec3 p2 = rayEnd * params.y;
vec3 delta = p1 - p2;
float len = length( delta );
float norm = len / linewidth;
#ifndef USE_DASH
#ifdef USE_ALPHA_TO_COVERAGE
float dnorm = fwidth( norm );
alpha = 1.0 - smoothstep( 0.5 - dnorm, 0.5 + dnorm, norm );
#else
if ( norm > 0.5 ) {
discard;
}
#endif
#endif
#else
#ifdef USE_ALPHA_TO_COVERAGE
// artifacts appear on some hardware if a derivative is taken within a conditional
float a = vUv.x;
float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;
float len2 = a * a + b * b;
float dlen = fwidth( len2 );
if ( abs( vUv.y ) > 1.0 ) {
alpha = 1.0 - smoothstep( 1.0 - dlen, 1.0 + dlen, len2 );
}
#else
if ( abs( vUv.y ) > 1.0 ) {
float a = vUv.x;
float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;
float len2 = a * a + b * b;
if ( len2 > 1.0 ) discard;
}
#endif
#endif
#include <logdepthbuf_fragment>
#include <color_fragment>
gl_FragColor = vec4( diffuseColor.rgb, alpha );
#include <tonemapping_fragment>
#include <colorspace_fragment>
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
}
`};class Mp extends In{constructor(e){super({type:"LineMaterial",uniforms:Tu.clone(gn.line.uniforms),vertexShader:gn.line.vertexShader,fragmentShader:gn.line.fragmentShader,clipping:!0}),this.isLineMaterial=!0,this.setValues(e)}get color(){return this.uniforms.diffuse.value}set color(e){this.uniforms.diffuse.value=e}get worldUnits(){return"WORLD_UNITS"in this.defines}set worldUnits(e){e===!0!==this.worldUnits&&(this.needsUpdate=!0),e===!0?this.defines.WORLD_UNITS="":delete this.defines.WORLD_UNITS}get linewidth(){return this.uniforms.linewidth.value}set linewidth(e){this.uniforms.linewidth&&(this.uniforms.linewidth.value=e)}get dashed(){return"USE_DASH"in this.defines}set dashed(e){e===!0!==this.dashed&&(this.needsUpdate=!0),e===!0?this.defines.USE_DASH="":delete this.defines.USE_DASH}get dashScale(){return this.uniforms.dashScale.value}set dashScale(e){this.uniforms.dashScale.value=e}get dashSize(){return this.uniforms.dashSize.value}set dashSize(e){this.uniforms.dashSize.value=e}get dashOffset(){return this.uniforms.dashOffset.value}set dashOffset(e){this.uniforms.dashOffset.value=e}get gapSize(){return this.uniforms.gapSize.value}set gapSize(e){this.uniforms.gapSize.value=e}get opacity(){return this.uniforms.opacity.value}set opacity(e){this.uniforms&&(this.uniforms.opacity.value=e)}get resolution(){return this.uniforms.resolution.value}set resolution(e){this.uniforms.resolution.value.copy(e)}get alphaToCoverage(){return"USE_ALPHA_TO_COVERAGE"in this.defines}set alphaToCoverage(e){this.defines&&(e===!0!==this.alphaToCoverage&&(this.needsUpdate=!0),e===!0?this.defines.USE_ALPHA_TO_COVERAGE="":delete this.defines.USE_ALPHA_TO_COVERAGE)}}const kl=new Et,pd=new k,md=new k,Kt=new Et,qt=new Et,Jn=new Et,Fl=new k,Bl=new Rt,Zt=new r_,gd=new k,qa=new mn,$a=new pr,jn=new Et;let si,ps;function _d(n,e,t){return jn.set(0,0,-e,1).applyMatrix4(n.projectionMatrix),jn.multiplyScalar(1/jn.w),jn.x=ps/t.width,jn.y=ps/t.height,jn.applyMatrix4(n.projectionMatrixInverse),jn.multiplyScalar(1/jn.w),Math.abs(Math.max(jn.x,jn.y))}function _S(n,e){const t=n.matrixWorld,i=n.geometry,s=i.attributes.instanceStart,r=i.attributes.instanceEnd,a=Math.min(i.instanceCount,s.count);for(let o=0,l=a;o<l;o++){Zt.start.fromBufferAttribute(s,o),Zt.end.fromBufferAttribute(r,o),Zt.applyMatrix4(t);const c=new k,u=new k;si.distanceSqToSegment(Zt.start,Zt.end,u,c),u.distanceTo(c)<ps*.5&&e.push({point:u,pointOnLine:c,distance:si.origin.distanceTo(u),object:n,face:null,faceIndex:o,uv:null,uv1:null})}}function xS(n,e,t){const i=e.projectionMatrix,r=n.material.resolution,a=n.matrixWorld,o=n.geometry,l=o.attributes.instanceStart,c=o.attributes.instanceEnd,u=Math.min(o.instanceCount,l.count),h=-e.near;si.at(1,Jn),Jn.w=1,Jn.applyMatrix4(e.matrixWorldInverse),Jn.applyMatrix4(i),Jn.multiplyScalar(1/Jn.w),Jn.x*=r.x/2,Jn.y*=r.y/2,Jn.z=0,Fl.copy(Jn),Bl.multiplyMatrices(e.matrixWorldInverse,a);for(let d=0,f=u;d<f;d++){if(Kt.fromBufferAttribute(l,d),qt.fromBufferAttribute(c,d),Kt.w=1,qt.w=1,Kt.applyMatrix4(Bl),qt.applyMatrix4(Bl),Kt.z>h&&qt.z>h)continue;if(Kt.z>h){const b=Kt.z-qt.z,x=(Kt.z-h)/b;Kt.lerp(qt,x)}else if(qt.z>h){const b=qt.z-Kt.z,x=(qt.z-h)/b;qt.lerp(Kt,x)}Kt.applyMatrix4(i),qt.applyMatrix4(i),Kt.multiplyScalar(1/Kt.w),qt.multiplyScalar(1/qt.w),Kt.x*=r.x/2,Kt.y*=r.y/2,qt.x*=r.x/2,qt.y*=r.y/2,Zt.start.copy(Kt),Zt.start.z=0,Zt.end.copy(qt),Zt.end.z=0;const _=Zt.closestPointToPointParameter(Fl,!0);Zt.at(_,gd);const m=Gf.lerp(Kt.z,qt.z,_),g=m>=-1&&m<=1,v=Fl.distanceTo(gd)<ps*.5;if(g&&v){Zt.start.fromBufferAttribute(l,d),Zt.end.fromBufferAttribute(c,d),Zt.start.applyMatrix4(a),Zt.end.applyMatrix4(a);const b=new k,x=new k;si.distanceSqToSegment(Zt.start,Zt.end,x,b),t.push({point:x,pointOnLine:b,distance:si.origin.distanceTo(x),object:n,face:null,faceIndex:d,uv:null,uv1:null})}}}class yS extends Ht{constructor(e=new bp,t=new Mp({color:Math.random()*16777215})){super(e,t),this.isLineSegments2=!0,this.type="LineSegments2"}computeLineDistances(){const e=this.geometry,t=e.attributes.instanceStart,i=e.attributes.instanceEnd,s=new Float32Array(2*t.count);for(let a=0,o=0,l=t.count;a<l;a++,o+=2)pd.fromBufferAttribute(t,a),md.fromBufferAttribute(i,a),s[o]=o===0?0:s[o-1],s[o+1]=s[o]+pd.distanceTo(md);const r=new qc(s,2,1);return e.setAttribute("instanceDistanceStart",new ai(r,1,0)),e.setAttribute("instanceDistanceEnd",new ai(r,1,1)),this}raycast(e,t){const i=this.material.worldUnits,s=e.camera;if(s===null&&!i&&console.error('LineSegments2: "Raycaster.camera" needs to be set in order to raycast against LineSegments2 while worldUnits is set to false.'),i===!1&&(this.material.resolution.x===0||this.material.resolution.y===0))return;const r=e.params.Line2!==void 0&&e.params.Line2.threshold||0;si=e.ray;const a=this.matrixWorld,o=this.geometry,l=this.material;ps=l.linewidth+r,o.boundingSphere===null&&o.computeBoundingSphere(),$a.copy(o.boundingSphere).applyMatrix4(a);let c;if(i)c=ps*.5;else{const h=Math.max(s.near,$a.distanceToPoint(si.origin));c=_d(s,h,l.resolution)}if($a.radius+=c,si.intersectsSphere($a)===!1)return;o.boundingBox===null&&o.computeBoundingBox(),qa.copy(o.boundingBox).applyMatrix4(a);let u;if(i)u=ps*.5;else{const h=Math.max(s.near,qa.distanceToPoint(si.origin));u=_d(s,h,l.resolution)}qa.expandByScalar(u),si.intersectsBox(qa)!==!1&&(i?_S(this,t):xS(this,s,t))}onBeforeRender(e){const t=this.material.uniforms;t&&t.resolution&&(e.getViewport(kl),this.material.uniforms.resolution.value.set(kl.z,kl.w))}}function vS(n,e,t){const i=(1-Math.abs(2*t-1))*e,s=i*(1-Math.abs(n/60%2-1)),r=t-i/2;let a,o,l;return n<60?(a=i,o=s,l=0):n<120?(a=s,o=i,l=0):n<180?(a=0,o=i,l=s):n<240?(a=0,o=s,l=i):n<300?(a=s,o=0,l=i):(a=i,o=0,l=s),Math.round((a+r)*255)*65536+Math.round((o+r)*255)*256+Math.round((l+r)*255)}const SS=[null,16711680,16776960,65280,65535,255,16711935,16777215,4276545,8421504],bS=[[1,.5],[1,.28],[.65,.65],[.65,.38],[.35,.8],[.35,.48],[.18,.68],[.18,.38],[0,.55],[0,.3]];function Za(n,e=!0){if(n==null||n===0||n===256)return null;if(n===7)return e?16777215:0;if(n<=9)return SS[n]??null;if(n>=250&&n<=255){const t=Math.round(40+(n-250)*43);return t*65536+t*256+t}if(n>=10&&n<=249){const t=n-10,[i,s]=bS[t%10];return vS(Math.floor(t/10)*15,i,s)}return 13226457}function Ru(n){if(n==null)return null;if(typeof n=="object"&&n!==null&&"value"in n){const e=n.value;if(typeof e=="number"&&Number.isFinite(e))return e.toString(16);if(typeof e=="string"&&e.length){const t=Number(e);return Number.isFinite(t)?t.toString(16):e.toLowerCase()}return null}if(typeof n=="number"&&Number.isFinite(n))return n.toString(16);if(typeof n=="string"&&n.length){const e=Number(n);return Number.isFinite(e)?e.toString(16):n.toLowerCase()}return null}function Ap(n){return Ru(n.ownerHandle)}function MS(n){const e=n.toLowerCase().replace(/\*/g,"").trim();return e?e==="model_space"||e==="ms"||e.startsWith("model")?"model":e==="paper_space"||e==="ps"||e.startsWith("paper")?"paper":null:null}function AS(n,e,t){return n==="model"?"Model":n==="paper"?t<=1?"Layout":`Layout (${e.replace(/^\*/,"")})`:e}function Qs(n){var a;const e=((a=n==null?void 0:n.tables)==null?void 0:a.blocks)??[],t=(n==null?void 0:n.entities)??[],i=new Map;for(const o of t){const l=Ap(o);l&&i.set(l,(i.get(l)||0)+1)}const s=[];let r=0;for(const o of e){const l=MS(o.name??"");if(!l)continue;const c=Ru(o.handle);if(!c)continue;l==="paper"&&(r+=1);const u=typeof o.handle=="number"?o.handle:typeof o.handle=="object"&&o.handle&&"value"in o.handle?Number(o.handle.value):null;s.push({id:c,label:AS(l,o.name??"",r),name:o.name??"",handle:Number.isFinite(u)?u:null,handleHex:c,kind:l,entityCount:i.get(c)||0})}return s.sort((o,l)=>{if(o.kind!==l.kind){if(o.kind==="model")return-1;if(l.kind==="model")return 1}return 0}),s}function ES(n){if(!n.length)return null;const e=n.find(i=>i.kind==="paper"&&i.entityCount>0);if(e)return e;const t=n.find(i=>i.kind==="model");return t||(n[0]??null)}function Hl(n,e,t=3){const i=new Set([e]);for(let s=0;s<t;s++){let r=!1;for(const a of n){const o=Ap(a);if(!o||!i.has(o))continue;const l=Ru(a.handle);l&&!i.has(l)&&(i.add(l),r=!0)}if(!r)break}return i}var Lu=0,Ep=-3;function jr(){this.table=new Uint16Array(16),this.trans=new Uint16Array(288)}function TS(n,e){this.source=n,this.sourceIndex=0,this.tag=0,this.bitcount=0,this.dest=e,this.destLen=0,this.ltree=new jr,this.dtree=new jr}var Tp=new jr,Cp=new jr,Du=new Uint8Array(30),Iu=new Uint16Array(30),wp=new Uint8Array(30),Rp=new Uint16Array(30),CS=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),xd=new jr,Qn=new Uint8Array(320);function Lp(n,e,t,i){var s,r;for(s=0;s<t;++s)n[s]=0;for(s=0;s<30-t;++s)n[s+t]=s/t|0;for(r=i,s=0;s<30;++s)e[s]=r,r+=1<<n[s]}function wS(n,e){var t;for(t=0;t<7;++t)n.table[t]=0;for(n.table[7]=24,n.table[8]=152,n.table[9]=112,t=0;t<24;++t)n.trans[t]=256+t;for(t=0;t<144;++t)n.trans[24+t]=t;for(t=0;t<8;++t)n.trans[168+t]=280+t;for(t=0;t<112;++t)n.trans[176+t]=144+t;for(t=0;t<5;++t)e.table[t]=0;for(e.table[5]=32,t=0;t<32;++t)e.trans[t]=t}var yd=new Uint16Array(16);function zl(n,e,t,i){var s,r;for(s=0;s<16;++s)n.table[s]=0;for(s=0;s<i;++s)n.table[e[t+s]]++;for(n.table[0]=0,r=0,s=0;s<16;++s)yd[s]=r,r+=n.table[s];for(s=0;s<i;++s)e[t+s]&&(n.trans[yd[e[t+s]]++]=s)}function RS(n){n.bitcount--||(n.tag=n.source[n.sourceIndex++],n.bitcount=7);var e=n.tag&1;return n.tag>>>=1,e}function ii(n,e,t){if(!e)return t;for(;n.bitcount<24;)n.tag|=n.source[n.sourceIndex++]<<n.bitcount,n.bitcount+=8;var i=n.tag&65535>>>16-e;return n.tag>>>=e,n.bitcount-=e,i+t}function Jc(n,e){for(;n.bitcount<24;)n.tag|=n.source[n.sourceIndex++]<<n.bitcount,n.bitcount+=8;var t=0,i=0,s=0,r=n.tag;do i=2*i+(r&1),r>>>=1,++s,t+=e.table[s],i-=e.table[s];while(i>=0);return n.tag=r,n.bitcount-=s,e.trans[t+i]}function LS(n,e,t){var i,s,r,a,o,l;for(i=ii(n,5,257),s=ii(n,5,1),r=ii(n,4,4),a=0;a<19;++a)Qn[a]=0;for(a=0;a<r;++a){var c=ii(n,3,0);Qn[CS[a]]=c}for(zl(xd,Qn,0,19),o=0;o<i+s;){var u=Jc(n,xd);switch(u){case 16:var h=Qn[o-1];for(l=ii(n,2,3);l;--l)Qn[o++]=h;break;case 17:for(l=ii(n,3,3);l;--l)Qn[o++]=0;break;case 18:for(l=ii(n,7,11);l;--l)Qn[o++]=0;break;default:Qn[o++]=u;break}}zl(e,Qn,0,i),zl(t,Qn,i,s)}function vd(n,e,t){for(;;){var i=Jc(n,e);if(i===256)return Lu;if(i<256)n.dest[n.destLen++]=i;else{var s,r,a,o;for(i-=257,s=ii(n,Du[i],Iu[i]),r=Jc(n,t),a=n.destLen-ii(n,wp[r],Rp[r]),o=a;o<a+s;++o)n.dest[n.destLen++]=n.dest[o]}}}function DS(n){for(var e,t,i;n.bitcount>8;)n.sourceIndex--,n.bitcount-=8;if(e=n.source[n.sourceIndex+1],e=256*e+n.source[n.sourceIndex],t=n.source[n.sourceIndex+3],t=256*t+n.source[n.sourceIndex+2],e!==(~t&65535))return Ep;for(n.sourceIndex+=4,i=e;i;--i)n.dest[n.destLen++]=n.source[n.sourceIndex++];return n.bitcount=0,Lu}function Dp(n,e){var t=new TS(n,e),i,s,r;do{switch(i=RS(t),s=ii(t,2,0),s){case 0:r=DS(t);break;case 1:r=vd(t,Tp,Cp);break;case 2:LS(t,t.ltree,t.dtree),r=vd(t,t.ltree,t.dtree);break;default:r=Ep}if(r!==Lu)throw new Error("Data error")}while(!i);return t.destLen<t.dest.length?typeof t.dest.slice=="function"?t.dest.slice(0,t.destLen):t.dest.subarray(0,t.destLen):t.dest}wS(Tp,Cp);Lp(Du,Iu,4,3);Lp(wp,Rp,2,1);Du[28]=0;Iu[28]=258;function Ks(n,e,t,i,s){return Math.pow(1-s,3)*n+3*Math.pow(1-s,2)*s*e+3*(1-s)*Math.pow(s,2)*t+Math.pow(s,3)*i}function Ss(){this.x1=Number.NaN,this.y1=Number.NaN,this.x2=Number.NaN,this.y2=Number.NaN}Ss.prototype.isEmpty=function(){return isNaN(this.x1)||isNaN(this.y1)||isNaN(this.x2)||isNaN(this.y2)};Ss.prototype.addPoint=function(n,e){typeof n=="number"&&((isNaN(this.x1)||isNaN(this.x2))&&(this.x1=n,this.x2=n),n<this.x1&&(this.x1=n),n>this.x2&&(this.x2=n)),typeof e=="number"&&((isNaN(this.y1)||isNaN(this.y2))&&(this.y1=e,this.y2=e),e<this.y1&&(this.y1=e),e>this.y2&&(this.y2=e))};Ss.prototype.addX=function(n){this.addPoint(n,null)};Ss.prototype.addY=function(n){this.addPoint(null,n)};Ss.prototype.addBezier=function(n,e,t,i,s,r,a,o){const l=[n,e],c=[t,i],u=[s,r],h=[a,o];this.addPoint(n,e),this.addPoint(a,o);for(let d=0;d<=1;d++){const f=6*l[d]-12*c[d]+6*u[d],p=-3*l[d]+9*c[d]-9*u[d]+3*h[d],_=3*c[d]-3*l[d];if(p===0){if(f===0)continue;const b=-_/f;0<b&&b<1&&(d===0&&this.addX(Ks(l[d],c[d],u[d],h[d],b)),d===1&&this.addY(Ks(l[d],c[d],u[d],h[d],b)));continue}const m=Math.pow(f,2)-4*_*p;if(m<0)continue;const g=(-f+Math.sqrt(m))/(2*p);0<g&&g<1&&(d===0&&this.addX(Ks(l[d],c[d],u[d],h[d],g)),d===1&&this.addY(Ks(l[d],c[d],u[d],h[d],g)));const v=(-f-Math.sqrt(m))/(2*p);0<v&&v<1&&(d===0&&this.addX(Ks(l[d],c[d],u[d],h[d],v)),d===1&&this.addY(Ks(l[d],c[d],u[d],h[d],v)))}};Ss.prototype.addQuad=function(n,e,t,i,s,r){const a=n+.6666666666666666*(t-n),o=e+2/3*(i-e),l=a+1/3*(s-n),c=o+1/3*(r-e);this.addBezier(n,e,a,o,l,c,s,r)};var Ip=Ss;function Wt(){this.commands=[],this.fill="black",this.stroke=null,this.strokeWidth=1}var Ir={};function Pp(n,e){const t=Math.floor(n),i=n-t;if(Ir[e]||(Ir[e]={}),Ir[e][i]!==void 0){const r=Ir[e][i];return t+r}const s=+(Math.round(i+"e+"+e)+"e-"+e);return Ir[e][i]=s,t+s}function Op(n){let e=[[]],t=0,i=0;for(let s=0;s<n.length;s+=1){const r=e[e.length-1],a=n[s],o=r[0],l=r[1],c=r[r.length-1],u=n[s+1];r.push(a),a.type==="M"?(t=a.x,i=a.y):a.type==="L"&&(!u||u.type==="Z")?Math.abs(a.x-t)>1||Math.abs(a.y-i)>1||r.pop():a.type==="L"&&c&&c.x===a.x&&c.y===a.y?r.pop():a.type==="Z"&&(o&&l&&c&&o.type==="M"&&l.type==="L"&&c.type==="L"&&c.x===o.x&&c.y===o.y&&(r.shift(),r[0].type="M"),s+1<n.length&&e.push([]))}return n=[].concat.apply([],e),n}function IS(n){return Object.assign({},{decimalPlaces:2,optimize:!0,flipY:!0,flipYBase:void 0,scale:1,x:0,y:0},n)}function PS(n){return parseInt(n)===n&&(n={decimalPlaces:n,flipY:!1}),Object.assign({},{decimalPlaces:2,optimize:!0,flipY:!0,flipYBase:void 0},n)}Wt.prototype.fromSVG=function(n,e={}){typeof SVGPathElement<"u"&&n instanceof SVGPathElement&&(n=n.getAttribute("d")),e=IS(e),this.commands=[];const t="0123456789",i="MmLlQqCcZzHhVv",s="SsTtAa",r="-+";let a={},o=[""],l=!1;function c(p){return p.filter(_=>_.length).map(_=>{let m=parseFloat(_);return(e.decimalPlaces||e.decimalPlaces===0)&&(m=Pp(m,e.decimalPlaces)),m})}function u(p){if(!this.commands.length)return p;const _=this.commands[this.commands.length-1];for(let m=0;m<p.length;m++)p[m]+=_[m&1?"y":"x"];return p}function h(){if(a.type===void 0)return;const p=a.type.toUpperCase(),_=p!=="Z"&&a.type.toUpperCase()!==a.type;let m=c(o);if(o=[""],!m.length&&p!=="Z")return;_&&p!=="H"&&p!=="V"&&(m=u.apply(this,[m]));const g=this.commands.length&&this.commands[this.commands.length-1].x||0,v=this.commands.length&&this.commands[this.commands.length-1].y||0;switch(p){case"M":this.moveTo(...m);break;case"L":this.lineTo(...m);break;case"V":for(let b=0;b<m.length;b++){let x=0;_&&(x=this.commands.length&&this.commands[this.commands.length-1].y||0),this.lineTo(g,m[b]+x)}break;case"H":for(let b=0;b<m.length;b++){let x=0;_&&(x=this.commands.length&&this.commands[this.commands.length-1].x||0),this.lineTo(m[b]+x,v)}break;case"C":this.bezierCurveTo(...m);break;case"Q":this.quadraticCurveTo(...m);break;case"Z":(this.commands.length<1||this.commands[this.commands.length-1].type!=="Z")&&this.close();break}if(this.commands.length)for(const b in this.commands[this.commands.length-1])this.commands[this.commands.length-1][b]===void 0&&(this.commands[this.commands.length-1][b]=0)}for(let p=0;p<n.length;p++){const _=n.charAt(p),m=o[o.length-1];if(t.indexOf(_)>-1)o[o.length-1]+=_;else if(r.indexOf(_)>-1)if(!a.type&&!this.commands.length&&(a.type="L"),_==="-")!a.type||m.indexOf("-")>0?l=!0:m.length?o.push("-"):o[o.length-1]=_;else if(!a.type||m.length>0)l=!0;else continue;else if(i.indexOf(_)>-1)a.type?(h.apply(this),a={type:_}):a.type=_;else{if(s.indexOf(_)>-1)throw new Error("Unsupported path command: "+_+". Currently supported commands are "+i.split("").join(", ")+".");` ,
\r\f\v`.indexOf(_)>-1?o.push(""):_==="."?!a.type||m.indexOf(_)>-1?l=!0:o[o.length-1]+=_:l=!0}if(l)throw new Error("Unexpected character: "+_+" at offset "+p)}h.apply(this),e.optimize&&(this.commands=Op(this.commands));const d=e.flipY;let f=e.flipYBase;if(d===!0&&e.flipYBase===void 0){const p=this.getBoundingBox();f=p.y1+p.y2}for(const p in this.commands){const _=this.commands[p];for(const m in _)["x","x1","x2"].includes(m)?this.commands[p][m]=e.x+_[m]*e.scale:["y","y1","y2"].includes(m)&&(this.commands[p][m]=e.y+(d?f-_[m]:_[m])*e.scale)}return this};Wt.fromSVG=function(n,e){return new Wt().fromSVG(n,e)};Wt.prototype.moveTo=function(n,e){this.commands.push({type:"M",x:n,y:e})};Wt.prototype.lineTo=function(n,e){this.commands.push({type:"L",x:n,y:e})};Wt.prototype.curveTo=Wt.prototype.bezierCurveTo=function(n,e,t,i,s,r){this.commands.push({type:"C",x1:n,y1:e,x2:t,y2:i,x:s,y:r})};Wt.prototype.quadTo=Wt.prototype.quadraticCurveTo=function(n,e,t,i){this.commands.push({type:"Q",x1:n,y1:e,x:t,y:i})};Wt.prototype.close=Wt.prototype.closePath=function(){this.commands.push({type:"Z"})};Wt.prototype.extend=function(n){if(n.commands)n=n.commands;else if(n instanceof Ip){const e=n;this.moveTo(e.x1,e.y1),this.lineTo(e.x2,e.y1),this.lineTo(e.x2,e.y2),this.lineTo(e.x1,e.y2),this.close();return}Array.prototype.push.apply(this.commands,n)};Wt.prototype.getBoundingBox=function(){const n=new Ip;let e=0,t=0,i=0,s=0;for(let r=0;r<this.commands.length;r++){const a=this.commands[r];switch(a.type){case"M":n.addPoint(a.x,a.y),e=i=a.x,t=s=a.y;break;case"L":n.addPoint(a.x,a.y),i=a.x,s=a.y;break;case"Q":n.addQuad(i,s,a.x1,a.y1,a.x,a.y),i=a.x,s=a.y;break;case"C":n.addBezier(i,s,a.x1,a.y1,a.x2,a.y2,a.x,a.y),i=a.x,s=a.y;break;case"Z":i=e,s=t;break;default:throw new Error("Unexpected path command "+a.type)}}return n.isEmpty()&&n.addPoint(0,0),n};Wt.prototype.draw=function(n){const e=this._layers;if(e&&e.length){for(let i=0;i<e.length;i++)this.draw.call(e[i],n);return}const t=this._image;if(t){n.drawImage(t.image,t.x,t.y,t.width,t.height);return}n.beginPath();for(let i=0;i<this.commands.length;i+=1){const s=this.commands[i];s.type==="M"?n.moveTo(s.x,s.y):s.type==="L"?n.lineTo(s.x,s.y):s.type==="C"?n.bezierCurveTo(s.x1,s.y1,s.x2,s.y2,s.x,s.y):s.type==="Q"?n.quadraticCurveTo(s.x1,s.y1,s.x,s.y):s.type==="Z"&&this.stroke&&this.strokeWidth&&n.closePath()}this.fill&&(n.fillStyle=this.fill,n.fill()),this.stroke&&(n.strokeStyle=this.stroke,n.lineWidth=this.strokeWidth,n.stroke())};Wt.prototype.toPathData=function(n){n=PS(n);function e(o){const l=Pp(o,n.decimalPlaces);return Math.round(o)===l?""+l:l.toFixed(n.decimalPlaces)}function t(){let o="";for(let l=0;l<arguments.length;l+=1){const c=arguments[l];c>=0&&l>0&&(o+=" "),o+=e(c)}return o}let i=this.commands;n.optimize&&(i=JSON.parse(JSON.stringify(this.commands)),i=Op(i));const s=n.flipY;let r=n.flipYBase;if(s===!0&&r===void 0){const o=new Wt;o.extend(i);const l=o.getBoundingBox();r=l.y1+l.y2}let a="";for(let o=0;o<i.length;o+=1){const l=i[o];l.type==="M"?a+="M"+t(l.x,s?r-l.y:l.y):l.type==="L"?a+="L"+t(l.x,s?r-l.y:l.y):l.type==="C"?a+="C"+t(l.x1,s?r-l.y1:l.y1,l.x2,s?r-l.y2:l.y2,l.x,s?r-l.y:l.y):l.type==="Q"?a+="Q"+t(l.x1,s?r-l.y1:l.y1,l.x,s?r-l.y:l.y):l.type==="Z"&&(a+="Z")}return a};Wt.prototype.toSVG=function(n,e){this._layers&&this._layers.length&&console.warn("toSVG() does not support colr font layers yet"),this._image&&console.warn("toSVG() does not support SVG glyphs yet"),e||(e=this.toPathData(n));let t='<path d="';return t+=e,t+='"',this.fill!==void 0&&this.fill!=="black"&&(this.fill===null?t+=' fill="none"':t+=' fill="'+this.fill+'"'),this.stroke&&(t+=' stroke="'+this.stroke+'" stroke-width="'+this.strokeWidth+'"'),t+="/>",t};Wt.prototype.toDOMElement=function(n,e){this._layers&&this._layers.length&&console.warn("toDOMElement() does not support colr font layers yet"),e||(e=this.toPathData(n));const t=document.createElementNS("http://www.w3.org/2000/svg","path");return t.setAttribute("d",e),this.fill!==void 0&&this.fill!=="black"&&(this.fill===null?t.setAttribute("fill","none"):t.setAttribute("fill",this.fill)),this.stroke&&(t.setAttribute("stroke",this.stroke),t.setAttribute("stroke-width",this.strokeWidth)),t};var cr=Wt;function Up(n){throw new Error(n)}function Sd(n,e){n||Up(e)}var Ve={fail:Up,argument:Sd,assert:Sd},bd=32768,Md=2147483648,OS=-32768,US=32767+1/65536,ur={},Ce={},Ze={};function Yn(n){return function(){return n}}Ce.BYTE=function(n){return Ve.argument(n>=0&&n<=255,"Byte value should be between 0 and 255."),[n]};Ze.BYTE=Yn(1);Ce.CHAR=function(n){return[n.charCodeAt(0)]};Ze.CHAR=Yn(1);Ce.CHARARRAY=function(n){(n===null||typeof n>"u")&&(n="",console.warn("CHARARRAY with undefined or null value encountered and treated as an empty string. This is probably caused by a missing glyph name."));const e=[];for(let t=0;t<n.length;t+=1)e[t]=n.charCodeAt(t);return e};Ze.CHARARRAY=function(n){return typeof n>"u"?0:n.length};Ce.USHORT=function(n){return[n>>8&255,n&255]};Ze.USHORT=Yn(2);Ce.SHORT=function(n){return n>=bd&&(n=-(2*bd-n)),[n>>8&255,n&255]};Ze.SHORT=Yn(2);Ce.UINT24=function(n){return[n>>16&255,n>>8&255,n&255]};Ze.UINT24=Yn(3);Ce.ULONG=function(n){return[n>>24&255,n>>16&255,n>>8&255,n&255]};Ze.ULONG=Yn(4);Ce.LONG=function(n){return n>=Md&&(n=-(2*Md-n)),[n>>24&255,n>>16&255,n>>8&255,n&255]};Ze.LONG=Yn(4);Ce.FLOAT=function(n){if(n>US||n<OS)throw new Error(`Value ${n} is outside the range of representable values in 16.16 format`);const e=Math.round(n*65536)<<0;return Ce.ULONG(e)};Ze.FLOAT=Ze.ULONG;Ce.FIXED=Ce.ULONG;Ze.FIXED=Ze.ULONG;Ce.FWORD=Ce.SHORT;Ze.FWORD=Ze.SHORT;Ce.UFWORD=Ce.USHORT;Ze.UFWORD=Ze.USHORT;Ce.F2DOT14=function(n){return Ce.USHORT(n*16384)};Ze.F2DOT14=Ze.USHORT;Ce.LONGDATETIME=function(n){return[0,0,0,0,n>>24&255,n>>16&255,n>>8&255,n&255]};Ze.LONGDATETIME=Yn(8);Ce.TAG=function(n){return Ve.argument(n.length===4,"Tag should be exactly 4 ASCII characters."),[n.charCodeAt(0),n.charCodeAt(1),n.charCodeAt(2),n.charCodeAt(3)]};Ze.TAG=Yn(4);Ce.Card8=Ce.BYTE;Ze.Card8=Ze.BYTE;Ce.Card16=Ce.USHORT;Ze.Card16=Ze.USHORT;Ce.OffSize=Ce.BYTE;Ze.OffSize=Ze.BYTE;Ce.SID=Ce.USHORT;Ze.SID=Ze.USHORT;Ce.NUMBER=function(n){return n>=-107&&n<=107?[n+139]:n>=108&&n<=1131?(n=n-108,[(n>>8)+247,n&255]):n>=-1131&&n<=-108?(n=-n-108,[(n>>8)+251,n&255]):n>=-32768&&n<=32767?Ce.NUMBER16(n):Ce.NUMBER32(n)};Ze.NUMBER=function(n){return Ce.NUMBER(n).length};Ce.NUMBER16=function(n){return[28,n>>8&255,n&255]};Ze.NUMBER16=Yn(3);Ce.NUMBER32=function(n){return[29,n>>24&255,n>>16&255,n>>8&255,n&255]};Ze.NUMBER32=Yn(5);Ce.REAL=function(n){let e=n.toString();const t=/\.(\d*?)(?:9{5,20}|0{5,20})\d{0,2}(?:e(.+)|$)/.exec(e);if(t){const r=parseFloat("1e"+((t[2]?+t[2]:0)+t[1].length));e=(Math.round(n*r)/r).toString()}let i="";for(let r=0,a=e.length;r<a;r+=1){const o=e[r];o==="e"?i+=e[++r]==="-"?"c":"b":o==="."?i+="a":o==="-"?i+="e":i+=o}i+=i.length&1?"f":"ff";const s=[30];for(let r=0,a=i.length;r<a;r+=2)s.push(parseInt(i.substr(r,2),16));return s};Ze.REAL=function(n){return Ce.REAL(n).length};Ce.NAME=Ce.CHARARRAY;Ze.NAME=Ze.CHARARRAY;Ce.STRING=Ce.CHARARRAY;Ze.STRING=Ze.CHARARRAY;ur.UTF8=function(n,e,t){const i=[],s=t;for(let r=0;r<s;r++,e+=1)i[r]=n.getUint8(e);return String.fromCharCode.apply(null,i)};ur.UTF16=function(n,e,t){const i=[],s=t/2;for(let r=0;r<s;r++,e+=2)i[r]=n.getUint16(e);return String.fromCharCode.apply(null,i)};Ce.UTF16=function(n){const e=[];for(let t=0;t<n.length;t+=1){const i=n.charCodeAt(t);e[e.length]=i>>8&255,e[e.length]=i&255}return e};Ze.UTF16=function(n){return n.length*2};var wo={"x-mac-croatian":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®Š™´¨≠ŽØ∞±≤≥∆µ∂∑∏š∫ªºΩžø¿¡¬√ƒ≈ƫȅ ÀÃÕŒœĐ—“”‘’÷◊©⁄€‹›Æ»–·‚„‰ÂćÁčÈÍÎÏÌÓÔđÒÚÛÙıˆ˜¯πË˚¸Êæˇ","x-mac-cyrillic":"АБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ†°Ґ£§•¶І®©™Ђђ≠Ѓѓ∞±≤≥іµґЈЄєЇїЉљЊњјЅ¬√ƒ≈∆«»… ЋћЌќѕ–—“”‘’÷„ЎўЏџ№Ёёяабвгдежзийклмнопрстуфхцчшщъыьэю","x-mac-gaelic":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ÆØḂ±≤≥ḃĊċḊḋḞḟĠġṀæøṁṖṗɼƒſṠ«»… ÀÃÕŒœ–—“”‘’ṡẛÿŸṪ€‹›Ŷŷṫ·Ỳỳ⁊ÂÊÁËÈÍÎÏÌÓÔ♣ÒÚÛÙıÝýŴŵẄẅẀẁẂẃ","x-mac-greek":"Ĺ²É³ÖÜ΅àâä΄¨çéèê룙î‰ôö¦€ùûü†ΓΔΘΛΞΠß®©ΣΪ§≠°·Α±≤≥¥ΒΕΖΗΙΚΜΦΫΨΩάΝ¬ΟΡ≈Τ«»… ΥΧΆΈœ–―“”‘’÷ΉΊΌΎέήίόΏύαβψδεφγηιξκλμνοπώρστθωςχυζϊϋΐΰ­","x-mac-icelandic":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûüݰ¢£§•¶ß®©™´¨≠ÆØ∞±≤≥¥µ∂∑∏π∫ªºΩæø¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸ⁄€ÐðÞþý·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙıˆ˜¯˘˙˚¸˝˛ˇ","x-mac-inuit":"ᐃᐄᐅᐆᐊᐋᐱᐲᐳᐴᐸᐹᑉᑎᑏᑐᑑᑕᑖᑦᑭᑮᑯᑰᑲᑳᒃᒋᒌᒍᒎᒐᒑ°ᒡᒥᒦ•¶ᒧ®©™ᒨᒪᒫᒻᓂᓃᓄᓅᓇᓈᓐᓯᓰᓱᓲᓴᓵᔅᓕᓖᓗᓘᓚᓛᓪᔨᔩᔪᔫᔭ… ᔮᔾᕕᕖᕗ–—“”‘’ᕘᕙᕚᕝᕆᕇᕈᕉᕋᕌᕐᕿᖀᖁᖂᖃᖄᖅᖏᖐᖑᖒᖓᖔᖕᙱᙲᙳᙴᙵᙶᖖᖠᖡᖢᖣᖤᖥᖦᕼŁł","x-mac-ce":"ÄĀāÉĄÖÜáąČäčĆć鏟ĎíďĒēĖóėôöõúĚěü†°Ę£§•¶ß®©™ę¨≠ģĮįĪ≤≥īĶ∂∑łĻļĽľĹĺŅņѬ√ńŇ∆«»… ňŐÕőŌ–—“”‘’÷◊ōŔŕŘ‹›řŖŗŠ‚„šŚśÁŤťÍŽžŪÓÔūŮÚůŰűŲųÝýķŻŁżĢˇ",macintosh:"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ÆØ∞±≤≥¥µ∂∑∏π∫ªºΩæø¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸ⁄€‹›fifl‡·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙıˆ˜¯˘˙˚¸˝˛ˇ","x-mac-romanian":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ĂȘ∞±≤≥¥µ∂∑∏π∫ªºΩăș¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸ⁄€‹›Țț‡·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙıˆ˜¯˘˙˚¸˝˛ˇ","x-mac-turkish":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ÆØ∞±≤≥¥µ∂∑∏π∫ªºΩæø¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸĞğİıŞş‡·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙˆ˜¯˘˙˚¸˝˛ˇ"};ur.MACSTRING=function(n,e,t,i){const s=wo[i];if(s===void 0)return;let r="";for(let a=0;a<t;a++){const o=n.getUint8(e+a);o<=127?r+=String.fromCharCode(o):r+=s[o&127]}return r};var Ja=typeof WeakMap=="function"&&new WeakMap,ja,NS=function(n){if(!ja){ja={};for(let s in wo)ja[s]=new String(s)}const e=ja[n];if(e===void 0)return;if(Ja){const s=Ja.get(e);if(s!==void 0)return s}const t=wo[n];if(t===void 0)return;const i={};for(let s=0;s<t.length;s++)i[t.charCodeAt(s)]=s+128;return Ja&&Ja.set(e,i),i};Ce.MACSTRING=function(n,e){const t=NS(e);if(t===void 0)return;const i=[];for(let s=0;s<n.length;s++){let r=n.charCodeAt(s);if(r>=128&&(r=t[r],r===void 0))return;i[s]=r}return i};Ze.MACSTRING=function(n,e){const t=Ce.MACSTRING(n,e);return t!==void 0?t.length:0};function jc(n){return n>=-128&&n<=127}function kS(n,e,t){let i=0;const s=n.length;for(;e<s&&i<64&&n[e]===0;)++e,++i;return t.push(128|i-1),e}function FS(n,e,t){let i=0;const s=n.length;let r=e;for(;r<s&&i<64;){const a=n[r];if(!jc(a)||a===0&&r+1<s&&n[r+1]===0)break;++r,++i}t.push(i-1);for(let a=e;a<r;++a)t.push(n[a]+256&255);return r}function BS(n,e,t){let i=0;const s=n.length;let r=e;for(;r<s&&i<64;){const a=n[r];if(a===0||jc(a)&&r+1<s&&jc(n[r+1]))break;++r,++i}t.push(64|i-1);for(let a=e;a<r;++a){const o=n[a];t.push(o+65536>>8&255,o+256&255)}return r}Ce.VARDELTAS=function(n){let e=0;const t=[];for(;e<n.length;){const i=n[e];i===0?e=kS(n,e,t):i>=-128&&i<=127?e=FS(n,e,t):e=BS(n,e,t)}return t};Ce.INDEX=function(n){let e=1;const t=[e],i=[];for(let o=0;o<n.length;o+=1){const l=Ce.OBJECT(n[o]);Array.prototype.push.apply(i,l),e+=l.length,t.push(e)}if(i.length===0)return[0,0];const s=[],r=1+Math.floor(Math.log(e)/Math.log(2))/8|0,a=[void 0,Ce.BYTE,Ce.USHORT,Ce.UINT24,Ce.ULONG][r];for(let o=0;o<t.length;o+=1){const l=a(t[o]);Array.prototype.push.apply(s,l)}return Array.prototype.concat(Ce.Card16(n.length),Ce.OffSize(r),s,i)};Ze.INDEX=function(n){return Ce.INDEX(n).length};Ce.DICT=function(n){let e=[];const t=Object.keys(n),i=t.length;for(let s=0;s<i;s+=1){const r=parseInt(t[s],0),a=n[r],o=Ce.OPERAND(a.value,a.type),l=Ce.OPERATOR(r);for(let c=0;c<o.length;c++)e.push(o[c]);for(let c=0;c<l.length;c++)e.push(l[c])}return e};Ze.DICT=function(n){return Ce.DICT(n).length};Ce.OPERATOR=function(n){return n<1200?[n]:[12,n-1200]};Ce.OPERAND=function(n,e){let t=[];if(Array.isArray(e))for(let i=0;i<e.length;i+=1){Ve.argument(n.length===e.length,"Not enough arguments given for type"+e);const s=Ce.OPERAND(n[i],e[i]);for(let r=0;r<s.length;r++)t.push(s[r])}else if(e==="SID"){const i=Ce.NUMBER(n);for(let s=0;s<i.length;s++)t.push(i[s])}else if(e==="offset"){const i=Ce.NUMBER32(n);for(let s=0;s<i.length;s++)t.push(i[s])}else if(e==="number"){const i=Ce.NUMBER(n);for(let s=0;s<i.length;s++)t.push(i[s])}else if(e==="real"){const i=Ce.REAL(n);for(let s=0;s<i.length;s++)t.push(i[s])}else throw new Error("Unknown operand type "+e);return t};Ce.OP=Ce.BYTE;Ze.OP=Ze.BYTE;var Qa=typeof WeakMap=="function"&&new WeakMap;Ce.CHARSTRING=function(n){if(Qa){const i=Qa.get(n);if(i!==void 0)return i}let e=[];const t=n.length;for(let i=0;i<t;i+=1){const s=n[i],r=Ce[s.type](s.value);for(let a=0;a<r.length;a++)e.push(r[a])}return Qa&&Qa.set(n,e),e};Ze.CHARSTRING=function(n){return Ce.CHARSTRING(n).length};Ce.OBJECT=function(n){const e=Ce[n.type];return Ve.argument(e!==void 0,"No encoding function for type "+n.type),e(n.value)};Ze.OBJECT=function(n){const e=Ze[n.type];return Ve.argument(e!==void 0,"No sizeOf function for type "+n.type),e(n.value)};Ce.TABLE=function(n){let e=[];const t=(n.fields||[]).length,i=[],s=[];for(let r=0;r<t;r+=1){const a=n.fields[r],o=Ce[a.type];Ve.argument(o!==void 0,"No encoding function for field type "+a.type+" ("+a.name+")");let l=n[a.name];l===void 0&&(l=a.value);const c=o(l);if(a.type==="TABLE")l.fields!==null&&(s.push(e.length),i.push(c)),e.push(0,0);else for(let u=0;u<c.length;u++)e.push(c[u])}for(let r=0;r<i.length;r+=1){const a=s[r],o=e.length;Ve.argument(o<65536,"Table "+n.tableName+" too big."),e[a]=o>>8,e[a+1]=o&255;for(let l=0;l<i[r].length;l++)e.push(i[r][l])}return e};Ze.TABLE=function(n){let e=0;const t=(n.fields||[]).length;for(let i=0;i<t;i+=1){const s=n.fields[i],r=Ze[s.type];Ve.argument(r!==void 0,"No sizeOf function for field type "+s.type+" ("+s.name+")");let a=n[s.name];a===void 0&&(a=s.value),e+=r(a),s.type==="TABLE"&&(e+=2)}return e};Ce.RECORD=Ce.TABLE;Ze.RECORD=Ze.TABLE;Ce.LITERAL=function(n){return n};Ze.LITERAL=function(n){return n.length};function Nt(n,e,t){if(e&&e.length)for(let i=0;i<e.length;i+=1){const s=e[i];this[s.name]=s.value}if(this.tableName=n,this.fields=e,t){const i=Object.keys(t);for(let s=0;s<i.length;s+=1){const r=i[s],a=t[r];this[r]!==void 0&&(this[r]=a)}}}Nt.prototype.encode=function(){return Ce.TABLE(this)};Nt.prototype.sizeOf=function(){return Ze.TABLE(this)};function hr(n,e,t){t===void 0&&(t=e.length);const i=new Array(e.length+1);i[0]={name:n+"Count",type:"USHORT",value:t};for(let s=0;s<e.length;s++)i[s+1]={name:n+s,type:"USHORT",value:e[s]};return i}function Qc(n,e,t){const i=e.length,s=new Array(i+1);s[0]={name:n+"Count",type:"USHORT",value:i};for(let r=0;r<i;r++)s[r+1]={name:n+r,type:"TABLE",value:t(e[r],r)};return s}function dr(n,e,t){const i=e.length;let s=[];s[0]={name:n+"Count",type:"USHORT",value:i};for(let r=0;r<i;r++)s=s.concat(t(e[r],r));return s}function Ro(n){n.format===1?Nt.call(this,"coverageTable",[{name:"coverageFormat",type:"USHORT",value:1}].concat(hr("glyph",n.glyphs))):n.format===2?Nt.call(this,"coverageTable",[{name:"coverageFormat",type:"USHORT",value:2}].concat(dr("rangeRecord",n.ranges,function(e,t){return[{name:"startGlyphID"+t,type:"USHORT",value:e.start},{name:"endGlyphID"+t,type:"USHORT",value:e.end},{name:"startCoverageIndex"+t,type:"USHORT",value:e.index}]}))):Ve.assert(!1,"Coverage format must be 1 or 2.")}Ro.prototype=Object.create(Nt.prototype);Ro.prototype.constructor=Ro;function Lo(n){Nt.call(this,"scriptListTable",dr("scriptRecord",n,function(e,t){const i=e.script;let s=i.defaultLangSys;return Ve.assert(!!s,"Unable to write GSUB: script "+e.tag+" has no default language system."),[{name:"scriptTag"+t,type:"TAG",value:e.tag},{name:"script"+t,type:"TABLE",value:new Nt("scriptTable",[{name:"defaultLangSys",type:"TABLE",value:new Nt("defaultLangSys",[{name:"lookupOrder",type:"USHORT",value:0},{name:"reqFeatureIndex",type:"USHORT",value:s.reqFeatureIndex}].concat(hr("featureIndex",s.featureIndexes)))}].concat(dr("langSys",i.langSysRecords,function(r,a){const o=r.langSys;return[{name:"langSysTag"+a,type:"TAG",value:r.tag},{name:"langSys"+a,type:"TABLE",value:new Nt("langSys",[{name:"lookupOrder",type:"USHORT",value:0},{name:"reqFeatureIndex",type:"USHORT",value:o.reqFeatureIndex}].concat(hr("featureIndex",o.featureIndexes)))}]})))}]}))}Lo.prototype=Object.create(Nt.prototype);Lo.prototype.constructor=Lo;function Do(n){Nt.call(this,"featureListTable",dr("featureRecord",n,function(e,t){const i=e.feature;return[{name:"featureTag"+t,type:"TAG",value:e.tag},{name:"feature"+t,type:"TABLE",value:new Nt("featureTable",[{name:"featureParams",type:"USHORT",value:i.featureParams}].concat(hr("lookupListIndex",i.lookupListIndexes)))}]}))}Do.prototype=Object.create(Nt.prototype);Do.prototype.constructor=Do;function Io(n,e){Nt.call(this,"lookupListTable",Qc("lookup",n,function(t){let i=e[t.lookupType];return Ve.assert(!!i,"Unable to write GSUB lookup type "+t.lookupType+" tables."),new Nt("lookupTable",[{name:"lookupType",type:"USHORT",value:t.lookupType},{name:"lookupFlag",type:"USHORT",value:t.lookupFlag}].concat(Qc("subtable",t.subtables,i)))}))}Io.prototype=Object.create(Nt.prototype);Io.prototype.constructor=Io;function Po(n){n.format===1?Nt.call(this,"classDefTable",[{name:"classFormat",type:"USHORT",value:1},{name:"startGlyphID",type:"USHORT",value:n.startGlyph}].concat(hr("glyph",n.classes))):n.format===2?Nt.call(this,"classDefTable",[{name:"classFormat",type:"USHORT",value:2}].concat(dr("rangeRecord",n.ranges,function(e,t){return[{name:"startGlyphID"+t,type:"USHORT",value:e.start},{name:"endGlyphID"+t,type:"USHORT",value:e.end},{name:"class"+t,type:"USHORT",value:e.classId}]}))):Ve.assert(!1,"Class format must be 1 or 2.")}Po.prototype=Object.create(Nt.prototype);Po.prototype.constructor=Po;var _e={Table:Nt,Record:Nt,Coverage:Ro,ClassDef:Po,ScriptList:Lo,FeatureList:Do,LookupList:Io,ushortList:hr,tableList:Qc,recordList:dr};function Ad(n,e){return n.getUint8(e)}function Oo(n,e){return n.getUint16(e,!1)}function HS(n,e){return n.getInt16(e,!1)}function Np(n,e){return(n.getUint16(e)<<8)+n.getUint8(e+2)}function Pu(n,e){return n.getUint32(e,!1)}function zS(n,e){return n.getInt32(e,!1)}function kp(n,e){const t=n.getInt16(e,!1),i=n.getUint16(e+2,!1);return t+i/65535}function VS(n,e){let t="";for(let i=e;i<e+4;i+=1)t+=String.fromCharCode(n.getInt8(i));return t}function GS(n,e,t){let i=0;for(let s=0;s<t;s+=1)i<<=8,i+=n.getUint8(e+s);return i}function WS(n,e,t){const i=[];for(let s=e;s<t;s+=1)i.push(n.getUint8(s));return i}function XS(n){let e="";for(let t=0;t<n.length;t+=1)e+=String.fromCharCode(n[t]);return e}var YS={byte:1,uShort:2,f2dot14:2,short:2,uInt24:3,uLong:4,fixed:4,longDateTime:8,tag:4},nn={LONG_WORDS:32768,WORD_DELTA_COUNT_MASK:32767,SHARED_POINT_NUMBERS:32768,COUNT_MASK:4095,EMBEDDED_PEAK_TUPLE:32768,INTERMEDIATE_REGION:16384,PRIVATE_POINT_NUMBERS:8192,TUPLE_INDEX_MASK:4095,POINTS_ARE_WORDS:128,POINT_RUN_COUNT_MASK:127,DELTAS_ARE_ZERO:128,DELTAS_ARE_WORDS:64,DELTA_RUN_COUNT_MASK:63,INNER_INDEX_BIT_COUNT_MASK:15,MAP_ENTRY_SIZE_MASK:48};function Y(n,e){this.data=n,this.offset=e,this.relativeOffset=0}Y.prototype.parseByte=function(){const n=this.data.getUint8(this.offset+this.relativeOffset);return this.relativeOffset+=1,n};Y.prototype.parseChar=function(){const n=this.data.getInt8(this.offset+this.relativeOffset);return this.relativeOffset+=1,n};Y.prototype.parseCard8=Y.prototype.parseByte;Y.prototype.parseUShort=function(){const n=this.data.getUint16(this.offset+this.relativeOffset);return this.relativeOffset+=2,n};Y.prototype.parseCard16=Y.prototype.parseUShort;Y.prototype.parseSID=Y.prototype.parseUShort;Y.prototype.parseOffset16=Y.prototype.parseUShort;Y.prototype.parseShort=function(){const n=this.data.getInt16(this.offset+this.relativeOffset);return this.relativeOffset+=2,n};Y.prototype.parseF2Dot14=function(){const n=this.data.getInt16(this.offset+this.relativeOffset)/16384;return this.relativeOffset+=2,n};Y.prototype.parseUInt24=function(){const n=Np(this.data,this.offset+this.relativeOffset);return this.relativeOffset+=3,n};Y.prototype.parseULong=function(){const n=Pu(this.data,this.offset+this.relativeOffset);return this.relativeOffset+=4,n};Y.prototype.parseLong=function(){const n=zS(this.data,this.offset+this.relativeOffset);return this.relativeOffset+=4,n};Y.prototype.parseOffset32=Y.prototype.parseULong;Y.prototype.parseFixed=function(){const n=kp(this.data,this.offset+this.relativeOffset);return this.relativeOffset+=4,n};Y.prototype.parseString=function(n){const e=this.data,t=this.offset+this.relativeOffset;let i="";this.relativeOffset+=n;for(let s=0;s<n;s++)i+=String.fromCharCode(e.getUint8(t+s));return i};Y.prototype.parseTag=function(){return this.parseString(4)};Y.prototype.parseLongDateTime=function(){let n=Pu(this.data,this.offset+this.relativeOffset+4);return n-=2082844800,this.relativeOffset+=8,n};Y.prototype.parseVersion=function(n){const e=Oo(this.data,this.offset+this.relativeOffset),t=Oo(this.data,this.offset+this.relativeOffset+2);return this.relativeOffset+=4,n===void 0&&(n=4096),e+t/n/10};Y.prototype.skip=function(n,e){e===void 0&&(e=1),this.relativeOffset+=YS[n]*e};Y.prototype.parseULongList=function(n){n===void 0&&(n=this.parseULong());const e=new Array(n),t=this.data;let i=this.offset+this.relativeOffset;for(let s=0;s<n;s++)e[s]=t.getUint32(i),i+=4;return this.relativeOffset+=n*4,e};Y.prototype.parseOffset16List=Y.prototype.parseUShortList=function(n){n===void 0&&(n=this.parseUShort());const e=new Array(n),t=this.data;let i=this.offset+this.relativeOffset;for(let s=0;s<n;s++)e[s]=t.getUint16(i),i+=2;return this.relativeOffset+=n*2,e};Y.prototype.parseShortList=function(n){const e=new Array(n),t=this.data;let i=this.offset+this.relativeOffset;for(let s=0;s<n;s++)e[s]=t.getInt16(i),i+=2;return this.relativeOffset+=n*2,e};Y.prototype.parseByteList=function(n){const e=new Array(n),t=this.data;let i=this.offset+this.relativeOffset;for(let s=0;s<n;s++)e[s]=t.getUint8(i++);return this.relativeOffset+=n,e};Y.prototype.parseList=function(n,e){e||(e=n,n=this.parseUShort());const t=new Array(n);for(let i=0;i<n;i++)t[i]=e.call(this);return t};Y.prototype.parseList32=function(n,e){e||(e=n,n=this.parseULong());const t=new Array(n);for(let i=0;i<n;i++)t[i]=e.call(this);return t};Y.prototype.parseRecordList=function(n,e){e||(e=n,n=this.parseUShort());const t=new Array(n),i=Object.keys(e);for(let s=0;s<n;s++){const r={};for(let a=0;a<i.length;a++){const o=i[a],l=e[o];r[o]=l.call(this)}t[s]=r}return t};Y.prototype.parseRecordList32=function(n,e){e||(e=n,n=this.parseULong());const t=new Array(n),i=Object.keys(e);for(let s=0;s<n;s++){const r={};for(let a=0;a<i.length;a++){const o=i[a],l=e[o];r[o]=l.call(this)}t[s]=r}return t};Y.prototype.parseTupleRecords=function(n,e){let t=[];for(let i=0;i<n;i++){let s=[];for(let r=0;r<e;r++)s.push(this.parseF2Dot14());t.push(s)}return t};Y.prototype.parseStruct=function(n){if(typeof n=="function")return n.call(this);{const e=Object.keys(n),t={};for(let i=0;i<e.length;i++){const s=e[i],r=n[s];t[s]=r.call(this)}return t}};Y.prototype.parseValueRecord=function(n){if(n===void 0&&(n=this.parseUShort()),n===0)return;const e={};return n&1&&(e.xPlacement=this.parseShort()),n&2&&(e.yPlacement=this.parseShort()),n&4&&(e.xAdvance=this.parseShort()),n&8&&(e.yAdvance=this.parseShort()),n&16&&(e.xPlaDevice=void 0,this.parseShort()),n&32&&(e.yPlaDevice=void 0,this.parseShort()),n&64&&(e.xAdvDevice=void 0,this.parseShort()),n&128&&(e.yAdvDevice=void 0,this.parseShort()),e};Y.prototype.parseValueRecordList=function(){const n=this.parseUShort(),e=this.parseUShort(),t=new Array(e);for(let i=0;i<e;i++)t[i]=this.parseValueRecord(n);return t};Y.prototype.parsePointer=function(n){const e=this.parseOffset16();if(e>0)return new Y(this.data,this.offset+e).parseStruct(n)};Y.prototype.parsePointer32=function(n){const e=this.parseOffset32();if(e>0)return new Y(this.data,this.offset+e).parseStruct(n)};Y.prototype.parseListOfLists=function(n){const e=this.parseOffset16List(),t=e.length,i=this.relativeOffset,s=new Array(t);for(let r=0;r<t;r++){const a=e[r];if(a===0){s[r]=void 0;continue}if(this.relativeOffset=a,n){const o=this.parseOffset16List(),l=new Array(o.length);for(let c=0;c<o.length;c++)this.relativeOffset=a+o[c],l[c]=n.call(this);s[r]=l}else s[r]=this.parseUShortList()}return this.relativeOffset=i,s};Y.prototype.parseCoverage=function(){const n=this.offset+this.relativeOffset,e=this.parseUShort(),t=this.parseUShort();if(e===1)return{format:1,glyphs:this.parseUShortList(t)};if(e===2){const i=new Array(t);for(let s=0;s<t;s++)i[s]={start:this.parseUShort(),end:this.parseUShort(),index:this.parseUShort()};return{format:2,ranges:i}}throw new Error("0x"+n.toString(16)+": Coverage format must be 1 or 2.")};Y.prototype.parseClassDef=function(){const n=this.offset+this.relativeOffset,e=this.parseUShort();return e===1?{format:1,startGlyph:this.parseUShort(),classes:this.parseUShortList()}:e===2?{format:2,ranges:this.parseRecordList({start:Y.uShort,end:Y.uShort,classId:Y.uShort})}:(console.warn(`0x${n.toString(16)}: This font file uses an invalid ClassDef format of ${e}. It might be corrupted and should be reacquired if it doesn't display as intended.`),{format:e})};Y.list=function(n,e){return function(){return this.parseList(n,e)}};Y.list32=function(n,e){return function(){return this.parseList32(n,e)}};Y.recordList=function(n,e){return function(){return this.parseRecordList(n,e)}};Y.recordList32=function(n,e){return function(){return this.parseRecordList32(n,e)}};Y.pointer=function(n){return function(){return this.parsePointer(n)}};Y.pointer32=function(n){return function(){return this.parsePointer32(n)}};Y.tag=Y.prototype.parseTag;Y.byte=Y.prototype.parseByte;Y.uShort=Y.offset16=Y.prototype.parseUShort;Y.uShortList=Y.prototype.parseUShortList;Y.uInt24=Y.prototype.parseUInt24;Y.uLong=Y.offset32=Y.prototype.parseULong;Y.uLongList=Y.prototype.parseULongList;Y.fixed=Y.prototype.parseFixed;Y.f2Dot14=Y.prototype.parseF2Dot14;Y.struct=Y.prototype.parseStruct;Y.coverage=Y.prototype.parseCoverage;Y.classDef=Y.prototype.parseClassDef;var Ed={reserved:Y.uShort,reqFeatureIndex:Y.uShort,featureIndexes:Y.uShortList};Y.prototype.parseScriptList=function(){return this.parsePointer(Y.recordList({tag:Y.tag,script:Y.pointer({defaultLangSys:Y.pointer(Ed),langSysRecords:Y.recordList({tag:Y.tag,langSys:Y.pointer(Ed)})})}))||[]};Y.prototype.parseFeatureList=function(){return this.parsePointer(Y.recordList({tag:Y.tag,feature:Y.pointer({featureParams:Y.offset16,lookupListIndexes:Y.uShortList})}))||[]};Y.prototype.parseLookupList=function(n){return this.parsePointer(Y.list(Y.pointer(function(){const e=this.parseUShort();Ve.argument(1<=e&&e<=9,"GPOS/GSUB lookup type "+e+" unknown.");const t=this.parseUShort(),i=t&16;return{lookupType:e,lookupFlag:t,subtables:this.parseList(Y.pointer(n[e])),markFilteringSet:i?this.parseUShort():void 0}})))||[]};Y.prototype.parseFeatureVariationsList=function(){return this.parsePointer32(function(){const n=this.parseUShort(),e=this.parseUShort();return Ve.argument(n===1&&e<1,"GPOS/GSUB feature variations table unknown."),this.parseRecordList32({conditionSetOffset:Y.offset32,featureTableSubstitutionOffset:Y.offset32})})||[]};Y.prototype.parseVariationStore=function(){const n=this.relativeOffset,e=this.parseUShort(),t={itemVariationStore:this.parseItemVariationStore()};return this.relativeOffset=n+e+2,t};Y.prototype.parseItemVariationStore=function(){const n=this.relativeOffset,e={format:this.parseUShort(),variationRegions:[],itemVariationSubtables:[]},t=this.parseOffset32(),i=this.parseUShort(),s=this.parseULongList(i);this.relativeOffset=n+t,e.variationRegions=this.parseVariationRegionList();for(let r=0;r<i;r++){const a=s[r];this.relativeOffset=n+a,e.itemVariationSubtables.push(this.parseItemVariationSubtable())}return e};Y.prototype.parseVariationRegionList=function(){const n=this.parseUShort(),e=this.parseUShort();return this.parseRecordList(e,{regionAxes:Y.recordList(n,{startCoord:Y.f2Dot14,peakCoord:Y.f2Dot14,endCoord:Y.f2Dot14})})};Y.prototype.parseItemVariationSubtable=function(){const n=this.parseUShort(),e=this.parseUShort(),t=this.parseUShortList(),i=t.length;return{regionIndexes:t,deltaSets:n&&i?this.parseDeltaSets(n,e,i):[]}};Y.prototype.parseDeltaSetIndexMap=function(){const n=this.parseByte(),e=this.parseByte(),t=[];let i=0;switch(n){case 0:i=this.parseUShort();break;case 1:i=this.parseULong();break;default:console.error(`unsupported DeltaSetIndexMap format ${n}`)}if(!i)return{format:n,entryFormat:e};const s=(e&nn.INNER_INDEX_BIT_COUNT_MASK)+1,r=((e&nn.MAP_ENTRY_SIZE_MASK)>>4)+1;for(let a=0;a<i;a++){let o;if(r===1)o=this.parseByte();else if(r===2)o=this.parseUShort();else if(r===3)o=this.parseUInt24();else if(r===4)o=this.parseULong();else throw new Error(`Invalid entry size of ${r}`);const l=o>>s,c=o&(1<<s)-1;t.push({outerIndex:l,innerIndex:c})}return{format:n,entryFormat:e,map:t}};Y.prototype.parseDeltaSets=function(n,e,t){const i=Array.from({length:n},()=>[]),s=e&nn.LONG_WORDS,r=e&nn.WORD_DELTA_COUNT_MASK;if(r>t)throw Error("wordCount must be less than or equal to regionIndexCount");const a=(s?this.parseLong:this.parseShort).bind(this),o=(s?this.parseShort:this.parseChar).bind(this);for(let l=0;l<n;l++)for(let c=0;c<t;c++)c<r?i[l].push(a()):i[l].push(o());return i};Y.prototype.parseTupleVariationStoreList=function(n,e,t){const i=this.parseUShort(),r=this.parseUShort()&1,a=this.parseOffset32(),o=(r?this.parseULong:this.parseUShort).bind(this),l={};let c=o();r||(c*=2);let u;for(let h=0;h<i;h++){u=o(),r||(u*=2);const d=u-c;l[h]=d?this.parseTupleVariationStore(a+c,n,e,t,h):void 0,c=u}return l};Y.prototype.parseTupleVariationStore=function(n,e,t,i,s){const r=this.relativeOffset;this.relativeOffset=n,t==="cvar"&&(this.relativeOffset+=4);const a=this.parseUShort(),o=!!(a&nn.SHARED_POINT_NUMBERS),l=a&nn.COUNT_MASK;let c=this.parseOffset16();const u=[];let h=[];for(let p=0;p<l;p++){const _=this.parseTupleVariationHeader(e,t);u.push(_)}this.relativeOffset!==n+c&&(console.warn(`Unexpected offset after parsing tuple variation headers! Expected ${n+c}, actually ${this.relativeOffset}`),this.relativeOffset=n+c),o&&(h=this.parsePackedPointNumbers());let d=this.relativeOffset;for(let p=0;p<l;p++){const _=u[p];_.privatePoints=[],this.relativeOffset=d,t==="cvar"&&!_.peakTuple&&console.warn("An embedded peak tuple is required in TupleVariationHeaders for the cvar table."),_.flags.privatePointNumbers&&(_.privatePoints=this.parsePackedPointNumbers()),delete _.flags;const m=this.offset,g=this.relativeOffset,v=b=>{let x,E;const S=()=>{let A=0;if(t==="gvar"){if(A=_.privatePoints.length||h.length,!A){const y=i.get(s);y.path,A=y.points.length,A+=4}}else t==="cvar"&&(A=i.length);this.offset=m,this.relativeOffset=g,x=this.parsePackedDeltas(A),t==="gvar"&&(E=this.parsePackedDeltas(A))};return{configurable:!0,get:function(){return x===void 0&&S(),b==="deltasY"?E:x},set:function(A){x===void 0&&S(),b==="deltasY"?E=A:x=A}}};Object.defineProperty(_,"deltas",v.call(this,"deltas")),t==="gvar"&&Object.defineProperty(_,"deltasY",v.call(this,"deltasY")),d+=_.variationDataSize,delete _.variationDataSize}this.relativeOffset=r;const f={headers:u};return f.sharedPoints=h,f};Y.prototype.parseTupleVariationHeader=function(n,e){const t=this.parseUShort(),i=this.parseUShort(),s=!!(i&nn.EMBEDDED_PEAK_TUPLE),r=!!(i&nn.INTERMEDIATE_REGION),a=!!(i&nn.PRIVATE_POINT_NUMBERS),o=s?void 0:i&nn.TUPLE_INDEX_MASK,l=s?this.parseTupleRecords(1,n)[0]:void 0,c=r?this.parseTupleRecords(1,n)[0]:void 0,u=r?this.parseTupleRecords(1,n)[0]:void 0,h={variationDataSize:t,peakTuple:l,intermediateStartTuple:c,intermediateEndTuple:u,flags:{embeddedPeakTuple:s,intermediateRegion:r,privatePointNumbers:a}};return e==="gvar"&&(h.sharedTupleRecordsIndex=o),h};Y.prototype.parsePackedPointNumbers=function(){const n=this.parseByte(),e=[];let t=n;if(n>=128){const s=this.parseByte();t=(n&nn.POINT_RUN_COUNT_MASK)<<8|s}let i=0;for(;e.length<t;){const s=this.parseByte(),r=!!(s&nn.POINTS_ARE_WORDS);let a=(s&nn.POINT_RUN_COUNT_MASK)+1;for(let o=0;o<a&&e.length<t;o++){let l;r?l=this.parseUShort():l=this.parseByte(),i=i+l,e.push(i)}}return e};Y.prototype.parsePackedDeltas=function(n){const e=[];for(;e.length<n;){const t=this.parseByte(),i=!!(t&nn.DELTAS_ARE_ZERO),s=!!(t&nn.DELTAS_ARE_WORDS),r=(t&nn.DELTA_RUN_COUNT_MASK)+1;for(let a=0;a<r&&e.length<n;a++)i?e.push(0):s?e.push(this.parseShort()):e.push(this.parseChar())}return e};var Ie={getByte:Ad,getCard8:Ad,getUShort:Oo,getCard16:Oo,getShort:HS,getUInt24:Np,getULong:Pu,getFixed:kp,getTag:VS,getOffset:GS,getBytes:WS,bytesToString:XS,Parser:Y},Uo=["copyright","fontFamily","fontSubfamily","uniqueID","fullName","version","postScriptName","trademark","manufacturer","designer","description","manufacturerURL","designerURL","license","licenseURL","reserved","preferredFamily","preferredSubfamily","compatibleFullName","sampleText","postScriptFindFontName","wwsFamily","wwsSubfamily"],Fp={0:"en",1:"fr",2:"de",3:"it",4:"nl",5:"sv",6:"es",7:"da",8:"pt",9:"no",10:"he",11:"ja",12:"ar",13:"fi",14:"el",15:"is",16:"mt",17:"tr",18:"hr",19:"zh-Hant",20:"ur",21:"hi",22:"th",23:"ko",24:"lt",25:"pl",26:"hu",27:"es",28:"lv",29:"se",30:"fo",31:"fa",32:"ru",33:"zh",34:"nl-BE",35:"ga",36:"sq",37:"ro",38:"cz",39:"sk",40:"si",41:"yi",42:"sr",43:"mk",44:"bg",45:"uk",46:"be",47:"uz",48:"kk",49:"az-Cyrl",50:"az-Arab",51:"hy",52:"ka",53:"mo",54:"ky",55:"tg",56:"tk",57:"mn-CN",58:"mn",59:"ps",60:"ks",61:"ku",62:"sd",63:"bo",64:"ne",65:"sa",66:"mr",67:"bn",68:"as",69:"gu",70:"pa",71:"or",72:"ml",73:"kn",74:"ta",75:"te",76:"si",77:"my",78:"km",79:"lo",80:"vi",81:"id",82:"tl",83:"ms",84:"ms-Arab",85:"am",86:"ti",87:"om",88:"so",89:"sw",90:"rw",91:"rn",92:"ny",93:"mg",94:"eo",128:"cy",129:"eu",130:"ca",131:"la",132:"qu",133:"gn",134:"ay",135:"tt",136:"ug",137:"dz",138:"jv",139:"su",140:"gl",141:"af",142:"br",143:"iu",144:"gd",145:"gv",146:"ga",147:"to",148:"el-polyton",149:"kl",150:"az",151:"nn"},KS={0:0,1:0,2:0,3:0,4:0,5:0,6:0,7:0,8:0,9:0,10:5,11:1,12:4,13:0,14:6,15:0,16:0,17:0,18:0,19:2,20:4,21:9,22:21,23:3,24:29,25:29,26:29,27:29,28:29,29:0,30:0,31:4,32:7,33:25,34:0,35:0,36:0,37:0,38:29,39:29,40:0,41:5,42:7,43:7,44:7,45:7,46:7,47:7,48:7,49:7,50:4,51:24,52:23,53:7,54:7,55:7,56:7,57:27,58:7,59:4,60:4,61:4,62:4,63:26,64:9,65:9,66:9,67:13,68:13,69:11,70:10,71:12,72:17,73:16,74:14,75:15,76:18,77:19,78:20,79:22,80:30,81:0,82:0,83:0,84:4,85:28,86:28,87:28,88:0,89:0,90:0,91:0,92:0,93:0,94:0,128:0,129:0,130:0,131:0,132:0,133:0,134:0,135:7,136:4,137:26,138:0,139:0,140:0,141:0,142:0,143:28,144:0,145:0,146:0,147:0,148:6,149:0,150:0,151:0},Bp={1078:"af",1052:"sq",1156:"gsw",1118:"am",5121:"ar-DZ",15361:"ar-BH",3073:"ar",2049:"ar-IQ",11265:"ar-JO",13313:"ar-KW",12289:"ar-LB",4097:"ar-LY",6145:"ary",8193:"ar-OM",16385:"ar-QA",1025:"ar-SA",10241:"ar-SY",7169:"aeb",14337:"ar-AE",9217:"ar-YE",1067:"hy",1101:"as",2092:"az-Cyrl",1068:"az",1133:"ba",1069:"eu",1059:"be",2117:"bn",1093:"bn-IN",8218:"bs-Cyrl",5146:"bs",1150:"br",1026:"bg",1027:"ca",3076:"zh-HK",5124:"zh-MO",2052:"zh",4100:"zh-SG",1028:"zh-TW",1155:"co",1050:"hr",4122:"hr-BA",1029:"cs",1030:"da",1164:"prs",1125:"dv",2067:"nl-BE",1043:"nl",3081:"en-AU",10249:"en-BZ",4105:"en-CA",9225:"en-029",16393:"en-IN",6153:"en-IE",8201:"en-JM",17417:"en-MY",5129:"en-NZ",13321:"en-PH",18441:"en-SG",7177:"en-ZA",11273:"en-TT",2057:"en-GB",1033:"en",12297:"en-ZW",1061:"et",1080:"fo",1124:"fil",1035:"fi",2060:"fr-BE",3084:"fr-CA",1036:"fr",5132:"fr-LU",6156:"fr-MC",4108:"fr-CH",1122:"fy",1110:"gl",1079:"ka",3079:"de-AT",1031:"de",5127:"de-LI",4103:"de-LU",2055:"de-CH",1032:"el",1135:"kl",1095:"gu",1128:"ha",1037:"he",1081:"hi",1038:"hu",1039:"is",1136:"ig",1057:"id",1117:"iu",2141:"iu-Latn",2108:"ga",1076:"xh",1077:"zu",1040:"it",2064:"it-CH",1041:"ja",1099:"kn",1087:"kk",1107:"km",1158:"quc",1159:"rw",1089:"sw",1111:"kok",1042:"ko",1088:"ky",1108:"lo",1062:"lv",1063:"lt",2094:"dsb",1134:"lb",1071:"mk",2110:"ms-BN",1086:"ms",1100:"ml",1082:"mt",1153:"mi",1146:"arn",1102:"mr",1148:"moh",1104:"mn",2128:"mn-CN",1121:"ne",1044:"nb",2068:"nn",1154:"oc",1096:"or",1123:"ps",1045:"pl",1046:"pt",2070:"pt-PT",1094:"pa",1131:"qu-BO",2155:"qu-EC",3179:"qu",1048:"ro",1047:"rm",1049:"ru",9275:"smn",4155:"smj-NO",5179:"smj",3131:"se-FI",1083:"se",2107:"se-SE",8251:"sms",6203:"sma-NO",7227:"sms",1103:"sa",7194:"sr-Cyrl-BA",3098:"sr",6170:"sr-Latn-BA",2074:"sr-Latn",1132:"nso",1074:"tn",1115:"si",1051:"sk",1060:"sl",11274:"es-AR",16394:"es-BO",13322:"es-CL",9226:"es-CO",5130:"es-CR",7178:"es-DO",12298:"es-EC",17418:"es-SV",4106:"es-GT",18442:"es-HN",2058:"es-MX",19466:"es-NI",6154:"es-PA",15370:"es-PY",10250:"es-PE",20490:"es-PR",3082:"es",1034:"es",21514:"es-US",14346:"es-UY",8202:"es-VE",2077:"sv-FI",1053:"sv",1114:"syr",1064:"tg",2143:"tzm",1097:"ta",1092:"tt",1098:"te",1054:"th",1105:"bo",1055:"tr",1090:"tk",1152:"ug",1058:"uk",1070:"hsb",1056:"ur",2115:"uz-Cyrl",1091:"uz",1066:"vi",1106:"cy",1160:"wo",1157:"sah",1144:"ii",1130:"yo"};function qS(n,e,t){switch(n){case 0:if(e===65535)return"und";if(t)return t[e];break;case 1:return Fp[e];case 3:return Bp[e]}}var eu="utf-16",$S={0:"macintosh",1:"x-mac-japanese",2:"x-mac-chinesetrad",3:"x-mac-korean",6:"x-mac-greek",7:"x-mac-cyrillic",9:"x-mac-devanagai",10:"x-mac-gurmukhi",11:"x-mac-gujarati",12:"x-mac-oriya",13:"x-mac-bengali",14:"x-mac-tamil",15:"x-mac-telugu",16:"x-mac-kannada",17:"x-mac-malayalam",18:"x-mac-sinhalese",19:"x-mac-burmese",20:"x-mac-khmer",21:"x-mac-thai",22:"x-mac-lao",23:"x-mac-georgian",24:"x-mac-armenian",25:"x-mac-chinesesimp",26:"x-mac-tibetan",27:"x-mac-mongolian",28:"x-mac-ethiopic",29:"x-mac-ce",30:"x-mac-vietnamese",31:"x-mac-extarabic"},ZS={15:"x-mac-icelandic",17:"x-mac-turkish",18:"x-mac-croatian",24:"x-mac-ce",25:"x-mac-ce",26:"x-mac-ce",27:"x-mac-ce",28:"x-mac-ce",30:"x-mac-icelandic",37:"x-mac-romanian",38:"x-mac-ce",39:"x-mac-ce",40:"x-mac-ce",143:"x-mac-inuit",146:"x-mac-gaelic"};function Ou(n,e,t){switch(n){case 0:return eu;case 1:return ZS[t]||$S[e];case 3:if(e===1||e===10)return eu;break}}var Hp={0:"unicode",1:"macintosh",2:"reserved",3:"windows"};function JS(n){return Hp[n]}function jS(n,e,t){const i={},s=new Ie.Parser(n,e),r=s.parseUShort(),a=s.parseUShort(),o=s.offset+s.parseUShort();for(let l=0;l<a;l++){const c=s.parseUShort(),u=s.parseUShort(),h=s.parseUShort(),d=s.parseUShort(),f=Uo[d]||d,p=s.parseUShort(),_=s.parseUShort(),m=qS(c,h,t),g=Ou(c,u,h),v=JS(c);if(g!==void 0&&m!==void 0&&v!==void 0){let b;if(g===eu?b=ur.UTF16(n,o+_,p):b=ur.MACSTRING(n,o+_,p,g),b){let x=i[v];x===void 0&&(x=i[v]={});let E=x[f];E===void 0&&(E=x[f]={}),E[m]=b}}}return r===1&&s.parseUShort(),i}function eo(n){const e={};for(let t in n)e[n[t]]=parseInt(t);return e}function Td(n,e,t,i,s,r){return new _e.Record("NameRecord",[{name:"platformID",type:"USHORT",value:n},{name:"encodingID",type:"USHORT",value:e},{name:"languageID",type:"USHORT",value:t},{name:"nameID",type:"USHORT",value:i},{name:"length",type:"USHORT",value:s},{name:"offset",type:"USHORT",value:r}])}function QS(n,e){const t=n.length,i=e.length-t+1;e:for(let s=0;s<i;s++)for(;s<i;s++){for(let r=0;r<t;r++)if(e[s+r]!==n[r])continue e;return s}return-1}function Cd(n,e){let t=QS(n,e);if(t<0){t=e.length;let i=0;const s=n.length;for(;i<s;++i)e.push(n[i])}return t}function eb(n,e){const t=eo(Hp),i=eo(Fp),s=eo(Bp),r=[],a=[];for(let l in n){let c;const u=[],h={},d=eo(Uo),f=t[l];for(let p in n[l]){let _=d[p];if(_===void 0&&(_=p),c=parseInt(_),isNaN(c))throw new Error('Name table entry "'+p+'" does not exist, see nameTableNames for complete list.');h[c]=n[l][p],u.push(c)}for(let p=0;p<u.length;p++){c=u[p];const _=h[c];for(let m in _){const g=_[m];if(f===1||f===0){let v=i[m],b=KS[v];const x=Ou(f,b,v);let E=Ce.MACSTRING(g,x);if(f===0&&(v=e.indexOf(m),v<0&&(v=e.length,e.push(m)),b=4,E=Ce.UTF16(g)),E!==void 0){const S=Cd(E,a);r.push(Td(f,b,v,c,E.length,S))}}if(f===3){const v=s[m];if(v!==void 0){const b=Ce.UTF16(g),x=Cd(b,a);r.push(Td(3,1,v,c,b.length,x))}}}}}r.sort(function(l,c){return l.platformID-c.platformID||l.encodingID-c.encodingID||l.languageID-c.languageID||l.nameID-c.nameID});const o=new _e.Table("name",[{name:"format",type:"USHORT",value:0},{name:"count",type:"USHORT",value:r.length},{name:"stringOffset",type:"USHORT",value:6+r.length*12}]);for(let l=0;l<r.length;l++)o.fields.push({name:"record_"+l,type:"RECORD",value:r[l]});return o.fields.push({name:"strings",type:"LITERAL",value:a}),o}function No(n,e,t=[]){if(e<256&&e in Uo){if(t.length&&!t.includes(parseInt(e)))return;e=Uo[e]}for(let i in n)for(let s in n[i])if(s===e||parseInt(s)===e)return n[i][s]}var zp={parse:jS,make:eb,getNameByID:No};function tb(n,e,t,i){n.length=e.parseUShort(),n.language=e.parseUShort()-1;const s=e.parseByteList(n.length),r=Object.assign({},s),a=Ou(t,i,n.language),o=wo[a];for(let l=0;l<o.length;l++)r[o.charCodeAt(l)]=s[128+l];n.glyphIndexMap=r}function nb(n,e,t){e.parseUShort(),n.length=e.parseULong(),n.language=e.parseULong();let i;n.groupCount=i=e.parseULong(),n.glyphIndexMap={};for(let s=0;s<i;s+=1){const r=e.parseULong(),a=e.parseULong();let o=e.parseULong();for(let l=r;l<=a;l+=1)n.glyphIndexMap[l]=o,t===12&&o++}}function ib(n,e,t,i,s){n.length=e.parseUShort(),n.language=e.parseUShort();let r;n.segCount=r=e.parseUShort()>>1,e.skip("uShort",3),n.glyphIndexMap={};const a=new Ie.Parser(t,i+s+14),o=new Ie.Parser(t,i+s+16+r*2),l=new Ie.Parser(t,i+s+16+r*4),c=new Ie.Parser(t,i+s+16+r*6);let u=i+s+16+r*8;for(let h=0;h<r-1;h+=1){let d;const f=a.parseUShort(),p=o.parseUShort(),_=l.parseShort(),m=c.parseUShort();for(let g=p;g<=f;g+=1)m!==0?(u=c.offset+c.relativeOffset-2,u+=m,u+=(g-p)*2,d=Ie.getUShort(t,u),d!==0&&(d=d+_&65535)):d=g+_&65535,n.glyphIndexMap[g]=d}}function sb(n,e){const t={};e.skip("uLong");const i=e.parseULong();for(let s=0;s<i;s+=1){const r=e.parseUInt24(),a={varSelector:r},o=e.parseOffset32(),l=e.parseOffset32(),c=e.relativeOffset;o&&(e.relativeOffset=o,a.defaultUVS=e.parseStruct({ranges:function(){return e.parseRecordList32({startUnicodeValue:e.parseUInt24,additionalCount:e.parseByte})}})),l&&(e.relativeOffset=l,a.nonDefaultUVS=e.parseStruct({uvsMappings:function(){const u={},h=e.parseRecordList32({unicodeValue:e.parseUInt24,glyphID:e.parseUShort});for(let d=0;d<h.length;d+=1)u[h[d].unicodeValue]=h[d];return u}})),t[r]=a,e.relativeOffset=c}n.varSelectorList=t}function rb(n,e){const t={};t.version=Ie.getUShort(n,e),Ve.argument(t.version===0,"cmap table version should be 0."),t.numTables=Ie.getUShort(n,e+2);let i=null,s=-1,r=-1,a=null,o=null;const l=[0,1,2,3,4,6],c=[0,1,10];for(let h=t.numTables-1;h>=0;h-=1)if(a=Ie.getUShort(n,e+4+h*8),o=Ie.getUShort(n,e+4+h*8+2),a===3&&c.includes(o)||a===0&&l.includes(o)||a===1&&o===0){if(r>0)continue;if(r=Ie.getULong(n,e+4+h*8+4),i)break}else if(a===0&&o===5){if(s=Ie.getULong(n,e+4+h*8+4),i=new Ie.Parser(n,e+s),i.parseUShort()!==14)s=-1,i=null;else if(r>0)break}if(r===-1)throw new Error("No valid cmap sub-tables found.");const u=new Ie.Parser(n,e+r);if(t.format=u.parseUShort(),t.format===0)tb(t,u,a,o);else if(t.format===12||t.format===13)nb(t,u,t.format);else if(t.format===4)ib(t,u,n,e,r);else throw new Error("Only format 0 (platformId 1, encodingId 0), 4, 12 and 14 cmap tables are supported (found format "+t.format+", platformId "+a+", encodingId "+o+").");return i&&sb(t,i),t}function ab(n,e,t){n.segments.push({end:e,start:e,delta:-(e-t),offset:0,glyphIndex:t})}function ob(n){n.segments.push({end:65535,start:65535,delta:1,offset:0})}function lb(n){if(n.length===0)return n;const e=[n[0]];for(let t=1;t<n.length;t++){const i=e[e.length-1],s=n[t];i.end+1===s.start&&i.delta===s.delta&&s.end!==65535?i.end=s.end:e.push(s)}return e}function cb(n){let e=!0,t;for(t=n.length-1;t>0;t-=1)if(n.get(t).unicode>65535){e=!1;break}let i=[{name:"version",type:"USHORT",value:0},{name:"numTables",type:"USHORT",value:e?1:2},{name:"platformID",type:"USHORT",value:3},{name:"encodingID",type:"USHORT",value:1},{name:"offset",type:"ULONG",value:e?12:20}];e||i.push({name:"cmap12PlatformID",type:"USHORT",value:3},{name:"cmap12EncodingID",type:"USHORT",value:10},{name:"cmap12Offset",type:"ULONG",value:0}),i.push({name:"format",type:"USHORT",value:4},{name:"cmap4Length",type:"USHORT",value:0},{name:"language",type:"USHORT",value:0},{name:"segCountX2",type:"USHORT",value:0},{name:"searchRange",type:"USHORT",value:0},{name:"entrySelector",type:"USHORT",value:0},{name:"rangeShift",type:"USHORT",value:0});const s=new _e.Table("cmap",i);for(s.segments=[],t=0;t<n.length;t+=1){const f=n.get(t);for(let p=0;p<f.unicodes.length;p+=1)ab(s,f.unicodes[p],t)}s.segments.sort(function(f,p){return f.start-p.start}),s.segments=lb(s.segments),ob(s);const r=s.segments.length;let a=0,o=[],l=[],c=[],u=[],h=[],d=[];for(t=0;t<r;t+=1){const f=s.segments[t];f.end<=65535&&f.start<=65535?(o.push({name:"end_"+t,type:"USHORT",value:f.end}),l.push({name:"start_"+t,type:"USHORT",value:f.start}),c.push({name:"idDelta_"+t,type:"SHORT",value:f.delta}),u.push({name:"idRangeOffset_"+t,type:"USHORT",value:f.offset}),f.glyphId!==void 0&&h.push({name:"glyph_"+t,type:"USHORT",value:f.glyphId})):a+=1,!e&&f.glyphIndex!==void 0&&(d.push({name:"cmap12Start_"+t,type:"ULONG",value:f.start}),d.push({name:"cmap12End_"+t,type:"ULONG",value:f.end}),d.push({name:"cmap12Glyph_"+t,type:"ULONG",value:f.glyphIndex}))}s.segCountX2=(r-a)*2,s.searchRange=Math.pow(2,Math.floor(Math.log(r-a)/Math.log(2)))*2,s.entrySelector=Math.log(s.searchRange/2)/Math.log(2),s.rangeShift=s.segCountX2-s.searchRange;for(let f=0;f<o.length;f++)s.fields.push(o[f]);s.fields.push({name:"reservedPad",type:"USHORT",value:0});for(let f=0;f<l.length;f++)s.fields.push(l[f]);for(let f=0;f<c.length;f++)s.fields.push(c[f]);for(let f=0;f<u.length;f++)s.fields.push(u[f]);for(let f=0;f<h.length;f++)s.fields.push(h[f]);if(s.cmap4Length=14+o.length*2+2+l.length*2+c.length*2+u.length*2+h.length*2,!e){const f=16+d.length*4;s.cmap12Offset=12+2*2+4+s.cmap4Length,s.fields.push({name:"cmap12Format",type:"USHORT",value:12},{name:"cmap12Reserved",type:"USHORT",value:0},{name:"cmap12Length",type:"ULONG",value:f},{name:"cmap12Language",type:"ULONG",value:0},{name:"cmap12nGroups",type:"ULONG",value:d.length/3});for(let p=0;p<d.length;p++)s.fields.push(d[p])}return s}var Vp={parse:rb,make:cb},mo=[".notdef","space","exclam","quotedbl","numbersign","dollar","percent","ampersand","quoteright","parenleft","parenright","asterisk","plus","comma","hyphen","period","slash","zero","one","two","three","four","five","six","seven","eight","nine","colon","semicolon","less","equal","greater","question","at","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","bracketleft","backslash","bracketright","asciicircum","underscore","quoteleft","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","braceleft","bar","braceright","asciitilde","exclamdown","cent","sterling","fraction","yen","florin","section","currency","quotesingle","quotedblleft","guillemotleft","guilsinglleft","guilsinglright","fi","fl","endash","dagger","daggerdbl","periodcentered","paragraph","bullet","quotesinglbase","quotedblbase","quotedblright","guillemotright","ellipsis","perthousand","questiondown","grave","acute","circumflex","tilde","macron","breve","dotaccent","dieresis","ring","cedilla","hungarumlaut","ogonek","caron","emdash","AE","ordfeminine","Lslash","Oslash","OE","ordmasculine","ae","dotlessi","lslash","oslash","oe","germandbls","onesuperior","logicalnot","mu","trademark","Eth","onehalf","plusminus","Thorn","onequarter","divide","brokenbar","degree","thorn","threequarters","twosuperior","registered","minus","eth","multiply","threesuperior","copyright","Aacute","Acircumflex","Adieresis","Agrave","Aring","Atilde","Ccedilla","Eacute","Ecircumflex","Edieresis","Egrave","Iacute","Icircumflex","Idieresis","Igrave","Ntilde","Oacute","Ocircumflex","Odieresis","Ograve","Otilde","Scaron","Uacute","Ucircumflex","Udieresis","Ugrave","Yacute","Ydieresis","Zcaron","aacute","acircumflex","adieresis","agrave","aring","atilde","ccedilla","eacute","ecircumflex","edieresis","egrave","iacute","icircumflex","idieresis","igrave","ntilde","oacute","ocircumflex","odieresis","ograve","otilde","scaron","uacute","ucircumflex","udieresis","ugrave","yacute","ydieresis","zcaron","exclamsmall","Hungarumlautsmall","dollaroldstyle","dollarsuperior","ampersandsmall","Acutesmall","parenleftsuperior","parenrightsuperior","266 ff","onedotenleader","zerooldstyle","oneoldstyle","twooldstyle","threeoldstyle","fouroldstyle","fiveoldstyle","sixoldstyle","sevenoldstyle","eightoldstyle","nineoldstyle","commasuperior","threequartersemdash","periodsuperior","questionsmall","asuperior","bsuperior","centsuperior","dsuperior","esuperior","isuperior","lsuperior","msuperior","nsuperior","osuperior","rsuperior","ssuperior","tsuperior","ff","ffi","ffl","parenleftinferior","parenrightinferior","Circumflexsmall","hyphensuperior","Gravesmall","Asmall","Bsmall","Csmall","Dsmall","Esmall","Fsmall","Gsmall","Hsmall","Ismall","Jsmall","Ksmall","Lsmall","Msmall","Nsmall","Osmall","Psmall","Qsmall","Rsmall","Ssmall","Tsmall","Usmall","Vsmall","Wsmall","Xsmall","Ysmall","Zsmall","colonmonetary","onefitted","rupiah","Tildesmall","exclamdownsmall","centoldstyle","Lslashsmall","Scaronsmall","Zcaronsmall","Dieresissmall","Brevesmall","Caronsmall","Dotaccentsmall","Macronsmall","figuredash","hypheninferior","Ogoneksmall","Ringsmall","Cedillasmall","questiondownsmall","oneeighth","threeeighths","fiveeighths","seveneighths","onethird","twothirds","zerosuperior","foursuperior","fivesuperior","sixsuperior","sevensuperior","eightsuperior","ninesuperior","zeroinferior","oneinferior","twoinferior","threeinferior","fourinferior","fiveinferior","sixinferior","seveninferior","eightinferior","nineinferior","centinferior","dollarinferior","periodinferior","commainferior","Agravesmall","Aacutesmall","Acircumflexsmall","Atildesmall","Adieresissmall","Aringsmall","AEsmall","Ccedillasmall","Egravesmall","Eacutesmall","Ecircumflexsmall","Edieresissmall","Igravesmall","Iacutesmall","Icircumflexsmall","Idieresissmall","Ethsmall","Ntildesmall","Ogravesmall","Oacutesmall","Ocircumflexsmall","Otildesmall","Odieresissmall","OEsmall","Oslashsmall","Ugravesmall","Uacutesmall","Ucircumflexsmall","Udieresissmall","Yacutesmall","Thornsmall","Ydieresissmall","001.000","001.001","001.002","001.003","Black","Bold","Book","Light","Medium","Regular","Roman","Semibold"],ub=[".notdef","space","exclam","quotedbl","numbersign","dollar","percent","ampersand","quoteright","parenleft","parenright","asterisk","plus","comma","hyphen","period","slash","zero","one","two","three","four","five","six","seven","eight","nine","colon","semicolon","less","equal","greater","question","at","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","bracketleft","backslash","bracketright","asciicircum","underscore","quoteleft","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","braceleft","bar","braceright","asciitilde","exclamdown","cent","sterling","fraction","yen","florin","section","currency","quotesingle","quotedblleft","guillemotleft","guilsinglleft","guilsinglright","fi","fl","endash","dagger","daggerdbl","periodcentered","paragraph","bullet","quotesinglbase","quotedblbase","quotedblright","guillemotright","ellipsis","perthousand","questiondown","grave","acute","circumflex","tilde","macron","breve","dotaccent","dieresis","ring","cedilla","hungarumlaut","ogonek","caron","emdash","AE","ordfeminine","Lslash","Oslash","OE","ordmasculine","ae","dotlessi","lslash","oslash","oe","germandbls","onesuperior","logicalnot","mu","trademark","Eth","onehalf","plusminus","Thorn","onequarter","divide","brokenbar","degree","thorn","threequarters","twosuperior","registered","minus","eth","multiply","threesuperior","copyright","Aacute","Acircumflex","Adieresis","Agrave","Aring","Atilde","Ccedilla","Eacute","Ecircumflex","Edieresis","Egrave","Iacute","Icircumflex","Idieresis","Igrave","Ntilde","Oacute","Ocircumflex","Odieresis","Ograve","Otilde","Scaron","Uacute","Ucircumflex","Udieresis","Ugrave","Yacute","Ydieresis","Zcaron","aacute","acircumflex","adieresis","agrave","aring","atilde","ccedilla","eacute","ecircumflex","edieresis","egrave","iacute","icircumflex","idieresis","igrave","ntilde","oacute","ocircumflex","odieresis","ograve","otilde","scaron","uacute","ucircumflex","udieresis","ugrave","yacute","ydieresis","zcaron"],hb=[".notdef","space","exclamsmall","Hungarumlautsmall","dollaroldstyle","dollarsuperior","ampersandsmall","Acutesmall","parenleftsuperior","parenrightsuperior","twodotenleader","onedotenleader","comma","hyphen","period","fraction","zerooldstyle","oneoldstyle","twooldstyle","threeoldstyle","fouroldstyle","fiveoldstyle","sixoldstyle","sevenoldstyle","eightoldstyle","nineoldstyle","colon","semicolon","commasuperior","threequartersemdash","periodsuperior","questionsmall","asuperior","bsuperior","centsuperior","dsuperior","esuperior","isuperior","lsuperior","msuperior","nsuperior","osuperior","rsuperior","ssuperior","tsuperior","ff","fi","fl","ffi","ffl","parenleftinferior","parenrightinferior","Circumflexsmall","hyphensuperior","Gravesmall","Asmall","Bsmall","Csmall","Dsmall","Esmall","Fsmall","Gsmall","Hsmall","Ismall","Jsmall","Ksmall","Lsmall","Msmall","Nsmall","Osmall","Psmall","Qsmall","Rsmall","Ssmall","Tsmall","Usmall","Vsmall","Wsmall","Xsmall","Ysmall","Zsmall","colonmonetary","onefitted","rupiah","Tildesmall","exclamdownsmall","centoldstyle","Lslashsmall","Scaronsmall","Zcaronsmall","Dieresissmall","Brevesmall","Caronsmall","Dotaccentsmall","Macronsmall","figuredash","hypheninferior","Ogoneksmall","Ringsmall","Cedillasmall","onequarter","onehalf","threequarters","questiondownsmall","oneeighth","threeeighths","fiveeighths","seveneighths","onethird","twothirds","zerosuperior","onesuperior","twosuperior","threesuperior","foursuperior","fivesuperior","sixsuperior","sevensuperior","eightsuperior","ninesuperior","zeroinferior","oneinferior","twoinferior","threeinferior","fourinferior","fiveinferior","sixinferior","seveninferior","eightinferior","nineinferior","centinferior","dollarinferior","periodinferior","commainferior","Agravesmall","Aacutesmall","Acircumflexsmall","Atildesmall","Adieresissmall","Aringsmall","AEsmall","Ccedillasmall","Egravesmall","Eacutesmall","Ecircumflexsmall","Edieresissmall","Igravesmall","Iacutesmall","Icircumflexsmall","Idieresissmall","Ethsmall","Ntildesmall","Ogravesmall","Oacutesmall","Ocircumflexsmall","Otildesmall","Odieresissmall","OEsmall","Oslashsmall","Ugravesmall","Uacutesmall","Ucircumflexsmall","Udieresissmall","Yacutesmall","Thornsmall","Ydieresissmall"],db=[".notdef","space","dollaroldstyle","dollarsuperior","parenleftsuperior","parenrightsuperior","twodotenleader","onedotenleader","comma","hyphen","period","fraction","zerooldstyle","oneoldstyle","twooldstyle","threeoldstyle","fouroldstyle","fiveoldstyle","sixoldstyle","sevenoldstyle","eightoldstyle","nineoldstyle","colon","semicolon","commasuperior","threequartersemdash","periodsuperior","asuperior","bsuperior","centsuperior","dsuperior","esuperior","isuperior","lsuperior","msuperior","nsuperior","osuperior","rsuperior","ssuperior","tsuperior","ff","fi","fl","ffi","ffl","parenleftinferior","parenrightinferior","hyphensuperior","colonmonetary","onefitted","rupiah","centoldstyle","figuredash","hypheninferior","onequarter","onehalf","threequarters","oneeighth","threeeighths","fiveeighths","seveneighths","onethird","twothirds","zerosuperior","onesuperior","twosuperior","threesuperior","foursuperior","fivesuperior","sixsuperior","sevensuperior","eightsuperior","ninesuperior","zeroinferior","oneinferior","twoinferior","threeinferior","fourinferior","fiveinferior","sixinferior","seveninferior","eightinferior","nineinferior","centinferior","dollarinferior","periodinferior","commainferior"],tu=["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","space","exclam","quotedbl","numbersign","dollar","percent","ampersand","quoteright","parenleft","parenright","asterisk","plus","comma","hyphen","period","slash","zero","one","two","three","four","five","six","seven","eight","nine","colon","semicolon","less","equal","greater","question","at","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","bracketleft","backslash","bracketright","asciicircum","underscore","quoteleft","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","braceleft","bar","braceright","asciitilde","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","exclamdown","cent","sterling","fraction","yen","florin","section","currency","quotesingle","quotedblleft","guillemotleft","guilsinglleft","guilsinglright","fi","fl","","endash","dagger","daggerdbl","periodcentered","","paragraph","bullet","quotesinglbase","quotedblbase","quotedblright","guillemotright","ellipsis","perthousand","","questiondown","","grave","acute","circumflex","tilde","macron","breve","dotaccent","dieresis","","ring","cedilla","","hungarumlaut","ogonek","caron","emdash","","","","","","","","","","","","","","","","","AE","","ordfeminine","","","","","Lslash","Oslash","OE","ordmasculine","","","","","","ae","","","","dotlessi","","","lslash","oslash","oe","germandbls"],fb=["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","space","exclamsmall","Hungarumlautsmall","","dollaroldstyle","dollarsuperior","ampersandsmall","Acutesmall","parenleftsuperior","parenrightsuperior","twodotenleader","onedotenleader","comma","hyphen","period","fraction","zerooldstyle","oneoldstyle","twooldstyle","threeoldstyle","fouroldstyle","fiveoldstyle","sixoldstyle","sevenoldstyle","eightoldstyle","nineoldstyle","colon","semicolon","commasuperior","threequartersemdash","periodsuperior","questionsmall","","asuperior","bsuperior","centsuperior","dsuperior","esuperior","","","isuperior","","","lsuperior","msuperior","nsuperior","osuperior","","","rsuperior","ssuperior","tsuperior","","ff","fi","fl","ffi","ffl","parenleftinferior","","parenrightinferior","Circumflexsmall","hyphensuperior","Gravesmall","Asmall","Bsmall","Csmall","Dsmall","Esmall","Fsmall","Gsmall","Hsmall","Ismall","Jsmall","Ksmall","Lsmall","Msmall","Nsmall","Osmall","Psmall","Qsmall","Rsmall","Ssmall","Tsmall","Usmall","Vsmall","Wsmall","Xsmall","Ysmall","Zsmall","colonmonetary","onefitted","rupiah","Tildesmall","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","exclamdownsmall","centoldstyle","Lslashsmall","","","Scaronsmall","Zcaronsmall","Dieresissmall","Brevesmall","Caronsmall","","Dotaccentsmall","","","Macronsmall","","","figuredash","hypheninferior","","","Ogoneksmall","Ringsmall","Cedillasmall","","","","onequarter","onehalf","threequarters","questiondownsmall","oneeighth","threeeighths","fiveeighths","seveneighths","onethird","twothirds","","","zerosuperior","onesuperior","twosuperior","threesuperior","foursuperior","fivesuperior","sixsuperior","sevensuperior","eightsuperior","ninesuperior","zeroinferior","oneinferior","twoinferior","threeinferior","fourinferior","fiveinferior","sixinferior","seveninferior","eightinferior","nineinferior","centinferior","dollarinferior","periodinferior","commainferior","Agravesmall","Aacutesmall","Acircumflexsmall","Atildesmall","Adieresissmall","Aringsmall","AEsmall","Ccedillasmall","Egravesmall","Eacutesmall","Ecircumflexsmall","Edieresissmall","Igravesmall","Iacutesmall","Icircumflexsmall","Idieresissmall","Ethsmall","Ntildesmall","Ogravesmall","Oacutesmall","Ocircumflexsmall","Otildesmall","Odieresissmall","OEsmall","Oslashsmall","Ugravesmall","Uacutesmall","Ucircumflexsmall","Udieresissmall","Yacutesmall","Thornsmall","Ydieresissmall"],us=[".notdef",".null","nonmarkingreturn","space","exclam","quotedbl","numbersign","dollar","percent","ampersand","quotesingle","parenleft","parenright","asterisk","plus","comma","hyphen","period","slash","zero","one","two","three","four","five","six","seven","eight","nine","colon","semicolon","less","equal","greater","question","at","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","bracketleft","backslash","bracketright","asciicircum","underscore","grave","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","braceleft","bar","braceright","asciitilde","Adieresis","Aring","Ccedilla","Eacute","Ntilde","Odieresis","Udieresis","aacute","agrave","acircumflex","adieresis","atilde","aring","ccedilla","eacute","egrave","ecircumflex","edieresis","iacute","igrave","icircumflex","idieresis","ntilde","oacute","ograve","ocircumflex","odieresis","otilde","uacute","ugrave","ucircumflex","udieresis","dagger","degree","cent","sterling","section","bullet","paragraph","germandbls","registered","copyright","trademark","acute","dieresis","notequal","AE","Oslash","infinity","plusminus","lessequal","greaterequal","yen","mu","partialdiff","summation","product","pi","integral","ordfeminine","ordmasculine","Omega","ae","oslash","questiondown","exclamdown","logicalnot","radical","florin","approxequal","Delta","guillemotleft","guillemotright","ellipsis","nonbreakingspace","Agrave","Atilde","Otilde","OE","oe","endash","emdash","quotedblleft","quotedblright","quoteleft","quoteright","divide","lozenge","ydieresis","Ydieresis","fraction","currency","guilsinglleft","guilsinglright","fi","fl","daggerdbl","periodcentered","quotesinglbase","quotedblbase","perthousand","Acircumflex","Ecircumflex","Aacute","Edieresis","Egrave","Iacute","Icircumflex","Idieresis","Igrave","Oacute","Ocircumflex","apple","Ograve","Uacute","Ucircumflex","Ugrave","dotlessi","circumflex","tilde","macron","breve","dotaccent","ring","cedilla","hungarumlaut","ogonek","caron","Lslash","lslash","Scaron","scaron","Zcaron","zcaron","brokenbar","Eth","eth","Yacute","yacute","Thorn","thorn","minus","multiply","onesuperior","twosuperior","threesuperior","onehalf","onequarter","threequarters","franc","Gbreve","gbreve","Idotaccent","Scedilla","scedilla","Cacute","cacute","Ccaron","ccaron","dcroat"];function Gp(n){this.font=n}Gp.prototype.charToGlyphIndex=function(n){const e=n.codePointAt(0),t=this.font.glyphs;if(t)for(let i=0;i<t.length;i+=1){const s=t.get(i);for(let r=0;r<s.unicodes.length;r+=1)if(s.unicodes[r]===e)return i}return null};function Wp(n){this.cmap=n}Wp.prototype.charToGlyphIndex=function(n){return this.cmap.glyphIndexMap[n.codePointAt(0)]||0};function Xp(n,e){this.encoding=n,this.charset=e}Xp.prototype.charToGlyphIndex=function(n){const e=n.codePointAt(0),t=this.encoding[e];return this.charset.indexOf(t)};function Uu(n){switch(n.version){case 1:this.names=us.slice();break;case 2:this.names=new Array(n.numberOfGlyphs);for(let e=0;e<n.numberOfGlyphs;e++)n.glyphNameIndex[e]<us.length?this.names[e]=us[n.glyphNameIndex[e]]:this.names[e]=n.names[n.glyphNameIndex[e]-us.length];break;case 2.5:this.names=new Array(n.numberOfGlyphs);for(let e=0;e<n.numberOfGlyphs;e++)this.names[e]=us[e+n.glyphNameIndex[e]];break;case 3:this.names=[];break;default:this.names=[];break}}Uu.prototype.nameToGlyphIndex=function(n){return this.names.indexOf(n)};Uu.prototype.glyphIndexToName=function(n){return this.names[n]};function pb(n){let e;const t=n.tables.cmap.glyphIndexMap,i=Object.keys(t);for(let s=0;s<i.length;s+=1){const r=i[s],a=t[r];e=n.glyphs.get(a),e.addUnicode(parseInt(r))}for(let s=0;s<n.glyphs.length;s+=1)e=n.glyphs.get(s),n.cffEncoding?e.name=n.cffEncoding.charset[s]:n.glyphNames.names&&(e.name=n.glyphNames.glyphIndexToName(s))}function mb(n){n._IndexToUnicodeMap={};const e=n.tables.cmap.glyphIndexMap,t=Object.keys(e);for(let i=0;i<t.length;i+=1){const s=t[i];let r=e[s];n._IndexToUnicodeMap[r]===void 0?n._IndexToUnicodeMap[r]={unicodes:[parseInt(s)]}:n._IndexToUnicodeMap[r].unicodes.push(parseInt(s))}}function gb(n,e){e.lowMemory?mb(n):pb(n)}function _b(n,e,t,i,s){n.beginPath(),n.moveTo(e,t),n.lineTo(i,s),n.stroke()}var as={line:_b};function xb(n,e){const t=new Y(n,e),i=t.parseShort();i!==0&&console.warn("Only CPALv0 is currently fully supported.");const s=t.parseShort(),r=t.parseShort(),a=t.parseShort(),o=t.parseOffset32(),l=t.parseUShortList(r);t.relativeOffset=o;const c=t.parseULongList(a);return t.relativeOffset=o,{version:i,numPaletteEntries:s,colorRecords:c,colorRecordIndices:l}}function yb({version:n=0,numPaletteEntries:e=0,colorRecords:t=[],colorRecordIndices:i=[0]}){return Ve.argument(n===0,"Only CPALv0 are supported."),Ve.argument(t.length,"No colorRecords given."),Ve.argument(i.length,"No colorRecordIndices given."),i.length>1&&Ve.argument(e,"Can't infer numPaletteEntries on multiple colorRecordIndices"),new _e.Table("CPAL",[{name:"version",type:"USHORT",value:n},{name:"numPaletteEntries",type:"USHORT",value:e||t.length},{name:"numPalettes",type:"USHORT",value:i.length},{name:"numColorRecords",type:"USHORT",value:t.length},{name:"colorRecordsArrayOffset",type:"ULONG",value:12+2*i.length},...i.map((s,r)=>({name:"colorRecordIndices_"+r,type:"USHORT",value:s})),...t.map((s,r)=>({name:"colorRecords_"+r,type:"ULONG",value:s}))])}function Yp(n){var e=(n&4278190080)>>24,t=(n&16711680)>>16,i=(n&65280)>>8,s=n&255;return e=e+256&255,t=t+256&255,i=i+256&255,s=(s+256&255)/255,{b:e,g:t,r:i,a:s}}function Nu(n,e,t=0,i="hexa"){if(e==65535)return"currentColor";const s=n&&n.tables&&n.tables.cpal;if(!s)return"currentColor";if(t>s.colorRecordIndices.length-1)throw new Error(`Palette index out of range (colorRecordIndices.length: ${s.colorRecordIndices.length}, index: ${e})`);if(e>s.numPaletteEntries)throw new Error(`Color index out of range (numPaletteEntries: ${s.numPaletteEntries}, index: ${e})`);const r=s.colorRecordIndices[t]+e;if(r>s.colorRecords)throw new Error(`Color index out of range (colorRecords.length: ${s.colorRecords.length}, lookupIndex: ${r})`);const a=Yp(s.colorRecords[r]);return i==="bgra"?a:fr(a,i)}function Hn(n){return("0"+parseInt(n).toString(16)).slice(-2)}function vb(n){const e=n.r/255,t=n.g/255,i=n.b/255,s=Math.max(e,t,i),r=Math.min(e,t,i);let a,o,l=(s+r)/2;if(s===r)a=o=0;else{const c=s-r;switch(o=l>.5?c/(2-s-r):c/(s+r),s){case e:a=(t-i)/c+(t<i?6:0);break;case t:a=(i-e)/c+2;break;case i:a=(e-t)/c+4;break}a/=6}return{h:a*360,s:o*100,l:l*100}}function Sb(n){let{h:e,s:t,l:i,a:s}=n;e=e%360,t/=100,i/=100;const r=(1-Math.abs(2*i-1))*t,a=r*(1-Math.abs(e/60%2-1)),o=i-r/2;let l=0,c=0,u=0;return 0<=e&&e<60?(l=r,c=a,u=0):60<=e&&e<120?(l=a,c=r,u=0):120<=e&&e<180?(l=0,c=r,u=a):180<=e&&e<240?(l=0,c=a,u=r):240<=e&&e<300?(l=a,c=0,u=r):300<=e&&e<=360&&(l=r,c=0,u=a),{r:Math.round((l+o)*255),g:Math.round((c+o)*255),b:Math.round((u+o)*255),a:s}}function Kp(n){return parseInt(`0x${Hn(n.b)}${Hn(n.g)}${Hn(n.r)}${Hn(n.a*255)}`,16)}function ko(n,e="hexa"){const t=e=="raw"||e=="cpal",i=Number.isInteger(n);let s=!0;if(i&&t||n==="currentColor")return n;if(typeof n=="object"){if(e=="bgra")return n;if(t)return Kp(n)}else if(!i&&/^#([a-f0-9]{3}|[a-f0-9]{4}|[a-f0-9]{6}|[a-f0-9]{8})$/i.test(n.trim())){switch(n=n.trim().substring(1),n.length){case 3:n={r:parseInt(n[0].repeat(2),16),g:parseInt(n[1].repeat(2),16),b:parseInt(n[2].repeat(2),16),a:1};break;case 4:n={r:parseInt(n[0].repeat(2),16),g:parseInt(n[1].repeat(2),16),b:parseInt(n[2].repeat(2),16),a:parseInt(n[3].repeat(2),16)/255};break;case 6:n={r:parseInt(n[0]+n[1],16),g:parseInt(n[2]+n[3],16),b:parseInt(n[4]+n[5],16),a:1};break;case 8:n={r:parseInt(n[0]+n[1],16),g:parseInt(n[2]+n[3],16),b:parseInt(n[4]+n[5],16),a:parseInt(n[6]+n[7],16)/255};break}if(e=="bgra")return n}else if(typeof document<"u"&&/^[a-z]+$/i.test(n)){const r=document.createElement("canvas").getContext("2d");r.fillStyle=n;const a=fr(r.fillStyle,"hexa");a==="#000000ff"&&n.toLowerCase()!=="black"?s=!1:n=a}else{n=n.trim();const r=/rgba?\(\s*(?:(\d*\.\d+)(%?)|(\d+)(%?))\s*(?:,|\s*)\s*(?:(\d*\.\d+)(%?)|(\d+)(%?))\s*(?:,|\s*)\s*(?:(\d*\.\d+)(%?)|(\d+)(%?))\s*(?:(?:,|\s|\/)\s*(?:(0*(?:\.\d+)?()|0*1(?:\.0+)?())|(?:\.\d+)|(\d+)(%)|(\d*\.\d+)(%)))?\s*\)/;if(r.test(n)){const a=n.match(r).filter(o=>typeof o<"u");n={r:Math.round(parseFloat(a[1])/(a[2]?100/255:1)),g:Math.round(parseFloat(a[3])/(a[4]?100/255:1)),b:Math.round(parseFloat(a[5])/(a[6]?100/255:1)),a:a[7]?parseFloat(a[7])/(a[8]?100:1):1}}else{const a=/hsla?\(\s*(?:(\d*\.\d+|\d+)(deg|turn|))\s*(?:,|\s*)\s*(?:(\d*\.\d+)%?|(\d+)%?)\s*(?:,|\s*)\s*(?:(\d*\.\d+)%?|(\d+)%?)\s*(?:(?:,|\s|\/)\s*(?:(0*(?:\.\d+)?()|0*1(?:\.0+)?())|(?:\.\d+)|(\d+)(%)|(\d*\.\d+)(%)))?\s*\)/;if(a.test(n)){const o=n.match(a).filter(l=>typeof l<"u");n=Sb({h:parseFloat(o[1])*(o[2]==="turn"?360:1),s:parseFloat(o[3]),l:parseFloat(o[4]),a:o[5]?parseFloat(o[5])/(o[6]?100:1):1})}else s=!1}}if(!s)throw new Error(`Invalid color format: ${n}`);return fr(n,e)}function fr(n,e="hexa"){if(n==="currentColor")return n;if(Number.isInteger(n)){if(e=="raw"||e=="cpal")return n;n=Yp(n)}else typeof n!="object"&&(n=ko(n,"bgra"));let t=["hsl","hsla"].includes(e)?vb(n):null;switch(e){case"rgba":return`rgba(${n.r}, ${n.g}, ${n.b}, ${parseFloat(n.a.toFixed(3))})`;case"rgb":return`rgb(${n.r}, ${n.g}, ${n.b})`;case"hex":case"hex6":case"hex-6":return`#${Hn(n.r)}${Hn(n.g)}${Hn(n.b)}`;case"hexa":case"hex8":case"hex-8":return`#${Hn(n.r)}${Hn(n.g)}${Hn(n.b)}${Hn(n.a*255)}`;case"hsl":return`hsl(${t.h.toFixed(2)}, ${t.s.toFixed(2)}%, ${t.l.toFixed(2)}%)`;case"hsla":return`hsla(${t.h.toFixed(2)}, ${t.s.toFixed(2)}%, ${t.l.toFixed(2)}%, ${parseFloat(n.a.toFixed(3))})`;case"bgra":return n;case"raw":case"cpal":return Kp(n);default:throw new Error("Unknown color format: "+e)}}var qp={parse:xb,make:yb,getPaletteColor:Nu,parseColor:ko,formatColor:fr};function bb(n,e){let t=e||new cr;return{configurable:!0,get:function(){return typeof t=="function"&&(t=t()),t},set:function(i){t=i}}}function rn(n){this.bindConstructorValues(n)}rn.prototype.bindConstructorValues=function(n){if(this.index=n.index||0,n.name===".notdef"?n.unicode=void 0:n.name===".null"&&(n.unicode=0),n.unicode===0&&n.name!==".null")throw new Error('The unicode value "0" is reserved for the glyph name ".null" and cannot be used by any other glyph.');this.name=n.name||null,this.unicode=n.unicode,this.unicodes=n.unicodes||(n.unicode!==void 0?[n.unicode]:[]),"xMin"in n&&(this.xMin=n.xMin),"yMin"in n&&(this.yMin=n.yMin),"xMax"in n&&(this.xMax=n.xMax),"yMax"in n&&(this.yMax=n.yMax),"advanceWidth"in n&&(this.advanceWidth=n.advanceWidth),"leftSideBearing"in n&&(this.leftSideBearing=n.leftSideBearing),"points"in n&&(this.points=n.points),Object.defineProperty(this,"path",bb(this,n.path))};rn.prototype.addUnicode=function(n){this.unicodes.length===0&&(this.unicode=n),this.unicodes.push(n)};rn.prototype.getBoundingBox=function(){return this.path.getBoundingBox()};rn.prototype.getPath=function(n,e,t,i,s){n=n!==void 0?n:0,e=e!==void 0?e:0,t=t!==void 0?t:72,i=Object.assign({},s&&s.defaultRenderOptions,i);let r,a,o=i.xScale,l=i.yScale;const c=1/(this.path.unitsPerEm||1e3)*t;let u=this;s&&s.variation&&(u=s.variation.getTransform(this,i.variation),r=u.path.commands),i.hinting&&s&&s.hinting&&(a=u.path&&s.hinting.exec(u,t,i)),a?(r=s.hinting.getCommands(a),n=Math.round(n),e=Math.round(e),o=l=1):(r=u.path.commands,o===void 0&&(o=c),l===void 0&&(l=c));const h=new cr;if(i.drawSVG){const d=this.getSvgImage(s);if(d){const f=new cr;return f._image={image:d.image,x:n+d.leftSideBearing*c,y:e-d.baseline*c,width:d.image.width*c,height:d.image.height*c},h._layers=[f],h}}if(i.drawLayers){const d=this.getLayers(s);if(d&&d.length){h._layers=[];for(let f=0;f<d.length;f+=1){const p=d[f];let _=Nu(s,p.paletteIndex,i.usePalette);_==="currentColor"?_=i.fill||"black":_=fr(_,i.colorFormat||"rgba"),i=Object.assign({},i,{fill:_}),h._layers.push(this.getPath.call(p.glyph,n,e,t,i,s))}return h}}h.fill=i.fill||this.path.fill,h.stroke=this.path.stroke,h.strokeWidth=this.path.strokeWidth*c;for(let d=0;d<r.length;d+=1){const f=r[d];f.type==="M"?h.moveTo(n+f.x*o,e+-f.y*l):f.type==="L"?h.lineTo(n+f.x*o,e+-f.y*l):f.type==="Q"?h.quadraticCurveTo(n+f.x1*o,e+-f.y1*l,n+f.x*o,e+-f.y*l):f.type==="C"?h.curveTo(n+f.x1*o,e+-f.y1*l,n+f.x2*o,e+-f.y2*l,n+f.x*o,e+-f.y*l):f.type==="Z"&&h.stroke&&h.strokeWidth&&h.closePath()}return h};rn.prototype.getLayers=function(n){if(!n)throw new Error("The font object is required to read the colr/cpal tables in order to get the layers.");return n.layers.get(this.index)};rn.prototype.getSvgImage=function(n){if(!n)throw new Error("The font object is required to read the svg table in order to get the image.");return n.svgImages.get(this.index)};rn.prototype.getContours=function(n=null){if(this.points===void 0&&!n)return[];const e=[];let t=[],i=n||this.points;for(let s=0;s<i.length;s+=1){const r=i[s];t.push(r),r.lastPointOfContour&&(e.push(t),t=[])}return Ve.argument(t.length===0,"There are still points left in the current contour."),e};rn.prototype.getMetrics=function(){const n=this.path.commands,e=[],t=[];for(let s=0;s<n.length;s+=1){const r=n[s];r.type!=="Z"&&(e.push(r.x),t.push(r.y)),(r.type==="Q"||r.type==="C")&&(e.push(r.x1),t.push(r.y1)),r.type==="C"&&(e.push(r.x2),t.push(r.y2))}const i={xMin:Math.min.apply(null,e),yMin:Math.min.apply(null,t),xMax:Math.max.apply(null,e),yMax:Math.max.apply(null,t),leftSideBearing:this.leftSideBearing};return isFinite(i.xMin)||(i.xMin=0),isFinite(i.xMax)||(i.xMax=this.advanceWidth),isFinite(i.yMin)||(i.yMin=0),isFinite(i.yMax)||(i.yMax=0),i.rightSideBearing=this.advanceWidth-i.leftSideBearing-(i.xMax-i.xMin),i};rn.prototype.draw=function(n,e,t,i,s,r){s=Object.assign({},r&&r.defaultRenderOptions,s),this.getPath(e,t,i,s,r).draw(n)};rn.prototype.drawPoints=function(n,e,t,i,s,r){if(s=Object.assign({},r&&r.defaultRenderOptions,s),s.drawLayers){const d=this.getLayers(r);if(d&&d.length){for(let f=0;f<d.length;f+=1)d[f].glyph.index!==this.index&&this.drawPoints.call(d[f].glyph,n,e,t,i);return}}function a(d,f,p,_){n.beginPath();for(let m=0;m<d.length;m+=1)n.moveTo(f+d[m].x*_,p+d[m].y*_),n.arc(f+d[m].x*_,p+d[m].y*_,2,0,Math.PI*2,!1);n.fill()}e=e!==void 0?e:0,t=t!==void 0?t:0,i=i!==void 0?i:24;const o=1/this.path.unitsPerEm*i,l=[],c=[];let h=this.path.commands;r&&r.variation&&(h=r.variation.getTransform(this,s.variation).path.commands);for(let d=0;d<h.length;d+=1){const f=h[d];f.x!==void 0&&l.push({x:f.x,y:-f.y}),f.x1!==void 0&&c.push({x:f.x1,y:-f.y1}),f.x2!==void 0&&c.push({x:f.x2,y:-f.y2})}n.fillStyle="blue",a(l,e,t,o),n.fillStyle="red",a(c,e,t,o)};rn.prototype.drawMetrics=function(n,e,t,i){let s;e=e!==void 0?e:0,t=t!==void 0?t:0,i=i!==void 0?i:24,s=1/this.path.unitsPerEm*i,n.lineWidth=1,n.strokeStyle="black",as.line(n,e,-1e4,e,1e4),as.line(n,-1e4,t,1e4,t);const r=this.xMin||0;let a=this.yMin||0;const o=this.xMax||0;let l=this.yMax||0;const c=this.advanceWidth||0;n.strokeStyle="blue",as.line(n,e+r*s,-1e4,e+r*s,1e4),as.line(n,e+o*s,-1e4,e+o*s,1e4),as.line(n,-1e4,t+-a*s,1e4,t+-a*s),as.line(n,-1e4,t+-l*s,1e4,t+-l*s),n.strokeStyle="green",as.line(n,e+c*s,-1e4,e+c*s,1e4)};rn.prototype.toPathData=function(n,e){n=Object.assign({},{variation:e&&e.defaultRenderOptions.variation},n);let t=this;e&&e.variation&&(t=e.variation.getTransform(this,n.variation));let i=t.points&&n.pointsTransform?n.pointsTransform(t.points):t.path;return n.pathTransform&&(i=n.pathTransform(i)),i.toPathData(n)};rn.prototype.fromSVG=function(n,e={}){return this.path.fromSVG(n,e)};rn.prototype.toSVG=function(n,e){const t=this.toPathData.apply(this,[n,e]);return this.path.toSVG(n,t)};rn.prototype.toDOMElement=function(n,e){n=Object.assign({},{variation:e&&e.defaultRenderOptions.variation},n);let t=this.path;return e&&e.variation&&(t=e.variation.getTransform(this,n.variation).path),t.toDOMElement(n)};var Qr=rn;function qs(n,e,t){Object.defineProperty(n,e,{get:function(){return typeof n[t]>"u"&&n.path,n[t]},set:function(i){n[t]=i},enumerable:!0,configurable:!0})}function Ko(n,e){if(this.font=n,this.glyphs={},Array.isArray(e))for(let t=0;t<e.length;t++){const i=e[t];i.path.unitsPerEm=n.unitsPerEm,this.glyphs[t]=i}this.length=e&&e.length||0}typeof Symbol<"u"&&Symbol.iterator&&(Ko.prototype[Symbol.iterator]=function(){let n=-1;return{next:(function(){n++;const e=n>=this.length-1;return{value:this.get(n),done:e}}).bind(this)}});Ko.prototype.get=function(n){if(this.font._push&&this.glyphs[n]===void 0){this.font._push(n),typeof this.glyphs[n]=="function"&&(this.glyphs[n]=this.glyphs[n]());let e=this.glyphs[n],t=this.font._IndexToUnicodeMap[n];if(t)for(let i=0;i<t.unicodes.length;i++)e.addUnicode(t.unicodes[i]);this.font.cffEncoding?e.name=this.font.cffEncoding.charset[n]:this.font.glyphNames.names&&(e.name=this.font.glyphNames.glyphIndexToName(n)),this.glyphs[n].advanceWidth=this.font._hmtxTableData[n].advanceWidth,this.glyphs[n].leftSideBearing=this.font._hmtxTableData[n].leftSideBearing}else typeof this.glyphs[n]=="function"&&(this.glyphs[n]=this.glyphs[n]());return this.glyphs[n]};Ko.prototype.push=function(n,e){this.glyphs[n]=e,this.length++};function Mb(n,e){return new Qr({index:e,font:n})}function Ab(n,e,t,i,s,r){return function(){const a=new Qr({index:e,font:n});return a.path=function(){t(a,i,s);const o=r(n.glyphs,a);return o.unitsPerEm=n.unitsPerEm,o},qs(a,"numberOfContours","_numberOfContours"),qs(a,"xMin","_xMin"),qs(a,"xMax","_xMax"),qs(a,"yMin","_yMin"),qs(a,"yMax","_yMax"),qs(a,"points","_points"),a}}function Eb(n,e,t,i,s){return function(){const r=new Qr({index:e,font:n});return r.path=function(){const a=t(n,r,i,s);return a.unitsPerEm=n.unitsPerEm,a},r}}var hi={GlyphSet:Ko,glyphLoader:Mb,ttfGlyphLoader:Ab,cffGlyphLoader:Eb};function $p(n,e){if(n===e)return!0;if(Array.isArray(n)&&Array.isArray(e)){if(n.length!==e.length)return!1;for(let t=0;t<n.length;t+=1)if(!$p(n[t],e[t]))return!1;return!0}else return!1}var wd=10;function Fo(n){let e;return n.length<1240?e=107:n.length<33900?e=1131:e=32768,e}function ni(n,e,t,i){const s=[],r=[],a=i>1?Ie.getULong(n,e):Ie.getCard16(n,e),o=i>1?4:2;let l,c;if(a!==0){const u=Ie.getByte(n,e+o);l=e+(a+1)*u+o;let h=e+o+1;for(let d=0;d<a+1;d+=1)s.push(Ie.getOffset(n,h,u)),h+=u;c=l+s[a]}else c=e+o;for(let u=0;u<s.length-1;u+=1){let h=Ie.getBytes(n,l+s[u],l+s[u+1]);t&&(h=t(h,n,e,i)),r.push(h)}return{objects:r,startOffset:e,endOffset:c}}function Tb(n,e,t){const i=[],s=t>1?Ie.getULong(n,e):Ie.getCard16(n,e),r=t>1?4:2;let a,o;if(s!==0){const l=Ie.getByte(n,e+r);a=e+(s+1)*l+r;let c=e+r+1;for(let u=0;u<s+1;u+=1)i.push(Ie.getOffset(n,c,l)),c+=l;o=a+i[s]}else o=e+r;return{offsets:i,startOffset:e,endOffset:o}}function Cb(n,e,t,i,s,r){const a=r>1?Ie.getULong(t,i):Ie.getCard16(t,i),o=r>1?4:2;let l=0;if(a!==0){const u=Ie.getByte(t,i+o);l=i+(a+1)*u+o}return Ie.getBytes(t,l+e[n],l+e[n+1])}function wb(n){let e="";const i=["0","1","2","3","4","5","6","7","8","9",".","E","E-",null,"-"];for(;;){const s=n.parseByte(),r=s>>4,a=s&15;if(r===15||(e+=i[r],a===15))break;e+=i[a]}return parseFloat(e)}function Rb(n,e){let t,i,s,r;if(e===28)return t=n.parseByte(),i=n.parseByte(),t<<8|i;if(e===29)return t=n.parseByte(),i=n.parseByte(),s=n.parseByte(),r=n.parseByte(),t<<24|i<<16|s<<8|r;if(e===30)return wb(n);if(e>=32&&e<=246)return e-139;if(e>=247&&e<=250)return t=n.parseByte(),(e-247)*256+t+108;if(e>=251&&e<=254)return t=n.parseByte(),-(e-251)*256-t-108;throw new Error("Invalid b0 "+e)}function Lb(n){const e={};for(let t=0;t<n.length;t+=1){const i=n[t][0],s=n[t][1];let r;if(s.length===1?r=s[0]:r=s,Object.prototype.hasOwnProperty.call(e,i)&&!isNaN(e[i]))throw new Error("Object "+e+" already has key "+i);e[i]=r}return e}function ku(n,e,t,i){e=e!==void 0?e:0;const s=new Ie.Parser(n,e),r=[];let a=[];t=t!==void 0?t:n.byteLength;let o=i<2?22:28;for(;s.relativeOffset<t;){let l=s.parseByte();if(l<o){if(l===12&&(l=1200+s.parseByte()),i>1&&l===23){Hb(a);continue}r.push([l,a]),a=[]}else a.push(Rb(s,l))}return Lb(r)}function Wr(n,e){return e<=390?e=mo[e]:n?e=n[e-391]:e=void 0,e}function Fu(n,e,t){const i={};let s;for(let r=0;r<e.length;r+=1){const a=e[r];if(Array.isArray(a.type)){const o=[];o.length=a.type.length;for(let l=0;l<a.type.length;l++)s=n[a.op]!==void 0?n[a.op][l]:void 0,s===void 0&&(s=a.value!==void 0&&a.value[l]!==void 0?a.value[l]:null),a.type[l]==="SID"&&(s=Wr(t,s)),o[l]=s;i[a.name]=o}else s=n[a.op],s===void 0&&(s=a.value!==void 0?a.value:null),a.type==="SID"&&(s=Wr(t,s)),i[a.name]=s}return i}function Db(n,e){const t={};if(t.formatMajor=Ie.getCard8(n,e),t.formatMinor=Ie.getCard8(n,e+1),t.formatMajor>2)throw new Error(`Unsupported CFF table version ${t.formatMajor}.${t.formatMinor}`);return t.size=Ie.getCard8(n,e+2),t.formatMajor<2?(t.offsetSize=Ie.getCard8(n,e+3),t.startOffset=e,t.endOffset=e+4):(t.topDictLength=Ie.getCard16(n,e+3),t.endOffset=e+8),t}var Zp=[{name:"version",op:0,type:"SID"},{name:"notice",op:1,type:"SID"},{name:"copyright",op:1200,type:"SID"},{name:"fullName",op:2,type:"SID"},{name:"familyName",op:3,type:"SID"},{name:"weight",op:4,type:"SID"},{name:"isFixedPitch",op:1201,type:"number",value:0},{name:"italicAngle",op:1202,type:"number",value:0},{name:"underlinePosition",op:1203,type:"number",value:-100},{name:"underlineThickness",op:1204,type:"number",value:50},{name:"paintType",op:1205,type:"number",value:0},{name:"charstringType",op:1206,type:"number",value:2},{name:"fontMatrix",op:1207,type:["real","real","real","real","real","real"],value:[.001,0,0,.001,0,0]},{name:"uniqueId",op:13,type:"number"},{name:"fontBBox",op:5,type:["number","number","number","number"],value:[0,0,0,0]},{name:"strokeWidth",op:1208,type:"number",value:0},{name:"xuid",op:14,type:[],value:null},{name:"charset",op:15,type:"offset",value:0},{name:"encoding",op:16,type:"offset",value:0},{name:"charStrings",op:17,type:"offset",value:0},{name:"private",op:18,type:["number","offset"],value:[0,0]},{name:"ros",op:1230,type:["SID","SID","number"]},{name:"cidFontVersion",op:1231,type:"number",value:0},{name:"cidFontRevision",op:1232,type:"number",value:0},{name:"cidFontType",op:1233,type:"number",value:0},{name:"cidCount",op:1234,type:"number",value:8720},{name:"uidBase",op:1235,type:"number"},{name:"fdArray",op:1236,type:"offset"},{name:"fdSelect",op:1237,type:"offset"},{name:"fontName",op:1238,type:"SID"}],Ib=[{name:"fontMatrix",op:1207,type:["real","real","real","real","real","real"],value:[.001,0,0,.001,0,0]},{name:"charStrings",op:17,type:"offset"},{name:"fdArray",op:1236,type:"offset"},{name:"fdSelect",op:1237,type:"offset"},{name:"vstore",op:24,type:"offset"}],Jp=[{name:"subrs",op:19,type:"offset",value:0},{name:"defaultWidthX",op:20,type:"number",value:0},{name:"nominalWidthX",op:21,type:"number",value:0}],Pb=[{name:"blueValues",op:6,type:"delta"},{name:"otherBlues",op:7,type:"delta"},{name:"familyBlues",op:7,type:"delta"},{name:"familyBlues",op:8,type:"delta"},{name:"familyOtherBlues",op:9,type:"delta"},{name:"blueScale",op:1209,type:"number",value:.039625},{name:"blueShift",op:1210,type:"number",value:7},{name:"blueFuzz",op:1211,type:"number",value:1},{name:"stdHW",op:10,type:"number"},{name:"stdVW",op:11,type:"number"},{name:"stemSnapH",op:1212,type:"number"},{name:"stemSnapV",op:1213,type:"number"},{name:"languageGroup",op:1217,type:"number",value:0},{name:"expansionFactor",op:1218,type:"number",value:.06},{name:"vsindex",op:22,type:"number",value:0},{name:"subrs",op:19,type:"offset"}],Ob=[{name:"private",op:18,type:["number","offset"],value:[0,0]}];function Ub(n,e,t,i){const s=ku(n,e,n.byteLength,i);return Fu(s,i>1?Ib:Zp,t)}function Bu(n,e,t,i,s){const r=ku(n,e,t,s);return Fu(r,s>1?Pb:Jp,i)}function Nb(n,e,t){const i=ku(n,e,void 0,t);return Fu(i,Ob)}function kb(n,e,t){const i=[];for(let s=0;s<t.length;s++){const r=new DataView(new Uint8Array(t[s]).buffer),a=Nb(r,0,2),o=a.private[0],l=a.private[1];if(o!==0&&l!==0){const c=Bu(n,l+e,o,[],2);if(c.subrs){const u=l+c.subrs,h=ni(n,u+e,void 0,2);a._subrs=h.objects,a._subrsBias=Fo(a._subrs)}a._privateDict=c}i.push(a)}return i}function Vl(n,e,t,i,s){const r=[];for(let a=0;a<t.length;a+=1){const o=new DataView(new Uint8Array(t[a]).buffer),l=Ub(o,0,i,s);l._subrs=[],l._subrsBias=0,l._defaultWidthX=0,l._nominalWidthX=0;const c=s<2?l.private[0]:0,u=s<2?l.private[1]:0;if(c!==0&&u!==0){const h=Bu(n,u+e,c,i,s);if(l._defaultWidthX=h.defaultWidthX,l._nominalWidthX=h.nominalWidthX,h.subrs!==0){const d=u+h.subrs,f=ni(n,d+e,void 0,s);l._subrs=f.objects,l._subrsBias=Fo(l._subrs)}l._privateDict=h}r.push(l)}return r}function Fb(n,e,t,i,s){let r,a;const o=new Ie.Parser(n,e);t-=1;const l=[".notdef"],c=o.parseCard8();if(c===0)for(let u=0;u<t;u+=1)r=o.parseSID(),s?l.push(r):l.push(Wr(i,r)||r);else if(c===1)for(;l.length<=t;){r=o.parseSID(),a=o.parseCard8();for(let u=0;u<=a;u+=1)s?l.push("cid"+("00000"+r).slice(-5)):l.push(Wr(i,r)||r),r+=1}else if(c===2)for(;l.length<=t;){r=o.parseSID(),a=o.parseCard16();for(let u=0;u<=a;u+=1)s?l.push("cid"+("00000"+r).slice(-5)):l.push(Wr(i,r)||r),r+=1}else throw new Error("Unknown charset format "+c);return l}function Bb(n,e){let t;const i={},s=new Ie.Parser(n,e),r=s.parseCard8();if(r===0){const a=s.parseCard8();for(let o=0;o<a;o+=1)t=s.parseCard8(),i[t]=o}else if(r===1){const a=s.parseCard8();t=1;for(let o=0;o<a;o+=1){const l=s.parseCard8(),c=s.parseCard8();for(let u=l;u<=l+c;u+=1)i[u]=t,t+=1}}else throw new Error("Unknown encoding format "+r);return i}function Hb(n){let e=n.pop();for(;n.length>e;)n.pop()}function jp(n,e){const t=n.tables.cff&&n.tables.cff.topDict&&n.tables.cff.topDict.paintType||0;return t===2&&(e.fill=null,e.stroke="black",e.strokeWidth=n.tables.cff.topDict.strokeWidth||0),t}function nu(n,e,t,i,s){let r,a,o,l;const c=new cr,u=[];let h=0,d=!1,f=!1,p=0,_=0,m,g,v,b,x=0,E=[],S,A=0;const y=n.tables.cff2||n.tables.cff;if(v=y.topDict._defaultWidthX,b=y.topDict._nominalWidthX,s=s||n.variation&&n.variation.get(),e.getBlendPath||(e.getBlendPath=function(U){return nu(n,e,t,i,U)}),n.isCIDFont||i>1){const U=y.topDict._fdSelect?y.topDict._fdSelect[e.index]:0,D=y.topDict._fdArray[U];m=D._subrs,g=D._subrsBias,i>1?(E=y.topDict._vstore.itemVariationStore,x=D._privateDict.vsindex):(v=D._defaultWidthX,b=D._nominalWidthX)}else m=y.topDict._subrs,g=y.topDict._subrsBias;const T=jp(n,c);let L=v;function R(U,D){f&&T!==2&&c.closePath(),c.moveTo(U,D),f=!0}function w(){let U;U=(u.length&1)!==0,U&&!d&&(L=u.shift()+b),h+=u.length>>1,u.length=0,d=!0}function P(U){let D,K,B,ie,F,se,V,oe,Ae,me,ue,z,ee=0;for(;ee<U.length;){let Ye=U[ee];switch(ee+=1,Ye){case 1:w();break;case 3:w();break;case 4:u.length>1&&!d&&(L=u.shift()+b,d=!0),_+=u.pop(),R(p,_);break;case 5:for(;u.length>0;)p+=u.shift(),_+=u.shift(),c.lineTo(p,_);break;case 6:for(;u.length>0&&(p+=u.shift(),c.lineTo(p,_),u.length!==0);)_+=u.shift(),c.lineTo(p,_);break;case 7:for(;u.length>0&&(_+=u.shift(),c.lineTo(p,_),u.length!==0);)p+=u.shift(),c.lineTo(p,_);break;case 8:for(;u.length>0;)r=p+u.shift(),a=_+u.shift(),o=r+u.shift(),l=a+u.shift(),p=o+u.shift(),_=l+u.shift(),c.curveTo(r,a,o,l,p,_);break;case 10:if(F=u.pop()+g,se=m[F],se){if(A>=wd){console.warn("CFF charstring subroutine call depth exceeded, skipping callsubr");break}A++,P(se),A--}break;case 11:if(i>1){console.error("CFF CharString operator return (11) is not supported in CFF2");break}return;case 12:switch(Ye=U[ee],ee+=1,Ye){case 35:r=p+u.shift(),a=_+u.shift(),o=r+u.shift(),l=a+u.shift(),V=o+u.shift(),oe=l+u.shift(),Ae=V+u.shift(),me=oe+u.shift(),ue=Ae+u.shift(),z=me+u.shift(),p=ue+u.shift(),_=z+u.shift(),u.shift(),c.curveTo(r,a,o,l,V,oe),c.curveTo(Ae,me,ue,z,p,_);break;case 34:r=p+u.shift(),a=_,o=r+u.shift(),l=a+u.shift(),V=o+u.shift(),oe=l,Ae=V+u.shift(),me=l,ue=Ae+u.shift(),z=_,p=ue+u.shift(),c.curveTo(r,a,o,l,V,oe),c.curveTo(Ae,me,ue,z,p,_);break;case 36:r=p+u.shift(),a=_+u.shift(),o=r+u.shift(),l=a+u.shift(),V=o+u.shift(),oe=l,Ae=V+u.shift(),me=l,ue=Ae+u.shift(),z=me+u.shift(),p=ue+u.shift(),c.curveTo(r,a,o,l,V,oe),c.curveTo(Ae,me,ue,z,p,_);break;case 37:r=p+u.shift(),a=_+u.shift(),o=r+u.shift(),l=a+u.shift(),V=o+u.shift(),oe=l+u.shift(),Ae=V+u.shift(),me=oe+u.shift(),ue=Ae+u.shift(),z=me+u.shift(),Math.abs(ue-p)>Math.abs(z-_)?p=ue+u.shift():_=z+u.shift(),c.curveTo(r,a,o,l,V,oe),c.curveTo(Ae,me,ue,z,p,_);break;default:console.log("Glyph "+e.index+": unknown operator 1200"+Ye),u.length=0}break;case 14:if(i>1){console.error("CFF CharString operator endchar (14) is not supported in CFF2");break}if(u.length>=4){const Ke=tu[u.pop()],Be=tu[u.pop()],Pe=u.pop(),st=u.pop();if(Ke&&Be){e.isComposite=!0,e.components=[];const mt=n.cffEncoding.charset.indexOf(Ke),gt=n.cffEncoding.charset.indexOf(Be);e.components.push({glyphIndex:gt,dx:0,dy:0}),e.components.push({glyphIndex:mt,dx:st,dy:Pe}),c.extend(n.glyphs.get(gt).path);const ft=n.glyphs.get(mt),_t=JSON.parse(JSON.stringify(ft.path.commands));for(let G=0;G<_t.length;G+=1){const nt=_t[G];nt.type!=="Z"&&(nt.x+=st,nt.y+=Pe),(nt.type==="Q"||nt.type==="C")&&(nt.x1+=st,nt.y1+=Pe),nt.type==="C"&&(nt.x2+=st,nt.y2+=Pe)}c.extend(_t)}}else u.length>0&&!d&&(L=u.shift()+b,d=!0);f&&T!==2&&(c.closePath(),f=!1);break;case 15:if(i<2){console.error("CFF2 CharString operator vsindex (15) is not supported in CFF");break}x=u.pop();break;case 16:if(i<2){console.error("CFF2 CharString operator blend (16) is not supported in CFF");break}S||(S=n.variation&&s&&n.variation.process.getBlendVector(E,x,s));var Z=u.pop(),xe=S?S.length:E.itemVariationSubtables[x].regionIndexes.length,be=Z*xe,Se=u.length-be,Oe=Se-Z;if(S)for(let Ke=0;Ke<Z;Ke++){var Ge=u[Oe+Ke];for(let Be=0;Be<xe;Be++)Ge+=S[Be]*u[Se++];u[Oe+Ke]=Ge}for(;be--;)u.pop();break;case 18:w();break;case 19:case 20:w(),ee+=h+7>>3;break;case 21:u.length>2&&!d&&(L=u.shift()+b,d=!0),_+=u.pop(),p+=u.pop(),R(p,_);break;case 22:u.length>1&&!d&&(L=u.shift()+b,d=!0),p+=u.pop(),R(p,_);break;case 23:w();break;case 24:for(;u.length>2;)r=p+u.shift(),a=_+u.shift(),o=r+u.shift(),l=a+u.shift(),p=o+u.shift(),_=l+u.shift(),c.curveTo(r,a,o,l,p,_);p+=u.shift(),_+=u.shift(),c.lineTo(p,_);break;case 25:for(;u.length>6;)p+=u.shift(),_+=u.shift(),c.lineTo(p,_);r=p+u.shift(),a=_+u.shift(),o=r+u.shift(),l=a+u.shift(),p=o+u.shift(),_=l+u.shift(),c.curveTo(r,a,o,l,p,_);break;case 26:for(u.length&1&&(p+=u.shift());u.length>0;)r=p,a=_+u.shift(),o=r+u.shift(),l=a+u.shift(),p=o,_=l+u.shift(),c.curveTo(r,a,o,l,p,_);break;case 27:for(u.length&1&&(_+=u.shift());u.length>0;)r=p+u.shift(),a=_,o=r+u.shift(),l=a+u.shift(),p=o+u.shift(),_=l,c.curveTo(r,a,o,l,p,_);break;case 28:D=U[ee],K=U[ee+1],u.push((D<<24|K<<16)>>16),ee+=2;break;case 29:if(F=u.pop()+n.gsubrsBias,se=n.gsubrs[F],se){if(A>=wd){console.warn("CFF charstring subroutine call depth exceeded, skipping callgsubr");break}A++,P(se),A--}break;case 30:for(;u.length>0&&(r=p,a=_+u.shift(),o=r+u.shift(),l=a+u.shift(),p=o+u.shift(),_=l+(u.length===1?u.shift():0),c.curveTo(r,a,o,l,p,_),u.length!==0);)r=p+u.shift(),a=_,o=r+u.shift(),l=a+u.shift(),_=l+u.shift(),p=o+(u.length===1?u.shift():0),c.curveTo(r,a,o,l,p,_);break;case 31:for(;u.length>0&&(r=p+u.shift(),a=_,o=r+u.shift(),l=a+u.shift(),_=l+u.shift(),p=o+(u.length===1?u.shift():0),c.curveTo(r,a,o,l,p,_),u.length!==0);)r=p,a=_+u.shift(),o=r+u.shift(),l=a+u.shift(),p=o+u.shift(),_=l+(u.length===1?u.shift():0),c.curveTo(r,a,o,l,p,_);break;default:Ye<32?console.log("Glyph "+e.index+": unknown operator "+Ye):Ye<247?u.push(Ye-139):Ye<251?(D=U[ee],ee+=1,u.push((Ye-247)*256+D+108)):Ye<255?(D=U[ee],ee+=1,u.push(-(Ye-251)*256-D-108)):(D=U[ee],K=U[ee+1],B=U[ee+2],ie=U[ee+3],ee+=4,u.push((D<<24|K<<16|B<<8|ie)/65536))}}}return P(t),n.variation&&s&&(c.commands=c.commands.map(U=>{const D=Object.keys(U);for(let K=0;K<D.length;K++){const B=D[K];B!=="type"&&(U[B]=Math.round(U[B]))}return U})),d&&(e.advanceWidth=L),c}function Rd(n,e,t,i,s){const r=[];let a;const o=new Ie.Parser(n,e),l=o.parseCard8();if(l===0)for(let c=0;c<t;c++){if(a=o.parseCard8(),a>=i)throw new Error("CFF table CID Font FDSelect has bad FD index value "+a+" (FD count "+i+")");r.push(a)}else if(l===3||s>1&&l===4){const c=l===4?o.parseULong():o.parseCard16();let u=l===4?o.parseULong():o.parseCard16();if(u!==0)throw new Error(`CFF Table CID Font FDSelect format ${l} range has bad initial GID ${u}`);let h;for(let d=0;d<c;d++){if(a=l===4?o.parseUShort():o.parseCard8(),h=l===4?o.parseULong():o.parseCard16(),a>=i)throw new Error("CFF table CID Font FDSelect has bad FD index value "+a+" (FD count "+i+")");if(h>t)throw new Error(`CFF Table CID Font FDSelect format ${s} range has bad GID ${h}`);for(;u<h;u++)r.push(a);u=h}if(h!==t)throw new Error("CFF Table CID Font FDSelect format 3 range has bad final (Sentinal) GID "+h)}else throw new Error("CFF Table CID Font FDSelect table has unsupported format "+l);return r}function zb(n,e,t,i){let s;const r=Db(n,e);r.formatMajor===2?s=t.tables.cff2={}:s=t.tables.cff={};const a=r.formatMajor>1?null:ni(n,r.endOffset,Ie.bytesToString),o=r.formatMajor>1?null:ni(n,a.endOffset),l=r.formatMajor>1?null:ni(n,o.endOffset,Ie.bytesToString),c=ni(n,r.formatMajor>1?e+r.size+r.topDictLength:l.endOffset,void 0,r.formatMajor);t.gsubrs=c.objects,t.gsubrsBias=Fo(t.gsubrs);let u;if(r.formatMajor>1){const d=e+r.size,f=Ie.getBytes(n,d,d+r.topDictLength);u=Vl(n,0,[f],void 0,r.formatMajor)[0]}else{const d=Vl(n,e,o.objects,l.objects,r.formatMajor);if(d.length!==1)throw new Error("CFF table has too many fonts in 'FontSet' - count of fonts NameIndex.length = "+d.length);u=d[0]}if(s.topDict=u,u._privateDict&&(t.defaultWidthX=u._privateDict.defaultWidthX,t.nominalWidthX=u._privateDict.nominalWidthX),r.formatMajor<2&&u.ros[0]!==void 0&&u.ros[1]!==void 0&&(t.isCIDFont=!0),r.formatMajor>1){let d=u.fdArray,f=u.fdSelect;if(!d)throw new Error("This is a CFF2 font, but FDArray information is missing");const p=ni(n,e+d,null,r.formatMajor),_=kb(n,e,p.objects);u._fdArray=_,f&&(u._fdSelect=Rd(n,e+f,t.numGlyphs,_.length,r.formatMajor))}else if(t.isCIDFont){let d=u.fdArray,f=u.fdSelect;if(d===0||f===0)throw new Error("Font is marked as a CID font, but FDArray and/or FDSelect information is missing");d+=e;const p=ni(n,d),_=Vl(n,e,p.objects,l.objects,r.formatMajor);u._fdArray=_,f+=e,u._fdSelect=Rd(n,f,t.numGlyphs,_.length,r.formatMajor)}if(r.formatMajor<2){const d=e+u.private[1],f=Bu(n,d,u.private[0],l.objects,r.formatMajor);if(t.defaultWidthX=f.defaultWidthX,t.nominalWidthX=f.nominalWidthX,f.subrs!==0){const p=d+f.subrs,_=ni(n,p);t.subrs=_.objects,t.subrsBias=Fo(t.subrs)}else t.subrs=[],t.subrsBias=0}let h;if(i.lowMemory?(h=Tb(n,e+u.charStrings,r.formatMajor),t.nGlyphs=h.offsets.length-(r.formatMajor>1?1:0)):(h=ni(n,e+u.charStrings,null,r.formatMajor),t.nGlyphs=h.objects.length),r.formatMajor>1&&t.tables.maxp&&t.nGlyphs!==t.tables.maxp.numGlyphs&&console.error(`Glyph count in the CFF2 table (${t.nGlyphs}) must correspond to the glyph count in the maxp table (${t.tables.maxp.numGlyphs})`),r.formatMajor<2){let d=[],f=[];u.charset===0?d=ub:u.charset===1?d=hb:u.charset===2?d=db:d=Fb(n,e+u.charset,t.nGlyphs,l.objects,t.isCIDFont),u.encoding===0?f=tu:u.encoding===1?f=fb:f=Bb(n,e+u.encoding),t.cffEncoding=new Xp(f,d),t.encoding=t.encoding||t.cffEncoding}if(t.glyphs=new hi.GlyphSet(t),i.lowMemory)t._push=function(d){const f=Cb(d,h.offsets,n,e+u.charStrings,void 0,r.formatMajor);t.glyphs.push(d,hi.cffGlyphLoader(t,d,nu,f,r.formatMajor))};else for(let d=0;d<t.nGlyphs;d+=1){const f=h.objects[d];t.glyphs.push(d,hi.cffGlyphLoader(t,d,nu,f,r.formatMajor))}if(u.vstore){const d=new Ie.Parser(n,e+u.vstore);u._vstore=d.parseVariationStore()}}function Qp(n,e){let t,i=mo.indexOf(n);return i>=0&&(t=i),i=e.indexOf(n),i>=0?t=i+mo.length:(t=mo.length+e.length,e.push(n)),t}function Vb(){return new _e.Record("Header",[{name:"major",type:"Card8",value:1},{name:"minor",type:"Card8",value:0},{name:"hdrSize",type:"Card8",value:4},{name:"major",type:"Card8",value:1}])}function Gb(n){const e=new _e.Record("Name INDEX",[{name:"names",type:"INDEX",value:[]}]);e.names=[];for(let t=0;t<n.length;t+=1)e.names.push({name:"name_"+t,type:"NAME",value:n[t]});return e}function e0(n,e,t){const i={};for(let s=0;s<n.length;s+=1){const r=n[s];let a=e[r.name];a!==void 0&&!$p(a,r.value)&&(r.type==="SID"&&(a=Qp(a,t)),i[r.op]={name:r.name,type:r.type,value:a})}return i}function Ld(n,e,t){const i=new _e.Record("Top DICT",[{name:"dict",type:"DICT",value:{}}]);return i.dict=e0(Zp,n,e),i}function Dd(n){const e=new _e.Record("Top DICT INDEX",[{name:"topDicts",type:"INDEX",value:[]}]);return e.topDicts=[{name:"topDict_0",type:"TABLE",value:n}],e}function Wb(n){const e=new _e.Record("String INDEX",[{name:"strings",type:"INDEX",value:[]}]);e.strings=[];for(let t=0;t<n.length;t+=1)e.strings.push({name:"string_"+t,type:"STRING",value:n[t]});return e}function Xb(){return new _e.Record("Global Subr INDEX",[{name:"subrs",type:"INDEX",value:[]}])}function Yb(n,e){const t=new _e.Record("Charsets",[{name:"format",type:"Card8",value:0}]);for(let i=0;i<n.length;i+=1){const s=n[i],r=Qp(s,e);t.fields.push({name:"glyph_"+i,type:"SID",value:r})}return t}function Kb(n,e){const t=[],i=n.path;t.push({name:"width",type:"NUMBER",value:n.advanceWidth});let s=0,r=0;for(let a=0;a<i.commands.length;a+=1){let o,l,c=i.commands[a];if(c.type==="Q"){const u=.3333333333333333,h=2/3;c={type:"C",x:c.x,y:c.y,x1:Math.round(u*s+h*c.x1),y1:Math.round(u*r+h*c.y1),x2:Math.round(u*c.x+h*c.x1),y2:Math.round(u*c.y+h*c.y1)}}if(c.type==="M")o=Math.round(c.x-s),l=Math.round(c.y-r),t.push({name:"dx",type:"NUMBER",value:o}),t.push({name:"dy",type:"NUMBER",value:l}),t.push({name:"rmoveto",type:"OP",value:21}),s=Math.round(c.x),r=Math.round(c.y);else if(c.type==="L")o=Math.round(c.x-s),l=Math.round(c.y-r),t.push({name:"dx",type:"NUMBER",value:o}),t.push({name:"dy",type:"NUMBER",value:l}),t.push({name:"rlineto",type:"OP",value:5}),s=Math.round(c.x),r=Math.round(c.y);else if(c.type==="C"){const u=Math.round(c.x1-s),h=Math.round(c.y1-r),d=Math.round(c.x2-c.x1),f=Math.round(c.y2-c.y1);o=Math.round(c.x-c.x2),l=Math.round(c.y-c.y2),t.push({name:"dx1",type:"NUMBER",value:u}),t.push({name:"dy1",type:"NUMBER",value:h}),t.push({name:"dx2",type:"NUMBER",value:d}),t.push({name:"dy2",type:"NUMBER",value:f}),t.push({name:"dx",type:"NUMBER",value:o}),t.push({name:"dy",type:"NUMBER",value:l}),t.push({name:"rrcurveto",type:"OP",value:8}),s=Math.round(c.x),r=Math.round(c.y)}}return t.push({name:"endchar",type:"OP",value:14}),t}function qb(n,e){const t=new _e.Record("CharStrings INDEX",[{name:"charStrings",type:"INDEX",value:[]}]);for(let i=0;i<n.length;i+=1){const s=n.get(i),r=Kb(s);t.charStrings.push({name:s.name,type:"CHARSTRING",value:r})}return t}function $b(n,e,t){const i=new _e.Record("Private DICT",[{name:"dict",type:"DICT",value:{}}]);return i.dict=e0(Jp,n,e),i}function Zb(n,e){const t=new _e.Table("CFF ",[{name:"header",type:"RECORD"},{name:"nameIndex",type:"RECORD"},{name:"topDictIndex",type:"RECORD"},{name:"stringIndex",type:"RECORD"},{name:"globalSubrIndex",type:"RECORD"},{name:"charsets",type:"RECORD"},{name:"charStringsIndex",type:"RECORD"},{name:"privateDict",type:"RECORD"}]),i=1/e.unitsPerEm,s={version:e.version,fullName:e.fullName,familyName:e.familyName,weight:e.weightName,fontBBox:e.fontBBox||[0,0,0,0],fontMatrix:[i,0,0,i,0,0],charset:999,encoding:0,charStrings:999,private:[0,999]},r=e&&e.topDict||{};r.paintType&&(s.paintType=r.paintType,s.strokeWidth=r.strokeWidth||0);const a={},o=[];let l;for(let d=1;d<n.length;d+=1)l=n.get(d),o.push(l.name);const c=[];t.header=Vb(),t.nameIndex=Gb([e.postScriptName]);let u=Ld(s,c);t.topDictIndex=Dd(u),t.globalSubrIndex=Xb(),t.charsets=Yb(o,c),t.charStringsIndex=qb(n),t.privateDict=$b(a,c),t.stringIndex=Wb(c);const h=t.header.sizeOf()+t.nameIndex.sizeOf()+t.topDictIndex.sizeOf()+t.stringIndex.sizeOf()+t.globalSubrIndex.sizeOf();return s.charset=h,s.encoding=0,s.charStrings=s.charset+t.charsets.sizeOf(),s.private[1]=s.charStrings+t.charStringsIndex.sizeOf(),u=Ld(s,c),t.topDictIndex=Dd(u),t}var iu={parse:zb,make:Zb};function Jb(n,e){const t={},i=new Ie.Parser(n,e);return t.version=i.parseVersion(),t.fontRevision=Math.round(i.parseFixed()*1e3)/1e3,t.checkSumAdjustment=i.parseULong(),t.magicNumber=i.parseULong(),Ve.argument(t.magicNumber===1594834165,"Font header has wrong magic number."),t.flags=i.parseUShort(),t.unitsPerEm=i.parseUShort(),t.created=i.parseLongDateTime(),t.modified=i.parseLongDateTime(),t.xMin=i.parseShort(),t.yMin=i.parseShort(),t.xMax=i.parseShort(),t.yMax=i.parseShort(),t.macStyle=i.parseUShort(),t.lowestRecPPEM=i.parseUShort(),t.fontDirectionHint=i.parseShort(),t.indexToLocFormat=i.parseShort(),t.glyphDataFormat=i.parseShort(),t}function jb(n){const e=Math.round(new Date().getTime()/1e3)+2082844800;let t=e,i=n.macStyle||0;return n.createdTimestamp&&(t=n.createdTimestamp+2082844800),new _e.Table("head",[{name:"version",type:"FIXED",value:65536},{name:"fontRevision",type:"FIXED",value:65536},{name:"checkSumAdjustment",type:"ULONG",value:0},{name:"magicNumber",type:"ULONG",value:1594834165},{name:"flags",type:"USHORT",value:0},{name:"unitsPerEm",type:"USHORT",value:1e3},{name:"created",type:"LONGDATETIME",value:t},{name:"modified",type:"LONGDATETIME",value:e},{name:"xMin",type:"SHORT",value:0},{name:"yMin",type:"SHORT",value:0},{name:"xMax",type:"SHORT",value:0},{name:"yMax",type:"SHORT",value:0},{name:"macStyle",type:"USHORT",value:i},{name:"lowestRecPPEM",type:"USHORT",value:0},{name:"fontDirectionHint",type:"SHORT",value:2},{name:"indexToLocFormat",type:"SHORT",value:0},{name:"glyphDataFormat",type:"SHORT",value:0}],n)}var t0={parse:Jb,make:jb};function Qb(n,e){const t={},i=new Ie.Parser(n,e);return t.version=i.parseVersion(),t.ascender=i.parseShort(),t.descender=i.parseShort(),t.lineGap=i.parseShort(),t.advanceWidthMax=i.parseUShort(),t.minLeftSideBearing=i.parseShort(),t.minRightSideBearing=i.parseShort(),t.xMaxExtent=i.parseShort(),t.caretSlopeRise=i.parseShort(),t.caretSlopeRun=i.parseShort(),t.caretOffset=i.parseShort(),i.relativeOffset+=8,t.metricDataFormat=i.parseShort(),t.numberOfHMetrics=i.parseUShort(),t}function e2(n){return new _e.Table("hhea",[{name:"version",type:"FIXED",value:65536},{name:"ascender",type:"FWORD",value:0},{name:"descender",type:"FWORD",value:0},{name:"lineGap",type:"FWORD",value:0},{name:"advanceWidthMax",type:"UFWORD",value:0},{name:"minLeftSideBearing",type:"FWORD",value:0},{name:"minRightSideBearing",type:"FWORD",value:0},{name:"xMaxExtent",type:"FWORD",value:0},{name:"caretSlopeRise",type:"SHORT",value:1},{name:"caretSlopeRun",type:"SHORT",value:0},{name:"caretOffset",type:"SHORT",value:0},{name:"reserved1",type:"SHORT",value:0},{name:"reserved2",type:"SHORT",value:0},{name:"reserved3",type:"SHORT",value:0},{name:"reserved4",type:"SHORT",value:0},{name:"metricDataFormat",type:"SHORT",value:0},{name:"numberOfHMetrics",type:"USHORT",value:0}],n)}var n0={parse:Qb,make:e2};function t2(n,e,t,i,s){let r,a;const o=new Ie.Parser(n,e);for(let l=0;l<i;l+=1){l<t&&(r=o.parseUShort(),a=o.parseShort());const c=s.get(l);c.advanceWidth=r,c.leftSideBearing=a}}function n2(n,e,t,i,s){n._hmtxTableData={};let r,a;const o=new Ie.Parser(e,t);for(let l=0;l<s;l+=1)l<i&&(r=o.parseUShort(),a=o.parseShort()),n._hmtxTableData[l]={advanceWidth:r,leftSideBearing:a}}function i2(n,e,t,i,s,r,a){a.lowMemory?n2(n,e,t,i,s):t2(e,t,i,s,r)}function s2(n){const e=new _e.Table("hmtx",[]);for(let t=0;t<n.length;t+=1){const i=n.get(t),s=i.advanceWidth||0,r=i.leftSideBearing||0;e.fields.push({name:"advanceWidth_"+t,type:"USHORT",value:s}),e.fields.push({name:"leftSideBearing_"+t,type:"SHORT",value:r})}return e}var i0={parse:i2,make:s2};function r2(n){const e=new _e.Table("ltag",[{name:"version",type:"ULONG",value:1},{name:"flags",type:"ULONG",value:0},{name:"numTags",type:"ULONG",value:n.length}]);let t="";const i=12+n.length*4;for(let s=0;s<n.length;++s){let r=t.indexOf(n[s]);r<0&&(r=t.length,t+=n[s]),e.fields.push({name:"offset "+s,type:"USHORT",value:i+r}),e.fields.push({name:"length "+s,type:"USHORT",value:n[s].length})}return e.fields.push({name:"stringPool",type:"CHARARRAY",value:t}),e}function a2(n,e){const t=new Ie.Parser(n,e),i=t.parseULong();Ve.argument(i===1,"Unsupported ltag table version."),t.skip("uLong",1);const s=t.parseULong(),r=[];for(let a=0;a<s;a++){let o="";const l=e+t.parseUShort(),c=t.parseUShort();for(let u=l;u<l+c;++u)o+=String.fromCharCode(n.getInt8(u));r.push(o)}return r}var s0={make:r2,parse:a2};function o2(n,e){const t={},i=new Ie.Parser(n,e);return t.version=i.parseVersion(),t.numGlyphs=i.parseUShort(),t.version===1&&(t.maxPoints=i.parseUShort(),t.maxContours=i.parseUShort(),t.maxCompositePoints=i.parseUShort(),t.maxCompositeContours=i.parseUShort(),t.maxZones=i.parseUShort(),t.maxTwilightPoints=i.parseUShort(),t.maxStorage=i.parseUShort(),t.maxFunctionDefs=i.parseUShort(),t.maxInstructionDefs=i.parseUShort(),t.maxStackElements=i.parseUShort(),t.maxSizeOfInstructions=i.parseUShort(),t.maxComponentElements=i.parseUShort(),t.maxComponentDepth=i.parseUShort()),t}function l2(n){return new _e.Table("maxp",[{name:"version",type:"FIXED",value:20480},{name:"numGlyphs",type:"USHORT",value:n}])}var r0={parse:o2,make:l2},su=[{begin:0,end:127},{begin:128,end:255},{begin:256,end:383},{begin:384,end:591},{begin:592,end:687},{begin:688,end:767},{begin:768,end:879},{begin:880,end:1023},{begin:11392,end:11519},{begin:1024,end:1279},{begin:1328,end:1423},{begin:1424,end:1535},{begin:42240,end:42559},{begin:1536,end:1791},{begin:1984,end:2047},{begin:2304,end:2431},{begin:2432,end:2559},{begin:2560,end:2687},{begin:2688,end:2815},{begin:2816,end:2943},{begin:2944,end:3071},{begin:3072,end:3199},{begin:3200,end:3327},{begin:3328,end:3455},{begin:3584,end:3711},{begin:3712,end:3839},{begin:4256,end:4351},{begin:6912,end:7039},{begin:4352,end:4607},{begin:7680,end:7935},{begin:7936,end:8191},{begin:8192,end:8303},{begin:8304,end:8351},{begin:8352,end:8399},{begin:8400,end:8447},{begin:8448,end:8527},{begin:8528,end:8591},{begin:8592,end:8703},{begin:8704,end:8959},{begin:8960,end:9215},{begin:9216,end:9279},{begin:9280,end:9311},{begin:9312,end:9471},{begin:9472,end:9599},{begin:9600,end:9631},{begin:9632,end:9727},{begin:9728,end:9983},{begin:9984,end:10175},{begin:12288,end:12351},{begin:12352,end:12447},{begin:12448,end:12543},{begin:12544,end:12591},{begin:12592,end:12687},{begin:43072,end:43135},{begin:12800,end:13055},{begin:13056,end:13311},{begin:44032,end:55215},{begin:55296,end:57343},{begin:67840,end:67871},{begin:19968,end:40959},{begin:57344,end:63743},{begin:12736,end:12783},{begin:64256,end:64335},{begin:64336,end:65023},{begin:65056,end:65071},{begin:65040,end:65055},{begin:65104,end:65135},{begin:65136,end:65279},{begin:65280,end:65519},{begin:65520,end:65535},{begin:3840,end:4095},{begin:1792,end:1871},{begin:1920,end:1983},{begin:3456,end:3583},{begin:4096,end:4255},{begin:4608,end:4991},{begin:5024,end:5119},{begin:5120,end:5759},{begin:5760,end:5791},{begin:5792,end:5887},{begin:6016,end:6143},{begin:6144,end:6319},{begin:10240,end:10495},{begin:40960,end:42127},{begin:5888,end:5919},{begin:66304,end:66351},{begin:66352,end:66383},{begin:66560,end:66639},{begin:118784,end:119039},{begin:119808,end:120831},{begin:1044480,end:1048573},{begin:65024,end:65039},{begin:917504,end:917631},{begin:6400,end:6479},{begin:6480,end:6527},{begin:6528,end:6623},{begin:6656,end:6687},{begin:11264,end:11359},{begin:11568,end:11647},{begin:19904,end:19967},{begin:43008,end:43055},{begin:65536,end:65663},{begin:65856,end:65935},{begin:66432,end:66463},{begin:66464,end:66527},{begin:66640,end:66687},{begin:66688,end:66735},{begin:67584,end:67647},{begin:68096,end:68191},{begin:119552,end:119647},{begin:73728,end:74751},{begin:119648,end:119679},{begin:7040,end:7103},{begin:7168,end:7247},{begin:7248,end:7295},{begin:43136,end:43231},{begin:43264,end:43311},{begin:43312,end:43359},{begin:43520,end:43615},{begin:65936,end:65999},{begin:66e3,end:66047},{begin:66208,end:66271},{begin:127024,end:127135}];function c2(n){for(let e=0;e<su.length;e+=1){const t=su[e];if(n>=t.begin&&n<t.end)return e}return-1}function u2(n,e){const t={},i=new Ie.Parser(n,e);t.version=i.parseUShort(),t.xAvgCharWidth=i.parseShort(),t.usWeightClass=i.parseUShort(),t.usWidthClass=i.parseUShort(),t.fsType=i.parseUShort(),t.ySubscriptXSize=i.parseShort(),t.ySubscriptYSize=i.parseShort(),t.ySubscriptXOffset=i.parseShort(),t.ySubscriptYOffset=i.parseShort(),t.ySuperscriptXSize=i.parseShort(),t.ySuperscriptYSize=i.parseShort(),t.ySuperscriptXOffset=i.parseShort(),t.ySuperscriptYOffset=i.parseShort(),t.yStrikeoutSize=i.parseShort(),t.yStrikeoutPosition=i.parseShort(),t.sFamilyClass=i.parseShort(),t.panose=[];for(let s=0;s<10;s++)t.panose[s]=i.parseByte();return t.ulUnicodeRange1=i.parseULong(),t.ulUnicodeRange2=i.parseULong(),t.ulUnicodeRange3=i.parseULong(),t.ulUnicodeRange4=i.parseULong(),t.achVendID=String.fromCharCode(i.parseByte(),i.parseByte(),i.parseByte(),i.parseByte()),t.fsSelection=i.parseUShort(),t.usFirstCharIndex=i.parseUShort(),t.usLastCharIndex=i.parseUShort(),t.sTypoAscender=i.parseShort(),t.sTypoDescender=i.parseShort(),t.sTypoLineGap=i.parseShort(),t.usWinAscent=i.parseUShort(),t.usWinDescent=i.parseUShort(),t.version>=1&&(t.ulCodePageRange1=i.parseULong(),t.ulCodePageRange2=i.parseULong()),t.version>=2&&(t.sxHeight=i.parseShort(),t.sCapHeight=i.parseShort(),t.usDefaultChar=i.parseUShort(),t.usBreakChar=i.parseUShort(),t.usMaxContent=i.parseUShort()),t}function h2(n){return new _e.Table("OS/2",[{name:"version",type:"USHORT",value:3},{name:"xAvgCharWidth",type:"SHORT",value:0},{name:"usWeightClass",type:"USHORT",value:0},{name:"usWidthClass",type:"USHORT",value:0},{name:"fsType",type:"USHORT",value:0},{name:"ySubscriptXSize",type:"SHORT",value:650},{name:"ySubscriptYSize",type:"SHORT",value:699},{name:"ySubscriptXOffset",type:"SHORT",value:0},{name:"ySubscriptYOffset",type:"SHORT",value:140},{name:"ySuperscriptXSize",type:"SHORT",value:650},{name:"ySuperscriptYSize",type:"SHORT",value:699},{name:"ySuperscriptXOffset",type:"SHORT",value:0},{name:"ySuperscriptYOffset",type:"SHORT",value:479},{name:"yStrikeoutSize",type:"SHORT",value:49},{name:"yStrikeoutPosition",type:"SHORT",value:258},{name:"sFamilyClass",type:"SHORT",value:0},{name:"bFamilyType",type:"BYTE",value:0},{name:"bSerifStyle",type:"BYTE",value:0},{name:"bWeight",type:"BYTE",value:0},{name:"bProportion",type:"BYTE",value:0},{name:"bContrast",type:"BYTE",value:0},{name:"bStrokeVariation",type:"BYTE",value:0},{name:"bArmStyle",type:"BYTE",value:0},{name:"bLetterform",type:"BYTE",value:0},{name:"bMidline",type:"BYTE",value:0},{name:"bXHeight",type:"BYTE",value:0},{name:"ulUnicodeRange1",type:"ULONG",value:0},{name:"ulUnicodeRange2",type:"ULONG",value:0},{name:"ulUnicodeRange3",type:"ULONG",value:0},{name:"ulUnicodeRange4",type:"ULONG",value:0},{name:"achVendID",type:"CHARARRAY",value:"XXXX"},{name:"fsSelection",type:"USHORT",value:0},{name:"usFirstCharIndex",type:"USHORT",value:0},{name:"usLastCharIndex",type:"USHORT",value:0},{name:"sTypoAscender",type:"SHORT",value:0},{name:"sTypoDescender",type:"SHORT",value:0},{name:"sTypoLineGap",type:"SHORT",value:0},{name:"usWinAscent",type:"USHORT",value:0},{name:"usWinDescent",type:"USHORT",value:0},{name:"ulCodePageRange1",type:"ULONG",value:0},{name:"ulCodePageRange2",type:"ULONG",value:0},{name:"sxHeight",type:"SHORT",value:0},{name:"sCapHeight",type:"SHORT",value:0},{name:"usDefaultChar",type:"USHORT",value:0},{name:"usBreakChar",type:"USHORT",value:0},{name:"usMaxContext",type:"USHORT",value:0}],n)}var ru={parse:u2,make:h2,unicodeRanges:su,getUnicodeRange:c2};function d2(n,e){const t={},i=new Ie.Parser(n,e);switch(t.version=i.parseVersion(),t.italicAngle=i.parseFixed(),t.underlinePosition=i.parseShort(),t.underlineThickness=i.parseShort(),t.isFixedPitch=i.parseULong(),t.minMemType42=i.parseULong(),t.maxMemType42=i.parseULong(),t.minMemType1=i.parseULong(),t.maxMemType1=i.parseULong(),t.version){case 1:t.names=us.slice();break;case 2:t.numberOfGlyphs=i.parseUShort(),t.glyphNameIndex=new Array(t.numberOfGlyphs);for(let s=0;s<t.numberOfGlyphs;s++)t.glyphNameIndex[s]=i.parseUShort();t.names=[];for(let s=0;s<t.numberOfGlyphs;s++)if(t.glyphNameIndex[s]>=us.length){const r=i.parseChar();t.names.push(i.parseString(r))}break;case 2.5:t.numberOfGlyphs=i.parseUShort(),t.offset=new Array(t.numberOfGlyphs);for(let s=0;s<t.numberOfGlyphs;s++)t.offset[s]=i.parseChar();break}return t}function f2(n){const{italicAngle:e=Math.round((n.italicAngle||0)*65536),underlinePosition:t=0,underlineThickness:i=0,isFixedPitch:s=0,minMemType42:r=0,maxMemType42:a=0,minMemType1:o=0,maxMemType1:l=0}=n.tables.post||{};return new _e.Table("post",[{name:"version",type:"FIXED",value:196608},{name:"italicAngle",type:"FIXED",value:e},{name:"underlinePosition",type:"FWORD",value:t},{name:"underlineThickness",type:"FWORD",value:i},{name:"isFixedPitch",type:"ULONG",value:s},{name:"minMemType42",type:"ULONG",value:r},{name:"maxMemType42",type:"ULONG",value:a},{name:"minMemType1",type:"ULONG",value:o},{name:"maxMemType1",type:"ULONG",value:l}])}var a0={parse:d2,make:f2},Wn=new Array(9);Wn[1]=function(){const e=this.offset+this.relativeOffset,t=this.parseUShort();if(t===1)return{substFormat:1,coverage:this.parsePointer(Y.coverage),deltaGlyphId:this.parseShort()};if(t===2)return{substFormat:2,coverage:this.parsePointer(Y.coverage),substitute:this.parseOffset16List()};Ve.assert(!1,"0x"+e.toString(16)+": lookup type 1 format must be 1 or 2.")};Wn[2]=function(){const e=this.parseUShort();return Ve.argument(e===1,"GSUB Multiple Substitution Subtable identifier-format must be 1"),{substFormat:e,coverage:this.parsePointer(Y.coverage),sequences:this.parseListOfLists()}};Wn[3]=function(){const e=this.parseUShort();return Ve.argument(e===1,"GSUB Alternate Substitution Subtable identifier-format must be 1"),{substFormat:e,coverage:this.parsePointer(Y.coverage),alternateSets:this.parseListOfLists()}};Wn[4]=function(){const e=this.parseUShort();return Ve.argument(e===1,"GSUB ligature table identifier-format must be 1"),{substFormat:e,coverage:this.parsePointer(Y.coverage),ligatureSets:this.parseListOfLists(function(){return{ligGlyph:this.parseUShort(),components:this.parseUShortList(this.parseUShort()-1)}})}};var ir={sequenceIndex:Y.uShort,lookupListIndex:Y.uShort};Wn[5]=function(){const e=this.offset+this.relativeOffset,t=this.parseUShort();if(t===1)return{substFormat:t,coverage:this.parsePointer(Y.coverage),ruleSets:this.parseListOfLists(function(){const i=this.parseUShort(),s=this.parseUShort();return{input:this.parseUShortList(i-1),lookupRecords:this.parseRecordList(s,ir)}})};if(t===2)return{substFormat:t,coverage:this.parsePointer(Y.coverage),classDef:this.parsePointer(Y.classDef),classSets:this.parseListOfLists(function(){const i=this.parseUShort(),s=this.parseUShort();return{classes:this.parseUShortList(i-1),lookupRecords:this.parseRecordList(s,ir)}})};if(t===3){const i=this.parseUShort(),s=this.parseUShort();return{substFormat:t,coverages:this.parseList(i,Y.pointer(Y.coverage)),lookupRecords:this.parseRecordList(s,ir)}}Ve.assert(!1,"0x"+e.toString(16)+": lookup type 5 format must be 1, 2 or 3.")};Wn[6]=function(){const e=this.offset+this.relativeOffset,t=this.parseUShort();if(t===1)return{substFormat:1,coverage:this.parsePointer(Y.coverage),chainRuleSets:this.parseListOfLists(function(){return{backtrack:this.parseUShortList(),input:this.parseUShortList(this.parseShort()-1),lookahead:this.parseUShortList(),lookupRecords:this.parseRecordList(ir)}})};if(t===2)return{substFormat:2,coverage:this.parsePointer(Y.coverage),backtrackClassDef:this.parsePointer(Y.classDef),inputClassDef:this.parsePointer(Y.classDef),lookaheadClassDef:this.parsePointer(Y.classDef),chainClassSet:this.parseListOfLists(function(){return{backtrack:this.parseUShortList(),input:this.parseUShortList(this.parseShort()-1),lookahead:this.parseUShortList(),lookupRecords:this.parseRecordList(ir)}})};if(t===3)return{substFormat:3,backtrackCoverage:this.parseList(Y.pointer(Y.coverage)),inputCoverage:this.parseList(Y.pointer(Y.coverage)),lookaheadCoverage:this.parseList(Y.pointer(Y.coverage)),lookupRecords:this.parseRecordList(ir)};Ve.assert(!1,"0x"+e.toString(16)+": lookup type 6 format must be 1, 2 or 3.")};Wn[7]=function(){const e=this.parseUShort();Ve.argument(e===1,"GSUB Extension Substitution subtable identifier-format must be 1");const t=this.parseUShort(),i=new Y(this.data,this.offset+this.parseULong());return{substFormat:1,lookupType:t,extension:Wn[t].call(i)}};Wn[8]=function(){const e=this.parseUShort();return Ve.argument(e===1,"GSUB Reverse Chaining Contextual Single Substitution Subtable identifier-format must be 1"),{substFormat:e,coverage:this.parsePointer(Y.coverage),backtrackCoverage:this.parseList(Y.pointer(Y.coverage)),lookaheadCoverage:this.parseList(Y.pointer(Y.coverage)),substitutes:this.parseUShortList()}};function p2(n,e){e=e||0;const t=new Y(n,e),i=t.parseVersion(1);return Ve.argument(i===1||i===1.1,"Unsupported GSUB table version."),i===1?{version:i,scripts:t.parseScriptList(),features:t.parseFeatureList(),lookups:t.parseLookupList(Wn)}:{version:i,scripts:t.parseScriptList(),features:t.parseFeatureList(),lookups:t.parseLookupList(Wn),variations:t.parseFeatureVariationsList()}}var bs=new Array(9);bs[1]=function(e){if(e.substFormat===1)return new _e.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:1},{name:"coverage",type:"TABLE",value:new _e.Coverage(e.coverage)},{name:"deltaGlyphID",type:"SHORT",value:e.deltaGlyphId}]);if(e.substFormat===2)return new _e.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:2},{name:"coverage",type:"TABLE",value:new _e.Coverage(e.coverage)}].concat(_e.ushortList("substitute",e.substitute)));Ve.fail("Lookup type 1 substFormat must be 1 or 2.")};bs[2]=function(e){return Ve.assert(e.substFormat===1,"Lookup type 2 substFormat must be 1."),new _e.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:1},{name:"coverage",type:"TABLE",value:new _e.Coverage(e.coverage)}].concat(_e.tableList("seqSet",e.sequences,function(t){return new _e.Table("sequenceSetTable",_e.ushortList("sequence",t))})))};bs[3]=function(e){return Ve.assert(e.substFormat===1,"Lookup type 3 substFormat must be 1."),new _e.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:1},{name:"coverage",type:"TABLE",value:new _e.Coverage(e.coverage)}].concat(_e.tableList("altSet",e.alternateSets,function(t){return new _e.Table("alternateSetTable",_e.ushortList("alternate",t))})))};bs[4]=function(e){return Ve.assert(e.substFormat===1,"Lookup type 4 substFormat must be 1."),new _e.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:1},{name:"coverage",type:"TABLE",value:new _e.Coverage(e.coverage)}].concat(_e.tableList("ligSet",e.ligatureSets,function(t){return new _e.Table("ligatureSetTable",_e.tableList("ligature",t,function(i){return new _e.Table("ligatureTable",[{name:"ligGlyph",type:"USHORT",value:i.ligGlyph}].concat(_e.ushortList("component",i.components,i.components.length+1)))}))})))};bs[5]=function(e){if(e.substFormat===1)return new _e.Table("contextualSubstitutionTable",[{name:"substFormat",type:"USHORT",value:e.substFormat},{name:"coverage",type:"TABLE",value:new _e.Coverage(e.coverage)}].concat(_e.tableList("sequenceRuleSet",e.ruleSets,function(t){return t?new _e.Table("sequenceRuleSetTable",_e.tableList("sequenceRule",t,function(i){let s=_e.ushortList("seqLookup",[],i.lookupRecords.length).concat(_e.ushortList("inputSequence",i.input,i.input.length+1));[s[0],s[1]]=[s[1],s[0]];for(let r=0;r<i.lookupRecords.length;r++){const a=i.lookupRecords[r];s=s.concat({name:"sequenceIndex"+r,type:"USHORT",value:a.sequenceIndex}).concat({name:"lookupListIndex"+r,type:"USHORT",value:a.lookupListIndex})}return new _e.Table("sequenceRuleTable",s)})):new _e.Table("NULL",null)})));if(e.substFormat===2)return new _e.Table("contextualSubstitutionTable",[{name:"substFormat",type:"USHORT",value:e.substFormat},{name:"coverage",type:"TABLE",value:new _e.Coverage(e.coverage)},{name:"classDef",type:"TABLE",value:new _e.ClassDef(e.classDef)}].concat(_e.tableList("classSeqRuleSet",e.classSets,function(t){return t?new _e.Table("classSeqRuleSetTable",_e.tableList("classSeqRule",t,function(i){let s=_e.ushortList("classes",i.classes,i.classes.length+1).concat(_e.ushortList("seqLookupCount",[],i.lookupRecords.length));for(let r=0;r<i.lookupRecords.length;r++){const a=i.lookupRecords[r];s=s.concat({name:"sequenceIndex"+r,type:"USHORT",value:a.sequenceIndex}).concat({name:"lookupListIndex"+r,type:"USHORT",value:a.lookupListIndex})}return new _e.Table("classSeqRuleTable",s)})):new _e.Table("NULL",null)})));if(e.substFormat===3){let t=[{name:"substFormat",type:"USHORT",value:e.substFormat}];t.push({name:"inputGlyphCount",type:"USHORT",value:e.coverages.length}),t.push({name:"substitutionCount",type:"USHORT",value:e.lookupRecords.length});for(let s=0;s<e.coverages.length;s++){const r=e.coverages[s];t.push({name:"inputCoverage"+s,type:"TABLE",value:new _e.Coverage(r)})}for(let s=0;s<e.lookupRecords.length;s++){const r=e.lookupRecords[s];t=t.concat({name:"sequenceIndex"+s,type:"USHORT",value:r.sequenceIndex}).concat({name:"lookupListIndex"+s,type:"USHORT",value:r.lookupListIndex})}return new _e.Table("contextualSubstitutionTable",t)}Ve.assert(!1,"lookup type 5 format must be 1, 2 or 3.")};bs[6]=function(e){if(e.substFormat===1)return new _e.Table("chainContextTable",[{name:"substFormat",type:"USHORT",value:e.substFormat},{name:"coverage",type:"TABLE",value:new _e.Coverage(e.coverage)}].concat(_e.tableList("chainRuleSet",e.chainRuleSets,function(i){return new _e.Table("chainRuleSetTable",_e.tableList("chainRule",i,function(s){let r=_e.ushortList("backtrackGlyph",s.backtrack,s.backtrack.length).concat(_e.ushortList("inputGlyph",s.input,s.input.length+1)).concat(_e.ushortList("lookaheadGlyph",s.lookahead,s.lookahead.length)).concat(_e.ushortList("substitution",[],s.lookupRecords.length));for(let a=0;a<s.lookupRecords.length;a++){const o=s.lookupRecords[a];r=r.concat({name:"sequenceIndex"+a,type:"USHORT",value:o.sequenceIndex}).concat({name:"lookupListIndex"+a,type:"USHORT",value:o.lookupListIndex})}return new _e.Table("chainRuleTable",r)}))})));if(e.substFormat===2)Ve.assert(!1,"lookup type 6 format 2 is not yet supported.");else if(e.substFormat===3){let t=[{name:"substFormat",type:"USHORT",value:e.substFormat}];t.push({name:"backtrackGlyphCount",type:"USHORT",value:e.backtrackCoverage.length});for(let s=0;s<e.backtrackCoverage.length;s++){const r=e.backtrackCoverage[s];t.push({name:"backtrackCoverage"+s,type:"TABLE",value:new _e.Coverage(r)})}t.push({name:"inputGlyphCount",type:"USHORT",value:e.inputCoverage.length});for(let s=0;s<e.inputCoverage.length;s++){const r=e.inputCoverage[s];t.push({name:"inputCoverage"+s,type:"TABLE",value:new _e.Coverage(r)})}t.push({name:"lookaheadGlyphCount",type:"USHORT",value:e.lookaheadCoverage.length});for(let s=0;s<e.lookaheadCoverage.length;s++){const r=e.lookaheadCoverage[s];t.push({name:"lookaheadCoverage"+s,type:"TABLE",value:new _e.Coverage(r)})}t.push({name:"substitutionCount",type:"USHORT",value:e.lookupRecords.length});for(let s=0;s<e.lookupRecords.length;s++){const r=e.lookupRecords[s];t=t.concat({name:"sequenceIndex"+s,type:"USHORT",value:r.sequenceIndex}).concat({name:"lookupListIndex"+s,type:"USHORT",value:r.lookupListIndex})}return new _e.Table("chainContextTable",t)}Ve.assert(!1,"lookup type 6 format must be 1, 2 or 3.")};function m2(n){return new _e.Table("GSUB",[{name:"version",type:"ULONG",value:65536},{name:"scripts",type:"TABLE",value:new _e.ScriptList(n.scripts)},{name:"features",type:"TABLE",value:new _e.FeatureList(n.features)},{name:"lookups",type:"TABLE",value:new _e.LookupList(n.lookups,bs)}])}var o0={parse:p2,make:m2};function g2(n,e){const t=new Ie.Parser(n,e),i=t.parseULong();Ve.argument(i===1,"Unsupported META table version."),t.parseULong(),t.parseULong();const s=t.parseULong(),r={};for(let a=0;a<s;a++){const o=t.parseTag(),l=t.parseULong(),c=t.parseULong();if(o==="appl"||o==="bild")continue;const u=ur.UTF8(n,e+l,c);r[o]=u}return r}function _2(n){const e=Object.keys(n).length;let t="";const i=16+e*12,s=new _e.Table("meta",[{name:"version",type:"ULONG",value:1},{name:"flags",type:"ULONG",value:0},{name:"offset",type:"ULONG",value:i},{name:"numTags",type:"ULONG",value:e}]);for(let r in n){const a=t.length;t+=n[r],s.fields.push({name:"tag "+r,type:"TAG",value:r}),s.fields.push({name:"offset "+r,type:"ULONG",value:i+a}),s.fields.push({name:"length "+r,type:"ULONG",value:n[r].length})}return s.fields.push({name:"stringPool",type:"CHARARRAY",value:t}),s}var l0={parse:g2,make:_2};function x2(n,e){const t=new Y(n,e),i=t.parseUShort();i!==0&&console.warn("Only COLRv0 is currently fully supported. A subset of color glyphs might be available in this font if provided in the v0 format.");const s=t.parseUShort(),r=t.parseOffset32(),a=t.parseOffset32(),o=t.parseUShort();t.relativeOffset=r;const l=t.parseRecordList(s,{glyphID:Y.uShort,firstLayerIndex:Y.uShort,numLayers:Y.uShort});t.relativeOffset=a;const c=t.parseRecordList(o,{glyphID:Y.uShort,paletteIndex:Y.uShort});return{version:i,baseGlyphRecords:l,layerRecords:c}}function y2({version:n=0,baseGlyphRecords:e=[],layerRecords:t=[]}){Ve.argument(n===0,"Only COLRv0 supported.");const i=14,s=i+e.length*6;return new _e.Table("COLR",[{name:"version",type:"USHORT",value:n},{name:"numBaseGlyphRecords",type:"USHORT",value:e.length},{name:"baseGlyphRecordsOffset",type:"ULONG",value:i},{name:"layerRecordsOffset",type:"ULONG",value:s},{name:"numLayerRecords",type:"USHORT",value:t.length},...e.map((r,a)=>[{name:"glyphID_"+a,type:"USHORT",value:r.glyphID},{name:"firstLayerIndex_"+a,type:"USHORT",value:r.firstLayerIndex},{name:"numLayers_"+a,type:"USHORT",value:r.numLayers}]).flat(),...t.map((r,a)=>[{name:"LayerGlyphID_"+a,type:"USHORT",value:r.glyphID},{name:"paletteIndex_"+a,type:"USHORT",value:r.paletteIndex}]).flat()])}var c0={parse:x2,make:y2};function v2(n,e){return[{name:"tag_"+n,type:"TAG",value:e.tag},{name:"minValue_"+n,type:"FIXED",value:e.minValue<<16},{name:"defaultValue_"+n,type:"FIXED",value:e.defaultValue<<16},{name:"maxValue_"+n,type:"FIXED",value:e.maxValue<<16},{name:"flags_"+n,type:"USHORT",value:0},{name:"nameID_"+n,type:"USHORT",value:e.axisNameID}]}function S2(n,e,t){const i={},s=new Ie.Parser(n,e);i.tag=s.parseTag(),i.minValue=s.parseFixed(),i.defaultValue=s.parseFixed(),i.maxValue=s.parseFixed(),s.skip("uShort",1);const r=s.parseUShort();return i.axisNameID=r,i.name=No(t,r),i}function b2(n,e,t,i={}){const s=[{name:"nameID_"+n,type:"USHORT",value:e.subfamilyNameID},{name:"flags_"+n,type:"USHORT",value:0}];for(let r=0;r<t.length;++r){const a=t[r].tag;s.push({name:"axis_"+n+" "+a,type:"FIXED",value:e.coordinates[a]<<16})}return i&&i.postScriptNameID&&s.push({name:"postScriptNameID_",type:"USHORT",value:e.postScriptNameID!==void 0?e.postScriptNameID:65535}),s}function M2(n,e,t,i,s){const r={},a=new Ie.Parser(n,e),o=a.parseUShort();r.subfamilyNameID=o,r.name=No(i,o,[2,17]),a.skip("uShort",1),r.coordinates={};for(let c=0;c<t.length;++c)r.coordinates[t[c].tag]=a.parseFixed();if(a.relativeOffset===s)return r.postScriptNameID=void 0,r.postScriptName=void 0,r;const l=a.parseUShort();return r.postScriptNameID=l==65535?void 0:l,r.postScriptName=r.postScriptNameID!==void 0?No(i,l,[6]):"",r}function A2(n,e){const t=new _e.Table("fvar",[{name:"version",type:"ULONG",value:65536},{name:"offsetToData",type:"USHORT",value:0},{name:"countSizePairs",type:"USHORT",value:2},{name:"axisCount",type:"USHORT",value:n.axes.length},{name:"axisSize",type:"USHORT",value:20},{name:"instanceCount",type:"USHORT",value:n.instances.length},{name:"instanceSize",type:"USHORT",value:4+n.axes.length*4}]);t.offsetToData=t.sizeOf();for(let s=0;s<n.axes.length;s++)t.fields=t.fields.concat(v2(s,n.axes[s]));const i={};for(let s=0;s<n.instances.length;s++)if(n.instances[s].postScriptNameID!==void 0){t.instanceSize+=2,i.postScriptNameID=!0;break}for(let s=0;s<n.instances.length;s++)t.fields=t.fields.concat(b2(s,n.instances[s],n.axes,i));return t}function E2(n,e,t){const i=new Ie.Parser(n,e),s=i.parseULong();Ve.argument(s===65536,"Unsupported fvar table version.");const r=i.parseOffset16();i.skip("uShort",1);const a=i.parseUShort(),o=i.parseUShort(),l=i.parseUShort(),c=i.parseUShort(),u=[];for(let f=0;f<a;f++)u.push(S2(n,e+r+f*o,t));const h=[],d=e+r+a*o;for(let f=0;f<l;f++)h.push(M2(n,d+f*c,u,t,c));return{axes:u,instances:h}}var u0={make:A2,parse:E2},T2={tag:Y.tag,nameID:Y.uShort,ordering:Y.uShort},sa=new Array(5);sa[1]=function(){return{axisIndex:this.parseUShort(),flags:this.parseUShort(),valueNameID:this.parseUShort(),value:this.parseFixed()}};sa[2]=function(){return{axisIndex:this.parseUShort(),flags:this.parseUShort(),valueNameID:this.parseUShort(),nominalValue:this.parseFixed(),rangeMinValue:this.parseFixed(),rangeMaxValue:this.parseFixed()}};sa[3]=function(){return{axisIndex:this.parseUShort(),flags:this.parseUShort(),valueNameID:this.parseUShort(),value:this.parseFixed(),linkedValue:this.parseFixed()}};sa[4]=function(){const e=this.parseUShort();return{flags:this.parseUShort(),valueNameID:this.parseUShort(),axisValues:this.parseList(e,function(){return{axisIndex:this.parseUShort(),value:this.parseFixed()}})}};function C2(){const n=this.parseUShort(),e=sa[n],t={format:n};return e===void 0?(console.warn(`Unknown axis value table format ${n}`),t):Object.assign(t,this.parseStruct(e.bind(this)))}function w2(n,e,t){e||(e=0);const i=new Ie.Parser(n,e),s=i.parseUShort(),r=i.parseUShort();s!==1&&console.warn(`Unsupported STAT table version ${s}.${r}`);const a=[s,r],o=i.parseUShort(),l=i.parseUShort(),c=i.parseOffset32(),u=i.parseUShort(),h=i.parseOffset32(),d=s>1||r>0?i.parseUShort():void 0;t!==void 0&&Ve.argument(l>=t.axes.length,"STAT axis count must be greater than or equal to fvar axis count"),u>0&&Ve.argument(l>=0,"STAT axis count must be greater than 0 if STAT axis value count is greater than 0");const f=[];for(let m=0;m<l;m++)i.offset=e+c,i.relativeOffset=m*o,f.push(i.parseStruct(T2));i.offset=e,i.relativeOffset=h;const p=i.parseUShortList(u),_=[];for(let m=0;m<u;m++)i.offset=e+h,i.relativeOffset=p[m],_.push(C2.apply(i));return{version:a,axes:f,values:_,elidedFallbackNameID:d}}var ra=new Array(5);ra[1]=function(e,t){return[{name:`format${e}`,type:"USHORT",value:1},{name:`axisIndex${e}`,type:"USHORT",value:t.axisIndex},{name:`flags${e}`,type:"USHORT",value:t.flags},{name:`valueNameID${e}`,type:"USHORT",value:t.valueNameID},{name:`value${e}`,type:"FLOAT",value:t.value}]};ra[2]=function(e,t){return[{name:`format${e}`,type:"USHORT",value:2},{name:`axisIndex${e}`,type:"USHORT",value:t.axisIndex},{name:`flags${e}`,type:"USHORT",value:t.flags},{name:`valueNameID${e}`,type:"USHORT",value:t.valueNameID},{name:`nominalValue${e}`,type:"FLOAT",value:t.nominalValue},{name:`rangeMinValue${e}`,type:"FLOAT",value:t.rangeMinValue},{name:`rangeMaxValue${e}`,type:"FLOAT",value:t.rangeMaxValue}]};ra[3]=function(e,t){return[{name:`format${e}`,type:"USHORT",value:3},{name:`axisIndex${e}`,type:"USHORT",value:t.axisIndex},{name:`flags${e}`,type:"USHORT",value:t.flags},{name:`valueNameID${e}`,type:"USHORT",value:t.valueNameID},{name:`value${e}`,type:"FLOAT",value:t.value},{name:`linkedValue${e}`,type:"FLOAT",value:t.linkedValue}]};ra[4]=function(e,t){let i=[{name:`format${e}`,type:"USHORT",value:4},{name:`axisCount${e}`,type:"USHORT",value:t.axisValues.length},{name:`flags${e}`,type:"USHORT",value:t.flags},{name:`valueNameID${e}`,type:"USHORT",value:t.valueNameID}];for(let s=0;s<t.axisValues.length;s++)i=i.concat([{name:`format${e}axisIndex${s}`,type:"USHORT",value:t.axisValues[s].axisIndex},{name:`format${e}value${s}`,type:"FLOAT",value:t.axisValues[s].value}]);return i};function R2(n,e){return new _e.Record("axisRecord_"+n,[{name:"axisTag_"+n,type:"TAG",value:e.tag},{name:"axisNameID_"+n,type:"USHORT",value:e.nameID},{name:"axisOrdering_"+n,type:"USHORT",value:e.ordering}])}function L2(n,e){const t=e.format,i=ra[t];Ve.argument(i!==void 0,`Unknown axis value table format ${t}`);const s=i(n,e);return new _e.Table("axisValueTable_"+n,s)}function D2(n){const e=new _e.Table("STAT",[{name:"majorVersion",type:"USHORT",value:1},{name:"minorVersion",type:"USHORT",value:2},{name:"designAxisSize",type:"USHORT",value:8},{name:"designAxisCount",type:"USHORT",value:n.axes.length},{name:"designAxesOffset",type:"ULONG",value:0},{name:"axisValueCount",type:"USHORT",value:n.values.length},{name:"offsetToAxisValueOffsets",type:"ULONG",value:0},{name:"elidedFallbackNameID",type:"USHORT",value:n.elidedFallbackNameID}]);e.designAxesOffset=e.offsetToAxisValueOffsets=e.sizeOf();for(let r=0;r<n.axes.length;r++){const a=R2(r,n.axes[r]);e.offsetToAxisValueOffsets+=a.sizeOf(),e.fields=e.fields.concat(a.fields)}const t=[];let i=[],s=n.values.length*2;for(let r=0;r<n.values.length;r++){const a=L2(r,n.values[r]);t.push({name:"offset_"+r,type:"USHORT",value:s}),s+=a.sizeOf(),i=i.concat(a.fields)}return e.fields=e.fields.concat(t),e.fields=e.fields.concat(i),e}var h0={make:D2,parse:w2};function I2(n,e){return new _e.Record("axisValueMap_"+n,[{name:"fromCoordinate_"+n,type:"F2DOT14",value:e.fromCoordinate},{name:"toCoordinate_"+n,type:"F2DOT14",value:e.toCoordinate}])}function P2(n,e){const t=new _e.Record("segmentMap_"+n,[{name:"positionMapCount_"+n,type:"USHORT",value:e.axisValueMaps.length}]);let i=[];for(let s=0;s<e.axisValueMaps.length;s++){const r=I2(`${n}_${s}`,e.axisValueMaps[s]);i=i.concat(r.fields)}return t.fields=t.fields.concat(i),t}function O2(n,e){Ve.argument(n.axisSegmentMaps.length===e.axes.length,"avar axis count must correspond to fvar axis count");const t=new _e.Table("avar",[{name:"majorVersion",type:"USHORT",value:1},{name:"minorVersion",type:"USHORT",value:0},{name:"reserved",type:"USHORT",value:0},{name:"axisCount",type:"USHORT",value:n.axisSegmentMaps.length}]);for(let i=0;i<n.axisSegmentMaps.length;i++){const s=P2(i,n.axisSegmentMaps[i]);t.fields=t.fields.concat(s.fields)}return t}function U2(n,e,t){e||(e=0);const i=new Y(n,e),s=i.parseUShort(),r=i.parseUShort();s!==1&&console.warn(`Unsupported avar table version ${s}.${r}`),i.skip("uShort",1);const a=i.parseUShort();Ve.argument(a===t.axes.length,"avar axis count must correspond to fvar axis count");const o=[];for(let l=0;l<a;l++){const c=[],u=i.parseUShort();for(let h=0;h<u;h++){const d=i.parseF2Dot14(),f=i.parseF2Dot14();c.push({fromCoordinate:d,toCoordinate:f})}o.push({axisValueMaps:c})}return{version:[s,r],axisSegmentMaps:o}}var d0={make:O2,parse:U2};function N2(n,e,t,i){const s=new Ie.Parser(n,e),r=s.parseTupleVariationStore(s.relativeOffset,t.axes.length,"cvar",i),a=s.parseUShort(),o=s.parseUShort();return a!==1&&console.warn(`Unsupported cvar table version ${a}.${o}`),{version:[a,o],...r}}function k2(){console.warn("Writing of cvar tables is not yet supported.")}var f0={make:k2,parse:N2};function F2(n,e,t,i){const s=new Ie.Parser(n,e),r=s.parseUShort(),a=s.parseUShort();r!==1&&console.warn(`Unsupported gvar table version ${r}.${a}`);const o=s.parseUShort();o!==t.axes.length&&console.warn(`axisCount ${o} in gvar table does not match the number of axes ${t.axes.length} in the fvar table!`);const l=s.parseUShort(),c=s.parsePointer32(function(){return this.parseTupleRecords(l,o)}),u=s.parseTupleVariationStoreList(o,"gvar",i);return{version:[r,a],sharedTuples:c,glyphVariations:u}}function B2(){console.warn("Writing of gvar tables is not yet supported.")}var p0={make:B2,parse:F2};function H2(n,e){const t={},i=new Ie.Parser(n,e);t.version=i.parseUShort(),Ve.argument(t.version<=1,"Unsupported gasp table version."),t.numRanges=i.parseUShort(),t.gaspRanges=[];for(let s=0;s<t.numRanges;s++)t.gaspRanges[s]={rangeMaxPPEM:i.parseUShort(),rangeGaspBehavior:i.parseUShort()};return t}function z2(n){const e=new _e.Table("gasp",[{name:"version",type:"USHORT",value:1},{name:"numRanges",type:"USHORT",value:n.numRanges}]);for(let t in n.gaspRanges)e.fields.push({name:"rangeMaxPPEM",type:"USHORT",value:n.gaspRanges[t].rangeMaxPPEM}),e.fields.push({name:"rangeGaspBehavior",type:"USHORT",value:n.gaspRanges[t].rangeGaspBehavior});return e}var m0={parse:H2,make:z2};function V2(n,e){const t=new Map,i=n.buffer,s=new Y(n,e);if(s.parseUShort()!==0)return t;s.relativeOffset=s.parseOffset32();const a=n.byteOffset+e+s.relativeOffset,o=s.parseUShort(),l=new Map;for(let c=0;c<o;c++){const u=s.parseUShort(),h=s.parseUShort(),d=a+s.parseOffset32(),f=s.parseULong();let p=l.get(d);p===void 0&&(p=new Uint8Array(i,d,f),l.set(d,p));for(let _=u;_<=h;_++)t.set(_,p)}return t}function G2(n){const e=Array.from(n.keys()).sort(),t=[],i=[],s=new Map;let r=0,a={endGlyphID:null};for(let d=0,f=e.length;d<f;d++){const p=e[d],_=n.get(p);let m=s.get(_);m===void 0&&(m=r,i.push(_),s.set(_,m),r+=_.byteLength),p-1===a.endGlyphID&&m===a.svgDocOffset?a.endGlyphID=p:(a={startGlyphID:p,endGlyphID:p,svgDocOffset:m,svgDocLength:_.byteLength},t.push(a))}const o=t.length,l=i.length,c=2+o*12,u=new Array(4+o*4+l);let h=0;u[h++]={name:"version",type:"USHORT",value:0},u[h++]={name:"svgDocumentListOffset",type:"ULONG",value:10},u[h++]={name:"reserved",type:"ULONG",value:0},u[h++]={name:"numEntries",type:"USHORT",value:o};for(let d=0;d<o;d++){const f="documentRecord_"+d,{startGlyphID:p,endGlyphID:_,svgDocOffset:m,svgDocLength:g}=t[d];u[h++]={name:f+"_startGlyphID",type:"USHORT",value:p},u[h++]={name:f+"_endGlyphID",type:"USHORT",value:_},u[h++]={name:f+"_svgDocOffset",type:"ULONG",value:c+m},u[h++]={name:f+"_svgDocLength",type:"ULONG",value:g}}for(let d=0;d<l;d++)u[h++]={name:"svgDoc_"+d,type:"LITERAL",value:i[d]};return new _e.Table("SVG ",u)}var g0={make:G2,parse:V2};function Id(n){return Math.log(n)/Math.log(2)|0}function Hu(n){for(;n.length%4!==0;)n.push(0);let e=0;for(let t=0;t<n.length;t+=4)e+=(n[t]<<24)+(n[t+1]<<16)+(n[t+2]<<8)+n[t+3];return e%=Math.pow(2,32),e}function Pd(n,e,t,i){return new _e.Record("Table Record",[{name:"tag",type:"TAG",value:n!==void 0?n:""},{name:"checkSum",type:"ULONG",value:e!==void 0?e:0},{name:"offset",type:"ULONG",value:t!==void 0?t:0},{name:"length",type:"ULONG",value:i!==void 0?i:0}])}function _0(n){const e=new _e.Table("sfnt",[{name:"version",type:"TAG",value:"OTTO"},{name:"numTables",type:"USHORT",value:0},{name:"searchRange",type:"USHORT",value:0},{name:"entrySelector",type:"USHORT",value:0},{name:"rangeShift",type:"USHORT",value:0}]);e.tables=n,e.numTables=n.length;const t=Math.pow(2,Id(e.numTables));e.searchRange=16*t,e.entrySelector=Id(t),e.rangeShift=e.numTables*16-e.searchRange;const i=[],s=[];let r=e.sizeOf()+Pd().sizeOf()*e.numTables;for(;r%4!==0;)r+=1,s.push({name:"padding",type:"BYTE",value:0});for(let a=0;a<n.length;a+=1){const o=n[a];Ve.argument(o.tableName.length===4,"Table name"+o.tableName+" is invalid.");const l=o.sizeOf(),c=Pd(o.tableName,Hu(o.encode()),r,l);for(i.push({name:c.tag+" Table Record",type:"RECORD",value:c}),s.push({name:o.tableName+" table",type:"RECORD",value:o}),r+=l,Ve.argument(!isNaN(r),"Something went wrong calculating the offset.");r%4!==0;)r+=1,s.push({name:"padding",type:"BYTE",value:0})}return i.sort(function(a,o){return a.value.tag>o.value.tag?1:-1}),e.fields=e.fields.concat(i),e.fields=e.fields.concat(s),e}function Od(n,e,t){for(let i=0;i<e.length;i+=1){const s=n.charToGlyphIndex(e[i]);if(s>0)return n.glyphs.get(s).getMetrics()}return t}function W2(n){let e=0;for(let t=0;t<n.length;t+=1)e+=n[t];return e/n.length}function X2(n){const e=[],t=[],i=[],s=[],r=[],a=[],o=[];let l,c=0,u=0,h=0,d=0,f=0;for(let Z=0;Z<n.glyphs.length;Z+=1){const xe=n.glyphs.get(Z),be=xe.unicode|0;if(isNaN(xe.advanceWidth))throw new Error("Glyph "+xe.name+" ("+Z+"): advanceWidth is not a number.");(l>be||l===void 0)&&be>0&&(l=be),c<be&&(c=be);const Se=ru.getUnicodeRange(be);if(Se<32)u|=1<<Se;else if(Se<64)h|=1<<Se-32;else if(Se<96)d|=1<<Se-64;else if(Se<123)f|=1<<Se-96;else throw new Error("Unicode ranges bits > 123 are reserved for internal usage");if(xe.name===".notdef")continue;const Oe=xe.getMetrics();e.push(Oe.xMin),t.push(Oe.yMin),i.push(Oe.xMax),s.push(Oe.yMax),a.push(Oe.leftSideBearing),o.push(Oe.rightSideBearing),r.push(xe.advanceWidth)}const p={xMin:Math.min.apply(null,e),yMin:Math.min.apply(null,t),xMax:Math.max.apply(null,i),yMax:Math.max.apply(null,s),advanceWidthMax:Math.max.apply(null,r),advanceWidthAvg:W2(r),minLeftSideBearing:Math.min.apply(null,a),maxLeftSideBearing:Math.max.apply(null,a),minRightSideBearing:Math.min.apply(null,o)};p.ascender=n.ascender,p.descender=n.descender;let _=0;n.weightClass>=600&&(_|=n.macStyleValues.BOLD),n.italicAngle<0&&(_|=n.macStyleValues.ITALIC);const m=t0.make({flags:3,unitsPerEm:n.unitsPerEm,xMin:p.xMin,yMin:p.yMin,xMax:p.xMax,yMax:p.yMax,lowestRecPPEM:3,macStyle:_,createdTimestamp:n.createdTimestamp}),g=n0.make({ascender:p.ascender,descender:p.descender,advanceWidthMax:p.advanceWidthMax,minLeftSideBearing:p.minLeftSideBearing,minRightSideBearing:p.minRightSideBearing,xMaxExtent:p.maxLeftSideBearing+(p.xMax-p.xMin),numberOfHMetrics:n.glyphs.length}),v=r0.make(n.glyphs.length),b=ru.make(Object.assign({xAvgCharWidth:Math.round(p.advanceWidthAvg),usFirstCharIndex:l,usLastCharIndex:c,ulUnicodeRange1:u,ulUnicodeRange2:h,ulUnicodeRange3:d,ulUnicodeRange4:f,sTypoAscender:p.ascender,sTypoDescender:p.descender,sTypoLineGap:0,usWinAscent:p.yMax,usWinDescent:Math.abs(p.yMin),ulCodePageRange1:1,sxHeight:Od(n,"xyvw",{yMax:Math.round(p.ascender/2)}).yMax,sCapHeight:Od(n,"HIKLEFJMNTZBDPRAGOQSUVWXY",p).yMax,usDefaultChar:n.hasChar(" ")?32:0,usBreakChar:n.hasChar(" ")?32:0},n.tables.os2)),x=i0.make(n.glyphs),E=Vp.make(n.glyphs),S=n.getEnglishName("fontFamily"),A=n.getEnglishName("fontSubfamily"),y=S+" "+A;let T=n.getEnglishName("postScriptName");T||(T=S.replace(/\s/g,"")+"-"+A);const L={};for(let Z in n.names)L[Z]=n.names[Z];L.unicode=L.unicode||{},L.macintosh=L.macintosh||{},L.windows=L.windows||{};const R=n.names.unicode||{},w=n.names.macintosh||{},P=n.names.windows||{};for(const Z in L){if(L[Z]=L[Z]||{},!L[Z].uniqueID){const xe=n.getEnglishName("manufacturer")||"";L[Z].uniqueID={en:`${xe}: ${y}`}}L[Z].postScriptName||(L[Z].postScriptName={en:T})}L.unicode.preferredFamily||(L.unicode.preferredFamily=R.fontFamily||w.fontFamily||P.fontFamily),L.macintosh.preferredFamily||(L.macintosh.preferredFamily=w.fontFamily||R.fontFamily||P.fontFamily),L.windows.preferredFamily||(L.windows.preferredFamily=P.fontFamily||R.fontFamily||w.fontFamily),L.unicode.preferredSubfamily||(L.unicode.preferredSubfamily=R.fontSubfamily||w.fontSubfamily||P.fontSubfamily),L.macintosh.preferredSubfamily||(L.macintosh.preferredSubfamily=w.fontSubfamily||R.fontSubfamily||P.fontSubfamily),L.windows.preferredSubfamily||(L.windows.preferredSubfamily=P.fontSubfamily||R.fontSubfamily||w.fontSubfamily);const U=[],D=zp.make(L,U),K=U.length>0?s0.make(U):void 0,B=a0.make(n),ie=iu.make(n.glyphs,{version:n.getEnglishName("version"),fullName:y,familyName:S,weightName:A,postScriptName:T,unitsPerEm:n.unitsPerEm,fontBBox:[0,p.yMin,p.ascender,p.advanceWidthMax],topDict:n.tables.cff&&n.tables.cff.topDict||{}}),F=n.metas&&Object.keys(n.metas).length>0?l0.make(n.metas):void 0,se=[m,g,v,b,D,E,B,ie,x];K&&se.push(K);const V={gsub:o0,cpal:qp,colr:c0,stat:h0,avar:d0,cvar:f0,fvar:u0,gvar:p0,gasp:m0,svg:g0},oe={avar:[n.tables.fvar],fvar:[n.names]};for(let Z in V){const xe=n.tables[Z];if(xe){const be=V[Z].make.call(n,xe,...oe[Z]||[]);be&&se.push(be)}}F&&se.push(F);const Ae=_0(se),me=Ae.encode(),ue=Hu(me),z=Ae.fields;let ee=!1;for(let Z=0;Z<z.length;Z+=1)if(z[Z].name==="head table"){z[Z].value.checkSumAdjustment=2981146554-ue,ee=!0;break}if(!ee)throw new Error("Could not find head table with checkSum to adjust.");return Ae}var Y2={make:_0,fontToTable:X2,computeCheckSum:Hu};function Gl(n,e){let t=0,i=n.length-1;for(;t<=i;){const s=t+i>>>1,r=n[s].tag;if(r===e)return s;r<e?t=s+1:i=s-1}return-t-1}function Ud(n,e){let t=0,i=n.length-1;for(;t<=i;){const s=t+i>>>1,r=n[s];if(r===e)return s;r<e?t=s+1:i=s-1}return-t-1}function Nd(n,e){let t,i=0,s=n.length-1;for(;i<=s;){const r=i+s>>>1;t=n[r];const a=t.start;if(a===e)return t;a<e?i=r+1:s=r-1}if(i>0)return t=n[i-1],e>t.end?0:t}function x0(n,e){this.font=n,this.tableName=e}x0.prototype={searchTag:Gl,binSearch:Ud,getTable:function(n){let e=this.font.tables[this.tableName];return!e&&n&&(e=this.font.tables[this.tableName]=this.createDefaultTable()),e},getScriptNames:function(){let n=this.getTable();return n?n.scripts.map(function(e){return e.tag}):[]},getDefaultScriptName:function(){let n=this.getTable();if(!n)return;let e=!1;for(let t=0;t<n.scripts.length;t++){const i=n.scripts[t].tag;if(i==="DFLT")return i;i==="latn"&&(e=!0)}if(e)return"latn"},getScriptTable:function(n,e){const t=this.getTable(e);if(t){n=n||"DFLT";const i=t.scripts,s=Gl(t.scripts,n);if(s>=0)return i[s].script;if(e){const r={tag:n,script:{defaultLangSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]},langSysRecords:[]}};return i.splice(-1-s,0,r),r.script}}},getLangSysTable:function(n,e,t){const i=this.getScriptTable(n,t);if(i){if(!e||e==="dflt"||e==="DFLT")return i.defaultLangSys;const s=Gl(i.langSysRecords,e);if(s>=0)return i.langSysRecords[s].langSys;if(t){const r={tag:e,langSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]}};return i.langSysRecords.splice(-1-s,0,r),r.langSys}}},getFeatureTable:function(n,e,t,i){const s=this.getLangSysTable(n,e,i);if(s){let r;const a=s.featureIndexes,o=this.font.tables[this.tableName].features;for(let l=0;l<a.length;l++)if(r=o[a[l]],r.tag===t)return r.feature;if(i){const l=o.length;return Ve.assert(l===0||t>=o[l-1].tag,"Features must be added in alphabetical order."),r={tag:t,feature:{params:0,lookupListIndexes:[]}},o.push(r),a.push(l),r.feature}}},getLookupTables:function(n,e,t,i,s){const r=this.getFeatureTable(n,e,t,s),a=[];if(r){let o;const l=r.lookupListIndexes,c=this.font.tables[this.tableName].lookups;for(let u=0;u<l.length;u++)o=c[l[u]],o.lookupType===i&&a.push(o);if(a.length===0&&s){o={lookupType:i,lookupFlag:0,subtables:[],markFilteringSet:void 0};const u=c.length;return c.push(o),l.push(u),[o]}}return a},getGlyphClass:function(n,e){switch(n.format){case 1:return n.startGlyph<=e&&e<n.startGlyph+n.classes.length?n.classes[e-n.startGlyph]:0;case 2:{const t=Nd(n.ranges,e);return t?t.classId:0}}},getCoverageIndex:function(n,e){switch(n.format){case 1:{const t=Ud(n.glyphs,e);return t>=0?t:-1}case 2:{const t=Nd(n.ranges,e);return t?t.index+e-t.start:-1}}},expandCoverage:function(n){if(n.format===1)return n.glyphs;{const e=[],t=n.ranges;for(let i=0;i<t.length;i++){const s=t[i],r=s.start,a=s.end;for(let o=r;o<=a;o++)e.push(o)}return e}}};var qo=x0;function aa(n){qo.call(this,n,"gpos")}aa.prototype=qo.prototype;aa.prototype.init=function(){const n=this.getDefaultScriptName();this.defaultKerningTables=this.getKerningTables(n)};aa.prototype.getKerningValue=function(n,e,t){for(let i=0;i<n.length;i++){const s=n[i].subtables;for(let r=0;r<s.length;r++){const a=s[r],o=this.getCoverageIndex(a.coverage,e);if(!(o<0))switch(a.posFormat){case 1:{let l=a.pairSets[o];for(let c=0;c<l.length;c++){let u=l[c];if(u.secondGlyph===t)return u.value1&&u.value1.xAdvance||0}break}case 2:{const l=this.getGlyphClass(a.classDef1,e),c=this.getGlyphClass(a.classDef2,t),u=a.classRecords[l][c];return u.value1&&u.value1.xAdvance||0}}}}return 0};aa.prototype.getKerningTables=function(n,e){if(this.font.tables.gpos)return this.getLookupTables(n,e,"kern",2)};var K2=aa;function q2(n,e){const t=n.length;if(t!==e.length)return!1;for(let i=0;i<t;i++)if(n[i]!==e[i])return!1;return!0}function $2(n,e,t){let i=0,s=n.length-1,r=null;for(;i<=s;){const a=Math.floor((i+s)/2),o=n[a],l=o[e];if(l<t)i=a+1;else if(l>t)s=a-1;else{r=o;break}}return r}function Z2(n,e,t){let i=0,s=n.length-1;for(;i<=s;){const r=Math.floor((i+s)/2),a=n[r];if(a[e]<t)i=r+1;else if(a[e]>t)s=r-1;else return r}return-1}function J2(n,e,t){let i=0,s=n.length;const r=(a,o)=>a[e]-o[e];for(;i<s;){const a=i+s>>>1;r(n[a],t)<0?i=a+1:s=a}return n.splice(i,0,t),i}function y0(n){return n[0]===31&&n[1]===139&&n[2]===8}function j2(n){const e=new DataView(n.buffer,n.byteOffset,n.byteLength);let t=10;const i=n.byteLength-8,s=e.getInt8(3);if(s&4&&(t+=2+e.getUint16(t,!0)),s&8)for(;t<i&&n[t++]!==0;);if(s&16)for(;t<i&&n[t++]!==0;);if(s&2&&(t+=2),t>=i)throw new Error("Can't find compressed blocks");const r=e.getUint32(e.byteLength-4,!0);return Dp(n.subarray(t,i),new Uint8Array(r))}function kd(n){return{x:n.x,y:n.y,onCurve:n.onCurve,lastPointOfContour:n.lastPointOfContour}}function Q2(n){return{glyphIndex:n.glyphIndex,xScale:n.xScale,scale01:n.scale01,scale10:n.scale10,yScale:n.yScale,dx:n.dx,dy:n.dy}}function bn(n){qo.call(this,n,"gsub")}function zu(n,e,t){const i=n.subtables;for(let s=0;s<i.length;s++){const r=i[s];if(r.substFormat===e)return r}if(t)return i.push(t),t}bn.prototype=qo.prototype;bn.prototype.createDefaultTable=function(){return{version:1,scripts:[{tag:"DFLT",script:{defaultLangSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]},langSysRecords:[]}}],features:[],lookups:[]}};bn.prototype.getSingle=function(n,e,t){const i=[],s=this.getLookupTables(e,t,n,1);for(let r=0;r<s.length;r++){const a=s[r].subtables;for(let o=0;o<a.length;o++){const l=a[o],c=this.expandCoverage(l.coverage);let u;if(l.substFormat===1){const h=l.deltaGlyphId;for(u=0;u<c.length;u++){const d=c[u];i.push({sub:d,by:d+h})}}else{const h=l.substitute;for(u=0;u<c.length;u++)i.push({sub:c[u],by:h[u]})}}}return i};bn.prototype.getMultiple=function(n,e,t){const i=[],s=this.getLookupTables(e,t,n,2);for(let r=0;r<s.length;r++){const a=s[r].subtables;for(let o=0;o<a.length;o++){const l=a[o],c=this.expandCoverage(l.coverage);let u;for(u=0;u<c.length;u++){const h=c[u],d=l.sequences[u];i.push({sub:h,by:d})}}}return i};bn.prototype.getAlternates=function(n,e,t){const i=[],s=this.getLookupTables(e,t,n,3);for(let r=0;r<s.length;r++){const a=s[r].subtables;for(let o=0;o<a.length;o++){const l=a[o],c=this.expandCoverage(l.coverage),u=l.alternateSets;for(let h=0;h<c.length;h++)i.push({sub:c[h],by:u[h]})}}return i};bn.prototype.getLigatures=function(n,e,t){const i=[],s=this.getLookupTables(e,t,n,4);for(let r=0;r<s.length;r++){const a=s[r].subtables;for(let o=0;o<a.length;o++){const l=a[o],c=this.expandCoverage(l.coverage),u=l.ligatureSets;for(let h=0;h<c.length;h++){const d=c[h],f=u[h];for(let p=0;p<f.length;p++){const _=f[p];i.push({sub:[d].concat(_.components),by:_.ligGlyph})}}}}return i};bn.prototype.addSingle=function(n,e,t,i){const s=this.getLookupTables(t,i,n,1,!0)[0],r=zu(s,2,{substFormat:2,coverage:{format:1,glyphs:[]},substitute:[]});Ve.assert(r.coverage.format===1,"Single: unable to modify coverage table format "+r.coverage.format);const a=e.sub;let o=this.binSearch(r.coverage.glyphs,a);o<0&&(o=-1-o,r.coverage.glyphs.splice(o,0,a),r.substitute.splice(o,0,0)),r.substitute[o]=e.by};bn.prototype.addMultiple=function(n,e,t,i){Ve.assert(e.by instanceof Array&&e.by.length>1,'Multiple: "by" must be an array of two or more ids');const s=this.getLookupTables(t,i,n,2,!0)[0],r=zu(s,1,{substFormat:1,coverage:{format:1,glyphs:[]},sequences:[]});Ve.assert(r.coverage.format===1,"Multiple: unable to modify coverage table format "+r.coverage.format);const a=e.sub;let o=this.binSearch(r.coverage.glyphs,a);o<0&&(o=-1-o,r.coverage.glyphs.splice(o,0,a),r.sequences.splice(o,0,0)),r.sequences[o]=e.by};bn.prototype.addAlternate=function(n,e,t,i){const s=this.getLookupTables(t,i,n,3,!0)[0],r=zu(s,1,{substFormat:1,coverage:{format:1,glyphs:[]},alternateSets:[]});Ve.assert(r.coverage.format===1,"Alternate: unable to modify coverage table format "+r.coverage.format);const a=e.sub;let o=this.binSearch(r.coverage.glyphs,a);o<0&&(o=-1-o,r.coverage.glyphs.splice(o,0,a),r.alternateSets.splice(o,0,0)),r.alternateSets[o]=e.by};bn.prototype.addLigature=function(n,e,t,i){const s=this.getLookupTables(t,i,n,4,!0)[0];let r=s.subtables[0];r||(r={substFormat:1,coverage:{format:1,glyphs:[]},ligatureSets:[]},s.subtables[0]=r),Ve.assert(r.coverage.format===1,"Ligature: unable to modify coverage table format "+r.coverage.format);const a=e.sub[0],o=e.sub.slice(1),l={ligGlyph:e.by,components:o};let c=this.binSearch(r.coverage.glyphs,a);if(c>=0){const u=r.ligatureSets[c];for(let h=0;h<u.length;h++)if(q2(u[h].components,o))return;u.push(l)}else c=-1-c,r.coverage.glyphs.splice(c,0,a),r.ligatureSets.splice(c,0,[l])};bn.prototype.getFeature=function(n,e,t){if(/ss\d\d/.test(n))return this.getSingle(n,e,t);switch(n){case"aalt":case"salt":return this.getSingle(n,e,t).concat(this.getAlternates(n,e,t));case"dlig":case"liga":case"rlig":return this.getLigatures(n,e,t);case"ccmp":return this.getMultiple(n,e,t).concat(this.getLigatures(n,e,t));case"stch":return this.getMultiple(n,e,t)}};bn.prototype.add=function(n,e,t,i){if(/ss\d\d/.test(n))return this.addSingle(n,e,t,i);switch(n){case"aalt":case"salt":return typeof e.by=="number"?this.addSingle(n,e,t,i):this.addAlternate(n,e,t,i);case"dlig":case"liga":case"rlig":return this.addLigature(n,e,t,i);case"ccmp":return e.by instanceof Array?this.addMultiple(n,e,t,i):this.addLigature(n,e,t,i)}};var eM=bn,v0=class{constructor(n){this.defaultValue=255,this.font=n}cpal(){return this.font.tables&&this.font.tables.cpal?this.font.tables.cpal:!1}getAll(n){const e=[],t=this.cpal();if(!t)return e;for(let i=0;i<t.colorRecordIndices.length;i++){const s=t.colorRecordIndices[i],r=[];for(let a=s;a<s+t.numPaletteEntries;a++)r.push(fr(t.colorRecords[a],n||"hexa"));e.push(r)}return e}toCPALcolor(n){return Array.isArray(n)?n.map(e=>ko(e,"raw")):ko(n,"raw")}fillPalette(n,e=[],t=this.cpal().numPaletteEntries){return n=Number.isInteger(n)?this.get(n,"raw"):n,Object.assign(Array(t).fill(this.defaultValue),this.toCPALcolor(n).concat(this.toCPALcolor(e)))}extend(n){if(this.ensureCPAL(Array(n).fill(this.defaultValue)))return;const e=this.cpal(),t=e.numPaletteEntries+n,i=this.getAll().map(s=>this.fillPalette(s,[],t));e.numPaletteEntries=t,e.colorRecords=this.toCPALcolor(i.flat()),this.updateIndices()}get(n,e="hexa"){return this.getAll(e)[n]||null}getColor(n,e=0,t="hexa"){return Nu(this.font,n,e,t)}setColor(n,e,t=0){n=parseInt(n),t=parseInt(t);let i=this.getAll("raw"),s=i[t];if(!s)throw Error(`paletteIndex ${t} out of range`);const r=this.cpal(),a=r.numPaletteEntries;Array.isArray(e)||(e=[e]),e.length+n>a&&(this.extend(e.length+n-a),i=this.getAll("raw"),s=i[t]);for(let o=0;o<e.length;o++)s[o+n]=this.toCPALcolor(e[o]);r.colorRecords=i.flat(),this.updateIndices()}add(n){if(this.ensureCPAL(n))return;const e=this.cpal(),t=e.numPaletteEntries;n&&n.length?(n=this.toCPALcolor(n),n.length>t?this.extend(n.length-t):n.length<t&&(n=this.fillPalette(n)),e.colorRecordIndices.push(e.colorRecords.length),e.colorRecords.push(...n)):(e.colorRecordIndices.push(e.colorRecords.length),e.colorRecords.push(...Array(t).fill(this.defaultValue)))}delete(n){const e=this.getAll("raw");delete e[n];const t=this.cpal();t.colorRecordIndices.pop(),t.colorRecords=e.flat()}deleteColor(n,e){if(n===e)throw Error("replacementIndex cannot be the same as colorIndex");const t=this.cpal(),i=this.getAll("raw"),s=[];if(e>t.numPaletteEntries-1)throw Error(`Replacement index out of range: numPaletteEntries after deletion: ${t.numPaletteEntries-1}, replacementIndex: ${e})`);for(let o=0;o<i.length;o++){const c=i[o].filter((u,h)=>h!==n);s.push(c)}const r=this.font.tables.colr;if(r){const o=r.layerRecords;for(let l=0;l<o.length;l++){const c=o[l].paletteIndex;if(c>n)o[l].paletteIndex-=1;else if(c===n){let u=0;for(let h=0;h<i.length;h++)if(e>n&&e<=n+i[h].length){u++;break}o[l].paletteIndex=e-u}}this.font.tables.colr={...r,layerRecords:o}}const a=s.flat();for(let o=0;o<i.length;o++)t.colorRecordIndices[o]-=o;t.numPaletteEntries=Math.max(0,t.numPaletteEntries-1),t.colorRecords=this.toCPALcolor(a)}ensureCPAL(n){return this.cpal()?!1:(!n||!n.length?n=[this.defaultValue]:n=this.toCPALcolor(n),this.font.tables.cpal={version:0,numPaletteEntries:n.length,colorRecords:n,colorRecordIndices:[0]},!0)}updateIndices(){const n=this.cpal(),e=Math.ceil(n.colorRecords.length/n.numPaletteEntries);n.colorRecordIndices=[];for(let t=0;t<e;t++)n.colorRecordIndices.push(t*n.numPaletteEntries)}},tM=class{constructor(n){this.font=n}ensureCOLR(){return this.font.tables.colr||(this.font.tables.colr={version:0,baseGlyphRecords:[],layerRecords:[]}),this.font}get(n){const e=this.font,t=[],i=e.tables.colr,s=e.tables.cpal;if(!i||!s)return t;const r=$2(i.baseGlyphRecords,"glyphID",n);if(!r)return t;const a=r.firstLayerIndex,o=r.numLayers;for(let l=0;l<o;l++){const c=i.layerRecords[a+l];t.push({glyph:e.glyphs.get(c.glyphID),paletteIndex:c.paletteIndex})}return t}add(n,e,t){const i=this.get(n);e=Array.isArray(e)?e:[e],t===void 0||t===1/0||t>i.length?t=i.length:t<0&&(t=i.length+1+t%(i.length+1),t>=i.length+1&&(t-=i.length+1));const s=[];for(let r=0;r<t;r++){const a=Number.isInteger(i[r].glyph)?i[r].glyph:i[r].glyph.index;s.push({glyphID:a,paletteIndex:i[r].paletteIndex})}for(const r of e){const a=Number.isInteger(r.glyph)?r.glyph:r.glyph.index;s.push({glyphID:a,paletteIndex:r.paletteIndex})}for(let r=t;r<i.length;r++){const a=Number.isInteger(i[r].glyph)?i[r].glyph:i[r].glyph.index;s.push({glyphID:a,paletteIndex:i[r].paletteIndex})}this.updateColrTable(n,s)}setPaletteIndex(n,e,t){let i=this.get(n);i[e]?(i=i.map((s,r)=>({glyphID:s.glyph.index,paletteIndex:r===e?t:s.paletteIndex})),this.updateColrTable(n,i)):console.error("Invalid layer index")}remove(n,e,t=e){let i=this.get(n);i=i.map(s=>({glyphID:s.glyph.index,paletteIndex:s.paletteIndex})),i.splice(e,t-e+1),this.updateColrTable(n,i)}updateColrTable(n,e){this.ensureCOLR();const i=this.font.tables.colr;let s=Z2(i.baseGlyphRecords,"glyphID",n);if(s===-1){const u={glyphID:n,firstLayerIndex:i.layerRecords.length,numLayers:0};s=J2(i.baseGlyphRecords,"glyphID",u)}const a=i.baseGlyphRecords[s],o=a.numLayers,l=e.length,c=l-o;if(c>0){const u=e.slice(o).map(h=>({glyphID:h.glyphID,paletteIndex:h.paletteIndex}));i.layerRecords.splice(a.firstLayerIndex+o,0,...u)}else c<0&&i.layerRecords.splice(a.firstLayerIndex+l,-c);for(let u=0;u<Math.min(o,l);u++)i.layerRecords[a.firstLayerIndex+u]={glyphID:e[u].glyphID,paletteIndex:e[u].paletteIndex};if(a.numLayers=l,c!==0)for(let u=0;u<i.baseGlyphRecords.length;u++){const h=i.baseGlyphRecords[u];u===s||h.firstLayerIndex<a.firstLayerIndex||(i.baseGlyphRecords[u].firstLayerIndex+=c)}}},nM=class{constructor(n){this.font=n,this.cache=new WeakMap}get(n){const e=this.getOrCreateSvgImageCacheEntry(n);return e&&e.image}getAsync(n){const e=this.getOrCreateSvgImageCacheEntry(n);return e&&e.promise}getOrCreateSvgImageCacheEntry(n){const e=this.font.tables.svg;if(e===void 0)return;const t=e.get(n);if(t===void 0)return;let i=this.cache.get(t);i===void 0&&(i=iM(t),this.cache.set(t,i));let s=i.images.get(n);return s===void 0&&(s=sM(this.font,i.template,n),s.promise.then(r=>{if(s.image=r,typeof this.font.onGlyphUpdated=="function")try{this.font.onGlyphUpdated(n)}catch(a){console.error("font.onGlyphUpdated",n,a)}}),i.images.set(n,s)),s}};function iM(n){return{template:rM(n).then(lM),images:new Map}}function sM(n,e,t){return{promise:e.then(i=>{let s;typeof i=="string"?s=i:(i[4]=t,s=i.join(""));const r=cM(s,n.unitsPerEm);return r.image.decode().then(()=>r)}),image:void 0}}var rM=typeof DecompressionStream=="function"?oM:aM;function aM(n){try{return Promise.resolve(new TextDecoder().decode(y0(n)?j2(n):n))}catch(e){return Promise.reject(e)}}function oM(n){if(y0(n))return new Response(new Response(n).body.pipeThrough(new DecompressionStream("gzip"))).text();try{return Promise.resolve(new TextDecoder().decode(n))}catch(e){return Promise.reject(e)}}function lM(n){const e=n.indexOf("<svg"),t=n.indexOf(">",e+4)+1;if(/ id=['"]glyph\d+['"]/.test(n.substring(e,t)))return n;const i=n.lastIndexOf("</svg>");return[n.substring(0,t),"<defs>",n.substring(t,i),'</defs><use href="#glyph',"",'"/>',n.substring(i)]}function cM(n,e){const i=new DOMParser().parseFromString(n,"image/svg+xml").documentElement,s=i.viewBox.baseVal,r=i.width.baseVal,a=i.height.baseVal;let o=1,l=1;s.width>0&&s.height>0&&(r.unitType===1?(o=r.valueInSpecifiedUnits/s.width,l=a.unitType===1?a.valueInSpecifiedUnits/s.height:o):a.unitType===1?(l=a.valueInSpecifiedUnits/s.height,o=l):e&&(o=e/s.width,l=e/s.height));const c=document.createElement("div");c.style.position="fixed",c.style.visibility="hidden",c.appendChild(i),document.body.appendChild(c);const u=i.getBBox();document.body.removeChild(c);const h=(u.x-s.x)*o,d=(s.y-u.y)*l,f=u.width*o,p=u.height*l;i.setAttribute("viewBox",[u.x,u.y,u.width,u.height].join(" ")),o!==1&&i.setAttribute("width",f),l!==1&&i.setAttribute("height",p);const _=new Image(f,p);return _.src="data:image/svg+xml;charset=utf-8,"+encodeURIComponent(i.outerHTML),{leftSideBearing:h,baseline:d,image:_}}var Wl=new WeakMap;function Fd(n,e,t,i,s){let r;return(e&i)>0?(r=n.parseByte(),e&s||(r=-r),r=t+r):(e&s)>0?r=t:r=t+n.parseShort(),r}function S0(n,e,t){const i=new Ie.Parser(e,t);n._numberOfContours=i.parseShort(),n._xMin=i.parseShort(),n._yMin=i.parseShort(),n._xMax=i.parseShort(),n._yMax=i.parseShort();let s,r;if(n._numberOfContours>0){const a=n.endPointIndices=[];for(let l=0;l<n._numberOfContours;l+=1)a.push(i.parseUShort());n.instructionLength=i.parseUShort(),n.instructions=[];for(let l=0;l<n.instructionLength;l+=1)n.instructions.push(i.parseByte());const o=a[a.length-1]+1;s=[];for(let l=0;l<o;l+=1)if(r=i.parseByte(),s.push(r),(r&8)>0){const c=i.parseByte();for(let u=0;u<c;u+=1)s.push(r),l+=1}if(Ve.argument(s.length===o,"Bad flags."),a.length>0){const l=[];let c;if(o>0){for(let d=0;d<o;d+=1)r=s[d],c={},c.onCurve=!!(r&1),c.lastPointOfContour=a.indexOf(d)>=0,l.push(c);let u=0;for(let d=0;d<o;d+=1)r=s[d],c=l[d],c.x=Fd(i,r,u,2,16),u=c.x;let h=0;for(let d=0;d<o;d+=1)r=s[d],c=l[d],c.y=Fd(i,r,h,4,32),h=c.y}n.points=l}else n.points=[]}else if(n._numberOfContours===0)n.points=[];else{n.isComposite=!0,n.points=[],n.components=[];let a=!0;for(;a;){s=i.parseUShort();const o={glyphIndex:i.parseUShort(),xScale:1,scale01:0,scale10:0,yScale:1,dx:0,dy:0};(s&1)>0?(s&2)>0?(o.dx=i.parseShort(),o.dy=i.parseShort()):o.matchedPoints=[i.parseUShort(),i.parseUShort()]:(s&2)>0?(o.dx=i.parseChar(),o.dy=i.parseChar()):o.matchedPoints=[i.parseByte(),i.parseByte()],(s&8)>0?o.xScale=o.yScale=i.parseF2Dot14():(s&64)>0?(o.xScale=i.parseF2Dot14(),o.yScale=i.parseF2Dot14()):(s&128)>0&&(o.xScale=i.parseF2Dot14(),o.scale01=i.parseF2Dot14(),o.scale10=i.parseF2Dot14(),o.yScale=i.parseF2Dot14()),n.components.push(o),a=!!(s&32)}if(s&256){n.instructionLength=i.parseUShort(),n.instructions=[];for(let o=0;o<n.instructionLength;o+=1)n.instructions.push(i.parseByte())}}}function go(n,e){const t=[];for(let i=0;i<n.length;i+=1){const s=n[i],r={x:e.xScale*s.x+e.scale10*s.y+e.dx,y:e.scale01*s.x+e.yScale*s.y+e.dy,onCurve:s.onCurve,lastPointOfContour:s.lastPointOfContour};t.push(r)}return t}function uM(n){const e=[];let t=[];for(let i=0;i<n.length;i+=1){const s=n[i];t.push(s),s.lastPointOfContour&&(e.push(t),t=[])}return Ve.argument(t.length===0,"There are still points left in the current contour."),e}function Vu(n){const e=new cr;if(!n)return e;const t=uM(n);for(let i=0;i<t.length;++i){const s=t[i];let r=s[s.length-1],a=s[0];if(r.onCurve)e.moveTo(r.x,r.y);else if(a.onCurve)e.moveTo(a.x,a.y);else{const o={x:(r.x+a.x)*.5,y:(r.y+a.y)*.5};e.moveTo(o.x,o.y)}for(let o=0;o<s.length;++o)if(r=a,a=s[(o+1)%s.length],r.onCurve)e.lineTo(r.x,r.y);else{let l=a;a.onCurve||(l={x:(r.x+a.x)*.5,y:(r.y+a.y)*.5}),e.quadraticCurveTo(r.x,r.y,l.x,l.y)}e.closePath()}return e}function b0(n,e){if(e.isComposite){Wl.has(n)||Wl.set(n,new Set);const t=Wl.get(n);t.add(e.index);try{for(let i=0;i<e.components.length;i+=1){const s=e.components[i];if(t.has(s.glyphIndex))continue;const r=n.get(s.glyphIndex);if(r.getPath(),r.points){let a;if(s.matchedPoints===void 0)a=go(r.points,s);else{if(s.matchedPoints[0]>e.points.length-1||s.matchedPoints[1]>r.points.length-1)throw Error("Matched points out of range in "+e.name);const o=e.points[s.matchedPoints[0]];let l=r.points[s.matchedPoints[1]];const c={xScale:s.xScale,scale01:s.scale01,scale10:s.scale10,yScale:s.yScale,dx:0,dy:0};l=go([l],c)[0],c.dx=o.x-l.x,c.dy=o.y-l.y,a=go(r.points,c)}e.points=e.points.concat(a)}}}finally{t.delete(e.index)}}return Vu(e.points)}function hM(n,e,t,i){const s=new hi.GlyphSet(i);for(let r=0;r<t.length-1;r+=1){const a=t[r],o=t[r+1];a!==o?s.push(r,hi.ttfGlyphLoader(i,r,S0,n,e+a,b0)):s.push(r,hi.glyphLoader(i,r))}return s}function dM(n,e,t,i){const s=new hi.GlyphSet(i);return i._push=function(r){const a=t[r],o=t[r+1];a!==o?s.push(r,hi.ttfGlyphLoader(i,r,S0,n,e+a,b0)):s.push(r,hi.glyphLoader(i,r))},s}function fM(n,e,t,i,s){return s.lowMemory?dM(n,e,t,i):hM(n,e,t,i)}var M0={getPath:Vu,parse:fM},pM=class{constructor(n){this.font=n}normalizeCoordTags(n){for(const e in n)if(e.length<4){const t=e.padEnd(4," ");n[t]===void 0&&(n[t]=n[e]),delete n[e]}}getNormalizedCoords(n){n||(n=this.font.variation.get());let e=[];this.normalizeCoordTags(n);for(let t=0;t<this.fvar().axes.length;t++){const i=this.fvar().axes[t];let s=n[i.tag];s===void 0&&(s=i.defaultValue),s<i.defaultValue?e.push((s-i.defaultValue+Number.EPSILON)/(i.defaultValue-i.minValue+Number.EPSILON)):e.push((s-i.defaultValue+Number.EPSILON)/(i.maxValue-i.defaultValue+Number.EPSILON))}if(this.avar())for(let t=0;t<this.avar().axisSegmentMaps.length;t++){let i=this.avar().axisSegmentMaps[t];for(let s=0;s<i.axisValueMaps.length;s++){let r=i.axisValueMaps[s];if(s>=1&&e[t]<r.fromCoordinate){let a=i.axisValueMaps[s-1];e[t]=((e[t]-a.fromCoordinate)*(r.toCoordinate-a.toCoordinate)+Number.EPSILON)/(r.fromCoordinate-a.fromCoordinate+Number.EPSILON)+a.toCoordinate;break}}}return e}interpolatePoints(n,e,t){if(n.length===0)return;let i=0;for(;i<n.length;){let s=i,r=i,a=n[r];for(;!a.lastPointOfContour;)a=n[++r];for(;i<=r&&!t[i];)i++;if(i>r)continue;let o=i,l=i;for(i++;i<=r;)t[i]&&(this.deltaInterpolate(l+1,i-1,l,i,e,n),l=i),i++;l===o?this.deltaShift(s,r,l,e,n):(this.deltaInterpolate(l+1,r,l,o,e,n),o>0&&this.deltaInterpolate(s,o-1,l,o,e,n)),i=r+1}}deltaInterpolate(n,e,t,i,s,r){if(n>e)return;let a=["x","y"];for(let l=0;l<a.length;l++){let c=a[l];if(s[t][c]>s[i][c]){var o=t;t=i,i=o}let u=s[t][c],h=s[i][c],d=r[t][c],f=r[i][c];if(u!==h||d===f){let p=u===h?0:(f-d)/(h-u);for(let _=n;_<=e;_++){let m=s[_][c];m<=u?m+=d-u:m>=h?m+=f-h:m=d+(m-u)*p,r[_][c]=m}}}}deltaShift(n,e,t,i,s){let r=s[t].x-i[t].x,a=s[t].y-i[t].y;if(!(r===0&&a===0))for(let o=n;o<=e;o++)o!==t&&(s[o].x+=r,s[o].y+=a)}transformComponents(n,e,t,i,s,r){let a=0;for(let o=0;o<n.components.length;o++){const l=n.components[o],c=this.font.glyphs.get(l.glyphIndex),u=Q2(l),h=i.indexOf(o);h>-1&&(u.dx+=Math.round(s.deltas[h]*r),u.dy+=Math.round(s.deltasY[h]*r));const d=go(this.getTransform(c,t).points,u);e.splice(a,d.length,...d),a+=c.points.length}}applyTupleVariationStore(n,e,t,i="gvar",s={}){t||(t=this.font.variation.get());const r=this.getNormalizedCoords(t),{headers:a,sharedPoints:o}=n,l=this.fvar().axes.length;let c;i==="gvar"?c=e.map(kd):i==="cvar"&&(c=[...e]);for(let u=0;u<a.length;u++){const h=a[u];let d=1;for(let p=0;p<l;p++){let _=[0];switch(i){case"gvar":_=h.peakTuple?h.peakTuple:this.gvar().sharedTuples[h.sharedTupleRecordsIndex];break;case"cvar":_=h.peakTuple;break}if(_[p]!==0){if(r[p]===0){d=0;break}if(h.intermediateStartTuple)if(r[p]<h.intermediateStartTuple[p]||r[p]>h.intermediateEndTuple[p]){d=0;break}else r[p]<_[p]?d=d*(r[p]-h.intermediateStartTuple[p]+Number.EPSILON)/(_[p]-h.intermediateStartTuple[p]+Number.EPSILON):d=d*(h.intermediateEndTuple[p]-r[p]+Number.EPSILON)/(h.intermediateEndTuple[p]-_[p]+Number.EPSILON);else{if(r[p]<Math.min(0,_[p])||r[p]>Math.max(0,_[p])){d=0;break}d=(d*r[p]+Number.EPSILON)/(_[p]+Number.EPSILON)}}}if(d===0)continue;const f=h.privatePoints.length?h.privatePoints:o;if(i==="gvar"&&s.glyph&&s.glyph.isComposite)this.transformComponents(s.glyph,c,t,f,h,d);else if(f.length===0)for(let p=0;p<c.length;p++){const _=c[p];i==="gvar"?c[p]={x:Math.round(_.x+h.deltas[p]*d),y:Math.round(_.y+h.deltasY[p]*d),onCurve:_.onCurve,lastPointOfContour:_.lastPointOfContour}:i==="cvar"&&(c[p]=Math.round(_+h.deltas[p]*d))}else{let p;i==="gvar"?p=c.map(kd):i==="cvar"&&(p=c);const _=Array(e.length).fill(!1);for(let m=0;m<f.length;m++){let g=f[m];if(g<e.length){let v=p[g];i==="gvar"?(_[g]=!0,v.x+=h.deltas[m]*d,v.y+=h.deltasY[m]*d):i==="cvar"&&(c[g]=Math.round(v+h.deltas[m]*d))}}if(i==="gvar"){this.interpolatePoints(p,c,_);for(let m=0;m<e.length;m++){let g=p[m].x-c[m].x,v=p[m].y-c[m].y;c[m].x=Math.round(c[m].x+g),c[m].y=Math.round(c[m].y+v)}}}}return c}getTransform(n,e){Number.isInteger(n)&&(n=this.font.glyphs.get(n));const t=n.getBlendPath,i=!!(n.points&&n.points.length);let s=n;if(t||i){if(e||(e=this.font.variation.get()),i){const r=this.gvar()&&this.gvar().glyphVariations[n.index];if(r){const a=n.points;let o=this.applyTupleVariationStore(r,a,e,"gvar",{glyph:n});s=new Qr(Object.assign({},n,{points:o,path:Vu(o)}))}}else if(t){const r=n.getBlendPath(e);s=new Qr(Object.assign({},n,{path:r}))}}return this.font.tables.hvar&&(n._advanceWidth=typeof n._advanceWidth<"u"?n._advanceWidth:n.advanceWidth,n.advanceWidth=s.advanceWidth=Math.round(n._advanceWidth+this.getVariableAdjustment(s.index,"hvar","advanceWidth",e)),n._leftSideBearing=typeof n._leftSideBearing<"u"?n._leftSideBearing:n.leftSideBearing,n.leftSideBearing=s.leftSideBearing=Math.round(n._leftSideBearing+this.getVariableAdjustment(s.index,"hvar","lsb",e))),s}getCvarTransform(n){const e=this.font.tables.cvt,t=this.cvar();return!e||!e.length||!t||!t.headers.length?e:this.applyTupleVariationStore(t,e,n,"cvar")}getVariableAdjustment(n,e,t,i){i=i||this.font.variation.get();let s,r;const a=this.font.tables[e];if(!a)throw Error(`trying to get variation adjustment from non-existent table "${a}"`);if(!a.itemVariationStore)throw Error(`trying to get variation adjustment from table "${a}" which does not have an itemVariationStore`);const o=a[t]&&a[t].map.length;if(o){let l=n;l>=o&&(l=o-1),{outerIndex:s,innerIndex:r}=a[t].map[l]}else s=0,r=n;return this.getDelta(a.itemVariationStore,s,r,i)}getDelta(n,e,t,i){if(e>=n.itemVariationSubtables.length)return 0;let s=n.itemVariationSubtables[e];if(t>=s.deltaSets.length)return 0;let r=s.deltaSets[t],a=this.getBlendVector(n,e,i),o=0;for(let l=0;l<s.regionIndexes.length;l++)o+=r[l]*a[l];return o}getBlendVector(n,e,t){t||(t=this.font.variation.get());let i=n.itemVariationSubtables[e];const s=this.getNormalizedCoords(t);let r=[];for(let a=0;a<i.regionIndexes.length;a++){let o=1,l=i.regionIndexes[a],c=n.variationRegions[l].regionAxes;for(let u=0;u<c.length;u++){let h=c[u],d;h.startCoord>h.peakCoord||h.peakCoord>h.endCoord||h.startCoord<0&&h.endCoord>0&&h.peakCoord!==0||h.peakCoord===0?d=1:s[u]<h.startCoord||s[u]>h.endCoord?d=0:s[u]===h.peakCoord?d=1:s[u]<h.peakCoord?d=(s[u]-h.startCoord+Number.EPSILON)/(h.peakCoord-h.startCoord+Number.EPSILON):d=(h.endCoord-s[u]+Number.EPSILON)/(h.endCoord-h.peakCoord+Number.EPSILON),o*=d}r[a]=o}return r}avar(){return this.font.tables.avar}cvar(){return this.font.tables.cvar}fvar(){return this.font.tables.fvar}gvar(){return this.font.tables.gvar}hvar(){return this.font.tables.hvar}},mM=class{constructor(n){this.font=n,this.process=new pM(this.font),this.activateDefaultVariation(),this.getTransform=this.process.getTransform.bind(this.process)}activateDefaultVariation(){const n=this.getDefaultInstanceIndex();n>-1?this.set(n):this.set(this.getDefaultCoordinates())}getDefaultCoordinates(){return this.fvar().axes.reduce((n,e)=>(n[e.tag]=e.defaultValue,n),{})}getDefaultInstanceIndex(){const n=this.getDefaultCoordinates();let e=this.getInstanceIndex(n);return e<0&&(e=this.fvar().instances.findIndex(t=>t.name&&t.name.en==="Regular")),e}getInstanceIndex(n){return this.fvar().instances.findIndex(e=>Object.keys(n).every(t=>e.coordinates[t]===n[t]))}getInstance(n){return this.fvar().instances&&this.fvar().instances[n]}set(n){let e;if(Number.isInteger(n)){const t=this.getInstance(n);if(!t)throw Error(`Invalid instance index ${n}`);e={...t.coordinates}}else e=n,this.process.normalizeCoordTags(e);e=Object.assign({},this.font.defaultRenderOptions.variation,e),this.font.defaultRenderOptions=Object.assign({},this.font.defaultRenderOptions,{variation:e})}get(){return Object.assign({},this.font.defaultRenderOptions.variation)}avar(){return this.font.tables.avar}cvar(){return this.font.tables.cvar}fvar(){return this.font.tables.fvar}gvar(){return this.font.tables.gvar}hvar(){return this.font.tables.hvar}},Bd=1e6,Bo=64,Ho=1e4,A0,ys,E0,au;function T0(n){this.font=n,this.getCommands=function(e){return M0.getPath(e).commands},this._fpgmState=this._prepState=void 0,this._errorState=0}function gM(n){return n}function C0(n){return Math.sign(n)*Math.round(Math.abs(n))}function _M(n){return Math.sign(n)*Math.round(Math.abs(n*2))/2}function xM(n){return Math.sign(n)*(Math.round(Math.abs(n)+.5)-.5)}function yM(n){return Math.sign(n)*Math.ceil(Math.abs(n))}function vM(n){return Math.sign(n)*Math.floor(Math.abs(n))}var w0=function(n){const e=this.srPeriod;let t=this.srPhase;const i=this.srThreshold;let s=1;return n<0&&(n=-n,s=-1),n+=i-t,n=Math.trunc(n/e)*e,n+=t,n<0?t*s:n*s},oi={x:1,y:0,axis:"x",distance:function(n,e,t,i){return(t?n.xo:n.x)-(i?e.xo:e.x)},interpolate:function(n,e,t,i){let s,r,a,o,l,c,u;if(!i||i===this){if(s=n.xo-e.xo,r=n.xo-t.xo,l=e.x-e.xo,c=t.x-t.xo,a=Math.abs(s),o=Math.abs(r),u=a+o,u===0){n.x=n.xo+(l+c)/2;return}n.x=n.xo+(l*o+c*a)/u;return}if(s=i.distance(n,e,!0,!0),r=i.distance(n,t,!0,!0),l=i.distance(e,e,!1,!0),c=i.distance(t,t,!1,!0),a=Math.abs(s),o=Math.abs(r),u=a+o,u===0){oi.setRelative(n,n,(l+c)/2,i,!0);return}oi.setRelative(n,n,(l*o+c*a)/u,i,!0)},normalSlope:Number.NEGATIVE_INFINITY,setRelative:function(n,e,t,i,s){if(!i||i===this){n.x=(s?e.xo:e.x)+t;return}const r=s?e.xo:e.x,a=s?e.yo:e.y,o=r+t*i.x,l=a+t*i.y;n.x=o+(n.y-l)/i.normalSlope},slope:0,touch:function(n){n.xTouched=!0},touched:function(n){return n.xTouched},untouch:function(n){n.xTouched=!1}},bi={x:0,y:1,axis:"y",distance:function(n,e,t,i){return(t?n.yo:n.y)-(i?e.yo:e.y)},interpolate:function(n,e,t,i){let s,r,a,o,l,c,u;if(!i||i===this){if(s=n.yo-e.yo,r=n.yo-t.yo,l=e.y-e.yo,c=t.y-t.yo,a=Math.abs(s),o=Math.abs(r),u=a+o,u===0){n.y=n.yo+(l+c)/2;return}n.y=n.yo+(l*o+c*a)/u;return}if(s=i.distance(n,e,!0,!0),r=i.distance(n,t,!0,!0),l=i.distance(e,e,!1,!0),c=i.distance(t,t,!1,!0),a=Math.abs(s),o=Math.abs(r),u=a+o,u===0){bi.setRelative(n,n,(l+c)/2,i,!0);return}bi.setRelative(n,n,(l*o+c*a)/u,i,!0)},normalSlope:0,setRelative:function(n,e,t,i,s){if(!i||i===this){n.y=(s?e.yo:e.y)+t;return}const r=s?e.xo:e.x,a=s?e.yo:e.y,o=r+t*i.x,l=a+t*i.y;n.y=l+i.normalSlope*(n.x-o)},slope:Number.POSITIVE_INFINITY,touch:function(n){n.yTouched=!0},touched:function(n){return n.yTouched},untouch:function(n){n.yTouched=!1}};Object.freeze(oi);Object.freeze(bi);function oa(n,e){this.x=n,this.y=e,this.axis=void 0,this.slope=e/n,this.normalSlope=-n/e,Object.freeze(this)}oa.prototype.distance=function(n,e,t,i){return this.x*oi.distance(n,e,t,i)+this.y*bi.distance(n,e,t,i)};oa.prototype.interpolate=function(n,e,t,i){let s,r,a,o,l,c,u;if(a=i.distance(n,e,!0,!0),o=i.distance(n,t,!0,!0),s=i.distance(e,e,!1,!0),r=i.distance(t,t,!1,!0),l=Math.abs(a),c=Math.abs(o),u=l+c,u===0){this.setRelative(n,n,(s+r)/2,i,!0);return}this.setRelative(n,n,(s*c+r*l)/u,i,!0)};oa.prototype.setRelative=function(n,e,t,i,s){i=i||this;const r=s?e.xo:e.x,a=s?e.yo:e.y,o=r+t*i.x,l=a+t*i.y,c=i.normalSlope,u=this.slope,h=n.x,d=n.y;n.x=(u*h-c*o+l-d)/(u-c),n.y=u*(n.x-h)+d};oa.prototype.touch=function(n){n.xTouched=!0,n.yTouched=!0};function la(n,e){const t=Math.sqrt(n*n+e*e);return n/=t,e/=t,n===1&&e===0?oi:n===0&&e===1?bi:new oa(n,e)}function Ti(n,e,t,i){this.x=this.xo=Math.round(n*64)/64,this.y=this.yo=Math.round(e*64)/64,this.lastPointOfContour=t,this.onCurve=i,this.prevPointOnContour=void 0,this.nextPointOnContour=void 0,this.xTouched=!1,this.yTouched=!1,Object.preventExtensions(this)}Ti.prototype.nextTouched=function(n){let e=this.nextPointOnContour;for(;!n.touched(e)&&e!==this;)e=e.nextPointOnContour;return e};Ti.prototype.prevTouched=function(n){let e=this.prevPointOnContour;for(;!n.touched(e)&&e!==this;)e=e.prevPointOnContour;return e};var ea=Object.freeze(new Ti(0,0)),SM={cvCutIn:17/16,deltaBase:9,deltaShift:.125,loop:1,minDis:1,autoFlip:!0};function qi(n,e){switch(this.env=n,this.stack=[],this.prog=e,n){case"glyf":this.zp0=this.zp1=this.zp2=1,this.rp0=this.rp1=this.rp2=0;case"prep":this.fv=this.pv=this.dpv=oi,this.round=C0}}T0.prototype.exec=function(n,e){if(typeof e!="number")throw new Error("Point size is not a number!");if(this._errorState>2)return;const t=this.font;let i=this._prepState;if(!i||i.ppem!==e){let s=this._fpgmState;if(!s){qi.prototype=SM,s=this._fpgmState=new qi("fpgm",t.tables.fpgm),s.funcs=[],s.font=t,s.instructionCount=0,s.callDepth=0;try{ys(s)}catch(a){console.log("Hinting error in FPGM:"+a),this._errorState=3;return}}qi.prototype=s,i=this._prepState=new qi("prep",t.tables.prep),i.ppem=e,i.instructionCount=0,i.callDepth=0;const r=t.variation&&t.variation.process.getCvarTransform()||t.tables.cvt;if(r){const a=i.cvt=new Array(r.length),o=e/t.unitsPerEm;for(let l=0;l<r.length;l++)a[l]=r[l]*o}else i.cvt=[];try{ys(i)}catch(a){this._errorState<2&&console.log("Hinting error in PREP:"+a),this._errorState=2}}if(!(this._errorState>1))try{return E0(n,i)}catch(s){this._errorState<1&&(console.log("Hinting error:"+s),console.log("Note: further hinting errors are silenced")),this._errorState=1;return}};E0=function(n,e){const t=e.ppem/e.font.unitsPerEm,i=t;let s=n.components,r,a,o;if(qi.prototype=e,!s)o=new qi("glyf",n.instructions),o.instructionCount=0,o.callDepth=0,au(n,o,t,i),a=o.gZone;else{const l=e.font;a=[],r=[];for(let c=0;c<s.length;c++){const u=s[c],h=l.glyphs.get(u.glyphIndex);o=new qi("glyf",h.instructions),o.instructionCount=0,o.callDepth=0,au(h,o,t,i);const d=Math.round(u.dx*t),f=Math.round(u.dy*i),p=o.gZone,_=o.contours;for(let g=0;g<p.length;g++){const v=p[g];v.xTouched=v.yTouched=!1,v.xo=v.x=v.x+d,v.yo=v.y=v.y+f}const m=a.length;a.push.apply(a,p);for(let g=0;g<_.length;g++)r.push(_[g]+m)}n.instructions&&!o.inhibitGridFit&&(o=new qi("glyf",n.instructions),o.gZone=o.z0=o.z1=o.z2=a,o.contours=r,a.push(new Ti(0,0),new Ti(Math.round(n.advanceWidth*t),0)),ys(o),a.length-=2)}return a};au=function(n,e,t,i){const s=n.points||[],r=s.length,a=e.gZone=e.z0=e.z1=e.z2=[],o=e.contours=[];let l;for(let h=0;h<r;h++)l=s[h],a[h]=new Ti(l.x*t,l.y*i,l.lastPointOfContour,l.onCurve);let c,u;for(let h=0;h<r;h++)l=a[h],c||(c=l,o.push(h)),l.lastPointOfContour?(l.nextPointOnContour=c,c.prevPointOnContour=l,c=void 0):(u=a[h+1],l.nextPointOnContour=u,u.prevPointOnContour=l);e.inhibitGridFit||(a.push(new Ti(0,0),new Ti(Math.round(n.advanceWidth*t),0)),ys(e),a.length-=2)};ys=function(n){let e=n.prog;if(!e)return;const t=e.length;let i;for(n.ip=0;n.ip<t;n.ip++){if(++n.instructionCount>Bd)throw new Error("Hinting instructions exceeded maximum of "+Bd);if(i=A0[e[n.ip]],!i)throw new Error("unknown instruction: 0x"+Number(e[n.ip]).toString(16));i(n)}};function $o(n){const e=n.tZone=new Array(n.gZone.length);for(let t=0;t<e.length;t++)e[t]=new Ti(0,0)}function R0(n,e){const t=n.prog;let i=n.ip,s=1,r;do if(r=t[++i],r===88)s++;else if(r===89)s--;else if(r===64)i+=t[i+1]+1;else if(r===65)i+=2*t[i+1]+1;else if(r>=176&&r<=183)i+=r-176+1;else if(r>=184&&r<=191)i+=(r-184+1)*2;else if(e&&s===1&&r===27)break;while(s>0);n.ip=i}function Hd(n,e){e.fv=e.pv=e.dpv=n}function zd(n,e){e.pv=e.dpv=n}function Vd(n,e){e.fv=n}function Gd(n,e){const t=e.stack,i=t.pop(),s=t.pop(),r=e.z2[i],a=e.z1[s];let o,l;n?(o=r.y-a.y,l=a.x-r.x):(o=a.x-r.x,l=a.y-r.y),e.pv=e.dpv=la(o,l)}function Wd(n,e){const t=e.stack,i=t.pop(),s=t.pop(),r=e.z2[i],a=e.z1[s];let o,l;n?(o=r.y-a.y,l=a.x-r.x):(o=a.x-r.x,l=a.y-r.y),e.fv=la(o,l)}function bM(n){const e=n.stack,t=e.pop(),i=e.pop();n.pv=n.dpv=la(i,t)}function MM(n){const e=n.stack,t=e.pop(),i=e.pop();n.fv=la(i,t)}function AM(n){const e=n.stack,t=n.pv;e.push(t.x*16384),e.push(t.y*16384)}function EM(n){const e=n.stack,t=n.fv;e.push(t.x*16384),e.push(t.y*16384)}function TM(n){n.fv=n.pv}function CM(n){const e=n.stack,t=e.pop(),i=e.pop(),s=e.pop(),r=e.pop(),a=e.pop(),o=n.z0,l=n.z1,c=o[t],u=o[i],h=l[s],d=l[r],f=n.z2[a],p=c.x,_=c.y,m=u.x,g=u.y,v=h.x,b=h.y,x=d.x,E=d.y,S=(p-m)*(b-E)-(_-g)*(v-x),A=p*g-_*m,y=v*E-b*x;f.x=(A*(v-x)-y*(p-m))/S,f.y=(A*(b-E)-y*(_-g))/S}function wM(n){n.rp0=n.stack.pop()}function RM(n){n.rp1=n.stack.pop()}function LM(n){n.rp2=n.stack.pop()}function DM(n){const e=n.stack.pop();switch(n.zp0=e,e){case 0:n.tZone||$o(n),n.z0=n.tZone;break;case 1:n.z0=n.gZone;break;default:throw new Error("Invalid zone pointer")}}function IM(n){const e=n.stack.pop();switch(n.zp1=e,e){case 0:n.tZone||$o(n),n.z1=n.tZone;break;case 1:n.z1=n.gZone;break;default:throw new Error("Invalid zone pointer")}}function PM(n){const e=n.stack.pop();switch(n.zp2=e,e){case 0:n.tZone||$o(n),n.z2=n.tZone;break;case 1:n.z2=n.gZone;break;default:throw new Error("Invalid zone pointer")}}function OM(n){const e=n.stack.pop();switch(n.zp0=n.zp1=n.zp2=e,e){case 0:n.tZone||$o(n),n.z0=n.z1=n.z2=n.tZone;break;case 1:n.z0=n.z1=n.z2=n.gZone;break;default:throw new Error("Invalid zone pointer")}}function UM(n){n.loop=n.stack.pop(),n.loop>Ho&&(n.loop=Ho)}function NM(n){n.round=C0}function kM(n){n.round=xM}function FM(n){const e=n.stack.pop();n.minDis=e/64}function BM(n){R0(n,!1)}function HM(n){const e=n.stack.pop();n.ip+=e-1}function zM(n){const e=n.stack.pop();n.cvCutIn=e/64}function VM(n){const e=n.stack;e.push(e[e.length-1])}function Xl(n){n.stack.pop()}function GM(n){n.stack.length=0}function WM(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(t),e.push(i)}function XM(n){const e=n.stack;e.push(e.length)}function YM(n){const e=n.stack,t=e.pop();let i=e.pop();if(i>Ho&&(i=Ho),++n.callDepth>Bo)throw new Error("Hinting call depth exceeded maximum of "+Bo);const s=n.ip,r=n.prog;n.prog=n.funcs[t];for(let a=0;a<i;a++)ys(n);n.ip=s,n.prog=r,n.callDepth--}function KM(n){const e=n.stack.pop();if(++n.callDepth>Bo)throw new Error("Hinting call depth exceeded maximum of "+Bo);const t=n.ip,i=n.prog;n.prog=n.funcs[e],ys(n),n.ip=t,n.prog=i,n.callDepth--}function qM(n){const e=n.stack,t=e.pop();e.push(e[e.length-t])}function $M(n){const e=n.stack,t=e.pop();e.push(e.splice(e.length-t,1)[0])}function ZM(n){if(n.env!=="fpgm")throw new Error("FDEF not allowed here");const e=n.stack,t=n.prog;let i=n.ip;const s=e.pop(),r=i;for(;t[++i]!==45;);n.ip=i,n.funcs[s]=t.slice(r+1,i)}function Xd(n,e){const t=e.stack.pop(),i=e.z0[t],s=e.fv,r=e.pv;let a=r.distance(i,ea);n&&(a=e.round(a)),s.setRelative(i,ea,a,r),s.touch(i),e.rp0=e.rp1=t}function Yd(n,e){const t=e.z2,i=t.length-2;let s,r,a;for(let o=0;o<i;o++)s=t[o],!n.touched(s)&&(r=s.prevTouched(n),r!==s&&(a=s.nextTouched(n),r===a&&n.setRelative(s,s,n.distance(r,r,!1,!0),n,!0),n.interpolate(s,r,a,n)))}function Kd(n,e){const t=e.stack,i=n?e.rp1:e.rp2,s=(n?e.z0:e.z1)[i],r=e.fv,a=e.pv;let o=e.loop;const l=e.z2;for(;o--;){const c=t.pop(),u=l[c],h=a.distance(s,s,!1,!0);r.setRelative(u,u,h,a),r.touch(u)}e.loop=1}function qd(n,e){const t=e.stack,i=n?e.rp1:e.rp2,s=(n?e.z0:e.z1)[i],r=e.fv,a=e.pv,o=t.pop(),l=e.z2[e.contours[o]];let c=l;const u=a.distance(s,s,!1,!0);do c!==s&&r.setRelative(c,c,u,a),c=c.nextPointOnContour;while(c!==l)}function $d(n,e){const t=e.stack,i=n?e.rp1:e.rp2,s=(n?e.z0:e.z1)[i],r=e.fv,a=e.pv,o=t.pop();let l;switch(o){case 0:l=e.tZone;break;case 1:l=e.gZone;break;default:throw new Error("Invalid zone")}let c;const u=a.distance(s,s,!1,!0),h=l.length-2;for(let d=0;d<h;d++)c=l[d],r.setRelative(c,c,u,a)}function JM(n){const e=n.stack;let t=n.loop;const i=n.fv,s=e.pop()/64,r=n.z2;for(;t--;){const a=e.pop(),o=r[a];i.setRelative(o,o,s),i.touch(o)}n.loop=1}function jM(n){const e=n.stack,t=n.rp1,i=n.rp2;let s=n.loop;const r=n.z0[t],a=n.z1[i],o=n.fv,l=n.dpv,c=n.z2;for(;s--;){const u=e.pop(),h=c[u];o.interpolate(h,r,a,l),o.touch(h)}n.loop=1}function Zd(n,e){const t=e.stack,i=t.pop()/64,s=t.pop(),r=e.z1[s],a=e.z0[e.rp0],o=e.fv,l=e.pv;o.setRelative(r,a,i,l),o.touch(r),e.rp1=e.rp0,e.rp2=s,n&&(e.rp0=s)}function QM(n){const e=n.stack,t=n.rp0,i=n.z0[t];let s=n.loop;const r=n.fv,a=n.pv,o=n.z1;for(;s--;){const l=e.pop(),c=o[l];r.setRelative(c,i,0,a),r.touch(c)}n.loop=1}function e3(n){n.round=_M}function Jd(n,e){const t=e.stack,i=t.pop(),s=t.pop(),r=e.z0[s],a=e.fv,o=e.pv;let l=e.cvt[i],c=o.distance(r,ea);n&&(Math.abs(c-l)<e.cvCutIn&&(c=l),c=e.round(c)),a.setRelative(r,ea,c,o),e.zp0===0&&(r.xo=r.x,r.yo=r.y),a.touch(r),e.rp0=e.rp1=s}function t3(n){const e=n.prog;let t=n.ip;const i=n.stack,s=e[++t];for(let r=0;r<s;r++)i.push(e[++t]);n.ip=t}function n3(n){let e=n.ip;const t=n.prog,i=n.stack,s=t[++e];for(let r=0;r<s;r++){let a=t[++e]<<8|t[++e];a&32768&&(a=-((a^65535)+1)),i.push(a)}n.ip=e}function i3(n){const e=n.stack;let t=n.store;t||(t=n.store=[]);const i=e.pop(),s=e.pop();t[s]=i}function s3(n){const e=n.stack,t=n.store,i=e.pop(),s=t&&t[i]||0;e.push(s)}function r3(n){const e=n.stack,t=e.pop(),i=e.pop();n.cvt[i]=t/64}function a3(n){const e=n.stack,t=e.pop();e.push(n.cvt[t]*64)}function jd(n,e){const t=e.stack,i=t.pop(),s=e.z2[i];t.push(e.dpv.distance(s,ea,n,!1)*64)}function Qd(n,e){const t=e.stack,i=t.pop(),s=t.pop(),r=e.z1[i],a=e.z0[s],o=e.dpv.distance(a,r,n,n);e.stack.push(Math.round(o*64))}function o3(n){n.stack.push(n.ppem)}function l3(n){n.autoFlip=!0}function c3(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(i<t?1:0)}function u3(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(i<=t?1:0)}function h3(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(i>t?1:0)}function d3(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(i>=t?1:0)}function f3(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(t===i?1:0)}function p3(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(t!==i?1:0)}function m3(n){const e=n.stack,t=e.pop();e.push(Math.trunc(t)&1?1:0)}function g3(n){const e=n.stack,t=e.pop();e.push(Math.trunc(t)&1?0:1)}function _3(n){n.stack.pop()||R0(n,!0)}function x3(n){}function y3(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(t&&i?1:0)}function v3(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(t||i?1:0)}function S3(n){const e=n.stack,t=e.pop();e.push(t?0:1)}function Yl(n,e){const t=e.stack,i=t.pop(),s=e.fv,r=e.pv,a=e.ppem,o=e.deltaBase+(n-1)*16,l=e.deltaShift,c=e.z0;for(let u=0;u<i;u++){const h=t.pop(),d=t.pop();if(o+((d&240)>>4)!==a)continue;let p=(d&15)-8;p>=0&&p++;const _=c[h];s.setRelative(_,_,p*l,r)}}function b3(n){const t=n.stack.pop();n.deltaBase=t}function M3(n){const t=n.stack.pop();n.deltaShift=Math.pow(.5,t)}function A3(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(i+t)}function E3(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(i-t)}function T3(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(i*64/t)}function C3(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(i*t/64)}function w3(n){const e=n.stack,t=e.pop();e.push(Math.abs(t))}function R3(n){const e=n.stack;let t=e.pop();e.push(-t)}function L3(n){const e=n.stack,t=e.pop();e.push(Math.floor(t/64)*64)}function D3(n){const e=n.stack,t=e.pop();e.push(Math.ceil(t/64)*64)}function to(n,e){const t=e.stack,i=t.pop();t.push(e.round(i/64)*64)}function I3(n){const e=n.stack,t=e.pop(),i=e.pop();n.cvt[i]=t*n.ppem/n.font.unitsPerEm}function Kl(n,e){const t=e.stack,i=t.pop(),s=e.ppem,r=e.deltaBase+(n-1)*16,a=e.deltaShift;for(let o=0;o<i;o++){const l=t.pop(),c=t.pop();if(r+((c&240)>>4)!==s)continue;let h=(c&15)-8;h>=0&&h++;const d=h*a;e.cvt[l]+=d}}function P3(n){let e=n.stack.pop();n.round=w0;let t;switch(e&192){case 0:t=.5;break;case 64:t=1;break;case 128:t=2;break;default:throw new Error("invalid SROUND value")}switch(n.srPeriod=t,e&48){case 0:n.srPhase=0;break;case 16:n.srPhase=.25*t;break;case 32:n.srPhase=.5*t;break;case 48:n.srPhase=.75*t;break;default:throw new Error("invalid SROUND value")}e&=15,e===0?n.srThreshold=0:n.srThreshold=(e/8-.5)*t}function O3(n){let e=n.stack.pop();n.round=w0;let t;switch(e&192){case 0:t=Math.sqrt(2)/2;break;case 64:t=Math.sqrt(2);break;case 128:t=2*Math.sqrt(2);break;default:throw new Error("invalid S45ROUND value")}switch(n.srPeriod=t,e&48){case 0:n.srPhase=0;break;case 16:n.srPhase=.25*t;break;case 32:n.srPhase=.5*t;break;case 48:n.srPhase=.75*t;break;default:throw new Error("invalid S45ROUND value")}e&=15,e===0?n.srThreshold=0:n.srThreshold=(e/8-.5)*t}function U3(n){n.round=gM}function N3(n){n.round=yM}function k3(n){n.round=vM}function F3(n){n.stack.pop()}function ef(n,e){const t=e.stack,i=t.pop(),s=t.pop(),r=e.z2[i],a=e.z1[s];let o,l;n?(o=r.y-a.y,l=a.x-r.x):(o=a.x-r.x,l=a.y-r.y),e.dpv=la(o,l)}function B3(n){const e=n.stack,t=e.pop();let i=0;t&1&&(i=35),t&32&&(i|=4096),e.push(i)}function H3(n){const e=n.stack,t=e.pop(),i=e.pop(),s=e.pop();e.push(i),e.push(t),e.push(s)}function z3(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(Math.max(i,t))}function V3(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(Math.min(i,t))}function G3(n){n.stack.pop()}function W3(n){const e=n.stack.pop();let t=n.stack.pop();switch(e){case 1:n.inhibitGridFit=!!t;return;case 2:n.ignoreCvt=!!t;return;default:throw new Error("invalid INSTCTRL[] selector")}}function Hi(n,e){const t=e.stack,i=e.prog;let s=e.ip;for(let r=0;r<n;r++)t.push(i[++s]);e.ip=s}function zi(n,e){let t=e.ip;const i=e.prog,s=e.stack;for(let r=0;r<n;r++){let a=i[++t]<<8|i[++t];a&32768&&(a=-((a^65535)+1)),s.push(a)}e.ip=t}function ze(n,e,t,i,s,r){const a=r.stack,o=n&&a.pop(),l=a.pop(),c=r.rp0,u=r.z0[c],h=r.z1[l],d=r.minDis,f=r.fv,p=r.dpv;let _,m,g;_=p.distance(h,u,!0,!0),m=_>=0?1:-1,_=Math.abs(_),n&&(g=r.cvt[o],i&&Math.abs(_-g)<r.cvCutIn&&(_=g)),t&&_<d&&(_=d),i&&(_=r.round(_)),f.setRelative(h,u,m*_,p),f.touch(h),r.rp1=r.rp0,r.rp2=l,e&&(r.rp0=l)}A0=[Hd.bind(void 0,bi),Hd.bind(void 0,oi),zd.bind(void 0,bi),zd.bind(void 0,oi),Vd.bind(void 0,bi),Vd.bind(void 0,oi),Gd.bind(void 0,0),Gd.bind(void 0,1),Wd.bind(void 0,0),Wd.bind(void 0,1),bM,MM,AM,EM,TM,CM,wM,RM,LM,DM,IM,PM,OM,UM,NM,kM,FM,BM,HM,zM,void 0,void 0,VM,Xl,GM,WM,XM,qM,$M,void 0,void 0,void 0,YM,KM,ZM,void 0,Xd.bind(void 0,0),Xd.bind(void 0,1),Yd.bind(void 0,bi),Yd.bind(void 0,oi),Kd.bind(void 0,0),Kd.bind(void 0,1),qd.bind(void 0,0),qd.bind(void 0,1),$d.bind(void 0,0),$d.bind(void 0,1),JM,jM,Zd.bind(void 0,0),Zd.bind(void 0,1),QM,e3,Jd.bind(void 0,0),Jd.bind(void 0,1),t3,n3,i3,s3,r3,a3,jd.bind(void 0,0),jd.bind(void 0,1),void 0,Qd.bind(void 0,0),Qd.bind(void 0,1),o3,void 0,l3,void 0,void 0,c3,u3,h3,d3,f3,p3,m3,g3,_3,x3,y3,v3,S3,Yl.bind(void 0,1),b3,M3,A3,E3,T3,C3,w3,R3,L3,D3,to.bind(void 0,0),to.bind(void 0,1),to.bind(void 0,2),to.bind(void 0,3),void 0,void 0,void 0,void 0,I3,Yl.bind(void 0,2),Yl.bind(void 0,3),Kl.bind(void 0,1),Kl.bind(void 0,2),Kl.bind(void 0,3),P3,O3,void 0,void 0,U3,void 0,N3,k3,Xl,Xl,void 0,void 0,void 0,void 0,void 0,F3,ef.bind(void 0,0),ef.bind(void 0,1),B3,void 0,H3,z3,V3,G3,W3,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,Hi.bind(void 0,1),Hi.bind(void 0,2),Hi.bind(void 0,3),Hi.bind(void 0,4),Hi.bind(void 0,5),Hi.bind(void 0,6),Hi.bind(void 0,7),Hi.bind(void 0,8),zi.bind(void 0,1),zi.bind(void 0,2),zi.bind(void 0,3),zi.bind(void 0,4),zi.bind(void 0,5),zi.bind(void 0,6),zi.bind(void 0,7),zi.bind(void 0,8),ze.bind(void 0,0,0,0,0,0),ze.bind(void 0,0,0,0,0,1),ze.bind(void 0,0,0,0,0,2),ze.bind(void 0,0,0,0,0,3),ze.bind(void 0,0,0,0,1,0),ze.bind(void 0,0,0,0,1,1),ze.bind(void 0,0,0,0,1,2),ze.bind(void 0,0,0,0,1,3),ze.bind(void 0,0,0,1,0,0),ze.bind(void 0,0,0,1,0,1),ze.bind(void 0,0,0,1,0,2),ze.bind(void 0,0,0,1,0,3),ze.bind(void 0,0,0,1,1,0),ze.bind(void 0,0,0,1,1,1),ze.bind(void 0,0,0,1,1,2),ze.bind(void 0,0,0,1,1,3),ze.bind(void 0,0,1,0,0,0),ze.bind(void 0,0,1,0,0,1),ze.bind(void 0,0,1,0,0,2),ze.bind(void 0,0,1,0,0,3),ze.bind(void 0,0,1,0,1,0),ze.bind(void 0,0,1,0,1,1),ze.bind(void 0,0,1,0,1,2),ze.bind(void 0,0,1,0,1,3),ze.bind(void 0,0,1,1,0,0),ze.bind(void 0,0,1,1,0,1),ze.bind(void 0,0,1,1,0,2),ze.bind(void 0,0,1,1,0,3),ze.bind(void 0,0,1,1,1,0),ze.bind(void 0,0,1,1,1,1),ze.bind(void 0,0,1,1,1,2),ze.bind(void 0,0,1,1,1,3),ze.bind(void 0,1,0,0,0,0),ze.bind(void 0,1,0,0,0,1),ze.bind(void 0,1,0,0,0,2),ze.bind(void 0,1,0,0,0,3),ze.bind(void 0,1,0,0,1,0),ze.bind(void 0,1,0,0,1,1),ze.bind(void 0,1,0,0,1,2),ze.bind(void 0,1,0,0,1,3),ze.bind(void 0,1,0,1,0,0),ze.bind(void 0,1,0,1,0,1),ze.bind(void 0,1,0,1,0,2),ze.bind(void 0,1,0,1,0,3),ze.bind(void 0,1,0,1,1,0),ze.bind(void 0,1,0,1,1,1),ze.bind(void 0,1,0,1,1,2),ze.bind(void 0,1,0,1,1,3),ze.bind(void 0,1,1,0,0,0),ze.bind(void 0,1,1,0,0,1),ze.bind(void 0,1,1,0,0,2),ze.bind(void 0,1,1,0,0,3),ze.bind(void 0,1,1,0,1,0),ze.bind(void 0,1,1,0,1,1),ze.bind(void 0,1,1,0,1,2),ze.bind(void 0,1,1,0,1,3),ze.bind(void 0,1,1,1,0,0),ze.bind(void 0,1,1,1,0,1),ze.bind(void 0,1,1,1,0,2),ze.bind(void 0,1,1,1,0,3),ze.bind(void 0,1,1,1,1,0),ze.bind(void 0,1,1,1,1,1),ze.bind(void 0,1,1,1,1,2),ze.bind(void 0,1,1,1,1,3)];var X3=T0;function _r(n){this.char=n,this.state={},this.activeState=null}function Gu(n,e,t){this.contextName=t,this.startIndex=n,this.endOffset=e}function Y3(n,e,t){this.contextName=n,this.openRange=null,this.ranges=[],this.checkStart=e,this.checkEnd=t}function dn(n,e){this.context=n,this.index=e,this.length=n.length,this.current=n[e],this.backtrack=n.slice(0,e),this.lookahead=n.slice(e+1)}function Zo(n){this.eventId=n,this.subscribers=[]}function K3(n){const e=["start","end","next","newToken","contextStart","contextEnd","insertToken","removeToken","removeRange","replaceToken","replaceRange","composeRUD","updateContextsRanges"];for(let i=0;i<e.length;i++){const s=e[i];Object.defineProperty(this.events,s,{value:new Zo(s)})}if(n)for(let i=0;i<e.length;i++){const s=e[i],r=n[s];typeof r=="function"&&this.events[s].subscribe(r)}const t=["insertToken","removeToken","removeRange","replaceToken","replaceRange","composeRUD"];for(let i=0;i<t.length;i++){const s=t[i];this.events[s].subscribe(this.updateContextsRanges)}}function Pt(n){this.tokens=[],this.registeredContexts={},this.contextCheckers=[],this.events={},this.registeredModifiers=[],K3.call(this,n)}_r.prototype.setState=function(n,e){return this.state[n]=e,this.activeState={key:n,value:this.state[n]},this.activeState};_r.prototype.getState=function(n){return this.state[n]||null};Pt.prototype.inboundIndex=function(n){return n>=0&&n<this.tokens.length};Pt.prototype.composeRUD=function(n){const t=n.map(s=>this[s[0]].apply(this,s.slice(1).concat(!0))),i=s=>typeof s=="object"&&Object.prototype.hasOwnProperty.call(s,"FAIL");if(t.every(i))return{FAIL:"composeRUD: one or more operations hasn't completed successfully",report:t.filter(i)};this.dispatch("composeRUD",[t.filter(s=>!i(s))])};Pt.prototype.replaceRange=function(n,e,t,i){e=e!==null?e:this.tokens.length;const s=t.every(r=>r instanceof _r);if(!isNaN(n)&&this.inboundIndex(n)&&s){const r=this.tokens.splice.apply(this.tokens,[n,e].concat(t));return i||this.dispatch("replaceToken",[n,e,t]),[r,t]}else return{FAIL:"replaceRange: invalid tokens or startIndex."}};Pt.prototype.replaceToken=function(n,e,t){if(!isNaN(n)&&this.inboundIndex(n)&&e instanceof _r){const i=this.tokens.splice(n,1,e);return t||this.dispatch("replaceToken",[n,e]),[i[0],e]}else return{FAIL:"replaceToken: invalid token or index."}};Pt.prototype.removeRange=function(n,e,t){e=isNaN(e)?this.tokens.length:e;const i=this.tokens.splice(n,e);return t||this.dispatch("removeRange",[i,n,e]),i};Pt.prototype.removeToken=function(n,e){if(!isNaN(n)&&this.inboundIndex(n)){const t=this.tokens.splice(n,1);return e||this.dispatch("removeToken",[t,n]),t}else return{FAIL:"removeToken: invalid token index."}};Pt.prototype.insertToken=function(n,e,t){return n.every(s=>s instanceof _r)?(this.tokens.splice.apply(this.tokens,[e,0].concat(n)),t||this.dispatch("insertToken",[n,e]),n):{FAIL:"insertToken: invalid token(s)."}};Pt.prototype.registerModifier=function(n,e,t){this.events.newToken.subscribe(function(i,s){const r=[i,s],a=e===null||e.apply(this,r)===!0,o=[i,s];if(a){let l=t.apply(this,o);i.setState(n,l)}}),this.registeredModifiers.push(n)};Zo.prototype.subscribe=function(n){return typeof n=="function"?this.subscribers.push(n)-1:{FAIL:`invalid '${this.eventId}' event handler`}};Zo.prototype.unsubscribe=function(n){this.subscribers.splice(n,1)};dn.prototype.setCurrentIndex=function(n){this.index=n,this.current=this.context[n],this.backtrack=this.context.slice(0,n),this.lookahead=this.context.slice(n+1)};dn.prototype.get=function(n){switch(!0){case n===0:return this.current;case(n<0&&Math.abs(n)<=this.backtrack.length):return this.backtrack.slice(n)[0];case(n>0&&n<=this.lookahead.length):return this.lookahead[n-1];default:return null}};Pt.prototype.rangeToText=function(n){if(n instanceof Gu)return this.getRangeTokens(n).map(e=>e.char).join("")};Pt.prototype.getText=function(){return this.tokens.map(n=>n.char).join("")};Pt.prototype.getContext=function(n){let e=this.registeredContexts[n];return e||null};Pt.prototype.on=function(n,e){const t=this.events[n];return t?t.subscribe(e):null};Pt.prototype.dispatch=function(n,e){const t=this.events[n];if(t instanceof Zo)for(let i=0;i<t.subscribers.length;i++)t.subscribers[i].apply(this,e||[])};Pt.prototype.registerContextChecker=function(n,e,t){if(this.getContext(n))return{FAIL:`context name '${n}' is already registered.`};if(typeof e!="function")return{FAIL:"missing context start check."};if(typeof t!="function")return{FAIL:"missing context end check."};const i=new Y3(n,e,t);return this.registeredContexts[n]=i,this.contextCheckers.push(i),i};Pt.prototype.getRangeTokens=function(n){const e=n.startIndex+n.endOffset;return[].concat(this.tokens.slice(n.startIndex,e))};Pt.prototype.getContextRanges=function(n){const e=this.getContext(n);return e?e.ranges:{FAIL:`context checker '${n}' is not registered.`}};Pt.prototype.resetContextsRanges=function(){const n=this.registeredContexts;for(const e in n)if(Object.prototype.hasOwnProperty.call(n,e)){const t=n[e];t.ranges=[]}};Pt.prototype.updateContextsRanges=function(){this.resetContextsRanges();const n=this.tokens.map(e=>e.char);for(let e=0;e<n.length;e++){const t=new dn(n,e);this.runContextCheck(t)}this.dispatch("updateContextsRanges",[this.registeredContexts])};Pt.prototype.setEndOffset=function(n,e){const t=this.getContext(e).openRange.startIndex;let i=new Gu(t,n,e);const s=this.getContext(e).ranges;return i.rangeId=`${e}.${s.length}`,s.push(i),this.getContext(e).openRange=null,i};Pt.prototype.runContextCheck=function(n){const e=n.index;for(let t=0;t<this.contextCheckers.length;t++){const i=this.contextCheckers[t];let s=i.contextName,r=this.getContext(s).openRange;if(!r&&i.checkStart(n)&&(r=new Gu(e,null,s),this.getContext(s).openRange=r,this.dispatch("contextStart",[s,e])),r&&i.checkEnd(n)){const a=e-r.startIndex+1,o=this.setEndOffset(a,s);this.dispatch("contextEnd",[s,o])}}};Pt.prototype.tokenize=function(n){this.tokens=[],this.resetContextsRanges();let e=Array.from(n);this.dispatch("start");for(let t=0;t<e.length;t++){const i=e[t],s=new dn(e,t);this.dispatch("next",[s]),this.runContextCheck(s);let r=new _r(i);this.tokens.push(r),this.dispatch("newToken",[r,s])}return this.dispatch("end",[this.tokens]),this.tokens};var q3=Pt;function $i(n){return/[\u0600-\u065F\u066A-\u06D2\u06FA-\u06FF]/.test(n)}function L0(n){return/[\u0630\u0690\u0621\u0631\u0661\u0671\u0622\u0632\u0672\u0692\u06C2\u0623\u0673\u0693\u06C3\u0624\u0694\u06C4\u0625\u0675\u0695\u06C5\u06E5\u0676\u0696\u06C6\u0627\u0677\u0697\u06C7\u0648\u0688\u0698\u06C8\u0689\u0699\u06C9\u068A\u06CA\u066B\u068B\u06CB\u068C\u068D\u06CD\u06FD\u068E\u06EE\u06FE\u062F\u068F\u06CF\u06EF]/.test(n)}function ji(n){return/[\u0600-\u0605\u060C-\u060E\u0610-\u061B\u061E\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED]/.test(n)}function _o(n){return/[\u0E00-\u0E7F]/.test(n)}function xo(n){return/[A-z]/.test(n)}function $3(n){return/\s/.test(n)}function Mn(n){this.font=n,this.features={}}function Gi(n){this.id=n.id,this.tag=n.tag,this.substitution=n.substitution}function Qi(n,e){if(!n)return-1;switch(e.format){case 1:return e.glyphs.indexOf(n);case 2:{let t=e.ranges;for(let i=0;i<t.length;i++){const s=t[i];if(n>=s.start&&n<=s.end){let r=n-s.start;return s.index+r}}break}default:return-1}return-1}function Z3(n,e){return Qi(n,e.coverage)===-1?null:n+e.deltaGlyphId}function J3(n,e){let t=Qi(n,e.coverage);return t===-1?null:e.substitute[t]}function ql(n,e){let t=[];for(let i=0;i<n.length;i++){const s=n[i];let r=e.current;r=Array.isArray(r)?r[0]:r;const a=Qi(r,s);a!==-1&&t.push(a)}return t.length!==n.length?-1:t}function j3(n,e){const t=e.inputCoverage.length+e.lookaheadCoverage.length+e.backtrackCoverage.length;if(n.context.length<t)return[];let i=ql(e.inputCoverage,n);if(i===-1)return[];const s=e.inputCoverage.length-1;if(n.lookahead.length<e.lookaheadCoverage.length)return[];let r=n.lookahead.slice(s);for(;r.length&&ji(r[0].char);)r.shift();const a=new dn(r,0);let o=ql(e.lookaheadCoverage,a),l=[].concat(n.backtrack);for(l.reverse();l.length&&ji(l[0].char);)l.shift();if(l.length<e.backtrackCoverage.length)return[];const c=new dn(l,0);let u=ql(e.backtrackCoverage,c);const h=i.length===e.inputCoverage.length&&o.length===e.lookaheadCoverage.length&&u.length===e.backtrackCoverage.length;let d=[];if(h)for(let f=0;f<e.lookupRecords.length;f++){const p=e.lookupRecords[f],_=p.lookupListIndex,m=this.getLookupByIndex(_);for(let g=0;g<m.subtables.length;g++){let v=m.subtables[g],b,x=this.getSubstitutionType(m,v);if(x==="71"?(x=this.getSubstitutionType(v,v.extension),b=this.getLookupMethod(v,v.extension),v=v.extension):b=this.getLookupMethod(m,v),x==="12"){const E=n.get(p.sequenceIndex),S=b(E);S&&d.push(S)}else if(x==="21"){const E=n.get(p.sequenceIndex),S=b(E);S&&d.push(S)}else throw new Error(`Substitution type ${x} is not supported in chaining substitution`)}}return d}function Q3(n,e){let t=n.current,i=Qi(t,e.coverage);if(i===-1)return null;let s,r=e.ligatureSets[i];for(let a=0;a<r.length;a++){s=r[a];for(let o=0;o<s.components.length;o++){const l=n.lookahead[o],c=s.components[o];if(l!==c)break;if(o===s.components.length-1)return s}}return null}function eA(n,e){let t=n.current;if(Qi(t,e.coverage)===-1)return null;for(const s of e.ruleSets)for(const r of s){let a=!0;for(let o=0;o<r.input.length;o++)if(n.lookahead[o]!==r.input[o]){a=!1;break}if(a){let o=[];o.push(t);for(let c=0;c<r.input.length;c++)o.push(r.input[c]);const l=(c,u)=>{const{lookupListIndex:h,sequenceIndex:d}=u,{subtables:f}=this.getLookupByIndex(h);for(const p of f)Qi(c[d],p.coverage)!==-1&&(c[d]=p.deltaGlyphId)};for(let c=0;c<r.lookupRecords.length;c++){const u=r.lookupRecords[c];l(o,u)}return o}}return null}function tA(n,e){if(n.context.length<e.coverages.length)return[];for(let i=0;i<e.coverages.length;i++){let s=n.get(i);if(s=Array.isArray(s)?s[0]:s,Qi(s,e.coverages[i])===-1)return[]}let t=[];for(let i=0;i<e.lookupRecords.length;i++){const s=e.lookupRecords[i],r=s.lookupListIndex,a=this.getLookupByIndex(r);for(let o=0;o<a.subtables.length;o++){let l=a.subtables[o],c,u=this.getSubstitutionType(a,l);if(u==="71"?(u=this.getSubstitutionType(l,l.extension),c=this.getLookupMethod(l,l.extension),l=l.extension):c=this.getLookupMethod(a,l),u==="12"){const h=n.get(s.sequenceIndex),d=c(h);d&&t.push(d)}else if(u==="21"){const h=n.get(s.sequenceIndex),d=c(h);d&&t.push(d)}}}return t}function nA(n,e){let t=Qi(n,e.coverage);return t===-1?null:e.sequences[t]}Mn.prototype.getDefaultScriptFeaturesIndexes=function(){const n=this.font.tables.gsub.scripts;for(let e=0;e<n.length;e++){const t=n[e];if(t.tag==="DFLT")return t.script.defaultLangSys.featureIndexes}return[]};Mn.prototype.getScriptFeaturesIndexes=function(n){if(!this.font.tables.gsub)return[];if(!n)return this.getDefaultScriptFeaturesIndexes();const t=this.font.tables.gsub.scripts;for(let i=0;i<t.length;i++){const s=t[i];if(s.tag===n&&s.script.defaultLangSys)return s.script.defaultLangSys.featureIndexes;{let r=s.langSysRecords;if(r)for(let a=0;a<r.length;a++){const o=r[a];if(o.tag===n)return o.langSys.featureIndexes}}}return this.getDefaultScriptFeaturesIndexes()};Mn.prototype.mapTagsToFeatures=function(n,e){let t={};for(let i=0;i<n.length;i++){const s=n[i].tag,r=n[i].feature;t[s]=r}this.features[e].tags=t};Mn.prototype.getScriptFeatures=function(n){let e=this.features[n];if(Object.prototype.hasOwnProperty.call(this.features,n))return e;const t=this.getScriptFeaturesIndexes(n);if(!t)return null;const i=this.font.tables.gsub;return e=t.map(s=>i.features[s]),this.features[n]=e,this.mapTagsToFeatures(e,n),e};Mn.prototype.getSubstitutionType=function(n,e){const t=n.lookupType.toString(),i=e.substFormat.toString();return t+i};Mn.prototype.getLookupMethod=function(n,e){let t=this.getSubstitutionType(n,e);switch(t){case"11":return i=>Z3.apply(this,[i,e]);case"12":return i=>J3.apply(this,[i,e]);case"63":return i=>j3.apply(this,[i,e]);case"41":return i=>Q3.apply(this,[i,e]);case"21":return i=>nA.apply(this,[i,e]);case"51":return i=>eA.apply(this,[i,e]);case"53":return i=>tA.apply(this,[i,e]);default:throw new Error(`substitutionType : ${t} lookupType: ${n.lookupType} - substFormat: ${e.substFormat} is not yet supported`)}};Mn.prototype.lookupFeature=function(n){let e=n.contextParams,t=e.index;const i=this.getFeature({tag:n.tag,script:n.script});if(!i)return new Error(`font '${(this.font.names.unicode||this.font.names.windows||this.font.names.macintosh).fullName.en}' doesn't support feature '${n.tag}' for script '${n.script}'.`);const s=this.getFeatureLookups(i),r=[].concat(e.context);for(let a=0;a<s.length;a++){const o=s[a],l=this.getLookupSubtables(o);for(let c=0;c<l.length;c++){let u=l[c],h=this.getSubstitutionType(o,u),d;h==="71"?(h=this.getSubstitutionType(u,u.extension),d=this.getLookupMethod(u,u.extension),u=u.extension):d=this.getLookupMethod(o,u);let f;switch(h){case"11":f=d(e.current),f&&r.splice(t,1,new Gi({id:11,tag:n.tag,substitution:f}));break;case"12":f=d(e.current),f&&r.splice(t,1,new Gi({id:12,tag:n.tag,substitution:f}));break;case"63":f=d(e),Array.isArray(f)&&f.length&&r.splice(t,1,new Gi({id:63,tag:n.tag,substitution:f}));break;case"41":f=d(e),f&&r.splice(t,1,new Gi({id:41,tag:n.tag,substitution:f}));break;case"21":f=d(e.current),f&&r.splice(t,1,new Gi({id:21,tag:n.tag,substitution:f}));break;case"51":case"53":f=d(e),Array.isArray(f)&&f.length&&r.splice(t,1,new Gi({id:parseInt(h),tag:n.tag,substitution:f}));break}e=new dn(r,t),!(Array.isArray(f)&&!f.length)&&(f=null)}}return r.length?r:null};Mn.prototype.supports=function(n){if(!n.script)return!1;this.getScriptFeatures(n.script);const e=Object.prototype.hasOwnProperty.call(this.features,n.script);if(!n.tag)return e;const t=this.features[n.script].some(i=>i.tag===n.tag);return e&&t};Mn.prototype.getLookupSubtables=function(n){return n.subtables||null};Mn.prototype.getLookupByIndex=function(n){return this.font.tables.gsub.lookups[n]||null};Mn.prototype.getFeatureLookups=function(n){return n.lookupListIndexes.map(this.getLookupByIndex.bind(this))};Mn.prototype.getFeature=function(e){if(!this.font)return{FAIL:"No font was found"};Object.prototype.hasOwnProperty.call(this.features,e.script)||this.getScriptFeatures(e.script);const t=this.features[e.script];return t?t.tags[e.tag]?this.features[e.script].tags[e.tag]:null:{FAIL:`No feature for script ${e.script}`}};var iA=Mn;function sA(n){const e=n.current,t=n.get(-1);return t===null&&$i(e)||!$i(t)&&$i(e)}function rA(n){const e=n.get(1);return e===null||!$i(e)}var aA={startCheck:sA,endCheck:rA};function oA(n){const e=n.current,t=n.get(-1);return($i(e)||ji(e))&&!$i(t)}function lA(n){const e=n.get(1);switch(!0){case e===null:return!0;case(!$i(e)&&!ji(e)):{const t=$3(e);if(!t)return!0;if(t){let i=!1;if(i=n.lookahead.some(s=>$i(s)||ji(s)),!i)return!0}break}default:return!1}}var cA={startCheck:oA,endCheck:lA};function uA(n,e,t){e[t].setState(n.tag,n.substitution)}function hA(n,e,t){e[t].setState(n.tag,n.substitution)}function $l(n,e,t){for(let i=0;i<n.substitution.length;i++){const s=n.substitution[i],r=e[t+i];if(Array.isArray(s)){s.length?r.setState(n.tag,s[0]):r.setState("deleted",!0);continue}r.setState(n.tag,s)}}function dA(n,e,t){let i=e[t];i.setState(n.tag,n.substitution.ligGlyph);const s=n.substitution.components.length;for(let r=0;r<s;r++)i=e[t+r+1],i.setState("deleted",!0)}var tf={11:uA,12:hA,63:$l,41:dA,51:$l,53:$l};function fA(n,e,t){n instanceof Gi&&tf[n.id]&&tf[n.id](n,e,t)}var Ms=fA;function pA(n){let e=[].concat(n.backtrack);for(let t=e.length-1;t>=0;t--){const i=e[t],s=L0(i),r=ji(i);if(!s&&!r)return!0;if(s)return!1}return!1}function mA(n){if(L0(n.current))return!1;for(let e=0;e<n.lookahead.length;e++){const t=n.lookahead[e];if(!ji(t))return!0}return!1}function gA(n){const e="arab",t=this.featuresTags[e],i=this.tokenizer.getRangeTokens(n);if(i.length===1)return;let s=new dn(i.map(a=>a.getState("glyphIndex")),0);const r=new dn(i.map(a=>a.char),0);for(let a=0;a<i.length;a++){const o=i[a];if(ji(o.char))continue;s.setCurrentIndex(a),r.setCurrentIndex(a);let l=0;pA(r)&&(l|=1),mA(r)&&(l|=2);let c;switch(l){case 1:c="fina";break;case 2:c="init";break;case 3:c="medi";break}if(t.indexOf(c)===-1)continue;let u=this.query.lookupFeature({tag:c,script:e,contextParams:s});if(u instanceof Error){console.info(u.message);continue}for(let h=0;h<u.length;h++){const d=u[h];d instanceof Gi&&(Ms(d,i,h),s.context[h]=d.substitution)}}}var _A=gA;function nf(n,e){const t=n.map(i=>i.activeState.value);return new dn(t,0)}function xA(n){const e="arab";let t=this.tokenizer.getRangeTokens(n),i=nf(t);for(let s=0;s<i.context.length;s++){i.setCurrentIndex(s);let r=this.query.lookupFeature({tag:"rlig",script:e,contextParams:i});if(r.length){for(let a=0;a<r.length;a++){const o=r[a];Ms(o,t,s)}i=nf(t)}}}var yA=xA;function vA(n){return n.index===0&&n.context.length>1}function SA(n){return n.index===n.context.length-1}var bA={startCheck:vA,endCheck:SA};function sf(n,e){const t=n.map(i=>i.activeState.value);return new dn(t,0)}function MA(n){const e="delf",t="ccmp";let i=this.tokenizer.getRangeTokens(n),s=sf(i);for(let r=0;r<s.context.length;r++){if(!this.query.getFeature({tag:t,script:e,contextParams:s}))continue;s.setCurrentIndex(r);let a=this.query.lookupFeature({tag:t,script:e,contextParams:s});if(a.length){for(let o=0;o<a.length;o++){const l=a[o];Ms(l,i,r)}s=sf(i)}}}var AA=MA;function EA(n){const e=n.current,t=n.get(-1);return t===null&&xo(e)||!xo(t)&&xo(e)}function TA(n){const e=n.get(1);return e===null||!xo(e)}var CA={startCheck:EA,endCheck:TA};function rf(n,e){const t=n.map(i=>i.activeState.value);return new dn(t,0)}function wA(n){const e="latn";let t=this.tokenizer.getRangeTokens(n),i=rf(t);for(let s=0;s<i.context.length;s++){i.setCurrentIndex(s);let r=this.query.lookupFeature({tag:"liga",script:e,contextParams:i});if(r.length){for(let a=0;a<r.length;a++){const o=r[a];Ms(o,t,s)}i=rf(t)}}}var RA=wA;function LA(n){const e=n.current,t=n.get(-1);return t===null&&_o(e)||!_o(t)&&_o(e)}function DA(n){const e=n.get(1);return e===null||!_o(e)}var IA={startCheck:LA,endCheck:DA};function af(n,e){const t=n.map(i=>i.activeState.value);return new dn(t,e||0)}function PA(n){const e="thai";let t=this.tokenizer.getRangeTokens(n),i=af(t,0);for(let s=0;s<i.context.length;s++){i.setCurrentIndex(s);let r=this.query.lookupFeature({tag:"ccmp",script:e,contextParams:i});if(r.length){for(let a=0;a<r.length;a++){const o=r[a];Ms(o,t,s)}i=af(t,s)}}}var OA=PA;function of(n,e){const t=n.map(i=>i.activeState.value);return new dn(t,e||0)}function UA(n){const e="thai";let t=this.tokenizer.getRangeTokens(n),i=of(t,0);for(let s=0;s<i.context.length;s++){i.setCurrentIndex(s);let r=this.query.lookupFeature({tag:"liga",script:e,contextParams:i});if(r.length){for(let a=0;a<r.length;a++){const o=r[a];Ms(o,t,s)}i=of(t,s)}}}var NA=UA;function lf(n,e){const t=n.map(i=>i.activeState.value);return new dn(t,e||0)}function kA(n){const e="thai";let t=this.tokenizer.getRangeTokens(n),i=lf(t,0);for(let s=0;s<i.context.length;s++){i.setCurrentIndex(s);let r=this.query.lookupFeature({tag:"rlig",script:e,contextParams:i});if(r.length){for(let a=0;a<r.length;a++){const o=r[a];Ms(o,t,s)}i=lf(t,s)}}}var FA=kA;function ou(n){if(n===null)return!1;const e=n.codePointAt(0);return e>=6155&&e<=6157||e>=65024&&e<=65039||e>=917760&&e<=917999}function BA(n){const e=n.current,t=n.get(1);return t===null&&ou(e)||ou(t)}function HA(n){const e=n.get(1);return e===null||!ou(e)}var zA={startCheck:BA,endCheck:HA};function VA(n){const e=this.query.font,t=this.tokenizer.getRangeTokens(n);if(t[1].setState("deleted",!0),e.tables.cmap&&e.tables.cmap.varSelectorList){const i=t[0].char.codePointAt(0),s=t[1].char.codePointAt(0),r=e.tables.cmap.varSelectorList[s];if(r!==void 0&&r.nonDefaultUVS){const a=r.nonDefaultUVS.uvsMappings;if(a[i]){const o=a[i].glyphID;e.glyphs.glyphs[o]!==void 0&&t[0].setState("glyphIndex",o)}}}}var GA=VA;function Pn(n){this.baseDir=n||"ltr",this.tokenizer=new q3,this.featuresTags={}}Pn.prototype.setText=function(n){this.text=n};Pn.prototype.contextChecks={ccmpReplacementCheck:bA,latinWordCheck:CA,arabicWordCheck:aA,arabicSentenceCheck:cA,thaiWordCheck:IA,unicodeVariationSequenceCheck:zA};function $s(n){const e=this.contextChecks[`${n}Check`];return this.tokenizer.registerContextChecker(n,e.startCheck,e.endCheck)}function WA(){return $s.call(this,"ccmpReplacement"),$s.call(this,"latinWord"),$s.call(this,"arabicWord"),$s.call(this,"arabicSentence"),$s.call(this,"thaiWord"),$s.call(this,"unicodeVariationSequence"),this.tokenizer.tokenize(this.text)}function XA(){const n=this.tokenizer.getContextRanges("arabicSentence");for(let e=0;e<n.length;e++){const t=n[e];let i=this.tokenizer.getRangeTokens(t);this.tokenizer.replaceRange(t.startIndex,t.endOffset,i.reverse())}}Pn.prototype.registerFeatures=function(n,e){const t=e.filter(i=>this.query.supports({script:n,tag:i}));Object.prototype.hasOwnProperty.call(this.featuresTags,n)?this.featuresTags[n]=this.featuresTags[n].concat(t):this.featuresTags[n]=t};Pn.prototype.applyFeatures=function(n,e){if(!n)throw new Error("No valid font was provided to apply features");this.query||(this.query=new iA(n));for(let t=0;t<e.length;t++){const i=e[t];this.query.supports({script:i.script})&&this.registerFeatures(i.script,i.tags)}};Pn.prototype.registerModifier=function(n,e,t){this.tokenizer.registerModifier(n,e,t)};function ca(){if(this.tokenizer.registeredModifiers.indexOf("glyphIndex")===-1)throw new Error("glyphIndex modifier is required to apply arabic presentation features.")}function YA(){if(!Object.prototype.hasOwnProperty.call(this.featuresTags,"arab"))return;ca.call(this);const e=this.tokenizer.getContextRanges("arabicWord");for(let t=0;t<e.length;t++){const i=e[t];_A.call(this,i)}}function KA(){ca.call(this);const n=this.tokenizer.getContextRanges("ccmpReplacement");for(let e=0;e<n.length;e++){const t=n[e];AA.call(this,t)}}function qA(){if(!this.hasFeatureEnabled("arab","rlig"))return;ca.call(this);const n=this.tokenizer.getContextRanges("arabicWord");for(let e=0;e<n.length;e++){const t=n[e];yA.call(this,t)}}function $A(){if(!this.hasFeatureEnabled("latn","liga"))return;ca.call(this);const n=this.tokenizer.getContextRanges("latinWord");for(let e=0;e<n.length;e++){const t=n[e];RA.call(this,t)}}function ZA(){const n=this.tokenizer.getContextRanges("unicodeVariationSequence");for(let e=0;e<n.length;e++){const t=n[e];GA.call(this,t)}}function JA(){ca.call(this);const n=this.tokenizer.getContextRanges("thaiWord");for(let e=0;e<n.length;e++){const t=n[e];this.hasFeatureEnabled("thai","liga")&&NA.call(this,t),this.hasFeatureEnabled("thai","rlig")&&FA.call(this,t),this.hasFeatureEnabled("thai","ccmp")&&OA.call(this,t)}}Pn.prototype.checkContextReady=function(n){return!!this.tokenizer.getContext(n)};Pn.prototype.applyFeaturesToContexts=function(){this.checkContextReady("ccmpReplacement")&&KA.call(this),this.checkContextReady("arabicWord")&&(YA.call(this),qA.call(this)),this.checkContextReady("latinWord")&&$A.call(this),this.checkContextReady("arabicSentence")&&XA.call(this),this.checkContextReady("thaiWord")&&JA.call(this),this.checkContextReady("unicodeVariationSequence")&&ZA.call(this)};Pn.prototype.hasFeatureEnabled=function(n,e){return(this.featuresTags[n]||[]).indexOf(e)!==-1};Pn.prototype.processText=function(n){(!this.text||this.text!==n)&&(this.setText(n),WA.call(this),this.applyFeaturesToContexts())};Pn.prototype.getBidiText=function(n){return this.processText(n),this.tokenizer.getText()};Pn.prototype.getTextGlyphs=function(n){this.processText(n);let e=[];for(let t=0;t<this.tokenizer.tokens.length;t++){const i=this.tokenizer.tokens[t];if(i.state.deleted)continue;const s=i.activeState.value;e.push(Array.isArray(s)?s[0]:s)}return e};var jA=Pn;function Zl(n){return{fontFamily:{en:n.familyName||" "},fontSubfamily:{en:n.styleName||" "},fullName:{en:n.fullName||n.familyName+" "+n.styleName},postScriptName:{en:n.postScriptName||(n.familyName+n.styleName).replace(/\s/g,"")},designer:{en:n.designer||" "},designerURL:{en:n.designerURL||" "},manufacturer:{en:n.manufacturer||" "},manufacturerURL:{en:n.manufacturerURL||" "},license:{en:n.license||" "},licenseURL:{en:n.licenseURL||" "},version:{en:n.version||"Version 0.1"},description:{en:n.description||" "},copyright:{en:n.copyright||" "},trademark:{en:n.trademark||" "}}}function vt(n){if(n=n||{},n.tables=n.tables||{},!n.empty){if(!n.familyName)throw new Error("When creating a new Font object, familyName is required.");if(!n.styleName)throw new Error("When creating a new Font object, styleName is required.");if(!n.unitsPerEm)throw new Error("When creating a new Font object, unitsPerEm is required.");if(!n.ascender)throw new Error("When creating a new Font object, ascender is required.");if(n.descender>0)throw new Error("When creating a new Font object, negative descender value is required.");this.names={},this.names.unicode=Zl(n),this.names.macintosh=Zl(n),this.names.windows=Zl(n),this.unitsPerEm=n.unitsPerEm||1e3,this.ascender=n.ascender,this.descender=n.descender,this.createdTimestamp=n.createdTimestamp,this.italicAngle=n.italicAngle||0,this.weightClass=n.weightClass||0;let e=0;n.fsSelection?e=n.fsSelection:(this.italicAngle<0?e|=this.fsSelectionValues.ITALIC:this.italicAngle>0&&(e|=this.fsSelectionValues.OBLIQUE),this.weightClass>=600&&(e|=this.fsSelectionValues.BOLD),e===0&&(e=this.fsSelectionValues.REGULAR)),(!n.panose||!Array.isArray(n.panose))&&(n.panose=[0,0,0,0,0,0,0,0,0]),this.tables=Object.assign(n.tables,{os2:Object.assign({usWeightClass:n.weightClass||this.usWeightClasses.MEDIUM,usWidthClass:n.widthClass||this.usWidthClasses.MEDIUM,bFamilyType:n.panose[0]||0,bSerifStyle:n.panose[1]||0,bWeight:n.panose[2]||0,bProportion:n.panose[3]||0,bContrast:n.panose[4]||0,bStrokeVariation:n.panose[5]||0,bArmStyle:n.panose[6]||0,bLetterform:n.panose[7]||0,bMidline:n.panose[8]||0,bXHeight:n.panose[9]||0,fsSelection:e},n.tables.os2)})}this.supported=!0,this.glyphs=new hi.GlyphSet(this,n.glyphs||[]),this.encoding=new Gp(this),this.position=new K2(this),this.substitution=new eM(this),this.tables=this.tables||{},this.tables=new Proxy(this.tables,{set:(e,t,i)=>(e[t]=i,e.fvar&&(e.gvar||e.cff2)&&!this.variation&&(this.variation=new mM(this)),!0)}),this.palettes=new v0(this),this.layers=new tM(this),this.svgImages=new nM(this),this._push=null,this._hmtxTableData={},Object.defineProperty(this,"hinting",{get:function(){return this._hinting?this._hinting:this.outlinesFormat==="truetype"?this._hinting=new X3(this):null}})}vt.prototype.hasChar=function(n){return this.encoding.charToGlyphIndex(n)>0};vt.prototype.charToGlyphIndex=function(n){return this.encoding.charToGlyphIndex(n)};vt.prototype.charToGlyph=function(n){const e=this.charToGlyphIndex(n);let t=this.glyphs.get(e);return t||(t=this.glyphs.get(0)),t};vt.prototype.updateFeatures=function(n){return this.defaultRenderOptions.features.map(e=>e.script==="latn"?{script:"latn",tags:e.tags.filter(t=>n[t])}:e)};vt.prototype.stringToGlyphIndexes=function(n,e){const t=new jA,i=r=>this.charToGlyphIndex(r.char);t.registerModifier("glyphIndex",null,i);let s=e?this.updateFeatures(e.features):this.defaultRenderOptions.features;return t.applyFeatures(this,s),t.getTextGlyphs(n)};vt.prototype.stringToGlyphs=function(n,e){const t=this.stringToGlyphIndexes(n,e);let i=t.length;const s=new Array(i),r=this.glyphs.get(0);for(let a=0;a<i;a+=1)s[a]=this.glyphs.get(t[a])||r;return s};vt.prototype.nameToGlyphIndex=function(n){return this.glyphNames.nameToGlyphIndex(n)};vt.prototype.nameToGlyph=function(n){const e=this.nameToGlyphIndex(n);let t=this.glyphs.get(e);return t||(t=this.glyphs.get(0)),t};vt.prototype.glyphIndexToName=function(n){return this.glyphNames.glyphIndexToName?this.glyphNames.glyphIndexToName(n):""};vt.prototype.getKerningValue=function(n,e){n=n.index||n,e=e.index||e;const t=this.position.defaultKerningTables;return t?this.position.getKerningValue(t,n,e):this.kerningPairs[n+","+e]||0};vt.prototype.defaultRenderOptions={kerning:!0,features:[{script:"arab",tags:["init","medi","fina","rlig"]},{script:"latn",tags:["liga","rlig"]},{script:"thai",tags:["liga","rlig","ccmp"]}],hinting:!1,usePalette:0,drawLayers:!0,drawSVG:!0};vt.prototype.forEachGlyph=function(n,e,t,i,s,r){e=e!==void 0?e:0,t=t!==void 0?t:0,i=i!==void 0?i:72,s=Object.assign({},this.defaultRenderOptions,s);const a=1/this.unitsPerEm*i,o=this.stringToGlyphs(n,s);let l;if(s.kerning){const c=s.script||this.position.getDefaultScriptName();l=this.position.getKerningTables(c,s.language)}for(let c=0;c<o.length;c+=1){const u=o[c];if(r.call(this,u,e,t,i,s),u.advanceWidth&&(e+=u.advanceWidth*a),s.kerning&&c<o.length-1){const h=l?this.position.getKerningValue(l,u.index,o[c+1].index):this.getKerningValue(u,o[c+1]);e+=h*a}s.letterSpacing?e+=s.letterSpacing*i:s.tracking&&(e+=s.tracking/1e3*i)}return e};vt.prototype.getPath=function(n,e,t,i,s){s=Object.assign({},this.defaultRenderOptions,s);const r=new cr;if(r._layers=[],jp(this,r),r.stroke){const a=1/(r.unitsPerEm||1e3)*i;r.strokeWidth*=a}return this.forEachGlyph(n,e,t,i,s,(a,o,l,c)=>{const u=a.getPath(o,l,c,s,this);if(s.drawSVG||s.drawLayers){const h=u._layers;if(h&&h.length){for(let d=0;d<h.length;d++){const f=h[d];r._layers.push(f)}return}}r.extend(u)}),r};vt.prototype.getPaths=function(n,e,t,i,s){s=Object.assign({},this.defaultRenderOptions,s);const r=[];return this.forEachGlyph(n,e,t,i,s,function(a,o,l,c){const u=a.getPath(o,l,c,s,this);r.push(u)}),r};vt.prototype.getAdvanceWidth=function(n,e,t){return t=Object.assign({},this.defaultRenderOptions,t),this.forEachGlyph(n,0,0,e,t,function(){})};vt.prototype.draw=function(n,e,t,i,s,r){this.getPath(e,t,i,s,r).draw(n)};vt.prototype.drawPoints=function(n,e,t,i,s,r){r=Object.assign({},this.defaultRenderOptions,r),this.forEachGlyph(e,t,i,s,r,function(a,o,l,c){a.drawPoints(n,o,l,c,r,this)})};vt.prototype.drawMetrics=function(n,e,t,i,s,r){r=Object.assign({},this.defaultRenderOptions,r),this.forEachGlyph(e,t,i,s,r,function(a,o,l,c){a.drawMetrics(n,o,l,c)})};vt.prototype.getEnglishName=function(n){const e=(this.names.unicode||this.names.macintosh||this.names.windows)[n];if(e)return e.en};vt.prototype.validate=function(){const n=[],e=this;function t(s,r){s||(console.warn(`[opentype.js] ${r}`),n.push(r))}function i(s){const r=e.getEnglishName(s);t(r&&r.trim().length>0,"No English "+s+" specified.")}if(i("fontFamily"),i("weightName"),i("manufacturer"),i("copyright"),i("version"),t(this.unitsPerEm>0,"No unitsPerEm specified."),this.tables.colr){const s=this.tables.colr.baseGlyphRecords;let r=-1;for(let a=0;a<s.length;a++){const o=s[a].glyphID;if(t(r<s[a].glyphID,`baseGlyphs must be sorted by GlyphID in ascending order, but glyphID ${o} comes after ${r}`),r>s[a].glyphID)break;r=o}}return n};vt.prototype.toTables=function(){return Y2.fontToTable(this)};vt.prototype.toBuffer=function(){return console.warn("Font.toBuffer is deprecated. Use Font.toArrayBuffer instead."),this.toArrayBuffer()};vt.prototype.toArrayBuffer=function(){const e=this.toTables().encode(),t=new ArrayBuffer(e.length),i=new Uint8Array(t);for(let s=0;s<e.length;s++)i[s]=e[s];return t};vt.prototype.download=function(){console.error("DEPRECATED: platform-specific actions are to be implemented on user-side")};vt.prototype.fsSelectionValues={ITALIC:1,UNDERSCORE:2,NEGATIVE:4,OUTLINED:8,STRIKEOUT:16,BOLD:32,REGULAR:64,USER_TYPO_METRICS:128,WWS:256,OBLIQUE:512};vt.prototype.macStyleValues={BOLD:1,ITALIC:2,UNDERLINE:4,OUTLINED:8,SHADOW:16,CONDENSED:32,EXTENDED:64};vt.prototype.usWidthClasses={ULTRA_CONDENSED:1,EXTRA_CONDENSED:2,CONDENSED:3,SEMI_CONDENSED:4,MEDIUM:5,SEMI_EXPANDED:6,EXPANDED:7,EXTRA_EXPANDED:8,ULTRA_EXPANDED:9};vt.prototype.usWeightClasses={THIN:100,EXTRA_LIGHT:200,LIGHT:300,NORMAL:400,MEDIUM:500,SEMI_BOLD:600,BOLD:700,EXTRA_BOLD:800,BLACK:900};var QA=vt;function eE(n,e){const t=new Ie.Parser(n,e),i=t.parseUShort(),s=t.parseUShort();i!==1&&console.warn(`Unsupported hvar table version ${i}.${s}`);const r=[i,s],a=t.parsePointer32(function(){return this.parseItemVariationStore()}),o=t.parsePointer32(function(){return this.parseDeltaSetIndexMap()}),l=t.parsePointer32(function(){return this.parseDeltaSetIndexMap()}),c=t.parsePointer32(function(){return this.parseDeltaSetIndexMap()});return{version:r,itemVariationStore:a,advanceWidth:o,lsb:l,rsb:c}}function tE(){console.warn("Writing of hvar tables is not yet supported.")}var nE={make:tE,parse:eE},iE=function(){return{coverage:this.parsePointer(Y.coverage),attachPoints:this.parseList(Y.pointer(Y.uShortList))}},sE=function(){var n=this.parseUShort();if(Ve.argument(n===1||n===2||n===3,"Unsupported CaretValue table version."),n===1)return{coordinate:this.parseShort()};if(n===2)return{pointindex:this.parseShort()};if(n===3)return{coordinate:this.parseShort()}},rE=function(){return this.parseList(Y.pointer(sE))},aE=function(){return{coverage:this.parsePointer(Y.coverage),ligGlyphs:this.parseList(Y.pointer(rE))}},oE=function(){return this.parseUShort(),this.parseList(Y.pointer(Y.coverage))};function lE(n,e){e=e||0;const t=new Y(n,e),i=t.parseVersion(1);Ve.argument(i===1||i===1.2||i===1.3,"Unsupported GDEF table version.");var s={version:i,classDef:t.parsePointer(Y.classDef),attachList:t.parsePointer(iE),ligCaretList:t.parsePointer(aE),markAttachClassDef:t.parsePointer(Y.classDef)};return i>=1.2&&(s.markGlyphSets=t.parsePointer(oE)),s}var cE={parse:lE},Xn=new Array(10);Xn[1]=function(){const e=this.offset+this.relativeOffset,t=this.parseUShort();if(t===1)return{posFormat:1,coverage:this.parsePointer(Y.coverage),value:this.parseValueRecord()};if(t===2)return{posFormat:2,coverage:this.parsePointer(Y.coverage),values:this.parseValueRecordList()};Ve.assert(!1,"0x"+e.toString(16)+": GPOS lookup type 1 format must be 1 or 2.")};Xn[2]=function(){const e=this.offset+this.relativeOffset,t=this.parseUShort();Ve.assert(t===1||t===2,"0x"+e.toString(16)+": GPOS lookup type 2 format must be 1 or 2.");const i=this.parsePointer(Y.coverage),s=this.parseUShort(),r=this.parseUShort();if(t===1)return{posFormat:t,coverage:i,valueFormat1:s,valueFormat2:r,pairSets:this.parseList(Y.pointer(Y.list(function(){return{secondGlyph:this.parseUShort(),value1:this.parseValueRecord(s),value2:this.parseValueRecord(r)}})))};if(t===2){const a=this.parsePointer(Y.classDef),o=this.parsePointer(Y.classDef),l=this.parseUShort(),c=this.parseUShort();return{posFormat:t,coverage:i,valueFormat1:s,valueFormat2:r,classDef1:a,classDef2:o,class1Count:l,class2Count:c,classRecords:this.parseList(l,Y.list(c,function(){return{value1:this.parseValueRecord(s),value2:this.parseValueRecord(r)}}))}}};Xn[3]=function(){return{error:"GPOS Lookup 3 not supported"}};Xn[4]=function(){return{error:"GPOS Lookup 4 not supported"}};Xn[5]=function(){return{error:"GPOS Lookup 5 not supported"}};Xn[6]=function(){return{error:"GPOS Lookup 6 not supported"}};Xn[7]=function(){return{error:"GPOS Lookup 7 not supported"}};Xn[8]=function(){return{error:"GPOS Lookup 8 not supported"}};Xn[9]=function(){return{error:"GPOS Lookup 9 not supported"}};function uE(n,e){e=e||0;const t=new Y(n,e),i=t.parseVersion(1);return Ve.argument(i===1||i===1.1,"Unsupported GPOS table version "+i),i===1?{version:i,scripts:t.parseScriptList(),features:t.parseFeatureList(),lookups:t.parseLookupList(Xn)}:{version:i,scripts:t.parseScriptList(),features:t.parseFeatureList(),lookups:t.parseLookupList(Xn),variations:t.parseFeatureVariationsList()}}var hE=new Array(10);function dE(n){return new _e.Table("GPOS",[{name:"version",type:"ULONG",value:65536},{name:"scripts",type:"TABLE",value:new _e.ScriptList(n.scripts)},{name:"features",type:"TABLE",value:new _e.FeatureList(n.features)},{name:"lookups",type:"TABLE",value:new _e.LookupList(n.lookups,hE)}])}var fE={parse:uE,make:dE};function pE(n){const e={};n.skip("uShort");const t=n.parseUShort();Ve.argument(t===0,"Unsupported kern sub-table version."),n.skip("uShort",2);const i=n.parseUShort();n.skip("uShort",3);for(let s=0;s<i;s+=1){const r=n.parseUShort(),a=n.parseUShort(),o=n.parseShort();e[r+","+a]=o}return e}function mE(n){const e={};n.skip("uShort"),n.parseULong()>1&&console.warn("Only the first kern subtable is supported."),n.skip("uLong");const s=n.parseUShort()&255;if(n.skip("uShort"),s===0){const r=n.parseUShort();n.skip("uShort",3);for(let a=0;a<r;a+=1){const o=n.parseUShort(),l=n.parseUShort(),c=n.parseShort();e[o+","+l]=c}}return e}function gE(n,e){const t=new Ie.Parser(n,e),i=t.parseUShort();if(i===0)return pE(t);if(i===1)return mE(t);throw new Error("Unsupported kern table version ("+i+").")}var _E={parse:gE};function xE(n,e,t,i){const s=new Ie.Parser(n,e),r=i?s.parseUShort:s.parseULong,a=[];for(let o=0;o<t+1;o+=1){let l=r.call(s);i&&(l*=2),a.push(l)}return a}var yE={parse:xE};function cf(n,e){const t=[];let i=12;for(let s=0;s<e;s+=1){const r=Ie.getTag(n,i),a=Ie.getULong(n,i+4),o=Ie.getULong(n,i+8),l=Ie.getULong(n,i+12);t.push({tag:r,checksum:a,offset:o,length:l,compression:!1}),i+=16}return t}function vE(n,e){const t=[];let i=44;for(let s=0;s<e;s+=1){const r=Ie.getTag(n,i),a=Ie.getULong(n,i+4),o=Ie.getULong(n,i+8),l=Ie.getULong(n,i+12);let c;o<l?c="WOFF":c=!1,t.push({tag:r,offset:a,compression:c,compressedLength:o,length:l}),i+=20}return t}function pt(n,e){if(e.compression==="WOFF"){const t=new Uint8Array(n.buffer,e.offset+2,e.compressedLength-2),i=new Uint8Array(e.length);if(Dp(t,i),i.byteLength!==e.length)throw new Error("Decompression error: "+e.tag+" decompressed length doesn't match recorded length");return{data:new DataView(i.buffer,0),offset:0}}else return{data:n,offset:e.offset}}function SE(n,e={}){let t,i;const s=new QA({empty:!0});n.constructor!==ArrayBuffer&&(n=new Uint8Array(n).buffer);const r=new DataView(n,0);let a,o=[];const l=Ie.getTag(r,0);if(l==="\0\0\0"||l==="true"||l==="typ1")s.outlinesFormat="truetype",a=Ie.getUShort(r,4),o=cf(r,a);else if(l==="OTTO")s.outlinesFormat="cff",a=Ie.getUShort(r,4),o=cf(r,a);else if(l==="wOFF"){const P=Ie.getTag(r,4);if(P==="\0\0\0")s.outlinesFormat="truetype";else if(P==="OTTO")s.outlinesFormat="cff";else throw new Error("Unsupported OpenType flavor "+l);a=Ie.getUShort(r,12),o=vE(r,a)}else if(l==="wOF2"){const P="https://github.com/opentypejs/opentype.js/issues/183#issuecomment-1147228025";throw new Error("WOFF2 require an external decompressor library, see examples at: "+P)}else throw new Error("Unsupported OpenType signature "+l);let c,u,h,d,f,p,_,m,g,v,b,x,E,S,A,y,T,L;for(let P=0;P<a;P+=1){const U=o[P];let D;switch(U.tag){case"avar":_=U;break;case"cmap":D=pt(r,U),s.tables.cmap=Vp.parse(D.data,D.offset),s.encoding=new Wp(s.tables.cmap);break;case"cvt ":D=pt(r,U),L=new Ie.Parser(D.data,D.offset),s.tables.cvt=L.parseShortList(U.length/2);break;case"fvar":h=U;break;case"STAT":d=U;break;case"gvar":f=U;break;case"cvar":p=U;break;case"fpgm":D=pt(r,U),L=new Ie.Parser(D.data,D.offset),s.tables.fpgm=L.parseByteList(U.length);break;case"head":D=pt(r,U),s.tables.head=t0.parse(D.data,D.offset),s.unitsPerEm=s.tables.head.unitsPerEm,t=s.tables.head.indexToLocFormat;break;case"hhea":D=pt(r,U),s.tables.hhea=n0.parse(D.data,D.offset),s.ascender=s.tables.hhea.ascender,s.descender=s.tables.hhea.descender,s.numberOfHMetrics=s.tables.hhea.numberOfHMetrics;break;case"HVAR":E=U;break;case"hmtx":x=U;break;case"ltag":D=pt(r,U),i=s0.parse(D.data,D.offset);break;case"COLR":D=pt(r,U),s.tables.colr=c0.parse(D.data,D.offset);break;case"CPAL":D=pt(r,U),s.tables.cpal=qp.parse(D.data,D.offset);break;case"maxp":D=pt(r,U),s.tables.maxp=r0.parse(D.data,D.offset),s.numGlyphs=s.tables.maxp.numGlyphs;break;case"name":y=U;break;case"OS/2":D=pt(r,U),s.tables.os2=ru.parse(D.data,D.offset);break;case"post":D=pt(r,U),s.tables.post=a0.parse(D.data,D.offset),s.glyphNames=new Uu(s.tables.post);break;case"prep":D=pt(r,U),L=new Ie.Parser(D.data,D.offset),s.tables.prep=L.parseByteList(U.length);break;case"glyf":m=U;break;case"loca":A=U;break;case"CFF ":c=U;break;case"CFF2":u=U;break;case"kern":S=U;break;case"GDEF":g=U;break;case"GPOS":v=U;break;case"GSUB":b=U;break;case"meta":T=U;break;case"gasp":try{D=pt(r,U),s.tables.gasp=m0.parse(D.data,D.offset)}catch(K){console.warn("Failed to parse gasp table, skipping."),console.warn(K)}break;case"SVG ":D=pt(r,U),s.tables.svg=g0.parse(D.data,D.offset);break}}const R=pt(r,y);if(s.tables.name=zp.parse(R.data,R.offset,i),s.names=s.tables.name,m&&A){const P=t===0,U=pt(r,A),D=yE.parse(U.data,U.offset,s.numGlyphs,P),K=pt(r,m);s.glyphs=M0.parse(K.data,K.offset,D,s,e)}else if(c){const P=pt(r,c);iu.parse(P.data,P.offset,s,e)}else if(u){const P=pt(r,u);iu.parse(P.data,P.offset,s,e)}else throw new Error("Font doesn't contain TrueType, CFF or CFF2 outlines.");const w=pt(r,x);if(i0.parse(s,w.data,w.offset,s.numberOfHMetrics,s.numGlyphs,s.glyphs,e),gb(s,e),S){const P=pt(r,S);s.kerningPairs=_E.parse(P.data,P.offset)}else s.kerningPairs={};if(g){const P=pt(r,g);s.tables.gdef=cE.parse(P.data,P.offset)}if(v){const P=pt(r,v);s.tables.gpos=fE.parse(P.data,P.offset),s.position.init()}if(b){const P=pt(r,b);s.tables.gsub=o0.parse(P.data,P.offset)}if(h){const P=pt(r,h);s.tables.fvar=u0.parse(P.data,P.offset,s.names)}if(d){const P=pt(r,d);s.tables.stat=h0.parse(P.data,P.offset,s.tables.fvar)}if(f){h||console.warn("This font provides a gvar table, but no fvar table, which is required for variable fonts."),m||console.warn("This font provides a gvar table, but no glyf table. Glyph variation only works with TrueType outlines.");const P=pt(r,f);s.tables.gvar=p0.parse(P.data,P.offset,s.tables.fvar,s.glyphs)}if(p){h||console.warn("This font provides a cvar table, but no fvar table, which is required for variable fonts."),s.tables.cvt||console.warn("This font provides a cvar table, but no cvt table which could be made variable."),m||console.warn("This font provides a gvar table, but no glyf table. Glyph variation only works with TrueType outlines.");const P=pt(r,p);s.tables.cvar=f0.parse(P.data,P.offset,s.tables.fvar,s.tables.cvt||[])}if(_){h||console.warn("This font provides an avar table, but no fvar table, which is required for variable fonts.");const P=pt(r,_);s.tables.avar=d0.parse(P.data,P.offset,s.tables.fvar)}if(E){h||console.warn("This font provides an HVAR table, but no fvar table, which is required for variable fonts."),x||console.warn("This font provides an HVAR table, but no hmtx table to vary.");const P=pt(r,E);s.tables.hvar=nE.parse(P.data,P.offset,s.tables.fvar)}if(T){const P=pt(r,T);s.tables.meta=l0.parse(P.data,P.offset),s.metas=s.tables.meta}return s.palettes=new v0(s),s}const hs=1024,pn=8,no=.08;let D0="/fonts/NanumGothic-Regular.ttf";function bE(n){D0=n,ta._shared=null}const Xr=class Xr{constructor(e){Lt(this,"capHeightEm");Lt(this,"ascentEm");Lt(this,"descentEm");Lt(this,"font");Lt(this,"upem");Lt(this,"glyphs",new Map);Lt(this,"data",new Float32Array(hs*4*64));Lt(this,"used",0);Lt(this,"_texture",null);Lt(this,"_texelsUploaded",0);var t,i;this.font=e,this.upem=e.unitsPerEm,this.capHeightEm=(((i=(t=e.tables)==null?void 0:t.os2)==null?void 0:i.sCapHeight)||e.ascender*.88)/this.upem,this.ascentEm=e.ascender/this.upem,this.descentEm=e.descender/this.upem}static shared(e=D0){return this._shared||(this._shared=(async()=>{const t=await(await fetch(e)).arrayBuffer();return new Xr(SE(t))})(),this._shared.catch(()=>{Xr._shared=null})),this._shared}measureEm(e){let t=0;for(const i of e)t+=this.ensureGlyph(i.codePointAt(0)).advance;return t}ensureGlyph(e){let t=this.glyphs.get(e);if(t)return t;const i=this.font.charToGlyph(String.fromCodePoint(e)),s=(i.advanceWidth??this.upem*.5)/this.upem,r=i.getPath(0,0,1),a=[];let o=0,l=0,c=0,u=0;for(const w of r.commands)switch(w.type){case"M":c=o=w.x,u=l=-w.y;break;case"L":a.push(uf(c,u,w.x,-w.y)),c=w.x,u=-w.y;break;case"Q":a.push({x0:c,y0:u,cx:w.x1,cy:-w.y1,x1:w.x,y1:-w.y}),c=w.x,u=-w.y;break;case"C":{const P=(w.x1+w.x2)/2,U=(-w.y1+-w.y2)/2;a.push({x0:c,y0:u,cx:P,cy:U,x1:w.x,y1:-w.y}),c=w.x,u=-w.y;break}case"Z":(c!==o||u!==l)&&a.push(uf(c,u,o,l)),c=o,u=l;break}if(!a.length)return t={base:-1,advance:s},this.glyphs.set(e,t),t;let h=1/0,d=1/0,f=-1/0,p=-1/0;for(const w of a)h=Math.min(h,w.x0,w.cx,w.x1),f=Math.max(f,w.x0,w.cx,w.x1),d=Math.min(d,w.y0,w.cy,w.y1),p=Math.max(p,w.y0,w.cy,w.y1);const _=Math.max(f-h,1e-6),m=Math.max(p-d,1e-6),g=Array.from({length:pn},()=>[]),v=Array.from({length:pn},()=>[]);a.forEach((w,P)=>{const U=Math.min(w.y0,w.cy,w.y1),D=Math.max(w.y0,w.cy,w.y1),K=Math.min(w.x0,w.cx,w.x1),B=Math.max(w.x0,w.cx,w.x1),ie=io((U-d)/m),F=io((D-d)/m);for(let oe=ie;oe<=F;oe++)g[oe].push(P);const se=io((K-h)/_),V=io((B-h)/_);for(let oe=se;oe<=V;oe++)v[oe].push(P)});const b=w=>Math.ceil(w.length/4),x=g.reduce((w,P)=>w+b(P),0)+v.reduce((w,P)=>w+b(P),0),E=2+pn*2+x+a.length*2,S=this.alloc(E),A=this.data,y=(w,P,U,D,K)=>{A[w*4]=P,A[w*4+1]=U,A[w*4+2]=D,A[w*4+3]=K},T=S+2+pn*2+x;y(S,h,d,f,p),y(S+1,S+2,S+2+pn,0,0);let L=S+2+pn*2;const R=(w,P)=>{for(let U=0;U<pn;U++){y(P+U,L,w[U].length,0,0);const D=w[U];for(let K=0;K<D.length;K+=4)y(L++,T+D[K]*2,K+1<D.length?T+D[K+1]*2:0,K+2<D.length?T+D[K+2]*2:0,K+3<D.length?T+D[K+3]*2:0)}};return R(g,S+2),R(v,S+2+pn),a.forEach((w,P)=>{y(T+P*2,w.x0,w.y0,w.cx,w.cy),y(T+P*2+1,w.x1,w.y1,0,0)}),t={base:S,advance:s},this.glyphs.set(e,t),t}bboxOf(e){const t=e.base*4;return[this.data[t],this.data[t+1],this.data[t+2],this.data[t+3]]}alloc(e){const t=(this.used+e)*4;if(t>this.data.length){let s=this.data.length;for(;s<t;)s*=2;const r=new Float32Array(s);r.set(this.data),this.data=r}const i=this.used;return this.used+=e,i}texture(){var t;const e=Math.max(1,Math.ceil(this.used/hs));if(!this._texture||this._texelsUploaded<this.used){(t=this._texture)==null||t.dispose();const i=new Float32Array(hs*e*4);i.set(this.data.subarray(0,Math.min(this.data.length,hs*e*4)));const s=new Jf(i,hs,e,Ln,Gn);s.minFilter=zt,s.magFilter=zt,s.generateMipmaps=!1,s.needsUpdate=!0,this._texture=s,this._texelsUploaded=this.used}return this._texture}};Lt(Xr,"_shared",null);let ta=Xr;function uf(n,e,t,i){return{x0:n,y0:e,cx:(n+t)/2,cy:(e+i)/2,x1:t,y1:i}}function io(n){return Math.min(pn-1,Math.max(0,Math.floor(n*pn)))}const ME=`
attribute vec2 emuv;
attribute float gbase;
attribute vec3 tcolor;
varying vec2 vEm;
flat varying int vBase;
varying vec3 vColor;
void main() {
vEm = emuv;
vBase = int(gbase);
vColor = tcolor;
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
}
`,AE=`
precision highp float;
uniform sampler2D dataTex;
varying vec2 vEm;
flat varying int vBase;
varying vec3 vColor;
layout(location = 0) out vec4 fragOut;
vec4 T(int i) { return texelFetch(dataTex, ivec2(i % ${hs}, i / ${hs}), 0); }
// Lengyel's banded winding-number coverage for one ray along +x from p.
// Curves are fetched via the band's index list; 'swap' mirrors x/y for the
// vertical (+y) ray, whose winding sign flips (handedness reversal).
float rayCoverage(vec2 p, float ppem, int bandTexel, bool swap) {
vec4 band = T(bandTexel);
int count = int(band.y);
float cov = 0.0;
for (int j = 0; j < 256; j++) {
if (j >= count) break;
vec4 idx4 = T(int(band.x) + (j >> 2));
int cb = int(j % 4 == 0 ? idx4.x : j % 4 == 1 ? idx4.y : j % 4 == 2 ? idx4.z : idx4.w);
vec4 A = T(cb);
vec2 e = T(cb + 1).xy;
// Swap the CURVE points before subtracting: p is already in swapped
// coordinates for the vertical ray ((A.xy - p).yx would be wrong).
vec2 p1 = (swap ? A.yx : A.xy) - p;
vec2 p2 = (swap ? A.wz : A.zw) - p;
vec2 p3 = (swap ? e.yx : e.xy) - p;
uint code = (0x2E74u >> ((p1.y > 0.0 ? 2u : 0u) + (p2.y > 0.0 ? 4u : 0u) + (p3.y > 0.0 ? 8u : 0u))) & 3u;
if (code != 0u) {
vec2 a = p1 - p2 * 2.0 + p3;
vec2 b = p1 - p2;
float t1, t2;
if (abs(a.y) < 1e-6) {
float t = p1.y / (2.0 * b.y);
t1 = t; t2 = t;
} else {
float d = sqrt(max(b.y * b.y - a.y * p1.y, 0.0));
t1 = (b.y - d) / a.y;
t2 = (b.y + d) / a.y;
}
if ((code & 1u) != 0u) {
float x = (a.x * t1 - b.x * 2.0) * t1 + p1.x;
cov += clamp(x * ppem + 0.5, 0.0, 1.0);
}
if (code > 1u) {
float x = (a.x * t2 - b.x * 2.0) * t2 + p1.x;
cov -= clamp(x * ppem + 0.5, 0.0, 1.0);
}
}
}
return cov;
}
void main() {
vec4 bbox = T(vBase);
vec4 bases = T(vBase + 1);
vec2 fw = fwidth(vEm);
vec2 span = max(bbox.zw - bbox.xy, vec2(1e-6));
int hb = clamp(int((vEm.y - bbox.y) / span.y * float(${pn})), 0, ${pn-1});
int vb = clamp(int((vEm.x - bbox.x) / span.x * float(${pn})), 0, ${pn-1});
float covH = rayCoverage(vEm, 1.0 / max(fw.x, 1e-9), int(bases.x) + hb, false);
float covV = -rayCoverage(vEm.yx, 1.0 / max(fw.y, 1e-9), int(bases.y) + vb, true);
float alpha = clamp((covH + covV) * 0.5, 0.0, 1.0);
if (alpha < 0.004) discard;
fragOut = vec4(vColor, alpha);
}
`;class EE{constructor(e){Lt(this,"pos",[]);Lt(this,"emuv",[]);Lt(this,"gbase",[]);Lt(this,"color",[]);Lt(this,"index",[]);this.engine=e}add(e,t,i,s,r,a,o){const l=this.engine,c=String(e).split(`
`),u=i/l.capHeightEm,h=i*5/3,d=(c.length-1)*h+i;a===4&&(o=2);let f;o===3?f=-i:o===2?f=d/2-i:f=(c.length-1)*h;const p=Math.cos(s),_=Math.sin(s),m=(r>>16&255)/255,g=(r>>8&255)/255,v=(r&255)/255;for(let b=0;b<c.length;b++){const x=c[b];if(!x)continue;const E=l.measureEm(x),S=a===1||a===4?-E*u/2:a===2?-E*u:0,A=f-b*h;let y=0;for(const T of x){const L=l.ensureGlyph(T.codePointAt(0));if(L.base>=0){const[R,w,P,U]=this.engine.bboxOf(L),D=R-no,K=w-no,B=P+no,ie=U+no,F=this.pos.length/3;for(const[se,V]of[[D,K],[B,K],[B,ie],[D,ie]]){const oe=S+(y+se)*u,Ae=A+V*u;this.pos.push(t.x+oe*p-Ae*_,t.y+oe*_+Ae*p,1),this.emuv.push(se,V),this.gbase.push(L.base),this.color.push(m,g,v)}this.index.push(F,F+1,F+2,F,F+2,F+3)}y+=L.advance}}}build(){if(!this.index.length)return null;const e=new wt;e.setAttribute("position",new dt(this.pos,3)),e.setAttribute("emuv",new dt(this.emuv,2)),e.setAttribute("gbase",new dt(this.gbase,1)),e.setAttribute("tcolor",new dt(this.color,3)),e.setIndex(this.index);const t=new In({glslVersion:Wc,vertexShader:ME,fragmentShader:AE,uniforms:{dataTex:{value:this.engine.texture()}},transparent:!0,depthTest:!1,depthWrite:!1,side:Yt}),i=new Ht(e,t);return i.frustumCulled=!0,i}}const TE=`; IntelliCAD Linetypes\r
;\r
; icad.lin\r
; Release 1.0 \r
; \r
; .............................................................................\r
;\r
; Copyright (c) 1998 by Visio Corporation. All rights reserved.\r
;\r
; The Software is subject to the license agreement that accompanies \r
; or is included with the Software, which specifies the permitted \r
; and prohibited uses of the Software. Any unauthorized duplication \r
; or use of Visio Corporation Software, in whole or in part, in print, \r
; or in any other storage and retrieval system is prohibited.\r
; \r
; To the maximum extent permitted by applicable law, Visio Corporation\r
; and its suppliers disclaim any and all warranties and conditions,\r
; either express or implied, including, without limitation, implied\r
; warranties of merchantability, fitness for a particular purpose,\r
; title, and non-infringement, and those arising out of usage of trade\r
; or course of dealing, concerning these materials. These materials\r
; are provided "as is" without warranty of any kind.\r
; .............................................................................\r
\r
\r
\r
*BORDER,__ __ . __ __ . __ __ . __ __ . __ __ . __ __ . __ __ . __ __ . \r
A,0.50,-0.250,0.50,-0.250,0,-0.250\r
*BORDER2,__.__.__.__.__.__.__.__.__.__.__.__.__.__.__.__.__.__.__.__.__ \r
A,0.25,-0.125,0.25,-0.125,0,-0.125\r
*BORDERX2,____ ____ . ____ ____ . ____ ____ . ____ ____ . \r
A,1.0,-0.5,1.0,-0.5,0,-0.5\r
\r
*CENTER,____ _ ____ _ ____ _ ____ _ ____ _ ____ _ ____ _ ____ _ ____ _\r
A,1.250,-0.25,0.25,-0.25\r
*CENTER2,___ _ ___ _ ___ _ ___ _ ___ _ ___ _ ___ _ ___ _ ___ _ ___ _ _\r
A,0.75,-0.1250,0.1250,-0.125\r
*CENTERX2,________ __ ________ __ ________ __ ________ __ ____\r
A,2.5,-0.50,0.50,-0.50\r
\r
*DASHDOT,__ . __ . __ . __ . __ . __ . __ . __ . __ . __ . __ . __ . _\r
A,0.50,-0.250,0,-0.250\r
*DASHDOT2,_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._.\r
A,0.25,-0.125,0,-0.125\r
*DASHDOTX2,____ . ____ . ____ . ____ . ____ . ____ . ____ \r
A,1.0,-0.5,0,-0.5\r
\r
*DASHED,__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __\r
A,0.50,-0.250\r
*DASHED2,_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _\r
A,0.250,-0.1250\r
*DASHEDX2,____ ____ ____ ____ ____ ____ ____ ____ ____ ____ \r
A,1.0,-0.5\r
\r
*DIVIDE,____ . . ____ . . ____ . . ____ . . ____ . . ____ . . ____ . .\r
A,0.50,-0.25,0,-0.25,0,-0.25\r
*DIVIDE2,__..__..__..__..__..__..__..__..__..__..__..__..__..__..__..__..\r
A,0.25,-0.125,0,-0.125,0,-0.125\r
*DIVIDEX2,________ . . ________ . . ________ . . ________ . .\r
A,1.0,-0.5,0,-0.5,0,-0.50\r
\r
*DOT,. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\r
A,0,-0.25\r
*DOT2,................................................................\r
A,0,-0.125\r
*DOTX2,. . . . . . . . . . . . . . . . . . . . . \r
A,0,-0.5\r
\r
*HIDDEN,__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ \r
A,0.250,-0.1250\r
*HIDDEN2,_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _\r
A,0.125,-0.06250\r
*HIDDENX2,____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ \r
A,0.5,-0.25\r
\r
*PHANTOM,______ __ __ ______ __ __ ______ __ __ ______ __ __\r
A,1.25,-0.25,0.250,-0.25,0.25,-0.25\r
*PHANTOM2,___ _ _ ___ _ _ ___ _ _ ___ _ _ ___ _ _ ___ _ _ ___ _ _ ___ _ _\r
A,0.625,-0.125,0.1250,-0.125,0.125,-0.1250\r
*PHANTOMX2,____________ ____ ____ ____________ ____ ____ \r
A,2.5,-0.5,0.5,-0.5,0.50,-0.5\r
\r
*PHANTOM4,___ _ _ ___ _ _ (1/2 of Phantom2)__ _ _ ___ _ _ ___ _ _ ___ _ _\r
A,0.3125,-0.0625,0.0625,-0.0625,0.0625,-0.0625\r
\r
*PHANTOM8,___ _ _ ___ _ _ (1/2 of Phantom4)__ _ _ ___ _ _ ___ _ _ ___ _ _\r
A,0.15625,-0.03125,0.03125,-0.03125,0.03125,-0.03125\r
\r
*BORDER4,__.__.__.__.__.__._ (1/2 of Border2) _.__.__.__.__.__.__.__.__ \r
A,0.125,-0.0625,0.125,-0.0625,0,-0.0625\r
\r
*CENTER4,___ _ ___ _ ___ _ __ (1/2 of Center2)__ _ ___ _ ___ _ ___ _ _\r
A,0.375,-0.0625,0.0625,-0.0625\r
*CENTER8,___ _ ___ _ ___ _ __ (1/2 of Center4)__ _ ___ _ ___ _ ___ _ _\r
A,0.1875,-0.03125,0.03125,-0.03125\r
\r
*CENTERF,_____ _ _____ (Finer short dashes than Center) _____\r
A,1.25,-0.125,0.125,-0.125\r
*CENTERF2,___ _ ___ _ ___ _ ___ _ ___ _ ___ _ ___ _ ___ _ ___ _ ___ _ _\r
A,0.75,-0.0625,0.0625,-0.0625\r
;; Auto-Arch additions for finer linetypes.\r
*CENTERF4,___ _ ___ _ ___ _ __ (1/2 of CenterF2)__ _ ___ _ ___ _ ___ _ _\r
A,0.375,-0.03125,0.03125,-0.03125\r
*CENTERF8,___ _ ___ _ ___ _ __ (1/2 of CenterF4)__ _ ___ _ ___ _ ___ _ _\r
A,0.1875,-0.0015625,0.0015625,-0.0015625\r
\r
*DASHED4,_ _ _ _ _ _ _ _ (1/2 of Dashed2)_ _ _ _ _ _ _ _ _ _ _ _ _ _ _\r
A,0.125,-0.0625\r
*DASHED8,_ _ _ _ _ _ _ _ (1/2 of Dashed4)_ _ _ _ _ _ _ _ _ _ _ _ _ _ _\r
A,0.0625,-0.03125\r
\r
*DEMOx2,____ ____ ____ ____ ____\r
A,0.250,-0.5\r
*DEMO,__ __ __ __ __ __ __ __ __ __ __\r
A,0.125,-0.25\r
*DEMO2,_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _\r
A,0.0625,-0.125\r
*DEMO4,_ _ _ _ _ _ (1/2 of Demo2) _ _ _ _ _ _ _ _ _ _ _\r
A,0.0625,-0.125\r
*DEMO8,_ _ _ _ _ _ (1/2 of Demo4) _ _ _ _ _ _ _ _ _ _ _\r
A,0.03125,-0.0625\r
\r
*INVISIBLE,. (Dot at endpoints only) .\r
A,0,-1000\r
\r
*DOT4,...................(1/2 of Dot2)................................\r
A,0,-0.06125\r
*DOT8,...................(1/2 of Dot4)................................\r
A,0,-0.03125\r
*DOT16,..................(1/2 of Dot8)................................\r
A,0,-0.0015625\r
\r
*HIDDEN4,_ _ _ _ _ _ _ _ (1/2 of Hidden2)_ _ _ _ _ _ _ _ _ _ _ _ _ _\r
A,0.0625,-0.03125\r
*HIDDEN8,_ _ _ _ _ _ _ _ (1/2 of Hidden4)_ _ _ _ _ _ _ _ _ _ _ _ _ _\r
A,0.03125,-0.015\r
\r
*JIS_02_0.7, Hot Water Supply __ __ __ __ __ __ __\r
A,0.8,-0.5\r
*JIS_02_1.0, HIDDEN 0.8 - - - - - - - - - -\r
A,0.8,-0.8\r
*JIS_02_1.2, HIDDEN01.25 - - - - - - - - - -\r
A,1.26,-1.26\r
*JIS_02_2.0, HIDDEN02 __ __ __ __ __ __ __ __ __ __ __ \r
A,1.99,-0.99\r
*JIS_02_4.0, HIDDEN04 ____ ____ ____ ____ ____ ____ ____ \r
A,3.999,-0.999\r
*JIS_08_11, ___ _ ___ _ ___ _ ___ _ ___ _ ___ _ ___\r
A,10.9999,-0.499,0.499,-0.499\r
*JIS_08_15, ____ _ ____ _ ____ _ ____ _ ____ _ ____\r
A,14.999,-0.499,0.499,-0.499\r
*JIS_08_25, ________ __ ________ __ ________ __\r
A,24.999,-1,0.8,-1\r
*JIS_08_37, _____________ __ _____________ __ _____________ __ \r
A,36.999,-1.0,0.8,-1\r
*JIS_08_50, , ___________________ __ ___________________ __ \r
A,49.999,-1.0,0.8,-1\r
*JIS_09_08, _____ _ _ _____ _ _ _____ _ _ _____ _ _ _____ _ _ \r
A,7.999,-0.5,0.5,-0.5,0.5,-0.5\r
*JIS_09_15, _________ _ _ _________ _ _ _________ _ _ _________ _ _ \r
A,14.999,-0.999,0.499,-0.999,0.499,-0.999\r
*JIS_09_29, _____________ _ _ _____________ _ _ _____________ _ _ \r
A,28.999,-1.499,0.999,-1.499,0.999,-1.499\r
*JIS_09_50, _______________________ __ __ _______________________\r
A,49.999,-1.499,0.999,-1.499,0.999,-1.499\r
\r
\r
\r
*CONTOUR,______ ______ ______ ______ ______ ______ ______ ______\r
A,0.375,-0.09375\r
*CONTOUR2,____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ \r
A,0.25,-0.0625\r
*COLDWR,___ _ ____ _ _____ _ _____ _ _____ _ ____\r
A,0.25,-0.075,0.075,-0.075\r
*HOTWR,___ _ _ ___ _ _ ___ _ _ ___ _ _ ___ _ _ ___\r
A,0.25,-0.075,0.075,-0.075,0.075,-0.075\r
*HCW,_____ _ _ _ _____ _ _ _ _____ _ _ _ _____\r
A,1,-0.125,0.125,-0.125,0.125,-0.125,0.125,-0.125\r
*BOUNDARY,___________ __ __ ___________ __ __ ______ \r
A,1.75,-0.125,0.125,-0.125,0.125,-0.125\r
*BOUNDARY2,______ _ _ ______ _ _ ______ _ _ ______ _ _ ______\r
A,1,-0.0625,0.0625,-0.0625,0.0625,-0.0625\r
*STREAM,_________ . . ___________ . . ___________\r
A,1,-0.125,0,-0.125,0,-0.125 \r
*PNEUM,__ ___ ___ ___ ___ ___ ___ ___ ___ ___ __\r
A,0.2,-0.1,0.2,-0.1\r
*WASTE,__ __ __ __ __ __ __ __ __ __ __ __ __ __\r
A,0.25,-0.125\r
*2DASHES,____ _ _ _____ _ _ ____ _ _ ____ _ _ ____\r
A,0.75,-0.25,0.1,-0.25,0.1,-0.25\r
*EWIREUP,__ . __ . __ . __ . __ . __ . __ . __ .__\r
A,0.25,-.075,0,-.075\r
*EWCELL,___ ___ . ___ ___ . __ __ . __ __ . __ __\r
A,0.25,-0.075,0.25,-.075,0,-.075\r
\r
*EVENDASH,-- -- -- -- -- -- -- -- -- -- --\r
A,0.125,-0.125\r
\r
;; Additional Plumbing linetypes\r
*DCW,Domestic Cold Water ___ _ ______________ _ ____\r
A,1.25,-0.06,0.08,-0.06\r
*DCW2,Domestic Cold Water __ _ ______ _ _____ _ ____\r
A,0.625,-0.03,0.04,-0.03\r
*DCWX2,Domestic Cold Water ________ ___ __________\r
A,2.5,-0.12,0.16,-0.12\r
*DHW,Domestic Hot Water ___ _ _ ___________ _ _ ____\r
A,1.25,-0.06,0.08,-0.06,0.08,-0.06\r
*DHW2,Domestic Hot Water __ _ _ _____ _ _ ____ _ _ __\r
A,0.625,-0.03,0.04,-0.03,0.04,-0.03\r
*DHWX2,Domestic Hot Water _____ ___ ___ ___ _____\r
A,2.5,-0.12,0.16,-0.12,0.16,-0.12\r
*DHWR,Domestic Hot Wtr Return _____ __ __ __ ________\r
A,1.25,-0.06,0.08,-0.06,0.08,-0.06,0.08,-0.06\r
*DHWR2,Domestic Hot Wtr Return ___ _ _ _ ____________\r
A,0.625,-0.03,0.04,-0.03,0.04,-0.03,0.04,-0.03\r
*DHWRX2,Domestic Hot Wtr Return ____ ___ ____ ____ ____\r
A,2.5,-0.12,0.16,-0.12,0.16,-0.12,0.16,-0.12\r
*VENT,Sanitary Vent Pipe __ __ __ __ __ __ __ __ __ __\r
A,0.16,-0.08\r
*VENT2,Sanitary Vent Pipe _ _ _ _ _ _ _ _ _ _ _ _ _ _ _\r
A,0.08,-0.04\r
*VENTX2,Sanitary Vent Pipe ____ ____ ____ ___\r
A,0.32,-0.16\r
*COND,Steam Condensate __ __ __ __ __ __ __ __ __ __ __\r
A,0.16,-0.08\r
*COND2,Steam Condensate _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _\r
A,0.08,-0.04\r
*CONDX2,Steam Condensate ____ ____ ____ ____\r
A,0.32,-0.16\r
\r
;;; ISO LINTYPES\r
*DaL013,02b013 Dashed line 0.13mm\r
A,1.56,-0.39\r
*DaSpL013,03b013 Dashed space line 0.13mm\r
A,1.56,-2.34\r
*LDaDoL013,04b013 Long dashed dotted line 0.13mm \r
A,3.12,-0.39,0.065,-0.39\r
*LDaDbDoL,05b013 Long dash double dotted line 0.13mm \r
A,3.12,-0.39,0.065,-0.39,0.065,-0.39\r
*LDaTrDoL,06b013 Long dashed triplicate dotted line 0.13mm \r
A,3.12,-0.39,0.065,-0.39,0.065,-0.39,0.065,-0.39\r
*DoL013,07b013 Dotted line\r
A,0.065,-0.39\r
*LDaShDaL013,08b013 Long dashed short dashed line 0.13mm \r
A,3.12,-0.39,0.78,-0.39\r
*09b013,Long dashed double-short-dashed line 0.13mm \r
A,3.12,-0.39,0.78,-0.39,0.78,-0.39\r
*10b013,Dashed dotted line 0.13mm \r
A,1.56,-0.39,0.065,-0.39\r
*11b013,Double-dashed dotted line 0.13mm \r
A,1.56,-0.39,1.56,-0.39,0.065,-0.39\r
*12b013,Dashed double-dotted line 0.13mm \r
A,1.56,-0.39,0.065,-0.39,0.065,-0.39\r
*13b013,Double-dashed double-dotted line 0.13mm \r
A,1.56,-0.39,1.56,-0.39,0.065,-0.39,0.065,-0.39\r
*14b013,Dashed triplicate-dotted line 0.13mm \r
A,1.56,-0.39,0.065,-0.39,0.065,-0.39,0.065,-0.39\r
*15b013,Double-dashed triplicate-dotted line 0.13mm \r
A,1.56,-0.39,1.56,-0.39,0.065,-0.39,0.065,-0.39,0.065,-0.39\r
*02b018,Dashed line 0.18mm \r
A,2.16,-0.54\r
*03b018,Dashed space line 0.18mm \r
A,2.16,-3.24\r
*04b018,Long dashed dotted line 0.18mm \r
A,4.32,-0.54,0.09,-0.54\r
*05b018,Long dash double dotted line 0.18mm \r
A,4.32,-0.54,0.09,-0.54,0.09,-0.54\r
*06b018,Long dashed triplicate dotted line 0.18mm \r
A,4.32,-0.54,0.09,-0.54,0.09,-0.54,0.09,-0.54\r
*07b018,Lotted line\r
A,0.09,-0.54\r
*08b018,Long dashed short dashed line 0.18mm \r
A,4.32,-0.54,1.08,-0.54\r
*09b018,Long dashed double-short-dashed line 0.18mm \r
A,4.32,-0.54,1.08,-0.54,1.08,-0.54\r
*10b018,Dashed dotted line 0.18mm \r
A,2.16,-0.54,0.09,-0.54\r
*11b018,Double-dashed dotted line 0.18mm \r
A,2.16,-0.54,2.16,-0.54,.09,-0.54\r
*12b018,Dashed double-dotted line 0.18mm \r
A,2.16,-0.54,0.09,-0.54,0.09,-0.54\r
*13b018,Double-dashed double-dotted line 0.18mm \r
A,2.16,-0.54,2.16,-0.54,0.09,-0.54,0.09,-0.54\r
*14b018,Dashed triplicate-dotted line 0.18mm \r
A,2.16,-0.54,0.09,-0.54,0.09,-0.54,0.09,-0.54\r
*15b018,Double-dashed triplicate-dotted line 0.18mm \r
A,2.16,-0.54,2.16,-0.54,0.09,-0.54,0.09,-0.54,0.09,-0.54\r
*02b025,Dashed Line 0.25mm \r
A,3,-0.75\r
*03b025,Dashed space line 0.25mm \r
A,3,-4.5\r
*04b025,Long dashed dotted line 0.25mm \r
A,6,-0.75,0.125,-0.75\r
*05b025,Long dash double dotted line 0.25mm \r
A,6,-0.75,0.125,-0.75,0.125,-0.75\r
*06b025,Long dashed triplicate dotted line 0.25mm \r
A,6,-0.75,0.125,-0.75,0.125,-0.75,0.125,-0.75\r
*07b025,Dotted line 0.25 mm \r
A,0.125,-0.75\r
*08b025,Long dashed short dashed line 0.25mm \r
A,6,-0.75,1.5,-0.75\r
*09b025,Long dashed double-short-dashed line 0.25mm \r
A,6,-0.75,1.5,-0.75,1.5,-0.75\r
*10b025,Dashed dotted line 0.25mm \r
A,3,-0.75,0.125,-0.75\r
*11b025,Double-dashed dotted line 0.25mm \r
A,3,-0.75,3,-0.75,0.125,-0.75\r
*12b025,Dashed double-dotted line 0.25mm \r
A,3,-0.75,0.125,-0.75,0.125,-0.75\r
*13b025,Double-dashed double-dotted line 0.25mm \r
A,3,-0.75,3,-0.75,0.125,-0.75,0.125,-0.75\r
*14b025,Dashed triplicate-dotted line 0.25mm \r
A,3,-0.75,0.125,-0.75,0.125,-0.75,0.125,-0.75\r
*15b025,Double-dashed triplicate-dotted line 0.25mm \r
A,3,-0.75,3,-0.75,0.125,-0.75,0.125,-0.75,0.125,-0.75\r
*02b035,Dashed line 0.35mm \r
A,4.2,-1.05\r
*03b035,Dashed space line 0.35mm \r
A,4.2,-6.3\r
*04b035,Long dashed dotted line 0.35mm \r
A,8.4,-1.05,0.175,-1.05\r
*05b035,Long dash double dotted line 0.35mm \r
A,8.4,-1.05,0.175,-1.05,0.175,-1.05\r
*06b035,Long dashed triplicate dotted line 0.35mm \r
A,8.4,-1.05,.175,-1.05,.175,-1.05,0.175,-1.05\r
*07b035,Dotted line 0.35mm \r
A,.175,-1.05\r
*08b035,Long dashed short dashed line 0.35mm \r
A,8.4,-1.05,2.1,-1.05\r
*09b035,Long dashed double-short-dashed line 0.35mm \r
A,8.4,-1.05,2.1,-1.05,2.1,-1.05\r
*10b035,Lashed dotted line 0.35mm \r
A,4.2,-1.05,0.175,-1.05\r
*11b035,Double-dashed dotted line 0.35mm \r
A,4.2,-1.05,4.2,-1.05,.175,-1.05\r
*12b035,Dashed double-dotted line 0.35mm \r
A,4.2,-1.05,.175,-1.05,.175,-1.05\r
*13b035,Double-dashed double-dotted line 0.35mm \r
A,4.2,-1.05,4.2,-1.05,.175,-1.05,.175,-1.05\r
*14b035,Dashed triplicate-dotted line 0.35mm \r
A,4.2,-1.05,.175,-1.05,.175,-1.05,.175,-1.05\r
*15b035,Double-dashed triplicate-dotted line 0.35mm \r
A,4.2,-1.05,4.2,-1.05,.175,-1.05,.175,-1.05,.175,-1.05\r
*02b05,Dashed line 0.5mm \r
A,6,-1.5\r
*03b05,Dashed space line 0.5mm \r
A,6,-9\r
*04b05,Long dashed dotted line 0.5mm \r
A,12,-1.5,0.25,-1.5\r
*05b05,Long dash double dotted line 0.5mm \r
A,12,-1.5,0.25,-1.5,0.25,-1.5\r
*06b05,Long dashed triplicate dotted line 0.5mm \r
A,12,-1.5,0.25,-1.5,.25,-1.5,0.25,-1.5\r
*07b05,Dotted line 0.5mm \r
A,0.25,-1.5\r
*08b05,Long dashed short dashed line 0.5mm \r
A,12,-1.5,3,-1.5\r
*09b05,Long dashed double-short-dashed line 0.5mm \r
A,12,-1.5,3,-1.5,3,-1.5\r
*10b05,Dashed dotted line 0.5mm \r
A,6,-1.5,0.25,-1.5\r
*11b05,Double-dashed dotted line 0.5mm \r
A,6,-1.5,6,-1.5,0.25,-1.5\r
*12b05,Dashed double-dotted line 0.5mm \r
A,6,-1.5,.25,-1.5,0.25,-1.5\r
*13b05,Double-dashed double-dotted line 0.5mm \r
A,6,-1.5,6,-1.5,0.25,-1.5,0.25,-1.5\r
*14b05,Dashed triplicate-dotted line 0.5mm \r
A,6,-1.5,0.25,-1.5,0.25,-1.5,0.25,-1.5\r
*15b05,Double-dashed triplicate-dotted line 0.5mm \r
A,6,-1.5,6,-1.5,0.25,-1.5,0.25,-1.5,0.25,-1.5\r
*02b07,Dashed Line 0.7mm \r
A,8.4,-2.1\r
*03b07,Dashed space line 0.7mm \r
A,8.4,-12.6\r
*04b07,Long dashed dotted line 0.7mm \r
A,16.8,-2.1,0.35,-2.1\r
*05b07,Long dash double dotted line 0.7mm \r
A,16.8,-2.1,0.35,-2.1,0.35,-2.1\r
*06b07,Long dashed triplicate dotted line 0.7mm \r
A,16.8,-2.1,0.35,-2.1,0.35,-2.1,0.35,-2.1\r
*07b07,Dotted line 0.7mm \r
A,0.35,-2.1\r
*08b07,Long dashed short dashed line 0.7mm \r
A,16.8,-2.1,4.2,-2.1\r
*09b07,Long dashed double-short-dashed line 0.7mm \r
A,16.8,-2.1,4.2,-2.1,4.2,-2.1\r
*10b07,Dashed dotted line 0.7mm \r
A,8.4,-2.1,0.35,-2.1\r
*11b07,Double-dashed dotted line 0.7mm \r
A,8.4,-2.1,8.4,-2.1,0.35,-2.1\r
*12b07,Dashed double-dotted line 0.7mm \r
A,8.4,-2.1,0.35,-2.1,0.35,-2.1\r
*13b07,Double-dashed double-dotted line 0.7mm \r
A,8.4,-2.1,8.4,-2.1,0.35,-2.1,0.35,-2.1\r
*14b07,Dashed triplicate-dotted line 0.7mm \r
A,8.4,-2.1,0.35,-2.1,0.35,-2.1,0.35,-2.1\r
*15b07,Double-dashed triplicate-dotted line 0.7mm \r
A,8.4,-2.1,8.4,-2.1,0.35,-2.1,0.35,-2.1,0.35,-2.1\r
*02b1,Dashed Line 1mm \r
A,12,-3\r
*03b1,Dashed space line 1mm \r
A,12,-18\r
*04b1,Long dashed dotted line 1mm \r
A,24,-3,.5,-3\r
*05b1,Long dash double dotted line 1mm \r
A,24,-3,.5,-3,.5,-3\r
*06b1,Long dashed triplicate dotted line 1mm \r
A,24,-3,.5,-3,.5,-3,.5,-3\r
*07b1,Dotted line\r
A,.5,-3\r
*08b1,Long dashed short dashed line 1mm \r
A,24,-3,6,-3\r
*09b1,Long dashed double-short-dashed line 1mm \r
A,24,-3,6,-3,6,-3\r
*10b1,Dashed dotted line 1mm \r
A,12,-3,.5,-3\r
*11b1,Double-dashed dotted line 1mm \r
A,12,-3,12,-3,0.5,-3\r
*12b1,Dashed double-dotted line 1mm \r
A,12,-3,0.5,-3,0.5,-3\r
*13b1,Double-dashed double-dotted line 1mm \r
A,12,-3,12,-3,0.5,-3,0.5,-3\r
*14b1,Dashed triplicate-dotted line 1mm \r
A,12,-3,0.5,-3,0.5,-3,0.5,-3\r
*15b1,Double-dashed triplicate-dotted line 1mm \r
A,12,-3,12,-3,0.5,-3,.5,-3,0.5,-3\r
*02b14,Dashed Line 1.4mm \r
A,16.8,-4.2\r
*03b14,Dashed space line 1.4mm \r
A,16.8,25.2\r
*04b14,Long dashed dotted line 1.4mm \r
A,33.6,-4.2,.7,-4.2\r
*05b14,Long dash double dotted line 1.4mm \r
A,33.6,-4.2,.7,-4.2,.7,-4.2\r
*06b14,Long dashed triplicate dotted line 1.4mm \r
A,33.6,-4.2,.7,-4.2,.7,-4.2,.7,-4.2\r
*07b14,Dotted line 1.4mm \r
A,.7,-4.2\r
*08b14,Long dashed short dashed line 1.4mm \r
A,33.6,-4.2,8.4,-4.2\r
*09b14,Long dashed double-short-dashed line 1.4mm \r
A,33.6,-4.2,8.4,-4.2,8.4,-4.2\r
*10b14,Dashed dotted line 1.4mm \r
A,16.8,-4.2,.7,-4.2\r
*11b14,Double-dashed dotted line 1.4mm \r
A,16.8,-4.2,16.8,-4.2,.7,-4.2\r
*12b14,Dashed double-dotted line 1.4mm \r
A,16.8,-4.2,.7,-4.2,.7,-4.2\r
*13b14,Double-dashed double-dotted line 1.4mm \r
A,16.8,-4.2,16.8,-4.2,.7,-4.2,.7,-4.2\r
*14b14,Dashed triplicate-dotted line 1.4mm \r
A,16.8,-4.2,.7,-4.2,.7,-4.2,.7,-4.2\r
*15b14,Double-dashed triplicate-dotted line 1.4mm \r
A,16.8,-4.2,16.8,-4.2,.7,-4.2,.7,-4.2,.7,-4.2\r
*02b2,Dashed Line 2mm \r
A,24,-6\r
*03b2,Dashed space line 2mm \r
A,24,-36\r
*04b2,Long dashed dotted line 2mm \r
A,48,-6,1,-6\r
*05b2,Long dash double dotted line 2mm \r
A,48,-6,1,-6,1,-6\r
*06b2,Long dashed triplicate dotted line 2mm \r
A,48,-6,1,-6,1,-6,1,-6\r
*07b2,Dotted line 2mm \r
A,1,-6\r
*08b2,Long dashed short dashed line 2mm \r
A,48,-6,12,-6\r
*09b2,Long dashed double-short-dashed line 2mm \r
A,48,-6,12,-6,12,-6\r
*10b2,Dashed dotted line 2mm \r
A,24,-6,1,-6\r
*11b2,Double-dashed dotted line 2mm \r
A,24,-6,24,-6,1,-6\r
*12b2,Dashed double-dotted line 2mm \r
A,24,-6,1,-6,1,-6\r
*13b2,Double-dashed double-dotted line 2mm \r
A,24,-6,24,-6,1,-6,1,-6\r
*14b2,Dashed triplicate-dotted line 2mm \r
A,24,-6,1,-6,1,-6,1,-6\r
*15b2,Double-dashed triplicate-dotted line 2mm \r
A,24,-6,24,-6,1,-6,1,-6,1,-6\r
;; Complex linetypes using standard style\r
*FENCELINE1,Fenceline_circle ----0-----0----0-----0----0-----0--\r
A,.25,-.1,[CIRC1,ltypeshp.shx,x=-.1,s=.1],-.1,.1\r
*FENCELINE2,Fenceline square ----[]-----[]----[]-----[]----[]---\r
A,.25,-.1,[BOX,ltypeshp.shx,x=-.1,s=.1],-.1,1\r
*TRACKS,Tracks -|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-\r
A,.15,[TRACK1,ltypeshp.shx,s=.25],.15\r
*MAP,Map line ----MAP----MAP----MAP----MAP----MAP---- \r
A,.5,-.2,["MAP",STANDARD,S=.1,R=0.0,X=-0.1,Y=-.05],-.25\r
*BATTING,Batting SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS\r
A,.0001,-.1,[BAT,ltypeshp.shx,x=-.1,s=.1],-.2,[BAT,ltypeshp.shx,r=180,x=.1,s=.1],-.1\r
*ZIGZAG,Zig zag /\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\r
A,.0001,-.2,[ZIG,ltypeshp.shx,x=-.2,s=.2],-.4,[ZIG,ltypeshp.shx,r=180,x=.2,s=.2],-.2\r
*HOT_WATER_SUPPLY,Hot water supply ---- HW ---- HW ---- HW ----\r
A,12.7,-5.08,["HW",STANDARD,S=2.54,R=0.0,X=-2.54,Y=-1.27],-5.08\r
*GAS_LINE,Gas line ----GAS----GAS----GAS----GAS----GAS----GAS--\r
A,.5,-.2,["GAS",STANDARD,S=.1,U=0.0,X=-0.1,Y=-.05],-.25\r
*SMILEYS,Smiley line ---- :^) ---- 8) ---- :^) ----\r
A,12.7,-5.08,[":^)",STANDARD,S=2.54,R=0.0,X=-2.54,Y=-1.27],-5.08,12.7,-5.08,["8)",STANDARD,S=2.54,R=0.0,X=-2.54,Y=-1.27],-5.08\r
\r
;------------Slope--------------\r
*SLOPE,1B 1S |-|-|-|-|-|-|-|-|-|-|-|-\r
A,0.13,[TRACK1,ltypeshp.shx,S=0.52,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.26],0.13\r
*SLOPE-D, 1B 1S Double |-|-|-|-|-|-|-|-|-|-|-|-\r
A,0.13,[TRACK1,ltypeshp.shx,S=1.04,R=0.0,X=0,Y=1.04],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.26],0.13\r
*SLOPE2, 1B 2S ||-||-||-||-||-||-||-||-||-||-||-||-\r
A,0.13,[TRACK1,ltypeshp.shx,S=0.52,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.26],0.13\r
*SLOPE2-D, 1B 2S Double ||-||-||-||-||-||-||-||-||-||-||-||-\r
A,0.13,[TRACK1,ltypeshp.shx,S=1.04,R=0.0,X=0,Y=1.04],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.26],0.13\r
*SLOPE3, 1B 3S |||-|||-|||-|||-|||-|||-|||-|||-|||-|||-|||-|||-\r
A,0.13,[TRACK1,ltypeshp.shx,S=0.52,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.26],0.13\r
*SLOPE3-D, 1B 3S Double |||-|||-|||-|||-|||-|||-|||-|||-|||-|||-|||-|||-\r
A,0.13,[TRACK1,ltypeshp.shx,S=1.04,R=0.0,X=0,Y=1.04],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.26],0.13\r
*SLOPE4, 1B 4S ||||-||||-||||-||||-||||-||||-||||-||||-||||-||||-\r
A,0.13,[TRACK1,ltypeshp.shx,S=0.52,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.26],0.13\r
*SLOPE4-D, 1B 4S Double ||||-||||-||||-||||-||||-||||-||||-||||-||||-||||-\r
A,0.13,[TRACK1,ltypeshp.shx,S=1.04,R=0.0,X=0,Y=1.04],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.26],0.13\r
*SLOPE5, 1B 5S |||||-|||||-|||||-|||||-|||||-|||||-|||||-|||||-|||||-|||||-\r
A,0.13,[TRACK1,ltypeshp.shx,S=0.52,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.26],0.13\r
*SLOPE5-D, 1B 5S Double |||||-|||||-|||||-|||||-|||||-|||||-|||||-|||||-|||||-|||||-\r
A,0.13,[TRACK1,ltypeshp.shx,S=1.04,R=0.0,X=0,Y=1.04],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.26],0.13\r
\r
;------------Alphabets--------------\r
*Letter A, ---- A ---- A ---- A ---- A ---- A ----\r
A,1.0,-0.5,["A",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r
*Letter B, ---- B ---- B ---- B ---- B ---- B ----\r
A,1.0,-0.5,["B",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r
*Letter C,---- C ---- C ---- C ---- C ---- C ----\r
A,1.0,-0.5,["C",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r
*Letter D, ---- D ---- D ---- D ---- D ---- D ----\r
A,1.0,-0.5,["D",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r
*Letter E, ---- E ---- E ---- E ---- E ---- E ----\r
A,1.0,-0.5,["E",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r
*Letter F, ---- F ---- F ---- F ---- F ---- F ----\r
A,1.0,-0.5,["F",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r
*Letter G, ---- G ---- G ---- G ---- G ---- G ----\r
A,1.0,-0.5,["G",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r
*Letter H, ---- H ---- H ---- H ---- H ---- H ----\r
A,1.0,-0.5,["H",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r
*Letter I, ---- I ---- I ---- I ---- I ---- I ----\r
A,1.0,-0.5,["I",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r
*Letter J, ---- J ---- J ---- J ---- J ---- J ----\r
A,1.0,-0.5,["J",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r
*Letter K, ---- K ---- K ---- K ---- K ---- K ----\r
A,1.0,-0.5,["K",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r
*Letter L, ---- L ---- L ---- L ---- L ---- L ----\r
A,1.0,-0.5,["L",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r
*Letter M, ---- M ---- M ---- M ---- M ---- M ----\r
A,1.0,-0.5,["M",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r
*Letter N, ---- N ---- N ---- N ---- N ---- N ----\r
A,1.0,-0.5,["N",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r
*Letter O, ---- O ---- O ---- O ---- O ---- O ----\r
A,1.0,-0.5,["O",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r
*Letter P, ---- P ---- P ---- P ---- P ---- P ----\r
A,1.0,-0.5,["P",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r
*Letter Q, ---- Q ---- Q ---- Q ---- Q ---- Q ----\r
A,1.0,-0.5,["Q",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r
*Letter R, ---- R ---- R ---- R ---- R ---- R ----\r
A,1.0,-0.5,["R",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r
*Letter S, ---- S ---- S ---- S ---- S ---- S ----\r
A,1.0,-0.5,["S",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r
*Letter T, ---- T ---- T ---- T ---- T ---- T ----\r
A,1.0,-0.5,["T",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r
*Letter U, ---- U ---- U ---- U ---- U ---- U ----\r
A,1.0,-0.5,["U",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r
*Letter V, ---- V ---- V ---- V ---- V ---- V ----\r
A,1.0,-0.5,["V",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r
*Letter W, ---- W ---- W ---- W ---- W ---- W ----\r
A,1.0,-0.5,["W",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r
*Letter X, ---- X ---- X ---- X ---- X ---- X ----\r
A,1.0,-0.5,["X",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r
*Letter Y, ---- Y ---- Y ---- Y ---- Y ---- Y ----\r
A,1.0,-0.5,["Y",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r
*Letter Z, ---- Z ---- Z ---- Z ---- Z ---- Z ----\r
A,1.0,-0.5,["Z",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r
\r
;------------Numericals--------------\r
*Numbers 0, ---- 0 ---- 0 ---- 0 ---- 0 ---- 0 ----\r
A,1.0,-0.5,["0",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r
*Numbers 1, ---- 1 ---- 1 ---- 1 ---- 1 ---- 1 ----\r
A,1.0,-0.5,["1",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r
*Numbers 2, ---- 2 ---- 2 ---- 2 ---- 2 ---- 2 ----\r
A,1.0,-0.5,["2",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r
*Numbers 3, ---- 3 ---- 3 ---- 3 ---- 3 ---- 3 ----\r
A,1.0,-0.5,["3",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r
*Numbers 4, ---- 4 ---- 4 ---- 4 ---- 4 ---- 4 ----\r
A,1.0,-0.5,["4",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r
*Numbers 5, ---- 5 ---- 5 ---- 5 ---- 5 ---- 5 ----\r
A,1.0,-0.5,["5",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r
*Numbers 6, ---- 6 ---- 6 ---- 6 ---- 6 ---- 6 ----\r
A,1.0,-0.5,["6",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r
*Numbers 7, ---- 7 ---- 7 ---- 7 ---- 7 ---- 7 ----\r
A,1.0,-0.5,["7",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r
*Numbers 8, ---- 8 ---- 8 ---- 8 ---- 8 ---- 8 ----\r
A,1.0,-0.5,["8",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r
*Numbers 9, ---- 9 ---- 9 ---- 9 ---- 9 ---- 9 ----\r
A,1.0,-0.5,["9",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r
\r
\r
`,CE=`;; ------------------------------------ ------------------------------------\r
;; (KOSDIC.lin) ǼCALS/EC ڵ ۼǥ Ͽ ǵ \r
;; AutoCAD ڿ ϱ ۵Ǿϴ.\r
;; \r
;; ǥع : ǼCALS/EC ڵ ۼǥ V1.1(2006.12)\r
;; : ǼCALS/EC ѱǼ\r
;;\r
;; Ģ : 1/1 ô ũ 2.0mm ũ\r
;; LIB Ģ : AutoCAD ANSI( ) Ű 1/10 \r
;; () 2mm̸ 0.2unit \r
;; Ģ : ǹ Ģ յǷ ô 10\r
;; () LTSCALE=10 ( 8~10), ô 1/5 ̸ LTSCALE=5x10=50\r
;;\r
;; ISO ԰ 15\r
// AutoCAD ISO 25.4 \r
*A-ISONS01,ISO ԰ 01 Continuous ________________________________\r
A,1,1\r
*A-ISONS02,ISO ԰ 02 dash __ __ __ __ __ __ __ __ __ __ __ __ __\r
A,.47244,-.118111\r
*A-ISONS03,ISO ԰ 03 dash space __ __ __ __ __ __\r
A,.47244,-.7086614\r
*A-ISONS04,ISO ԰ 04 long-dash dot ____ . ____ . ____ . ____ . _\r
A,.94488,-.11811,0,-.11811\r
*A-ISONS05,ISO ԰ 05 long-dash double-dot ____ .. ____ .. ____ . \r
A,.94488,-.11811,0,-.11811,0,-.11811\r
*A-ISONS06,ISO ԰ 06 long-dash triple-dot ____ ... ____ ... ____\r
A,.94488,-.11811,0,-.11811,0,-.11811,0,-.11811\r
*A-ISONS07,ISO ԰ 07 dot . . . . . . . . . . . . . . . . . . . . \r
A,0,-.11811\r
*A-ISONS08,ISO ԰ 08 long-dash short-dash ____ __ ____ __ ____ _\r
A,.94488,-.11811,.94488,-.11811\r
*A-ISONS09,ISO ԰ 09 long-dash double-short-dash ____ __ __ ____\r
A,.94488,-.11811,.94488,-.11811,.94488,-.11811\r
*A-ISONS10,ISO ԰ 10 dash dot __ . __ . __ . __ . __ . __ . __ . \r
A,.47244,-.11811,0,-.11811\r
*A-ISONS11,ISO ԰ 11 double-dash dot __ __ . __ __ . __ __ . __ _\r
A,.47244,-.11811,.47244,-.11811,0,-.11811\r
*A-ISONS12,ISO ԰ 12 dash double-dot __ . . __ . . __ . . __ . . \r
A,.47244,-.11811,0,-.11811,0,-.11811\r
*A-ISONS13,ISO ԰ 13 double-dash double-dot __ __ . . __ __ . . _\r
A,.47244,-.11811,.47244,-.11811,0,-.11811,0,-.11811\r
*A-ISONS14,ISO ԰ 14 dash triple-dot __ . . . __ . . . __ . . . _\r
A,.47244,-.11811,0,-.11811,0,-.11811,0,-.11811\r
*A-ISONS15,ISO ԰ 15 double-dash triple-dot __ __ . . . __ __ . .\r
A,.47244,-.11811,.47244,-.11811,0,-.11811,0,-.11811,0,-.11811\r
\r
;; CAD \r
*A-BORDR01,ܰ(Ϲ) Border __ __ . __ __ . __ __ . __ __ . __ __ .\r
A,.5,-.25,.5,-.25,0,-.25\r
*A-BORDR01H,ܰ(ݹ) Border (.5x) __.__.__.__.__.__.__.__.__.__.__.\r
A,.25,-.125,.25,-.125,0,-.125\r
*A-BORDR01X,ܰ() Border (2x) ____ ____ . ____ ____ . ___\r
A,1.0,-.5,1.0,-.5,0,-.5\r
*A-CENTR01,߽ɼ(Ϲ) Center ____ _ ____ _ ____ _ ____ _ ____ _ ____\r
A,1.25,-.25,.25,-.25\r
*A-CENTR01H,߽ɼ(ݹ) Center (.5x) ___ _ ___ _ ___ _ ___ _ ___ _ ___\r
A,.75,-.125,.125,-.125\r
*A-CENTR01X,߽ɼ() Center (2x) ________ __ ________ __ _____\r
A,2.5,-.5,.5,-.5\r
*A-DASDT01,Ĵ(Ϲ) Dash dot __ . __ . __ . __ . __ . __ . __ . __\r
A,.5,-.25,0,-.25\r
*A-DASDT01H,Ĵ(ݹ) Dash dot (.5x) _._._._._._._._._._._._._._._.\r
A,.25,-.125,0,-.125\r
*A-DASDT01X,Ĵ() Dash dot (2x) ____ . ____ . ____ . ___\r
A,1.0,-.5,0,-.5\r
*A-DASHD01,ļ(Ϲ) Dashed __ __ __ __ __ __ __ __ __ __ __ __ __ _\r
A,.5,-.25\r
*A-DASHD01H,ļ(ݹ) Dashed (.5x) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ \r
A,.25,-.125\r
*A-DASHD01X,ļ() Dashed (2x) ____ ____ ____ ____ ____ ___\r
A,1.0,-.5\r
*A-DIVID01,Ҽ(Ϲ) Divide ____ . . ____ . . ____ . . ____ . . ____\r
A,.5,-.25,0,-.25,0,-.25\r
*A-DIVID01H,Ҽ(ݹ) Divide (.5x) __..__..__..__..__..__..__..__.._\r
A,.25,-.125,0,-.125,0,-.125\r
*A-DIVID01X,Ҽ() Divide (2x) ________ . . ________ . . _\r
A,1.0,-.5,0,-.5,0,-.5\r
*A-DOTLN01,(Ϲ) Dot . . . . . . . . . . . . . . . . . . . . . . . .\r
A,0,-.25\r
*A-DOTLN01H,(ݹ) Dot (.5x) ........................................\r
A,0,-.125\r
*A-DOTLN01X,() Dot (2x) . . . . . . . . . . . . . .\r
A,0,-.5\r
*A-HIDDN01,(Ϲ) Hidden __ __ __ __ __ __ __ __ __ __ __ __ __ __\r
A,.25,-.125\r
*A-HIDDN01H,(ݹ) Hidden (.5x) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ \r
A,.125,-.0625\r
*A-HIDDN01X,() Hidden (2x) ____ ____ ____ ____ ____ ____ ____ \r
A,.5,-.25\r
*A-PHATM01,(Ϲ) Phantom ______ __ __ ______ __ __ ______ \r
A,1.25,-.25,.25,-.25,.25,-.25\r
*A-PHATM01H,(ݹ) Phantom (.5x) ___ _ _ ___ _ _ ___ _ _ ___ _ _\r
A,.625,-.125,.125,-.125,.125,-.125\r
*A-PHATM01X,() Phantom (2x) ____________ ____ ____ _\r
A,2.5,-.5,.5,-.5,.5,-.5\r
\r
;; ü\r
*E-FENCE01,潺(X ļ)\r
A,.85,-.15,[KSC11,kosdic.shx,s=.1],-.15,.85\r
*E-FENCE02,潺(X Ǽ)\r
A,1.0,[KSC11,kosdic.shx,s=.1],1.0\r
*E-FENCE03,潺(/\\ ļ)\r
A,.875,-.05,[KSC12,kosdic.shx,s=.1],-.2,.875\r
*E-FENCE04,潺(+ ļ)\r
A,.85,-.15,[KSC15,kosdic.shx,s=.1],-.15,.85\r
\r
;; \r
*E-UTIL01,(| Ǽ)\r
A,1.0,[KSC01,kosdic.shx,s=.1],1.0\r
*E-UTIL02,(|| ļ)\r
A,.05,[KSC01,kosdic.shx,s=.1],-.1,[KSC01,kosdic.shx,s=.1],1.85\r
*E-UTIL03,(|| Ǽ)\r
A,.95,[KSC01,kosdic.shx,s=.1],.1,[KSC01,kosdic.shx,s=.1],.95\r
*E-UTIL04,(||| ļ)\r
A,.9,[KSC01,kosdic.shx,s=.1],-.1,[KSC01,kosdic.shx,s=.1],-.1,[KSC01,kosdic.shx,s=.1],.9\r
*E-UTIL05,(||| Ǽ)\r
A,.9,[KSC01,kosdic.shx,s=.1],.1,[KSC01,kosdic.shx,s=.1],.1,[KSC01,kosdic.shx,s=.1],.9\r
*E-UTIL06,(/ ļ)\r
A,.9,-.1,[KSC02,kosdic.shx,s=.1],-.1,.9\r
*E-UTIL07,(/ Ǽ)\r
A,1.0,[KSC02,kosdic.shx,s=.1],1.0\r
*E-UTIL08,(// ļ)\r
A,.85,-.15,[KSC05,kosdic.shx,s=.1],-.15,.85\r
*E-UTIL09,(// Ǽ)\r
A,1.0,[KSC05,kosdic.shx,s=.1],1.0\r
*E-UTIL10,(/// ļ)\r
A,.8,-.2,[KSC06,kosdic.shx,s=.1],-.2,.8\r
*E-UTIL11,(/// Ǽ)\r
A,1.0,[KSC06,kosdic.shx,s=.1],1.0\r
\r
;; ü\r
*E-FACLN01,ü(- ༱)\r
A,.25,[KSC01,kosdic.shx,y=-.05,s=.1,r=270],.25\r
*E-FACLN02,ü(= ༱)\r
A,.25,[KSC04,kosdic.shx,y=-.05,s=.1],.25\r
*E-FACLN03,ü(O ļ)\r
A,.85,[KSC31,kosdic.shx,x=.075,s=.075],-.15,1.0\r
*E-FACLN04,ü(O Ǽ)\r
A,1.0,[KSC31,kosdic.shx,s=.075],1.0\r
*E-FACLN05,ü(,Ʈ)\r
A,1.0,[KSC32,kosdic.shx,s=.075],1.0\r
\r
;; \r
*E-TOPOG01,( ļ)\r
A,.000002,[KSC16,kosdic.shx,s=.1],-.25\r
*E-TOPOG02,( Ǽ)\r
A,.000002,[KSC16,kosdic.shx,s=.1],-.2\r
*E-TOPOG03,(| Ǽ)\r
A,0,-.1,[KSC15,kosdic.shx,s=.1],-.1\r
*E-TOPOG04,(| )\r
A,0,[KSC00,kosdic.shx,y=.1,s=.1],.2,[KSC00,kosdic.shx,s=.1],.2\r
*E-TOPOG05,(~. )\r
A,.000005,[KSC1C,kosdic.shx,s=.1],-.45,[KSC30,kosdic.shx,s=.1],-.05\r
\r
;; \r
*B-ZIGZG01,()\r
A,.000002,[KSC13,kosdic.shx,s=.1],-.2\r
*B-ZIGZG02,(ȣ)\r
A,.000002,[KSC1B,kosdic.shx,s=.1],-.2\r
*C-ZIGZG01,(Ǽ,)\r
A,.1,[KSC13,kosdic.shx,s=.1],.1\r
*C-ZIGZG02,(Ǽ,ȣ)\r
A,.1,[KSC1B,kosdic.shx,s=.1],.1\r
\r
;; \r
*D-SWALL01,(ű)\r
A,0,[KSC61,kosdic.shx,y=-.1,s=.1],-.2\r
*X-SWALL01,()\r
A,0,[KSC71,kosdic.shx,s=.1],-.4\r
*D-BWALL01,ϴ()\r
A,0,[KSC18,kosdic.shx,s=.1],-.25\r
*D-BWALL02,ϴ(ű)\r
A,.000005,[KSC3A,kosdic.shx,s=.05],-.1,[KSC3A,kosdic.shx,s=.05],-.1,[KSC04,kosdic.shx,y=-.025,s=.05],-.1,[KSC04,kosdic.shx,y=-.025,s=.05],-.1,[KSC04,kosdic.shx,y=-.025,s=.05],-.05\r
\r
;; /迭\r
*E-DOTLN01,ҹ迭\r
A,0,[KSC30,kosdic.shx,s=.3],-.15\r
*E-DOTLN02,ҹ迭()\r
A,.075,[KSC30,kosdic.shx,s=.3],.075\r
*E-CIRCL01,Ϲ迭\r
A,0,[KSC31,kosdic.shx,s=.1],-.2\r
*E-CIRCL02,äϹ迭\r
A,0,[KSC32,kosdic.shx,s=.1],-.2\r
*D-RROAD01,ö()\r
A,0,[KSC3A,kosdic.shx,s=.1],-.2,[KSC04,kosdic.shx,y=-.05,s=.1],-.2\r
\r
;; \r
*E-DIGLN01,\r
A,.9,-.2,[KSC19,kosdic.shx,s=.1,r=180],.9\r
*E-DIGLN01H,(ݹ)\r
A,.45,-.1,[KSC19,kosdic.shx,s=.05,r=180],.45\r
*E-DIGLN01X,()\r
A,1.8,-.4,[KSC19,kosdic.shx,s=.2,r=180],1.8\r
\r
;; \r
*B-GREEN01,/\r
A,.000002,[KSC08,kosdic.shx,s=.1],-.2\r
*B-GREEN02,\r
A,0,[KSC21,kosdic.shx,s=.1],-.45\r
*E-BOUND01,\r
A,.875,[KSC60,kosdic.shx,s=.1],-.25,.875\r
\r
;; Ÿ\r
*B-RANDM01,ұĢ\r
A,0,[KSC1A,kosdic.shx,s=.1],-.2\r
*E-DEMOL01,öŴ\r
A,.075,[KSC01,kosdic.shx,s=.1,r=30],.075\r
*X-EARTH01,ݼ\r
A,0,[KSC20,kosdic.shx,s=.1,x=.25,r=180],.25\r
\r
;; ܼ\r
*E-CUTLN01,ܼ()\r
A,.95,[KSC14,kosdic.shx,s=.1],-.1,.95\r
*E-CUTLN02,ܼ(ȣ)\r
A,.95,[KSC22,kosdic.shx,s=.1],-.1,.95\r
\r
;; \r
*E-WFLOW01,帧(, ļ)\r
A,.6,[KSC36,kosdic.shx,s=.1],-.65\r
*E-WFLOW02,帧(, Ǽ)\r
A,1.5,[KSC36,kosdic.shx,s=.1],0\r
*E-WFLOW03,帧(ȭ, ļ)\r
A,.6,[KSC35,kosdic.shx,s=.1],-.65\r
*E-WFLOW04,帧(ȭ, Ǽ)\r
A,1.5,[KSC35,kosdic.shx,s=.1],0\r
\r
;; \r
*G-WATER01,(W )\r
A,2.933333,["W",Standard,y=.05,s=.2],.066667\r
*G-WATER02,(W ļ)\r
A,2.75,-.05,["W",Standard,y=-.1,s=.2,r=360],-.2\r
\r
;; ¼\r
*G-HWATR01,¼(HWL )\r
A,2.783629,["HWL",Standard,y=.05,s=.2],.216371\r
*G-HWATR02,¼(HWL ļ)\r
A,2.35,-.05,["HWL",Standard,y=-.1,s=.2],-.6\r
\r
;; ü\r
*G-CWATR01,ü(CWL )\r
A,2.783629,["CWL",Standard,y=.05,s=.2],.216371\r
*G-CWATR02,ü(CWL ļ)\r
A,2.35,-.05,["CWL",Standard,y=-.1,s=.2],-.6\r
\r
;; \r
*E-SEWER01,()\r
A,.95,-.1,[KSC09,kosdic.shx,s=.1,r=180],.95\r
*E-SEWER01H,(,ݹ)\r
A,.475,-.05,[KSC09,kosdic.shx,s=.05,r=180],.475\r
*E-SEWER01X,(,)\r
A,1.9,-.2,[KSC09,kosdic.shx,s=.2,r=180],1.9\r
*G-SEWER01,(S )\r
A,2.933333,["S",Standard,y=.05,s=.2],.066667\r
*G-SEWER02,(S ļ)\r
A,2.75,-.05,["S",Standard,y=-.1,s=.2,r=360],-.2\r
\r
;; ż\r
*G-TELCM01,ż(T )\r
A,2.933333,["T",Standard,y=.05,s=.2],.066667\r
*G-TELCM02,ż(T ļ)\r
A,2.75,-.05,["T",Standard,y=-.1,s=.2,r=360],-.2\r
\r
;; \r
*G-ELECT01,(E )\r
A,2.933333,["E",Standard,y=.05,s=.2],.066667\r
*G-ELECT02,(E ļ)\r
A,2.75,-.05,["E",Standard,y=-.1,s=.2,r=360],-.2\r
\r
;; \r
*G-GASLN01,(G )\r
A,2.933333,["G",Standard,y=.05,s=.2],.066667\r
*G-GASLN02,(G ļ)\r
A,2.75,-.05,["G",Standard,y=-.1,s=.2,r=360],-.2\r
*G-GASLN03,(GAS )\r
A,2.783629,["GAS",Standard,y=.05,s=.2],.216371\r
*G-GASLN04,(GAS ļ)\r
A,2.35,-.05,["GAS",Standard,y=-.1,s=.2],-.6\r
\r
;; Ϲ\r
;; *CAL421,PIPE\r
;; A,2.733333,["PIPE",Standard,y=.05,s=.2],.266667\r
*G-PIPEL01,Ϲ (PIPE ļ)\r
A,3.25,-.05,["PIPE",Standard,y=-.1,s=.2],-.7\r
\r
;; \r
*H-DICHT00,\r
A,1.1,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["T",Standard,y=-.1,s=.2,r=360],-.216667\r
*H-DICHT00R,()\r
A,1.1,[KSC35,kosdic.shx,s=.1],-.466667,["T",Standard,y=.1,s=.2,r=180],-.083333\r
\r
;; L\r
*H-DICHL00,L 00\r
A,1.1,[KSC35,kosdic.shx,s=.1],-.333333,["L",Standard,y=-.1,s=.2],-.216667\r
*H-DICHL00R,L 00()\r
A,1.1,[KSC35,kosdic.shx,s=.1],-.466667,["L",Standard,y=.1,s=.2,r=180],-.083333\r
*H-DICHL01,L 01\r
A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.366667,["L1",Standard,y=-.1,s=.2,r=360],-.383333\r
*H-DICHL01R,L 01()\r
A,.9,[KSC35,kosdic.shx,s=.1],-.633333,["L1",Standard,y=.1,s=.2,r=180],-.116667\r
*H-DICHL02,L 02\r
A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["L2",Standard,y=-.1,s=.2],-.416667\r
*H-DICHL02R,L 02()\r
A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["L2",Standard,y=.1,s=.2,r=180],-.083333\r
*H-DICHL03,L 03\r
A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["L3",Standard,y=-.1,s=.2,r=360],-.416667\r
*H-DICHL03R,L 03()\r
A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["L3",Standard,y=.1,s=.2,r=180],-.083333\r
*H-DICHL04,L 04\r
A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["L4",Standard,y=-.1,s=.2],-.416667\r
*H-DICHL04R,L 04()\r
A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["L4",Standard,y=.1,s=.2,r=180],-.083333\r
*H-DICHL05,L 05\r
A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["L5",Standard,y=-.1,s=.2],-.416667\r
*H-DICHL05R,L 05()\r
A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.666667,["L5",Standard,y=.1,s=.2,r=180],-.083333\r
*H-DICHL06,L 06\r
A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["L6",Standard,y=-.1,s=.2],-.416667\r
*H-DICHL06R,L 06()\r
A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.666667,["L6",Standard,y=.1,s=.2,r=180],-.083333\r
*H-DICHL07,L 07\r
A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["L7",Standard,y=-.1,s=.2],-.416667\r
*H-DICHL07R,L 07()\r
A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["L7",Standard,y=.1,s=.2,r=180],-.083333\r
*H-DICHL08,L 08\r
A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["L8",Standard,y=-.1,s=.2],-.416667\r
*H-DICHL08R,L 08()\r
A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["L8",Standard,y=.1,s=.2,r=180],-.083333\r
*H-DICHL09,L 09\r
A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["L9",Standard,y=-.1,s=.2,r=360],-.416667\r
*H-DICHL09R,L 09()\r
A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.666667,["L9",Standard,y=.1,s=.2,r=180],-.083333\r
*H-DICHL10,L 10\r
A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.383333,["L10",Standard,y=-.1,s=.2,r=360],-.566667\r
*H-DICHL10R,L 10()\r
A,.7,[KSC35,kosdic.shx,s=.1],-.816667,["L10",Standard,y=.1,s=.2,r=180],-.133333\r
*H-DICHL11,L 11\r
A,.7,[KSC35,kosdic.shx,s=.1],-.4,["L11",Standard,y=-.1,s=.2],-.55\r
*H-DICHL11R,L 11()\r
A,.7,[KSC35,kosdic.shx,s=.1],-.8,["L11",Standard,y=.1,s=.2,r=180],-.15\r
*H-DICHL12,L 12\r
A,.7,[KSC35,kosdic.shx,s=.1],-.366667,["L12",Standard,y=-.1,s=.2],-.583333\r
*H-DICHL12R,L 12()\r
A,.7,[KSC35,kosdic.shx,s=.1],-.833333,["L12",Standard,y=.1,s=.2,r=180],-.116667\r
*H-DICHL13,L 13\r
A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.366667,["L13",Standard,y=-.1,s=.2,r=360],-.583333\r
*H-DICHL13R,L 13()\r
A,.7,[KSC35,kosdic.shx,s=.1],-.833333,["L13",Standard,y=.1,s=.2,r=180],-.116667\r
*H-DICHL14,L 14\r
A,.7,[KSC35,kosdic.shx,s=.1],-.366667,["L14",Standard,y=-.1,s=.2],-.583333\r
*H-DICHL14R,L 14()\r
A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.833333,["L14",Standard,y=.1,s=.2,r=180],-.116667\r
*H-DICHL15,L 15\r
A,.7,[KSC35,kosdic.shx,s=.1],-.366667,["L15",Standard,y=-.1,s=.2],-.583333\r
*H-DICHL15R,L 15()\r
A,.7,[KSC35,kosdic.shx,s=.1],-.833333,["L15",Standard,y=.1,s=.2,r=180],-.116667\r
\r
;; U\r
*H-DICHU00,U 00\r
A,1.1,[KSC35,kosdic.shx,s=.1],-.333333,["U",Standard,y=-.1,s=.2],-.216667\r
*H-DICHU00R,U 00()\r
A,1.1,[KSC35,kosdic.shx,s=.1],-.466667,["U",Standard,y=.1,s=.2,r=180],-.083333\r
*H-DICHU01,U 01\r
A,.9,[KSC35,kosdic.shx,s=.1],-.366667,["U1",Standard,y=-.1,s=.2],-.383333\r
*H-DICHU01R,U 01()\r
A,.9,[KSC35,kosdic.shx,s=.1],-.633333,["U1",Standard,y=.1,s=.2,r=180],-.116667\r
*H-DICHU02,U 02\r
A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["U2",Standard,y=-.1,s=.2,r=360],-.416667\r
*H-DICHU02R,U 02()\r
A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["U2",Standard,y=.1,s=.2,r=180],-.083333\r
*H-DICHU03,U 03\r
A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["U3",Standard,y=-.1,s=.2,r=360],-.416667\r
*H-DICHU03R,U 03()\r
A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["U3",Standard,y=.1,s=.2,r=180],-.083333\r
*H-DICHU04,U 04\r
A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["U4",Standard,y=-.1,s=.2],-.416667\r
*H-DICHU04R,U 04()\r
A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["U4",Standard,y=.1,s=.2,r=180],-.083333\r
*H-DICHU05,U 05\r
A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["U5",Standard,y=-.1,s=.2],-.416667\r
*H-DICHU05R,U 05()\r
A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["U5",Standard,y=.1,s=.2,r=180],-.083333\r
*H-DICHU06,U 06\r
A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["U6",Standard,y=-.1,s=.2],-.416667\r
*H-DICHU06R,U 06()\r
A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["U6",Standard,y=.1,s=.2,r=180],-.083333\r
*H-DICHU07,U 07\r
A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["U7",Standard,y=-.1,s=.2],-.416667\r
*H-DICHU07R,U 07()\r
A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["U7",Standard,y=.1,s=.2,r=180],-.083333\r
*H-DICHU08,U 08\r
A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["U8",Standard,y=-.1,s=.2],-.416667\r
*H-DICHU08R,U 08()\r
A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["U8",Standard,y=.1,s=.2,r=180],-.083333\r
*H-DICHU09,U 09\r
A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["U9",Standard,y=-.1,s=.2],-.416667\r
*H-DICHU09R,U 09()\r
A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["U9",Standard,y=.1,s=.2,r=180],-.083333\r
*H-DICHU10,U 10\r
A,.7,[KSC35,kosdic.shx,s=.1],-.383333,["U10",Standard,y=-.1,s=.2],-.566667\r
*H-DICHU10R,U 10()\r
A,.7,[KSC35,kosdic.shx,s=.1],-.816667,["U10",Standard,y=.1,s=.2,r=180],-.133333\r
*H-DICHU11,U 11\r
A,.7,[KSC35,kosdic.shx,s=.1],-.4,["U11",Standard,y=-.1,s=.2],-.55\r
*H-DICHU11R,U 11()\r
A,.7,[KSC35,kosdic.shx,s=.1],-.8,["U11",Standard,y=.1,s=.2,r=180],-.15\r
*H-DICHU12,U 12\r
A,.7,[KSC35,kosdic.shx,s=.1],-.366667,["U12",Standard,y=-.1,s=.2],-.583333\r
*H-DICHU12R,U 12()\r
A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.833333,["U12",Standard,y=.1,s=.2,r=180],-.116667\r
*H-DICHU13,U 13\r
A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.366667,["U13",Standard,y=-.1,s=.2,r=360],-.583333\r
*H-DICHU13R,U 13()\r
A,.7,[KSC35,kosdic.shx,s=.1],-.833333,["U13",Standard,y=.1,s=.2,r=180],-.116667\r
*H-DICHU14,U 14\r
A,.7,[KSC35,kosdic.shx,s=.1],-.366667,["U14",Standard,y=-.1,s=.2],-.583333\r
*H-DICHU14R,U 14()\r
A,.7,[KSC35,kosdic.shx,s=.1],-.833333,["U14",Standard,y=.1,s=.2,r=180],-.116667\r
*H-DICHU15,U 15\r
A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.366667,["U15",Standard,y=-.1,s=.2,r=360],-.583333\r
*H-DICHU15R,U 15()\r
A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.833333,["U15",Standard,y=.1,s=.2,r=180],-.116667\r
\r
;; V\r
*H-DICHV00,V 00\r
A,1.1,[KSC35,kosdic.shx,s=.1,r=360],-.3,["V",Standard,y=-.1,s=.2,r=360],-.25\r
*H-DICHV00R,V 00()\r
A,1.1,[KSC35,kosdic.shx,s=.1,r=360],-.5,["V",Standard,y=.1,s=.2,r=180],-.05\r
*H-DICHV01,V 01\r
A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["V1",Standard,y=-.1,s=.2,r=360],-.416667\r
*H-DICHV01R,V 01()\r
A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["V1",Standard,y=.1,s=.2,r=180],-.083333\r
*H-DICHV02,V 02\r
A,.9,[KSC35,kosdic.shx,s=.1],-.3,["V2",Standard,y=-.1,s=.2],-.45\r
*H-DICHV02R,V 02()\r
A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.7,["V2",Standard,y=.1,s=.2,r=180],-.05\r
*H-DICHV03,V 03\r
A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.3,["V3",Standard,y=-.1,s=.2,r=360],-.45\r
*H-DICHV03R,V 03()\r
A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.7,["V3",Standard,y=.1,s=.2,r=180],-.05\r
*H-DICHV04,V 04\r
A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.3,["V4",Standard,y=-.1,s=.2,r=360],-.45\r
*H-DICHV04R,V 04()\r
A,.9,[KSC35,kosdic.shx,s=.1],-.7,["V4",Standard,y=.1,s=.2,r=180],-.05\r
*H-DICHV05,V 05\r
A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.3,["V5",Standard,y=-.1,s=.2,r=360],-.45\r
*H-DICHV05R,V 05()\r
A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.7,["V5",Standard,y=.1,s=.2,r=180],-.05\r
*H-DICHV06,V 06\r
A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.3,["V6",Standard,y=-.1,s=.2,r=360],-.45\r
*H-DICHV06R,V 06()\r
A,.9,[KSC35,kosdic.shx,s=.1],-.25,0,-.45,["V6",Standard,y=.1,s=.2,r=180],-.05\r
*H-DICHV07,V 07\r
A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.3,["V7",Standard,y=-.1,s=.2,r=360],-.45\r
*H-DICHV07R,V 07()\r
A,.9,[KSC35,kosdic.shx,s=.1],-.7,["V7",Standard,y=.1,s=.2,r=180],-.05\r
*H-DICHV08,V 08\r
A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.3,["V8",Standard,y=-.1,s=.2,r=360],-.45\r
*H-DICHV08R,V 08()\r
A,.9,[KSC35,kosdic.shx,s=.1],-.7,["V8",Standard,y=.1,s=.2,r=180],-.05\r
*H-DICHV09,V 09\r
A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.3,["V9",Standard,y=-.1,s=.2,r=360],-.45\r
*H-DICHV09R,V 09()\r
A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.7,["V9",Standard,y=.1,s=.2,r=180],-.05\r
*H-DICHV10,V 10\r
A,.7,[KSC35,kosdic.shx,s=.1],-.35,["V10",Standard,y=-.1,s=.2],-.6\r
*H-DICHV10R,V 10()\r
A,.7,[KSC35,kosdic.shx,s=.1],-.85,["V10",Standard,y=.1,s=.2,r=180],-.1\r
*H-DICHV11,V 11\r
A,.7,[KSC35,kosdic.shx,s=.1],-.366667,["V11",Standard,y=-.1,s=.2],-.583333\r
*H-DICHV11R,V 11()\r
A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.833333,["V11",Standard,y=.1,s=.2,r=180],-.116667\r
*H-DICHV12,V 12\r
A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["V12",Standard,y=-.1,s=.2,r=360],-.616667\r
*H-DICHV12R,V 12()\r
A,.7,[KSC35,kosdic.shx,s=.1],-.866667,["V12",Standard,y=.1,s=.2,r=180],-.083333\r
*H-DICHV13,V 13\r
A,.7,[KSC35,kosdic.shx,s=.1],-.333333,["V13",Standard,y=-.1,s=.2],-.616667\r
*H-DICHV13R,V 13()\r
A,.7,[KSC35,kosdic.shx,s=.1],-.866667,["V13",Standard,y=.1,s=.2,r=180],-.083333\r
*H-DICHV14,V 14\r
A,.7,[KSC35,kosdic.shx,s=.1],-.333333,["V14",Standard,y=-.1,s=.2],-.616667\r
*H-DICHV14R,V 14()\r
A,.7,[KSC35,kosdic.shx,s=.1],-.866667,["V14",Standard,y=.1,s=.2,r=180],-.083333\r
*H-DICHV15,V 15\r
A,.7,[KSC35,kosdic.shx,s=.1],-.333333,["V15",Standard,y=-.1,s=.2],-.616667\r
*H-DICHV15R,V 15()\r
A,.7,[KSC35,kosdic.shx,s=.1],-.866667,["V15",Standard,y=.1,s=.2,r=180],-.083333\r
\r
;; ũ\r
*H-DICHD00,ũ 00\r
A,1.1,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["D",Standard,y=-.1,s=.2,r=360],-.216667\r
*H-DICHD00R,ũ 00()\r
A,1.1,[KSC35,kosdic.shx,s=.1],-.466667,["D",Standard,y=.1,s=.2,r=180],-.083333\r
*H-DICHD01,ũ 01\r
A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.366667,["D1",Standard,y=-.1,s=.2,r=360],-.383333\r
*H-DICHD01R,ũ 01()\r
A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.633333,["D1",Standard,y=.1,s=.2,r=180],-.116667\r
*H-DICHD02,ũ 02\r
A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["D2",Standard,y=-.1,s=.2,r=360],-.416667\r
*H-DICHD02R,ũ 02()\r
A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["D2",Standard,y=.1,s=.2,r=180],-.083333\r
*H-DICHD03,ũ 03\r
A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["D3",Standard,y=-.1,s=.2],-.416667\r
*H-DICHD03R,ũ 03()\r
A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["D3",Standard,y=.1,s=.2,r=180],-.083333\r
*H-DICHD04,ũ 04\r
A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["D4",Standard,y=-.1,s=.2],-.416667\r
*H-DICHD04R,ũ 04()\r
A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.666667,["D4",Standard,y=.1,s=.2,r=180],-.083333\r
*H-DICHD05,ũ 05\r
A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["D5",Standard,y=-.1,s=.2],-.416667\r
*H-DICHD05R,ũ 05()\r
A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["D5",Standard,y=.1,s=.2,r=180],-.083333\r
\r
;; \r
*H-DICHB00, 00\r
A,.00001,[KSC52,kosdic.shx,s=.1],-.633333,["B",Standard,y=-.1,s=.2],-.216667\r
*H-DICHB00R, 00()\r
A,.00001,[KSC52,kosdic.shx,s=.1],-.766667,["B",Standard,y=.1,s=.2,r=180],-.083333\r
*H-DICHB01, 01\r
A,.00001,[KSC52,kosdic.shx,s=.1],-.666667,["B1",Standard,y=-.1,s=.2],-.383333\r
*H-DICHB01R, 01()\r
A,.00001,[KSC52,kosdic.shx,s=.1],-.933333,["B1",Standard,y=.1,s=.2,r=180],-.116667\r
*H-DICHB02, 02\r
A,.00001,[KSC52,kosdic.shx,s=.1],-.633333,["B2",Standard,y=-.1,s=.2],-.416667\r
*H-DICHB02R, 02()\r
A,.00001,[KSC52,kosdic.shx,s=.1],-.966667,["B2",Standard,y=.1,s=.2,r=180],-.083333\r
*H-DICHB03, 03\r
A,.00001,[KSC52,kosdic.shx,s=.1],-.633333,["B3",Standard,y=-.1,s=.2],-.416667\r
*H-DICHB03R, 03()\r
A,.00001,[KSC52,kosdic.shx,s=.1],-.966667,["B3",Standard,y=.1,s=.2,r=180],-.083333\r
*H-DICHB04, 04\r
A,.00001,[KSC52,kosdic.shx,s=.1],-.633333,["B4",Standard,y=-.1,s=.2],-.416667\r
*H-DICHB04R, 04()\r
A,.00001,[KSC52,kosdic.shx,s=.1],-.966667,["B4",Standard,y=.1,s=.2,r=180],-.083333\r
*H-DICHB05, 05\r
A,.00001,[KSC52,kosdic.shx,s=.1],-.633333,["B5",Standard,y=-.1,s=.2],-.416667\r
*H-DICHB05R, 05()\r
A,.00001,[KSC52,kosdic.shx,s=.1],-.966667,["B5",Standard,y=.1,s=.2,r=180],-.083333\r
\r
;; ;ϰ\r
*H-DICHM00,;ϰ 00\r
A,1.1,[KSC35,kosdic.shx,s=.1],-.333333,["M",Standard,y=-.1,s=.2],-.216667\r
*H-DICHM00R,;ϰ 00()\r
A,1.1,[KSC35,kosdic.shx,s=.1],-.466667,["M",Standard,y=.1,s=.2,r=180],-.083333\r
*H-DICHM01,;ϰ 01\r
A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.366667,["M1",Standard,y=-.1,s=.2,r=360],-.383333\r
*H-DICHM01R,;ϰ 01()\r
A,.9,[KSC35,kosdic.shx,s=.1],-.633333,["M1",Standard,y=.1,s=.2,r=180],-.116667\r
*H-DICHM02,;ϰ 02\r
A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["M2",Standard,y=-.1,s=.2],-.416667\r
*H-DICHM02R,;ϰ 02()\r
A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.666667,["M2",Standard,y=.1,s=.2,r=180],-.083333\r
*H-DICHM03,;ϰ 03\r
A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["M3",Standard,y=-.1,s=.2],-.416667\r
*H-DICHM03R,;ϰ 03()\r
A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["M3",Standard,y=.1,s=.2,r=180],-.083333\r
*H-DICHM04,;ϰ 04\r
A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["M4",Standard,y=-.1,s=.2],-.416667\r
*H-DICHM04R,;ϰ 04()\r
A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["M4",Standard,y=.1,s=.2,r=180],-.083333\r
*H-DICHM05,;ϰ 05\r
A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["M5",Standard,y=-.1,s=.2],-.416667\r
*H-DICHM05R,;ϰ 05()\r
A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["M5",Standard,y=.1,s=.2,r=180],-.083333\r
\r
;; \r
*H-DICHO00, 00\r
A,.7,[KSC35,kosdic.shx,s=.1],-.333333,["L/O",Standard,y=-.1,s=.2],-.616667\r
*H-DICHO00R, 00()\r
A,.7,[KSC35,kosdic.shx,s=.1],-.866667,["L/O",Standard,y=.1,s=.2,r=180],-.083333\r
*H-DICHO01, 01\r
A,.5,[KSC35,kosdic.shx,s=.1],-.366667,["L1/O",Standard,y=-.1,s=.2],-.783333\r
*H-DICHO01R, 01()\r
A,.5,[KSC35,kosdic.shx,s=.1],-1.033333,["L1/O",Standard,y=.1,s=.2,r=180],-.116667\r
*H-DICHO02, 02\r
A,.5,[KSC35,kosdic.shx,s=.1],-.333333,["L2/O",Standard,y=-.1,s=.2],-.816667\r
*H-DICHO02R, 02()\r
A,.5,[KSC35,kosdic.shx,s=.1,r=360],-1.066667,["L2/O",Standard,y=.1,s=.2,r=180],-.083333\r
*H-DICHO03, 03\r
A,.5,[KSC35,kosdic.shx,s=.1],-.333333,["L3/O",Standard,y=-.1,s=.2],-.816667\r
*H-DICHO03R, 03()\r
A,.5,[KSC35,kosdic.shx,s=.1],-1.066667,["L3/O",Standard,y=.1,s=.2,r=180],-.083333\r
*H-DICHO04, 04\r
A,.5,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["L4/O",Standard,y=-.1,s=.2,r=360],-.816667\r
*H-DICHO04R, 04()\r
A,.5,[KSC35,kosdic.shx,s=.1],-1.066667,["L4/O",Standard,y=.1,s=.2,r=180],-.083333\r
*H-DICHO05, 05\r
A,.5,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["L5/O",Standard,y=-.1,s=.2,r=360],-.816667\r
*H-DICHO05R, 05()\r
A,.5,[KSC35,kosdic.shx,s=.1],-1.066667,["L5/O",Standard,y=.1,s=.2,r=180],-.083333\r
\r
;; Ҵ\r
*H-DICHG00,Ҵ 00\r
A,1.1,[KSC35,kosdic.shx,s=.1],-.333333,["G",Standard,y=-.1,s=.2],-.216667\r
*H-DICHG00R,Ҵ 00()\r
A,1.1,[KSC35,kosdic.shx,s=.1],-.466667,["G",Standard,y=.1,s=.2,r=180],-.083333\r
*H-DICHG01,Ҵ 01\r
A,.9,[KSC35,kosdic.shx,s=.1],-.366667,["G1",Standard,y=-.1,s=.2],-.383333\r
*H-DICHG01R,Ҵ 01()\r
A,.9,[KSC35,kosdic.shx,s=.1],-.633333,["G1",Standard,y=.1,s=.2,r=180],-.116667\r
*H-DICHG02,Ҵ 02\r
A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["G2",Standard,y=-.1,s=.2,r=360],-.416667\r
*H-DICHG02R,Ҵ 02()\r
A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["G2",Standard,y=.1,s=.2,r=180],-.083333\r
*H-DICHG03,Ҵ 03\r
A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["G3",Standard,y=-.1,s=.2,r=360],-.416667\r
*H-DICHG03R,Ҵ 03()\r
A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["G3",Standard,y=.1,s=.2,r=180],-.083333\r
*H-DICHG04,Ҵ 04\r
A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["G4",Standard,y=-.1,s=.2,r=360],-.416667\r
*H-DICHG04R,Ҵ 04()\r
A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["G4",Standard,y=.1,s=.2,r=180],-.083333\r
*H-DICHG05,Ҵ 05\r
A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["G5",Standard,y=-.1,s=.2],-.416667\r
*H-DICHG05R,Ҵ 05()\r
A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["G5",Standard,y=.1,s=.2,r=180],-.083333\r
\r
;; J\r
*H-DICHJ00,J 00\r
A,1.1,[KSC35,kosdic.shx,s=.1],-.333333,["J",Standard,y=-.1,s=.2],-.216667\r
*H-DICHJ00R,J 00()\r
A,1.1,[KSC35,kosdic.shx,s=.1],-.466667,["J",Standard,y=.1,s=.2,r=180],-.083333\r
*H-DICHJ01,J 01\r
A,.9,[KSC35,kosdic.shx,s=.1],-.366667,["J1",Standard,y=-.1,s=.2],-.383333\r
*H-DICHJ01R,J 01()\r
A,.9,[KSC35,kosdic.shx,s=.1],-.633333,["J1",Standard,y=.1,s=.2,r=180],-.116667\r
*H-DICHJ02,J 02\r
A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["J2",Standard,y=-.1,s=.2],-.416667\r
*H-DICHJ02R,J 02()\r
A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["J2",Standard,y=.1,s=.2,r=180],-.083333\r
*H-DICHJ03,J 03\r
A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["J3",Standard,y=-.1,s=.2],-.416667\r
*H-DICHJ03R,J 03()\r
A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["J3",Standard,y=.1,s=.2,r=180],-.083333\r
*H-DICHJ04,J 04\r
A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["J4",Standard,y=-.1,s=.2],-.416667\r
*H-DICHJ04R,J 04()\r
A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["J4",Standard,y=.1,s=.2,r=180],-.083333\r
*H-DICHJ05,J 05\r
A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["J5",Standard,y=-.1,s=.2,r=360],-.416667\r
*H-DICHJ05R,J 05()\r
A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["J5",Standard,y=.1,s=.2,r=180],-.083333\r
\r
;; \r
*H-CANAL00, 00\r
A,1.1,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["Y",Standard,y=-.1,s=.2,r=360],-.216667\r
*H-CANAL00R, 00()\r
A,1.1,[KSC35,kosdic.shx,s=.1],-.466667,["Y",Standard,y=.1,s=.2,r=180],-.083333\r
*H-CANAL01, 01\r
A,.9,[KSC35,kosdic.shx,s=.1],-.366667,["Y1",Standard,y=-.1,s=.2],-.383333\r
*H-CANAL01R, 01()\r
A,.9,[KSC35,kosdic.shx,s=.1],-.633333,["Y1",Standard,y=.1,s=.2,r=180],-.116667\r
*H-CANAL02, 02\r
A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["Y2",Standard,y=-.1,s=.2,r=360],-.416667\r
*H-CANAL02R, 02()\r
A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.666667,["Y2",Standard,y=.1,s=.2,r=180],-.083333\r
*H-CANAL03, 03\r
A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["Y3",Standard,y=-.1,s=.2],-.416667\r
*H-CANAL03R, 03()\r
A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.666667,["Y3",Standard,y=.1,s=.2,r=180],-.083333\r
*H-CANAL04, 04\r
A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["Y4",Standard,y=-.1,s=.2],-.416667\r
*H-CANAL04R, 04()\r
A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["Y4",Standard,y=.1,s=.2,r=180],-.083333\r
*H-CANAL05, 05\r
A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["Y5",Standard,y=-.1,s=.2,r=360],-.416667\r
*H-CANAL05R, 05()\r
A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.666667,["Y5",Standard,y=.1,s=.2,r=180],-.083333\r
*H-CANAL06, 06\r
A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["Y6",Standard,y=-.1,s=.2],-.416667\r
*H-CANAL06R, 06()\r
A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["Y6",Standard,y=.1,s=.2,r=180],-.083333\r
*H-CANAL07, 07\r
A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["Y7",Standard,y=-.1,s=.2],-.416667\r
*H-CANAL07R, 07()\r
A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["Y7",Standard,y=.1,s=.2,r=180],-.083333\r
*H-CANAL08, 08\r
A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["Y8",Standard,y=-.1,s=.2],-.416667\r
*H-CANAL08R, 08()\r
A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["Y8",Standard,y=.1,s=.2,r=180],-.083333\r
*H-CANAL09, 09\r
A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["Y9",Standard,y=-.1,s=.2],-.416667\r
*H-CANAL09R, 09()\r
A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["Y9",Standard,y=.1,s=.2,r=180],-.083333\r
*H-CANAL10, 10\r
A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.383333,["Y10",Standard,y=-.1,s=.2,r=360],-.566667\r
*H-CANAL10R, 10()\r
A,.7,[KSC35,kosdic.shx,s=.1],-.816667,["Y10",Standard,y=.1,s=.2,r=180],-.133333\r
*H-CANAL11, 11\r
A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.383333,["Y11",Standard,y=-.1,s=.2,r=360],-.566667\r
*H-CANAL11R, 11()\r
A,.7,[KSC35,kosdic.shx,s=.1],-.816667,["Y11",Standard,y=.1,s=.2,r=180],-.133333\r
*H-CANAL12, 12\r
A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.383333,["Y12",Standard,y=-.1,s=.2,r=360],-.566667\r
*H-CANAL12R, 12()\r
A,.7,[KSC35,kosdic.shx,s=.1],-.816667,["Y12",Standard,y=.1,s=.2,r=180],-.133333\r
*H-CANAL13, 13\r
A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.383333,["Y13",Standard,y=-.1,s=.2,r=360],-.566667\r
*H-CANAL13R, 13()\r
A,.7,[KSC35,kosdic.shx,s=.1],-.816667,["Y13",Standard,y=.1,s=.2,r=180],-.133333\r
*H-CANAL14, 14\r
A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.383333,["Y14",Standard,y=-.1,s=.2,r=360],-.566667\r
*H-CANAL14R, 14()\r
A,.7,[KSC35,kosdic.shx,s=.1],-.816667,["Y14",Standard,y=.1,s=.2,r=180],-.133333\r
*H-CANAL15, 15\r
A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.383333,["Y15",Standard,y=-.1,s=.2,r=360],-.566667\r
*H-CANAL15R, 15()\r
A,.7,[KSC35,kosdic.shx,s=.1],-.816667,["Y15",Standard,y=.1,s=.2,r=180],-.133333\r
*H-CANAL16, 16\r
A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.383333,["Y16",Standard,y=-.1,s=.2,r=360],-.566667\r
*H-CANAL16R, 16()\r
A,.7,[KSC35,kosdic.shx,s=.1],-.816667,["Y16",Standard,y=.1,s=.2,r=180],-.133333\r
*H-CANAL17, 17\r
A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.383333,["Y17",Standard,y=-.1,s=.2,r=360],-.566667\r
*H-CANAL17R, 17()\r
A,.7,[KSC35,kosdic.shx,s=.1],-.816667,["Y17",Standard,y=.1,s=.2,r=180],-.133333\r
*H-CANAL18, 18\r
A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.383333,["Y18",Standard,y=-.1,s=.2,r=360],-.566667\r
*H-CANAL18R, 18()\r
A,.7,[KSC35,kosdic.shx,s=.1],-.816667,["Y18",Standard,y=.1,s=.2,r=180],-.133333\r
\r
`;function wE(n){const e=[];let t="",i=!1;for(let _=0;_<n.length;_++){const m=n[_];m==='"'&&(i=!i),m===","&&!i?(e.push(t.trim()),t=""):t+=m}t.trim()&&e.push(t.trim());let s="shape",r,a,o,l,c=1,u=0,h=!1,d=!1,f=0,p=0;if(e.length>0){const _=e[0];_.startsWith('"')&&_.endsWith('"')?(s="text",o=_.slice(1,-1),e.length>1&&!e[1].includes("=")&&(l=e[1])):(s="shape",r=_,e.length>1&&!e[1].includes("=")&&(a=e[1]));for(let m=1;m<e.length;m++){const g=e[m],v=g.indexOf("=");if(v>0){const b=g.substring(0,v).trim().toLowerCase(),x=g.substring(v+1).trim(),E=parseFloat(x);isNaN(E)||(b==="s"?c=E:b==="r"?u=E:b==="a"?(u=E,h=!0):b==="u"?(u=E,d=!0):b==="x"?f=E:b==="y"&&(p=E))}}}return{type:s,shapeName:r,shxFile:a,text:o,style:l,scale:c,rotation:u,isAbsoluteAngle:h,isUprightAngle:d,xOffset:f,yOffset:p}}function RE(n){const e=n.replace(/^A\s*,\s*/i,"").trim(),t=[];let i="",s=!1,r=!1;for(let a=0;a<e.length;a++){const o=e[a];o==='"'&&(r=!r),o==="["&&!r&&(s=!0),o==="]"&&!r&&(s=!1),o===","&&!s&&!r?(i.trim()&&t.push(i.trim()),i=""):i+=o}return i.trim()&&t.push(i.trim()),t}function LE(n){const e=new Map,t=n.split(/\r?\n/);let i=null,s="";for(let r of t)if(r=r.trim(),!(!r||r.startsWith(";"))){if(r.startsWith("*")){const a=r.indexOf(",");a>0?(i=r.substring(1,a).trim(),s=r.substring(a+1).trim()):(i=r.substring(1).trim(),s="")}else if(i&&r.toUpperCase().startsWith("A,")){const a=RE(r),o=[];let l=0;for(const c of a)if(c.startsWith("[")&&c.endsWith("]")){const u=wE(c.slice(1,-1));o.push(u)}else{const u=parseFloat(c);if(!isNaN(u))if(u>1e-6)o.push({type:"dash",val:u,scale:1,rotation:0,isAbsoluteAngle:!1,isUprightAngle:!1,xOffset:0,yOffset:0}),l+=u;else if(u<-1e-6){const h=Math.abs(u);o.push({type:"gap",val:-h,scale:1,rotation:0,isAbsoluteAngle:!1,isUprightAngle:!1,xOffset:0,yOffset:0}),l+=h}else o.push({type:"dash",val:.05,scale:1,rotation:0,isAbsoluteAngle:!1,isUprightAngle:!1,xOffset:0,yOffset:0}),l+=.05}o.length>0&&e.set(i.toUpperCase(),{name:i,description:s,elements:o,patternLength:Math.max(l,.1)}),i=null}}return e}const I0=new Map;function P0(n){const e=LE(n);for(const[t,i]of e.entries())I0.set(t,i)}P0(TE);P0(CE);const DE={"H-DICHL02":"L2-2/0","H-DICHL02R":"L2-2","H-DICHL01":"L2-3/0","H-DICHL01R":"L2-3","H-DICHL06":"L5-1","H-DICHL06R":"L5-1","H-DICHL05":"L5","H-DICHL05R":"L5","H-DICHU05":"U5","H-DICHU05R":"U5","H-DICHB01":"B1","H-DICHB01R":"B1","H-DICHM03":"M3","H-DICHM03R":"M3","H-DICHV01":"V1","H-DICHV01R":"V1","H-DICHO01":"O1","H-DICHO01R":"O1","H-DICHL03":"L3","H-DICHL03R":"L3","H-DICHL04":"L4","H-DICHL04R":"L4","H-DICHL08":"L8","H-DICHL08R":"L8"},IE=new Set(["H-DICHL05","H-DICHL05R","H-DICHU05","H-DICHU05R","H-DICHB01","H-DICHB01R","H-DICHM03","H-DICHM03R","H-DICHV01","H-DICHV01R","H-DICHO01","H-DICHO01R"]);function O0(n){if(!n)return;const e=n.toUpperCase().trim(),t=I0.get(e);if(!t)return;let i=t.elements;IE.has(e)&&(i=i.filter(r=>r.type!=="shape"));const s=DE[e];return s&&(i=i.map(r=>r.type==="text"?{...r,text:s}:r)),{...t,elements:i}}function PE(n,e,t){if(!n)return;const i=O0(n);if(!e||!e.length)return i;if(!i){const o=[];let l=0;for(const c of e)if(c>1e-6)o.push({type:"dash",val:c,scale:1,rotation:0,isAbsoluteAngle:!1,isUprightAngle:!1,xOffset:0,yOffset:0}),l+=c;else if(c<-1e-6){const u=Math.abs(c);o.push({type:"gap",val:-u,scale:1,rotation:0,isAbsoluteAngle:!1,isUprightAngle:!1,xOffset:0,yOffset:0}),l+=u}return{name:n,description:t||"",elements:o,patternLength:Math.max(l,.1)}}const s=[];let r=0,a=0;for(const o of i.elements)if(o.type==="dash"){const l=r<e.length&&e[r]>0?e[r]:o.val||.05;r<e.length&&e[r]>0&&r++,s.push({...o,val:l}),a+=l}else if(o.type==="gap"){const l=r<e.length&&e[r]<0?e[r]:o.val;r<e.length&&e[r]<0&&r++;const c=Math.abs(l||.1);s.push({...o,val:-c}),a+=c}else s.push({...o});return{...i,description:t||i.description,elements:s,patternLength:Math.max(a,.1)}}const Jl=13226457,hf=64,jl=72,OE=14,UE=8,NE=.25,kE=.25,FE=24,BE=4e5;function HE(n){const e=new Map;for(const t of n){const i=t.layer??"0";let s=e.get(i);s||e.set(i,s=[]),s.push(t)}return e}function Js(n){return n?n.replace(/\\A\d+;/g,"").replace(/\\p[^;]*;/g,"").replace(/\\P/g,`
`).replace(/\\[a-zA-Z][^;]*;/g,"").replace(/\{[^{}]*\}/g,e=>Js(e.slice(1,-1))).replace(/%%d/gi,"°").replace(/%%p/gi,"±").replace(/%%c/gi,"Ø").replace(/[{}]/g,"").replace(/[ \t]{2,}/g," ").replace(/^[ \t]+|[ \t]+$/gm,"").replace(/\n{3,}/g,`
`).replace(/^\n+|\n+$/g,""):""}class zE{constructor(e){this._container=e,this._entityMeta=[],this._layerByHandle=new Map,this._layerByName=new Map,this._onSelectCb=null,this._measureActive=!1,this._measureCb=null,this._measurePtA=null,this._measureMarkers=[],this._textGen=0,this._curLayer=null,this._curLayerId=-1,this._layerObjs=new Map,this._layerBoxes=new Map,this._layerSamples=new Map,this._indexedBufs=[],this._fatBufs=[],this._metaHidden=null,this._fullContentBox=null,this._hiddenLayers=new Set,this._lwForced=null,this._lwDisplay=!1,this._curLwPx=0,ta.shared().catch(()=>{}),this._scene=new sg,this._scene.background=new it(856343),this._isDark=!0,this._isLoading=!1;const t=e.clientWidth||800,i=e.clientHeight||600;this._camera=new Cu(-t/2,t/2,i/2,-i/2,-1e4,1e4),this._camera.position.set(0,0,100),this._renderer=new nS({antialias:!0,preserveDrawingBuffer:!0}),this._renderer.setPixelRatio(window.devicePixelRatio),this._renderer.setSize(t,i),e.appendChild(this._renderer.domElement),this._controls=new sS(this._camera,this._renderer.domElement),this._controls.enableRotate=!1,this._controls.screenSpacePanning=!0,this._controls.zoomToCursor=!0,this._controls.mouseButtons={LEFT:Mi.PAN,MIDDLE:Mi.PAN,RIGHT:Mi.PAN},this._controls.touches={ONE:Xi.PAN,TWO:Xi.DOLLY_PAN};const s=localStorage.getItem("hmw:zoom-speed");if(s){const r=parseFloat(s);isNaN(r)||(this._controls.zoomSpeed=r)}window.addEventListener("keydown",r=>{(r.key==="f"||r.key==="F")&&this.fit()}),this._group=new Nr,this._scene.add(this._group),window.addEventListener("resize",()=>this._onResize()),this._renderer.domElement.addEventListener("pointerdown",r=>{r.button===1&&r.preventDefault()}),this._renderer.domElement.addEventListener("mousedown",r=>{this._downXY=[r.clientX,r.clientY],r.button===1&&r.preventDefault()}),this._renderer.domElement.addEventListener("click",r=>this._onClick(r)),this._renderer.domElement.addEventListener("pointermove",r=>this._onPointerMove(r)),this._renderer.domElement.addEventListener("pointerleave",()=>{this._onPointerWorldCb&&this._onPointerWorldCb(null)}),this._selColor={r:216/255,g:58/255,b:47/255},this._gridVisible=!1,this._gridMesh=null,this._activeSpaceHex=null,this._onPointerWorldCb=null,this._ptrWorldTmp=new k,this._coordOrigin={x:0,y:0,z:0},this._coordXAxis={x:1,y:0,z:0},this._coordYAxis={x:0,y:1,z:0},this._controls.addEventListener("change",()=>{this._gridVisible&&this._rebuildGrid()}),this._animate()}onSelect(e){this._onSelectCb=e}resize(){this._onResize()}setZoomSpeed(e){this._controls&&(this._controls.zoomSpeed=e)}getZoomSpeed(){return this._controls?this._controls.zoomSpeed:1}onPointerWorld(e){this._onPointerWorldCb=e||null}screenToWorld(e,t){const i=this._screenToWcs(e,t);return i?this._wcsToCad(i.x,i.y):null}_screenToWcs(e,t){var v,b,x,E,S;const i=(v=this._renderer)==null?void 0:v.domElement,s=this._camera;if(!i||!s)return null;const r=i.getBoundingClientRect();if(r.width<1||r.height<1)return null;s.updateMatrixWorld(!0);const a=(e-r.left)/r.width*2-1,o=-((t-r.top)/r.height)*2+1,l=s.zoom||1,c=(s.right-s.left)*.5/l,u=(s.top-s.bottom)*.5/l,h=s.matrixWorld.elements,d=h[0],f=h[1],p=h[4],_=h[5],m=((x=(b=this._controls)==null?void 0:b.target)==null?void 0:x.x)??s.position.x,g=((S=(E=this._controls)==null?void 0:E.target)==null?void 0:S.y)??s.position.y;return{x:m+a*c*d+o*u*p,y:g+a*c*f+o*u*_,z:0}}_wcsToCad(e,t){const i=this._coordOrigin||{x:0,y:0},s=this._coordXAxis||{x:1,y:0},r=this._coordYAxis||{x:0,y:1},a=e-(i.x||0),o=t-(i.y||0);return{x:a*(s.x||0)+o*(s.y||0),y:a*(r.x||0)+o*(r.y||0),z:0}}_setCoordFrame(e){const i=Qs(e).find(r=>r.handleHex===this._activeSpaceHex),s=(e==null?void 0:e.vars)||{};(i==null?void 0:i.kind)==="model"&&s.ucsOrigin?(this._coordOrigin={x:s.ucsOrigin.x||0,y:s.ucsOrigin.y||0,z:s.ucsOrigin.z||0},this._coordXAxis=s.ucsXAxis||{x:1,y:0,z:0},this._coordYAxis=s.ucsYAxis||{x:0,y:1,z:0}):(this._coordOrigin={x:0,y:0,z:0},this._coordXAxis={x:1,y:0,z:0},this._coordYAxis={x:0,y:1,z:0})}_onPointerMove(e){if(!this._onPointerWorldCb)return;const t=this.screenToWorld(e.clientX,e.clientY);this._onPointerWorldCb(t)}fit(){if(this._contentBox&&!this._contentBox.isEmpty()){this._fit(this._contentBox);return}const e=new mn,t=[];if(this._group.traverse(s=>{var l;if(!s.geometry||s.visible===!1)return;e.expandByObject(s);const r=(l=s.geometry.attributes)==null?void 0:l.position;if(!(r!=null&&r.array))return;const a=r.array,o=Math.max(3,Math.floor(a.length/3/4e3)*3);for(let c=0;c+1<a.length;c+=o)Number.isFinite(a[c])&&Number.isFinite(a[c+1])&&t.push(a[c],a[c+1])}),e.isEmpty())return;const i=this._trimmedContentBox(t,e)||e;this._hiddenLayers.size||(this._contentBox=i.clone()),this._fit(i)}load(e,t={}){var i,s,r,a,o,l,c,u,h,d,f,p,_,m,g,v,b,x,E,S,A,y,T,L,R,w,P,U,D,K,B,ie,F,se,V,oe,Ae;this._isLoading=!0;try{if(this._lastResult=e,this._selMeta=null,this._clear(),this._entityMeta=[],Object.prototype.hasOwnProperty.call(t,"spaceHandle")){const H=t.spaceHandle;H==null||H===""?this._activeSpaceHex=null:this._activeSpaceHex=typeof H=="number"?H.toString(16):String(H).toLowerCase()}if(!t.keepTheme){const ne=Qs(e).find(De=>De.handleHex===this._activeSpaceHex),O=(ne==null?void 0:ne.kind)==="paper";this.setTheme(!O)}this._buildLayerMap((i=e==null?void 0:e.tables)==null?void 0:i.layers),this._buildStyleMap(((s=e==null?void 0:e.tables)==null?void 0:s.styles)||((r=e==null?void 0:e.tables)==null?void 0:r.textStyles)),this._buildLinetypeMap(e),this._lwDisplay=this._lwForced??!!(((a=e==null?void 0:e.vars)==null?void 0:a.lwdisplay)??((o=e==null?void 0:e.vars)==null?void 0:o.$LWDISPLAY)??((l=e==null?void 0:e.vars)==null?void 0:l.LWDISPLAY)),this._viewTwist=this._readViewTwist(e),this._pickSegs=[],this._pickSegMeta=[],this._pickFills=[],this._pickCurIdx=-1;const me=(e==null?void 0:e.entities)||[],ue=[],z=[],ee=[],Z=new Map,xe=[],be=H=>{let ne=Z.get(H);return ne===void 0&&(ne=xe.length,xe.push(H),Z.set(H,ne)),ne},Se=new Map;let Oe=null,Ge=-1,Ye=[];const Ke=new mn,Be=new k,Pe=[],st=new Set,mt=new Set,gt=new Map,ft=new Map;for(const H of((c=e==null?void 0:e.tables)==null?void 0:c.blocks)??[]){const ne=(H.name??"").toLowerCase().replace(/\*/g,"").trim(),O=typeof H.handle=="object"?(h=(u=H.handle)==null?void 0:u.value)==null?void 0:h.toString(16):(d=H.handle)==null?void 0:d.toString(16);O&&(H.basePoint&&gt.set(O,H.basePoint),ft.set(O,(H.name??"").toLowerCase()),ne==="model_space"||ne==="paper_space"||ne==="ms"||ne==="ps"||ne.startsWith("model")||ne.startsWith("paper")||ne===""?mt.add(O):st.add(O))}const _t=mt.size>0;this._blockCount=st.size,this._activeSpaceHex&&mt.size&&!mt.has(this._activeSpaceHex)&&(this._activeSpaceHex=null);const G=this._activeSpaceHex?Hl(me,this._activeSpaceHex):null,nt=new Map;for(const H of me){const ne=(p=(f=H.ownerHandle)==null?void 0:f.value)==null?void 0:p.toString(16);ne!=null&&(nt.has(ne)||nt.set(ne,[]),nt.get(ne).push(H))}const lt=[];let I=0,M=null,q=null;const te=H=>{const ne=H||"0";ne!==this._curLayer&&(this._curLayer=ne,this._curLayerId=be(ne),M=this._layerBoxes.get(ne),M||this._layerBoxes.set(ne,M=new mn),q=this._layerSamples.get(ne),q||this._layerSamples.set(ne,q=[]))},Q=(H,ne,O=0)=>{!Number.isFinite(H)||!Number.isFinite(ne)||(Ke.expandByPoint(Be.set(H,ne,O)),M&&M.expandByPoint(Be),I++,!(I&7)&&lt.length<1e5&&(lt.push(H,ne),q&&q.push(H,ne)))},he=(H,ne,O,De,ye,N)=>{const ge=(N>>16&255)/255,le=(N>>8&255)/255,W=(N&255)/255,ae=this._curLwPx;if(Oe||ae>0){const $=`${Oe?Oe.key:""}#${ae}`;let de=Se.get($);de||(de={dash:(Oe==null?void 0:Oe.dash)??0,gap:(Oe==null?void 0:Oe.gap)??0,lwPx:ae,verts:[],colors:[],segLayer:[],entIdx:-2},Se.set($,de)),de.entIdx!==Ge&&(de.entIdx=Ge,de.entStart=de.colors.length,Ye.push(de)),de.verts.push(H,ne,ye,O,De,ye),de.colors.push(ge,le,W,ge,le,W),de.segLayer.push(this._curLayerId)}else ue.push(H,ne,ye,O,De,ye),z.push(ge,le,W,ge,le,W),ee.push(this._curLayerId);this._pickCurIdx>=0&&(this._pickSegs.push(H,ne,O,De),this._pickSegMeta.push(this._pickCurIdx)),Q(H,ne,ye),Q(O,De,ye)},Te=-1,ce=Qs(e),pe=ce.find(H=>H.handleHex===this._activeSpaceHex);if((pe==null?void 0:pe.kind)==="paper"){const H=ce.find(ne=>ne.kind==="model");if(H){const ne=Hl(me,H.handleHex),O=me.filter(N=>{var le,W;return(N.type||N.typeName||"").toUpperCase()!=="VIEWPORT"?!1:((W=(le=N.ownerHandle)==null?void 0:le.value)==null?void 0:W.toString(16))===this._activeSpaceHex&&this._isModelViewport(N)}),De=(N,ge,le,W,ae,$)=>{he(N,ge,le,W,Te,$)},ye=(N,ge,le=0)=>Q(N,ge,Te);for(const N of O)this._emitModelThroughViewport(N,{entities:me,modelAllowed:ne,blockDefHandles:st,entsByOwner:nt,blockBaseByHex:gt,blockNameByHex:ft,pushSeg:De,expand:ye,pendingTexts:Pe,setCurLayer:te,box:Ke,_tmp:Be,underlay:!0})}}for(const H of me){const ne=(m=(_=H.ownerHandle)==null?void 0:_.value)==null?void 0:m.toString(16);if(_t&&ne&&st.has(ne)||G&&ne&&!G.has(ne))continue;te(this._layerNameOf(H));const O=H.data||H,De=(H.type||H.typeName||"").toUpperCase(),ye=this._entityColor(H),N=this._resolveComplexLinetype(H);N?Oe=null:Oe=this._resolveDash(H),this._curLwPx=this._lwPx(H);const ge={entity:H,type:De,bounds:null,layer:this._curLayer,colStart:z.length};Ge=this._entityMeta.length,Ye=[],this._entityMeta.push(ge),this._pickCurIdx=this._entityMeta.length-1;const le=Pe.length;try{switch(De){case"LINE":O.start&&O.end&&(N?this._drawComplexPath([O.start,O.end],!1,N.pattern,N.ltscale,ye,he,Pe):he(O.start.x,O.start.y,O.end.x,O.end.y,O.start.z||0,ye),ge.bounds={type:"line",x1:O.start.x,y1:O.start.y,x2:O.end.x,y2:O.end.y});break;case"CIRCLE":if(O.center&&O.radius!=null){if(N){const W=this._sampleArcPoints(O.center,O.radius,0,Math.PI*2,O.center.z||0);this._drawComplexPath(W,!0,N.pattern,N.ltscale,ye,he,Pe)}else this._arcSegs(O.center,O.radius,0,Math.PI*2,O.center.z||0,ye,he);ge.bounds={type:"circle",cx:O.center.x,cy:O.center.y,r:O.radius}}break;case"ARC":if(O.center&&O.radius!=null){if(N){const W=this._sampleArcPoints(O.center,O.radius,O.startAngle??0,O.endAngle??Math.PI*2,O.center.z||0);this._drawComplexPath(W,!1,N.pattern,N.ltscale,ye,he,Pe)}else this._arcSegs(O.center,O.radius,O.startAngle??0,O.endAngle??Math.PI*2,O.center.z||0,ye,he);ge.bounds={type:"circle",cx:O.center.x,cy:O.center.y,r:O.radius}}break;case"LWPOLYLINE":if((g=O.points)!=null&&g.length){const W=(v=O.bulges)==null?void 0:v.some(de=>Math.abs(de)>=1e-6),ae=!!(O.closed||O.flags&1),$=ae?O.points.length:O.points.length-1;if(this._polyHasWidth(H,$,1))this._widePolyMesh(O.points,O.bulges,ae,H,ye,1,Q);else if(N){const de=this._samplePolylinePoints(O.points,O.bulges,ae,O.elevation||0);this._drawComplexPath(de,ae,N.pattern,N.ltscale,ye,he,Pe),de.forEach(fe=>Q(fe.x,fe.y,fe.z))}else W?this._bulgePolySegs(O.points,O.bulges,ae,ye,he,Q):(this._polylineSegs(O.points,ae,O.elevation||0,ye,he),O.points.forEach(de=>Q(de.x,de.y,O.elevation||0)));ge.bounds={type:"point",cx:O.points[0].x,cy:O.points[0].y}}break;case"POLYLINE":if(N&&(O.vertices||O.points)){const W=!!(O.closed||O.flags&1),ae=O.vertices||O.points;this._drawComplexPath(ae,W,N.pattern,N.ltscale,ye,he,Pe),ae.forEach($=>Q($.x,$.y,$.z||0))}else this._polylineSegs(O.vertices||O.points,O.closed||O.flags&1,0,ye,he);break;case"POLYLINE_2D":{const W=(nt.get((x=(b=H.handle)==null?void 0:b.value)==null?void 0:x.toString(16))??[]).filter(ae=>(ae.type||"").toUpperCase().startsWith("VERTEX")&&ae.point);if(W.length>=2){const ae=W.map(Ue=>Ue.point),$=W.map(Ue=>Ue.bulge||0),de=(O.flags&1)===1,fe=O.elevation||0;if(N){const Ue=this._samplePolylinePoints(ae,$,de,fe);this._drawComplexPath(Ue,de,N.pattern,N.ltscale,ye,he,Pe),Ue.forEach(ve=>Q(ve.x,ve.y,ve.z))}else $.some(Ue=>Math.abs(Ue)>=1e-6)?this._bulgePolySegs(ae,$,de,ye,he,Q):(this._polylineSegs(ae,de,fe,ye,he),ae.forEach(Ue=>Q(Ue.x,Ue.y,fe)));ge.bounds={type:"point",cx:ae[0].x,cy:ae[0].y}}break}case"POINT":{const W=O.position||O;typeof W.x=="number"&&(he(W.x-1,W.y,W.x+1,W.y,W.z||0,ye),he(W.x,W.y-1,W.x,W.y+1,W.z||0,ye),ge.bounds={type:"point",cx:W.x,cy:W.y});break}case"ELLIPSE":if(O.center){if(N){const W=this._sampleEllipsePoints(O);this._drawComplexPath(W,!1,N.pattern,N.ltscale,ye,he,Pe),W.forEach(ae=>Q(ae.x,ae.y,ae.z||0))}else this._ellipseSegs(O,ye,he);ge.bounds={type:"point",cx:O.center.x,cy:O.center.y}}break;case"SPLINE":{const W=O.controlPoints??O.fitPoints;if((W==null?void 0:W.length)>=2){const ae=W.length>=3?(()=>{const $=W.length*10,de=[];for(let fe=0;fe<=$;fe++){const Ue=fe/$;de.push(this._catmullRom(W,Ue))}return de})():W;N?(this._drawComplexPath(ae,!!O.closed,N.pattern,N.ltscale,ye,he,Pe),ae.forEach($=>Q($.x,$.y,$.z||0))):(this._polylineSegs(ae,!1,0,ye,he),ae.forEach($=>Q($.x,$.y,$.z||0))),ge.bounds={type:"point",cx:ae[0].x,cy:ae[0].y}}break}case"ATTRIB":case"ATTDEF":{if((O.flags??0)&1)break;const W=H.text??O.text??O.textValue??O.defaultValue??"",ae=Js(W),$=H.textHeight??H.height??O.textHeight??O.height??2.5,de=H.rotationAngle??O.rotationAngle??0,fe=H.horizAlignment??O.horizAlignment??0,Ue=H.vertAlignment??O.vertAlignment??0,qe=fe!==0||Ue!==0?H.alignmentPt??O.alignmentPt??H.insertionPt??O.insertionPt??O.insertionPoint??{x:0,y:0}:H.insertionPt??O.insertionPt??O.insertionPoint??{x:0,y:0};ae&&(Pe.push({text:ae,pos:qe,height:$,rotation:de,color:ye,alignH:fe,alignV:2}),ge.bounds={type:"point",cx:qe.x,cy:qe.y},this._addTextPick(ae,qe,$,fe,2),Q(qe.x,qe.y,0));break}case"XLINE":case"RAY":{const W=O.basePoint??O.point??O.startPoint,ae=O.direction??O.unitDir??O.vector;if(W&&ae){const de=W.x+ae.x*1e6,fe=W.y+ae.y*1e6;De==="XLINE"?he(W.x-ae.x*1e6,W.y-ae.y*1e6,de,fe,0,ye):he(W.x,W.y,de,fe,0,ye),ge.bounds={type:"point",cx:W.x,cy:W.y},Q(W.x,W.y)}break}case"SOLID":{const W=[O.corner1||O.pt1||O.point1,O.corner2||O.pt2||O.point2,O.corner3||O.pt3||O.point3,O.corner4||O.pt4||O.point4].filter(Boolean);W.length>=3&&(this._solidMesh(W,ye),ge.bounds={type:"point",cx:W[0].x,cy:W[0].y});break}case"MESH":{((E=O.vertices)==null?void 0:E.length)>=3&&(this._meshSegs(O,ye,he),ge.bounds={type:"point",cx:O.vertices[0],cy:O.vertices[1]});break}case"TEXT":case"MTEXT":{const W=H.text??O.text??"",ae=Js(W),$=H.textHeight??H.height??O.textHeight??O.height??2.5;let de=0,fe=0,Ue=0,ve;if(De==="TEXT")de=H.rotationAngle??O.rotationAngle??0,fe=H.horizAlignment??O.horizAlignment??0,Ue=H.vertAlignment??O.vertAlignment??0,fe===4&&(Ue=2),ve=fe!==0||Ue!==0?H.alignmentPt??O.alignmentPt??H.insertionPt??O.insertionPt??{x:0,y:0}:H.insertionPt??O.insertionPt??O.insertionPoint??{x:0,y:0};else{const qe=H.xAxisDir??O.xAxisDir;qe&&(de=Math.atan2(qe.y,qe.x));const ct=H.attachment??O.attachment??H.attachmentPoint??O.attachmentPoint??5;fe=[1,4,7].includes(ct)?0:[3,6,9].includes(ct)?2:1,Ue=[1,2,3].includes(ct)?3:[7,8,9].includes(ct)?1:2,ve=H.insertionPt??O.insertionPt??O.insertionPoint??{x:0,y:0}}if(ae){const qe={text:ae,pos:ve,height:$,rotation:de,color:ye,alignH:fe,alignV:Ue};De==="MTEXT"&&(qe.linespacingFactor=H.linespacingFactor??O.linespacingFactor??1,qe.rectWidth=H.rectWidth??O.rectWidth??0,qe.rectHeight=H.rectHeight??O.rectHeight??0,qe.bgFillFlags=H.bgFillFlags??O.bgFillFlags??0,qe.bgScale=H.bgScale??O.bgScale??1.5,qe.bgColorIndex=H.bgColorIndex??O.bgColorIndex,qe.bgColorRgb=H.bgColorRgb??O.bgColorRgb),Pe.push(qe),ge.bounds={type:"point",cx:ve.x,cy:ve.y},this._addTextPick(ae,ve,$,fe,Ue),Q(ve.x,ve.y,0)}break}case"INSERT":{const W=H.insertionPt??O.insertionPt??O.insertionPoint,ae=O.scaleX??((S=O.scale)==null?void 0:S.x)??((A=H.scale)==null?void 0:A.x)??1,$=O.scaleY??((y=O.scale)==null?void 0:y.y)??((T=H.scale)==null?void 0:T.y)??1,de=O.rotation??H.rotation??0,fe=((L=H.blockHeaderHandle)==null?void 0:L.value)??((R=O.blockHeaderHandle)==null?void 0:R.value);if(fe!=null){const Ue=fe.toString(16),ve=nt.get(Ue)??[];if(ve.length>0){const qe=(P=(w=e==null?void 0:e.tables)==null?void 0:w.blocks)==null?void 0:P.find(ct=>{var Ct;return(typeof ct.handle=="object"?(Ct=ct.handle)==null?void 0:Ct.value:ct.handle)===fe});this._insertEntities(ve,{insertionPoint:W??{x:0,y:0,z:0},xScale:ae,yScale:$,rotation:de,basePoint:qe==null?void 0:qe.basePoint},ye,he,Pe,{entsByOwner:nt,blockBase:gt})}}W&&(ge.bounds={type:"point",cx:W.x,cy:W.y},Q(W.x,W.y,0));break}case"HATCH":{const W=O.paths??H.paths,ae=O.solidFill??H.solidFill??!1;if(!(W!=null&&W.length))break;let $=null;for(const de of W){if(!((U=de.points)!=null&&U.length)||de.points.length<2)continue;$||($=de.points[0]),((D=de.bulges)==null?void 0:D.some(Ue=>Math.abs(Ue)>=1e-6))?this._bulgePolySegs(de.points,de.bulges,!0,ye,he,Q):(this._polylineSegs(de.points,!0,0,ye,he),de.points.forEach(Ue=>Q(Ue.x,Ue.y,0)))}ae&&this._hatchFill(W,ye),$&&(ge.bounds={type:"point",cx:$.x,cy:$.y});break}case"DIMENSION":case"DIMENSION_LINEAR":case"DIMENSION_ALIGNED":case"DIMENSION_RADIUS":case"DIMENSION_DIAMETER":case"DIMENSION_ANG_3PT":case"DIMENSION_ANG_2LN":case"DIMENSION_ORDINATE":{const W=((K=H.blockHeaderHandle)==null?void 0:K.value)??((B=O.blockHeaderHandle)==null?void 0:B.value);let ae=[];if(W!=null){const $=W.toString(16);ae=nt.get($)??[]}if(ae.length>0){for(const fe of ae){const Ue=(fe.type||fe.typeName||"").toUpperCase(),ve=fe.data||fe,qe=this._entityColor(fe)||ye;if(Ue==="LINE"&&ve.start&&ve.end)he(ve.start.x,ve.start.y,ve.end.x,ve.end.y,0,qe),Q(ve.start.x,ve.start.y),Q(ve.end.x,ve.end.y);else if(Ue==="SOLID"){const ct=[ve.corner1||ve.pt1,ve.corner2||ve.pt2,ve.corner3||ve.pt3,ve.corner4||ve.pt4].filter(Boolean);ct.length>=3&&(this._solidMesh(ct,qe),ct.forEach(an=>Q(an.x,an.y)))}else if(Ue==="ARC"&&ve.center&&ve.radius!=null)this._arcSegs(ve.center,ve.radius,ve.startAngle??0,ve.endAngle??Math.PI*2,0,qe,he);else if(Ue==="TEXT"||Ue==="MTEXT"){const ct=fe.text??ve.text??ve.textValue??"",an=Js(ct),Ct=fe.insertionPt??ve.insertionPt??ve.insertionPoint??{x:0,y:0},On=ve.textHeight??ve.height??fe.textHeight??2.5;an&&(Pe.push({text:an,pos:Ct,height:On,rotation:ve.rotationAngle??0,color:qe,alignH:1,alignV:2}),Q(Ct.x,Ct.y))}else if(Ue==="INSERT"){const ct=fe.insertionPt??ve.insertionPt??ve.insertionPoint??{x:0,y:0},an=ve.rotation??fe.rotation??0,Ct=ve.scaleX??((ie=ve.scale)==null?void 0:ie.x)??((F=fe.scale)==null?void 0:F.x)??1,On=ve.scaleY??((se=ve.scale)==null?void 0:se.y)??((V=fe.scale)==null?void 0:V.y)??Ct,Un=((oe=fe.blockHeaderHandle)==null?void 0:oe.value)??((Ae=ve.blockHeaderHandle)==null?void 0:Ae.value),An=Un==null?void 0:Un.toString(16),pi=ft.get(An)??"",Ri=An?nt.get(An)??[]:[];pi.includes("dot")?this._dotMesh(ct,this._arrowDotRadius(Ri)*Math.abs(Ct)||Math.abs(Ct)*.5,qe):Ri.length?this._insertEntities(Ri,{insertionPoint:ct,xScale:Ct,yScale:On,rotation:an,basePoint:gt.get(An)},qe,he,Pe,{entsByOwner:nt,blockBase:gt}):this._defaultArrow(pi,ct,an,Math.abs(Ct)||1,qe,he),Q(ct.x,ct.y)}}const $=ae.find(fe=>(fe.type||fe.typeName||"").toUpperCase()==="LINE"),de=($==null?void 0:$.data)||$;de!=null&&de.start&&(ge.bounds={type:"point",cx:de.start.x,cy:de.start.y})}else{this._renderDimFallback(H,O,De,ye,he,Pe,Q);const $=H.pt10??O.pt10;$&&(ge.bounds={type:"point",cx:$.x,cy:$.y},Q($.x,$.y))}break}case"LEADER":{const W=O.points??H.points;if((W==null?void 0:W.length)>=2){if(this._polylineSegs(W,!1,0,ye,he),W.forEach(ae=>Q(ae.x,ae.y,ae.z||0)),O.arrowheadOn??H.arrowheadOn??!0){const ae=W[0],$=W[1],de=Math.atan2($.y-ae.y,$.x-ae.x),fe=O.arrowSize??H.arrowSize??2.5;this._arrowMesh(ae,de,fe,ye)}ge.bounds={type:"point",cx:W[0].x,cy:W[0].y}}break}case"OLE2FRAME":{const W=H.upperLeft??O.upperLeft??{x:0,y:0,z:0},ae=H.lowerRight??O.lowerRight??{x:0,y:0,z:0},$=H.sourceApp??O.sourceApp??H.source_application??"",de=H.imageDataUrl??O.imageDataUrl;let fe=Math.min(W.x,ae.x),Ue=Math.max(W.x,ae.x),ve=Math.min(W.y,ae.y),qe=Math.max(W.y,ae.y),ct=Ue-fe,an=qe-ve;const Ct=W.z||0;if(he(fe,ve,Ue,ve,Ct,ye),he(Ue,ve,Ue,qe,Ct,ye),he(Ue,qe,fe,qe,Ct,ye),he(fe,qe,fe,ve,Ct,ye),de)try{const Un=(yr=>{const ua=yr.split(",")[1],As=atob(ua),on=new Uint8Array(As.length);for(let j=0;j<As.length;j++)on[j]=As.charCodeAt(j);const ts=new DataView(on.buffer);if(String.fromCharCode(on[0],on[1])!=="BM")throw new Error("Not a BMP file");const Sr=ts.getUint32(10,!0),Nn=ts.getInt32(18,!0),ha=ts.getInt32(22,!0),da=ts.getUint16(28,!0),Li=Math.abs(ha),fa=ha>0,C=document.createElement("canvas");C.width=Nn,C.height=Li;const X=C.getContext("2d"),re=X.createImageData(Nn,Li),J=re.data;if(da===32){const j=Nn*4;for(let Me=0;Me<Li;Me++){const Ne=fa?Li-1-Me:Me,Re=Sr+Ne*j,He=Me*Nn*4;for(let ke=0;ke<Nn;ke++){const Je=Re+ke*4,je=He+ke*4;J[je]=on[Je+2],J[je+1]=on[Je+1],J[je+2]=on[Je],J[je+3]=255}}}else if(da===24){const j=Math.ceil(Nn*3/4)*4;for(let Me=0;Me<Li;Me++){const Ne=fa?Li-1-Me:Me,Re=Sr+Ne*j,He=Me*Nn*4;for(let ke=0;ke<Nn;ke++){const Je=Re+ke*3,je=He+ke*4;J[je]=on[Je+2],J[je+1]=on[Je+1],J[je+2]=on[Je],J[je+3]=255}}}return X.putImageData(re,0,0),C})(de),An=new Fa(Un);An.colorSpace=Sn,An.needsUpdate=!0;const pi=new fs(ct,Math.abs(an)),Ri=new ti({map:An,side:Yt,transparent:!1}),Kn=new Ht(pi,Ri);Kn.position.set(fe+ct/2,ve+Math.abs(an)/2,Ct+10),this._addObj(Kn),this._renderer.render(this._scene,this._camera)}catch(On){console.error("Failed rendering CanvasTexture for OLE image:",On)}else{he(fe,ve,Ue,qe,Ct,ye),he(fe,qe,Ue,ve,Ct,ye);const On=Math.abs(an),Un=Math.max(Math.min(On*.05,300),40),An=$?`[OLE: ${$}]`:"[OLE2Frame]",pi={x:(fe+Ue)/2,y:(ve+qe)/2,z:Ct};Pe.push({text:An,pos:pi,height:Un,rotation:0,color:ye,alignH:1,alignV:2})}Q(fe,ve,Ct),Q(Ue,qe,Ct),ge.bounds={type:"point",cx:(fe+Ue)/2,cy:(ve+qe)/2};break}case"VIEWPORT":break;default:break}}catch{}ge.colEnd=z.length,Ye.length&&(ge.spans=Ye.map(W=>({bk:W,start:W.entStart,end:W.colors.length})),Ye=[]);for(let W=le;W<Pe.length;W++)Pe[W].layer===void 0&&(Pe[W].layer=this._curLayer)}if(Pe.length){const H=Ke.isEmpty()?new k(1,1,0):Ke.getSize(new k),ne=Math.hypot(Math.max(H.x,1),Math.max(H.y,1)),O=[];for(const $ of Pe){const de=$.height;de>0&&Number.isFinite(de)&&O.push(de)}O.sort(($,de)=>$-de);const De=O.length?O[O.length>>1]:2.5,ye=Math.min(ne*2e-4,De),N=2e4,ge=Pe.filter($=>$.underlay),le=Pe.filter($=>!$.underlay),W=ge.concat(le),ae=W.length>N?(console.warn(`텍스트 ${W.length}개 → ${N}개로 제한`),le.concat(ge).sort(($,de)=>de.height-$.height).slice(0,N)):W;this._drawTexts(ae,ye)}this._layerNames=xe,this._lineColorAttr=null,this._origColors=null,this._hairRt=null;for(const H of Se.values())if(H.fat=H.lwPx>0&&H.verts.length/6<=BE,H.lwPx>0&&!H.fat&&console.warn(`선가중치 ${H.lwPx}px 세그먼트 ${H.verts.length/6}개 → 헤어라인으로 대체`),!H.fat&&H.dash<=0){H.mergeOffset=z.length;for(let ne=0;ne<H.verts.length;ne++)ue.push(H.verts[ne]);for(let ne=0;ne<H.colors.length;ne++)z.push(H.colors[ne]);for(let ne=0;ne<H.segLayer.length;ne++)ee.push(H.segLayer[ne]);H.merged=!0}if(ue.length){const H=new wt;H.setAttribute("position",new dt(ue,3));const ne=new dt(z,3);H.setAttribute("color",ne);const O=new ka(H,new js({vertexColors:!0}));this._registerIndexed(O,ee),this._group.add(O),this._lineColorAttr=ne,this._origColors=Float32Array.from(ne.array),this._hairRt={attr:ne,orig:this._origColors}}for(const H of Se.values())if(!(!H.verts.length||H.merged))if(H.fat){const ne=new bp;ne.setPositions(H.verts),ne.setColors(H.colors);const O=new Mp({vertexColors:!0,linewidth:H.lwPx,worldUnits:!1,dashed:H.dash>0,dashSize:H.dash,gapSize:H.gap});this._sizeLineMaterial(O);const De=new yS(ne,O);H.dash>0&&De.computeLineDistances(),this._registerFat(De,H.segLayer),H.rt=this._fatBufs[this._fatBufs.length-1],this._group.add(De)}else{const ne=new wt;ne.setAttribute("position",new dt(H.verts,3));const O=new dt(H.colors,3);ne.setAttribute("color",O);const De=new ka(ne,new Qg({vertexColors:!0,dashSize:H.dash,gapSize:H.gap}));De.computeLineDistances(),this._registerIndexed(De,H.segLayer),H.rt={attr:O,orig:Float32Array.from(O.array)},this._group.add(De)}this._setCoordFrame(e);const Ee=Ke.isEmpty()?null:this._trimmedContentBox(lt,Ke)||Ke;this._fullContentBox=Ee?Ee.clone():null,this._contentBox=Ee?Ee.clone():null,this._applyLayerVisibility();const We=this._contentBox;!t.keepView&&We&&!We.isEmpty()&&this._fit(We)}finally{this._isLoading=!1}}setTheme(e){const t=!!e,i=this._isDark!==t;this._isDark=t,this._scene.background=new it(this._isDark?658189:16777215),this._gridVisible&&this._rebuildGrid(),i&&this._lastResult&&!this._isLoading&&this.load(this._lastResult,{keepView:!0,keepTheme:!0,spaceHandle:this._activeSpaceHex})}setGrid(e){this._gridVisible=e,e?this._rebuildGrid():this._gridMesh&&(this._scene.remove(this._gridMesh),this._gridMesh.geometry.dispose(),this._gridMesh.material.dispose(),this._gridMesh=null)}_rebuildGrid(){this._gridMesh&&(this._scene.remove(this._gridMesh),this._gridMesh.geometry.dispose(),this._gridMesh.material.dispose(),this._gridMesh=null);const e=this._camera.zoom||1,t=this._camera.position.x,i=this._camera.position.y,s=(this._camera.right-this._camera.left)/e/2,r=(this._camera.top-this._camera.bottom)/e/2,a=Math.max(s,r)*3,o=this._niceSpacing(Math.max(s,r)*2/20),[l,c,u,h]=[t-a,t+a,i-a,i+a],f=this._scene.background.r<.5?2829099:12303291,p=[];for(let m=Math.ceil(l/o)*o;m<=c;m+=o)p.push(m,u,-.5,m,h,-.5);for(let m=Math.ceil(u/o)*o;m<=h;m+=o)p.push(l,m,-.5,c,m,-.5);const _=new wt;_.setAttribute("position",new dt(p,3)),this._gridMesh=new ka(_,new js({color:f})),this._scene.add(this._gridMesh)}_niceSpacing(e){if(e<=0)return 1;const t=Math.pow(10,Math.floor(Math.log10(e))),i=e/t;return(i<2?1:i<5?2:5)*t}getZoomPercent(){var e;return Math.round((((e=this._camera)==null?void 0:e.zoom)??1)*100)}onViewChange(e){var t;(t=this._controls)==null||t.addEventListener("change",e)}setHiddenLayers(e){this._hiddenLayers=new Set(e||[]),!this._applyLayerVisibility()&&this._lastResult&&this.load(this._lastResult,{keepView:!0})}_layerNameOf(e){var i,s;const t=((i=e.layerHandle)==null?void 0:i.value)??e.layerHandle;return(t!=null&&((s=this._layerNameByHandle)==null?void 0:s.get(String(t))))??e.layer??e.layerName??"0"}_registerIndexed(e,t){const i=e.geometry.attributes.position.count;if(!i)return;const s=i>65535?Uint32Array:Uint16Array,r=new s(i);for(let o=0;o<i;o++)r[o]=o;const a=new Dn(r,1);a.setUsage(tl),e.geometry.setIndex(a),this._indexedBufs.push({mesh:e,segLayer:Int32Array.from(t),index:r,attr:a})}_registerFat(e,t){var a,o;const i=e.geometry,s=(a=i.attributes.instanceStart)==null?void 0:a.data,r=(o=i.attributes.instanceColorStart)==null?void 0:o.data;s&&(s.setUsage(tl),r==null||r.setUsage(tl),this._fatBufs.push({mesh:e,segLayer:Int32Array.from(t),posBuf:s,colBuf:r,posSrc:Float32Array.from(s.array),colSrc:r?Float32Array.from(r.array):null}))}_sizeLineMaterial(e){var s,r,a,o,l,c;const t=((s=this._container)==null?void 0:s.clientWidth)||((a=(r=this._renderer)==null?void 0:r.domElement)==null?void 0:a.clientWidth)||1,i=((o=this._container)==null?void 0:o.clientHeight)||((c=(l=this._renderer)==null?void 0:l.domElement)==null?void 0:c.clientHeight)||1;e.resolution.set(t,i)}setLineweightEnabled(e){this._lwForced=e==null?null:!!e,this._lastResult&&!this._isLoading&&this.load(this._lastResult,{keepView:!0,keepTheme:!0,spaceHandle:this._activeSpaceHex})}getLineweightEnabled(){return this._lwDisplay}_addObj(e,t){const i=t??this._curLayer;if(i!=null){e.userData.cadLayer=i;let s=this._layerObjs.get(i);s||this._layerObjs.set(i,s=[]),s.push(e),this._hiddenLayers.has(i)&&(e.visible=!1)}this._group.add(e)}_applyLayerVisibility(){var a;if(!this._layerNames&&!this._layerObjs.size)return!1;const e=this._hiddenLayers;for(const[o,l]of this._layerObjs){const c=!e.has(o);for(const u of l)u.visible=c}const t=this._layerNames||[],i=new Uint8Array(t.length);for(let o=0;o<t.length;o++)e.has(t[o])&&(i[o]=1);for(const o of this._indexedBufs){const l=o.segLayer,c=o.index;let u=0;for(let h=0;h<l.length;h++){const d=l[h];if(d>=0&&i[d])continue;const f=h*2;c[u++]=f,c[u++]=f+1}o.attr.needsUpdate=!0,o.mesh.geometry.setDrawRange(0,u)}for(const o of this._fatBufs){const l=o.segLayer;o.slotOf||(o.slotOf=new Int32Array(l.length));const c=o.slotOf;let u=0;for(let h=0;h<l.length;h++){const d=l[h];if(d>=0&&i[d]){c[h]=-1;continue}o.posBuf.array.set(o.posSrc.subarray(h*6,h*6+6),u*6),o.colBuf&&o.colBuf.array.set(o.colSrc.subarray(h*6,h*6+6),u*6),c[h]=u,u++}o.posBuf.needsUpdate=!0,o.colBuf&&(o.colBuf.needsUpdate=!0),o.mesh.geometry.instanceCount=u,o.mesh.visible=u>0}const s=this._entityMeta,r=new Uint8Array(s.length);if(e.size)for(let o=0;o<s.length;o++)e.has(s[o].layer)&&(r[o]=1);return this._metaHidden=r,this._selMeta&&e.has(this._selMeta.layer)?(this._highlight(null),(a=this._onSelectCb)==null||a.call(this,null)):this._selMeta&&this._fatBufs.length&&this._paintMeta(this._selMeta,this._selColor),this._contentBox=this._visibleContentBox(),!0}_visibleContentBox(){const e=this._hiddenLayers;if(!e.size)return this._fullContentBox?this._fullContentBox.clone():null;const t=new mn,i=[];for(const[s,r]of this._layerBoxes){if(e.has(s)||r.isEmpty())continue;t.union(r);const a=this._layerSamples.get(s);if(a)for(let o=0;o<a.length;o++)i.push(a[o])}return t.isEmpty()?null:(this._trimmedContentBox(i,t)||t).clone()}getSpaces(){return Qs(this._lastResult)}getActiveSpace(){return this._activeSpaceHex}setSpace(e,t={}){e==null||e===""?this._activeSpaceHex=null:typeof e=="number"?this._activeSpaceHex=e.toString(16):this._activeSpaceHex=String(e).toLowerCase(),this._lastResult&&this.load(this._lastResult,{keepView:!!t.keepView,spaceHandle:this._activeSpaceHex})}_isModelViewport(e){if(!e||e.status&&e.status.isOn===!1||(e.id??0)===1)return!1;const i=Number(e.height)||0,s=Number(e.viewHeight)||0;if(i<=0||s<=0)return!1;const r=i/s,a=e.center||{},o=e.viewCenter||{},l=e.viewTarget||{},c=Math.hypot(l.x||0,l.y||0)<.001,u=Math.hypot((o.x||0)-(a.x||0),(o.y||0)-(a.y||0))<Math.max(i,1)*.05;return!(Math.abs(r-1)<.03&&c&&u)}_viewportModelToPaper(e){const t=e.center||{x:0,y:0},i=e.viewCenter||{x:0,y:0},s=e.viewTarget||{x:0,y:0},r=Number(e.height)||1,a=Number(e.viewHeight)>1e-12?Number(e.viewHeight):r,o=r/a,l=Number(e.twistAngle)||0,c=Math.cos(l),u=Math.sin(l),h=(d,f)=>{const p=d-(s.x||0),_=f-(s.y||0),m=c*p-u*_,g=u*p+c*_;return{x:(t.x||0)+(m-(i.x||0))*o,y:(t.y||0)+(g-(i.y||0))*o}};return h.scale=o,h.twist=l,h}_viewportPaperClip(e){const t=e.center||{x:0,y:0},i=(Number(e.width)||0)/2,s=(Number(e.height)||0)/2,r=Math.max(i,s)*1e-6;return{minX:(t.x||0)-i-r,maxX:(t.x||0)+i+r,minY:(t.y||0)-s-r,maxY:(t.y||0)+s+r}}_clipSegToRect(e,t,i,s,r,a){const d=(_,m)=>{let g=0;return _<r.minX?g|=1:_>r.maxX&&(g|=2),m<r.minY?g|=4:m>r.maxY&&(g|=8),g};let f=d(e,t),p=d(i,s);for(;;){if(!(f|p)){a(e,t,i,s);return}if(f&p)return;const _=f||p;let m=0,g=0;_&8?(m=e+(i-e)*(r.maxY-t)/(s-t||1e-30),g=r.maxY):_&4?(m=e+(i-e)*(r.minY-t)/(s-t||1e-30),g=r.minY):_&2?(g=t+(s-t)*(r.maxX-e)/(i-e||1e-30),m=r.maxX):(g=t+(s-t)*(r.minX-e)/(i-e||1e-30),m=r.minX),_===f?(e=m,t=g,f=d(e,t)):(i=m,s=g,p=d(i,s))}}_emitModelThroughViewport(e,t){var x,E,S,A,y,T,L,R,w,P,U,D,K;const{entities:i,modelAllowed:s,blockDefHandles:r,entsByOwner:a,blockBaseByHex:o,pushSeg:l,expand:c,pendingTexts:u,setCurLayer:h,underlay:d=!1}=t,f=this._viewportModelToPaper(e),p=this._viewportPaperClip(e),_=f.scale||1,m=new Set((e.frozenLayers||[]).map(B=>String(B))),g=(B,ie,F,se,V,oe)=>{const Ae=f(B,ie),me=f(F,se);this._clipSegToRect(Ae.x,Ae.y,me.x,me.y,p,(ue,z,ee,Z)=>{l(ue,z,ee,Z,V||0,oe)})},v=(B,ie,F=0)=>{const se=f(B,ie);se.x>=p.minX&&se.x<=p.maxX&&se.y>=p.minY&&se.y<=p.maxY&&c(se.x,se.y,F)},b=(B,ie)=>B>=p.minX&&B<=p.maxX&&ie>=p.minY&&ie<=p.maxY;for(const B of i){const ie=(E=(x=B.ownerHandle)==null?void 0:x.value)==null?void 0:E.toString(16);if(!ie||!s.has(ie)||r.has(ie))continue;if(h==null||h(this._layerNameOf(B)),m.size){const me=(S=B.layerHandle)==null?void 0:S.value;if(me!=null&&m.has(String(me)))continue}const F=B.data||B,se=(B.type||B.typeName||"").toUpperCase(),V=this._entityColor(B),oe=this._resolveComplexLinetype(B),Ae=u.length;try{switch(se){case"LINE":F.start&&F.end&&(oe?this._drawComplexPath([F.start,F.end],!1,oe.pattern,oe.ltscale,V,g,u):g(F.start.x,F.start.y,F.end.x,F.end.y,F.start.z||0,V));break;case"CIRCLE":if(F.center&&F.radius!=null)if(oe){const me=this._sampleArcPoints(F.center,F.radius,0,Math.PI*2,F.center.z||0);this._drawComplexPath(me,!0,oe.pattern,oe.ltscale,V,g,u)}else this._arcSegs(F.center,F.radius,0,Math.PI*2,F.center.z||0,V,g);break;case"ARC":if(F.center&&F.radius!=null)if(oe){const me=this._sampleArcPoints(F.center,F.radius,F.startAngle??0,F.endAngle??Math.PI*2,F.center.z||0);this._drawComplexPath(me,!1,oe.pattern,oe.ltscale,V,g,u)}else this._arcSegs(F.center,F.radius,F.startAngle??0,F.endAngle??Math.PI*2,F.center.z||0,V,g);break;case"LWPOLYLINE":if((A=F.points)!=null&&A.length){const me=(y=F.bulges)==null?void 0:y.some(z=>Math.abs(z)>=1e-6),ue=!!(F.closed||F.flags&1);if(oe){const z=this._samplePolylinePoints(F.points,F.bulges,ue,F.elevation||0);this._drawComplexPath(z,ue,oe.pattern,oe.ltscale,V,g,u),z.forEach(ee=>v(ee.x,ee.y,ee.z))}else me?this._bulgePolySegs(F.points,F.bulges,ue,V,g,v):(this._polylineSegs(F.points,ue,F.elevation||0,V,g),F.points.forEach(z=>v(z.x,z.y,F.elevation||0)))}break;case"POLYLINE":if(oe&&(F.vertices||F.points)){const me=!!(F.closed||F.flags&1),ue=F.vertices||F.points;this._drawComplexPath(ue,me,oe.pattern,oe.ltscale,V,g,u),ue.forEach(z=>v(z.x,z.y,z.z||0))}else this._polylineSegs(F.vertices||F.points,F.closed||F.flags&1,0,V,g);break;case"ELLIPSE":if(F.center)if(typeof this._ellipseSegs=="function")this._ellipseSegs(F,V,g);else{const me=F.center.x,ue=F.center.y,z=F.smAxis||F.majorAxis||{x:F.radius||1,y:0},ee=F.axisRatio??F.minorAxisRatio??.5,Z=F.startAngle??F.startParameter??0,xe=F.endAngle??F.endParameter??Math.PI*2,be=64;let Se,Oe;for(let Ge=0;Ge<=be;Ge++){const Ye=Z+(xe-Z)*(Ge/be),Ke=Math.cos(Ye),Be=Math.sin(Ye),Pe=me+z.x*Ke-z.y*ee*Be,st=ue+z.y*Ke+z.x*ee*Be;Ge>0&&g(Se,Oe,Pe,st,0,V),Se=Pe,Oe=st}}break;case"SOLID":{const me=[F.corner1||F.pt1,F.corner2||F.pt2,F.corner3||F.pt3,F.corner4||F.pt4].filter(Boolean);if(me.length>=2)for(let ue=0;ue<me.length;ue++){const z=me[ue],ee=me[(ue+1)%me.length];z&&ee&&g(z.x,z.y,ee.x,ee.y,0,V)}break}case"MESH":((T=F.vertices)==null?void 0:T.length)>=3&&this._meshSegs(F,V,g);break;case"HATCH":{const me=F.paths||B.paths||[];for(const ue of me){const z=ue.points||ue.vertices;if(!(z!=null&&z.length))continue;const ee=ue.closed!==!1,Z=ue.bulges;Z!=null&&Z.some(xe=>Math.abs(xe)>=1e-6)?this._bulgePolySegs(z,Z,ee,V,g,v):(this._polylineSegs(z,ee,0,V,g),z.forEach(xe=>v(xe.x,xe.y)))}break}case"SPLINE":{const me=(L=F.fitPoints)!=null&&L.length?F.fitPoints:F.controlPoints;(me==null?void 0:me.length)>=2&&this._polylineSegs(me,!!F.closed,0,V,g);break}case"TEXT":case"MTEXT":{const me=B.text??F.text??"",ue=Js(me);if(!ue)break;const z=(B.textHeight??B.height??F.textHeight??F.height??2.5)*_;let ee=(B.rotationAngle??F.rotationAngle??0)+(f.twist||0),Z=0,xe=0,be;if(se==="TEXT")Z=B.horizAlignment??F.horizAlignment??0,xe=B.vertAlignment??F.vertAlignment??0,Z===4&&(xe=2),be=Z!==0||xe!==0?B.alignmentPt??F.alignmentPt??B.insertionPt??F.insertionPt??{x:0,y:0}:B.insertionPt??F.insertionPt??F.insertionPoint??{x:0,y:0};else{const Oe=B.xAxisDir??F.xAxisDir;Oe&&(ee=Math.atan2(Oe.y,Oe.x)+(f.twist||0));const Ge=B.attachment??F.attachment??B.attachmentPoint??F.attachmentPoint??5;Z=[1,4,7].includes(Ge)?0:[3,6,9].includes(Ge)?2:1,xe=[1,2,3].includes(Ge)?3:[7,8,9].includes(Ge)?1:2,be=B.insertionPt??F.insertionPt??F.insertionPoint??{x:0,y:0}}const Se=f(be.x,be.y);if(!b(Se.x,Se.y))break;u.push({text:ue,pos:Se,height:z,rotation:ee,color:V,alignH:Z,alignV:xe,underlay:!!d}),v(be.x,be.y);break}case"INSERT":{const me=B.insertionPt??F.insertionPt??F.insertionPoint;if(!me)break;const ue=F.scaleX??((R=F.scale)==null?void 0:R.x)??((w=B.scale)==null?void 0:w.x)??1,z=F.scaleY??((P=F.scale)==null?void 0:P.y)??((U=B.scale)==null?void 0:U.y)??1,ee=((D=B.blockHeaderHandle)==null?void 0:D.value)??((K=F.blockHeaderHandle)==null?void 0:K.value),Z=ee!=null?ee.toString(16):null,xe=Z?a.get(Z)??[]:[];if(xe.length){const be=u.length;this._insertEntities(xe,{insertionPoint:me,xScale:ue,yScale:z,rotation:F.rotation??B.rotation??0,basePoint:o.get(Z)},V,g,u,{entsByOwner:a,blockBase:o});for(let Se=be;Se<u.length;Se++){const Oe=u[Se];if(!(Oe!=null&&Oe.pos))continue;const Ge=f(Oe.pos.x,Oe.pos.y);Oe.pos=Ge,Oe.height=(Oe.height||2.5)*_,Oe.rotation=(Oe.rotation||0)+(f.twist||0),Oe.underlay=!!d}}v(me.x,me.y);break}default:break}if(oe&&u.length>Ae)for(let me=Ae;me<u.length;me++){const ue=u[me];if(!(ue!=null&&ue.pos))continue;const z=f(ue.pos.x,ue.pos.y);ue.pos=z,ue.height=(ue.height||2.5)*_,ue.rotation=(ue.rotation||0)+(f.twist||0),ue.underlay=!!d}}catch{}for(let me=Ae;me<u.length;me++)u[me].layer===void 0&&(u[me].layer=this._curLayer)}}getStats(){return{entities:this._entityMeta.length,blocks:this._blockCount??0}}snapshotWebPBlob(){return new Promise(e=>{this._renderer.render(this._scene,this._camera),this._renderer.domElement.toBlob(t=>e(t),"image/webp",.75)})}getLayerInfo(){var s,r,a;const e=this._lastResult;if(!e)return[];let t=this._layerInfoCache;if(!t){const o=new Map,l=this._activeSpaceHex?Hl(e.entities||[],this._activeSpaceHex):null;for(const c of e.entities||[]){const u=(r=(s=c.ownerHandle)==null?void 0:s.value)==null?void 0:r.toString(16);if(l&&u&&!l.has(u))continue;const h=this._layerNameOf(c);o.set(h,(o.get(h)||0)+1)}t=(((a=e.tables)==null?void 0:a.layers)||[]).map(c=>{const u=c.name??c.layerName??"0",h=Math.abs(c.colorIndex??c.color??c.colorNumber??7);return{name:u,colorHex:"#"+(Za(h,this._isDark)??Jl).toString(16).padStart(6,"0"),count:o.get(u)||0}}).filter(c=>c.count>0||!c.name.startsWith("*")),this._layerInfoCache=t}const i=this._hiddenLayers||new Set;return t.map(o=>({...o,visible:!i.has(o.name)}))}_resolveComplexLinetype(e){var o,l,c,u,h;let t=e.lineType??e.linetype;if(!t||t==="ByLayer"||t==="BYLAYER"||t==="ByBlock"||t==="BYBLOCK"){const d=((o=e.layerHandle)==null?void 0:o.value)??e.layerHandle;t=d!=null&&((l=this._layerLtByHandle)==null?void 0:l.get(String(d)))||((c=this._layerLtByName)==null?void 0:c.get(e.layer??e.layerName))||null}if(!t||t==="Continuous"||t==="ByLayer"||t==="ByBlock")return null;const i=t.toUpperCase().trim(),s=((u=this._dwgLinPatterns)==null?void 0:u.get(i))||O0(t);if(!s)return null;const r=((h=e.entityHeader)==null?void 0:h.linetypeScale)>0?e.entityHeader.linetypeScale:1,a=(this._globalLtscale||1)*r;return{pattern:s,ltscale:a}}_sampleArcPoints(e,t,i,s,r=0){let a=s-i;a<=0&&(a+=Math.PI*2);const o=Math.max(16,Math.ceil(a/(Math.PI*2)*hf)),l=[],c=e.z||r||0;for(let u=0;u<=o;u++){const h=i+a*u/o;l.push({x:e.x+t*Math.cos(h),y:e.y+t*Math.sin(h),z:c})}return l}_samplePolylinePoints(e,t,i,s=0){if(!e||e.length<2)return e||[];const r=[],a=i?e.length:e.length-1;for(let o=0;o<a;o++){const l=e[o],c=e[(o+1)%e.length],u=(t==null?void 0:t[o])||0,h=l.z||s||0;if(Math.abs(u)<1e-6)r.length===0&&r.push({x:l.x,y:l.y,z:h}),r.push({x:c.x,y:c.y,z:h});else{const d=c.x-l.x,f=c.y-l.y,p=Math.hypot(d,f);if(p>1e-9){const _=4*Math.atan(u),m=Math.abs(_)/2,g=p/2/Math.sin(m),v=g*Math.cos(m),b=(l.x+c.x)/2,x=(l.y+c.y)/2,E=-f/p,S=d/p,A=u>0?1:-1,y=b+A*E*v,T=x+A*S*v,L=Math.atan2(l.y-T,l.x-y),R=Math.max(4,Math.ceil(Math.abs(_)/(Math.PI/16)));for(let w=r.length===0?0:1;w<=R;w++){const P=L+_*w/R;r.push({x:y+g*Math.cos(P),y:T+g*Math.sin(P),z:h})}}}}return r}_sampleEllipsePoints(e){const t=e.majorAxis??e.smAxis??{x:e.radius||1,y:0},i=e.center||{x:0,y:0},s=e.ratio??e.axisRatio??e.minorAxisRatio??.5,r=e.startParam??e.startAngle??0,a=e.endParam??e.endAngle??Math.PI*2,o=Math.hypot(t.x??1,t.y??0),l=o*s,c=Math.atan2(t.y??0,t.x??1);let u=a-r;u<=0&&(u+=Math.PI*2);const h=jl,d=[],f=i.z||0;for(let p=0;p<=h;p++){const _=r+u*p/h,m=o*Math.cos(_),g=l*Math.sin(_),v=i.x+m*Math.cos(c)-g*Math.sin(c),b=i.y+m*Math.sin(c)+g*Math.cos(c);d.push({x:v,y:b,z:f})}return d}_drawComplexPath(e,t,i,s,r,a,o){var g;if(!e||e.length<2)return;const l=e.slice();t&&Math.hypot(l[l.length-1].x-l[0].x,l[l.length-1].y-l[0].y)>1e-6&&l.push(l[0]);const c=[];let u=0;for(let v=0;v<l.length-1;v++){const b=l[v+1].x-l[v].x,x=l[v+1].y-l[v].y,E=Math.hypot(b,x);c.push(E),u+=E}if(u<1e-6)return;const h=v=>{let b=Math.max(0,Math.min(v,u));for(let S=0;S<c.length;S++){const A=c[S];if(b<=A||S===c.length-1){const y=A>1e-9?b/A:0,T=l[S],L=l[S+1],R=T.x+(L.x-T.x)*y,w=T.y+(L.y-T.y)*y,P=(T.z||0)+((L.z||0)-(T.z||0))*y,U=Math.atan2(L.y-T.y,L.x-T.x);return{x:R,y:w,z:P,angle:U}}b-=A}const x=l[l.length-1],E=l[l.length-2];return{x:x.x,y:x.y,z:x.z||0,angle:Math.atan2(x.y-E.y,x.x-E.x)}},d=i.elements||[];if(i.patternLength*s<1e-6||!d.length)return;let p=0;for(const v of d){if(v.type==="shape")break;v.type==="dash"?p+=Math.max((v.val||.05)*s,.01*s):v.type==="gap"&&(p+=Math.abs(v.val||.1)*s)}let _=0,m=0;for(;_<u;){const v=d[m%d.length];if(m++,v.type==="dash"){const b=Math.max((v.val||.05)*s,.01*s),x=_,E=Math.min(_+b,u);if(E>x){const S=h(x),A=h(E);a(S.x,S.y,A.x,A.y,S.z,r)}_+=b}else if(v.type==="gap"){const b=Math.abs(v.val||.1)*s;_+=b}else if(v.type==="shape"){const b=h(_);this._renderShapeSymbol(v,b,s,r,a)}else if(v.type==="text"){const b=h(_);if(v.text&&o){const x=(v.style||"STANDARD").toUpperCase(),E=((g=this._textStyleHeightMap)==null?void 0:g.get(x))||0,S=v.scale>0?v.scale*.5:.1,y=(E>0?E*S:S)*s;let T=b.angle+(v.rotation||0)*Math.PI/180;v.isAbsoluteAngle&&(T=(v.rotation||0)*Math.PI/180);let L=Math.atan2(Math.sin(T),Math.cos(T));L>Math.PI/2?L-=Math.PI:L<-Math.PI/2&&(L+=Math.PI),T=L;const R=Math.cos(T),w=Math.sin(T),P=(v.xOffset||0)*s,U=0,D=d[(m-2+d.length)%d.length],K=d[m%d.length],B=D&&D.type==="gap"?Math.abs(D.val||0)*s:0,ie=K&&K.type==="gap"?Math.abs(K.val||0)*s:0;let F=b;B>ie&&B>1e-6?F=h(_-B/2):ie>1e-6&&(F=h(_+ie/2));const se=F.x+(P*R-U*w),V=F.y+(P*w+U*R);o.push({text:v.text,pos:{x:se,y:V,z:F.z},height:Math.max(y,.01),rotation:T,color:r,alignH:1,alignV:2})}}}}_renderShapeSymbol(e,t,i,s,r){const a=(e.shapeName||"").toUpperCase(),o=(e.scale||.1)*i,l=e.isAbsoluteAngle?(e.rotation||0)*Math.PI/180:t.angle+(e.rotation||0)*Math.PI/180,c=(e.xOffset||0)*i,u=(e.yOffset||0)*i,h=Math.cos(t.angle),d=Math.sin(t.angle),f=t.x+(c*h-u*d),p=t.y+(c*d+u*h),_=t.z||0,m=Math.cos(l),g=Math.sin(l),v=(b,x)=>({x:f+(b*m-x*g)*o,y:p+(b*g+x*m)*o});if(a.includes("KSC35")||a.includes("KSC36")||a.includes("KSC19")||a.includes("ARROW")){for(let A=0;A<=12;A++){const y=A/12,T=-.5+y,L=.25*(1-y),R=v(T,L),w=v(T,-L);r(R.x,R.y,w.x,w.y,_,s)}const x=v(.5,0),E=v(-.5,.25),S=v(-.5,-.25);r(x.x,x.y,E.x,E.y,_,s),r(E.x,E.y,S.x,S.y,_,s),r(S.x,S.y,x.x,x.y,_,s)}else if(a.includes("CIRC")||a.includes("KSC11")||a.includes("KSC01")){let x=v(.3,0);for(let E=1;E<=12;E++){const S=E/12*Math.PI*2,A=v(.3*Math.cos(S),.3*Math.sin(S));r(x.x,x.y,A.x,A.y,_,s),x=A}}else if(a.includes("BOX")||a.includes("KSC02")||a.includes("KSC05")){const b=v(-.3,-.3),x=v(.3,-.3),E=v(.3,.3),S=v(-.3,.3);r(b.x,b.y,x.x,x.y,_,s),r(x.x,x.y,E.x,E.y,_,s),r(E.x,E.y,S.x,S.y,_,s),r(S.x,S.y,b.x,b.y,_,s)}else if(a.includes("TRACK1")){const b=v(0,-.4),x=v(0,.4);r(b.x,b.y,x.x,x.y,_,s)}else if(a.includes("BAT")||a.includes("DIAMOND")){const b=v(0,.4),x=v(.4,0),E=v(0,-.4),S=v(-.4,0);r(b.x,b.y,x.x,x.y,_,s),r(x.x,x.y,E.x,E.y,_,s),r(E.x,E.y,S.x,S.y,_,s),r(S.x,S.y,b.x,b.y,_,s)}else{const b=v(.3,0),x=v(-.3,.2),E=v(-.3,-.2);r(b.x,b.y,x.x,x.y,_,s),r(x.x,x.y,E.x,E.y,_,s),r(E.x,E.y,b.x,b.y,_,s)}}_buildStyleMap(e){if(this._textStyleHeightMap||(this._textStyleHeightMap=new Map),this._textStyleHeightMap.clear(),!(!e||!Array.isArray(e)))for(const t of e){const i=(t.name||t.styleName||"").toUpperCase(),s=t.height??t.fixedTextHeight??0;i&&s>0&&this._textStyleHeightMap.set(i,s)}}_buildLayerMap(e){var t;if(this._layerByHandle.clear(),this._layerByName.clear(),this._layerNameByHandle=new Map,this._layerLwByHandle=new Map,this._layerLwByName=new Map,this._layer0Handle=null,!!e)for(const i of e){const s=((t=i.handle)==null?void 0:t.value)??i.handle,r=i.name??i.layerName,a=Math.abs(i.colorIndex??i.color??i.colorNumber??7),o=Za(a,this._isDark)??Jl;s!=null&&this._layerByHandle.set(String(s),o),r&&this._layerByName.set(r,o),s!=null&&r&&this._layerNameByHandle.set(String(s),r),r==="0"&&s!=null&&(this._layer0Handle=String(s));const l=i.lineWeight??i.lineweight??i.lineWeightRaw;typeof l=="number"&&(s!=null&&this._layerLwByHandle.set(String(s),l),r&&this._layerLwByName.set(r,l))}}_lwPx(e,t=0){var r,a;if(!this._lwDisplay)return 0;let i=((r=e==null?void 0:e.entityHeader)==null?void 0:r.lineWeight)??(e==null?void 0:e.lineWeight)??(e==null?void 0:e.lineweight);if(typeof i!="number")return 0;if(i===-2)return t;if(i===-1){const o=((a=e.layerHandle)==null?void 0:a.value)??e.layerHandle,l=o!=null?this._layerLwByHandle.get(String(o)):void 0,c=e.layer??e.layerName;i=l??(c!=null?this._layerLwByName.get(c):void 0)??-3,(i===-1||i===-2)&&(i=-3)}const s=i===-3?NE:i/100;return s>kE?Math.min(FE,Math.round(s*UE*10)/10):0}_readViewTwist(e){var r;const t=(r=e==null?void 0:e.tables)==null?void 0:r.vports;if(!Array.isArray(t)||!t.length)return 0;const i=t.find(a=>/active/i.test(a.name||""))||t[0],s=i==null?void 0:i.viewTwist;return typeof s=="number"&&isFinite(s)?s:0}_buildLinetypeMap(e){var t,i,s,r;this._ltPatterns=new Map,this._dwgLinPatterns=new Map,this._layerLtByName=new Map,this._layerLtByHandle=new Map,this._globalLtscale=((t=e==null?void 0:e.vars)==null?void 0:t.ltscale)>0?e.vars.ltscale:1;for(const a of((i=e==null?void 0:e.tables)==null?void 0:i.lineTypes)??[])if(a!=null&&a.name){const o=Array.isArray(a.pattern)?a.pattern:[];if(this._ltPatterns.set(a.name,o),o.length>0){const l=PE(a.name,o,a.description);l&&this._dwgLinPatterns.set(a.name.toUpperCase().trim(),l)}}for(const a of((s=e==null?void 0:e.tables)==null?void 0:s.layers)??[]){const o=a.name??a.layerName,l=((r=a.handle)==null?void 0:r.value)??a.handle,c=a.lineType??a.linetype;o&&c&&this._layerLtByName.set(o,c),l!=null&&c&&this._layerLtByHandle.set(String(l),c)}}_resolveDash(e){var l,c;if(!this._ltPatterns||this._ltPatterns.size===0)return null;let t=e.lineType??e.linetype;if(!t||t==="ByLayer"||t==="BYLAYER"||t==="ByBlock"||t==="BYBLOCK"){const u=((l=e.layerHandle)==null?void 0:l.value)??e.layerHandle;t=u!=null&&this._layerLtByHandle.get(String(u))||this._layerLtByName.get(e.layer??e.layerName)||null}if(!t||t==="Continuous"||t==="ByLayer"||t==="ByBlock")return null;const i=this._ltPatterns.get(t);if(!i||i.length===0)return null;const s=((c=e.entityHeader)==null?void 0:c.linetypeScale)>0?e.entityHeader.linetypeScale:1,r=this._globalLtscale*s;let a=0,o=0;for(const u of i){const h=Math.abs(u)*r;u>1e-6?a+=h:u<-1e-6?o+=h:a+=Math.max(h,.01*r)}return a<1e-4||o<1e-4?null:{key:`${a.toFixed(3)}|${o.toFixed(3)}`,dash:a,gap:o}}_resolveBlockColor(e,t){var r,a;const i=((r=e.entityHeader)==null?void 0:r.colorIndex)??e.color??e.colorIndex??e.colorNumber??256;if(i===0)return t;const s=String(((a=e.layerHandle)==null?void 0:a.value)??e.layerHandle??"");return i===256&&this._layer0Handle&&s===this._layer0Handle?t:this._entityColor(e)}_entityColor(e){var r,a;const t=((r=e.entityHeader)==null?void 0:r.colorIndex)??e.color??e.colorIndex??e.colorNumber??256;if(t!=null){const o=Za(t,this._isDark);if(o!==null)return o}const i=((a=e.layerHandle)==null?void 0:a.value)??e.layerHandle;if(i!=null){const o=this._layerByHandle.get(String(i));if(o!==void 0)return o}const s=e.layer??e.layerName;if(s){const o=this._layerByName.get(s);if(o!==void 0)return o}return Jl}_arrowMesh(e,t,i,s){if(!e||i<1e-4)return;const r=i*.166,a=(s>>16&255)/255,o=(s>>8&255)/255,l=(s&255)/255,c=new wt;c.setAttribute("position",new dt([0,0,0,-i,r,0,-i,-r,0],3)),c.setAttribute("color",new dt([a,o,l,a,o,l,a,o,l],3));const u=new Ht(c,new ti({vertexColors:!0,side:Yt}));u.position.set(e.x,e.y,(e.z||0)+.5),u.rotation.z=t,this._addObj(u)}_defaultArrow(e,t,i,s,r,a){if(!t||s<1e-4)return;const o=(e||"").replace(/^[_*]+/,""),l=Math.cos(i),c=Math.sin(i),u=(h,d)=>({x:t.x+h*l-d*c,y:t.y+h*c+d*l});if(!(o==="none"||o==="small"||o==="integral")){if(o==="dot"||o==="dotsmall"||o==="dotblank"||o==="dotsmallblank"||o==="origin"||o==="origin2"){this._dotMesh(t,s*(o==="dotsmall"?.12:.5),r);return}if(o==="oblique"||o==="archtick"){const h=u(s*.5,s*.5),d=u(-s*.5,-s*.5);a(h.x,h.y,d.x,d.y,(t.z||0)+.5,r);return}if(o==="open"||o==="open30"||o==="open90"){const h=o==="open90"?s:s*.42,d=u(0,0),f=u(-s,h),p=u(-s,-h);a(f.x,f.y,d.x,d.y,(t.z||0)+.5,r),a(p.x,p.y,d.x,d.y,(t.z||0)+.5,r);return}this._arrowMesh(t,i,s,r)}}_dotMesh(e,t,i){if(!e||!(t>1e-5))return;const s=(i>>16&255)/255,r=(i>>8&255)/255,a=(i&255)/255,o=20,l=[],c=[],u=(e.z||0)+.5;for(let d=0;d<o;d++){const f=d/o*Math.PI*2,p=(d+1)/o*Math.PI*2;l.push(e.x,e.y,u,e.x+t*Math.cos(f),e.y+t*Math.sin(f),u,e.x+t*Math.cos(p),e.y+t*Math.sin(p),u),c.push(s,r,a,s,r,a,s,r,a)}const h=new wt;h.setAttribute("position",new dt(l,3)),h.setAttribute("color",new dt(c,3)),this._addObj(new Ht(h,new ti({vertexColors:!0,side:Yt})))}_arrowDotRadius(e){let t=0;for(const i of e||[]){const s=i.data||i;(i.type||"").toUpperCase()==="CIRCLE"&&s.radius&&(t=Math.max(t,s.radius));const r=s.points??s.vertices;if(r!=null&&r.length){let a=0,o=0;r.forEach(l=>{a+=l.x,o+=l.y}),a/=r.length,o/=r.length,r.forEach(l=>{t=Math.max(t,Math.hypot(l.x-a,l.y-o))})}}return t}_arcSegs(e,t,i,s,r,a,o){let l=s-i;l<=0&&(l+=Math.PI*2);const c=Math.max(8,Math.ceil(l/(Math.PI*2)*hf));let u=null;for(let h=0;h<=c;h++){const d=i+l*h/c,f=e.x+t*Math.cos(d),p=e.y+t*Math.sin(d);u&&o(u.x,u.y,f,p,r,a),u={x:f,y:p}}}_catmullRom(e,t){const i=e.length,s=t*(i-1),r=Math.min(Math.floor(s),i-2),a=s-r,o=e[Math.max(r-1,0)],l=e[r],c=e[r+1],u=e[Math.min(r+2,i-1)],h=a*a,d=h*a;return{x:.5*(2*l.x+(-o.x+c.x)*a+(2*o.x-5*l.x+4*c.x-u.x)*h+(-o.x+3*l.x-3*c.x+u.x)*d),y:.5*(2*l.y+(-o.y+c.y)*a+(2*o.y-5*l.y+4*c.y-u.y)*h+(-o.y+3*l.y-3*c.y+u.y)*d),z:.5*(2*(l.z||0)+(-(o.z||0)+(c.z||0))*a+(2*(o.z||0)-5*(l.z||0)+4*(c.z||0)-(u.z||0))*h+(-(o.z||0)+3*(l.z||0)-3*(c.z||0)+(u.z||0))*d)}}_ellipseSegs(e,t,i){const s=e.majorAxis??e.smAxis??{x:1,y:0},r=e.center,a=e.ratio??e.axisRatio??1,o=e.startParam??0,l=e.endParam??Math.PI*2,c=(s==null?void 0:s.x)??1,u=(s==null?void 0:s.y)??0,h=Math.sqrt(c*c+u*u),d=h*a,f=Math.atan2(u,c);let p=l-o;p<=0&&(p+=Math.PI*2);let _=null;for(let m=0;m<=jl;m++){const g=o+p*m/jl,v=h*Math.cos(g),b=d*Math.sin(g),x=r.x+v*Math.cos(f)-b*Math.sin(f),E=r.y+v*Math.sin(f)+b*Math.cos(f);_&&i(_.x,_.y,x,E,r.z||0,t),_={x,y:E}}}_polylineSegs(e,t,i,s,r){if(!(!e||e.length<2)){for(let a=0;a<e.length-1;a++)r(e[a].x,e[a].y,e[a+1].x,e[a+1].y,i,s);if(t){const a=e[e.length-1],o=e[0];r(a.x,a.y,o.x,o.y,i,s)}}}_meshSegs(e,t,i,s=null){const r=e.vertices;if(!(r!=null&&r.length))return;const a=r.length/3|0,o=(u,h)=>{if(u===h||!(u>=0&&u<a)||!(h>=0&&h<a))return;let d=r[u*3],f=r[u*3+1],p=r[h*3],_=r[h*3+1];const m=((r[u*3+2]||0)+(r[h*3+2]||0))/2;s&&([d,f]=s(d,f),[p,_]=s(p,_)),i(d,f,p,_,m,t)},l=e.edges;if((l==null?void 0:l.length)>=2){for(let u=0;u+1<l.length;u+=2)o(l[u],l[u+1]);return}const c=e.faceList;if(c!=null&&c.length)for(let u=0;u<c.length;){const h=c[u++];if(!(h>=3)||u+h>c.length)break;for(let d=0;d<h;d++)o(c[u+d],c[u+(d+1)%h]);u+=h}}_segWidths(e,t,i=1){var d,f;const s=(e==null?void 0:e.data)||e||{},r=(s.constantWidth??s.constWidth??0)*i,a=(s.defaultStartWidth??0)*i,o=(s.defaultEndWidth??0)*i,l=(((d=s.startWidths)==null?void 0:d[t])??0)*i,c=(((f=s.endWidths)==null?void 0:f[t])??0)*i,u=Math.abs(l)>1e-12?l:Math.abs(r)>1e-12?r:a,h=Math.abs(c)>1e-12?c:Math.abs(r)>1e-12?r:o;return{sw:Math.abs(u),ew:Math.abs(h)}}_polyHasWidth(e,t,i=1){for(let s=0;s<t;s++){const{sw:r,ew:a}=this._segWidths(e,s,i);if(r>1e-9||a>1e-9)return!0}return!1}_pushWideSeg(e,t,i,s,r){const a=i.x-t.x,o=i.y-t.y,l=Math.hypot(a,o);if(l<1e-12)return;const c=-o/l,u=a/l,h=s*.5,d=r*.5,f={x:t.x+c*h,y:t.y+u*h},p={x:t.x-c*h,y:t.y-u*h},_={x:i.x-c*d,y:i.y-u*d},m={x:i.x+c*d,y:i.y+u*d};e.push(f.x,f.y,0,p.x,p.y,0,_.x,_.y,0),e.push(f.x,f.y,0,_.x,_.y,0,m.x,m.y,0)}_widePolyMesh(e,t,i,s,r,a=1,o=null){if(!e||e.length<2)return;const l=e.length,c=i?l:l-1,u=[];for(let f=0;f<c;f++){const p=e[f],_=e[(f+1)%l],{sw:m,ew:g}=this._segWidths(s,f,a);if(m<1e-9&&g<1e-9){this._pushWideSeg(u,p,_,.01*a,.01*a),o&&(o(p.x,p.y),o(_.x,_.y));continue}const v=(t==null?void 0:t[f])||0;if(Math.abs(v)<1e-6)this._pushWideSeg(u,p,_,m,g),o&&(o(p.x,p.y),o(_.x,_.y));else{const b=_.x-p.x,x=_.y-p.y,E=Math.hypot(b,x);if(E<1e-9)continue;const S=4*Math.atan(v),A=Math.abs(S)/2,y=E/2/Math.sin(A),T=y*Math.cos(A),L=(p.x+_.x)/2,R=(p.y+_.y)/2,w=-x/E,P=b/E,U=v>0?1:-1,D=L+U*w*T,K=R+U*P*T,B=Math.atan2(p.y-K,p.x-D),ie=Math.max(2,Math.ceil(Math.abs(S)/(Math.PI/16)));let F={x:p.x,y:p.y},se=m;for(let V=1;V<=ie;V++){const oe=V/ie,Ae=B+S*V/ie,me={x:D+y*Math.cos(Ae),y:K+y*Math.sin(Ae)},ue=m+(g-m)*oe;this._pushWideSeg(u,F,me,se,ue),F=me,se=ue}o&&(o(p.x,p.y),o(_.x,_.y))}}if(u.length<9)return;const h=new wt;h.setAttribute("position",new dt(u,3)),h.computeVertexNormals();const d=new ti({color:new it(r),side:Yt,depthWrite:!1});if(this._addObj(new Ht(h,d)),this._pickCurIdx>=0&&this._pickSegs)for(let f=0;f<c;f++){const p=e[f],_=e[(f+1)%l];this._pickSegs.push(p.x,p.y,_.x,_.y),this._pickSegMeta.push(this._pickCurIdx)}}_bulgePolySegs(e,t,i,s,r,a){const o=e.length,l=i?o:o-1;for(let c=0;c<l;c++){const u=e[c],h=e[(c+1)%o],d=(t==null?void 0:t[c])||0;if(Math.abs(d)<1e-6)r(u.x,u.y,h.x,h.y,0,s),a&&(a(u.x,u.y),a(h.x,h.y));else{const f=h.x-u.x,p=h.y-u.y,_=Math.sqrt(f*f+p*p);if(_<1e-9)continue;const m=4*Math.atan(d),g=Math.abs(m)/2,v=_/2/Math.sin(g),b=v*Math.cos(g),x=(u.x+h.x)/2,E=(u.y+h.y)/2,S=-p/_,A=f/_,y=d>0?1:-1,T=x+y*S*b,L=E+y*A*b,R=Math.atan2(u.y-L,u.x-T),w=Math.max(2,Math.ceil(Math.abs(m)/(Math.PI/16)));let P=u;for(let U=1;U<=w;U++){const D=R+m*U/w,K=T+v*Math.cos(D),B=L+v*Math.sin(D);r(P.x,P.y,K,B,0,s),P={x:K,y:B}}a&&(a(u.x,u.y),a(h.x,h.y))}}}_solidMesh(e,t){const i=(t>>16&255)/255,s=(t>>8&255)/255,r=(t&255)/255,a=[],o=[],l=(...u)=>{for(const h of u)a.push(h.x,h.y,h.z||0),o.push(i,s,r)};e.length>=4?(l(e[0],e[1],e[3]),l(e[0],e[3],e[2])):l(e[0],e[1],e[2]);const c=new wt;if(c.setAttribute("position",new dt(a,3)),c.setAttribute("color",new dt(o,3)),this._addObj(new Ht(c,new ti({vertexColors:!0,side:Yt}))),this._pickCurIdx>=0&&e.length>=3){const u=e.length>=4?[e[0],e[1],e[3],e[2]]:e.slice(0,3);this._pickFills.push({metaIdx:this._pickCurIdx,loops:[u]})}}_addTextPick(e,t,i,s=0,r=0){if(this._pickCurIdx<0||!t)return;const a=String(e).split(`
`),l=a.reduce((d,f)=>Math.max(d,f.length),1)*i*.62,c=a.length*i*1.2;let u=t.x;s===2?u=t.x-l:(s===1||s===4)&&(u=t.x-l/2);let h=t.y;r===3?h=t.y-c:r===2&&(h=t.y-c/2),this._pickFills.push({metaIdx:this._pickCurIdx,loops:[[{x:u,y:h},{x:u+l,y:h},{x:u+l,y:h+c},{x:u,y:h+c}]]})}_fillHit(e,t,i){let s=!1;for(const r of e)for(let a=0,o=r.length-1;a<r.length;o=a++){const l=r[a].x,c=r[a].y,u=r[o].x,h=r[o].y;c>i!=h>i&&t<(u-l)*(i-c)/(h-c)+l&&(s=!s)}return s}_pointInAnyLoop(e,t,i){for(const s of e){if(!(s!=null&&s.length))continue;let r=!1;for(let a=0,o=s.length-1;a<s.length;o=a++){const l=s[a],c=s[o];l.y>i!=c.y>i&&t<(c.x-l.x)*(i-l.y)/(c.y-l.y)+l.x&&(r=!r)}if(r)return!0}return!1}_loopArea(e){let t=0;for(let i=0;i<e.length;i++){const s=e[i],r=e[(i+1)%e.length];t+=s.x*r.y-r.x*s.y}return Math.abs(t)/2}_fillClosedPolyIfUncovered(e,t,i){if(!e||e.length<3)return;const s=e[0],r=e[e.length-1],a=Math.hypot(s.x-r.x,s.y-r.y);let o=1/0,l=1/0,c=-1/0,u=-1/0;for(const m of e)m.x<o&&(o=m.x),m.y<l&&(l=m.y),m.x>c&&(c=m.x),m.y>u&&(u=m.y);const h=Math.hypot(c-o,u-l)||1;if(a>h*1e-4&&a>1e-6)return;let d=0;for(let m=0;m<e.length;m++){const g=e[m],v=e[(m+1)%e.length];d+=g.x*v.y-v.x*g.y}const f=Math.abs(d)/2;if(f<1e-6||f>5e3)return;let p=0,_=0;for(const m of e)p+=m.x,_+=m.y;p/=e.length,_/=e.length;for(const m of this._pickFills)if(this._pointInAnyLoop(m.loops,p,_))return;this._hatchFill([{points:e,bulges:t||null,closed:!0}],i)}_pathPoints(e){const t=e.points;if(!(t!=null&&t.length))return null;const i=e.bulges,s=t.length;if(!(i!=null&&i.some(a=>Math.abs(a)>=1e-6)))return t.map(a=>({x:a.x,y:a.y}));const r=[];for(let a=0;a<s;a++){const o=t[a],l=t[(a+1)%s],c=i[a]||0;if(r.push({x:o.x,y:o.y}),Math.abs(c)<1e-6)continue;const u=l.x-o.x,h=l.y-o.y,d=Math.hypot(u,h);if(d<1e-9)continue;const f=4*Math.atan(c),p=Math.abs(f)/2,_=d/2/Math.sin(p),m=_*Math.cos(p),g=(o.x+l.x)/2,v=(o.y+l.y)/2,b=-h/d,x=u/d,E=c>0?1:-1,S=g+E*b*m,A=v+E*x*m,y=Math.atan2(o.y-A,o.x-S),T=Math.max(6,Math.ceil(Math.abs(f)/(Math.PI/16)));for(let L=1;L<T;L++){const R=y+f*L/T;r.push({x:S+_*Math.cos(R),y:A+_*Math.sin(R)})}}return r}_hatchFill(e,t){if(e.reduce((l,c)=>{var u;return l+(((u=c.points)==null?void 0:u.length)??0)},0)>8e3)return;let s=[];for(const l of e){const c=this._pathPoints(l);c&&c.length>=3&&s.push(c)}if(!s.length)return;const r=l=>{let c=0;for(let u=0;u<l.length;u++){const h=l[u],d=l[(u+1)%l.length];c+=h.x*d.y-d.x*h.y}return Math.abs(c)/2};if(e.some(l=>{var c;return!((c=l.points)!=null&&c.length)})&&s.length>=3||s.length>=5){const l=s.map(r).sort((u,h)=>u-h),c=l[Math.floor(l.length/2)]||0;if(c>0&&(s=s.filter(u=>r(u)<=c*10)),!s.length)return}if(this._pickCurIdx>=0&&s.length&&this._pickFills.push({metaIdx:this._pickCurIdx,loops:s}),s.length>=5||s.some(l=>this._polySelfIntersects(l))||this._hatchHasNestedLoop(s)){this._hatchFillEvenOddCanvas(s,t);return}const o=new ti({color:new it(t),side:Yt});for(const l of s)try{const c=new ap;c.moveTo(l[0].x,l[0].y);for(let u=1;u<l.length;u++)c.lineTo(l[u].x,l[u].y);c.closePath(),this._addObj(new Ht(new Eu(c),o))}catch{}}_hatchHasNestedLoop(e){if(e.length<2)return!1;const t=o=>{let l=0;for(let c=0;c<o.length;c++){const u=o[c],h=o[(c+1)%o.length];l+=u.x*h.y-h.x*u.y}return Math.abs(l)/2},i=o=>{let l=1/0,c=1/0,u=-1/0,h=-1/0;for(const d of o)d.x<l&&(l=d.x),d.y<c&&(c=d.y),d.x>u&&(u=d.x),d.y>h&&(h=d.y);return{minX:l,minY:c,maxX:u,maxY:h}},s=(o,l)=>{let c=!1;for(let u=0,h=o.length-1;u<o.length;h=u++){const d=o[u],f=o[h];d.y>l.y!=f.y>l.y&&l.x<(f.x-d.x)*(l.y-d.y)/(f.y-d.y)+d.x&&(c=!c)}return c},r=e.map(t),a=e.map(i);for(let o=0;o<e.length;o++){let l=0,c=0;for(const u of e[o])l+=u.x,c+=u.y;l/=e[o].length,c/=e[o].length;for(let u=0;u<e.length;u++){if(o===u||r[u]<=r[o])continue;const h=a[u],d=a[o];if(h.minX<=d.minX&&h.minY<=d.minY&&h.maxX>=d.maxX&&h.maxY>=d.maxY||s(e[u],{x:l,y:c}))return!0}}return!1}_polySelfIntersects(e){const t=e.length;if(t<4)return!1;const i=(a,o,l)=>(o.x-a.x)*(l.y-a.y)-(o.y-a.y)*(l.x-a.x),s=(a,o,l,c)=>{const u=i(a,o,l),h=i(a,o,c),d=i(l,c,a),f=i(l,c,o);return(u>0&&h<0||u<0&&h>0)&&(d>0&&f<0||d<0&&f>0)},r=Math.min(t,80);for(let a=0;a<r;a++){const o=e[a],l=e[(a+1)%t];for(let c=a+2;c<r;c++)if(!(a===0&&c===t-1)&&c!==(a+t-1)%t&&s(o,l,e[c],e[(c+1)%t]))return!0}return!1}_isDiameterInflatedPath(e){if(!e||e.length<8)return!1;let t=1/0,i=1/0,s=-1/0,r=-1/0;for(const v of e)v.x<t&&(t=v.x),v.y<i&&(i=v.y),v.x>s&&(s=v.x),v.y>r&&(r=v.y);const a=s-t,o=r-i,l=Math.min(a,o);if(!(l>1e-9))return!1;const c=(t+s)/2,u=(i+r)/2,h=.55*l,d=.22*l;let f=0;for(let v=0;v<e.length;v++){const b=e[v],x=e[(v+1)%e.length];if(Math.hypot(x.x-b.x,x.y-b.y)<h)continue;const S=(b.x+x.x)/2,A=(b.y+x.y)/2;Math.hypot(S-c,A-u)<=d&&f++}if(!f)return!1;let p=0;for(let v=0;v<e.length;v++){const b=e[v],x=e[(v+1)%e.length];p+=b.x*x.y-x.x*b.y}const _=Math.abs(p)/2,m=this._convexHull(e);if(m.length<3)return!1;let g=0;for(let v=0;v<m.length;v++){const b=m[v],x=m[(v+1)%m.length];g+=b.x*x.y-x.x*b.y}return g=Math.abs(g)/2,g>1e-9&&_>g*1.15}_convexHull(e){const t=e.map(a=>({x:a.x,y:a.y})).sort((a,o)=>a.x-o.x||a.y-o.y);if(t.length<=2)return t;const i=(a,o,l)=>(o.x-a.x)*(l.y-a.y)-(o.y-a.y)*(l.x-a.x),s=[];for(const a of t){for(;s.length>=2&&i(s[s.length-2],s[s.length-1],a)<=0;)s.pop();s.push(a)}const r=[];for(let a=t.length-1;a>=0;a--){const o=t[a];for(;r.length>=2&&i(r[r.length-2],r[r.length-1],o)<=0;)r.pop();r.push(o)}return s.pop(),r.pop(),s.concat(r)}_polyCentroid(e){let t=0,i=0;for(const s of e)t+=s.x,i+=s.y;return{x:t/e.length,y:i/e.length}}_pointInPoly(e,t){let i=!1;for(let s=0,r=e.length-1;s<e.length;r=s++){const a=e[s],o=e[r];a.y>t.y!=o.y>t.y&&t.x<(o.x-a.x)*(t.y-a.y)/(o.y-a.y)+a.x&&(i=!i)}return i}_hatchFillEvenOddCanvas(e,t){let i=1/0,s=1/0,r=-1/0,a=-1/0;for(const w of e)for(const P of w)P.x<i&&(i=P.x),P.y<s&&(s=P.y),P.x>r&&(r=P.x),P.y>a&&(a=P.y);const o=r-i,l=a-s;if(!(o>1e-12)||!(l>1e-12))return;const c=2048,u=Math.min(c/o,c/l,64),h=Math.max(2,Math.ceil(o*u)+2),d=Math.max(2,Math.ceil(l*u)+2),f=(h-2)/o,p=(d-2)/l,_=document.createElement("canvas");_.width=h,_.height=d;const m=_.getContext("2d");if(!m)return;m.clearRect(0,0,h,d);const g=w=>({x:1+(w.x-i)*f,y:1+(a-w.y)*p}),v=w=>{if(w.length<3)return;const P=g(w[0]);m.moveTo(P.x,P.y);for(let U=1;U<w.length;U++){const D=g(w[U]);m.lineTo(D.x,D.y)}m.closePath()},b=[],x=[];for(const w of e)this._isDiameterInflatedPath(w)?b.push(w):x.push(w);const E=b.map(w=>this._convexHull(w)),S=w=>{if(w.length<3||!E.length)return!1;const P=this._polyCentroid(w);for(const U of E)if(U.length>=3&&this._pointInPoly(U,P))return!0;return!1};if(b.length){m.fillStyle="#ffffff",m.beginPath();for(const P of b)v(P);m.fill("nonzero");const w=x.filter(S);if(w.length){m.globalCompositeOperation="destination-out",m.beginPath();for(const P of w)v(P);m.fill("nonzero"),m.globalCompositeOperation="source-over"}}const A=x.filter(w=>!S(w));if(A.length){m.fillStyle="#ffffff",m.beginPath();for(const w of A)v(w);m.fill("evenodd")}const y=new Fa(_);y.colorSpace=vi,y.magFilter=Jt,y.minFilter=Yi,y.generateMipmaps=!0,y.needsUpdate=!0;const T=new ti({map:y,color:new it(t),transparent:!0,alphaTest:.4,side:Yt,depthWrite:!1}),L=new fs(o,l),R=new Ht(L,T);R.position.set((i+r)/2,(s+a)/2,0),this._addObj(R)}_multilineSprite(e,t,i,s,r,a,o,l=0){const u="96px 'Malgun Gothic', 'Apple SD Gothic Neo', monospace",h=document.createElement("canvas"),d=h.getContext("2d");d.font=u;let f=1,p=96*.7,_=96*.2;for(const U of e){const D=d.measureText(U||" ");f=Math.max(f,Math.ceil(D.width)),p=Math.max(p,D.actualBoundingBoxAscent||96*.7),_=Math.max(_,D.actualBoundingBoxDescent||96*.2)}const m=Math.ceil(96*.15),g=Math.ceil(p+_+96*.35);h.width=f+m*2,h.height=g*e.length+m*2,d.font=u;const v=r>>16&255,b=r>>8&255,x=r&255;d.fillStyle=`rgb(${v},${b},${x})`,d.textBaseline="alphabetic";let E=m;a===1||a===4?(d.textAlign="center",E=h.width/2):a===2?(d.textAlign="right",E=h.width-m):(d.textAlign="left",E=m);for(let U=0;U<e.length;U++)d.fillText(e[U],E,m+p+U*g);const S=new Fa(h),A=i/p,y=h.width*A,T=h.height*A;let L=0,R=0;a===0||a===3||a===5?L=y/2:a===2&&(L=-y/2),o===3?R=-T/2:(o===0||o===1)&&(R=T/2);const w=new Xc({map:S,transparent:!0,depthTest:!1});s&&(w.rotation=s);const P=new xh(w);P.scale.set(y,T,1),P.position.set(t.x+L,t.y+R,1),P.renderOrder=l,this._addObj(P)}_drawMTextBackground(e,t,i){var R,w;const s=e.bgFillFlags|0;if(!s)return;const r=!!(s&1)||!!(s&2),a=!!(s&16);if(!r&&!a)return;const o=Math.max(e.height||2.5,i||0),l=String(e.text||"").split(`
`),c=e.linespacingFactor>0?e.linespacingFactor:1,u=o*(5/3)*c;let h=0;if(t!=null&&t.measureEm)for(const P of l)h=Math.max(h,t.measureEm(P||" "));else for(const P of l)h=Math.max(h,(P||" ").length*.9);let d=Math.max(h*o,o*.5),f=l.length<=1?o:o+(l.length-1)*u;e.rectWidth>0&&(d=Math.max(d,e.rectWidth)),e.rectHeight>0&&(f=Math.max(f,e.rectHeight));const p=e.bgScale>0?e.bgScale:1.5,_=d*p,m=f*p,g=e.alignH??1,v=e.alignV??2;let b=0,x=0;g===0||g===3||g===5?b=d/2:g===2&&(b=-d/2),v===3?x=-f/2:(v===0||v===1)&&(x=f/2);const E=e.rotation||0,S=Math.cos(E),A=Math.sin(E),y=e.pos.x+b*S-x*A,T=e.pos.y+b*A+x*S;let L=16776960;if(s&2)L=((w=(R=this._scene)==null?void 0:R.background)==null?void 0:w.r)<.5?658189:16250611;else if(e.bgColorRgb&&e.bgColorRgb.r!=null)L=(e.bgColorRgb.r&255)<<16|(e.bgColorRgb.g&255)<<8|e.bgColorRgb.b&255;else if(e.bgColorIndex!=null){const P=Za(e.bgColorIndex,this._isDark);P!=null&&(L=P)}if(r){const P=new fs(_,m),U=new ti({color:new it(L),side:Yt,depthWrite:!1,transparent:!1}),D=new Ht(P,U);D.position.set(y,T,.4),D.rotation.z=E,this._addObj(D)}if(a&&!r){const P=_/2,U=m/2,K=[[-P,-U],[P,-U],[P,U],[-P,U],[-P,-U]].map(([B,ie])=>({x:y+B*S-ie*A,y:T+B*A+ie*S}));for(let B=0;B<4;B++){const ie=K[B],F=K[B+1];this._widePolyMesh([ie,F],null,!1,{constantWidth:Math.max(o*.05,.01)},L,1,null)}}}async _drawTexts(e,t){const i=this._textGen,s=e.filter(o=>o.underlay),r=e.filter(o=>!o.underlay),a=[{list:s,order:0},{list:r,order:1}];try{const o=await ta.shared();if(i!==this._textGen)return;for(const{list:l,order:c}of a)if(l.length){for(const u of l)u.bgFillFlags|0&&(this._curLayer=u.layer??"0",this._drawMTextBackground(u,o,t));for(const[u,h]of HE(l)){const d=new EE(o);for(const p of h)d.add(p.text,p.pos,Math.max(p.height,t),p.rotation||0,p.color,p.alignH??0,p.alignV??0);const f=d.build();f&&(f.renderOrder=c,f.material&&(f.material.depthWrite=!1,f.material.transparent=!0),this._addObj(f,u))}}}catch(o){if(console.warn("[Viewer2D] Slug text unavailable, falling back to canvas sprites:",(o==null?void 0:o.message)??o),i!==this._textGen)return;for(const{list:l,order:c}of a)for(const u of l)this._curLayer=u.layer??"0",u.bgFillFlags|0&&this._drawMTextBackground(u,null,t),this._textSprite(u.text,u.pos,Math.max(u.height,t),u.rotation,u.color,u.alignH??0,u.alignV??0,c)}}_textSprite(e,t,i,s,r,a=0,o=0,l=0){const c=String(e).split(`
`);if(c.length>1){this._multilineSprite(c,t,i,s,r,a,o,l);return}const u=e+"\0"+r;let h=(this._texCache??(this._texCache=new Map)).get(u);if(!h){const y="96px 'Malgun Gothic', 'Apple SD Gothic Neo', monospace",T=document.createElement("canvas"),L=T.getContext("2d");L.font=y;const R=L.measureText(e),w=Math.max(1,Math.ceil(R.width)),P=R.actualBoundingBoxAscent||96*.7,U=R.actualBoundingBoxDescent||96*.2,D=Math.ceil(96*.15);T.width=w+D*2,T.height=Math.ceil(P+U)+D*2,L.font=y;const K=r>>16&255,B=r>>8&255,ie=r&255;L.fillStyle=`rgb(${K},${B},${ie})`,L.textBaseline="alphabetic",L.fillText(e,D,D+P),h={texture:new Fa(T),w:T.width,h:T.height,asc:P,pad:D},this._texCache.set(u,h)}const{texture:d,asc:f,pad:p}=h,_=i*h.h/f,m=_*(h.w/h.h),g=_/h.h,v=h.h/2;let b=0;a===0||a===3||a===5?b=m/2:a===1||a===4?b=0:a===2&&(b=-m/2);let x=0;a!==4&&(o===0||o===1?x=(p+f-v)*g:o===3&&(x=(p-v)*g));const E=new Xc({map:d,transparent:!0,depthTest:!1});s&&(E.rotation=s);const S=new xh(E);S.scale.set(m,_,1),S.position.set(t.x+b,t.y+x,1),S.renderOrder=l,this._addObj(S)}_insertEntities(e,t,i,s,r,a){var T,L,R,w,P,U,D,K,B,ie,F;const o=a==null?void 0:a.entsByOwner,l=a==null?void 0:a.blockBase,c=(a==null?void 0:a.parentXf)??null,u=(a==null?void 0:a.scale)??1,h=(a==null?void 0:a.rot)??0,d=(a==null?void 0:a.depth)??0,f=t.insertionPoint??{x:0,y:0},p=t.basePoint,_=t.xScale??1,m=t.yScale??1,g=t.rotation??0,v=Math.cos(g),b=Math.sin(g),x=(se,V)=>{const oe=p?se-p.x:se,Ae=p?V-p.y:V;return[f.x+oe*_*v-Ae*m*b,f.y+oe*_*b+Ae*m*v]},E=c?(se,V)=>c(...x(se,V)):x,S=u*Math.max(Math.abs(_),Math.abs(m)),A=h+g,y=this._curLwPx;for(const se of e){const V=se.data||se,oe=(se.type||se.typeName||"").toUpperCase();if(oe==="ATTDEF")continue;const Ae=this._resolveBlockColor(se,i);this._curLwPx=this._lwPx(se,y);try{if(oe==="LINE"&&V.start&&V.end){const[me,ue]=E(V.start.x,V.start.y),[z,ee]=E(V.end.x,V.end.y);s(me,ue,z,ee,0,Ae)}else if(oe==="MESH"&&((T=V.vertices)==null?void 0:T.length)>=3)this._meshSegs(V,Ae,s,E);else if((oe==="CIRCLE"||oe==="ARC")&&V.center&&V.radius!=null){const[me,ue]=E(V.center.x,V.center.y),z=V.radius*S,ee=oe==="ARC"?(V.startAngle??0)+A:0,Z=oe==="ARC"?(V.endAngle??Math.PI*2)+A:Math.PI*2;this._arcSegs({x:me,y:ue,z:0},z,ee,Z,0,Ae,s)}else if(oe==="ELLIPSE"&&V.center){const[me,ue]=E(V.center.x,V.center.y),z=V.majorAxis??V.smAxis??{x:1,y:0},ee=Math.hypot(z.x??0,z.y??0)*S,Z=Math.atan2(z.y??0,z.x??1)+A;this._ellipseSegs({center:{x:me,y:ue,z:0},majorAxis:{x:ee*Math.cos(Z),y:ee*Math.sin(Z)},ratio:V.ratio??V.axisRatio??1,startParam:V.startParam??0,endParam:V.endParam??Math.PI*2},Ae,s)}else if((oe==="LWPOLYLINE"||oe==="POLYLINE")&&(V.points||V.vertices)){const ue=(V.points??V.vertices).map(xe=>{const[be,Se]=E(xe.x,xe.y);return{x:be,y:Se}}),z=V.bulges??null,ee=!!(V.closed||V.flags&1);let Z=!1;if(ue.length>=2&&this._pickFills.length){let xe=0,be=0,Se=1/0,Oe=1/0,Ge=-1/0,Ye=-1/0;for(const Pe of ue)xe+=Pe.x,be+=Pe.y,Pe.x<Se&&(Se=Pe.x),Pe.y<Oe&&(Oe=Pe.y),Pe.x>Ge&&(Ge=Pe.x),Pe.y>Ye&&(Ye=Pe.y);xe/=ue.length,be/=ue.length;const Ke=Math.max(Ge-Se,1e-9),Be=Math.max(Ye-Oe,1e-9);for(const Pe of this._pickFills)if(this._pointInAnyLoop(Pe.loops,xe,be)){for(const st of Pe.loops){if(!(st!=null&&st.length))continue;let mt=1/0,gt=1/0,ft=-1/0,_t=-1/0;for(const I of st)I.x<mt&&(mt=I.x),I.y<gt&&(gt=I.y),I.x>ft&&(ft=I.x),I.y>_t&&(_t=I.y);const G=Math.max(ft-mt,1e-9),nt=Math.max(_t-gt,1e-9);if(Ke<=G*1.5&&Be<=nt*1.5&&G<=Ke*1.5&&nt<=Be*1.5){Z=!0;break}}if(Z)break}}if(!Z){const xe=ee?ue.length:ue.length-1;this._polyHasWidth(se,xe,S)?this._widePolyMesh(ue,z,ee,se,Ae,S,null):(z!=null&&z.some(be=>Math.abs(be)>=1e-6)?this._bulgePolySegs(ue,z,ee,Ae,s):this._polylineSegs(ue,ee,0,Ae,s),this._fillClosedPolyIfUncovered(ue,z,Ae))}}else if(oe==="POLYLINE_2D"&&o){const me=(o.get((R=(L=se.handle)==null?void 0:L.value)==null?void 0:R.toString(16))??[]).filter(ue=>(ue.type||"").toUpperCase().startsWith("VERTEX")&&ue.point);if(me.length>=2){const ue=me.map(Z=>{const[xe,be]=E(Z.point.x,Z.point.y);return{x:xe,y:be}}),z=me.map(Z=>Z.bulge||0),ee=(V.flags&1)===1;z.some(Z=>Math.abs(Z)>=1e-6)?this._bulgePolySegs(ue,z,ee,Ae,s):this._polylineSegs(ue,ee,0,Ae,s)}}else if(oe==="HATCH"){const me=V.paths??se.paths;if(me!=null&&me.length){const ue=V.solidFill??se.solidFill??!1,z=me.map(ee=>({...ee,points:(ee.points??[]).map(Z=>{const[xe,be]=E(Z.x,Z.y);return{x:xe,y:be}})}));if(ue)this._hatchFill(z,Ae);else for(const ee of z)(((w=ee.points)==null?void 0:w.length)??0)<2||((P=ee.bulges)!=null&&P.some(Z=>Math.abs(Z)>=1e-6)?this._bulgePolySegs(ee.points,ee.bulges,!0,Ae,s):this._polylineSegs(ee.points,!0,0,Ae,s))}}else if(oe==="SOLID"){const me=[V.corner1||V.pt1,V.corner2||V.pt2,V.corner3||V.pt3,V.corner4||V.pt4].filter(Boolean);if(me.length>=3){const ue=me.map(z=>{const[ee,Z]=E(z.x,z.y);return{x:ee,y:Z,z:z.z||0}});this._solidMesh(ue,Ae)}}else if(oe==="INSERT"&&o&&d<8){const me=((U=se.blockHeaderHandle)==null?void 0:U.value)??((D=V.blockHeaderHandle)==null?void 0:D.value);if(me!=null){const ue=me.toString(16),z=o.get(ue)??[];if(z.length){const ee=se.insertionPt??V.insertionPt??V.insertionPoint??{x:0,y:0},Z=V.scaleX??((K=V.scale)==null?void 0:K.x)??((B=se.scale)==null?void 0:B.x)??1,xe=V.scaleY??((ie=V.scale)==null?void 0:ie.y)??((F=se.scale)==null?void 0:F.y)??1,be=V.rotation??se.rotation??0;this._insertEntities(z,{insertionPoint:ee,xScale:Z,yScale:xe,rotation:be,basePoint:l==null?void 0:l.get(ue)},Ae,s,r,{entsByOwner:o,blockBase:l,parentXf:E,scale:S,rot:A,depth:d+1})}}}else if((oe==="TEXT"||oe==="MTEXT"||oe==="ATTRIB"||oe==="ATTDEF")&&r){if((oe==="ATTRIB"||oe==="ATTDEF")&&(V.flags??0)&1)continue;const me=se.text??V.text??V.textValue??V.defaultValue??"",ue=Js(me);let z,ee,Z=(V.rotationAngle??0)+A;if(oe==="MTEXT"){const Be=se.attachment??V.attachment??se.attachmentPoint??V.attachmentPoint??5;z=[1,4,7].includes(Be)?0:[3,6,9].includes(Be)?2:1,ee=[1,2,3].includes(Be)?3:[7,8,9].includes(Be)?1:2;const Pe=se.xAxisDir??V.xAxisDir;Pe&&(Z=Math.atan2(Pe.y,Pe.x)+A)}else z=V.horizAlignment??se.horizAlignment??0,ee=V.vertAlignment??se.vertAlignment??0;const xe=oe!=="MTEXT"&&(z!==0||ee!==0),be=se.alignmentPt??V.alignmentPt,Se=se.insertionPt??V.insertionPt??V.insertionPoint,Oe=xe?be??Se??{x:0,y:0}:Se??{x:0,y:0},[Ge,Ye]=E(Oe.x,Oe.y),Ke=(V.textHeight??V.height??se.textHeight??2.5)*S;if(ue){const Be={text:ue,pos:{x:Ge,y:Ye},height:Ke,rotation:Z,color:Ae,alignH:z,alignV:ee};oe==="MTEXT"&&(Be.linespacingFactor=se.linespacingFactor??V.linespacingFactor??1,Be.rectWidth=(se.rectWidth??V.rectWidth??0)*S,Be.rectHeight=(se.rectHeight??V.rectHeight??0)*S,Be.bgFillFlags=se.bgFillFlags??V.bgFillFlags??0,Be.bgScale=se.bgScale??V.bgScale??1.5,Be.bgColorIndex=se.bgColorIndex??V.bgColorIndex,Be.bgColorRgb=se.bgColorRgb??V.bgColorRgb),r.push(Be)}}}catch{}}this._curLwPx=y}_renderDimFallback(e,t,i,s,r,a,o){const l=e.pt10??t.pt10,c=e.pt13??t.pt13,u=e.pt14??t.pt14,h=e.pt15??t.pt15,d=e.textMidPt??t.textMidPt,f=e.actualMeasurement??t.actualMeasurement??0,p=e.textRot??t.textRot??0,_=e.dimRot??t.dimRot??0,m=e.userText??t.userText??"",g=S=>Math.abs(S)<1?S.toFixed(3):S.toFixed(2),v=(S,A)=>{!S||!A||(r(S.x,S.y,A.x,A.y,0,s),o(S.x,S.y),o(A.x,A.y))},b=(S,A,y,T,L)=>{this._arcSegs({x:S,y:A},y,T,L,0,s,r)},x=(S,A,y)=>this._arrowMesh(S,A,y,s),E=(S,A,y,T)=>{A&&S&&a.push({text:A,pos:S,height:y,rotation:T??0,color:s,alignH:1,alignV:2})};switch(i){case"DIMENSION":case"DIMENSION_LINEAR":case"DIMENSION_ALIGNED":{if(!c||!u||!l)return;let S,A,y,T;if(i==="DIMENSION_ALIGNED"){const R=u.x-c.x,w=u.y-c.y,P=Math.hypot(R,w);if(P<1e-9)return;const U=R/P,D=w/P,K=f/2;S=l.x-U*K,A=l.y-D*K,y=l.x+U*K,T=l.y+D*K}else{const R=Math.abs(Math.sin(_))>.5,w=f/2;S=l.x-(R?0:w),A=l.y-(R?w:0),y=l.x+(R?0:w),T=l.y+(R?w:0)}const L=Math.max(f*.04,1);v({x:S,y:A},{x:y,y:T}),v(c,{x:S,y:A}),v(u,{x:y,y:T}),x({x:S,y:A,z:0},Math.atan2(A-T,S-y),L),x({x:y,y:T,z:0},Math.atan2(T-A,y-S),L),E(d??{x:(S+y)/2,y:(A+T)/2},m||g(f),Math.max(L*1.5,1),p);break}case"DIMENSION_RADIUS":{if(!l||!h)return;const S=Math.max(f*.05,.5);v(l,h),x({x:h.x,y:h.y,z:0},Math.atan2(h.y-l.y,h.x-l.x),S),E(d??{x:(l.x+h.x)/2,y:(l.y+h.y)/2},m||`R${g(f)}`,Math.max(S*2,1));break}case"DIMENSION_DIAMETER":{if(!l||!h)return;const S={x:2*l.x-h.x,y:2*l.y-h.y},A=Math.max(f/2*.05,.5);v(h,S),x({x:h.x,y:h.y,z:0},Math.atan2(h.y-l.y,h.x-l.x),A),x({x:S.x,y:S.y,z:0},Math.atan2(S.y-l.y,S.x-l.x),A),E(d??l,m||${g(f)}`,Math.max(A*2,1));break}case"DIMENSION_ANG_3PT":case"DIMENSION_ANG_2LN":{if(!l||!c||!u)return;const S=l.x,A=l.y,y=Math.hypot(c.x-S,c.y-A);if(y<1e-9)return;let T=Math.atan2(c.y-A,c.x-S),L=Math.atan2(u.y-A,u.x-S),R=L-T;for(;R<0;)R+=Math.PI*2;R>Math.PI&&([T,L]=[L,T],R=Math.PI*2-R),b(S,A,y,T,T+R);const w=Math.max(y*.05,.5);x({x:S+Math.cos(T)*y,y:A+Math.sin(T)*y,z:0},T-Math.PI/2,w),x({x:S+Math.cos(T+R)*y,y:A+Math.sin(T+R)*y,z:0},T+R+Math.PI/2,w);const P=T+R/2;E(d??{x:S+Math.cos(P)*y*1.2,y:A+Math.sin(P)*y*1.2},m||`${(f*180/Math.PI).toFixed(1)}°`,Math.max(y*.1,1));break}case"DIMENSION_ORDINATE":{if(!l||!c)return;v(l,c),E(d??c,m||((f==null?void 0:f.toFixed(2))??""),2.5);break}}}_onClick(e){var p;if(this._downXY){const _=e.clientX-this._downXY[0],m=e.clientY-this._downXY[1];if(Math.hypot(_,m)>5)return}const t=this._camera,i=this._renderer.domElement.getBoundingClientRect(),s=this._screenToWcs(e.clientX,e.clientY);if(!s)return;const r=s.x,a=s.y;if(this._measureActive){this._doMeasure2D(r,a);return}const o=OE*(t.right-t.left)/(i.width*(t.zoom||1));let l=-1,c=o;const u=this._pickSegs,h=this._pickSegMeta,d=this._hiddenLayers.size?this._metaHidden:null;for(let _=0,m=0;_<u.length;_+=4,m++){if(d&&d[h[m]])continue;const g=this._segDist(r,a,u[_],u[_+1],u[_+2],u[_+3]);g<c&&(c=g,l=h[m])}if(l<0){let _=1/0;for(const m of this._pickFills)if(!(d&&d[m.metaIdx])&&this._fillHit(m.loops,r,a)){const g=this._loopArea(m.loops[0]||[]);g<_&&(_=g,l=m.metaIdx)}}const f=l>=0?this._entityMeta[l]:null;this._highlight(f),(p=this._onSelectCb)==null||p.call(this,f?f.entity:null)}_segDist(e,t,i,s,r,a){const o=r-i,l=a-s,c=o*o+l*l;if(!c)return Math.hypot(e-i,t-s);const u=Math.max(0,Math.min(1,((e-i)*o+(t-s)*l)/c));return Math.hypot(e-(i+u*o),t-(s+u*l))}startMeasure(e){this.stopMeasure(),this._measureCb=e,this._measureActive=!0}stopMeasure(){var e,t;this._measureActive=!1,this._measureCb=null,this._measurePtA=null;for(const i of this._measureMarkers)this._group.remove(i),(e=i.geometry)==null||e.dispose(),(t=i.material)==null||t.dispose();this._measureMarkers=[]}_doMeasure2D(e,t){var i,s;if(this._measurePtA){const r=this._measurePtA,a=Math.hypot(e-r.x,t-r.y),o=this._mkMeasureMarker(e,t),l=this._mkMeasureLine(r.x,r.y,e,t);this._measureMarkers.push(o,l),this._group.add(o,l),(s=this._measureCb)==null||s.call(this,{phase:"done",ax:r.x,ay:r.y,az:0,bx:e,by:t,bz:0,d:a}),this._measurePtA=null}else{this._measurePtA={x:e,y:t};const r=this._mkMeasureMarker(e,t);this._measureMarkers.push(r),this._group.add(r),(i=this._measureCb)==null||i.call(this,{phase:"a",ax:e,ay:t,az:0,bx:e,by:t,bz:0,d:0})}}_mkMeasureMarker(e,t){const i=this._camera,s=this._renderer.domElement.getBoundingClientRect(),r=(i.right-i.left)/(s.width*(i.zoom||1))*8,a=[new k(e-r,t,0),new k(e+r,t,0),new k(e,t-r,0),new k(e,t+r,0)],o=new wt().setFromPoints(a);o.setIndex([0,1,2,3]);const l=new js({color:15085616,depthTest:!1}),c=new ka(o,l);return c.renderOrder=100,c}_mkMeasureLine(e,t,i,s){const r=new wt().setFromPoints([new k(e,t,0),new k(i,s,0)]),a=new js({color:15085616,depthTest:!1}),o=new Qf(r,a);return o.renderOrder=100,o}_highlight(e){this._selMeta&&this._paintMeta(this._selMeta,null),this._selMeta=e||null,e&&this._paintMeta(e,this._selColor)}_paintMeta(e,t){const i=this._hairRt;if(i&&e.colEnd>e.colStart&&this._paintSpan(i,e.colStart,e.colEnd,t),!!e.spans)for(const s of e.spans){const r=s.bk;r.merged?i&&this._paintSpan(i,s.start+r.mergeOffset,s.end+r.mergeOffset,t):r.rt&&this._paintSpan(r.rt,s.start,s.end,t)}}_paintSpan(e,t,i,s){var l;if(e.attr){const c=e.attr.array,u=e.orig;for(let h=t;h<i&&h<c.length;h+=3)s?(c[h]=s.r,c[h+1]=s.g,c[h+2]=s.b):(c[h]=u[h],c[h+1]=u[h+1],c[h+2]=u[h+2]);e.attr.needsUpdate=!0;return}const r=(l=e.colBuf)==null?void 0:l.array,a=e.colSrc,o=e.slotOf;if(!(!r||!a)){for(let c=t;c<i&&c<a.length;c+=3){const u=o?o[c/6|0]:c/6|0;if(u<0)continue;const h=u*6+c%6;s?(r[h]=s.r,r[h+1]=s.g,r[h+2]=s.b):(r[h]=a[c],r[h+1]=a[c+1],r[h+2]=a[c+2])}e.colBuf.needsUpdate=!0}}setAccent(e){if(this._selColor={r:parseInt(e.slice(1,3),16)/255,g:parseInt(e.slice(3,5),16)/255,b:parseInt(e.slice(5,7),16)/255},this._selMeta){const t=this._selMeta;this._selMeta=null,this._highlight(t)}}getSelectedEntity(){return this._selMeta?this._selMeta.entity:null}zoomToSelection(){if(!this._selMeta)return;const e=this._entityMeta.indexOf(this._selMeta);if(e<0)return;const t=new mn,i=this._pickSegs,s=this._pickSegMeta;if(i&&s)for(let r=0,a=0;r<i.length;r+=4,a++)s[a]===e&&(t.expandByPoint(new k(i[r],i[r+1],0)),t.expandByPoint(new k(i[r+2],i[r+3],0)));if(this._pickFills){for(const r of this._pickFills)if(r.metaIdx===e)for(const a of r.loops||[])for(const o of a)t.expandByPoint(new k(o.x,o.y,0))}if(t.isEmpty()&&this._selMeta.entity){const r=this._selMeta.entity,a=r.data||r,o=a.start||a.center||a.pos||a.insertionPoint||a.insertionPt;o&&(t.expandByPoint(new k(o.x-10,o.y-10,0)),t.expandByPoint(new k(o.x+10,o.y+10,0)))}t.isEmpty()||this._fit(t)}_distToBounds(e,t,i){if(i.type==="point")return Math.hypot(e-i.cx,t-i.cy);if(i.type==="circle")return Math.abs(Math.hypot(e-i.cx,t-i.cy)-i.r);if(i.type==="line"){const s=i.x2-i.x1,r=i.y2-i.y1,a=s*s+r*r;if(!a)return Math.hypot(e-i.x1,t-i.y1);const o=Math.max(0,Math.min(1,((e-i.x1)*s+(t-i.y1)*r)/a));return Math.hypot(e-(i.x1+o*s),t-(i.y1+o*r))}return 1/0}_trimmedContentBox(e,t){if(!t||t.isEmpty())return null;const i=e?e.length>>1:0;if(i<32)return t.clone();const s=new Float64Array(i),r=new Float64Array(i);let a=0;for(let v=0;v+1<e.length;v+=2){const b=e[v],x=e[v+1];!Number.isFinite(b)||!Number.isFinite(x)||(s[a]=b,r[a]=x,a++)}if(a<32)return t.clone();const o=s.subarray(0,a),l=r.subarray(0,a);o.sort(),l.sort();const c=Math.max(0,Math.floor(a*.005)),u=Math.min(a-1,Math.floor(a*.995));let h=o[c],d=o[u],f=l[c],p=l[u];if(!(d>h)||!(p>f))return t.clone();const _=Math.max((d-h)*.02,1),m=Math.max((p-f)*.02,1),g=new mn(new k(h-_,f-m,0),new k(d+_,p+m,0));return g.min.max(t.min),g.max.min(t.max),g}_fit(e){if(!e||e.isEmpty())return;const t=e.getCenter(new k),i=e.getSize(new k),s=this._container.clientWidth||800,r=this._container.clientHeight||600,a=s/Math.max(r,1),o=1.12,l=Math.max(i.x,1e-9),c=Math.max(i.y,1e-9),u=l/c;let h,d;u>a*8?(d=c*o,h=d*a):u<a/8?(h=l*o,d=h/a):(h=l*o,d=c*o,h/d>a?d=h/a:h=d*a),this._camera.zoom=1,this._camera.left=-h/2,this._camera.right=h/2,this._camera.top=d/2,this._camera.bottom=-d/2;const f=Math.max(h,d,1e3);this._camera.near=-f,this._camera.far=f,this._camera.position.set(t.x,t.y,100);const p=-(this._viewTwist||0);this._camera.up.set(-Math.sin(p),Math.cos(p),0),this._controls.target.set(t.x,t.y,0),this._camera.lookAt(this._controls.target),this._camera.updateProjectionMatrix(),this._camera.updateMatrixWorld(!0),this._controls.update()}_clear(){var e,t,i;for(let s=this._group.children.length-1;s>=0;s--){const r=this._group.children[s];(e=r.geometry)==null||e.dispose(),r.material&&((t=r.material.map)==null||t.dispose(),r.material.dispose()),this._group.remove(r)}(i=this._texCache)==null||i.clear(),this._textGen++,this._contentBox=null,this._fullContentBox=null,this._layerObjs.clear(),this._layerBoxes.clear(),this._layerSamples.clear(),this._indexedBufs=[],this._fatBufs=[],this._layerNames=null,this._metaHidden=null,this._curLayer=null,this._curLayerId=-1,this._layerInfoCache=null}_onResize(){const e=this._container.clientWidth,t=this._container.clientHeight;if(!e||!t)return;this._renderer.setSize(e,t);const i=(this._camera.right-this._camera.left)/2,s=i/(e/t);this._camera.left=-i,this._camera.right=i,this._camera.top=s,this._camera.bottom=-s,this._camera.updateProjectionMatrix();for(const r of this._fatBufs)this._sizeLineMaterial(r.mesh.material)}_animate(){requestAnimationFrame(()=>this._animate()),this._controls.update(),this._renderer.render(this._scene,this._camera)}}const VE="modulepreload",GE=function(n){return"/"+n},df={},WE=function(e,t,i){let s=Promise.resolve();if(t&&t.length>0){document.getElementsByTagName("link");const a=document.querySelector("meta[property=csp-nonce]"),o=(a==null?void 0:a.nonce)||(a==null?void 0:a.getAttribute("nonce"));s=Promise.allSettled(t.map(l=>{if(l=GE(l),l in df)return;df[l]=!0;const c=l.endsWith(".css"),u=c?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${l}"]${u}`))return;const h=document.createElement("link");if(h.rel=c?"stylesheet":VE,c||(h.as="script"),h.crossOrigin="",h.href=l,o&&h.setAttribute("nonce",o),document.head.appendChild(h),c)return new Promise((d,f)=>{h.addEventListener("load",d),h.addEventListener("error",()=>f(new Error(`Unable to preload CSS for ${l}`)))})}))}function r(a){const o=new Event("vite:preloadError",{cancelable:!0});if(o.payload=a,window.dispatchEvent(o),!o.defaultPrevented)throw a}return s.then(a=>{for(const o of a||[])o.status==="rejected"&&r(o.reason);return e().catch(r)})},ff=/[\uAC00-\uD7A3]/,pf=/[\u1100-\u11FF\u3130-\u318F]/,XE=["cp949","windows-949","euc-kr"];let Pr;function YE(){if(Pr!==void 0)return Pr;for(const n of XE)try{return Pr=new TextDecoder(n),Pr}catch{}return Pr=null,null}function mf(n){if(!n||ff.test(n)||pf.test(n))return n;let e=!1;const t=new Uint8Array(n.length);for(let r=0;r<n.length;r++){const a=n.charCodeAt(r);if(a>255)return n;a>127&&(e=!0),t[r]=a}if(!e)return n;const i=YE();if(!i)return n;let s;try{s=i.decode(t)}catch{return n}return(ff.test(s)||pf.test(s))&&!s.includes("")?s:n}function KE(n){if(n==null||typeof n!="object")return n;const e=new WeakSet,t=i=>{if(i==null||typeof i!="object"||e.has(i))return;if(e.add(i),Array.isArray(i)){for(let r=0;r<i.length;r++){const a=i[r];typeof a=="string"?i[r]=mf(a):t(a)}return}const s=i;for(const r of Object.keys(s)){if(r==="imageDataUrl")continue;const a=s[r];typeof a=="string"?s[r]=mf(a):t(a)}};return t(n),n}async function gf(n){const{initAcadrustParser:e,parseDwgAcadrust:t}=await WE(async()=>{const{initAcadrustParser:i,parseDwgAcadrust:s}=await import("./acadrustParser-BrZjSf1T.js");return{initAcadrustParser:i,parseDwgAcadrust:s}},[]);return await e(),KE(t(n))}class qE{constructor(e){this._pointer=0,this._eof=!1,this._data=e}next(){if(!this.hasNext())throw this._eof?new Error("Cannot call 'next' after EOF group has been read"):new Error("Unexpected end of input: EOF group not read before end of file. Ended on code "+this._data[this._pointer]);const e={code:parseInt(this._data[this._pointer])};return this._pointer++,e.value=_f(e.code,this._data[this._pointer].trim()),this._pointer++,e.code===0&&e.value==="EOF"&&(this._eof=!0),this.lastReadGroup=e,e}peek(){if(!this.hasNext())throw this._eof?new Error("Cannot call 'next' after EOF group has been read"):new Error("Unexpected end of input: EOF group not read before end of file. Ended on code "+this._data[this._pointer]);const e={code:parseInt(this._data[this._pointer])};return e.value=_f(e.code,this._data[this._pointer+1].trim()),e}rewind(e=1){this._pointer=this._pointer-e*2}hasNext(){return!(this._eof||this._pointer>this._data.length-2)}isEOF(){return this._eof}}function _f(n,e){return n<=9?e:n>=10&&n<=59?parseFloat(e):n>=60&&n<=99?parseInt(e):n>=100&&n<=109?e:n>=110&&n<=149?parseFloat(e):n>=160&&n<=179?parseInt(e):n>=210&&n<=239?parseFloat(e):n>=270&&n<=289?parseInt(e):n>=290&&n<=299?$E(e):n>=300&&n<=369?e:n>=370&&n<=389?parseInt(e):n>=390&&n<=399?e:n>=400&&n<=409?parseInt(e):n>=410&&n<=419?e:n>=420&&n<=429?parseInt(e):n>=430&&n<=439?e:n>=440&&n<=459?parseInt(e):n>=460&&n<=469?parseFloat(e):n>=470&&n<=481||n===999||n>=1e3&&n<=1009?e:n>=1010&&n<=1059?parseFloat(e):n>=1060&&n<=1071?parseInt(e):(console.log("WARNING: Group code does not have a defined type: %j",{code:n,value:e}),e)}function $E(n){if(n==="0")return!1;if(n==="1")return!0;throw TypeError("String '"+n+"' cannot be cast to Boolean type")}const U0=[0,16711680,16776960,65280,65535,255,16711935,16777215,8421504,12632256,16711680,16744319,13369344,13395558,10027008,10046540,8323072,8339263,4980736,4990502,16727808,16752511,13382400,13401958,10036736,10051404,8331008,8343359,4985600,4992806,16744192,16760703,13395456,13408614,10046464,10056268,8339200,8347455,4990464,4995366,16760576,16768895,13408512,13415014,10056192,10061132,8347392,8351551,4995328,4997670,16776960,16777087,13421568,13421670,10000384,10000460,8355584,8355647,5000192,5000230,12582656,14679935,10079232,11717734,7510016,8755276,6258432,7307071,3755008,4344870,8388352,12582783,6736896,10079334,5019648,7510092,4161280,6258495,2509824,3755046,4194048,10485631,3394560,8375398,2529280,6264908,2064128,5209919,1264640,3099686,65280,8388479,52224,6736998,38912,5019724,32512,4161343,19456,2509862,65343,8388511,52275,6737023,38950,5019743,32543,4161359,19475,2509871,65407,8388543,52326,6737049,38988,5019762,32575,4161375,19494,2509881,65471,8388575,52377,6737074,39026,5019781,32607,4161391,19513,2509890,65535,8388607,52428,6737100,39064,5019800,32639,4161407,19532,2509900,49151,8380415,39372,6730444,29336,5014936,24447,4157311,14668,2507340,32767,8372223,26316,6724044,19608,5010072,16255,4153215,9804,2505036,16383,8364031,13260,6717388,9880,5005208,8063,4149119,4940,2502476,255,8355839,204,6710988,152,5000344,127,4145023,76,2500172,4129023,10452991,3342540,8349388,2490520,6245528,2031743,5193599,1245260,3089996,8323327,12550143,6684876,10053324,4980888,7490712,4128895,6242175,2490444,3745356,12517631,14647295,10027212,11691724,7471256,8735896,6226047,7290751,3735628,4335180,16711935,16744447,13369548,13395660,9961624,9981080,8323199,8339327,4980812,4990540,16711871,16744415,13369497,13395634,9961586,9981061,8323167,8339311,4980793,4990530,16711807,16744383,13369446,13395609,9961548,9981042,8323135,8339295,4980774,4990521,16711743,16744351,13369395,13395583,9961510,9981023,8323103,8339279,4980755,4990511,3355443,5987163,8684676,11382189,14079702,16777215];function ZE(n){return U0[n]}function ot(n){const e={};n.rewind();let t=n.next(),i=t.code;if(e.x=t.value,i+=10,t=n.next(),t.code!=i)throw new Error("Expected code for point value to be "+i+" but got "+t.code+".");return e.y=t.value,i+=10,t=n.next(),t.code!=i?(n.rewind(),e):(e.z=t.value,e)}function jt(n,e,t){switch(e.code){case 0:n.type=e.value;break;case 5:n.handle=e.value;break;case 6:n.lineType=e.value;break;case 8:n.layer=e.value;break;case 48:n.lineTypeScale=e.value;break;case 60:n.visible=e.value===0;break;case 62:n.colorIndex=e.value,n.color=ZE(Math.abs(e.value));break;case 67:n.inPaperSpace=e.value!==0;break;case 100:break;case 101:for(;e.code!=0;)e=t.next();t.rewind();break;case 330:n.ownerHandle=e.value;break;case 347:n.materialObjectHandle=e.value;break;case 370:n.lineweight=e.value;break;case 420:n.color=e.value;break;case 1e3:n.extendedData=n.extendedData||{},n.extendedData.customStrings=n.extendedData.customStrings||[],n.extendedData.customStrings.push(e.value);break;case 1001:n.extendedData=n.extendedData||{},n.extendedData.applicationName=e.value;break;default:return!1}return!0}class JE{constructor(){this.ForEntityName="3DFACE"}parseEntity(e,t){const i={type:t.value,vertices:[]};for(t=e.next();!e.isEOF()&&t.code!==0;){switch(t.code){case 70:i.shape=(t.value&1)===1,i.hasContinuousLinetypePattern=(t.value&128)===128;break;case 10:i.vertices=jE(e,t),t=e.lastReadGroup;break;default:jt(i,t,e);break}t=e.next()}return i}}function jE(n,e){var t=[],i=!1,s=!1,r=4;for(let o=0;o<=r;o++){for(var a={};!n.isEOF()&&!(e.code===0||s);){switch(e.code){case 10:case 11:case 12:case 13:if(i){s=!0;continue}a.x=e.value,i=!0;break;case 20:case 21:case 22:case 23:a.y=e.value;break;case 30:case 31:case 32:case 33:a.z=e.value;break;default:return t}e=n.next()}t.push(a),i=!1,s=!1}return n.rewind(),t}class QE{constructor(){this.ForEntityName="ARC"}parseEntity(e,t){const i={type:t.value};for(t=e.next();!e.isEOF()&&t.code!==0;){switch(t.code){case 10:i.center=ot(e);break;case 40:i.radius=t.value;break;case 50:i.startAngle=Math.PI/180*t.value;break;case 51:i.endAngle=Math.PI/180*t.value,i.angleLength=i.endAngle-i.startAngle;break;case 210:i.extrusionDirectionX=t.value;break;case 220:i.extrusionDirectionY=t.value;break;case 230:i.extrusionDirectionZ=t.value;break;default:jt(i,t,e);break}t=e.next()}return i}}class eT{constructor(){this.ForEntityName="ATTDEF"}parseEntity(e,t){var i={type:t.value,scale:1,textStyle:"STANDARD"};for(t=e.next();!e.isEOF()&&t.code!==0;){switch(t.code){case 1:i.text=t.value;break;case 2:i.tag=t.value;break;case 3:i.prompt=t.value;break;case 7:i.textStyle=t.value;break;case 10:i.startPoint=ot(e);break;case 11:i.endPoint=ot(e);break;case 39:i.thickness=t.value;break;case 40:i.textHeight=t.value;break;case 41:i.scale=t.value;break;case 50:i.rotation=t.value;break;case 51:i.obliqueAngle=t.value;break;case 70:i.invisible=!!(t.value&1),i.constant=!!(t.value&2),i.verificationRequired=!!(t.value&4),i.preset=!!(t.value&8);break;case 71:i.backwards=!!(t.value&2),i.mirrored=!!(t.value&4);break;case 72:i.horizontalJustification=t.value;break;case 73:i.fieldLength=t.value;break;case 74:i.verticalJustification=t.value;break;case 100:break;case 210:i.extrusionDirectionX=t.value;break;case 220:i.extrusionDirectionY=t.value;break;case 230:i.extrusionDirectionZ=t.value;break;default:jt(i,t,e);break}t=e.next()}return i}}class tT{constructor(){this.ForEntityName="CIRCLE"}parseEntity(e,t){const i={type:t.value};for(t=e.next();!e.isEOF()&&t.code!==0;){switch(t.code){case 10:i.center=ot(e);break;case 40:i.radius=t.value;break;case 50:i.startAngle=Math.PI/180*t.value;break;case 51:const s=Math.PI/180*t.value;s<i.startAngle?i.angleLength=s+2*Math.PI-i.startAngle:i.angleLength=s-i.startAngle,i.endAngle=s;break;default:jt(i,t,e);break}t=e.next()}return i}}class nT{constructor(){this.ForEntityName="DIMENSION"}parseEntity(e,t){const i={type:t.value};for(t=e.next();!e.isEOF()&&t.code!==0;){switch(t.code){case 2:i.block=t.value;break;case 10:i.anchorPoint=ot(e);break;case 11:i.middleOfText=ot(e);break;case 12:i.insertionPoint=ot(e);break;case 13:i.linearOrAngularPoint1=ot(e);break;case 14:i.linearOrAngularPoint2=ot(e);break;case 15:i.diameterOrRadiusPoint=ot(e);break;case 16:i.arcPoint=ot(e);break;case 70:i.dimensionType=t.value;break;case 71:i.attachmentPoint=t.value;break;case 42:i.actualMeasurement=t.value;break;case 1:i.text=t.value;break;case 50:i.angle=t.value;break;default:jt(i,t,e);break}t=e.next()}return i}}class iT{constructor(){this.ForEntityName="ELLIPSE"}parseEntity(e,t){const i={type:t.value};for(t=e.next();!e.isEOF()&&t.code!==0;){switch(t.code){case 10:i.center=ot(e);break;case 11:i.majorAxisEndPoint=ot(e);break;case 40:i.axisRatio=t.value;break;case 41:i.startAngle=t.value;break;case 42:i.endAngle=t.value;break;case 2:i.name=t.value;break;default:jt(i,t,e);break}t=e.next()}return i}}class sT{constructor(){this.ForEntityName="INSERT"}parseEntity(e,t){const i={type:t.value};for(t=e.next();!e.isEOF()&&t.code!==0;){switch(t.code){case 2:i.name=t.value;break;case 41:i.xScale=t.value;break;case 42:i.yScale=t.value;break;case 43:i.zScale=t.value;break;case 10:i.position=ot(e);break;case 50:i.rotation=t.value;break;case 70:i.columnCount=t.value;break;case 71:i.rowCount=t.value;break;case 44:i.columnSpacing=t.value;break;case 45:i.rowSpacing=t.value;break;case 210:i.extrusionDirection=ot(e);break;default:jt(i,t,e);break}t=e.next()}return i}}class rT{constructor(){this.ForEntityName="LINE"}parseEntity(e,t){const i={type:t.value,vertices:[]};for(t=e.next();!e.isEOF()&&t.code!==0;){switch(t.code){case 10:i.vertices.unshift(ot(e));break;case 11:i.vertices.push(ot(e));break;case 210:i.extrusionDirection=ot(e);break;case 100:break;default:jt(i,t,e);break}t=e.next()}return i}}class aT{constructor(){this.ForEntityName="LWPOLYLINE"}parseEntity(e,t){const i={type:t.value,vertices:[]};let s=0;for(t=e.next();!e.isEOF()&&t.code!==0;){switch(t.code){case 38:i.elevation=t.value;break;case 39:i.depth=t.value;break;case 70:i.shape=(t.value&1)===1,i.hasContinuousLinetypePattern=(t.value&128)===128;break;case 90:s=t.value;break;case 10:i.vertices=oT(s,e);break;case 43:t.value!==0&&(i.width=t.value);break;case 210:i.extrusionDirectionX=t.value;break;case 220:i.extrusionDirectionY=t.value;break;case 230:i.extrusionDirectionZ=t.value;break;default:jt(i,t,e);break}t=e.next()}return i}}function oT(n,e){if(!n||n<=0)throw Error("n must be greater than 0 verticies");const t=[];let i=!1,s=!1,r=e.lastReadGroup;for(let a=0;a<n;a++){const o={};for(;!e.isEOF()&&!(r.code===0||s);){switch(r.code){case 10:if(i){s=!0;continue}o.x=r.value,i=!0;break;case 20:o.y=r.value;break;case 30:o.z=r.value;break;case 40:o.startWidth=r.value;break;case 41:o.endWidth=r.value;break;case 42:r.value!=0&&(o.bulge=r.value);break;default:return e.rewind(),i&&t.push(o),e.rewind(),t}r=e.next()}t.push(o),i=!1,s=!1}return e.rewind(),t}class lT{constructor(){this.ForEntityName="MTEXT"}parseEntity(e,t){const i={type:t.value};for(t=e.next();!e.isEOF()&&t.code!==0;){switch(t.code){case 3:i.text?i.text+=t.value:i.text=t.value;break;case 1:i.text?i.text+=t.value:i.text=t.value;break;case 10:i.position=ot(e);break;case 11:i.directionVector=ot(e);break;case 40:i.height=t.value;break;case 41:i.width=t.value;break;case 50:i.rotation=t.value;break;case 71:i.attachmentPoint=t.value;break;case 72:i.drawingDirection=t.value;break;default:jt(i,t,e);break}t=e.next()}return i}}class cT{constructor(){this.ForEntityName="POINT"}parseEntity(e,t){const s={type:t.value};for(t=e.next();!e.isEOF()&&t.code!==0;){switch(t.code){case 10:s.position=ot(e);break;case 39:s.thickness=t.value;break;case 210:s.extrusionDirection=ot(e);break;case 100:break;default:jt(s,t,e);break}t=e.next()}return s}}class uT{constructor(){this.ForEntityName="VERTEX"}parseEntity(e,t){var i={type:t.value};for(t=e.next();!e.isEOF()&&t.code!==0;){switch(t.code){case 10:i.x=t.value;break;case 20:i.y=t.value;break;case 30:i.z=t.value;break;case 40:break;case 41:break;case 42:t.value!=0&&(i.bulge=t.value);break;case 70:i.curveFittingVertex=(t.value&1)!==0,i.curveFitTangent=(t.value&2)!==0,i.splineVertex=(t.value&8)!==0,i.splineControlPoint=(t.value&16)!==0,i.threeDPolylineVertex=(t.value&32)!==0,i.threeDPolylineMesh=(t.value&64)!==0,i.polyfaceMeshVertex=(t.value&128)!==0;break;case 50:break;case 71:i.faceA=t.value;break;case 72:i.faceB=t.value;break;case 73:i.faceC=t.value;break;case 74:i.faceD=t.value;break;default:jt(i,t,e);break}t=e.next()}return i}}class hT{constructor(){this.ForEntityName="POLYLINE"}parseEntity(e,t){var i={type:t.value,vertices:[]};for(t=e.next();!e.isEOF()&&t.code!==0;){switch(t.code){case 10:break;case 20:break;case 30:break;case 39:i.thickness=t.value;break;case 40:break;case 41:break;case 70:i.shape=(t.value&1)!==0,i.includesCurveFitVertices=(t.value&2)!==0,i.includesSplineFitVertices=(t.value&4)!==0,i.is3dPolyline=(t.value&8)!==0,i.is3dPolygonMesh=(t.value&16)!==0,i.is3dPolygonMeshClosed=(t.value&32)!==0,i.isPolyfaceMesh=(t.value&64)!==0,i.hasContinuousLinetypePattern=(t.value&128)!==0;break;case 71:break;case 72:break;case 73:break;case 74:break;case 75:break;case 210:i.extrusionDirection=ot(e);break;default:jt(i,t,e);break}t=e.next()}return i.vertices=dT(e,t),i}}function dT(n,e){const t=new uT,i=[];for(;!n.isEOF();)if(e.code===0){if(e.value==="VERTEX")i.push(t.parseEntity(n,e)),e=n.lastReadGroup;else if(e.value==="SEQEND"){fT(n,e);break}}return i}function fT(n,e){const t={type:e.value};for(e=n.next();!n.isEOF()&&e.code!=0;)jt(t,e,n),e=n.next();return t}class pT{constructor(){this.ForEntityName="SOLID"}parseEntity(e,t){const i={type:t.value,points:[]};for(t=e.next();!e.isEOF()&&t.code!==0;){switch(t.code){case 10:i.points[0]=ot(e);break;case 11:i.points[1]=ot(e);break;case 12:i.points[2]=ot(e);break;case 13:i.points[3]=ot(e);break;case 210:i.extrusionDirection=ot(e);break;default:jt(i,t,e);break}t=e.next()}return i}}class mT{constructor(){this.ForEntityName="SPLINE"}parseEntity(e,t){const i={type:t.value};for(t=e.next();!e.isEOF()&&t.code!==0;){switch(t.code){case 10:i.controlPoints||(i.controlPoints=[]),i.controlPoints.push(ot(e));break;case 11:i.fitPoints||(i.fitPoints=[]),i.fitPoints.push(ot(e));break;case 12:i.startTangent=ot(e);break;case 13:i.endTangent=ot(e);break;case 40:i.knotValues||(i.knotValues=[]),i.knotValues.push(t.value);break;case 70:t.value&1&&(i.closed=!0),t.value&2&&(i.periodic=!0),t.value&4&&(i.rational=!0),t.value&8&&(i.planar=!0),t.value&16&&(i.planar=!0,i.linear=!0);break;case 71:i.degreeOfSplineCurve=t.value;break;case 72:i.numberOfKnots=t.value;break;case 73:i.numberOfControlPoints=t.value;break;case 74:i.numberOfFitPoints=t.value;break;case 210:i.normalVector=ot(e);break;default:jt(i,t,e);break}t=e.next()}return i}}class gT{constructor(){this.ForEntityName="TEXT"}parseEntity(e,t){const i={type:t.value};for(t=e.next();!e.isEOF()&&t.code!==0;){switch(t.code){case 10:i.startPoint=ot(e);break;case 11:i.endPoint=ot(e);break;case 40:i.textHeight=t.value;break;case 41:i.xScale=t.value;break;case 50:i.rotation=t.value;break;case 1:i.text=t.value;break;case 72:i.halign=t.value;break;case 73:i.valign=t.value;break;default:jt(i,t,e);break}t=e.next()}return i}}var _T=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function xT(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var N0={exports:{}};(function(n){(function(e,t){n.exports?n.exports=t():e.log=t()})(_T,function(){var e=function(){},t="undefined",i=typeof window!==t&&typeof window.navigator!==t&&/Trident\/|MSIE /.test(window.navigator.userAgent),s=["trace","debug","info","warn","error"],r={},a=null;function o(_,m){var g=_[m];if(typeof g.bind=="function")return g.bind(_);try{return Function.prototype.bind.call(g,_)}catch{return function(){return Function.prototype.apply.apply(g,[_,arguments])}}}function l(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function c(_){return _==="debug"&&(_="log"),typeof console===t?!1:_==="trace"&&i?l:console[_]!==void 0?o(console,_):console.log!==void 0?o(console,"log"):e}function u(){for(var _=this.getLevel(),m=0;m<s.length;m++){var g=s[m];this[g]=m<_?e:this.methodFactory(g,_,this.name)}if(this.log=this.debug,typeof console===t&&_<this.levels.SILENT)return"No console available for logging"}function h(_){return function(){typeof console!==t&&(u.call(this),this[_].apply(this,arguments))}}function d(_,m,g){return c(_)||h.apply(this,arguments)}function f(_,m){var g=this,v,b,x,E="loglevel";typeof _=="string"?E+=":"+_:typeof _=="symbol"&&(E=void 0);function S(R){var w=(s[R]||"silent").toUpperCase();if(!(typeof window===t||!E)){try{window.localStorage[E]=w;return}catch{}try{window.document.cookie=encodeURIComponent(E)+"="+w+";"}catch{}}}function A(){var R;if(!(typeof window===t||!E)){try{R=window.localStorage[E]}catch{}if(typeof R===t)try{var w=window.document.cookie,P=encodeURIComponent(E),U=w.indexOf(P+"=");U!==-1&&(R=/^([^;]+)/.exec(w.slice(U+P.length+1))[1])}catch{}return g.levels[R]===void 0&&(R=void 0),R}}function y(){if(!(typeof window===t||!E)){try{window.localStorage.removeItem(E)}catch{}try{window.document.cookie=encodeURIComponent(E)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}function T(R){var w=R;if(typeof w=="string"&&g.levels[w.toUpperCase()]!==void 0&&(w=g.levels[w.toUpperCase()]),typeof w=="number"&&w>=0&&w<=g.levels.SILENT)return w;throw new TypeError("log.setLevel() called with invalid level: "+R)}g.name=_,g.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},g.methodFactory=m||d,g.getLevel=function(){return x??b??v},g.setLevel=function(R,w){return x=T(R),w!==!1&&S(x),u.call(g)},g.setDefaultLevel=function(R){b=T(R),A()||g.setLevel(R,!1)},g.resetLevel=function(){x=null,y(),u.call(g)},g.enableAll=function(R){g.setLevel(g.levels.TRACE,R)},g.disableAll=function(R){g.setLevel(g.levels.SILENT,R)},g.rebuild=function(){if(a!==g&&(v=T(a.getLevel())),u.call(g),a===g)for(var R in r)r[R].rebuild()},v=T(a?a.getLevel():"WARN");var L=A();L!=null&&(x=T(L)),u.call(g)}a=new f,a.getLogger=function(m){if(typeof m!="symbol"&&typeof m!="string"||m==="")throw new TypeError("You must supply a name when creating a logger.");var g=r[m];return g||(g=r[m]=new f(m,a.methodFactory)),g};var p=typeof window!==t?window.log:void 0;return a.noConflict=function(){return typeof window!==t&&window.log===a&&(window.log=p),a},a.getLoggers=function(){return r},a.default=a,a})})(N0);var yT=N0.exports;const rt=xT(yT);rt.setLevel("error");function vT(n){n.registerEntityHandler(JE),n.registerEntityHandler(QE),n.registerEntityHandler(eT),n.registerEntityHandler(tT),n.registerEntityHandler(nT),n.registerEntityHandler(iT),n.registerEntityHandler(sT),n.registerEntityHandler(rT),n.registerEntityHandler(aT),n.registerEntityHandler(lT),n.registerEntityHandler(cT),n.registerEntityHandler(hT),n.registerEntityHandler(pT),n.registerEntityHandler(mT),n.registerEntityHandler(gT)}class ST{constructor(){this._entityHandlers={},vT(this)}parse(e){return typeof e=="string"?this._parse(e):(console.error("Cannot read dxf source of type `"+typeof e),null)}registerEntityHandler(e){const t=new e;this._entityHandlers[t.ForEntityName]=t}parseSync(e){return this.parse(e)}parseStream(e){let t="";const i=this;return new Promise((s,r)=>{e.on("data",a=>{t+=a}),e.on("end",()=>{try{s(i._parse(t))}catch(a){r(a)}}),e.on("error",a=>{r(a)})})}_parse(e){const t={};let i=0;const s=e.split(/\r\n|\r|\n/g),r=new qE(s);if(!r.hasNext())throw Error("Empty file");const a=this;let o;function l(){for(o=r.next();!r.isEOF();)if(o.code===0&&o.value==="SECTION"){if(o=r.next(),o.code!==2){console.error("Unexpected code %s after 0:SECTION",k0(o)),o=r.next();continue}o.value==="HEADER"?(rt.debug("> HEADER"),t.header=c(),rt.debug("<")):o.value==="BLOCKS"?(rt.debug("> BLOCKS"),t.blocks=u(),rt.debug("<")):o.value==="ENTITIES"?(rt.debug("> ENTITIES"),t.entities=b(!1),rt.debug("<")):o.value==="TABLES"?(rt.debug("> TABLES"),t.tables=d(),rt.debug("<")):o.value==="EOF"?rt.debug("EOF"):rt.warn("Skipping section '%s'",o.value)}else o=r.next()}function c(){let S=null,A=null;const y={};for(o=r.next();;){if(ei(o,0,"ENDSEC")){S&&(y[S]=A);break}else o.code===9?(S&&(y[S]=A),S=o.value):o.code===10?A={x:o.value}:o.code===20?A.y=o.value:o.code===30?A.z=o.value:A=o.value;o=r.next()}return o=r.next(),y}function u(){const S={};for(o=r.next();o.value!=="EOF"&&!ei(o,0,"ENDSEC");)if(ei(o,0,"BLOCK")){rt.debug("block {");const A=h();rt.debug("}"),E(A),A.name?S[A.name]=A:rt.error('block with handle "'+A.handle+'" is missing a name.')}else os(o),o=r.next();return S}function h(){const S={};for(o=r.next();o.value!=="EOF";){switch(o.code){case 1:S.xrefPath=o.value,o=r.next();break;case 2:S.name=o.value,o=r.next();break;case 3:S.name2=o.value,o=r.next();break;case 5:S.handle=o.value,o=r.next();break;case 8:S.layer=o.value,o=r.next();break;case 10:S.position=x(o),o=r.next();break;case 67:S.paperSpace=!!(o.value&&o.value==1),o=r.next();break;case 70:o.value!=0&&(S.type=o.value),o=r.next();break;case 100:o=r.next();break;case 330:S.ownerHandle=o.value,o=r.next();break;case 0:if(o.value=="ENDBLK")break;S.entities=b(!0);break;default:os(o),o=r.next()}if(ei(o,0,"ENDBLK")){o=r.next();break}}return S}function d(){const S={};for(o=r.next();o.value!=="EOF"&&!ei(o,0,"ENDSEC");)ei(o,0,"TABLE")?(o=r.next(),v[o.value]?(rt.debug(o.value+" Table {"),S[v[o.value].tableName]=p(o),rt.debug("}")):rt.debug("Unhandled Table "+o.value)):o=r.next();return o=r.next(),S}const f="ENDTAB";function p(S){const A=v[S.value],y={};let T=0;for(o=r.next();!ei(o,0,f);)switch(o.code){case 5:y.handle=o.value,o=r.next();break;case 330:y.ownerHandle=o.value,o=r.next();break;case 100:o.value==="AcDbSymbolTable"||os(o),o=r.next();break;case 70:T=o.value,o=r.next();break;case 0:o.value===A.dxfSymbolName?y[A.tableRecordsProperty]=A.parseTableRecords():(os(o),o=r.next());break;default:os(o),o=r.next()}const L=y[A.tableRecordsProperty];if(L){let R=(()=>{if(L.constructor===Array)return L.length;if(typeof L=="object")return Object.keys(L).length})();T!==R&&rt.warn("Parsed "+R+" "+A.dxfSymbolName+"'s but expected "+T)}return o=r.next(),y}function _(){const S=[];let A={};for(rt.debug("ViewPort {"),o=r.next();!ei(o,0,f);)switch(o.code){case 2:A.name=o.value,o=r.next();break;case 10:A.lowerLeftCorner=x(o),o=r.next();break;case 11:A.upperRightCorner=x(o),o=r.next();break;case 12:A.center=x(o),o=r.next();break;case 13:A.snapBasePoint=x(o),o=r.next();break;case 14:A.snapSpacing=x(o),o=r.next();break;case 15:A.gridSpacing=x(o),o=r.next();break;case 16:A.viewDirectionFromTarget=x(o),o=r.next();break;case 17:A.viewTarget=x(o),o=r.next();break;case 42:A.lensLength=o.value,o=r.next();break;case 43:A.frontClippingPlane=o.value,o=r.next();break;case 44:A.backClippingPlane=o.value,o=r.next();break;case 45:A.viewHeight=o.value,o=r.next();break;case 50:A.snapRotationAngle=o.value,o=r.next();break;case 51:A.viewTwistAngle=o.value,o=r.next();break;case 79:A.orthographicType=o.value,o=r.next();break;case 110:A.ucsOrigin=x(o),o=r.next();break;case 111:A.ucsXAxis=x(o),o=r.next();break;case 112:A.ucsYAxis=x(o),o=r.next();break;case 110:A.ucsOrigin=x(o),o=r.next();break;case 281:A.renderMode=o.value,o=r.next();break;case 281:A.defaultLightingType=o.value,o=r.next();break;case 292:A.defaultLightingOn=o.value,o=r.next();break;case 330:A.ownerHandle=o.value,o=r.next();break;case 63:case 421:case 431:A.ambientColor=o.value,o=r.next();break;case 0:o.value==="VPORT"&&(rt.debug("}"),S.push(A),rt.debug("ViewPort {"),A={},o=r.next());break;default:os(o),o=r.next();break}return rt.debug("}"),S.push(A),S}function m(){const S={};let A={},y=0,T;for(rt.debug("LType {"),o=r.next();!ei(o,0,"ENDTAB");)switch(o.code){case 2:A.name=o.value,T=o.value,o=r.next();break;case 3:A.description=o.value,o=r.next();break;case 73:y=o.value,y>0&&(A.pattern=[]),o=r.next();break;case 40:A.patternLength=o.value,o=r.next();break;case 49:A.pattern.push(o.value),o=r.next();break;case 0:rt.debug("}"),y>0&&y!==A.pattern.length&&rt.warn("lengths do not match on LTYPE pattern"),S[T]=A,A={},rt.debug("LType {"),o=r.next();break;default:o=r.next()}return rt.debug("}"),S[T]=A,S}function g(){const S={};let A={},y;for(rt.debug("Layer {"),o=r.next();!ei(o,0,"ENDTAB");)switch(o.code){case 2:A.name=o.value,y=o.value,o=r.next();break;case 62:A.visible=o.value>=0,A.colorIndex=Math.abs(o.value),A.color=bT(A.colorIndex),o=r.next();break;case 70:A.frozen=(o.value&1)!=0||(o.value&2)!=0,o=r.next();break;case 0:o.value==="LAYER"&&(rt.debug("}"),S[y]=A,rt.debug("Layer {"),A={},y=void 0,o=r.next());break;default:os(o),o=r.next();break}return rt.debug("}"),S[y]=A,S}const v={VPORT:{tableRecordsProperty:"viewPorts",tableName:"viewPort",dxfSymbolName:"VPORT",parseTableRecords:_},LTYPE:{tableRecordsProperty:"lineTypes",tableName:"lineType",dxfSymbolName:"LTYPE",parseTableRecords:m},LAYER:{tableRecordsProperty:"layers",tableName:"layer",dxfSymbolName:"LAYER",parseTableRecords:g}};function b(S){const A=[],y=S?"ENDBLK":"ENDSEC";for(S||(o=r.next());;)if(o.code===0){if(o.value===y)break;const T=a._entityHandlers[o.value];if(T!=null){rt.debug(o.value+" {");const L=T.parseEntity(r,o);o=r.lastReadGroup,rt.debug("}"),E(L),A.push(L)}else{rt.warn("Unhandled entity "+o.value),o=r.next();continue}}else o=r.next();return y=="ENDSEC"&&(o=r.next()),A}function x(S){const A={};let y=S.code;if(A.x=S.value,y+=10,S=r.next(),S.code!=y)throw new Error("Expected code for point value to be "+y+" but got "+S.code+".");return A.y=S.value,y+=10,S=r.next(),S.code!=y?(r.rewind(),A):(A.z=S.value,A)}function E(S){if(!S)throw new TypeError("entity cannot be undefined or null");S.handle||(S.handle=i++)}return l(),t}}function ei(n,e,t){return n.code===e&&n.value===t}function os(n){rt.debug("unhandled group "+k0(n))}function k0(n){return n.code+":"+n.value}function bT(n){return U0[n]}const so=Math.PI/180,MT=48;function AT(n,e,t,i,s,r,a){let o=s-i;if(r)for(;o<=0;)o+=Math.PI*2;else for(;o>=0;)o-=Math.PI*2;const l=Math.max(2,Math.ceil(Math.abs(o)/(Math.PI*2)*MT));for(let c=0;c<=l;c++){const u=i+o*c/l;a.push({x:n+t*Math.cos(u),y:e+t*Math.sin(u)})}}class ET{constructor(){this.ForEntityName="HATCH"}parseEntity(e,t){const i={type:t.value,paths:[],solidFill:!1};for(t=e.next();!e.isEOF()&&t.code!==0;){switch(t.code){case 70:i.solidFill=t.value!==0;break;case 2:i.patternName=t.value;break;case 8:i.layer=t.value;break;case 62:i.colorIndex=t.value;break;case 91:{const s=t.value;let r=e.next();for(let a=0;a<s&&!e.isEOF();a++)r=this._readPath(e,i,r);t=r;continue}}t=e.next()}return i}_readPath(e,t,i){for(;!e.isEOF()&&i.code!==92;)i=e.next();const r=((i.value|0)&2)!==0,a={points:[],bulges:[]};let o=e.next();if(r){let l=!1;for(;o.code===72||o.code===73;)o.code===72&&(l=o.value!==0),o=e.next();let c=0;o.code===93&&(c=o.value,o=e.next());for(let u=0;u<c&&!e.isEOF();u++){let h=0,d=0,f=0;o.code===10&&(h=o.value,o=e.next()),o.code===20&&(d=o.value,o=e.next()),l&&o.code===42&&(f=o.value,o=e.next()),a.points.push({x:h,y:d}),a.bulges.push(f)}}else{let l=0;o.code===93&&(l=o.value,o=e.next());for(let c=0;c<l&&!e.isEOF();c++){let u=0;o.code===72&&(u=o.value,o=e.next()),o=this._readEdge(e,a,u,o)}}if(o.code===97){const l=o.value|0;o=e.next();for(let c=0;c<l&&!e.isEOF()&&o.code===330;c++)o=e.next()}return a.points.length>=2&&t.paths.push(a),o}_readEdge(e,t,i,s){if(i===1){let r=0,a=0,o=0,l=0;s.code===10&&(r=s.value,s=e.next()),s.code===20&&(a=s.value,s=e.next()),s.code===11&&(o=s.value,s=e.next()),s.code===21&&(l=s.value,s=e.next()),t.points.push({x:r,y:a}),t.points.push({x:o,y:l})}else if(i===2){let r=0,a=0,o=0,l=0,c=0,u=1;s.code===10&&(r=s.value,s=e.next()),s.code===20&&(a=s.value,s=e.next()),s.code===40&&(o=s.value,s=e.next()),s.code===50&&(l=s.value*so,s=e.next()),s.code===51&&(c=s.value*so,s=e.next()),s.code===73&&(u=s.value,s=e.next()),AT(r,a,o,l,c,u!==0,t.points)}else if(i===3){let r=0,a=0,o=1,l=0,c=1,u=0,h=Math.PI*2,d=1;s.code===10&&(r=s.value,s=e.next()),s.code===20&&(a=s.value,s=e.next()),s.code===11&&(o=s.value,s=e.next()),s.code===21&&(l=s.value,s=e.next()),s.code===40&&(c=s.value,s=e.next()),s.code===50&&(u=s.value*so,s=e.next()),s.code===51&&(h=s.value*so,s=e.next()),s.code===73&&(d=s.value,s=e.next());const f=Math.hypot(o,l),p=f*c,_=Math.atan2(l,o);let m=h-u;if(d!==0)for(;m<=0;)m+=Math.PI*2;else for(;m>=0;)m-=Math.PI*2;const g=Math.max(4,Math.ceil(Math.abs(m)/(Math.PI*2)*72));for(let v=0;v<=g;v++){const b=u+m*v/g,x=f*Math.cos(b),E=p*Math.sin(b);t.points.push({x:r+x*Math.cos(_)-E*Math.sin(_),y:a+x*Math.sin(_)+E*Math.cos(_)})}}else if(i===4){let r=0,a=0;const o=()=>{const l=s.value|0;return s=e.next(),l};for(;!e.isEOF();)if(s.code===95)r=o();else if(s.code===96)a=o();else if(s.code===94||s.code===73||s.code===74)s=e.next();else break;for(let l=0;l<r&&s.code===40&&!e.isEOF();l++)s=e.next();for(let l=0;l<a&&!e.isEOF();l++){let c=0,u=0;s.code===10&&(c=s.value,s=e.next()),s.code===20&&(u=s.value,s=e.next()),s.code===42&&(s=e.next()),t.points.push({x:c,y:u})}}else s=e.next();return s}}const ro=Math.PI/180,$t=n=>n&&{x:n.x,y:n.y,z:n.z||0};function xf(n,e){var s;const t={...n};switch(delete t.color,(n.type||"").toUpperCase()){case"LINE":((s=n.vertices)==null?void 0:s.length)>=2&&(t.start=$t(n.vertices[0]),t.end=$t(n.vertices[1]));break;case"POLYLINE":case"LWPOLYLINE":t.type="LWPOLYLINE",t.points=(n.vertices||[]).map($t),t.bulges=(n.vertices||[]).map(r=>r.bulge||0),t.closed=!!n.shape||((n.flags||0)&1)===1;break;case"ARC":case"CIRCLE":t.center=$t(n.center);break;case"ELLIPSE":t.center=$t(n.center),t.majorAxis=$t(n.majorAxisEndPoint),t.ratio=n.axisRatio,t.startParam=n.startAngle,t.endParam=n.endAngle;break;case"POINT":t.position=$t(n.position);break;case"SOLID":case"3DFACE":{const r=n.points||[];r[0]&&(t.corner1=$t(r[0])),r[1]&&(t.corner2=$t(r[1])),r[2]&&(t.corner3=$t(r[2])),r[3]&&(t.corner4=$t(r[3])),t.type="SOLID";break}case"TEXT":case"ATTRIB":case"ATTDEF":t.insertionPoint=$t(n.startPoint||n.position),t.alignmentPt=$t(n.endPoint),t.rotationAngle=(n.rotation||0)*ro,t.horizAlignment=n.halign||0,t.vertAlignment=n.valign||0,t.textHeight=n.textHeight??n.height;break;case"MTEXT":t.insertionPoint=$t(n.position),t.textHeight=n.height??n.textHeight,n.directionVector?t.xAxisDir=$t(n.directionVector):n.rotation!=null&&(t.xAxisDir={x:Math.cos(n.rotation*ro),y:Math.sin(n.rotation*ro)});break;case"INSERT":{t.insertionPoint=$t(n.position),t.scaleX=n.xScale??1,t.scaleY=n.yScale??1,t.rotation=(n.rotation||0)*ro;const r=e.get(n.name);r!=null&&(t.blockHeaderHandle={value:r});break}case"DIMENSION":{const r=e.get(n.block);r!=null&&(t.blockHeaderHandle={value:r});break}}return t}function TT(n){var u,h;const e=n.blocks||{},t=Object.keys(e),i=new Map;t.forEach((d,f)=>i.set(d,f+1));const s=t.find(d=>/model_space/i.test(d))??t.find(d=>/model/i.test(d)),r=s!=null?i.get(s):0,a=[];for(const d of n.entities||[]){const f=xf(d,i);f.ownerHandle={value:r},a.push(f)}for(const d of t){const f=i.get(d);for(const p of e[d].entities||[]){const _=xf(p,i);_.ownerHandle={value:f},a.push(_)}}const o=t.map(d=>({name:d,handle:{value:i.get(d)},basePoint:$t(e[d].position)||{x:0,y:0,z:0}})),l=((h=(u=n.tables)==null?void 0:u.layer)==null?void 0:h.layers)||{},c=Object.values(l).map(d=>({name:d.name,colorIndex:d.colorIndex}));return{version:"dxf",vars:n.header||{},entities:a,tables:{blocks:o,layers:c}}}function CT(n){var s,r;try{return new TextDecoder("utf-8",{fatal:!0}).decode(n)}catch{}const t=(r=(s=new TextDecoder("latin1").decode(new Uint8Array(n,0,Math.min(n.byteLength,4096))).match(/\$DWGCODEPAGE[\s\S]*?\n\s*3\s*\n\s*([^\r\n]+)/i))==null?void 0:s[1])==null?void 0:r.trim().toLowerCase();let i="windows-1252";t&&(/949/.test(t)?i="euc-kr":/932/.test(t)?i="shift_jis":/936/.test(t)?i="gbk":/950/.test(t)&&(i="big5"));try{return new TextDecoder(i).decode(n)}catch{return new TextDecoder("utf-8").decode(n)}}function yf(n){return wT(CT(n))}function wT(n){const e=new ST;e.registerEntityHandler(ET);const t=e.parseSync(n);return TT(t)}const F0=/\.dwg$/i,B0=/\.dxf$/i;function RT(n){return F0.test(n)}function LT(n){return B0.test(n)}function DT(n){return F0.test(n)||B0.test(n)}const Wi=n=>typeof n=="number"?n.toFixed(2):n??"-",cn=n=>typeof n=="number"?n.toFixed(3):n??"-",Zs=n=>{if(typeof n!="number")return"-";let e=n*180/Math.PI;for(;e<0;)e+=360;for(;e>=360;)e-=360;return e.toFixed(1)+"°"},Cn=n=>{if(!n)return"-";const e=typeof n.x=="number"?Wi(n.x):"0.00",t=typeof n.y=="number"?Wi(n.y):"0.00",i=typeof n.z=="number"&&Math.abs(n.z)>1e-6?`, ${Wi(n.z)}`:"";return`${e}, ${t}${i}`};function IT(n){return n==null?"BYLAYER":typeof n=="number"?n===256?"BYLAYER (256)":n===0?"BYBLOCK (0)":`ACI ${n}`:String(n)}function PT(n){return typeof n!="number"||n===-1?"BYLAYER":n===-2?"BYBLOCK":n===-3?"DEFAULT (0.25mm)":n<0?String(n):`${(n/100).toFixed(2)}mm`}function OT(n){var h,d,f,p,_,m;if(!n)return{id:"",type:"",handle:"",layer:"",general:[],geometry:[]};const e=n.data||n,t=(n.type||n.typeName||"ENTITY").toUpperCase(),i=((h=n.handle)==null?void 0:h.value)??n.handle??"-",s=n.layer??n.layerName??"0",r=IT(n.color??e.color),a=n.lineType??n.linetype??e.lineType??"BYLAYER",o=PT(((d=n.entityHeader)==null?void 0:d.lineWeight)??n.lineWeight??n.lineweight??e.lineweight),l=[["유형 (Type)",t],["핸들 (Handle)",String(i)],["레이어 (Layer)",String(s)],["색상 (Color)",r],["선종류 (Linetype)",String(a)],["선가중치 (Lineweight)",o]],c=[];switch(t){case"LINE":{if(e.start&&e.end){const g=e.end.x-e.start.x,v=e.end.y-e.start.y,b=(e.end.z||0)-(e.start.z||0),x=Math.hypot(g,v,b),E=Math.atan2(v,g);c.push(["시작점 (Start)",Cn(e.start)]),c.push(["끝점 (End)",Cn(e.end)]),c.push(["증분 (ΔX, ΔY)",`${Wi(g)}, ${Wi(v)}`]),c.push(["길이 (Length)",cn(x)]),c.push(["각도 (Angle)",Zs(E)])}break}case"CIRCLE":{if(e.center&&e.radius!=null){const g=e.radius,v=g*2,b=2*Math.PI*g,x=Math.PI*g*g;c.push(["중심점 (Center)",Cn(e.center)]),c.push(["반지름 (Radius)",cn(g)]),c.push(["지름 (Diameter)",cn(v)]),c.push(["둘레 (Circumference)",cn(b)]),c.push(["넓이 (Area)",cn(x)])}break}case"ARC":{if(e.center&&e.radius!=null){const g=e.radius,v=e.startAngle??0,b=e.endAngle??Math.PI*2;let x=b-v;for(;x<0;)x+=Math.PI*2;const E=x*g;c.push(["중심점 (Center)",Cn(e.center)]),c.push(["반지름 (Radius)",cn(g)]),c.push(["시작각 (Start Angle)",Zs(v)]),c.push(["끝각 (End Angle)",Zs(b)]),c.push(["중심각 (Sweep Angle)",Zs(x)]),c.push(["호 길이 (Arc Length)",cn(E)])}break}case"LWPOLYLINE":case"POLYLINE":{const g=e.points??e.vertices??[],v=!!(e.closed||e.flags&1);let b=0;for(let x=0;x<g.length-(v?0:1);x++){const E=g[x],S=g[(x+1)%g.length];E&&S&&(b+=Math.hypot(S.x-E.x,S.y-E.y))}if(c.push(["정점 개수 (Vertices)",String(g.length)]),c.push(["닫힘 여부 (Closed)",v?"예 (Closed)":"아니오 (Open)"]),c.push(["총 길이 (Total Length)",cn(b)]),v&&g.length>=3){let x=0;for(let E=0;E<g.length;E++){const S=g[E],A=g[(E+1)%g.length];x+=S.x*A.y-A.x*S.y}c.push(["면적 (Area)",cn(Math.abs(x)/2)])}if(g.length>0){const x=Math.min(g.length,4);for(let E=0;E<x;E++)c.push([`정점 P${E+1}`,Cn(g[E])]);g.length>x&&c.push(["...",`외 ${g.length-x}개 정점`])}break}case"MESH":{const g=e.vertices??[],v=e.vertexCount??Math.floor(g.length/3),b=e.faceCount??0,x=Math.floor((((f=e.edges)==null?void 0:f.length)??0)/2),E=e.subdivisionLevel??0;if(c.push(["정점 개수 (Vertices)",String(v)]),c.push(["면 개수 (Faces)",String(b)]),c.push(["모서리 개수 (Edges)",String(x)]),c.push(["세분 레벨 (Subdivision)",String(E)]),c.push(["크리스 혼합 (Blend Crease)",e.blendCrease?"예 (Yes)":"아니오 (No)"]),v>0){let S=1/0,A=1/0,y=1/0,T=-1/0,L=-1/0,R=-1/0;for(let w=0;w+2<g.length;w+=3){const P=g[w],U=g[w+1],D=g[w+2];P<S&&(S=P),P>T&&(T=P),U<A&&(A=U),U>L&&(L=U),D<y&&(y=D),D>R&&(R=D)}c.push(["최소점 (Min)",Cn({x:S,y:A,z:y})]),c.push(["최대점 (Max)",Cn({x:T,y:L,z:R})]),c.push(["표고 범위 (Z Range)",`${cn(y)} ~ ${cn(R)}`])}break}case"TEXT":case"MTEXT":case"ATTRIB":{const g=e.text??n.text??e.textValue??"-",v=e.textHeight??e.height??n.textHeight,b=e.rotationAngle??e.rotation??0,x=e.insertionPoint??e.insertionPt??e.alignmentPt??e.pos;c.push(["텍스트 내용 (Content)",String(g)]),v!=null&&c.push(["높이 (Height)",cn(v)]),c.push(["회전각 (Rotation)",Zs(b)]),x&&c.push(["삽입점 (Position)",Cn(x)]);break}case"INSERT":{const g=e.name??e.blockName??n.name??"-",v=e.insertionPoint??e.insertionPt??n.insertionPt,b=e.xScale??((p=e.scale)==null?void 0:p.x)??1,x=e.yScale??((_=e.scale)==null?void 0:_.y)??1,E=e.zScale??((m=e.scale)==null?void 0:m.z)??1,S=e.rotation??0;c.push(["블록 이름 (Block)",String(g)]),v&&c.push(["삽입점 (Position)",Cn(v)]),c.push(["축척 (Scale X,Y,Z)",`${Wi(b)}, ${Wi(x)}, ${Wi(E)}`]),c.push(["회전각 (Rotation)",Zs(S)]);break}case"HATCH":{const g=e.solidFill??n.solidFill??!1,v=e.patternName??e.name??(g?"SOLID":"HATCH"),b=e.paths??n.paths??[];c.push(["패턴 (Pattern)",String(v)]),c.push(["채우기 유형 (Type)",g?"단색 채우기 (Solid)":"패턴 (Pattern)"]),c.push(["경계 루프 수 (Loops)",String(b.length)]);break}case"DIMENSION":case"DIMENSION_LINEAR":case"DIMENSION_ALIGNED":case"DIMENSION_RADIUS":case"DIMENSION_DIAMETER":case"DIMENSION_ANG_3PT":case"DIMENSION_ANG_2LN":case"DIMENSION_ORDINATE":{const g=e.actualMeasurement??n.actualMeasurement,v=e.userText||(g!=null?cn(g):"-"),b=e.textMidPt??n.textMidPt;c.push(["치수 유형 (Dim Type)",t]),g!=null&&c.push(["측정값 (Measurement)",cn(g)]),c.push(["표시 텍스트 (Text)",String(v)]),b&&c.push(["텍스트 위치 (Text Mid)",Cn(b)]);break}case"ELLIPSE":{e.center&&(c.push(["중심점 (Center)",Cn(e.center)]),e.majorAxis&&c.push(["주축 벡터 (Major Axis)",Cn(e.majorAxis)]),(e.axisRatio!=null||e.ratio!=null)&&c.push(["단축 비율 (Ratio)",cn(e.axisRatio??e.ratio)]));break}default:{let g=0;for(const[v,b]of Object.entries(e))if(!(typeof b=="object"||b==null||typeof b=="function")&&(c.push([v,String(b)]),g++,g>=12))break}}return{id:`${t}${i!=="-"?" · #"+i:""}`,type:t,handle:String(i),layer:String(s),general:l,geometry:c}}function Ql(n){return n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function lu(n,e,t){if(!n)return;if(!e){t!=null&&t.zoomBtnEl&&(t.zoomBtnEl.style.display="none"),n.innerHTML=`
<div style="padding:40px 20px;text-align:center;color:var(--muted);font-size:12px;line-height:1.6">
<div style="font-size:24px;margin-bottom:8px;opacity:.5">🔍</div>
도면에서 객체(엔티티)를 클릭하면<br/>상세 속성이 표시됩니다
</div>`;return}t!=null&&t.zoomBtnEl&&(t.zoomBtnEl.style.display="inline-flex");const i=OT(e),s=r=>r.map(([a,o])=>`
<div style="display:flex;justify-content:space-between;align-items:center;gap:12px;padding:6px 0;border-bottom:1px solid var(--line)">
<span style="font-size:12px;color:var(--muted);flex-shrink:0">${Ql(a)}</span>
<span style="font-family:var(--mono);font-size:12px;color:var(--ink);text-align:right;word-break:break-all;user-select:all">${Ql(o)}</span>
</div>`).join("");n.innerHTML=`
<div style="padding:14px">
<!-- Entity ID Tag -->
<div style="display:flex;align-items:center;gap:8px;margin-bottom:14px;background:rgba(63,185,80,.1);border:1px solid rgba(63,185,80,.25);padding:8px 10px;border-radius:6px">
<span style="width:8px;height:8px;border-radius:50%;background:var(--accent);flex-shrink:0"></span>
<span style="font-family:var(--mono);font-size:13px;font-weight:700;color:var(--accent)">${Ql(i.id)}</span>
</div>
<!-- General Section -->
<div style="margin-bottom:14px">
<div style="font-size:11px;font-weight:700;letter-spacing:.05em;text-transform:uppercase;color:var(--muted);margin-bottom:6px">
일반 정보 (General)
</div>
${s(i.general)}
</div>
<!-- Geometry Section -->
${i.geometry.length>0?`
<div>
<div style="font-size:11px;font-weight:700;letter-spacing:.05em;text-transform:uppercase;color:var(--accent);margin-bottom:6px">
기하 속성 (Geometry)
</div>
${s(i.geometry)}
</div>`:""}
</div>`}class UT{constructor(e,t,i){Lt(this,"viewer");Lt(this,"listEl");Lt(this,"countEl");Lt(this,"searchInputEl");Lt(this,"hiddenLayers",new Set);Lt(this,"searchQuery","");this.viewer=e,this.listEl=t,this.countEl=(i==null?void 0:i.countEl)||null,this.searchInputEl=(i==null?void 0:i.searchInputEl)||null,this.searchInputEl&&this.searchInputEl.addEventListener("input",s=>{this.searchQuery=s.target.value.trim().toLowerCase(),this.render()}),i!=null&&i.showAllBtnEl&&i.showAllBtnEl.addEventListener("click",()=>this.showAllLayers()),i!=null&&i.hideAllBtnEl&&i.hideAllBtnEl.addEventListener("click",()=>this.hideAllLayers()),this.listEl.addEventListener("click",s=>{var o,l;const r=(l=(o=s.target)==null?void 0:o.closest)==null?void 0:l.call(o,".layer-row");if(!r)return;const a=r.dataset.name;a&&this.toggleLayer(a)})}update(){this.hiddenLayers.clear();const e=this.viewer.getLayerInfo()||[];for(const t of e)t.visible||this.hiddenLayers.add(t.name);this.render()}showAllLayers(){this.hiddenLayers.clear(),this.viewer.setHiddenLayers(this.hiddenLayers),this.syncRows()}hideAllLayers(){const e=this.viewer.getLayerInfo()||[];for(const t of e)this.hiddenLayers.add(t.name);this.viewer.setHiddenLayers(this.hiddenLayers),this.syncRows()}toggleLayer(e){this.hiddenLayers.has(e)?this.hiddenLayers.delete(e):this.hiddenLayers.add(e),this.viewer.setHiddenLayers(this.hiddenLayers),this.syncRow(e)}syncRow(e){var i;const t=(i=this.listEl)==null?void 0:i.querySelector(`.layer-row[data-name="${NT(e)}"]`);t&&this.paintRow(t,!this.hiddenLayers.has(e))}syncRows(){this.listEl&&this.listEl.querySelectorAll(".layer-row").forEach(e=>{const t=e.dataset.name;t!=null&&this.paintRow(e,!this.hiddenLayers.has(t))})}paintRow(e,t){e.style.opacity=t?"1":"0.4";const i=e.querySelector(".eye-btn");i&&(i.textContent=t?"👁️":"🕶️",i.title=t?"숨기기":"표시하기")}render(){if(!this.listEl)return;const e=this.viewer.getLayerInfo()||[];if(this.countEl&&(this.countEl.textContent=`${e.length}개`),!e.length){this.listEl.innerHTML=`
<div style="padding:30px 16px;text-align:center;color:var(--muted);font-size:12px">
도면에 레이어 정보가 없습니다
</div>`;return}const t=e.filter(i=>i.name.toLowerCase().includes(this.searchQuery));if(!t.length){this.listEl.innerHTML=`
<div style="padding:24px 16px;text-align:center;color:var(--muted);font-size:12px">
검색 결과가 없습니다 ("${Or(this.searchQuery)}")
</div>`;return}this.listEl.innerHTML=t.map(i=>{const s=!this.hiddenLayers.has(i.name),r=s?"1":"0.4",a=s?"👁️":"🕶️",o=s?"숨기기":"표시하기";return`
<div class="layer-row" data-name="${Or(i.name)}"
style="display:flex;align-items:center;gap:10px;padding:7px 10px;border-bottom:1px solid var(--line);opacity:${r};transition:opacity .15s;user-select:none">
<span style="width:10px;height:10px;border-radius:3px;background:${i.colorHex||"#888"};flex-shrink:0;box-shadow:0 0 0 1px rgba(255,255,255,.15)"></span>
<span class="mono" style="flex:1;font-size:12px;color:var(--ink);white-space:nowrap;overflow:hidden;text-overflow:ellipsis" title="${Or(i.name)}">
${Or(i.name)}
</span>
<span class="mono" style="font-size:11px;color:var(--muted);background:rgba(255,255,255,.06);padding:2px 6px;border-radius:4px;flex-shrink:0">
${i.count}
</span>
<button type="button" class="eye-btn" data-toggle="${Or(i.name)}" title="${o}"
style="background:none;border:none;cursor:pointer;font-size:13px;padding:2px 4px;border-radius:4px;color:var(--ink);transition:transform .1s">
${a}
</button>
</div>`}).join("")}}function NT(n){return n.replace(/["\\]/g,"\\$&")}function Or(n){return n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}let ao=30;function H0(n,e){if(!n)return{toggleCollapse:()=>{},isCollapsed:()=>!1};const t=(e==null?void 0:e.handleEl)||n.querySelector(".hdr")||n,i=(e==null?void 0:e.collapseBtnEl)||n.querySelector(".collapse-btn"),s=(e==null?void 0:e.bodyEl)||n.querySelector("#propBody")||n.querySelector("#layerBody")||n.children[1];let r=!1,a=!1,o=0,l=0,c=0,u=0;t&&(t.style.cursor="grab",t.style.userSelect="none"),n.addEventListener("pointerdown",()=>{ao++,n.style.zIndex=String(ao)});const h=m=>{if(m.target.closest("button, input, select, a, label, .hdr-actions"))return;a=!0,ao++,n.style.zIndex=String(ao),t&&(t.style.cursor="grabbing");const v=n.getBoundingClientRect();o=m.clientX,l=m.clientY,c=v.left,u=v.top,n.style.left=`${c}px`,n.style.top=`${u}px`,n.style.right="auto",n.style.bottom="auto",document.addEventListener("pointermove",d),document.addEventListener("pointerup",f),m.preventDefault()},d=m=>{if(!a)return;const g=m.clientX-o,v=m.clientY-l;let b=c+g,x=u+v;const E=Math.max(10,window.innerWidth-n.offsetWidth-10),S=Math.max(10,window.innerHeight-n.offsetHeight-10);b=Math.max(10,Math.min(b,E)),x=Math.max(10,Math.min(x,S)),n.style.left=`${b}px`,n.style.top=`${x}px`},f=()=>{a&&(a=!1,t&&(t.style.cursor="grab"),document.removeEventListener("pointermove",d),document.removeEventListener("pointerup",f))};t&&(t.addEventListener("pointerdown",h),t.addEventListener("dblclick",m=>{m.target.closest("button, input, select, a, label")||_()}));let p="";const _=()=>{r=!r,n.classList.toggle("collapsed",r),r?(p=n.style.height||`${n.offsetHeight}px`,n.style.height="42px",s&&(s.style.display="none")):(n.style.height=p||"480px",s&&(s.style.display="flex")),i&&(i.textContent=r?"▸":"▾",i.setAttribute("title",r?"펼치기":"접기")),e!=null&&e.onCollapseToggle&&e.onCollapseToggle(r)};return i&&i.addEventListener("click",m=>{m.stopPropagation(),_()}),{toggleCollapse:_,isCollapsed:()=>r}}bE("/fonts/NanumGothic-Regular.ttf");const kT=document.getElementById("app"),vf=document.getElementById("status"),oo=document.getElementById("spaces"),zo=document.getElementById("layers"),FT=document.getElementById("layerList"),BT=document.getElementById("layerCount"),HT=document.getElementById("layerSearch"),zT=document.getElementById("layerShowAll"),VT=document.getElementById("layerHideAll"),GT=document.getElementById("closeLayersBtn"),WT=document.getElementById("collapseLayersBtn"),na=document.getElementById("properties"),cu=document.getElementById("propBody"),XT=document.getElementById("propsBtn"),Vo=document.getElementById("zoomSelBtn"),YT=document.getElementById("closePropsBtn"),KT=document.getElementById("collapsePropsBtn");function vs(n,e=!1){vf.textContent=n,vf.classList.toggle("err",e)}H0(na,{collapseBtnEl:KT});H0(zo,{collapseBtnEl:WT});lu(cu,null,{zoomBtnEl:Vo});const Ft=new zE(kT),qT=new UT(Ft,FT,{countEl:BT,searchInputEl:HT,showAllBtnEl:zT,hideAllBtnEl:VT});Ft.onSelect(n=>{var t;if(!n){vs("deselected"),lu(cu,null,{zoomBtnEl:Vo});return}na.style.display="flex",lu(cu,n,{zoomBtnEl:Vo});const e=n;vs(`select ${e.type??"?"} · layer=${e.layer??"-"} · h=${((t=e.handle)==null?void 0:t.value)??"-"}`)});const Sf=document.getElementById("coordX"),bf=document.getElementById("coordY");function Mf(n){const e=Math.abs(n);return e>=1e6?n.toFixed(1):e>=1e3?n.toFixed(2):e>=1?n.toFixed(3):n.toFixed(4)}Ft.onPointerWorld(n=>{if(!n){Sf.textContent="—",bf.textContent="—";return}Sf.textContent=Mf(n.x),bf.textContent=Mf(n.y)});function z0(){var t;const n=Ft.getSpaces(),e=Ft.getActiveSpace();if(oo.innerHTML="",n.length<2&&!((t=n[0])!=null&&t.entityCount)){oo.style.display="none";return}oo.style.display="flex";for(const i of n){const s=document.createElement("button");s.type="button",s.textContent=`${i.label}${i.entityCount?` (${i.entityCount})`:""}`,s.title=`${i.name} · handle ${i.handleHex}`,i.handleHex===e&&s.classList.add("active"),s.addEventListener("click",()=>{i.handleHex!==Ft.getActiveSpace()&&(Ft.setSpace(i.handleHex),z0(),Wu(),Ft.fit(),vs(`space ${i.label} · ${i.entityCount} entities`))}),oo.append(s)}}async function $T(n,e){return LT(e)?yf(n):RT(e)?gf(new Uint8Array(n)):new TextDecoder("latin1").decode(new Uint8Array(n,0,Math.min(6,n.byteLength))).startsWith("AC")?gf(new Uint8Array(n)):yf(n)}async function V0(n,e){const t=await $T(n,e),i=Qs(t),s=ES(i);return Ft.load(t,{spaceHandle:(s==null?void 0:s.handleHex)??null}),Ft.resize(),W0(),t}async function Jo(n,e){const t=e??n.split("?")[0].split("/").pop()??n,i=await fetch(n);if(!i.ok)throw new Error(`HTTP ${i.status}`);return V0(await i.arrayBuffer(),t)}async function G0(n){if(!DT(n.name))throw new Error(`not .dwg/.dxf: ${n.name}`);return V0(await n.arrayBuffer(),n.name)}function Wu(){qT.update()}async function ZT(n,e){var r;const i=Qs(e).find(a=>a.handleHex===Ft.getActiveSpace()),s=i?` · ${i.label}`:"";vs(`✓ ${n} · ${((r=e.entities)==null?void 0:r.length)??0} entities${s}`),z0(),Wu(),Ft.fit()}async function xr(n,e){vs(`loading ${n}…`);try{await ZT(n,await e())}catch(t){vs(`${n}: ${t.message}`,!0),console.error(t)}}const JT="/samples/civil.dwg";document.getElementById("sample").addEventListener("click",()=>{xr("BasicSample.dwg",()=>Jo("/samples/BasicSample.dwg","BasicSample.dwg"))});var Af;(Af=document.getElementById("sampleCivil"))==null||Af.addEventListener("click",()=>{xr("C0060202-001-평면및종단면도.dwg",()=>Jo(JT,"C0060202-001-평면및종단면도.dwg"))});document.getElementById("sampleDxf").addEventListener("click",()=>{xr("simple.dxf",()=>Jo("/samples/simple.dxf","simple.dxf"))});document.getElementById("file").addEventListener("change",n=>{var t;const e=(t=n.target.files)==null?void 0:t[0];e&&(xr(e.name,()=>G0(e)),n.target.value="")});let ec=!0;var Ef;(Ef=document.getElementById("fit"))==null||Ef.addEventListener("click",()=>{Ft.fit()});document.getElementById("theme").addEventListener("click",()=>{ec=!ec,Ft.setTheme(ec),Wu()});const uu=document.getElementById("lwt"),W0=()=>{const n=Ft.getLineweightEnabled();uu.classList.toggle("primary",n),uu.title=`선가중치 표시 ${n?"ON":"OFF"} (AutoCAD LWDISPLAY)`};uu.addEventListener("click",()=>{Ft.setLineweightEnabled(!Ft.getLineweightEnabled()),W0()});document.getElementById("layersBtn").addEventListener("click",()=>{zo.style.display=zo.style.display==="flex"?"none":"flex"});GT.addEventListener("click",()=>{zo.style.display="none"});XT.addEventListener("click",()=>{na.style.display=na.style.display==="none"?"flex":"none"});Vo.addEventListener("click",()=>{Ft.zoomToSelection()});YT.addEventListener("click",()=>{na.style.display="none"});window.addEventListener("keydown",n=>{var e;(n.key==="f"||n.key==="F")&&((e=n.target)==null?void 0:e.tagName)!=="INPUT"&&Ft.fit()});window.addEventListener("dragover",n=>n.preventDefault());window.addEventListener("drop",n=>{var t,i;n.preventDefault();const e=(i=(t=n.dataTransfer)==null?void 0:t.files)==null?void 0:i[0];e&&xr(e.name,()=>G0(e))});const tc=new URLSearchParams(location.search).get("model");tc?xr(tc,()=>Jo(tc)):vs("ready");window.addEventListener("resize",()=>Ft.resize());