@wayrisignals/kicad-webview
Version:
Interactive KiCad schematic, PCB and 3D viewer for the web, with Gerber, Excellon, linked views and offline HTML exports
4,894 lines • 1.27 MB
JavaScript
/*! KiCad WebView 1.2.1 | Copyright (c) 2026 wayri | SPDX-License-Identifier: MPL-2.0 | Source: https://github.com/wayri/kicad-webview/tree/v1.2.1 | Keep LICENSE and THIRD-PARTY-NOTICES.md; bundled dependencies retain their licenses. */
import{a as nv}from"./chunk-KOT5IEJZ.js";import{a as cS,b as lS}from"./chunk-JQFHUX53.js";import{a as uS}from"./chunk-S6II22ZF.js";import{b as aS}from"./chunk-FPOLRSV2.js";import{a as iv,b as dl,c as md}from"./chunk-ISOTB6CX.js";import{b as tv,c as oS,d as wa}from"./chunk-TZWR7E27.js";var dM=tv((hM,Qp)=>{(i=>{"use strict";let n=f=>f&&typeof f=="object"&&!Array.isArray(f)?f.quoted:f,r=f=>Array.isArray(f)?String(n(f[0])):"",s=(f,p)=>Array.isArray(f)?f.filter(v=>Array.isArray(v)&&r(v)===p):[],o=(f,p)=>s(f,p)[0],a=(f,p)=>n(o(f,p)?.[1]),c=(f,p)=>typeof n(f)=="number"&&Number.isFinite(n(f))?n(f):p,l=(f,p,v)=>{let _=o(o(f,p),"xyz");return _?[c(_[1],NaN),c(_[2],NaN),c(_[3],NaN)]:[...v]},u=f=>typeof f=="string"&&f.length>0&&f.length<=500&&!/[\\\u0000-\u001f\u007f?%]/.test(f)&&!/^[a-z][a-z\d+.-]*:/i.test(f)&&!f.startsWith("/");function h(f,p){if(typeof p=="string"&&(p=p.replace(/\\/g,"/")),!u(f)||!/\.kicad_pcb$/i.test(f)||!u(p))return null;let v=f.split("/");if(v.some(E=>!E||E==="."||E===".."))return null;let _=p.replace(/^(?:\$\{KIPRJMOD\}|\$\(KIPRJMOD\))\//,"");if(_.includes("$(")||_.includes("${")||_.includes("}"))return null;let y=v.slice(0,-1);for(let E of _.split("/"))if(!(!E||E==="."))if(E===".."){if(!y.length)return null;y.pop()}else y.push(E);let b=y.join("/");return b.length<=500&&u(b)?b:null}function d(f){if(r(f)!=="kicad_pcb")throw new Error("Expected a saved KiCad PCB.");let p=new Set(["at","layer","uuid","tstamp","model","embedded_files"]),v=["kicad_pcb"];for(let _ of f){if(r(_)==="embedded_files"&&v.push(_),r(_)!=="footprint")continue;let y=["footprint"];if(v.push(y),!!_.some(b=>r(b)==="model"))for(let b of _){let E=r(b);p.has(E)?y.push(b):(E==="property"&&n(b[1])==="Reference"||E==="fp_text"&&n(b[1])==="reference")&&y.push(b.slice(0,3))}}return v}function m(f,p,v=i.KiCadDesignDiff?.parse,_=[]){if(typeof v!="function")throw new Error("KiCad S-expression parser is unavailable.");return g(v(f),p,_)}function g(f,p,v=[]){if(r(f)!=="kicad_pcb")throw new Error("Expected a saved KiCad PCB.");let _=[],y=[],b=N=>{y.length<48&&y.push(N)},E=Array.isArray(v)?v.slice(0,2e3).filter(N=>u(N)&&N.split("/").every(I=>I&&I!=="."&&I!=="..")):[];function A(N,I){let L=h(p,N),q=/^(?:\$\{(?:KICAD\d+_3DMODEL_DIR|KISYS3DMOD)\}|\$\((?:KICAD\d+_3DMODEL_DIR|KISYS3DMOD)\))[\\/]/,K=typeof N=="string"&&q.test(N)?N.replace(q,"").replace(/\\/g,"/"):null,B=L||K;if(L&&(!E.length||E.includes(L)))return L;if(Array.isArray(v)&&v.length>=2e3)return L||b(`${I}: model discovery is incomplete; library recovery is unavailable: ${String(N).slice(0,100)}`),L;if(L){let j=E.filter(J=>J.toLowerCase()===L.toLowerCase());if(j.length===1)return b(`${I}: model path casing corrected to ${j[0]}`),j[0];if(j.length>1)return b(`${I}: model path casing is ambiguous: ${L}`),null}if(B&&u(B)&&B.split("/").every(j=>j&&j!=="."&&j!=="..")){let j=K?E.filter(se=>se===K||se.endsWith("/"+K)):[];if(j.length===1)return j[0];if(j.length>1)return b(`${I}: model library path matches multiple repository files: ${K}`),null;if(K){let se=K.toLowerCase(),ce=E.filter(me=>me.toLowerCase()===se||me.toLowerCase().endsWith("/"+se));if(ce.length===1)return b(`${I}: model path casing corrected to ${ce[0]}`),ce[0];if(ce.length>1)return b(`${I}: model path casing is ambiguous: ${K}`),null}let J=B.replace(/\.(?:step|stp|wrl|vrml)$/i,"");if(J!==B){let se=E.filter(ce=>{let me=ce.replace(/\.(?:step|stp|wrl|vrml)$/i,"");return me!==ce&&(me.toLowerCase()===J.toLowerCase()||K&&me.toLowerCase().endsWith("/"+J.toLowerCase()))});if(se.length===1)return b(`${I}: using repository model alternative ${se[0]} for ${N}`),se[0];if(se.length>1)return b(`${I}: model alternatives are ambiguous: ${B}`),null}}return L||(!K||!u(K)||K.split("/").some(j=>!j||j==="."||j==="..")||b(`${I}: library model is not included in this project: ${K}. Include the model files with the project to load them offline or in the browser.`),null)}function T(N){let I=new Map;for(let L of s(o(N,"embedded_files"),"file")){let q=a(L,"name");if(!(!u(q)||q.split("/").some(K=>!K||K==="."||K===".."))){if(I.has(q)){I.set(q,null),b(`Duplicate embedded model name: ${q}`);continue}I.set(q,L)}}return I}let M=T(f),S=new WeakMap;function C(N){if(!N)return null;if(S.has(N))return S.get(N);let I=o(N,"data"),L=0;for(let B=1;B<(I?.length||0)&&L<=11200002;B++)L+=String(n(I[B])).length;let q=L&&L<=11200002?I.slice(1).map(n).join(""):"",K=q.startsWith("|")&&q.endsWith("|")?{base64:q.slice(1,-1),checksum:String(a(N,"checksum")||"")}:null;return S.set(N,K),K}for(let[N,I]of s(f,"footprint").entries()){let L=s(I,"model");if(!L.length)continue;let q=s(I,"property").find(w=>n(w[1])==="Reference"),K=s(I,"fp_text").find(w=>n(w[1])==="reference"),B=String(n(q?.[2])||n(K?.[2])||`REF${N+1}`),j=a(I,"uuid")||a(I,"tstamp")||`component-${B}`,J=o(I,"at"),se=c(J?.[1],NaN),ce=c(J?.[2],NaN),me=c(J?.[3],0),Se=String(a(I,"layer")||"F.Cu");if(![se,ce,me].every(Number.isFinite)||!["F.Cu","B.Cu"].includes(Se)){b(`${B}: footprint placement or side is unsupported.`);continue}let V;for(let w of L){if(_.length>=2048)return b("Only the first 2048 footprint model references are loaded."),{models:_,diagnostics:y};let O=n(w[1]),W=typeof O=="string"&&O.startsWith("kicad-embed://")?O.slice(14):null;W!==null&&(V??=T(I));let Q=W!==null?C(V.has(W)?V.get(W):M.get(W)):null;if(W!==null&&!Q){b(`${B}: embedded model is missing or ambiguous: ${W}`);continue}let ee=W!==null?O:A(O,B);if(!ee){b(`${B}: model path is not a repository-relative file: ${String(O).slice(0,100)}`);continue}let he=/\.([a-z\d]+)$/i.exec(ee)?.[1]?.toLowerCase();if(!["wrl","vrml","glb","step","stp"].includes(he)){b(`${B}: ${he==="step"||he==="stp"?"STEP":"model format"} is not supported in the browser: ${ee}`);continue}let Ce=o(w,"hide");if(Ce&&n(Ce[1])!=="no"&&n(Ce[1])!==!1)continue;let oe=l(w,"offset",[0,0,0]),ue=l(w,"scale",[1,1,1]),H=l(w,"rotate",[0,0,0]);if(oe.some(Ie=>!Number.isFinite(Ie)||Math.abs(Ie)>1e4)||ue.some(Ie=>!Number.isFinite(Ie)||Ie<=0||Ie>1e3)||H.some(Ie=>!Number.isFinite(Ie)||Math.abs(Ie)>3600)){b(`${B}: model transform is invalid: ${ee}`);continue}_.push({path:ee,format:he,footprintId:String(j),reference:B,footprint:{x:se,y:ce,angle:me,layer:Se},offset:oe,scale:ue,rotate:H,...Q?{embeddedAsset:Q,assetKey:`embedded:${V.has(W)?N:"board"}:${W}`}:{}})}}return{models:_,diagnostics:y}}function x(f,p,v,_){let y=f.footprint.layer==="B.Cu",b=f.footprint.angle*Math.PI/180,[E,A,T]=f.offset,M=y?-A:A,S=["glb","step","stp"].includes(f.format)?1:2.54;return{position:[f.footprint.x-p+E*Math.cos(b)-M*Math.sin(b),v-f.footprint.y+E*Math.sin(b)+M*Math.cos(b),(y?-1:1)*(_/2+T)],footprintAngle:b,modelRotation:[(y?180:0)-f.rotate[0],(y?1:-1)*f.rotate[1],(y?1:-1)*f.rotate[2]].map(C=>C*Math.PI/180),scale:f.scale.map(C=>C*S)}}i.KiCadRepoModels={collect:m,collectParsed:g,modelSource:d,resolveModelPath:h,modelPose:x},typeof Qp=="object"&&Qp.exports&&(Qp.exports=i.KiCadRepoModels)})(typeof globalThis=="object"?globalThis:hM)});var pM=tv((fM,$p)=>{(i=>{"use strict";function e(r){if(r?.success!==!0||!Array.isArray(r.meshes)||!r.meshes.length||r.meshes.length>512)throw new Error("STEP did not produce a supported mesh.");let s=0,o=0,a=0;return r.meshes.map((c,l)=>{let u=c.attributes?.position?.array,h=c.index?.array,d=c.attributes?.normal?.array;if(!Array.isArray(u)||u.length%3||!u.length||!Array.isArray(h)||h.length%3||!h.length)throw new Error("STEP returned invalid mesh arrays.");if(s+=u.length/3,o+=h.length/3,s>5e5||o>5e5)throw new Error("STEP tessellation exceeds 500,000 vertices or triangles.");if(u.some(T=>!Number.isFinite(T)||Math.abs(T)>1e6)||h.some(T=>!Number.isSafeInteger(T)||T<0||T>=u.length/3))throw new Error("STEP mesh coordinates or indices are invalid.");if(d&&(!Array.isArray(d)||d.length!==u.length||d.some(T=>!Number.isFinite(T))))throw new Error("STEP returned invalid mesh normals.");let m=Array.isArray(c.color)&&c.color.length===3&&c.color.every(T=>Number.isFinite(T)&&T>=0&&T<=1)?c.color:[.65,.68,.7],g=c.brep_faces;if(g!==void 0&&(!Array.isArray(g)||g.length>h.length/3))throw new Error("STEP returned invalid face ranges.");let x=[m],f=new Map([[JSON.stringify(m),0]]),p=new Uint8Array(h.length/3).fill(255),v=Math.min(8,1024-a-(r.meshes.length-l-1));for(let T of g||[]){let M=T?.first,S=T?.last;if(!Number.isSafeInteger(M)||!Number.isSafeInteger(S)||M<0||S<M||S>=p.length)throw new Error("STEP returned invalid face ranges.");let C=Array.isArray(T.color)&&T.color.length===3&&T.color.every(L=>Number.isFinite(L)&&L>=0&&L<=1),N=C?JSON.stringify(T.color):null,I=C?f.get(N):0;if(I===void 0){if(x.length>=v)throw new Error("STEP face colours exceed the bounded material budget.");I=x.length,x.push(T.color),f.set(N,I)}for(let L=M;L<=S;L++){if(p[L]!==255)throw new Error("STEP returned overlapping face ranges.");p[L]=I}}let _=new Uint32Array(x.length);for(let T=0;T<p.length;T++)p[T]===255&&(p[T]=0),_[p[T]]+=3;let y=[],b=new Uint32Array(x.length),E=0;for(let T=0;T<x.length;T++)b[T]=E,_[T]&&(y.push({start:E,count:_[T],color:x[T]}),E+=_[T]);a+=y.length;let A=new Uint32Array(h.length);for(let T=0;T<p.length;T++){let M=b[p[T]];b[p[T]]+=3,A[M]=h[T*3],A[M+1]=h[T*3+1],A[M+2]=h[T*3+2]}return{positions:new Float32Array(u),normals:d?new Float32Array(d):null,index:A,color:m,groups:y}})}async function t(r,s=i.Worker,o=i,a){let c=await o.fetch(r,{credentials:"omit",redirect:"error",signal:a});if(!c.ok)throw new Error("Bundled STEP worker could not be read.");let l=await c.arrayBuffer();if(l.byteLength>256*1024)throw new Error("Bundled STEP worker exceeds 256 KiB.");let u=o.URL.createObjectURL(new o.Blob([l],{type:"text/javascript"}));try{return new s(u)}finally{o.URL.revokeObjectURL(u)}}class n{constructor(s,o=i.Worker){this.url=s,this.WorkerType=o,this.worker=null,this.queue=Promise.resolve(),this.disposed=!1,this.pending=null,this.loadingAbort=null,this.initialized=!1,this.wasmUrl=i.KiCadVSCodeContext?.stepWasmUrl}decode(s){let o=()=>this.run(s),a=this.queue.then(o,o);return this.queue=a.catch(()=>{}),a}async run(s){if(this.disposed)throw new Error("STEP decoder is closed.");if(!(s instanceof Uint8Array)||!s.byteLength||s.byteLength>8*1024*1024)throw new Error("STEP input exceeds 8 MiB or is empty.");if(!this.worker){this.initialized=!1;let o=new AbortController;this.loadingAbort=o;let a=setTimeout(()=>o.abort(),1e4);try{this.worker=i.KiCadVSCodeContext?.stepWorkerUrl?await t(i.KiCadVSCodeContext.stepWorkerUrl,this.WorkerType,i,o.signal):new this.WorkerType(this.url)}catch(c){throw new Error("STEP worker is unavailable: "+c.message)}finally{clearTimeout(a),this.loadingAbort=null}if(this.disposed)throw this.worker.terminate(),this.worker=null,new Error("STEP decoder is closed.")}return new Promise((o,a)=>{let c=(m,g)=>{clearTimeout(u),this.pending=null,this.worker&&(this.worker.onmessage=this.worker.onerror=null),m?a(m):o(g)},l=m=>{this.worker?.terminate(),this.worker=null,this.initialized=!1,c(new Error(m))},u,h=this.initialized,d=(m,g)=>{clearTimeout(u),u=setTimeout(()=>l(g),m)};d(this.initialized?3e4:6e4,this.initialized?"STEP conversion timed out after 30 seconds.":"STEP initialization timed out after 60 seconds."),this.pending=()=>l("STEP decoder is closed."),this.worker.onmessage=m=>{if(m.data?.stage==="kernel-ready"){h||(h=!0,this.initialized=!0,d(3e4,"STEP conversion timed out after 30 seconds."));return}this.initialized=m.data?.ok===!0,this.initialized?c(null,m.data.meshes):c(new Error(m.data?.error||"STEP conversion failed."))},this.worker.onerror=()=>l("STEP worker failed.");try{let m=s.slice();this.worker.postMessage({bytes:m,reportStages:!0,...this.wasmUrl?{wasmUrl:this.wasmUrl}:{}},[m.buffer])}catch{l("STEP worker could not accept input.")}})}dispose(){this.disposed=!0,this.loadingAbort?.abort(),this.pending?.(),this.worker?.terminate(),this.worker=null}}i.KiCadStepDecoder={meshes:e,Client:n,bundledWorker:t},typeof $p=="object"&&$p.exports&&($p.exports=i.KiCadStepDecoder)})(typeof globalThis=="object"?globalThis:fM)});function rv(i=512){if(!Number.isInteger(i)||i<0||i>4096)throw new TypeError("Choose a bounded geometry cache size.");let e=new Map,t=0,n=0;return{get(r,s){if(e.has(r))return t++,e.get(r);let o=s();return e.size<i?e.set(r,o):n++,o},clear(){e.clear()},stats(){return{entries:e.size,hits:t,uncached:n}}}}function sv(i,e=t=>t.assetKey||t.path){let t=new Map,n=new Map;for(let r of i){let s=e(r);t.set(s,(t.get(s)||0)+1)}return{get(r,s){let o=e(r);return n.has(o)||n.set(o,Promise.resolve().then(s)),n.get(o)},isLastUse(r){return t.get(e(r))===1},release(r){let s=e(r),o=(t.get(s)||0)-1;o>0?t.set(s,o):(t.delete(s),n.delete(s))},clear(){t.clear(),n.clear()},stats:()=>({templates:n.size,remainingAssets:t.size})}}var Km={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4},ov={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Wr=(i,e)=>{if(!Number.isSafeInteger(i)||i<0)throw Error("Invalid GLB "+e+".");return i},gd=i=>{throw Object.assign(Error("Linked model "+i+" exceeds its decoded memory budget; saved footprint proxies and identities are retained."),{code:"MODEL_ALLOCATION_BUDGET"})},Zm="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function hS(i,e){if(i.bufferView!==void 0){let a=e(i.bufferView);return{length:a.length,at:c=>a[c]}}let t=/^data:([^;,]+);base64,/i.exec(i.uri||"");if(!t)throw Error("Embedded model image has no supported bounded header.");let n=i.uri,r=t[0].length,s=n.length-r,o=n.endsWith("==")?2:n.endsWith("=")?1:0;if(s%4||s<4)throw Error("Invalid embedded image base64.");for(let a=r;a<n.length-o;a++)if(Zm.indexOf(n[a])<0)throw Error("Invalid embedded image base64.");return{length:s*3/4-o,at(a){let c=Math.floor(a/3)*4+r,l=a%3,u=Zm.indexOf(n[c+l]),h=Zm.indexOf(n[c+l+1]);return l===0?(u<<2|h>>4)&255:l===1?(u<<4|h>>2)&255:(u<<6|h)&255}}}function dS(i){let e=i.length,t=i.at,n=s=>t(s)*256+t(s+1),r=s=>t(s)*16777216+t(s+1)*65536+t(s+2)*256+t(s+3);if(e>=24&&t(0)===137&&t(1)===80&&t(2)===78&&t(3)===71&&t(4)===13&&t(5)===10&&t(6)===26&&t(7)===10){if(r(8)!==13||r(12)!==1229472850)throw Error("Invalid embedded PNG header.");let s=r(16),o=r(20);if(!s||!o)throw Error("Invalid embedded PNG dimensions.");return{width:s,height:o}}if(e>=4&&t(0)===255&&t(1)===216){let s=2;for(;s<e;){if(t(s++)!==255)throw Error("Invalid embedded JPEG marker.");for(;s<e&&t(s)===255;)s++;if(s>=e)break;let o=t(s++);if(o===0||o===218||o===217)break;if(o===1||o>=208&&o<=216)continue;if(s+2>e)break;let a=n(s);if(a<2||s+a>e)throw Error("Invalid embedded JPEG segment.");if(o>=192&&o<=207&&![196,200,204].includes(o)){if(a<8)throw Error("Invalid embedded JPEG frame.");let c=n(s+3),l=n(s+5),u=t(s+7);if(!l||!c||!u||a<8+3*u)throw Error("Invalid embedded JPEG dimensions.");return{width:l,height:c}}s+=a}throw Error("Embedded JPEG has no bounded frame dimensions.")}throw Error("Embedded model image format has no bounded PNG/JPEG dimension preflight; saved footprint proxies are retained.")}function av(i,e,t,{maxAccessorBytes:n=64*1024*1024,maxTextureBytes:r=32*1024*1024,maxTextureDimension:s=8192}={}){for(let[x,f]of[[n,"accessor budget"],[r,"texture budget"],[s,"texture dimension"]])if(!Number.isSafeInteger(x)||x<1)throw TypeError("Invalid GLB "+f+".");let o=null,a=t;for(;a<e.length;){if(a+8>e.length)throw Error("Truncated GLB chunk.");let x=new DataView(e.buffer,e.byteOffset+a,8),f=x.getUint32(0,!0),p=x.getUint32(4,!0);if(a+=8,f>e.length-a)throw Error("Truncated GLB chunk.");if(p===5130562){if(o)throw Error("Duplicate GLB binary chunk.");o=e.subarray(a,a+f)}a+=f}let c=i.buffers||[],l=i.bufferViews||[];function u(x){Wr(x,"buffer view index");let f=l[x];if(!f)throw Error("GLB references an invalid buffer view.");let p=c[Wr(f.buffer,"buffer index")];if(!p)throw Error("GLB references an invalid buffer.");let v=Wr(f.byteOffset??0,"buffer offset"),_=Wr(f.byteLength,"buffer length"),y=Wr(p.byteLength,"buffer length");if(!Number.isSafeInteger(v+_)||v+_>y)throw Error("GLB buffer view exceeds its declared buffer.");if(!p.uri&&(!o||y>o.length))throw Error("GLB buffer exceeds its binary chunk.");return{view:f,start:v,length:_,buffer:p}}let h=x=>{let{buffer:f,start:p,length:v}=u(x);if(f.uri)throw Error("Embedded image buffer uses an unsupported nested data URI.");return o.subarray(p,p+v)},d=0;for(let x=0;x<l.length;x++)d+=u(x).length,(!Number.isSafeInteger(d)||d>n+r)&&gd("buffer view expansion");let m=0;for(let x of i.accessors||[]){let f=Wr(x.count,"accessor count"),p=Km[x.componentType],v=ov[x.type];if(!f||!Number.isInteger(x.componentType)||!p||!Object.hasOwn(Km,x.componentType)||!v||!Object.hasOwn(ov,x.type))throw Error("Invalid GLB accessor component type, shape or count.");let _=x.type.startsWith("MAT")?Number(x.type.at(-1)):1,y=v/_,b=_>1?_*Math.ceil(y*p/4)*4:v*p,E=b,A=Wr(x.byteOffset??0,"accessor offset");if(A%p)throw Error("Misaligned GLB accessor offset.");if(x.bufferView!==void 0){let M=u(x.bufferView);if(E=M.view.byteStride??b,!Number.isSafeInteger(E)||E<b||E%p||M.view.byteStride!==void 0&&(E<4||E>252||E%4))throw Error("Invalid GLB accessor stride.");let S=(f-1)*E+b;if(!Number.isSafeInteger(S)||A+S>M.length)throw Error("GLB accessor exceeds its buffer view.")}else if(A)throw Error("GLB accessor without a buffer view has an offset.");let T=f*E;if(x.sparse){let M=x.sparse,S=Wr(M.count,"sparse count"),C=Km[M.indices?.componentType];if(!S||S>f||![5121,5123,5125].includes(M.indices?.componentType)||!M.values)throw Error("Invalid GLB sparse accessor.");for(let[N,I,L]of[[M.indices,S*C,C],[M.values,S*b,p]]){let q=u(N.bufferView),K=Wr(N.byteOffset??0,"sparse offset");if(K%L||K+I>q.length)throw Error("GLB sparse accessor exceeds its buffer view.")}T+=f*v*p}m+=T,(!Number.isSafeInteger(m)||m>n)&&gd("accessor expansion")}let g=0;for(let x of i.images||[]){let{width:f,height:p}=dS(hS(x,h));(f>s||p>s)&&gd("image dimensions"),g+=Math.ceil(f*p*4*4/3),(!Number.isSafeInteger(g)||g>r)&&gd("image pixels")}return{accessorBytes:m,textureBytes:g}}var cv=(i,e)=>i||e>512?1:3,Ss=()=>Object.assign(Error("Linked model graph exceeds the bounded assembly node budget; saved footprint proxies and identities are retained."),{code:"MODEL_GRAPH_BUDGET"});function lv(i){if(!Number.isSafeInteger(i)||i<1)throw TypeError("Choose a positive model node budget.");let e=new WeakMap,t=0,n=0,r=0;function s(o){if(e.has(o))return e.get(o);let a=[o],c=0;for(;a.length;){let l=a.pop();if(++c>i)throw Ss();for(let u of l.children||[]){if(c+a.length>=i)throw Ss();a.push(u)}}return e.set(o,c),c}return{limit:i,checkTemplate(o,a=0){try{let c=s(o);if(t+c+a>i)throw Ss();return c}catch(c){throw c.code==="MODEL_GRAPH_BUDGET"&&n++,c}},rejectPreflight(){n++},admit(o,a,c){let l=s(o)+a;if(t+l>i)throw r++,Ss();let u=c();return t+=l,u},stats:()=>({limit:i,admittedNodes:t,rejectedTemplates:n,rejectedOccurrences:r})}}function uv(i,e,t){if(i.byteLength<20)throw Error("GLB has an external dependency or invalid header");let n=new DataView(i.buffer,i.byteOffset,i.byteLength),r=n.getUint32(12,!0);if(n.getUint32(0,!0)!==1179937895||n.getUint32(4,!0)!==2||n.getUint32(8,!0)!==i.byteLength||n.getUint32(16,!0)!==1313821514||r>i.byteLength-20)throw Error("GLB has an external dependency or invalid header");let s=JSON.parse(new TextDecoder().decode(i.subarray(20,20+r)));for(let h of[s.buffers||[],s.images||[]])for(let d of h)if(d.uri&&!/^data:/i.test(d.uri))throw Error("GLB has an external dependency or invalid header");av(s,i,20+r,t);let o=s.nodes||[],a=s.scenes||[],c=s.meshes||[],l=a.length;if(o.length>e||l>e)throw Ss();let u=[];for(let h of a){for(let d of h.nodes||[]){if(l+u.length>=e)throw Ss();u.push(d)}for(;u.length;){let d=u.pop(),m=o[d];if(!Number.isInteger(d)||!m)throw Error("GLB references an invalid node.");let g=1;if(m.mesh!==void 0){let x=c[m.mesh];if(!x||!Array.isArray(x.primitives))throw Error("GLB references an invalid mesh.");x.primitives.length>1&&(g+=x.primitives.length)}if(m.camera!==void 0&&g++,m.extensions?.KHR_lights_punctual&&(g+=2),l+=g,l>e)throw Ss();for(let x of m.children||[]){if(l+u.length>=e)throw Ss();u.push(x)}}}return l}var Wn={};oS(Wn,{ACESFilmicToneMapping:()=>jo,AddEquation:()=>xi,AddOperation:()=>a0,AdditiveAnimationBlendMode:()=>yp,AdditiveBlending:()=>op,AgXToneMapping:()=>Uu,AlphaFormat:()=>dp,AlwaysCompare:()=>M0,AlwaysDepth:()=>Ru,AlwaysStencilFunc:()=>af,AmbientLight:()=>Wo,AnimationAction:()=>Su,AnimationClip:()=>Pr,AnimationLoader:()=>Ef,AnimationMixer:()=>Of,AnimationObjectGroup:()=>Lf,AnimationUtils:()=>ab,ArcCurve:()=>zl,ArrayCamera:()=>bu,ArrowHelper:()=>ep,AttachedBindMode:()=>of,Audio:()=>Mu,AudioAnalyser:()=>Nf,AudioContext:()=>mc,AudioListener:()=>Pf,AudioLoader:()=>Rf,AxesHelper:()=>tp,BackSide:()=>un,BasicDepthPacking:()=>f0,BasicShadowMap:()=>__,BatchedMesh:()=>Bl,Bone:()=>Gs,BooleanKeyframeTrack:()=>Rr,Box2:()=>Vf,Box3:()=>zt,Box3Helper:()=>Qf,BoxGeometry:()=>Qn,BoxHelper:()=>Jf,BufferAttribute:()=>gt,BufferGeometry:()=>ot,BufferGeometryLoader:()=>_u,ByteType:()=>lp,Cache:()=>br,Camera:()=>No,CameraHelper:()=>Zf,CanvasTexture:()=>ns,CapsuleGeometry:()=>Xl,CatmullRomCurve3:()=>Vl,CineonToneMapping:()=>Fu,CircleGeometry:()=>Yl,ClampToEdgeWrapping:()=>Mn,Clock:()=>Xo,Color:()=>Ue,ColorKeyframeTrack:()=>dc,ColorManagement:()=>_t,CompressedArrayTexture:()=>_f,CompressedCubeTexture:()=>bf,CompressedTexture:()=>Fo,CompressedTextureLoader:()=>Sf,ConeGeometry:()=>ko,ConstantAlphaFactor:()=>r0,ConstantColorFactor:()=>n0,Controls:()=>gc,CubeCamera:()=>Ol,CubeReflectionMapping:()=>Nr,CubeRefractionMapping:()=>us,CubeTexture:()=>Vs,CubeTextureLoader:()=>Tf,CubeUVReflectionMapping:()=>qo,CubicBezierCurve:()=>nc,CubicBezierCurve3:()=>Hl,CubicInterpolant:()=>uu,CullFaceBack:()=>rp,CullFaceFront:()=>Xg,CullFaceFrontBack:()=>v_,CullFaceNone:()=>Wg,Curve:()=>vi,CurvePath:()=>Wl,CustomBlending:()=>Au,CustomToneMapping:()=>c0,CylinderGeometry:()=>is,Cylindrical:()=>Bf,Data3DTexture:()=>$a,DataArrayTexture:()=>Po,DataTexture:()=>An,DataTextureLoader:()=>Af,DataUtils:()=>eb,DecrementStencilOp:()=>I_,DecrementWrapStencilOp:()=>L_,DefaultLoadingManager:()=>C0,DepthFormat:()=>Ds,DepthStencilFormat:()=>Mr,DepthTexture:()=>Xs,DetachedBindMode:()=>l0,DirectionalLight:()=>as,DirectionalLightHelper:()=>Kf,DiscreteInterpolant:()=>hu,DodecahedronGeometry:()=>jl,DoubleSide:()=>xn,DstAlphaFactor:()=>xc,DstColorFactor:()=>yc,DynamicCopyUsage:()=>j_,DynamicDrawUsage:()=>bp,DynamicReadUsage:()=>W_,EdgesGeometry:()=>ss,EllipseCurve:()=>Uo,EqualCompare:()=>y0,EqualDepth:()=>Pu,EqualStencilFunc:()=>U_,EquirectangularReflectionMapping:()=>_c,EquirectangularRefractionMapping:()=>bc,Euler:()=>yi,EventDispatcher:()=>ki,ExtrudeGeometry:()=>Ys,FileLoader:()=>Vn,Float16BufferAttribute:()=>mf,Float32BufferAttribute:()=>ze,FloatType:()=>si,Fog:()=>Ul,FogExp2:()=>Fl,FramebufferTexture:()=>vf,FrontSide:()=>Jn,Frustum:()=>Ws,GLBufferAttribute:()=>kf,GLSL1:()=>K_,GLSL3:()=>Mp,GreaterCompare:()=>v0,GreaterDepth:()=>Nu,GreaterEqualCompare:()=>b0,GreaterEqualDepth:()=>Iu,GreaterEqualStencilFunc:()=>V_,GreaterStencilFunc:()=>B_,GridHelper:()=>jf,Group:()=>Dt,HalfFloatType:()=>Hn,HemisphereLight:()=>fu,HemisphereLightHelper:()=>Yf,IcosahedronGeometry:()=>Jl,ImageBitmapLoader:()=>pc,ImageLoader:()=>js,ImageUtils:()=>Nl,IncrementStencilOp:()=>P_,IncrementWrapStencilOp:()=>N_,InstancedBufferAttribute:()=>Xi,InstancedBufferGeometry:()=>vu,InstancedInterleavedBuffer:()=>Uf,InstancedMesh:()=>$r,Int16BufferAttribute:()=>ff,Int32BufferAttribute:()=>pf,Int8BufferAttribute:()=>uf,IntType:()=>zu,InterleavedBuffer:()=>Er,InterleavedBufferAttribute:()=>ir,Interpolant:()=>wr,InterpolateDiscrete:()=>Bs,InterpolateLinear:()=>zs,InterpolateSmooth:()=>Al,InvertStencilOp:()=>O_,KeepStencilOp:()=>Ns,KeyframeTrack:()=>bi,LOD:()=>kl,LatheGeometry:()=>ac,Layers:()=>Io,LessCompare:()=>x0,LessDepth:()=>Cu,LessEqualCompare:()=>_p,LessEqualDepth:()=>Us,LessEqualStencilFunc:()=>k_,LessStencilFunc:()=>F_,Light:()=>ar,LightProbe:()=>xu,Line:()=>ai,Line3:()=>Hf,LineBasicMaterial:()=>Xt,LineCurve:()=>ic,LineCurve3:()=>Gl,LineDashedMaterial:()=>lu,LineLoop:()=>es,LineSegments:()=>ln,LinearFilter:()=>nn,LinearInterpolant:()=>hc,LinearMipMapLinearFilter:()=>S_,LinearMipMapNearestFilter:()=>E_,LinearMipmapLinearFilter:()=>Ei,LinearMipmapNearestFilter:()=>Zs,LinearSRGBColorSpace:()=>On,LinearToneMapping:()=>Ou,LinearTransfer:()=>Ka,Loader:()=>rn,LoaderUtils:()=>Mi,LoadingManager:()=>fc,LoopOnce:()=>u0,LoopPingPong:()=>d0,LoopRepeat:()=>h0,LuminanceAlphaFormat:()=>mp,LuminanceFormat:()=>pp,MOUSE:()=>cs,Material:()=>cn,MaterialLoader:()=>yu,MathUtils:()=>Js,Matrix2:()=>zf,Matrix3:()=>xt,Matrix4:()=>nt,MaxEquation:()=>Kg,Mesh:()=>ct,MeshBasicMaterial:()=>Ht,MeshDepthMaterial:()=>lc,MeshDistanceMaterial:()=>uc,MeshLambertMaterial:()=>au,MeshMatcapMaterial:()=>cu,MeshNormalMaterial:()=>Ho,MeshPhongMaterial:()=>Vo,MeshPhysicalMaterial:()=>Dn,MeshStandardMaterial:()=>En,MeshToonMaterial:()=>ou,MinEquation:()=>qg,MirroredRepeatWrapping:()=>ks,MixOperation:()=>o0,MultiplyBlending:()=>cp,MultiplyOperation:()=>vc,NearestFilter:()=>Jt,NearestMipMapLinearFilter:()=>M_,NearestMipMapNearestFilter:()=>b_,NearestMipmapLinearFilter:()=>hs,NearestMipmapNearestFilter:()=>Mc,NeutralToneMapping:()=>ku,NeverCompare:()=>g0,NeverDepth:()=>wu,NeverStencilFunc:()=>D_,NoBlending:()=>yn,NoColorSpace:()=>Dr,NoToneMapping:()=>Ir,NormalAnimationBlendMode:()=>yh,NormalBlending:()=>Fs,NotEqualCompare:()=>_0,NotEqualDepth:()=>Lu,NotEqualStencilFunc:()=>z_,NumberKeyframeTrack:()=>rr,Object3D:()=>St,ObjectLoader:()=>wf,ObjectSpaceNormalMap:()=>m0,OctahedronGeometry:()=>cc,OneFactor:()=>Zg,OneMinusConstantAlphaFactor:()=>s0,OneMinusConstantColorFactor:()=>i0,OneMinusDstAlphaFactor:()=>$g,OneMinusDstColorFactor:()=>e0,OneMinusSrcAlphaFactor:()=>Il,OneMinusSrcColorFactor:()=>Qg,OrthographicCamera:()=>cr,PCFShadowMap:()=>sp,PCFSoftShadowMap:()=>Tu,PMREMGenerator:()=>ia,Path:()=>Tr,PerspectiveCamera:()=>jt,Plane:()=>Li,PlaneGeometry:()=>Ar,PlaneHelper:()=>$f,PointLight:()=>os,PointLightHelper:()=>Xf,Points:()=>ts,PointsMaterial:()=>Sr,PolarGridHelper:()=>qf,PolyhedronGeometry:()=>rs,PositionalAudio:()=>If,PropertyBinding:()=>Ut,PropertyMixer:()=>Eu,QuadraticBezierCurve:()=>rc,QuadraticBezierCurve3:()=>sc,Quaternion:()=>Zt,QuaternionKeyframeTrack:()=>sr,QuaternionLinearInterpolant:()=>du,RED_GREEN_RGTC2_Format:()=>gh,RED_RGTC1_Format:()=>xp,REVISION:()=>Gg,RGBADepthPacking:()=>p0,RGBAFormat:()=>Ln,RGBAIntegerFormat:()=>Xu,RGBA_ASTC_10x10_Format:()=>uh,RGBA_ASTC_10x5_Format:()=>ah,RGBA_ASTC_10x6_Format:()=>ch,RGBA_ASTC_10x8_Format:()=>lh,RGBA_ASTC_12x10_Format:()=>hh,RGBA_ASTC_12x12_Format:()=>dh,RGBA_ASTC_4x4_Format:()=>$u,RGBA_ASTC_5x4_Format:()=>eh,RGBA_ASTC_5x5_Format:()=>th,RGBA_ASTC_6x5_Format:()=>nh,RGBA_ASTC_6x6_Format:()=>ih,RGBA_ASTC_8x5_Format:()=>rh,RGBA_ASTC_8x6_Format:()=>sh,RGBA_ASTC_8x8_Format:()=>oh,RGBA_BPTC_Format:()=>Rc,RGBA_ETC2_EAC_Format:()=>Qu,RGBA_PVRTC_2BPPV1_Format:()=>Ku,RGBA_PVRTC_4BPPV1_Format:()=>qu,RGBA_S3TC_DXT1_Format:()=>Tc,RGBA_S3TC_DXT3_Format:()=>Ac,RGBA_S3TC_DXT5_Format:()=>wc,RGBDepthPacking:()=>A_,RGBFormat:()=>fp,RGBIntegerFormat:()=>T_,RGB_BPTC_SIGNED_Format:()=>fh,RGB_BPTC_UNSIGNED_Format:()=>ph,RGB_ETC1_Format:()=>Zu,RGB_ETC2_Format:()=>Ju,RGB_PVRTC_2BPPV1_Format:()=>ju,RGB_PVRTC_4BPPV1_Format:()=>Yu,RGB_S3TC_DXT1_Format:()=>Sc,RGDepthPacking:()=>w_,RGFormat:()=>gp,RGIntegerFormat:()=>Wu,RawShaderMaterial:()=>zo,Ray:()=>nr,Raycaster:()=>lr,RectAreaLight:()=>mu,RedFormat:()=>Gu,RedIntegerFormat:()=>Ec,ReinhardToneMapping:()=>Du,RenderTarget:()=>Ll,RepeatWrapping:()=>gn,ReplaceStencilOp:()=>C_,ReverseSubtractEquation:()=>jg,RingGeometry:()=>Ql,SIGNED_RED_GREEN_RGTC2_Format:()=>xh,SIGNED_RED_RGTC1_Format:()=>mh,SRGBColorSpace:()=>wt,SRGBTransfer:()=>kt,Scene:()=>oi,ShaderChunk:()=>Tt,ShaderLib:()=>hr,ShaderMaterial:()=>$t,ShadowMaterial:()=>su,Shape:()=>Fi,ShapeGeometry:()=>$l,ShapePath:()=>np,ShapeUtils:()=>Ui,ShortType:()=>up,Skeleton:()=>Do,SkeletonHelper:()=>Wf,SkinnedMesh:()=>Oo,Source:()=>_r,Sphere:()=>qt,SphereGeometry:()=>_i,Spherical:()=>Yo,SphericalHarmonics3:()=>gu,SplineCurve:()=>oc,SpotLight:()=>Go,SpotLightHelper:()=>Gf,Sprite:()=>Lo,SpriteMaterial:()=>Hs,SrcAlphaFactor:()=>Pl,SrcAlphaSaturateFactor:()=>t0,SrcColorFactor:()=>Jg,StaticCopyUsage:()=>Y_,StaticDrawUsage:()=>Za,StaticReadUsage:()=>G_,StereoCamera:()=>Cf,StreamCopyUsage:()=>q_,StreamDrawUsage:()=>H_,StreamReadUsage:()=>X_,StringKeyframeTrack:()=>Cr,SubtractEquation:()=>Yg,SubtractiveBlending:()=>ap,TOUCH:()=>ls,TangentSpaceNormalMap:()=>ds,TetrahedronGeometry:()=>eu,Texture:()=>Qt,TextureLoader:()=>qs,TextureUtils:()=>lb,TorusGeometry:()=>tu,TorusKnotGeometry:()=>nu,Triangle:()=>Oi,TriangleFanDrawMode:()=>Zo,TriangleStripDrawMode:()=>Cc,TrianglesDrawMode:()=>vp,TubeGeometry:()=>iu,UVMapping:()=>Bu,Uint16BufferAttribute:()=>ec,Uint32BufferAttribute:()=>tc,Uint8BufferAttribute:()=>hf,Uint8ClampedBufferAttribute:()=>df,Uniform:()=>Df,UniformsGroup:()=>Ff,UniformsLib:()=>Ze,UniformsUtils:()=>Gn,UnsignedByteType:()=>ci,UnsignedInt248Type:()=>Or,UnsignedInt5999Type:()=>hp,UnsignedIntType:()=>Lr,UnsignedShort4444Type:()=>Vu,UnsignedShort5551Type:()=>Hu,UnsignedShortType:()=>Ko,VSMShadowMap:()=>ur,Vector2:()=>Me,Vector3:()=>z,Vector4:()=>It,VectorKeyframeTrack:()=>or,VideoTexture:()=>yf,WebGL3DRenderTarget:()=>lf,WebGLArrayRenderTarget:()=>cf,WebGLCoordinateSystem:()=>tr,WebGLCubeRenderTarget:()=>Dl,WebGLMultipleRenderTargets:()=>ip,WebGLRenderTarget:()=>on,WebGLRenderer:()=>fs,WebGLUtils:()=>kb,WebGPUCoordinateSystem:()=>Ja,WireframeGeometry:()=>ru,WrapAroundEnding:()=>qa,ZeroCurvatureEnding:()=>Ls,ZeroFactor:()=>Ks,ZeroSlopeEnding:()=>Os,ZeroStencilOp:()=>R_,createCanvasElement:()=>T0});var Gg="171",cs={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},ls={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},Wg=0,rp=1,Xg=2,v_=3,__=0,sp=1,Tu=2,ur=3,Jn=0,un=1,xn=2,yn=0,Fs=1,op=2,ap=3,cp=4,Au=5,xi=100,Yg=101,jg=102,qg=103,Kg=104,Ks=200,Zg=201,Jg=202,Qg=203,Pl=204,Il=205,xc=206,$g=207,yc=208,e0=209,t0=210,n0=211,i0=212,r0=213,s0=214,wu=0,Ru=1,Cu=2,Us=3,Pu=4,Iu=5,Nu=6,Lu=7,vc=0,o0=1,a0=2,Ir=0,Ou=1,Du=2,Fu=3,jo=4,c0=5,Uu=6,ku=7,of="attached",l0="detached",Bu=300,Nr=301,us=302,_c=303,bc=304,qo=306,gn=1e3,Mn=1001,ks=1002,Jt=1003,Mc=1004,b_=1004,hs=1005,M_=1005,nn=1006,Zs=1007,E_=1007,Ei=1008,S_=1008,ci=1009,lp=1010,up=1011,Ko=1012,zu=1013,Lr=1014,si=1015,Hn=1016,Vu=1017,Hu=1018,Or=1020,hp=35902,dp=1021,fp=1022,Ln=1023,pp=1024,mp=1025,Ds=1026,Mr=1027,Gu=1028,Ec=1029,gp=1030,Wu=1031,T_=1032,Xu=1033,Sc=33776,Tc=33777,Ac=33778,wc=33779,Yu=35840,ju=35841,qu=35842,Ku=35843,Zu=36196,Ju=37492,Qu=37496,$u=37808,eh=37809,th=37810,nh=37811,ih=37812,rh=37813,sh=37814,oh=37815,ah=37816,ch=37817,lh=37818,uh=37819,hh=37820,dh=37821,Rc=36492,fh=36494,ph=36495,xp=36283,mh=36284,gh=36285,xh=36286,u0=2200,h0=2201,d0=2202,Bs=2300,zs=2301,Al=2302,Ls=2400,Os=2401,qa=2402,yh=2500,yp=2501,vp=0,Cc=1,Zo=2,f0=3200,p0=3201,A_=3202,w_=3203,ds=0,m0=1,Dr="",wt="srgb",On="srgb-linear",Ka="linear",kt="srgb",R_=0,Ns=7680,C_=7681,P_=7682,I_=7683,N_=34055,L_=34056,O_=5386,D_=512,F_=513,U_=514,k_=515,B_=516,z_=517,V_=518,af=519,g0=512,x0=513,y0=514,_p=515,v0=516,_0=517,b0=518,M0=519,Za=35044,bp=35048,H_=35040,G_=35045,W_=35049,X_=35041,Y_=35046,j_=35050,q_=35042,K_="100",Mp="300 es",tr=2e3,Ja=2001,ki=class{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});let n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){if(this._listeners===void 0)return!1;let n=this._listeners;return n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){if(this._listeners===void 0)return;let r=this._listeners[e];if(r!==void 0){let s=r.indexOf(t);s!==-1&&r.splice(s,1)}}dispatchEvent(e){if(this._listeners===void 0)return;let n=this._listeners[e.type];if(n!==void 0){e.target=this;let r=n.slice(0);for(let s=0,o=r.length;s<o;s++)r[s].call(this,e);e.target=null}}},qn=["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"],hv=1234567,Ro=Math.PI/180,Co=180/Math.PI;function Di(){let i=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(qn[i&255]+qn[i>>8&255]+qn[i>>16&255]+qn[i>>24&255]+"-"+qn[e&255]+qn[e>>8&255]+"-"+qn[e>>16&15|64]+qn[e>>24&255]+"-"+qn[t&63|128]+qn[t>>8&255]+"-"+qn[t>>16&255]+qn[t>>24&255]+qn[n&255]+qn[n>>8&255]+qn[n>>16&255]+qn[n>>24&255]).toLowerCase()}function mt(i,e,t){return Math.max(e,Math.min(t,i))}function E0(i,e){return(i%e+e)%e}function fS(i,e,t,n,r){return n+(i-e)*(r-n)/(t-e)}function pS(i,e,t){return i!==e?(t-i)/(e-i):0}function wl(i,e,t){return(1-t)*i+t*e}function mS(i,e,t,n){return wl(i,e,1-Math.exp(-t*n))}function gS(i,e=1){return e-Math.abs(E0(i,e*2)-e)}function xS(i,e,t){return i<=e?0:i>=t?1:(i=(i-e)/(t-e),i*i*(3-2*i))}function yS(i,e,t){return i<=e?0:i>=t?1:(i=(i-e)/(t-e),i*i*i*(i*(i*6-15)+10))}function vS(i,e){return i+Math.floor(Math.random()*(e-i+1))}function _S(i,e){return i+Math.random()*(e-i)}function bS(i){return i*(.5-Math.random())}function MS(i){i!==void 0&&(hv=i);let e=hv+=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 ES(i){return i*Ro}function SS(i){return i*Co}function TS(i){return(i&i-1)===0&&i!==0}function AS(i){return Math.pow(2,Math.ceil(Math.log(i)/Math.LN2))}function wS(i){return Math.pow(2,Math.floor(Math.log(i)/Math.LN2))}function RS(i,e,t,n,r){let s=Math.cos,o=Math.sin,a=s(t/2),c=o(t/2),l=s((e+n)/2),u=o((e+n)/2),h=s((e-n)/2),d=o((e-n)/2),m=s((n-e)/2),g=o((n-e)/2);switch(r){case"XYX":i.set(a*u,c*h,c*d,a*l);break;case"YZY":i.set(c*d,a*u,c*h,a*l);break;case"ZXZ":i.set(c*h,c*d,a*u,a*l);break;case"XZX":i.set(a*u,c*g,c*m,a*l);break;case"YXY":i.set(c*m,a*u,c*g,a*l);break;case"ZYZ":i.set(c*g,c*m,a*u,a*l);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}}function ri(i,e){switch(e.constructor){case Float32Array:return i;case Uint32Array:return i/4294967295;case Uint16Array:return i/65535;case Uint8Array:return i/255;case Int32Array:return Math.max(i/2147483647,-1);case Int16Array:return Math.max(i/32767,-1);case Int8Array:return Math.max(i/127,-1);default:throw new Error("Invalid component type.")}}function Mt(i,e){switch(e.constructor){case Float32Array:return i;case Uint32Array:return Math.round(i*4294967295);case Uint16Array:return Math.round(i*65535);case Uint8Array:return Math.round(i*255);case Int32Array:return Math.round(i*2147483647);case Int16Array:return Math.round(i*32767);case Int8Array:return Math.round(i*127);default:throw new Error("Invalid component type.")}}var Js={DEG2RAD:Ro,RAD2DEG:Co,generateUUID:Di,clamp:mt,euclideanModulo:E0,mapLinear:fS,inverseLerp:pS,lerp:wl,damp:mS,pingpong:gS,smoothstep:xS,smootherstep:yS,randInt:vS,randFloat:_S,randFloatSpread:bS,seededRandom:MS,degToRad:ES,radToDeg:SS,isPowerOfTwo:TS,ceilPowerOfTwo:AS,floorPowerOfTwo:wS,setQuaternionFromProperEuler:RS,normalize:Mt,denormalize:ri},Me=class i{constructor(e=0,t=0){i.prototype.isVector2=!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("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("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){let t=this.x,n=this.y,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6],this.y=r[1]*t+r[4]*n+r[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=mt(this.x,e.x,t.x),this.y=mt(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=mt(this.x,e,t),this.y=mt(this.y,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(mt(n,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){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(mt(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y;return t*t+n*n}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,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,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){let n=Math.cos(t),r=Math.sin(t),s=this.x-e.x,o=this.y-e.y;return this.x=s*n-o*r+e.x,this.y=s*r+o*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},xt=class i{constructor(e,t,n,r,s,o,a,c,l){i.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,r,s,o,a,c,l)}set(e,t,n,r,s,o,a,c,l){let u=this.elements;return u[0]=e,u[1]=r,u[2]=a,u[3]=t,u[4]=s,u[5]=c,u[6]=n,u[7]=o,u[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){let 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){let n=e.elements,r=t.elements,s=this.elements,o=n[0],a=n[3],c=n[6],l=n[1],u=n[4],h=n[7],d=n[2],m=n[5],g=n[8],x=r[0],f=r[3],p=r[6],v=r[1],_=r[4],y=r[7],b=r[2],E=r[5],A=r[8];return s[0]=o*x+a*v+c*b,s[3]=o*f+a*_+c*E,s[6]=o*p+a*y+c*A,s[1]=l*x+u*v+h*b,s[4]=l*f+u*_+h*E,s[7]=l*p+u*y+h*A,s[2]=d*x+m*v+g*b,s[5]=d*f+m*_+g*E,s[8]=d*p+m*y+g*A,this}multiplyScalar(e){let 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(){let e=this.elements,t=e[0],n=e[1],r=e[2],s=e[3],o=e[4],a=e[5],c=e[6],l=e[7],u=e[8];return t*o*u-t*a*l-n*s*u+n*a*c+r*s*l-r*o*c}invert(){let e=this.elements,t=e[0],n=e[1],r=e[2],s=e[3],o=e[4],a=e[5],c=e[6],l=e[7],u=e[8],h=u*o-a*l,d=a*c-u*s,m=l*s-o*c,g=t*h+n*d+r*m;if(g===0)return this.set(0,0,0,0,0,0,0,0,0);let x=1/g;return e[0]=h*x,e[1]=(r*l-u*n)*x,e[2]=(a*n-r*o)*x,e[3]=d*x,e[4]=(u*t-r*c)*x,e[5]=(r*s-a*t)*x,e[6]=m*x,e[7]=(n*c-l*t)*x,e[8]=(o*t-n*s)*x,this}transpose(){let e,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){let 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,n,r,s,o,a){let c=Math.cos(s),l=Math.sin(s);return this.set(n*c,n*l,-n*(c*o+l*a)+o+e,-r*l,r*c,-r*(-l*o+c*a)+a+t,0,0,1),this}scale(e,t){return this.premultiply(Jm.makeScale(e,t)),this}rotate(e){return this.premultiply(Jm.makeRotation(-e)),this}translate(e,t){return this.premultiply(Jm.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){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){let t=this.elements,n=e.elements;for(let r=0;r<9;r++)if(t[r]!==n[r])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}},Jm=new xt;function S0(i){for(let e=i.length-1;e>=0;--e)if(i[e]>=65535)return!0;return!1}var CS={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};function Xa(i,e){return new CS[i](e)}function Qa(i){return document.createElementNS("http://www.w3.org/1999/xhtml",i)}function T0(){let i=Qa("canvas");return i.style.display="block",i}var dv={};function Jo(i){i in dv||(dv[i]=!0,console.warn(i))}function Z_(i,e,t){return new Promise(function(n,r){function s(){switch(i.clientWaitSync(e,i.SYNC_FLUSH_COMMANDS_BIT,0)){case i.WAIT_FAILED:r();break;case i.TIMEOUT_EXPIRED:setTimeout(s,t);break;default:n()}}setTimeout(s,t)})}function J_(i){let e=i.elements;e[2]=.5*e[2]+.5*e[3],e[6]=.5*e[6]+.5*e[7],e[10]=.5*e[10]+.5*e[11],e[14]=.5*e[14]+.5*e[15]}function Q_(i){let e=i.elements;e[11]===-1?(e[10]=-e[10]-1,e[14]=-e[14]):(e[10]=-e[10],e[14]=-e[14]+1)}var fv=new xt().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),pv=new xt().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function PS(){let i={enabled:!0,workingColorSpace:On,spaces:{},convert:function(r,s,o){return this.enabled===!1||s===o||!s||!o||(this.spaces[s].transfer===kt&&(r.r=Qr(r.r),r.g=Qr(r.g),r.b=Qr(r.b)),this.spaces[s].primaries!==this.spaces[o].primaries&&(r.applyMatrix3(this.spaces[s].toXYZ),r.applyMatrix3(this.spaces[o].fromXYZ)),this.spaces[o].transfer===kt&&(r.r=ja(r.r),r.g=ja(r.g),r.b=ja(r.b))),r},fromWorkingColorSpace:function(r,s){return this.convert(r,this.workingColorSpace,s)},toWorkingColorSpace:function(r,s){return this.convert(r,s,this.workingColorSpace)},getPrimaries:function(r){return this.spaces[r].primaries},getTransfer:function(r){return r===Dr?Ka:this.spaces[r].transfer},getLuminanceCoefficients:function(r,s=this.workingColorSpace){return r.fromArray(this.spaces[s].luminanceCoefficients)},define:function(r){Object.assign(this.spaces,r)},_getMatrix:function(r,s,o){return r.copy(this.spaces[s].toXYZ).multiply(this.spaces[o].fromXYZ)},_getDrawingBufferColorSpace:function(r){return this.spaces[r].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(r=this.workingColorSpace){return this.spaces[r].workingColorSpaceConfig.unpackColorSpace}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],n=[.3127,.329];return i.define({[On]:{primaries:e,whitePoint:n,transfer:Ka,toXYZ:fv,fromXYZ:pv,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:wt},outputColorSpaceConfig:{drawingBufferColorSpace:wt}},[wt]:{primaries:e,whitePoint:n,transfer:kt,toXYZ:fv,fromXYZ:pv,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:wt}}}),i}var _t=PS();function Qr(i){return i<.04045?i*.0773993808:Math.pow(i*.9478672986+.0521327014,2.4)}function ja(i){return i<.0031308?i*12.92:1.055*Math.pow(i,.41666)-.055}var Ra,Nl=class{static getDataURL(e){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let t;if(e instanceof HTMLCanvasElement)t=e;else{Ra===void 0&&(Ra=Qa("canvas")),Ra.width=e.width,Ra.height=e.height;let n=Ra.getContext("2d");e instanceof ImageData?n.putImageData(e,0,0):n.drawImage(e,0,0,e.width,e.height),t=Ra}return t.width>2048||t.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",e),t.toDataURL("image/jpeg",.6)):t.toDataURL("image/png")}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){let t=Qa("canvas");t.width=e.width,t.height=e.height;let n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);let r=n.getImageData(0,0,e.width,e.height),s=r.data;for(let o=0;o<s.length;o++)s[o]=Qr(s[o]/255)*255;return n.putImageData(r,0,0),t}else if(e.data){let t=e.data.slice(0);for(let n=0;n<t.length;n++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[n]=Math.floor(Qr(t[n]/255)*255):t[n]=Qr(t[n]);return{data:t,width:e.width,height:e.height}}else return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}},IS=0,_r=class{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:IS++}),this.uuid=Di(),this.data=e,this.dataReady=!0,this.version=0}set needsUpdate(e){e===!0&&this.version++}toJSON(e){let t=e===void 0||typeof e=="string";if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];let n={uuid:this.uuid,url:""},r=this.data;if(r!==null){let s;if(Array.isArray(r)){s=[];for(let o=0,a=r.length;o<a;o++)r[o].isDataTexture?s.push(Qm(r[o].image)):s.push(Qm(r[o]))}else s=Qm(r);n.url=s}return t||(e.images[this.uuid]=n),n}};function Qm(i){return typeof HTMLImageElement<"u"&&i instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&i instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&i instanceof ImageBitmap?Nl.getDataURL(i):i.data?{data:Array.from(i.data),width:i.width,height:i.height,type:i.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}var NS=0,Qt=class i extends ki{constructor(e=i.DEFAULT_IMAGE,t=i.DEFAULT_MAPPING,n=Mn,r=Mn,s=nn,o=Ei,a=Ln,c=ci,l=i.DEFAULT_ANISOTROPY,u=Dr){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:NS++}),this.uuid=Di(),this.name="",this.source=new _r(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=n,this.wrapT=r,this.magFilter=s,this.minFilter=o,this.anisotropy=l,this.format=a,this.internalFormat=null,this.type=c,this.offset=new Me(0,0),this.repeat=new Me(1,1),this.center=new Me(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new xt,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=u,this.userData={},this.version=0,this.onUpdate=null,this.isRenderTargetTexture=!1,this.pmremVersion=0}get image(){return this.source.data}set image(e=null){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)}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.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.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}toJSON(e){let t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];let n={metadata:{version:4.6,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,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&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==Bu)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case gn:e.x=e.x-Math.floor(e.x);break;case Mn:e.x=e.x<0?0:1;break;case ks: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 gn:e.y=e.y-Math.floor(e.y);break;case Mn:e.y=e.y<0?0:1;break;case ks: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++}};Qt.DEFAULT_IMAGE=null;Qt.DEFAULT_MAPPING=Bu;Qt.DEFAULT_ANISOTROPY=1;var It=class i{constructor(e=0,t=0,n=0,r=1){i.prototype.isVector4=!0,this.x=e,this.y=t,this.z=n,this.w=r}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,n,r){return this.x=e,this.y=t,this.z=n,this.w=r,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("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("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){let t=this.x,n=this.y,r=this.z,s=this.w,o=e.elements;return this.x=o[0]*t+o[4]*n+o[8]*r+o[12]*s,this.y=o[1]*t+o[5]*n+o[9]*r+o[13]*s,this.z=o[2]*t+o[6]*n+o[10]*r+o[14]*s,this.w=o[3]*t+o[7]*n+o[11]*r+o[15]*s,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);let 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,n,r,s,c=e.elements,l=c[0],u=c[4],h=c[8],d=c[1],m=c[5],g=c[9],x=c[2],f=c[6],p=c[10];if(Math.abs(u-d)<.01&&Math.abs(h-x)<.01&&Math.abs(g-f)<.01){if(Math.abs(u+d)<.1&&Math.abs(h+x)<.1&&Math.abs(g+f)<.1&&Math.abs(l+m+p-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;let _=(l+1)/2,y=(m+1)/2,b=(p+1)/2,E=(u+d)/4,A=(h+x)/4,T=(g+f)/4;return _>y&&_>b?_<.01?(n=0,r=.707106781,s=.707106781):(n=Math.sqrt(_),r=E/n,s=A/n):y>b?y<.01?(n=.707106781,r=0,s=.707106781):(r=Math.sqrt(y),n=E/r,s=T/r):b<.01?(n=.707106781,r=.707106781,s=0):(s=Math.sqrt(b),n=A/s,r=T/s),this.set(n,r,s,t),this}let v=Math.sqrt((f-g)*(f-g)+(h-x)*(h-x)+(d-u)*(d-u));return Math.abs(v)<.001&&(v=1),this.x=(f-g)/v,this.y=(h-x)/v,this.z=(d-u)/v,this.w=Math.acos((l+m+p-1)/2),this}setFromMatrixPosition(e){let 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=mt(this.x,e.x,t.x),this.y=mt(this.y,e.y,t.y),this.z=mt(this.z,e.z,t.z),this.w=mt(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=mt(this.x,e,t),this.y=mt(this.y,e,t),this.z=mt(this.z,e,t),this.w=mt(this.w,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(mt(n,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,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,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}},Ll=class extends ki{constructor(e=1,t=1,n={}){super(),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=1,this.scissor=new It(0,0,e,t),this.scissorTest=!1,this.viewport=new It(0,0,e,t);let r={width:e,height:t,depth:1};n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:nn,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1},n);let s=new Qt(r,n.mapping,n.wrapS,n.wrapT,n.magFilter,n.minFilter,n.format,n.type,n.anisotropy,n.colorSpace);s.flipY=!1,s.generateMipmaps=n.generateMipmaps,s.internalFormat=n.internalFormat,this.textures=[];let o=n.count;for(let a=0;a<o;a++)this.textures[a]=s.clone(),this.textures[a].isRenderTargetTexture=!0;this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this.depthTexture=n.depthTexture,this.samples=n.samples}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}setSize(e,t,n=1){if(this.width!==e||this.height!==t||this.depth!==n){this.width=e,this.height=t,this.depth=n;for(let r=0,s=this.textures.length;r<s;r++)this.textures[r].image.width=e,this.textures[r].image.height=t,this.textures[r].image.depth=n;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 n=0,r=e.textures.length;n<r;n++)this.textures[n]=e.textures[n].clone(),this.textures[n].isRenderTargetTexture=!0;let t=Object.assign({},e.texture.image);return this.texture.source=new _r(t),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}dispose(){this.dispatchEvent({type:"dispose"})}},on=class extends Ll{constructor(e=1,t=1,n={}){super(e,t,n),this.isWebGLRenderTarget=!0}},Po=class extends Qt{constructor(e=null,t=1,n=1,r=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:r},this.magFilter=Jt,this.minFilter=Jt,this.wrapR=Mn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}},cf=class extends on{constructor(e=1,t=1,n=1,r={}){super(e,t,r),this.isWebGLArrayRenderTarget=!0,this.depth=n,this.texture=new Po(null,e,t,n),this.texture.isRenderTargetTexture=!0}},$a=class extends Qt{constructor(e=null,t=1,n=1,r=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:n,depth:r},this.magFilter=Jt,this.minFilter=Jt,this.wrapR=Mn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},lf=class extends on{constructor(e=1,t=1,n=1,r={}){super(e,t,r),this.isWebGL3DRenderTarget=!0,this.depth=n,this.texture=new $a(null,e,t,n),this.texture.isRenderTargetTexture=!0}},Zt=class{constructor(e=0,t=0,n=0,r=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=r}static slerpFlat(e,t,n,r,s,o,a){let c=n[r+0],l=n[r+1],u=n[r+2],h=n[r+3],d=s[o+0],m=s[o+1],g=s[o+2],x=s[o+3];if(a===0){e[t+0]=c,e[t+1]=l,e[t+2]=u,e[t+3]=h;return}if(a===1){e[t+0]=d,e[t+1]=m,e[t+2]=g,e[t+3]=x;return}if(h!==x||c!==d||l!==m||u!==g){let f=1-a,p=c*d+l*m+u*g+h*x,v=p>=0?1:-1,_=1-p*p;if(_>Number.EPSILON){let b=Math.sqrt(_),E=Math.atan2(b,p*v);f=Math.sin(f*E)/b,a=Math.sin(a*E)/b}let y=a*v;if(c=c*f+d*y,l=l*f+m*y,u=u*f+g*y,h=h*f+x*y,f===1-a){let b=1/Math.sqrt(c*c+l*l+u*u+h*h);c*=b,l*=b,u*=b,h*=b}}e[t]=c,e[t+1]=l,e[t+2]=u,e[t+3]=h}static multiplyQuaternionsFlat(e,t,n,r,s,o){let a=n[r],c=n[r+1],l=n[r+2],u=n[r+3],h=s[o],d=s[o+1],m=s[o+2],g=s[o+3];return e[t]=a*g+u*h+c*m-l*d,e[t+1]=c*g+u*d+l*h-a*m,e[t+2]=l*g+u*m+a*d-c*h,e[t+3]=u*g-a*h-c*d-l*m,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,n,r){return this._x=e,this._y=t,this._z=n,this._w=r,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){let n=e._x,r=e._y,s=e._z,o=e._order,a=Math.cos,c=Math.sin,l=a(n/2),u=a(r/2),h=a(s/2),d=c(n/2),m=c(r/2),g=c(s/2);switch(o){case"XYZ":this._x=d*u*h+l*m*g,this._y=l*m*h-d*u*g,this._z=l*u*g+d*m*h,this._w=l*u*h-d*m*g;break;case"YXZ":this._x=d*u*h+l*m*g,this._y=l*m*h-d*u*g,this._z=l*u*g-d*m*h,this._w=l*u*h+d*m*g;break;case"ZXY":this._x=d*u*h-l*m*g,this._y=l*m*h+d*u*g,this._z=l*u*g+d*m*h,this._w=l*u*h-d*m*g;break;case"ZYX":this._x=d*u*h-l*m*g,this._y=l*m*h+d*u*g,this._z=l*u*g-d*m*h,this._w=l*u*h+d*m*g;break;case"YZX":this._x=d*u*h+l*m*g,this._y=l*m*h+d*u*g,this._z=l*u*g-d*m*h,this._w=l*u*h-d*m*g;break;case"XZY":this._x=d*u*h-l*m*g,this._y=l*m*h-d*u*g,this._z=l*u*g+d*m*h,this._w=l*u*h+d*m*g;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+o)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){let n=t/2,r=Math.sin(n);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){let t=e.elements,n=t[0],r=t[4],s=t[8],o=t[1],a=t[5],c=t[9],l=t[2],u=t[6],h=t[10],d=n+a+h;if(d>0){let m=.5/Math.sqrt(d+1);this._w=.25/m,this._x=(u-c)*m,this._y=(s-l)*m,this._z=(o-r)*m}else if(n>a&&n>h){let m=2*Math.sqrt(1+n-a-h);this._w=(u-c)/m,this._x=.25*m,this._y=(r+o)/m,this._z=(s+l)/m}else if(a>h){let m=2*Math.sqrt(1+a-n-h);this._w=(s-l)/m,this._x=(r+o)/m,this._y=.25*m,this._z=(c+u)/m}else{let m=2*Math.sqrt(1+h-n-a);this._w=(o-r)/m,this._x=(s+l)/m,this._y=(c+u)/m,this._z=.25*m}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<Number.EPSILON?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(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=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(mt(this.dot(e),-1,1)))}rotateTowards(e,t){let n=this.angleTo(e);if(n===0)return this;let r=Math.min(1,t/n);return this.slerp(e,r),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){let n=e._x,r=e._y,s=e._z,o=e._w,a=t._x,c=t._y,l=t._z,u=t._w;return this._x=n*u+o*a+r*l-s*c,this._y=r*u+o*c+s*a-n*l,this._z=s*u+o*l+n*c-r*a,this._w=o*u-n*a-r*c-s*l,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);let n=this._x,r=this._y,s=this._z,o=this._w,a=o*e._w+n*e._x+r*e._y+s*e._z;if(a<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,a=-a):this.copy(e),a>=1)return this._w=o,this._x=n,this._y=r,this._z=s,this;let c=1-a*a;if(c<=Number.EPSILON){let m=1-t;return this._w=m*o+t*this._w,this._x=m*n+t*this._x,this._y=m*r+t*this._y,this._z=m*s+t*this._z,this.normalize(),this}let l=Math.sqrt(c),u=Math.atan2(l,a),h=Math.sin((1-t)*u)/l,d=Math.sin(t*u)/l;return this._w=o*h+this._w*d,this._x=n*h+this._x*d,this._y=r*h+this._y*d,this._z=s*h+this._z*d,this._onChangeCallback(),this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){let e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),r=Math.sqrt(1-n),s=Math.sqrt(n);return this.set(r*Math.sin(e),r*Math.cos(e),s*Math.sin(t),s*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}},z=class i{constructor(e=0,t=0,n=0){i.prototype.isVector3=!0,this.x=e,this.y=t,this.z=n}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,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("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("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(mv.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(mv.setFromAxisAngle(e,t))}applyMatrix3(e){let t=this.x,n=this.y,r=this.z,s=e.elements;return this.x=s[0]*t+s[3]*n+s[6]*r,this.y=s[1]*t+s[4]*n+s[7]*r,this.z=s[2]*t+s[5]*n+s[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let t=this.x,n=this.y,r=this.z,s=e.elements,o=1/(s[3]*t+s[7]*n+s[11]*r+s[15]);return this.x=(s[0]*t+s[4]*n+s[8]*r+s[12])*o,this.y=(s[1]*t+s[5]*n+s[9]*r+s[13])*o,this.z=(s[2]*t+s[6]*n+s[10]*r+s[14])*o,this}applyQuaternion(e){let t=this.x,n=this.y,r=this.z,s=e.x,o=e.y,a=e.z,c=e.w,l=2*(o*r-a*n),u=2*(a*t-s*r),h=2*(s*n-o*t);return this.x=t+c*l+o*h-a*u,this.y=n+c*u+a*l-s*h,this.z=r+c*h+s*u-o*l,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){let t=this.x,n=this.y,r=this.z,s=e.elements;return this.x=s[0]*t+s[4]*n+s[8]*r,this.y=s[1]*t+s[5]*n+s[9]*r,this.z=s[2]*t+s[6]*n+s[10]*r,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=mt(this.x,e.x,t.x),this.y=mt(this.y,e.y,t.y),this.z=mt(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=mt(this.x,e,t),this.y=mt(this.y,e,t),this.z=mt(this.z,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(mt(n,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,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){let n=e.x,r=e.y,s=e.z,o=t.x,a=t.y,c=t.z;return this.x=r*c-s*a,this.y=s*o-n*c,this.z=n*a-r*o,this}projectOnVector(e){let t=e.lengthSq();if(t===0)return this.set(0,0,0);let n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return $m.copy(this).projectOnVector(e),this.sub($m)}reflect(e){return this.sub($m.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(mt(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y,r=this.z-e.z;return t*t+n*n+r*r}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,n){let r=Math.sin(t)*e;return this.x=r*Math.sin(n),this.y=Math.cos(t)*e,this.z=r*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){let t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=r,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(){let e=Math.random()*Math.PI*2,t=Math.random()*2-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}},$m=new z,mv=new Zt,zt=class{constructor(e=new z(1/0,1/0,1/0),t=new z(-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,n=e.length;t<n;t+=3)this.expandByPoint(Qi.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(Qi.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){let n=Qi.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),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);let n=e.geometry;if(n!==void 0){let s=n.getAttribute("position");if(t===!0&&s!==void 0&&e.isInstancedMesh!==!0)for(let o=0,a=s.count;o<a;o++)e.isMesh===!0?e.getVertexPosition(o,Qi):Qi.fromBufferAttribute(s,o),Qi.applyMatrix4(e.matrixWorld),this.expandByPoint(Qi);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),xd.copy(e.boundingBox)):(n.boundingBox===null&&n.computeBoundingBox(),xd.copy(n.boundingBox)),xd.applyMatrix4(e.matrixWorld),this.union(xd)}let r=e.children;for(let s=0,o=r.length;s<o;s++)this.expandByObject(r[s],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,Qi),Qi.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(fl),yd.subVectors(this.max,fl),Ca.subVectors(e.a,fl),Pa.subVectors(e.b,fl),Ia.subVectors(e.c,fl),Ts.subVectors(Pa,Ca),As.subVectors(Ia,Pa),go.subVectors(Ca,Ia);let t=[0,-Ts.z,Ts.y,0,-As.z,As.y,0,-go.z,go.y,Ts.z,0,-Ts.x,As.z,0,-As.x,go.z,0,-go.x,-Ts.y,Ts.x,0,-As.y,As.x,0,-go.y,go.x,0];return!eg(t,Ca,Pa,Ia,yd)||(t=[1,0,0,0,1,0,0,0,1],!eg(t,Ca,Pa,Ia,yd))?!1:(vd.crossVectors(Ts,As),t=[vd.x,vd.y,vd.z],eg(t,Ca,Pa,Ia,yd))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Qi).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Qi).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:(Xr[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Xr[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Xr[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Xr[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Xr[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Xr[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Xr[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Xr[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Xr),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)}},Xr=[new z,new z,new z,new z,new z,new z,new z,new z],Qi=new z,xd=new zt,Ca=new z,Pa=new z,Ia=new z,Ts=new z,As=new z,go=new z,fl=new z,yd=new z,vd=new z,xo=new z;function eg(i,e,t,n,r){for(let s=0,o=i.length-3;s<=o;s+=3){xo.fromArray(i,s);let a=r.x*Math.abs(xo.x)+r.y*Math.abs(xo.y)+r.z*Math.abs(xo.z),c=e.dot(xo),l=t.dot(xo),u=n.dot(xo);if(Math.max(-Math.max(c,l,u),Math.min(c,l,u))>a)return!1}return!0}var LS=new zt,pl=new z,tg=new z,qt=class{constructor(e=new z,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){let n=this.center;t!==void 0?n.copy(t):LS.setFromPoints(e).getCenter(n);let r=0;for(let s=0,o=e.length;s<o;s++)r=Math.max(r,n.distanceToSquared(e[s]));return this.radius=Math.sqrt(r),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){let 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){let n=this.center.distanceToSquared(e);return t.copy(e),n>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;pl.subVectors(e,this.center);let t=pl.lengthSq();if(t>this.radius*this.radius){let n=Math.sqrt(t),r=(n-this.radius)*.5;this.center.addScaledVector(pl,r/n),this.radius+=r}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):(tg.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(pl.copy(e.center).add(tg)),this.expandByPoint(pl.copy(e.center).sub(tg))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}},Yr=new z,ng=new z,_d=new z,ws=new z,ig=new z,bd=new z,rg=new z,nr=class{constructor(e=new z,t=new z(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,Yr)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);let n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){let t=Yr.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Yr.copy(this.origin).addScaledVector(this.direction,t),Yr.distanceToSquared(e))}distanceSqToSegment(e,t,n,r){ng.copy(e).add(t).multiplyScalar(.5),_d.copy(t).sub(e).normalize(),ws.copy(this.origin).sub(ng);let s=e.distanceTo(t)*.5,o=-this.direction.dot(_d),a=ws.dot(this.direction),c=-ws.dot(_d),l=ws.lengthSq(),u=Math.abs(1-o*o),h,d,m,g;if(u>0)if(h=o*c-a,d=o*a-c,g=s*u,h>=0)if(d>=-g)if(d<=g){let x=1/u;h*=x,d*=x,m=h*(h+o*d+2*a)+d*(o*h+d+2*c)+l}else d=s,h=Math.max(0,-(o*d+a)),m=-h*h+d*(d+2*c)+l;else d=-s,h=Math.max(0,-(o*d+a)),m=-h*h+d*(d+2*c)+l;else d<=-g?(h=Math.max(0,-(-o*s+a)),d=h>0?-s:Math.min(Math.max(-s,-c),s),m=-h*h+d*(d+2*c)+l):d<=g?(h=0,d=Math.min(Math.max(-s,-c),s),m=d*(d+2*c)+l):(h=Math.max(0,-(o*s+a)),d=h>0?s:Math.min(Math.max(-s,-c),s),m=-h*h+d*(d+2*c)+l);else d=o>0?-s:s,h=Math.max(0,-(o*d+a)),m=-h*h+d*(d+2*c)+l;return n&&n.copy(this.origin).addScaledVector(this.direction,h),r&&r.copy(ng).addScaledVector(_d,d),m}intersectSphere(e,t){Yr.subVectors(e.center,this.origin);let n=Yr.dot(this.direction),r=Yr.dot(Yr)-n*n,s=e.radius*e.radius;if(r>s)return null;let o=Math.sqrt(s-r),a=n-o,c=n+o;return c<0?null:a<0?this.at(c,t):this.at(a,t)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){let t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;let n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){let n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){let t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,r,s,o,a,c,l=1/this.direction.x,u=1/this.direction.y,h=1/this.direction.z,d=this.origin;return l>=0?(n=(e.min.x-d.x)*l,r=(e.max.x-d.x)*l):(n=(e.max.x-d.x)*l,r=(e.min.x-d.x)*l),u>=0?(s=(e.min.y-d.y)*u,o=(e.max.y-d.y)*u):(s=(e.max.y-d.y)*u,o=(e.min.y-d.y)*u),n>o||s>r||((s>n||isNaN(n))&&(n=s),(o<r||isNaN(r))&&(r=o),h>=0?(a=(e.min.z-d.z)*h,c=(e.max.z-d.z)*h):(a=(e.max.z-d.z)*h,c=(e.min.z-d.z)*h),n>c||a>r)||((a>n||n!==n)&&(n=a),(c<r||r!==r)&&(r=c),r<0)?null:this.at(n>=0?n:r,t)}intersectsBox(e){return this.intersectBox(e,Yr)!==null}intersectTriangle(e,t,n,r,s){ig.subVectors(t,e),bd.subVectors(n,e),rg.crossVectors(ig,bd);let o=this.direction.dot(rg),a;if(o>0){if(r)return null;a=1}else if(o<0)a=-1,o=-o;else return null;ws.subVectors(this.origin,e);let c=a*this.direction.dot(bd.crossVectors(ws,bd));if(c<0)return null;let l=a*this.direction.dot(ig.cross(ws));if(l<0||c+l>o)return null;let u=-a*ws.dot(rg);return u<0?null:this.at(u/o,s)}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)}},nt=class i{constructor(e,t,n,r,s,o,a,c,l,u,h,d,m,g,x,f){i.prototype.isMatrix4=!0,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,n,r,s,o,a,c,l,u,h,d,m,g,x,f)}set(e,t,n,r,s,o,a,c,l,u,h,d,m,g,x,f){let p=this.elements;return p[0]=e,p[4]=t,p[8]=n,p[12]=r,p[1]=s,p[5]=o,p[9]=a,p[13]=c,p[2]=l,p[6]=u,p[10]=h,p[14]=d,p[3]=m,p[7]=g,p[11]=x,p[15]=f,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 i().fromArray(this.elements)}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){let t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){let 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,n){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){let t=this.elements,n=e.elements,r=1/Na.setFromMatrixColumn(e,0).length(),s=1/Na.setFromMatrixColumn(e,1).length(),o=1/Na.setFromMatrixColumn(e,2).length();return t[0]=n[0]*r,t[1]=n[1]*r,t[2]=n[2]*r,t[3]=0,t[4]=n[4]*s,t[5]=n[5]*s,t[6]=n[6]*s,t[7]=0,t[8]=n[8]*o,t[9]=n[9]*o,t[10]=n[10]*o,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){let t=this.elements,n=e.x,r=e.y,s=e.z,o=Math.cos(n),a=Math.sin(n),c=Math.cos(r),l=Math.sin(r),u=Math.cos(s),h=Math.sin(s);if(e.order==="XYZ"){let d=o*u,m=o*h,g=a*u,x=a*h;t[0]=c*u,t[4]=-c*h,t[8]=l,t[1]=m+g*l,t[5]=d-x*l,t[9]=-a*c,t[2]=x-d*l,t[6]=g+m*l,t[10]=o*c}else if(e.order==="YXZ"){let d=c*u,m=c*h,g=l*u,x=l*h;t[0]=d+x*a,t[4]=g*a-m,t[8]=o*l,t[1]=o*h,t[5]=o*u,t[9]=-a,t[2]=m*a-g,t[6]=x+d*a,t[10]=o*c}else if(e.order==="ZXY"){let d=c*u,m=c*h,g=l*u,x=l*h;t[0]=d-x*a,t[4]=-o*h,t[8]=g+m*a,t[1]=m+g*a,t[5]=o*u,t[9]=x-d*a,t[2]=-o*l,t[6]=a,t[10]=o*c}else if(e.order==="ZYX"){let d=o*u,m=o*h,g=a*u,x=a*h;t[0]=c*u,t[4]=g*l-m,t[8]=d*l+x,t[1]=c*h,t[5]=x*l+d,t[9]=m*l-g,t[2]=-l,t[6]=a*c,t[10]=o*c}else if(e.order==="YZX"){let d=o*c,m=o*l,g=a*c,x=a*l;t[0]=c*u,t[4]=x-d*h,t[8]=g*h+m,t[1]=h,t[5]=o*u,t[9]=-a*u,t[2]=-l*u,t[6]=m*h+g,t[10]=d-x*h}else if(e.order==="XZY"){let d=o*c,m=o*l,g=a*c,x=a*l;t[0]=c*u,t[4]=-h,t[8]=l*u,t[1]=d*h+x,t[5]=o*u,t[9]=m*h-g,t[2]=g*h-m,t[6]=a*u,t[10]=x*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(OS,e,DS)}lookAt(e,t,n){let r=this.elements;return Ii.subVectors(e,t),Ii.lengthSq()===0&&(Ii.z=1),Ii.normalize(),Rs.crossVectors(n,Ii),Rs.lengthSq()===0&&(Math.abs(n.z)===1?Ii.x+=1e-4:Ii.z+=1e-4,Ii.normalize(),Rs.crossVectors(n,Ii)),Rs.normalize(),Md.crossVectors(Ii,Rs),r[0]=Rs.x,r[4]=Md.x,r[8]=Ii.x,r[1]=Rs.y,r[5]=Md.y,r[9]=Ii.y,r[2]=Rs.z,r[6]=Md.z,r[10]=Ii.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,r=t.elements,s=this.elements,o=n[0],a=n[4],c=n[8],l=n[12],u=n[1],h=n[5],d=n[9],m=n[13],g=n[2],x=n[6],f=n[10],p=n[14],v=n[3],_=n[7],y=n[11],b=n[15],E=r[0],A=r[4],T=r[8],M=r[12],S=r[1],C=r[5],N=r[9],I=r[13],L=r[2],q=r[6],K=r[10],B=r[14],j=r[3],J=r[7],se=r[11],ce=r[15];return s[0]=o*E+a*S+c*L+l*j,s[4]=o*A+a*C+c*q+l*J,s[8]=o*T+a*N+c*K+l*se,s[12]=o*M+a*I+c*B+l*ce,s[1]=u*E+h*S+d*L+m*j,s[5]=u*A+h*C+d*q+m*J,s[9]=u*T+h*N+d*K+m*se,s[13]=u*M+h*I+d*B+m*ce,s[2]=g*E+x*S+f*L+p*j,s[6]=g*A+x*C+f*q+p*J,s[10]=g*T+x*N+f*K+p*se,s[14]=g*M+x*I+f*B+p*ce,s[3]=v*E+_*S+y*L+b*j,s[7]=v*A+_*C+y*q+b*J,s[11]=v*T+_*N+y*K+b*se,s[15]=v*M+_*I+y*B+b*ce,this}multiplyScalar(e){let 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(){let e=this.elements,t=e[0],n=e[4],r=e[8],s=e[12],o=e[1],a=e[5],c=e[9],l=e[13],u=e[2],h=e[6],d=e[10],m=e[14],g=e[3],x=e[7],f=e[11],p=e[15];return g*(+s*c*h-r*l*h-s*a*d+n*l*d+r*a*m-n*c*m)+x*(+t*c*m-t*l*d+s*o*d-r*o*m+r*l*u-s*c*u)+f*(+t*l*h-t*a*m-s*o*h+n*o*m+s*a*u-n*l*u)+p*(-r*a*u-t*c*h+t*a*d+r*o*h-n*o*d+n*c*u)}transpose(){let e=this.elements,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,n){let r=this.elements;return e.isVector3?(r[12]=e.x,r[13]=e.y,r[14]=e.z):(r[12]=e,r[13]=t,r[14]=n),this}invert(){let e=this.elements,t=e[0],n=e[1],r=e[2],s=e[3],o=e[4],a=e[5],c=e[6],l=e[7],u=e[8],h=e[9],d=e[10],m=e[11],g=e[12],x=e[13],f=e[14],p=e[15],v=h*f*l-x*d*l+x*c*m-a*f*m-h*c*p+a*d*p,_=g*d*l-u*f*l-g*c*m+o*f*m+u*c*p-o*d*p,y=u*x*l-g*h*l+g*a*m-o*x*m-u*a*p+o*h*p,b=g*h*c-u*x*c-g*a*d+o*x*d+u*a*f-o*h*f,E=t*v+n*_+r*y+s*b;if(E===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let A=1/E;return e[0]=v*A,e[1]=(x*d*s-h*f*s-x*r*m+n*f*m+h*r*p-n*d*p)*A,e[2]=(a*f*s-x*c*s+x*r*l-n*f*l-a*r*p+n*c*p)*A,e[3]=(h*c*s-a*d*s-h*r*l+n*d*l+a*r*m-n*c*m)*A,e[4]=_*A,e[5]=(u*f*s-g*d*s+g*r*m-t*f*m-u*r*p+t*d*p)*A,e[6]=(g*c*s-o*f*s-g*r*l+t*f*l+o*r*p-t*c*p)*A,e[7]=(o*d*s-u*c*s+u*r*l-t*d*l-o*r*m+t*c*m)*A,e[8]=y*A,e[9]=(g*h*s-u*x*s-g*n*m+t*x*m+u*n*p-t*h*p)*A,e[10]=(o*x*s-g*a*s+g*n*l-t*x*l-o*n*p+t*a*p)*A,e[11]=(u*a*s-o*h*s-u*n*l+t*h*l+o*n*m-t*a*m)*A,e[12]=b*A,e[13]=(u*x*r-g*h*r+g*n*d-t*x*d-u*n*f+t*h*f)*A,e[14]=(g*a*r-o*x*r-g*n*c+t*x*c+o*n*f-t*a*f)*A,e[15]=(o*h*r-u*a*r+u*n*c-t*h*c-o*n*d+t*a*d)*A,this}scale(e){let t=this.elements,n=e.x,r=e.y,s=e.z;return t[0]*=n,t[4]*=r,t[8]*=s,t[1]*=n,t[5]*=r,t[9]*=s,t[2]*=n,t[6]*=r,t[10]*=s,t[3]*=n,t[7]*=r,t[11]*=s,this}getMaxScaleOnAxis(){let e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],r=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,r))}makeTranslation(e,t,n){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,n,0,0,0,1),this}makeRotationX(e){let t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){let n=Math.cos(t),r=Math.sin(t),s=1-n,o=e.x,a=e.y,c=e.z,l=s*o,u=s*a;return this.set(l*o+n,l*a-r*c,l*c+r*a,0,l*a+r*c,u*a+n,u*c-r*o,0,l*c-r*a,u*c+r*o,s*c*c+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,r,s,o){return this.set(1,n,s,0,e,1,o,0,t,r,1,0,0,0,0,1),this}compose(e,t,n){let r=this.elements,s=t._x,o=t._y,a=t._z,c=t._w,l=s+s,u=o+o,h=a+a,d=s*l,m=s*u,g=s*h,x=o*u,f=o*h,p=a*h,v=c*l,_=c*u,y=c*h,b=n.x,E=n.y,A=n.z;return r[0]=(1-(x+p))*b,r[1]=(m+y)*b,r[2]=(g-_)*b,r[3]=0,r[4]=(m-y)*E,r[5]=(1-(d+p))*E,r[6]=(f+v)*E,r[7]=0,r[8]=(g+_)*A,r[9]=(f-v)*A,r[10]=(1-(d+x))*A,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decompose(e,t,n){let r=this.elements,s=Na.set(r[0],r[1],r[2]).length(),o=Na.set(r[4],r[5],r[6]).length(),a=Na.set(r[8],r[9],r[10]).length();this.determinant()<0&&(s=-s),e.x=r[12],e.y=r[13],e.z=r[14],$i.copy(this);let l=1/s,u=1/o,h=1/a;return $i.elements[0]*=l,$i.elements[1]*=l,$i.elements[2]*=l,$i.elements[4]*=u,$i.elements[5]*=u,$i.elements[6]*=u,$i.elements[8]*=h,$i.elements[9]*=h,$i.elements[10]*=h,t.setFromRotationMatrix($i),n.x=s,n.y=o,n.z=a,this}makePerspective(e,t,n,r,s,o,a=tr){let c=this.elements,l=2*s/(t-e),u=2*s/(n-r),h=(t+e)/(t-e),d=(n+r)/(n-r),m,g;if(a===tr)m=-(o+s)/(o-s),g=-2*o*s/(o-s);else if(a===Ja)m=-o/(o-s),g=-o*s/(o-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+a);return c[0]=l,c[4]=0,c[8]=h,c[12]=0,c[1]=0,c[5]=u,c[9]=d,c[13]=0,c[2]=0,c[6]=0,c[10]=m,c[14]=g,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,t,n,r,s,o,a=tr){let c=this.elements,l=1/(t-e),u=1/(n-r),h=1/(o-s),d=(t+e)*l,m=(n+r)*u,g,x;if(a===tr)g=(o+s)*h,x=-2*h;else if(a===Ja)g=s*h,x=-1*h;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);return c[0]=2*l,c[4]=0,c[8]=0,c[12]=-d,c[1]=0,c[5]=2*u,c[9]=0,c[13]=-m,c[2]=0,c[6]=0,c[10]=x,c[14]=-g,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(e){let t=this.elements,n=e.elements;for(let r=0;r<16;r++)if(t[r]!==n[r])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}},Na=new z,$i=new nt,OS=new z(0,0,0),DS=new z(1,1,1),Rs=new z,Md=new z,Ii=new z,gv=new nt,xv=new Zt,yi=class i{constructor(e=0,t=0,n=0,r=i.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=r}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,n,r=this._order){return this._x=e,this._y=t,this._z=n,this._order=r,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,n=!0){let r=e.elements,s=r[0],o=r[4],a=r[8],c=r[1],l=r[5],u=r[9],h=r[2],d=r[6],m=r[10];switch(t){case"XYZ":this._y=Math.asin(mt(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-u,m),this._z=Math.atan2(-o,s)):(this._x=Math.atan2(d,l),this._z=0);break;case"YXZ":this._x=Math.asin(-mt(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(a,m),this._z=Math.atan2(c,l)):(this._y=Math.atan2(-h,s),this._z=0);break;case"ZXY":this._x=Math.asin(mt(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-h,m),this._z=Math.atan2(-o,l)):(this._y=0,this._z=Math.atan2(c,s));break;case"ZYX":this._y=Math.asin(-mt(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(d,m),this._z=Math.atan2(c,s)):(this._x=0,this._z=Math.atan2(-o,l));break;case"YZX":this._z=Math.asin(mt(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-u,l),this._y=Math.atan2(-h,s)):(this._x=0,this._y=Math.atan2(a,m));break;case"XZY":this._z=Math.asin(-mt(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(d,l),this._y=Math.atan2(a,s)):(this._x=Math.atan2(-u,m),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return gv.makeRotationFromQuaternion(e),this.setFromRotationMatrix(gv,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return xv.setFromEuler(this),this.setFromQuaternion(xv,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}};yi.DEFAULT_ORDER="XYZ";var Io=class{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}},FS=0,yv=new z,La=new Zt,jr=new nt,Ed=new z,ml=new z,US=new z,kS=new Zt,vv=new z(1,0,0),_v=new z(0,1,0),bv=new z(0,0,1),Mv={type:"added"},BS={type:"removed"},Oa={type:"childadded",child:null},sg={type:"childremoved",child:null},St=class i extends ki{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:FS++}),this.uuid=Di(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=i.DEFAULT_UP.clone();let e=new z,t=new yi,n=new Zt,r=new z(1,1,1);function s(){n.setFromEuler(t,!1)}function o(){t.setFromQuaternion(n,void 0,!1)}t._onChange(s),n._onChange(o),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:r},modelViewMatrix:{value:new nt},normalMatrix:{value:new xt}}),this.matrix=new nt,this.matrixWorld=new nt,this.matrixAutoUpdate=i.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=i.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new Io,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.userData={}}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 La.setFromAxisAngle(e,t),this.quaternion.multiply(La),this}rotateOnWorldAxis(e,t){return La.setFromAxisAngle(e,t),this.quaternion.premultiply(La),this}rotateX(e){return this.rotateOnAxis(vv,e)}rotateY(e){return this.rotateOnAxis(_v,e)}rotateZ(e){return this.rotateOnAxis(bv,e)}translateOnAxis(e,t){return yv.copy(e).applyQuaternion(this.quaternion),this.position.add(yv.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(vv,e)}translateY(e){return this.translateOnAxis(_v,e)}translateZ(e){return this.translateOnAxis(bv,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(jr.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?Ed.copy(e):Ed.set(e,t,n);let r=this.parent;this.updateWorldMatrix(!0,!1),ml.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?jr.lookAt(ml,Ed,this.up):jr.lookAt(Ed,ml,this.up),this.quaternion.setFromRotationMatrix(jr),r&&(jr.extractRotation(r.matrixWorld),La.setFromRotationMatrix(jr),this.quaternion.premultiply(La.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(console.error("THREE.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(Mv),Oa.child=e,this.dispatchEvent(Oa),Oa.child=null):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.remove(arguments[n]);return this}let t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(BS),sg.child=e,this.dispatchEvent(sg),sg.child=null),this}removeFromParent(){let e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),jr.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),jr.multiply(e.parent.matrixWorld)),e.applyMatrix4(jr),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(Mv),Oa.child=e,this.dispatchEvent(Oa),Oa.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 n=0,r=this.children.length;n<r;n++){let o=this.children[n].getObjectByProperty(e,t);if(o!==void 0)return o}}getObjectsByProperty(e,t,n=[]){this[e]===t&&n.push(this);let r=this.children;for(let s=0,o=r.length;s<o;s++)r[s].getObjectsByProperty(e,t,n);return n}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(ml,e,US),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(ml,kS,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);let t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);let t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);let t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].traverseVisible(e)}traverseAncestors(e){let t=this.parent;t!==null&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),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);let t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].updateMatrixWorld(e)}updateWorldMatrix(e,t){let n=this.parent;if(e===!0&&n!==null&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),t===!0){let r=this.children;for(let s=0,o=r.length;s<o;s++)r[s].updateWorldMatrix(!1,!0)}}toJSON(e){let t=e===void 0||typeof e=="string",n={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.6,type:"Object",generator:"Object3D.toJSON"});let r={};r.uuid=this.uuid,r.type=this.type,this.name!==""&&(r.name=this.name),this.castShadow===!0&&(r.castShadow=!0),this.receiveShadow===!0&&(r.receiveShadow=!0),this.visible===!1&&(r.visible=!1),this.frustumCulled===!1&&(r.frustumCulled=!1),this.renderOrder!==0&&(r.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(r.userData=this.userData),r.layers=this.layers.mask,r.matrix=this.matrix.toArray(),r.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(r.matrixAutoUpdate=!1),this.isInstancedMesh&&(r.type="InstancedMesh",r.count=this.count,r.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(r.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(r.type="BatchedMesh",r.perObjectFrustumCulled=this.perObjectFrustumCulled,r.sortObjects=this.sortObjects,r.drawRanges=this._drawRanges,r.reservedRanges=this._reservedRanges,r.visibility=this._visibility,r.active=this._active,r.bounds=this._bounds.map(a=>({boxInitialized:a.boxInitialized,boxMin:a.box.min.toArray(),boxMax:a.box.max.toArray(),sphereInitialized:a.sphereInitialized,sphereRadius:a.sphere.radius,sphereCenter:a.sphere.center.toArray()})),r.maxInstanceCount=this._maxInstanceCount,r.maxVertexCount=this._maxVertexCount,r.maxIndexCount=this._maxIndexCount,r.geometryInitialized=this._geometryInitialized,r.geometryCount=this._geometryCount,r.matricesTexture=this._matricesTexture.toJSON(e),this._colorsTexture!==null&&(r.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(r.boundingSphere={center:r.boundingSphere.center.toArray(),radius:r.boundingSphere.radius}),this.boundingBox!==null&&(r.boundingBox={min:r.boundingBox.min.toArray(),max:r.boundingBox.max.toArray()}));function s(a,c){return a[c.uuid]===void 0&&(a[c.uuid]=c.toJSON(e)),c.uuid}if(this.isScene)this.background&&(this.background.isColor?r.background=this.background.toJSON():this.background.isTexture&&(r.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(r.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.geometry=s(e.geometries,this.geometry);let a=this.geometry.parameters;if(a!==void 0&&a.shapes!==void 0){let c=a.shapes;if(Array.isArray(c))for(let l=0,u=c.length;l<u;l++){let h=c[l];s(e.shapes,h)}else s(e.shapes,c)}}if(this.isSkinnedMesh&&(r.bindMode=this.bindMode,r.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(s(e.skeletons,this.skeleton),r.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){let a=[];for(let c=0,l=this.material.length;c<l;c++)a.push(s(e.materials,this.material[c]));r.material=a}else r.material=s(e.materials,this.material);if(this.children.length>0){r.children=[];for(let a=0;a<this.children.length;a++)r.children.push(this.children[a].toJSON(e).object)}if(this.animations.length>0){r.animations=[];for(let a=0;a<this.animations.length;a++){let c=this.animations[a];r.animations.push(s(e.animations,c))}}if(t){let a=o(e.geometries),c=o(e.materials),l=o(e.textures),u=o(e.images),h=o(e.shapes),d=o(e.skeletons),m=o(e.animations),g=o(e.nodes);a.length>0&&(n.geometries=a),c.length>0&&(n.materials=c),l.length>0&&(n.textures=l),u.length>0&&(n.images=u),h.length>0&&(n.shapes=h),d.length>0&&(n.skeletons=d),m.length>0&&(n.animations=m),g.length>0&&(n.nodes=g)}return n.object=r,n;function o(a){let c=[];for(let l in a){let u=a[l];delete u.metadata,c.push(u)}return c}}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.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.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let n=0;n<e.children.length;n++){let r=e.children[n];this.add(r.clone())}return this}};St.DEFAULT_UP=new z(0,1,0);St.DEFAULT_MATRIX_AUTO_UPDATE=!0;St.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;var er=new z,qr=new z,og=new z,Kr=new z,Da=new z,Fa=new z,Ev=new z,ag=new z,cg=new z,lg=new z,ug=new It,hg=new It,dg=new It,Oi=class i{constructor(e=new z,t=new z,n=new z){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,r){r.subVectors(n,t),er.subVectors(e,t),r.cross(er);let s=r.lengthSq();return s>0?r.multiplyScalar(1/Math.sqrt(s)):r.set(0,0,0)}static getBarycoord(e,t,n,r,s){er.subVectors(r,t),qr.subVectors(n,t),og.subVectors(e,t);let o=er.dot(er),a=er.dot(qr),c=er.dot(og),l=qr.dot(qr),u=qr.dot(og),h=o*l-a*a;if(h===0)return s.set(0,0,0),null;let d=1/h,m=(l*c-a*u)*d,g=(o*u-a*c)*d;return s.set(1-m-g,g,m)}static containsPoint(e,t,n,r){return this.getBarycoord(e,t,n,r,Kr)===null?!1:Kr.x>=0&&Kr.y>=0&&Kr.x+Kr.y<=1}static getInterpolation(e,t,n,r,s,o,a,c){return this.getBarycoord(e,t,n,r,Kr)===null?(c.x=0,c.y=0,"z"in c&&(c.z=0),"w"in c&&(c.w=0),null):(c.setScalar(0),c.addScaledVector(s,Kr.x),c.addScaledVector(o,Kr.y),c.addScaledVector(a,Kr.z),c)}static getInterpolatedAttribute(e,t,n,r,s,o){return ug.setScalar(0),hg.setScalar(0),dg.setScalar(0),ug.fromBufferAttribute(e,t),hg.fromBufferAttribute(e,n),dg.fromBufferAttribute(e,r),o.setScalar(0),o.addScaledVector(ug,s.x),o.addScaledVector(hg,s.y),o.addScaledVector(dg,s.z),o}static isFrontFacing(e,t,n,r){return er.subVectors(n,t),qr.subVectors(e,t),er.cross(qr).dot(r)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,r){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[r]),this}setFromAttributeAndIndices(e,t,n,r){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,r),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 er.subVectors(this.c,this.b),qr.subVectors(this.a,this.b),er.cross(qr).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return i.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return i.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,r,s){return i.getInterpolation(e,this.a,this.b,this.c,t,n,r,s)}containsPoint(e){return i.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return i.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){let n=this.a,r=this.b,s=this.c,o,a;Da.subVectors(r,n),Fa.subVectors(s,n),ag.subVectors(e,n);let c=Da.dot(ag),l=Fa.dot(ag);if(c<=0&&l<=0)return t.copy(n);cg.subVectors(e,r);let u=Da.dot(cg),h=Fa.dot(cg);if(u>=0&&h<=u)return t.copy(r);let d=c*h-u*l;if(d<=0&&c>=0&&u<=0)return o=c/(c-u),t.copy(n).addScaledVector(Da,o);lg.subVectors(e,s);let m=Da.dot(lg),g=Fa.dot(lg);if(g>=0&&m<=g)return t.copy(s);let x=m*l-c*g;if(x<=0&&l>=0&&g<=0)return a=l/(l-g),t.copy(n).addScaledVector(Fa,a);let f=u*g-m*h;if(f<=0&&h-u>=0&&m-g>=0)return Ev.subVectors(s,r),a=(h-u)/(h-u+(m-g)),t.copy(r).addScaledVector(Ev,a);let p=1/(f+x+d);return o=x*p,a=d*p,t.copy(n).addScaledVector(Da,o).addScaledVector(Fa,a)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}},$_={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},Cs={h:0,s:0,l:0},Sd={h:0,s:0,l:0};function fg(i,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?i+(e-i)*6*t:t<1/2?e:t<2/3?i+(e-i)*6*(2/3-t):i}var Ue=class{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){let r=e;r&&r.isColor?this.copy(r):typeof r=="number"?this.setHex(r):typeof r=="string"&&this.setStyle(r)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=wt){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,_t.toWorkingColorSpace(this,t),this}setRGB(e,t,n,r=_t.workingColorSpace){return this.r=e,this.g=t,this.b=n,_t.toWorkingColorSpace(this,r),this}setHSL(e,t,n,r=_t.workingColorSpace){if(e=E0(e,1),t=mt(t,0,1),n=mt(n,0,1),t===0)this.r=this.g=this.b=n;else{let s=n<=.5?n*(1+t):n+t-n*t,o=2*n-s;this.r=fg(o,s,e+1/3),this.g=fg(o,s,e),this.b=fg(o,s,e-1/3)}return _t.toWorkingColorSpace(this,r),this}setStyle(e,t=wt){function n(s){s!==void 0&&parseFloat(s)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(e)){let s,o=r[1],a=r[2];switch(o){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(s[4]),this.setRGB(Math.min(255,parseInt(s[1],10))/255,Math.min(255,parseInt(s[2],10))/255,Math.min(255,parseInt(s[3],10))/255,t);if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(s[4]),this.setRGB(Math.min(100,parseInt(s[1],10))/100,Math.min(100,parseInt(s[2],10))/100,Math.min(100,parseInt(s[3],10))/100,t);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,t);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){let s=r[1],o=s.length;if(o===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,t);if(o===6)return this.setHex(parseInt(s,16),t);console.warn("THREE.Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=wt){let n=$_[e.toLowerCase()];return n!==void 0?this.setHex(n,t):console.warn("THREE.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=Qr(e.r),this.g=Qr(e.g),this.b=Qr(e.b),this}copyLinearToSRGB(e){return this.r=ja(e.r),this.g=ja(e.g),this.b=ja(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=wt){return _t.fromWorkingColorSpace(Kn.copy(this),e),Math.round(mt(Kn.r*255,0,255))*65536+Math.round(mt(Kn.g*255,0,255))*256+Math.round(mt(Kn.b*255,0,255))}getHexString(e=wt){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=_t.workingColorSpace){_t.fromWorkingColorSpace(Kn.copy(this),t);let n=Kn.r,r=Kn.g,s=Kn.b,o=Math.max(n,r,s),a=Math.min(n,r,s),c,l,u=(a+o)/2;if(a===o)c=0,l=0;else{let h=o-a;switch(l=u<=.5?h/(o+a):h/(2-o-a),o){case n:c=(r-s)/h+(r<s?6:0);break;case r:c=(s-n)/h+2;break;case s:c=(n-r)/h+4;break}c/=6}return e.h=c,e.s=l,e.l=u,e}getRGB(e,t=_t.workingColorSpace){return _t.fromWorkingColorSpace(Kn.copy(this),t),e.r=Kn.r,e.g=Kn.g,e.b=Kn.b,e}getStyle(e=wt){_t.fromWorkingColorSpace(Kn.copy(this),e);let t=Kn.r,n=Kn.g,r=Kn.b;return e!==wt?`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${r.toFixed(3)})`:`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(r*255)})`}offsetHSL(e,t,n){return this.getHSL(Cs),this.setHSL(Cs.h+e,Cs.s+t,Cs.l+n)}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,n){return this.r=e.r+(t.r-e.r)*n,this.g=e.g+(t.g-e.g)*n,this.b=e.b+(t.b-e.b)*n,this}lerpHSL(e,t){this.getHSL(Cs),e.getHSL(Sd);let n=wl(Cs.h,Sd.h,t),r=wl(Cs.s,Sd.s,t),s=wl(Cs.l,Sd.l,t);return this.setHSL(n,r,s),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){let t=this.r,n=this.g,r=this.b,s=e.elements;return this.r=s[0]*t+s[3]*n+s[6]*r,this.g=s[1]*t+s[4]*n+s[7]*r,this.b=s[2]*t+s[5]*n+s[8]*r,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}},Kn=new Ue;Ue.NAMES=$_;var zS=0,cn=class extends ki{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:zS++}),this.uuid=Di(),this.name="",this.type="Material",this.blending=Fs,this.side=Jn,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=Pl,this.blendDst=Il,this.blendEquation=xi,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Ue(0,0,0),this.blendAlpha=0,this.depthFunc=Us,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=af,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Ns,this.stencilZFail=Ns,this.stencilZPass=Ns,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.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(let t in e){let n=e[t];if(n===void 0){console.warn(`THREE.Material: parameter '${t}' has value of undefined.`);continue}let r=this[t];if(r===void 0){console.warn(`THREE.Material: '${t}' is not a property of THREE.${this.type}.`);continue}r&&r.isColor?r.set(n):r&&r.isVector3&&n&&n.isVector3?r.copy(n):this[t]=n}}toJSON(e){let t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});let n={metadata:{version:4.6,type:"Material",generator:"Material.toJSON"}};n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.dispersion!==void 0&&(n.dispersion=this.dispersion),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==Fs&&(n.blending=this.blending),this.side!==Jn&&(n.side=this.side),this.vertexColors===!0&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=!0),this.blendSrc!==Pl&&(n.blendSrc=this.blendSrc),this.blendDst!==Il&&(n.blendDst=this.blendDst),this.blendEquation!==xi&&(n.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(n.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(n.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(n.blendAlpha=this.blendAlpha),this.depthFunc!==Us&&(n.depthFunc=this.depthFunc),this.depthTest===!1&&(n.depthTest=this.depthTest),this.depthWrite===!1&&(n.depthWrite=this.depthWrite),this.colorWrite===!1&&(n.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(n.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==af&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Ns&&(n.stencilFail=this.stencilFail),this.stencilZFail!==Ns&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==Ns&&(n.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(n.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaHash===!0&&(n.alphaHash=!0),this.alphaToCoverage===!0&&(n.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=!0),this.forceSinglePass===!0&&(n.forceSinglePass=!0),this.wireframe===!0&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=!0),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData);function r(s){let o=[];for(let a in s){let c=s[a];delete c.metadata,o.push(c)}return o}if(t){let s=r(e.textures),o=r(e.images);s.length>0&&(n.textures=s),o.length>0&&(n.images=o)}return n}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;let t=e.clippingPlanes,n=null;if(t!==null){let r=t.length;n=new Array(r);for(let s=0;s!==r;++s)n[s]=t[s].clone()}return this.clippingPlanes=n,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.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++}onBuild(){console.warn("Material: onBuild() has been removed.")}},Ht=class extends cn{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Ue(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 yi,this.combine=vc,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}},Jr=VS();function VS(){let i=new ArrayBuffer(4),e=new Float32Array(i),t=new Uint32Array(i),n=new Uint32Array(512),r=new Uint32Array(512);for(let c=0;c<256;++c){let l=c-127;l<-27?(n[c]=0,n[c|256]=32768,r[c]=24,r[c|256]=24):l<-14?(n[c]=1024>>-l-14,n[c|256]=1024>>-l-14|32768,r[c]=-l-1,r[c|256]=-l-1):l<=15?(n[c]=l+15<<10,n[c|256]=l+15<<10|32768,r[c]=13,r[c|256]=13):l<128?(n[c]=31744,n[c|256]=64512,r[c]=24,r[c|256]=24):(n[c]=31744,n[c|256]=64512,r[c]=13,r[c|256]=13)}let s=new Uint32Array(2048),o=new Uint32Array(64),a=new Uint32Array(64);for(let c=1;c<1024;++c){let l=c<<13,u=0;for(;(l&8388608)===0;)l<<=1,u-=8388608;l&=-8388609,u+=947912704,s[c]=l|u}for(let c=1024;c<2048;++c)s[c]=939524096+(c-1024<<13);for(let c=1;c<31;++c)o[c]=c<<23;o[31]=1199570944,o[32]=2147483648;for(let c=33;c<63;++c)o[c]=2147483648+(c-32<<23);o[63]=3347054592;for(let c=1;c<64;++c)c!==32&&(a[c]=1024);return{floatView:e,uint32View:t,baseTable:n,shiftTable:r,mantissaTable:s,exponentTable:o,offsetTable:a}}function gi(i){Math.abs(i)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),i=mt(i,-65504,65504),Jr.floatView[0]=i;let e=Jr.uint32View[0],t=e>>23&511;return Jr.baseTable[t]+((e&8388607)>>Jr.shiftTable[t])}function Tl(i){let e=i>>10;return Jr.uint32View[0]=Jr.mantissaTable[Jr.offsetTable[e]+(i&1023)]+Jr.exponentTable[e],Jr.floatView[0]}var eb={toHalfFloat:gi,fromHalfFloat:Tl},bn=new z,Td=new Me,gt=class{constructor(e,t,n=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n,this.usage=Za,this.updateRanges=[],this.gpuType=si,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,n){e*=this.itemSize,n*=t.itemSize;for(let r=0,s=this.itemSize;r<s;r++)this.array[e+r]=t.array[n+r];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,n=this.count;t<n;t++)Td.fromBufferAttribute(this,t),Td.applyMatrix3(e),this.setXY(t,Td.x,Td.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)bn.fromBufferAttribute(this,t),bn.applyMatrix3(e),this.setXYZ(t,bn.x,bn.y,bn.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)bn.fromBufferAttribute(this,t),bn.applyMatrix4(e),this.setXYZ(t,bn.x,bn.y,bn.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)bn.fromBufferAttribute(this,t),bn.applyNormalMatrix(e),this.setXYZ(t,bn.x,bn.y,bn.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)bn.fromBufferAttribute(this,t),bn.transformDirection(e),this.setXYZ(t,bn.x,bn.y,bn.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let n=this.array[e*this.itemSize+t];return this.normalized&&(n=ri(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=Mt(n,this.array)),this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=ri(t,this.array)),t}setX(e,t){return this.normalized&&(t=Mt(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=ri(t,this.array)),t}setY(e,t){return this.normalized&&(t=Mt(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=ri(t,this.array)),t}setZ(e,t){return this.normalized&&(t=Mt(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=ri(t,this.array)),t}setW(e,t){return this.normalized&&(t=Mt(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=Mt(t,this.array),n=Mt(n,this.array)),this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,r){return e*=this.itemSize,this.normalized&&(t=Mt(t,this.array),n=Mt(n,this.array),r=Mt(r,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this}setXYZW(e,t,n,r,s){return e*=this.itemSize,this.normalized&&(t=Mt(t,this.array),n=Mt(n,this.array),r=Mt(r,this.array),s=Mt(s,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this.array[e+3]=s,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){let 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!==Za&&(e.usage=this.usage),e}},uf=class extends gt{constructor(e,t,n){super(new Int8Array(e),t,n)}},hf=class extends gt{constructor(e,t,n){super(new Uint8Array(e),t,n)}},df=class extends gt{constructor(e,t,n){super(new Uint8ClampedArray(e),t,n)}},ff=class extends gt{constructor(e,t,n){super(new Int16Array(e),t,n)}},ec=class extends gt{constructor(e,t,n){super(new Uint16Array(e),t,n)}},pf=class extends gt{constructor(e,t,n){super(new Int32Array(e),t,n)}},tc=class extends gt{constructor(e,t,n){super(new Uint32Array(e),t,n)}},mf=class extends gt{constructor(e,t,n){super(new Uint16Array(e),t,n),this.isFloat16BufferAttribute=!0}getX(e){let t=Tl(this.array[e*this.itemSize]);return this.normalized&&(t=ri(t,this.array)),t}setX(e,t){return this.normalized&&(t=Mt(t,this.array)),this.array[e*this.itemSize]=gi(t),this}getY(e){let t=Tl(this.array[e*this.itemSize+1]);return this.normalized&&(t=ri(t,this.array)),t}setY(e,t){return this.normalized&&(t=Mt(t,this.array)),this.array[e*this.itemSize+1]=gi(t),this}getZ(e){let t=Tl(this.array[e*this.itemSize+2]);return this.normalized&&(t=ri(t,this.array)),t}setZ(e,t){return this.normalized&&(t=Mt(t,this.array)),this.array[e*this.itemSize+2]=gi(t),this}getW(e){let t=Tl(this.array[e*this.itemSize+3]);return this.normalized&&(t=ri(t,this.array)),t}setW(e,t){return this.normalized&&(t=Mt(t,this.array)),this.array[e*this.itemSize+3]=gi(t),this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=Mt(t,this.array),n=Mt(n,this.array)),this.array[e+0]=gi(t),this.array[e+1]=gi(n),this}setXYZ(e,t,n,r){return e*=this.itemSize,this.normalized&&(t=Mt(t,this.array),n=Mt(n,this.array),r=Mt(r,this.array)),this.array[e+0]=gi(t),this.array[e+1]=gi(n),this.array[e+2]=gi(r),this}setXYZW(e,t,n,r,s){return e*=this.itemSize,this.normalized&&(t=Mt(t,this.array),n=Mt(n,this.array),r=Mt(r,this.array),s=Mt(s,this.array)),this.array[e+0]=gi(t),this.array[e+1]=gi(n),this.array[e+2]=gi(r),this.array[e+3]=gi(s),this}},ze=class extends gt{constructor(e,t,n){super(new Float32Array(e),t,n)}},HS=0,Wi=new nt,pg=new St,Ua=new z,Ni=new zt,gl=new zt,Nn=new z,ot=class i extends ki{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:HS++}),this.uuid=Di(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(S0(e)?tc:ec)(e,1):this.index=e,this}setIndirect(e){return this.indirect=e,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,n=0){this.groups.push({start:e,count:t,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){let t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);let n=this.attributes.normal;if(n!==void 0){let s=new xt().getNormalMatrix(e);n.applyNormalMatrix(s),n.needsUpdate=!0}let r=this.attributes.tangent;return r!==void 0&&(r.transformDirection(e),r.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return Wi.makeRotationFromQuaternion(e),this.applyMatrix4(Wi),this}rotateX(e){return Wi.makeRotationX(e),this.applyMatrix4(Wi),this}rotateY(e){return Wi.makeRotationY(e),this.applyMatrix4(Wi),this}rotateZ(e){return Wi.makeRotationZ(e),this.applyMatrix4(Wi),this}translate(e,t,n){return Wi.makeTranslation(e,t,n),this.applyMatrix4(Wi),this}scale(e,t,n){return Wi.makeScale(e,t,n),this.applyMatrix4(Wi),this}lookAt(e){return pg.lookAt(e),pg.updateMatrix(),this.applyMatrix4(pg.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Ua).negate(),this.translate(Ua.x,Ua.y,Ua.z),this}setFromPoints(e){let t=this.getAttribute("position");if(t===void 0){let n=[];for(let r=0,s=e.length;r<s;r++){let o=e[r];n.push(o.x,o.y,o.z||0)}this.setAttribute("position",new ze(n,3))}else{let n=Math.min(e.length,t.count);for(let r=0;r<n;r++){let s=e[r];t.setXYZ(r,s.x,s.y,s.z||0)}e.length>t.count&&console.warn("THREE.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 zt);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new z(-1/0,-1/0,-1/0),new z(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let n=0,r=t.length;n<r;n++){let s=t[n];Ni.setFromBufferAttribute(s),this.morphTargetsRelative?(Nn.addVectors(this.boundingBox.min,Ni.min),this.boundingBox.expandByPoint(Nn),Nn.addVectors(this.boundingBox.max,Ni.max),this.boundingBox.expandByPoint(Nn)):(this.boundingBox.expandByPoint(Ni.min),this.boundingBox.expandByPoint(Ni.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.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 qt);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new z,1/0);return}if(e){let n=this.boundingSphere.center;if(Ni.setFromBufferAttribute(e),t)for(let s=0,o=t.length;s<o;s++){let a=t[s];gl.setFromBufferAttribute(a),this.morphTargetsRelative?(Nn.addVectors(Ni.min,gl.min),Ni.expandByPoint(Nn),Nn.addVectors(Ni.max,gl.max),Ni.expandByPoint(Nn)):(Ni.expandByPoint(gl.min),Ni.expandByPoint(gl.max))}Ni.getCenter(n);let r=0;for(let s=0,o=e.count;s<o;s++)Nn.fromBufferAttribute(e,s),r=Math.max(r,n.distanceToSquared(Nn));if(t)for(let s=0,o=t.length;s<o;s++){let a=t[s],c=this.morphTargetsRelative;for(let l=0,u=a.count;l<u;l++)Nn.fromBufferAttribute(a,l),c&&(Ua.fromBufferAttribute(e,l),Nn.add(Ua)),r=Math.max(r,n.distanceToSquared(Nn))}this.boundingSphere.radius=Math.sqrt(r),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){let e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}let n=t.position,r=t.normal,s=t.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new gt(new Float32Array(4*n.count),4));let o=this.getAttribute("tangent"),a=[],c=[];for(let T=0;T<n.count;T++)a[T]=new z,c[T]=new z;let l=new z,u=new z,h=new z,d=new Me,m=new Me,g=new Me,x=new z,f=new z;function p(T,M,S){l.fromBufferAttribute(n,T),u.fromBufferAttribute(n,M),h.fromBufferAttribute(n,S),d.fromBufferAttribute(s,T),m.fromBufferAttribute(s,M),g.fromBufferAttribute(s,S),u.sub(l),h.sub(l),m.sub(d),g.sub(d);let C=1/(m.x*g.y-g.x*m.y);isFinite(C)&&(x.copy(u).multiplyScalar(g.y).addScaledVector(h,-m.y).multiplyScalar(C),f.copy(h).multiplyScalar(m.x).addScaledVector(u,-g.x).multiplyScalar(C),a[T].add(x),a[M].add(x),a[S].add(x),c[T].add(f),c[M].add(f),c[S].add(f))}let v=this.groups;v.length===0&&(v=[{start:0,count:e.count}]);for(let T=0,M=v.length;T<M;++T){let S=v[T],C=S.start,N=S.count;for(let I=C,L=C+N;I<L;I+=3)p(e.getX(I+0),e.getX(I+1),e.getX(I+2))}let _=new z,y=new z,b=new z,E=new z;function A(T){b.fromBufferAttribute(r,T),E.copy(b);let M=a[T];_.copy(M),_.sub(b.multiplyScalar(b.dot(M))).normalize(),y.crossVectors(E,M);let C=y.dot(c[T])<0?-1:1;o.setXYZW(T,_.x,_.y,_.z,C)}for(let T=0,M=v.length;T<M;++T){let S=v[T],C=S.start,N=S.count;for(let I=C,L=C+N;I<L;I+=3)A(e.getX(I+0)),A(e.getX(I+1)),A(e.getX(I+2))}}computeVertexNormals(){let e=this.index,t=this.getAttribute("position");if(t!==void 0){let n=this.getAttribute("normal");if(n===void 0)n=new gt(new Float32Array(t.count*3),3),this.setAttribute("normal",n);else for(let d=0,m=n.count;d<m;d++)n.setXYZ(d,0,0,0);let r=new z,s=new z,o=new z,a=new z,c=new z,l=new z,u=new z,h=new z;if(e)for(let d=0,m=e.count;d<m;d+=3){let g=e.getX(d+0),x=e.getX(d+1),f=e.getX(d+2);r.fromBufferAttribute(t,g),s.fromBufferAttribute(t,x),o.fromBufferAttribute(t,f),u.subVectors(o,s),h.subVectors(r,s),u.cross(h),a.fromBufferAttribute(n,g),c.fromBufferAttribute(n,x),l.fromBufferAttribute(n,f),a.add(u),c.add(u),l.add(u),n.setXYZ(g,a.x,a.y,a.z),n.setXYZ(x,c.x,c.y,c.z),n.setXYZ(f,l.x,l.y,l.z)}else for(let d=0,m=t.count;d<m;d+=3)r.fromBufferAttribute(t,d+0),s.fromBufferAttribute(t,d+1),o.fromBufferAttribute(t,d+2),u.subVectors(o,s),h.subVectors(r,s),u.cross(h),n.setXYZ(d+0,u.x,u.y,u.z),n.setXYZ(d+1,u.x,u.y,u.z),n.setXYZ(d+2,u.x,u.y,u.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){let e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)Nn.fromBufferAttribute(e,t),Nn.normalize(),e.setXYZ(t,Nn.x,Nn.y,Nn.z)}toNonIndexed(){function e(a,c){let l=a.array,u=a.itemSize,h=a.normalized,d=new l.constructor(c.length*u),m=0,g=0;for(let x=0,f=c.length;x<f;x++){a.isInterleavedBufferAttribute?m=c[x]*a.data.stride+a.offset:m=c[x]*u;for(let p=0;p<u;p++)d[g++]=l[m++]}return new gt(d,u,h)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;let t=new i,n=this.index.array,r=this.attributes;for(let a in r){let c=r[a],l=e(c,n);t.setAttribute(a,l)}let s=this.morphAttributes;for(let a in s){let c=[],l=s[a];for(let u=0,h=l.length;u<h;u++){let d=l[u],m=e(d,n);c.push(m)}t.morphAttributes[a]=c}t.morphTargetsRelative=this.morphTargetsRelative;let o=this.groups;for(let a=0,c=o.length;a<c;a++){let l=o[a];t.addGroup(l.start,l.count,l.materialIndex)}return t}toJSON(){let e={metadata:{version:4.6,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){let c=this.parameters;for(let l in c)c[l]!==void 0&&(e[l]=c[l]);return e}e.data={attributes:{}};let t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});let n=this.attributes;for(let c in n){let l=n[c];e.data.attributes[c]=l.toJSON(e.data)}let r={},s=!1;for(let c in this.morphAttributes){let l=this.morphAttributes[c],u=[];for(let h=0,d=l.length;h<d;h++){let m=l[h];u.push(m.toJSON(e.data))}u.length>0&&(r[c]=u,s=!0)}s&&(e.data.morphAttributes=r,e.data.morphTargetsRelative=this.morphTargetsRelative);let o=this.groups;o.length>0&&(e.data.groups=JSON.parse(JSON.stringify(o)));let a=this.boundingSphere;return a!==null&&(e.data.boundingSphere={center:a.center.toArray(),radius:a.radius}),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;let t={};this.name=e.name;let n=e.index;n!==null&&this.setIndex(n.clone(t));let r=e.attributes;for(let l in r){let u=r[l];this.setAttribute(l,u.clone(t))}let s=e.morphAttributes;for(let l in s){let u=[],h=s[l];for(let d=0,m=h.length;d<m;d++)u.push(h[d].clone(t));this.morphAttributes[l]=u}this.morphTargetsRelative=e.morphTargetsRelative;let o=e.groups;for(let l=0,u=o.length;l<u;l++){let h=o[l];this.addGroup(h.start,h.count,h.materialIndex)}let a=e.boundingBox;a!==null&&(this.boundingBox=a.clone());let c=e.boundingSphere;return c!==null&&(this.boundingSphere=c.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}},Sv=new nt,yo=new nr,Ad=new qt,Tv=new z,wd=new z,Rd=new z,Cd=new z,mg=new z,Pd=new z,Av=new z,Id=new z,ct=class extends St{constructor(e=new ot,t=new Ht){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,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(){let t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){let r=t[n[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=r.length;s<o;s++){let a=r[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=s}}}}getVertexPosition(e,t){let n=this.geometry,r=n.attributes.position,s=n.morphAttributes.position,o=n.morphTargetsRelative;t.fromBufferAttribute(r,e);let a=this.morphTargetInfluences;if(s&&a){Pd.set(0,0,0);for(let c=0,l=s.length;c<l;c++){let u=a[c],h=s[c];u!==0&&(mg.fromBufferAttribute(h,e),o?Pd.addScaledVector(mg,u):Pd.addScaledVector(mg.sub(t),u))}t.add(Pd)}return t}raycast(e,t){let n=this.geometry,r=this.material,s=this.matrixWorld;r!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),Ad.copy(n.boundingSphere),Ad.applyMatrix4(s),yo.copy(e.ray).recast(e.near),!(Ad.containsPoint(yo.origin)===!1&&(yo.intersectSphere(Ad,Tv)===null||yo.origin.distanceToSquared(Tv)>(e.far-e.near)**2))&&(Sv.copy(s).invert(),yo.copy(e.ray).applyMatrix4(Sv),!(n.boundingBox!==null&&yo.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,yo)))}_computeIntersections(e,t,n){let r,s=this.geometry,o=this.material,a=s.index,c=s.attributes.position,l=s.attributes.uv,u=s.attributes.uv1,h=s.attributes.normal,d=s.groups,m=s.drawRange;if(a!==null)if(Array.isArray(o))for(let g=0,x=d.length;g<x;g++){let f=d[g],p=o[f.materialIndex],v=Math.max(f.start,m.start),_=Math.min(a.count,Math.min(f.start+f.count,m.start+m.count));for(let y=v,b=_;y<b;y+=3){let E=a.getX(y),A=a.getX(y+1),T=a.getX(y+2);r=Nd(this,p,e,n,l,u,h,E,A,T),r&&(r.faceIndex=Math.floor(y/3),r.face.materialIndex=f.materialIndex,t.push(r))}}else{let g=Math.max(0,m.start),x=Math.min(a.count,m.start+m.count);for(let f=g,p=x;f<p;f+=3){let v=a.getX(f),_=a.getX(f+1),y=a.getX(f+2);r=Nd(this,o,e,n,l,u,h,v,_,y),r&&(r.faceIndex=Math.floor(f/3),t.push(r))}}else if(c!==void 0)if(Array.isArray(o))for(let g=0,x=d.length;g<x;g++){let f=d[g],p=o[f.materialIndex],v=Math.max(f.start,m.start),_=Math.min(c.count,Math.min(f.start+f.count,m.start+m.count));for(let y=v,b=_;y<b;y+=3){let E=y,A=y+1,T=y+2;r=Nd(this,p,e,n,l,u,h,E,A,T),r&&(r.faceIndex=Math.floor(y/3),r.face.materialIndex=f.materialIndex,t.push(r))}}else{let g=Math.max(0,m.start),x=Math.min(c.count,m.start+m.count);for(let f=g,p=x;f<p;f+=3){let v=f,_=f+1,y=f+2;r=Nd(this,o,e,n,l,u,h,v,_,y),r&&(r.faceIndex=Math.floor(f/3),t.push(r))}}}};function GS(i,e,t,n,r,s,o,a){let c;if(e.side===un?c=n.intersectTriangle(o,s,r,!0,a):c=n.intersectTriangle(r,s,o,e.side===Jn,a),c===null)return null;Id.copy(a),Id.applyMatrix4(i.matrixWorld);let l=t.ray.origin.distanceTo(Id);return l<t.near||l>t.far?null:{distance:l,point:Id.clone(),object:i}}function Nd(i,e,t,n,r,s,o,a,c,l){i.getVertexPosition(a,wd),i.getVertexPosition(c,Rd),i.getVertexPosition(l,Cd);let u=GS(i,e,t,n,wd,Rd,Cd,Av);if(u){let h=new z;Oi.getBarycoord(Av,wd,Rd,Cd,h),r&&(u.uv=Oi.getInterpolatedAttribute(r,a,c,l,h,new Me)),s&&(u.uv1=Oi.getInterpolatedAttribute(s,a,c,l,h,new Me)),o&&(u.normal=Oi.getInterpolatedAttribute(o,a,c,l,h,new z),u.normal.dot(n.direction)>0&&u.normal.multiplyScalar(-1));let d={a,b:c,c:l,normal:new z,materialIndex:0};Oi.getNormal(wd,Rd,Cd,d.normal),u.face=d,u.barycoord=h}return u}var Qn=class i extends ot{constructor(e=1,t=1,n=1,r=1,s=1,o=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:r,heightSegments:s,depthSegments:o};let a=this;r=Math.floor(r),s=Math.floor(s),o=Math.floor(o);let c=[],l=[],u=[],h=[],d=0,m=0;g("z","y","x",-1,-1,n,t,e,o,s,0),g("z","y","x",1,-1,n,t,-e,o,s,1),g("x","z","y",1,1,e,n,t,r,o,2),g("x","z","y",1,-1,e,n,-t,r,o,3),g("x","y","z",1,-1,e,t,n,r,s,4),g("x","y","z",-1,-1,e,t,-n,r,s,5),this.setIndex(c),this.setAttribute("position",new ze(l,3)),this.setAttribute("normal",new ze(u,3)),this.setAttribute("uv",new ze(h,2));function g(x,f,p,v,_,y,b,E,A,T,M){let S=y/A,C=b/T,N=y/2,I=b/2,L=E/2,q=A+1,K=T+1,B=0,j=0,J=new z;for(let se=0;se<K;se++){let ce=se*C-I;for(let me=0;me<q;me++){let Se=me*S-N;J[x]=Se*v,J[f]=ce*_,J[p]=L,l.push(J.x,J.y,J.z),J[x]=0,J[f]=0,J[p]=E>0?1:-1,u.push(J.x,J.y,J.z),h.push(me/A),h.push(1-se/T),B+=1}}for(let se=0;se<T;se++)for(let ce=0;ce<A;ce++){let me=d+ce+q*se,Se=d+ce+q*(se+1),V=d+(ce+1)+q*(se+1),w=d+(ce+1)+q*se;c.push(me,Se,w),c.push(Se,V,w),j+=6}a.addGroup(m,j,M),m+=j,d+=B}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new i(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}};function Qo(i){let e={};for(let t in i){e[t]={};for(let n in i[t]){let r=i[t][n];r&&(r.isColor||r.isMatrix3||r.isMatrix4||r.isVector2||r.isVector3||r.isVector4||r.isTexture||r.isQuaternion)?r.isRenderTargetTexture?(console.warn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[t][n]=null):e[t][n]=r.clone():Array.isArray(r)?e[t][n]=r.slice():e[t][n]=r}}return e}function $n(i){let e={};for(let t=0;t<i.length;t++){let n=Qo(i[t]);for(let r in n)e[r]=n[r]}return e}function WS(i){let e=[];for(let t=0;t<i.length;t++)e.push(i[t].clone());return e}function A0(i){let e=i.getRenderTarget();return e===null?i.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:_t.workingColorSpace}var Gn={clone:Qo,merge:$n},XS=`void main() {
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}`,YS=`void main() {
gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
}`,$t=class extends cn{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=XS,this.fragmentShader=YS,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=Qo(e.uniforms),this.uniformsGroups=WS(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}toJSON(e){let t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(let r in this.uniforms){let o=this.uniforms[r].value;o&&o.isTexture?t.uniforms[r]={type:"t",value:o.toJSON(e).uuid}:o&&o.isColor?t.uniforms[r]={type:"c",value:o.getHex()}:o&&o.isVector2?t.uniforms[r]={type:"v2",value:o.toArray()}:o&&o.isVector3?t.uniforms[r]={type:"v3",value:o.toArray()}:o&&o.isVector4?t.uniforms[r]={type:"v4",value:o.toArray()}:o&&o.isMatrix3?t.uniforms[r]={type:"m3",value:o.toArray()}:o&&o.isMatrix4?t.uniforms[r]={type:"m4",value:o.toArray()}:t.uniforms[r]={value:o}}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;let n={};for(let r in this.extensions)this.extensions[r]===!0&&(n[r]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}},No=class extends St{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new nt,this.projectionMatrix=new nt,this.projectionMatrixInverse=new nt,this.coordinateSystem=tr}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.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}},Ps=new z,wv=new Me,Rv=new Me,jt=class extends No{constructor(e=50,t=1,n=.1,r=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,this.far=r,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){let t=.5*this.getFilmHeight()/e;this.fov=Co*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){let e=Math.tan(Ro*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return Co*2*Math.atan(Math.tan(Ro*.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,n){Ps.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(Ps.x,Ps.y).multiplyScalar(-e/Ps.z),Ps.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(Ps.x,Ps.y).multiplyScalar(-e/Ps.z)}getViewSize(e,t){return this.getViewBounds(e,wv,Rv),t.subVectors(Rv,wv)}setViewOffset(e,t,n,r,s,o){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=n,this.view.offsetY=r,this.view.width=s,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let e=this.near,t=e*Math.tan(Ro*.5*this.fov)/this.zoom,n=2*t,r=this.aspect*n,s=-.5*r,o=this.view;if(this.view!==null&&this.view.enabled){let c=o.fullWidth,l=o.fullHeight;s+=o.offsetX*r/c,t-=o.offsetY*n/l,r*=o.width/c,n*=o.height/l}let a=this.filmOffset;a!==0&&(s+=e*a/this.getFilmWidth()),this.projectionMatrix.makePerspective(s,s+r,t,t-n,e,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let 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}},ka=-90,Ba=1,Ol=class extends St{constructor(e,t,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;let r=new jt(ka,Ba,e,t);r.layers=this.layers,this.add(r);let s=new jt(ka,Ba,e,t);s.layers=this.layers,this.add(s);let o=new jt(ka,Ba,e,t);o.layers=this.layers,this.add(o);let a=new jt(ka,Ba,e,t);a.layers=this.layers,this.add(a);let c=new jt(ka,Ba,e,t);c.layers=this.layers,this.add(c);let l=new jt(ka,Ba,e,t);l.layers=this.layers,this.add(l)}updateCoordinateSystem(){let e=this.coordinateSystem,t=this.children.concat(),[n,r,s,o,a,c]=t;for(let l of t)this.remove(l);if(e===tr)n.up.set(0,1,0),n.lookAt(1,0,0),r.up.set(0,1,0),r.lookAt(-1,0,0),s.up.set(0,0,-1),s.lookAt(0,1,0),o.up.set(0,0,1),o.lookAt(0,-1,0),a.up.set(0,1,0),a.lookAt(0,0,1),c.up.set(0,1,0),c.lookAt(0,0,-1);else if(e===Ja)n.up.set(0,-1,0),n.lookAt(-1,0,0),r.up.set(0,-1,0),r.lookAt(1,0,0),s.up.set(0,0,1),s.lookAt(0,1,0),o.up.set(0,0,-1),o.lookAt(0,-1,0),a.up.set(0,-1,0),a.lookAt(0,0,1),c.up.set(0,-1,0),c.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(let l of t)this.add(l),l.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();let{renderTarget:n,activeMipmapLevel:r}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());let[s,o,a,c,l,u]=this.children,h=e.getRenderTarget(),d=e.getActiveCubeFace(),m=e.getActiveMipmapLevel(),g=e.xr.enabled;e.xr.enabled=!1;let x=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,e.setRenderTarget(n,0,r),e.render(t,s),e.setRenderTarget(n,1,r),e.render(t,o),e.setRenderTarget(n,2,r),e.render(t,a),e.setRenderTarget(n,3,r),e.render(t,c),e.setRenderTarget(n,4,r),e.render(t,l),n.texture.generateMipmaps=x,e.setRenderTarget(n,5,r),e.render(t,u),e.setRenderTarget(h,d,m),e.xr.enabled=g,n.texture.needsPMREMUpdate=!0}},Vs=class extends Qt{constructor(e,t,n,r,s,o,a,c,l,u){e=e!==void 0?e:[],t=t!==void 0?t:Nr,super(e,t,n,r,s,o,a,c,l,u),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}},Dl=class extends on{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;let n={width:e,height:e,depth:1},r=[n,n,n,n,n,n];this.texture=new Vs(r,t.mapping,t.wrapS,t.wrapT,t.magFilter,t.minFilter,t.format,t.type,t.anisotropy,t.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=t.generateMipmaps!==void 0?t.generateMipmaps:!1,this.texture.minFilter=t.minFilter!==void 0?t.minFilter:nn}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;let n={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 );
}
`},r=new Qn(5,5,5),s=new $t({name:"CubemapFromEquirect",uniforms:Qo(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:un,blending:yn});s.uniforms.tEquirect.value=t;let o=new ct(r,s),a=t.minFilter;return t.minFilter===Ei&&(t.minFilter=nn),new Ol(1,10,this).update(e,o),t.minFilter=a,o.geometry.dispose(),o.material.dispose(),this}clear(e,t,n,r){let s=e.getRenderTarget();for(let o=0;o<6;o++)e.setRenderTarget(this,o),e.clear(t,n,r);e.setRenderTarget(s)}},Fl=class i{constructor(e,t=25e-5){this.isFogExp2=!0,this.name="",this.color=new Ue(e),this.density=t}clone(){return new i(this.color,this.density)}toJSON(){return{type:"FogExp2",name:this.name,color:this.color.getHex(),density:this.density}}},Ul=class i{constructor(e,t=1,n=1e3){this.isFog=!0,this.name="",this.color=new Ue(e),this.near=t,this.far=n}clone(){return new i(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}},oi=class extends St{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 yi,this.environmentIntensity=1,this.environmentRotation=new yi,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){let 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}},Er=class{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=Za,this.updateRanges=[],this.version=0,this.uuid=Di()}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,n){e*=this.stride,n*=t.stride;for(let r=0,s=this.stride;r<s;r++)this.array[e+r]=t.array[n+r];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=Di()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);let t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(t,this.stride);return n.setUsage(this.usage),n}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=Di()),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}}},ii=new z,ir=class i{constructor(e,t,n,r=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=n,this.normalized=r}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,n=this.data.count;t<n;t++)ii.fromBufferAttribute(this,t),ii.applyMatrix4(e),this.setXYZ(t,ii.x,ii.y,ii.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)ii.fromBufferAttribute(this,t),ii.applyNormalMatrix(e),this.setXYZ(t,ii.x,ii.y,ii.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)ii.fromBufferAttribute(this,t),ii.transformDirection(e),this.setXYZ(t,ii.x,ii.y,ii.z);return this}getComponent(e,t){let n=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(n=ri(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=Mt(n,this.array)),this.data.array[e*this.data.stride+this.offset+t]=n,this}setX(e,t){return this.normalized&&(t=Mt(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=Mt(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=Mt(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=Mt(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=ri(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=ri(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=ri(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=ri(t,this.array)),t}setXY(e,t,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=Mt(t,this.array),n=Mt(n,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this}setXYZ(e,t,n,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=Mt(t,this.array),n=Mt(n,this.array),r=Mt(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=r,this}setXYZW(e,t,n,r,s){return e=e*this.data.stride+this.offset,this.normalized&&(t=Mt(t,this.array),n=Mt(n,this.array),r=Mt(r,this.array),s=Mt(s,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=r,this.data.array[e+3]=s,this}clone(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");let t=[];for(let n=0;n<this.count;n++){let r=n*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[r+s])}return new gt(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 i(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");let t=[];for(let n=0;n<this.count;n++){let r=n*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[r+s])}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}}},Hs=class extends cn{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new Ue(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}},za,xl=new z,Va=new z,Ha=new z,Ga=new Me,yl=new Me,tb=new nt,Ld=new z,vl=new z,Od=new z,Cv=new Me,gg=new Me,Pv=new Me,Lo=class extends St{constructor(e=new Hs){if(super(),this.isSprite=!0,this.type="Sprite",za===void 0){za=new ot;let t=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),n=new Er(t,5);za.setIndex([0,1,2,0,2,3]),za.setAttribute("position",new ir(n,3,0,!1)),za.setAttribute("uv",new ir(n,2,3,!1))}this.geometry=za,this.material=e,this.center=new Me(.5,.5)}raycast(e,t){e.camera===null&&console.error('THREE.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),Va.setFromMatrixScale(this.matrixWorld),tb.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),Ha.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&Va.multiplyScalar(-Ha.z);let n=this.material.rotation,r,s;n!==0&&(s=Math.cos(n),r=Math.sin(n));let o=this.center;Dd(Ld.set(-.5,-.5,0),Ha,o,Va,r,s),Dd(vl.set(.5,-.5,0),Ha,o,Va,r,s),Dd(Od.set(.5,.5,0),Ha,o,Va,r,s),Cv.set(0,0),gg.set(1,0),Pv.set(1,1);let a=e.ray.intersectTriangle(Ld,vl,Od,!1,xl);if(a===null&&(Dd(vl.set(-.5,.5,0),Ha,o,Va,r,s),gg.set(0,1),a=e.ray.intersectTriangle(Ld,Od,vl,!1,xl),a===null))return;let c=e.ray.origin.distanceTo(xl);c<e.near||c>e.far||t.push({distance:c,point:xl.clone(),uv:Oi.getInterpolation(xl,Ld,vl,Od,Cv,gg,Pv,new Me),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 Dd(i,e,t,n,r,s){Ga.subVectors(i,t).addScalar(.5).multiply(n),r!==void 0?(yl.x=s*Ga.x-r*Ga.y,yl.y=r*Ga.x+s*Ga.y):yl.copy(Ga),i.copy(e),i.x+=yl.x,i.y+=yl.y,i.applyMatrix4(tb)}var Fd=new z,Iv=new z,kl=class extends St{constructor(){super(),this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]},isLOD:{value:!0}}),this.autoUpdate=!0}copy(e){super.copy(e,!1);let t=e.levels;for(let n=0,r=t.length;n<r;n++){let s=t[n];this.addLevel(s.object.clone(),s.distance,s.hysteresis)}return this.autoUpdate=e.autoUpdate,this}addLevel(e,t=0,n=0){t=Math.abs(t);let r=this.levels,s;for(s=0;s<r.length&&!(t<r[s].distance);s++);return r.splice(s,0,{distance:t,hysteresis:n,object:e}),this.add(e),this}removeLevel(e){let t=this.levels;for(let n=0;n<t.length;n++)if(t[n].distance===e){let r=t.splice(n,1);return this.remove(r[0].object),!0}return!1}getCurrentLevel(){return this._currentLevel}getObjectForDistance(e){let t=this.levels;if(t.length>0){let n,r;for(n=1,r=t.length;n<r;n++){let s=t[n].distance;if(t[n].object.visible&&(s-=s*t[n].hysteresis),e<s)break}return t[n-1].object}return null}raycast(e,t){if(this.levels.length>0){Fd.setFromMatrixPosition(this.matrixWorld);let r=e.ray.origin.distanceTo(Fd);this.getObjectForDistance(r).raycast(e,t)}}update(e){let t=this.levels;if(t.length>1){Fd.setFromMatrixPosition(e.matrixWorld),Iv.setFromMatrixPosition(this.matrixWorld);let n=Fd.distanceTo(Iv)/e.zoom;t[0].object.visible=!0;let r,s;for(r=1,s=t.length;r<s;r++){let o=t[r].distance;if(t[r].object.visible&&(o-=o*t[r].hysteresis),n>=o)t[r-1].object.visible=!1,t[r].object.visible=!0;else break}for(this._currentLevel=r-1;r<s;r++)t[r].object.visible=!1}}toJSON(e){let t=super.toJSON(e);this.autoUpdate===!1&&(t.object.autoUpdate=!1),t.object.levels=[];let n=this.levels;for(let r=0,s=n.length;r<s;r++){let o=n[r];t.object.levels.push({object:o.object.uuid,distance:o.distance,hysteresis:o.hysteresis})}return t}},Nv=new z,Lv=new It,Ov=new It,jS=new z,Dv=new nt,Ud=new z,xg=new qt,Fv=new nt,yg=new nr,Oo=class extends ct{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=of,this.bindMatrix=new nt,this.bindMatrixInverse=new nt,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){let e=this.geometry;this.boundingBox===null&&(this.boundingBox=new zt),this.boundingBox.makeEmpty();let t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,Ud),this.boundingBox.expandByPoint(Ud)}computeBoundingSphere(){let e=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new qt),this.boundingSphere.makeEmpty();let t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,Ud),this.boundingSphere.expandByPoint(Ud)}copy(e,t){return super.copy(e,t),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}raycast(e,t){let n=this.material,r=this.matrixWorld;n!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),xg.copy(this.boundingSphere),xg.applyMatrix4(r),e.ray.intersectsSphere(xg)!==!1&&(Fv.copy(r).invert(),yg.copy(e.ray).applyMatrix4(Fv),!(this.boundingBox!==null&&yg.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(e,t,yg)))}getVertexPosition(e,t){return super.getVertexPosition(e,t),this.applyBoneTransform(e,t),t}bind(e,t){this.skeleton=e,t===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){let e=new It,t=this.geometry.attributes.skinWeight;for(let n=0,r=t.count;n<r;n++){e.fromBufferAttribute(t,n);let s=1/e.manhattanLength();s!==1/0?e.multiplyScalar(s):e.set(1,0,0,0),t.setXYZW(n,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode===of?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===l0?this.bindMatrixInverse.copy(this.bindMatrix).invert():console.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){let n=this.skeleton,r=this.geometry;Lv.fromBufferAttribute(r.attributes.skinIndex,e),Ov.fromBufferAttribute(r.attributes.skinWeight,e),Nv.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let s=0;s<4;s++){let o=Ov.getComponent(s);if(o!==0){let a=Lv.getComponent(s);Dv.multiplyMatrices(n.bones[a].matrixWorld,n.boneInverses[a]),t.addScaledVector(jS.copy(Nv).applyMatrix4(Dv),o)}}return t.applyMatrix4(this.bindMatrixInverse)}},Gs=class extends St{constructor(){super(),this.isBone=!0,this.type="Bone"}},An=class extends Qt{constructor(e=null,t=1,n=1,r,s,o,a,c,l=Jt,u=Jt,h,d){super(null,o,a,c,l,u,r,s,h,d),this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},Uv=new nt,qS=new nt,Do=class i{constructor(e=[],t=[]){this.uuid=Di(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,this.init()}init(){let e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(e.length*16),t.length===0)this.calculateInverses();else if(e.length!==t.length){console.warn("THREE.Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let n=0,r=this.bones.length;n<r;n++)this.boneInverses.push(new nt)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){let n=new nt;this.bones[e]&&n.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(n)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){let n=this.bones[e];n&&n.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){let n=this.bones[e];n&&(n.parent&&n.parent.isBone?(n.matrix.copy(n.parent.matrixWorld).invert(),n.matrix.multiply(n.matrixWorld)):n.matrix.copy(n.matrixWorld),n.matrix.decompose(n.position,n.quaternion,n.scale))}}update(){let e=this.bones,t=this.boneInverses,n=this.boneMatrices,r=this.boneTexture;for(let s=0,o=e.length;s<o;s++){let a=e[s]?e[s].matrixWorld:qS;Uv.multiplyMatrices(a,t[s]),Uv.toArray(n,s*16)}r!==null&&(r.needsUpdate=!0)}clone(){return new i(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(this.bones.length*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);let t=new Float32Array(e*e*4);t.set(this.boneMatrices);let n=new An(t,e,e,Ln,si);return n.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=n,this}getBoneByName(e){for(let t=0,n=this.bones.length;t<n;t++){let r=this.bones[t];if(r.name===e)return r}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let n=0,r=e.bones.length;n<r;n++){let s=e.bones[n],o=t[s];o===void 0&&(console.warn("THREE.Skeleton: No bone found with UUID:",s),o=new Gs),this.bones.push(o),this.boneInverses.push(new nt().fromArray(e.boneInverses[n]))}return this.init(),this}toJSON(){let e={metadata:{version:4.6,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;let t=this.bones,n=this.boneInverses;for(let r=0,s=t.length;r<s;r++){let o=t[r];e.bones.push(o.uuid);let a=n[r];e.boneInverses.push(a.toArray())}return e}},Xi=class extends gt{constructor(e,t,n,r=1){super(e,t,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=r}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){let e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}},Wa=new nt,kv=new nt,kd=[],Bv=new zt,KS=new nt,_l=new ct,bl=new qt,$r=class extends ct{constructor(e,t,n){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new Xi(new Float32Array(n*16),16),this.instanceColor=null,this.morphTexture=null,this.count=n,this.boundingBox=null,this.boundingSphere=null;for(let r=0;r<n;r++)this.setMatrixAt(r,KS)}computeBoundingBox(){let e=this.geometry,t=this.count;this.boundingBox===null&&(this.boundingBox=new zt),e.boundingBox===null&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,Wa),Bv.copy(e.boundingBox).applyMatrix4(Wa),this.boundingBox.union(Bv)}computeBoundingSphere(){let e=this.geometry,t=this.count;this.boundingSphere===null&&(this.boundingSphere=new qt),e.boundingSphere===null&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,Wa),bl.copy(e.boundingSphere).applyMatrix4(Wa),this.boundingSphere.union(bl)}copy(e,t){return super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),e.morphTexture!==null&&(this.morphTexture=e.morphTexture.clone()),e.instanceColor!==null&&(this.instanceColor=e.instanceColor.clone()),this.count=e.count,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}getColorAt(e,t){t.fromArray(this.instanceColor.array,e*3)}getMatrixAt(e,t){t.fromArray(this.instanceMatrix.array,e*16)}getMorphAt(e,t){let n=t.morphTargetInfluences,r=this.morphTexture.source.data.data,s=n.length+1,o=e*s+1;for(let a=0;a<n.length;a++)n[a]=r[o+a]}raycast(e,t){let n=this.matrixWorld,r=this.count;if(_l.geometry=this.geometry,_l.material=this.material,_l.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),bl.copy(this.boundingSphere),bl.applyMatrix4(n),e.ray.intersectsSphere(bl)!==!1))for(let s=0;s<r;s++){this.getMatrixAt(s,Wa),kv.multiplyMatrices(n,Wa),_l.matrixWorld=kv,_l.raycast(e,kd);for(let o=0,a=kd.length;o<a;o++){let c=kd[o];c.instanceId=s,c.object=this,t.push(c)}kd.length=0}}setColorAt(e,t){this.instanceColor===null&&(this.instanceColor=new Xi(new Float32Array(this.instanceMatrix.count*3).fill(1),3)),t.toArray(this.instanceColor.array,e*3)}setMatrixAt(e,t){t.toArray(this.instanceMatrix.array,e*16)}setMorphAt(e,t){let n=t.morphTargetInfluences,r=n.length+1;this.morphTexture===null&&(this.morphTexture=new An(new Float32Array(r*this.count),r,this.count,Gu,si));let s=this.morphTexture.source.data.data,o=0;for(let l=0;l<n.length;l++)o+=n[l];let a=this.geometry.morphTargetsRelative?1:1-o,c=r*e;s[c]=a,s.set(n,c+1)}updateMorphTargets(){}dispose(){return this.dispatchEvent({type:"dispose"}),this.morphTexture!==null&&(this.morphTexture.dispose(),this.morphTexture=null),this}},vg=new z,ZS=new z,JS=new xt,Li=class{constructor(e=new z(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,n,r){return this.normal.set(e,t,n),this.constant=r,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){let r=vg.subVectors(n,t).cross(ZS.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(r,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){let 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){let n=e.delta(vg),r=this.normal.dot(n);if(r===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;let s=-(e.start.dot(this.normal)+this.constant)/r;return s<0||s>1?null:t.copy(e.start).addScaledVector(n,s)}intersectsLine(e){let t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<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){let n=t||JS.getNormalMatrix(e),r=this.coplanarPoint(vg).applyMatrix4(e),s=this.normal.applyMatrix3(n).normalize();return this.constant=-r.dot(s),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)}},vo=new qt,Bd=new z,Ws=class{constructor(e=new Li,t=new Li,n=new Li,r=new Li,s=new Li,o=new Li){this.planes=[e,t,n,r,s,o]}set(e,t,n,r,s,o){let a=this.planes;return a[0].copy(e),a[1].copy(t),a[2].copy(n),a[3].copy(r),a[4].copy(s),a[5].copy(o),this}copy(e){let t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=tr){let n=this.planes,r=e.elements,s=r[0],o=r[1],a=r[2],c=r[3],l=r[4],u=r[5],h=r[6],d=r[7],m=r[8],g=r[9],x=r[10],f=r[11],p=r[12],v=r[13],_=r[14],y=r[15];if(n[0].setComponents(c-s,d-l,f-m,y-p).normalize(),n[1].setComponents(c+s,d+l,f+m,y+p).normalize(),n[2].setComponents(c+o,d+u,f+g,y+v).normalize(),n[3].setComponents(c-o,d-u,f-g,y-v).normalize(),n[4].setComponents(c-a,d-h,f-x,y-_).normalize(),t===tr)n[5].setComponents(c+a,d+h,f+x,y+_).normalize();else if(t===Ja)n[5].setComponents(a,h,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(),vo.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{let t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),vo.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(vo)}intersectsSprite(e){return vo.center.set(0,0,0),vo.radius=.7071067811865476,vo.applyMatrix4(e.matrixWorld),this.intersectsSphere(vo)}intersectsSphere(e){let t=this.planes,n=e.center,r=-e.radius;for(let s=0;s<6;s++)if(t[s].distanceToPoint(n)<r)return!1;return!0}intersectsBox(e){let t=this.planes;for(let n=0;n<6;n++){let r=t[n];if(Bd.x=r.normal.x>0?e.max.x:e.min.x,Bd.y=r.normal.y>0?e.max.y:e.min.y,Bd.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(Bd)<0)return!1}return!0}containsPoint(e){let t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}};function _g(i,e){return i-e}function QS(i,e){return i.z-e.z}function $S(i,e){return e.z-i.z}var Ng=class{constructor(){this.index=0,this.pool=[],this.list=[]}push(e,t,n,r){let s=this.pool,o=this.list;this.index>=s.length&&s.push({start:-1,count:-1,z:-1,index:-1});let a=s[this.index];o.push(a),this.index++,a.start=e,a.count=t,a.z=n,a.index=r}reset(){this.list.length=0,this.index=0}},mi=new nt,eT=new Ue(1,1,1),bg=new Ws,zd=new zt,_o=new qt,Ml=new z,zv=new z,tT=new z,Mg=new Ng,Zn=new ct,Vd=[];function nT(i,e,t=0){let n=e.itemSize;if(i.isInterleavedBufferAttribute||i.array.constructor!==e.array.constructor){let r=i.count;for(let s=0;s<r;s++)for(let o=0;o<n;o++)e.setComponent(s+t,o,i.getComponent(s,o))}else e.array.set(i.array,t*n);e.needsUpdate=!0}function bo(i,e){if(i.constructor!==e.constructor){let t=Math.min(i.length,e.length);for(let n=0;n<t;n++)e[n]=i[n]}else{let t=Math.min(i.length,e.length);e.set(new i.constructor(i.buffer,0,t))}}var Bl=class extends ct{get maxInstanceCount(){return this._maxInstanceCount}get instanceCount(){return this._instanceInfo.length-this._availableInstanceIds.length}get unusedVertexCount(){return this._maxVertexCount-this._nextVertexStart}get unusedIndexCount(){return this._maxIndexCount-this._nextIndexStart}constructor(e,t,n=t*2,r){super(new ot,r),this.isBatchedMesh=!0,this.perObjectFrustumCulled=!0,this.sortObjects=!0,this.boundingBox=null,this.boundingSphere=null,this.customSort=null,this._instanceInfo=[],this._geometryInfo=[],this._availableInstanceIds=[],this._availableGeometryIds=[],this._nextIndexStart=0,this._nextVertexStart=0,this._geometryCount=0,this._visibilityChanged=!0,this._geometryInitialized=!1,this._maxInstanceCount=e,this._maxVertexCount=t,this._maxIndexCount=n,this._multiDrawCounts=new Int32Array(e),this._multiDrawStarts=new Int32Array(e),this._multiDrawCount=0,this._multiDrawInstances=null,this._matricesTexture=null,this._indirectTexture=null,this._colorsTexture=null,this._initMatricesTexture(),this._initIndirectTexture()}_initMatricesTexture(){let e=Math.sqrt(this._maxInstanceCount*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);let t=new Float32Array(e*e*4),n=new An(t,e,e,Ln,si);this._matricesTexture=n}_initIndirectTexture(){let e=Math.sqrt(this._maxInstanceCount);e=Math.ceil(e);let t=new Uint32Array(e*e),n=new An(t,e,e,Ec,Lr);this._indirectTexture=n}_initColorsTexture(){let e=Math.sqrt(this._maxInstanceCount);e=Math.ceil(e);let t=new Float32Array(e*e*4).fill(1),n=new An(t,e,e,Ln,si);n.colorSpace=_t.workingColorSpace,this._colorsTexture=n}_initializeGeometry(e){let t=this.geometry,n=this._maxVertexCount,r=this._maxIndexCount;if(this._geometryInitialized===!1){for(let s in e.attributes){let o=e.getAttribute(s),{array:a,itemSize:c,normalized:l}=o,u=new a.constructor(n*c),h=new gt(u,c,l);t.setAttribute(s,h)}if(e.getIndex()!==null){let s=n>65535?new Uint32Array(r):new Uint16Array(r);t.setIndex(new gt(s,1))}this._geometryInitialized=!0}}_validateGeometry(e){let t=this.geometry;if(!!e.getIndex()!=!!t.getIndex())throw new Error('THREE.BatchedMesh: All geometries must consistently have "index".');for(let n in t.attributes){if(!e.hasAttribute(n))throw new Error(`THREE.BatchedMesh: Added geometry missing "${n}". All geometries must have consistent attributes.`);let r=e.getAttribute(n),s=t.getAttribute(n);if(r.itemSize!==s.itemSize||r.normalized!==s.normalized)throw new Error("THREE.BatchedMesh: All attributes must have a consistent itemSize and normalized value.")}}validateInstanceId(e){let t=this._instanceInfo;if(e<0||e>=t.length||t[e].active===!1)throw new Error(`THREE.BatchedMesh: Invalid instanceId ${e}. Instance is either out of range or has been deleted.`)}validateGeometryId(e){let t=this._geometryInfo;if(e<0||e>=t.length||t[e].active===!1)throw new Error(`THREE.BatchedMesh: Invalid geometryId ${e}. Geometry is either out of range or has been deleted.`)}setCustomSort(e){return this.customSort=e,this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new zt);let e=this.boundingBox,t=this._instanceInfo;e.makeEmpty();for(let n=0,r=t.length;n<r;n++){if(t[n].active===!1)continue;let s=t[n].geometryIndex;this.getMatrixAt(n,mi),this.getBoundingBoxAt(s,zd).applyMatrix4(mi),e.union(zd)}}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new qt);let e=this.boundingSphere,t=this._instanceInfo;e.makeEmpty();for(let n=0,r=t.length;n<r;n++){if(t[n].active===!1)continue;let s=t[n].geometryIndex;this.getMatrixAt(n,mi),this.getBoundingSphereAt(s,_o).applyMatrix4(mi),e.union(_o)}}addInstance(e){if(this._instanceInfo.length>=this.maxInstanceCount&&this._availableInstanceIds.length===0)throw new Error("THREE.BatchedMesh: Maximum item count reached.");let n={visible:!0,active:!0,geometryIndex:e},r=null;this._availableInstanceIds.length>0?(this._availableInstanceIds.sort(_g),r=this._availableInstanceIds.shift(),this._instanceInfo[r]=n):(r=this._instanceInfo.length,this._instanceInfo.push(n));let s=this._matricesTexture;mi.identity().toArray(s.image.data,r*16),s.needsUpdate=!0;let o=this._colorsTexture;return o&&(eT.toArray(o.image.data,r*4),o.needsUpdate=!0),this._visibilityChanged=!0,r}addGeometry(e,t=-1,n=-1){this._initializeGeometry(e),this._validateGeometry(e);let r={vertexStart:-1,vertexCount:-1,reservedVertexCount:-1,indexStart:-1,indexCount:-1,reservedIndexCount:-1,start:-1,count:-1,boundingBox:null,boundingSphere:null,active:!0},s=this._geometryInfo;r.vertexStart=this._nextVertexStart,r.reservedVertexCount=t===-1?e.getAttribute("position").count:t;let o=e.getIndex();if(o!==null&&(r.indexStart=this._nextIndexStart,r.reservedIndexCount=n===-1?o.count:n),r.indexStart!==-1&&r.indexStart+r.reservedIndexCount>this._maxIndexCount||r.vertexStart+r.reservedVertexCount>this._maxVertexCount)throw new Error("THREE.BatchedMesh: Reserved space request exceeds the maximum buffer size.");let c;return this._availableGeometryIds.length>0?(this._availableGeometryIds.sort(_g),c=this._availableGeometryIds.shift(),s[c]=r):(c=this._geometryCount,this._geometryCount++,s.push(r)),this.setGeometryAt(c,e),this._nextIndexStart=r.indexStart+r.reservedIndexCount,this._nextVertexStart=r.vertexStart+r.reservedVertexCount,c}setGeometryAt(e,t){if(e>=this._geometryCount)throw new Error("THREE.BatchedMesh: Maximum geometry count reached.");this._validateGeometry(t);let n=this.geometry,r=n.getIndex()!==null,s=n.getIndex(),o=t.getIndex(),a=this._geometryInfo[e];if(r&&o.count>a.reservedIndexCount||t.attributes.position.count>a.reservedVertexCount)throw new Error("THREE.BatchedMesh: Reserved space not large enough for provided geometry.");let c=a.vertexStart,l=a.reservedVertexCount;a.vertexCount=t.getAttribute("position").count;for(let u in n.attributes){let h=t.getAttribute(u),d=n.getAttribute(u);nT(h,d,c);let m=h.itemSize;for(let g=h.count,x=l;g<x;g++){let f=c+g;for(let p=0;p<m;p++)d.setComponent(f,p,0)}d.needsUpdate=!0,d.addUpdateRange(c*m,l*m)}if(r){let u=a.indexStart,h=a.reservedIndexCount;a.indexCount=t.getIndex().count;for(let d=0;d<o.count;d++)s.setX(u+d,c+o.getX(d));for(let d=o.count,m=h;d<m;d++)s.setX(u+d,c);s.needsUpdate=!0,s.addUpdateRange(u,a.reservedIndexCount)}return a.start=r?a.indexStart:a.vertexStart,a.count=r?a.indexCount:a.vertexCount,a.boundingBox=null,t.boundingBox!==null&&(a.boundingBox=t.boundingBox.clone()),a.boundingSphere=null,t.boundingSphere!==null&&(a.boundingSphere=t.boundingSphere.clone()),this._visibilityChanged=!0,e}deleteGeometry(e){let t=this._geometryInfo;if(e>=t.length||t[e].active===!1)return this;let n=this._instanceInfo;for(let r=0,s=n.length;r<s;r++)n[r].geometryIndex===e&&this.deleteInstance(r);return t[e].active=!1,this._availableGeometryIds.push(e),this._visibilityChanged=!0,this}deleteInstance(e){return this.validateInstanceId(e),this._instanceInfo[e].active=!1,this._availableInstanceIds.push(e),this._visibilityChanged=!0,this}optimize(){let e=0,t=0,n=this._geometryInfo,r=n.map((o,a)=>a).sort((o,a)=>n[o].vertexStart-n[a].vertexStart),s=this.geometry;for(let o=0,a=n.length;o<a;o++){let c=r[o],l=n[c];if(l.active!==!1){if(s.index!==null){if(l.indexStart!==t){let{indexStart:u,vertexStart:h,reservedIndexCount:d}=l,m=s.index,g=m.array,x=e-h;for(let f=u;f<u+d;f++)g[f]=g[f]+x;m.array.copyWithin(t,u,u+d),m.addUpdateRange(t,d),l.indexStart=t}t+=l.reservedIndexCount}if(l.vertexStart!==e){let{vertexStart:u,reservedVertexCount:h}=l,d=s.attributes;for(let m in d){let g=d[m],{array:x,itemSize:f}=g;x.copyWithin(e*f,u*f,(u+h)*f),g.addUpdateRange(e*f,h*f)}l.vertexStart=e}e+=l.reservedVertexCount,l.start=s.index?l.indexStart:l.vertexStart,this._nextIndexStart=s.index?l.indexStart+l.reservedIndexCount:0,this._nextVertexStart=l.vertexStart+l.reservedVertexCount}}return this}getBoundingBoxAt(e,t){if(e>=this._geometryCount)return null;let n=this.geometry,r=this._geometryInfo[e];if(r.boundingBox===null){let s=new zt,o=n.index,a=n.attributes.position;for(let c=r.start,l=r.start+r.count;c<l;c++){let u=c;o&&(u=o.getX(u)),s.expandByPoint(Ml.fromBufferAttribute(a,u))}r.boundingBox=s}return t.copy(r.boundingBox),t}getBoundingSphereAt(e,t){if(e>=this._geometryCount)return null;let n=this.geometry,r=this._geometryInfo[e];if(r.boundingSphere===null){let s=new qt;this.getBoundingBoxAt(e,zd),zd.getCenter(s.center);let o=n.index,a=n.attributes.position,c=0;for(let l=r.start,u=r.start+r.count;l<u;l++){let h=l;o&&(h=o.getX(h)),Ml.fromBufferAttribute(a,h),c=Math.max(c,s.center.distanceToSquared(Ml))}s.radius=Math.sqrt(c),r.boundingSphere=s}return t.copy(r.boundingSphere),t}setMatrixAt(e,t){this.validateInstanceId(e);let n=this._matricesTexture,r=this._matricesTexture.image.data;return t.toArray(r,e*16),n.needsUpdate=!0,this}getMatrixAt(e,t){return this.validateInstanceId(e),t.fromArray(this._matricesTexture.image.data,e*16)}setColorAt(e,t){return this.validateInstanceId(e),this._colorsTexture===null&&this._initColorsTexture(),t.toArray(this._colorsTexture.image.data,e*4),this._colorsTexture.needsUpdate=!0,this}getColorAt(e,t){return this.validateInstanceId(e),t.fromArray(this._colorsTexture.image.data,e*4)}setVisibleAt(e,t){return this.validateInstanceId(e),this._instanceInfo[e].visible===t?this:(this._instanceInfo[e].visible=t,this._visibilityChanged=!0,this)}getVisibleAt(e){return this.validateInstanceId(e),this._instanceInfo[e].visible}setGeometryIdAt(e,t){return this.validateInstanceId(e),this.validateGeometryId(t),this._instanceInfo[e].geometryIndex=t,this}getGeometryIdAt(e){return this.validateInstanceId(e),this._instanceInfo[e].geometryIndex}getGeometryRangeAt(e,t={}){this.validateGeometryId(e);let n=this._geometryInfo[e];return t.vertexStart=n.vertexStart,t.vertexCount=n.vertexCount,t.reservedVertexCount=n.reservedVertexCount,t.indexStart=n.indexStart,t.indexCount=n.indexCount,t.reservedIndexCount=n.reservedIndexCount,t.start=n.start,t.count=n.count,t}setInstanceCount(e){let t=this._availableInstanceIds,n=this._instanceInfo;for(t.sort(_g);t[t.length-1]===n.length;)n.pop(),t.pop();if(e<n.length)throw new Error(`BatchedMesh: Instance ids outside the range ${e} are being used. Cannot shrink instance count.`);let r=new Int32Array(e),s=new Int32Array(e);bo(this._multiDrawCounts,r),bo(this._multiDrawStarts,s),this._multiDrawCounts=r,this._multiDrawStarts=s,this._maxInstanceCount=e;let o=this._indirectTexture,a=this._matricesTexture,c=this._colorsTexture;o.dispose(),this._initIndirectTexture(),bo(o.image.data,this._indirectTexture.image.data),a.dispose(),this._initMatricesTexture(),bo(a.image.data,this._matricesTexture.image.data),c&&(c.dispose(),this._initColorsTexture(),bo(c.image.data,this._colorsTexture.image.data))}setGeometrySize(e,t){let n=[...this._geometryInfo].filter(a=>a.active);if(Math.max(...n.map(a=>a.vertexStart+a.reservedVertexCount))>e)throw new Error(`BatchedMesh: Geometry vertex values are being used outside the range ${t}. Cannot shrink further.`);if(this.geometry.index&&Math.max(...n.map(c=>c.indexStart+c.reservedIndexCount))>t)throw new Error(`BatchedMesh: Geometry index values are being used outside the range ${t}. Cannot shrink further.`);let s=this.geometry;s.dispose(),this._maxVertexCount=e,this._maxIndexCount=t,this._geometryInitialized&&(this._geometryInitialized=!1,this.geometry=new ot,this._initializeGeometry(s));let o=this.geometry;s.index&&bo(s.index.array,o.index.array);for(let a in s.attributes)bo(s.attributes[a].array,o.attributes[a].array)}raycast(e,t){let n=this._instanceInfo,r=this._geometryInfo,s=this.matrixWorld,o=this.geometry;Zn.material=this.material,Zn.geometry.index=o.index,Zn.geometry.attributes=o.attributes,Zn.geometry.boundingBox===null&&(Zn.geometry.boundingBox=new zt),Zn.geometry.boundingSphere===null&&(Zn.geometry.boundingSphere=new qt);for(let a=0,c=n.length;a<c;a++){if(!n[a].visible||!n[a].active)continue;let l=n[a].geometryIndex,u=r[l];Zn.geometry.setDrawRange(u.start,u.count),this.getMatrixAt(a,Zn.matrixWorld).premultiply(s),this.getBoundingBoxAt(l,Zn.geometry.boundingBox),this.getBoundingSphereAt(l,Zn.geometry.boundingSphere),Zn.raycast(e,Vd);for(let h=0,d=Vd.length;h<d;h++){let m=Vd[h];m.object=this,m.batchId=a,t.push(m)}Vd.length=0}Zn.material=null,Zn.geometry.index=null,Zn.geometry.attributes={},Zn.geometry.setDrawRange(0,1/0)}copy(e){return super.copy(e),this.geometry=e.geometry.clone(),this.perObjectFrustumCulled=e.perObjectFrustumCulled,this.sortObjects=e.sortObjects,this.boundingBox=e.boundingBox!==null?e.boundingBox.clone():null,this.boundingSphere=e.boundingSphere!==null?e.boundingSphere.clone():null,this._geometryInfo=e._geometryInfo.map(t=>({...t,boundingBox:t.boundingBox!==null?t.boundingBox.clone():null,boundingSphere:t.boundingSphere!==null?t.boundingSphere.clone():null})),this._instanceInfo=e._instanceInfo.map(t=>({...t})),this._maxInstanceCount=e._maxInstanceCount,this._maxVertexCount=e._maxVertexCount,this._maxIndexCount=e._maxIndexCount,this._geometryInitialized=e._geometryInitialized,this._geometryCount=e._geometryCount,this._multiDrawCounts=e._multiDrawCounts.slice(),this._multiDrawStarts=e._multiDrawStarts.slice(),this._matricesTexture=e._matricesTexture.clone(),this._matricesTexture.image.data=this._matricesTexture.image.data.slice(),this._colorsTexture!==null&&(this._colorsTexture=e._colorsTexture.clone(),this._colorsTexture.image.data=this._colorsTexture.image.data.slice()),this}dispose(){return this.geometry.dispose(),this._matricesTexture.dispose(),this._matricesTexture=null,this._indirectTexture.dispose(),this._indirectTexture=null,this._colorsTexture!==null&&(this._colorsTexture.dispose(),this._colorsTexture=null),this}onBeforeRender(e,t,n,r,s){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;let o=r.getIndex(),a=o===null?1:o.array.BYTES_PER_ELEMENT,c=this._instanceInfo,l=this._multiDrawStarts,u=this._multiDrawCounts,h=this._geometryInfo,d=this.perObjectFrustumCulled,m=this._indirectTexture,g=m.image.data;d&&(mi.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse).multiply(this.matrixWorld),bg.setFromProjectionMatrix(mi,e.coordinateSystem));let x=0;if(this.sortObjects){mi.copy(this.matrixWorld).invert(),Ml.setFromMatrixPosition(n.matrixWorld).applyMatrix4(mi),zv.set(0,0,-1).transformDirection(n.matrixWorld).transformDirection(mi);for(let v=0,_=c.length;v<_;v++)if(c[v].visible&&c[v].active){let y=c[v].geometryIndex;this.getMatrixAt(v,mi),this.getBoundingSphereAt(y,_o).applyMatrix4(mi);let b=!1;if(d&&(b=!bg.intersectsSphere(_o)),!b){let E=h[y],A=tT.subVectors(_o.center,Ml).dot(zv);Mg.push(E.start,E.count,A,v)}}let f=Mg.list,p=this.customSort;p===null?f.sort(s.transparent?$S:QS):p.call(this,f,n);for(let v=0,_=f.length;v<_;v++){let y=f[v];l[x]=y.start*a,u[x]=y.count,g[x]=y.index,x++}Mg.reset()}else for(let f=0,p=c.length;f<p;f++)if(c[f].visible&&c[f].active){let v=c[f].geometryIndex,_=!1;if(d&&(this.getMatrixAt(f,mi),this.getBoundingSphereAt(v,_o).applyMatrix4(mi),_=!bg.intersectsSphere(_o)),!_){let y=h[v];l[x]=y.start*a,u[x]=y.count,g[x]=f,x++}}m.needsUpdate=!0,this._multiDrawCount=x,this._visibilityChanged=!1}onBeforeShadow(e,t,n,r,s,o){this.onBeforeRender(e,null,r,s,o)}},Xt=class extends cn{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Ue(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}},gf=new z,xf=new z,Vv=new nt,El=new nr,Hd=new qt,Eg=new z,Hv=new z,ai=class extends St{constructor(e=new ot,t=new Xt){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,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(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,n=[0];for(let r=1,s=t.count;r<s;r++)gf.fromBufferAttribute(t,r-1),xf.fromBufferAttribute(t,r),n[r]=n[r-1],n[r]+=gf.distanceTo(xf);e.setAttribute("lineDistance",new ze(n,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){let n=this.geometry,r=this.matrixWorld,s=e.params.Line.threshold,o=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),Hd.copy(n.boundingSphere),Hd.applyMatrix4(r),Hd.radius+=s,e.ray.intersectsSphere(Hd)===!1)return;Vv.copy(r).invert(),El.copy(e.ray).applyMatrix4(Vv);let a=s/((this.scale.x+this.scale.y+this.scale.z)/3),c=a*a,l=this.isLineSegments?2:1,u=n.index,d=n.attributes.position;if(u!==null){let m=Math.max(0,o.start),g=Math.min(u.count,o.start+o.count);for(let x=m,f=g-1;x<f;x+=l){let p=u.getX(x),v=u.getX(x+1),_=Gd(this,e,El,c,p,v);_&&t.push(_)}if(this.isLineLoop){let x=u.getX(g-1),f=u.getX(m),p=Gd(this,e,El,c,x,f);p&&t.push(p)}}else{let m=Math.max(0,o.start),g=Math.min(d.count,o.start+o.count);for(let x=m,f=g-1;x<f;x+=l){let p=Gd(this,e,El,c,x,x+1);p&&t.push(p)}if(this.isLineLoop){let x=Gd(this,e,El,c,g-1,m);x&&t.push(x)}}}updateMorphTargets(){let t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){let r=t[n[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=r.length;s<o;s++){let a=r[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=s}}}}};function Gd(i,e,t,n,r,s){let o=i.geometry.attributes.position;if(gf.fromBufferAttribute(o,r),xf.fromBufferAttribute(o,s),t.distanceSqToSegment(gf,xf,Eg,Hv)>n)return;Eg.applyMatrix4(i.matrixWorld);let c=e.ray.origin.distanceTo(Eg);if(!(c<e.near||c>e.far))return{distance:c,point:Hv.clone().applyMatrix4(i.matrixWorld),index:r,face:null,faceIndex:null,barycoord:null,object:i}}var Gv=new z,Wv=new z,ln=class extends ai{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,n=[];for(let r=0,s=t.count;r<s;r+=2)Gv.fromBufferAttribute(t,r),Wv.fromBufferAttribute(t,r+1),n[r]=r===0?0:n[r-1],n[r+1]=n[r]+Gv.distanceTo(Wv);e.setAttribute("lineDistance",new ze(n,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}},es=class extends ai{constructor(e,t){super(e,t),this.isLineLoop=!0,this.type="LineLoop"}},Sr=class extends cn{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new Ue(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!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.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}},Xv=new nt,Lg=new nr,Wd=new qt,Xd=new z,ts=class extends St{constructor(e=new ot,t=new Sr){super(),this.isPoints=!0,this.type="Points",this.geometry=e,this.material=t,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}raycast(e,t){let n=this.geometry,r=this.matrixWorld,s=e.params.Points.threshold,o=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),Wd.copy(n.boundingSphere),Wd.applyMatrix4(r),Wd.radius+=s,e.ray.intersectsSphere(Wd)===!1)return;Xv.copy(r).invert(),Lg.copy(e.ray).applyMatrix4(Xv);let a=s/((this.scale.x+this.scale.y+this.scale.z)/3),c=a*a,l=n.index,h=n.attributes.position;if(l!==null){let d=Math.max(0,o.start),m=Math.min(l.count,o.start+o.count);for(let g=d,x=m;g<x;g++){let f=l.getX(g);Xd.fromBufferAttribute(h,f),Yv(Xd,f,c,r,e,t,this)}}else{let d=Math.max(0,o.start),m=Math.min(h.count,o.start+o.count);for(let g=d,x=m;g<x;g++)Xd.fromBufferAttribute(h,g),Yv(Xd,g,c,r,e,t,this)}}updateMorphTargets(){let t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){let r=t[n[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=r.length;s<o;s++){let a=r[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=s}}}}};function Yv(i,e,t,n,r,s,o){let a=Lg.distanceSqToPoint(i);if(a<t){let c=new z;Lg.closestPointToPoint(i,c),c.applyMatrix4(n);let l=r.ray.origin.distanceTo(c);if(l<r.near||l>r.far)return;s.push({distance:l,distanceToRay:Math.sqrt(a),point:c,index:e,face:null,faceIndex:null,barycoord:null,object:o})}}var Dt=class extends St{constructor(){super(),this.isGroup=!0,this.type="Group"}},yf=class extends Qt{constructor(e,t,n,r,s,o,a,c,l){super(e,t,n,r,s,o,a,c,l),this.isVideoTexture=!0,this.minFilter=o!==void 0?o:nn,this.magFilter=s!==void 0?s:nn,this.generateMipmaps=!1;let u=this;function h(){u.needsUpdate=!0,e.requestVideoFrameCallback(h)}"requestVideoFrameCallback"in e&&e.requestVideoFrameCallback(h)}clone(){return new this.constructor(this.image).copy(this)}update(){let e=this.image;"requestVideoFrameCallback"in e===!1&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}},vf=class extends Qt{constructor(e,t){super({width:e,height:t}),this.isFramebufferTexture=!0,this.magFilter=Jt,this.minFilter=Jt,this.generateMipmaps=!1,this.needsUpdate=!0}},Fo=class extends Qt{constructor(e,t,n,r,s,o,a,c,l,u,h,d){super(null,o,a,c,l,u,r,s,h,d),this.isCompressedTexture=!0,this.image={width:t,height:n},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}},_f=class extends Fo{constructor(e,t,n,r,s,o){super(e,t,n,s,o),this.isCompressedArrayTexture=!0,this.image.depth=r,this.wrapR=Mn,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}},bf=class extends Fo{constructor(e,t,n){super(void 0,e[0].width,e[0].height,t,n,Nr),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=e}},ns=class extends Qt{constructor(e,t,n,r,s,o,a,c,l){super(e,t,n,r,s,o,a,c,l),this.isCanvasTexture=!0,this.needsUpdate=!0}},Xs=class extends Qt{constructor(e,t,n,r,s,o,a,c,l,u=Ds){if(u!==Ds&&u!==Mr)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");n===void 0&&u===Ds&&(n=Lr),n===void 0&&u===Mr&&(n=Or),super(null,r,s,o,a,c,u,n,l),this.isDepthTexture=!0,this.image={width:e,height:t},this.magFilter=a!==void 0?a:Jt,this.minFilter=c!==void 0?c:Jt,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.compareFunction=e.compareFunction,this}toJSON(e){let t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}},vi=class{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(e,t){let n=this.getUtoTmapping(e);return this.getPoint(n,t)}getPoints(e=5){let t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return t}getSpacedPoints(e=5){let t=[];for(let n=0;n<=e;n++)t.push(this.getPointAt(n/e));return t}getLength(){let 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;let t=[],n,r=this.getPoint(0),s=0;t.push(0);for(let o=1;o<=e;o++)n=this.getPoint(o/e),s+=n.distanceTo(r),t.push(s),r=n;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){let n=this.getLengths(),r=0,s=n.length,o;t?o=t:o=e*n[s-1];let a=0,c=s-1,l;for(;a<=c;)if(r=Math.floor(a+(c-a)/2),l=n[r]-o,l<0)a=r+1;else if(l>0)c=r-1;else{c=r;break}if(r=c,n[r]===o)return r/(s-1);let u=n[r],d=n[r+1]-u,m=(o-u)/d;return(r+m)/(s-1)}getTangent(e,t){let r=e-1e-4,s=e+1e-4;r<0&&(r=0),s>1&&(s=1);let o=this.getPoint(r),a=this.getPoint(s),c=t||(o.isVector2?new Me:new z);return c.copy(a).sub(o).normalize(),c}getTangentAt(e,t){let n=this.getUtoTmapping(e);return this.getTangent(n,t)}computeFrenetFrames(e,t){let n=new z,r=[],s=[],o=[],a=new z,c=new nt;for(let m=0;m<=e;m++){let g=m/e;r[m]=this.getTangentAt(g,new z)}s[0]=new z,o[0]=new z;let l=Number.MAX_VALUE,u=Math.abs(r[0].x),h=Math.abs(r[0].y),d=Math.abs(r[0].z);u<=l&&(l=u,n.set(1,0,0)),h<=l&&(l=h,n.set(0,1,0)),d<=l&&n.set(0,0,1),a.crossVectors(r[0],n).normalize(),s[0].crossVectors(r[0],a),o[0].crossVectors(r[0],s[0]);for(let m=1;m<=e;m++){if(s[m]=s[m-1].clone(),o[m]=o[m-1].clone(),a.crossVectors(r[m-1],r[m]),a.length()>Number.EPSILON){a.normalize();let g=Math.acos(mt(r[m-1].dot(r[m]),-1,1));s[m].applyMatrix4(c.makeRotationAxis(a,g))}o[m].crossVectors(r[m],s[m])}if(t===!0){let m=Math.acos(mt(s[0].dot(s[e]),-1,1));m/=e,r[0].dot(a.crossVectors(s[0],s[e]))>0&&(m=-m);for(let g=1;g<=e;g++)s[g].applyMatrix4(c.makeRotationAxis(r[g],m*g)),o[g].crossVectors(r[g],s[g])}return{tangents:r,normals:s,binormals:o}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){let e={metadata:{version:4.6,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}},Uo=class extends vi{constructor(e=0,t=0,n=1,r=1,s=0,o=Math.PI*2,a=!1,c=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=n,this.yRadius=r,this.aStartAngle=s,this.aEndAngle=o,this.aClockwise=a,this.aRotation=c}getPoint(e,t=new Me){let n=t,r=Math.PI*2,s=this.aEndAngle-this.aStartAngle,o=Math.abs(s)<Number.EPSILON;for(;s<0;)s+=r;for(;s>r;)s-=r;s<Number.EPSILON&&(o?s=0:s=r),this.aClockwise===!0&&!o&&(s===r?s=-r:s=s-r);let a=this.aStartAngle+e*s,c=this.aX+this.xRadius*Math.cos(a),l=this.aY+this.yRadius*Math.sin(a);if(this.aRotation!==0){let u=Math.cos(this.aRotation),h=Math.sin(this.aRotation),d=c-this.aX,m=l-this.aY;c=d*u-m*h+this.aX,l=d*h+m*u+this.aY}return n.set(c,l)}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(){let 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}},zl=class extends Uo{constructor(e,t,n,r,s,o){super(e,t,n,n,r,s,o),this.isArcCurve=!0,this.type="ArcCurve"}};function w0(){let i=0,e=0,t=0,n=0;function r(s,o,a,c){i=s,e=a,t=-3*s+3*o-2*a-c,n=2*s-2*o+a+c}return{initCatmullRom:function(s,o,a,c,l){r(o,a,l*(a-s),l*(c-o))},initNonuniformCatmullRom:function(s,o,a,c,l,u,h){let d=(o-s)/l-(a-s)/(l+u)+(a-o)/u,m=(a-o)/u-(c-o)/(u+h)+(c-a)/h;d*=u,m*=u,r(o,a,d,m)},calc:function(s){let o=s*s,a=o*s;return i+e*s+t*o+n*a}}}var Yd=new z,Sg=new w0,Tg=new w0,Ag=new w0,Vl=class extends vi{constructor(e=[],t=!1,n="centripetal",r=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=e,this.closed=t,this.curveType=n,this.tension=r}getPoint(e,t=new z){let n=t,r=this.points,s=r.length,o=(s-(this.closed?0:1))*e,a=Math.floor(o),c=o-a;this.closed?a+=a>0?0:(Math.floor(Math.abs(a)/s)+1)*s:c===0&&a===s-1&&(a=s-2,c=1);let l,u;this.closed||a>0?l=r[(a-1)%s]:(Yd.subVectors(r[0],r[1]).add(r[0]),l=Yd);let h=r[a%s],d=r[(a+1)%s];if(this.closed||a+2<s?u=r[(a+2)%s]:(Yd.subVectors(r[s-1],r[s-2]).add(r[s-1]),u=Yd),this.curveType==="centripetal"||this.curveType==="chordal"){let m=this.curveType==="chordal"?.5:.25,g=Math.pow(l.distanceToSquared(h),m),x=Math.pow(h.distanceToSquared(d),m),f=Math.pow(d.distanceToSquared(u),m);x<1e-4&&(x=1),g<1e-4&&(g=x),f<1e-4&&(f=x),Sg.initNonuniformCatmullRom(l.x,h.x,d.x,u.x,g,x,f),Tg.initNonuniformCatmullRom(l.y,h.y,d.y,u.y,g,x,f),Ag.initNonuniformCatmullRom(l.z,h.z,d.z,u.z,g,x,f)}else this.curveType==="catmullrom"&&(Sg.initCatmullRom(l.x,h.x,d.x,u.x,this.tension),Tg.initCatmullRom(l.y,h.y,d.y,u.y,this.tension),Ag.initCatmullRom(l.z,h.z,d.z,u.z,this.tension));return n.set(Sg.calc(c),Tg.calc(c),Ag.calc(c)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){let r=e.points[t];this.points.push(r.clone())}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}toJSON(){let e=super.toJSON();e.points=[];for(let t=0,n=this.points.length;t<n;t++){let r=this.points[t];e.points.push(r.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,n=e.points.length;t<n;t++){let r=e.points[t];this.points.push(new z().fromArray(r))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}};function jv(i,e,t,n,r){let s=(n-e)*.5,o=(r-t)*.5,a=i*i,c=i*a;return(2*t-2*n+s+o)*c+(-3*t+3*n-2*s-o)*a+s*i+t}function iT(i,e){let t=1-i;return t*t*e}function rT(i,e){return 2*(1-i)*i*e}function sT(i,e){return i*i*e}function Rl(i,e,t,n){return iT(i,e)+rT(i,t)+sT(i,n)}function oT(i,e){let t=1-i;return t*t*t*e}function aT(i,e){let t=1-i;return 3*t*t*i*e}function cT(i,e){return 3*(1-i)*i*i*e}function lT(i,e){return i*i*i*e}function Cl(i,e,t,n,r){return oT(i,e)+aT(i,t)+cT(i,n)+lT(i,r)}var nc=class extends vi{constructor(e=new Me,t=new Me,n=new Me,r=new Me){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=n,this.v3=r}getPoint(e,t=new Me){let n=t,r=this.v0,s=this.v1,o=this.v2,a=this.v3;return n.set(Cl(e,r.x,s.x,o.x,a.x),Cl(e,r.y,s.y,o.y,a.y)),n}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(){let 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}},Hl=class extends vi{constructor(e=new z,t=new z,n=new z,r=new z){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=n,this.v3=r}getPoint(e,t=new z){let n=t,r=this.v0,s=this.v1,o=this.v2,a=this.v3;return n.set(Cl(e,r.x,s.x,o.x,a.x),Cl(e,r.y,s.y,o.y,a.y),Cl(e,r.z,s.z,o.z,a.z)),n}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(){let 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}},ic=class extends vi{constructor(e=new Me,t=new Me){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new Me){let n=t;return e===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(e).add(this.v1)),n}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new Me){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(){let 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}},Gl=class extends vi{constructor(e=new z,t=new z){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=e,this.v2=t}getPoint(e,t=new z){let n=t;return e===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(e).add(this.v1)),n}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new z){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(){let 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}},rc=class extends vi{constructor(e=new Me,t=new Me,n=new Me){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new Me){let n=t,r=this.v0,s=this.v1,o=this.v2;return n.set(Rl(e,r.x,s.x,o.x),Rl(e,r.y,s.y,o.y)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let 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}},sc=class extends vi{constructor(e=new z,t=new z,n=new z){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new z){let n=t,r=this.v0,s=this.v1,o=this.v2;return n.set(Rl(e,r.x,s.x,o.x),Rl(e,r.y,s.y,o.y),Rl(e,r.z,s.z,o.z)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let 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}},oc=class extends vi{constructor(e=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=e}getPoint(e,t=new Me){let n=t,r=this.points,s=(r.length-1)*e,o=Math.floor(s),a=s-o,c=r[o===0?o:o-1],l=r[o],u=r[o>r.length-2?r.length-1:o+1],h=r[o>r.length-3?r.length-1:o+2];return n.set(jv(a,c.x,l.x,u.x,h.x),jv(a,c.y,l.y,u.y,h.y)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){let r=e.points[t];this.points.push(r.clone())}return this}toJSON(){let e=super.toJSON();e.points=[];for(let t=0,n=this.points.length;t<n;t++){let r=this.points[t];e.points.push(r.toArray())}return e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){let r=e.points[t];this.points.push(new Me().fromArray(r))}return this}},Mf=Object.freeze({__proto__:null,ArcCurve:zl,CatmullRomCurve3:Vl,CubicBezierCurve:nc,CubicBezierCurve3:Hl,EllipseCurve:Uo,LineCurve:ic,LineCurve3:Gl,QuadraticBezierCurve:rc,QuadraticBezierCurve3:sc,SplineCurve:oc}),Wl=class extends vi{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(e){this.curves.push(e)}closePath(){let e=this.curves[0].getPoint(0),t=this.curves[this.curves.length-1].getPoint(1);if(!e.equals(t)){let n=e.isVector2===!0?"LineCurve":"LineCurve3";this.curves.push(new Mf[n](t,e))}return this}getPoint(e,t){let n=e*this.getLength(),r=this.getCurveLengths(),s=0;for(;s<r.length;){if(r[s]>=n){let o=r[s]-n,a=this.curves[s],c=a.getLength(),l=c===0?0:1-o/c;return a.getPointAt(l,t)}s++}return null}getLength(){let 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;let e=[],t=0;for(let n=0,r=this.curves.length;n<r;n++)t+=this.curves[n].getLength(),e.push(t);return this.cacheLengths=e,e}getSpacedPoints(e=40){let t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return this.autoClose&&t.push(t[0]),t}getPoints(e=12){let t=[],n;for(let r=0,s=this.curves;r<s.length;r++){let o=s[r],a=o.isEllipseCurve?e*2:o.isLineCurve||o.isLineCurve3?1:o.isSplineCurve?e*o.points.length:e,c=o.getPoints(a);for(let l=0;l<c.length;l++){let u=c[l];n&&n.equals(u)||(t.push(u),n=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,n=e.curves.length;t<n;t++){let r=e.curves[t];this.curves.push(r.clone())}return this.autoClose=e.autoClose,this}toJSON(){let e=super.toJSON();e.autoClose=this.autoClose,e.curves=[];for(let t=0,n=this.curves.length;t<n;t++){let r=this.curves[t];e.curves.push(r.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.autoClose=e.autoClose,this.curves=[];for(let t=0,n=e.curves.length;t<n;t++){let r=e.curves[t];this.curves.push(new Mf[r.type]().fromJSON(r))}return this}},Tr=class extends Wl{constructor(e){super(),this.type="Path",this.currentPoint=new Me,e&&this.setFromPoints(e)}setFromPoints(e){this.moveTo(e[0].x,e[0].y);for(let t=1,n=e.length;t<n;t++)this.lineTo(e[t].x,e[t].y);return this}moveTo(e,t){return this.currentPoint.set(e,t),this}lineTo(e,t){let n=new ic(this.currentPoint.clone(),new Me(e,t));return this.curves.push(n),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,n,r){let s=new rc(this.currentPoint.clone(),new Me(e,t),new Me(n,r));return this.curves.push(s),this.currentPoint.set(n,r),this}bezierCurveTo(e,t,n,r,s,o){let a=new nc(this.currentPoint.clone(),new Me(e,t),new Me(n,r),new Me(s,o));return this.curves.push(a),this.currentPoint.set(s,o),this}splineThru(e){let t=[this.currentPoint.clone()].concat(e),n=new oc(t);return this.curves.push(n),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,n,r,s,o){let a=this.currentPoint.x,c=this.currentPoint.y;return this.absarc(e+a,t+c,n,r,s,o),this}absarc(e,t,n,r,s,o){return this.absellipse(e,t,n,n,r,s,o),this}ellipse(e,t,n,r,s,o,a,c){let l=this.currentPoint.x,u=this.currentPoint.y;return this.absellipse(e+l,t+u,n,r,s,o,a,c),this}absellipse(e,t,n,r,s,o,a,c){let l=new Uo(e,t,n,r,s,o,a,c);if(this.curves.length>0){let h=l.getPoint(0);h.equals(this.currentPoint)||this.lineTo(h.x,h.y)}this.curves.push(l);let u=l.getPoint(1);return this.currentPoint.copy(u),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){let e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}},ac=class i extends ot{constructor(e=[new Me(0,-.5),new Me(.5,0),new Me(0,.5)],t=12,n=0,r=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:e,segments:t,phiStart:n,phiLength:r},t=Math.floor(t),r=mt(r,0,Math.PI*2);let s=[],o=[],a=[],c=[],l=[],u=1/t,h=new z,d=new Me,m=new z,g=new z,x=new z,f=0,p=0;for(let v=0;v<=e.length-1;v++)switch(v){case 0:f=e[v+1].x-e[v].x,p=e[v+1].y-e[v].y,m.x=p*1,m.y=-f,m.z=p*0,x.copy(m),m.normalize(),c.push(m.x,m.y,m.z);break;case e.length-1:c.push(x.x,x.y,x.z);break;default:f=e[v+1].x-e[v].x,p=e[v+1].y-e[v].y,m.x=p*1,m.y=-f,m.z=p*0,g.copy(m),m.x+=x.x,m.y+=x.y,m.z+=x.z,m.normalize(),c.push(m.x,m.y,m.z),x.copy(g)}for(let v=0;v<=t;v++){let _=n+v*u*r,y=Math.sin(_),b=Math.cos(_);for(let E=0;E<=e.length-1;E++){h.x=e[E].x*y,h.y=e[E].y,h.z=e[E].x*b,o.push(h.x,h.y,h.z),d.x=v/t,d.y=E/(e.length-1),a.push(d.x,d.y);let A=c[3*E+0]*y,T=c[3*E+1],M=c[3*E+0]*b;l.push(A,T,M)}}for(let v=0;v<t;v++)for(let _=0;_<e.length-1;_++){let y=_+v*e.length,b=y,E=y+e.length,A=y+e.length+1,T=y+1;s.push(b,E,T),s.push(A,T,E)}this.setIndex(s),this.setAttribute("position",new ze(o,3)),this.setAttribute("uv",new ze(a,2)),this.setAttribute("normal",new ze(l,3))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new i(e.points,e.segments,e.phiStart,e.phiLength)}},Xl=class i extends ac{constructor(e=1,t=1,n=4,r=8){let s=new Tr;s.absarc(0,-t/2,e,Math.PI*1.5,0),s.absarc(0,t/2,e,0,Math.PI*.5),super(s.getPoints(n),r),this.type="CapsuleGeometry",this.parameters={radius:e,length:t,capSegments:n,radialSegments:r}}static fromJSON(e){return new i(e.radius,e.length,e.capSegments,e.radialSegments)}},Yl=class i extends ot{constructor(e=1,t=32,n=0,r=Math.PI*2){super(),this.type="CircleGeometry",this.parameters={radius:e,segments:t,thetaStart:n,thetaLength:r},t=Math.max(3,t);let s=[],o=[],a=[],c=[],l=new z,u=new Me;o.push(0,0,0),a.push(0,0,1),c.push(.5,.5);for(let h=0,d=3;h<=t;h++,d+=3){let m=n+h/t*r;l.x=e*Math.cos(m),l.y=e*Math.sin(m),o.push(l.x,l.y,l.z),a.push(0,0,1),u.x=(o[d]/e+1)/2,u.y=(o[d+1]/e+1)/2,c.push(u.x,u.y)}for(let h=1;h<=t;h++)s.push(h,h+1,0);this.setIndex(s),this.setAttribute("position",new ze(o,3)),this.setAttribute("normal",new ze(a,3)),this.setAttribute("uv",new ze(c,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new i(e.radius,e.segments,e.thetaStart,e.thetaLength)}},is=class i extends ot{constructor(e=1,t=1,n=1,r=32,s=1,o=!1,a=0,c=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:n,radialSegments:r,heightSegments:s,openEnded:o,thetaStart:a,thetaLength:c};let l=this;r=Math.floor(r),s=Math.floor(s);let u=[],h=[],d=[],m=[],g=0,x=[],f=n/2,p=0;v(),o===!1&&(e>0&&_(!0),t>0&&_(!1)),this.setIndex(u),this.setAttribute("position",new ze(h,3)),this.setAttribute("normal",new ze(d,3)),this.setAttribute("uv",new ze(m,2));function v(){let y=new z,b=new z,E=0,A=(t-e)/n;for(let T=0;T<=s;T++){let M=[],S=T/s,C=S*(t-e)+e;for(let N=0;N<=r;N++){let I=N/r,L=I*c+a,q=Math.sin(L),K=Math.cos(L);b.x=C*q,b.y=-S*n+f,b.z=C*K,h.push(b.x,b.y,b.z),y.set(q,A,K).normalize(),d.push(y.x,y.y,y.z),m.push(I,1-S),M.push(g++)}x.push(M)}for(let T=0;T<r;T++)for(let M=0;M<s;M++){let S=x[M][T],C=x[M+1][T],N=x[M+1][T+1],I=x[M][T+1];(e>0||M!==0)&&(u.push(S,C,I),E+=3),(t>0||M!==s-1)&&(u.push(C,N,I),E+=3)}l.addGroup(p,E,0),p+=E}function _(y){let b=g,E=new Me,A=new z,T=0,M=y===!0?e:t,S=y===!0?1:-1;for(let N=1;N<=r;N++)h.push(0,f*S,0),d.push(0,S,0),m.push(.5,.5),g++;let C=g;for(let N=0;N<=r;N++){let L=N/r*c+a,q=Math.cos(L),K=Math.sin(L);A.x=M*K,A.y=f*S,A.z=M*q,h.push(A.x,A.y,A.z),d.push(0,S,0),E.x=q*.5+.5,E.y=K*.5*S+.5,m.push(E.x,E.y),g++}for(let N=0;N<r;N++){let I=b+N,L=C+N;y===!0?u.push(L,L+1,I):u.push(L+1,L,I),T+=3}l.addGroup(p,T,y===!0?1:2),p+=T}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new i(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}},ko=class i extends is{constructor(e=1,t=1,n=32,r=1,s=!1,o=0,a=Math.PI*2){super(0,e,t,n,r,s,o,a),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:n,heightSegments:r,openEnded:s,thetaStart:o,thetaLength:a}}static fromJSON(e){return new i(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}},rs=class i extends ot{constructor(e=[],t=[],n=1,r=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:n,detail:r};let s=[],o=[];a(r),l(n),u(),this.setAttribute("position",new ze(s,3)),this.setAttribute("normal",new ze(s.slice(),3)),this.setAttribute("uv",new ze(o,2)),r===0?this.computeVertexNormals():this.normalizeNormals();function a(v){let _=new z,y=new z,b=new z;for(let E=0;E<t.length;E+=3)m(t[E+0],_),m(t[E+1],y),m(t[E+2],b),c(_,y,b,v)}function c(v,_,y,b){let E=b+1,A=[];for(let T=0;T<=E;T++){A[T]=[];let M=v.clone().lerp(y,T/E),S=_.clone().lerp(y,T/E),C=E-T;for(let N=0;N<=C;N++)N===0&&T===E?A[T][N]=M:A[T][N]=M.clone().lerp(S,N/C)}for(let T=0;T<E;T++)for(let M=0;M<2*(E-T)-1;M++){let S=Math.floor(M/2);M%2===0?(d(A[T][S+1]),d(A[T+1][S]),d(A[T][S])):(d(A[T][S+1]),d(A[T+1][S+1]),d(A[T+1][S]))}}function l(v){let _=new z;for(let y=0;y<s.length;y+=3)_.x=s[y+0],_.y=s[y+1],_.z=s[y+2],_.normalize().multiplyScalar(v),s[y+0]=_.x,s[y+1]=_.y,s[y+2]=_.z}function u(){let v=new z;for(let _=0;_<s.length;_+=3){v.x=s[_+0],v.y=s[_+1],v.z=s[_+2];let y=f(v)/2/Math.PI+.5,b=p(v)/Math.PI+.5;o.push(y,1-b)}g(),h()}function h(){for(let v=0;v<o.length;v+=6){let _=o[v+0],y=o[v+2],b=o[v+4],E=Math.max(_,y,b),A=Math.min(_,y,b);E>.9&&A<.1&&(_<.2&&(o[v+0]+=1),y<.2&&(o[v+2]+=1),b<.2&&(o[v+4]+=1))}}function d(v){s.push(v.x,v.y,v.z)}function m(v,_){let y=v*3;_.x=e[y+0],_.y=e[y+1],_.z=e[y+2]}function g(){let v=new z,_=new z,y=new z,b=new z,E=new Me,A=new Me,T=new Me;for(let M=0,S=0;M<s.length;M+=9,S+=6){v.set(s[M+0],s[M+1],s[M+2]),_.set(s[M+3],s[M+4],s[M+5]),y.set(s[M+6],s[M+7],s[M+8]),E.set(o[S+0],o[S+1]),A.set(o[S+2],o[S+3]),T.set(o[S+4],o[S+5]),b.copy(v).add(_).add(y).divideScalar(3);let C=f(b);x(E,S+0,v,C),x(A,S+2,_,C),x(T,S+4,y,C)}}function x(v,_,y,b){b<0&&v.x===1&&(o[_]=v.x-1),y.x===0&&y.z===0&&(o[_]=b/2/Math.PI+.5)}function f(v){return Math.atan2(v.z,-v.x)}function p(v){return Math.atan2(-v.y,Math.sqrt(v.x*v.x+v.z*v.z))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new i(e.vertices,e.indices,e.radius,e.details)}},jl=class i extends rs{constructor(e=1,t=0){let n=(1+Math.sqrt(5))/2,r=1/n,s=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-r,-n,0,-r,n,0,r,-n,0,r,n,-r,-n,0,-r,n,0,r,-n,0,r,n,0,-n,0,-r,n,0,-r,-n,0,r,n,0,r],o=[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9];super(s,o,e,t),this.type="DodecahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new i(e.radius,e.detail)}},jd=new z,qd=new z,wg=new z,Kd=new Oi,ss=class extends ot{constructor(e=null,t=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:e,thresholdAngle:t},e!==null){let r=Math.pow(10,4),s=Math.cos(Ro*t),o=e.getIndex(),a=e.getAttribute("position"),c=o?o.count:a.count,l=[0,0,0],u=["a","b","c"],h=new Array(3),d={},m=[];for(let g=0;g<c;g+=3){o?(l[0]=o.getX(g),l[1]=o.getX(g+1),l[2]=o.getX(g+2)):(l[0]=g,l[1]=g+1,l[2]=g+2);let{a:x,b:f,c:p}=Kd;if(x.fromBufferAttribute(a,l[0]),f.fromBufferAttribute(a,l[1]),p.fromBufferAttribute(a,l[2]),Kd.getNormal(wg),h[0]=`${Math.round(x.x*r)},${Math.round(x.y*r)},${Math.round(x.z*r)}`,h[1]=`${Math.round(f.x*r)},${Math.round(f.y*r)},${Math.round(f.z*r)}`,h[2]=`${Math.round(p.x*r)},${Math.round(p.y*r)},${Math.round(p.z*r)}`,!(h[0]===h[1]||h[1]===h[2]||h[2]===h[0]))for(let v=0;v<3;v++){let _=(v+1)%3,y=h[v],b=h[_],E=Kd[u[v]],A=Kd[u[_]],T=`${y}_${b}`,M=`${b}_${y}`;M in d&&d[M]?(wg.dot(d[M].normal)<=s&&(m.push(E.x,E.y,E.z),m.push(A.x,A.y,A.z)),d[M]=null):T in d||(d[T]={index0:l[v],index1:l[_],normal:wg.clone()})}}for(let g in d)if(d[g]){let{index0:x,index1:f}=d[g];jd.fromBufferAttribute(a,x),qd.fromBufferAttribute(a,f),m.push(jd.x,jd.y,jd.z),m.push(qd.x,qd.y,qd.z)}this.setAttribute("position",new ze(m,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}},Fi=class extends Tr{constructor(e){super(e),this.uuid=Di(),this.type="Shape",this.holes=[]}getPointsHoles(e){let t=[];for(let n=0,r=this.holes.length;n<r;n++)t[n]=this.holes[n].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,n=e.holes.length;t<n;t++){let r=e.holes[t];this.holes.push(r.clone())}return this}toJSON(){let e=super.toJSON();e.uuid=this.uuid,e.holes=[];for(let t=0,n=this.holes.length;t<n;t++){let r=this.holes[t];e.holes.push(r.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.uuid=e.uuid,this.holes=[];for(let t=0,n=e.holes.length;t<n;t++){let r=e.holes[t];this.holes.push(new Tr().fromJSON(r))}return this}},uT={triangulate:function(i,e,t=2){let n=e&&e.length,r=n?e[0]*t:i.length,s=nb(i,0,r,t,!0),o=[];if(!s||s.next===s.prev)return o;let a,c,l,u,h,d,m;if(n&&(s=mT(i,e,s,t)),i.length>80*t){a=l=i[0],c=u=i[1];for(let g=t;g<r;g+=t)h=i[g],d=i[g+1],h<a&&(a=h),d<c&&(c=d),h>l&&(l=h),d>u&&(u=d);m=Math.max(l-a,u-c),m=m!==0?32767/m:0}return ql(s,o,t,a,c,m,0),o}};function nb(i,e,t,n,r){let s,o;if(r===AT(i,e,t,n)>0)for(s=e;s<t;s+=n)o=qv(s,i[s],i[s+1],o);else for(s=t-n;s>=e;s-=n)o=qv(s,i[s],i[s+1],o);return o&&Ep(o,o.next)&&(Zl(o),o=o.next),o}function Bo(i,e){if(!i)return i;e||(e=i);let t=i,n;do if(n=!1,!t.steiner&&(Ep(t,t.next)||an(t.prev,t,t.next)===0)){if(Zl(t),t=e=t.prev,t===t.next)break;n=!0}else t=t.next;while(n||t!==e);return e}function ql(i,e,t,n,r,s,o){if(!i)return;!o&&s&&_T(i,n,r,s);let a=i,c,l;for(;i.prev!==i.next;){if(c=i.prev,l=i.next,s?dT(i,n,r,s):hT(i)){e.push(c.i/t|0),e.push(i.i/t|0),e.push(l.i/t|0),Zl(i),i=l.next,a=l.next;continue}if(i=l,i===a){o?o===1?(i=fT(Bo(i),e,t),ql(i,e,t,n,r,s,2)):o===2&&pT(i,e,t,n,r,s):ql(Bo(i),e,t,n,r,s,1);break}}}function hT(i){let e=i.prev,t=i,n=i.next;if(an(e,t,n)>=0)return!1;let r=e.x,s=t.x,o=n.x,a=e.y,c=t.y,l=n.y,u=r<s?r<o?r:o:s<o?s:o,h=a<c?a<l?a:l:c<l?c:l,d=r>s?r>o?r:o:s>o?s:o,m=a>c?a>l?a:l:c>l?c:l,g=n.next;for(;g!==e;){if(g.x>=u&&g.x<=d&&g.y>=h&&g.y<=m&&Ya(r,a,s,c,o,l,g.x,g.y)&&an(g.prev,g,g.next)>=0)return!1;g=g.next}return!0}function dT(i,e,t,n){let r=i.prev,s=i,o=i.next;if(an(r,s,o)>=0)return!1;let a=r.x,c=s.x,l=o.x,u=r.y,h=s.y,d=o.y,m=a<c?a<l?a:l:c<l?c:l,g=u<h?u<d?u:d:h<d?h:d,x=a>c?a>l?a:l:c>l?c:l,f=u>h?u>d?u:d:h>d?h:d,p=Og(m,g,e,t,n),v=Og(x,f,e,t,n),_=i.prevZ,y=i.nextZ;for(;_&&_.z>=p&&y&&y.z<=v;){if(_.x>=m&&_.x<=x&&_.y>=g&&_.y<=f&&_!==r&&_!==o&&Ya(a,u,c,h,l,d,_.x,_.y)&&an(_.prev,_,_.next)>=0||(_=_.prevZ,y.x>=m&&y.x<=x&&y.y>=g&&y.y<=f&&y!==r&&y!==o&&Ya(a,u,c,h,l,d,y.x,y.y)&&an(y.prev,y,y.next)>=0))return!1;y=y.nextZ}for(;_&&_.z>=p;){if(_.x>=m&&_.x<=x&&_.y>=g&&_.y<=f&&_!==r&&_!==o&&Ya(a,u,c,h,l,d,_.x,_.y)&&an(_.prev,_,_.next)>=0)return!1;_=_.prevZ}for(;y&&y.z<=v;){if(y.x>=m&&y.x<=x&&y.y>=g&&y.y<=f&&y!==r&&y!==o&&Ya(a,u,c,h,l,d,y.x,y.y)&&an(y.prev,y,y.next)>=0)return!1;y=y.nextZ}return!0}function fT(i,e,t){let n=i;do{let r=n.prev,s=n.next.next;!Ep(r,s)&&ib(r,n,n.next,s)&&Kl(r,s)&&Kl(s,r)&&(e.push(r.i/t|0),e.push(n.i/t|0),e.push(s.i/t|0),Zl(n),Zl(n.next),n=i=s),n=n.next}while(n!==i);return Bo(n)}function pT(i,e,t,n,r,s){let o=i;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&ET(o,a)){let c=rb(o,a);o=Bo(o,o.next),c=Bo(c,c.next),ql(o,e,t,n,r,s,0),ql(c,e,t,n,r,s,0);return}a=a.next}o=o.next}while(o!==i)}function mT(i,e,t,n){let r=[],s,o,a,c,l;for(s=0,o=e.length;s<o;s++)a=e[s]*n,c=s<o-1?e[s+1]*n:i.length,l=nb(i,a,c,n,!1),l===l.next&&(l.steiner=!0),r.push(MT(l));for(r.sort(gT),s=0;s<r.length;s++)t=xT(r[s],t);return t}function gT(i,e){return i.x-e.x}function xT(i,e){let t=yT(i,e);if(!t)return e;let n=rb(t,i);return Bo(n,n.next),Bo(t,t.next)}function yT(i,e){let t=e,n=-1/0,r,s=i.x,o=i.y;do{if(o<=t.y&&o>=t.next.y&&t.next.y!==t.y){let d=t.x+(o-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(d<=s&&d>n&&(n=d,r=t.x<t.next.x?t:t.next,d===s))return r}t=t.next}while(t!==e);if(!r)return null;let a=r,c=r.x,l=r.y,u=1/0,h;t=r;do s>=t.x&&t.x>=c&&s!==t.x&&Ya(o<l?s:n,o,c,l,o<l?n:s,o,t.x,t.y)&&(h=Math.abs(o-t.y)/(s-t.x),Kl(t,i)&&(h<u||h===u&&(t.x>r.x||t.x===r.x&&vT(r,t)))&&(r=t,u=h)),t=t.next;while(t!==a);return r}function vT(i,e){return an(i.prev,i,e.prev)<0&&an(e.next,i,i.next)<0}function _T(i,e,t,n){let r=i;do r.z===0&&(r.z=Og(r.x,r.y,e,t,n)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==i);r.prevZ.nextZ=null,r.prevZ=null,bT(r)}function bT(i){let e,t,n,r,s,o,a,c,l=1;do{for(t=i,i=null,s=null,o=0;t;){for(o++,n=t,a=0,e=0;e<l&&(a++,n=n.nextZ,!!n);e++);for(c=l;a>0||c>0&&n;)a!==0&&(c===0||!n||t.z<=n.z)?(r=t,t=t.nextZ,a--):(r=n,n=n.nextZ,c--),s?s.nextZ=r:i=r,r.prevZ=s,s=r;t=n}s.nextZ=null,l*=2}while(o>1);return i}function Og(i,e,t,n,r){return i=(i-t)*r|0,e=(e-n)*r|0,i=(i|i<<8)&16711935,i=(i|i<<4)&252645135,i=(i|i<<2)&858993459,i=(i|i<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,i|e<<1}function MT(i){let e=i,t=i;do(e.x<t.x||e.x===t.x&&e.y<t.y)&&(t=e),e=e.next;while(e!==i);return t}function Ya(i,e,t,n,r,s,o,a){return(r-o)*(e-a)>=(i-o)*(s-a)&&(i-o)*(n-a)>=(t-o)*(e-a)&&(t-o)*(s-a)>=(r-o)*(n-a)}function ET(i,e){return i.next.i!==e.i&&i.prev.i!==e.i&&!ST(i,e)&&(Kl(i,e)&&Kl(e,i)&&TT(i,e)&&(an(i.prev,i,e.prev)||an(i,e.prev,e))||Ep(i,e)&&an(i.prev,i,i.next)>0&&an(e.prev,e,e.next)>0)}function an(i,e,t){return(e.y-i.y)*(t.x-e.x)-(e.x-i.x)*(t.y-e.y)}function Ep(i,e){return i.x===e.x&&i.y===e.y}function ib(i,e,t,n){let r=Jd(an(i,e,t)),s=Jd(an(i,e,n)),o=Jd(an(t,n,i)),a=Jd(an(t,n,e));return!!(r!==s&&o!==a||r===0&&Zd(i,t,e)||s===0&&Zd(i,n,e)||o===0&&Zd(t,i,n)||a===0&&Zd(t,e,n))}function Zd(i,e,t){return e.x<=Math.max(i.x,t.x)&&e.x>=Math.min(i.x,t.x)&&e.y<=Math.max(i.y,t.y)&&e.y>=Math.min(i.y,t.y)}function Jd(i){return i>0?1:i<0?-1:0}function ST(i,e){let t=i;do{if(t.i!==i.i&&t.next.i!==i.i&&t.i!==e.i&&t.next.i!==e.i&&ib(t,t.next,i,e))return!0;t=t.next}while(t!==i);return!1}function Kl(i,e){return an(i.prev,i,i.next)<0?an(i,e,i.next)>=0&&an(i,i.prev,e)>=0:an(i,e,i.prev)<0||an(i,i.next,e)<0}function TT(i,e){let t=i,n=!1,r=(i.x+e.x)/2,s=(i.y+e.y)/2;do t.y>s!=t.next.y>s&&t.next.y!==t.y&&r<(t.next.x-t.x)*(s-t.y)/(t.next.y-t.y)+t.x&&(n=!n),t=t.next;while(t!==i);return n}function rb(i,e){let t=new Dg(i.i,i.x,i.y),n=new Dg(e.i,e.x,e.y),r=i.next,s=e.prev;return i.next=e,e.prev=i,t.next=r,r.prev=t,n.next=t,t.prev=n,s.next=n,n.prev=s,n}function qv(i,e,t,n){let r=new Dg(i,e,t);return n?(r.next=n.next,r.prev=n,n.next.prev=r,n.next=r):(r.prev=r,r.next=r),r}function Zl(i){i.next.prev=i.prev,i.prev.next=i.next,i.prevZ&&(i.prevZ.nextZ=i.nextZ),i.nextZ&&(i.nextZ.prevZ=i.prevZ)}function Dg(i,e,t){this.i=i,this.x=e,this.y=t,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function AT(i,e,t,n){let r=0;for(let s=e,o=t-n;s<t;s+=n)r+=(i[o]-i[s])*(i[s+1]+i[o+1]),o=s;return r}var Ui=class i{static area(e){let t=e.length,n=0;for(let r=t-1,s=0;s<t;r=s++)n+=e[r].x*e[s].y-e[s].x*e[r].y;return n*.5}static isClockWise(e){return i.area(e)<0}static triangulateShape(e,t){let n=[],r=[],s=[];Kv(e),Zv(n,e);let o=e.length;t.forEach(Kv);for(let c=0;c<t.length;c++)r.push(o),o+=t[c].length,Zv(n,t[c]);let a=uT.triangulate(n,r);for(let c=0;c<a.length;c+=3)s.push(a.slice(c,c+3));return s}};function Kv(i){let e=i.length;e>2&&i[e-1].equals(i[0])&&i.pop()}function Zv(i,e){for(let t=0;t<e.length;t++)i.push(e[t].x),i.push(e[t].y)}var Ys=class i extends ot{constructor(e=new Fi([new Me(.5,.5),new Me(-.5,.5),new Me(-.5,-.5),new Me(.5,-.5)]),t={}){super(),this.type="ExtrudeGeometry",this.parameters={shapes:e,options:t},e=Array.isArray(e)?e:[e];let n=this,r=[],s=[];for(let a=0,c=e.length;a<c;a++){let l=e[a];o(l)}this.setAttribute("position",new ze(r,3)),this.setAttribute("uv",new ze(s,2)),this.computeVertexNormals();function o(a){let c=[],l=t.curveSegments!==void 0?t.curveSegments:12,u=t.steps!==void 0?t.steps:1,h=t.depth!==void 0?t.depth:1,d=t.bevelEnabled!==void 0?t.bevelEnabled:!0,m=t.bevelThickness!==void 0?t.bevelThickness:.2,g=t.bevelSize!==void 0?t.bevelSize:m-.1,x=t.bevelOffset!==void 0?t.bevelOffset:0,f=t.bevelSegments!==void 0?t.bevelSegments:3,p=t.extrudePath,v=t.UVGenerator!==void 0?t.UVGenerator:wT,_,y=!1,b,E,A,T;p&&(_=p.getSpacedPoints(u),y=!0,d=!1,b=p.computeFrenetFrames(u,!1),E=new z,A=new z,T=new z),d||(f=0,m=0,g=0,x=0);let M=a.extractPoints(l),S=M.shape,C=M.holes;if(!Ui.isClockWise(S)){S=S.reverse();for(let oe=0,ue=C.length;oe<ue;oe++){let H=C[oe];Ui.isClockWise(H)&&(C[oe]=H.reverse())}}let I=Ui.triangulateShape(S,C),L=S;for(let oe=0,ue=C.length;oe<ue;oe++){let H=C[oe];S=S.concat(H)}function q(oe,ue,H){return ue||console.error("THREE.ExtrudeGeometry: vec does not exist"),oe.clone().addScaledVector(ue,H)}let K=S.length,B=I.length;function j(oe,ue,H){let Ie,Te,Oe,Re=oe.x-ue.x,We=oe.y-ue.y,Ae=H.x-oe.x,Y=H.y-oe.y,F=Re*Re+We*We,D=Re*Y-We*Ae;if(Math.abs(D)>Number.EPSILON){let P=Math.sqrt(F),U=Math.sqrt(Ae*Ae+Y*Y),X=ue.x-We/P,Z=ue.y+Re/P,$=H.x-Y/U,te=H.y+Ae/U,ae=(($-X)*Y-(te-Z)*Ae)/(Re*Y-We*Ae);Ie=X+Re*ae-oe.x,Te=Z+We*ae-oe.y;let re=Ie*Ie+Te*Te;if(re<=2)return new Me(Ie,Te);Oe=Math.sqrt(re/2)}else{let P=!1;Re>Number.EPSILON?Ae>Number.EPSILON&&(P=!0):Re<-Number.EPSILON?Ae<-Number.EPSILON&&(P=!0):Math.sign(We)===Math.sign(Y)&&(P=!0),P?(Ie=-We,Te=Re,Oe=Math.sqrt(F)):(Ie=Re,Te=We,Oe=Math.sqrt(F/2))}return new Me(Ie/Oe,Te/Oe)}let J=[];for(let oe=0,ue=L.length,H=ue-1,Ie=oe+1;oe<ue;oe++,H++,Ie++)H===ue&&(H=0),Ie===ue&&(Ie=0),J[oe]=j(L[oe],L[H],L[Ie]);let se=[],ce,me=J.concat();for(let oe=0,ue=C.length;oe<ue;oe++){let H=C[oe];ce=[];for(let Ie=0,Te=H.length,Oe=Te-1,Re=Ie+1;Ie<Te;Ie++,Oe++,Re++)Oe===Te&&(Oe=0),Re===Te&&(Re=0),ce[Ie]=j(H[Ie],H[Oe],H[Re]);se.push(ce),me=me.concat(ce)}for(let oe=0;oe<f;oe++){let ue=oe/f,H=m*Math.cos(ue*Math.PI/2),Ie=g*Math.sin(ue*Math.PI/2)+x;for(let Te=0,Oe=L.length;Te<Oe;Te++){let Re=q(L[Te],J[Te],Ie);W(Re.x,Re.y,-H)}for(let Te=0,Oe=C.length;Te<Oe;Te++){let Re=C[Te];ce=se[Te];for(let We=0,Ae=Re.length;We<Ae;We++){let Y=q(Re[We],ce[We],Ie);W(Y.x,Y.y,-H)}}}let Se=g+x;for(let oe=0;oe<K;oe++){let ue=d?q(S[oe],me[oe],Se):S[oe];y?(A.copy(b.normals[0]).multiplyScalar(ue.x),E.copy(b.binormals[0]).multiplyScalar(ue.y),T.copy(_[0]).add(A).add(E),W(T.x,T.y,T.z)):W(ue.x,ue.y,0)}for(let oe=1;oe<=u;oe++)for(let ue=0;ue<K;ue++){let H=d?q(S[ue],me[ue],Se):S[ue];y?(A.copy(b.normals[oe]).multiplyScalar(H.x),E.copy(b.binormals[oe]).multiplyScalar(H.y),T.copy(_[oe]).add(A).add(E),W(T.x,T.y,T.z)):W(H.x,H.y,h/u*oe)}for(let oe=f-1;oe>=0;oe--){let ue=oe/f,H=m*Math.cos(ue*Math.PI/2),Ie=g*Math.sin(ue*Math.PI/2)+x;for(let Te=0,Oe=L.length;Te<Oe;Te++){let Re=q(L[Te],J[Te],Ie);W(Re.x,Re.y,h+H)}for(let Te=0,Oe=C.length;Te<Oe;Te++){let Re=C[Te];ce=se[Te];for(let We=0,Ae=Re.length;We<Ae;We++){let Y=q(Re[We],ce[We],Ie);y?W(Y.x,Y.y+_[u-1].y,_[u-1].x+H):W(Y.x,Y.y,h+H)}}}V(),w();function V(){let oe=r.length/3;if(d){let ue=0,H=K*ue;for(let Ie=0;Ie<B;Ie++){let Te=I[Ie];Q(Te[2]+H,Te[1]+H,Te[0]+H)}ue=u+f*2,H=K*ue;for(let Ie=0;Ie<B;Ie++){let Te=I[Ie];Q(Te[0]+H,Te[1]+H,Te[2]+H)}}else{for(let ue=0;ue<B;ue++){let H=I[ue];Q(H[2],H[1],H[0])}for(let ue=0;ue<B;ue++){let H=I[ue];Q(H[0]+K*u,H[1]+K*u,H[2]+K*u)}}n.addGroup(oe,r.length/3-oe,0)}function w(){let oe=r.length/3,ue=0;O(L,ue),ue+=L.length;for(let H=0,Ie=C.length;H<Ie;H++){let Te=C[H];O(Te,ue),ue+=Te.length}n.addGroup(oe,r.length/3-oe,1)}function O(oe,ue){let H=oe.length;for(;--H>=0;){let Ie=H,Te=H-1;Te<0&&(Te=oe.length-1);for(let Oe=0,Re=u+f*2;Oe<Re;Oe++){let We=K*Oe,Ae=K*(Oe+1),Y=ue+Ie+We,F=ue+Te+We,D=ue+Te+Ae,P=ue+Ie+Ae;ee(Y,F,D,P)}}}function W(oe,ue,H){c.push(oe),c.push(ue),c.push(H)}function Q(oe,ue,H){he(oe),he(ue),he(H);let Ie=r.length/3,Te=v.generateTopUV(n,r,Ie-3,Ie-2,Ie-1);Ce(Te[0]),Ce(Te[1]),Ce(Te[2])}function ee(oe,ue,H,Ie){he(oe),he(ue),he(Ie),he(ue),he(H),he(Ie);let Te=r.length/3,Oe=v.generateSideWallUV(n,r,Te-6,Te-3,Te-2,Te-1);Ce(Oe[0]),Ce(Oe[1]),Ce(Oe[3]),Ce(Oe[1]),Ce(Oe[2]),Ce(Oe[3])}function he(oe){r.push(c[oe*3+0]),r.push(c[oe*3+1]),r.push(c[oe*3+2])}function Ce(oe){s.push(oe.x),s.push(oe.y)}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){let e=super.toJSON(),t=this.parameters.shapes,n=this.parameters.options;return RT(t,n,e)}static fromJSON(e,t){let n=[];for(let s=0,o=e.shapes.length;s<o;s++){let a=t[e.shapes[s]];n.push(a)}let r=e.options.extrudePath;return r!==void 0&&(e.options.extrudePath=new Mf[r.type]().fromJSON(r)),new i(n,e.options)}},wT={generateTopUV:function(i,e,t,n,r){let s=e[t*3],o=e[t*3+1],a=e[n*3],c=e[n*3+1],l=e[r*3],u=e[r*3+1];return[new Me(s,o),new Me(a,c),new Me(l,u)]},generateSideWallUV:function(i,e,t,n,r,s){let o=e[t*3],a=e[t*3+1],c=e[t*3+2],l=e[n*3],u=e[n*3+1],h=e[n*3+2],d=e[r*3],m=e[r*3+1],g=e[r*3+2],x=e[s*3],f=e[s*3+1],p=e[s*3+2];return Math.abs(a-u)<Math.abs(o-l)?[new Me(o,1-c),new Me(l,1-h),new Me(d,1-g),new Me(x,1-p)]:[new Me(a,1-c),new Me(u,1-h),new Me(m,1-g),new Me(f,1-p)]}};function RT(i,e,t){if(t.shapes=[],Array.isArray(i))for(let n=0,r=i.length;n<r;n++){let s=i[n];t.shapes.push(s.uuid)}else t.shapes.push(i.uuid);return t.options=Object.assign({},e),e.extrudePath!==void 0&&(t.options.extrudePath=e.extrudePath.toJSON()),t}var Jl=class i extends rs{constructor(e=1,t=0){let n=(1+Math.sqrt(5))/2,r=[-1,n,0,1,n,0,-1,-n,0,1,-n,0,0,-1,n,0,1,n,0,-1,-n,0,1,-n,n,0,-1,n,0,1,-n,0,-1,-n,0,1],s=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1];super(r,s,e,t),this.type="IcosahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new i(e.radius,e.detail)}},cc=class i extends rs{constructor(e=1,t=0){let n=[1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],r=[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2];super(n,r,e,t),this.type="OctahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new i(e.radius,e.detail)}},Ar=class i extends ot{constructor(e=1,t=1,n=1,r=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:n,heightSegments:r};let s=e/2,o=t/2,a=Math.floor(n),c=Math.floor(r),l=a+1,u=c+1,h=e/a,d=t/c,m=[],g=[],x=[],f=[];for(let p=0;p<u;p++){let v=p*d-o;for(let _=0;_<l;_++){let y=_*h-s;g.push(y,-v,0),x.push(0,0,1),f.push(_/a),f.push(1-p/c)}}for(let p=0;p<c;p++)for(let v=0;v<a;v++){let _=v+l*p,y=v+l*(p+1),b=v+1+l*(p+1),E=v+1+l*p;m.push(_,y,E),m.push(y,b,E)}this.setIndex(m),this.setAttribute("position",new ze(g,3)),this.setAttribute("normal",new ze(x,3)),this.setAttribute("uv",new ze(f,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new i(e.width,e.height,e.widthSegments,e.heightSegments)}},Ql=class i extends ot{constructor(e=.5,t=1,n=32,r=1,s=0,o=Math.PI*2){super(),this.type="RingGeometry",this.parameters={innerRadius:e,outerRadius:t,thetaSegments:n,phiSegments:r,thetaStart:s,thetaLength:o},n=Math.max(3,n),r=Math.max(1,r);let a=[],c=[],l=[],u=[],h=e,d=(t-e)/r,m=new z,g=new Me;for(let x=0;x<=r;x++){for(let f=0;f<=n;f++){let p=s+f/n*o;m.x=h*Math.cos(p),m.y=h*Math.sin(p),c.push(m.x,m.y,m.z),l.push(0,0,1),g.x=(m.x/t+1)/2,g.y=(m.y/t+1)/2,u.push(g.x,g.y)}h+=d}for(let x=0;x<r;x++){let f=x*(n+1);for(let p=0;p<n;p++){let v=p+f,_=v,y=v+n+1,b=v+n+2,E=v+1;a.push(_,y,E),a.push(y,b,E)}}this.setIndex(a),this.setAttribute("position",new ze(c,3)),this.setAttribute("normal",new ze(l,3)),this.setAttribute("uv",new ze(u,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new i(e.innerRadius,e.outerRadius,e.thetaSegments,e.phiSegments,e.thetaStart,e.thetaLength)}},$l=class i extends ot{constructor(e=new Fi([new Me(0,.5),new Me(-.5,-.5),new Me(.5,-.5)]),t=12){super(),this.type="ShapeGeometry",this.parameters={shapes:e,curveSegments:t};let n=[],r=[],s=[],o=[],a=0,c=0;if(Array.isArray(e)===!1)l(e);else for(let u=0;u<e.length;u++)l(e[u]),this.addGroup(a,c,u),a+=c,c=0;this.setIndex(n),this.setAttribute("position",new ze(r,3)),this.setAttribute("normal",new ze(s,3)),this.setAttribute("uv",new ze(o,2));function l(u){let h=r.length/3,d=u.extractPoints(t),m=d.shape,g=d.holes;Ui.isClockWise(m)===!1&&(m=m.reverse());for(let f=0,p=g.length;f<p;f++){let v=g[f];Ui.isClockWise(v)===!0&&(g[f]=v.reverse())}let x=Ui.triangulateShape(m,g);for(let f=0,p=g.length;f<p;f++){let v=g[f];m=m.concat(v)}for(let f=0,p=m.length;f<p;f++){let v=m[f];r.push(v.x,v.y,0),s.push(0,0,1),o.push(v.x,v.y)}for(let f=0,p=x.length;f<p;f++){let v=x[f],_=v[0]+h,y=v[1]+h,b=v[2]+h;n.push(_,y,b),c+=3}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){let e=super.toJSON(),t=this.parameters.shapes;return CT(t,e)}static fromJSON(e,t){let n=[];for(let r=0,s=e.shapes.length;r<s;r++){let o=t[e.shapes[r]];n.push(o)}return new i(n,e.curveSegments)}};function CT(i,e){if(e.shapes=[],Array.isArray(i))for(let t=0,n=i.length;t<n;t++){let r=i[t];e.shapes.push(r.uuid)}else e.shapes.push(i.uuid);return e}var _i=class i extends ot{constructor(e=1,t=32,n=16,r=0,s=Math.PI*2,o=0,a=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:n,phiStart:r,phiLength:s,thetaStart:o,thetaLength:a},t=Math.max(3,Math.floor(t)),n=Math.max(2,Math.floor(n));let c=Math.min(o+a,Math.PI),l=0,u=[],h=new z,d=new z,m=[],g=[],x=[],f=[];for(let p=0;p<=n;p++){let v=[],_=p/n,y=0;p===0&&o===0?y=.5/t:p===n&&c===Math.PI&&(y=-.5/t);for(let b=0;b<=t;b++){let E=b/t;h.x=-e*Math.cos(r+E*s)*Math.sin(o+_*a),h.y=e*Math.cos(o+_*a),h.z=e*Math.sin(r+E*s)*Math.sin(o+_*a),g.push(h.x,h.y,h.z),d.copy(h).normalize(),x.push(d.x,d.y,d.z),f.push(E+y,1-_),v.push(l++)}u.push(v)}for(let p=0;p<n;p++)for(let v=0;v<t;v++){let _=u[p][v+1],y=u[p][v],b=u[p+1][v],E=u[p+1][v+1];(p!==0||o>0)&&m.push(_,y,E),(p!==n-1||c<Math.PI)&&m.push(y,b,E)}this.setIndex(m),this.setAttribute("position",new ze(g,3)),this.setAttribute("normal",new ze(x,3)),this.setAttribute("uv",new ze(f,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new i(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}},eu=class i extends rs{constructor(e=1,t=0){let n=[1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],r=[2,1,0,0,3,2,1,3,0,2,3,1];super(n,r,e,t),this.type="TetrahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new i(e.radius,e.detail)}},tu=class i extends ot{constructor(e=1,t=.4,n=12,r=48,s=Math.PI*2){super(),this.type="TorusGeometry",this.parameters={radius:e,tube:t,radialSegments:n,tubularSegments:r,arc:s},n=Math.floor(n),r=Math.floor(r);let o=[],a=[],c=[],l=[],u=new z,h=new z,d=new z;for(let m=0;m<=n;m++)for(let g=0;g<=r;g++){let x=g/r*s,f=m/n*Math.PI*2;h.x=(e+t*Math.cos(f))*Math.cos(x),h.y=(e+t*Math.cos(f))*Math.sin(x),h.z=t*Math.sin(f),a.push(h.x,h.y,h.z),u.x=e*Math.cos(x),u.y=e*Math.sin(x),d.subVectors(h,u).normalize(),c.push(d.x,d.y,d.z),l.push(g/r),l.push(m/n)}for(let m=1;m<=n;m++)for(let g=1;g<=r;g++){let x=(r+1)*m+g-1,f=(r+1)*(m-1)+g-1,p=(r+1)*(m-1)+g,v=(r+1)*m+g;o.push(x,f,v),o.push(f,p,v)}this.setIndex(o),this.setAttribute("position",new ze(a,3)),this.setAttribute("normal",new ze(c,3)),this.setAttribute("uv",new ze(l,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new i(e.radius,e.tube,e.radialSegments,e.tubularSegments,e.arc)}},nu=class i extends ot{constructor(e=1,t=.4,n=64,r=8,s=2,o=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:e,tube:t,tubularSegments:n,radialSegments:r,p:s,q:o},n=Math.floor(n),r=Math.floor(r);let a=[],c=[],l=[],u=[],h=new z,d=new z,m=new z,g=new z,x=new z,f=new z,p=new z;for(let _=0;_<=n;++_){let y=_/n*s*Math.PI*2;v(y,s,o,e,m),v(y+.01,s,o,e,g),f.subVectors(g,m),p.addVectors(g,m),x.crossVectors(f,p),p.crossVectors(x,f),x.normalize(),p.normalize();for(let b=0;b<=r;++b){let E=b/r*Math.PI*2,A=-t*Math.cos(E),T=t*Math.sin(E);h.x=m.x+(A*p.x+T*x.x),h.y=m.y+(A*p.y+T*x.y),h.z=m.z+(A*p.z+T*x.z),c.push(h.x,h.y,h.z),d.subVectors(h,m).normalize(),l.push(d.x,d.y,d.z),u.push(_/n),u.push(b/r)}}for(let _=1;_<=n;_++)for(let y=1;y<=r;y++){let b=(r+1)*(_-1)+(y-1),E=(r+1)*_+(y-1),A=(r+1)*_+y,T=(r+1)*(_-1)+y;a.push(b,E,T),a.push(E,A,T)}this.setIndex(a),this.setAttribute("position",new ze(c,3)),this.setAttribute("normal",new ze(l,3)),this.setAttribute("uv",new ze(u,2));function v(_,y,b,E,A){let T=Math.cos(_),M=Math.sin(_),S=b/y*_,C=Math.cos(S);A.x=E*(2+C)*.5*T,A.y=E*(2+C)*M*.5,A.z=E*Math.sin(S)*.5}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new i(e.radius,e.tube,e.tubularSegments,e.radialSegments,e.p,e.q)}},iu=class i extends ot{constructor(e=new sc(new z(-1,-1,0),new z(-1,1,0),new z(1,1,0)),t=64,n=1,r=8,s=!1){super(),this.type="TubeGeometry",this.parameters={path:e,tubularSegments:t,radius:n,radialSegments:r,closed:s};let o=e.computeFrenetFrames(t,s);this.tangents=o.tangents,this.normals=o.normals,this.binormals=o.binormals;let a=new z,c=new z,l=new Me,u=new z,h=[],d=[],m=[],g=[];x(),this.setIndex(g),this.setAttribute("position",new ze(h,3)),this.setAttribute("normal",new ze(d,3)),this.setAttribute("uv",new ze(m,2));function x(){for(let _=0;_<t;_++)f(_);f(s===!1?t:0),v(),p()}function f(_){u=e.getPointAt(_/t,u);let y=o.normals[_],b=o.binormals[_];for(let E=0;E<=r;E++){let A=E/r*Math.PI*2,T=Math.sin(A),M=-Math.cos(A);c.x=M*y.x+T*b.x,c.y=M*y.y+T*b.y,c.z=M*y.z+T*b.z,c.normalize(),d.push(c.x,c.y,c.z),a.x=u.x+n*c.x,a.y=u.y+n*c.y,a.z=u.z+n*c.z,h.push(a.x,a.y,a.z)}}function p(){for(let _=1;_<=t;_++)for(let y=1;y<=r;y++){let b=(r+1)*(_-1)+(y-1),E=(r+1)*_+(y-1),A=(r+1)*_+y,T=(r+1)*(_-1)+y;g.push(b,E,T),g.push(E,A,T)}}function v(){for(let _=0;_<=t;_++)for(let y=0;y<=r;y++)l.x=_/t,l.y=y/r,m.push(l.x,l.y)}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){let e=super.toJSON();return e.path=this.parameters.path.toJSON(),e}static fromJSON(e){return new i(new Mf[e.path.type]().fromJSON(e.path),e.tubularSegments,e.radius,e.radialSegments,e.closed)}},ru=class extends ot{constructor(e=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:e},e!==null){let t=[],n=new Set,r=new z,s=new z;if(e.index!==null){let o=e.attributes.position,a=e.index,c=e.groups;c.length===0&&(c=[{start:0,count:a.count,materialIndex:0}]);for(let l=0,u=c.length;l<u;++l){let h=c[l],d=h.start,m=h.count;for(let g=d,x=d+m;g<x;g+=3)for(let f=0;f<3;f++){let p=a.getX(g+f),v=a.getX(g+(f+1)%3);r.fromBufferAttribute(o,p),s.fromBufferAttribute(o,v),Jv(r,s,n)===!0&&(t.push(r.x,r.y,r.z),t.push(s.x,s.y,s.z))}}}else{let o=e.attributes.position;for(let a=0,c=o.count/3;a<c;a++)for(let l=0;l<3;l++){let u=3*a+l,h=3*a+(l+1)%3;r.fromBufferAttribute(o,u),s.fromBufferAttribute(o,h),Jv(r,s,n)===!0&&(t.push(r.x,r.y,r.z),t.push(s.x,s.y,s.z))}}this.setAttribute("position",new ze(t,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}};function Jv(i,e,t){let n=`${i.x},${i.y},${i.z}-${e.x},${e.y},${e.z}`,r=`${e.x},${e.y},${e.z}-${i.x},${i.y},${i.z}`;return t.has(n)===!0||t.has(r)===!0?!1:(t.add(n),t.add(r),!0)}var Qv=Object.freeze({__proto__:null,BoxGeometry:Qn,CapsuleGeometry:Xl,CircleGeometry:Yl,ConeGeometry:ko,CylinderGeometry:is,DodecahedronGeometry:jl,EdgesGeometry:ss,ExtrudeGeometry:Ys,IcosahedronGeometry:Jl,LatheGeometry:ac,OctahedronGeometry:cc,PlaneGeometry:Ar,PolyhedronGeometry:rs,RingGeometry:Ql,ShapeGeometry:$l,SphereGeometry:_i,TetrahedronGeometry:eu,TorusGeometry:tu,TorusKnotGeometry:nu,TubeGeometry:iu,WireframeGeometry:ru}),su=class extends cn{constructor(e){super(),this.isShadowMaterial=!0,this.type="ShadowMaterial",this.color=new Ue(0),this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.fog=e.fog,this}},zo=class extends $t{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}},En=class extends cn{constructor(e){super(),this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new Ue(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ue(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=ds,this.normalScale=new Me(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new yi,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}},Dn=class extends En{constructor(e){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new Me(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return mt(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+.4*t)/(1-.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new Ue(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new Ue(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new Ue(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._dispersion=0,this._iridescence=0,this._sheen=0,this._transmission=0,this.setValues(e)}get anisotropy(){return this._anisotropy}set anisotropy(e){this._anisotropy>0!=e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get dispersion(){return this._dispersion}set dispersion(e){this._dispersion>0!=e>0&&this.version++,this._dispersion=e}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.dispersion=e.dispersion,this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}},Vo=class extends cn{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new Ue(16777215),this.specular=new Ue(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ue(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=ds,this.normalScale=new Me(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new yi,this.combine=vc,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,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.flatShading=e.flatShading,this.fog=e.fog,this}},ou=class extends cn{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new Ue(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ue(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=ds,this.normalScale=new Me(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,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.gradientMap=e.gradientMap,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}},Ho=class extends cn{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=ds,this.normalScale=new Me(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this}},au=class extends cn{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new Ue(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ue(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=ds,this.normalScale=new Me(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new yi,this.combine=vc,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,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.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,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.flatShading=e.flatShading,this.fog=e.fog,this}},lc=class extends cn{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=f0,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}},uc=class extends cn{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}},cu=class extends cn{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new Ue(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=ds,this.normalScale=new Me(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={MATCAP:""},this.color.copy(e.color),this.matcap=e.matcap,this.map=e.map,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.flatShading=e.flatShading,this.fog=e.fog,this}},lu=class extends Xt{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}};function wo(i,e,t){return!i||!t&&i.constructor===e?i:typeof e.BYTES_PER_ELEMENT=="number"?new e(i):Array.prototype.slice.call(i)}function sb(i){return ArrayBuffer.isView(i)&&!(i instanceof DataView)}function ob(i){function e(r,s){return i[r]-i[s]}let t=i.length,n=new Array(t);for(let r=0;r!==t;++r)n[r]=r;return n.sort(e),n}function Fg(i,e,t){let n=i.length,r=new i.constructor(n);for(let s=0,o=0;o!==n;++s){let a=t[s]*e;for(let c=0;c!==e;++c)r[o++]=i[a+c]}return r}function R0(i,e,t,n){let r=1,s=i[0];for(;s!==void 0&&s[n]===void 0;)s=i[r++];if(s===void 0)return;let o=s[n];if(o!==void 0)if(Array.isArray(o))do o=s[n],o!==void 0&&(e.push(s.time),t.push.apply(t,o)),s=i[r++];while(s!==void 0);else if(o.toArray!==void 0)do o=s[n],o!==void 0&&(e.push(s.time),o.toArray(t,t.length)),s=i[r++];while(s!==void 0);else do o=s[n],o!==void 0&&(e.push(s.time),t.push(o)),s=i[r++];while(s!==void 0)}function PT(i,e,t,n,r=30){let s=i.clone();s.name=e;let o=[];for(let c=0;c<s.tracks.length;++c){let l=s.tracks[c],u=l.getValueSize(),h=[],d=[];for(let m=0;m<l.times.length;++m){let g=l.times[m]*r;if(!(g<t||g>=n)){h.push(l.times[m]);for(let x=0;x<u;++x)d.push(l.values[m*u+x])}}h.length!==0&&(l.times=wo(h,l.times.constructor),l.values=wo(d,l.values.constructor),o.push(l))}s.tracks=o;let a=1/0;for(let c=0;c<s.tracks.length;++c)a>s.tracks[c].times[0]&&(a=s.tracks[c].times[0]);for(let c=0;c<s.tracks.length;++c)s.tracks[c].shift(-1*a);return s.resetDuration(),s}function IT(i,e=0,t=i,n=30){n<=0&&(n=30);let r=t.tracks.length,s=e/n;for(let o=0;o<r;++o){let a=t.tracks[o],c=a.ValueTypeName;if(c==="bool"||c==="string")continue;let l=i.tracks.find(function(p){return p.name===a.name&&p.ValueTypeName===c});if(l===void 0)continue;let u=0,h=a.getValueSize();a.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(u=h/3);let d=0,m=l.getValueSize();l.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(d=m/3);let g=a.times.length-1,x;if(s<=a.times[0]){let p=u,v=h-u;x=a.values.slice(p,v)}else if(s>=a.times[g]){let p=g*h+u,v=p+h-u;x=a.values.slice(p,v)}else{let p=a.createInterpolant(),v=u,_=h-u;p.evaluate(s),x=p.resultBuffer.slice(v,_)}c==="quaternion"&&new Zt().fromArray(x).normalize().conjugate().toArray(x);let f=l.times.length;for(let p=0;p<f;++p){let v=p*m+d;if(c==="quaternion")Zt.multiplyQuaternionsFlat(l.values,v,x,0,l.values,v);else{let _=m-d*2;for(let y=0;y<_;++y)l.values[v+y]-=x[y]}}}return i.blendMode=yp,i}var ab={convertArray:wo,isTypedArray:sb,getKeyframeOrder:ob,sortedArray:Fg,flattenJSON:R0,subclip:PT,makeClipAdditive:IT},wr=class{constructor(e,t,n,r){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=r!==void 0?r:new t.constructor(n),this.sampleValues=t,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(e){let t=this.parameterPositions,n=this._cachedIndex,r=t[n],s=t[n-1];e:{t:{let o;n:{i:if(!(e<r)){for(let a=n+2;;){if(r===void 0){if(e<s)break i;return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===a)break;if(s=r,r=t[++n],e<r)break t}o=t.length;break n}if(!(e>=s)){let a=t[1];e<a&&(n=2,s=a);for(let c=n-2;;){if(s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===c)break;if(r=s,s=t[--n-1],e>=s)break t}o=n,n=0;break n}break e}for(;n<o;){let a=n+o>>>1;e<t[a]?o=a:n=a+1}if(r=t[n],s=t[n-1],s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(r===void 0)return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,s,r)}return this.interpolate_(n,s,e,r)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){let t=this.resultBuffer,n=this.sampleValues,r=this.valueSize,s=e*r;for(let o=0;o!==r;++o)t[o]=n[s+o];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}},uu=class extends wr{constructor(e,t,n,r){super(e,t,n,r),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:Ls,endingEnd:Ls}}intervalChanged_(e,t,n){let r=this.parameterPositions,s=e-2,o=e+1,a=r[s],c=r[o];if(a===void 0)switch(this.getSettings_().endingStart){case Os:s=e,a=2*t-n;break;case qa:s=r.length-2,a=t+r[s]-r[s+1];break;default:s=e,a=n}if(c===void 0)switch(this.getSettings_().endingEnd){case Os:o=e,c=2*n-t;break;case qa:o=1,c=n+r[1]-r[0];break;default:o=e-1,c=t}let l=(n-t)*.5,u=this.valueSize;this._weightPrev=l/(t-a),this._weightNext=l/(c-n),this._offsetPrev=s*u,this._offsetNext=o*u}interpolate_(e,t,n,r){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,c=e*a,l=c-a,u=this._offsetPrev,h=this._offsetNext,d=this._weightPrev,m=this._weightNext,g=(n-t)/(r-t),x=g*g,f=x*g,p=-d*f+2*d*x-d*g,v=(1+d)*f+(-1.5-2*d)*x+(-.5+d)*g+1,_=(-1-m)*f+(1.5+m)*x+.5*g,y=m*f-m*x;for(let b=0;b!==a;++b)s[b]=p*o[u+b]+v*o[l+b]+_*o[c+b]+y*o[h+b];return s}},hc=class extends wr{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e,t,n,r){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,c=e*a,l=c-a,u=(n-t)/(r-t),h=1-u;for(let d=0;d!==a;++d)s[d]=o[l+d]*h+o[c+d]*u;return s}},hu=class extends wr{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e){return this.copySampleValue_(e-1)}},bi=class{constructor(e,t,n,r){if(e===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(t===void 0||t.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=wo(t,this.TimeBufferType),this.values=wo(n,this.ValueBufferType),this.setInterpolation(r||this.DefaultInterpolation)}static toJSON(e){let t=e.constructor,n;if(t.toJSON!==this.toJSON)n=t.toJSON(e);else{n={name:e.name,times:wo(e.times,Array),values:wo(e.values,Array)};let r=e.getInterpolation();r!==e.DefaultInterpolation&&(n.interpolation=r)}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new hu(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new hc(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new uu(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case Bs:t=this.InterpolantFactoryMethodDiscrete;break;case zs:t=this.InterpolantFactoryMethodLinear;break;case Al:t=this.InterpolantFactoryMethodSmooth;break}if(t===void 0){let n="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(n);return console.warn("THREE.KeyframeTrack:",n),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return Bs;case this.InterpolantFactoryMethodLinear:return zs;case this.InterpolantFactoryMethodSmooth:return Al}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){let t=this.times;for(let n=0,r=t.length;n!==r;++n)t[n]+=e}return this}scale(e){if(e!==1){let t=this.times;for(let n=0,r=t.length;n!==r;++n)t[n]*=e}return this}trim(e,t){let n=this.times,r=n.length,s=0,o=r-1;for(;s!==r&&n[s]<e;)++s;for(;o!==-1&&n[o]>t;)--o;if(++o,s!==0||o!==r){s>=o&&(o=Math.max(o,1),s=o-1);let a=this.getValueSize();this.times=n.slice(s,o),this.values=this.values.slice(s*a,o*a)}return this}validate(){let e=!0,t=this.getValueSize();t-Math.floor(t)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);let n=this.times,r=this.values,s=n.length;s===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let o=null;for(let a=0;a!==s;a++){let c=n[a];if(typeof c=="number"&&isNaN(c)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,a,c),e=!1;break}if(o!==null&&o>c){console.error("THREE.KeyframeTrack: Out of order keys.",this,a,c,o),e=!1;break}o=c}if(r!==void 0&&sb(r))for(let a=0,c=r.length;a!==c;++a){let l=r[a];if(isNaN(l)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,a,l),e=!1;break}}return e}optimize(){let e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),r=this.getInterpolation()===Al,s=e.length-1,o=1;for(let a=1;a<s;++a){let c=!1,l=e[a],u=e[a+1];if(l!==u&&(a!==1||l!==e[0]))if(r)c=!0;else{let h=a*n,d=h-n,m=h+n;for(let g=0;g!==n;++g){let x=t[h+g];if(x!==t[d+g]||x!==t[m+g]){c=!0;break}}}if(c){if(a!==o){e[o]=e[a];let h=a*n,d=o*n;for(let m=0;m!==n;++m)t[d+m]=t[h+m]}++o}}if(s>0){e[o]=e[s];for(let a=s*n,c=o*n,l=0;l!==n;++l)t[c+l]=t[a+l];++o}return o!==e.length?(this.times=e.slice(0,o),this.values=t.slice(0,o*n)):(this.times=e,this.values=t),this}clone(){let e=this.times.slice(),t=this.values.slice(),n=this.constructor,r=new n(this.name,e,t);return r.createInterpolant=this.createInterpolant,r}};bi.prototype.TimeBufferType=Float32Array;bi.prototype.ValueBufferType=Float32Array;bi.prototype.DefaultInterpolation=zs;var Rr=class extends bi{constructor(e,t,n){super(e,t,n)}};Rr.prototype.ValueTypeName="bool";Rr.prototype.ValueBufferType=Array;Rr.prototype.DefaultInterpolation=Bs;Rr.prototype.InterpolantFactoryMethodLinear=void 0;Rr.prototype.InterpolantFactoryMethodSmooth=void 0;var dc=class extends bi{};dc.prototype.ValueTypeName="color";var rr=class extends bi{};rr.prototype.ValueTypeName="number";var du=class extends wr{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e,t,n,r){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,c=(n-t)/(r-t),l=e*a;for(let u=l+a;l!==u;l+=4)Zt.slerpFlat(s,0,o,l-a,o,l,c);return s}},sr=class extends bi{InterpolantFactoryMethodLinear(e){return new du(this.times,this.values,this.getValueSize(),e)}};sr.prototype.ValueTypeName="quaternion";sr.prototype.InterpolantFactoryMethodSmooth=void 0;var Cr=class extends bi{constructor(e,t,n){super(e,t,n)}};Cr.prototype.ValueTypeName="string";Cr.prototype.ValueBufferType=Array;Cr.prototype.DefaultInterpolation=Bs;Cr.prototype.InterpolantFactoryMethodLinear=void 0;Cr.prototype.InterpolantFactoryMethodSmooth=void 0;var or=class extends bi{};or.prototype.ValueTypeName="vector";var Pr=class{constructor(e="",t=-1,n=[],r=yh){this.name=e,this.tracks=n,this.duration=t,this.blendMode=r,this.uuid=Di(),this.duration<0&&this.resetDuration()}static parse(e){let t=[],n=e.tracks,r=1/(e.fps||1);for(let o=0,a=n.length;o!==a;++o)t.push(LT(n[o]).scale(r));let s=new this(e.name,e.duration,t,e.blendMode);return s.uuid=e.uuid,s}static toJSON(e){let t=[],n=e.tracks,r={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let s=0,o=n.length;s!==o;++s)t.push(bi.toJSON(n[s]));return r}static CreateFromMorphTargetSequence(e,t,n,r){let s=t.length,o=[];for(let a=0;a<s;a++){let c=[],l=[];c.push((a+s-1)%s,a,(a+1)%s),l.push(0,1,0);let u=ob(c);c=Fg(c,1,u),l=Fg(l,1,u),!r&&c[0]===0&&(c.push(s),l.push(l[0])),o.push(new rr(".morphTargetInfluences["+t[a].name+"]",c,l).scale(1/n))}return new this(e,-1,o)}static findByName(e,t){let n=e;if(!Array.isArray(e)){let r=e;n=r.geometry&&r.geometry.animations||r.animations}for(let r=0;r<n.length;r++)if(n[r].name===t)return n[r];return null}static CreateClipsFromMorphTargetSequences(e,t,n){let r={},s=/^([\w-]*?)([\d]+)$/;for(let a=0,c=e.length;a<c;a++){let l=e[a],u=l.name.match(s);if(u&&u.length>1){let h=u[1],d=r[h];d||(r[h]=d=[]),d.push(l)}}let o=[];for(let a in r)o.push(this.CreateFromMorphTargetSequence(a,r[a],t,n));return o}static parseAnimation(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;let n=function(h,d,m,g,x){if(m.length!==0){let f=[],p=[];R0(m,f,p,g),f.length!==0&&x.push(new h(d,f,p))}},r=[],s=e.name||"default",o=e.fps||30,a=e.blendMode,c=e.length||-1,l=e.hierarchy||[];for(let h=0;h<l.length;h++){let d=l[h].keys;if(!(!d||d.length===0))if(d[0].morphTargets){let m={},g;for(g=0;g<d.length;g++)if(d[g].morphTargets)for(let x=0;x<d[g].morphTargets.length;x++)m[d[g].morphTargets[x]]=-1;for(let x in m){let f=[],p=[];for(let v=0;v!==d[g].morphTargets.length;++v){let _=d[g];f.push(_.time),p.push(_.morphTarget===x?1:0)}r.push(new rr(".morphTargetInfluence["+x+"]",f,p))}c=m.length*o}else{let m=".bones["+t[h].name+"]";n(or,m+".position",d,"pos",r),n(sr,m+".quaternion",d,"rot",r),n(or,m+".scale",d,"scl",r)}}return r.length===0?null:new this(s,c,r,a)}resetDuration(){let e=this.tracks,t=0;for(let n=0,r=e.length;n!==r;++n){let s=this.tracks[n];t=Math.max(t,s.times[s.times.length-1])}return this.duration=t,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){let e=[];for(let t=0;t<this.tracks.length;t++)e.push(this.tracks[t].clone());return new this.constructor(this.name,this.duration,e,this.blendMode)}toJSON(){return this.constructor.toJSON(this)}};function NT(i){switch(i.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return rr;case"vector":case"vector2":case"vector3":case"vector4":return or;case"color":return dc;case"quaternion":return sr;case"bool":case"boolean":return Rr;case"string":return Cr}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+i)}function LT(i){if(i.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");let e=NT(i.type);if(i.times===void 0){let t=[],n=[];R0(i.keys,t,n,"value"),i.times=t,i.values=n}return e.parse!==void 0?e.parse(i):new e(i.name,i.times,i.values,i.interpolation)}var br={enabled:!1,files:{},add:function(i,e){this.enabled!==!1&&(this.files[i]=e)},get:function(i){if(this.enabled!==!1)return this.files[i]},remove:function(i){delete this.files[i]},clear:function(){this.files={}}},fc=class{constructor(e,t,n){let r=this,s=!1,o=0,a=0,c,l=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this.itemStart=function(u){a++,s===!1&&r.onStart!==void 0&&r.onStart(u,o,a),s=!0},this.itemEnd=function(u){o++,r.onProgress!==void 0&&r.onProgress(u,o,a),o===a&&(s=!1,r.onLoad!==void 0&&r.onLoad())},this.itemError=function(u){r.onError!==void 0&&r.onError(u)},this.resolveURL=function(u){return c?c(u):u},this.setURLModifier=function(u){return c=u,this},this.addHandler=function(u,h){return l.push(u,h),this},this.removeHandler=function(u){let h=l.indexOf(u);return h!==-1&&l.splice(h,2),this},this.getHandler=function(u){for(let h=0,d=l.length;h<d;h+=2){let m=l[h],g=l[h+1];if(m.global&&(m.lastIndex=0),m.test(u))return g}return null}}},C0=new fc,rn=class{constructor(e){this.manager=e!==void 0?e:C0,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){let n=this;return new Promise(function(r,s){n.load(e,r,t,s)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}};rn.DEFAULT_MATERIAL_NAME="__DEFAULT";var Zr={},Ug=class extends Error{constructor(e,t){super(e),this.response=t}},Vn=class extends rn{constructor(e){super(e)}load(e,t,n,r){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);let s=br.get(e);if(s!==void 0)return this.manager.itemStart(e),setTimeout(()=>{t&&t(s),this.manager.itemEnd(e)},0),s;if(Zr[e]!==void 0){Zr[e].push({onLoad:t,onProgress:n,onError:r});return}Zr[e]=[],Zr[e].push({onLoad:t,onProgress:n,onError:r});let o=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),a=this.mimeType,c=this.responseType;fetch(o).then(l=>{if(l.status===200||l.status===0){if(l.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||l.body===void 0||l.body.getReader===void 0)return l;let u=Zr[e],h=l.body.getReader(),d=l.headers.get("X-File-Size")||l.headers.get("Content-Length"),m=d?parseInt(d):0,g=m!==0,x=0,f=new ReadableStream({start(p){v();function v(){h.read().then(({done:_,value:y})=>{if(_)p.close();else{x+=y.byteLength;let b=new ProgressEvent("progress",{lengthComputable:g,loaded:x,total:m});for(let E=0,A=u.length;E<A;E++){let T=u[E];T.onProgress&&T.onProgress(b)}p.enqueue(y),v()}},_=>{p.error(_)})}}});return new Response(f)}else throw new Ug(`fetch for "${l.url}" responded with ${l.status}: ${l.statusText}`,l)}).then(l=>{switch(c){case"arraybuffer":return l.arrayBuffer();case"blob":return l.blob();case"document":return l.text().then(u=>new DOMParser().parseFromString(u,a));case"json":return l.json();default:if(a===void 0)return l.text();{let h=/charset="?([^;"\s]*)"?/i.exec(a),d=h&&h[1]?h[1].toLowerCase():void 0,m=new TextDecoder(d);return l.arrayBuffer().then(g=>m.decode(g))}}}).then(l=>{br.add(e,l);let u=Zr[e];delete Zr[e];for(let h=0,d=u.length;h<d;h++){let m=u[h];m.onLoad&&m.onLoad(l)}}).catch(l=>{let u=Zr[e];if(u===void 0)throw this.manager.itemError(e),l;delete Zr[e];for(let h=0,d=u.length;h<d;h++){let m=u[h];m.onError&&m.onError(l)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}},Ef=class extends rn{constructor(e){super(e)}load(e,t,n,r){let s=this,o=new Vn(this.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,function(a){try{t(s.parse(JSON.parse(a)))}catch(c){r?r(c):console.error(c),s.manager.itemError(e)}},n,r)}parse(e){let t=[];for(let n=0;n<e.length;n++){let r=Pr.parse(e[n]);t.push(r)}return t}},Sf=class extends rn{constructor(e){super(e)}load(e,t,n,r){let s=this,o=[],a=new Fo,c=new Vn(this.manager);c.setPath(this.path),c.setResponseType("arraybuffer"),c.setRequestHeader(this.requestHeader),c.setWithCredentials(s.withCredentials);let l=0;function u(h){c.load(e[h],function(d){let m=s.parse(d,!0);o[h]={width:m.width,height:m.height,format:m.format,mipmaps:m.mipmaps},l+=1,l===6&&(m.mipmapCount===1&&(a.minFilter=nn),a.image=o,a.format=m.format,a.needsUpdate=!0,t&&t(a))},n,r)}if(Array.isArray(e))for(let h=0,d=e.length;h<d;++h)u(h);else c.load(e,function(h){let d=s.parse(h,!0);if(d.isCubemap){let m=d.mipmaps.length/d.mipmapCount;for(let g=0;g<m;g++){o[g]={mipmaps:[]};for(let x=0;x<d.mipmapCount;x++)o[g].mipmaps.push(d.mipmaps[g*d.mipmapCount+x]),o[g].format=d.format,o[g].width=d.width,o[g].height=d.height}a.image=o}else a.image.width=d.width,a.image.height=d.height,a.mipmaps=d.mipmaps;d.mipmapCount===1&&(a.minFilter=nn),a.format=d.format,a.needsUpdate=!0,t&&t(a)},n,r);return a}},js=class extends rn{constructor(e){super(e)}load(e,t,n,r){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);let s=this,o=br.get(e);if(o!==void 0)return s.manager.itemStart(e),setTimeout(function(){t&&t(o),s.manager.itemEnd(e)},0),o;let a=Qa("img");function c(){u(),br.add(e,this),t&&t(this),s.manager.itemEnd(e)}function l(h){u(),r&&r(h),s.manager.itemError(e),s.manager.itemEnd(e)}function u(){a.removeEventListener("load",c,!1),a.removeEventListener("error",l,!1)}return a.addEventListener("load",c,!1),a.addEventListener("error",l,!1),e.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(a.crossOrigin=this.crossOrigin),s.manager.itemStart(e),a.src=e,a}},Tf=class extends rn{constructor(e){super(e)}load(e,t,n,r){let s=new Vs;s.colorSpace=wt;let o=new js(this.manager);o.setCrossOrigin(this.crossOrigin),o.setPath(this.path);let a=0;function c(l){o.load(e[l],function(u){s.images[l]=u,a++,a===6&&(s.needsUpdate=!0,t&&t(s))},void 0,r)}for(let l=0;l<e.length;++l)c(l);return s}},Af=class extends rn{constructor(e){super(e)}load(e,t,n,r){let s=this,o=new An,a=new Vn(this.manager);return a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setPath(this.path),a.setWithCredentials(s.withCredentials),a.load(e,function(c){let l;try{l=s.parse(c)}catch(u){if(r!==void 0)r(u);else{console.error(u);return}}l.image!==void 0?o.image=l.image:l.data!==void 0&&(o.image.width=l.width,o.image.height=l.height,o.image.data=l.data),o.wrapS=l.wrapS!==void 0?l.wrapS:Mn,o.wrapT=l.wrapT!==void 0?l.wrapT:Mn,o.magFilter=l.magFilter!==void 0?l.magFilter:nn,o.minFilter=l.minFilter!==void 0?l.minFilter:nn,o.anisotropy=l.anisotropy!==void 0?l.anisotropy:1,l.colorSpace!==void 0&&(o.colorSpace=l.colorSpace),l.flipY!==void 0&&(o.flipY=l.flipY),l.format!==void 0&&(o.format=l.format),l.type!==void 0&&(o.type=l.type),l.mipmaps!==void 0&&(o.mipmaps=l.mipmaps,o.minFilter=Ei),l.mipmapCount===1&&(o.minFilter=nn),l.generateMipmaps!==void 0&&(o.generateMipmaps=l.generateMipmaps),o.needsUpdate=!0,t&&t(o,l)},n,r),o}},qs=class extends rn{constructor(e){super(e)}load(e,t,n,r){let s=new Qt,o=new js(this.manager);return o.setCrossOrigin(this.crossOrigin),o.setPath(this.path),o.load(e,function(a){s.image=a,s.needsUpdate=!0,t!==void 0&&t(s)},n,r),s}},ar=class extends St{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new Ue(e),this.intensity=t}dispose(){}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){let t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,this.groundColor!==void 0&&(t.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(t.object.distance=this.distance),this.angle!==void 0&&(t.object.angle=this.angle),this.decay!==void 0&&(t.object.decay=this.decay),this.penumbra!==void 0&&(t.object.penumbra=this.penumbra),this.shadow!==void 0&&(t.object.shadow=this.shadow.toJSON()),this.target!==void 0&&(t.object.target=this.target.uuid),t}},fu=class extends ar{constructor(e,t,n){super(e,n),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(St.DEFAULT_UP),this.updateMatrix(),this.groundColor=new Ue(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}},Rg=new nt,$v=new z,e_=new z,pu=class{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Me(512,512),this.map=null,this.mapPass=null,this.matrix=new nt,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Ws,this._frameExtents=new Me(1,1),this._viewportCount=1,this._viewports=[new It(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){let t=this.camera,n=this.matrix;$v.setFromMatrixPosition(e.matrixWorld),t.position.copy($v),e_.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(e_),t.updateMatrixWorld(),Rg.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Rg),n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(Rg)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.intensity=e.intensity,this.bias=e.bias,this.radius=e.radius,this.mapSize.copy(e.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){let e={};return this.intensity!==1&&(e.intensity=this.intensity),this.bias!==0&&(e.bias=this.bias),this.normalBias!==0&&(e.normalBias=this.normalBias),this.radius!==1&&(e.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}},kg=class extends pu{constructor(){super(new jt(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(e){let t=this.camera,n=Co*2*e.angle*this.focus,r=this.mapSize.width/this.mapSize.height,s=e.distance||t.far;(n!==t.fov||r!==t.aspect||s!==t.far)&&(t.fov=n,t.aspect=r,t.far=s,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}},Go=class extends ar{constructor(e,t,n=0,r=Math.PI/3,s=0,o=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(St.DEFAULT_UP),this.updateMatrix(),this.target=new St,this.distance=n,this.angle=r,this.penumbra=s,this.decay=o,this.map=null,this.shadow=new kg}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}},t_=new nt,Sl=new z,Cg=new z,Bg=class extends pu{constructor(){super(new jt(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new Me(4,2),this._viewportCount=6,this._viewports=[new It(2,1,1,1),new It(0,1,1,1),new It(3,1,1,1),new It(1,1,1,1),new It(3,0,1,1),new It(1,0,1,1)],this._cubeDirections=[new z(1,0,0),new z(-1,0,0),new z(0,0,1),new z(0,0,-1),new z(0,1,0),new z(0,-1,0)],this._cubeUps=[new z(0,1,0),new z(0,1,0),new z(0,1,0),new z(0,1,0),new z(0,0,1),new z(0,0,-1)]}updateMatrices(e,t=0){let n=this.camera,r=this.matrix,s=e.distance||n.far;s!==n.far&&(n.far=s,n.updateProjectionMatrix()),Sl.setFromMatrixPosition(e.matrixWorld),n.position.copy(Sl),Cg.copy(n.position),Cg.add(this._cubeDirections[t]),n.up.copy(this._cubeUps[t]),n.lookAt(Cg),n.updateMatrixWorld(),r.makeTranslation(-Sl.x,-Sl.y,-Sl.z),t_.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(t_)}},os=class extends ar{constructor(e,t,n=0,r=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=r,this.shadow=new Bg}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}},cr=class extends No{constructor(e=-1,t=1,n=1,r=-1,s=.1,o=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=r,this.near=s,this.far=o,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,n,r,s,o){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=n,this.view.offsetY=r,this.view.width=s,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,r=(this.top+this.bottom)/2,s=n-e,o=n+e,a=r+t,c=r-t;if(this.view!==null&&this.view.enabled){let l=(this.right-this.left)/this.view.fullWidth/this.zoom,u=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=l*this.view.offsetX,o=s+l*this.view.width,a-=u*this.view.offsetY,c=a-u*this.view.height}this.projectionMatrix.makeOrthographic(s,o,a,c,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let 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}},zg=class extends pu{constructor(){super(new cr(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}},as=class extends ar{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(St.DEFAULT_UP),this.updateMatrix(),this.target=new St,this.shadow=new zg}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}},Wo=class extends ar{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}},mu=class extends ar{constructor(e,t,n=10,r=10){super(e,t),this.isRectAreaLight=!0,this.type="RectAreaLight",this.width=n,this.height=r}get power(){return this.intensity*this.width*this.height*Math.PI}set power(e){this.intensity=e/(this.width*this.height*Math.PI)}copy(e){return super.copy(e),this.width=e.width,this.height=e.height,this}toJSON(e){let t=super.toJSON(e);return t.object.width=this.width,t.object.height=this.height,t}},gu=class{constructor(){this.isSphericalHarmonics3=!0,this.coefficients=[];for(let e=0;e<9;e++)this.coefficients.push(new z)}set(e){for(let t=0;t<9;t++)this.coefficients[t].copy(e[t]);return this}zero(){for(let e=0;e<9;e++)this.coefficients[e].set(0,0,0);return this}getAt(e,t){let n=e.x,r=e.y,s=e.z,o=this.coefficients;return t.copy(o[0]).multiplyScalar(.282095),t.addScaledVector(o[1],.488603*r),t.addScaledVector(o[2],.488603*s),t.addScaledVector(o[3],.488603*n),t.addScaledVector(o[4],1.092548*(n*r)),t.addScaledVector(o[5],1.092548*(r*s)),t.addScaledVector(o[6],.315392*(3*s*s-1)),t.addScaledVector(o[7],1.092548*(n*s)),t.addScaledVector(o[8],.546274*(n*n-r*r)),t}getIrradianceAt(e,t){let n=e.x,r=e.y,s=e.z,o=this.coefficients;return t.copy(o[0]).multiplyScalar(.886227),t.addScaledVector(o[1],2*.511664*r),t.addScaledVector(o[2],2*.511664*s),t.addScaledVector(o[3],2*.511664*n),t.addScaledVector(o[4],2*.429043*n*r),t.addScaledVector(o[5],2*.429043*r*s),t.addScaledVector(o[6],.743125*s*s-.247708),t.addScaledVector(o[7],2*.429043*n*s),t.addScaledVector(o[8],.429043*(n*n-r*r)),t}add(e){for(let t=0;t<9;t++)this.coefficients[t].add(e.coefficients[t]);return this}addScaledSH(e,t){for(let n=0;n<9;n++)this.coefficients[n].addScaledVector(e.coefficients[n],t);return this}scale(e){for(let t=0;t<9;t++)this.coefficients[t].multiplyScalar(e);return this}lerp(e,t){for(let n=0;n<9;n++)this.coefficients[n].lerp(e.coefficients[n],t);return this}equals(e){for(let t=0;t<9;t++)if(!this.coefficients[t].equals(e.coefficients[t]))return!1;return!0}copy(e){return this.set(e.coefficients)}clone(){return new this.constructor().copy(this)}fromArray(e,t=0){let n=this.coefficients;for(let r=0;r<9;r++)n[r].fromArray(e,t+r*3);return this}toArray(e=[],t=0){let n=this.coefficients;for(let r=0;r<9;r++)n[r].toArray(e,t+r*3);return e}static getBasisAt(e,t){let n=e.x,r=e.y,s=e.z;t[0]=.282095,t[1]=.488603*r,t[2]=.488603*s,t[3]=.488603*n,t[4]=1.092548*n*r,t[5]=1.092548*r*s,t[6]=.315392*(3*s*s-1),t[7]=1.092548*n*s,t[8]=.546274*(n*n-r*r)}},xu=class extends ar{constructor(e=new gu,t=1){super(void 0,t),this.isLightProbe=!0,this.sh=e}copy(e){return super.copy(e),this.sh.copy(e.sh),this}fromJSON(e){return this.intensity=e.intensity,this.sh.fromArray(e.sh),this}toJSON(e){let t=super.toJSON(e);return t.object.sh=this.sh.toArray(),t}},yu=class i extends rn{constructor(e){super(e),this.textures={}}load(e,t,n,r){let s=this,o=new Vn(s.manager);o.setPath(s.path),o.setRequestHeader(s.requestHeader),o.setWithCredentials(s.withCredentials),o.load(e,function(a){try{t(s.parse(JSON.parse(a)))}catch(c){r?r(c):console.error(c),s.manager.itemError(e)}},n,r)}parse(e){let t=this.textures;function n(s){return t[s]===void 0&&console.warn("THREE.MaterialLoader: Undefined texture",s),t[s]}let r=this.createMaterialFromType(e.type);if(e.uuid!==void 0&&(r.uuid=e.uuid),e.name!==void 0&&(r.name=e.name),e.color!==void 0&&r.color!==void 0&&r.color.setHex(e.color),e.roughness!==void 0&&(r.roughness=e.roughness),e.metalness!==void 0&&(r.metalness=e.metalness),e.sheen!==void 0&&(r.sheen=e.sheen),e.sheenColor!==void 0&&(r.sheenColor=new Ue().setHex(e.sheenColor)),e.sheenRoughness!==void 0&&(r.sheenRoughness=e.sheenRoughness),e.emissive!==void 0&&r.emissive!==void 0&&r.emissive.setHex(e.emissive),e.specular!==void 0&&r.specular!==void 0&&r.specular.setHex(e.specular),e.specularIntensity!==void 0&&(r.specularIntensity=e.specularIntensity),e.specularColor!==void 0&&r.specularColor!==void 0&&r.specularColor.setHex(e.specularColor),e.shininess!==void 0&&(r.shininess=e.shininess),e.clearcoat!==void 0&&(r.clearcoat=e.clearcoat),e.clearcoatRoughness!==void 0&&(r.clearcoatRoughness=e.clearcoatRoughness),e.dispersion!==void 0&&(r.dispersion=e.dispersion),e.iridescence!==void 0&&(r.iridescence=e.iridescence),e.iridescenceIOR!==void 0&&(r.iridescenceIOR=e.iridescenceIOR),e.iridescenceThicknessRange!==void 0&&(r.iridescenceThicknessRange=e.iridescenceThicknessRange),e.transmission!==void 0&&(r.transmission=e.transmission),e.thickness!==void 0&&(r.thickness=e.thickness),e.attenuationDistance!==void 0&&(r.attenuationDistance=e.attenuationDistance),e.attenuationColor!==void 0&&r.attenuationColor!==void 0&&r.attenuationColor.setHex(e.attenuationColor),e.anisotropy!==void 0&&(r.anisotropy=e.anisotropy),e.anisotropyRotation!==void 0&&(r.anisotropyRotation=e.anisotropyRotation),e.fog!==void 0&&(r.fog=e.fog),e.flatShading!==void 0&&(r.flatShading=e.flatShading),e.blending!==void 0&&(r.blending=e.blending),e.combine!==void 0&&(r.combine=e.combine),e.side!==void 0&&(r.side=e.side),e.shadowSide!==void 0&&(r.shadowSide=e.shadowSide),e.opacity!==void 0&&(r.opacity=e.opacity),e.transparent!==void 0&&(r.transparent=e.transparent),e.alphaTest!==void 0&&(r.alphaTest=e.alphaTest),e.alphaHash!==void 0&&(r.alphaHash=e.alphaHash),e.depthFunc!==void 0&&(r.depthFunc=e.depthFunc),e.depthTest!==void 0&&(r.depthTest=e.depthTest),e.depthWrite!==void 0&&(r.depthWrite=e.depthWrite),e.colorWrite!==void 0&&(r.colorWrite=e.colorWrite),e.blendSrc!==void 0&&(r.blendSrc=e.blendSrc),e.blendDst!==void 0&&(r.blendDst=e.blendDst),e.blendEquation!==void 0&&(r.blendEquation=e.blendEquation),e.blendSrcAlpha!==void 0&&(r.blendSrcAlpha=e.blendSrcAlpha),e.blendDstAlpha!==void 0&&(r.blendDstAlpha=e.blendDstAlpha),e.blendEquationAlpha!==void 0&&(r.blendEquationAlpha=e.blendEquationAlpha),e.blendColor!==void 0&&r.blendColor!==void 0&&r.blendColor.setHex(e.blendColor),e.blendAlpha!==void 0&&(r.blendAlpha=e.blendAlpha),e.stencilWriteMask!==void 0&&(r.stencilWriteMask=e.stencilWriteMask),e.stencilFunc!==void 0&&(r.stencilFunc=e.stencilFunc),e.stencilRef!==void 0&&(r.stencilRef=e.stencilRef),e.stencilFuncMask!==void 0&&(r.stencilFuncMask=e.stencilFuncMask),e.stencilFail!==void 0&&(r.stencilFail=e.stencilFail),e.stencilZFail!==void 0&&(r.stencilZFail=e.stencilZFail),e.stencilZPass!==void 0&&(r.stencilZPass=e.stencilZPass),e.stencilWrite!==void 0&&(r.stencilWrite=e.stencilWrite),e.wireframe!==void 0&&(r.wireframe=e.wireframe),e.wireframeLinewidth!==void 0&&(r.wireframeLinewidth=e.wireframeLinewidth),e.wireframeLinecap!==void 0&&(r.wireframeLinecap=e.wireframeLinecap),e.wireframeLinejoin!==void 0&&(r.wireframeLinejoin=e.wireframeLinejoin),e.rotation!==void 0&&(r.rotation=e.rotation),e.linewidth!==void 0&&(r.linewidth=e.linewidth),e.dashSize!==void 0&&(r.dashSize=e.dashSize),e.gapSize!==void 0&&(r.gapSize=e.gapSize),e.scale!==void 0&&(r.scale=e.scale),e.polygonOffset!==void 0&&(r.polygonOffset=e.polygonOffset),e.polygonOffsetFactor!==void 0&&(r.polygonOffsetFactor=e.polygonOffsetFactor),e.polygonOffsetUnits!==void 0&&(r.polygonOffsetUnits=e.polygonOffsetUnits),e.dithering!==void 0&&(r.dithering=e.dithering),e.alphaToCoverage!==void 0&&(r.alphaToCoverage=e.alphaToCoverage),e.premultipliedAlpha!==void 0&&(r.premultipliedAlpha=e.premultipliedAlpha),e.forceSinglePass!==void 0&&(r.forceSinglePass=e.forceSinglePass),e.visible!==void 0&&(r.visible=e.visible),e.toneMapped!==void 0&&(r.toneMapped=e.toneMapped),e.userData!==void 0&&(r.userData=e.userData),e.vertexColors!==void 0&&(typeof e.vertexColors=="number"?r.vertexColors=e.vertexColors>0:r.vertexColors=e.vertexColors),e.uniforms!==void 0)for(let s in e.uniforms){let o=e.uniforms[s];switch(r.uniforms[s]={},o.type){case"t":r.uniforms[s].value=n(o.value);break;case"c":r.uniforms[s].value=new Ue().setHex(o.value);break;case"v2":r.uniforms[s].value=new Me().fromArray(o.value);break;case"v3":r.uniforms[s].value=new z().fromArray(o.value);break;case"v4":r.uniforms[s].value=new It().fromArray(o.value);break;case"m3":r.uniforms[s].value=new xt().fromArray(o.value);break;case"m4":r.uniforms[s].value=new nt().fromArray(o.value);break;default:r.uniforms[s].value=o.value}}if(e.defines!==void 0&&(r.defines=e.defines),e.vertexShader!==void 0&&(r.vertexShader=e.vertexShader),e.fragmentShader!==void 0&&(r.fragmentShader=e.fragmentShader),e.glslVersion!==void 0&&(r.glslVersion=e.glslVersion),e.extensions!==void 0)for(let s in e.extensions)r.extensions[s]=e.extensions[s];if(e.lights!==void 0&&(r.lights=e.lights),e.clipping!==void 0&&(r.clipping=e.clipping),e.size!==void 0&&(r.size=e.size),e.sizeAttenuation!==void 0&&(r.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(r.map=n(e.map)),e.matcap!==void 0&&(r.matcap=n(e.matcap)),e.alphaMap!==void 0&&(r.alphaMap=n(e.alphaMap)),e.bumpMap!==void 0&&(r.bumpMap=n(e.bumpMap)),e.bumpScale!==void 0&&(r.bumpScale=e.bumpScale),e.normalMap!==void 0&&(r.normalMap=n(e.normalMap)),e.normalMapType!==void 0&&(r.normalMapType=e.normalMapType),e.normalScale!==void 0){let s=e.normalScale;Array.isArray(s)===!1&&(s=[s,s]),r.normalScale=new Me().fromArray(s)}return e.displacementMap!==void 0&&(r.displacementMap=n(e.displacementMap)),e.displacementScale!==void 0&&(r.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(r.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(r.roughnessMap=n(e.roughnessMap)),e.metalnessMap!==void 0&&(r.metalnessMap=n(e.metalnessMap)),e.emissiveMap!==void 0&&(r.emissiveMap=n(e.emissiveMap)),e.emissiveIntensity!==void 0&&(r.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(r.specularMap=n(e.specularMap)),e.specularIntensityMap!==void 0&&(r.specularIntensityMap=n(e.specularIntensityMap)),e.specularColorMap!==void 0&&(r.specularColorMap=n(e.specularColorMap)),e.envMap!==void 0&&(r.envMap=n(e.envMap)),e.envMapRotation!==void 0&&r.envMapRotation.fromArray(e.envMapRotation),e.envMapIntensity!==void 0&&(r.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(r.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(r.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(r.lightMap=n(e.lightMap)),e.lightMapIntensity!==void 0&&(r.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(r.aoMap=n(e.aoMap)),e.aoMapIntensity!==void 0&&(r.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(r.gradientMap=n(e.gradientMap)),e.clearcoatMap!==void 0&&(r.clearcoatMap=n(e.clearcoatMap)),e.clearcoatRoughnessMap!==void 0&&(r.clearcoatRoughnessMap=n(e.clearcoatRoughnessMap)),e.clearcoatNormalMap!==void 0&&(r.clearcoatNormalMap=n(e.clearcoatNormalMap)),e.clearcoatNormalScale!==void 0&&(r.clearcoatNormalScale=new Me().fromArray(e.clearcoatNormalScale)),e.iridescenceMap!==void 0&&(r.iridescenceMap=n(e.iridescenceMap)),e.iridescenceThicknessMap!==void 0&&(r.iridescenceThicknessMap=n(e.iridescenceThicknessMap)),e.transmissionMap!==void 0&&(r.transmissionMap=n(e.transmissionMap)),e.thicknessMap!==void 0&&(r.thicknessMap=n(e.thicknessMap)),e.anisotropyMap!==void 0&&(r.anisotropyMap=n(e.anisotropyMap)),e.sheenColorMap!==void 0&&(r.sheenColorMap=n(e.sheenColorMap)),e.sheenRoughnessMap!==void 0&&(r.sheenRoughnessMap=n(e.sheenRoughnessMap)),r}setTextures(e){return this.textures=e,this}createMaterialFromType(e){return i.createMaterialFromType(e)}static createMaterialFromType(e){let t={ShadowMaterial:su,SpriteMaterial:Hs,RawShaderMaterial:zo,ShaderMaterial:$t,PointsMaterial:Sr,MeshPhysicalMaterial:Dn,MeshStandardMaterial:En,MeshPhongMaterial:Vo,MeshToonMaterial:ou,MeshNormalMaterial:Ho,MeshLambertMaterial:au,MeshDepthMaterial:lc,MeshDistanceMaterial:uc,MeshBasicMaterial:Ht,MeshMatcapMaterial:cu,LineDashedMaterial:lu,LineBasicMaterial:Xt,Material:cn};return new t[e]}},Mi=class{static decodeText(e){if(console.warn("THREE.LoaderUtils: decodeText() has been deprecated with r165 and will be removed with r175. Use TextDecoder instead."),typeof TextDecoder<"u")return new TextDecoder().decode(e);let t="";for(let n=0,r=e.length;n<r;n++)t+=String.fromCharCode(e[n]);try{return decodeURIComponent(escape(t))}catch{return t}}static extractUrlBase(e){let t=e.lastIndexOf("/");return t===-1?"./":e.slice(0,t+1)}static resolveURL(e,t){return typeof e!="string"||e===""?"":(/^https?:\/\//i.test(t)&&/^\//.test(e)&&(t=t.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(e)||/^data:.*,.*$/i.test(e)||/^blob:.*$/i.test(e)?e:t+e)}},vu=class extends ot{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(e){return super.copy(e),this.instanceCount=e.instanceCount,this}toJSON(){let e=super.toJSON();return e.instanceCount=this.instanceCount,e.isInstancedBufferGeometry=!0,e}},_u=class extends rn{constructor(e){super(e)}load(e,t,n,r){let s=this,o=new Vn(s.manager);o.setPath(s.path),o.setRequestHeader(s.requestHeader),o.setWithCredentials(s.withCredentials),o.load(e,function(a){try{t(s.parse(JSON.parse(a)))}catch(c){r?r(c):console.error(c),s.manager.itemError(e)}},n,r)}parse(e){let t={},n={};function r(m,g){if(t[g]!==void 0)return t[g];let f=m.interleavedBuffers[g],p=s(m,f.buffer),v=Xa(f.type,p),_=new Er(v,f.stride);return _.uuid=f.uuid,t[g]=_,_}function s(m,g){if(n[g]!==void 0)return n[g];let f=m.arrayBuffers[g],p=new Uint32Array(f).buffer;return n[g]=p,p}let o=e.isInstancedBufferGeometry?new vu:new ot,a=e.data.index;if(a!==void 0){let m=Xa(a.type,a.array);o.setIndex(new gt(m,1))}let c=e.data.attributes;for(let m in c){let g=c[m],x;if(g.isInterleavedBufferAttribute){let f=r(e.data,g.data);x=new ir(f,g.itemSize,g.offset,g.normalized)}else{let f=Xa(g.type,g.array),p=g.isInstancedBufferAttribute?Xi:gt;x=new p(f,g.itemSize,g.normalized)}g.name!==void 0&&(x.name=g.name),g.usage!==void 0&&x.setUsage(g.usage),o.setAttribute(m,x)}let l=e.data.morphAttributes;if(l)for(let m in l){let g=l[m],x=[];for(let f=0,p=g.length;f<p;f++){let v=g[f],_;if(v.isInterleavedBufferAttribute){let y=r(e.data,v.data);_=new ir(y,v.itemSize,v.offset,v.normalized)}else{let y=Xa(v.type,v.array);_=new gt(y,v.itemSize,v.normalized)}v.name!==void 0&&(_.name=v.name),x.push(_)}o.morphAttributes[m]=x}e.data.morphTargetsRelative&&(o.morphTargetsRelative=!0);let h=e.data.groups||e.data.drawcalls||e.data.offsets;if(h!==void 0)for(let m=0,g=h.length;m!==g;++m){let x=h[m];o.addGroup(x.start,x.count,x.materialIndex)}let d=e.data.boundingSphere;if(d!==void 0){let m=new z;d.center!==void 0&&m.fromArray(d.center),o.boundingSphere=new qt(m,d.radius)}return e.name&&(o.name=e.name),e.userData&&(o.userData=e.userData),o}},wf=class extends rn{constructor(e){super(e)}load(e,t,n,r){let s=this,o=this.path===""?Mi.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||o;let a=new Vn(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(c){let l=null;try{l=JSON.parse(c)}catch(h){r!==void 0&&r(h),console.error("THREE:ObjectLoader: Can't parse "+e+".",h.message);return}let u=l.metadata;if(u===void 0||u.type===void 0||u.type.toLowerCase()==="geometry"){r!==void 0&&r(new Error("THREE.ObjectLoader: Can't load "+e)),console.error("THREE.ObjectLoader: Can't load "+e);return}s.parse(l,t)},n,r)}async loadAsync(e,t){let n=this,r=this.path===""?Mi.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||r;let s=new Vn(this.manager);s.setPath(this.path),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials);let o=await s.loadAsync(e,t),a=JSON.parse(o),c=a.metadata;if(c===void 0||c.type===void 0||c.type.toLowerCase()==="geometry")throw new Error("THREE.ObjectLoader: Can't load "+e);return await n.parseAsync(a)}parse(e,t){let n=this.parseAnimations(e.animations),r=this.parseShapes(e.shapes),s=this.parseGeometries(e.geometries,r),o=this.parseImages(e.images,function(){t!==void 0&&t(l)}),a=this.parseTextures(e.textures,o),c=this.parseMaterials(e.materials,a),l=this.parseObject(e.object,s,c,a,n),u=this.parseSkeletons(e.skeletons,l);if(this.bindSkeletons(l,u),this.bindLightTargets(l),t!==void 0){let h=!1;for(let d in o)if(o[d].data instanceof HTMLImageElement){h=!0;break}h===!1&&t(l)}return l}async parseAsync(e){let t=this.parseAnimations(e.animations),n=this.parseShapes(e.shapes),r=this.parseGeometries(e.geometries,n),s=await this.parseImagesAsync(e.images),o=this.parseTextures(e.textures,s),a=this.parseMaterials(e.materials,o),c=this.parseObject(e.object,r,a,o,t),l=this.parseSkeletons(e.skeletons,c);return this.bindSkeletons(c,l),this.bindLightTargets(c),c}parseShapes(e){let t={};if(e!==void 0)for(let n=0,r=e.length;n<r;n++){let s=new Fi().fromJSON(e[n]);t[s.uuid]=s}return t}parseSkeletons(e,t){let n={},r={};if(t.traverse(function(s){s.isBone&&(r[s.uuid]=s)}),e!==void 0)for(let s=0,o=e.length;s<o;s++){let a=new Do().fromJSON(e[s],r);n[a.uuid]=a}return n}parseGeometries(e,t){let n={};if(e!==void 0){let r=new _u;for(let s=0,o=e.length;s<o;s++){let a,c=e[s];switch(c.type){case"BufferGeometry":case"InstancedBufferGeometry":a=r.parse(c);break;default:c.type in Qv?a=Qv[c.type].fromJSON(c,t):console.warn(`THREE.ObjectLoader: Unsupported geometry type "${c.type}"`)}a.uuid=c.uuid,c.name!==void 0&&(a.name=c.name),c.userData!==void 0&&(a.userData=c.userData),n[c.uuid]=a}}return n}parseMaterials(e,t){let n={},r={};if(e!==void 0){let s=new yu;s.setTextures(t);for(let o=0,a=e.length;o<a;o++){let c=e[o];n[c.uuid]===void 0&&(n[c.uuid]=s.parse(c)),r[c.uuid]=n[c.uuid]}}return r}parseAnimations(e){let t={};if(e!==void 0)for(let n=0;n<e.length;n++){let r=e[n],s=Pr.parse(r);t[s.uuid]=s}return t}parseImages(e,t){let n=this,r={},s;function o(c){return n.manager.itemStart(c),s.load(c,function(){n.manager.itemEnd(c)},void 0,function(){n.manager.itemError(c),n.manager.itemEnd(c)})}function a(c){if(typeof c=="string"){let l=c,u=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(l)?l:n.resourcePath+l;return o(u)}else return c.data?{data:Xa(c.type,c.data),width:c.width,height:c.height}:null}if(e!==void 0&&e.length>0){let c=new fc(t);s=new js(c),s.setCrossOrigin(this.crossOrigin);for(let l=0,u=e.length;l<u;l++){let h=e[l],d=h.url;if(Array.isArray(d)){let m=[];for(let g=0,x=d.length;g<x;g++){let f=d[g],p=a(f);p!==null&&(p instanceof HTMLImageElement?m.push(p):m.push(new An(p.data,p.width,p.height)))}r[h.uuid]=new _r(m)}else{let m=a(h.url);r[h.uuid]=new _r(m)}}}return r}async parseImagesAsync(e){let t=this,n={},r;async function s(o){if(typeof o=="string"){let a=o,c=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(a)?a:t.resourcePath+a;return await r.loadAsync(c)}else return o.data?{data:Xa(o.type,o.data),width:o.width,height:o.height}:null}if(e!==void 0&&e.length>0){r=new js(this.manager),r.setCrossOrigin(this.crossOrigin);for(let o=0,a=e.length;o<a;o++){let c=e[o],l=c.url;if(Array.isArray(l)){let u=[];for(let h=0,d=l.length;h<d;h++){let m=l[h],g=await s(m);g!==null&&(g instanceof HTMLImageElement?u.push(g):u.push(new An(g.data,g.width,g.height)))}n[c.uuid]=new _r(u)}else{let u=await s(c.url);n[c.uuid]=new _r(u)}}}return n}parseTextures(e,t){function n(s,o){return typeof s=="number"?s:(console.warn("THREE.ObjectLoader.parseTexture: Constant should be in numeric form.",s),o[s])}let r={};if(e!==void 0)for(let s=0,o=e.length;s<o;s++){let a=e[s];a.image===void 0&&console.warn('THREE.ObjectLoader: No "image" specified for',a.uuid),t[a.image]===void 0&&console.warn("THREE.ObjectLoader: Undefined image",a.image);let c=t[a.image],l=c.data,u;Array.isArray(l)?(u=new Vs,l.length===6&&(u.needsUpdate=!0)):(l&&l.data?u=new An:u=new Qt,l&&(u.needsUpdate=!0)),u.source=c,u.uuid=a.uuid,a.name!==void 0&&(u.name=a.name),a.mapping!==void 0&&(u.mapping=n(a.mapping,OT)),a.channel!==void 0&&(u.channel=a.channel),a.offset!==void 0&&u.offset.fromArray(a.offset),a.repeat!==void 0&&u.repeat.fromArray(a.repeat),a.center!==void 0&&u.center.fromArray(a.center),a.rotation!==void 0&&(u.rotation=a.rotation),a.wrap!==void 0&&(u.wrapS=n(a.wrap[0],n_),u.wrapT=n(a.wrap[1],n_)),a.format!==void 0&&(u.format=a.format),a.internalFormat!==void 0&&(u.internalFormat=a.internalFormat),a.type!==void 0&&(u.type=a.type),a.colorSpace!==void 0&&(u.colorSpace=a.colorSpace),a.minFilter!==void 0&&(u.minFilter=n(a.minFilter,i_)),a.magFilter!==void 0&&(u.magFilter=n(a.magFilter,i_)),a.anisotropy!==void 0&&(u.anisotropy=a.anisotropy),a.flipY!==void 0&&(u.flipY=a.flipY),a.generateMipmaps!==void 0&&(u.generateMipmaps=a.generateMipmaps),a.premultiplyAlpha!==void 0&&(u.premultiplyAlpha=a.premultiplyAlpha),a.unpackAlignment!==void 0&&(u.unpackAlignment=a.unpackAlignment),a.compareFunction!==void 0&&(u.compareFunction=a.compareFunction),a.userData!==void 0&&(u.userData=a.userData),r[a.uuid]=u}return r}parseObject(e,t,n,r,s){let o;function a(d){return t[d]===void 0&&console.warn("THREE.ObjectLoader: Undefined geometry",d),t[d]}function c(d){if(d!==void 0){if(Array.isArray(d)){let m=[];for(let g=0,x=d.length;g<x;g++){let f=d[g];n[f]===void 0&&console.warn("THREE.ObjectLoader: Undefined material",f),m.push(n[f])}return m}return n[d]===void 0&&console.warn("THREE.ObjectLoader: Undefined material",d),n[d]}}function l(d){return r[d]===void 0&&console.warn("THREE.ObjectLoader: Undefined texture",d),r[d]}let u,h;switch(e.type){case"Scene":o=new oi,e.background!==void 0&&(Number.isInteger(e.background)?o.background=new Ue(e.background):o.background=l(e.background)),e.environment!==void 0&&(o.environment=l(e.environment)),e.fog!==void 0&&(e.fog.type==="Fog"?o.fog=new Ul(e.fog.color,e.fog.near,e.fog.far):e.fog.type==="FogExp2"&&(o.fog=new Fl(e.fog.color,e.fog.density)),e.fog.name!==""&&(o.fog.name=e.fog.name)),e.backgroundBlurriness!==void 0&&(o.backgroundBlurriness=e.backgroundBlurriness),e.backgroundIntensity!==void 0&&(o.backgroundIntensity=e.backgroundIntensity),e.backgroundRotation!==void 0&&o.backgroundRotation.fromArray(e.backgroundRotation),e.environmentIntensity!==void 0&&(o.environmentIntensity=e.environmentIntensity),e.environmentRotation!==void 0&&o.environmentRotation.fromArray(e.environmentRotation);break;case"PerspectiveCamera":o=new jt(e.fov,e.aspect,e.near,e.far),e.focus!==void 0&&(o.focus=e.focus),e.zoom!==void 0&&(o.zoom=e.zoom),e.filmGauge!==void 0&&(o.filmGauge=e.filmGauge),e.filmOffset!==void 0&&(o.filmOffset=e.filmOffset),e.view!==void 0&&(o.view=Object.assign({},e.view));break;case"OrthographicCamera":o=new cr(e.left,e.right,e.top,e.bottom,e.near,e.far),e.zoom!==void 0&&(o.zoom=e.zoom),e.view!==void 0&&(o.view=Object.assign({},e.view));break;case"AmbientLight":o=new Wo(e.color,e.intensity);break;case"DirectionalLight":o=new as(e.color,e.intensity),o.target=e.target||"";break;case"PointLight":o=new os(e.color,e.intensity,e.distance,e.decay);break;case"RectAreaLight":o=new mu(e.color,e.intensity,e.width,e.height);break;case"SpotLight":o=new Go(e.color,e.intensity,e.distance,e.angle,e.penumbra,e.decay),o.target=e.target||"";break;case"HemisphereLight":o=new fu(e.color,e.groundColor,e.intensity);break;case"LightProbe":o=new xu().fromJSON(e);break;case"SkinnedMesh":u=a(e.geometry),h=c(e.material),o=new Oo(u,h),e.bindMode!==void 0&&(o.bindMode=e.bindMode),e.bindMatrix!==void 0&&o.bindMatrix.fromArray(e.bindMatrix),e.skeleton!==void 0&&(o.skeleton=e.skeleton);break;case"Mesh":u=a(e.geometry),h=c(e.material),o=new ct(u,h);break;case"InstancedMesh":u=a(e.geometry),h=c(e.material);let d=e.count,m=e.instanceMatrix,g=e.instanceColor;o=new $r(u,h,d),o.instanceMatrix=new Xi(new Float32Array(m.array),16),g!==void 0&&(o.instanceColor=new Xi(new Float32Array(g.array),g.itemSize));break;case"BatchedMesh":u=a(e.geometry),h=c(e.material),o=new Bl(e.maxInstanceCount,e.maxVertexCount,e.maxIndexCount,h),o.geometry=u,o.perObjectFrustumCulled=e.perObjectFrustumCulled,o.sortObjects=e.sortObjects,o._drawRanges=e.drawRanges,o._reservedRanges=e.reservedRanges,o._visibility=e.visibility,o._active=e.active,o._bounds=e.bounds.map(x=>{let f=new zt;f.min.fromArray(x.boxMin),f.max.fromArray(x.boxMax);let p=new qt;return p.radius=x.sphereRadius,p.center.fromArray(x.sphereCenter),{boxInitialized:x.boxInitialized,box:f,sphereInitialized:x.sphereInitialized,sphere:p}}),o._maxInstanceCount=e.maxInstanceCount,o._maxVertexCount=e.maxVertexCount,o._maxIndexCount=e.maxIndexCount,o._geometryInitialized=e.geometryInitialized,o._geometryCount=e.geometryCount,o._matricesTexture=l(e.matricesTexture.uuid),e.colorsTexture!==void 0&&(o._colorsTexture=l(e.colorsTexture.uuid));break;case"LOD":o=new kl;break;case"Line":o=new ai(a(e.geometry),c(e.material));break;case"LineLoop":o=new es(a(e.geometry),c(e.material));break;case"LineSegments":o=new ln(a(e.geometry),c(e.material));break;case"PointCloud":case"Points":o=new ts(a(e.geometry),c(e.material));break;case"Sprite":o=new Lo(c(e.material));break;case"Group":o=new Dt;break;case"Bone":o=new Gs;break;default:o=new St}if(o.uuid=e.uuid,e.name!==void 0&&(o.name=e.name),e.matrix!==void 0?(o.matrix.fromArray(e.matrix),e.matrixAutoUpdate!==void 0&&(o.matrixAutoUpdate=e.matrixAutoUpdate),o.matrixAutoUpdate&&o.matrix.decompose(o.position,o.quaternion,o.scale)):(e.position!==void 0&&o.position.fromArray(e.position),e.rotation!==void 0&&o.rotation.fromArray(e.rotation),e.quaternion!==void 0&&o.quaternion.fromArray(e.quaternion),e.scale!==void 0&&o.scale.fromArray(e.scale)),e.up!==void 0&&o.up.fromArray(e.up),e.castShadow!==void 0&&(o.castShadow=e.castShadow),e.receiveShadow!==void 0&&(o.receiveShadow=e.receiveShadow),e.shadow&&(e.shadow.intensity!==void 0&&(o.shadow.intensity=e.shadow.intensity),e.shadow.bias!==void 0&&(o.shadow.bias=e.shadow.bias),e.shadow.normalBias!==void 0&&(o.shadow.normalBias=e.shadow.normalBias),e.shadow.radius!==void 0&&(o.shadow.radius=e.shadow.radius),e.shadow.mapSize!==void 0&&o.shadow.mapSize.fromArray(e.shadow.mapSize),e.shadow.camera!==void 0&&(o.shadow.camera=this.parseObject(e.shadow.camera))),e.visible!==void 0&&(o.visible=e.visible),e.frustumCulled!==void 0&&(o.frustumCulled=e.frustumCulled),e.renderOrder!==void 0&&(o.renderOrder=e.renderOrder),e.userData!==void 0&&(o.userData=e.userData),e.layers!==void 0&&(o.layers.mask=e.layers),e.children!==void 0){let d=e.children;for(let m=0;m<d.length;m++)o.add(this.parseObject(d[m],t,n,r,s))}if(e.animations!==void 0){let d=e.animations;for(let m=0;m<d.length;m++){let g=d[m];o.animations.push(s[g])}}if(e.type==="LOD"){e.autoUpdate!==void 0&&(o.autoUpdate=e.autoUpdate);let d=e.levels;for(let m=0;m<d.length;m++){let g=d[m],x=o.getObjectByProperty("uuid",g.object);x!==void 0&&o.addLevel(x,g.distance,g.hysteresis)}}return o}bindSkeletons(e,t){Object.keys(t).length!==0&&e.traverse(function(n){if(n.isSkinnedMesh===!0&&n.skeleton!==void 0){let r=t[n.skeleton];r===void 0?console.warn("THREE.ObjectLoader: No skeleton found with UUID:",n.skeleton):n.bind(r,n.bindMatrix)}})}bindLightTargets(e){e.traverse(function(t){if(t.isDirectionalLight||t.isSpotLight){let n=t.target,r=e.getObjectByProperty("uuid",n);r!==void 0?t.target=r:t.target=new St}})}},OT={UVMapping:Bu,CubeReflectionMapping:Nr,CubeRefractionMapping:us,EquirectangularReflectionMapping:_c,EquirectangularRefractionMapping:bc,CubeUVReflectionMapping:qo},n_={RepeatWrapping:gn,ClampToEdgeWrapping:Mn,MirroredRepeatWrapping:ks},i_={NearestFilter:Jt,NearestMipmapNearestFilter:Mc,NearestMipmapLinearFilter:hs,LinearFilter:nn,LinearMipmapNearestFilter:Zs,LinearMipmapLinearFilter:Ei},pc=class extends rn{constructor(e){super(e),this.isImageBitmapLoader=!0,typeof createImageBitmap>"u"&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"}}setOptions(e){return this.options=e,this}load(e,t,n,r){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);let s=this,o=br.get(e);if(o!==void 0){if(s.manager.itemStart(e),o.then){o.then(l=>{t&&t(l),s.manager.itemEnd(e)}).catch(l=>{r&&r(l)});return}return setTimeout(function(){t&&t(o),s.manager.itemEnd(e)},0),o}let a={};a.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",a.headers=this.requestHeader;let c=fetch(e,a).then(function(l){return l.blob()}).then(function(l){return createImageBitmap(l,Object.assign(s.options,{colorSpaceConversion:"none"}))}).then(function(l){return br.add(e,l),t&&t(l),s.manager.itemEnd(e),l}).catch(function(l){r&&r(l),br.remove(e),s.manager.itemError(e),s.manager.itemEnd(e)});br.add(e,c),s.manager.itemStart(e)}},Qd,mc=class{static getContext(){return Qd===void 0&&(Qd=new(window.AudioContext||window.webkitAudioContext)),Qd}static setContext(e){Qd=e}},Rf=class extends rn{constructor(e){super(e)}load(e,t,n,r){let s=this,o=new Vn(this.manager);o.setResponseType("arraybuffer"),o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,function(c){try{let l=c.slice(0);mc.getContext().decodeAudioData(l,function(h){t(h)}).catch(a)}catch(l){a(l)}},n,r);function a(c){r?r(c):console.error(c),s.manager.itemError(e)}}},r_=new nt,s_=new nt,Mo=new nt,Cf=class{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new jt,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new jt,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1,this._cache={focus:null,fov:null,aspect:null,near:null,far:null,zoom:null,eyeSep:null}}update(e){let t=this._cache;if(t.focus!==e.focus||t.fov!==e.fov||t.aspect!==e.aspect*this.aspect||t.near!==e.near||t.far!==e.far||t.zoom!==e.zoom||t.eyeSep!==this.eyeSep){t.focus=e.focus,t.fov=e.fov,t.aspect=e.aspect*this.aspect,t.near=e.near,t.far=e.far,t.zoom=e.zoom,t.eyeSep=this.eyeSep,Mo.copy(e.projectionMatrix);let r=t.eyeSep/2,s=r*t.near/t.focus,o=t.near*Math.tan(Ro*t.fov*.5)/t.zoom,a,c;s_.elements[12]=-r,r_.elements[12]=r,a=-o*t.aspect+s,c=o*t.aspect+s,Mo.elements[0]=2*t.near/(c-a),Mo.elements[8]=(c+a)/(c-a),this.cameraL.projectionMatrix.copy(Mo),a=-o*t.aspect-s,c=o*t.aspect-s,Mo.elements[0]=2*t.near/(c-a),Mo.elements[8]=(c+a)/(c-a),this.cameraR.projectionMatrix.copy(Mo)}this.cameraL.matrixWorld.copy(e.matrixWorld).multiply(s_),this.cameraR.matrixWorld.copy(e.matrixWorld).multiply(r_)}},bu=class extends jt{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}},Xo=class{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=o_(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let e=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){let t=o_();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}};function o_(){return performance.now()}var Eo=new z,a_=new Zt,DT=new z,So=new z,Pf=class extends St{constructor(){super(),this.type="AudioListener",this.context=mc.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new Xo}getInput(){return this.gain}removeFilter(){return this.filter!==null&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null),this}getFilter(){return this.filter}setFilter(e){return this.filter!==null?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=e,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}updateMatrixWorld(e){super.updateMatrixWorld(e);let t=this.context.listener,n=this.up;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(Eo,a_,DT),So.set(0,0,-1).applyQuaternion(a_),t.positionX){let r=this.context.currentTime+this.timeDelta;t.positionX.linearRampToValueAtTime(Eo.x,r),t.positionY.linearRampToValueAtTime(Eo.y,r),t.positionZ.linearRampToValueAtTime(Eo.z,r),t.forwardX.linearRampToValueAtTime(So.x,r),t.forwardY.linearRampToValueAtTime(So.y,r),t.forwardZ.linearRampToValueAtTime(So.z,r),t.upX.linearRampToValueAtTime(n.x,r),t.upY.linearRampToValueAtTime(n.y,r),t.upZ.linearRampToValueAtTime(n.z,r)}else t.setPosition(Eo.x,Eo.y,Eo.z),t.setOrientation(So.x,So.y,So.z,n.x,n.y,n.z)}},Mu=class extends St{constructor(e){super(),this.type="Audio",this.listener=e,this.context=e.context,this.gain=this.context.createGain(),this.gain.connect(e.getInput()),this.autoplay=!1,this.buffer=null,this.detune=0,this.loop=!1,this.loopStart=0,this.loopEnd=0,this.offset=0,this.duration=void 0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.source=null,this.sourceType="empty",this._startedAt=0,this._progress=0,this._connected=!1,this.filters=[]}getOutput(){return this.gain}setNodeSource(e){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=e,this.connect(),this}setMediaElementSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(e),this.connect(),this}setMediaStreamSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaStreamNode",this.source=this.context.createMediaStreamSource(e),this.connect(),this}setBuffer(e){return this.buffer=e,this.sourceType="buffer",this.autoplay&&this.play(),this}play(e=0){if(this.isPlaying===!0){console.warn("THREE.Audio: Audio is already playing.");return}if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}this._startedAt=this.context.currentTime+e;let t=this.context.createBufferSource();return t.buffer=this.buffer,t.loop=this.loop,t.loopStart=this.loopStart,t.loopEnd=this.loopEnd,t.onended=this.onEnded.bind(this),t.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=t,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect()}pause(){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.isPlaying===!0&&(this._progress+=Math.max(this.context.currentTime-this._startedAt,0)*this.playbackRate,this.loop===!0&&(this._progress=this._progress%(this.duration||this.buffer.duration)),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this}stop(e=0){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this._progress=0,this.source!==null&&(this.source.stop(this.context.currentTime+e),this.source.onended=null),this.isPlaying=!1,this}connect(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(let e=1,t=this.filters.length;e<t;e++)this.filters[e-1].connect(this.filters[e]);this.filters[this.filters.length-1].connect(this.getOutput())}else this.source.connect(this.getOutput());return this._connected=!0,this}disconnect(){if(this._connected!==!1){if(this.filters.length>0){this.source.disconnect(this.filters[0]);for(let e=1,t=this.filters.length;e<t;e++)this.filters[e-1].disconnect(this.filters[e]);this.filters[this.filters.length-1].disconnect(this.getOutput())}else this.source.disconnect(this.getOutput());return this._connected=!1,this}}getFilters(){return this.filters}setFilters(e){return e||(e=[]),this._connected===!0?(this.disconnect(),this.filters=e.slice(),this.connect()):this.filters=e.slice(),this}setDetune(e){return this.detune=e,this.isPlaying===!0&&this.source.detune!==void 0&&this.source.detune.setTargetAtTime(this.detune,this.context.currentTime,.01),this}getDetune(){return this.detune}getFilter(){return this.getFilters()[0]}setFilter(e){return this.setFilters(e?[e]:[])}setPlaybackRate(e){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.playbackRate=e,this.isPlaying===!0&&this.source.playbackRate.setTargetAtTime(this.playbackRate,this.context.currentTime,.01),this}getPlaybackRate(){return this.playbackRate}onEnded(){this.isPlaying=!1,this._progress=0}getLoop(){return this.hasPlaybackControl===!1?(console.warn("THREE.Audio: this Audio has no playback control."),!1):this.loop}setLoop(e){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.loop=e,this.isPlaying===!0&&(this.source.loop=this.loop),this}setLoopStart(e){return this.loopStart=e,this}setLoopEnd(e){return this.loopEnd=e,this}getVolume(){return this.gain.gain.value}setVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}copy(e,t){return super.copy(e,t),e.sourceType!=="buffer"?(console.warn("THREE.Audio: Audio source type cannot be copied."),this):(this.autoplay=e.autoplay,this.buffer=e.buffer,this.detune=e.detune,this.loop=e.loop,this.loopStart=e.loopStart,this.loopEnd=e.loopEnd,this.offset=e.offset,this.duration=e.duration,this.playbackRate=e.playbackRate,this.hasPlaybackControl=e.hasPlaybackControl,this.sourceType=e.sourceType,this.filters=e.filters.slice(),this)}clone(e){return new this.constructor(this.listener).copy(this,e)}},To=new z,c_=new Zt,FT=new z,Ao=new z,If=class extends Mu{constructor(e){super(e),this.panner=this.context.createPanner(),this.panner.panningModel="HRTF",this.panner.connect(this.gain)}connect(){super.connect(),this.panner.connect(this.gain)}disconnect(){super.disconnect(),this.panner.disconnect(this.gain)}getOutput(){return this.panner}getRefDistance(){return this.panner.refDistance}setRefDistance(e){return this.panner.refDistance=e,this}getRolloffFactor(){return this.panner.rolloffFactor}setRolloffFactor(e){return this.panner.rolloffFactor=e,this}getDistanceModel(){return this.panner.distanceModel}setDistanceModel(e){return this.panner.distanceModel=e,this}getMaxDistance(){return this.panner.maxDistance}setMaxDistance(e){return this.panner.maxDistance=e,this}setDirectionalCone(e,t,n){return this.panner.coneInnerAngle=e,this.panner.coneOuterAngle=t,this.panner.coneOuterGain=n,this}updateMatrixWorld(e){if(super.updateMatrixWorld(e),this.hasPlaybackControl===!0&&this.isPlaying===!1)return;this.matrixWorld.decompose(To,c_,FT),Ao.set(0,0,1).applyQuaternion(c_);let t=this.panner;if(t.positionX){let n=this.context.currentTime+this.listener.timeDelta;t.positionX.linearRampToValueAtTime(To.x,n),t.positionY.linearRampToValueAtTime(To.y,n),t.positionZ.linearRampToValueAtTime(To.z,n),t.orientationX.linearRampToValueAtTime(Ao.x,n),t.orientationY.linearRampToValueAtTime(Ao.y,n),t.orientationZ.linearRampToValueAtTime(Ao.z,n)}else t.setPosition(To.x,To.y,To.z),t.setOrientation(Ao.x,Ao.y,Ao.z)}},Nf=class{constructor(e,t=2048){this.analyser=e.context.createAnalyser(),this.analyser.fftSize=t,this.data=new Uint8Array(this.analyser.frequencyBinCount),e.getOutput().connect(this.analyser)}getFrequencyData(){return this.analyser.getByteFrequencyData(this.data),this.data}getAverageFrequency(){let e=0,t=this.getFrequencyData();for(let n=0;n<t.length;n++)e+=t[n];return e/t.length}},Eu=class{constructor(e,t,n){this.binding=e,this.valueSize=n;let r,s,o;switch(t){case"quaternion":r=this._slerp,s=this._slerpAdditive,o=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(n*6),this._workIndex=5;break;case"string":case"bool":r=this._select,s=this._select,o=this._setAdditiveIdentityOther,this.buffer=new Array(n*5);break;default:r=this._lerp,s=this._lerpAdditive,o=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(n*5)}this._mixBufferRegion=r,this._mixBufferRegionAdditive=s,this._setIdentity=o,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(e,t){let n=this.buffer,r=this.valueSize,s=e*r+r,o=this.cumulativeWeight;if(o===0){for(let a=0;a!==r;++a)n[s+a]=n[a];o=t}else{o+=t;let a=t/o;this._mixBufferRegion(n,s,0,a,r)}this.cumulativeWeight=o}accumulateAdditive(e){let t=this.buffer,n=this.valueSize,r=n*this._addIndex;this.cumulativeWeightAdditive===0&&this._setIdentity(),this._mixBufferRegionAdditive(t,r,0,e,n),this.cumulativeWeightAdditive+=e}apply(e){let t=this.valueSize,n=this.buffer,r=e*t+t,s=this.cumulativeWeight,o=this.cumulativeWeightAdditive,a=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,s<1){let c=t*this._origIndex;this._mixBufferRegion(n,r,c,1-s,t)}o>0&&this._mixBufferRegionAdditive(n,r,this._addIndex*t,1,t);for(let c=t,l=t+t;c!==l;++c)if(n[c]!==n[c+t]){a.setValue(n,r);break}}saveOriginalState(){let e=this.binding,t=this.buffer,n=this.valueSize,r=n*this._origIndex;e.getValue(t,r);for(let s=n,o=r;s!==o;++s)t[s]=t[r+s%n];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){let e=this.valueSize*3;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){let e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let n=e;n<t;n++)this.buffer[n]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){let e=this._origIndex*this.valueSize,t=this._addIndex*this.valueSize;for(let n=0;n<this.valueSize;n++)this.buffer[t+n]=this.buffer[e+n]}_select(e,t,n,r,s){if(r>=.5)for(let o=0;o!==s;++o)e[t+o]=e[n+o]}_slerp(e,t,n,r){Zt.slerpFlat(e,t,e,t,e,n,r)}_slerpAdditive(e,t,n,r,s){let o=this._workIndex*s;Zt.multiplyQuaternionsFlat(e,o,e,t,e,n),Zt.slerpFlat(e,t,e,t,e,o,r)}_lerp(e,t,n,r,s){let o=1-r;for(let a=0;a!==s;++a){let c=t+a;e[c]=e[c]*o+e[n+a]*r}}_lerpAdditive(e,t,n,r,s){for(let o=0;o!==s;++o){let a=t+o;e[a]=e[a]+e[n+o]*r}}},P0="\\[\\]\\.:\\/",UT=new RegExp("["+P0+"]","g"),I0="[^"+P0+"]",kT="[^"+P0.replace("\\.","")+"]",BT=/((?:WC+[\/:])*)/.source.replace("WC",I0),zT=/(WCOD+)?/.source.replace("WCOD",kT),VT=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",I0),HT=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",I0),GT=new RegExp("^"+BT+zT+VT+HT+"$"),WT=["material","materials","bones","map"],Vg=class{constructor(e,t,n){let r=n||Ut.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,r)}getValue(e,t){this.bind();let n=this._targetGroup.nCachedObjects_,r=this._bindings[n];r!==void 0&&r.getValue(e,t)}setValue(e,t){let n=this._bindings;for(let r=this._targetGroup.nCachedObjects_,s=n.length;r!==s;++r)n[r].setValue(e,t)}bind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}},Ut=class i{constructor(e,t,n){this.path=t,this.parsedPath=n||i.parseTrackName(t),this.node=i.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,n){return e&&e.isAnimationObjectGroup?new i.Composite(e,t,n):new i(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(UT,"")}static parseTrackName(e){let t=GT.exec(e);if(t===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);let n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},r=n.nodeName&&n.nodeName.lastIndexOf(".");if(r!==void 0&&r!==-1){let s=n.nodeName.substring(r+1);WT.indexOf(s)!==-1&&(n.nodeName=n.nodeName.substring(0,r),n.objectName=s)}if(n.propertyName===null||n.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return n}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){let n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){let n=function(s){for(let o=0;o<s.length;o++){let a=s[o];if(a.name===t||a.uuid===t)return a;let c=n(a.children);if(c)return c}return null},r=n(e.children);if(r)return r}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){let n=this.resolvedProperty;for(let r=0,s=n.length;r!==s;++r)e[t++]=n[r]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){let n=this.resolvedProperty;for(let r=0,s=n.length;r!==s;++r)n[r]=e[t++]}_setValue_array_setNeedsUpdate(e,t){let n=this.resolvedProperty;for(let r=0,s=n.length;r!==s;++r)n[r]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){let n=this.resolvedProperty;for(let r=0,s=n.length;r!==s;++r)n[r]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node,t=this.parsedPath,n=t.objectName,r=t.propertyName,s=t.propertyIndex;if(e||(e=i.findNode(this.rootNode,t.nodeName),this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){console.warn("THREE.PropertyBinding: No target node found for track: "+this.path+".");return}if(n){let l=t.objectIndex;switch(n){case"materials":if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}e=e.material.materials;break;case"bones":if(!e.skeleton){console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let u=0;u<e.length;u++)if(e[u].name===l){l=u;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){console.error("THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}e=e.material.map;break;default:if(e[n]===void 0){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[n]}if(l!==void 0){if(e[l]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[l]}}let o=e[r];if(o===void 0){let l=t.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+l+"."+r+" but it wasn't found.",e);return}let a=this.Versioning.None;this.targetObject=e,e.needsUpdate!==void 0?a=this.Versioning.NeedsUpdate:e.matrixWorldNeedsUpdate!==void 0&&(a=this.Versioning.MatrixWorldNeedsUpdate);let c=this.BindingType.Direct;if(s!==void 0){if(r==="morphTargetInfluences"){if(!e.geometry){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}e.morphTargetDictionary[s]!==void 0&&(s=e.morphTargetDictionary[s])}c=this.BindingType.ArrayElement,this.resolvedProperty=o,this.propertyIndex=s}else o.fromArray!==void 0&&o.toArray!==void 0?(c=this.BindingType.HasFromToArray,this.resolvedProperty=o):Array.isArray(o)?(c=this.BindingType.EntireArray,this.resolvedProperty=o):this.propertyName=r;this.getValue=this.GetterByBindingType[c],this.setValue=this.SetterByBindingTypeAndVersioning[c][a]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}};Ut.Composite=Vg;Ut.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};Ut.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};Ut.prototype.GetterByBindingType=[Ut.prototype._getValue_direct,Ut.prototype._getValue_array,Ut.prototype._getValue_arrayElement,Ut.prototype._getValue_toArray];Ut.prototype.SetterByBindingTypeAndVersioning=[[Ut.prototype._setValue_direct,Ut.prototype._setValue_direct_setNeedsUpdate,Ut.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[Ut.prototype._setValue_array,Ut.prototype._setValue_array_setNeedsUpdate,Ut.prototype._setValue_array_setMatrixWorldNeedsUpdate],[Ut.prototype._setValue_arrayElement,Ut.prototype._setValue_arrayElement_setNeedsUpdate,Ut.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[Ut.prototype._setValue_fromArray,Ut.prototype._setValue_fromArray_setNeedsUpdate,Ut.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];var Lf=class{constructor(){this.isAnimationObjectGroup=!0,this.uuid=Di(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;let e={};this._indicesByUUID=e;for(let n=0,r=arguments.length;n!==r;++n)e[arguments[n].uuid]=n;this._paths=[],this._parsedPaths=[],this._bindings=[],this._bindingsIndicesByPath={};let t=this;this.stats={objects:{get total(){return t._objects.length},get inUse(){return this.total-t.nCachedObjects_}},get bindingsPerObject(){return t._bindings.length}}}add(){let e=this._objects,t=this._indicesByUUID,n=this._paths,r=this._parsedPaths,s=this._bindings,o=s.length,a,c=e.length,l=this.nCachedObjects_;for(let u=0,h=arguments.length;u!==h;++u){let d=arguments[u],m=d.uuid,g=t[m];if(g===void 0){g=c++,t[m]=g,e.push(d);for(let x=0,f=o;x!==f;++x)s[x].push(new Ut(d,n[x],r[x]))}else if(g<l){a=e[g];let x=--l,f=e[x];t[f.uuid]=g,e[g]=f,t[m]=x,e[x]=d;for(let p=0,v=o;p!==v;++p){let _=s[p],y=_[x],b=_[g];_[g]=y,b===void 0&&(b=new Ut(d,n[p],r[p])),_[x]=b}}else e[g]!==a&&console.error("THREE.AnimationObjectGroup: Different objects with the same UUID detected. Clean the caches or recreate your infrastructure when reloading scenes.")}this.nCachedObjects_=l}remove(){let e=this._objects,t=this._indicesByUUID,n=this._bindings,r=n.length,s=this.nCachedObjects_;for(let o=0,a=arguments.length;o!==a;++o){let c=arguments[o],l=c.uuid,u=t[l];if(u!==void 0&&u>=s){let h=s++,d=e[h];t[d.uuid]=u,e[u]=d,t[l]=h,e[h]=c;for(let m=0,g=r;m!==g;++m){let x=n[m],f=x[h],p=x[u];x[u]=f,x[h]=p}}}this.nCachedObjects_=s}uncache(){let e=this._objects,t=this._indicesByUUID,n=this._bindings,r=n.length,s=this.nCachedObjects_,o=e.length;for(let a=0,c=arguments.length;a!==c;++a){let l=arguments[a],u=l.uuid,h=t[u];if(h!==void 0)if(delete t[u],h<s){let d=--s,m=e[d],g=--o,x=e[g];t[m.uuid]=h,e[h]=m,t[x.uuid]=d,e[d]=x,e.pop();for(let f=0,p=r;f!==p;++f){let v=n[f],_=v[d],y=v[g];v[h]=_,v[d]=y,v.pop()}}else{let d=--o,m=e[d];d>0&&(t[m.uuid]=h),e[h]=m,e.pop();for(let g=0,x=r;g!==x;++g){let f=n[g];f[h]=f[d],f.pop()}}}this.nCachedObjects_=s}subscribe_(e,t){let n=this._bindingsIndicesByPath,r=n[e],s=this._bindings;if(r!==void 0)return s[r];let o=this._paths,a=this._parsedPaths,c=this._objects,l=c.length,u=this.nCachedObjects_,h=new Array(l);r=s.length,n[e]=r,o.push(e),a.push(t),s.push(h);for(let d=u,m=c.length;d!==m;++d){let g=c[d];h[d]=new Ut(g,e,t)}return h}unsubscribe_(e){let t=this._bindingsIndicesByPath,n=t[e];if(n!==void 0){let r=this._paths,s=this._parsedPaths,o=this._bindings,a=o.length-1,c=o[a],l=e[a];t[l]=n,o[n]=c,o.pop(),s[n]=s[a],s.pop(),r[n]=r[a],r.pop()}}},Su=class{constructor(e,t,n=null,r=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=n,this.blendMode=r;let s=t.tracks,o=s.length,a=new Array(o),c={endingStart:Ls,endingEnd:Ls};for(let l=0;l!==o;++l){let u=s[l].createInterpolant(null);a[l]=u,u.settings=c}this._interpolantSettings=c,this._interpolants=a,this._propertyBindings=new Array(o),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=h0,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&this.timeScale!==0&&this._startTime===null&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,n){if(e.fadeOut(t),this.fadeIn(t),n){let r=this._clip.duration,s=e._clip.duration,o=s/r,a=r/s;e.warp(1,o,t),this.warp(a,1,t)}return this}crossFadeTo(e,t,n){return e.crossFadeFrom(this,t,n)}stopFading(){let e=this._weightInterpolant;return e!==null&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,n){let r=this._mixer,s=r.time,o=this.timeScale,a=this._timeScaleInterpolant;a===null&&(a=r._lendControlInterpolant(),this._timeScaleInterpolant=a);let c=a.parameterPositions,l=a.sampleValues;return c[0]=s,c[1]=s+n,l[0]=e/o,l[1]=t/o,this}stopWarping(){let e=this._timeScaleInterpolant;return e!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,n,r){if(!this.enabled){this._updateWeight(e);return}let s=this._startTime;if(s!==null){let c=(e-s)*n;c<0||n===0?t=0:(this._startTime=null,t=n*c)}t*=this._updateTimeScale(e);let o=this._updateTime(t),a=this._updateWeight(e);if(a>0){let c=this._interpolants,l=this._propertyBindings;switch(this.blendMode){case yp:for(let u=0,h=c.length;u!==h;++u)c[u].evaluate(o),l[u].accumulateAdditive(a);break;case yh:default:for(let u=0,h=c.length;u!==h;++u)c[u].evaluate(o),l[u].accumulate(r,a)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;let n=this._weightInterpolant;if(n!==null){let r=n.evaluate(e)[0];t*=r,e>n.parameterPositions[1]&&(this.stopFading(),r===0&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;let n=this._timeScaleInterpolant;if(n!==null){let r=n.evaluate(e)[0];t*=r,e>n.parameterPositions[1]&&(this.stopWarping(),t===0?this.paused=!0:this.timeScale=t)}}return this._effectiveTimeScale=t,t}_updateTime(e){let t=this._clip.duration,n=this.loop,r=this.time+e,s=this._loopCount,o=n===d0;if(e===0)return s===-1?r:o&&(s&1)===1?t-r:r;if(n===u0){s===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(r>=t)r=t;else if(r<0)r=0;else{this.time=r;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(s===-1&&(e>=0?(s=0,this._setEndings(!0,this.repetitions===0,o)):this._setEndings(this.repetitions===0,!0,o)),r>=t||r<0){let a=Math.floor(r/t);r-=t*a,s+=Math.abs(a);let c=this.repetitions-s;if(c<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,r=e>0?t:0,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(c===1){let l=e<0;this._setEndings(l,!l,o)}else this._setEndings(!1,!1,o);this._loopCount=s,this.time=r,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:a})}}else this.time=r;if(o&&(s&1)===1)return t-r}return r}_setEndings(e,t,n){let r=this._interpolantSettings;n?(r.endingStart=Os,r.endingEnd=Os):(e?r.endingStart=this.zeroSlopeAtStart?Os:Ls:r.endingStart=qa,t?r.endingEnd=this.zeroSlopeAtEnd?Os:Ls:r.endingEnd=qa)}_scheduleFading(e,t,n){let r=this._mixer,s=r.time,o=this._weightInterpolant;o===null&&(o=r._lendControlInterpolant(),this._weightInterpolant=o);let a=o.parameterPositions,c=o.sampleValues;return a[0]=s,c[0]=t,a[1]=s+e,c[1]=n,this}},XT=new Float32Array(1),Of=class extends ki{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,t){let n=e._localRoot||this._root,r=e._clip.tracks,s=r.length,o=e._propertyBindings,a=e._interpolants,c=n.uuid,l=this._bindingsByRootAndName,u=l[c];u===void 0&&(u={},l[c]=u);for(let h=0;h!==s;++h){let d=r[h],m=d.name,g=u[m];if(g!==void 0)++g.referenceCount,o[h]=g;else{if(g=o[h],g!==void 0){g._cacheIndex===null&&(++g.referenceCount,this._addInactiveBinding(g,c,m));continue}let x=t&&t._propertyBindings[h].binding.parsedPath;g=new Eu(Ut.create(n,m,x),d.ValueTypeName,d.getValueSize()),++g.referenceCount,this._addInactiveBinding(g,c,m),o[h]=g}a[h].resultBuffer=g.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){let n=(e._localRoot||this._root).uuid,r=e._clip.uuid,s=this._actionsByClip[r];this._bindAction(e,s&&s.knownActions[0]),this._addInactiveAction(e,r,n)}let t=e._propertyBindings;for(let n=0,r=t.length;n!==r;++n){let s=t[n];s.useCount++===0&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){let t=e._propertyBindings;for(let n=0,r=t.length;n!==r;++n){let s=t[n];--s.useCount===0&&(s.restoreOriginalState(),this._takeBackBinding(s))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;let e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){let t=e._cacheIndex;return t!==null&&t<this._nActiveActions}_addInactiveAction(e,t,n){let r=this._actions,s=this._actionsByClip,o=s[t];if(o===void 0)o={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,s[t]=o;else{let a=o.knownActions;e._byClipCacheIndex=a.length,a.push(e)}e._cacheIndex=r.length,r.push(e),o.actionByRoot[n]=e}_removeInactiveAction(e){let t=this._actions,n=t[t.length-1],r=e._cacheIndex;n._cacheIndex=r,t[r]=n,t.pop(),e._cacheIndex=null;let s=e._clip.uuid,o=this._actionsByClip,a=o[s],c=a.knownActions,l=c[c.length-1],u=e._byClipCacheIndex;l._byClipCacheIndex=u,c[u]=l,c.pop(),e._byClipCacheIndex=null;let h=a.actionByRoot,d=(e._localRoot||this._root).uuid;delete h[d],c.length===0&&delete o[s],this._removeInactiveBindingsForAction(e)}_removeInactiveBindingsForAction(e){let t=e._propertyBindings;for(let n=0,r=t.length;n!==r;++n){let s=t[n];--s.referenceCount===0&&this._removeInactiveBinding(s)}}_lendAction(e){let t=this._actions,n=e._cacheIndex,r=this._nActiveActions++,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=n,t[n]=s}_takeBackAction(e){let t=this._actions,n=e._cacheIndex,r=--this._nActiveActions,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=n,t[n]=s}_addInactiveBinding(e,t,n){let r=this._bindingsByRootAndName,s=this._bindings,o=r[t];o===void 0&&(o={},r[t]=o),o[n]=e,e._cacheIndex=s.length,s.push(e)}_removeInactiveBinding(e){let t=this._bindings,n=e.binding,r=n.rootNode.uuid,s=n.path,o=this._bindingsByRootAndName,a=o[r],c=t[t.length-1],l=e._cacheIndex;c._cacheIndex=l,t[l]=c,t.pop(),delete a[s],Object.keys(a).length===0&&delete o[r]}_lendBinding(e){let t=this._bindings,n=e._cacheIndex,r=this._nActiveBindings++,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=n,t[n]=s}_takeBackBinding(e){let t=this._bindings,n=e._cacheIndex,r=--this._nActiveBindings,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=n,t[n]=s}_lendControlInterpolant(){let e=this._controlInterpolants,t=this._nActiveControlInterpolants++,n=e[t];return n===void 0&&(n=new hc(new Float32Array(2),new Float32Array(2),1,XT),n.__cacheIndex=t,e[t]=n),n}_takeBackControlInterpolant(e){let t=this._controlInterpolants,n=e.__cacheIndex,r=--this._nActiveControlInterpolants,s=t[r];e.__cacheIndex=r,t[r]=e,s.__cacheIndex=n,t[n]=s}clipAction(e,t,n){let r=t||this._root,s=r.uuid,o=typeof e=="string"?Pr.findByName(r,e):e,a=o!==null?o.uuid:e,c=this._actionsByClip[a],l=null;if(n===void 0&&(o!==null?n=o.blendMode:n=yh),c!==void 0){let h=c.actionByRoot[s];if(h!==void 0&&h.blendMode===n)return h;l=c.knownActions[0],o===null&&(o=l._clip)}if(o===null)return null;let u=new Su(this,o,t,n);return this._bindAction(u,l),this._addInactiveAction(u,a,s),u}existingAction(e,t){let n=t||this._root,r=n.uuid,s=typeof e=="string"?Pr.findByName(n,e):e,o=s?s.uuid:e,a=this._actionsByClip[o];return a!==void 0&&a.actionByRoot[r]||null}stopAllAction(){let e=this._actions,t=this._nActiveActions;for(let n=t-1;n>=0;--n)e[n].stop();return this}update(e){e*=this.timeScale;let t=this._actions,n=this._nActiveActions,r=this.time+=e,s=Math.sign(e),o=this._accuIndex^=1;for(let l=0;l!==n;++l)t[l]._update(r,e,s,o);let a=this._bindings,c=this._nActiveBindings;for(let l=0;l!==c;++l)a[l].apply(o);return this}setTime(e){this.time=0;for(let t=0;t<this._actions.length;t++)this._actions[t].time=0;return this.update(e)}getRoot(){return this._root}uncacheClip(e){let t=this._actions,n=e.uuid,r=this._actionsByClip,s=r[n];if(s!==void 0){let o=s.knownActions;for(let a=0,c=o.length;a!==c;++a){let l=o[a];this._deactivateAction(l);let u=l._cacheIndex,h=t[t.length-1];l._cacheIndex=null,l._byClipCacheIndex=null,h._cacheIndex=u,t[u]=h,t.pop(),this._removeInactiveBindingsForAction(l)}delete r[n]}}uncacheRoot(e){let t=e.uuid,n=this._actionsByClip;for(let o in n){let a=n[o].actionByRoot,c=a[t];c!==void 0&&(this._deactivateAction(c),this._removeInactiveAction(c))}let r=this._bindingsByRootAndName,s=r[t];if(s!==void 0)for(let o in s){let a=s[o];a.restoreOriginalState(),this._removeInactiveBinding(a)}}uncacheAction(e,t){let n=this.existingAction(e,t);n!==null&&(this._deactivateAction(n),this._removeInactiveAction(n))}},Df=class i{constructor(e){this.value=e}clone(){return new i(this.value.clone===void 0?this.value:this.value.clone())}},YT=0,Ff=class extends ki{constructor(){super(),this.isUniformsGroup=!0,Object.defineProperty(this,"id",{value:YT++}),this.name="",this.usage=Za,this.uniforms=[]}add(e){return this.uniforms.push(e),this}remove(e){let t=this.uniforms.indexOf(e);return t!==-1&&this.uniforms.splice(t,1),this}setName(e){return this.name=e,this}setUsage(e){return this.usage=e,this}dispose(){return this.dispatchEvent({type:"dispose"}),this}copy(e){this.name=e.name,this.usage=e.usage;let t=e.uniforms;this.uniforms.length=0;for(let n=0,r=t.length;n<r;n++){let s=Array.isArray(t[n])?t[n]:[t[n]];for(let o=0;o<s.length;o++)this.uniforms.push(s[o].clone())}return this}clone(){return new this.constructor().copy(this)}},Uf=class extends Er{constructor(e,t,n=1){super(e,t),this.isInstancedInterleavedBuffer=!0,this.meshPerAttribute=n}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}clone(e){let t=super.clone(e);return t.meshPerAttribute=this.meshPerAttribute,t}toJSON(e){let t=super.toJSON(e);return t.isInstancedInterleavedBuffer=!0,t.meshPerAttribute=this.meshPerAttribute,t}},kf=class{constructor(e,t,n,r,s){this.isGLBufferAttribute=!0,this.name="",this.buffer=e,this.type=t,this.itemSize=n,this.elementSize=r,this.count=s,this.version=0}set needsUpdate(e){e===!0&&this.version++}setBuffer(e){return this.buffer=e,this}setType(e,t){return this.type=e,this.elementSize=t,this}setItemSize(e){return this.itemSize=e,this}setCount(e){return this.count=e,this}},l_=new nt,lr=class{constructor(e,t,n=0,r=1/0){this.ray=new nr(e,t),this.near=n,this.far=r,this.camera=null,this.layers=new Io,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(e,t){this.ray.set(e,t)}setFromCamera(e,t){t.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,(t.near+t.far)/(t.near-t.far)).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):console.error("THREE.Raycaster: Unsupported camera type: "+t.type)}setFromXRController(e){return l_.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(l_),this}intersectObject(e,t=!0,n=[]){return Hg(e,this,n,t),n.sort(u_),n}intersectObjects(e,t=!0,n=[]){for(let r=0,s=e.length;r<s;r++)Hg(e[r],this,n,t);return n.sort(u_),n}};function u_(i,e){return i.distance-e.distance}function Hg(i,e,t,n){let r=!0;if(i.layers.test(e.layers)&&i.raycast(e,t)===!1&&(r=!1),r===!0&&n===!0){let s=i.children;for(let o=0,a=s.length;o<a;o++)Hg(s[o],e,t,!0)}}var Yo=class{constructor(e=1,t=0,n=0){return this.radius=e,this.phi=t,this.theta=n,this}set(e,t,n){return this.radius=e,this.phi=t,this.theta=n,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=mt(this.phi,1e-6,Math.PI-1e-6),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,n){return this.radius=Math.sqrt(e*e+t*t+n*n),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,n),this.phi=Math.acos(mt(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}},Bf=class{constructor(e=1,t=0,n=0){return this.radius=e,this.theta=t,this.y=n,this}set(e,t,n){return this.radius=e,this.theta=t,this.y=n,this}copy(e){return this.radius=e.radius,this.theta=e.theta,this.y=e.y,this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,n){return this.radius=Math.sqrt(e*e+n*n),this.theta=Math.atan2(e,n),this.y=t,this}clone(){return new this.constructor().copy(this)}},zf=class i{constructor(e,t,n,r){i.prototype.isMatrix2=!0,this.elements=[1,0,0,1],e!==void 0&&this.set(e,t,n,r)}identity(){return this.set(1,0,0,1),this}fromArray(e,t=0){for(let n=0;n<4;n++)this.elements[n]=e[n+t];return this}set(e,t,n,r){let s=this.elements;return s[0]=e,s[2]=t,s[1]=n,s[3]=r,this}},h_=new Me,Vf=class{constructor(e=new Me(1/0,1/0),t=new Me(-1/0,-1/0)){this.isBox2=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){let n=h_.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}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=1/0,this.max.x=this.max.y=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y}getCenter(e){return this.isEmpty()?e.set(0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(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}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y}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}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))}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}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,h_).distanceTo(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}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)}},d_=new z,$d=new z,Hf=class{constructor(e=new z,t=new z){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){d_.subVectors(e,this.start),$d.subVectors(this.end,this.start);let n=$d.dot($d),s=$d.dot(d_)/n;return t&&(s=mt(s,0,1)),s}closestPointToPoint(e,t,n){let r=this.closestPointToPointParameter(e,t);return this.delta(n).multiplyScalar(r).add(this.start)}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)}},f_=new z,Gf=class extends St{constructor(e,t){super(),this.light=e,this.matrixAutoUpdate=!1,this.color=t,this.type="SpotLightHelper";let n=new ot,r=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let o=0,a=1,c=32;o<c;o++,a++){let l=o/c*Math.PI*2,u=a/c*Math.PI*2;r.push(Math.cos(l),Math.sin(l),1,Math.cos(u),Math.sin(u),1)}n.setAttribute("position",new ze(r,3));let s=new Xt({fog:!1,toneMapped:!1});this.cone=new ln(n,s),this.add(this.cone),this.update()}dispose(){this.cone.geometry.dispose(),this.cone.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),this.parent?(this.parent.updateWorldMatrix(!0),this.matrix.copy(this.parent.matrixWorld).invert().multiply(this.light.matrixWorld)):this.matrix.copy(this.light.matrixWorld),this.matrixWorld.copy(this.light.matrixWorld);let e=this.light.distance?this.light.distance:1e3,t=e*Math.tan(this.light.angle);this.cone.scale.set(t,t,e),f_.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(f_),this.color!==void 0?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}},Is=new z,ef=new nt,Pg=new nt,Wf=class extends ln{constructor(e){let t=cb(e),n=new ot,r=[],s=[],o=new Ue(0,0,1),a=new Ue(0,1,0);for(let l=0;l<t.length;l++){let u=t[l];u.parent&&u.parent.isBone&&(r.push(0,0,0),r.push(0,0,0),s.push(o.r,o.g,o.b),s.push(a.r,a.g,a.b))}n.setAttribute("position",new ze(r,3)),n.setAttribute("color",new ze(s,3));let c=new Xt({vertexColors:!0,depthTest:!1,depthWrite:!1,toneMapped:!1,transparent:!0});super(n,c),this.isSkeletonHelper=!0,this.type="SkeletonHelper",this.root=e,this.bones=t,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1}updateMatrixWorld(e){let t=this.bones,n=this.geometry,r=n.getAttribute("position");Pg.copy(this.root.matrixWorld).invert();for(let s=0,o=0;s<t.length;s++){let a=t[s];a.parent&&a.parent.isBone&&(ef.multiplyMatrices(Pg,a.matrixWorld),Is.setFromMatrixPosition(ef),r.setXYZ(o,Is.x,Is.y,Is.z),ef.multiplyMatrices(Pg,a.parent.matrixWorld),Is.setFromMatrixPosition(ef),r.setXYZ(o+1,Is.x,Is.y,Is.z),o+=2)}n.getAttribute("position").needsUpdate=!0,super.updateMatrixWorld(e)}dispose(){this.geometry.dispose(),this.material.dispose()}};function cb(i){let e=[];i.isBone===!0&&e.push(i);for(let t=0;t<i.children.length;t++)e.push.apply(e,cb(i.children[t]));return e}var Xf=class extends ct{constructor(e,t,n){let r=new _i(t,4,2),s=new Ht({wireframe:!0,fog:!1,toneMapped:!1});super(r,s),this.light=e,this.color=n,this.type="PointLightHelper",this.matrix=this.light.matrixWorld,this.matrixAutoUpdate=!1,this.update()}dispose(){this.geometry.dispose(),this.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.color!==void 0?this.material.color.set(this.color):this.material.color.copy(this.light.color)}},jT=new z,p_=new Ue,m_=new Ue,Yf=class extends St{constructor(e,t,n){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=n,this.type="HemisphereLightHelper";let r=new cc(t);r.rotateY(Math.PI*.5),this.material=new Ht({wireframe:!0,fog:!1,toneMapped:!1}),this.color===void 0&&(this.material.vertexColors=!0);let s=r.getAttribute("position"),o=new Float32Array(s.count*3);r.setAttribute("color",new gt(o,3)),this.add(new ct(r,this.material)),this.update()}dispose(){this.children[0].geometry.dispose(),this.children[0].material.dispose()}update(){let e=this.children[0];if(this.color!==void 0)this.material.color.set(this.color);else{let t=e.geometry.getAttribute("color");p_.copy(this.light.color),m_.copy(this.light.groundColor);for(let n=0,r=t.count;n<r;n++){let s=n<r/2?p_:m_;t.setXYZ(n,s.r,s.g,s.b)}t.needsUpdate=!0}this.light.updateWorldMatrix(!0,!1),e.lookAt(jT.setFromMatrixPosition(this.light.matrixWorld).negate())}},jf=class extends ln{constructor(e=10,t=10,n=4473924,r=8947848){n=new Ue(n),r=new Ue(r);let s=t/2,o=e/t,a=e/2,c=[],l=[];for(let d=0,m=0,g=-a;d<=t;d++,g+=o){c.push(-a,0,g,a,0,g),c.push(g,0,-a,g,0,a);let x=d===s?n:r;x.toArray(l,m),m+=3,x.toArray(l,m),m+=3,x.toArray(l,m),m+=3,x.toArray(l,m),m+=3}let u=new ot;u.setAttribute("position",new ze(c,3)),u.setAttribute("color",new ze(l,3));let h=new Xt({vertexColors:!0,toneMapped:!1});super(u,h),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}},qf=class extends ln{constructor(e=10,t=16,n=8,r=64,s=4473924,o=8947848){s=new Ue(s),o=new Ue(o);let a=[],c=[];if(t>1)for(let h=0;h<t;h++){let d=h/t*(Math.PI*2),m=Math.sin(d)*e,g=Math.cos(d)*e;a.push(0,0,0),a.push(m,0,g);let x=h&1?s:o;c.push(x.r,x.g,x.b),c.push(x.r,x.g,x.b)}for(let h=0;h<n;h++){let d=h&1?s:o,m=e-e/n*h;for(let g=0;g<r;g++){let x=g/r*(Math.PI*2),f=Math.sin(x)*m,p=Math.cos(x)*m;a.push(f,0,p),c.push(d.r,d.g,d.b),x=(g+1)/r*(Math.PI*2),f=Math.sin(x)*m,p=Math.cos(x)*m,a.push(f,0,p),c.push(d.r,d.g,d.b)}}let l=new ot;l.setAttribute("position",new ze(a,3)),l.setAttribute("color",new ze(c,3));let u=new Xt({vertexColors:!0,toneMapped:!1});super(l,u),this.type="PolarGridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}},g_=new z,tf=new z,x_=new z,Kf=class extends St{constructor(e,t,n){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=n,this.type="DirectionalLightHelper",t===void 0&&(t=1);let r=new ot;r.setAttribute("position",new ze([-t,t,0,t,t,0,t,-t,0,-t,-t,0,-t,t,0],3));let s=new Xt({fog:!1,toneMapped:!1});this.lightPlane=new ai(r,s),this.add(this.lightPlane),r=new ot,r.setAttribute("position",new ze([0,0,0,0,0,1],3)),this.targetLine=new ai(r,s),this.add(this.targetLine),this.update()}dispose(){this.lightPlane.geometry.dispose(),this.lightPlane.material.dispose(),this.targetLine.geometry.dispose(),this.targetLine.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),g_.setFromMatrixPosition(this.light.matrixWorld),tf.setFromMatrixPosition(this.light.target.matrixWorld),x_.subVectors(tf,g_),this.lightPlane.lookAt(tf),this.color!==void 0?(this.lightPlane.material.color.set(this.color),this.targetLine.material.color.set(this.color)):(this.lightPlane.material.color.copy(this.light.color),this.targetLine.material.color.copy(this.light.color)),this.targetLine.lookAt(tf),this.targetLine.scale.z=x_.length()}},nf=new z,fn=new No,Zf=class extends ln{constructor(e){let t=new ot,n=new Xt({color:16777215,vertexColors:!0,toneMapped:!1}),r=[],s=[],o={};a("n1","n2"),a("n2","n4"),a("n4","n3"),a("n3","n1"),a("f1","f2"),a("f2","f4"),a("f4","f3"),a("f3","f1"),a("n1","f1"),a("n2","f2"),a("n3","f3"),a("n4","f4"),a("p","n1"),a("p","n2"),a("p","n3"),a("p","n4"),a("u1","u2"),a("u2","u3"),a("u3","u1"),a("c","t"),a("p","c"),a("cn1","cn2"),a("cn3","cn4"),a("cf1","cf2"),a("cf3","cf4");function a(g,x){c(g),c(x)}function c(g){r.push(0,0,0),s.push(0,0,0),o[g]===void 0&&(o[g]=[]),o[g].push(r.length/3-1)}t.setAttribute("position",new ze(r,3)),t.setAttribute("color",new ze(s,3)),super(t,n),this.type="CameraHelper",this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=o,this.update();let l=new Ue(16755200),u=new Ue(16711680),h=new Ue(43775),d=new Ue(16777215),m=new Ue(3355443);this.setColors(l,u,h,d,m)}setColors(e,t,n,r,s){let a=this.geometry.getAttribute("color");a.setXYZ(0,e.r,e.g,e.b),a.setXYZ(1,e.r,e.g,e.b),a.setXYZ(2,e.r,e.g,e.b),a.setXYZ(3,e.r,e.g,e.b),a.setXYZ(4,e.r,e.g,e.b),a.setXYZ(5,e.r,e.g,e.b),a.setXYZ(6,e.r,e.g,e.b),a.setXYZ(7,e.r,e.g,e.b),a.setXYZ(8,e.r,e.g,e.b),a.setXYZ(9,e.r,e.g,e.b),a.setXYZ(10,e.r,e.g,e.b),a.setXYZ(11,e.r,e.g,e.b),a.setXYZ(12,e.r,e.g,e.b),a.setXYZ(13,e.r,e.g,e.b),a.setXYZ(14,e.r,e.g,e.b),a.setXYZ(15,e.r,e.g,e.b),a.setXYZ(16,e.r,e.g,e.b),a.setXYZ(17,e.r,e.g,e.b),a.setXYZ(18,e.r,e.g,e.b),a.setXYZ(19,e.r,e.g,e.b),a.setXYZ(20,e.r,e.g,e.b),a.setXYZ(21,e.r,e.g,e.b),a.setXYZ(22,e.r,e.g,e.b),a.setXYZ(23,e.r,e.g,e.b),a.setXYZ(24,t.r,t.g,t.b),a.setXYZ(25,t.r,t.g,t.b),a.setXYZ(26,t.r,t.g,t.b),a.setXYZ(27,t.r,t.g,t.b),a.setXYZ(28,t.r,t.g,t.b),a.setXYZ(29,t.r,t.g,t.b),a.setXYZ(30,t.r,t.g,t.b),a.setXYZ(31,t.r,t.g,t.b),a.setXYZ(32,n.r,n.g,n.b),a.setXYZ(33,n.r,n.g,n.b),a.setXYZ(34,n.r,n.g,n.b),a.setXYZ(35,n.r,n.g,n.b),a.setXYZ(36,n.r,n.g,n.b),a.setXYZ(37,n.r,n.g,n.b),a.setXYZ(38,r.r,r.g,r.b),a.setXYZ(39,r.r,r.g,r.b),a.setXYZ(40,s.r,s.g,s.b),a.setXYZ(41,s.r,s.g,s.b),a.setXYZ(42,s.r,s.g,s.b),a.setXYZ(43,s.r,s.g,s.b),a.setXYZ(44,s.r,s.g,s.b),a.setXYZ(45,s.r,s.g,s.b),a.setXYZ(46,s.r,s.g,s.b),a.setXYZ(47,s.r,s.g,s.b),a.setXYZ(48,s.r,s.g,s.b),a.setXYZ(49,s.r,s.g,s.b),a.needsUpdate=!0}update(){let e=this.geometry,t=this.pointMap,n=1,r=1;fn.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),mn("c",t,e,fn,0,0,-1),mn("t",t,e,fn,0,0,1),mn("n1",t,e,fn,-n,-r,-1),mn("n2",t,e,fn,n,-r,-1),mn("n3",t,e,fn,-n,r,-1),mn("n4",t,e,fn,n,r,-1),mn("f1",t,e,fn,-n,-r,1),mn("f2",t,e,fn,n,-r,1),mn("f3",t,e,fn,-n,r,1),mn("f4",t,e,fn,n,r,1),mn("u1",t,e,fn,n*.7,r*1.1,-1),mn("u2",t,e,fn,-n*.7,r*1.1,-1),mn("u3",t,e,fn,0,r*2,-1),mn("cf1",t,e,fn,-n,0,1),mn("cf2",t,e,fn,n,0,1),mn("cf3",t,e,fn,0,-r,1),mn("cf4",t,e,fn,0,r,1),mn("cn1",t,e,fn,-n,0,-1),mn("cn2",t,e,fn,n,0,-1),mn("cn3",t,e,fn,0,-r,-1),mn("cn4",t,e,fn,0,r,-1),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function mn(i,e,t,n,r,s,o){nf.set(r,s,o).unproject(n);let a=e[i];if(a!==void 0){let c=t.getAttribute("position");for(let l=0,u=a.length;l<u;l++)c.setXYZ(a[l],nf.x,nf.y,nf.z)}}var rf=new zt,Jf=class extends ln{constructor(e,t=16776960){let n=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),r=new Float32Array(24),s=new ot;s.setIndex(new gt(n,1)),s.setAttribute("position",new gt(r,3)),super(s,new Xt({color:t,toneMapped:!1})),this.object=e,this.type="BoxHelper",this.matrixAutoUpdate=!1,this.update()}update(e){if(e!==void 0&&console.warn("THREE.BoxHelper: .update() has no longer arguments."),this.object!==void 0&&rf.setFromObject(this.object),rf.isEmpty())return;let t=rf.min,n=rf.max,r=this.geometry.attributes.position,s=r.array;s[0]=n.x,s[1]=n.y,s[2]=n.z,s[3]=t.x,s[4]=n.y,s[5]=n.z,s[6]=t.x,s[7]=t.y,s[8]=n.z,s[9]=n.x,s[10]=t.y,s[11]=n.z,s[12]=n.x,s[13]=n.y,s[14]=t.z,s[15]=t.x,s[16]=n.y,s[17]=t.z,s[18]=t.x,s[19]=t.y,s[20]=t.z,s[21]=n.x,s[22]=t.y,s[23]=t.z,r.needsUpdate=!0,this.geometry.computeBoundingSphere()}setFromObject(e){return this.object=e,this.update(),this}copy(e,t){return super.copy(e,t),this.object=e.object,this}dispose(){this.geometry.dispose(),this.material.dispose()}},Qf=class extends ln{constructor(e,t=16776960){let n=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),r=[1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],s=new ot;s.setIndex(new gt(n,1)),s.setAttribute("position",new ze(r,3)),super(s,new Xt({color:t,toneMapped:!1})),this.box=e,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(e){let t=this.box;t.isEmpty()||(t.getCenter(this.position),t.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(e))}dispose(){this.geometry.dispose(),this.material.dispose()}},$f=class extends ai{constructor(e,t=1,n=16776960){let r=n,s=[1,-1,0,-1,1,0,-1,-1,0,1,1,0,-1,1,0,-1,-1,0,1,-1,0,1,1,0],o=new ot;o.setAttribute("position",new ze(s,3)),o.computeBoundingSphere(),super(o,new Xt({color:r,toneMapped:!1})),this.type="PlaneHelper",this.plane=e,this.size=t;let a=[1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],c=new ot;c.setAttribute("position",new ze(a,3)),c.computeBoundingSphere(),this.add(new ct(c,new Ht({color:r,opacity:.2,transparent:!0,depthWrite:!1,toneMapped:!1})))}updateMatrixWorld(e){this.position.set(0,0,0),this.scale.set(.5*this.size,.5*this.size,1),this.lookAt(this.plane.normal),this.translateZ(-this.plane.constant),super.updateMatrixWorld(e)}dispose(){this.geometry.dispose(),this.material.dispose(),this.children[0].geometry.dispose(),this.children[0].material.dispose()}},y_=new z,sf,Ig,ep=class extends St{constructor(e=new z(0,0,1),t=new z(0,0,0),n=1,r=16776960,s=n*.2,o=s*.2){super(),this.type="ArrowHelper",sf===void 0&&(sf=new ot,sf.setAttribute("position",new ze([0,0,0,0,1,0],3)),Ig=new is(0,.5,1,5,1),Ig.translate(0,-.5,0)),this.position.copy(t),this.line=new ai(sf,new Xt({color:r,toneMapped:!1})),this.line.matrixAutoUpdate=!1,this.add(this.line),this.cone=new ct(Ig,new Ht({color:r,toneMapped:!1})),this.cone.matrixAutoUpdate=!1,this.add(this.cone),this.setDirection(e),this.setLength(n,s,o)}setDirection(e){if(e.y>.99999)this.quaternion.set(0,0,0,1);else if(e.y<-.99999)this.quaternion.set(1,0,0,0);else{y_.set(e.z,0,-e.x).normalize();let t=Math.acos(e.y);this.quaternion.setFromAxisAngle(y_,t)}}setLength(e,t=e*.2,n=t*.2){this.line.scale.set(1,Math.max(1e-4,e-t),1),this.line.updateMatrix(),this.cone.scale.set(n,t,n),this.cone.position.y=e,this.cone.updateMatrix()}setColor(e){this.line.material.color.set(e),this.cone.material.color.set(e)}copy(e){return super.copy(e,!1),this.line.copy(e.line),this.cone.copy(e.cone),this}dispose(){this.line.geometry.dispose(),this.line.material.dispose(),this.cone.geometry.dispose(),this.cone.material.dispose()}},tp=class extends ln{constructor(e=1){let t=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],n=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],r=new ot;r.setAttribute("position",new ze(t,3)),r.setAttribute("color",new ze(n,3));let s=new Xt({vertexColors:!0,toneMapped:!1});super(r,s),this.type="AxesHelper"}setColors(e,t,n){let r=new Ue,s=this.geometry.attributes.color.array;return r.set(e),r.toArray(s,0),r.toArray(s,3),r.set(t),r.toArray(s,6),r.toArray(s,9),r.set(n),r.toArray(s,12),r.toArray(s,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}},np=class{constructor(){this.type="ShapePath",this.color=new Ue,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new Tr,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this}lineTo(e,t){return this.currentPath.lineTo(e,t),this}quadraticCurveTo(e,t,n,r){return this.currentPath.quadraticCurveTo(e,t,n,r),this}bezierCurveTo(e,t,n,r,s,o){return this.currentPath.bezierCurveTo(e,t,n,r,s,o),this}splineThru(e){return this.currentPath.splineThru(e),this}toShapes(e){function t(p){let v=[];for(let _=0,y=p.length;_<y;_++){let b=p[_],E=new Fi;E.curves=b.curves,v.push(E)}return v}function n(p,v){let _=v.length,y=!1;for(let b=_-1,E=0;E<_;b=E++){let A=v[b],T=v[E],M=T.x-A.x,S=T.y-A.y;if(Math.abs(S)>Number.EPSILON){if(S<0&&(A=v[E],M=-M,T=v[b],S=-S),p.y<A.y||p.y>T.y)continue;if(p.y===A.y){if(p.x===A.x)return!0}else{let C=S*(p.x-A.x)-M*(p.y-A.y);if(C===0)return!0;if(C<0)continue;y=!y}}else{if(p.y!==A.y)continue;if(T.x<=p.x&&p.x<=A.x||A.x<=p.x&&p.x<=T.x)return!0}}return y}let r=Ui.isClockWise,s=this.subPaths;if(s.length===0)return[];let o,a,c,l=[];if(s.length===1)return a=s[0],c=new Fi,c.curves=a.curves,l.push(c),l;let u=!r(s[0].getPoints());u=e?!u:u;let h=[],d=[],m=[],g=0,x;d[g]=void 0,m[g]=[];for(let p=0,v=s.length;p<v;p++)a=s[p],x=a.getPoints(),o=r(x),o=e?!o:o,o?(!u&&d[g]&&g++,d[g]={s:new Fi,p:x},d[g].s.curves=a.curves,u&&g++,m[g]=[]):m[g].push({h:a,p:x[0]});if(!d[0])return t(s);if(d.length>1){let p=!1,v=0;for(let _=0,y=d.length;_<y;_++)h[_]=[];for(let _=0,y=d.length;_<y;_++){let b=m[_];for(let E=0;E<b.length;E++){let A=b[E],T=!0;for(let M=0;M<d.length;M++)n(A.p,d[M].p)&&(_!==M&&v++,T?(T=!1,h[M].push(A)):p=!0);T&&h[_].push(A)}}v>0&&p===!1&&(m=h)}let f;for(let p=0,v=d.length;p<v;p++){c=d[p].s,l.push(c),f=m[p];for(let _=0,y=f.length;_<y;_++)c.holes.push(f[_].h)}return l}},gc=class extends ki{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(){}disconnect(){}dispose(){}update(){}};function qT(i,e){let t=i.image&&i.image.width?i.image.width/i.image.height:1;return t>e?(i.repeat.x=1,i.repeat.y=t/e,i.offset.x=0,i.offset.y=(1-i.repeat.y)/2):(i.repeat.x=e/t,i.repeat.y=1,i.offset.x=(1-i.repeat.x)/2,i.offset.y=0),i}function KT(i,e){let t=i.image&&i.image.width?i.image.width/i.image.height:1;return t>e?(i.repeat.x=e/t,i.repeat.y=1,i.offset.x=(1-i.repeat.x)/2,i.offset.y=0):(i.repeat.x=1,i.repeat.y=t/e,i.offset.x=0,i.offset.y=(1-i.repeat.y)/2),i}function ZT(i){return i.repeat.x=1,i.repeat.y=1,i.offset.x=0,i.offset.y=0,i}function Sp(i,e,t,n){let r=JT(n);switch(t){case dp:return i*e;case pp:return i*e;case mp:return i*e*2;case Gu:return i*e/r.components*r.byteLength;case Ec:return i*e/r.components*r.byteLength;case gp:return i*e*2/r.components*r.byteLength;case Wu:return i*e*2/r.components*r.byteLength;case fp:return i*e*3/r.components*r.byteLength;case Ln:return i*e*4/r.components*r.byteLength;case Xu:return i*e*4/r.components*r.byteLength;case Sc:case Tc:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*8;case Ac:case wc:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case ju:case Ku:return Math.max(i,16)*Math.max(e,8)/4;case Yu:case qu:return Math.max(i,8)*Math.max(e,8)/2;case Zu:case Ju:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*8;case Qu:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case $u:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case eh:return Math.floor((i+4)/5)*Math.floor((e+3)/4)*16;case th:return Math.floor((i+4)/5)*Math.floor((e+4)/5)*16;case nh:return Math.floor((i+5)/6)*Math.floor((e+4)/5)*16;case ih:return Math.floor((i+5)/6)*Math.floor((e+5)/6)*16;case rh:return Math.floor((i+7)/8)*Math.floor((e+4)/5)*16;case sh:return Math.floor((i+7)/8)*Math.floor((e+5)/6)*16;case oh:return Math.floor((i+7)/8)*Math.floor((e+7)/8)*16;case ah:return Math.floor((i+9)/10)*Math.floor((e+4)/5)*16;case ch:return Math.floor((i+9)/10)*Math.floor((e+5)/6)*16;case lh:return Math.floor((i+9)/10)*Math.floor((e+7)/8)*16;case uh:return Math.floor((i+9)/10)*Math.floor((e+9)/10)*16;case hh:return Math.floor((i+11)/12)*Math.floor((e+9)/10)*16;case dh:return Math.floor((i+11)/12)*Math.floor((e+11)/12)*16;case Rc:case fh:case ph:return Math.ceil(i/4)*Math.ceil(e/4)*16;case xp:case mh:return Math.ceil(i/4)*Math.ceil(e/4)*8;case gh:case xh:return Math.ceil(i/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function JT(i){switch(i){case ci:case lp:return{byteLength:1,components:1};case Ko:case up:case Hn:return{byteLength:2,components:1};case Vu:case Hu:return{byteLength:2,components:4};case Lr:case zu:case si:return{byteLength:4,components:1};case hp:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${i}.`)}var lb={contain:qT,cover:KT,fill:ZT,getByteLength:Sp},ip=class extends on{constructor(e=1,t=1,n=1,r={}){console.warn('THREE.WebGLMultipleRenderTargets has been deprecated and will be removed in r172. Use THREE.WebGLRenderTarget and set the "count" parameter to enable MRT.'),super(e,t,{...r,count:n}),this.isWebGLMultipleRenderTargets=!0}get texture(){return this.textures}};typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:"171"}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__="171");function Lb(){let i=null,e=!1,t=null,n=null;function r(s,o){t(s,o),n=i.requestAnimationFrame(r)}return{start:function(){e!==!0&&t!==null&&(n=i.requestAnimationFrame(r),e=!0)},stop:function(){i.cancelAnimationFrame(n),e=!1},setAnimationLoop:function(s){t=s},setContext:function(s){i=s}}}function QT(i){let e=new WeakMap;function t(a,c){let l=a.array,u=a.usage,h=l.byteLength,d=i.createBuffer();i.bindBuffer(c,d),i.bufferData(c,l,u),a.onUploadCallback();let m;if(l instanceof Float32Array)m=i.FLOAT;else if(l instanceof Uint16Array)a.isFloat16BufferAttribute?m=i.HALF_FLOAT:m=i.UNSIGNED_SHORT;else if(l instanceof Int16Array)m=i.SHORT;else if(l instanceof Uint32Array)m=i.UNSIGNED_INT;else if(l instanceof Int32Array)m=i.INT;else if(l instanceof Int8Array)m=i.BYTE;else if(l instanceof Uint8Array)m=i.UNSIGNED_BYTE;else if(l instanceof Uint8ClampedArray)m=i.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+l);return{buffer:d,type:m,bytesPerElement:l.BYTES_PER_ELEMENT,version:a.version,size:h}}function n(a,c,l){let u=c.array,h=c.updateRanges;if(i.bindBuffer(l,a),h.length===0)i.bufferSubData(l,0,u);else{h.sort((m,g)=>m.start-g.start);let d=0;for(let m=1;m<h.length;m++){let g=h[d],x=h[m];x.start<=g.start+g.count+1?g.count=Math.max(g.count,x.start+x.count-g.start):(++d,h[d]=x)}h.length=d+1;for(let m=0,g=h.length;m<g;m++){let x=h[m];i.bufferSubData(l,x.start*u.BYTES_PER_ELEMENT,u,x.start,x.count)}c.clearUpdateRanges()}c.onUploadCallback()}function r(a){return a.isInterleavedBufferAttribute&&(a=a.data),e.get(a)}function s(a){a.isInterleavedBufferAttribute&&(a=a.data);let c=e.get(a);c&&(i.deleteBuffer(c.buffer),e.delete(a))}function o(a,c){if(a.isInterleavedBufferAttribute&&(a=a.data),a.isGLBufferAttribute){let u=e.get(a);(!u||u.version<a.version)&&e.set(a,{buffer:a.buffer,type:a.type,bytesPerElement:a.elementSize,version:a.version});return}let l=e.get(a);if(l===void 0)e.set(a,t(a,c));else if(l.version<a.version){if(l.size!==a.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.");n(l.buffer,a,c),l.version=a.version}}return{get:r,remove:s,update:o}}var $T=`#ifdef USE_ALPHAHASH
if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
#endif`,eA=`#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`,tA=`#ifdef USE_ALPHAMAP
diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
#endif`,nA=`#ifdef USE_ALPHAMAP
uniform sampler2D alphaMap;
#endif`,iA=`#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`,rA=`#ifdef USE_ALPHATEST
uniform float alphaTest;
#endif`,sA=`#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`,oA=`#ifdef USE_AOMAP
uniform sampler2D aoMap;
uniform float aoMapIntensity;
#endif`,aA=`#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;
vec3 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 ).rgb;
}
#endif`,cA=`#ifdef USE_BATCHING
mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
#endif`,lA=`vec3 transformed = vec3( position );
#ifdef USE_ALPHAHASH
vPosition = vec3( position );
#endif`,uA=`vec3 objectNormal = vec3( normal );
#ifdef USE_TANGENT
vec3 objectTangent = vec3( tangent.xyz );
#endif`,hA=`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`,dA=`#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`,fA=`#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`,pA=`#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`,mA=`#if NUM_CLIPPING_PLANES > 0
varying vec3 vClipPosition;
uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
#endif`,gA=`#if NUM_CLIPPING_PLANES > 0
varying vec3 vClipPosition;
#endif`,xA=`#if NUM_CLIPPING_PLANES > 0
vClipPosition = - mvPosition.xyz;
#endif`,yA=`#if defined( USE_COLOR_ALPHA )
diffuseColor *= vColor;
#elif defined( USE_COLOR )
diffuseColor.rgb *= vColor;
#endif`,vA=`#if defined( USE_COLOR_ALPHA )
varying vec4 vColor;
#elif defined( USE_COLOR )
varying vec3 vColor;
#endif`,_A=`#if defined( USE_COLOR_ALPHA )
varying vec4 vColor;
#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
varying vec3 vColor;
#endif`,bA=`#if defined( USE_COLOR_ALPHA )
vColor = vec4( 1.0 );
#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
vColor = vec3( 1.0 );
#endif
#ifdef USE_COLOR
vColor *= color;
#endif
#ifdef USE_INSTANCING_COLOR
vColor.xyz *= instanceColor.xyz;
#endif
#ifdef USE_BATCHING_COLOR
vec3 batchingColor = getBatchingColor( getIndirectIndex( gl_DrawID ) );
vColor.xyz *= batchingColor.xyz;
#endif`,MA=`#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 );
}
vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {
return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );
}
mat3 transposeMat3( const in mat3 m ) {
mat3 tmp;
tmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );
tmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );
tmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );
return tmp;
}
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`,EA=`#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`,SA=`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;
#ifdef FLIP_SIDED
transformedTangent = - transformedTangent;
#endif
#endif`,TA=`#ifdef USE_DISPLACEMENTMAP
uniform sampler2D displacementMap;
uniform float displacementScale;
uniform float displacementBias;
#endif`,AA=`#ifdef USE_DISPLACEMENTMAP
transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
#endif`,wA=`#ifdef USE_EMISSIVEMAP
vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
#ifdef DECODE_VIDEO_TEXTURE_EMISSIVE
emissiveColor = sRGBTransferEOTF( emissiveColor );
#endif
totalEmissiveRadiance *= emissiveColor.rgb;
#endif`,RA=`#ifdef USE_EMISSIVEMAP
uniform sampler2D emissiveMap;
#endif`,CA="gl_FragColor = linearToOutputTexel( gl_FragColor );",PA=`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 );
}`,IA=`#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 = inverseTransformDirection( 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 * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );
#else
vec4 envColor = vec4( 0.0 );
#endif
#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`,NA=`#ifdef USE_ENVMAP
uniform float envMapIntensity;
uniform float flipEnvMap;
uniform mat3 envMapRotation;
#ifdef ENVMAP_TYPE_CUBE
uniform samplerCube envMap;
#else
uniform sampler2D envMap;
#endif
#endif`,LA=`#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`,OA=`#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`,DA=`#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 = inverseTransformDirection( transformedNormal, viewMatrix );
#ifdef ENVMAP_MODE_REFLECTION
vReflect = reflect( cameraToVertex, worldNormal );
#else
vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
#endif
#endif
#endif`,FA=`#ifdef USE_FOG
vFogDepth = - mvPosition.z;
#endif`,UA=`#ifdef USE_FOG
varying float vFogDepth;
#endif`,kA=`#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`,BA=`#ifdef USE_FOG
uniform vec3 fogColor;
varying float vFogDepth;
#ifdef FOG_EXP2
uniform float fogDensity;
#else
uniform float fogNear;
uniform float fogFar;
#endif
#endif`,zA=`#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
}`,VA=`#ifdef USE_LIGHTMAP
uniform sampler2D lightMap;
uniform float lightMapIntensity;
#endif`,HA=`LambertMaterial material;
material.diffuseColor = diffuseColor.rgb;
material.specularStrength = specularStrength;`,GA=`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`,WA=`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 = inverseTransformDirection( 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`,XA=`#ifdef USE_ENVMAP
vec3 getIBLIrradiance( const in vec3 normal ) {
#ifdef ENVMAP_TYPE_CUBE_UV
vec3 worldNormal = inverseTransformDirection( 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, roughness * roughness) );
reflectVec = inverseTransformDirection( 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`,YA=`ToonMaterial material;
material.diffuseColor = diffuseColor.rgb;`,jA=`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`,qA=`BlinnPhongMaterial material;
material.diffuseColor = diffuseColor.rgb;
material.specularColor = specular;
material.specularShininess = shininess;
material.specularStrength = specularStrength;`,KA=`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`,ZA=`PhysicalMaterial material;
material.diffuseColor = diffuseColor.rgb * ( 1.0 - 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 = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );
#else
material.specularColor = mix( vec3( 0.04 ), 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.07, 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`,JA=`struct PhysicalMaterial {
vec3 diffuseColor;
float roughness;
vec3 specularColor;
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;
#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 ) );
float v = 0.5 / ( gv + gl );
return saturate(v);
}
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.specularColor;
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 * transposeMat3( 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 a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;
float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;
float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );
return saturate( DG * RECIPROCAL_PI );
}
vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
float dotNV = saturate( dot( normal, viewDir ) );
const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );
const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );
vec4 r = roughness * c0 + c1;
float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;
vec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;
return fab;
}
vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {
vec2 fab = DFGApprox( normal, viewDir, roughness );
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
vec2 fab = DFGApprox( normal, viewDir, roughness );
#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;
}
#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.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );
reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );
reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );
}
#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 );
#endif
reflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material );
reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
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 ) {
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
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 );
#endif
vec3 singleScattering = vec3( 0.0 );
vec3 multiScattering = vec3( 0.0 );
vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
#ifdef USE_IRIDESCENCE
computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );
#else
computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );
#endif
vec3 totalScattering = singleScattering + multiScattering;
vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );
reflectedLight.indirectSpecular += radiance * singleScattering;
reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;
reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;
}
#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 );
}`,QA=`
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.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );
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 )
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
#endif
#if defined( RE_IndirectSpecular )
vec3 radiance = vec3( 0.0 );
vec3 clearcoatRadiance = vec3( 0.0 );
#endif`,$A=`#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( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )
iblIrradiance += getIBLIrradiance( geometryNormal );
#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`,ew=`#if defined( RE_IndirectDiffuse )
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`,tw=`#if defined( USE_LOGDEPTHBUF )
gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
#endif`,nw=`#if defined( USE_LOGDEPTHBUF )
uniform float logDepthBufFC;
varying float vFragDepth;
varying float vIsPerspective;
#endif`,iw=`#ifdef USE_LOGDEPTHBUF
varying float vFragDepth;
varying float vIsPerspective;
#endif`,rw=`#ifdef USE_LOGDEPTHBUF
vFragDepth = 1.0 + gl_Position.w;
vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
#endif`,sw=`#ifdef USE_MAP
vec4 sampledDiffuseColor = texture2D( map, vMapUv );
#ifdef DECODE_VIDEO_TEXTURE
sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );
#endif
diffuseColor *= sampledDiffuseColor;
#endif`,ow=`#ifdef USE_MAP
uniform sampler2D map;
#endif`,aw=`#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`,cw=`#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`,lw=`float metalnessFactor = metalness;
#ifdef USE_METALNESSMAP
vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
metalnessFactor *= texelMetalness.b;
#endif`,uw=`#ifdef USE_METALNESSMAP
uniform sampler2D metalnessMap;
#endif`,hw=`#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`,dw=`#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`,fw=`#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`,pw=`#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`,mw=`#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`,gw=`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
#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
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
#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
tbn2[0] *= faceDirection;
tbn2[1] *= faceDirection;
#endif
#endif
vec3 nonPerturbedNormal = normal;`,xw=`#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;
mapN.xy *= normalScale;
normal = normalize( tbn * mapN );
#elif defined( USE_BUMPMAP )
normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
#endif`,yw=`#ifndef FLAT_SHADED
varying vec3 vNormal;
#ifdef USE_TANGENT
varying vec3 vTangent;
varying vec3 vBitangent;
#endif
#endif`,vw=`#ifndef FLAT_SHADED
varying vec3 vNormal;
#ifdef USE_TANGENT
varying vec3 vTangent;
varying vec3 vBitangent;
#endif
#endif`,_w=`#ifndef FLAT_SHADED
vNormal = normalize( transformedNormal );
#ifdef USE_TANGENT
vTangent = normalize( transformedTangent );
vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
#endif
#endif`,bw=`#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`,Mw=`#ifdef USE_CLEARCOAT
vec3 clearcoatNormal = nonPerturbedNormal;
#endif`,Ew=`#ifdef USE_CLEARCOAT_NORMALMAP
vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
clearcoatMapN.xy *= clearcoatNormalScale;
clearcoatNormal = normalize( tbn2 * clearcoatMapN );
#endif`,Sw=`#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`,Tw=`#ifdef USE_IRIDESCENCEMAP
uniform sampler2D iridescenceMap;
#endif
#ifdef USE_IRIDESCENCE_THICKNESSMAP
uniform sampler2D iridescenceThicknessMap;
#endif`,Aw=`#ifdef OPAQUE
diffuseColor.a = 1.0;
#endif
#ifdef USE_TRANSMISSION
diffuseColor.a *= material.transmissionAlpha;
#endif
gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,ww=`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 ) {
return depth * ( near - far ) - near;
}
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 ) {
return ( near * far ) / ( ( far - near ) * depth - far );
}`,Rw=`#ifdef PREMULTIPLIED_ALPHA
gl_FragColor.rgb *= gl_FragColor.a;
#endif`,Cw=`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;`,Pw=`#ifdef DITHERING
gl_FragColor.rgb = dithering( gl_FragColor.rgb );
#endif`,Iw=`#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`,Nw=`float roughnessFactor = roughness;
#ifdef USE_ROUGHNESSMAP
vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
roughnessFactor *= texelRoughness.g;
#endif`,Lw=`#ifdef USE_ROUGHNESSMAP
uniform sampler2D roughnessMap;
#endif`,Ow=`#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
uniform sampler2D directionalShadowMap[ 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
uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
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 sampler2D pointShadowMap[ 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
float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {
return step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );
}
vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {
return unpackRGBATo2Half( texture2D( shadow, uv ) );
}
float VSMShadow (sampler2D shadow, vec2 uv, float compare ){
float occlusion = 1.0;
vec2 distribution = texture2DDistribution( shadow, uv );
float hard_shadow = step( compare , distribution.x );
if (hard_shadow != 1.0 ) {
float distance = compare - distribution.x ;
float variance = max( 0.00000, distribution.y * distribution.y );
float softness_probability = variance / (variance + distance * distance ); softness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 ); occlusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );
}
return occlusion;
}
float getShadow( sampler2D 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 ) {
#if defined( SHADOWMAP_TYPE_PCF )
vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
float dx0 = - texelSize.x * shadowRadius;
float dy0 = - texelSize.y * shadowRadius;
float dx1 = + texelSize.x * shadowRadius;
float dy1 = + texelSize.y * shadowRadius;
float dx2 = dx0 / 2.0;
float dy2 = dy0 / 2.0;
float dx3 = dx1 / 2.0;
float dy3 = dy1 / 2.0;
shadow = (
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +
texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +
texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +
texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +
texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +
texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )
) * ( 1.0 / 17.0 );
#elif defined( SHADOWMAP_TYPE_PCF_SOFT )
vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
float dx = texelSize.x;
float dy = texelSize.y;
vec2 uv = shadowCoord.xy;
vec2 f = fract( uv * shadowMapSize + 0.5 );
uv -= f * texelSize;
shadow = (
texture2DCompare( shadowMap, uv, shadowCoord.z ) +
texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +
texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +
texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +
mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),
texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),
f.x ) +
mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),
texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),
f.x ) +
mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),
texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),
f.y ) +
mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),
texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),
f.y ) +
mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),
texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),
f.x ),
mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),
texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),
f.x ),
f.y )
) * ( 1.0 / 9.0 );
#elif defined( SHADOWMAP_TYPE_VSM )
shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );
#else
shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );
#endif
}
return mix( 1.0, shadow, shadowIntensity );
}
vec2 cubeToUV( vec3 v, float texelSizeY ) {
vec3 absV = abs( v );
float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );
absV *= scaleToCube;
v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );
vec2 planar = v.xy;
float almostATexel = 1.5 * texelSizeY;
float almostOne = 1.0 - almostATexel;
if ( absV.z >= almostOne ) {
if ( v.z > 0.0 )
planar.x = 4.0 - v.x;
} else if ( absV.x >= almostOne ) {
float signX = sign( v.x );
planar.x = v.z * signX + 2.0 * signX;
} else if ( absV.y >= almostOne ) {
float signY = sign( v.y );
planar.x = v.x + 2.0 * signY + 2.0;
planar.y = v.z * signY - 2.0;
}
return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );
}
float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
float shadow = 1.0;
vec3 lightToPosition = shadowCoord.xyz;
float lightToPositionLength = length( lightToPosition );
if ( lightToPositionLength - shadowCameraFar <= 0.0 && lightToPositionLength - shadowCameraNear >= 0.0 ) {
float dp = ( lightToPositionLength - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias;
vec3 bd3D = normalize( lightToPosition );
vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );
#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )
vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;
shadow = (
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +
texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )
) * ( 1.0 / 9.0 );
#else
shadow = texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );
#endif
}
return mix( 1.0, shadow, shadowIntensity );
}
#endif`,Dw=`#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`,Fw=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
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`,Uw=`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
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;
}`,kw=`#ifdef USE_SKINNING
mat4 boneMatX = getBoneMatrix( skinIndex.x );
mat4 boneMatY = getBoneMatrix( skinIndex.y );
mat4 boneMatZ = getBoneMatrix( skinIndex.z );
mat4 boneMatW = getBoneMatrix( skinIndex.w );
#endif`,Bw=`#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`,zw=`#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`,Vw=`#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`,Hw=`float specularStrength;
#ifdef USE_SPECULARMAP
vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
specularStrength = texelSpecular.r;
#else
specularStrength = 1.0;
#endif`,Gw=`#ifdef USE_SPECULARMAP
uniform sampler2D specularMap;
#endif`,Ww=`#if defined( TONE_MAPPING )
gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
#endif`,Xw=`#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; }`,Yw=`#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 = inverseTransformDirection( normal, viewMatrix );
vec4 transmitted = getIBLVolumeRefraction(
n, v, material.roughness, material.diffuseColor, material.specularColor, 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`,jw=`#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`,qw=`#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`,Kw=`#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`,Zw=`#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`,Jw=`#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`,Qw=`varying vec2 vUv;
uniform mat3 uvTransform;
void main() {
vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
gl_Position = vec4( position.xy, 1.0, 1.0 );
}`,$w=`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>
}`,e1=`varying vec3 vWorldDirection;
#include <common>
void main() {
vWorldDirection = transformDirection( position, modelMatrix );
#include <begin_vertex>
#include <project_vertex>
gl_Position.z = gl_Position.w;
}`,t1=`#ifdef ENVMAP_TYPE_CUBE
uniform samplerCube envMap;
#elif defined( ENVMAP_TYPE_CUBE_UV )
uniform sampler2D envMap;
#endif
uniform float flipEnvMap;
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 * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );
#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>
}`,n1=`varying vec3 vWorldDirection;
#include <common>
void main() {
vWorldDirection = transformDirection( position, modelMatrix );
#include <begin_vertex>
#include <project_vertex>
gl_Position.z = gl_Position.w;
}`,i1=`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>
}`,r1=`#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;
}`,s1=`#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>
float fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;
#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
}`,o1=`#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;
}`,a1=`#define DISTANCE
uniform vec3 referencePosition;
uniform float nearDistance;
uniform float farDistance;
varying vec3 vWorldPosition;
#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 <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 = packDepthToRGBA( dist );
}`,c1=`varying vec3 vWorldDirection;
#include <common>
void main() {
vWorldDirection = transformDirection( position, modelMatrix );
#include <begin_vertex>
#include <project_vertex>
}`,l1=`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>
}`,u1=`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>
}`,h1=`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>
}`,d1=`#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>
}`,f1=`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>
}`,p1=`#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>
}`,m1=`#define LAMBERT
uniform vec3 diffuse;
uniform vec3 emissive;
uniform float opacity;
#include <common>
#include <packing>
#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 <envmap_common_pars_fragment>
#include <envmap_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>
}`,g1=`#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;
}`,x1=`#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>
}`,y1=`#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
}`,v1=`#define NORMAL
uniform float opacity;
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
varying vec3 vViewPosition;
#endif
#include <packing>
#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( packNormalToRGB( normal ), diffuseColor.a );
#ifdef OPAQUE
gl_FragColor.a = 1.0;
#endif
}`,_1=`#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>
}`,b1=`#define PHONG
uniform vec3 diffuse;
uniform vec3 emissive;
uniform vec3 specular;
uniform float shininess;
uniform float opacity;
#include <common>
#include <packing>
#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 <envmap_common_pars_fragment>
#include <envmap_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>
}`,M1=`#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
}`,E1=`#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 <packing>
#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
float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );
outgoingLight = outgoingLight * sheenEnergyComp + 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>
}`,S1=`#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>
}`,T1=`#define TOON
uniform vec3 diffuse;
uniform vec3 emissive;
uniform float opacity;
#include <common>
#include <packing>
#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>
}`,A1=`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>
}`,w1=`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>
}`,R1=`#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>
}`,C1=`uniform vec3 color;
uniform float opacity;
#include <common>
#include <packing>
#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>
}`,P1=`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>
}`,I1=`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:$T,alphahash_pars_fragment:eA,alphamap_fragment:tA,alphamap_pars_fragment:nA,alphatest_fragment:iA,alphatest_pars_fragment:rA,aomap_fragment:sA,aomap_pars_fragment:oA,batching_pars_vertex:aA,batching_vertex:cA,begin_vertex:lA,beginnormal_vertex:uA,bsdfs:hA,iridescence_fragment:dA,bumpmap_pars_fragment:fA,clipping_planes_fragment:pA,clipping_planes_pars_fragment:mA,clipping_planes_pars_vertex:gA,clipping_planes_vertex:xA,color_fragment:yA,color_pars_fragment:vA,color_pars_vertex:_A,color_vertex:bA,common:MA,cube_uv_reflection_fragment:EA,defaultnormal_vertex:SA,displacementmap_pars_vertex:TA,displacementmap_vertex:AA,emissivemap_fragment:wA,emissivemap_pars_fragment:RA,colorspace_fragment:CA,colorspace_pars_fragment:PA,envmap_fragment:IA,envmap_common_pars_fragment:NA,envmap_pars_fragment:LA,envmap_pars_vertex:OA,envmap_physical_pars_fragment:XA,envmap_vertex:DA,fog_vertex:FA,fog_pars_vertex:UA,fog_fragment:kA,fog_pars_fragment:BA,gradientmap_pars_fragment:zA,lightmap_pars_fragment:VA,lights_lambert_fragment:HA,lights_lambert_pars_fragment:GA,lights_pars_begin:WA,lights_toon_fragment:YA,lights_toon_pars_fragment:jA,lights_phong_fragment:qA,lights_phong_pars_fragment:KA,lights_physical_fragment:ZA,lights_physical_pars_fragment:JA,lights_fragment_begin:QA,lights_fragment_maps:$A,lights_fragment_end:ew,logdepthbuf_fragment:tw,logdepthbuf_pars_fragment:nw,logdepthbuf_pars_vertex:iw,logdepthbuf_vertex:rw,map_fragment:sw,map_pars_fragment:ow,map_particle_fragment:aw,map_particle_pars_fragment:cw,metalnessmap_fragment:lw,metalnessmap_pars_fragment:uw,morphinstance_vertex:hw,morphcolor_vertex:dw,morphnormal_vertex:fw,morphtarget_pars_vertex:pw,morphtarget_vertex:mw,normal_fragment_begin:gw,normal_fragment_maps:xw,normal_pars_fragment:yw,normal_pars_vertex:vw,normal_vertex:_w,normalmap_pars_fragment:bw,clearcoat_normal_fragment_begin:Mw,clearcoat_normal_fragment_maps:Ew,clearcoat_pars_fragment:Sw,iridescence_pars_fragment:Tw,opaque_fragment:Aw,packing:ww,premultiplied_alpha_fragment:Rw,project_vertex:Cw,dithering_fragment:Pw,dithering_pars_fragment:Iw,roughnessmap_fragment:Nw,roughnessmap_pars_fragment:Lw,shadowmap_pars_fragment:Ow,shadowmap_pars_vertex:Dw,shadowmap_vertex:Fw,shadowmask_pars_fragment:Uw,skinbase_vertex:kw,skinning_pars_vertex:Bw,skinning_vertex:zw,skinnormal_vertex:Vw,specularmap_fragment:Hw,specularmap_pars_fragment:Gw,tonemapping_fragment:Ww,tonemapping_pars_fragment:Xw,transmission_fragment:Yw,transmission_pars_fragment:jw,uv_pars_fragment:qw,uv_pars_vertex:Kw,uv_vertex:Zw,worldpos_vertex:Jw,background_vert:Qw,background_frag:$w,backgroundCube_vert:e1,backgroundCube_frag:t1,cube_vert:n1,cube_frag:i1,depth_vert:r1,depth_frag:s1,distanceRGBA_vert:o1,distanceRGBA_frag:a1,equirect_vert:c1,equirect_frag:l1,linedashed_vert:u1,linedashed_frag:h1,meshbasic_vert:d1,meshbasic_frag:f1,meshlambert_vert:p1,meshlambert_frag:m1,meshmatcap_vert:g1,meshmatcap_frag:x1,meshnormal_vert:y1,meshnormal_frag:v1,meshphong_vert:_1,meshphong_frag:b1,meshphysical_vert:M1,meshphysical_frag:E1,meshtoon_vert:S1,meshtoon_frag:T1,points_vert:A1,points_frag:w1,shadow_vert:R1,shadow_frag:C1,sprite_vert:P1,sprite_frag:I1},Ze={common:{diffuse:{value:new Ue(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new xt},alphaMap:{value:null},alphaMapTransform:{value:new xt},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new xt}},envmap:{envMap:{value:null},envMapRotation:{value:new xt},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new xt}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new xt}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new xt},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new xt},normalScale:{value:new Me(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new xt},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new xt}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new xt}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new xt}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Ue(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new Ue(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new xt},alphaTest:{value:0},uvTransform:{value:new xt}},sprite:{diffuse:{value:new Ue(16777215)},opacity:{value:1},center:{value:new Me(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new xt},alphaMap:{value:null},alphaMapTransform:{value:new xt},alphaTest:{value:0}}},hr={basic:{uniforms:$n([Ze.common,Ze.specularmap,Ze.envmap,Ze.aomap,Ze.lightmap,Ze.fog]),vertexShader:Tt.meshbasic_vert,fragmentShader:Tt.meshbasic_frag},lambert:{uniforms:$n([Ze.common,Ze.specularmap,Ze.envmap,Ze.aomap,Ze.lightmap,Ze.emissivemap,Ze.bumpmap,Ze.normalmap,Ze.displacementmap,Ze.fog,Ze.lights,{emissive:{value:new Ue(0)}}]),vertexShader:Tt.meshlambert_vert,fragmentShader:Tt.meshlambert_frag},phong:{uniforms:$n([Ze.common,Ze.specularmap,Ze.envmap,Ze.aomap,Ze.lightmap,Ze.emissivemap,Ze.bumpmap,Ze.normalmap,Ze.displacementmap,Ze.fog,Ze.lights,{emissive:{value:new Ue(0)},specular:{value:new Ue(1118481)},shininess:{value:30}}]),vertexShader:Tt.meshphong_vert,fragmentShader:Tt.meshphong_frag},standard:{uniforms:$n([Ze.common,Ze.envmap,Ze.aomap,Ze.lightmap,Ze.emissivemap,Ze.bumpmap,Ze.normalmap,Ze.displacementmap,Ze.roughnessmap,Ze.metalnessmap,Ze.fog,Ze.lights,{emissive:{value:new Ue(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Tt.meshphysical_vert,fragmentShader:Tt.meshphysical_frag},toon:{uniforms:$n([Ze.common,Ze.aomap,Ze.lightmap,Ze.emissivemap,Ze.bumpmap,Ze.normalmap,Ze.displacementmap,Ze.gradientmap,Ze.fog,Ze.lights,{emissive:{value:new Ue(0)}}]),vertexShader:Tt.meshtoon_vert,fragmentShader:Tt.meshtoon_frag},matcap:{uniforms:$n([Ze.common,Ze.bumpmap,Ze.normalmap,Ze.displacementmap,Ze.fog,{matcap:{value:null}}]),vertexShader:Tt.meshmatcap_vert,fragmentShader:Tt.meshmatcap_frag},points:{uniforms:$n([Ze.points,Ze.fog]),vertexShader:Tt.points_vert,fragmentShader:Tt.points_frag},dashed:{uniforms:$n([Ze.common,Ze.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Tt.linedashed_vert,fragmentShader:Tt.linedashed_frag},depth:{uniforms:$n([Ze.common,Ze.displacementmap]),vertexShader:Tt.depth_vert,fragmentShader:Tt.depth_frag},normal:{uniforms:$n([Ze.common,Ze.bumpmap,Ze.normalmap,Ze.displacementmap,{opacity:{value:1}}]),vertexShader:Tt.meshnormal_vert,fragmentShader:Tt.meshnormal_frag},sprite:{uniforms:$n([Ze.sprite,Ze.fog]),vertexShader:Tt.sprite_vert,fragmentShader:Tt.sprite_frag},background:{uniforms:{uvTransform:{value:new xt},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Tt.background_vert,fragmentShader:Tt.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new xt}},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},distanceRGBA:{uniforms:$n([Ze.common,Ze.displacementmap,{referencePosition:{value:new z},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Tt.distanceRGBA_vert,fragmentShader:Tt.distanceRGBA_frag},shadow:{uniforms:$n([Ze.lights,Ze.fog,{color:{value:new Ue(0)},opacity:{value:1}}]),vertexShader:Tt.shadow_vert,fragmentShader:Tt.shadow_frag}};hr.physical={uniforms:$n([hr.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new xt},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new xt},clearcoatNormalScale:{value:new Me(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new xt},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new xt},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new xt},sheen:{value:0},sheenColor:{value:new Ue(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new xt},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new xt},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new xt},transmissionSamplerSize:{value:new Me},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new xt},attenuationDistance:{value:0},attenuationColor:{value:new Ue(0)},specularColor:{value:new Ue(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new xt},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new xt},anisotropyVector:{value:new Me},anisotropyMap:{value:null},anisotropyMapTransform:{value:new xt}}]),vertexShader:Tt.meshphysical_vert,fragmentShader:Tt.meshphysical_frag};var Tp={r:0,b:0,g:0},$o=new yi,N1=new nt;function L1(i,e,t,n,r,s,o){let a=new Ue(0),c=s===!0?0:1,l,u,h=null,d=0,m=null;function g(_){let y=_.isScene===!0?_.background:null;return y&&y.isTexture&&(y=(_.backgroundBlurriness>0?t:e).get(y)),y}function x(_){let y=!1,b=g(_);b===null?p(a,c):b&&b.isColor&&(p(b,1),y=!0);let E=i.xr.getEnvironmentBlendMode();E==="additive"?n.buffers.color.setClear(0,0,0,1,o):E==="alpha-blend"&&n.buffers.color.setClear(0,0,0,0,o),(i.autoClear||y)&&(n.buffers.depth.setTest(!0),n.buffers.depth.setMask(!0),n.buffers.color.setMask(!0),i.clear(i.autoClearColor,i.autoClearDepth,i.autoClearStencil))}function f(_,y){let b=g(y);b&&(b.isCubeTexture||b.mapping===qo)?(u===void 0&&(u=new ct(new Qn(1,1,1),new $t({name:"BackgroundCubeMaterial",uniforms:Qo(hr.backgroundCube.uniforms),vertexShader:hr.backgroundCube.vertexShader,fragmentShader:hr.backgroundCube.fragmentShader,side:un,depthTest:!1,depthWrite:!1,fog:!1})),u.geometry.deleteAttribute("normal"),u.geometry.deleteAttribute("uv"),u.onBeforeRender=function(E,A,T){this.matrixWorld.copyPosition(T.matrixWorld)},Object.defineProperty(u.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),r.update(u)),$o.copy(y.backgroundRotation),$o.x*=-1,$o.y*=-1,$o.z*=-1,b.isCubeTexture&&b.isRenderTargetTexture===!1&&($o.y*=-1,$o.z*=-1),u.material.uniforms.envMap.value=b,u.material.uniforms.flipEnvMap.value=b.isCubeTexture&&b.isRenderTargetTexture===!1?-1:1,u.material.uniforms.backgroundBlurriness.value=y.backgroundBlurriness,u.material.uniforms.backgroundIntensity.value=y.backgroundIntensity,u.material.uniforms.backgroundRotation.value.setFromMatrix4(N1.makeRotationFromEuler($o)),u.material.toneMapped=_t.getTransfer(b.colorSpace)!==kt,(h!==b||d!==b.version||m!==i.toneMapping)&&(u.material.needsUpdate=!0,h=b,d=b.version,m=i.toneMapping),u.layers.enableAll(),_.unshift(u,u.geometry,u.material,0,0,null)):b&&b.isTexture&&(l===void 0&&(l=new ct(new Ar(2,2),new $t({name:"BackgroundMaterial",uniforms:Qo(hr.background.uniforms),vertexShader:hr.background.vertexShader,fragmentShader:hr.background.fragmentShader,side:Jn,depthTest:!1,depthWrite:!1,fog:!1})),l.geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),r.update(l)),l.material.uniforms.t2D.value=b,l.material.uniforms.backgroundIntensity.value=y.backgroundIntensity,l.material.toneMapped=_t.getTransfer(b.colorSpace)!==kt,b.matrixAutoUpdate===!0&&b.updateMatrix(),l.material.uniforms.uvTransform.value.copy(b.matrix),(h!==b||d!==b.version||m!==i.toneMapping)&&(l.material.needsUpdate=!0,h=b,d=b.version,m=i.toneMapping),l.layers.enableAll(),_.unshift(l,l.geometry,l.material,0,0,null))}function p(_,y){_.getRGB(Tp,A0(i)),n.buffers.color.setClear(Tp.r,Tp.g,Tp.b,y,o)}function v(){u!==void 0&&(u.geometry.dispose(),u.material.dispose()),l!==void 0&&(l.geometry.dispose(),l.material.dispose())}return{getClearColor:function(){return a},setClearColor:function(_,y=1){a.set(_),c=y,p(a,c)},getClearAlpha:function(){return c},setClearAlpha:function(_){c=_,p(a,c)},render:x,addToRenderList:f,dispose:v}}function O1(i,e){let t=i.getParameter(i.MAX_VERTEX_ATTRIBS),n={},r=d(null),s=r,o=!1;function a(S,C,N,I,L){let q=!1,K=h(I,N,C);s!==K&&(s=K,l(s.object)),q=m(S,I,N,L),q&&g(S,I,N,L),L!==null&&e.update(L,i.ELEMENT_ARRAY_BUFFER),(q||o)&&(o=!1,y(S,C,N,I),L!==null&&i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,e.get(L).buffer))}function c(){return i.createVertexArray()}function l(S){return i.bindVertexArray(S)}function u(S){return i.deleteVertexArray(S)}function h(S,C,N){let I=N.wireframe===!0,L=n[S.id];L===void 0&&(L={},n[S.id]=L);let q=L[C.id];q===void 0&&(q={},L[C.id]=q);let K=q[I];return K===void 0&&(K=d(c()),q[I]=K),K}function d(S){let C=[],N=[],I=[];for(let L=0;L<t;L++)C[L]=0,N[L]=0,I[L]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:C,enabledAttributes:N,attributeDivisors:I,object:S,attributes:{},index:null}}function m(S,C,N,I){let L=s.attributes,q=C.attributes,K=0,B=N.getAttributes();for(let j in B)if(B[j].location>=0){let se=L[j],ce=q[j];if(ce===void 0&&(j==="instanceMatrix"&&S.instanceMatrix&&(ce=S.instanceMatrix),j==="instanceColor"&&S.instanceColor&&(ce=S.instanceColor)),se===void 0||se.attribute!==ce||ce&&se.data!==ce.data)return!0;K++}return s.attributesNum!==K||s.index!==I}function g(S,C,N,I){let L={},q=C.attributes,K=0,B=N.getAttributes();for(let j in B)if(B[j].location>=0){let se=q[j];se===void 0&&(j==="instanceMatrix"&&S.instanceMatrix&&(se=S.instanceMatrix),j==="instanceColor"&&S.instanceColor&&(se=S.instanceColor));let ce={};ce.attribute=se,se&&se.data&&(ce.data=se.data),L[j]=ce,K++}s.attributes=L,s.attributesNum=K,s.index=I}function x(){let S=s.newAttributes;for(let C=0,N=S.length;C<N;C++)S[C]=0}function f(S){p(S,0)}function p(S,C){let N=s.newAttributes,I=s.enabledAttributes,L=s.attributeDivisors;N[S]=1,I[S]===0&&(i.enableVertexAttribArray(S),I[S]=1),L[S]!==C&&(i.vertexAttribDivisor(S,C),L[S]=C)}function v(){let S=s.newAttributes,C=s.enabledAttributes;for(let N=0,I=C.length;N<I;N++)C[N]!==S[N]&&(i.disableVertexAttribArray(N),C[N]=0)}function _(S,C,N,I,L,q,K){K===!0?i.vertexAttribIPointer(S,C,N,L,q):i.vertexAttribPointer(S,C,N,I,L,q)}function y(S,C,N,I){x();let L=I.attributes,q=N.getAttributes(),K=C.defaultAttributeValues;for(let B in q){let j=q[B];if(j.location>=0){let J=L[B];if(J===void 0&&(B==="instanceMatrix"&&S.instanceMatrix&&(J=S.instanceMatrix),B==="instanceColor"&&S.instanceColor&&(J=S.instanceColor)),J!==void 0){let se=J.normalized,ce=J.itemSize,me=e.get(J);if(me===void 0)continue;let Se=me.buffer,V=me.type,w=me.bytesPerElement,O=V===i.INT||V===i.UNSIGNED_INT||J.gpuType===zu;if(J.isInterleavedBufferAttribute){let W=J.data,Q=W.stride,ee=J.offset;if(W.isInstancedInterleavedBuffer){for(let he=0;he<j.locationSize;he++)p(j.location+he,W.meshPerAttribute);S.isInstancedMesh!==!0&&I._maxInstanceCount===void 0&&(I._maxInstanceCount=W.meshPerAttribute*W.count)}else for(let he=0;he<j.locationSize;he++)f(j.location+he);i.bindBuffer(i.ARRAY_BUFFER,Se);for(let he=0;he<j.locationSize;he++)_(j.location+he,ce/j.locationSize,V,se,Q*w,(ee+ce/j.locationSize*he)*w,O)}else{if(J.isInstancedBufferAttribute){for(let W=0;W<j.locationSize;W++)p(j.location+W,J.meshPerAttribute);S.isInstancedMesh!==!0&&I._maxInstanceCount===void 0&&(I._maxInstanceCount=J.meshPerAttribute*J.count)}else for(let W=0;W<j.locationSize;W++)f(j.location+W);i.bindBuffer(i.ARRAY_BUFFER,Se);for(let W=0;W<j.locationSize;W++)_(j.location+W,ce/j.locationSize,V,se,ce*w,ce/j.locationSize*W*w,O)}}else if(K!==void 0){let se=K[B];if(se!==void 0)switch(se.length){case 2:i.vertexAttrib2fv(j.location,se);break;case 3:i.vertexAttrib3fv(j.location,se);break;case 4:i.vertexAttrib4fv(j.location,se);break;default:i.vertexAttrib1fv(j.location,se)}}}}v()}function b(){T();for(let S in n){let C=n[S];for(let N in C){let I=C[N];for(let L in I)u(I[L].object),delete I[L];delete C[N]}delete n[S]}}function E(S){if(n[S.id]===void 0)return;let C=n[S.id];for(let N in C){let I=C[N];for(let L in I)u(I[L].object),delete I[L];delete C[N]}delete n[S.id]}function A(S){for(let C in n){let N=n[C];if(N[S.id]===void 0)continue;let I=N[S.id];for(let L in I)u(I[L].object),delete I[L];delete N[S.id]}}function T(){M(),o=!0,s!==r&&(s=r,l(s.object))}function M(){r.geometry=null,r.program=null,r.wireframe=!1}return{setup:a,reset:T,resetDefaultState:M,dispose:b,releaseStatesOfGeometry:E,releaseStatesOfProgram:A,initAttributes:x,enableAttribute:f,disableUnusedAttributes:v}}function D1(i,e,t){let n;function r(l){n=l}function s(l,u){i.drawArrays(n,l,u),t.update(u,n,1)}function o(l,u,h){h!==0&&(i.drawArraysInstanced(n,l,u,h),t.update(u,n,h))}function a(l,u,h){if(h===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(n,l,0,u,0,h);let m=0;for(let g=0;g<h;g++)m+=u[g];t.update(m,n,1)}function c(l,u,h,d){if(h===0)return;let m=e.get("WEBGL_multi_draw");if(m===null)for(let g=0;g<l.length;g++)o(l[g],u[g],d[g]);else{m.multiDrawArraysInstancedWEBGL(n,l,0,u,0,d,0,h);let g=0;for(let x=0;x<h;x++)g+=u[x]*d[x];t.update(g,n,1)}}this.setMode=r,this.render=s,this.renderInstances=o,this.renderMultiDraw=a,this.renderMultiDrawInstances=c}function F1(i,e,t,n){let r;function s(){if(r!==void 0)return r;if(e.has("EXT_texture_filter_anisotropic")===!0){let A=e.get("EXT_texture_filter_anisotropic");r=i.getParameter(A.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r}function o(A){return!(A!==Ln&&n.convert(A)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_FORMAT))}function a(A){let T=A===Hn&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(A!==ci&&n.convert(A)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_TYPE)&&A!==si&&!T)}function c(A){if(A==="highp"){if(i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.HIGH_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.HIGH_FLOAT).precision>0)return"highp";A="mediump"}return A==="mediump"&&i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.MEDIUM_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let l=t.precision!==void 0?t.precision:"highp",u=c(l);u!==l&&(console.warn("THREE.WebGLRenderer:",l,"not supported, using",u,"instead."),l=u);let h=t.logarithmicDepthBuffer===!0,d=t.reverseDepthBuffer===!0&&e.has("EXT_clip_control"),m=i.getParameter(i.MAX_TEXTURE_IMAGE_UNITS),g=i.getParameter(i.MAX_VERTEX_TEXTURE_IMAGE_UNITS),x=i.getParameter(i.MAX_TEXTURE_SIZE),f=i.getParameter(i.MAX_CUBE_MAP_TEXTURE_SIZE),p=i.getParameter(i.MAX_VERTEX_ATTRIBS),v=i.getParameter(i.MAX_VERTEX_UNIFORM_VECTORS),_=i.getParameter(i.MAX_VARYING_VECTORS),y=i.getParameter(i.MAX_FRAGMENT_UNIFORM_VECTORS),b=g>0,E=i.getParameter(i.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:s,getMaxPrecision:c,textureFormatReadable:o,textureTypeReadable:a,precision:l,logarithmicDepthBuffer:h,reverseDepthBuffer:d,maxTextures:m,maxVertexTextures:g,maxTextureSize:x,maxCubemapSize:f,maxAttributes:p,maxVertexUniforms:v,maxVaryings:_,maxFragmentUniforms:y,vertexTextures:b,maxSamples:E}}function U1(i){let e=this,t=null,n=0,r=!1,s=!1,o=new Li,a=new xt,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(h,d){let m=h.length!==0||d||n!==0||r;return r=d,n=h.length,m},this.beginShadows=function(){s=!0,u(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(h,d){t=u(h,d,0)},this.setState=function(h,d,m){let g=h.clippingPlanes,x=h.clipIntersection,f=h.clipShadows,p=i.get(h);if(!r||g===null||g.length===0||s&&!f)s?u(null):l();else{let v=s?0:n,_=v*4,y=p.clippingState||null;c.value=y,y=u(g,d,_,m);for(let b=0;b!==_;++b)y[b]=t[b];p.clippingState=y,this.numIntersection=x?this.numPlanes:0,this.numPlanes+=v}};function l(){c.value!==t&&(c.value=t,c.needsUpdate=n>0),e.numPlanes=n,e.numIntersection=0}function u(h,d,m,g){let x=h!==null?h.length:0,f=null;if(x!==0){if(f=c.value,g!==!0||f===null){let p=m+x*4,v=d.matrixWorldInverse;a.getNormalMatrix(v),(f===null||f.length<p)&&(f=new Float32Array(p));for(let _=0,y=m;_!==x;++_,y+=4)o.copy(h[_]).applyMatrix4(v,a),o.normal.toArray(f,y),f[y+3]=o.constant}c.value=f,c.needsUpdate=!0}return e.numPlanes=x,e.numIntersection=0,f}}function k1(i){let e=new WeakMap;function t(o,a){return a===_c?o.mapping=Nr:a===bc&&(o.mapping=us),o}function n(o){if(o&&o.isTexture){let a=o.mapping;if(a===_c||a===bc)if(e.has(o)){let c=e.get(o).texture;return t(c,o.mapping)}else{let c=o.image;if(c&&c.height>0){let l=new Dl(c.height);return l.fromEquirectangularTexture(i,o),e.set(o,l),o.addEventListener("dispose",r),t(l.texture,o.mapping)}else return null}}return o}function r(o){let a=o.target;a.removeEventListener("dispose",r);let c=e.get(a);c!==void 0&&(e.delete(a),c.dispose())}function s(){e=new WeakMap}return{get:n,dispose:s}}var Ic=4,ub=[.125,.215,.35,.446,.526,.582],na=20,N0=new cr,hb=new Ue,L0=null,O0=0,D0=0,F0=!1,ta=(1+Math.sqrt(5))/2,Pc=1/ta,db=[new z(-ta,Pc,0),new z(ta,Pc,0),new z(-Pc,0,ta),new z(Pc,0,ta),new z(0,ta,-Pc),new z(0,ta,Pc),new z(-1,1,-1),new z(1,1,-1),new z(-1,1,1),new z(1,1,1)],ia=class{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(e,t=0,n=.1,r=100){L0=this._renderer.getRenderTarget(),O0=this._renderer.getActiveCubeFace(),D0=this._renderer.getActiveMipmapLevel(),F0=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(256);let s=this._allocateTargets();return s.depthBuffer=!0,this._sceneToCubeUV(e,n,r,s),t>0&&this._blur(s,0,0,t),this._applyPMREM(s),this._cleanup(s),s}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=mb(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=pb(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.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._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodPlanes.length;e++)this._lodPlanes[e].dispose()}_cleanup(e){this._renderer.setRenderTarget(L0,O0,D0),this._renderer.xr.enabled=F0,e.scissorTest=!1,Ap(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===Nr||e.mapping===us?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),L0=this._renderer.getRenderTarget(),O0=this._renderer.getActiveCubeFace(),D0=this._renderer.getActiveMipmapLevel(),F0=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;let n=t||this._allocateTargets();return this._textureToCubeUV(e,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){let e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,n={magFilter:nn,minFilter:nn,generateMipmaps:!1,type:Hn,format:Ln,colorSpace:On,depthBuffer:!1},r=fb(e,t,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=fb(e,t,n);let{_lodMax:s}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=B1(s)),this._blurMaterial=z1(s,e,t)}return r}_compileMaterial(e){let t=new ct(this._lodPlanes[0],e);this._renderer.compile(t,N0)}_sceneToCubeUV(e,t,n,r){let a=new jt(90,1,t,n),c=[1,-1,1,1,1,1],l=[1,1,1,-1,-1,-1],u=this._renderer,h=u.autoClear,d=u.toneMapping;u.getClearColor(hb),u.toneMapping=Ir,u.autoClear=!1;let m=new Ht({name:"PMREM.Background",side:un,depthWrite:!1,depthTest:!1}),g=new ct(new Qn,m),x=!1,f=e.background;f?f.isColor&&(m.color.copy(f),e.background=null,x=!0):(m.color.copy(hb),x=!0);for(let p=0;p<6;p++){let v=p%3;v===0?(a.up.set(0,c[p],0),a.lookAt(l[p],0,0)):v===1?(a.up.set(0,0,c[p]),a.lookAt(0,l[p],0)):(a.up.set(0,c[p],0),a.lookAt(0,0,l[p]));let _=this._cubeSize;Ap(r,v*_,p>2?_:0,_,_),u.setRenderTarget(r),x&&u.render(g,a),u.render(e,a)}g.geometry.dispose(),g.material.dispose(),u.toneMapping=d,u.autoClear=h,e.background=f}_textureToCubeUV(e,t){let n=this._renderer,r=e.mapping===Nr||e.mapping===us;r?(this._cubemapMaterial===null&&(this._cubemapMaterial=mb()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=pb());let s=r?this._cubemapMaterial:this._equirectMaterial,o=new ct(this._lodPlanes[0],s),a=s.uniforms;a.envMap.value=e;let c=this._cubeSize;Ap(t,0,0,3*c,2*c),n.setRenderTarget(t),n.render(o,N0)}_applyPMREM(e){let t=this._renderer,n=t.autoClear;t.autoClear=!1;let r=this._lodPlanes.length;for(let s=1;s<r;s++){let o=Math.sqrt(this._sigmas[s]*this._sigmas[s]-this._sigmas[s-1]*this._sigmas[s-1]),a=db[(r-s-1)%db.length];this._blur(e,s-1,s,o,a)}t.autoClear=n}_blur(e,t,n,r,s){let o=this._pingPongRenderTarget;this._halfBlur(e,o,t,n,r,"latitudinal",s),this._halfBlur(o,e,n,n,r,"longitudinal",s)}_halfBlur(e,t,n,r,s,o,a){let c=this._renderer,l=this._blurMaterial;o!=="latitudinal"&&o!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");let u=3,h=new ct(this._lodPlanes[r],l),d=l.uniforms,m=this._sizeLods[n]-1,g=isFinite(s)?Math.PI/(2*m):2*Math.PI/(2*na-1),x=s/g,f=isFinite(s)?1+Math.floor(u*x):na;f>na&&console.warn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${f} samples when the maximum is set to ${na}`);let p=[],v=0;for(let A=0;A<na;++A){let T=A/x,M=Math.exp(-T*T/2);p.push(M),A===0?v+=M:A<f&&(v+=2*M)}for(let A=0;A<p.length;A++)p[A]=p[A]/v;d.envMap.value=e.texture,d.samples.value=f,d.weights.value=p,d.latitudinal.value=o==="latitudinal",a&&(d.poleAxis.value=a);let{_lodMax:_}=this;d.dTheta.value=g,d.mipInt.value=_-n;let y=this._sizeLods[r],b=3*y*(r>_-Ic?r-_+Ic:0),E=4*(this._cubeSize-y);Ap(t,b,E,3*y,2*y),c.setRenderTarget(t),c.render(h,N0)}};function B1(i){let e=[],t=[],n=[],r=i,s=i-Ic+1+ub.length;for(let o=0;o<s;o++){let a=Math.pow(2,r);t.push(a);let c=1/a;o>i-Ic?c=ub[o-i+Ic-1]:o===0&&(c=0),n.push(c);let l=1/(a-2),u=-l,h=1+l,d=[u,u,h,u,h,h,u,u,h,h,u,h],m=6,g=6,x=3,f=2,p=1,v=new Float32Array(x*g*m),_=new Float32Array(f*g*m),y=new Float32Array(p*g*m);for(let E=0;E<m;E++){let A=E%3*2/3-1,T=E>2?0:-1,M=[A,T,0,A+2/3,T,0,A+2/3,T+1,0,A,T,0,A+2/3,T+1,0,A,T+1,0];v.set(M,x*g*E),_.set(d,f*g*E);let S=[E,E,E,E,E,E];y.set(S,p*g*E)}let b=new ot;b.setAttribute("position",new gt(v,x)),b.setAttribute("uv",new gt(_,f)),b.setAttribute("faceIndex",new gt(y,p)),e.push(b),r>Ic&&r--}return{lodPlanes:e,sizeLods:t,sigmas:n}}function fb(i,e,t){let n=new on(i,e,t);return n.texture.mapping=qo,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function Ap(i,e,t,n,r){i.viewport.set(e,t,n,r),i.scissor.set(e,t,n,r)}function z1(i,e,t){let n=new Float32Array(na),r=new z(0,1,0);return new $t({name:"SphericalGaussianBlur",defines:{n:na,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${i}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:r}},vertexShader:Y0(),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:yn,depthTest:!1,depthWrite:!1})}function pb(){return new $t({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:Y0(),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:yn,depthTest:!1,depthWrite:!1})}function mb(){return new $t({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Y0(),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:yn,depthTest:!1,depthWrite:!1})}function Y0(){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 );
}
`}function V1(i){let e=new WeakMap,t=null;function n(a){if(a&&a.isTexture){let c=a.mapping,l=c===_c||c===bc,u=c===Nr||c===us;if(l||u){let h=e.get(a),d=h!==void 0?h.texture.pmremVersion:0;if(a.isRenderTargetTexture&&a.pmremVersion!==d)return t===null&&(t=new ia(i)),h=l?t.fromEquirectangular(a,h):t.fromCubemap(a,h),h.texture.pmremVersion=a.pmremVersion,e.set(a,h),h.texture;if(h!==void 0)return h.texture;{let m=a.image;return l&&m&&m.height>0||u&&m&&r(m)?(t===null&&(t=new ia(i)),h=l?t.fromEquirectangular(a):t.fromCubemap(a),h.texture.pmremVersion=a.pmremVersion,e.set(a,h),a.addEventListener("dispose",s),h.texture):null}}}return a}function r(a){let c=0,l=6;for(let u=0;u<l;u++)a[u]!==void 0&&c++;return c===l}function s(a){let c=a.target;c.removeEventListener("dispose",s);let l=e.get(c);l!==void 0&&(e.delete(c),l.dispose())}function o(){e=new WeakMap,t!==null&&(t.dispose(),t=null)}return{get:n,dispose:o}}function H1(i){let e={};function t(n){if(e[n]!==void 0)return e[n];let r;switch(n){case"WEBGL_depth_texture":r=i.getExtension("WEBGL_depth_texture")||i.getExtension("MOZ_WEBGL_depth_texture")||i.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":r=i.getExtension("EXT_texture_filter_anisotropic")||i.getExtension("MOZ_EXT_texture_filter_anisotropic")||i.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":r=i.getExtension("WEBGL_compressed_texture_s3tc")||i.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||i.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":r=i.getExtension("WEBGL_compressed_texture_pvrtc")||i.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:r=i.getExtension(n)}return e[n]=r,r}return{has:function(n){return t(n)!==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(n){let r=t(n);return r===null&&Jo("THREE.WebGLRenderer: "+n+" extension not supported."),r}}}function G1(i,e,t,n){let r={},s=new WeakMap;function o(h){let d=h.target;d.index!==null&&e.remove(d.index);for(let g in d.attributes)e.remove(d.attributes[g]);d.removeEventListener("dispose",o),delete r[d.id];let m=s.get(d);m&&(e.remove(m),s.delete(d)),n.releaseStatesOfGeometry(d),d.isInstancedBufferGeometry===!0&&delete d._maxInstanceCount,t.memory.geometries--}function a(h,d){return r[d.id]===!0||(d.addEventListener("dispose",o),r[d.id]=!0,t.memory.geometries++),d}function c(h){let d=h.attributes;for(let m in d)e.update(d[m],i.ARRAY_BUFFER)}function l(h){let d=[],m=h.index,g=h.attributes.position,x=0;if(m!==null){let v=m.array;x=m.version;for(let _=0,y=v.length;_<y;_+=3){let b=v[_+0],E=v[_+1],A=v[_+2];d.push(b,E,E,A,A,b)}}else if(g!==void 0){let v=g.array;x=g.version;for(let _=0,y=v.length/3-1;_<y;_+=3){let b=_+0,E=_+1,A=_+2;d.push(b,E,E,A,A,b)}}else return;let f=new(S0(d)?tc:ec)(d,1);f.version=x;let p=s.get(h);p&&e.remove(p),s.set(h,f)}function u(h){let d=s.get(h);if(d){let m=h.index;m!==null&&d.version<m.version&&l(h)}else l(h);return s.get(h)}return{get:a,update:c,getWireframeAttribute:u}}function W1(i,e,t){let n;function r(d){n=d}let s,o;function a(d){s=d.type,o=d.bytesPerElement}function c(d,m){i.drawElements(n,m,s,d*o),t.update(m,n,1)}function l(d,m,g){g!==0&&(i.drawElementsInstanced(n,m,s,d*o,g),t.update(m,n,g))}function u(d,m,g){if(g===0)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(n,m,0,s,d,0,g);let f=0;for(let p=0;p<g;p++)f+=m[p];t.update(f,n,1)}function h(d,m,g,x){if(g===0)return;let f=e.get("WEBGL_multi_draw");if(f===null)for(let p=0;p<d.length;p++)l(d[p]/o,m[p],x[p]);else{f.multiDrawElementsInstancedWEBGL(n,m,0,s,d,0,x,0,g);let p=0;for(let v=0;v<g;v++)p+=m[v]*x[v];t.update(p,n,1)}}this.setMode=r,this.setIndex=a,this.render=c,this.renderInstances=l,this.renderMultiDraw=u,this.renderMultiDrawInstances=h}function X1(i){let e={geometries:0,textures:0},t={frame:0,calls:0,triangles:0,points:0,lines:0};function n(s,o,a){switch(t.calls++,o){case i.TRIANGLES:t.triangles+=a*(s/3);break;case i.LINES:t.lines+=a*(s/2);break;case i.LINE_STRIP:t.lines+=a*(s-1);break;case i.LINE_LOOP:t.lines+=a*s;break;case i.POINTS:t.points+=a*s;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",o);break}}function r(){t.calls=0,t.triangles=0,t.points=0,t.lines=0}return{memory:e,render:t,programs:null,autoReset:!0,reset:r,update:n}}function Y1(i,e,t){let n=new WeakMap,r=new It;function s(o,a,c){let l=o.morphTargetInfluences,u=a.morphAttributes.position||a.morphAttributes.normal||a.morphAttributes.color,h=u!==void 0?u.length:0,d=n.get(a);if(d===void 0||d.count!==h){let M=function(){A.dispose(),n.delete(a),a.removeEventListener("dispose",M)};d!==void 0&&d.texture.dispose();let m=a.morphAttributes.position!==void 0,g=a.morphAttributes.normal!==void 0,x=a.morphAttributes.color!==void 0,f=a.morphAttributes.position||[],p=a.morphAttributes.normal||[],v=a.morphAttributes.color||[],_=0;m===!0&&(_=1),g===!0&&(_=2),x===!0&&(_=3);let y=a.attributes.position.count*_,b=1;y>e.maxTextureSize&&(b=Math.ceil(y/e.maxTextureSize),y=e.maxTextureSize);let E=new Float32Array(y*b*4*h),A=new Po(E,y,b,h);A.type=si,A.needsUpdate=!0;let T=_*4;for(let S=0;S<h;S++){let C=f[S],N=p[S],I=v[S],L=y*b*4*S;for(let q=0;q<C.count;q++){let K=q*T;m===!0&&(r.fromBufferAttribute(C,q),E[L+K+0]=r.x,E[L+K+1]=r.y,E[L+K+2]=r.z,E[L+K+3]=0),g===!0&&(r.fromBufferAttribute(N,q),E[L+K+4]=r.x,E[L+K+5]=r.y,E[L+K+6]=r.z,E[L+K+7]=0),x===!0&&(r.fromBufferAttribute(I,q),E[L+K+8]=r.x,E[L+K+9]=r.y,E[L+K+10]=r.z,E[L+K+11]=I.itemSize===4?r.w:1)}}d={count:h,texture:A,size:new Me(y,b)},n.set(a,d),a.addEventListener("dispose",M)}if(o.isInstancedMesh===!0&&o.morphTexture!==null)c.getUniforms().setValue(i,"morphTexture",o.morphTexture,t);else{let m=0;for(let x=0;x<l.length;x++)m+=l[x];let g=a.morphTargetsRelative?1:1-m;c.getUniforms().setValue(i,"morphTargetBaseInfluence",g),c.getUniforms().setValue(i,"morphTargetInfluences",l)}c.getUniforms().setValue(i,"morphTargetsTexture",d.texture,t),c.getUniforms().setValue(i,"morphTargetsTextureSize",d.size)}return{update:s}}function j1(i,e,t,n){let r=new WeakMap;function s(c){let l=n.render.frame,u=c.geometry,h=e.get(c,u);if(r.get(h)!==l&&(e.update(h),r.set(h,l)),c.isInstancedMesh&&(c.hasEventListener("dispose",a)===!1&&c.addEventListener("dispose",a),r.get(c)!==l&&(t.update(c.instanceMatrix,i.ARRAY_BUFFER),c.instanceColor!==null&&t.update(c.instanceColor,i.ARRAY_BUFFER),r.set(c,l))),c.isSkinnedMesh){let d=c.skeleton;r.get(d)!==l&&(d.update(),r.set(d,l))}return h}function o(){r=new WeakMap}function a(c){let l=c.target;l.removeEventListener("dispose",a),t.remove(l.instanceMatrix),l.instanceColor!==null&&t.remove(l.instanceColor)}return{update:s,dispose:o}}var Ob=new Qt,gb=new Xs(1,1),Db=new Po,Fb=new $a,Ub=new Vs,xb=[],yb=[],vb=new Float32Array(16),_b=new Float32Array(9),bb=new Float32Array(4);function Lc(i,e,t){let n=i[0];if(n<=0||n>0)return i;let r=e*t,s=xb[r];if(s===void 0&&(s=new Float32Array(r),xb[r]=s),e!==0){n.toArray(s,0);for(let o=1,a=0;o!==e;++o)a+=t,i[o].toArray(s,a)}return s}function wn(i,e){if(i.length!==e.length)return!1;for(let t=0,n=i.length;t<n;t++)if(i[t]!==e[t])return!1;return!0}function Rn(i,e){for(let t=0,n=e.length;t<n;t++)i[t]=e[t]}function Rp(i,e){let t=yb[e];t===void 0&&(t=new Int32Array(e),yb[e]=t);for(let n=0;n!==e;++n)t[n]=i.allocateTextureUnit();return t}function q1(i,e){let t=this.cache;t[0]!==e&&(i.uniform1f(this.addr,e),t[0]=e)}function K1(i,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(i.uniform2f(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(wn(t,e))return;i.uniform2fv(this.addr,e),Rn(t,e)}}function Z1(i,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(i.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)&&(i.uniform3f(this.addr,e.r,e.g,e.b),t[0]=e.r,t[1]=e.g,t[2]=e.b);else{if(wn(t,e))return;i.uniform3fv(this.addr,e),Rn(t,e)}}function J1(i,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(i.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(wn(t,e))return;i.uniform4fv(this.addr,e),Rn(t,e)}}function Q1(i,e){let t=this.cache,n=e.elements;if(n===void 0){if(wn(t,e))return;i.uniformMatrix2fv(this.addr,!1,e),Rn(t,e)}else{if(wn(t,n))return;bb.set(n),i.uniformMatrix2fv(this.addr,!1,bb),Rn(t,n)}}function $1(i,e){let t=this.cache,n=e.elements;if(n===void 0){if(wn(t,e))return;i.uniformMatrix3fv(this.addr,!1,e),Rn(t,e)}else{if(wn(t,n))return;_b.set(n),i.uniformMatrix3fv(this.addr,!1,_b),Rn(t,n)}}function eR(i,e){let t=this.cache,n=e.elements;if(n===void 0){if(wn(t,e))return;i.uniformMatrix4fv(this.addr,!1,e),Rn(t,e)}else{if(wn(t,n))return;vb.set(n),i.uniformMatrix4fv(this.addr,!1,vb),Rn(t,n)}}function tR(i,e){let t=this.cache;t[0]!==e&&(i.uniform1i(this.addr,e),t[0]=e)}function nR(i,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(i.uniform2i(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(wn(t,e))return;i.uniform2iv(this.addr,e),Rn(t,e)}}function iR(i,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(i.uniform3i(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(wn(t,e))return;i.uniform3iv(this.addr,e),Rn(t,e)}}function rR(i,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(i.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(wn(t,e))return;i.uniform4iv(this.addr,e),Rn(t,e)}}function sR(i,e){let t=this.cache;t[0]!==e&&(i.uniform1ui(this.addr,e),t[0]=e)}function oR(i,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(i.uniform2ui(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(wn(t,e))return;i.uniform2uiv(this.addr,e),Rn(t,e)}}function aR(i,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(i.uniform3ui(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(wn(t,e))return;i.uniform3uiv(this.addr,e),Rn(t,e)}}function cR(i,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(i.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(wn(t,e))return;i.uniform4uiv(this.addr,e),Rn(t,e)}}function lR(i,e,t){let n=this.cache,r=t.allocateTextureUnit();n[0]!==r&&(i.uniform1i(this.addr,r),n[0]=r);let s;this.type===i.SAMPLER_2D_SHADOW?(gb.compareFunction=_p,s=gb):s=Ob,t.setTexture2D(e||s,r)}function uR(i,e,t){let n=this.cache,r=t.allocateTextureUnit();n[0]!==r&&(i.uniform1i(this.addr,r),n[0]=r),t.setTexture3D(e||Fb,r)}function hR(i,e,t){let n=this.cache,r=t.allocateTextureUnit();n[0]!==r&&(i.uniform1i(this.addr,r),n[0]=r),t.setTextureCube(e||Ub,r)}function dR(i,e,t){let n=this.cache,r=t.allocateTextureUnit();n[0]!==r&&(i.uniform1i(this.addr,r),n[0]=r),t.setTexture2DArray(e||Db,r)}function fR(i){switch(i){case 5126:return q1;case 35664:return K1;case 35665:return Z1;case 35666:return J1;case 35674:return Q1;case 35675:return $1;case 35676:return eR;case 5124:case 35670:return tR;case 35667:case 35671:return nR;case 35668:case 35672:return iR;case 35669:case 35673:return rR;case 5125:return sR;case 36294:return oR;case 36295:return aR;case 36296:return cR;case 35678:case 36198:case 36298:case 36306:case 35682:return lR;case 35679:case 36299:case 36307:return uR;case 35680:case 36300:case 36308:case 36293:return hR;case 36289:case 36303:case 36311:case 36292:return dR}}function pR(i,e){i.uniform1fv(this.addr,e)}function mR(i,e){let t=Lc(e,this.size,2);i.uniform2fv(this.addr,t)}function gR(i,e){let t=Lc(e,this.size,3);i.uniform3fv(this.addr,t)}function xR(i,e){let t=Lc(e,this.size,4);i.uniform4fv(this.addr,t)}function yR(i,e){let t=Lc(e,this.size,4);i.uniformMatrix2fv(this.addr,!1,t)}function vR(i,e){let t=Lc(e,this.size,9);i.uniformMatrix3fv(this.addr,!1,t)}function _R(i,e){let t=Lc(e,this.size,16);i.uniformMatrix4fv(this.addr,!1,t)}function bR(i,e){i.uniform1iv(this.addr,e)}function MR(i,e){i.uniform2iv(this.addr,e)}function ER(i,e){i.uniform3iv(this.addr,e)}function SR(i,e){i.uniform4iv(this.addr,e)}function TR(i,e){i.uniform1uiv(this.addr,e)}function AR(i,e){i.uniform2uiv(this.addr,e)}function wR(i,e){i.uniform3uiv(this.addr,e)}function RR(i,e){i.uniform4uiv(this.addr,e)}function CR(i,e,t){let n=this.cache,r=e.length,s=Rp(t,r);wn(n,s)||(i.uniform1iv(this.addr,s),Rn(n,s));for(let o=0;o!==r;++o)t.setTexture2D(e[o]||Ob,s[o])}function PR(i,e,t){let n=this.cache,r=e.length,s=Rp(t,r);wn(n,s)||(i.uniform1iv(this.addr,s),Rn(n,s));for(let o=0;o!==r;++o)t.setTexture3D(e[o]||Fb,s[o])}function IR(i,e,t){let n=this.cache,r=e.length,s=Rp(t,r);wn(n,s)||(i.uniform1iv(this.addr,s),Rn(n,s));for(let o=0;o!==r;++o)t.setTextureCube(e[o]||Ub,s[o])}function NR(i,e,t){let n=this.cache,r=e.length,s=Rp(t,r);wn(n,s)||(i.uniform1iv(this.addr,s),Rn(n,s));for(let o=0;o!==r;++o)t.setTexture2DArray(e[o]||Db,s[o])}function LR(i){switch(i){case 5126:return pR;case 35664:return mR;case 35665:return gR;case 35666:return xR;case 35674:return yR;case 35675:return vR;case 35676:return _R;case 5124:case 35670:return bR;case 35667:case 35671:return MR;case 35668:case 35672:return ER;case 35669:case 35673:return SR;case 5125:return TR;case 36294:return AR;case 36295:return wR;case 36296:return RR;case 35678:case 36198:case 36298:case 36306:case 35682:return CR;case 35679:case 36299:case 36307:return PR;case 35680:case 36300:case 36308:case 36293:return IR;case 36289:case 36303:case 36311:case 36292:return NR}}var k0=class{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.setValue=fR(t.type)}},B0=class{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=LR(t.type)}},z0=class{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,n){let r=this.seq;for(let s=0,o=r.length;s!==o;++s){let a=r[s];a.setValue(e,t[a.id],n)}}},U0=/(\w+)(\])?(\[|\.)?/g;function Mb(i,e){i.seq.push(e),i.map[e.id]=e}function OR(i,e,t){let n=i.name,r=n.length;for(U0.lastIndex=0;;){let s=U0.exec(n),o=U0.lastIndex,a=s[1],c=s[2]==="]",l=s[3];if(c&&(a=a|0),l===void 0||l==="["&&o+2===r){Mb(t,l===void 0?new k0(a,i,e):new B0(a,i,e));break}else{let h=t.map[a];h===void 0&&(h=new z0(a),Mb(t,h)),t=h}}}var Nc=class{constructor(e,t){this.seq=[],this.map={};let n=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let r=0;r<n;++r){let s=e.getActiveUniform(t,r),o=e.getUniformLocation(t,s.name);OR(s,o,this)}}setValue(e,t,n,r){let s=this.map[t];s!==void 0&&s.setValue(e,n,r)}setOptional(e,t,n){let r=t[n];r!==void 0&&this.setValue(e,n,r)}static upload(e,t,n,r){for(let s=0,o=t.length;s!==o;++s){let a=t[s],c=n[a.id];c.needsUpdate!==!1&&a.setValue(e,c.value,r)}}static seqWithValue(e,t){let n=[];for(let r=0,s=e.length;r!==s;++r){let o=e[r];o.id in t&&n.push(o)}return n}};function Eb(i,e,t){let n=i.createShader(e);return i.shaderSource(n,t),i.compileShader(n),n}var DR=37297,FR=0;function UR(i,e){let t=i.split(`
`),n=[],r=Math.max(e-6,0),s=Math.min(e+6,t.length);for(let o=r;o<s;o++){let a=o+1;n.push(`${a===e?">":" "} ${a}: ${t[o]}`)}return n.join(`
`)}var Sb=new xt;function kR(i){_t._getMatrix(Sb,_t.workingColorSpace,i);let e=`mat3( ${Sb.elements.map(t=>t.toFixed(4))} )`;switch(_t.getTransfer(i)){case Ka:return[e,"LinearTransferOETF"];case kt:return[e,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space: ",i),[e,"LinearTransferOETF"]}}function Tb(i,e,t){let n=i.getShaderParameter(e,i.COMPILE_STATUS),r=i.getShaderInfoLog(e).trim();if(n&&r==="")return"";let s=/ERROR: 0:(\d+)/.exec(r);if(s){let o=parseInt(s[1]);return t.toUpperCase()+`
`+r+`
`+UR(i.getShaderSource(e),o)}else return r}function BR(i,e){let t=kR(e);return[`vec4 ${i}( vec4 value ) {`,` return ${t[1]}( vec4( value.rgb * ${t[0]}, value.a ) );`,"}"].join(`
`)}function zR(i,e){let t;switch(e){case Ou:t="Linear";break;case Du:t="Reinhard";break;case Fu:t="Cineon";break;case jo:t="ACESFilmic";break;case Uu:t="AgX";break;case ku:t="Neutral";break;case c0:t="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),t="Linear"}return"vec3 "+i+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}var wp=new z;function VR(){_t.getLuminanceCoefficients(wp);let i=wp.x.toFixed(4),e=wp.y.toFixed(4),t=wp.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${i}, ${e}, ${t} );`," return dot( weights, rgb );","}"].join(`
`)}function HR(i){return[i.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",i.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(vh).join(`
`)}function GR(i){let e=[];for(let t in i){let n=i[t];n!==!1&&e.push("#define "+t+" "+n)}return e.join(`
`)}function WR(i,e){let t={},n=i.getProgramParameter(e,i.ACTIVE_ATTRIBUTES);for(let r=0;r<n;r++){let s=i.getActiveAttrib(e,r),o=s.name,a=1;s.type===i.FLOAT_MAT2&&(a=2),s.type===i.FLOAT_MAT3&&(a=3),s.type===i.FLOAT_MAT4&&(a=4),t[o]={type:s.type,location:i.getAttribLocation(e,o),locationSize:a}}return t}function vh(i){return i!==""}function Ab(i,e){let t=e.numSpotLightShadows+e.numSpotLightMaps-e.numSpotLightShadowsWithMaps;return i.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 wb(i,e){return i.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}var XR=/^[ \t]*#include +<([\w\d./]+)>/gm;function V0(i){return i.replace(XR,jR)}var YR=new Map;function jR(i,e){let t=Tt[e];if(t===void 0){let n=YR.get(e);if(n!==void 0)t=Tt[n],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,n);else throw new Error("Can not resolve #include <"+e+">")}return V0(t)}var qR=/#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 Rb(i){return i.replace(qR,KR)}function KR(i,e,t,n){let r="";for(let s=parseInt(e);s<parseInt(t);s++)r+=n.replace(/\[\s*i\s*\]/g,"[ "+s+" ]").replace(/UNROLLED_LOOP_INDEX/g,s);return r}function Cb(i){let e=`precision ${i.precision} float;
precision ${i.precision} int;
precision ${i.precision} sampler2D;
precision ${i.precision} samplerCube;
precision ${i.precision} sampler3D;
precision ${i.precision} sampler2DArray;
precision ${i.precision} sampler2DShadow;
precision ${i.precision} samplerCubeShadow;
precision ${i.precision} sampler2DArrayShadow;
precision ${i.precision} isampler2D;
precision ${i.precision} isampler3D;
precision ${i.precision} isamplerCube;
precision ${i.precision} isampler2DArray;
precision ${i.precision} usampler2D;
precision ${i.precision} usampler3D;
precision ${i.precision} usamplerCube;
precision ${i.precision} usampler2DArray;
`;return i.precision==="highp"?e+=`
#define HIGH_PRECISION`:i.precision==="mediump"?e+=`
#define MEDIUM_PRECISION`:i.precision==="lowp"&&(e+=`
#define LOW_PRECISION`),e}function ZR(i){let e="SHADOWMAP_TYPE_BASIC";return i.shadowMapType===sp?e="SHADOWMAP_TYPE_PCF":i.shadowMapType===Tu?e="SHADOWMAP_TYPE_PCF_SOFT":i.shadowMapType===ur&&(e="SHADOWMAP_TYPE_VSM"),e}function JR(i){let e="ENVMAP_TYPE_CUBE";if(i.envMap)switch(i.envMapMode){case Nr:case us:e="ENVMAP_TYPE_CUBE";break;case qo:e="ENVMAP_TYPE_CUBE_UV";break}return e}function QR(i){let e="ENVMAP_MODE_REFLECTION";if(i.envMap)switch(i.envMapMode){case us:e="ENVMAP_MODE_REFRACTION";break}return e}function $R(i){let e="ENVMAP_BLENDING_NONE";if(i.envMap)switch(i.combine){case vc:e="ENVMAP_BLENDING_MULTIPLY";break;case o0:e="ENVMAP_BLENDING_MIX";break;case a0:e="ENVMAP_BLENDING_ADD";break}return e}function eC(i){let e=i.envMapCubeUVHeight;if(e===null)return null;let t=Math.log2(e)-2,n=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,t),112)),texelHeight:n,maxMip:t}}function tC(i,e,t,n){let r=i.getContext(),s=t.defines,o=t.vertexShader,a=t.fragmentShader,c=ZR(t),l=JR(t),u=QR(t),h=$R(t),d=eC(t),m=HR(t),g=GR(s),x=r.createProgram(),f,p,v=t.glslVersion?"#version "+t.glslVersion+`
`:"";t.isRawShaderMaterial?(f=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g].filter(vh).join(`
`),f.length>0&&(f+=`
`),p=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g].filter(vh).join(`
`),p.length>0&&(p+=`
`)):(f=[Cb(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g,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.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 "+c:"",t.sizeAttenuation?"#define USE_SIZEATTENUATION":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",t.reverseDepthBuffer?"#define USE_REVERSEDEPTHBUF":"","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(vh).join(`
`),p=[Cb(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g,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 "+l:"",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.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||t.batchingColor?"#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.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 "+c:"",t.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",t.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",t.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",t.reverseDepthBuffer?"#define USE_REVERSEDEPTHBUF":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==Ir?"#define TONE_MAPPING":"",t.toneMapping!==Ir?Tt.tonemapping_pars_fragment:"",t.toneMapping!==Ir?zR("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",Tt.colorspace_pars_fragment,BR("linearToOutputTexel",t.outputColorSpace),VR(),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",`
`].filter(vh).join(`
`)),o=V0(o),o=Ab(o,t),o=wb(o,t),a=V0(a),a=Ab(a,t),a=wb(a,t),o=Rb(o),a=Rb(a),t.isRawShaderMaterial!==!0&&(v=`#version 300 es
`,f=[m,"#define attribute in","#define varying out","#define texture2D texture"].join(`
`)+`
`+f,p=["#define varying in",t.glslVersion===Mp?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===Mp?"":"#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(`
`)+`
`+p);let _=v+f+o,y=v+p+a,b=Eb(r,r.VERTEX_SHADER,_),E=Eb(r,r.FRAGMENT_SHADER,y);r.attachShader(x,b),r.attachShader(x,E),t.index0AttributeName!==void 0?r.bindAttribLocation(x,0,t.index0AttributeName):t.morphTargets===!0&&r.bindAttribLocation(x,0,"position"),r.linkProgram(x);function A(C){if(i.debug.checkShaderErrors){let N=r.getProgramInfoLog(x).trim(),I=r.getShaderInfoLog(b).trim(),L=r.getShaderInfoLog(E).trim(),q=!0,K=!0;if(r.getProgramParameter(x,r.LINK_STATUS)===!1)if(q=!1,typeof i.debug.onShaderError=="function")i.debug.onShaderError(r,x,b,E);else{let B=Tb(r,b,"vertex"),j=Tb(r,E,"fragment");console.error("THREE.WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(x,r.VALIDATE_STATUS)+`
Material Name: `+C.name+`
Material Type: `+C.type+`
Program Info Log: `+N+`
`+B+`
`+j)}else N!==""?console.warn("THREE.WebGLProgram: Program Info Log:",N):(I===""||L==="")&&(K=!1);K&&(C.diagnostics={runnable:q,programLog:N,vertexShader:{log:I,prefix:f},fragmentShader:{log:L,prefix:p}})}r.deleteShader(b),r.deleteShader(E),T=new Nc(r,x),M=WR(r,x)}let T;this.getUniforms=function(){return T===void 0&&A(this),T};let M;this.getAttributes=function(){return M===void 0&&A(this),M};let S=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return S===!1&&(S=r.getProgramParameter(x,DR)),S},this.destroy=function(){n.releaseStatesOfProgram(this),r.deleteProgram(x),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=FR++,this.cacheKey=e,this.usedTimes=1,this.program=x,this.vertexShader=b,this.fragmentShader=E,this}var nC=0,H0=class{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){let t=e.vertexShader,n=e.fragmentShader,r=this._getShaderStage(t),s=this._getShaderStage(n),o=this._getShaderCacheForMaterial(e);return o.has(r)===!1&&(o.add(r),r.usedTimes++),o.has(s)===!1&&(o.add(s),s.usedTimes++),this}remove(e){let t=this.materialCache.get(e);for(let n of t)n.usedTimes--,n.usedTimes===0&&this.shaderCache.delete(n.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){let t=this.materialCache,n=t.get(e);return n===void 0&&(n=new Set,t.set(e,n)),n}_getShaderStage(e){let t=this.shaderCache,n=t.get(e);return n===void 0&&(n=new G0(e),t.set(e,n)),n}},G0=class{constructor(e){this.id=nC++,this.code=e,this.usedTimes=0}};function iC(i,e,t,n,r,s,o){let a=new Io,c=new H0,l=new Set,u=[],h=r.logarithmicDepthBuffer,d=r.vertexTextures,m=r.precision,g={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",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 x(M){return l.add(M),M===0?"uv":`uv${M}`}function f(M,S,C,N,I){let L=N.fog,q=I.geometry,K=M.isMeshStandardMaterial?N.environment:null,B=(M.isMeshStandardMaterial?t:e).get(M.envMap||K),j=B&&B.mapping===qo?B.image.height:null,J=g[M.type];M.precision!==null&&(m=r.getMaxPrecision(M.precision),m!==M.precision&&console.warn("THREE.WebGLProgram.getParameters:",M.precision,"not supported, using",m,"instead."));let se=q.morphAttributes.position||q.morphAttributes.normal||q.morphAttributes.color,ce=se!==void 0?se.length:0,me=0;q.morphAttributes.position!==void 0&&(me=1),q.morphAttributes.normal!==void 0&&(me=2),q.morphAttributes.color!==void 0&&(me=3);let Se,V,w,O;if(J){let Ge=hr[J];Se=Ge.vertexShader,V=Ge.fragmentShader}else Se=M.vertexShader,V=M.fragmentShader,c.update(M),w=c.getVertexShaderID(M),O=c.getFragmentShaderID(M);let W=i.getRenderTarget(),Q=i.state.buffers.depth.getReversed(),ee=I.isInstancedMesh===!0,he=I.isBatchedMesh===!0,Ce=!!M.map,oe=!!M.matcap,ue=!!B,H=!!M.aoMap,Ie=!!M.lightMap,Te=!!M.bumpMap,Oe=!!M.normalMap,Re=!!M.displacementMap,We=!!M.emissiveMap,Ae=!!M.metalnessMap,Y=!!M.roughnessMap,F=M.anisotropy>0,D=M.clearcoat>0,P=M.dispersion>0,U=M.iridescence>0,X=M.sheen>0,Z=M.transmission>0,$=F&&!!M.anisotropyMap,te=D&&!!M.clearcoatMap,ae=D&&!!M.clearcoatNormalMap,re=D&&!!M.clearcoatRoughnessMap,ge=U&&!!M.iridescenceMap,xe=U&&!!M.iridescenceThicknessMap,Ne=X&&!!M.sheenColorMap,ke=X&&!!M.sheenRoughnessMap,$e=!!M.specularMap,Le=!!M.specularColorMap,Xe=!!M.specularIntensityMap,ne=Z&&!!M.transmissionMap,Pe=Z&&!!M.thicknessMap,pe=!!M.gradientMap,fe=!!M.alphaMap,Be=M.alphaTest>0,De=!!M.alphaHash,st=!!M.extensions,pt=Ir;M.toneMapped&&(W===null||W.isXRRenderTarget===!0)&&(pt=i.toneMapping);let lt={shaderID:J,shaderType:M.type,shaderName:M.name,vertexShader:Se,fragmentShader:V,defines:M.defines,customVertexShaderID:w,customFragmentShaderID:O,isRawShaderMaterial:M.isRawShaderMaterial===!0,glslVersion:M.glslVersion,precision:m,batching:he,batchingColor:he&&I._colorsTexture!==null,instancing:ee,instancingColor:ee&&I.instanceColor!==null,instancingMorph:ee&&I.morphTexture!==null,supportsVertexTextures:d,outputColorSpace:W===null?i.outputColorSpace:W.isXRRenderTarget===!0?W.texture.colorSpace:On,alphaToCoverage:!!M.alphaToCoverage,map:Ce,matcap:oe,envMap:ue,envMapMode:ue&&B.mapping,envMapCubeUVHeight:j,aoMap:H,lightMap:Ie,bumpMap:Te,normalMap:Oe,displacementMap:d&&Re,emissiveMap:We,normalMapObjectSpace:Oe&&M.normalMapType===m0,normalMapTangentSpace:Oe&&M.normalMapType===ds,metalnessMap:Ae,roughnessMap:Y,anisotropy:F,anisotropyMap:$,clearcoat:D,clearcoatMap:te,clearcoatNormalMap:ae,clearcoatRoughnessMap:re,dispersion:P,iridescence:U,iridescenceMap:ge,iridescenceThicknessMap:xe,sheen:X,sheenColorMap:Ne,sheenRoughnessMap:ke,specularMap:$e,specularColorMap:Le,specularIntensityMap:Xe,transmission:Z,transmissionMap:ne,thicknessMap:Pe,gradientMap:pe,opaque:M.transparent===!1&&M.blending===Fs&&M.alphaToCoverage===!1,alphaMap:fe,alphaTest:Be,alphaHash:De,combine:M.combine,mapUv:Ce&&x(M.map.channel),aoMapUv:H&&x(M.aoMap.channel),lightMapUv:Ie&&x(M.lightMap.channel),bumpMapUv:Te&&x(M.bumpMap.channel),normalMapUv:Oe&&x(M.normalMap.channel),displacementMapUv:Re&&x(M.displacementMap.channel),emissiveMapUv:We&&x(M.emissiveMap.channel),metalnessMapUv:Ae&&x(M.metalnessMap.channel),roughnessMapUv:Y&&x(M.roughnessMap.channel),anisotropyMapUv:$&&x(M.anisotropyMap.channel),clearcoatMapUv:te&&x(M.clearcoatMap.channel),clearcoatNormalMapUv:ae&&x(M.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:re&&x(M.clearcoatRoughnessMap.channel),iridescenceMapUv:ge&&x(M.iridescenceMap.channel),iridescenceThicknessMapUv:xe&&x(M.iridescenceThicknessMap.channel),sheenColorMapUv:Ne&&x(M.sheenColorMap.channel),sheenRoughnessMapUv:ke&&x(M.sheenRoughnessMap.channel),specularMapUv:$e&&x(M.specularMap.channel),specularColorMapUv:Le&&x(M.specularColorMap.channel),specularIntensityMapUv:Xe&&x(M.specularIntensityMap.channel),transmissionMapUv:ne&&x(M.transmissionMap.channel),thicknessMapUv:Pe&&x(M.thicknessMap.channel),alphaMapUv:fe&&x(M.alphaMap.channel),vertexTangents:!!q.attributes.tangent&&(Oe||F),vertexColors:M.vertexColors,vertexAlphas:M.vertexColors===!0&&!!q.attributes.color&&q.attributes.color.itemSize===4,pointsUvs:I.isPoints===!0&&!!q.attributes.uv&&(Ce||fe),fog:!!L,useFog:M.fog===!0,fogExp2:!!L&&L.isFogExp2,flatShading:M.flatShading===!0,sizeAttenuation:M.sizeAttenuation===!0,logarithmicDepthBuffer:h,reverseDepthBuffer:Q,skinning:I.isSkinnedMesh===!0,morphTargets:q.morphAttributes.position!==void 0,morphNormals:q.morphAttributes.normal!==void 0,morphColors:q.morphAttributes.color!==void 0,morphTargetsCount:ce,morphTextureStride:me,numDirLights:S.directional.length,numPointLights:S.point.length,numSpotLights:S.spot.length,numSpotLightMaps:S.spotLightMap.length,numRectAreaLights:S.rectArea.length,numHemiLights:S.hemi.length,numDirLightShadows:S.directionalShadowMap.length,numPointLightShadows:S.pointShadowMap.length,numSpotLightShadows:S.spotShadowMap.length,numSpotLightShadowsWithMaps:S.numSpotLightShadowsWithMaps,numLightProbes:S.numLightProbes,numClippingPlanes:o.numPlanes,numClipIntersection:o.numIntersection,dithering:M.dithering,shadowMapEnabled:i.shadowMap.enabled&&C.length>0,shadowMapType:i.shadowMap.type,toneMapping:pt,decodeVideoTexture:Ce&&M.map.isVideoTexture===!0&&_t.getTransfer(M.map.colorSpace)===kt,decodeVideoTextureEmissive:We&&M.emissiveMap.isVideoTexture===!0&&_t.getTransfer(M.emissiveMap.colorSpace)===kt,premultipliedAlpha:M.premultipliedAlpha,doubleSided:M.side===xn,flipSided:M.side===un,useDepthPacking:M.depthPacking>=0,depthPacking:M.depthPacking||0,index0AttributeName:M.index0AttributeName,extensionClipCullDistance:st&&M.extensions.clipCullDistance===!0&&n.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(st&&M.extensions.multiDraw===!0||he)&&n.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:n.has("KHR_parallel_shader_compile"),customProgramCacheKey:M.customProgramCacheKey()};return lt.vertexUv1s=l.has(1),lt.vertexUv2s=l.has(2),lt.vertexUv3s=l.has(3),l.clear(),lt}function p(M){let S=[];if(M.shaderID?S.push(M.shaderID):(S.push(M.customVertexShaderID),S.push(M.customFragmentShaderID)),M.defines!==void 0)for(let C in M.defines)S.push(C),S.push(M.defines[C]);return M.isRawShaderMaterial===!1&&(v(S,M),_(S,M),S.push(i.outputColorSpace)),S.push(M.customProgramCacheKey),S.join()}function v(M,S){M.push(S.precision),M.push(S.outputColorSpace),M.push(S.envMapMode),M.push(S.envMapCubeUVHeight),M.push(S.mapUv),M.push(S.alphaMapUv),M.push(S.lightMapUv),M.push(S.aoMapUv),M.push(S.bumpMapUv),M.push(S.normalMapUv),M.push(S.displacementMapUv),M.push(S.emissiveMapUv),M.push(S.metalnessMapUv),M.push(S.roughnessMapUv),M.push(S.anisotropyMapUv),M.push(S.clearcoatMapUv),M.push(S.clearcoatNormalMapUv),M.push(S.clearcoatRoughnessMapUv),M.push(S.iridescenceMapUv),M.push(S.iridescenceThicknessMapUv),M.push(S.sheenColorMapUv),M.push(S.sheenRoughnessMapUv),M.push(S.specularMapUv),M.push(S.specularColorMapUv),M.push(S.specularIntensityMapUv),M.push(S.transmissionMapUv),M.push(S.thicknessMapUv),M.push(S.combine),M.push(S.fogExp2),M.push(S.sizeAttenuation),M.push(S.morphTargetsCount),M.push(S.morphAttributeCount),M.push(S.numDirLights),M.push(S.numPointLights),M.push(S.numSpotLights),M.push(S.numSpotLightMaps),M.push(S.numHemiLights),M.push(S.numRectAreaLights),M.push(S.numDirLightShadows),M.push(S.numPointLightShadows),M.push(S.numSpotLightShadows),M.push(S.numSpotLightShadowsWithMaps),M.push(S.numLightProbes),M.push(S.shadowMapType),M.push(S.toneMapping),M.push(S.numClippingPlanes),M.push(S.numClipIntersection),M.push(S.depthPacking)}function _(M,S){a.disableAll(),S.supportsVertexTextures&&a.enable(0),S.instancing&&a.enable(1),S.instancingColor&&a.enable(2),S.instancingMorph&&a.enable(3),S.matcap&&a.enable(4),S.envMap&&a.enable(5),S.normalMapObjectSpace&&a.enable(6),S.normalMapTangentSpace&&a.enable(7),S.clearcoat&&a.enable(8),S.iridescence&&a.enable(9),S.alphaTest&&a.enable(10),S.vertexColors&&a.enable(11),S.vertexAlphas&&a.enable(12),S.vertexUv1s&&a.enable(13),S.vertexUv2s&&a.enable(14),S.vertexUv3s&&a.enable(15),S.vertexTangents&&a.enable(16),S.anisotropy&&a.enable(17),S.alphaHash&&a.enable(18),S.batching&&a.enable(19),S.dispersion&&a.enable(20),S.batchingColor&&a.enable(21),M.push(a.mask),a.disableAll(),S.fog&&a.enable(0),S.useFog&&a.enable(1),S.flatShading&&a.enable(2),S.logarithmicDepthBuffer&&a.enable(3),S.reverseDepthBuffer&&a.enable(4),S.skinning&&a.enable(5),S.morphTargets&&a.enable(6),S.morphNormals&&a.enable(7),S.morphColors&&a.enable(8),S.premultipliedAlpha&&a.enable(9),S.shadowMapEnabled&&a.enable(10),S.doubleSided&&a.enable(11),S.flipSided&&a.enable(12),S.useDepthPacking&&a.enable(13),S.dithering&&a.enable(14),S.transmission&&a.enable(15),S.sheen&&a.enable(16),S.opaque&&a.enable(17),S.pointsUvs&&a.enable(18),S.decodeVideoTexture&&a.enable(19),S.decodeVideoTextureEmissive&&a.enable(20),S.alphaToCoverage&&a.enable(21),M.push(a.mask)}function y(M){let S=g[M.type],C;if(S){let N=hr[S];C=Gn.clone(N.uniforms)}else C=M.uniforms;return C}function b(M,S){let C;for(let N=0,I=u.length;N<I;N++){let L=u[N];if(L.cacheKey===S){C=L,++C.usedTimes;break}}return C===void 0&&(C=new tC(i,S,M,s),u.push(C)),C}function E(M){if(--M.usedTimes===0){let S=u.indexOf(M);u[S]=u[u.length-1],u.pop(),M.destroy()}}function A(M){c.remove(M)}function T(){c.dispose()}return{getParameters:f,getProgramCacheKey:p,getUniforms:y,acquireProgram:b,releaseProgram:E,releaseShaderCache:A,programs:u,dispose:T}}function rC(){let i=new WeakMap;function e(o){return i.has(o)}function t(o){let a=i.get(o);return a===void 0&&(a={},i.set(o,a)),a}function n(o){i.delete(o)}function r(o,a,c){i.get(o)[a]=c}function s(){i=new WeakMap}return{has:e,get:t,remove:n,update:r,dispose:s}}function sC(i,e){return i.groupOrder!==e.groupOrder?i.groupOrder-e.groupOrder:i.renderOrder!==e.renderOrder?i.renderOrder-e.renderOrder:i.material.id!==e.material.id?i.material.id-e.material.id:i.z!==e.z?i.z-e.z:i.id-e.id}function Pb(i,e){return i.groupOrder!==e.groupOrder?i.groupOrder-e.groupOrder:i.renderOrder!==e.renderOrder?i.renderOrder-e.renderOrder:i.z!==e.z?e.z-i.z:i.id-e.id}function Ib(){let i=[],e=0,t=[],n=[],r=[];function s(){e=0,t.length=0,n.length=0,r.length=0}function o(h,d,m,g,x,f){let p=i[e];return p===void 0?(p={id:h.id,object:h,geometry:d,material:m,groupOrder:g,renderOrder:h.renderOrder,z:x,group:f},i[e]=p):(p.id=h.id,p.object=h,p.geometry=d,p.material=m,p.groupOrder=g,p.renderOrder=h.renderOrder,p.z=x,p.group=f),e++,p}function a(h,d,m,g,x,f){let p=o(h,d,m,g,x,f);m.transmission>0?n.push(p):m.transparent===!0?r.push(p):t.push(p)}function c(h,d,m,g,x,f){let p=o(h,d,m,g,x,f);m.transmission>0?n.unshift(p):m.transparent===!0?r.unshift(p):t.unshift(p)}function l(h,d){t.length>1&&t.sort(h||sC),n.length>1&&n.sort(d||Pb),r.length>1&&r.sort(d||Pb)}function u(){for(let h=e,d=i.length;h<d;h++){let m=i[h];if(m.id===null)break;m.id=null,m.object=null,m.geometry=null,m.material=null,m.group=null}}return{opaque:t,transmissive:n,transparent:r,init:s,push:a,unshift:c,finish:u,sort:l}}function oC(){let i=new WeakMap;function e(n,r){let s=i.get(n),o;return s===void 0?(o=new Ib,i.set(n,[o])):r>=s.length?(o=new Ib,s.push(o)):o=s[r],o}function t(){i=new WeakMap}return{get:e,dispose:t}}function aC(){let i={};return{get:function(e){if(i[e.id]!==void 0)return i[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new z,color:new Ue};break;case"SpotLight":t={position:new z,direction:new z,color:new Ue,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new z,color:new Ue,distance:0,decay:0};break;case"HemisphereLight":t={direction:new z,skyColor:new Ue,groundColor:new Ue};break;case"RectAreaLight":t={color:new Ue,position:new z,halfWidth:new z,halfHeight:new z};break}return i[e.id]=t,t}}}function cC(){let i={};return{get:function(e){if(i[e.id]!==void 0)return i[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Me};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Me};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Me,shadowCameraNear:1,shadowCameraFar:1e3};break}return i[e.id]=t,t}}}var lC=0;function uC(i,e){return(e.castShadow?2:0)-(i.castShadow?2:0)+(e.map?1:0)-(i.map?1:0)}function hC(i){let e=new aC,t=cC(),n={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 l=0;l<9;l++)n.probe.push(new z);let r=new z,s=new nt,o=new nt;function a(l){let u=0,h=0,d=0;for(let M=0;M<9;M++)n.probe[M].set(0,0,0);let m=0,g=0,x=0,f=0,p=0,v=0,_=0,y=0,b=0,E=0,A=0;l.sort(uC);for(let M=0,S=l.length;M<S;M++){let C=l[M],N=C.color,I=C.intensity,L=C.distance,q=C.shadow&&C.shadow.map?C.shadow.map.texture:null;if(C.isAmbientLight)u+=N.r*I,h+=N.g*I,d+=N.b*I;else if(C.isLightProbe){for(let K=0;K<9;K++)n.probe[K].addScaledVector(C.sh.coefficients[K],I);A++}else if(C.isDirectionalLight){let K=e.get(C);if(K.color.copy(C.color).multiplyScalar(C.intensity),C.castShadow){let B=C.shadow,j=t.get(C);j.shadowIntensity=B.intensity,j.shadowBias=B.bias,j.shadowNormalBias=B.normalBias,j.shadowRadius=B.radius,j.shadowMapSize=B.mapSize,n.directionalShadow[m]=j,n.directionalShadowMap[m]=q,n.directionalShadowMatrix[m]=C.shadow.matrix,v++}n.directional[m]=K,m++}else if(C.isSpotLight){let K=e.get(C);K.position.setFromMatrixPosition(C.matrixWorld),K.color.copy(N).multiplyScalar(I),K.distance=L,K.coneCos=Math.cos(C.angle),K.penumbraCos=Math.cos(C.angle*(1-C.penumbra)),K.decay=C.decay,n.spot[x]=K;let B=C.shadow;if(C.map&&(n.spotLightMap[b]=C.map,b++,B.updateMatrices(C),C.castShadow&&E++),n.spotLightMatrix[x]=B.matrix,C.castShadow){let j=t.get(C);j.shadowIntensity=B.intensity,j.shadowBias=B.bias,j.shadowNormalBias=B.normalBias,j.shadowRadius=B.radius,j.shadowMapSize=B.mapSize,n.spotShadow[x]=j,n.spotShadowMap[x]=q,y++}x++}else if(C.isRectAreaLight){let K=e.get(C);K.color.copy(N).multiplyScalar(I),K.halfWidth.set(C.width*.5,0,0),K.halfHeight.set(0,C.height*.5,0),n.rectArea[f]=K,f++}else if(C.isPointLight){let K=e.get(C);if(K.color.copy(C.color).multiplyScalar(C.intensity),K.distance=C.distance,K.decay=C.decay,C.castShadow){let B=C.shadow,j=t.get(C);j.shadowIntensity=B.intensity,j.shadowBias=B.bias,j.shadowNormalBias=B.normalBias,j.shadowRadius=B.radius,j.shadowMapSize=B.mapSize,j.shadowCameraNear=B.camera.near,j.shadowCameraFar=B.camera.far,n.pointShadow[g]=j,n.pointShadowMap[g]=q,n.pointShadowMatrix[g]=C.shadow.matrix,_++}n.point[g]=K,g++}else if(C.isHemisphereLight){let K=e.get(C);K.skyColor.copy(C.color).multiplyScalar(I),K.groundColor.copy(C.groundColor).multiplyScalar(I),n.hemi[p]=K,p++}}f>0&&(i.has("OES_texture_float_linear")===!0?(n.rectAreaLTC1=Ze.LTC_FLOAT_1,n.rectAreaLTC2=Ze.LTC_FLOAT_2):(n.rectAreaLTC1=Ze.LTC_HALF_1,n.rectAreaLTC2=Ze.LTC_HALF_2)),n.ambient[0]=u,n.ambient[1]=h,n.ambient[2]=d;let T=n.hash;(T.directionalLength!==m||T.pointLength!==g||T.spotLength!==x||T.rectAreaLength!==f||T.hemiLength!==p||T.numDirectionalShadows!==v||T.numPointShadows!==_||T.numSpotShadows!==y||T.numSpotMaps!==b||T.numLightProbes!==A)&&(n.directional.length=m,n.spot.length=x,n.rectArea.length=f,n.point.length=g,n.hemi.length=p,n.directionalShadow.length=v,n.directionalShadowMap.length=v,n.pointShadow.length=_,n.pointShadowMap.length=_,n.spotShadow.length=y,n.spotShadowMap.length=y,n.directionalShadowMatrix.length=v,n.pointShadowMatrix.length=_,n.spotLightMatrix.length=y+b-E,n.spotLightMap.length=b,n.numSpotLightShadowsWithMaps=E,n.numLightProbes=A,T.directionalLength=m,T.pointLength=g,T.spotLength=x,T.rectAreaLength=f,T.hemiLength=p,T.numDirectionalShadows=v,T.numPointShadows=_,T.numSpotShadows=y,T.numSpotMaps=b,T.numLightProbes=A,n.version=lC++)}function c(l,u){let h=0,d=0,m=0,g=0,x=0,f=u.matrixWorldInverse;for(let p=0,v=l.length;p<v;p++){let _=l[p];if(_.isDirectionalLight){let y=n.directional[h];y.direction.setFromMatrixPosition(_.matrixWorld),r.setFromMatrixPosition(_.target.matrixWorld),y.direction.sub(r),y.direction.transformDirection(f),h++}else if(_.isSpotLight){let y=n.spot[m];y.position.setFromMatrixPosition(_.matrixWorld),y.position.applyMatrix4(f),y.direction.setFromMatrixPosition(_.matrixWorld),r.setFromMatrixPosition(_.target.matrixWorld),y.direction.sub(r),y.direction.transformDirection(f),m++}else if(_.isRectAreaLight){let y=n.rectArea[g];y.position.setFromMatrixPosition(_.matrixWorld),y.position.applyMatrix4(f),o.identity(),s.copy(_.matrixWorld),s.premultiply(f),o.extractRotation(s),y.halfWidth.set(_.width*.5,0,0),y.halfHeight.set(0,_.height*.5,0),y.halfWidth.applyMatrix4(o),y.halfHeight.applyMatrix4(o),g++}else if(_.isPointLight){let y=n.point[d];y.position.setFromMatrixPosition(_.matrixWorld),y.position.applyMatrix4(f),d++}else if(_.isHemisphereLight){let y=n.hemi[x];y.direction.setFromMatrixPosition(_.matrixWorld),y.direction.transformDirection(f),x++}}}return{setup:a,setupView:c,state:n}}function Nb(i){let e=new hC(i),t=[],n=[];function r(u){l.camera=u,t.length=0,n.length=0}function s(u){t.push(u)}function o(u){n.push(u)}function a(){e.setup(t)}function c(u){e.setupView(t,u)}let l={lightsArray:t,shadowsArray:n,camera:null,lights:e,transmissionRenderTarget:{}};return{init:r,state:l,setupLights:a,setupLightsView:c,pushLight:s,pushShadow:o}}function dC(i){let e=new WeakMap;function t(r,s=0){let o=e.get(r),a;return o===void 0?(a=new Nb(i),e.set(r,[a])):s>=o.length?(a=new Nb(i),o.push(a)):a=o[s],a}function n(){e=new WeakMap}return{get:t,dispose:n}}var fC=`void main() {
gl_Position = vec4( position, 1.0 );
}`,pC=`uniform sampler2D shadow_pass;
uniform vec2 resolution;
uniform float radius;
#include <packing>
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 = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );
mean += distribution.x;
squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;
#else
float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );
mean += depth;
squared_mean += depth * depth;
#endif
}
mean = mean / samples;
squared_mean = squared_mean / samples;
float std_dev = sqrt( squared_mean - mean * mean );
gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
}`;function mC(i,e,t){let n=new Ws,r=new Me,s=new Me,o=new It,a=new lc({depthPacking:p0}),c=new uc,l={},u=t.maxTextureSize,h={[Jn]:un,[un]:Jn,[xn]:xn},d=new $t({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Me},radius:{value:4}},vertexShader:fC,fragmentShader:pC}),m=d.clone();m.defines.HORIZONTAL_PASS=1;let g=new ot;g.setAttribute("position",new gt(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let x=new ct(g,d),f=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=sp;let p=this.type;this.render=function(E,A,T){if(f.enabled===!1||f.autoUpdate===!1&&f.needsUpdate===!1||E.length===0)return;let M=i.getRenderTarget(),S=i.getActiveCubeFace(),C=i.getActiveMipmapLevel(),N=i.state;N.setBlending(yn),N.buffers.color.setClear(1,1,1,1),N.buffers.depth.setTest(!0),N.setScissorTest(!1);let I=p!==ur&&this.type===ur,L=p===ur&&this.type!==ur;for(let q=0,K=E.length;q<K;q++){let B=E[q],j=B.shadow;if(j===void 0){console.warn("THREE.WebGLShadowMap:",B,"has no shadow.");continue}if(j.autoUpdate===!1&&j.needsUpdate===!1)continue;r.copy(j.mapSize);let J=j.getFrameExtents();if(r.multiply(J),s.copy(j.mapSize),(r.x>u||r.y>u)&&(r.x>u&&(s.x=Math.floor(u/J.x),r.x=s.x*J.x,j.mapSize.x=s.x),r.y>u&&(s.y=Math.floor(u/J.y),r.y=s.y*J.y,j.mapSize.y=s.y)),j.map===null||I===!0||L===!0){let ce=this.type!==ur?{minFilter:Jt,magFilter:Jt}:{};j.map!==null&&j.map.dispose(),j.map=new on(r.x,r.y,ce),j.map.texture.name=B.name+".shadowMap",j.camera.updateProjectionMatrix()}i.setRenderTarget(j.map),i.clear();let se=j.getViewportCount();for(let ce=0;ce<se;ce++){let me=j.getViewport(ce);o.set(s.x*me.x,s.y*me.y,s.x*me.z,s.y*me.w),N.viewport(o),j.updateMatrices(B,ce),n=j.getFrustum(),y(A,T,j.camera,B,this.type)}j.isPointLightShadow!==!0&&this.type===ur&&v(j,T),j.needsUpdate=!1}p=this.type,f.needsUpdate=!1,i.setRenderTarget(M,S,C)};function v(E,A){let T=e.update(x);d.defines.VSM_SAMPLES!==E.blurSamples&&(d.defines.VSM_SAMPLES=E.blurSamples,m.defines.VSM_SAMPLES=E.blurSamples,d.needsUpdate=!0,m.needsUpdate=!0),E.mapPass===null&&(E.mapPass=new on(r.x,r.y)),d.uniforms.shadow_pass.value=E.map.texture,d.uniforms.resolution.value=E.mapSize,d.uniforms.radius.value=E.radius,i.setRenderTarget(E.mapPass),i.clear(),i.renderBufferDirect(A,null,T,d,x,null),m.uniforms.shadow_pass.value=E.mapPass.texture,m.uniforms.resolution.value=E.mapSize,m.uniforms.radius.value=E.radius,i.setRenderTarget(E.map),i.clear(),i.renderBufferDirect(A,null,T,m,x,null)}function _(E,A,T,M){let S=null,C=T.isPointLight===!0?E.customDistanceMaterial:E.customDepthMaterial;if(C!==void 0)S=C;else if(S=T.isPointLight===!0?c:a,i.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){let N=S.uuid,I=A.uuid,L=l[N];L===void 0&&(L={},l[N]=L);let q=L[I];q===void 0&&(q=S.clone(),L[I]=q,A.addEventListener("dispose",b)),S=q}if(S.visible=A.visible,S.wireframe=A.wireframe,M===ur?S.side=A.shadowSide!==null?A.shadowSide:A.side:S.side=A.shadowSide!==null?A.shadowSide:h[A.side],S.alphaMap=A.alphaMap,S.alphaTest=A.alphaTest,S.map=A.map,S.clipShadows=A.clipShadows,S.clippingPlanes=A.clippingPlanes,S.clipIntersection=A.clipIntersection,S.displacementMap=A.displacementMap,S.displacementScale=A.displacementScale,S.displacementBias=A.displacementBias,S.wireframeLinewidth=A.wireframeLinewidth,S.linewidth=A.linewidth,T.isPointLight===!0&&S.isMeshDistanceMaterial===!0){let N=i.properties.get(S);N.light=T}return S}function y(E,A,T,M,S){if(E.visible===!1)return;if(E.layers.test(A.layers)&&(E.isMesh||E.isLine||E.isPoints)&&(E.castShadow||E.receiveShadow&&S===ur)&&(!E.frustumCulled||n.intersectsObject(E))){E.modelViewMatrix.multiplyMatrices(T.matrixWorldInverse,E.matrixWorld);let I=e.update(E),L=E.material;if(Array.isArray(L)){let q=I.groups;for(let K=0,B=q.length;K<B;K++){let j=q[K],J=L[j.materialIndex];if(J&&J.visible){let se=_(E,J,M,S);E.onBeforeShadow(i,E,A,T,I,se,j),i.renderBufferDirect(T,null,I,se,E,j),E.onAfterShadow(i,E,A,T,I,se,j)}}}else if(L.visible){let q=_(E,L,M,S);E.onBeforeShadow(i,E,A,T,I,q,null),i.renderBufferDirect(T,null,I,q,E,null),E.onAfterShadow(i,E,A,T,I,q,null)}}let N=E.children;for(let I=0,L=N.length;I<L;I++)y(N[I],A,T,M,S)}function b(E){E.target.removeEventListener("dispose",b);for(let T in l){let M=l[T],S=E.target.uuid;S in M&&(M[S].dispose(),delete M[S])}}}var gC={[wu]:Ru,[Cu]:Nu,[Pu]:Lu,[Us]:Iu,[Ru]:wu,[Nu]:Cu,[Lu]:Pu,[Iu]:Us};function xC(i,e){function t(){let ne=!1,Pe=new It,pe=null,fe=new It(0,0,0,0);return{setMask:function(Be){pe!==Be&&!ne&&(i.colorMask(Be,Be,Be,Be),pe=Be)},setLocked:function(Be){ne=Be},setClear:function(Be,De,st,pt,lt){lt===!0&&(Be*=pt,De*=pt,st*=pt),Pe.set(Be,De,st,pt),fe.equals(Pe)===!1&&(i.clearColor(Be,De,st,pt),fe.copy(Pe))},reset:function(){ne=!1,pe=null,fe.set(-1,0,0,0)}}}function n(){let ne=!1,Pe=!1,pe=null,fe=null,Be=null;return{setReversed:function(De){if(Pe!==De){let st=e.get("EXT_clip_control");Pe?st.clipControlEXT(st.LOWER_LEFT_EXT,st.ZERO_TO_ONE_EXT):st.clipControlEXT(st.LOWER_LEFT_EXT,st.NEGATIVE_ONE_TO_ONE_EXT);let pt=Be;Be=null,this.setClear(pt)}Pe=De},getReversed:function(){return Pe},setTest:function(De){De?W(i.DEPTH_TEST):Q(i.DEPTH_TEST)},setMask:function(De){pe!==De&&!ne&&(i.depthMask(De),pe=De)},setFunc:function(De){if(Pe&&(De=gC[De]),fe!==De){switch(De){case wu:i.depthFunc(i.NEVER);break;case Ru:i.depthFunc(i.ALWAYS);break;case Cu:i.depthFunc(i.LESS);break;case Us:i.depthFunc(i.LEQUAL);break;case Pu:i.depthFunc(i.EQUAL);break;case Iu:i.depthFunc(i.GEQUAL);break;case Nu:i.depthFunc(i.GREATER);break;case Lu:i.depthFunc(i.NOTEQUAL);break;default:i.depthFunc(i.LEQUAL)}fe=De}},setLocked:function(De){ne=De},setClear:function(De){Be!==De&&(Pe&&(De=1-De),i.clearDepth(De),Be=De)},reset:function(){ne=!1,pe=null,fe=null,Be=null,Pe=!1}}}function r(){let ne=!1,Pe=null,pe=null,fe=null,Be=null,De=null,st=null,pt=null,lt=null;return{setTest:function(Ge){ne||(Ge?W(i.STENCIL_TEST):Q(i.STENCIL_TEST))},setMask:function(Ge){Pe!==Ge&&!ne&&(i.stencilMask(Ge),Pe=Ge)},setFunc:function(Ge,Je,we){(pe!==Ge||fe!==Je||Be!==we)&&(i.stencilFunc(Ge,Je,we),pe=Ge,fe=Je,Be=we)},setOp:function(Ge,Je,we){(De!==Ge||st!==Je||pt!==we)&&(i.stencilOp(Ge,Je,we),De=Ge,st=Je,pt=we)},setLocked:function(Ge){ne=Ge},setClear:function(Ge){lt!==Ge&&(i.clearStencil(Ge),lt=Ge)},reset:function(){ne=!1,Pe=null,pe=null,fe=null,Be=null,De=null,st=null,pt=null,lt=null}}}let s=new t,o=new n,a=new r,c=new WeakMap,l=new WeakMap,u={},h={},d=new WeakMap,m=[],g=null,x=!1,f=null,p=null,v=null,_=null,y=null,b=null,E=null,A=new Ue(0,0,0),T=0,M=!1,S=null,C=null,N=null,I=null,L=null,q=i.getParameter(i.MAX_COMBINED_TEXTURE_IMAGE_UNITS),K=!1,B=0,j=i.getParameter(i.VERSION);j.indexOf("WebGL")!==-1?(B=parseFloat(/^WebGL (\d)/.exec(j)[1]),K=B>=1):j.indexOf("OpenGL ES")!==-1&&(B=parseFloat(/^OpenGL ES (\d)/.exec(j)[1]),K=B>=2);let J=null,se={},ce=i.getParameter(i.SCISSOR_BOX),me=i.getParameter(i.VIEWPORT),Se=new It().fromArray(ce),V=new It().fromArray(me);function w(ne,Pe,pe,fe){let Be=new Uint8Array(4),De=i.createTexture();i.bindTexture(ne,De),i.texParameteri(ne,i.TEXTURE_MIN_FILTER,i.NEAREST),i.texParameteri(ne,i.TEXTURE_MAG_FILTER,i.NEAREST);for(let st=0;st<pe;st++)ne===i.TEXTURE_3D||ne===i.TEXTURE_2D_ARRAY?i.texImage3D(Pe,0,i.RGBA,1,1,fe,0,i.RGBA,i.UNSIGNED_BYTE,Be):i.texImage2D(Pe+st,0,i.RGBA,1,1,0,i.RGBA,i.UNSIGNED_BYTE,Be);return De}let O={};O[i.TEXTURE_2D]=w(i.TEXTURE_2D,i.TEXTURE_2D,1),O[i.TEXTURE_CUBE_MAP]=w(i.TEXTURE_CUBE_MAP,i.TEXTURE_CUBE_MAP_POSITIVE_X,6),O[i.TEXTURE_2D_ARRAY]=w(i.TEXTURE_2D_ARRAY,i.TEXTURE_2D_ARRAY,1,1),O[i.TEXTURE_3D]=w(i.TEXTURE_3D,i.TEXTURE_3D,1,1),s.setClear(0,0,0,1),o.setClear(1),a.setClear(0),W(i.DEPTH_TEST),o.setFunc(Us),Te(!1),Oe(rp),W(i.CULL_FACE),H(yn);function W(ne){u[ne]!==!0&&(i.enable(ne),u[ne]=!0)}function Q(ne){u[ne]!==!1&&(i.disable(ne),u[ne]=!1)}function ee(ne,Pe){return h[ne]!==Pe?(i.bindFramebuffer(ne,Pe),h[ne]=Pe,ne===i.DRAW_FRAMEBUFFER&&(h[i.FRAMEBUFFER]=Pe),ne===i.FRAMEBUFFER&&(h[i.DRAW_FRAMEBUFFER]=Pe),!0):!1}function he(ne,Pe){let pe=m,fe=!1;if(ne){pe=d.get(Pe),pe===void 0&&(pe=[],d.set(Pe,pe));let Be=ne.textures;if(pe.length!==Be.length||pe[0]!==i.COLOR_ATTACHMENT0){for(let De=0,st=Be.length;De<st;De++)pe[De]=i.COLOR_ATTACHMENT0+De;pe.length=Be.length,fe=!0}}else pe[0]!==i.BACK&&(pe[0]=i.BACK,fe=!0);fe&&i.drawBuffers(pe)}function Ce(ne){return g!==ne?(i.useProgram(ne),g=ne,!0):!1}let oe={[xi]:i.FUNC_ADD,[Yg]:i.FUNC_SUBTRACT,[jg]:i.FUNC_REVERSE_SUBTRACT};oe[qg]=i.MIN,oe[Kg]=i.MAX;let ue={[Ks]:i.ZERO,[Zg]:i.ONE,[Jg]:i.SRC_COLOR,[Pl]:i.SRC_ALPHA,[t0]:i.SRC_ALPHA_SATURATE,[yc]:i.DST_COLOR,[xc]:i.DST_ALPHA,[Qg]:i.ONE_MINUS_SRC_COLOR,[Il]:i.ONE_MINUS_SRC_ALPHA,[e0]:i.ONE_MINUS_DST_COLOR,[$g]:i.ONE_MINUS_DST_ALPHA,[n0]:i.CONSTANT_COLOR,[i0]:i.ONE_MINUS_CONSTANT_COLOR,[r0]:i.CONSTANT_ALPHA,[s0]:i.ONE_MINUS_CONSTANT_ALPHA};function H(ne,Pe,pe,fe,Be,De,st,pt,lt,Ge){if(ne===yn){x===!0&&(Q(i.BLEND),x=!1);return}if(x===!1&&(W(i.BLEND),x=!0),ne!==Au){if(ne!==f||Ge!==M){if((p!==xi||y!==xi)&&(i.blendEquation(i.FUNC_ADD),p=xi,y=xi),Ge)switch(ne){case Fs:i.blendFuncSeparate(i.ONE,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case op:i.blendFunc(i.ONE,i.ONE);break;case ap:i.blendFuncSeparate(i.ZERO,i.ONE_MINUS_SRC_COLOR,i.ZERO,i.ONE);break;case cp:i.blendFuncSeparate(i.ZERO,i.SRC_COLOR,i.ZERO,i.SRC_ALPHA);break;default:console.error("THREE.WebGLState: Invalid blending: ",ne);break}else switch(ne){case Fs:i.blendFuncSeparate(i.SRC_ALPHA,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case op:i.blendFunc(i.SRC_ALPHA,i.ONE);break;case ap:i.blendFuncSeparate(i.ZERO,i.ONE_MINUS_SRC_COLOR,i.ZERO,i.ONE);break;case cp:i.blendFunc(i.ZERO,i.SRC_COLOR);break;default:console.error("THREE.WebGLState: Invalid blending: ",ne);break}v=null,_=null,b=null,E=null,A.set(0,0,0),T=0,f=ne,M=Ge}return}Be=Be||Pe,De=De||pe,st=st||fe,(Pe!==p||Be!==y)&&(i.blendEquationSeparate(oe[Pe],oe[Be]),p=Pe,y=Be),(pe!==v||fe!==_||De!==b||st!==E)&&(i.blendFuncSeparate(ue[pe],ue[fe],ue[De],ue[st]),v=pe,_=fe,b=De,E=st),(pt.equals(A)===!1||lt!==T)&&(i.blendColor(pt.r,pt.g,pt.b,lt),A.copy(pt),T=lt),f=ne,M=!1}function Ie(ne,Pe){ne.side===xn?Q(i.CULL_FACE):W(i.CULL_FACE);let pe=ne.side===un;Pe&&(pe=!pe),Te(pe),ne.blending===Fs&&ne.transparent===!1?H(yn):H(ne.blending,ne.blendEquation,ne.blendSrc,ne.blendDst,ne.blendEquationAlpha,ne.blendSrcAlpha,ne.blendDstAlpha,ne.blendColor,ne.blendAlpha,ne.premultipliedAlpha),o.setFunc(ne.depthFunc),o.setTest(ne.depthTest),o.setMask(ne.depthWrite),s.setMask(ne.colorWrite);let fe=ne.stencilWrite;a.setTest(fe),fe&&(a.setMask(ne.stencilWriteMask),a.setFunc(ne.stencilFunc,ne.stencilRef,ne.stencilFuncMask),a.setOp(ne.stencilFail,ne.stencilZFail,ne.stencilZPass)),We(ne.polygonOffset,ne.polygonOffsetFactor,ne.polygonOffsetUnits),ne.alphaToCoverage===!0?W(i.SAMPLE_ALPHA_TO_COVERAGE):Q(i.SAMPLE_ALPHA_TO_COVERAGE)}function Te(ne){S!==ne&&(ne?i.frontFace(i.CW):i.frontFace(i.CCW),S=ne)}function Oe(ne){ne!==Wg?(W(i.CULL_FACE),ne!==C&&(ne===rp?i.cullFace(i.BACK):ne===Xg?i.cullFace(i.FRONT):i.cullFace(i.FRONT_AND_BACK))):Q(i.CULL_FACE),C=ne}function Re(ne){ne!==N&&(K&&i.lineWidth(ne),N=ne)}function We(ne,Pe,pe){ne?(W(i.POLYGON_OFFSET_FILL),(I!==Pe||L!==pe)&&(i.polygonOffset(Pe,pe),I=Pe,L=pe)):Q(i.POLYGON_OFFSET_FILL)}function Ae(ne){ne?W(i.SCISSOR_TEST):Q(i.SCISSOR_TEST)}function Y(ne){ne===void 0&&(ne=i.TEXTURE0+q-1),J!==ne&&(i.activeTexture(ne),J=ne)}function F(ne,Pe,pe){pe===void 0&&(J===null?pe=i.TEXTURE0+q-1:pe=J);let fe=se[pe];fe===void 0&&(fe={type:void 0,texture:void 0},se[pe]=fe),(fe.type!==ne||fe.texture!==Pe)&&(J!==pe&&(i.activeTexture(pe),J=pe),i.bindTexture(ne,Pe||O[ne]),fe.type=ne,fe.texture=Pe)}function D(){let ne=se[J];ne!==void 0&&ne.type!==void 0&&(i.bindTexture(ne.type,null),ne.type=void 0,ne.texture=void 0)}function P(){try{i.compressedTexImage2D.apply(i,arguments)}catch(ne){console.error("THREE.WebGLState:",ne)}}function U(){try{i.compressedTexImage3D.apply(i,arguments)}catch(ne){console.error("THREE.WebGLState:",ne)}}function X(){try{i.texSubImage2D.apply(i,arguments)}catch(ne){console.error("THREE.WebGLState:",ne)}}function Z(){try{i.texSubImage3D.apply(i,arguments)}catch(ne){console.error("THREE.WebGLState:",ne)}}function $(){try{i.compressedTexSubImage2D.apply(i,arguments)}catch(ne){console.error("THREE.WebGLState:",ne)}}function te(){try{i.compressedTexSubImage3D.apply(i,arguments)}catch(ne){console.error("THREE.WebGLState:",ne)}}function ae(){try{i.texStorage2D.apply(i,arguments)}catch(ne){console.error("THREE.WebGLState:",ne)}}function re(){try{i.texStorage3D.apply(i,arguments)}catch(ne){console.error("THREE.WebGLState:",ne)}}function ge(){try{i.texImage2D.apply(i,arguments)}catch(ne){console.error("THREE.WebGLState:",ne)}}function xe(){try{i.texImage3D.apply(i,arguments)}catch(ne){console.error("THREE.WebGLState:",ne)}}function Ne(ne){Se.equals(ne)===!1&&(i.scissor(ne.x,ne.y,ne.z,ne.w),Se.copy(ne))}function ke(ne){V.equals(ne)===!1&&(i.viewport(ne.x,ne.y,ne.z,ne.w),V.copy(ne))}function $e(ne,Pe){let pe=l.get(Pe);pe===void 0&&(pe=new WeakMap,l.set(Pe,pe));let fe=pe.get(ne);fe===void 0&&(fe=i.getUniformBlockIndex(Pe,ne.name),pe.set(ne,fe))}function Le(ne,Pe){let fe=l.get(Pe).get(ne);c.get(Pe)!==fe&&(i.uniformBlockBinding(Pe,fe,ne.__bindingPointIndex),c.set(Pe,fe))}function Xe(){i.disable(i.BLEND),i.disable(i.CULL_FACE),i.disable(i.DEPTH_TEST),i.disable(i.POLYGON_OFFSET_FILL),i.disable(i.SCISSOR_TEST),i.disable(i.STENCIL_TEST),i.disable(i.SAMPLE_ALPHA_TO_COVERAGE),i.blendEquation(i.FUNC_ADD),i.blendFunc(i.ONE,i.ZERO),i.blendFuncSeparate(i.ONE,i.ZERO,i.ONE,i.ZERO),i.blendColor(0,0,0,0),i.colorMask(!0,!0,!0,!0),i.clearColor(0,0,0,0),i.depthMask(!0),i.depthFunc(i.LESS),o.setReversed(!1),i.clearDepth(1),i.stencilMask(4294967295),i.stencilFunc(i.ALWAYS,0,4294967295),i.stencilOp(i.KEEP,i.KEEP,i.KEEP),i.clearStencil(0),i.cullFace(i.BACK),i.frontFace(i.CCW),i.polygonOffset(0,0),i.activeTexture(i.TEXTURE0),i.bindFramebuffer(i.FRAMEBUFFER,null),i.bindFramebuffer(i.DRAW_FRAMEBUFFER,null),i.bindFramebuffer(i.READ_FRAMEBUFFER,null),i.useProgram(null),i.lineWidth(1),i.scissor(0,0,i.canvas.width,i.canvas.height),i.viewport(0,0,i.canvas.width,i.canvas.height),u={},J=null,se={},h={},d=new WeakMap,m=[],g=null,x=!1,f=null,p=null,v=null,_=null,y=null,b=null,E=null,A=new Ue(0,0,0),T=0,M=!1,S=null,C=null,N=null,I=null,L=null,Se.set(0,0,i.canvas.width,i.canvas.height),V.set(0,0,i.canvas.width,i.canvas.height),s.reset(),o.reset(),a.reset()}return{buffers:{color:s,depth:o,stencil:a},enable:W,disable:Q,bindFramebuffer:ee,drawBuffers:he,useProgram:Ce,setBlending:H,setMaterial:Ie,setFlipSided:Te,setCullFace:Oe,setLineWidth:Re,setPolygonOffset:We,setScissorTest:Ae,activeTexture:Y,bindTexture:F,unbindTexture:D,compressedTexImage2D:P,compressedTexImage3D:U,texImage2D:ge,texImage3D:xe,updateUBOMapping:$e,uniformBlockBinding:Le,texStorage2D:ae,texStorage3D:re,texSubImage2D:X,texSubImage3D:Z,compressedTexSubImage2D:$,compressedTexSubImage3D:te,scissor:Ne,viewport:ke,reset:Xe}}function yC(i,e,t,n,r,s,o){let a=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,c=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),l=new Me,u=new WeakMap,h,d=new WeakMap,m=!1;try{m=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function g(Y,F){return m?new OffscreenCanvas(Y,F):Qa("canvas")}function x(Y,F,D){let P=1,U=Ae(Y);if((U.width>D||U.height>D)&&(P=D/Math.max(U.width,U.height)),P<1)if(typeof HTMLImageElement<"u"&&Y instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&Y instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&Y instanceof ImageBitmap||typeof VideoFrame<"u"&&Y instanceof VideoFrame){let X=Math.floor(P*U.width),Z=Math.floor(P*U.height);h===void 0&&(h=g(X,Z));let $=F?g(X,Z):h;return $.width=X,$.height=Z,$.getContext("2d").drawImage(Y,0,0,X,Z),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+U.width+"x"+U.height+") to ("+X+"x"+Z+")."),$}else return"data"in Y&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+U.width+"x"+U.height+")."),Y;return Y}function f(Y){return Y.generateMipmaps}function p(Y){i.generateMipmap(Y)}function v(Y){return Y.isWebGLCubeRenderTarget?i.TEXTURE_CUBE_MAP:Y.isWebGL3DRenderTarget?i.TEXTURE_3D:Y.isWebGLArrayRenderTarget||Y.isCompressedArrayTexture?i.TEXTURE_2D_ARRAY:i.TEXTURE_2D}function _(Y,F,D,P,U=!1){if(Y!==null){if(i[Y]!==void 0)return i[Y];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+Y+"'")}let X=F;if(F===i.RED&&(D===i.FLOAT&&(X=i.R32F),D===i.HALF_FLOAT&&(X=i.R16F),D===i.UNSIGNED_BYTE&&(X=i.R8)),F===i.RED_INTEGER&&(D===i.UNSIGNED_BYTE&&(X=i.R8UI),D===i.UNSIGNED_SHORT&&(X=i.R16UI),D===i.UNSIGNED_INT&&(X=i.R32UI),D===i.BYTE&&(X=i.R8I),D===i.SHORT&&(X=i.R16I),D===i.INT&&(X=i.R32I)),F===i.RG&&(D===i.FLOAT&&(X=i.RG32F),D===i.HALF_FLOAT&&(X=i.RG16F),D===i.UNSIGNED_BYTE&&(X=i.RG8)),F===i.RG_INTEGER&&(D===i.UNSIGNED_BYTE&&(X=i.RG8UI),D===i.UNSIGNED_SHORT&&(X=i.RG16UI),D===i.UNSIGNED_INT&&(X=i.RG32UI),D===i.BYTE&&(X=i.RG8I),D===i.SHORT&&(X=i.RG16I),D===i.INT&&(X=i.RG32I)),F===i.RGB_INTEGER&&(D===i.UNSIGNED_BYTE&&(X=i.RGB8UI),D===i.UNSIGNED_SHORT&&(X=i.RGB16UI),D===i.UNSIGNED_INT&&(X=i.RGB32UI),D===i.BYTE&&(X=i.RGB8I),D===i.SHORT&&(X=i.RGB16I),D===i.INT&&(X=i.RGB32I)),F===i.RGBA_INTEGER&&(D===i.UNSIGNED_BYTE&&(X=i.RGBA8UI),D===i.UNSIGNED_SHORT&&(X=i.RGBA16UI),D===i.UNSIGNED_INT&&(X=i.RGBA32UI),D===i.BYTE&&(X=i.RGBA8I),D===i.SHORT&&(X=i.RGBA16I),D===i.INT&&(X=i.RGBA32I)),F===i.RGB&&D===i.UNSIGNED_INT_5_9_9_9_REV&&(X=i.RGB9_E5),F===i.RGBA){let Z=U?Ka:_t.getTransfer(P);D===i.FLOAT&&(X=i.RGBA32F),D===i.HALF_FLOAT&&(X=i.RGBA16F),D===i.UNSIGNED_BYTE&&(X=Z===kt?i.SRGB8_ALPHA8:i.RGBA8),D===i.UNSIGNED_SHORT_4_4_4_4&&(X=i.RGBA4),D===i.UNSIGNED_SHORT_5_5_5_1&&(X=i.RGB5_A1)}return(X===i.R16F||X===i.R32F||X===i.RG16F||X===i.RG32F||X===i.RGBA16F||X===i.RGBA32F)&&e.get("EXT_color_buffer_float"),X}function y(Y,F){let D;return Y?F===null||F===Lr||F===Or?D=i.DEPTH24_STENCIL8:F===si?D=i.DEPTH32F_STENCIL8:F===Ko&&(D=i.DEPTH24_STENCIL8,console.warn("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):F===null||F===Lr||F===Or?D=i.DEPTH_COMPONENT24:F===si?D=i.DEPTH_COMPONENT32F:F===Ko&&(D=i.DEPTH_COMPONENT16),D}function b(Y,F){return f(Y)===!0||Y.isFramebufferTexture&&Y.minFilter!==Jt&&Y.minFilter!==nn?Math.log2(Math.max(F.width,F.height))+1:Y.mipmaps!==void 0&&Y.mipmaps.length>0?Y.mipmaps.length:Y.isCompressedTexture&&Array.isArray(Y.image)?F.mipmaps.length:1}function E(Y){let F=Y.target;F.removeEventListener("dispose",E),T(F),F.isVideoTexture&&u.delete(F)}function A(Y){let F=Y.target;F.removeEventListener("dispose",A),S(F)}function T(Y){let F=n.get(Y);if(F.__webglInit===void 0)return;let D=Y.source,P=d.get(D);if(P){let U=P[F.__cacheKey];U.usedTimes--,U.usedTimes===0&&M(Y),Object.keys(P).length===0&&d.delete(D)}n.remove(Y)}function M(Y){let F=n.get(Y);i.deleteTexture(F.__webglTexture);let D=Y.source,P=d.get(D);delete P[F.__cacheKey],o.memory.textures--}function S(Y){let F=n.get(Y);if(Y.depthTexture&&(Y.depthTexture.dispose(),n.remove(Y.depthTexture)),Y.isWebGLCubeRenderTarget)for(let P=0;P<6;P++){if(Array.isArray(F.__webglFramebuffer[P]))for(let U=0;U<F.__webglFramebuffer[P].length;U++)i.deleteFramebuffer(F.__webglFramebuffer[P][U]);else i.deleteFramebuffer(F.__webglFramebuffer[P]);F.__webglDepthbuffer&&i.deleteRenderbuffer(F.__webglDepthbuffer[P])}else{if(Array.isArray(F.__webglFramebuffer))for(let P=0;P<F.__webglFramebuffer.length;P++)i.deleteFramebuffer(F.__webglFramebuffer[P]);else i.deleteFramebuffer(F.__webglFramebuffer);if(F.__webglDepthbuffer&&i.deleteRenderbuffer(F.__webglDepthbuffer),F.__webglMultisampledFramebuffer&&i.deleteFramebuffer(F.__webglMultisampledFramebuffer),F.__webglColorRenderbuffer)for(let P=0;P<F.__webglColorRenderbuffer.length;P++)F.__webglColorRenderbuffer[P]&&i.deleteRenderbuffer(F.__webglColorRenderbuffer[P]);F.__webglDepthRenderbuffer&&i.deleteRenderbuffer(F.__webglDepthRenderbuffer)}let D=Y.textures;for(let P=0,U=D.length;P<U;P++){let X=n.get(D[P]);X.__webglTexture&&(i.deleteTexture(X.__webglTexture),o.memory.textures--),n.remove(D[P])}n.remove(Y)}let C=0;function N(){C=0}function I(){let Y=C;return Y>=r.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+Y+" texture units while this GPU supports only "+r.maxTextures),C+=1,Y}function L(Y){let F=[];return F.push(Y.wrapS),F.push(Y.wrapT),F.push(Y.wrapR||0),F.push(Y.magFilter),F.push(Y.minFilter),F.push(Y.anisotropy),F.push(Y.internalFormat),F.push(Y.format),F.push(Y.type),F.push(Y.generateMipmaps),F.push(Y.premultiplyAlpha),F.push(Y.flipY),F.push(Y.unpackAlignment),F.push(Y.colorSpace),F.join()}function q(Y,F){let D=n.get(Y);if(Y.isVideoTexture&&Re(Y),Y.isRenderTargetTexture===!1&&Y.version>0&&D.__version!==Y.version){let P=Y.image;if(P===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(P.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{V(D,Y,F);return}}t.bindTexture(i.TEXTURE_2D,D.__webglTexture,i.TEXTURE0+F)}function K(Y,F){let D=n.get(Y);if(Y.version>0&&D.__version!==Y.version){V(D,Y,F);return}t.bindTexture(i.TEXTURE_2D_ARRAY,D.__webglTexture,i.TEXTURE0+F)}function B(Y,F){let D=n.get(Y);if(Y.version>0&&D.__version!==Y.version){V(D,Y,F);return}t.bindTexture(i.TEXTURE_3D,D.__webglTexture,i.TEXTURE0+F)}function j(Y,F){let D=n.get(Y);if(Y.version>0&&D.__version!==Y.version){w(D,Y,F);return}t.bindTexture(i.TEXTURE_CUBE_MAP,D.__webglTexture,i.TEXTURE0+F)}let J={[gn]:i.REPEAT,[Mn]:i.CLAMP_TO_EDGE,[ks]:i.MIRRORED_REPEAT},se={[Jt]:i.NEAREST,[Mc]:i.NEAREST_MIPMAP_NEAREST,[hs]:i.NEAREST_MIPMAP_LINEAR,[nn]:i.LINEAR,[Zs]:i.LINEAR_MIPMAP_NEAREST,[Ei]:i.LINEAR_MIPMAP_LINEAR},ce={[g0]:i.NEVER,[M0]:i.ALWAYS,[x0]:i.LESS,[_p]:i.LEQUAL,[y0]:i.EQUAL,[b0]:i.GEQUAL,[v0]:i.GREATER,[_0]:i.NOTEQUAL};function me(Y,F){if(F.type===si&&e.has("OES_texture_float_linear")===!1&&(F.magFilter===nn||F.magFilter===Zs||F.magFilter===hs||F.magFilter===Ei||F.minFilter===nn||F.minFilter===Zs||F.minFilter===hs||F.minFilter===Ei)&&console.warn("THREE.WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),i.texParameteri(Y,i.TEXTURE_WRAP_S,J[F.wrapS]),i.texParameteri(Y,i.TEXTURE_WRAP_T,J[F.wrapT]),(Y===i.TEXTURE_3D||Y===i.TEXTURE_2D_ARRAY)&&i.texParameteri(Y,i.TEXTURE_WRAP_R,J[F.wrapR]),i.texParameteri(Y,i.TEXTURE_MAG_FILTER,se[F.magFilter]),i.texParameteri(Y,i.TEXTURE_MIN_FILTER,se[F.minFilter]),F.compareFunction&&(i.texParameteri(Y,i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE),i.texParameteri(Y,i.TEXTURE_COMPARE_FUNC,ce[F.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(F.magFilter===Jt||F.minFilter!==hs&&F.minFilter!==Ei||F.type===si&&e.has("OES_texture_float_linear")===!1)return;if(F.anisotropy>1||n.get(F).__currentAnisotropy){let D=e.get("EXT_texture_filter_anisotropic");i.texParameterf(Y,D.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(F.anisotropy,r.getMaxAnisotropy())),n.get(F).__currentAnisotropy=F.anisotropy}}}function Se(Y,F){let D=!1;Y.__webglInit===void 0&&(Y.__webglInit=!0,F.addEventListener("dispose",E));let P=F.source,U=d.get(P);U===void 0&&(U={},d.set(P,U));let X=L(F);if(X!==Y.__cacheKey){U[X]===void 0&&(U[X]={texture:i.createTexture(),usedTimes:0},o.memory.textures++,D=!0),U[X].usedTimes++;let Z=U[Y.__cacheKey];Z!==void 0&&(U[Y.__cacheKey].usedTimes--,Z.usedTimes===0&&M(F)),Y.__cacheKey=X,Y.__webglTexture=U[X].texture}return D}function V(Y,F,D){let P=i.TEXTURE_2D;(F.isDataArrayTexture||F.isCompressedArrayTexture)&&(P=i.TEXTURE_2D_ARRAY),F.isData3DTexture&&(P=i.TEXTURE_3D);let U=Se(Y,F),X=F.source;t.bindTexture(P,Y.__webglTexture,i.TEXTURE0+D);let Z=n.get(X);if(X.version!==Z.__version||U===!0){t.activeTexture(i.TEXTURE0+D);let $=_t.getPrimaries(_t.workingColorSpace),te=F.colorSpace===Dr?null:_t.getPrimaries(F.colorSpace),ae=F.colorSpace===Dr||$===te?i.NONE:i.BROWSER_DEFAULT_WEBGL;i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,F.flipY),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,F.premultiplyAlpha),i.pixelStorei(i.UNPACK_ALIGNMENT,F.unpackAlignment),i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,ae);let re=x(F.image,!1,r.maxTextureSize);re=We(F,re);let ge=s.convert(F.format,F.colorSpace),xe=s.convert(F.type),Ne=_(F.internalFormat,ge,xe,F.colorSpace,F.isVideoTexture);me(P,F);let ke,$e=F.mipmaps,Le=F.isVideoTexture!==!0,Xe=Z.__version===void 0||U===!0,ne=X.dataReady,Pe=b(F,re);if(F.isDepthTexture)Ne=y(F.format===Mr,F.type),Xe&&(Le?t.texStorage2D(i.TEXTURE_2D,1,Ne,re.width,re.height):t.texImage2D(i.TEXTURE_2D,0,Ne,re.width,re.height,0,ge,xe,null));else if(F.isDataTexture)if($e.length>0){Le&&Xe&&t.texStorage2D(i.TEXTURE_2D,Pe,Ne,$e[0].width,$e[0].height);for(let pe=0,fe=$e.length;pe<fe;pe++)ke=$e[pe],Le?ne&&t.texSubImage2D(i.TEXTURE_2D,pe,0,0,ke.width,ke.height,ge,xe,ke.data):t.texImage2D(i.TEXTURE_2D,pe,Ne,ke.width,ke.height,0,ge,xe,ke.data);F.generateMipmaps=!1}else Le?(Xe&&t.texStorage2D(i.TEXTURE_2D,Pe,Ne,re.width,re.height),ne&&t.texSubImage2D(i.TEXTURE_2D,0,0,0,re.width,re.height,ge,xe,re.data)):t.texImage2D(i.TEXTURE_2D,0,Ne,re.width,re.height,0,ge,xe,re.data);else if(F.isCompressedTexture)if(F.isCompressedArrayTexture){Le&&Xe&&t.texStorage3D(i.TEXTURE_2D_ARRAY,Pe,Ne,$e[0].width,$e[0].height,re.depth);for(let pe=0,fe=$e.length;pe<fe;pe++)if(ke=$e[pe],F.format!==Ln)if(ge!==null)if(Le){if(ne)if(F.layerUpdates.size>0){let Be=Sp(ke.width,ke.height,F.format,F.type);for(let De of F.layerUpdates){let st=ke.data.subarray(De*Be/ke.data.BYTES_PER_ELEMENT,(De+1)*Be/ke.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,pe,0,0,De,ke.width,ke.height,1,ge,st)}F.clearLayerUpdates()}else t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,pe,0,0,0,ke.width,ke.height,re.depth,ge,ke.data)}else t.compressedTexImage3D(i.TEXTURE_2D_ARRAY,pe,Ne,ke.width,ke.height,re.depth,0,ke.data,0,0);else console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else Le?ne&&t.texSubImage3D(i.TEXTURE_2D_ARRAY,pe,0,0,0,ke.width,ke.height,re.depth,ge,xe,ke.data):t.texImage3D(i.TEXTURE_2D_ARRAY,pe,Ne,ke.width,ke.height,re.depth,0,ge,xe,ke.data)}else{Le&&Xe&&t.texStorage2D(i.TEXTURE_2D,Pe,Ne,$e[0].width,$e[0].height);for(let pe=0,fe=$e.length;pe<fe;pe++)ke=$e[pe],F.format!==Ln?ge!==null?Le?ne&&t.compressedTexSubImage2D(i.TEXTURE_2D,pe,0,0,ke.width,ke.height,ge,ke.data):t.compressedTexImage2D(i.TEXTURE_2D,pe,Ne,ke.width,ke.height,0,ke.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Le?ne&&t.texSubImage2D(i.TEXTURE_2D,pe,0,0,ke.width,ke.height,ge,xe,ke.data):t.texImage2D(i.TEXTURE_2D,pe,Ne,ke.width,ke.height,0,ge,xe,ke.data)}else if(F.isDataArrayTexture)if(Le){if(Xe&&t.texStorage3D(i.TEXTURE_2D_ARRAY,Pe,Ne,re.width,re.height,re.depth),ne)if(F.layerUpdates.size>0){let pe=Sp(re.width,re.height,F.format,F.type);for(let fe of F.layerUpdates){let Be=re.data.subarray(fe*pe/re.data.BYTES_PER_ELEMENT,(fe+1)*pe/re.data.BYTES_PER_ELEMENT);t.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,fe,re.width,re.height,1,ge,xe,Be)}F.clearLayerUpdates()}else t.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,0,re.width,re.height,re.depth,ge,xe,re.data)}else t.texImage3D(i.TEXTURE_2D_ARRAY,0,Ne,re.width,re.height,re.depth,0,ge,xe,re.data);else if(F.isData3DTexture)Le?(Xe&&t.texStorage3D(i.TEXTURE_3D,Pe,Ne,re.width,re.height,re.depth),ne&&t.texSubImage3D(i.TEXTURE_3D,0,0,0,0,re.width,re.height,re.depth,ge,xe,re.data)):t.texImage3D(i.TEXTURE_3D,0,Ne,re.width,re.height,re.depth,0,ge,xe,re.data);else if(F.isFramebufferTexture){if(Xe)if(Le)t.texStorage2D(i.TEXTURE_2D,Pe,Ne,re.width,re.height);else{let pe=re.width,fe=re.height;for(let Be=0;Be<Pe;Be++)t.texImage2D(i.TEXTURE_2D,Be,Ne,pe,fe,0,ge,xe,null),pe>>=1,fe>>=1}}else if($e.length>0){if(Le&&Xe){let pe=Ae($e[0]);t.texStorage2D(i.TEXTURE_2D,Pe,Ne,pe.width,pe.height)}for(let pe=0,fe=$e.length;pe<fe;pe++)ke=$e[pe],Le?ne&&t.texSubImage2D(i.TEXTURE_2D,pe,0,0,ge,xe,ke):t.texImage2D(i.TEXTURE_2D,pe,Ne,ge,xe,ke);F.generateMipmaps=!1}else if(Le){if(Xe){let pe=Ae(re);t.texStorage2D(i.TEXTURE_2D,Pe,Ne,pe.width,pe.height)}ne&&t.texSubImage2D(i.TEXTURE_2D,0,0,0,ge,xe,re)}else t.texImage2D(i.TEXTURE_2D,0,Ne,ge,xe,re);f(F)&&p(P),Z.__version=X.version,F.onUpdate&&F.onUpdate(F)}Y.__version=F.version}function w(Y,F,D){if(F.image.length!==6)return;let P=Se(Y,F),U=F.source;t.bindTexture(i.TEXTURE_CUBE_MAP,Y.__webglTexture,i.TEXTURE0+D);let X=n.get(U);if(U.version!==X.__version||P===!0){t.activeTexture(i.TEXTURE0+D);let Z=_t.getPrimaries(_t.workingColorSpace),$=F.colorSpace===Dr?null:_t.getPrimaries(F.colorSpace),te=F.colorSpace===Dr||Z===$?i.NONE:i.BROWSER_DEFAULT_WEBGL;i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,F.flipY),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,F.premultiplyAlpha),i.pixelStorei(i.UNPACK_ALIGNMENT,F.unpackAlignment),i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,te);let ae=F.isCompressedTexture||F.image[0].isCompressedTexture,re=F.image[0]&&F.image[0].isDataTexture,ge=[];for(let fe=0;fe<6;fe++)!ae&&!re?ge[fe]=x(F.image[fe],!0,r.maxCubemapSize):ge[fe]=re?F.image[fe].image:F.image[fe],ge[fe]=We(F,ge[fe]);let xe=ge[0],Ne=s.convert(F.format,F.colorSpace),ke=s.convert(F.type),$e=_(F.internalFormat,Ne,ke,F.colorSpace),Le=F.isVideoTexture!==!0,Xe=X.__version===void 0||P===!0,ne=U.dataReady,Pe=b(F,xe);me(i.TEXTURE_CUBE_MAP,F);let pe;if(ae){Le&&Xe&&t.texStorage2D(i.TEXTURE_CUBE_MAP,Pe,$e,xe.width,xe.height);for(let fe=0;fe<6;fe++){pe=ge[fe].mipmaps;for(let Be=0;Be<pe.length;Be++){let De=pe[Be];F.format!==Ln?Ne!==null?Le?ne&&t.compressedTexSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+fe,Be,0,0,De.width,De.height,Ne,De.data):t.compressedTexImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+fe,Be,$e,De.width,De.height,0,De.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):Le?ne&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+fe,Be,0,0,De.width,De.height,Ne,ke,De.data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+fe,Be,$e,De.width,De.height,0,Ne,ke,De.data)}}}else{if(pe=F.mipmaps,Le&&Xe){pe.length>0&&Pe++;let fe=Ae(ge[0]);t.texStorage2D(i.TEXTURE_CUBE_MAP,Pe,$e,fe.width,fe.height)}for(let fe=0;fe<6;fe++)if(re){Le?ne&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+fe,0,0,0,ge[fe].width,ge[fe].height,Ne,ke,ge[fe].data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+fe,0,$e,ge[fe].width,ge[fe].height,0,Ne,ke,ge[fe].data);for(let Be=0;Be<pe.length;Be++){let st=pe[Be].image[fe].image;Le?ne&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+fe,Be+1,0,0,st.width,st.height,Ne,ke,st.data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+fe,Be+1,$e,st.width,st.height,0,Ne,ke,st.data)}}else{Le?ne&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+fe,0,0,0,Ne,ke,ge[fe]):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+fe,0,$e,Ne,ke,ge[fe]);for(let Be=0;Be<pe.length;Be++){let De=pe[Be];Le?ne&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+fe,Be+1,0,0,Ne,ke,De.image[fe]):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+fe,Be+1,$e,Ne,ke,De.image[fe])}}}f(F)&&p(i.TEXTURE_CUBE_MAP),X.__version=U.version,F.onUpdate&&F.onUpdate(F)}Y.__version=F.version}function O(Y,F,D,P,U,X){let Z=s.convert(D.format,D.colorSpace),$=s.convert(D.type),te=_(D.internalFormat,Z,$,D.colorSpace),ae=n.get(F),re=n.get(D);if(re.__renderTarget=F,!ae.__hasExternalTextures){let ge=Math.max(1,F.width>>X),xe=Math.max(1,F.height>>X);U===i.TEXTURE_3D||U===i.TEXTURE_2D_ARRAY?t.texImage3D(U,X,te,ge,xe,F.depth,0,Z,$,null):t.texImage2D(U,X,te,ge,xe,0,Z,$,null)}t.bindFramebuffer(i.FRAMEBUFFER,Y),Oe(F)?a.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,P,U,re.__webglTexture,0,Te(F)):(U===i.TEXTURE_2D||U>=i.TEXTURE_CUBE_MAP_POSITIVE_X&&U<=i.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&i.framebufferTexture2D(i.FRAMEBUFFER,P,U,re.__webglTexture,X),t.bindFramebuffer(i.FRAMEBUFFER,null)}function W(Y,F,D){if(i.bindRenderbuffer(i.RENDERBUFFER,Y),F.depthBuffer){let P=F.depthTexture,U=P&&P.isDepthTexture?P.type:null,X=y(F.stencilBuffer,U),Z=F.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,$=Te(F);Oe(F)?a.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,$,X,F.width,F.height):D?i.renderbufferStorageMultisample(i.RENDERBUFFER,$,X,F.width,F.height):i.renderbufferStorage(i.RENDERBUFFER,X,F.width,F.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,Z,i.RENDERBUFFER,Y)}else{let P=F.textures;for(let U=0;U<P.length;U++){let X=P[U],Z=s.convert(X.format,X.colorSpace),$=s.convert(X.type),te=_(X.internalFormat,Z,$,X.colorSpace),ae=Te(F);D&&Oe(F)===!1?i.renderbufferStorageMultisample(i.RENDERBUFFER,ae,te,F.width,F.height):Oe(F)?a.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,ae,te,F.width,F.height):i.renderbufferStorage(i.RENDERBUFFER,te,F.width,F.height)}}i.bindRenderbuffer(i.RENDERBUFFER,null)}function Q(Y,F){if(F&&F.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(t.bindFramebuffer(i.FRAMEBUFFER,Y),!(F.depthTexture&&F.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");let P=n.get(F.depthTexture);P.__renderTarget=F,(!P.__webglTexture||F.depthTexture.image.width!==F.width||F.depthTexture.image.height!==F.height)&&(F.depthTexture.image.width=F.width,F.depthTexture.image.height=F.height,F.depthTexture.needsUpdate=!0),q(F.depthTexture,0);let U=P.__webglTexture,X=Te(F);if(F.depthTexture.format===Ds)Oe(F)?a.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.TEXTURE_2D,U,0,X):i.framebufferTexture2D(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.TEXTURE_2D,U,0);else if(F.depthTexture.format===Mr)Oe(F)?a.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,i.DEPTH_STENCIL_ATTACHMENT,i.TEXTURE_2D,U,0,X):i.framebufferTexture2D(i.FRAMEBUFFER,i.DEPTH_STENCIL_ATTACHMENT,i.TEXTURE_2D,U,0);else throw new Error("Unknown depthTexture format")}function ee(Y){let F=n.get(Y),D=Y.isWebGLCubeRenderTarget===!0;if(F.__boundDepthTexture!==Y.depthTexture){let P=Y.depthTexture;if(F.__depthDisposeCallback&&F.__depthDisposeCallback(),P){let U=()=>{delete F.__boundDepthTexture,delete F.__depthDisposeCallback,P.removeEventListener("dispose",U)};P.addEventListener("dispose",U),F.__depthDisposeCallback=U}F.__boundDepthTexture=P}if(Y.depthTexture&&!F.__autoAllocateDepthBuffer){if(D)throw new Error("target.depthTexture not supported in Cube render targets");Q(F.__webglFramebuffer,Y)}else if(D){F.__webglDepthbuffer=[];for(let P=0;P<6;P++)if(t.bindFramebuffer(i.FRAMEBUFFER,F.__webglFramebuffer[P]),F.__webglDepthbuffer[P]===void 0)F.__webglDepthbuffer[P]=i.createRenderbuffer(),W(F.__webglDepthbuffer[P],Y,!1);else{let U=Y.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,X=F.__webglDepthbuffer[P];i.bindRenderbuffer(i.RENDERBUFFER,X),i.framebufferRenderbuffer(i.FRAMEBUFFER,U,i.RENDERBUFFER,X)}}else if(t.bindFramebuffer(i.FRAMEBUFFER,F.__webglFramebuffer),F.__webglDepthbuffer===void 0)F.__webglDepthbuffer=i.createRenderbuffer(),W(F.__webglDepthbuffer,Y,!1);else{let P=Y.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,U=F.__webglDepthbuffer;i.bindRenderbuffer(i.RENDERBUFFER,U),i.framebufferRenderbuffer(i.FRAMEBUFFER,P,i.RENDERBUFFER,U)}t.bindFramebuffer(i.FRAMEBUFFER,null)}function he(Y,F,D){let P=n.get(Y);F!==void 0&&O(P.__webglFramebuffer,Y,Y.texture,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,0),D!==void 0&&ee(Y)}function Ce(Y){let F=Y.texture,D=n.get(Y),P=n.get(F);Y.addEventListener("dispose",A);let U=Y.textures,X=Y.isWebGLCubeRenderTarget===!0,Z=U.length>1;if(Z||(P.__webglTexture===void 0&&(P.__webglTexture=i.createTexture()),P.__version=F.version,o.memory.textures++),X){D.__webglFramebuffer=[];for(let $=0;$<6;$++)if(F.mipmaps&&F.mipmaps.length>0){D.__webglFramebuffer[$]=[];for(let te=0;te<F.mipmaps.length;te++)D.__webglFramebuffer[$][te]=i.createFramebuffer()}else D.__webglFramebuffer[$]=i.createFramebuffer()}else{if(F.mipmaps&&F.mipmaps.length>0){D.__webglFramebuffer=[];for(let $=0;$<F.mipmaps.length;$++)D.__webglFramebuffer[$]=i.createFramebuffer()}else D.__webglFramebuffer=i.createFramebuffer();if(Z)for(let $=0,te=U.length;$<te;$++){let ae=n.get(U[$]);ae.__webglTexture===void 0&&(ae.__webglTexture=i.createTexture(),o.memory.textures++)}if(Y.samples>0&&Oe(Y)===!1){D.__webglMultisampledFramebuffer=i.createFramebuffer(),D.__webglColorRenderbuffer=[],t.bindFramebuffer(i.FRAMEBUFFER,D.__webglMultisampledFramebuffer);for(let $=0;$<U.length;$++){let te=U[$];D.__webglColorRenderbuffer[$]=i.createRenderbuffer(),i.bindRenderbuffer(i.RENDERBUFFER,D.__webglColorRenderbuffer[$]);let ae=s.convert(te.format,te.colorSpace),re=s.convert(te.type),ge=_(te.internalFormat,ae,re,te.colorSpace,Y.isXRRenderTarget===!0),xe=Te(Y);i.renderbufferStorageMultisample(i.RENDERBUFFER,xe,ge,Y.width,Y.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+$,i.RENDERBUFFER,D.__webglColorRenderbuffer[$])}i.bindRenderbuffer(i.RENDERBUFFER,null),Y.depthBuffer&&(D.__webglDepthRenderbuffer=i.createRenderbuffer(),W(D.__webglDepthRenderbuffer,Y,!0)),t.bindFramebuffer(i.FRAMEBUFFER,null)}}if(X){t.bindTexture(i.TEXTURE_CUBE_MAP,P.__webglTexture),me(i.TEXTURE_CUBE_MAP,F);for(let $=0;$<6;$++)if(F.mipmaps&&F.mipmaps.length>0)for(let te=0;te<F.mipmaps.length;te++)O(D.__webglFramebuffer[$][te],Y,F,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+$,te);else O(D.__webglFramebuffer[$],Y,F,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+$,0);f(F)&&p(i.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(Z){for(let $=0,te=U.length;$<te;$++){let ae=U[$],re=n.get(ae);t.bindTexture(i.TEXTURE_2D,re.__webglTexture),me(i.TEXTURE_2D,ae),O(D.__webglFramebuffer,Y,ae,i.COLOR_ATTACHMENT0+$,i.TEXTURE_2D,0),f(ae)&&p(i.TEXTURE_2D)}t.unbindTexture()}else{let $=i.TEXTURE_2D;if((Y.isWebGL3DRenderTarget||Y.isWebGLArrayRenderTarget)&&($=Y.isWebGL3DRenderTarget?i.TEXTURE_3D:i.TEXTURE_2D_ARRAY),t.bindTexture($,P.__webglTexture),me($,F),F.mipmaps&&F.mipmaps.length>0)for(let te=0;te<F.mipmaps.length;te++)O(D.__webglFramebuffer[te],Y,F,i.COLOR_ATTACHMENT0,$,te);else O(D.__webglFramebuffer,Y,F,i.COLOR_ATTACHMENT0,$,0);f(F)&&p($),t.unbindTexture()}Y.depthBuffer&&ee(Y)}function oe(Y){let F=Y.textures;for(let D=0,P=F.length;D<P;D++){let U=F[D];if(f(U)){let X=v(Y),Z=n.get(U).__webglTexture;t.bindTexture(X,Z),p(X),t.unbindTexture()}}}let ue=[],H=[];function Ie(Y){if(Y.samples>0){if(Oe(Y)===!1){let F=Y.textures,D=Y.width,P=Y.height,U=i.COLOR_BUFFER_BIT,X=Y.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,Z=n.get(Y),$=F.length>1;if($)for(let te=0;te<F.length;te++)t.bindFramebuffer(i.FRAMEBUFFER,Z.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+te,i.RENDERBUFFER,null),t.bindFramebuffer(i.FRAMEBUFFER,Z.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+te,i.TEXTURE_2D,null,0);t.bindFramebuffer(i.READ_FRAMEBUFFER,Z.__webglMultisampledFramebuffer),t.bindFramebuffer(i.DRAW_FRAMEBUFFER,Z.__webglFramebuffer);for(let te=0;te<F.length;te++){if(Y.resolveDepthBuffer&&(Y.depthBuffer&&(U|=i.DEPTH_BUFFER_BIT),Y.stencilBuffer&&Y.resolveStencilBuffer&&(U|=i.STENCIL_BUFFER_BIT)),$){i.framebufferRenderbuffer(i.READ_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.RENDERBUFFER,Z.__webglColorRenderbuffer[te]);let ae=n.get(F[te]).__webglTexture;i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,ae,0)}i.blitFramebuffer(0,0,D,P,0,0,D,P,U,i.NEAREST),c===!0&&(ue.length=0,H.length=0,ue.push(i.COLOR_ATTACHMENT0+te),Y.depthBuffer&&Y.resolveDepthBuffer===!1&&(ue.push(X),H.push(X),i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,H)),i.invalidateFramebuffer(i.READ_FRAMEBUFFER,ue))}if(t.bindFramebuffer(i.READ_FRAMEBUFFER,null),t.bindFramebuffer(i.DRAW_FRAMEBUFFER,null),$)for(let te=0;te<F.length;te++){t.bindFramebuffer(i.FRAMEBUFFER,Z.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+te,i.RENDERBUFFER,Z.__webglColorRenderbuffer[te]);let ae=n.get(F[te]).__webglTexture;t.bindFramebuffer(i.FRAMEBUFFER,Z.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+te,i.TEXTURE_2D,ae,0)}t.bindFramebuffer(i.DRAW_FRAMEBUFFER,Z.__webglMultisampledFramebuffer)}else if(Y.depthBuffer&&Y.resolveDepthBuffer===!1&&c){let F=Y.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,[F])}}}function Te(Y){return Math.min(r.maxSamples,Y.samples)}function Oe(Y){let F=n.get(Y);return Y.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&F.__useRenderToTexture!==!1}function Re(Y){let F=o.render.frame;u.get(Y)!==F&&(u.set(Y,F),Y.update())}function We(Y,F){let D=Y.colorSpace,P=Y.format,U=Y.type;return Y.isCompressedTexture===!0||Y.isVideoTexture===!0||D!==On&&D!==Dr&&(_t.getTransfer(D)===kt?(P!==Ln||U!==ci)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",D)),F}function Ae(Y){return typeof HTMLImageElement<"u"&&Y instanceof HTMLImageElement?(l.width=Y.naturalWidth||Y.width,l.height=Y.naturalHeight||Y.height):typeof VideoFrame<"u"&&Y instanceof VideoFrame?(l.width=Y.displayWidth,l.height=Y.displayHeight):(l.width=Y.width,l.height=Y.height),l}this.allocateTextureUnit=I,this.resetTextureUnits=N,this.setTexture2D=q,this.setTexture2DArray=K,this.setTexture3D=B,this.setTextureCube=j,this.rebindTextures=he,this.setupRenderTarget=Ce,this.updateRenderTargetMipmap=oe,this.updateMultisampleRenderTarget=Ie,this.setupDepthRenderbuffer=ee,this.setupFrameBufferTexture=O,this.useMultisampledRTT=Oe}function kb(i,e){function t(n,r=Dr){let s,o=_t.getTransfer(r);if(n===ci)return i.UNSIGNED_BYTE;if(n===Vu)return i.UNSIGNED_SHORT_4_4_4_4;if(n===Hu)return i.UNSIGNED_SHORT_5_5_5_1;if(n===hp)return i.UNSIGNED_INT_5_9_9_9_REV;if(n===lp)return i.BYTE;if(n===up)return i.SHORT;if(n===Ko)return i.UNSIGNED_SHORT;if(n===zu)return i.INT;if(n===Lr)return i.UNSIGNED_INT;if(n===si)return i.FLOAT;if(n===Hn)return i.HALF_FLOAT;if(n===dp)return i.ALPHA;if(n===fp)return i.RGB;if(n===Ln)return i.RGBA;if(n===pp)return i.LUMINANCE;if(n===mp)return i.LUMINANCE_ALPHA;if(n===Ds)return i.DEPTH_COMPONENT;if(n===Mr)return i.DEPTH_STENCIL;if(n===Gu)return i.RED;if(n===Ec)return i.RED_INTEGER;if(n===gp)return i.RG;if(n===Wu)return i.RG_INTEGER;if(n===Xu)return i.RGBA_INTEGER;if(n===Sc||n===Tc||n===Ac||n===wc)if(o===kt)if(s=e.get("WEBGL_compressed_texture_s3tc_srgb"),s!==null){if(n===Sc)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===Tc)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===Ac)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===wc)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(s=e.get("WEBGL_compressed_texture_s3tc"),s!==null){if(n===Sc)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===Tc)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===Ac)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===wc)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===Yu||n===ju||n===qu||n===Ku)if(s=e.get("WEBGL_compressed_texture_pvrtc"),s!==null){if(n===Yu)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===ju)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===qu)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===Ku)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===Zu||n===Ju||n===Qu)if(s=e.get("WEBGL_compressed_texture_etc"),s!==null){if(n===Zu||n===Ju)return o===kt?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(n===Qu)return o===kt?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(n===$u||n===eh||n===th||n===nh||n===ih||n===rh||n===sh||n===oh||n===ah||n===ch||n===lh||n===uh||n===hh||n===dh)if(s=e.get("WEBGL_compressed_texture_astc"),s!==null){if(n===$u)return o===kt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===eh)return o===kt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===th)return o===kt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===nh)return o===kt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===ih)return o===kt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===rh)return o===kt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===sh)return o===kt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===oh)return o===kt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===ah)return o===kt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===ch)return o===kt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===lh)return o===kt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===uh)return o===kt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===hh)return o===kt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===dh)return o===kt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===Rc||n===fh||n===ph)if(s=e.get("EXT_texture_compression_bptc"),s!==null){if(n===Rc)return o===kt?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===fh)return s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===ph)return s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===xp||n===mh||n===gh||n===xh)if(s=e.get("EXT_texture_compression_rgtc"),s!==null){if(n===Rc)return s.COMPRESSED_RED_RGTC1_EXT;if(n===mh)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===gh)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===xh)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===Or?i.UNSIGNED_INT_24_8:i[n]!==void 0?i[n]:null}return{convert:t}}var vC={type:"move"},_h=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Dt,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 Dt,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new z,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new z),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Dt,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new z,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new z),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){let t=this._hand;if(t)for(let n of e.hand.values())this._getHandJoint(t,n)}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,n){let r=null,s=null,o=null,a=this._targetRay,c=this._grip,l=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(l&&e.hand){o=!0;for(let x of e.hand.values()){let f=t.getJointPose(x,n),p=this._getHandJoint(l,x);f!==null&&(p.matrix.fromArray(f.transform.matrix),p.matrix.decompose(p.position,p.rotation,p.scale),p.matrixWorldNeedsUpdate=!0,p.jointRadius=f.radius),p.visible=f!==null}let u=l.joints["index-finger-tip"],h=l.joints["thumb-tip"],d=u.position.distanceTo(h.position),m=.02,g=.005;l.inputState.pinching&&d>m+g?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!l.inputState.pinching&&d<=m-g&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else c!==null&&e.gripSpace&&(s=t.getPose(e.gripSpace,n),s!==null&&(c.matrix.fromArray(s.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),c.matrixWorldNeedsUpdate=!0,s.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(s.linearVelocity)):c.hasLinearVelocity=!1,s.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(s.angularVelocity)):c.hasAngularVelocity=!1));a!==null&&(r=t.getPose(e.targetRaySpace,n),r===null&&s!==null&&(r=s),r!==null&&(a.matrix.fromArray(r.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),a.matrixWorldNeedsUpdate=!0,r.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(r.linearVelocity)):a.hasLinearVelocity=!1,r.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(r.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(vC)))}return a!==null&&(a.visible=r!==null),c!==null&&(c.visible=s!==null),l!==null&&(l.visible=o!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){let n=new Dt;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}},_C=`
void main() {
gl_Position = vec4( position, 1.0 );
}`,bC=`
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;
}
}`,W0=class{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t,n){if(this.texture===null){let r=new Qt,s=e.properties.get(r);s.__webglTexture=t.texture,(t.depthNear!=n.depthNear||t.depthFar!=n.depthFar)&&(this.depthNear=t.depthNear,this.depthFar=t.depthFar),this.texture=r}}getMesh(e){if(this.texture!==null&&this.mesh===null){let t=e.cameras[0].viewport,n=new $t({vertexShader:_C,fragmentShader:bC,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new ct(new Ar(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}},X0=class extends ki{constructor(e,t){super();let n=this,r=null,s=1,o=null,a="local-floor",c=1,l=null,u=null,h=null,d=null,m=null,g=null,x=new W0,f=t.getContextAttributes(),p=null,v=null,_=[],y=[],b=new Me,E=null,A=new jt;A.viewport=new It;let T=new jt;T.viewport=new It;let M=[A,T],S=new bu,C=null,N=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(V){let w=_[V];return w===void 0&&(w=new _h,_[V]=w),w.getTargetRaySpace()},this.getControllerGrip=function(V){let w=_[V];return w===void 0&&(w=new _h,_[V]=w),w.getGripSpace()},this.getHand=function(V){let w=_[V];return w===void 0&&(w=new _h,_[V]=w),w.getHandSpace()};function I(V){let w=y.indexOf(V.inputSource);if(w===-1)return;let O=_[w];O!==void 0&&(O.update(V.inputSource,V.frame,l||o),O.dispatchEvent({type:V.type,data:V.inputSource}))}function L(){r.removeEventListener("select",I),r.removeEventListener("selectstart",I),r.removeEventListener("selectend",I),r.removeEventListener("squeeze",I),r.removeEventListener("squeezestart",I),r.removeEventListener("squeezeend",I),r.removeEventListener("end",L),r.removeEventListener("inputsourceschange",q);for(let V=0;V<_.length;V++){let w=y[V];w!==null&&(y[V]=null,_[V].disconnect(w))}C=null,N=null,x.reset(),e.setRenderTarget(p),m=null,d=null,h=null,r=null,v=null,Se.stop(),n.isPresenting=!1,e.setPixelRatio(E),e.setSize(b.width,b.height,!1),n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(V){s=V,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(V){a=V,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||o},this.setReferenceSpace=function(V){l=V},this.getBaseLayer=function(){return d!==null?d:m},this.getBinding=function(){return h},this.getFrame=function(){return g},this.getSession=function(){return r},this.setSession=async function(V){if(r=V,r!==null){if(p=e.getRenderTarget(),r.addEventListener("select",I),r.addEventListener("selectstart",I),r.addEventListener("selectend",I),r.addEventListener("squeeze",I),r.addEventListener("squeezestart",I),r.addEventListener("squeezeend",I),r.addEventListener("end",L),r.addEventListener("inputsourceschange",q),f.xrCompatible!==!0&&await t.makeXRCompatible(),E=e.getPixelRatio(),e.getSize(b),r.renderState.layers===void 0){let w={antialias:f.antialias,alpha:!0,depth:f.depth,stencil:f.stencil,framebufferScaleFactor:s};m=new XRWebGLLayer(r,t,w),r.updateRenderState({baseLayer:m}),e.setPixelRatio(1),e.setSize(m.framebufferWidth,m.framebufferHeight,!1),v=new on(m.framebufferWidth,m.framebufferHeight,{format:Ln,type:ci,colorSpace:e.outputColorSpace,stencilBuffer:f.stencil})}else{let w=null,O=null,W=null;f.depth&&(W=f.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,w=f.stencil?Mr:Ds,O=f.stencil?Or:Lr);let Q={colorFormat:t.RGBA8,depthFormat:W,scaleFactor:s};h=new XRWebGLBinding(r,t),d=h.createProjectionLayer(Q),r.updateRenderState({layers:[d]}),e.setPixelRatio(1),e.setSize(d.textureWidth,d.textureHeight,!1),v=new on(d.textureWidth,d.textureHeight,{format:Ln,type:ci,depthTexture:new Xs(d.textureWidth,d.textureHeight,O,void 0,void 0,void 0,void 0,void 0,void 0,w),stencilBuffer:f.stencil,colorSpace:e.outputColorSpace,samples:f.antialias?4:0,resolveDepthBuffer:d.ignoreDepthValues===!1})}v.isXRRenderTarget=!0,this.setFoveation(c),l=null,o=await r.requestReferenceSpace(a),Se.setContext(r),Se.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(r!==null)return r.environmentBlendMode},this.getDepthTexture=function(){return x.getDepthTexture()};function q(V){for(let w=0;w<V.removed.length;w++){let O=V.removed[w],W=y.indexOf(O);W>=0&&(y[W]=null,_[W].disconnect(O))}for(let w=0;w<V.added.length;w++){let O=V.added[w],W=y.indexOf(O);if(W===-1){for(let ee=0;ee<_.length;ee++)if(ee>=y.length){y.push(O),W=ee;break}else if(y[ee]===null){y[ee]=O,W=ee;break}if(W===-1)break}let Q=_[W];Q&&Q.connect(O)}}let K=new z,B=new z;function j(V,w,O){K.setFromMatrixPosition(w.matrixWorld),B.setFromMatrixPosition(O.matrixWorld);let W=K.distanceTo(B),Q=w.projectionMatrix.elements,ee=O.projectionMatrix.elements,he=Q[14]/(Q[10]-1),Ce=Q[14]/(Q[10]+1),oe=(Q[9]+1)/Q[5],ue=(Q[9]-1)/Q[5],H=(Q[8]-1)/Q[0],Ie=(ee[8]+1)/ee[0],Te=he*H,Oe=he*Ie,Re=W/(-H+Ie),We=Re*-H;if(w.matrixWorld.decompose(V.position,V.quaternion,V.scale),V.translateX(We),V.translateZ(Re),V.matrixWorld.compose(V.position,V.quaternion,V.scale),V.matrixWorldInverse.copy(V.matrixWorld).invert(),Q[10]===-1)V.projectionMatrix.copy(w.projectionMatrix),V.projectionMatrixInverse.copy(w.projectionMatrixInverse);else{let Ae=he+Re,Y=Ce+Re,F=Te-We,D=Oe+(W-We),P=oe*Ce/Y*Ae,U=ue*Ce/Y*Ae;V.projectionMatrix.makePerspective(F,D,P,U,Ae,Y),V.projectionMatrixInverse.copy(V.projectionMatrix).invert()}}function J(V,w){w===null?V.matrixWorld.copy(V.matrix):V.matrixWorld.multiplyMatrices(w.matrixWorld,V.matrix),V.matrixWorldInverse.copy(V.matrixWorld).invert()}this.updateCamera=function(V){if(r===null)return;let w=V.near,O=V.far;x.texture!==null&&(x.depthNear>0&&(w=x.depthNear),x.depthFar>0&&(O=x.depthFar)),S.near=T.near=A.near=w,S.far=T.far=A.far=O,(C!==S.near||N!==S.far)&&(r.updateRenderState({depthNear:S.near,depthFar:S.far}),C=S.near,N=S.far),A.layers.mask=V.layers.mask|2,T.layers.mask=V.layers.mask|4,S.layers.mask=A.layers.mask|T.layers.mask;let W=V.parent,Q=S.cameras;J(S,W);for(let ee=0;ee<Q.length;ee++)J(Q[ee],W);Q.length===2?j(S,A,T):S.projectionMatrix.copy(A.projectionMatrix),se(V,S,W)};function se(V,w,O){O===null?V.matrix.copy(w.matrixWorld):(V.matrix.copy(O.matrixWorld),V.matrix.invert(),V.matrix.multiply(w.matrixWorld)),V.matrix.decompose(V.position,V.quaternion,V.scale),V.updateMatrixWorld(!0),V.projectionMatrix.copy(w.projectionMatrix),V.projectionMatrixInverse.copy(w.projectionMatrixInverse),V.isPerspectiveCamera&&(V.fov=Co*2*Math.atan(1/V.projectionMatrix.elements[5]),V.zoom=1)}this.getCamera=function(){return S},this.getFoveation=function(){if(!(d===null&&m===null))return c},this.setFoveation=function(V){c=V,d!==null&&(d.fixedFoveation=V),m!==null&&m.fixedFoveation!==void 0&&(m.fixedFoveation=V)},this.hasDepthSensing=function(){return x.texture!==null},this.getDepthSensingMesh=function(){return x.getMesh(S)};let ce=null;function me(V,w){if(u=w.getViewerPose(l||o),g=w,u!==null){let O=u.views;m!==null&&(e.setRenderTargetFramebuffer(v,m.framebuffer),e.setRenderTarget(v));let W=!1;O.length!==S.cameras.length&&(S.cameras.length=0,W=!0);for(let ee=0;ee<O.length;ee++){let he=O[ee],Ce=null;if(m!==null)Ce=m.getViewport(he);else{let ue=h.getViewSubImage(d,he);Ce=ue.viewport,ee===0&&(e.setRenderTargetTextures(v,ue.colorTexture,d.ignoreDepthValues?void 0:ue.depthStencilTexture),e.setRenderTarget(v))}let oe=M[ee];oe===void 0&&(oe=new jt,oe.layers.enable(ee),oe.viewport=new It,M[ee]=oe),oe.matrix.fromArray(he.transform.matrix),oe.matrix.decompose(oe.position,oe.quaternion,oe.scale),oe.projectionMatrix.fromArray(he.projectionMatrix),oe.projectionMatrixInverse.copy(oe.projectionMatrix).invert(),oe.viewport.set(Ce.x,Ce.y,Ce.width,Ce.height),ee===0&&(S.matrix.copy(oe.matrix),S.matrix.decompose(S.position,S.quaternion,S.scale)),W===!0&&S.cameras.push(oe)}let Q=r.enabledFeatures;if(Q&&Q.includes("depth-sensing")){let ee=h.getDepthInformation(O[0]);ee&&ee.isValid&&ee.texture&&x.init(e,ee,r.renderState)}}for(let O=0;O<_.length;O++){let W=y[O],Q=_[O];W!==null&&Q!==void 0&&Q.update(W,w,l||o)}ce&&ce(V,w),w.detectedPlanes&&n.dispatchEvent({type:"planesdetected",data:w}),g=null}let Se=new Lb;Se.setAnimationLoop(me),this.setAnimationLoop=function(V){ce=V},this.dispose=function(){}}},ea=new yi,MC=new nt;function EC(i,e){function t(f,p){f.matrixAutoUpdate===!0&&f.updateMatrix(),p.value.copy(f.matrix)}function n(f,p){p.color.getRGB(f.fogColor.value,A0(i)),p.isFog?(f.fogNear.value=p.near,f.fogFar.value=p.far):p.isFogExp2&&(f.fogDensity.value=p.density)}function r(f,p,v,_,y){p.isMeshBasicMaterial||p.isMeshLambertMaterial?s(f,p):p.isMeshToonMaterial?(s(f,p),h(f,p)):p.isMeshPhongMaterial?(s(f,p),u(f,p)):p.isMeshStandardMaterial?(s(f,p),d(f,p),p.isMeshPhysicalMaterial&&m(f,p,y)):p.isMeshMatcapMaterial?(s(f,p),g(f,p)):p.isMeshDepthMaterial?s(f,p):p.isMeshDistanceMaterial?(s(f,p),x(f,p)):p.isMeshNormalMaterial?s(f,p):p.isLineBasicMaterial?(o(f,p),p.isLineDashedMaterial&&a(f,p)):p.isPointsMaterial?c(f,p,v,_):p.isSpriteMaterial?l(f,p):p.isShadowMaterial?(f.color.value.copy(p.color),f.opacity.value=p.opacity):p.isShaderMaterial&&(p.uniformsNeedUpdate=!1)}function s(f,p){f.opacity.value=p.opacity,p.color&&f.diffuse.value.copy(p.color),p.emissive&&f.emissive.value.copy(p.emissive).multiplyScalar(p.emissiveIntensity),p.map&&(f.map.value=p.map,t(p.map,f.mapTransform)),p.alphaMap&&(f.alphaMap.value=p.alphaMap,t(p.alphaMap,f.alphaMapTransform)),p.bumpMap&&(f.bumpMap.value=p.bumpMap,t(p.bumpMap,f.bumpMapTransform),f.bumpScale.value=p.bumpScale,p.side===un&&(f.bumpScale.value*=-1)),p.normalMap&&(f.normalMap.value=p.normalMap,t(p.normalMap,f.normalMapTransform),f.normalScale.value.copy(p.normalScale),p.side===un&&f.normalScale.value.negate()),p.displacementMap&&(f.displacementMap.value=p.displacementMap,t(p.displacementMap,f.displacementMapTransform),f.displacementScale.value=p.displacementScale,f.displacementBias.value=p.displacementBias),p.emissiveMap&&(f.emissiveMap.value=p.emissiveMap,t(p.emissiveMap,f.emissiveMapTransform)),p.specularMap&&(f.specularMap.value=p.specularMap,t(p.specularMap,f.specularMapTransform)),p.alphaTest>0&&(f.alphaTest.value=p.alphaTest);let v=e.get(p),_=v.envMap,y=v.envMapRotation;_&&(f.envMap.value=_,ea.copy(y),ea.x*=-1,ea.y*=-1,ea.z*=-1,_.isCubeTexture&&_.isRenderTargetTexture===!1&&(ea.y*=-1,ea.z*=-1),f.envMapRotation.value.setFromMatrix4(MC.makeRotationFromEuler(ea)),f.flipEnvMap.value=_.isCubeTexture&&_.isRenderTargetTexture===!1?-1:1,f.reflectivity.value=p.reflectivity,f.ior.value=p.ior,f.refractionRatio.value=p.refractionRatio),p.lightMap&&(f.lightMap.value=p.lightMap,f.lightMapIntensity.value=p.lightMapIntensity,t(p.lightMap,f.lightMapTransform)),p.aoMap&&(f.aoMap.value=p.aoMap,f.aoMapIntensity.value=p.aoMapIntensity,t(p.aoMap,f.aoMapTransform))}function o(f,p){f.diffuse.value.copy(p.color),f.opacity.value=p.opacity,p.map&&(f.map.value=p.map,t(p.map,f.mapTransform))}function a(f,p){f.dashSize.value=p.dashSize,f.totalSize.value=p.dashSize+p.gapSize,f.scale.value=p.scale}function c(f,p,v,_){f.diffuse.value.copy(p.color),f.opacity.value=p.opacity,f.size.value=p.size*v,f.scale.value=_*.5,p.map&&(f.map.value=p.map,t(p.map,f.uvTransform)),p.alphaMap&&(f.alphaMap.value=p.alphaMap,t(p.alphaMap,f.alphaMapTransform)),p.alphaTest>0&&(f.alphaTest.value=p.alphaTest)}function l(f,p){f.diffuse.value.copy(p.color),f.opacity.value=p.opacity,f.rotation.value=p.rotation,p.map&&(f.map.value=p.map,t(p.map,f.mapTransform)),p.alphaMap&&(f.alphaMap.value=p.alphaMap,t(p.alphaMap,f.alphaMapTransform)),p.alphaTest>0&&(f.alphaTest.value=p.alphaTest)}function u(f,p){f.specular.value.copy(p.specular),f.shininess.value=Math.max(p.shininess,1e-4)}function h(f,p){p.gradientMap&&(f.gradientMap.value=p.gradientMap)}function d(f,p){f.metalness.value=p.metalness,p.metalnessMap&&(f.metalnessMap.value=p.metalnessMap,t(p.metalnessMap,f.metalnessMapTransform)),f.roughness.value=p.roughness,p.roughnessMap&&(f.roughnessMap.value=p.roughnessMap,t(p.roughnessMap,f.roughnessMapTransform)),p.envMap&&(f.envMapIntensity.value=p.envMapIntensity)}function m(f,p,v){f.ior.value=p.ior,p.sheen>0&&(f.sheenColor.value.copy(p.sheenColor).multiplyScalar(p.sheen),f.sheenRoughness.value=p.sheenRoughness,p.sheenColorMap&&(f.sheenColorMap.value=p.sheenColorMap,t(p.sheenColorMap,f.sheenColorMapTransform)),p.sheenRoughnessMap&&(f.sheenRoughnessMap.value=p.sheenRoughnessMap,t(p.sheenRoughnessMap,f.sheenRoughnessMapTransform))),p.clearcoat>0&&(f.clearcoat.value=p.clearcoat,f.clearcoatRoughness.value=p.clearcoatRoughness,p.clearcoatMap&&(f.clearcoatMap.value=p.clearcoatMap,t(p.clearcoatMap,f.clearcoatMapTransform)),p.clearcoatRoughnessMap&&(f.clearcoatRoughnessMap.value=p.clearcoatRoughnessMap,t(p.clearcoatRoughnessMap,f.clearcoatRoughnessMapTransform)),p.clearcoatNormalMap&&(f.clearcoatNormalMap.value=p.clearcoatNormalMap,t(p.clearcoatNormalMap,f.clearcoatNormalMapTransform),f.clearcoatNormalScale.value.copy(p.clearcoatNormalScale),p.side===un&&f.clearcoatNormalScale.value.negate())),p.dispersion>0&&(f.dispersion.value=p.dispersion),p.iridescence>0&&(f.iridescence.value=p.iridescence,f.iridescenceIOR.value=p.iridescenceIOR,f.iridescenceThicknessMinimum.value=p.iridescenceThicknessRange[0],f.iridescenceThicknessMaximum.value=p.iridescenceThicknessRange[1],p.iridescenceMap&&(f.iridescenceMap.value=p.iridescenceMap,t(p.iridescenceMap,f.iridescenceMapTransform)),p.iridescenceThicknessMap&&(f.iridescenceThicknessMap.value=p.iridescenceThicknessMap,t(p.iridescenceThicknessMap,f.iridescenceThicknessMapTransform))),p.transmission>0&&(f.transmission.value=p.transmission,f.transmissionSamplerMap.value=v.texture,f.transmissionSamplerSize.value.set(v.width,v.height),p.transmissionMap&&(f.transmissionMap.value=p.transmissionMap,t(p.transmissionMap,f.transmissionMapTransform)),f.thickness.value=p.thickness,p.thicknessMap&&(f.thicknessMap.value=p.thicknessMap,t(p.thicknessMap,f.thicknessMapTransform)),f.attenuationDistance.value=p.attenuationDistance,f.attenuationColor.value.copy(p.attenuationColor)),p.anisotropy>0&&(f.anisotropyVector.value.set(p.anisotropy*Math.cos(p.anisotropyRotation),p.anisotropy*Math.sin(p.anisotropyRotation)),p.anisotropyMap&&(f.anisotropyMap.value=p.anisotropyMap,t(p.anisotropyMap,f.anisotropyMapTransform))),f.specularIntensity.value=p.specularIntensity,f.specularColor.value.copy(p.specularColor),p.specularColorMap&&(f.specularColorMap.value=p.specularColorMap,t(p.specularColorMap,f.specularColorMapTransform)),p.specularIntensityMap&&(f.specularIntensityMap.value=p.specularIntensityMap,t(p.specularIntensityMap,f.specularIntensityMapTransform))}function g(f,p){p.matcap&&(f.matcap.value=p.matcap)}function x(f,p){let v=e.get(p).light;f.referencePosition.value.setFromMatrixPosition(v.matrixWorld),f.nearDistance.value=v.shadow.camera.near,f.farDistance.value=v.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:r}}function SC(i,e,t,n){let r={},s={},o=[],a=i.getParameter(i.MAX_UNIFORM_BUFFER_BINDINGS);function c(v,_){let y=_.program;n.uniformBlockBinding(v,y)}function l(v,_){let y=r[v.id];y===void 0&&(g(v),y=u(v),r[v.id]=y,v.addEventListener("dispose",f));let b=_.program;n.updateUBOMapping(v,b);let E=e.render.frame;s[v.id]!==E&&(d(v),s[v.id]=E)}function u(v){let _=h();v.__bindingPointIndex=_;let y=i.createBuffer(),b=v.__size,E=v.usage;return i.bindBuffer(i.UNIFORM_BUFFER,y),i.bufferData(i.UNIFORM_BUFFER,b,E),i.bindBuffer(i.UNIFORM_BUFFER,null),i.bindBufferBase(i.UNIFORM_BUFFER,_,y),y}function h(){for(let v=0;v<a;v++)if(o.indexOf(v)===-1)return o.push(v),v;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function d(v){let _=r[v.id],y=v.uniforms,b=v.__cache;i.bindBuffer(i.UNIFORM_BUFFER,_);for(let E=0,A=y.length;E<A;E++){let T=Array.isArray(y[E])?y[E]:[y[E]];for(let M=0,S=T.length;M<S;M++){let C=T[M];if(m(C,E,M,b)===!0){let N=C.__offset,I=Array.isArray(C.value)?C.value:[C.value],L=0;for(let q=0;q<I.length;q++){let K=I[q],B=x(K);typeof K=="number"||typeof K=="boolean"?(C.__data[0]=K,i.bufferSubData(i.UNIFORM_BUFFER,N+L,C.__data)):K.isMatrix3?(C.__data[0]=K.elements[0],C.__data[1]=K.elements[1],C.__data[2]=K.elements[2],C.__data[3]=0,C.__data[4]=K.elements[3],C.__data[5]=K.elements[4],C.__data[6]=K.elements[5],C.__data[7]=0,C.__data[8]=K.elements[6],C.__data[9]=K.elements[7],C.__data[10]=K.elements[8],C.__data[11]=0):(K.toArray(C.__data,L),L+=B.storage/Float32Array.BYTES_PER_ELEMENT)}i.bufferSubData(i.UNIFORM_BUFFER,N,C.__data)}}}i.bindBuffer(i.UNIFORM_BUFFER,null)}function m(v,_,y,b){let E=v.value,A=_+"_"+y;if(b[A]===void 0)return typeof E=="number"||typeof E=="boolean"?b[A]=E:b[A]=E.clone(),!0;{let T=b[A];if(typeof E=="number"||typeof E=="boolean"){if(T!==E)return b[A]=E,!0}else if(T.equals(E)===!1)return T.copy(E),!0}return!1}function g(v){let _=v.uniforms,y=0,b=16;for(let A=0,T=_.length;A<T;A++){let M=Array.isArray(_[A])?_[A]:[_[A]];for(let S=0,C=M.length;S<C;S++){let N=M[S],I=Array.isArray(N.value)?N.value:[N.value];for(let L=0,q=I.length;L<q;L++){let K=I[L],B=x(K),j=y%b,J=j%B.boundary,se=j+J;y+=J,se!==0&&b-se<B.storage&&(y+=b-se),N.__data=new Float32Array(B.storage/Float32Array.BYTES_PER_ELEMENT),N.__offset=y,y+=B.storage}}}let E=y%b;return E>0&&(y+=b-E),v.__size=y,v.__cache={},this}function x(v){let _={boundary:0,storage:0};return typeof v=="number"||typeof v=="boolean"?(_.boundary=4,_.storage=4):v.isVector2?(_.boundary=8,_.storage=8):v.isVector3||v.isColor?(_.boundary=16,_.storage=12):v.isVector4?(_.boundary=16,_.storage=16):v.isMatrix3?(_.boundary=48,_.storage=48):v.isMatrix4?(_.boundary=64,_.storage=64):v.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",v),_}function f(v){let _=v.target;_.removeEventListener("dispose",f);let y=o.indexOf(_.__bindingPointIndex);o.splice(y,1),i.deleteBuffer(r[_.id]),delete r[_.id],delete s[_.id]}function p(){for(let v in r)i.deleteBuffer(r[v]);o=[],r={},s={}}return{bind:c,update:l,dispose:p}}var fs=class{constructor(e={}){let{canvas:t=T0(),context:n=null,depth:r=!0,stencil:s=!1,alpha:o=!1,antialias:a=!1,premultipliedAlpha:c=!0,preserveDrawingBuffer:l=!1,powerPreference:u="default",failIfMajorPerformanceCaveat:h=!1,reverseDepthBuffer:d=!1}=e;this.isWebGLRenderer=!0;let m;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");m=n.getContextAttributes().alpha}else m=o;let g=new Uint32Array(4),x=new Int32Array(4),f=null,p=null,v=[],_=[];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._outputColorSpace=wt,this.toneMapping=Ir,this.toneMappingExposure=1;let y=this,b=!1,E=0,A=0,T=null,M=-1,S=null,C=new It,N=new It,I=null,L=new Ue(0),q=0,K=t.width,B=t.height,j=1,J=null,se=null,ce=new It(0,0,K,B),me=new It(0,0,K,B),Se=!1,V=new Ws,w=!1,O=!1,W=new nt,Q=new nt,ee=new z,he=new It,Ce={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0},oe=!1;function ue(){return T===null?j:1}let H=n;function Ie(G,le){return t.getContext(G,le)}try{let G={alpha:!0,depth:r,stencil:s,antialias:a,premultipliedAlpha:c,preserveDrawingBuffer:l,powerPreference:u,failIfMajorPerformanceCaveat:h};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${"171"}`),t.addEventListener("webglcontextlost",fe,!1),t.addEventListener("webglcontextrestored",Be,!1),t.addEventListener("webglcontextcreationerror",De,!1),H===null){let le="webgl2";if(H=Ie(le,G),H===null)throw Ie(le)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(G){throw console.error("THREE.WebGLRenderer: "+G.message),G}let Te,Oe,Re,We,Ae,Y,F,D,P,U,X,Z,$,te,ae,re,ge,xe,Ne,ke,$e,Le,Xe,ne;function Pe(){Te=new H1(H),Te.init(),Le=new kb(H,Te),Oe=new F1(H,Te,e,Le),Re=new xC(H,Te),Oe.reverseDepthBuffer&&d&&Re.buffers.depth.setReversed(!0),We=new X1(H),Ae=new rC,Y=new yC(H,Te,Re,Ae,Oe,Le,We),F=new k1(y),D=new V1(y),P=new QT(H),Xe=new O1(H,P),U=new G1(H,P,We,Xe),X=new j1(H,U,P,We),Ne=new Y1(H,Oe,Y),re=new U1(Ae),Z=new iC(y,F,D,Te,Oe,Xe,re),$=new EC(y,Ae),te=new oC,ae=new dC(Te),xe=new L1(y,F,D,Re,X,m,c),ge=new mC(y,X,Oe),ne=new SC(H,We,Oe,Re),ke=new D1(H,Te,We),$e=new W1(H,Te,We),We.programs=Z.programs,y.capabilities=Oe,y.extensions=Te,y.properties=Ae,y.renderLists=te,y.shadowMap=ge,y.state=Re,y.info=We}Pe();let pe=new X0(y,H);this.xr=pe,this.getContext=function(){return H},this.getContextAttributes=function(){return H.getContextAttributes()},this.forceContextLoss=function(){let G=Te.get("WEBGL_lose_context");G&&G.loseContext()},this.forceContextRestore=function(){let G=Te.get("WEBGL_lose_context");G&&G.restoreContext()},this.getPixelRatio=function(){return j},this.setPixelRatio=function(G){G!==void 0&&(j=G,this.setSize(K,B,!1))},this.getSize=function(G){return G.set(K,B)},this.setSize=function(G,le,_e=!0){if(pe.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}K=G,B=le,t.width=Math.floor(G*j),t.height=Math.floor(le*j),_e===!0&&(t.style.width=G+"px",t.style.height=le+"px"),this.setViewport(0,0,G,le)},this.getDrawingBufferSize=function(G){return G.set(K*j,B*j).floor()},this.setDrawingBufferSize=function(G,le,_e){K=G,B=le,j=_e,t.width=Math.floor(G*_e),t.height=Math.floor(le*_e),this.setViewport(0,0,G,le)},this.getCurrentViewport=function(G){return G.copy(C)},this.getViewport=function(G){return G.copy(ce)},this.setViewport=function(G,le,_e,be){G.isVector4?ce.set(G.x,G.y,G.z,G.w):ce.set(G,le,_e,be),Re.viewport(C.copy(ce).multiplyScalar(j).round())},this.getScissor=function(G){return G.copy(me)},this.setScissor=function(G,le,_e,be){G.isVector4?me.set(G.x,G.y,G.z,G.w):me.set(G,le,_e,be),Re.scissor(N.copy(me).multiplyScalar(j).round())},this.getScissorTest=function(){return Se},this.setScissorTest=function(G){Re.setScissorTest(Se=G)},this.setOpaqueSort=function(G){J=G},this.setTransparentSort=function(G){se=G},this.getClearColor=function(G){return G.copy(xe.getClearColor())},this.setClearColor=function(){xe.setClearColor.apply(xe,arguments)},this.getClearAlpha=function(){return xe.getClearAlpha()},this.setClearAlpha=function(){xe.setClearAlpha.apply(xe,arguments)},this.clear=function(G=!0,le=!0,_e=!0){let be=0;if(G){let de=!1;if(T!==null){let Ve=T.texture.format;de=Ve===Xu||Ve===Wu||Ve===Ec}if(de){let Ve=T.texture.type,Ke=Ve===ci||Ve===Lr||Ve===Ko||Ve===Or||Ve===Vu||Ve===Hu,it=xe.getClearColor(),qe=xe.getClearAlpha(),ft=it.r,Ye=it.g,ut=it.b;Ke?(g[0]=ft,g[1]=Ye,g[2]=ut,g[3]=qe,H.clearBufferuiv(H.COLOR,0,g)):(x[0]=ft,x[1]=Ye,x[2]=ut,x[3]=qe,H.clearBufferiv(H.COLOR,0,x))}else be|=H.COLOR_BUFFER_BIT}le&&(be|=H.DEPTH_BUFFER_BIT),_e&&(be|=H.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),H.clear(be)},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.dispose=function(){t.removeEventListener("webglcontextlost",fe,!1),t.removeEventListener("webglcontextrestored",Be,!1),t.removeEventListener("webglcontextcreationerror",De,!1),xe.dispose(),te.dispose(),ae.dispose(),Ae.dispose(),F.dispose(),D.dispose(),X.dispose(),Xe.dispose(),ne.dispose(),Z.dispose(),pe.dispose(),pe.removeEventListener("sessionstart",tt),pe.removeEventListener("sessionend",at),bt.stop()};function fe(G){G.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),b=!0}function Be(){console.log("THREE.WebGLRenderer: Context Restored."),b=!1;let G=We.autoReset,le=ge.enabled,_e=ge.autoUpdate,be=ge.needsUpdate,de=ge.type;Pe(),We.autoReset=G,ge.enabled=le,ge.autoUpdate=_e,ge.needsUpdate=be,ge.type=de}function De(G){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",G.statusMessage)}function st(G){let le=G.target;le.removeEventListener("dispose",st),pt(le)}function pt(G){lt(G),Ae.remove(G)}function lt(G){let le=Ae.get(G).programs;le!==void 0&&(le.forEach(function(_e){Z.releaseProgram(_e)}),G.isShaderMaterial&&Z.releaseShaderCache(G))}this.renderBufferDirect=function(G,le,_e,be,de,Ve){le===null&&(le=Ce);let Ke=de.isMesh&&de.matrixWorld.determinant()<0,it=to(G,le,_e,be,de);Re.setMaterial(be,Ke);let qe=_e.index,ft=1;if(be.wireframe===!0){if(qe=U.getWireframeAttribute(_e),qe===void 0)return;ft=2}let Ye=_e.drawRange,ut=_e.attributes.position,Nt=Ye.start*ft,At=(Ye.start+Ye.count)*ft;Ve!==null&&(Nt=Math.max(Nt,Ve.start*ft),At=Math.min(At,(Ve.start+Ve.count)*ft)),qe!==null?(Nt=Math.max(Nt,0),At=Math.min(At,qe.count)):ut!=null&&(Nt=Math.max(Nt,0),At=Math.min(At,ut.count));let en=At-Nt;if(en<0||en===1/0)return;Xe.setup(de,be,it,_e,qe);let yt,Ct=ke;if(qe!==null&&(yt=P.get(qe),Ct=$e,Ct.setIndex(yt)),de.isMesh)be.wireframe===!0?(Re.setLineWidth(be.wireframeLinewidth*ue()),Ct.setMode(H.LINES)):Ct.setMode(H.TRIANGLES);else if(de.isLine){let ht=be.linewidth;ht===void 0&&(ht=1),Re.setLineWidth(ht*ue()),de.isLineSegments?Ct.setMode(H.LINES):de.isLineLoop?Ct.setMode(H.LINE_LOOP):Ct.setMode(H.LINE_STRIP)}else de.isPoints?Ct.setMode(H.POINTS):de.isSprite&&Ct.setMode(H.TRIANGLES);if(de.isBatchedMesh)if(de._multiDrawInstances!==null)Ct.renderMultiDrawInstances(de._multiDrawStarts,de._multiDrawCounts,de._multiDrawCount,de._multiDrawInstances);else if(Te.get("WEBGL_multi_draw"))Ct.renderMultiDraw(de._multiDrawStarts,de._multiDrawCounts,de._multiDrawCount);else{let ht=de._multiDrawStarts,pn=de._multiDrawCounts,Ot=de._multiDrawCount,ti=qe?P.get(qe).bytesPerElement:1,Ai=Ae.get(be).currentProgram.getUniforms();for(let kn=0;kn<Ot;kn++)Ai.setValue(H,"_gl_DrawID",kn),Ct.render(ht[kn]/ti,pn[kn])}else if(de.isInstancedMesh)Ct.renderInstances(Nt,en,de.count);else if(_e.isInstancedBufferGeometry){let ht=_e._maxInstanceCount!==void 0?_e._maxInstanceCount:1/0,pn=Math.min(_e.instanceCount,ht);Ct.renderInstances(Nt,en,pn)}else Ct.render(Nt,en)};function Ge(G,le,_e){G.transparent===!0&&G.side===xn&&G.forceSinglePass===!1?(G.side=un,G.needsUpdate=!0,ui(G,le,_e),G.side=Jn,G.needsUpdate=!0,ui(G,le,_e),G.side=xn):ui(G,le,_e)}this.compile=function(G,le,_e=null){_e===null&&(_e=G),p=ae.get(_e),p.init(le),_.push(p),_e.traverseVisible(function(de){de.isLight&&de.layers.test(le.layers)&&(p.pushLight(de),de.castShadow&&p.pushShadow(de))}),G!==_e&&G.traverseVisible(function(de){de.isLight&&de.layers.test(le.layers)&&(p.pushLight(de),de.castShadow&&p.pushShadow(de))}),p.setupLights();let be=new Set;return G.traverse(function(de){if(!(de.isMesh||de.isPoints||de.isLine||de.isSprite))return;let Ve=de.material;if(Ve)if(Array.isArray(Ve))for(let Ke=0;Ke<Ve.length;Ke++){let it=Ve[Ke];Ge(it,_e,de),be.add(it)}else Ge(Ve,_e,de),be.add(Ve)}),_.pop(),p=null,be},this.compileAsync=function(G,le,_e=null){let be=this.compile(G,le,_e);return new Promise(de=>{function Ve(){if(be.forEach(function(Ke){Ae.get(Ke).currentProgram.isReady()&&be.delete(Ke)}),be.size===0){de(G);return}setTimeout(Ve,10)}Te.get("KHR_parallel_shader_compile")!==null?Ve():setTimeout(Ve,10)})};let Je=null;function we(G){Je&&Je(G)}function tt(){bt.stop()}function at(){bt.start()}let bt=new Lb;bt.setAnimationLoop(we),typeof self<"u"&&bt.setContext(self),this.setAnimationLoop=function(G){Je=G,pe.setAnimationLoop(G),G===null?bt.stop():bt.start()},pe.addEventListener("sessionstart",tt),pe.addEventListener("sessionend",at),this.render=function(G,le){if(le!==void 0&&le.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(b===!0)return;if(G.matrixWorldAutoUpdate===!0&&G.updateMatrixWorld(),le.parent===null&&le.matrixWorldAutoUpdate===!0&&le.updateMatrixWorld(),pe.enabled===!0&&pe.isPresenting===!0&&(pe.cameraAutoUpdate===!0&&pe.updateCamera(le),le=pe.getCamera()),G.isScene===!0&&G.onBeforeRender(y,G,le,T),p=ae.get(G,_.length),p.init(le),_.push(p),Q.multiplyMatrices(le.projectionMatrix,le.matrixWorldInverse),V.setFromProjectionMatrix(Q),O=this.localClippingEnabled,w=re.init(this.clippingPlanes,O),f=te.get(G,v.length),f.init(),v.push(f),pe.enabled===!0&&pe.isPresenting===!0){let Ve=y.xr.getDepthSensingMesh();Ve!==null&&Xn(Ve,le,-1/0,y.sortObjects)}Xn(G,le,0,y.sortObjects),f.finish(),y.sortObjects===!0&&f.sort(J,se),oe=pe.enabled===!1||pe.isPresenting===!1||pe.hasDepthSensing()===!1,oe&&xe.addToRenderList(f,G),this.info.render.frame++,w===!0&&re.beginShadows();let _e=p.state.shadowsArray;ge.render(_e,G,le),w===!0&&re.endShadows(),this.info.autoReset===!0&&this.info.reset();let be=f.opaque,de=f.transmissive;if(p.setupLights(),le.isArrayCamera){let Ve=le.cameras;if(de.length>0)for(let Ke=0,it=Ve.length;Ke<it;Ke++){let qe=Ve[Ke];mr(be,de,G,qe)}oe&&xe.render(G);for(let Ke=0,it=Ve.length;Ke<it;Ke++){let qe=Ve[Ke];ei(f,G,qe,qe.viewport)}}else de.length>0&&mr(be,de,G,le),oe&&xe.render(G),ei(f,G,le);T!==null&&(Y.updateMultisampleRenderTarget(T),Y.updateRenderTargetMipmap(T)),G.isScene===!0&&G.onAfterRender(y,G,le),Xe.resetDefaultState(),M=-1,S=null,_.pop(),_.length>0?(p=_[_.length-1],w===!0&&re.setGlobalState(y.clippingPlanes,p.state.camera)):p=null,v.pop(),v.length>0?f=v[v.length-1]:f=null};function Xn(G,le,_e,be){if(G.visible===!1)return;if(G.layers.test(le.layers)){if(G.isGroup)_e=G.renderOrder;else if(G.isLOD)G.autoUpdate===!0&&G.update(le);else if(G.isLight)p.pushLight(G),G.castShadow&&p.pushShadow(G);else if(G.isSprite){if(!G.frustumCulled||V.intersectsSprite(G)){be&&he.setFromMatrixPosition(G.matrixWorld).applyMatrix4(Q);let Ke=X.update(G),it=G.material;it.visible&&f.push(G,Ke,it,_e,he.z,null)}}else if((G.isMesh||G.isLine||G.isPoints)&&(!G.frustumCulled||V.intersectsObject(G))){let Ke=X.update(G),it=G.material;if(be&&(G.boundingSphere!==void 0?(G.boundingSphere===null&&G.computeBoundingSphere(),he.copy(G.boundingSphere.center)):(Ke.boundingSphere===null&&Ke.computeBoundingSphere(),he.copy(Ke.boundingSphere.center)),he.applyMatrix4(G.matrixWorld).applyMatrix4(Q)),Array.isArray(it)){let qe=Ke.groups;for(let ft=0,Ye=qe.length;ft<Ye;ft++){let ut=qe[ft],Nt=it[ut.materialIndex];Nt&&Nt.visible&&f.push(G,Ke,Nt,_e,he.z,ut)}}else it.visible&&f.push(G,Ke,it,_e,he.z,null)}}let Ve=G.children;for(let Ke=0,it=Ve.length;Ke<it;Ke++)Xn(Ve[Ke],le,_e,be)}function ei(G,le,_e,be){let de=G.opaque,Ve=G.transmissive,Ke=G.transparent;p.setupLightsView(_e),w===!0&&re.setGlobalState(y.clippingPlanes,_e),be&&Re.viewport(C.copy(be)),de.length>0&&Ti(de,le,_e),Ve.length>0&&Ti(Ve,le,_e),Ke.length>0&&Ti(Ke,le,_e),Re.buffers.depth.setTest(!0),Re.buffers.depth.setMask(!0),Re.buffers.color.setMask(!0),Re.setPolygonOffset(!1)}function mr(G,le,_e,be){if((_e.isScene===!0?_e.overrideMaterial:null)!==null)return;p.state.transmissionRenderTarget[be.id]===void 0&&(p.state.transmissionRenderTarget[be.id]=new on(1,1,{generateMipmaps:!0,type:Te.has("EXT_color_buffer_half_float")||Te.has("EXT_color_buffer_float")?Hn:ci,minFilter:Ei,samples:4,stencilBuffer:s,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:_t.workingColorSpace}));let Ve=p.state.transmissionRenderTarget[be.id],Ke=be.viewport||C;Ve.setSize(Ke.z,Ke.w);let it=y.getRenderTarget();y.setRenderTarget(Ve),y.getClearColor(L),q=y.getClearAlpha(),q<1&&y.setClearColor(16777215,.5),y.clear(),oe&&xe.render(_e);let qe=y.toneMapping;y.toneMapping=Ir;let ft=be.viewport;if(be.viewport!==void 0&&(be.viewport=void 0),p.setupLightsView(be),w===!0&&re.setGlobalState(y.clippingPlanes,be),Ti(G,_e,be),Y.updateMultisampleRenderTarget(Ve),Y.updateRenderTargetMipmap(Ve),Te.has("WEBGL_multisampled_render_to_texture")===!1){let Ye=!1;for(let ut=0,Nt=le.length;ut<Nt;ut++){let At=le[ut],en=At.object,yt=At.geometry,Ct=At.material,ht=At.group;if(Ct.side===xn&&en.layers.test(be.layers)){let pn=Ct.side;Ct.side=un,Ct.needsUpdate=!0,Fn(en,_e,be,yt,Ct,ht),Ct.side=pn,Ct.needsUpdate=!0,Ye=!0}}Ye===!0&&(Y.updateMultisampleRenderTarget(Ve),Y.updateRenderTargetMipmap(Ve))}y.setRenderTarget(it),y.setClearColor(L,q),ft!==void 0&&(be.viewport=ft),y.toneMapping=qe}function Ti(G,le,_e){let be=le.isScene===!0?le.overrideMaterial:null;for(let de=0,Ve=G.length;de<Ve;de++){let Ke=G[de],it=Ke.object,qe=Ke.geometry,ft=be===null?Ke.material:be,Ye=Ke.group;it.layers.test(_e.layers)&&Fn(it,le,_e,qe,ft,Ye)}}function Fn(G,le,_e,be,de,Ve){G.onBeforeRender(y,le,_e,be,de,Ve),G.modelViewMatrix.multiplyMatrices(_e.matrixWorldInverse,G.matrixWorld),G.normalMatrix.getNormalMatrix(G.modelViewMatrix),de.onBeforeRender(y,le,_e,be,G,Ve),de.transparent===!0&&de.side===xn&&de.forceSinglePass===!1?(de.side=un,de.needsUpdate=!0,y.renderBufferDirect(_e,le,be,de,G,Ve),de.side=Jn,de.needsUpdate=!0,y.renderBufferDirect(_e,le,be,de,G,Ve),de.side=xn):y.renderBufferDirect(_e,le,be,de,G,Ve),G.onAfterRender(y,le,_e,be,de,Ve)}function ui(G,le,_e){le.isScene!==!0&&(le=Ce);let be=Ae.get(G),de=p.state.lights,Ve=p.state.shadowsArray,Ke=de.state.version,it=Z.getParameters(G,de.state,Ve,le,_e),qe=Z.getProgramCacheKey(it),ft=be.programs;be.environment=G.isMeshStandardMaterial?le.environment:null,be.fog=le.fog,be.envMap=(G.isMeshStandardMaterial?D:F).get(G.envMap||be.environment),be.envMapRotation=be.environment!==null&&G.envMap===null?le.environmentRotation:G.envMapRotation,ft===void 0&&(G.addEventListener("dispose",st),ft=new Map,be.programs=ft);let Ye=ft.get(qe);if(Ye!==void 0){if(be.currentProgram===Ye&&be.lightsStateVersion===Ke)return Un(G,it),Ye}else it.uniforms=Z.getUniforms(G),G.onBeforeCompile(it,y),Ye=Z.acquireProgram(it,qe),ft.set(qe,Ye),be.uniforms=it.uniforms;let ut=be.uniforms;return(!G.isShaderMaterial&&!G.isRawShaderMaterial||G.clipping===!0)&&(ut.clippingPlanes=re.uniform),Un(G,it),be.needsLights=$h(G),be.lightsStateVersion=Ke,be.needsLights&&(ut.ambientLightColor.value=de.state.ambient,ut.lightProbe.value=de.state.probe,ut.directionalLights.value=de.state.directional,ut.directionalLightShadows.value=de.state.directionalShadow,ut.spotLights.value=de.state.spot,ut.spotLightShadows.value=de.state.spotShadow,ut.rectAreaLights.value=de.state.rectArea,ut.ltc_1.value=de.state.rectAreaLTC1,ut.ltc_2.value=de.state.rectAreaLTC2,ut.pointLights.value=de.state.point,ut.pointLightShadows.value=de.state.pointShadow,ut.hemisphereLights.value=de.state.hemi,ut.directionalShadowMap.value=de.state.directionalShadowMap,ut.directionalShadowMatrix.value=de.state.directionalShadowMatrix,ut.spotShadowMap.value=de.state.spotShadowMap,ut.spotLightMatrix.value=de.state.spotLightMatrix,ut.spotLightMap.value=de.state.spotLightMap,ut.pointShadowMap.value=de.state.pointShadowMap,ut.pointShadowMatrix.value=de.state.pointShadowMatrix),be.currentProgram=Ye,be.uniformsList=null,Ye}function dn(G){if(G.uniformsList===null){let le=G.currentProgram.getUniforms();G.uniformsList=Nc.seqWithValue(le.seq,G.uniforms)}return G.uniformsList}function Un(G,le){let _e=Ae.get(G);_e.outputColorSpace=le.outputColorSpace,_e.batching=le.batching,_e.batchingColor=le.batchingColor,_e.instancing=le.instancing,_e.instancingColor=le.instancingColor,_e.instancingMorph=le.instancingMorph,_e.skinning=le.skinning,_e.morphTargets=le.morphTargets,_e.morphNormals=le.morphNormals,_e.morphColors=le.morphColors,_e.morphTargetsCount=le.morphTargetsCount,_e.numClippingPlanes=le.numClippingPlanes,_e.numIntersection=le.numClipIntersection,_e.vertexAlphas=le.vertexAlphas,_e.vertexTangents=le.vertexTangents,_e.toneMapping=le.toneMapping}function to(G,le,_e,be,de){le.isScene!==!0&&(le=Ce),Y.resetTextureUnits();let Ve=le.fog,Ke=be.isMeshStandardMaterial?le.environment:null,it=T===null?y.outputColorSpace:T.isXRRenderTarget===!0?T.texture.colorSpace:On,qe=(be.isMeshStandardMaterial?D:F).get(be.envMap||Ke),ft=be.vertexColors===!0&&!!_e.attributes.color&&_e.attributes.color.itemSize===4,Ye=!!_e.attributes.tangent&&(!!be.normalMap||be.anisotropy>0),ut=!!_e.morphAttributes.position,Nt=!!_e.morphAttributes.normal,At=!!_e.morphAttributes.color,en=Ir;be.toneMapped&&(T===null||T.isXRRenderTarget===!0)&&(en=y.toneMapping);let yt=_e.morphAttributes.position||_e.morphAttributes.normal||_e.morphAttributes.color,Ct=yt!==void 0?yt.length:0,ht=Ae.get(be),pn=p.state.lights;if(w===!0&&(O===!0||G!==S)){let Pn=G===S&&be.id===M;re.setState(be,G,Pn)}let Ot=!1;be.version===ht.__version?(ht.needsLights&&ht.lightsStateVersion!==pn.state.version||ht.outputColorSpace!==it||de.isBatchedMesh&&ht.batching===!1||!de.isBatchedMesh&&ht.batching===!0||de.isBatchedMesh&&ht.batchingColor===!0&&de.colorTexture===null||de.isBatchedMesh&&ht.batchingColor===!1&&de.colorTexture!==null||de.isInstancedMesh&&ht.instancing===!1||!de.isInstancedMesh&&ht.instancing===!0||de.isSkinnedMesh&&ht.skinning===!1||!de.isSkinnedMesh&&ht.skinning===!0||de.isInstancedMesh&&ht.instancingColor===!0&&de.instanceColor===null||de.isInstancedMesh&&ht.instancingColor===!1&&de.instanceColor!==null||de.isInstancedMesh&&ht.instancingMorph===!0&&de.morphTexture===null||de.isInstancedMesh&&ht.instancingMorph===!1&&de.morphTexture!==null||ht.envMap!==qe||be.fog===!0&&ht.fog!==Ve||ht.numClippingPlanes!==void 0&&(ht.numClippingPlanes!==re.numPlanes||ht.numIntersection!==re.numIntersection)||ht.vertexAlphas!==ft||ht.vertexTangents!==Ye||ht.morphTargets!==ut||ht.morphNormals!==Nt||ht.morphColors!==At||ht.toneMapping!==en||ht.morphTargetsCount!==Ct)&&(Ot=!0):(Ot=!0,ht.__version=be.version);let ti=ht.currentProgram;Ot===!0&&(ti=ui(be,le,de));let Ai=!1,kn=!1,Vi=!1,Bt=ti.getUniforms(),Yn=ht.uniforms;if(Re.useProgram(ti.program)&&(Ai=!0,kn=!0,Vi=!0),be.id!==M&&(M=be.id,kn=!0),Ai||S!==G){Re.buffers.depth.getReversed()?(W.copy(G.projectionMatrix),J_(W),Q_(W),Bt.setValue(H,"projectionMatrix",W)):Bt.setValue(H,"projectionMatrix",G.projectionMatrix),Bt.setValue(H,"viewMatrix",G.matrixWorldInverse);let Bn=Bt.map.cameraPosition;Bn!==void 0&&Bn.setValue(H,ee.setFromMatrixPosition(G.matrixWorld)),Oe.logarithmicDepthBuffer&&Bt.setValue(H,"logDepthBufFC",2/(Math.log(G.far+1)/Math.LN2)),(be.isMeshPhongMaterial||be.isMeshToonMaterial||be.isMeshLambertMaterial||be.isMeshBasicMaterial||be.isMeshStandardMaterial||be.isShaderMaterial)&&Bt.setValue(H,"isOrthographic",G.isOrthographicCamera===!0),S!==G&&(S=G,kn=!0,Vi=!0)}if(de.isSkinnedMesh){Bt.setOptional(H,de,"bindMatrix"),Bt.setOptional(H,de,"bindMatrixInverse");let Pn=de.skeleton;Pn&&(Pn.boneTexture===null&&Pn.computeBoneTexture(),Bt.setValue(H,"boneTexture",Pn.boneTexture,Y))}de.isBatchedMesh&&(Bt.setOptional(H,de,"batchingTexture"),Bt.setValue(H,"batchingTexture",de._matricesTexture,Y),Bt.setOptional(H,de,"batchingIdTexture"),Bt.setValue(H,"batchingIdTexture",de._indirectTexture,Y),Bt.setOptional(H,de,"batchingColorTexture"),de._colorsTexture!==null&&Bt.setValue(H,"batchingColorTexture",de._colorsTexture,Y));let ni=_e.morphAttributes;if((ni.position!==void 0||ni.normal!==void 0||ni.color!==void 0)&&Ne.update(de,_e,ti),(kn||ht.receiveShadow!==de.receiveShadow)&&(ht.receiveShadow=de.receiveShadow,Bt.setValue(H,"receiveShadow",de.receiveShadow)),be.isMeshGouraudMaterial&&be.envMap!==null&&(Yn.envMap.value=qe,Yn.flipEnvMap.value=qe.isCubeTexture&&qe.isRenderTargetTexture===!1?-1:1),be.isMeshStandardMaterial&&be.envMap===null&&le.environment!==null&&(Yn.envMapIntensity.value=le.environmentIntensity),kn&&(Bt.setValue(H,"toneMappingExposure",y.toneMappingExposure),ht.needsLights&&kr(Yn,Vi),Ve&&be.fog===!0&&$.refreshFogUniforms(Yn,Ve),$.refreshMaterialUniforms(Yn,be,j,B,p.state.transmissionRenderTarget[G.id]),Nc.upload(H,dn(ht),Yn,Y)),be.isShaderMaterial&&be.uniformsNeedUpdate===!0&&(Nc.upload(H,dn(ht),Yn,Y),be.uniformsNeedUpdate=!1),be.isSpriteMaterial&&Bt.setValue(H,"center",de.center),Bt.setValue(H,"modelViewMatrix",de.modelViewMatrix),Bt.setValue(H,"normalMatrix",de.normalMatrix),Bt.setValue(H,"modelMatrix",de.matrixWorld),be.isShaderMaterial||be.isRawShaderMaterial){let Pn=be.uniformsGroups;for(let Bn=0,ms=Pn.length;Bn<ms;Bn++){let Br=Pn[Bn];ne.update(Br,ti),ne.bind(Br,ti)}}return ti}function kr(G,le){G.ambientLightColor.needsUpdate=le,G.lightProbe.needsUpdate=le,G.directionalLights.needsUpdate=le,G.directionalLightShadows.needsUpdate=le,G.pointLights.needsUpdate=le,G.pointLightShadows.needsUpdate=le,G.spotLights.needsUpdate=le,G.spotLightShadows.needsUpdate=le,G.rectAreaLights.needsUpdate=le,G.hemisphereLights.needsUpdate=le}function $h(G){return G.isMeshLambertMaterial||G.isMeshToonMaterial||G.isMeshPhongMaterial||G.isMeshStandardMaterial||G.isShadowMaterial||G.isShaderMaterial&&G.lights===!0}this.getActiveCubeFace=function(){return E},this.getActiveMipmapLevel=function(){return A},this.getRenderTarget=function(){return T},this.setRenderTargetTextures=function(G,le,_e){Ae.get(G.texture).__webglTexture=le,Ae.get(G.depthTexture).__webglTexture=_e;let be=Ae.get(G);be.__hasExternalTextures=!0,be.__autoAllocateDepthBuffer=_e===void 0,be.__autoAllocateDepthBuffer||Te.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),be.__useRenderToTexture=!1)},this.setRenderTargetFramebuffer=function(G,le){let _e=Ae.get(G);_e.__webglFramebuffer=le,_e.__useDefaultFramebuffer=le===void 0},this.setRenderTarget=function(G,le=0,_e=0){T=G,E=le,A=_e;let be=!0,de=null,Ve=!1,Ke=!1;if(G){let qe=Ae.get(G);if(qe.__useDefaultFramebuffer!==void 0)Re.bindFramebuffer(H.FRAMEBUFFER,null),be=!1;else if(qe.__webglFramebuffer===void 0)Y.setupRenderTarget(G);else if(qe.__hasExternalTextures)Y.rebindTextures(G,Ae.get(G.texture).__webglTexture,Ae.get(G.depthTexture).__webglTexture);else if(G.depthBuffer){let ut=G.depthTexture;if(qe.__boundDepthTexture!==ut){if(ut!==null&&Ae.has(ut)&&(G.width!==ut.image.width||G.height!==ut.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");Y.setupDepthRenderbuffer(G)}}let ft=G.texture;(ft.isData3DTexture||ft.isDataArrayTexture||ft.isCompressedArrayTexture)&&(Ke=!0);let Ye=Ae.get(G).__webglFramebuffer;G.isWebGLCubeRenderTarget?(Array.isArray(Ye[le])?de=Ye[le][_e]:de=Ye[le],Ve=!0):G.samples>0&&Y.useMultisampledRTT(G)===!1?de=Ae.get(G).__webglMultisampledFramebuffer:Array.isArray(Ye)?de=Ye[_e]:de=Ye,C.copy(G.viewport),N.copy(G.scissor),I=G.scissorTest}else C.copy(ce).multiplyScalar(j).floor(),N.copy(me).multiplyScalar(j).floor(),I=Se;if(Re.bindFramebuffer(H.FRAMEBUFFER,de)&&be&&Re.drawBuffers(G,de),Re.viewport(C),Re.scissor(N),Re.setScissorTest(I),Ve){let qe=Ae.get(G.texture);H.framebufferTexture2D(H.FRAMEBUFFER,H.COLOR_ATTACHMENT0,H.TEXTURE_CUBE_MAP_POSITIVE_X+le,qe.__webglTexture,_e)}else if(Ke){let qe=Ae.get(G.texture),ft=le||0;H.framebufferTextureLayer(H.FRAMEBUFFER,H.COLOR_ATTACHMENT0,qe.__webglTexture,_e||0,ft)}M=-1},this.readRenderTargetPixels=function(G,le,_e,be,de,Ve,Ke){if(!(G&&G.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let it=Ae.get(G).__webglFramebuffer;if(G.isWebGLCubeRenderTarget&&Ke!==void 0&&(it=it[Ke]),it){Re.bindFramebuffer(H.FRAMEBUFFER,it);try{let qe=G.texture,ft=qe.format,Ye=qe.type;if(!Oe.textureFormatReadable(ft)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!Oe.textureTypeReadable(Ye)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}le>=0&&le<=G.width-be&&_e>=0&&_e<=G.height-de&&H.readPixels(le,_e,be,de,Le.convert(ft),Le.convert(Ye),Ve)}finally{let qe=T!==null?Ae.get(T).__webglFramebuffer:null;Re.bindFramebuffer(H.FRAMEBUFFER,qe)}}},this.readRenderTargetPixelsAsync=async function(G,le,_e,be,de,Ve,Ke){if(!(G&&G.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let it=Ae.get(G).__webglFramebuffer;if(G.isWebGLCubeRenderTarget&&Ke!==void 0&&(it=it[Ke]),it){let qe=G.texture,ft=qe.format,Ye=qe.type;if(!Oe.textureFormatReadable(ft))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!Oe.textureTypeReadable(Ye))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");if(le>=0&&le<=G.width-be&&_e>=0&&_e<=G.height-de){Re.bindFramebuffer(H.FRAMEBUFFER,it);let ut=H.createBuffer();H.bindBuffer(H.PIXEL_PACK_BUFFER,ut),H.bufferData(H.PIXEL_PACK_BUFFER,Ve.byteLength,H.STREAM_READ),H.readPixels(le,_e,be,de,Le.convert(ft),Le.convert(Ye),0);let Nt=T!==null?Ae.get(T).__webglFramebuffer:null;Re.bindFramebuffer(H.FRAMEBUFFER,Nt);let At=H.fenceSync(H.SYNC_GPU_COMMANDS_COMPLETE,0);return H.flush(),await Z_(H,At,4),H.bindBuffer(H.PIXEL_PACK_BUFFER,ut),H.getBufferSubData(H.PIXEL_PACK_BUFFER,0,Ve),H.deleteBuffer(ut),H.deleteSync(At),Ve}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")}},this.copyFramebufferToTexture=function(G,le=null,_e=0){G.isTexture!==!0&&(Jo("WebGLRenderer: copyFramebufferToTexture function signature has changed."),le=arguments[0]||null,G=arguments[1]);let be=Math.pow(2,-_e),de=Math.floor(G.image.width*be),Ve=Math.floor(G.image.height*be),Ke=le!==null?le.x:0,it=le!==null?le.y:0;Y.setTexture2D(G,0),H.copyTexSubImage2D(H.TEXTURE_2D,_e,0,0,Ke,it,de,Ve),Re.unbindTexture()};let Sm=H.createFramebuffer(),Tm=H.createFramebuffer();this.copyTextureToTexture=function(G,le,_e=null,be=null,de=0,Ve=null){G.isTexture!==!0&&(Jo("WebGLRenderer: copyTextureToTexture function signature has changed."),be=arguments[0]||null,G=arguments[1],le=arguments[2],Ve=arguments[3]||0,_e=null),Ve===null&&(de!==0?(Jo("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),Ve=de,de=0):Ve=0);let Ke,it,qe,ft,Ye,ut,Nt,At,en,yt=G.isCompressedTexture?G.mipmaps[Ve]:G.image;if(_e!==null)Ke=_e.max.x-_e.min.x,it=_e.max.y-_e.min.y,qe=_e.isBox3?_e.max.z-_e.min.z:1,ft=_e.min.x,Ye=_e.min.y,ut=_e.isBox3?_e.min.z:0;else{let ni=Math.pow(2,-de);Ke=Math.floor(yt.width*ni),it=Math.floor(yt.height*ni),G.isDataArrayTexture?qe=yt.depth:G.isData3DTexture?qe=Math.floor(yt.depth*ni):qe=1,ft=0,Ye=0,ut=0}be!==null?(Nt=be.x,At=be.y,en=be.z):(Nt=0,At=0,en=0);let Ct=Le.convert(le.format),ht=Le.convert(le.type),pn;le.isData3DTexture?(Y.setTexture3D(le,0),pn=H.TEXTURE_3D):le.isDataArrayTexture||le.isCompressedArrayTexture?(Y.setTexture2DArray(le,0),pn=H.TEXTURE_2D_ARRAY):(Y.setTexture2D(le,0),pn=H.TEXTURE_2D),H.pixelStorei(H.UNPACK_FLIP_Y_WEBGL,le.flipY),H.pixelStorei(H.UNPACK_PREMULTIPLY_ALPHA_WEBGL,le.premultiplyAlpha),H.pixelStorei(H.UNPACK_ALIGNMENT,le.unpackAlignment);let Ot=H.getParameter(H.UNPACK_ROW_LENGTH),ti=H.getParameter(H.UNPACK_IMAGE_HEIGHT),Ai=H.getParameter(H.UNPACK_SKIP_PIXELS),kn=H.getParameter(H.UNPACK_SKIP_ROWS),Vi=H.getParameter(H.UNPACK_SKIP_IMAGES);H.pixelStorei(H.UNPACK_ROW_LENGTH,yt.width),H.pixelStorei(H.UNPACK_IMAGE_HEIGHT,yt.height),H.pixelStorei(H.UNPACK_SKIP_PIXELS,ft),H.pixelStorei(H.UNPACK_SKIP_ROWS,Ye),H.pixelStorei(H.UNPACK_SKIP_IMAGES,ut);let Bt=G.isDataArrayTexture||G.isData3DTexture,Yn=le.isDataArrayTexture||le.isData3DTexture;if(G.isDepthTexture){let ni=Ae.get(G),Pn=Ae.get(le),Bn=Ae.get(ni.__renderTarget),ms=Ae.get(Pn.__renderTarget);Re.bindFramebuffer(H.READ_FRAMEBUFFER,Bn.__webglFramebuffer),Re.bindFramebuffer(H.DRAW_FRAMEBUFFER,ms.__webglFramebuffer);for(let Br=0;Br<qe;Br++)Bt&&(H.framebufferTextureLayer(H.READ_FRAMEBUFFER,H.COLOR_ATTACHMENT0,Ae.get(G).__webglTexture,de,ut+Br),H.framebufferTextureLayer(H.DRAW_FRAMEBUFFER,H.COLOR_ATTACHMENT0,Ae.get(le).__webglTexture,Ve,en+Br)),H.blitFramebuffer(ft,Ye,Ke,it,Nt,At,Ke,it,H.DEPTH_BUFFER_BIT,H.NEAREST);Re.bindFramebuffer(H.READ_FRAMEBUFFER,null),Re.bindFramebuffer(H.DRAW_FRAMEBUFFER,null)}else if(de!==0||G.isRenderTargetTexture||Ae.has(G)){let ni=Ae.get(G),Pn=Ae.get(le);Re.bindFramebuffer(H.READ_FRAMEBUFFER,Sm),Re.bindFramebuffer(H.DRAW_FRAMEBUFFER,Tm);for(let Bn=0;Bn<qe;Bn++)Bt?H.framebufferTextureLayer(H.READ_FRAMEBUFFER,H.COLOR_ATTACHMENT0,ni.__webglTexture,de,ut+Bn):H.framebufferTexture2D(H.READ_FRAMEBUFFER,H.COLOR_ATTACHMENT0,H.TEXTURE_2D,ni.__webglTexture,de),Yn?H.framebufferTextureLayer(H.DRAW_FRAMEBUFFER,H.COLOR_ATTACHMENT0,Pn.__webglTexture,Ve,en+Bn):H.framebufferTexture2D(H.DRAW_FRAMEBUFFER,H.COLOR_ATTACHMENT0,H.TEXTURE_2D,Pn.__webglTexture,Ve),de!==0?H.blitFramebuffer(ft,Ye,Ke,it,Nt,At,Ke,it,H.COLOR_BUFFER_BIT,H.NEAREST):Yn?H.copyTexSubImage3D(pn,Ve,Nt,At,en+Bn,ft,Ye,Ke,it):H.copyTexSubImage2D(pn,Ve,Nt,At,ft,Ye,Ke,it);Re.bindFramebuffer(H.READ_FRAMEBUFFER,null),Re.bindFramebuffer(H.DRAW_FRAMEBUFFER,null)}else Yn?G.isDataTexture||G.isData3DTexture?H.texSubImage3D(pn,Ve,Nt,At,en,Ke,it,qe,Ct,ht,yt.data):le.isCompressedArrayTexture?H.compressedTexSubImage3D(pn,Ve,Nt,At,en,Ke,it,qe,Ct,yt.data):H.texSubImage3D(pn,Ve,Nt,At,en,Ke,it,qe,Ct,ht,yt):G.isDataTexture?H.texSubImage2D(H.TEXTURE_2D,Ve,Nt,At,Ke,it,Ct,ht,yt.data):G.isCompressedTexture?H.compressedTexSubImage2D(H.TEXTURE_2D,Ve,Nt,At,yt.width,yt.height,Ct,yt.data):H.texSubImage2D(H.TEXTURE_2D,Ve,Nt,At,Ke,it,Ct,ht,yt);H.pixelStorei(H.UNPACK_ROW_LENGTH,Ot),H.pixelStorei(H.UNPACK_IMAGE_HEIGHT,ti),H.pixelStorei(H.UNPACK_SKIP_PIXELS,Ai),H.pixelStorei(H.UNPACK_SKIP_ROWS,kn),H.pixelStorei(H.UNPACK_SKIP_IMAGES,Vi),Ve===0&&le.generateMipmaps&&H.generateMipmap(pn),Re.unbindTexture()},this.copyTextureToTexture3D=function(G,le,_e=null,be=null,de=0){return G.isTexture!==!0&&(Jo("WebGLRenderer: copyTextureToTexture3D function signature has changed."),_e=arguments[0]||null,be=arguments[1]||null,G=arguments[2],le=arguments[3],de=arguments[4]||0),Jo('WebGLRenderer: copyTextureToTexture3D function has been deprecated. Use "copyTextureToTexture" instead.'),this.copyTextureToTexture(G,le,_e,be,de)},this.initRenderTarget=function(G){Ae.get(G).__webglFramebuffer===void 0&&Y.setupRenderTarget(G)},this.initTexture=function(G){G.isCubeTexture?Y.setTextureCube(G,0):G.isData3DTexture?Y.setTexture3D(G,0):G.isDataArrayTexture||G.isCompressedArrayTexture?Y.setTexture2DArray(G,0):Y.setTexture2D(G,0),Re.unbindTexture()},this.resetState=function(){E=0,A=0,T=null,Re.reset(),Xe.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return tr}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;let t=this.getContext();t.drawingBufferColorspace=_t._getDrawingBufferColorSpace(e),t.unpackColorSpace=_t._getUnpackColorSpace()}};var zb={triangulate:function(i,e,t=2){let n=e&&e.length,r=n?e[0]*t:i.length,s=Vb(i,0,r,t,!0),o=[];if(!s||s.next===s.prev)return o;let a,c,l,u,h,d,m;if(n&&(s=CC(i,e,s,t)),i.length>80*t){a=l=i[0],c=u=i[1];for(let g=t;g<r;g+=t)h=i[g],d=i[g+1],h<a&&(a=h),d<c&&(c=d),h>l&&(l=h),d>u&&(u=d);m=Math.max(l-a,u-c),m=m!==0?32767/m:0}return bh(s,o,t,a,c,m,0),o}};function Vb(i,e,t,n,r){let s,o;if(r===zC(i,e,t,n)>0)for(s=e;s<t;s+=n)o=Bb(s,i[s],i[s+1],o);else for(s=t-n;s>=e;s-=n)o=Bb(s,i[s],i[s+1],o);return o&&Ip(o,o.next)&&(Eh(o),o=o.next),o}function ra(i,e){if(!i)return i;e||(e=i);let t=i,n;do if(n=!1,!t.steiner&&(Ip(t,t.next)||hn(t.prev,t,t.next)===0)){if(Eh(t),t=e=t.prev,t===t.next)break;n=!0}else t=t.next;while(n||t!==e);return e}function bh(i,e,t,n,r,s,o){if(!i)return;!o&&s&&OC(i,n,r,s);let a=i,c,l;for(;i.prev!==i.next;){if(c=i.prev,l=i.next,s?AC(i,n,r,s):TC(i)){e.push(c.i/t|0),e.push(i.i/t|0),e.push(l.i/t|0),Eh(i),i=l.next,a=l.next;continue}if(i=l,i===a){o?o===1?(i=wC(ra(i),e,t),bh(i,e,t,n,r,s,2)):o===2&&RC(i,e,t,n,r,s):bh(ra(i),e,t,n,r,s,1);break}}}function TC(i){let e=i.prev,t=i,n=i.next;if(hn(e,t,n)>=0)return!1;let r=e.x,s=t.x,o=n.x,a=e.y,c=t.y,l=n.y,u=r<s?r<o?r:o:s<o?s:o,h=a<c?a<l?a:l:c<l?c:l,d=r>s?r>o?r:o:s>o?s:o,m=a>c?a>l?a:l:c>l?c:l,g=n.next;for(;g!==e;){if(g.x>=u&&g.x<=d&&g.y>=h&&g.y<=m&&Oc(r,a,s,c,o,l,g.x,g.y)&&hn(g.prev,g,g.next)>=0)return!1;g=g.next}return!0}function AC(i,e,t,n){let r=i.prev,s=i,o=i.next;if(hn(r,s,o)>=0)return!1;let a=r.x,c=s.x,l=o.x,u=r.y,h=s.y,d=o.y,m=a<c?a<l?a:l:c<l?c:l,g=u<h?u<d?u:d:h<d?h:d,x=a>c?a>l?a:l:c>l?c:l,f=u>h?u>d?u:d:h>d?h:d,p=j0(m,g,e,t,n),v=j0(x,f,e,t,n),_=i.prevZ,y=i.nextZ;for(;_&&_.z>=p&&y&&y.z<=v;){if(_.x>=m&&_.x<=x&&_.y>=g&&_.y<=f&&_!==r&&_!==o&&Oc(a,u,c,h,l,d,_.x,_.y)&&hn(_.prev,_,_.next)>=0||(_=_.prevZ,y.x>=m&&y.x<=x&&y.y>=g&&y.y<=f&&y!==r&&y!==o&&Oc(a,u,c,h,l,d,y.x,y.y)&&hn(y.prev,y,y.next)>=0))return!1;y=y.nextZ}for(;_&&_.z>=p;){if(_.x>=m&&_.x<=x&&_.y>=g&&_.y<=f&&_!==r&&_!==o&&Oc(a,u,c,h,l,d,_.x,_.y)&&hn(_.prev,_,_.next)>=0)return!1;_=_.prevZ}for(;y&&y.z<=v;){if(y.x>=m&&y.x<=x&&y.y>=g&&y.y<=f&&y!==r&&y!==o&&Oc(a,u,c,h,l,d,y.x,y.y)&&hn(y.prev,y,y.next)>=0)return!1;y=y.nextZ}return!0}function wC(i,e,t){let n=i;do{let r=n.prev,s=n.next.next;!Ip(r,s)&&Hb(r,n,n.next,s)&&Mh(r,s)&&Mh(s,r)&&(e.push(r.i/t|0),e.push(n.i/t|0),e.push(s.i/t|0),Eh(n),Eh(n.next),n=i=s),n=n.next}while(n!==i);return ra(n)}function RC(i,e,t,n,r,s){let o=i;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&UC(o,a)){let c=Gb(o,a);o=ra(o,o.next),c=ra(c,c.next),bh(o,e,t,n,r,s,0),bh(c,e,t,n,r,s,0);return}a=a.next}o=o.next}while(o!==i)}function CC(i,e,t,n){let r=[],s,o,a,c,l;for(s=0,o=e.length;s<o;s++)a=e[s]*n,c=s<o-1?e[s+1]*n:i.length,l=Vb(i,a,c,n,!1),l===l.next&&(l.steiner=!0),r.push(FC(l));for(r.sort(PC),s=0;s<r.length;s++)t=IC(r[s],t);return t}function PC(i,e){return i.x-e.x}function IC(i,e){let t=NC(i,e);if(!t)return e;let n=Gb(t,i);return ra(n,n.next),ra(t,t.next)}function NC(i,e){let t=e,n=-1/0,r,s=i.x,o=i.y;do{if(o<=t.y&&o>=t.next.y&&t.next.y!==t.y){let d=t.x+(o-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(d<=s&&d>n&&(n=d,r=t.x<t.next.x?t:t.next,d===s))return r}t=t.next}while(t!==e);if(!r)return null;let a=r,c=r.x,l=r.y,u=1/0,h;t=r;do s>=t.x&&t.x>=c&&s!==t.x&&Oc(o<l?s:n,o,c,l,o<l?n:s,o,t.x,t.y)&&(h=Math.abs(o-t.y)/(s-t.x),Mh(t,i)&&(h<u||h===u&&(t.x>r.x||t.x===r.x&&LC(r,t)))&&(r=t,u=h)),t=t.next;while(t!==a);return r}function LC(i,e){return hn(i.prev,i,e.prev)<0&&hn(e.next,i,i.next)<0}function OC(i,e,t,n){let r=i;do r.z===0&&(r.z=j0(r.x,r.y,e,t,n)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==i);r.prevZ.nextZ=null,r.prevZ=null,DC(r)}function DC(i){let e,t,n,r,s,o,a,c,l=1;do{for(t=i,i=null,s=null,o=0;t;){for(o++,n=t,a=0,e=0;e<l&&(a++,n=n.nextZ,!!n);e++);for(c=l;a>0||c>0&&n;)a!==0&&(c===0||!n||t.z<=n.z)?(r=t,t=t.nextZ,a--):(r=n,n=n.nextZ,c--),s?s.nextZ=r:i=r,r.prevZ=s,s=r;t=n}s.nextZ=null,l*=2}while(o>1);return i}function j0(i,e,t,n,r){return i=(i-t)*r|0,e=(e-n)*r|0,i=(i|i<<8)&16711935,i=(i|i<<4)&252645135,i=(i|i<<2)&858993459,i=(i|i<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,i|e<<1}function FC(i){let e=i,t=i;do(e.x<t.x||e.x===t.x&&e.y<t.y)&&(t=e),e=e.next;while(e!==i);return t}function Oc(i,e,t,n,r,s,o,a){return(r-o)*(e-a)>=(i-o)*(s-a)&&(i-o)*(n-a)>=(t-o)*(e-a)&&(t-o)*(s-a)>=(r-o)*(n-a)}function UC(i,e){return i.next.i!==e.i&&i.prev.i!==e.i&&!kC(i,e)&&(Mh(i,e)&&Mh(e,i)&&BC(i,e)&&(hn(i.prev,i,e.prev)||hn(i,e.prev,e))||Ip(i,e)&&hn(i.prev,i,i.next)>0&&hn(e.prev,e,e.next)>0)}function hn(i,e,t){return(e.y-i.y)*(t.x-e.x)-(e.x-i.x)*(t.y-e.y)}function Ip(i,e){return i.x===e.x&&i.y===e.y}function Hb(i,e,t,n){let r=Pp(hn(i,e,t)),s=Pp(hn(i,e,n)),o=Pp(hn(t,n,i)),a=Pp(hn(t,n,e));return!!(r!==s&&o!==a||r===0&&Cp(i,t,e)||s===0&&Cp(i,n,e)||o===0&&Cp(t,i,n)||a===0&&Cp(t,e,n))}function Cp(i,e,t){return e.x<=Math.max(i.x,t.x)&&e.x>=Math.min(i.x,t.x)&&e.y<=Math.max(i.y,t.y)&&e.y>=Math.min(i.y,t.y)}function Pp(i){return i>0?1:i<0?-1:0}function kC(i,e){let t=i;do{if(t.i!==i.i&&t.next.i!==i.i&&t.i!==e.i&&t.next.i!==e.i&&Hb(t,t.next,i,e))return!0;t=t.next}while(t!==i);return!1}function Mh(i,e){return hn(i.prev,i,i.next)<0?hn(i,e,i.next)>=0&&hn(i,i.prev,e)>=0:hn(i,e,i.prev)<0||hn(i,i.next,e)<0}function BC(i,e){let t=i,n=!1,r=(i.x+e.x)/2,s=(i.y+e.y)/2;do t.y>s!=t.next.y>s&&t.next.y!==t.y&&r<(t.next.x-t.x)*(s-t.y)/(t.next.y-t.y)+t.x&&(n=!n),t=t.next;while(t!==i);return n}function Gb(i,e){let t=new q0(i.i,i.x,i.y),n=new q0(e.i,e.x,e.y),r=i.next,s=e.prev;return i.next=e,e.prev=i,t.next=r,r.prev=t,n.next=t,t.prev=n,s.next=n,n.prev=s,n}function Bb(i,e,t,n){let r=new q0(i,e,t);return n?(r.next=n.next,r.prev=n,n.next.prev=r,n.next=r):(r.prev=r,r.next=r),r}function Eh(i){i.next.prev=i.prev,i.prev.next=i.next,i.prevZ&&(i.prevZ.nextZ=i.nextZ),i.nextZ&&(i.nextZ.prevZ=i.prevZ)}function q0(i,e,t){this.i=i,this.x=e,this.y=t,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function zC(i,e,t,n){let r=0;for(let s=e,o=t-n;s<t;s+=n)r+=(i[o]-i[s])*(i[s+1]+i[o+1]),o=s;return r}var K0=i=>i&&typeof i=="object"&&!Array.isArray(i)?i.quoted:i;function VC(i){let e=i.size;if(!Number.isSafeInteger(e)||e<3)throw Error("Invalid saved zone point count.");let t=i.filled?e*15+Math.max(0,e-2)*3*(e>65535?4:2):e*12;if(!Number.isSafeInteger(t))throw Error("Invalid saved zone geometry size.");return t}function Wb(i,e,{world:t,triangulate:n,maxBytes:r=64*1024*1024}={}){if(typeof t!="function"||typeof n!="function"||!Number.isSafeInteger(r)||r<0)throw TypeError("Invalid saved zone geometry options.");if(VC(e)>r)throw Object.assign(Error("Saved zone exceeds the remaining typed-geometry byte budget."),{code:"ZONE_GEOMETRY_BUDGET"});let s=new Float64Array(e.size*2),o=0,a=(g,x)=>{let f=t([g,x]);if(!f.every(Number.isFinite)||o>=e.size)throw Error("Invalid saved zone coordinate.");s[o*2]=f[0],s[o*2+1]=f[1],o++},c=e.sourcePoints[1];if(c instanceof Float64Array)for(let g=0;g<c.length;g+=2)a(c[g],c[g+1]);else for(let g of e.sourcePoints)!Array.isArray(g)||K0(g[0])!=="xy"||a(Number(K0(g[1])),Number(K0(g[2])));if(o!==e.size)throw Error("Saved zone point count changed.");o>3&&s[0]===s[(o-1)*2]&&s[1]===s[(o-1)*2+1]&&o--;let l=new Float32Array(o*3),u=e.filled?new Int8Array(o*3):null;for(let g=0;g<o;g++)l[g*3]=s[g*2],l[g*3+1]=s[g*2+1],u&&(u[g*3+2]=127);let h=null;if(e.filled){let g=n(s.subarray(0,o*2),void 0,2);if(!g.length||g.length%3||g.length>(o-2)*3)throw Error("Saved zone could not be triangulated faithfully.");let x=o>65535?Uint32Array:Uint16Array;h=new x(g.length);for(let f=0;f<g.length;f++){let p=g[f];if(!Number.isInteger(p)||p<0||p>=o)throw Error("Invalid saved zone triangulation index.");h[f]=p}}let d=l.byteLength+(u?.byteLength||0)+(h?.byteLength||0);if(d>r)throw Object.assign(Error("Saved zone exceeds its typed-geometry byte budget."),{code:"ZONE_GEOMETRY_BUDGET"});let m=new i.BufferGeometry;return m.setAttribute("position",new i.BufferAttribute(l,3)),u&&m.setAttribute("normal",new i.BufferAttribute(u,3,!0)),h&&m.setIndex(new i.BufferAttribute(h,1)),{geometry:m,bytes:d,vertices:o}}var Xb={type:"change"},J0={type:"start"},jb={type:"end"},Np=new nr,Yb=new Li,HC=Math.cos(70*Js.DEG2RAD),Cn=new z,Si=2*Math.PI,Kt={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},Z0=1e-6,Qs=class extends gc{constructor(e,t=null){super(e,t),this.state=Kt.NONE,this.enabled=!0,this.target=new z,this.cursor=new z,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.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:cs.ROTATE,MIDDLE:cs.DOLLY,RIGHT:cs.PAN},this.touches={ONE:ls.ROTATE,TWO:ls.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this._lastPosition=new z,this._lastQuaternion=new Zt,this._lastTargetPosition=new z,this._quat=new Zt().setFromUnitVectors(e.up,new z(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new Yo,this._sphericalDelta=new Yo,this._scale=1,this._panOffset=new z,this._rotateStart=new Me,this._rotateEnd=new Me,this._rotateDelta=new Me,this._panStart=new Me,this._panEnd=new Me,this._panDelta=new Me,this._dollyStart=new Me,this._dollyEnd=new Me,this._dollyDelta=new Me,this._dollyDirection=new z,this._mouse=new Me,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=WC.bind(this),this._onPointerDown=GC.bind(this),this._onPointerUp=XC.bind(this),this._onContextMenu=QC.bind(this),this._onMouseWheel=qC.bind(this),this._onKeyDown=KC.bind(this),this._onTouchStart=ZC.bind(this),this._onTouchMove=JC.bind(this),this._onMouseDown=YC.bind(this),this._onMouseMove=jC.bind(this),this._interceptControlDown=$C.bind(this),this._interceptControlUp=eP.bind(this),this.domElement!==null&&this.connect(),this.update()}connect(){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.removeEventListener("pointermove",this._onPointerMove),this.domElement.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="auto"}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(Xb),this.update(),this.state=Kt.NONE}update(e=null){let t=this.object.position;Cn.copy(t).sub(this.target),Cn.applyQuaternion(this._quat),this._spherical.setFromVector3(Cn),this.autoRotate&&this.state===Kt.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 n=this.minAzimuthAngle,r=this.maxAzimuthAngle;isFinite(n)&&isFinite(r)&&(n<-Math.PI?n+=Si:n>Math.PI&&(n-=Si),r<-Math.PI?r+=Si:r>Math.PI&&(r-=Si),n<=r?this._spherical.theta=Math.max(n,Math.min(r,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(n+r)/2?Math.max(n,this._spherical.theta):Math.min(r,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 s=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{let o=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),s=o!=this._spherical.radius}if(Cn.setFromSpherical(this._spherical),Cn.applyQuaternion(this._quatInverse),t.copy(this.target).add(Cn),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 o=null;if(this.object.isPerspectiveCamera){let a=Cn.length();o=this._clampDistance(a*this._scale);let c=a-o;this.object.position.addScaledVector(this._dollyDirection,c),this.object.updateMatrixWorld(),s=!!c}else if(this.object.isOrthographicCamera){let a=new z(this._mouse.x,this._mouse.y,0);a.unproject(this.object);let c=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),s=c!==this.object.zoom;let l=new z(this._mouse.x,this._mouse.y,0);l.unproject(this.object),this.object.position.sub(l).add(a),this.object.updateMatrixWorld(),o=Cn.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;o!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(o).add(this.object.position):(Np.origin.copy(this.object.position),Np.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(Np.direction))<HC?this.object.lookAt(this.target):(Yb.setFromNormalAndCoplanarPoint(this.object.up,this.target),Np.intersectPlane(Yb,this.target))))}else if(this.object.isOrthographicCamera){let o=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),o!==this.object.zoom&&(this.object.updateProjectionMatrix(),s=!0)}return this._scale=1,this._performCursorZoom=!1,s||this._lastPosition.distanceToSquared(this.object.position)>Z0||8*(1-this._lastQuaternion.dot(this.object.quaternion))>Z0||this._lastTargetPosition.distanceToSquared(this.target)>Z0?(this.dispatchEvent(Xb),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?Si/60*this.autoRotateSpeed*e:Si/60/60*this.autoRotateSpeed}_getZoomScale(e){let 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){Cn.setFromMatrixColumn(t,0),Cn.multiplyScalar(-e),this._panOffset.add(Cn)}_panUp(e,t){this.screenSpacePanning===!0?Cn.setFromMatrixColumn(t,1):(Cn.setFromMatrixColumn(t,0),Cn.crossVectors(this.object.up,Cn)),Cn.multiplyScalar(e),this._panOffset.add(Cn)}_pan(e,t){let n=this.domElement;if(this.object.isPerspectiveCamera){let r=this.object.position;Cn.copy(r).sub(this.target);let s=Cn.length();s*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*s/n.clientHeight,this.object.matrix),this._panUp(2*t*s/n.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/n.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/n.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;let n=this.domElement.getBoundingClientRect(),r=e-n.left,s=t-n.top,o=n.width,a=n.height;this._mouse.x=r/o*2-1,this._mouse.y=-(s/a)*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);let t=this.domElement;this._rotateLeft(Si*this._rotateDelta.x/t.clientHeight),this._rotateUp(Si*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(Si*this.rotateSpeed/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(-Si*this.rotateSpeed/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(Si*this.rotateSpeed/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(-Si*this.rotateSpeed/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{let t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this._rotateStart.set(n,r)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this._panStart.set(n,r)}}_handleTouchStartDolly(e){let t=this._getSecondPointerPosition(e),n=e.pageX-t.x,r=e.pageY-t.y,s=Math.sqrt(n*n+r*r);this._dollyStart.set(0,s)}_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{let n=this._getSecondPointerPosition(e),r=.5*(e.pageX+n.x),s=.5*(e.pageY+n.y);this._rotateEnd.set(r,s)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);let t=this.domElement;this._rotateLeft(Si*this._rotateDelta.x/t.clientHeight),this._rotateUp(Si*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{let t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this._panEnd.set(n,r)}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){let t=this._getSecondPointerPosition(e),n=e.pageX-t.x,r=e.pageY-t.y,s=Math.sqrt(n*n+r*r);this._dollyEnd.set(0,s),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);let o=(e.pageX+t.x)*.5,a=(e.pageY+t.y)*.5;this._updateZoomParameters(o,a)}_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 Me,this._pointerPositions[e.pointerId]=t),t.set(e.pageX,e.pageY)}_getSecondPointerPosition(e){let t=e.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[t]}_customWheelEvent(e){let t=e.deltaMode,n={clientX:e.clientX,clientY:e.clientY,deltaY:e.deltaY};switch(t){case 1:n.deltaY*=16;break;case 2:n.deltaY*=100;break}return e.ctrlKey&&!this._controlActive&&(n.deltaY*=10),n}};function GC(i){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(i.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.domElement.addEventListener("pointerup",this._onPointerUp)),!this._isTrackingPointer(i)&&(this._addPointer(i),i.pointerType==="touch"?this._onTouchStart(i):this._onMouseDown(i)))}function WC(i){this.enabled!==!1&&(i.pointerType==="touch"?this._onTouchMove(i):this._onMouseMove(i))}function XC(i){switch(this._removePointer(i),this._pointers.length){case 0:this.domElement.releasePointerCapture(i.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(jb),this.state=Kt.NONE;break;case 1:let e=this._pointers[0],t=this._pointerPositions[e];this._onTouchStart({pointerId:e,pageX:t.x,pageY:t.y});break}}function YC(i){let e;switch(i.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 cs.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(i),this.state=Kt.DOLLY;break;case cs.ROTATE:if(i.ctrlKey||i.metaKey||i.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(i),this.state=Kt.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(i),this.state=Kt.ROTATE}break;case cs.PAN:if(i.ctrlKey||i.metaKey||i.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(i),this.state=Kt.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(i),this.state=Kt.PAN}break;default:this.state=Kt.NONE}this.state!==Kt.NONE&&this.dispatchEvent(J0)}function jC(i){switch(this.state){case Kt.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(i);break;case Kt.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(i);break;case Kt.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(i);break}}function qC(i){this.enabled===!1||this.enableZoom===!1||this.state!==Kt.NONE||(i.preventDefault(),this.dispatchEvent(J0),this._handleMouseWheel(this._customWheelEvent(i)),this.dispatchEvent(jb))}function KC(i){this.enabled!==!1&&this._handleKeyDown(i)}function ZC(i){switch(this._trackPointer(i),this._pointers.length){case 1:switch(this.touches.ONE){case ls.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(i),this.state=Kt.TOUCH_ROTATE;break;case ls.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(i),this.state=Kt.TOUCH_PAN;break;default:this.state=Kt.NONE}break;case 2:switch(this.touches.TWO){case ls.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(i),this.state=Kt.TOUCH_DOLLY_PAN;break;case ls.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(i),this.state=Kt.TOUCH_DOLLY_ROTATE;break;default:this.state=Kt.NONE}break;default:this.state=Kt.NONE}this.state!==Kt.NONE&&this.dispatchEvent(J0)}function JC(i){switch(this._trackPointer(i),this.state){case Kt.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(i),this.update();break;case Kt.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(i),this.update();break;case Kt.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(i),this.update();break;case Kt.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(i),this.update();break;default:this.state=Kt.NONE}}function QC(i){this.enabled!==!1&&i.preventDefault()}function $C(i){i.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function eP(i){i.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function qb(i){return class extends i{_viewFrame(){let t=this.object.position.clone().sub(this.target),n=t.clone().normalize(),r=this.object.up.clone().addScaledVector(n,-this.object.up.dot(n));return r.lengthSq()<1e-8&&(r.setFromMatrixColumn(this.object.matrix,1),r.addScaledVector(n,-r.dot(n))),r.lengthSq()<1e-8&&(r.set(Math.abs(n.y)<.9?0:1,Math.abs(n.y)<.9?1:0,0),r.addScaledVector(n,-r.dot(n))),r.normalize(),this.object.up.copy(r),{offset:t,up:r,right:r.clone().cross(n).normalize()}}_inputAngle(t){let n=this.domElement?.clientHeight||600,r=this.domElement?.clientWidth||600;return t*n/Math.max(600,r,n)}_rotateLeft(t){let{offset:n,up:r}=this._viewFrame();n.applyAxisAngle(r,-this._inputAngle(t)),this.object.position.copy(this.target).add(n)}_rotateUp(t){let{offset:n,up:r,right:s}=this._viewFrame(),o=-this._inputAngle(t);n.applyAxisAngle(s,o),r.applyAxisAngle(s,o),this.object.up.copy(r),this.object.position.copy(this.target).add(n)}update(t){let{up:n}=this._viewFrame();return this._quat.setFromUnitVectors(n,n.clone().set(0,1,0)),this._quatInverse.copy(this._quat).invert(),super.update(t)}}}function Kb(i,e,t){i.mouseButtons.LEFT=t?e.MOUSE.PAN:e.MOUSE.ROTATE,i.touches.ONE=t?e.TOUCH.PAN:e.TOUCH.ROTATE}function Q0(i,e){if(e===vp)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),i;if(e===Zo||e===Cc){let t=i.getIndex();if(t===null){let o=[],a=i.getAttribute("position");if(a!==void 0){for(let c=0;c<a.count;c++)o.push(c);i.setIndex(o),t=i.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),i}let n=t.count-2,r=[];if(e===Zo)for(let o=1;o<=n;o++)r.push(t.getX(0)),r.push(t.getX(o)),r.push(t.getX(o+1));else for(let o=0;o<n;o++)o%2===0?(r.push(t.getX(o)),r.push(t.getX(o+1)),r.push(t.getX(o+2))):(r.push(t.getX(o+2)),r.push(t.getX(o+1)),r.push(t.getX(o)));r.length/3!==n&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");let s=i.clone();return s.setIndex(r),s.clearGroups(),s}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),i}var Lp=class extends rn{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new sx(t)}),this.register(function(t){return new ox(t)}),this.register(function(t){return new mx(t)}),this.register(function(t){return new gx(t)}),this.register(function(t){return new xx(t)}),this.register(function(t){return new cx(t)}),this.register(function(t){return new lx(t)}),this.register(function(t){return new ux(t)}),this.register(function(t){return new hx(t)}),this.register(function(t){return new rx(t)}),this.register(function(t){return new dx(t)}),this.register(function(t){return new ax(t)}),this.register(function(t){return new px(t)}),this.register(function(t){return new fx(t)}),this.register(function(t){return new nx(t)}),this.register(function(t){return new yx(t)}),this.register(function(t){return new vx(t)})}load(e,t,n,r){let s=this,o;if(this.resourcePath!=="")o=this.resourcePath;else if(this.path!==""){let l=Mi.extractUrlBase(e);o=Mi.resolveURL(l,this.path)}else o=Mi.extractUrlBase(e);this.manager.itemStart(e);let a=function(l){r?r(l):console.error(l),s.manager.itemError(e),s.manager.itemEnd(e)},c=new Vn(this.manager);c.setPath(this.path),c.setResponseType("arraybuffer"),c.setRequestHeader(this.requestHeader),c.setWithCredentials(this.withCredentials),c.load(e,function(l){try{s.parse(l,o,function(u){t(u),s.manager.itemEnd(e)},a)}catch(u){a(u)}},n,a)}setDRACOLoader(e){return this.dracoLoader=e,this}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,n,r){let s,o={},a={},c=new TextDecoder;if(typeof e=="string")s=JSON.parse(e);else if(e instanceof ArrayBuffer)if(c.decode(new Uint8Array(e,0,4))===eM){try{o[Pt.KHR_BINARY_GLTF]=new _x(e)}catch(h){r&&r(h);return}s=JSON.parse(o[Pt.KHR_BINARY_GLTF].content)}else s=JSON.parse(c.decode(e));else s=e;if(s.asset===void 0||s.asset.version[0]<2){r&&r(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}let l=new wx(s,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});l.fileLoader.setRequestHeader(this.requestHeader);for(let u=0;u<this.pluginCallbacks.length;u++){let h=this.pluginCallbacks[u](l);h.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),a[h.name]=h,o[h.name]=!0}if(s.extensionsUsed)for(let u=0;u<s.extensionsUsed.length;++u){let h=s.extensionsUsed[u],d=s.extensionsRequired||[];switch(h){case Pt.KHR_MATERIALS_UNLIT:o[h]=new ix;break;case Pt.KHR_DRACO_MESH_COMPRESSION:o[h]=new bx(s,this.dracoLoader);break;case Pt.KHR_TEXTURE_TRANSFORM:o[h]=new Mx;break;case Pt.KHR_MESH_QUANTIZATION:o[h]=new Ex;break;default:d.indexOf(h)>=0&&a[h]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+h+'".')}}l.setExtensions(o),l.setPlugins(a),l.parse(n,r)}parseAsync(e,t){let n=this;return new Promise(function(r,s){n.parse(e,t,r,s)})}};function tP(){let i={};return{get:function(e){return i[e]},add:function(e,t){i[e]=t},remove:function(e){delete i[e]},removeAll:function(){i={}}}}var Pt={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"},nx=class{constructor(e){this.parser=e,this.name=Pt.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){let e=this.parser,t=this.parser.json.nodes||[];for(let n=0,r=t.length;n<r;n++){let s=t[n];s.extensions&&s.extensions[this.name]&&s.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,s.extensions[this.name].light)}}_loadLight(e){let t=this.parser,n="light:"+e,r=t.cache.get(n);if(r)return r;let s=t.json,c=((s.extensions&&s.extensions[this.name]||{}).lights||[])[e],l,u=new Ue(16777215);c.color!==void 0&&u.setRGB(c.color[0],c.color[1],c.color[2],On);let h=c.range!==void 0?c.range:0;switch(c.type){case"directional":l=new as(u),l.target.position.set(0,0,-1),l.add(l.target);break;case"point":l=new os(u),l.distance=h;break;case"spot":l=new Go(u),l.distance=h,c.spot=c.spot||{},c.spot.innerConeAngle=c.spot.innerConeAngle!==void 0?c.spot.innerConeAngle:0,c.spot.outerConeAngle=c.spot.outerConeAngle!==void 0?c.spot.outerConeAngle:Math.PI/4,l.angle=c.spot.outerConeAngle,l.penumbra=1-c.spot.innerConeAngle/c.spot.outerConeAngle,l.target.position.set(0,0,-1),l.add(l.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+c.type)}return l.position.set(0,0,0),l.decay=2,ps(l,c),c.intensity!==void 0&&(l.intensity=c.intensity),l.name=t.createUniqueName(c.name||"light_"+e),r=Promise.resolve(l),t.cache.add(n,r),r}getDependency(e,t){if(e==="light")return this._loadLight(t)}createNodeAttachment(e){let t=this,n=this.parser,s=n.json.nodes[e],a=(s.extensions&&s.extensions[this.name]||{}).light;return a===void 0?null:this._loadLight(a).then(function(c){return n._getNodeRef(t.cache,a,c)})}},ix=class{constructor(){this.name=Pt.KHR_MATERIALS_UNLIT}getMaterialType(){return Ht}extendParams(e,t,n){let r=[];e.color=new Ue(1,1,1),e.opacity=1;let s=t.pbrMetallicRoughness;if(s){if(Array.isArray(s.baseColorFactor)){let o=s.baseColorFactor;e.color.setRGB(o[0],o[1],o[2],On),e.opacity=o[3]}s.baseColorTexture!==void 0&&r.push(n.assignTexture(e,"map",s.baseColorTexture,wt))}return Promise.all(r)}},rx=class{constructor(e){this.parser=e,this.name=Pt.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){let r=this.parser.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();let s=r.extensions[this.name].emissiveStrength;return s!==void 0&&(t.emissiveIntensity=s),Promise.resolve()}},sx=class{constructor(e){this.parser=e,this.name=Pt.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){let n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:Dn}extendMaterialParams(e,t){let n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();let s=[],o=r.extensions[this.name];if(o.clearcoatFactor!==void 0&&(t.clearcoat=o.clearcoatFactor),o.clearcoatTexture!==void 0&&s.push(n.assignTexture(t,"clearcoatMap",o.clearcoatTexture)),o.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=o.clearcoatRoughnessFactor),o.clearcoatRoughnessTexture!==void 0&&s.push(n.assignTexture(t,"clearcoatRoughnessMap",o.clearcoatRoughnessTexture)),o.clearcoatNormalTexture!==void 0&&(s.push(n.assignTexture(t,"clearcoatNormalMap",o.clearcoatNormalTexture)),o.clearcoatNormalTexture.scale!==void 0)){let a=o.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new Me(a,a)}return Promise.all(s)}},ox=class{constructor(e){this.parser=e,this.name=Pt.KHR_MATERIALS_DISPERSION}getMaterialType(e){let n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:Dn}extendMaterialParams(e,t){let r=this.parser.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();let s=r.extensions[this.name];return t.dispersion=s.dispersion!==void 0?s.dispersion:0,Promise.resolve()}},ax=class{constructor(e){this.parser=e,this.name=Pt.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){let n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:Dn}extendMaterialParams(e,t){let n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();let s=[],o=r.extensions[this.name];return o.iridescenceFactor!==void 0&&(t.iridescence=o.iridescenceFactor),o.iridescenceTexture!==void 0&&s.push(n.assignTexture(t,"iridescenceMap",o.iridescenceTexture)),o.iridescenceIor!==void 0&&(t.iridescenceIOR=o.iridescenceIor),t.iridescenceThicknessRange===void 0&&(t.iridescenceThicknessRange=[100,400]),o.iridescenceThicknessMinimum!==void 0&&(t.iridescenceThicknessRange[0]=o.iridescenceThicknessMinimum),o.iridescenceThicknessMaximum!==void 0&&(t.iridescenceThicknessRange[1]=o.iridescenceThicknessMaximum),o.iridescenceThicknessTexture!==void 0&&s.push(n.assignTexture(t,"iridescenceThicknessMap",o.iridescenceThicknessTexture)),Promise.all(s)}},cx=class{constructor(e){this.parser=e,this.name=Pt.KHR_MATERIALS_SHEEN}getMaterialType(e){let n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:Dn}extendMaterialParams(e,t){let n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();let s=[];t.sheenColor=new Ue(0,0,0),t.sheenRoughness=0,t.sheen=1;let o=r.extensions[this.name];if(o.sheenColorFactor!==void 0){let a=o.sheenColorFactor;t.sheenColor.setRGB(a[0],a[1],a[2],On)}return o.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=o.sheenRoughnessFactor),o.sheenColorTexture!==void 0&&s.push(n.assignTexture(t,"sheenColorMap",o.sheenColorTexture,wt)),o.sheenRoughnessTexture!==void 0&&s.push(n.assignTexture(t,"sheenRoughnessMap",o.sheenRoughnessTexture)),Promise.all(s)}},lx=class{constructor(e){this.parser=e,this.name=Pt.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){let n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:Dn}extendMaterialParams(e,t){let n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();let s=[],o=r.extensions[this.name];return o.transmissionFactor!==void 0&&(t.transmission=o.transmissionFactor),o.transmissionTexture!==void 0&&s.push(n.assignTexture(t,"transmissionMap",o.transmissionTexture)),Promise.all(s)}},ux=class{constructor(e){this.parser=e,this.name=Pt.KHR_MATERIALS_VOLUME}getMaterialType(e){let n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:Dn}extendMaterialParams(e,t){let n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();let s=[],o=r.extensions[this.name];t.thickness=o.thicknessFactor!==void 0?o.thicknessFactor:0,o.thicknessTexture!==void 0&&s.push(n.assignTexture(t,"thicknessMap",o.thicknessTexture)),t.attenuationDistance=o.attenuationDistance||1/0;let a=o.attenuationColor||[1,1,1];return t.attenuationColor=new Ue().setRGB(a[0],a[1],a[2],On),Promise.all(s)}},hx=class{constructor(e){this.parser=e,this.name=Pt.KHR_MATERIALS_IOR}getMaterialType(e){let n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:Dn}extendMaterialParams(e,t){let r=this.parser.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();let s=r.extensions[this.name];return t.ior=s.ior!==void 0?s.ior:1.5,Promise.resolve()}},dx=class{constructor(e){this.parser=e,this.name=Pt.KHR_MATERIALS_SPECULAR}getMaterialType(e){let n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:Dn}extendMaterialParams(e,t){let n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();let s=[],o=r.extensions[this.name];t.specularIntensity=o.specularFactor!==void 0?o.specularFactor:1,o.specularTexture!==void 0&&s.push(n.assignTexture(t,"specularIntensityMap",o.specularTexture));let a=o.specularColorFactor||[1,1,1];return t.specularColor=new Ue().setRGB(a[0],a[1],a[2],On),o.specularColorTexture!==void 0&&s.push(n.assignTexture(t,"specularColorMap",o.specularColorTexture,wt)),Promise.all(s)}},fx=class{constructor(e){this.parser=e,this.name=Pt.EXT_MATERIALS_BUMP}getMaterialType(e){let n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:Dn}extendMaterialParams(e,t){let n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();let s=[],o=r.extensions[this.name];return t.bumpScale=o.bumpFactor!==void 0?o.bumpFactor:1,o.bumpTexture!==void 0&&s.push(n.assignTexture(t,"bumpMap",o.bumpTexture)),Promise.all(s)}},px=class{constructor(e){this.parser=e,this.name=Pt.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){let n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:Dn}extendMaterialParams(e,t){let n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();let s=[],o=r.extensions[this.name];return o.anisotropyStrength!==void 0&&(t.anisotropy=o.anisotropyStrength),o.anisotropyRotation!==void 0&&(t.anisotropyRotation=o.anisotropyRotation),o.anisotropyTexture!==void 0&&s.push(n.assignTexture(t,"anisotropyMap",o.anisotropyTexture)),Promise.all(s)}},mx=class{constructor(e){this.parser=e,this.name=Pt.KHR_TEXTURE_BASISU}loadTexture(e){let t=this.parser,n=t.json,r=n.textures[e];if(!r.extensions||!r.extensions[this.name])return null;let s=r.extensions[this.name],o=t.options.ktx2Loader;if(!o){if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,s.source,o)}},gx=class{constructor(e){this.parser=e,this.name=Pt.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){let t=this.name,n=this.parser,r=n.json,s=r.textures[e];if(!s.extensions||!s.extensions[t])return null;let o=s.extensions[t],a=r.images[o.source],c=n.textureLoader;if(a.uri){let l=n.options.manager.getHandler(a.uri);l!==null&&(c=l)}return this.detectSupport().then(function(l){if(l)return n.loadTextureImage(e,o.source,c);if(r.extensionsRequired&&r.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return n.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){let t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(t.height===1)}})),this.isSupported}},xx=class{constructor(e){this.parser=e,this.name=Pt.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(e){let t=this.name,n=this.parser,r=n.json,s=r.textures[e];if(!s.extensions||!s.extensions[t])return null;let o=s.extensions[t],a=r.images[o.source],c=n.textureLoader;if(a.uri){let l=n.options.manager.getHandler(a.uri);l!==null&&(c=l)}return this.detectSupport().then(function(l){if(l)return n.loadTextureImage(e,o.source,c);if(r.extensionsRequired&&r.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return n.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){let t=new Image;t.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",t.onload=t.onerror=function(){e(t.height===1)}})),this.isSupported}},yx=class{constructor(e){this.name=Pt.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){let t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){let r=n.extensions[this.name],s=this.parser.getDependency("buffer",r.buffer),o=this.parser.options.meshoptDecoder;if(!o||!o.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return s.then(function(a){let c=r.byteOffset||0,l=r.byteLength||0,u=r.count,h=r.byteStride,d=new Uint8Array(a,c,l);return o.decodeGltfBufferAsync?o.decodeGltfBufferAsync(u,h,d,r.mode,r.filter).then(function(m){return m.buffer}):o.ready.then(function(){let m=new ArrayBuffer(u*h);return o.decodeGltfBuffer(new Uint8Array(m),u,h,d,r.mode,r.filter),m})})}else return null}},vx=class{constructor(e){this.name=Pt.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){let t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||n.mesh===void 0)return null;let r=t.meshes[n.mesh];for(let l of r.primitives)if(l.mode!==Yi.TRIANGLES&&l.mode!==Yi.TRIANGLE_STRIP&&l.mode!==Yi.TRIANGLE_FAN&&l.mode!==void 0)return null;let o=n.extensions[this.name].attributes,a=[],c={};for(let l in o)a.push(this.parser.getDependency("accessor",o[l]).then(u=>(c[l]=u,c[l])));return a.length<1?null:(a.push(this.parser.createNodeMesh(e)),Promise.all(a).then(l=>{let u=l.pop(),h=u.isGroup?u.children:[u],d=l[0].count,m=[];for(let g of h){let x=new nt,f=new z,p=new Zt,v=new z(1,1,1),_=new $r(g.geometry,g.material,d);for(let y=0;y<d;y++)c.TRANSLATION&&f.fromBufferAttribute(c.TRANSLATION,y),c.ROTATION&&p.fromBufferAttribute(c.ROTATION,y),c.SCALE&&v.fromBufferAttribute(c.SCALE,y),_.setMatrixAt(y,x.compose(f,p,v));for(let y in c)if(y==="_COLOR_0"){let b=c[y];_.instanceColor=new Xi(b.array,b.itemSize,b.normalized)}else y!=="TRANSLATION"&&y!=="ROTATION"&&y!=="SCALE"&&g.geometry.setAttribute(y,c[y]);St.prototype.copy.call(_,g),this.parser.assignFinalMaterial(_),m.push(_)}return u.isGroup?(u.clear(),u.add(...m),u):m[0]}))}},eM="glTF",Sh=12,Zb={JSON:1313821514,BIN:5130562},_x=class{constructor(e){this.name=Pt.KHR_BINARY_GLTF,this.content=null,this.body=null;let t=new DataView(e,0,Sh),n=new TextDecoder;if(this.header={magic:n.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==eM)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");let r=this.header.length-Sh,s=new DataView(e,Sh),o=0;for(;o<r;){let a=s.getUint32(o,!0);o+=4;let c=s.getUint32(o,!0);if(o+=4,c===Zb.JSON){let l=new Uint8Array(e,Sh+o,a);this.content=n.decode(l)}else if(c===Zb.BIN){let l=Sh+o;this.body=e.slice(l,l+a)}o+=a}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}},bx=class{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=Pt.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){let n=this.json,r=this.dracoLoader,s=e.extensions[this.name].bufferView,o=e.extensions[this.name].attributes,a={},c={},l={};for(let u in o){let h=Tx[u]||u.toLowerCase();a[h]=o[u]}for(let u in e.attributes){let h=Tx[u]||u.toLowerCase();if(o[u]!==void 0){let d=n.accessors[e.attributes[u]],m=Dc[d.componentType];l[h]=m.name,c[h]=d.normalized===!0}}return t.getDependency("bufferView",s).then(function(u){return new Promise(function(h,d){r.decodeDracoFile(u,function(m){for(let g in m.attributes){let x=m.attributes[g],f=c[g];f!==void 0&&(x.normalized=f)}h(m)},a,l,On,d)})})}},Mx=class{constructor(){this.name=Pt.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){return(t.texCoord===void 0||t.texCoord===e.channel)&&t.offset===void 0&&t.rotation===void 0&&t.scale===void 0||(e=e.clone(),t.texCoord!==void 0&&(e.channel=t.texCoord),t.offset!==void 0&&e.offset.fromArray(t.offset),t.rotation!==void 0&&(e.rotation=t.rotation),t.scale!==void 0&&e.repeat.fromArray(t.scale),e.needsUpdate=!0),e}},Ex=class{constructor(){this.name=Pt.KHR_MESH_QUANTIZATION}},Op=class extends wr{constructor(e,t,n,r){super(e,t,n,r)}copySampleValue_(e){let t=this.resultBuffer,n=this.sampleValues,r=this.valueSize,s=e*r*3+r;for(let o=0;o!==r;o++)t[o]=n[s+o];return t}interpolate_(e,t,n,r){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,c=a*2,l=a*3,u=r-t,h=(n-t)/u,d=h*h,m=d*h,g=e*l,x=g-l,f=-2*m+3*d,p=m-d,v=1-f,_=p-d+h;for(let y=0;y!==a;y++){let b=o[x+y+a],E=o[x+y+c]*u,A=o[g+y+a],T=o[g+y]*u;s[y]=v*b+_*E+f*A+p*T}return s}},nP=new Zt,Sx=class extends Op{interpolate_(e,t,n,r){let s=super.interpolate_(e,t,n,r);return nP.fromArray(s).normalize().toArray(s),s}},Yi={FLOAT:5126,FLOAT_MAT3:35675,FLOAT_MAT4:35676,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,LINEAR:9729,REPEAT:10497,SAMPLER_2D:35678,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123},Dc={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},Jb={9728:Jt,9729:nn,9984:Mc,9985:Zs,9986:hs,9987:Ei},Qb={33071:Mn,33648:ks,10497:gn},$0={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Tx={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},$s={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},iP={CUBICSPLINE:void 0,LINEAR:zs,STEP:Bs},ex={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function rP(i){return i.DefaultMaterial===void 0&&(i.DefaultMaterial=new En({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:Jn})),i.DefaultMaterial}function sa(i,e,t){for(let n in t.extensions)i[n]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[n]=t.extensions[n])}function ps(i,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(i.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function sP(i,e,t){let n=!1,r=!1,s=!1;for(let l=0,u=e.length;l<u;l++){let h=e[l];if(h.POSITION!==void 0&&(n=!0),h.NORMAL!==void 0&&(r=!0),h.COLOR_0!==void 0&&(s=!0),n&&r&&s)break}if(!n&&!r&&!s)return Promise.resolve(i);let o=[],a=[],c=[];for(let l=0,u=e.length;l<u;l++){let h=e[l];if(n){let d=h.POSITION!==void 0?t.getDependency("accessor",h.POSITION):i.attributes.position;o.push(d)}if(r){let d=h.NORMAL!==void 0?t.getDependency("accessor",h.NORMAL):i.attributes.normal;a.push(d)}if(s){let d=h.COLOR_0!==void 0?t.getDependency("accessor",h.COLOR_0):i.attributes.color;c.push(d)}}return Promise.all([Promise.all(o),Promise.all(a),Promise.all(c)]).then(function(l){let u=l[0],h=l[1],d=l[2];return n&&(i.morphAttributes.position=u),r&&(i.morphAttributes.normal=h),s&&(i.morphAttributes.color=d),i.morphTargetsRelative=!0,i})}function oP(i,e){if(i.updateMorphTargets(),e.weights!==void 0)for(let t=0,n=e.weights.length;t<n;t++)i.morphTargetInfluences[t]=e.weights[t];if(e.extras&&Array.isArray(e.extras.targetNames)){let t=e.extras.targetNames;if(i.morphTargetInfluences.length===t.length){i.morphTargetDictionary={};for(let n=0,r=t.length;n<r;n++)i.morphTargetDictionary[t[n]]=n}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function aP(i){let e,t=i.extensions&&i.extensions[Pt.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+tx(t.attributes):e=i.indices+":"+tx(i.attributes)+":"+i.mode,i.targets!==void 0)for(let n=0,r=i.targets.length;n<r;n++)e+=":"+tx(i.targets[n]);return e}function tx(i){let e="",t=Object.keys(i).sort();for(let n=0,r=t.length;n<r;n++)e+=t[n]+":"+i[t[n]]+";";return e}function Ax(i){switch(i){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}function cP(i){return i.search(/\.jpe?g($|\?)/i)>0||i.search(/^data\:image\/jpeg/)===0?"image/jpeg":i.search(/\.webp($|\?)/i)>0||i.search(/^data\:image\/webp/)===0?"image/webp":i.search(/\.ktx2($|\?)/i)>0||i.search(/^data\:image\/ktx2/)===0?"image/ktx2":"image/png"}var lP=new nt,wx=class{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new tP,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let n=!1,r=-1,s=!1,o=-1;if(typeof navigator<"u"){let a=navigator.userAgent;n=/^((?!chrome|android).)*safari/i.test(a)===!0;let c=a.match(/Version\/(\d+)/);r=n&&c?parseInt(c[1],10):-1,s=a.indexOf("Firefox")>-1,o=s?a.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>"u"||n&&r<17||s&&o<98?this.textureLoader=new qs(this.options.manager):this.textureLoader=new pc(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new Vn(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){let n=this,r=this.json,s=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(o){return o._markDefs&&o._markDefs()}),Promise.all(this._invokeAll(function(o){return o.beforeRoot&&o.beforeRoot()})).then(function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])}).then(function(o){let a={scene:o[0][r.scene||0],scenes:o[0],animations:o[1],cameras:o[2],asset:r.asset,parser:n,userData:{}};return sa(s,a,r),ps(a,r),Promise.all(n._invokeAll(function(c){return c.afterRoot&&c.afterRoot(a)})).then(function(){for(let c of a.scenes)c.updateMatrixWorld();e(a)})}).catch(t)}_markDefs(){let e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let r=0,s=t.length;r<s;r++){let o=t[r].joints;for(let a=0,c=o.length;a<c;a++)e[o[a]].isBone=!0}for(let r=0,s=e.length;r<s;r++){let o=e[r];o.mesh!==void 0&&(this._addNodeRef(this.meshCache,o.mesh),o.skin!==void 0&&(n[o.mesh].isSkinnedMesh=!0)),o.camera!==void 0&&this._addNodeRef(this.cameraCache,o.camera)}}_addNodeRef(e,t){t!==void 0&&(e.refs[t]===void 0&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,n){if(e.refs[t]<=1)return n;let r=n.clone(),s=(o,a)=>{let c=this.associations.get(o);c!=null&&this.associations.set(a,c);for(let[l,u]of o.children.entries())s(u,a.children[l])};return s(n,r),r.name+="_instance_"+e.uses[t]++,r}_invokeOne(e){let t=Object.values(this.plugins);t.push(this);for(let n=0;n<t.length;n++){let r=e(t[n]);if(r)return r}return null}_invokeAll(e){let t=Object.values(this.plugins);t.unshift(this);let n=[];for(let r=0;r<t.length;r++){let s=e(t[r]);s&&n.push(s)}return n}getDependency(e,t){let n=e+":"+t,r=this.cache.get(n);if(!r){switch(e){case"scene":r=this.loadScene(t);break;case"node":r=this._invokeOne(function(s){return s.loadNode&&s.loadNode(t)});break;case"mesh":r=this._invokeOne(function(s){return s.loadMesh&&s.loadMesh(t)});break;case"accessor":r=this.loadAccessor(t);break;case"bufferView":r=this._invokeOne(function(s){return s.loadBufferView&&s.loadBufferView(t)});break;case"buffer":r=this.loadBuffer(t);break;case"material":r=this._invokeOne(function(s){return s.loadMaterial&&s.loadMaterial(t)});break;case"texture":r=this._invokeOne(function(s){return s.loadTexture&&s.loadTexture(t)});break;case"skin":r=this.loadSkin(t);break;case"animation":r=this._invokeOne(function(s){return s.loadAnimation&&s.loadAnimation(t)});break;case"camera":r=this.loadCamera(t);break;default:if(r=this._invokeOne(function(s){return s!=this&&s.getDependency&&s.getDependency(e,t)}),!r)throw new Error("Unknown type: "+e);break}this.cache.add(n,r)}return r}getDependencies(e){let t=this.cache.get(e);if(!t){let n=this,r=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(r.map(function(s,o){return n.getDependency(e,o)})),this.cache.add(e,t)}return t}loadBuffer(e){let t=this.json.buffers[e],n=this.fileLoader;if(t.type&&t.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(t.uri===void 0&&e===0)return Promise.resolve(this.extensions[Pt.KHR_BINARY_GLTF].body);let r=this.options;return new Promise(function(s,o){n.load(Mi.resolveURL(t.uri,r.path),s,void 0,function(){o(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))})})}loadBufferView(e){let t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then(function(n){let r=t.byteLength||0,s=t.byteOffset||0;return n.slice(s,s+r)})}loadAccessor(e){let t=this,n=this.json,r=this.json.accessors[e];if(r.bufferView===void 0&&r.sparse===void 0){let o=$0[r.type],a=Dc[r.componentType],c=r.normalized===!0,l=new a(r.count*o);return Promise.resolve(new gt(l,o,c))}let s=[];return r.bufferView!==void 0?s.push(this.getDependency("bufferView",r.bufferView)):s.push(null),r.sparse!==void 0&&(s.push(this.getDependency("bufferView",r.sparse.indices.bufferView)),s.push(this.getDependency("bufferView",r.sparse.values.bufferView))),Promise.all(s).then(function(o){let a=o[0],c=$0[r.type],l=Dc[r.componentType],u=l.BYTES_PER_ELEMENT,h=u*c,d=r.byteOffset||0,m=r.bufferView!==void 0?n.bufferViews[r.bufferView].byteStride:void 0,g=r.normalized===!0,x,f;if(m&&m!==h){let p=Math.floor(d/m),v="InterleavedBuffer:"+r.bufferView+":"+r.componentType+":"+p+":"+r.count,_=t.cache.get(v);_||(x=new l(a,p*m,r.count*m/u),_=new Er(x,m/u),t.cache.add(v,_)),f=new ir(_,c,d%m/u,g)}else a===null?x=new l(r.count*c):x=new l(a,d,r.count*c),f=new gt(x,c,g);if(r.sparse!==void 0){let p=$0.SCALAR,v=Dc[r.sparse.indices.componentType],_=r.sparse.indices.byteOffset||0,y=r.sparse.values.byteOffset||0,b=new v(o[1],_,r.sparse.count*p),E=new l(o[2],y,r.sparse.count*c);a!==null&&(f=new gt(f.array.slice(),f.itemSize,f.normalized)),f.normalized=!1;for(let A=0,T=b.length;A<T;A++){let M=b[A];if(f.setX(M,E[A*c]),c>=2&&f.setY(M,E[A*c+1]),c>=3&&f.setZ(M,E[A*c+2]),c>=4&&f.setW(M,E[A*c+3]),c>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}f.normalized=g}return f})}loadTexture(e){let t=this.json,n=this.options,s=t.textures[e].source,o=t.images[s],a=this.textureLoader;if(o.uri){let c=n.manager.getHandler(o.uri);c!==null&&(a=c)}return this.loadTextureImage(e,s,a)}loadTextureImage(e,t,n){let r=this,s=this.json,o=s.textures[e],a=s.images[t],c=(a.uri||a.bufferView)+":"+o.sampler;if(this.textureCache[c])return this.textureCache[c];let l=this.loadImageSource(t,n).then(function(u){u.flipY=!1,u.name=o.name||a.name||"",u.name===""&&typeof a.uri=="string"&&a.uri.startsWith("data:image/")===!1&&(u.name=a.uri);let d=(s.samplers||{})[o.sampler]||{};return u.magFilter=Jb[d.magFilter]||nn,u.minFilter=Jb[d.minFilter]||Ei,u.wrapS=Qb[d.wrapS]||gn,u.wrapT=Qb[d.wrapT]||gn,u.generateMipmaps=!u.isCompressedTexture&&u.minFilter!==Jt&&u.minFilter!==nn,r.associations.set(u,{textures:e}),u}).catch(function(){return null});return this.textureCache[c]=l,l}loadImageSource(e,t){let n=this,r=this.json,s=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(h=>h.clone());let o=r.images[e],a=self.URL||self.webkitURL,c=o.uri||"",l=!1;if(o.bufferView!==void 0)c=n.getDependency("bufferView",o.bufferView).then(function(h){l=!0;let d=new Blob([h],{type:o.mimeType});return c=a.createObjectURL(d),c});else if(o.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");let u=Promise.resolve(c).then(function(h){return new Promise(function(d,m){let g=d;t.isImageBitmapLoader===!0&&(g=function(x){let f=new Qt(x);f.needsUpdate=!0,d(f)}),t.load(Mi.resolveURL(h,s.path),g,void 0,m)})}).then(function(h){return l===!0&&a.revokeObjectURL(c),ps(h,o),h.userData.mimeType=o.mimeType||cP(o.uri),h}).catch(function(h){throw console.error("THREE.GLTFLoader: Couldn't load texture",c),h});return this.sourceCache[e]=u,u}assignTexture(e,t,n,r){let s=this;return this.getDependency("texture",n.index).then(function(o){if(!o)return null;if(n.texCoord!==void 0&&n.texCoord>0&&(o=o.clone(),o.channel=n.texCoord),s.extensions[Pt.KHR_TEXTURE_TRANSFORM]){let a=n.extensions!==void 0?n.extensions[Pt.KHR_TEXTURE_TRANSFORM]:void 0;if(a){let c=s.associations.get(o);o=s.extensions[Pt.KHR_TEXTURE_TRANSFORM].extendTexture(o,a),s.associations.set(o,c)}}return r!==void 0&&(o.colorSpace=r),e[t]=o,o})}assignFinalMaterial(e){let t=e.geometry,n=e.material,r=t.attributes.tangent===void 0,s=t.attributes.color!==void 0,o=t.attributes.normal===void 0;if(e.isPoints){let a="PointsMaterial:"+n.uuid,c=this.cache.get(a);c||(c=new Sr,cn.prototype.copy.call(c,n),c.color.copy(n.color),c.map=n.map,c.sizeAttenuation=!1,this.cache.add(a,c)),n=c}else if(e.isLine){let a="LineBasicMaterial:"+n.uuid,c=this.cache.get(a);c||(c=new Xt,cn.prototype.copy.call(c,n),c.color.copy(n.color),c.map=n.map,this.cache.add(a,c)),n=c}if(r||s||o){let a="ClonedMaterial:"+n.uuid+":";r&&(a+="derivative-tangents:"),s&&(a+="vertex-colors:"),o&&(a+="flat-shading:");let c=this.cache.get(a);c||(c=n.clone(),s&&(c.vertexColors=!0),o&&(c.flatShading=!0),r&&(c.normalScale&&(c.normalScale.y*=-1),c.clearcoatNormalScale&&(c.clearcoatNormalScale.y*=-1)),this.cache.add(a,c),this.associations.set(c,this.associations.get(n))),n=c}e.material=n}getMaterialType(){return En}loadMaterial(e){let t=this,n=this.json,r=this.extensions,s=n.materials[e],o,a={},c=s.extensions||{},l=[];if(c[Pt.KHR_MATERIALS_UNLIT]){let h=r[Pt.KHR_MATERIALS_UNLIT];o=h.getMaterialType(),l.push(h.extendParams(a,s,t))}else{let h=s.pbrMetallicRoughness||{};if(a.color=new Ue(1,1,1),a.opacity=1,Array.isArray(h.baseColorFactor)){let d=h.baseColorFactor;a.color.setRGB(d[0],d[1],d[2],On),a.opacity=d[3]}h.baseColorTexture!==void 0&&l.push(t.assignTexture(a,"map",h.baseColorTexture,wt)),a.metalness=h.metallicFactor!==void 0?h.metallicFactor:1,a.roughness=h.roughnessFactor!==void 0?h.roughnessFactor:1,h.metallicRoughnessTexture!==void 0&&(l.push(t.assignTexture(a,"metalnessMap",h.metallicRoughnessTexture)),l.push(t.assignTexture(a,"roughnessMap",h.metallicRoughnessTexture))),o=this._invokeOne(function(d){return d.getMaterialType&&d.getMaterialType(e)}),l.push(Promise.all(this._invokeAll(function(d){return d.extendMaterialParams&&d.extendMaterialParams(e,a)})))}s.doubleSided===!0&&(a.side=xn);let u=s.alphaMode||ex.OPAQUE;if(u===ex.BLEND?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,u===ex.MASK&&(a.alphaTest=s.alphaCutoff!==void 0?s.alphaCutoff:.5)),s.normalTexture!==void 0&&o!==Ht&&(l.push(t.assignTexture(a,"normalMap",s.normalTexture)),a.normalScale=new Me(1,1),s.normalTexture.scale!==void 0)){let h=s.normalTexture.scale;a.normalScale.set(h,h)}if(s.occlusionTexture!==void 0&&o!==Ht&&(l.push(t.assignTexture(a,"aoMap",s.occlusionTexture)),s.occlusionTexture.strength!==void 0&&(a.aoMapIntensity=s.occlusionTexture.strength)),s.emissiveFactor!==void 0&&o!==Ht){let h=s.emissiveFactor;a.emissive=new Ue().setRGB(h[0],h[1],h[2],On)}return s.emissiveTexture!==void 0&&o!==Ht&&l.push(t.assignTexture(a,"emissiveMap",s.emissiveTexture,wt)),Promise.all(l).then(function(){let h=new o(a);return s.name&&(h.name=s.name),ps(h,s),t.associations.set(h,{materials:e}),s.extensions&&sa(r,h,s),h})}createUniqueName(e){let t=Ut.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){let t=this,n=this.extensions,r=this.primitiveCache;function s(a){return n[Pt.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(a,t).then(function(c){return $b(c,a,t)})}let o=[];for(let a=0,c=e.length;a<c;a++){let l=e[a],u=aP(l),h=r[u];if(h)o.push(h.promise);else{let d;l.extensions&&l.extensions[Pt.KHR_DRACO_MESH_COMPRESSION]?d=s(l):d=$b(new ot,l,t),r[u]={primitive:l,promise:d},o.push(d)}}return Promise.all(o)}loadMesh(e){let t=this,n=this.json,r=this.extensions,s=n.meshes[e],o=s.primitives,a=[];for(let c=0,l=o.length;c<l;c++){let u=o[c].material===void 0?rP(this.cache):this.getDependency("material",o[c].material);a.push(u)}return a.push(t.loadGeometries(o)),Promise.all(a).then(function(c){let l=c.slice(0,c.length-1),u=c[c.length-1],h=[];for(let m=0,g=u.length;m<g;m++){let x=u[m],f=o[m],p,v=l[m];if(f.mode===Yi.TRIANGLES||f.mode===Yi.TRIANGLE_STRIP||f.mode===Yi.TRIANGLE_FAN||f.mode===void 0)p=s.isSkinnedMesh===!0?new Oo(x,v):new ct(x,v),p.isSkinnedMesh===!0&&p.normalizeSkinWeights(),f.mode===Yi.TRIANGLE_STRIP?p.geometry=Q0(p.geometry,Cc):f.mode===Yi.TRIANGLE_FAN&&(p.geometry=Q0(p.geometry,Zo));else if(f.mode===Yi.LINES)p=new ln(x,v);else if(f.mode===Yi.LINE_STRIP)p=new ai(x,v);else if(f.mode===Yi.LINE_LOOP)p=new es(x,v);else if(f.mode===Yi.POINTS)p=new ts(x,v);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+f.mode);Object.keys(p.geometry.morphAttributes).length>0&&oP(p,s),p.name=t.createUniqueName(s.name||"mesh_"+e),ps(p,s),f.extensions&&sa(r,p,f),t.assignFinalMaterial(p),h.push(p)}for(let m=0,g=h.length;m<g;m++)t.associations.set(h[m],{meshes:e,primitives:m});if(h.length===1)return s.extensions&&sa(r,h[0],s),h[0];let d=new Dt;s.extensions&&sa(r,d,s),t.associations.set(d,{meshes:e});for(let m=0,g=h.length;m<g;m++)d.add(h[m]);return d})}loadCamera(e){let t,n=this.json.cameras[e],r=n[n.type];if(!r){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return n.type==="perspective"?t=new jt(Js.radToDeg(r.yfov),r.aspectRatio||1,r.znear||1,r.zfar||2e6):n.type==="orthographic"&&(t=new cr(-r.xmag,r.xmag,r.ymag,-r.ymag,r.znear,r.zfar)),n.name&&(t.name=this.createUniqueName(n.name)),ps(t,n),Promise.resolve(t)}loadSkin(e){let t=this.json.skins[e],n=[];for(let r=0,s=t.joints.length;r<s;r++)n.push(this._loadNodeShallow(t.joints[r]));return t.inverseBindMatrices!==void 0?n.push(this.getDependency("accessor",t.inverseBindMatrices)):n.push(null),Promise.all(n).then(function(r){let s=r.pop(),o=r,a=[],c=[];for(let l=0,u=o.length;l<u;l++){let h=o[l];if(h){a.push(h);let d=new nt;s!==null&&d.fromArray(s.array,l*16),c.push(d)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[l])}return new Do(a,c)})}loadAnimation(e){let t=this.json,n=this,r=t.animations[e],s=r.name?r.name:"animation_"+e,o=[],a=[],c=[],l=[],u=[];for(let h=0,d=r.channels.length;h<d;h++){let m=r.channels[h],g=r.samplers[m.sampler],x=m.target,f=x.node,p=r.parameters!==void 0?r.parameters[g.input]:g.input,v=r.parameters!==void 0?r.parameters[g.output]:g.output;x.node!==void 0&&(o.push(this.getDependency("node",f)),a.push(this.getDependency("accessor",p)),c.push(this.getDependency("accessor",v)),l.push(g),u.push(x))}return Promise.all([Promise.all(o),Promise.all(a),Promise.all(c),Promise.all(l),Promise.all(u)]).then(function(h){let d=h[0],m=h[1],g=h[2],x=h[3],f=h[4],p=[];for(let v=0,_=d.length;v<_;v++){let y=d[v],b=m[v],E=g[v],A=x[v],T=f[v];if(y===void 0)continue;y.updateMatrix&&y.updateMatrix();let M=n._createAnimationTracks(y,b,E,A,T);if(M)for(let S=0;S<M.length;S++)p.push(M[S])}return new Pr(s,void 0,p)})}createNodeMesh(e){let t=this.json,n=this,r=t.nodes[e];return r.mesh===void 0?null:n.getDependency("mesh",r.mesh).then(function(s){let o=n._getNodeRef(n.meshCache,r.mesh,s);return r.weights!==void 0&&o.traverse(function(a){if(a.isMesh)for(let c=0,l=r.weights.length;c<l;c++)a.morphTargetInfluences[c]=r.weights[c]}),o})}loadNode(e){let t=this.json,n=this,r=t.nodes[e],s=n._loadNodeShallow(e),o=[],a=r.children||[];for(let l=0,u=a.length;l<u;l++)o.push(n.getDependency("node",a[l]));let c=r.skin===void 0?Promise.resolve(null):n.getDependency("skin",r.skin);return Promise.all([s,Promise.all(o),c]).then(function(l){let u=l[0],h=l[1],d=l[2];d!==null&&u.traverse(function(m){m.isSkinnedMesh&&m.bind(d,lP)});for(let m=0,g=h.length;m<g;m++)u.add(h[m]);return u})}_loadNodeShallow(e){let t=this.json,n=this.extensions,r=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];let s=t.nodes[e],o=s.name?r.createUniqueName(s.name):"",a=[],c=r._invokeOne(function(l){return l.createNodeMesh&&l.createNodeMesh(e)});return c&&a.push(c),s.camera!==void 0&&a.push(r.getDependency("camera",s.camera).then(function(l){return r._getNodeRef(r.cameraCache,s.camera,l)})),r._invokeAll(function(l){return l.createNodeAttachment&&l.createNodeAttachment(e)}).forEach(function(l){a.push(l)}),this.nodeCache[e]=Promise.all(a).then(function(l){let u;if(s.isBone===!0?u=new Gs:l.length>1?u=new Dt:l.length===1?u=l[0]:u=new St,u!==l[0])for(let h=0,d=l.length;h<d;h++)u.add(l[h]);if(s.name&&(u.userData.name=s.name,u.name=o),ps(u,s),s.extensions&&sa(n,u,s),s.matrix!==void 0){let h=new nt;h.fromArray(s.matrix),u.applyMatrix4(h)}else s.translation!==void 0&&u.position.fromArray(s.translation),s.rotation!==void 0&&u.quaternion.fromArray(s.rotation),s.scale!==void 0&&u.scale.fromArray(s.scale);return r.associations.has(u)||r.associations.set(u,{}),r.associations.get(u).nodes=e,u}),this.nodeCache[e]}loadScene(e){let t=this.extensions,n=this.json.scenes[e],r=this,s=new Dt;n.name&&(s.name=r.createUniqueName(n.name)),ps(s,n),n.extensions&&sa(t,s,n);let o=n.nodes||[],a=[];for(let c=0,l=o.length;c<l;c++)a.push(r.getDependency("node",o[c]));return Promise.all(a).then(function(c){for(let u=0,h=c.length;u<h;u++)s.add(c[u]);let l=u=>{let h=new Map;for(let[d,m]of r.associations)(d instanceof cn||d instanceof Qt)&&h.set(d,m);return u.traverse(d=>{let m=r.associations.get(d);m!=null&&h.set(d,m)}),h};return r.associations=l(s),s})}_createAnimationTracks(e,t,n,r,s){let o=[],a=e.name?e.name:e.uuid,c=[];$s[s.path]===$s.weights?e.traverse(function(d){d.morphTargetInfluences&&c.push(d.name?d.name:d.uuid)}):c.push(a);let l;switch($s[s.path]){case $s.weights:l=rr;break;case $s.rotation:l=sr;break;case $s.position:case $s.scale:l=or;break;default:switch(n.itemSize){case 1:l=rr;break;case 2:case 3:default:l=or;break}break}let u=r.interpolation!==void 0?iP[r.interpolation]:zs,h=this._getArrayFromAccessor(n);for(let d=0,m=c.length;d<m;d++){let g=new l(c[d]+"."+$s[s.path],t.array,h,u);r.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(g),o.push(g)}return o}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){let n=Ax(t.constructor),r=new Float32Array(t.length);for(let s=0,o=t.length;s<o;s++)r[s]=t[s]*n;t=r}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(n){let r=this instanceof sr?Sx:Op;return new r(this.times,this.values,this.getValueSize()/3,n)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}};function uP(i,e,t){let n=e.attributes,r=new zt;if(n.POSITION!==void 0){let a=t.json.accessors[n.POSITION],c=a.min,l=a.max;if(c!==void 0&&l!==void 0){if(r.set(new z(c[0],c[1],c[2]),new z(l[0],l[1],l[2])),a.normalized){let u=Ax(Dc[a.componentType]);r.min.multiplyScalar(u),r.max.multiplyScalar(u)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;let s=e.targets;if(s!==void 0){let a=new z,c=new z;for(let l=0,u=s.length;l<u;l++){let h=s[l];if(h.POSITION!==void 0){let d=t.json.accessors[h.POSITION],m=d.min,g=d.max;if(m!==void 0&&g!==void 0){if(c.setX(Math.max(Math.abs(m[0]),Math.abs(g[0]))),c.setY(Math.max(Math.abs(m[1]),Math.abs(g[1]))),c.setZ(Math.max(Math.abs(m[2]),Math.abs(g[2]))),d.normalized){let x=Ax(Dc[d.componentType]);c.multiplyScalar(x)}a.max(c)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}r.expandByVector(a)}i.boundingBox=r;let o=new qt;r.getCenter(o.center),o.radius=r.min.distanceTo(r.max)/2,i.boundingSphere=o}function $b(i,e,t){let n=e.attributes,r=[];function s(o,a){return t.getDependency("accessor",o).then(function(c){i.setAttribute(a,c)})}for(let o in n){let a=Tx[o]||o.toLowerCase();a in i.attributes||r.push(s(n[o],a))}if(e.indices!==void 0&&!i.index){let o=t.getDependency("accessor",e.indices).then(function(a){i.setIndex(a)});r.push(o)}return _t.workingColorSpace!==On&&"COLOR_0"in n&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${_t.workingColorSpace}" not supported.`),ps(i,e),uP(i,e,t),Promise.all(r).then(function(){return e.targets!==void 0?sP(i,e.targets,t):i})}var Et=(i,e)=>()=>(e||(e={exports:{}},i(e.exports,e)),e.exports),tM=Et(i=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.VERSION=void 0,i.VERSION="9.0.1"}),Vt=Et((exports,module)=>{"use strict";var __spreadArray=exports&&exports.__spreadArray||function(i,e){for(var t=0,n=e.length,r=i.length;t<n;t++,r++)i[r]=e[t];return i};Object.defineProperty(exports,"__esModule",{value:!0}),exports.toFastProperties=exports.timer=exports.peek=exports.isES2015MapSupported=exports.PRINT_WARNING=exports.PRINT_ERROR=exports.packArray=exports.IDENTITY=exports.NOOP=exports.merge=exports.groupBy=exports.defaults=exports.assignNoOverwrite=exports.assign=exports.zipObject=exports.sortBy=exports.indexOf=exports.some=exports.difference=exports.every=exports.isObject=exports.isRegExp=exports.isArray=exports.partial=exports.uniq=exports.compact=exports.reduce=exports.findAll=exports.find=exports.cloneObj=exports.cloneArr=exports.contains=exports.has=exports.pick=exports.reject=exports.filter=exports.dropRight=exports.drop=exports.isFunction=exports.isUndefined=exports.isString=exports.forEach=exports.last=exports.first=exports.flatten=exports.map=exports.mapValues=exports.values=exports.keys=exports.isEmpty=void 0;function isEmpty(i){return i&&i.length===0}exports.isEmpty=isEmpty;function keys(i){return i==null?[]:Object.keys(i)}exports.keys=keys;function values(i){for(var e=[],t=Object.keys(i),n=0;n<t.length;n++)e.push(i[t[n]]);return e}exports.values=values;function mapValues(i,e){for(var t=[],n=keys(i),r=0;r<n.length;r++){var s=n[r];t.push(e.call(null,i[s],s))}return t}exports.mapValues=mapValues;function map(i,e){for(var t=[],n=0;n<i.length;n++)t.push(e.call(null,i[n],n));return t}exports.map=map;function flatten(i){for(var e=[],t=0;t<i.length;t++){var n=i[t];Array.isArray(n)?e=e.concat(flatten(n)):e.push(n)}return e}exports.flatten=flatten;function first(i){return isEmpty(i)?void 0:i[0]}exports.first=first;function last(i){var e=i&&i.length;return e?i[e-1]:void 0}exports.last=last;function forEach(i,e){if(Array.isArray(i))for(var t=0;t<i.length;t++)e.call(null,i[t],t);else if(isObject(i))for(var n=keys(i),t=0;t<n.length;t++){var r=n[t],s=i[r];e.call(null,s,r)}else throw Error("non exhaustive match")}exports.forEach=forEach;function isString(i){return typeof i=="string"}exports.isString=isString;function isUndefined(i){return i===void 0}exports.isUndefined=isUndefined;function isFunction(i){return i instanceof Function}exports.isFunction=isFunction;function drop(i,e){return e===void 0&&(e=1),i.slice(e,i.length)}exports.drop=drop;function dropRight(i,e){return e===void 0&&(e=1),i.slice(0,i.length-e)}exports.dropRight=dropRight;function filter(i,e){var t=[];if(Array.isArray(i))for(var n=0;n<i.length;n++){var r=i[n];e.call(null,r)&&t.push(r)}return t}exports.filter=filter;function reject(i,e){return filter(i,function(t){return!e(t)})}exports.reject=reject;function pick(i,e){for(var t=Object.keys(i),n={},r=0;r<t.length;r++){var s=t[r],o=i[s];e(o)&&(n[s]=o)}return n}exports.pick=pick;function has(i,e){return isObject(i)?i.hasOwnProperty(e):!1}exports.has=has;function contains(i,e){return find(i,function(t){return t===e})!==void 0}exports.contains=contains;function cloneArr(i){for(var e=[],t=0;t<i.length;t++)e.push(i[t]);return e}exports.cloneArr=cloneArr;function cloneObj(i){var e={};for(var t in i)Object.prototype.hasOwnProperty.call(i,t)&&(e[t]=i[t]);return e}exports.cloneObj=cloneObj;function find(i,e){for(var t=0;t<i.length;t++){var n=i[t];if(e.call(null,n))return n}}exports.find=find;function findAll(i,e){for(var t=[],n=0;n<i.length;n++){var r=i[n];e.call(null,r)&&t.push(r)}return t}exports.findAll=findAll;function reduce(i,e,t){for(var n=Array.isArray(i),r=n?i:values(i),s=n?[]:keys(i),o=t,a=0;a<r.length;a++)o=e.call(null,o,r[a],n?a:s[a]);return o}exports.reduce=reduce;function compact(i){return reject(i,function(e){return e==null})}exports.compact=compact;function uniq(i,e){e===void 0&&(e=function(n){return n});var t=[];return reduce(i,function(n,r){var s=e(r);return contains(t,s)?n:(t.push(s),n.concat(r))},[])}exports.uniq=uniq;function partial(i){for(var e=[],t=1;t<arguments.length;t++)e[t-1]=arguments[t];var n=[null],r=n.concat(e);return Function.bind.apply(i,r)}exports.partial=partial;function isArray(i){return Array.isArray(i)}exports.isArray=isArray;function isRegExp(i){return i instanceof RegExp}exports.isRegExp=isRegExp;function isObject(i){return i instanceof Object}exports.isObject=isObject;function every(i,e){for(var t=0;t<i.length;t++)if(!e(i[t],t))return!1;return!0}exports.every=every;function difference(i,e){return reject(i,function(t){return contains(e,t)})}exports.difference=difference;function some(i,e){for(var t=0;t<i.length;t++)if(e(i[t]))return!0;return!1}exports.some=some;function indexOf(i,e){for(var t=0;t<i.length;t++)if(i[t]===e)return t;return-1}exports.indexOf=indexOf;function sortBy(i,e){var t=cloneArr(i);return t.sort(function(n,r){return e(n)-e(r)}),t}exports.sortBy=sortBy;function zipObject(i,e){if(i.length!==e.length)throw Error("can't zipObject with different number of keys and values!");for(var t={},n=0;n<i.length;n++)t[i[n]]=e[n];return t}exports.zipObject=zipObject;function assign(i){for(var e=[],t=1;t<arguments.length;t++)e[t-1]=arguments[t];for(var n=0;n<e.length;n++)for(var r=e[n],s=keys(r),o=0;o<s.length;o++){var a=s[o];i[a]=r[a]}return i}exports.assign=assign;function assignNoOverwrite(i){for(var e=[],t=1;t<arguments.length;t++)e[t-1]=arguments[t];for(var n=0;n<e.length;n++)for(var r=e[n],s=keys(r),o=0;o<s.length;o++){var a=s[o];has(i,a)||(i[a]=r[a])}return i}exports.assignNoOverwrite=assignNoOverwrite;function defaults(){for(var i=[],e=0;e<arguments.length;e++)i[e]=arguments[e];return assignNoOverwrite.apply(void 0,__spreadArray([{}],i))}exports.defaults=defaults;function groupBy(i,e){var t={};return forEach(i,function(n){var r=e(n),s=t[r];s?s.push(n):t[r]=[n]}),t}exports.groupBy=groupBy;function merge(i,e){for(var t=cloneObj(i),n=keys(e),r=0;r<n.length;r++){var s=n[r],o=e[s];t[s]=o}return t}exports.merge=merge;function NOOP(){}exports.NOOP=NOOP;function IDENTITY(i){return i}exports.IDENTITY=IDENTITY;function packArray(i){for(var e=[],t=0;t<i.length;t++){var n=i[t];e.push(n!==void 0?n:void 0)}return e}exports.packArray=packArray;function PRINT_ERROR(i){console&&console.error&&console.error("Error: "+i)}exports.PRINT_ERROR=PRINT_ERROR;function PRINT_WARNING(i){console&&console.warn&&console.warn("Warning: "+i)}exports.PRINT_WARNING=PRINT_WARNING;function isES2015MapSupported(){return typeof Map=="function"}exports.isES2015MapSupported=isES2015MapSupported;function peek(i){return i[i.length-1]}exports.peek=peek;function timer(i){var e=new Date().getTime(),t=i(),n=new Date().getTime(),r=n-e;return{time:r,value:t}}exports.timer=timer;function toFastProperties(toBecomeFast){function FakeConstructor(){}FakeConstructor.prototype=toBecomeFast;var fakeInstance=new FakeConstructor;function fakeAccess(){return typeof fakeInstance.bar}return fakeAccess(),fakeAccess(),toBecomeFast}exports.toFastProperties=toFastProperties}),Rx=Et((i,e)=>{(function(t,n){typeof define=="function"&&define.amd?define([],n):typeof e=="object"&&e.exports?e.exports=n():t.regexpToAst=n()})(typeof self<"u"?self:i,function(){function t(){}t.prototype.saveState=function(){return{idx:this.idx,input:this.input,groupIdx:this.groupIdx}},t.prototype.restoreState=function(f){this.idx=f.idx,this.input=f.input,this.groupIdx=f.groupIdx},t.prototype.pattern=function(f){this.idx=0,this.input=f,this.groupIdx=0,this.consumeChar("/");var p=this.disjunction();this.consumeChar("/");for(var v={type:"Flags",loc:{begin:this.idx,end:f.length},global:!1,ignoreCase:!1,multiLine:!1,unicode:!1,sticky:!1};this.isRegExpFlag();)switch(this.popChar()){case"g":c(v,"global");break;case"i":c(v,"ignoreCase");break;case"m":c(v,"multiLine");break;case"u":c(v,"unicode");break;case"y":c(v,"sticky");break}if(this.idx!==this.input.length)throw Error("Redundant input: "+this.input.substring(this.idx));return{type:"Pattern",flags:v,value:p,loc:this.loc(0)}},t.prototype.disjunction=function(){var f=[],p=this.idx;for(f.push(this.alternative());this.peekChar()==="|";)this.consumeChar("|"),f.push(this.alternative());return{type:"Disjunction",value:f,loc:this.loc(p)}},t.prototype.alternative=function(){for(var f=[],p=this.idx;this.isTerm();)f.push(this.term());return{type:"Alternative",value:f,loc:this.loc(p)}},t.prototype.term=function(){return this.isAssertion()?this.assertion():this.atom()},t.prototype.assertion=function(){var f=this.idx;switch(this.popChar()){case"^":return{type:"StartAnchor",loc:this.loc(f)};case"$":return{type:"EndAnchor",loc:this.loc(f)};case"\\":switch(this.popChar()){case"b":return{type:"WordBoundary",loc:this.loc(f)};case"B":return{type:"NonWordBoundary",loc:this.loc(f)}}throw Error("Invalid Assertion Escape");case"(":this.consumeChar("?");var p;switch(this.popChar()){case"=":p="Lookahead";break;case"!":p="NegativeLookahead";break}l(p);var v=this.disjunction();return this.consumeChar(")"),{type:p,value:v,loc:this.loc(f)}}u()},t.prototype.quantifier=function(f){var p,v=this.idx;switch(this.popChar()){case"*":p={atLeast:0,atMost:1/0};break;case"+":p={atLeast:1,atMost:1/0};break;case"?":p={atLeast:0,atMost:1};break;case"{":var _=this.integerIncludingZero();switch(this.popChar()){case"}":p={atLeast:_,atMost:_};break;case",":var y;this.isDigit()?(y=this.integerIncludingZero(),p={atLeast:_,atMost:y}):p={atLeast:_,atMost:1/0},this.consumeChar("}");break}if(f===!0&&p===void 0)return;l(p);break}if(!(f===!0&&p===void 0))return l(p),this.peekChar(0)==="?"?(this.consumeChar("?"),p.greedy=!1):p.greedy=!0,p.type="Quantifier",p.loc=this.loc(v),p},t.prototype.atom=function(){var f,p=this.idx;switch(this.peekChar()){case".":f=this.dotAll();break;case"\\":f=this.atomEscape();break;case"[":f=this.characterClass();break;case"(":f=this.group();break}return f===void 0&&this.isPatternCharacter()&&(f=this.patternCharacter()),l(f),f.loc=this.loc(p),this.isQuantifier()&&(f.quantifier=this.quantifier()),f},t.prototype.dotAll=function(){return this.consumeChar("."),{type:"Set",complement:!0,value:[o(`
`),o("\r"),o("\u2028"),o("\u2029")]}},t.prototype.atomEscape=function(){switch(this.consumeChar("\\"),this.peekChar()){case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":return this.decimalEscapeAtom();case"d":case"D":case"s":case"S":case"w":case"W":return this.characterClassEscape();case"f":case"n":case"r":case"t":case"v":return this.controlEscapeAtom();case"c":return this.controlLetterEscapeAtom();case"0":return this.nulCharacterAtom();case"x":return this.hexEscapeSequenceAtom();case"u":return this.regExpUnicodeEscapeSequenceAtom();default:return this.identityEscapeAtom()}},t.prototype.decimalEscapeAtom=function(){var f=this.positiveInteger();return{type:"GroupBackReference",value:f}},t.prototype.characterClassEscape=function(){var f,p=!1;switch(this.popChar()){case"d":f=d;break;case"D":f=d,p=!0;break;case"s":f=g;break;case"S":f=g,p=!0;break;case"w":f=m;break;case"W":f=m,p=!0;break}return l(f),{type:"Set",value:f,complement:p}},t.prototype.controlEscapeAtom=function(){var f;switch(this.popChar()){case"f":f=o("\f");break;case"n":f=o(`
`);break;case"r":f=o("\r");break;case"t":f=o(" ");break;case"v":f=o("\v");break}return l(f),{type:"Character",value:f}},t.prototype.controlLetterEscapeAtom=function(){this.consumeChar("c");var f=this.popChar();if(/[a-zA-Z]/.test(f)===!1)throw Error("Invalid ");var p=f.toUpperCase().charCodeAt(0)-64;return{type:"Character",value:p}},t.prototype.nulCharacterAtom=function(){return this.consumeChar("0"),{type:"Character",value:o("\0")}},t.prototype.hexEscapeSequenceAtom=function(){return this.consumeChar("x"),this.parseHexDigits(2)},t.prototype.regExpUnicodeEscapeSequenceAtom=function(){return this.consumeChar("u"),this.parseHexDigits(4)},t.prototype.identityEscapeAtom=function(){var f=this.popChar();return{type:"Character",value:o(f)}},t.prototype.classPatternCharacterAtom=function(){switch(this.peekChar()){case`
`:case"\r":case"\u2028":case"\u2029":case"\\":case"]":throw Error("TBD");default:var f=this.popChar();return{type:"Character",value:o(f)}}},t.prototype.characterClass=function(){var f=[],p=!1;for(this.consumeChar("["),this.peekChar(0)==="^"&&(this.consumeChar("^"),p=!0);this.isClassAtom();){var v=this.classAtom(),_=v.type==="Character";if(_&&this.isRangeDash()){this.consumeChar("-");var y=this.classAtom(),b=y.type==="Character";if(b){if(y.value<v.value)throw Error("Range out of order in character class");f.push({from:v.value,to:y.value})}else a(v.value,f),f.push(o("-")),a(y.value,f)}else a(v.value,f)}return this.consumeChar("]"),{type:"Set",complement:p,value:f}},t.prototype.classAtom=function(){switch(this.peekChar()){case"]":case`
`:case"\r":case"\u2028":case"\u2029":throw Error("TBD");case"\\":return this.classEscape();default:return this.classPatternCharacterAtom()}},t.prototype.classEscape=function(){switch(this.consumeChar("\\"),this.peekChar()){case"b":return this.consumeChar("b"),{type:"Character",value:o("\b")};case"d":case"D":case"s":case"S":case"w":case"W":return this.characterClassEscape();case"f":case"n":case"r":case"t":case"v":return this.controlEscapeAtom();case"c":return this.controlLetterEscapeAtom();case"0":return this.nulCharacterAtom();case"x":return this.hexEscapeSequenceAtom();case"u":return this.regExpUnicodeEscapeSequenceAtom();default:return this.identityEscapeAtom()}},t.prototype.group=function(){var f=!0;switch(this.consumeChar("("),this.peekChar(0)){case"?":this.consumeChar("?"),this.consumeChar(":"),f=!1;break;default:this.groupIdx++;break}var p=this.disjunction();this.consumeChar(")");var v={type:"Group",capturing:f,value:p};return f&&(v.idx=this.groupIdx),v},t.prototype.positiveInteger=function(){var f=this.popChar();if(s.test(f)===!1)throw Error("Expecting a positive integer");for(;r.test(this.peekChar(0));)f+=this.popChar();return parseInt(f,10)},t.prototype.integerIncludingZero=function(){var f=this.popChar();if(r.test(f)===!1)throw Error("Expecting an integer");for(;r.test(this.peekChar(0));)f+=this.popChar();return parseInt(f,10)},t.prototype.patternCharacter=function(){var f=this.popChar();switch(f){case`
`:case"\r":case"\u2028":case"\u2029":case"^":case"$":case"\\":case".":case"*":case"+":case"?":case"(":case")":case"[":case"|":throw Error("TBD");default:return{type:"Character",value:o(f)}}},t.prototype.isRegExpFlag=function(){switch(this.peekChar(0)){case"g":case"i":case"m":case"u":case"y":return!0;default:return!1}},t.prototype.isRangeDash=function(){return this.peekChar()==="-"&&this.isClassAtom(1)},t.prototype.isDigit=function(){return r.test(this.peekChar(0))},t.prototype.isClassAtom=function(f){switch(f===void 0&&(f=0),this.peekChar(f)){case"]":case`
`:case"\r":case"\u2028":case"\u2029":return!1;default:return!0}},t.prototype.isTerm=function(){return this.isAtom()||this.isAssertion()},t.prototype.isAtom=function(){if(this.isPatternCharacter())return!0;switch(this.peekChar(0)){case".":case"\\":case"[":case"(":return!0;default:return!1}},t.prototype.isAssertion=function(){switch(this.peekChar(0)){case"^":case"$":return!0;case"\\":switch(this.peekChar(1)){case"b":case"B":return!0;default:return!1}case"(":return this.peekChar(1)==="?"&&(this.peekChar(2)==="="||this.peekChar(2)==="!");default:return!1}},t.prototype.isQuantifier=function(){var f=this.saveState();try{return this.quantifier(!0)!==void 0}catch{return!1}finally{this.restoreState(f)}},t.prototype.isPatternCharacter=function(){switch(this.peekChar()){case"^":case"$":case"\\":case".":case"*":case"+":case"?":case"(":case")":case"[":case"|":case"/":case`
`:case"\r":case"\u2028":case"\u2029":return!1;default:return!0}},t.prototype.parseHexDigits=function(f){for(var p="",v=0;v<f;v++){var _=this.popChar();if(n.test(_)===!1)throw Error("Expecting a HexDecimal digits");p+=_}var y=parseInt(p,16);return{type:"Character",value:y}},t.prototype.peekChar=function(f){return f===void 0&&(f=0),this.input[this.idx+f]},t.prototype.popChar=function(){var f=this.peekChar(0);return this.consumeChar(),f},t.prototype.consumeChar=function(f){if(f!==void 0&&this.input[this.idx]!==f)throw Error("Expected: '"+f+"' but found: '"+this.input[this.idx]+"' at offset: "+this.idx);if(this.idx>=this.input.length)throw Error("Unexpected end of input");this.idx++},t.prototype.loc=function(f){return{begin:f,end:this.idx}};var n=/[0-9a-fA-F]/,r=/[0-9]/,s=/[1-9]/;function o(f){return f.charCodeAt(0)}function a(f,p){f.length!==void 0?f.forEach(function(v){p.push(v)}):p.push(f)}function c(f,p){if(f[p]===!0)throw"duplicate flag "+p;f[p]=!0}function l(f){if(f===void 0)throw Error("Internal Error - Should never get here!")}function u(){throw Error("Internal Error - Should never get here!")}var h,d=[];for(h=o("0");h<=o("9");h++)d.push(h);var m=[o("_")].concat(d);for(h=o("a");h<=o("z");h++)m.push(h);for(h=o("A");h<=o("Z");h++)m.push(h);var g=[o(" "),o("\f"),o(`
`),o("\r"),o(" "),o("\v"),o(" "),o("\xA0"),o("\u1680"),o("\u2000"),o("\u2001"),o("\u2002"),o("\u2003"),o("\u2004"),o("\u2005"),o("\u2006"),o("\u2007"),o("\u2008"),o("\u2009"),o("\u200A"),o("\u2028"),o("\u2029"),o("\u202F"),o("\u205F"),o("\u3000"),o("\uFEFF")];function x(){}return x.prototype.visitChildren=function(f){for(var p in f){var v=f[p];f.hasOwnProperty(p)&&(v.type!==void 0?this.visit(v):Array.isArray(v)&&v.forEach(function(_){this.visit(_)},this))}},x.prototype.visit=function(f){switch(f.type){case"Pattern":this.visitPattern(f);break;case"Flags":this.visitFlags(f);break;case"Disjunction":this.visitDisjunction(f);break;case"Alternative":this.visitAlternative(f);break;case"StartAnchor":this.visitStartAnchor(f);break;case"EndAnchor":this.visitEndAnchor(f);break;case"WordBoundary":this.visitWordBoundary(f);break;case"NonWordBoundary":this.visitNonWordBoundary(f);break;case"Lookahead":this.visitLookahead(f);break;case"NegativeLookahead":this.visitNegativeLookahead(f);break;case"Character":this.visitCharacter(f);break;case"Set":this.visitSet(f);break;case"Group":this.visitGroup(f);break;case"GroupBackReference":this.visitGroupBackReference(f);break;case"Quantifier":this.visitQuantifier(f);break}this.visitChildren(f)},x.prototype.visitPattern=function(f){},x.prototype.visitFlags=function(f){},x.prototype.visitDisjunction=function(f){},x.prototype.visitAlternative=function(f){},x.prototype.visitStartAnchor=function(f){},x.prototype.visitEndAnchor=function(f){},x.prototype.visitWordBoundary=function(f){},x.prototype.visitNonWordBoundary=function(f){},x.prototype.visitLookahead=function(f){},x.prototype.visitNegativeLookahead=function(f){},x.prototype.visitCharacter=function(f){},x.prototype.visitSet=function(f){},x.prototype.visitGroup=function(f){},x.prototype.visitGroupBackReference=function(f){},x.prototype.visitQuantifier=function(f){},{RegExpParser:t,BaseRegExpVisitor:x,VERSION:"0.5.0"}})}),Cx=Et(i=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.clearRegExpParserCache=i.getRegExpAst=void 0;var e=Rx(),t={},n=new e.RegExpParser;function r(o){var a=o.toString();if(t.hasOwnProperty(a))return t[a];var c=n.pattern(a);return t[a]=c,c}i.getRegExpAst=r;function s(){t={}}i.clearRegExpParserCache=s}),hP=Et(i=>{"use strict";var e=i&&i.__extends||(function(){var x=function(f,p){return x=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(v,_){v.__proto__=_}||function(v,_){for(var y in _)Object.prototype.hasOwnProperty.call(_,y)&&(v[y]=_[y])},x(f,p)};return function(f,p){if(typeof p!="function"&&p!==null)throw new TypeError("Class extends value "+String(p)+" is not a constructor or null");x(f,p);function v(){this.constructor=f}f.prototype=p===null?Object.create(p):(v.prototype=p.prototype,new v)}})();Object.defineProperty(i,"__esModule",{value:!0}),i.canMatchCharCode=i.firstCharOptimizedIndices=i.getOptimizedStartCodesIndices=i.failedOptimizationPrefixMsg=void 0;var t=Rx(),n=Vt(),r=Cx(),s=nM(),o="Complement Sets are not supported for first char optimization";i.failedOptimizationPrefixMsg=`Unable to use "first char" lexer optimizations:
`;function a(x,f){f===void 0&&(f=!1);try{var p=r.getRegExpAst(x),v=c(p.value,{},p.flags.ignoreCase);return v}catch(y){if(y.message===o)f&&n.PRINT_WARNING(""+i.failedOptimizationPrefixMsg+(" Unable to optimize: < "+x.toString()+` >
`)+` Complement Sets cannot be automatically optimized.
This will disable the lexer's first char optimizations.
See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#COMPLEMENT for details.`);else{var _="";f&&(_=`
This will disable the lexer's first char optimizations.
See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#REGEXP_PARSING for details.`),n.PRINT_ERROR(i.failedOptimizationPrefixMsg+`
`+(" Failed parsing: < "+x.toString()+` >
`)+(" Using the regexp-to-ast library version: "+t.VERSION+`
`)+" Please open an issue at: https://github.com/bd82/regexp-to-ast/issues"+_)}}return[]}i.getOptimizedStartCodesIndices=a;function c(x,f,p){switch(x.type){case"Disjunction":for(var v=0;v<x.value.length;v++)c(x.value[v],f,p);break;case"Alternative":for(var _=x.value,v=0;v<_.length;v++){var y=_[v];switch(y.type){case"EndAnchor":case"GroupBackReference":case"Lookahead":case"NegativeLookahead":case"StartAnchor":case"WordBoundary":case"NonWordBoundary":continue}var b=y;switch(b.type){case"Character":l(b.value,f,p);break;case"Set":if(b.complement===!0)throw Error(o);n.forEach(b.value,function(T){if(typeof T=="number")l(T,f,p);else{var M=T;if(p===!0)for(var S=M.from;S<=M.to;S++)l(S,f,p);else{for(var S=M.from;S<=M.to&&S<s.minOptimizationVal;S++)l(S,f,p);if(M.to>=s.minOptimizationVal)for(var C=M.from>=s.minOptimizationVal?M.from:s.minOptimizationVal,N=M.to,I=s.charCodeToOptimizedIndex(C),L=s.charCodeToOptimizedIndex(N),q=I;q<=L;q++)f[q]=q}}});break;case"Group":c(b.value,f,p);break;default:throw Error("Non Exhaustive Match")}var E=b.quantifier!==void 0&&b.quantifier.atLeast===0;if(b.type==="Group"&&d(b)===!1||b.type!=="Group"&&E===!1)break}break;default:throw Error("non exhaustive match!")}return n.values(f)}i.firstCharOptimizedIndices=c;function l(x,f,p){var v=s.charCodeToOptimizedIndex(x);f[v]=v,p===!0&&u(x,f)}function u(x,f){var p=String.fromCharCode(x),v=p.toUpperCase();if(v!==p){var _=s.charCodeToOptimizedIndex(v.charCodeAt(0));f[_]=_}else{var y=p.toLowerCase();if(y!==p){var _=s.charCodeToOptimizedIndex(y.charCodeAt(0));f[_]=_}}}function h(x,f){return n.find(x.value,function(p){if(typeof p=="number")return n.contains(f,p);var v=p;return n.find(f,function(_){return v.from<=_&&_<=v.to})!==void 0})}function d(x){return x.quantifier&&x.quantifier.atLeast===0?!0:x.value?n.isArray(x.value)?n.every(x.value,d):d(x.value):!1}var m=(function(x){e(f,x);function f(p){var v=x.call(this)||this;return v.targetCharCodes=p,v.found=!1,v}return f.prototype.visitChildren=function(p){if(this.found!==!0){switch(p.type){case"Lookahead":this.visitLookahead(p);return;case"NegativeLookahead":this.visitNegativeLookahead(p);return}x.prototype.visitChildren.call(this,p)}},f.prototype.visitCharacter=function(p){n.contains(this.targetCharCodes,p.value)&&(this.found=!0)},f.prototype.visitSet=function(p){p.complement?h(p,this.targetCharCodes)===void 0&&(this.found=!0):h(p,this.targetCharCodes)!==void 0&&(this.found=!0)},f})(t.BaseRegExpVisitor);function g(x,f){if(f instanceof RegExp){var p=r.getRegExpAst(f),v=new m(x);return v.visit(p),v.found}else return n.find(f,function(_){return n.contains(x,_.charCodeAt(0))})!==void 0}i.canMatchCharCode=g}),nM=Et(i=>{"use strict";var e=i&&i.__extends||(function(){var w=function(O,W){return w=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(Q,ee){Q.__proto__=ee}||function(Q,ee){for(var he in ee)Object.prototype.hasOwnProperty.call(ee,he)&&(Q[he]=ee[he])},w(O,W)};return function(O,W){if(typeof W!="function"&&W!==null)throw new TypeError("Class extends value "+String(W)+" is not a constructor or null");w(O,W);function Q(){this.constructor=O}O.prototype=W===null?Object.create(W):(Q.prototype=W.prototype,new Q)}})();Object.defineProperty(i,"__esModule",{value:!0}),i.charCodeToOptimizedIndex=i.minOptimizationVal=i.buildLineBreakIssueMessage=i.LineTerminatorOptimizedTester=i.isShortPattern=i.isCustomPattern=i.cloneEmptyGroups=i.performWarningRuntimeChecks=i.performRuntimeChecks=i.addStickyFlag=i.addStartOfInput=i.findUnreachablePatterns=i.findModesThatDoNotExist=i.findInvalidGroupType=i.findDuplicatePatterns=i.findUnsupportedFlags=i.findStartOfInputAnchor=i.findEmptyMatchRegExps=i.findEndOfInputAnchor=i.findInvalidPatterns=i.findMissingPatterns=i.validatePatterns=i.analyzeTokenTypes=i.enableSticky=i.disableSticky=i.SUPPORT_STICKY=i.MODES=i.DEFAULT_MODE=void 0;var t=Rx(),n=Dp(),r=Vt(),s=hP(),o=Cx(),a="PATTERN";i.DEFAULT_MODE="defaultMode",i.MODES="modes",i.SUPPORT_STICKY=typeof new RegExp("(?:)").sticky=="boolean";function c(){i.SUPPORT_STICKY=!1}i.disableSticky=c;function l(){i.SUPPORT_STICKY=!0}i.enableSticky=l;function u(w,O){O=r.defaults(O,{useSticky:i.SUPPORT_STICKY,debug:!1,safeMode:!1,positionTracking:"full",lineTerminatorCharacters:["\r",`
`],tracer:function(D,P){return P()}});var W=O.tracer;W("initCharCodeToOptimizedIndexMap",function(){V()});var Q;W("Reject Lexer.NA",function(){Q=r.reject(w,function(D){return D[a]===n.Lexer.NA})});var ee=!1,he;W("Transform Patterns",function(){ee=!1,he=r.map(Q,function(D){var P=D[a];if(r.isRegExp(P)){var U=P.source;return U.length===1&&U!=="^"&&U!=="$"&&U!=="."&&!P.ignoreCase?U:U.length===2&&U[0]==="\\"&&!r.contains(["d","D","s","S","t","r","n","t","0","c","b","B","f","v","w","W"],U[1])?U[1]:O.useSticky?N(P):C(P)}else{if(r.isFunction(P))return ee=!0,{exec:P};if(r.has(P,"exec"))return ee=!0,P;if(typeof P=="string"){if(P.length===1)return P;var X=P.replace(/[\\^$.*+?()[\]{}|]/g,"\\$&"),Z=new RegExp(X);return O.useSticky?N(Z):C(Z)}else throw Error("non exhaustive match")}})});var Ce,oe,ue,H,Ie;W("misc mapping",function(){Ce=r.map(Q,function(D){return D.tokenTypeIdx}),oe=r.map(Q,function(D){var P=D.GROUP;if(P!==n.Lexer.SKIPPED){if(r.isString(P))return P;if(r.isUndefined(P))return!1;throw Error("non exhaustive match")}}),ue=r.map(Q,function(D){var P=D.LONGER_ALT;if(P){var U=r.indexOf(Q,P);return U}}),H=r.map(Q,function(D){return D.PUSH_MODE}),Ie=r.map(Q,function(D){return r.has(D,"POP_MODE")})});var Te;W("Line Terminator Handling",function(){var D=se(O.lineTerminatorCharacters);Te=r.map(Q,function(P){return!1}),O.positionTracking!=="onlyOffset"&&(Te=r.map(Q,function(P){if(r.has(P,"LINE_BREAKS"))return P.LINE_BREAKS;if(j(P,D)===!1)return s.canMatchCharCode(D,P.PATTERN)}))});var Oe,Re,We,Ae;W("Misc Mapping #2",function(){Oe=r.map(Q,K),Re=r.map(he,B),We=r.reduce(Q,function(D,P){var U=P.GROUP;return r.isString(U)&&U!==n.Lexer.SKIPPED&&(D[U]=[]),D},{}),Ae=r.map(he,function(D,P){return{pattern:he[P],longerAlt:ue[P],canLineTerminator:Te[P],isCustom:Oe[P],short:Re[P],group:oe[P],push:H[P],pop:Ie[P],tokenTypeIdx:Ce[P],tokenType:Q[P]}})});var Y=!0,F=[];return O.safeMode||W("First Char Optimization",function(){F=r.reduce(Q,function(D,P,U){if(typeof P.PATTERN=="string"){var X=P.PATTERN.charCodeAt(0),Z=Se(X);ce(D,Z,Ae[U])}else if(r.isArray(P.START_CHARS_HINT)){var $;r.forEach(P.START_CHARS_HINT,function(ae){var re=typeof ae=="string"?ae.charCodeAt(0):ae,ge=Se(re);$!==ge&&($=ge,ce(D,ge,Ae[U]))})}else if(r.isRegExp(P.PATTERN))if(P.PATTERN.unicode)Y=!1,O.ensureOptimizations&&r.PRINT_ERROR(""+s.failedOptimizationPrefixMsg+(" Unable to analyze < "+P.PATTERN.toString()+` > pattern.
`)+` The regexp unicode flag is not currently supported by the regexp-to-ast library.
This will disable the lexer's first char optimizations.
For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#UNICODE_OPTIMIZE`);else{var te=s.getOptimizedStartCodesIndices(P.PATTERN,O.ensureOptimizations);r.isEmpty(te)&&(Y=!1),r.forEach(te,function(ae){ce(D,ae,Ae[U])})}else O.ensureOptimizations&&r.PRINT_ERROR(""+s.failedOptimizationPrefixMsg+(" TokenType: <"+P.name+`> is using a custom token pattern without providing <start_chars_hint> parameter.
`)+` This will disable the lexer's first char optimizations.
For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#CUSTOM_OPTIMIZE`),Y=!1;return D},[])}),W("ArrayPacking",function(){F=r.packArray(F)}),{emptyGroups:We,patternIdxToConfig:Ae,charCodeToPatternIdxToConfig:F,hasCustom:ee,canBeOptimized:Y}}i.analyzeTokenTypes=u;function h(w,O){var W=[],Q=m(w);W=W.concat(Q.errors);var ee=g(Q.valid),he=ee.valid;return W=W.concat(ee.errors),W=W.concat(d(he)),W=W.concat(E(he)),W=W.concat(A(he,O)),W=W.concat(T(he)),W}i.validatePatterns=h;function d(w){var O=[],W=r.filter(w,function(Q){return r.isRegExp(Q[a])});return O=O.concat(f(W)),O=O.concat(_(W)),O=O.concat(y(W)),O=O.concat(b(W)),O=O.concat(p(W)),O}function m(w){var O=r.filter(w,function(ee){return!r.has(ee,a)}),W=r.map(O,function(ee){return{message:"Token Type: ->"+ee.name+"<- missing static 'PATTERN' property",type:n.LexerDefinitionErrorType.MISSING_PATTERN,tokenTypes:[ee]}}),Q=r.difference(w,O);return{errors:W,valid:Q}}i.findMissingPatterns=m;function g(w){var O=r.filter(w,function(ee){var he=ee[a];return!r.isRegExp(he)&&!r.isFunction(he)&&!r.has(he,"exec")&&!r.isString(he)}),W=r.map(O,function(ee){return{message:"Token Type: ->"+ee.name+"<- static 'PATTERN' can only be a RegExp, a Function matching the {CustomPatternMatcherFunc} type or an Object matching the {ICustomPattern} interface.",type:n.LexerDefinitionErrorType.INVALID_PATTERN,tokenTypes:[ee]}}),Q=r.difference(w,O);return{errors:W,valid:Q}}i.findInvalidPatterns=g;var x=/[^\\][\$]/;function f(w){var O=(function(ee){e(he,ee);function he(){var Ce=ee!==null&&ee.apply(this,arguments)||this;return Ce.found=!1,Ce}return he.prototype.visitEndAnchor=function(Ce){this.found=!0},he})(t.BaseRegExpVisitor),W=r.filter(w,function(ee){var he=ee[a];try{var Ce=o.getRegExpAst(he),oe=new O;return oe.visit(Ce),oe.found}catch{return x.test(he.source)}}),Q=r.map(W,function(ee){return{message:`Unexpected RegExp Anchor Error:
Token Type: ->`+ee.name+`<- static 'PATTERN' cannot contain end of input anchor '$'
See chevrotain.io/docs/guide/resolving_lexer_errors.html#ANCHORS for details.`,type:n.LexerDefinitionErrorType.EOI_ANCHOR_FOUND,tokenTypes:[ee]}});return Q}i.findEndOfInputAnchor=f;function p(w){var O=r.filter(w,function(Q){var ee=Q[a];return ee.test("")}),W=r.map(O,function(Q){return{message:"Token Type: ->"+Q.name+"<- static 'PATTERN' must not match an empty string",type:n.LexerDefinitionErrorType.EMPTY_MATCH_PATTERN,tokenTypes:[Q]}});return W}i.findEmptyMatchRegExps=p;var v=/[^\\[][\^]|^\^/;function _(w){var O=(function(ee){e(he,ee);function he(){var Ce=ee!==null&&ee.apply(this,arguments)||this;return Ce.found=!1,Ce}return he.prototype.visitStartAnchor=function(Ce){this.found=!0},he})(t.BaseRegExpVisitor),W=r.filter(w,function(ee){var he=ee[a];try{var Ce=o.getRegExpAst(he),oe=new O;return oe.visit(Ce),oe.found}catch{return v.test(he.source)}}),Q=r.map(W,function(ee){return{message:`Unexpected RegExp Anchor Error:
Token Type: ->`+ee.name+`<- static 'PATTERN' cannot contain start of input anchor '^'
See https://chevrotain.io/docs/guide/resolving_lexer_errors.html#ANCHORS for details.`,type:n.LexerDefinitionErrorType.SOI_ANCHOR_FOUND,tokenTypes:[ee]}});return Q}i.findStartOfInputAnchor=_;function y(w){var O=r.filter(w,function(Q){var ee=Q[a];return ee instanceof RegExp&&(ee.multiline||ee.global)}),W=r.map(O,function(Q){return{message:"Token Type: ->"+Q.name+"<- static 'PATTERN' may NOT contain global('g') or multiline('m')",type:n.LexerDefinitionErrorType.UNSUPPORTED_FLAGS_FOUND,tokenTypes:[Q]}});return W}i.findUnsupportedFlags=y;function b(w){var O=[],W=r.map(w,function(he){return r.reduce(w,function(Ce,oe){return he.PATTERN.source===oe.PATTERN.source&&!r.contains(O,oe)&&oe.PATTERN!==n.Lexer.NA&&(O.push(oe),Ce.push(oe)),Ce},[])});W=r.compact(W);var Q=r.filter(W,function(he){return he.length>1}),ee=r.map(Q,function(he){var Ce=r.map(he,function(ue){return ue.name}),oe=r.first(he).PATTERN;return{message:"The same RegExp pattern ->"+oe+"<-"+("has been used in all of the following Token Types: "+Ce.join(", ")+" <-"),type:n.LexerDefinitionErrorType.DUPLICATE_PATTERNS_FOUND,tokenTypes:he}});return ee}i.findDuplicatePatterns=b;function E(w){var O=r.filter(w,function(Q){if(!r.has(Q,"GROUP"))return!1;var ee=Q.GROUP;return ee!==n.Lexer.SKIPPED&&ee!==n.Lexer.NA&&!r.isString(ee)}),W=r.map(O,function(Q){return{message:"Token Type: ->"+Q.name+"<- static 'GROUP' can only be Lexer.SKIPPED/Lexer.NA/A String",type:n.LexerDefinitionErrorType.INVALID_GROUP_TYPE_FOUND,tokenTypes:[Q]}});return W}i.findInvalidGroupType=E;function A(w,O){var W=r.filter(w,function(ee){return ee.PUSH_MODE!==void 0&&!r.contains(O,ee.PUSH_MODE)}),Q=r.map(W,function(ee){var he="Token Type: ->"+ee.name+"<- static 'PUSH_MODE' value cannot refer to a Lexer Mode ->"+ee.PUSH_MODE+"<-which does not exist";return{message:he,type:n.LexerDefinitionErrorType.PUSH_MODE_DOES_NOT_EXIST,tokenTypes:[ee]}});return Q}i.findModesThatDoNotExist=A;function T(w){var O=[],W=r.reduce(w,function(Q,ee,he){var Ce=ee.PATTERN;return Ce===n.Lexer.NA||(r.isString(Ce)?Q.push({str:Ce,idx:he,tokenType:ee}):r.isRegExp(Ce)&&S(Ce)&&Q.push({str:Ce.source,idx:he,tokenType:ee})),Q},[]);return r.forEach(w,function(Q,ee){r.forEach(W,function(he){var Ce=he.str,oe=he.idx,ue=he.tokenType;if(ee<oe&&M(Ce,Q.PATTERN)){var H="Token: ->"+ue.name+`<- can never be matched.
`+("Because it appears AFTER the Token Type ->"+Q.name+"<-")+`in the lexer's definition.
See https://chevrotain.io/docs/guide/resolving_lexer_errors.html#UNREACHABLE`;O.push({message:H,type:n.LexerDefinitionErrorType.UNREACHABLE_PATTERN,tokenTypes:[Q,ue]})}})}),O}i.findUnreachablePatterns=T;function M(w,O){if(r.isRegExp(O)){var W=O.exec(w);return W!==null&&W.index===0}else{if(r.isFunction(O))return O(w,0,[],{});if(r.has(O,"exec"))return O.exec(w,0,[],{});if(typeof O=="string")return O===w;throw Error("non exhaustive match")}}function S(w){var O=[".","\\","[","]","|","^","$","(",")","?","*","+","{"];return r.find(O,function(W){return w.source.indexOf(W)!==-1})===void 0}function C(w){var O=w.ignoreCase?"i":"";return new RegExp("^(?:"+w.source+")",O)}i.addStartOfInput=C;function N(w){var O=w.ignoreCase?"iy":"y";return new RegExp(""+w.source,O)}i.addStickyFlag=N;function I(w,O,W){var Q=[];return r.has(w,i.DEFAULT_MODE)||Q.push({message:"A MultiMode Lexer cannot be initialized without a <"+i.DEFAULT_MODE+`> property in its definition
`,type:n.LexerDefinitionErrorType.MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE}),r.has(w,i.MODES)||Q.push({message:"A MultiMode Lexer cannot be initialized without a <"+i.MODES+`> property in its definition
`,type:n.LexerDefinitionErrorType.MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY}),r.has(w,i.MODES)&&r.has(w,i.DEFAULT_MODE)&&!r.has(w.modes,w.defaultMode)&&Q.push({message:"A MultiMode Lexer cannot be initialized with a "+i.DEFAULT_MODE+": <"+w.defaultMode+`>which does not exist
`,type:n.LexerDefinitionErrorType.MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST}),r.has(w,i.MODES)&&r.forEach(w.modes,function(ee,he){r.forEach(ee,function(Ce,oe){r.isUndefined(Ce)&&Q.push({message:"A Lexer cannot be initialized using an undefined Token Type. Mode:"+("<"+he+"> at index: <"+oe+`>
`),type:n.LexerDefinitionErrorType.LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED})})}),Q}i.performRuntimeChecks=I;function L(w,O,W){var Q=[],ee=!1,he=r.compact(r.flatten(r.mapValues(w.modes,function(ue){return ue}))),Ce=r.reject(he,function(ue){return ue[a]===n.Lexer.NA}),oe=se(W);return O&&r.forEach(Ce,function(ue){var H=j(ue,oe);if(H!==!1){var Ie=J(ue,H),Te={message:Ie,type:H.issue,tokenType:ue};Q.push(Te)}else r.has(ue,"LINE_BREAKS")?ue.LINE_BREAKS===!0&&(ee=!0):s.canMatchCharCode(oe,ue.PATTERN)&&(ee=!0)}),O&&!ee&&Q.push({message:`Warning: No LINE_BREAKS Found.
This Lexer has been defined to track line and column information,
But none of the Token Types can be identified as matching a line terminator.
See https://chevrotain.io/docs/guide/resolving_lexer_errors.html#LINE_BREAKS
for details.`,type:n.LexerDefinitionErrorType.NO_LINE_BREAKS_FLAGS}),Q}i.performWarningRuntimeChecks=L;function q(w){var O={},W=r.keys(w);return r.forEach(W,function(Q){var ee=w[Q];if(r.isArray(ee))O[Q]=[];else throw Error("non exhaustive match")}),O}i.cloneEmptyGroups=q;function K(w){var O=w.PATTERN;if(r.isRegExp(O))return!1;if(r.isFunction(O)||r.has(O,"exec"))return!0;if(r.isString(O))return!1;throw Error("non exhaustive match")}i.isCustomPattern=K;function B(w){return r.isString(w)&&w.length===1?w.charCodeAt(0):!1}i.isShortPattern=B,i.LineTerminatorOptimizedTester={test:function(w){for(var O=w.length,W=this.lastIndex;W<O;W++){var Q=w.charCodeAt(W);if(Q===10)return this.lastIndex=W+1,!0;if(Q===13)return w.charCodeAt(W+1)===10?this.lastIndex=W+2:this.lastIndex=W+1,!0}return!1},lastIndex:0};function j(w,O){if(r.has(w,"LINE_BREAKS"))return!1;if(r.isRegExp(w.PATTERN)){try{s.canMatchCharCode(O,w.PATTERN)}catch(W){return{issue:n.LexerDefinitionErrorType.IDENTIFY_TERMINATOR,errMsg:W.message}}return!1}else{if(r.isString(w.PATTERN))return!1;if(K(w))return{issue:n.LexerDefinitionErrorType.CUSTOM_LINE_BREAK};throw Error("non exhaustive match")}}function J(w,O){if(O.issue===n.LexerDefinitionErrorType.IDENTIFY_TERMINATOR)return`Warning: unable to identify line terminator usage in pattern.
`+(" The problem is in the <"+w.name+`> Token Type
`)+(" Root cause: "+O.errMsg+`.
`)+" For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#IDENTIFY_TERMINATOR";if(O.issue===n.LexerDefinitionErrorType.CUSTOM_LINE_BREAK)return`Warning: A Custom Token Pattern should specify the <line_breaks> option.
`+(" The problem is in the <"+w.name+`> Token Type
`)+" For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#CUSTOM_LINE_BREAK";throw Error("non exhaustive match")}i.buildLineBreakIssueMessage=J;function se(w){var O=r.map(w,function(W){return r.isString(W)&&W.length>0?W.charCodeAt(0):W});return O}function ce(w,O,W){w[O]===void 0?w[O]=[W]:w[O].push(W)}i.minOptimizationVal=256;var me=[];function Se(w){return w<i.minOptimizationVal?w:me[w]}i.charCodeToOptimizedIndex=Se;function V(){if(r.isEmpty(me)){me=new Array(65536);for(var w=0;w<65536;w++)me[w]=w>255?255+~~(w/255):w}}}),Th=Et(i=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.isTokenType=i.hasExtendingTokensTypesMapProperty=i.hasExtendingTokensTypesProperty=i.hasCategoriesProperty=i.hasShortKeyProperty=i.singleAssignCategoriesToksMap=i.assignCategoriesMapProp=i.assignCategoriesTokensProp=i.assignTokenDefaultProps=i.expandCategories=i.augmentTokenTypes=i.tokenIdxToClass=i.tokenShortNameIdx=i.tokenStructuredMatcherNoCategories=i.tokenStructuredMatcher=void 0;var e=Vt();function t(x,f){var p=x.tokenTypeIdx;return p===f.tokenTypeIdx?!0:f.isParent===!0&&f.categoryMatchesMap[p]===!0}i.tokenStructuredMatcher=t;function n(x,f){return x.tokenTypeIdx===f.tokenTypeIdx}i.tokenStructuredMatcherNoCategories=n,i.tokenShortNameIdx=1,i.tokenIdxToClass={};function r(x){var f=s(x);o(f),c(f),a(f),e.forEach(f,function(p){p.isParent=p.categoryMatches.length>0})}i.augmentTokenTypes=r;function s(x){for(var f=e.cloneArr(x),p=x,v=!0;v;){p=e.compact(e.flatten(e.map(p,function(y){return y.CATEGORIES})));var _=e.difference(p,f);f=f.concat(_),e.isEmpty(_)?v=!1:p=_}return f}i.expandCategories=s;function o(x){e.forEach(x,function(f){u(f)||(i.tokenIdxToClass[i.tokenShortNameIdx]=f,f.tokenTypeIdx=i.tokenShortNameIdx++),h(f)&&!e.isArray(f.CATEGORIES)&&(f.CATEGORIES=[f.CATEGORIES]),h(f)||(f.CATEGORIES=[]),d(f)||(f.categoryMatches=[]),m(f)||(f.categoryMatchesMap={})})}i.assignTokenDefaultProps=o;function a(x){e.forEach(x,function(f){f.categoryMatches=[],e.forEach(f.categoryMatchesMap,function(p,v){f.categoryMatches.push(i.tokenIdxToClass[v].tokenTypeIdx)})})}i.assignCategoriesTokensProp=a;function c(x){e.forEach(x,function(f){l([],f)})}i.assignCategoriesMapProp=c;function l(x,f){e.forEach(x,function(p){f.categoryMatchesMap[p.tokenTypeIdx]=!0}),e.forEach(f.CATEGORIES,function(p){var v=x.concat(f);e.contains(v,p)||l(v,p)})}i.singleAssignCategoriesToksMap=l;function u(x){return e.has(x,"tokenTypeIdx")}i.hasShortKeyProperty=u;function h(x){return e.has(x,"CATEGORIES")}i.hasCategoriesProperty=h;function d(x){return e.has(x,"categoryMatches")}i.hasExtendingTokensTypesProperty=d;function m(x){return e.has(x,"categoryMatchesMap")}i.hasExtendingTokensTypesMapProperty=m;function g(x){return e.has(x,"tokenTypeIdx")}i.isTokenType=g}),iM=Et(i=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.defaultLexerErrorProvider=void 0,i.defaultLexerErrorProvider={buildUnableToPopLexerModeMessage:function(e){return"Unable to pop Lexer Mode after encountering Token ->"+e.image+"<- The Mode Stack is empty"},buildUnexpectedCharactersMessage:function(e,t,n,r,s){return"unexpected character: ->"+e.charAt(t)+"<- at offset: "+t+","+(" skipped "+n+" characters.")}}}),Dp=Et(i=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.Lexer=i.LexerDefinitionErrorType=void 0;var e=nM(),t=Vt(),n=Th(),r=iM(),s=Cx(),o;(function(l){l[l.MISSING_PATTERN=0]="MISSING_PATTERN",l[l.INVALID_PATTERN=1]="INVALID_PATTERN",l[l.EOI_ANCHOR_FOUND=2]="EOI_ANCHOR_FOUND",l[l.UNSUPPORTED_FLAGS_FOUND=3]="UNSUPPORTED_FLAGS_FOUND",l[l.DUPLICATE_PATTERNS_FOUND=4]="DUPLICATE_PATTERNS_FOUND",l[l.INVALID_GROUP_TYPE_FOUND=5]="INVALID_GROUP_TYPE_FOUND",l[l.PUSH_MODE_DOES_NOT_EXIST=6]="PUSH_MODE_DOES_NOT_EXIST",l[l.MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE=7]="MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE",l[l.MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY=8]="MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY",l[l.MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST=9]="MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST",l[l.LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED=10]="LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED",l[l.SOI_ANCHOR_FOUND=11]="SOI_ANCHOR_FOUND",l[l.EMPTY_MATCH_PATTERN=12]="EMPTY_MATCH_PATTERN",l[l.NO_LINE_BREAKS_FLAGS=13]="NO_LINE_BREAKS_FLAGS",l[l.UNREACHABLE_PATTERN=14]="UNREACHABLE_PATTERN",l[l.IDENTIFY_TERMINATOR=15]="IDENTIFY_TERMINATOR",l[l.CUSTOM_LINE_BREAK=16]="CUSTOM_LINE_BREAK"})(o=i.LexerDefinitionErrorType||(i.LexerDefinitionErrorType={}));var a={deferDefinitionErrorsHandling:!1,positionTracking:"full",lineTerminatorsPattern:/\n|\r\n?/g,lineTerminatorCharacters:[`
`,"\r"],ensureOptimizations:!1,safeMode:!1,errorMessageProvider:r.defaultLexerErrorProvider,traceInitPerf:!1,skipValidations:!1};Object.freeze(a);var c=(function(){function l(u,h){var d=this;if(h===void 0&&(h=a),this.lexerDefinition=u,this.lexerDefinitionErrors=[],this.lexerDefinitionWarning=[],this.patternIdxToConfig={},this.charCodeToPatternIdxToConfig={},this.modes=[],this.emptyGroups={},this.config=void 0,this.trackStartLines=!0,this.trackEndLines=!0,this.hasCustom=!1,this.canModeBeOptimized={},typeof h=="boolean")throw Error(`The second argument to the Lexer constructor is now an ILexerConfig Object.
a boolean 2nd argument is no longer supported`);this.config=t.merge(a,h);var m=this.config.traceInitPerf;m===!0?(this.traceInitMaxIdent=1/0,this.traceInitPerf=!0):typeof m=="number"&&(this.traceInitMaxIdent=m,this.traceInitPerf=!0),this.traceInitIndent=-1,this.TRACE_INIT("Lexer Constructor",function(){var g,x=!0;d.TRACE_INIT("Lexer Config handling",function(){if(d.config.lineTerminatorsPattern===a.lineTerminatorsPattern)d.config.lineTerminatorsPattern=e.LineTerminatorOptimizedTester;else if(d.config.lineTerminatorCharacters===a.lineTerminatorCharacters)throw Error(`Error: Missing <lineTerminatorCharacters> property on the Lexer config.
For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#MISSING_LINE_TERM_CHARS`);if(h.safeMode&&h.ensureOptimizations)throw Error('"safeMode" and "ensureOptimizations" flags are mutually exclusive.');d.trackStartLines=/full|onlyStart/i.test(d.config.positionTracking),d.trackEndLines=/full/i.test(d.config.positionTracking),t.isArray(u)?(g={modes:{}},g.modes[e.DEFAULT_MODE]=t.cloneArr(u),g[e.DEFAULT_MODE]=e.DEFAULT_MODE):(x=!1,g=t.cloneObj(u))}),d.config.skipValidations===!1&&(d.TRACE_INIT("performRuntimeChecks",function(){d.lexerDefinitionErrors=d.lexerDefinitionErrors.concat(e.performRuntimeChecks(g,d.trackStartLines,d.config.lineTerminatorCharacters))}),d.TRACE_INIT("performWarningRuntimeChecks",function(){d.lexerDefinitionWarning=d.lexerDefinitionWarning.concat(e.performWarningRuntimeChecks(g,d.trackStartLines,d.config.lineTerminatorCharacters))})),g.modes=g.modes?g.modes:{},t.forEach(g.modes,function(_,y){g.modes[y]=t.reject(_,function(b){return t.isUndefined(b)})});var f=t.keys(g.modes);if(t.forEach(g.modes,function(_,y){d.TRACE_INIT("Mode: <"+y+"> processing",function(){if(d.modes.push(y),d.config.skipValidations===!1&&d.TRACE_INIT("validatePatterns",function(){d.lexerDefinitionErrors=d.lexerDefinitionErrors.concat(e.validatePatterns(_,f))}),t.isEmpty(d.lexerDefinitionErrors)){n.augmentTokenTypes(_);var b;d.TRACE_INIT("analyzeTokenTypes",function(){b=e.analyzeTokenTypes(_,{lineTerminatorCharacters:d.config.lineTerminatorCharacters,positionTracking:h.positionTracking,ensureOptimizations:h.ensureOptimizations,safeMode:h.safeMode,tracer:d.TRACE_INIT.bind(d)})}),d.patternIdxToConfig[y]=b.patternIdxToConfig,d.charCodeToPatternIdxToConfig[y]=b.charCodeToPatternIdxToConfig,d.emptyGroups=t.merge(d.emptyGroups,b.emptyGroups),d.hasCustom=b.hasCustom||d.hasCustom,d.canModeBeOptimized[y]=b.canBeOptimized}})}),d.defaultMode=g.defaultMode,!t.isEmpty(d.lexerDefinitionErrors)&&!d.config.deferDefinitionErrorsHandling){var p=t.map(d.lexerDefinitionErrors,function(_){return _.message}),v=p.join(`-----------------------
`);throw new Error(`Errors detected in definition of Lexer:
`+v)}t.forEach(d.lexerDefinitionWarning,function(_){t.PRINT_WARNING(_.message)}),d.TRACE_INIT("Choosing sub-methods implementations",function(){if(e.SUPPORT_STICKY?(d.chopInput=t.IDENTITY,d.match=d.matchWithTest):(d.updateLastIndex=t.NOOP,d.match=d.matchWithExec),x&&(d.handleModes=t.NOOP),d.trackStartLines===!1&&(d.computeNewColumn=t.IDENTITY),d.trackEndLines===!1&&(d.updateTokenEndLineColumnLocation=t.NOOP),/full/i.test(d.config.positionTracking))d.createTokenInstance=d.createFullToken;else if(/onlyStart/i.test(d.config.positionTracking))d.createTokenInstance=d.createStartOnlyToken;else if(/onlyOffset/i.test(d.config.positionTracking))d.createTokenInstance=d.createOffsetOnlyToken;else throw Error('Invalid <positionTracking> config option: "'+d.config.positionTracking+'"');d.hasCustom?(d.addToken=d.addTokenUsingPush,d.handlePayload=d.handlePayloadWithCustom):(d.addToken=d.addTokenUsingMemberAccess,d.handlePayload=d.handlePayloadNoCustom)}),d.TRACE_INIT("Failed Optimization Warnings",function(){var _=t.reduce(d.canModeBeOptimized,function(y,b,E){return b===!1&&y.push(E),y},[]);if(h.ensureOptimizations&&!t.isEmpty(_))throw Error("Lexer Modes: < "+_.join(", ")+` > cannot be optimized.
Disable the "ensureOptimizations" lexer config flag to silently ignore this and run the lexer in an un-optimized mode.
Or inspect the console log for details on how to resolve these issues.`)}),d.TRACE_INIT("clearRegExpParserCache",function(){s.clearRegExpParserCache()}),d.TRACE_INIT("toFastProperties",function(){t.toFastProperties(d)})})}return l.prototype.tokenize=function(u,h){if(h===void 0&&(h=this.defaultMode),!t.isEmpty(this.lexerDefinitionErrors)){var d=t.map(this.lexerDefinitionErrors,function(x){return x.message}),m=d.join(`-----------------------
`);throw new Error(`Unable to Tokenize because Errors detected in definition of Lexer:
`+m)}var g=this.tokenizeInternal(u,h);return g},l.prototype.tokenizeInternal=function(u,h){var d=this,m,g,x,f,p,v,_,y,b,E,A,T,M,S,C,N=u,I=N.length,L=0,q=0,K=this.hasCustom?0:Math.floor(u.length/10),B=new Array(K),j=[],J=this.trackStartLines?1:void 0,se=this.trackStartLines?1:void 0,ce=e.cloneEmptyGroups(this.emptyGroups),me=this.trackStartLines,Se=this.config.lineTerminatorsPattern,V=0,w=[],O=[],W=[],Q=[];Object.freeze(Q);var ee=void 0;function he(){return w}function Ce(ae){var re=e.charCodeToOptimizedIndex(ae),ge=O[re];return ge===void 0?Q:ge}var oe=function(ae){if(W.length===1&&ae.tokenType.PUSH_MODE===void 0){var re=d.config.errorMessageProvider.buildUnableToPopLexerModeMessage(ae);j.push({offset:ae.startOffset,line:ae.startLine!==void 0?ae.startLine:void 0,column:ae.startColumn!==void 0?ae.startColumn:void 0,length:ae.image.length,message:re})}else{W.pop();var ge=t.last(W);w=d.patternIdxToConfig[ge],O=d.charCodeToPatternIdxToConfig[ge],V=w.length;var xe=d.canModeBeOptimized[ge]&&d.config.safeMode===!1;O&&xe?ee=Ce:ee=he}};function ue(ae){W.push(ae),O=this.charCodeToPatternIdxToConfig[ae],w=this.patternIdxToConfig[ae],V=w.length,V=w.length;var re=this.canModeBeOptimized[ae]&&this.config.safeMode===!1;O&&re?ee=Ce:ee=he}ue.call(this,h);for(var H;L<I;){p=null;var Ie=N.charCodeAt(L),Te=ee(Ie),Oe=Te.length;for(m=0;m<Oe;m++){H=Te[m];var Re=H.pattern;v=null;var We=H.short;if(We!==!1?Ie===We&&(p=Re):H.isCustom===!0?(C=Re.exec(N,L,B,ce),C!==null?(p=C[0],C.payload!==void 0&&(v=C.payload)):p=null):(this.updateLastIndex(Re,L),p=this.match(Re,u,L)),p!==null){if(f=H.longerAlt,f!==void 0){var Ae=w[f],Y=Ae.pattern;_=null,Ae.isCustom===!0?(C=Y.exec(N,L,B,ce),C!==null?(x=C[0],C.payload!==void 0&&(_=C.payload)):x=null):(this.updateLastIndex(Y,L),x=this.match(Y,u,L)),x&&x.length>p.length&&(p=x,v=_,H=Ae)}break}}if(p!==null){if(y=p.length,b=H.group,b!==void 0&&(E=H.tokenTypeIdx,A=this.createTokenInstance(p,L,E,H.tokenType,J,se,y),this.handlePayload(A,v),b===!1?q=this.addToken(B,q,A):ce[b].push(A)),u=this.chopInput(u,y),L=L+y,se=this.computeNewColumn(se,y),me===!0&&H.canLineTerminator===!0){var F=0,D=void 0,P=void 0;Se.lastIndex=0;do D=Se.test(p),D===!0&&(P=Se.lastIndex-1,F++);while(D===!0);F!==0&&(J=J+F,se=y-P,this.updateTokenEndLineColumnLocation(A,b,P,F,J,se,y))}this.handleModes(H,oe,ue,A)}else{for(var U=L,X=J,Z=se,$=!1;!$&&L<I;)for(M=N.charCodeAt(L),u=this.chopInput(u,1),L++,g=0;g<V;g++){var te=w[g],Re=te.pattern,We=te.short;if(We!==!1?N.charCodeAt(L)===We&&($=!0):te.isCustom===!0?$=Re.exec(N,L,B,ce)!==null:(this.updateLastIndex(Re,L),$=Re.exec(u)!==null),$===!0)break}T=L-U,S=this.config.errorMessageProvider.buildUnexpectedCharactersMessage(N,U,T,X,Z),j.push({offset:U,line:X,column:Z,length:T,message:S})}}return this.hasCustom||(B.length=q),{tokens:B,groups:ce,errors:j}},l.prototype.handleModes=function(u,h,d,m){if(u.pop===!0){var g=u.push;h(m),g!==void 0&&d.call(this,g)}else u.push!==void 0&&d.call(this,u.push)},l.prototype.chopInput=function(u,h){return u.substring(h)},l.prototype.updateLastIndex=function(u,h){u.lastIndex=h},l.prototype.updateTokenEndLineColumnLocation=function(u,h,d,m,g,x,f){var p,v;h!==void 0&&(p=d===f-1,v=p?-1:0,m===1&&p===!0||(u.endLine=g+v,u.endColumn=x-1+-v))},l.prototype.computeNewColumn=function(u,h){return u+h},l.prototype.createTokenInstance=function(){for(var u=[],h=0;h<arguments.length;h++)u[h]=arguments[h];return null},l.prototype.createOffsetOnlyToken=function(u,h,d,m){return{image:u,startOffset:h,tokenTypeIdx:d,tokenType:m}},l.prototype.createStartOnlyToken=function(u,h,d,m,g,x){return{image:u,startOffset:h,startLine:g,startColumn:x,tokenTypeIdx:d,tokenType:m}},l.prototype.createFullToken=function(u,h,d,m,g,x,f){return{image:u,startOffset:h,endOffset:h+f-1,startLine:g,endLine:g,startColumn:x,endColumn:x+f-1,tokenTypeIdx:d,tokenType:m}},l.prototype.addToken=function(u,h,d){return 666},l.prototype.addTokenUsingPush=function(u,h,d){return u.push(d),h},l.prototype.addTokenUsingMemberAccess=function(u,h,d){return u[h]=d,h++,h},l.prototype.handlePayload=function(u,h){},l.prototype.handlePayloadNoCustom=function(u,h){},l.prototype.handlePayloadWithCustom=function(u,h){h!==null&&(u.payload=h)},l.prototype.match=function(u,h,d){return null},l.prototype.matchWithTest=function(u,h,d){var m=u.test(h);return m===!0?h.substring(d,u.lastIndex):null},l.prototype.matchWithExec=function(u,h){var d=u.exec(h);return d!==null?d[0]:d},l.prototype.TRACE_INIT=function(u,h){if(this.traceInitPerf===!0){this.traceInitIndent++;var d=new Array(this.traceInitIndent+1).join(" ");this.traceInitIndent<this.traceInitMaxIdent&&console.log(d+"--> <"+u+">");var m=t.timer(h),g=m.time,x=m.value,f=g>10?console.warn:console.log;return this.traceInitIndent<this.traceInitMaxIdent&&f(d+"<-- <"+u+"> time: "+g+"ms"),this.traceInitIndent--,x}else return h()},l.SKIPPED="This marks a skipped Token pattern, this means each token identified by it willbe consumed and then thrown into oblivion, this can be used to for example to completely ignore whitespace.",l.NA=/NOT_APPLICABLE/,l})();i.Lexer=c}),oa=Et(i=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.tokenMatcher=i.createTokenInstance=i.EOF=i.createToken=i.hasTokenLabel=i.tokenName=i.tokenLabel=void 0;var e=Vt(),t=Dp(),n=Th();function r(y){return o(y)?y.LABEL:y.name}i.tokenLabel=r;function s(y){return y.name}i.tokenName=s;function o(y){return e.isString(y.LABEL)&&y.LABEL!==""}i.hasTokenLabel=o;var a="parent",c="categories",l="label",u="group",h="push_mode",d="pop_mode",m="longer_alt",g="line_breaks",x="start_chars_hint";function f(y){return p(y)}i.createToken=f;function p(y){var b=y.pattern,E={};if(E.name=y.name,e.isUndefined(b)||(E.PATTERN=b),e.has(y,a))throw`The parent property is no longer supported.
See: https://github.com/chevrotain/chevrotain/issues/564#issuecomment-349062346 for details.`;return e.has(y,c)&&(E.CATEGORIES=y[c]),n.augmentTokenTypes([E]),e.has(y,l)&&(E.LABEL=y[l]),e.has(y,u)&&(E.GROUP=y[u]),e.has(y,d)&&(E.POP_MODE=y[d]),e.has(y,h)&&(E.PUSH_MODE=y[h]),e.has(y,m)&&(E.LONGER_ALT=y[m]),e.has(y,g)&&(E.LINE_BREAKS=y[g]),e.has(y,x)&&(E.START_CHARS_HINT=y[x]),E}i.EOF=f({name:"EOF",pattern:t.Lexer.NA}),n.augmentTokenTypes([i.EOF]);function v(y,b,E,A,T,M,S,C){return{image:b,startOffset:E,endOffset:A,startLine:T,endLine:M,startColumn:S,endColumn:C,tokenTypeIdx:y.tokenTypeIdx,tokenType:y}}i.createTokenInstance=v;function _(y,b){return n.tokenStructuredMatcher(y,b)}i.tokenMatcher=_}),Bi=Et(i=>{"use strict";var e=i&&i.__extends||(function(){var p=function(v,_){return p=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(y,b){y.__proto__=b}||function(y,b){for(var E in b)Object.prototype.hasOwnProperty.call(b,E)&&(y[E]=b[E])},p(v,_)};return function(v,_){if(typeof _!="function"&&_!==null)throw new TypeError("Class extends value "+String(_)+" is not a constructor or null");p(v,_);function y(){this.constructor=v}v.prototype=_===null?Object.create(_):(y.prototype=_.prototype,new y)}})();Object.defineProperty(i,"__esModule",{value:!0}),i.serializeProduction=i.serializeGrammar=i.Terminal=i.Alternation=i.RepetitionWithSeparator=i.Repetition=i.RepetitionMandatoryWithSeparator=i.RepetitionMandatory=i.Option=i.Alternative=i.Rule=i.NonTerminal=i.AbstractProduction=void 0;var t=Vt(),n=oa(),r=(function(){function p(v){this._definition=v}return Object.defineProperty(p.prototype,"definition",{get:function(){return this._definition},set:function(v){this._definition=v},enumerable:!1,configurable:!0}),p.prototype.accept=function(v){v.visit(this),t.forEach(this.definition,function(_){_.accept(v)})},p})();i.AbstractProduction=r;var s=(function(p){e(v,p);function v(_){var y=p.call(this,[])||this;return y.idx=1,t.assign(y,t.pick(_,function(b){return b!==void 0})),y}return Object.defineProperty(v.prototype,"definition",{get:function(){return this.referencedRule!==void 0?this.referencedRule.definition:[]},set:function(_){},enumerable:!1,configurable:!0}),v.prototype.accept=function(_){_.visit(this)},v})(r);i.NonTerminal=s;var o=(function(p){e(v,p);function v(_){var y=p.call(this,_.definition)||this;return y.orgText="",t.assign(y,t.pick(_,function(b){return b!==void 0})),y}return v})(r);i.Rule=o;var a=(function(p){e(v,p);function v(_){var y=p.call(this,_.definition)||this;return y.ignoreAmbiguities=!1,t.assign(y,t.pick(_,function(b){return b!==void 0})),y}return v})(r);i.Alternative=a;var c=(function(p){e(v,p);function v(_){var y=p.call(this,_.definition)||this;return y.idx=1,t.assign(y,t.pick(_,function(b){return b!==void 0})),y}return v})(r);i.Option=c;var l=(function(p){e(v,p);function v(_){var y=p.call(this,_.definition)||this;return y.idx=1,t.assign(y,t.pick(_,function(b){return b!==void 0})),y}return v})(r);i.RepetitionMandatory=l;var u=(function(p){e(v,p);function v(_){var y=p.call(this,_.definition)||this;return y.idx=1,t.assign(y,t.pick(_,function(b){return b!==void 0})),y}return v})(r);i.RepetitionMandatoryWithSeparator=u;var h=(function(p){e(v,p);function v(_){var y=p.call(this,_.definition)||this;return y.idx=1,t.assign(y,t.pick(_,function(b){return b!==void 0})),y}return v})(r);i.Repetition=h;var d=(function(p){e(v,p);function v(_){var y=p.call(this,_.definition)||this;return y.idx=1,t.assign(y,t.pick(_,function(b){return b!==void 0})),y}return v})(r);i.RepetitionWithSeparator=d;var m=(function(p){e(v,p);function v(_){var y=p.call(this,_.definition)||this;return y.idx=1,y.ignoreAmbiguities=!1,y.hasPredicates=!1,t.assign(y,t.pick(_,function(b){return b!==void 0})),y}return Object.defineProperty(v.prototype,"definition",{get:function(){return this._definition},set:function(_){this._definition=_},enumerable:!1,configurable:!0}),v})(r);i.Alternation=m;var g=(function(){function p(v){this.idx=1,t.assign(this,t.pick(v,function(_){return _!==void 0}))}return p.prototype.accept=function(v){v.visit(this)},p})();i.Terminal=g;function x(p){return t.map(p,f)}i.serializeGrammar=x;function f(p){function v(b){return t.map(b,f)}if(p instanceof s)return{type:"NonTerminal",name:p.nonTerminalName,idx:p.idx};if(p instanceof a)return{type:"Alternative",definition:v(p.definition)};if(p instanceof c)return{type:"Option",idx:p.idx,definition:v(p.definition)};if(p instanceof l)return{type:"RepetitionMandatory",idx:p.idx,definition:v(p.definition)};if(p instanceof u)return{type:"RepetitionMandatoryWithSeparator",idx:p.idx,separator:f(new g({terminalType:p.separator})),definition:v(p.definition)};if(p instanceof d)return{type:"RepetitionWithSeparator",idx:p.idx,separator:f(new g({terminalType:p.separator})),definition:v(p.definition)};if(p instanceof h)return{type:"Repetition",idx:p.idx,definition:v(p.definition)};if(p instanceof m)return{type:"Alternation",idx:p.idx,definition:v(p.definition)};if(p instanceof g){var _={type:"Terminal",name:p.terminalType.name,label:n.tokenLabel(p.terminalType),idx:p.idx},y=p.terminalType.PATTERN;return p.terminalType.PATTERN&&(_.pattern=t.isRegExp(y)?y.source:y),_}else{if(p instanceof o)return{type:"Rule",name:p.name,orgText:p.orgText,definition:v(p.definition)};throw Error("non exhaustive match")}}i.serializeProduction=f}),Px=Et(i=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.RestWalker=void 0;var e=Vt(),t=Bi(),n=(function(){function s(){}return s.prototype.walk=function(o,a){var c=this;a===void 0&&(a=[]),e.forEach(o.definition,function(l,u){var h=e.drop(o.definition,u+1);if(l instanceof t.NonTerminal)c.walkProdRef(l,h,a);else if(l instanceof t.Terminal)c.walkTerminal(l,h,a);else if(l instanceof t.Alternative)c.walkFlat(l,h,a);else if(l instanceof t.Option)c.walkOption(l,h,a);else if(l instanceof t.RepetitionMandatory)c.walkAtLeastOne(l,h,a);else if(l instanceof t.RepetitionMandatoryWithSeparator)c.walkAtLeastOneSep(l,h,a);else if(l instanceof t.RepetitionWithSeparator)c.walkManySep(l,h,a);else if(l instanceof t.Repetition)c.walkMany(l,h,a);else if(l instanceof t.Alternation)c.walkOr(l,h,a);else throw Error("non exhaustive match")})},s.prototype.walkTerminal=function(o,a,c){},s.prototype.walkProdRef=function(o,a,c){},s.prototype.walkFlat=function(o,a,c){var l=a.concat(c);this.walk(o,l)},s.prototype.walkOption=function(o,a,c){var l=a.concat(c);this.walk(o,l)},s.prototype.walkAtLeastOne=function(o,a,c){var l=[new t.Option({definition:o.definition})].concat(a,c);this.walk(o,l)},s.prototype.walkAtLeastOneSep=function(o,a,c){var l=r(o,a,c);this.walk(o,l)},s.prototype.walkMany=function(o,a,c){var l=[new t.Option({definition:o.definition})].concat(a,c);this.walk(o,l)},s.prototype.walkManySep=function(o,a,c){var l=r(o,a,c);this.walk(o,l)},s.prototype.walkOr=function(o,a,c){var l=this,u=a.concat(c);e.forEach(o.definition,function(h){var d=new t.Alternative({definition:[h]});l.walk(d,u)})},s})();i.RestWalker=n;function r(s,o,a){var c=[new t.Option({definition:[new t.Terminal({terminalType:s.separator})].concat(s.definition)})],l=c.concat(o,a);return l}}),Ah=Et(i=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.GAstVisitor=void 0;var e=Bi(),t=(function(){function n(){}return n.prototype.visit=function(r){var s=r;switch(s.constructor){case e.NonTerminal:return this.visitNonTerminal(s);case e.Alternative:return this.visitAlternative(s);case e.Option:return this.visitOption(s);case e.RepetitionMandatory:return this.visitRepetitionMandatory(s);case e.RepetitionMandatoryWithSeparator:return this.visitRepetitionMandatoryWithSeparator(s);case e.RepetitionWithSeparator:return this.visitRepetitionWithSeparator(s);case e.Repetition:return this.visitRepetition(s);case e.Alternation:return this.visitAlternation(s);case e.Terminal:return this.visitTerminal(s);case e.Rule:return this.visitRule(s);default:throw Error("non exhaustive match")}},n.prototype.visitNonTerminal=function(r){},n.prototype.visitAlternative=function(r){},n.prototype.visitOption=function(r){},n.prototype.visitRepetition=function(r){},n.prototype.visitRepetitionMandatory=function(r){},n.prototype.visitRepetitionMandatoryWithSeparator=function(r){},n.prototype.visitRepetitionWithSeparator=function(r){},n.prototype.visitAlternation=function(r){},n.prototype.visitTerminal=function(r){},n.prototype.visitRule=function(r){},n})();i.GAstVisitor=t}),Fp=Et(i=>{"use strict";var e=i&&i.__extends||(function(){var d=function(m,g){return d=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(x,f){x.__proto__=f}||function(x,f){for(var p in f)Object.prototype.hasOwnProperty.call(f,p)&&(x[p]=f[p])},d(m,g)};return function(m,g){if(typeof g!="function"&&g!==null)throw new TypeError("Class extends value "+String(g)+" is not a constructor or null");d(m,g);function x(){this.constructor=m}m.prototype=g===null?Object.create(g):(x.prototype=g.prototype,new x)}})();Object.defineProperty(i,"__esModule",{value:!0}),i.collectMethods=i.DslMethodsCollectorVisitor=i.getProductionDslName=i.isBranchingProd=i.isOptionalProd=i.isSequenceProd=void 0;var t=Vt(),n=Bi(),r=Ah();function s(d){return d instanceof n.Alternative||d instanceof n.Option||d instanceof n.Repetition||d instanceof n.RepetitionMandatory||d instanceof n.RepetitionMandatoryWithSeparator||d instanceof n.RepetitionWithSeparator||d instanceof n.Terminal||d instanceof n.Rule}i.isSequenceProd=s;function o(d,m){m===void 0&&(m=[]);var g=d instanceof n.Option||d instanceof n.Repetition||d instanceof n.RepetitionWithSeparator;return g?!0:d instanceof n.Alternation?t.some(d.definition,function(x){return o(x,m)}):d instanceof n.NonTerminal&&t.contains(m,d)?!1:d instanceof n.AbstractProduction?(d instanceof n.NonTerminal&&m.push(d),t.every(d.definition,function(x){return o(x,m)})):!1}i.isOptionalProd=o;function a(d){return d instanceof n.Alternation}i.isBranchingProd=a;function c(d){if(d instanceof n.NonTerminal)return"SUBRULE";if(d instanceof n.Option)return"OPTION";if(d instanceof n.Alternation)return"OR";if(d instanceof n.RepetitionMandatory)return"AT_LEAST_ONE";if(d instanceof n.RepetitionMandatoryWithSeparator)return"AT_LEAST_ONE_SEP";if(d instanceof n.RepetitionWithSeparator)return"MANY_SEP";if(d instanceof n.Repetition)return"MANY";if(d instanceof n.Terminal)return"CONSUME";throw Error("non exhaustive match")}i.getProductionDslName=c;var l=(function(d){e(m,d);function m(){var g=d!==null&&d.apply(this,arguments)||this;return g.separator="-",g.dslMethods={option:[],alternation:[],repetition:[],repetitionWithSeparator:[],repetitionMandatory:[],repetitionMandatoryWithSeparator:[]},g}return m.prototype.reset=function(){this.dslMethods={option:[],alternation:[],repetition:[],repetitionWithSeparator:[],repetitionMandatory:[],repetitionMandatoryWithSeparator:[]}},m.prototype.visitTerminal=function(g){var x=g.terminalType.name+this.separator+"Terminal";t.has(this.dslMethods,x)||(this.dslMethods[x]=[]),this.dslMethods[x].push(g)},m.prototype.visitNonTerminal=function(g){var x=g.nonTerminalName+this.separator+"Terminal";t.has(this.dslMethods,x)||(this.dslMethods[x]=[]),this.dslMethods[x].push(g)},m.prototype.visitOption=function(g){this.dslMethods.option.push(g)},m.prototype.visitRepetitionWithSeparator=function(g){this.dslMethods.repetitionWithSeparator.push(g)},m.prototype.visitRepetitionMandatory=function(g){this.dslMethods.repetitionMandatory.push(g)},m.prototype.visitRepetitionMandatoryWithSeparator=function(g){this.dslMethods.repetitionMandatoryWithSeparator.push(g)},m.prototype.visitRepetition=function(g){this.dslMethods.repetition.push(g)},m.prototype.visitAlternation=function(g){this.dslMethods.alternation.push(g)},m})(r.GAstVisitor);i.DslMethodsCollectorVisitor=l;var u=new l;function h(d){u.reset(),d.accept(u);var m=u.dslMethods;return u.reset(),m}i.collectMethods=h}),rM=Et(i=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.firstForTerminal=i.firstForBranching=i.firstForSequence=i.first=void 0;var e=Vt(),t=Bi(),n=Fp();function r(c){if(c instanceof t.NonTerminal)return r(c.referencedRule);if(c instanceof t.Terminal)return a(c);if(n.isSequenceProd(c))return s(c);if(n.isBranchingProd(c))return o(c);throw Error("non exhaustive match")}i.first=r;function s(c){for(var l=[],u=c.definition,h=0,d=u.length>h,m,g=!0;d&&g;)m=u[h],g=n.isOptionalProd(m),l=l.concat(r(m)),h=h+1,d=u.length>h;return e.uniq(l)}i.firstForSequence=s;function o(c){var l=e.map(c.definition,function(u){return r(u)});return e.uniq(e.flatten(l))}i.firstForBranching=o;function a(c){return[c.terminalType]}i.firstForTerminal=a}),sM=Et(i=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.IN=void 0,i.IN="_~IN~_"}),dP=Et(i=>{"use strict";var e=i&&i.__extends||(function(){var h=function(d,m){return h=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(g,x){g.__proto__=x}||function(g,x){for(var f in x)Object.prototype.hasOwnProperty.call(x,f)&&(g[f]=x[f])},h(d,m)};return function(d,m){if(typeof m!="function"&&m!==null)throw new TypeError("Class extends value "+String(m)+" is not a constructor or null");h(d,m);function g(){this.constructor=d}d.prototype=m===null?Object.create(m):(g.prototype=m.prototype,new g)}})();Object.defineProperty(i,"__esModule",{value:!0}),i.buildInProdFollowPrefix=i.buildBetweenProdsFollowPrefix=i.computeAllProdsFollows=i.ResyncFollowsWalker=void 0;var t=Px(),n=rM(),r=Vt(),s=sM(),o=Bi(),a=(function(h){e(d,h);function d(m){var g=h.call(this)||this;return g.topProd=m,g.follows={},g}return d.prototype.startWalking=function(){return this.walk(this.topProd),this.follows},d.prototype.walkTerminal=function(m,g,x){},d.prototype.walkProdRef=function(m,g,x){var f=l(m.referencedRule,m.idx)+this.topProd.name,p=g.concat(x),v=new o.Alternative({definition:p}),_=n.first(v);this.follows[f]=_},d})(t.RestWalker);i.ResyncFollowsWalker=a;function c(h){var d={};return r.forEach(h,function(m){var g=new a(m).startWalking();r.assign(d,g)}),d}i.computeAllProdsFollows=c;function l(h,d){return h.name+d+s.IN}i.buildBetweenProdsFollowPrefix=l;function u(h){var d=h.terminalType.name;return d+h.idx+s.IN}i.buildInProdFollowPrefix=u}),Up=Et(i=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.defaultGrammarValidatorErrorProvider=i.defaultGrammarResolverErrorProvider=i.defaultParserErrorProvider=void 0;var e=oa(),t=Vt(),n=Vt(),r=Bi(),s=Fp();i.defaultParserErrorProvider={buildMismatchTokenMessage:function(o){var a=o.expected,c=o.actual,l=o.previous,u=o.ruleName,h=e.hasTokenLabel(a),d=h?"--> "+e.tokenLabel(a)+" <--":"token of type --> "+a.name+" <--",m="Expecting "+d+" but found --> '"+c.image+"' <--";return m},buildNotAllInputParsedMessage:function(o){var a=o.firstRedundant,c=o.ruleName;return"Redundant input, expecting EOF but found: "+a.image},buildNoViableAltMessage:function(o){var a=o.expectedPathsPerAlt,c=o.actual,l=o.previous,u=o.customUserDescription,h=o.ruleName,d="Expecting: ",m=n.first(c).image,g=`
but found: '`+m+"'";if(u)return d+u+g;var x=n.reduce(a,function(_,y){return _.concat(y)},[]),f=n.map(x,function(_){return"["+n.map(_,function(y){return e.tokenLabel(y)}).join(", ")+"]"}),p=n.map(f,function(_,y){return" "+(y+1)+". "+_}),v=`one of these possible Token sequences:
`+p.join(`
`);return d+v+g},buildEarlyExitMessage:function(o){var a=o.expectedIterationPaths,c=o.actual,l=o.customUserDescription,u=o.ruleName,h="Expecting: ",d=n.first(c).image,m=`
but found: '`+d+"'";if(l)return h+l+m;var g=n.map(a,function(f){return"["+n.map(f,function(p){return e.tokenLabel(p)}).join(",")+"]"}),x=`expecting at least one iteration which starts with one of these possible Token sequences::
`+("<"+g.join(" ,")+">");return h+x+m}},Object.freeze(i.defaultParserErrorProvider),i.defaultGrammarResolverErrorProvider={buildRuleNotFoundError:function(o,a){var c="Invalid grammar, reference to a rule which is not defined: ->"+a.nonTerminalName+`<-
inside top level rule: ->`+o.name+"<-";return c}},i.defaultGrammarValidatorErrorProvider={buildDuplicateFoundError:function(o,a){function c(f){return f instanceof r.Terminal?f.terminalType.name:f instanceof r.NonTerminal?f.nonTerminalName:""}var l=o.name,u=n.first(a),h=u.idx,d=s.getProductionDslName(u),m=c(u),g=h>0,x="->"+d+(g?h:"")+"<- "+(m?"with argument: ->"+m+"<-":"")+`
appears more than once (`+a.length+" times) in the top level rule: ->"+l+`<-.
For further details see: https://chevrotain.io/docs/FAQ.html#NUMERICAL_SUFFIXES
`;return x=x.replace(/[ \t]+/g," "),x=x.replace(/\s\s+/g,`
`),x},buildNamespaceConflictError:function(o){var a=`Namespace conflict found in grammar.
`+("The grammar has both a Terminal(Token) and a Non-Terminal(Rule) named: <"+o.name+`>.
`)+`To resolve this make sure each Terminal and Non-Terminal names are unique
This is easy to accomplish by using the convention that Terminal names start with an uppercase letter
and Non-Terminal names start with a lower case letter.`;return a},buildAlternationPrefixAmbiguityError:function(o){var a=n.map(o.prefixPath,function(u){return e.tokenLabel(u)}).join(", "),c=o.alternation.idx===0?"":o.alternation.idx,l="Ambiguous alternatives: <"+o.ambiguityIndices.join(" ,")+`> due to common lookahead prefix
`+("in <OR"+c+"> inside <"+o.topLevelRule.name+`> Rule,
`)+("<"+a+`> may appears as a prefix path in all these alternatives.
`)+`See: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#COMMON_PREFIX
For Further details.`;return l},buildAlternationAmbiguityError:function(o){var a=n.map(o.prefixPath,function(u){return e.tokenLabel(u)}).join(", "),c=o.alternation.idx===0?"":o.alternation.idx,l="Ambiguous Alternatives Detected: <"+o.ambiguityIndices.join(" ,")+"> in <OR"+c+">"+(" inside <"+o.topLevelRule.name+`> Rule,
`)+("<"+a+`> may appears as a prefix path in all these alternatives.
`);return l=l+`See: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#AMBIGUOUS_ALTERNATIVES
For Further details.`,l},buildEmptyRepetitionError:function(o){var a=s.getProductionDslName(o.repetition);o.repetition.idx!==0&&(a+=o.repetition.idx);var c="The repetition <"+a+"> within Rule <"+o.topLevelRule.name+`> can never consume any tokens.
This could lead to an infinite loop.`;return c},buildTokenNameError:function(o){return"deprecated"},buildEmptyAlternationError:function(o){var a="Ambiguous empty alternative: <"+(o.emptyChoiceIdx+1)+">"+(" in <OR"+o.alternation.idx+"> inside <"+o.topLevelRule.name+`> Rule.
`)+"Only the last alternative may be an empty alternative.";return a},buildTooManyAlternativesError:function(o){var a=`An Alternation cannot have more than 256 alternatives:
`+("<OR"+o.alternation.idx+"> inside <"+o.topLevelRule.name+`> Rule.
has `+(o.alternation.definition.length+1)+" alternatives.");return a},buildLeftRecursionError:function(o){var a=o.topLevelRule.name,c=t.map(o.leftRecursionPath,function(h){return h.name}),l=a+" --> "+c.concat([a]).join(" --> "),u=`Left Recursion found in grammar.
`+("rule: <"+a+`> can be invoked from itself (directly or indirectly)
`)+(`without consuming any Tokens. The grammar path that causes this is:
`+l+`
`)+` To fix this refactor your grammar to remove the left recursion.
see: https://en.wikipedia.org/wiki/LL_parser#Left_Factoring.`;return u},buildInvalidRuleNameError:function(o){return"deprecated"},buildDuplicateRuleNameError:function(o){var a;o.topLevelRule instanceof r.Rule?a=o.topLevelRule.name:a=o.topLevelRule;var c="Duplicate definition, rule: ->"+a+"<- is already defined in the grammar: ->"+o.grammarName+"<-";return c}}}),fP=Et(i=>{"use strict";var e=i&&i.__extends||(function(){var a=function(c,l){return a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(u,h){u.__proto__=h}||function(u,h){for(var d in h)Object.prototype.hasOwnProperty.call(h,d)&&(u[d]=h[d])},a(c,l)};return function(c,l){if(typeof l!="function"&&l!==null)throw new TypeError("Class extends value "+String(l)+" is not a constructor or null");a(c,l);function u(){this.constructor=c}c.prototype=l===null?Object.create(l):(u.prototype=l.prototype,new u)}})();Object.defineProperty(i,"__esModule",{value:!0}),i.GastRefResolverVisitor=i.resolveGrammar=void 0;var t=ji(),n=Vt(),r=Ah();function s(a,c){var l=new o(a,c);return l.resolveRefs(),l.errors}i.resolveGrammar=s;var o=(function(a){e(c,a);function c(l,u){var h=a.call(this)||this;return h.nameToTopRule=l,h.errMsgProvider=u,h.errors=[],h}return c.prototype.resolveRefs=function(){var l=this;n.forEach(n.values(this.nameToTopRule),function(u){l.currTopLevel=u,u.accept(l)})},c.prototype.visitNonTerminal=function(l){var u=this.nameToTopRule[l.nonTerminalName];if(u)l.referencedRule=u;else{var h=this.errMsgProvider.buildRuleNotFoundError(this.currTopLevel,l);this.errors.push({message:h,type:t.ParserDefinitionErrorType.UNRESOLVED_SUBRULE_REF,ruleName:this.currTopLevel.name,unresolvedRefName:l.nonTerminalName})}},c})(r.GAstVisitor);i.GastRefResolverVisitor=o}),kp=Et(i=>{"use strict";var e=i&&i.__extends||(function(){var f=function(p,v){return f=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(_,y){_.__proto__=y}||function(_,y){for(var b in y)Object.prototype.hasOwnProperty.call(y,b)&&(_[b]=y[b])},f(p,v)};return function(p,v){if(typeof v!="function"&&v!==null)throw new TypeError("Class extends value "+String(v)+" is not a constructor or null");f(p,v);function _(){this.constructor=p}p.prototype=v===null?Object.create(v):(_.prototype=v.prototype,new _)}})();Object.defineProperty(i,"__esModule",{value:!0}),i.nextPossibleTokensAfter=i.possiblePathsFrom=i.NextTerminalAfterAtLeastOneSepWalker=i.NextTerminalAfterAtLeastOneWalker=i.NextTerminalAfterManySepWalker=i.NextTerminalAfterManyWalker=i.AbstractNextTerminalAfterProductionWalker=i.NextAfterTokenWalker=i.AbstractNextPossibleTokensWalker=void 0;var t=Px(),n=Vt(),r=rM(),s=Bi(),o=(function(f){e(p,f);function p(v,_){var y=f.call(this)||this;return y.topProd=v,y.path=_,y.possibleTokTypes=[],y.nextProductionName="",y.nextProductionOccurrence=0,y.found=!1,y.isAtEndOfPath=!1,y}return p.prototype.startWalking=function(){if(this.found=!1,this.path.ruleStack[0]!==this.topProd.name)throw Error("The path does not start with the walker's top Rule!");return this.ruleStack=n.cloneArr(this.path.ruleStack).reverse(),this.occurrenceStack=n.cloneArr(this.path.occurrenceStack).reverse(),this.ruleStack.pop(),this.occurrenceStack.pop(),this.updateExpectedNext(),this.walk(this.topProd),this.possibleTokTypes},p.prototype.walk=function(v,_){_===void 0&&(_=[]),this.found||f.prototype.walk.call(this,v,_)},p.prototype.walkProdRef=function(v,_,y){if(v.referencedRule.name===this.nextProductionName&&v.idx===this.nextProductionOccurrence){var b=_.concat(y);this.updateExpectedNext(),this.walk(v.referencedRule,b)}},p.prototype.updateExpectedNext=function(){n.isEmpty(this.ruleStack)?(this.nextProductionName="",this.nextProductionOccurrence=0,this.isAtEndOfPath=!0):(this.nextProductionName=this.ruleStack.pop(),this.nextProductionOccurrence=this.occurrenceStack.pop())},p})(t.RestWalker);i.AbstractNextPossibleTokensWalker=o;var a=(function(f){e(p,f);function p(v,_){var y=f.call(this,v,_)||this;return y.path=_,y.nextTerminalName="",y.nextTerminalOccurrence=0,y.nextTerminalName=y.path.lastTok.name,y.nextTerminalOccurrence=y.path.lastTokOccurrence,y}return p.prototype.walkTerminal=function(v,_,y){if(this.isAtEndOfPath&&v.terminalType.name===this.nextTerminalName&&v.idx===this.nextTerminalOccurrence&&!this.found){var b=_.concat(y),E=new s.Alternative({definition:b});this.possibleTokTypes=r.first(E),this.found=!0}},p})(o);i.NextAfterTokenWalker=a;var c=(function(f){e(p,f);function p(v,_){var y=f.call(this)||this;return y.topRule=v,y.occurrence=_,y.result={token:void 0,occurrence:void 0,isEndOfRule:void 0},y}return p.prototype.startWalking=function(){return this.walk(this.topRule),this.result},p})(t.RestWalker);i.AbstractNextTerminalAfterProductionWalker=c;var l=(function(f){e(p,f);function p(){return f!==null&&f.apply(this,arguments)||this}return p.prototype.walkMany=function(v,_,y){if(v.idx===this.occurrence){var b=n.first(_.concat(y));this.result.isEndOfRule=b===void 0,b instanceof s.Terminal&&(this.result.token=b.terminalType,this.result.occurrence=b.idx)}else f.prototype.walkMany.call(this,v,_,y)},p})(c);i.NextTerminalAfterManyWalker=l;var u=(function(f){e(p,f);function p(){return f!==null&&f.apply(this,arguments)||this}return p.prototype.walkManySep=function(v,_,y){if(v.idx===this.occurrence){var b=n.first(_.concat(y));this.result.isEndOfRule=b===void 0,b instanceof s.Terminal&&(this.result.token=b.terminalType,this.result.occurrence=b.idx)}else f.prototype.walkManySep.call(this,v,_,y)},p})(c);i.NextTerminalAfterManySepWalker=u;var h=(function(f){e(p,f);function p(){return f!==null&&f.apply(this,arguments)||this}return p.prototype.walkAtLeastOne=function(v,_,y){if(v.idx===this.occurrence){var b=n.first(_.concat(y));this.result.isEndOfRule=b===void 0,b instanceof s.Terminal&&(this.result.token=b.terminalType,this.result.occurrence=b.idx)}else f.prototype.walkAtLeastOne.call(this,v,_,y)},p})(c);i.NextTerminalAfterAtLeastOneWalker=h;var d=(function(f){e(p,f);function p(){return f!==null&&f.apply(this,arguments)||this}return p.prototype.walkAtLeastOneSep=function(v,_,y){if(v.idx===this.occurrence){var b=n.first(_.concat(y));this.result.isEndOfRule=b===void 0,b instanceof s.Terminal&&(this.result.token=b.terminalType,this.result.occurrence=b.idx)}else f.prototype.walkAtLeastOneSep.call(this,v,_,y)},p})(c);i.NextTerminalAfterAtLeastOneSepWalker=d;function m(f,p,v){v===void 0&&(v=[]),v=n.cloneArr(v);var _=[],y=0;function b(M){return M.concat(n.drop(f,y+1))}function E(M){var S=m(b(M),p,v);return _.concat(S)}for(;v.length<p&&y<f.length;){var A=f[y];if(A instanceof s.Alternative||A instanceof s.NonTerminal)return E(A.definition);if(A instanceof s.Option)_=E(A.definition);else if(A instanceof s.RepetitionMandatory){var T=A.definition.concat([new s.Repetition({definition:A.definition})]);return E(T)}else if(A instanceof s.RepetitionMandatoryWithSeparator){var T=[new s.Alternative({definition:A.definition}),new s.Repetition({definition:[new s.Terminal({terminalType:A.separator})].concat(A.definition)})];return E(T)}else if(A instanceof s.RepetitionWithSeparator){var T=A.definition.concat([new s.Repetition({definition:[new s.Terminal({terminalType:A.separator})].concat(A.definition)})]);_=E(T)}else if(A instanceof s.Repetition){var T=A.definition.concat([new s.Repetition({definition:A.definition})]);_=E(T)}else{if(A instanceof s.Alternation)return n.forEach(A.definition,function(M){n.isEmpty(M.definition)===!1&&(_=E(M.definition))}),_;if(A instanceof s.Terminal)v.push(A.terminalType);else throw Error("non exhaustive match")}y++}return _.push({partialPath:v,suffixDef:n.drop(f,y)}),_}i.possiblePathsFrom=m;function g(f,p,v,_){var y="EXIT_NONE_TERMINAL",b=[y],E="EXIT_ALTERNATIVE",A=!1,T=p.length,M=T-_-1,S=[],C=[];for(C.push({idx:-1,def:f,ruleStack:[],occurrenceStack:[]});!n.isEmpty(C);){var N=C.pop();if(N===E){A&&n.last(C).idx<=M&&C.pop();continue}var I=N.def,L=N.idx,q=N.ruleStack,K=N.occurrenceStack;if(!n.isEmpty(I)){var B=I[0];if(B===y){var j={idx:L,def:n.drop(I),ruleStack:n.dropRight(q),occurrenceStack:n.dropRight(K)};C.push(j)}else if(B instanceof s.Terminal)if(L<T-1){var J=L+1,se=p[J];if(v(se,B.terminalType)){var j={idx:J,def:n.drop(I),ruleStack:q,occurrenceStack:K};C.push(j)}}else if(L===T-1)S.push({nextTokenType:B.terminalType,nextTokenOccurrence:B.idx,ruleStack:q,occurrenceStack:K}),A=!0;else throw Error("non exhaustive match");else if(B instanceof s.NonTerminal){var ce=n.cloneArr(q);ce.push(B.nonTerminalName);var me=n.cloneArr(K);me.push(B.idx);var j={idx:L,def:B.definition.concat(b,n.drop(I)),ruleStack:ce,occurrenceStack:me};C.push(j)}else if(B instanceof s.Option){var Se={idx:L,def:n.drop(I),ruleStack:q,occurrenceStack:K};C.push(Se),C.push(E);var V={idx:L,def:B.definition.concat(n.drop(I)),ruleStack:q,occurrenceStack:K};C.push(V)}else if(B instanceof s.RepetitionMandatory){var w=new s.Repetition({definition:B.definition,idx:B.idx}),O=B.definition.concat([w],n.drop(I)),j={idx:L,def:O,ruleStack:q,occurrenceStack:K};C.push(j)}else if(B instanceof s.RepetitionMandatoryWithSeparator){var W=new s.Terminal({terminalType:B.separator}),w=new s.Repetition({definition:[W].concat(B.definition),idx:B.idx}),O=B.definition.concat([w],n.drop(I)),j={idx:L,def:O,ruleStack:q,occurrenceStack:K};C.push(j)}else if(B instanceof s.RepetitionWithSeparator){var Se={idx:L,def:n.drop(I),ruleStack:q,occurrenceStack:K};C.push(Se),C.push(E);var W=new s.Terminal({terminalType:B.separator}),Q=new s.Repetition({definition:[W].concat(B.definition),idx:B.idx}),O=B.definition.concat([Q],n.drop(I)),V={idx:L,def:O,ruleStack:q,occurrenceStack:K};C.push(V)}else if(B instanceof s.Repetition){var Se={idx:L,def:n.drop(I),ruleStack:q,occurrenceStack:K};C.push(Se),C.push(E);var Q=new s.Repetition({definition:B.definition,idx:B.idx}),O=B.definition.concat([Q],n.drop(I)),V={idx:L,def:O,ruleStack:q,occurrenceStack:K};C.push(V)}else if(B instanceof s.Alternation)for(var ee=B.definition.length-1;ee>=0;ee--){var he=B.definition[ee],Ce={idx:L,def:he.definition.concat(n.drop(I)),ruleStack:q,occurrenceStack:K};C.push(Ce),C.push(E)}else if(B instanceof s.Alternative)C.push({idx:L,def:B.definition.concat(n.drop(I)),ruleStack:q,occurrenceStack:K});else if(B instanceof s.Rule)C.push(x(B,L,q,K));else throw Error("non exhaustive match")}}return S}i.nextPossibleTokensAfter=g;function x(f,p,v,_){var y=n.cloneArr(v);y.push(f.name);var b=n.cloneArr(_);return b.push(1),{idx:p,def:f.definition,ruleStack:y,occurrenceStack:b}}}),Bp=Et(i=>{"use strict";var e=i&&i.__extends||(function(){var M=function(S,C){return M=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(N,I){N.__proto__=I}||function(N,I){for(var L in I)Object.prototype.hasOwnProperty.call(I,L)&&(N[L]=I[L])},M(S,C)};return function(S,C){if(typeof C!="function"&&C!==null)throw new TypeError("Class extends value "+String(C)+" is not a constructor or null");M(S,C);function N(){this.constructor=S}S.prototype=C===null?Object.create(C):(N.prototype=C.prototype,new N)}})();Object.defineProperty(i,"__esModule",{value:!0}),i.areTokenCategoriesNotUsed=i.isStrictPrefixOfPath=i.containsPath=i.getLookaheadPathsForOptionalProd=i.getLookaheadPathsForOr=i.lookAheadSequenceFromAlternatives=i.buildSingleAlternativeLookaheadFunction=i.buildAlternativesLookAheadFunc=i.buildLookaheadFuncForOptionalProd=i.buildLookaheadFuncForOr=i.getProdType=i.PROD_TYPE=void 0;var t=Vt(),n=kp(),r=Px(),s=Th(),o=Bi(),a=Ah(),c;(function(M){M[M.OPTION=0]="OPTION",M[M.REPETITION=1]="REPETITION",M[M.REPETITION_MANDATORY=2]="REPETITION_MANDATORY",M[M.REPETITION_MANDATORY_WITH_SEPARATOR=3]="REPETITION_MANDATORY_WITH_SEPARATOR",M[M.REPETITION_WITH_SEPARATOR=4]="REPETITION_WITH_SEPARATOR",M[M.ALTERNATION=5]="ALTERNATION"})(c=i.PROD_TYPE||(i.PROD_TYPE={}));function l(M){if(M instanceof o.Option)return c.OPTION;if(M instanceof o.Repetition)return c.REPETITION;if(M instanceof o.RepetitionMandatory)return c.REPETITION_MANDATORY;if(M instanceof o.RepetitionMandatoryWithSeparator)return c.REPETITION_MANDATORY_WITH_SEPARATOR;if(M instanceof o.RepetitionWithSeparator)return c.REPETITION_WITH_SEPARATOR;if(M instanceof o.Alternation)return c.ALTERNATION;throw Error("non exhaustive match")}i.getProdType=l;function u(M,S,C,N,I,L){var q=y(M,S,C),K=T(q)?s.tokenStructuredMatcherNoCategories:s.tokenStructuredMatcher;return L(q,N,K,I)}i.buildLookaheadFuncForOr=u;function h(M,S,C,N,I,L){var q=b(M,S,I,C),K=T(q)?s.tokenStructuredMatcherNoCategories:s.tokenStructuredMatcher;return L(q[0],K,N)}i.buildLookaheadFuncForOptionalProd=h;function d(M,S,C,N){var I=M.length,L=t.every(M,function(B){return t.every(B,function(j){return j.length===1})});if(S)return function(B){for(var j=t.map(B,function(Q){return Q.GATE}),J=0;J<I;J++){var se=M[J],ce=se.length,me=j[J];if(!(me!==void 0&&me.call(this)===!1))e:for(var Se=0;Se<ce;Se++){for(var V=se[Se],w=V.length,O=0;O<w;O++){var W=this.LA(O+1);if(C(W,V[O])===!1)continue e}return J}}};if(L&&!N){var q=t.map(M,function(B){return t.flatten(B)}),K=t.reduce(q,function(B,j,J){return t.forEach(j,function(se){t.has(B,se.tokenTypeIdx)||(B[se.tokenTypeIdx]=J),t.forEach(se.categoryMatches,function(ce){t.has(B,ce)||(B[ce]=J)})}),B},[]);return function(){var B=this.LA(1);return K[B.tokenTypeIdx]}}else return function(){for(var B=0;B<I;B++){var j=M[B],J=j.length;e:for(var se=0;se<J;se++){for(var ce=j[se],me=ce.length,Se=0;Se<me;Se++){var V=this.LA(Se+1);if(C(V,ce[Se])===!1)continue e}return B}}}}i.buildAlternativesLookAheadFunc=d;function m(M,S,C){var N=t.every(M,function(j){return j.length===1}),I=M.length;if(N&&!C){var L=t.flatten(M);if(L.length===1&&t.isEmpty(L[0].categoryMatches)){var q=L[0],K=q.tokenTypeIdx;return function(){return this.LA(1).tokenTypeIdx===K}}else{var B=t.reduce(L,function(j,J,se){return j[J.tokenTypeIdx]=!0,t.forEach(J.categoryMatches,function(ce){j[ce]=!0}),j},[]);return function(){var j=this.LA(1);return B[j.tokenTypeIdx]===!0}}}else return function(){e:for(var j=0;j<I;j++){for(var J=M[j],se=J.length,ce=0;ce<se;ce++){var me=this.LA(ce+1);if(S(me,J[ce])===!1)continue e}return!0}return!1}}i.buildSingleAlternativeLookaheadFunction=m;var g=(function(M){e(S,M);function S(C,N,I){var L=M.call(this)||this;return L.topProd=C,L.targetOccurrence=N,L.targetProdType=I,L}return S.prototype.startWalking=function(){return this.walk(this.topProd),this.restDef},S.prototype.checkIsTarget=function(C,N,I,L){return C.idx===this.targetOccurrence&&this.targetProdType===N?(this.restDef=I.concat(L),!0):!1},S.prototype.walkOption=function(C,N,I){this.checkIsTarget(C,c.OPTION,N,I)||M.prototype.walkOption.call(this,C,N,I)},S.prototype.walkAtLeastOne=function(C,N,I){this.checkIsTarget(C,c.REPETITION_MANDATORY,N,I)||M.prototype.walkOption.call(this,C,N,I)},S.prototype.walkAtLeastOneSep=function(C,N,I){this.checkIsTarget(C,c.REPETITION_MANDATORY_WITH_SEPARATOR,N,I)||M.prototype.walkOption.call(this,C,N,I)},S.prototype.walkMany=function(C,N,I){this.checkIsTarget(C,c.REPETITION,N,I)||M.prototype.walkOption.call(this,C,N,I)},S.prototype.walkManySep=function(C,N,I){this.checkIsTarget(C,c.REPETITION_WITH_SEPARATOR,N,I)||M.prototype.walkOption.call(this,C,N,I)},S})(r.RestWalker),x=(function(M){e(S,M);function S(C,N,I){var L=M.call(this)||this;return L.targetOccurrence=C,L.targetProdType=N,L.targetRef=I,L.result=[],L}return S.prototype.checkIsTarget=function(C,N){C.idx===this.targetOccurrence&&this.targetProdType===N&&(this.targetRef===void 0||C===this.targetRef)&&(this.result=C.definition)},S.prototype.visitOption=function(C){this.checkIsTarget(C,c.OPTION)},S.prototype.visitRepetition=function(C){this.checkIsTarget(C,c.REPETITION)},S.prototype.visitRepetitionMandatory=function(C){this.checkIsTarget(C,c.REPETITION_MANDATORY)},S.prototype.visitRepetitionMandatoryWithSeparator=function(C){this.checkIsTarget(C,c.REPETITION_MANDATORY_WITH_SEPARATOR)},S.prototype.visitRepetitionWithSeparator=function(C){this.checkIsTarget(C,c.REPETITION_WITH_SEPARATOR)},S.prototype.visitAlternation=function(C){this.checkIsTarget(C,c.ALTERNATION)},S})(a.GAstVisitor);function f(M){for(var S=new Array(M),C=0;C<M;C++)S[C]=[];return S}function p(M){for(var S=[""],C=0;C<M.length;C++){for(var N=M[C],I=[],L=0;L<S.length;L++){var q=S[L];I.push(q+"_"+N.tokenTypeIdx);for(var K=0;K<N.categoryMatches.length;K++){var B="_"+N.categoryMatches[K];I.push(q+B)}}S=I}return S}function v(M,S,C){for(var N=0;N<M.length;N++)if(N!==C)for(var I=M[N],L=0;L<S.length;L++){var q=S[L];if(I[q]===!0)return!1}return!0}function _(M,S){for(var C=t.map(M,function(J){return n.possiblePathsFrom([J],1)}),N=f(C.length),I=t.map(C,function(J){var se={};return t.forEach(J,function(ce){var me=p(ce.partialPath);t.forEach(me,function(Se){se[Se]=!0})}),se}),L=C,q=1;q<=S;q++){var K=L;L=f(K.length);for(var B=function(J){for(var se=K[J],ce=0;ce<se.length;ce++){var me=se[ce].partialPath,Se=se[ce].suffixDef,V=p(me),w=v(I,V,J);if(w||t.isEmpty(Se)||me.length===S){var O=N[J];if(E(O,me)===!1){O.push(me);for(var W=0;W<V.length;W++){var Q=V[W];I[J][Q]=!0}}}else{var ee=n.possiblePathsFrom(Se,q+1,me);L[J]=L[J].concat(ee),t.forEach(ee,function(he){var Ce=p(he.partialPath);t.forEach(Ce,function(oe){I[J][oe]=!0})})}}},j=0;j<K.length;j++)B(j)}return N}i.lookAheadSequenceFromAlternatives=_;function y(M,S,C,N){var I=new x(M,c.ALTERNATION,N);return S.accept(I),_(I.result,C)}i.getLookaheadPathsForOr=y;function b(M,S,C,N){var I=new x(M,C);S.accept(I);var L=I.result,q=new g(S,M,C),K=q.startWalking(),B=new o.Alternative({definition:L}),j=new o.Alternative({definition:K});return _([B,j],N)}i.getLookaheadPathsForOptionalProd=b;function E(M,S){e:for(var C=0;C<M.length;C++){var N=M[C];if(N.length===S.length){for(var I=0;I<N.length;I++){var L=S[I],q=N[I],K=L===q||q.categoryMatchesMap[L.tokenTypeIdx]!==void 0;if(K===!1)continue e}return!0}}return!1}i.containsPath=E;function A(M,S){return M.length<S.length&&t.every(M,function(C,N){var I=S[N];return C===I||I.categoryMatchesMap[C.tokenTypeIdx]})}i.isStrictPrefixOfPath=A;function T(M){return t.every(M,function(S){return t.every(S,function(C){return t.every(C,function(N){return t.isEmpty(N.categoryMatches)})})})}i.areTokenCategoriesNotUsed=T}),oM=Et(i=>{"use strict";var e=i&&i.__extends||(function(){var N=function(I,L){return N=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(q,K){q.__proto__=K}||function(q,K){for(var B in K)Object.prototype.hasOwnProperty.call(K,B)&&(q[B]=K[B])},N(I,L)};return function(I,L){if(typeof L!="function"&&L!==null)throw new TypeError("Class extends value "+String(L)+" is not a constructor or null");N(I,L);function q(){this.constructor=I}I.prototype=L===null?Object.create(L):(q.prototype=L.prototype,new q)}})();Object.defineProperty(i,"__esModule",{value:!0}),i.checkPrefixAlternativesAmbiguities=i.validateSomeNonEmptyLookaheadPath=i.validateTooManyAlts=i.RepetionCollector=i.validateAmbiguousAlternationAlternatives=i.validateEmptyOrAlternative=i.getFirstNoneTerminal=i.validateNoLeftRecursion=i.validateRuleIsOverridden=i.validateRuleDoesNotAlreadyExist=i.OccurrenceValidationCollector=i.identifyProductionForDuplicates=i.validateGrammar=void 0;var t=Vt(),n=Vt(),r=ji(),s=Fp(),o=Bp(),a=kp(),c=Bi(),l=Ah();function u(N,I,L,q,K){var B=t.map(N,function(w){return h(w,q)}),j=t.map(N,function(w){return p(w,w,q)}),J=[],se=[],ce=[];n.every(j,n.isEmpty)&&(J=n.map(N,function(w){return y(w,q)}),se=n.map(N,function(w){return b(w,I,q)}),ce=T(N,I,q));var me=C(N,L,q),Se=n.map(N,function(w){return A(w,q)}),V=n.map(N,function(w){return x(w,N,K,q)});return t.flatten(B.concat(ce,j,J,se,me,Se,V))}i.validateGrammar=u;function h(N,I){var L=new g;N.accept(L);var q=L.allProductions,K=t.groupBy(q,d),B=t.pick(K,function(J){return J.length>1}),j=t.map(t.values(B),function(J){var se=t.first(J),ce=I.buildDuplicateFoundError(N,J),me=s.getProductionDslName(se),Se={message:ce,type:r.ParserDefinitionErrorType.DUPLICATE_PRODUCTIONS,ruleName:N.name,dslName:me,occurrence:se.idx},V=m(se);return V&&(Se.parameter=V),Se});return j}function d(N){return s.getProductionDslName(N)+"_#_"+N.idx+"_#_"+m(N)}i.identifyProductionForDuplicates=d;function m(N){return N instanceof c.Terminal?N.terminalType.name:N instanceof c.NonTerminal?N.nonTerminalName:""}var g=(function(N){e(I,N);function I(){var L=N!==null&&N.apply(this,arguments)||this;return L.allProductions=[],L}return I.prototype.visitNonTerminal=function(L){this.allProductions.push(L)},I.prototype.visitOption=function(L){this.allProductions.push(L)},I.prototype.visitRepetitionWithSeparator=function(L){this.allProductions.push(L)},I.prototype.visitRepetitionMandatory=function(L){this.allProductions.push(L)},I.prototype.visitRepetitionMandatoryWithSeparator=function(L){this.allProductions.push(L)},I.prototype.visitRepetition=function(L){this.allProductions.push(L)},I.prototype.visitAlternation=function(L){this.allProductions.push(L)},I.prototype.visitTerminal=function(L){this.allProductions.push(L)},I})(l.GAstVisitor);i.OccurrenceValidationCollector=g;function x(N,I,L,q){var K=[],B=n.reduce(I,function(J,se){return se.name===N.name?J+1:J},0);if(B>1){var j=q.buildDuplicateRuleNameError({topLevelRule:N,grammarName:L});K.push({message:j,type:r.ParserDefinitionErrorType.DUPLICATE_RULE_NAME,ruleName:N.name})}return K}i.validateRuleDoesNotAlreadyExist=x;function f(N,I,L){var q=[],K;return t.contains(I,N)||(K="Invalid rule override, rule: ->"+N+"<- cannot be overridden in the grammar: ->"+L+"<-as it is not defined in any of the super grammars ",q.push({message:K,type:r.ParserDefinitionErrorType.INVALID_RULE_OVERRIDE,ruleName:N})),q}i.validateRuleIsOverridden=f;function p(N,I,L,q){q===void 0&&(q=[]);var K=[],B=v(I.definition);if(t.isEmpty(B))return[];var j=N.name,J=t.contains(B,N);J&&K.push({message:L.buildLeftRecursionError({topLevelRule:N,leftRecursionPath:q}),type:r.ParserDefinitionErrorType.LEFT_RECURSION,ruleName:j});var se=t.difference(B,q.concat([N])),ce=t.map(se,function(me){var Se=t.cloneArr(q);return Se.push(me),p(N,me,L,Se)});return K.concat(t.flatten(ce))}i.validateNoLeftRecursion=p;function v(N){var I=[];if(t.isEmpty(N))return I;var L=t.first(N);if(L instanceof c.NonTerminal)I.push(L.referencedRule);else if(L instanceof c.Alternative||L instanceof c.Option||L instanceof c.RepetitionMandatory||L instanceof c.RepetitionMandatoryWithSeparator||L instanceof c.RepetitionWithSeparator||L instanceof c.Repetition)I=I.concat(v(L.definition));else if(L instanceof c.Alternation)I=t.flatten(t.map(L.definition,function(j){return v(j.definition)}));else if(!(L instanceof c.Terminal))throw Error("non exhaustive match");var q=s.isOptionalProd(L),K=N.length>1;if(q&&K){var B=t.drop(N);return I.concat(v(B))}else return I}i.getFirstNoneTerminal=v;var _=(function(N){e(I,N);function I(){var L=N!==null&&N.apply(this,arguments)||this;return L.alternations=[],L}return I.prototype.visitAlternation=function(L){this.alternations.push(L)},I})(l.GAstVisitor);function y(N,I){var L=new _;N.accept(L);var q=L.alternations,K=t.reduce(q,function(B,j){var J=t.dropRight(j.definition),se=t.map(J,function(ce,me){var Se=a.nextPossibleTokensAfter([ce],[],null,1);return t.isEmpty(Se)?{message:I.buildEmptyAlternationError({topLevelRule:N,alternation:j,emptyChoiceIdx:me}),type:r.ParserDefinitionErrorType.NONE_LAST_EMPTY_ALT,ruleName:N.name,occurrence:j.idx,alternative:me+1}:null});return B.concat(t.compact(se))},[]);return K}i.validateEmptyOrAlternative=y;function b(N,I,L){var q=new _;N.accept(q);var K=q.alternations;K=n.reject(K,function(j){return j.ignoreAmbiguities===!0});var B=t.reduce(K,function(j,J){var se=J.idx,ce=J.maxLookahead||I,me=o.getLookaheadPathsForOr(se,N,ce,J),Se=M(me,J,N,L),V=S(me,J,N,L);return j.concat(Se,V)},[]);return B}i.validateAmbiguousAlternationAlternatives=b;var E=(function(N){e(I,N);function I(){var L=N!==null&&N.apply(this,arguments)||this;return L.allProductions=[],L}return I.prototype.visitRepetitionWithSeparator=function(L){this.allProductions.push(L)},I.prototype.visitRepetitionMandatory=function(L){this.allProductions.push(L)},I.prototype.visitRepetitionMandatoryWithSeparator=function(L){this.allProductions.push(L)},I.prototype.visitRepetition=function(L){this.allProductions.push(L)},I})(l.GAstVisitor);i.RepetionCollector=E;function A(N,I){var L=new _;N.accept(L);var q=L.alternations,K=t.reduce(q,function(B,j){return j.definition.length>255&&B.push({message:I.buildTooManyAlternativesError({topLevelRule:N,alternation:j}),type:r.ParserDefinitionErrorType.TOO_MANY_ALTS,ruleName:N.name,occurrence:j.idx}),B},[]);return K}i.validateTooManyAlts=A;function T(N,I,L){var q=[];return n.forEach(N,function(K){var B=new E;K.accept(B);var j=B.allProductions;n.forEach(j,function(J){var se=o.getProdType(J),ce=J.maxLookahead||I,me=J.idx,Se=o.getLookaheadPathsForOptionalProd(me,K,se,ce),V=Se[0];if(n.isEmpty(n.flatten(V))){var w=L.buildEmptyRepetitionError({topLevelRule:K,repetition:J});q.push({message:w,type:r.ParserDefinitionErrorType.NO_NON_EMPTY_LOOKAHEAD,ruleName:K.name})}})}),q}i.validateSomeNonEmptyLookaheadPath=T;function M(N,I,L,q){var K=[],B=n.reduce(N,function(J,se,ce){return I.definition[ce].ignoreAmbiguities===!0||n.forEach(se,function(me){var Se=[ce];n.forEach(N,function(V,w){ce!==w&&o.containsPath(V,me)&&I.definition[w].ignoreAmbiguities!==!0&&Se.push(w)}),Se.length>1&&!o.containsPath(K,me)&&(K.push(me),J.push({alts:Se,path:me}))}),J},[]),j=t.map(B,function(J){var se=n.map(J.alts,function(me){return me+1}),ce=q.buildAlternationAmbiguityError({topLevelRule:L,alternation:I,ambiguityIndices:se,prefixPath:J.path});return{message:ce,type:r.ParserDefinitionErrorType.AMBIGUOUS_ALTS,ruleName:L.name,occurrence:I.idx,alternatives:[J.alts]}});return j}function S(N,I,L,q){var K=[],B=n.reduce(N,function(j,J,se){var ce=n.map(J,function(me){return{idx:se,path:me}});return j.concat(ce)},[]);return n.forEach(B,function(j){var J=I.definition[j.idx];if(J.ignoreAmbiguities!==!0){var se=j.idx,ce=j.path,me=n.findAll(B,function(V){return I.definition[V.idx].ignoreAmbiguities!==!0&&V.idx<se&&o.isStrictPrefixOfPath(V.path,ce)}),Se=n.map(me,function(V){var w=[V.idx+1,se+1],O=I.idx===0?"":I.idx,W=q.buildAlternationPrefixAmbiguityError({topLevelRule:L,alternation:I,ambiguityIndices:w,prefixPath:V.path});return{message:W,type:r.ParserDefinitionErrorType.AMBIGUOUS_PREFIX_ALTS,ruleName:L.name,occurrence:O,alternatives:w}});K=K.concat(Se)}}),K}i.checkPrefixAlternativesAmbiguities=S;function C(N,I,L){var q=[],K=n.map(I,function(B){return B.name});return n.forEach(N,function(B){var j=B.name;if(n.contains(K,j)){var J=L.buildNamespaceConflictError(B);q.push({message:J,type:r.ParserDefinitionErrorType.CONFLICT_TOKENS_RULES_NAMESPACE,ruleName:j})}}),q}}),pP=Et(i=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.validateGrammar=i.resolveGrammar=void 0;var e=Vt(),t=fP(),n=oM(),r=Up();function s(a){a=e.defaults(a,{errMsgProvider:r.defaultGrammarResolverErrorProvider});var c={};return e.forEach(a.rules,function(l){c[l.name]=l}),t.resolveGrammar(c,a.errMsgProvider)}i.resolveGrammar=s;function o(a){return a=e.defaults(a,{errMsgProvider:r.defaultGrammarValidatorErrorProvider}),n.validateGrammar(a.rules,a.maxLookahead,a.tokenTypes,a.errMsgProvider,a.grammarName)}i.validateGrammar=o}),wh=Et(i=>{"use strict";var e=i&&i.__extends||(function(){var g=function(x,f){return g=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(p,v){p.__proto__=v}||function(p,v){for(var _ in v)Object.prototype.hasOwnProperty.call(v,_)&&(p[_]=v[_])},g(x,f)};return function(x,f){if(typeof f!="function"&&f!==null)throw new TypeError("Class extends value "+String(f)+" is not a constructor or null");g(x,f);function p(){this.constructor=x}x.prototype=f===null?Object.create(f):(p.prototype=f.prototype,new p)}})();Object.defineProperty(i,"__esModule",{value:!0}),i.EarlyExitException=i.NotAllInputParsedException=i.NoViableAltException=i.MismatchedTokenException=i.isRecognitionException=void 0;var t=Vt(),n="MismatchedTokenException",r="NoViableAltException",s="EarlyExitException",o="NotAllInputParsedException",a=[n,r,s,o];Object.freeze(a);function c(g){return t.contains(a,g.name)}i.isRecognitionException=c;var l=(function(g){e(x,g);function x(f,p){var v=this.constructor,_=g.call(this,f)||this;return _.token=p,_.resyncedTokens=[],Object.setPrototypeOf(_,v.prototype),Error.captureStackTrace&&Error.captureStackTrace(_,_.constructor),_}return x})(Error),u=(function(g){e(x,g);function x(f,p,v){var _=g.call(this,f,p)||this;return _.previousToken=v,_.name=n,_}return x})(l);i.MismatchedTokenException=u;var h=(function(g){e(x,g);function x(f,p,v){var _=g.call(this,f,p)||this;return _.previousToken=v,_.name=r,_}return x})(l);i.NoViableAltException=h;var d=(function(g){e(x,g);function x(f,p){var v=g.call(this,f,p)||this;return v.name=o,v}return x})(l);i.NotAllInputParsedException=d;var m=(function(g){e(x,g);function x(f,p,v){var _=g.call(this,f,p)||this;return _.previousToken=v,_.name=s,_}return x})(l);i.EarlyExitException=m}),aM=Et(i=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.attemptInRepetitionRecovery=i.Recoverable=i.InRuleRecoveryException=i.IN_RULE_RECOVERY_EXCEPTION=i.EOF_FOLLOW_KEY=void 0;var e=oa(),t=Vt(),n=wh(),r=sM(),s=ji();i.EOF_FOLLOW_KEY={},i.IN_RULE_RECOVERY_EXCEPTION="InRuleRecoveryException";function o(l){this.name=i.IN_RULE_RECOVERY_EXCEPTION,this.message=l}i.InRuleRecoveryException=o,o.prototype=Error.prototype;var a=(function(){function l(){}return l.prototype.initRecoverable=function(u){this.firstAfterRepMap={},this.resyncFollows={},this.recoveryEnabled=t.has(u,"recoveryEnabled")?u.recoveryEnabled:s.DEFAULT_PARSER_CONFIG.recoveryEnabled,this.recoveryEnabled&&(this.attemptInRepetitionRecovery=c)},l.prototype.getTokenToInsert=function(u){var h=e.createTokenInstance(u,"",NaN,NaN,NaN,NaN,NaN,NaN);return h.isInsertedInRecovery=!0,h},l.prototype.canTokenTypeBeInsertedInRecovery=function(u){return!0},l.prototype.tryInRepetitionRecovery=function(u,h,d,m){for(var g=this,x=this.findReSyncTokenType(),f=this.exportLexerState(),p=[],v=!1,_=this.LA(1),y=this.LA(1),b=function(){var E=g.LA(0),A=g.errorMessageProvider.buildMismatchTokenMessage({expected:m,actual:_,previous:E,ruleName:g.getCurrRuleFullName()}),T=new n.MismatchedTokenException(A,_,g.LA(0));T.resyncedTokens=t.dropRight(p),g.SAVE_ERROR(T)};!v;)if(this.tokenMatcher(y,m)){b();return}else if(d.call(this)){b(),u.apply(this,h);return}else this.tokenMatcher(y,x)?v=!0:(y=this.SKIP_TOKEN(),this.addToResyncTokens(y,p));this.importLexerState(f)},l.prototype.shouldInRepetitionRecoveryBeTried=function(u,h,d){return!(d===!1||u===void 0||h===void 0||this.tokenMatcher(this.LA(1),u)||this.isBackTracking()||this.canPerformInRuleRecovery(u,this.getFollowsForInRuleRecovery(u,h)))},l.prototype.getFollowsForInRuleRecovery=function(u,h){var d=this.getCurrentGrammarPath(u,h),m=this.getNextPossibleTokenTypes(d);return m},l.prototype.tryInRuleRecovery=function(u,h){if(this.canRecoverWithSingleTokenInsertion(u,h)){var d=this.getTokenToInsert(u);return d}if(this.canRecoverWithSingleTokenDeletion(u)){var m=this.SKIP_TOKEN();return this.consumeToken(),m}throw new o("sad sad panda")},l.prototype.canPerformInRuleRecovery=function(u,h){return this.canRecoverWithSingleTokenInsertion(u,h)||this.canRecoverWithSingleTokenDeletion(u)},l.prototype.canRecoverWithSingleTokenInsertion=function(u,h){var d=this;if(!this.canTokenTypeBeInsertedInRecovery(u)||t.isEmpty(h))return!1;var m=this.LA(1),g=t.find(h,function(x){return d.tokenMatcher(m,x)})!==void 0;return g},l.prototype.canRecoverWithSingleTokenDeletion=function(u){var h=this.tokenMatcher(this.LA(2),u);return h},l.prototype.isInCurrentRuleReSyncSet=function(u){var h=this.getCurrFollowKey(),d=this.getFollowSetFromFollowKey(h);return t.contains(d,u)},l.prototype.findReSyncTokenType=function(){for(var u=this.flattenFollowSet(),h=this.LA(1),d=2;;){var m=h.tokenType;if(t.contains(u,m))return m;h=this.LA(d),d++}},l.prototype.getCurrFollowKey=function(){if(this.RULE_STACK.length===1)return i.EOF_FOLLOW_KEY;var u=this.getLastExplicitRuleShortName(),h=this.getLastExplicitRuleOccurrenceIndex(),d=this.getPreviousExplicitRuleShortName();return{ruleName:this.shortRuleNameToFullName(u),idxInCallingRule:h,inRule:this.shortRuleNameToFullName(d)}},l.prototype.buildFullFollowKeyStack=function(){var u=this,h=this.RULE_STACK,d=this.RULE_OCCURRENCE_STACK;return t.map(h,function(m,g){return g===0?i.EOF_FOLLOW_KEY:{ruleName:u.shortRuleNameToFullName(m),idxInCallingRule:d[g],inRule:u.shortRuleNameToFullName(h[g-1])}})},l.prototype.flattenFollowSet=function(){var u=this,h=t.map(this.buildFullFollowKeyStack(),function(d){return u.getFollowSetFromFollowKey(d)});return t.flatten(h)},l.prototype.getFollowSetFromFollowKey=function(u){if(u===i.EOF_FOLLOW_KEY)return[e.EOF];var h=u.ruleName+u.idxInCallingRule+r.IN+u.inRule;return this.resyncFollows[h]},l.prototype.addToResyncTokens=function(u,h){return this.tokenMatcher(u,e.EOF)||h.push(u),h},l.prototype.reSyncTo=function(u){for(var h=[],d=this.LA(1);this.tokenMatcher(d,u)===!1;)d=this.SKIP_TOKEN(),this.addToResyncTokens(d,h);return t.dropRight(h)},l.prototype.attemptInRepetitionRecovery=function(u,h,d,m,g,x,f){},l.prototype.getCurrentGrammarPath=function(u,h){var d=this.getHumanReadableRuleStack(),m=t.cloneArr(this.RULE_OCCURRENCE_STACK),g={ruleStack:d,occurrenceStack:m,lastTok:u,lastTokOccurrence:h};return g},l.prototype.getHumanReadableRuleStack=function(){var u=this;return t.map(this.RULE_STACK,function(h){return u.shortRuleNameToFullName(h)})},l})();i.Recoverable=a;function c(l,u,h,d,m,g,x){var f=this.getKeyForAutomaticLookahead(d,m),p=this.firstAfterRepMap[f];if(p===void 0){var v=this.getCurrRuleFullName(),_=this.getGAstProductions()[v],y=new g(_,m);p=y.startWalking(),this.firstAfterRepMap[f]=p}var b=p.token,E=p.occurrence,A=p.isEndOfRule;this.RULE_STACK.length===1&&A&&b===void 0&&(b=e.EOF,E=1),this.shouldInRepetitionRecoveryBeTried(b,E,x)&&this.tryInRepetitionRecovery(l,u,h,b)}i.attemptInRepetitionRecovery=c}),Ix=Et(i=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.getKeyForAutomaticLookahead=i.AT_LEAST_ONE_SEP_IDX=i.MANY_SEP_IDX=i.AT_LEAST_ONE_IDX=i.MANY_IDX=i.OPTION_IDX=i.OR_IDX=i.BITS_FOR_ALT_IDX=i.BITS_FOR_RULE_IDX=i.BITS_FOR_OCCURRENCE_IDX=i.BITS_FOR_METHOD_TYPE=void 0,i.BITS_FOR_METHOD_TYPE=4,i.BITS_FOR_OCCURRENCE_IDX=8,i.BITS_FOR_RULE_IDX=12,i.BITS_FOR_ALT_IDX=8,i.OR_IDX=1<<i.BITS_FOR_OCCURRENCE_IDX,i.OPTION_IDX=2<<i.BITS_FOR_OCCURRENCE_IDX,i.MANY_IDX=3<<i.BITS_FOR_OCCURRENCE_IDX,i.AT_LEAST_ONE_IDX=4<<i.BITS_FOR_OCCURRENCE_IDX,i.MANY_SEP_IDX=5<<i.BITS_FOR_OCCURRENCE_IDX,i.AT_LEAST_ONE_SEP_IDX=6<<i.BITS_FOR_OCCURRENCE_IDX;function e(n,r,s){return s|r|n}i.getKeyForAutomaticLookahead=e;var t=32-i.BITS_FOR_ALT_IDX}),mP=Et(i=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.LooksAhead=void 0;var e=Bp(),t=Vt(),n=ji(),r=Ix(),s=Fp(),o=(function(){function a(){}return a.prototype.initLooksAhead=function(c){this.dynamicTokensEnabled=t.has(c,"dynamicTokensEnabled")?c.dynamicTokensEnabled:n.DEFAULT_PARSER_CONFIG.dynamicTokensEnabled,this.maxLookahead=t.has(c,"maxLookahead")?c.maxLookahead:n.DEFAULT_PARSER_CONFIG.maxLookahead,this.lookAheadFuncsCache=t.isES2015MapSupported()?new Map:[],t.isES2015MapSupported()?(this.getLaFuncFromCache=this.getLaFuncFromMap,this.setLaFuncCache=this.setLaFuncCacheUsingMap):(this.getLaFuncFromCache=this.getLaFuncFromObj,this.setLaFuncCache=this.setLaFuncUsingObj)},a.prototype.preComputeLookaheadFunctions=function(c){var l=this;t.forEach(c,function(u){l.TRACE_INIT(u.name+" Rule Lookahead",function(){var h=s.collectMethods(u),d=h.alternation,m=h.repetition,g=h.option,x=h.repetitionMandatory,f=h.repetitionMandatoryWithSeparator,p=h.repetitionWithSeparator;t.forEach(d,function(v){var _=v.idx===0?"":v.idx;l.TRACE_INIT(""+s.getProductionDslName(v)+_,function(){var y=e.buildLookaheadFuncForOr(v.idx,u,v.maxLookahead||l.maxLookahead,v.hasPredicates,l.dynamicTokensEnabled,l.lookAheadBuilderForAlternatives),b=r.getKeyForAutomaticLookahead(l.fullRuleNameToShort[u.name],r.OR_IDX,v.idx);l.setLaFuncCache(b,y)})}),t.forEach(m,function(v){l.computeLookaheadFunc(u,v.idx,r.MANY_IDX,e.PROD_TYPE.REPETITION,v.maxLookahead,s.getProductionDslName(v))}),t.forEach(g,function(v){l.computeLookaheadFunc(u,v.idx,r.OPTION_IDX,e.PROD_TYPE.OPTION,v.maxLookahead,s.getProductionDslName(v))}),t.forEach(x,function(v){l.computeLookaheadFunc(u,v.idx,r.AT_LEAST_ONE_IDX,e.PROD_TYPE.REPETITION_MANDATORY,v.maxLookahead,s.getProductionDslName(v))}),t.forEach(f,function(v){l.computeLookaheadFunc(u,v.idx,r.AT_LEAST_ONE_SEP_IDX,e.PROD_TYPE.REPETITION_MANDATORY_WITH_SEPARATOR,v.maxLookahead,s.getProductionDslName(v))}),t.forEach(p,function(v){l.computeLookaheadFunc(u,v.idx,r.MANY_SEP_IDX,e.PROD_TYPE.REPETITION_WITH_SEPARATOR,v.maxLookahead,s.getProductionDslName(v))})})})},a.prototype.computeLookaheadFunc=function(c,l,u,h,d,m){var g=this;this.TRACE_INIT(""+m+(l===0?"":l),function(){var x=e.buildLookaheadFuncForOptionalProd(l,c,d||g.maxLookahead,g.dynamicTokensEnabled,h,g.lookAheadBuilderForOptional),f=r.getKeyForAutomaticLookahead(g.fullRuleNameToShort[c.name],u,l);g.setLaFuncCache(f,x)})},a.prototype.lookAheadBuilderForOptional=function(c,l,u){return e.buildSingleAlternativeLookaheadFunction(c,l,u)},a.prototype.lookAheadBuilderForAlternatives=function(c,l,u,h){return e.buildAlternativesLookAheadFunc(c,l,u,h)},a.prototype.getKeyForAutomaticLookahead=function(c,l){var u=this.getLastExplicitRuleShortName();return r.getKeyForAutomaticLookahead(u,c,l)},a.prototype.getLaFuncFromCache=function(c){},a.prototype.getLaFuncFromMap=function(c){return this.lookAheadFuncsCache.get(c)},a.prototype.getLaFuncFromObj=function(c){return this.lookAheadFuncsCache[c]},a.prototype.setLaFuncCache=function(c,l){},a.prototype.setLaFuncCacheUsingMap=function(c,l){this.lookAheadFuncsCache.set(c,l)},a.prototype.setLaFuncUsingObj=function(c,l){this.lookAheadFuncsCache[c]=l},a})();i.LooksAhead=o}),gP=Et(i=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.addNoneTerminalToCst=i.addTerminalToCst=i.setNodeLocationFull=i.setNodeLocationOnlyOffset=void 0;function e(s,o){isNaN(s.startOffset)===!0?(s.startOffset=o.startOffset,s.endOffset=o.endOffset):s.endOffset<o.endOffset&&(s.endOffset=o.endOffset)}i.setNodeLocationOnlyOffset=e;function t(s,o){isNaN(s.startOffset)===!0?(s.startOffset=o.startOffset,s.startColumn=o.startColumn,s.startLine=o.startLine,s.endOffset=o.endOffset,s.endColumn=o.endColumn,s.endLine=o.endLine):s.endOffset<o.endOffset&&(s.endOffset=o.endOffset,s.endColumn=o.endColumn,s.endLine=o.endLine)}i.setNodeLocationFull=t;function n(s,o,a){s.children[a]===void 0?s.children[a]=[o]:s.children[a].push(o)}i.addTerminalToCst=n;function r(s,o,a){s.children[o]===void 0?s.children[o]=[a]:s.children[o].push(a)}i.addNoneTerminalToCst=r}),cM=Et(i=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.defineNameProp=i.functionName=i.classNameFromInstance=void 0;var e=Vt();function t(o){return r(o.constructor)}i.classNameFromInstance=t;var n="name";function r(o){var a=o.name;return a||"anonymous"}i.functionName=r;function s(o,a){var c=Object.getOwnPropertyDescriptor(o,n);return e.isUndefined(c)||c.configurable?(Object.defineProperty(o,n,{enumerable:!1,configurable:!0,writable:!1,value:a}),!0):!1}i.defineNameProp=s}),xP=Et(i=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.validateRedundantMethods=i.validateMissingCstMethods=i.validateVisitor=i.CstVisitorDefinitionError=i.createBaseVisitorConstructorWithDefaults=i.createBaseSemanticVisitorConstructor=i.defaultVisit=void 0;var e=Vt(),t=cM();function n(h,d){for(var m=e.keys(h),g=m.length,x=0;x<g;x++)for(var f=m[x],p=h[f],v=p.length,_=0;_<v;_++){var y=p[_];y.tokenTypeIdx===void 0&&this[y.name](y.children,d)}}i.defaultVisit=n;function r(h,d){var m=function(){};t.defineNameProp(m,h+"BaseSemantics");var g={visit:function(x,f){if(e.isArray(x)&&(x=x[0]),!e.isUndefined(x))return this[x.name](x.children,f)},validateVisitor:function(){var x=a(this,d);if(!e.isEmpty(x)){var f=e.map(x,function(p){return p.msg});throw Error("Errors Detected in CST Visitor <"+t.functionName(this.constructor)+`>:
`+(""+f.join(`
`).replace(/\n/g,`
`)))}}};return m.prototype=g,m.prototype.constructor=m,m._RULE_NAMES=d,m}i.createBaseSemanticVisitorConstructor=r;function s(h,d,m){var g=function(){};t.defineNameProp(g,h+"BaseSemanticsWithDefaults");var x=Object.create(m.prototype);return e.forEach(d,function(f){x[f]=n}),g.prototype=x,g.prototype.constructor=g,g}i.createBaseVisitorConstructorWithDefaults=s;var o;(function(h){h[h.REDUNDANT_METHOD=0]="REDUNDANT_METHOD",h[h.MISSING_METHOD=1]="MISSING_METHOD"})(o=i.CstVisitorDefinitionError||(i.CstVisitorDefinitionError={}));function a(h,d){var m=c(h,d),g=u(h,d);return m.concat(g)}i.validateVisitor=a;function c(h,d){var m=e.map(d,function(g){if(!e.isFunction(h[g]))return{msg:"Missing visitor method: <"+g+"> on "+t.functionName(h.constructor)+" CST Visitor.",type:o.MISSING_METHOD,methodName:g}});return e.compact(m)}i.validateMissingCstMethods=c;var l=["constructor","visit","validateVisitor"];function u(h,d){var m=[];for(var g in h)e.isFunction(h[g])&&!e.contains(l,g)&&!e.contains(d,g)&&m.push({msg:"Redundant visitor method: <"+g+"> on "+t.functionName(h.constructor)+` CST Visitor
There is no Grammar Rule corresponding to this method's name.
`,type:o.REDUNDANT_METHOD,methodName:g});return m}i.validateRedundantMethods=u}),yP=Et(i=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.TreeBuilder=void 0;var e=gP(),t=Vt(),n=xP(),r=ji(),s=(function(){function o(){}return o.prototype.initTreeBuilder=function(a){if(this.CST_STACK=[],this.outputCst=a.outputCst,this.nodeLocationTracking=t.has(a,"nodeLocationTracking")?a.nodeLocationTracking:r.DEFAULT_PARSER_CONFIG.nodeLocationTracking,!this.outputCst)this.cstInvocationStateUpdate=t.NOOP,this.cstFinallyStateUpdate=t.NOOP,this.cstPostTerminal=t.NOOP,this.cstPostNonTerminal=t.NOOP,this.cstPostRule=t.NOOP;else if(/full/i.test(this.nodeLocationTracking))this.recoveryEnabled?(this.setNodeLocationFromToken=e.setNodeLocationFull,this.setNodeLocationFromNode=e.setNodeLocationFull,this.cstPostRule=t.NOOP,this.setInitialNodeLocation=this.setInitialNodeLocationFullRecovery):(this.setNodeLocationFromToken=t.NOOP,this.setNodeLocationFromNode=t.NOOP,this.cstPostRule=this.cstPostRuleFull,this.setInitialNodeLocation=this.setInitialNodeLocationFullRegular);else if(/onlyOffset/i.test(this.nodeLocationTracking))this.recoveryEnabled?(this.setNodeLocationFromToken=e.setNodeLocationOnlyOffset,this.setNodeLocationFromNode=e.setNodeLocationOnlyOffset,this.cstPostRule=t.NOOP,this.setInitialNodeLocation=this.setInitialNodeLocationOnlyOffsetRecovery):(this.setNodeLocationFromToken=t.NOOP,this.setNodeLocationFromNode=t.NOOP,this.cstPostRule=this.cstPostRuleOnlyOffset,this.setInitialNodeLocation=this.setInitialNodeLocationOnlyOffsetRegular);else if(/none/i.test(this.nodeLocationTracking))this.setNodeLocationFromToken=t.NOOP,this.setNodeLocationFromNode=t.NOOP,this.cstPostRule=t.NOOP,this.setInitialNodeLocation=t.NOOP;else throw Error('Invalid <nodeLocationTracking> config option: "'+a.nodeLocationTracking+'"')},o.prototype.setInitialNodeLocationOnlyOffsetRecovery=function(a){a.location={startOffset:NaN,endOffset:NaN}},o.prototype.setInitialNodeLocationOnlyOffsetRegular=function(a){a.location={startOffset:this.LA(1).startOffset,endOffset:NaN}},o.prototype.setInitialNodeLocationFullRecovery=function(a){a.location={startOffset:NaN,startLine:NaN,startColumn:NaN,endOffset:NaN,endLine:NaN,endColumn:NaN}},o.prototype.setInitialNodeLocationFullRegular=function(a){var c=this.LA(1);a.location={startOffset:c.startOffset,startLine:c.startLine,startColumn:c.startColumn,endOffset:NaN,endLine:NaN,endColumn:NaN}},o.prototype.cstInvocationStateUpdate=function(a,c){var l={name:a,children:{}};this.setInitialNodeLocation(l),this.CST_STACK.push(l)},o.prototype.cstFinallyStateUpdate=function(){this.CST_STACK.pop()},o.prototype.cstPostRuleFull=function(a){var c=this.LA(0),l=a.location;l.startOffset<=c.startOffset?(l.endOffset=c.endOffset,l.endLine=c.endLine,l.endColumn=c.endColumn):(l.startOffset=NaN,l.startLine=NaN,l.startColumn=NaN)},o.prototype.cstPostRuleOnlyOffset=function(a){var c=this.LA(0),l=a.location;l.startOffset<=c.startOffset?l.endOffset=c.endOffset:l.startOffset=NaN},o.prototype.cstPostTerminal=function(a,c){var l=this.CST_STACK[this.CST_STACK.length-1];e.addTerminalToCst(l,c,a),this.setNodeLocationFromToken(l.location,c)},o.prototype.cstPostNonTerminal=function(a,c){var l=this.CST_STACK[this.CST_STACK.length-1];e.addNoneTerminalToCst(l,c,a),this.setNodeLocationFromNode(l.location,a.location)},o.prototype.getBaseCstVisitorConstructor=function(){if(t.isUndefined(this.baseCstVisitorConstructor)){var a=n.createBaseSemanticVisitorConstructor(this.className,t.keys(this.gastProductionsCache));return this.baseCstVisitorConstructor=a,a}return this.baseCstVisitorConstructor},o.prototype.getBaseCstVisitorConstructorWithDefaults=function(){if(t.isUndefined(this.baseCstVisitorWithDefaultsConstructor)){var a=n.createBaseVisitorConstructorWithDefaults(this.className,t.keys(this.gastProductionsCache),this.getBaseCstVisitorConstructor());return this.baseCstVisitorWithDefaultsConstructor=a,a}return this.baseCstVisitorWithDefaultsConstructor},o.prototype.getLastExplicitRuleShortName=function(){var a=this.RULE_STACK;return a[a.length-1]},o.prototype.getPreviousExplicitRuleShortName=function(){var a=this.RULE_STACK;return a[a.length-2]},o.prototype.getLastExplicitRuleOccurrenceIndex=function(){var a=this.RULE_OCCURRENCE_STACK;return a[a.length-1]},o})();i.TreeBuilder=s}),vP=Et(i=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.LexerAdapter=void 0;var e=ji(),t=(function(){function n(){}return n.prototype.initLexerAdapter=function(){this.tokVector=[],this.tokVectorLength=0,this.currIdx=-1},Object.defineProperty(n.prototype,"input",{get:function(){return this.tokVector},set:function(r){if(this.selfAnalysisDone!==!0)throw Error("Missing <performSelfAnalysis> invocation at the end of the Parser's constructor.");this.reset(),this.tokVector=r,this.tokVectorLength=r.length},enumerable:!1,configurable:!0}),n.prototype.SKIP_TOKEN=function(){return this.currIdx<=this.tokVector.length-2?(this.consumeToken(),this.LA(1)):e.END_OF_FILE},n.prototype.LA=function(r){var s=this.currIdx+r;return s<0||this.tokVectorLength<=s?e.END_OF_FILE:this.tokVector[s]},n.prototype.consumeToken=function(){this.currIdx++},n.prototype.exportLexerState=function(){return this.currIdx},n.prototype.importLexerState=function(r){this.currIdx=r},n.prototype.resetLexerState=function(){this.currIdx=-1},n.prototype.moveToTerminatedState=function(){this.currIdx=this.tokVector.length-1},n.prototype.getLexerPosition=function(){return this.exportLexerState()},n})();i.LexerAdapter=t}),_P=Et(i=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.RecognizerApi=void 0;var e=Vt(),t=wh(),n=ji(),r=Up(),s=oM(),o=Bi(),a=(function(){function c(){}return c.prototype.ACTION=function(l){return l.call(this)},c.prototype.consume=function(l,u,h){return this.consumeInternal(u,l,h)},c.prototype.subrule=function(l,u,h){return this.subruleInternal(u,l,h)},c.prototype.option=function(l,u){return this.optionInternal(u,l)},c.prototype.or=function(l,u){return this.orInternal(u,l)},c.prototype.many=function(l,u){return this.manyInternal(l,u)},c.prototype.atLeastOne=function(l,u){return this.atLeastOneInternal(l,u)},c.prototype.CONSUME=function(l,u){return this.consumeInternal(l,0,u)},c.prototype.CONSUME1=function(l,u){return this.consumeInternal(l,1,u)},c.prototype.CONSUME2=function(l,u){return this.consumeInternal(l,2,u)},c.prototype.CONSUME3=function(l,u){return this.consumeInternal(l,3,u)},c.prototype.CONSUME4=function(l,u){return this.consumeInternal(l,4,u)},c.prototype.CONSUME5=function(l,u){return this.consumeInternal(l,5,u)},c.prototype.CONSUME6=function(l,u){return this.consumeInternal(l,6,u)},c.prototype.CONSUME7=function(l,u){return this.consumeInternal(l,7,u)},c.prototype.CONSUME8=function(l,u){return this.consumeInternal(l,8,u)},c.prototype.CONSUME9=function(l,u){return this.consumeInternal(l,9,u)},c.prototype.SUBRULE=function(l,u){return this.subruleInternal(l,0,u)},c.prototype.SUBRULE1=function(l,u){return this.subruleInternal(l,1,u)},c.prototype.SUBRULE2=function(l,u){return this.subruleInternal(l,2,u)},c.prototype.SUBRULE3=function(l,u){return this.subruleInternal(l,3,u)},c.prototype.SUBRULE4=function(l,u){return this.subruleInternal(l,4,u)},c.prototype.SUBRULE5=function(l,u){return this.subruleInternal(l,5,u)},c.prototype.SUBRULE6=function(l,u){return this.subruleInternal(l,6,u)},c.prototype.SUBRULE7=function(l,u){return this.subruleInternal(l,7,u)},c.prototype.SUBRULE8=function(l,u){return this.subruleInternal(l,8,u)},c.prototype.SUBRULE9=function(l,u){return this.subruleInternal(l,9,u)},c.prototype.OPTION=function(l){return this.optionInternal(l,0)},c.prototype.OPTION1=function(l){return this.optionInternal(l,1)},c.prototype.OPTION2=function(l){return this.optionInternal(l,2)},c.prototype.OPTION3=function(l){return this.optionInternal(l,3)},c.prototype.OPTION4=function(l){return this.optionInternal(l,4)},c.prototype.OPTION5=function(l){return this.optionInternal(l,5)},c.prototype.OPTION6=function(l){return this.optionInternal(l,6)},c.prototype.OPTION7=function(l){return this.optionInternal(l,7)},c.prototype.OPTION8=function(l){return this.optionInternal(l,8)},c.prototype.OPTION9=function(l){return this.optionInternal(l,9)},c.prototype.OR=function(l){return this.orInternal(l,0)},c.prototype.OR1=function(l){return this.orInternal(l,1)},c.prototype.OR2=function(l){return this.orInternal(l,2)},c.prototype.OR3=function(l){return this.orInternal(l,3)},c.prototype.OR4=function(l){return this.orInternal(l,4)},c.prototype.OR5=function(l){return this.orInternal(l,5)},c.prototype.OR6=function(l){return this.orInternal(l,6)},c.prototype.OR7=function(l){return this.orInternal(l,7)},c.prototype.OR8=function(l){return this.orInternal(l,8)},c.prototype.OR9=function(l){return this.orInternal(l,9)},c.prototype.MANY=function(l){this.manyInternal(0,l)},c.prototype.MANY1=function(l){this.manyInternal(1,l)},c.prototype.MANY2=function(l){this.manyInternal(2,l)},c.prototype.MANY3=function(l){this.manyInternal(3,l)},c.prototype.MANY4=function(l){this.manyInternal(4,l)},c.prototype.MANY5=function(l){this.manyInternal(5,l)},c.prototype.MANY6=function(l){this.manyInternal(6,l)},c.prototype.MANY7=function(l){this.manyInternal(7,l)},c.prototype.MANY8=function(l){this.manyInternal(8,l)},c.prototype.MANY9=function(l){this.manyInternal(9,l)},c.prototype.MANY_SEP=function(l){this.manySepFirstInternal(0,l)},c.prototype.MANY_SEP1=function(l){this.manySepFirstInternal(1,l)},c.prototype.MANY_SEP2=function(l){this.manySepFirstInternal(2,l)},c.prototype.MANY_SEP3=function(l){this.manySepFirstInternal(3,l)},c.prototype.MANY_SEP4=function(l){this.manySepFirstInternal(4,l)},c.prototype.MANY_SEP5=function(l){this.manySepFirstInternal(5,l)},c.prototype.MANY_SEP6=function(l){this.manySepFirstInternal(6,l)},c.prototype.MANY_SEP7=function(l){this.manySepFirstInternal(7,l)},c.prototype.MANY_SEP8=function(l){this.manySepFirstInternal(8,l)},c.prototype.MANY_SEP9=function(l){this.manySepFirstInternal(9,l)},c.prototype.AT_LEAST_ONE=function(l){this.atLeastOneInternal(0,l)},c.prototype.AT_LEAST_ONE1=function(l){return this.atLeastOneInternal(1,l)},c.prototype.AT_LEAST_ONE2=function(l){this.atLeastOneInternal(2,l)},c.prototype.AT_LEAST_ONE3=function(l){this.atLeastOneInternal(3,l)},c.prototype.AT_LEAST_ONE4=function(l){this.atLeastOneInternal(4,l)},c.prototype.AT_LEAST_ONE5=function(l){this.atLeastOneInternal(5,l)},c.prototype.AT_LEAST_ONE6=function(l){this.atLeastOneInternal(6,l)},c.prototype.AT_LEAST_ONE7=function(l){this.atLeastOneInternal(7,l)},c.prototype.AT_LEAST_ONE8=function(l){this.atLeastOneInternal(8,l)},c.prototype.AT_LEAST_ONE9=function(l){this.atLeastOneInternal(9,l)},c.prototype.AT_LEAST_ONE_SEP=function(l){this.atLeastOneSepFirstInternal(0,l)},c.prototype.AT_LEAST_ONE_SEP1=function(l){this.atLeastOneSepFirstInternal(1,l)},c.prototype.AT_LEAST_ONE_SEP2=function(l){this.atLeastOneSepFirstInternal(2,l)},c.prototype.AT_LEAST_ONE_SEP3=function(l){this.atLeastOneSepFirstInternal(3,l)},c.prototype.AT_LEAST_ONE_SEP4=function(l){this.atLeastOneSepFirstInternal(4,l)},c.prototype.AT_LEAST_ONE_SEP5=function(l){this.atLeastOneSepFirstInternal(5,l)},c.prototype.AT_LEAST_ONE_SEP6=function(l){this.atLeastOneSepFirstInternal(6,l)},c.prototype.AT_LEAST_ONE_SEP7=function(l){this.atLeastOneSepFirstInternal(7,l)},c.prototype.AT_LEAST_ONE_SEP8=function(l){this.atLeastOneSepFirstInternal(8,l)},c.prototype.AT_LEAST_ONE_SEP9=function(l){this.atLeastOneSepFirstInternal(9,l)},c.prototype.RULE=function(l,u,h){if(h===void 0&&(h=n.DEFAULT_RULE_CONFIG),e.contains(this.definedRulesNames,l)){var d=r.defaultGrammarValidatorErrorProvider.buildDuplicateRuleNameError({topLevelRule:l,grammarName:this.className}),m={message:d,type:n.ParserDefinitionErrorType.DUPLICATE_RULE_NAME,ruleName:l};this.definitionErrors.push(m)}this.definedRulesNames.push(l);var g=this.defineRule(l,u,h);return this[l]=g,g},c.prototype.OVERRIDE_RULE=function(l,u,h){h===void 0&&(h=n.DEFAULT_RULE_CONFIG);var d=[];d=d.concat(s.validateRuleIsOverridden(l,this.definedRulesNames,this.className)),this.definitionErrors=this.definitionErrors.concat(d);var m=this.defineRule(l,u,h);return this[l]=m,m},c.prototype.BACKTRACK=function(l,u){return function(){this.isBackTrackingStack.push(1);var h=this.saveRecogState();try{return l.apply(this,u),!0}catch(d){if(t.isRecognitionException(d))return!1;throw d}finally{this.reloadRecogState(h),this.isBackTrackingStack.pop()}}},c.prototype.getGAstProductions=function(){return this.gastProductionsCache},c.prototype.getSerializedGastProductions=function(){return o.serializeGrammar(e.values(this.gastProductionsCache))},c})();i.RecognizerApi=a}),bP=Et(i=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.RecognizerEngine=void 0;var e=Vt(),t=Ix(),n=wh(),r=Bp(),s=kp(),o=ji(),a=aM(),c=oa(),l=Th(),u=cM(),h=(function(){function d(){}return d.prototype.initRecognizerEngine=function(m,g){if(this.className=u.classNameFromInstance(this),this.shortRuleNameToFull={},this.fullRuleNameToShort={},this.ruleShortNameIdx=256,this.tokenMatcher=l.tokenStructuredMatcherNoCategories,this.definedRulesNames=[],this.tokensMap={},this.isBackTrackingStack=[],this.RULE_STACK=[],this.RULE_OCCURRENCE_STACK=[],this.gastProductionsCache={},e.has(g,"serializedGrammar"))throw Error(`The Parser's configuration can no longer contain a <serializedGrammar> property.
See: https://chevrotain.io/docs/changes/BREAKING_CHANGES.html#_6-0-0
For Further details.`);if(e.isArray(m)){if(e.isEmpty(m))throw Error(`A Token Vocabulary cannot be empty.
Note that the first argument for the parser constructor
is no longer a Token vector (since v4.0).`);if(typeof m[0].startOffset=="number")throw Error(`The Parser constructor no longer accepts a token vector as the first argument.
See: https://chevrotain.io/docs/changes/BREAKING_CHANGES.html#_4-0-0
For Further details.`)}if(e.isArray(m))this.tokensMap=e.reduce(m,function(v,_){return v[_.name]=_,v},{});else if(e.has(m,"modes")&&e.every(e.flatten(e.values(m.modes)),l.isTokenType)){var x=e.flatten(e.values(m.modes)),f=e.uniq(x);this.tokensMap=e.reduce(f,function(v,_){return v[_.name]=_,v},{})}else if(e.isObject(m))this.tokensMap=e.cloneObj(m);else throw new Error("<tokensDictionary> argument must be An Array of Token constructors, A dictionary of Token constructors or an IMultiModeLexerDefinition");this.tokensMap.EOF=c.EOF;var p=e.every(e.values(m),function(v){return e.isEmpty(v.categoryMatches)});this.tokenMatcher=p?l.tokenStructuredMatcherNoCategories:l.tokenStructuredMatcher,l.augmentTokenTypes(e.values(this.tokensMap))},d.prototype.defineRule=function(m,g,x){if(this.selfAnalysisDone)throw Error("Grammar rule <"+m+`> may not be defined after the 'performSelfAnalysis' method has been called'
Make sure that all grammar rule definitions are done before 'performSelfAnalysis' is called.`);var f=e.has(x,"resyncEnabled")?x.resyncEnabled:o.DEFAULT_RULE_CONFIG.resyncEnabled,p=e.has(x,"recoveryValueFunc")?x.recoveryValueFunc:o.DEFAULT_RULE_CONFIG.recoveryValueFunc,v=this.ruleShortNameIdx<<t.BITS_FOR_METHOD_TYPE+t.BITS_FOR_OCCURRENCE_IDX;this.ruleShortNameIdx++,this.shortRuleNameToFull[v]=m,this.fullRuleNameToShort[m]=v;function _(E){try{if(this.outputCst===!0){g.apply(this,E);var A=this.CST_STACK[this.CST_STACK.length-1];return this.cstPostRule(A),A}else return g.apply(this,E)}catch(T){return this.invokeRuleCatch(T,f,p)}finally{this.ruleFinallyStateUpdate()}}var y=function(E,A){return E===void 0&&(E=0),this.ruleInvocationStateUpdate(v,m,E),_.call(this,A)},b="ruleName";return y[b]=m,y.originalGrammarAction=g,y},d.prototype.invokeRuleCatch=function(m,g,x){var f=this.RULE_STACK.length===1,p=g&&!this.isBackTracking()&&this.recoveryEnabled;if(n.isRecognitionException(m)){var v=m;if(p){var _=this.findReSyncTokenType();if(this.isInCurrentRuleReSyncSet(_))if(v.resyncedTokens=this.reSyncTo(_),this.outputCst){var y=this.CST_STACK[this.CST_STACK.length-1];return y.recoveredNode=!0,y}else return x();else{if(this.outputCst){var y=this.CST_STACK[this.CST_STACK.length-1];y.recoveredNode=!0,v.partialCstResult=y}throw v}}else{if(f)return this.moveToTerminatedState(),x();throw v}}else throw m},d.prototype.optionInternal=function(m,g){var x=this.getKeyForAutomaticLookahead(t.OPTION_IDX,g);return this.optionInternalLogic(m,g,x)},d.prototype.optionInternalLogic=function(m,g,x){var f=this,p=this.getLaFuncFromCache(x),v,_;if(m.DEF!==void 0){if(v=m.DEF,_=m.GATE,_!==void 0){var y=p;p=function(){return _.call(f)&&y.call(f)}}}else v=m;if(p.call(this)===!0)return v.call(this)},d.prototype.atLeastOneInternal=function(m,g){var x=this.getKeyForAutomaticLookahead(t.AT_LEAST_ONE_IDX,m);return this.atLeastOneInternalLogic(m,g,x)},d.prototype.atLeastOneInternalLogic=function(m,g,x){var f=this,p=this.getLaFuncFromCache(x),v,_;if(g.DEF!==void 0){if(v=g.DEF,_=g.GATE,_!==void 0){var y=p;p=function(){return _.call(f)&&y.call(f)}}}else v=g;if(p.call(this)===!0)for(var b=this.doSingleRepetition(v);p.call(this)===!0&&b===!0;)b=this.doSingleRepetition(v);else throw this.raiseEarlyExitException(m,r.PROD_TYPE.REPETITION_MANDATORY,g.ERR_MSG);this.attemptInRepetitionRecovery(this.atLeastOneInternal,[m,g],p,t.AT_LEAST_ONE_IDX,m,s.NextTerminalAfterAtLeastOneWalker)},d.prototype.atLeastOneSepFirstInternal=function(m,g){var x=this.getKeyForAutomaticLookahead(t.AT_LEAST_ONE_SEP_IDX,m);this.atLeastOneSepFirstInternalLogic(m,g,x)},d.prototype.atLeastOneSepFirstInternalLogic=function(m,g,x){var f=this,p=g.DEF,v=g.SEP,_=this.getLaFuncFromCache(x);if(_.call(this)===!0){p.call(this);for(var y=function(){return f.tokenMatcher(f.LA(1),v)};this.tokenMatcher(this.LA(1),v)===!0;)this.CONSUME(v),p.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[m,v,y,p,s.NextTerminalAfterAtLeastOneSepWalker],y,t.AT_LEAST_ONE_SEP_IDX,m,s.NextTerminalAfterAtLeastOneSepWalker)}else throw this.raiseEarlyExitException(m,r.PROD_TYPE.REPETITION_MANDATORY_WITH_SEPARATOR,g.ERR_MSG)},d.prototype.manyInternal=function(m,g){var x=this.getKeyForAutomaticLookahead(t.MANY_IDX,m);return this.manyInternalLogic(m,g,x)},d.prototype.manyInternalLogic=function(m,g,x){var f=this,p=this.getLaFuncFromCache(x),v,_;if(g.DEF!==void 0){if(v=g.DEF,_=g.GATE,_!==void 0){var y=p;p=function(){return _.call(f)&&y.call(f)}}}else v=g;for(var b=!0;p.call(this)===!0&&b===!0;)b=this.doSingleRepetition(v);this.attemptInRepetitionRecovery(this.manyInternal,[m,g],p,t.MANY_IDX,m,s.NextTerminalAfterManyWalker,b)},d.prototype.manySepFirstInternal=function(m,g){var x=this.getKeyForAutomaticLookahead(t.MANY_SEP_IDX,m);this.manySepFirstInternalLogic(m,g,x)},d.prototype.manySepFirstInternalLogic=function(m,g,x){var f=this,p=g.DEF,v=g.SEP,_=this.getLaFuncFromCache(x);if(_.call(this)===!0){p.call(this);for(var y=function(){return f.tokenMatcher(f.LA(1),v)};this.tokenMatcher(this.LA(1),v)===!0;)this.CONSUME(v),p.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[m,v,y,p,s.NextTerminalAfterManySepWalker],y,t.MANY_SEP_IDX,m,s.NextTerminalAfterManySepWalker)}},d.prototype.repetitionSepSecondInternal=function(m,g,x,f,p){for(;x();)this.CONSUME(g),f.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[m,g,x,f,p],x,t.AT_LEAST_ONE_SEP_IDX,m,p)},d.prototype.doSingleRepetition=function(m){var g=this.getLexerPosition();m.call(this);var x=this.getLexerPosition();return x>g},d.prototype.orInternal=function(m,g){var x=this.getKeyForAutomaticLookahead(t.OR_IDX,g),f=e.isArray(m)?m:m.DEF,p=this.getLaFuncFromCache(x),v=p.call(this,f);if(v!==void 0){var _=f[v];return _.ALT.call(this)}this.raiseNoAltException(g,m.ERR_MSG)},d.prototype.ruleFinallyStateUpdate=function(){if(this.RULE_STACK.pop(),this.RULE_OCCURRENCE_STACK.pop(),this.cstFinallyStateUpdate(),this.RULE_STACK.length===0&&this.isAtEndOfInput()===!1){var m=this.LA(1),g=this.errorMessageProvider.buildNotAllInputParsedMessage({firstRedundant:m,ruleName:this.getCurrRuleFullName()});this.SAVE_ERROR(new n.NotAllInputParsedException(g,m))}},d.prototype.subruleInternal=function(m,g,x){var f;try{var p=x!==void 0?x.ARGS:void 0;return f=m.call(this,g,p),this.cstPostNonTerminal(f,x!==void 0&&x.LABEL!==void 0?x.LABEL:m.ruleName),f}catch(v){this.subruleInternalError(v,x,m.ruleName)}},d.prototype.subruleInternalError=function(m,g,x){throw n.isRecognitionException(m)&&m.partialCstResult!==void 0&&(this.cstPostNonTerminal(m.partialCstResult,g!==void 0&&g.LABEL!==void 0?g.LABEL:x),delete m.partialCstResult),m},d.prototype.consumeInternal=function(m,g,x){var f;try{var p=this.LA(1);this.tokenMatcher(p,m)===!0?(this.consumeToken(),f=p):this.consumeInternalError(m,p,x)}catch(v){f=this.consumeInternalRecovery(m,g,v)}return this.cstPostTerminal(x!==void 0&&x.LABEL!==void 0?x.LABEL:m.name,f),f},d.prototype.consumeInternalError=function(m,g,x){var f,p=this.LA(0);throw x!==void 0&&x.ERR_MSG?f=x.ERR_MSG:f=this.errorMessageProvider.buildMismatchTokenMessage({expected:m,actual:g,previous:p,ruleName:this.getCurrRuleFullName()}),this.SAVE_ERROR(new n.MismatchedTokenException(f,g,p))},d.prototype.consumeInternalRecovery=function(m,g,x){if(this.recoveryEnabled&&x.name==="MismatchedTokenException"&&!this.isBackTracking()){var f=this.getFollowsForInRuleRecovery(m,g);try{return this.tryInRuleRecovery(m,f)}catch(p){throw p.name===a.IN_RULE_RECOVERY_EXCEPTION?x:p}}else throw x},d.prototype.saveRecogState=function(){var m=this.errors,g=e.cloneArr(this.RULE_STACK);return{errors:m,lexerState:this.exportLexerState(),RULE_STACK:g,CST_STACK:this.CST_STACK}},d.prototype.reloadRecogState=function(m){this.errors=m.errors,this.importLexerState(m.lexerState),this.RULE_STACK=m.RULE_STACK},d.prototype.ruleInvocationStateUpdate=function(m,g,x){this.RULE_OCCURRENCE_STACK.push(x),this.RULE_STACK.push(m),this.cstInvocationStateUpdate(g,m)},d.prototype.isBackTracking=function(){return this.isBackTrackingStack.length!==0},d.prototype.getCurrRuleFullName=function(){var m=this.getLastExplicitRuleShortName();return this.shortRuleNameToFull[m]},d.prototype.shortRuleNameToFullName=function(m){return this.shortRuleNameToFull[m]},d.prototype.isAtEndOfInput=function(){return this.tokenMatcher(this.LA(1),c.EOF)},d.prototype.reset=function(){this.resetLexerState(),this.isBackTrackingStack=[],this.errors=[],this.RULE_STACK=[],this.CST_STACK=[],this.RULE_OCCURRENCE_STACK=[]},d})();i.RecognizerEngine=h}),MP=Et(i=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.ErrorHandler=void 0;var e=wh(),t=Vt(),n=Bp(),r=ji(),s=(function(){function o(){}return o.prototype.initErrorHandler=function(a){this._errors=[],this.errorMessageProvider=t.has(a,"errorMessageProvider")?a.errorMessageProvider:r.DEFAULT_PARSER_CONFIG.errorMessageProvider},o.prototype.SAVE_ERROR=function(a){if(e.isRecognitionException(a))return a.context={ruleStack:this.getHumanReadableRuleStack(),ruleOccurrenceStack:t.cloneArr(this.RULE_OCCURRENCE_STACK)},this._errors.push(a),a;throw Error("Trying to save an Error which is not a RecognitionException")},Object.defineProperty(o.prototype,"errors",{get:function(){return t.cloneArr(this._errors)},set:function(a){this._errors=a},enumerable:!1,configurable:!0}),o.prototype.raiseEarlyExitException=function(a,c,l){for(var u=this.getCurrRuleFullName(),h=this.getGAstProductions()[u],d=n.getLookaheadPathsForOptionalProd(a,h,c,this.maxLookahead),m=d[0],g=[],x=1;x<=this.maxLookahead;x++)g.push(this.LA(x));var f=this.errorMessageProvider.buildEarlyExitMessage({expectedIterationPaths:m,actual:g,previous:this.LA(0),customUserDescription:l,ruleName:u});throw this.SAVE_ERROR(new e.EarlyExitException(f,this.LA(1),this.LA(0)))},o.prototype.raiseNoAltException=function(a,c){for(var l=this.getCurrRuleFullName(),u=this.getGAstProductions()[l],h=n.getLookaheadPathsForOr(a,u,this.maxLookahead),d=[],m=1;m<=this.maxLookahead;m++)d.push(this.LA(m));var g=this.LA(0),x=this.errorMessageProvider.buildNoViableAltMessage({expectedPathsPerAlt:h,actual:d,previous:g,customUserDescription:c,ruleName:this.getCurrRuleFullName()});throw this.SAVE_ERROR(new e.NoViableAltException(x,this.LA(1),g))},o})();i.ErrorHandler=s}),EP=Et(i=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.ContentAssist=void 0;var e=kp(),t=Vt(),n=(function(){function r(){}return r.prototype.initContentAssist=function(){},r.prototype.computeContentAssist=function(s,o){var a=this.gastProductionsCache[s];if(t.isUndefined(a))throw Error("Rule ->"+s+"<- does not exist in this grammar.");return e.nextPossibleTokensAfter([a],o,this.tokenMatcher,this.maxLookahead)},r.prototype.getNextPossibleTokenTypes=function(s){var o=t.first(s.ruleStack),a=this.getGAstProductions(),c=a[o],l=new e.NextAfterTokenWalker(c,s).startWalking();return l},r})();i.ContentAssist=n}),SP=Et(i=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.GastRecorder=void 0;var e=Vt(),t=Bi(),n=Dp(),r=Th(),s=oa(),o=ji(),a=Ix(),c={description:"This Object indicates the Parser is during Recording Phase"};Object.freeze(c);var l=!0,u=Math.pow(2,a.BITS_FOR_OCCURRENCE_IDX)-1,h=s.createToken({name:"RECORDING_PHASE_TOKEN",pattern:n.Lexer.NA});r.augmentTokenTypes([h]);var d=s.createTokenInstance(h,`This IToken indicates the Parser is in Recording Phase
See: https://chevrotain.io/docs/guide/internals.html#grammar-recording for details`,-1,-1,-1,-1,-1,-1);Object.freeze(d);var m={name:`This CSTNode indicates the Parser is in Recording Phase
See: https://chevrotain.io/docs/guide/internals.html#grammar-recording for details`,children:{}},g=(function(){function _(){}return _.prototype.initGastRecorder=function(y){this.recordingProdStack=[],this.RECORDING_PHASE=!1},_.prototype.enableRecording=function(){var y=this;this.RECORDING_PHASE=!0,this.TRACE_INIT("Enable Recording",function(){for(var b=function(A){var T=A>0?A:"";y["CONSUME"+T]=function(M,S){return this.consumeInternalRecord(M,A,S)},y["SUBRULE"+T]=function(M,S){return this.subruleInternalRecord(M,A,S)},y["OPTION"+T]=function(M){return this.optionInternalRecord(M,A)},y["OR"+T]=function(M){return this.orInternalRecord(M,A)},y["MANY"+T]=function(M){this.manyInternalRecord(A,M)},y["MANY_SEP"+T]=function(M){this.manySepFirstInternalRecord(A,M)},y["AT_LEAST_ONE"+T]=function(M){this.atLeastOneInternalRecord(A,M)},y["AT_LEAST_ONE_SEP"+T]=function(M){this.atLeastOneSepFirstInternalRecord(A,M)}},E=0;E<10;E++)b(E);y.consume=function(A,T,M){return this.consumeInternalRecord(T,A,M)},y.subrule=function(A,T,M){return this.subruleInternalRecord(T,A,M)},y.option=function(A,T){return this.optionInternalRecord(T,A)},y.or=function(A,T){return this.orInternalRecord(T,A)},y.many=function(A,T){this.manyInternalRecord(A,T)},y.atLeastOne=function(A,T){this.atLeastOneInternalRecord(A,T)},y.ACTION=y.ACTION_RECORD,y.BACKTRACK=y.BACKTRACK_RECORD,y.LA=y.LA_RECORD})},_.prototype.disableRecording=function(){var y=this;this.RECORDING_PHASE=!1,this.TRACE_INIT("Deleting Recording methods",function(){for(var b=0;b<10;b++){var E=b>0?b:"";delete y["CONSUME"+E],delete y["SUBRULE"+E],delete y["OPTION"+E],delete y["OR"+E],delete y["MANY"+E],delete y["MANY_SEP"+E],delete y["AT_LEAST_ONE"+E],delete y["AT_LEAST_ONE_SEP"+E]}delete y.consume,delete y.subrule,delete y.option,delete y.or,delete y.many,delete y.atLeastOne,delete y.ACTION,delete y.BACKTRACK,delete y.LA})},_.prototype.ACTION_RECORD=function(y){},_.prototype.BACKTRACK_RECORD=function(y,b){return function(){return!0}},_.prototype.LA_RECORD=function(y){return o.END_OF_FILE},_.prototype.topLevelRuleRecord=function(y,b){try{var E=new t.Rule({definition:[],name:y});return E.name=y,this.recordingProdStack.push(E),b.call(this),this.recordingProdStack.pop(),E}catch(A){if(A.KNOWN_RECORDER_ERROR!==!0)try{A.message=A.message+`
This error was thrown during the "grammar recording phase" For more info see:
https://chevrotain.io/docs/guide/internals.html#grammar-recording`}catch{throw A}throw A}},_.prototype.optionInternalRecord=function(y,b){return x.call(this,t.Option,y,b)},_.prototype.atLeastOneInternalRecord=function(y,b){x.call(this,t.RepetitionMandatory,b,y)},_.prototype.atLeastOneSepFirstInternalRecord=function(y,b){x.call(this,t.RepetitionMandatoryWithSeparator,b,y,l)},_.prototype.manyInternalRecord=function(y,b){x.call(this,t.Repetition,b,y)},_.prototype.manySepFirstInternalRecord=function(y,b){x.call(this,t.RepetitionWithSeparator,b,y,l)},_.prototype.orInternalRecord=function(y,b){return f.call(this,y,b)},_.prototype.subruleInternalRecord=function(y,b,E){if(v(b),!y||e.has(y,"ruleName")===!1){var A=new Error("<SUBRULE"+p(b)+"> argument is invalid"+(" expecting a Parser method reference but got: <"+JSON.stringify(y)+">")+(`
inside top level rule: <`+this.recordingProdStack[0].name+">"));throw A.KNOWN_RECORDER_ERROR=!0,A}var T=e.peek(this.recordingProdStack),M=y.ruleName,S=new t.NonTerminal({idx:b,nonTerminalName:M,referencedRule:void 0});return T.definition.push(S),this.outputCst?m:c},_.prototype.consumeInternalRecord=function(y,b,E){if(v(b),!r.hasShortKeyProperty(y)){var A=new Error("<CONSUME"+p(b)+"> argument is invalid"+(" expecting a TokenType reference but got: <"+JSON.stringify(y)+">")+(`
inside top level rule: <`+this.recordingProdStack[0].name+">"));throw A.KNOWN_RECORDER_ERROR=!0,A}var T=e.peek(this.recordingProdStack),M=new t.Terminal({idx:b,terminalType:y});return T.definition.push(M),d},_})();i.GastRecorder=g;function x(_,y,b,E){E===void 0&&(E=!1),v(b);var A=e.peek(this.recordingProdStack),T=e.isFunction(y)?y:y.DEF,M=new _({definition:[],idx:b});return E&&(M.separator=y.SEP),e.has(y,"MAX_LOOKAHEAD")&&(M.maxLookahead=y.MAX_LOOKAHEAD),this.recordingProdStack.push(M),T.call(this),A.definition.push(M),this.recordingProdStack.pop(),c}function f(_,y){var b=this;v(y);var E=e.peek(this.recordingProdStack),A=e.isArray(_)===!1,T=A===!1?_:_.DEF,M=new t.Alternation({definition:[],idx:y,ignoreAmbiguities:A&&_.IGNORE_AMBIGUITIES===!0});e.has(_,"MAX_LOOKAHEAD")&&(M.maxLookahead=_.MAX_LOOKAHEAD);var S=e.some(T,function(C){return e.isFunction(C.GATE)});return M.hasPredicates=S,E.definition.push(M),e.forEach(T,function(C){var N=new t.Alternative({definition:[]});M.definition.push(N),e.has(C,"IGNORE_AMBIGUITIES")?N.ignoreAmbiguities=C.IGNORE_AMBIGUITIES:e.has(C,"GATE")&&(N.ignoreAmbiguities=!0),b.recordingProdStack.push(N),C.ALT.call(b),b.recordingProdStack.pop()}),c}function p(_){return _===0?"":""+_}function v(_){if(_<0||_>u){var y=new Error("Invalid DSL Method idx value: <"+_+`>
`+("Idx value must be a none negative value smaller than "+(u+1)));throw y.KNOWN_RECORDER_ERROR=!0,y}}}),TP=Et(i=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.PerformanceTracer=void 0;var e=Vt(),t=ji(),n=(function(){function r(){}return r.prototype.initPerformanceTracer=function(s){if(e.has(s,"traceInitPerf")){var o=s.traceInitPerf,a=typeof o=="number";this.traceInitMaxIdent=a?o:1/0,this.traceInitPerf=a?o>0:o}else this.traceInitMaxIdent=0,this.traceInitPerf=t.DEFAULT_PARSER_CONFIG.traceInitPerf;this.traceInitIndent=-1},r.prototype.TRACE_INIT=function(s,o){if(this.traceInitPerf===!0){this.traceInitIndent++;var a=new Array(this.traceInitIndent+1).join(" ");this.traceInitIndent<this.traceInitMaxIdent&&console.log(a+"--> <"+s+">");var c=e.timer(o),l=c.time,u=c.value,h=l>10?console.warn:console.log;return this.traceInitIndent<this.traceInitMaxIdent&&h(a+"<-- <"+s+"> time: "+l+"ms"),this.traceInitIndent--,u}else return o()},r})();i.PerformanceTracer=n}),AP=Et(i=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.applyMixins=void 0;function e(t,n){n.forEach(function(r){var s=r.prototype;Object.getOwnPropertyNames(s).forEach(function(o){if(o!=="constructor"){var a=Object.getOwnPropertyDescriptor(s,o);a&&(a.get||a.set)?Object.defineProperty(t.prototype,o,a):t.prototype[o]=r.prototype[o]}})})}i.applyMixins=e}),ji=Et(i=>{"use strict";var e=i&&i.__extends||(function(){var A=function(T,M){return A=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(S,C){S.__proto__=C}||function(S,C){for(var N in C)Object.prototype.hasOwnProperty.call(C,N)&&(S[N]=C[N])},A(T,M)};return function(T,M){if(typeof M!="function"&&M!==null)throw new TypeError("Class extends value "+String(M)+" is not a constructor or null");A(T,M);function S(){this.constructor=T}T.prototype=M===null?Object.create(M):(S.prototype=M.prototype,new S)}})();Object.defineProperty(i,"__esModule",{value:!0}),i.EmbeddedActionsParser=i.CstParser=i.Parser=i.EMPTY_ALT=i.ParserDefinitionErrorType=i.DEFAULT_RULE_CONFIG=i.DEFAULT_PARSER_CONFIG=i.END_OF_FILE=void 0;var t=Vt(),n=dP(),r=oa(),s=Up(),o=pP(),a=aM(),c=mP(),l=yP(),u=vP(),h=_P(),d=bP(),m=MP(),g=EP(),x=SP(),f=TP(),p=AP();i.END_OF_FILE=r.createTokenInstance(r.EOF,"",NaN,NaN,NaN,NaN,NaN,NaN),Object.freeze(i.END_OF_FILE),i.DEFAULT_PARSER_CONFIG=Object.freeze({recoveryEnabled:!1,maxLookahead:3,dynamicTokensEnabled:!1,outputCst:!0,errorMessageProvider:s.defaultParserErrorProvider,nodeLocationTracking:"none",traceInitPerf:!1,skipValidations:!1}),i.DEFAULT_RULE_CONFIG=Object.freeze({recoveryValueFunc:function(){},resyncEnabled:!0});var v;(function(A){A[A.INVALID_RULE_NAME=0]="INVALID_RULE_NAME",A[A.DUPLICATE_RULE_NAME=1]="DUPLICATE_RULE_NAME",A[A.INVALID_RULE_OVERRIDE=2]="INVALID_RULE_OVERRIDE",A[A.DUPLICATE_PRODUCTIONS=3]="DUPLICATE_PRODUCTIONS",A[A.UNRESOLVED_SUBRULE_REF=4]="UNRESOLVED_SUBRULE_REF",A[A.LEFT_RECURSION=5]="LEFT_RECURSION",A[A.NONE_LAST_EMPTY_ALT=6]="NONE_LAST_EMPTY_ALT",A[A.AMBIGUOUS_ALTS=7]="AMBIGUOUS_ALTS",A[A.CONFLICT_TOKENS_RULES_NAMESPACE=8]="CONFLICT_TOKENS_RULES_NAMESPACE",A[A.INVALID_TOKEN_NAME=9]="INVALID_TOKEN_NAME",A[A.NO_NON_EMPTY_LOOKAHEAD=10]="NO_NON_EMPTY_LOOKAHEAD",A[A.AMBIGUOUS_PREFIX_ALTS=11]="AMBIGUOUS_PREFIX_ALTS",A[A.TOO_MANY_ALTS=12]="TOO_MANY_ALTS"})(v=i.ParserDefinitionErrorType||(i.ParserDefinitionErrorType={}));function _(A){return A===void 0&&(A=void 0),function(){return A}}i.EMPTY_ALT=_;var y=(function(){function A(T,M){this.definitionErrors=[],this.selfAnalysisDone=!1;var S=this;if(S.initErrorHandler(M),S.initLexerAdapter(),S.initLooksAhead(M),S.initRecognizerEngine(T,M),S.initRecoverable(M),S.initTreeBuilder(M),S.initContentAssist(),S.initGastRecorder(M),S.initPerformanceTracer(M),t.has(M,"ignoredIssues"))throw new Error(`The <ignoredIssues> IParserConfig property has been deprecated.
Please use the <IGNORE_AMBIGUITIES> flag on the relevant DSL method instead.
See: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#IGNORING_AMBIGUITIES
For further details.`);this.skipValidations=t.has(M,"skipValidations")?M.skipValidations:i.DEFAULT_PARSER_CONFIG.skipValidations}return A.performSelfAnalysis=function(T){throw Error("The **static** `performSelfAnalysis` method has been deprecated. \nUse the **instance** method with the same name instead.")},A.prototype.performSelfAnalysis=function(){var T=this;this.TRACE_INIT("performSelfAnalysis",function(){var M;T.selfAnalysisDone=!0;var S=T.className;T.TRACE_INIT("toFastProps",function(){t.toFastProperties(T)}),T.TRACE_INIT("Grammar Recording",function(){try{T.enableRecording(),t.forEach(T.definedRulesNames,function(N){var I=T[N],L=I.originalGrammarAction,q=void 0;T.TRACE_INIT(N+" Rule",function(){q=T.topLevelRuleRecord(N,L)}),T.gastProductionsCache[N]=q})}finally{T.disableRecording()}});var C=[];if(T.TRACE_INIT("Grammar Resolving",function(){C=o.resolveGrammar({rules:t.values(T.gastProductionsCache)}),T.definitionErrors=T.definitionErrors.concat(C)}),T.TRACE_INIT("Grammar Validations",function(){if(t.isEmpty(C)&&T.skipValidations===!1){var N=o.validateGrammar({rules:t.values(T.gastProductionsCache),maxLookahead:T.maxLookahead,tokenTypes:t.values(T.tokensMap),errMsgProvider:s.defaultGrammarValidatorErrorProvider,grammarName:S});T.definitionErrors=T.definitionErrors.concat(N)}}),t.isEmpty(T.definitionErrors)&&(T.recoveryEnabled&&T.TRACE_INIT("computeAllProdsFollows",function(){var N=n.computeAllProdsFollows(t.values(T.gastProductionsCache));T.resyncFollows=N}),T.TRACE_INIT("ComputeLookaheadFunctions",function(){T.preComputeLookaheadFunctions(t.values(T.gastProductionsCache))})),!A.DEFER_DEFINITION_ERRORS_HANDLING&&!t.isEmpty(T.definitionErrors))throw M=t.map(T.definitionErrors,function(N){return N.message}),new Error(`Parser Definition Errors detected:
`+M.join(`
-------------------------------
`))})},A.DEFER_DEFINITION_ERRORS_HANDLING=!1,A})();i.Parser=y,p.applyMixins(y,[a.Recoverable,c.LooksAhead,l.TreeBuilder,u.LexerAdapter,d.RecognizerEngine,h.RecognizerApi,m.ErrorHandler,g.ContentAssist,x.GastRecorder,f.PerformanceTracer]);var b=(function(A){e(T,A);function T(M,S){S===void 0&&(S=i.DEFAULT_PARSER_CONFIG);var C=this,N=t.cloneObj(S);return N.outputCst=!0,C=A.call(this,M,N)||this,C}return T})(y);i.CstParser=b;var E=(function(A){e(T,A);function T(M,S){S===void 0&&(S=i.DEFAULT_PARSER_CONFIG);var C=this,N=t.cloneObj(S);return N.outputCst=!1,C=A.call(this,M,N)||this,C}return T})(y);i.EmbeddedActionsParser=E}),wP=Et(i=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.createSyntaxDiagramsCode=void 0;var e=tM();function t(n,r){var s=r===void 0?{}:r,o=s.resourceBase,a=o===void 0?"https://unpkg.com/chevrotain@"+e.VERSION+"/diagrams/":o,c=s.css,l=c===void 0?"https://unpkg.com/chevrotain@"+e.VERSION+"/diagrams/diagrams.css":c,u=`
<!-- This is a generated file -->
<!DOCTYPE html>
<meta charset="utf-8">
<style>
body {
background-color: hsl(30, 20%, 95%)
}
</style>
`,h=`
<link rel='stylesheet' href='`+l+`'>
`,d=`
<script src='`+a+`vendor/railroad-diagrams.js'><\/script>
<script src='`+a+`src/diagrams_builder.js'><\/script>
<script src='`+a+`src/diagrams_behavior.js'><\/script>
<script src='`+a+`src/main.js'><\/script>
`,m=`
<div id="diagrams" align="center"></div>
`,g=`
<script>
window.serializedGrammar = `+JSON.stringify(n,null," ")+`;
<\/script>
`,x=`
<script>
var diagramsDiv = document.getElementById("diagrams");
main.drawDiagramsFromSerializedGrammar(serializedGrammar, diagramsDiv);
<\/script>
`;return u+h+d+m+g+x}i.createSyntaxDiagramsCode=t}),RP=Et(i=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.Parser=i.createSyntaxDiagramsCode=i.clearCache=i.GAstVisitor=i.serializeProduction=i.serializeGrammar=i.Terminal=i.Rule=i.RepetitionWithSeparator=i.RepetitionMandatoryWithSeparator=i.RepetitionMandatory=i.Repetition=i.Option=i.NonTerminal=i.Alternative=i.Alternation=i.defaultLexerErrorProvider=i.NoViableAltException=i.NotAllInputParsedException=i.MismatchedTokenException=i.isRecognitionException=i.EarlyExitException=i.defaultParserErrorProvider=i.tokenName=i.tokenMatcher=i.tokenLabel=i.EOF=i.createTokenInstance=i.createToken=i.LexerDefinitionErrorType=i.Lexer=i.EMPTY_ALT=i.ParserDefinitionErrorType=i.EmbeddedActionsParser=i.CstParser=i.VERSION=void 0;var e=tM();Object.defineProperty(i,"VERSION",{enumerable:!0,get:function(){return e.VERSION}});var t=ji();Object.defineProperty(i,"CstParser",{enumerable:!0,get:function(){return t.CstParser}}),Object.defineProperty(i,"EmbeddedActionsParser",{enumerable:!0,get:function(){return t.EmbeddedActionsParser}}),Object.defineProperty(i,"ParserDefinitionErrorType",{enumerable:!0,get:function(){return t.ParserDefinitionErrorType}}),Object.defineProperty(i,"EMPTY_ALT",{enumerable:!0,get:function(){return t.EMPTY_ALT}});var n=Dp();Object.defineProperty(i,"Lexer",{enumerable:!0,get:function(){return n.Lexer}}),Object.defineProperty(i,"LexerDefinitionErrorType",{enumerable:!0,get:function(){return n.LexerDefinitionErrorType}});var r=oa();Object.defineProperty(i,"createToken",{enumerable:!0,get:function(){return r.createToken}}),Object.defineProperty(i,"createTokenInstance",{enumerable:!0,get:function(){return r.createTokenInstance}}),Object.defineProperty(i,"EOF",{enumerable:!0,get:function(){return r.EOF}}),Object.defineProperty(i,"tokenLabel",{enumerable:!0,get:function(){return r.tokenLabel}}),Object.defineProperty(i,"tokenMatcher",{enumerable:!0,get:function(){return r.tokenMatcher}}),Object.defineProperty(i,"tokenName",{enumerable:!0,get:function(){return r.tokenName}});var s=Up();Object.defineProperty(i,"defaultParserErrorProvider",{enumerable:!0,get:function(){return s.defaultParserErrorProvider}});var o=wh();Object.defineProperty(i,"EarlyExitException",{enumerable:!0,get:function(){return o.EarlyExitException}}),Object.defineProperty(i,"isRecognitionException",{enumerable:!0,get:function(){return o.isRecognitionException}}),Object.defineProperty(i,"MismatchedTokenException",{enumerable:!0,get:function(){return o.MismatchedTokenException}}),Object.defineProperty(i,"NotAllInputParsedException",{enumerable:!0,get:function(){return o.NotAllInputParsedException}}),Object.defineProperty(i,"NoViableAltException",{enumerable:!0,get:function(){return o.NoViableAltException}});var a=iM();Object.defineProperty(i,"defaultLexerErrorProvider",{enumerable:!0,get:function(){return a.defaultLexerErrorProvider}});var c=Bi();Object.defineProperty(i,"Alternation",{enumerable:!0,get:function(){return c.Alternation}}),Object.defineProperty(i,"Alternative",{enumerable:!0,get:function(){return c.Alternative}}),Object.defineProperty(i,"NonTerminal",{enumerable:!0,get:function(){return c.NonTerminal}}),Object.defineProperty(i,"Option",{enumerable:!0,get:function(){return c.Option}}),Object.defineProperty(i,"Repetition",{enumerable:!0,get:function(){return c.Repetition}}),Object.defineProperty(i,"RepetitionMandatory",{enumerable:!0,get:function(){return c.RepetitionMandatory}}),Object.defineProperty(i,"RepetitionMandatoryWithSeparator",{enumerable:!0,get:function(){return c.RepetitionMandatoryWithSeparator}}),Object.defineProperty(i,"RepetitionWithSeparator",{enumerable:!0,get:function(){return c.RepetitionWithSeparator}}),Object.defineProperty(i,"Rule",{enumerable:!0,get:function(){return c.Rule}}),Object.defineProperty(i,"Terminal",{enumerable:!0,get:function(){return c.Terminal}});var l=Bi();Object.defineProperty(i,"serializeGrammar",{enumerable:!0,get:function(){return l.serializeGrammar}}),Object.defineProperty(i,"serializeProduction",{enumerable:!0,get:function(){return l.serializeProduction}});var u=Ah();Object.defineProperty(i,"GAstVisitor",{enumerable:!0,get:function(){return u.GAstVisitor}});function h(){console.warn(`The clearCache function was 'soft' removed from the Chevrotain API.
It performs no action other than printing this message.
Please avoid using it as it will be completely removed in the future`)}i.clearCache=h;var d=wP();Object.defineProperty(i,"createSyntaxDiagramsCode",{enumerable:!0,get:function(){return d.createSyntaxDiagramsCode}});var m=(function(){function g(){throw new Error(`The Parser class has been deprecated, use CstParser or EmbeddedActionsParser instead.
See: https://chevrotain.io/docs/changes/BREAKING_CHANGES.html#_7-0-0`)}return g})();i.Parser=m}),Fc=RP();var zp=class extends rn{constructor(e){super(e)}load(e,t,n,r){let s=this,o=s.path===""?Mi.extractUrlBase(e):s.path,a=new Vn(s.manager);a.setPath(s.path),a.setRequestHeader(s.requestHeader),a.setWithCredentials(s.withCredentials),a.load(e,function(c){try{t(s.parse(c,o))}catch(l){r?r(l):console.error(l),s.manager.itemError(e)}},n,r)}parse(e,t){let n={};function r(D){let P=s(),U=new Nx(P.tokens),X=new Lx(P.tokenVocabulary),Z=o(X.getBaseCstVisitorConstructor()),$=U.lex(D);X.input=$.tokens;let te=X.vrml();if(X.errors.length>0)throw console.error(X.errors),Error("THREE.VRMLLoader: Parsing errors detected.");return Z.visit(te)}function s(){let D=Fc.createToken,P=D({name:"RouteIdentifier",pattern:/[^\x30-\x39\0-\x20\x22\x27\x23\x2b\x2c\x2d\x2e\x5b\x5d\x5c\x7b\x7d][^\0-\x20\x22\x27\x23\x2b\x2c\x2d\x2e\x5b\x5d\x5c\x7b\x7d]*[\.][^\x30-\x39\0-\x20\x22\x27\x23\x2b\x2c\x2d\x2e\x5b\x5d\x5c\x7b\x7d][^\0-\x20\x22\x27\x23\x2b\x2c\x2d\x2e\x5b\x5d\x5c\x7b\x7d]*/}),U=D({name:"Identifier",pattern:/[^\x30-\x39\0-\x20\x22\x27\x23\x2b\x2c\x2d\x2e\x5b\x5d\x5c\x7b\x7d]([^\0-\x20\x22\x27\x23\x2b\x2c\x2e\x5b\x5d\x5c\x7b\x7d])*/,longer_alt:P}),X=["Anchor","Billboard","Collision","Group","Transform","Inline","LOD","Switch","AudioClip","DirectionalLight","PointLight","Script","Shape","Sound","SpotLight","WorldInfo","CylinderSensor","PlaneSensor","ProximitySensor","SphereSensor","TimeSensor","TouchSensor","VisibilitySensor","Box","Cone","Cylinder","ElevationGrid","Extrusion","IndexedFaceSet","IndexedLineSet","PointSet","Sphere","Color","Coordinate","Normal","TextureCoordinate","Appearance","FontStyle","ImageTexture","Material","MovieTexture","PixelTexture","TextureTransform","ColorInterpolator","CoordinateInterpolator","NormalInterpolator","OrientationInterpolator","PositionInterpolator","ScalarInterpolator","Background","Fog","NavigationInfo","Viewpoint","Text"],Z=D({name:"Version",pattern:/#VRML.*/,longer_alt:U}),$=D({name:"NodeName",pattern:new RegExp(X.join("|")),longer_alt:U}),te=D({name:"DEF",pattern:/DEF/,longer_alt:U}),ae=D({name:"USE",pattern:/USE/,longer_alt:U}),re=D({name:"ROUTE",pattern:/ROUTE/,longer_alt:U}),ge=D({name:"TO",pattern:/TO/,longer_alt:U}),xe=D({name:"StringLiteral",pattern:/"(?:[^\\"\n\r]|\\[bfnrtv"\\/]|\\u[0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F])*"/}),Ne=D({name:"HexLiteral",pattern:/0[xX][0-9a-fA-F]+/}),ke=D({name:"NumberLiteral",pattern:/[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?/}),$e=D({name:"TrueLiteral",pattern:/TRUE/}),Le=D({name:"FalseLiteral",pattern:/FALSE/}),Xe=D({name:"NullLiteral",pattern:/NULL/}),ne=D({name:"LSquare",pattern:/\[/}),Pe=D({name:"RSquare",pattern:/]/}),pe=D({name:"LCurly",pattern:/{/}),fe=D({name:"RCurly",pattern:/}/}),Be=D({name:"Comment",pattern:/#.*/,group:Fc.Lexer.SKIPPED}),st=[D({name:"WhiteSpace",pattern:/[ ,\s]/,group:Fc.Lexer.SKIPPED}),$,te,ae,re,ge,$e,Le,Xe,Z,U,P,xe,Ne,ke,ne,Pe,pe,fe,Be],pt={};for(let lt=0,Ge=st.length;lt<Ge;lt++){let Je=st[lt];pt[Je.name]=Je}return{tokens:st,tokenVocabulary:pt}}function o(D){class P extends D{constructor(){super(),this.validateVisitor()}vrml(Z){let $={version:this.visit(Z.version),nodes:[],routes:[]};for(let te=0,ae=Z.node.length;te<ae;te++){let re=Z.node[te];$.nodes.push(this.visit(re))}if(Z.route)for(let te=0,ae=Z.route.length;te<ae;te++){let re=Z.route[te];$.routes.push(this.visit(re))}return $}version(Z){return Z.Version[0].image}node(Z){let $={name:Z.NodeName[0].image,fields:[]};if(Z.field)for(let te=0,ae=Z.field.length;te<ae;te++){let re=Z.field[te];$.fields.push(this.visit(re))}return Z.def&&($.DEF=this.visit(Z.def[0])),$}field(Z){let $={name:Z.Identifier[0].image,type:null,values:null},te;return Z.singleFieldValue&&(te=this.visit(Z.singleFieldValue[0])),Z.multiFieldValue&&(te=this.visit(Z.multiFieldValue[0])),$.type=te.type,$.values=te.values,$}def(Z){return(Z.Identifier||Z.NodeName)[0].image}use(Z){return{USE:(Z.Identifier||Z.NodeName)[0].image}}singleFieldValue(Z){return U(this,Z)}multiFieldValue(Z){return U(this,Z)}route(Z){return{FROM:Z.RouteIdentifier[0].image,TO:Z.RouteIdentifier[1].image}}}function U(X,Z){let $={type:null,values:[]};if(Z.node){$.type="node";for(let te=0,ae=Z.node.length;te<ae;te++){let re=Z.node[te];$.values.push(X.visit(re))}}if(Z.use){$.type="use";for(let te=0,ae=Z.use.length;te<ae;te++){let re=Z.use[te];$.values.push(X.visit(re))}}if(Z.StringLiteral){$.type="string";for(let te=0,ae=Z.StringLiteral.length;te<ae;te++){let re=Z.StringLiteral[te];$.values.push(re.image.replace(/'|"/g,""))}}if(Z.NumberLiteral){$.type="number";for(let te=0,ae=Z.NumberLiteral.length;te<ae;te++){let re=Z.NumberLiteral[te];$.values.push(parseFloat(re.image))}}if(Z.HexLiteral){$.type="hex";for(let te=0,ae=Z.HexLiteral.length;te<ae;te++){let re=Z.HexLiteral[te];$.values.push(re.image)}}if(Z.TrueLiteral){$.type="boolean";for(let te=0,ae=Z.TrueLiteral.length;te<ae;te++)Z.TrueLiteral[te].image==="TRUE"&&$.values.push(!0)}if(Z.FalseLiteral){$.type="boolean";for(let te=0,ae=Z.FalseLiteral.length;te<ae;te++)Z.FalseLiteral[te].image==="FALSE"&&$.values.push(!1)}return Z.NullLiteral&&($.type="null",Z.NullLiteral.forEach(function(){$.values.push(null)})),$}return new P}function a(D){let P=D.nodes,U=new oi;for(let X=0,Z=P.length;X<Z;X++){let $=P[X];c($)}for(let X=0,Z=P.length;X<Z;X++){let $=P[X],te=l($);te instanceof St&&U.add(te),$.name==="WorldInfo"&&(U.userData.worldInfo=te)}return U}function c(D){D.DEF&&(n[D.DEF]=D);let P=D.fields;for(let U=0,X=P.length;U<X;U++){let Z=P[U];if(Z.type==="node"){let $=Z.values;for(let te=0,ae=$.length;te<ae;te++)c($[te])}}}function l(D){return D.USE?K(D.USE):(D.build!==void 0||(D.build=u(D)),D.build)}function u(D){let P=D.name,U;switch(P){case"Anchor":case"Group":case"Transform":case"Collision":U=h(D);break;case"Background":U=d(D);break;case"Shape":U=m(D);break;case"Appearance":U=g(D);break;case"Material":U=x(D);break;case"ImageTexture":U=_(D);break;case"PixelTexture":U=v(D);break;case"TextureTransform":U=y(D);break;case"IndexedFaceSet":U=A(D);break;case"IndexedLineSet":U=T(D);break;case"PointSet":U=M(D);break;case"Box":U=S(D);break;case"Cone":U=C(D);break;case"Cylinder":U=N(D);break;case"Sphere":U=I(D);break;case"ElevationGrid":U=L(D);break;case"Extrusion":U=q(D);break;case"Color":case"Coordinate":case"Normal":case"TextureCoordinate":U=b(D);break;case"WorldInfo":U=E(D);break;case"Billboard":case"Inline":case"LOD":case"Switch":case"AudioClip":case"DirectionalLight":case"PointLight":case"Script":case"Sound":case"SpotLight":case"CylinderSensor":case"PlaneSensor":case"ProximitySensor":case"SphereSensor":case"TimeSensor":case"TouchSensor":case"VisibilitySensor":case"Text":case"FontStyle":case"MovieTexture":case"ColorInterpolator":case"CoordinateInterpolator":case"NormalInterpolator":case"OrientationInterpolator":case"PositionInterpolator":case"ScalarInterpolator":case"Fog":case"NavigationInfo":case"Viewpoint":break;default:console.warn("THREE.VRMLLoader: Unknown node:",P);break}return U!==void 0&&D.DEF!==void 0&&U.hasOwnProperty("name")===!0&&(U.name=D.DEF),U}function h(D){let P=new Dt,U=D.fields;for(let X=0,Z=U.length;X<Z;X++){let $=U[X],te=$.name,ae=$.values;switch(te){case"bboxCenter":break;case"bboxSize":break;case"center":break;case"children":B(ae,P);break;case"description":break;case"collide":break;case"parameter":break;case"rotation":let re=new z(ae[0],ae[1],ae[2]).normalize(),ge=ae[3];P.quaternion.setFromAxisAngle(re,ge);break;case"scale":P.scale.set(ae[0],ae[1],ae[2]);break;case"scaleOrientation":break;case"translation":P.position.set(ae[0],ae[1],ae[2]);break;case"proxy":break;case"url":break;default:console.warn("THREE.VRMLLoader: Unknown field:",te);break}}return P}function d(D){let P=new Dt,U,X,Z,$,te=D.fields;for(let re=0,ge=te.length;re<ge;re++){let xe=te[re],Ne=xe.name,ke=xe.values;switch(Ne){case"groundAngle":U=ke;break;case"groundColor":X=ke;break;case"backUrl":break;case"bottomUrl":break;case"frontUrl":break;case"leftUrl":break;case"rightUrl":break;case"topUrl":break;case"skyAngle":Z=ke;break;case"skyColor":$=ke;break;default:console.warn("THREE.VRMLLoader: Unknown field:",Ne);break}}let ae=1e4;if($){let re=new _i(ae,32,16),ge=new Ht({fog:!1,side:un,depthWrite:!1,depthTest:!1});$.length>3?(We(re,ae,Z,Oe($),!0),ge.vertexColors=!0):ge.color.setRGB($[0],$[1],$[2],wt);let xe=new ct(re,ge);P.add(xe)}if(X&&X.length>0){let re=new _i(ae,32,16,0,2*Math.PI,.5*Math.PI,1.5*Math.PI),ge=new Ht({fog:!1,side:un,vertexColors:!0,depthWrite:!1,depthTest:!1});We(re,ae,U,Oe(X),!1);let xe=new ct(re,ge);P.add(xe)}return P.renderOrder=-1/0,P}function m(D){let P=D.fields,U=new Ht({name:rn.DEFAULT_MATERIAL_NAME,color:0}),X;for(let $=0,te=P.length;$<te;$++){let ae=P[$],re=ae.name,ge=ae.values;switch(re){case"appearance":ge[0]!==null&&(U=l(ge[0]));break;case"geometry":ge[0]!==null&&(X=l(ge[0]));break;default:console.warn("THREE.VRMLLoader: Unknown field:",re);break}}let Z;if(X&&X.attributes.position){let $=X._type;if($==="points"){let te=new Sr({name:rn.DEFAULT_MATERIAL_NAME,color:16777215,opacity:U.opacity,transparent:U.transparent});X.attributes.color!==void 0?te.vertexColors=!0:U.isMeshPhongMaterial&&te.color.copy(U.emissive),Z=new ts(X,te)}else if($==="line"){let te=new Xt({name:rn.DEFAULT_MATERIAL_NAME,color:16777215,opacity:U.opacity,transparent:U.transparent});X.attributes.color!==void 0?te.vertexColors=!0:U.isMeshPhongMaterial&&te.color.copy(U.emissive),Z=new ln(X,te)}else X._solid!==void 0&&(U.side=X._solid?Jn:xn),X.attributes.color!==void 0&&(U.vertexColors=!0),Z=new ct(X,U)}else Z=new St,Z.visible=!1;return Z}function g(D){let P=new Vo,U,X=D.fields;for(let Z=0,$=X.length;Z<$;Z++){let te=X[Z],ae=te.name,re=te.values;switch(ae){case"material":if(re[0]!==null){let xe=l(re[0]);xe.diffuseColor&&P.color.copy(xe.diffuseColor),xe.emissiveColor&&P.emissive.copy(xe.emissiveColor),xe.shininess&&(P.shininess=xe.shininess),xe.specularColor&&P.specular.copy(xe.specularColor),xe.transparency&&(P.opacity=1-xe.transparency),xe.transparency>0&&(P.transparent=!0)}else P=new Ht({name:rn.DEFAULT_MATERIAL_NAME,color:0});break;case"texture":let ge=re[0];ge!==null&&(ge.name==="ImageTexture"||ge.name==="PixelTexture")&&(P.map=l(ge));break;case"textureTransform":re[0]!==null&&(U=l(re[0]));break;default:console.warn("THREE.VRMLLoader: Unknown field:",ae);break}}if(P.map){if(P.map.__type){switch(P.map.__type){case dr.INTENSITY_ALPHA:P.opacity=1;break;case dr.RGB:P.color.set(16777215);break;case dr.RGBA:P.color.set(16777215),P.opacity=1;break;default:}delete P.map.__type}U&&(P.map.center.copy(U.center),P.map.rotation=U.rotation,P.map.repeat.copy(U.scale),P.map.offset.copy(U.translation))}return P}function x(D){let P={},U=D.fields;for(let X=0,Z=U.length;X<Z;X++){let $=U[X],te=$.name,ae=$.values;switch(te){case"ambientIntensity":break;case"diffuseColor":P.diffuseColor=new Ue().setRGB(ae[0],ae[1],ae[2],wt);break;case"emissiveColor":P.emissiveColor=new Ue().setRGB(ae[0],ae[1],ae[2],wt);break;case"shininess":P.shininess=ae[0];break;case"specularColor":P.specularColor=new Ue().setRGB(ae[0],ae[1],ae[2],wt);break;case"transparency":P.transparency=ae[0];break;default:console.warn("THREE.VRMLLoader: Unknown field:",te);break}}return P}function f(D,P,U){let X;switch(P){case dr.INTENSITY:X=parseInt(D),U.r=X,U.g=X,U.b=X,U.a=1;break;case dr.INTENSITY_ALPHA:X=parseInt("0x"+D.substring(2,4)),U.r=X,U.g=X,U.b=X,U.a=parseInt("0x"+D.substring(4,6));break;case dr.RGB:U.r=parseInt("0x"+D.substring(2,4)),U.g=parseInt("0x"+D.substring(4,6)),U.b=parseInt("0x"+D.substring(6,8)),U.a=1;break;case dr.RGBA:U.r=parseInt("0x"+D.substring(2,4)),U.g=parseInt("0x"+D.substring(4,6)),U.b=parseInt("0x"+D.substring(6,8)),U.a=parseInt("0x"+D.substring(8,10));break;default:}}function p(D){let P;switch(D){case 1:P=dr.INTENSITY;break;case 2:P=dr.INTENSITY_ALPHA;break;case 3:P=dr.RGB;break;case 4:P=dr.RGBA;break;default:}return P}function v(D){let P,U=gn,X=gn,Z=D.fields;for(let $=0,te=Z.length;$<te;$++){let ae=Z[$],re=ae.name,ge=ae.values;switch(re){case"image":let xe=ge[0],Ne=ge[1],ke=ge[2],$e=p(ke),Le=new Uint8Array(4*xe*Ne),Xe={r:0,g:0,b:0,a:0};for(let ne=3,Pe=0,pe=ge.length;ne<pe;ne++,Pe++){f(ge[ne],$e,Xe);let fe=Pe*4;Le[fe+0]=Xe.r,Le[fe+1]=Xe.g,Le[fe+2]=Xe.b,Le[fe+3]=Xe.a}P=new An(Le,xe,Ne),P.colorSpace=wt,P.needsUpdate=!0,P.__type=$e;break;case"repeatS":ge[0]===!1&&(U=Mn);break;case"repeatT":ge[0]===!1&&(X=Mn);break;default:console.warn("THREE.VRMLLoader: Unknown field:",re);break}}return P&&(P.wrapS=U,P.wrapT=X),P}function _(D){let P,U=gn,X=gn,Z=D.fields;for(let $=0,te=Z.length;$<te;$++){let ae=Z[$],re=ae.name,ge=ae.values;switch(re){case"url":let xe=ge[0];xe&&(P=Ae.load(xe));break;case"repeatS":ge[0]===!1&&(U=Mn);break;case"repeatT":ge[0]===!1&&(X=Mn);break;default:console.warn("THREE.VRMLLoader: Unknown field:",re);break}}return P&&(P.wrapS=U,P.wrapT=X,P.colorSpace=wt),P}function y(D){let P={center:new Me,rotation:new Me,scale:new Me,translation:new Me},U=D.fields;for(let X=0,Z=U.length;X<Z;X++){let $=U[X],te=$.name,ae=$.values;switch(te){case"center":P.center.set(ae[0],ae[1]);break;case"rotation":P.rotation=ae[0];break;case"scale":P.scale.set(ae[0],ae[1]);break;case"translation":P.translation.set(ae[0],ae[1]);break;default:console.warn("THREE.VRMLLoader: Unknown field:",te);break}}return P}function b(D){return D.fields[0].values}function E(D){let P={},U=D.fields;for(let X=0,Z=U.length;X<Z;X++){let $=U[X],te=$.name,ae=$.values;switch(te){case"title":P.title=ae[0];break;case"info":P.info=ae;break;default:console.warn("THREE.VRMLLoader: Unknown field:",te);break}}return P}function A(D){let P,U,X,Z,$=!0,te=!0,ae=0,re,ge,xe,Ne,ke=!0,$e=!0,Le=D.fields;for(let De=0,st=Le.length;De<st;De++){let pt=Le[De],lt=pt.name,Ge=pt.values;switch(lt){case"color":let Je=Ge[0];Je!==null&&(P=l(Je));break;case"coord":let we=Ge[0];we!==null&&(U=l(we));break;case"normal":let tt=Ge[0];tt!==null&&(X=l(tt));break;case"texCoord":let at=Ge[0];at!==null&&(Z=l(at));break;case"ccw":$=Ge[0];break;case"colorIndex":re=Ge;break;case"colorPerVertex":ke=Ge[0];break;case"convex":break;case"coordIndex":ge=Ge;break;case"creaseAngle":ae=Ge[0];break;case"normalIndex":xe=Ge;break;case"normalPerVertex":$e=Ge[0];break;case"solid":te=Ge[0];break;case"texCoordIndex":Ne=Ge;break;default:console.warn("THREE.VRMLLoader: Unknown field:",lt);break}}if(ge===void 0)return console.warn("THREE.VRMLLoader: Missing coordIndex."),new ot;let Xe=j(ge,$),ne,Pe,pe;if(P){if(ke===!0)if(re&&re.length>0){let De=j(re,$);ne=ee(Xe,De,P,3)}else ne=oe(Xe,new ze(P,3));else if(re&&re.length>0){let De=se(P,re),st=J(De,ge);ne=he(Xe,st)}else{let De=J(P,ge);ne=he(Xe,De)}Re(ne)}if(X)if($e===!0)if(xe&&xe.length>0){let De=j(xe,$);Pe=ee(Xe,De,X,3)}else Pe=oe(Xe,new ze(X,3));else if(xe&&xe.length>0){let De=se(X,xe),st=J(De,ge);Pe=he(Xe,st)}else{let De=J(X,ge);Pe=he(Xe,De)}else Pe=Ie(Xe,U,ae);if(Z)if(Ne&&Ne.length>0){let De=j(Ne,$);pe=ee(Xe,De,Z,2)}else pe=oe(Xe,new ze(Z,2));let fe=new ot,Be=oe(Xe,new ze(U,3));return fe.setAttribute("position",Be),fe.setAttribute("normal",Pe),ne&&fe.setAttribute("color",ne),pe&&fe.setAttribute("uv",pe),fe._solid=te,fe._type="mesh",fe}function T(D){let P,U,X,Z,$=!0,te=D.fields;for(let Ne=0,ke=te.length;Ne<ke;Ne++){let $e=te[Ne],Le=$e.name,Xe=$e.values;switch(Le){case"color":let ne=Xe[0];ne!==null&&(P=l(ne));break;case"coord":let Pe=Xe[0];Pe!==null&&(U=l(Pe));break;case"colorIndex":X=Xe;break;case"colorPerVertex":$=Xe[0];break;case"coordIndex":Z=Xe;break;default:console.warn("THREE.VRMLLoader: Unknown field:",Le);break}}let ae,re=ce(Z);if(P){if($===!0)if(X.length>0){let Ne=ce(X);ae=ee(re,Ne,P,3)}else ae=oe(re,new ze(P,3));else if(X.length>0){let Ne=se(P,X),ke=me(Ne,Z);ae=Ce(re,ke)}else{let Ne=me(P,Z);ae=Ce(re,Ne)}Re(ae)}let ge=new ot,xe=oe(re,new ze(U,3));return ge.setAttribute("position",xe),ae&&ge.setAttribute("color",ae),ge._type="line",ge}function M(D){let P,U,X=D.fields;for(let $=0,te=X.length;$<te;$++){let ae=X[$],re=ae.name,ge=ae.values;switch(re){case"color":let xe=ge[0];xe!==null&&(P=l(xe));break;case"coord":let Ne=ge[0];Ne!==null&&(U=l(Ne));break;default:console.warn("THREE.VRMLLoader: Unknown field:",re);break}}let Z=new ot;if(Z.setAttribute("position",new ze(U,3)),P){let $=new ze(P,3);Re($),Z.setAttribute("color",$)}return Z._type="points",Z}function S(D){let P=new z(2,2,2),U=D.fields;for(let Z=0,$=U.length;Z<$;Z++){let te=U[Z],ae=te.name,re=te.values;switch(ae){case"size":P.x=re[0],P.y=re[1],P.z=re[2];break;default:console.warn("THREE.VRMLLoader: Unknown field:",ae);break}}return new Qn(P.x,P.y,P.z)}function C(D){let P=1,U=2,X=!1,Z=D.fields;for(let te=0,ae=Z.length;te<ae;te++){let re=Z[te],ge=re.name,xe=re.values;switch(ge){case"bottom":X=!xe[0];break;case"bottomRadius":P=xe[0];break;case"height":U=xe[0];break;case"side":break;default:console.warn("THREE.VRMLLoader: Unknown field:",ge);break}}return new ko(P,U,16,1,X)}function N(D){let P=1,U=2,X=D.fields;for(let $=0,te=X.length;$<te;$++){let ae=X[$],re=ae.name,ge=ae.values;switch(re){case"bottom":break;case"radius":P=ge[0];break;case"height":U=ge[0];break;case"side":break;case"top":break;default:console.warn("THREE.VRMLLoader: Unknown field:",re);break}}return new is(P,P,U,16,1)}function I(D){let P=1,U=D.fields;for(let Z=0,$=U.length;Z<$;Z++){let te=U[Z],ae=te.name,re=te.values;switch(ae){case"radius":P=re[0];break;default:console.warn("THREE.VRMLLoader: Unknown field:",ae);break}}return new _i(P,16,16)}function L(D){let P,U,X,Z,$=!0,te=!0,ae=!0,re=!0,ge=0,xe=2,Ne=2,ke=1,$e=1,Le=D.fields;for(let Ge=0,Je=Le.length;Ge<Je;Ge++){let we=Le[Ge],tt=we.name,at=we.values;switch(tt){case"color":let bt=at[0];bt!==null&&(P=l(bt));break;case"normal":let Xn=at[0];Xn!==null&&(U=l(Xn));break;case"texCoord":let ei=at[0];ei!==null&&(X=l(ei));break;case"height":Z=at;break;case"ccw":re=at[0];break;case"colorPerVertex":$=at[0];break;case"creaseAngle":ge=at[0];break;case"normalPerVertex":te=at[0];break;case"solid":ae=at[0];break;case"xDimension":xe=at[0];break;case"xSpacing":ke=at[0];break;case"zDimension":Ne=at[0];break;case"zSpacing":$e=at[0];break;default:console.warn("THREE.VRMLLoader: Unknown field:",tt);break}}let Xe=[],ne=[],Pe=[],pe=[];for(let Ge=0;Ge<Ne;Ge++)for(let Je=0;Je<xe;Je++){let we=Ge*xe+Je,tt=ke*Ge,at=Z[we],bt=$e*Je;if(Xe.push(tt,at,bt),P&&$===!0){let Xn=P[we*3+0],ei=P[we*3+1],mr=P[we*3+2];Pe.push(Xn,ei,mr)}if(U&&te===!0){let Xn=U[we*3+0],ei=U[we*3+1],mr=U[we*3+2];ne.push(Xn,ei,mr)}if(X){let Xn=X[we*2+0],ei=X[we*2+1];pe.push(Xn,ei)}else pe.push(Ge/(xe-1),Je/(Ne-1))}let fe=[];for(let Ge=0;Ge<xe-1;Ge++)for(let Je=0;Je<Ne-1;Je++){let we=Ge+Je*xe,tt=Ge+(Je+1)*xe,at=Ge+1+(Je+1)*xe,bt=Ge+1+Je*xe;re===!0?(fe.push(we,at,tt),fe.push(at,we,bt)):(fe.push(we,tt,at),fe.push(at,bt,we))}let Be=oe(fe,new ze(Xe,3)),De=oe(fe,new ze(pe,2)),st,pt;if(P){if($===!1){for(let Ge=0;Ge<xe-1;Ge++)for(let Je=0;Je<Ne-1;Je++){let we=Ge+Je*(xe-1),tt=P[we*3+0],at=P[we*3+1],bt=P[we*3+2];Pe.push(tt,at,bt),Pe.push(tt,at,bt),Pe.push(tt,at,bt),Pe.push(tt,at,bt),Pe.push(tt,at,bt),Pe.push(tt,at,bt)}st=new ze(Pe,3)}else st=oe(fe,new ze(Pe,3));Re(st)}if(U)if(te===!1){for(let Ge=0;Ge<xe-1;Ge++)for(let Je=0;Je<Ne-1;Je++){let we=Ge+Je*(xe-1),tt=U[we*3+0],at=U[we*3+1],bt=U[we*3+2];ne.push(tt,at,bt),ne.push(tt,at,bt),ne.push(tt,at,bt),ne.push(tt,at,bt),ne.push(tt,at,bt),ne.push(tt,at,bt)}pt=new ze(ne,3)}else pt=oe(fe,new ze(ne,3));else pt=Ie(fe,Xe,ge);let lt=new ot;return lt.setAttribute("position",Be),lt.setAttribute("normal",pt),lt.setAttribute("uv",De),st&<.setAttribute("color",st),lt._solid=ae,lt._type="mesh",lt}function q(D){let P=[1,1,1,-1,-1,-1,-1,1,1,1],U=[0,0,0,0,1,0],X,Z,$=!0,te=!0,ae=0,re=!0,ge=!0,xe=D.fields;for(let lt=0,Ge=xe.length;lt<Ge;lt++){let Je=xe[lt],we=Je.name,tt=Je.values;switch(we){case"beginCap":$=tt[0];break;case"ccw":te=tt[0];break;case"convex":break;case"creaseAngle":ae=tt[0];break;case"crossSection":P=tt;break;case"endCap":re=tt[0];break;case"orientation":Z=tt;break;case"scale":X=tt;break;case"solid":ge=tt[0];break;case"spine":U=tt;break;default:console.warn("THREE.VRMLLoader: Unknown field:",we);break}}let Ne=P[0]===P[P.length-2]&&P[1]===P[P.length-1],ke=[],$e=new z,Le=new z,Xe=new z,ne=new z,Pe=new Zt;for(let lt=0,Ge=0,Je=0,we=U.length;lt<we;lt+=3,Ge+=2,Je+=4){$e.fromArray(U,lt),Le.x=X?X[Ge+0]:1,Le.y=1,Le.z=X?X[Ge+1]:1,Xe.x=Z?Z[Je+0]:0,Xe.y=Z?Z[Je+1]:0,Xe.z=Z?Z[Je+2]:1;let tt=Z?Z[Je+3]:0;for(let at=0,bt=P.length;at<bt;at+=2)ne.x=P[at+0],ne.y=0,ne.z=P[at+1],ne.multiply(Le),Pe.setFromAxisAngle(Xe,tt),ne.applyQuaternion(Pe),ne.add($e),ke.push(ne.x,ne.y,ne.z)}let pe=[],fe=U.length/3,Be=P.length/2;for(let lt=0;lt<fe-1;lt++)for(let Ge=0;Ge<Be-1;Ge++){let Je=Ge+lt*Be,we=Ge+1+lt*Be,tt=Ge+(lt+1)*Be,at=Ge+1+(lt+1)*Be;Ge===Be-2&&Ne===!0&&(we=lt*Be,at=(lt+1)*Be),te===!0?(pe.push(Je,we,tt),pe.push(tt,we,at)):(pe.push(Je,tt,we),pe.push(tt,at,we))}if($===!0||re===!0){let lt=[];for(let we=0,tt=P.length;we<tt;we+=2)lt.push(new Me(P[we],P[we+1]));let Ge=Ui.triangulateShape(lt,[]),Je=[];for(let we=0,tt=Ge.length;we<tt;we++){let at=Ge[we];Je.push(at[0],at[1],at[2])}if($===!0)for(let we=0,tt=Je.length;we<tt;we+=3)te===!0?pe.push(Je[we+0],Je[we+1],Je[we+2]):pe.push(Je[we+0],Je[we+2],Je[we+1]);if(re===!0){let we=Be*(fe-1);for(let tt=0,at=Je.length;tt<at;tt+=3)te===!0?pe.push(we+Je[tt+0],we+Je[tt+2],we+Je[tt+1]):pe.push(we+Je[tt+0],we+Je[tt+1],we+Je[tt+2])}}let De=oe(pe,new ze(ke,3)),st=Ie(pe,ke,ae),pt=new ot;return pt.setAttribute("position",De),pt.setAttribute("normal",st),pt._solid=ge,pt._type="mesh",pt}function K(D){let P=n[D],U=l(P);return U.isObject3D||U.isMaterial?U.clone():U}function B(D,P){for(let U=0,X=D.length;U<X;U++){let Z=l(D[U]);Z instanceof St&&P.add(Z)}}function j(D,P){let U=[],X=0;for(let Z=0,$=D.length;Z<$;Z++){let te=D[X],ae=D[Z+(P?1:2)],re=D[Z+(P?2:1)];U.push(te,ae,re),(D[Z+3]===-1||Z+3>=$)&&(Z+=3,X=Z+1)}return U}function J(D,P){let U=[],X=0;for(let Z=0,$=P.length;Z<$;Z++){let te=X*3,ae=D[te],re=D[te+1],ge=D[te+2];U.push(ae,re,ge),(P[Z+3]===-1||Z+3>=$)&&(Z+=3,X++)}return U}function se(D,P){let U=[];for(let X=0,Z=P.length;X<Z;X++){let te=P[X]*3,ae=D[te],re=D[te+1],ge=D[te+2];U.push(ae,re,ge)}return U}function ce(D){let P=[];for(let U=0,X=D.length;U<X;U++){let Z=D[U],$=D[U+1];P.push(Z,$),(D[U+2]===-1||U+2>=X)&&(U+=2)}return P}function me(D,P){let U=[],X=0;for(let Z=0,$=P.length;Z<$;Z++){let te=X*3,ae=D[te],re=D[te+1],ge=D[te+2];U.push(ae,re,ge),(P[Z+2]===-1||Z+2>=$)&&(Z+=2,X++)}return U}let Se=new z,V=new z,w=new z,O=new Me,W=new Me,Q=new Me;function ee(D,P,U,X){let Z=[];for(let $=0,te=D.length;$<te;$+=3){let ae=P[$],re=P[$+1],ge=P[$+2];X===2?(O.fromArray(U,ae*X),W.fromArray(U,re*X),Q.fromArray(U,ge*X),Z.push(O.x,O.y),Z.push(W.x,W.y),Z.push(Q.x,Q.y)):(Se.fromArray(U,ae*X),V.fromArray(U,re*X),w.fromArray(U,ge*X),Z.push(Se.x,Se.y,Se.z),Z.push(V.x,V.y,V.z),Z.push(w.x,w.y,w.z))}return new ze(Z,X)}function he(D,P){let U=[];for(let X=0,Z=0,$=D.length;X<$;X+=3,Z++)Se.fromArray(P,Z*3),U.push(Se.x,Se.y,Se.z),U.push(Se.x,Se.y,Se.z),U.push(Se.x,Se.y,Se.z);return new ze(U,3)}function Ce(D,P){let U=[];for(let X=0,Z=0,$=D.length;X<$;X+=2,Z++)Se.fromArray(P,Z*3),U.push(Se.x,Se.y,Se.z),U.push(Se.x,Se.y,Se.z);return new ze(U,3)}function oe(D,P){let U=P.array,X=P.itemSize,Z=new U.constructor(D.length*X),$=0,te=0;for(let ae=0,re=D.length;ae<re;ae++){$=D[ae]*X;for(let ge=0;ge<X;ge++)Z[te++]=U[$++]}return new ze(Z,X)}let ue=new z,H=new z;function Ie(D,P,U){let X=[],Z={};for(let te=0,ae=D.length;te<ae;te+=3){let re=D[te],ge=D[te+1],xe=D[te+2],Ne=new Ox(re,ge,xe);Se.fromArray(P,re*3),V.fromArray(P,ge*3),w.fromArray(P,xe*3),H.subVectors(w,V),ue.subVectors(Se,V),H.cross(ue),H.normalize(),Ne.normal.copy(H),Z[re]===void 0&&(Z[re]=[]),Z[ge]===void 0&&(Z[ge]=[]),Z[xe]===void 0&&(Z[xe]=[]),Z[re].push(Ne.normal),Z[ge].push(Ne.normal),Z[xe].push(Ne.normal),X.push(Ne)}let $=[];for(let te=0,ae=X.length;te<ae;te++){let re=X[te],ge=Te(Z[re.a],re.normal,U),xe=Te(Z[re.b],re.normal,U),Ne=Te(Z[re.c],re.normal,U);Se.fromArray(P,re.a*3),V.fromArray(P,re.b*3),w.fromArray(P,re.c*3),$.push(ge.x,ge.y,ge.z),$.push(xe.x,xe.y,xe.z),$.push(Ne.x,Ne.y,Ne.z)}return new ze($,3)}function Te(D,P,U){let X=new z;if(U===0)X.copy(P);else for(let Z=0,$=D.length;Z<$;Z++)D[Z].angleTo(P)<U&&X.add(D[Z]);return X.normalize()}function Oe(D){let P=[];for(let U=0,X=D.length;U<X;U+=3)P.push(new Ue(D[U],D[U+1],D[U+2]));return P}function Re(D){let P=new Ue;for(let U=0;U<D.count;U++)P.fromBufferAttribute(D,U),_t.toWorkingColorSpace(P,wt),D.setXYZ(U,P.r,P.g,P.b)}function We(D,P,U,X,Z){let $=[],te=Z===!0?0:Math.PI;for(let ke=0,$e=X.length;ke<$e;ke++){let Le=ke===0?0:U[ke-1];Le=Z===!0?Le:te-Le;let Xe=new z;Xe.setFromSphericalCoords(P,Le,0),$.push(Xe)}let ae=D.index,re=D.attributes.position,ge=new gt(new Float32Array(D.attributes.position.count*3),3),xe=new z,Ne=new Ue;for(let ke=0;ke<ae.count;ke++){let $e=ae.getX(ke);xe.fromBufferAttribute(re,$e);let Le,Xe,ne=1;for(let fe=1;fe<$.length;fe++){Le=fe-1,Xe=fe;let Be=$[Le],De=$[Xe];if(Z===!0){if(xe.y<=Be.y&&xe.y>De.y){ne=Math.abs(Be.y-xe.y)/Math.abs(Be.y-De.y);break}}else if(xe.y>=Be.y&&xe.y<De.y){ne=Math.abs(Be.y-xe.y)/Math.abs(Be.y-De.y);break}}let Pe=X[Le],pe=X[Xe];Ne.copy(Pe).lerp(pe,ne),_t.toWorkingColorSpace(Ne,wt),ge.setXYZ($e,Ne.r,Ne.g,Ne.b)}D.setAttribute("color",ge)}let Ae=new qs(this.manager);if(Ae.setPath(this.resourcePath||t).setCrossOrigin(this.crossOrigin),e.indexOf("#VRML V2.0")===-1)throw Error("THREE.VRMLLexer: Version of VRML asset not supported.");let Y=r(e);return a(Y)}},Nx=class{constructor(e){this.lexer=new Fc.Lexer(e)}lex(e){let t=this.lexer.tokenize(e);if(t.errors.length>0)throw console.error(t.errors),Error("THREE.VRMLLexer: Lexing errors detected.");return t}},CP=Fc.CstParser,Lx=class extends CP{constructor(e){super(e);let t=this,n=e.Version,r=e.LCurly,s=e.RCurly,o=e.LSquare,a=e.RSquare,c=e.Identifier,l=e.RouteIdentifier,u=e.StringLiteral,h=e.HexLiteral,d=e.NumberLiteral,m=e.TrueLiteral,g=e.FalseLiteral,x=e.NullLiteral,f=e.DEF,p=e.USE,v=e.ROUTE,_=e.TO,y=e.NodeName;t.RULE("vrml",function(){t.SUBRULE(t.version),t.AT_LEAST_ONE(function(){t.SUBRULE(t.node)}),t.MANY(function(){t.SUBRULE(t.route)})}),t.RULE("version",function(){t.CONSUME(n)}),t.RULE("node",function(){t.OPTION(function(){t.SUBRULE(t.def)}),t.CONSUME(y),t.CONSUME(r),t.MANY(function(){t.SUBRULE(t.field)}),t.CONSUME(s)}),t.RULE("field",function(){t.CONSUME(c),t.OR2([{ALT:function(){t.SUBRULE(t.singleFieldValue)}},{ALT:function(){t.SUBRULE(t.multiFieldValue)}}])}),t.RULE("def",function(){t.CONSUME(f),t.OR([{ALT:function(){t.CONSUME(c)}},{ALT:function(){t.CONSUME(y)}}])}),t.RULE("use",function(){t.CONSUME(p),t.OR([{ALT:function(){t.CONSUME(c)}},{ALT:function(){t.CONSUME(y)}}])}),t.RULE("singleFieldValue",function(){t.AT_LEAST_ONE(function(){t.OR([{ALT:function(){t.SUBRULE(t.node)}},{ALT:function(){t.SUBRULE(t.use)}},{ALT:function(){t.CONSUME(u)}},{ALT:function(){t.CONSUME(h)}},{ALT:function(){t.CONSUME(d)}},{ALT:function(){t.CONSUME(m)}},{ALT:function(){t.CONSUME(g)}},{ALT:function(){t.CONSUME(x)}}])})}),t.RULE("multiFieldValue",function(){t.CONSUME(o),t.MANY(function(){t.OR([{ALT:function(){t.SUBRULE(t.node)}},{ALT:function(){t.SUBRULE(t.use)}},{ALT:function(){t.CONSUME(u)}},{ALT:function(){t.CONSUME(h)}},{ALT:function(){t.CONSUME(d)}},{ALT:function(){t.CONSUME(x)}}])}),t.CONSUME(a)}),t.RULE("route",function(){t.CONSUME(v),t.CONSUME(l),t.CONSUME(_),t.CONSUME2(l)}),this.performSelfAnalysis()}},Ox=class{constructor(e,t,n){this.a=e,this.b=t,this.c=n,this.normal=new z}},dr={INTENSITY:1,INTENSITY_ALPHA:2,RGB:3,RGBA:4};var Vp=class extends oi{constructor(){super();let e=new Qn;e.deleteAttribute("uv");let t=new En({side:un}),n=new En,r=new os(16777215,900,28,2);r.position.set(.418,16.199,.3),this.add(r);let s=new ct(e,t);s.position.set(-.757,13.219,.717),s.scale.set(31.713,28.305,28.591),this.add(s);let o=new ct(e,n);o.position.set(-10.906,2.009,1.846),o.rotation.set(0,-.195,0),o.scale.set(2.328,7.905,4.651),this.add(o);let a=new ct(e,n);a.position.set(-5.607,-.754,-.758),a.rotation.set(0,.994,0),a.scale.set(1.97,1.534,3.955),this.add(a);let c=new ct(e,n);c.position.set(6.167,.857,7.803),c.rotation.set(0,.561,0),c.scale.set(3.927,6.285,3.687),this.add(c);let l=new ct(e,n);l.position.set(-2.017,.018,6.124),l.rotation.set(0,.333,0),l.scale.set(2.002,4.566,2.064),this.add(l);let u=new ct(e,n);u.position.set(2.291,-.756,-2.621),u.rotation.set(0,-.286,0),u.scale.set(1.546,1.552,1.496),this.add(u);let h=new ct(e,n);h.position.set(-2.193,-.369,-5.547),h.rotation.set(0,.516,0),h.scale.set(3.875,3.487,2.986),this.add(h);let d=new ct(e,Uc(50));d.position.set(-16.116,14.37,8.208),d.scale.set(.1,2.428,2.739),this.add(d);let m=new ct(e,Uc(50));m.position.set(-16.109,18.021,-8.207),m.scale.set(.1,2.425,2.751),this.add(m);let g=new ct(e,Uc(17));g.position.set(14.904,12.198,-1.832),g.scale.set(.15,4.265,6.331),this.add(g);let x=new ct(e,Uc(43));x.position.set(-.462,8.89,14.52),x.scale.set(4.38,5.441,.088),this.add(x);let f=new ct(e,Uc(20));f.position.set(3.235,11.486,-12.541),f.scale.set(2.5,2,.1),this.add(f);let p=new ct(e,Uc(100));p.position.set(0,20,0),p.scale.set(1,.1,1),this.add(p)}dispose(){let e=new Set;this.traverse(t=>{t.isMesh&&(e.add(t.geometry),e.add(t.material))});for(let t of e)t.dispose()}};function Uc(i){let e=new Ht;return e.color.setScalar(i),e}var Rh=new z;function qi(i,e,t,n,r,s){let o=2*Math.PI*r/4,a=Math.max(s-2*r,0),c=Math.PI/4;Rh.copy(e),Rh[n]=0,Rh.normalize();let l=.5*o/(o+a),u=1-Rh.angleTo(i)/c;return Math.sign(Rh[t])===1?u*l:a/(o+a)+l+l*(1-u)}var Hp=class extends Qn{constructor(e=1,t=1,n=1,r=2,s=.1){if(r=r*2+1,s=Math.min(e/2,t/2,n/2,s),super(1,1,1,r,r,r),r===1)return;let o=this.toNonIndexed();this.index=null,this.attributes.position=o.attributes.position,this.attributes.normal=o.attributes.normal,this.attributes.uv=o.attributes.uv;let a=new z,c=new z,l=new z(e,t,n).divideScalar(2).subScalar(s),u=this.attributes.position.array,h=this.attributes.normal.array,d=this.attributes.uv.array,m=u.length/6,g=new z,x=.5/r;for(let f=0,p=0;f<u.length;f+=3,p+=2)switch(a.fromArray(u,f),c.copy(a),c.x-=Math.sign(c.x)*x,c.y-=Math.sign(c.y)*x,c.z-=Math.sign(c.z)*x,c.normalize(),u[f+0]=l.x*Math.sign(a.x)+c.x*s,u[f+1]=l.y*Math.sign(a.y)+c.y*s,u[f+2]=l.z*Math.sign(a.z)+c.z*s,h[f+0]=c.x,h[f+1]=c.y,h[f+2]=c.z,Math.floor(f/m)){case 0:g.set(1,0,0),d[p+0]=qi(g,c,"z","y",s,n),d[p+1]=1-qi(g,c,"y","z",s,t);break;case 1:g.set(-1,0,0),d[p+0]=1-qi(g,c,"z","y",s,n),d[p+1]=1-qi(g,c,"y","z",s,t);break;case 2:g.set(0,1,0),d[p+0]=1-qi(g,c,"x","z",s,e),d[p+1]=qi(g,c,"z","x",s,n);break;case 3:g.set(0,-1,0),d[p+0]=1-qi(g,c,"x","z",s,e),d[p+1]=1-qi(g,c,"z","x",s,n);break;case 4:g.set(0,0,1),d[p+0]=1-qi(g,c,"x","y",s,e),d[p+1]=1-qi(g,c,"y","x",s,t);break;case 5:g.set(0,0,-1),d[p+0]=qi(g,c,"x","y",s,e),d[p+1]=1-qi(g,c,"y","x",s,t);break}}};var kc={name:"CopyShader",uniforms:{tDiffuse:{value:null},opacity:{value:1}},vertexShader:`
varying vec2 vUv;
void main() {
vUv = uv;
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}`,fragmentShader:`
uniform float opacity;
uniform sampler2D tDiffuse;
varying vec2 vUv;
void main() {
vec4 texel = texture2D( tDiffuse, vUv );
gl_FragColor = opacity * texel;
}`};var li=class{constructor(){this.isPass=!0,this.enabled=!0,this.needsSwap=!0,this.clear=!1,this.renderToScreen=!1}setSize(){}render(){console.error("THREE.Pass: .render() must be implemented in derived pass.")}dispose(){}},PP=new cr(-1,1,1,-1,0,1),Dx=class extends ot{constructor(){super(),this.setAttribute("position",new ze([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new ze([0,2,0,0,2,0],2))}},IP=new Dx,Fr=class{constructor(e){this._mesh=new ct(IP,e)}dispose(){this._mesh.geometry.dispose()}render(e){e.render(this._mesh,PP)}get material(){return this._mesh.material}set material(e){this._mesh.material=e}};var Gp=class extends li{constructor(e,t){super(),this.textureID=t!==void 0?t:"tDiffuse",e instanceof $t?(this.uniforms=e.uniforms,this.material=e):e&&(this.uniforms=Gn.clone(e.uniforms),this.material=new $t({name:e.name!==void 0?e.name:"unspecified",defines:Object.assign({},e.defines),uniforms:this.uniforms,vertexShader:e.vertexShader,fragmentShader:e.fragmentShader})),this.fsQuad=new Fr(this.material)}render(e,t,n){this.uniforms[this.textureID]&&(this.uniforms[this.textureID].value=n.texture),this.fsQuad.material=this.material,this.renderToScreen?(e.setRenderTarget(null),this.fsQuad.render(e)):(e.setRenderTarget(t),this.clear&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),this.fsQuad.render(e))}dispose(){this.material.dispose(),this.fsQuad.dispose()}};var Ch=class extends li{constructor(e,t){super(),this.scene=e,this.camera=t,this.clear=!0,this.needsSwap=!1,this.inverse=!1}render(e,t,n){let r=e.getContext(),s=e.state;s.buffers.color.setMask(!1),s.buffers.depth.setMask(!1),s.buffers.color.setLocked(!0),s.buffers.depth.setLocked(!0);let o,a;this.inverse?(o=0,a=1):(o=1,a=0),s.buffers.stencil.setTest(!0),s.buffers.stencil.setOp(r.REPLACE,r.REPLACE,r.REPLACE),s.buffers.stencil.setFunc(r.ALWAYS,o,4294967295),s.buffers.stencil.setClear(a),s.buffers.stencil.setLocked(!0),e.setRenderTarget(n),this.clear&&e.clear(),e.render(this.scene,this.camera),e.setRenderTarget(t),this.clear&&e.clear(),e.render(this.scene,this.camera),s.buffers.color.setLocked(!1),s.buffers.depth.setLocked(!1),s.buffers.color.setMask(!0),s.buffers.depth.setMask(!0),s.buffers.stencil.setLocked(!1),s.buffers.stencil.setFunc(r.EQUAL,1,4294967295),s.buffers.stencil.setOp(r.KEEP,r.KEEP,r.KEEP),s.buffers.stencil.setLocked(!0)}},Wp=class extends li{constructor(){super(),this.needsSwap=!1}render(e){e.state.buffers.stencil.setLocked(!1),e.state.buffers.stencil.setTest(!1)}};var Xp=class{constructor(e,t){if(this.renderer=e,this._pixelRatio=e.getPixelRatio(),t===void 0){let n=e.getSize(new Me);this._width=n.width,this._height=n.height,t=new on(this._width*this._pixelRatio,this._height*this._pixelRatio,{type:Hn}),t.texture.name="EffectComposer.rt1"}else this._width=t.width,this._height=t.height;this.renderTarget1=t,this.renderTarget2=t.clone(),this.renderTarget2.texture.name="EffectComposer.rt2",this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2,this.renderToScreen=!0,this.passes=[],this.copyPass=new Gp(kc),this.copyPass.material.blending=yn,this.clock=new Xo}swapBuffers(){let e=this.readBuffer;this.readBuffer=this.writeBuffer,this.writeBuffer=e}addPass(e){this.passes.push(e),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}insertPass(e,t){this.passes.splice(t,0,e),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}removePass(e){let t=this.passes.indexOf(e);t!==-1&&this.passes.splice(t,1)}isLastEnabledPass(e){for(let t=e+1;t<this.passes.length;t++)if(this.passes[t].enabled)return!1;return!0}render(e){e===void 0&&(e=this.clock.getDelta());let t=this.renderer.getRenderTarget(),n=!1;for(let r=0,s=this.passes.length;r<s;r++){let o=this.passes[r];if(o.enabled!==!1){if(o.renderToScreen=this.renderToScreen&&this.isLastEnabledPass(r),o.render(this.renderer,this.writeBuffer,this.readBuffer,e,n),o.needsSwap){if(n){let a=this.renderer.getContext(),c=this.renderer.state.buffers.stencil;c.setFunc(a.NOTEQUAL,1,4294967295),this.copyPass.render(this.renderer,this.writeBuffer,this.readBuffer,e),c.setFunc(a.EQUAL,1,4294967295)}this.swapBuffers()}Ch!==void 0&&(o instanceof Ch?n=!0:o instanceof Wp&&(n=!1))}}this.renderer.setRenderTarget(t)}reset(e){if(e===void 0){let t=this.renderer.getSize(new Me);this._pixelRatio=this.renderer.getPixelRatio(),this._width=t.width,this._height=t.height,e=this.renderTarget1.clone(),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}this.renderTarget1.dispose(),this.renderTarget2.dispose(),this.renderTarget1=e,this.renderTarget2=e.clone(),this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2}setSize(e,t){this._width=e,this._height=t;let n=this._width*this._pixelRatio,r=this._height*this._pixelRatio;this.renderTarget1.setSize(n,r),this.renderTarget2.setSize(n,r);for(let s=0;s<this.passes.length;s++)this.passes[s].setSize(n,r)}setPixelRatio(e){this._pixelRatio=e,this.setSize(this._width,this._height)}dispose(){this.renderTarget1.dispose(),this.renderTarget2.dispose(),this.copyPass.dispose()}};var Yp=class extends li{constructor(e,t,n=null,r=null,s=null){super(),this.scene=e,this.camera=t,this.overrideMaterial=n,this.clearColor=r,this.clearAlpha=s,this.clear=!0,this.clearDepth=!1,this.needsSwap=!1,this._oldClearColor=new Ue}render(e,t,n){let r=e.autoClear;e.autoClear=!1;let s,o;this.overrideMaterial!==null&&(o=this.scene.overrideMaterial,this.scene.overrideMaterial=this.overrideMaterial),this.clearColor!==null&&(e.getClearColor(this._oldClearColor),e.setClearColor(this.clearColor,e.getClearAlpha())),this.clearAlpha!==null&&(s=e.getClearAlpha(),e.setClearAlpha(this.clearAlpha)),this.clearDepth==!0&&e.clearDepth(),e.setRenderTarget(this.renderToScreen?null:n),this.clear===!0&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),e.render(this.scene,this.camera),this.clearColor!==null&&e.setClearColor(this._oldClearColor),this.clearAlpha!==null&&e.setClearAlpha(s),this.overrideMaterial!==null&&(this.scene.overrideMaterial=o),e.autoClear=r}};var Ph={name:"GTAOShader",defines:{PERSPECTIVE_CAMERA:1,SAMPLES:16,NORMAL_VECTOR_TYPE:1,DEPTH_SWIZZLING:"x",SCREEN_SPACE_RADIUS:0,SCREEN_SPACE_RADIUS_SCALE:100,SCENE_CLIP_BOX:0},uniforms:{tNormal:{value:null},tDepth:{value:null},tNoise:{value:null},resolution:{value:new Me},cameraNear:{value:null},cameraFar:{value:null},cameraProjectionMatrix:{value:new nt},cameraProjectionMatrixInverse:{value:new nt},cameraWorldMatrix:{value:new nt},radius:{value:.25},distanceExponent:{value:1},thickness:{value:1},distanceFallOff:{value:1},scale:{value:1},sceneBoxMin:{value:new z(-1,-1,-1)},sceneBoxMax:{value:new z(1,1,1)}},vertexShader:`
varying vec2 vUv;
void main() {
vUv = uv;
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}`,fragmentShader:`
varying vec2 vUv;
uniform highp sampler2D tNormal;
uniform highp sampler2D tDepth;
uniform sampler2D tNoise;
uniform vec2 resolution;
uniform float cameraNear;
uniform float cameraFar;
uniform mat4 cameraProjectionMatrix;
uniform mat4 cameraProjectionMatrixInverse;
uniform mat4 cameraWorldMatrix;
uniform float radius;
uniform float distanceExponent;
uniform float thickness;
uniform float distanceFallOff;
uniform float scale;
#if SCENE_CLIP_BOX == 1
uniform vec3 sceneBoxMin;
uniform vec3 sceneBoxMax;
#endif
#include <common>
#include <packing>
#ifndef FRAGMENT_OUTPUT
#define FRAGMENT_OUTPUT vec4(vec3(ao), 1.)
#endif
vec3 getViewPosition(const in vec2 screenPosition, const in float depth) {
vec4 clipSpacePosition = vec4(vec3(screenPosition, depth) * 2.0 - 1.0, 1.0);
vec4 viewSpacePosition = cameraProjectionMatrixInverse * clipSpacePosition;
return viewSpacePosition.xyz / viewSpacePosition.w;
}
float getDepth(const vec2 uv) {
return textureLod(tDepth, uv.xy, 0.0).DEPTH_SWIZZLING;
}
float fetchDepth(const ivec2 uv) {
return texelFetch(tDepth, uv.xy, 0).DEPTH_SWIZZLING;
}
float getViewZ(const in float depth) {
#if PERSPECTIVE_CAMERA == 1
return perspectiveDepthToViewZ(depth, cameraNear, cameraFar);
#else
return orthographicDepthToViewZ(depth, cameraNear, cameraFar);
#endif
}
vec3 computeNormalFromDepth(const vec2 uv) {
vec2 size = vec2(textureSize(tDepth, 0));
ivec2 p = ivec2(uv * size);
float c0 = fetchDepth(p);
float l2 = fetchDepth(p - ivec2(2, 0));
float l1 = fetchDepth(p - ivec2(1, 0));
float r1 = fetchDepth(p + ivec2(1, 0));
float r2 = fetchDepth(p + ivec2(2, 0));
float b2 = fetchDepth(p - ivec2(0, 2));
float b1 = fetchDepth(p - ivec2(0, 1));
float t1 = fetchDepth(p + ivec2(0, 1));
float t2 = fetchDepth(p + ivec2(0, 2));
float dl = abs((2.0 * l1 - l2) - c0);
float dr = abs((2.0 * r1 - r2) - c0);
float db = abs((2.0 * b1 - b2) - c0);
float dt = abs((2.0 * t1 - t2) - c0);
vec3 ce = getViewPosition(uv, c0).xyz;
vec3 dpdx = (dl < dr) ? ce - getViewPosition((uv - vec2(1.0 / size.x, 0.0)), l1).xyz : -ce + getViewPosition((uv + vec2(1.0 / size.x, 0.0)), r1).xyz;
vec3 dpdy = (db < dt) ? ce - getViewPosition((uv - vec2(0.0, 1.0 / size.y)), b1).xyz : -ce + getViewPosition((uv + vec2(0.0, 1.0 / size.y)), t1).xyz;
return normalize(cross(dpdx, dpdy));
}
vec3 getViewNormal(const vec2 uv) {
#if NORMAL_VECTOR_TYPE == 2
return normalize(textureLod(tNormal, uv, 0.).rgb);
#elif NORMAL_VECTOR_TYPE == 1
return unpackRGBToNormal(textureLod(tNormal, uv, 0.).rgb);
#else
return computeNormalFromDepth(uv);
#endif
}
vec3 getSceneUvAndDepth(vec3 sampleViewPos) {
vec4 sampleClipPos = cameraProjectionMatrix * vec4(sampleViewPos, 1.);
vec2 sampleUv = sampleClipPos.xy / sampleClipPos.w * 0.5 + 0.5;
float sampleSceneDepth = getDepth(sampleUv);
return vec3(sampleUv, sampleSceneDepth);
}
void main() {
float depth = getDepth(vUv.xy);
if (depth >= 1.0) {
discard;
return;
}
vec3 viewPos = getViewPosition(vUv, depth);
vec3 viewNormal = getViewNormal(vUv);
float radiusToUse = radius;
float distanceFalloffToUse = thickness;
#if SCREEN_SPACE_RADIUS == 1
float radiusScale = getViewPosition(vec2(0.5 + float(SCREEN_SPACE_RADIUS_SCALE) / resolution.x, 0.0), depth).x;
radiusToUse *= radiusScale;
distanceFalloffToUse *= radiusScale;
#endif
#if SCENE_CLIP_BOX == 1
vec3 worldPos = (cameraWorldMatrix * vec4(viewPos, 1.0)).xyz;
float boxDistance = length(max(vec3(0.0), max(sceneBoxMin - worldPos, worldPos - sceneBoxMax)));
if (boxDistance > radiusToUse) {
discard;
return;
}
#endif
vec2 noiseResolution = vec2(textureSize(tNoise, 0));
vec2 noiseUv = vUv * resolution / noiseResolution;
vec4 noiseTexel = textureLod(tNoise, noiseUv, 0.0);
vec3 randomVec = noiseTexel.xyz * 2.0 - 1.0;
vec3 tangent = normalize(vec3(randomVec.xy, 0.));
vec3 bitangent = vec3(-tangent.y, tangent.x, 0.);
mat3 kernelMatrix = mat3(tangent, bitangent, vec3(0., 0., 1.));
const int DIRECTIONS = SAMPLES < 30 ? 3 : 5;
const int STEPS = (SAMPLES + DIRECTIONS - 1) / DIRECTIONS;
float ao = 0.0;
for (int i = 0; i < DIRECTIONS; ++i) {
float angle = float(i) / float(DIRECTIONS) * PI;
vec4 sampleDir = vec4(cos(angle), sin(angle), 0., 0.5 + 0.5 * noiseTexel.w);
sampleDir.xyz = normalize(kernelMatrix * sampleDir.xyz);
vec3 viewDir = normalize(-viewPos.xyz);
vec3 sliceBitangent = normalize(cross(sampleDir.xyz, viewDir));
vec3 sliceTangent = cross(sliceBitangent, viewDir);
vec3 normalInSlice = normalize(viewNormal - sliceBitangent * dot(viewNormal, sliceBitangent));
vec3 tangentToNormalInSlice = cross(normalInSlice, sliceBitangent);
vec2 cosHorizons = vec2(dot(viewDir, tangentToNormalInSlice), dot(viewDir, -tangentToNormalInSlice));
for (int j = 0; j < STEPS; ++j) {
vec3 sampleViewOffset = sampleDir.xyz * radiusToUse * sampleDir.w * pow(float(j + 1) / float(STEPS), distanceExponent);
vec3 sampleSceneUvDepth = getSceneUvAndDepth(viewPos + sampleViewOffset);
vec3 sampleSceneViewPos = getViewPosition(sampleSceneUvDepth.xy, sampleSceneUvDepth.z);
vec3 viewDelta = sampleSceneViewPos - viewPos;
if (abs(viewDelta.z) < thickness) {
float sampleCosHorizon = dot(viewDir, normalize(viewDelta));
cosHorizons.x += max(0., (sampleCosHorizon - cosHorizons.x) * mix(1., 2. / float(j + 2), distanceFallOff));
}
sampleSceneUvDepth = getSceneUvAndDepth(viewPos - sampleViewOffset);
sampleSceneViewPos = getViewPosition(sampleSceneUvDepth.xy, sampleSceneUvDepth.z);
viewDelta = sampleSceneViewPos - viewPos;
if (abs(viewDelta.z) < thickness) {
float sampleCosHorizon = dot(viewDir, normalize(viewDelta));
cosHorizons.y += max(0., (sampleCosHorizon - cosHorizons.y) * mix(1., 2. / float(j + 2), distanceFallOff));
}
}
vec2 sinHorizons = sqrt(1. - cosHorizons * cosHorizons);
float nx = dot(normalInSlice, sliceTangent);
float ny = dot(normalInSlice, viewDir);
float nxb = 1. / 2. * (acos(cosHorizons.y) - acos(cosHorizons.x) + sinHorizons.x * cosHorizons.x - sinHorizons.y * cosHorizons.y);
float nyb = 1. / 2. * (2. - cosHorizons.x * cosHorizons.x - cosHorizons.y * cosHorizons.y);
float occlusion = nx * nxb + ny * nyb;
ao += occlusion;
}
ao = clamp(ao / float(DIRECTIONS), 0., 1.);
#if SCENE_CLIP_BOX == 1
ao = mix(ao, 1., smoothstep(0., radiusToUse, boxDistance));
#endif
ao = pow(ao, scale);
gl_FragColor = FRAGMENT_OUTPUT;
}`},Ih={name:"GTAODepthShader",defines:{PERSPECTIVE_CAMERA:1},uniforms:{tDepth:{value:null},cameraNear:{value:null},cameraFar:{value:null}},vertexShader:`
varying vec2 vUv;
void main() {
vUv = uv;
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}`,fragmentShader:`
uniform sampler2D tDepth;
uniform float cameraNear;
uniform float cameraFar;
varying vec2 vUv;
#include <packing>
float getLinearDepth( const in vec2 screenPosition ) {
#if PERSPECTIVE_CAMERA == 1
float fragCoordZ = texture2D( tDepth, screenPosition ).x;
float viewZ = perspectiveDepthToViewZ( fragCoordZ, cameraNear, cameraFar );
return viewZToOrthographicDepth( viewZ, cameraNear, cameraFar );
#else
return texture2D( tDepth, screenPosition ).x;
#endif
}
void main() {
float depth = getLinearDepth( vUv );
gl_FragColor = vec4( vec3( 1.0 - depth ), 1.0 );
}`},jp={name:"GTAOBlendShader",uniforms:{tDiffuse:{value:null},intensity:{value:1}},vertexShader:`
varying vec2 vUv;
void main() {
vUv = uv;
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}`,fragmentShader:`
uniform float intensity;
uniform sampler2D tDiffuse;
varying vec2 vUv;
void main() {
vec4 texel = texture2D( tDiffuse, vUv );
gl_FragColor = vec4(mix(vec3(1.), texel.rgb, intensity), texel.a);
}`};function lM(i=5){let e=Math.floor(i)%2===0?Math.floor(i)+1:Math.floor(i),t=NP(e),n=t.length,r=new Uint8Array(n*4);for(let o=0;o<n;++o){let a=t[o],c=2*Math.PI*a/n,l=new z(Math.cos(c),Math.sin(c),0).normalize();r[o*4]=(l.x*.5+.5)*255,r[o*4+1]=(l.y*.5+.5)*255,r[o*4+2]=127,r[o*4+3]=255}let s=new An(r,e,e);return s.wrapS=gn,s.wrapT=gn,s.needsUpdate=!0,s}function NP(i){let e=Math.floor(i)%2===0?Math.floor(i)+1:Math.floor(i),t=e*e,n=Array(t).fill(0),r=Math.floor(e/2),s=e-1;for(let o=1;o<=t;){if(r===-1&&s===e?(s=e-2,r=0):(s===e&&(s=0),r<0&&(r=e-1)),n[r*e+s]!==0){s-=2,r++;continue}else n[r*e+s]=o++;s++,r--}return n}var Nh={name:"PoissonDenoiseShader",defines:{SAMPLES:16,SAMPLE_VECTORS:Fx(16,2,1),NORMAL_VECTOR_TYPE:1,DEPTH_VALUE_SOURCE:0},uniforms:{tDiffuse:{value:null},tNormal:{value:null},tDepth:{value:null},tNoise:{value:null},resolution:{value:new Me},cameraProjectionMatrixInverse:{value:new nt},lumaPhi:{value:5},depthPhi:{value:5},normalPhi:{value:5},radius:{value:4},index:{value:0}},vertexShader:`
varying vec2 vUv;
void main() {
vUv = uv;
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}`,fragmentShader:`
varying vec2 vUv;
uniform sampler2D tDiffuse;
uniform sampler2D tNormal;
uniform sampler2D tDepth;
uniform sampler2D tNoise;
uniform vec2 resolution;
uniform mat4 cameraProjectionMatrixInverse;
uniform float lumaPhi;
uniform float depthPhi;
uniform float normalPhi;
uniform float radius;
uniform int index;
#include <common>
#include <packing>
#ifndef SAMPLE_LUMINANCE
#define SAMPLE_LUMINANCE dot(vec3(0.2125, 0.7154, 0.0721), a)
#endif
#ifndef FRAGMENT_OUTPUT
#define FRAGMENT_OUTPUT vec4(denoised, 1.)
#endif
float getLuminance(const in vec3 a) {
return SAMPLE_LUMINANCE;
}
const vec3 poissonDisk[SAMPLES] = SAMPLE_VECTORS;
vec3 getViewPosition(const in vec2 screenPosition, const in float depth) {
vec4 clipSpacePosition = vec4(vec3(screenPosition, depth) * 2.0 - 1.0, 1.0);
vec4 viewSpacePosition = cameraProjectionMatrixInverse * clipSpacePosition;
return viewSpacePosition.xyz / viewSpacePosition.w;
}
float getDepth(const vec2 uv) {
#if DEPTH_VALUE_SOURCE == 1
return textureLod(tDepth, uv.xy, 0.0).a;
#else
return textureLod(tDepth, uv.xy, 0.0).r;
#endif
}
float fetchDepth(const ivec2 uv) {
#if DEPTH_VALUE_SOURCE == 1
return texelFetch(tDepth, uv.xy, 0).a;
#else
return texelFetch(tDepth, uv.xy, 0).r;
#endif
}
vec3 computeNormalFromDepth(const vec2 uv) {
vec2 size = vec2(textureSize(tDepth, 0));
ivec2 p = ivec2(uv * size);
float c0 = fetchDepth(p);
float l2 = fetchDepth(p - ivec2(2, 0));
float l1 = fetchDepth(p - ivec2(1, 0));
float r1 = fetchDepth(p + ivec2(1, 0));
float r2 = fetchDepth(p + ivec2(2, 0));
float b2 = fetchDepth(p - ivec2(0, 2));
float b1 = fetchDepth(p - ivec2(0, 1));
float t1 = fetchDepth(p + ivec2(0, 1));
float t2 = fetchDepth(p + ivec2(0, 2));
float dl = abs((2.0 * l1 - l2) - c0);
float dr = abs((2.0 * r1 - r2) - c0);
float db = abs((2.0 * b1 - b2) - c0);
float dt = abs((2.0 * t1 - t2) - c0);
vec3 ce = getViewPosition(uv, c0).xyz;
vec3 dpdx = (dl < dr) ? ce - getViewPosition((uv - vec2(1.0 / size.x, 0.0)), l1).xyz
: -ce + getViewPosition((uv + vec2(1.0 / size.x, 0.0)), r1).xyz;
vec3 dpdy = (db < dt) ? ce - getViewPosition((uv - vec2(0.0, 1.0 / size.y)), b1).xyz
: -ce + getViewPosition((uv + vec2(0.0, 1.0 / size.y)), t1).xyz;
return normalize(cross(dpdx, dpdy));
}
vec3 getViewNormal(const vec2 uv) {
#if NORMAL_VECTOR_TYPE == 2
return normalize(textureLod(tNormal, uv, 0.).rgb);
#elif NORMAL_VECTOR_TYPE == 1
return unpackRGBToNormal(textureLod(tNormal, uv, 0.).rgb);
#else
return computeNormalFromDepth(uv);
#endif
}
void denoiseSample(in vec3 center, in vec3 viewNormal, in vec3 viewPos, in vec2 sampleUv, inout vec3 denoised, inout float totalWeight) {
vec4 sampleTexel = textureLod(tDiffuse, sampleUv, 0.0);
float sampleDepth = getDepth(sampleUv);
vec3 sampleNormal = getViewNormal(sampleUv);
vec3 neighborColor = sampleTexel.rgb;
vec3 viewPosSample = getViewPosition(sampleUv, sampleDepth);
float normalDiff = dot(viewNormal, sampleNormal);
float normalSimilarity = pow(max(normalDiff, 0.), normalPhi);
float lumaDiff = abs(getLuminance(neighborColor) - getLuminance(center));
float lumaSimilarity = max(1.0 - lumaDiff / lumaPhi, 0.0);
float depthDiff = abs(dot(viewPos - viewPosSample, viewNormal));
float depthSimilarity = max(1. - depthDiff / depthPhi, 0.);
float w = lumaSimilarity * depthSimilarity * normalSimilarity;
denoised += w * neighborColor;
totalWeight += w;
}
void main() {
float depth = getDepth(vUv.xy);
vec3 viewNormal = getViewNormal(vUv);
if (depth == 1. || dot(viewNormal, viewNormal) == 0.) {
discard;
return;
}
vec4 texel = textureLod(tDiffuse, vUv, 0.0);
vec3 center = texel.rgb;
vec3 viewPos = getViewPosition(vUv, depth);
vec2 noiseResolution = vec2(textureSize(tNoise, 0));
vec2 noiseUv = vUv * resolution / noiseResolution;
vec4 noiseTexel = textureLod(tNoise, noiseUv, 0.0);
vec2 noiseVec = vec2(sin(noiseTexel[index % 4] * 2. * PI), cos(noiseTexel[index % 4] * 2. * PI));
mat2 rotationMatrix = mat2(noiseVec.x, -noiseVec.y, noiseVec.x, noiseVec.y);
float totalWeight = 1.0;
vec3 denoised = texel.rgb;
for (int i = 0; i < SAMPLES; i++) {
vec3 sampleDir = poissonDisk[i];
vec2 offset = rotationMatrix * (sampleDir.xy * (1. + sampleDir.z * (radius - 1.)) / resolution);
vec2 sampleUv = vUv + offset;
denoiseSample(center, viewNormal, viewPos, sampleUv, denoised, totalWeight);
}
if (totalWeight > 0.) {
denoised /= totalWeight;
}
gl_FragColor = FRAGMENT_OUTPUT;
}`};function Fx(i,e,t){let n=LP(i,e,t),r="vec3[SAMPLES](";for(let s=0;s<i;s++){let o=n[s];r+=`vec3(${o.x}, ${o.y}, ${o.z})${s<i-1?",":")"}`}return r}function LP(i,e,t){let n=[];for(let r=0;r<i;r++){let s=2*Math.PI*e*r/i,o=Math.pow(r/(i-1),t);n.push(new z(Math.cos(s),Math.sin(s),o))}return n}var qp=class{constructor(e=Math){this.grad3=[[1,1,0],[-1,1,0],[1,-1,0],[-1,-1,0],[1,0,1],[-1,0,1],[1,0,-1],[-1,0,-1],[0,1,1],[0,-1,1],[0,1,-1],[0,-1,-1]],this.grad4=[[0,1,1,1],[0,1,1,-1],[0,1,-1,1],[0,1,-1,-1],[0,-1,1,1],[0,-1,1,-1],[0,-1,-1,1],[0,-1,-1,-1],[1,0,1,1],[1,0,1,-1],[1,0,-1,1],[1,0,-1,-1],[-1,0,1,1],[-1,0,1,-1],[-1,0,-1,1],[-1,0,-1,-1],[1,1,0,1],[1,1,0,-1],[1,-1,0,1],[1,-1,0,-1],[-1,1,0,1],[-1,1,0,-1],[-1,-1,0,1],[-1,-1,0,-1],[1,1,1,0],[1,1,-1,0],[1,-1,1,0],[1,-1,-1,0],[-1,1,1,0],[-1,1,-1,0],[-1,-1,1,0],[-1,-1,-1,0]],this.p=[];for(let t=0;t<256;t++)this.p[t]=Math.floor(e.random()*256);this.perm=[];for(let t=0;t<512;t++)this.perm[t]=this.p[t&255];this.simplex=[[0,1,2,3],[0,1,3,2],[0,0,0,0],[0,2,3,1],[0,0,0,0],[0,0,0,0],[0,0,0,0],[1,2,3,0],[0,2,1,3],[0,0,0,0],[0,3,1,2],[0,3,2,1],[0,0,0,0],[0,0,0,0],[0,0,0,0],[1,3,2,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[1,2,0,3],[0,0,0,0],[1,3,0,2],[0,0,0,0],[0,0,0,0],[0,0,0,0],[2,3,0,1],[2,3,1,0],[1,0,2,3],[1,0,3,2],[0,0,0,0],[0,0,0,0],[0,0,0,0],[2,0,3,1],[0,0,0,0],[2,1,3,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[2,0,1,3],[0,0,0,0],[0,0,0,0],[0,0,0,0],[3,0,1,2],[3,0,2,1],[0,0,0,0],[3,1,2,0],[2,1,0,3],[0,0,0,0],[0,0,0,0],[0,0,0,0],[3,1,0,2],[0,0,0,0],[3,2,0,1],[3,2,1,0]]}dot(e,t,n){return e[0]*t+e[1]*n}dot3(e,t,n,r){return e[0]*t+e[1]*n+e[2]*r}dot4(e,t,n,r,s){return e[0]*t+e[1]*n+e[2]*r+e[3]*s}noise(e,t){let n,r,s,o=.5*(Math.sqrt(3)-1),a=(e+t)*o,c=Math.floor(e+a),l=Math.floor(t+a),u=(3-Math.sqrt(3))/6,h=(c+l)*u,d=c-h,m=l-h,g=e-d,x=t-m,f,p;g>x?(f=1,p=0):(f=0,p=1);let v=g-f+u,_=x-p+u,y=g-1+2*u,b=x-1+2*u,E=c&255,A=l&255,T=this.perm[E+this.perm[A]]%12,M=this.perm[E+f+this.perm[A+p]]%12,S=this.perm[E+1+this.perm[A+1]]%12,C=.5-g*g-x*x;C<0?n=0:(C*=C,n=C*C*this.dot(this.grad3[T],g,x));let N=.5-v*v-_*_;N<0?r=0:(N*=N,r=N*N*this.dot(this.grad3[M],v,_));let I=.5-y*y-b*b;return I<0?s=0:(I*=I,s=I*I*this.dot(this.grad3[S],y,b)),70*(n+r+s)}noise3d(e,t,n){let r,s,o,a,l=(e+t+n)*.3333333333333333,u=Math.floor(e+l),h=Math.floor(t+l),d=Math.floor(n+l),m=1/6,g=(u+h+d)*m,x=u-g,f=h-g,p=d-g,v=e-x,_=t-f,y=n-p,b,E,A,T,M,S;v>=_?_>=y?(b=1,E=0,A=0,T=1,M=1,S=0):v>=y?(b=1,E=0,A=0,T=1,M=0,S=1):(b=0,E=0,A=1,T=1,M=0,S=1):_<y?(b=0,E=0,A=1,T=0,M=1,S=1):v<y?(b=0,E=1,A=0,T=0,M=1,S=1):(b=0,E=1,A=0,T=1,M=1,S=0);let C=v-b+m,N=_-E+m,I=y-A+m,L=v-T+2*m,q=_-M+2*m,K=y-S+2*m,B=v-1+3*m,j=_-1+3*m,J=y-1+3*m,se=u&255,ce=h&255,me=d&255,Se=this.perm[se+this.perm[ce+this.perm[me]]]%12,V=this.perm[se+b+this.perm[ce+E+this.perm[me+A]]]%12,w=this.perm[se+T+this.perm[ce+M+this.perm[me+S]]]%12,O=this.perm[se+1+this.perm[ce+1+this.perm[me+1]]]%12,W=.6-v*v-_*_-y*y;W<0?r=0:(W*=W,r=W*W*this.dot3(this.grad3[Se],v,_,y));let Q=.6-C*C-N*N-I*I;Q<0?s=0:(Q*=Q,s=Q*Q*this.dot3(this.grad3[V],C,N,I));let ee=.6-L*L-q*q-K*K;ee<0?o=0:(ee*=ee,o=ee*ee*this.dot3(this.grad3[w],L,q,K));let he=.6-B*B-j*j-J*J;return he<0?a=0:(he*=he,a=he*he*this.dot3(this.grad3[O],B,j,J)),32*(r+s+o+a)}noise4d(e,t,n,r){let s=this.grad4,o=this.simplex,a=this.perm,c=(Math.sqrt(5)-1)/4,l=(5-Math.sqrt(5))/20,u,h,d,m,g,x=(e+t+n+r)*c,f=Math.floor(e+x),p=Math.floor(t+x),v=Math.floor(n+x),_=Math.floor(r+x),y=(f+p+v+_)*l,b=f-y,E=p-y,A=v-y,T=_-y,M=e-b,S=t-E,C=n-A,N=r-T,I=M>S?32:0,L=M>C?16:0,q=S>C?8:0,K=M>N?4:0,B=S>N?2:0,j=C>N?1:0,J=I+L+q+K+B+j,se=o[J][0]>=3?1:0,ce=o[J][1]>=3?1:0,me=o[J][2]>=3?1:0,Se=o[J][3]>=3?1:0,V=o[J][0]>=2?1:0,w=o[J][1]>=2?1:0,O=o[J][2]>=2?1:0,W=o[J][3]>=2?1:0,Q=o[J][0]>=1?1:0,ee=o[J][1]>=1?1:0,he=o[J][2]>=1?1:0,Ce=o[J][3]>=1?1:0,oe=M-se+l,ue=S-ce+l,H=C-me+l,Ie=N-Se+l,Te=M-V+2*l,Oe=S-w+2*l,Re=C-O+2*l,We=N-W+2*l,Ae=M-Q+3*l,Y=S-ee+3*l,F=C-he+3*l,D=N-Ce+3*l,P=M-1+4*l,U=S-1+4*l,X=C-1+4*l,Z=N-1+4*l,$=f&255,te=p&255,ae=v&255,re=_&255,ge=a[$+a[te+a[ae+a[re]]]]%32,xe=a[$+se+a[te+ce+a[ae+me+a[re+Se]]]]%32,Ne=a[$+V+a[te+w+a[ae+O+a[re+W]]]]%32,ke=a[$+Q+a[te+ee+a[ae+he+a[re+Ce]]]]%32,$e=a[$+1+a[te+1+a[ae+1+a[re+1]]]]%32,Le=.6-M*M-S*S-C*C-N*N;Le<0?u=0:(Le*=Le,u=Le*Le*this.dot4(s[ge],M,S,C,N));let Xe=.6-oe*oe-ue*ue-H*H-Ie*Ie;Xe<0?h=0:(Xe*=Xe,h=Xe*Xe*this.dot4(s[xe],oe,ue,H,Ie));let ne=.6-Te*Te-Oe*Oe-Re*Re-We*We;ne<0?d=0:(ne*=ne,d=ne*ne*this.dot4(s[Ne],Te,Oe,Re,We));let Pe=.6-Ae*Ae-Y*Y-F*F-D*D;Pe<0?m=0:(Pe*=Pe,m=Pe*Pe*this.dot4(s[ke],Ae,Y,F,D));let pe=.6-P*P-U*U-X*X-Z*Z;return pe<0?g=0:(pe*=pe,g=pe*pe*this.dot4(s[$e],P,U,X,Z)),27*(u+h+d+m+g)}};var Bc=class i extends li{constructor(e,t,n,r,s,o,a){super(),this.width=n!==void 0?n:512,this.height=r!==void 0?r:512,this.clear=!0,this.camera=t,this.scene=e,this.output=0,this._renderGBuffer=!0,this._visibilityCache=new Map,this.blendIntensity=1,this.pdRings=2,this.pdRadiusExponent=2,this.pdSamples=16,this.gtaoNoiseTexture=lM(),this.pdNoiseTexture=this.generateNoise(),this.gtaoRenderTarget=new on(this.width,this.height,{type:Hn}),this.pdRenderTarget=this.gtaoRenderTarget.clone(),this.gtaoMaterial=new $t({defines:Object.assign({},Ph.defines),uniforms:Gn.clone(Ph.uniforms),vertexShader:Ph.vertexShader,fragmentShader:Ph.fragmentShader,blending:yn,depthTest:!1,depthWrite:!1}),this.gtaoMaterial.defines.PERSPECTIVE_CAMERA=this.camera.isPerspectiveCamera?1:0,this.gtaoMaterial.uniforms.tNoise.value=this.gtaoNoiseTexture,this.gtaoMaterial.uniforms.resolution.value.set(this.width,this.height),this.gtaoMaterial.uniforms.cameraNear.value=this.camera.near,this.gtaoMaterial.uniforms.cameraFar.value=this.camera.far,this.normalMaterial=new Ho,this.normalMaterial.blending=yn,this.pdMaterial=new $t({defines:Object.assign({},Nh.defines),uniforms:Gn.clone(Nh.uniforms),vertexShader:Nh.vertexShader,fragmentShader:Nh.fragmentShader,depthTest:!1,depthWrite:!1}),this.pdMaterial.uniforms.tDiffuse.value=this.gtaoRenderTarget.texture,this.pdMaterial.uniforms.tNoise.value=this.pdNoiseTexture,this.pdMaterial.uniforms.resolution.value.set(this.width,this.height),this.pdMaterial.uniforms.lumaPhi.value=10,this.pdMaterial.uniforms.depthPhi.value=2,this.pdMaterial.uniforms.normalPhi.value=3,this.pdMaterial.uniforms.radius.value=8,this.depthRenderMaterial=new $t({defines:Object.assign({},Ih.defines),uniforms:Gn.clone(Ih.uniforms),vertexShader:Ih.vertexShader,fragmentShader:Ih.fragmentShader,blending:yn}),this.depthRenderMaterial.uniforms.cameraNear.value=this.camera.near,this.depthRenderMaterial.uniforms.cameraFar.value=this.camera.far,this.copyMaterial=new $t({uniforms:Gn.clone(kc.uniforms),vertexShader:kc.vertexShader,fragmentShader:kc.fragmentShader,transparent:!0,depthTest:!1,depthWrite:!1,blendSrc:yc,blendDst:Ks,blendEquation:xi,blendSrcAlpha:xc,blendDstAlpha:Ks,blendEquationAlpha:xi}),this.blendMaterial=new $t({uniforms:Gn.clone(jp.uniforms),vertexShader:jp.vertexShader,fragmentShader:jp.fragmentShader,transparent:!0,depthTest:!1,depthWrite:!1,blending:Au,blendSrc:yc,blendDst:Ks,blendEquation:xi,blendSrcAlpha:xc,blendDstAlpha:Ks,blendEquationAlpha:xi}),this.fsQuad=new Fr(null),this.originalClearColor=new Ue,this.setGBuffer(s?s.depthTexture:void 0,s?s.normalTexture:void 0),o!==void 0&&this.updateGtaoMaterial(o),a!==void 0&&this.updatePdMaterial(a)}dispose(){this.gtaoNoiseTexture.dispose(),this.pdNoiseTexture.dispose(),this.normalRenderTarget.dispose(),this.gtaoRenderTarget.dispose(),this.pdRenderTarget.dispose(),this.normalMaterial.dispose(),this.pdMaterial.dispose(),this.copyMaterial.dispose(),this.depthRenderMaterial.dispose(),this.fsQuad.dispose()}get gtaoMap(){return this.pdRenderTarget.texture}setGBuffer(e,t){e!==void 0?(this.depthTexture=e,this.normalTexture=t,this._renderGBuffer=!1):(this.depthTexture=new Xs,this.depthTexture.format=Mr,this.depthTexture.type=Or,this.normalRenderTarget=new on(this.width,this.height,{minFilter:Jt,magFilter:Jt,type:Hn,depthTexture:this.depthTexture}),this.normalTexture=this.normalRenderTarget.texture,this._renderGBuffer=!0);let n=this.normalTexture?1:0,r=this.depthTexture===this.normalTexture?"w":"x";this.gtaoMaterial.defines.NORMAL_VECTOR_TYPE=n,this.gtaoMaterial.defines.DEPTH_SWIZZLING=r,this.gtaoMaterial.uniforms.tNormal.value=this.normalTexture,this.gtaoMaterial.uniforms.tDepth.value=this.depthTexture,this.pdMaterial.defines.NORMAL_VECTOR_TYPE=n,this.pdMaterial.defines.DEPTH_SWIZZLING=r,this.pdMaterial.uniforms.tNormal.value=this.normalTexture,this.pdMaterial.uniforms.tDepth.value=this.depthTexture,this.depthRenderMaterial.uniforms.tDepth.value=this.normalRenderTarget.depthTexture}setSceneClipBox(e){e?(this.gtaoMaterial.needsUpdate=this.gtaoMaterial.defines.SCENE_CLIP_BOX!==1,this.gtaoMaterial.defines.SCENE_CLIP_BOX=1,this.gtaoMaterial.uniforms.sceneBoxMin.value.copy(e.min),this.gtaoMaterial.uniforms.sceneBoxMax.value.copy(e.max)):(this.gtaoMaterial.needsUpdate=this.gtaoMaterial.defines.SCENE_CLIP_BOX===0,this.gtaoMaterial.defines.SCENE_CLIP_BOX=0)}updateGtaoMaterial(e){e.radius!==void 0&&(this.gtaoMaterial.uniforms.radius.value=e.radius),e.distanceExponent!==void 0&&(this.gtaoMaterial.uniforms.distanceExponent.value=e.distanceExponent),e.thickness!==void 0&&(this.gtaoMaterial.uniforms.thickness.value=e.thickness),e.distanceFallOff!==void 0&&(this.gtaoMaterial.uniforms.distanceFallOff.value=e.distanceFallOff,this.gtaoMaterial.needsUpdate=!0),e.scale!==void 0&&(this.gtaoMaterial.uniforms.scale.value=e.scale),e.samples!==void 0&&e.samples!==this.gtaoMaterial.defines.SAMPLES&&(this.gtaoMaterial.defines.SAMPLES=e.samples,this.gtaoMaterial.needsUpdate=!0),e.screenSpaceRadius!==void 0&&(e.screenSpaceRadius?1:0)!==this.gtaoMaterial.defines.SCREEN_SPACE_RADIUS&&(this.gtaoMaterial.defines.SCREEN_SPACE_RADIUS=e.screenSpaceRadius?1:0,this.gtaoMaterial.needsUpdate=!0)}updatePdMaterial(e){let t=!1;e.lumaPhi!==void 0&&(this.pdMaterial.uniforms.lumaPhi.value=e.lumaPhi),e.depthPhi!==void 0&&(this.pdMaterial.uniforms.depthPhi.value=e.depthPhi),e.normalPhi!==void 0&&(this.pdMaterial.uniforms.normalPhi.value=e.normalPhi),e.radius!==void 0&&e.radius!==this.radius&&(this.pdMaterial.uniforms.radius.value=e.radius),e.radiusExponent!==void 0&&e.radiusExponent!==this.pdRadiusExponent&&(this.pdRadiusExponent=e.radiusExponent,t=!0),e.rings!==void 0&&e.rings!==this.pdRings&&(this.pdRings=e.rings,t=!0),e.samples!==void 0&&e.samples!==this.pdSamples&&(this.pdSamples=e.samples,t=!0),t&&(this.pdMaterial.defines.SAMPLES=this.pdSamples,this.pdMaterial.defines.SAMPLE_VECTORS=Fx(this.pdSamples,this.pdRings,this.pdRadiusExponent),this.pdMaterial.needsUpdate=!0)}render(e,t,n){switch(this._renderGBuffer&&(this.overrideVisibility(),this.renderOverride(e,this.normalMaterial,this.normalRenderTarget,7829503,1),this.restoreVisibility()),this.gtaoMaterial.uniforms.cameraNear.value=this.camera.near,this.gtaoMaterial.uniforms.cameraFar.value=this.camera.far,this.gtaoMaterial.uniforms.cameraProjectionMatrix.value.copy(this.camera.projectionMatrix),this.gtaoMaterial.uniforms.cameraProjectionMatrixInverse.value.copy(this.camera.projectionMatrixInverse),this.gtaoMaterial.uniforms.cameraWorldMatrix.value.copy(this.camera.matrixWorld),this.renderPass(e,this.gtaoMaterial,this.gtaoRenderTarget,16777215,1),this.pdMaterial.uniforms.cameraProjectionMatrixInverse.value.copy(this.camera.projectionMatrixInverse),this.renderPass(e,this.pdMaterial,this.pdRenderTarget,16777215,1),this.output){case i.OUTPUT.Off:break;case i.OUTPUT.Diffuse:this.copyMaterial.uniforms.tDiffuse.value=n.texture,this.copyMaterial.blending=yn,this.renderPass(e,this.copyMaterial,this.renderToScreen?null:t);break;case i.OUTPUT.AO:this.copyMaterial.uniforms.tDiffuse.value=this.gtaoRenderTarget.texture,this.copyMaterial.blending=yn,this.renderPass(e,this.copyMaterial,this.renderToScreen?null:t);break;case i.OUTPUT.Denoise:this.copyMaterial.uniforms.tDiffuse.value=this.pdRenderTarget.texture,this.copyMaterial.blending=yn,this.renderPass(e,this.copyMaterial,this.renderToScreen?null:t);break;case i.OUTPUT.Depth:this.depthRenderMaterial.uniforms.cameraNear.value=this.camera.near,this.depthRenderMaterial.uniforms.cameraFar.value=this.camera.far,this.renderPass(e,this.depthRenderMaterial,this.renderToScreen?null:t);break;case i.OUTPUT.Normal:this.copyMaterial.uniforms.tDiffuse.value=this.normalRenderTarget.texture,this.copyMaterial.blending=yn,this.renderPass(e,this.copyMaterial,this.renderToScreen?null:t);break;case i.OUTPUT.Default:this.copyMaterial.uniforms.tDiffuse.value=n.texture,this.copyMaterial.blending=yn,this.renderPass(e,this.copyMaterial,this.renderToScreen?null:t),this.blendMaterial.uniforms.intensity.value=this.blendIntensity,this.blendMaterial.uniforms.tDiffuse.value=this.pdRenderTarget.texture,this.renderPass(e,this.blendMaterial,this.renderToScreen?null:t);break;default:console.warn("THREE.GTAOPass: Unknown output type.")}}renderPass(e,t,n,r,s){e.getClearColor(this.originalClearColor);let o=e.getClearAlpha(),a=e.autoClear;e.setRenderTarget(n),e.autoClear=!1,r!=null&&(e.setClearColor(r),e.setClearAlpha(s||0),e.clear()),this.fsQuad.material=t,this.fsQuad.render(e),e.autoClear=a,e.setClearColor(this.originalClearColor),e.setClearAlpha(o)}renderOverride(e,t,n,r,s){e.getClearColor(this.originalClearColor);let o=e.getClearAlpha(),a=e.autoClear;e.setRenderTarget(n),e.autoClear=!1,r=t.clearColor||r,s=t.clearAlpha||s,r!=null&&(e.setClearColor(r),e.setClearAlpha(s||0),e.clear()),this.scene.overrideMaterial=t,e.render(this.scene,this.camera),this.scene.overrideMaterial=null,e.autoClear=a,e.setClearColor(this.originalClearColor),e.setClearAlpha(o)}setSize(e,t){this.width=e,this.height=t,this.gtaoRenderTarget.setSize(e,t),this.normalRenderTarget.setSize(e,t),this.pdRenderTarget.setSize(e,t),this.gtaoMaterial.uniforms.resolution.value.set(e,t),this.gtaoMaterial.uniforms.cameraProjectionMatrix.value.copy(this.camera.projectionMatrix),this.gtaoMaterial.uniforms.cameraProjectionMatrixInverse.value.copy(this.camera.projectionMatrixInverse),this.pdMaterial.uniforms.resolution.value.set(e,t),this.pdMaterial.uniforms.cameraProjectionMatrixInverse.value.copy(this.camera.projectionMatrixInverse)}overrideVisibility(){let e=this.scene,t=this._visibilityCache;e.traverse(function(n){t.set(n,n.visible),(n.isPoints||n.isLine)&&(n.visible=!1)})}restoreVisibility(){let e=this.scene,t=this._visibilityCache;e.traverse(function(n){let r=t.get(n);n.visible=r}),t.clear()}generateNoise(e=64){let t=new qp,n=e*e*4,r=new Uint8Array(n);for(let o=0;o<e;o++)for(let a=0;a<e;a++){let c=o,l=a;r[(o*e+a)*4]=(t.noise(c,l)*.5+.5)*255,r[(o*e+a)*4+1]=(t.noise(c+e,l)*.5+.5)*255,r[(o*e+a)*4+2]=(t.noise(c,l+e)*.5+.5)*255,r[(o*e+a)*4+3]=(t.noise(c+e,l+e)*.5+.5)*255}let s=new An(r,e,e,Ln,ci);return s.wrapS=gn,s.wrapT=gn,s.needsUpdate=!0,s}};Bc.OUTPUT={Off:-1,Default:0,Diffuse:1,Depth:2,Normal:3,AO:4,Denoise:5};var uM={name:"OutputShader",uniforms:{tDiffuse:{value:null},toneMappingExposure:{value:1}},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;
#include <tonemapping_pars_fragment>
#include <colorspace_pars_fragment>
varying vec2 vUv;
void main() {
gl_FragColor = texture2D( tDiffuse, vUv );
// tone mapping
#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 );
#endif
// color space
#ifdef SRGB_TRANSFER
gl_FragColor = sRGBTransferOETF( gl_FragColor );
#endif
}`};var Kp=class extends li{constructor(){super();let e=uM;this.uniforms=Gn.clone(e.uniforms),this.material=new zo({name:e.name,uniforms:this.uniforms,vertexShader:e.vertexShader,fragmentShader:e.fragmentShader}),this.fsQuad=new Fr(this.material),this._outputColorSpace=null,this._toneMapping=null}render(e,t,n){this.uniforms.tDiffuse.value=n.texture,this.uniforms.toneMappingExposure.value=e.toneMappingExposure,(this._outputColorSpace!==e.outputColorSpace||this._toneMapping!==e.toneMapping)&&(this._outputColorSpace=e.outputColorSpace,this._toneMapping=e.toneMapping,this.material.defines={},_t.getTransfer(this._outputColorSpace)===kt&&(this.material.defines.SRGB_TRANSFER=""),this._toneMapping===Ou?this.material.defines.LINEAR_TONE_MAPPING="":this._toneMapping===Du?this.material.defines.REINHARD_TONE_MAPPING="":this._toneMapping===Fu?this.material.defines.CINEON_TONE_MAPPING="":this._toneMapping===jo?this.material.defines.ACES_FILMIC_TONE_MAPPING="":this._toneMapping===Uu?this.material.defines.AGX_TONE_MAPPING="":this._toneMapping===ku&&(this.material.defines.NEUTRAL_TONE_MAPPING=""),this.material.needsUpdate=!0),this.renderToScreen===!0?(e.setRenderTarget(null),this.fsQuad.render(e)):(e.setRenderTarget(t),this.clear&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),this.fsQuad.render(e))}dispose(){this.material.dispose(),this.fsQuad.dispose()}};var Lh={name:"SMAAEdgesShader",defines:{SMAA_THRESHOLD:"0.1"},uniforms:{tDiffuse:{value:null},resolution:{value:new Me(1/1024,1/512)}},vertexShader:`
uniform vec2 resolution;
varying vec2 vUv;
varying vec4 vOffset[ 3 ];
void SMAAEdgeDetectionVS( vec2 texcoord ) {
vOffset[ 0 ] = texcoord.xyxy + resolution.xyxy * vec4( -1.0, 0.0, 0.0, 1.0 ); // WebGL port note: Changed sign in W component
vOffset[ 1 ] = texcoord.xyxy + resolution.xyxy * vec4( 1.0, 0.0, 0.0, -1.0 ); // WebGL port note: Changed sign in W component
vOffset[ 2 ] = texcoord.xyxy + resolution.xyxy * vec4( -2.0, 0.0, 0.0, 2.0 ); // WebGL port note: Changed sign in W component
}
void main() {
vUv = uv;
SMAAEdgeDetectionVS( vUv );
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}`,fragmentShader:`
uniform sampler2D tDiffuse;
varying vec2 vUv;
varying vec4 vOffset[ 3 ];
vec4 SMAAColorEdgeDetectionPS( vec2 texcoord, vec4 offset[3], sampler2D colorTex ) {
vec2 threshold = vec2( SMAA_THRESHOLD, SMAA_THRESHOLD );
// Calculate color deltas:
vec4 delta;
vec3 C = texture2D( colorTex, texcoord ).rgb;
vec3 Cleft = texture2D( colorTex, offset[0].xy ).rgb;
vec3 t = abs( C - Cleft );
delta.x = max( max( t.r, t.g ), t.b );
vec3 Ctop = texture2D( colorTex, offset[0].zw ).rgb;
t = abs( C - Ctop );
delta.y = max( max( t.r, t.g ), t.b );
// We do the usual threshold:
vec2 edges = step( threshold, delta.xy );
// Then discard if there is no edge:
if ( dot( edges, vec2( 1.0, 1.0 ) ) == 0.0 )
discard;
// Calculate right and bottom deltas:
vec3 Cright = texture2D( colorTex, offset[1].xy ).rgb;
t = abs( C - Cright );
delta.z = max( max( t.r, t.g ), t.b );
vec3 Cbottom = texture2D( colorTex, offset[1].zw ).rgb;
t = abs( C - Cbottom );
delta.w = max( max( t.r, t.g ), t.b );
// Calculate the maximum delta in the direct neighborhood:
float maxDelta = max( max( max( delta.x, delta.y ), delta.z ), delta.w );
// Calculate left-left and top-top deltas:
vec3 Cleftleft = texture2D( colorTex, offset[2].xy ).rgb;
t = abs( C - Cleftleft );
delta.z = max( max( t.r, t.g ), t.b );
vec3 Ctoptop = texture2D( colorTex, offset[2].zw ).rgb;
t = abs( C - Ctoptop );
delta.w = max( max( t.r, t.g ), t.b );
// Calculate the final maximum delta:
maxDelta = max( max( maxDelta, delta.z ), delta.w );
// Local contrast adaptation in action:
edges.xy *= step( 0.5 * maxDelta, delta.xy );
return vec4( edges, 0.0, 0.0 );
}
void main() {
gl_FragColor = SMAAColorEdgeDetectionPS( vUv, vOffset, tDiffuse );
}`},Oh={name:"SMAAWeightsShader",defines:{SMAA_MAX_SEARCH_STEPS:"8",SMAA_AREATEX_MAX_DISTANCE:"16",SMAA_AREATEX_PIXEL_SIZE:"( 1.0 / vec2( 160.0, 560.0 ) )",SMAA_AREATEX_SUBTEX_SIZE:"( 1.0 / 7.0 )"},uniforms:{tDiffuse:{value:null},tArea:{value:null},tSearch:{value:null},resolution:{value:new Me(1/1024,1/512)}},vertexShader:`
uniform vec2 resolution;
varying vec2 vUv;
varying vec4 vOffset[ 3 ];
varying vec2 vPixcoord;
void SMAABlendingWeightCalculationVS( vec2 texcoord ) {
vPixcoord = texcoord / resolution;
// We will use these offsets for the searches later on (see @PSEUDO_GATHER4):
vOffset[ 0 ] = texcoord.xyxy + resolution.xyxy * vec4( -0.25, 0.125, 1.25, 0.125 ); // WebGL port note: Changed sign in Y and W components
vOffset[ 1 ] = texcoord.xyxy + resolution.xyxy * vec4( -0.125, 0.25, -0.125, -1.25 ); // WebGL port note: Changed sign in Y and W components
// And these for the searches, they indicate the ends of the loops:
vOffset[ 2 ] = vec4( vOffset[ 0 ].xz, vOffset[ 1 ].yw ) + vec4( -2.0, 2.0, -2.0, 2.0 ) * resolution.xxyy * float( SMAA_MAX_SEARCH_STEPS );
}
void main() {
vUv = uv;
SMAABlendingWeightCalculationVS( vUv );
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}`,fragmentShader:`
#define SMAASampleLevelZeroOffset( tex, coord, offset ) texture2D( tex, coord + float( offset ) * resolution, 0.0 )
uniform sampler2D tDiffuse;
uniform sampler2D tArea;
uniform sampler2D tSearch;
uniform vec2 resolution;
varying vec2 vUv;
varying vec4 vOffset[3];
varying vec2 vPixcoord;
#if __VERSION__ == 100
vec2 round( vec2 x ) {
return sign( x ) * floor( abs( x ) + 0.5 );
}
#endif
float SMAASearchLength( sampler2D searchTex, vec2 e, float bias, float scale ) {
// Not required if searchTex accesses are set to point:
// float2 SEARCH_TEX_PIXEL_SIZE = 1.0 / float2(66.0, 33.0);
// e = float2(bias, 0.0) + 0.5 * SEARCH_TEX_PIXEL_SIZE +
// e * float2(scale, 1.0) * float2(64.0, 32.0) * SEARCH_TEX_PIXEL_SIZE;
e.r = bias + e.r * scale;
return 255.0 * texture2D( searchTex, e, 0.0 ).r;
}
float SMAASearchXLeft( sampler2D edgesTex, sampler2D searchTex, vec2 texcoord, float end ) {
/**
* @PSEUDO_GATHER4
* This texcoord has been offset by (-0.25, -0.125) in the vertex shader to
* sample between edge, thus fetching four edges in a row.
* Sampling with different offsets in each direction allows to disambiguate
* which edges are active from the four fetched ones.
*/
vec2 e = vec2( 0.0, 1.0 );
for ( int i = 0; i < SMAA_MAX_SEARCH_STEPS; i ++ ) { // WebGL port note: Changed while to for
e = texture2D( edgesTex, texcoord, 0.0 ).rg;
texcoord -= vec2( 2.0, 0.0 ) * resolution;
if ( ! ( texcoord.x > end && e.g > 0.8281 && e.r == 0.0 ) ) break;
}
// We correct the previous (-0.25, -0.125) offset we applied:
texcoord.x += 0.25 * resolution.x;
// The searches are bias by 1, so adjust the coords accordingly:
texcoord.x += resolution.x;
// Disambiguate the length added by the last step:
texcoord.x += 2.0 * resolution.x; // Undo last step
texcoord.x -= resolution.x * SMAASearchLength(searchTex, e, 0.0, 0.5);
return texcoord.x;
}
float SMAASearchXRight( sampler2D edgesTex, sampler2D searchTex, vec2 texcoord, float end ) {
vec2 e = vec2( 0.0, 1.0 );
for ( int i = 0; i < SMAA_MAX_SEARCH_STEPS; i ++ ) { // WebGL port note: Changed while to for
e = texture2D( edgesTex, texcoord, 0.0 ).rg;
texcoord += vec2( 2.0, 0.0 ) * resolution;
if ( ! ( texcoord.x < end && e.g > 0.8281 && e.r == 0.0 ) ) break;
}
texcoord.x -= 0.25 * resolution.x;
texcoord.x -= resolution.x;
texcoord.x -= 2.0 * resolution.x;
texcoord.x += resolution.x * SMAASearchLength( searchTex, e, 0.5, 0.5 );
return texcoord.x;
}
float SMAASearchYUp( sampler2D edgesTex, sampler2D searchTex, vec2 texcoord, float end ) {
vec2 e = vec2( 1.0, 0.0 );
for ( int i = 0; i < SMAA_MAX_SEARCH_STEPS; i ++ ) { // WebGL port note: Changed while to for
e = texture2D( edgesTex, texcoord, 0.0 ).rg;
texcoord += vec2( 0.0, 2.0 ) * resolution; // WebGL port note: Changed sign
if ( ! ( texcoord.y > end && e.r > 0.8281 && e.g == 0.0 ) ) break;
}
texcoord.y -= 0.25 * resolution.y; // WebGL port note: Changed sign
texcoord.y -= resolution.y; // WebGL port note: Changed sign
texcoord.y -= 2.0 * resolution.y; // WebGL port note: Changed sign
texcoord.y += resolution.y * SMAASearchLength( searchTex, e.gr, 0.0, 0.5 ); // WebGL port note: Changed sign
return texcoord.y;
}
float SMAASearchYDown( sampler2D edgesTex, sampler2D searchTex, vec2 texcoord, float end ) {
vec2 e = vec2( 1.0, 0.0 );
for ( int i = 0; i < SMAA_MAX_SEARCH_STEPS; i ++ ) { // WebGL port note: Changed while to for
e = texture2D( edgesTex, texcoord, 0.0 ).rg;
texcoord -= vec2( 0.0, 2.0 ) * resolution; // WebGL port note: Changed sign
if ( ! ( texcoord.y < end && e.r > 0.8281 && e.g == 0.0 ) ) break;
}
texcoord.y += 0.25 * resolution.y; // WebGL port note: Changed sign
texcoord.y += resolution.y; // WebGL port note: Changed sign
texcoord.y += 2.0 * resolution.y; // WebGL port note: Changed sign
texcoord.y -= resolution.y * SMAASearchLength( searchTex, e.gr, 0.5, 0.5 ); // WebGL port note: Changed sign
return texcoord.y;
}
vec2 SMAAArea( sampler2D areaTex, vec2 dist, float e1, float e2, float offset ) {
// Rounding prevents precision errors of bilinear filtering:
vec2 texcoord = float( SMAA_AREATEX_MAX_DISTANCE ) * round( 4.0 * vec2( e1, e2 ) ) + dist;
// We do a scale and bias for mapping to texel space:
texcoord = SMAA_AREATEX_PIXEL_SIZE * texcoord + ( 0.5 * SMAA_AREATEX_PIXEL_SIZE );
// Move to proper place, according to the subpixel offset:
texcoord.y += SMAA_AREATEX_SUBTEX_SIZE * offset;
return texture2D( areaTex, texcoord, 0.0 ).rg;
}
vec4 SMAABlendingWeightCalculationPS( vec2 texcoord, vec2 pixcoord, vec4 offset[ 3 ], sampler2D edgesTex, sampler2D areaTex, sampler2D searchTex, ivec4 subsampleIndices ) {
vec4 weights = vec4( 0.0, 0.0, 0.0, 0.0 );
vec2 e = texture2D( edgesTex, texcoord ).rg;
if ( e.g > 0.0 ) { // Edge at north
vec2 d;
// Find the distance to the left:
vec2 coords;
coords.x = SMAASearchXLeft( edgesTex, searchTex, offset[ 0 ].xy, offset[ 2 ].x );
coords.y = offset[ 1 ].y; // offset[1].y = texcoord.y - 0.25 * resolution.y (@CROSSING_OFFSET)
d.x = coords.x;
// Now fetch the left crossing edges, two at a time using bilinear
// filtering. Sampling at -0.25 (see @CROSSING_OFFSET) enables to
// discern what value each edge has:
float e1 = texture2D( edgesTex, coords, 0.0 ).r;
// Find the distance to the right:
coords.x = SMAASearchXRight( edgesTex, searchTex, offset[ 0 ].zw, offset[ 2 ].y );
d.y = coords.x;
// We want the distances to be in pixel units (doing this here allow to
// better interleave arithmetic and memory accesses):
d = d / resolution.x - pixcoord.x;
// SMAAArea below needs a sqrt, as the areas texture is compressed
// quadratically:
vec2 sqrt_d = sqrt( abs( d ) );
// Fetch the right crossing edges:
coords.y -= 1.0 * resolution.y; // WebGL port note: Added
float e2 = SMAASampleLevelZeroOffset( edgesTex, coords, ivec2( 1, 0 ) ).r;
// Ok, we know how this pattern looks like, now it is time for getting
// the actual area:
weights.rg = SMAAArea( areaTex, sqrt_d, e1, e2, float( subsampleIndices.y ) );
}
if ( e.r > 0.0 ) { // Edge at west
vec2 d;
// Find the distance to the top:
vec2 coords;
coords.y = SMAASearchYUp( edgesTex, searchTex, offset[ 1 ].xy, offset[ 2 ].z );
coords.x = offset[ 0 ].x; // offset[1].x = texcoord.x - 0.25 * resolution.x;
d.x = coords.y;
// Fetch the top crossing edges:
float e1 = texture2D( edgesTex, coords, 0.0 ).g;
// Find the distance to the bottom:
coords.y = SMAASearchYDown( edgesTex, searchTex, offset[ 1 ].zw, offset[ 2 ].w );
d.y = coords.y;
// We want the distances to be in pixel units:
d = d / resolution.y - pixcoord.y;
// SMAAArea below needs a sqrt, as the areas texture is compressed
// quadratically:
vec2 sqrt_d = sqrt( abs( d ) );
// Fetch the bottom crossing edges:
coords.y -= 1.0 * resolution.y; // WebGL port note: Added
float e2 = SMAASampleLevelZeroOffset( edgesTex, coords, ivec2( 0, 1 ) ).g;
// Get the area for this direction:
weights.ba = SMAAArea( areaTex, sqrt_d, e1, e2, float( subsampleIndices.x ) );
}
return weights;
}
void main() {
gl_FragColor = SMAABlendingWeightCalculationPS( vUv, vPixcoord, vOffset, tDiffuse, tArea, tSearch, ivec4( 0.0 ) );
}`},Zp={name:"SMAABlendShader",uniforms:{tDiffuse:{value:null},tColor:{value:null},resolution:{value:new Me(1/1024,1/512)}},vertexShader:`
uniform vec2 resolution;
varying vec2 vUv;
varying vec4 vOffset[ 2 ];
void SMAANeighborhoodBlendingVS( vec2 texcoord ) {
vOffset[ 0 ] = texcoord.xyxy + resolution.xyxy * vec4( -1.0, 0.0, 0.0, 1.0 ); // WebGL port note: Changed sign in W component
vOffset[ 1 ] = texcoord.xyxy + resolution.xyxy * vec4( 1.0, 0.0, 0.0, -1.0 ); // WebGL port note: Changed sign in W component
}
void main() {
vUv = uv;
SMAANeighborhoodBlendingVS( vUv );
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}`,fragmentShader:`
uniform sampler2D tDiffuse;
uniform sampler2D tColor;
uniform vec2 resolution;
varying vec2 vUv;
varying vec4 vOffset[ 2 ];
vec4 SMAANeighborhoodBlendingPS( vec2 texcoord, vec4 offset[ 2 ], sampler2D colorTex, sampler2D blendTex ) {
// Fetch the blending weights for current pixel:
vec4 a;
a.xz = texture2D( blendTex, texcoord ).xz;
a.y = texture2D( blendTex, offset[ 1 ].zw ).g;
a.w = texture2D( blendTex, offset[ 1 ].xy ).a;
// Is there any blending weight with a value greater than 0.0?
if ( dot(a, vec4( 1.0, 1.0, 1.0, 1.0 )) < 1e-5 ) {
return texture2D( colorTex, texcoord, 0.0 );
} else {
// Up to 4 lines can be crossing a pixel (one through each edge). We
// favor blending by choosing the line with the maximum weight for each
// direction:
vec2 offset;
offset.x = a.a > a.b ? a.a : -a.b; // left vs. right
offset.y = a.g > a.r ? -a.g : a.r; // top vs. bottom // WebGL port note: Changed signs
// Then we go in the direction that has the maximum weight:
if ( abs( offset.x ) > abs( offset.y )) { // horizontal vs. vertical
offset.y = 0.0;
} else {
offset.x = 0.0;
}
// Fetch the opposite color and lerp by hand:
vec4 C = texture2D( colorTex, texcoord, 0.0 );
texcoord += sign( offset ) * resolution;
vec4 Cop = texture2D( colorTex, texcoord, 0.0 );
float s = abs( offset.x ) > abs( offset.y ) ? abs( offset.x ) : abs( offset.y );
// WebGL port note: Added gamma correction
C.xyz = pow(C.xyz, vec3(2.2));
Cop.xyz = pow(Cop.xyz, vec3(2.2));
vec4 mixed = mix(C, Cop, s);
mixed.xyz = pow(mixed.xyz, vec3(1.0 / 2.2));
return mixed;
}
}
void main() {
gl_FragColor = SMAANeighborhoodBlendingPS( vUv, vOffset, tColor, tDiffuse );
}`};var Jp=class extends li{constructor(e,t){super(),this.edgesRT=new on(e,t,{depthBuffer:!1,type:Hn}),this.edgesRT.texture.name="SMAAPass.edges",this.weightsRT=new on(e,t,{depthBuffer:!1,type:Hn}),this.weightsRT.texture.name="SMAAPass.weights";let n=this,r=new Image;r.src=this.getAreaTexture(),r.onload=function(){n.areaTexture.needsUpdate=!0},this.areaTexture=new Qt,this.areaTexture.name="SMAAPass.area",this.areaTexture.image=r,this.areaTexture.minFilter=nn,this.areaTexture.generateMipmaps=!1,this.areaTexture.flipY=!1;let s=new Image;s.src=this.getSearchTexture(),s.onload=function(){n.searchTexture.needsUpdate=!0},this.searchTexture=new Qt,this.searchTexture.name="SMAAPass.search",this.searchTexture.image=s,this.searchTexture.magFilter=Jt,this.searchTexture.minFilter=Jt,this.searchTexture.generateMipmaps=!1,this.searchTexture.flipY=!1,this.uniformsEdges=Gn.clone(Lh.uniforms),this.uniformsEdges.resolution.value.set(1/e,1/t),this.materialEdges=new $t({defines:Object.assign({},Lh.defines),uniforms:this.uniformsEdges,vertexShader:Lh.vertexShader,fragmentShader:Lh.fragmentShader}),this.uniformsWeights=Gn.clone(Oh.uniforms),this.uniformsWeights.resolution.value.set(1/e,1/t),this.uniformsWeights.tDiffuse.value=this.edgesRT.texture,this.uniformsWeights.tArea.value=this.areaTexture,this.uniformsWeights.tSearch.value=this.searchTexture,this.materialWeights=new $t({defines:Object.assign({},Oh.defines),uniforms:this.uniformsWeights,vertexShader:Oh.vertexShader,fragmentShader:Oh.fragmentShader}),this.uniformsBlend=Gn.clone(Zp.uniforms),this.uniformsBlend.resolution.value.set(1/e,1/t),this.uniformsBlend.tDiffuse.value=this.weightsRT.texture,this.materialBlend=new $t({uniforms:this.uniformsBlend,vertexShader:Zp.vertexShader,fragmentShader:Zp.fragmentShader}),this.fsQuad=new Fr(null)}render(e,t,n){this.uniformsEdges.tDiffuse.value=n.texture,this.fsQuad.material=this.materialEdges,e.setRenderTarget(this.edgesRT),this.clear&&e.clear(),this.fsQuad.render(e),this.fsQuad.material=this.materialWeights,e.setRenderTarget(this.weightsRT),this.clear&&e.clear(),this.fsQuad.render(e),this.uniformsBlend.tColor.value=n.texture,this.fsQuad.material=this.materialBlend,this.renderToScreen?(e.setRenderTarget(null),this.fsQuad.render(e)):(e.setRenderTarget(t),this.clear&&e.clear(),this.fsQuad.render(e))}setSize(e,t){this.edgesRT.setSize(e,t),this.weightsRT.setSize(e,t),this.materialEdges.uniforms.resolution.value.set(1/e,1/t),this.materialWeights.uniforms.resolution.value.set(1/e,1/t),this.materialBlend.uniforms.resolution.value.set(1/e,1/t)}getAreaTexture(){return"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAKAAAAIwCAIAAACOVPcQAACBeklEQVR42u39W4xlWXrnh/3WWvuciIzMrKxrV8/0rWbY0+SQFKcb4owIkSIFCjY9AC1BT/LYBozRi+EX+cV+8IMsYAaCwRcBwjzMiw2jAWtgwC8WR5Q8mDFHZLNHTarZGrLJJllt1W2qKrsumZWZcTvn7L3W54e1vrXX3vuciLPPORFR1XE2EomorB0nVuz//r71re/y/1eMvb4Cb3N11xV/PP/2v4UBAwJG/7H8urx6/25/Gf8O5hypMQ0EEEQwAqLfoN/Z+97f/SW+/NvcgQk4sGBJK6H7N4PFVL+K+e0N11yNfkKvwUdwdlUAXPHHL38oa15f/i/46Ih6SuMSPmLAYAwyRKn7dfMGH97jaMFBYCJUgotIC2YAdu+LyW9vvubxAP8kAL8H/koAuOKP3+q6+xGnd5kdYCeECnGIJViwGJMAkQKfDvB3WZxjLKGh8VSCCzhwEWBpMc5/kBbjawT4HnwJfhr+pPBIu7uu+OOTo9vsmtQcniMBGkKFd4jDWMSCRUpLjJYNJkM+IRzQ+PQvIeAMTrBS2LEiaiR9b/5PuT6Ap/AcfAFO4Y3dA3DFH7/VS+M8k4baEAQfMI4QfbVDDGIRg7GKaIY52qAjTAgTvGBAPGIIghOCYAUrGFNgzA7Q3QhgCwfwAnwe5vDejgG44o/fbm1C5ZlYQvQDARPAIQGxCWBM+wWl37ZQESb4gImexGMDouhGLx1Cst0Saa4b4AqO4Hk4gxo+3DHAV/nx27p3JziPM2pVgoiia5MdEzCGULprIN7gEEeQ5IQxEBBBQnxhsDb5auGmAAYcHMA9eAAz8PBol8/xij9+C4Djlim4gJjWcwZBhCBgMIIYxGAVIkH3ZtcBuLdtRFMWsPGoY9rN+HoBji9VBYdwD2ZQg4cnO7OSq/z4rU5KKdwVbFAjNojCQzTlCLPFSxtamwh2jMUcEgg2Wm/6XgErIBhBckQtGN3CzbVacERgCnfgLswhnvqf7QyAq/z4rRZm1YglYE3affGITaZsdIe2FmMIpnOCap25I6jt2kCwCW0D1uAD9sZctNGXcQIHCkINDQgc78aCr+zjtw3BU/ijdpw3zhCwcaONwBvdeS2YZKkJNJsMPf2JKEvC28RXxxI0ASJyzQCjCEQrO4Q7sFArEzjZhaFc4cdv+/JFdKULM4px0DfUBI2hIsy06BqLhGTQEVdbfAIZXYMPesq6VoCHICzUyjwInO4Y411//LYLs6TDa9wvg2CC2rElgAnpTBziThxaL22MYhzfkghz6GAs2VHbbdM91VZu1MEEpupMMwKyVTb5ij9+u4VJG/5EgEMMmFF01cFai3isRbKbzb+YaU/MQbAm2XSMoUPAmvZzbuKYRIFApbtlrfFuUGd6vq2hXNnH78ZLh/iFhsQG3T4D1ib7k5CC6vY0DCbtrohgLEIClXiGtl10zc0CnEGIhhatLBva7NP58Tvw0qE8yWhARLQ8h4+AhQSP+I4F5xoU+VilGRJs6wnS7ruti/4KvAY/CfdgqjsMy4pf8fodQO8/gnuX3f/3xi3om1/h7THr+co3x93PP9+FBUfbNUjcjEmhcrkT+8K7ml7V10Jo05mpIEFy1NmCJWx9SIKKt+EjAL4Ez8EBVOB6havuT/rByPvHXK+9zUcfcbb254+9fydJknYnRr1oGfdaiAgpxu1Rx/Rek8KISftx3L+DfsLWAANn8Hvw0/AFeAGO9DFV3c6D+CcWbL8Dj9e7f+T1k8AZv/d7+PXWM/Z+VvdCrIvuAKO09RpEEQJM0Ci6+B4xhTWr4cZNOvhktabw0ta0rSJmqz3Yw5/AKXwenod7cAhTmBSPKf6JBdvH8IP17h95pXqw50/+BFnj88fev4NchyaK47OPhhtI8RFSvAfDSNh0Ck0p2gLxGkib5NJj/JWCr90EWQJvwBzO4AHcgztwAFN1evHPUVGwfXON+0debT1YeGON9Yy9/63X+OguiwmhIhQhD7l4sMqlG3D86Suc3qWZ4rWjI1X7u0Ytw6x3rIMeIOPDprfe2XzNgyj6PahhBjO4C3e6puDgXrdg+/5l948vF3bqwZetZ+z9Rx9zdIY5pInPK4Nk0t+l52xdK2B45Qd87nM8fsD5EfUhIcJcERw4RdqqH7Yde5V7m1vhNmtedkz6EDzUMF/2jJYWbC+4fzzA/Y+/8PPH3j9dcBAPIRP8JLXd5BpAu03aziOL3VVHZzz3CXWDPWd+SH2AnxIqQoTZpo9Ckc6HIrFbAbzNmlcg8Ag8NFDDAhbJvTBZXbC94P7t68EXfv6o+21gUtPETU7bbkLxvNKRFG2+KXzvtObonPP4rBvsgmaKj404DlshFole1Glfh02fE7bYR7dZ82oTewIBGn1Md6CG6YUF26X376oevOLzx95vhUmgblI6LBZwTCDY7vMq0op5WVXgsObOXJ+1x3qaBl9j1FeLxbhU9w1F+Wiba6s1X/TBz1LnUfuYDi4r2C69f1f14BWfP+p+W2GFKuC9phcELMYRRLur9DEZTUdEH+iEqWdaM7X4WOoPGI+ZYD2+wcQ+y+ioHUZ9dTDbArzxmi/bJI9BND0Ynd6lBdve/butBw8+f/T9D3ABa3AG8W3VPX4hBin+bj8dMMmSpp5pg7fJ6xrBFE2WQQEWnV8Qg3FbAWzYfM1rREEnmvkN2o1+acG2d/9u68GDzx91v3mAjb1zkpqT21OipPKO0b9TO5W0nTdOmAQm0TObts3aBKgwARtoPDiCT0gHgwnbArzxmtcLc08HgF1asN0C4Ms/fvD5I+7PhfqyXE/b7RbbrGyRQRT9ARZcwAUmgdoz0ehJ9Fn7QAhUjhDAQSw0bV3T3WbNa59jzmiP6GsWbGXDX2ytjy8+f9T97fiBPq9YeLdBmyuizZHaqXITnXiMUEEVcJ7K4j3BFPurtB4bixW8wTpweL8DC95szWMOqucFYGsWbGU7p3TxxxefP+r+oTVktxY0v5hbq3KiOKYnY8ddJVSBxuMMVffNbxwIOERShst73HZ78DZrHpmJmH3K6sGz0fe3UUj0eyRrSCGTTc+rjVNoGzNSv05srAxUBh8IhqChiQgVNIIBH3AVPnrsnXQZbLTm8ammv8eVXn/vWpaTem5IXRlt+U/LA21zhSb9cye6jcOfCnOwhIAYXAMVTUNV0QhVha9xjgA27ODJbLbmitt3tRN80lqG6N/khgot4ZVlOyO4WNg3OIMzhIZQpUEHieg2im6F91hB3I2tubql6BYNN9Hj5S7G0G2tahslBWKDnOiIvuAEDzakDQKDNFQT6gbn8E2y4BBubM230YIpBnDbMa+y3dx0n1S0BtuG62lCCXwcY0F72T1VRR3t2ONcsmDjbmzNt9RFs2LO2hQNyb022JisaI8rAWuw4HI3FuAIhZdOGIcdjLJvvObqlpqvWTJnnQbyi/1M9O8UxWhBs//H42I0q1Yb/XPGONzcmm+ri172mHKvZBpHkJaNJz6v9jxqiklDj3U4CA2ugpAaYMWqNXsdXbmJNd9egCnJEsphXNM+MnK3m0FCJ5S1kmJpa3DgPVbnQnPGWIDspW9ozbcO4K/9LkfaQO2KHuqlfFXSbdNzcEcwoqNEFE9zcIXu9/6n/ym/BC/C3aJLzEKPuYVlbFnfhZ8kcWxV3dbv4bKl28566wD+8C53aw49lTABp9PWbsB+knfc/Li3eVizf5vv/xmvnPKg5ihwKEwlrcHqucuVcVOxEv8aH37E3ZqpZypUulrHEtIWKUr+txHg+ojZDGlwnqmkGlzcVi1dLiNSJiHjfbRNOPwKpx9TVdTn3K05DBx4psIk4Ei8aCkJahRgffk4YnEXe07T4H2RR1u27E6wfQsBDofUgjFUFnwC2AiVtA+05J2zpiDK2Oa0c5fmAecN1iJzmpqFZxqYBCYhFTCsUNEmUnIcZ6aEA5rQVhEywG6w7HSW02XfOoBlQmjwulOFQAg66SvJblrTEX1YtJ3uG15T/BH1OfOQeuR8g/c0gdpT5fx2SKbs9EfHTKdM8A1GaJRHLVIwhcGyydZsbifAFVKl5EMKNU2Hryo+06BeTgqnxzYjThVySDikbtJPieco75lYfKAJOMEZBTjoITuWHXXZVhcUDIS2hpiXHV9Ku4u44bN5OYLDOkJo8w+xJSMbhBRHEdEs9JZUCkQrPMAvaHyLkxgkEHxiNkx/x2YB0mGsQ8EUWj/stW5YLhtS5SMu+/YBbNPDCkGTUybN8krRLBGPlZkVOA0j+a1+rkyQKWGaPHPLZOkJhioQYnVZ2hS3zVxMtgC46KuRwbJNd9nV2PHgb36F194ecf/Yeu2vAFe5nm/bRBFrnY4BauE8ERmZRFUn0k8hbftiVYSKMEme2dJCJSCGYAlNqh87bXOPdUkGy24P6d1ll21MBqqx48Fvv8ZHH8HZFY7j/uAq1xMJUFqCSUlJPmNbIiNsmwuMs/q9CMtsZsFO6SprzCS1Z7QL8xCQClEelpjTduDMsmWD8S1PT152BtvmIGvUeDA/yRn83u/x0/4qxoPHjx+PXY9pqX9bgMvh/Nz9kpP4pOe1/fYf3axUiMdHLlPpZCNjgtNFAhcHEDxTumNONhHrBduW+vOyY++70WWnPXj98eA4kOt/mj/5E05l9+O4o8ePx67HFqyC+qSSnyselqjZGaVK2TadbFLPWAQ4NBhHqDCCV7OTpo34AlSSylPtIdd2AJZlyzYQrDJ5lcWGNceD80CunPLGGzsfD+7wRb95NevJI5docQ3tgCyr5bGnyaPRlmwNsFELViOOx9loebGNq2moDOKpHLVP5al2cymWHbkfzGXL7kfRl44H9wZy33tvt+PB/Xnf93e+nh5ZlU18wCiRUa9m7kib9LYuOk+hudQNbxwm0AQqbfloimaB2lM5fChex+ylMwuTbfmXQtmWlenZljbdXTLuOxjI/fDDHY4Hjx8/Hrse0zXfPFxbUN1kKqSCCSk50m0Ajtx3ub9XHBKHXESb8iO6E+qGytF4nO0OG3SXzbJlhxBnKtKyl0NwybjvYCD30aMdjgePHz8eu56SVTBbgxJMliQ3Oauwg0QHxXE2Ez/EIReLdQj42Gzb4CLS0YJD9xUx7bsi0vJi5mUbW1QzL0h0PFk17rtiIPfJk52MB48fPx67npJJwyrBa2RCCQRTbGZSPCxTPOiND4G2pYyOQ4h4jINIJh5wFU1NFZt+IsZ59LSnDqBjZ2awbOku+yInunLcd8VA7rNnOxkPHj9+PGY9B0MWJJNozOJmlglvDMXDEozdhQWbgs/U6oBanGzLrdSNNnZFjOkmbi5bNt1lX7JLLhn3vXAg9/h4y/Hg8ePHI9dzQMEkWCgdRfYykYKnkP7D4rIujsujaKPBsB54vE2TS00ccvFY/Tth7JXeq1hz+qgVy04sAJawTsvOknHfCwdyT062HA8eP348Zj0vdoXF4pilKa2BROed+9fyw9rWRXeTFXESMOanvDZfJuJaSXouQdMdDJZtekZcLLvEeK04d8m474UDuaenW44Hjx8/Xns9YYqZpszGWB3AN/4VHw+k7WSFtJ3Qicuqb/NlVmgXWsxh570xg2UwxUw3WfO6B5nOuO8aA7lnZxuPB48fPx6znm1i4bsfcbaptF3zNT78eFPtwi1OaCNOqp1x3zUGcs/PN++AGD1+fMXrSVm2baTtPhPahbPhA71wIHd2bXzRa69nG+3CraTtPivahV/55tXWg8fyRY/9AdsY8VbSdp8V7cKrrgdfM//z6ILQFtJ2nxHtwmuoB4/kf74+gLeRtvvMaBdeSz34+vifx0YG20jbfTa0C6+tHrwe//NmOG0L8EbSdp8R7cLrrQe/996O+ai3ujQOskpTNULa7jOjXXj99eCd8lHvoFiwsbTdZ0a78PrrwTvlo966pLuRtB2fFe3Cm6oHP9kNH/W2FryxtN1nTLvwRurBO+Kj3pWXHidtx2dFu/Bm68Fb81HvykuPlrb7LGkX3mw9eGs+6h1Y8MbSdjegXcguQLjmevDpTQLMxtJ2N6NdyBZu9AbrwVvwUW+LbteULUpCdqm0HTelXbhNPe8G68Gb8lFvVfYfSNuxvrTdTWoXbozAzdaDZzfkorOj1oxVxlIMlpSIlpLrt8D4hrQL17z+c3h6hU/wv4Q/utps4+bm+6P/hIcf0JwQ5oQGPBL0eKPTYEXTW+eL/2DKn73J9BTXYANG57hz1cEMviVf/4tf5b/6C5pTQkMIWoAq7hTpOJjtAM4pxKu5vg5vXeUrtI09/Mo/5H+4z+Mp5xULh7cEm2QbRP2tFIKR7WM3fPf/jZ3SWCqLM2l4NxID5zB72HQXv3jj/8mLR5xXNA5v8EbFQEz7PpRfl1+MB/hlAN65qgDn3wTgH13hK7T59bmP+NIx1SHHU84nLOITt3iVz8mNO+lPrjGAnBFqmioNn1mTyk1ta47R6d4MrX7tjrnjYUpdUbv2rVr6YpVfsGG58AG8Ah9eyUN8CX4WfgV+G8LVWPDGb+Zd4cU584CtqSbMKxauxTg+dyn/LkVgA+IR8KHtejeFKRtTmLLpxN6mYVLjYxwXf5x2VofiZcp/lwKk4wGOpYDnoIZPdg/AAbwMfx0+ge9dgZvYjuqKe4HnGnykYo5TvJbG0Vj12JagRhwKa44H95ShkZa5RyLGGdfYvG7aw1TsF6iapPAS29mNS3NmsTQZCmgTzFwgL3upCTgtBTRwvGMAKrgLn4evwin8+afJRcff+8izUGUM63GOOuAs3tJkw7J4kyoNreqrpO6cYLQeFUd7TTpr5YOTLc9RUUogUOVJQ1GYJaFLAW0oTmKyYS46ZooP4S4EON3xQ5zC8/CX4CnM4c1PE8ApexpoYuzqlP3d4S3OJP8ZDK7cKWNaTlqmgDiiHwl1YsE41w1zT4iRTm3DBqxvOUsbMKKDa/EHxagtnta072ejc3DOIh5ojvh8l3tk1JF/AV6FU6jh3U8HwEazLgdCLYSQ+MYiAI2ltomkzttUb0gGHdSUUgsIYjTzLG3mObX4FBRaYtpDVNZrih9TgTeYOBxsEnN1gOCTM8Bsw/ieMc75w9kuAT6A+/AiHGvN/+Gn4KRkiuzpNNDYhDGFndWRpE6SVfm8U5bxnSgVV2jrg6JCKmneqey8VMFgq2+AM/i4L4RUbfSi27lNXZ7R7W9RTcq/q9fk4Xw3AMQd4I5ifAZz8FcVtm9SAom/dyN4lczJQW/kC42ZrHgcCoIf1oVMKkVItmMBi9cOeNHGLqOZk+QqQmrbc5YmYgxELUUN35z2iohstgfLIFmcMV7s4CFmI74L9+EFmGsi+tGnAOD4Yk9gIpo01Y4cA43BWGygMdr4YZekG3OBIUXXNukvJS8tqa06e+lSDCtnqqMFu6hWHXCF+WaYt64m9QBmNxi7Ioy7D+fa1yHw+FMAcPt7SysFLtoG4PXAk7JOA3aAxBRqUiAdU9Yp5lK3HLSRFtOim0sa8euEt08xvKjYjzeJ2GU7YawexrnKI9tmobInjFXCewpwriY9+RR4aaezFhMhGCppKwom0ChrgFlKzyPKkGlTW1YQrE9HJqu8hKGgMc6hVi5QRq0PZxNfrYNgE64utmRv6KKHRpxf6VDUaOvNP5jCEx5q185My/7RKz69UQu2im5k4/eownpxZxNLwiZ1AZTO2ZjWjkU9uaB2HFn6Q3u0JcsSx/qV9hTEApRzeBLDJQXxYmTnq7bdLa3+uqFrxLJ5w1TehnNHx5ECvCh2g2c3hHH5YsfdaSKddztfjQ6imKFGSyFwlLzxEGPp6r5IevVjk1AMx3wMqi1NxDVjLBiPs9tbsCkIY5we5/ML22zrCScFxnNtzsr9Wcc3CnD+pYO+4VXXiDE0oc/vQQ/fDK3oPESJMYXNmJa/DuloJZkcTpcYE8lIH8Dz8DJMiynNC86Mb2lNaaqP/+L7f2fcE/yP7/Lde8xfgSOdMxvOixZf/9p3+M4hT1+F+zApxg9XfUvYjc8qX2lfOOpK2gNRtB4flpFu9FTKCp2XJRgXnX6olp1zyYjTKJSkGmLE2NjUr1bxFM4AeAAHBUFIeSLqXR+NvH/M9fOnfHzOD2vCSyQJKzfgsCh+yi/Mmc35F2fUrw7miW33W9hBD1vpuUojFphIyvg7aTeoymDkIkeW3XLHmguMzbIAJejN6B5MDrhipE2y6SoFRO/AK/AcHHZHNIfiWrEe/C6cr3f/yOvrQKB+zMM55/GQdLDsR+ifr5Fiuu+/y+M78LzOE5dsNuXC3PYvYWd8NXvphLSkJIasrlD2/HOqQ+RjcRdjKTGWYhhVUm4yxlyiGPuMsZR7sMCHUBeTuNWA7if+ifXgc/hovftHXs/DV+Fvwe+f8shzMiMcweFgBly3//vwJfg5AN4450fn1Hd1Rm1aBLu22Dy3y3H2+OqMemkbGZ4jozcDjJf6596xOLpC0eMTHbKnxLxH27uZ/bMTGs2jOaMOY4m87CfQwF0dw53oa1k80JRuz/XgS+8fX3N9Af4qPIMfzKgCp4H5TDGe9GGeFPzSsZz80SlPTxXjgwJmC45njzgt2vbQ4b4OAdUK4/vWhO8d8v6EE8fMUsfakXbPpFJeLs2ubM/qdm/la3WP91uWhxXHjoWhyRUq2iJ/+5mA73zwIIo+LoZ/SgvIRjAd1IMvvn98PfgOvAJfhhm8scAKVWDuaRaK8aQ9f7vuPDH6Bj47ZXau7rqYJ66mTDwEDU6lLbCjCK0qTXyl5mnDoeNRxanj3FJbaksTk0faXxHxLrssgPkWB9LnA/MFleXcJozzjwsUvUG0X/QCve51qkMDXp9mtcyOy3rwBfdvVJK7D6/ACSzg3RoruIq5UDeESfEmVclDxnniU82vxMLtceD0hGZWzBNPMM/jSPne2OVatiTKUpY5vY7gc0LdUAWeWM5tH+O2I66AOWw9xT2BuyRVLGdoDHUsVRXOo/c+ZdRXvFfnxWyIV4upFLCl9eAL7h8Zv0QH8Ry8pA2cHzQpGesctVA37ZtklBTgHjyvdSeKY/RZw/kJMk0Y25cSNRWSigQtlULPTw+kzuJPeYEkXjQRpoGZobYsLF79pyd1dMRHInbgFTZqNLhDqiIsTNpoex2WLcy0/X6rHcdMMQvFSd5dWA++4P7xv89deACnmr36uGlL69bRCL6BSZsS6c0TU2TKK5gtWCzgAOOwQcurqk9j8whvziZSMLcq5hbuwBEsYjopUBkqw1yYBGpLA97SRElEmx5MCInBY5vgLk94iKqSWmhIGmkJ4Bi9m4L645J68LyY4wsFYBfUg5feP/6gWWm58IEmKQM89hq7KsZNaKtP5TxxrUZZVkNmMJtjbKrGxLNEbHPJxhqy7lAmbC32ZqeF6lTaknRWcYaFpfLUBh/rwaQycCCJmW15Kstv6jRHyJFry2C1ahkkIW0LO75s61+owxK1y3XqweX9m5YLM2DPFeOjn/iiqCKJ+yKXF8t5Yl/kNsqaSCryxPq5xWTFIaP8KSW0RYxqupaUf0RcTNSSdJZGcKYdYA6kdtrtmyBckfKXwqk0pHpUHlwWaffjNRBYFPUDWa8e3Lt/o0R0CdisKDM89cX0pvRHEfM8ca4t0s2Xx4kgo91MPQJ/0c9MQYq0co8MBh7bz1fio0UUHLR4aAIOvOmoYO6kwlEVODSSTliWtOtH6sPkrtctF9ZtJ9GIerBskvhdVS5cFNv9s1BU0AbdUgdK4FG+dRnjFmDTzniRMdZO1QhzMK355vigbdkpz9P6qjUGE5J2qAcXmwJ20cZUiAD0z+pGMx6xkzJkmEf40Hr4qZfVg2XzF9YOyoV5BjzVkUJngKf8lgNYwKECEHrCNDrWZzMlflS3yBhr/InyoUgBc/lKT4pxVrrC6g1YwcceK3BmNxZcAtz3j5EIpqguh9H6wc011YN75cKDLpFDxuwkrPQmUwW4KTbj9mZTwBwLq4aQMUZbHm1rylJ46dzR0dua2n3RYCWZsiHROeywyJGR7mXKlpryyCiouY56sFkBWEnkEB/raeh/Sw4162KeuAxMQpEkzy5alMY5wamMsWKKrtW2WpEWNnReZWONKWjrdsKZarpFjqCslq773PLmEhM448Pc3+FKr1+94vv/rfw4tEcu+lKTBe4kZSdijBrykwv9vbCMPcLQTygBjzVckSLPRVGslqdunwJ4oegtFOYb4SwxNgWLCmD7T9kVjTv5YDgpo0XBmN34Z/rEHp0sgyz7lngsrm4lvMm2Mr1zNOJYJ5cuxuQxwMGJq/TP5emlb8fsQBZviK4t8hFL+zbhtlpwaRSxQRWfeETjuauPsdGxsBVdO7nmP4xvzSoT29pRl7kGqz+k26B3Oy0YNV+SXbbQas1ctC/GarskRdFpKczVAF1ZXnLcpaMuzVe6lZ2g/1ndcvOVgRG3sdUAY1bKD6achijMPdMxV4muKVorSpiDHituH7rSTs7n/4y5DhRXo4FVBN4vO/zbAcxhENzGbHCzU/98Mcx5e7a31kWjw9FCe/zNeYyQjZsWb1uc7U33pN4Mji6hCLhivqfa9Ss6xLg031AgfesA/l99m9fgvnaF9JoE6bYKmkGNK3aPbHB96w3+DnxFm4hs0drLsk7U8kf/N/CvwQNtllna0rjq61sH8L80HAuvwH1tvBy2ChqWSCaYTaGN19sTvlfzFD6n+iKTbvtayfrfe9ueWh6GJFoxLdr7V72a5ZpvHcCPDzma0wTO4EgbLyedxstO81n57LYBOBzyfsOhUKsW1J1BB5vr/tz8RyqOFylQP9Tvst2JALsC5lsH8PyQ40DV4ANzYa4dedNiKNR1s+x2wwbR7q4/4cTxqEk4LWDebfisuo36JXLiWFjOtLrlNWh3K1rRS4xvHcDNlFnNmWBBAl5SWaL3oPOfnvbr5pdjVnEaeBJSYjuLEkyLLsWhKccadmOphZkOPgVdalj2QpSmfOsADhMWE2ZBu4+EEJI4wKTAuCoC4xwQbWXBltpxbjkXJtKxxabo9e7tyhlgb6gNlSbUpMh+l/FaqzVwewGu8BW1Zx7pTpQDJUjb8tsUTW6+GDXbMn3mLbXlXJiGdggxFAoUrtPS3wE4Nk02UZG2OOzlk7fRs7i95QCLo3E0jtrjnM7SR3uS1p4qtS2nJ5OwtQVHgOvArLBFijZUV9QtSl8dAY5d0E0hM0w3HS2DpIeB6m/A1+HfhJcGUq4sOxH+x3f5+VO+Ds9rYNI7zPXOYWPrtf8bYMx6fuOAX5jzNR0PdsuON+X1f7EERxMJJoU6GkTEWBvVolVlb5lh3tKCg6Wx1IbaMDdJ+9sUCc5KC46hKGCk3IVOS4TCqdBNfUs7Kd4iXf2RjnT/LLysJy3XDcHLh/vde3x8DoGvwgsa67vBk91G5Pe/HbOe7xwym0NXbtiuuDkGO2IJDh9oQvJ4cY4vdoqLDuoH9Zl2F/ofsekn8lkuhIlhQcffUtSjytFyp++p6NiE7Rqx/lodgKVoceEp/CP4FfjrquZaTtj2AvH5K/ywpn7M34K/SsoYDAdIN448I1/0/wveW289T1/lX5xBzc8N5IaHr0XMOQdHsIkDuJFifj20pBm5jzwUv9e2FhwRsvhAbalCIuIw3bhJihY3p6nTFFIZgiSYjfTf3aXuOjmeGn4bPoGvwl+CFzTRczBIuHBEeImHc37/lGfwZR0cXzVDOvaKfNHvwe+suZ771K/y/XcBlsoN996JpBhoE2toYxOznNEOS5TJc6Id5GEXLjrWo+LEWGNpPDU4WAwsIRROu+1vM+0oW37z/MBN9kqHnSArwPfgFJ7Cq/Ai3Ie7g7ncmI09v8sjzw9mzOAEXoIHxURueaAce5V80f/DOuuZwHM8vsMb5wBzOFWM7wymTXPAEvm4vcFpZ2ut0VZRjkiP2MlmLd6DIpbGSiHOjdnUHN90hRYmhTnmvhzp1iKDNj+b7t5hi79lWGwQ+HN9RsfFMy0FXbEwhfuczKgCbyxYwBmcFhhvo/7a44v+i3XWcwDP86PzpGQYdWh7csP5dBvZ1jNzdxC8pBGuxqSW5vw40nBpj5JhMwvOzN0RWqERHMr4Lv1kWX84xLR830G3j6yqZ1a8UstTlW+qJPOZ+sZ7xZPKTJLhiNOAFd6tk+jrTH31ncLOxid8+nzRb128HhUcru/y0Wn6iT254YPC6FtVSIMoW2sk727AhvTtrWKZTvgsmckfXYZWeNRXx/3YQ2OUxLDrbHtN11IwrgXT6c8dATDwLniYwxzO4RzuQqTKSC5gAofMZ1QBK3zQ4JWobFbcvJm87FK+6JXrKahLn54m3p+McXzzYtP8VF/QpJuh1OwieElEoI1pRxPS09FBrkq2tWCU59+HdhNtTIqKm8EBrw2RTOEDpG3IKo2Y7mFdLm3ZeVjYwVw11o/oznceMve4CgMfNym/utA/d/ILMR7gpXzRy9eDsgLcgbs8O2Va1L0zzIdwGGemTBuwROHeoMShkUc7P+ISY3KH5ZZeWqO8mFTxQYeXTNuzvvK5FGPdQfuu00DwYFY9dyhctEt+OJDdnucfpmyhzUJzfsJjr29l8S0bXBfwRS9ZT26tmMIdZucch5ZboMz3Nio3nIOsYHCGoDT4kUA9MiXEp9Xsui1S8th/kbWIrMBxDGLodWUQIWcvnXy+9M23xPiSMOiRPqM+YMXkUN3gXFrZJwXGzUaMpJfyRS9ZT0lPe8TpScuRlbMHeUmlaKDoNuy62iWNTWNFYjoxFzuJs8oR+RhRx7O4SVNSXpa0ZJQ0K1LAHDQ+D9IepkMXpcsq5EVCvClBUIzDhDoyKwDw1Lc59GbTeORivugw1IcuaEOaGWdNm+Ps5fQ7/tm0DjMegq3yM3vb5j12qUId5UZD2oxDSEWOZMSqFl/W+5oynWDa/aI04tJRQ2eTXusg86SQVu/nwSYwpW6wLjlqIzwLuxGIvoAvul0PS+ZNz0/akp/pniO/8JDnGyaCkzbhl6YcqmK/69prxPqtpx2+Km9al9sjL+rwMgHw4jE/C8/HQ3m1vBuL1fldbzd8mOueVJ92syqdEY4KJjSCde3mcRw2TA6szxedn+zwhZMps0XrqEsiUjnC1hw0TELC2Ek7uAAdzcheXv1BYLagspxpzSAoZZUsIzIq35MnFQ9DOrlNB30jq3L4pkhccKUAA8/ocvN1Rzx9QyOtERs4CVsJRK/DF71kPYrxYsGsm6RMh4cps5g1DOmM54Ly1ii0Hd3Y/BMk8VWFgBVmhqrkJCPBHAolwZaWzLR9Vb7bcWdX9NyUYE+uB2BKfuaeBUcjDljbYVY4DdtsVWvzRZdWnyUzDpjNl1Du3aloAjVJTNDpcIOVVhrHFF66lLfJL1zJr9PQ2nFJSBaKoDe+sAvLufZVHVzYh7W0h/c6AAZ+7Tvj6q9j68G/cTCS/3n1vLKHZwNi+P+pS0WkZNMBMUl+LDLuiE4omZy71r3UFMwNJV+VJ/GC5ixVUkBStsT4gGKh0Gm4Oy3qvq7Lbmq24nPdDuDR9deR11XzP4vFu3TYzfnIyiSVmgizUYGqkIXNdKTY9pgb9D2Ix5t0+NHkVzCdU03suWkkVZAoCONCn0T35gAeW38de43mf97sMOpSvj4aa1KYUm58USI7Wxxes03bAZdRzk6UtbzMaCQ6IxO0dy7X+XsjoD16hpsBeGz9dfzHj+R/Hp8nCxZRqkEDTaCKCSywjiaoMJ1TITE9eg7Jqnq8HL6gDwiZb0u0V0Rr/rmvqjxKuaLCX7ZWXTvAY+uvm3z8CP7nzVpngqrJpZKwWnCUjIviYVlirlGOzPLI3SMVyp/elvBUjjDkNhrtufFFErQ8pmdSlbK16toBHlt/HV8uHMX/vEGALkV3RJREiSlopxwdMXOZPLZ+ix+kAHpMKIk8UtE1ygtquttwxNhphrIZ1IBzjGF3IIGxGcBj6q8bHJBG8T9vdsoWrTFEuebEZuVxhhClH6P5Zo89OG9fwHNjtNQTpD0TG9PJLEYqvEY6Rlxy+ZZGfL0Aj62/bnQCXp//eeM4KzfQVJbgMQbUjlMFIm6TpcfWlZje7NBSV6IsEVmumWIbjiloUzQX9OzYdo8L1wjw2PrrpimONfmfNyzKklrgnEkSzT5QWYQW40YShyzqsRmMXbvVxKtGuYyMKaU1ugenLDm5Ily4iT14fP11Mx+xJv+zZ3MvnfdFqxU3a1W/FTB4m3Qfsyc1XUcdVhDeUDZXSFHHLQj/Y5jtC7ZqM0CXGwB4bP11i3LhOvzPGygYtiUBiwQV/4wFO0majijGsafHyRLu0yG6q35cL1rOpVxr2s5cM2jJYMCdc10Aj6q/blRpWJ//+dmm5psMl0KA2+AFRx9jMe2WbC4jQxnikd4DU8TwUjRVacgdlhmr3bpddzuJ9zXqr2xnxJfzP29RexdtjDVZqzkqa6PyvcojGrfkXiJ8SEtml/nYskicv0ivlxbqjemwUjMw5evdg8fUX9nOiC/lf94Q2i7MURk9nW1MSj5j8eAyV6y5CN2S6qbnw3vdA1Iwq+XOSCl663udN3IzLnrt+us25cI1+Z83SXQUldqQq0b5XOT17bGpLd6ssN1VMPf8c+jG8L3NeCnMdF+Ra3fRa9dft39/LuZ/3vwHoHrqGmQFafmiQw6eyzMxS05K4bL9uA+SKUQzCnSDkqOGokXyJvbgJ/BHI+qvY69//4rl20NsmK2ou2dTsyIALv/91/8n3P2Aao71WFGi8KKv1fRC5+J67Q/507/E/SOshqN5TsmYIjVt+kcjAx98iz/4SaojbIV1rexE7/C29HcYD/DX4a0rBOF5VTu7omsb11L/AWcVlcVZHSsqGuXLLp9ha8I//w3Mv+T4Ew7nTBsmgapoCrNFObIcN4pf/Ob/mrvHTGqqgAupL8qWjWPS9m/31jAe4DjA+4+uCoQoT/zOzlrNd3qd4SdphFxsUvYwGWbTWtISc3wNOWH+kHBMfc6kpmpwPgHWwqaSUG2ZWWheYOGQGaHB+eQ/kn6b3pOgLV+ODSn94wDvr8Bvb70/LLuiPPEr8OGVWfDmr45PZyccEmsVXZGe1pRNX9SU5+AVQkNTIVPCHF/jGmyDC9j4R9LfWcQvfiETmgMMUCMN1uNCakkweZsowdYobiMSlnKA93u7NzTXlSfe+SVbfnPQXmg9LpYAQxpwEtONyEyaueWM4FPjjyjG3uOaFmBTWDNgBXGEiQpsaWhnAqIijB07Dlsy3fUGeP989xbWkyf+FF2SNEtT1E0f4DYYVlxFlbaSMPIRMk/3iMU5pME2SIWJvjckciebkQuIRRyhUvkHg/iUljG5kzVog5hV7vIlCuBrmlhvgPfNHQM8lCf+FEGsYbMIBC0qC9a0uuy2wLXVbLBaP5kjHokCRxapkQyzI4QEcwgYHRZBp+XEFTqXFuNVzMtjXLJgX4gAid24Hjwc4N3dtVSe+NNiwTrzH4WVUOlDobUqr1FuAgYllc8pmzoVrELRHSIW8ViPxNy4xwjBpyR55I6J220qQTZYR4guvUICJiSpr9gFFle4RcF/OMB7BRiX8sSfhpNSO3lvEZCQfLUVTKT78Ek1LRLhWN+yLyTnp8qWUZ46b6vxdRGXfHVqx3eI75YaLa4iNNiK4NOW7wPW6lhbSOF9/M9qw8e/aoB3d156qTzxp8pXx5BKAsYSTOIIiPkp68GmTq7sZtvyzBQaRLNxIZ+paozHWoLFeExIhRBrWitHCAHrCF7/thhD8JhYz84wg93QRV88wLuLY8zF8sQ36qF1J455bOlgnELfshKVxYOXKVuKx0jaj22sczTQqPqtV/XDgpswmGTWWMSDw3ssyUunLLrVPGjYRsH5ggHeHSWiV8kT33ycFSfMgkoOK8apCye0J6VW6GOYvffgU9RWsukEi2kUV2nl4dOYUzRik9p7bcA4ggdJ53LxKcEe17B1R8eqAd7dOepV8sTXf5lhejoL85hUdhDdknPtKHFhljOT+bdq0hxbm35p2nc8+Ja1Iw+tJykgp0EWuAAZYwMVwac5KzYMslhvgHdHRrxKnvhTYcfKsxTxtTETkjHO7rr3zjoV25lAQHrqpV7bTiy2aXMmUhTBnKS91jhtR3GEoF0oLnWhWNnYgtcc4N0FxlcgT7yz3TgNIKkscx9jtV1ZKpWW+Ub1tc1eOv5ucdgpx+FJy9pgbLE7xDyXb/f+hLHVGeitHOi6A7ybo3sF8sS7w7cgdk0nJaOn3hLj3uyD0Zp5pazFIUXUpuTTU18d1EPkDoX8SkmWTnVIozEdbTcZjoqxhNHf1JrSS/AcvHjZ/SMHhL/7i5z+POsTUh/8BvNfYMTA8n+yU/MlTZxSJDRStqvEuLQKWwDctMTQogUDyQRoTQG5Kc6oQRE1yV1jCA7ri7jdZyK0sYTRjCR0Hnnd+y7nHxNgTULqw+8wj0mQKxpYvhjm9uSUxg+TTy7s2GtLUGcywhXSKZN275GsqlclX90J6bRI1aouxmgL7Q0Nen5ziM80SqMIo8cSOo+8XplT/5DHNWsSUr/6lLN/QQ3rDyzLruEW5enpf7KqZoShEduuSFOV7DLX7Ye+GmXb6/hnNNqKsVXuMDFpb9Y9eH3C6NGEzuOuI3gpMH/I6e+zDiH1fXi15t3vA1czsLws0TGEtmPEJdiiFPwlwKbgLHAFk4P6ZyPdymYYHGE0dutsChQBl2JcBFlrEkY/N5bQeXQ18gjunuMfMfsBlxJSx3niO485fwO4fGD5T/+3fPQqkneWVdwnw/3bMPkW9Wbqg+iC765Zk+xcT98ibKZc2EdgHcLoF8cSOo/Oc8fS+OyEULF4g4sJqXVcmfMfsc7A8v1/yfGXmL9I6Fn5pRwZhsPv0TxFNlAfZCvG+Oohi82UC5f/2IsJo0cTOm9YrDoKhFPEUr/LBYTUNht9zelHXDqwfPCIw4owp3mOcIQcLttWXFe3VZ/j5H3cIc0G6oPbCR+6Y2xF2EC5cGUm6wKC5tGEzhsWqw5hNidUiKX5gFWE1GXh4/Qplw4sVzOmx9QxU78g3EF6wnZlEN4FzJ1QPSLEZz1KfXC7vd8ssGdIbNUYpVx4UapyFUHzJoTOo1McSkeNn1M5MDQfs4qQuhhX5vQZFw8suwWTcyYTgioISk2YdmkhehG4PkE7w51inyAGGaU+uCXADabGzJR1fn3lwkty0asIo8cROm9Vy1g0yDxxtPvHDAmpu+PKnM8Ix1wwsGw91YJqhteaWgjYBmmQiebmSpwKKzE19hx7jkzSWOm66oPbzZ8Yj6kxVSpYjVAuvLzYMCRo3oTQecOOjjgi3NQ4l9K5/hOGhNTdcWVOTrlgYNkEXINbpCkBRyqhp+LdRB3g0OU6rMfW2HPCFFMV9nSp+uB2woepdbLBuJQyaw/ZFysXrlXwHxI0b0LovEkiOpXGA1Ijagf+KUNC6rKNa9bQnLFqYNkEnMc1uJrg2u64ELPBHpkgWbmwKpJoDhMwNbbGzAp7Yg31wS2T5rGtzit59PrKhesWG550CZpHEzpv2NGRaxlNjbMqpmEIzygJqQfjypycs2pg2cS2RY9r8HUqkqdEgKTWtWTKoRvOBPDYBltja2SO0RGjy9UHtxwRjA11ujbKF+ti5cIR9eCnxUg6owidtyoU5tK4NLji5Q3HCtiyF2IqLGYsHViOXTXOYxucDqG0HyttqYAKqYo3KTY1ekyDXRAm2AWh9JmsVh/ccg9WJ2E8YjG201sPq5ULxxX8n3XLXuMInbft2mk80rRGjCGctJ8/GFdmEQ9Ug4FlE1ll1Y7jtiraqm5Fe04VV8lvSVBL8hiPrfFVd8+7QH3Qbu2ipTVi8cvSGivc9cj8yvH11YMHdNSERtuOslM97feYFOPKzGcsI4zW0YGAbTAOaxCnxdfiYUmVWslxiIblCeAYr9VYR1gM7GmoPrilunSxxeT3DN/2eBQ9H11+nk1adn6VK71+5+Jfct4/el10/7KBZfNryUunWSCPxPECk1rdOv1WVSrQmpC+Tl46YD3ikQYcpunSQgzVB2VHFhxHVGKDgMEY5GLlQnP7FMDzw7IacAWnO6sBr12u+XanW2AO0wQ8pknnFhsL7KYIqhkEPmEXFkwaN5KQphbkUmG72wgw7WSm9RiL9QT925hkjiVIIhphFS9HKI6/8QAjlpXqg9W2C0apyaVDwKQwrwLY3j6ADR13ZyUNByQXHQu6RY09Hu6zMqXRaNZGS/KEJs0cJEe9VH1QdvBSJv9h09eiRmy0V2uJcqHcShcdvbSNg5fxkenkVprXM9rDVnX24/y9MVtncvbKY706anNl3ASll9a43UiacVquXGhvq4s2FP62NGKfQLIQYu9q1WmdMfmUrDGt8eDS0cXozH/fjmUH6Jruvm50hBDSaEU/2Ru2LEN/dl006TSc/g7tfJERxGMsgDUEr104pfWH9lQaN+M4KWQjwZbVc2rZVNHsyHal23wZtIs2JJqtIc/WLXXRFCpJkfE9jvWlfFbsNQ9pP5ZBS0zKh4R0aMFj1IjTcTnvi0Zz2rt7NdvQb2mgbju1plsH8MmbnEk7KbK0b+wC2iy3aX3szW8xeZvDwET6hWZYwqTXSSG+wMETKum0Dq/q+x62gt2ua2ppAo309TRk9TPazfV3qL9H8z7uhGqGqxNVg/FKx0HBl9OVUORn8Q8Jx9gFttGQUDr3tzcXX9xGgN0EpzN9mdZ3GATtPhL+CjxFDmkeEU6x56kqZRusLzALXVqkCN7zMEcqwjmywDQ6OhyUe0Xao1Qpyncrg6wKp9XfWDsaZplElvQ/b3sdweeghorwBDlHzgk1JmMc/wiERICVy2VJFdMjFuLQSp3S0W3+sngt2njwNgLssFGVQdJ0tu0KH4ky1LW4yrbkuaA6Iy9oz/qEMMXMMDWyIHhsAyFZc2peV9hc7kiKvfULxCl9iddfRK1f8kk9qvbdOoBtOg7ZkOZ5MsGrSHsokgLXUp9y88smniwWyuFSIRVmjplga3yD8Uij5QS1ZiM4U3Qw5QlSm2bXjFe6jzzBFtpg+/YBbLAWG7OPynNjlCw65fukGNdkJRf7yM1fOxVzbxOJVocFoYIaGwH22mIQkrvu1E2nGuebxIgW9U9TSiukPGU+Lt++c3DJPKhyhEEbXCQLUpae2exiKy6tMPe9mDRBFCEMTWrtwxN8qvuGnt6MoihKWS5NSyBhbH8StXoAz8PLOrRgLtOT/+4vcu+7vDLnqNvztOq7fmd8sMmY9Xzn1zj8Dq8+XVdu2Nv0IIySgEdQo3xVHps3Q5i3fLFsV4aiqzAiBhbgMDEd1uh8qZZ+lwhjkgokkOIv4xNJmyncdfUUzgB4oFMBtiu71Xumpz/P+cfUP+SlwFExwWW62r7b+LSPxqxn/gvMZ5z9C16t15UbNlq+jbGJtco7p8wbYlL4alSyfWdeuu0j7JA3JFNuVAwtst7F7FhWBbPFNKIUORndWtLraFLmMu7KFVDDOzqkeaiN33YAW/r76wR4XDN/yN1z7hejPau06EddkS/6XThfcz1fI/4K736fO48vlxt2PXJYFaeUkFS8U15XE3428xdtn2kc8GQlf1vkIaNRRnOMvLTWrZbElEHeLWi1o0dlKPAh1MVgbbVquPJ5+Cr8LU5/H/+I2QlHIU2ClXM9G8v7Rr7oc/hozfUUgsPnb3D+I+7WF8kNO92GY0SNvuxiE+2Bt8prVJTkzE64sfOstxuwfxUUoyk8VjcTlsqe2qITSFoSj6Epd4KsT6BZOWmtgE3hBfir8IzZDwgV4ZTZvD8VvPHERo8v+vL1DASHTz/i9OlKueHDjK5Rnx/JB1Vb1ioXdBra16dmt7dgik10yA/FwJSVY6XjA3oy4SqM2frqDPPSRMex9qs3XQtoWxMj7/Er8GWYsXgjaVz4OYumP2+9kbxvny/6kvWsEBw+fcb5bInc8APdhpOSs01tEqIkoiZjbAqKMruLbJYddHuHFRIyJcbdEdbl2sVLaySygunutBg96Y2/JjKRCdyHV+AEFtTvIpbKIXOamknYSiB6KV/0JetZITgcjjk5ZdaskBtWO86UF0ap6ozGXJk2WNiRUlCPFir66lzdm/SLSuK7EUdPz8f1z29Skq6F1fXg8+5UVR6bszncP4Tn4KUkkdJ8UFCY1zR1i8RmL/qQL3rlei4THG7OODlnKko4oI01kd3CaM08Ia18kC3GNoVaO9iDh+hWxSyTXFABXoau7Q6q9OxYg/OVEMw6jdbtSrJ9cBcewGmaZmg+bvkUnUUaGr+ZfnMH45Ivevl61hMcXsxYLFTu1hTm2zViCp7u0o5l+2PSUh9bDj6FgYypufBDhqK2+oXkiuHFHR3zfj+9PtA8oR0xnqX8qn+sx3bFODSbbF0X8EUvWQ8jBIcjo5bRmLOljDNtcqNtOe756h3l0VhKa9hDd2l1eqmsnh0MNMT/Cqnx6BInumhLT8luljzQ53RiJeA/0dxe5NK0o2fA1+GLXr6eNQWHNUOJssQaTRlGpLHKL9fD+IrQzTOMZS9fNQD4AnRNVxvTdjC+fJdcDDWQcyB00B0t9BDwTxXgaAfzDZ/DBXzRnfWMFRwuNqocOmX6OKNkY63h5n/fFcB28McVHqnXZVI27K0i4rDLNE9lDKV/rT+udVbD8dFFu2GGZ8mOt0kAXcoX3ZkIWVtw+MNf5NjR2FbivROHmhV1/pj2egv/fMGIOWTIWrV3Av8N9imV9IWml36H6cUjqEWNv9aNc+veb2sH46PRaHSuMBxvtW+twxctq0z+QsHhux8Q7rCY4Ct8lqsx7c6Sy0dl5T89rIeEuZKoVctIk1hNpfavER6yyH1Vvm3MbsUHy4ab4hWr/OZPcsRBphnaV65/ZcdYPNNwsjN/djlf9NqCw9U5ExCPcdhKxUgLSmfROpLp4WSUr8ojdwbncbvCf+a/YzRaEc6QOvXcGO256TXc5Lab9POvB+AWY7PigWYjzhifbovuunzRawsO24ZqQQAqguBtmpmPB7ysXJfyDDaV/aPGillgz1MdQg4u5MYaEtBNNHFjkRlSpd65lp4hd2AVPTfbV7FGpyIOfmNc/XVsPfg7vzaS/3nkvLL593ANLvMuRMGpQIhiF7kUEW9QDpAUbTWYBcbp4WpacHHY1aacqQyjGZS9HI3yCBT9kUZJhVOD+zUDvEH9ddR11fzPcTDQ5TlgB0KwqdXSavk9BC0pKp0WmcuowSw07VXmXC5guzSa4p0UvRw2lbDiYUx0ExJJRzWzi6Gm8cnEkfXXsdcG/M/jAJa0+bmCgdmQ9CYlNlSYZOKixmRsgiFxkrmW4l3KdFKv1DM8tk6WxPYJZhUUzcd8Kdtgrw/gkfXXDT7+avmfVak32qhtkg6NVdUS5wgkru1YzIkSduTW1FDwVWV3JQVJVuieTc0y4iDpFwc7/BvSalvKdQM8sv662cevz/+8sQVnjVAT0W2wLllw1JiMhJRxgDjCjLQsOzSFSgZqx7lAW1JW0e03yAD3asC+GD3NbQhbe+mN5GXH1F83KDOM4n/e5JIuH4NpdQARrFPBVptUNcjj4cVMcFSRTE2NpR1LEYbYMmfWpXgP9KejaPsLUhuvLCsVXznAG9dfx9SR1ud/3hZdCLHb1GMdPqRJgqDmm76mHbvOXDtiO2QPUcKo/TWkQ0i2JFXpBoo7vij1i1Lp3ADAo+qvG3V0rM//vFnnTE4hxd5Ka/Cor5YEdsLVJyKtDgVoHgtW11pWSjolPNMnrlrVj9Fv2Qn60twMwKPqr+N/wvr8z5tZcDsDrv06tkqyzESM85Ycv6XBWA2birlNCXrI6VbD2lx2L0vQO0QVTVVLH4SE67fgsfVXv8n7sz7/85Z7cMtbE6f088wSaR4kCkCm10s6pKbJhfqiUNGLq+0gLWC6eUAZFPnLjwqtKd8EwGvWX59t7iPW4X/eAN1svgRVSY990YZg06BD1ohLMtyFTI4pKTJsS9xREq9EOaPWiO2gpms7397x6nQJkbh+Fz2q/rqRROX6/M8bJrqlVW4l6JEptKeUFuMYUbtCQ7CIttpGc6MY93x1r1vgAnRXvY5cvwWPqb9uWQm+lP95QxdNMeWhOq1x0Db55C7GcUv2ZUuN6n8iKzsvOxibC//Yfs9Na8r2Rlz02vXXDT57FP/zJi66/EJSmsJKa8QxnoqW3VLQ+jZVUtJwJ8PNX1NQCwfNgdhhHD9on7PdRdrdGPF28rJr1F+3LBdeyv+8yYfLoMYet1vX4upNAjVvwOUWnlNXJXlkzk5Il6kqeoiL0C07qno+/CYBXq/+utlnsz7/Mzvy0tmI4zm4ag23PRN3t/CWryoUVJGm+5+K8RJ0V8Hc88/XHUX/HfiAq7t+BH+x6v8t438enWmdJwFA6ZINriLGKv/95f8lT9/FnyA1NMVEvQyaXuu+gz36f/DD73E4pwqpLcvm/o0Vle78n//+L/NPvoefp1pTJye6e4A/D082FERa5/opeH9zpvh13cNm19/4v/LDe5xMWTi8I0Ta0qKlK27AS/v3/r+/x/2GO9K2c7kVMonDpq7//jc5PKCxeNPpFVzaRr01wF8C4Pu76hXuX18H4LduTr79guuFD3n5BHfI+ZRFhY8w29TYhbbLi/bvBdqKE4fUgg1pBKnV3FEaCWOWyA+m3WpORZr/j+9TKJtW8yBTF2/ZEODI9/QavHkVdGFp/Pjn4Q+u5hXapsP5sOH+OXXA1LiKuqJxiMNbhTkbdJTCy4llEt6NnqRT4dhg1V3nbdrm6dYMecA1yTOL4PWTE9L5VzPFlLBCvlG58AhehnN4uHsAYinyJ+AZ/NkVvELbfOBUuOO5syBIEtiqHU1k9XeISX5bsimrkUUhnGDxourN8SgUsCZVtKyGbyGzHXdjOhsAvOAswSRyIBddRdEZWP6GZhNK/yjwew9ehBo+3jEADu7Ay2n8mDc+TS7awUHg0OMzR0LABhqLD4hJEh/BEGyBdGlSJoXYXtr+3HS4ijzVpgi0paWXtdruGTknXBz+11qT1Q2inxaTzQCO46P3lfLpyS4fou2PH/PupwZgCxNhGlj4IvUuWEsTkqMWm6i4xCSMc9N1RDQoCVcuGItJ/MRWefais+3synowi/dESgJjkilnWnBTGvRWmaw8oR15257t7CHmCf8HOn7cwI8+NQBXMBEmAa8PMRemrNCEhLGEhDQKcGZWS319BX9PFBEwGTbRBhLbDcaV3drFcDqk5kCTd2JF1Wp0HraqBx8U0wwBTnbpCadwBA/gTH/CDrcCs93LV8E0YlmmcyQRQnjBa8JESmGUfIjK/7fkaDJpmD2QptFNVJU1bbtIAjjWQizepOKptRjbzR9Kag6xZmMLLjHOtcLT3Tx9o/0EcTT1XN3E45u24AiwEypDJXihKjQxjLprEwcmRKclaDNZCVqr/V8mYWyFADbusiY5hvgFoU2vio49RgJLn5OsReRFN6tabeetiiy0V7KFHT3HyZLx491u95sn4K1QQSPKM9hNT0wMVvAWbzDSVdrKw4zRjZMyJIHkfq1VAVCDl/bUhNKlGq0zGr05+YAceXVPCttVk0oqjVwMPt+BBefx4yPtGVkUsqY3CHDPiCM5ngupUwCdbkpd8kbPrCWHhkmtIKLEetF2499eS1jZlIPGYnlcPXeM2KD9vLS0bW3ktYNqUllpKLn5ZrsxlIzxvDu5eHxzGLctkZLEY4PgSOg2IUVVcUONzUDBEpRaMoXNmUc0tFZrTZquiLyKxrSm3DvIW9Fil+AkhXu5PhEPx9mUNwqypDvZWdKlhIJQY7vn2OsnmBeOWnYZ0m1iwbbw1U60by5om47iHRV6fOgzjMf/DAZrlP40Z7syxpLK0lJ0gqaAK1c2KQKu7tabTXkLFz0sCftuwX++MyNeNn68k5Buq23YQhUh0SNTJa1ioQ0p4nUG2y0XilF1JqODqdImloPS4Bp111DEWT0jJjVv95uX9BBV7eB3bUWcu0acSVM23YZdd8R8UbQUxJ9wdu3oMuhdt929ME+mh6JXJ8di2RxbTi6TbrDquqV4aUKR2iwT6aZbyOwEXN3DUsWr8Hn4EhwNyHuXHh7/pdaUjtR7vnDh/d8c9xD/s5f501eQ1+CuDiCvGhk1AN/4Tf74RfxPwD3toLarR0zNtsnPzmS64KIRk861dMWCU8ArasG9T9H0ZBpsDGnjtAOM2+/LuIb2iIUGXNgl5ZmKD/Tw8TlaAuihaFP5yrw18v4x1898zIdP+DDAX1bM3GAMvPgRP/cJn3zCW013nrhHkrITyvYuwOUkcHuKlRSW5C6rzIdY4ppnF7J8aAJbQepgbJYBjCY9usGXDKQxq7RZfh9eg5d1UHMVATRaD/4BHK93/1iAgYZ/+jqPn8Dn4UExmWrpa3+ZOK6MvM3bjwfzxNWA2dhs8+51XHSPJiaAhGSpWevEs5xHLXcEGFXYiCONySH3fPWq93JIsBiSWvWyc3CAN+EcXoT7rCSANloPPoa31rt/5PUA/gp8Q/jDD3hyrjzlR8VkanfOvB1XPubt17vzxAfdSVbD1pzAnfgyF3ycadOTOTXhpEUoLC1HZyNGW3dtmjeXgr2r56JNmRwdNNWaQVBddd6rh4MhviEB9EFRD/7RGvePvCbwAL4Mx/D6M541hHO4D3e7g6PafdcZVw689z7NGTwo5om7A8sPhccT6qKcl9NJl9aM/9kX+e59Hh1yPqGuCCZxuITcsmNaJ5F7d0q6J3H48TO1/+M57085q2icdu2U+W36Ldllz9Agiv4YGljoEN908EzvDOrBF98/vtJwCC/BF2AG75xxEmjmMIcjxbjoaxqOK3/4hPOZzhMPBpYPG44CM0dTVm1LjLtUWWVz1Bcf8tEx0zs8O2A2YVHRxKYOiy/aOVoAaMu0i7ubu43njjmd4ibMHU1sIDHaQNKrZND/FZYdk54oCXetjq7E7IVl9eAL7t+oHnwXXtLx44czzoRFHBztYVwtH1d+NOMkupZ5MTM+gUmq90X+Bh9zjRlmaQ+m7YMqUL/veemcecAtOJ0yq1JnVlN27di2E0+Klp1tAJ4KRw1eMI7aJjsO3R8kPSI3fUFXnIOfdQe86sIIVtWDL7h//Ok6vj8vwDk08NEcI8zz7OhBy+WwalzZeZ4+0XniRfst9pAJqQHDGLzVQ2pheZnnv1OWhwO43/AgcvAEXEVVpa4db9sGvNK8wjaENHkfFQ4Ci5i7dqnQlPoLQrHXZDvO3BIXZbJOBrOaEbML6sFL798I4FhKihjHMsPjBUZYCMFr6nvaArxqXPn4lCa+cHfSa2cP27g3Z3ziYTRrcbQNGLQmGF3F3cBdzzzX7AILx0IB9rbwn9kx2G1FW3Inic+ZLIsVvKR8Zwfj0l1fkqo8LWY1M3IX14OX3r9RKTIO+d9XzAI8qRPGPn/4NC2n6o4rN8XJ82TOIvuVA8zLKUHRFgBCetlDZlqR1gLKjS39xoE7Bt8UvA6BxuEDjU3tFsEijgA+615tmZkXKqiEENrh41iLDDZNq4pKTWR3LZfnos81LOuNa15cD956vLMsJd1rqYp51gDUQqMYm2XsxnUhD2jg1DM7SeuJxxgrmpfISSXVIJIS5qJJSvJPEQ49DQTVIbYWJ9QWa/E2+c/oPK1drmC7WSfJRNKBO5Yjvcp7Gc3dmmI/Xh1kDTEuiSnWqQf37h+fTMhGnDf6dsS8SQfQWlqqwXXGlc/PEZ/SC5mtzIV0nAshlQdM/LvUtYutrEZ/Y+EAFtq1k28zQhOwLr1AIeANzhF8t9qzTdZf2qRKO6MWE9ohBYwibbOmrFtNmg3mcS+tB28xv2uKd/agYCvOP+GkSc+0lr7RXzyufL7QbkUpjLjEWFLqOIkAGu2B0tNlO9Eau2W1qcOUvVRgKzypKIQZ5KI3q0MLzqTNRYqiZOqmtqloIRlmkBHVpHmRYV6/HixbO6UC47KOFJnoMrVyr7wYz+SlW6GUaghYbY1I6kkxA2W1fSJokUdSh2LQ1GAimRGm0MT+uu57H5l7QgOWxERpO9moLRPgTtquWCfFlGlIjQaRly9odmzMOWY+IBO5tB4sW/0+VWGUh32qYk79EidWKrjWuiLpiVNGFWFRJVktyeXWmbgBBzVl8anPuXyNJlBJOlKLTgAbi/EYHVHxWiDaVR06GnHQNpJcWcK2jJtiCfG2sEHLzuI66sGrMK47nPIInPnu799935aOK2cvmvubrE38ZzZjrELCmXM2hM7UcpXD2oC3+ECVp7xtIuxptJ0jUr3sBmBS47TVxlvJ1Sqb/E0uLdvLj0lLr29ypdd/eMX3f6lrxGlKwKQxEGvw0qHbkbwrF3uHKwVENbIV2wZ13kNEF6zD+x24aLNMfDTCbDPnEikZFyTNttxWBXDaBuM8KtI2rmaMdUY7cXcUPstqTGvBGSrFWIpNMfbdea990bvAOC1YX0qbc6smDS1mPxSJoW4fwEXvjMmhlijDRq6qale6aJEuFGoppYDoBELQzLBuh/mZNx7jkinv0EtnUp50lO9hbNK57lZaMAWuWR5Yo9/kYwcYI0t4gWM47Umnl3YmpeBPqSyNp3K7s2DSAS/39KRuEN2bS4xvowV3dFRMx/VFcp2Yp8w2nTO9hCXtHG1kF1L4KlrJr2wKfyq77R7MKpFKzWlY9UkhYxyHWW6nBWPaudvEAl3CGcNpSXPZ6R9BbBtIl6cHL3gIBi+42CYXqCx1gfGWe7Ap0h3luyXdt1MKy4YUT9xSF01G16YEdWsouW9mgDHd3veyA97H+Ya47ZmEbqMY72oPztCGvK0onL44AvgC49saZKkWRz4veWljE1FHjbRJaWv6ZKKtl875h4CziFCZhG5rx7tefsl0aRT1bMHZjm8dwL/6u7wCRysaQblQoG5yAQN5zpatMNY/+yf8z+GLcH/Qn0iX2W2oEfXP4GvwQHuIL9AYGnaO3zqAX6946nkgqZNnUhx43DIdQtMFeOPrgy/y3Yd85HlJWwjLFkU3kFwq28xPnuPhMWeS+tDLV9Otllq7pQCf3uXJDN9wFDiUTgefHaiYbdfi3b3u8+iY6TnzhgehI1LTe8lcd7s1wJSzKbahCRxKKztTLXstGAiu3a6rPuQs5pk9TWAan5f0BZmGf7Ylxzzk/A7PAs4QPPPAHeFQ2hbFHszlgZuKZsJcUmbDC40sEU403cEjczstOEypa+YxevL4QBC8oRYqWdK6b7sK25tfE+oDZgtOQ2Jg8T41HGcBE6fTWHn4JtHcu9S7uYgU5KSCkl/mcnq+5/YBXOEr6lCUCwOTOM1taOI8mSxx1NsCXBEmLKbMAg5MkwbLmpBaFOPrNSlO2HnLiEqW3tHEwd8AeiQLmn+2gxjC3k6AxREqvKcJbTEzlpLiw4rNZK6oJdidbMMGX9FULKr0AkW+2qDEPBNNm5QAt2Ik2nftNWHetubosHLo2nG4vQA7GkcVCgVCgaDixHqo9UUn1A6OshapaNR/LPRYFV8siT1cCtJE0k/3WtaNSuUZYKPnsVIW0xXWnMUxq5+En4Kvw/MqQmVXnAXj9Z+9zM98zM/Agy7F/qqj2Nh67b8HjFnPP3iBn/tkpdzwEJX/whIcQUXOaikeliCRGUk7tiwF0rItwMEhjkZ309hikFoRAmLTpEXWuHS6y+am/KB/fM50aLEhGnSMwkpxzOov4H0AvgovwJ1iGzDLtJn/9BU+fAINfwUe6FHSLhu83viV/+/HrOePX+STT2B9uWGbrMHHLldRBlhS/CJQmcRxJFqZica01XixAZsYiH1uolZxLrR/SgxVIJjkpQP4PE9sE59LKLr7kltSBogS5tyszzH8Fvw8/AS8rNOg0xUS9fIaHwb+6et8Q/gyvKRjf5OusOzGx8evA/BP4IP11uN/grca5O0lcsPLJ5YjwI4QkJBOHa0WdMZYGxPbh2W2nR9v3WxEWqgp/G3+6VZbRLSAAZ3BhdhAaUL33VUSw9yjEsvbaQ9u4A/gGXwZXoEHOuU1GSj2chf+Mo+f8IcfcAxfIKVmyunRbYQVnoevwgfw3TXXcw++xNuP4fhyueEUNttEduRVaDttddoP0eSxLe2LENk6itYxlrxBNBYrNNKSQmeaLcm9c8UsaB5WyO6675yyQIAWSDpBVoA/gxmcwEvwoDv0m58UE7gHn+fJOa8/Ywan8EKRfjsopF83eCglX/Sfr7OeaRoQfvt1CGvIDccH5BCvw1sWIzRGC/66t0VTcLZQZtm6PlAasbOJ9iwWtUo7biktTSIPxnR24jxP1ZKaqq+2RcXM9OrBAm/AAs7hDJ5bNmGb+KIfwCs8a3jnjBrOFeMjHSCdbKr+2uOLfnOd9eiA8Hvvwwq54VbP2OqwkB48Ytc4YEOiH2vTXqodabfWEOzso4qxdbqD5L6tbtNPECqbhnA708DZH4QOJUXqScmUlks7Ot6FBuZw3n2mEbaUX7kDzxHOOQk8nKWMzAzu6ZZ8sOFw4RK+6PcuXo9tB4SbMz58ApfKDXf3szjNIIbGpD5TKTRxGkEMLjLl+K3wlWXBsCUxIDU+jbOiysESqAy1MGUJpXgwbTWzNOVEziIXZrJ+VIztl1PUBxTSo0dwn2bOmfDRPD3TRTGlfbCJvO9KvuhL1hMHhB9wPuPRLGHcdOWG2xc0U+5bQtAJT0nRTewXL1pgk2+rZAdeWmz3jxAqfNQQdzTlbF8uJ5ecEIWvTkevAHpwz7w78QujlD/Lr491bD8/1vhM2yrUQRrWXNQY4fGilfctMWYjL72UL/qS9eiA8EmN88nbNdour+PBbbAjOjIa4iBhfFg6rxeKdEGcL6p3EWR1Qq2Qkhs2DrnkRnmN9tG2EAqmgPw6hoL7Oza7B+3SCrR9tRftko+Lsf2F/mkTndN2LmzuMcKTuj/mX2+4Va3ki16+nnJY+S7MefpkidxwnV+4wkXH8TKnX0tsYzYp29DOOoSW1nf7nTh2akYiWmcJOuTidSaqESrTYpwjJJNVGQr+rLI7WsqerHW6Kp/oM2pKuV7T1QY9gjqlZp41/WfKpl56FV/0kvXQFRyeQ83xaTu5E8p5dNP3dUF34ihyI3GSpeCsywSh22ZJdWto9winhqifb7VRvgktxp13vyjrS0EjvrRfZ62uyqddSWaWYlwTPAtJZ2oZ3j/Sgi/mi+6vpzesfAcWNA0n8xVyw90GVFGuZjTXEQy+6GfLGLMLL523f5E0OmxVjDoOuRiH91RKU+vtoCtH7TgmvBLvtFXWLW15H9GTdVw8ow4IlRLeHECN9ym1e9K0I+Cbnhgv4Yu+aD2HaQJ80XDqOzSGAV4+4yCqBxrsJAX6ZTIoX36QnvzhhzzMfFW2dZVLOJfo0zbce5OvwXMFaZ81mOnlTVXpDZsQNuoYWveketKb5+6JOOsgX+NTm7H49fUTlx+WLuWL7qxnOFh4BxpmJx0p2gDzA/BUARuS6phR+pUsY7MMboAHx5xNsSVfVZcYSwqCKrqon7zM+8ecCkeS4nm3rINuaWvVNnMRI1IRpxTqx8PZUZ0Br/UEduo3B3hNvmgZfs9gQPj8vIOxd2kndir3awvJ6BLvoUuOfFWNYB0LR1OQJoUySKb9IlOBx74q1+ADC2G6rOdmFdJcD8BkfualA+BdjOOzP9uUhGUEX/TwhZsUduwRr8wNuXKurCixLBgpQI0mDbJr9dIqUuV+92ngkJZ7xduCk2yZKbfWrH1VBiTg9VdzsgRjW3CVXCvAwDd+c1z9dWw9+B+8MJL/eY15ZQ/HqvTwVdsZn5WQsgRRnMaWaecu3jFvMBEmgg+FJFZsnSl0zjB9OqPYaBD7qmoVyImFvzi41usesV0julaAR9dfR15Xzv9sEruRDyk1nb+QaLU67T885GTls6YgcY+UiMa25M/pwGrbCfzkvR3e0jjtuaFtnwuagHTSb5y7boBH119HXhvwP487jJLsLJ4XnUkHX5sLbS61dpiAXRoZSCrFJ+EjpeU3puVfitngYNo6PJrAigKktmwjyQdZpfq30mmtulaAx9Zfx15Xzv+cyeuiBFUs9zq8Kq+XB9a4PVvph3GV4E3y8HENJrN55H1X2p8VyqSKwVusJDKzXOZzplWdzBUFK9e+B4+uv468xvI/b5xtSAkBHQaPvtqWzllVvEOxPbuiE6+j2pvjcKsbvI7txnRErgfH7LdXqjq0IokKzga14GzQ23SSbCQvO6r+Or7SMIr/efOkkqSdMnj9mBx2DRsiY29Uj6+qK9ZrssCKaptR6HKURdwUYeUWA2kPzVKQO8ku2nU3Anhs/XWkBx3F/7wJtCTTTIKftthue1ty9xvNYLY/zo5KSbIuKbXpbEdSyeRyYdAIwKY2neyoc3+k1XUaufYga3T9daMUx/r8z1s10ITknIO0kuoMt+TB8jK0lpayqqjsJ2qtXAYwBU932zinimgmd6mTRDnQfr88q36NAI+tv24E8Pr8zxtasBqx0+xHH9HhlrwsxxNUfKOHQaZBITNf0uccj8GXiVmXAuPEAKSdN/4GLHhs/XWj92dN/uetNuBMnVR+XWDc25JLjo5Mg5IZIq226tmCsip2zZliL213YrTlL2hcFjpCduyim3M7/eB16q/blQsv5X/esDRbtJeabLIosWy3ycavwLhtxdWzbMmHiBTiVjJo6lCLjXZsi7p9PEPnsq6X6wd4bP11i0rD5fzPm/0A6brrIsllenZs0lCJlU4abakR59enZKrKe3BZihbTxlyZ2zl1+g0wvgmA166/bhwDrcn/7Ddz0eWZuJvfSESug6NzZsox3Z04FIxz0mUjMwVOOVTq1CQ0AhdbBGVdjG/CgsfUX7esJl3K/7ytWHRv683praW/8iDOCqWLLhpljDY1ZpzK75QiaZoOTpLKl60auHS/97oBXrv+umU9+FL+5+NtLFgjqVLCdbmj7pY5zPCPLOHNCwXGOcLquOhi8CmCWvbcuO73XmMUPab+ug3A6/A/78Bwe0bcS2+tgHn4J5pyS2WbOck0F51Vq3LcjhLvZ67p1ABbaL2H67bg78BfjKi/jr3+T/ABV3ilLmNXTI2SpvxWBtt6/Z//D0z/FXaGbSBgylzlsEGp+5//xrd4/ae4d8DUUjlslfIYS3t06HZpvfQtvv0N7AHWqtjP2pW08QD/FLy//da38vo8PNlKHf5y37Dxdfe/oj4kVIgFq3koLReSR76W/bx//n9k8jonZxzWTANVwEniDsg87sOSd/z7//PvMp3jQiptGVWFX2caezzAXwfgtzYUvbr0iozs32c3Uge7varH+CNE6cvEYmzbPZ9hMaYDdjK4V2iecf6EcEbdUDVUARda2KzO/JtCuDbNQB/iTeL0EG1JSO1jbXS+nLxtPMDPw1fh5+EPrgSEKE/8Gry5A73ui87AmxwdatyMEBCPNOCSKUeRZ2P6Myb5MRvgCHmA9ywsMifU+AYXcB6Xa5GibUC5TSyerxyh0j6QgLVpdyhfArRTTLqQjwe4HOD9s92D4Ap54odXAPBWLAwB02igG5Kkc+piN4lvODIFGAZgT+EO4Si1s7fjSR7vcQETUkRm9O+MXyo9OYhfe4xt9STQ2pcZRLayCV90b4D3jR0DYAfyxJ+eywg2IL7NTMXna7S/RpQ63JhWEM8U41ZyQGjwsVS0QBrEKLu8xwZsbi4wLcCT+OGidPIOCe1PiSc9Qt+go+vYqB7cG+B9d8cAD+WJPz0Am2gxXgU9IneOqDpAAXOsOltVuMzpdakJXrdPCzXiNVUpCeOos5cxnpQT39G+XVLhs1osQVvJKPZyNq8HDwd4d7pNDuWJPxVX7MSzqUDU6gfadKiNlUFTzLeFHHDlzO4kpa7aiKhBPGKwOqxsBAmYkOIpipyXcQSPlRTf+Tii0U3EJGaZsDER2qoB3h2hu0qe+NNwUooYU8y5mILbJe6OuX+2FTKy7bieTDAemaQyQ0CPthljSWO+xmFDIYiESjM5xKd6Ik5lvLq5GrQ3aCMLvmCA9wowLuWJb9xF59hVVP6O0CrBi3ZjZSNOvRy+I6klNVRJYRBaEzdN+imiUXQ8iVF8fsp+W4JXw7WISW7fDh7lptWkCwZ4d7QTXyBPfJMYK7SijjFppGnlIVJBJBYj7eUwtiP1IBXGI1XCsjNpbjENVpSAJ2hq2LTywEly3hUYazt31J8w2+aiLx3g3fohXixPfOMYm6zCGs9LVo9MoW3MCJE7R5u/WsOIjrqBoHUO0bJE9vxBpbhsd3+Nb4/vtPCZ4oZYCitNeYuC/8UDvDvy0qvkiW/cgqNqRyzqSZa/s0mqNGjtKOoTm14zZpUauiQgVfqtQiZjq7Q27JNaSK5ExRcrGCXO1FJYh6jR6CFqK7bZdQZ4t8g0rSlPfP1RdBtqaa9diqtzJkQ9duSryi2brQXbxDwbRUpFMBHjRj8+Nt7GDKgvph9okW7LX47gu0SpGnnFQ1S1lYldOsC7hYteR574ZuKs7Ei1lBsfdz7IZoxzzCVmmVqaSySzQbBVAWDek+N4jh9E/4VqZrJjPwiv9BC1XcvOWgO8275CVyBPvAtTVlDJfZkaZGU7NpqBogAj/xEHkeAuJihWYCxGN6e8+9JtSegFXF1TrhhLGP1fak3pebgPz192/8gB4d/6WT7+GdYnpH7hH/DJzzFiYPn/vjW0SgNpTNuPIZoAEZv8tlGw4+RLxy+ZjnKa5NdFoC7UaW0aduoYse6+bXg1DLg6UfRYwmhGEjqPvF75U558SANrElK/+MdpXvmqBpaXOa/MTZaa1DOcSiLaw9j0NNNst3c+63c7EKTpkvKHzu6bPbP0RkuHAVcbRY8ijP46MIbQeeT1mhA+5PV/inyDdQipf8LTvMXbwvoDy7IruDNVZKTfV4CTSRUYdybUCnGU7KUTDxLgCknqUm5aAW6/1p6eMsOYsphLzsHrE0Y/P5bQedx1F/4yPHnMB3/IOoTU9+BL8PhtjuFKBpZXnYNJxTuv+2XqolKR2UQgHhS5novuxVySJhBNRF3SoKK1XZbbXjVwWNyOjlqWJjrWJIy+P5bQedyldNScP+HZ61xKSK3jyrz+NiHG1hcOLL/+P+PDF2gOkekKGiNWKgJ+8Z/x8Iv4DdQHzcpZyF4v19I27w9/yPGDFQvmEpKtqv/TLiWMfn4sofMm9eAH8Ao0zzh7h4sJqYtxZd5/D7hkYPneDzl5idlzNHcIB0jVlQ+8ULzw/nc5/ojzl2juE0apD7LRnJxe04dMz2iOCFNtGFpTuXA5AhcTRo8mdN4kz30nVjEC4YTZQy4gpC7GlTlrePKhGsKKgeXpCYeO0MAd/GH7yKQUlXPLOasOH3FnSphjHuDvEu4gB8g66oNbtr6eMbFIA4fIBJkgayoXriw2XEDQPJrQeROAlY6aeYOcMf+IVYTU3XFlZufMHinGywaW3YLpObVBAsbjF4QJMsVUSayjk4voPsHJOQfPWDhCgDnmDl6XIRerD24HsGtw86RMHOLvVSHrKBdeVE26gKB5NKHzaIwLOmrqBWJYZDLhASG16c0Tn+CdRhWDgWXnqRZUTnPIHuMJTfLVpkoYy5CzylHVTGZMTwkGAo2HBlkQplrJX6U+uF1wZz2uwS1SQ12IqWaPuO4baZaEFBdukksJmkcTOm+YJSvoqPFzxFA/YUhIvWxcmSdPWTWwbAKVp6rxTtPFUZfKIwpzm4IoMfaYQLWgmlG5FME2gdBgm+J7J+rtS/XBbaVLsR7bpPQnpMFlo2doWaVceHk9+MkyguZNCJ1He+kuHTWyQAzNM5YSUg/GlTk9ZunAsg1qELVOhUSAK0LABIJHLKbqaEbHZLL1VA3VgqoiOKXYiS+HRyaEKgsfIqX64HYWbLRXy/qWoylIV9gudL1OWBNgBgTNmxA6b4txDT4gi3Ri7xFSLxtXpmmYnzAcWDZgY8d503LFogz5sbonDgkKcxGsWsE1OI+rcQtlgBBCSOKD1mtqYpIU8cTvBmAT0yZe+zUzeY92fYjTtGipXLhuR0ePoHk0ofNWBX+lo8Z7pAZDk8mEw5L7dVyZZoE/pTewbI6SNbiAL5xeygW4xPRuLCGbhcO4RIeTMFYHEJkYyEO9HmJfXMDEj/LaH781wHHZEtqSQ/69UnGpzH7LKIAZEDSPJnTesJTUa+rwTepI9dLJEawYV+ZkRn9g+QirD8vF8Mq0jFQ29js6kCS3E1+jZIhgPNanHdHFqFvPJLHqFwQqbIA4jhDxcNsOCCQLDomaL/dr5lyJaJU6FxPFjO3JOh3kVMcROo8u+C+jo05GjMF3P3/FuDLn5x2M04xXULPwaS6hBYki+MrMdZJSgPHlcB7nCR5bJ9Kr5ACUn9jk5kivdd8tk95SOGrtqu9lr2IhK65ZtEl7ZKrp7DrqwZfRUSN1el7+7NJxZbywOC8neNKTch5vsTEMNsoCCqHBCqIPRjIPkm0BjvFODGtto99rCl+d3wmHkW0FPdpZtC7MMcVtGFQjJLX5bdQ2+x9ypdc313uj8xlsrfuLgWXz1cRhZvJYX0iNVBRcVcmCXZs6aEf3RQF2WI/TcCbKmGU3IOoDJGDdDub0+hYckt6PlGu2BcxmhbTdj/klhccLGJMcqRjMJP1jW2ETqLSWJ/29MAoORluJ+6LPffBZbi5gqi5h6catQpmOT7/OFf5UorRpLzCqcMltBLhwd1are3kztrSzXO0LUbXRQcdLh/RdSZ+swRm819REDrtqzC4es6Gw4JCKlSnjYVpo0xeq33PrADbFLL3RuCmObVmPN+24kfa+AojDuM4umKe2QwCf6EN906HwjujaitDs5o0s1y+k3lgbT2W2i7FJdnwbLXhJUBq/9liTctSmFC/0OqUinb0QddTWamtjbHRFuWJJ6NpqZ8vO3fZJ37Db+2GkaPYLGHs7XTTdiFQJ68SkVJFVmY6McR5UycflNCsccHFaV9FNbR4NttLxw4pQ7wJd066Z0ohVbzihaxHVExd/ay04oxUKWt+AsdiQ9OUyZ2krzN19IZIwafSTFgIBnMV73ADj7V/K8u1MaY2sJp2HWm0f41tqwajEvdHWOJs510MaAqN4aoSiPCXtN2KSi46dUxHdaMquar82O1x5jqhDGvqmoE9LfxcY3zqA7/x3HA67r9ZG4O6Cuxu12/+TP+eLP+I+HErqDDCDVmBDO4larujNe7x8om2rMug0MX0rL1+IWwdwfR+p1TNTyNmVJ85ljWzbWuGv8/C7HD/izjkHNZNYlhZcUOKVzKFUxsxxN/kax+8zPWPSFKw80rJr9Tizyj3o1gEsdwgWGoxPezDdZ1TSENE1dLdNvuKL+I84nxKesZgxXVA1VA1OcL49dFlpFV5yJMhzyCmNQ+a4BqusPJ2bB+xo8V9u3x48VVIEPS/mc3DvAbXyoYr6VgDfh5do5hhHOCXMqBZUPhWYbWZECwVJljLgMUWOCB4MUuMaxGNUQDVI50TQ+S3kFgIcu2qKkNSHVoM0SHsgoZxP2d5HH8B9woOk4x5bPkKtAHucZsdykjxuIpbUrSILgrT8G7G5oCW+K0990o7E3T6AdW4TilH5kDjds+H64kS0mz24grtwlzDHBJqI8YJQExotPvoC4JBq0lEjjQkyBZ8oH2LnRsQ4Hu1QsgDTJbO8fQDnllitkxuVskoiKbRF9VwzMDvxHAdwB7mD9yCplhHFEyUWHx3WtwCbSMMTCUCcEmSGlg4gTXkHpZXWQ7kpznK3EmCHiXInqndkQjunG5kxTKEeGye7jWz9cyMR2mGiFQ15ENRBTbCp+Gh86vAyASdgmJq2MC6hoADQ3GosP0QHbnMHjyBQvQqfhy/BUbeHd5WY/G/9LK/8Ka8Jd7UFeNWEZvzPb458Dn8DGLOe3/wGL/4xP+HXlRt+M1PE2iLhR8t+lfgxsuh7AfO2AOf+owWhSZRYQbd622hbpKWKuU+XuvNzP0OseRDa+mObgDHJUSc/pKx31QdKffQ5OIJpt8GWjlgTwMc/w5MPCR/yl1XC2a2Yut54SvOtMev55Of45BOat9aWG27p2ZVORRvnEk1hqWMVUmqa7S2YtvlIpspuF1pt0syuZS2NV14mUidCSfzQzg+KqvIYCMljIx2YK2AO34fX4GWdu5xcIAb8MzTw+j/lyWM+Dw/gjs4GD6ehNgA48kX/AI7XXM/XAN4WHr+9ntywqoCakCqmKP0rmQrJJEErG2Upg1JObr01lKQy4jskWalKYfJ/EDLMpjNSHFEUAde2fltaDgmrNaWQ9+AAb8I5vKjz3L1n1LriB/BXkG/wwR9y/oRX4LlioHA4LzP2inzRx/DWmutRweFjeP3tNeSGlaE1Fde0OS11yOpmbIp2u/jF1n2RRZviJM0yBT3IZl2HWImKjQOxIyeU325b/qWyU9Moj1o07tS0G7qJDoGHg5m8yeCxMoEH8GU45tnrNM84D2l297DQ9t1YP7jki/7RmutRweEA77/HWXOh3HCxkRgldDQkAjNTMl2Iloc1qN5JfJeeTlyTRzxURTdn1Ixv2uKjs12AbdEWlBtmVdk2k7FFwj07PCZ9XAwW3dG+8xKzNFr4EnwBZpy9Qzhh3jDXebBpYcpuo4fQ44u+fD1dweEnHzI7v0xuuOALRUV8rXpFyfSTQYkhd7IHm07jpyhlkCmI0ALYqPTpUxXS+z4jgDj1Pflvmz5ecuItpIBxyTHpSTGWd9g1ApfD/bvwUhL4nT1EzqgX7cxfCcNmb3mPL/qi9SwTHJ49oj5ZLjccbTG3pRmlYi6JCG0mQrAt1+i2UXTZ2dv9IlQpN5naMYtviaXlTrFpoMsl3bOAFEa8sqPj2WCMrx3Yjx99qFwO59Aw/wgx+HlqNz8oZvA3exRDvuhL1jMQHPaOJ0+XyA3fp1OfM3qObEVdhxjvynxNMXQV4+GJyvOEFqeQBaIbbO7i63rpxCltdZShPFxkjM2FPVkn3TG+Rp9pO3l2RzFegGfxGDHIAh8SteR0C4HopXzRF61nheDw6TFN05Ebvq8M3VKKpGjjO6r7nhudTEGMtYM92HTDaR1FDMXJ1eThsbKfywyoWwrzRSXkc51flG3vIid62h29bIcFbTGhfV+faaB+ohj7dPN0C2e2lC96+XouFByen9AsunLDJZ9z7NExiUc0OuoYW6UZkIyx2YUR2z6/TiRjyKMx5GbbjLHvHuf7YmtKghf34LJfx63Yg8vrvN2zC7lY0x0tvKezo4HmGYDU+Gab6dFL+KI761lDcNifcjLrrr9LWZJctG1FfU1uwhoQE22ObjdfkSzY63CbU5hzs21WeTddH2BaL11Gi7lVdlxP1nkxqhnKhVY6knS3EPgVGg1JpN5cP/hivujOelhXcPj8HC/LyI6MkteVjlolBdMmF3a3DbsuAYhL44dxzthWSN065xxUd55Lmf0wRbOYOqH09/o9WbO2VtFdaMb4qBgtFJoT1SqoN8wPXMoXLb3p1PUEhxfnnLzGzBI0Ku7FxrKsNJj/8bn/H8fPIVOd3rfrklUB/DOeO+nkghgSPzrlPxluCMtOnDL4Yml6dK1r3vsgMxgtPOrMFUZbEUbTdIzii5beq72G4PD0DKnwjmBULUVFmy8t+k7fZ3pKc0Q4UC6jpVRqS9Umv8bxw35flZVOU1X7qkjnhZlsMbk24qQ6Hz7QcuL6sDC0iHHki96Uh2UdvmgZnjIvExy2TeJdMDZNSbdZyAHe/Yd1xsQhHiKzjh7GxQ4yqMPaywPkjMamvqrYpmO7Knad+ZQC5msCuAPWUoxrxVhrGv7a+KLXFhyONdTMrZ7ke23qiO40ZJUyzgYyX5XyL0mV7NiUzEs9mjtbMN0dERqwyAJpigad0B3/zRV7s4PIfXSu6YV/MK7+OrYe/JvfGMn/PHJe2fyUdtnFrKRNpXV0Y2559aWPt/G4BlvjTMtXlVIWCnNyA3YQBDmYIodFz41PvXPSa6rq9lWZawZ4dP115HXV/M/tnFkkrBOdzg6aP4pID+MZnTJ1SuuB6iZlyiox4HT2y3YBtkUKWooacBQUDTpjwaDt5poBHl1/HXltwP887lKKXxNUEyPqpGTyA699UqY/lt9yGdlUKra0fFWS+36iylVWrAyd7Uw0CZM0z7xKTOduznLIjG2Hx8cDPLb+OvK6Bv7n1DYci4CxUuRxrjBc0bb4vD3rN5Zz36ntLb83eVJIB8LiIzCmn6SMPjlX+yNlTjvIGjs+QzHPf60Aj62/jrzG8j9vYMFtm1VoRWCJdmw7z9N0t+c8cxZpPeK4aTRicS25QhrVtUp7U578chk4q04Wx4YoQSjFryUlpcQ1AbxZ/XVMknIU//OGl7Q6z9Zpxi0+3yFhSkjUDpnCIUhLWVX23KQ+L9vKvFKI0ZWFQgkDLvBoylrHNVmaw10zwCPrr5tlodfnf94EWnQ0lFRWy8pW9LbkLsyUVDc2NSTHGDtnD1uMtchjbCeb1mpxFP0YbcClhzdLu6lfO8Bj6q+bdT2sz/+8SZCV7VIxtt0DUn9L7r4cLYWDSXnseEpOGFuty0qbOVlS7NNzs5FOGJUqQpl2Q64/yBpZf90sxbE+//PGdZ02HSipCbmD6NItmQ4Lk5XUrGpDMkhbMm2ZVheNYV+VbUWTcv99+2NyX1VoafSuC+AN6q9bFIMv5X/eagNWXZxEa9JjlMwNWb00akGUkSoepp1/yRuuqHGbUn3UdBSTxBU6SEVklzWRUkPndVvw2PrrpjvxOvzPmwHc0hpmq82npi7GRro8dXp0KXnUQmhZbRL7NEVp1uuZmO45vuzKsHrktS3GLWXODVjw+vXXLYx4Hf7njRPd0i3aoAGX6W29GnaV5YdyDj9TFkakje7GHYzDoObfddHtOSpoi2SmzJHrB3hM/XUDDEbxP2/oosszcRlehWXUvzHv4TpBVktHqwenFo8uLVmy4DKLa5d3RtLrmrM3aMFr1183E4sewf+85VWeg1c5ag276NZrM9IJVNcmLEvDNaV62aq+14IAOGFsBt973Ra8Xv11YzXwNfmft7Jg2oS+XOyoC8/cwzi66Dhmgk38kUmP1CUiYWOX1bpD2zWXt2FCp7uq8703APAa9dfNdscR/M/bZLIyouVxqJfeWvG9Je+JVckHQ9+CI9NWxz+blX/KYYvO5n2tAP/vrlZ7+8/h9y+9qeB/Hnt967e5mevX10rALDWK//FaAT5MXdBXdP0C/BAes792c40H+AiAp1e1oH8HgH94g/Lttx1gp63op1eyoM/Bvw5/G/7xFbqJPcCXnmBiwDPb/YKO4FX4OjyCb289db2/Noqicw4i7N6TVtoz8tNwDH+8x/i6Ae7lmaQVENzJFb3Di/BFeAwz+Is9SjeQySpPqbLFlNmyz47z5a/AF+AYFvDmHqibSXTEzoT4Gc3OALaqAP4KPFUJ6n+1x+rGAM6Zd78bgJ0a8QN4GU614vxwD9e1Amy6CcskNrczLx1JIp6HE5UZD/DBHrFr2oNlgG4Odv226BodoryjGJ9q2T/AR3vQrsOCS0ctXZi3ruLlhpFDJYl4HmYtjQCP9rhdn4suySLKDt6wLcC52h8xPlcjju1fn+yhuw4LZsAGUuo2b4Fx2UwQu77uqRHXGtg92aN3tQCbFexc0uk93vhTXbct6y7MulLycoUljx8ngDMBg1tvJjAazpEmOtxlzclvj1vQf1Tx7QlPDpGpqgtdSKz/d9/hdy1vTfFHSmC9dGDZbLiezz7Ac801HirGZsWjydfZyPvHXL/Y8Mjzg8BxTZiuwKz4Eb8sBE9zznszmjvFwHKPIWUnwhqfVRcd4Ck0K6ate48m1oOfrX3/yOtvAsJ8zsPAM89sjnddmuLuDPjX9Bu/L7x7xpMzFk6nWtyQfPg278Gn4Aekz2ZgOmU9eJ37R14vwE/BL8G3aibCiWMWWDQ0ZtkPMnlcGeAu/Ag+8ZyecU5BPuy2ILD+sQqyZhAKmn7XZd+jIMTN9eBL7x95xVLSX4On8EcNlXDqmBlqS13jG4LpmGbkF/0CnOi3H8ETOIXzmnmtb0a16Tzxj1sUvQCBiXZGDtmB3KAefPH94xcUa/6vwRn80GOFyjEXFpba4A1e8KQfFF+259tx5XS4egYn8fQsLGrqGrHbztr+uByTahWuL1NUGbDpsnrwBfePPwHHIf9X4RnM4Z2ABWdxUBlqQ2PwhuDxoS0vvqB1JzS0P4h2nA/QgTrsJFn+Y3AOjs9JFC07CGWX1oNX3T/yHOzgDjwPn1PM3g9Jk9lZrMEpxnlPmBbjyo2+KFXRU52TJM/2ALcY57RUzjObbjqxVw++4P6RAOf58pcVsw9Daje3htriYrpDOonre3CudSe6bfkTEgHBHuDiyu5MCsc7BHhYDx7ePxLjqigXZsw+ijMHFhuwBmtoTPtOxOrTvYJDnC75dnUbhfwu/ZW9AgYd+peL68HD+0emKquiXHhWjJg/UrkJYzuiaL3E9aI/ytrCvAd4GcYZMCkSQxfUg3v3j8c4e90j5ZTPdvmJJGHnOCI2nHS8081X013pHuBlV1gB2MX1YNmWLHqqGN/TWmG0y6clJWthxNUl48q38Bi8vtMKyzzpFdSDhxZ5WBA5ZLt8Jv3895DduBlgbPYAj8C4B8hO68FDkoh5lydC4FiWvBOVqjYdqjiLv92t8yPDjrDaiHdUD15qkSURSGmXJwOMSxWAXYwr3zaAufJ66l+94vv3AO+vPcD7aw/w/toDvL/2AO+vPcD7aw/wHuD9tQd4f+0B3l97gPfXHuD9tQd4f+0B3l97gG8LwP8G/AL8O/A5OCq0Ys2KIdv/qOIXG/4mvFAMF16gZD+2Xvu/B8as5+8bfllWyg0zaNO5bfXj6vfhhwD86/Aq3NfRS9t9WPnhfnvCIw/CT8GLcFTMnpntdF/z9V+PWc/vWoIH+FL3Znv57PitcdGP4R/C34avw5fgRVUInCwbsn1yyA8C8zm/BH8NXoXnVE6wVPjdeCI38kX/3+Ct9dbz1pTmHFRu+Hm4O9Ch3clr99negxfwj+ER/DR8EV6B5+DuQOnTgUw5rnkY+FbNU3gNXh0o/JYTuWOvyBf9FvzX663HH/HejO8LwAl8Hl5YLTd8q7sqA3wbjuExfAFegQdwfyDoSkWY8swzEf6o4Qyewefg+cHNbqMQruSL/u/WWc+E5g7vnnEXgDmcDeSGb/F4cBcCgT+GGRzDU3hZYburAt9TEtHgbM6JoxJ+6NMzzTcf6c2bycv2+KK/f+l6LBzw5IwfqZJhA3M472pWT/ajKxnjv4AFnMEpnBTPND6s2J7qHbPAqcMK74T2mZ4VGB9uJA465It+/eL1WKhYOD7xHOkr1ajK7d0C4+ke4Hy9qXZwpgLr+Znm/uNFw8xQOSy8H9IzjUrd9+BIfenYaylf9FsXr8fBAadnPIEDna8IBcwlxnuA0/Wv6GAWPd7dDIKjMdSWueAsBj4M7TOd06qBbwDwKr7oleuxMOEcTuEZTHWvDYUO7aHqAe0Bbq+HEFRzOz7WVoTDQkVds7A4sIIxfCQdCefFRoIOF/NFL1mPab/nvOakSL/Q1aFtNpUb/nFOVX6gzyg/1nISyDfUhsokIzaBR9Kxm80s5mK+6P56il1jXic7nhQxsxSm3OwBHl4fFdLqi64nDQZvqE2at7cWAp/IVvrN6/BFL1mPhYrGMBfOi4PyjuSGf6wBBh7p/FZTghCNWGgMzlBbrNJoPJX2mW5mwZfyRffXo7OFi5pZcS4qZUrlViptrXtw+GQoyhDPS+ANjcGBNRiLCQDPZPMHuiZfdFpPSTcQwwKYdRNqpkjm7AFeeT0pJzALgo7g8YYGrMHS0iocy+YTm2vyRUvvpXCIpQ5pe666TJrcygnScUf/p0NDs/iAI/nqDHC8TmQT8x3NF91l76oDdQGwu61Z6E0ABv7uO1dbf/37Zlv+Zw/Pbh8f1s4Avur6657/+YYBvur6657/+YYBvur6657/+YYBvur6657/+aYBvuL6657/+VMA8FXWX/f8zzcN8BXXX/f8zzcNMFdbf93zP38KLPiK6697/uebtuArrr/u+Z9vGmCusP6653/+1FjwVdZf9/zPN7oHX339dc//fNMu+irrr3v+50+Bi+Zq6697/uebA/jz8Pudf9ht/fWv517J/XUzAP8C/BAeX9WCDrUpZ3/dEMBxgPcfbtTVvsYV5Yn32u03B3Ac4P3b8I+vxNBKeeL9dRMAlwO83959qGO78sT769oB7g3w/vGVYFzKE++v6wV4OMD7F7tckFkmT7y/rhHgpQO8b+4Y46XyxPvrugBeNcB7BRiX8sT767oAvmCA9woAHsoT76+rBJjLBnh3txOvkifeX1dswZcO8G6N7sXyxPvr6i340gHe3TnqVfLE++uKAb50gHcXLnrX8sR7gNdPRqwzwLu7Y/FO5Yn3AK9jXCMGeHdgxDuVJ75VAI8ljP7PAb3/RfjcZfePHBB+79dpfpH1CanN30d+mT1h9GqAxxJGM5LQeeQ1+Tb+EQJrElLb38VHQ94TRq900aMIo8cSOo+8Dp8QfsB8zpqE1NO3OI9Zrj1h9EV78PqE0WMJnUdeU6E+Jjyk/hbrEFIfeWbvId8H9oTRFwdZaxJGvziW0Hn0gqYB/wyZ0PwRlxJST+BOw9m77Amj14ii1yGM/txYQudN0qDzGe4EqfA/5GJCagsHcPaEPWH0esekSwmjRxM6b5JEcZ4ww50ilvAOFxBSx4yLW+A/YU8YvfY5+ALC6NGEzhtmyZoFZoarwBLeZxUhtY4rc3bKnjB6TKJjFUHzJoTOozF2YBpsjcyxDgzhQ1YRUse8+J4wenwmaylB82hC5w0zoRXUNXaRBmSMQUqiWSWkLsaVqc/ZE0aPTFUuJWgeTei8SfLZQeMxNaZSIzbII4aE1Nmr13P2hNHjc9E9guYNCZ032YlNwESMLcZiLQHkE4aE1BFg0yAR4z1h9AiAGRA0jyZ03tyIxWMajMPWBIsxYJCnlITU5ShiHYdZ94TR4wCmSxg9jtB5KyPGYzymAYexWEMwAPIsAdYdV6aObmNPGD0aYLoEzaMJnTc0Ygs+YDw0GAtqxBjkuP38bMRWCHn73xNGjz75P73WenCEJnhwyVe3AEe8TtKdJcYhBl97wuhNAObK66lvD/9J9NS75v17wuitAN5fe4D31x7g/bUHeH/tAd5fe4D3AO+vPcD7aw/w/toDvL/2AO+vPcD7aw/w/toDvAd4f/24ABzZ8o+KLsSLS+Pv/TqTb3P4hKlQrTGh+fbIBT0Axqznnb+L/V2mb3HkN5Mb/nEHeK7d4IcDld6lmDW/iH9E+AH1MdOw/Jlu2T1xNmY98sv4wHnD7D3uNHu54WUuOsBTbQuvBsPT/UfzNxGYzwkP8c+Yz3C+r/i6DcyRL/rZ+utRwWH5PmfvcvYEt9jLDS/bg0/B64DWKrQM8AL8FPwS9beQCe6EMKNZYJol37jBMy35otdaz0Bw2H/C2Smc7+WGB0HWDELBmOByA3r5QONo4V+DpzR/hFS4U8wMW1PXNB4TOqYz9urxRV++ntWCw/U59Ty9ebdWbrgfRS9AYKKN63ZokZVygr8GZ/gfIhZXIXPsAlNjPOLBby5c1eOLvmQ9lwkOy5x6QV1j5TYqpS05JtUgUHUp5toHGsVfn4NX4RnMCe+AxTpwmApTYxqMxwfCeJGjpXzRF61nbcHhUBPqWze9svwcHJ+S6NPscKrEjug78Dx8Lj3T8D4YxGIdxmJcwhi34fzZUr7olevZCw5vkOhoClq5zBPZAnygD/Tl9EzDh6kl3VhsHYcDEb+hCtJSvuiV69kLDm+WycrOTArHmB5/VYyP6jOVjwgGawk2zQOaTcc1L+aLXrKeveDwZqlKrw8U9Y1p66uK8dEzdYwBeUQAY7DbyYNezBfdWQ97weEtAKYQg2xJIkuveAT3dYeLGH+ShrWNwZgN0b2YL7qznr3g8JYAo5bQBziPjx7BPZ0d9RCQp4UZbnFdzBddor4XHN4KYMrB2qHFRIzzcLAHQZ5the5ovui94PCWAPefaYnxIdzRwdHCbuR4B+tbiy96Lzi8E4D7z7S0mEPd+eqO3cT53Z0Y8SV80XvB4Z0ADJi/f7X113f+7p7/+UYBvur6657/+YYBvur6657/+aYBvuL6657/+aYBvuL6657/+aYBvuL6657/+aYBvuL6657/+VMA8FXWX/f8z58OgK+y/rrnf75RgLna+uue//lTA/CV1V/3/M837aKvvv6653++UQvmauuve/7nTwfAV1N/3fM/fzr24Cuuv+75nz8FFnxl9dc9//MOr/8/glixwRuUfM4AAAAASUVORK5CYII="}getSearchTexture(){return"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEIAAAAhCAAAAABIXyLAAAAAOElEQVRIx2NgGAWjYBSMglEwEICREYRgFBZBqDCSLA2MGPUIVQETE9iNUAqLR5gIeoQKRgwXjwAAGn4AtaFeYLEAAAAASUVORK5CYII="}dispose(){this.edgesRT.dispose(),this.weightsRT.dispose(),this.areaTexture.dispose(),this.searchTexture.dispose(),this.materialEdges.dispose(),this.materialWeights.dispose(),this.materialBlend.dispose(),this.fsQuad.dispose()}};var r2=wa(aS()),s2=wa(dM()),kE=wa(uS()),o2=wa(lS()),a2=wa(pM());function Ux(i,e){if(!(i>0)||!Number.isFinite(i)||!Number.isFinite(e))return{steps:1,limited:!1};let t=Math.min(Math.PI/48,2*Math.acos(Math.max(-1,1-Math.min(.005,i)/i))),n=Math.max(8,Math.ceil(Math.abs(e)/Math.max(t,1e-8)));return{steps:Math.min(512,n),limited:n>512}}var ON=Object.freeze({side:2,depthWrite:!0,transparent:!1,opacity:1});var mM=i=>i&&typeof i=="object"&&!Array.isArray(i)?i.quoted:i;function em(i,e,t,n){for(let r of["uuid","tstamp"]){let s=mM(i.find(o=>Array.isArray(o)&&mM(o[0])===r)?.[1]);if(typeof s=="string"&&s||typeof s=="number"&&Number.isFinite(s))return String(s)}if(!Number.isSafeInteger(t)||t<0||!Number.isSafeInteger(n)||n<0)throw TypeError("Choose bounded source pad occurrences.");return`display-pad:${t}:${n}`}function kx(i,e=0,t=e){let n=Number.POSITIVE_INFINITY,r=Number.NEGATIVE_INFINITY,s=0;for(let o of i)Number.isFinite(o)&&(o<n&&(n=o),o>r&&(r=o),s+=1);return s?{minimum:n,maximum:r,count:s}:{minimum:e,maximum:t,count:0}}var OP=new Set(["signal","power","mixed","jumper"]);function DP(i){return!i.name||i.name.includes("*")?!1:i.name.endsWith(".Cu")||OP.has(i.kind.toLowerCase())}function FP(i,e){return i==="F.Cu"?-1:e==="F.Cu"||i==="B.Cu"?1:e==="B.Cu"?-1:i.localeCompare(e,void 0,{numeric:!0})}function UP(i,e=[],t=[]){let n=[...i].filter(DP).map(l=>l.name),r=[...new Set(t)].filter(l=>l.endsWith(".Cu")&&!l.includes("*")),s=new Set(r),o=n.length>0&&n.every(l=>s.has(l))?[...r,...n.filter(l=>!s.has(l))]:n,a=new Set(o),c=[...new Set(e)].filter(l=>l.endsWith(".Cu")&&!l.includes("*")&&!a.has(l)).sort(FP);return[...o,...c]}var kP=.015;function ca(i){return Array.isArray(i)}function*BP(i){let e="",t=!1,n=!1;for(let r of i)n?(e+=r,n=!1):t&&r==="\\"?n=!0:r==='"'?t=!t:t?e+=r:r==="("||r===")"?(e&&(yield e,e=""),yield r):/\s/.test(r)?e&&(yield e,e=""):e+=r;e&&(yield e)}function zP(i){let e=[],t=[e];for(let r of i)if(r==="("){let s=[];t[t.length-1].push(s),t.push(s)}else r===")"?t.length>1&&t.pop():t[t.length-1].push(r);return e.find(ca)??[]}function Yt(i,e){return i.find(t=>ca(t)&&t[0]===e)}function Ur(i,e){return i.filter(t=>ca(t)&&t[0]===e)}function vn(i,e,t=0){let n=Number(tm(i?.[e]));return Number.isFinite(n)?n:t}function tm(i){return i&&typeof i=="object"&&!Array.isArray(i)&&!(i instanceof Float64Array)?i.quoted:typeof i=="string"||typeof i=="number"?i:void 0}function Gt(i,e,t=""){let n=tm(i?.[e]);return typeof n=="string"?n:typeof n=="number"?String(n):t}function Sn(i,e){let t=i?Yt(i,e):void 0;if(!(!t||t.length<3))return[vn(t,1),vn(t,2)]}function Bx(i,e,t){let n=Yt(Yt(i??[],e)??[],"xyz");return n?[vn(n,1,t[0]),vn(n,2,t[1]),vn(n,3,t[2])]:t}function bM(i){let e=i?Yt(i,"pts"):void 0;if(!e)return[];let t=e[1];if(t instanceof Float64Array){let n=[];for(let r=0;r<t.length;r+=2)n.push([t[r],t[r+1]]);return n}return Ur(e,"xy").map(n=>[vn(n,1),vn(n,2)])}function Dh(i,e){return Gt(Yt(i,"uuid"),1,Gt(Yt(i,"tstamp"),1,e))}function Fh(i,e="F.Cu"){return Gt(Yt(i,"layer"),1,Gt(Yt(i,"layers"),1,e))}function gM(i,e){return Gt(Ur(i,"property").find(t=>Gt(t,1).toLowerCase()===e.toLowerCase()),2)}function VP(i,e,t){let n=i[0],r=-t*Math.PI/180,s=Math.cos(r),o=Math.sin(r);return[e[0]+n*s-i[1]*o,e[1]+n*o+i[1]*s]}function MM(i,e,t){let[n,r]=i,[s,o]=e,[a,c]=t,l=2*(n*(o-c)+s*(c-r)+a*(r-o));if(Math.abs(l)<1e-9)return null;let u=((n*n+r*r)*(o-c)+(s*s+o*o)*(c-r)+(a*a+c*c)*(r-o))/l,h=((n*n+r*r)*(a-s)+(s*s+o*o)*(n-a)+(a*a+c*c)*(s-n))/l,d=Math.atan2(r-h,n-u),m=Math.atan2(o-h,s-u),g=Math.atan2(c-h,a-u),x=Math.PI*2,f=y=>(y%x+x)%x,p=f(m-d),v=f(g-d),_=p<=v?v:v-x;return{center:[u,h],radius:Math.hypot(n-u,r-h),sweep:_,startAngle:d}}function EM(i,e,t){let n=MM(i,e,t);if(!n)return[i,t];let{steps:r}=Ux(n.radius,n.sweep);return Array.from({length:r+1},(s,o)=>{let a=n.startAngle+n.sweep*o/r;return[n.center[0]+n.radius*Math.cos(a),n.center[1]+n.radius*Math.sin(a)]})}function HP(i,e){let t=Math.hypot(e[0]-i[0],e[1]-i[1]);return Array.from({length:65},(n,r)=>{let s=Math.PI*2*r/64;return[i[0]+t*Math.cos(s),i[1]+t*Math.sin(s)]})}function xM(i,e,t,n){let r=Gt(i,0),s=Fh(i,"Dwgs.User"),o=Yt(i,"stroke"),a=vn(Yt(o??i,"width"),1,.12),c=t??(h=>h),l,u;if(r.endsWith("_line")){let h=Sn(i,"start"),d=Sn(i,"end");if(!h||!d)return null;l="line",u=[c(h),c(d)]}else if(r.endsWith("_arc")){let h=Sn(i,"start"),d=Sn(i,"mid"),m=Sn(i,"end");if(!h||!d||!m)return null;l="arc",u=EM(h,d,m).map(c)}else if(r.endsWith("_circle")){let h=Sn(i,"center"),d=Sn(i,"end");if(!h||!d)return null;l="circle",u=HP(h,d).map(c)}else if(r.endsWith("_rect")){let h=Sn(i,"start"),d=Sn(i,"end");if(!h||!d)return null;l="rect",u=[c(h),c([d[0],h[1]]),c(d),c([h[0],d[1]]),c(h)]}else if(r.endsWith("_poly"))l="poly",u=bM(i).map(c),u.length>2&&u.push(u[0]);else return null;return{id:e,type:l,points:u,layer:s,width:a,ref:n}}function aa(i,e){return Math.hypot(i[0]-e[0],i[1]-e[1])<=kP}function Uh(i){let e=0;for(let t=0;t<i.length-1;t+=1)e+=i[t][0]*i[t+1][1]-i[t+1][0]*i[t][1];return e/2}function yM(i,e="Edge.Cuts"){let t=[],n=[];for(i.filter(r=>r.layer===e).forEach(r=>{let s=r.points;s.length>2&&aa(s[0],s[s.length-1])?t.push(s):s.length>1&&n.push([...s])});n.length;){let r=n.shift(),s=!0;for(;s&&!aa(r[0],r[r.length-1]);){s=!1;for(let o=0;o<n.length;o+=1){let a=n[o];if(aa(r[r.length-1],a[0]))r.push(...a.slice(1));else if(aa(r[r.length-1],a[a.length-1]))r.push(...a.slice(0,-1).reverse());else if(aa(r[0],a[a.length-1]))r.unshift(...a.slice(0,-1));else if(aa(r[0],a[0]))r.unshift(...a.slice(1).reverse());else continue;n.splice(o,1),s=!0;break}}r.length>2&&aa(r[0],r[r.length-1])&&(r[r.length-1]=r[0],t.push(r))}return t.sort((r,s)=>Math.abs(Uh(s))-Math.abs(Uh(r)))}function GP(i){let e=`${i.name} ${i.userName??""}`.trim().toLowerCase();return/rigid[ ._-]*flex/.test(e)?null:/(^|[ ._-])bend(?:[ ._-]|\d|$)/.test(e)?"bend":/(^|[ ._-])stiffener(?:[ ._-]|\d|$)/.test(e)?"stiffener":/(^|[ ._-])transition(?:[ ._-]|\d|$)/.test(e)?"transition":/(^|[ ._-])flex(?:ible)?(?:[ ._-]*(?:region|outline|area))?(?:[ ._-]|\d|$)/.test(e)?"flex":/(^|[ ._-])rigid(?:[ ._-]*(?:region|outline|area))?(?:[ ._-]|\d|$)/.test(e)?"rigid":null}function vM(i,e){let t=e==="r"||e==="radius"?/(?:^|[ _.-])(?:r|radius)\s*=?\s*(-?\d+(?:\.\d+)?)\s*(?:mm)?(?:$|[ _.-])/i:/(?:^|[ _.-])(?:a|angle)\s*=?\s*(-?\d+(?:\.\d+)?)\s*(?:deg)?(?:$|[ _.-])/i,n=Number(i.match(t)?.[1]);return Number.isFinite(n)?n:void 0}function _M(i){if(!i.length)return{minX:0,minY:0,maxX:100,maxY:70};let e=kx(i.map(n=>n[0])),t=kx(i.map(n=>n[1]));return{minX:e.minimum,minY:t.minimum,maxX:e.maximum,maxY:t.maximum}}function SM(i,e,t={}){let n=e||zP(BP(i));if(n[0]!=="kicad_pcb")throw new Error("The selected file is not a KiCad PCB document.");let r=[],s=[],o=[],a=[],c=[],l=[],u=new Set,h=[],d=new Set,m=[],g=[],x={};for(let B of n)ca(B)&&B[0]==="net"&&(x[Gt(B,1)]=Gt(B,2));let f=B=>{let j=Yt(B,"net"),J=Gt(j,1),ce=Gt(j,2)||Gt(Yt(B,"net_name"),1)||x[J]||(/^\d+$/.test(J)?"":J);return ce&&(x[J||ce]=ce),ce||void 0},p=-1;for(let B of n){if(!ca(B)||!B.length)continue;let j=Gt(B,0);if((j==="footprint"||j==="module")&&p++,j==="layers")B.slice(1).filter(ca).forEach(J=>{let se=Gt(J,1);se&&!se.includes("*")&&m.push({id:vn(J,0,m.length),name:se,kind:Gt(J,2)||"user",userName:Gt(J,3)||void 0}),se.endsWith(".Cu")&&!se.includes("*")&&d.add(se)});else if(j==="setup"){let J=Yt(B,"stackup");Ur(J??[],"layer").forEach(se=>{let ce=Gt(se,1);if(!ce)return;let me=Yt(se,"thickness"),Se=Yt(se,"epsilon_r"),V=Yt(se,"loss_tangent");g.push({name:ce,type:Gt(Yt(se,"type"),1,"unknown"),thickness:me?vn(me,1):void 0,material:Gt(Yt(se,"material"),1)||void 0,epsilonR:Se?vn(Se,1):void 0,lossTangent:V?vn(V,1):void 0}),ce.endsWith(".Cu")&&d.add(ce)})}else if(j==="segment"||j==="arc"){let J=vn(Yt(B,"width"),1,.25),se=Fh(B),ce=f(B),me=Dh(B,`track-${r.length+1}`);if(j==="arc"){let V=Sn(B,"start"),w=Sn(B,"mid"),O=Sn(B,"end"),W=V&&w&&O?MM(V,w,O):null;W&&Ux(W.radius,W.sweep).limited&&s.length<100&&s.push("Saved copper arc "+me+" exceeds the 512-segment/5 \xC2\xB5m chord budget and is shown approximately.")}let Se=j==="arc"?EM(Sn(B,"start")??[0,0],Sn(B,"mid")??[0,0],Sn(B,"end")??[0,0]):[Sn(B,"start"),Sn(B,"end")].filter(Boolean);for(let V=0;V<Se.length-1;V+=1)r.push({id:Se.length>2?`${me}:${V}`:me,start:Se[V],end:Se[V+1],width:J,layer:se,net:ce});d.add(se)}else if(j==="via"){let J=Sn(B,"at");if(!J)continue;let se=Yt(B,"layers")?.slice(1).map(tm).filter(ce=>typeof ce=="string")??["F.Cu","B.Cu"];o.push({id:Dh(B,`via-${o.length+1}`),at:J,size:vn(Yt(B,"size"),1,.8),drill:vn(Yt(B,"drill"),1,.4),layers:se,net:f(B)})}else if(j==="zone"){let J=Fh(B),se=Ur(B,"filled_polygon");(se.length?se:Ur(B,"polygon")).forEach((me,Se)=>{let V=Yt(me,"pts"),w=V?.[1]instanceof Float64Array?V[1].length/2:0;for(let ee of V||[])ca(ee)&&Gt(ee,0)==="xy"&&w++;if(w<3)return;let O=Fh(me,J),W=f(B);if(d.add(O),u.add(O),t.zonePoints===!1)return;let Q=bM(me);l.push({id:`${Dh(B,`zone-${l.length+1}`)}:${Se}`,points:Q,layer:O,net:W})})}else if(j.startsWith("gr_")){let J=xM(B,Dh(B,`drawing-${h.length+1}`));J&&h.push(J)}else if(j==="footprint"||j==="module"){let J=Sn(B,"at")??[0,0],se=Yt(B,"at"),ce=vn(se,3),me=Fh(B),Se=me.startsWith("B."),V=ue=>VP(ue,J,ce),w=gM(B,"Reference")||Gt(Ur(B,"fp_text").find(ue=>Gt(ue,1)==="reference"),2)||`REF${c.length+1}`,O=gM(B,"Value")||Gt(Ur(B,"fp_text").find(ue=>Gt(ue,1)==="value"),2)||"",W=[],Q=[];Ur(B,"pad").forEach((ue,H)=>{let Ie=Sn(ue,"at")??[0,0];Q.push(Ie);let Te=Yt(ue,"size"),Oe=Yt(ue,"layers")?.slice(1).map(tm).filter(F=>typeof F=="string")??[me],Re=Oe.includes("F.Cu")||Oe.includes("*.Cu")?Se?"B.Cu":"F.Cu":Oe.find(F=>F.endsWith(".Cu"))??me,We=Yt(ue,"drill"),Ae=Gt(We,1)==="oval"?vn(We,2):vn(We,1),Y={id:em(ue,w,p,H),name:Gt(ue,1,String(H+1)),at:V(Ie),width:vn(Te,1,1),height:vn(Te,2,1),rotation:vn(Yt(ue,"at"),3),shape:Gt(ue,3,"rect"),drill:Ae,layers:Oe,layer:Re,net:f(ue),ref:w};a.push(Y),W.push(Y),Oe.filter(F=>F.endsWith(".Cu")&&!F.includes("*")).forEach(F=>d.add(F))});for(let ue of["fp_line","fp_arc","fp_circle","fp_rect","fp_poly"])Ur(B,ue).forEach((H,Ie)=>{let Te=xM(H,`${w}:${ue}:${Ie}`,V,w);Te&&h.push(Te)});let ee=_M(Q),he=Q.length?Math.max(ee.maxX-ee.minX+2.5,2.5):5,Ce=Q.length?Math.max(ee.maxY-ee.minY+2.5,2.5):5,oe=Yt(B,"model");c.push({id:Dh(B,`component-${w}`),ref:w,value:O,library:Gt(B,1),at:J,width:he,height:Ce,rotation:ce,layer:me,model:!!oe,modelPath:Gt(oe,1),modelPaths:Ur(B,"model").map(ue=>Gt(ue,1)).filter(Boolean),modelOffset:Bx(oe,"offset",[0,0,0]),modelScale:Bx(oe,"scale",[1,1,1]),modelRotation:Bx(oe,"rotate",[0,0,0])}),d.add(me==="B.Cu"?"B.Cu":"F.Cu")}}let v=yM(h),_=v[0]??r.flatMap(B=>[B.start,B.end]).concat(a.map(B=>B.at)),y=_M(_),b=new Set(m.map(B=>B.name)),E=Math.max(-1,...m.map(B=>B.id))+1;[...r.map(B=>B.layer),...a.flatMap(B=>B.layers),...u,...h.map(B=>B.layer)].forEach(B=>{!B||B.includes("*")||b.has(B)||(b.add(B),m.push({id:E++,name:B,kind:B.endsWith(".Cu")?"signal":"user"}))});let A=UP(m,d,g.map(B=>B.name)),T=[],M=[];m.forEach(B=>{let j=GP(B);if(!j)return;let J=B.userName||B.name;if(j==="bend"){h.filter(se=>se.layer===B.name&&se.points.length>=2).forEach((se,ce)=>{M.push({id:`bend:${se.id}`,name:`${J} ${ce+1}`,points:se.points,sourceLayer:B.name,radiusMm:vM(J,"radius"),angleDeg:vM(J,"angle")})});return}yM(h,B.name).forEach((se,ce)=>{T.push({id:`region:${B.id}:${ce}`,name:`${J}${ce?` ${ce+1}`:""}`,kind:j,outline:se,sourceLayer:B.name,source:"kicad-user-layer"})})});let S=v[0]??[],C=Math.abs(Uh(S)),N=T.filter(B=>B.kind==="flex").reduce((B,j)=>B+Math.abs(Uh(j.outline)),0),I=N>0,L=T.some(B=>B.kind==="rigid"),q=I?!L&&C>0&&N>=C*.92?"flex":"rigid-flex":"rigid",K=[...T];return S.length&&q!=="flex"&&!K.some(B=>B.kind==="rigid"&&Math.abs(Uh(B.outline))>=C*.92)&&K.unshift({id:"region:implicit-rigid-board",name:"Rigid board",kind:"rigid",outline:S,sourceLayer:"Edge.Cuts",source:"implicit-board-outline"}),{width:Math.max(y.maxX-y.minX,1),height:Math.max(y.maxY-y.minY,1),bounds:y,outlineLoops:v,tracks:r,geometryWarnings:s,vias:o,pads:a,components:c,zones:l,drawings:h,layers:A,layerDefinitions:m,stackup:g,nets:x,technology:q,regions:K,bendLines:M}}var l2=wa(cS());var TM=i=>i&&(i.type==="Component"||typeof i.library=="string"),zc=i=>{for(let e=i;e;e=e.parent)if(!e.visible)return!1;return!0},zx=(i,e)=>{if(typeof i!="string"||!i||i.length>128||/[\x00-\x1f\x7f]/.test(i))throw new TypeError("Choose a bounded "+e+".");return i},AM={top:[0,0,1],bottom:[0,0,-1],front:[0,-1,0],back:[0,1,0],left:[-1,0,0],right:[1,0,0]};function WP(i,e,t){let n=e?.getAttribute?.("position"),r=e?.index;if(!n||n.itemSize<3||e.morphAttributes?.position?.length)throw new Error("Demo faces require a static triangle mesh.");let s=Math.floor((r?r.count:n.count)/3);if(!s||s>5e4)throw new Error("Selected mesh exceeds the 50,000-triangle face-selection budget.");let o=Math.ceil((e.drawRange?.start||0)/3),a=Math.min(s,Math.floor(((e.drawRange?.start||0)+(Number.isFinite(e.drawRange?.count)?e.drawRange.count:s*3))/3));if(!Number.isInteger(t)||t<o||t>=a)throw new Error("Choose a visible triangle face.");let c=w=>new i.Vector3().fromBufferAttribute(n,r?r.getX(w):w),l=[c(t*3),c(t*3+1),c(t*3+2)],u=new i.Vector3().subVectors(l[1],l[0]).cross(new i.Vector3().subVectors(l[2],l[0]));if(u.lengthSq()<1e-20)throw new Error("The selected triangle has no usable planar area.");u.normalize(),e.computeBoundingBox();let h=e.boundingBox.getSize(new i.Vector3).length(),d=Math.max(1e-7,h*1e-7),m=u.dot(l[0]),g=e.groups||[];if(g.length>256)throw new Error("Selected mesh exceeds the 256 material-group face budget.");let x=new Int32Array(s);x.fill(-1);for(let w of g){if(!Number.isInteger(w.start)||!Number.isInteger(w.count)||w.start<0||w.count<0||w.start%3||w.count%3||!Number.isInteger(w.materialIndex)||w.materialIndex<0||w.materialIndex>1e6)throw new Error("Unsupported triangle material groups.");for(let O=w.start/3;O<Math.min(s,(w.start+w.count)/3);O++){if(x[O]!==-1)throw new Error("Overlapping material groups make the selected face ambiguous.");x[O]=w.materialIndex}}let f=w=>x[w],p=f(t);if(g.length&&p===-1)throw new Error("The selected face has no supported material group.");let v=w=>[w.x,w.y,w.z].map(O=>Math.round(O/d)).join(","),_=(w,O)=>w<O?w+"|"+O:O+"|"+w,y=new Map,b=new Map,E=new i.Vector3,A=new i.Vector3;for(let w=o;w<a;w++){if(f(w)!==p)continue;let O=[c(w*3),c(w*3+1),c(w*3+2)];if(O.some(he=>!Number.isFinite(he.x)||!Number.isFinite(he.y)||!Number.isFinite(he.z)||Math.abs(u.dot(he)-m)>d))continue;let W=E.subVectors(O[1],O[0]).cross(A.subVectors(O[2],O[0]));if(W.lengthSq()<1e-20||W.normalize().dot(u)<.99999)continue;let Q=O.map(v),ee=[_(Q[0],Q[1]),_(Q[1],Q[2]),_(Q[2],Q[0])];y.set(w,{points:O,edges:ee});for(let he of ee){let Ce=b.get(he)||[];Ce.push(w),b.set(he,Ce)}}let T=[t],M=new Set(T),S=new Set,C=new Set;for(let w=0;w<T.length;w++){let O=T[w],W=y.get(O);if(W){S.add(O);for(let Q of W.edges)if(!C.has(Q)){C.add(Q);for(let ee of b.get(Q)||[])M.has(ee)||(M.add(ee),T.push(ee))}}}if(!S.size)throw new Error("No connected planar face was found.");let N=new i.Vector3(Math.abs(u.x)<.9?1:0,Math.abs(u.x)<.9?0:1,0);N.addScaledVector(u,-N.dot(u)).normalize();let I=new i.Vector3().crossVectors(u,N).normalize(),L=1/0,q=-1/0,K=1/0,B=-1/0,j=0,J=[];for(let w of S){let O=y.get(w).points;j+=new i.Vector3().subVectors(O[1],O[0]).cross(new i.Vector3().subVectors(O[2],O[0])).length()/2;for(let W of O){let Q=W.dot(N),ee=W.dot(I);L=Math.min(L,Q),q=Math.max(q,Q),K=Math.min(K,ee),B=Math.max(B,ee),J.push(W)}}let se=q-L,ce=B-K;if(!(se>d&&ce>d&&j>d*d))throw new Error("The selected face is too small for a display.");let me=new Float32Array(J.length*3),Se=new Float32Array(J.length*2);J.forEach((w,O)=>{me.set([w.x,w.y,w.z],O*3),Se.set([(w.dot(N)-L)/se,(w.dot(I)-K)/ce],O*2)});let V=u.clone().multiplyScalar(m).addScaledVector(N,(L+q)/2).addScaledVector(I,(K+B)/2);return{positions:me,uvs:Se,normal:u,u:N,v:I,center:V,width:se,height:ce,area:j,triangles:S.size,faceIndex:Math.min(...S),faceIndices:[...S]}}function wM(i,{scene:e,objects:t,document:n=globalThis.document,invalidate:r=()=>{},onError:s=()=>{}}){if(!e?.add||typeof t!="function"||!n?.createElement)throw new TypeError("Choose a 3D scene, saved component meshes and document.");let o=new i.Group;o.name="Scripted demo surfaces",e.add(o);let a="demo-face-"+Math.random().toString(36).slice(2)+"-",c=new Map,l=new Map,u=0,h=!1,d=null,m=null,g=0,x=0,f=()=>{if(h)throw new Error("Demo surfaces have been disposed.")};function p(w,O){w.updateWorldMatrix(!0,!1);let W=w.matrixWorld.clone();if(w.isInstancedMesh){if(!Number.isInteger(O)||O<0||O>=w.count)return null;let Q=new i.Matrix4;if(w.getMatrixAt(O,Q),Math.abs(Q.determinant())<1e-15)return null;W.multiply(Q)}return Math.abs(W.determinant())<1e-15?null:W}function v(w,O){return w?.isInstancedMesh?w.userData.records?.[O]:w?.userData.record}function _(w,O,W){if(!t().includes(w)||!zc(w)||w.isSkinnedMesh)throw new Error("Choose a visible static component face.");let Q=v(w,O),ee=p(w,O);if(!TM(Q)||!ee)throw new Error("Choose a visible component body, not a pad or board surface.");let he=WP(i,w.geometry,W),Ce=he.normal.clone().applyMatrix3(new i.Matrix3().getNormalMatrix(ee)).normalize(),oe=new i.Vector3().applyMatrix4(ee),ue=he.u.clone().multiplyScalar(he.width).applyMatrix4(ee).sub(oe),H=he.v.clone().multiplyScalar(he.height).applyMatrix4(ee).sub(oe);return{object:w,instanceId:O,record:Q,geometry:w.geometry,patch:he,normal:Ce,width:ue.length(),height:H.length(),key:w.uuid+":"+O+":"+he.faceIndex}}function y(w){let O=[...c.values()].reduce((Q,ee)=>Q+ee.patch.triangles,0);for(;c.size>=128||O+w.patch.triangles>1e5;){let Q=[...c].find(([,ee])=>![...l.values()].some(he=>he.face===ee));if(!Q)throw new Error("Selected demo faces exceed the geometry budget.");O-=Q[1].patch.triangles,c.delete(Q[0])}let W=a+ ++u;return w.token=W,c.set(W,w),b(w)}function b(w){let O=p(w.object,w.instanceId);return O?Object.freeze({token:w.token,shape:"face",uuid:String(w.record.uuid||w.record.id||""),reference:String(w.record.ref||""),center:w.patch.center.clone().applyMatrix4(O).toArray(),normal:w.patch.normal.clone().applyMatrix3(new i.Matrix3().getNormalMatrix(O)).normalize().toArray(),up:w.patch.v.clone().transformDirection(O).toArray(),right:w.patch.u.clone().transformDirection(O).toArray(),width:w.width,height:w.height,triangles:w.patch.triangles}):null}function E(w){if(f(),!w||!Number.isInteger(w.faceIndex))throw new Error("Select a component triangle face.");return y(_(w.object,w.instanceId,w.faceIndex))}function A(w){if(!w||typeof w!="object"||!AM[w.face||"top"])throw new TypeError("Choose a saved component and top/bottom/front/back/left/right face.");let O=w.uuid===void 0?null:zx(w.uuid,"component UUID"),W=w.reference===void 0?null:zx(w.reference,"component reference");if(!O&&!W)throw new TypeError("A demo face needs a component UUID or unique reference.");let Q=[],ee=new Set,he=0;for(let Ce of t()){let oe=Ce.userData.records||[Ce.userData.record];for(let ue=0;ue<oe.length;ue++){if(++he>2e5)throw new Error("Component face lookup exceeds its record budget.");let H=oe[ue];if(!TM(H)||O&&O!==(H.uuid||H.id)||W&&W!==H.ref)continue;let Ie=Ce.isInstancedMesh?ue:void 0;if(!zc(Ce)||!p(Ce,Ie))continue;let Te=String(H.uuid||H.id||"")+"|"+String(H.ref||"")+"|"+JSON.stringify(H.at||[]);ee.add(Te),Q.push({object:Ce,instanceId:Ie})}}if(ee.size!==1)throw new Error("The component anchor is absent or ambiguous.");return Q}function T(w){let O=A(w),W=new i.Vector3(...AM[w.face||"top"]),Q=null,ee=25e4;for(let he of O){let Ce=he.object.geometry,oe=Ce?.getAttribute?.("position"),ue=Ce?.index;if(!oe||he.object.isSkinnedMesh||Ce.morphAttributes?.position?.length)continue;let H=Math.floor((ue?ue.count:oe.count)/3);if(H>5e4)throw new Error("Selected mesh exceeds the 50,000-triangle face-selection budget.");let Ie=p(he.object,he.instanceId),Te=new i.Matrix3().getNormalMatrix(Ie),Oe=new Set,Re=Math.ceil((Ce.drawRange?.start||0)/3),We=Math.min(H,Math.floor(((Ce.drawRange?.start||0)+(Number.isFinite(Ce.drawRange?.count)?Ce.drawRange.count:H*3))/3));for(let Ae=Re;Ae<We;Ae++){if(Oe.has(Ae))continue;let Y=new i.Vector3().fromBufferAttribute(oe,ue?ue.getX(Ae*3):Ae*3),F=new i.Vector3().fromBufferAttribute(oe,ue?ue.getX(Ae*3+1):Ae*3+1),D=new i.Vector3().fromBufferAttribute(oe,ue?ue.getX(Ae*3+2):Ae*3+2);if(F.sub(Y).cross(D.sub(Y)).normalize().applyMatrix3(Te).normalize().dot(W)<.9999)continue;if((ee-=H)<0)throw new Error("Automatic face selection exceeds its triangle-work budget. Select an actual face manually.");let U=_(he.object,he.instanceId,Ae);for(let ae of U.patch.faceIndices)Oe.add(ae);let X=p(U.object,U.instanceId),Z=new i.Vector3().applyMatrix4(X),$=U.patch.u.clone().multiplyScalar(U.patch.width).applyMatrix4(X).sub(Z),te=U.patch.v.clone().multiplyScalar(U.patch.height).applyMatrix4(X).sub(Z);U.worldArea=U.patch.area*$.cross(te).length()/(U.patch.width*U.patch.height),U.depth=U.patch.center.clone().applyMatrix4(X).dot(W),(!Q||U.depth>Q.depth+1e-5||Math.abs(U.depth-Q.depth)<=1e-5&&U.worldArea>Q.worldArea)&&(Q=U)}}if(!Q)throw new Error("This component has no supported planar face in that direction. Select an actual face instead.");return y(Q)}function M(w){let O=w.face||w.anchor&&T(w.anchor),W=typeof O=="string"?O:O?.token,Q=c.get(W);if(!Q)throw new Error("The selected face belongs to another or closed 3D view. Select it again.");if(!t().includes(Q.object)||!zc(Q.object)||Q.object.geometry!==Q.geometry||!p(Q.object,Q.instanceId))throw new Error("The selected source geometry is no longer available. Select it again.");return Q}function S(w,O,W,Q,ee={}){if(typeof d=="function")try{d({id:w.id,type:O,...O==="change"?{value:w.value}:{},...Q?{uv:{x:Q.x,y:Q.y}}:{},source:"pointer",originalEvent:W,...ee})}catch(he){d=null;try{s(he)}catch{}}}function C(w){let O=w.width??(w.kind==="led"?32:128),W=w.height??(w.kind==="led"?32:w.kind==="button"?64:128);if(!Number.isInteger(O)||!Number.isInteger(W)||O<1||W<1||O>1024||W>1024)throw new TypeError("Demo canvases need integer dimensions from 1 to 1024.");return{width:O,height:W}}function N(w){if(w.kind==="led"&&!w.canvas){w.material.color.set(w.color).multiplyScalar(w.on?w.brightness:.025);return}let O=w.canvas.getContext("2d");if(!O)throw new Error("Canvas drawing is unavailable.");w.kind!=="display"&&(O.clearRect(0,0,w.canvas.width,w.canvas.height),w.kind==="led"?(O.fillStyle=w.color,O.fillRect(0,0,w.canvas.width,w.canvas.height),w.material.color.setScalar(w.on?w.brightness:.025)):(O.fillStyle=w.pressed?"#77d4df":"#182f3e",O.fillRect(0,0,w.canvas.width,w.canvas.height),O.fillStyle=w.pressed?"#10202c":"#e1eaf3",O.textAlign="center",O.textBaseline="middle",O.font="600 "+Math.max(9,Math.round(w.canvas.height*.22))+"px system-ui",O.fillText(w.kind==="knob"?String(w.value):w.label,w.canvas.width/2,w.canvas.height/2,w.canvas.width-8)),w.texture.needsUpdate=!0)}function I(w){if(w.bindings){let Q=!1;for(let ee of w.bindings){let he=p(ee.object,ee.instanceId);ee.mesh.visible=t().includes(ee.object)&&ee.object.geometry===ee.geometry&&zc(ee.object)&&!!he,ee.mesh.visible&&(ee.mesh.matrix.copy(he),ee.mesh.matrixWorldNeedsUpdate=!0,Q=!0)}return Q}let O=w.face,W=p(O.object,O.instanceId);if(w.mesh.visible=t().includes(O.object)&&O.object.geometry===O.geometry&&zc(O.object)&&!!W,w.mesh.visible){let Q=O.patch.normal.clone().applyMatrix3(new i.Matrix3().getNormalMatrix(W)).normalize(),ee=Math.max(1e-5,Math.min(.006,Math.min(O.width,O.height)*.002));w.mesh.matrix.copy(W),w.mesh.matrix.elements[12]+=Q.x*ee,w.mesh.matrix.elements[13]+=Q.y*ee,w.mesh.matrix.elements[14]+=Q.z*ee,w.mesh.matrixWorldNeedsUpdate=!0}return!w.mesh.visible&&m?.entry===w&&ce("cancel",null),w.mesh.visible}function L(w){if(!(!l.has(w.id)||l.get(w.id)!==w)&&(m?.entry===w&&ce("cancel",null),l.get(w.id)===w)){l.delete(w.id),g-=w.pixels,x-=w.triangles;for(let O of w.meshes||[w.mesh])O.removeFromParent();w.texture?.dispose(),w.material.dispose(),w.bindings||w.mesh.geometry.dispose(),r()}}function q(w){if(typeof w!="string"||w.length>64||!/^#[0-9a-f]{3}(?:[0-9a-f]{3})?$/i.test(w)&&!Object.hasOwn(i.Color.NAMES,w.toLowerCase()))throw new TypeError("Choose a hex or named LED color.");return"#"+new i.Color(w).getHexString()}function K(w,O={}){let W={on:O.on===void 0?w.on:!!O.on,color:O.color===void 0?w.color:q(O.color),brightness:O.brightness===void 0?w.brightness:O.brightness};if(!Number.isFinite(W.brightness)||W.brightness<0||W.brightness>1)throw new TypeError("Choose LED brightness from 0 to 1.");Object.assign(w,W),N(w),r()}function B(w){let O=new i.Box3;for(let ee of w.bindings){let he=p(ee.object,ee.instanceId);he&&(ee.geometry.boundingBox||ee.geometry.computeBoundingBox(),O.union(ee.geometry.boundingBox.clone().applyMatrix4(he)))}if(O.isEmpty())return null;let W=O.getSize(new i.Vector3),Q=w.bindings[0].record;return{shape:"component",uuid:String(Q.uuid||Q.id||""),reference:String(Q.ref||""),center:O.getCenter(new i.Vector3).toArray(),normal:null,width:W.x,height:W.y,triangles:w.triangles}}function j(w,O){let W=A(O.anchor),Q=l.get(w),ee=W.reduce((ue,H)=>{let Ie=H.object.geometry;if(H.object.isSkinnedMesh||Ie.morphAttributes?.position?.length)throw new Error("LED body binding requires static geometry.");return ue+Math.floor((Ie.index?.count||Ie.getAttribute("position")?.count||0)/3)},0);if(!ee||ee>5e4||l.size-(Q?1:0)>=64||x-(Q?.triangles||0)+ee>1e5)throw new Error("LED component geometry exceeds the demo surface budget.");let he=q(O.color||"#59f3a5");if(O.brightness!==void 0&&(!Number.isFinite(O.brightness)||O.brightness<0||O.brightness>1))throw new TypeError("Choose LED brightness from 0 to 1.");let Ce=new i.MeshBasicMaterial({color:16777215,depthTest:!0,depthWrite:!0,toneMapped:!1,polygonOffset:!0,polygonOffsetFactor:-1,polygonOffsetUnits:-2}),oe={id:w,kind:"led",bindings:W,material:Ce,pixels:0,triangles:ee,on:!1,brightness:1,color:he};for(let ue of W)ue.geometry=ue.object.geometry,ue.record=v(ue.object,ue.instanceId),ue.mesh=new i.Mesh(ue.geometry,Ce),ue.mesh.matrixAutoUpdate=!1,ue.mesh.userData.demoSurface=w,ue.mesh.renderOrder=10;oe.meshes=W.map(ue=>ue.mesh),K(oe,O),Q&&L(Q),l.set(w,oe),x+=ee;for(let ue of oe.meshes)o.add(ue);return I(oe),r(),{get face(){return B(oe)},getFace(){return B(oe)},setLED(ue){if(f(),l.get(w)!==oe)throw new Error("LED surface is closed.");K(oe,ue)},update(){return f(),I(oe)},setValue(){throw new Error("An LED uses setLED().")},isAvailable(){return!h&&l.get(w)===oe&&I(oe)},dispose(){L(oe)}}}function J(w,O={}){if(f(),zx(w,"demo surface ID"),!["led","display","button","knob"].includes(O.kind))throw new TypeError("Choose an LED, display, button or knob.");if(O.kind==="led"&&!O.face&&O.anchor&&!O.anchor.face)return j(w,O);let W=M(O),Q=l.get(w),ee=C(O),he=ee.width*ee.height;if(l.size-(Q?1:0)>=64||g-(Q?.pixels||0)+he>4194304||x-(Q?.triangles||0)+W.patch.triangles>1e5)throw new Error("Demo surfaces exceed their canvas or geometry budget.");if([...l.values()].some(D=>D!==Q&&D.face?.key===W.key))throw new Error("This geometry face already has a demo surface.");let Ce=O.kind==="led"?q(O.color||"#59f3a5"):"#59f3a5";if(O.brightness!==void 0&&(!Number.isFinite(O.brightness)||O.brightness<0||O.brightness>1))throw new TypeError("Choose LED brightness from 0 to 1.");let oe=n.createElement("canvas");oe.width=ee.width,oe.height=ee.height;let ue=O.kind==="display"?n.createElement("canvas"):oe;ue.width=ee.width,ue.height=ee.height;let H=new i.CanvasTexture(ue);H.colorSpace=i.SRGBColorSpace,H.minFilter=i.LinearFilter,H.magFilter=O.mode==="matrix"?i.NearestFilter:i.LinearFilter,H.generateMipmaps=!1;let Ie=new i.BufferGeometry;Ie.setAttribute("position",new i.BufferAttribute(W.patch.positions.slice(),3)),Ie.setAttribute("uv",new i.BufferAttribute(W.patch.uvs.slice(),2)),Ie.computeVertexNormals();let Te=new i.MeshBasicMaterial({map:H,color:16777215,side:i.FrontSide,depthTest:!0,depthWrite:!0,toneMapped:!1,polygonOffset:!0,polygonOffsetFactor:-1,polygonOffsetUnits:-2}),Oe=new i.Mesh(Ie,Te);Oe.matrixAutoUpdate=!1,Oe.userData.demoSurface=w,Oe.renderOrder=10;let Re=O.min??0,We=O.max??100,Ae=O.step??1;if(![Re,We,Ae].every(Number.isFinite)||We<=Re||Ae<=0)throw H.dispose(),Te.dispose(),Ie.dispose(),new TypeError("Choose a finite increasing knob range and positive step.");let Y=D=>Math.max(Re,Math.min(We,Re+Math.round((D-Re)/Ae)*Ae)),F={id:w,kind:O.kind,face:W,canvas:oe,uploadCanvas:ue,texture:H,material:Te,mesh:Oe,pixels:he,triangles:W.patch.triangles,min:Re,max:We,step:Ae,clamp:Y,value:Y(Number.isFinite(O.value)?O.value:Re),pressed:!1,color:Ce,on:!!O.on,brightness:Number.isFinite(O.brightness)?Math.max(0,Math.min(1,O.brightness)):1,label:typeof O.label=="string"?O.label.slice(0,64):w};try{N(F)}catch(D){throw H.dispose(),Te.dispose(),Ie.dispose(),D}return Q&&L(Q),l.set(w,F),g+=he,x+=W.patch.triangles,o.add(Oe),I(F),r(),{canvas:oe,get face(){return b(W)},getFace(){return b(W)},update(){if(f(),l.get(w)!==F)throw new Error("Demo surface is closed.");let D=C({width:oe.width,height:oe.height}),P=D.width*D.height;if(g-F.pixels+P>4194304)throw new Error("Demo surfaces exceed their canvas budget.");if(F.kind==="display"){let U=oe.getContext("2d");if(!U)throw new Error("Canvas drawing is unavailable.");try{U.getImageData(0,0,1,1)}catch(Z){let $=new Error("Display graphics must be CORS-enabled and origin-clean before upload.");throw $.cause=Z,$}let X=ue.getContext("2d");if(!X)throw new Error("Canvas upload is unavailable.");ue.width!==oe.width&&(ue.width=oe.width),ue.height!==oe.height&&(ue.height=oe.height),X.clearRect(0,0,ue.width,ue.height),X.drawImage(oe,0,0)}return g+=P-F.pixels,F.pixels=P,H.needsUpdate=!0,r(),I(F)},setLED(D={}){if(f(),F.kind!=="led"||l.get(w)!==F)throw new Error("Choose an active LED surface.");K(F,D)},setValue(D){if(f(),!Number.isFinite(D)||l.get(w)!==F)throw new TypeError("Choose a finite active control value.");return F.value=F.clamp(D),F.kind==="button"&&(F.pressed=!!F.value),N(F),r(),F.value},isAvailable(){return!h&&l.get(w)===F&&I(F)},dispose(){L(F)}}}function se(w){let O=w?.object?.userData?.demoSurface&&l.get(w.object.userData.demoSurface);return O&&zc(w.object)&&(O.mesh===w.object||O.meshes?.includes(w.object))&&I(O)?O:null}function ce(w,O){let W=m;return W?(m=null,W.entry.pressed=!1,N(W.entry),r(),S(W.entry,"release",O,W.uv,{cancelled:w==="cancel"}),!0):!1}function me(w,O,W={}){if(h)return!1;if(O==="release"||O==="cancel")return!m||W.pointerId!==void 0&&W.pointerId!==m.pointerId?!1:ce(O,W);if(O==="move"){if(!m||W.pointerId!==void 0&&W.pointerId!==m.pointerId)return!1;let ee=m.entry;if(ee.kind==="knob"&&Number.isFinite(W.clientY)){let he=ee.clamp(m.startValue+(m.startY-W.clientY)*ee.step);he!==ee.value&&(ee.value=he,N(ee),r(),S(ee,"change",W,w?.uv||m.uv))}return!0}if(O!=="press"||m)return!1;let Q=se(w);return!Q||Q.kind==="led"?!1:(m={entry:Q,pointerId:W.pointerId,startY:Number.isFinite(W.clientY)?W.clientY:0,startValue:Q.value,uv:w.uv?{x:w.uv.x,y:w.uv.y}:void 0},Q.pressed=!0,N(Q),r(),S(Q,"press",W,m.uv),!0)}function Se(){if(!h)for(let w of l.values())I(w)}function V(){if(!h){ce("cancel",null);for(let w of[...l.values()])L(w);h=!0,c.clear(),d=null,o.removeFromParent()}}return{selectFace:E,createSurface:J,setInputHandler(w){if(h&&w===null){d=null;return}if(f(),w!==null&&typeof w!="function")throw new TypeError("Choose an input callback or null.");w===null&&ce("cancel",null),d=w},getPickables(){return Se(),[...l.values()].flatMap(w=>w.meshes||[w.mesh]).filter(w=>w.visible)},getFace(w){let O=l.get(w);return O?O.bindings?B(O):b(O.face):null},objects(){return this.getPickables()},isHit(w){return!!se(w)},pointer:me,sync:Se,get hasActivePointer(){return!!m},dispose:V}}function nm(i,e,t,n=1.1){if(!(i>0)||!Number.isFinite(i)||!(t>0)||!Number.isFinite(t)||!(e>0&&e<180))return null;let r=e*Math.PI/360,s=Math.atan(Math.tan(r)*t);return i*Math.max(1,n)/Math.sin(Math.min(r,s))}function im(i,e,t,n,r=.85,s=[0,1,0]){if(!Array.isArray(i)||i.length!==3||i.some(f=>!Number.isFinite(f)||f<0)||!Array.isArray(e)||e.length!==3||e.some(f=>!Number.isFinite(f))||!Array.isArray(s)||s.length!==3||s.some(f=>!Number.isFinite(f))||Math.hypot(...s)<1e-10||!(n>0&&Number.isFinite(n))||!(t>0&&t<180)||!(r>0&&r<1))return null;let o=Math.hypot(...e);if(o<1e-10)return null;let a=e.map(f=>f/o),c=(f,p)=>[f[1]*p[2]-f[2]*p[1],f[2]*p[0]-f[0]*p[2],f[0]*p[1]-f[1]*p[0]],l=(f,p)=>f.reduce((v,_,y)=>v+_*p[y],0),u=c(s,a);Math.hypot(...u)<1e-8&&(u=c(Math.abs(a[2])<.9?[0,0,1]:[0,1,0],a));let h=Math.hypot(...u);u=u.map(f=>f/h);let d=c(a,u),m=Math.tan(t*Math.PI/360)*r,g=m*n,x=.01;for(let f of[-1,1])for(let p of[-1,1])for(let v of[-1,1]){let _=[f*i[0]/2,p*i[1]/2,v*i[2]/2],y=l(_,a);x=Math.max(x,y+Math.abs(l(_,u))/g,y+Math.abs(l(_,d))/m,y+.01)}return x}function RM(i,e,t,n,r){if(!["F.Cu","B.Cu"].includes(t)||![i,e].every(u=>Array.isArray(u)&&u.length===3&&u.every(Number.isFinite))||i.some((u,h)=>u>e[h]))return null;let s=i.map((u,h)=>(u+e[h])/2),o=i.map((u,h)=>Math.max(h===2?1:8,e[h]-u)),a=t==="B.Cu"?-1:1,c=[0,1,0],l=im(o,[0,0,a],n,r,.55,c);return l===null?null:{target:s,position:[s[0],s[1],s[2]+a*l],up:c}}var kh=i=>i&&typeof i=="object"&&!Array.isArray(i)?i.quoted:i,XP=i=>Array.isArray(i)?kh(i[0]):void 0,Hx=(i,e)=>(Array.isArray(i)?i:[]).filter(t=>XP(t)===e),Vx=(i,e)=>Hx(i,e)[0],Vc=i=>Number.isFinite(i)&&i>0;function CM(i={},e=[],t=1.6){let n=[],r=new Map,s=0,o=A=>{n.length<64?n.push(A):s++},a=[...new Set((i.layers||[]).filter(A=>typeof A=="string"&&/^(?:F|B|In[1-9]\d*)\.Cu$/.test(A)))],c=a.slice(0,64);a.length>64&&o("Copper layer display is limited to 64 layers; additional source layers are omitted.");let l=new Set(c),u=Array.isArray(i.stackup)?i.stackup:[],h=Vc(t)?t:1.6;Vc(t)||o("Board thickness is unavailable; copper elevation uses an estimated 1.6 mm board depth.");let d=u.filter(A=>l.has(A.name)),m=new Map(d.filter(A=>Vc(A.thickness)).map(A=>[A.name,A.thickness])),g=c.filter(A=>!m.has(A));g.length&&o(`Saved copper thickness is unavailable for ${g.join(", ")}; 0.035 mm is used for display only.`);let x=A=>/^dielectric\b/i.test(A.name||"")||/^(core|prepreg|dielectric)$/i.test(A.type||""),f=c.length>0&&d.length===c.length&&d.every((A,T)=>A.name===c[T]&&Vc(A.thickness))&&u.every(A=>!(l.has(A.name)||x(A))||Vc(A.thickness)),p;if(f){let A=0,T=new Map;for(let M of u){let S=Vc(M.thickness)?M.thickness:0;l.has(M.name)&&T.set(M.name,h/2-A-S/2),A+=S}Math.abs(A-h)>Math.max(1e-6,h*1e-6)?o("Saved stackup thickness differs from board depth; copper elevations are estimated uniformly."):p=c.map(M=>({name:M,z:T.get(M),thickness:m.get(M)}))}let v=!!p;if(!p){f||o("Complete saved stackup depths are unavailable; copper elevations are estimated uniformly across the board.");let A=m.get(c[0])||.035,T=m.get(c.at(-1))||.035;p=c.map((M,S)=>({name:M,thickness:m.get(M)||.035,z:c.length<2?0:h/2-A/2-S/(c.length-1)*(h-(A+T)/2)}))}let _=new Map(p.map(A=>[A.name,A])),y=new Map,b=new Set,E=0;for(let A of Hx(e,"via")){if((Vx(A,"at")?.length||0)<3)continue;E++;let T=String(kh(Vx(A,"uuid")?.[1])||kh(Vx(A,"tstamp")?.[1])||`via-${E}`);y.has(T)&&b.add(T),y.set(T,A)}for(let A of i.vias||[]){let T=y.get(A.id),M=Hx(T,"layers"),S=M.length===1?M[0].slice(1).map(kh):[],C=me=>o(`Via ${A.id}: ${me}; span omitted.`);if(!T||b.has(A.id)||S.length!==2||S.some(me=>typeof me!="string"||!_.has(me))||S[0]===S[1]){C("saved copper endpoint pair is absent, ambiguous or unknown");continue}let N=T.slice(1).filter(me=>!Array.isArray(me)).map(kh),I=N.filter(me=>["through","blind","buried","micro"].includes(me));if(I.length>1||N.some(me=>!["through","blind","buried","micro","locked"].includes(me))){C("saved via type is ambiguous or unsupported");continue}let L=S.map(me=>c.indexOf(me)).sort((me,Se)=>me-Se),q=c[L[0]],K=c[L[1]],B=q==="F.Cu"&&K==="B.Cu",j=I[0]||"through",J=[q,K].filter(me=>me==="F.Cu"||me==="B.Cu").length;if(j==="through"&&!B||j!=="through"&&B||j==="micro"&&L[1]-L[0]!==1||j==="buried"&&J!==0){C("saved via type does not agree with its layer endpoints");continue}let se=_.get(q),ce=_.get(K);r.set(A.id,{zMin:Math.min(se.z,ce.z),zMax:Math.max(se.z,ce.z),from:q,to:K,through:B,type:j==="blind"&&J===0?"buried":j})}return s&&n.push(`${s} additional saved-geometry diagnostics omitted.`),{layers:p,byLayer:_,viaSpans:r,warnings:n,savedDepths:v}}var Bh=i=>typeof i=="number"&&Number.isFinite(i)&&Math.abs(i)<=1e4,fr=(i,e)=>Math.abs(i-e)<=1e-9;function PM(i){let e=i.customPrimitives;if(i.customAnchor!=="rect"||!Array.isArray(e)||e.length!==3||!Bh(i.width)||!Bh(i.height)||i.width<=0||i.height<=0)return null;let t=e.filter(f=>f?.shape==="circle"),n=e.filter(f=>f?.shape==="polygon");if(t.length!==2||n.length!==1)return null;let r=i.width/2,s=i.height/2;for(let f of t)if(!Array.isArray(f.center)||f.center.length!==2||!f.center.every(Bh)||!Bh(f.radius)||!fr(f.radius,r)||!fr(f.center[0],0))return null;if(!(fr(t[0].center[1],s)&&fr(t[1].center[1],-s)||fr(t[1].center[1],s)&&fr(t[0].center[1],-s)))return null;let o=n[0].points;if(!Array.isArray(o)||o.length<4||o.length>5||!o.every(f=>Array.isArray(f)&&f.length===2&&f.every(Bh)))return null;if(o.length===5){if(!o[0].every((f,p)=>fr(f,o[4][p])))return null;o=o.slice(0,4)}let a=o.some(f=>fr(f[0],r))?1:o.some(f=>fr(f[0],-r))?-1:0;if(!a)return null;let c=[[0,-s-r],[a*r,-s-r],[a*r,s+r],[0,s+r]],l=new Set;for(let f of o){let p=c.findIndex(v=>v.every((_,y)=>fr(_,f[y])));if(p<0||l.has(p))return null;l.add(p)}let u=o.map(f=>c.findIndex(p=>p.every((v,_)=>fr(v,f[_]))));if(!u.every((f,p)=>(u[(p+1)%4]-f+4)%4===(u[1]-u[0]+4)%4)||![1,3].includes((u[1]-u[0]+4)%4))return null;let h=Math.ceil(Math.PI/Math.acos(Math.max(-1,1-.0025/r))),d=Math.min(128,Math.max(64,Math.ceil(h/4)*4)),m=d/4,g=[];for(let f=0;f<=m;f++){let p=Math.PI/2+f*Math.PI/2/m;g.push([r*Math.cos(p),s+r*Math.sin(p)])}for(let f=0;f<=m;f++){let p=Math.PI+f*Math.PI/2/m;g.push([r*Math.cos(p),-s+r*Math.sin(p)])}if(g.push([r,-s-r],[r,s+r]),a<0){for(let f of g)f[0]=-f[0];g.reverse()}g.push([...g[0]]);let x=r*(1-Math.cos(Math.PI/d));return{outline:g,tessellation:{error:x,limited:x>.0025*(1+1e-10),tolerance:.0025}}}var LM=1e4,IM=16,sm=1e-10,NM=i=>typeof i=="number"&&Number.isFinite(i)&&i>0&&i<=LM,om=i=>typeof i=="number"&&Number.isFinite(i)&&Math.abs(i)<=LM;function YP(i){let e=[];for(let t of i){let n=e.at(-1);(!n||Math.hypot(t[0]-n[0],t[1]-n[1])>sm)&&e.push(t)}return e.length>1&&Math.hypot(e[0][0]-e.at(-1)[0],e[0][1]-e.at(-1)[1])<=sm&&e.pop(),e.push([...e[0]]),e}function rm(i,e,t){let n=i/2,r=e/2;if(t===0)return[[-n,-r],[n,-r],[n,r],[-n,r],[-n,-r]];let s=[],o=[[n-t,-r+t],[n-t,r-t],[-n+t,r-t],[-n+t,-r+t]];for(let a=0;a<4;a++)for(let c=0;c<=IM;c++){let l=(-.5+a*.5+c*.5/IM)*Math.PI;s.push([o[a][0]+t*Math.cos(l),o[a][1]+t*Math.sin(l)])}return YP(s)}function Gx(i,e,t,n){return!NM(e)||!NM(t)?null:i==="rect"?rm(e,t,0):i==="oval"?rm(e,t,Math.min(e,t)/2):i==="circle"?Math.abs(e-t)<=sm*Math.max(1,e,t)?rm(e,t,e/2):null:i==="roundrect"&&typeof n=="number"&&Number.isFinite(n)&&n>=0&&n<=.5?rm(e,t,Math.min(e,t)*n):null}function am(i){if(!i||typeof i!="object"||!["circle","oval"].includes(i.drillShape))return null;let e=i.drillWidth??i.drill,t=i.drillHeight??(i.drillShape==="circle"?e:void 0),n=Gx(i.drillShape,e,t);if(!n)return null;let r=i.drillOffset??[0,0];if(!Array.isArray(r)||r.length!==2||!r.every(om))return null;let s=n.map(([o,a])=>[o+r[0],a+r[1]]).reverse();return s.every(o=>o.every(om))?s:null}function OM(i){if(!i||typeof i!="object")return null;let e=i.shape,t=e==="custom"?PM(i):null,n=t?.outline||Gx(e,i.width,i.height,i.roundrectRatio??i.roundrect_rratio);if(!n)return null;let r=null;return(i.drill!==void 0&&i.drill!==0||i.drillWidth!==void 0||i.drillHeight!==void 0)&&(r=am(i),!r||!r.every(o=>DM(n,o)))?null:{shape:e,outline:n,drill:r,...t?{tessellation:t.tessellation}:{}}}function DM(i,[e,t],n=!1){let r=!1;for(let s=0,o=i.length-2;s<i.length-1;o=s++){let[a,c]=i[o],[l,u]=i[s],h=l-a,d=u-c,m=((e-a)*h+(t-c)*d)/(h*h+d*d),g=Math.max(0,Math.min(1,m));if(Math.hypot(e-(a+g*h),t-(c+g*d))<=sm)return n;c>t!=u>t&&e<(l-a)*(t-c)/(u-c)+a&&(r=!r)}return r}function FM(i){if(i?.padType!=="np_thru_hole")return!1;let e=Gx(i.shape,i.width,i.height,i.roundrectRatio??i.roundrect_rratio),t=am(i);return!!(e&&t&&e.every(n=>DM(t,n,!0)))}var _n=i=>i&&typeof i=="object"&&!Array.isArray(i)?i.quoted:i,zi=(i,e)=>i.find(t=>Array.isArray(t)&&_n(t[0])===e);function jP(i){let e=zi(i,"primitives");if(!e||e.length>17)return null;let t=[],n=(r,s)=>{let o=zi(r,s)?.slice(1).map(_n);return o?.length===2&&o.every(om)?o:null};for(let r of e.slice(1)){if(!Array.isArray(r)||_n(zi(r,"fill")?.[1])!=="yes"||_n(zi(r,"width")?.[1])!==0)return null;if(_n(r[0])==="gr_circle"){let s=n(r,"center"),o=n(r,"end");if(!s||!o)return null;t.push({shape:"circle",center:s,radius:Math.hypot(o[0]-s[0],o[1]-s[1])})}else if(_n(r[0])==="gr_poly"){let s=zi(r,"pts");if(!s||s.length<4||s.length>17)return null;let o=[];for(let a of s.slice(1)){if(!Array.isArray(a)||_n(a[0])!=="xy")return null;let c=a.slice(1).map(_n);if(c.length!==2||!c.every(om))return null;o.push(c)}t.push({shape:"polygon",points:o})}else return null}return t}function UM(i){let e=new Map,t=new Set,n=0;if(!Array.isArray(i)||_n(i[0])!=="kicad_pcb"||i.length>1e6)return e;let r=-1;for(let s of i){if(!Array.isArray(s)||!["footprint","module"].includes(_n(s[0]))||(r++,s.length>1e6))continue;let o=s.find(c=>Array.isArray(c)&&_n(c[0])==="property"&&_n(c[1])==="Reference")?.[2],a=-1;for(let c of s){if(!Array.isArray(c)||_n(c[0])!=="pad"||(a++,c.length>1e4))continue;if(++n>2e5)return e;let l=em(c,_n(o),r,a);if(typeof l!="string"||!l||l.length>128)continue;if(t.has(l)){e.delete(l);continue}t.add(l);let u=zi(c,"roundrect_rratio")?.[1],h=zi(c,"drill"),d={type:"Pad",padType:String(_n(c[2])||""),uuid:l,ownerUuid:_n(zi(s,"uuid")?.[1]??zi(s,"tstamp")?.[1]),pinNumber:String(_n(c[1])??""),pinName:String(_n(zi(c,"pinfunction")?.[1])??"")};if(typeof u=="number"&&(d.roundrectRatio=u),_n(c[3])==="custom"&&(d.customAnchor=_n(zi(zi(c,"options")||[],"anchor")?.[1]),d.customPrimitives=jP(c)),h){let m=_n(h[1])==="oval";d.drillShape=m?"oval":"circle",d.drillWidth=h[m?2:1],d.drillHeight=m?h[3]:d.drillWidth;let g=zi(h,"offset");g&&(d.drillOffset=[g[1],g[2]])}if(e.set(l,d),e.size>=2e5)return e}}return e}var Hc=Math.PI*2,Xx=1e-9,Vh=.0025,Tn=i=>typeof i=="number"&&Number.isFinite(i);function cm(i,{tolerance:e=Vh,min:t=24,max:n=128}={}){if(!Tn(i)||i<=0||!Tn(e)||e<=0||!Number.isInteger(t)||!Number.isInteger(n)||t<4||n<t||n>4096)throw Error("Invalid circular tessellation parameters.");let r=2*Math.acos(Math.max(-1,Math.min(1,1-e/i))),s=r>0?Math.ceil(Hc/r):n,o=Math.min(n,Math.max(t,Math.ceil(s/4)*4)),a=i*(1-Math.cos(Math.PI/o));return{segments:o,error:a,limited:a>e*(1+1e-10),tolerance:e}}function kM(i,e,{world:t,z:n,thickness:r}){if(!Array.isArray(e)||typeof t!="function"||!Tn(n)||!Tn(r)||r<=0)throw Error("Invalid copper stroke batch parameters.");let s=e.filter(x=>Tn(x.width)&&x.width>0&&Array.isArray(x.start)&&Array.isArray(x.end)&&x.start.length===2&&x.end.length===2&&[...x.start,...x.end].every(Tn)),o=e.length-s.length;if(!s.length)return{batches:[],tracks:s,invalid:o,plan:null,triangles:0};let a=[12,16,24,32,48,64,96,128],c=new Map,l=new Map,u=[],h=0,d=!1;for(let x of s){let f=l.get(x.width);if(!f){let v=cm(x.width/2,{min:12});f=a.find(_=>_>=v.segments)||128,l.set(x.width,f)}let p=x.width/2*(1-Math.cos(Math.PI/f));h=Math.max(h,p),d||=p>Vh*(1+1e-10),c.has(f)||c.set(f,[]),c.get(f).push(x)}let m=s.filter(x=>Math.hypot(x.end[0]-x.start[0],x.end[1]-x.start[1])>1e-12);m.length&&u.push({part:"core",records:m,geometry:new i.BoxGeometry(1,1,1),place(x,f){let p=t(f.start),v=t(f.end);x.position.set((p[0]+v[0])/2,(p[1]+v[1])/2,n),x.rotation.set(0,0,Math.atan2(v[1]-p[1],v[0]-p[0])),x.scale.set(Math.hypot(v[0]-p[0],v[1]-p[1]),f.width,r)}});for(let[x,f]of[...c].sort((p,v)=>p[0]-v[0])){let p=new i.CylinderGeometry(1,1,1,x/2,1,!1,0,Math.PI);p.rotateX(Math.PI/2);for(let v of["start","end"])u.push({part:v+"-"+x,records:f,geometry:p,place(_,y){let[b,E]=t(y[v]),A=t(y.start),T=t(y.end);_.position.set(b,E,n),_.rotation.set(0,0,Math.atan2(T[1]-A[1],T[0]-A[0])+(v==="start"?Math.PI:0)),_.scale.set(y.width/2,y.width/2,r)}})}let g={segments:Math.max(...c.keys()),error:h,limited:d,tolerance:Vh};return{batches:u,tracks:s,invalid:o,plan:g,triangles:u.reduce((x,f)=>x+(f.geometry.index?.count||f.geometry.getAttribute("position").count)/3*f.records.length,0)}}function qP(i,e,t){if(!t)return[[-i/2,-e/2],[i/2,-e/2],[i/2,e/2],[-i/2,e/2],[-i/2,-e/2]];let n=cm(t,{min:64}),r=n.segments/4,s=[],o=i/2,a=e/2,c=[[o-t,-a+t],[o-t,a-t],[-o+t,a-t],[-o+t,-a+t]];for(let l=0;l<4;l++)for(let u=0;u<=r;u++){let h=(-.5+l*.5+u*.5/r)*Math.PI,d=[c[l][0]+t*Math.cos(h),c[l][1]+t*Math.sin(h)],m=s.at(-1);(!m||Math.hypot(d[0]-m[0],d[1]-m[1])>Xx)&&s.push(d)}return Math.hypot(s[0][0]-s.at(-1)[0],s[0][1]-s.at(-1)[1])<Xx&&s.pop(),s.push([...s[0]]),s}function BM(i,e,t,n){return qP(e,t,i==="rect"?0:i==="roundrect"?Math.min(e,t)*n:Math.min(e,t)/2)}function lm(i){if(!am(i))return null;let e=i.drillWidth??i.drill,t=i.drillHeight??(i.drillShape==="circle"?e:void 0),n=i.drillOffset||[0,0];return BM(i.drillShape,e,t,0).map(([r,s])=>[r+n[0],s+n[1]]).reverse()}function KP(i,e){let t=0;for(let n=0;n<i.length-1;n++){let r=i[n],s=i[n+1],o=(s[0]-r[0])*(e[1]-r[1])-(s[1]-r[1])*(e[0]-r[0]);if(Math.abs(o)<1e-12)return!1;let a=Math.sign(o);if(t&&a!==t)return!1;t=a}return!0}function Yx(i){let e=OM(i);if(!e)return null;if(i.shape==="custom"){let a=e.drill?Math.min(i.drillWidth??i.drill,i.drillHeight??i.drill)/2:0,c=Math.max(e.tessellation.error,a*(1-Math.cos(Math.PI/64)));return{...e,tessellation:{...e.tessellation,error:c,limited:c>Vh*(1+1e-10)}}}let t=i.roundrectRatio??i.roundrect_rratio,n=BM(i.shape,i.width,i.height,t),r=i.drill||i.drillWidth||i.drillHeight?lm(i):null,s=[i.shape==="rect"?0:i.shape==="roundrect"?Math.min(i.width,i.height)*t:Math.min(i.width,i.height)/2,r?Math.min(i.drillWidth??i.drill,i.drillHeight??i.drill)/2:0].filter(a=>a>0),o=s.map(a=>cm(a,{min:64}));return r&&r.some(a=>!KP(n,a))?{...e,tessellation:{error:Math.max(0,...s.map(a=>a*(1-Math.cos(Math.PI/64)))),limited:!0,reason:"Refined hole containment requires retaining the validated contour resolution."}}:{shape:i.shape,outline:n,drill:r,tessellation:{error:Math.max(0,...o.map(a=>a.error)),limited:o.some(a=>a.limited)}}}function zM(i,e,t){if(!Array.isArray(e)||e.length<4||!e.every(a=>Array.isArray(a)&&a.length===2&&a.every(Tn))||!Tn(t)||t<=0||Math.hypot(e[0][0]-e.at(-1)[0],e[0][1]-e.at(-1)[1])>Xx)throw Error("Invalid saved drill wall.");let n=e.length-1,r=[],s=[];for(let a=0;a<n;a++){let[c,l]=e[a];r.push(c,-l,0,c,-l,t);let u=(a+1)%n;s.push(a*2,u*2,a*2+1,u*2,u*2+1,a*2+1)}let o=new i.BufferGeometry;return o.setAttribute("position",new i.Float32BufferAttribute(r,3)),o.setIndex(s),o.computeVertexNormals(),o}function VM(i,e,t=.035,n){if(!["F.Cu","B.Cu"].includes(i)||!Tn(e)||e<=0||!Tn(t)||t<=0||n!==void 0&&!Tn(n))throw Error("Invalid outer copper placement.");let r=i==="F.Cu"?1:-1,s=.001,o=n??r*(e/2-t/2),a=o+r*s;return{center:a,sourceCenter:o,base:a-t/2,thickness:t,displayOffset:s}}function HM(i,e){if(!["F.Cu","B.Cu"].includes(i)||!Tn(e?.base)||!Tn(e?.thickness)||e.thickness<=0)throw Error("Invalid zone display placement.");let t=Math.min(.005,e.thickness/4);return i==="F.Cu"?e.base+e.thickness-t:e.base+t}function GM(i,e){if(!Tn(i)||i<=0||!e?.get)throw Error("Invalid substrate depth plan.");let t=e.get("F.Cu"),n=e.get("B.Cu"),r=a=>a&&Tn(a.z)&&Tn(a.thickness)&&a.thickness>0,s=r(t)?t.z-t.thickness/2:i/2,o=r(n)?n.z+n.thickness/2:-i/2;if(!Tn(s-o)||s<=o)throw Error("Outer copper inner faces do not enclose a valid substrate.");return{top:s,bottom:o,depth:s-o,missingOuterDepths:!r(t)||!r(n)}}var la=i=>i&&typeof i=="object"&&!Array.isArray(i)?i.quoted:i,zh=(i,e)=>i.find(t=>Array.isArray(t)&&la(t[0])===e),Wx=(i,e)=>{let t=zh(i,e),n=t?.slice(1,3).map(la);return n?.length===2&&n.every(Tn)?n:null};function ZP(i,e,t){let n=e[0]-i[0],r=e[1]-i[1],s=t[0]-i[0],o=t[1]-i[1],a=2*(n*o-r*s);if(Math.abs(a)<1e-12)return null;let c=n*n+r*r,l=s*s+o*o,u=[i[0]+(c*o-l*r)/a,i[1]+(l*n-c*s)/a],h=Math.atan2(i[1]-u[1],i[0]-u[0]),d=f=>(f%Hc+Hc)%Hc,m=d(Math.atan2(t[1]-u[1],t[0]-u[0])-h),g=d(Math.atan2(e[1]-u[1],e[0]-u[0])-h),x=Math.hypot(i[0]-u[0],i[1]-u[1]);return u.every(Tn)&&Tn(x)?{center:u,radius:x,start:h,sweep:g<=m?m:m-Hc}:null}function WM(i,e,{maxSegments:t=2e5}={}){if(!Array.isArray(i)||!Array.isArray(e)||!Number.isInteger(t)||t<1||t>1e6)throw Error("Invalid saved track refinement input.");let n=[],r=new Map,s=new Map,o=new Set,a=Math.max(0,t-i.length);for(let h of i){let d=String(h.id||"").replace(/:\d+$/,"");r.has(d)||r.set(d,[]),r.get(d).push(h)}let c=(h,d)=>h&&d&&Math.hypot(h[0]-d[0],h[1]-d[1])<1e-6;for(let h of e){if(!Array.isArray(h)||la(h[0])!=="arc")continue;let d=Wx(h,"start"),m=Wx(h,"mid"),g=Wx(h,"end"),x=la(zh(h,"uuid")?.[1])??la(zh(h,"tstamp")?.[1]),f=la(zh(h,"layer")?.[1]),p=la(zh(h,"width")?.[1]);if(!d||!m||!g)continue;let v=typeof x=="string"&&r.has(x)?[[x,r.get(x)]]:[...r].filter(([,S])=>S[0].layer===f&&S[0].width===p&&c(S[0].start,d)&&c(S.at(-1).end,g));if(v.length!==1){n.push("A saved copper arc could not be matched unambiguously; existing parsed segments are retained.");continue}let[_,y]=v[0];if(o.has(_)){s.delete(_),n.push("Duplicate saved copper arc identity retained without refinement.");continue}o.add(_);let b=ZP(d,m,g);if(!b){n.push("Degenerate saved copper arc retained without refinement.");continue}let E=cm(b.radius,{min:24,max:4096}),A=Math.max(y.length,2,Math.ceil(E.segments*Math.abs(b.sweep)/Hc)),T=Math.max(0,A-y.length);if(E.limited||T>a){n.push("Saved copper arc refinement reached its geometric error or segment budget; parsed segments are retained.");continue}a-=T;let M=Array.from({length:A+1},(S,C)=>{let N=b.start+b.sweep*C/A;return[b.center[0]+b.radius*Math.cos(N),b.center[1]+b.radius*Math.sin(N)]});M[0]=d,M[A]=g,s.set(_,Array.from({length:A},(S,C)=>({...y[Math.min(y.length-1,Math.floor(C*y.length/A))],...typeof x=="string"?{uuid:x}:{},start:M[C],end:M[C+1]})))}let l=[],u=new Set;for(let h of i){let d=String(h.id||"").replace(/:\d+$/,"");s.has(d)?u.has(d)||(l.push(...s.get(d)),u.add(d)):l.push(h)}return{tracks:l,warnings:[...new Set(n)],tolerance:Vh}}var XM=i=>encodeURIComponent(i?.trim()||"global");function ua(i,e,t){return`spike:${i}:${XM(e)}:${XM(t)}`}function jx(i){let e=new Map;return i.forEach((t,n)=>{let r=t?.ref;typeof r!="string"||!r||e.set(r,e.has(r)?null:n)}),e}function YM(i,e){let t=i.map(()=>!0),n=jx(i);if(!Array.isArray(e))return t;let r=new Map;for(let s of e)typeof s?.reference!="string"||!s.reference||typeof s.populated!="boolean"||r.set(s.reference,r.has(s.reference)?null:s.populated);for(let[s,o]of r){let a=n.get(s);a!=null&&o!=null&&(t[a]=o)}return t}function qM(i){let e=new Map,t=new Map,n=new Map;for(let r of i.components)t.set(r.ref,(t.get(r.ref)||0)+1);for(let r of[...i.drawings,...i.pads])r.ref&&(e.has(r.ref)||e.set(r.ref,[]),e.get(r.ref).push(r));for(let r of i.components){if(t.get(r.ref)!==1)continue;let s=e.get(r.ref)||[],o=r.layer?.startsWith("B.")?"B":"F",a=[],c=null;for(let b of[o+".Fab",o+".CrtYd"]){let E=s.filter(A=>A.layer===b&&A.points).map(A=>A.points);if(a=E.flat(),c=JP(E),a.length)break}if(!a.length)for(let b of s.filter(E=>E.at&&E.width>0&&E.height>0)){let E=-(b.rotation||0)*Math.PI/180,A=Math.cos(E),T=Math.sin(E);for(let M of[-b.width/2,b.width/2])for(let S of[-b.height/2,b.height/2])a.push([b.at[0]+M*A-S*T,b.at[1]+M*T+S*A])}let l=(r.rotation||0)*Math.PI/180,u=Math.cos(l),h=Math.sin(l),d=a.filter(b=>b?.length>=2&&b.every(Number.isFinite)).map(([b,E])=>(b-=r.at[0],E-=r.at[1],[b*u-E*h,b*h+E*u]));if(!d.length)continue;let m=1/0,g=1/0,x=-1/0,f=-1/0;for(let[b,E]of d)m=Math.min(m,b),g=Math.min(g,E),x=Math.max(x,b),f=Math.max(f,E);let p=x-m,v=f-g;if(!(p>1e-6&&v>1e-6))continue;let _=(m+x)/2,y=(g+f)/2;if(c){let b=c.map(([T,M])=>(T-=r.at[0],M-=r.at[1],[T*u-M*h,T*h+M*u]));if(!jM([_,y],b))continue;let E=0,A=1;for(let T=0;T<30;T++){let M=(E+A)/2,S=[[-1,-1],[1,-1],[1,1],[-1,1]].map(([N,I])=>[_+N*p*M/2,y+I*v*M/2]);S.every(N=>jM(N,b))&&!S.some((N,I)=>b.some((L,q)=>QP(N,S[(I+1)%4],L,b[(q+1)%b.length])))?E=M:A=M}if(p*=E,v*=E,!(p>1e-6&&v>1e-6))continue}n.set(r,{at:[r.at[0]+_*u+y*h,r.at[1]-_*h+y*u],width:p,height:v,rotation:l})}return n}var Hh=(i,e)=>Math.hypot(i[0]-e[0],i[1]-e[1])<1e-5;function JP(i){if(i.length>512)return[];let e=i.filter(n=>n.length>1).map(n=>[...n]),t=[];for(;e.length;){let n=e.shift();for(;!Hh(n[0],n.at(-1));){let r=e.findIndex(o=>Hh(n.at(-1),o[0])||Hh(n.at(-1),o.at(-1)));if(r<0)break;let s=e.splice(r,1)[0];Hh(n.at(-1),s[0])||s.reverse(),n.push(...s.slice(1))}n.length>3&&Hh(n[0],n.at(-1))&&t.push(n.slice(0,-1))}return t.length===1?t[0]:t.length?[]:null}function jM(i,e){let t=!1;for(let n=0,r=e.length-1;n<e.length;r=n++){let s=e[n],o=e[r];s[1]>i[1]!=o[1]>i[1]&&i[0]<(o[0]-s[0])*(i[1]-s[1])/(o[1]-s[1])+s[0]&&(t=!t)}return t}function QP(i,e,t,n){let r=(s,o,a)=>(o[0]-s[0])*(a[1]-s[1])-(o[1]-s[1])*(a[0]-s[0]);return r(i,e,t)*r(i,e,n)<-1e-12&&r(t,n,i)*r(t,n,e)<-1e-12}function KM(i,{objects:e,camera:t,rect:n,positionToWorld:r}){let s=o=>o?.type==="Component"||typeof o?.library=="string";return function(a){if(!a||typeof a!="object")return null;let c=n();if(!(c.width>0&&c.height>0))return null;let l=x=>(x.project(t),![x.x,x.y,x.z].every(Number.isFinite)||Math.abs(x.x)>1||Math.abs(x.y)>1||x.z<-1||x.z>1?null:{x:c.left+(x.x+1)*c.width/2,y:c.top+(1-x.y)*c.height/2,visible:!0});if(a.position){let{x,y:f}=a.position;return![x,f].every(p=>typeof p=="number"&&Number.isFinite(p)&&Math.abs(p)<=1e6)||!["front","back",void 0].includes(a.side)?null:l(r({x,y:f},a.side))}let u=x=>typeof x=="string"&&x.length>0&&x.length<=500&&!/[\x00-\x1f\x7f]/.test(x);if(!["uuid","reference","pinNumber","net"].some(x=>u(a[x]))||["uuid","reference","pinNumber","net"].some(x=>a[x]!==void 0&&!u(a[x]))||a.pinNumber&&!a.uuid&&!a.reference)return null;let h=new Map,d=new i.Matrix4,m=new i.Matrix4;for(let x of e()){let f=!0;for(let v=x;v;v=v.parent)v.visible||(f=!1);if(!f)continue;let p=x.userData.records||[x.userData.record];for(let v=0;v<p.length;v++){let _=p[v];if(!_)continue;let y=_.uuid||_.id;if(a.uuid&&a.uuid!==y&&!(a.pinNumber&&a.uuid===_.ownerUuid)&&!(typeof y=="string"&&y.replace(/:\d+$/,"")===a.uuid)||a.reference&&_.ref!==a.reference||a.pinNumber&&String(_.pinNumber??_.name??"")!==a.pinNumber||a.net&&_.net!==a.net||a.reference&&!a.uuid&&!a.pinNumber&&!a.net&&!s(_)||(x.updateWorldMatrix(!0,!1),x.geometry?.boundingBox||x.geometry?.computeBoundingBox(),!x.geometry?.boundingBox))continue;let b=x.geometry.boundingBox.clone();if(x.isInstancedMesh){if(x.getMatrixAt(v,m),m.determinant()===0)continue;d.multiplyMatrices(x.matrixWorld,m),b.applyMatrix4(d)}else b.applyMatrix4(x.matrixWorld);if(b.isEmpty())continue;let E=y||_.ref;E&&(h.has(E)?h.get(E).union(b):h.set(E,b))}}if(!a.net&&h.size!==1)return null;let g=[...h.values()].map(x=>l(x.getCenter(new i.Vector3))).filter(Boolean);return g.sort((x,f)=>Math.hypot(x.x-c.left-c.width/2,x.y-c.top-c.height/2)-Math.hypot(f.x-c.left-c.width/2,f.y-c.top-c.height/2)),g[0]||null}}function um(i={}){if(!i||typeof i!="object"||Array.isArray(i))throw new TypeError("Selection style must be an object.");let{mode:e="dim",color:t="accent"}=i;if(!["dim","bright","isolate"].includes(e))throw new TypeError("Choose dim, bright or isolate selection mode.");if(!["accent","source"].includes(t))throw new TypeError("Choose accent or source selection color.");return{mode:e,color:t}}function ZM(i,e){let t=new Map,n=new Map,r=new Map,s=new Map,o={owned:[]},a="",c=v=>Array.isArray(v)?v:[v];function l(){for(let[v,_]of t){v.material=_.material,v.isInstancedMesh&&(v.instanceColor!==_.instanceColor&&v.dispose?.(),v.instanceColor=_.instanceColor,v.customDepthMaterial=_.depth,v.customDistanceMaterial=_.distance);for(let y of _.owned)y.dispose()}for(let v of o.owned)v.dispose();o.owned.length=0,n.clear(),r.clear(),s.clear(),t.clear(),a=""}function u(v){if(t.has(v))return t.get(v);let _={material:v.material,instanceColor:v.instanceColor,depth:v.customDepthMaterial,distance:v.customDistanceMaterial,owned:[]};return t.set(v,_),_}function h(v,_){let y=v.clone();return y.onBeforeCompile=v.onBeforeCompile,y.customProgramCacheKey=()=>v.customProgramCacheKey(),_.owned.push(y),y}function d(v,_,y){if(v.has(_))return v.get(_);let b=h(_,o);return y(b),v.set(_,b),b}function m(v,_,y=!1){if(y&&n.has(v))return n.get(v);let b=h(v,y?o:_),E=v.onBeforeCompile;return b.userData??={},b.userData.selectionOpacityCap=.24,b.opacity=Math.min(v.opacity??1,.24),b.transparent=!0,b.depthWrite=!1,b.onBeforeCompile=(A,T)=>{E?.call(b,A,T),A.fragmentShader=A.fragmentShader.replace("#include <opaque_fragment>",`outgoingLight = vec3(dot(outgoingLight, vec3(0.2126, 0.7152, 0.0722))) * 0.24;
#include <opaque_fragment>`)},b.customProgramCacheKey=()=>v.customProgramCacheKey()+":selection-grey",y&&n.set(v,b),b}function g(v){return v.accent||(v.accent=c(v.material).map(_=>d(s,_,y=>{y.color?.setHex(6547182),y.emissive?.setHex(1201756),y.metalness=0,y.roughness=.55}))),Array.isArray(v.material)?v.accent:v.accent[0]}function x(v,_,y=!1,b=!1){let E=v.onBeforeCompile,A=v.customProgramCacheKey(),T=y?v:h(v,_);return y&&_.owned.push(T),b&&(T.transparent=!0,T.depthWrite=!1),T.onBeforeCompile=(M,S)=>{E?.call(T,M,S),M.vertexShader=M.vertexShader.replace("#include <common>",`#include <common>
varying float vSelectionStyle;`).replace("#include <begin_vertex>",`#include <begin_vertex>
vSelectionStyle = 0.0;
#ifdef USE_INSTANCING_COLOR
if (instanceColor.r < -1.0e25) { vSelectionStyle = 3.0; }
else if (instanceColor.r < -1.0e15) { vSelectionStyle = 2.0; }
else if (instanceColor.r < 0.0) { vSelectionStyle = 1.0; }
#endif`),M.vertexShader=M.vertexShader.replace("#include <color_vertex>",`#ifdef USE_INSTANCING_COLOR
vec3 selectionDecodedColor = instanceColor.r < -1.0e15 ? vec3(1.0) : instanceColor.r < 0.0 ? -instanceColor - vec3(1.0) : instanceColor;
#endif
`+i.ShaderChunk.color_vertex.replace(/\binstanceColor\b/g,"selectionDecodedColor")),M.fragmentShader=M.fragmentShader.replace("#include <common>",`#include <common>
varying float vSelectionStyle;`).replace("#include <clipping_planes_fragment>",`#include <clipping_planes_fragment>
if (vSelectionStyle > 2.5) discard;`).replace("#include <color_fragment>",`#include <color_fragment>
if (vSelectionStyle > 1.5 && vSelectionStyle < 2.5) diffuseColor.rgb = vec3(0.1247718, 0.7912979, 0.8549926);`).replace("#include <opaque_fragment>","if (vSelectionStyle > 0.5 && vSelectionStyle < 1.5) { outgoingLight = vec3(dot(outgoingLight, vec3(0.2126, 0.7152, 0.0722))) * 0.24;"+(b?" diffuseColor.a *= 0.24;":"")+` }
#include <opaque_fragment>`)},T.customProgramCacheKey=()=>A+":selection-instances-v1"+(b?":translucent-context":""),T}function f(v,_,y=null,b={}){let E=um(b),A=b.expanded===!0,T=b.netContext===!0,M=E.mode+":"+E.color+":"+A+":"+T,S=E.mode==="dim"&&T,C=I=>v(I)&&!(S&&(I?.type==="Component"||typeof I?.library=="string"));if(!_){l();return}a&&a!==M&&l(),a=M;let N=E.mode==="dim"&&E.color==="accent";for(let I of e()){if(!I.material)continue;let L=u(I),q=I.userData.records,K=I.userData.identity?.startsWith("spike:via-barrel:"),B=N&&!K&&!S;if(K&&E.mode!=="isolate"&&!((A||T)&&E.mode==="dim")){I.material=L.material,I.instanceColor!==L.instanceColor&&(I.instanceColor=L.instanceColor);continue}if(I.isInstancedMesh&&q){if(B){L.white||(L.white=c(L.material).map(se=>{let ce=h(se,L);return ce.color?.setHex(16777215),ce}),I.instanceColor=L.instanceColor?.clone()||null),I.material=Array.isArray(L.material)?L.white:L.white[0];let j=c(L.material)[0].color||new i.Color(16777215),J=new i.Color;for(let se=0;se<q.length;se++){if(L.instanceColor?J.fromArray(L.instanceColor.array,se*3).multiply(j):J.copy(j),y?.(q[se]))J.setHex(6547182);else if(!v(q[se])){let ce=(J.r*.2126+J.g*.7152+J.b*.0722)*.24;J.setRGB(ce,ce,ce)}I.setColorAt(se,J)}}else{L.instances||(L.instances=c(L.material).map(J=>x(J,L,!1,E.mode==="dim"&&(T||K&&A))),I.instanceColor=L.instanceColor?.clone()||null,E.mode==="isolate"&&(I.customDepthMaterial=x(L.depth||new i.MeshDepthMaterial({depthPacking:i.RGBADepthPacking}),L,!L.depth),I.customDistanceMaterial=x(L.distance||new i.MeshDistanceMaterial,L,!L.distance))),I.material=Array.isArray(L.material)?L.instances:L.instances[0];let j=new i.Color;for(let J=0;J<q.length;J++){L.instanceColor?j.fromArray(L.instanceColor.array,J*3):j.setHex(16777215);let se=q[J],ce=C(se);!ce&&E.mode==="isolate"?j.setRGB(-1e30,-1e30,-1e30):!K&&E.color==="accent"&&y?.(se)?j.setRGB(-1e20,-1e20,-1e20):!ce&&E.mode==="dim"&&j.setRGB(-j.r-1,-j.g-1,-j.b-1),I.setColorAt(J,j)}}I.instanceColor&&(I.instanceColor.needsUpdate=!0)}else E.mode==="isolate"&&I.userData.record&&I.userData.record.type!=="Board"&&!v(I.userData.record)?(L.hidden||(L.hidden=c(L.material).map(j=>d(r,j,J=>{J.visible=!1}))),I.material=Array.isArray(L.material)?L.hidden:L.hidden[0]):!K&&E.color==="accent"&&y?.(I.userData.record)?I.material=g(L):C(I.userData.record)||E.mode!=="dim"?I.material=L.material:(L.dim||(L.dim=c(L.material).map(j=>m(j,L,!I.isInstancedMesh))),I.material=Array.isArray(L.material)?L.dim:L.dim[0])}}function p(v,_){let y=v.isInstancedMesh&&v.instanceColor;return y&&Number.isInteger(_)&&y.array[_*3]<-1e25?!1:c(v.material).some(b=>b&&b.visible!==!1)}return{update:f,restore:l,dispose:l,isVisible:p,stats:()=>({capturedObjects:t.size,sharedDimMaterials:n.size})}}var $P=Object.freeze(["realistic","layers","translucent"]);function qx(i){if(!$P.includes(i))throw new TypeError("Choose realistic, layers or translucent appearance.");return i}function JM(){let i=new Map,e=new Map,t=!1,n=!1,r={substrate:.12,component:.22,zone:.08,silkscreen:.45};function s(l){return Array.isArray(l)?l:[l]}function o(l,u){if(!l||!l.clone)return l;let h=e.get(l);if(h||(h=new Map,e.set(l,h)),h.has(u))return h.get(u);let d=l.clone();return d.onBeforeCompile=l.onBeforeCompile,d.customProgramCacheKey=()=>l.customProgramCacheKey(),d.transparent=!0,d.opacity=(Number.isFinite(l.opacity)?l.opacity:1)*r[u],d.depthWrite=!1,d.forceSinglePass=!0,d.needsUpdate=!0,h.set(u,d),d}function a(l,u){let h=s(u.material).map(d=>o(d,u.role));l.material=Array.isArray(u.material)?h:h[0]}function c(){for(let[l,u]of i)l.material=u.material;for(let l of e.values())for(let u of l.values())u.dispose();e.clear()}return{add(l,u){if(n||!l?.material||!Object.hasOwn(r,u)||i.has(l))return;let h={material:l.material,role:u};i.set(l,h),t&&a(l,h)},setEnabled(l){if(n)return!1;let u=!!l;if(u===t)return t;if(u||c(),t=u,t)for(let[h,d]of i)a(h,d);return t},stats(){return{enabled:t,objects:i.size,materials:[...e.values()].reduce((l,u)=>l+u.size,0)}},dispose(){n||(c(),i.clear(),t=!1,n=!0)}}}function hm(i,e,t){if(t==="translucent"&&i===e)return!1;for(let n=i;n;n=n.parent)if(!n.visible)return!1;return!0}function QM(i,e){if(!(e>0)||!Number.isFinite(e))throw new TypeError("A positive board thickness is required.");let n=["F.Cu",...[...new Set(i.layers||[])].filter(h=>typeof h=="string"&&/^In(?:[1-9]|[1-5][0-9]|6[0-2])\.Cu$/.test(h)).slice(0,62),"B.Cu"],r=Array.isArray(i.stackup)?i.stackup:[],s=new Map,o=0,a=r.findIndex(h=>h.name==="F.Cu"),c=r.findIndex(h=>h.name==="B.Cu"),l=a>=0&&c>a&&r.slice(a,c+1).every(h=>Number.isFinite(h.thickness)&&h.thickness>=0);if(l)for(let h of r){let d=Number.isFinite(h.thickness)&&h.thickness>=0?h.thickness:0;if(n.includes(h.name)){if(s.has(h.name)){s.clear();break}s.set(h.name,e/2-o-d/2)}o+=d}let u=l&&n.every(h=>s.has(h))&&Math.abs(o-e)<1e-6&&n.every((h,d)=>!d||s.get(n[d-1])>s.get(h));return n.map((h,d)=>({name:h,internal:d>0&&d<n.length-1,z:d===0?e/2+.025:d===n.length-1?-e/2-.025:u?s.get(h):e/2-d*e/(n.length-1),basis:d===0||d===n.length-1?"outer-surface":u?"saved-stackup":"illustrative"}))}function $M(i,e){let t=!1,n=!1,r=0,s=0;return{request(){if(!n&&(r++,!t)){t=!0;try{e()}catch(o){throw t=!1,o}}},flush(){n||!t||(t=!1,s++,i())},dispose(){n=!0,t=!1},stats(){return{requestCount:r,flushCount:s,pending:t}}}}function dm({request:i,cancel:e,render:t,canRender:n=()=>!0,state:r={}}){let s={documentVisible:!0,intersecting:!0,hasSize:!0,contextAvailable:!0,...r},o=null,a=!1,c=!1,l=0,u=0,h=0,d=0,m=0,g=0,x=0,f=()=>!c&&s.documentVisible&&s.intersecting&&s.hasSize&&s.contextAvailable&&n();function p(){o!==null&&(e(o),o=null,m++)}function v(){!a||o!==null||!f()||(u++,o=i(()=>{if(o=null,!f()){g++;return}a&&(a=!1,h++,t())}))}return{invalidate(){c||(l++,a=!0,f()?v():d++)},setState(_){if(c)return;let y=f();Object.assign(s,_),f()?(y||(x++,a=!0),v()):p()},stats(){return{...s,paused:!f(),dirty:a,pending:o!==null,requestCount:l,scheduledFrames:u,renderCallbacks:h,suppressedInvalidations:d,cancelledFrames:m,skippedFrames:g,resumeCount:x}},dispose(){c||(c=!0,p(),a=!1)}}}function fm(i,e,t=globalThis.IntersectionObserver){if(typeof t!="function")return null;let n;try{return n=new t(r=>{let s=r.find(o=>o.target===e);s&&i.setState({intersecting:!!s.isIntersecting&&s.intersectionRatio!==0})}),n.observe(e),n}catch{return n?.disconnect(),i.setState({intersecting:!0}),null}}function eE(i){let e=!0,t=0;return{invalidate(){e=!0},check(){return e?(e=!1,t++,i.getError()===i.NO_ERROR):!0},stats:()=>({checks:t,pending:e})}}function tE(i,e={}){let t=new Set((Array.isArray(i.netNames)?i.netNames:[]).filter(n=>typeof n=="string"&&n));for(let n of Array.isArray(i.netCodes)?i.netCodes:[]){if(n===0||n==="0"||n==null||n==="")continue;let r=e.nets?.[String(n)];r?t.add(r):typeof n=="string"&&!/^\d+$/.test(n)&&t.add(n)}return t}function nE(i,e){return e.size>0&&!["references","uuids"].some(t=>Array.isArray(i[t])&&i[t].some(n=>typeof n=="string"&&n))}function eI(i,e){let t=i.instanceMatrix?.array,n=e*16;if(!t||n+15>=t.length)return!1;let r=t[n]*(t[n+5]*t[n+10]-t[n+9]*t[n+6])-t[n+4]*(t[n+1]*t[n+10]-t[n+9]*t[n+2])+t[n+8]*(t[n+1]*t[n+6]-t[n+5]*t[n+2]);return Number.isFinite(r)&&r!==0}function iE(i,e){let t=new Set,n=0,r=0,s=0;for(let o of i){let a=!0;for(let l=o;l;l=l.parent)if(!l.visible){a=!1;break}if(!a||!o.geometry?.attributes?.position?.count)continue;s++;let c=(l,u)=>{n++,!(!e(l)||o.isInstancedMesh&&Number.isInteger(u)&&!eI(o,u))&&(r++,t.add(l?.ref?"part:"+l.ref:l?.uuid||l?.id||o.uuid+":"+u))};Array.isArray(o.userData.records)?o.userData.records.forEach(c):c(o.userData.record)}return{matched:t.size,matchedRecords:r,visitedRecords:n,visibleObjects:s}}function Gh(i={}){return["references","uuids","netNames"].some(e=>Array.isArray(i[e])&&i[e].some(t=>typeof t=="string"&&t.length>0))||Array.isArray(i.netCodes)&&i.netCodes.some(e=>typeof e=="number"&&Number.isFinite(e)&&e!==0||typeof e=="string"&&e!==""&&e!=="0")}function rE(i={},e={}){let t=a=>new Set(Array.isArray(a)?a.filter(c=>typeof c=="string"&&c):[]),n=t(i.references),r=t(i.uuids),s=t(i.netNames);for(let a of Array.isArray(i.netCodes)?i.netCodes:[]){if(a===0||a==="0"||a==null||a==="")continue;let c=e.nets?.[String(a)];c?s.add(c):typeof a=="string"&&!/^\d+$/.test(a)&&s.add(a)}let o=new Set;for(let a of e.pads||[])s.has(a.net)&&a.ref&&o.add(a.ref);return a=>!!(a&&(n.has(a.ref)||s.has(a.net)||r.has(a.uuid)||r.has(a.id)||typeof a.id=="string"&&r.has(a.id.split(":")[0])||o.has(a.ref)&&(a.type==="Component"||typeof a.library=="string")))}function pm(i=6){let e=new Map,t=!1;return{down(n){e.size||(t=!1),e.set(n.pointerId,[n.clientX,n.clientY]),e.size>1&&(t=!0)},move(n){let r=e.get(n.pointerId);r&&Math.hypot(n.clientX-r[0],n.clientY-r[1])>=i&&(t=!0)},up(n){let r=e.get(n.pointerId),s=!!(r&&!t&&e.size===1&&Math.hypot(n.clientX-r[0],n.clientY-r[1])<i);return e.delete(n.pointerId),s},cancel(n){e.delete(n.pointerId),t=!0}}}function sE(i,{later:e=setTimeout,clear:t=clearTimeout,delay:n=550,limit:r=8}={}){let s=new Set,o=null,a=null,c=!1,l=()=>{o!==null&&t(o),o=null};return{down(u){s.size||(c=!1),s.add(u.pointerId),l(),!(u.pointerType!=="touch"||s.size!==1)&&(a={pointerId:u.pointerId,clientX:u.clientX,clientY:u.clientY},o=e(()=>{o=null,c=!0,i(a)},n))},move(u){a?.pointerId===u.pointerId&&Math.hypot(u.clientX-a.clientX,u.clientY-a.clientY)>=r&&l()},up(u){return l(),s.delete(u.pointerId),c},isHeld(){return c},dispose(){l(),s.clear(),a=null}}}function oE(i,e="all"){if(!i)return!1;let t=i.type==="Pad"||typeof i.ref=="string"&&typeof i.name=="string"&&Array.isArray(i.at)&&Number.isFinite(i.width)&&Number.isFinite(i.height);return e==="pin"?t:e==="part"?!t&&(i.type==="Component"||typeof i.library=="string"):e==="net"?typeof i.net=="string"&&!!i.net:!0}function aE(i,{scene:e,renderer:t,extent:n,bottom:r,constrained:s=!1}){let o=new i.ShadowMaterial({color:0,opacity:.18,depthWrite:!1}),a=new i.Mesh(new i.PlaneGeometry(n*6,n*6),o);a.name="Presentation stage",a.position.z=r-Math.max(3,n*.035),a.receiveShadow=!0,a.visible=!1,e.add(a);let c=new Map,l=[];e.traverse(h=>{h.isDirectionalLight&&h.castShadow&&l.push(h)});function u(h,{fast:d=!1}={}){for(let[g,x]of c)g.castShadow=h||x;a.visible=h,e.environmentIntensity=h?1:.65,t.toneMappingExposure=h?1.05:1;let m=h&&!s&&!d?2048:1024;for(let g of l)g.shadow.mapSize.x!==m&&(g.shadow.map?.dispose(),g.shadow.map=null,g.shadow.mapSize.set(m,m),g.shadow.needsUpdate=!0);t.shadowMap.needsUpdate=!0}return{apply:u,addCaster(h){c.set(h,h.castShadow),h.castShadow=a.visible||h.castShadow},get enabled(){return a.visible},dispose(){for(let[h,d]of c)h.castShadow=d;c.clear(),e.remove(a),a.geometry.dispose(),o.dispose()}}}function Wh(i,e,t=1,n=4096){let r=Number.isFinite(i)&&i>0?i:1,s=Number.isFinite(e)&&e>0?e:1,o=Number.isFinite(t)&&t>0?t:1,a=Number.isFinite(n)&&n>0?n:4096;return Math.min(o,3,Math.sqrt(4e6/r/s),a/r,a/s)}function mm(i){return["low","balanced","high","presentation","photoreal-fast"].includes(i)?i:"balanced"}function cE({maxTextureSize:i=4096,maxRenderbufferSize:e=i,deviceMemory:t,hardwareConcurrency:n=0,floatTargets:r=!1,android:s=!1}={}){let o=Math.min(...[i,e].map(u=>Number.isFinite(u)&&u>0?u:4096)),a=Number.isFinite(t)&&t>0?t:null,c=o<=4096||a!==null&&a<=2,l=!c&&r&&o>=8192&&(a!==null?a>=6:o>=16384&&n>=8);return{tier:c?"constrained":l?"premium":"standard",constrained:c,premium:l,maxDimension:o,defaultQuality:s&&l?"high":"balanced",highMaxPixels:c?1e6:l?3e6:2e6}}function Kx(i,e,t=1,n=4096,r="balanced",s=!1){let o=mm(r),a=Number.isFinite(i)&&i>0?i:1,c=Number.isFinite(e)&&e>0?e:1,l=s&&typeof s=="object"?s:null,u=l?l.constrained:s,h=o==="high"||o==="presentation",d=o==="photoreal-fast"?1e6:o==="presentation"?u?1e6:l?.premium?4e6:3e6:o==="high"?l?l.highMaxPixels:u?1e6:2e6:o==="low"||u?1e6:2e6,m=Math.min(Wh(a,c,o==="presentation"&&!u?Math.max(1.5,t):t,n),Math.sqrt(d/a/c)),g=Math.floor(a*m)*Math.floor(c*m),x=h?96:o==="low"?12:48;return{quality:o,ratio:m,width:Math.max(1,Math.floor(a*m)),height:Math.max(1,Math.floor(c*m)),pixels:g,maxPixels:d,estimatedBytes:g*x+(o==="low"?0:2*(o==="presentation"&&!u?2048:1024)**2*4)}}function lE(i=1.6,e="high"){let t=Number.isFinite(i)&&i>0?i:1.6;return{radius:Math.max(.35,Math.min(3,t*.85)),thickness:Math.max(.12,Math.min(1,t*.3)),distanceExponent:2,distanceFallOff:1,scale:1,samples:e==="presentation"?24:12,screenSpaceRadius:!1}}function uE(i,e){let t=e==="B.Cu"?"B.Mask":"F.Mask";return Array.isArray(i?.layers)&&(i.layers.includes(t)||i.layers.includes("*.Mask"))}var Gc=Object.freeze({coatedCopper:1459761,exposedCopper:12954220});function hE(i,e,t,n){let r=0,s=0;for(let o=0;o<3;o++)r+=((t[o]+n[o])/2-i[o])*e[o],s+=(n[o]-t[o])/2*Math.abs(e[o]);return r-s}function dE(i,e,t){let n=Number.isFinite(i)&&i>0?i:1,r=Number.isFinite(e)&&e>0?e:1,s=Number.isFinite(t)?t:n-r,o=Math.max(.005,s*.5);return{near:o,far:Math.max(10,n+r*4,o+1)}}var fE=Object.freeze([{x:.65,y:-.45,z:1,intensity:1.25,color:16774632},{x:.65,y:-.45,z:-1,intensity:1.25,color:16774632},{x:-.8,y:.35,z:.6,intensity:.65,color:15069183},{x:-.8,y:.35,z:-.6,intensity:.65,color:15069183}].map(Object.freeze)),pr=Object.freeze({solderMask:Object.freeze({color:870709,roughness:.46,metalness:.04,clearcoat:.3,clearcoatRoughness:.5}),substrateEdge:Object.freeze({color:11049070,roughness:.92,metalness:0}),copper:Object.freeze({metalness:.62,roughness:.38}),proxy:Object.freeze({color:3489097,metalness:.06,roughness:.66})});function pE(i){let e=i.onBeforeCompile;i.onBeforeCompile=function(n,r){e?.call(this,n,r);let s="#include <logdepthbuf_fragment>";if(!n.fragmentShader.includes(s))throw Error("Unsupported occlusion depth shader.");n.fragmentShader=n.fragmentShader.replace(s,"")};let t=i.customProgramCacheKey;i.customProgramCacheKey=function(){return t.call(this)+"|perspective-occlusion-depth-v1"}}var tI=2e5,nI=6e5;function Xh(i){if(!i||!Array.isArray(i.points)||!Array.isArray(i.triangles)||!Array.isArray(i.values))throw new Error("A saved triangular result surface is required.");if(i.points.length>nI||i.triangles.length>tI)throw new Error("Saved surface exceeds the 200,000 triangle / 600,000 point limit.");let e=i.nodal!==!1;if(i.values.length!==(e?i.points.length:i.triangles.length))throw new Error("Saved result values do not match the surface.");for(let t of i.points)if(!Array.isArray(t)||t.length!==3||!t.every(n=>Number.isFinite(n)&&Number.isFinite(Math.fround(n))))throw new Error("Saved surface contains an invalid coordinate.");for(let t of i.triangles)if(!Array.isArray(t)||t.length!==3||!t.every(n=>Number.isSafeInteger(n)&&n>=0&&n<i.points.length))throw new Error("Saved surface contains an invalid triangle index.");for(let t of i.values)if(t!==null&&!Number.isFinite(t))throw new Error("Saved surface contains an invalid result value.");return{...i,nodal:e}}function mE(i){i.traverse(e=>{e.geometry?.dispose(),(Array.isArray(e.material)?e.material:[e.material]).forEach(n=>{n?.map?.dispose(),n?.dispose()})}),i.clear()}function Yh(i,e=n=>n,t={}){let n=Xh(i),r=t.palette;if(r!==void 0&&(!Array.isArray(r)||r.length!==4||r.some(b=>!Array.isArray(b)||b.length!==3||b.some(E=>!Number.isFinite(E)||E<0||E>255))))throw new TypeError("Choose four finite RGB palette stops.");if(t.range!==void 0&&(!Array.isArray(t.range)||t.range.length!==2||!t.range.every(Number.isFinite)||t.range[1]<=t.range[0]))throw new TypeError("Choose an increasing finite result range.");let s=new Dt,o=new Dt,a=1/0,c=-1/0;for(let b of n.values)b!==null&&(a=Math.min(a,b),c=Math.max(c,b));t.range&&(a=t.range[0],c=t.range[1]);let l=[],u=[],h=[],d=[],m=[new Ue(2639291),new Ue(52179),new Ue(16769114),new Ue(15154225)],g=b=>Number.isFinite(c-a)?(b-a)/(c-a):(b/2-a/2)/(c/2-a/2),x=b=>c>a?Math.max(0,Math.min(1,g(b))):.5,f=b=>{let E=x(b)*3,A=Math.min(2,Math.floor(E)),T=E-A;if(r){let M=r[A].map((S,C)=>Math.round(S+(r[A+1][C]-S)*T)/255);return new Ue().setRGB(...M,wt)}return m[A].clone().lerp(m[A+1],T)};n.triangles.forEach((b,E)=>{let A=n.nodal?b.map(N=>n.values[N]):b.map(()=>n.values[E]);if(A.some(N=>N===null))return;let T=b.map(N=>e(n.points[N]));if(T.some(N=>!Array.isArray(N)||N.length!==3||!N.every(I=>Number.isFinite(I)&&Number.isFinite(Math.fround(I)))))throw new Error("Invalid result coordinate mapping.");let M=new z(...T[0]),S=new z(...T[1]),C=new z(...T[2]);S.clone().sub(M).cross(C.clone().sub(M)).lengthSq()!==0&&(T.forEach((N,I)=>{l.push(...N);let L=f(A[I]);u.push(L.r,L.g,L.b),t.range&&d.push(g(A[I]))}),h.push(E))});let p=new ot;p.setAttribute("position",new ze(l,3)),p.setAttribute("color",new ze(u,3)),t.range&&p.setAttribute("resultScalar",new ze(d,1)),p.computeBoundingSphere();let v=new Ht({vertexColors:!0,toneMapped:!1,side:xn,transparent:!0,opacity:.85,depthWrite:!1,polygonOffset:!0,polygonOffsetFactor:-2,polygonOffsetUnits:-2}),_=new ct(p,v);s.add(_,o);function y(b){if(!b||b.object!==_||b.faceIndex==null)return null;let E=h[b.faceIndex],A=n.triangles[E];if(!A)return null;let T=A.map(I=>new z(...e(n.points[I]))),M=new z;if(Oi.getBarycoord(b.point,...T,M),![M.x,M.y,M.z].every(Number.isFinite))return null;let S=A.map(I=>n.points[I]),C=I=>S[0][I]*M.x+S[1][I]*M.y+S[2][I]*M.z,N=n.nodal?n.values[A[0]]*M.x+n.values[A[1]]*M.y+n.values[A[2]]*M.z:n.values[E];return{x:C(0),y:C(1),z:C(2),value:N,unit:String(n.unit||""),method:n.nodal?"nodal barycentric interpolation":"saved cell value",triangle:E}}return{group:s,mesh:_,surface:n,min:a,max:c,range:Number.isFinite(a)&&Number.isFinite(c)?[a,c]:null,sample:y,setOpacity(b){Number.isFinite(b)&&(v.opacity=Math.max(0,Math.min(1,b)),_.visible=v.opacity>0)},setProbes(b=[]){if(mE(o),!Array.isArray(b))return;let E=Math.max((p.boundingSphere?.radius||1)*.012,.001);for(let A of b.slice(0,100)){if(![A.x,A.y,A.z].every(Number.isFinite))continue;let T=new ct(new _i(E,12,8),new Ht({color:16777215,depthTest:!1}));if(T.position.set(...e([A.x,A.y,A.z])),T.renderOrder=10,T.userData.label=String(A.label||""),o.add(T),A.label){let M=document.createElement("canvas");M.width=256,M.height=64;let S=M.getContext("2d");if(S){S.fillStyle="#101d28",S.fillRect(0,0,256,64),S.fillStyle="#fff",S.font="bold 32px system-ui",S.textBaseline="middle",S.fillText(String(A.label).slice(0,12),8,32,240);let C=new ns(M);C.colorSpace=wt;let N=new Lo(new Hs({map:C,depthTest:!1}));N.position.copy(T.position).add(new z(0,0,E*4)),N.scale.set(E*12,E*3,1),N.renderOrder=11,o.add(N)}}}},dispose(){mE(s),s.removeFromParent()}}}function iI(i,e={}){let t=document.createElement("div");t.style.cssText="height:100%;min-height:240px;display:flex;flex-direction:column;position:relative";let n=t.attachShadow({mode:"open"}),r=document.createElement("style");r.textContent=":host{font:12px system-ui}*{box-sizing:border-box}.shell{height:100%;min-height:240px;display:flex;flex-direction:column}.bar{display:flex;flex-wrap:wrap;gap:8px;align-items:center;padding:8px}button{padding:5px 10px;border-radius:4px;border:1px solid #819597;background:transparent;color:inherit;cursor:pointer}button:focus-visible,input:focus-visible{outline:2px solid #42bd95}.stage{position:relative;flex:1;min-height:200px;overflow:hidden}.stage canvas{display:block;width:100%;height:100%;touch-action:none}.notice{padding:6px 8px}.value{padding:6px 8px;min-height:28px}label{display:flex;gap:4px;align-items:center}.title{font-weight:700}";let s=document.createElement("div");s.className="shell";let o=document.createElement("div");o.className="bar";let a=document.createElement("span");a.className="title",o.append(a);let c=document.createElement("div");c.className="stage";let l=document.createElement("div");l.className="notice";let u=document.createElement("div");u.className="value",u.setAttribute("aria-live","polite"),s.append(o,c,l,u),n.append(r,s),i.append(t);let h;try{h=new fs({antialias:!0,alpha:!1})}catch{return l.textContent="3D rendering is unavailable on this device. Use the 2D result view.",{host:t,unavailable:!0,setSurface(){},setOpacity(){},setTheme(){},setProbes(){},fit(){},dispose(){t.remove()}}}h.outputColorSpace=wt,h.domElement.setAttribute("role","img"),h.domElement.setAttribute("aria-label","3D saved result surface"),c.append(h.domElement);let d=new oi;d.background=new Ue(1056040);let m=new jt(45,1,.001,1e6);m.up.set(0,0,1);let g=new Qs(m,h.domElement);g.enableDamping=!0;let x=null,f=!0,p=0,v=.85,_=[],y=new Me,b=new lr;function E(V=!1){if(!f||!x)return;let w=new zt().setFromObject(x.mesh),O=w.getBoundingSphere(new qt);if(w.isEmpty())return;let W=Math.max(O.radius,.001),Q=W/Math.sin(Js.degToRad(m.fov/2))*1.25/Math.min(m.aspect,1);g.target.copy(O.center),m.position.copy(O.center).add(new z(...V?[0,-1e-6,1]:[1,-1,1]).normalize().multiplyScalar(Q)),m.near=Math.max(W*1e-5,1e-6),m.far=Q+W*1e3,m.updateProjectionMatrix(),g.minDistance=W*.005,g.maxDistance=W*1e3,g.update()}function A(V){if(!f)return;let w=Yh(V,([O,W,Q])=>[O,-W,Q]);x?.dispose(),x=w,d.add(w.group),w.setOpacity(v),w.setProbes(_),a.textContent=String(V.title||"Saved result surface"),l.textContent=`${V.zKnown?"Saved surface geometry":"No saved layer elevation; flat field"} \xB7 drag to orbit \xB7 right-drag / two fingers to pan \xB7 pinch / wheel to zoom${Number.isFinite(w.min)?` \xB7 ${w.min.toPrecision(5)}\u2013${w.max.toPrecision(5)} ${V.unit||""}`:" \xB7 no valid samples"}`,u.textContent="Click a colored surface to probe.",E()}let T=(V,w)=>{let O=document.createElement("button");O.textContent=V,O.type="button",O.addEventListener("click",w),o.append(O)};T("Fit",()=>E()),T("Top",()=>E(!0));let M=document.createElement("label");M.textContent="Opacity";let S=document.createElement("input");S.type="range",S.min="0",S.max="1",S.step=".05",S.value=String(v),S.setAttribute("aria-label","Result surface opacity"),M.append(S),o.append(M);let C=V=>{!f||!Number.isFinite(V)||(v=Math.max(0,Math.min(1,V)),S.value=String(v),x?.setOpacity(v))};S.addEventListener("input",()=>C(Number(S.value)));function N(V){if(!x||!x.mesh.visible)return null;let w=h.domElement.getBoundingClientRect();return!w.width||!w.height?null:(y.set((V.clientX-w.left)/w.width*2-1,-(V.clientY-w.top)/w.height*2+1),b.setFromCamera(y,m),x.sample(b.intersectObject(x.mesh,!1)[0]))}let I=null,L=V=>{I={id:V.pointerId,x:V.clientX,y:V.clientY,moved:!1}},q=V=>{I&&(I.id!==V.pointerId||Math.hypot(V.clientX-I.x,V.clientY-I.y)>5)&&(I.moved=!0),e.onHover?.(N(V))},K=V=>{let w=I&&I.id===V.pointerId&&!I.moved&&(V.button===0||V.pointerType==="touch");if(I=null,!w)return;let O=N(V);O&&(u.textContent=`${O.value.toPrecision(6)} ${O.unit} at (${O.x.toFixed(3)}, ${O.y.toFixed(3)}, ${O.z.toFixed(3)}) \xB7 ${O.method}`,e.onProbe?.(O))},B=()=>{I=null},j=()=>e.onHover?.(null);for(let[V,w]of[["pointerdown",L],["pointermove",q],["pointerup",K],["pointercancel",B],["pointerleave",j]])h.domElement.addEventListener(V,w);let J=()=>{if(!f)return;let V=Math.max(c.clientWidth,1),w=Math.max(c.clientHeight,1),O=Wh(V,w,globalThis.devicePixelRatio,h.capabilities.maxTextureSize);h.getPixelRatio()!==O&&h.setPixelRatio(O),h.setSize(V,w,!1),m.aspect=V/w,m.updateProjectionMatrix()},se=new ResizeObserver(J);se.observe(c),J();let ce=V=>{V.preventDefault(),l.textContent="3D graphics context lost. Reopen this view to restore rendering.",f=!1,cancelAnimationFrame(p)};h.domElement.addEventListener("webglcontextlost",ce);let me=V=>{t.style.background=V?"#101d28":"#f3f7f5",t.style.color=V?"#e7f3ef":"#172e36",d.background.setHex(V?1056040:15988725)};me(e.dark!==!1);try{A(e.surface)}catch(V){throw se.disconnect(),g.dispose(),h.dispose(),t.remove(),V}let Se=()=>{f&&(p=requestAnimationFrame(Se),g.update(),h.render(d,m))};return Se(),{host:t,setSurface:A,setOpacity:C,setTheme:me,fit:E,setProbes(V){_=Array.isArray(V)?V:[],x?.setProbes(_)},dispose(){f=!1,cancelAnimationFrame(p),se.disconnect(),g.dispose(),x?.dispose(),h.domElement.removeEventListener("webglcontextlost",ce);for(let[V,w]of[["pointerdown",L],["pointermove",q],["pointerup",K],["pointercancel",B],["pointerleave",j]])h.domElement.removeEventListener(V,w);h.dispose(),t.remove()}}}var rI=1e4,sI=2e5,Jx="Source XYZ translated by the saved bounds center; +Z up; no PCB registration",yE=i=>Array.isArray(i)&&i.length===3&&i.every(e=>Number.isFinite(e)&&Number.isFinite(Math.fround(e)));function Zx(i,e){return Object.assign(new Error(i),{code:e,fallback:"2d"})}function gE(){return new DOMException("Saved result view was aborted.","AbortError")}function xE(i,e){for(let t=0;t<3;t++)i.min[t]=Math.min(i.min[t],e[t]),i.max[t]=Math.max(i.max[t],e[t])}function oI(i){let[e,t,n]=i,r=t.map((o,a)=>o-e[a]),s=n.map((o,a)=>o-e[a]);return Math.hypot(r[1]*s[2]-r[2]*s[1],r[2]*s[0]-r[0]*s[2],r[0]*s[1]-r[1]*s[0])>0}function Qx(i,{contextPrimitives:e=[],coordinateUnit:t="source units",range:n,palette:r="wayricad"}={}){let s=dl(r),o=Xh(i);if(n!==void 0&&(!Array.isArray(n)||n.length!==2||!n.every(Number.isFinite)||n[1]<=n[0]))throw new TypeError("Choose an increasing finite saved-field range.");if(o.zKnown!==!0)throw Zx("No saved Z coordinates or layer elevation. Use the 2D field view.","SAVED_Z_REQUIRED");if(typeof t!="string"||t.length>80||/[\x00-\x1f]/.test(t))throw new TypeError("Choose a bounded source coordinate unit label.");if(!Array.isArray(e)||e.length>rI)throw new TypeError("Saved context exceeds 10,000 primitives.");let a={min:[1/0,1/0,1/0],max:[-1/0,-1/0,-1/0]},c=[],l=[],u=0,h=0,d=0,m=0;if(o.triangles.forEach((x,f)=>{if((o.nodal?x.map(p=>o.values[p]):[o.values[f]]).some(p=>p===null)||!oI(x.map(p=>o.points[p]))){h++;return}u++;for(let p of x)xE(a,o.points[p])}),!u)throw Zx("No valid saved triangles with known field values. Missing samples remain holes in the 2D field view.","NO_SAVED_FIELD_VALUES");for(let x of e){let f=x?.points;if(!["line","polygon"].includes(x?.type)||!Array.isArray(f)||f.length<(x.type==="polygon"?3:2)||!f.every(yE)){m++;continue}if(d+=f.length,d>sI)throw new TypeError("Saved context exceeds 200,000 explicit XYZ points.");let p=f.map(v=>[...v]);c.push({type:x.type,points:p}),p.forEach(v=>xE(a,v))}m&&l.push(m+" context primitives without supported explicit XYZ geometry were omitted; no elevation was invented."),h&&l.push(h+" triangles with missing values or degenerate geometry remain unrendered.");let g=a.min.map((x,f)=>x/2+a.max[f]/2);if(a.max.some((x,f)=>x-a.min[f]>1e7))throw Zx("Saved geometry exceeds the bounded 3D coordinate span. Use the 2D field view.","SAVED_GEOMETRY_RANGE");return{surface:o,context:c,bounds:a,origin:g,palette:r,stops:s,range:n?[...n]:md(o.values),coordinateUnit:t||"source units",coordinateConvention:Jx,renderedTriangles:u,omittedTriangles:h,diagnostics:l}}function $x(i,e=iv){let t=i.mesh.material,n=t.clone(),r=t.onBeforeCompile,s=t.customProgramCacheKey(),o=!1,a=n;n.vertexColors=!1,n.onBeforeCompile=(u,h)=>{if(r.call(n,u,h),!u.vertexShader.includes("#include <begin_vertex>")||!u.fragmentShader.includes("#include <color_fragment>"))throw new Error("Unsupported saved-field color shader.");u.uniforms.savedFieldPalette={value:e.map(d=>new z(...d.map(m=>m/255)))},u.vertexShader=u.vertexShader.replace("#include <common>",`#include <common>
attribute float resultScalar;
varying float vSavedResultScalar;`).replace("#include <begin_vertex>",`#include <begin_vertex>
vSavedResultScalar = resultScalar;`),u.fragmentShader=u.fragmentShader.replace("#include <common>",`#include <common>
varying float vSavedResultScalar;
uniform vec3 savedFieldPalette[4];`).replace("#include <color_fragment>",`#include <color_fragment>
float fieldBand = clamp(vSavedResultScalar, 0.0, 1.0) * 3.0;
vec3 fieldRGB = fieldBand < 1.0 ? mix(savedFieldPalette[0], savedFieldPalette[1], fieldBand) : fieldBand < 2.0 ? mix(savedFieldPalette[1], savedFieldPalette[2], fieldBand - 1.0) : mix(savedFieldPalette[2], savedFieldPalette[3], fieldBand - 2.0);
fieldRGB = floor(fieldRGB * 255.0 + 0.5) / 255.0;
diffuseColor.rgb = sRGBTransferEOTF(vec4(fieldRGB, 1.0)).rgb;`)},n.customProgramCacheKey=()=>s+":wayricad-scalar-palette-v1",i.mesh.material=n;let c=i.setOpacity;i.setOpacity=u=>{c(u),a&&(a.opacity=t.opacity)};let l={material:n,fallbackMaterial:t,get mode(){return a?"scalar":"vertex-color"},useFallback(){return o||!a?!1:(i.mesh.material=t,a.dispose(),a=null,!0)},dispose(){o||(o=!0,a&&t.dispose())}};return i.mesh.geometry.getAttribute("resultScalar").array.every(Number.isFinite)||l.useFallback(),l}function aI(i,e={}){let t=Qx(i,e),n=u=>u.map((h,d)=>h-t.origin[d]),r=Yh(t.surface,n,{palette:t.stops,range:t.range}),s=$x(r,t.stops),o=new Dt,a=[];s.mode==="vertex-color"&&t.diagnostics.push("Scalar values exceed the GPU normalization range; vertex-color interpolation is active. Probe values remain exact.");let c=null,l=!1;try{for(let u of t.context){let h=u.points;for(let d=1;d<h.length;d++)a.push(...n(h[d-1]),...n(h[d]));u.type==="polygon"&&a.push(...n(h.at(-1)),...n(h[0]))}if(a.length){let u=new ot;u.setAttribute("position",new ze(a,3)),c=new ln(u,new Xt({color:8886951,transparent:!0,opacity:.65})),o.add(c)}o.add(r.group)}catch(u){throw s.dispose(),r.dispose(),c?.geometry.dispose(),c?.material.dispose(),u}return{group:o,overlay:r,prepared:t,contextMesh:c,scalarAppearance:s,dispose(){l||(l=!0,s.dispose(),r.dispose(),c?.geometry.dispose(),c?.material.dispose(),o.clear(),o.removeFromParent())}}}function cI(i){let e=u=>{let h=i?.[u];if(!yE(h)||h.some(d=>Math.abs(d)>1e12))throw new TypeError("Choose finite bounded source-view camera vectors.");return[...h]},t=e("position"),n=e("target"),r=e("up"),s=t.map((u,h)=>u-n[h]),o=Math.hypot(...s),a=Math.hypot(...r);if(!(o>0)||!(a>0))throw new TypeError("Choose a nondegenerate source-view camera.");let c=s.map(u=>u/o),l=r.map(u=>u/a);if(Math.hypot(c[1]*l[2]-c[2]*l[1],c[2]*l[0]-c[0]*l[2],c[0]*l[1]-c[1]*l[0])<1e-6)throw new TypeError("Choose a camera up vector independent of its direction.");return{position:t,target:n,up:r}}function lI(i,e,t={}){if(t.signal?.aborted)throw gE();let n=i?.ownerDocument;if(!n||typeof i.append!="function")throw new TypeError("Choose a saved result viewer container.");let r,s;try{r=Qx(e,t)}catch(V){if(V.fallback!=="2d")throw V;s=V}r&&t.range!==void 0&&(t={...t,range:[...r.range]});let o=n.createElement("div"),a=n.createElement("div"),c=n.createElement("div"),l=n.createElement("div");o.style.cssText="height:100%;min-height:240px;display:flex;flex-direction:column;position:relative;font:12px/1.5 system-ui",a.style.cssText="position:relative;flex:1;min-height:180px;overflow:hidden",c.style.cssText=l.style.cssText="padding:6px 8px;overflow-wrap:anywhere",c.setAttribute("role","status"),l.setAttribute("aria-live","polite"),o.append(a,c,l),i.append(o);let u=V=>{o.style.background=V?"#101d28":"#f3f7f5",o.style.color=V?"#e7f3ef":"#172e36"};u(t.dark!==!1);let h=V=>{let w=!1;c.textContent=V.message,a.hidden=!0;let O=()=>{w||(w=!0,t.signal?.removeEventListener("abort",O),o.remove())};t.signal?.addEventListener("abort",O,{once:!0});let W={host:o,unavailable:!0,diagnostic:{code:V.code||"WEBGL_UNAVAILABLE",message:V.message,fallback:"2d"},setSurface(Q){return Qx(Q,t),!1},setTheme:u,setOpacity(){},fit(){return!1},getCameraState(){return null},setCameraState(){return!1},getRenderStats(){return{unavailable:!0,renderCount:0,coordinateConvention:Jx,coordinateUnit:t.coordinateUnit||"source units"}},dispose:O};try{t.onDiagnostics?.([V.message])}catch(Q){throw O(),Q}return W};if(s)return h(s);let d;try{d=new fs({antialias:!0,alpha:!1})}catch{return h(new Error("3D graphics are unavailable on this device. Use the 2D field view."))}let m=!0,g=null,x=.85,f=0,p=0,v=!1,_=null,y=null,b=null,E=null,A=new oi,T=new jt(45,1,.001,1e3);T.up.set(0,0,1),d.outputColorSpace=wt,d.domElement.style.cssText="display:block;width:100%;height:100%;touch-action:none",d.domElement.setAttribute("role","img"),d.domElement.setAttribute("aria-label","3D saved field in source XYZ coordinates"),a.append(d.domElement);let M=[],S=new Me,C=new lr,N=pm(),I=(V,w,O)=>{V.addEventListener(w,O),M.push(()=>V.removeEventListener(w,O))},L=()=>a.clientWidth>0&&a.clientHeight>0,q=()=>{m&&(b.setState({documentVisible:!n.hidden,hasSize:L()}),b.invalidate())};d.debug.onShaderError=()=>{v=!0};function K(){if(m){E.update(),v=!1;try{if(d.render(A,T),v)throw new Error("Saved scalar color shader failed.");f++}catch(V){if(g?.scalarAppearance.useFallback()){p++,g.prepared.diagnostics.push("Scalar color mapping is unavailable; vertex-color interpolation is active. Probe values remain exact."),J(g.prepared),t.onDiagnostics?.([...g.prepared.diagnostics]),v=!1;try{if(d.render(A,T),v)throw V;f++}catch{c.textContent="3D graphics could not draw this field. Use the 2D field view."}}else c.textContent="3D graphics could not draw this field. Use the 2D field view."}}}function B(){if(!g)return;let V=Math.max(g.sphere.radius,1e-12),w=T.position.distanceTo(g.sphere.center);T.near=Math.max(V*1e-7,(w-V)*.5,1e-15),T.far=Math.max(w+V*4,T.near*2),T.updateProjectionMatrix()}function j(V=!1){if(!m||!g||new zt().setFromObject(g.group).isEmpty())return!1;let O=g.sphere,W=Math.max(O.radius,1e-12),Q=nm(W,T.fov,T.aspect,1.2);return E.target.copy(O.center),T.position.copy(O.center).add(new z(...V?[0,-1e-6,1]:[1,-1,1]).normalize().multiplyScalar(Q)),B(),E.minDistance=W*1e-4,E.maxDistance=W*100,E.update(),q(),!0}function J(V){c.textContent="Independent saved field \xB7 "+V.coordinateUnit+" \xB7 source XYZ, +Z up \xB7 saved Z"+(V.surface.zBasis?" ("+String(V.surface.zBasis).slice(0,160)+")":"")+" \xB7 no PCB registration"+(V.context.length?" \xB7 retained source context":"")+" \xB7 "+V.renderedTriangles+" colored triangles \xB7 "+V.range.map(w=>Number(w.toPrecision(6))).join(" \u2013 ")+(V.surface.unit?" "+String(V.surface.unit).slice(0,80):"")+(g?.scalarAppearance.mode==="vertex-color"?" \xB7 vertex-color interpolation fallback":""),l.textContent="Drag to orbit \xB7 right-drag or two fingers to pan \xB7 pinch or wheel to zoom \xB7 tap a colored triangle to probe."}function se(V,{retainCamera:w=!1}={}){if(!m)return!1;let O=aI(V,t);O.overlay.setOpacity(x),A.add(O.group),O.sphere=new zt().setFromObject(O.group).getBoundingSphere(new qt);let W=g;return g=O,W?.dispose(),J(g.prepared),w?B():j(),t.onDiagnostics?.([...g.prepared.diagnostics]),q(),!0}function ce(){if(!m)return;let V=L();if(b.setState({hasSize:V}),!V){q();return}let w=a.clientWidth,O=a.clientHeight,W=Wh(w,O,globalThis.devicePixelRatio,d.capabilities.maxTextureSize);d.getPixelRatio()!==W&&d.setPixelRatio(W),d.setSize(w,O,!1),T.aspect=w/O,T.updateProjectionMatrix(),q()}function me(V){if(!g?.overlay.mesh.visible)return null;let w=d.domElement.getBoundingClientRect();return!w.width||!w.height?null:(S.set((V.clientX-w.left)/w.width*2-1,-(V.clientY-w.top)/w.height*2+1),C.setFromCamera(S,T),g.overlay.sample(C.intersectObject(g.overlay.mesh,!1)[0]))}function Se(){if(m){m=!1,b?.dispose(),_?.disconnect(),y?.disconnect();for(let V of M)V();M.length=0,t.signal?.removeEventListener("abort",Se),E?.dispose(),g?.dispose(),g=null,A.clear(),d.dispose(),d.domElement.width=d.domElement.height=1,o.remove()}}try{if(E=new Qs(T,d.domElement),E.enableDamping=!1,b=dm({request:V=>requestAnimationFrame(V),cancel:V=>cancelAnimationFrame(V),render:K,canRender:()=>m&&!n.hidden&&L(),state:{documentVisible:!n.hidden,hasSize:L()}}),I(E,"change",()=>{B(),q()}),I(n,"visibilitychange",()=>{b.setState({documentVisible:!n.hidden}),n.hidden||q()}),I(d.domElement,"pointerdown",V=>N.down(V)),I(d.domElement,"pointermove",V=>{N.move(V),t.onHover&&t.onHover(me(V))}),I(d.domElement,"pointerup",V=>{if(!N.up(V)||V.button!==0&&V.pointerType!=="touch")return;let w=me(V);w&&(l.textContent=w.value.toPrecision(6)+" "+w.unit+" at source XYZ ("+[w.x,w.y,w.z].map(O=>Number(O.toPrecision(7))).join(", ")+") "+g.prepared.coordinateUnit+" \xB7 "+w.method,t.onProbe?.(w))}),I(d.domElement,"pointercancel",V=>N.cancel(V)),I(d.domElement,"pointerleave",()=>t.onHover?.(null)),I(d.domElement,"webglcontextlost",V=>{V.preventDefault(),b.setState({contextAvailable:!1}),c.textContent="3D graphics context interrupted. Saved field geometry is retained."}),I(d.domElement,"webglcontextrestored",()=>{b.setState({contextAvailable:!0}),g&&J(g.prepared),q()}),typeof ResizeObserver=="function"?(_=new ResizeObserver(ce),_.observe(a)):n.defaultView&&I(n.defaultView,"resize",ce),y=fm(b,a),t.signal?.addEventListener("abort",Se,{once:!0}),A.background=new Ue(t.dark!==!1?1056040:15988725),ce(),se(r.surface),t.signal?.aborted)throw Se(),gE()}catch(V){throw Se(),V}return{host:o,unavailable:!1,setSurface:se,setPalette(V){if(dl(V),!m)return!1;let w=t;t={...t,palette:V};try{return se(g.prepared.surface,{retainCamera:!0})}catch(O){throw t=w,O}},setProbes(V){g?.overlay.setProbes(V),q()},setTheme(V){m&&(u(!!V),A.background.setHex(V?1056040:15988725),q())},setOpacity(V){if(m){if(!Number.isFinite(V)||V<0||V>1)throw new TypeError("Choose result opacity between 0 and 1.");x=V,g.overlay.setOpacity(V),q()}},fit:j,getCameraState(){return{position:T.position.toArray(),target:E.target.toArray(),up:T.up.toArray()}},setCameraState(V){if(!m)return!1;let w=cI(V);T.position.fromArray(w.position),E.target.fromArray(w.target),T.up.fromArray(w.up);let O=T.position.distanceTo(E.target);return E.minDistance=Math.min(E.minDistance,O),E.maxDistance=Math.max(E.maxDistance,O),E.update(),q(),!0},getRenderStats(){let V=g?.prepared;return{unavailable:!1,renderCount:f,renderActivity:{...b.stats(),observesIntersection:!!y},drawCalls:d.info.render.calls,gpuTextures:d.info.memory.textures,renderedTriangles:V?.renderedTriangles||0,omittedTriangles:V?.omittedTriangles||0,contextPrimitives:V?.context.length||0,range:V?[...V.range]:null,palette:V?.palette||"wayricad",colorInterpolation:g?.scalarAppearance.mode||null,scalarColorFallbacks:p,coordinateUnit:V?.coordinateUnit||t.coordinateUnit||"source units",coordinateConvention:Jx,sourceOrigin:V?[...V.origin]:null,sourceBounds:V?{min:[...V.bounds.min],max:[...V.bounds.max]}:null}},dispose:Se}}function jh(i){return Object.assign(new Error(i),{code:"UNSUPPORTED_RESULT_REGISTRATION"})}function uI(i,{bounds:e,thickness:t,layers:n=[]},r={}){let s=Xh(i),o=s.zBasis,a=s.layer??r.layer??null;if(r.layer!==void 0&&s.layer!==void 0&&r.layer!==s.layer)throw jh("Selected layer does not match the saved result layer.");if(a!==null&&(typeof a!="string"||!n.includes(a)))throw jh("Saved result layer is not present on this board.");if(o!=null&&!["front-depth","board-center"].includes(o))throw jh("Saved result elevation basis is unsupported; use the standalone result scene.");if(s.zKnown===!0?!["front-depth","board-center"].includes(o):!["F.Cu","B.Cu"].includes(s.layer))throw jh("Saved elevation requires front-depth or board-center; without saved Z only saved F.Cu/B.Cu layers can be placed.");if(!e||![e.minX,e.minY,e.maxX,e.maxY,t].every(Number.isFinite)||e.minX>e.maxX||e.minY>e.maxY||t<=0)throw new TypeError("Choose finite board bounds and a positive thickness.");let c=r.palette===void 0?null:dl(r.palette);if(r.range!==void 0&&(!Array.isArray(r.range)||r.range.length!==2||!r.range.every(Number.isFinite)||r.range[1]<=r.range[0]))throw new TypeError("Choose an increasing finite result range.");let l=e.minX/2+e.maxX/2,u=e.minY/2+e.maxY/2,h=([m,g,x])=>[m-l,u-g,s.zKnown===!0?o==="front-depth"?t/2-x:x:s.layer==="F.Cu"?t/2:-t/2],d=r.range?[...r.range]:c?md(s.values):null;if(c&&!d)throw jh("No known saved field values are available for placement.");return{surface:s,transform:h,stops:c,palette:r.palette??null,layer:a,basis:s.zKnown===!0?o:s.layer,flat:s.zKnown!==!0,range:d,throughBoard:r.throughBoard!==!1}}function hI(i,e,t={}){let n=uI(i,e,t),r=Yh(n.surface,n.transform,{...n.range?{range:n.range}:{},...n.stops?{palette:n.stops}:{}}),s=r.sample;r.sample=l=>{let u=s(l);return u?{...u,overlayOwner:t.owner}:null};let o=null,a=!1;try{r.mesh.material.depthTest=!n.throughBoard,r.mesh.renderOrder=n.throughBoard?20:0,n.stops&&(o=$x(r,n.stops))}catch(l){throw o?.dispose(),r.dispose(),l}let c=[];return o?.mode==="vertex-color"&&c.push("Scalar values exceed the GPU normalization range; vertex-color interpolation is active. Probe values remain exact."),{overlay:r,prepared:n,scalarAppearance:o,diagnostics:c,state(){return{placed:!0,palette:n.palette,layer:n.layer,basis:n.basis,flat:n.flat,throughBoard:n.throughBoard,triangles:r.mesh.geometry.getAttribute("position").count/3,range:r.range?[...r.range]:null,diagnostics:[...c]}},useColorFallback(){return o?.useFallback()?(c.push("Scalar color mapping is unavailable; vertex-color interpolation is active. Probe values remain exact."),!0):!1},dispose(){a||(a=!0,o?.dispose(),r.dispose())}}}function vE(i,{scene:e,invalidate:t=()=>{},isActive:n=()=>!0}={}){let r=null,s,o=c=>c?.owner===void 0||c.owner===s,a=c=>({placed:!1,layer:null,basis:null,throughBoard:!1,triangles:0,range:null,diagnostics:[],...c?{reason:c}:{}});return{get overlay(){return r?.overlay||null},getAnalysisOverlayState(){return r?r.state():a()},setAnalysisOverlay(c,l={}){if(!n())return a("3D viewer is closed.");if(!c)return o(l)?(r?.dispose(),r=null,s=void 0,t(),a("Overlay cleared.")):a("Overlay belongs to another owner.");let u;try{u=hI(c,i,l)}catch(d){if(d.code==="UNSUPPORTED_RESULT_REGISTRATION")return a(d.message);throw d}e.add(u.overlay.group);let h=r;return r=u,s=l.owner,h?.dispose(),t(),r.state()},setAnalysisProbes(c,l={}){return!r||!o(l)?!1:(r.overlay.setProbes(c),t(),!0)},setAnalysisOpacity(c,l={}){return!r||!o(l)?!1:(r.overlay.setOpacity(c),t(),!0)},useColorFallback(){return r?.useColorFallback()||!1},dispose(){r?.dispose(),r=null,s=void 0}}}var Ki=i=>i&&typeof i=="object"&&!Array.isArray(i)?i.quoted:i,gm=i=>Array.isArray(i)?String(Ki(i[0])):"",ey=(i,e)=>i.filter(t=>gm(t)===e),eo=(i,e)=>ey(i,e)[0],qh=(i,e,t)=>(e[0]-i[0])*(t[1]-i[1])-(e[1]-i[1])*(t[0]-i[0]),Kh=(i,e,t)=>Math.abs(qh(i,e,t))<1e-8&&t[0]>=Math.min(i[0],e[0])-1e-8&&t[0]<=Math.max(i[0],e[0])+1e-8&&t[1]>=Math.min(i[1],e[1])-1e-8&&t[1]<=Math.max(i[1],e[1])+1e-8;function dI(i,e,t,n){let r=qh(i,e,t),s=qh(i,e,n),o=qh(t,n,i),a=qh(t,n,e);return r*s<0&&o*a<0||Kh(i,e,t)||Kh(i,e,n)||Kh(t,n,i)||Kh(t,n,e)}function _E(i,e){let t=!1;for(let n=0,r=e.length-1;n<e.length;r=n++){let s=e[n],o=e[r];if(Kh(s,o,i))return!1;s[1]>i[1]!=o[1]>i[1]&&i[0]<(o[0]-s[0])*(i[1]-s[1])/(o[1]-s[1])+s[0]&&(t=!t)}return t}function bE(i,e,t=[]){if(!Array.isArray(i)||i.length<3||!Array.isArray(e)||e.length<3||i.some(n=>!n.every(Number.isFinite)||!_E(n,e)||t.some(r=>_E(n,r))))return!1;for(let n of[e,...t])for(let r=0;r<i.length;r++)for(let s=0;s<n.length;s++)if(dI(i[r],i[(r+1)%i.length],n[s],n[(s+1)%n.length]))return!1;return!0}function ME(i,{maxContours:e=1e5}={}){if(!Number.isSafeInteger(e)||e<1)throw TypeError("Invalid zone contour index limit.");let t=new Map;for(let h of i)gm(h)==="net"&&t.set(Ki(h[1]),String(Ki(h[2])||""));let n=new Map,r=0,s=0,o=0,a=0,c=0,l=0,u=0;for(let h of i){if(gm(h)!=="zone")continue;let d=ey(h,"filled_polygon"),m=d.length>0;m||r++;let g=eo(h,"layers")?.slice(1).map(Ki)??[Ki(eo(h,"layer")?.[1])],x=Ki(eo(h,"uuid")?.[1])||Ki(eo(h,"tstamp")?.[1]),f=Ki(eo(h,"net")?.[1]),p=String(Ki(eo(h,"net_name")?.[1])||t.get(f)||(typeof f=="string"?f:""));for(let v of m?d:ey(h,"polygon")){let _=eo(v,"pts")||[],y=_[1]instanceof Float64Array?_[1].length/2:0,b=!1;for(let A of _)gm(A)==="xy"&&((!Number.isFinite(Number(Ki(A[1])))||!Number.isFinite(Number(Ki(A[2]))))&&(b=!0),y++);if(b||y<3){a++;continue}let E=Ki(eo(v,"layer")?.[1]);for(let A of E?[E]:g){if(typeof A!="string")continue;if(s>=e){c++;continue}let T={id:String(x||"saved-zone-"+s),net:p,layer:A,filled:m,size:y,contour:s,sourcePoints:_};n.has(A)||n.set(A,[]),n.get(A).push(T),s++,o+=y,A.endsWith(".Cu")?l++:u++}}}return{forLayer:h=>n.get(h)||[],stats:()=>({contours:s,copperContours:l,nonCopperContours:u,points:o,unfilled:r,invalid:a,omitted:c,layers:n.size,retainsCoordinateCopies:!1})}}var xm=i=>i&&["x","y","z"].every(e=>typeof i[e]=="number"&&Number.isFinite(i[e])),Wc=i=>({x:i.x,y:i.y,z:i.z,approximate:!!i.approximate});function fI(i,e){if(!xm(i)||!xm(e))return null;let t={x:e.x-i.x,y:e.y-i.y,z:e.z-i.z},n=Math.hypot(t.x,t.y,t.z);return Number.isFinite(n)?{from:Wc(i),to:Wc(e),delta:t,distance:n,approximate:!!(i.approximate||e.approximate)}:null}function vm(i,e="mm"){return typeof i!="number"||!Number.isFinite(i)||i<0?"\u2014":e==="mil"?(i/.0254).toFixed(2)+" mil":i.toFixed(3)+" mm"}var ym=class{constructor(){this.pending=null,this.records=[],this.selected=null,this.nextId=1}add(e){if(!xm(e))return null;if(!this.pending)return this.pending=Wc(e),this.selected=null,{pending:this.pending};let t=fI(this.pending,e);return t?(t.id=this.nextId++,this.pending=null,this.records.unshift(t),this.records.length>5&&(this.records.length=5),this.selected=t,t):null}replay(e){let t=this.records.find(n=>n.id===Number(e));return t?(this.pending=null,this.selected=t,t):null}clear(){this.pending=null,this.records=[],this.selected=null}snapshot(){return{pending:this.pending?Wc(this.pending):null,records:this.records.map(e=>({...e,from:Wc(e.from),to:Wc(e.to),delta:{...e.delta}})),selected:this.selected?.id??null}}};function EE(i,e,t,{mode:n="edges",tolerance:r=12}={}){if(!i||![i.x,i.y,r].every(Number.isFinite)||r<=0||!["edges","corners"].includes(n)||!Array.isArray(e))return null;let s=null,o=(a,c,l)=>{let u=Math.hypot(c.x-i.x,c.y-i.y);u<=r&&(!s||u<s.distance)&&(s={point:{x:a.x,y:a.y,z:a.z},screen:{x:c.x,y:c.y},kind:l,distance:u})};for(let a of e.slice(0,1e4)){if(!Array.isArray(a)||a.length!==2||!a.every(xm))continue;let[c,l]=a,u=t(c),h=t(l);if(!u||!h||![u.x,u.y,u.z,h.x,h.y,h.z].every(Number.isFinite)||u.z<-1||u.z>1||h.z<-1||h.z>1)continue;if(n==="corners"){o(c,u,"mesh vertex"),o(l,h,"mesh vertex");continue}let d=h.x-u.x,m=h.y-u.y,g=d*d+m*m;if(g<1e-10)continue;let x=Math.max(0,Math.min(1,((i.x-u.x)*d+(i.y-u.y)*m)/g)),f=Number.isFinite(u.w)&&u.w>0?u.w:1,p=Number.isFinite(h.w)&&h.w>0?h.w:1,v=x*f/((1-x)*p+x*f);o({x:c.x+(l.x-c.x)*v,y:c.y+(l.y-c.y)*v,z:c.z+(l.z-c.z)*v},{x:u.x+d*x,y:u.y+m*x},"mesh edge")}return s}var Zh=[{id:"top",label:"Top",direction:[0,0,1],up:[0,1,0]},{id:"bottom",label:"Bottom",direction:[0,0,-1],up:[0,-1,0]},{id:"front",label:"Front",direction:[0,-1,0],up:[0,0,1]},{id:"back",label:"Back",direction:[0,1,0],up:[0,0,1]},{id:"left",label:"Left",direction:[-1,0,0],up:[0,0,1]},{id:"right",label:"Right",direction:[1,0,0],up:[0,0,1]},{id:"isometric",label:"Isometric",direction:[.45,-.38,1],up:[0,0,1]}];function SE(i){let e=i===!0?"top":i===!1?"iso":i;return Zh.find(t=>t.id===e)||Zh.at(-1)}function TE({onChange:i=()=>{}}={}){let e=!1,t=0,n=-1,r=null,s=new Set,o=new WeakSet,a=new Map;function c(p){let v=p.source?.data,_=0,y=b=>{Number.isFinite(b?.width)&&Number.isFinite(b?.height)&&(_+=Math.ceil(b.width*b.height*4*(b.data?.BYTES_PER_ELEMENT||1)*(p.generateMipmaps?4/3:1)))};if(Array.isArray(v))for(let b of v)y(b);else y(v);return _}function l(){for(let[p,v]of a)if(p.instanceMatrix?.array!==v.matrix||p.instanceColor?.array!==v.color||p.boneMatrices!==v.bones||p.isTexture&&c(p)!==v.textureBytes)return!1;return!0}function u(p){return!p||typeof p!="object"||typeof p.dispose!="function"||(e?h(p):s.has(p)||(s.add(p),t++,i())),p}function h(p){o.has(p)||(o.add(p),p.dispose(),p.isTexture&&p.source?.data?.close?.())}function d(p,v=!1){let _=new Set,y=E=>{E&&typeof E.dispose=="function"&&!s.has(E)&&_.add(E)},b=E=>{if(!(!E||v&&s.has(E))){for(let A in E)Object.hasOwn(E,A)&&E[A]?.isTexture&&y(E[A]);y(E)}};return p?.traverse?.(E=>{if(E.isInstancedMesh&&y(E),y(E.geometry),Array.isArray(E.material))for(let A of E.material)b(A);else b(E.material);E.skeleton&&y(E.skeleton)}),_}function m(p,v=1/0,_=1/0,y=!1){let b=d(p,y),E=y&&!b.size&&n===t&&l()?r:f(b);if(!e&&(E.retainedGeometryBytes>v||E.retainedTextureBytes>_)){for(let A of b)h(A);throw Error("Decoded model geometry or textures exceed this device\u2019s memory budget.")}for(let A of b)u(A);return e||(E!==r&&g(),r=E,n=t),p}function g(){for(let p of s)if(p.isInstancedMesh||p.boneMatrices||p.isTexture){let v=a.get(p);v||(v={},a.set(p,v)),v.matrix=p.instanceMatrix?.array,v.color=p.instanceColor?.array,v.bones=p.boneMatrices,p.isTexture&&(v.textureBytes=c(p))}}function x(){if(!e){e=!0;for(let p of s)h(p);s.clear(),a.clear(),r=null,n=-1}}function f(p){let v=new Set,_=0,y=0,b=0,E=T=>{let M=T?.buffer;M&&!v.has(M)&&(v.add(M),_+=M.byteLength)},A=T=>{if(T.isTexture&&(y++,b+=c(T)),T.isInstancedMesh&&(E(T.instanceMatrix?.array),E(T.instanceColor?.array)),T.boneMatrices&&E(T.boneMatrices),T.isBufferGeometry){let M=S=>E(S?.array||S?.data?.array);for(let S in T.attributes)Object.hasOwn(T.attributes,S)&&M(T.attributes[S]);for(let S in T.morphAttributes)if(Object.hasOwn(T.morphAttributes,S))for(let C of T.morphAttributes[S])M(C);M(T.index)}};for(let T of s)A(T);if(p)for(let T of p)A(T);return{retainedResources:s.size+(p?.size||0),retainedGeometryBytes:_,retainedTextures:y,retainedTextureBytes:b}}return{track:u,retain:m,dispose:x,stats:()=>f(),discard(p){for(let v of d(p))h(v)},retainClone:(p,v,_)=>m(p,v,_,!0)}}function AE({onPick:i,onContextMenu:e,isHeld:t=()=>!1},n=6){let r=pm(n);return{down:s=>r.down(s),move:s=>r.move(s),cancel:s=>r.cancel(s),up(s,{select:o=!0}={}){let a=r.up(s);return o&&a&&!t()&&(s.button===0?i(s):s.button===2&&e(s)),a},context(s){s.preventDefault?.(),s.button!==2&&!t()&&e(s)}}}var wE=i=>{let e=Math.max(0,Math.min(1,i));return e*e*(3-2*e)};function ha(i){if(!Number.isFinite(i))throw new TypeError("Expand amount must be finite.");let e=Math.max(0,Math.min(100,i));return{amount:e,components:wE(e/35),layers:wE((e-35)/65)}}function RE({request:i,cancel:e,now:t=()=>performance.now(),update:n,canRun:r=()=>!0,reducedMotion:s=()=>!1,settle:o=()=>{}}){let a=0,c=0,l=null,u=0,h=!1;function d(){!h&&l===null&&a!==c&&r()&&(u=t(),l=i(m))}function m(g){if(l=null,h||!r())return;let x=Math.max(1,Math.min(64,g-u));u=g,a+=(c-a)*(1-Math.exp(-x/85)),Math.abs(c-a)<.04&&(a=c),n(a),!h&&(a!==c?l=i(m):o(a))}return{set(g,{immediate:x=!1}={}){return h||(c=ha(g).amount,x||s()?(l!==null&&e(l),l=null,a=c,n(a),h||o(a)):d()),c},resume:d,get:()=>a,target:()=>c,running:()=>l!==null,dispose(){h=!0,l!==null&&e(l),l=null}}}function CE(i,e,{maxGap:t=4,componentLift:n=8}={}){let r=[...e.layers||[]].filter(f=>typeof f.name=="string"&&Number.isFinite(f.z)).sort((f,p)=>p.z-f.z).slice(0,64),s=new Map(r.map((f,p)=>[f.name,(r.length-1)/2-p])),o=new WeakMap,a=new WeakMap,c=0,l=f=>{let p=ha(c).layers;return p===0?0:(s.get(f)||0)*t*p},u=f=>l(f)+(f==="B.Cu"?-1:1)*n*ha(c).components,h=f=>r.reduce((p,v)=>!p||Math.abs(v.z-f)<Math.abs(p.z-f)?v:p,null)?.name;function d(f,p){o.has(f)||o.set(f,f.position.z),f.position.z=o.get(f)+l(p),f.updateMatrix?.()}function m(f,p){o.has(f)||o.set(f,f.position.z),f.position.z=o.get(f)+u(p),f.updateMatrix?.()}function g(f,p){if(!f?.isInstancedMesh||!p||!(p.zMax>p.zMin))return;a.has(f)||a.set(f,f.instanceMatrix.array.slice());let v=a.get(f),_=l(h(p.zMin)),y=l(h(p.zMax)),b=(p.zMax-p.zMin+y-_)/(p.zMax-p.zMin),E=new i.Matrix4,A=new i.Vector3(1,1,b);for(let T=0;T<f.count;T++)E.fromArray(v,T*16),E.elements[14]+=_,E.scale(A),f.setMatrixAt(T,E);f.instanceMatrix.needsUpdate=!0,f.computeBoundingSphere?.(),f.computeBoundingBox?.()}function x(f){f.traverse(p=>{p.geometry&&(p.userData.explodeSpan?g(p,p.userData.explodeSpan):d(p,p.userData.layer||p.userData.record?.layer))})}return{offset:l,componentOffset:u,component:m,layer:d,barrels:g,overlay:x,set(f){return c=ha(f).amount,c},get:()=>c,phases:()=>ha(c),span:()=>t*ha(c).layers*Math.max(0,r.length-1),layers:r.map(f=>f.name)}}function PE(){let i=new WeakMap;return{sync(e,t){let n=e?.group;return n?t>0?(i.has(n)||i.set(n,n.visible),n.visible=!1,!0):(i.has(n)&&(n.visible=i.get(n),i.delete(n)),!1):!1}}}function IE(i,{scene:e,objects:t,visible:n=()=>!0,colorForLayer:r=()=>7534079,maxInstances:s=5e4,maxMeshes:o=2048}){let a=new i.Group;a.name="Selected net shine-through",e.add(a);let c=new Map,l=new Map,u=new i.Matrix4,h="",d=0,m=0,g=!1,x={sourceScans:0,recordScans:0,transformSyncs:0};function f(b,E=!1,A=!1,T="accent",M=!1){let S=[b,E,A,T,M].join("|");if(l.has(S))return l.get(S);let C={color:M||b==="through"?12954220:T==="source"?r(b):7534079,transparent:!0,opacity:E?.14:.95,depthTest:!1,depthWrite:!1,toneMapped:!1},N=A?new i.LineBasicMaterial(C):new i.MeshBasicMaterial({...C,side:i.DoubleSide});return l.set(S,N),N}function p(){for(let b of c.values())a.remove(b.mesh),b.mesh.dispose?.(),b.edge&&(a.remove(b.edge),b.edge.geometry.dispose());c.clear();for(let b of l.values())b.dispose();l.clear(),d=0,m=0,g=!1,h=""}function v(b,{color:E="accent"}={}){let A=JSON.stringify([[...b].sort(),E]);if(!b.size){c.size&&p();return}A!==h&&(p(),h=A);for(let T of c.values())T.mesh.visible=!1,T.edge&&(T.edge.visible=!1);for(let T of t()){if(x.sourceScans++,T.userData?.record?.type==="Component")continue;let M=T.userData?.identity||"",S=T.userData?.record?.type==="Zone",C=M.startsWith("spike:via-barrel:");if(!T.geometry?.attributes?.position||!S&&!/^spike:(copper-track|copper-pad|via-barrel):/.test(M))continue;let N=S?T.userData.record.layer:decodeURIComponent(M.split(":")[2]||"");if(!n(T,N))continue;let I=c.get(T);if(!I){if(c.size>=o){g=!0;continue}let L=T.userData.records,q=[],K=Math.max(0,s-d);if(T.isInstancedMesh&&L){for(let J=0;J<Math.min(L.length,T.count);J++)if(x.recordScans++,b.has(L[J].net)){if(q.length>=K){g=!0;break}q.push(J)}}else b.has(T.userData.record?.net)&&q.push(null);if(!q.length)continue;let B=Math.max(0,s-d);if(q.length>B&&(q.length=B,g=!0),!q.length)continue;let j=T.isInstancedMesh?new i.InstancedMesh(T.geometry,f(N,!1,!1,E,C),q.length):new i.Mesh(T.geometry,f(N,S,!1,E,C));if(j.matrixAutoUpdate=!1,j.renderOrder=201,j.frustumCulled=!1,a.add(j),I={mesh:j,indices:q,edge:null,layer:N},S)if(T.geometry.attributes.position.count*6+m<=2e5){let J=new i.LineSegments(new i.EdgesGeometry(T.geometry,1),f(N,!1,!0,E));m+=J.geometry.attributes.position.count,J.matrixAutoUpdate=!1,J.renderOrder=202,J.frustumCulled=!1,a.add(J),I.edge=J}else g=!0;c.set(T,I),d+=q.length}_(T,I)}}function _(b,E){if(x.transformSyncs++,b.updateWorldMatrix(!0,!1),E.mesh.matrix.copy(b.matrixWorld),E.mesh.matrixWorldNeedsUpdate=!0,E.mesh.visible=!0,b.isInstancedMesh){for(let A=0;A<E.indices.length;A++)b.getMatrixAt(E.indices[A],u),E.mesh.setMatrixAt(A,u);E.mesh.instanceMatrix.needsUpdate=!0}E.edge&&(E.edge.matrix.copy(b.matrixWorld),E.edge.matrixWorldNeedsUpdate=!0,E.edge.visible=!0)}function y(){for(let[b,E]of c)E.mesh.visible=n(b,E.layer),E.edge&&(E.edge.visible=E.mesh.visible),E.mesh.visible&&_(b,E)}return{update:v,syncTransforms:y,clear:p,stats:()=>{let b=0,E=0;for(let A of c.values())A.mesh.visible&&(b++,E+=A.indices.length);return{meshes:b,instances:E,retainedMeshes:c.size,limited:g,throughBoard:!0,...x}},dispose(){p(),e.remove(a)}}}function Xc(i,e="all"){let t={zone:1,track:-1,pad:-2,via:-3}[i];if(typeof t!="number")throw Error("Unknown copper surface role.");if(!["all","cap","wall"].includes(e))throw Error("Unknown copper surface kind.");return{polygonOffset:e!=="wall",polygonOffsetFactor:e==="cap"?t/2:0,polygonOffsetUnits:e==="wall"?0:t*2}}function ty(i,e,t){return["cap","wall"].map(n=>_m(new i.MeshStandardMaterial({...t,...Xc(e,n)}),e,n))}function _m(i,e,t="all"){let n=Xc(e,t);if(!n.polygonOffset)return i;let r=i.onBeforeCompile,s=i.customProgramCacheKey();return i.onBeforeCompile=function(o,a){r?.call(this,o,a),this.polygonOffset=!a?.capabilities?.logarithmicDepthBuffer;let c="#include <logdepthbuf_fragment>";if(!o.fragmentShader.includes(c))throw Error("Unsupported copper depth shader.");o.fragmentShader=o.fragmentShader.replace(c,c+`
#ifdef USE_LOGDEPTHBUF
gl_FragDepth = clamp(gl_FragDepth + `+(n.polygonOffsetUnits*4/16777215).toPrecision(12)+`, 0.0, 1.0);
#endif`)},i.customProgramCacheKey=()=>s+"|copper-log-depth-v1:"+e+":"+t,i}var NE=i=>i&&typeof i=="object"&&!Array.isArray(i)?i.quoted:i,bm=i=>Array.isArray(i)?String(NE(i[0])):"",pI=(i,e)=>Array.isArray(i)?i.find(t=>bm(t)===e):void 0,ny=i=>["F.SilkS","B.SilkS"].includes(NE(pI(i,"layer")?.[1]));function LE(i){let e=[i[0]];for(let t of i.slice(1)){let n=bm(t);if(["version","generator","layers"].includes(n)||ny(t)&&n.startsWith("gr_"))e.push(t);else if(n==="footprint"){let r=t.filter((s,o)=>o<2||["at","layer","uuid","tstamp"].includes(bm(s))||ny(s)&&["fp_line","fp_arc","fp_rect","fp_circle","fp_poly","fp_text","fp_curve","property"].includes(bm(s)));r.some(s=>ny(s))&&e.push(r)}}return e}function OE(i,e,t=2048,n=!1){if(![i,e,t].every(Number.isFinite)||i<=0||e<=0||t<1)return null;let r=Math.min(2048,t),s=n?524288:1048576,o=Math.min(16,r/i,r/e,Math.sqrt(s/i/e)),a=Math.max(1,Math.floor(i*o)),c=Math.max(1,Math.floor(e*o));return{width:a,height:c,scale:Math.min(a/i,c/e),pixels:a*c,maxPixels:s}}function Mm(i,e,t,n,r,s){let o=c=>({x:(c.x-t.minX)*n.width/(t.maxX-t.minX),y:(c.y-t.minY)*n.height/(t.maxY-t.minY)}),a=n.scale;if(i.clearRect(0,0,n.width,n.height),i.save(),r?.length){i.beginPath();for(let c of r)c.forEach((l,u)=>{let h=o({x:l[0],y:l[1]});u?i.lineTo(h.x,h.y):i.moveTo(h.x,h.y)}),i.closePath();i.clip("evenodd")}for(let c of e){if(i.save(),i.strokeStyle=i.fillStyle="#f2efda",i.lineWidth=Math.max(.6,(c.width||.15)*a),i.lineCap=i.lineJoin="round",c.type==="text"){let l=o(c),u=(c.fontHeight||c.size||1)*a;i.translate(l.x,l.y),i.rotate((c.angle||0)*Math.PI/180),(c.mirror||c.mirrored)&&i.scale(-1,1),i.font=`${c.bold?"bold ":""}${c.italic?"italic ":""}${u*4/3}px Arial,sans-serif`,i.textAlign=c.align||"center",i.textBaseline=c.baseline||"middle",c.fontWidth&&c.fontHeight&&i.scale(c.fontWidth/c.fontHeight,1),String(c.text||"").split(`
`).forEach((h,d,m)=>i.fillText(h,0,(d-(m.length-1)/2)*u*(c.lineSpacing||1.5))),i.restore();continue}if(i.beginPath(),c.type==="arc"){let l=s?.(c.start,c.mid,c.end);if(l){let u=o(l);i.arc(u.x,u.y,l.r*a,l.start,l.end,l.ccw)}}else if(c.type==="circle"){let l=o(c);i.arc(l.x,l.y,c.r*a,0,2*Math.PI)}else{for(let[l,u]of(c.points||[]).entries()){let h=o(u);l?i.lineTo(h.x,h.y):i.moveTo(h.x,h.y)}c.type==="polygon"&&i.closePath()}c.fill&&i.fill(),c.stroke!==!1&&i.stroke(),i.restore()}i.restore()}function iy(i,e,t,n,r,s,o=.2){e.updateMatrixWorld();let a=[];for(let x of[-1,1])for(let f of[-1,1])for(let p of[-1,1])a.push(new i.Vector3(p,f,x).unproject(e));let c=[];for(let x=0;x<8;x++)for(let f of[1,2,4]){let p=x^f;if(p<x)continue;let v=a[x],_=a[p],y=_.z-v.z;if(Math.abs(y)<1e-12)continue;let b=(t-v.z)/y;b>=0&&b<=1&&c.push({x:v.x+(_.x-v.x)*b+r,y:s-v.y-(_.y-v.y)*b})}if(!c.length)return null;let l=Math.max(n.minX,Math.min(...c.map(x=>x.x))),u=Math.min(n.maxX,Math.max(...c.map(x=>x.x))),h=Math.max(n.minY,Math.min(...c.map(x=>x.y))),d=Math.min(n.maxY,Math.max(...c.map(x=>x.y)));if(u-l<1e-6||d-h<1e-6)return null;let m=(u-l)*o,g=(d-h)*o;return{minX:Math.max(n.minX,l-m),maxX:Math.min(n.maxX,u+m),minY:Math.max(n.minY,h-g),maxY:Math.min(n.maxY,d+g)}}function DE(i,e,t=4096,n=!1){if(![i,e,t].every(Number.isFinite)||i<=0||e<=0||t<1)return null;let r=Math.min(n?1024:2048,t),s=n?1048576:4194304,o=Math.min(r/i,r/e,Math.sqrt(s/i/e)),a=Math.max(1,Math.floor(i*o)),c=Math.max(1,Math.floor(e*o));return{width:a,height:c,scale:Math.min(a/i,c/e),pixels:a*c,maxPixels:s}}function FE(i,{camera:e,document:t,bounds:n,centerX:r,centerY:s,graphics:o,resources:a,invalidate:c,arcThrough:l,setTimer:u=setTimeout,clearTimer:h=clearTimeout,onError:d=()=>{}}){let m=[],g=!1,x=null,f=null,p=!1,v=0;function _(b){b.crop=null,b.scale=null,b.mesh.material.map=b.base,b.mesh.position.set(0,0,b.z),b.mesh.scale.set(1,1,1)}function y(){if(x=null,!(g||p)){if(t.hidden){f=null;return}for(let b of m){if(!b.mesh.visible||!b.mesh.parent?.visible||(b.front?e.position.z<=b.z:e.position.z>=b.z))continue;let E=iy(i,e,b.z,n,r,s);if(!E)continue;let A=E.maxX-E.minX,T=E.maxY-E.minY,M=DE(A,T,o.maxDimension,o.constrained);if(M)try{let S=Math.floor(Math.min(o.constrained?1024:2048,o.maxDimension));b.texture||(b.canvas.width=b.canvas.height=S);let C=b.canvas.getContext("2d");if(!C)continue;C.clearRect(0,0,S,S),Mm(C,b.primitives,E,M,b.clips,l),v++,b.texture||(b.texture=a.track(new i.CanvasTexture(b.canvas)),b.texture.colorSpace=i.SRGBColorSpace,b.texture.anisotropy=b.base.anisotropy),b.texture.repeat.set(M.width/S,M.height/S),b.texture.offset.set(0,1-M.height/S),b.texture.needsUpdate=!0,b.mesh.material.map=b.texture,b.crop=E,b.scale=M.scale,b.mesh.scale.set(A/(n.maxX-n.minX),T/(n.maxY-n.minY),1),b.mesh.position.set((E.minX+E.maxX)/2-r,s-(E.minY+E.maxY)/2,b.z)}catch(S){_(b),d(S)}}c()}}return{add(b,E,A,T){m.push({mesh:b,primitives:E,clips:A,front:T,z:b.position.z,base:b.material.map,canvas:t.createElement("canvas"),texture:null})},sync({moving:b=!1}={}){if(g)return;for(let T of m)T.z=T.mesh.position.z;if(b){x!==null&&h(x),x=null;for(let T of m){if(T.crop){let M=iy(i,e,T.z,n,r,s,0),S=T.crop;(!M||M.minX<S.minX||M.maxX>S.maxX||M.minY<S.minY||M.maxY>S.maxY)&&_(T)}T.mesh.material.map=T.crop?T.texture:T.base}p=!0,f=null;return}p=!1;for(let T of m){let M=T.crop?T.texture:T.base;T.mesh.material.map!==M&&(T.mesh.material.map=M)}e.updateMatrixWorld();let E=[...e.matrixWorld.elements,...e.projectionMatrix.elements,...m.flatMap(T=>[T.mesh.visible&&T.mesh.parent?.visible?1:0,T.z])];if(f&&E.every((T,M)=>Math.abs(T-f[M])<=1e-5*Math.max(1,Math.abs(T),Math.abs(f[M]))))return;f=E;let A=!1;for(let T of m){if(!T.mesh.visible||!T.mesh.parent?.visible||(T.front?e.position.z<=T.z:e.position.z>=T.z))continue;let M=iy(i,e,T.z,n,r,s,0),S=T.crop;if(!(M&&S&&M.minX>=S.minX&&M.maxX<=S.maxX&&M.minY>=S.minY&&M.maxY<=S.maxY)){_(T),A=!0;continue}let N=DE(M.maxX-M.minX,M.maxY-M.minY,o.maxDimension,o.constrained);N&&N.scale>T.scale*1.5&&(A=!0)}A&&x===null&&(x=u(y,100))},stats:()=>({repaints:v,moving:p,pending:x!==null,detailTextures:m.filter(b=>b.texture).length}),dispose(){if(!g){g=!0,x!==null&&h(x),x=null;for(let b of m)_(b),b.canvas.width=b.canvas.height=1;m.length=0}}}}var mI=qb(Qs),Em=i=>Number.parseInt(globalThis.KiCadLayerColors.hexFor(i).slice(1),16),gI=`
:host{display:block;width:100%;height:100%;container-type:inline-size;font:12px/1.4 system-ui,-apple-system,"Segoe UI",sans-serif;
--ink:#e6e9ef;--surface:#151820;--bar:#1e2128;--border:#343944;--accent:#91b9ff;
--muted:#9ca5b5;--button:#292d36;--button-border:#343944;--button-ink:#e6e9ef;
--hint:#1e2128e8;--panel:#1e2128f2;--menu:#252a34;--notice:#1e2128;color:var(--ink);color-scheme:dark;--tools-bottom:58px}
:host([data-theme="light"]){--ink:#252c38;--surface:#e7ebf1;--bar:#fff;--border:#d9dee7;
--accent:#336ac2;--muted:#616d80;--button:#edf0f5;--button-border:#d9dee7;--button-ink:#252c38;
--hint:#ffffffed;--panel:#fffffff2;--menu:#fff;--notice:#fff;color-scheme:light}
*{box-sizing:border-box}.shell{display:flex;flex-direction:column;width:100%;height:100%;min-height:0;background:var(--surface)}
.bar{display:flex;align-items:center;gap:6px;min-height:40px;padding:5px 10px;background:var(--bar);border-bottom:1px solid var(--border);flex-wrap:nowrap;flex-shrink:0;min-width:0}
.title{font-size:10px;font-weight:650;letter-spacing:.07em;color:var(--muted);white-space:nowrap}.detail{font-size:11px;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--muted)}.spacer{flex:1;min-width:0}
button,select{background:var(--button);border:1px solid var(--button-border);color:var(--button-ink);padding:4px 8px;border-radius:5px;font:500 11px/1.4 system-ui;min-height:28px;cursor:pointer;flex-shrink:0}
select{color-scheme:dark}select option{background:var(--menu);color:var(--ink)}select option:disabled{color:var(--muted)}:host([data-theme="light"]) select{color-scheme:light}
button:hover,select:hover{border-color:var(--accent)}button:focus-visible,select:focus-visible,input:focus-visible,summary:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
.bar button{display:inline-flex;align-items:center;justify-content:center;gap:5px;background:transparent;border-color:transparent}.bar button:hover,.bar button[aria-expanded=true]{background:var(--button);border-color:var(--button-border)}.bar svg{width:15px;height:15px;flex-shrink:0}.view-select{max-width:105px;background:transparent}.bar .divider{width:1px;height:18px;background:var(--border);flex-shrink:0}
label{display:flex;align-items:center;gap:7px;white-space:nowrap;color:var(--muted);font-size:11px}input{accent-color:var(--accent)}.visibility-options{position:absolute;right:10px;top:10px;z-index:6;width:min(260px,calc(100% - 20px));max-height:calc(100% - 20px);overflow:auto;padding:12px;background:var(--menu);border:1px solid var(--border);border-radius:8px;box-shadow:0 8px 24px #0004;display:grid;gap:12px}.visibility-options[hidden]{display:none}.visibility-options fieldset{min-width:0;margin:0;padding:0;border:0;display:grid;gap:9px}.visibility-options fieldset+fieldset{border-top:1px solid var(--border);padding-top:12px}.visibility-options legend{padding:0 0 8px;color:var(--muted);font-size:10px;font-weight:650;letter-spacing:.06em;text-transform:uppercase}.visibility-options label{white-space:normal;min-width:0}.visibility-options select{min-width:0;width:130px;max-width:65%;margin-left:auto;flex-shrink:1}.visibility-options label>span{min-width:0}.visibility-options{overscroll-behavior:contain;scrollbar-gutter:stable}.display-heading{position:sticky;top:-12px;z-index:1;margin:-12px -12px 0;padding:10px 12px;background:var(--menu);border-bottom:1px solid var(--border)}.visibility-options input{width:16px;height:16px;margin:0}.display-heading{display:flex;align-items:center;justify-content:space-between;font-weight:600}.display-heading button{min-height:24px;padding:1px 6px}.quality-help{margin:0;color:var(--muted);font-size:10px;line-height:1.5}
.stage{position:relative;flex:1;min-height:0;overflow:hidden}.canvas{position:absolute;inset:0}.canvas canvas{display:block;width:100%;height:100%}
.hint{padding:4px 10px;color:var(--muted);background:var(--bar);font-size:10px;border-top:1px solid var(--border);flex-shrink:0}
.inspector{position:absolute;right:12px;bottom:12px;width:min(280px,45%);max-height:50%;overflow:auto;background:var(--panel);border:1px solid var(--border);border-radius:7px;padding:10px;box-shadow:0 8px 28px #0005}
.inspector[hidden],.menu[hidden]{display:none}.inspector h2{font-size:13px;margin:0 0 6px;color:var(--accent)}.inspector dl{display:grid;grid-template-columns:auto 1fr;gap:3px 8px;margin:0}.inspector dt{color:var(--muted)}.inspector dd{margin:0;overflow-wrap:anywhere}
.menu{position:absolute;z-index:4;display:grid;gap:3px;padding:5px;border:1px solid var(--border);border-radius:5px;background:var(--menu);box-shadow:0 7px 25px #0005}
.notice{padding:3px 9px;background:var(--notice);color:var(--muted);font-size:10px;border-top:1px solid var(--border);flex-shrink:0}.notice details{display:inline;margin-left:8px}.notice summary{display:inline;cursor:pointer;color:var(--accent)}.notice details[open]{display:block;margin:6px 0 0}.notice ul{max-height:120px;overflow:auto;margin:6px 0;padding-left:16px;line-height:1.6}.quality-notice{position:absolute;left:12px;right:12px;top:10px;z-index:7;padding:10px 12px;border:1px solid #bf725c;border-radius:7px;background:var(--panel);color:var(--ink);font-size:12px;max-width:560px;max-height:calc(100% - 20px);overflow:auto}.quality-notice[hidden]{display:none}.quality-notice button{margin:6px 0 0 8px}
button[aria-pressed=true]{border-color:var(--accent);color:var(--accent)}.measurement-panel{position:absolute;bottom:10px;left:10px;z-index:5;width:min(350px,calc(100% - 20px));padding:10px 12px;border:1px solid var(--border);border-radius:8px;background:var(--panel);box-shadow:0 4px 18px #0003;display:grid;gap:6px;max-height:calc(100% - 20px);overflow:auto;overscroll-behavior:contain}.measurement-panel[hidden],.measurement-label[hidden]{display:none}.measurement-heading{display:flex;align-items:center;gap:6px}.measurement-heading strong{font-size:12px;margin-right:auto}.measurement-panel output{font:600 18px/1.3 system-ui;color:var(--ink);font-variant-numeric:tabular-nums}.measurement-panel small{color:var(--muted);font-size:10px}.measurement-panel .measurement-tools{display:flex;align-items:center;gap:6px}.measurement-panel .measurement-tools select{min-width:0;flex:1}.measurement-panel p{margin:0;color:var(--muted);font-size:11px}.measurement-label{position:absolute;z-index:4;pointer-events:none;padding:4px 7px;border:1px solid #c5a35f;border-radius:5px;background:var(--panel);color:var(--ink);font:600 12px/1.4 system-ui;white-space:nowrap;box-shadow:0 2px 8px #0004}:host([data-measuring=true]) .hint{display:none}
@media(max-width:700px){.detail{display:none}.bar{gap:4px;padding-inline:6px}.hint{display:none}.inspector{width:min(260px,65%)}}@media(max-width:380px){.title{display:none}.bar{gap:2px}.bar button{padding-inline:5px}.view-select{max-width:90px}}
@media(pointer:coarse){button,select{min-height:40px}.bar{min-height:50px}.visibility-options label{min-height:32px}}
:host([data-embedded="true"]) .shell{position:relative}
:host([data-embedded="true"]) .bar{position:absolute;z-index:5;top:12px;left:12px;right:auto;max-width:calc(100% - 24px);flex-wrap:wrap;gap:3px;min-height:36px;padding:4px;border:1px solid var(--border);border-radius:9px;box-shadow:0 4px 16px #0002;background:var(--bar)}
:host([data-embedded="true"]) .bar .title,:host([data-embedded="true"]) .bar .detail,:host([data-embedded="true"]) .bar .spacer,:host([data-embedded="true"]) .bar .divider,:host([data-embedded="true"]) .bar .fit-action,:host([data-embedded="true"]) .hint,:host([data-embedded="true"]) .notice{display:none}
:host([data-embedded="true"]) .bar button{min-height:28px;padding:5px 7px}
:host([data-embedded="true"]) .visibility-options{top:var(--tools-bottom);max-height:calc(100% - var(--tools-bottom) - 10px)}
:host([data-embedded="true"]) .quality-notice{top:calc(var(--tools-bottom) + 4px);max-height:calc(100% - var(--tools-bottom) - 16px)}
.bar{gap:3px;min-height:34px;height:34px;padding:2px 5px}.bar .title,.bar .detail,.bar .spacer,.bar .divider{display:none}
.bar button,.bar select,.bar summary{appearance:none;box-sizing:border-box;min-height:28px;height:28px;margin:0;padding:3px 6px;font:600 11px/1 system-ui}
.bar .view-select{max-width:86px}.bar .tools-more{position:relative;flex:0 0 auto}.bar .tools-more>summary{display:inline-flex;align-items:center;justify-content:center;min-width:42px;border:1px solid transparent;border-radius:5px;color:var(--button-ink);cursor:pointer;list-style:none}.bar .tools-more>summary::-webkit-details-marker{display:none}.bar .tools-more[open]>summary{background:var(--button);border-color:var(--button-border)}
.bar .tools-panel{position:absolute;z-index:9;right:0;top:calc(100% + 4px);display:grid;gap:4px;width:min(230px,calc(100cqw - 12px));max-height:var(--tools-panel-height,240px);overflow:auto;overscroll-behavior:contain;padding:6px;border:1px solid var(--border);border-radius:7px;background:var(--menu);box-shadow:0 8px 24px #0004}
.bar .tools-panel>button{justify-content:flex-start;width:100%;min-height:30px;height:30px}.bar .tools-panel .explode-control{display:grid!important;grid-template-columns:auto 1fr auto;gap:5px;min-width:0;white-space:nowrap}.bar .tools-panel .explode-control input{width:100%!important;min-width:0!important}
:host([data-embedded="true"]) .bar{top:6px;left:6px;right:auto;max-width:calc(100% - 12px);min-height:34px;height:34px;padding:2px 4px;flex-wrap:nowrap}
:host([data-embedded="true"]) .bar button,:host([data-embedded="true"]) .bar select,:host([data-embedded="true"]) .bar summary{min-height:28px;height:28px;padding:3px 5px}
:host([data-embedded="true"]) .bar .tools-panel{left:0;right:auto}
@media(pointer:coarse){.bar{min-height:34px;height:34px}.bar button,.bar select,.bar summary{min-height:28px;height:28px}}
`;function UE(i={}){let e=["arcs","pads","vias","tracks","fills","polygons","bodies","silkscreen"],t=[...new Set((Array.isArray(i.hiddenTypes)?i.hiddenTypes:[]).filter(r=>typeof r=="string"&&r.length<=40).slice(0,64))],n=["top","bottom"].includes(i.side)?i.side:"all";return{hiddenTypes:t,side:n,supportedTypes:e,unsupportedTypes:t.filter(r=>!e.includes(r)),visible(r,s){return!t.includes(r)&&!(n==="top"&&s?.startsWith("B."))&&!(n==="bottom"&&s?.startsWith("F."))}}}function Qh(i,e){let t=new Tr;return i.forEach((n,r)=>{let[s,o]=e(n);r===0?t.moveTo(s,o):t.lineTo(s,o)}),t}function xI(i,e){let t=i.outlineLoops?.filter(s=>s.length>=3)||[],n=t[0]||[[i.bounds.minX,i.bounds.minY],[i.bounds.maxX,i.bounds.minY],[i.bounds.maxX,i.bounds.maxY],[i.bounds.minX,i.bounds.maxY]],r=new Fi;Qh(n,e).getPoints().forEach((s,o)=>{o===0?r.moveTo(s.x,s.y):r.lineTo(s.x,s.y)});for(let s of t.slice(1))r.holes.push(Qh(s,e));return r}function Jh(i,e,t,n,r,s){if(!n.length)return null;let o=new $r(e,t,n.length),a=new St;return n.forEach((c,l)=>{r(a,c),a.updateMatrix(),o.setMatrixAt(l,a.matrix)}),o.instanceMatrix.needsUpdate=!0,o.userData.records=n,o.userData.identity=s,i.add(o),o}function G2(i,e,t={}){t||={};let n=qx(t.appearance??"realistic"),r=t.dark!==!1,s=t.sourceSnapshot?(t.sourceParser||globalThis.KiCadDesignDiff).preparedFile(t.sourceSnapshot,t.sourceKey,e):globalThis.KiCadDesignDiff.parse(e),o=ME(s),a=SM(e,s,{zonePoints:!1}),c=UM(s),l=a.pads.map(R=>({...R,...c.get(R.id)})),u=[...a.geometryWarnings||[]];if(!a?.bounds||!Number.isFinite(a.width)||!Number.isFinite(a.height))throw new Error("SPIKE could not parse this PCB layout.");let h=document.createElement("div");h.dataset.theme=r?"dark":"light",h.dataset.embedded=t.embedded===!0&&typeof t.onDiagnostics=="function"?"true":"false";let d=h.attachShadow({mode:"open"}),m=document.createElement("style");m.textContent=gI;let g=document.createElement("div");g.className="shell";let x=document.createElement("div");x.className="bar",x.setAttribute("role","toolbar"),x.setAttribute("aria-label","3D tools");let f=document.createElement("div");f.className="stage";let p=document.createElement("div");p.className="canvas";let v=document.createElement("div");v.className="hint",v.textContent="Drag to orbit \xB7 right-drag to pan \xB7 wheel to zoom \xB7 click to inspect";let _=document.createElement("div");_.className="inspector",_.hidden=!0;let y=document.createElement("div");y.className="menu",y.hidden=!0;let b=document.createElement("div");b.className="notice",b.textContent="Material preview \xB7 mask openings follow saved pad layer flags \xB7 footprint stand-ins where linked models are unavailable.";let E=document.createElement("div");E.className="quality-notice",E.hidden=!0,E.setAttribute("role","status"),f.append(E),f.append(p,_,y),g.append(x,f,v,b),d.append(m,g),i.append(h);let A=document.createElement("strong");A.className="title",A.textContent="3D VIEW";let T=document.createElement("span");T.className="detail",T.textContent=`${a.width.toFixed(1)} \xD7 ${a.height.toFixed(1)} mm \xB7 ${a.components.length} parts \xB7 ${a.tracks.length} tracks`;let M=document.createElement("span");M.className="spacer";function S(R,k,ie,ye=R){let ve=document.createElement("button");if(ve.type="button",ve.title=ye,ve.setAttribute("aria-label",ye),ie){let He=document.createElementNS("http://www.w3.org/2000/svg","svg"),je=document.createElementNS("http://www.w3.org/2000/svg","path");He.setAttribute("viewBox","0 0 24 24"),He.setAttribute("fill","none"),He.setAttribute("stroke","currentColor"),He.setAttribute("stroke-width","1.6"),He.setAttribute("stroke-linecap","round"),He.setAttribute("stroke-linejoin","round"),He.setAttribute("aria-hidden","true"),je.setAttribute("d",ie),He.append(je),ve.append(He)}let Ee=document.createElement("span");return Ee.textContent=R,ve.append(Ee),ve.addEventListener("click",()=>{k(),fe()}),x.append(ve),ve}let C=document.createElement("section");C.className="visibility-options",C.id="display-options",C.hidden=!0,C.setAttribute("aria-label","3D display settings"),f.append(C);let N=document.createElement("div");N.className="display-heading",N.append(document.createTextNode("Display"));let I=document.createElement("button");I.type="button",I.textContent="\xD7",I.title="Close display settings",I.setAttribute("aria-label","Close display settings"),I.onclick=()=>J(!1,!0),N.append(I);let L=document.createElement("fieldset"),q=document.createElement("legend");q.textContent="Rendering",L.append(q);let K=document.createElement("fieldset"),B=document.createElement("legend");B.textContent="Visible geometry",K.append(B),C.append(N,L,K);function j(){if(g.clientHeight&&h.style.setProperty("--tools-panel-height",Math.max(72,Math.min(280,g.clientHeight-50))+"px"),h.dataset.embedded!=="true")return;let R=f.getBoundingClientRect(),k=x.getBoundingClientRect(),ie=Math.min(Math.max(8,Math.ceil(k.bottom-R.top+6)),Math.max(8,R.height-180));h.style.setProperty("--tools-bottom",ie+"px")}function J(R,k=!1){R&&(j(),typeof ro<"u"&&(ro.open=!1)),C.hidden=!R,ga.setAttribute("aria-expanded",String(R)),k&&ga.focus()}function se(R,k,ie){let ye=document.createElement("label"),ve=document.createElement("input");return ve.type="checkbox",ve.checked=k,ve.addEventListener("change",()=>{ie(ve.checked),fe()}),ye.append(ve,document.createTextNode(R)),K.append(ye),ve}x.append(A,T,M);let ce="pocket-kivi:3d-quality:v1",me="balanced",Se=!1;try{let R=localStorage.getItem(ce);["low","balanced","high"].includes(R)&&(me=R,Se=!0)}catch{}t.quality&&(me=mm(t.quality));let V=document.createElement("label");V.className="quality-label";let w=document.createElement("span");w.textContent="Quality";let O=document.createElement("select");O.setAttribute("aria-label","3D rendering quality"),O.title="Photoreal Fast: studio stage, reflections and cached shadows, without screen-space effects. Presentation: studio stage, dense occlusion and enhanced shadows. High: ambient occlusion and enhanced antialiasing. Balanced: responsive studio lighting. Low: reduced memory.";for(let[R,k]of[["low","Low"],["balanced","Balanced"],["high","High"],["photoreal-fast","Photoreal Fast"],["presentation","Presentation"]]){let ie=document.createElement("option");ie.value=R,ie.textContent=k,O.append(ie)}O.value=me,V.append(w,O);let W=(a.bounds.minX+a.bounds.maxX)/2,Q=(a.bounds.minY+a.bounds.maxY)/2,ee=([R,k])=>[R-W,Q-k],he=([R,k])=>[R,-k],Ce=rv(),oe=(R,k)=>Ce.get(JSON.stringify([R.outline,R.drill||null,k]),()=>new Ys(ue(R),{depth:k,bevelEnabled:!1,curveSegments:8})),ue=R=>{let k=new Fi;return Qh(R.outline,he).getPoints().forEach((ie,ye)=>ye?k.lineTo(ie.x,ie.y):k.moveTo(ie.x,ie.y)),R.drill&&k.holes.push(Qh(R.drill,he)),k},H=Math.max(1,a.width),Ie=Math.max(1,a.height),Te=Math.max(H,Ie),Oe=a.stackup?.filter(R=>Number.isFinite(R.thickness)).reduce((R,k)=>R+k.thickness,0)||1.6,Re=Oe/2,We=-Re,Ae=new oi;Ae.background=new Ue(r?1382432:15199217);let Y=null,F=TE({onChange:()=>Y?.invalidate()}),D=new jt(45,1,.1,Math.max(3e3,Te*30));D.up.set(0,0,1);let P=new fs({antialias:!1,logarithmicDepthBuffer:!0,alpha:!1,powerPreference:"high-performance"}),U=P.getContext(),X=cE({maxTextureSize:P.capabilities.maxTextureSize,maxRenderbufferSize:U.getParameter(U.MAX_RENDERBUFFER_SIZE),deviceMemory:globalThis.navigator?.deviceMemory,hardwareConcurrency:globalThis.navigator?.hardwareConcurrency,floatTargets:P.extensions.has("EXT_color_buffer_float"),android:/Android/i.test(globalThis.navigator?.userAgent||"")});Y=eE(U);let Z=(X.constrained?32:X.premium?96:64)*1024*1024,$=(X.constrained?32:64)*1024*1024,te={budgetBytes:$,retainedBytes:0,renderedContours:0,vertices:0,rejected:0},ae=(X.constrained?16:X.premium?64:32)*1024*1024,re=lv(X.constrained?8192:32768),ge=cv(X.constrained,a.components.length);!Se&&!t.quality&&(me=X.defaultQuality);let xe=!0,Ne=!1,ke=0,$e=null,Le=me,Xe=!1;function ne(){Ae.background.setHex(h.dataset.theme==="dark"?1513237:16250350)}let Pe=()=>p.clientWidth>0&&p.clientHeight>0,pe=dm({request:R=>requestAnimationFrame(R),cancel:R=>cancelAnimationFrame(R),render:sS,canRender:()=>xe&&!Ne&&!document.hidden&&Pe(),state:{documentVisible:!document.hidden,hasSize:Pe()}});function fe(){xe&&(pe.setState({documentVisible:!document.hidden,hasSize:Pe()}),pe.invalidate())}function Be(R,k=!1){E.replaceChildren(document.createTextNode(R)),E.hidden=!1;let ie=document.createElement("button");if(ie.type="button",ie.textContent="Dismiss",ie.onclick=()=>{E.hidden=!0},E.append(ie),k){let ye=document.createElement("button");ye.type="button",ye.textContent="Retry graphics",ye.onclick=()=>P.forceContextRestore(),E.append(ye)}}function De(){if($e){for(let R of $e.passes)R.dispose?.(),R instanceof Bc&&(R.gtaoMaterial.dispose(),R.blendMaterial.dispose(),R.depthTexture?.dispose());$e.composer.dispose(),$e=null}}function st(){if(De(),Y.invalidate(),Le==="low")return;let R=["high","presentation"].includes(Le)&&yt!=="translucent"&&Ye.get()===0,k=P.extensions.has("EXT_color_buffer_float");if(R&&!k)throw Error("Floating-point render targets are unavailable.");let ie=new on(1,1,{type:k?Hn:ci,depthBuffer:!0,stencilBuffer:!1}),ye=new Xp(P,ie),ve=[];$e={composer:ye,passes:ve,occlusion:R};let Ee=new Yp(Ae,D);if(ve.push(Ee),R){let Qe=new Bc(Ae,D,1,1,void 0,lE(Oe,Le));pE(Qe.normalMaterial),Qe.blendIntensity=.65,Qe.updatePdMaterial({radius:4,rings:2,samples:Le==="presentation"?24:12});let rt=Qe.overrideVisibility.bind(Qe);Qe.overrideVisibility=()=>{rt(),Ae.traverse(Fe=>{(Array.isArray(Fe.material)?Fe.material:[Fe.material]).some(et=>et&&(et.transparent||et.depthTest===!1))&&(Fe.visible=!1)})},ve.push(Qe)}let He=new Kp,je=new Jp(1,1);for(let Qe of[je.areaTexture,je.searchTexture])Qe.image?.addEventListener?.("load",()=>{Y.invalidate(),fe()},{once:!0});ve.push(He,je);for(let Qe of ve)ye.addPass(Qe)}function pt(R){De(),Le="balanced",O.value=Le,h.dataset.quality=Le,Xe=!1,P.setRenderTarget(null),Ti.apply(!1),ne(),Be(R),gs()}function lt(R,k=!0){if(Le=mm(R),O.value=Le,h.dataset.quality=Le,E.hidden=!0,Xe=!1,ne(),k)try{localStorage.setItem(ce,Le==="presentation"?"high":Le==="photoreal-fast"?"balanced":Le)}catch{}Ti.apply(["presentation","photoreal-fast"].includes(Le)&&yt!=="translucent",{fast:Le==="photoreal-fast"}),P.shadowMap.enabled=Le!=="low"&&yt!=="translucent"&&Ye.get()===0,P.shadowMap.needsUpdate=!0;try{st()}catch{pt("Enhanced quality is unavailable on this graphics device. Balanced rendering is active.")}return ma(),gs(),fe(),Le}O.onchange=()=>lt(O.value),P.debug.onShaderError=()=>{Xe=!0},P.outputColorSpace=wt,P.toneMapping=jo,P.toneMappingExposure=1,P.shadowMap.enabled=!0,P.shadowMap.type=Tu,P.shadowMap.autoUpdate=!1,P.shadowMap.needsUpdate=!0;function Ge(){if(!P.extensions.has("EXT_color_buffer_float"))return null;let R,k;try{return R=new Vp,k=new ia(P),k.fromScene(R,.04,.1,100)}catch{return Be("Studio reflections are unavailable on this graphics device. Direct lighting remains active."),null}finally{R?.dispose(),k?.dispose()}}let Je=Ge();Ae.environment=Je?.texture||null,Ae.environmentIntensity=.65,p.append(P.domElement);let we=new mI(D,P.domElement),tt=!1,at=!1,bt=null,Xn=null,ei=()=>{tt=!0,at=!0,bt!==null&&clearTimeout(bt),bt=null},mr=()=>{bt!==null&&clearTimeout(bt),bt=setTimeout(()=>{bt=null,at=!1,fe()},100)};we.addEventListener("start",ei),we.addEventListener("end",mr),we.addEventListener("change",fe),we.enableDamping=!1,we.dampingFactor=.1,we.screenSpacePanning=!0,we.minDistance=.1,we.maxDistance=Te*8,Ae.add(new Wo(16777215,.35));for(let R of fE){let k=new as(R.color,R.intensity);Math.abs(R.z)===1&&(k.castShadow=!0,k.shadow.mapSize.set(1024,1024),k.shadow.camera.left=k.shadow.camera.bottom=-Te,k.shadow.camera.right=k.shadow.camera.top=Te,k.shadow.camera.near=.1,k.shadow.camera.far=Te*5,k.shadow.normalBias=.02,k.shadow.bias=-1e-4),k.position.set(Te*R.x,Te*R.y,Te*R.z),Ae.add(k)}let Ti=aE(Wn,{scene:Ae,renderer:P,extent:Te,bottom:We,constrained:X.constrained}),Fn=new Dt;Ae.add(Fn);let ui=new Map,dn=[],Un=UE(),to=[],kr=(R,k,ie)=>(to.push({mesh:R,type:k,layer:ie}),R.visible=Un.visible(k,ie),R),$h=new Set(s.filter(R=>Array.isArray(R)&&R[0]==="arc").map(R=>{let k=R.find(ie=>Array.isArray(ie)&&["uuid","tstamp"].includes(ie[0]))?.[1];return typeof k=="object"?k?.quoted:k}).filter(Boolean)),Sm=R=>$h.has(R.id)||$h.has(R.id?.replace(/:\d+$/,""))||/^track-\d+:\d+$/.test(R.id||""),Tm=QM(a,Oe).map(R=>R.name),G=CM({...a,layers:Tm},s,Oe),le=G.layers.map(R=>{let k=!["F.Cu","B.Cu"].includes(R.name);return{...R,internal:k,basis:k?G.savedDepths?"saved-stackup":"illustrative":"outer-surface"}}),_e=new Set,be=new Map(le.map(R=>[R.name,!0])),de=a.vias.filter(R=>G.viaSpans.get(R.id)?.through);de.length<G.viaSpans.size&&u.push("Blind and buried via walls follow saved endpoint layers. Partial-depth dielectric cavities are not cut.");let Ve=WM(a.tracks,s),Ke;try{Ke=GM(Oe,G.byLayer)}catch{Ke={bottom:We,depth:Oe},u.push("Outer copper depths do not enclose a valid substrate. The nominal board envelope is shown.")}u.push(...G.warnings,...Ve.warnings);function it(R){let k=G.byLayer.get(R);return R==="F.Cu"||R==="B.Cu"?VM(R,Oe,k.thickness,k.z):{center:k.z,base:k.z-k.thickness/2,thickness:k.thickness}}let qe=null;function ft(R){return qe?R.name===qe:be.get(R.name)&&(!R.internal||yt==="translucent"||Ye.get()>0)}let Ye=CE(Wn,{layers:le},{maxGap:Math.max(.8,Math.min(8,Te*.45/Math.max(1,le.length-1))),componentLift:Math.max(6,Math.min(40,Te*.15))}),ut=[],Nt=PE(),At=JM(),en=[],yt="realistic",Ct=!1,ht=!1,pn=!1,Ot=!1,ti=document.createElement("label");ti.append(document.createTextNode("Appearance"));let Ai=document.createElement("select");Ai.setAttribute("aria-label","3D board appearance");for(let[R,k]of[["realistic","Realistic"],["layers","Layer colors"],["translucent","Translucent"]]){let ie=document.createElement("option");ie.value=R,ie.textContent=k,Ai.append(ie)}ti.append(Ai);let kn=document.createElement("p");kn.className="quality-help",kn.textContent="Translucent reveals copper in layer colors through the board and models. Fills stay faint; shadows and screen-space occlusion are disabled in this inspection mode. Photoreal Fast adds studio reflections and cached shadows without a visible floor, using a bounded framebuffer, without ambient occlusion or supersampling. Presentation adds enhanced shadows and screen-space effects. Both render only when needed; source model fidelity is unchanged.",L.append(ti,V,kn);function Vi(R=yt){let k=qx(R),ie=yt;Ct&&yr.restore(),At.setEnabled(!1),yt=k,Ai.value=k,h.dataset.appearance=k,(qe||k==="translucent"||Ye.get()>0)&&id();let ye=!qe&&k==="realistic"&&Ye.get()===0;for(let{mesh:ve,role:Ee,layer:He,pads:je}of en){let Qe=Array.isArray(ve.material)?ve.material:[ve.material];if(Ee==="pads"){for(let Fe of Qe)Fe.color.setHex(16777215);let rt=new Ue;je.forEach((Fe,vt)=>ve.setColorAt(vt,rt.setHex(ye?uE(Fe,He)?Gc.exposedCopper:Gc.coatedCopper:Em(He)))),ve.instanceColor&&(ve.instanceColor.needsUpdate=!0)}else for(let rt of Qe)rt.color.setHex(ye?Gc.coatedCopper:Em(He));for(let rt of Qe)rt.metalness=ye&&Ee!=="pads"?.08:pr.copper.metalness,rt.roughness=ye&&Ee!=="pads"?.52:pr.copper.roughness}for(let ve of le){let Ee=ui.get(ve.name);Ee&&(Ee.visible=ft(ve))}if(At.setEnabled(k==="translucent"),Ti.apply(["presentation","photoreal-fast"].includes(Le)&&k!=="translucent",{fast:Le==="photoreal-fast"}),P.shadowMap.enabled=Le!=="low"&&k!=="translucent"&&Ye.get()===0,P.shadowMap.needsUpdate=!0,ie==="translucent"!=(k==="translucent"))try{st()}catch{pt("Enhanced quality is unavailable. Balanced rendering is active.")}return Yc(),Ct&&Hi(zn),t.onAppearanceChange?.(k),fe(),k}Ai.onchange=()=>Vi(Ai.value);let Bt=R=>{if(!ui.has(R)){let k=new Dt;k.name=R,Fn.add(k),ui.set(R,k)}return ui.get(R)},Yn=xI(a,ee),ni=new Set,Pn=0,Bn=0,ms=0,Br=(R,k)=>{let ie=!1;for(let ye=0,ve=k.length-1;ye<k.length;ve=ye++){let[Ee,He]=[k[ye],k[ve]];Ee[1]>R[1]!=He[1]>R[1]&&R[0]<(He[0]-Ee[0])*(R[1]-Ee[1])/(He[1]-Ee[1])+Ee[0]&&(ie=!ie)}return ie},ry=a.outlineLoops?.[0],sy=a.outlineLoops?.slice(1)||[];for(let R of[...l,...de.map(k=>({...k,shape:"circle",width:k.size,height:k.size,drillShape:"circle",rotation:0}))]){if(!(R.drill>0))continue;let k=lm(R);if(!k){ms++;continue}let ie=(R.rotation||0)*Math.PI/180,ye=Math.cos(ie),ve=Math.sin(ie),[Ee,He]=ee(R.at);if(sy.some(rt=>Br(R.at,rt)))continue;let je=k.map(([rt,Fe])=>[Ee+rt*ye+Fe*ve,He+rt*ve-Fe*ye]),Qe=JSON.stringify(je.map(rt=>rt.map(Fe=>Math.round(Fe*1e4)/1e4)));if(!ni.has(Qe)){if(Pn>=1024||Bn+je.length>1e5||!ry||!bE(je.map(([rt,Fe])=>[rt+W,Q-Fe]),ry,sy)){ms++;continue}ni.add(Qe),Pn++,Bn+=je.length,Yn.holes.push(Qh(je,rt=>rt))}}ms&&u.push(`${ms} drill loops could not be cut within the saved-geometry/triangulation budget.`);let In=new ct(new Ys(Yn,{depth:Ke.depth,bevelEnabled:!1,curveSegments:8}),[new Dn(pr.solderMask),new En(pr.substrateEdge)]);In.position.z=Ke.bottom,In.receiveShadow=!0,Ti.addCaster(In),In.userData.record={type:"Board",name:"Substrate",layer:"Edge.Cuts",id:"board"},In.userData.identity=ua("substrate","Edge.Cuts","board"),Fn.add(In),dn.push(In),At.add(In,"substrate");let ed=new ln(new ss(In.geometry,20),new Xt({color:10205100,transparent:!0,opacity:.42}));ed.position.z=Ke.bottom,Fn.add(ed);let da=new Dt;Fn.add(da);function Yc(){let R=Math.min(1-Ye.phases().layers*.98,qe?.08:1),k=(yt==="translucent"?.12:1)*R,ie=Ct&&ao.mode==="isolate"&&Gh(zn)&&!ht;for(let ye of Array.isArray(In.material)?In.material:[In.material]){let ve=ie?0:Math.min(k,ye.userData.selectionOpacityCap??1),Ee=ve<1;ye.transparent!==Ee&&(ye.transparent=Ee,ye.needsUpdate=!0),ye.opacity=ve,ye.depthWrite=!Ee}ed.material.opacity=Math.min(.42*R,ed.material.userData.selectionOpacityCap??1),In.castShadow=!qe&&Ye.get()===0&&Ti.enabled}let td=FE(Wn,{camera:D,document,bounds:a.bounds,centerX:W,centerY:Q,graphics:X,resources:F,invalidate:fe,arcThrough:globalThis.KiCadOwnedCanvas?.arcThrough,onError:R=>Be("Silkscreen detail could not be refreshed: "+R.message)});if(globalThis.KiCadPCBRenderer&&globalThis.KiCadOwnedCanvas?.arcThrough)try{let R=globalThis.KiCadPCBRenderer.build(LE(s),t.boardPath||"").primitives.filter(ve=>!ve.frame&&!ve.hidden&&["F.SilkS","B.SilkS"].includes(ve.layer)),k=OE(H,Ie,X.maxDimension,X.constrained),ie=Yn.extractPoints(8),ye=[ie.shape,...ie.holes].map(ve=>ve.map(Ee=>[Ee.x+W,Q-Ee.y]));for(let ve of["F.SilkS","B.SilkS"]){let Ee=R.filter(Fe=>Fe.layer===ve);if(!Ee.length||!k)continue;let He=document.createElement("canvas");He.width=k.width,He.height=k.height;let je=He.getContext("2d");if(!je)continue;Mm(je,Ee,a.bounds,k,ye,globalThis.KiCadOwnedCanvas.arcThrough);let Qe=F.track(new ns(He));Qe.colorSpace=wt,Qe.anisotropy=Math.min(16,P.capabilities.getMaxAnisotropy());let rt=new ct(new Ar(H,Ie),new En({map:Qe,color:16777215,roughness:.85,metalness:0,side:ve==="F.SilkS"?Jn:un,transparent:!0,alphaTest:.05,depthWrite:!1}));rt.position.z=ve==="F.SilkS"?Re+.055:We-.055,rt.renderOrder=1,da.add(rt),At.add(rt,"silkscreen"),kr(rt,"silkscreen",ve),td.add(rt,Ee,ye,ve==="F.SilkS")}}catch(R){u.push("Saved silkscreen could not be prepared: "+R.message)}let no=new Map,nd=0;for(let R of a.vias){let k=G.viaSpans.get(R.id),ie=Yx({shape:"circle",width:R.size,height:R.size,drill:R.drill,drillShape:"circle"});if(!ie||!k){nd++;continue}let ye=JSON.stringify([R.size,R.drill,k.zMin,k.zMax]);if(!no.has(ye)){if(no.size>=128){nd++;continue}no.set(ye,{outline:ie,span:k,vias:[]})}no.get(ye).vias.push(R)}nd&&u.push(`${nd} via bodies with unsupported annuli or unknown saved spans omitted.`);let Am=new Dt;Fn.add(Am);for(let[R,k]of no){let ie=zM(Wn,lm({drill:k.vias[0].drill,drillShape:"circle"}),k.span.zMax-k.span.zMin),ye=new En({color:Gc.exposedCopper,...pr.copper,side:xn,...Xc("via","wall")}),ve=Jh(Am,ie,ye,k.vias,(Ee,He)=>{let[je,Qe]=ee(He.at);Ee.position.set(je,Qe,k.span.zMin)},ua("via-barrel",k.span.through?"through":k.span.from+"-"+k.span.to,R));ve&&(kr(ve,"vias",k.span.through?"through":k.span.from+"-"+k.span.to),dn.push(ve),ut.push({mesh:ve,span:k.span}))}u.push("Outer copper uses saved plan centers/thickness (or the disclosed stackup fallback) with a 0.001 mm outward display offset; the substrate spans the outer copper inner faces. Saved zone fills are opaque zero-height display films inset by the smaller of 0.005 mm or one quarter of the copper thickness. Via bodies show the saved drill wall; plating thickness is not inferred.");let BE=no.size?ty(Wn,"via",{color:Gc.exposedCopper,...pr.copper}):null;function oy(R){if(_e.has(R))return;_e.add(R);let k=Em(R),ie=it(R),ye=ie.center;for(let Fe of["tracks","arcs"]){let vt=Ve.tracks.filter(Lt=>Lt.layer===R&&(Sm(Lt)?"arcs":"tracks")===Fe),et=kM(Wn,vt,{world:ee,z:ye,thickness:ie.thickness});et.invalid&&u.push(`${R}: invalid saved track widths or positions omitted.`),et.plan?.limited&&u.push(`${R}: large track caps exceed the ${et.plan.tolerance} mm tessellation tolerance at the 128-segment display limit.`);let dt=_m(new En({color:k,...pr.copper,...Xc("track")}),"track");for(let Lt of et.batches){let Rt=Jh(Bt(R),Lt.geometry,dt,Lt.records,Lt.place,ua("copper-track",R,Fe+"-"+Lt.part));Rt&&(kr(Rt,Fe,R),dn.push(Rt),en.push({mesh:Rt,role:"tracks",layer:R}))}et.batches.length||dt.dispose()}let ve=l.filter(Fe=>!FM(Fe)&&(Fe.layer===R||Fe.layers?.includes(R)||Fe.layers?.includes("*.Cu"))),Ee=new Map,He=0;for(let Fe of ve){let vt=JSON.stringify([Fe.shape,Fe.width,Fe.height,Fe.roundrectRatio,Fe.drill,Fe.drillShape,Fe.drillWidth,Fe.drillHeight,Fe.drillOffset,Fe.customAnchor,Fe.customPrimitives]);if(!Ee.has(vt)){let et=Yx(Fe);if(!et||Ee.size>=256){He++;continue}et.tessellation.limited&&u.push(`${R}: a pad contour retains validated geometry because the 0.0025 mm tolerance could not be met within hole-containment/display limits.`),Ee.set(vt,{outline:et,pads:[]})}Ee.get(vt).pads.push(Fe)}He&&u.push(`${R}: ${He} unsupported/ambiguous pad shapes omitted; no rectangular stand-ins were substituted.`);let je=Ee.size?ty(Wn,"pad",{color:16777215,...pr.copper}):null;for(let[Fe,vt]of Ee){let et=oe(vt.outline,ie.thickness),dt=Jh(Bt(R),et,je,vt.pads,(Lt,Rt)=>{let[Wt,Ft]=ee(Rt.at);Lt.position.set(Wt,Ft,ie.base),Lt.rotation.z=(Rt.rotation||0)*Math.PI/180},ua("copper-pad",R,Fe));dt&&(kr(dt,"pads",R),dn.push(dt),en.push({mesh:dt,role:"pads",layer:R,pads:vt.pads}))}let Qe=_m(new En({color:k,...pr.copper,side:xn,...Xc("zone")}),"zone"),rt=!1;for(let Fe of o.forLayer(R)){let vt;try{let dt=Wb(Wn,Fe,{world:ee,triangulate:zb.triangulate,maxBytes:$-te.retainedBytes});vt=dt.geometry,te.retainedBytes+=dt.bytes,te.renderedContours++,te.vertices+=dt.vertices}catch(dt){te.rejected++,u.push(`${R}: saved zone ${Fe.id} contour ${Fe.contour}: ${dt.message}`);continue}if(!Fe.filled){let dt=new es(vt,new Xt({color:k,transparent:!0,opacity:.6}));dt.position.z=ye,Bt(R).add(dt),kr(dt,"polygons",R);continue}rt=!0;let et=new ct(vt,Qe);et.position.z=["F.Cu","B.Cu"].includes(R)?HM(R,ie):ye,et.userData.record={id:Fe.id,net:Fe.net,layer:R,filled:!0,contour:Fe.contour,type:"Zone"},Bt(R).add(et),kr(et,"fills",R),dn.push(et),en.push({mesh:et,role:"zone",layer:R}),At.add(et,"zone")}rt||Qe.dispose();for(let[Fe,vt]of no){if(vt.span.from!==R&&vt.span.to!==R)continue;let et=oe(vt.outline,ie.thickness),dt=Jh(Bt(R),et,BE,vt.vias,(Lt,Rt)=>{let[Wt,Ft]=ee(Rt.at);Lt.position.set(Wt,Ft,ie.base)},ua("via-barrel",R,"annulus-"+Fe));dt&&(kr(dt,"vias",R),dn.push(dt))}}for(let R of le.filter(k=>!k.internal))oy(R.name);function id(){let R=le.filter(ie=>ie.internal&&!_e.has(ie.name));if(!R.length)return;let k=u.length;for(let ie of R)oy(ie.name),F.retain(ui.get(ie.name));wi.push(...u.slice(k)),R.some(ie=>ie.basis==="illustrative")&&wi.push("Internal copper has saved XY coordinates and layer order; elevations are illustrative because a complete saved stackup is unavailable."),Zc()}let fa=new Dt;Fn.add(fa);let zE=qM(a),sn=Jh(fa,new Hp(1,1,1,2,.06),new En(pr.proxy),a.components,(R,k)=>{let ie=zE.get(k),[ye,ve]=ee(ie?.at||k.at),Ee=k.layer?.startsWith("B.");R.position.set(ye,ve,Ee?We-1.1:Re+1.1),R.rotation.set(0,0,ie?.rotation||0),R.scale.set(ie?.width||0,ie?.height||0,ie?2.1:0)},ua("component","F.Fab","proxies"));sn&&(dn.push(sn),At.add(sn,"component")),sn&&(sn.castShadow=!0,sn.receiveShadow=!0);let ay=jx(a.components),rd=a.components.map((R,k)=>{let ie=new nt;return sn?.getMatrixAt(k,ie),ie}),VE=new nt().makeScale(0,0,0),zr=new Map,jc=new Set,qc=null,pa=a.components.map(()=>!0);function sd(){let R=new nt;a.components.forEach((k,ie)=>{R.copy(rd[ie]),R.elements[14]+=Ye.componentOffset(k.layer?.startsWith("B.")?"B.Cu":"F.Cu"),sn?.setMatrixAt(ie,pa[ie]&&Un.visible("bodies",k.layer)&&!jc.has(ie)?R:VE)}),sn&&(sn.instanceMatrix.needsUpdate=!0,sn.computeBoundingSphere());for(let[k,ie]of zr)ie.visible=pa[k]&&Un.visible("bodies",a.components[k].layer),Ye.component(ie,a.components[k].layer?.startsWith("B.")?"B.Cu":"F.Cu");P.shadowMap.needsUpdate=!0,fe()}let wi=Array.isArray(t.assetWarnings)?t.assetWarnings.filter(R=>typeof R=="string").slice(0,48).map(R=>R.slice(0,500)):[];o.stats().unfilled&&wi.push(`${o.stats().unfilled} zones have no saved copper fill; only their boundaries are shown.`),(o.stats().omitted||o.stats().invalid)&&wi.push("Saved zone index: "+o.stats().omitted+" contours exceed the descriptor budget; "+o.stats().invalid+" invalid contours were rejected."),wi.push(...u),Zc();let cy=0,Kc=$M(()=>{if(!xe)return;Y.invalidate();let R=performance.now();try{sd(),Pm(),Hi(zn),Zc()}finally{cy+=performance.now()-R}},fe);function Zc(){let R=jc.size,k=wi.length;b.replaceChildren(document.createTextNode(`Material preview \xB7 linked models ${R}/${a.components.length}`));let ie=document.createElement("details"),ye=document.createElement("summary"),ve=document.createElement("ul");ye.textContent=k?`${k} rendering notes`:"Rendering details";let Ee=["Mask openings follow saved pad layer flags; this is not a reconstructed solder-mask solid.",a.components.length-R+" footprints have no linked model; bounded stand-ins are used only where usable saved footprint bounds exist.",...wi];for(let He of Ee){let je=document.createElement("li");je.textContent=He,ve.append(je)}ie.append(ye,ve),b.append(ie),t.onDiagnostics?.(["Linked component models: "+R+"/"+a.components.length,...Ee]),b.title=wi.join(`
`)}function wm(R,k){try{return re.checkTemplate(R,2+(zr.has(k)?0:1)),F.retain(R,Z,ae)}catch(ie){throw F.discard(R),ie}}async function HE(R,k,ie,ye){let ve=k?.base64,Ee=R.embeddedAsset?await globalThis.KiCadEmbeddedModels.decode(k,kE.default.decompress):globalThis.KiCadEmbeddedModels.decodeBase64(ve);if(Ee.byteLength>8*1024*1024)throw new Error("model asset exceeds 8 MiB");if(ie(Ee.byteLength),["step","stp"].includes(R.format)){qc||=new globalThis.KiCadStepDecoder.Client(new URL("step-worker.js",location.href).href);let je=await qc.decode(Ee),Qe=new Dt;for(let rt of je){let Fe=new ot;Fe.setAttribute("position",new gt(rt.positions,3)),Fe.setIndex(new gt(rt.index,1)),rt.normals?Fe.setAttribute("normal",new gt(rt.normals,3)):Fe.computeVertexNormals();let vt=rt.groups.map((dt,Lt)=>(Fe.addGroup(dt.start,dt.count,Lt),new En({color:new Ue(...dt.color),roughness:.65,metalness:.1}))),et=vt.length===1?vt[0]:vt;Qe.add(new ct(Fe,et))}return wm(Qe,ye)}if(R.format==="glb"){try{uv(Ee,re.limit,{maxAccessorBytes:Z,maxTextureBytes:ae,maxTextureDimension:X.maxDimension})}catch(je){throw["MODEL_GRAPH_BUDGET","MODEL_ALLOCATION_BUDGET"].includes(je.code)&&re.rejectPreflight(),je}return wm((await new Lp().parseAsync(Ee.buffer,"")).scene,ye)}let He=new TextDecoder("utf-8",{fatal:!0}).decode(Ee);if(/\b(?:Inline|ImageTexture|MovieTexture|AudioClip)\b|\burl\s*(?:\[|\")/i.test(He))throw new Error("VRML has an external resource reference");return wm(new zp().parse(He),ye)}async function GE(R){if(!t.boardPath)return;let k;try{k=globalThis.KiCadRepoModels.collectParsed(R,t.boardPath,t.assetPaths),R=null}catch(je){wi.push(`Cannot read model references: ${je.message}`),Zc();return}wi.push(...k.diagnostics),Zc();let ie=sv(k.models),ye=new Map(a.components.map((je,Qe)=>[je.id,Qe])),ve=0,Ee=0;async function He(je){let Qe=ye.get(je.footprintId);if(Qe===void 0){wi.push(`${je.reference}: footprint identity not found`),ie.release(je);return}try{let rt=await ie.get(je,async()=>{let Fe=je.embeddedAsset||await t.loadAsset?.(je.path);if(!xe)throw Error("3D viewer closed before model decoding.");return HE(je,Fe,vt=>{if(ve+=vt,ve>25165824)throw new Error("Decoded 3D model assets exceed 24 MiB in this viewer")},Qe)});if(!xe)return;re.admit(rt,2+(zr.has(Qe)?0:1),()=>{let Fe=ie.isLastUse(je)?rt:rt.clone(!0);F.retainClone(Fe,Z,ae);let vt=0;if(Fe.traverse(Rt=>{Rt.isMesh&&Rt.geometry?.attributes?.position?.count&&(vt++,Rt.castShadow=!0,Rt.receiveShadow=!0,Rt.userData.record={...a.components[Qe],type:"Component",modelPath:je.path},At.add(Rt,"component"),dn.push(Rt))}),!vt)throw new Error("asset has no drawable mesh");let et=globalThis.KiCadRepoModels.modelPose(je,W,Q,Oe),dt=new Dt;dt.position.set(...et.position),dt.rotation.z=et.footprintAngle;let Lt=new Dt;if(Lt.rotation.set(...et.modelRotation,"ZYX"),Lt.scale.set(...et.scale),Lt.add(Fe),dt.add(Lt),!zr.has(Qe)){let Rt=new Dt;zr.set(Qe,Rt),fa.add(Rt)}zr.get(Qe).add(dt),jc.add(Qe),je.format==="glb"&&wi.push(`${je.reference}: GLB geometry is interpreted in millimetres.`)})}catch(rt){wi.push(`${je.reference}: ${je.path}: ${rt?.message||String(rt)}`)}finally{ie.release(je)}Kc.request()}await Promise.all(Array.from({length:Math.min(ge,k.models.length)},async()=>{for(;Ee<k.models.length&&xe;)await He(k.models[Ee++])})),ie.clear(),qc?.dispose(),qc=null,xe&&(Kc.flush(),!tt&&jc.size&&io())}let Rm=Math.hypot(H,Ie,Oe+5)/2,Cm=new z,WE=new z,Jc=new zt().setFromObject(Fn);function ma(){let R=hE(D.position.toArray(),D.getWorldDirection(WE).toArray(),Jc.min.toArray(),Jc.max.toArray()),k=dE(D.position.distanceTo(we.target),Rm+we.target.distanceTo(Cm),R);D.near=k.near,D.far=Ti.enabled?Math.max(k.far,Te*10):k.far,D.updateProjectionMatrix()}function Pm(){Jc.setFromObject(Fn);let R=Jc.getBoundingSphere(new qt);Number.isFinite(R.radius)&&R.radius>0&&(Rm=R.radius,Cm.copy(R.center)),ma()}we.addEventListener("change",ma);function ly(R){if(!Xn)return;let{width:k,height:ie,ratio:ye}=Xn,ve=R?Math.min(ye,Math.sqrt(6e5/k/ie),ye*.78):ye;(P.domElement.width!==Math.floor(k*ve)||P.domElement.height!==Math.floor(ie*ve)||P.getPixelRatio()!==ve)&&P.setDrawingBufferSize(k,ie,ve)}function gs(){let R=Pe();if(pe.setState({hasSize:R}),!R){fe();return}let k=Math.max(1,p.clientWidth),ie=Math.max(1,p.clientHeight),ye=Kx(k,ie,globalThis.devicePixelRatio,X.maxDimension,ys.running()?"low":Le,X),ve=ye.ratio;(P.domElement.width!==Math.floor(k*ve)||P.domElement.height!==Math.floor(ie*ve))&&Y.invalidate(),Xn={width:k,height:ie,ratio:ve},ly(at),D.aspect=k/ie,$e&&($e.composer.setPixelRatio(ve),$e.composer.setSize(k,ie)),D.updateProjectionMatrix(),fe()}function io(R="iso"){gs(),Fn.updateWorldMatrix(!0,!0);let k=new zt().setFromObject(Fn),ie=k.getBoundingSphere(new qt),ye=Number.isFinite(ie.radius)&&ie.radius>0?ie.radius:Math.hypot(H,Ie,Oe+5)/2,ve=ie.radius>0?ie.center:new z,Ee=SE(R),He=new z(...Ee.direction).normalize(),je=im(k.getSize(new z).toArray(),He.toArray(),D.fov,D.aspect,.85,Ee.up)||nm(ye,D.fov,D.aspect)||Te*3;Rm=ye,Cm.copy(ve),Jc.copy(k),we.maxDistance=Math.max(Te*8,je*4),D.position.copy(ve).addScaledVector(He,je),D.up.fromArray(Ee.up),we.target.copy(ve),we.update(),ma()}S("Fit",()=>{tt=!0,io()},"M8 3H3v5M16 3h5v5M21 16v5h-5M8 21H3v-5M8 8h8v8H8Z","Fit board to viewport").classList.add("fit-action");let gr=document.createElement("select");gr.className="view-select",gr.title="Choose a board viewing side",gr.setAttribute("aria-label","3D camera view");let od=document.createElement("option");od.value="",od.disabled=!0,od.textContent="View",gr.append(od);for(let{id:R,label:k}of Zh){let ie=document.createElement("option");ie.value=R,ie.textContent=k,gr.append(ie)}gr.value="",gr.onchange=()=>{tt=!0,io(gr.value),gr.value=""},x.append(gr);let Im=document.createElement("span");Im.className="divider",Im.setAttribute("aria-hidden","true"),x.append(Im);let xs=!1;function uy(R){return xs=!!R,Kb(we,Wn,xs),Nm.setAttribute("aria-pressed",String(xs)),P.domElement.style.cursor=xs?"grab":"",xs}let Nm=S("Pan",()=>{oo(!1),uy(!xs)},"M12 3v18M3 12h18M8 7l4-4 4 4M8 17l4 4 4-4M7 8l-4 4 4 4M17 8l4 4-4 4","Pan view with left drag");Nm.setAttribute("aria-pressed","false");let ad=S("Measure",()=>oo(!tn),"M3 17 17 3l4 4L7 21ZM7 13l3 3M10 10l2 2M13 7l3 3","Measure distance between 3D surfaces");ad.setAttribute("aria-pressed","false");let ga=S("Display",()=>J(C.hidden),"M3 6h18M3 12h18M3 18h18M7 3v6M17 9v6M10 15v6","3D display settings");ga.setAttribute("aria-expanded","false"),ga.setAttribute("aria-controls",C.id);let Qc=document.createElement("label");Qc.className="explode-control",Qc.style.cssText="display:inline-flex;align-items:center;gap:5px;font-size:11px",Qc.title="Expand mode: components lift first, then copper layers separate, the substrate fades and vias stretch. Saved identities remain linked.";let hy=document.createElement("span");hy.textContent="Expand mode";let Ri=document.createElement("input");Ri.type="range",Ri.min="0",Ri.max="100",Ri.step="1",Ri.value="0",Ri.style.cssText="width:80px;min-width:50px",Ri.setAttribute("aria-label","Expand assembly");let Lm=document.createElement("output");Lm.textContent="0%",Qc.append(hy,Ri,Lm);let ro=document.createElement("details");ro.className="tools-more";let $c=document.createElement("summary");$c.textContent="3D tools",$c.title="More 3D tools",$c.setAttribute("aria-label","More 3D tools");let Om=document.createElement("div");Om.className="tools-panel",Om.append(Nm,ad,ga,Qc),ro.append($c,Om),x.append(ro);let so=document.createElement("p");so.className="quality-help",so.setAttribute("role","status"),so.hidden=!0,so.style.cssText="position:absolute;left:10px;bottom:10px;z-index:5;max-width:calc(100% - 20px);margin:0;padding:6px 9px;background:var(--panel);border:1px solid var(--border);border-radius:5px;pointer-events:none",f.append(so);function dy(){Nt.sync(Gr.overlay,Ye.get())}function fy(R=Gr.getAnalysisOverlayState()){return Ye.get()>0&&R.placed?{...R,displaySuspended:!0,diagnostics:[...R.diagnostics,"Registered result and probes are hidden while Expand mode is active; restore Expand mode to 0% to view them."]}:R}let py=0,my=0,Dm=0;function XE(R){let k=performance.now();if(!xe)return Ye.get();let ie=Ye.get(),ye=Ye.set(R);if(ie===0!=(ye===0)&&(ye>0&&De(),Vi(yt)),P.shadowMap.enabled=!1,ye>0){let Ee=_e.size;id(),_e.size!==Ee&&Vi(yt)}ye!==ie&&(tt=!0,vr(),tn&&oo(!1));for(let Ee of le){let He=ui.get(Ee.name);He&&(Ye.layer(He,Ee.name),He.visible=ft(Ee))}for(let Ee of da.children){let He=to.find(je=>je.mesh===Ee)?.layer;Ye.layer(Ee,He==="B.SilkS"?"B.Cu":"F.Cu")}for(let{mesh:Ee,span:He}of ut)Ye.barrels(Ee,He);sd(),Ot?Ma.syncTransforms():Gh(zn)&&Hi(zn),hi?.object&&!pn&&(ky(hi.object,hi.instanceId),ho.getCenter(hi.point)),Yc(),dy(),Pm(),by(),Lm.textContent=Math.round(ye)+"%",Ri.setAttribute("aria-valuetext",Math.round(ye)+" percent expanded"),so.hidden=ye===0,so.textContent="Display-only expansion: components lift first, then copper separates and substrate fades. "+(le.some(Ee=>Ee.basis==="illustrative")?"Internal elevations are illustrative. ":"")+"Registered results and measurements resume at 0%.",py++;let ve=performance.now()-k;return my+=ve,Dm=Math.max(Dm,ve),t.onExplodeChange?.(ye),fe(),ye}let ys=RE({request:R=>requestAnimationFrame(R),cancel:R=>cancelAnimationFrame(R),update:XE,canRun:()=>xe&&!Ne&&!pe.stats().paused,reducedMotion:()=>globalThis.matchMedia?.("(prefers-reduced-motion: reduce)").matches===!0,settle:R=>{if(P.shadowMap.enabled=R===0&&Le!=="low"&&yt!=="translucent",P.shadowMap.needsUpdate=!0,R===0)try{st()}catch{pt("Enhanced quality is unavailable. Balanced rendering is active.")}gs(),fe()}});function cd(R,k=!1){if(!xe)return Ye.get();if(!Number.isFinite(R)||R<0||R>100)throw new TypeError("Expand amount must be between 0 and 100.");R>0&&id(),Ri.value=String(R);let ie=ys.set(R,{immediate:k});return gs(),ie}Ri.oninput=()=>cd(Number(Ri.value));let gy=new Map,Fm=()=>le.filter(R=>be.get(R.name)).map(R=>R.name);function xy(R){if(!Array.isArray(R)||R.some(ve=>typeof ve!="string"||!be.has(ve))||new Set(R).size!==R.length)throw new TypeError("Choose saved physical copper layer names.");let k=new Set(R),ie=!1;for(let ve of le){let Ee=k.has(ve.name);be.get(ve.name)!==Ee&&(ie=!0),be.set(ve.name,Ee);let He=gy.get(ve.name);He&&(He.checked=Ee);let je=ui.get(ve.name);je&&(je.visible=ft(ve))}Hi(zn),fe();let ye=Fm();return ie&&t.onLayersChange?.([...ye]),ye}for(let R of le)gy.set(R.name,se(R.name==="F.Cu"?"Front copper":R.name==="B.Cu"?"Back copper":R.name+" copper",!0,k=>{let ie=new Set(Fm());k?ie.add(R.name):ie.delete(R.name),xy([...ie])}));let yy=document.createElement("label"),el=document.createElement("select");yy.append(document.createTextNode("Inspect copper layer"),el),el.setAttribute("aria-label","Inspect copper layer");for(let[R,k]of[["","Assembled board"],...le.map(ie=>[ie.name,ie.name])]){let ie=document.createElement("option");ie.value=R,ie.textContent=k,el.append(ie)}K.append(yy);let YE=se("Parts",!0,R=>{fa.visible=!qe&&R,Gh(zn)&&Hi(zn),P.shadowMap.needsUpdate=!0}),jE=se("Silkscreen",!0,R=>{da.visible=!qe&&R});el.onchange=()=>{qe=el.value||null,fa.visible=!qe&&YE.checked,da.visible=!qe&&jE.checked,Am.visible=!qe,Vi(yt)};let vy=!1,tl=new Dt,xr=new Map;Ae.add(tl);let _y=new Ar(1,1),qE=l.filter(R=>R.name&&R.net&&R.name.length<=40&&R.net.length<=48).slice(0,1e4).map(R=>{let[k,ie]=ee(R.at);return{pad:R,x:k,y:ie}}),xa=[],ld=new Set;function KE(R){let k=JSON.stringify([R.name,R.net]);if(xr.has(k)){let Ee=xr.get(k);return xr.delete(k),xr.set(k,Ee),ld.add(Ee),Ee}if(xr.size>=150){let Ee=[...xr].find(([,He])=>!ld.has(He));if(!Ee)return null;xr.delete(Ee[0]),Ee[1].dispose()}let ie=document.createElement("canvas");ie.width=512,ie.height=48;let ye=ie.getContext("2d");ye.font="600 14px monospace",ye.textAlign="center",ye.textBaseline="middle",ye.lineJoin="round",ye.lineWidth=5,ye.strokeStyle="#101820",ye.fillStyle="#f3f8fa";for(let[Ee,He]of[[R.name,13],[R.net,34]])ye.strokeText(Ee,256,He),ye.fillText(Ee,256,He);let ve=new ns(ie);return ve.colorSpace=wt,xr.set(k,ve),ld.add(ve),ve}let nl=new z,ZE=new z;function by(){let R=0;if(ld.clear(),tl.visible=vy&&!tn,!tl.visible)return;if(!Un.visible("pads"))return void xa.forEach(Ee=>Ee.visible=!1);let k=Math.max(1,p.clientHeight),ie=Math.max(1,p.clientWidth),ye=[],ve=D.position.z>=we.target.z?"F.Cu":"B.Cu";if(!Bt(ve).visible||!Un.visible("pads",ve))return void xa.forEach(Ee=>Ee.visible=!1);for(let{pad:Ee,x:He,y:je}of qE){if(R>=150)break;if(!(Ee.layers?.includes(ve)||Ee.layers?.includes("*.Cu")||Ee.layer===ve))continue;let Qe=(ve==="F.Cu"?Re+.055:We-.055)+Ye.offset(ve),rt=D.position.distanceTo(ZE.set(He,je,Qe)),Fe=k/(2*Math.tan(D.fov*Math.PI/360)*rt),vt=Math.min(Ee.width,Ee.height)*Fe;if(!Number.isFinite(vt)||vt<32||(nl.set(He,je,Qe).project(D),nl.z<-1||nl.z>1))continue;let et=Math.min(16,Math.max(10,vt*.22)),dt=(Math.max(Ee.name.length,Ee.net.length)*.63+1)*et,Lt=et*2.8,Rt=(nl.x+1)*ie/2,Wt=(1-nl.y)*k/2,Ft={x:Rt-dt/2,y:Wt-Lt/2,w:dt,h:Lt};if(Ft.x<0||Ft.y<0||Ft.x+dt>ie||Ft.y+Lt>k||ye.some(Aa=>Ft.x<Aa.x+Aa.w&&Ft.x+dt>Aa.x&&Ft.y<Aa.y+Aa.h&&Ft.y+Lt>Aa.y))continue;let jn=KE(Ee);if(!jn)continue;let Gi=xa[R];Gi||(Gi=new ct(_y,new Ht({transparent:!0,depthTest:!0,depthWrite:!1,side:xn})),Gi.renderOrder=5,tl.add(Gi),xa.push(Gi)),Gi.material.map!==jn&&(Gi.material.map=jn,Gi.material.needsUpdate=!0),Gi.position.set(He,je,Qe),Gi.quaternion.copy(D.quaternion),Gi.scale.set(512/14*et/Fe,48/14*et/Fe,1),Gi.visible=!0,ye.push(Ft),R++}for(let Ee=R;Ee<xa.length;Ee++)xa[Ee].visible=!1}se("Pad and net names (close zoom)",!1,R=>{vy=R}),io();let vs=new lr,_s=new Me,Ci=new ym,tn=!1,bs="mm",ya=document.createElement("section");ya.className="measurement-panel",ya.hidden=!0,ya.setAttribute("aria-label","3D surface measurement");let Um=document.createElement("div");Um.className="measurement-heading";let My=document.createElement("strong");My.textContent="Surface distance";let il=document.createElement("select");il.setAttribute("aria-label","3D measurement units");for(let R of["mm","mil"]){let k=document.createElement("option");k.value=R,k.textContent=R,il.append(k)}let rl=document.createElement("button");rl.type="button",rl.textContent="Done",rl.title="Exit measurement mode",rl.onclick=()=>oo(!1),Um.append(My,il,rl);let sl=document.createElement("select"),ol=document.createElement("select"),km=document.createElement("div");km.className="measurement-tools",sl.setAttribute("aria-label","3D measurement snap"),ol.setAttribute("aria-label","3D measurement selection filter");for(let[R,k]of[["surface","Surface"],["edges","Snap to edges"],["corners","Snap to corners"]]){let ie=document.createElement("option");ie.value=R,ie.textContent=k,sl.append(ie)}for(let[R,k]of[["all","All geometry"],["board","Board outline/body"],["models","Component models"],["pads","Pads"],["tracks","Tracks"],["vias","Vias"]]){let ie=document.createElement("option");ie.value=R,ie.textContent=k,ol.append(ie)}km.append(sl,ol);let Ey=new WeakMap,Vr=null,al=null,Ms=new Set,Pi=document.createElement("canvas");Pi.width=Pi.height=240,Pi.className="measurement-label",Pi.hidden=!0,Pi.setAttribute("aria-label","3D measurement magnifier"),Pi.style.cssText="width:120px;height:120px;position:absolute;right:12px;top:50px;left:auto;pointer-events:none;border-radius:50%;z-index:8;padding:0",f.append(Pi);function JE(){if(!tn||!Vr){Pi.hidden=!0;return}let R=P.domElement.getBoundingClientRect(),k=Vr.x-R.left,ie=Vr.y-R.top;Pi.hidden=!1;let ye=Pi.getContext("2d");if(!ye)return;let ve=P.domElement.width/R.width,Ee=P.domElement.height/R.height;ye.clearRect(0,0,240,240),ye.drawImage(P.domElement,(k-20)*ve,(ie-20)*Ee,40*ve,40*Ee,0,0,240,240),ye.strokeStyle="#ffcf66",ye.lineWidth=2,ye.beginPath(),ye.moveTo(110,120),ye.lineTo(130,120),ye.moveTo(120,110),ye.lineTo(120,130),ye.stroke()}let Bm=document.createElement("output");Bm.setAttribute("aria-live","polite");let zm=document.createElement("p");zm.setAttribute("role","status");let Sy=document.createElement("small"),Ty=document.createElement("small");Ty.textContent="Model surfaces \xB7 footprint stand-ins are approximate.";let Vm=document.createElement("div");Vm.className="measurement-tools";let Hr=document.createElement("select");Hr.setAttribute("aria-label","Recent 3D measurements");let cl=document.createElement("button");cl.type="button",cl.textContent="Clear",cl.title="Clear all 3D measurements",cl.onclick=Py,Vm.append(Hr,cl),ya.append(Um,km,Bm,zm,Sy,Vm,Ty),f.append(ya);let Zi=document.createElement("div");Zi.className="measurement-label",Zi.hidden=!0,Zi.setAttribute("aria-hidden","true"),f.append(Zi);let va=new Dt;va.visible=!1,Ae.add(va);let Hm=new ot;Hm.setAttribute("position",new gt(new Float32Array(6),3));let QE=new Xt({color:16765818,transparent:!0,opacity:.95,depthTest:!1,depthWrite:!1,toneMapped:!1}),ud=new ai(Hm,QE);ud.frustumCulled=!1,ud.renderOrder=201,va.add(ud);let Ay=new _i(1,12,8),wy=new Ht({color:16765818,transparent:!0,opacity:.95,depthTest:!1,depthWrite:!1,toneMapped:!1}),ll=[new ct(Ay,wy),new ct(Ay,wy)];for(let R of ll)R.renderOrder=202,va.add(R);let Ry=R=>new z(R.x-W,Q-R.y,R.z);function _a(R){let k=Ci.selected,ie=Ci.pending;Bm.textContent=k?(k.approximate?"\u2248 ":"")+vm(k.distance,bs):"\u2014",zm.textContent=R||(ie?"Choose the second surface point.":k?"Choose a point to start another measurement.":"Choose the first surface point.");let ye=Ee=>(bs==="mil"?Ee/.0254:Ee).toFixed(bs==="mil"?2:3);Sy.textContent=k?`\u0394X ${ye(k.delta.x)} \xB7 \u0394Y ${ye(k.delta.y)} \xB7 \u0394Z ${ye(k.delta.z)} ${bs}`:"",Hr.replaceChildren();let ve=document.createElement("option");ve.value="",ve.textContent=Ci.records.length?"Recent measurements":"No measurements yet",Hr.append(ve);for(let Ee of Ci.records){let He=document.createElement("option");He.value=String(Ee.id),He.textContent=`#${Ee.id} \xB7 ${Ee.approximate?"\u2248 ":""}${vm(Ee.distance,bs)}`,Hr.append(He)}Hr.value=k?String(k.id):"",Hr.disabled=!Ci.records.length,Zi.textContent=k?(k.approximate?"\u2248 ":"")+vm(k.distance,bs):"",Cy(),fe()}function Cy(){let R=Ci.selected,k=Ci.pending;if(va.visible=tn&&!!(R||k),Zi.hidden=!tn||!R,!va.visible)return;let ie=Ry(R?.from||k),ye=R?Ry(R.to):null;if(ll[0].position.copy(ie),ll[1].visible=!!ye,ud.visible=!!ye,ye){ll[1].position.copy(ye);let ve=Hm.getAttribute("position");ve.setXYZ(0,ie.x,ie.y,ie.z),ve.setXYZ(1,ye.x,ye.y,ye.z),ve.needsUpdate=!0;let Ee=ie.clone().add(ye).multiplyScalar(.5).project(D);Zi.hidden=Ee.z<-1||Ee.z>1,Zi.style.left=Math.max(8,Math.min(p.clientWidth-Zi.offsetWidth-8,(Ee.x+1)*p.clientWidth/2+8))+"px",Zi.style.top=Math.max(8,Math.min(p.clientHeight-Zi.offsetHeight-8,(1-Ee.y)*p.clientHeight/2-24))+"px"}for(let ve of ll){let Ee=Math.max(.005,D.position.distanceTo(ve.position)*2*Math.tan(D.fov*Math.PI/360)/Math.max(1,p.clientHeight)*3.5);ve.scale.setScalar(Ee)}}function oo(R){return xe?R&&Ye.get()>0?(Be("Restore Expand mode to 0% before measuring saved geometry."),!1):(tn=!!R,tn&&uy(!1),h.dataset.measuring=String(tn),ad.setAttribute("aria-pressed",String(tn)),ya.hidden=!tn,tn||(Ci.pending=null,Vr=null,al=null,Ms.clear(),we.enabled=!0,Pi.hidden=!0),_a(),t.onMeasurementMode?.(tn),tn):!1}function Py(){Ci.clear(),_a(),t.onMeasurement?.(null)}il.onchange=()=>{bs=il.value==="mil"?"mil":"mm",_a()},Hr.onchange=()=>{let R=Ci.replay(Hr.value);R&&(_a(),t.onMeasurement?.(R))};let Iy=R=>{R.key==="Escape"&&tn&&(R.preventDefault(),R.stopPropagation(),oo(!1),ad.focus())};d.addEventListener("keydown",Iy);function $E(){let R=Wt=>hm(Wt,In,qe||Ye.get()>0?"translucent":yt),k=vs.intersectObjects(dn.filter(R),!1).find(Wt=>yr.isVisible(Wt.object,Wt.instanceId));if(!k)return null;let ie=k.object===In?"board":to.find(Wt=>Wt.mesh===k.object)?.type||"models",ye=ie==="arcs"?"tracks":ie;if(ol.value!=="all"&&ol.value!==ye)return null;if(sl.value==="surface")return{point:k.point,approximate:k.object===sn,kind:"surface"};let ve=k.object.geometry,Ee=ve?.getAttribute("position");if(!Ee||Ee.count>2e5)return null;let He=Ey.get(ve);if(!He){let Wt=new ss(ve,25),Ft=Wt.getAttribute("position");He=[];for(let jn=0;jn+1<Ft.count&&He.length<1e4;jn+=2)He.push([[Ft.getX(jn),Ft.getY(jn),Ft.getZ(jn)],[Ft.getX(jn+1),Ft.getY(jn+1),Ft.getZ(jn+1)]]);Wt.dispose(),Ey.set(ve,He)}let je=k.object.matrixWorld.clone();if(Number.isInteger(k.instanceId)){let Wt=new nt;k.object.getMatrixAt(k.instanceId,Wt),je.multiply(Wt)}let Qe=He.map(Wt=>Wt.map(Ft=>{let jn=new z(...Ft).applyMatrix4(je);return{x:jn.x,y:jn.y,z:jn.z}})),rt=P.domElement.getBoundingClientRect(),Fe=Wt=>{let Ft=new It(Wt.x,Wt.y,Wt.z,1).applyMatrix4(D.matrixWorldInverse).applyMatrix4(D.projectionMatrix);return Ft.w<=0?null:{x:(Ft.x/Ft.w+1)*rt.width/2,y:(1-Ft.y/Ft.w)*rt.height/2,z:Ft.z/Ft.w,w:Ft.w}},vt=EE({x:(_s.x+1)*rt.width/2,y:(1-_s.y)*rt.height/2},Qe,Fe,{mode:sl.value,tolerance:Vr?18:12});if(!vt)return null;let et=new z(vt.point.x,vt.point.y,vt.point.z),dt=et.clone().project(D),Lt=new lr;Lt.setFromCamera(new Me(dt.x,dt.y),D);let Rt=Lt.intersectObjects(dn.filter(R),!1).find(Wt=>yr.isVisible(Wt.object,Wt.instanceId));return!Rt||Rt.object!==k.object||Rt.instanceId!==k.instanceId||Rt.point.distanceTo(et)>Math.max(.002,D.position.distanceTo(et)*5e-5)?null:{point:et,approximate:k.object===sn,kind:vt.kind}}function eS(){let R=$E();if(!R){_a("No visible feature within snap range. Adjust snap/filter or zoom in.");return}let k=Ci.add({x:R.point.x+W,y:Q-R.point.y,z:R.point.z,approximate:R.approximate});_a(R.kind+" selected. "+(Ci.pending?"Choose the second point.":"Measurement complete.")),k?.distance!==void 0&&t.onMeasurement?.(k)}let hi=null,ul=AE({onPick:R=>{xs||Ym(R)},onContextMenu:Wy,isHeld:()=>Ta.isHeld()}),ba=!0,ao=um(),yr=ZM(Wn,()=>{let R=[];return Fn.traverse(k=>{k.material&&R.push(k)}),R});Ct=!0;let co=2e3,Ny=new ss(new Qn(1,1,1)),Es=Ny.getAttribute("position"),lo=new ot,hd=new gt(new Float32Array(co*Es.count*3),3);hd.setUsage(bp),lo.setAttribute("position",hd),lo.setDrawRange(0,0);let Ly=()=>new Xt({color:r?16768893:10179840,depthTest:!0,depthWrite:!1,toneMapped:!1}),uo=new ln(lo,Ly());uo.frustumCulled=!1,uo.renderOrder=101,Ae.add(uo);let zn={},Ma=IE(Wn,{scene:Ae,objects:()=>dn,colorForLayer:Em,visible:(R,k)=>{if(qe?k!==qe:be.has(k)&&!be.get(k))return!1;for(let ie=R;ie;ie=ie.parent)if(!ie.visible&&ie!==ui.get(k))return!1;return!0}});function Oy(R){Ma.update(R,ao),Ma.stats().limited&&(di.hidden=!1,di.style.display="",di.textContent="Net shine-through reached its display budget; native selection is retained.")}let Ea={netOnlyUpdates:0,netRecordsScanned:0,netBoundsAvoided:0,boundsEvaluations:0,outlineVerticesWritten:0},di=document.createElement("div");di.className="hint",di.style.bottom="42px",di.hidden=!0,f.append(di);function Hi(R={}){if(Y.invalidate(),fe(),zn=R||{},Ot=!1,ht=!1,pn=!1,!Gh(zn))return Ma.clear(),lo.setDrawRange(0,0),di.hidden=!0,di.style.display="none",fi.visible=!1,uo.visible=!1,yr.restore(),Yc(),{highlighted:0,matched:0,limited:!1};let k=tE(zn,a);k.size&&id();let ie=rE(zn,a);if(ht=ie(In.userData.record),pn=k.size>0,nE(zn,k)){Ot=!0;let et=iE(dn,ie);return Ea.netOnlyUpdates++,Ea.netRecordsScanned+=et.visitedRecords,Ea.netBoundsAvoided+=et.matchedRecords,lo.setDrawRange(0,0),di.hidden=!0,di.style.display="none",fi.visible=!1,uo.visible=!1,yr.update(ie,et.matched>0&&ba,dt=>k.has(dt?.net),{...ao,expanded:Ye.get()>0,netContext:k.size>0}),Yc(),Oy(k),{highlighted:Math.min(et.matched,co),matched:et.matched,limited:et.matched>co}}let ye=new nt,ve=new nt,Ee=new zt,He=new z,je=new z,Qe=0,rt=0,Fe=new Map,vt=(et,dt,Lt)=>{if(Number.isInteger(dt)&&(et.getMatrixAt(dt,ve),ve.determinant()===0)||(Ea.boundsEvaluations++,et.updateWorldMatrix(!0,!1),Number.isInteger(dt)?(et.geometry.boundingBox||et.geometry.computeBoundingBox(),Ee.copy(et.geometry.boundingBox),ye.multiplyMatrices(et.matrixWorld,ve),Ee.applyMatrix4(ye)):Ee.setFromObject(et),Ee.isEmpty()))return;let Rt=Lt?.ref?"part:"+Lt.ref:Lt?.uuid||Lt?.id||et.uuid+":"+dt;Fe.has(Rt)?Fe.get(Rt).union(Ee):Fe.size<co?Fe.set(Rt,Ee.clone()):rt++};for(let et of dn){let dt=!0;for(let Rt=et;Rt;Rt=Rt.parent)Rt.visible||(dt=!1);if(!dt)continue;let Lt=et.userData.records;Lt?Lt.forEach((Rt,Wt)=>{ie(Rt)&&vt(et,Wt,Rt)}):ie(et.userData.record)&&vt(et,void 0,et.userData.record)}for(let et of Fe.values()){et.expandByScalar(.035),et.getCenter(He),et.getSize(je);for(let dt=0;dt<Es.count;dt++)hd.setXYZ(Qe*Es.count+dt,He.x+Es.getX(dt)*je.x,He.y+Es.getY(dt)*je.y,He.z+Es.getZ(dt)*je.z);Qe++}return rt+=Fe.size,lo.setDrawRange(0,Qe*Es.count),hd.needsUpdate=!0,Ea.outlineVerticesWritten+=Qe*Es.count,di.hidden=rt<=co,di.textContent=`Showing ${Qe} of ${rt} selected 3D objects`,di.style.display=rt>co?"block":"none",fi.visible=!1,uo.visible=!k.size,yr.update(ie,rt>0&&ba,k.size?et=>k.has(et?.net):null,{...ao,expanded:Ye.get()>0,netContext:k.size>0}),Yc(),Oy(k),{highlighted:Qe,matched:rt,limited:rt>co}}let fi=new ln(Ny,Ly());fi.matrixAutoUpdate=!1,fi.renderOrder=100,fi.visible=!1,Ae.add(fi);let Dy=new nt,ho=new zt,Fy=new z,Uy=new z;function ky(R,k){if(fe(),R.updateWorldMatrix(!0,!1),Number.isInteger(k)?(R.getMatrixAt(k,Dy),R.geometry.boundingBox||R.geometry.computeBoundingBox(),ho.copy(R.geometry.boundingBox).applyMatrix4(Dy).applyMatrix4(R.matrixWorld)):ho.setFromObject(R),ho.isEmpty()){fi.visible=!1;return}ho.expandByScalar(.035),ho.getCenter(Fy),ho.getSize(Uy),fi.matrix.compose(Fy,new Zt,Uy),fi.matrixWorldNeedsUpdate=!0,fi.visible=!0}function Gm(){hi=null,_.hidden=!0,y.hidden=!0,fi.visible=!1,Hi({}),t.onSelect?.(null)}function Wm(R,k,ie,ye){let ve=t.getSelectionMode?.()||jm;Hi(ve==="net"&&R.net?{netNames:[R.net]}:R.type==="Component"||typeof R.library=="string"?{references:[R.ref]}:{uuids:[R.uuid||R.id]}),hi={record:R,point:k.clone(),object:ie,instanceId:ye},lo.setDrawRange(0,0),ve!=="net"||!R.net?ky(ie,ye):fi.visible=!1,t.onSelect?.(R),_.replaceChildren();let Ee=document.createElement("h2");Ee.textContent=R.ref||R.name||R.type||"Board object";let He=document.createElement("dl");for(let[je,Qe]of Object.entries({Type:R.type||(R.ref?"Component":"Copper"),Reference:R.ref,Value:R.value,Layer:R.layer||R.layers?.join(", "),Net:R.net,Model:R.modelPath||R.modelPaths?.join(", ")})){if(Qe==null||Qe==="")continue;let rt=document.createElement("dt"),Fe=document.createElement("dd");rt.textContent=je,Fe.textContent=String(Qe),He.append(rt,Fe)}_.append(Ee,He),_.hidden=!!t.externalInspector}let pi=wM(Wn,{scene:Ae,objects:()=>dn,document,invalidate:fe}),fo=document.createElement("div");fo.hidden=!0,fo.setAttribute("role","status"),fo.style.cssText="position:absolute;left:12px;right:12px;bottom:12px;z-index:8;padding:9px 12px;border:1px solid var(--accent);border-radius:7px;background:var(--menu);color:var(--ink);font:12px/1.4 system-ui;max-height:calc(100% - 24px);overflow:auto;pointer-events:none",f.append(fo);let Xm=document.createElement("span"),Sa=document.createElement("button");Sa.type="button",Sa.textContent="Cancel",Sa.setAttribute("aria-label","Cancel demo face selection"),Sa.style.cssText="pointer-events:auto;margin-left:10px",Sa.onclick=()=>mo(new DOMException("Face selection was cancelled.","AbortError")),fo.append(Xm,Sa);let po=null,Ji=null,tS=R=>hm(R,In,qe||Ye.get()>0?"translucent":yt);function dd(R,k=!0){pi.sync();let ie=P.domElement.getBoundingClientRect();return!ie.width||!ie.height?null:(_s.set((R.clientX-ie.left)/ie.width*2-1,-((R.clientY-ie.top)/ie.height)*2+1),vs.setFromCamera(_s,D),vs.intersectObjects((k?[...dn,...pi.objects()]:dn).filter(tS),!1).find(ye=>yr.isVisible(ye.object,ye.instanceId))||null)}function mo(R,k){let ie=po;ie&&(po=null,ie.signal?.removeEventListener("abort",ie.abort),fo.hidden=!0,P.domElement.style.cursor="",R?ie.reject(R):ie.resolve(k))}function nS({signal:R}={}){return xe?R?.aborted?Promise.reject(new DOMException("Face selection was aborted.","AbortError")):(mo(new DOMException("Face selection was replaced.","AbortError")),vr(),oo(!1),new Promise((k,ie)=>{let ye=()=>mo(new DOMException("Face selection was aborted.","AbortError"));po={resolve:k,reject:ie,signal:R,abort:ye},R?.addEventListener("abort",ye,{once:!0}),Xm.textContent="Choose a flat component face for the demo display. Drag to orbit; press Escape to cancel.",fo.hidden=!1,P.domElement.style.cursor="crosshair",P.domElement.tabIndex=0,P.domElement.focus({preventScroll:!0})})):Promise.reject(new Error("The 3D view is closed."))}function vr(R){if(Ji===null)return;let k=Ji;Ji=null,pi.pointer(null,"cancel",{pointerId:k,clientY:R?.clientY||0,cancelled:!0}),we.enabled=!0;try{P.domElement.releasePointerCapture(k)}catch{}}function By(R){if(Ji!==null){R.preventDefault(),R.stopImmediatePropagation();return}if(tn||xs||po||R.button!==0)return;let k=dd(R);if(pi.isHit(k)&&pi.pointer(k,"press",R)&&(R.preventDefault(),R.stopImmediatePropagation(),!(!xe||!pi.isHit(k)))){Ji=R.pointerId,we.enabled=!1,P.domElement.tabIndex=0,P.domElement.focus({preventScroll:!0});try{P.domElement.setPointerCapture(R.pointerId)}catch{}}}function zy(R){Ji===R.pointerId&&(pi.pointer(dd(R),"move",R),R.preventDefault(),R.stopImmediatePropagation())}function Vy(R){if(Ji!==R.pointerId)return;let k=Ji;Ji=null,pi.pointer(dd(R),"release",R),we.enabled=!0;try{P.domElement.releasePointerCapture(k)}catch{}R.preventDefault(),R.stopImmediatePropagation()}function fd(R){Ji===R.pointerId&&(vr(R),R.preventDefault(),R.stopImmediatePropagation())}let Hy=R=>{R.key==="Escape"&&po&&(mo(new DOMException("Face selection was cancelled.","AbortError")),R.preventDefault(),R.stopImmediatePropagation())};for(let[R,k]of[["pointerdown",By],["pointermove",zy],["pointerup",Vy],["pointercancel",fd],["lostpointercapture",fd]])P.domElement.addEventListener(R,k,!0);d.addEventListener("keydown",Hy,!0),document.defaultView?.addEventListener("blur",vr);function Ym(R){if(po){try{let Fe=dd(R,!1);mo(null,pi.selectFace(Fe))}catch(Fe){Xm.textContent=Fe.message+" Choose another flat component face, or press Escape."}return}let k=P.domElement.getBoundingClientRect();if(_s.set((R.clientX-k.left)/k.width*2-1,-((R.clientY-k.top)/k.height)*2+1),vs.setFromCamera(_s,D),tn){eS();return}let ie=null,ye=Gr.overlay;if(ye?.group?.visible!==!1&&ye?.mesh.visible){let Fe=ye.sample(vs.intersectObject(ye.mesh,!1)[0]);Fe&&(ie=Fe)}let ve=Fe=>hm(Fe,In,qe||Ye.get()>0?"translucent":yt),Ee=vs.intersectObjects(dn.filter(ve),!1).filter(Fe=>yr.isVisible(Fe.object,Fe.instanceId)),He=t.getSelectionMode?.()||jm,je=Fe=>oE(Fe.object.userData.records?.[Fe.instanceId]||Fe.object.userData.record,He),Qe=yt==="translucent"&&Ee.find(Fe=>je(Fe)&&(Fe.object.userData.records?.[Fe.instanceId]||Fe.object.userData.record)?.type!=="Zone")||Ee.find(je);if(!Qe){ie?t.onAnalysisProbe?.(ie):Gm();return}let rt=Qe.object.userData.records?.[Qe.instanceId]||Qe.object.userData.record;rt&&Wm(rt,Qe.point,Qe.object,Qe.instanceId),ie&&t.onAnalysisProbe?.(ie)}let jm="all",Ta=sE(R=>Wy(R)),Gy=R=>{tn&&R.pointerType==="touch"&&Ms.size&&(we.enabled=!0)};P.domElement.addEventListener("pointerdown",Gy,!0),P.domElement.addEventListener("pointerdown",R=>{ul.down(R),Ta.down(R),y.hidden=!0,tn&&R.pointerType==="touch"&&(Ms.add(R.pointerId),al=Ms.size===1?R.pointerId:null,we.enabled=Ms.size!==1,Vr={x:R.clientX,y:R.clientY},fe())}),P.domElement.addEventListener("pointermove",R=>{ul.move(R),Ta.move(R),tn&&R.pointerType==="touch"&&(Vr={x:R.clientX,y:R.clientY},fe());let k=Gr.overlay;if(k&&t.onAnalysisHover){let ie=P.domElement.getBoundingClientRect();_s.set((R.clientX-ie.left)/ie.width*2-1,-((R.clientY-ie.top)/ie.height)*2+1),vs.setFromCamera(_s,D),t.onAnalysisHover(k.group.visible&&k.mesh.visible?k.sample(vs.intersectObject(k.mesh,!1)[0]):null)}}),P.domElement.addEventListener("pointercancel",R=>{ul.cancel(R),Ta.up(R),Ms.delete(R.pointerId),al=null,we.enabled=!0,Vr=null,Pi.hidden=!0}),P.domElement.addEventListener("pointerup",R=>{Ta.up(R),ul.up(R,{select:!(tn&&R.pointerType==="touch")}),tn&&R.pointerType==="touch"&&(al===R.pointerId&&Ms.size===1&&Ym(R),Ms.delete(R.pointerId),al=null,we.enabled=!0),Vr=null,Pi.hidden=!0});function Wy(R){if(R.preventDefault?.(),tn||po||(Ym(R),!hi))return;y.replaceChildren();let k=[["Focus object",()=>{we.target.copy(hi.point),we.update()}],["Copy reference",()=>navigator.clipboard.writeText(hi.record.ref||hi.record.name||"")]];typeof t.onInspect=="function"&&k.unshift(["Properties",()=>t.onInspect(hi.record)]),typeof t.onComment=="function"&&k.push(["Comment on object",()=>t.onComment(hi.record)]);for(let[ve,Ee]of k){let He=document.createElement("button");He.textContent=ve,He.type="button",He.addEventListener("click",()=>{Ee(),y.hidden=!0}),y.append(He)}let ie=f.getBoundingClientRect();y.hidden=!1,y.style.maxWidth="calc(100% - 16px)",y.style.maxHeight="calc(100% - 16px)",y.style.overflowY="auto";let ye=y.getBoundingClientRect();y.style.left=`${Math.max(8,Math.min(R.clientX-ie.left,ie.width-ye.width-8))}px`,y.style.top=`${Math.max(8,Math.min(R.clientY-ie.top,ie.height-ye.height-8))}px`}P.domElement.addEventListener("contextmenu",R=>{ul.context(R)});let pd=gs,Xy=new ResizeObserver(()=>{pd(),j()});Xy.observe(p);let Yy=fm(pe,p);pd(),j();let Gr=vE({bounds:a.bounds,thickness:Oe,layers:a.layers||[]},{scene:Ae,invalidate:fe,isActive:()=>xe}),iS=requestAnimationFrame(()=>{xe&&(pd(),tt||io())}),jy=KM(Wn,{objects:()=>dn,camera:D,rect:()=>P.domElement.getBoundingClientRect(),positionToWorld:(R,k)=>{let[ie,ye]=ee([R.x,R.y]);return new z(ie,ye,k==="back"?We+Ye.offset("B.Cu"):Re+Ye.offset("F.Cu"))}}),hl=null,qm="",qy="";function Ky(){if(!hl)return;let R=jy(hl),k=JSON.stringify(R);k!==qm&&(qm=k,t.onAnchor?.({anchor:hl,point:R}))}function rS(){let R=P.domElement.getBoundingClientRect(),k=JSON.stringify([D.matrixWorld.elements,D.projectionMatrix.elements,R.left,R.top,R.width,R.height]);k!==qy&&(qy=k,t.onViewChange?.()),Ky()}function sS(){if(ys.resume(),!xe||Ne||document.hidden)return;let R=at&&!tn;R||Kc.flush(),we.update(),ly(R),td.sync({moving:at||ys.running()}),pi.sync(),Ji!==null&&!pi.hasActivePointer&&vr(),Cy(),R?tl.visible=!1:by();let k=!1;Xe=!1;try{if($e&&!R){if($e.composer.render(),Xe||!Y.check())throw Error("Enhanced rendering failed.")}else if(P.render(Ae,D),Xe)throw Error("Board rendering shader failed.");ke++,k=!0}catch{Xe&&Gr.useColorFallback()?(Xe=!1,fe()):$e&&!R?(pt("Enhanced rendering could not complete. Balanced rendering is active."),fe()):Be("The graphics device could not draw this view. Try Low quality or reopen 3D.")}k&&(JE(),rS())}let Zy=R=>{vr(),mo(new DOMException("The graphics context was interrupted.","AbortError")),R.preventDefault(),Ne=!0,pe.setState({contextAvailable:!1}),O.disabled=!0,Be("The graphics context was interrupted. The board and selection are retained while the browser recovers.",!0)},Jy=()=>{xe&&(Ne=!1,pe.setState({contextAvailable:!0}),O.disabled=!1,De(),Je?.dispose(),Je=Ge(),Ae.environment=Je?.texture||null,P.shadowMap.needsUpdate=!0,Le="balanced",Ti.apply(!1),ne(),O.value=Le,h.dataset.quality=Le,Be("Graphics restored. Balanced rendering is active; High quality can be selected again."),gs(),fe())};P.domElement.addEventListener("webglcontextlost",Zy),P.domElement.addEventListener("webglcontextrestored",Jy);let Qy=()=>{document.hidden&&vr(),pe.setState({documentVisible:!document.hidden}),document.hidden||(ys.resume(),fe())};document.addEventListener("visibilitychange",Qy);let $y=R=>{let k=R.composedPath();!k.includes(ga)&&!k.includes(C)&&J(!1)},ev=R=>{R.key==="Escape"&&!C.hidden?(J(!1,!0),R.preventDefault(),R.stopImmediatePropagation()):R.key==="Escape"&&ro.open&&(ro.open=!1,$c.focus(),R.preventDefault(),R.stopImmediatePropagation())};return document.addEventListener("pointerdown",$y),d.addEventListener("keydown",ev,!0),F.retain(Ae),Vi(n),lt(me,!1),GE(t.boardPath?globalThis.KiCadRepoModels.modelSource(s):null),{host:h,board:a,pickDemoFace:nS,createDemoSurface(R,k){if(Y.invalidate(),!xe)throw new Error("The 3D view is closed.");return pi.createSurface(R,k)},setDemoInputHandler(R){R===null&&vr(),pi.setInputHandler(R)},objectVisibilityCapabilities(){return{supportedTypes:[...Un.supportedTypes],unsupportedTypes:["graphics","texts","regions","dimensions","rooms","footprints"]}},setObjectVisibility(R={}){let k=UE(R||{});(k.side!==Un.side||JSON.stringify(k.hiddenTypes)!==JSON.stringify(Un.hiddenTypes))&&(tt=!0),Un=k;for(let{mesh:ie,type:ye,layer:ve}of to)ie.visible=Un.visible(ye,ve);return sd(),Hi(zn),{hiddenTypes:[...Un.hiddenTypes],side:Un.side,supportedTypes:[...Un.supportedTypes],unsupportedTypes:[...Un.unsupportedTypes]}},setMeasurementMode:oo,clearMeasurements:Py,measurementState(){return{mode:tn,unit:bs,...Ci.snapshot()}},setQuality(R){return xe?lt(R):Le},setAppearance(R){return xe?Vi(R):yt},getAppearance(){return yt},getCopperLayers(){return le.map(R=>R.name)},getVisibleCopperLayers(){return Fm()},setVisibleCopperLayers:xy,getRenderStats(){return{...Kx(p.clientWidth,p.clientHeight,globalThis.devicePixelRatio,X.maxDimension,Le,X),...F.stats(),zones:{...o.stats(),...te},modelGraph:{...re.stats(),decodeConcurrency:ge,imagePreflight:"png-jpeg"},padGeometryCache:Ce.stats(),selectionMaterials:yr.stats(),appearance:yt,netGlow:Ma.stats(),effectiveLayerColors:!!qe||Ye.get()>0||yt!=="realistic",renderedPixels:P.domElement.width*P.domElement.height,expansion:{amount:Ye.get(),target:ys.target(),running:ys.running(),...Ye.phases(),frames:py,cpuMilliseconds:my,maxFrameMilliseconds:Dm,frontComponentOffset:Ye.componentOffset("F.Cu"),backComponentOffset:Ye.componentOffset("B.Cu"),layerOffsets:le.map(k=>({name:k.name,offset:Ye.offset(k.name)}))},renderActivity:{...pe.stats(),observesIntersection:!!Yy},selectionWorkload:{...Ea},modelUpdates:{...Kc.stats(),cpuMilliseconds:cy},copperLayers:[..._e],translucency:At.stats(),graphicsTier:X.tier,defaultQuality:X.defaultQuality,maxDimension:X.maxDimension,antialias:U.getContextAttributes()?.antialias===!0,logarithmicDepth:P.capabilities.logarithmicDepthBuffer,floatTargets:X.premium||P.extensions.has("EXT_color_buffer_float"),presentationStage:Ti.enabled,environmentLighting:!!Ae.environment,ambientOcclusion:!!$e?.occlusion,graphicsHealth:Y.stats(),silkscreenDetail:td.stats(),antialiasMethod:$e?"smaa":"none",renderCount:ke,contextLost:Ne,gpuTextures:P.info.memory.textures,drawCalls:P.info.render.calls,loadedModelCount:jc.size,componentCount:a.components.length}},restoreExpand:R=>cd(R,!0),setExplode:cd,getExplode:()=>Ye.get(),setExpand:cd,getExpand:()=>Ye.get(),setAnalysisOverlay(R,k){Y.invalidate();let ie=Gr.setAnalysisOverlay(R,k);return dy(),fy(ie)},getAnalysisOverlayState:()=>fy(),setAnalysisProbes:Gr.setAnalysisProbes,setAnalysisOpacity:Gr.setAnalysisOpacity,setSelection:Hi,focusPart(R){if(!xe||typeof R!="string")return!1;let k=a.components.flatMap((je,Qe)=>je.id===R?[Qe]:[]);if(k.length!==1)return!1;let ie=k[0];if(!pa[ie]||!sn||!rd[ie])return!1;Fn.updateWorldMatrix(!0,!0);let ye=zr.get(ie),ve=new zt;if(ye?.children.length)ve.setFromObject(ye);else{let je=new nt;if(sn.getMatrixAt(ie,je),je.determinant()===0)return!1;sn.geometry.boundingBox||sn.geometry.computeBoundingBox(),ve.copy(sn.geometry.boundingBox).applyMatrix4(new nt().multiplyMatrices(sn.matrixWorld,je))}if(ve.isEmpty())return!1;gs();let Ee=RM(ve.min.toArray(),ve.max.toArray(),a.components[ie].layer,D.fov,D.aspect);if(!Ee)return!1;D.position.fromArray(Ee.position),we.target.fromArray(Ee.target),D.up.fromArray(Ee.up);let He=D.position.distanceTo(we.target);return we.minDistance=Math.min(we.minDistance,He),we.maxDistance=Math.max(we.maxDistance,He),tt=!0,we.update(),Pm(),fe(),!0},clearSelection:Gm,projectAnchor:jy,setAnchor(R){hl=R&&typeof R=="object"?R:null,qm="",hl?Ky():t.onAnchor?.({anchor:null,point:null})},setSelectionDim(R){return ba=!!R,Hi(zn),ba},setSelectionStyle(R){let k=um(R);return ba&&k.mode===ao.mode&&k.color===ao.color?{...k}:(ba=!0,ao=k,Hi(zn),{...k})},selectionAppearanceCapabilities(){return{dim:!0,bright:!0,isolate:!0,sourceColors:!0,instanceColors:!0,desaturatesTextures:!0}},setSelectionMode(R){jm=["all","part","net","pin"].includes(R)?R:"all"},fit(R=!1){xe&&io(R)},getCameraState(){return{position:D.position.toArray(),target:we.target.toArray(),up:D.up.toArray()}},setCameraState(R){if(!xe)return!1;let k=nv(R),ie=we.enableDamping;ei(),mr(),we.enableDamping=!1,we.update(),D.position.fromArray(k.position),we.target.fromArray(k.target),D.up.fromArray(k.up);let ye=D.position.distanceTo(we.target);return we.minDistance=Math.min(we.minDistance,ye),we.maxDistance=Math.max(we.maxDistance,ye),we.update(),we.enableDamping=ie,tt=!0,ma(),fe(),!0},setView(R){return!xe||!Zh.some(k=>k.id===R)?!1:(tt=!0,io(R),!0)},zoom(R){if(!xe||!Number.isFinite(R)||R<=0)return;let k=D.position.clone().sub(we.target),ie=Math.max(we.minDistance,Math.min(we.maxDistance,k.length()/R));k.length()>0&&D.position.copy(we.target).add(k.setLength(ie)),we.update()},setTheme(R){xe&&(h.dataset.theme=R?"dark":"light",ne(),fi.material.color.setHex(R?16768893:10179840),uo.material.color.setHex(R?16768893:10179840),pd(),fe())},selectReference(R){let k=ay.get(R);if(k==null||!sn||!rd[k]||!xe||!pa[k])return!1;let ie=zr.get(k);if(ie?.children.length){let Qe=a.components[k],[rt,Fe]=ee(Qe.at);return Wm(Qe,new z(rt,Fe,(Qe.layer?.startsWith("B.")?We:Re)+Ye.componentOffset(Qe.layer?.startsWith("B.")?"B.Cu":"F.Cu")),ie),!0}let ye=new nt;if(sn.getMatrixAt(k,ye),ye.determinant()===0)return!1;let ve=a.components[k],[Ee,He]=ee(ve.at),je=new z(Ee,He,(ve.layer?.startsWith("B.")?We-1.1:Re+1.1)+Ye.componentOffset(ve.layer?.startsWith("B.")?"B.Cu":"F.Cu"));return sn.localToWorld(je),Wm(ve,je,sn,k),!0},setPopulation(R){if(!(!sn||!xe)&&(pa=YM(a.components,R),sd(),Hi(zn),hi?.record?.ref)){let k=ay.get(hi.record.ref);k!=null&&!pa[k]&&Gm()}},dispose(){td.dispose(),vr(),mo(new DOMException("The 3D view was closed.","AbortError")),pi.dispose();for(let[R,k]of[["pointerdown",By],["pointermove",zy],["pointerup",Vy],["pointercancel",fd],["lostpointercapture",fd]])P.domElement.removeEventListener(R,k,!0);d.removeEventListener("keydown",Hy,!0),document.defaultView?.removeEventListener("blur",vr),tn&&t.onMeasurementMode?.(!1),xe=!1,ys.dispose(),Ri.oninput=null,Kc.dispose(),Gr.dispose(),qc?.dispose(),pe.dispose(),cancelAnimationFrame(iS),Xy.disconnect(),Yy?.disconnect(),we.removeEventListener("change",fe),we.removeEventListener("change",ma),we.removeEventListener("start",ei),we.removeEventListener("end",mr),bt!==null&&clearTimeout(bt),bt=null,we.dispose(),De(),Je?.dispose(),P.domElement.removeEventListener("webglcontextlost",Zy),P.domElement.removeEventListener("webglcontextrestored",Jy),document.removeEventListener("pointerdown",$y),d.removeEventListener("keydown",ev,!0),d.removeEventListener("keydown",Iy),P.domElement.removeEventListener("pointerdown",Gy,!0),document.removeEventListener("visibilitychange",Qy),Ma.dispose(),yr.dispose(),At.dispose(),Ae.traverse(R=>R.shadow?.dispose?.()),F.retain(Ae),xr.forEach(R=>F.track(R)),F.track(_y),F.dispose(),Ae.clear(),Fn.clear(),fa.clear(),da.clear(),ui.clear(),dn.length=0,to.length=0,en.length=0,rd.length=0,zr.clear(),xr.clear(),Ce.clear(),Ta.dispose(),P.dispose(),P.domElement.width=1,P.domElement.height=1,h.remove()}}}export{G2 as mountBoard3D,iI as mountResultScene,lI as mountSavedResult3D,UE as objectVisibilityPolicy};
/*! Bundled license information:
three/build/three.core.js:
three/build/three.module.js:
(**
* @license
* Copyright 2010-2024 Three.js Authors
* SPDX-License-Identifier: MIT
*)
three/examples/jsm/libs/chevrotain.module.min.js:
(*! chevrotain - v9.0.1 *)
*/