PageSourceSearch

https://www.lachainemeteo.ch/bundles/meteoconsultwebmap/plugin/mapjs.beta.4.9.0.min.js

js lachainemeteo.ch collected 2026-09-28 06:52:07 UTC 1,770,444 bytes, 2,452 lines download raw bytes

1(function(){try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode(".cross-icon[data-v-bfa64c90],.target-icon[data-v-b1aa0a44]{pointer-events:none;display:block}.mapjs-picker-valuebox[data-v-700dff50]{pointer-events:none;z-index:1000;height:36px;position:absolute}.mapjs-picker-valuebox__container[data-v-700dff50]{vertical-align:baseline;background:#0a5a96d9;border-radius:5px;flex-direction:column;gap:6px;height:100%;padding:0 12px;display:inline-grid;box-shadow:0 2px 8px #0000004d}.mapjs-picker-valuebox__location[data-v-700dff50]{color:#ffffffe6;border-bottom:1px solid #fff3;align-items:center;gap:6px;padding-bottom:4px;font-size:11px;display:flex}.mapjs-picker-valuebox__location-icon[data-v-700dff50]{opacity:.7;width:14px;height:14px}.mapjs-picker-valuebox__coordinates[data-v-700dff50]{opacity:.85;font-family:monospace;font-size:10px}.mapjs-picker-valuebox__value-group[data-v-700dff50]{align-items:center;gap:10px;display:flex}.mapjs-picker-valuebox__icon[data-v-700dff50]{flex-shrink:0;width:14px;height:14px;margin-bottom:14px}.mapjs-picker-valuebox__icon svg[data-v-700dff50]{width:100%;height:100%;display:block}.mapjs-picker-valuebox__value-container[data-v-700dff50]{flex-direction:column;display:flex}.mapjs-picker-valuebox__value[data-v-700dff50]{color:#fff;align-items:baseline;gap:4px;display:flex}.mapjs-picker-valuebox__wind-arrow[data-v-700dff50]{width:24px;height:24px;display:inline-block;position:relative;top:7px}.mapjs-picker-valuebox__wind-arrow svg[data-v-700dff50]{width:100%;height:100%}.mapjs-picker-valuebox__value-number[data-v-700dff50]{font-family:sans-serif;font-size:12px;font-weight:500;line-height:1}.mapjs-picker-valuebox__unit[data-v-700dff50]{font-family:monospace;font-size:12px}.mapjs-picker-icon[data-v-5b28b63b]{pointer-events:auto;z-index:1000;width:30px;height:30px;position:absolute}.mapjs-picker-icon.draggable[data-v-5b28b63b]:active{cursor:grabbing!important}.mapjs-picker.draggable[data-v-5b28b63b],.mapjs-picker-icon.draggable[data-v-5b28b63b]{touch-action:none;-ms-touch-action:none}/*$vite$:1*/")),document.head.appendChild(e)}}catch(t){console.error("vite-plugin-css-injected-by-js",t)}})();var PO=Object.create,p2=Object.defineProperty,kO=Object.getOwnPropertyDescriptor,IO=Object.getOwnPropertyNames,FO=Object.getPrototypeOf,DO=Object.prototype.hasOwnProperty,OO=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),BO=(e,t,i,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(var s=IO(t),n=0,a=s.length,o;n<a;n++)o=s[n],!DO.call(e,o)&&o!==i&&p2(e,o,{get:(l=>t[l]).bind(null,o),enumerable:!(r=kO(t,o))||r.enumerable});return e},UO=(e,t,i)=>(i=e==null?{}:PO(FO(e)),BO(t||!e||!e.__esModule?p2(i,"default",{value:e,enumerable:!0}):i,e));typeof globalThis<"u"&&globalThis.GPUShaderStage===void 0&&(globalThis.GPUShaderStage={VERTEX:1,FRAGMENT:2,COMPUTE:4});var VO=class{constructor(){this.last=null,this.root=null,this.count=0,this.indexKey="index"}add(e){this.root?(this.last.next=e,e.prev=this.last,this.last=e):this.root=this.last=e,this.count++}remove(e){e.prev&&(e.prev.next=e.next),e.next&&(e.next.prev=e.prev),e===this.root&&(this.root=e.next),e===this.last&&(this.last=e.prev),e.next=e.prev=null,this.count--}insertSorted(e){this.count==0?this.add(e):this.insertInOrder(e)}insertInOrder(e){let t=this.root;for(;t;){if(e[this.indexKey]<=t[this.indexKey]){this.insertBefore(e,t);return}t=t.next}this.add(e)}insertWithPivot(e){if(!e[this.indexKey])throw Error("Node must have an 'index' property.");if(this.count==0){this.add(e);return}let t=this.root,i=this.last,r=this.count;for(;r>2;){let s=t,n=t;for(;n!==i&&n.next!==i;)s=s.next,n=n.next.next;let a=s;e[this.indexKey]<=a[this.indexKey]?(i=a,r=Math.floor(r/2)):(t=a,r-=Math.floor(r/2))}e[this.indexKey]<=t[this.indexKey]?this.insertBefore(e,t):e[this.indexKey]>=i[this.indexKey]?this.insertAfter(e,i):this.insertAfter(e,t)}insertAfter(e,t){if(e==t){console.warn("node == afterNode");return}let i=t.next;t.next=e,e.prev=t,i===null?this.last=e:(e.next=i,i.prev=e),this.count++}insertBefore(e,t){if(e==t){console.warn("node == beforeNode");return}let i=t.prev;t.prev=e,e.next=t,e.prev=i,i===null?this.root=e:i.next=e,this.count++}pop(){if(this.isEmpty())return null;let e=this.last;return this.remove(e),e}shift(){if(this.isEmpty())return null;let e=this.root;return this.remove(e),e}getNodeAtIdx(e){if(e>=this.count||e<0)return null;let t=this.root;for(let i=0;i<e&&t;i++)t=t.next;return t}toArray(){let e=[],t=this.root;for(;t;)e.push(t),t=t.next;return e}fromArray(e){this.reset();for(let t of e)t.prev=t.next=null,this.add(t)}reset(){this.last=this.root=null,this.count=0}isEmpty(){return this.count===0}log(){let e=`DoubleLinkedList[${this.count}] : `,t=this.root;for(;t;)e+=`${t[this.indexKey]},`,t=t.next;console.log(e)}},m2=class{constructor(e,t=0,i=!0){this.size=t,this.canExpand=i,this.createFunc=e,this.availableItems=[];for(let r=0;r<t;r++)this.availableItems.push(this.createFunc())}checkOut(){return this.size===0?(console.warn("The pool is empty."),this.canExpand?this.createFunc():null):(this.size--,this.availableItems.pop())}checkIn(e){this.size++,this.availableItems.push(e)}get(){return this.checkOut()}release(e){return this.checkIn(e)}dispose(){this.availableItems=[],this.size=0}},zO=class{constructor(){this.prev=null,this.next=null,this.listener=null}},je=class pg{static POOL=new m2(()=>new zO,512);constructor(){this.listeners=new VO,this.listenersOnce=[],this.listenerNodes=new WeakMap}add(t){this.listenerNodes.has(t)&&this.remove(t);let i=pg.POOL.get();i.listener=t,this.listenerNodes.set(t,i),this.listeners.add(i)}remove(t){let i=this.listenerNodes.get(t);i&&(this.listeners.remove(i),pg.POOL.release(i),this.listenerNodes.delete(t))}once(t){this.addOnce(t)}addOnce(t){this.listenersOnce.push(t)}
1dispatch(){let t=this.listenersOnce.length;if(t>0){for(let r=0;r<t;r++)this.listenersOnce[r].apply(null,arguments);this.listenersOnce=[]}let i=this.listeners.root;for(;i;)i.listener.apply(null,arguments),i=i.next}dispose(){let t=this.listeners.root;for(;t;){let i=t.next;this.listenerNodes.delete(t.listener),t.listener=null,pg.POOL.release(t),t=i}this.listeners=null,this.listenerNodes=null,this.listenersOnce=null}removeAll(){let t=this.listeners.root;for(;t;){let i=t.next;this.listenerNodes.delete(t.listener),t.listener=null,pg.POOL.release(t),t=i}this.listeners.reset(),this.listenersOnce=[]}clear(){this.removeAll()}},GO={"d-intel":"https://static5.mclcm.net/jsmap/benchmark-gpu/d-intel.json","d-nvidia":"https://static5.mclcm.net/jsmap/benchmark-gpu/d-nvidia.json","d-geforce":"https://static5.mclcm.net/jsmap/benchmark-gpu/d-geforce.json","d-amd":"https://static5.mclcm.net/jsmap/benchmark-gpu/d-amd.json","d-radeon":"https://static5.mclcm.net/jsmap/benchmark-gpu/d-radeon.json","d-adreno":"https://static5.mclcm.net/jsmap/benchmark-gpu/d-adreno.json","d-apple":"https://static5.mclcm.net/jsmap/benchmark-gpu/d-apple.json","m-adreno":"https://static5.mclcm.net/jsmap/benchmark-gpu/m-adreno.json","m-mali":"https://static5.mclcm.net/jsmap/benchmark-gpu/m-mali.json","m-mali-t":"https://static5.mclcm.net/jsmap/benchmark-gpu/m-mali-t.json","m-powervr":"https://static5.mclcm.net/jsmap/benchmark-gpu/m-powervr.json","m-nvidia":"https://static5.mclcm.net/jsmap/benchmark-gpu/m-nvidia.json","m-intel":"https://static5.mclcm.net/jsmap/benchmark-gpu/m-intel.json","m-apple":"https://static5.mclcm.net/jsmap/benchmark-gpu/m-apple.json","m-apple-ipad":"https://static5.mclcm.net/jsmap/benchmark-gpu/m-apple-ipad.json","m-samsung":"https://static5.mclcm.net/jsmap/benchmark-gpu/m-samsung.json"},g2="mapjs-gpu-tier-cache",jO=10080*60*1e3,Fo={},z1={},f2=async e=>{try{if(z1[e])return z1[e];let t=GO[e];if(!t)return null;let i=await fetch(t,{cache:"force-cache"});if(!i.ok)throw Error(`Failed to fetch ${t}: ${i.status}`);let r=await i.json();return z1[e]=r,r}catch(t){return console.warn("Failed to fetch benchmark data:",e,t),null}},$O=e=>{if(console.log(e),!e)return"d-intel";let t=e.toLowerCase();return t.includes("adreno")?"m-adreno":t.includes("mali-t")?"m-mali-t":t.includes("mali")?"m-mali":t.includes("powervr")?"m-powervr":t.includes("apple")&&t.includes("ipad")?"m-apple-ipad":t.includes("apple")&&(t.includes("mobile")||t.includes("iphone"))?"m-apple":t.includes("samsung")?"m-samsung":t.includes("geforce")?"d-geforce":t.includes("nvidia")?"d-nvidia":t.includes("radeon")?"d-radeon":t.includes("amd")?"d-amd":t.includes("intel")?"d-intel":t.includes("apple")?"d-apple":"d-intel"},WO=(e,t,i)=>{try{let r=e.toLowerCase();for(let s=1;s<t.length;s++){let n=t[s];if(n&&n.length>=4){let a=n[0].toLowerCase(),o=n[1].toLowerCase();if(a.includes(r)||o.includes(r)){let l=n[2],h=n[3]||[],u=30,d=window.screen.width||1920,c=window.screen.height||1080;for(let p of h)if(p.length>=3){let[m,g,f]=p;Math.abs(m-d)+Math.abs(g-c)<1e3&&(u=Math.max(u,f))}return{tier:l,isMobile:i,type:"LOCAL_BENCHMARK",fps:u,gpu:e}}}}return{tier:+!i,isMobile:i,type:"LOCAL_DEFAULT",fps:30,gpu:e}}catch(r){return console.warn("Error calculating performance tier:",r),{tier:+!i,isMobile:i,type:"LOCAL_ERROR",fps:30,gpu:e}}},HO=async e=>{try{let t=await f2($O(e));if(t)return t;let i=await f2("d-intel");if(i)return i}catch(t){console.warn("Failed to get local benchmark, falling back to default:",t)}return["5",["default","default",0,[[1920,1080,30]]]]},qO=async()=>{let e=performance.now();try{let t=localStorage.getItem(g2);if(t){let{tier:i,timestamp:r}=JSON.parse(t);if(Date.now()-r<jO){Fo=i;return}}}catch(t){console.warn("[Performance] Failed to read GPU cache:",t)}try{let t=document.createElement("canvas"),i=t.getContext("webgl")||t.getContext("experimental-webgl");if(!i){Fo={tier:0,isMobile:!1,type:"DEFAULT",fps:30,gpu:"unknown"};return}let r=i.getExtension("WEBGL_debug_renderer_info"),s=r?i.getParameter(r.UNMASKED_RENDERER_WEBGL):"unknown",n=/Android|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);Fo=WO(s,await HO(s),n);try{localStorage.setItem(g2,JSON.stringify({tier:Fo,timestamp:Date.now()})),console.log("[MapJS] GPU tier cached for future use")}catch(o){console.warn("[MapJS] Failed to cache GPU tier:",o)}let a=performance.now()-e;console.log(`[MapJS] GPU tier detection completed in ${a.toFixed(2)}ms`,Fo)}catch(t){console.warn("Performance test failed, using default tier:",t);let i=/Android|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);Fo={tier:+!i,isMobile:i,type:"FALLBACK",fps:30,gpu:"unknown"}}},y2=()=>Fo.isMobile==1?5:Fo.tier,G1=navigator.userAgent||navigator.vendor||window.opera,XO=/windows phone/i.test(G1),YO=/android/i.test(G1),KO=(/iPad|iPhone|iPod/.test(G1)||navigator.platform==="MacIntel"&&navigator.maxTouchPoints>1)&&!window.MSStream;navigator.platform.toUpperCase().indexOf("MAC");var Fs=XO||YO||KO;window.opr&&window.opr.addons||window.opera||navigator.userAgent.indexOf(" OPR/"),navigator.userAgent.toLowerCase().includes("firefox"),/constructor/i.test(window.HTMLElement)||(function(e){return e.toString()==="[object SafariRemoteNotification]"})(!window.safari||window.safari!==void 0&&window.safari.pushNotification),document.documentMode,/Edg/.test(navigator.userAgent),window.chrome&&(window.chrome.webstore||window.chrome.runtime),navigator.brave;var Pu=window.location.href.indexOf("localhost")>=0||window.location.href.indexOf("192.168.")>=0,N=new class{constructor(){this.pause=!1,this.lastTime=performance.now(),this.lastUpdateTime=performance.now(),this.width=-1,this.height=-1,this.ratioX=1,this.ratioY=1,this.onResize=new je,this.onUpdate=new je,this.onAfterUpdate=new je,this.refreshPerformanceProfile(!1),this.resize(window.innerWidth,window.innerHeight),requestAnimationFrame(this.update)}getPerformanceProfile=()=>{let e=y2(),t=Number.isFinite(e),i=t?e<=2?120:60:Fs?60:120,r=t?e<=2?2:1:Fs?1:2;return{targetFPS:i,devicePixelRatio:window.location.search.includes("ratio1")?1:Math.min(r,window.devicePixelRatio||1)}};refreshPerformanceProfile=(e=!0)=>{let{targetFPS:t,devicePixelRatio:i}=this.getPerformanceProfile(),r=this.targetFPS!==t||this.devicePixelRatio!==i;return this.targetFPS=t,this.devicePixelRatio=this.pixelRatio=i,e&&r&&this.onResize.dispatch(),r};resize=(e=-1,t=-1,i)=>{e!=-1&&(this.ratioX=e/window.innerWidth),t!=-1&&(this.ratioY=t/window.innerHeight);let r=Math.floor(window.innerWidth*this.ratioX),s=Math.floor(window.innerHeight*this.ratioY);this.documentHeight=document.documentElement.clientHeight,this.width=r,this.height=s,this.onResize.dispatch()};update=()=>{let e=performance.now();if(e-this.lastTime,this.lastTime=e,this.disposed||requestAnimationFrame(this.update),this.pause)return;let t=1e3/this.targetFPS;if(e-this.lastUpdateTime<t)return;let i=e-this.lastUpdateTime;this.lastUpdateTime=e,this.onUpdate.dispatch(i),this.onAfterUpdate.dispatch(i)};dispose(){this.disposed=!0,this.pause=!0,this.onResize.removeAll(),this.onUpdate.removeAll(),this.onAfterUpdate.removeAll()}},lh="184dev",Or=1e3,Fa=1001,vg=1002,lr=1003,ZO=1004,JO=1005,mi=1006,QO=1007,bg=1008,eB=1008,hr=1009,Nc=1010,Lc=1011,ku=1012,Do=1013,ur=1014,Pn=1015,as=1016,tB=1017,iB=1018,hh=1020,x2=35902,v2=35899,rB=1021,j1=1022,Br=1023,Da=1026,uh=1027,_g=1028,$1=1029,Oo=1030,W1=1031,sB=1032,H1=1033,b2=33776,_2=33777,T2=33778,w2=33779,nB=35840,aB=35841,oB=35842,lB=35843,S2=36196,M2=37492,C2=37496,R2=37488,E2=37489,A2=37490,N2=37491,L2=37808,P2=37809,k2=37810,I2=37811,F2=37812,D2=37813,O2=37814,B2=37815,U2=37816,V2=37817,z2=37818,G2=37819,j2=37820,$2=37821,W2=36492,hB=36494,uB=36495,H2=36283,q2=36284,X2=36285,Y2=36286,Tg=2300,q1=2301,X1=2302,K2=2303,Z2=2400,J2=2401,Q2=2402,Gi="srgb",Pc="srgb-linear",wg="linear",dB="srgb",Sg=7680,cB=7681,pB=7682,mB=7683,gB=34055,fB=34056,yB=5386,dh=35044,an=35048,xB=35040,ch=2e3,eM=2001,Ur={COMPUTE:"compute",RENDER:"render"},ph={TEXTURE_COMPARE:"depthTextureCompare"};function vB(e){for(let t=e.length-1;t>=0;--t)if(e[t]>=65535)return!0;return!1}function kc(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function Mg(e){return document.createElementNS("http://www.w3.org/1999/xhtml",e)}function bB(){let e=Mg("canvas");return e.style.display="block",e}var tM={},mh=null;function _B(e){mh=e}function Y1(...e){let t="THREE."+e.shift();mh?mh("log",t,...e):console.log(t,...e)}function iM(e){let t=e[0];if(typeof t=="string"&&t.startsWith("TSL:")){let i=e[1];i&&i.isStackTrace?e[0]+=" "+i.getLocation():e[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return e}function de(...e){e=iM(e);let t="THREE."+e.shift();if(mh)mh("warn",t,...e);else{let i=e[0];i&&i.isStackTrace?console.warn(i.getError(t)):console.warn(t,...e)}}function re(...e){e=iM(e);let t="THREE."+e.shift();if(mh)mh("error",t,...e);else{let i=e[0];i&&i.isStackTrace?console.error(i.getError(t)):console.error(t,...e)}}function ut(...e){let t=e.join(" ");t in tM||(tM[t]=!0,de(...e))}function rM(){return typeof self<"u"&&self.scheduler!==void 0&&self.scheduler.yield!==void 0?self.scheduler.yield():new Promise(e=>{requestAnimationFrame(e)})}
vendor: 4,545 bytes, line 1
1var sM={0:1,2:6,4:7,3:5,1:0,6:2,7:4,5:3},Ds=class{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});let i=this._listeners;i[e]===void 0&&(i[e]=[]),i[e].indexOf(t)===-1&&i[e].push(t)}hasEventListener(e,t){let i=this._listeners;return i===void 0?!1:i[e]!==void 0&&i[e].indexOf(t)!==-1}removeEventListener(e,t){let i=this._listeners;if(i===void 0)return;let r=i[e];if(r!==void 0){let s=r.indexOf(t);s!==-1&&r.splice(s,1)}}dispatchEvent(e){let t=this._listeners;if(t===void 0)return;let i=t[e.type];if(i!==void 0){e.target=this;let r=i.slice(0);for(let s=0,n=r.length;s<n;s++)r[s].call(this,e);e.target=null}}},_r="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".split("."),nM=1234567,Ic=Math.PI/180,Iu=180/Math.PI;function kn(){let e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,i=Math.random()*4294967295|0,r=Math.random()*4294967295|0;return(_r[e&255]+_r[e>>8&255]+_r[e>>16&255]+_r[e>>24&255]+"-"+_r[t&255]+_r[t>>8&255]+"-"+_r[t>>16&15|64]+_r[t>>24&255]+"-"+_r[i&63|128]+_r[i>>8&255]+"-"+_r[i>>16&255]+_r[i>>24&255]+_r[r&255]+_r[r>>8&255]+_r[r>>16&255]+_r[r>>24&255]).toLowerCase()}function He(e,t,i){return Math.max(t,Math.min(i,e))}function K1(e,t){return(e%t+t)%t}function TB(e,t,i,r,s){return r+(e-t)*(s-r)/(i-t)}function wB(e,t,i){return e===t?0:(i-e)/(t-e)}function Fc(e,t,i){return(1-i)*e+i*t}function SB(e,t,i,r){return Fc(e,t,1-Math.exp(-i*r))}function MB(e,t=1){return t-Math.abs(K1(e,t*2)-t)}function CB(e,t,i){return e<=t?0:e>=i?1:(e=(e-t)/(i-t),e*e*(3-2*e))}function RB(e,t,i){return e<=t?0:e>=i?1:(e=(e-t)/(i-t),e*e*e*(e*(e*6-15)+10))}function EB(e,t){return e+Math.floor(Math.random()*(t-e+1))}function AB(e,t){return e+Math.random()*(t-e)}function NB(e){return e*(.5-Math.random())}function LB(e){e!==void 0&&(nM=e);let t=nM+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}function PB(e){return e*Ic}function kB(e){return e*Iu}function IB(e){return(e&e-1)==0&&e!==0}function FB(e){return 2**Math.ceil(Math.log(e)/Math.LN2)}function DB(e){return 2**Math.floor(Math.log(e)/Math.LN2)}function OB(e,t,i,r,s){let n=Math.cos,a=Math.sin,o=n(i/2),l=a(i/2),h=n((t+r)/2),u=a((t+r)/2),d=n((t-r)/2),c=a((t-r)/2),p=n((r-t)/2),m=a((r-t)/2);switch(s){case"XYX":e.set(o*u,l*d,l*c,o*h);break;case"YZY":e.set(l*c,o*u,l*d,o*h);break;case"ZXZ":e.set(l*d,l*c,o*u,o*h);break;case"XZX":e.set(o*u,l*m,l*p,o*h);break;case"YXY":e.set(l*p,o*u,l*m,o*h);break;case"ZYZ":e.set(l*m,l*p,o*u,o*h);break;default:de("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+s)}}function Vr(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return e/4294967295;case Uint16Array:return e/65535;case Uint8Array:return e/255;case Int32Array:return Math.max(e/2147483647,-1);case Int16Array:return Math.max(e/32767,-1);case Int8Array:return Math.max(e/127,-1);default:throw Error("Invalid component type.")}}function Ve(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return Math.round(e*4294967295);case Uint16Array:return Math.round(e*65535);case Uint8Array:return Math.round(e*255);case Int32Array:return Math.round(e*2147483647);case Int16Array:return Math.round(e*32767);case Int8Array:return Math.round(e*127);default:throw Error("Invalid component type.")}}var aM={DEG2RAD:Ic,RAD2DEG:Iu,generateUUID:kn,clamp:He,euclideanModulo:K1,mapLinear:TB,inverseLerp:wB,lerp:Fc,damp:SB,pingpong:MB,smoothstep:CB,smootherstep:RB,randInt:EB,randFloat:AB,randFloatSpread:NB,seededRandom:LB,degToRad:PB,radToDeg:kB,isPowerOfTwo:IB,ceilPowerOfTwo:FB,floorPowerOfTwo:DB,setQuaternionFromProperEuler:OB,normalize:Ve,denormalize:Vr},ge=class HD{static{HD.prototype.isVector2=!0}constructor(t=0,i=0){this.x=t,this.y=i}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}
vendor: 5,702 bytes, line 1
1set(t,i){return this.x=t,this.y=i,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,i){switch(t){case 0:this.x=i;break;case 1:this.y=i;break;default:throw Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,i){return this.x=t.x+i.x,this.y=t.y+i.y,this}addScaledVector(t,i){return this.x+=t.x*i,this.y+=t.y*i,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,i){return this.x=t.x-i.x,this.y=t.y-i.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){let i=this.x,r=this.y,s=t.elements;return this.x=s[0]*i+s[3]*r+s[6],this.y=s[1]*i+s[4]*r+s[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,i){return this.x=He(this.x,t.x,i.x),this.y=He(this.y,t.y,i.y),this}clampScalar(t,i){return this.x=He(this.x,t,i),this.y=He(this.y,t,i),this}clampLength(t,i){let r=this.length();return this.divideScalar(r||1).multiplyScalar(He(r,t,i))}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(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.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(t){let i=Math.sqrt(this.lengthSq()*t.lengthSq());if(i===0)return Math.PI/2;let r=this.dot(t)/i;return Math.acos(He(r,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){let i=this.x-t.x,r=this.y-t.y;return i*i+r*r}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,i){return this.x+=(t.x-this.x)*i,this.y+=(t.y-this.y)*i,this}lerpVectors(t,i,r){return this.x=t.x+(i.x-t.x)*r,this.y=t.y+(i.y-t.y)*r,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,i=0){return this.x=t[i],this.y=t[i+1],this}toArray(t=[],i=0){return t[i]=this.x,t[i+1]=this.y,t}fromBufferAttribute(t,i){return this.x=t.getX(i),this.y=t.getY(i),this}rotateAround(t,i){let r=Math.cos(i),s=Math.sin(i),n=this.x-t.x,a=this.y-t.y;return this.x=n*r-a*s+t.x,this.y=n*s+a*r+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},Bo=class{constructor(e=0,t=0,i=0,r=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=i,this._w=r}static slerpFlat(e,t,i,r,s,n,a){let o=i[r+0],l=i[r+1],h=i[r+2],u=i[r+3],d=s[n+0],c=s[n+1],p=s[n+2],m=s[n+3];if(u!==m||o!==d||l!==c||h!==p){let g=o*d+l*c+h*p+u*m;g<0&&(d=-d,c=-c,p=-p,m=-m,g=-g);let f=1-a;if(g<.9995){let y=Math.acos(g),x=Math.sin(y);f=Math.sin(f*y)/x,a=Math.sin(a*y)/x,o=o*f+d*a,l=l*f+c*a,h=h*f+p*a,u=u*f+m*a}else{o=o*f+d*a,l=l*f+c*a,h=h*f+p*a,u=u*f+m*a;let y=1/Math.sqrt(o*o+l*l+h*h+u*u);o*=y,l*=y,h*=y,u*=y}}e[t]=o,e[t+1]=l,e[t+2]=h,e[t+3]=u}static multiplyQuaternionsFlat(e,t,i,r,s,n){let a=i[r],o=i[r+1],l=i[r+2],h=i[r+3],u=s[n],d=s[n+1],c=s[n+2],p=s[n+3];return e[t]=a*p+h*u+o*c-l*d,e[t+1]=o*p+h*d+l*u-a*c,e[t+2]=l*p+h*c+a*d-o*u,e[t+3]=h*p-a*u-o*d-l*c,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,i,r){return this._x=e,this._y=t,this._z=i,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 i=e._x,r=e._y,s=e._z,n=e._order,a=Math.cos,o=Math.sin,l=a(i/2),h=a(r/2),u=a(s/2),d=o(i/2),c=o(r/2),p=o(s/2);switch(n){case"XYZ":this._x=d*h*u+l*c*p,this._y=l*c*u-d*h*p,this._z=l*h*p+d*c*u,this._w=l*h*u-d*c*p;break;case"YXZ":this._x=d*h*u+l*c*p,this._y=l*c*u-d*h*p,this._z=l*h*p-d*c*u,this._w=l*h*u+d*c*p;break;case"ZXY":this._x=d*h*u-l*c*p,this._y=l*c*u+d*h*p,this._z=l*h*p+d*c*u,this._w=l*h*u-d*c*p;break;case"ZYX":this._x=d*h*u-l*c*p,this._y=l*c*u+d*h*p,this._z=l*h*p-d*c*u,this._w=l*h*u+d*c*p;break;case"YZX":this._x=d*h*u+l*c*p,this._y=l*c*u+d*h*p,this._z=l*h*p-d*c*u,this._w=l*h*u-d*c*p;break;case"XZY":this._x=d*h*u-l*c*p,this._y=l*c*u-d*h*p,this._z=l*h*p+d*c*u,this._w=l*h*u+d*c*p;break;default:de("Quaternion: .setFromEuler() encountered an unknown order: "+n)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){let i=t/2,r=Math.sin(i);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(e){let t=e.elements,i=t[0],r=t[4],s=t[8],n=t[1],a=t[5],o=t[9],l=t[2],h=t[6],u=t[10],d=i+a+u;if(d>0){let c=.5/Math.sqrt(d+1);this._w=.25/c,this._x=(h-o)*c,this._y=(s-l)*c,this._z=(n-r)*c}else if(i>
vendor: 17,058 bytes, line 1
1a&&i>u){let c=2*Math.sqrt(1+i-a-u);this._w=(h-o)/c,this._x=.25*c,this._y=(r+n)/c,this._z=(s+l)/c}else if(a>u){let c=2*Math.sqrt(1+a-i-u);this._w=(s-l)/c,this._x=(r+n)/c,this._y=.25*c,this._z=(o+h)/c}else{let c=2*Math.sqrt(1+u-i-a);this._w=(n-r)/c,this._x=(s+l)/c,this._y=(o+h)/c,this._z=.25*c}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let i=e.dot(t)+1;return i<1e-8?(i=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=i):(this._x=0,this._y=-e.z,this._z=e.y,this._w=i)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=i),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(He(this.dot(e),-1,1)))}rotateTowards(e,t){let i=this.angleTo(e);if(i===0)return this;let r=Math.min(1,t/i);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*=e,this._y*=e,this._z*=e,this._w*=e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){let i=e._x,r=e._y,s=e._z,n=e._w,a=t._x,o=t._y,l=t._z,h=t._w;return this._x=i*h+n*a+r*l-s*o,this._y=r*h+n*o+s*a-i*l,this._z=s*h+n*l+i*o-r*a,this._w=n*h-i*a-r*o-s*l,this._onChangeCallback(),this}slerp(e,t){let i=e._x,r=e._y,s=e._z,n=e._w,a=this.dot(e);a<0&&(i=-i,r=-r,s=-s,n=-n,a=-a);let o=1-t;if(a<.9995){let l=Math.acos(a),h=Math.sin(l);o=Math.sin(o*l)/h,t=Math.sin(t*l)/h,this._x=this._x*o+i*t,this._y=this._y*o+r*t,this._z=this._z*o+s*t,this._w=this._w*o+n*t,this._onChangeCallback()}else this._x=this._x*o+i*t,this._y=this._y*o+r*t,this._z=this._z*o+s*t,this._w=this._w*o+n*t,this.normalize();return this}slerpQuaternions(e,t,i){return this.copy(e).slerp(t,i)}random(){let e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),i=Math.random(),r=Math.sqrt(1-i),s=Math.sqrt(i);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}},F=class qD{static{qD.prototype.isVector3=!0}constructor(t=0,i=0,r=0){this.x=t,this.y=i,this.z=r}set(t,i,r){return r===void 0&&(r=this.z),this.x=t,this.y=i,this.z=r,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,i){switch(t){case 0:this.x=i;break;case 1:this.y=i;break;case 2:this.z=i;break;default:throw Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,i){return this.x=t.x+i.x,this.y=t.y+i.y,this.z=t.z+i.z,this}addScaledVector(t,i){return this.x+=t.x*i,this.y+=t.y*i,this.z+=t.z*i,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,i){return this.x=t.x-i.x,this.y=t.y-i.y,this.z=t.z-i.z,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,i){return this.x=t.x*i.x,this.y=t.y*i.y,this.z=t.z*i.z,this}applyEuler(t){return this.applyQuaternion(oM.setFromEuler(t))}applyAxisAngle(t,i){return this.applyQuaternion(oM.setFromAxisAngle(t,i))}applyMatrix3(t){let i=this.x,r=this.y,s=this.z,n=t.elements;return this.x=n[0]*i+n[3]*r+n[6]*s,this.y=n[1]*i+n[4]*r+n[7]*s,this.z=n[2]*i+n[5]*r+n[8]*s,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){let i=this.x,r=this.y,s=this.z,n=t.elements,a=1/(n[3]*i+n[7]*r+n[11]*s+n[15]);return this.x=(n[0]*i+n[4]*r+n[8]*s+n[12])*a,this.y=(n[1]*i+n[5]*r+n[9]*s+n[13])*a,this.z=(n[2]*i+n[6]*r+n[10]*s+n[14])*a,this}applyQuaternion(t){let i=this.x,r=this.y,s=this.z,n=t.x,a=t.y,o=t.z,l=t.w,h=2*(a*s-o*r),u=2*(o*i-n*s),d=2*(n*r-a*i);return this.x=i+l*h+a*d-o*u,this.y=r+l*u+o*h-n*d,this.z=s+l*d+n*u-a*h,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){let i=this.x,r=this.y,s=this.z,n=t.elements;return this.x=n[0]*i+n[4]*r+n[8]*s,this.y=n[1]*i+n[5]*r+n[9]*s,this.z=n[2]*i+n[6]*r+n[10]*s,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,i){return this.x=He(this.x,t.x,i.x),this.y=He(this.y,t.y,i.y),this.z=He(this.z,t.z,i.z),this}clampScalar(t,i){return this.x=He(this.x,t,i),this.y=He(this.y,t,i),this.z=He(this.z,t,i),this}clampLength(t,i){let r=this.length();return this.divideScalar(r||1).multiplyScalar(He(r,t,i))}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(t){return this.x*t.x+this.y*t.y+this.z*t.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(t){return this.normalize().multiplyScalar(t)}lerp(t,i){return this.x+=(t.x-this.x)*i,this.y+=(t.y-this.y)*i,this.z+=(t.z-this.z)*i,this}lerpVectors(t,i,r){return this.x=t.x+(i.x-t.x)*r,this.y=t.y+(i.y-t.y)*r,this.z=t.z+(i.z-t.z)*r,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,i){let r=t.x,s=t.y,n=t.z,a=i.x,o=i.y,l=i.z;return this.x=s*l-n*o,this.y=n*a-r*l,this.z=r*o-s*a,this}projectOnVector(t){let i=t.lengthSq();if(i===0)return this.set(0,0,0);let r=t.dot(this)/i;return this.copy(t).multiplyScalar(r)}projectOnPlane(t){return Z1.copy(this).projectOnVector(t),this.sub(Z1)}reflect(t){return this.sub(Z1.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){let i=Math.sqrt(this.lengthSq()*t.lengthSq());if(i===0)return Math.PI/2;let r=this.dot(t)/i;return Math.acos(He(r,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){let i=this.x-t.x,r=this.y-t.y,s=this.z-t.z;return i*i+r*r+s*s}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSpherical(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)}setFromSphericalCoords(t,i,r){let s=Math.sin(i)*t;return this.x=s*Math.sin(r),this.y=Math.cos(i)*t,this.z=s*Math.cos(r),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,i,r){return this.x=t*Math.sin(i),this.y=r,this.z=t*Math.cos(i),this}setFromMatrixPosition(t){let i=t.elements;return this.x=i[12],this.y=i[13],this.z=i[14],this}setFromMatrixScale(t){let i=this.setFromMatrixColumn(t,0).length(),r=this.setFromMatrixColumn(t,1).length(),s=this.setFromMatrixColumn(t,2).length();return this.x=i,this.y=r,this.z=s,this}setFromMatrixColumn(t,i){return this.fromArray(t.elements,i*4)}setFromMatrix3Column(t,i){return this.fromArray(t.elements,i*3)}setFromEuler(t){return this.x=t._x,this.y=t._y,this.z=t._z,this}setFromColor(t){return this.x=t.r,this.y=t.g,this.z=t.b,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,i=0){return this.x=t[i],this.y=t[i+1],this.z=t[i+2],this}toArray(t=[],i=0){return t[i]=this.x,t[i+1]=this.y,t[i+2]=this.z,t}fromBufferAttribute(t,i){return this.x=t.getX(i),this.y=t.getY(i),this.z=t.getZ(i),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let t=Math.random()*Math.PI*2,i=Math.random()*2-1,r=Math.sqrt(1-i*i);return this.x=r*Math.cos(t),this.y=i,this.z=r*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}},Z1=new F,oM=new Bo,Os=class XD{static{XD.prototype.isMatrix3=!0}constructor(t,i,r,s,n,a,o,l,h){this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0&&this.set(t,i,r,s,n,a,o,l,h)}set(t,i,r,s,n,a,o,l,h){let u=this.elements;return u[0]=t,u[1]=s,u[2]=o,u[3]=i,u[4]=n,u[5]=l,u[6]=r,u[7]=a,u[8]=h,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){let i=this.elements,r=t.elements;return i[0]=r[0],i[1]=r[1],i[2]=r[2],i[3]=r[3],i[4]=r[4],i[5]=r[5],i[6]=r[6],i[7]=r[7],i[8]=r[8],this}extractBasis(t,i,r){return t.setFromMatrix3Column(this,0),i.setFromMatrix3Column(this,1),r.setFromMatrix3Column(this,2),this}setFromMatrix4(t){let i=t.elements;return this.set(i[0],i[4],i[8],i[1],i[5],i[9],i[2],i[6],i[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,i){let r=t.elements,s=i.elements,n=this.elements,a=r[0],o=r[3],l=r[6],h=r[1],u=r[4],d=r[7],c=r[2],p=r[5],m=r[8],g=s[0],f=s[3],y=s[6],x=s[1],b=s[4],_=s[7],T=s[2],w=s[5],M=s[8];return n[0]=a*g+o*x+l*T,n[3]=a*f+o*b+l*w,n[6]=a*y+o*_+l*M,n[1]=h*g+u*x+d*T,n[4]=h*f+u*b+d*w,n[7]=h*y+u*_+d*M,n[2]=c*g+p*x+m*T,n[5]=c*f+p*b+m*w,n[8]=c*y+p*_+m*M,this}multiplyScalar(t){let i=this.elements;return i[0]*=t,i[3]*=t,i[6]*=t,i[1]*=t,i[4]*=t,i[7]*=t,i[2]*=t,i[5]*=t,i[8]*=t,this}determinant(){let t=this.elements,i=t[0],r=t[1],s=t[2],n=t[3],a=t[4],o=t[5],l=t[6],h=t[7],u=t[8];return i*a*u-i*o*h-r*n*u+r*o*l+s*n*h-s*a*l}invert(){let t=this.elements,i=t[0],r=t[1],s=t[2],n=t[3],a=t[4],o=t[5],l=t[6],h=t[7],u=t[8],d=u*a-o*h,c=o*l-u*n,p=h*n-a*l,m=i*d+r*c+s*p;if(m===0)return this.set(0,0,0,0,0,0,0,0,0);let g=1/m;return t[0]=d*g,t[1]=(s*h-u*r)*g,t[2]=(o*r-s*a)*g,t[3]=c*g,t[4]=(u*i-s*l)*g,t[5]=(s*n-o*i)*g,t[6]=p*g,t[7]=(r*l-h*i)*g,t[8]=(a*i-r*n)*g,this}transpose(){let t,i=this.elements;return t=i[1],i[1]=i[3],i[3]=t,t=i[2],i[2]=i[6],i[6]=t,t=i[5],i[5]=i[7],i[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){let i=this.elements;return t[0]=i[0],t[1]=i[3],t[2]=i[6],t[3]=i[1],t[4]=i[4],t[5]=i[7],t[6]=i[2],t[7]=i[5],t[8]=i[8],this}setUvTransform(t,i,r,s,n,a,o){let l=Math.cos(n),h=Math.sin(n);return this.set(r*l,r*h,-r*(l*a+h*o)+a+t,-s*h,s*l,-s*(-h*a+l*o)+o+i,0,0,1),this}scale(t,i){return this.premultiply(J1.makeScale(t,i)),this}rotate(t){return this.premultiply(J1.makeRotation(-t)),this}translate(t,i){return this.premultiply(J1.makeTranslation(t,i)),this}makeTranslation(t,i){return t.isVector2?this.set(1,0,t.x,0,1,t.y,0,0,1):this.set(1,0,t,0,1,i,0,0,1),this}makeRotation(t){let i=Math.cos(t),r=Math.sin(t);return this.set(i,-r,0,r,i,0,0,0,1),this}makeScale(t,i){return this.set(t,0,0,0,i,0,0,0,1),this}equals(t){let i=this.elements,r=t.elements;for(let s=0;s<9;s++)if(i[s]!==r[s])return!1;return!0}fromArray(t,i=0){for(let r=0;r<9;r++)this.elements[r]=t[r+i];return this}toArray(t=[],i=0){let r=this.elements;return t[i]=r[0],t[i+1]=r[1],t[i+2]=r[2],t[i+3]=r[3],t[i+4]=r[4],t[i+5]=r[5],t[i+6]=r[6],t[i+7]=r[7],t[i+8]=r[8],t}clone(){return new this.constructor().fromArray(this.elements)}},J1=new Os,lM=new Os().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),hM=new Os().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function BB(){let e={enabled:!0,workingColorSpace:Pc,spaces:{},convert:function(s,n,a){return this.enabled===!1||n===a||!n||!a||(this.spaces[n].transfer==="srgb"&&(s.r=Oa(s.r),s.g=Oa(s.g),s.b=Oa(s.b)),this.spaces[n].primaries!==this.spaces[a].primaries&&(s.applyMatrix3(this.spaces[n].toXYZ),s.applyMatrix3(this.spaces[a].fromXYZ)),this.spaces[a].transfer==="srgb"&&(s.r=Fu(s.r),s.g=Fu(s.g),s.b=Fu(s.b))),s},workingToColorSpace:function(s,n){return this.convert(s,this.workingColorSpace,n)},colorSpaceToWorking:function(s,n){return this.convert(s,n,this.workingColorSpace)},getPrimaries:function(s){return this.spaces[s].primaries},getTransfer:function(s){return s===""?wg:this.spaces[s].transfer},getToneMappingMode:function(s){return this.spaces[s].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(s,n=this.workingColorSpace){return s.fromArray(this.spaces[n].luminanceCoefficients)},define:function(s){Object.assign(this.spaces,s)},_getMatrix:function(s,n,a){return s.copy(this.spaces[n].toXYZ).multiply(this.spaces[a].fromXYZ)},_getDrawingBufferColorSpace:function(s){return this.spaces[s].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(s=this.workingColorSpace){return this.spaces[s].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(s,n){return ut("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),e.workingToColorSpace(s,n)},toWorkingColorSpace:function(s,n){return ut("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),e.colorSpaceToWorking(s,n)}},t=[.64,.33,.3,.6,.15,.06],i=[.2126,.7152,.0722],r=[.3127,.329];return e.define({[Pc]:{primaries:t,whitePoint:r,transfer:wg,toXYZ:lM,fromXYZ:hM,luminanceCoefficients:i,workingColorSpaceConfig:{unpackColorSpace:Gi},outputColorSpaceConfig:{drawingBufferColorSpace:Gi}},[Gi]:{primaries:t,whitePoint:r,transfer:dB,toXYZ:lM,fromXYZ:hM,luminanceCoefficients:i,outputColorSpaceConfig:{drawingBufferColorSpace:Gi}}}),e}var lt=BB();function Oa(e){return e<.04045?e*.0773993808:(e*.9478672986+.0521327014)**2.4}function Fu(e){return e<.0031308?e*12.92:1.055*e**.41666-.055}var Du,UB=class{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let i;if(e instanceof HTMLCanvasElement)i=e;else{Du===void 0&&(Du=Mg("canvas")),Du.width=e.width,Du.height=e.height;let r=Du.getContext("2d");e instanceof ImageData?r.putImageData(e,0,0):r.drawImage(e,0,0,e.width,e.height),i=Du}return i.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){let t=Mg("canvas");t.width=e.width,t.height=e.height;let i=t.getContext("2d");i.drawImage(e,0,0,e.width,e.height);let r=i.getImageData(0,0,e.width,e.height),s=r.data;for(let n=0;n<s.length;n++)s[n]=Oa(s[n]/255)*255;return i.putImageData(r,0,0),t}else if(e.data){let t=e.data.slice(0);for(let i=0;i<t.length;i++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[i]=Math.floor(Oa(t[i]/255)*255):t[i]=Oa(t[i]);return{data:t,width:e.width,height:e.height}}else return de("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}},VB=0,Q1=class{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:VB++}),this.uuid=kn(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){let t=this.data;return typeof HTMLVideoElement<"u"&&t instanceof HTMLVideoElement?e.set(t.videoWidth,t.videoHeight,0):typeof VideoFrame<"u"&&t instanceof VideoFrame?e.set(t.displayWidth,t.displayHeight,0):t===null?e.set(0,0,0):e.set(t.width,t.height,t.depth||0),e}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 i={uuid:this.uuid,url:""},r=this.data;if(r!==null){let s;if(Array.isArray(r)){s=[];for(let n=0,a=r.length;n<a;n++)r[n].isDataTexture?s.push(ex(r[n].image)):s.push(ex(r[n]))}else s=ex(r);i.url=s}return t||(e.images[this.uuid]=i),i}};function ex(e){return typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap?UB.getDataURL(e):e.data?{data:Array.from(e.data),width:e.width,height:e.height,type:e.data.constructor.name}:(de("Texture: Unable to serialize Texture."),{})}
1var zB=0,tx=new F,Li=class D1 extends Ds{constructor(t=D1.DEFAULT_IMAGE,i=D1.DEFAULT_MAPPING,r=Fa,s=Fa,n=mi,a=bg,o=Br,l=hr,h=D1.DEFAULT_ANISOTROPY,u=""){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:zB++}),this.uuid=kn(),this.name="",this.source=new Q1(t),this.mipmaps=[],this.mapping=i,this.channel=0,this.wrapS=r,this.wrapT=s,this.magFilter=n,this.minFilter=a,this.anisotropy=h,this.format=o,this.internalFormat=null,this.type=l,this.offset=new ge(0,0),this.repeat=new ge(1,1),this.center=new ge(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Os,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=u,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(t&&t.depth&&t.depth>1),this.pmremVersion=0}get width(){return this.source.getSize(tx).x}get height(){return this.source.getSize(tx).y}get depth(){return this.source.getSize(tx).z}get image(){return this.source.data}set image(t){this.source.data=t}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(t,i){this.updateRanges.push({start:t,count:i})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(t){return this.name=t.name,this.source=t.source,this.mipmaps=t.mipmaps.slice(0),this.mapping=t.mapping,this.channel=t.channel,this.wrapS=t.wrapS,this.wrapT=t.wrapT,this.magFilter=t.magFilter,this.minFilter=t.minFilter,this.anisotropy=t.anisotropy,this.format=t.format,this.internalFormat=t.internalFormat,this.type=t.type,this.offset.copy(t.offset),this.repeat.copy(t.repeat),this.center.copy(t.center),this.rotation=t.rotation,this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrix.copy(t.matrix),this.generateMipmaps=t.generateMipmaps,this.premultiplyAlpha=t.premultiplyAlpha,this.flipY=t.flipY,this.unpackAlignment=t.unpackAlignment,this.colorSpace=t.colorSpace,this.renderTarget=t.renderTarget,this.isRenderTargetTexture=t.isRenderTargetTexture,this.isArrayTexture=t.isArrayTexture,this.userData=JSON.parse(JSON.stringify(t.userData)),this.needsUpdate=!0,this}setValues(t){for(let i in t){let r=t[i];if(r===void 0){de(`Texture.setValues(): parameter '${i}' has value of undefined.`);continue}let s=this[i];if(s===void 0){de(`Texture.setValues(): property '${i}' does not exist.`);continue}s&&r&&s.isVector2&&r.isVector2||s&&r&&s.isVector3&&r.isVector3||s&&r&&s.isMatrix3&&r.isMatrix3?s.copy(r):this[i]=r}}toJSON(t){let i=t===void 0||typeof t=="string";if(!i&&t.textures[this.uuid]!==void 0)return t.textures[this.uuid];let r={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(t).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&&(r.userData=this.userData),i||(t.textures[this.uuid]=r),r}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(t){if(this.mapping!==300)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case Or:t.x-=Math.floor(t.x);break;case Fa:t.x=t.x<0?0:1;break;case vg:Math.abs(Math.floor(t.x)%2)===1?t.x=Math.ceil(t.x)-t.x:t.x-=Math.floor(t.x);break}if(t.y<0||t.y>1)switch(this.wrapT){case Or:t.y-=Math.floor(t.y);break;case Fa:t.y=t.y<0?0:1;break;case vg:Math.abs(Math.floor(t.y)%2)===1?t.y=Math.ceil(t.y)-t.y:t.y-=Math.floor(t.y);break}return this.flipY&&(t.y=1-t.y),t}set needsUpdate(t){t===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(t){t===!0&&this.pmremVersion++}};Li.DEFAULT_IMAGE=null,Li.DEFAULT_MAPPING=300,Li.DEFAULT_ANISOTROPY=1;var yt=class YD{static{YD.prototype.isVector4=!0}constructor(t=0,i=0,r=0,s=1){this.x=t,this.y=i,this.z=r,this.w=s}get width(){return this.z}set width(t){this.z=t}get height(){return this.w}set height(t){this.w=t}
vendor: 6,534 bytes, line 1
1set(t,i,r,s){return this.x=t,this.y=i,this.z=r,this.w=s,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this.w=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setW(t){return this.w=t,this}setComponent(t,i){switch(t){case 0:this.x=i;break;case 1:this.y=i;break;case 2:this.z=i;break;case 3:this.w=i;break;default:throw Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w===void 0?1:t.w,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this}addVectors(t,i){return this.x=t.x+i.x,this.y=t.y+i.y,this.z=t.z+i.z,this.w=t.w+i.w,this}addScaledVector(t,i){return this.x+=t.x*i,this.y+=t.y*i,this.z+=t.z*i,this.w+=t.w*i,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this}subVectors(t,i){return this.x=t.x-i.x,this.y=t.y-i.y,this.z=t.z-i.z,this.w=t.w-i.w,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}applyMatrix4(t){let i=this.x,r=this.y,s=this.z,n=this.w,a=t.elements;return this.x=a[0]*i+a[4]*r+a[8]*s+a[12]*n,this.y=a[1]*i+a[5]*r+a[9]*s+a[13]*n,this.z=a[2]*i+a[6]*r+a[10]*s+a[14]*n,this.w=a[3]*i+a[7]*r+a[11]*s+a[15]*n,this}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this.w/=t.w,this}divideScalar(t){return this.multiplyScalar(1/t)}setAxisAngleFromQuaternion(t){this.w=2*Math.acos(t.w);let i=Math.sqrt(1-t.w*t.w);return i<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/i,this.y=t.y/i,this.z=t.z/i),this}setAxisAngleFromRotationMatrix(t){let i,r,s,n,a=.01,o=.1,l=t.elements,h=l[0],u=l[4],d=l[8],c=l[1],p=l[5],m=l[9],g=l[2],f=l[6],y=l[10];if(Math.abs(u-c)<a&&Math.abs(d-g)<a&&Math.abs(m-f)<a){if(Math.abs(u+c)<o&&Math.abs(d+g)<o&&Math.abs(m+f)<o&&Math.abs(h+p+y-3)<o)return this.set(1,0,0,0),this;i=Math.PI;let b=(h+1)/2,_=(p+1)/2,T=(y+1)/2,w=(u+c)/4,M=(d+g)/4,S=(m+f)/4;return b>_&&b>T?b<a?(r=0,s=.707106781,n=.707106781):(r=Math.sqrt(b),s=w/r,n=M/r):_>T?_<a?(r=.707106781,s=0,n=.707106781):(s=Math.sqrt(_),r=w/s,n=S/s):T<a?(r=.707106781,s=.707106781,n=0):(n=Math.sqrt(T),r=M/n,s=S/n),this.set(r,s,n,i),this}let x=Math.sqrt((f-m)*(f-m)+(d-g)*(d-g)+(c-u)*(c-u));return Math.abs(x)<.001&&(x=1),this.x=(f-m)/x,this.y=(d-g)/x,this.z=(c-u)/x,this.w=Math.acos((h+p+y-1)/2),this}setFromMatrixPosition(t){let i=t.elements;return this.x=i[12],this.y=i[13],this.z=i[14],this.w=i[15],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w),this}clamp(t,i){return this.x=He(this.x,t.x,i.x),this.y=He(this.y,t.y,i.y),this.z=He(this.z,t.z,i.z),this.w=He(this.w,t.w,i.w),this}clampScalar(t,i){return this.x=He(this.x,t,i),this.y=He(this.y,t,i),this.z=He(this.z,t,i),this.w=He(this.w,t,i),this}clampLength(t,i){let r=this.length();return this.divideScalar(r||1).multiplyScalar(He(r,t,i))}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(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.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(t){return this.normalize().multiplyScalar(t)}lerp(t,i){return this.x+=(t.x-this.x)*i,this.y+=(t.y-this.y)*i,this.z+=(t.z-this.z)*i,this.w+=(t.w-this.w)*i,this}lerpVectors(t,i,r){return this.x=t.x+(i.x-t.x)*r,this.y=t.y+(i.y-t.y)*r,this.z=t.z+(i.z-t.z)*r,this.w=t.w+(i.w-t.w)*r,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w}fromArray(t,i=0){return this.x=t[i],this.y=t[i+1],this.z=t[i+2],this.w=t[i+3],this}toArray(t=[],i=0){return t[i]=this.x,t[i+1]=this.y,t[i+2]=this.z,t[i+3]=this.w,t}fromBufferAttribute(t,i){return this.x=t.getX(i),this.y=t.getY(i),this.z=t.getZ(i),this.w=t.getW(i),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}},zr=class extends Ds{constructor(e=1,t=1,i={}){super(),i=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:mi,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1},i),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=i.depth,this.scissor=new yt(0,0,e,t),this.scissorTest=!1,this.viewport=new yt(0,0,e,t),this.textures=[];let r=new Li({width:e,height:t,depth:i.depth}),s=i.count;for(let n=0;n<s;n++)this.textures[n]=r.clone(),this.textures[n].isRenderTargetTexture=!0,this.textures[n].renderTarget=this;this._setTextureOptions(i),this.depthBuffer=i.depthBuffer,this.stencilBuffer=i.stencilBuffer,this.resolveDepthBuffer=i.resolveDepthBuffer,this.resolveStencilBuffer=i.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=i.depthTexture,this.samples=i.samples,this.multiview=i.multiview}_setTextureOptions(e={}){let t={minFilter:mi,generateMipmaps:!1,flipY:!1,internalFormat:null};e.mapping!==void 0&&(t.mapping=e.mapping),e.wrapS!==void 0&&(t.wrapS=e.wrapS),e.wrapT!==void 0&&(t.wrapT=e.wrapT),e.wrapR!==void 0&&(t.wrapR=e.wrapR),e.magFilter!==void 0&&(t.magFilter=e.magFilter),e.minFilter!==void 0&&(t.minFilter=e.minFilter),e.format!==void 0&&(t.format=e.format),e.type!==void 0&&(t.type=e.type),e.anisotropy!==void 0&&(t.anisotropy=e.anisotropy),e.colorSpace!==void 0&&(t.colorSpace
vendor: 9,401 bytes, line 1
1=e.colorSpace),e.flipY!==void 0&&(t.flipY=e.flipY),e.generateMipmaps!==void 0&&(t.generateMipmaps=e.generateMipmaps),e.internalFormat!==void 0&&(t.internalFormat=e.internalFormat);for(let i=0;i<this.textures.length;i++)this.textures[i].setValues(t)}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),e!==null&&(e.renderTarget=this),this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,t,i=1){if(this.width!==e||this.height!==t||this.depth!==i){this.width=e,this.height=t,this.depth=i;for(let 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=i,this.textures[r].isData3DTexture!==!0&&(this.textures[r].isArrayTexture=this.textures[r].image.depth>1);this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,i=e.textures.length;t<i;t++){this.textures[t]=e.textures[t].clone(),this.textures[t].isRenderTargetTexture=!0,this.textures[t].renderTarget=this;let r=Object.assign({},e.textures[t].image);this.textures[t].source=new Q1(r)}return this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}},GB=class extends Li{constructor(e=null,t=1,i=1,r=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:i,depth:r},this.magFilter=lr,this.minFilter=lr,this.wrapR=Fa,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}},$e=class r2{static{r2.prototype.isMatrix4=!0}constructor(t,i,r,s,n,a,o,l,h,u,d,c,p,m,g,f){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!==void 0&&this.set(t,i,r,s,n,a,o,l,h,u,d,c,p,m,g,f)}set(t,i,r,s,n,a,o,l,h,u,d,c,p,m,g,f){let y=this.elements;return y[0]=t,y[4]=i,y[8]=r,y[12]=s,y[1]=n,y[5]=a,y[9]=o,y[13]=l,y[2]=h,y[6]=u,y[10]=d,y[14]=c,y[3]=p,y[7]=m,y[11]=g,y[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 r2().fromArray(this.elements)}copy(t){let i=this.elements,r=t.elements;return i[0]=r[0],i[1]=r[1],i[2]=r[2],i[3]=r[3],i[4]=r[4],i[5]=r[5],i[6]=r[6],i[7]=r[7],i[8]=r[8],i[9]=r[9],i[10]=r[10],i[11]=r[11],i[12]=r[12],i[13]=r[13],i[14]=r[14],i[15]=r[15],this}copyPosition(t){let i=this.elements,r=t.elements;return i[12]=r[12],i[13]=r[13],i[14]=r[14],this}setFromMatrix3(t){let i=t.elements;return this.set(i[0],i[3],i[6],0,i[1],i[4],i[7],0,i[2],i[5],i[8],0,0,0,0,1),this}extractBasis(t,i,r){return this.determinant()===0?(t.set(1,0,0),i.set(0,1,0),r.set(0,0,1),this):(t.setFromMatrixColumn(this,0),i.setFromMatrixColumn(this,1),r.setFromMatrixColumn(this,2),this)}makeBasis(t,i,r){return this.set(t.x,i.x,r.x,0,t.y,i.y,r.y,0,t.z,i.z,r.z,0,0,0,0,1),this}extractRotation(t){if(t.determinant()===0)return this.identity();let i=this.elements,r=t.elements,s=1/Ou.setFromMatrixColumn(t,0).length(),n=1/Ou.setFromMatrixColumn(t,1).length(),a=1/Ou.setFromMatrixColumn(t,2).length();return i[0]=r[0]*s,i[1]=r[1]*s,i[2]=r[2]*s,i[3]=0,i[4]=r[4]*n,i[5]=r[5]*n,i[6]=r[6]*n,i[7]=0,i[8]=r[8]*a,i[9]=r[9]*a,i[10]=r[10]*a,i[11]=0,i[12]=0,i[13]=0,i[14]=0,i[15]=1,this}makeRotationFromEuler(t){let i=this.elements,r=t.x,s=t.y,n=t.z,a=Math.cos(r),o=Math.sin(r),l=Math.cos(s),h=Math.sin(s),u=Math.cos(n),d=Math.sin(n);if(t.order==="XYZ"){let c=a*u,p=a*d,m=o*u,g=o*d;i[0]=l*u,i[4]=-l*d,i[8]=h,i[1]=p+m*h,i[5]=c-g*h,i[9]=-o*l,i[2]=g-c*h,i[6]=m+p*h,i[10]=a*l}else if(t.order==="YXZ"){let c=l*u,p=l*d,m=h*u,g=h*d;i[0]=c+g*o,i[4]=m*o-p,i[8]=a*h,i[1]=a*d,i[5]=a*u,i[9]=-o,i[2]=p*o-m,i[6]=g+c*o,i[10]=a*l}else if(t.order==="ZXY"){let c=l*u,p=l*d,m=h*u,g=h*d;i[0]=c-g*o,i[4]=-a*d,i[8]=m+p*o,i[1]=p+m*o,i[5]=a*u,i[9]=g-c*o,i[2]=-a*h,i[6]=o,i[10]=a*l}else if(t.order==="ZYX"){let c=a*u,p=a*d,m=o*u,g=o*d;i[0]=l*u,i[4]=m*h-p,i[8]=c*h+g,i[1]=l*d,i[5]=g*h+c,i[9]=p*h-m,i[2]=-h,i[6]=o*l,i[10]=a*l}else if(t.order==="YZX"){let c=a*l,p=a*h,m=o*l,g=o*h;i[0]=l*u,i[4]=g-c*d,i[8]=m*d+p,i[1]=d,i[5]=a*u,i[9]=-o*u,i[2]=-h*u,i[6]=p*d+m,i[10]=c-g*d}else if(t.order==="XZY"){let c=a*l,p=a*h,m=o*l,g=o*h;i[0]=l*u,i[4]=-d,i[8]=h*u,i[1]=c*d+g,i[5]=a*u,i[9]=p*d-m,i[2]=m*d-p,i[6]=o*u,i[10]=g*d+c}return i[3]=0,i[7]=0,i[11]=0,i[12]=0,i[13]=0,i[14]=0,i[15]=1,this}makeRotationFromQuaternion(t){return this.compose(jB,t,$B)}lookAt(t,i,r){let s=this.elements;return gs.subVectors(t,i),gs.lengthSq()===0&&(gs.z=1),gs.normalize(),Uo.crossVectors(r,gs),Uo.lengthSq()===0&&(Math.abs(r.z)===1?gs.x+=1e-4:gs.z+=1e-4,gs.normalize(),Uo.crossVectors(r,gs)),Uo.normalize(),Cg.crossVectors(gs,Uo),s[0]=Uo.x,s[4]=Cg.x,s[8]=gs.x,s[1]=Uo.y,s[5]=Cg.y,s[9]=gs.y,s[2]=Uo.z,s[6]=Cg.z,s[10]=gs.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,i){let r=t.elements,s=i.elements,n=this.elements,a=r[0],o=r[4],l=r[8],h=r[12],u=r[1],d=r[5],c=r[9],p=r[13],m=r[2],g=r[6],f=r[10],y=r[14],x=r[3],b=r[7],_=r[11],T=r[15],w=s[0],M=s[4],S=s[8],R=s[12],I=s[1],B=s[5],O=s[9],U=s[13],V=s[2],z=s[6],Z=s[10],j=s[14],ae=s[3],W=s[7],me=s[11],Ce=s[15];return n[0]=a*w+o*I+l*V+h*ae,n[4]=a*M+o*B+l*z+h*W,n[8]=a*S+o*O+l*Z+h*me,n[12]=a*R+o*U+l*j+h*Ce,n[1]=u*w+d*I+c*V+p*ae,n[5]=u*M+d*B+c*z+p*W,n[9]=u*S+d*O+c*Z+p*me,n[13]=u*R+d*U+c*j+p*Ce,n[2]=m*w+g*I+f*V+y*ae,n[6]=m*M+g*B+f*z+y*W,n[10]=m*S+g*O+f*Z+y*me,n[14]=m*R+g*U+f*j+y*Ce,n[3]=x*w+b*I+_*V+T*ae,n[7]=x*M+b*B+_*z+T*W,n[11]=x*S+b*O+_*Z+T*me,n[15]=x*R+b*U+_*j+T*Ce,this}multiplyScalar(t){let i=this.elements;return i[0]*=t,i[4]*=t,i[8]*=t,i[12]*=t,i[1]*=t,i[5]*=t,i[9]*=t,i[13]*=t,i[2]*=t,i[6]*=t,i[10]*=t,i[14]*=t,i[3]*=t,i[7]*=t,i[11]*=t,i[15]*=t,this}determinant(){let t=this.elements,i=t[0],r=t[4],s=t[8],n=t[12],a=t[1],o=t[5],l=t[9],h=t[13],u=t[2],d=t[6],c=t[10],p=t[14],m=t[3],g=t[7],f=t[11],y=t[15],x=l*p-h*c,b=o*p-h*d,_=o*c-l*d,T=a*p-h*u,w=a*c-l*u,M=a*d-o*u;return i*(g*x-f*b+y*_)-r*(m*x-f*T+y*w)+s*(m*b-g*T+y*M)-n*(m*_-g*w+f*M)}transpose(){let t=this.elements,i;return i=t[1],t[1]=t[4],t[4]=i,i=t[2],t[2]=t[8],t[8]=i,i=t[6],t[6]=t[9],t[9]=i,i=t[3],t[3]=t[12],t[12]=i,i=t[7],t[7]=t[13],t[13]=i,i=t[11],t[11]=t[14],t[14]=i,this}setPosition(t,i,r){let s=this.elements;return t.isVector3?(s[12]=t.x,s[13]=t.y,s[14]=t.z):(s[12]=t,s[13]=i,s[14]=r),this}invert(){let t=this.elements,i=t[0],r=t[1],s=t[2],n=t[3],a=t[4],o=t[5],l=t[6],h=t[7],u=t[8],d=t[9],c=t[10],p=t[11],m=t[12],g=t[13],f=t[14],y=t[15],x=i*o-r*a,b=i*l-s*a,_=i*h-n*a,T=r*l-s*o,w=r*h-n*o,M=s*h-n*l,S=u*g-d*m,R=u*f-c*m,I=u*y-p*m,B=d*f-c*g,O=d*y-p*g,U=c*y-p*f,V=x*U-b*O+_*B+T*I-w*R+M*S;if(V===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let z=1/V;return t[0]=(o*U-l*O+h*B)*z,t[1]=(s*O-r*U-n*B)*z,t[2]=(g*M-f*w+y*T)*z,t[3]=(c*w-d*M-p*T)*z,t[4]=(l*I-a*U-h*R)*z,t[5]=(i*U-s*I+n*R)*z,t[6]=(f*_-m*M-y*b)*z,t[7]=(u*M-c*_+p*b)*z,t[8]=(a*O-o*I+h*S)*z,t[9]=(r*I-i*O-n*S)*z,t[10]=(m*w-g*_+y*x)*z,t[11]=(d*_-u*w-p*x)*z,t[12]=(o*R-a*B-l*S)*z,t[13]=(i*B-r*R+s*S)*z,t[14]=(g*b-m*T-f*x)*z,t[15]=(u*T-d*b+c*x)*z,this}scale(t){let i=this.elements,r=t.x,s=t.y,n=t.z;return i[0]*=r,i[4]*=s,i[8]*=n,i[1]*=r,i[5]*=s,i[9]*=n,i[2]*=r,i[6]*=s,i[10]*=n,i[3]*=r,i[7]*=s,i[11]*=n,this}getMaxScaleOnAxis(){let t=this.elements,i=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],r=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],s=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(i,r,s))}makeTranslation(t,i,r){return t.isVector3?this.set(1,0,0,t.x,0,1,0,t.y,0,0,1,t.z,0,0,0,1):this.set(1,0,0,t,0,1,0,i,0,0,1,r,0,0,0,1),this}makeRotationX(t){let i=Math.cos(t),r=Math.sin(t);return this.set(1,0,0,0,0,i,-r,0,0,r,i,0,0,0,0,1),this}makeRotationY(t){let i=Math.cos(t),r=Math.sin(t);return this.set(i,0,r,0,0,1,0,0,-r,0,i,0,0,0,0,1),this}makeRotationZ(t){let i=Math.cos(t),r=Math.sin(t);return this.set(i,-r,0,0,r,i,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,i){let r=Math.cos(i),s=Math.sin(i),n=1-r,a=t.x,o=t.y,l=t.z,h=n*a,u=n*o;return this.set(h*a+r,h*o-s*l,h*l+s*o,0,h*o+s*l,u*o+r,u*l-s*a,0,h*l-s*o,u*l+s*a,n*l*l+r,0,0,0,0,1),this}makeScale(t,i,r){return this.set(t,0,0,0,0,i,0,0,0,0,r,0,0,0,0,1),this}makeShear(t,i,r,s,n,a){return this.set(1,r,n,0,t,1,a,0,i,s,1,0,0,0,0,1),this}compose(t,i,r){let s=this.elements,n=i._x,a=i._y,o=i._z,l=i._w,h=n+n,u=a+a,d=o+o,c=n*h,p=n*u,m=n*d,g=a*u,f=a*d,y=o*d,x=l*h,b=l*u,_=l*d,T=r.x,w=r.y,M=r.z;return s[0]=(1-(g+y))*T,s[1]=(p+_)*T,s[2]=(m-b)*T,s[3]=0,s[4]=(p-_)*w,s[5]=(1-(c+y))*w,s[6]=(f+x)*w,s[7]=0,s[8]=(m+b)*M,s[9]=(f-x)*M,s[10]=(1-(c+g))*M,s[11]=0,s[12]=t.x,s[13]=t.y,s[14]=t.z,s[15]=1,this}decompose(t,i,r){let s=this.elements;t.x=s[12],t.y=s[13],t.z=s[14];let n=this.determinant();if(n===0)return r.set(1,1,1),i.identity(),this;let a=Ou.set(s[0],s[1],s[2]).length(),o=Ou.set(s[4],s[5],s[6]).length(),l=Ou.set(s[8],s[9],s[10]).length();n<0&&(a=-a),on.copy(this);let h=1/a,u=1/o,d=1/l;return on.elements[0]*=h,on.elements[1]*=h,on.elements[2]*=h,on.elements[4]*=u,on.elements[5]*=u,on.elements[6]*=u,on.elements[8]*=d,on.elements[9]*=d,on.elements[10]*=d,i.setFromRotationMatrix(on),r.x=a,r.
vendor: 7,820 bytes, line 1
1y=o,r.z=l,this}makePerspective(t,i,r,s,n,a,o=ch,l=!1){let h=this.elements,u=2*n/(i-t),d=2*n/(r-s),c=(i+t)/(i-t),p=(r+s)/(r-s),m,g;if(l)m=n/(a-n),g=a*n/(a-n);else if(o===2e3)m=-(a+n)/(a-n),g=-2*a*n/(a-n);else if(o===2001)m=-a/(a-n),g=-a*n/(a-n);else throw Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return h[0]=u,h[4]=0,h[8]=c,h[12]=0,h[1]=0,h[5]=d,h[9]=p,h[13]=0,h[2]=0,h[6]=0,h[10]=m,h[14]=g,h[3]=0,h[7]=0,h[11]=-1,h[15]=0,this}makeOrthographic(t,i,r,s,n,a,o=ch,l=!1){let h=this.elements,u=2/(i-t),d=2/(r-s),c=-(i+t)/(i-t),p=-(r+s)/(r-s),m,g;if(l)m=1/(a-n),g=a/(a-n);else if(o===2e3)m=-2/(a-n),g=-(a+n)/(a-n);else if(o===2001)m=-1/(a-n),g=-n/(a-n);else throw Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return h[0]=u,h[4]=0,h[8]=0,h[12]=c,h[1]=0,h[5]=d,h[9]=0,h[13]=p,h[2]=0,h[6]=0,h[10]=m,h[14]=g,h[3]=0,h[7]=0,h[11]=0,h[15]=1,this}equals(t){let i=this.elements,r=t.elements;for(let s=0;s<16;s++)if(i[s]!==r[s])return!1;return!0}fromArray(t,i=0){for(let r=0;r<16;r++)this.elements[r]=t[r+i];return this}toArray(t=[],i=0){let r=this.elements;return t[i]=r[0],t[i+1]=r[1],t[i+2]=r[2],t[i+3]=r[3],t[i+4]=r[4],t[i+5]=r[5],t[i+6]=r[6],t[i+7]=r[7],t[i+8]=r[8],t[i+9]=r[9],t[i+10]=r[10],t[i+11]=r[11],t[i+12]=r[12],t[i+13]=r[13],t[i+14]=r[14],t[i+15]=r[15],t}},Ou=new F,on=new $e,jB=new F(0,0,0),$B=new F(1,1,1),Uo=new F,Cg=new F,gs=new F,uM=new $e,dM=new Bo,In=class KD{constructor(t=0,i=0,r=0,s=KD.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=i,this._z=r,this._order=s}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get order(){return this._order}set order(t){this._order=t,this._onChangeCallback()}set(t,i,r,s=this._order){return this._x=t,this._y=i,this._z=r,this._order=s,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,i=this._order,r=!0){let s=t.elements,n=s[0],a=s[4],o=s[8],l=s[1],h=s[5],u=s[9],d=s[2],c=s[6],p=s[10];switch(i){case"XYZ":this._y=Math.asin(He(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-u,p),this._z=Math.atan2(-a,n)):(this._x=Math.atan2(c,h),this._z=0);break;case"YXZ":this._x=Math.asin(-He(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(o,p),this._z=Math.atan2(l,h)):(this._y=Math.atan2(-d,n),this._z=0);break;case"ZXY":this._x=Math.asin(He(c,-1,1)),Math.abs(c)<.9999999?(this._y=Math.atan2(-d,p),this._z=Math.atan2(-a,h)):(this._y=0,this._z=Math.atan2(l,n));break;case"ZYX":this._y=Math.asin(-He(d,-1,1)),Math.abs(d)<.9999999?(this._x=Math.atan2(c,p),this._z=Math.atan2(l,n)):(this._x=0,this._z=Math.atan2(-a,h));break;case"YZX":this._z=Math.asin(He(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-u,h),this._y=Math.atan2(-d,n)):(this._x=0,this._y=Math.atan2(o,p));break;case"XZY":this._z=Math.asin(-He(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(c,h),this._y=Math.atan2(o,n)):(this._x=Math.atan2(-u,p),this._y=0);break;default:de("Euler: .setFromRotationMatrix() encountered an unknown order: "+i)}return this._order=i,r===!0&&this._onChangeCallback(),this}setFromQuaternion(t,i,r){return uM.makeRotationFromQuaternion(t),this.setFromRotationMatrix(uM,i,r)}setFromVector3(t,i=this._order){return this.set(t.x,t.y,t.z,i)}reorder(t){return dM.setFromEuler(this),this.setFromQuaternion(dM,t)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(t){return this._x=t[0],this._y=t[1],this._z=t[2],t[3]!==void 0&&(this._order=t[3]),this._onChangeCallback(),this}toArray(t=[],i=0){return t[i]=this._x,t[i+1]=this._y,t[i+2]=this._z,t[i+3]=this._order,t}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}};In.DEFAULT_ORDER="XYZ";var cM=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}},WB=0,pM=new F,Bu=new Bo,Ba=new $e,Rg=new F,Dc=new F,HB=new F,qB=new Bo,mM=new F(1,0,0),gM=new F(0,1,0),fM=new F(0,0,1),yM={type:"added"},XB={type:"removed"},Uu={type:"childadded",child:null},ix={type:"childremoved",child:null},dr=class O1 extends Ds{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:WB++}),this.uuid=kn(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=O1.DEFAULT_UP.clone();let t=new F,i=new In,r=new Bo,s=new F(1,1,1);function n(){r.setFromEuler(i,!1)}function a(){i.setFromQuaternion(r,void 0,!1)}i._onChange(n),r._onChange(a),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:t},rotation:{configurable:!0,enumerable:!0,value:i},quaternion:{configurable:!0,enumerable:!0,value:r},scale:{configurable:!0,enumerable:!0,value:s},modelViewMatrix:{value:new $e},normalMatrix:{value:new Os}}),this.matrix=new $e,this.matrixWorld=new $e,this.matrixAutoUpdate=O1.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=O1.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new cM,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.static=!1,this.userData={},this.pivot=null}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(t){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(t),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(t){return this.quaternion.premultiply(t),this}setRotationFromAxisAngle(t,i){this.quaternion.setFromAxisAngle(t,i)}setRotationFromEuler(t){this.quaternion.setFromEuler(t,!0)}setRotationFromMatrix(t){this.quaternion.setFromRotationMatrix(t)}setRotationFromQuaternion(t){this.quaternion.copy(t)}rotateOnAxis(t,i){return Bu.setFromAxisAngle(t,i),this.quaternion.multiply(Bu),this}rotateOnWorldAxis(t,i){return Bu.setFromAxisAngle(t,i),this.quaternion.premultiply(Bu),this}rotateX(t){return this.rotateOnAxis(mM,t)}rotateY(t){return this.rotateOnAxis(gM,t)}rotateZ(t){return this.rotateOnAxis(fM,t)}translateOnAxis(t,i){return pM.copy(t).applyQuaternion(this.quaternion),this.position.add(pM.multiplyScalar(i)),this}translateX(t){return this.translateOnAxis(mM,t)}translateY(t){return this.translateOnAxis(gM,t)}translateZ(t){return this.translateOnAxis(fM,t)}localToWorld(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(this.matrixWorld)}worldToLocal(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(Ba.copy(this.matrixWorld).invert())}lookAt(t,i,r){t.isVector3?Rg.copy(t):Rg.set(t,i,r);let s=this.parent;this.updateWorldMatrix(!0,!1),Dc.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Ba.lookAt(Dc,Rg,this.up):Ba.lookAt(Rg,Dc,this.up),this.quaternion.setFromRotationMatrix(Ba),s&&(Ba.extractRotation(s.matrixWorld),Bu.setFromRotationMatrix(Ba),this.quaternion.premultiply(Bu.invert()))}add(t){if(arguments.length>1){for(let i=0;i<arguments.length;i++)this.add(arguments[i]);return this}return t===this?(re("Object3D.add: object can't be added as a child of itself.",t),this):(t&&t.isObject3D?(t.removeFromParent(),t.parent=this,this.children.push(t),t.dispatchEvent(yM),Uu.child=t,this.dispatchEvent(Uu),Uu.child=null):re("Object3D.add: object not an instance of THREE.Object3D.",t),this)}remove(t){if(arguments.length>1){for(let r=0;r<arguments.length;r++)this.remove(arguments[r]);return this}let i=this.children.indexOf(t);
vendor: 3,012 bytes, line 1
1return i!==-1&&(t.parent=null,this.children.splice(i,1),t.dispatchEvent(XB),ix.child=t,this.dispatchEvent(ix),ix.child=null),this}removeFromParent(){let t=this.parent;return t!==null&&t.remove(this),this}clear(){return this.remove(...this.children)}attach(t){return this.updateWorldMatrix(!0,!1),Ba.copy(this.matrixWorld).invert(),t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),Ba.multiply(t.parent.matrixWorld)),t.applyMatrix4(Ba),t.removeFromParent(),t.parent=this,this.children.push(t),t.updateWorldMatrix(!1,!0),t.dispatchEvent(yM),Uu.child=t,this.dispatchEvent(Uu),Uu.child=null,this}getObjectById(t){return this.getObjectByProperty("id",t)}getObjectByName(t){return this.getObjectByProperty("name",t)}getObjectByProperty(t,i){if(this[t]===i)return this;for(let r=0,s=this.children.length;r<s;r++){let n=this.children[r].getObjectByProperty(t,i);if(n!==void 0)return n}}getObjectsByProperty(t,i,r=[]){this[t]===i&&r.push(this);let s=this.children;for(let n=0,a=s.length;n<a;n++)s[n].getObjectsByProperty(t,i,r);return r}getWorldPosition(t){return this.updateWorldMatrix(!0,!1),t.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Dc,t,HB),t}getWorldScale(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Dc,qB,t),t}getWorldDirection(t){this.updateWorldMatrix(!0,!1);let i=this.matrixWorld.elements;return t.set(i[8],i[9],i[10]).normalize()}raycast(){}traverse(t){t(this);let i=this.children;for(let r=0,s=i.length;r<s;r++)i[r].traverse(t)}traverseVisible(t){if(this.visible===!1)return;t(this);let i=this.children;for(let r=0,s=i.length;r<s;r++)i[r].traverseVisible(t)}traverseAncestors(t){let i=this.parent;i!==null&&(t(i),i.traverseAncestors(t))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale);let t=this.pivot;if(t!==null){let i=t.x,r=t.y,s=t.z,n=this.matrix.elements;n[12]+=i-n[0]*i-n[4]*r-n[8]*s,n[13]+=r-n[1]*i-n[5]*r-n[9]*s,n[14]+=s-n[2]*i-n[6]*r-n[10]*s}this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,t=!0);let i=this.children;for(let r=0,s=i.length;r<s;r++)i[r].updateMatrixWorld(t)}updateWorldMatrix(t,i){let r=this.parent;if(t===!0&&r!==null&&r.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)),i===!0){let s=this.children;for(let n=0,a=s.length;n<a;n++)s[n].updateWorldMatrix(!1,!0)}}toJSON(t){let i=t===void 0||typeof t=="string",r={};i&&(t={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},r.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});let s={};
vendor: 14,366 bytes, line 1
1s.uuid=this.uuid,s.type=this.type,this.name!==""&&(s.name=this.name),this.castShadow===!0&&(s.castShadow=!0),this.receiveShadow===!0&&(s.receiveShadow=!0),this.visible===!1&&(s.visible=!1),this.frustumCulled===!1&&(s.frustumCulled=!1),this.renderOrder!==0&&(s.renderOrder=this.renderOrder),this.static!==!1&&(s.static=this.static),Object.keys(this.userData).length>0&&(s.userData=this.userData),s.layers=this.layers.mask,s.matrix=this.matrix.toArray(),s.up=this.up.toArray(),this.pivot!==null&&(s.pivot=this.pivot.toArray()),this.matrixAutoUpdate===!1&&(s.matrixAutoUpdate=!1),this.morphTargetDictionary!==void 0&&(s.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(s.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(s.type="InstancedMesh",s.count=this.count,s.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(s.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(s.type="BatchedMesh",s.perObjectFrustumCulled=this.perObjectFrustumCulled,s.sortObjects=this.sortObjects,s.drawRanges=this._drawRanges,s.reservedRanges=this._reservedRanges,s.geometryInfo=this._geometryInfo.map(o=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),s.instanceInfo=this._instanceInfo.map(o=>({...o})),s.availableInstanceIds=this._availableInstanceIds.slice(),s.availableGeometryIds=this._availableGeometryIds.slice(),s.nextIndexStart=this._nextIndexStart,s.nextVertexStart=this._nextVertexStart,s.geometryCount=this._geometryCount,s.maxInstanceCount=this._maxInstanceCount,s.maxVertexCount=this._maxVertexCount,s.maxIndexCount=this._maxIndexCount,s.geometryInitialized=this._geometryInitialized,s.matricesTexture=this._matricesTexture.toJSON(t),s.indirectTexture=this._indirectTexture.toJSON(t),this._colorsTexture!==null&&(s.colorsTexture=this._colorsTexture.toJSON(t)),this.boundingSphere!==null&&(s.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(s.boundingBox=this.boundingBox.toJSON()));function n(o,l){return o[l.uuid]===void 0&&(o[l.uuid]=l.toJSON(t)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?s.background=this.background.toJSON():this.background.isTexture&&(s.background=this.background.toJSON(t).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(s.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){s.geometry=n(t.geometries,this.geometry);let o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){let l=o.shapes;if(Array.isArray(l))for(let h=0,u=l.length;h<u;h++){let d=l[h];n(t.shapes,d)}else n(t.shapes,l)}}if(this.isSkinnedMesh&&(s.bindMode=this.bindMode,s.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(n(t.skeletons,this.skeleton),s.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){let o=[];for(let l=0,h=this.material.length;l<h;l++)o.push(n(t.materials,this.material[l]));s.material=o}else s.material=n(t.materials,this.material);if(this.children.length>0){s.children=[];for(let o=0;o<this.children.length;o++)s.children.push(this.children[o].toJSON(t).object)}if(this.animations.length>0){s.animations=[];for(let o=0;o<this.animations.length;o++){let l=this.animations[o];s.animations.push(n(t.animations,l))}}if(i){let o=a(t.geometries),l=a(t.materials),h=a(t.textures),u=a(t.images),d=a(t.shapes),c=a(t.skeletons),p=a(t.animations),m=a(t.nodes);o.length>0&&(r.geometries=o),l.length>0&&(r.materials=l),h.length>0&&(r.textures=h),u.length>0&&(r.images=u),d.length>0&&(r.shapes=d),c.length>0&&(r.skeletons=c),p.length>0&&(r.animations=p),m.length>0&&(r.nodes=m)}return r.object=s,r;function a(o){let l=[];for(let h in o){let u=o[h];delete u.metadata,l.push(u)}return l}}clone(t){return new this.constructor().copy(this,t)}copy(t,i=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.pivot=t.pivot===null?null:t.pivot.clone(),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldAutoUpdate=t.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.static=t.static,this.animations=t.animations.slice(),this.userData=JSON.parse(JSON.stringify(t.userData)),i===!0)for(let r=0;r<t.children.length;r++){let s=t.children[r];this.add(s.clone())}return this}};dr.DEFAULT_UP=new F(0,1,0),dr.DEFAULT_MATRIX_AUTO_UPDATE=!0,dr.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;var Gr=class extends dr{constructor(){super(),this.isGroup=!0,this.type="Group"}},YB={type:"move"},KB=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Gr,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 Gr,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new F,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new F),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Gr,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new F,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new F,this._grip.eventsEnabled=!1),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){let t=this._hand;if(t)for(let i of e.hand.values())this._getHandJoint(t,i)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,i){let r=null,s=null,n=null,a=this._targetRay,o=this._grip,l=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(l&&e.hand){n=!0;for(let c of e.hand.values()){let p=t.getJointPose(c,i),m=this._getHandJoint(l,c);p!==null&&(m.matrix.fromArray(p.transform.matrix),m.matrix.decompose(m.position,m.rotation,m.scale),m.matrixWorldNeedsUpdate=!0,m.jointRadius=p.radius),m.visible=p!==null}let h=l.joints["index-finger-tip"],u=l.joints["thumb-tip"],d=h.position.distanceTo(u.position);l.inputState.pinching&&d>.025?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!l.inputState.pinching&&d<=.015&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else o!==null&&e.gripSpace&&(s=t.getPose(e.gripSpace,i),s!==null&&(o.matrix.fromArray(s.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,s.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(s.linearVelocity)):o.hasLinearVelocity=!1,s.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(s.angularVelocity)):o.hasAngularVelocity=!1,o.eventsEnabled&&o.dispatchEvent({type:"gripUpdated",data:e,target:this})));a!==null&&(r=t.getPose(e.targetRaySpace,i),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(YB)))}return a!==null&&(a.visible=r!==null),o!==null&&(o.visible=s!==null),l!==null&&(l.visible=n!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){let i=new Gr;i.matrixAutoUpdate=!1,i.visible=!1,e.joints[t.jointName]=i,e.add(i)}return e.joints[t.jointName]}},xM={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},Vo={h:0,s:0,l:0},Eg={h:0,s:0,l:0};function rx(e,t,i){return i<0&&(i+=1),i>1&&--i,i<1/6?e+(t-e)*6*i:i<1/2?t:i<2/3?e+(t-e)*6*(2/3-i):e}var Ke=class{constructor(e,t,i){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,i)}set(e,t,i){if(t===void 0&&i===void 0){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,i);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=Gi){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,lt.colorSpaceToWorking(this,t),this}setRGB(e,t,i,r=lt.workingColorSpace){return this.r=e,this.g=t,this.b=i,lt.colorSpaceToWorking(this,r),this}setHSL(e,t,i,r=lt.workingColorSpace){if(e=K1(e,1),t=He(t,0,1),i=He(i,0,1),t===0)this.r=this.g=this.b=i;else{let s=i<=.5?i*(1+t):i+t-i*t,n=2*i-s;this.r=rx(n,s,e+1/3),this.g=rx(n,s,e),this.b=rx(n,s,e-1/3)}return lt.colorSpaceToWorking(this,r),this}setStyle(e,t=Gi){function i(s){s!==void 0&&parseFloat(s)<1&&de("Color: Alpha component of "+e+" will be ignored.")}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(e)){let s,n=r[1],a=r[2];switch(n){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return i(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 i(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 i(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,t);break;default:de("Color: Unknown color model "+e)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){let s=r[1],n=s.length;if(n===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,t);if(n===6)return this.setHex(parseInt(s,16),t);de("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=Gi){let i=xM[e.toLowerCase()];return i===void 0?de("Color: Unknown color "+e):this.setHex(i,t),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=Oa(e.r),this.g=Oa(e.g),this.b=Oa(e.b),this}copyLinearToSRGB(e){return this.r=Fu(e.r),this.g=Fu(e.g),this.b=Fu(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Gi){return lt.workingToColorSpace(Tr.copy(this),e),Math.round(He(Tr.r*255,0,255))*65536+Math.round(He(Tr.g*255,0,255))*256+Math.round(He(Tr.b*255,0,255))}getHexString(e=Gi){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=lt.workingColorSpace){lt.workingToColorSpace(Tr.copy(this),t);let i=Tr.r,r=Tr.g,s=Tr.b,n=Math.max(i,r,s),a=Math.min(i,r,s),o,l,h=(a+n)/2;if(a===n)o=0,l=0;else{let u=n-a;switch(l=h<=.5?u/(n+a):u/(2-n-a),n){case i:o=(r-s)/u+(r<s?6:0);break;case r:o=(s-i)/u+2;break;case s:o=(i-r)/u+4;break}o/=6}return e.h=o,e.s=l,e.l=h,e}getRGB(e,t=lt.workingColorSpace){return lt.workingToColorSpace(Tr.copy(this),t),e.r=Tr.r,e.g=Tr.g,e.b=Tr.b,e}
vendor: 3,664 bytes, line 1
1getStyle(e=Gi){lt.workingToColorSpace(Tr.copy(this),e);let t=Tr.r,i=Tr.g,r=Tr.b;return e==="srgb"?`rgb(${Math.round(t*255)},${Math.round(i*255)},${Math.round(r*255)})`:`color(${e} ${t.toFixed(3)} ${i.toFixed(3)} ${r.toFixed(3)})`}offsetHSL(e,t,i){return this.getHSL(Vo),this.setHSL(Vo.h+e,Vo.s+t,Vo.l+i)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,i){return this.r=e.r+(t.r-e.r)*i,this.g=e.g+(t.g-e.g)*i,this.b=e.b+(t.b-e.b)*i,this}lerpHSL(e,t){this.getHSL(Vo),e.getHSL(Eg);let i=Fc(Vo.h,Eg.h,t),r=Fc(Vo.s,Eg.s,t),s=Fc(Vo.l,Eg.l,t);return this.setHSL(i,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,i=this.g,r=this.b,s=e.elements;return this.r=s[0]*t+s[3]*i+s[6]*r,this.g=s[1]*t+s[4]*i+s[7]*r,this.b=s[2]*t+s[5]*i+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}},Tr=new Ke;Ke.NAMES=xM;var Oc=class extends dr{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 In,this.environmentIntensity=1,this.environmentRotation=new In,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}},ln=new F,Ua=new F,sx=new F,Va=new F,Vu=new F,zu=new F,vM=new F,nx=new F,ax=new F,ox=new F,lx=new yt,hx=new yt,ux=new yt,Gu=class Cc{constructor(t=new F,i=new F,r=new F){this.a=t,this.b=i,this.c=r}static getNormal(t,i,r,s){s.subVectors(r,i),ln.subVectors(t,i),s.cross(ln);let n=s.lengthSq();return n>0?s.multiplyScalar(1/Math.sqrt(n)):s.set(0,0,0)}static getBarycoord(t,i,r,s,n){ln.subVectors(s,i),Ua.subVectors(r,i),sx.subVectors(t,i);let a=ln.dot(ln),o=ln.dot(Ua),l=ln.dot(sx),h=Ua.dot(Ua),u=Ua.dot(sx),d=a*h-o*o;if(d===0)return n.set(0,0,0),null;
vendor: 4,500 bytes, line 1
1let c=1/d,p=(h*l-o*u)*c,m=(a*u-o*l)*c;return n.set(1-p-m,m,p)}static containsPoint(t,i,r,s){return this.getBarycoord(t,i,r,s,Va)===null?!1:Va.x>=0&&Va.y>=0&&Va.x+Va.y<=1}static getInterpolation(t,i,r,s,n,a,o,l){return this.getBarycoord(t,i,r,s,Va)===null?(l.x=0,l.y=0,"z"in l&&(l.z=0),"w"in l&&(l.w=0),null):(l.setScalar(0),l.addScaledVector(n,Va.x),l.addScaledVector(a,Va.y),l.addScaledVector(o,Va.z),l)}static getInterpolatedAttribute(t,i,r,s,n,a){return lx.setScalar(0),hx.setScalar(0),ux.setScalar(0),lx.fromBufferAttribute(t,i),hx.fromBufferAttribute(t,r),ux.fromBufferAttribute(t,s),a.setScalar(0),a.addScaledVector(lx,n.x),a.addScaledVector(hx,n.y),a.addScaledVector(ux,n.z),a}static isFrontFacing(t,i,r,s){return ln.subVectors(r,i),Ua.subVectors(t,i),ln.cross(Ua).dot(s)<0}set(t,i,r){return this.a.copy(t),this.b.copy(i),this.c.copy(r),this}setFromPointsAndIndices(t,i,r,s){return this.a.copy(t[i]),this.b.copy(t[r]),this.c.copy(t[s]),this}setFromAttributeAndIndices(t,i,r,s){return this.a.fromBufferAttribute(t,i),this.b.fromBufferAttribute(t,r),this.c.fromBufferAttribute(t,s),this}clone(){return new this.constructor().copy(this)}copy(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this}getArea(){return ln.subVectors(this.c,this.b),Ua.subVectors(this.a,this.b),ln.cross(Ua).length()*.5}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return Cc.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,i){return Cc.getBarycoord(t,this.a,this.b,this.c,i)}getInterpolation(t,i,r,s,n){return Cc.getInterpolation(t,this.a,this.b,this.c,i,r,s,n)}containsPoint(t){return Cc.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return Cc.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,i){let r=this.a,s=this.b,n=this.c,a,o;Vu.subVectors(s,r),zu.subVectors(n,r),nx.subVectors(t,r);let l=Vu.dot(nx),h=zu.dot(nx);if(l<=0&&h<=0)return i.copy(r);ax.subVectors(t,s);let u=Vu.dot(ax),d=zu.dot(ax);if(u>=0&&d<=u)return i.copy(s);let c=l*d-u*h;if(c<=0&&l>=0&&u<=0)return a=l/(l-u),i.copy(r).addScaledVector(Vu,a);ox.subVectors(t,n);let p=Vu.dot(ox),m=zu.dot(ox);if(m>=0&&p<=m)return i.copy(n);let g=p*h-l*m;if(g<=0&&h>=0&&m<=0)return o=h/(h-m),i.copy(r).addScaledVector(zu,o);let f=u*m-p*d;if(f<=0&&d-u>=0&&p-m>=0)return vM.subVectors(n,s),o=(d-u)/(d-u+(p-m)),i.copy(s).addScaledVector(vM,o);let y=1/(f+g+c);return a=g*y,o=c*y,i.copy(r).addScaledVector(Vu,a).addScaledVector(zu,o)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}},Fn=class{constructor(e=new F(1/0,1/0,1/0),t=new F(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t+=3)this.expandByPoint(hn.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,i=e.count;t<i;t++)this.expandByPoint(hn.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){let i=hn.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(i),this.max.copy(e).add(i),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);let i=e.geometry;if(i!==void 0){let s=i.getAttribute("position");if(t===!0&&s!==void 0&&e.isInstancedMesh!==!0)for(let n=0,a=s.count;n<a;n++)e.isMesh===!0?e.getVertexPosition(n,hn):hn.fromBufferAttribute(s,n),hn.applyMatrix4(e.matrixWorld),this.expandByPoint(hn);else e.boundingBox===void 0?(i.boundingBox===null&&i.computeBoundingBox(),Ag.copy(i.boundingBox)):(e.boundingBox===null&&e.computeBoundingBox(),Ag.copy(e.boundingBox)),Ag.applyM
vendor: 29,084 bytes, line 1
1atrix4(e.matrixWorld),this.union(Ag)}let r=e.children;for(let s=0,n=r.length;s<n;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,hn),hn.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,i;return e.normal.x>0?(t=e.normal.x*this.min.x,i=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,i=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,i+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,i+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,i+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,i+=e.normal.z*this.min.z),t<=-e.constant&&i>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(Bc),Ng.subVectors(this.max,Bc),ju.subVectors(e.a,Bc),$u.subVectors(e.b,Bc),Wu.subVectors(e.c,Bc),zo.subVectors($u,ju),Go.subVectors(Wu,$u),gh.subVectors(ju,Wu);let t=[0,-zo.z,zo.y,0,-Go.z,Go.y,0,-gh.z,gh.y,zo.z,0,-zo.x,Go.z,0,-Go.x,gh.z,0,-gh.x,-zo.y,zo.x,0,-Go.y,Go.x,0,-gh.y,gh.x,0];return!dx(t,ju,$u,Wu,Ng)||(t=[1,0,0,0,1,0,0,0,1],!dx(t,ju,$u,Wu,Ng))?!1:(Lg.crossVectors(zo,Go),t=[Lg.x,Lg.y,Lg.z],dx(t,ju,$u,Wu,Ng))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,hn).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(hn).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:(za[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),za[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),za[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),za[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),za[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),za[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),za[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),za[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(za),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}},za=[new F,new F,new F,new F,new F,new F,new F,new F],hn=new F,Ag=new Fn,ju=new F,$u=new F,Wu=new F,zo=new F,Go=new F,gh=new F,Bc=new F,Ng=new F,Lg=new F,fh=new F;function dx(e,t,i,r,s){for(let n=0,a=e.length-3;n<=a;n+=3){fh.fromArray(e,n);let o=s.x*Math.abs(fh.x)+s.y*Math.abs(fh.y)+s.z*Math.abs(fh.z),l=t.dot(fh),h=i.dot(fh),u=r.dot(fh);if(Math.max(-Math.max(l,h,u),Math.min(l,h,u))>o)return!1}return!0}var Ga=ZB();function ZB(){let e=new ArrayBuffer(4),t=new Float32Array(e),i=new Uint32Array(e),r=new Uint32Array(512),s=new Uint32Array(512);for(let l=0;l<256;++l){let h=l-127;h<-27?(r[l]=0,r[l|256]=32768,s[l]=24,s[l|256]=24):h<-14?(r[l]=1024>>-h-14,r[l|256]=1024>>-h-14|32768,s[l]=-h-1,s[l|256]=-h-1):h<=15?(r[l]=h+15<<10,r[l|256]=h+15<<10|32768,s[l]=13,s[l|256]=13):h<128?(r[l]=31744,r[l|256]=64512,s[l]=24,s[l|256]=24):(r[l]=31744,r[l|256]=64512,s[l]=13,s[l|256]=13)}let n=new Uint32Array(2048),a=new Uint32Array(64),o=new Uint32Array(64);for(let l=1;l<1024;++l){let h=l<<13,u=0;for(;!(h&8388608);)h<<=1,u-=8388608;h&=-8388609,u+=947912704,n[l]=h|u}for(let l=1024;l<2048;++l)n[l]=939524096+(l-1024<<13);for(let l=1;l<31;++l)a[l]=l<<23;a[31]=1199570944,a[32]=2147483648;for(let l=33;l<63;++l)a[l]=2147483648+(l-32<<23);a[63]=3347054592;for(let l=1;l<64;++l)l!==32&&(o[l]=1024);return{floatView:t,uint32View:i,baseTable:r,shiftTable:s,mantissaTable:n,exponentTable:a,offsetTable:o}}function fs(e){Math.abs(e)>65504&&de("DataUtils.toHalfFloat(): Value out of range."),e=He(e,-65504,65504),Ga.floatView[0]=e;let t=Ga.uint32View[0],i=t>>23&511;return Ga.baseTable[i]+((t&8388607)>>Ga.shiftTable[i])}function Pg(e){let t=e>>10;return Ga.uint32View[0]=Ga.mantissaTable[Ga.offsetTable[t]+(e&1023)]+Ga.exponentTable[t],Ga.floatView[0]}var Pi=new F,kg=new ge,JB=0,jr=class{constructor(e,t,i=!1){if(Array.isArray(e))throw TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:JB++}),this.name="",this.array=e,this.itemSize=t,this.count=e===void 0?0:e.length/t,this.normalized=i,this.usage=dh,this.updateRanges=[],this.gpuType=Pn,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,i){e*=this.itemSize,i*=t.itemSize;for(let r=0,s=this.itemSize;r<s;r++)this.array[e+r]=t.array[i+r];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,i=this.count;t<i;t++)kg.fromBufferAttribute(this,t),kg.applyMatrix3(e),this.setXY(t,kg.x,kg.y);else if(this.itemSize===3)for(let t=0,i=this.count;t<i;t++)Pi.fromBufferAttribute(this,t),Pi.applyMatrix3(e),this.setXYZ(t,Pi.x,Pi.y,Pi.z);return this}applyMatrix4(e){for(let t=0,i=this.count;t<i;t++)Pi.fromBufferAttribute(this,t),Pi.applyMatrix4(e),this.setXYZ(t,Pi.x,Pi.y,Pi.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)Pi.fromBufferAttribute(this,t),Pi.applyNormalMatrix(e),this.setXYZ(t,Pi.x,Pi.y,Pi.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)Pi.fromBufferAttribute(this,t),Pi.transformDirection(e),this.setXYZ(t,Pi.x,Pi.y,Pi.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let i=this.array[e*this.itemSize+t];return this.normalized&&(i=Vr(i,this.array)),i}setComponent(e,t,i){return this.normalized&&(i=Ve(i,this.array)),this.array[e*this.itemSize+t]=i,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=Vr(t,this.array)),t}setX(e,t){return this.normalized&&(t=Ve(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=Vr(t,this.array)),t}setY(e,t){return this.normalized&&(t=Ve(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=Vr(t,this.array)),t}setZ(e,t){return this.normalized&&(t=Ve(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=Vr(t,this.array)),t}setW(e,t){return this.normalized&&(t=Ve(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,i){return e*=this.itemSize,this.normalized&&(t=Ve(t,this.array),i=Ve(i,this.array)),this.array[e+0]=t,this.array[e+1]=i,this}setXYZ(e,t,i,r){return e*=this.itemSize,this.normalized&&(t=Ve(t,this.array),i=Ve(i,this.array),r=Ve(r,this.array)),this.array[e+0]=t,this.array[e+1]=i,this.array[e+2]=r,this}setXYZW(e,t,i,r,s){return e*=this.itemSize,this.normalized&&(t=Ve(t,this.array),i=Ve(i,this.array),r=Ve(r,this.array),s=Ve(s,this.array)),this.array[e+0]=t,this.array[e+1]=i,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!==35044&&(e.usage=this.usage),e}},bM=class extends jr{constructor(e,t,i){super(new Uint16Array(e),t,i)}},_M=class extends jr{constructor(e,t,i){super(new Uint32Array(e),t,i)}},TM=class extends jr{constructor(e,t,i){super(new Uint16Array(e),t,i),this.isFloat16BufferAttribute=!0}getX(e){let t=Pg(this.array[e*this.itemSize]);return this.normalized&&(t=Vr(t,this.array)),t}setX(e,t){return this.normalized&&(t=Ve(t,this.array)),this.array[e*this.itemSize]=fs(t),this}getY(e){let t=Pg(this.array[e*this.itemSize+1]);return this.normalized&&(t=Vr(t,this.array)),t}setY(e,t){return this.normalized&&(t=Ve(t,this.array)),this.array[e*this.itemSize+1]=fs(t),this}getZ(e){let t=Pg(this.array[e*this.itemSize+2]);return this.normalized&&(t=Vr(t,this.array)),t}setZ(e,t){return this.normalized&&(t=Ve(t,this.array)),this.array[e*this.itemSize+2]=fs(t),this}getW(e){let t=Pg(this.array[e*this.itemSize+3]);return this.normalized&&(t=Vr(t,this.array)),t}setW(e,t){return this.normalized&&(t=Ve(t,this.array)),this.array[e*this.itemSize+3]=fs(t),this}setXY(e,t,i){return e*=this.itemSize,this.normalized&&(t=Ve(t,this.array),i=Ve(i,this.array)),this.array[e+0]=fs(t),this.array[e+1]=fs(i),this}setXYZ(e,t,i,r){return e*=this.itemSize,this.normalized&&(t=Ve(t,this.array),i=Ve(i,this.array),r=Ve(r,this.array)),this.array[e+0]=fs(t),this.array[e+1]=fs(i),this.array[e+2]=fs(r),this}setXYZW(e,t,i,r,s){return e*=this.itemSize,this.normalized&&(t=Ve(t,this.array),i=Ve(i,this.array),r=Ve(r,this.array),s=Ve(s,this.array)),this.array[e+0]=fs(t),this.array[e+1]=fs(i),this.array[e+2]=fs(r),this.array[e+3]=fs(s),this}},Ht=class extends jr{constructor(e,t,i){super(new Float32Array(e),t,i)}},QB=new Fn,Uc=new F,cx=new F,ja=class{constructor(e=new F,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 i=this.center;t===void 0?QB.setFromPoints(e).getCenter(i):i.copy(t);let r=0;for(let s=0,n=e.length;s<n;s++)r=Math.max(r,i.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 i=this.center.distanceToSquared(e);return t.copy(e),i>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius*=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;Uc.subVectors(e,this.center);let t=Uc.lengthSq();if(t>this.radius*this.radius){let i=Math.sqrt(t),r=(i-this.radius)*.5;this.center.addScaledVector(Uc,r/i),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):(cx.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Uc.copy(e.center).add(cx)),this.expandByPoint(Uc.copy(e.center).sub(cx))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}},e4=0,Bs=new $e,px=new dr,Hu=new F,ys=new Fn,Vc=new Fn,er=new F,$r=class ZD extends Ds{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:e4++}),this.uuid=kn(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(t){return Array.isArray(t)?this.index=new(vB(t)?_M:bM)(t,1):this.index=t,this}setIndirect(t,i=0){return this.indirect=t,this.indirectOffset=i,this}getIndirect(){return this.indirect}getAttribute(t){return this.attributes[t]}setAttribute(t,i){return this.attributes[t]=i,this}deleteAttribute(t){return delete this.attributes[t],this}hasAttribute(t){return this.attributes[t]!==void 0}addGroup(t,i,r=0){this.groups.push({start:t,count:i,materialIndex:r})}clearGroups(){this.groups=[]}setDrawRange(t,i){this.drawRange.start=t,this.drawRange.count=i}applyMatrix4(t){let i=this.attributes.position;i!==void 0&&(i.applyMatrix4(t),i.needsUpdate=!0);let r=this.attributes.normal;if(r!==void 0){let n=new Os().getNormalMatrix(t);r.applyNormalMatrix(n),r.needsUpdate=!0}let s=this.attributes.tangent;return s!==void 0&&(s.transformDirection(t),s.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(t){return Bs.makeRotationFromQuaternion(t),this.applyMatrix4(Bs),this}rotateX(t){return Bs.makeRotationX(t),this.applyMatrix4(Bs),this}rotateY(t){return Bs.makeRotationY(t),this.applyMatrix4(Bs),this}rotateZ(t){return Bs.makeRotationZ(t),this.applyMatrix4(Bs),this}translate(t,i,r){return Bs.makeTranslation(t,i,r),this.applyMatrix4(Bs),this}scale(t,i,r){return Bs.makeScale(t,i,r),this.applyMatrix4(Bs),this}lookAt(t){return px.lookAt(t),px.updateMatrix(),this.applyMatrix4(px.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Hu).negate(),this.translate(Hu.x,Hu.y,Hu.z),this}setFromPoints(t){let i=this.getAttribute("position");if(i===void 0){let r=[];for(let s=0,n=t.length;s<n;s++){let a=t[s];r.push(a.x,a.y,a.z||0)}this.setAttribute("position",new Ht(r,3))}else{let r=Math.min(t.length,i.count);for(let s=0;s<r;s++){let n=t[s];i.setXYZ(s,n.x,n.y,n.z||0)}t.length>i.count&&de("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),i.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Fn);let t=this.attributes.position,i=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){re("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new F(-1/0,-1/0,-1/0),new F(1/0,1/0,1/0));return}if(t!==void 0){if(this.boundingBox.setFromBufferAttribute(t),i)for(let r=0,s=i.length;r<s;r++){let n=i[r];ys.setFromBufferAttribute(n),this.morphTargetsRelative?(er.addVectors(this.boundingBox.min,ys.min),this.boundingBox.expandByPoint(er),er.addVectors(this.boundingBox.max,ys.max),this.boundingBox.expandByPoint(er)):(this.boundingBox.expandByPoint(ys.min),this.boundingBox.expandByPoint(ys.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&re('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 ja);let t=this.attributes.position,i=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){re("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new F,1/0);return}if(t){let r=this.boundingSphere.center;if(ys.setFromBufferAttribute(t),i)for(let n=0,a=i.length;n<a;n++){let o=i[n];Vc.setFromBufferAttribute(o),this.morphTargetsRelative?(er.addVectors(ys.min,Vc.min),ys.expandByPoint(er),er.addVectors(ys.max,Vc.max),ys.expandByPoint(er)):(ys.expandByPoint(Vc.min),ys.expandByPoint(Vc.max))}ys.getCenter(r);let s=0;for(let n=0,a=t.count;n<a;n++)er.fromBufferAttribute(t,n),s=Math.max(s,r.distanceToSquared(er));if(i)for(let n=0,a=i.length;n<a;n++){let o=i[n],l=this.morphTargetsRelative;for(let h=0,u=o.count;h<u;h++)er.fromBufferAttribute(o,h),l&&(Hu.fromBufferAttribute(t,h),er.add(Hu)),s=Math.max(s,r.distanceToSquared(er))}this.boundingSphere.radius=Math.sqrt(s),isNaN(this.boundingSphere.radius)&&re('BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){let t=this.index,i=this.attributes;if(t===null||i.position===void 0||i.normal===void 0||i.uv===void 0){re("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}let r=i.position,s=i.normal,n=i.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new jr(new Float32Array(4*r.count),4));let a=this.getAttribute("tangent"),o=[],l=[];for(let S=0;S<r.count;S++)o[S]=new F,l[S]=new F;let h=new F,u=new F,d=new F,c=new ge,p=new ge,m=new ge,g=new F,f=new F;function y(S,R,I){h.fromBufferAttribute(r,S),u.fromBufferAttribute(r,R),d.fromBufferAttribute(r,I),c.fromBufferAttribute(n,S),p.fromBufferAttribute(n,R),m.fromBufferAttribute(n,I),u.sub(h),d.sub(h),p.sub(c),m.sub(c);let B=1/(p.x*m.y-m.x*p.y);isFinite(B)&&(g.copy(u).multiplyScalar(m.y).addScaledVector(d,-p.y).multiplyScalar(B),f.copy(d).multiplyScalar(p.x).addScaledVector(u,-m.x).multiplyScalar(B),o[S].add(g),o[R].add(g),o[I].add(g),l[S].add(f),l[R].add(f),l[I].add(f))}let x=this.groups;x.length===0&&(x=[{start:0,count:t.count}]);for(let S=0,R=x.length;S<R;++S){let I=x[S],B=I.start,O=I.count;for(let U=B,V=B+O;U<V;U+=3)y(t.getX(U+0),t.getX(U+1),t.getX(U+2))}let b=new F,_=new F,T=new F,w=new F;function M(S){T.fromBufferAttribute(s,S),w.copy(T);let R=o[S];b.copy(R),b.sub(T.multiplyScalar(T.dot(R))).normalize(),_.crossVectors(w,R);let I=_.dot(l[S])<0?-1:1;a.setXYZW(S,b.x,b.y,b.z,I)}for(let S=0,R=x.length;S<R;++S){let I=x[S],B=I.start,O=I.count;for(let U=B,V=B+O;U<V;U+=3)M(t.getX(U+0)),M(t.getX(U+1)),M(t.getX(U+2))}}computeVertexNormals(){let t=this.index,i=this.getAttribute("position");if(i!==void 0){let r=this.getAttribute("normal");if(r===void 0)r=new jr(new Float32Array(i.count*3),3),this.setAttribute("normal",r);else for(let c=0,p=r.count;c<p;c++)r.setXYZ(c,0,0,0);let s=new F,n=new F,a=new F,o=new F,l=new F,h=new F,u=new F,d=new F;if(t)for(let c=0,p=t.count;c<p;c+=3){let m=t.getX(c+0),g=t.getX(c+1),f=t.getX(c+2);s.fromBufferAttribute(i,m),n.fromBufferAttribute(i,g),a.fromBufferAttribute(i,f),u.subVectors(a,n),d.subVectors(s,n),u.cross(d),o.fromBufferAttribute(r,m),l.fromBufferAttribute(r,g),h.fromBufferAttribute(r,f),o.add(u),l.add(u),h.add(u),r.setXYZ(m,o.x,o.y,o.z),r.setXYZ(g,l.x,l.y,l.z),r.setXYZ(f,h.x,h.y,h.z)}else for(let c=0,p=i.count;c<p;c+=3)s.fromBufferAttribute(i,c+0),n.fromBufferAttribute(i,c+1),a.fromBufferAttribute(i,c+2),u.subVectors(a,n),d.subVectors(s,n),u.cross(d),r.setXYZ(c+0,u.x,u.y,u.z),r.setXYZ(c+1,u.x,u.y,u.z),r.setXYZ(c+2,u.x,u.y,u.z);this.normalizeNormals(),r.needsUpdate=!0}}normalizeNormals(){let t=this.attributes.normal;for(let i=0,r=t.count;i<r;i++)er.fromBufferAttribute(t,i),er.normalize(),t.setXYZ(i,er.x,er.y,er.z)}toNonIndexed(){function t(o,l){let h=o.array,u=o.itemSize,d=o.normalized,c=new h.constructor(l.length*u),p=0,m=0;for(let g=0,f=l.length;g<f;g++){p=o.isInterleavedBufferAttribute?l[g]*o.data.stride+o.offset:l[g]*u;for(let y=0;y<u;y++)c[m++]=h[p++]}return new jr(c,u,d)}if(this.index===null)return de("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;let i=new ZD,r=this.index.array,s=this.attributes;for(let o in s){let l=s[o],h=t(l,r);i.setAttribute(o,h)}let n=this.morphAttributes;for(let o in n){let l=[],h=n[o];for(let u=0,d=h.length;u<d;u++){let c=h[u],p=t(c,r);l.push(p)}i.morphAttributes[o]=l}i.morphTargetsRelative=this.morphTargetsRelative;let a=this.groups;for(let o=0,l=a.length;o<l;o++){let h=a[o];i.addGroup(h.start,h.count,h.materialIndex)}return i}toJSON(){let t={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(t.uuid=this.uuid,t.type=this.type,this.name!==""&&(t.name=this.name),Object.keys(this.userData).length>0&&(t.userData=this.userData),this.parameters!==void 0){let l=this.parameters;for(let h in l)l[h]!==void 0&&(t[h]=l[h]);return t}t.data={attributes:{}};let i=this.index;i!==null&&(t.data.index={type:i.array.constructor.name,array:Array.prototype.slice.call(i.array)});let r=this.attributes;for(let l in r){let h=r[l];t.data.attributes[l]=h.toJSON(t.data)}let s={},n=!1;for(let l in this.morphAttributes){let h=this.morphAttributes[l],u=[];for(let d=0,c=h.length;d<c;d++){let p=h[d];u.push(p.toJSON(t.data))}u.length>0&&(s[l]=u,n=!0)}n&&(t.data.morphAttributes=s,t.data.morphTargetsRelative=this.morphTargetsRelative);let a=this.groups;a.length>0&&(t.data.groups=JSON.parse(JSON.stringify(a)));let o=this.boundingSphere;return o!==null&&(t.data.boundingSphere=o.toJSON()),t}clone(){return new this.constructor().copy(this)}copy(t){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let i={};this.name=t.name;let r=t.index;r!==null&&this.setIndex(r.clone());let s=t.attributes;for(let h in s){let u=s[h];this.setAttribute(h,u.clone(i))}let n=t.morphAttributes;for(let h in n){let u=[],d=n[h];for(let c=0,p=d.length;c<p;c++)u.push(d[c].clone(i));this.morphAttributes[h]=u}this.morphTargetsRelative=t.morphTargetsRelative;let a=t.groups;for(let h=0,u=a.length;h<u;h++){let d=a[h];this.addGroup(d.start,d.count,d.materialIndex)}let o=t.boundingBox;o!==null&&(this.boundingBox=o.clone());let l=t.boundingSphere;return l!==null&&(this.boundingSphere=l.clone()),this.drawRange.start=t.drawRange.start,this.drawRange.count=t.drawRange.count,this.userData=t.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}},mx=class{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e===void 0?0:e.length/t,this.usage=dh,this.updateRanges=[],this.version=0,this.uuid=kn()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,i){e*=this.stride,i*=t.stride;for(let r=0,s=this.stride;r<s;r++)this.array[e+r]=t.array[i+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=kn()),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]),i=new this.constructor(t,this.stride);return i.setUsage(this.usage),i}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=kn()),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}}},Wr=new F,gx=class JD{constructor(t,i,r,s=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=t,this.itemSize=i,this.offset=r,this.normalized=s}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(t){this.data.needsUpdate=t}applyMatrix4(t){for(let i=0,r=this.data.count;i<r;i++)Wr.fromBufferAttribute(this,i),Wr.applyMatrix4(t),this.setXYZ(i,Wr.x,Wr.y,Wr.z);return this}applyNormalMatrix(t){for(let i=0,r=this.count;i<r;i++)Wr.fromBufferAttribute(this,i),Wr.applyNormalMatrix(t),this.setXYZ(i,Wr.x,Wr.y,Wr.z);return this}transformDirection(t){for(let i=0,r=this.count;i<r;i++)Wr.fromBufferAttribute(this,i),Wr.transformDirection(t),this.setXYZ(i,Wr.x,Wr.y,Wr.z);return this}getComponent(t,i){let r=this.array[t*this.data.stride+this.offset+i];return this.normalized&&(r=Vr(r,this.array)),r}setComponent(t,i,r){return this.normalized&&(r=Ve(r,this.array)),this.data.array[t*this.data.stride+this.offset+i]=r,this}setX(t,i){return this.normalized&&(i=Ve(i,this.array)),this.data.array[t*this.data.stride+this.offset]=i,this}setY(t,i){return this.normalized&&(i=Ve(i,this.array)),this.data.array[t*this.data.stride+this.offset+1]=i,this}setZ(t,i){return this.normalized&&(i=Ve(i,this.array)),this.data.array[t*this.data.stride+this.offset+2]=i,this}setW(t,i){return this.normalized&&(i=Ve(i,this.array)),this.data.array[t*this.data.stride+this.offset+3]=i,this}getX(t){let i=this.data.array[t*this.data.stride+this.offset];return this.normalized&&(i=Vr(i,this.array)),i}getY(t){let i=this.data.array[t*this.data.stride+this.offset+1];return this.normalized&&(i=Vr(i,this.array)),i}getZ(t){let i=this.data.array[t*this.data.stride+this.offset+2];return this.normalized&&(i=Vr(i,this.array)),i}getW(t){let i=this.data.array[t*this.data.stride+this.offset+3];return this.normalized&&(i=Vr(i,this.array)),i}setXY(t,i,r){return t=t*this.data.stride+this.offset,this.normalized&&(i=Ve(i,this.array),r=Ve(r,this.array)),this.data.array[t+0]=i,this.data.array[t+1]=r,this}setXYZ(t,i,r,s){return t=t*this.data.stride+this.offset,this.normalized&&(i=Ve(i,this.array),r=Ve(r,this.array),s=Ve(s,this.array)),this.data.array[t+0]=i,this.data.array[t+1]=r,this.data.array[t+2]=s,this}setXYZW(t,i,r,s,n){return t=t*this.data.stride+this.offset,this.normalized&&(i=Ve(i,this.array),r=Ve(r,this.array),s=Ve(s,this.array),n=Ve(n,this.array)),this.data.array[t+0]=i,this.data.array[t+1]=r,this.data.array[t+2]=s,this.data.array[t+3]=n,this}clone(t){if(t===void 0){Y1("InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");let i=[];for(let r=0;r<this.count;r++){let s=r*this.data.stride+this.offset;for(let n=0;n<this.itemSize;n++)i.push(this.data.array[s+n])}return new jr(new this.array.constructor(i),this.itemSize,this.normalized)}else return t.interleavedBuffers===void 0&&(t.interleavedBuffers={}),t.interleavedBuffers[this.data.uuid]===void 0&&(t.interleavedBuffers[this.data.uuid]=this.data.clone(t)),new JD(t.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(t){if(t===void 0){Y1("InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");let i=[];for(let r=0;r<this.count;r++){let s=r*this.data.stride+this.offset;for(let n=0;n<this.itemSize;n++)i.push(this.data.array[s+n])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:i,normalized:this.normalized}}else return t.interleavedBuffers===void 0&&(t.interleavedBuffers={}),t.interleavedBuffers[this.data.uuid]===void 0&&(t.interleavedBuffers[this.data.uuid]=this.data.toJSON(t)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}},t4=0,xs=class extends Ds{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:t4++}),this.uuid=kn(),this.name="",this.type="Material",this.blending=1,this.side=0,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=204,this.blendDst=205,this.blendEquation=100,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Ke(0,0,0),this.blendAlpha=0,this.depthFunc=3,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=519,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Sg,this.stencilZFail=Sg,this.stencilZPass=Sg,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(let t in e){let i=e[t];if(i===void 0){de(`Material: parameter '${t}' has value of undefined.`);continue}let r=this[t];if(r===void 0){de(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}r&&r.isColor?r.set(i):r&&r.isVector3&&i&&i.isVector3?r.copy(i):this[t]=i}}toJSON(e){let t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});let i={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};
vendor: 9,085 bytes, line 1
1i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.color&&this.color.isColor&&(i.color=this.color.getHex()),this.roughness!==void 0&&(i.roughness=this.roughness),this.metalness!==void 0&&(i.metalness=this.metalness),this.sheen!==void 0&&(i.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(i.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(i.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(i.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(i.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(i.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(i.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(i.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(i.shininess=this.shininess),this.clearcoat!==void 0&&(i.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(i.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(i.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(i.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(i.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,i.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(i.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(i.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),this.dispersion!==void 0&&(i.dispersion=this.dispersion),this.iridescence!==void 0&&(i.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(i.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(i.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(i.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(i.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(i.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(i.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(i.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(i.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(i.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(i.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(i.lightMap=this.lightMap.toJSON(e).uuid,i.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(i.aoMap=this.aoMap.toJSON(e).uuid,i.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(i.bumpMap=this.bumpMap.toJSON(e).uuid,i.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(i.normalMap=this.normalMap.toJSON(e).uuid,i.normalMapType=this.normalMapType,i.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(i.displacementMap=this.displacementMap.toJSON(e).uuid,i.displacementScale=this.displacementScale,i.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(i.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(i.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(i.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(i.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(i.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(i.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(i.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(i.combine=this.combine)),this.envMapRotation!==void 0&&(i.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(i.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(i.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(i.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(i.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(i.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(i.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(i.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(i.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(i.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(i.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(i.size=this.size),this.shadowSide!==null&&(i.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(i.sizeAttenuation=this.sizeAttenuation),this.blending!==1&&(i.blending=this.blending),this.side!==0&&(i.side=this.side),this.vertexColors===!0&&(i.vertexColors=!0),this.opacity<1&&(i.opacity=this.opacity),this.transparent===!0&&(i.transparent=!0),this.blendSrc!==204&&(i.blendSrc=this.blendSrc),this.blendDst!==205&&(i.blendDst=this.blendDst),this.blendEquation!==100&&(i.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(i.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(i.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(i.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(i.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(i.blendAlpha=this.blendAlpha),this.depthFunc!==3&&(i.depthFunc=this.depthFunc),this.depthTest===!1&&(i.depthTest=this.depthTest),this.depthWrite===!1&&(i.depthWrite=this.depthWrite),this.colorWrite===!1&&(i.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(i.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==519&&(i.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(i.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(i.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==7680&&(i.stencilFail=this.stencilFail),this.stencilZFail!==7680&&(i.stencilZFail=this.stencilZFail),this.stencilZPass!==7680&&(i.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(i.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(i.rotation=this.rotation),this.polygonOffset===!0&&(i.polygonOffset=!0),this.polygonOffsetFactor!==0&&(i.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(i.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(i.linewidth=this.linewidth),this.dashSize!==void 0&&(i.dashSize=this.dashSize),this.gapSize!==void 0&&(i.gapSize=this.gapSize),this.scale!==void 0&&(i.scale=this.scale),this.dithering===!0&&(i.dithering=!0),this.alphaTest>0&&(i.alphaTest=this.alphaTest),this.alphaHash===!0&&(i.alphaHash=!0),this.alphaToCoverage===!0&&(i.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(i.premultipliedAlpha=!0),this.forceSinglePass===!0&&(i.forceSinglePass=!0),this.allowOverride===!1&&(i.allowOverride=!1),this.wireframe===!0&&(i.wireframe=!0),this.wireframeLinewidth>1&&(i.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(i.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(i.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(i.flatShading=!0),this.visible===!1&&(i.visible=!1),this.toneMapped===!1&&(i.toneMapped=!1),this.fog===!1&&(i.fog=!1),Object.keys(this.userData).length>0&&(i.userData=this.userData);function r(s){let n=[];for(let a in s){let o=s[a];delete o.metadata,n.push(o)}return n}if(t){let s=r(e.textures),n=r(e.images);s.length>0&&(i.textures=s),n.length>0&&(i.images=n)}return i}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,i=null;if(t!==null){let r=t.length;i=Array(r);for(let s=0;s!==r;++s)i[s]=t[s].clone()}return this.clippingPlanes=i,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipSh
vendor: 4,505 bytes, line 1
1adows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.allowOverride=e.allowOverride,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}},wM=class extends xs{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new Ke(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}},qu,zc=new F,Xu=new F,Yu=new F,Ku=new ge,Gc=new ge,SM=new $e,Ig=new F,jc=new F,Fg=new F,MM=new ge,fx=new ge,CM=new ge,i4=class extends dr{constructor(e=new wM){if(super(),this.isSprite=!0,this.type="Sprite",qu===void 0){qu=new $r;let t=new mx(new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),5);qu.setIndex([0,1,2,0,2,3]),qu.setAttribute("position",new gx(t,3,0,!1)),qu.setAttribute("uv",new gx(t,2,3,!1))}this.geometry=qu,this.material=e,this.center=new ge(.5,.5),this.count=1}raycast(e,t){e.camera===null&&re('Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),Xu.setFromMatrixScale(this.matrixWorld),SM.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),Yu.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&Xu.multiplyScalar(-Yu.z);let i=this.material.rotation,r,s;i!==0&&(s=Math.cos(i),r=Math.sin(i));let n=this.center;Dg(Ig.set(-.5,-.5,0),Yu,n,Xu,r,s),Dg(jc.set(.5,-.5,0),Yu,n,Xu,r,s),Dg(Fg.set(.5,.5,0),Yu,n,Xu,r,s),MM.set(0,0),fx.set(1,0),CM.set(1,1);let a=e.ray.intersectTriangle(Ig,jc,Fg,!1,zc);if(a===null&&(Dg(jc.set(-.5,.5,0),Yu,n,Xu,r,s),fx.set(0,1),a=e.ray.intersectTriangle(Ig,Fg,jc,!1,zc),a===null))return;let o=e.ray.origin.distanceTo(zc);o<e.near||o>e.far||t.push({distance:o,point:zc.clone(),uv:Gu.getInterpolation(zc,Ig,jc,Fg,MM,fx,CM,new ge),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 Dg(e,t,i,r,s,n){Ku.subVectors(e,i).addScalar(.5).multiply(r),s===void 0?Gc.copy(Ku):(Gc.x=n*Ku.x-s*Ku.y,Gc.y=s*Ku.x+n*Ku.y),e.copy(t),e.x+=Gc.x,e.y+=Gc.y,e.applyMatrix4(SM)}var $a=new F,yx=new F,Og=new F,jo=new F,xx=new F,Bg=new F,vx=new F,bx=class{constructor(e=new F,t=new F(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,$a)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);let i=t.dot(this.direction);return i<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,i)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){let t=$a.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):($a.copy(this.origin).addScaledVector(this.direction,t),$a.distanceToSquared(e))}distanceSqToSegment(e,t,i,r){yx.copy(e).add(t).multiplyScalar(.5),Og.copy(t).sub(e).normalize(),jo.copy(this.origin).sub(yx);let s=e.distanceTo(t)*.5,n=-this.direction.dot(Og),a=jo.dot(this.direction),o=-jo.dot(Og),l=jo.lengthSq(),h=Math.abs(1-n*n),u,d,c,p;if(h>0)if(u=n*o-a,d=n*a-o,p=s*h,u>=0)if(d>=-p)if(d<=p){let m=1/h;u*=m,d*=m,c=u*(u+n*d+2*a)+d*(n*u+d+2*o)+l}else d=s,u=Math.max(0,-(n*d+a)),c=-u*u+d*(d+2*o)+l;else d=-s,u=Math.max(0,-(n*d+a)),c=-u*u+d*(d+2*o)+l;else d<=-p?(u=Math.max(0,-(-n*s+a)),d=u>0?-s:Math.min(Math.max(-s,-o),s),c=-u*u+d*(d+2*o)+l):d<=p?(u=0,d=Math.min(Math.max(-s,-o),s),c=d*(d+2*o)+l):(u=Math.max(0,-(n*s+a)),d=u>0?s:Math.min(Math.max(-s,-o),s),c=-u*u+d*(d+2*o)+l);else d=n>0?-s:s,u=Math.max(0,-(n*d+a)),c=-u*u+d*(d+2*o)+l;
vendor: 10,493 bytes, line 1
1return i&&i.copy(this.origin).addScaledVector(this.direction,u),r&&r.copy(yx).addScaledVector(Og,d),c}intersectSphere(e,t){$a.subVectors(e.center,this.origin);let i=$a.dot(this.direction),r=$a.dot($a)-i*i,s=e.radius*e.radius;if(r>s)return null;let n=Math.sqrt(s-r),a=i-n,o=i+n;return o<0?null:a<0?this.at(o,t):this.at(a,t)}intersectsSphere(e){return e.radius<0?!1: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 i=-(this.origin.dot(e.normal)+e.constant)/t;return i>=0?i:null}intersectPlane(e,t){let i=this.distanceToPlane(e);return i===null?null:this.at(i,t)}intersectsPlane(e){let t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let i,r,s,n,a,o,l=1/this.direction.x,h=1/this.direction.y,u=1/this.direction.z,d=this.origin;return l>=0?(i=(e.min.x-d.x)*l,r=(e.max.x-d.x)*l):(i=(e.max.x-d.x)*l,r=(e.min.x-d.x)*l),h>=0?(s=(e.min.y-d.y)*h,n=(e.max.y-d.y)*h):(s=(e.max.y-d.y)*h,n=(e.min.y-d.y)*h),i>n||s>r||((s>i||isNaN(i))&&(i=s),(n<r||isNaN(r))&&(r=n),u>=0?(a=(e.min.z-d.z)*u,o=(e.max.z-d.z)*u):(a=(e.max.z-d.z)*u,o=(e.min.z-d.z)*u),i>o||a>r)||((a>i||i!==i)&&(i=a),(o<r||r!==r)&&(r=o),r<0)?null:this.at(i>=0?i:r,t)}intersectsBox(e){return this.intersectBox(e,$a)!==null}intersectTriangle(e,t,i,r,s){xx.subVectors(t,e),Bg.subVectors(i,e),vx.crossVectors(xx,Bg);let n=this.direction.dot(vx),a;if(n>0){if(r)return null;a=1}else if(n<0)a=-1,n=-n;else return null;jo.subVectors(this.origin,e);let o=a*this.direction.dot(Bg.crossVectors(jo,Bg));if(o<0)return null;let l=a*this.direction.dot(xx.cross(jo));if(l<0||o+l>n)return null;let h=-a*jo.dot(vx);return h<0?null:this.at(h/n,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)}},ji=class extends xs{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Ke(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 In,this.combine=0,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}},RM=new $e,yh=new bx,Ug=new ja,EM=new F,Vg=new F,zg=new F,Gg=new F,_x=new F,jg=new F,AM=new F,$g=new F,xt=class extends dr{constructor(e=new $r,t=new ji){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){let e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){let i=e[t[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,s=i.length;r<s;r++){let n=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[n]=r}}}}getVertexPosition(e,t){let i=this.geometry,r=i.attributes.position,s=i.morphAttributes.position,n=i.morphTargetsRelative;t.fromBufferAttribute(r,e);let a=this.morphTargetInfluences;if(s&&a){jg.set(0,0,0);for(let o=0,l=s.length;o<l;o++){let h=a[o],u=s[o];h!==0&&(_x.fromBufferAttribute(u,e),n?jg.addScaledVector(_x,h):jg.addScaledVector(_x.sub(t),h))}t.add(jg)}return t}raycast(e,t){let i=this.geometry,r=this.material,s=this.matrixWorld;r!==void 0&&(i.boundingSphere===null&&i.computeBoundingSphere(),Ug.copy(i.boundingSphere),Ug.applyMatrix4(s),yh.copy(e.ray).recast(e.near),!(Ug.containsPoint(yh.origin)===!1&&(yh.intersectSphere(Ug,EM)===null||yh.origin.distanceToSquared(EM)>(e.far-e.near)**2))&&(RM.copy(s).invert(),yh.copy(e.ray).applyMatrix4(RM),!(i.boundingBox!==null&&yh.intersectsBox(i.boundingBox)===!1)&&this._computeIntersections(e,t,yh)))}_computeIntersections(e,t,i){let r,s=this.geometry,n=this.material,a=s.index,o=s.attributes.position,l=s.attributes.uv,h=s.attributes.uv1,u=s.attributes.normal,d=s.groups,c=s.drawRange;if(a!==null)if(Array.isArray(n))for(let p=0,m=d.length;p<m;p++){let g=d[p],f=n[g.materialIndex],y=Math.max(g.start,c.start),x=Math.min(a.count,Math.min(g.start+g.count,c.start+c.count));for(let b=y,_=x;b<_;b+=3){let T=a.getX(b),w=a.getX(b+1),M=a.getX(b+2);r=Wg(this,f,e,i,l,h,u,T,w,M),r&&(r.faceIndex=Math.floor(b/3),r.face.materialIndex=g.materialIndex,t.push(r))}}else{let p=Math.max(0,c.start),m=Math.min(a.count,c.start+c.count);for(let g=p,f=m;g<f;g+=3){let y=a.getX(g),x=a.getX(g+1),b=a.getX(g+2);r=Wg(this,n,e,i,l,h,u,y,x,b),r&&(r.faceIndex=Math.floor(g/3),t.push(r))}}else if(o!==void 0)if(Array.isArray(n))for(let p=0,m=d.length;p<m;p++){let g=d[p],f=n[g.materialIndex],y=Math.max(g.start,c.start),x=Math.min(o.count,Math.min(g.start+g.count,c.start+c.count));for(let b=y,_=x;b<_;b+=3){let T=b,w=b+1,M=b+2;r=Wg(this,f,e,i,l,h,u,T,w,M),r&&(r.faceIndex=Math.floor(b/3),r.face.materialIndex=g.materialIndex,t.push(r))}}else{let p=Math.max(0,c.start),m=Math.min(o.count,c.start+c.count);for(let g=p,f=m;g<f;g+=3){let y=g,x=g+1,b=g+2;r=Wg(this,n,e,i,l,h,u,y,x,b),r&&(r.faceIndex=Math.floor(g/3),t.push(r))}}}};function r4(e,t,i,r,s,n,a,o){let l;if(l=t.side===1?r.intersectTriangle(a,n,s,!0,o):r.intersectTriangle(s,n,a,t.side===0,o),l===null)return null;$g.copy(o),$g.applyMatrix4(e.matrixWorld);let h=i.ray.origin.distanceTo($g);return h<i.near||h>i.far?null:{distance:h,point:$g.clone(),object:e}}function Wg(e,t,i,r,s,n,a,o,l,h){e.getVertexPosition(o,Vg),e.getVertexPosition(l,zg),e.getVertexPosition(h,Gg);let u=r4(e,t,i,r,Vg,zg,Gg,AM);if(u){let d=new F;Gu.getBarycoord(AM,Vg,zg,Gg,d),s&&(u.uv=Gu.getInterpolatedAttribute(s,o,l,h,d,new ge)),n&&(u.uv1=Gu.getInterpolatedAttribute(n,o,l,h,d,new ge)),a&&(u.normal=Gu.getInterpolatedAttribute(a,o,l,h,d,new F),u.normal.dot(r.direction)>0&&u.normal.multiplyScalar(-1));let c={a:o,b:l,c:h,normal:new F,materialIndex:0};Gu.getNormal(Vg,zg,Gg,c.normal),u.face=c,u.barycoord=d}return u}var Tx=class extends Li{constructor(e=null,t=1,i=1,r,s,n,a,o,l=lr,h=lr,u,d){super(null,n,a,o,l,h,r,s,u,d),this.isDataTexture=!0,this.image={data:e,width:t,height:i},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},cr=class extends jr{constructor(e,t,i,r=1){super(e,t,i),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}},Zu=new $e,NM=new $e,Hg=[],LM=new Fn,s4=new $e,$c=new xt,Wc=new ja,wx=class extends xt{constructor(e,t,i){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new cr(new Float32Array(i*16),16),this.previousInstanceMatrix=null,this.instanceColor=null,this.morphTexture=null,this.count=i,this.boundingBox=null,this.boundingSphere=null;for(let r=0;r<i;r++)this.setMatrixAt(r,s4)}computeBoundingBox(){let e=this.geometry,t=this.count;this.boundingBox===null&&(this.boundingBox=new Fn),e.boundingBox===null&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let i=0;i<t;i++)this.getMatrixAt(i,Zu),LM.copy(e.boundingBox).applyMatrix4(Zu),this.boundingBox.union(LM)}computeBoundingSphere(){let e=this.geometry,t=this.count;this.boundingSphere===null&&(this.boundingSphere=new ja),e.boundingSphere===null&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let i=0;i<t;i++)this.getMatrixAt(i,Zu),Wc.copy(e.boundingSphere).applyMatrix4(Zu),this.boundingSphere.union(Wc)}copy(e,t){return super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),e.previousInstanceMatrix!==null&&(this.previousInstanceMatrix=e.previousInstanceMatrix.clone()),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){return this.instanceColor===null?t.setRGB(1,1,1):t.fromArray(this.instanceColor.array,e*3)}getMatrixAt(e,t){return t.fromArray(this.instanceMatrix.array,e*16)}getMorphAt(e,t){let i=t.morphTargetInfluences,r=this.morphTexture.source.data.data,s=e*(i.length+1)+1;for(let n=0;n<i.length;n++)i[n]=r[s+n]}raycast(e,t){let i=this.matrixWorld,r=this.count;if($c.geometry=this.geometry,$c.material=this.material,$c.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),Wc.copy(this.boundingSphere),Wc.applyMatrix4(i),e.ray.intersectsSphere(Wc)!==!1))for(let s=0;s<r;s++){this.getMatrixAt(s,Zu),NM.multiplyMatrices(i,Zu),$c.matrixWorld=NM,$c.raycast(e,Hg);for(let n=0,a=Hg.length;n<a;n++){let o=Hg[n];o.instanceId=s,o.object=this,t.push(o)}Hg.length=0}}setColorAt(e,t){return this.instanceColor===null&&(this.instanceColor=new cr(new Float32Array(this.instanceMatrix.count*3).fill(1),3)),t.toArray(this.instanceColor.array,e*3),this}setMatrixAt(e,t){return t.toArray(this.instanceMatrix.array,e*16),this}setMorphAt(e,t){let i=t.morphTargetInfluences,r=i.length+1;this.morphTexture===null&&(this.morphTexture=new Tx(new Float32Array(r*this.count),r,this.count,_g,Pn));let s=this.morphTexture.source.data.data,n=0;for(let l=0;l<i.length;l++)n+=i[l];let a=this.geometry.morphTargetsRelative?1:1-n,o=r*e;return s[o]=a,s.set(i,o+1),this}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"}),this.morphTexture!==null&&(this.morphTexture.dispose(),this.morphTexture=null)}}
vendor: 13,694 bytes, line 1
1,Sx=new F,n4=new F,a4=new Os,$o=class{constructor(e=new F(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,i,r){return this.normal.set(e,t,i),this.constant=r,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,i){let r=Sx.subVectors(i,t).cross(n4.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 i=e.delta(Sx),r=this.normal.dot(i);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(i,s)}intersectsLine(e){let t=this.distanceToPoint(e.start),i=this.distanceToPoint(e.end);return t<0&&i>0||i<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){let i=t||a4.getNormalMatrix(e),r=this.coplanarPoint(Sx).applyMatrix4(e),s=this.normal.applyMatrix3(i).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)}},xh=new ja,o4=new ge(.5,.5),qg=new F,Mx=class{constructor(e=new $o,t=new $o,i=new $o,r=new $o,s=new $o,n=new $o){this.planes=[e,t,i,r,s,n]}set(e,t,i,r,s,n){let a=this.planes;return a[0].copy(e),a[1].copy(t),a[2].copy(i),a[3].copy(r),a[4].copy(s),a[5].copy(n),this}copy(e){let t=this.planes;for(let i=0;i<6;i++)t[i].copy(e.planes[i]);return this}setFromProjectionMatrix(e,t=ch,i=!1){let r=this.planes,s=e.elements,n=s[0],a=s[1],o=s[2],l=s[3],h=s[4],u=s[5],d=s[6],c=s[7],p=s[8],m=s[9],g=s[10],f=s[11],y=s[12],x=s[13],b=s[14],_=s[15];if(r[0].setComponents(l-n,c-h,f-p,_-y).normalize(),r[1].setComponents(l+n,c+h,f+p,_+y).normalize(),r[2].setComponents(l+a,c+u,f+m,_+x).normalize(),r[3].setComponents(l-a,c-u,f-m,_-x).normalize(),i)r[4].setComponents(o,d,g,b).normalize(),r[5].setComponents(l-o,c-d,f-g,_-b).normalize();else if(r[4].setComponents(l-o,c-d,f-g,_-b).normalize(),t===2e3)r[5].setComponents(l+o,c+d,f+g,_+b).normalize();else if(t===2001)r[5].setComponents(o,d,g,b).normalize();else throw Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),xh.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{let t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),xh.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(xh)}intersectsSprite(e){return xh.center.set(0,0,0),xh.radius=.7071067811865476+o4.distanceTo(e.center),xh.applyMatrix4(e.matrixWorld),this.intersectsSphere(xh)}intersectsSphere(e){let t=this.planes,i=e.center,r=-e.radius;for(let s=0;s<6;s++)if(t[s].distanceToPoint(i)<r)return!1;return!0}intersectsBox(e){let t=this.planes;for(let i=0;i<6;i++){let r=t[i];if(qg.x=r.normal.x>0?e.max.x:e.min.x,qg.y=r.normal.y>0?e.max.y:e.min.y,qg.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(qg)<0)return!1}return!0}containsPoint(e){let t=this.planes;for(let i=0;i<6;i++)if(t[i].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}},Dn=new $e,On=new Mx,l4=class QD{constructor(){this.coordinateSystem=ch}intersectsObject(t,i){if(!i.isArrayCamera||i.cameras.length===0)return!1;for(let r=0;r<i.cameras.length;r++){let s=i.cameras[r];if(Dn.multiplyMatrices(s.projectionMatrix,s.matrixWorldInverse),On.setFromProjectionMatrix(Dn,s.coordinateSystem,s.reversedDepth),On.intersectsObject(t))return!0}return!1}intersectsSprite(t,i){if(!i||!i.cameras||i.cameras.length===0)return!1;for(let r=0;r<i.cameras.length;r++){let s=i.cameras[r];if(Dn.multiplyMatrices(s.projectionMatrix,s.matrixWorldInverse),On.setFromProjectionMatrix(Dn,s.coordinateSystem,s.reversedDepth),On.intersectsSprite(t))return!0}return!1}intersectsSphere(t,i){if(!i||!i.cameras||i.cameras.length===0)return!1;for(let r=0;r<i.cameras.length;r++){let s=i.cameras[r];if(Dn.multiplyMatrices(s.projectionMatrix,s.matrixWorldInverse),On.setFromProjectionMatrix(Dn,s.coordinateSystem,s.reversedDepth),On.intersectsSphere(t))return!0}return!1}intersectsBox(t,i){if(!i||!i.cameras||i.cameras.length===0)return!1;for(let r=0;r<i.cameras.length;r++){let s=i.cameras[r];if(Dn.multiplyMatrices(s.projectionMatrix,s.matrixWorldInverse),On.setFromProjectionMatrix(Dn,s.coordinateSystem,s.reversedDepth),On.intersectsBox(t))return!0}return!1}containsPoint(t,i){if(!i||!i.cameras||i.cameras.length===0)return!1;for(let r=0;r<i.cameras.length;r++){let s=i.cameras[r];if(Dn.multiplyMatrices(s.projectionMatrix,s.matrixWorldInverse),On.setFromProjectionMatrix(Dn,s.coordinateSystem,s.reversedDepth),On.containsPoint(t))return!0}return!1}clone(){return new QD}},PM=class extends xs{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Ke(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}},h4=class extends xs{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new Ke(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}},Cx=class extends Li{constructor(e,t){super({width:e,height:t}),this.isFramebufferTexture=!0,this.magFilter=lr,this.minFilter=lr,this.generateMipmaps=!1,this.needsUpdate=!0}},Xg=class extends Li{constructor(e=[],t=301,i,r,s,n,a,o,l,h){super(e,t,i,r,s,n,a,o,l,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}},u4=class extends Li{constructor(e,t,i,r,s,n,a,o,l){super(e,t,i,r,s,n,a,o,l),this.isCanvasTexture=!0,this.needsUpdate=!0}},Us=class extends Li{constructor(e,t,i=ur,r,s,n,a=lr,o=lr,l,h=Da,u=1){if(h!==1026&&h!==1027)throw Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");super({width:e,height:t,depth:u},r,s,n,a,o,h,i,l),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new Q1(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){let t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}},d4=class extends Us{constructor(e,t=ur,i=301,r,s,n=lr,a=lr,o,l=Da){let h={width:e,height:e,depth:1},u=[h,h,h,h,h,h];super(e,e,t,i,r,s,n,a,o,l),this.image=u,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}},kM=class eO extends $r{constructor(t=1,i=1,r=1,s=1,n=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:t,height:i,depth:r,widthSegments:s,heightSegments:n,depthSegments:a};let o=this;s=Math.floor(s),n=Math.floor(n),a=Math.floor(a);let l=[],h=[],u=[],d=[],c=0,p=0;m("z","y","x",-1,-1,r,i,t,a,n,0),m("z","y","x",1,-1,r,i,-t,a,n,1),m("x","z","y",1,1,t,r,i,s,a,2),m("x","z","y",1,-1,t,r,-i,s,a,3),m("x","y","z",1,-1,t,i,r,s,n,4),m("x","y","z",-1,-1,t,i,-r,s,n,5),this.setIndex(l),this.setAttribute("position",new Ht(h,3)),this.setAttribute("normal",new Ht(u,3)),this.setAttribute("uv",new Ht(d,2));function m(g,f,y,x,b,_,T,w,M,S,R){let I=_/M,B=T/S,O=_/2,U=T/2,V=w/2,z=M+1,Z=S+1,j=0,ae=0,W=new F;for(let me=0;me<Z;me++){let Ce=me*B-U;for(let Qe=0;Qe<z;Qe++)W[g]=(Qe*I-O)*x,W[f]=Ce*b,W[y]=V,h.push(W.x,W.y,W.z),W[g]=0,W[f]=0,W[y]=w>0?1:-1,u.push(W.x,W.y,W.z),d.push(Qe/M),d.push(1-me/S),j+=1}for(let me=0;me<S;me++)for(let Ce=0;Ce<M;Ce++){let Qe=c+Ce+z*me,oe=c+Ce+z*(me+1),dt=c+(Ce+1)+z*(me+1),et=c+(Ce+1)+z*me;l.push(Qe,oe,et),l.push(oe,dt,et),ae+=6}o.addGroup(p,ae,R),p+=ae,c+=j}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new eO(t.width,t.height,t.depth,t.widthSegments,t.heightSegments,t.depthSegments)}},c4=class tO extends $r{constructor(t=1,i=32,r=0,s=Math.PI*2){super(),this.type="CircleGeometry",this.parameters={radius:t,segments:i,thetaStart:r,thetaLength:s},i=Math.max(3,i);let n=[],a=[],o=[],l=[],h=new F,u=new ge;a.push(0,0,0),o.push(0,0,1),l.push(.5,.5);for(let d=0,c=3;d<=i;d++,c+=3){let p=r+d/i*s;h.x=t*Math.cos(p),h.y=t*Math.sin(p),a.push(h.x,h.y,h.z),o.push(0,0,1),u.x=(a[c]/t+1)/2,u.y=(a[c+1]/t+1)/2,l.push(u.x,u.y)}for(let d=1;d<=i;d++)n.push(d,d+1,0);this.setIndex(n),this.setAttribute("position",new Ht(a,3)),this.setAttribute("normal",new Ht(o,3)),this.setAttribute("uv",new Ht(l,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new tO(t.radius,t.segments,t.thetaStart,t.thetaLength)}},p4=class iO extends $r{constructor(t=1,i=1,r=1,s=32,n=1,a=!1,o=0,l=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:t,radiusBottom:i,height:r,radialSegments:s,heightSegments:n,openEnded:a,thetaStart:o,thetaLength:l};let h=this;s=Math.floor(s),n=Math.floor(n);let u=[],d=[],c=[],p=[],m=0,g=[],f=r/2,y=0;x(),a===!1&&(t>0&&b(!0),i>0&&b(!1)),this.setIndex(u),this.setAttribute("position",new Ht(d,3)),this.setAttribute("normal",new Ht(c,3)),this.setAttribute("uv",new Ht(p,2));function x(){let _=new F,T=new F,w=0,M=(i-t)/r;for(let S=0;S<=n;S++){let R=[],I=S/n,B=I*(i-t)+t;for(let O=0;O<=s;O++){let U=O/s,V=U*l+o,z=Math.sin(V),Z=Math.cos(V);T.x=B*z,T.y=-I*r+f,T.z=B*Z,d.push(T.x,T.y,T.z),_.set(z,M,Z).normalize(),c.push(_.x,_.y,_.z),p.push(U,1-I),R.push(m++)}g.push(R)}for(let S=0;S<s;S++)for(let R=0;R<n;R++){let I=g[R][S],B=g[R+1][S],O=g[R+1][S+1],U=g[R][S+1];(t>0||R!==0)&&(u.push(I,B,U),w+=3),(i>0||R!==n-1)&&(u.push(B,O,U),w+=3)}h.addGroup(y,w,0),y+=w}function b(_){let T=m,w=new ge,M=new F,S=0,R=_===!0?t:i,I=_===!0?1:-1;for(let O=1;O<=s;O++)d.push(0,f*I,0),c.push(0,I,0),p.push(.5,.5),m++;let B=m;for(let O=0;O<=s;O++){let U=O/s*l+o,V=Math.cos(U),z=Math.sin(U);M.x=R*z,M.y=f*I,M.z=R*V,d.push(M.x,M.y,M.z),c.push(0,I,0),w.x=V*.5+.5,w.y=z*.5*I+.5,p.push(w.x,w.y),m++}for(let O=0;O<s;O++){let U=T+O,V=B+O;_===!0?u.push(V,V+1,U):u.push(V+1,V,U),S+=3}h.addGroup(y,S,_===!0?1:2),y+=S}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new iO(t.radiusTop,t.radiusBottom,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}},Bn=class{constructor(){this.type="Curve",this.arcLengthDivisions=200,this.needsUpdate=!1,this.cacheArcLengths=null}getPoint(){de("Curve: .getPoint() not implemented.")}getPointAt(e,t){let i=this.getUtoTmapping(e);return this.getPoint(i,t)}getPoints(e=5){let t=[];for(let i=0;i<=e;i++)t.push(this.getPoint(i/e));return t}getSpacedPoints(e=5){let t=[];for(let i=0;i<=e;i++)t.push(this.getPointAt(i/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=[],i,r=this.getPoint(0),s=0;t.push(0);for(let n=1;n<=e;n++)i=this.getPoint(n/e),s+=i.distanceTo(r),t.push(s),r=i;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t=null){let i=this.getLengths(),r=0,s=i.length,n;n=t||e*i[s-1];let a=0,o=s-1,l;for(;a<=o;)if(r=Math.floor(a+(o-a)/2),l=i[r]-n,l<0)a=r+1;else if(l>0)o=r-1;else{o=r;break}if(r=o,i[r]===n)return r/(s-1);let h=i[r],u=i[r+1]-h,d=(n-h)/u;return(r+d)/(s-1)}getTangent(e,t){let i=1e-4,r=e-i,s=e+i;r<0&&(r=0),s>1&&(s=1);let n=this.getPoint(r),a=this.getPoint(s),o=t||(n.isVector2?new ge:new F);return o.copy(a).sub(n).normalize(),o}getTangentAt(e,t){let i=this.getUtoTmapping(e);return this.getTangent(i,t)}computeFrenetFrames(e,t=!1){let i=new F,r=[],s=[],n=[],a=new F,o=new $e;for(let c=0;c<=e;c++){let p=c/e;r[c]=this.getTangentAt(p,new F)}s[0]=new F,n[0]=new F;let l=Number.MAX_VALUE,h=Math.abs(r[0].x),u=Math.abs(r[0].y),d=Math.abs(r[0].z);h<=l&&(l=h,i.set(1,0,0)),u<=l&&(l=u,i.set(0,1,0)),d<=l&&i.set(0,0,1),a.crossVectors(r[0],i).normalize(),s[0].crossVectors(r[0],a),n[0].crossVectors(r[0],s[0]);for(let c=1;c<=e;c++){if(s[c]=s[c-1].clone(),n[c]=n[c-1].clone(),a.crossVectors(r[c-1],r[c]),a.length()>2**-52){a.normalize();let p=Math.acos(He(r[c-1].dot(r[c]),-1,1));s[c].applyMatrix4(o.makeRotationAxis(a,p))}n[c].crossVectors(r[c],s[c])}if(t===!0){let c=Math.acos(He(s[0].dot(s[e]),-1,1));c/=e,r[0].dot(a.crossVectors(s[0],s[e]))>0&&(c=-c);for(let p=1;p<=e;p++)s[p].applyMatrix4(o.makeRotationAxis(r[p],c*p)),n[p].crossVectors(r[p],s[p])}return{tangents:r,normals:s,binormals:n}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){let e={metadata:{version:4.7,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.t
vendor: 5,921 bytes, line 1
1ype,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}},Rx=class extends Bn{constructor(e=0,t=0,i=1,r=1,s=0,n=Math.PI*2,a=!1,o=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=i,this.yRadius=r,this.aStartAngle=s,this.aEndAngle=n,this.aClockwise=a,this.aRotation=o}getPoint(e,t=new ge){let i=t,r=Math.PI*2,s=this.aEndAngle-this.aStartAngle,n=Math.abs(s)<2**-52;for(;s<0;)s+=r;for(;s>r;)s-=r;s<2**-52&&(s=n?0:r),this.aClockwise===!0&&!n&&(s===r?s=-r:s-=r);let a=this.aStartAngle+e*s,o=this.aX+this.xRadius*Math.cos(a),l=this.aY+this.yRadius*Math.sin(a);if(this.aRotation!==0){let h=Math.cos(this.aRotation),u=Math.sin(this.aRotation),d=o-this.aX,c=l-this.aY;o=d*h-c*u+this.aX,l=d*u+c*h+this.aY}return i.set(o,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}},m4=class extends Rx{constructor(e,t,i,r,s,n){super(e,t,i,i,r,s,n),this.isArcCurve=!0,this.type="ArcCurve"}};function Ex(){let e=0,t=0,i=0,r=0;function s(n,a,o,l){e=n,t=o,i=-3*n+3*a-2*o-l,r=2*n-2*a+o+l}return{initCatmullRom:function(n,a,o,l,h){s(a,o,h*(o-n),h*(l-a))},initNonuniformCatmullRom:function(n,a,o,l,h,u,d){let c=(a-n)/h-(o-n)/(h+u)+(o-a)/u,p=(o-a)/u-(l-a)/(u+d)+(l-o)/d;c*=u,p*=u,s(a,o,c,p)},calc:function(n){let a=n*n,o=a*n;return e+t*n+i*a+r*o}}}var Yg=new F,Ax=new Ex,Nx=new Ex,Lx=new Ex,g4=class extends Bn{constructor(e=[],t=!1,i="centripetal",r=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=e,this.closed=t,this.curveType=i,this.tension=r}getPoint(e,t=new F){let i=t,r=this.points,s=r.length,n=(s-+!this.closed)*e,a=Math.floor(n),o=n-a;this.closed?a+=a>0?0:(Math.floor(Math.abs(a)/s)+1)*s:o===0&&a===s-1&&(a=s-2,o=1);let l,h;this.closed||a>0?l=r[(a-1)%s]:(Yg.subVectors(r[0],r[1]).add(r[0]),l=Yg);let u=r[a%s],d=r[(a+1)%s];if(this.closed||a+2<s?h=r[(a+2)%s]:(Yg.subVectors(r[s-1],r[s-2]).add(r[s-1]),h=Yg),this.curveType==="centripetal"||this.curveType==="chordal"){let c=this.curveType==="chordal"?.5:.25,p=l.distanceToSquared(u)**+c,m=u.distanceToSquared(d)**+c,g=d.distanceToSquared(h)**+c;m<1e-4&&(m=1),p<1e-4&&(p=m),g<1e-4&&(g=m),Ax.initNonuniformCatmullRom(l.x,u.x,d.x,h.x,p,m,g),Nx.initNonuniformCatmullRom(l.y,u.y,d.y,h.y,p,m,g),Lx.initNonuniformCatmullRom(l.z,u.z,d.z,h.z,p,m,g)}else this.curveType==="catmullrom"&&(Ax.initCatmullRom(l.x,u.x,d.x,h.x,this.tension),Nx.initCatmullRom(l.y,u.y,d.y,h.y,this.tension),Lx.initCatmullRom(l.z,u.z,d.z,h.z,this.tension));return i.set(Ax.calc(o),Nx.calc(o),Lx.calc(o)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t<i;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,i=this.points.length;t<i;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,i=e.points.length;t<i;t++){let r=e.points[t];this.points.push(new F().fromArray(r))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}};function IM(e,t,i,r,s){let n=(r-t)*.5,a=(s-i)*.5,o=e*e,l=e*o;return(2*i-2*r+n+a)*l+(-3*i+3*r-2*n-a)*o+n*e+i}function f4(e,t){let i=1-e;return i*i*t}function y4(e,t){return 2*(1-e)*e*t}function x4(e,t){return e*e*t}function Hc(e,t,i,r){return f4(e,t)+y4(e,i)+x4(e,r)}function v4(e,t){let i=1-e;return i*i*i*t}function b4(e,t){let i=1-e;return 3*i*i*e*t}function _4(e,t){return 3*(1-e)*e*e*t}function T4(e,t){return e*e*e*t}function qc(e,t,i,r,s){return v4(e,t)+b4(e,i)+_4(e,r)+T4(e,s)}var FM=class extends Bn{constructor(e=new ge,t=new ge,i=new ge,r=new ge){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=i,this.v3=r}getPoint(e,t=new ge){let i=t,r=this.v0,s=this.v1,n=this.v2,a=this.v3;return i.set(qc(e,r.x,s.x,n.x,a.x),qc(e,r.y,s.y,n.y,a.y)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.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}},w4=class extends Bn{constructor(e=new F,t=new F,i=new F,r=new F){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=i,this.v3=r}getPoint(e,t=new F){let i=t,r=this.v0,s=this.v1,n=this.v2,a=this.v3;return i.set(qc(e,r.x,s.x,n.x,a.x),qc(e,r.y,s.y,n.y,a.y),qc(e,r.z,s.z,n.z,a.z)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.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}},DM=class extends Bn{constructor(e=new ge,t=new ge){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new ge){let i=t;return e===1?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(e).add(this.v1)),i}getPointAt(e,t){return this.getPoint(e,t)}
vendor: 4,513 bytes, line 1
1getTangent(e,t=new ge){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}},S4=class extends Bn{constructor(e=new F,t=new F){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=e,this.v2=t}getPoint(e,t=new F){let i=t;return e===1?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(e).add(this.v1)),i}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new F){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}},OM=class extends Bn{constructor(e=new ge,t=new ge,i=new ge){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new ge){let i=t,r=this.v0,s=this.v1,n=this.v2;return i.set(Hc(e,r.x,s.x,n.x),Hc(e,r.y,s.y,n.y)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){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}},M4=class extends Bn{constructor(e=new F,t=new F,i=new F){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new F){let i=t,r=this.v0,s=this.v1,n=this.v2;return i.set(Hc(e,r.x,s.x,n.x),Hc(e,r.y,s.y,n.y),Hc(e,r.z,s.z,n.z)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){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}},BM=class extends Bn{constructor(e=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=e}getPoint(e,t=new ge){let i=t,r=this.points,s=(r.length-1)*e,n=Math.floor(s),a=s-n,o=r[n===0?n:n-1],l=r[n],h=r[n>r.length-2?r.length-1:n+1],u=r[n>r.length-3?r.length-1:n+2];return i.set(IM(a,o.x,l.x,h.x,u.x),IM(a,o.y,l.y,h.y,u.y)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let r=e.points[t];this.points.push(r.clone())}return this}toJSON(){let e=super.toJSON();e.points=[];for(let t=0,i=this.points.length;t<i;t++){let r=this.points[t];e.points.push(r.toArray())}return e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let r=e.points[t];this.points.push(new ge().fromArray(r))}return this}},UM=Object.freeze({__proto__:null,ArcCurve:m4,CatmullRomCurve3:g4,CubicBezierCurve:FM,CubicBezierCurve3:w4,EllipseCurve:Rx,LineCurve:DM,LineCurve3:S4,QuadraticBezierCurve:OM,QuadraticBezierCurve3:M4,SplineCurve:BM}),C4=class extends Bn{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 i=e.isVector2===!0?"LineCurve":"LineCurve3";this.curves.push(new UM[i](t,e))}return this}getPoint(e,t){let i=e*this.getLength(),r=this.getCurveLengths(),s=0;for(;s<r.length;){if(r[s]>=i){let n=r[s]-i,a=this.curves[s],o=a.getLength(),l=o===0?0:1-n/o;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 i=0,r=this.curves.length;i<r;i++)t+=this.curves[i].getLength(),e.push(t);return this.cacheLengths=e,e}getSpacedPoints(e=40){let t=[];for(let i=0;i<=e;i++)t.push(this.getPoint(i/e));return this.autoClose&&t.push(t[0]),t}getPoints(e=12){let t=[],i;for(let r=0,s=this.curves;r<s.length;r++){let n=s[r],a=n.isEllipseCurve?e*2:n.isLineCurve||n.isLineCurve3?1:n.isSplineCurve?e*n.points.length:e,o=n.getPoints(a);for(let l=0;l<o.length;l++){let h=o[l];i&&i.equals(h)||(t.push(h),i=h)}}return this.autoClose&&t.length>
vendor: 9,322 bytes, line 1
11&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,i=e.curves.length;t<i;t++){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,i=this.curves.length;t<i;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,i=e.curves.length;t<i;t++){let r=e.curves[t];this.curves.push(new UM[r.type]().fromJSON(r))}return this}},Px=class extends C4{constructor(e){super(),this.type="Path",this.currentPoint=new ge,e&&this.setFromPoints(e)}setFromPoints(e){this.moveTo(e[0].x,e[0].y);for(let t=1,i=e.length;t<i;t++)this.lineTo(e[t].x,e[t].y);return this}moveTo(e,t){return this.currentPoint.set(e,t),this}lineTo(e,t){let i=new DM(this.currentPoint.clone(),new ge(e,t));return this.curves.push(i),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,i,r){let s=new OM(this.currentPoint.clone(),new ge(e,t),new ge(i,r));return this.curves.push(s),this.currentPoint.set(i,r),this}bezierCurveTo(e,t,i,r,s,n){let a=new FM(this.currentPoint.clone(),new ge(e,t),new ge(i,r),new ge(s,n));return this.curves.push(a),this.currentPoint.set(s,n),this}splineThru(e){let t=new BM([this.currentPoint.clone()].concat(e));return this.curves.push(t),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,i,r,s,n){let a=this.currentPoint.x,o=this.currentPoint.y;return this.absarc(e+a,t+o,i,r,s,n),this}absarc(e,t,i,r,s,n){return this.absellipse(e,t,i,i,r,s,n),this}ellipse(e,t,i,r,s,n,a,o){let l=this.currentPoint.x,h=this.currentPoint.y;return this.absellipse(e+l,t+h,i,r,s,n,a,o),this}absellipse(e,t,i,r,s,n,a,o){let l=new Rx(e,t,i,r,s,n,a,o);if(this.curves.length>0){let u=l.getPoint(0);u.equals(this.currentPoint)||this.lineTo(u.x,u.y)}this.curves.push(l);let h=l.getPoint(1);return this.currentPoint.copy(h),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}},Kg=class extends Px{constructor(e){super(e),this.uuid=kn(),this.type="Shape",this.holes=[]}getPointsHoles(e){let t=[];for(let i=0,r=this.holes.length;i<r;i++)t[i]=this.holes[i].getPoints(e);return t}extractPoints(e){return{shape:this.getPoints(e),holes:this.getPointsHoles(e)}}copy(e){super.copy(e),this.holes=[];for(let t=0,i=e.holes.length;t<i;t++){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,i=this.holes.length;t<i;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,i=e.holes.length;t<i;t++){let r=e.holes[t];this.holes.push(new Px().fromJSON(r))}return this}};function R4(e,t,i=2){let r=t&&t.length,s=r?t[0]*i:e.length,n=VM(e,0,s,i,!0),a=[];if(!n||n.next===n.prev)return a;let o,l,h;if(r&&(n=P4(e,t,n,i)),e.length>80*i){o=e[0],l=e[1];let u=o,d=l;for(let c=i;c<s;c+=i){let p=e[c],m=e[c+1];p<o&&(o=p),m<l&&(l=m),p>u&&(u=p),m>d&&(d=m)}h=Math.max(u-o,d-l),h=h===0?0:32767/h}return Xc(n,a,i,o,l,h,0),a}function VM(e,t,i,r,s){let n;if(s===j4(e,t,i,r)>0)for(let a=t;a<i;a+=r)n=$M(a/r|0,e[a],e[a+1],n);else for(let a=i-r;a>=t;a-=r)n=$M(a/r|0,e[a],e[a+1],n);return n&&Ju(n,n.next)&&(Zc(n),n=n.next),n}function vh(e,t){if(!e)return e;t||=e;let i=e,r;do if(r=!1,!i.steiner&&(Ju(i,i.next)||si(i.prev,i,i.next)===0)){if(Zc(i),i=t=i.prev,i===i.next)break;r=!0}else i=i.next;while(r||i!==t);return t}function Xc(e,t,i,r,s,n,a){if(!e)return;!a&&n&&O4(e,r,s,n);let o=e;for(;e.prev!==e.next;){let l=e.prev,h=e.next;if(n?A4(e,r,s,n):E4(e)){t.push(l.i,e.i,h.i),Zc(e),e=h.next,o=h.next;continue}if(e=h,e===o){a?a===1?(e=N4(vh(e),t),Xc(e,t,i,r,s,n,2)):a===2&&L4(e,t,i,r,s,n):Xc(vh(e),t,i,r,s,n,1);break}}}function E4(e){let t=e.prev,i=e,r=e.next;if(si(t,i,r)>=0)return!1;let s=t.x,n=i.x,a=r.x,o=t.y,l=i.y,h=r.y,u=Math.min(s,n,a),d=Math.min(o,l,h),c=Math.max(s,n,a),p=Math.max(o,l,h),m=r.next;for(;m!==t;){if(m.x>=u&&m.x<=c&&m.y>=d&&m.y<=p&&Yc(s,o,n,l,a,h,m.x,m.y)&&si(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function A4(e,t,i,r){let s=e.prev,n=e,a=e.next;if(si(s,n,a)>=0)return!1;let o=s.x,l=n.x,h=a.x,u=s.y,d=n.y,c=a.y,p=Math.min(o,l,h),m=Math.min(u,d,c),g=Math.max(o,l,h),f=Math.max(u,d,c),y=kx(p,m,t,i,r),x=kx(g,f,t,i,r),b=e.prevZ,_=e.nextZ;for(;b&&b.z>=y&&_&&_.z<=x;){if(b.x>=p&&b.x<=g&&b.y>=m&&b.y<=f&&b!==s&&b!==a&&Yc(o,u,l,d,h,c,b.x,b.y)&&si(b.prev,b,b.next)>=0||(b=b.prevZ,_.x>=p&&_.x<=g&&_.y>=m&&_.y<=f&&_!==s&&_!==a&&Yc(o,u,l,d,h,c,_.x,_.y)&&si(_.prev,_,_.next)>=0))return!1;_=_.nextZ}for(;b&&b.z>=y;){if(b.x>=p&&b.x<=g&&b.y>=m&&b.y<=f&&b!==s&&b!==a&&Yc(o,u,l,d,h,c,b.x,b.y)&&si(b.prev,b,b.next)>=0)return!1;b=b.prevZ}for(;_&&_.z<=x;){if(_.x>=p&&_.x<=g&&_.y>=m&&_.y<=f&&_!==s&&_!==a&&Yc(o,u,l,d,h,c,_.x,_.y)&&si(_.prev,_,_.next)>=0)return!1;_=_.nextZ}return!0}function N4(e,t){let i=e;do{let r=i.prev,s=i.next.next;!Ju(r,s)&&GM(r,i,i.next,s)&&Kc(r,s)&&Kc(s,r)&&(t.push(r.i,i.i,s.i),Zc(i),Zc(i.next),i=e=s),i=i.next}while(i!==e);return vh(i)}function L4(e,t,i,r,s,n){let a=e;do{let o=a.next.next;for(;o!==a.prev;){if(a.i!==o.i&&V4(a,o)){let l=jM(a,o);a=vh(a,a.next),l=vh(l,l.next),Xc(a,t,i,r,s,n,0),Xc(l,t,i,r,s,n,0);return}o=o.next}a=a.next}while(a!==e)}function P4(e,t,i,r){let s=[];for(let n=0,a=t.length;n<a;n++){let o=VM(e,t[n]*r,n<a-1?t[n+1]*r:e.length,r,!1);o===o.next&&(o.steiner=!0),s.push(U4(o))}s.sort(k4);for(let n=0;n<s.length;n++)i=I4(s[n],i);return i}function k4(e,t){let i=e.x-t.x;return i===0&&(i=e.y-t.y,i===0&&(i=(e.next.y-e.y)/(e.next.x-e.x)-(t.next.y-t.y)/(t.next.x-t.x))),i}function I4(e,t){let i=F4(e,t);if(!i)return t;let r=jM(i,e);return vh(r,r.next),vh(i,i.next)}function F4(e,t){let i=t,r=e.x,s=e.y,n=-1/0,a;if(Ju(e,i))return i;do{if(Ju(e,i.next))return i.next;if(s<=i.y&&s>=i.next.y&&i.next.y!==i.y){let d=i.x+(s-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(d<=r&&d>n&&(n=d,a=i.x<i.next.x?i:i.next,d===r))return a}i=i.next}while(i!==t);if(!a)return null;let o=a,l=a.x,h=a.y,u=1/0;i=a;do{if(r>=i.x&&i.x>=l&&r!==i.x&&zM(s<h?r:n,s,l,h,s<h?n:r,s,i.x,i.y)){let d=Math.abs(s-i.y)/(r-i.x);Kc(i,e)&&(d<u||d===u&&(i.x>a.x||i.x===a.x&&D4(a,i)))&&(a=i,u=d)}i=i.next}while(i!==o);return a}function D4(e,t){return si(e.prev,e,t.prev)<0&&si(t.next,e,e.next)<0}function O4(e,t,i,r){let s=e;do s.z===0&&(s.z=kx(s.x,s.y,t,i,r)),s.prevZ=s.prev,s.nextZ=s.next,s=s.next;while(s!==e);s.prevZ.nextZ=null,s.prevZ=null,B4(s)}function B4(e){let t,i=1;do{let r=e,s;e=null;let n=null;for(t=0;r;){t++;let a=r,o=0;for(let h=0;h<i&&(o++,a=a.nextZ,a);h++);let l=i;for(;o>0||l>0&&a;)o!==0&&(l===0||!a||r.z<=a.z)?(s=r,r=r.nextZ,o--):(s=a,a=a.nextZ,l--),n?n.nextZ=s:e=s,s.prevZ=n,n=s;r=a}n.nextZ=null,i*=2}while(t>1);return e}function kx(e,t,i,r,s){return e=(e-i)*s|0,t=(t-r)*s|0,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,e|t<<1}function U4(e){let t=e,i=e;do(t.x<i.x||t.x===i.x&&t.y<i.y)&&(i=t),t=t.next;while(t!==e);return i}function zM(e,t,i,r,s,n,a,o){return(s-a)*(t-o)>=(e-a)*(n-o)&&(e-a)*(r-o)>=(i-a)*(t-o)&&(i-a)*(n-o)>=(s-a)*(r-o)}function Yc(e,t,i,r,s,n,a,o){return!(e===a&&t===o)&&zM(e,t,i,r,s,n,a,o)}function V4(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!z4(e,t)&&(Kc(e,t)&&Kc(t,e)&&G4(e,t)&&(si(e.prev,e,t.prev)||si(e,t.prev,t))||Ju(e,t)&&si(e.prev,e,e.next)>0&&si(t.prev,t,t.next)>0)}function si(e,t,i){return(t.y-e.y)*(i.x-t.x)-(t.x-e.x)*(i.y-t.y)}function Ju(e,t){return e.x===t.x&&e.y===t.y}function GM(e,t,i,r){let s=Jg(si(e,t,i)),n=Jg(si(e,t,r)),a=Jg(si(i,r,e)),o=Jg(si(i,r,t));return!!(s!==n&&a!==o||s===0&&Zg(e,i,t)||n===0&&Zg(e,r,t)||a===0&&Zg(i,e,r)||o===0&&Zg(i,t,r))}function Zg(e,t,i){return t.x<=Math.max(e.x,i.x)&&t.x>=Math.min(e.x,i.x)&&t.y<=Math.max(e.y,i.y)&&t.y>=Math.min(e.y,i.y)}function Jg(e){return e>0?1:e<0?-1:0}function z4(e,t){let i=e;do{if(i.i!==e.i&&i.next.i!==e.i&&i.i!==t.i&&i.next.i!==t.i&&GM(i,i.next,e,t))return!0;i=i.next}while(i!==e);return!1}function Kc(e,t){return si(e.prev,e,e.next)<0?si(e,t,e.next)>=0&&si(e,e.prev,t)>=0:si(e,t,e.prev)<0||si(e,e.next,t)<0}function G4(e,t){let i=e,r=!1,s=(e.x+t.x)/2,n=(e.y+t.y)/2;do i.y>n!=i.next.y>n&&i.next.y!==i.y&&s<(i.next.x-i.x)*(n-i.y)/(i.next.y-i.y)+i.x&&(r=!r),i=i.next;while(i!==e);return r}function jM(e,t){let i=Ix(e.i,e.x,e.y),r=Ix(t.i,t.x,t.y),s=e.next,n=t.prev;return e.next=t,t.prev=e,i.next=s,s.prev=i,r.next=i,i.prev=r,n.next=r,r.prev=n,r}function $M(e,t,i,r){let s=Ix(e,t,i);return r?(s.next=r.next,s.prev=r,r.next.prev=s,r.next=s):(s.prev=s,s.next=s),s}function Zc(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function Ix(e,t,i){return{i:e,x:t,y:i,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function j4(e,t,i,r){let s=0;for(let n=t,a=i-r;n<i;n+=r)s+=(e[a]-e[n])*(e[n+1]+e[a+1]),a=n;return s}var $4=class{static triangulate(e,t,i=2){return R4(e,t,i)}},Fx=class rO{static area(t){let i=t.length,r=0;for(let s=i-1,n=0;n<i;s=n++)r+=t[s].x*t[n].y-t[n].x*t[s].y;return r*.5}static isClockWise(t){return rO.area(t)<0}static triangulateShape(t,i){let r=[],s=[],n=[];WM(t),HM(r,t);let a=t.length;
vendor: 15,781 bytes, line 1
1i.forEach(WM);for(let l=0;l<i.length;l++)s.push(a),a+=i[l].length,HM(r,i[l]);let o=$4.triangulate(r,s);for(let l=0;l<o.length;l+=3)n.push(o.slice(l,l+3));return n}};function WM(e){let t=e.length;t>2&&e[t-1].equals(e[0])&&e.pop()}function HM(e,t){for(let i=0;i<t.length;i++)e.push(t[i].x),e.push(t[i].y)}var Un=class sO extends $r{constructor(t=1,i=1,r=1,s=1){super(),this.type="PlaneGeometry",this.parameters={width:t,height:i,widthSegments:r,heightSegments:s};let n=t/2,a=i/2,o=Math.floor(r),l=Math.floor(s),h=o+1,u=l+1,d=t/o,c=i/l,p=[],m=[],g=[],f=[];for(let y=0;y<u;y++){let x=y*c-a;for(let b=0;b<h;b++){let _=b*d-n;m.push(_,-x,0),g.push(0,0,1),f.push(b/o),f.push(1-y/l)}}for(let y=0;y<l;y++)for(let x=0;x<o;x++){let b=x+h*y,_=x+h*(y+1),T=x+1+h*(y+1),w=x+1+h*y;p.push(b,_,w),p.push(_,T,w)}this.setIndex(p),this.setAttribute("position",new Ht(m,3)),this.setAttribute("normal",new Ht(g,3)),this.setAttribute("uv",new Ht(f,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new sO(t.width,t.height,t.widthSegments,t.heightSegments)}},W4=class nO extends $r{constructor(t=.5,i=1,r=32,s=1,n=0,a=Math.PI*2){super(),this.type="RingGeometry",this.parameters={innerRadius:t,outerRadius:i,thetaSegments:r,phiSegments:s,thetaStart:n,thetaLength:a},r=Math.max(3,r),s=Math.max(1,s);let o=[],l=[],h=[],u=[],d=t,c=(i-t)/s,p=new F,m=new ge;for(let g=0;g<=s;g++){for(let f=0;f<=r;f++){let y=n+f/r*a;p.x=d*Math.cos(y),p.y=d*Math.sin(y),l.push(p.x,p.y,p.z),h.push(0,0,1),m.x=(p.x/i+1)/2,m.y=(p.y/i+1)/2,u.push(m.x,m.y)}d+=c}for(let g=0;g<s;g++){let f=g*(r+1);for(let y=0;y<r;y++){let x=y+f,b=x,_=x+r+1,T=x+r+2,w=x+1;o.push(b,_,w),o.push(_,T,w)}}this.setIndex(o),this.setAttribute("position",new Ht(l,3)),this.setAttribute("normal",new Ht(h,3)),this.setAttribute("uv",new Ht(u,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new nO(t.innerRadius,t.outerRadius,t.thetaSegments,t.phiSegments,t.thetaStart,t.thetaLength)}},Dx=class aO extends $r{constructor(t=new Kg([new ge(0,.5),new ge(-.5,-.5),new ge(.5,-.5)]),i=12){super(),this.type="ShapeGeometry",this.parameters={shapes:t,curveSegments:i};let r=[],s=[],n=[],a=[],o=0,l=0;if(Array.isArray(t)===!1)h(t);else for(let u=0;u<t.length;u++)h(t[u]),this.addGroup(o,l,u),o+=l,l=0;this.setIndex(r),this.setAttribute("position",new Ht(s,3)),this.setAttribute("normal",new Ht(n,3)),this.setAttribute("uv",new Ht(a,2));function h(u){let d=s.length/3,c=u.extractPoints(i),p=c.shape,m=c.holes;Fx.isClockWise(p)===!1&&(p=p.reverse());for(let f=0,y=m.length;f<y;f++){let x=m[f];Fx.isClockWise(x)===!0&&(m[f]=x.reverse())}let g=Fx.triangulateShape(p,m);for(let f=0,y=m.length;f<y;f++){let x=m[f];p=p.concat(x)}for(let f=0,y=p.length;f<y;f++){let x=p[f];s.push(x.x,x.y,0),n.push(0,0,1),a.push(x.x,x.y)}for(let f=0,y=g.length;f<y;f++){let x=g[f],b=x[0]+d,_=x[1]+d,T=x[2]+d;r.push(b,_,T),l+=3}}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}toJSON(){let t=super.toJSON(),i=this.parameters.shapes;return H4(i,t)}static fromJSON(t,i){let r=[];for(let s=0,n=t.shapes.length;s<n;s++){let a=i[t.shapes[s]];r.push(a)}return new aO(r,t.curveSegments)}};function H4(e,t){if(t.shapes=[],Array.isArray(e))for(let i=0,r=e.length;i<r;i++){let s=e[i];t.shapes.push(s.uuid)}else t.shapes.push(e.uuid);return t}var q4=class oO extends $r{constructor(t=1,i=32,r=16,s=0,n=Math.PI*2,a=0,o=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:t,widthSegments:i,heightSegments:r,phiStart:s,phiLength:n,thetaStart:a,thetaLength:o},i=Math.max(3,Math.floor(i)),r=Math.max(2,Math.floor(r));let l=Math.min(a+o,Math.PI),h=0,u=[],d=new F,c=new F,p=[],m=[],g=[],f=[];for(let y=0;y<=r;y++){let x=[],b=y/r,_=0;y===0&&a===0?_=.5/i:y===r&&l===Math.PI&&(_=-.5/i);for(let T=0;T<=i;T++){let w=T/i;d.x=-t*Math.cos(s+w*n)*Math.sin(a+b*o),d.y=t*Math.cos(a+b*o),d.z=t*Math.sin(s+w*n)*Math.sin(a+b*o),m.push(d.x,d.y,d.z),c.copy(d).normalize(),g.push(c.x,c.y,c.z),f.push(w+_,1-b),x.push(h++)}u.push(x)}for(let y=0;y<r;y++)for(let x=0;x<i;x++){let b=u[y][x+1],_=u[y][x],T=u[y+1][x],w=u[y+1][x+1];(y!==0||a>0)&&p.push(b,_,w),(y!==r-1||l<Math.PI)&&p.push(_,T,w)}this.setIndex(p),this.setAttribute("position",new Ht(m,3)),this.setAttribute("normal",new Ht(g,3)),this.setAttribute("uv",new Ht(f,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new oO(t.radius,t.widthSegments,t.heightSegments,t.phiStart,t.phiLength,t.thetaStart,t.thetaLength)}},X4=class extends xs{constructor(e){super(),this.isShadowMaterial=!0,this.type="ShadowMaterial",this.color=new Ke(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}},qM=class extends xs{constructor(e){super(),this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new Ke(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 Ke(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new ge(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 In,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}},Y4=class extends qM{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 ge(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return He(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 Ke(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 Ke(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new Ke(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}},K4=class extends xs{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new Ke(16777215),this.specular=new Ke(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ke(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new ge(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new In,this.combine=0,this.reflectivity=1,this.envMapIntensity=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.envMapIntensity=e.envMapIntensity,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}},Z4=class extends xs{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new Ke(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ke(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new ge(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}},J4=class extends xs{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new ge(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}},Q4=class extends xs{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new Ke(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ke(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new ge(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new In,this.combine=0,this.reflectivity=1,this.envMapIntensity=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.envMapIntensity=e.envMapIntensity,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}}
vendor: 4,305 bytes, line 1
1,eU=class extends xs{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new Ke(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new ge(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,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.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this.fog=e.fog,this}},tU=class extends PM{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 Qg(e,t){return!e||e.constructor===t?e:typeof t.BYTES_PER_ELEMENT=="number"?new t(e):Array.prototype.slice.call(e)}var Jc=class{constructor(e,t,i,r){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=r===void 0?new t.constructor(i):r,this.sampleValues=t,this.valueSize=i,this.settings=null,this.DefaultSettings_={}}evaluate(e){let t=this.parameterPositions,i=this._cachedIndex,r=t[i],s=t[i-1];e:{t:{let n;i:{r:if(!(e<r)){for(let a=i+2;;){if(r===void 0){if(e<s)break r;return i=t.length,this._cachedIndex=i,this.copySampleValue_(i-1)}if(i===a)break;if(s=r,r=t[++i],e<r)break t}n=t.length;break i}if(!(e>=s)){let a=t[1];e<a&&(i=2,s=a);for(let o=i-2;;){if(s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===o)break;if(r=s,s=t[--i-1],e>=s)break t}n=i,i=0;break i}break e}for(;i<n;){let a=i+n>>>1;e<t[a]?n=a:i=a+1}if(r=t[i],s=t[i-1],s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(r===void 0)return i=t.length,this._cachedIndex=i,this.copySampleValue_(i-1)}this._cachedIndex=i,this.intervalChanged_(i,s,r)}return this.interpolate_(i,s,e,r)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){let t=this.resultBuffer,i=this.sampleValues,r=this.valueSize,s=e*r;for(let n=0;n!==r;++n)t[n]=i[s+n];return t}interpolate_(){throw Error("call to abstract method")}intervalChanged_(){}},iU=class extends Jc{constructor(e,t,i,r){super(e,t,i,r),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:Z2,endingEnd:Z2}}intervalChanged_(e,t,i){let r=this.parameterPositions,s=e-2,n=e+1,a=r[s],o=r[n];if(a===void 0)switch(this.getSettings_().endingStart){case J2:s=e,a=2*t-i;break;case Q2:s=r.length-2,a=t+r[s]-r[s+1];break;default:s=e,a=i}if(o===void 0)switch(this.getSettings_().endingEnd){case J2:n=e,o=2*i-t;break;case Q2:n=1,o=i+r[1]-r[0];break;default:n=e-1,o=t}let l=(i-t)*.5,h=this.valueSize;this._weightPrev=l/(t-a),this._weightNext=l/(o-i),this._offsetPrev=s*h,this._offsetNext=n*h}interpolate_(e,t,i,r){let s=this.resultBuffer,n=this.sampleValues,a=this.valueSize,o=e*a,l=o-a,h=this._offsetPrev,u=this._offsetNext,d=this._weightPrev,c=this._weightNext,p=(i-t)/(r-t),m=p*p,g=m*p,f=-d*g+2*d*m-d*p,y=(1+d)*g+(-1.5-2*d)*m+(-.5+d)*p+1,x=(-1-c)*g+(1.5+c)*m+.5*p,b=c*g-c*m;for(let _=0;_!==a;++_)s[_]=f*n[h+_]+y*n[l+_]+x*n[o+_]+b*n[u+_];return s}},rU=class extends Jc{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e,t,i,r){let s=this.resultBuffer,n=this.sampleValues,a=this.valueSize,o=e*a,l=o-a,h=(i-t)/(r-t),u=1-h;for(let d=0;d!==a;++d)s[d]=n[l+d]*u+n[o+d]*h;return s}},sU=class extends Jc{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e){return this.copySampleValue_(e-1)}},nU=class extends Jc{interpolate_(e,t,i,r){let s=this.resultBuffer,n=this.sampleValues,a=this.valueSize,o=e*a,l=o-a,h=this.settings||this.DefaultSettings_,u=h.inTangents,d=h.outTangents;if(!u||!d){let m=(i-t)/(r-t),g=1-m;for(let f=0;f!==a;++f)s[f]=n[l+f]*g+n[o+f]*m;return s}let c=a*2,p=e-1;for(let m=0;m!==a;
vendor: 16,235 bytes, line 1
1++m){let g=n[l+m],f=n[o+m],y=p*c+m*2,x=d[y],b=d[y+1],_=e*c+m*2,T=u[_],w=u[_+1],M=(i-t)/(r-t),S,R,I,B,O;for(let U=0;U<8;U++){S=M*M,R=S*M,I=1-M,B=I*I,O=B*I;let V=O*t+3*B*M*x+3*I*S*T+R*r-i;if(Math.abs(V)<1e-10)break;let z=3*B*(x-t)+6*I*M*(T-x)+3*S*(r-T);if(Math.abs(z)<1e-10)break;M-=V/z,M=Math.max(0,Math.min(1,M))}s[m]=O*g+3*B*M*b+3*I*S*w+R*f}return s}},Vn=class{constructor(e,t,i,r){if(e===void 0)throw Error("THREE.KeyframeTrack: track name is undefined");if(t===void 0||t.length===0)throw Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=Qg(t,this.TimeBufferType),this.values=Qg(i,this.ValueBufferType),this.setInterpolation(r||this.DefaultInterpolation)}static toJSON(e){let t=e.constructor,i;if(t.toJSON!==this.toJSON)i=t.toJSON(e);else{i={name:e.name,times:Qg(e.times,Array),values:Qg(e.values,Array)};let r=e.getInterpolation();r!==e.DefaultInterpolation&&(i.interpolation=r)}return i.type=e.ValueTypeName,i}InterpolantFactoryMethodDiscrete(e){return new sU(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new rU(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new iU(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodBezier(e){let t=new nU(this.times,this.values,this.getValueSize(),e);return this.settings&&(t.settings=this.settings),t}setInterpolation(e){let t;switch(e){case Tg:t=this.InterpolantFactoryMethodDiscrete;break;case q1:t=this.InterpolantFactoryMethodLinear;break;case X1:t=this.InterpolantFactoryMethodSmooth;break;case K2:t=this.InterpolantFactoryMethodBezier;break}if(t===void 0){let i="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 Error(i);return de("KeyframeTrack:",i),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return Tg;case this.InterpolantFactoryMethodLinear:return q1;case this.InterpolantFactoryMethodSmooth:return X1;case this.InterpolantFactoryMethodBezier:return K2}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){let t=this.times;for(let i=0,r=t.length;i!==r;++i)t[i]+=e}return this}scale(e){if(e!==1){let t=this.times;for(let i=0,r=t.length;i!==r;++i)t[i]*=e}return this}trim(e,t){let i=this.times,r=i.length,s=0,n=r-1;for(;s!==r&&i[s]<e;)++s;for(;n!==-1&&i[n]>t;)--n;if(++n,s!==0||n!==r){s>=n&&(n=Math.max(n,1),s=n-1);let a=this.getValueSize();this.times=i.slice(s,n),this.values=this.values.slice(s*a,n*a)}return this}validate(){let e=!0,t=this.getValueSize();t-Math.floor(t)!==0&&(re("KeyframeTrack: Invalid value size in track.",this),e=!1);let i=this.times,r=this.values,s=i.length;s===0&&(re("KeyframeTrack: Track is empty.",this),e=!1);let n=null;for(let a=0;a!==s;a++){let o=i[a];if(typeof o=="number"&&isNaN(o)){re("KeyframeTrack: Time is not a valid number.",this,a,o),e=!1;break}if(n!==null&&n>o){re("KeyframeTrack: Out of order keys.",this,a,o,n),e=!1;break}n=o}if(r!==void 0&&kc(r))for(let a=0,o=r.length;a!==o;++a){let l=r[a];if(isNaN(l)){re("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(),i=this.getValueSize(),r=this.getInterpolation()===X1,s=e.length-1,n=1;for(let a=1;a<s;++a){let o=!1,l=e[a];if(l!==e[a+1]&&(a!==1||l!==e[0]))if(r)o=!0;else{let h=a*i,u=h-i,d=h+i;for(let c=0;c!==i;++c){let p=t[h+c];if(p!==t[u+c]||p!==t[d+c]){o=!0;break}}}if(o){if(a!==n){e[n]=e[a];let h=a*i,u=n*i;for(let d=0;d!==i;++d)t[u+d]=t[h+d]}++n}}if(s>0){e[n]=e[s];for(let a=s*i,o=n*i,l=0;l!==i;++l)t[o+l]=t[a+l];++n}return n===e.length?(this.times=e,this.values=t):(this.times=e.slice(0,n),this.values=t.slice(0,n*i)),this}clone(){let e=this.times.slice(),t=this.values.slice(),i=this.constructor,r=new i(this.name,e,t);return r.createInterpolant=this.createInterpolant,r}};Vn.prototype.ValueTypeName="",Vn.prototype.TimeBufferType=Float32Array,Vn.prototype.ValueBufferType=Float32Array,Vn.prototype.DefaultInterpolation=q1;var Qc=class extends Vn{constructor(e,t,i){super(e,t,i)}};Qc.prototype.ValueTypeName="bool",Qc.prototype.ValueBufferType=Array,Qc.prototype.DefaultInterpolation=Tg,Qc.prototype.InterpolantFactoryMethodLinear=void 0,Qc.prototype.InterpolantFactoryMethodSmooth=void 0;var aU=class extends Vn{constructor(e,t,i,r){super(e,t,i,r)}};aU.prototype.ValueTypeName="color";var oU=class extends Vn{constructor(e,t,i,r){super(e,t,i,r)}};oU.prototype.ValueTypeName="number";var lU=class extends Jc{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e,t,i,r){let s=this.resultBuffer,n=this.sampleValues,a=this.valueSize,o=(i-t)/(r-t),l=e*a;for(let h=l+a;l!==h;l+=4)Bo.slerpFlat(s,0,n,l-a,n,l,o);return s}},XM=class extends Vn{constructor(e,t,i,r){super(e,t,i,r)}InterpolantFactoryMethodLinear(e){return new lU(this.times,this.values,this.getValueSize(),e)}};XM.prototype.ValueTypeName="quaternion",XM.prototype.InterpolantFactoryMethodSmooth=void 0;var ep=class extends Vn{constructor(e,t,i){super(e,t,i)}};ep.prototype.ValueTypeName="string",ep.prototype.ValueBufferType=Array,ep.prototype.DefaultInterpolation=Tg,ep.prototype.InterpolantFactoryMethodLinear=void 0,ep.prototype.InterpolantFactoryMethodSmooth=void 0;var hU=class extends Vn{constructor(e,t,i,r){super(e,t,i,r)}};hU.prototype.ValueTypeName="vector";var Ox={enabled:!1,files:{},add:function(e,t){this.enabled!==!1&&(YM(e)||(this.files[e]=t))},get:function(e){if(this.enabled!==!1&&!YM(e))return this.files[e]},remove:function(e){delete this.files[e]},clear:function(){this.files={}}};function YM(e){try{let t=e.slice(e.indexOf(":")+1);return new URL(t).protocol==="blob:"}catch{return!1}}var uU=new class{constructor(e,t,i){let r=this,s=!1,n=0,a=0,o,l=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=i,this._abortController=null,this.itemStart=function(h){a++,s===!1&&r.onStart!==void 0&&r.onStart(h,n,a),s=!0},this.itemEnd=function(h){n++,r.onProgress!==void 0&&r.onProgress(h,n,a),n===a&&(s=!1,r.onLoad!==void 0&&r.onLoad())},this.itemError=function(h){r.onError!==void 0&&r.onError(h)},this.resolveURL=function(h){return o?o(h):h},this.setURLModifier=function(h){return o=h,this},this.addHandler=function(h,u){return l.push(h,u),this},this.removeHandler=function(h){let u=l.indexOf(h);return u!==-1&&l.splice(u,2),this},this.getHandler=function(h){for(let u=0,d=l.length;u<d;u+=2){let c=l[u],p=l[u+1];if(c.global&&(c.lastIndex=0),c.test(h))return p}return null},this.abort=function(){return this.abortController.abort(),this._abortController=null,this}}get abortController(){return this._abortController||=new AbortController,this._abortController}},Bx=class{constructor(e){this.manager=e===void 0?uU:e,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}load(){}loadAsync(e,t){let i=this;return new Promise(function(r,s){i.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}abort(){return this}};Bx.DEFAULT_MATERIAL_NAME="__DEFAULT";var Qu=new WeakMap,dU=class extends Bx{constructor(e){super(e)}load(e,t,i,r){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);let s=this,n=Ox.get(`image:${e}`);if(n!==void 0){if(n.complete===!0)s.manager.itemStart(e),setTimeout(function(){t&&t(n),s.manager.itemEnd(e)},0);else{let u=Qu.get(n);u===void 0&&(u=[],Qu.set(n,u)),u.push({onLoad:t,onError:r})}return n}let a=Mg("img");function o(){h(),t&&t(this);let u=Qu.get(this)||[];for(let d=0;d<u.length;d++){let c=u[d];c.onLoad&&c.onLoad(this)}Qu.delete(this),s.manager.itemEnd(e)}function l(u){h(),r&&r(u),Ox.remove(`image:${e}`);let d=Qu.get(this)||[];for(let c=0;c<d.length;c++){let p=d[c];p.onError&&p.onError(u)}Qu.delete(this),s.manager.itemError(e),s.manager.itemEnd(e)}function h(){a.removeEventListener("load",o,!1),a.removeEventListener("error",l,!1)}return a.addEventListener("load",o,!1),a.addEventListener("error",l,!1),e.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(a.crossOrigin=this.crossOrigin),Ox.add(`image:${e}`,a),s.manager.itemStart(e),a.src=e,a}},Wo=class extends Bx{constructor(e){super(e)}load(e,t,i,r){let s=new Li,n=new dU(this.manager);return n.setCrossOrigin(this.crossOrigin),n.setPath(this.path),n.load(e,function(a){s.image=a,s.needsUpdate=!0,t!==void 0&&t(s)},i,r),s}},bh=class extends dr{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new Ke(e),this.intensity=t}dispose(){this.dispatchEvent({type:"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,t}},cU=class extends bh{constructor(e,t,i){super(e,i),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(dr.DEFAULT_UP),this.updateMatrix(),this.groundColor=new Ke(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}toJSON(e){let t=super.toJSON(e);return t.object.groundColor=this.groundColor.getHex(),t}},Ux=new $e,KM=new F,ZM=new F,Vx=class{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.biasNode=null,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new ge(512,512),this.mapType=hr,this.map=null,this.mapPass=null,this.matrix=new $e,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Mx,this._frameExtents=new ge(1,1),this._viewportCount=1,this._viewports=[new yt(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){let t=this.camera,i=this.matrix;KM.setFromMatrixPosition(e.matrixWorld),t.position.copy(KM),ZM.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(ZM),t.updateMatrixWorld(),Ux.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Ux,t.coordinateSystem,t.reversedDepth),t.coordinateSystem===2001||t.reversedDepth?i.set(.5,0,0,.5,0,.5,0,.5,0,0,1,0,0,0,0,1):i.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),i.multiply(Ux)}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.autoUpdate=e.autoUpdate,this.needsUpdate=e.needsUpdate,this.normalBias=e.normalBias,this.blurSamples=e.blurSamples,this.mapSize.copy(e.mapSize),this.biasNode=e.biasNode,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}},ef=new F,tf=new Bo,zn=new F,JM=class extends dr{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new $e,this.projectionMatrix=new $e,this.projectionMatrixInverse=new $e,this.coordinateSystem=ch,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorld.decompose(ef,tf,zn),zn.x===1&&zn.y===1&&zn.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(ef,tf,zn.set(1,1,1)).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorld.decompose(ef,tf,zn),zn.x===1&&zn.y===1&&zn.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(ef,tf,zn.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}},Ho=new F,QM=new ge,eC=new ge,os=class extends JM{constructor(e=50,t=1,i=.1,r=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=i,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=Iu*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){let e=Math.tan(Ic*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return Iu*2*Math.atan(Math.tan(Ic*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,i){Ho.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(Ho.x,Ho.y).multiplyScalar(-e/Ho.z),Ho.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),i.set(Ho.x,Ho.y).multiplyScalar(-e/Ho.z)}getViewSize(e,t){return this.getViewBounds(e,QM,eC),t.subVectors(eC,QM)}setViewOffset(e,t,i,r,s,n){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=r,this.view.width=s,this.view.height=n,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let e=this.near,t=e*Math.tan(Ic*.5*this.fov)/this.zoom,i=2*t,r=this.aspect*i,s=-.5*r,n=this.view;if(this.view!==null&&this.view.enabled){let o=n.fullWidth,l=n.fullHeight;s+=n.offsetX*r/o,t-=n.offsetY*i/l,r*=n.width/o,i*=n.height/l}let a=this.filmOffset;a!==0&&(s+=e*a/this.getFilmWidth()),this.projectionMatrix.makePerspective(s,s+r,t,t-i,e,this.far,this.coordinateSystem,this.reversedDepth),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}},pU=class extends Vx{constructor(){super(new os(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1,this.aspect=1}updateMatrices(e){let t=this.camera,i=Iu*2*e.angle*this.focus,r=this.mapSize.width/this.mapSize.height*this.aspect,s=e.distance||t.far;(i!==t.fov||r!==t.aspect||s!==t.far)&&(t.fov=i,t.aspect=r,t.far=s,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}},zx=class extends bh{constructor(e,t,i=0,r=Math.PI/3,s=0,n=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(dr.DEFAULT_UP),this.updateMatrix(),this.target=new dr,this.distance=i,this.angle=r,this.penumbra=s,this.decay=n,this.map=null,this.shadow=new pU}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){super.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.map=e.map,this.shadow=e.shadow.clone(),this}toJSON(e){let t=super.toJSON(e);return t.object.distance=this.distance,t.object.angle=this.angle,t.object.decay=this.decay,t.object.penumbra=this.penumbra,t.object.target=this.target.uuid,this.map&&this.map.isTexture&&(t.object.map=this.map.toJSON(e).uuid),t.object.shadow=this.shadow.toJSON(),t}},mU=class extends Vx{constructor(){super(new os(90,1,.5,500)),this.isPointLightShadow=!0}
vendor: 6,192 bytes, line 1
1},gU=class extends bh{constructor(e,t,i=0,r=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=i,this.decay=r,this.shadow=new mU}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){super.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}toJSON(e){let t=super.toJSON(e);return t.object.distance=this.distance,t.object.decay=this.decay,t.object.shadow=this.shadow.toJSON(),t}},rf=class extends JM{constructor(e=-1,t=1,i=1,r=-1,s=.1,n=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=i,this.bottom=r,this.near=s,this.far=n,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,i,r,s,n){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=r,this.view.width=s,this.view.height=n,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),i=(this.right+this.left)/2,r=(this.top+this.bottom)/2,s=i-e,n=i+e,a=r+t,o=r-t;if(this.view!==null&&this.view.enabled){let l=(this.right-this.left)/this.view.fullWidth/this.zoom,h=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=l*this.view.offsetX,n=s+l*this.view.width,a-=h*this.view.offsetY,o=a-h*this.view.height}this.projectionMatrix.makeOrthographic(s,n,a,o,this.near,this.far,this.coordinateSystem,this.reversedDepth),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}},fU=class extends Vx{constructor(){super(new rf(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}},yU=class extends bh{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(dr.DEFAULT_UP),this.updateMatrix(),this.target=new dr,this.shadow=new fU}dispose(){super.dispose(),this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}toJSON(e){let t=super.toJSON(e);return t.object.shadow=this.shadow.toJSON(),t.object.target=this.target.uuid,t}},xU=class extends bh{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}},vU=class extends bh{constructor(e,t,i=10,r=10){super(e,t),this.isRectAreaLight=!0,this.type="RectAreaLight",this.width=i,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}},bU=class{constructor(){this.isSphericalHarmonics3=!0,this.coefficients=[];for(let e=0;e<9;e++)this.coefficients.push(new F)}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 i=e.x,r=e.y,s=e.z,n=this.coefficients;return t.copy(n[0]).multiplyScalar(.282095),t.addScaledVector(n[1],.488603*r),t.addScaledVector(n[2],.488603*s),t.addScaledVector(n[3],.488603*i),t.addScaledVector(n[4],i*r*1.092548),t.addScaledVector(n[5],r*s*1.092548),t.addScaledVector(n[6],.315392*(3*s*s-1)),t.addScaledVector(n[7],i*s*1.092548),t.addScaledVector(n[8],.546274*(i*i-r*r)),t}getIrradianceAt(e,t){let i=e.x,r=e.y,s=e.z,n=this.coefficients;return t.copy(n[0]).multiplyScalar(.886227),t.addScaledVector(n[1],2*.511664*r),t.addScaledVector(n[2],2*.511664*s),t.addScaledVector(n[3],2*.511664*i),t.addScaledVector(n[4],2*.429043*i*r),t.addScaledVector(n[5],2*.429043*r*s),t.addScaledVector(n[6],.743125*s*s-.247708),t.addScaledVector(n[7],2*.429043*i*s),t.addScaledVector(n[8],.429043*(i*i-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 i=0;i<9;i++)this.coefficients[i].addScaledVector(e.coefficients[i],t);return this}scale(e){for(let t=0;t<9;t++)this.coefficients[t].multiplyScalar(e);return this}lerp(e,t){for(let i=0;i<9;i++)this.coefficients[i].lerp(e.coefficients[i],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 i=this.coefficients;for(let r=0;r<9;r++)i[r].fromArray(e,t+r*3);return this}toArray(e=[],t=0){let i=this.coefficients;for(let r=0;r<9;r++)i[r].toArray(e,t+r*3);return e}static getBasisAt(e,t){let i=e.x,r=e.y,s=e.z;t[0]=.282095,t[1]=.488603*r,t[2]=.488603*s,t[3]=.488603*i,t[4]=1.092548*i*r,t[5]=1.092548*r*s,t[6]=.315392*(3*s*s-1),t[7]=1.092548*i*s,t[8]=.546274*(i*i-r*r)}},_U=class extends bh{constructor(e=new bU,t=1){super(void 0,t),this.isLightProbe=!0,this.sh=e}copy(e){return super.copy(e),this.sh.copy(e.sh),this}toJSON(e){let t=super.toJSON(e);return t.object.sh=this.sh.toArray(),t}},ed=-90,td=1,TU=class extends dr{constructor(e,t,i){super(),this.type="CubeCamera",this.renderTarget=i,this.coordinateSystem=null,this.activeMipmapLevel=0;let r=new os(ed,td,e,t);r.layers=this.layers,this.add(r);let s=new os(ed,td,e,t);s.layers=this.layers,this.add(s);let n=new os(ed,td,e,t);n.layers=this.layers,this.add(n);let a=new os(ed,td,e,t);a.layers=this.layers,this.add(a);let o=new os(ed,td,e,t);o.layers=this.layers,this.add(o);let l=new os(ed,td,e,t);l.layers=this.layers,this.add(l)}updateCoordinateSystem(){let e=this.coordinateSystem,t=this.children.concat(),[i,r,s,n,a,o]=t;
vendor: 4,823 bytes, line 1
1for(let l of t)this.remove(l);if(e===2e3)i.up.set(0,1,0),i.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),n.up.set(0,0,1),n.lookAt(0,-1,0),a.up.set(0,1,0),a.lookAt(0,0,1),o.up.set(0,1,0),o.lookAt(0,0,-1);else if(e===2001)i.up.set(0,-1,0),i.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),n.up.set(0,0,-1),n.lookAt(0,-1,0),a.up.set(0,-1,0),a.lookAt(0,0,1),o.up.set(0,-1,0),o.lookAt(0,0,-1);else throw 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:i,activeMipmapLevel:r}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());let[s,n,a,o,l,h]=this.children,u=e.getRenderTarget(),d=e.getActiveCubeFace(),c=e.getActiveMipmapLevel(),p=e.xr.enabled;e.xr.enabled=!1;let m=i.texture.generateMipmaps;i.texture.generateMipmaps=!1;let g=!1;g=e.isWebGLRenderer===!0?e.state.buffers.depth.getReversed():e.reversedDepthBuffer,e.setRenderTarget(i,0,r),g&&e.autoClear===!1&&e.clearDepth(),e.render(t,s),e.setRenderTarget(i,1,r),g&&e.autoClear===!1&&e.clearDepth(),e.render(t,n),e.setRenderTarget(i,2,r),g&&e.autoClear===!1&&e.clearDepth(),e.render(t,a),e.setRenderTarget(i,3,r),g&&e.autoClear===!1&&e.clearDepth(),e.render(t,o),e.setRenderTarget(i,4,r),g&&e.autoClear===!1&&e.clearDepth(),e.render(t,l),i.texture.generateMipmaps=m,e.setRenderTarget(i,5,r),g&&e.autoClear===!1&&e.clearDepth(),e.render(t,h),e.setRenderTarget(u,d,c),e.xr.enabled=p,i.texture.needsPMREMUpdate=!0}},wU=class extends os{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}},SU="\\[\\]\\.:\\/",MU=RegExp("[\\[\\]\\.:\\/]","g"),Gx="[^\\[\\]\\.:\\/]",CU="[^"+SU.replace("\\.","")+"]",RU="((?:WC+[\\/:])*)".replace("WC",Gx),EU="(WCOD+)?".replace("WCOD",CU),AU="(?:\\.(WC+)(?:\\[(.+)\\])?)?".replace("WC",Gx),NU="\\.(WC+)(?:\\[(.+)\\])?".replace("WC",Gx),LU=RegExp("^"+RU+EU+AU+NU+"$"),PU=["material","materials","bones","map"],kU=class{constructor(e,t,i){let r=i||gi.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,r)}getValue(e,t){this.bind();let i=this._targetGroup.nCachedObjects_,r=this._bindings[i];r!==void 0&&r.getValue(e,t)}setValue(e,t){let i=this._bindings;for(let r=this._targetGroup.nCachedObjects_,s=i.length;r!==s;++r)i[r].setValue(e,t)}bind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].bind()}unbind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].unbind()}},gi=class Rc{constructor(t,i,r){this.path=i,this.parsedPath=r||Rc.parseTrackName(i),this.node=Rc.findNode(t,this.parsedPath.nodeName),this.rootNode=t,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(t,i,r){return t&&t.isAnimationObjectGroup?new Rc.Composite(t,i,r):new Rc(t,i,r)}static sanitizeNodeName(t){return t.replace(/\s/g,"_").replace(MU,"")}static parseTrackName(t){let i=LU.exec(t);if(i===null)throw Error("PropertyBinding: Cannot parse trackName: "+t);let r={nodeName:i[2],objectName:i[3],objectIndex:i[4],propertyName:i[5],propertyIndex:i[6]},s=r.nodeName&&r.nodeName.lastIndexOf(".");if(s!==void 0&&s!==-1){let n=r.nodeName.substring(s+1);PU.indexOf(n)!==-1&&(r.nodeName=r.nodeName.substring(0,s),r.objectName=n)}if(r.propertyName===null||r.propertyName.length===0)throw Error("PropertyBinding: can not parse propertyName from trackName: "+t);return r}static findNode(t,i){if(i===void 0||i===""||i==="."||i===-1||i===t.name||i===t.uuid)return t;if(t.skeleton){let r=t.skeleton.getBoneByName(i);if(r!==void 0)return r}if(t.children){let r=function(n){for(let a=0;a<n.length;a++){let o=n[a];if(o.name===i||o.uuid===i)return o;let l=r(o.children);if(l)return l}return null},s=r(t.children);if(s)return s}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(t,i){t[i]=this.targetObject[this.propertyName]}_getValue_array(t,i){let r=this.resolvedProperty;for(let s=0,n=r.length;s!==n;++s)t[i++]=r[s]}_getValue_arrayElement(t,i){t[i]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(t,i){this.resolvedProperty.toArray(t,i)}_setValue_direct(t,i){this.targetObject[this.propertyName]=t[i]}_setValue_direct_setNeedsUpdate(t,i){this.targetObject[this.propertyName]=t[i],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(t,i){this.targetObject[this.propertyName]=t[i],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(t,i){let r=this.resolvedProperty;for(let s=0,n=r.length;s!==n;++s)r[s]=t[i++]}_setValue_array_setNeedsUpdate(t,i){let r=this.resolvedProperty;for(let s=0,n=r.length;s!==n;++s)r[s]=t[i++];this.targetObject.needsUpdate=!0}
vendor: 4,150 bytes, line 1
1_setValue_array_setMatrixWorldNeedsUpdate(t,i){let r=this.resolvedProperty;for(let s=0,n=r.length;s!==n;++s)r[s]=t[i++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(t,i){this.resolvedProperty[this.propertyIndex]=t[i]}_setValue_arrayElement_setNeedsUpdate(t,i){this.resolvedProperty[this.propertyIndex]=t[i],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(t,i){this.resolvedProperty[this.propertyIndex]=t[i],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(t,i){this.resolvedProperty.fromArray(t,i)}_setValue_fromArray_setNeedsUpdate(t,i){this.resolvedProperty.fromArray(t,i),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(t,i){this.resolvedProperty.fromArray(t,i),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(t,i){this.bind(),this.getValue(t,i)}_setValue_unbound(t,i){this.bind(),this.setValue(t,i)}bind(){let t=this.node,i=this.parsedPath,r=i.objectName,s=i.propertyName,n=i.propertyIndex;if(t||(t=Rc.findNode(this.rootNode,i.nodeName),this.node=t),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!t){de("PropertyBinding: No target node found for track: "+this.path+".");return}if(r){let h=i.objectIndex;switch(r){case"materials":if(!t.material){re("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!t.material.materials){re("PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}t=t.material.materials;break;case"bones":if(!t.skeleton){re("PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}t=t.skeleton.bones;for(let u=0;u<t.length;u++)if(t[u].name===h){h=u;break}break;case"map":if("map"in t){t=t.map;break}if(!t.material){re("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!t.material.map){re("PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}t=t.material.map;break;default:if(t[r]===void 0){re("PropertyBinding: Can not bind to objectName of node undefined.",this);return}t=t[r]}if(h!==void 0){if(t[h]===void 0){re("PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,t);return}t=t[h]}}let a=t[s];if(a===void 0){let h=i.nodeName;re("PropertyBinding: Trying to update property for track: "+h+"."+s+" but it wasn't found.",t);return}let o=this.Versioning.None;this.targetObject=t,t.isMaterial===!0?o=this.Versioning.NeedsUpdate:t.isObject3D===!0&&(o=this.Versioning.MatrixWorldNeedsUpdate);let l=this.BindingType.Direct;if(n!==void 0){if(s==="morphTargetInfluences"){if(!t.geometry){re("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!t.geometry.morphAttributes){re("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}t.morphTargetDictionary[n]!==void 0&&(n=t.morphTargetDictionary[n])}l=this.BindingType.ArrayElement,this.resolvedProperty=a,this.propertyIndex=n}else a.fromArray!==void 0&&a.toArray!==void 0?(l=this.BindingType.HasFromToArray,this.resolvedProperty=a):Array.isArray(a)?(l=this.BindingType.EntireArray,this.resolvedProperty=a):this.propertyName=s;this.getValue=this.GetterByBindingType[l],this.setValue=this.SetterByBindingTypeAndVersioning[l][o]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}};gi.Composite=kU,gi.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},gi.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},gi.prototype.GetterByBindingType=[gi.prototype._getValue_direct,gi.prototype._getValue_array,gi.prototype._getValue_arrayElement,gi.prototype._getValue_toArray],gi.prototype.SetterByBindingTypeAndVersioning=[[gi.prototype._setValue_direct,gi.prototype._setValue_direct_setNeedsUpdate,gi.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[gi.prototype._setValue_array,gi.prototype._setValue_array_setNeedsUpdate,gi.prototype._setValue_array_setMatr
1ixWorldNeedsUpdate],[gi.prototype._setValue_arrayElement,gi.prototype._setValue_arrayElement_setNeedsUpdate,gi.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[gi.prototype._setValue_fromArray,gi.prototype._setValue_fromArray_setNeedsUpdate,gi.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];var IU=class extends mx{constructor(e,t,i=1){super(e,t),this.isInstancedInterleavedBuffer=!0,this.meshPerAttribute=i}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}clone(e){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}},tC=new $e,FU=class{constructor(e,t,i=0,r=1/0){this.ray=new bx(e,t),this.near=i,this.far=r,this.camera=null,this.layers=new cM,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):re("Raycaster: Unsupported camera type: "+t.type)}setFromXRController(e){return tC.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(tC),this}intersectObject(e,t=!0,i=[]){return jx(e,this,i,t),i.sort(iC),i}intersectObjects(e,t=!0,i=[]){for(let r=0,s=e.length;r<s;r++)jx(e[r],this,i,t);return i.sort(iC),i}};function iC(e,t){return e.distance-t.distance}function jx(e,t,i,r){let s=!0;if(e.layers.test(t.layers)&&e.raycast(t,i)===!1&&(s=!1),s===!0&&r===!0){let n=e.children;for(let a=0,o=n.length;a<o;a++)jx(n[a],t,i,!0)}}var rC=class lO{static{lO.prototype.isMatrix2=!0}constructor(t,i,r,s){this.elements=[1,0,0,1],t!==void 0&&this.set(t,i,r,s)}identity(){return this.set(1,0,0,1),this}fromArray(t,i=0){for(let r=0;r<4;r++)this.elements[r]=t[r+i];return this}set(t,i,r,s){let n=this.elements;return n[0]=t,n[2]=i,n[1]=r,n[3]=s,this}};function DU(e,t,i,r){let s=OU(r);switch(i){case rB:return e*t;case _g:return e*t/s.components*s.byteLength;case $1:return e*t/s.components*s.byteLength;case Oo:return e*t*2/s.components*s.byteLength;case W1:return e*t*2/s.components*s.byteLength;case j1:return e*t*3/s.components*s.byteLength;case Br:return e*t*4/s.components*s.byteLength;case H1:return e*t*4/s.components*s.byteLength;case b2:case _2:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*8;case T2:case w2:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*16;case aB:case lB:return Math.max(e,16)*Math.max(t,8)/4;case nB:case oB:return Math.max(e,8)*Math.max(t,8)/2;case S2:case M2:case R2:case E2:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*8;case C2:case A2:case N2:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*16;case L2:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*16;case P2:return Math.floor((e+4)/5)*Math.floor((t+3)/4)*16;case k2:return Math.floor((e+4)/5)*Math.floor((t+4)/5)*16;case I2:return Math.floor((e+5)/6)*Math.floor((t+4)/5)*16;case F2:return Math.floor((e+5)/6)*Math.floor((t+5)/6)*16;case D2:return Math.floor((e+7)/8)*Math.floor((t+4)/5)*16;case O2:return Math.floor((e+7)/8)*Math.floor((t+5)/6)*16;case B2:return Math.floor((e+7)/8)*Math.floor((t+7)/8)*16;case U2:return Math.floor((e+9)/10)*Math.floor((t+4)/5)*16;case V2:return Math.floor((e+9)/10)*Math.floor((t+5)/6)*16;case z2:return Math.floor((e+9)/10)*Math.floor((t+7)/8)*16;case G2:return Math.floor((e+9)/10)*Math.floor((t+9)/10)*16;case j2:return Math.floor((e+11)/12)*Math.floor((t+9)/10)*16;case $2:return Math.floor((e+11)/12)*Math.floor((t+11)/12)*16;case W2:case hB:case uB:return Math.ceil(e/4)*Math.ceil(t/4)*16;case H2:case q2:return Math.ceil(e/4)*Math.ceil(t/4)*8;case X2:case Y2:return Math.ceil(e/4)*Math.ceil(t/4)*16}throw Error(`Unable to determine texture byte length for ${i} format.`)}function OU(e){switch(e){case hr:case Nc:return{byteLength:1,components:1};case ku:case Lc:case as:return{byteLength:2,components:1};case tB:case iB:return{byteLength:2,components:4};case ur:case Do:case Pn:return{byteLength:4,components:1};case x2:case v2:return{byteLength:4,components:3}}throw Error(`Unknown texture type ${e}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:lh}})),typeof window<"u"&&(window.__THREE__?de("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=lh);var BU="alphaMap.alphaTest.anisotropy.anisotropyMap.anisotropyRotation.aoMap.aoMapIntensity.attenuationColor.attenuationDistance.bumpMap.clearcoat.clearcoatMap.clearcoatNormalMap.clearcoatNormalScale.clearcoatRoughness.color.dispersion.displacementMap.emissive.emissiveIntensity.emissiveMap.envMap.envMapIntensity.gradientMap.ior.iridescence.iridescenceIOR.iridescenceMap.iridescenceThicknessMap.lightMap.lightMapIntensity.map.matcap.metalness.metalnessMap.normalMap.normalScale.opacity.roughness.roughnessMap.sheen.sheenColor.sheenColorMap.sheenRoughnessMap.shininess.specular.specularColor.specularColorMap.specularIntensity.specularIntensityMap.specularMap.thickness.transmission.transmissionMap".split("."),$x=new WeakMap,UU=class{constructor(e){this.renderObjects=new WeakMap,this.hasNode=this.containsNode(e),this.hasAnimation=e.object.isSkinnedMesh===!0,this.refreshUniforms=BU,this.renderId=0}firstInitialization(e){return this.renderObjects.has(e)===!1?(this.getRenderObjectData(e),!0):!1}needsVelocity(e){let t=e.getMRT();return t!==null&&t.has("velocity")}getRenderObjectData(e){let t=this.renderObjects.get(e);if(t===void 0){let{geometry:i,material:r,object:s}=e;if(t={material:this.getMaterialData(r),geometry:{id:i.id,attributes:this.getAttributesData(i.attributes),indexId:i.index?i.index.id:null,indexVersion:i.index?i.index.version:null,drawRange:{start:i.drawRange.start,count:i.drawRange.count}},worldMatrix:s.matrixWorld.clone()},s.center&&(t.center=s.center.clone()),s.morphTargetInfluences&&(t.morphTargetInfluences=s.morphTargetInfluences.slice()),e.bundle!==null&&(t.version=e.bundle.version),t.material.transmission>0){let{width:n,height:a}=e.context;t.bufferWidth=n,t.bufferHeight=a}t.lights=this.getLightsData(e.lightsNode.getLights()),this.renderObjects.set(e,t)}return t}getAttributesData(e){let t={};for(let i in e){let r=e[i];t[i]={id:r.id,version:r.version}}return t}containsNode(e){let t=e.material;for(let i in t)if(t[i]&&t[i].isNode)return!0;return!!(e.context.modelViewMatrix||e.context.modelNormalViewMatrix||e.context.getAO||e.context.getShadow)}getMaterialData(e){let t={};for(let i of this.refreshUniforms){let r=e[i];r!=null&&(typeof r=="object"&&r.clone!==void 0?r.isTexture===!0?t[i]={id:r.id,version:r.version}:t[i]=r.clone():t[i]=r)}return t}equals(e,t){let{object:i,material:r,geometry:s}=e,n=this.getRenderObjectData(e);if(n.worldMatrix.equals(i.matrixWorld)!==!0)return n.worldMatrix.copy(i.matrixWorld),!1;let a=n.material;for(let y in a){let x=a[y],b=r[y];if(x.equals!==void 0){if(x.equals(b)===!1)return x.copy(b),!1}
1else if(b.isTexture===!0){if(x.id!==b.id||x.version!==b.version)return x.id=b.id,x.version=b.version,!1}else if(x!==b)return a[y]=b,!1}if(a.transmission>0){let{width:y,height:x}=e.context;if(n.bufferWidth!==y||n.bufferHeight!==x)return n.bufferWidth=y,n.bufferHeight=x,!1}let o=n.geometry,l=s.attributes,h=o.attributes;if(o.id!==s.id)return o.id=s.id,!1;let u=0,d=0;for(let y in l)u++;for(let y in h){d++;let x=h[y],b=l[y];if(b===void 0)return delete h[y],!1;if(x.id!==b.id||x.version!==b.version)return x.id=b.id,x.version=b.version,!1}if(d!==u)return n.geometry.attributes=this.getAttributesData(l),!1;let c=s.index,p=o.indexId,m=o.indexVersion,g=c?c.id:null,f=c?c.version:null;if(p!==g||m!==f)return o.indexId=g,o.indexVersion=f,!1;if(o.drawRange.start!==s.drawRange.start||o.drawRange.count!==s.drawRange.count)return o.drawRange.start=s.drawRange.start,o.drawRange.count=s.drawRange.count,!1;if(n.morphTargetInfluences){let y=!1;for(let x=0;x<n.morphTargetInfluences.length;x++)n.morphTargetInfluences[x]!==i.morphTargetInfluences[x]&&(n.morphTargetInfluences[x]=i.morphTargetInfluences[x],y=!0);if(y)return!1}if(n.lights){for(let y=0;y<t.length;y++)if(n.lights[y].map!==t[y].map)return!1}return n.center&&n.center.equals(i.center)===!1?(n.center.copy(i.center),!0):(e.bundle!==null&&(n.version=e.bundle.version),!0)}getLightsData(e){let t=[];for(let i of e)i.isSpotLight===!0&&i.map!==null&&t.push({map:i.map.version});return t}getLights(e,t){if($x.has(e)){let r=$x.get(e);if(r.renderId===t)return r.lightsData}let i=this.getLightsData(e.getLights());return $x.set(e,{renderId:t,lightsData:i}),i}needsRefresh(e,t){if(this.hasNode||this.hasAnimation||this.firstInitialization(e)||this.needsVelocity(t.renderer))return!0;let{renderId:i}=t;if(this.renderId!==i)return this.renderId=i,!0;let r=e.object.static===!0,s=e.bundle!==null&&e.bundle.static===!0&&this.getRenderObjectData(e).version===e.bundle.version;if(r||s)return!1;let n=this.getLights(e.lightsNode,i);return this.equals(e,n)!==!0}},VU=[/^StackTrace\.js$/,/^TSLCore\.js$/,/^.*Node\.js$/,/^three\.webgpu.*\.js$/];function zU(e){let t=/(?:at\s+(.+?)\s+\()?(?:(.+?)@)?([^@\s()]+):(\d+):(\d+)/;return e.split(`
2`).map(i=>{let r=i.match(t);if(!r)return null;let s=r[1]||r[2]||"",n=r[3].split("?")[0],a=parseInt(r[4],10),o=parseInt(r[5],10);return{fn:s,file:n.split("/").pop(),line:a,column:o}}).filter(i=>i&&!VU.some(r=>r.test(i.file)))}var fi=class{constructor(e=null){this.isStackTrace=!0,this.stack=zU(e||Error().stack)}getLocation(){if(this.stack.length===0)return"[Unknown location]";let e=this.stack[0],t=e.fn;return`${t?`"${t}()" at `:""}"${e.file}:${e.line}"`}getError(e){return this.stack.length===0?e:`${e}
3${this.stack.map(t=>{let i=`${t.file}:${t.line}:${t.column}`;return t.fn?`    at ${t.fn} (${i})`:`    at ${i}`}).join(`
4`)}`}};function Wx(e,t=0){let i=3735928559^t,r=1103547991^t;if(e instanceof Array)for(let s=0,n;s<e.length;s++)n=e[s],i=Math.imul(i^n,2654435761),r=Math.imul(r^n,1597334677);else for(let s=0,n;s<e.length;s++)n=e.charCodeAt(s),i=Math.imul(i^n,2654435761),r=Math.imul(r^n,1597334677);return i=Math.imul(i^i>>>16,2246822507),i^=Math.imul(r^r>>>13,3266489909),r=Math.imul(r^r>>>16,2246822507),r^=Math.imul(i^i>>>13,3266489909),4294967296*(2097151&r)+(i>>>0)}var id=e=>Wx(e),tp=e=>Wx(e),ip=(...e)=>Wx(e),GU=new Map([[1,"float"],[2,"vec2"],[3,"vec3"],[4,"vec4"],[9,"mat3"],[16,"mat4"]]),sC=new WeakMap;function nC(e){return GU.get(e)}function sf(e){if(/[iu]?vec\d/.test(e))return e.startsWith("ivec")?Int32Array:e.startsWith("uvec")?Uint32Array:Float32Array;if(/mat\d/.test(e)||/float/.test(e))return Float32Array;if(/uint/.test(e))return Uint32Array;if(/int/.test(e))return Int32Array;throw Error(`THREE.NodeUtils: Unsupported type: ${e}`)}function aC(e){if(/float|int|uint/.test(e))return 1;if(/vec2/.test(e))return 2;if(/vec3/.test(e))return 3;if(/vec4/.test(e)||/mat2/.test(e))return 4;if(/mat3/.test(e))return 9;if(/mat4/.test(e))return 16;re(`TSL: Unsupported type: ${e}`,new fi)}function jU(e){if(/float|int|uint/.test(e))return 1;if(/vec2/.test(e))return 2;if(/vec3/.test(e))return 3;if(/vec4/.test(e)||/mat2/.test(e))return 4;if(/mat3/.test(e))return 12;if(/mat4/.test(e))return 16;re(`TSL: Unsupported type: ${e}`,new fi)}function $U(e){if(/float|int|uint/.test(e))return 4;if(/vec2/.test(e))return 8;if(/vec3/.test(e)||/vec4/.test(e))return 16;if(/mat2/.test(e))return 8;if(/mat3/.test(e)||/mat4/.test(e))return 16;re(`TSL: Unsupported type: ${e}`,new fi)}function qo(e){if(e==null)return null;let t=typeof e;return e.isNode===!0?"node":t==="number"?"float":t==="boolean"?"bool":t==="string"?"string":t==="function"?"shader":e.isVector2===!0?"vec2":e.isVector3===!0?"vec3":e.isVector4===!0?"vec4":e.isMatrix2===!0?"mat2":e.isMatrix3===!0?"mat3":e.isMatrix4===!0?"mat4":e.isColor===!0?"color":e instanceof ArrayBuffer?"ArrayBuffer":null}function Hx(e,...t){let i=e?e.slice(-4):void 0;return t.length===1&&(i==="vec2"?t=[t[0],t[0]]:i==="vec3"?t=[t[0],t[0],t[0]]:i==="vec4"&&(t=[t[0],t[0],t[0],t[0]])),e==="color"?new Ke(...t):i==="vec2"?new ge(...t):i==="vec3"?new F(...t):i==="vec4"?new yt(...t):i==="mat2"?new rC(...t):i==="mat3"?new Os(...t):i==="mat4"?new $e(...t):e==="bool"?t[0]||!1:e==="float"||e==="int"||e==="uint"?t[0]||0:e==="string"?t[0]||"":e==="ArrayBuffer"?HU(t[0]):null}function oC(e){let t=sC.get(e);return t===void 0&&(t={},sC.set(e,t)),t}function WU(e){let t="",i=new Uint8Array(e);for(let r=0;r<i.length;r++)t+=String.fromCharCode(i[r]);return btoa(t)}function HU(e){return Uint8Array.from(atob(e),t=>t.charCodeAt(0)).buffer}var rp={VERTEX:"vertex",FRAGMENT:"fragment"},Re={NONE:"none",FRAME:"frame",RENDER:"render",OBJECT:"object"},qU={BOOLEAN:"bool",INTEGER:"int",FLOAT:"float",VECTOR2:"vec2",VECTOR3:"vec3",VECTOR4:"vec4",MATRIX2:"mat2",MATRIX3:"mat3",MATRIX4:"mat4"},pr={READ_ONLY:"readOnly",WRITE_ONLY:"writeOnly",READ_WRITE:"readWrite"},lC=["fragment","vertex"],nf=["setup","analyze","generate"],af=[...lC,"compute"],_h=["x","y","z","w"],XU={analyze:"setup",generate:"analyze"},YU=0,ve=class hO extends Ds{static get type(){return"Node"}constructor(t=null){super(),this.nodeType=t,this.updateType=Re.NONE,this.updateBeforeType=Re.NONE,this.updateAfterType=Re.NONE,this.version=0,this.name="",this.global=!1,this.parents=!1,this.isNode=!0,this._beforeNodes=null,this._cacheKey=null,this._uuid=null,this._cacheKeyVersion=0,this.id=YU++,this.stackTrace=null,hO.captureStackTrace===!0&&(this.stackTrace=new fi)}set needsUpdate(t){t===!0&&this.version++}get uuid(){return this._uuid===null&&(this._uuid=aM.generateUUID()),this._uuid}get type(){return this.constructor.type}onUpdate(t,i){return this.updateType=i,this.update=t.bind(this),this}onFrameUpdate(t){return this.onUpdate(t,Re.FRAME)}
4onRenderUpdate(t){return this.onUpdate(t,Re.RENDER)}onObjectUpdate(t){return this.onUpdate(t,Re.OBJECT)}onReference(t){return this.updateReference=t.bind(this),this}updateReference(){return this}isGlobal(){return this.global}*getChildren(){for(let{childNode:t}of this._getChildren())yield t}dispose(){this.dispatchEvent({type:"dispose"})}traverse(t){t(this);for(let i of this.getChildren())i.traverse(t)}_getChildren(t=new Set){let i=[];t.add(this);for(let r of Object.getOwnPropertyNames(this)){let s=this[r];if(!(r.startsWith("_")===!0||t.has(s))){if(Array.isArray(s)===!0)for(let n=0;n<s.length;n++){let a=s[n];a&&a.isNode===!0&&i.push({property:r,index:n,childNode:a})}else if(s&&s.isNode===!0)i.push({property:r,childNode:s});else if(s&&Object.getPrototypeOf(s)===Object.prototype)for(let n in s){if(n.startsWith("_")===!0)continue;let a=s[n];a&&a.isNode===!0&&i.push({property:r,index:n,childNode:a})}}}return i}getCacheKey(t=!1,i=null){if(t||=this.version!==this._cacheKeyVersion,t===!0||this._cacheKey===null){i===null&&(i=new Set);let r=[];for(let{property:s,childNode:n}of this._getChildren(i))r.push(id(s.slice(0,-4)),n.getCacheKey(t,i));this._cacheKey=ip(tp(r),this.customCacheKey()),this._cacheKeyVersion=this.version}return this._cacheKey}customCacheKey(){return this.id}getScope(){return this}getHash(){return String(this.id)}getUpdateType(){return this.updateType}getUpdateBeforeType(){return this.updateBeforeType}getUpdateAfterType(){return this.updateAfterType}getElementType(t){let i=this.getNodeType(t);return t.getElementType(i)}getMemberType(){return"void"}getNodeType(t,i=null){let r=t.getDataFromNode(this),s;return i===null?(s=r.type,s===void 0&&(s=this.generateNodeType(t),r.type=s)):(r.typeFromOutput=r.typeFromOutput||{},s=r.typeFromOutput[i],s===void 0&&(s=this.generateNodeType(t,i),r.typeFromOutput[i]=s)),s}generateNodeType(t,i=null){let r=t.getNodeProperties(this);return r.outputNode?r.outputNode.getNodeType(t,i):this.nodeType}getShared(t){let i=this.getHash(t);return t.getNodeFromHash(i)||this}getArrayCount(){return null}setup(t){let i=t.getNodeProperties(this),r=0;for(let s of this.getChildren())i["node"+r++]=s;return i.outputNode||null}analyze(t,i=null){let r=t.increaseUsage(this);if(this.parents===!0){let s=t.getDataFromNode(this,"any");s.stages=s.stages||{},s.stages[t.shaderStage]=s.stages[t.shaderStage]||[],s.stages[t.shaderStage].push(i)}if(r===1){let s=t.getNodeProperties(this);for(let n of Object.values(s))n&&n.isNode===!0&&n.build(t,this)}}generate(t,i){let{outputNode:r}=t.getNodeProperties(this);if(r&&r.isNode===!0)return r.build(t,i)}updateBefore(){de("Abstract function.")}updateAfter(){de("Abstract function.")}update(){de("Abstract function.")}before(t){return this._beforeNodes===null&&(this._beforeNodes=[]),this._beforeNodes.push(t),this}build(t,i=null){let r=this.getShared(t);if(this!==r)return r.build(t,i);if(this._beforeNodes!==null){let l=this._beforeNodes;this._beforeNodes=null;for(let h of l)h.build(t,i);this._beforeNodes=l}let s=t.getDataFromNode(this);s.buildStages=s.buildStages||{},s.buildStages[t.buildStage]=!0;let n=XU[t.buildStage];if(n&&s.buildStages[n]!==!0){let l=t.getBuildStage();t.setBuildStage(n),this.build(t),t.setBuildStage(l)}t.addChain(this);let a=null,o=t.getBuildStage();if(o==="setup"){t.addNode(this),this.updateReference(t);let l=t.getNodeProperties(this);if(l.initialized!==!0){l.initialized=!0,l.outputNode=this.setup(t)||l.outputNode||null;for(let h of Object.values(l))if(h&&h.isNode===!0){if(h.parents===!0){let u=t.getNodeProperties(h);u.parents=u.parents||[],u.parents.push(this)}h.build(t)}t.addSequentialNode(this)}a=l.outputNode}else if(o==="analyze")this.analyze(t,i);else if(o==="generate"){if(this.generate.length<2){let l=this.getNodeType(t),h=t.getDataFromNode(this);a=h.snippet,a===void 0?h.generated===void 0?(h.generated=!0,a=this.generate(t)||"",h.snippet=a):(de("Node: Recursion detected.",this),a="/* Recursion detected. */"):h.flowCodes!==void 0&&t.context.nodeBlock!==void 0&&t.addFlowCodeHierarchy(this,t.context.nodeBlock),a=t.format(a,l,i)}else a=this.generate(t,i)||"";a===""&&i!==null&&i!=="void"&&i!=="OutputType"&&(re(`TSL: Invalid generated code, expected a "${i}".`),a=t.generateConst(i))}return t.removeChain(this),a}getSerializeChildren(){return this._getChildren()}serialize(t){let i=this.getSerializeChildren(),r={};for(let{property:s,index:n,childNode:a}of i)n===void 0?r[s]=a.toJSON(t.meta).uuid:(r[s]===void 0&&(r[s]=Number.isInteger(n)?[]:{}),r[s][n]=a.toJSON(t.meta).uuid);Object.keys(r).length>0&&(t.inputNodes=r)}deserialize(t){if(t.inputNodes!==void 0){let i=t.meta.nodes;for(let r in t.inputNodes)if(Array.isArray(t.inputNodes[r])){let s=[];for(let n of t.inputNodes[r])s.push(i[n]);this[r]=s}else if(typeof t.inputNodes[r]=="object"){let s={};for(let n in t.inputNodes[r])s[n]=i[t.inputNodes[r][n]];this[r]=s}else{let s=t.inputNodes[r];this[r]=i[s]}}}toJSON(t){let{uuid:i,type:r}=this,s=t===void 0||typeof t=="string";s&&(t={textures:{},images:{},nodes:{}});let n=t.nodes[i];n===void 0&&(n={uuid:i,type:r,meta:t,metadata:{version:4.7,type:"Node",generator:"Node.toJSON"}},s!==!0&&(t.nodes[n.uuid]=n),this.serialize(n),delete n.meta);function a(o){let l=[];for(let h in o){let u=o[h];delete u.metadata,l.push(u)}return l}if(s){let o=a(t.textures),l=a(t.images),h=a(t.nodes);o.length>0&&(n.textures=o),l.length>0&&(n.images=l),h.length>0&&(n.nodes=h)}return n}};ve.captureStackTrace=!1;var Th=class extends ve{static get type(){return"ArrayElementNode"}constructor(e,t){super(),this.node=e,this.indexNode=t,this.isArrayElementNode=!0}generateNodeType(e){return this.node.getElementType(e)}getMemberType(e,t){return this.node.getMemberType(e,t)}generate(e){let t=this.indexNode.getNodeType(e);return`${this.node.build(e)}[ ${this.indexNode.build(e,!e.isVector(t)&&e.isInteger(t)?t:"uint")} ]`}},hC=class extends ve{static get type(){return"ConvertNode"}constructor(e,t){super(),this.node=e,this.convertTo=t}generateNodeType(e){let t=this.node.getNodeType(e),i=null;for(let r of this.convertTo.split("|"))(i===null||e.getTypeLength(t)===e.getTypeLength(r))&&(i=r);return i}serialize(e){super.serialize(e),e.convertTo=this.convertTo}deserialize(e){super.deserialize(e),this.convertTo=e.convertTo}generate(e,t){let i=this.node,r=this.getNodeType(e),s=i.build(e,r);return e.format(s,r,t)}},ei=class extends ve{static get type(){return"TempNode"}constructor(e=null){super(e),this.isTempNode=!0}hasDependencies(e){return e.getDataFromNode(this).usageCount>1}build(e,t){if(e.getBuildStage()==="generate"){let i=e.getVectorType(this.getNodeType(e,t)),r=e.getDataFromNode(this);if(r.propertyName!==void 0)return e.format(r.propertyName,i,t);if(i!=="void"&&t!=="void"&&this.hasDependencies(e)){let s=super.build(e,i),n=e.getVarFromNode(this,null,i),a=e.getPropertyName(n);return e.addLineFlowCode(`${a} = ${s}`,this),r.snippet=s,r.propertyName=a,e.format(r.propertyName,i,t)}}return super.build(e,t)}},KU=class extends ei{static get type(){return"JoinNode"}constructor(e=[],t=null){super(t),this.nodes=e}generateNodeType(e){return this.nodeType===null?e.getTypeFromLength(this.nodes.reduce((t,i)=>t+e.getTypeLength(i.getNodeType(e)),0)):e.getVectorType(this.nodeType)}generate(e,t){let i=this.getNodeType(e),r=e.getTypeLength(i),s=this.nodes,n=e.getComponentType(i),a=[],o=0;for(let h of s){if(o>=r){re(`TSL: Length of parameters exceeds maximum length of function '${i}()' type.`,this.stackTrace);break}let u=h.getNodeType(e),d=e.getTypeLength(u),c;if(o+d>r&&(re(`TSL: Length of '${i}()' data exceeds maximum length of output type.`,this.stackTrace),d=r-o,u=e.getTypeFromLength(d)),o+=d,c=h.build(e,u),e.getComponentType(u)!==n){let p=e.getTypeFromLength(d,n);c=e.format(c,u,p)}a.push(c)}let l=`${e.getType(i)}( ${a.join(", ")} )`;return e.format(l,i,t)}},ZU=_h.join(""),uC=class extends ve{static get type(){return"SplitNode"}constructor(e,t="x"){super(),this.node=e,this.components=t,this.isSplitNode=!0}getVectorLength(){let e=this.components.length;for(let t of this.components)e=Math.max(_h.indexOf(t)+1,e);return e}getComponentType(e){return e.getComponentType(this.node.getNodeType(e))}generateNodeType(e){return e.getTypeFromLength(this.components.length,this.getComponentType(e))}getScope(){return this.node.getScope()}generate(e,t){let i=this.node,r=e.getTypeLength(i.getNodeType(e)),s=null;if(r>1){let n=null;this.getVectorLength()>=r&&(n=e.getTypeFromLength(this.getVectorLength(),this.getComponentType(e)));let a=i.build(e,n);s=this.components.length===r&&this.components===ZU.slice(0,this.components.length)?e.format(a,n,t):e.format(`${a}.${this.components}`,this.getNodeType(e),t)}else s=i.build(e,t);return s}serialize(e){super.serialize(e),e.components=this.components}deserialize(e){super.deserialize(e),this.components=e.components}},JU=class extends ei{static get type(){return"SetNode"}constructor(e,t,i){super(),this.sourceNode=e,this.components=t,this.targetNode=i}
4generateNodeType(e){return this.sourceNode.getNodeType(e)}generate(e){let{sourceNode:t,components:i,targetNode:r}=this,s=this.getNodeType(e),n=e.getComponentType(r.getNodeType(e)),a=e.getTypeFromLength(i.length,n),o=r.build(e,a),l=t.build(e,s),h=e.getTypeLength(s),u=[];for(let d=0;d<h;d++){let c=_h[d];c===i[0]?(u.push(o),d+=i.length-1):u.push(l+"."+c)}return`${e.getType(s)}( ${u.join(", ")} )`}},QU=class extends ei{static get type(){return"FlipNode"}constructor(e,t){super(),this.sourceNode=e,this.components=t}generateNodeType(e){return this.sourceNode.getNodeType(e)}generate(e){let{components:t,sourceNode:i}=this,r=this.getNodeType(e),s=i.build(e),n=e.getVarFromNode(this),a=e.getPropertyName(n);e.addLineFlowCode(a+" = "+s,this);let o=e.getTypeLength(r),l=[],h=0;for(let u=0;u<o;u++){let d=_h[u];d===t[h]?(l.push("1.0 - "+(a+"."+d)),h++):l.push(a+"."+d)}return`${e.getType(r)}( ${l.join(", ")} )`}},qx=class extends ve{static get type(){return"InputNode"}constructor(e,t=null){super(t),this.isInputNode=!0,this.value=e,this.precision=null}generateNodeType(){return this.nodeType===null?qo(this.value):this.nodeType}getInputType(e){return this.getNodeType(e)}setPrecision(e){return this.precision=e,this}serialize(e){super.serialize(e),e.value=this.value,this.value&&this.value.toArray&&(e.value=this.value.toArray()),e.valueType=qo(this.value),e.nodeType=this.nodeType,e.valueType==="ArrayBuffer"&&(e.value=WU(e.value)),e.precision=this.precision}deserialize(e){super.deserialize(e),this.nodeType=e.nodeType,this.value=Array.isArray(e.value)?Hx(e.valueType,...e.value):e.value,this.precision=e.precision||null,this.value&&this.value.fromArray&&(this.value=this.value.fromArray(e.value))}generate(){de("Abstract function.")}},dC=/float|u?int/,Vs=class extends qx{static get type(){return"ConstNode"}constructor(e,t=null){super(e,t),this.isConstNode=!0}generateConst(e){return e.generateConst(this.getNodeType(e),this.value)}generate(e,t){let i=this.getNodeType(e);return dC.test(i)&&dC.test(t)?e.generateConst(t,this.value):e.format(this.generateConst(e),i,t)}},e6=class extends ve{static get type(){return"MemberNode"}constructor(e,t){super(),this.structNode=e,this.property=t,this.isMemberNode=!0}hasMember(e){return this.structNode.isMemberNode&&this.structNode.hasMember(e)===!1?!1:this.structNode.getMemberType(e,this.property)!=="void"}generateNodeType(e){return this.hasMember(e)===!1?"float":this.structNode.getMemberType(e,this.property)}getMemberType(e,t){if(this.hasMember(e)===!1)return"float";let i=this.getNodeType(e);return e.getStructTypeNode(i).getMemberType(e,t)}generate(e){if(this.hasMember(e)===!1){de(`TSL: Member "${this.property}" does not exist in struct.`,this.stackTrace);let t=this.getNodeType(e);return e.generateConst(t)}return this.structNode.build(e)+"."+this.property}},Xo=null,Xx=new Map;function H(e,t){if(Xx.has(e)){de(`TSL: Redefinition of method chaining '${e}'.`);return}if(typeof t!="function")throw Error(`THREE.TSL: Node element ${e} is not a function`);Xx.set(e,t),e!=="assign"&&(ve.prototype[e]=function(...i){return this.isStackNode?this.addToStack(t(...i)):t(this,...i)},ve.prototype[e+"Assign"]=function(...i){return this.isStackNode?this.assign(i[0],t(...i)):this.assign(t(this,...i))})}var t6=e=>e.replace(/r|s/g,"x").replace(/g|t/g,"y").replace(/b|p/g,"z").replace(/a|q/g,"w"),cC=e=>t6(e).split("").sort().join("");ve.prototype.assign=function(...e){if(this.isStackNode!==!0)return Xo===null?re("TSL: No stack defined for assign operation. Make sure the assign is inside a Fn().",new fi):Xo.assign(this,...e),this;{let t=Xx.get("assign");return this.addToStack(t(...e))}},ve.prototype.toVarIntent=function(){return this},ve.prototype.get=function(e){return new e6(this,e)};var sp={};function of(e,t,i){sp[e]=sp[t]=sp[i]={get(){this._cache=this._cache||{};let a=this._cache[e];return a===void 0&&(a=new uC(this,e),this._cache[e]=a),a},set(a){this[e].assign(xe(a))}};let r=e.toUpperCase(),s=t.toUpperCase(),n=i.toUpperCase();ve.prototype["set"+r]=ve.prototype["set"+s]=ve.prototype["set"+n]=function(a){let o=cC(e);return new JU(this,o,xe(a))},ve.prototype["flip"+r]=ve.prototype["flip"+s]=ve.prototype["flip"+n]=function(){let a=cC(e);return new QU(this,a)}}var Gn=["x","y","z","w"],jn=["r","g","b","a"],$n=["s","t","p","q"];for(let e=0;e<4;e++){let t=Gn[e],i=jn[e],r=$n[e];of(t,i,r);for(let s=0;s<4;s++){t=Gn[e]+Gn[s],i=jn[e]+jn[s],r=$n[e]+$n[s],of(t,i,r);for(let n=0;n<4;n++){t=Gn[e]+Gn[s]+Gn[n],i=jn[e]+jn[s]+jn[n],r=$n[e]+$n[s]+$n[n],of(t,i,r);for(let a=0;a<4;a++)t=Gn[e]+Gn[s]+Gn[n]+Gn[a],i=jn[e]+jn[s]+jn[n]+jn[a],r=$n[e]+$n[s]+$n[n]+$n[a],of(t,i,r)}}}for(let e=0;e<32;e++)sp[e]={get(){this._cache=this._cache||{};let t=this._cache[e];return t===void 0&&(t=new Th(this,new Vs(e,"uint")),this._cache[e]=t),t},set(t){this[e].assign(xe(t))}};Object.defineProperties(ve.prototype,sp);var pC=new WeakMap,i6=function(e,t=null){let i=qo(e);return i==="node"?e:t===null&&(i==="float"||i==="boolean")||i&&i!=="shader"&&i!=="string"?xe(Jx(e,t)):i==="shader"?e.isFn?e:k(e):e},r6=function(e,t=null){for(let i in e)e[i]=xe(e[i],t);return e},s6=function(e,t=null){let i=e.length;for(let r=0;r<i;r++)e[r]=xe(e[r],t);return e},mC=function(e,t=null,i=null,r=null){function s(u){return r===null?u=xe(u):(u=xe(Object.assign(u,r)),r.intent===!0&&(u=u.toVarIntent
4())),u}let n,a=t,o,l;function h(u){let d;return d=a?/[a-z]/i.test(a)?a+"()":a:e.type,o!==void 0&&u.length<o?(re(`TSL: "${d}" parameter length is less than minimum required.`,new fi),u.concat(Array(o-u.length).fill(0))):l!==void 0&&u.length>l?(re(`TSL: "${d}" parameter length exceeds limit.`,new fi),u.slice(0,l)):u}return t===null?n=(...u)=>s(new e(...wh(h(u)))):i===null?n=(...u)=>s(new e(t,...wh(h(u)))):(i=xe(i),n=(...u)=>s(new e(t,...wh(h(u)),i))),n.setParameterLength=(...u)=>(u.length===1?o=l=u[0]:u.length===2&&([o,l]=u),n),n.setName=u=>(a=u,n),n},n6=function(e,...t){return new e(...wh(t))},a6=class extends ve{constructor(e,t){super(),this.shaderNode=e,this.rawInputs=t,this.isShaderCallNodeInternal=!0}generateNodeType(e){return this.shaderNode.nodeType||this.getOutputNode(e).getNodeType(e)}getElementType(e){return this.getOutputNode(e).getElementType(e)}getMemberType(e,t){return this.getOutputNode(e).getMemberType(e,t)}call(e){let{shaderNode:t,rawInputs:i}=this,r=e.getNodeProperties(t),s=e.getClosestSubBuild(t.subBuilds)||"",n=s||"default";if(r[n])return r[n];let a=e.subBuildFn,o=e.fnCall;e.subBuildFn=s,e.fnCall=this;let l=null;if(t.layout){let h=pC.get(e.constructor);h===void 0&&(h=new WeakMap,pC.set(e.constructor,h));let u=h.get(t);u===void 0&&(u=xe(e.buildFunctionNode(t)),h.set(t,u)),e.addInclude(u);let d=i?o6(i):null;l=xe(u.call(d))}else{let h=new Proxy(e,{get:(p,m,g)=>{let f;return f=Symbol.iterator===m?function*(){yield void 0}:Reflect.get(p,m,g),f}}),u=i?l6(i):null,d=Array.isArray(i)?i.length>0:i!==null,c=t.jsFunc;l=xe(d||c.length>1?c(u,h):c(h))}return e.subBuildFn=a,e.fnCall=o,t.once&&(r[n]=l),l}setupOutput(e){return e.addStack(),e.stack.outputNode=this.call(e),e.removeStack()}getOutputNode(e){let t=e.getNodeProperties(this),i=e.getSubBuildOutput(this);return t[i]=t[i]||this.setupOutput(e),t[i].subBuild=e.getClosestSubBuild(this),t[i]}build(e,t=null){let i=null,r=e.getBuildStage(),s=e.getNodeProperties(this),n=e.getSubBuildOutput(this),a=this.getOutputNode(e),o=e.fnCall;if(e.fnCall=this,r==="setup"){let l=e.getSubBuildProperty("initialized",this);if(s[l]!==!0&&(s[l]=!0,s[n]=this.getOutputNode(e),s[n].build(e),this.shaderNode.subBuilds))for(let h of e.chaining){let u=e.getDataFromNode(h,"any");u.subBuilds=u.subBuilds||new Set;for(let d of this.shaderNode.subBuilds)u.subBuilds.add(d)}i=s[n]}else r==="analyze"?a.build(e,t):r==="generate"&&(i=a.build(e,t)||"");return e.fnCall=o,i}};function o6(e){let t;return uf(e),t=e[0]&&(e[0].isNode||Object.getPrototypeOf(e[0])!==Object.prototype)?[...e]:e[0],t}function l6(e){let t=0;return uf(e),new Proxy(e,{get:(i,r,s)=>{let n;if(r==="length")return n=e.length,n;if(Symbol.iterator===r)n=function*(){for(let a of e)yield xe(a)};else{if(e.length>0)if(Object.getPrototypeOf(e[0])===Object.prototype){let a=e[0];n=a[r]===void 0?a[t++]:Reflect.get(a,r,s)}else e[0]instanceof ve&&(n=e[r]===void 0?e[t++]:Reflect.get(e,r,s));else n=Reflect.get(i,r,s);n=xe(n)}return n}})}var h6=class extends ve{constructor(e,t){super(t),this.jsFunc=e,this.layout=null,this.global=!0,this.once=!1}setLayout(e){return this.layout=e,this}getLayout(){return this.layout}call(e=null){return new a6(this,e)}setup(){return this.call()}},u6=[!1,!0],d6=[0,1,2,3],c6=[-1,-2],gC=[.5,1.5,1/3,1e-6,1e6,Math.PI,Math.PI*2,1/Math.PI,2/Math.PI,1/(Math.PI*2),Math.PI/2],Yx=new Map;for(let e of u6)Yx.set(e,new Vs(e));var Kx=new Map;for(let e of d6)Kx.set(e,new Vs(e,"uint"));var Zx=new Map([...Kx].map(e=>new Vs(e.value,"int")));for(let e of c6)Zx.set(e,new Vs(e,"int"));var lf=new Map([...Zx].map(e=>new Vs(e.value)));for(let e of gC)lf.set(e,new Vs(e));for(let e of gC)lf.set(-e,new Vs(-e));var hf={bool:Yx,uint:Kx,ints:Zx,float:lf},fC=new Map([...Yx,...lf]),Jx=(e,t)=>fC.has(e)?fC.get(e):e.isNode===!0?e:new Vs(e,t),ki=function(e,t=null){return(...i)=>{for(let r of i)if(r===void 0)return re(`TSL: Invalid parameter for the type "${e}".`,new fi),new Vs(0,e);if((i.length===0||!["bool","float","int","uint"].includes(e)&&i.every(r=>{let s=typeof r;return s!=="object"&&s!=="function"}))&&(i=[Hx(e,...i)]),i.length===1&&t!==null&&t.has(i[0]))return np(t.get(i[0]));if(i.length===1){let r=Jx(i[0],e);return r.nodeType===e?np(r):np(new hC(r,e))}return np(new KU(i.map(r=>Jx(r)),e))}};function rd(e){return e&&e.isNode&&e.traverse(t=>{t.isConstNode&&(e=t.value)}),!!e}var yC=e=>e==null?null:e.nodeType||e.convertTo||(typeof e=="string"?e:null);function sd(e,t){return new h6(e,t)}var xe=(e,t=null)=>i6(e,t),np=(e,t=null)=>
4xe(e,t).toVarIntent(),uf=(e,t=null)=>new r6(e,t),wh=(e,t=null)=>new s6(e,t),Fe=(e,t=null,i=null,r=null)=>new mC(e,t,i,r),pe=(e,...t)=>new n6(e,...t),ne=(e,t=null,i=null,r={})=>new mC(e,t,i,{...r,intent:!0}),p6=0,m6=class extends ve{constructor(e,t=null){super();let i=null;t!==null&&(typeof t=="object"?i=t.return:(typeof t=="string"?i=t:re("TSL: Invalid layout type.",new fi),t=null)),this.shaderNode=new sd(e,i),t!==null&&this.setLayout(t),this.isFn=!0}setLayout(e){let t=this.shaderNode.nodeType;if(typeof e.inputs!="object"){let i={name:"fn"+p6++,type:t,inputs:[]};for(let r in e)r!=="return"&&i.inputs.push({name:r,type:e[r]});e=i}return this.shaderNode.setLayout(e),this}generateNodeType(e){return this.shaderNode.getNodeType(e)||"float"}call(...e){let t=this.shaderNode.call(e);return this.shaderNode.nodeType==="void"&&t.toStack(),t.toVarIntent()}once(e=null){return this.shaderNode.once=!0,this.shaderNode.subBuilds=e,this}generate(e){let t=this.getNodeType(e);return re('TSL: "Fn()" was declared but not invoked. Try calling it like "Fn()( ...params )".',this.stackTrace),e.generateConst(t)}};function k(e,t=null){let i=new m6(e,t);return new Proxy(()=>{},{apply(r,s,n){return i.call(...n)},get(r,s,n){return Reflect.get(i,s,n)},set(r,s,n,a){return Reflect.set(i,s,n,a)}})}var ap=e=>{Xo=e},Qx=()=>Xo,Se=(...e)=>Xo.If(...e),g6=(...e)=>Xo.Switch(...e);function df(e){return Xo&&Xo.addToStack(e),e}H("toStack",df);var xC=new ki("color"),C=new ki("float",hf.float),A=new ki("int",hf.ints),K=new ki("uint",hf.uint),vs=new ki("bool",hf.bool),se=new ki("vec2"),Ii=new ki("ivec2"),ev=new ki("uvec2"),vC=new ki("bvec2"),L=new ki("vec3"),tv=new ki("ivec3"),Sh=new ki("uvec3"),iv=new ki("bvec3"),Te=new ki("vec4"),rv=new ki("ivec4"),sv=new ki("uvec4"),bC=new ki("bvec4"),cf=new ki("mat2"),tr=new ki("mat3"),Yo=new ki("mat4"),f6=(e="")=>new Vs(e,"string"),y6=e=>new Vs(e,"ArrayBuffer");H("toColor",xC),H("toFloat",C),H("toInt",A),H("toUint",K),H("toBool",vs),H("toVec2",se),H("toIVec2",Ii),H("toUVec2",ev),H("toBVec2",vC),H("toVec3",L),H("toIVec3",tv),H("toUVec3",Sh),H("toBVec3",iv),H("toVec4",Te),H("toIVec4",rv),H("toUVec4",sv),H("toBVec4",bC),H("toMat2",cf),H("toMat3",tr),H("toMat4",Yo);var _C=Fe(Th).setParameterLength(2),TC=(e,t)=>new hC(xe(e),t),x6=(e,t)=>new uC(xe(e),t);H("element",_C),H("convert",TC);var v6=e=>(de("TSL: append() has been renamed to Stack().",new fi),df(e));H("append",e=>(de("TSL: .append() has been renamed to .toStack().",new fi),df(e)));var pt=class extends ve{static get type(){return"PropertyNode"}constructor(e,t=null,i=!1){super(e),this.name=t,this.varying=i,this.isPropertyNode=!0,this.global=!0}customCacheKey(){return id(this.type+":"+(this.name||"")+":"+(this.varying?"1":"0"))}getHash(e){return this.name||super.getHash(e)}generate(e){let t;return this.varying===!0?(t=e.getVaryingFromNode(this,this.name),t.needsInterpolation=!0):t=e.getVarFromNode(this,this.name),e.getPropertyName(t)}},Wa=(e,t)=>new pt(e,t),op=(e,t)=>new pt(e,t,!0),vt=pe(pt,"vec4","DiffuseColor"),Mh=pe(pt,"vec3","DiffuseContribution"),nv=pe(pt,"vec3","EmissiveColor"),Wn=pe(pt,"float","Roughness"),Ha=pe(pt,"float","Metalness"),pf=pe(pt,"float","Clearcoat"),nd=pe(pt,"float","ClearcoatRoughness"),bs=pe(pt,"vec3","Sheen"),Ko=pe(pt,"float","SheenRoughness"),mf=pe(pt,"float","Iridescence"),gf=pe(pt,"float","IridescenceIOR"),ff=pe(pt,"float","IridescenceThickness"),yf=pe(pt,"float","AlphaT"),Zo=pe(pt,"float","Anisotropy"),lp=pe(pt,"vec3","AnisotropyT"),Ch=pe(pt,"vec3","AnisotropyB"),Jo=pe(pt,"color","SpecularColor"),Rh=pe(pt,"color","SpecularColorBlended"),Eh=pe(pt,"float","SpecularF90"),xf=pe(pt,"float","Shininess"),ad=pe(pt,"vec4","Output"),vf=pe(pt,"float","dashSize"),av=pe(pt,"float","gapSize"),b6=pe(pt,"float","pointWidth"),hp=pe(pt,"float","IOR"),bf=pe(pt,"float","Transmission"),ov=pe(pt,"float","Thickness"),lv=pe(pt,"float","AttenuationDistance"),hv=pe(pt,"color","AttenuationColor"),uv=pe(pt,"float","Dispersion"),wC=class extends ve{static get type(){return"UniformGroupNode"}constructor(e,t=!1,i=1,r=null){super("string"),this.name=e,this.shared=t,this.order=i,this.updateType=r,this.isUniformGroup=!0}
4update(){this.needsUpdate=!0}serialize(e){super.serialize(e),e.name=this.name,e.version=this.version,e.shared=this.shared}deserialize(e){super.deserialize(e),this.name=e.name,this.version=e.version,this.shared=e.shared}},SC=(e,t=1,i=null)=>new wC(e,!1,t,i),_f=(e,t=0,i=null)=>new wC(e,!0,t,i),_6=_f("frame",0,Re.FRAME),we=_f("render",0,Re.RENDER),MC=SC("object",1,Re.OBJECT),up=class extends qx{static get type(){return"UniformNode"}constructor(e,t=null){super(e,t),this.isUniformNode=!0,this.name="",this.groupNode=MC}setName(e){return this.name=e,this}label(e){return de('TSL: "label()" has been deprecated. Use "setName()" instead.',new fi),this.setName(e)}setGroup(e){return this.groupNode=e,this}getGroup(){return this.groupNode}getUniformHash(e){return this.getHash(e)}onUpdate(e,t){return e=e.bind(this),super.onUpdate(i=>{let r=e(i,this);r!==void 0&&(this.value=r)},t)}getInputType(e){let t=super.getInputType(e);return t==="bool"&&(t="uint"),t}generate(e,t){let i=this.getNodeType(e),r=this.getUniformHash(e),s=e.getNodeFromHash(r);s===void 0&&(e.setHashNode(this,r),s=this);let n=s.getInputType(e),a=e.getUniformFromNode(s,n,e.shaderStage,this.name||e.context.nodeName),o=e.getPropertyName(a);e.context.nodeName!==void 0&&delete e.context.nodeName;let l=o;if(i==="bool"){let h=e.getDataFromNode(this),u=h.propertyName;if(u===void 0){let d=e.getVarFromNode(this,null,"bool");u=e.getPropertyName(d),h.propertyName=u,l=e.format(o,n,i),e.addLineFlowCode(`${u} = ${l}`,this)}l=u}return e.format(l,i,t)}},be=(e,t)=>{let i=yC(t||e);if(i===e&&(e=Hx(i)),e&&e.isNode===!0){let r=e.value;e.traverse(s=>{s.isConstNode===!0&&(r=s.value)}),e=r}return new up(e,i)},CC=class extends ei{static get type(){return"ArrayNode"}constructor(e,t,i=null){super(e),this.count=t,this.values=i,this.isArrayNode=!0}getArrayCount(){return this.count}generateNodeType(e){return this.nodeType===null?this.values[0].getNodeType(e):this.nodeType}getElementType(e){return this.getNodeType(e)}getMemberType(e,t){return this.nodeType===null?this.values[0].getMemberType(e,t):super.getMemberType(e,t)}generate(e){let t=this.getNodeType(e);return e.generateArray(t,this.count,this.values)}},RC=(...e)=>{let t;if(e.length===1){let i=e[0];t=new CC(null,i.length,i)}else{let i=e[0],r=e[1];t=new CC(i,r)}return xe(t)};H("toArray",(e,t)=>RC(Array(t).fill(e)));var EC=Fe(class extends ei{static get type(){return"AssignNode"}constructor(e,t){super(),this.targetNode=e,this.sourceNode=t,this.isAssignNode=!0}hasDependencies(){return!1}generateNodeType(e,t){return t==="void"?"void":this.targetNode.getNodeType(e)}needsSplitAssign(e){let{targetNode:t}=this;if(e.isAvailable("swizzleAssign")===!1&&t.isSplitNode&&t.components.length>1){let i=e.getTypeLength(t.node.getNodeType(e));return _h.join("").slice(0,i)!==t.components}return!1}setup(e){let{targetNode:t,sourceNode:i}=this,r=t.getScope(),s=e.getDataFromNode(r);s.assign=!0;let n=e.getNodeProperties(this);n.sourceNode=i,n.targetNode=t.context({assign:!0})}generate(e,t){let{targetNode:i,sourceNode:r}=e.getNodeProperties(this),s=this.needsSplitAssign(e),n=i.build(e),a=i.getNodeType(e),o=r.build(e,a),l=r.getNodeType(e),h=e.getDataFromNode(this),u;if(h.initialized===!0)t!=="void"&&(u=n);else if(s){let d=e.getVarFromNode(this,null,a),c=e.getPropertyName(d);e.addLineFlowCode(`${c} = ${o}`,this);let p=i.node,m=p.node.context({assign:!0}).build(e);for(let g=0;g<p.components.length;g++){let f=p.components[g];e.addLineFlowCode(`${m}.${f} = ${c}[ ${g} ]`,this)}t!=="void"&&(u=n)}else u=`${n} = ${o}`,(t==="void"||l==="void")&&(e.addLineFlowCode(u,this),t!=="void"&&(u=n));return h.initialized=!0,e.format(u,a,t)}}).setParameterLength(2);H("assign",EC);var T6=class extends ei{static get type(){return"FunctionCallNode"}constructor(e=null,t={}){super(),this.functionNode=e,this.parameters=t}setParameters(e){return this.parameters=e,this}getParameters(){return this.parameters}generateNodeType(e){return this.functionNode.getNodeType(e)}getMemberType(e,t){return this.functionNode.getMemberType(e,t)}generate(e){let t=[],i=this.functionNode,r=i.getInputs(e),s=this.parameters,n=(a,o)=>{let l=o.type,h=l==="pointer",u;return u=h?"&"+a.build(e):a.build(e,l),u};
4if(Array.isArray(s)){if(s.length>r.length)re("TSL: The number of provided parameters exceeds the expected number of inputs in 'Fn()'."),s.length=r.length;else if(s.length<r.length)for(re("TSL: The number of provided parameters is less than the expected number of inputs in 'Fn()'.");s.length<r.length;)s.push(C(0));for(let a=0;a<s.length;a++)t.push(n(s[a],r[a]))}else for(let a of r){let o=s[a.name];o===void 0?(re(`TSL: Input '${a.name}' not found in 'Fn()'.`),t.push(n(C(0),a))):t.push(n(o,a))}return`${i.build(e,"property")}( ${t.join(", ")} )`}},AC=(e,...t)=>(t=t.length>1||t[0]&&t[0].isNode===!0?wh(t):uf(t[0]),new T6(xe(e),t));H("call",AC);var w6={"==":"equal","!=":"notEqual","<":"lessThan",">":"greaterThan","<=":"lessThanEqual",">=":"greaterThanEqual","%":"mod"},Ti=class s2 extends ei{static get type(){return"OperatorNode"}constructor(t,i,r,...s){if(super(),s.length>0){let n=new s2(t,i,r);for(let a=0;a<s.length-1;a++)n=new s2(t,n,s[a]);i=n,r=s[s.length-1]}this.op=t,this.aNode=i,this.bNode=r,this.isOperatorNode=!0}getOperatorMethod(t,i){return t.getMethod(w6[this.op],i)}generateNodeType(t,i=null){let r=this.op,s=this.aNode,n=this.bNode,a=s.getNodeType(t),o=n?n.getNodeType(t):null;if(a==="void"||o==="void")return i||"void";if(r==="%")return a;
4if(r==="~"||r==="&"||r==="|"||r==="^"||r===">>"||r==="<<")return t.getIntegerType(a);if(r==="!"||r==="&&"||r==="||"||r==="^^")return"bool";if(r==="=="||r==="!="||r==="<"||r===">"||r==="<="||r===">="){let l=Math.max(t.getTypeLength(a),t.getTypeLength(o));return l>1?`bvec${l}`:"bool"}else{if(t.isMatrix(a)){if(o==="float")return a;if(t.isVector(o))return t.getVectorFromMatrix(a);if(t.isMatrix(o))return a}else if(t.isMatrix(o)){if(a==="float")return o;if(t.isVector(a))return t.getVectorFromMatrix(o)}return t.getTypeLength(o)>t.getTypeLength(a)?o:a}}generate(t,i){let r=this.op,{aNode:s,bNode:n}=this,a=this.getNodeType(t,i),o=null,l=null;a==="void"?o=l=a:(o=s.getNodeType(t),l=n?n.getNodeType(t):null,r==="<"||r===">"||r==="<="||r===">="||r==="=="||r==="!="?t.isVector(o)?l=o:t.isVector(l)?o=l:o!==l&&(o=l="float"):r===">>"||r==="<<"?(o=a,l=t.changeComponentType(l,"uint")):r==="%"?(o=a,l=t.isInteger(o)&&t.isInteger(l)?l:o):t.isMatrix(o)?l==="float"?l="float":t.isVector(l)?l=t.getVectorFromMatrix(o):t.isMatrix(l)||(o=l=a):o=t.isMatrix(l)?o==="float"?"float":t.isVector(o)?t.getVectorFromMatrix(l):l=a:l=a);let h=s.build(t,o),u=n?n.build(t,l):null,d=t.getFunctionOperator(r);if(i!=="void"){let c=t.renderer.coordinateSystem===ch;if(r==="=="||r==="!="||r==="<"||r===">"||r==="<="||r===">=")return c&&t.isVector(o)?t.format(`${this.getOperatorMethod(t,i)}( ${h}, ${u} )`,a,i):t.format(`( ${h} ${r} ${u} )`,a,i);if(r==="%")return t.isInteger(l)?t.format(`( ${h} % ${u} )`,a,i):t.format(`${this.getOperatorMethod(t,a)}( ${h}, ${u} )`,a,i);if(r==="!"||r==="~")return t.format(`(${r}${h})`,o,i);if(d)return t.format(`${d}( ${h}, ${u} )`,a,i);if(t.isMatrix(o)&&l==="float")return t.format(`( ${u} ${r} ${h} )`,a,i);if(o==="float"&&t.isMatrix(l))return t.format(`${h} ${r} ${u}`,a,i);{let p=`( ${h} ${r} ${u} )`;return!c&&a==="bool"&&t.isVector(o)&&t.isVector(l)&&(p=`all${p}`),t.format(p,a,i)}}else if(o!=="void")return d?t.format(`${d}( ${h}, ${u} )`,a,i):t.isMatrix(o)&&l==="float"?t.format(`${u} ${r} ${h}`,a,i):t.format(`${h} ${r} ${u}`,a,i)}serialize(t){super.serialize(t),t.op=this.op}deserialize(t){super.deserialize(t),this.op=t.op}},wi=ne(Ti,"+").setParameterLength(2,1/0).setName("add"),tt=ne(Ti,"-").setParameterLength(2,1/0).setName("sub"),Pe=ne(Ti,"*").setParameterLength(2,1/0).setName("mul"),_s=ne(Ti,"/").setParameterLength(2,1/0).setName("div"),dp=ne(Ti,"%").setParameterLength(2).setName("mod"),NC=ne(Ti,"==").setParameterLength(2).setName("equal"),LC=ne(Ti,"!=").setParameterLength(2).setName("notEqual"),PC=ne(Ti,"<").setParameterLength(2).setName("lessThan"),dv=ne(Ti,">").setParameterLength(2).setName("greaterThan"),kC=ne(Ti,"<=").setParameterLength(2).setName("lessThanEqual"),IC=ne(Ti,">=").setParameterLength(2).setName("greaterThanEqual"),FC=ne(Ti,"&&").setParameterLength(2,1/0).setName("and"),DC=ne(Ti,"||").setParameterLength(2,1/0).setName("or"),OC=ne(Ti,"!").setParameterLength(1).setName("not"),BC=ne(Ti,"^^").setParameterLength(2).setName("xor"),UC=ne(Ti,"&").setParameterLength(2).setName("bitAnd"),VC=ne(Ti,"~").setParameterLength(1).setName("bitNot"),zC=ne(Ti,"|").setParameterLength(2).setName("bitOr"),GC=ne(Ti,"^").setParameterLength(2).setName("bitXor"),jC=ne(Ti,"<<").setParameterLength(2).setName("shiftLeft"),$C=ne(Ti,">>").setParameterLength(2).setName("shiftRight"),WC=k(([e])=>(e.addAssign(1),e)),HC=k(([e])=>(e.subAssign(1),e)),qC=k(([e])=>{let t=A(e).toConst();return e.addAssign(1),t}),XC=k(([e])=>{let t=A(e).toConst();return e.subAssign(1),t});H("add",wi),H("sub",tt),H("mul",Pe),H("div",_s),H("mod",dp),H("equal",NC),H("notEqual",LC),H("lessThan",PC),H("greaterThan",dv),H("lessThanEqual",kC),H("greaterThanEqual",IC),H("and",FC),H("or",DC),H("not",OC),H("xor",BC),H("bitAnd",UC),H("bitNot",VC),H("bitOr",zC),H("bitXor",GC),H("shiftLeft",jC),H("shiftRight",$C),H("incrementBefore",WC),H("decrementBefore",HC),H("increment",qC),H("decrement",XC);var YC=(e,t)=>(de('TSL: "modInt()" is deprecated. Use "mod( int( ... ) )" instead.',new fi),dp(A(e),A(t)));H("modInt",YC);var G=class Yt extends ei{static get type(){return"MathNode"}constructor(t,i,r=null,s=null){if(super(),(t===Yt.MAX||t===Yt.MIN)&&arguments.length>3){let n=new Yt(t,i,r);for(let a=2;a<arguments.length-1;a++)n=new Yt(t,n,arguments[a]);i=n,r=arguments[arguments.length-1],s=null}this.method=t,this.aNode=i,this.bNode=r,this.cNode=s,this.isMathNode=!0}getInputType(t){let i=this.aNode.getNodeType(t),r=this.bNode?this.bNode.getNodeType(t):null,s=this.cNode?this.cNode.getNodeType(t):null,n=t.isMatrix(i)?0:t.getTypeLength(i),a=t.isMatrix(r)?0:t.getTypeLength(r),o=t.isMatrix(s)?0:t.getTypeLength(s);return n>a&&n>o?i:a>
4o?r:o>n?s:i}generateNodeType(t){let i=this.method;return i===Yt.LENGTH||i===Yt.DISTANCE||i===Yt.DOT?"float":i===Yt.CROSS?"vec3":i===Yt.ALL||i===Yt.ANY?"bool":i===Yt.EQUALS?t.changeComponentType(this.aNode.getNodeType(t),"bool"):this.getInputType(t)}setup(t){let{aNode:i,bNode:r,method:s}=this,n=null;if(s===Yt.ONE_MINUS)n=tt(1,i);else if(s===Yt.RECIPROCAL)n=_s(1,i);else if(s===Yt.DIFFERENCE)n=kt(tt(i,r));else if(s===Yt.TRANSFORM_DIRECTION){let a=i,o=r;t.isMatrix(a.getNodeType(t))?o=Te(L(o),0):a=Te(L(a),0);let l=Pe(a,o).xyz;n=ls(l)}return n===null?super.setup(t):n}generate(t,i){if(t.getNodeProperties(this).outputNode)return super.generate(t,i);let r=this.method,s=this.getNodeType(t),n=this.getInputType(t),a=this.aNode,o=this.bNode,l=this.cNode,h=t.renderer.coordinateSystem;if(r===Yt.NEGATE)return t.format("( - "+a.build(t,n)+" )",s,i);{let u=[];return r===Yt.CROSS?u.push(a.build(t,s),o.build(t,s)):h===2e3&&r===Yt.STEP?u.push(a.build(t,t.getTypeLength(a.getNodeType(t))===1?"float":n),o.build(t,n)):h===2e3&&(r===Yt.MIN||r===Yt.MAX)?u.push(a.build(t,n),o.build(t,t.getTypeLength(o.getNodeType(t))===1?"float":n)):r===Yt.REFRACT?u.push(a.build(t,n),o.build(t,n),l.build(t,"float")):r===Yt.MIX?u.push(a.build(t,n),o.build(t,n),l.build(t,t.getTypeLength(l.getNodeType(t))===1?"float":n)):(h===2001&&r===Yt.ATAN&&o!==null&&(r="atan2"),t.shaderStage!=="fragment"&&(r===Yt.DFDX||r===Yt.DFDY)&&(de(`TSL: '${r}' is not supported in the ${t.shaderStage} stage.`,this.stackTrace),r="/*"+r+"*/"),u.push(a.build(t,n)),o!==null&&u.push(o.build(t,n)),l!==null&&u.push(l.build(t,n))),t.format(`${t.getMethod(r,s)}( ${u.join(", ")} )`,s,i)}}serialize(t){super.serialize(t),t.method=this.method}deserialize(t){super.deserialize(t),this.method=t.method}};G.ALL="all",G.ANY="any",G.RADIANS="radians",G.DEGREES="degrees",G.EXP="exp",G.EXP2="exp2",G.LOG="log",G.LOG2="log2",G.SQRT="sqrt",G.INVERSE_SQRT="inversesqrt",G.FLOOR="floor",G.CEIL="ceil",G.NORMALIZE="normalize",G.FRACT="fract",G.SIN="sin",G.COS="cos",G.TAN="tan",G.ASIN="asin",G.ACOS="acos",G.ATAN="atan",G.ABS="abs",G.SIGN="sign",G.LENGTH="length",G.NEGATE="negate",G.ONE_MINUS="oneMinus",G.DFDX="dFdx",G.DFDY="dFdy",G.ROUND="round",G.RECIPROCAL="reciprocal",G.TRUNC="trunc",G.FWIDTH="fwidth",G.TRANSPOSE="transpose",G.DETERMINANT="determinant",G.INVERSE="inverse",G.EQUALS="equals",G.MIN="min",G.MAX="max",G.STEP="step",G.REFLECT="reflect",G.DISTANCE="distance",G.DIFFERENCE="difference",G.DOT="dot",G.CROSS="cross",G.POW="pow",G.TRANSFORM_DIRECTION="transformDirection",G.MIX="mix",G.CLAMP="clamp",G.REFRACT="refract",G.SMOOTHSTEP="smoothstep",G.FACEFORWARD="faceforward";var cv=C(1e-6),S6=C(1e6),Tf=C(Math.PI),M6=C(Math.PI*2),C6=C(Math.PI*2),R6=C(Math.PI*.5),KC=ne(G,G.ALL).setParameterLength(1),ZC=ne(G,G.ANY).setParameterLength(1),JC=ne(G,G.RADIANS).setParameterLength(1),QC=ne(G,G.DEGREES).setParameterLength(1),pv=ne(G,G.EXP).setParameterLength(1),od=ne(G,G.EXP2).setParameterLength(1),wf=ne(G,G.LOG).setParameterLength(1),Hn=ne(G,G.LOG2).setParameterLength(1),Hr=ne(G,G.SQRT).setParameterLength(1),mv=ne(G,G.INVERSE_SQRT).setParameterLength(1),qn=ne(G,G.FLOOR).setParameterLength(1),Sf=ne(G,G.CEIL).setParameterLength(1),ls=ne(G,G.NORMALIZE).setParameterLength(1),un=ne(G,G.FRACT).setParameterLength(1),qr=ne(G,G.SIN).setParameterLength(1),dn=ne(G,G.COS).setParameterLength(1),eR=ne(G,G.TAN).setParameterLength(1),tR=ne(G,G.ASIN).setParameterLength(1),gv=ne(G,G.ACOS).setParameterLength(1),fv=ne(G,G.ATAN).setParameterLength(1,2),kt=ne(G,G.ABS).setParameterLength(1),yv=ne(G,G.SIGN).setParameterLength(1),Xn=ne(G,G.LENGTH).setParameterLength(1),xv=ne(G,G.NEGATE).setParameterLength(1),iR=ne(G,G.ONE_MINUS).setParameterLength(1),vv=ne(G,G.DFDX).setParameterLength(1),bv=ne(G,G.DFDY).setParameterLength(1),rR=ne(G,G.ROUND).setParameterLength(1),sR=ne(G,G.RECIPROCAL).setParameterLength(1),_v=ne(G,G.TRUNC).setParameterLength(1),Tv=ne(G,G.FWIDTH).setParameterLength(1),nR=ne(G,G.TRANSPOSE).setParameterLength(1),aR=ne(G,G.DETERMINANT).setParameterLength(1),oR=ne(G,G.INVERSE).setParameterLength(1),hs=ne(G,G.MIN).setParameterLength(2,1/0),ti=ne(G,G.MAX).setParameterLength(2,1/0),Ah=ne(G,G.STEP).setParameterLength(2),lR=ne(G,G.REFLECT).setParameterLength(2),hR=ne(G,G.DISTANCE).setParameterLength(2),uR=ne(G,G.DIFFERENCE).setParameterLength(2),zs=ne(G,G.DOT).setParameterLength(2),qa=ne(G,G.CROSS).setParameterLength(2),Gs=ne(G,G.POW).setParameterLength(2),wv=e=>Pe(e,e),dR=e=>Pe(e,e,e),Sv=e=>Pe(e,e,e,e),cR=ne(G,G.TRANSFORM_DIRECTION).setParameterLength(2),pR=e=>Pe(yv(e),Gs(kt(e),1/3)),Mv=e=>zs(e,e),Ze=ne(G,G.MIX).setParameterLength(3),cn=(e,t=0,i=1)=>new G(G.CLAMP,xe(e),xe(t),xe(i)),Mf=e=>cn(e),Cv=ne(G,G.REFRACT).setParameterLength(3),pn=ne(G,G.SMOOTHSTEP).setParameterLength(3),Rv=ne(G,G.FACEFORWARD).setParameterLength(3),mR=k(([e])=>un(qr(dp(zs(e.xy,se(12.9898,78.233)),Tf)).mul(43758.5453))),gR=(e,t,i)=>Ze(t,i,e),fR=(e,t,i)=>pn(t,i,e),yR=(e,t)=>Ah(t,e),E6=Rv,A6=mv;H("all",KC),H("any",ZC),H("radians",JC),H("degrees",QC),H("exp",pv),H("exp2",od),H("log",wf),H("log2",Hn),H("sqrt",Hr),H("inverseSqrt",mv),H("floor",qn),H("ceil",Sf),H("normalize",ls),H("fract",un),H("sin",qr),H("cos",dn),H("tan",eR),H("asin",tR),H("acos",gv),H("atan",fv),H("abs",kt),H("sign",yv),H("length",Xn),H("lengthSq",Mv),H("negate",xv),H("oneMinus",iR),H("dFdx",vv),H("dFdy",bv),H("round",rR),H("reciprocal",sR),H("trunc",_v),H("fwidth",Tv),H("min",hs),H("max",ti),H("step",yR),H("reflect",lR),H("distance",hR),H("dot",zs),H("cross",qa),H("pow",Gs),H("pow2",wv),H("pow3",dR),H("pow4",Sv),H("transformDirection",cR),H("mix",gR),H("clamp",cn),H("refract",Cv),H("smoothstep",fR),H("faceForward",Rv),H("difference",uR),H("saturate",Mf),H("cbrt",pR),H("transpose",nR),H("determinant",aR),H("inverse",oR),H("rand",mR);var wr=Fe(class extends ve{static get type(){return"ConditionalNode"}constructor(e,t,i=null){super(),this.condNode=e,this.ifNode=t,this.elseNode=i}
4generateNodeType(e){let{ifNode:t,elseNode:i}=e.getNodeProperties(this);if(t===void 0)return e.flowBuildStage(this,"setup"),this.getNodeType(e);let r=t.getNodeType(e);if(i!==null){let s=i.getNodeType(e);if(e.getTypeLength(s)>e.getTypeLength(r))return s}return r}setup(e){let t=this.condNode,i=this.ifNode.isolate(),r=this.elseNode?this.elseNode.isolate():null,s=e.context.nodeBlock;e.getDataFromNode(i).parentNodeBlock=s,r!==null&&(e.getDataFromNode(r).parentNodeBlock=s);let n=e.context.uniformFlow,a=e.getNodeProperties(this);a.condNode=t,a.ifNode=n?i:i.context({nodeBlock:i}),a.elseNode=r?n?r:r.context({nodeBlock:r}):null}generate(e,t){let i=this.getNodeType(e),r=e.getDataFromNode(this);if(r.nodeProperty!==void 0)return r.nodeProperty;let{condNode:s,ifNode:n,elseNode:a}=e.getNodeProperties(this),o=e.currentFunctionNode,l=t!=="void",h=l?Wa(i).build(e):"";r.nodeProperty=h;let u=s.build(e,"bool");if(e.context.uniformFlow&&a!==null){let c=n.build(e,i),p=a.build(e,i),m=e.getTernary(u,c,p);return e.format(m,i,t)}e.addFlowCode(`
5${e.tab}if ( ${u} ) {
6
7`).addFlowTab();let d=n.build(e,i);if(d&&(l?d=h+" = "+d+";":(d="return "+d+";",o===null&&(de("TSL: Return statement used in an inline 'Fn()'. Define a layout struct to allow return values.",this.stackTrace),d="// "+d))),e.removeFlowTab().addFlowCode(e.tab+"	"+d+`
8
9`+e.tab+"}"),a!==null){e.addFlowCode(` else {
10
11`).addFlowTab();let c=a.build(e,i);c&&(l?c=h+" = "+c+";":(c="return "+c+";",o===null&&(de("TSL: Return statement used in an inline 'Fn()'. Define a layout struct to allow return values.",this.stackTrace),c="// "+c))),e.removeFlowTab().addFlowCode(e.tab+"	"+c+`
12
13`+e.tab+`}
14
15`)}else e.addFlowCode(`
16
17`);return e.format(h,i,t)}}).setParameterLength(2,3);H("select",wr);var xR=class extends ve{static get type(){return"ContextNode"}constructor(e=null,t={}){super(),this.isContextNode=!0,this.node=e,this.value=t}getScope(){return this.node.getScope()}generateNodeType(e){return this.node.getNodeType(e)}getFlowContextData(){let e=[];return this.traverse(t=>{t.isContextNode===!0&&e.push(t.value)}),Object.assign({},...e)}getMemberType(e,t){return this.node.getMemberType(e,t)}analyze(e){let t=e.addContext(this.value);this.node.build(e),e.setContext(t)}setup(e){let t=e.addContext(this.value);this.node.build(e),e.setContext(t)}generate(e,t){let i=e.addContext(this.value),r=this.node.build(e,t);return e.setContext(i),r}},Xa=(e=null,t={})=>{let i=e;return(i===null||i.isNode!==!0)&&(t=i||t,i=null),new xR(i,t)},vR=e=>Xa(e,{uniformFlow:!0}),Ev=(e,t)=>Xa(e,{nodeName:t});function bR(e,t,i=null){return Xa(i,{getShadow:({light:r,shadowColorNode:s})=>t===r?s.mul(e):s})}function _R(e,t=null){return Xa(t,{getAO:(i,{material:r})=>r.transparent===!0?i:i===null?e:i.mul(e)})}function TR(e,t){return de('TSL: "label()" has been deprecated. Use "setName()" instead.'),Ev(e,t)}H("context",Xa),H("label",TR),H("uniformFlow",vR),H("setName",Ev),H("builtinShadowContext",(e,t,i)=>bR(t,i,e)),H("builtinAOContext",(e,t)=>_R(t,e));var Cf=class extends ve{static get type(){return"VarNode"}constructor(e,t=null,i=!1){super(),this.node=e,this.name=t,this.global=!0,this.isVarNode=!0,this.readOnly=i,this.parents=!0,this.intent=!1}setIntent(e){return this.intent=e,this}isIntent(e){return e.getDataFromNode(this).forceDeclaration===!0?!1:this.intent}getIntent(){return this.intent}getMemberType(e,t){return this.node.getMemberType(e,t)}getElementType(e){return this.node.getElementType(e)}generateNodeType(e){return this.node.getNodeType(e)}getArrayCount(e){return this.node.getArrayCount(e)}isAssign(e){return e.getDataFromNode(this).assign}build(...e){let t=e[0];if(this._hasStack(t)===!1&&t.buildStage==="setup"&&(t.context.nodeLoop||t.context.nodeBlock)){let i=!1;if(this.node.isShaderCallNodeInternal&&this.node.shaderNode.getLayout()===null&&t.fnCall&&t.fnCall.shaderNode&&t.getDataFromNode(this.node.shaderNode).hasLoop){let s=t.getDataFromNode(this);s.forceDeclaration=!0,i=!0}let r=t.getBaseStack();i?r.addToStackBefore(this):r.addToStack(this)}return this.isIntent(t)&&this.isAssign(t)!==!0?this.node.build(...e):super.build(...e)}generate(e){let{node:t,name:i,readOnly:r}=this,{renderer:s}=e,n=s.backend.isWebGPUBackend===!0,a=!1,o=!1;r&&(a=e.isDeterministic(t),o=n?r:a);let l=this.getNodeType(e);if(l=="void")return this.isIntent(e)!==!0&&re('TSL: ".toVar()" can not be used with void type.',this.stackTrace),t.build(e);let h=e.getVectorType(l),u=t.build(e,h),d=e.getVarFromNode(this,i,h,void 0,o),c=e.getPropertyName(d),p=c;if(o)if(n)p=a?`const ${c}`:`let ${c}`;else{let m=t.getArrayCount(e);p=`const ${e.getVar(d.type,c,m)}`}return e.addLineFlowCode(`${p} = ${u}`,this),c}_hasStack(e){return e.getDataFromNode(this).stack!==void 0}},Av=Fe(Cf),wR=(e,t=null)=>Av(e,t).toStack(),SR=(e,t=null)=>Av(e,t,!0).toStack(),MR=e=>Av(e).setIntent(!0).toStack();H("toVar",wR),H("toConst",SR),H("toVarIntent",MR);var N6=class extends ve{static get type(){return"SubBuild"}constructor(e,t,i=null){super(i),this.node=e,this.name=t,this.isSubBuildNode=!0}generateNodeType(e){if(this.nodeType!==null)return this.nodeType;e.addSubBuild(this.name);let t=this.node.getNodeType(e);return e.removeSubBuild(),t}build(e,...t){e.addSubBuild(this.name);let i=this.node.build(e,...t);return e.removeSubBuild(),i}},Nh=(e,t,i=null)=>new N6(xe(e),t,i),Qo=Fe(class extends ve{static get type(){return"VaryingNode"}constructor(e,t=null){super(),this.node=Nh(e,"VERTEX"),this.name=t,this.isVaryingNode=!0,this.interpolationType=null,this.interpolationSampling=null,this.global=!0}setInterpolation(e,t=null){return this.interpolationType=e,this.interpolationSampling=t,this}getHash(e){return this.name||super.getHash(e)}generateNodeType(e){return this.node.getNodeType(e)}setupVarying(e){let t=e.getNodeProperties(this),i=t.varying;if(i===void 0){let r=this.name,s=this.getNodeType(e),n=this.interpolationType,a=this.interpolationSampling;t.varying=i=e.getVaryingFromNode(this,r,s,n,a),t.node=Nh(this.node,"VERTEX")}return i.needsInterpolation||=e.shaderStage==="fragment",i}setup(e){this.setupVarying(e),e.flowNodeFromShaderStage(rp.VERTEX,this.node)}analyze(e){this.setupVarying(e),e.flowNodeFromShaderStage(rp.VERTEX,this.node)}generate(e){let t=e.getSubBuildProperty("property",e.currentStack),i=e.getNodeProperties(this),r=this.setupVarying(e);if(i[t]===void 0){let s=this.getNodeType(e),n=e.getPropertyName(r,rp.VERTEX);e.flowNodeFromShaderStage(rp.VERTEX,i.node,s,n),i[t]=n}return e.getPropertyName(r)}}).setParameterLength(1,2),CR=e=>Qo(e);H("toVarying",Qo),H("toVertexStage",CR);var RR=k(([e])=>Ze(e.mul(.9478672986).add(.0521327014).pow(2.4),e.mul(.0773993808),e.lessThanEqual(.04045))).setLayout({name:"sRGBTransferEOTF",type:"vec3",input
17s:[{name:"color",type:"vec3"}]}),ER=k(([e])=>Ze(e.pow(.41666).mul(1.055).sub(.055),e.mul(12.92),e.lessThanEqual(.0031308))).setLayout({name:"sRGBTransferOETF",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),Nv="WorkingColorSpace",L6="OutputColorSpace",Lv=class extends ei{static get type(){return"ColorSpaceNode"}constructor(e,t,i){super("vec4"),this.colorNode=e,this.source=t,this.target=i}resolveColorSpace(e,t){return t===Nv?lt.workingColorSpace:t===L6?e.context.outputColorSpace||e.renderer.outputColorSpace:t}setup(e){let{colorNode:t}=this,i=this.resolveColorSpace(e,this.source),r=this.resolveColorSpace(e,this.target),s=t;return lt.enabled===!1||i===r||!i||!r||(lt.getTransfer(i)==="srgb"&&(s=Te(RR(s.rgb),s.a)),lt.getPrimaries(i)!==lt.getPrimaries(r)&&(s=Te(tr(lt._getMatrix(new Os,i,r)).mul(s.rgb),s.a)),lt.getTransfer(r)==="srgb"&&(s=Te(ER(s.rgb),s.a))),s}},AR=(e,t)=>new Lv(xe(e),Nv,t),Rf=(e,t)=>new Lv(xe(e),t,Nv),P6=(e,t,i)=>new Lv(xe(e),t,i);H("workingToColorSpace",AR),H("colorSpaceToWorking",Rf);var k6=class extends Th{static get type(){return"ReferenceElementNode"}constructor(e,t){super(e,t),this.referenceNode=e,this.isReferenceElementNode=!0}generateNodeType(){return this.referenceNode.uniformType}generate(e){let t=super.generate(e),i=this.referenceNode.getNodeType(),r=this.getNodeType();return e.format(t,i,r)}},NR=class extends ve{static get type(){return"ReferenceBaseNode"}constructor(e,t,i=null,r=null){super(),this.property=e,this.uniformType=t,this.object=i,this.count=r,this.properties=e.split("."),this.reference=i,this.node=null,this.group=null,this.updateType=Re.OBJECT}setGroup(e){return this.group=e,this}element(e){return new k6(this,xe(e))}setNodeType(e){let t=be(null,e);this.group!==null&&t.setGroup(this.group),this.node=t}generateNodeType(e){return this.node===null&&(this.updateReference(e),this.updateValue()),this.node.getNodeType(e)}getValueFromReference(e=this.reference){let{properties:t}=this,i=e[t[0]];for(let r=1;r<t.length;r++)i=i[t[r]];return i}updateReference(e){return this.reference=this.object===null?e.object:this.object,this.reference}setup(){return this.updateValue(),this.node}update(){this.updateValue()}updateValue(){this.node===null&&this.setNodeType(this.uniformType);let e=this.getValueFromReference();Array.isArray(e)?this.node.array=e:this.node.value=e}},I6=(e,t,i)=>new NR(e,t,i),F6=class extends NR{static get type(){return"RendererReferenceNode"}constructor(e,t,i=null){super(e,t,i),this.renderer=i,this.setGroup(we)}updateReference(e){return this.reference=this.renderer===null?e.renderer:this.renderer,this.reference}},LR=(e,t,i=null)=>new F6(e,t,i),D6=class extends ei{static get type(){return"ToneMappingNode"}constructor(e,t=kR,i=null){super("vec3"),this._toneMapping=e,this.exposureNode=t,this.colorNode=i}customCacheKey(){return ip(this._toneMapping)}setToneMapping(e){return this._toneMapping=e,this}getToneMapping(){return this._toneMapping}setup(e){let t=this.colorNode||e.context.color,i=this._toneMapping;if(i===0)return t;let r=null,s=e.renderer.library.getToneMappingFunction(i);return s===null?(re("ToneMappingNode: Unsupported Tone Mapping configuration.",i),r=t):r=Te(s(t.rgb,this.exposureNode),t.a),r}},PR=(e,t,i)=>new D6(e,xe(t),xe(i)),kR=LR("toneMappingExposure","float");H("toneMapping",(e,t,i)=>PR(t,i,e));var IR=new WeakMap;function FR(e,t){let i=IR.get(e);return i===void 0&&(i=new mx(e,t),IR.set(e,i)),i}var el=class extends qx{static get type(){return"BufferAttributeNode"}constructor(e,t=null,i=0,r=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferStride=i,this.bufferOffset=r,this.usage=dh,this.instanced=!1,this.attribute=null,this.global=!0,e&&e.isBufferAttribute===!0&&e.itemSize<=4&&(this.attribute=e,this.usage=e.usage,this.instanced=e.isInstancedBufferAttribute)}getHash(e){let t;if(this.bufferStride===0&&this.bufferOffset===0){let i=e.globalCache.getData(this.value);i===void 0&&(i={node:this},e.globalCache.setData(this.value,i)),t=i.node.id}else t=this.id;return String(t)}generateNodeType(e){return this.bufferType===null&&(this.bufferType=e.getTypeFromAttribute(this.attribute)),this.bufferType}setup(e){if(this.attribute!==null)return;let t=this.getNodeType(e),i=e.getTypeLength(t),r=this.value,s=this.bufferStride||i,n=this.bufferOffset,a;a=r.isInterleavedBuffer===!0?r:r.isBufferAttribute===!0?FR(r.array,s):FR(r,s);let o=new gx(a,i,n);a.setUsage(this.usage),this.attribute=o,this.attribute.isInstancedBufferAttribute=this.instanced}generate(e){let t=this.getNodeType(e),i=e.getBufferAttributeFromNode(this,t),r=e.getPropertyName(i),s=null;return e.shaderStage==="vertex"||e.shaderStage==="compute"?(this.name=r,s=r):s=Qo(this).build(e,t),s}getInputType(){return"bufferAttribute"}setUsage(e){return this.usage=e,this.attribute&&this.attribute.isBufferAttribute===!0&&(this.attribute.usage=e),this}setInstanced(e){return this.instanced=e,this}};
17function Ef(e,t=null,i=0,r=0,s=dh,n=!1){return t==="mat3"||t===null&&e.itemSize===9?tr(new el(e,"vec3",9,0).setUsage(s).setInstanced(n),new el(e,"vec3",9,3).setUsage(s).setInstanced(n),new el(e,"vec3",9,6).setUsage(s).setInstanced(n)):t==="mat4"||t===null&&e.itemSize===16?Yo(new el(e,"vec4",16,0).setUsage(s).setInstanced(n),new el(e,"vec4",16,4).setUsage(s).setInstanced(n),new el(e,"vec4",16,8).setUsage(s).setInstanced(n),new el(e,"vec4",16,12).setUsage(s).setInstanced(n)):new el(e,t,i,r).setUsage(s)}var Pv=(e,t=null,i=0,r=0)=>Ef(e,t,i,r),O6=(e,t=null,i=0,r=0)=>Ef(e,t,i,r,an),Af=(e,t=null,i=0,r=0)=>Ef(e,t,i,r,dh,!0),kv=(e,t=null,i=0,r=0)=>Ef(e,t,i,r,an,!0);H("toAttribute",e=>Pv(e.value));var B6=class extends ve{static get type(){return"ComputeNode"}constructor(e,t){super("void"),this.isComputeNode=!0,this.computeNode=e,this.workgroupSize=t,this.count=null,this.version=1,this.name="",this.updateBeforeType=Re.OBJECT,this.onInitFunction=null}setCount(e){return this.count=e,this}getCount(){return this.count}dispose(){this.dispatchEvent({type:"dispose"})}setName(e){return this.name=e,this}label(e){return de('TSL: "label()" has been deprecated. Use "setName()" instead.',new fi),this.setName(e)}onInit(e){return this.onInitFunction=e,this}updateBefore({renderer:e}){e.compute(this)}setup(e){let t=this.computeNode.build(e);if(t){let i=e.getNodeProperties(this);i.outputComputeNode=t.outputNode,t.outputNode=null}return t}generate(e,t){let{shaderStage:i}=e;if(i==="compute"){let r=this.computeNode.build(e,"void");r!==""&&e.addLineFlowCode(r,this)}else{let r=e.getNodeProperties(this).outputComputeNode;if(r)return r.build(e,t)}}},Iv=(e,t=[64])=>{(t.length===0||t.length>3)&&re("TSL: compute() workgroupSize must have 1, 2, or 3 elements",new fi);for(let i=0;i<t.length;i++){let r=t[i];(typeof r!="number"||r<=0||!Number.isInteger(r))&&re(`TSL: compute() workgroupSize element at index [ ${i} ] must be a positive integer`,new fi)}for(;t.length<3;)t.push(1);return new B6(xe(e),t)},DR=(e,t,i)=>Iv(e,i).setCount(t);H("compute",DR),H("computeKernel",Iv);var U6=class extends ve{static get type(){return"IsolateNode"}constructor(e,t=!0){super(),this.node=e,this.parent=t,this.isIsolateNode=!0}generateNodeType(e){let t=e.getCache(),i=e.getCacheFromNode(this,this.parent);e.setCache(i);let r=this.node.getNodeType(e);return e.setCache(t),r}build(e,...t){let i=e.getCache(),r=e.getCacheFromNode(this,this.parent);e.setCache(r);let s=this.node.build(e,...t);return e.setCache(i),s}setParent(e){return this.parent=e,this}getParent(){return this.parent}},ld=e=>new U6(xe(e));function OR(e,t=!0){return de('TSL: "cache()" has been deprecated. Use "isolate()" instead.'),ld(e).setParent(t)}H("cache",OR),H("isolate",ld);var BR=Fe(class extends ve{static get type(){return"BypassNode"}constructor(e,t){super(),this.isBypassNode=!0,this.outputNode=e,this.callNode=t}generateNodeType(e){return this.outputNode.getNodeType(e)}generate(e){let t=this.callNode.build(e,"void");return t!==""&&e.addLineFlowCode(t,this),this.outputNode.build(e)}}).setParameterLength(2);H("bypass",BR);var Fv=k(([e,t,i,r=C(0),s=C(1),n=vs(!1)])=>{let a=e.sub(t).div(i.sub(t));return rd(n)&&(a=a.clamp()),a.mul(s.sub(r)).add(r)});function UR(e,t,i,r=C(0),s=C(1)){return Fv(e,t,i,r,s,!0)}H("remap",Fv),H("remapClamp",UR);var Nf=class extends ve{static get type(){return"ExpressionNode"}constructor(e="",t="void"){super(t),this.snippet=e}generate(e,t){let i=this.getNodeType(e),r=this.snippet;if(i==="void")e.addLineFlowCode(r,this);else return e.format(r,i,t)}},Ts=Fe(Nf).setParameterLength(1,2),VR=e=>(e?wr(e,Ts("discard")):Ts("discard")).toStack(),V6=()=>Ts("return").toStack();H("discard",VR);var z6=class extends ei{static get type(){return"RenderOutputNode"}constructor(e,t,i){super("vec4"),this.colorNode=e,this._toneMapping=t,this.outputColorSpace=i,this.isRenderOutputNode=!0}setToneMapping(e){return this._toneMapping=e,this}getToneMapping(){return this._toneMapping}setup({context:e}){let t=this.colorNode||e.color,i=(this._toneMapping===null?e.toneMapping:this._toneMapping)||0,r=(this.outputColorSpace===null?e.outputColorSpace:this.outputColorSpace)||"";return i!==0&&(t=t.toneMapping(i)),r!==""&&r!==lt.workingColorSpace&&(t=t.workingToColorSpace(r)),t}},Lf=(e,t=null,i=null)=>new z6(xe(e),t,i);H("renderOutput",Lf);var G6=class extends ei{static get type(){return"DebugNode"}constructor(e,t=null){super(),this.node=e,this.callback=t}generateNodeType(e){return this.node.getNodeType(e)}setup(e){return this.node.build(e)}analyze(e){return this.node.build(e)}generate(e){let t=this.callback,i=this.node.build(e);if(t!==null)t(e,i);else{let r="--- TSL debug - "+e.shaderStage+" shader ---",s="-".repeat(r.length),n="";n+="// #"+r+`#
18`,n+=e.flow.code.replace(/^\t/gm,"")+`
19`,n+="/* ... */ "+i+` /* ... */
20`,n+="// #"+s+`#
21`,Y1(n)}return i}},zR=(e,t=null)=>new G6(xe(e),t).toStack();H("debug",zR);var Dv=class extends Ds{constructor(){super(),this._renderer=null,this.currentFrame=null}get nodeFrame(){return this._renderer._nodes.nodeFrame}setRenderer(e){return this._renderer=e,this}getRenderer(){return this._renderer}init(){}begin(){}finish(){}inspect(){}computeAsync(){}beginCompute(){}finishCompute(){}beginRender(){}finishRender(){}copyTextureToTexture(){}copyFramebufferToTexture(){}},j6=class extends ve{static get type(){return"InspectorNode"}constructor(e,t="",i=null){super(),this.node=e,this.name=t,this.callback=i,this.updateType=Re.FRAME,this.isInspectorNode=!0}getName(){return this.name||this.node.name}update(e){e.renderer.inspector.inspect(this)}generateNodeType(e){return this.node.getNodeType(e)}setup(e){let t=this.node;
21return e.context.inspector===!0&&this.callback!==null&&(t=this.callback(t)),e.renderer.backend.isWebGPUBackend!==!0&&e.renderer.inspector.constructor!==Dv&&ut('TSL: ".toInspector()" is only available with WebGPU.'),t}};function GR(e,t="",i=null){return e=xe(e),e.before(new j6(e,t,i))}H("toInspector",GR);function $6(e){de("TSL: AddNodeElement has been removed in favor of tree-shaking. Trying add",e)}var jR=class extends ve{static get type(){return"AttributeNode"}constructor(e,t=null){super(t),this.global=!0,this._attributeName=e}getHash(e){return this.getAttributeName(e)}generateNodeType(e){let t=this.nodeType;if(t===null){let i=this.getAttributeName(e);if(e.hasGeometryAttribute(i)){let r=e.geometry.getAttribute(i);t=e.getTypeFromAttribute(r)}else t="float"}return t}setAttributeName(e){return this._attributeName=e,this}getAttributeName(){return this._attributeName}generate(e){let t=this.getAttributeName(e),i=this.getNodeType(e);if(e.hasGeometryAttribute(t)===!0){let r=e.geometry.getAttribute(t),s=e.getTypeFromAttribute(r),n=e.getAttribute(t,s);return e.shaderStage==="vertex"?e.format(n.name,s,i):Qo(this).build(e,i)}else return de(`AttributeNode: Vertex attribute "${t}" not found on geometry.`),e.generateConst(i)}serialize(e){super.serialize(e),e.global=this.global,e._attributeName=this._attributeName}deserialize(e){super.deserialize(e),this.global=e.global,this._attributeName=e._attributeName}},Ya=(e,t=null)=>new jR(e,t),Mt=(e=0)=>Ya("uv"+(e>0?e:""),"vec2"),tl=Fe(class extends ve{static get type(){return"TextureSizeNode"}constructor(e,t=null){super("uvec2"),this.isTextureSizeNode=!0,this.textureNode=e,this.levelNode=t}generate(e,t){let i=this.textureNode.build(e,"property"),r=this.levelNode===null?"0":this.levelNode.build(e,"int");return e.format(`${e.getMethod("textureDimensions")}( ${i}, ${r} )`,this.getNodeType(e),t)}}).setParameterLength(1,2),Ov=Fe(class extends up{static get type(){return"MaxMipLevelNode"}constructor(e){super(0),this._textureNode=e,this.updateType=Re.FRAME}get textureNode(){return this._textureNode}get texture(){return this._textureNode.value}update(){let e=this.texture,t=e.images,i=t&&t.length>0?t[0]&&t[0].image||t[0]:e.image;if(i&&i.width!==void 0){let{width:r,height:s}=i;this.value=Math.log2(Math.max(r,s))}}}).setParameterLength(1),$R=class extends Error{constructor(e,t=null){super(e),this.name="NodeError",this.stackTrace=t}},Bv=new Li,Yn=class extends up{static get type(){return"TextureNode"}constructor(e=Bv,t=null,i=null,r=null){super(e),this.isTextureNode=!0,this.uvNode=t,this.levelNode=i,this.biasNode=r,this.compareNode=null,this.depthNode=null,this.gradNode=null,this.offsetNode=null,this.sampler=!0,this.updateMatrix=!1,this.updateType=Re.NONE,this.referenceNode=null,this._value=e,this._matrixUniform=null,this._flipYUniform=null,this.setUpdateMatrix(t===null)}set value(e){this.referenceNode?this.referenceNode.value=e:this._value=e}get value(){return this.referenceNode?this.referenceNode.value:this._value}getUniformHash(){return this.value.uuid}generateNodeType(){return this.value.isDepthTexture===!0?"float":this.value.type===1014?"uvec4":this.value.type===1013?"ivec4":"vec4"}getInputType(){return"texture"}getDefaultUV(){return Mt(this.value.channel)}updateReference(){return this.value}getTransformedUV(e){return this._matrixUniform===null&&(this._matrixUniform=be(this.value.matrix)),this._matrixUniform.mul(L(e,1)).xy}setUpdateMatrix(e){return this.updateMatrix=e,this}setupUV(e,t){return e.isFlipY()&&(this._flipYUniform===null&&(this._flipYUniform=be(!1)),t=t.toVar(),t=this.sampler?this._flipYUniform.select(t.flipY(),t):this._flipYUniform.select(t.setY(A(tl(this,this.levelNode).y).sub(t.y).sub(1)),t)),t}setup(e){let t=e.getNodeProperties(this);t.referenceNode=this.referenceNode;let i=this.value;if(!i||i.isTexture!==!0)throw new $R("THREE.TSL: `texture( value )` function expects a valid instance of THREE.Texture().",this.stackTrace);let r=k(()=>{let o=this.uvNode;return(o===null||e.context.forceUVContext===!0)&&e.context.getUV&&(o=e.context.getUV(this,e)),o||=this.getDefaultUV(),this.updateMatrix===!0&&(o=this.getTransformedUV(o)),o=this.setupUV(e,o),this.updateType=this._matrixUniform!==null||this._flipYUniform!==null?Re.OBJECT:Re.NONE,o})(),s=this.levelNode;s===null&&e.context.getTextureLevel&&(s=e.context.getTextureLevel(this));let n=null,a=null;if(this.compareNode!==null)if(e.renderer.hasCompatibility(ph.TEXTURE_COMPARE))n=this.compareNode;else{let o=i.compareFunction;o===null||o===513||o===515||o===516||o===518?a=this.compareNode:(n=this.compareNode,ut('TSL: Only "LessCompare", "LessEqualCompare", "GreaterCompare" and "GreaterEqualCompare" are supported for depth texture comparison fallback.'))}t.uvNode=r,t.levelNode=s,t.biasNode=this.biasNode,t.compareNode=n,t.compareStepNode=a,t.gradNode=this.gradNode,t.depthNode=this.depthNode,t.offsetNode=this.offsetNode}generateUV(e,t){return t.build(e,this.sampler===!0?"vec2":"ivec2")}generateOffset(e,t){return t.build(e,"ivec2")}generateSnippet(e,t,i,r,s,n,a,o,l){let h=this.value,u;return u=s?e.generateTextureBias(h,t,i,s,n,l):o?e.generateTextureGrad(h,t,i,o,n,l):a?e.generateTextureCompare(h,t,i,a,n,l):this.sampler===!1?e.generateTextureLoad(h,t,i,r,n,l):r?e.generateTextureLevel(h,t,i,r,n,l):e.generateTexture(h,t,i,n,l),u}generate(e,t){let i=this.value,r=e.getNodeProperties(this),s=super.generate(e,"property");if(/^sampler/.test(t))return s+"_sampler";if(e.isReference(t))return s;{let n=e.getDataFromNode(this),a=this.getNodeType(e),o=n.propertyName;if(o===void 0){let{uvNode:h,levelNode:u,biasNode:d,compareNode:c,compareStepNode:p,depthNode:m,gradNode:g,offsetNode:f}=r,y=this.generateUV(e,h),x=u?u.build(e,"float"):null,b=d?d.build(e,"float"):null,_=m?m.build(e,"int"):null,T=c?c.build(e,"float"):null,w=p?p.build(e,"float"):null,M=g?[g[0].build(e,"vec2"),g[1].build(e,"vec2")]:null,S=f?this.generateOffset(e,f):null,R=_;R===null&&i.isArrayTexture&&this.isTexture3DNode!==!0&&(R="0");let I=e.getVarFromNode(this);o=e.getPropertyName(I);let B=this.generateSnippet(e,s,y,x,b,R,T,M,S);if(w!==null){let O=i.compareFunction;B=O===516||O===518?Ah(Ts(B,a),Ts(w,"float")).build(e,a):Ah(Ts(w,"float"),Ts(B,a)).build(e,a)}e.addLineFlowCode(`${o} = ${B}`,this),n.snippet=B,n.propertyName=o}let l=o;return e.needsToWorkingColorSpace(i)&&(l=Rf(Ts(l,a),i.colorSpace).setup(e).build(e,a)),e.format(l,a,t)}}setSampler(e){return this.sampler=e,this}getSampler(){return this.sampler}sample(e){let t=this.clone();return t.uvNode=xe(e),t.referenceNode=this.getBase(),xe(t)}load(e){return this.sample(e).setSampler(!1)}blur(e){let t=this.clone();t.biasNode=xe(e).mul(Ov(t)),t.referenceNode=this.getBase();let i=t.value;return t.generateMipmaps===!1&&(i&&i.generateMipmaps===!1||i.minFilter===1003||i.magFilter===1003)&&(de("TSL: texture().blur() requires mipmaps and sampling. Use .generateMipmaps=true and .minFilter/.magFilter=THREE.LinearFilter in the Texture."),t.biasNode=null),xe(t)}level(e){let t=this.clone();return t.levelNode=xe(e),t.referenceNode=this.getBase(),xe(t)}size(e){return tl(this,e)}bias(e){let t=this.clone();return t.biasNode=xe(e),t.referenceNode=this.getBase(),xe(t)}getBase(){return this.referenceNode?this.referenceNode.getBase():this}compare(e){let t=this.clone();return t.compareNode=xe(e),t.referenceNode=this.getBase(),xe(t)}grad(e,t){let i=this.clone();return i.gradNode=[xe(e),xe(t)],i.referenceNode=this.getBase(),xe(i)}depth(e){let t=this.clone();return t.depthNode=xe(e),t.referenceNode=this.getBase(),xe(t)}offset(e){let t=this.clone();return t.offsetNode=xe(e),t.referenceNode=this.getBase(),xe(t)}serialize(e){super.serialize(e),e.value=this.value.toJSON(e.meta).uuid,e.sampler=this.sampler,e.updateMatrix=this.updateMatrix,e.updateType=this.updateType}deserialize(e){super.deserialize(e),this.value=e.meta.textures[e.value],this.sampler=e.sampler,this.updateMatrix=e.updateMatrix,this.updateType=e.updateType}update(){let e=this.value,t=this._matrixUniform;t!==null&&(t.value=e.matrix),e.matrixAutoUpdate===!0&&e.updateMatrix();let i=this._flipYUniform;i!==null&&(i.value=e.image instanceof ImageBitmap&&e.flipY===!0||e.isRenderTargetTexture===!0||e.isFramebufferTexture===!0||e.isDepthTexture===!0)}clone(){let e=new this.constructor(this.value,this.uvNode,this.levelNode,this.biasNode);return e.sampler=this.sampler,e.depthNode=this.depthNode,e.compareNode=this.compareNode,e.gradNode=this.gradNode,e.offsetNode=this.offsetNode,e}},W6=Fe(Yn).setParameterLength(1,4).setName("texture"),st=(e=Bv,t=null,i=null,r=null)=>{let s;return e&&e.isTextureNode===!0?(s=xe(e.clone()),s.referenceNode=e.getBase(),t!==null&&(s.uvNode=xe(t)),i!==null&&(s.levelNode=xe(i)),r!==null&&(s.biasNode=xe(r))):s=W6(e,t,i,r),s},H6=(e=Bv)=>st(e),ni=(...e)=>st(...e).setSampler(!1),q6=(e,t,i)=>st(e,t).level(i),X6=e=>(e.isNode===!0?e:st(e)).convert("sampler"),Y6=e=>(e.isNode===!0?e:st(e)).convert("samplerComparison"),Uv=class extends up{static get type(){return"BufferNode"}constructor(e,t,i=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferCount=i,this.updateRanges=[]}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}getElementType(e){return this.getNodeType(e)}getInputType(){return"buffer"}},cp=(e,t,i)=>new Uv(e,t,i),K6=class extends Th{static get type(){return"UniformArrayElementNode"}constructor(e,t){super(e,t),this.isArrayBufferElementNode=!0}generate(e){let t=super.generate(e),i=this.getNodeType(e),r=this.node.getPaddedType();return e.format(t,r,i)}},Z6=class extends Uv{static get type(){return"UniformArrayNode"}constructor(e,t=null){super(null),this.array=e,this.elementType=t===null?qo(e[0]):t,this.paddedType=this.getPaddedType(),this.updateType=Re.RENDER,this.isArrayBufferNode=!0}generateNodeType(){return this.paddedType}getElementType(){return this.elementType}getPaddedType(){let e=this.elementType,t="vec4";return e==="mat2"?t="mat2":/mat/.test(e)===!0?t="mat4":e.charAt(0)==="i"?t="ivec4":e.charAt(0)==="u"&&(t="uvec4"),t}update(){let{array:e,value:t}=this,i=this.elementType;if(i==="float"||i==="int"||i==="uint")for(let r=0;r<e.length;r++){let s=r*4;t[s]=e[r]}else if(i==="color")for(let r=0;r<e.length;r++){let s=r*4,n=e[r];t[s]=n.r,t[s+1]=n.g,t[s+2]=n.b||0}else if(i==="mat2")for(let r=0;r<e.length;r++){let s=r*4,n=e[r];t[s]=n.elements[0],t[s+1]=n.elements[1],t[s+2]=n.elements[2],t[s+3]=n.elements[3]}else if(i==="mat3")for(let r=0;r<e.length;r++){let s=r*16,n=e[r];t[s]=n.elements[0],t[s+1]=n.elements[1],t[s+2]=n.elements[2],t[s+4]=n.elements[3],t[s+5]=n.elements[4],t[s+6]=n.elements[5],t[s+8]=n.elements[6],t[s+9]=n.elements[7],t[s+10]=n.elements[8],t[s+1
215]=1}else if(i==="mat4")for(let r=0;r<e.length;r++){let s=r*16,n=e[r];for(let a=0;a<n.elements.length;a++)t[s+a]=n.elements[a]}else for(let r=0;r<e.length;r++){let s=r*4,n=e[r];t[s]=n.x,t[s+1]=n.y,t[s+2]=n.z||0,t[s+3]=n.w||0}}setup(e){let t=this.array.length,i=this.elementType,r=Float32Array,s=this.paddedType,n=e.getTypeLength(s);return i.charAt(0)==="i"&&(r=Int32Array),i.charAt(0)==="u"&&(r=Uint32Array),this.value=new r(t*n),this.bufferCount=t,this.bufferType=s,this.update(),super.setup(e)}element(e){return new K6(this,xe(e))}},Sr=(e,t)=>new Z6(e,t),Ka=Fe(class extends ve{constructor(e){super("float"),this.name=e,this.isBuiltinNode=!0}generate(){return this.name}}).setParameterLength(1),Pf,kf,Xr=class nn extends ve{static get type(){return"ScreenNode"}constructor(t){super(),this.scope=t,this._output=null,this.isViewportNode=!0}generateNodeType(){return this.scope===nn.DPR?"float":this.scope===nn.VIEWPORT?"vec4":"vec2"}getUpdateType(){let t=Re.NONE;return(this.scope===nn.SIZE||this.scope===nn.VIEWPORT||this.scope===nn.DPR)&&(t=Re.RENDER),this.updateType=t,t}update({renderer:t}){let i=t.getRenderTarget();this.scope===nn.VIEWPORT?i===null?(t.getViewport(kf),kf.multiplyScalar(t.getPixelRatio())):kf.copy(i.viewport):this.scope===nn.DPR?this._output.value=t.getPixelRatio():i===null?t.getDrawingBufferSize(Pf):(Pf.width=i.width,Pf.height=i.height)}setup(){let t=this.scope,i=null;return i=t===nn.SIZE?be(Pf||=new ge):t===nn.VIEWPORT?be(kf||=new yt):t===nn.DPR?be(1):se(Ph.div(Lh)),this._output=i,i}generate(t){if(this.scope===nn.COORDINATE){let i=t.getFragCoord();if(t.isFlipY()){let r=t.getNodeProperties(Lh).outputNode.build(t);i=`${t.getType("vec2")}( ${i}.x, ${r}.y - ${i}.y )`}return i}return super.generate(t)}};Xr.COORDINATE="coordinate",Xr.VIEWPORT="viewport",Xr.SIZE="size",Xr.UV="uv",Xr.DPR="dpr";var WR=pe(Xr,Xr.DPR),Kn=pe(Xr,Xr.UV),Lh=pe(Xr,Xr.SIZE),Ph=pe(Xr,Xr.COORDINATE),Vv=pe(Xr,Xr.VIEWPORT),zv=Vv.zw,HR=Ph.sub(Vv.xy),J6=HR.div(zv),Q6=k(()=>(de('TSL: "viewportResolution" is deprecated. Use "screenSize" instead.',new fi),Lh),"vec2").once()(),Gv=null,If=null,jv=null,Ff=null,$v=null,Df=null,Wv=null,Of=null,Hv=null,Bf=null,qv=null,Uf=null,Xv=null,Vf=null,il=be(0,"uint").setName("u_cameraIndex").setGroup(_f("cameraIndex")).toVarying("v_cameraIndex"),rl=be("float").setName("cameraNear").setGroup(we).onRenderUpdate(({camera:e})=>e.near),sl=be("float").setName("cameraFar").setGroup(we).onRenderUpdate(({camera:e})=>e.far),Za=k(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){let i=[];for(let r of e.cameras)i.push(r.projectionMatrix);If===null?If=Sr(i).setGroup(we).setName("cameraProjectionMatrices"):If.array=i,t=If.element(e.isMultiViewCamera?Ka("gl_ViewID_OVR"):il).toConst("cameraProjectionMatrix")}else Gv===null&&(Gv=be(e.projectionMatrix).setName("cameraProjectionMatrix").setGroup(we).onRenderUpdate(({camera:i})=>i.projectionMatrix)),t=Gv;return t}).once()(),qR=k(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){let i=[];for(let r of e.cameras)i.push(r.projectionMatrixInverse);Ff===null?Ff=Sr(i).setGroup(we).setName("cameraProjectionMatricesInverse"):Ff.array=i,t=Ff.element(e.isMultiViewCamera?Ka("gl_ViewID_OVR"):il).toConst("cameraProjectionMatrixInverse")}else jv===null&&(jv=be(e.projectionMatrixInverse).setName("cameraProjectionMatrixInverse").setGroup(we).onRenderUpdate(({camera:i})=>i.projectionMatrixInverse)),t=jv;return t}).once()(),js=k(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){let i=[];for(let r of e.cameras)i.push(r.matrixWorldInverse);Df===null?Df=Sr(i).setGroup(we).setName("cameraViewMatrices"):Df.array=i,t=Df.element(e.isMultiViewCamera?Ka("gl_ViewID_OVR"):il).toConst("cameraViewMatrix")}else $v===null&&($v=be(e.matrixWorldInverse).setName("cameraViewMatrix").setGroup(we).onRenderUpdate(({camera:i})=>i.matrixWorldInverse)),t=$v;return t}).once()(),eV=k(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){let i=[];for(let r of e.cameras)i.push(r.matrixWorld);Of===null?Of=Sr(i).setGroup(we).setName("cameraWorldMatrices"):Of.array=i,t=Of.element(e.isMultiViewCamera?Ka("gl_ViewID_OVR"):il).toConst("cameraWorldMatrix")}else Wv===null&&(Wv=be(e.matrixWorld).setName("cameraWorldMatrix").setGroup(we).onRenderUpd
21ate(({camera:i})=>i.matrixWorld)),t=Wv;return t}).once()(),tV=k(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){let i=[];for(let r of e.cameras)i.push(r.normalMatrix);Bf===null?Bf=Sr(i).setGroup(we).setName("cameraNormalMatrices"):Bf.array=i,t=Bf.element(e.isMultiViewCamera?Ka("gl_ViewID_OVR"):il).toConst("cameraNormalMatrix")}else Hv===null&&(Hv=be(e.normalMatrix).setName("cameraNormalMatrix").setGroup(we).onRenderUpdate(({camera:i})=>i.normalMatrix)),t=Hv;return t}).once()(),XR=k(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){let i=[];for(let r=0,s=e.cameras.length;r<s;r++)i.push(new F);Uf===null?Uf=Sr(i).setGroup(we).setName("cameraPositions").onRenderUpdate(({camera:r},s)=>{let n=r.cameras,a=s.array;for(let o=0,l=n.length;o<l;o++)a[o].setFromMatrixPosition(n[o].matrixWorld)}):Uf.array=i,t=Uf.element(e.isMultiViewCamera?Ka("gl_ViewID_OVR"):il).toConst("cameraPosition")}else qv===null&&(qv=be(new F).setName("cameraPosition").setGroup(we).onRenderUpdate(({camera:i},r)=>r.value.setFromMatrixPosition(i.matrixWorld))),t=qv;return t}).once()(),iV=k(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){let i=[];for(let r of e.cameras)i.push(r.viewport);Vf===null?Vf=Sr(i,"vec4").setGroup(we).setName("cameraViewports"):Vf.array=i,t=Vf.element(il).toConst("cameraViewport")}else Xv===null&&(Xv=Te(0,0,Lh.x,Lh.y).toConst("cameraViewport")),t=Xv;return t}).once()(),YR=new ja,$i=class Qi extends ve{static get type(){return"Object3DNode"}constructor(t,i=null){super(),this.scope=t,this.object3d=i,this.updateType=Re.OBJECT,this.uniformNode=new up(null)}generateNodeType(){let t=this.scope;if(t===Qi.WORLD_MATRIX)return"mat4";if(t===Qi.POSITION||t===Qi.VIEW_POSITION||t===Qi.DIRECTION||t===Qi.SCALE)return"vec3";if(t===Qi.RADIUS)return"float"}update(t){let i=this.object3d,r=this.uniformNode,s=this.scope;if(s===Qi.WORLD_MATRIX)r.value=i.matrixWorld;else if(s===Qi.POSITION)r.value=r.value||new F,r.value.setFromMatrixPosition(i.matrixWorld);else if(s===Qi.SCALE)r.value=r.value||new F,r.value.setFromMatrixScale(i.matrixWorld);else if(s===Qi.DIRECTION)r.value=r.value||new F,i.getWorldDirection(r.value);else if(s===Qi.VIEW_POSITION){let n=t.camera;r.value=r.value||new F,r.value.setFromMatrixPosition(i.matrixWorld),r.value.applyMatrix4(n.matrixWorldInverse)}else if(s===Qi.RADIUS){let n=t.object.geometry;n.boundingSphere===null&&n.computeBoundingSphere(),YR.copy(n.boundingSphere).applyMatrix4(i.matrixWorld),r.value=YR.radius}}generate(t){let i=this.scope;return i===Qi.WORLD_MATRIX?this.uniformNode.nodeType="mat4":i===Qi.POSITION||i===Qi.VIEW_POSITION||i===Qi.DIRECTION||i===Qi.SCALE?this.uniformNode.nodeType="vec3":i===Qi.RADIUS&&(this.uniformNode.nodeType="float"),this.uniformNode.build(t)}serialize(t){super.serialize(t),t.scope=this.scope}deserialize(t){super.deserialize(t),this.scope=t.scope}};$i.WORLD_MATRIX="worldMatrix",$i.POSITION="position",$i.SCALE="scale",$i.VIEW_POSITION="viewPosition",$i.DIRECTION="direction",$i.RADIUS="radius";var rV=Fe($i,$i.DIRECTION).setParameterLength(1),sV=Fe($i,$i.WORLD_MATRIX).setParameterLength(1),nV=Fe($i,$i.POSITION).setParameterLength(1),aV=Fe($i,$i.SCALE).setParameterLength(1),oV=Fe($i,$i.VIEW_POSITION).setParameterLength(1),lV=Fe($i,$i.RADIUS).setParameterLength(1),$s=class extends $i{static get type(){return"ModelNode"}constructor(e){super(e)}update(e){this.object3d=e.object,super.update(e)}},hV=pe($s,$s.DIRECTION),Ws=pe($s,$s.WORLD_MATRIX),uV=pe($s,$s.POSITION),dV=pe($s,$s.SCALE),cV=pe($s,$s.VIEW_POSITION),pV=pe($s,$s.RADIUS),KR=be(new Os).onObjectUpdate(({object:e},t)=>t.value.getNormalMatrix(e.matrixWorld)),mV=be(new $e).onObjectUpdate(({object:e},t)=>t.value.copy(e.matrixWorld).invert()),nl=k(e=>e.context.modelViewMatrix||ZR).once()().toVar("modelViewMatrix"),ZR=js.mul(Ws),Yv=k(e=>
21(e.context.isHighPrecisionModelViewMatrix=!0,be("mat4").onObjectUpdate(({object:t,camera:i})=>t.modelViewMatrix.multiplyMatrices(i.matrixWorldInverse,t.matrixWorld)))).once()().toVar("highpModelViewMatrix"),Kv=k(e=>{let t=e.context.isHighPrecisionModelViewMatrix;return be("mat3").onObjectUpdate(({object:i,camera:r})=>(t!==!0&&i.modelViewMatrix.multiplyMatrices(r.matrixWorldInverse,i.matrixWorld),i.normalMatrix.getNormalMatrix(i.modelViewMatrix)))}).once()().toVar("highpModelNormalViewMatrix"),JR=k(e=>e.shaderStage==="fragment"?e.context.clipSpace.toVarying("v_clipSpace"):(ut("TSL: `clipSpace` is only available in fragment stage."),Te())).once()(),pp=Ya("position","vec3"),ii=pp.toVarying("positionLocal"),hd=pp.toVarying("positionPrevious"),Zn=k(e=>Ws.mul(ii).xyz.toVarying(e.getSubBuildProperty("v_positionWorld")),"vec3").once(["POSITION"])(),Zv=k(()=>ii.transformDirection(Ws).toVarying("v_positionWorldDirection").normalize().toVar("positionWorldDirection"),"vec3").once(["POSITION"])(),yi=k(e=>{if(e.shaderStage==="fragment"&&e.material.vertexNode){let t=qR.mul(JR);return t.xyz.div(t.w).toVar("positionView")}return e.context.setupPositionView().toVarying("v_positionView")},"vec3").once(["POSITION","VERTEX"])(),Lt=k(e=>{let t;return t=e.camera.isOrthographicCamera?L(0,0,1):yi.negate().toVarying("v_positionViewDirection").normalize(),t.toVar("positionViewDirection")},"vec3").once(["POSITION"])(),QR=pe(class extends ve{static get type(){return"FrontFacingNode"}constructor(){super("bool"),this.isFrontFacingNode=!0}generate(e){if(e.shaderStage!=="fragment")return"true";let{material:t}=e;return t.side===1?"false":e.getFrontFacing()}}),Jv=C(QR).mul(2).sub(1),ud=k(([e],{material:t})=>{let i=t.side;return i===1?e=e.mul(-1):i===2&&(e=e.mul(Jv)),e}),zf=Ya("normal","vec3"),us=k(e=>e.geometry.hasAttribute("normal")===!1?(de('TSL: Vertex attribute "normal" not found on geometry.'),L(0,1,0)):zf,"vec3").once()().toVar("normalLocal"),eE=yi.dFdx().cross(yi.dFdy()).normalize().toVar("normalFlat"),dd=k(e=>{let t;return t=e.isFlatShading()?eE:Qv(us).toVarying("v_normalViewGeometry").normalize(),t},"vec3").once()().toVar("normalViewGeometry"),tE=k(e=>{let t=dd.transformDirection(js);return e.isFlatShading()!==!0&&(t=t.toVarying("v_normalWorldGeometry")),t.normalize().toVar("normalWorldGeometry")},"vec3").once()(),nt=k(e=>{let t;return e.subBuildFn==="NORMAL"||e.subBuildFn==="VERTEX"?(t=dd,e.isFlatShading()!==!0&&(t=ud(t))):t=e.context.setupNormal().context({getUV:null,getTextureLevel:null}),t},"vec3").once(["NORMAL","VERTEX"])().toVar("normalView"),al=nt.transformDirection(js).toVar("normalWorld"),ol=k(({subBuildFn:e,context:t})=>{let i;return i=e==="NORMAL"||e==="VERTEX"?nt:t.setupClearcoatNormal().context({getUV:null,getTextureLevel:null}),i},"vec3").once(["NORMAL","VERTEX"])().toVar("clearcoatNormalView"),iE=k(([e,t=Ws])=>{let i=tr(t),r=e.div(L(i[0].dot(i[0]),i[1].dot(i[1]),i[2].dot(i[2])));return i.mul(r).xyz}),Qv=k(([e],t)=>{let i=t.context.modelNormalViewMatrix;if(i)return i.transformDirection(e);let r=KR.mul(e);return js.transformDirection(r)}),gV=k(()=>(de('TSL: "transformedNormalView" is deprecated. Use "normalView" instead.'),nt)).once(["NORMAL","VERTEX"])(),fV=k(()=>(de('TSL: "transformedNormalWorld" is deprecated. Use "normalWorld" instead.'),al)).once(["NORMAL","VERTEX"])(),yV=k(()=>(de('TSL: "transformedClearcoatNormalView" is deprecated. Use "clearcoatNormalView" instead.'),ol)).once(["NORMAL","VERTEX"])(),rE=new In,eb=new $e,sE=be(0).onReference(({material:e})=>e).onObjectUpdate(({material:e})=>e.refractionRatio),Gf=be(1).onReference(({material:e})=>e).onObjectUpdate(function({material:e,scene:t}){return e.envMap?e.envMapIntensity:t.environmentIntensity}),tb=be(new $e).onReference(function(e){return e.material}).onObjectUpdate(function({material:e,scene:t}){let i=t.environment!==null&&e.envMap===null?t.environmentRotation:e.envMapRotation;return i?(rE.copy(i),eb.makeRotationFromEuler(rE)):eb.identity(),eb}),nE=Lt.negate().reflect(nt),aE=Lt.negate().refract(nt,sE),oE=nE.transformDirection(js).toVar("reflectVector"),lE=aE.transformDirection(js).toVar("reflectVector"),hE=new Xg,ib=Fe(class extends Yn{static get type(){return"CubeTextureNode"}constructor(e,t=null,i=null,r=null){super(e,t,i,r),this.isCubeTextureNode=!0}getInputType(){return this.value.isDepthTexture===!0?"cubeDepthTexture":"cubeTexture"}getDefaultUV(){let e=this.value;return e.mapping===301?oE:e.mapping===302?lE:(re('CubeTextureNode: Mapping "%s" not supported.',e.mapping),L(0,0,0))}setUpdateMatrix(){}setupUV(e,t){let i=this.value;return i.isDepthTexture===!0?e.renderer.coordinateSystem===2001?L(t.x,t.y.negate(),t.z):t:((e.renderer.coordinateSystem===2001||!i.isRenderTargetTexture)&&(t=L(t.x.negate(),t.yz)),tb.mul(t))}generateUV(e,t){return t.build(e,this.sampler===!0?"vec3":"ivec3")}}).setParameterLength(1,4).setName("cubeTexture"),Yr=(e=hE,t=null,i=null,r=null)=>{let s;return e&&e.isCubeTextureNode===!0?(s=xe(e.clone()),s.referenceNode=e,t!==null&&(s.uvNode=xe(t)),i!==null&&(s.levelNode=xe(i)),r!==null&&(s.biasNode=xe(r))):s=ib(e,t,i,r),s},xV=(e=hE)=>ib(e),vV=class extends Th{static get type(){return"ReferenceElementNode"}constructor(e,t){super(e,t),this.referenceNode=e,this.isReferenceElementNode=!0}generateNodeType(){return this.referenceNode.uniformType}generate(e){let t=super.generate(e),i=this.referenceNode.getNodeType(e),r=this.getNodeType(e);return e.format(t,i,r)}},jf=class extends ve{static get type(){return"ReferenceNode"}constructor(e,t,i=null,r=null){super(),this.property=e,this.uniformType=t,this.object=i,this.count=r,this.properties=e.split("."),this.reference=i,this.node=null,this.group=null,this.name=null,this.updateType=Re.OBJECT}element(e){return new vV(this,xe(e))}setGroup(e){return this.group=e,this}setName(e){return this.name=e,this}label(e){return de('TSL: "label()" has been deprecated. Use "setName()" instead.'),this.setName(e)}setNodeType(e){let t=null;t=this.count===null?Array.isArray(this.getValueFromReference())?Sr(null,e):e==="texture"?st(null):e==="cubeTexture"?Yr(null):be(null,e):cp(null,e,this.count),this.group!==null&&t.setGroup(this.group),this.name!==null&&t.setName(this.name),this.node=t}generateNodeType(e){return this.node===null&&(this.updateReference(e),this.updateV
21alue()),this.node.getNodeType(e)}getValueFromReference(e=this.reference){let{properties:t}=this,i=e[t[0]];for(let r=1;r<t.length;r++)i=i[t[r]];return i}updateReference(e){return this.reference=this.object===null?e.object:this.object,this.reference}setup(){return this.updateValue(),this.node}update(){this.updateValue()}updateValue(){this.node===null&&this.setNodeType(this.uniformType);let e=this.getValueFromReference();Array.isArray(e)?this.node.array=e:this.node.value=e}},qt=(e,t,i)=>new jf(e,t,i),rb=(e,t,i,r)=>new jf(e,t,r,i),bV=class extends jf{static get type(){return"MaterialReferenceNode"}constructor(e,t,i=null){super(e,t,i),this.material=i,this.isMaterialReferenceNode=!0}updateReference(e){return this.reference=this.material===null?e.material:this.material,this.reference}},Ja=(e,t,i=null)=>new bV(e,t,i),uE=Mt(),_V=yi.dFdx(),TV=yi.dFdy(),dE=uE.dFdx(),cE=uE.dFdy(),pE=nt,mE=TV.cross(pE),gE=pE.cross(_V),sb=mE.mul(dE.x).add(gE.mul(cE.x)),nb=mE.mul(dE.y).add(gE.mul(cE.y)),fE=sb.dot(sb).max(nb.dot(nb)),yE=fE.equal(0).select(0,fE.inverseSqrt()),wV=sb.mul(yE).toVar("tangentViewFrame"),SV=nb.mul(yE).toVar("bitangentViewFrame"),$f=Ya("tangent","vec4"),cd=$f.xyz.toVar("tangentLocal"),Wf=k(e=>{let t;return t=e.subBuildFn==="VERTEX"||e.geometry.hasAttribute("tangent")?nl.mul(Te(cd,0)).xyz.toVarying("v_tangentView").normalize():wV,e.isFlatShading()!==!0&&(t=ud(t)),t},"vec3").once(["NORMAL","VERTEX"])().toVar("tangentView"),xE=Wf.transformDirection(js).toVarying("v_tangentWorld").normalize().toVar("tangentWorld"),Hf=k(([e,t],i)=>{let r=e.mul($f.w).xyz;return i.subBuildFn==="NORMAL"&&i.isFlatShading()!==!0&&(r=r.toVarying(t)),r}).once(["NORMAL"]),MV=Hf(zf.cross($f),"v_bitangentGeometry").normalize().toVar("bitangentGeometry"),CV=Hf(us.cross(cd),"v_bitangentLocal").normalize().toVar("bitangentLocal"),vE=k(e=>{let t;return t=e.subBuildFn==="VERTEX"||e.geometry.hasAttribute("tangent")?Hf(nt.cross(Wf),"v_bitangentView").normalize():SV,e.isFlatShading()!==!0&&(t=ud(t)),t},"vec3").once(["NORMAL","VERTEX"])().toVar("bitangentView"),RV=Hf(al.cross(xE),"v_bitangentWorld").normalize().toVar("bitangentWorld"),kh=tr(Wf,vE,nt).toVar("TBNViewMatrix"),bE=Lt.mul(kh),EV=(e,t)=>e.sub(bE.mul(t)),_E=k(()=>{let e=Ch.cross(Lt);return e=e.cross(Ch).normalize(),e=Ze(e,nt,Zo.mul(Wn.oneMinus()).oneMinus().pow2().pow2()).normalize(),e}).once()(),TE=e=>xe(e).mul(.5).add(.5),AV=e=>xe(e).mul(2).sub(1),ab=e=>L(e,Hr(Mf(C(1).sub(zs(e,e))))),ob=Fe(class extends ei{static get type(){return"NormalMapNode"}constructor(e,t=null){super("vec3"),this.node=e,this.scaleNode=t,this.normalMapType=0,this.unpackNormalMode=""}setup(e){let{normalMapType:t,scaleNode:i,unpackNormalMode:r}=this,s=this.node.mul(2).sub(1);if(t===0?r==="rg"?s=ab(s.xy):r==="ga"?s=ab(s.yw):r!==""&&console.error(`THREE.NodeMaterial: Unexpected unpack normal mode: ${r}`):r!==""&&console.error(`THREE.NodeMaterial: Normal map type '${t}' is not compatible with unpack normal mode '${r}'`),i!==null){let a=i;e.isFlatShading()===!0&&(a=ud(a)),s=L(s.xy.mul(a),s.z)}let n=null;return t===1?n=Qv(s):t===0?n=kh.mul(s).normalize():(re(`NodeMaterial: Unsupported normal map type: ${t}`),n=nt),n}}).setParameterLength(1,2),NV=k(({textureNode:e,bumpScale:t})=>{let i=s=>e.isolate().context({getUV:n=>s(n.uvNode||Mt()),forceUVContext:!0}),r=C(i(s=>s));return se(C(i(s=>s.add(s.dFdx()))).sub(r),C(i(s=>s.add(s.dFdy()))).sub(r)).mul(t)}),LV=k(e=>{let{surf_pos:t,surf_norm:i,dHdxy:r}=e,s=t.dFdx().normalize(),n=t.dFdy().normalize(),a=i,o=n.cross(a),l=a.cross(s),h=s.dot(o).mul(Jv),u=h.sign().mul(r.x.mul(o).add(r.y.mul(l)));return h.abs().mul(i).sub(u).normalize()}),lb=Fe(class extends ei{static get type(){return"BumpMapNode"}constructor(e,t=null){super("vec3"),this.textureNode=e,this.scaleNode=t}setup(){let e=this.scaleNode===null?1:this.scaleNode;return LV({surf_pos:yi,surf_norm:nt,dHdxy:NV({textureNode:this.textureNode,bumpScale:e})})}}).setParameterLength(1,2),wE=new Map,ie=class di extends ve{static get type(){return"MaterialNode"}constructor(t){super(),this.scope=t}getCache(t,i){let r=wE.get(t);return r===void 0&&(r=Ja(t,i),wE.set(t,r)),r}getFloat(t){return this.getCache(t,"float")}getColor(t){return this.getCache(t,"color")}getTexture(t){return this.getCache(t==="map"?"map":t+"Map","texture")}setup(t){let i=t.context.material,r=this.scope,s=null;if(r===di.COLOR){let n=i.color===void 0?L():this.getColor(r);s=i.map&&i.map.isTexture===!0?n.mul(this.getTexture("map")):n}else if(r===di.OPACITY){let n=this.getFloat(r);s=i.alphaMap&&i.alphaMap.isTexture===!0?n.mul(this.getTexture("alpha")):n}else if(r===di.SPECULAR_STRENGTH)s=i.specularMap&&i.specularMap.isTexture===!0?this.getTexture("specular").r:C(1);else if(r===di.SPECULAR_INTENSITY){let n=this.getFloat(r);s=i.specularIntensityMap&&i.specularIntensityMap.isTexture===!0?n.mul(this.getTexture(r).a):n}else if(r===di.SPECULAR_COLOR){let n=this.getColor(r);s=i.specularColorMap&&i.specularColorMap.isTexture===!0?n.mul(this.getTexture(r).rgb):n}else if(r===di.ROUGHNESS){let n=this.getFloat(r);s=i.roughnessMap&&i.roughnessMap.isTexture===!0?n.mul(this.getTexture(r).g):n}else if(r===di.METALNESS){let n=this.getFloat(r);s=i.metalnessMap&&i.metalnessMap.isTexture===!0?n.mul(this.getTexture(r).b):n}else if(r===di.EMISSIVE){let n=this.getFloat("emissiveIntensity"),a=this.getColor(r).mul(n);s=i.emissiveMap&&i.emissiveMap.isTexture===!0?a.mul(this.getTexture(r)):a}else if(r===di.NORMAL)i.normalMap?(s=ob(this.getTexture("normal"),this.getCache("normalScale","vec2")),s.normalMapType=i.normalMapType,(i.normalMap.format==1030||i.normalMap.format==36285||i.normalMap.format==37490)&&(s.unpackNormalMode="rg")):s=i.bumpMap?lb(this.getTexture("bump").r,this.getFloat("bumpScale")):nt;else if(r===di.CLEARCOAT){let n=this.getFloat(r);s=i.clearcoatMap&&i.clearcoatMap.isTexture===!0?n.mul(this.getTexture(r).r):n}else if(r===di.CLEARCOAT_ROUGHNESS){let n=this.getFloat(r);s=i.clearcoatRoughnessMap&&i.clearcoatRoughnessMap.isTexture===!0?n.mul(this.getTexture(r).r):n}else if(r===di.CLEARCOAT_NORMAL)s=i.clearcoatNormalMap?ob(this.getTexture(r),this.getCache(r+"Scale","vec2")):nt;else if(r===di.SHEEN){let n=this.getColor("sheenColor").mul(this.getFloat("sheen"));s=i.sheenColorMap&&i.sheenColorMap.isTexture===!0?n.mul(this.getTexture("sheenColor").rgb):n}else if(r===di.SHEEN_ROUGHNESS){let n=this.getFloat(r);s=i.sheenRoughnessMap&&i.sheenRoughnessMap.isTexture===!0?n.mul(this.getTexture(r).a):n,s=s.clamp(1e-4,1)}else if(r===di.ANISOTROPY)if(i.anisotropyMap&&i.anisotropyMap.isTexture===!0){let n=this.getTexture(r);s=cf(pd.x,pd.y,pd.y.negate(),pd.x).mul(n.rg.mul(2).sub(se(1)).normalize().mul(n.b))}else s=pd;else if(r===di.IRIDESCENCE_THICKNESS){let n=qt("1","float",i.iridescenceThicknessRange);
21if(i.iridescenceThicknessMap){let a=qt("0","float",i.iridescenceThicknessRange);s=n.sub(a).mul(this.getTexture(r).g).add(a)}else s=n}else if(r===di.TRANSMISSION){let n=this.getFloat(r);s=i.transmissionMap?n.mul(this.getTexture(r).r):n}else if(r===di.THICKNESS){let n=this.getFloat(r);s=i.thicknessMap?n.mul(this.getTexture(r).g):n}else if(r===di.IOR)s=this.getFloat(r);else if(r===di.LIGHT_MAP)s=this.getTexture(r).rgb.mul(this.getFloat("lightMapIntensity"));else if(r===di.AO)s=this.getTexture(r).r.sub(1).mul(this.getFloat("aoMapIntensity")).add(1);else if(r===di.LINE_DASH_OFFSET)s=i.dashOffset?this.getFloat(r):C(0);else{let n=this.getNodeType(t);s=this.getCache(r,n)}return s}};ie.ALPHA_TEST="alphaTest",ie.COLOR="color",ie.OPACITY="opacity",ie.SHININESS="shininess",ie.SPECULAR="specular",ie.SPECULAR_STRENGTH="specularStrength",ie.SPECULAR_INTENSITY="specularIntensity",ie.SPECULAR_COLOR="specularColor",ie.REFLECTIVITY="reflectivity",ie.ROUGHNESS="roughness",ie.METALNESS="metalness",ie.NORMAL="normal",ie.CLEARCOAT="clearcoat",ie.CLEARCOAT_ROUGHNESS="clearcoatRoughness",ie.CLEARCOAT_NORMAL="clearcoatNormal",ie.EMISSIVE="emissive",ie.ROTATION="rotation",ie.SHEEN="sheen",ie.SHEEN_ROUGHNESS="sheenRoughness",ie.ANISOTROPY="anisotropy",ie.IRIDESCENCE="iridescence",ie.IRIDESCENCE_IOR="iridescenceIOR",ie.IRIDESCENCE_THICKNESS="iridescenceThickness",ie.IOR="ior",ie.TRANSMISSION="transmission",ie.THICKNESS="thickness",ie.ATTENUATION_DISTANCE="attenuationDistance",ie.ATTENUATION_COLOR="attenuationColor",ie.LINE_SCALE="scale",ie.LINE_DASH_SIZE="dashSize",ie.LINE_GAP_SIZE="gapSize",ie.LINE_WIDTH="linewidth",ie.LINE_DASH_OFFSET="dashOffset",ie.POINT_SIZE="size",ie.DISPERSION="dispersion",ie.LIGHT_MAP="light",ie.AO="ao";var SE=pe(ie,ie.ALPHA_TEST),ME=pe(ie,ie.COLOR),CE=pe(ie,ie.SHININESS),RE=pe(ie,ie.EMISSIVE),hb=pe(ie,ie.OPACITY),EE=pe(ie,ie.SPECULAR),ub=pe(ie,ie.SPECULAR_INTENSITY),AE=pe(ie,ie.SPECULAR_COLOR),mp=pe(ie,ie.SPECULAR_STRENGTH),qf=pe(ie,ie.REFLECTIVITY),NE=pe(ie,ie.ROUGHNESS),LE=pe(ie,ie.METALNESS),PE=pe(ie,ie.NORMAL),kE=pe(ie,ie.CLEARCOAT),IE=pe(ie,ie.CLEARCOAT_ROUGHNESS),FE=pe(ie,ie.CLEARCOAT_NORMAL),DE=pe(ie,ie.ROTATION),OE=pe(ie,ie.SHEEN),BE=pe(ie,ie.SHEEN_ROUGHNESS),UE=pe(ie,ie.ANISOTROPY),VE=pe(ie,ie.IRIDESCENCE),zE=pe(ie,ie.IRIDESCENCE_IOR),GE=pe(ie,ie.IRIDESCENCE_THICKNESS),jE=pe(ie,ie.TRANSMISSION),$E=pe(ie,ie.THICKNESS),WE=pe(ie,ie.IOR),HE=pe(ie,ie.ATTENUATION_DISTANCE),qE=pe(ie,ie.ATTENUATION_COLOR),XE=pe(ie,ie.LINE_SCALE),YE=pe(ie,ie.LINE_DASH_SIZE),KE=pe(ie,ie.LINE_GAP_SIZE),PV=pe(ie,ie.LINE_WIDTH),ZE=pe(ie,ie.LINE_DASH_OFFSET),JE=pe(ie,ie.POINT_SIZE),QE=pe(ie,ie.DISPERSION),db=pe(ie,ie.LIGHT_MAP),eA=pe(ie,ie.AO),pd=be(new ge).onReference(function(e){return e.material}).onRenderUpdate(function({material:e}){this.value.set(e.anisotropy*Math.cos(e.anisotropyRotation),e.anisotropy*Math.sin(e.anisotropyRotation))}),tA=k(e=>e.context.setupModelViewProjection(),"vec4").once()().toVarying("v_modelViewProjection"),kV=Fe(class extends Th{static get type(){return"StorageArrayElementNode"}constructor(e,t){super(e,t),this.isStorageArrayElementNode=!0}set storageBufferNode(e){this.node=e}get storageBufferNode(){return this.node}getMemberType(e,t){let i=this.storageBufferNode.structTypeNode;return i?i.getMemberType(e,t):"void"}setup(e){return e.isAvailable("storageBuffer")===!1&&this.node.isPBO===!0&&e.setupPBO(this.node),super.setup(e)}generate(e,t){let i,r=e.context.assign;if(i=e.isAvailable("storageBuffer")===!1?this.node.isPBO===!0&&r!==!0&&(this.node.value.isInstancedBufferAttribute||e.shaderStage!=="compute")?e.generatePBO(this):this.node.build(e):super.generate(e),r!==!0){let s=this.getNodeType(e);i=e.format(i,s,t)}return i}}).setParameterLength(2),IV=class extends Uv{static get type(){return"StorageBufferNode"}constructor(e,t=null,i=0){let r,s=null;t&&t.isStruct?(r="struct",s=t.layout,(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)&&(i=e.count)):t===null&&(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)?(r=nC(e.itemSize),i=e.count):r=t,super(e,r,i),this.isStorageBufferNode=!0,this.structTypeNode=s,this.access=pr.READ_WRITE,this.isAtomic=!1,this.isPBO=!1,this._attribute=null,this._varying=null,this.global=!0,e.isStorageBufferAttribute!==!0&&e.isStorageInstancedBufferAttribute!==!0&&(e.isInstancedBufferAttribute?e.isStorageInstancedBufferAttribute=!0:e.isStorageBufferAttribute=!0)}getHash(e){let t;if(this.bufferCount===0){let i=e.globalCache.getData(this.value);i===void 0&&(i={node:this},e.globalCache.setData(this.value,i)),t=i.node.id}else t=this.id;return String(t)}getInputType(){return this.value.isIndirectStorageBufferAttribute?"indirectStorageBuffer":"storageBuffer"}element(e){return kV(this,e)}setPBO(e){return this.isPBO=e,this}getPBO(){return this.isPBO}setAccess(e){return this.access=e,this}toReadOnly(){return this.setAccess(pr.READ_ONLY)}setAtomic(e){return this.isAtomic=e,this}toAtomic(){return this.setAtomic(!0)}getAttributeData(){return this._attribute===null&&(this._attribute=Pv(this.value),this._varying=Qo(this._attribute)),{attribute:this._attribute,varying:this._varying}}generateNodeType(e){if(this.structTypeNode!==null)return this.structTypeNode.getNodeType(e);if(e.isAvailable("storageBuffer")||e.isAvailable("indirectStorageBuffer"))return super.generateNodeType(e);let{attribute:t}=this.getAttributeData();return t.getNodeType(e)}getMemberType(e,t){return this.structTypeNode===null?"void":this.structTypeNode.getMemberType(e,t)}generate(e){if(this.structTypeNode!==null&&this.structTypeNode.build(e),e.isAvailable("storageBuffer")||e.isAvailable("indirectStorageBuffer"))return super.generate(e);let{attribute:t,varying:i}=this.getAttributeData(),r=i.build(e);return e.registerTransform(r,t),r}},ll=(e,t=null,i=0)=>new IV(e,t,i),ir=class Lu extends ve{static get type(){return"IndexNode"}constructor(t){super("uint"),this.scope=t,this.isIndexNode=!0}generate(t){let i=this.getNodeType(t),r=this.scope,s;if(r===Lu.VERTEX)s=t.getVertexIndex();else if(r===Lu.INSTANCE)s=t.getInstanceIndex();else if(r===Lu.DRAW)s=t.getDrawIndex();else if(r===Lu.INVOCATION_LOCAL)s=t.getInvocationLocalIndex();
21else if(r===Lu.INVOCATION_SUBGROUP)s=t.getInvocationSubgroupIndex();else if(r===Lu.SUBGROUP)s=t.getSubgroupIndex();else throw Error("THREE.IndexNode: Unknown scope: "+r);let n;return n=t.shaderStage==="vertex"||t.shaderStage==="compute"?s:Qo(this).build(t,i),n}};ir.VERTEX="vertex",ir.INSTANCE="instance",ir.SUBGROUP="subgroup",ir.INVOCATION_LOCAL="invocationLocal",ir.INVOCATION_SUBGROUP="invocationSubgroup",ir.DRAW="draw";var iA=pe(ir,ir.VERTEX),Jn=pe(ir,ir.INSTANCE),FV=pe(ir,ir.SUBGROUP),DV=pe(ir,ir.INVOCATION_SUBGROUP),OV=pe(ir,ir.INVOCATION_LOCAL),rA=pe(ir,ir.DRAW),sA=class extends ve{static get type(){return"InstanceNode"}constructor(e,t,i=null){super("void"),this.count=e,this.instanceMatrix=t,this.instanceColor=i,this.instanceMatrixNode=null,this.instanceColorNode=null,this.updateType=Re.FRAME,this.buffer=null,this.bufferColor=null,this.previousInstanceMatrixNode=null}get isStorageMatrix(){let{instanceMatrix:e}=this;return e&&e.isStorageInstancedBufferAttribute===!0}get isStorageColor(){let{instanceColor:e}=this;return e&&e.isStorageInstancedBufferAttribute===!0}setup(e){let{instanceMatrixNode:t,instanceColorNode:i}=this;t===null&&(t=this._createInstanceMatrixNode(!0,e),this.instanceMatrixNode=t);let{instanceColor:r,isStorageColor:s}=this;if(r&&i===null){if(s)i=ll(r,"vec3",Math.max(r.count,1)).element(Jn);else{let a=new cr(r.array,3),o=r.usage===35048?kv:Af;this.bufferColor=a,i=L(o(a,"vec3",3,0))}this.instanceColorNode=i}let n=t.mul(ii).xyz;if(ii.assign(n),e.needsPreviousData()&&hd.assign(this.getPreviousInstancedPosition(e)),e.hasGeometryAttribute("normal")){let a=iE(us,t);us.assign(a)}this.instanceColorNode!==null&&op("vec3","vInstanceColor").assign(this.instanceColorNode)}update(e){this.buffer!==null&&this.isStorageMatrix!==!0&&(this.buffer.clearUpdateRanges(),this.buffer.updateRanges.push(...this.instanceMatrix.updateRanges),this.instanceMatrix.version!==this.buffer.version&&(this.buffer.version=this.instanceMatrix.version)),this.instanceColor&&this.bufferColor!==null&&this.isStorageColor!==!0&&(this.bufferColor.clearUpdateRanges(),this.bufferColor.updateRanges.push(...this.instanceColor.updateRanges),this.instanceColor.version!==this.bufferColor.version&&(this.bufferColor.version=this.instanceColor.version)),this.previousInstanceMatrixNode!==null&&e.object.previousInstanceMatrix.array.set(this.instanceMatrix.array)}getPreviousInstancedPosition(e){let t=e.object;return this.previousInstanceMatrixNode===null&&(t.previousInstanceMatrix=this.instanceMatrix.clone(),this.previousInstanceMatrixNode=this._createInstanceMatrixNode(!1,e)),this.previousInstanceMatrixNode.mul(hd).xyz}_createInstanceMatrixNode(e,t){let i,{instanceMatrix:r}=this,{count:s}=r;if(this.isStorageMatrix)i=ll(r,"mat4",Math.max(s,1)).element(Jn);else if(s*16*4<=t.getUniformBufferLimit())i=cp(r.array,"mat4",Math.max(s,1)).element(Jn);else{let n=new IU(r.array,16,1);e===!0&&(this.buffer=n);let a=r.usage===35048?kv:Af;i=Yo(a(n,"vec4",16,0),a(n,"vec4",16,4),a(n,"vec4",16,8),a(n,"vec4",16,12))}return i}},BV=Fe(sA).setParameterLength(2,3),nA=Fe(class extends sA{static get type(){return"InstancedMeshNode"}
21constructor(e){let{count:t,instanceMatrix:i,instanceColor:r}=e;super(t,i,r),this.instancedMesh=e}}).setParameterLength(1),aA=Fe(class extends ve{static get type(){return"BatchNode"}constructor(e){super("void"),this.batchMesh=e,this.batchingIdNode=null}setup(e){this.batchingIdNode===null&&(e.getDrawIndex()===null?this.batchingIdNode=Jn:this.batchingIdNode=rA);let t=k(([c])=>{let p=A(tl(ni(this.batchMesh._indirectTexture),0).x).toConst(),m=A(c).mod(p).toConst(),g=A(c).div(p).toConst();return ni(this.batchMesh._indirectTexture,Ii(m,g)).x}).setLayout({name:"getIndirectIndex",type:"uint",inputs:[{name:"id",type:"int"}]})(A(this.batchingIdNode)),i=this.batchMesh._matricesTexture,r=A(tl(ni(i),0).x).toConst(),s=C(t).mul(4).toInt().toConst(),n=s.mod(r).toConst(),a=s.div(r).toConst(),o=Yo(ni(i,Ii(n,a)),ni(i,Ii(n.add(1),a)),ni(i,Ii(n.add(2),a)),ni(i,Ii(n.add(3),a))),l=this.batchMesh._colorsTexture;if(l!==null){let c=k(([p])=>{let m=A(tl(ni(l),0).x).toConst(),g=p;return ni(l,Ii(g.mod(m).toConst(),g.div(m).toConst())).rgb}).setLayout({name:"getBatchingColor",type:"vec3",inputs:[{name:"id",type:"int"}]})(t);op("vec3","vBatchColor").assign(c)}let h=tr(o);ii.assign(o.mul(ii));let u=us.div(L(h[0].dot(h[0]),h[1].dot(h[1]),h[2].dot(h[2]))),d=h.mul(u).xyz;us.assign(d),e.hasGeometryAttribute("tangent")&&cd.mulAssign(h)}}).setParameterLength(1),oA=new WeakMap,lA=class extends ve{static get type(){return"SkinningNode"}constructor(e){super("void"),this.skinnedMesh=e,this.updateType=Re.OBJECT,this.skinIndexNode=Ya("skinIndex","uvec4"),this.skinWeightNode=Ya("skinWeight","vec4"),this.bindMatrixNode=qt("bindMatrix","mat4"),this.bindMatrixInverseNode=qt("bindMatrixInverse","mat4"),this.boneMatricesNode=rb("skeleton.boneMatrices","mat4",e.skeleton.bones.length),this.positionNode=ii,this.toPositionNode=ii,this.previousBoneMatricesNode=null}getSkinnedPosition(e=this.boneMatricesNode,t=this.positionNode){let{skinIndexNode:i,skinWeightNode:r,bindMatrixNode:s,bindMatrixInverseNode:n}=this,a=e.element(i.x),o=e.element(i.y),l=e.element(i.z),h=e.element(i.w),u=s.mul(t),d=wi(a.mul(r.x).mul(u),o.mul(r.y).mul(u),l.mul(r.z).mul(u),h.mul(r.w).mul(u));return n.mul(d).xyz}getSkinnedNormalAndTangent(e=this.boneMatricesNode,t=us,i=cd){let{skinIndexNode:r,skinWeightNode:s,bindMatrixNode:n,bindMatrixInverseNode:a}=this,o=e.element(r.x),l=e.element(r.y),h=e.element(r.z),u=e.element(r.w),d=wi(s.x.mul(o),s.y.mul(l),s.z.mul(h),s.w.mul(u));return d=a.mul(d).mul(n),{skinNormal:d.transformDirection(t).xyz,skinTangent:d.transformDirection(i).xyz}}getPreviousSkinnedPosition(e){let t=e.object;return this.previousBoneMatricesNode===null&&(t.skeleton.previousBoneMatrices=new Float32Array(t.skeleton.boneMatrices),this.previousBoneMatricesNode=rb("skeleton.previousBoneMatrices","mat4",t.skeleton.bones.length)),this.getSkinnedPosition(this.previousBoneMatricesNode,hd)}setup(e){e.needsPreviousData()&&hd.assign(this.getPreviousSkinnedPosition(e));let t=this.getSkinnedPosition();if(this.toPositionNode&&this.toPositionNode.assign(t),e.hasGeometryAttribute("normal")){let{skinNormal:i,skinTangent:r}=this.getSkinnedNormalAndTangent();us.assign(i),e.hasGeometryAttribute("tangent")&&cd.assign(r)}return t}generate(e,t){if(t!=="void")return super.generate(e,t)}update(e){let t=e.object&&e.object.skeleton?e.object.skeleton:this.skinnedMesh.skeleton;oA.get(t)!==e.frameId&&(oA.set(t,e.frameId),this.previousBoneMatricesNode!==null&&(t.previousBoneMatrices===null&&(t.previousBoneMatrices=new Float32Array(t.boneMatrices)),t.previousBoneMatrices.set(t.boneMatrices)),t.update())}},hA=e=>new lA(e),UV=(e,t=null)=>{let i=new lA(e);return i.positionNode=ll(new cr(e.geometry.getAttribute("position").array,3),"vec3").setPBO(!0).toReadOnly().element(Jn).toVar(),i.skinIndexNode=ll(new cr(new Uint32Array(e.geometry.getAttribute("skinIndex").array),4),"uvec4").setPBO(!0).toReadOnly().element(Jn).toVar(),i.skinWeightNode=ll(new cr(e.geometry.getAttribute("skinWeight").array,4),"vec4").setPBO(!0).toReadOnly().element(Jn).toVar(),i.bindMatrixNode=be(e.bindMatrix,"mat4"),i.bindMatrixInverseNode=be(e.bindMatrixInverse,"mat4"),i.boneMatricesNode=cp(e.skeleton.boneMatrices,"mat4",e.skeleton.bones.length),i.toPositionNode=t,xe(i)},VV=class extends ve{static get type(){return"LoopNode"}constructor(e=[]){super("void"),this.params=e}getVarName(e){return String.fromCharCode(105+e)}getProperties(e){let t=e.getNodeProperties(this);if(t.stackNode!==void 0)return t;let i={};for(let a=0,o=this.params.length-1;a<o;a++){let l=this.params[a],h=l.isNode!==!0&&l.name||this.getVarName(a);i[h]=Ts(h,l.isNode!==!0&&l.type||"int")}let r=e.addStack(),s=this.params[this.params.length-1](i);t.returnsNode=s.context({nodeLoop:s}
21),t.stackNode=r;let n=this.params[0];if(n.isNode!==!0&&typeof n.update=="function"){let a=k(this.params[0].update)(i);t.updateNode=a.context({nodeLoop:a})}return e.removeStack(),t}setup(e){if(this.getProperties(e),e.fnCall){let t=e.getDataFromNode(e.fnCall.shaderNode);t.hasLoop=!0}}generate(e){let t=this.getProperties(e),i=this.params,r=t.stackNode;for(let n=0,a=i.length-1;n<a;n++){let o=i[n],l=!1,h=null,u=null,d=null,c=null,p=null,m=null;o.isNode?o.getNodeType(e)==="bool"?(l=!0,c="bool",u=o.build(e,c)):(c="int",d=this.getVarName(n),h="0",u=o.build(e,c),p="<"):(c=o.type||"int",d=o.name||this.getVarName(n),h=o.start,u=o.end,p=o.condition,m=o.update,typeof h=="number"?h=e.generateConst(c,h):h&&h.isNode&&(h=h.build(e,c)),typeof u=="number"?u=e.generateConst(c,u):u&&u.isNode&&(u=u.build(e,c)),h!==void 0&&u===void 0?(h+=" - 1",u="0",p=">="):u!==void 0&&h===void 0&&(h="0",p="<"),p===void 0&&(p=Number(h)>Number(u)?">=":"<"));let g;if(l)g=`while ( ${u} )`;else{let f={start:h,end:u},y=f.start,x=f.end,b,_=()=>p.includes("<")?"+=":"-=";if(m!=null)switch(typeof m){case"function":b=e.flowStagesNode(t.updateNode,"void").code.replace(/\t|;/g,"");break;case"number":b=d+" "+_()+" "+e.generateConst(c,m);break;case"string":b=d+" "+m;break;default:m.isNode?b=d+" "+_()+" "+m.build(e):(re("TSL: 'Loop( { update: ... } )' is not a function, string or number.",this.stackTrace),b="break /* invalid update */")}else m=c==="int"||c==="uint"?p.includes("<")?"++":"--":_()+" 1.",b=d+" "+m;g=`for ( ${e.getVar(c,d)+" = "+y}; ${d+" "+p+" "+x}; ${b} )`}e.addFlowCode((n===0?`
22`:"")+e.tab+g+` {
23
24`).addFlowTab()}let s=r.build(e,"void");t.returnsNode.build(e,"void"),e.removeFlowTab().addFlowCode(`
25`+e.tab+s);for(let n=0,a=this.params.length-1;n<a;n++)e.addFlowCode((n===0?"":e.tab)+`}
26
27`).removeFlowTab();e.addFlowTab()}},bt=(...e)=>new VV(wh(e,"int")).toStack(),zV=()=>Ts("continue").toStack(),uA=()=>Ts("break").toStack(),cb=new WeakMap,ws=new yt,dA=k(({bufferMap:e,influence:t,stride:i,width:r,depth:s,offset:n})=>{let a=A(iA).mul(i).add(n),o=a.div(r);return ni(e,Ii(a.sub(o.mul(r)),o)).depth(s).xyz.mul(t)});function GV(e){let t=e.morphAttributes.position!==void 0,i=e.morphAttributes.normal!==void 0,r=e.morphAttributes.color!==void 0,s=e.morphAttributes.position||e.morphAttributes.normal||e.morphAttributes.color,n=s===void 0?0:s.length,a=cb.get(e);if(a===void 0||a.count!==n){let y=function(){g.dispose(),cb.delete(e),e.removeEventListener("dispose",y)};a!==void 0&&a.texture.dispose();let o=e.morphAttributes.position||[],l=e.morphAttributes.normal||[],h=e.morphAttributes.color||[],u=0;t===!0&&(u=1),i===!0&&(u=2),r===!0&&(u=3);let d=e.attributes.position.count*u,c=1,p=4096;d>p&&(c=Math.ceil(d/p),d=p);let m=new Float32Array(d*c*4*n),g=new GB(m,d,c,n);g.type=Pn,g.needsUpdate=!0;let f=u*4;for(let x=0;x<n;x++){let b=o[x],_=l[x],T=h[x],w=d*c*4*x;for(let M=0;M<b.count;M++){let S=M*f;t===!0&&(ws.fromBufferAttribute(b,M),m[w+S+0]=ws.x,m[w+S+1]=ws.y,m[w+S+2]=ws.z,m[w+S+3]=0),i===!0&&(ws.fromBufferAttribute(_,M),m[w+S+4]=ws.x,m[w+S+5]=ws.y,m[w+S+6]=ws.z,m[w+S+7]=0),r===!0&&(ws.fromBufferAttribute(T,M),m[w+S+8]=ws.x,m[w+S+9]=ws.y,m[w+S+10]=ws.z,m[w+S+11]=T.itemSize===4?ws.w:1)}}a={count:n,texture:g,stride:u,size:new ge(d,c)},cb.set(e,a),e.addEventListener("dispose",y)}return a}var cA=Fe(class extends ve{static get type(){return"MorphNode"}constructor(e){super("void"),this.mesh=e,this.morphBaseInfluence=be(1),this.updateType=Re.OBJECT}setup(e){let{geometry:t}=e,i=t.morphAttributes.position!==void 0,r=t.hasAttribute("normal")&&t.morphAttributes.normal!==void 0,s=t.morphAttributes.position||t.morphAttributes.normal||t.morphAttributes.color,n=s===void 0?0:s.length,{texture:a,stride:o,size:l}=GV(t);i===!0&&ii.mulAssign(this.morphBaseInfluence),r===!0&&us.mulAssign(this.morphBaseInfluence);let h=A(l.width);bt(n,({i:u})=>{let d=C(0).toVar();this.mesh.count>1&&this.mesh.morphTexture!==null&&this.mesh.morphTexture!==void 0?d.assign(ni(this.mesh.morphTexture,Ii(A(u).add(1),A(Jn))).r):d.assign(qt("morphTargetInfluences","float").element(u).toVar()),Se(d.notEqual(0),()=>{i===!0&&ii.addAssign(dA({bufferMap:a,influence:d,stride:o,width:h,depth:u,offset:A(0)})),r===!0&&us.addAssign(dA({bufferMap:a,influence:d,stride:o,width:h,depth:u,offset:A(1)}))})})}update(){let e=this.morphBaseInfluence;this.mesh.geometry.morphTargetsRelative?e.value=1:e.value=1-this.mesh.morphTargetInfluences.reduce((t,i)=>t+i,0)}}).setParameterLength(1),md=class extends ve{static get type(){return"LightingNode"}constructor(){super("vec3"),this.isLightingNode=!0}},jV=class extends md{static get type(){return"AONode"}constructor(e=null){super(),this.aoNode=e}setup(e){e.context.ambientOcclusion.mulAssign(this.aoNode)}},pA=Fe(class extends xR{static get type(){return"LightingContextNode"}constructor(e,t=null,i=null,r=null){super(e),this.lightingModel=t,this.backdropNode=i,this.backdropAlphaNode=r,this._value=null}getContext(){let{backdropNode:e,backdropAlphaNode:t}=this,i={directDiffuse:L().toVar("directDiffuse"),directSpecular:L().toVar("directSpecular"),indirectDiffuse:L().toVar("indirectDiffuse"),indirectSpecular:L().toVar("indirectSpecular")};return{radiance:L().toVar("radiance"),irradiance:L().toVar("irradiance"),iblIrradiance:L().toVar("iblIrradiance"),ambientOcclusion:C(1).toVar("ambientOcclusion"),reflectedLight:i,backdrop:e,backdropAlpha:t}}setup(e){return this.value=this._value||=this.getContext(),this.value.lightingModel=this.lightingModel||e.context.lightingModel,super.setup(e)}}),$V=class extends md{static get type(){return"IrradianceNode"}constructor(e){super(),this.node=e}
27setup(e){e.context.irradiance.addAssign(this.node)}},Ih=new ge,Xf=class extends Yn{static get type(){return"ViewportTextureNode"}constructor(e=Kn,t=null,i=null){let r=null;i===null?(r=new Cx,r.minFilter=bg,i=r):r=i,super(i,e,t),this.generateMipmaps=!1,this.defaultFramebuffer=r,this.isOutputTextureNode=!0,this.updateBeforeType=Re.RENDER,this._cacheTextures=new WeakMap}getTextureForReference(e=null){let t,i;if(this.referenceNode?(t=this.referenceNode.defaultFramebuffer,i=this.referenceNode._cacheTextures):(t=this.defaultFramebuffer,i=this._cacheTextures),e===null)return t;if(i.has(e)===!1){let r=t.clone();i.set(e,r)}return i.get(e)}updateReference(e){let t=e.renderer,i=t.getRenderTarget(),r=t.getCanvasTarget(),s=i||r;return this.value=this.getTextureForReference(s),this.value}updateBefore(e){let t=e.renderer,i=t.getRenderTarget(),r=t.getCanvasTarget(),s=i||r;s===null?t.getDrawingBufferSize(Ih):s.getDrawingBufferSize?s.getDrawingBufferSize(Ih):Ih.set(s.width,s.height);let n=this.getTextureForReference(s);(n.image.width!==Ih.width||n.image.height!==Ih.height)&&(n.image.width=Ih.width,n.image.height=Ih.height,n.needsUpdate=!0);let a=n.generateMipmaps;n.generateMipmaps=this.generateMipmaps,t.copyFramebufferToTexture(n),n.generateMipmaps=a}clone(){let e=new this.constructor(this.uvNode,this.levelNode,this.value);return e.generateMipmaps=this.generateMipmaps,e}},WV=Fe(Xf).setParameterLength(0,3),pb=Fe(Xf,null,null,{generateMipmaps:!0}).setParameterLength(0,3),HV=pb(),mA=(e=Kn,t=null)=>HV.sample(e,t),mb=null,gb=Fe(class extends Xf{static get type(){return"ViewportDepthTextureNode"}constructor(e=Kn,t=null,i=null){i===null&&(mb===null&&(mb=new Us),i=mb),super(e,t,i)}}).setParameterLength(0,3),Qa=class mg extends ve{static get type(){return"ViewportDepthNode"}constructor(t,i=null){super("float"),this.scope=t,this.valueNode=i,this.isViewportDepthNode=!0}generate(t){let{scope:i}=this;return i===mg.DEPTH_BASE?t.getFragDepth():super.generate(t)}setup({camera:t}){let{scope:i}=this,r=this.valueNode,s=null;return i===mg.DEPTH_BASE?r!==null&&(s=fA().assign(r)):i===mg.DEPTH?s=t.isPerspectiveCamera?fb(yi.z,rl,sl):gd(yi.z,rl,sl):i===mg.LINEAR_DEPTH&&(s=r===null?gd(yi.z,rl,sl):t.isPerspectiveCamera?gd(yb(r,rl,sl),rl,sl):r),s}};Qa.DEPTH_BASE="depthBase",Qa.DEPTH="depth",Qa.LINEAR_DEPTH="linearDepth";var gd=(e,t,i)=>e.add(t).div(t.sub(i)),qV=(e,t,i)=>e.add(i).div(i.sub(t)),XV=k(([e,t,i],r)=>r.renderer.reversedDepthBuffer===!0?i.sub(t).mul(e).sub(i):t.sub(i).mul(e).sub(t)),fb=(e,t,i)=>t.add(e).mul(i).div(i.sub(t).mul(e)),gA=(e,t,i)=>t.mul(e.add(i)).div(e.mul(t.sub(i))),yb=k(([e,t,i],r)=>r.renderer.reversedDepthBuffer===!0?t.mul(i).div(t.sub(i).mul(e).sub(t)):t.mul(i).div(i.sub(t).mul(e).sub(i))),xb=(e,t,i)=>{t=t.max(1e-6).toVar();let r=Hn(e.negate().div(t)),s=Hn(i.div(t));return r.div(s)},YV=(e,t,i)=>{let r=e.mul(wf(i.div(t)));return C(Math.E).pow(r).mul(t).negate()},fA=Fe(Qa,Qa.DEPTH_BASE),vb=pe(Qa,Qa.DEPTH),Yf=Fe(Qa,Qa.LINEAR_DEPTH).setParameterLength(0,1),KV=Yf(gb());vb.assign=e=>fA(e);var hl=class B1 extends ve{static get type(){return"ClippingNode"}constructor(t=B1.DEFAULT){super(),this.scope=t}setup(t){super.setup(t);let{intersectionPlanes:i,unionPlanes:r}=t.clippingContext;return this.hardwareClipping=t.material.hardwareClipping,this.scope===B1.ALPHA_TO_COVERAGE?this.setupAlphaToCoverage(i,r):this.scope===B1.HARDWARE?this.setupHardwareClipping(r,t):this.setupDefault(i,r)}setupAlphaToCoverage(t,i){return k(()=>{let r=C().toVar("distanceToPlane"),s=C().toVar("distanceToGradient"),n=C(1).toVar("clipOpacity"),a=i.length;if(this.hardwareClipping===!1&&a>0){let l=Sr(i).setGroup(we);bt(a,({i:h})=>{let u=l.element(h);r.assign(yi.dot(u.xyz).negate().add(u.w)),s.assign(r.fwidth().div(2)),n.mulAssign(pn(s.negate(),s,r))})}let o=t.length;if(o>0){let l=Sr(t).setGroup(we),h=C(1).toVar("intersectionClipOpacity");bt(o,({i:u})=>{let d=l.element(u);r.assign(yi.dot(d.xyz).negate().add(d.w)),s.assign(r.fwidth().div(2)),h.mulAssign(pn(s.negate(),s,r).oneMinus())}),n.mulAssign(h.oneMinus())}vt.a.mulAssign(n),vt.a.equal(0).discard()})()}setupDefault(t,i){return k(()=>{let r=i.length;if(this.hardwareClipping===!1&&r>0){let n=Sr(i).setGroup(we);bt(r,({i:a})=>
27{let o=n.element(a);yi.dot(o.xyz).greaterThan(o.w).discard()})}let s=t.length;if(s>0){let n=Sr(t).setGroup(we),a=vs(!0).toVar("clipped");bt(s,({i:o})=>{let l=n.element(o);a.assign(yi.dot(l.xyz).greaterThan(l.w).and(a))}),a.discard()}})()}setupHardwareClipping(t,i){let r=t.length;return i.enableHardwareClipping(r),k(()=>{let s=Sr(t).setGroup(we),n=Ka(i.getClipDistance());bt(r,({i:a})=>{let o=s.element(a),l=yi.dot(o.xyz).sub(o.w).negate();n.element(a).assign(l)})})()}};hl.ALPHA_TO_COVERAGE="alphaToCoverage",hl.DEFAULT="default",hl.HARDWARE="hardware";var ZV=()=>new hl,JV=()=>new hl(hl.ALPHA_TO_COVERAGE),QV=()=>new hl(hl.HARDWARE),ez=.05,yA=k(([e])=>un(Pe(1e4,qr(Pe(17,e.x).add(Pe(.1,e.y)))).mul(wi(.1,kt(qr(Pe(13,e.y).add(e.x))))))),xA=k(([e])=>yA(se(yA(e.xy),e.z))),tz=k(([e])=>{let t=ti(Xn(vv(e.xyz)),Xn(bv(e.xyz))),i=C(1).div(C(ez).mul(t)).toVar("pixScale"),r=se(od(qn(Hn(i))),od(Sf(Hn(i)))),s=se(xA(qn(r.x.mul(e.xyz))),xA(qn(r.y.mul(e.xyz)))),n=un(Hn(i)),a=wi(Pe(n.oneMinus(),s.x),Pe(n,s.y)),o=hs(n,n.oneMinus()),l=L(a.mul(a).div(Pe(2,o).mul(tt(1,o))),a.sub(Pe(.5,o)).div(tt(1,o)),tt(1,tt(1,a).mul(tt(1,a)).div(Pe(2,o).mul(tt(1,o)))));return cn(a.lessThan(o.oneMinus()).select(a.lessThan(o).select(l.x,l.y),l.z),1e-6,1)}).setLayout({name:"getAlphaHashThreshold",type:"float",inputs:[{name:"position",type:"vec3"}]}),iz=class extends jR{static get type(){return"VertexColorNode"}constructor(e){super(null,"vec4"),this.isVertexColorNode=!0,this.index=e}getAttributeName(){let e=this.index;return"color"+(e>0?e:"")}generate(e){let t=this.getAttributeName(e),i=e.hasGeometryAttribute(t),r;return r=i===!0?super.generate(e):e.generateConst(this.nodeType,new yt(1,1,1,1)),r}serialize(e){super.serialize(e),e.index=this.index}deserialize(e){super.deserialize(e),this.index=e.index}},vA=(e=0)=>new iz(e),rz=k(([e,t])=>hs(1,e.oneMinus().div(t)).oneMinus()).setLayout({name:"blendBurn",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),sz=k(([e,t])=>hs(e.div(t.oneMinus()),1)).setLayout({name:"blendDodge",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),nz=k(([e,t])=>e.oneMinus().mul(t.oneMinus()).oneMinus()).setLayout({name:"blendScreen",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),az=k(([e,t])=>Ze(e.mul(2).mul(t),e.oneMinus().mul(2).mul(t.oneMinus()).oneMinus(),Ah(.5,e))).setLayout({name:"blendOverlay",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),oz=k(([e,t])=>{let i=t.a.add(e.a.mul(t.a.oneMinus()));return Te(t.rgb.mul(t.a).add(e.rgb.mul(e.a).mul(t.a.oneMinus())).div(i),i)}).setLayout({name:"blendColor",type:"vec4",inputs:[{name:"base",type:"vec4"},{name:"blend",type:"vec4"}]}),bA=k(([e])=>Te(e.rgb.mul(e.a),e.a),{color:"vec4",return:"vec4"}),lz=k(([e])=>(Se(e.a.equal(0),()=>Te(0)),Te(e.rgb.div(e.a),e.a)),{color:"vec4",return:"vec4"}),Ot=class extends xs{static get type(){return"NodeMaterial"}get type(){return this.constructor.type}set type(e){}constructor(){super(),this.isNodeMaterial=!0,this.fog=!0,this.lights=!1,this.hardwareClipping=!1,this.lightsNode=null,this.envNode=null,this.aoNode=null,this.colorNode=null,this.normalNode=null,this.opacityNode=null,this.backdropNode=null,this.backdropAlphaNode=null,this.alphaTestNode=null,this.maskNode=null,this.maskShadowNode=null,this.positionNode=null,this.geometryNode=null,this.depthNode=null,this.receivedShadowPositionNode=null,this.castShadowPositionNode=null,this.receivedShadowNode=null,this.castShadowNode=null,this.outputNode=null,this.mrtNode=null,this.fragmentNode=null,this.vertexNode=null,this.contextNode=null}_getNodeChildren(){let e=[];for(let t of Object.getOwnPropertyNames(this)){if(t.startsWith("_")===!0)continue;let i=this[t];i&&i.isNode===!0&&e.push({property:t,childNode:i})}return e}customProgramCacheKey(){let e=[];for(let{property:t,childNode:i}of this._getNodeChildren())e.push(id(t.slice(0,-4)),i.getCacheKey());return this.type+tp(e)}build(e){this.setup(e)}setupObserver(e){return new UU(e)}setup(e){e.context.setupNormal=()=>Nh(this.setupNormal(e),"NORMAL","vec3"),e.context.setupPositionView=()=>this.setupPositionView(e),e.context.setupModelViewProjection=()=>this.setupModelViewProjection(e);let t=e.renderer,i=t.getRenderTarget();t.contextNode.isContextNode===!0?e.context={...e.context,...t.contextNode.getFlowContextData()}:re('NodeMaterial: "renderer.contextNode" must be an instance of `context()`.'),this.contextNode!==null&&(this.contextNode.isContextNode===!0?e.context={...e.context,...this.contextNode.getFlowContextData()}:re('NodeMaterial: "material.contextNode" must be an instance of `context()`.')),e.addStack();let r=this.setupVertex(e),s=Nh(this.vertexNode||r,"VERTEX");e.context.clipSpace=s,e.stack.outputNode=s,this.setupHardwareClipping(e),this.geometryNode!==null&&(e.stack.outputNode=e.stack.outputNode.bypass(this.geometryNode)),e.addFlow("vertex",e.removeStack()),e.addStack();let n,a=this.setupClipping(e);if((this.depthWrite===!0||this.depthTest===!0)&&(i===null?t.depth===!0&&this.setupDepth(e):i.depthBuffer===!0&&this.setupDepth(e)),this.fragmentNode===null){this.setupDiffuseColor(e),this.setupVariants(e);let o=this.setupLighting(e);a!==null&&e.stack.addToStack(a);let l=Te(o,vt.a).max(0);n=this.setupOutput(e,l),ad.assign(n);let h=this.outputNode!==null;if(h&&(n=this.outputNode),e.context.getOutput&&(n=e.context.getOutput(n,e)),i!==null){let u=t.getMRT(),d=this.mrtNode;u===null?d!==null&&(n=d):(h&&ad.assign(n),n=u,d!==null&&(n=u.merge(d)))}}else{let o=this.fragmentNode;o.isOutputStructNode!==!0&&(o=Te(o)),n=this.setupOutput(e,o)}e.stack.outputNode=n,e.addFlow("fragment",e.removeStack()),e.observer=this.setupObserver(e)}setupClipping(e){if(e.clippingContext===null)return null;let{unionPlanes:t,intersectionPlanes:i}=e.clippingContext,r=null;if(t.length>0||i.length>0){let s=e.renderer.currentSamples;this.alphaToCoverage&&s>1?r=JV():e.stack.addToStack(ZV())}return r}setupHardwareClipping(e){if(this.hardwareClipping=!1,e.clippingContext===null)return;let t=e.clippingContext.unionPlanes.length;t>0&&t<=8&&e.isAvailable("clipDistance")&&(e.stack.addToStack(QV()),this.hardwareClipping=!0)}setupDepth(e){let{renderer:t,camera:i}=e,r=this.depthNode;if(r===null){let s=t.getMRT();s&&s.has("depth")?r=s.get("depth"):t.logarithmicDepthBuffer===!0&&(r=i.isPerspectiveCamera?xb(yi.z,rl,sl):gd(yi.z,rl,sl))}r!==null&&vb.assign(r).toStack()}setupPositionView(){return nl.mul(ii).xyz}setupModelViewProjection(){return Za.mul(yi)}setupVertex(e){return e.addStack(),this.setupPosition(e),e.context.position=e.removeStack(),tA}setupPosition(e){let{object:t,geometry:i}=e;if((i.morphAttributes.position||i.morphAttributes.normal||i.morphAttributes.color)&&cA(t).toStack(),t.isSkinnedMesh===!0&&hA(t).toStack(),this.displacementMap){let r=Ja("displacementMap","texture"),s=Ja("displacementScale","float"),n=Ja("displacementBias","float");ii.addAssign(us.normalize().mul(r.x.mul(s).add(n)))}return t.isBatchedMesh&&aA(t).toStack(),t.isInstancedMesh&&t.instanceMatrix&&t.instanceMatrix.isInstancedBufferAttribute===!0&&nA(t).toStack(),this.positionNode!==null&&ii.assign(Nh(this.positionNode,"POSITION","vec3")),ii}setupDiffuseColor(e){let{object:t,geometry:i}=e;this.maskNode!==null&&vs(this.maskNode).not().discard();let r=this.colorNode?Te(this.colorNode):ME;this.vertexColors===!0&&i.hasAttribute("color")&&(r=r.mul(vA())),t.instanceColor&&(r=op("vec3","vInstanceColor").mul(r)),t.isBatchedMesh&&t._
27colorsTexture&&(r=op("vec3","vBatchColor").mul(r)),vt.assign(r);let s=this.opacityNode?C(this.opacityNode):hb;vt.a.assign(vt.a.mul(s));let n=null;(this.alphaTestNode!==null||this.alphaTest>0)&&(n=this.alphaTestNode===null?SE:C(this.alphaTestNode),this.alphaToCoverage===!0?(vt.a=pn(n,n.add(Tv(vt.a)),vt.a),vt.a.lessThanEqual(0).discard()):vt.a.lessThanEqual(n).discard()),this.alphaHash===!0&&vt.a.lessThan(tz(ii)).discard(),e.isOpaque()&&vt.a.assign(1)}setupVariants(){}setupOutgoingLight(){return this.lights===!0?L(0):vt.rgb}setupNormal(){return this.normalNode?L(this.normalNode):PE}setupEnvironment(){let e=null;return this.envNode?e=this.envNode:this.envMap&&(e=this.envMap.isCubeTexture?Ja("envMap","cubeTexture"):Ja("envMap","texture")),e}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new $V(db)),t}setupLights(e){let t=[],i=this.setupEnvironment(e);i&&i.isLightingNode&&t.push(i);let r=this.setupLightMap(e);r&&r.isLightingNode&&t.push(r);let s=this.aoNode;s===null&&e.material.aoMap&&(s=eA),e.context.getAO&&(s=e.context.getAO(s,e)),s&&t.push(new jV(s));let n=this.lightsNode||e.lightsNode;return t.length>0&&(n=e.renderer.lighting.createNode([...n.getLights(),...t])),n}setupLightingModel(){}setupLighting(e){let{material:t}=e,{backdropNode:i,backdropAlphaNode:r,emissiveNode:s}=this,n=this.lights===!0||this.lightsNode!==null?this.setupLights(e):null,a=this.setupOutgoingLight(e);return n&&n.getScope().hasLights?a=pA(n,this.setupLightingModel(e)||null,i,r):i!==null&&(a=L(r===null?i:Ze(a,i,r))),(s&&s.isNode===!0||t.emissive&&t.emissive.isColor===!0)&&(nv.assign(L(s||RE)),a=a.add(nv)),a}setupFog(e,t){let i=e.fogNode;return i&&(ad.assign(t),t=Te(i.toVar())),t}setupPremultipliedAlpha(e,t){return bA(t)}setupOutput(e,t){return this.fog===!0&&(t=this.setupFog(e,t)),this.premultipliedAlpha===!0&&(t=this.setupPremultipliedAlpha(e,t)),t}setDefaultValues(e){for(let i in e){let r=e[i];this[i]===void 0&&(this[i]=r,r&&r.clone&&(this[i]=r.clone()))}let t=Object.getOwnPropertyDescriptors(e.constructor.prototype);for(let i in t)Object.getOwnPropertyDescriptor(this.constructor.prototype,i)===void 0&&t[i].get!==void 0&&Object.defineProperty(this.constructor.prototype,i,t[i])}toJSON(e){let t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{},nodes:{}});let i=xs.prototype.toJSON.call(this,e);i.inputNodes={};for(let{property:s,childNode:n}of this._getNodeChildren())i.inputNodes[s]=n.toJSON(e).uuid;function r(s){let n=[];for(let a in s){let o=s[a];delete o.metadata,n.push(o)}return n}if(t){let s=r(e.textures),n=r(e.images),a=r(e.nodes);s.length>0&&(i.textures=s),n.length>0&&(i.images=n),a.length>0&&(i.nodes=a)}return i}copy(e){return this.lightsNode=e.lightsNode,this.envNode=e.envNode,this.aoNode=e.aoNode,this.colorNode=e.colorNode,this.normalNode=e.normalNode,this.opacityNode=e.opacityNode,this.backdropNode=e.backdropNode,this.backdropAlphaNode=e.backdropAlphaNode,this.alphaTestNode=e.alphaTestNode,this.maskNode=e.maskNode,this.maskShadowNode=e.maskShadowNode,this.positionNode=e.positionNode,this.geometryNode=e.geometryNode,this.depthNode=e.depthNode,this.receivedShadowPositionNode=e.receivedShadowPositionNode,this.castShadowPositionNode=e.castShadowPositionNode,this.receivedShadowNode=e.receivedShadowNode,this.castShadowNode=e.castShadowNode,this.outputNode=e.outputNode,this.mrtNode=e.mrtNode,this.fragmentNode=e.fragmentNode,this.vertexNode=e.vertexNode,this.contextNode=e.contextNode,super.copy(e)}},hz=new PM,uz=class extends Ot{static get type(){return"LineBasicNodeMaterial"}constructor(e){super(),this.isLineBasicNodeMaterial=!0,this.setDefaultValues(hz),this.setValues(e)}},dz=new tU,cz=class extends Ot{static get type(){return"LineDashedNodeMaterial"}constructor(e){super(),this.isLineDashedNodeMaterial=!0,this.setDefaultValues(dz),this.dashOffset=0,this.offsetNode=null,this.dashScaleNode=null,this.dashSizeNode=null,this.gapSizeNode=null,this.setValues(e)}setupVariants(){let e=this.offsetNode?C(this.offsetNode):ZE,t=this.dashScaleNode?C(this.dashScaleNode):XE,i=this.dashSizeNode?C(this.dashSizeNode):YE,r=this.gapSizeNode?C(this.gapSizeNode):KE;vf.assign(i),av.assign(r);let s=Qo(Ya("lineDistance").mul(t));(e?s.add(e):s).mod(vf.add(av)).greaterThan(vf).discard()}},pz=new J4,mz=class extends Ot{static get type(){return"MeshNormalNodeMaterial"}constructor(e){super(),this.isMeshNormalNodeMaterial=!0,this.setDefaultValues(pz),this.setValues(e)}setupDiffuseColor(){let e=this.opacityNode?C(this.opacityNode):hb;vt.assign(Rf(Te(TE(nt),e),Gi))}},bb=k(([e=Zv])=>se(e.z.atan(e.x).mul(1/(Math.PI*2)).add(.5),e.y.clamp(-1,1).asin().mul(1/Math.PI).add(.5))),_A=class extends zr{constructor(e=1,t={}){super(e,e,t),this.isCubeRenderTarget=!0;let i={width:e,height:e,depth:1},r=[i,i,i,i,i,i];this.texture=new Xg(r),this._setTextureOptions(t),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(e,t){let i=t.minFilter,r=t.generateMipmaps;t.generateMipmaps=!0,this.texture.type=t.type,this.texture.colorSpace
27=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;let s=new kM(5,5,5),n=bb(Zv),a=new Ot;a.colorNode=st(t,n,0),a.side=1,a.blending=0;let o=new xt(s,a),l=new Oc;l.add(o),t.minFilter===1008&&(t.minFilter=mi);let h=new TU(1,10,this),u=e.getMRT();return e.setMRT(null),h.update(e,l),e.setMRT(u),t.minFilter=i,t.generateMipmaps=r,o.geometry.dispose(),o.material.dispose(),this}clear(e,t=!0,i=!0,r=!0){let s=e.getRenderTarget();for(let n=0;n<6;n++)e.setRenderTarget(this,n),e.clear(t,i,r);e.setRenderTarget(s)}},gp=new WeakMap,gz=class extends ei{static get type(){return"CubeMapNode"}constructor(e){super("vec3"),this.envNode=e,this._cubeTexture=null,this._cubeTextureNode=Yr(null);let t=new Xg;t.isRenderTargetTexture=!0,this._defaultTexture=t,this.updateBeforeType=Re.RENDER}updateBefore(e){let{renderer:t,material:i}=e,r=this.envNode;if(r.isTextureNode||r.isMaterialReferenceNode){let s=r.isTextureNode?r.value:i[r.property];if(s&&s.isTexture){let n=s.mapping;if(n===303||n===304){if(gp.has(s)){let a=gp.get(s);wA(a,s.mapping),this._cubeTexture=a}else{let a=s.image;if(fz(a)){let o=new _A(a.height);o.fromEquirectangularTexture(t,s),wA(o.texture,s.mapping),this._cubeTexture=o.texture,gp.set(s,o.texture),s.addEventListener("dispose",TA)}else this._cubeTexture=this._defaultTexture}this._cubeTextureNode.value=this._cubeTexture}else this._cubeTextureNode=this.envNode}}}setup(e){return this.updateBefore(e),this._cubeTextureNode}};function fz(e){return e==null?!1:e.height>0}function TA(e){let t=e.target;t.removeEventListener("dispose",TA);let i=gp.get(t);i!==void 0&&(gp.delete(t),i.dispose())}function wA(e,t){t===303?e.mapping=301:t===304&&(e.mapping=302)}var SA=Fe(gz).setParameterLength(1),_b=class extends md{static get type(){return"BasicEnvironmentNode"}constructor(e=null){super(),this.envNode=e}setup(e){e.context.environment=SA(this.envNode)}},yz=class extends md{static get type(){return"BasicLightMapNode"}constructor(e=null){super(),this.lightMapNode=e}setup(e){let t=C(1/Math.PI);e.context.irradianceLightMap=this.lightMapNode.mul(t)}},Kf=class{start(e){e.lightsNode.setupLights(e,e.lightsNode.getLightNodes(e)),this.indirect(e)}finish(){}direct(){}directRectArea(){}indirect(){}ambientOcclusion(){}},MA=class extends Kf{constructor(){super()}indirect({context:e}){let t=e.ambientOcclusion,i=e.reflectedLight,r=e.irradianceLightMap;i.indirectDiffuse.assign(Te(0)),r?i.indirectDiffuse.addAssign(r):i.indirectDiffuse.addAssign(Te(1,1,1,0)),i.indirectDiffuse.mulAssign(t),i.indirectDiffuse.mulAssign(vt.rgb)}finish(e){let{material:t,context:i}=e,r=i.outgoingLight,s=e.context.environment;if(s)switch(t.combine){case 0:r.rgb.assign(Ze(r.rgb,r.rgb.mul(s.rgb),mp.mul(qf)));break;case 1:r.rgb.assign(Ze(r.rgb,s.rgb,mp.mul(qf)));break;case 2:r.rgb.addAssign(s.rgb.mul(mp.mul(qf)));break;default:de("BasicLightingModel: Unsupported .combine value:",t.combine);break}}},xz=new ji,Qn=class extends Ot{static get type(){return"MeshBasicNodeMaterial"}constructor(e){super(),this.isMeshBasicNodeMaterial=!0,this.lights=!0,this.setDefaultValues(xz),this.setValues(e)}setupNormal(){return ud(dd)}setupEnvironment(e){let t=super.setupEnvironment(e);return t?new _b(t):null}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new yz(db)),t}setupOutgoingLight(){return vt.rgb}setupLightingModel(){return new MA}},fd=k(({f0:e,f90:t,dotVH:i})=>{let r=i.mul(-5.55473).sub(6.98316).mul(i).exp2();return e.mul(r.oneMinus()).add(t.mul(r))}),Fh=k(e=>e.diffuseColor.mul(1/Math.PI)),vz=()=>C(.25),bz=k(({dotNH:e})=>xf.mul(C(.5)).add(1).mul(C(1/Math.PI)).mul(e.pow(xf))),_z=k(({lightDirection:e})=>{let t=e.add(Lt).normalize(),i=nt.dot(t).clamp(),r=fd({f0:Jo,f90:1,dotVH:Lt.dot(t).clamp()}),s=vz(),n=bz({dotNH:i});return r.mul(s).mul(n)}),CA=class extends MA{constructor(e=!0){super(),this.specular=e}direct({lightDirection:e,lightColor:t,reflectedLight:i}){let r=nt.dot(e).clamp().mul(t);i.directDiffuse.addAssign(r.mul(Fh({diffuseColor:vt.rgb}))),this.specular===!0&&i.directSpecular.addAssign(r.mul(_z({lightDirection:e})).mul(mp))}indirect(e){let{ambientOcclusion:t,irradiance:i,reflectedLight:r}=e.context;r.indirectDiffuse.addAssign(i.mul(Fh({diffuseColor:vt}))),r.indirectDiffuse.mulAssign(t)}},Tz=new Q4,wz=class extends Ot{static get type(){return"MeshLambertNodeMaterial"}constructor(e){super(),this.isMeshLambertNodeMaterial=!0,this.lights=!0,this.setDefaultValues(Tz),this.setValues(e)}setupEnvironment(e){let t=super.setupEnvironment(e);return t?new _b(t):null}setupLightingModel(){return new CA(!1)}},Sz=new K4,Mz=class extends Ot{static get type(){return"MeshPhongNodeMaterial"}constructor(e){super(),this.isMeshPhongNodeMaterial=!0,this.lights=!0,this.shininessNode=null,this.specularNode=null,this.setDefaultValues(Sz),this.setValues(e)}setupEnvironment(e){let t=super.setupEnvironment(e);return t?new _b(t):null}setupLightingModel(){return new CA}setupVariants(){let e=(this.shininessNode?C(this.shininessNode):CE).max(1e-4);xf.assign(e);let t=this.specularNode||EE;Jo.assign(t)}copy(e){return this.shininessNode=e.shininessNode,this.specularNode=e.specularNode,super.copy(e)}},RA=k(e=>{if(e.geometry.hasAttribute("normal")===!1)return C(0);
vendor: 1,218 bytes, line 27
27let t=dd.dFdx().abs().max(dd.dFdy().abs());return t.x.max(t.y).max(t.z)}),Tb=k(e=>{let{roughness:t}=e,i=RA(),r=t.max(.0525);return r=r.add(i),r=r.min(1),r}),EA=k(({alpha:e,dotNL:t,dotNV:i})=>{let r=e.pow2(),s=t.mul(r.add(r.oneMinus().mul(i.pow2())).sqrt()),n=i.mul(r.add(r.oneMinus().mul(t.pow2())).sqrt());return _s(.5,s.add(n).max(cv))}).setLayout({name:"V_GGX_SmithCorrelated",type:"float",inputs:[{name:"alpha",type:"float"},{name:"dotNL",type:"float"},{name:"dotNV",type:"float"}]}),Cz=k(({alphaT:e,alphaB:t,dotTV:i,dotBV:r,dotTL:s,dotBL:n,dotNV:a,dotNL:o})=>{let l=o.mul(L(e.mul(i),t.mul(r),a).length()),h=a.mul(L(e.mul(s),t.mul(n),o).length());return _s(.5,l.add(h))}).setLayout({name:"V_GGX_SmithCorrelated_Anisotropic",type:"float",inputs:[{name:"alphaT",type:"float",qualifier:"in"},{name:"alphaB",type:"float",qualifier:"in"},{name:"dotTV",type:"float",qualifier:"in"},{name:"dotBV",type:"float",qualifier:"in"},{name:"dotTL",type:"float",qualifier:"in"},{name:"dotBL",type:"float",qualifier:"in"},{name:"dotNV",type:"float",qualifier:"in"},{name:"dotNL",type:"float",qualifier:"in"}]}),AA=k(({alpha:e,dotNH:t})=>{let i=e.pow2(),r=t.pow2().mul(i.oneMinus()).oneMinus();return i.div(r.pow2()).mul(1/Math.PI)}
vendor: 2,181 bytes, line 27
27).setLayout({name:"D_GGX",type:"float",inputs:[{name:"alpha",type:"float"},{name:"dotNH",type:"float"}]}),Rz=C(1/Math.PI),Ez=k(({alphaT:e,alphaB:t,dotNH:i,dotTH:r,dotBH:s})=>{let n=e.mul(t),a=L(t.mul(r),e.mul(s),n.mul(i)),o=a.dot(a),l=n.div(o);return Rz.mul(n.mul(l.pow2()))}).setLayout({name:"D_GGX_Anisotropic",type:"float",inputs:[{name:"alphaT",type:"float",qualifier:"in"},{name:"alphaB",type:"float",qualifier:"in"},{name:"dotNH",type:"float",qualifier:"in"},{name:"dotTH",type:"float",qualifier:"in"},{name:"dotBH",type:"float",qualifier:"in"}]}),wb=k(({lightDirection:e,f0:t,f90:i,roughness:r,f:s,normalView:n=nt,USE_IRIDESCENCE:a,USE_ANISOTROPY:o})=>{let l=r.pow2(),h=e.add(Lt).normalize(),u=n.dot(e).clamp(),d=n.dot(Lt).clamp(),c=n.dot(h).clamp(),p=fd({f0:t,f90:i,dotVH:Lt.dot(h).clamp()}),m,g;if(rd(a)&&(p=mf.mix(p,s)),rd(o)){let f=lp.dot(e),y=lp.dot(Lt),x=lp.dot(h),b=Ch.dot(e),_=Ch.dot(Lt),T=Ch.dot(h);m=Cz({alphaT:yf,alphaB:l,dotTV:y,dotBV:_,dotTL:f,dotBL:b,dotNV:d,dotNL:u}),g=Ez({alphaT:yf,alphaB:l,dotNH:c,dotTH:x,dotBH:T})}else m=EA({alpha:l,dotNL:u,dotNV:d}),g=AA({alpha:l,dotNH:c});return p.mul(m).mul(g)}),Az=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,
vendor: 3,178 bytes, line 27
2714942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]),ea=null,fp=k(({roughness:e,dotNV:t})=>{ea===null&&(ea=new Tx(Az,16,16,Oo,as),ea.name="DFG_LUT",ea.minFilter=mi,ea.magFilter=mi,ea.wrapS=Fa,ea.wrapT=Fa,ea.generateMipmaps=!1,ea.needsUpdate=!0);let i=se(e,t);return st(ea,i).rg}),Nz=k(({lightDirection:e,f0:t,f90:i,roughness:r,f:s,USE_IRIDESCENCE:n,USE_ANISOTROPY:a})=>{let o=wb({lightDirection:e,f0:t,f90:i,roughness:r,f:s,USE_IRIDESCENCE:n,USE_ANISOTROPY:a}),l=nt.dot(e).clamp(),h=fp({roughness:r,dotNV:nt.dot(Lt).clamp()}),u=fp({roughness:r,dotNV:l}),d=t.mul(h.x).add(i.mul(h.y)),c=t.mul(u.x).add(i.mul(u.y)),p=h.x.add(h.y),m=u.x.add(u.y),g=C(1).sub(p),f=C(1).sub(m),y=t.add(t.oneMinus().mul(.047619)),x=d.mul(c).mul(y).div(C(1).sub(g.mul(f).mul(y).mul(y)).add(cv)),b=g.mul(f),_=x.mul(b);return o.add(_)}),NA=k(e=>{let{dotNV:t,specularColor:i,specularF90:r,roughness:s}=e,n=fp({dotNV:t,roughness:s});return i.mul(n.x).add(r.mul(n.y))}),Sb=k(({f:e,f90:t,dotVH:i})=>{let r=i.oneMinus().saturate(),s=r.mul(r),n=r.mul(s,s).clamp(0,.9999);return e.sub(L(t).mul(n)).div(n.oneMinus())}).setLayout({name:"Schlick_to_F0",type:"vec3",inputs:[{name:"f",type:"vec3"},{name:"f90",type:"float"},{name:"dotVH",type:"float"}]}),Lz=k(({roughness:e,dotNH:t})=>{let i=e.pow2(),r=C(1).div(i),s=t.pow2().oneMinus().max(.0078125);return C(2).add(r).mul(s.pow(r.mul(.5))).div(2*Math.PI)}
vendor: 9,645 bytes, line 27
27).setLayout({name:"D_Charlie",type:"float",inputs:[{name:"roughness",type:"float"},{name:"dotNH",type:"float"}]}),Pz=k(({dotNV:e,dotNL:t})=>C(1).div(C(4).mul(t.add(e).sub(t.mul(e))))).setLayout({name:"V_Neubelt",type:"float",inputs:[{name:"dotNV",type:"float"},{name:"dotNL",type:"float"}]}),kz=k(({lightDirection:e})=>{let t=e.add(Lt).normalize(),i=nt.dot(e).clamp(),r=nt.dot(Lt).clamp(),s=Lz({roughness:Ko,dotNH:nt.dot(t).clamp()}),n=Pz({dotNV:r,dotNL:i});return bs.mul(s).mul(n)}),LA=k(({N:e,V:t,roughness:i})=>{let r=se(i,e.dot(t).saturate().oneMinus().sqrt());return r.assign(r.mul(.984375).add(.0078125)),r}).setLayout({name:"LTC_Uv",type:"vec2",inputs:[{name:"N",type:"vec3"},{name:"V",type:"vec3"},{name:"roughness",type:"float"}]}),Iz=k(({f:e})=>{let t=e.length();return ti(t.mul(t).add(e.z).div(t.add(1)),0)}).setLayout({name:"LTC_ClippedSphereFormFactor",type:"float",inputs:[{name:"f",type:"vec3"}]}),Zf=k(({v1:e,v2:t})=>{let i=e.dot(t),r=i.abs().toVar(),s=r.mul(.0145206).add(.4965155).mul(r).add(.8543985).toVar(),n=r.add(4.1616724).mul(r).add(3.417594).toVar(),a=s.div(n),o=i.greaterThan(0).select(a,ti(i.mul(i).oneMinus(),1e-7).inverseSqrt().mul(.5).sub(a));return e.cross(t).mul(o)}).setLayout({name:"LTC_EdgeVectorFormFactor",type:"vec3",inputs:[{name:"v1",type:"vec3"},{name:"v2",type:"vec3"}]}),Mb=k(({N:e,V:t,P:i,mInv:r,p0:s,p1:n,p2:a,p3:o})=>{let l=n.sub(s).toVar(),h=o.sub(s).toVar(),u=l.cross(h),d=L().toVar();return Se(u.dot(i.sub(s)).greaterThanEqual(0),()=>{let c=t.sub(e.mul(t.dot(e))).normalize(),p=e.cross(c).negate(),m=r.mul(tr(c,p,e).transpose()).toVar(),g=m.mul(s.sub(i)).normalize().toVar(),f=m.mul(n.sub(i)).normalize().toVar(),y=m.mul(a.sub(i)).normalize().toVar(),x=m.mul(o.sub(i)).normalize().toVar(),b=L(0).toVar();b.addAssign(Zf({v1:g,v2:f})),b.addAssign(Zf({v1:f,v2:y})),b.addAssign(Zf({v1:y,v2:x})),b.addAssign(Zf({v1:x,v2:g})),d.assign(L(Iz({f:b})))}),d}).setLayout({name:"LTC_Evaluate",type:"vec3",inputs:[{name:"N",type:"vec3"},{name:"V",type:"vec3"},{name:"P",type:"vec3"},{name:"mInv",type:"mat3"},{name:"p0",type:"vec3"},{name:"p1",type:"vec3"},{name:"p2",type:"vec3"},{name:"p3",type:"vec3"}]}),Jf=1/6,PA=e=>Pe(Jf,Pe(e,Pe(e,e.negate().add(3)).sub(3)).add(1)),Cb=e=>Pe(Jf,Pe(e,Pe(e,Pe(3,e).sub(6))).add(4)),kA=e=>Pe(Jf,Pe(e,Pe(e,Pe(-3,e).add(3)).add(3)).add(1)),Rb=e=>Pe(Jf,Gs(e,3)),IA=e=>PA(e).add(Cb(e)),FA=e=>kA(e).add(Rb(e)),DA=e=>wi(-1,Cb(e).div(PA(e).add(Cb(e)))),OA=e=>wi(1,Rb(e).div(kA(e).add(Rb(e)))),BA=(e,t,i)=>{let r=e.uvNode,s=Pe(r,t.zw).add(.5),n=qn(s),a=un(s),o=IA(a.x),l=FA(a.x),h=DA(a.x),u=OA(a.x),d=DA(a.y),c=OA(a.y),p=se(n.x.add(h),n.y.add(d)).sub(.5).mul(t.xy),m=se(n.x.add(u),n.y.add(d)).sub(.5).mul(t.xy),g=se(n.x.add(h),n.y.add(c)).sub(.5).mul(t.xy),f=se(n.x.add(u),n.y.add(c)).sub(.5).mul(t.xy),y=IA(a.y).mul(wi(o.mul(e.sample(p).level(i)),l.mul(e.sample(m).level(i)))),x=FA(a.y).mul(wi(o.mul(e.sample(g).level(i)),l.mul(e.sample(f).level(i))));return y.add(x)},Eb=k(([e,t])=>{let i=se(e.size(A(t))),r=se(e.size(A(t.add(1)))),s=_s(1,i),n=_s(1,r),a=BA(e,Te(s,i),qn(t)),o=BA(e,Te(n,r),Sf(t));return un(t).mix(a,o)}),Fz=k(([e,t])=>Eb(e,t.mul(Ov(e)))),UA=k(([e,t,i,r,s])=>{let n=L(Cv(t.negate(),ls(e),_s(1,r))),a=L(Xn(s[0].xyz),Xn(s[1].xyz),Xn(s[2].xyz));return ls(n).mul(i.mul(a))}).setLayout({name:"getVolumeTransmissionRay",type:"vec3",inputs:[{name:"n",type:"vec3"},{name:"v",type:"vec3"},{name:"thickness",type:"float"},{name:"ior",type:"float"},{name:"modelMatrix",type:"mat4"}]}),Dz=k(([e,t])=>e.mul(cn(t.mul(2).sub(2),0,1))).setLayout({name:"applyIorToRoughness",type:"float",inputs:[{name:"roughness",type:"float"},{name:"ior",type:"float"}]}),Oz=pb(),Bz=mA(),VA=k(([e,t,i],{material:r})=>Eb((r.side===1?Oz:Bz).sample(e),Hn(Lh.x).mul(Dz(t,i)))),zA=k(([e,t,i])=>(Se(i.notEqual(0),()=>pv(wf(t).negate().div(i).negate().mul(e))),L(1))).setLayout({name:"volumeAttenuation",type:"vec3",inputs:[{name:"transmissionDistance",type:"float"},{name:"attenuationColor",type:"vec3"},{name:"attenuationDistance",type:"float"}]}),Uz=k(([e,t,i,r,s,n,a,o,l,h,u,d,c,p,m])=>{let g,f;if(m){g=Te().toVar(),f=L().toVar();let _=u.sub(1).mul(m.mul(.025)),T=L(u.sub(_),u,u.add(_));bt({start:0,end:3},({i:w})=>{let M=T.element(w),S=UA(e,t,d,M,o),R=a.add(S),I=h.mul(l.mul(Te(R,1))),B=se(I.xy.div(I.w)).toVar();B.addAssign(1),B.divAssign(2),B.assign(se(B.x,B.y.oneMinus()));let O=VA(B,i,M);g.element(w).assign(O.element(w)),g.a.addAssign(O.a),f.element(w).assign(r.element(w).mul(zA(Xn(S),c,p).element(w)))}),g.a.divAssign(3)}else{let _=UA(e,t,d,u,o),T=a.add(_),w=h.mul(l.mul(Te(T,1))),M=se(w.xy.div(w.w)).toVar();M.addAssign(1),M.divAssign(2),M.assign(se(M.x,M.y.oneMinus())),g=VA(M,i,u),f=r.mul(zA(Xn(_),c,p))}let y=f.rgb.mul(g.rgb),x=L(NA({dotNV:e.dot(t).clamp(),specularColor:s,specularF90:n,roughness:i})),b=f.r.add(f.g,f.b).div(3);return Te(x.oneMinus().mul(y),g.a.oneMinus().mul(b).oneMinus())}),Vz=tr(3.2404542,-.969266,.0556434,-1.5371385,1.8760108,-.2040259,-.4985314,.041556,1.0572252),zz=e=>{let t=e.sqrt();return L(1).add(t).div(L(1).sub(t))},GA=(e,t)=>e.sub(t).div(e.add(t)).pow2(),Gz=(e,t)=>{let i=e.mul(2*Math.PI*1e-9),r=L(54856e-17,44201e-17,52481e-17),s=L(1681e3,1795300,2208400),n=L(43278e5,93046e5,66121e5),a=C(9747e-17*Math.sqrt(2*Math.PI*45282e5)).mul(i.mul(2239900).add(t.x).cos()).mul(i.pow2().mul(-45282e5).exp()),o=r.mul(n.mul(2*Math.PI).sqrt()).mul(s.mul(i).add(t).cos()).mul(i.pow2().negate().mul(n).exp());return o=L(o.x.add(a),o.y,o.z).div(10685e-11),Vz.mul(o)},jA=k(({outsideIOR:e,eta2:t,cosTheta1:i,thinFilmThickness:r,baseF0:s})=>{let n=Ze(e,t,pn(0,.03,r)),a=e.div(n).pow2().mul(i.pow2().oneMinus()).oneMinus();Se(a.lessThan(0),()=>L(1));let o=a.sqrt(),l=fd({f0:GA(n,e),f90:1,dotVH:i}),h=l.oneMinus(),u=n.lessThan(e).select(Math.PI,0),d=C(Math.PI).sub(u),c=zz(s.clamp(0,.9999)),p=fd({f0:GA(c,n.toVec3()),f90:1,dotVH:o}),m=L(c.x.lessThan(n).select(Math.PI,0),c.y.lessThan(n).select(Math.PI,0),c.z.lessThan(n).select(Math.PI,0)),g=n.mul(r,o,2),f=L(d).add(m),y=l.mul(p).clamp(1e-5,.9999),x=y.sqrt(),b=h.pow2().mul(p).div(L(1).sub(y)),_=l.add(b).toVar(),T=b.sub(h).toVar();return bt({start:1,end:2,condition:"<=",name:"m"},({m:w})=>{T.mulAssign(x);let M=Gz(C(w).mul(g),C(w).mul(f)).mul(2);_.addAssign(T.mul(M))}),_.max(L(0))}).setLayout({name:"evalIridescence",type:"vec3",inputs:[{name:"outsideIOR",type:"float"},{name:"eta2",type:"float"},{name:"cosTheta1",type:"float"},{name:"thinFilmThickness",type:"float"},{name:"baseF0",type:"vec3"}]}),yp=k(({normal:e,viewDir:t,roughness:i})=>{let r=e.dot(t).saturate(),s=i.mul(i),n=i.add(.1).reciprocal(),a=C(-1.9362).add(i.mul(1.0678)).add(s.mul(.4573)).sub(n.mul(.8469)),o=C(-.6014).add(i.mul(.5538)).sub(s.mul(.467)).sub(n.mul(.1255));return a.mul(r).add(o).exp().saturate()}),xp=L(.04),Qf=C(1),$A=class extends Kf{constructor(e=!1,t=!1,i=!1,r=!1,s=!1,n=!1){super(),this.clearcoat=e,this.sheen=t,this.iridescence=i,this.anisotropy=r,this.transmission=s,this.dispersion=n,this.clearcoatRadiance=null,this.clearcoatSpecularDirect=null,this.clearcoatSpecularIndirect=null,this.sheenSpecularDirect=null,this.sheenSpecularIndirect=null,this.iridescenceFresnel=null,this.iridescenceF0=null,this.iridescenceF0Dielectric=null,this.iridescenceF0Metallic=null}start(e){if(this.clearcoat===!0&&(this.clearcoatRadiance=L().toVar("clearcoatRadiance"),this.clearcoatSpecularDirect=L().toVar("clearcoatSpecularDirect"),this.clearcoatSpecularIndirect=L().toVar("clearcoatSpecularIndirect")),this.sheen===!0&&(this.sheenSpecularDirect=L().toVar("sheenSpecularDirect"),this.sheenSpecularIndirect=L().toVar("sheenSpecularIndirect")),this.iridescence===!0){let t=nt.dot(Lt).clamp(),i=jA({outsideIOR:C(1),eta2:gf,cosTheta1:t,thinFilmThickness:ff,baseF0:Jo}),r=jA({outsideIOR:C(1),eta2:gf,cosTheta1:t,thinFilmThickness:ff,baseF0:vt.rgb});this.iridescenceFresnel=Ze(i,r,Ha),this.iridescenceF0Dielectric=Sb({f:i,f90:1,dotVH:t}),this.iridescenceF0Metallic=Sb({f:r,f90:1,dotVH:t}),this.iridescenceF0=Ze(this.iridescenceF0Dielectric,this.iridescenceF0Metallic,Ha)}if(this.transmission===!0){let t=Zn,i=XR.sub(Zn).normalize(),r=al,s=e.context;s.backdrop=Uz(r,i,Wn,Mh,Rh,Eh,t,Ws,js,Za,hp,ov,hv,lv,this.dispersion?uv:null),s.backdropAlpha=bf,vt.a.mulAssign(Ze(1,s.backdrop.a,bf))}super.start(e)}computeMultiscattering(e,t,i,r,s=null){let n=fp({roughness:Wn,dotNV:nt.dot(Lt).clamp()}),a=s?mf.mix(r,s):r,o=a.mul(n.x).add(i.mul(n.y)),l=n.x.add(n.y).oneMinus(),h=a.add(a.oneMinus().mul(.047619)),u=o.mul(h).div(l.mul(h).oneMinus());e.addAssign(o),t.addAssign(u.mul(l))}direct({lightDirection:e,lightColor:t,reflectedLight:i}){let r=nt.dot(e).clamp().mul(t).toVar();if(this.sheen===!0){this.sheenSpecularDirect.addAssign(r.mul(kz({lightDirection:e})));let s=yp({normal:nt,viewDir:Lt,roughness:Ko}),n=yp({normal:nt,viewDir:e,roughness:Ko}),a=bs.r.max(bs.g).max(bs.b).mul(s.max(n)).oneMinus();r.mulAssign(a)}if(this.clearcoat===!0){let s=ol.dot(e).clamp().mul(t);this.clearcoatSpecularDirect.addAssign(s.mul(wb({lightDirection:e,f0:xp,f90:Qf,roughness:nd,normalView:ol})))}i.directDiffuse.addAssign(r.mul(Fh({diffuseColor:Mh}))),i.directSpecular.addAssign(r.mul(Nz({lightDirection:e,f0:Rh,f90:1,roughness:Wn,f:this.iridescenceFresnel,USE_IRIDESCENCE:this.iridescence,USE_ANISOTROPY:this.anisotropy})))}directRectArea({lightColor:e,lightPosition:t,halfWidth:i,halfHeight:r,reflectedLight:s,ltc_1:n,ltc_2:a}){let o=t.add(i).sub(r),l=t.sub(i).sub(r),h=t.sub(i).add(r),u=t.add(i).add(r),d=nt,c=Lt,p=yi.toVar(),m=LA({N:d,V:c,roughness:Wn}),g=n.sample(m).toVar(),f=a.sample(m).toVar(),y=tr(L(g.x,0,g.y),L(0,1,0),L(g.z,0,g.w)).toVar(),x=Rh.mul(f.x).add(Eh.sub(Rh).mul(f.y)).toVar();if(s.directSpecular.addAssign(e.mul(x).mul(Mb({N:d,V:c,P:p,mInv:y,p0:o,p1:l,p2:h,p3
27:u}))),s.directDiffuse.addAssign(e.mul(Mh).mul(Mb({N:d,V:c,P:p,mInv:tr(1,0,0,0,1,0,0,0,1),p0:o,p1:l,p2:h,p3:u}))),this.clearcoat===!0){let b=ol,_=LA({N:b,V:c,roughness:nd}),T=n.sample(_),w=a.sample(_),M=tr(L(T.x,0,T.y),L(0,1,0),L(T.z,0,T.w)),S=xp.mul(w.x).add(Qf.sub(xp).mul(w.y));this.clearcoatSpecularDirect.addAssign(e.mul(S).mul(Mb({N:b,V:c,P:p,mInv:M,p0:o,p1:l,p2:h,p3:u})))}}indirect(e){this.indirectDiffuse(e),this.indirectSpecular(e),this.ambientOcclusion(e)}indirectDiffuse(e){let{irradiance:t,reflectedLight:i}=e.context,r=t.mul(Fh({diffuseColor:Mh})).toVar();if(this.sheen===!0){let s=yp({normal:nt,viewDir:Lt,roughness:Ko}),n=bs.r.max(bs.g).max(bs.b).mul(s).oneMinus();r.mulAssign(n)}i.indirectDiffuse.addAssign(r)}indirectSpecular(e){let{radiance:t,iblIrradiance:i,reflectedLight:r}=e.context;if(this.sheen===!0&&this.sheenSpecularIndirect.addAssign(i.mul(bs,yp({normal:nt,viewDir:Lt,roughness:Ko}))),this.clearcoat===!0){let g=NA({dotNV:ol.dot(Lt).clamp(),specularColor:xp,specularF90:Qf,roughness:nd});this.clearcoatSpecularIndirect.addAssign(this.clearcoatRadiance.mul(g))}let s=L().toVar("singleScatteringDielectric"),n=L().toVar("multiScatteringDielectric"),a=L().toVar("singleScatteringMetallic"),o=L().toVar("multiScatteringMetallic");this.computeMultiscattering(s,n,Eh,Jo,this.iridescenceF0Dielectric),this.computeMultiscattering(a,o,Eh,vt.rgb,this.iridescenceF0Metallic);let l=Ze(s,a,Ha),h=Ze(n,o,Ha),u=s.add(n),d=Mh.mul(u.oneMinus()),c=i.mul(1/Math.PI),p=t.mul(l).add(h.mul(c)).toVar(),m=d.mul(c).toVar();if(this.sheen===!0){let g=yp({normal:nt,viewDir:Lt,roughness:Ko}),f=bs.r.max(bs.g).max(bs.b).mul(g).oneMinus();p.mulAssign(f),m.mulAssign(f)}r.indirectSpecular.addAssign(p),r.indirectDiffuse.addAssign(m)}ambientOcclusion(e){let{ambientOcclusion:t,reflectedLight:i}=e.context,r=nt.dot(Lt).clamp().add(t),s=Wn.mul(-16).oneMinus().negate().exp2(),n=t.sub(r.pow(s).oneMinus()).clamp();this.clearcoat===!0&&this.clearcoatSpecularIndirect.mulAssign(t),this.sheen===!0&&this.sheenSpecularIndirect.mulAssign(t),i.indirectDiffuse.mulAssign(t),i.indirectSpecular.mulAssign(n)}finish({context:e}){let{outgoingLight:t}=e;if(this.clearcoat===!0){let i=fd({dotVH:ol.dot(Lt).clamp(),f0:xp,f90:Qf}),r=t.mul(pf.mul(i).oneMinus()).add(this.clearcoatSpecularDirect.add(this.clearcoatSpecularIndirect).mul(pf));t.assign(r)}if(this.sheen===!0){let i=t.add(this.sheenSpecularDirect,this.sheenSpecularIndirect.mul(1/Math.PI));t.assign(i)}}},WA=C(1),Ab=C(-2),e0=C(.8),Nb=C(-1),t0=C(.4),Lb=C(2),i0=C(.305),Pb=C(3),HA=C(.21),jz=C(4),qA=C(4),$z=C(16),Wz=k(([e])=>{let t=L(kt(e)).toVar(),i=C(-1).toVar();return Se(t.x.greaterThan(t.z),()=>{Se(t.x.greaterThan(t.y),()=>{i.assign(wr(e.x.greaterThan(0),0,3))}).Else(()=>{i.assign(wr(e.y.greaterThan(0),1,4))})}).Else(()=>{Se(t.z.greaterThan(t.y),()=>{i.assign(wr(e.z.greaterThan(0),2,5))}).Else(()=>{i.assign(wr(e.y.greaterThan(0),1,4))})}),i}).setLayout({name:"getFace",type:"float",inputs:[{name:"direction",type:"vec3"}]}),Hz=k(([e,t])=>{let i=se().toVar();return Se(t.equal(0),()=>{i.assign(se(e.z,e.y).div(kt(e.x)))}).ElseIf(t.equal(1),()=>{i.assign(se(e.x.negate(),e.z.negate()).div(kt(e.y)))}).ElseIf(t.equal(2),()=>{i.assign(se(e.x.negate(),e.y).div(kt(e.z)))}).ElseIf(t.equal(3),()=>{i.assign(se(e.z.negate(),e.y).div(kt(e.x)))}).ElseIf(t.equal(4),()=>{i.assign(se(e.x.negate(),e.z).div(kt(e.y)))}).Else(()=>{i.assign(se(e.x,e.y).div(kt(e.z)))}),Pe(.5,i.add(1))}).setLayout({name:"getUV",type:"vec2",inputs:[{name:"direction",type:"vec3"},{name:"face",type:"float"}]}),qz=k(([e])=>{let t=C(0).toVar();return Se(e.greaterThanEqual(e0),()=>{t.assign(WA.sub(e).mul(Nb.sub(Ab)).div(WA.sub(e0)).add(Ab))}).ElseIf(e.greaterThanEqual(t0),()=>{t.assign(e0.sub(e).mul(Lb.sub(Nb)).div(e0.sub(t0)).add(Nb))}).ElseIf(e.greaterThanEqual(i0),()=>{t.assign(t0.sub(e).mul(Pb.sub(Lb)).div(t0.sub(i0)).add(Lb))}).ElseIf(e.greaterThanEqual(HA),()=>{t.assign(i0.sub(e).mul(jz.sub(Pb)).div(i0.sub(HA)).add(Pb))}).Else(()=>{t.assign(C(-2).mul(Hn(Pe(1.16,e))))}),t}).setLayout({name:"roughnessToMip",type:"float",inputs:[{name:"roughness",type:"float"}]}),XA=k(([e,t])=>{let i=e.toVar();i.assign(Pe(2,i).sub(1));let r=L(i,1).toVar();return Se(t.equal(0),()=>{r.assign(r.zyx)}).ElseIf(t.equal(1),()=>{r.assign(r.xzy),r.xz.mulAssign(-1)}).ElseIf(t.equal(2),()=>{r.x.mulAssign(-1)}
vendor: 4,182 bytes, line 27
27).ElseIf(t.equal(3),()=>{r.assign(r.zyx),r.xz.mulAssign(-1)}).ElseIf(t.equal(4),()=>{r.assign(r.xzy),r.xy.mulAssign(-1)}).ElseIf(t.equal(5),()=>{r.z.mulAssign(-1)}),r}).setLayout({name:"getDirection",type:"vec3",inputs:[{name:"uv",type:"vec2"},{name:"face",type:"float"}]}),YA=k(([e,t,i,r,s,n])=>{let a=C(i),o=L(t),l=cn(qz(a),Ab,n),h=un(l),u=qn(l),d=L(vp(e,o,u,r,s,n)).toVar();return Se(h.notEqual(0),()=>{let c=L(vp(e,o,u.add(1),r,s,n)).toVar();d.assign(Ze(d,c,h))}),d}),vp=k(([e,t,i,r,s,n])=>{let a=C(i).toVar(),o=L(t),l=C(Wz(o)).toVar(),h=C(ti(qA.sub(a),0)).toVar();a.assign(ti(a,qA));let u=C(od(a)).toVar(),d=se(Hz(o,l).mul(u.sub(2)).add(1)).toVar();return Se(l.greaterThan(2),()=>{d.y.addAssign(u),l.subAssign(3)}),d.x.addAssign(l.mul(u)),d.x.addAssign(h.mul(Pe(3,$z))),d.y.addAssign(Pe(4,od(n).sub(u))),d.x.mulAssign(r),d.y.mulAssign(s),e.sample(d).grad(se(),se())}),kb=k(({envMap:e,mipInt:t,outputDirection:i,theta:r,axis:s,CUBEUV_TEXEL_WIDTH:n,CUBEUV_TEXEL_HEIGHT:a,CUBEUV_MAX_MIP:o})=>{let l=dn(r);return vp(e,i.mul(l).add(s.cross(i).mul(qr(r))).add(s.mul(s.dot(i).mul(l.oneMinus()))),t,n,a,o)}),KA=k(({n:e,latitudinal:t,poleAxis:i,outputDirection:r,weights:s,samples:n,dTheta:a,mipInt:o,envMap:l,CUBEUV_TEXEL_WIDTH:h,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:d})=>{let c=L(wr(t,i,qa(i,r))).toVar();Se(c.equal(L(0)),()=>{c.assign(L(r.z,0,r.x.negate()))}),c.assign(ls(c));let p=L().toVar();return p.addAssign(s.element(0).mul(kb({theta:0,axis:c,outputDirection:r,mipInt:o,envMap:l,CUBEUV_TEXEL_WIDTH:h,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:d}))),bt({start:A(1),end:e},({i:m})=>{Se(m.greaterThanEqual(n),()=>{uA()});let g=C(a.mul(C(m))).toVar();p.addAssign(s.element(m).mul(kb({theta:g.mul(-1),axis:c,outputDirection:r,mipInt:o,envMap:l,CUBEUV_TEXEL_WIDTH:h,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:d}))),p.addAssign(s.element(m).mul(kb({theta:g,axis:c,outputDirection:r,mipInt:o,envMap:l,CUBEUV_TEXEL_WIDTH:h,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:d})))}),Te(p,1)}),Xz=k(([e])=>{let t=K(e).toVar();return t.assign(t.shiftLeft(K(16)).bitOr(t.shiftRight(K(16)))),t.assign(t.bitAnd(K(1431655765)).shiftLeft(K(1)).bitOr(t.bitAnd(K(2863311530)).shiftRight(K(1)))),t.assign(t.bitAnd(K(858993459)).shiftLeft(K(2)).bitOr(t.bitAnd(K(3435973836)).shiftRight(K(2)))),t.assign(t.bitAnd(K(252645135)).shiftLeft(K(4)).bitOr(t.bitAnd(K(4042322160)).shiftRight(K(4)))),t.assign(t.bitAnd(K(16711935)).shiftLeft(K(8)).bitOr(t.bitAnd(K(4278255360)).shiftRight(K(8)))),C(t).mul(23283064365386963e-26)}),Yz=k(([e,t])=>se(C(e).div(C(t)),Xz(e))),Kz=k(([e,t,i])=>{let r=i.mul(i).toConst(),s=L(1,0,0).toConst(),n=qa(t,s).toConst(),a=Hr(e.x).toConst(),o=Pe(2,3.14159265359).mul(e.y).toConst(),l=a.mul(dn(o)).toConst(),h=a.mul(qr(o)).toVar(),u=Pe(.5,t.z.add(1)).toConst();h.assign(u.oneMinus().mul(Hr(l.mul(l).oneMinus())).add(u.mul(h)));let d=s.mul(l).add(n.mul(h)).add(t.mul(Hr(ti(0,l.mul(l).add(h.mul(h)).oneMinus()))));return ls(L(r.mul(d.x),r.mul(d.y),ti(0,d.z)))}),ZA=k(({roughness:e,mipInt:t,envMap:i,N_immutable:r,GGX_SAMPLES:s,CUBEUV_TEXEL_WIDTH:n,CUBEUV_TEXEL_HEIGHT:a,CUBEUV_MAX_MIP:o})=>{let l=L(r).toVar(),h=L(0).toVar(),u=C(0).toVar();return Se(e.lessThan(.001),()=>{h.assign(vp(i,l,t,n,a,o))}).Else(()=>{let d=ls(qa(wr(kt(l.z).lessThan(.999),L(0,0,1),L(1,0,0)),l)).toVar(),c=qa(l,d).toVar();bt({start:K(0),end:s},({i:p})=>{let m=Kz(Yz(p,s),L(0,0,1),e),g=ls(d.mul(m.x).add(c.mul(m.y)).add(l.mul(m.z))),f=ls(g.mul(zs(l,g).mul(2)).sub(l)),y=ti(zs(l,f),0);Se(y.greaterThan(0),()=>{let x=vp(i,f,t,n,a,o);h.addAssign(x.mul(y)),u.addAssign(y)})}),Se(u.greaterThan(0),()=>{h.assign(h.div(u))})}),Te(h,1)}),ul=4,JA=[.125,.215,.35,.446,.526,.582],Dh=20,Zz=512,bp=new rf(-1,1,1,-1,0,1),Jz=new os(90,1),QA=new Ke,Ib=null,Fb=0,Db=0,Qz=new F,r0=new WeakMap,e8=[3,1,5,0,4,2],Ob=XA(Mt(),Ya("faceIndex")).normalize(),s0=L(Ob.x,Ob.y,Ob.z),t8=class{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._blurMaterial=null,this._ggxMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._backgroundBox=null}get _hasInitialized(){return this._renderer.hasInitialized()}fromScene(e,t=0,i=.1,r=100,s={}
27){let{size:n=256,position:a=Qz,renderTarget:o=null}=s;if(this._setSize(n),this._hasInitialized===!1){de('PMREMGenerator: ".fromScene()" called before the backend is initialized. Try using "await renderer.init()" instead.');let h=o||this._allocateTarget();return s.renderTarget=h,this.fromSceneAsync(e,t,i,r,s),h}Ib=this._renderer.getRenderTarget(),Fb=this._renderer.getActiveCubeFace(),Db=this._renderer.getActiveMipmapLevel();let l=o||this._allocateTarget();return l.depthBuffer=!0,this._init(l),this._sceneToCubeUV(e,i,r,l,a),t>0&&this._blur(l,0,0,t),this._applyPMREM(l),this._cleanup(l),l}async fromSceneAsync(e,t=0,i=.1,r=100,s={}){return ut('PMREMGenerator: ".fromSceneAsync()" is deprecated. Use "await renderer.init()" instead.'),await this._renderer.init(),this.fromScene(e,t,i,r,s)}fromEquirectangular(e,t=null){if(this._hasInitialized===!1){de('PMREMGenerator: .fromEquirectangular() called before the backend is initialized. Try using "await renderer.init()" instead.'),this._setSizeFromTexture(e);let i=t||this._allocateTarget();return this.fromEquirectangularAsync(e,i),i}return this._fromTexture(e,t)}async fromEquirectangularAsync(e,t=null){return ut('PMREMGenerator: ".fromEquirectangularAsync()" is deprecated. Use "await renderer.init()" instead.'),await this._renderer.init(),this._fromTexture(e,t)}fromCubemap(e,t=null){if(this._hasInitialized===!1){de("PMREMGenerator: .fromCubemap() called before the backend is initialized. Try using .fromCubemapAsync() instead."),this._setSizeFromTexture(e);let i=t||this._allocateTarget();return this.fromCubemapAsync(e,t),i}return this._fromTexture(e,t)}async fromCubemapAsync(e,t=null){return ut('PMREMGenerator: ".fromCubemapAsync()" is deprecated. Use "await renderer.init()" instead.'),await this._renderer.init(),this._fromTexture(e,t)}async compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=tN(),await this._compileMaterial(this._cubemapMaterial))}async compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=iN(),await this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._backgroundBox!==null&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSizeFromTexture(e){e.mapping===301||e.mapping===302?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4)}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=2**this._lodMax}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._ggxMaterial!==null&&this._ggxMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodMeshes.length;e++)this._lodMeshes[e].geometry.dispose()}_cleanup(e){this._renderer.setRenderTarget(Ib,Fb,Db),e.scissorTest=!1,this._setViewport(e,0,0,e.width,e.height)}_fromTexture(e,t){this._setSizeFromTexture(e),Ib=this._renderer.getRenderTarget(),Fb=this._renderer.getActiveCubeFace(),Db=this._renderer.getActiveMipmapLevel();let i=t||this._allocateTarget();return this._init(i),this._textureToCubeUV(e,i),this._applyPMREM(i),this._cleanup(i),i}_allocateTarget(){return eN(3*Math.max(this._cubeSize,112),4*this._cubeSize)}_init(e){if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e.width||this._pingPongRenderTarget.height!==e.height){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=eN(e.width,e.height);let{_lodMax:t}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=i8(t)),this._blurMaterial=r8(t,e.width,e.height),this._ggxMaterial=s8(t,e.width,e.height)}}async _compileMaterial(e){let t=new xt(new $r,e);await this._renderer.compile(t,bp)}_sceneToCubeUV(e,t,i,r,s){let n=Jz;n.near=t,n.far=i;let a=[1,1,1,1,-1,1],o=[1,-1,1,-1,1,-1],l=this._renderer,h=l.autoClear;l.getClearColor(QA),l.autoClear=!1,this._backgroundBox===null&&(this._backgroundBox=new xt(new kM,new ji({name:"PMREM.Backgroun
27d",side:1,depthWrite:!1,depthTest:!1})));let u=this._backgroundBox,d=u.material,c=!1,p=e.background;p?p.isColor&&(d.color.copy(p),e.background=null,c=!0):(d.color.copy(QA),c=!0),l.setRenderTarget(r),l.clear(),c&&l.render(u,n);for(let m=0;m<6;m++){let g=m%3;g===0?(n.up.set(0,a[m],0),n.position.set(s.x,s.y,s.z),n.lookAt(s.x+o[m],s.y,s.z)):g===1?(n.up.set(0,0,a[m]),n.position.set(s.x,s.y,s.z),n.lookAt(s.x,s.y+o[m],s.z)):(n.up.set(0,a[m],0),n.position.set(s.x,s.y,s.z),n.lookAt(s.x,s.y,s.z+o[m]));let f=this._cubeSize;this._setViewport(r,g*f,m>2?f:0,f,f),l.render(e,n)}l.autoClear=h,e.background=p}_textureToCubeUV(e,t){let i=this._renderer,r=e.mapping===301||e.mapping===302;r?this._cubemapMaterial===null&&(this._cubemapMaterial=tN(e)):this._equirectMaterial===null&&(this._equirectMaterial=iN(e));let s=r?this._cubemapMaterial:this._equirectMaterial;s.fragmentNode.value=e;let n=this._lodMeshes[0];n.material=s;let a=this._cubeSize;this._setViewport(t,0,0,3*a,2*a),i.setRenderTarget(t),i.render(n,bp)}_applyPMREM(e){let t=this._renderer,i=t.autoClear;t.autoClear=!1;let r=this._lodMeshes.length;for(let s=1;s<r;s++)this._applyGGXFilter(e,s-1,s);t.autoClear=i}_applyGGXFilter(e,t,i){let r=this._renderer,s=this._pingPongRenderTarget,n=this._ggxMaterial,a=this._lodMeshes[i];a.material=n;let o=r0.get(n),l=i/(this._lodMeshes.length-1),h=t/(this._lodMeshes.length-1),u=Math.sqrt(l*l-h*h)*(0+l*1.25),{_lodMax:d}=this,c=this._sizeLods[i],p=3*c*(i>d-ul?i-d+ul:0),m=4*(this._cubeSize-c);e.texture.frame=(e.texture.frame||0)+1,o.envMap.value=e.texture,o.roughness.value=u,o.mipInt.value=d-t,this._setViewport(s,p,m,3*c,2*c),r.setRenderTarget(s),r.render(a,bp),s.texture.frame=(s.texture.frame||0)+1,o.envMap.value=s.texture,o.roughness.value=0,o.mipInt.value=d-i,this._setViewport(e,p,m,3*c,2*c),r.setRenderTarget(e),r.render(a,bp)}_blur(e,t,i,r,s){let n=this._pingPongRenderTarget;this._halfBlur(e,n,t,i,r,"latitudinal",s),this._halfBlur(n,e,i,i,r,"longitudinal",s)}_halfBlur(e,t,i,r,s,n,a){let o=this._renderer,l=this._blurMaterial;n!=="latitudinal"&&n!=="longitudinal"&&re("blur direction must be either latitudinal or longitudinal!");let h=this._lodMeshes[r];h.material=l;let u=r0.get(l),d=this._sizeLods[i]-1,c=isFinite(s)?Math.PI/(2*d):2*Math.PI/(2*Dh-1),p=s/c,m=isFinite(s)?1+Math.floor(3*p):Dh;m>Dh&&de(`sigmaRadians, ${s}, is too large and will clip, as it requested ${m} samples when the maximum is set to ${Dh}`);let g=[],f=0;for(let T=0;T<Dh;++T){let w=T/p,M=Math.exp(-w*w/2);g.push(M),T===0?f+=M:T<m&&(f+=2*M)}for(let T=0;T<g.length;T++)g[T]=g[T]/f;e.texture.frame=(e.texture.frame||0)+1,u.envMap.value=e.texture,u.samples.value=m,u.weights.array=g,u.latitudinal.value=+(n==="latitudinal"),a&&(u.poleAxis.value=a);let{_lodMax:y}=this;u.dTheta.value=c,u.mipInt.value=y-i;let x=this._sizeLods[r],b=3*x*(r>y-ul?r-y+ul:0),_=4*(this._cubeSize-x);this._setViewport(t,b,_,3*x,2*x),o.setRenderTarget(t),o.render(h,bp)}_setViewport(e,t,i,r,s){this._renderer.isWebGLRenderer?(e.viewport.set(t,e.height-s-i,r,s),e.scissor.set(t,e.height-s-i,r,s)):(e.viewport.set(t,i,r,s),e.scissor.set(t,i,r,s))}};function i8(e){let t=[],i=[],r=[],s=e,n=e-ul+1+JA.length;for(let a=0;a<n;a++){let o=2**s;t.push(o);let l=1/o;a>e-ul?l=JA[a-e+ul-1]:a===0&&(l=0),i.push(l);let h=1/(o-2),u=-h,d=1+h,c=[u,u,d,u,d,d,u,u,d,d,u,d],p=new Float32Array(108),m=new Float32Array(72),g=new Float32Array(36);for(let y=0;y<6;y++){let x=y%3*2/3-1,b=y>2?0:-1,_=[x,b,0,x+2/3,b,0,x+2/3,b+1,0,x,b,0,x+2/3,b+1,0,x,b+1,0],T=e8[y];p.set(_,18*T),m.set(c,12*T);let w=[T,T,T,T,T,T];g.set(w,6*T)}let f=new $r;f.setAttribute("position",new jr(p,3)),f.setAttribute("uv",new jr(m,2)),f.setAttribute("faceIndex",new jr(g,1)),r.push(new xt(f,null)),s>ul&&s--}return{lodMeshes:r,sizeLods:t,sigmas:i}}function eN(e,t){let i=new zr(e,t,{magFilter:mi,minFilter:mi,generateMipmaps:!1,type:as,format:Br,colorSpace:Pc});return i.texture.mapping=306,i.texture.name="PMREM.cubeUv",i.texture.isPMREMTexture=!0,i.scissorTest=!0,i}function n0(e){let t=new Ot;return t.depthTest=!1,t.depthWrite=!1,t.blending=0,t.name=`PMREM_${e}`,t}function r8(e,t,i){let r=Sr(Array(Dh).fill(0)),s=be(new F(0,1,0)),n=be(0),a=C(Dh),o=be(0),l={n:a,latitudinal:o,weights:r,poleAxis:s,outputDirection:s0,dTheta:n,samples:be(1),envMap:st(),mipInt:be(0),CUBEUV_TEXEL_WIDTH:C(1/t),CUBEUV_TEXEL_HEIGHT:C(1/i),CUBEUV_MAX_MIP:C(e)},h=n0("blur");return h.fragmentNode=KA({...l,latitudinal:o.equal(1)}),r0.set(h,l),h}function s8(e,t,i){let r={envMap:st(),roughness:be(0),mipInt:be(0),CUBEUV_TEXEL_WIDTH:C(1/t),CUBEUV_TEXEL_HEIGHT:C(1/i),CUBEUV_MAX_MIP:C(e)},s=n0("ggx");return s.fragmentNode=ZA({...r,N_immutable:s0,GGX_SAMPLES:K(Zz)}),r0.set(s,r),s}function tN(e){let t=n0("cubemap");return t.fragmentNode=Yr(e,s0),t}function iN(e){let t=n0("equirect");return t.fragmentNode=st(e,bb(s0),0),t}var rN=new WeakMap;function n8(e){let t=Math.log2(e)-2,i=1/e;return{texelWidth:1/(3*Math.max(2**t,112)),texelHeight:i,maxMip:t}}function a8(e,t,i){let r=o8(t),s=r.get(e);if((s===void 0?-1:s.pmremVersion)!==e.pmremVersion){let n=e.image;if(e.isCubeTexture)if(h8(n))s=i.fromCubemap(e,s);else return null;else if(u8(n))s=i.fromEquirectangular(e,s);else return null;s.pmremVersion=e.pmremVersion,r.set(e,s)}return s.texture}function o8(e){let t=rN.get(e);return t===void 0&&(t=new WeakMap,rN.set(e,t)),t}var l8=class extends ei{static get type(){return"PMREMNode"}constructor(e,t=null,i=null){super("vec3"),this._value=e,this._pmrem=null,this.uvNode=t,this.levelNode=i,this._generator=null;let r=new Li;r.isRenderTargetTexture=!0,this._texture=st(r),this._width=be(0),this._height=be(0),this._maxMip=be(0),this.updateBeforeType=Re.RENDER}set value(e){this._value=e,this._pmrem=null}get value(){return this._value}updateFromTexture(e){let t=n8(e.image.height);this._texture.value=e,this._width.value=t.texelWidth,this._height.value=t.texelHeight,this._maxMip.value=t.maxMip}updateBefore(e){let t=this._pmrem,i=t?t.pmremVersion:-1,r=this._value;i!==r.pmremVersion&&(t=r.isPMREMTexture===!0?r:a8(r,e.renderer,this._generator),t!==null&&(this._pmrem=t,this.updateFromTexture(t)))}setup(e){this._generator===null&&(this._generator=new t8(e.renderer)),this.updateBefore(e);let t=this.uvNode;t===null&&e.context.getUV&&(t=e.context.getUV(this,e)),t=tb.mul(L(t.x,t.y.negate(),t.z));let i=this.levelNode;return i===null&&e.context.getTextureLevel&&(i=e.context.getTextureLevel(this)),YA(this._texture,t,i,this._width,this._height,this._maxMip)}dispose(){super.dispose(),this._generator!==null&&this._generator.dispose()}};function h8(e){if(e==null)return!1;let t=0;for(let i=0;i<6;i++)e[i]!==void 0&&t++;return t===6}function u8(e){return e==null?!1:e.height>0}var Bb=Fe(l8).setParameterLength(1,3),sN=new WeakMap,d8=class extends md{static get type(){return"EnvironmentNode"}constructor(e=null){super(),this.envNode=e}setup(e){let{material:t}=e,i=this.envNode;if(i.isTextureNode||i.isMaterialReferenceNode){let h=i.isTextureNode?i.value:t[i.property],u=this._getPMREMNodeCache(e.renderer),d=u.get(h);d===void 0&&(d=Bb(h),u.set(h,d)),i=d}let r=t.useAnisotropy===!0||t.anisotropy>0?_E:nt,s=i.context(nN(Wn,r)).mul(Gf),n=i.context(c8(al)).mul(Math.PI).mul(Gf),a=ld(s),o=ld(n);
vendor: 3,660 bytes, line 27
27e.context.radiance.addAssign(a),e.context.iblIrradiance.addAssign(o);let l=e.context.lightingModel.clearcoatRadiance;if(l){let h=ld(i.context(nN(nd,ol)).mul(Gf));l.addAssign(h)}}_getPMREMNodeCache(e){let t=sN.get(e);return t===void 0&&(t=new WeakMap,sN.set(e,t)),t}},nN=(e,t)=>{let i=null;return{getUV:()=>(i===null&&(i=Lt.negate().reflect(t),i=Sv(e).mix(i,t).normalize(),i=i.transformDirection(js)),i),getTextureLevel:()=>e}},c8=e=>({getUV:()=>e,getTextureLevel:()=>C(1)}),p8=new qM,aN=class extends Ot{static get type(){return"MeshStandardNodeMaterial"}constructor(e){super(),this.isMeshStandardNodeMaterial=!0,this.lights=!0,this.emissiveNode=null,this.metalnessNode=null,this.roughnessNode=null,this.setDefaultValues(p8),this.setValues(e)}setupEnvironment(e){let t=super.setupEnvironment(e);return t===null&&e.environmentNode&&(t=e.environmentNode),t?new d8(t):null}setupLightingModel(){return new $A}setupSpecular(){let e=Ze(L(.04),vt.rgb,Ha);Jo.assign(L(.04)),Rh.assign(e),Eh.assign(1)}setupVariants(){let e=this.metalnessNode?C(this.metalnessNode):LE;Ha.assign(e);let t=this.roughnessNode?C(this.roughnessNode):NE;t=Tb({roughness:t}),Wn.assign(t),this.setupSpecular(),Mh.assign(vt.rgb.mul(e.oneMinus()))}copy(e){return this.emissiveNode=e.emissiveNode,this.metalnessNode=e.metalnessNode,this.roughnessNode=e.roughnessNode,super.copy(e)}},m8=new Y4,g8=class extends aN{static get type(){return"MeshPhysicalNodeMaterial"}constructor(e){super(),this.isMeshPhysicalNodeMaterial=!0,this.clearcoatNode=null,this.clearcoatRoughnessNode=null,this.clearcoatNormalNode=null,this.sheenNode=null,this.sheenRoughnessNode=null,this.iridescenceNode=null,this.iridescenceIORNode=null,this.iridescenceThicknessNode=null,this.specularIntensityNode=null,this.specularColorNode=null,this.iorNode=null,this.transmissionNode=null,this.thicknessNode=null,this.attenuationDistanceNode=null,this.attenuationColorNode=null,this.dispersionNode=null,this.anisotropyNode=null,this.setDefaultValues(m8),this.setValues(e)}get useClearcoat(){return this.clearcoat>0||this.clearcoatNode!==null}get useIridescence(){return this.iridescence>0||this.iridescenceNode!==null}get useSheen(){return this.sheen>0||this.sheenNode!==null}get useAnisotropy(){return this.anisotropy>0||this.anisotropyNode!==null}get useTransmission(){return this.transmission>0||this.transmissionNode!==null}get useDispersion(){return this.dispersion>0||this.dispersionNode!==null}setupSpecular(){let e=this.iorNode?C(this.iorNode):WE;hp.assign(e),Jo.assign(hs(wv(hp.sub(1).div(hp.add(1))).mul(AE),L(1)).mul(ub)),Rh.assign(Ze(Jo,vt.rgb,Ha)),Eh.assign(Ze(ub,1,Ha))}setupLightingModel(){return new $A(this.useClearcoat,this.useSheen,this.useIridescence,this.useAnisotropy,this.useTransmission,this.useDispersion)}setupVariants(e){if(super.setupVariants(e),this.useClearcoat){let t=this.clearcoatNode?C(this.clearcoatNode):kE,i=this.clearcoatRoughnessNode?C(this.clearcoatRoughnessNode):IE;pf.assign(t),nd.assign(Tb({roughness:i}))}if(this.useSheen){let t=this.sheenNode?L(this.sheenNode):OE,i=this.sheenRoughnessNode?C(this.sheenRoughnessNode):BE;bs.assign(t),Ko.assign(i)}if(this.useIridescence){let t=this.iridescenceNode?C(this.iridescenceNode):VE,i=this.iridescenceIORNode?C(this.iridescenceIORNode):zE,r=this.iridescenceThicknessNode?C(this.iridescenceThicknessNode):GE;mf.assign(t),gf.assign(i),ff.assign(r)}if(this.useAnisotropy){let t=(this.anisotropyNode?se(this.anisotropyNode):UE).toVar();Zo.assign(t.length()),Se(Zo.equal(0),()=>{t.assign(se(1,0))}).Else(()=>{t.divAssign(se(Zo)),Zo.assign(Zo.saturate())}),yf.assign(Zo.pow2().mix(Wn.pow2(),1)),lp.assign(kh[0].mul(t.x).add(kh[1].mul(t.y))),Ch.assign(kh[
271].mul(t.x).sub(kh[0].mul(t.y)))}if(this.useTransmission){let t=this.transmissionNode?C(this.transmissionNode):jE,i=this.thicknessNode?C(this.thicknessNode):$E,r=this.attenuationDistanceNode?C(this.attenuationDistanceNode):HE,s=this.attenuationColorNode?L(this.attenuationColorNode):qE;if(bf.assign(t),ov.assign(i),lv.assign(r),hv.assign(s),this.useDispersion){let n=this.dispersionNode?C(this.dispersionNode):QE;uv.assign(n)}}}setupClearcoatNormal(){return this.clearcoatNormalNode?L(this.clearcoatNormalNode):FE}setup(e){e.context.setupClearcoatNormal=()=>Nh(this.setupClearcoatNormal(e),"NORMAL","vec3"),super.setup(e)}copy(e){return this.clearcoatNode=e.clearcoatNode,this.clearcoatRoughnessNode=e.clearcoatRoughnessNode,this.clearcoatNormalNode=e.clearcoatNormalNode,this.sheenNode=e.sheenNode,this.sheenRoughnessNode=e.sheenRoughnessNode,this.iridescenceNode=e.iridescenceNode,this.iridescenceIORNode=e.iridescenceIORNode,this.iridescenceThicknessNode=e.iridescenceThicknessNode,this.specularIntensityNode=e.specularIntensityNode,this.specularColorNode=e.specularColorNode,this.iorNode=e.iorNode,this.transmissionNode=e.transmissionNode,this.thicknessNode=e.thicknessNode,this.attenuationDistanceNode=e.attenuationDistanceNode,this.attenuationColorNode=e.attenuationColorNode,this.dispersionNode=e.dispersionNode,this.anisotropyNode=e.anisotropyNode,super.copy(e)}},f8=k(({normal:e,lightDirection:t,builder:i})=>{let r=se(e.dot(t).mul(.5).add(.5),0);if(i.material.gradientMap)return L(Ja("gradientMap","texture").context({getUV:()=>r}).r);{let s=r.fwidth().mul(.5);return Ze(L(.7),L(1),pn(C(.7).sub(s.x),C(.7).add(s.x),r.x))}}),y8=class extends Kf{direct({lightDirection:e,lightColor:t,reflectedLight:i},r){let s=f8({normal:zf,lightDirection:e,builder:r}).mul(t);i.directDiffuse.addAssign(s.mul(Fh({diffuseColor:vt.rgb})))}indirect(e){let{ambientOcclusion:t,irradiance:i,reflectedLight:r}=e.context;r.indirectDiffuse.addAssign(i.mul(Fh({diffuseColor:vt}))),r.indirectDiffuse.mulAssign(t)}},x8=new Z4,v8=class extends Ot{static get type(){return"MeshToonNodeMaterial"}constructor(e){super(),this.isMeshToonNodeMaterial=!0,this.lights=!0,this.setDefaultValues(x8),this.setValues(e)}setupLightingModel(){return new y8}},oN=k(()=>{let e=L(Lt.z,0,Lt.x.negate()).normalize(),t=Lt.cross(e);return se(e.dot(nt),t.dot(nt)).mul(.495).add(.5)}).once(["NORMAL","VERTEX"])().toVar("matcapUV"),b8=new eU,_8=class extends Ot{static get type(){return"MeshMatcapNodeMaterial"}constructor(e){super(),this.isMeshMatcapNodeMaterial=!0,this.setDefaultValues(b8),this.setValues(e)}setupVariants(e){let t=oN,i;i=e.material.matcap?Ja("matcap","texture").context({getUV:()=>t}):L(Ze(.2,.8,t.y)),vt.rgb.mulAssign(i.rgb)}},_p=Fe(class extends ei{static get type(){return"RotateNode"}constructor(e,t){super(),this.positionNode=e,this.rotationNode=t}generateNodeType(e){return this.positionNode.getNodeType(e)}setup(e){let{rotationNode:t,positionNode:i}=this;if(this.getNodeType(e)==="vec2"){let r=t.cos(),s=t.sin();return cf(r,s,s.negate(),r).mul(i)}else{let r=t,s=Yo(Te(1,0,0,0),Te(0,dn(r.x),qr(r.x).negate(),0),Te(0,qr(r.x),dn(r.x),0),Te(0,0,0,1)),n=Yo(Te(dn(r.y),0,qr(r.y),0),Te(0,1,0,0),Te(qr(r.y).negate(),0,dn(r.y),0),Te(0,0,0,1)),a=Yo(Te(dn(r.z),qr(r.z).negate(),0,0),Te(qr(r.z),dn(r.z),0,0),Te(0,0,1,0),Te(0,0,0,1));return s.mul(n).mul(a).mul(Te(i,1)).xyz}}}).setParameterLength(2),T8=new wM,Ub=class extends Ot{static get type(){return"SpriteNodeMaterial"}constructor(e){super(),this.isSpriteNodeMaterial=!0,this._useSizeAttenuation=!0,this.positionNode=null,this.rotationNode=null,this.scaleNode=null,this.transparent=!0,this.setDefaultValues(T8),this.setValues(e)}setupPositionView(e){let{object:t,camera:i}=e,{positionNode:r,rotationNode:s,scaleNode:n,sizeAttenuation:a}=this,o=nl.mul(L(r||0)),l=se(Ws[0].xyz.length(),Ws[1].xyz.length());n!==null&&(l=l.mul(se(n))),i.isPerspectiveCamera&&a===!1&&(l=l.mul(o.z.negate()));let h=pp.xy;if(t.center&&t.center.isVector2===!0){let c=I6("center","vec2",t);h=h.sub(c.sub(.5))}h=h.mul(l);let u=C(s||DE),d=_p(h,u);return Te(o.xy.add(d),o.zw)}copy(e){return this.positionNode=e.positionNode,this.rotationNode=e.rotationNode,this.scaleNode=e.scaleNode,super.copy(e)}get sizeAttenuation(){return this._useSizeAttenuation}set sizeAttenuation(e){this._useSizeAttenuation!==e&&(this._useSizeAttenuation=e,this.needsUpdate=!0)}},w8=new h4,S8=new ge,M8=class extends Ub{static get type(){return"PointsNodeMaterial"}constructor(e){super(),this.sizeNode=null,this.isPointsNodeMaterial=!0,this.setDefaultValues(w8),this.setValues(e)}setupPositionView(){let{positionNode:e}=this;return nl.mul(L(e||ii)).xyz}setupVertexSprite(e){let{material:t,camera:i}=e,{rotationNode:r,scaleNode:s,sizeNode:n,sizeAttenuation:a}=this,o=super.setupVertex(e);if(t.isNodeMaterial!==!0)return o;let l=n===null?JE:se(n);l=l.mul(WR),i.isPerspectiveCamera&&a===!0&&(l=l.mul(C8.div(yi.z.negate()))),s&&s.isNode&&(l=l.mul(se(s)));let h=pp.xy;if(r&&r.isNode){let u=C(r);h=_p(h,u)}return h=h.mul(l),h=h.div(zv.div(2)),h=h.mul(o.w),o=o.add(Te(h,0,0)),o}setupVertex(e){return e.object.isPoints?super.setupVertex(e):this.setupVertexSprite(e)}get alphaToCoverage(){return this._useAlphaToCoverage}set alphaToCoverage(e){this._useAlphaToCoverage!==e&&(this._useAlphaToCoverage=e,this.needsUpdate=!0)}},C8=be(1).onFrameUpdate(function({renderer:e}){let t=e.getSize(S8);this.value=.5*t.y}),R8=class extends Kf{constructor(){super(),this.shadowNode=C(1).toVar("shadowMask")}direct({lightNode:e}){e.shadowNode!==null&&this.shadowNode.mulAssign(e.shadowNode)}finish({context:e}){vt.a.mulAssign(this.shadowNode.oneMinus()),e.outgoingLight.rgb.assign(vt.rgb)}},E8=new X4,A8=class extends Ot{static get type(){return"ShadowNodeMaterial"}constructor(e){super(),this.isShadowNodeMaterial=!0,this.lights=!0,this.transparent=!0,this.setDefaultValues(E8),this.setValues(e)}setupLightingModel(){return new R8}};Wa("vec3"),Wa("vec3"),Wa("vec3");var N8=class{constructor(e,t,i){this.renderer=e,this.nodes=t,this.info=i,this._context=typeof self<"u"?self:null,this._animationLoop=null,this._requestId=null}start(){let e=(t,i)=>{this._requestId=this._context.requestAnimationFrame(e),this.info.autoReset===!0&&this.info.reset(),this.nodes.nodeFrame.update(
27),this.info.frame=this.nodes.nodeFrame.frameId,this.renderer._inspector.begin(),this._animationLoop!==null&&this._animationLoop(t,i),this.renderer._inspector.finish()};e()}stop(){this._context!==null&&this._context.cancelAnimationFrame(this._requestId),this._requestId=null}getAnimationLoop(){return this._animationLoop}setAnimationLoop(e){this._animationLoop=e}getContext(){return this._context}setContext(e){this._context=e}dispose(){this.stop()}},dl=class{constructor(){this.weakMaps={}}_getWeakMap(e){let t=e.length,i=this.weakMaps[t];return i===void 0&&(i=new WeakMap,this.weakMaps[t]=i),i}get(e){let t=this._getWeakMap(e);for(let i=0;i<e.length-1;i++)if(t=t.get(e[i]),t===void 0)return;return t.get(e[e.length-1])}set(e,t){let i=this._getWeakMap(e);for(let r=0;r<e.length-1;r++){let s=e[r];i.has(s)===!1&&i.set(s,new WeakMap),i=i.get(s)}return i.set(e[e.length-1],t),this}delete(e){let t=this._getWeakMap(e);for(let i=0;i<e.length-1;i++)if(t=t.get(e[i]),t===void 0)return!1;return t.delete(e[e.length-1])}},L8=0;function P8(e){let t=Object.keys(e),i=Object.getPrototypeOf(e);for(;i;){let r=Object.getOwnPropertyDescriptors(i);for(let s in r)if(r[s]!==void 0){let n=r[s];n&&typeof n.get=="function"&&t.push(s)}i=Object.getPrototypeOf(i)}return t}var k8=class{constructor(e,t,i,r,s,n,a,o,l,h){this.id=L8++,this._nodes=e,this._geometries=t,this.renderer=i,this.object=r,this.material=s,this.scene=n,this.camera=a,this.lightsNode=o,this.context=l,this.geometry=r.geometry,this.version=s.version,this.drawRange=null,this.attributes=null,this.attributesId=null,this.pipeline=null,this.group=null,this.vertexBuffers=null,this.drawParams=null,this.bundle=null,this.clippingContext=h,this.clippingContextCacheKey=h===null?"":h.cacheKey,this.initialNodesCacheKey=this.getDynamicCacheKey(),this.initialCacheKey=this.getCacheKey(),this._nodeBuilderState=null,this._bindings=null,this._monitor=null,this.onDispose=null,this.isRenderObject=!0,this.onMaterialDispose=()=>{this.dispose()},this.onGeometryDispose=()=>{this.attributes=null,this.attributesId=null},this.material.addEventListener("dispose",this.onMaterialDispose),this.geometry.addEventListener("dispose",this.onGeometryDispose)}updateClipping(e){this.clippingContext=e}get clippingNeedsUpdate(){return this.clippingContext===null||this.clippingContext.cacheKey===this.clippingContextCacheKey?!1:(this.clippingContextCacheKey=this.clippingContext.cacheKey,!0)}get hardwareClippingPlanes(){return this.material.hardwareClipping===!0?this.clippingContext.unionClippingCount:0}getNodeBuilderState(){return this._nodeBuilderState||=this._nodes.getForRender(this)}getMonitor(){return this._monitor||=this.getNodeBuilderState().observer}getBindings(){return this._bindings||=this.getNodeBuilderState().createBindings()}getBindingGroup(e){for(let t of this.getBindings())if(t.name===e)return t}getIndex(){return this._geometries.getIndex(this)}getIndirect(){return this._geometries.getIndirect(this)}getIndirectOffset(){return this._geometries.getIndirectOffset(this)}getChainArray(){return[this.object,this.material,this.context,this.lightsNode]}setGeometry(e){this.geometry=e,this.attributes=null,this.attributesId=null}getAttributes(){if(this.attributes!==null)return this.attributes;let e=this.getNodeBuilderState().nodeAttributes,t=this.geometry,i=[],r=new Set,s={};for(let n of e){let a;if(n.node&&n.node.attribute?a=n.node.attribute:(a=t.getAttribute(n.name),s[n.name]=a.id),a===void 0)continue;i.push(a);let o=a.isInterleavedBufferAttribute?a.data:a;r.add(o)}return this.attributes=i,this.attributesId=s,this.vertexBuffers=Array.from(r.values()),i}getVertexBuffers(){return this.vertexBuffers===null&&this.getAttributes(),this.vertexBuffers}getDrawParameters(){let{object:e,material:t,geometry:i,group:r,drawRange:s}=this,n=this.drawParams||={vertexCount:0,firstVertex:0,instanceCount:0,firstInstance:0},a=this.getIndex(),o=a!==null,l=1;if(i.isInstancedBufferGeometry===!0?l=i.instanceCount:e.count!==void 0&&(l=Math.max(0,e.count)),l===0)return null;if(n.instanceCount=l,e.isBatchedMesh===!0)return n;let h=1;t.wireframe===!0&&!e.isPoints&&!e.isLineSegments&&!e.isLine&&!e.isLineLoop&&(h=2);let u=s.start*h,d=(s.start+s.count)*h;r!==null&&(u=Math.max(u,r.start*h),d=Math.min(d,(r.start+r.count)*h));let c=i.attributes.position,p=1/0;o?p=a.count:c!=null&&(p=c.count),u=Math.max(u,0),d=Math.min(d,p);let m=d-u;return m<0||m===1/0?null:(n.vertexCount=m,n.firstVertex=u,n)}getGeometryCacheKey(){let{geometry:e}=this,t="";for(let i of Object.keys(e.attributes).sort()){let r=e.attributes[i];t+=i+",",r.data&&(t+=r.data.stride+","),r.offset&&(t+=r.offset+","),r.itemSize&&(t+=r.itemSize+","),r.normalized&&(t+="n,")}for(let i of Object.keys(e.morphAttributes).sort()){let r=e.morphAttributes[i];t+="morph-"+i+",";for(let s=0,n=r.length;s<n;s++){let a=r[s];t+=a.id+","}}return e.index&&(t+="index,"),t}getMaterialCacheKey(){let{object:e,material:t,renderer:i}=this,r=t.customProgramCacheKey();for(let s of P8(t)){if(/^(is[A-Z]|_)|^(visible|version|uuid|name|opacity|userData)$/.test(s))continue;let n=t[s],a;if(n!==null){let o=typeof n;o==="number"?a=n===0?"0":"1":o==="object"?(a="{",n.isTexture&&(a+=n.mapping,i.backend.isWebGPUBackend===!0&&(a+=n.magFilter,a+=n.minFilter,a+=n.wrapS,a+=n.wrapT,a+=n.wrapR)),a+="}"):a=String(n)}else a=String(n);r+=a+","}return r+=this.clippingContextCacheKey+",",e.geometry&&(r+=this.getGeometryCacheKey()),e.skeleton&&(r+=e.skeleton.bones.length+","),e.isBatchedMesh&&(r+=e._matricesTexture.uuid+",",e._colorsTexture!==null&&(r+=e._colorsTexture.uuid+",")),(e.isInstancedMesh||e.count>1||Array.isArray(e.morphTargetInfluences))&&(r+=e.uuid+","),r+=this.context.
27id+",",r+=e.receiveShadow+",",id(r)}get needsGeometryUpdate(){if(this.geometry.id!==this.object.geometry.id)return!0;if(this.attributes!==null){let e=this.attributesId;for(let t in e){let i=this.geometry.getAttribute(t);if(i===void 0||e[t]!==i.id)return!0}}return!1}get needsUpdate(){return this.initialNodesCacheKey!==this.getDynamicCacheKey()||this.clippingNeedsUpdate}getDynamicCacheKey(){let e=0;return this.material.isShadowPassMaterial!==!0&&(e=this._nodes.getCacheKey(this.scene,this.lightsNode)),this.camera.isArrayCamera&&(e=ip(e,this.camera.cameras.length)),this.object.receiveShadow&&(e=ip(e,1)),e=ip(e,this.renderer.contextNode.id,this.renderer.contextNode.version),e}getCacheKey(){return this.getMaterialCacheKey()+this.getDynamicCacheKey()}dispose(){this.material.removeEventListener("dispose",this.onMaterialDispose),this.geometry.removeEventListener("dispose",this.onGeometryDispose),this.onDispose()}},ta=[],I8=class{constructor(e,t,i,r,s,n){this.renderer=e,this.nodes=t,this.geometries=i,this.pipelines=r,this.bindings=s,this.info=n,this.chainMaps={}}get(e,t,i,r,s,n,a,o){let l=this.getChainMap(o);ta[0]=e,ta[1]=t,ta[2]=n,ta[3]=s;let h=l.get(ta);return h===void 0?(h=this.createRenderObject(this.nodes,this.geometries,this.renderer,e,t,i,r,s,n,a,o),l.set(ta,h)):(h.camera=r,h.updateClipping(a),h.needsGeometryUpdate&&h.setGeometry(e.geometry),(h.version!==t.version||h.needsUpdate)&&(h.initialCacheKey===h.getCacheKey()?h.version=t.version:(h.dispose(),h=this.get(e,t,i,r,s,n,a,o)))),ta[0]=null,ta[1]=null,ta[2]=null,ta[3]=null,h}getChainMap(e="default"){return this.chainMaps[e]||(this.chainMaps[e]=new dl)}dispose(){this.chainMaps={}}createRenderObject(e,t,i,r,s,n,a,o,l,h,u){let d=this.getChainMap(u),c=new k8(e,t,i,r,s,n,a,o,l,h);return c.onDispose=()=>{this.pipelines.delete(c),this.bindings.deleteForRender(c),this.nodes.delete(c),d.delete(c.getChainArray())},c}},cl=class{constructor(){this.data=new WeakMap}get(e){let t=this.data.get(e);return t===void 0&&(t={},this.data.set(e,t)),t}delete(e){let t=null;return this.data.has(e)&&(t=this.data.get(e),this.data.delete(e)),t}has(e){return this.data.has(e)}dispose(){this.data=new WeakMap}},Hs={VERTEX:1,INDEX:2,STORAGE:3,INDIRECT:4},pl=16,F8=211,D8=212,O8=class extends cl{constructor(e,t){super(),this.backend=e,this.info=t}delete(e){let t=super.delete(e);return t!==null&&(this.backend.destroyAttribute(e),this.info.destroyAttribute(e)),t}update(e,t){let i=this.get(e);if(i.version===void 0)t===Hs.VERTEX?(this.backend.createAttribute(e),this.info.createAttribute(e)):t===Hs.INDEX?(this.backend.createIndexAttribute(e),this.info.createIndexAttribute(e)):t===Hs.STORAGE?(this.backend.createStorageAttribute(e),this.info.createStorageAttribute(e)):t===Hs.INDIRECT&&(this.backend.createIndirectStorageAttribute(e),this.info.createIndirectStorageAttribute(e)),i.version=this._getBufferAttribute(e).version;else{let r=this._getBufferAttribute(e);(i.version<r.version||r.usage===35048)&&(this.backend.updateAttribute(e),i.version=r.version)}}_getBufferAttribute(e){return e.isInterleavedBufferAttribute&&(e=e.data),e}};function lN(e){return e.index===null?e.attributes.position.version:e.index.version}function hN(e){return e.index===null?e.attributes.position.id:e.index.id}function uN(e){let t=[],i=e.index,r=e.attributes.position;if(i!==null){let n=i.array;for(let a=0,o=n.length;a<o;a+=3){let l=n[a+0],h=n[a+1],u=n[a+2];t.push(l,h,h,u,u,l)}}else{let n=r.array;for(let a=0,o=n.length/3-1;a<o;a+=3){let l=a+0,h=a+1,u=a+2;t.push(l,h,h,u,u,l)}}let s=new(r.count>=65535?_M:bM)(t,1);return s.version=lN(e),s.__id=hN(e),s}var B8=class extends cl{constructor(e,t){super(),this.attributes=e,this.info=t,this.wireframes=new WeakMap,this.attributeCall=new WeakMap,this._geometryDisposeListeners=new Map}has(e){let t=e.geometry;return super.has(t)&&this.get(t).initialized===!0}updateForRender(e){this.has(e)===!1&&this.initGeometry(e),this.updateAttributes(e)}initGeometry(e){let t=e.geometry,i=this.get(t);i.initialized=!0,this.info.memory.geometries++;let r=()=>{this.info.memory.geometries--;let s=t.index,n=e.getAttributes();s!==null&&this.attributes.delete(s);for(let o of n)this.attributes.delete(o);let a=this.wireframes.get(t);a!==void 0&&this.attributes.delete(a),t.removeEventListener("dispose",r),this._geometryDisposeListeners.delete(t)};t.addEventListener("dispose",r),this._geometryDisposeListeners.set(t,r)}updateAttributes(e){let t=e.getAttributes();for(let s of t)s.isStorageBufferAttribute||s.isStorageInstancedBufferAttribute?this.updateAttribute(s,Hs.STORAGE):this.updateAttribute(s,Hs.VERTEX);let i=this.getIndex(e);i!==null&&this.updateAttribute(i,Hs.INDEX);let r=e.geometry.indirect;r!==null&&this.updateAttribute(r,Hs.INDIRECT)}updateAttribute(e,t){let i=this.info.render.calls;e.isInterleavedBufferAttribute?this.attributeCall.get(e)===void 0?(this.attributes.update(e,t),this.attributeCall.set(e,i)):this.attributeCall.get(e.data)!==i&&(this.attributes.update(e,t),this.attributeCall.set(e.data,i),this.attributeCall.set(e,i)):this.attributeCall.get(e)!==i&&(this.attributes.update(e,t),this.attributeCall.set(e,i))}getIndirect(e){return e.geometry.indirect}getIndirectOffset(e){return e.geometry.indirectOffset}getIndex(e){let{geometry:t,material:i}
27=e,r=t.index;if(i.wireframe===!0){let s=this.wireframes,n=s.get(t);n===void 0?(n=uN(t),s.set(t,n)):(n.version!==lN(t)||n.__id!==hN(t))&&(this.attributes.delete(n),n=uN(t),s.set(t,n)),r=n}return r}dispose(){for(let[e,t]of this._geometryDisposeListeners.entries())e.removeEventListener("dispose",t);this._geometryDisposeListeners.clear()}},U8=class{constructor(){this.autoReset=!0,this.frame=0,this.calls=0,this.render={calls:0,frameCalls:0,drawCalls:0,triangles:0,points:0,lines:0,timestamp:0},this.compute={calls:0,frameCalls:0,timestamp:0},this.memory={geometries:0,textures:0,attributes:0,indexAttributes:0,storageAttributes:0,indirectStorageAttributes:0,programs:0,renderTargets:0,total:0,texturesSize:0,attributesSize:0,indexAttributesSize:0,storageAttributesSize:0,indirectStorageAttributesSize:0},this.memoryMap=new Map}update(e,t,i){this.render.drawCalls++,e.isMesh||e.isSprite?this.render.triangles+=t/3*i:e.isPoints?this.render.points+=i*t:e.isLineSegments?this.render.lines+=t/2*i:e.isLine?this.render.lines+=i*(t-1):re("WebGPUInfo: Unknown object type.")}reset(){this.render.drawCalls=0,this.render.frameCalls=0,this.compute.frameCalls=0,this.render.triangles=0,this.render.points=0,this.render.lines=0}dispose(){this.reset(),this.calls=0,this.render.calls=0,this.compute.calls=0,this.render.timestamp=0,this.compute.timestamp=0;for(let e in this.memory)this.memory[e]=0;this.memoryMap.clear()}createTexture(e){let t=this._getTextureMemorySize(e);this.memoryMap.set(e,t),this.memory.textures++,this.memory.total+=t,this.memory.texturesSize+=t}destroyTexture(e){let t=this.memoryMap.get(e)||0;this.memoryMap.delete(e),this.memory.textures--,this.memory.total-=t,this.memory.texturesSize-=t}_createAttribute(e,t){let i=this._getAttributeMemorySize(e);this.memoryMap.set(e,{size:i,type:t}),this.memory[t]++,this.memory.total+=i,this.memory[t+"Size"]+=i}createAttribute(e){this._createAttribute(e,"attributes")}createIndexAttribute(e){this._createAttribute(e,"indexAttributes")}createStorageAttribute(e){this._createAttribute(e,"storageAttributes")}createIndirectStorageAttribute(e){this._createAttribute(e,"indirectStorageAttributes")}destroyAttribute(e){let t=this.memoryMap.get(e);t&&(this.memoryMap.delete(e),this.memory[t.type]--,this.memory.total-=t.size,this.memory[t.type+"Size"]-=t.size)}_getTextureMemorySize(e){if(e.isCompressedTexture)return 1;let t=1;e.type===1010||e.type===1009?t=1:e.type===1011||e.type===1012||e.type===1016?t=2:(e.type===1013||e.type===1014||e.type===1015)&&(t=4);let i=4;e.format===1021||e.format===1028||e.format===1029||e.format===1026||e.format===1027?i=1:e.format===1022&&(i=3);let r=t*i;e.type===1017||e.type===1018?r=2:(e.type===1020||e.type===35902||e.type===35899)&&(r=4);let s=e.width||1,n=e.height||1,a=e.isCubeTexture?6:e.depth||1,o=s*n*a*r,l=e.mipmaps;if(l&&l.length>0){let h=0;for(let u=0;u<l.length;u++){let d=l[u];if(d.data)h+=d.data.byteLength;else{let c=d.width||Math.max(1,s>>u),p=d.height||Math.max(1,n>>u);h+=c*p*a*r}}o+=h}else e.generateMipmaps&&(o*=1.333);return Math.round(o)}_getAttributeMemorySize(e){return e.isInterleavedBufferAttribute&&(e=e.data),e.array?e.array.byteLength:e.count&&e.itemSize?e.count*e.itemSize*4:0}},dN=class{constructor(e){this.cacheKey=e,this.usedTimes=0}},V8=class extends dN{constructor(e,t,i){super(e),this.vertexProgram=t,this.fragmentProgram=i}},z8=class extends dN{constructor(e,t){super(e),this.computeProgram=t,this.isComputePipeline=!0}},G8=0,Vb=class{constructor(e,t,i,r=null,s=null){this.id=G8++,this.code=e,this.stage=t,this.name=i,this.transforms=r,this.attributes=s,this.usedTimes=0}},j8=class extends cl{constructor(e,t,i){super(),this.backend=e,this.nodes=t,this.info=i,this.bindings=null,this.caches=new Map,this.programs={vertex:new Map,fragment:new Map,compute:new Map}}getForCompute(e,t){let{backend:i}=this,r=this.get(e);if(this._needsComputeUpdate(e)){let s=r.pipeline;s&&(s.usedTimes--,s.computeProgram.usedTimes--);let n=this.nodes.getForCompute(e),a=this.programs.compute.get(n.computeShader);a===void 0&&(s&&s.computeProgram.usedTimes===0&&this._releaseProgram(s.computeProgram),a=new Vb(n.computeShader,"compute",e.name,n.transforms,n.nodeAttributes),this.programs.compute.set(n.computeShader,a),i.createProgram(a));let o=this._getComputeCacheKey(e,a),l=this.caches.get(o);l===void 0&&(s&&s.usedTimes===0&&this._releasePipeline(s),l=this._getComputePipeline(e,a,o,t)),l.usedTimes++,a.usedTimes++,r.version=e.version,r.pipeline=l}return r.pipeline}getForRender(e,t=null){let{backend:i}=this,r=this.get(e);
27if(this._needsRenderUpdate(e)){let s=r.pipeline;s&&(s.usedTimes--,s.vertexProgram.usedTimes--,s.fragmentProgram.usedTimes--);let n=e.getNodeBuilderState(),a=e.material?e.material.name:"",o=this.programs.vertex.get(n.vertexShader);o===void 0&&(s&&s.vertexProgram.usedTimes===0&&this._releaseProgram(s.vertexProgram),o=new Vb(n.vertexShader,"vertex",a),this.programs.vertex.set(n.vertexShader,o),i.createProgram(o));let l=this.programs.fragment.get(n.fragmentShader);l===void 0&&(s&&s.fragmentProgram.usedTimes===0&&this._releaseProgram(s.fragmentProgram),l=new Vb(n.fragmentShader,"fragment",a),this.programs.fragment.set(n.fragmentShader,l),i.createProgram(l));let h=this._getRenderCacheKey(e,o,l),u=this.caches.get(h);u===void 0?(s&&s.usedTimes===0&&this._releasePipeline(s),u=this._getRenderPipeline(e,o,l,h,t)):e.pipeline=u,u.usedTimes++,o.usedTimes++,l.usedTimes++,r.pipeline=u}return r.pipeline}isReady(e){let t=this.get(e).pipeline;if(t===void 0)return!1;let i=this.backend.get(t);return i.pipeline!==void 0&&i.pipeline!==null}delete(e){let t=this.get(e).pipeline;return t&&(t.usedTimes--,t.usedTimes===0&&this._releasePipeline(t),t.isComputePipeline?(t.computeProgram.usedTimes--,t.computeProgram.usedTimes===0&&this._releaseProgram(t.computeProgram)):(t.fragmentProgram.usedTimes--,t.vertexProgram.usedTimes--,t.vertexProgram.usedTimes===0&&this._releaseProgram(t.vertexProgram),t.fragmentProgram.usedTimes===0&&this._releaseProgram(t.fragmentProgram))),super.delete(e)}dispose(){super.dispose(),this.caches=new Map,this.programs={vertex:new Map,fragment:new Map,compute:new Map}}updateForRender(e){this.getForRender(e)}_getComputePipeline(e,t,i,r){i||=this._getComputeCacheKey(e,t);let s=this.caches.get(i);return s===void 0&&(s=new z8(i,t),this.caches.set(i,s),this.backend.createComputePipeline(s,r),this.info.memory.programs++),s}_getRenderPipeline(e,t,i,r,s){r||=this._getRenderCacheKey(e,t,i);let n=this.caches.get(r);return n===void 0&&(n=new V8(r,t,i),this.caches.set(r,n),e.pipeline=n,this.backend.createRenderPipeline(e,s),this.info.memory.programs++),n}_getComputeCacheKey(e,t){return e.id+","+t.id}_getRenderCacheKey(e,t,i){return t.id+","+i.id+","+this.backend.getRenderCacheKey(e)}_releasePipeline(e){this.caches.delete(e.cacheKey),this.info.memory.programs--}_releaseProgram(e){let t=e.code,i=e.stage;this.programs[i].delete(t)}_needsComputeUpdate(e){let t=this.get(e);return t.pipeline===void 0||t.version!==e.version}_needsRenderUpdate(e){return this.get(e).pipeline===void 0||this.backend.needsRenderUpdate(e)}},$8=class extends cl{constructor(e,t,i,r,s,n){super(),this.backend=e,this.textures=i,this.pipelines=s,this.attributes=r,this.nodes=t,this.info=n,this.pipelines.bindings=this}getForRender(e){let t=e.getBindings();for(let i of t){let r=this.get(i);r.bindGroup===void 0&&(this._init(i),this.backend.createBindings(i,t,0),r.bindGroup=i)}return t}getForCompute(e){let t=this.nodes.getForCompute(e).bindings;for(let i of t){let r=this.get(i);r.bindGroup===void 0&&(this._init(i),this.backend.createBindings(i,t,0),r.bindGroup=i)}return t}updateForCompute(e){this._updateBindings(this.getForCompute(e))}updateForRender(e){this._updateBindings(this.getForRender(e))}deleteForCompute(e){let t=this.nodes.getForCompute(e).bindings;for(let i of t)this.backend.deleteBindGroupData(i),this.delete(i)}deleteForRender(e){let t=e.getBindings();for(let i of t)this.backend.deleteBindGroupData(i),this.delete(i)}_updateBindings(e){for(let t of e)this._update(t,e)}_init(e){for(let t of e.bindings)if(t.isSampledTexture)this.textures.updateTexture(t.texture);else if(t.isSampler)this.textures.updateSampler(t.texture);else if(t.isStorageBuffer){let i=t.attribute,r=i.isIndirectStorageBufferAttribute?Hs.INDIRECT:Hs.STORAGE;this.attributes.update(i,r)}}_update(e,t){let{backend:i}=this,r=!1,s=!0,n=0,a=0;for(let o of e.bindings)if(this.nodes.updateGroup(o)!==!1){if(o.isStorageBuffer){let l=o.attribute,h=l.isIndirectStorageBufferAttribute?Hs.INDIRECT:Hs.STORAGE,u=i.get(o);this.attributes.update(l,h),u.attribute!==l&&(u.attribute=l,r=!0)}if(o.isUniformBuffer)o.update()&&i.updateBinding(o);else if(o.isSampledTexture){let l=o.update(),h=o.texture,u=this.textures.get(h);if(l&&(this.textures.updateTexture(h),o.generation!==u.generation&&(o.generation=u.generation,r=!0),u.bindGroups.add(e)),i.get(h).externalTexture!==void 0||u.isDefaultTexture?s=!1:(n=n*10+h.id,a+=h.version),h.isStorageTexture===!0&&h.mipmapsAutoUpdate===!0){let d=this.get(h);o.store===!0?d.needsMipmap=!0:this.textures.needsMipmaps(h)&&d.needsMipmap===!0&&(this.backend.generateMipmaps(h),d.needsMipmap=!1)}}else if(o.isSampler&&o.update()){let l=this.textures.updateSampler(o.texture);o.samplerKey!==l&&(o.samplerKey=l,r=!0)}o.isBuffer&&o.updateRanges.length>0&&o.clearUpdateRanges()}r===!0&&this.backend.updateBindings(e,t,s?n:0,a)}};function W8(e,t){return e.groupOrder===t.groupOrder?e.renderOrder===t.renderOrder?e.z===t.z?e.id-t.id:e.z-t.z:e.renderOrder-t.renderOrder:e.groupOrder-t.groupOrder}function cN(e,t){return e.groupOrder===t.groupOrder?e.renderOrder===t.renderOrder?e.z===t.z?e.id-t.id:t.z-e.z:e.renderOrder-t.renderOrder:e.groupOrder-t.groupOrder}function pN(e){return(e.transmission>0||e.transmissionNode&&e.transmissionNode.isNode)&&e.side===2&&e.forceSinglePass===!1}var H8=class{constructor(e,t,i){this.renderItems=[],this.renderItemsIndex=0,this.opaque=[],this.transparentDoublePass=[],this.transparent=[],this.bundles=[],this.lightsNode=e.getNode(t,i),this.lightsArray=[],this.scene=t,this.camera=i,this.occlusionQueryCount=0}begin(){return this.renderItemsIndex=0,this.opaque.length=0,this.transparentDoublePass.length=0,this.transparent.length=0,this.bundles.length=0,this.lightsArray.length=0,this.occlusionQueryCount=0,this}getNextRenderItem(e,t,i,r,s,n,a){let o=this.renderItems[this.renderItemsIndex];return o===void 0?(o={id:e.id,object:e,geometry:t,material:i,groupOrder:r,renderOrder:e.renderOrder,z:s,group:n,clippingContext:a},this.renderItems[this.renderItemsIndex]=o):(o.id=e.id,o.object=e,o.geometry=t,o.material=i,o.groupOrder=r,o.renderOrder=e.renderOrder,o.z=s,o.group=n,o.clippingContext=a
27),this.renderItemsIndex++,o}push(e,t,i,r,s,n,a){let o=this.getNextRenderItem(e,t,i,r,s,n,a);e.occlusionTest===!0&&this.occlusionQueryCount++,i.transparent===!0||i.transmission>0||i.transmissionNode&&i.transmissionNode.isNode||i.backdropNode&&i.backdropNode.isNode?(pN(i)&&this.transparentDoublePass.push(o),this.transparent.push(o)):this.opaque.push(o)}unshift(e,t,i,r,s,n,a){let o=this.getNextRenderItem(e,t,i,r,s,n,a);i.transparent===!0||i.transmission>0||i.transmissionNode&&i.transmissionNode.isNode||i.backdropNode&&i.backdropNode.isNode?(pN(i)&&this.transparentDoublePass.unshift(o),this.transparent.unshift(o)):this.opaque.unshift(o)}pushBundle(e){this.bundles.push(e)}pushLight(e){this.lightsArray.push(e)}sort(e,t){this.opaque.length>1&&this.opaque.sort(e||W8),this.transparentDoublePass.length>1&&this.transparentDoublePass.sort(t||cN),this.transparent.length>1&&this.transparent.sort(t||cN)}finish(){this.lightsNode.setLights(this.lightsArray);for(let e=this.renderItemsIndex,t=this.renderItems.length;e<t;e++){let i=this.renderItems[e];if(i.id===null)break;i.id=null,i.object=null,i.geometry=null,i.material=null,i.groupOrder=null,i.renderOrder=null,i.z=null,i.group=null,i.clippingContext=null}}},yd=[],q8=class{constructor(e){this.lighting=e,this.lists=new dl}get(e,t){let i=this.lists;yd[0]=e,yd[1]=t;let r=i.get(yd);return r===void 0&&(r=new H8(this.lighting,e,t),i.set(yd,r)),yd[0]=null,yd[1]=null,r}dispose(){this.lists=new dl}},X8=0,Y8=class{constructor(){this.id=X8++,this.mrt=null,this.color=!0,this.clearColor=!0,this.clearColorValue={r:0,g:0,b:0,a:1},this.depth=!0,this.clearDepth=!0,this.clearDepthValue=1,this.stencil=!1,this.clearStencil=!0,this.clearStencilValue=1,this.viewport=!1,this.viewportValue=new yt,this.scissor=!1,this.scissorValue=new yt,this.renderTarget=null,this.textures=null,this.depthTexture=null,this.activeCubeFace=0,this.activeMipmapLevel=0,this.sampleCount=1,this.width=0,this.height=0,this.occlusionQueryCount=0,this.clippingContext=null,this.camera=null,this.isRenderContext=!0}getCacheKey(){return mN(this)}};function mN(e){let{textures:t,activeCubeFace:i,activeMipmapLevel:r}=e,s=[i,r];for(let n of t)s.push(n.id);return tp(s)}var K8=class{constructor(e){this.renderer=e,this._renderContexts={}}get(e=null,t=null,i=0){let r;if(e===null)r="default";else{let o=e.texture.format,l=e.texture.type;r=`${e.textures.length}:${o}:${l}:${e.samples}:${e.depthBuffer}:${e.stencilBuffer}`}let s=t===null?"default":t.id,n=r+"-"+s+"-"+i,a=this._renderContexts[n];return a===void 0&&(a=new Y8,a.mrt=t,this._renderContexts[n]=a),e!==null&&(a.sampleCount=e.samples===0?1:e.samples),a.clearDepthValue=this.renderer.getClearDepth(),a.clearStencilValue=this.renderer.getClearStencil(),a}dispose(){this._renderContexts={}}},Z8=new F,J8=class extends cl{constructor(e,t,i){super(),this.renderer=e,this.backend=t,this.info=i}updateRenderTarget(e,t=0){let i=this.get(e),r=e.samples===0?1:e.samples,s=i.depthTextureMips||={},n=e.textures,a=this.getSize(n[0]),o=a.width>>t,l=a.height>>t,h=e.depthTexture||s[t],u=e.depthBuffer===!0||e.stencilBuffer===!0,d=!1;h===void 0&&u&&(h=new Us,h.format=e.stencilBuffer?uh:Da,h.type=e.stencilBuffer?hh:ur,h.image.width=o,h.image.height=l,h.image.depth=a.depth,h.renderTarget=e,h.isArrayTexture=e.multiview===!0&&a.depth>1,s[t]=h),(i.width!==a.width||a.height!==i.height)&&(d=!0,h&&(h.needsUpdate=!0,h.image.width=o,h.image.height=l,h.image.depth=h.isArrayTexture?h.image.depth:1)),i.width=a.width,i.height=a.height,i.textures=n,i.depthTexture=h||null,i.depth=e.depthBuffer,i.stencil=e.stencilBuffer,i.renderTarget=e,i.sampleCount!==r&&(d=!0,h&&(h.needsUpdate=!0),i.sampleCount=r);let c={sampleCount:r};if(e.isXRRenderTarget!==!0){for(let p=0;p<n.length;p++){let m=n[p];d&&(m.needsUpdate=!0),this.updateTexture(m,c)}h&&this.updateTexture(h,c)}i.initialized!==!0&&(i.initialized=!0,this.info.memory.renderTargets++,i.onDispose=()=>{this._destroyRenderTarget(e)},e.addEventListener("dispose",i.onDispose))}updateTexture(e,t={}){let i=this.get(e);if(i.initialized===!0&&i.version===e.version)return;let r=e.isRenderTargetTexture||e.isDepthTexture||e.isFramebufferTexture,s=this.backend;if(r&&i.initialized===!0&&s.destroyTexture(e),e.isFramebufferTexture){let l=this.renderer.getRenderTarget();l?e.type=l.texture.type:e.type=hr}let{width:n,height:a,depth:o}=this.getSize(e);if(t.width=n,t.height=a,t.depth=o,t.needsMipmaps=this.needsMipmaps(e),t.levels=t.needsMipmaps?this.getMipLevels(e,n,a):1,e.isCubeTexture&&e.mipmaps.length>0&&t.levels++,r||e.isStorageTexture===!0||e.isExternalTexture===!0)s.createTexture(e,t),i.generation=e.version;else if(e.version>0){let l=e.image;if(l===void 0)de("Renderer: Texture marked for update but image is undefined.");else if(l.complete===!1)de("Renderer: Texture marked for update but image is incomplete.");else{if(e.images){let u=[];for(let d of e.images)u.push(d);t.images=u}else t.image=l;(i.isDefaultTexture===void 0||i.isDefaultTexture===!0)&&(s.createTexture(e,t),i.isDefaultTexture=!1,i.generation=e.version),e.source.dataReady===!0&&s.updateTexture(e,t);let h=e.isStorageTexture===!0&&e.mipmapsAutoUpdate===!1;t.needsMipmaps&&e.mipmaps.length===0&&!h&&s.generateMipmaps(e),e.onUpdate&&e.onUpdate(e)}}else s.createDefaultTexture(e),i.isDefaultTexture=!0,i.generation=e.version;i.initialized!==!0&&(i.initialized=!0,i.generation=e.version,i.bindGroups=new Set,this.info.createTexture(e),e.isVideoTexture&&lt.enabled===!0&&lt.getTransfer(e.colorSpace)!=="srgb"&&de("WebGPURenderer: Video textures must use a color space with a sRGB transfer function, e.g. SRGBColorSpace."),i.onDispose=()=>{this._destroyTexture(e)},e.addEventListener("dispose",i.onDispose)),i.version=e.version}updateSampler(e){return this.backend.updateSampler(e)}getSize(e,t=Z8){let i=e.images?e.images[0]:e.image;return i?(i.image!==void 0&&(i=i.image),typeof HTMLVideoElement<"u"&&i instanceof HTMLVideoElement?(t.width=i.videoWidth||1,t.height=i.videoHeight||1,t.depth=1):typeof VideoFrame<"u"&&i instanceof VideoFrame?(t.width=i.displayWidth||1,t.height=i.displayHeight||1,t.depth=1):(t.width=i.width||1,t.height=i.height||1,t.depth=e.isCubeTexture?6:i.depth||1)):t.width=t.height=t.depth=1,t}getMipLevels(e,t,i){let r;return r=e.mipmaps.length>0?e.mipmaps.length:e.isCompressedTexture===!0?1:Math.floor(Math.log2(Math.max(t,i)))+1,r}needsMipmaps(e){return e.generateMipmaps===!0||e.mipmaps.length>0}_destroyRenderTarget(e){if(this.has(e)===!0){let t=this.get(e),i=t.textures,r=t.depthTexture;e.removeEventListener("dispose",t.onDispose);for(let s=0;s<i.length;s++)this._destroyTexture(i[s]);r&&this._destroyTexture(r),this.delete(e),this.backend.delete(e),this.info.memory.renderTargets--}}_destroyTexture(e){if(this.has(e)===!0){let t=this.get(e);e.removeEventListener("dispose",t.onDispose);let i=t.isDefaultTexture;if(this.backend.destroyTexture(e,i),t.bindGroups)for(let r of t.bindGroups){let s=this.backend.get(r);s.groups=void 0,s.versions=void 0}this.delete(e),this.info.destroyTexture(e)}}},zb=class extends Ke{constructor(e,t,i,r=1){super(e,t,i),this.a=r}set(e,t,i,r=1){return this.a=r,super.set(e,t,i)}copy(e){return e.a!==void 0&&(this.a=e.a),super.copy(e)}clone(){return new this.constructor(this.r,this.g,this.b,this.a)}},gN=class extends pt{static get type(){return"ParameterNode"}constructor(e,t=null){super(e,t),this.isParameterNode=!0}getMemberType(e,t){let i=this.getNodeType(e),r=e.getStructTypeNode(i),s;return r===null?(re(`TSL: Member "${t}" not found in struct "${i}".`,new fi),s="float"):s=r.getMemberType(e,t),s}
27getHash(){return String(this.id)}generate(){return this.name}},Q8=(e,t)=>new gN(e,t),a0=Fe(class extends ve{static get type(){return"StackNode"}constructor(e=null){super(),this.nodes=[],this.outputNode=null,this.parent=e,this._currentCond=null,this._expressionNode=null,this._currentNode=null,this.isStackNode=!0}getElementType(e){return this.hasOutput(e)?this.outputNode.getElementType(e):"void"}generateNodeType(e){return this.hasOutput(e)?this.outputNode.getNodeType(e):"void"}getMemberType(e,t){return this.hasOutput(e)?this.outputNode.getMemberType(e,t):"void"}addToStack(e,t=this.nodes.length){return e.isNode===!0?(this.nodes.splice(t,0,e),this):(re("TSL: Invalid node added to stack.",new fi),this)}addToStackBefore(e){let t=this._currentNode?this.nodes.indexOf(this._currentNode):0;return this.addToStack(e,t)}If(e,t){let i=new sd(t);return this._currentCond=wr(e,i),this.addToStack(this._currentCond)}ElseIf(e,t){let i=wr(e,new sd(t));return this._currentCond.elseNode=i,this._currentCond=i,this}Else(e){return this._currentCond.elseNode=new sd(e),this}Switch(e){return this._expressionNode=xe(e),this}Case(...e){let t=[];if(e.length>=2)for(let a=0;a<e.length-1;a++)t.push(this._expressionNode.equal(xe(e[a])));else re("TSL: Invalid parameter length. Case() requires at least two parameters.",new fi);let i=e[e.length-1],r=new sd(i),s=t[0];for(let a=1;a<t.length;a++)s=s.or(t[a]);let n=wr(s,r);return this._currentCond===null?(this._currentCond=n,this.addToStack(this._currentCond)):(this._currentCond.elseNode=n,this._currentCond=n,this)}Default(e){return this.Else(e),this}setup(e){let t=e.getNodeProperties(this),i=0;for(let r of this.getChildren())r.isVarNode&&r.isIntent(e)&&r.isAssign(e)!==!0||(t["node"+i++]=r);return t.outputNode||null}hasOutput(e){return this.outputNode&&this.outputNode.isNode&&this.outputNode.getNodeType(e)!=="void"}build(e,...t){let i=Qx(),r=e.buildStage;ap(this),e.setActiveStack(this);let s=l=>{if(this._currentNode=l,!(l.isVarNode&&l.isIntent(e)&&l.isAssign(e)!==!0)){if(r==="setup")l.build(e);else if(r==="analyze")l.build(e,this);else if(r==="generate"){let h=e.getDataFromNode(l,"any").stages,u=h&&h[e.shaderStage];if(l.isVarNode&&u&&u.length===1&&u[0]&&u[0].isStackNode)return;l.build(e,"void")}}},n=[...this.nodes];for(let l of n)s(l);this._currentNode=null;let a=this.nodes.filter(l=>n.indexOf(l)===-1);for(let l of a)s(l);let o;return o=this.hasOutput(e)?this.outputNode.build(e,...t):super.build(e,...t),ap(i),e.removeActiveStack(this),o}}).setParameterLength(0,1);function eG(e){return Object.entries(e).map(([t,i])=>typeof i=="string"?{name:t,type:i,atomic:!1}:{name:t,type:i.type,atomic:i.atomic||!1})}var tG=class extends ve{static get type(){return"StructTypeNode"}constructor(e,t=null){super("struct"),this.membersLayout=eG(e),this.name=t,this.isStructLayoutNode=!0}getLength(){let e=Float32Array.BYTES_PER_ELEMENT,t=1,i=0;for(let r of this.membersLayout){let s=r.type,n=jU(s),a=$U(s)/e;t=Math.max(t,a);let o=i%t%a;o!==0&&(i+=a-o),i+=n}return Math.ceil(i/t)*t}getMemberType(e,t){let i=this.membersLayout.find(r=>r.name===t);return i?i.type:"void"}generateNodeType(e){return e.getStructTypeFromNode(this,this.membersLayout,this.name).name}setup(e){e.getStructTypeFromNode(this,this.membersLayout,this.name),e.addInclude(this)}generate(e){return this.getNodeType(e)}},iG=class extends ve{static get type(){return"StructNode"}constructor(e,t){super("vec3"),this.structTypeNode=e,this.values=t,this.isStructNode=!0}generateNodeType(e){return this.structTypeNode.getNodeType(e)}getMemberType(e,t){return this.structTypeNode.getMemberType(e,t)}_getChildren(){let e=super._getChildren(),t=e.find(i=>i.childNode===this.structTypeNode);return e.splice(e.indexOf(t),1),e.push(t),e}generate(e){let t=e.getVarFromNode(this),i=t.type,r=e.getPropertyName(t);return e.addLineFlowCode(`${r} = ${e.generateStruct(i,this.structTypeNode.membersLayout,this.values)}`,this),t.name}},rG=(e,t=null)=>{let i=new tG(e,t),r=(...s)=>{let n=null;if(s.length>0)if(s[0].isNode){n={};let a=Object.keys(e);for(let o=0;o<s.length;o++)n[a[o]]=s[o]}else n=s[0];return new iG(i,n)};return r.layout=i,r.isStruct=!0,r},fN=class extends ve{static get type(){return"OutputStructNode"}constructor(...e){super(),this.members=e,this.isOutputStructNode=!0}generateNodeType(){return"OutputType"}generate(e){let t=e.getDataFromNode(this);if(t.membersLayout===void 0){let n=this.members,a=[];for(let o=0;o<n.length;o++){let l="m"+o,h=n[o].getNodeType(e);a.push({name:l,type:h,index:o})}t.membersLayout=a,t.structType=e.getOutputStructTypeFromNode(this,t.membersLayout)}let i=e.getOutputStructName(),r=this.members,s=i===""?"":i+".";for(let n=0;n<r.length;n++){let a=r[n].build(e);e.addLineFlowCode(`${s}m${n} = ${a}`,this)}return i}},sG=Fe(fN),yN=class{constructor(e=1){this.blending=e,this.blendSrc=204,this.blendDst=205,this.blendEquation=100,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.premultiplyAlpha=!1}copy(e){return this.blending=e.blending,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.premultiplyAlpha=e.premultiplyAlpha,this}clone(){return new this.constructor().copy(this)}},nG=new yN(0),aG=new yN(6);function xN(e,t){for(let i=0;i<e.length;i++)if(e[i].name===t)return i;return-1}
27var vN=Fe(class extends fN{static get type(){return"MRTNode"}constructor(e){super(),this.outputNodes=e,this.blendModes={output:aG},this.isMRTNode=!0}setBlendMode(e,t){return this.blendModes[e]=t,this}getBlendMode(e){return this.blendModes[e]||nG}has(e){return this.outputNodes[e]!==void 0}get(e){return this.outputNodes[e]}merge(e){let t={...this.outputNodes,...e.outputNodes},i={...this.blendModes,...e.blendModes},r=vN(t);return r.blendings=i,r}setup(e){let t=this.outputNodes,i=e.renderer.getRenderTarget(),r=[],s=i.textures;for(let n in t){let a=xN(s,n);r[a]=Te(t[n])}return this.members=r,super.setup(e)}}),Tp=class extends ei{static get type(){return"BitcastNode"}constructor(e,t,i=null){super(),this.valueNode=e,this.conversionType=t,this.inputType=i,this.isBitcastNode=!0}generateNodeType(e){if(this.inputType!==null){let t=this.valueNode.getNodeType(e),i=e.getTypeLength(t);return e.getTypeFromLength(i,this.conversionType)}return this.conversionType}generate(e){let t=this.getNodeType(e),i="";if(this.inputType!==null){let r=this.valueNode.getNodeType(e);i=e.getTypeLength(r)===1?this.inputType:e.changeComponentType(r,this.inputType)}else i=this.valueNode.getNodeType(e);return`${e.getBitcastMethod(t,i)}( ${this.valueNode.build(e,i)} )`}},bN=ne(Tp).setParameterLength(2),oG=e=>new Tp(e,"int","float"),_N=e=>new Tp(e,"uint","float"),lG=e=>new Tp(e,"float","int"),hG=e=>new Tp(e,"float","uint"),o0={},eo=class U1 extends G{static get type(){return"BitcountNode"}constructor(t,i){super(t,i),this.isBitcountNode=!0}_resolveElementType(t,i,r){r==="int"?i.assign(bN(t,"uint")):i.assign(t)}_returnDataNode(t){switch(t){case"uint":return K;case"int":return A;case"uvec2":return ev;case"uvec3":return Sh;case"uvec4":return sv;case"ivec2":return Ii;case"ivec3":return tv;case"ivec4":return rv}}_createTrailingZerosBaseLayout(t,i){let r=this._returnDataNode(i);return k(([s])=>{let n=K(0);return this._resolveElementType(s,n,i),r(_N(C(n.bitAnd(xv(n)))).shiftRight(23).sub(127))}).setLayout({name:t,type:i,inputs:[{name:"value",type:i}]})}_createLeadingZerosBaseLayout(t,i){let r=this._returnDataNode(i);return k(([s])=>{Se(s.equal(K(0)),()=>K(32));let n=K(0),a=K(0);return this._resolveElementType(s,n,i),Se(n.shiftRight(16).equal(0),()=>{a.addAssign(16),n.shiftLeftAssign(16)}),Se(n.shiftRight(24).equal(0),()=>{a.addAssign(8),n.shiftLeftAssign(8)}),Se(n.shiftRight(28).equal(0),()=>{a.addAssign(4),n.shiftLeftAssign(4)}),Se(n.shiftRight(30).equal(0),()=>{a.addAssign(2),n.shiftLeftAssign(2)}),Se(n.shiftRight(31).equal(0),()=>{a.addAssign(1)}),r(a)}).setLayout({name:t,type:i,inputs:[{name:"value",type:i}]})}_createOneBitsBaseLayout(t,i){let r=this._returnDataNode(i);return k(([s])=>{let n=K(0);return this._resolveElementType(s,n,i),n.assign(n.sub(n.shiftRight(K(1)).bitAnd(K(1431655765)))),n.assign(n.bitAnd(K(858993459)).add(n.shiftRight(K(2)).bitAnd(K(858993459)))),r(n.add(n.shiftRight(K(4))).bitAnd(K(252645135)).mul(K(16843009)).shiftRight(K(24)))}).setLayout({name:t,type:i,inputs:[{name:"value",type:i}]})}_createMainLayout(t,i,r,s){let n=this._returnDataNode(i);return k(([a])=>{if(r===1)return n(s(a));{let o=n(0),l=["x","y","z","w"];for(let h=0;h<r;h++){let u=l[h];o[u].assign(s(a[u]))}return o}}).setLayout({name:t,type:i,inputs:[{name:"value",type:i}]})}setup(t){let{method:i,aNode:r}=this,{renderer:s}=t;if(s.backend.isWebGPUBackend)return super.setup(t);let n=this.getInputType(t),a=t.getElementType(n),o=t.getTypeLength(n),l=`${i}_base_${a}`,h=`${i}_${n}`,u=o0[l];if(u===void 0){switch(i){case U1.COUNT_LEADING_ZEROS:u=this._createLeadingZerosBaseLayout(l,a);break;case U1.COUNT_TRAILING_ZEROS:u=this._createTrailingZerosBaseLayout(l,a);break;case U1.COUNT_ONE_BITS:u=this._createOneBitsBaseLayout(l,a);break}o0[l]=u}let d=o0[h];return d===void 0&&(d=this._createMainLayout(h,n,o,u),o0[h]=d),k(()=>d(r))()}};eo.COUNT_TRAILING_ZEROS="countTrailingZeros",eo.COUNT_LEADING_ZEROS="countLeadingZeros",eo.COUNT_ONE_BITS="countOneBits";var uG=ne(eo,eo.COUNT_TRAILING_ZEROS).setParameterLength(1),dG=ne(eo,eo.COUNT_LEADING_ZEROS).setParameterLength(1),cG=ne(eo,eo.COUNT_ONE_BITS).setParameterLength(1),pG=k(([e])=>{let t=e.toUint().mul(747796405).add(2891336453),i=t.shiftRight(t.shiftRight(28).add(4)).bitXor(t).mul(277803737);
27return i.shiftRight(22).bitXor(i).toFloat().mul(1/2**32)}),Gb=(e,t)=>Gs(Pe(4,e.mul(tt(1,e))),t),mG=(e,t)=>e.lessThan(.5)?Gb(e.mul(2),t).div(2):tt(1,Gb(Pe(tt(1,e),2),t).div(2)),gG=(e,t,i)=>Gs(_s(Gs(e,t),wi(Gs(e,t),Gs(tt(1,e),i))),1/t),fG=(e,t)=>qr(Tf.mul(t.mul(e).sub(1))).div(Tf.mul(t.mul(e).sub(1))),jb=class extends ei{static get type(){return"PackFloatNode"}constructor(e,t){super(),this.vectorNode=t,this.encoding=e,this.isPackFloatNode=!0}generateNodeType(){return"uint"}generate(e){let t=this.vectorNode.getNodeType(e);return`${e.getFloatPackingMethod(this.encoding)}(${this.vectorNode.build(e,t)})`}},yG=ne(jb,"snorm").setParameterLength(1),xG=ne(jb,"unorm").setParameterLength(1),vG=ne(jb,"float16").setParameterLength(1),$b=class extends ei{static get type(){return"UnpackFloatNode"}constructor(e,t){super(),this.uintNode=t,this.encoding=e,this.isUnpackFloatNode=!0}generateNodeType(){return"vec2"}generate(e){let t=this.uintNode.getNodeType(e);return`${e.getFloatUnpackingMethod(this.encoding)}(${this.uintNode.build(e,t)})`}},bG=ne($b,"snorm").setParameterLength(1),_G=ne($b,"unorm").setParameterLength(1),TG=ne($b,"float16").setParameterLength(1),to=k(([e])=>e.fract().sub(.5).abs()).setLayout({name:"tri",type:"float",inputs:[{name:"x",type:"float"}]}),wG=k(([e])=>L(to(e.z.add(to(e.y.mul(1)))),to(e.z.add(to(e.x.mul(1)))),to(e.y.add(to(e.x.mul(1)))))).setLayout({name:"tri3",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),SG=k(([e,t,i])=>{let r=L(e).toVar(),s=C(1.4).toVar(),n=C(0).toVar(),a=L(r).toVar();return bt({start:C(0),end:C(3),type:"float",condition:"<="},()=>{let o=L(wG(a.mul(2))).toVar();r.addAssign(o.add(i.mul(C(.1).mul(t)))),a.mulAssign(1.8),s.mulAssign(1.5),r.mulAssign(1.2);let l=C(to(r.z.add(to(r.x.add(to(r.y)))))).toVar();n.addAssign(l.div(s)),a.addAssign(.14)}),n}).setLayout({name:"triNoise3D",type:"float",inputs:[{name:"position",type:"vec3"},{name:"speed",type:"float"},{name:"time",type:"float"}]}),MG=Fe(class extends ve{static get type(){return"FunctionOverloadingNode"}constructor(e=[],...t){super(),this.functionNodes=e,this.parametersNodes=t,this._candidateFn=null,this.global=!0}generateNodeType(e){return this.getCandidateFn(e).shaderNode.layout.type}getCandidateFn(e){let t=this.parametersNodes,i=this._candidateFn;if(i===null){let r=null,s=-1;for(let n of this.functionNodes){let a=n.shaderNode.layout;if(a===null)throw Error("FunctionOverloadingNode: FunctionNode must be a layout.");let o=a.inputs;if(t.length===o.length){let l=0;for(let h=0;h<t.length;h++){let u=t[h],d=o[h];u.getNodeType(e)===d.type&&l++}l>s&&(r=n,s=l)}}this._candidateFn=i=r}return i}setup(e){return this.getCandidateFn(e)(...this.parametersNodes)}}),mr=e=>(...t)=>MG(e,...t),xd=be(0).setGroup(we).onRenderUpdate(e=>e.time),CG=be(0).setGroup(we).onRenderUpdate(e=>e.deltaTime),TN=be(0,"uint").setGroup(we).onRenderUpdate(e=>e.frameId),RG=(e=xd)=>e.add(.75).mul(Math.PI*2).sin().mul(.5).add(.5),EG=(e=xd)=>e.fract().round(),AG=(e=xd)=>e.add(.5).fract().mul(2).sub(1).abs(),NG=(e=xd)=>e.fract();function LG(e,t=null){return Xa(t,{getUV:typeof e=="function"?e:()=>e})}var PG=k(([e,t,i=se(.5)])=>_p(e.sub(i),t).add(i)),kG=k(([e,t,i=se(.5)])=>{let r=e.sub(i),s=r.dot(r),n=s.mul(s).mul(t);return e.add(r.mul(n))}),IG=k(({position:e=null,horizontal:t=!0,vertical:i=!1})=>{let r;e===null?r=Ws:(r=Ws.toVar(),r[3][0]=e.x,r[3][1]=e.y,r[3][2]=e.z);let s=js.mul(r);return rd(t)&&(s[0][0]=Ws[0].length(),s[0][1]=0,s[0][2]=0),rd(i)&&(s[1][0]=0,s[1][1]=Ws[1].length(),s[1][2]=0),s[2][0]=0,s[2][1]=0,s[2][2]=1,Za.mul(s).mul(ii)}),FG=k(([e=null])=>{let t=Yf();return Yf(gb(e)).sub(t).lessThan(0).select(Kn,e)}),DG=k(([e,t=Mt(),i=C(0)])=>{let r=e.x,s=e.y,n=i.mod(r.mul(s)).floor(),a=n.mod(r),o=s.sub(n.add(1).div(r).ceil()),l=e.reciprocal(),h=se(a,o);return t.add(h).mul(l)}),wN=k(([e,t=null,i=null,r=C(1),s=ii,n=us])=>{let a=n.abs().normalize();a=a.div(a.dot(L(1)));let o=s.yz.mul(r),l=s.zx.mul(r),h=s.xy.mul(r),u=e.value,d=t===null?u:t.value,c=i===null?u:i.value;return wi(st(u,o).mul(a.x),st(d,l).mul(a.y),st(c,h).mul(a.z))}),OG=(...e)=>wN(...e),vd=new $o,Oh=new F,bd=new F,Wb=new F,wp=new $e,l0=new F(0,0,-1),ia=new yt,Sp=new F,h0=new F,Mp=new yt,u0=new ge,d0=new zr,BG=Kn.flipX();d0.depthTexture=new Us(1,1);var c0=!1,UG=class uO extends Yn{static get type(){return"ReflectorNode"}constructor(t={}){super(t.defaultTexture||d0.texture,BG),this._reflectorBaseNode=t.reflector||new VG(this,t),this._depthNode=null,this.setUpdateMatrix(!1)}get reflector(){return this._reflectorBaseNode}get target(){return this._reflectorBaseNode.target}getDepthNode(){if(this._depthNode===null){if(this._reflectorBaseNode.depth!==!0)throw Error("THREE.ReflectorNode: Depth node 
27can only be requested when the reflector is created with { depth: true }. ");this._depthNode=new uO({defaultTexture:d0.depthTexture,reflector:this._reflectorBaseNode})}return this._depthNode}setup(t){return t.object.isQuadMesh||this._reflectorBaseNode.build(t),super.setup(t)}clone(){let t=new this.constructor(this.reflectorNode);return t.uvNode=this.uvNode,t.levelNode=this.levelNode,t.biasNode=this.biasNode,t.sampler=this.sampler,t.depthNode=this.depthNode,t.compareNode=this.compareNode,t.gradNode=this.gradNode,t.offsetNode=this.offsetNode,t._reflectorBaseNode=this._reflectorBaseNode,t}dispose(){super.dispose(),this._reflectorBaseNode.dispose()}},VG=class extends ve{static get type(){return"ReflectorBaseNode"}constructor(e,t={}){super();let{target:i=new dr,resolutionScale:r=1,generateMipmaps:s=!1,bounces:n=!0,depth:a=!1,samples:o=0}=t;this.textureNode=e,this.target=i,this.resolutionScale=r,t.resolution!==void 0&&(ut('ReflectorNode: The "resolution" parameter has been renamed to "resolutionScale".'),this.resolutionScale=t.resolution),this.generateMipmaps=s,this.bounces=n,this.depth=a,this.samples=o,this.updateBeforeType=n?Re.RENDER:Re.FRAME,this.virtualCameras=new WeakMap,this.renderTargets=new Map,this.forceUpdate=!1,this.hasOutput=!1}_updateResolution(e,t){let i=this.resolutionScale;t.getDrawingBufferSize(u0),e.setSize(Math.round(u0.width*i),Math.round(u0.height*i))}setup(e){return this._updateResolution(d0,e.renderer),super.setup(e)}dispose(){super.dispose();for(let e of this.renderTargets.values())e.dispose()}getVirtualCamera(e){let t=this.virtualCameras.get(e);return t===void 0&&(t=e.clone(),this.virtualCameras.set(e,t)),t}getRenderTarget(e){let t=this.renderTargets.get(e);return t===void 0&&(t=new zr(0,0,{type:as,samples:this.samples}),this.generateMipmaps===!0&&(t.texture.minFilter=eB,t.texture.generateMipmaps=!0),this.depth===!0&&(t.depthTexture=new Us),this.renderTargets.set(e,t)),t}updateBefore(e){if(this.bounces===!1&&c0)return!1;c0=!0;let{scene:t,camera:i,renderer:r,material:s}=e,{target:n}=this,a=this.getVirtualCamera(i),o=this.getRenderTarget(a);r.getDrawingBufferSize(u0),this._updateResolution(o,r),bd.setFromMatrixPosition(n.matrixWorld),Wb.setFromMatrixPosition(i.matrixWorld),wp.extractRotation(n.matrixWorld),Oh.set(0,0,1),Oh.applyMatrix4(wp),Sp.subVectors(bd,Wb);let l=Sp.dot(Oh)>0,h=!1;if(l===!0&&this.forceUpdate===!1){if(this.hasOutput===!1){c0=!1;return}h=!0}Sp.reflect(Oh).negate(),Sp.add(bd),wp.extractRotation(i.matrixWorld),l0.set(0,0,-1),l0.applyMatrix4(wp),l0.add(Wb),h0.subVectors(bd,l0),h0.reflect(Oh).negate(),h0.add(bd),a.coordinateSystem=i.coordinateSystem,a.position.copy(Sp),a.up.set(0,1,0),a.up.applyMatrix4(wp),a.up.reflect(Oh),a.lookAt(h0),a.near=i.near,a.far=i.far,a.updateMatrixWorld(),a.projectionMatrix.copy(i.projectionMatrix),vd.setFromNormalAndCoplanarPoint(Oh,bd),vd.applyMatrix4(a.matrixWorldInverse),ia.set(vd.normal.x,vd.normal.y,vd.normal.z,vd.constant);let u=a.projectionMatrix;Mp.x=(Math.sign(ia.x)+u.elements[8])/u.elements[0],Mp.y=(Math.sign(ia.y)+u.elements[9])/u.elements[5],Mp.z=-1,Mp.w=(1+u.elements[10])/u.elements[14],ia.multiplyScalar(1/ia.dot(Mp)),u.elements[2]=ia.x,u.elements[6]=ia.y,u.elements[10]=r.coordinateSystem===2001?ia.z-0:ia.z+1-0,u.elements[14]=ia.w,this.textureNode.value=o.texture,this.depth===!0&&(this.textureNode.getDepthNode().value=o.depthTexture),s.visible=!1;let d=r.getRenderTarget(),c=r.getMRT(),p=r.autoClear;r.setMRT(null),r.setRenderTarget(o),r.autoClear=!0;let m=t.name;t.name=(t.name||"Scene")+" [ Reflector ]",h?(r.clear(),this.hasOutput=!1):(r.render(t,a),this.hasOutput=!0),t.name=m,r.setMRT(c),r.setRenderTarget(d),r.autoClear=p,s.visible=!0,c0=!1,this.forceUpdate=!1}get resolution(){return ut('ReflectorNode: The "resolution" property has been renamed to "resolutionScale".'),this.resolutionScale}set resolution(e){ut('ReflectorNode: The "resolution" property has been renamed to "resolutionScale".'),this.resolutionScale=e}},zG=e=>new UG(e),Hb=new rf(-1,1,1,-1,0,1),GG=new class extends $r{constructor(e=!1){super();let t=e===!1?[0,-1,0,1,2,1]:[0,2,0,0,2,0];this.setAttribute("position",new Ht([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new Ht(t,2))}},_d=class extends xt{constructor(e=null){super(GG,e),this.camera=Hb,this.isQuadMesh=!0}async renderAsync(e){ut('QuadMesh: "renderAsync()" has been deprecated. Use "render()" and "await renderer.init();
27" when creating the renderer.'),await e.init(),e.render(this,Hb)}render(e){e.render(this,Hb)}},jG=new ge,$G=class extends Yn{static get type(){return"RTTNode"}constructor(e,t=null,i=null,r={type:as}){let s=new zr(t,i,r);super(s.texture,Mt()),this.isRTTNode=!0,this.node=e,this.width=t,this.height=i,this.pixelRatio=1,this.renderTarget=s,this.textureNeedsUpdate=!0,this.autoUpdate=!0,this._rttNode=null,this._quadMesh=new _d(new Ot),this.updateBeforeType=Re.RENDER}get autoResize(){return this.width===null}setup(e){return this._rttNode=this.node.context(e.getSharedContext()),this._quadMesh.material.name="RTT",this._quadMesh.material.needsUpdate=!0,super.setup(e)}setSize(e,t){this.width=e,this.height=t;let i=e*this.pixelRatio,r=t*this.pixelRatio;this.renderTarget.setSize(i,r),this.textureNeedsUpdate=!0}setPixelRatio(e){this.pixelRatio=e,this.setSize(this.width,this.height)}updateBefore({renderer:e}){if(this.textureNeedsUpdate===!1&&this.autoUpdate===!1)return;if(this.textureNeedsUpdate=!1,this.autoResize===!0){let r=e.getPixelRatio(),s=e.getSize(jG),n=Math.floor(s.width*r),a=Math.floor(s.height*r);(n!==this.renderTarget.width||a!==this.renderTarget.height)&&(this.renderTarget.setSize(n,a),this.textureNeedsUpdate=!0)}let t="RTT";this.node.name&&(t=this.node.name+" [ "+t+" ]"),this._quadMesh.material.fragmentNode=this._rttNode,this._quadMesh.name=t;let i=e.getRenderTarget();e.setRenderTarget(this.renderTarget),this._quadMesh.render(e),e.setRenderTarget(i)}clone(){let e=new Yn(this.value,this.uvNode,this.levelNode);return e.sampler=this.sampler,e.referenceNode=this,e}},SN=(e,...t)=>new $G(xe(e),...t),WG=(e,...t)=>e.isSampleNode||e.isTextureNode?e:e.isPassNode?e.getTextureNode():SN(e,...t),Td=k(([e,t,i],r)=>{let s;r.renderer.coordinateSystem===2001?(e=se(e.x,e.y.oneMinus()).mul(2).sub(1),s=Te(L(e,t),1)):s=Te(L(e.x,e.y.oneMinus(),t).mul(2).sub(1),1);let n=Te(i.mul(s));return n.xyz.div(n.w)}),HG=k(([e,t])=>{let i=t.mul(Te(e,1)),r=i.xy.div(i.w).mul(.5).add(.5).toVar();return se(r.x,r.y.oneMinus())}),qG=k(([e,t,i])=>{let r=tl(ni(t)),s=Ii(e.mul(r)).toVar(),n=ni(t,s).toVar(),a=ni(t,s.sub(Ii(2,0))).toVar(),o=ni(t,s.sub(Ii(1,0))).toVar(),l=ni(t,s.add(Ii(1,0))).toVar(),h=ni(t,s.add(Ii(2,0))).toVar(),u=ni(t,s.add(Ii(0,2))).toVar(),d=ni(t,s.add(Ii(0,1))).toVar(),c=ni(t,s.sub(Ii(0,1))).toVar(),p=ni(t,s.sub(Ii(0,2))).toVar(),m=kt(tt(C(2).mul(o).sub(a),n)).toVar(),g=kt(tt(C(2).mul(l).sub(h),n)).toVar(),f=kt(tt(C(2).mul(d).sub(u),n)).toVar(),y=kt(tt(C(2).mul(c).sub(p),n)).toVar(),x=Td(e,n,i).toVar();return ls(qa(m.lessThan(g).select(x.sub(Td(e.sub(se(C(1).div(r.x),0)),o,i)),x.negate().add(Td(e.add(se(C(1).div(r.x),0)),l,i))),f.lessThan(y).select(x.sub(Td(e.add(se(0,C(1).div(r.y))),d,i)),x.negate().add(Td(e.sub(se(0,C(1).div(r.y))),c,i)
27))))}),qb=k(([e])=>un(C(52.9829189).mul(un(zs(e,se(.06711056,.00583715)))))).setLayout({name:"interleavedGradientNoise",type:"float",inputs:[{name:"position",type:"vec2"}]}),mn=k(([e,t,i])=>{let r=C(2.399963229728653),s=Hr(C(e).add(.5).div(C(t))),n=C(e).mul(r).add(i);return se(dn(n),qr(n)).mul(s)}).setLayout({name:"vogelDiskSample",type:"vec2",inputs:[{name:"sampleIndex",type:"int"},{name:"samplesCount",type:"int"},{name:"phi",type:"float"}]}),XG=class extends ve{static get type(){return"SampleNode"}constructor(e,t=null){super(),this.callback=e,this.uvNode=t,this.isSampleNode=!0}setup(){return this.sample(Mt())}sample(e){return this.callback(e)}},YG=(e,t=null)=>new XG(e,xe(t)),io=class gg extends ve{static get type(){return"EventNode"}constructor(t,i){super("void"),this.eventType=t,this.callback=i,t===gg.OBJECT?this.updateType=Re.OBJECT:t===gg.MATERIAL?this.updateType=Re.RENDER:t===gg.BEFORE_OBJECT?this.updateBeforeType=Re.OBJECT:t===gg.BEFORE_MATERIAL&&(this.updateBeforeType=Re.RENDER)}update(t){this.callback(t)}updateBefore(t){this.callback(t)}};io.OBJECT="object",io.MATERIAL="material",io.BEFORE_OBJECT="beforeObject",io.BEFORE_MATERIAL="beforeMaterial";var p0=(e,t)=>new io(e,t).toStack(),KG=e=>p0(io.OBJECT,e),ZG=e=>p0(io.MATERIAL,e),JG=e=>p0(io.BEFORE_OBJECT,e),QG=e=>p0(io.BEFORE_MATERIAL,e),e7=class extends cr{constructor(e,t,i=Float32Array){let r=ArrayBuffer.isView(e)?e:new i(e*t);super(r,t),this.isStorageInstancedBufferAttribute=!0}},t7=class extends jr{constructor(e,t,i=Float32Array){let r=ArrayBuffer.isView(e)?e:new i(e*t);super(r,t),this.isStorageBufferAttribute=!0}},i7=(e,t="float")=>{let i,r;return t.isStruct===!0?(i=t.layout.getLength(),r=sf("float")):(i=aC(t),r=sf(t)),ll(new t7(e,i,r),t,e)},r7=(e,t="float")=>{let i,r;t.isStruct===!0?(i=t.layout.getLength(),r=sf("float")):(i=aC(t),r=sf(t));let s=new e7(e,i,r);return ll(s,t,s.count)},s7=pe(class extends ve{static get type(){return"PointUVNode"}constructor(){super("vec2"),this.isPointUVNode=!0}generate(){return"vec2( gl_PointCoord.x, 1.0 - gl_PointCoord.y )"}}),Cp=new In,Xb=new $e,MN=be(0).setGroup(we).onRenderUpdate(({scene:e})=>e.backgroundBlurriness),Yb=be(1).setGroup(we).onRenderUpdate(({scene:e})=>e.backgroundIntensity),CN=be(new $e).setGroup(we).onRenderUpdate(({scene:e})=>{let t=e.background;return t!==null&&t.isTexture&&t.mapping!==300?(Cp.copy(e.backgroundRotation),Cp.x*=-1,Cp.y*=-1,Cp.z*=-1,Xb.makeRotationFromEuler(Cp)):Xb.identity(),Xb}),RN=Fe(class extends Yn{static get type(){return"StorageTextureNode"}constructor(e,t,i=null){super(e,t),this.storeNode=i,this.mipLevel=0,this.isStorageTextureNode=!0,this.access=pr.WRITE_ONLY}getInputType(){return"storageTexture"}setup(e){super.setup(e);let t=e.getNodeProperties(this);return t.storeNode=this.storeNode,t}setAccess(e){return this.access=e,this}
27setMipLevel(e){return this.mipLevel=e,this}generate(e,t){return this.storeNode===null?super.generate(e,t):(this.generateStore(e),"")}generateSnippet(e,t,i,r,s,n,a,o,l){let h=this.value;return e.generateStorageTextureLoad(h,t,i,r,n,l)}toReadWrite(){return this.setAccess(pr.READ_WRITE)}toReadOnly(){return this.setAccess(pr.READ_ONLY)}toWriteOnly(){return this.setAccess(pr.WRITE_ONLY)}generateStore(e){let{uvNode:t,storeNode:i,depthNode:r}=e.getNodeProperties(this),s=super.generate(e,"property"),n=t.build(e,this.value.is3DTexture===!0?"uvec3":"uvec2"),a=i.build(e,"vec4"),o=r?r.build(e,"int"):null,l=e.generateTextureStore(this.value,s,n,o,a);e.addLineFlowCode(l,this)}clone(){let e=super.clone();return e.storeNode=this.storeNode,e.mipLevel=this.mipLevel,e.access=this.access,e}}).setParameterLength(1,3),n7=(e,t,i)=>{let r;return e.isStorageTextureNode===!0?(r=e.clone(),r.uvNode=t,r.storeNode=i):r=RN(e,t,i),i!==null&&r.toStack(),r},a7=k(({texture:e,uv:t})=>{let i=1e-4,r=L().toVar();return Se(t.x.lessThan(i),()=>{r.assign(L(1,0,0))}).ElseIf(t.y.lessThan(i),()=>{r.assign(L(0,1,0))}).ElseIf(t.z.lessThan(i),()=>{r.assign(L(0,0,1))}).ElseIf(t.x.greaterThan(1-i),()=>{r.assign(L(-1,0,0))}).ElseIf(t.y.greaterThan(1-i),()=>{r.assign(L(0,-1,0))}).ElseIf(t.z.greaterThan(1-i),()=>{r.assign(L(0,0,-1))}).Else(()=>{let s=.01,n=e.sample(t.add(L(-.01,0,0))).r.sub(e.sample(t.add(L(s,0,0))).r),a=e.sample(t.add(L(0,-.01,0))).r.sub(e.sample(t.add(L(0,s,0))).r),o=e.sample(t.add(L(0,0,-.01))).r.sub(e.sample(t.add(L(0,0,s))).r);r.assign(L(n,a,o))}),r.normalize()}),Kb=Fe(class extends Yn{static get type(){return"Texture3DNode"}constructor(e,t=null,i=null){super(e,t,i),this.isTexture3DNode=!0}getInputType(){return"texture3D"}getDefaultUV(){return L(.5,.5,.5)}setUpdateMatrix(){}generateUV(e,t){return t.build(e,this.sampler===!0?"vec3":"ivec3")}generateOffset(e,t){return t.build(e,"ivec3")}normal(e){return a7({texture:this,uv:e})}}).setParameterLength(1,3),o7=(...e)=>Kb(...e).setSampler(!1),l7=(e,t,i)=>Kb(e,t).level(i),h7=class extends jf{static get type(){return"UserDataNode"}constructor(e,t,i=null){super(e,t,i),this.userData=i}updateReference(e){return this.reference=this.userData===null?e.object.userData:this.userData,this.reference}},u7=(e,t,i)=>new h7(e,t,i),EN=new WeakMap,d7=class extends ei{static get type(){return"VelocityNode"}constructor(){super("vec2"),this.projectionMatrix=null,this.updateType=Re.OBJECT,this.updateAfterType=Re.OBJECT,this.previousModelWorldMatrix=be(new $e),this.previousProjectionMatrix=be(new $e).setGroup(we),this.previousCameraViewMatrix=be(new $e)}setProjectionMatrix(e){this.projectionMatrix=e}update({frameId:e,camera:t,object:i}){let r=NN(i);this.previousModelWorldMatrix.value.copy(r);let s=AN(t);s.frameId!==e&&(s.frameId=e,s.previousProjectionMatrix===void 0?(s.previousProjectionMatrix=new $e,s.previousCameraViewMatrix=new $e,s.currentProjectionMatrix=new $e,s.currentCameraViewMatrix=new $e,s.previousProjectionMatrix.copy(this.projectionMatrix||t.projectionMatrix),s.previousCameraViewMatrix.copy(t.matrixWorldInverse)):(s.previousProjectionMatrix.copy(s.currentProjectionMatrix),s.previousCameraViewMatrix.copy(s.currentCameraViewMatrix)),s.currentProjectionMatrix.copy(this.projectionMatrix||t.projectionMatrix),s.currentCameraViewMatrix.copy(t.matrixWorldInverse),this.previousProjectionMatrix.value.copy(s.previousProjectionMatrix),this.previousCameraViewMatrix.value.copy(s.previousCameraViewMatrix))}updateAfter({object:e}){NN(e).copy(e.matrixWorld)}setup(){let e=this.projectionMatrix===null?Za:be(this.projectionMatrix),t=this.previousCameraViewMatrix.mul(this.previousModelWorldMatrix),i=e.mul(nl).mul(ii),r=this.previousProjectionMatrix.mul(t).mul(hd);return tt(i.xy.div(i.w),r.xy.div(r.w))}};function AN(e){let t=EN.get(e);return t===void 0&&(t={},EN.set(e,t)),t}function NN(e,t=0){let i=AN(e),r=i[t];return r===void 0&&(i[t]=r=new $e,i[t].copy(e.matrixWorld)),r}var c7=pe(d7),p7=k(([e])=>Zb(e.rgb)),m7=k(([e,t=C(1)])=>t.mix(Zb(e.rgb),e.rgb)),g7=k(([e,t=C(1)])=>{let i=wi(e.r,e.g,e.b).div(3),r=e.r.max(e.g.max(e.b)),s=r.sub(i).mul(t).mul(-3);return Ze(e.rgb,r,s)}),f7=k(([e,t=C(1)])=>{let i=L(.57735,.57735,.57735),r=t.cos();return L(e.rgb.mul(r).add(i.cross(e.rgb).mul(t.sin()).add(i.mul(zs(i,e.rgb).mul(r.oneMinus())))))}),Zb=(e,t=L(lt.getLuminanceCoefficients(new F)))=>zs(e,t),y7=k(([e,t=L(1),i=L(0),r=L(1),s=C(1),n=L(lt.getLuminanceCoefficients(new F,Pc))])=>{let a=e.rgb.dot(L(n)),o=ti(e.rgb.mul(t).add(i),0).toVar(),l=o.pow(r).toVar();return Se(o.r.greaterThan(0),()=>{o.r.assign(l.r)}),Se(o.g.greaterThan(0),()=>{o.g.assign(l.g)}),Se(o.b.greaterThan(0),()=>{o.b.assign(l.b)}),o.assign(a.add(o.sub(a).mul(s))),Te(o.rgb,e.a)}),x7=k(([e,t])=>e.mul(t).floor().div(t)),m0=null,v7=Fe(class extends Xf{static get type(){return"ViewportSharedTextureNode"}constructor(e=Kn,t=null){m0===null&&(m0=new Cx),super(e,t,m0)}getTextureForReference(){return m0}updateReference(){return this}}).setParameterLength(0,2),g0=new ge,LN=class extends Yn{static get type(){return"PassTextureNode"}constructor(e,t){super(t),this.passNode=e,this.isPassTextureNode=!0,this.setUpdateMatrix(!1)}setup(e){let t=e.getNodeProperties(this);return t.passNode=this.passNode,super.setup(e)}clone(){return new this.constructor(this.passNode,this.value)}},PN=class extends LN{static get type(){return"PassMultipleTextureNode"}constructor(e,t,i=!1){super(e,null),this.textureName=t,this.previousTexture=i,this.isPassMultipleTextureNode=!0}updateTexture(){this.value=this.previousTexture?this.passNode.getPreviousTexture(this.textureName):this.passNode.getTexture(this.textureName)}setup(e){return this.updateTexture(),super.setup(e)}clone(){let e=new this.constructor(this.passNode,this.textureName,this.previousTexture);return e.uvNode=this.uvNode,e.levelNode=this.levelNode,e.biasNode=this.biasNode,e.sampler=this.sampler,e.depthNode=this.depthNode,e.compareNode=this.compareNode,e.gradNode=this.gradNode,e.offsetNode=this.offsetNode,e}},ml=class dO extends ei{static get type(){return"PassNode"}constructor(t,i,r,s={}){super("vec4"),this.scope=t,this.scene=i,this.camera=r,this.options=s,this._pixelRatio=1,this._width=1,this._height=1;let n=new Us;n.isRenderTargetTexture=!0,n.name="depth";let a=new zr(this._width*this._pixelRatio,this._height*this._pixelRatio,{type:as,...s});a.texture.name="output",a.depthTexture=n,this.renderTarget=a,this.overrideMaterial=null,this.transparent=!0,this.opaque=!0,this.contextNode=null,this._contextNodeCache=null,this._textures={output:a.texture,depth:n},this._textureNodes={},this._linearDepthNodes={},this._viewZNodes={},this._previousTextures={},this._previousTextureNodes={},this._cameraNear=be(0),this._cameraFar=be(0),this._mrt=null,this._layers=null,this._resolutionScale=1,this._viewport=null,this._scissor=null,this.isPassNode=!0,this.updateBeforeType=Re.FRAME,this.global=!0}setResolutionScale(t){return this._resolutionScale=t,this}getResolutionScale(){return this._resolutionScale}setResolution(t){return de("PassNode: .setResolution() is deprecated. Use .setRe
27solutionScale() instead."),this.setResolutionScale(t)}getResolution(){return de("PassNode: .getResolution() is deprecated. Use .getResolutionScale() instead."),this.getResolutionScale()}setLayers(t){return this._layers=t,this}getLayers(){return this._layers}setMRT(t){return this._mrt=t,this}getMRT(){return this._mrt}getTexture(t){let i=this._textures[t];return i===void 0&&(i=this.renderTarget.texture.clone(),i.name=t,this._textures[t]=i,this.renderTarget.textures.push(i)),i}getPreviousTexture(t){let i=this._previousTextures[t];return i===void 0&&(i=this.getTexture(t).clone(),this._previousTextures[t]=i),i}toggleTexture(t){let i=this._previousTextures[t];if(i!==void 0){let r=this._textures[t],s=this.renderTarget.textures.indexOf(r);this.renderTarget.textures[s]=i,this._textures[t]=i,this._previousTextures[t]=r,this._textureNodes[t].updateTexture(),this._previousTextureNodes[t].updateTexture()}}getTextureNode(t="output"){let i=this._textureNodes[t];return i===void 0&&(i=new PN(this,t),i.updateTexture(),this._textureNodes[t]=i),i}getPreviousTextureNode(t="output"){let i=this._previousTextureNodes[t];return i===void 0&&(this._textureNodes[t]===void 0&&this.getTextureNode(t),i=new PN(this,t,!0),i.updateTexture(),this._previousTextureNodes[t]=i),i}getViewZNode(t="depth"){let i=this._viewZNodes[t];if(i===void 0){let r=this._cameraNear,s=this._cameraFar;this._viewZNodes[t]=i=yb(this.getTextureNode(t),r,s)}return i}getLinearDepthNode(t="depth"){let i=this._linearDepthNodes[t];if(i===void 0){let r=this._cameraNear,s=this._cameraFar,n=this.getViewZNode(t);this._linearDepthNodes[t]=i=gd(n,r,s)}return i}async compileAsync(t){let i=t.getRenderTarget(),r=t.getMRT();t.setRenderTarget(this.renderTarget),t.setMRT(this._mrt),await t.compileAsync(this.scene,this.camera),t.setRenderTarget(i),t.setMRT(r)}setup({renderer:t}){return this.renderTarget.samples=this.options.samples===void 0?t.samples:this.options.samples,this.renderTarget.texture.type=t.getOutputBufferType(),this.scope===dO.COLOR?this.getTextureNode():this.getLinearDepthNode()}updateBefore(t){let{renderer:i}=t,{scene:r}=this,s,n,a=i.getOutputRenderTarget();a&&a.isXRRenderTarget===!0?(n=1,s=i.xr.getCamera(),i.xr.updateCamera(s),g0.set(a.width,a.height)):(s=this.camera,n=i.getPixelRatio(),i.getSize(g0)),this._pixelRatio=n,this.setSize(g0.width,g0.height);let o=i.getRenderTarget(),l=i.getMRT(),h=i.autoClear,u=i.transparent,d=i.opaque,c=s.layers.mask,p=i.contextNode,m=r.overrideMaterial;this._cameraNear.value=s.near,this._cameraFar.value=s.far,this._layers!==null&&(s.layers.mask=this._layers.mask);for(let f in this._previousTextures)this.toggleTexture(f);this.overrideMaterial!==null&&(r.overrideMaterial=this.overrideMaterial),i.setRenderTarget(this.renderTarget),i.setMRT(this._mrt),i.autoClear=!0,i.transparent=this.transparent,i.opaque=this.opaque,this.contextNode!==null&&((this._contextNodeCache===null||this._contextNodeCache.version!==this.version)&&(this._contextNodeCache={version:this.version,context:Xa({...i.contextNode.getFlowContextData(),...this.contextNode.getFlowContextData()})}),i.contextNode=this._contextNodeCache.context);let g=r.name;r.name=this.name?this.name:r.name,i.render(r,s),r.name=g,r.overrideMaterial=m,i.setRenderTarget(o),i.setMRT(l),i.autoClear=h,i.transparent=u,i.opaque=d,i.contextNode=p,s.layers.mask=c}setSize(t,i){this._width=t,this._height=i;let r=Math.floor(this._width*this._pixelRatio*this._resolutionScale),s=Math.floor(this._height*this._pixelRatio*this._resolutionScale);this.renderTarget.setSize(r,s),this._scissor!==null&&this.renderTarget.scissor.copy(this._scissor),this._viewport!==null&&this.renderTarget.viewport.copy(this._viewport)}setScissor(t,i,r,s){t===null?this._scissor=null:(this._scissor===null&&(this._scissor=new yt),t.isVector4?this._scissor.copy(t):this._scissor.set(t,i,r,s),this._scissor.multiplyScalar(this._pixelRatio*this._resolutionScale).floor())}setViewport(t,i,r,s){t===null?this._viewport=null:(this._viewport===null&&(this._viewport=new yt),t.isVector4?this._viewport.copy(t):this._viewport.set(t,i,r,s),this._viewport.multiplyScalar(this._pixelRatio*this._resolutionScale).floor())}setPixelRatio(t){this._pixelRatio=t,this.setSize(this._width,this._height)}dispose(){this.renderTarget.dispose()}};ml.COLOR="color",ml.DEPTH="depth";var b7=(e,t,i)=>new ml(ml.COLOR,e,t,i),_7=(e,t)=>new LN(e,t),T7=(e,t,i)=>new ml(ml.DEPTH,e,t,i),w7=class extends ml{static get type(){return"ToonOutlinePassNode"}constructor(e,t,i,r,s){super(ml.COLOR,e,t),this.colorNode=i,this.thicknessNode=r,this.alphaNode=s,this._materialCache=new WeakMap,this.name="Outline Pass"}updateBefore(e){let{renderer:t}=e,i=t.getRenderObjectFunction();t.setRenderObjectFunction((r,s,n,a,o,l,h,u)=>{if((o.isMeshToonMaterial||o.isMeshToonNodeMaterial)&&o.wireframe===!1){let d=this._getOutlineMaterial(o);t.renderObject(r,s,n,a,d,l,h,u)}t.renderObject(r,s,n,a,o,l,h,u)}),super.updateBefore(e),t.setRenderObjectFunction(i)}_createMaterial(){let e=new Ot;e.isMeshToonOutlineMaterial=!0,e.name="Toon_Outline",e.side=1;let t=us.negate(),i=Za.mul(nl),r=C(1),s=i.mul(Te(ii,1)),n=i.mul(Te(ii.add(t),1)),a=ls(s.sub(n));return e.vertexNode=s.add(a.mul(this.thicknessNode).mul(s.w).mul(r)),e.colorNode=Te(this.colorNode,this.alphaNode),e}_getOutlineMaterial(e){let t=this._materialCache.get(e);return t===void 0&&(t=this._createMaterial(),this._materialCache.set(e,t)),t}},S7=(e,t,i=new Ke(0,0,0),r=.003,s=1)=>new w7(e,t,xe(i),xe(r),xe(s)),kN=k(([e,t])=>
27e.mul(t).clamp()).setLayout({name:"linearToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),IN=k(([e,t])=>(e=e.mul(t),e.div(e.add(1)).clamp())).setLayout({name:"reinhardToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),FN=k(([e,t])=>{e=e.mul(t),e=e.sub(.004).max(0);let i=e.mul(e.mul(6.2).add(.5)),r=e.mul(e.mul(6.2).add(1.7)).add(.06);return i.div(r).pow(2.2)}).setLayout({name:"cineonToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),M7=k(([e])=>{let t=e.mul(e.add(.0245786)).sub(90537e-9),i=e.mul(e.add(.432951).mul(.983729)).add(.238081);return t.div(i)}),DN=k(([e,t])=>{let i=tr(.59719,.35458,.04823,.076,.90834,.01566,.0284,.13383,.83777),r=tr(1.60475,-.53108,-.07367,-.10208,1.10813,-.00605,-.00327,-.07276,1.07602);return e=e.mul(t).div(.6),e=i.mul(e),e=M7(e),e=r.mul(e),e.clamp()}).setLayout({name:"acesFilmicToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),C7=tr(L(1.6605,-.1246,-.0182),L(-.5876,1.1329,-.1006),L(-.0728,-.0083,1.1187)),R7=tr(L(.6274,.0691,.0164),L(.3293,.9195,.088),L(.0433,.0113,.8956)),E7=k(([e])=>{let t=L(e).toVar(),i=L(t.mul(t)).toVar(),r=L(i.mul(i)).toVar();return C(15.5).mul(r.mul(i)).sub(Pe(40.14,r.mul(t))).add(Pe(31.96,r).sub(Pe(6.868,i.mul(t))).add(Pe(.4298,i).add(Pe(.1191,t).sub(.00232))))}),ON=k(([e,t])=>{let i=L(e).toVar(),r=tr(L(.856627153315983,.137318972929847,.11189821299995),L(.0951212405381588,.761241990602591,.0767994186031903),L(.0482516061458583,.101439036467562,.811302368396859)),s=tr(L(1.1271005818144368,-.1413297634984383,-.14132976349843826),L(-.11060664309660323,1.157823702216272,-.11060664309660294),L(-.016493938717834573,-.016493938717834257,1.2519364065950405)),n=C(-12.47393),a=C(4.026069);return i.mulAssign(t),i.assign(R7.mul(i)),i.assign(r.mul(i)),i.assign(ti(i,1e-10)),i.assign(Hn(i)),i.assign(i.sub(n).div(a.sub(n))),i.assign(cn(i,0,1)),i.assign(E7(i)),i.assign(s.mul(i)),i.assign(Gs(ti(L(0),i),L(2.2))),i.assign(C7.mul(i)),i.assign(cn(i,0,1)),i}).setLayout({name:"agxToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),BN=k(([e,t])=>{let i=C(.76),r=C(.15);e=e.mul(t);let s=hs(e.r,hs(e.g,e.b)),n=wr(s.lessThan(.08),s.sub(Pe(6.25,s.mul(s))),.04);e.subAssign(n);let a=ti(e.r,ti(e.g,e.b));Se(a.lessThan(i),()=>e);let o=tt(1,i),l=tt(1,o.mul(o).div(a.add(o.sub(i))));e.mulAssign(l.div(a));let h=tt(1,_s(1,r.mul(a.sub(l)).add(1)));return Ze(e,L(l),h)}).setLayout({name:"neutralToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),Wi=class extends ve{static get type(){return"CodeNode"}constructor(e="",t=[],i=""){super("code"),this.isCodeNode=!0,this.global=!0,this.code=e,this.includes=t,this.language=i}setIncludes(e){return this.includes=e,this}getIncludes(){return this.includes}generate(e){let t=this.getIncludes(e);for(let r of t)r.build(e);let i=e.getCodeFromNode(this,this.getNodeType(e));return i.code=this.code,i.code}serialize(e){super.serialize(e),e.code=this.code,e.language=this.language}deserialize(e){super.deserialize(e),this.code=e.code,this.language=e.language}},f0=Fe(Wi).setParameterLength(1,3),A7=(e,t)=>f0(e,t,"js"),N7=(e,t)=>f0(e,t,"wgsl"),L7=(e,t)=>f0(e,t,"glsl"),UN=class extends Wi{static get type(){return"FunctionNode"}constructor(e="",t=[],i=""){super(e,t,i)}generateNodeType(e){return this.getNodeFunction(e).type}getMemberType(e,t){let i=this.getNodeType(e);return e.getStructTypeNode(i).getMemberType(e,t)}getInputs(e){return this.getNodeFunction(e).inputs}getNodeFunction(e){let t=e.getDataFromNode(this),i=t.nodeFunction;return i===void 0&&(i=e.parser.parseFunction(this.code),t.nodeFunction=i),i}generate(e,t){super.generate(e);let i=this.getNodeFunction(e),r=i.name,s=i.type,n=e.getCodeFromNode(this,s);r!==""&&(n.name=r);let a=e.getPropertyName(n);return n.code=this.getNodeFunction(e).getCode(a)+`
28`,t==="property"?a:e.format(`${a}()`,s,t)}},VN=(e,t=[],i="")=>{for(let n=0;n<t.length;n++){let a=t[n];typeof a=="function"&&(t[n]=a.functionNode)}let r=new UN(e,t,i),s=(...n)=>r.call(...n);return s.functionNode=r,s},P7=(e,t)=>VN(e,t,"glsl"),k7=(e,t)=>VN(e,t,"wgsl");function Jb(e){let t,i=e.context.getViewZ;return i!==void 0&&(t=i(this)),(t||yi.z).negate()}var zN=k(([e,t],i)=>pn(e,t,Jb(i))),GN=k(([e],t)=>{let i=Jb(t);return e.mul(e,i,i).negate().exp().oneMinus()}),I7=k(([e,t],i)=>{let r=Jb(i),s=t.sub(Zn.y).max(0).toConst().mul(r).toConst();return e.mul(e,s,s).negate().exp().oneMinus()}),Qb=k(([e,t])=>Te(t.toFloat().mix(ad.rgb,e.toVec3()),ad.a)),wd=null,Sd=null,F7=Fe(class extends ve{static get type(){return"RangeNode"}constructor(e=C(),t=C()){super(),this.minNode=e,this.maxNode=t}getVectorLength(e){let t=this.getConstNode(this.minNode),i=this.getConstNode(this.maxNode),r=e.getTypeLength(qo(t.value)),s=e.getTypeLength(qo(i.value));return r>s?r:s}generateNodeType(e){return e.object.count>1?e.getTypeFromLength(this.getVectorLength(e)):"float"}getConstNode(e){let t=null;if(e.traverse(i=>{i.isConstNode===!0&&(t=i)}),t===null)throw new $R('THREE.TSL: No "ConstNode" found in node graph.',this.stackTrace);return t}setup(e){let t=e.object,i=null;if(t.count>1){let r=this.getConstNode(this.minNode),s=this.getConstNode(this.maxNode),n=r.value,a=s.value,o=e.getTypeLength(qo(n)),l=e.getTypeLength(qo(a));wd||=new yt,Sd||=new yt,wd.setScalar(0),Sd.setScalar(0),o===1?wd.setScalar(n):n.isColor?wd.set(n.r,n.g,n.b,1):wd.set(n.x,n.y,n.z||0,n.w||0),l===1?Sd.setScalar(a):a.isColor?Sd.set(a.r,a.g,a.b,1):Sd.set(a.x,a.y,a.z||0,a.w||0);let h=4*t.count,u=new Float32Array(h);for(let c=0;c<h;c++){let p=c%4,m=wd.getComponent(p),g=Sd.getComponent(p);u[c]=aM.lerp(m,g,Math.random())}let d=this.getNodeType(e);if(t.count*4*4<=e.getUniformBufferLimit())i=cp(u,"vec4",t.count).element
28(Jn).convert(d);else{let c=new cr(u,4);e.geometry.setAttribute("__range"+this.id,c),i=Af(c).convert(d)}}else i=C(0);return i}}).setParameterLength(2),D7=class extends ve{static get type(){return"ComputeBuiltinNode"}constructor(e,t){super(t),this._builtinName=e}getHash(e){return this.getBuiltinName(e)}generateNodeType(){return this.nodeType}setBuiltinName(e){return this._builtinName=e,this}getBuiltinName(){return this._builtinName}hasBuiltin(e){return e.hasBuiltin(this._builtinName)}generate(e,t){let i=this.getBuiltinName(e),r=this.getNodeType(e);return e.shaderStage==="compute"?e.format(i,r,t):(de(`ComputeBuiltinNode: Compute built-in value ${i} can not be accessed in the ${e.shaderStage} stage`),e.generateConst(r))}serialize(e){super.serialize(e),e.global=this.global,e._builtinName=this._builtinName}deserialize(e){super.deserialize(e),this.global=e.global,this._builtinName=e._builtinName}},Rp=(e,t)=>new D7(e,t),O7=Rp("numWorkgroups","uvec3"),B7=Rp("workgroupId","uvec3"),U7=Rp("globalId","uvec3"),V7=Rp("localId","uvec3"),z7=Rp("subgroupSize","uint"),e_=Fe(class extends ve{constructor(e){super(),this.scope=e}generate(e){let{scope:t}=this,{renderer:i}=e;i.backend.isWebGLBackend===!0?e.addFlowCode(`	// ${t}Barrier 
29`):e.addLineFlowCode(`${t}Barrier()`,this)}}),G7=()=>e_("workgroup").toStack(),j7=()=>e_("storage").toStack(),$7=()=>e_("texture").toStack(),W7=class extends Th{constructor(e,t){super(e,t),this.isWorkgroupInfoElementNode=!0}generate(e,t){let i,r=e.context.assign;if(i=super.generate(e),r!==!0){let s=this.getNodeType(e);i=e.format(i,s,t)}return i}},H7=class extends ve{constructor(e,t,i=0){super(t),this.bufferType=t,this.bufferCount=i,this.isWorkgroupInfoNode=!0,this.elementType=t,this.scope=e,this.name=""}setName(e){return this.name=e,this}label(e){return de('TSL: "label()" has been deprecated. Use "setName()" instead.',new fi),this.setName(e)}setScope(e){return this.scope=e,this}getElementType(){return this.elementType}getInputType(){return`${this.scope}Array`}element(e){return new W7(this,e)}generate(e){let t=this.name===""?`${this.scope}Array_${this.id}`:this.name;return e.getScopedArray(t,this.scope.toLowerCase(),this.bufferType,this.bufferCount)}},q7=(e,t)=>new H7("Workgroup",e,t),Hi=class extends ve{static get type(){return"AtomicFunctionNode"}constructor(e,t,i){super("uint"),this.method=e,this.pointerNode=t,this.valueNode=i,this.parents=!0}getInputType(e){return this.pointerNode.getNodeType(e)}generateNodeType(e){return this.getInputType(e)}generate(e){let t=e.getNodeProperties(this),i=t.parents,r=this.method,s=this.getNodeType(e),n=this.getInputType(e),a=this.pointerNode,o=this.valueNode,l=[];l.push(`&${a.build(e,n)}`),o!==null&&l.push(o.build(e,n));let h=`${e.getMethod(r,s)}( ${l.join(", ")} )`;if(i&&i.length===1&&i[0].isStackNode===!0)e.addLineFlowCode(h,this);else return t.constNode===void 0&&(t.constNode=Ts(h,s).toConst()),t.constNode.build(e)}};Hi.ATOMIC_LOAD="atomicLoad",Hi.ATOMIC_STORE="atomicStore",Hi.ATOMIC_ADD="atomicAdd",Hi.ATOMIC_SUB="atomicSub",Hi.ATOMIC_MAX="atomicMax",Hi.ATOMIC_MIN="atomicMin",Hi.ATOMIC_AND="atomicAnd",Hi.ATOMIC_OR="atomicOr",Hi.ATOMIC_XOR="atomicXor";var X7=Fe(Hi),ra=(e,t,i)=>X7(e,t,i).toStack(),Y7=e=>ra(Hi.ATOMIC_LOAD,e,null),K7=(e,t)=>ra(Hi.ATOMIC_STORE,e,t),Z7=(e,t)=>ra(Hi.ATOMIC_ADD,e,t),J7=(e,t)=>ra(Hi.ATOMIC_SUB,e,t),Q7=(e,t)=>ra(Hi.ATOMIC_MAX,e,t),e9=(e,t)=>ra(Hi.ATOMIC_MIN,e,t),t9=(e,t)=>ra(Hi.ATOMIC_AND,e,t),i9=(e,t)=>ra(Hi.ATOMIC_OR,e,t),r9=(e,t)=>ra(Hi.ATOMIC_XOR,e,t),fe=class ko extends ei{static get type(){return"SubgroupFunctionNode"}constructor(t,i=null,r=null){super(),this.method=t,this.aNode=i,this.bNode=r}getInputType(t){let i=this.aNode?this.aNode.getNodeType(t):null,r=this.bNode?this.bNode.getNodeType(t):null;return(t.isMatrix(i)?0:t.getTypeLength(i))>(t.isMatrix(r)?0:t.getTypeLength(r))?i:r}generateNodeType(t){let i=this.method;return i===ko.SUBGROUP_ELECT?"bool":i===ko.SUBGROUP_BALLOT?"uvec4":this.getInputType(t)}generate(t,i){let r=this.method,s=this.getNodeType(t),n=this.getInputType(t),a=this.aNode,o=this.bNode,l=[];if(r===ko.SUBGROUP_BROADCAST||r===ko.SUBGROUP_SHUFFLE||r===ko.QUAD_BROADCAST){let u=o.getNodeType(t);l.push(a.build(t,s),o.build(t,u==="float"?"int":s))}else r===ko.SUBGROUP_SHUFFLE_XOR||r===ko.SUBGROUP_SHUFFLE_DOWN||r===ko.SUBGROUP_SHUFFLE_UP?l.push(a.build(t,s),o.build(t,"uint")):(a!==null&&l.push(a.build(t,n)),o!==null&&l.push(o.build(t,n)));let h=l.length===0?"()":`( ${l.join(", ")} )`;return t.format(`${t.getMethod(r,s)}${h}`,s,i)}serialize(t){super.serialize(t),t.method=this.method}deserialize(t){super.deserialize(t),this.method=t.method}};fe.SUBGROUP_ELECT="subgroupElect",fe.SUBGROUP_BALLOT="subgroupBallot",fe.SUBGROUP_ADD="subgroupAdd",fe.SUBGROUP_INCLUSIVE_ADD="subgroupInclusiveAdd",fe.SUBGROUP_EXCLUSIVE_AND="subgroupExclusiveAdd",fe.SUBGROUP_MUL="subgroupMul",fe.SUBGROUP_INCLUSIVE_MUL="subgroupInclusiveMul",fe.SUBGROUP_EXCLUSIVE_MUL="subgroupExclusiveMul",fe.SUBGROUP_AND="subgroupAnd",fe.SUBGROUP_OR="subgroupOr",fe.SUBGROUP_XOR="subgroupXor",fe.SUBGROUP_MIN="subgroupMin",fe.SUBGROUP_MAX="subgroupMax",fe.SUBGROUP_ALL="subgroupAll",fe.SUBGROUP_ANY="subgroupAny",fe.SUBGROUP_BROADCAST_FIRST="subgroupBroadcastFirst",fe.QUAD_SWAP_X="quadSwapX",fe.QUAD_SWAP_Y="quadSwapY",fe.QUAD_SWAP_DIAGONAL="quadSwapDiagonal",fe.SUBGROUP_BROADCAST="subgroupBroadcast",fe.SUBGROUP_SHUFFLE="subgroupShuffle",fe.SUBGROUP_SHUFFLE_XOR="subgroupShuffleXor",fe.SUBGROUP_SHUFFLE_UP="subgroupShuffleUp",fe.SUBGROUP_SHUFFLE_DOWN="subgroupShuffleDown",fe.QUAD_BROADCAST="quadBroadcast";var s9=ne(fe,fe.SUBGROUP_ELECT).setParameterLength(0),n9=ne(fe,fe.SUBGROUP_BALLOT).setParameterLength(1),a9=ne(fe,fe.SUBGROUP_ADD).setParameterLength(1),o9=ne(fe,fe.SUBGROUP_INCLUSIVE_ADD).setParameterLength(1),l9=ne(fe,fe.SUBGROUP_EXCLUSIVE_AND).setParameterLength(1),h9=ne(fe,fe.SUBGROUP_MUL).setParameterLength(1),u9=ne(fe,fe.SUBGROUP_INCLUSIVE_MUL).setParameterLength(1),d9=ne(fe,fe.SUBGROUP_EXCLUSIVE_MUL).setParameterLength(1),c9=ne(fe,fe.SUBGROUP_AND).setParameterLength(1),p9=ne(fe,fe.SUBGROUP_OR).setParameterLength(1),m9=ne(fe,fe.SUBGROUP_XOR).setParameterLength(1),g9=ne(fe,fe.SUBGROUP_MIN).setParameterLength(1),f9=ne(fe,fe.SUBGROUP_MAX).setParameterLength(1),y9=ne(fe,fe.SUBGROUP_ALL).setParameterLength(0),x9=ne(fe,fe.SUBGROUP_ANY).setParameterLength(0),v9=ne(fe,fe.SUBGROUP_BROADCAST_FIRST).setParameterLength(2),b9=ne(fe,fe.QUAD_SWAP_X).setParameterLength(1),_9=ne(fe,fe.QUAD_SWAP_Y).setParameterLength(1),T9=ne(fe,fe.QUAD_SWAP_DIAGONAL).setParameterLength(1),w9=ne(fe,fe.SUBGROUP_BROADCAST).setParameterLength(2),S9
29=ne(fe,fe.SUBGROUP_SHUFFLE).setParameterLength(2),M9=ne(fe,fe.SUBGROUP_SHUFFLE_XOR).setParameterLength(2),C9=ne(fe,fe.SUBGROUP_SHUFFLE_UP).setParameterLength(2),R9=ne(fe,fe.SUBGROUP_SHUFFLE_DOWN).setParameterLength(2),E9=ne(fe,fe.QUAD_BROADCAST).setParameterLength(1),t_;function y0(e){t_||=new WeakMap;let t=t_.get(e);return t===void 0&&t_.set(e,t={}),t}function x0(e){let t=y0(e);return t.shadowMatrix||=be("mat4").setGroup(we).onRenderUpdate(i=>((e.castShadow!==!0||i.renderer.shadowMap.enabled===!1)&&(e.shadow.camera.coordinateSystem!==i.camera.coordinateSystem&&(e.shadow.camera.coordinateSystem=i.camera.coordinateSystem,e.shadow.camera.updateProjectionMatrix()),e.shadow.updateMatrices(e)),e.shadow.matrix))}function jN(e,t=Zn){let i=x0(e).mul(t);return i.xyz.div(i.w)}function i_(e){let t=y0(e);return t.position||=be(new F).setGroup(we).onRenderUpdate((i,r)=>r.value.setFromMatrixPosition(e.matrixWorld))}function $N(e){let t=y0(e);return t.targetPosition||=be(new F).setGroup(we).onRenderUpdate((i,r)=>r.value.setFromMatrixPosition(e.target.matrixWorld))}function r_(e){let t=y0(e);return t.viewPosition||=be(new F).setGroup(we).onRenderUpdate(({camera:i},r)=>{r.value=r.value||new F,r.value.setFromMatrixPosition(e.matrixWorld),r.value.applyMatrix4(i.matrixWorldInverse)})}var s_=e=>js.transformDirection(i_(e).sub($N(e))),A9=e=>e.sort((t,i)=>t.id-i.id),N9=(e,t)=>{for(let i of t)if(i.isAnalyticLightNode&&i.light.id===e)return i;return null},n_=new WeakMap,Ep=[],a_=class extends ve{static get type(){return"LightsNode"}constructor(){super("vec3"),this.totalDiffuseNode=Wa("vec3","totalDiffuse"),this.totalSpecularNode=Wa("vec3","totalSpecular"),this.outgoingLightNode=Wa("vec3","outgoingLight"),this._lights=[],this._lightNodes=null,this._lightNodesHash=null,this.global=!0}customCacheKey(){let e=this._lights;for(let i=0;i<e.length;i++){let r=e[i];if(Ep.push(r.id),Ep.push(+!!r.castShadow),r.isSpotLight===!0){let s=r.map===null?-1:r.map.id,n=r.colorNode?r.colorNode.getCacheKey():-1;Ep.push(s,n)}}let t=tp(Ep);return Ep.length=0,t}getHash(e){if(this._lightNodesHash===null){this._lightNodes===null&&this.setupLightsNode(e);let t=[];for(let i of this._lightNodes)t.push(i.getHash());this._lightNodesHash="lights-"+t.join(",")}return this._lightNodesHash}analyze(e){let t=e.getNodeProperties(this);for(let i of t.nodes)i.build(e);t.outputNode.build(e)}setupLightsNode(e){let t=[],i=this._lightNodes,r=A9(this._lights),s=e.renderer.library;for(let n of r)if(n.isNode)t.push(xe(n));else{let a=null;if(i!==null&&(a=N9(n.id,i)),a===null){let o=s.getLightNodeClass(n.constructor);if(o===null){de(`LightsNode.setupNodeLights: Light node not found for ${n.constructor.name}`);continue}n_.has(n)===!1&&n_.set(n,new o(n)),a=n_.get(n)}t.push(a)}this._lightNodes=t}setupDirectLight(e,t,i){let{lightingModel:r,reflectedLight:s}=e.context;r.direct({...i,lightNode:t,reflectedLight:s},e)}setupDirectRectAreaLight(e,t,i){let{lightingModel:r,reflectedLight:s}=e.context;r.directRectArea({...i,lightNode:t,reflectedLight:s},e)}setupLights(e,t){for(let i of t)i.build(e)}getLightNodes(e){return this._lightNodes===null&&this.setupLightsNode(e),this._lightNodes}setup(e){let t=e.lightsNode;e.lightsNode=this;let i=this.outgoingLightNode,r=e.context,s=r.lightingModel,n=e.getNodeProperties(this);if(s){let{totalDiffuseNode:a,totalSpecularNode:o}=this;r.outgoingLight=i,n.nodes=e.addStack().nodes,s.start(e);let{backdrop:l,backdropAlpha:h}=r,{directDiffuse:u,directSpecular:d,indirectDiffuse:c,indirectSpecular:p}=r.reflectedLight,m=u.add(c);l!==null&&(m=L(h===null?l:h.mix(m,l))),a.assign(m),o.assign(d.add(p)),i.assign(a.add(o)),s.finish(e),i=i.bypass(e.removeStack())}else n.nodes=[];return e.lightsNode=t,i}setLights(e){return this._lights=e,this._lightNodes=null,this._lightNodesHash=null,this}getLights(){return this._lights}get hasLights(){return this._lights.length>0}},L9=(e=[])=>new a_().setLights(e),P9=class extends ve{static get type(){return"ShadowBaseNode"}constructor(e){super(),this.light=e,this.updateBeforeType=Re.RENDER,this.isShadowBaseNode=!0}setupShadowPosition({context:e,material:t}){o_.assign(t.receivedShadowPositionNode||e.shadowPositionWorld||Zn)}},o_=Wa("vec3","shadowPositionWorld");function l_(e,t={}){return t.toneMapping=e.toneMapping,t.toneMappingExposure=e.toneMappingExposure,t.outputColorSpace
29=e.outputColorSpace,t.renderTarget=e.getRenderTarget(),t.activeCubeFace=e.getActiveCubeFace(),t.activeMipmapLevel=e.getActiveMipmapLevel(),t.renderObjectFunction=e.getRenderObjectFunction(),t.pixelRatio=e.getPixelRatio(),t.mrt=e.getMRT(),t.clearColor=e.getClearColor(t.clearColor||new Ke),t.clearAlpha=e.getClearAlpha(),t.autoClear=e.autoClear,t.scissorTest=e.getScissorTest(),t}function WN(e,t){return t=l_(e,t),e.setMRT(null),e.setRenderObjectFunction(null),e.setClearColor(0,1),e.autoClear=!0,t}function HN(e,t){e.toneMapping=t.toneMapping,e.toneMappingExposure=t.toneMappingExposure,e.outputColorSpace=t.outputColorSpace,e.setRenderTarget(t.renderTarget,t.activeCubeFace,t.activeMipmapLevel),e.setRenderObjectFunction(t.renderObjectFunction),e.setPixelRatio(t.pixelRatio),e.setMRT(t.mrt),e.setClearColor(t.clearColor,t.clearAlpha),e.autoClear=t.autoClear,e.setScissorTest(t.scissorTest)}function h_(e,t={}){return t.background=e.background,t.backgroundNode=e.backgroundNode,t.overrideMaterial=e.overrideMaterial,t}function qN(e,t){return t=h_(e,t),e.background=null,e.backgroundNode=null,e.overrideMaterial=null,t}function XN(e,t){e.background=t.background,e.backgroundNode=t.backgroundNode,e.overrideMaterial=t.overrideMaterial}function k9(e,t,i={}){return i=l_(e,i),i=h_(t,i),i}function YN(e,t,i){return i=WN(e,i),i=qN(t,i),i}function KN(e,t,i){HN(e,i),XN(t,i)}var v0=Object.freeze({__proto__:null,resetRendererAndSceneState:YN,resetRendererState:WN,resetSceneState:qN,restoreRendererAndSceneState:KN,restoreRendererState:HN,restoreSceneState:XN,saveRendererAndSceneState:k9,saveRendererState:l_,saveSceneState:h_}),b0=new WeakMap,ZN=k(({depthTexture:e,shadowCoord:t,depthLayer:i})=>{let r=st(e,t.xy).setName("t_basic");return e.isArrayTexture&&(r=r.depth(i)),r.compare(t.z)}),JN=k(({depthTexture:e,shadowCoord:t,shadow:i,depthLayer:r})=>{let s=(u,d)=>{let c=st(e,u);return e.isArrayTexture&&(c=c.depth(r)),c.compare(d)},n=qt("mapSize","vec2",i).setGroup(we),a=qt("radius","float",i).setGroup(we),o=se(1).div(n),l=a.mul(o.x),h=qb(Ph.xy).mul(6.28318530718);return wi(s(t.xy.add(mn(0,5,h).mul(l)),t.z),s(t.xy.add(mn(1,5,h).mul(l)),t.z),s(t.xy.add(mn(2,5,h).mul(l)),t.z),s(t.xy.add(mn(3,5,h).mul(l)),t.z),s(t.xy.add(mn(4,5,h).mul(l)),t.z)).mul(1/5)}),QN=k(({depthTexture:e,shadowCoord:t,shadow:i,depthLayer:r})=>{let s=(d,c)=>{let p=st(e,d);return e.isArrayTexture&&(p=p.depth(r)),p.compare(c)},n=qt("mapSize","vec2",i).setGroup(we),a=se(1).div(n),o=a.x,l=a.y,h=t.xy,u=un(h.mul(n).add(.5));return h.subAssign(u.mul(a)),wi(s(h,t.z),s(h.add(se(o,0)),t.z),s(h.add(se(0,l)),t.z),s(h.add(a),t.z),Ze(s(h.add(se(o.negate(),0)),t.z),s(h.add(se(o.mul(2),0)),t.z),u.x),Ze(s(h.add(se(o.negate(),l)),t.z),s(h.add(se(o.mul(2),l)),t.z),u.x),Ze(s(h.add(se(0,l.negate())),t.z),s(h.add(se(0,l.mul(2))),t.z),u.y),Ze(s(h.add(se(o,l.negate())),t.z),s(h.add(se(o,l.mul(2))),t.z),u.y),Ze(Ze(s(h.add(se(o.negate(),l.negate())),t.z),s(h.add(se(o.mul(2),l.negate())),t.z),u.x),Ze(s(h.add(se(o.negate(),l.mul(2))),t.z),s(h.add(se(o.mul(2),l.mul(2))),t.z),u.x),u.y)).mul(1/9)}),eL=k(({depthTexture:e,shadowCoord:t,depthLayer:i},r)=>{let s=st(e).sample(t.xy);e.isArrayTexture&&(s=s.depth(i)),s=s.rg;let n=s.x,a=ti(1e-7,s.y.mul(s.y)),o=r.renderer.reversedDepthBuffer?Ah(n,t.z):Ah(t.z,n),l=C(1).toVar();return Se(o.notEqual(1),()=>{let h=t.z.sub(n),u=a.div(a.add(h.mul(h)));u=cn(tt(u,.3).div(.65)),l.assign(ti(o,u))}),l}),tL=e=>{let t=b0.get(e);return t===void 0&&(t=new Ot,t.colorNode=Te(0,0,0,1),t.isShadowPassMaterial=!0,t.name="ShadowMaterial",t.blending=0,t.fog=!1,b0.set(e,t)),t},iL=e=>{let t=b0.get(e);t!==void 0&&(t.dispose(),b0.delete(e))},rL=new dl,Md=[],sL=(e,t,i,r)=>{Md[0]=e,Md[1]=t;let s=rL.get(Md);return(s===void 0||s.shadowType!==i||s.useVelocity!==r)&&(s=(n,a,o,l,h,u,...d)=>{(n.castShadow===!0||n.receiveShadow&&i===3)&&(r&&(oC(n).useVelocity=!0),n.onBeforeShadow(e,n,o,t.camera,l,a.overrideMaterial,u),e.renderObject(n,a,o,l,h,u,...d),n.onAfterShadow(e,n,o,t.camera,l,a.overrideMaterial,u))},s.shadowType=i,s.useVelocity=r,rL.set(Md,s)),Md[0]=null,Md[1]=null,s},I9=k(({samples:e,radius:t,size:i,shadowPass:r,depthLayer:s})=>{let n=C(0).toVar("meanVertical"),a=C(0).toVar("squareMeanVertical"),o=e.lessThanEqual(C(1)).select(C(0),C(2).div(e.sub(1))),l=e.lessThanEqual(C(1)).select(C(0),C(-1));return bt({start:A(0),end:A(e),type:"int",condition:"<"},({i:h})=>{let u=l.add(C(h).mul(o)),d=r.sample(wi(Ph.xy,se(0,u).mul(t)).div(i));r.value.isArrayTexture&&(d=d.depth(s)),d=d.x,n.addAssign(d),a.addAssign(d.mul(d))}),n.divAssign(e),a.divAssign(e),se(n,Hr(a.sub(n.mul(n)).max(0)))}
29),F9=k(({samples:e,radius:t,size:i,shadowPass:r,depthLayer:s})=>{let n=C(0).toVar("meanHorizontal"),a=C(0).toVar("squareMeanHorizontal"),o=e.lessThanEqual(C(1)).select(C(0),C(2).div(e.sub(1))),l=e.lessThanEqual(C(1)).select(C(0),C(-1));return bt({start:A(0),end:A(e),type:"int",condition:"<"},({i:h})=>{let u=l.add(C(h).mul(o)),d=r.sample(wi(Ph.xy,se(u,0).mul(t)).div(i));r.value.isArrayTexture&&(d=d.depth(s)),n.addAssign(d.x),a.addAssign(wi(d.y.mul(d.y),d.x.mul(d.x)))}),n.divAssign(e),a.divAssign(e),se(n,Hr(a.sub(n.mul(n)).max(0)))}),D9=[ZN,JN,QN,eL],u_,_0=new _d,nL=class extends P9{static get type(){return"ShadowNode"}constructor(e,t=null){super(e),this.shadow=t||e.shadow,this.shadowMap=null,this.vsmShadowMapVertical=null,this.vsmShadowMapHorizontal=null,this.vsmMaterialVertical=null,this.vsmMaterialHorizontal=null,this._node=null,this._currentShadowType=null,this._cameraFrameId=new WeakMap,this.isShadowNode=!0,this.depthLayer=0}setupShadowFilter(e,{filterFn:t,depthTexture:i,shadowCoord:r,shadow:s,depthLayer:n}){let a=r.x.greaterThanEqual(0).and(r.x.lessThanEqual(1)).and(r.y.greaterThanEqual(0)).and(r.y.lessThanEqual(1)).and(r.z.lessThanEqual(1)),o=t({depthTexture:i,shadowCoord:r,shadow:s,depthLayer:n});return a.select(o,C(1))}setupShadowCoord(e,t){let{shadow:i}=this,{renderer:r}=e,s=i.biasNode||qt("bias","float",i).setGroup(we),n=t,a;if(i.camera.isOrthographicCamera||r.logarithmicDepthBuffer!==!0)n=n.xyz.div(n.w),a=n.z;else{let o=n.w;n=n.xy.div(o);let l=qt("near","float",i.camera).setGroup(we),h=qt("far","float",i.camera).setGroup(we);a=xb(o.negate(),l,h)}return n=L(n.x,n.y.oneMinus(),r.reversedDepthBuffer?a.sub(s):a.add(s)),n}getShadowFilterFn(e){return D9[e]}setupRenderTarget(e,t){let i=new Us(e.mapSize.width,e.mapSize.height);i.name="ShadowDepthTexture",i.compareFunction=t.renderer.reversedDepthBuffer?518:515;let r=t.createRenderTarget(e.mapSize.width,e.mapSize.height);return r.texture.name="ShadowMap",r.texture.type=e.mapType,r.depthTexture=i,{shadowMap:r,depthTexture:i}}setupShadow(e){let{renderer:t,camera:i}=e,{light:r,shadow:s}=this,{depthTexture:n,shadowMap:a}=this.setupRenderTarget(s,e),o=t.shadowMap.type,l=t.hasCompatibility(ph.TEXTURE_COMPARE);if((o===1||o===2)&&l?(n.minFilter=mi,n.magFilter=mi):(n.minFilter=lr,n.magFilter=lr),s.camera.coordinateSystem=i.coordinateSystem,s.camera.updateProjectionMatrix(),o===3&&s.isPointLightShadow!==!0){n.compareFunction=null,a.depth>1?(a._vsmShadowMapVertical||(a._vsmShadowMapVertical=e.createRenderTarget(s.mapSize.width,s.mapSize.height,{format:Oo,type:as,depth:a.depth,depthBuffer:!1}),a._vsmShadowMapVertical.texture.name="VSMVertical"),this.vsmShadowMapVertical=a._vsmShadowMapVertical,a._vsmShadowMapHorizontal||(a._vsmShadowMapHorizontal=e.createRenderTarget(s.mapSize.width,s.mapSize.height,{format:Oo,type:as,depth:a.depth,depthBuffer:!1}),a._vsmShadowMapHorizontal.texture.name="VSMHorizontal"),this.vsmShadowMapHorizontal=a._vsmShadowMapHorizontal):(this.vsmShadowMapVertical=e.createRenderTarget(s.mapSize.width,s.mapSize.height,{format:Oo,type:as,depthBuffer:!1}),this.vsmShadowMapHorizontal=e.createRenderTarget(s.mapSize.width,s.mapSize.height,{format:Oo,type:as,depthBuffer:!1}));let b=st(n);n.isArrayTexture&&(b=b.depth(this.depthLayer));let _=st(this.vsmShadowMapVertical.texture);n.isArrayTexture&&(_=_.depth(this.depthLayer));let T=qt("blurSamples","float",s).setGroup(we),w=qt("radius","float",s).setGroup(we),M=qt("mapSize","vec2",s).setGroup(we),S=this.vsmMaterialVertical||=new Ot;S.fragmentNode=I9({samples:T,radius:w,size:M,shadowPass:b,depthLayer:this.depthLayer}).context(e.getSharedContext()),S.name="VSMVertical",S=this.vsmMaterialHorizontal||=new Ot,S.fragmentNode=F9({samples:T,radius:w,size:M,shadowPass:_,depthLayer:this.depthLayer}).context(e.getSharedContext()),S.name="VSMHorizontal"}let h=qt("intensity","float",s).setGroup(we),u=qt("normalBias","float",s).setGroup(we),d=x0(r).mul(o_.add(al.mul(u))),c=this.setupShadowCoord(e,d),p=s.filterNode||this.getShadowFilterFn(t.shadowMap.type)||null;if(p===null)throw Error("THREE.WebGPURenderer: Shadow map type not supported yet.");let m=o===3&&s.isPointLightShadow!==!0?this.vsmShadowMapHorizontal.texture:n,g=this.setupShadowFilter(e,{filterFn:p,shadowTexture:a.texture,depthTexture:m,shadowCoord:c,shadow:s,depthLayer:this.depthLayer}),f;t.shadowMap.transmitted===!0&&(a.texture.isCubeTexture?f=Yr(a.texture,c.xyz):(f=st(a.texture,c),n.isArrayTexture&&(f=f.depth(this.depthLayer))));let y;y=f?Ze(1,g.rgb.mix(f,1),h.mul(f.a)).toVar():Ze(1,g,h).toVar(),this.shadowMap=a,this.shadow.map=a;let x=`${this.light.type} Shadow [ ${this.light.name||"ID: "+this.light.id} ]`;return f&&y.toInspector(`${x} / Color`,()=>this.shadowMap.texture.isCubeTexture?Yr(this.shadowMap.texture):st(this.shadowMap.texture)),y.toInspector(`${x} / Depth`,()=>this.shadowMap.texture.isCubeTexture?Yr(this.shadowMap.texture).r.oneMinus():ni(this.shadowMap.depthTexture,Mt().mul(tl(st(this.shadowMap.depthTexture)))).r.oneMinus())}setup(e){if(e.renderer.shadowMap.enabled!==!1)return k(()=>{let t=e.renderer.shadowMap.type;this._currentShadowType!==t&&(this._reset(),this._node=null);let i=this._node;return this.setupShadowPosition(e),i===null&&(this._node=i=this.setupShadow(e),this._currentShadowType=t),e.material.receivedShadowNode&&(i=e.material.receivedShadowNode(i)),i})()}renderShadow(e){let{shadow:t,shadowMap:i,light:r}=this,{renderer:s,scene:n}=e;t.updateMatrices(r),i.setSize(t.mapSize.width,t.mapSize.height,i.depth);let a=n.name;n.name=`Shadow Map [ ${r.name||"ID: "+r.id} ]`,s.render(n,t.camera),n.name=a}updateShadow(e){let{shadowMap:t,light:i,shadow:r}=this,{renderer:s,scene:n,camera:a}=e,o=s.shadowMap.type,l=t.depthTexture.version;this._depthVersionCached=l;let h=r.camera.layers.mask;r.camera.layers.mask&4294967294||(r.camera.layers.mask=a.layers.mask);let u=s.getRenderObjectFunction(),d=s.getMRT(),c=d?d.has("velocity"):!1;u_=YN(s,n,u_),n.overrideMaterial=tL(i),s.setRenderObjectFunction(sL(s,r,o,c)),s.setClearColor(0,0),s.setRenderTarget(t),this.renderShadow(e),s.setRenderObjectFunction(u),o===3&&r.isPointLightShadow!==!0&&this.vsmPass(s),r.camera.layers.mask=h,KN(s,n,u_)}vsmPass(e){let{shadow:t}=this,i=this.shadowMap.depth;this.vsmShadowMapVertical.setSize(t.mapSize.width,t.mapSize.height,i),this.vsmShadowMapHorizontal.setSize(t.mapSize.width,t.mapSize.height,i),e.setRenderTarget(this.vsmShadowMapVertical),_0.material=this.vsmMaterialVertical,_0.render(e),e.setRenderTarget(this.vsmShadowMapHorizontal),_0.material=this.vsmMaterialHorizontal,_0.render(e)}dispose(){this._reset(),super.dispose()}_reset(){this._currentShadowType=null,iL(this.light),this.shadowMap&&=(this.shadowMap.dispose(),null),this.vsmShadowMapVertical!==null&&(this.vsmShadowMapVertical.dispose(),this.vsmShadowMapVertical=null,this.vsmMaterialVertical.dispose(),this.vsmMaterialVertical=null),this.vsmShadowMapHorizontal!==null&&(this.vsmShadowMapHorizontal.dispose(),this.vsmShadowMapHorizontal=null,this.vsmMaterialHorizontal.dispose(),this.vsmMaterialHorizontal=null)}updateBefore(e){let{shadow:t}=this,i=t.needsUpdate||t.autoUpdate;i&&(this._cameraFrameId[e.camera]===e.frameId&&(i=!1),this._cameraFrameId[e.camera]=e.frameId),i&&(this.updateShadow(e),this.shadowMap.depthTexture.version===this._depthVersionCached&&(t.needsUpdate=!1))}},aL=(e,t)=>new nL(e,t),O9=new Ke,oL=new $e,Ap=new F,d_=new F,B9=[new F(1,0,0),new F(-1,0,0),new F(0,-1,0),new F(0,1,0),new F(0,0,1),new F(0,0,-1)],U9=[new F(0,-1,0),new F(0,-1,0),new F(0,0,-1),new F(0,0,1),new F(0,-1,0),new F(0,-1,0)],V9=[new F(1,0,0),new F(-1,0,0),new F(0,1,0),new F(0,-1,0),new F(0,0,1),new F(0,0,-1)],z9=[new F(0,-1,0),new F(0,-1,0),new F(0,0,1),new F(0,0,-1),new F(0,-1,0),new F(0,-1,0)],lL=k(({depthTexture:e,bd3D:t,dp:i}
29)=>Yr(e,t).compare(i)),hL=k(({depthTexture:e,bd3D:t,dp:i,shadow:r})=>{let s=qt("radius","float",r).setGroup(we),n=qt("mapSize","vec2",r).setGroup(we),a=s.div(n.x),o=kt(t),l=ls(qa(t,o.x.greaterThan(o.z).select(L(0,1,0),L(1,0,0)))),h=qa(t,l),u=qb(Ph.xy).mul(6.28318530718),d=mn(0,5,u),c=mn(1,5,u),p=mn(2,5,u),m=mn(3,5,u),g=mn(4,5,u);return Yr(e,t.add(l.mul(d.x).add(h.mul(d.y)).mul(a))).compare(i).add(Yr(e,t.add(l.mul(c.x).add(h.mul(c.y)).mul(a))).compare(i)).add(Yr(e,t.add(l.mul(p.x).add(h.mul(p.y)).mul(a))).compare(i)).add(Yr(e,t.add(l.mul(m.x).add(h.mul(m.y)).mul(a))).compare(i)).add(Yr(e,t.add(l.mul(g.x).add(h.mul(g.y)).mul(a))).compare(i)).mul(1/5)}),G9=k(({filterFn:e,depthTexture:t,shadowCoord:i,shadow:r},s)=>{let n=i.xyz.toConst(),a=n.abs().toConst(),o=a.x.max(a.y).max(a.z),l=be("float").setGroup(we).onRenderUpdate(()=>r.camera.near),h=be("float").setGroup(we).onRenderUpdate(()=>r.camera.far),u=qt("bias","float",r).setGroup(we),d=C(1).toVar();return Se(o.sub(h).lessThanEqual(0).and(o.sub(l).greaterThanEqual(0)),()=>{let c;s.renderer.reversedDepthBuffer?(c=gA(o.negate(),l,h),c.subAssign(u)):(c=fb(o.negate(),l,h),c.addAssign(u));let p=n.normalize();d.assign(e({depthTexture:t,bd3D:p,dp:c,shadow:r}))}),d}),j9=class extends nL{static get type(){return"PointShadowNode"}constructor(e,t=null){super(e,t)}getShadowFilterFn(e){return e===0?lL:hL}setupShadowCoord(e,t){return t}setupShadowFilter(e,{filterFn:t,depthTexture:i,shadowCoord:r,shadow:s}){return G9({filterFn:t,depthTexture:i,shadowCoord:r,shadow:s})}setupRenderTarget(e,t){let i=new d4(e.mapSize.width);i.name="PointShadowDepthTexture",i.compareFunction=t.renderer.reversedDepthBuffer?518:515;let r=t.createCubeRenderTarget(e.mapSize.width);return r.texture.name="PointShadowMap",r.depthTexture=i,{shadowMap:r,depthTexture:i}}renderShadow(e){let{shadow:t,shadowMap:i,light:r}=this,{renderer:s,scene:n}=e,a=t.camera,o=t.matrix,l=s.coordinateSystem===eM,h=l?B9:V9,u=l?U9:z9;i.setSize(t.mapSize.width,t.mapSize.width);let d=s.autoClear,c=s.getClearColor(O9),p=s.getClearAlpha();s.autoClear=!1,s.setClearColor(t.clearColor,t.clearAlpha);for(let m=0;m<6;m++){s.setRenderTarget(i,m),s.clear();let g=r.distance||a.far;g!==a.far&&(a.far=g,a.updateProjectionMatrix()),Ap.setFromMatrixPosition(r.matrixWorld),a.position.copy(Ap),d_.copy(a.position),d_.add(h[m]),a.up.copy(u[m]),a.lookAt(d_),a.updateMatrixWorld(),o.makeTranslation(-Ap.x,-Ap.y,-Ap.z),oL.multiplyMatrices(a.projectionMatrix,a.matrixWorldInverse),t._frustum.setFromProjectionMatrix(oL,a.coordinateSystem,a.reversedDepth);let f=n.name;n.name=`Point Light Shadow [ ${r.name||"ID: "+r.id} ] - Face ${m+1}`,s.render(n,a),n.name=f}s.autoClear=d,s.setClearColor(c,p)}},uL=(e,t)=>new j9(e,t),Bh=class extends md{static get type(){return"AnalyticLightNode"}constructor(e=null){super(),this.light=e,this.color=new Ke,this.colorNode=e&&e.colorNode||be(this.color).setGroup(we),this.baseColorNode=null,this.shadowNode=null,this.shadowColorNode=null,this.isAnalyticLightNode=!0,this.updateType=Re.FRAME,e&&e.shadow&&(this._shadowDisposeListener=()=>{this.disposeShadow()},e.addEventListener("dispose",this._shadowDisposeListener))}dispose(){this._shadowDisposeListener&&this.light.removeEventListener("dispose",this._shadowDisposeListener),super.dispose()}disposeShadow(){this.shadowNode!==null&&(this.shadowNode.dispose(),this.shadowNode=null),this.shadowColorNode=null,this.baseColorNode!==null&&(this.colorNode=this.baseColorNode,this.baseColorNode=null)}getHash(){return this.light.uuid}getLightVector(e){return r_(this.light).sub(e.context.positionView||yi)}setupDirect(){}setupDirectRectArea(){}setupShadowNode(){return aL(this.light)}setupShadow(e){let{renderer:t}=e;if(t.shadowMap.enabled===!1)return;let i=this.shadowColorNode;if(i===null){let r=this.light.shadow.shadowNode,s;s=r===void 0?this.setupShadowNode():xe(r),this.shadowNode=s,this.shadowColorNode=i=this.colorNode.mul(s),this.baseColorNode=this.colorNode}e.context.getShadow&&(i=e.context.getShadow(this,e)),this.colorNode=i}setup(e){this.colorNode=this.baseColorNode||this.colorNode,this.light.castShadow?e.object.receiveShadow&&this.setupShadow(e):this.shadowNode!==null&&(this.shadowNode.dis
vendor: 8,458 bytes, line 29
29pose(),this.shadowNode=null,this.shadowColorNode=null);let t=this.setupDirect(e),i=this.setupDirectRectArea(e);t&&e.lightsNode.setupDirectLight(e,this,t),i&&e.lightsNode.setupDirectRectAreaLight(e,this,i)}update(){let{light:e}=this;this.color.copy(e.color).multiplyScalar(e.intensity)}},c_=k(({lightDistance:e,cutoffDistance:t,decayExponent:i})=>{let r=e.pow(i).max(.01).reciprocal();return t.greaterThan(0).select(r.mul(e.div(t).pow4().oneMinus().clamp().pow2()),r)}),dL=({color:e,lightVector:t,cutoffDistance:i,decayExponent:r})=>{let s=t.normalize(),n=c_({lightDistance:t.length(),cutoffDistance:i,decayExponent:r});return{lightDirection:s,lightColor:e.mul(n)}},$9=class extends Bh{static get type(){return"PointLightNode"}constructor(e=null){super(e),this.cutoffDistanceNode=be(0).setGroup(we),this.decayExponentNode=be(2).setGroup(we)}update(e){let{light:t}=this;super.update(e),this.cutoffDistanceNode.value=t.distance,this.decayExponentNode.value=t.decay}setupShadowNode(){return uL(this.light)}setupDirect(e){return dL({color:this.colorNode,lightVector:this.getLightVector(e),cutoffDistance:this.cutoffDistanceNode,decayExponent:this.decayExponentNode})}},W9=k(([e=Mt()])=>{let t=e.mul(2),i=t.x.floor(),r=t.y.floor();return i.add(r).mod(2).sign()}),H9=k(([e=Mt()],{renderer:t,material:i})=>{let r=Mv(e.mul(2).sub(1)),s;if(i.alphaToCoverage&&t.currentSamples>0){let n=C(r.fwidth()).toVar();s=pn(n.oneMinus(),n.add(1),r).oneMinus()}else s=wr(r.greaterThan(1),0,1);return s}),Np=k(([e,t,i])=>{let r=C(i).toVar(),s=C(t).toVar();return wr(vs(e).toVar(),s,r)}).setLayout({name:"mx_select",type:"float",inputs:[{name:"b",type:"bool"},{name:"t",type:"float"},{name:"f",type:"float"}]}),T0=k(([e,t])=>{let i=vs(t).toVar(),r=C(e).toVar();return wr(i,r.negate(),r)}).setLayout({name:"mx_negate_if",type:"float",inputs:[{name:"val",type:"float"},{name:"b",type:"bool"}]}),Si=k(([e])=>A(qn(C(e).toVar()))).setLayout({name:"mx_floor",type:"int",inputs:[{name:"x",type:"float"}]}),Zt=k(([e,t])=>{let i=C(e).toVar();return t.assign(Si(i)),i.sub(C(t))}),cL=mr([k(([e,t,i,r,s,n])=>{let a=C(n).toVar(),o=C(s).toVar(),l=C(r).toVar(),h=C(i).toVar(),u=C(t).toVar(),d=C(e).toVar(),c=C(tt(1,o)).toVar();return tt(1,a).mul(d.mul(c).add(u.mul(o))).add(a.mul(h.mul(c).add(l.mul(o))))}).setLayout({name:"mx_bilerp_0",type:"float",inputs:[{name:"v0",type:"float"},{name:"v1",type:"float"},{name:"v2",type:"float"},{name:"v3",type:"float"},{name:"s",type:"float"},{name:"t",type:"float"}]}),k(([e,t,i,r,s,n])=>{let a=C(n).toVar(),o=C(s).toVar(),l=L(r).toVar(),h=L(i).toVar(),u=L(t).toVar(),d=L(e).toVar(),c=C(tt(1,o)).toVar();return tt(1,a).mul(d.mul(c).add(u.mul(o))).add(a.mul(h.mul(c).add(l.mul(o))))}).setLayout({name:"mx_bilerp_1",type:"vec3",inputs:[{name:"v0",type:"vec3"},{name:"v1",type:"vec3"},{name:"v2",type:"vec3"},{name:"v3",type:"vec3"},{name:"s",type:"float"},{name:"t",type:"float"}]})]),pL=mr([k(([e,t,i,r,s,n,a,o,l,h,u])=>{let d=C(u).toVar(),c=C(h).toVar(),p=C(l).toVar(),m=C(o).toVar(),g=C(a).toVar(),f=C(n).toVar(),y=C(s).toVar(),x=C(r).toVar(),b=C(i).toVar(),_=C(t).toVar(),T=C(e).toVar(),w=C(tt(1,p)).toVar(),M=C(tt(1,c)).toVar();return C(tt(1,d)).toVar().mul(M.mul(T.mul(w).add(_.mul(p))).add(c.mul(b.mul(w).add(x.mul(p))))).add(d.mul(M.mul(y.mul(w).add(f.mul(p))).add(c.mul(g.mul(w).add(m.mul(p))))))}).setLayout({name:"mx_trilerp_0",type:"float",inputs:[{name:"v0",type:"float"},{name:"v1",type:"float"},{name:"v2",type:"float"},{name:"v3",type:"float"},{name:"v4",type:"float"},{name:"v5",type:"float"},{name:"v6",type:"float"},{name:"v7",type:"float"},{name:"s",type:"float"},{name:"t",type:"float"},{name:"r",type:"float"}]}),k(([e,t,i,r,s,n,a,o,l,h,u])=>{let d=C(u).toVar(),c=C(h).toVar(),p=C(l).toVar(),m=L(o).toVar(),g=L(a).toVar(),f=L(n).toVar(),y=L(s).toVar(),x=L(r).toVar(),b=L(i).toVar(),_=L(t).toVar(),T=L(e).toVar(),w=C(tt(1,p)).toVar(),M=C(tt(1,c)).toVar();return C(tt(1,d)).toVar().mul(M.mul(T.mul(w).add(_.mul(p))).add(c.mul(b.mul(w).add(x.mul(p))))).add(d.mul(M.mul(y.mul(w).add(f.mul(p))).add(c.mul(g.mul(w).add(m.mul(p))))))}).setLayout({name:"mx_trilerp_1",type:"vec3",inputs:[{name:"v0",type:"vec3"},{name:"v1",type:"vec3"},{name:"v2",type:"vec3"},{name:"v3",type:"vec3"},{name:"v4",type:"vec3"},{name:"v5",type:"vec3"},{name:"v6",type:"vec3"},{name:"v7",type:"vec3"},{name:"s",type:"float"},{name:"t",type:"float"},{name:"r",type:"float"}]})]),rr=mr([k(([e,t,i])=>{let r=C(i).toVar(),s=C(t).toVar(),n=K(K(e).toVar().bitAnd(K(7))).toVar(),a=C(Np(n.lessThan(K(4)),s,r)).toVar(),o=C(Pe(2,Np(n.lessThan(K(4)),r,s))).toVar();return T0(a,vs(n.bitAnd(K(1)))).add(T0(o,vs(n.bitAnd(K(2)))))}).setLayout({name:"mx_gradient_float_0",type:"float",inputs:[{name:"hash",type:"uint"},{name:"x",type:"float"},{name:"y",type:"float"}]}),k(([e,t,i,r])=>{let s=C(r).toVar(),n=C(i).toVar(),a=C(t).toVar(),o=K(K(e).toVar().bitAnd(K(15))).toVar(),l=C(Np(o.lessThan(K(8)),a,n)).toVar(),h=C(Np(o.lessThan(K(4)),n,Np(o.equal(K(12)).or(o.equal(K(14))),a,s))).toVar();return T0(l,vs(o.bitAnd(K(1)))).add(T0(h,vs(o.bitAnd(K(2)))))}).setLayout({name:"mx_gradient_float_1",type:"float",inputs:[{name:"hash",type:"uint"},{name:"x",type:"float"},{name:"y",type:"float"},{name:"z",type:"float"}]})]),qs=mr([k(([e,t,i])=>{let r=C(i).toVar(),s=C(t).toVar(),n=Sh(e).toVar();return L(rr(n.x,s,r),rr(n.y,s,r),rr(n.z,s,r))}).setLayout({name:"mx_gradient_vec3_0",type:"vec3",inputs:[{name:"hash",type:"uvec3"},{name:"x",type:"float"},{name:"y",type:"float"}]}),k(([e,t,i,r])=>{let s=C(r).toVar(),n=C(i).toVar(),a=C(t).toVar(),o=Sh(e).toVar();return L(rr(o.x,a,n,s),rr(o.y,a,n,s),rr(o.z,a,n,s))}).setLayout({name:"mx_gradient_vec3_1",type:"vec3",inputs:[{name:"hash",type:"uvec3"},{name:"x",type:"float"},{name:"y",type:"float"},{name:"z",type:"float"}]})]),q9=k(([e])=>Pe(.6616,C(e).toVar())).setLayout({name:"mx_gradient_scale2d_0",type:"float",inputs:[{name:"v",type:"float"}]}),X9=k(([e])=>Pe(.982,C(e).toVar())).setLayout({name:"mx_gradient_scale3d_0",type:"float",inputs:[{name:"v",type:"float"}]}),mL=mr([q9,k(([e])=>Pe(.6616,L(e).toVar())).setLayout({name:"mx_gradient_scale2d_1",type:"vec3",inputs:[{name:"v",type:"vec3"}]})]),gL=mr([X9,k(([e])=>Pe(.982,L(e).toVar())).setLayout({name:"mx_gradient_scale3d_1",type:"vec3",inputs:[{name:"v",type:"vec3"}]})]),Ss=k(([e,t])=>{let i=A(t).toVar(),r=K(e).toVar();return r.shiftLeft(i).bitOr(r.shiftRight(A(32).sub(i)))}).setLayout({name:"mx_rotl32",type:"uint",inputs:[{name:"x",type:"uint"},{name:"k",type:"int"}]}),fL=k(([e,t,i])=>{e.subAssign(i),e.bitXorAssign(Ss(i,A(4))),i.addAssign(t),t.subAssign(e),t.bitXorAssign(Ss(e,A(6))),e.addAssign(i),i.subAssign(t),i.bitXorAssign(Ss(t,A(8))),t.addAssign(e),e.subAssign(i),e.bitXorAssign(Ss(i,A(16))),i.addAssign(t),t.subAssign(e),t.bitXorAssign(Ss(e,A(19))),e.addAssign(i),i.subAssign(t),i.bitXorAssign(Ss(t,A(4))),t.addAssign(e)}),Lp=k(([e,t,i])=>{let r=K(i).toVar(),s=K(t).toVar(),n=K(e).toVar();return r.bitXorAssign(s),r.subAssign(Ss(s,A(14))),n.bitXorAssign(r),n.subAssign(Ss(r,A(11))),s.bitXorAssign(n),s.subAssign(Ss(n,A(25))),r.bitXorAssign(s),r.subAssign(Ss(s,A(16))),n.bitXorAssign(r),n.subAssign(Ss(r,A(4))),s.bitXorAssign(n),s.subAssign(Ss(n,A(14))),r.bitXorAssign(s),r.subAssign(Ss(s,A(24))),r}).setLayout({name:"mx_bjfinal",type:"uint",inputs:[{name:"a",type:"uint"},{name:"b",type:"uint"},{name:"c",type:"uint"}]}),Mr=k(([e])=>C(K(e).toVar()).div(C(K(A(4294967295))))).setLayout({name:"mx_bits_to_01",type:"float",inputs:[{name:"bits",type:"uint"}]}),sa=k(([e])=>{let t=C(e).toVar();return t.mul(t).mul(t).mul(t.mul(t.mul(6).sub(15)).add(10))}).setLayout({name:"mx_fade",type:"float",inputs:[{name:"t",type:"float"}]}),Ct=mr([k(([e])=>{let t=A(e).toVar(),i=K(K(1)).toVar(),r=K(K(A(3735928559)).add(i.shiftLeft(K(2))).add(K(13))).toVar();return Lp(r.add(K(t)),r,r)}).setLayout({name:"mx_hash_int_0",type:"uint",inputs:[{name:"x",type:"int"}]}),k(([e,t])=>{let i=A(t).toVar(),r=A(e).toVar(),s=K(K(2)).toVar(),n=K().toVar(),a=K().toVar(),o=K().toVar();return n.assign(a.assign(o.assign(K(A(3735928559)).add(s.shiftLeft(K(2))).add(K(13))))),n.addAssign(K(r)),a.addAssign(K(i)),Lp(n,a,o)}).setLayout({name:"mx_hash_int_1",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"}]}),k(([e,t,i])=>{let r=A(i).toVar(),s=A(t).toVar(),n=A(e).toVar(),a=K(K(3)).toVar(),o=K().toVar(),l=K().toVar(),h=K().toVar();return o.assign(l.assign(h.assign(K(A(3735928559)).add(a.shiftLeft(K(2))).add(K(13))))),o.addAssign(K(n)),l.addAssign(K(s)),h.addAssign(K(r)),Lp(o,l,h)}
29).setLayout({name:"mx_hash_int_2",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"}]}),k(([e,t,i,r])=>{let s=A(r).toVar(),n=A(i).toVar(),a=A(t).toVar(),o=A(e).toVar(),l=K(K(4)).toVar(),h=K().toVar(),u=K().toVar(),d=K().toVar();return h.assign(u.assign(d.assign(K(A(3735928559)).add(l.shiftLeft(K(2))).add(K(13))))),h.addAssign(K(o)),u.addAssign(K(a)),d.addAssign(K(n)),fL(h,u,d),h.addAssign(K(s)),Lp(h,u,d)}).setLayout({name:"mx_hash_int_3",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"},{name:"xx",type:"int"}]}),k(([e,t,i,r,s])=>{let n=A(s).toVar(),a=A(r).toVar(),o=A(i).toVar(),l=A(t).toVar(),h=A(e).toVar(),u=K(K(5)).toVar(),d=K().toVar(),c=K().toVar(),p=K().toVar();return d.assign(c.assign(p.assign(K(A(3735928559)).add(u.shiftLeft(K(2))).add(K(13))))),d.addAssign(K(h)),c.addAssign(K(l)),p.addAssign(K(o)),fL(d,c,p),d.addAssign(K(a)),c.addAssign(K(n)),Lp(d,c,p)}).setLayout({name:"mx_hash_int_4",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"},{name:"xx",type:"int"},{name:"yy",type:"int"}]})]),Xs=mr([k(([e,t])=>{let i=A(t).toVar(),r=K(Ct(A(e).toVar(),i)).toVar(),s=Sh().toVar();return s.x.assign(r.bitAnd(A(255))),s.y.assign(r.shiftRight(A(8)).bitAnd(A(255))),s.z.assign(r.shiftRight(A(16)).bitAnd(A(255))),s}
29).setLayout({name:"mx_hash_vec3_0",type:"uvec3",inputs:[{name:"x",type:"int"},{name:"y",type:"int"}]}),k(([e,t,i])=>{let r=A(i).toVar(),s=A(t).toVar(),n=K(Ct(A(e).toVar(),s,r)).toVar(),a=Sh().toVar();return a.x.assign(n.bitAnd(A(255))),a.y.assign(n.shiftRight(A(8)).bitAnd(A(255))),a.z.assign(n.shiftRight(A(16)).bitAnd(A(255))),a}).setLayout({name:"mx_hash_vec3_1",type:"uvec3",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"}]})]),p_=mr([k(([e])=>{let t=se(e).toVar(),i=A().toVar(),r=A().toVar(),s=C(Zt(t.x,i)).toVar(),n=C(Zt(t.y,r)).toVar(),a=C(sa(s)).toVar(),o=C(sa(n)).toVar();return mL(C(cL(rr(Ct(i,r),s,n),rr(Ct(i.add(A(1)),r),s.sub(1),n),rr(Ct(i,r.add(A(1))),s,n.sub(1)),rr(Ct(i.add(A(1)),r.add(A(1))),s.sub(1),n.sub(1)),a,o)).toVar())}).setLayout({name:"mx_perlin_noise_float_0",type:"float",inputs:[{name:"p",type:"vec2"}]}),k(([e])=>{let t=L(e).toVar(),i=A().toVar(),r=A().toVar(),s=A().toVar(),n=C(Zt(t.x,i)).toVar(),a=C(Zt(t.y,r)).toVar(),o=C(Zt(t.z,s)).toVar(),l=C(sa(n)).toVar(),h=C(sa(a)).toVar(),u=C(sa(o)).toVar();return gL(C(pL(rr(Ct(i,r,s),n,a,o),rr(Ct(i.add(A(1)),r,s),n.sub(1),a,o),rr(Ct(i,r.add(A(1)),s),n,a.sub(1),o),rr(Ct(i.add(A(1)),r.add(A(1)),s),n.sub(1),a.sub(1),o),rr(Ct(i,r,s.add(A(1))),n,a,o.sub(1)),rr(Ct(i.add(A(1)),r,s.add(A(1))),n.sub(1),a,o.sub(1)),rr(Ct(i,r.add(A(1)),s.add(A(1))),n,a.sub(1),o.sub(1)),rr(Ct(i.add(A(1)),r.add(A(1)),s.add(A(1))),n.sub(1),a.sub(1),o.sub(1)),l,h,u)).toVar())}).setLayout({name:"mx_perlin_noise_float_1",type:"float",inputs:[{name:"p",type:"vec3"}]})]),Pp=mr([k(([e])=>{let t=se(e).toVar(),i=A().toVar(),r=A().toVar(),s=C(Zt(t.x,i)).toVar(),n=C(Zt(t.y,r)).toVar(),a=C(sa(s)).toVar(),o=C(sa(n)).toVar();return mL(L(cL(qs(Xs(i,r),s,n),qs(Xs(i.add(A(1)),r),s.sub(1),n),qs(Xs(i,r.add(A(1))),s,n.sub(1)),qs(Xs(i.add(A(1)),r.add(A(1))),s.sub(1),n.sub(1)),a,o)).toVar())}).setLayout({name:"mx_perlin_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"vec2"}]}),k(([e])=>{let t=L(e).toVar(),i=A().toVar(),r=A().toVar(),s=A().toVar(),n=C(Zt(t.x,i)).toVar(),a=C(Zt(t.y,r)).toVar(),o=C(Zt(t.z,s
vendor: 11,130 bytes, line 29
29)).toVar(),l=C(sa(n)).toVar(),h=C(sa(a)).toVar(),u=C(sa(o)).toVar();return gL(L(pL(qs(Xs(i,r,s),n,a,o),qs(Xs(i.add(A(1)),r,s),n.sub(1),a,o),qs(Xs(i,r.add(A(1)),s),n,a.sub(1),o),qs(Xs(i.add(A(1)),r.add(A(1)),s),n.sub(1),a.sub(1),o),qs(Xs(i,r,s.add(A(1))),n,a,o.sub(1)),qs(Xs(i.add(A(1)),r,s.add(A(1))),n.sub(1),a,o.sub(1)),qs(Xs(i,r.add(A(1)),s.add(A(1))),n,a.sub(1),o.sub(1)),qs(Xs(i.add(A(1)),r.add(A(1)),s.add(A(1))),n.sub(1),a.sub(1),o.sub(1)),l,h,u)).toVar())}).setLayout({name:"mx_perlin_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec3"}]})]),Y9=mr([k(([e])=>Mr(Ct(A(Si(C(e).toVar())).toVar()))).setLayout({name:"mx_cell_noise_float_0",type:"float",inputs:[{name:"p",type:"float"}]}),k(([e])=>{let t=se(e).toVar();return Mr(Ct(A(Si(t.x)).toVar(),A(Si(t.y)).toVar()))}).setLayout({name:"mx_cell_noise_float_1",type:"float",inputs:[{name:"p",type:"vec2"}]}),k(([e])=>{let t=L(e).toVar();return Mr(Ct(A(Si(t.x)).toVar(),A(Si(t.y)).toVar(),A(Si(t.z)).toVar()))}).setLayout({name:"mx_cell_noise_float_2",type:"float",inputs:[{name:"p",type:"vec3"}]}),k(([e])=>{let t=Te(e).toVar();return Mr(Ct(A(Si(t.x)).toVar(),A(Si(t.y)).toVar(),A(Si(t.z)).toVar(),A(Si(t.w)).toVar()))}).setLayout({name:"mx_cell_noise_float_3",type:"float",inputs:[{name:"p",type:"vec4"}]})]),w0=mr([k(([e])=>{let t=A(Si(C(e).toVar())).toVar();return L(Mr(Ct(t,A(0))),Mr(Ct(t,A(1))),Mr(Ct(t,A(2))))}).setLayout({name:"mx_cell_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"float"}]}),k(([e])=>{let t=se(e).toVar(),i=A(Si(t.x)).toVar(),r=A(Si(t.y)).toVar();return L(Mr(Ct(i,r,A(0))),Mr(Ct(i,r,A(1))),Mr(Ct(i,r,A(2))))}).setLayout({name:"mx_cell_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec2"}]}),k(([e])=>{let t=L(e).toVar(),i=A(Si(t.x)).toVar(),r=A(Si(t.y)).toVar(),s=A(Si(t.z)).toVar();return L(Mr(Ct(i,r,s,A(0))),Mr(Ct(i,r,s,A(1))),Mr(Ct(i,r,s,A(2))))}).setLayout({name:"mx_cell_noise_vec3_2",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),k(([e])=>{let t=Te(e).toVar(),i=A(Si(t.x)).toVar(),r=A(Si(t.y)).toVar(),s=A(Si(t.z)).toVar(),n=A(Si(t.w)).toVar();return L(Mr(Ct(i,r,s,n,A(0))),Mr(Ct(i,r,s,n,A(1))),Mr(Ct(i,r,s,n,A(2))))}).setLayout({name:"mx_cell_noise_vec3_3",type:"vec3",inputs:[{name:"p",type:"vec4"}]})]),S0=k(([e,t,i,r])=>{let s=C(r).toVar(),n=C(i).toVar(),a=A(t).toVar(),o=L(e).toVar(),l=C(0).toVar(),h=C(1).toVar();return bt(a,()=>{l.addAssign(h.mul(p_(o))),h.mulAssign(s),o.mulAssign(n)}),l}).setLayout({name:"mx_fractal_noise_float",type:"float",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),M0=k(([e,t,i,r])=>{let s=C(r).toVar(),n=C(i).toVar(),a=A(t).toVar(),o=L(e).toVar(),l=L(0).toVar(),h=C(1).toVar();return bt(a,()=>{l.addAssign(h.mul(Pp(o))),h.mulAssign(s),o.mulAssign(n)}),l}).setLayout({name:"mx_fractal_noise_vec3",type:"vec3",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),K9=k(([e,t,i,r])=>{let s=C(r).toVar(),n=C(i).toVar(),a=A(t).toVar(),o=L(e).toVar();return se(S0(o,a,n,s),S0(o.add(L(A(19),A(193),A(17))),a,n,s))}).setLayout({name:"mx_fractal_noise_vec2",type:"vec2",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),Z9=k(([e,t,i,r])=>{let s=C(r).toVar(),n=C(i).toVar(),a=A(t).toVar(),o=L(e).toVar();return Te(L(M0(o,a,n,s)).toVar(),C(S0(o.add(L(A(19),A(193),A(17))),a,n,s)).toVar())}).setLayout({name:"mx_fractal_noise_vec4",type:"vec4",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),Cd=mr([k(([e,t,i,r,s,n,a])=>{let o=A(a).toVar(),l=C(n).toVar(),h=A(s).toVar(),u=A(r).toVar(),d=A(i).toVar(),c=A(t).toVar(),p=se(e).toVar(),m=L(w0(se(c.add(u),d.add(h)))).toVar(),g=se(m.x,m.y).toVar();g.subAssign(.5),g.mulAssign(l),g.addAssign(.5);let f=se(se(se(C(c),C(d)).add(g)).toVar().sub(p)).toVar();return Se(o.equal(A(2)),()=>kt(f.x).add(kt(f.y))),Se(o.equal(A(3)),()=>ti(kt(f.x),kt(f.y))),zs(f,f)}).setLayout({name:"mx_worley_distance_0",type:"float",inputs:[{name:"p",type:"vec2"},{name:"x",type:"int"},{name:"y",type:"int"},{name:"xoff",type:"int"},{name:"yoff",type:"int"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),k(([e,t,i,r,s,n,a,o,l])=>{let h=A(l).toVar(),u=C(o).toVar(),d=A(a).toVar(),c=A(n).toVar(),p=A(s).toVar(),m=A(r).toVar(),g=A(i).toVar(),f=A(t).toVar(),y=L(e).toVar(),x=L(w0(L(f.add(p),g.add(c),m.add(d)))).toVar();x.subAssign(.5),x.mulAssign(u),x.addAssign(.5);let b=L(L(L(C(f),C(g),C(m)).add(x)).toVar().sub(y)).toVar();return Se(h.equal(A(2)),()=>kt(b.x).add(kt(b.y)).add(kt(b.z))),Se(h.equal(A(3)),()=>ti(kt(b.x),kt(b.y),kt(b.z))),zs(b,b)}).setLayout({name:"mx_worley_distance_1",type:"float",inputs:[{name:"p",type:"vec3"},{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"},{name:"xoff",type:"int"},{name:"yoff",type:"int"},{name:"zoff",type:"int"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]})]),J9=k(([e,t,i])=>{let r=A(i).toVar(),s=C(t).toVar(),n=se(e).toVar(),a=A().toVar(),o=A().toVar(),l=se(Zt(n.x,a),Zt(n.y,o)).toVar(),h=C(1e6).toVar();return bt({start:-1,end:A(1),name:"x",condition:"<="},({x:u})=>{bt({start:-1,end:A(1),name:"y",condition:"<="},({y:d})=>{let c=C(Cd(l,u,d,a,o,s,r)).toVar();h.assign(hs(h,c))})}),Se(r.equal(A(0)),()=>{h.assign(Hr(h))}),h}).setLayout({name:"mx_worley_noise_float_0",type:"float",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),Q9=k(([e,t,i])=>{let r=A(i).toVar(),s=C(t).toVar(),n=se(e).toVar(),a=A().toVar(),o=A().toVar(),l=se(Zt(n.x,a),Zt(n.y,o)).toVar(),h=se(1e6,1e6).toVar();return bt({start:-1,end:A(1),name:"x",condition:"<="},({x:u})=>{bt({start:-1,end:A(1),name:"y",condition:"<="},({y:d})=>{let c=C(Cd(l,u,d,a,o,s,r)).toVar();Se(c.lessThan(h.x),()=>{h.y.assign(h.x),h.x.assign(c)}).ElseIf(c.lessThan(h.y),()=>{h.y.assign(c)})})}),Se(r.equal(A(0)),()=>{h.assign(Hr(h))}),h}).setLayout({name:"mx_worley_noise_vec2_0",type:"vec2",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),ej=k(([e,t,i])=>{let r=A(i).toVar(),s=C(t).toVar(),n=se(e).toVar(),a=A().toVar(),o=A().toVar(),l=se(Zt(n.x,a),Zt(n.y,o)).toVar(),h=L(1e6,1e6,1e6).toVar();return bt({start:-1,end:A(1),name:"x",condition:"<="},({x:u})=>{bt({start:-1,end:A(1),name:"y",condition:"<="},({y:d})=>{let c=C(Cd(l,u,d,a,o,s,r)).toVar();Se(c.lessThan(h.x),()=>{h.z.assign(h.y),h.y.assign(h.x),h.x.assign(c)}).ElseIf(c.lessThan(h.y),()=>{h.z.assign(h.y),h.y.assign(c)}).ElseIf(c.lessThan(h.z),()=>{h.z.assign(c)})})}),Se(r.equal(A(0)),()=>{h.assign(Hr(h))}),h}).setLayout({name:"mx_worley_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),tj=mr([J9,k(([e,t,i])=>{let r=A(i).toVar(),s=C(t).toVar(),n=L(e).toVar(),a=A().toVar(),o=A().toVar(),l=A().toVar(),h=L(Zt(n.x,a),Zt(n.y,o),Zt(n.z,l)).toVar(),u=C(1e6).toVar();return bt({start:-1,end:A(1),name:"x",condition:"<="},({x:d})=>{bt({start:-1,end:A(1),name:"y",condition:"<="},({y:c})=>{bt({start:-1,end:A(1),name:"z",condition:"<="},({z:p})=>{let m=C(Cd(h,d,c,p,a,o,l,s,r)).toVar();u.assign(hs(u,m))})})}),Se(r.equal(A(0)),()=>{u.assign(Hr(u))}),u}).setLayout({name:"mx_worley_noise_float_1",type:"float",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]})]),ij=mr([Q9,k(([e,t,i])=>{let r=A(i).toVar(),s=C(t).toVar(),n=L(e).toVar(),a=A().toVar(),o=A().toVar(),l=A().toVar(),h=L(Zt(n.x,a),Zt(n.y,o),Zt(n.z,l)).toVar(),u=se(1e6,1e6).toVar();return bt({start:-1,end:A(1),name:"x",condition:"<="},({x:d})=>{bt({start:-1,end:A(1),name:"y",condition:"<="},({y:c})=>{bt({start:-1,end:A(1),name:"z",condition:"<="},({z:p})=>{let m=C(Cd(h,d,c,p,a,o,l,s,r)).toVar();Se(m.lessThan(u.x),()=>{u.y.assign(u.x),u.x.assign(m)}).ElseIf(m.lessThan(u.y),()=>{u.y.assign(m)})})})}),Se(r.equal(A(0)),()=>{u.assign(Hr(u))}),u}).setLayout({name:"mx_worley_noise_vec2_1",type:"vec2",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]})]),m_=mr([ej,k(([e,t,i])=>{let r=A(i).toVar(),s=C(t).toVar(),n=L(e).toVar(),a=A().toVar(),o=A().toVar(),l=A().toVar(),h=L(Zt(n.x,a),Zt(n.y,o),Zt(n.z,l)).toVar(),u=L(1e6,1e6,1e6).toVar();return bt({start:-1,end:A(1),name:"x",condition:"<="},({x:d})=>{bt({start:-1,end:A(1),name:"y",condition:"<="},({y:c})=>{bt({start:-1,end:A(1),name:"z",condition:"<="},({z:p})=>{let m=C(Cd(h,d,c,p,a,o,l,s,r)).toVar();Se(m.lessThan(u.x),()=>{u.z.assign(u.y),u.y.assign(u.x),u.x.assign(m)}).ElseIf(m.lessThan(u.y),()=>{u.z.assign(u.y),u.y.assign(m)}).ElseIf(m.lessThan(u.z),()=>{u.z.assign(m)})})})}),Se(r.equal(A(0)),()=>{u.assign(Hr(u))}),u}).setLayout({name:"mx_worley_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]})]),rj=k(([e,t,i,r,s,n,a,o,l,h,u])=>{let d=A(e).toVar(),c=se(t).toVar(),p=se(i).toVar(),m=se(r).toVar(),g=C(s).toVar(),f=C(n).toVar(),y=C(a).toVar(),x=vs(o).toVar(),b=A(l).toVar(),_=C(h).toVar(),T=C(u).toVar(),w=c.mul(p).add(m),M=C(0).toVar();return Se(d.equal(A(0)),()=>{M.assign(Pp(w))}),Se(d.equal(A(1)),()=>{M.assign(w0(w))}),Se(d.equal(A(2)),()=>{M.assign(m_(w,g,A(0)))}),Se(d.equal(A(3)),()=>{M.assign(M0(L(w,0),b,_,T))}),M.assign(M.mul(y.sub(f)).add(f)),Se(x,()=>{M.assign(cn(M,f,y))}),M}).setLayout({name:"mx_unifiednoise2d",type:"float",inputs:[{name:"noiseType",type:"int"},{name:"texcoord",type:"vec2"},{name:"freq",type:"vec2"},{name:"offset",type:"vec2"},{name:"jitter",type:"float"},{name:"outmin",type:"float"},{name:"outmax",type:"float"},{name:"clampoutput",type:"bool"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),sj=k(([e,t,i,r,s,n,a,o,l,h,u])=>{let d=A(e).toVar(),c=L(t).toVar(),p=L(i).toVar(),m=L(r).toVar(),g=C(s).toVar(),f=C(n).toVar(),y=C(a).toVar(),x=vs(o).toVar(),b=A(l).toVar(),_=C(h).toVar(),T=C(u).toVar(),w=c.mul(p).add(m),M=C(0).toVar();return Se(d.equal(A(0)),()=>{M.assign(Pp(w))}),Se(d.equal(A(1)),()=>{M.assign(w0(w))}),Se(d.equal(A(2)),()=>{M.assign(m_(w,g,A(0)))}),Se(d.equal(A(3)),()=>{M.assign(M0(w,b,_,T))}),M.assign(M.mul(y.sub(f)).add(f)),Se(x,()=>{M.assign(cn(M,f,y))}),M}).setLayout({name:"mx_unifiednoise3d",type:"float",inputs:[{name:"noiseType",type:"int"},{name:"position",type:"vec3"},{name:"freq",type:"vec3"},{name:"offset",type:"vec3"},{name:"jitter",type:"float"},{name:"outmin",type:"float"},{name:"outmax",type:"float"},{name:"clampoutput",type:"bool"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),nj=k(([e])=>{let t=e.y,i=e.z,r=L().toVar();return Se(t.lessThan(1e-4),()=>{r.assign(L(i,i,i))}).Else(()=>{let s=e.x;s=s.sub(qn(s)).mul(6).toVar();let n=A(_v(s)),a=s.sub(C(n)),o=i.mul(t.oneMinus()),l=i.mul(t.mul(a).oneMinus()),h=i.mul(t.mul(a.oneMinus()).oneMinus());Se(n.equal(A(0)),()=>{r.assign(L(i,h,o))}).ElseIf(n.equal(A(1)),()=>{r.assign(L(l,i,o))}).ElseIf(n.equal(A(2)),()=>{r.assign(L(o,i,h))}).ElseIf(n.equal(A(3)),()=>{r.assign(L(o,l,i))}).ElseIf(n.equal(A(4)),()=>{r.assign(L(h,o,i))}).Else(()=>{r.assign(L(i,o,l))})}),r}
vendor: 6,405 bytes, line 29
29).setLayout({name:"mx_hsvtorgb",type:"vec3",inputs:[{name:"hsv",type:"vec3"}]}),aj=k(([e])=>{let t=L(e).toVar(),i=C(t.x).toVar(),r=C(t.y).toVar(),s=C(t.z).toVar(),n=C(hs(i,hs(r,s))).toVar(),a=C(ti(i,ti(r,s))).toVar(),o=C(a.sub(n)).toVar(),l=C().toVar(),h=C().toVar(),u=C().toVar();return u.assign(a),Se(a.greaterThan(0),()=>{h.assign(o.div(a))}).Else(()=>{h.assign(0)}),Se(h.lessThanEqual(0),()=>{l.assign(0)}).Else(()=>{Se(i.greaterThanEqual(a),()=>{l.assign(r.sub(s).div(o))}).ElseIf(r.greaterThanEqual(a),()=>{l.assign(wi(2,s.sub(i).div(o)))}).Else(()=>{l.assign(wi(4,i.sub(r).div(o)))}),l.mulAssign(1/6),Se(l.lessThan(0),()=>{l.addAssign(1)})}),L(l,h,u)}).setLayout({name:"mx_rgbtohsv",type:"vec3",inputs:[{name:"c",type:"vec3"}]}),oj=k(([e])=>{let t=L(e).toVar(),i=iv(dv(t,L(.04045))).toVar();return Ze(L(t.div(12.92)).toVar(),L(Gs(ti(t.add(L(.055)),L(0)).div(1.055),L(2.4))).toVar(),i)}).setLayout({name:"mx_srgb_texture_to_lin_rec709",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),yL=(e,t)=>{e=C(e),t=C(t);let i=se(t.dFdx(),t.dFdy()).length().mul(.7071067811865476);return pn(e.sub(i),e.add(i),t)},xL=(e,t,i,r)=>Ze(e,t,i[r].clamp()),lj=(e,t,i=Mt())=>xL(e,t,i,"x"),hj=(e,t,i=Mt())=>xL(e,t,i,"y"),uj=(e,t,i,r,s=Mt())=>{let n=s.x.clamp(),a=s.y.clamp();return Ze(Ze(e,t,n),Ze(i,r,n),a)},vL=(e,t,i,r,s)=>Ze(e,t,yL(i,r[s])),dj=(e,t,i,r=Mt())=>vL(e,t,i,r,"x"),cj=(e,t,i,r=Mt())=>vL(e,t,i,r,"y"),pj=(e=1,t=0,i=Mt())=>i.mul(e).add(t),mj=(e,t=1)=>(e=C(e),e.abs().pow(t).mul(e.sign())),gj=(e,t=1,i=.5)=>C(e).sub(i).mul(t).add(i),fj=(e=Mt(),t=1,i=0)=>p_(e.convert("vec2|vec3")).mul(t).add(i),yj=(e=Mt(),t=1,i=0)=>Pp(e.convert("vec2|vec3")).mul(t).add(i),xj=(e=Mt(),t=1,i=0)=>(e=e.convert("vec2|vec3"),Te(Pp(e),p_(e.add(se(19,73)))).mul(t).add(i)),vj=(e,t=Mt(),i=se(1,1),r=se(0,0),s=1,n=0,a=1,o=!1,l=1,h=2,u=.5)=>rj(e,t.convert("vec2|vec3"),i,r,s,n,a,o,l,h,u),bj=(e,t=Mt(),i=se(1,1),r=se(0,0),s=1,n=0,a=1,o=!1,l=1,h=2,u=.5)=>sj(e,t.convert("vec2|vec3"),i,r,s,n,a,o,l,h,u),_j=(e=Mt(),t=1)=>tj(e.convert("vec2|vec3"),t,A(1)),Tj=(e=Mt(),t=1)=>ij(e.convert("vec2|vec3"),t,A(1)),wj=(e=Mt(),t=1)=>m_(e.convert("vec2|vec3"),t,A(1)),Sj=(e=Mt())=>Y9(e.convert("vec2|vec3")),Mj=(e=Mt(),t=3,i=2,r=.5,s=1)=>S0(e,A(t),i,r).mul(s),Cj=(e=Mt(),t=3,i=2,r=.5,s=1)=>K9(e,A(t),i,r).mul(s),Rj=(e=Mt(),t=3,i=2,r=.5,s=1)=>M0(e,A(t),i,r).mul(s),Ej=(e=Mt(),t=3,i=2,r=.5,s=1)=>Z9(e,A(t),i,r).mul(s),Aj=(e,t=C(0))=>wi(e,t),Nj=(e,t=C(0))=>tt(e,t),Lj=(e,t=C(1))=>Pe(e,t),Pj=(e,t=C(1))=>_s(e,t),kj=(e,t=C(1))=>dp(e,t),Ij=(e,t=C(1))=>Gs(e,t),Fj=(e=C(0),t=C(1))=>fv(e,t),Dj=()=>xd,Oj=()=>TN,Bj=(e,t=C(1))=>tt(t,e),Uj=(e,t,i,r)=>e.greaterThan(t).mix(i,r),Vj=(e,t,i,r)=>e.greaterThanEqual(t).mix(i,r),zj=(e,t,i,r)=>e.equal(t).mix(i,r),Gj=(e,t=null)=>{if(typeof t=="string"){let i={x:0,r:0,y:1,g:1,z:2,b:2,w:3,a:3},r=t.replace(/^out/,"").toLowerCase();if(i[r]!==void 0)return e.element(i[r])}if(typeof t=="number")return e.element(t);if(typeof t=="string"&&t.length===1){let i={x:0,r:0,y:1,g:1,z:2,b:2,w:3,a:3};if(i[t]!==void 0)return e.element(i[t])}return e},jj=(e,t=se(.5,.5),i=se(1,1),r=C(0),s=se(0,0))=>{let n=e;if(t&&(n=n.sub(t)),i&&(n=n.mul(i)),r){let a=r.mul(Math.PI/180),o=a.cos(),l=a.sin();n=se(n.x.mul(o).sub(n.y.mul(l)),n.x.mul(l).add(n.y.mul(o)))}return t&&(n=n.add(t)),s&&(n=n.add(s)),n},$j=(e,t)=>{e=se(e),t=C(t);let i=t.mul(Math.PI/180);return _p(e,i)},Wj=(e,t,i)=>{e=L(e),t=C(t),i=L(i);let r=t.mul(Math.PI/180),s=i.normalize(),n=r.cos(),a=r.sin(),o=C(1).sub(n);return e.mul(n).add(s.cross(e).mul(a)).add(s.mul(s.dot(e)).mul(o))},Hj=(e,t)=>(e=L(e),t=C(t),lb(e,t)),qj=k(([e,t,i])=>{let r=ls(e).toVar(),s=tt(C(.5).mul(t.sub(i)),Zn).div(r).toVar(),n=tt(C(-.5).mul(t.sub(i)),Zn).div(r).toVar(),a=L().toVar();a.x=r.x.greaterThan(C(0)).select(s.x,n.x),a.y=r.y.greaterThan(C(0)).select(s.y,n.y),a.z=r.z.greaterThan(C(0)).select(s.z,n.z);let o=hs(a.x,a.y,a.z).toVar();return Zn.add(r.mul(o)).toVar().sub(i)}),bL=k(([e,t])=>{let i=e.x,r=e.y,s=e.z,n=t.element(0).mul(.886227);return n=n.add(t.element(1).mul(2*.511664).mul(r)),n=n.add(t.element(2).mul(2*.511664).mul(s)),n=n.add(t.element(3).mul(2*.511664).mul(i)),n=n.add(t.element(4).mul(2*.429043).mul(i).mul(r)),n=n.add(t.element(5).mul(2*.429043).mul(r).mul(s)),n=n.add(t.element(6).mul(s.mul(s).mul(.743125).sub(.247708))),n=n.add(t.element(7).mul(2*.429043).mul(i).mul(s)),n=n.add(t.element(8).mul(.429043).mul(Pe(i,i).sub(Pe(r,r)))),n}),v=Object.freeze({__proto__:null,BRDF_GGX:wb,BRDF_Lambert:Fh,BasicPointShadowFilter:lL,BasicShadowFilter:ZN,Break:uA,Const:SR,Continue:zV,DFGLUT:fp,D_GGX:AA,Discard:VR,EPSILON:cv,F_Schlick:fd,Fn:k,HALF_PI:R6,INFINITY:S6,If:Se,Loop:bt,NodeAccess:pr,NodeShaderStage:rp,NodeType:qU,NodeUpdateType:Re,OnBeforeMaterialUpdate:QG,OnBeforeObjectUpdate:JG,OnMaterialUpdate:ZG,OnObjectUpdate:KG,PCFShadowFilter:JN,PCFSoftShadowFilter:QN,PI:Tf,PI2:M6,PointShadowFilter:hL,Return:V6,Schlick_to_F0:Sb,ShaderNode:sd,Stack:df,Switch:g6,TBNViewMatrix:kh,TWO_PI:C6,VSMShadowFilter:eL,V_GGX_SmithCorrelated:EA,Var:wR,VarIntent:MR,abs:kt,acesFilmicToneMapping:DN,acos:gv,add:wi,addMethodChaining:H,addNodeElement:$6,agxToneMapping:ON,all:KC,alphaT:yf,and:FC,anisotropy:Zo,anisotropyB:Ch,anisotropyT:lp,any:ZC,append:v6,array:RC,arrayBuffer:y6,asin:tR,assign:EC,atan:fv,atomicAdd:Z7,atomicAnd:t9,atomicFunc:ra,atomicLoad:Y7,atomicMax:Q7,atomicMin:e9,atomicOr:i9,atomicStore:K7,atomicSub:J7,atomicXor:r9,attenuationColor:hv,attenuationDistance:lv,attribute:Ya,attributeArray:i7,backgroundBlurriness:MN,backgroundIntensity:Yb,backgroundRotation:CN,batch:aA,bentNormalView:_E,billboarding:IG,bitAnd:UC,bitNot:VC,bitOr:zC,bitXor:GC,bitangentGeometry:MV,bitangentLocal:CV,bitangentView:vE,bitangentWorld:RV,bitcast:bN,blendBurn:rz,blendColor:oz,blendDodge:sz,blendOverlay:az,blendScreen:nz,blur:KA,bool:vs,buffer:cp,bufferAttribute:Pv,builtin:Ka,builtinAOContext:_R,builtinShadowContext:bR,bumpMap:lb,bvec2:vC,bvec3:iv,bvec4:bC,bypass:BR,cache:OR,call:AC,cameraFar:sl,cameraIndex:il,cameraNear:rl,cameraNormalMatrix:tV,cameraPosition:XR,cameraProjectionMatrix:Za,cameraProjectionMatrixInverse:qR,cameraViewMatrix:js,cameraViewport:iV,cameraWorldMatrix:eV,cbrt:pR,cdl:y7,ceil:Sf,checker:W9,cineonToneMapping:FN,clamp:cn,clearcoat:pf,clearcoatNormalView:ol,clearcoatRoughness:nd,clipSpace:JR,code:f0,color:xC,colorSpaceToWorking:Rf,colorToDirection:AV,compute:DR,computeKernel:Iv,computeSkinning:UV,context:Xa,convert:TC,convertColorSpace:P6,convertToTexture:WG,cos:dn,
29countLeadingZeros:dG,countOneBits:cG,countTrailingZeros:uG,cross:qa,cubeTexture:Yr,cubeTextureBase:ib,dFdx:vv,dFdy:bv,dashSize:vf,debug:zR,decrement:XC,decrementBefore:HC,defaultBuildStages:nf,defaultShaderStages:lC,defined:rd,degrees:QC,deltaTime:CG,densityFogFactor:GN,depth:vb,depthPass:T7,determinant:aR,difference:uR,diffuseColor:vt,diffuseContribution:Mh,directPointLight:dL,directionToColor:TE,directionToFaceDirection:ud,dispersion:uv,disposeShadowMaterial:iL,distance:hR,div:_s,dot:zs,drawIndex:rA,dynamicBufferAttribute:O6,element:_C,emissive:nv,equal:NC,equirectUV:bb,exp:pv,exp2:od,exponentialHeightFogFactor:I7,expression:Ts,faceDirection:Jv,faceForward:Rv,faceforward:E6,float:C,floatBitsToInt:oG,floatBitsToUint:_N,floor:qn,fog:Qb,fract:un,frameGroup:_6,frameId:TN,frontFacing:QR,fwidth:Tv,gain:mG,gapSize:av,getConstNodeType:yC,getCurrentStack:Qx,getDirection:XA,getDistanceAttenuation:c_,getGeometryRoughness:RA,getNormalFromDepth:qG,getParallaxCorrectNormal:qj,getRoughness:Tb,getScreenPosition:HG,getShIrradianceAt:bL,getShadowMaterial:tL,getShadowRenderObjectFunction:sL,getTextureIndex:xN,getViewPosition:Td,ggxConvolution:ZA,globalId:U7,glsl:L7,glslFn:P7,grayscale:p7,greaterThan:dv,greaterThanEqual:IC,hash:pG,highpModelNormalViewMatrix:Kv,highpModelViewMatrix:Yv,hue:f7,increment:qC,incrementBefore:WC,inspector:GR,instance:BV,instanceIndex:Jn,instancedArray:r7,instancedBufferAttribute:Af,instancedDynamicBufferAttribute:kv,instancedMesh:nA,int:A,intBitsToFloat:lG,interleavedGradientNoise:qb,inverse:oR,inverseSqrt:mv,inversesqrt:A6,invocationLocalIndex:OV,invocationSubgroupIndex:DV,ior:hp,iridescence:mf,iridescenceIOR:gf,iridescenceThickness:ff,isolate:ld,ivec2:Ii,ivec3:tv,ivec4:rv,js:A7,label:TR,length:Xn,lengthSq:Mv,lessThan:PC,lessThanEqual:kC,lightPosition:i_,lightProjectionUV:jN,lightShadowMatrix:x0,lightTargetDirection:s_,lightTargetPosition:$N,lightViewPosition:r_,lightingContext:pA,lights:L9,linearDepth:Yf,linearToneMapping:kN,localId:V7,log:wf,log2:Hn,logarithmicDepthToViewZ:YV,luminance:Zb,mat2:cf,mat3:tr,mat4:Yo,matcapUV:oN,materialAO:eA,materialAlphaTest:SE,materialAnisotropy:UE,materialAnisotropyVector:pd,materialAttenuationColor:qE,materialAttenuationDistance:HE,materialClearcoat:kE,materialClearcoatNormal:FE,materialClearcoatRoughness:IE,materialColor:ME,materialDispersion:QE,materialEmissive:RE,materialEnvIntensity:Gf,materialEnvRotation:tb,materialIOR:WE,materialIridescence:VE,materialIridescenceIOR:zE,materialIridescenceThickness:GE,materialLightMap:db,materialLineDashOffset:ZE,materialLineDashSize:YE,materialLineGapSize:KE,materialLineScale:XE,materialLineWidth:PV,materialMetalness:LE,materialNormal:PE,materialOpacity:hb,materialPointSize:JE,materialReference:Ja,materialReflectivity:qf,materialRefractionRatio:sE,materialRotation:DE,materialRoughness:NE,materialSheen:OE,materialSheenRoughness:BE,materialShininess:CE,materialSpecular:EE,materialSpecularColor:AE,materialSpecularIntensity:ub,materialSpecularStrength:mp,materialThickness:$E,materialTransmission:jE,max:ti,maxMipLevel:Ov,mediumpModelViewMatrix:ZR,metalness:Ha,min:hs,mix:Ze,mixElement:gR,mod:dp,modInt:YC,modelDirection:hV,modelNormalMatrix:KR,modelPosition:uV,modelRadius:pV,modelScale:dV,modelViewMatrix:nl,modelViewPosition:cV,modelViewProjection:tA,modelWorldMatrix:Ws,modelWorldMatrixInverse:mV,morphReference:cA,mrt:vN,mul:Pe,mx_aastep:yL,mx_add:Aj,mx_atan2:Fj,mx_cell_noise_float:Sj,mx_contrast:gj,mx_divide:Pj,mx_fractal_noise_float:Mj,mx_fractal_noise_vec2:Cj,mx_fractal_noise_vec3:Rj,mx_fractal_noise_vec4:Ej,mx_frame:Oj,mx_heighttonormal:Hj,mx_hsvtorgb:nj,mx_ifequal:zj,mx_ifgreater:Uj,mx_ifgreatereq:Vj,mx_invert:Bj,mx_modulo:kj,mx_multiply:Lj,mx_noise_float:fj,mx_noise_vec3:yj,mx_noise_vec4:xj,mx_place2d:jj,mx_power:Ij,mx_ramp4:uj,mx_ramplr:lj,mx_ramptb:hj,mx_rgbtohsv:aj,mx_rotate2d:$j,mx_rotate3d:Wj,mx_safepower:mj,mx_separate:Gj,mx_splitlr:dj,mx_splittb:cj,mx_srgb_texture_to_lin_rec709:oj,mx_subtract:Nj,mx_timer:Dj,mx_transform_uv:pj,mx_unifiednoise2d:vj,mx_unifiednoise3d:bj,mx_worley_noise_float:_j,mx_worley_noise_vec2:Tj,mx_worley_noise_vec3:wj,negate:xv,neutralToneMapping:BN,nodeArray:wh,nodeImmutable:pe,nodeObject:xe,nodeObjectIntent:np,nodeObjects:uf,nodeProxy:Fe,nodeProxyIntent:ne,normalFlat:eE,normalGeometry:zf,normalLocal:us,normalMap:ob,normalView:nt,normalViewGeometry:dd,normalWorld:al,normalWorldGeometry:tE,normalize:ls,not:OC,notEqual:LC,numWorkgroups:O7,objectDirection:rV,objectGroup:MC,objectPosition:nV,objectRadius:lV,objectScale:aV,objectViewPosition:oV,objectWorldMatrix:sV,oneMinus:iR,or:DC,orthographicDepthToViewZ:XV,oscSawtooth:NG,oscSine:RG,oscSquare:EG,oscTriangle:AG,output:ad,outputStruct:sG,overloadingFn:mr,packHalf2x16:vG,packSnorm2x16:yG,packUnorm2x16:xG,parabola:Gb,parallaxDirection:bE,parallaxUV:EV,parameter:Q8,pass:b7,passTexture:_7,pcurve:gG,perspectiveDepthToViewZ:yb,pmremTexture:Bb,pointShadow:uL,pointUV:s7,pointWidth:b6,positionGeometry:pp,positionLocal:ii,positionPrevious:hd,positionView:yi,positionViewDirection:Lt,positionWorld:Zn,positionWorldDirection:Zv,posterize:x7,pow:Gs,pow2:wv,pow3:dR,pow4:Sv,premultiplyAlpha:bA,property:Wa,quadBroadcast:E9,quadSwapDiagonal:T9,quadSwapX:b9,quadSwapY:_9,radians:JC,rand:mR,range:F7,rangeFogFactor:zN,reciprocal:sR,reference:qt,referenceBuffer:rb,reflect:lR,reflectVector:oE,reflectView:nE,reflector:zG,refract:Cv,refractVector:lE,refractView:aE,reinhardToneMapping:IN,remap:Fv,remapClamp:UR,renderGroup:we,renderOutput:Lf,rendererReference:LR,replaceDefaultUV:LG,rotate:_p,rotateUV:PG,roughness:Wn,round:rR,rtt:SN,sRGBTransferEOTF:RR,sRGBTransferOETF:ER,sample:YG,sampler:X6,samplerComparison:Y6,saturate:Mf,saturation:m7,screenCoordinate:Ph,screenDPR:WR,screenSize:Lh,screenUV:Kn,select:wr,setCurrentStack:ap,setName:Ev,shaderStages:af,shadow:aL,shadowPositionWorld:o_,shapeCircle:H9,sharedUniformGroup:_f,sheen:bs,sheenRoughness:Ko,shiftLeft:jC,shiftRight:$C,shininess:xf,sign:yv,sin:qr,sinc:fG,skinning:hA,smoothstep:pn,smoothstepElement:fR,specularColor:Jo,specularColorBlended:Rh,specularF90:Eh,spherizeUV:kG,split:x6,spritesheetUV:DG,sqrt:Hr,stack:a0,step:Ah,stepElement:yR,storage:ll,storageBarrier:j7,storageTexture:RN,string:f6,struct:rG,sub:tt,subBuild:Nh,subgroupAdd:a9,subgroupAll:y9,subgroupAnd:c9,subgroupAny:x9,subgroupBallot:n9,subgroupBroadcast:w9,subgroupBroadcastFirst:v9,subgroupElect:s9,subgroupExclusiveAdd:l9,subgroupExclusiveMul:d9,subgroupInclusiveAdd:o9,subgroupInclusiveMul:u9,subgroupIndex:FV,subgroupMax:f9,subgroupMin:g9,subgroupMul:h9,subgroupOr:p9,subgroupShuffle:S9,subgroupShuffleDown:R9,subgroupShuffleUp:C9,subgroupShuffleXor:M9,subgroupSize:z7,subgroupXor:m9,tan:eR,tangentGeometry:$f,tangentLocal:cd,tangentView:Wf,tangentWorld:xE,texture:st,texture3D:Kb,texture3DLevel:l7,texture3DLoad:o7,textureBarrier:$7,textureBicubic:Fz,textureBicubicLevel:Eb,textureCubeUV:YA,textureLevel:q6,textureLoad:ni,textureSize:tl,textureStore:n7,thickness:ov,time:xd,toneMapping:PR,toneMappingExposure:kR,toonOutlinePass:S7,transformDirection:cR,transformNormal:iE,transformNormalToView:Qv,transformedClearcoatNormalView:yV,transformedNormalView:gV,transformedNormalWorld:fV,transmission:bf,transpose:nR,triNoise3D:SG,triplanarTexture:OG,triplanarTextures:wN,trunc:_v,uint:K,uintBitsToFloat:hG,uniform:be,uniformArray:Sr,uniformCubeTexture:xV,uniformFlow:vR,uniformGroup:SC,uniformTexture:H6,unpackHalf2x16:TG,unpackNormal:ab,unpackSnorm2x16:bG,unpackUnorm2x16:_G,unpremultiplyAlpha:lz,userData:u7,uv:Mt,uvec2:ev,uvec3:Sh,uvec4:sv,varying:Qo,varyingProperty:op,vec2:se,vec3:L,vec4:Te,vectorComponents:_h,velocity:c7,vertexColor:vA,vertexIndex:iA,vertexStage:CR,vibrance:g7,viewZToLogarithmicDepth:xb,viewZToOrthographicDepth:gd,viewZToPerspectiveDepth:fb,viewZToReversedOrthographicDepth:qV,viewZToReversedPerspectiveDepth:gA,viewport:Vv,viewportCoordinate:HR,viewportDepthTexture:gb,viewportLinearDepth:KV,viewportMipTexture:pb,viewportOpaqueMipTexture:mA,viewportResolution:Q6,viewportSafeUV:FG,viewportSharedTexture:v7,viewportSize:zv,viewportTexture:WV,viewportUV:J6,vogelDiskSample:mn,wgsl:N7,wgslFn:k7,workgroupArray:q7,workgroupBarrier:G7,workgroupId:B7,workingToColorSpace:AR,xor:BC}),gn=new zb,Xj=class extends cl{constructor(e,t){super(),this.renderer=e,this.nodes=t}
29update(e,t,i){let r=this.renderer,s=this.nodes.getBackgroundNode(e)||e.background,n=!1;if(s===null)r._clearColor.getRGB(gn),gn.a=r._clearColor.a;else if(s.isColor===!0)s.getRGB(gn),gn.a=1,n=!0;else if(s.isNode===!0){let o=this.get(e),l=s;gn.copy(r._clearColor);let h=o.backgroundMesh;if(h===void 0){let x=function(){s.removeEventListener("dispose",x),h.material.dispose(),h.geometry.dispose()},d=Te(l).mul(Yb).context({getUV:()=>CN.mul(tE),getTextureLevel:()=>MN}),c=Za.element(3).element(3).equal(1),p=_s(1,Za.element(1).element(1)).mul(3),m=c.select(ii.mul(p),ii),g=nl.mul(Te(m,0)),f=Za.mul(Te(g.xyz,1));f=f.setZ(f.w);let y=new Ot;y.name="Background.material",y.side=1,y.depthTest=!1,y.depthWrite=!1,y.allowOverride=!1,y.fog=!1,y.lights=!1,y.vertexNode=f,y.colorNode=d,o.backgroundMeshNode=d,o.backgroundMesh=h=new xt(new q4(1,32,32),y),h.frustumCulled=!1,h.name="Background.mesh",s.addEventListener("dispose",x)}let u=l.getCacheKey();o.backgroundCacheKey!==u&&(o.backgroundMeshNode.node=Te(l).mul(Yb),o.backgroundMeshNode.needsUpdate=!0,h.material.needsUpdate=!0,o.backgroundCacheKey=u),t.unshift(h,h.geometry,h.material,0,0,null,null)}else re("Renderer: Unsupported background configuration.",s);let a=r.xr.getEnvironmentBlendMode();if(a==="additive"?gn.set(0,0,0,1):a==="alpha-blend"&&gn.set(0,0,0,0),r.autoClear===!0||n===!0){let o=i.clearColorValue;o.r=gn.r,o.g=gn.g,o.b=gn.b,o.a=gn.a,(r.backend.isWebGLBackend===!0||r.alpha===!0)&&(o.r*=o.a,o.g*=o.a,o.b*=o.a),i.depthClearValue=r.getClearDepth(),i.stencilClearValue=r.getClearStencil(),i.clearColor=r.autoClearColor===!0,i.clearDepth=r.autoClearDepth===!0,i.clearStencil=r.autoClearStencil===!0}else i.clearColor=!1,i.clearDepth=!1,i.clearStencil=!1}},Yj=0,g_=class{constructor(e="",t=[]){this.name=e,this.bindings=t,this.id=Yj++}},Kj=class{constructor(e,t,i,r,s,n,a,o,l,h=[]){this.vertexShader=e,this.fragmentShader=t,this.computeShader=i,this.transforms=h,this.nodeAttributes=r,this.bindings=s,this.updateNodes=n,this.updateBeforeNodes=a,this.updateAfterNodes=o,this.observer=l,this.usedTimes=0}createBindings(){let e=[];for(let t of this.bindings)if(t.bindings[0].groupNode.shared!==!0){let i=new g_(t.name,[]);e.push(i);for(let r of t.bindings)i.bindings.push(r.clone())}else e.push(t);return e}},_L=class{constructor(e,t,i=null){this.isNodeAttribute=!0,this.name=e,this.type=t,this.node=i}},Zj=class{constructor(e,t,i){this.isNodeUniform=!0,this.name=e,this.type=t,this.node=i}get value(){return this.node.value}set value(e){this.node.value=e}get id(){return this.node.id}get groupNode(){return this.node.groupNode}},TL=class{constructor(e,t,i=!1,r=null){this.isNodeVar=!0,this.name=e,this.type=t,this.readOnly=i,this.count=r}},Jj=class extends TL{constructor(e,t,i=null,r=null){super(e,t),this.needsInterpolation=!1,this.isNodeVarying=!0,this.interpolationType=i,this.interpolationSampling=r}},Qj=class{constructor(e,t,i=""){this.name=e,this.type=t,this.code=i,Object.defineProperty(this,"isNodeCode",{value:!0})}},e$=0,f_=class{constructor(e=null){this.id=e$++,this.nodesData=new WeakMap,this.parent=e}getData(e){let t=this.nodesData.get(e);return t===void 0&&this.parent!==null&&(t=this.parent.getData(e)),t}setData(e,t){this.nodesData.set(e,t)}},t$=class{constructor(e,t){this.name=e,this.members=t,this.output=!1}},gl=class{constructor(e,t){this.name=e,this.value=t,this.boundary=0,this.itemSize=0,this.offset=0,this.index=-1}setValue(e){this.value=e}getValue(){return this.value}},i$=class extends gl{constructor(e,t=0){super(e,t),this.isNumberUniform=!0,this.boundary=4,this.itemSize=1}},r$=class extends gl{constructor(e,t=new ge){super(e,t),this.isVector2Uniform=!0,this.boundary=8,this.itemSize=2}},s$=class extends gl{constructor(e,t=new F){super(e,t),this.isVector3Uniform=!0,this.boundary=16,this.itemSize=3}},n$=class extends gl{constructor(e,t=new yt){super(e,t),this.isVector4Uniform=!0,this.boundary=16,this.itemSize=4}},a$=class extends gl{constructor(e,t=new Ke){super(e,t),this.isColorUniform=!0,this.boundary=16,this.itemSize=3}},o$=class extends gl{constructor(e,t=new rC){super(e,t),this.isMatrix2Uniform=!0,this.boundary=8,this.itemSize=4}},l$=class extends gl{constructor(e,t=new Os){super(e,t),this.isMatrix3Uniform=!0,this.boundary=48,this.itemSize=12}},h$=class extends gl{constructor(e,t=new $e){super(e,t),this.isMatrix4Uniform=!0,this.boundary=64,this.itemSize=16}},u$=class extends i${constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}},d$=class extends r${constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}},c$=class extends s${constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}},p$=class extends n${constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}},m$=class extends a${constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}},g$=class extends o${constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}},f$=class extends l${constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}},y$=class extends h${constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}},x$=0,wL=new WeakMap,v$=new WeakMap,b$=new Map([[Int8Array,"int"],[Int16Array,"int"],[Int32Array,"int"],[Uint8Array,"uint"],[Uint16Array,"uint"],[Uint32Array,"uint"],[Float32Array,"float"]]),C0=e=>/e/g.test(e)?String(e).replace(/\+/g,""):(e=Number(e),e+(e%1?"":".0")),SL=class{constructor(e,t,i){this.object=e,this.material=e&&e.material||null,this.geometry=e&&e.geometry||null,this.renderer=t,this.parser=i,this.scene=null,this.camera=null,this.nodes=[],this.sequentialNodes=[],this.updateNodes=[],this.updateBeforeNodes=[],this.updateAfterNodes=[],this.hashNodes={},this.observer=null,this.lightsNode=null,this.environmentNode=null,this.fogNode=null,this.clippingContext=null,this.vertexShader=null,this.fragmentShader=null,this.computeShader=null,this.flowNodes={vertex:[],fragment:[],compute:[]},this.flowCode={vertex:"",fragment:"",compute:""},this.uniforms={vertex:[],fragment:[],compute:[],index:0},this.structs={vertex:[],fragment:[],compute:[],index:0},this.types={vertex:[],fragment:[],compute:[],index:0},this.bindings={vertex:{},fragment:{},compute:{}},this.bindingsIndexes={},this.bindGroups=null,this.attributes=[],this.bufferAttributes=[],this.varyings=[],this.codes={},this.vars={},this.declarations={},this.flow={code:""},this.chaining=[],this.stack=a0(),this.stacks=[],this.tab="	",this.currentFunctionNode=null,this.context={material:this.material},this.cache=new f_,this.globalCache=this.cache,this.flowsData=new WeakMap,this.shaderStage=null,this.buildStage=null,this.subBuildLayers=[],this.activeStacks=[],this.subBuildFn=null,this.fnCall=null,Object.defineProperty(this,"id",{value:x$++})}isFlatShading(){return this.material.flatShading===!0||this.geometry.hasAttribute("normal")===!1}
29isOpaque(){let e=this.material;return e.transparent===!1&&e.blending===1&&e.alphaToCoverage===!1}createRenderTarget(e,t,i){return new zr(e,t,i)}createCubeRenderTarget(e,t){return new _A(e,t)}includes(e){return this.nodes.includes(e)}getOutputStructName(){}_getBindGroup(e,t){let i=t[0].groupNode,r=i.shared;if(r)for(let n=1;n<t.length;n++)i!==t[n].groupNode&&(r=!1);let s;if(r){let n="";for(let h of t)if(h.isNodeUniformsGroup){h.uniforms.sort((u,d)=>u.nodeUniform.node.id-d.nodeUniform.node.id);for(let u of h.uniforms)n+=u.nodeUniform.node.id}else n+=h.nodeUniform.id;let a=this.renderer._currentRenderContext||this.renderer,o=wL.get(a);o===void 0&&(o=new Map,wL.set(a,o));let l=id(n);s=o.get(l),s===void 0&&(s=new g_(e,t),o.set(l,s))}else s=new g_(e,t);return s}getBindGroupArray(e,t){let i=this.bindings[t],r=i[e];return r===void 0&&(this.bindingsIndexes[e]===void 0&&(this.bindingsIndexes[e]={binding:0,group:Object.keys(this.bindingsIndexes).length}),i[e]=r=[]),r}getBindings(){let e=this.bindGroups;if(e===null){let t={},i=this.bindings;for(let r of af)for(let s in i[r]){let n=i[r][s],a=t[s]||(t[s]=[]);for(let o of n)a.includes(o)===!1&&a.push(o)}e=[];for(let r in t){let s=t[r],n=this._getBindGroup(r,s);e.push(n)}this.bindGroups=e}return e}sortBindingGroups(){let e=this.getBindings();e.sort((t,i)=>t.bindings[0].groupNode.order-i.bindings[0].groupNode.order);for(let t=0;t<e.length;t++){let i=e[t];this.bindingsIndexes[i.name].group=t}}setHashNode(e,t){this.hashNodes[t]=e}addNode(e){this.nodes.includes(e)===!1&&(this.nodes.push(e),this.setHashNode(e,e.getHash(this)))}addSequentialNode(e){let t=e.getUpdateBeforeType(),i=e.getUpdateAfterType();(t!==Re.NONE||i!==Re.NONE)&&this.sequentialNodes.includes(e)===!1&&this.sequentialNodes.push(e)}buildUpdateNodes(){for(let e of this.nodes)e.getUpdateType()!==Re.NONE&&this.updateNodes.push(e);for(let e of this.sequentialNodes){let t=e.getUpdateBeforeType(),i=e.getUpdateAfterType();t!==Re.NONE&&this.updateBeforeNodes.push(e),i!==Re.NONE&&this.updateAfterNodes.push(e)}}get currentNode(){return this.chaining[this.chaining.length-1]}isFilteredTexture(e){return e.magFilter===1006||e.magFilter===1007||e.magFilter===1005||e.magFilter===1008||e.minFilter===1006||e.minFilter===1007||e.minFilter===1005||e.minFilter===1008}getUniformBufferLimit(){return this.renderer.backend.capabilities.getUniformBufferLimit()}addChain(e){this.chaining.push(e)}removeChain(e){if(this.chaining.pop()!==e)throw Error("NodeBuilder: Invalid node chaining!")}getMethod(e){return e}getTernary(){return null}getNodeFromHash(e){return this.hashNodes[e]}addFlow(e,t){return this.flowNodes[e].push(t),t}setContext(e){this.context=e}getContext(){return this.context}addContext(e){let t=this.getContext();return this.setContext({...this.context,...e}),t}getSharedContext(){let e={...this.context};return delete e.material,delete e.getUV,delete e.getOutput,delete e.getTextureLevel,delete e.getAO,delete e.getShadow,e}setCache(e){this.cache=e}getCache(){return this.cache}getCacheFromNode(e,t=!0){let i=this.getDataFromNode(e);return i.cache===void 0&&(i.cache=new f_(t?this.getCache():null)),i.cache}isAvailable(){return!1}getVertexIndex(){de("Abstract function.")}getInstanceIndex(){de("Abstract function.")}getDrawIndex(){de("Abstract function.")}getFrontFacing(){de("Abstract function.")}getFragCoord(){de("Abstract function.")}isFlipY(){return!1}increaseUsage(e){let t=this.getDataFromNode(e);return t.usageCount=t.usageCount===void 0?1:t.usageCount+1,t.usageCount}generateTexture(){de("Abstract function.")}generateTextureLod(){de("Abstract function.")}generateArrayDeclaration(e,t){return this.getType(e)+"[ "+t+" ]"}generateArray(e,t,i=null){let r=this.generateArrayDeclaration(e,t)+"( ";for(let s=0;s<t;s++){let n=i?i[s]:null;n===null?r+=this.generateConst(e):r+=n.build(this,e),s<t-1&&(r+=", ")}return r+=" )",r}generateStruct(e,t,i=null){let r=[];for(let s of t){let{name:n,type:a}=s;i&&i[n]&&i[n].isNode?r.push(i[n].build(this,a)):r.push(this.generateConst(a))}return e+"( "+r.join(", ")+" )"}generateConst(e,t=null){if(t===null&&(e==="float"||e==="int"||e==="uint"?t=0:e==="bool"?t=!1:e==="color"?t=new Ke:e==="vec2"||e==="uvec2"||e==="ivec2"?t=new ge:e==="vec3"||e==="uvec3"||e==="ivec3"?t=new F:(e==="vec4"||e==="uvec4"||e==="ivec4")&&(t=new yt)),e==="float")return C0(t);if(e==="int")return`${Math.round(t)}`;if(e==="uint")return t>=0?`${Math.round(t)}u`:"0u";if(e==="bool")return t?"true":"false";if(e==="color")return`${this.getType("vec3")}( ${C0(t.r)}, ${C0(t.g)}, ${C0(t.b)} )`;let i=this.getTypeLength(e),r=this.getComponentType(e),s=n=>this.generateConst(r,n);if(i===2)return`${this.getType(e)}( ${s(t.x)}, ${s(t.y)} )`;if(i===3)return`${this.getType(e)}( ${s(t.x)}, ${s(t.y)}, ${s(t.z)} )`;if(i===4&&e!=="mat2")return`${this.getType(e)}( ${s(t.x)}, ${s(t.y)}, ${s(t.z)}, ${s(t.w)} )`;if(i>=4&&t&&(t.isMatrix2||t.isMatrix3||t.isMatrix4))return`${this.getType(e)}( ${t.elements.map(s).join(", ")} )`;if(i>4)return`${this.getType(e)}()`;throw Error(`NodeBuilder: Type '${e}' not found in generate constant attempt.`)}getType(e){return e==="color"?"vec3":e}hasGeometryAttribute(e){return this.geometry&&this.geometry.getAttribute(e)!==void 0}getAttribute(e,t){let i=this.attributes;for(let s of i)if(s.name===e)return s;let r=new _L(e,t);return this.registerDeclaration(r),i.push(r),r}getPropertyName(e){return e.name}isVector(e){return/vec\d/.test(e)}isMatrix(e){return/mat\d/.test(e)}isReference(e){return e==="void"||e==="property"||e==="sampler"||e==="samplerComparison"||e==="texture"||e==="cubeTexture"||e==="storageTexture"||e==="depthTexture"||e==="texture3D"}needsToWorkingColorSpace(){return!1}getComponentTypeFromTexture(e){let t=e.type;if(e.isDataTexture){if(t===1013)return"int";if(t===1014)return"uint"}return"float"}getElementType(e){return e==="mat2"?"vec2":e==="mat3"?"vec3":e==="mat4"?"vec4":this.getComponentType(e)}getComponentType(e){if(e=this.getVectorType(e),e==="float"||e==="bool"||e==="int"||e==="uint")return e;let t=/(b|i|u|)(vec|mat)([2-4])/.exec(e);return t===null?null:t[1]==="b"?"bool":t[1]==="i"?"int":t[1]==="u"?"uint":"float"}getVectorType(e){return e==="color"?"vec3":e==="texture"||e==="cubeTexture"||e==="storageTexture"||e==="texture3D"?"vec4":e}getTypeFromLength(e,t="float"){if(e===1)return t;let i=nC(e),r=t==="float"?"":t[0];return/mat2/.test(t)===!0&&(i=i.replace("vec","mat")),r+i}getTypeFromArray(e){return b$.get(e.constructor)}isInteger(e){return/int|uint|(i|u)vec/.test(e)}getTypeFromAttribute(e){let t=e;e.isInterleavedBufferAttribute&&(t=e.data);let i=t.array,r=e.itemSize,s=e.normalized,n;return!(e instanceof TM)&&s!==!0&&(n=this.getTypeFromArray(i)),this.getTypeFromLength(r,n)}getTypeLength(e){let t=this.getVectorType(e),i=/vec([2-4])/.exec(t);return i===null?t==="float"||t==="bool"||t==="int"||t==="uint"?1:/mat2/.test(e)===!0?4:/mat3/.test(e)===!0?9:/mat4/.test(e)===!0?16:0:Number(i[1])}getVectorFromMatrix(e){return e.replace("mat","vec")}changeComponentType(e,t){return this.getTypeFromLength(this.getTypeLength(e),t)}getIntegerType(e){let t=this.getComponentType(e);return t==="int"||t==="uint"?e:this.changeComponentType(e,"int")}setActiveStack(e){this.activeStacks.push(e)}removeActiveStack(e){if(this.activeStacks[this.activeStacks.length-1]===e)this.activeStacks.pop();else throw Error("NodeBuilder: Invalid active stack removal.")}getActiveStack(){return this.activeStacks[this.activeStacks.length-1]}getBaseStack(){return this.activeStacks[0]}
29addStack(){this.stack=a0(this.stack);let e=Qx();return this.stacks.push(e),ap(this.stack),this.stack}removeStack(){let e=this.stack;for(let t of e.nodes){let i=this.getDataFromNode(t);i.stack=e}return this.stack=e.parent,ap(this.stacks.pop()),e}getDataFromNode(e,t=this.shaderStage,i=null){i=i===null?e.isGlobal(this)?this.globalCache:this.cache:i;let r=i.getData(e);r===void 0&&(r={},i.setData(e,r)),r[t]===void 0&&(r[t]={});let s=r[t],n=r.any?r.any.subBuilds:null,a=this.getClosestSubBuild(n);return a&&(s.subBuildsCache===void 0&&(s.subBuildsCache={}),s=s.subBuildsCache[a]||(s.subBuildsCache[a]={}),s.subBuilds=n),s}getNodeProperties(e,t="any"){let i=this.getDataFromNode(e,t);return i.properties||={outputNode:null}}getBufferAttributeFromNode(e,t){let i=this.getDataFromNode(e,"vertex"),r=i.bufferAttribute;return r===void 0&&(r=new _L("nodeAttribute"+this.uniforms.index++,t,e),this.bufferAttributes.push(r),i.bufferAttribute=r),r}getStructTypeNode(e,t=this.shaderStage){return this.types[t][e]||null}getStructTypeFromNode(e,t,i=null,r=this.shaderStage){let s=this.getDataFromNode(e,r,this.globalCache),n=s.structType;if(n===void 0){let a=this.structs.index++;i===null&&(i="StructType"+a),n=new t$(i,t),this.structs[r].push(n),this.types[r][i]=e,s.structType=n}return n}getOutputStructTypeFromNode(e,t){let i=this.getStructTypeFromNode(e,t,"OutputType","fragment");return i.output=!0,i}getUniformFromNode(e,t,i=this.shaderStage,r=null){let s=this.getDataFromNode(e,i,this.globalCache),n=s.uniform;if(n===void 0){let a=this.uniforms.index++;n=new Zj(r||"nodeUniform"+a,t,e),this.uniforms[i].push(n),this.registerDeclaration(n),s.uniform=n}return n}getVarFromNode(e,t=null,i=e.getNodeType(this),r=this.shaderStage,s=!1){let n=this.getDataFromNode(e,r),a=this.getSubBuildProperty("variable",n.subBuilds),o=n[a];if(o===void 0){let l=s?"_const":"_var",h=this.vars[r]||(this.vars[r]=[]),u=this.vars[l]||(this.vars[l]=0);t===null&&(t=(s?"nodeConst":"nodeVar")+u,this.vars[l]++),a!=="variable"&&(t=this.getSubBuildProperty(t,n.subBuilds));let d=e.getArrayCount(this);o=new TL(t,i,s,d),s||h.push(o),this.registerDeclaration(o),n[a]=o}return o}isDeterministic(e){if(e.isMathNode)return this.isDeterministic(e.aNode)&&(e.bNode?this.isDeterministic(e.bNode):!0)&&(e.cNode?this.isDeterministic(e.cNode):!0);if(e.isOperatorNode)return this.isDeterministic(e.aNode)&&(e.bNode?this.isDeterministic(e.bNode):!0);if(e.isArrayNode){if(e.values!==null){for(let t of e.values)if(!this.isDeterministic(t))return!1}return!0}else if(e.isConstNode)return!0;return!1}getVaryingFromNode(e,t=null,i=e.getNodeType(this),r=null,s=null){let n=this.getDataFromNode(e,"any"),a=this.getSubBuildProperty("varying",n.subBuilds),o=n[a];if(o===void 0){let l=this.varyings,h=l.length;t===null&&(t="nodeVarying"+h),a!=="varying"&&(t=this.getSubBuildProperty(t,n.subBuilds)),o=new Jj(t,i,r,s),l.push(o),this.registerDeclaration(o),n[a]=o}return o}registerDeclaration(e){let t=this.shaderStage,i=this.declarations[t]||(this.declarations[t]={}),r=this.getPropertyName(e),s=1,n=r;for(;i[n]!==void 0;)n=r+"_"+s++;s>1&&(e.name=n,de(`TSL: Declaration name '${r}' of '${e.type}' already in use. Renamed to '${n}'.`)),i[n]=e}getCodeFromNode(e,t,i=this.shaderStage){let r=this.getDataFromNode(e),s=r.code;if(s===void 0){let n=this.codes[i]||(this.codes[i]=[]),a=n.length;s=new Qj("nodeCode"+a,t),n.push(s),r.code=s}return s}addFlowCodeHierarchy(e,t){let{flowCodes:i,flowCodeBlock:r}=this.getDataFromNode(e),s=!0,n=t;for(;n;){if(r.get(n)===!0){s=!1;break}n=this.getDataFromNode(n).parentNodeBlock}if(s)for(let a of i)this.addLineFlowCode(a)}addLineFlowCodeBlock(e,t,i){let r=this.getDataFromNode(e),s=r.flowCodes||=[],n=r.flowCodeBlock||=new WeakMap;s.push(t),n.set(i,!0)}addLineFlowCode(e,t=null){return e===""?this:(t!==null&&this.context.nodeBlock&&this.addLineFlowCodeBlock(t,e,this.context.nodeBlock),e=this.tab+e,/;\s*$/.test(e)||(e+=`;
30`),this.flow.code+=e,this)}addFlowCode(e){return this.flow.code+=e,this}addFlowTab(){return this.tab+="	",this}removeFlowTab(){return this.tab=this.tab.slice(0,-1),this}getFlowData(e){return this.flowsData.get(e)}flowNode(e){let t=e.getNodeType(this),i=this.flowChildNode(e,t);return this.flowsData.set(e,i),i}addInclude(e){this.currentFunctionNode!==null&&this.currentFunctionNode.includes.push(e)}buildFunctionNode(e){let t=new UN,i=this.currentFunctionNode;return this.currentFunctionNode=t,t.code=this.buildFunctionCode(e),this.currentFunctionNode=i,t}flowShaderNode(e){let t=e.layout,i={[Symbol.iterator](){let n=0,a=Object.values(this);return{next:()=>({value:a[n],done:n++>=a.length})}}};
30for(let n of t.inputs)i[n.name]=new gN(n.type,n.name);e.layout=null;let r=e.call(i),s=this.flowStagesNode(r,t.type);return e.layout=t,s}flowBuildStage(e,t,i=null){let r=this.getBuildStage();this.setBuildStage(t);let s=e.build(this,i);return this.setBuildStage(r),s}flowStagesNode(e,t=null){let i=this.flow,r=this.vars,s=this.declarations,n=this.cache,a=this.buildStage,o=this.stack,l={code:""};this.flow=l,this.vars={},this.declarations={},this.cache=new f_,this.stack=a0();for(let h of nf)this.setBuildStage(h),l.result=e.build(this,t);return l.vars=this.getVars(this.shaderStage),this.flow=i,this.vars=r,this.declarations=s,this.cache=n,this.stack=o,this.setBuildStage(a),l}getFunctionOperator(){return null}buildFunctionCode(){de("Abstract function.")}flowChildNode(e,t=null){let i=this.flow,r={code:""};return this.flow=r,r.result=e.build(this,t),this.flow=i,r}flowNodeFromShaderStage(e,t,i=null,r=null){let s=this.tab,n=this.cache,a=this.shaderStage,o=this.context;this.setShaderStage(e);let l={...this.context};delete l.nodeBlock,this.cache=this.globalCache,this.tab="	",this.context=l;let h=null;if(this.buildStage==="generate"){let u=this.flowChildNode(t,i);r!==null&&(u.code+=`${this.tab+r} = ${u.result};
31`),this.flowCode[e]=this.flowCode[e]+u.code,h=u}else h=t.build(this);return this.setShaderStage(a),this.cache=n,this.tab=s,this.context=o,h}getAttributesArray(){return this.attributes.concat(this.bufferAttributes)}getAttributes(){de("Abstract function.")}getVaryings(){de("Abstract function.")}getVar(e,t,i=null){return`${i===null?this.getType(e):this.generateArrayDeclaration(e,i)} ${t}`}getVars(e){let t="",i=this.vars[e];if(i!==void 0)for(let r of i)t+=`${this.getVar(r.type,r.name)}; `;return t}getUniforms(){de("Abstract function.")}getCodes(e){let t=this.codes[e],i="";if(t!==void 0)for(let r of t)i+=r.code+`
32`;return i}getHash(){return this.vertexShader+this.fragmentShader+this.computeShader}setShaderStage(e){this.shaderStage=e}getShaderStage(){return this.shaderStage}setBuildStage(e){this.buildStage=e}getBuildStage(){return this.buildStage}buildCode(){de("Abstract function.")}get subBuild(){return this.subBuildLayers[this.subBuildLayers.length-1]||null}addSubBuild(e){this.subBuildLayers.push(e)}removeSubBuild(){return this.subBuildLayers.pop()}getClosestSubBuild(e){let t;if(t=e&&e.isNode?e.isShaderCallNodeInternal?e.shaderNode.subBuilds:e.isStackNode?[e.subBuild]:this.getDataFromNode(e,"any").subBuilds:e instanceof Set?[...e]:e,!t)return null;let i=this.subBuildLayers;for(let r=t.length-1;r>=0;r--){let s=t[r];if(i.includes(s))return s}return null}getSubBuildOutput(e){return this.getSubBuildProperty("outputNode",e)}getSubBuildProperty(e="",t=null){let i;i=t===null?this.subBuildFn:this.getClosestSubBuild(t);let r;return r=i?e?i+"_"+e:i:e,r}build(){let{object:e,material:t,renderer:i}=this;if(t!==null){let r=i.library.fromMaterial(t);r===null&&(re(`NodeMaterial: Material "${t.type}" is not compatible.`),r=new Ot),r.build(this)}else this.addFlow("compute",e);for(let r of nf){this.setBuildStage(r),this.context.position&&this.context.position.isNode&&this.flowNodeFromShaderStage("vertex",this.context.position);for(let s of af){this.setShaderStage(s);let n=this.flowNodes[s];for(let a of n)r==="generate"?this.flowNode(a):a.build(this)}}return this.setBuildStage(null),this.setShaderStage(null),this.buildCode(),this.buildUpdateNodes(),this}async buildAsync(){let{object:e,material:t,renderer:i}=this;if(t!==null){let r=i.library.fromMaterial(t);r===null&&(re(`NodeMaterial: Material "${t.type}" is not compatible.`),r=new Ot),r.build(this)}else this.addFlow("compute",e);for(let r of nf){this.setBuildStage(r),this.context.position&&this.context.position.isNode&&this.flowNodeFromShaderStage("vertex",this.context.position);for(let s of af){this.setShaderStage(s);let n=this.flowNodes[s];for(let a of n)r==="generate"?this.flowNode(a):a.build(this);await rM()}}return this.setBuildStage(null),this.setShaderStage(null),this.buildCode(),this.buildUpdateNodes(),this}getSharedDataFromNode(e){let t=v$.get(e);return t===void 0&&(t={}),t}getNodeUniform(e,t){let i=this.getSharedDataFromNode(e),r=i.cache;if(r===void 0){if(t==="float"||t==="int"||t==="uint")r=new u$(e);else if(t==="vec2"||t==="ivec2"||t==="uvec2")r=new d$(e);
32else if(t==="vec3"||t==="ivec3"||t==="uvec3")r=new c$(e);else if(t==="vec4"||t==="ivec4"||t==="uvec4")r=new p$(e);else if(t==="color")r=new m$(e);else if(t==="mat2")r=new g$(e);else if(t==="mat3")r=new f$(e);else if(t==="mat4")r=new y$(e);else throw Error(`Uniform "${t}" not implemented.`);i.cache=r}return r}format(e,t,i){if(t=this.getVectorType(t),i=this.getVectorType(i),t===i||i===null||this.isReference(i))return e;let r=this.getTypeLength(t),s=this.getTypeLength(i);return r===16&&s===9?`${this.getType(i)}( ${e}[ 0 ].xyz, ${e}[ 1 ].xyz, ${e}[ 2 ].xyz )`:r===9&&s===4?`${this.getType(i)}( ${e}[ 0 ].xy, ${e}[ 1 ].xy )`:r>4||s>4||s===0?e:r===s?`${this.getType(i)}( ${e} )`:r>s?(e=i==="bool"?`all( ${e} )`:`${e}.${"xyz".slice(0,s)}`,this.format(e,this.getTypeFromLength(s,this.getComponentType(t)),i)):s===4&&r>1?`${this.getType(i)}( ${this.format(e,t,"vec3")}, 1.0 )`:r===2?`${this.getType(i)}( ${this.format(e,t,"vec2")}, 0.0 )`:(r===1&&s>1&&t!==this.getComponentType(i)&&(e=`${this.getType(this.getComponentType(i))}( ${e} )`),`${this.getType(i)}( ${e} )`)}getSignature(){return`// Three.js r${lh} - Node System
33`}needsPreviousData(){let e=this.renderer.getMRT();return e&&e.has("velocity")||oC(this.object).useVelocity===!0}},ML=class{constructor(){this.time=0,this.deltaTime=0,this.frameId=0,this.renderId=0,this.updateMap=new WeakMap,this.updateBeforeMap=new WeakMap,this.updateAfterMap=new WeakMap,this.renderer=null,this.material=null,this.camera=null,this.object=null,this.scene=null}_getMaps(e,t){let i=e.get(t);return i===void 0&&(i={renderId:0,frameId:0},e.set(t,i)),i}updateBeforeNode(e){let t=e.getUpdateBeforeType(),i=e.updateReference(this);if(t===Re.FRAME){let r=this._getMaps(this.updateBeforeMap,i);if(r.frameId!==this.frameId){let s=r.frameId;r.frameId=this.frameId,e.updateBefore(this)===!1&&(r.frameId=s)}}else if(t===Re.RENDER){let r=this._getMaps(this.updateBeforeMap,i);if(r.renderId!==this.renderId){let s=r.renderId;r.renderId=this.renderId,e.updateBefore(this)===!1&&(r.renderId=s)}}else t===Re.OBJECT&&e.updateBefore(this)}updateAfterNode(e){let t=e.getUpdateAfterType(),i=e.updateReference(this);if(t===Re.FRAME){let r=this._getMaps(this.updateAfterMap,i);r.frameId!==this.frameId&&e.updateAfter(this)!==!1&&(r.frameId=this.frameId)}else if(t===Re.RENDER){let r=this._getMaps(this.updateAfterMap,i);r.renderId!==this.renderId&&e.updateAfter(this)!==!1&&(r.renderId=this.renderId)}else t===Re.OBJECT&&e.updateAfter(this)}updateNode(e){let t=e.getUpdateType(),i=e.updateReference(this);if(t===Re.FRAME){let r=this._getMaps(this.updateMap,i);r.frameId!==this.frameId&&e.update(this)!==!1&&(r.frameId=this.frameId)}else if(t===Re.RENDER){let r=this._getMaps(this.updateMap,i);r.renderId!==this.renderId&&e.update(this)!==!1&&(r.renderId=this.renderId)}else t===Re.OBJECT&&e.update(this)}update(){this.frameId++,this.lastTime===void 0&&(this.lastTime=performance.now()),this.deltaTime=(performance.now()-this.lastTime)/1e3,this.lastTime=performance.now(),this.time+=this.deltaTime}},y_=class{constructor(e,t,i=null,r="",s=!1){this.type=e,this.name=t,this.count=i,this.qualifier=r,this.isConst=s}};y_.isNodeFunctionInput=!0;var _$=class extends Bh{static get type(){return"AmbientLightNode"}constructor(e=null){super(e)}setup({context:e}){e.irradiance.addAssign(this.colorNode)}},T$=class extends Bh{static get type(){return"DirectionalLightNode"}constructor(e=null){super(e)}setupDirect(){let e=this.colorNode;return{lightDirection:s_(this.light),lightColor:e}}},w$=class extends Bh{static get type(){return"HemisphereLightNode"}constructor(e=null){super(e),this.lightPositionNode=i_(e),this.lightDirectionNode=this.lightPositionNode.normalize(),this.groundColorNode=be(new Ke).setGroup(we)}update(e){let{light:t}=this;super.update(e),this.lightPositionNode.object3d=t,this.groundColorNode.value.copy(t.groundColor).multiplyScalar(t.intensity)}setup(e){let{colorNode:t,groundColorNode:i,lightDirectionNode:r}=this,s=Ze(i,t,al.dot(r).mul(.5).add(.5));e.context.irradiance.addAssign(s)}},x_=class extends Bh{static get type(){return"SpotLightNode"}constructor(e=null){super(e),this.coneCosNode=be(0).setGroup(we),this.penumbraCosNode=be(0).setGroup(we),this.cutoffDistanceNode=be(0).setGroup(we),this.decayExponentNode=be(0).setGroup(we),this.colorNode=be(this.color).setGroup(we)}update(e){super.update(e);let{light:t}=this;this.coneCosNode.value=Math.cos(t.angle),this.penumbraCosNode.value=Math.cos(t.angle*(1-t.penumbra)),this.cutoffDistanceNode.value=t.distance,this.decayExponentNode.value=t.decay}
33getSpotAttenuation(e,t){let{coneCosNode:i,penumbraCosNode:r}=this;return pn(i,r,t)}getLightCoord(e){let t=e.getNodeProperties(this),i=t.projectionUV;return i===void 0&&(i=jN(this.light,e.context.positionWorld),t.projectionUV=i),i}setupDirect(e){let{colorNode:t,cutoffDistanceNode:i,decayExponentNode:r,light:s}=this,n=this.getLightVector(e),a=n.normalize(),o=a.dot(s_(s)),l=this.getSpotAttenuation(e,o),h=c_({lightDistance:n.length(),cutoffDistance:i,decayExponent:r}),u=t.mul(l).mul(h),d,c;return s.colorNode?(c=this.getLightCoord(e),d=s.colorNode(c)):s.map&&(c=this.getLightCoord(e),d=st(s.map,c.xy).onRenderUpdate(()=>s.map)),d&&(u=c.mul(2).sub(1).abs().lessThan(1).all().select(u.mul(d),u)),{lightColor:u,lightDirection:a}}},S$=class extends x_{static get type(){return"IESSpotLightNode"}getSpotAttenuation(e,t){let i=this.light.iesMap,r=null;return r=i&&i.isTexture===!0?st(i,se(t.acos().mul(1/Math.PI),0),0).r:super.getSpotAttenuation(t),r}},M$=class extends Bh{static get type(){return"LightProbeNode"}constructor(e=null){super(e);let t=[];for(let i=0;i<9;i++)t.push(new F);this.lightProbe=Sr(t)}update(e){let{light:t}=this;super.update(e);for(let i=0;i<9;i++)this.lightProbe.array[i].copy(t.sh.coefficients[i]).multiplyScalar(t.intensity)}setup(e){let t=bL(al,this.lightProbe);e.context.irradiance.addAssign(t)}},C$=k(([e,t])=>{let i=e.abs().sub(t);return Xn(ti(i,0)).add(hs(ti(i.x,i.y),0))}),R$=class extends x_{static get type(){return"ProjectorLightNode"}update(e){super.update(e);let t=this.light;if(this.penumbraCosNode.value=Math.min(Math.cos(t.angle*(1-t.penumbra)),.99999),t.aspect===null){let i=1;t.map!==null&&(i=t.map.width/t.map.height),t.shadow.aspect=i}else t.shadow.aspect=t.aspect}getSpotAttenuation(e){let t=C(0),i=this.penumbraCosNode,r=x0(this.light).mul(e.context.positionWorld||Zn);return Se(r.w.greaterThan(0),()=>{let s=C$(r.xyz.div(r.w).xy.sub(se(.5)),se(.5)),n=_s(-1,tt(1,gv(i)).sub(1));t.assign(Mf(s.mul(-2).mul(n)))}),t}},v_=new $e,R0=new $e,kp=null,E$=class extends Bh{static get type(){return"RectAreaLightNode"}constructor(e=null){super(e),this.halfHeight=be(new F).setGroup(we),this.halfWidth=be(new F).setGroup(we),this.updateType=Re.RENDER}update(e){super.update(e);let{light:t}=this,i=e.camera.matrixWorldInverse;R0.identity(),v_.copy(t.matrixWorld),v_.premultiply(i),R0.extractRotation(v_),this.halfWidth.value.set(t.width*.5,0,0),this.halfHeight.value.set(0,t.height*.5,0),this.halfWidth.value.applyMatrix4(R0),this.halfHeight.value.applyMatrix4(R0)}setupDirectRectArea(e){let t,i;e.isAvailable("float32Filterable")?(t=st(kp.LTC_FLOAT_1),i=st(kp.LTC_FLOAT_2)):(t=st(kp.LTC_HALF_1),i=st(kp.LTC_HALF_2));let{colorNode:r,light:s}=this;return{lightColor:r,lightPosition:r_(s),halfWidth:this.halfWidth,halfHeight:this.halfHeight,ltc_1:t,ltc_2:i}}static setLTC(e){kp=e}},CL=class{parseFunction(){de("Abstract function.")}},b_=class{constructor(e,t,i="",r=""){this.type=e,this.inputs=t,this.name=i,this.precision=r}getCode(){de("Abstract function.")}};b_.isNodeFunction=!0;var A$=/^\s*(highp|mediump|lowp)?\s*([a-z_0-9]+)\s*([a-z_0-9]+)?\s*\(([\s\S]*?)\)/i,N$=/[a-z_0-9]+/gi,L$="#pragma main",P$=e=>{e=e.trim();let t=e.indexOf(L$),i=t===-1?e:e.slice(t+12),r=i.match(A$);if(r!==null&&r.length===5){let s=r[4],n=[],a=null;for(;(a=N$.exec(s))!==null;)n.push(a);let o=[],l=0;for(;l<n.length;){let d=n[l][0]==="const";d===!0&&l++;let c=n[l][0];c==="in"||c==="out"||c==="inout"?l++:c="";let p=n[l++][0],m=Number.parseInt(n[l][0]);Number.isNaN(m)===!1?l++:m=null;let g=n[l++][0];o.push(new y_(p,g,m,c,d))}let h=i.substring(r[0].length),u=r[3]===void 0?"":r[3];return{type:r[2],inputs:o,name:u,precision:r[1]===void 0?"":r[1],inputsCode:s,blockCode:h,headerCode:t===-1?"":e.slice(0,t)}}else throw Error("FunctionNode: Function is not a GLSL code.")},k$=class extends b_{constructor(e){let{type:t,inputs:i,name:r,precision:s,inputsCode:n,blockCode:a,headerCode:o}=P$(e);super(t,i,r,s),this.inputsCode=n,this.blockCode=a,this.headerCode=o}getCode(e=this.name){let t,i=this.blockCode;if(i!==""){let{type:r,inputsCode:s,headerCode:n,precision:a}=this,o=`${r} ${e} ( ${s.trim()} )`;a!==""&&(o=`${a} ${o}`),t=n+o+i}else t="";return t}},I$=class extends CL{parseFunction(e){return new k$(e)}},RL=new WeakMap,Ys=[],fl=[],F$=class extends cl{constructor(e,t){super(),this.renderer=e,this.backend=t,this.nodeFrame=new ML,this.nodeBuilderCache=new Map,this.callHashCache=new dl,this.groupsData=new dl,this._buildQueue=[],this._buildInProgress=!1,this.cacheLib={}}updateGroup(e){let t=e.groupNode;Ys[0]=t,Ys[1]=e;let i=this.groupsData.get(Ys);return i===void 0&&this.groupsData.set(Ys,i={}),Ys[0]=null,Ys[1]=null,i.version===t.version?!1:(i.version=t.version,!0)}getForRenderCacheKey(e){return e.initialCacheKey}_createNodeBuilder(e,t){let i=this.backend.createNodeBuilder(e.object,this.renderer);return i.scene=e.scene,i.material=t,i.camera=e.camera,i.context.material=t,i.lightsNode=e.lightsNode,i.environmentNode=this.getEnvironmentNode(e.scene),i.fogNode=this.getFogNode(e.scene),i.clippingContext=e.clippingContext,this.renderer.getOutputRe
33nderTarget()&&this.renderer.getOutputRenderTarget().multiview&&i.enableMultiview(),i}getForRender(e,t=!1){let i=this.get(e),r=i.nodeBuilderState;if(r===void 0){let{nodeBuilderCache:s}=this,n=this.getForRenderCacheKey(e);if(r=s.get(n),r===void 0){let a=async()=>{let o=this._createNodeBuilder(e,e.material);try{t?await o.buildAsync():o.build()}catch(l){o=this._createNodeBuilder(e,new Ot),t?await o.buildAsync():o.build(),re("TSL: "+l)}return o};if(t)return a().then(o=>(r=this._createNodeBuilderState(o),s.set(n,r),r.usedTimes++,i.nodeBuilderState=r,r));{let o=this._createNodeBuilder(e,e.material);try{o.build()}catch(l){o=this._createNodeBuilder(e,new Ot),o.build();let h=l.stackTrace;!h&&l.stack&&(h=new fi(l.stack)),re("TSL: "+l,h)}r=this._createNodeBuilderState(o),s.set(n,r)}}r.usedTimes++,i.nodeBuilderState=r}return r}getForRenderAsync(e){let t=this.getForRender(e,!0);return t.then?t:Promise.resolve(t)}getForRenderDeferred(e){let t=this.get(e);if(t.nodeBuilderState!==void 0)return t.nodeBuilderState;let i=this.getForRenderCacheKey(e),r=this.nodeBuilderCache.get(i);return r===void 0?(t.pendingBuild!==!0&&(t.pendingBuild=!0,this._buildQueue.push(()=>this.getForRenderAsync(e).then(()=>{t.pendingBuild=!1})),this._processBuildQueue()),null):(r.usedTimes++,t.nodeBuilderState=r,r)}_processBuildQueue(){this._buildInProgress||this._buildQueue.length===0||(this._buildInProgress=!0,this._buildQueue.shift()().then(()=>{this._buildInProgress=!1,this._processBuildQueue()}))}delete(e){if(e.isRenderObject){let t=this.get(e).nodeBuilderState;t!==void 0&&(t.usedTimes--,t.usedTimes===0&&this.nodeBuilderCache.delete(this.getForRenderCacheKey(e)))}return super.delete(e)}getForCompute(e){let t=this.get(e),i=t.nodeBuilderState;if(i===void 0){let r=this.backend.createNodeBuilder(e,this.renderer);r.build(),i=this._createNodeBuilderState(r),t.nodeBuilderState=i}return i}_createNodeBuilderState(e){return new Kj(e.vertexShader,e.fragmentShader,e.computeShader,e.getAttributesArray(),e.getBindings(),e.updateNodes,e.updateBeforeNodes,e.updateAfterNodes,e.observer,e.transforms)}getEnvironmentNode(e){this.updateEnvironment(e);let t=null;if(e.environmentNode&&e.environmentNode.isNode)t=e.environmentNode;else{let i=this.get(e);i.environmentNode&&(t=i.environmentNode)}return t}
33getBackgroundNode(e){this.updateBackground(e);let t=null;if(e.backgroundNode&&e.backgroundNode.isNode)t=e.backgroundNode;else{let i=this.get(e);i.backgroundNode&&(t=i.backgroundNode)}return t}getFogNode(e){return this.updateFog(e),e.fogNode||this.get(e).fogNode||null}getCacheKey(e,t){Ys[0]=e,Ys[1]=t;let i=this.renderer.info.calls,r=this.callHashCache.get(Ys)||{};if(r.callId!==i){let s=this.getEnvironmentNode(e),n=this.getFogNode(e);t&&fl.push(t.getCacheKey(!0)),s&&fl.push(s.getCacheKey()),n&&fl.push(n.getCacheKey()),fl.push(this.renderer.getOutputRenderTarget()&&this.renderer.getOutputRenderTarget().multiview?1:0),fl.push(+!!this.renderer.shadowMap.enabled),fl.push(this.renderer.shadowMap.type),r.callId=i,r.cacheKey=tp(fl),this.callHashCache.set(Ys,r),fl.length=0}return Ys[0]=null,Ys[1]=null,r.cacheKey}get isToneMappingState(){return!this.renderer.getRenderTarget()}updateBackground(e){let t=this.get(e),i=e.background;if(i){let r=e.backgroundBlurriness===0&&t.backgroundBlurriness>0||e.backgroundBlurriness>0&&t.backgroundBlurriness===0;(t.background!==i||r)&&(t.backgroundNode=this.getCacheNode("background",i,()=>{if(i.isCubeTexture===!0||i.mapping===303||i.mapping===304||i.mapping===306){if(e.backgroundBlurriness>0||i.mapping===306)return Bb(i);{let s;return s=i.isCubeTexture===!0?Yr(i):st(i),SA(s)}}else{if(i.isTexture===!0)return st(i,Kn.flipY()).setUpdateMatrix(!0);i.isColor!==!0&&re("WebGPUNodes: Unsupported background configuration.",i)}},r),t.background=i,t.backgroundBlurriness=e.backgroundBlurriness)}else t.backgroundNode&&(delete t.backgroundNode,delete t.background)}getCacheNode(e,t,i,r=!1){let s=this.cacheLib[e]||(this.cacheLib[e]=new WeakMap),n=s.get(t);return(n===void 0||r)&&(n=i(),s.set(t,n)),n}updateFog(e){let t=this.get(e),i=e.fog;i?t.fog!==i&&(t.fogNode=this.getCacheNode("fog",i,()=>{if(i.isFogExp2)return Qb(qt("color","color",i).setGroup(we),GN(qt("density","float",i).setGroup(we)));if(i.isFog)return Qb(qt("color","color",i).setGroup(we),zN(qt("near","float",i).setGroup(we),qt("far","float",i).setGroup(we)));re("Renderer: Unsupported fog configuration.",i)}),t.fog=i):(delete t.fogNode,delete t.fog)}updateEnvironment(e){let t=this.get(e),i=e.environment;i?t.environment!==i&&(t.environmentNode=this.getCacheNode("environment",i,()=>{if(i.isCubeTexture===!0)return Yr(i);if(i.isTexture===!0)return st(i);re("Nodes: Unsupported environment configuration.",i)}),t.environment=i):t.environmentNode&&(delete t.environmentNode,delete t.environment)}getNodeFrame(e=this.renderer,t=null,i=null,r=null,s=null){let n=this.nodeFrame;return n.renderer=e,n.scene=t,n.object=i,n.camera=r,n.material=s,n}getNodeFrameForRender(e){return this.getNodeFrame(e.renderer,e.scene,e.object,e.camera,e.material)}getOutputCacheKey(){let e=this.renderer;return e.toneMapping+","+e.currentColorSpace+","+e.xr.isPresenting}hasOutputChange(e){return RL.get(e)!==this.getOutputCacheKey()}getOutputNode(e){let t=this.renderer,i=this.getOutputCacheKey(),r=e.isArrayTexture?st(e,Kn).depth(Ka("gl_ViewID_OVR")).renderOutput(t.toneMapping,t.currentColorSpace):st(e,Kn).renderOutput(t.toneMapping,t.currentColorSpace);return RL.set(e,i),r}updateBefore(e){let t=e.getNodeBuilderState();for(let i of t.updateBeforeNodes)this.getNodeFrameForRender(e).updateBeforeNode(i)}updateAfter(e){let t=e.getNodeBuilderState();for(let i of t.updateAfterNodes)this.getNodeFrameForRender(e).updateAfterNode(i)}updateForCompute(e){let t=this.getNodeFrame(),i=this.getForCompute(e);for(let r of i.updateNodes)t.updateNode(r)}updateForRender(e){let t=this.getNodeFrameForRender(e),i=e.getNodeBuilderState();for(let r of i.updateNodes)t.updateNode(r)}needsRefresh(e){let t=this.getNodeFrameForRender(e);return e.getMonitor().needsRefresh(e,t)}dispose(){super.dispose(),this.nodeFrame=new ML,this.nodeBuilderCache=new Map,this.cacheLib={}}},__=new $o,EL=class cO{constructor(t=null){this.version=0,this.clipIntersection=null,this.cacheKey="",this.shadowPass=!1,this.viewNormalMatrix=new Os,this.clippingGroupContexts=new WeakMap,this.intersectionPlanes=[],this.unionPlanes=[],this.parentVersion=null,t!==null&&(this.viewNormalMatrix=t.viewNormalMatrix,this.clippingGroupContexts=t.clippingGroupContexts,this.shadowPass=t.shadowPass,this.viewMatrix=t.viewMatrix)}projectPlanes(t,i,r){let s=t.length;for(let n=0;n<s;n++){__.copy(t[n]).applyMatrix4(this.viewMatrix,this.viewNormalMatrix);
33let a=i[r+n],o=__.normal;a.x=-o.x,a.y=-o.y,a.z=-o.z,a.w=__.constant}}updateGlobal(t,i){this.shadowPass=t.overrideMaterial!==null&&t.overrideMaterial.isShadowPassMaterial,this.viewMatrix=i.matrixWorldInverse,this.viewNormalMatrix.getNormalMatrix(this.viewMatrix)}update(t,i){let r=!1;t.version!==this.parentVersion&&(this.intersectionPlanes=Array.from(t.intersectionPlanes),this.unionPlanes=Array.from(t.unionPlanes),this.parentVersion=t.version),this.clipIntersection!==i.clipIntersection&&(this.clipIntersection=i.clipIntersection,this.clipIntersection?this.unionPlanes.length=t.unionPlanes.length:this.intersectionPlanes.length=t.intersectionPlanes.length);let s=i.clippingPlanes,n=s.length,a,o;if(this.clipIntersection?(a=this.intersectionPlanes,o=t.intersectionPlanes.length):(a=this.unionPlanes,o=t.unionPlanes.length),a.length!==o+n){a.length=o+n;for(let l=0;l<n;l++)a[o+l]=new yt;r=!0}this.projectPlanes(s,a,o),r&&(this.version++,this.cacheKey=`${this.intersectionPlanes.length}:${this.unionPlanes.length}`)}getGroupContext(t){if(this.shadowPass&&!t.clipShadows)return this;let i=this.clippingGroupContexts.get(t);return i===void 0&&(i=new cO(this),this.clippingGroupContexts.set(t,i)),i.update(this,t),i}get unionClippingCount(){return this.unionPlanes.length}},D$=class{constructor(e,t){this.bundleGroup=e,this.camera=t}},Rd=[],O$=class{constructor(){this.bundles=new dl}get(e,t){let i=this.bundles;Rd[0]=e,Rd[1]=t;let r=i.get(Rd);return r===void 0&&(r=new D$(e,t),i.set(Rd,r)),Rd[0]=null,Rd[1]=null,r}dispose(){this.bundles=new dl}},AL=class{constructor(){this.lightNodes=new WeakMap,this.materialNodes=new Map,this.toneMappingNodes=new Map}fromMaterial(e){if(e.isNodeMaterial)return e;let t=null,i=this.getMaterialNodeClass(e.type);if(i!==null){t=new i;for(let r in e)t[r]=e[r]}return t}addToneMapping(e,t){this.addType(e,t,this.toneMappingNodes)}getToneMappingFunction(e){return this.toneMappingNodes.get(e)||null}getMaterialNodeClass(e){return this.materialNodes.get(e)||null}addMaterial(e,t){this.addType(e,t,this.materialNodes)}getLightNodeClass(e){return this.lightNodes.get(e)||null}addLight(e,t){this.addClass(e,t,this.lightNodes)}addType(e,t,i){if(i.has(t)){de(`Redefinition of node ${t}`);return}if(typeof e!="function")throw Error(`Node class ${e.name} is not a class.`);if(typeof t=="function"||typeof t=="object")throw Error(`Base class ${t} is not a class.`);i.set(t,e)}addClass(e,t,i){if(i.has(t)){de(`Redefinition of node ${t.name}`);return}if(typeof e!="function")throw Error(`Node class ${e.name} is not a class.`);if(typeof t!="function")throw Error(`Base class ${t.name} is not a class.`);i.set(t,e)}},B$=new a_,NL=new WeakMap,U$=class{createNode(e=[]){return new a_().setLights(e)}getNode(e){if(e.isQuadMesh)return B$;let t=NL.get(e);return t===void 0&&(t=this.createNode(),NL.set(e,t)),t}},Ip=class extends zr{constructor(e=1,t=1,i={}){super(e,t,i),this.isXRRenderTarget=!0,this._hasExternalTextures=!1,this._autoAllocateDepthBuffer=!0,this._isOpaqueFramebuffer=!1}copy(e){return super.copy(e),this._hasExternalTextures=e._hasExternalTextures,this._autoAllocateDepthBuffer=e._autoAllocateDepthBuffer,this._isOpaqueFramebuffer=e._isOpaqueFramebuffer,this}},LL=new F,PL=new F,kL=new WeakMap,V$=class extends Ds{constructor(e,t=!1){super(),this.enabled=!1,this.isPresenting=!1,this.cameraAutoUpdate=!0,this._renderer=e,this._cameraL=new os,this._cameraL.viewport=new yt,this._cameraR=new os,this._cameraR.viewport=new yt,this._cameras=[this._cameraL,this._cameraR],this._cameraXR=new wU,this._currentDepthNear=null,this._currentDepthFar=null,this._controllers=[],this._controllerInputSources=[],this._xrRenderTarget=null,this._layers=[],this._sessionUsesLayers=!1,this._supportsGlBinding=typeof XRWebGLBinding<"u",this._createXRLayer=H$.bind(this),this._gl=null,this._currentAnimationContext=null,this._currentAnimationLoop=null,this._currentPixelRatio=null,this._currentSize=new ge,this._onSessionEvent=j$.bind(this),this._onSessionEnd=$$.bind(this),this._onInputSourcesChange=W$.bind(this),this._onAnimationFrame=q$.bind(this),this._referenceSpace=null,this._referenceSpaceType="local-floor",this._customReferenceSpace=null,this._framebufferScaleFactor=1,this._foveation=1,this._session=null,this._glBaseLayer=null,this._glBinding=null,this._glProjLayer=null,this._xrFrame=null,this._supportsLayers=this._supportsGlBinding&&"createProjectionLayer"in XRWebGLBinding.prototype,this._useMultiviewIfPossible=t,this._useMultiview=!1}getController(e){return this._getController(e).getTargetRaySpace()}getControllerGrip(e){return this._getController(e).getGripSpace()}getHand(e){return this._getController(e).getHandSpace()}getFoveation(){if(!(this._glProjLayer===null&&this._glBaseLayer===null))return this._foveation}setFoveation(e){this._foveation=e,this._glProjLayer!==null&&(this._glProjLayer.fixedFoveation=e),this._glBaseLayer!==null&&this._glBaseLayer.fixedFoveation!==void 0&&(this._glBaseLayer.fixedFoveation=e)}getFramebufferScaleFactor(){return this._framebufferScaleFactor}setFramebufferScaleFactor(e){this._framebufferScaleFactor=e,this.isPresenting===!0&&de("XRManager: Cannot change framebuffer scale while presenting.")}getReferenceSpaceType(){return this._referenceSpaceType}setReferenceSpaceType(e){this._referenceSpaceType=e,this.isPresenting===!0&&de("XRManager: Cannot change reference space type while presenting.")}getReferenceSpace(){return this._customReferenceSpace||this._referenceSpace}setReferenceSpace(e){this._customReferenceSpace=e}getCamera(){return this._cameraXR}getEnvironmentBlendMode(){if(this._session!==null)return this._session.environmentBlendMode}getBinding(){return this._glBinding===null&&this._supportsGlBinding&&(this._glBinding=new XRWebGLBinding(this._session,this._gl)),this._glBinding}getFrame(){return this._xrFrame}useMultiview(){return this._useMultiview}createQuadLayer(e,t,i,r,s,n,a,o={}){let l=new Un(e,t),h=new Ip(s,n,{format:Br,type:hr,depthTexture:new Us(s,n,o.stencil?hh:ur,void 0,void 0,void 0,void 0,void 0,void 0,o.stencil?uh:Da),stencilBuffer:o.stencil,resolveDepthBuffer:!1,resolveStencilBuffer:!1});h._autoAllocateDepthBuffer=!0;let u=new ji({color:16777215,side:0});u.map=h.texture,u.map.offset.y=1,u.map.repeat.y=-1;let d=new xt(l,u);d.position.copy(i),d.quaternion.copy(r);let c={type:"quad",width:e,height:t,translation:i,quaternion:r,pixelwidth:s,pixelheight:n,plane:d,material:u,rendercall:a,renderTarget:h};if(this._layers.push(c),this._session!==null){c.plane.material=new ji({color:16777215,side:0}),c.plane.material.blending=5,c.plane.material.blendEquation=100,c.plane.material.blendSrc=200,c.plane.material.blendDst=200,c.xrlayer=this._createXRLayer(c);let p=this._session.renderState.layers;p.unshift(c.xrlayer),this._session.updateRenderState({layers:p})}else h.isXRRenderTarget=!1;return d}createCylinderLayer(e,t,i,r,s,n,a,o,l={}){let h=new p4(e,e,e*t/i,64,64,!0,Math.PI-t/2,t),u=new Ip(n,a,{format:Br,type:hr,depthTexture:new Us(n,a,l.stencil?hh:ur,void 0,void 0,void 0,void 0,void 0,void 0,l.stencil?uh:Da),stencilBuffer:l.stencil,resolveDepthBuffer:!1,resolveStencilBuffer:!1});u._autoAllocateDepthBuffer=!0;let d=new ji({color:16777215,side:1});d.map=u.texture,d.map.offset.y=1,d.map.repeat.y=-1;let c=new xt(h,d);c.position.copy(r),c.quaternion.copy(s);
33let p={type:"cylinder",radius:e,centralAngle:t,aspectratio:i,translation:r,quaternion:s,pixelwidth:n,pixelheight:a,plane:c,material:d,rendercall:o,renderTarget:u};if(this._layers.push(p),this._session!==null){p.plane.material=new ji({color:16777215,side:1}),p.plane.material.blending=5,p.plane.material.blendEquation=100,p.plane.material.blendSrc=200,p.plane.material.blendDst=200,p.xrlayer=this._createXRLayer(p);let m=this._session.renderState.layers;m.unshift(p.xrlayer),this._session.updateRenderState({layers:m})}else u.isXRRenderTarget=!1;return c}renderLayers(){let e=new F,t=new Bo,i=this._renderer,r=this.isPresenting;this.isPresenting=!1;let s=new ge;i.getSize(s);let n=i.getRenderTarget();for(let a of this._layers){a.renderTarget.isXRRenderTarget=this._session!==null,a.renderTarget._hasExternalTextures=a.renderTarget.isXRRenderTarget;let o=i.contextNode,l;if(a.renderTarget.isXRRenderTarget&&this._sessionUsesLayers){a.xrlayer.transform=new XRRigidTransform(a.plane.getWorldPosition(e),a.plane.getWorldQuaternion(t));let h=this._glBinding.getSubImage(a.xrlayer,this._xrFrame);i.backend.setXRRenderTargetTextures(a.renderTarget,h.colorTexture,void 0),i._setXRLayerSize(a.renderTarget.width,a.renderTarget.height),l=kL.get(o),l===void 0&&(l=o.context({getOutput:u=>Lf(u,i.toneMapping,i.outputColorSpace)}),kL.set(o,l))}else l=o;i.contextNode=l,i.setRenderTarget(a.renderTarget),a.rendercall(),i.contextNode=o}i.setRenderTarget(n),i._setXRLayerSize(s.x,s.y),this.isPresenting=r}getSession(){return this._session}async setSession(e){let t=this._renderer,i=t.backend;this._gl=t.getContext();let r=this._gl,s=r.getContextAttributes();if(this._session=e,e!==null){if(i.isWebGPUBackend===!0)throw Error('THREE.XRManager: XR is currently not supported with a WebGPU backend. Use WebGL by passing "{ forceWebGL: true }" to the constructor of the renderer.');if(e.addEventListener("select",this._onSessionEvent),e.addEventListener("selectstart",this._onSessionEvent),e.addEventListener("selectend",this._onSessionEvent),e.addEventListener("squeeze",this._onSessionEvent),e.addEventListener("squeezestart",this._onSessionEvent),e.addEventListener("squeezeend",this._onSessionEvent),e.addEventListener("end",this._onSessionEnd),e.addEventListener("inputsourceschange",this._onInputSourcesChange),await i.makeXRCompatible(),this._currentPixelRatio=t.getPixelRatio(),t.getSize(this._currentSize),this._currentAnimationContext=t._animation.getContext(),this._currentAnimationLoop=t._animation.getAnimationLoop(),t._animation.stop(),this._supportsLayers===!0){let n=null,a=null,o=null;t.depth&&(o=t.stencil?r.DEPTH24_STENCIL8:r.DEPTH_COMPONENT24,n=t.stencil?uh:Da,a=t.stencil?hh:ur);let l={colorFormat:r.RGBA8,depthFormat:o,scaleFactor:this._framebufferScaleFactor,clearOnAccess:!1};this._useMultiviewIfPossible&&t.hasFeature("OVR_multiview2")&&(l.textureType="texture-array",this._useMultiview=!0),this._glBinding=this.getBinding();let h=this._glBinding.createProjectionLayer(l),u=[h];this._glProjLayer=h,t.setPixelRatio(1),t._setXRLayerSize(h.textureWidth,h.textureHeight);let d=this._useMultiview?2:1,c=new Us(h.textureWidth,h.textureHeight,a,void 0,void 0,void 0,void 0,void 0,void 0,n,d);if(this._xrRenderTarget=new Ip(h.textureWidth,h.textureHeight,{format:Br,type:hr,colorSpace:t.outputColorSpace,depthTexture:c,stencilBuffer:t.stencil,samples:s.antialias?4:0,resolveDepthBuffer:h.ignoreDepthValues===!1,resolveStencilBuffer:h.ignoreDepthValues===!1,depth:this._useMultiview?2:1,multiview:this._useMultiview}),this._xrRenderTarget._hasExternalTextures=!0,this._xrRenderTarget.depth=this._useMultiview?2:1,this._sessionUsesLayers=e.enabledFeatures.includes("layers"),this._referenceSpace=await e.requestReferenceSpace(this.getReferenceSpaceType()),this._sessionUsesLayers)for(let p of this._layers)p.plane.material=new ji({color:16777215,side:+(p.type==="cylinder")}),p.plane.material.blending=5,p.plane.material.blendEquation=100,p.plane.material.blendSrc=200,p.plane.material.blendDst=200,p.xrlayer=this._createXRLayer(p),u.unshift(p.xrlayer);e.updateRenderState({layers:u})}else{let n={antialias:t.currentSamples>0,alpha:!0,depth:t.depth,stencil:t.stencil,framebufferScaleFactor:this.getFramebufferScaleFactor()},a=new XRWebGLLayer(e,r,n);this._glBaseLayer=a,e.updateRenderState({baseLayer:a}),t.setPixelRatio(1),t._setXRLayerSize(a.framebufferWidth,a.framebufferHeight),this._xrRenderTarget=new Ip(a.framebufferWidth,a.framebufferHeight,{format:Br,type:hr,colorSpace:t.outputColorSpace,stencilBuffer:t.stencil,resolveDepthBuffer:a.ignoreDepthValues===!1,resolveStencilBuffer:a.ignoreDepthValues===!1}),this._xrRenderTarget._isOpaqueFramebuffer=!0,this._referenceSpace=await e.requestReferenceSpace(this.getReferenceSpaceType())}this.setFoveation(this.getFoveation()),t._animation.setAnimationLoop(this._onAnimationFrame),t._animation.setContext(e),t._animation.start(),this.isPresenting=!0,this.dispatchEvent({type:"sessionstart"})}}updateCamera(e){let t=this._session;if(t===null)return;let i=e.near,r=e.far,s=this._cameraXR,n=this._cameraL,a=this._cameraR;s.near=a.near=n.near=i,s.far=a.far=n.far=r,s.isMultiViewCamera=this._useMultiview,(this._currentDepthNear!==s.near||this._currentDepthFar!==s.far)&&(t.updateRenderState({depthNear:s.near,depthFar:s.far}),this._currentDepthNear=s.near,this._currentDepthFar=s.far),s.layers.mask=e.layers.mask|6,n.layers.mask=s.layers.mask&-5,a.layers.mask=s.layers.mask&-3;let o=e.parent,l=s.cameras;IL(s,o);for(let h=0;h<l.length;h++)IL(l[h],o);l.length===2?z$(s,n,a):s.projectionMatrix.copy(n.projectionMatrix),G$(e,s,o)}_getController(e){let t=this._controllers[e];return t===void 0&&(t=new KB,this._controllers[e]=t),t}};function z$(e,t,i){LL.setFromMatrixPosition(t.matrixWorld),PL.setFromMatrixPosition(i.matrixWorld);let r=LL.distanceTo(PL),s=t.projectionMatrix.elements,n=i.projectionMatrix.elements,a=s[14]/(s[10]-1),o=s[14]/(s[10]+1),l=(s[9]+1)/s[5],h=(s[9]-1)/s[5],u=(s[8]-1)/s[0],d=(n[8]+1)/n[0],c=a*u,p=a*d,m=r/(-u+d),g=m*-u;if(t.matrixWorld.decompose(e.position,e.quaternion,e.scale),e.translateX(g),e.translateZ(m),e.matrixWorld.compose(e.position,e.quaternion,e.scale),e.matrixWorldInverse.copy(e.matrixWorld).invert(),s[10]===-1)e.projectionMatrix.copy(t.projectionMatrix),e.projectionMatrixInverse.copy(t.projectionMatrixInverse);else{let f=a+m,y=o+m,x=c-g,b=p+(r-g),_=l*o/y*f,T=h*o/y*f;e.projectionMatrix.makePerspective(x,b,_,T,f,y),e.projectionMatrixInverse.copy(e.projectionMatrix).invert()}}function IL(e,t){t===null?e.matrixWorld.copy(e.matrix):e.matrixWorld.multiplyMatrices(t.matrixWorld,e.matrix),e.matrixWorldInverse.copy(e.matrixWorld).invert()}function G$(e,t,i){i===null?e.matrix.copy(t.matrixWorld):(e.matrix.copy(i.matrixWorld),e.matrix.invert(),e.matrix.multiply(t.matrixWorld)),e.matrix.decompose(e.position,e.quaternion,e.scale),e.updateMatrixWorld(!0),e.projectionMatrix.copy(t.projectionMatrix),e.projectionMatrixInverse.copy(t.projectionMatrixInverse),e.isPerspectiveCamera&&(e.fov=Iu*2*Math.atan(1/e.projectionMatrix.elements[5]),e.zoom=1)}function j$(e){let t=this._controllerInputSources.indexOf(e.inputSource);if(t===-1)return;let i=this._controllers[t];if(i!==void 0){let r=this.getReferenceSpace();i.update(e.inputSource,e.frame,r),i.dispatchEvent({type:e.type,data:e.inputSource})}}function $$(){let e=this._session,t=this._renderer;e.removeEventListener("select",this._onSessionEvent),e.removeEventListener("selectstart",this._onSessionEvent),e.removeEventListener("selectend",this._onSessionEvent),e.removeEventListener("squeeze",this._onSessionEvent),e.removeEventListener("squeezestart",this._onSessionEvent),e.removeEventListener("squeezeend",this._onSessionEvent),e.removeEventListener("end",this._onSessionEnd),e.removeEventListener("inputsourceschange",this._onInputSourcesChange);for(let i=0;i<this._controllers.length;i++){let r=this._controllerInputSources[i];r!==null&&(this._controllerInputSources[i]=null,this._controllers[i].disconnect(r))}if(this._currentDepthNear=null,this._currentDepthFar=null,t._resetXRState(),this._session=null,this._xrRenderTarget=null,this._glBinding=null,this._glBaseLayer=null,this._glProjLayer=null,this._sessionUsesLayers===!0)for(let i of this._layers)i.renderTarget=new Ip(i.pixelwidth,i.pixelheight,{format:Br,type:hr,depthTexture:new Us(i.pixelwidth,i.pixelheight,i.stencilBuffer?hh:ur,void 0,void 0,void 0,void 0,void 0,void 0,i.stencilBuffer?uh:Da),stencilBuffer:i.stencilBuffer,resolveDepthBuffer:!1,resolveStencilBuffer:!1}),i.renderTarget.isXRRenderTarget=!1,i.plane.material=i.material,i.material.map=i.renderTarget.texture,i.material.map.offset.y=1,i.material.map.repeat.y=-1,delete i.xrlayer;this.isPresenting=!1,this._useMultiview=!1,t._animation.stop(),t._animation.setAnimationLoop(this._currentAnimationLoop),t._animation.setContext(this._currentAnimationContext),t._animation.start(),t.setPixelRatio(this._currentPixelRatio),t.setSize(this._currentSize.width,this._currentSize.height,!1),this.dispatchEvent({type:"sessionend"})}function W$(e){let t=this._controllers,i=this._controllerInputSources;for(let r=0;r<e.removed.length;r++){let s=e.removed[r],n=i.indexOf(s);n>=0&&(i[n]=null,t[n].disconnect(s))}for(let r=0;r<e.added.length;r++){let s=e.added[r],n=i.indexOf(s);if(n===-1){for(let o=0;o<t.length;o++)if(o>=i.length){i.push(s),n=o;break}else if(i[o]===null){i[o]=s,n=o;break}if(n===-1)break}let a=t[n];a&&a.connect(s)}}function H$(e){return e.type==="quad"?this._glBinding.createQuadLayer({transform:new XRRigidTransform(e.translation,e.quaternion),width:e.width/2,height:e.height/2,space
33:this._referenceSpace,viewPixelWidth:e.pixelwidth,viewPixelHeight:e.pixelheight,clearOnAccess:!1}):this._glBinding.createCylinderLayer({transform:new XRRigidTransform(e.translation,e.quaternion),radius:e.radius,centralAngle:e.centralAngle,aspectRatio:e.aspectRatio,space:this._referenceSpace,viewPixelWidth:e.pixelwidth,viewPixelHeight:e.pixelheight,clearOnAccess:!1})}function q$(e,t){if(t===void 0)return;let i=this._cameraXR,r=this._renderer,s=r.backend,n=this._glBaseLayer,a=this.getReferenceSpace(),o=t.getViewerPose(a);if(this._xrFrame=t,o!==null){let l=o.views;this._glBaseLayer!==null&&s.setXRTarget(n.framebuffer);let h=!1;l.length!==i.cameras.length&&(i.cameras.length=0,h=!0);for(let u=0;u<l.length;u++){let d=l[u],c;if(this._supportsLayers===!0){let m=this._glBinding.getViewSubImage(this._glProjLayer,d);c=m.viewport,u===0&&s.setXRRenderTargetTextures(this._xrRenderTarget,m.colorTexture,this._glProjLayer.ignoreDepthValues&&!this._useMultiview?void 0:m.depthStencilTexture)}else c=n.getViewport(d);let p=this._cameras[u];p===void 0&&(p=new os,p.layers.enable(u),p.viewport=new yt,this._cameras[u]=p),p.matrix.fromArray(d.transform.matrix),p.matrix.decompose(p.position,p.quaternion,p.scale),p.projectionMatrix.fromArray(d.projectionMatrix),p.projectionMatrixInverse.copy(p.projectionMatrix).invert(),p.viewport.set(c.x,c.y,c.width,c.height),u===0&&(i.matrix.copy(p.matrix),i.matrix.decompose(i.position,i.quaternion,i.scale)),h===!0&&i.cameras.push(p)}r.setOutputRenderTarget(this._xrRenderTarget)}for(let l=0;l<this._controllers.length;l++){let h=this._controllerInputSources[l],u=this._controllers[l];h!==null&&u!==void 0&&u.update(h,t,a)}this._currentAnimationLoop&&this._currentAnimationLoop(e,t),t.detectedPlanes&&this.dispatchEvent({type:"planesdetected",data:t}),this._xrFrame=null}var FL=class extends Ds{constructor(e){super(),this.domElement=e,this._pixelRatio=1,this._width=this.domElement.width,this._height=this.domElement.height,this._viewport=new yt(0,0,this._width,this._height),this._scissor=new yt(0,0,this._width,this._height),this._scissorTest=!1,this.colorTexture=new Cx,this.depthTexture=new Us}getPixelRatio(){return this._pixelRatio}getDrawingBufferSize(e){return e.set(this._width*this._pixelRatio,this._height*this._pixelRatio).floor()}getSize(e){return e.set(this._width,this._height)}setPixelRatio(e=1){this._pixelRatio!==e&&(this._pixelRatio=e,this.setSize(this._width,this._height,!1))}setDrawingBufferSize(e,t,i){this.xr&&this.xr.isPresenting||(this._width=e,this._height=t,this._pixelRatio=i,this.domElement.width=Math.floor(e*i),this.domElement.height=Math.floor(t*i),this.setViewport(0,0,e,t),this._dispatchResize())}setSize(e,t,i=!0){this.xr&&this.xr.isPresenting||(this._width=e,this._height=t,this.domElement.width=Math.floor(e*this._pixelRatio),this.domElement.height=Math.floor(t*this._pixelRatio),i===!0&&(this.domElement.style.width=e+"px",this.domElement.style.height=t+"px"),this.setViewport(0,0,e,t),this._dispatchResize())}getScissor(e){let t=this._scissor;return e.x=t.x,e.y=t.y,e.width=t.width,e.height=t.height,e}setScissor(e,t,i,r){let s=this._scissor;e.isVector4?s.copy(e):s.set(e,t,i,r)}getScissorTest(){return this._scissorTest}setScissorTest(e){this._scissorTest=e}getViewport(e){return e.copy(this._viewport)}setViewport(e,t,i,r,s=0,n=1){let a=this._viewport;e.isVector4?a.copy(e):a.set(e,t,i,r),a.minDepth=s,a.maxDepth=n}_dispatchResize(){this.dispatchEvent({type:"resize"})}dispose(){this.dispatchEvent({type:"dispose"})}},DL=new Oc,Ed=new ge,T_=new yt,w_=new Mx,S_=new l4,E0=new $e,ro=new yt,X$={0:1,1:0,2:2},Y$=class{constructor(e,t={}){this.isRenderer=!0;let{logarithmicDepthBuffer:i=!1,reversedDepthBuffer:r=!1,alpha:s=!0,depth:n=!0,stencil:a=!1,antialias:o=!1,samples:l=0,getFallback:h=null,outputBufferType:u=as,multiview:d=!1}=t;this.backend=e,this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.alpha=s,this.logarithmicDepthBuffer=i,this.reversedDepthBuffer=r,this.outputColorSpace=Gi,this.toneMapping=0,this.toneMappingExposure=1,this.sortObjects=!0,this.depth=n,this.stencil=a,this.info=new U8,this.contextNode=Xa(),this.library=new AL,this.lighting=new U$,this._samples=l||o===!0?4:0,this._onCanvasTargetResize=this._onCanvasTargetResize.bind(this),this._canvasTarget=new FL(e.getDomElement()),this._canvasTarget.addEventListener("resize",this._onCanvasTargetResize),this._canvasTarget.isDefaultCanvasTarget=!0,this._inspector=new Dv,this._inspector.setRenderer(this),this._getFallback=h,this._attributes=null,this._geometries=null,this._nodes=null,this._animation=null,this._bindings=null,this._objects=null,this._pipelines=null,this._bundles=null,this._renderLists=null,this._renderContexts=null,this._textures=null,this._background=null,this._quad=new _d(new Ot),this._quad.name="Output C
33olor Transform",this._quad.material.name="outputColorTransform",this._currentRenderContext=null,this._opaqueSort=null,this._transparentSort=null,this._frameBufferTargets=new Map;let c=this.alpha===!0?0:1;this._clearColor=new zb(0,0,0,c),this._clearDepth=1,this._clearStencil=0,this._renderTarget=null,this._activeCubeFace=0,this._activeMipmapLevel=0,this._outputRenderTarget=null,this._mrt=null,this._renderObjectFunction=null,this._currentRenderObjectFunction=null,this._currentRenderBundle=null,this._handleObjectFunction=this._renderObjectDirect,this._isDeviceLost=!1,this.onDeviceLost=this._onDeviceLost,this._outputBufferType=u,this._cacheShadowNodes=new WeakMap,this._initialized=!1,this._callDepth=-1,this._initPromise=null,this._compilationPromises=null,this.transparent=!0,this.opaque=!0,this.shadowMap={enabled:!1,transmitted:!1,type:1},this.xr=new V$(this,d),this.debug={checkShaderErrors:!0,onShaderError:null,getShaderAsync:async(p,m,g)=>{await this.compileAsync(p,m);let f=this._renderLists.get(p,m),y=this._renderContexts.get(this._renderTarget,this._mrt),x=p.overrideMaterial||g.material,{fragmentShader:b,vertexShader:_}=this._objects.get(g,x,p,m,f.lightsNode,y,y.clippingContext).getNodeBuilderState();return{fragmentShader:b,vertexShader:_}}}}
33async init(){return this._initPromise===null&&(this._initPromise=new Promise(async(e,t)=>{let i=this.backend;try{await i.init(this)}catch(r){if(this._getFallback!==null)try{this.backend=i=this._getFallback(r),await i.init(this)}catch(s){t(s);return}else{t(r);return}}this._nodes=new F$(this,i),this._animation=new N8(this,this._nodes,this.info),this._attributes=new O8(i,this.info),this._background=new Xj(this,this._nodes),this._geometries=new B8(this._attributes,this.info),this._textures=new J8(this,i,this.info),this._pipelines=new j8(i,this._nodes,this.info),this._bindings=new $8(i,this._nodes,this._textures,this._attributes,this._pipelines,this.info),this._objects=new I8(this,this._nodes,this._geometries,this._pipelines,this._bindings,this.info),this._renderLists=new q8(this.lighting),this._bundles=new O$,this._renderContexts=new K8(this),this._animation.start(),this._initialized=!0,this._inspector.init(),e(this)})),this._initPromise}get domElement(){return this._canvasTarget.domElement}get coordinateSystem(){return this.backend.coordinateSystem}async compileAsync(e,t,i=null){if(this._isDeviceLost===!0)return;this._initialized===!1&&await this.init();let r=this._nodes.nodeFrame,s=r.renderId,n=this._currentRenderContext,a=this._currentRenderObjectFunction,o=this._handleObjectFunction,l=this._compilationPromises;i===null&&(i=e);let h=e.isScene===!0?e:i.isScene===!0?i:DL,u=this.needsFrameBufferTarget&&this._renderTarget===null?this._getFrameBufferTarget():this._renderTarget||this._outputRenderTarget,d=this._renderContexts.get(u,this._mrt),c=this._activeMipmapLevel,p=[];this._currentRenderContext=d,this._currentRenderObjectFunction=this.renderObject,this._handleObjectFunction=this._createObjectPipeline,this._compilationPromises=p,r.renderId++,r.update(
33),d.depth=this.depth,d.stencil=this.stencil,d.clippingContext||=new EL,d.clippingContext.updateGlobal(h,t),h.onBeforeRender(this,e,t,u);let m=this._renderLists.get(h,t);if(m.begin(),this._projectObject(e,t,0,m,d.clippingContext),i!==e&&i.traverseVisible(function(b){b.isLight&&b.layers.test(t.layers)&&m.pushLight(b)}),m.finish(),u!==null){this._textures.updateRenderTarget(u,c);let b=this._textures.get(u);d.textures=b.textures,d.depthTexture=b.depthTexture}else d.textures=null,d.depthTexture=null;i===e?this._background.update(h,m,d):this._background.update(i,m,d);let g=m.opaque,f=m.transparent,y=m.transparentDoublePass,x=m.lightsNode;this.opaque===!0&&g.length>0&&this._renderObjects(g,t,h,x),this.transparent===!0&&f.length>0&&this._renderTransparents(f,y,t,h,x),r.renderId=s,this._currentRenderContext=n,this._currentRenderObjectFunction=a,this._handleObjectFunction=o,this._compilationPromises=l;for(let b of p){let _=this._objects.get(b.object,b.material,b.scene,b.camera,b.lightsNode,b.renderContext,b.clippingContext,b.passId);_.drawRange=b.object.geometry.drawRange,_.group=b.group,this._geometries.updateForRender(_),await this._nodes.getForRenderAsync(_),this._nodes.updateBefore(_),this._nodes.updateForRender(_),this._bindings.updateForRender(_);let T=[];this._pipelines.getForRender(_,T),T.length>0&&await Promise.all(T),this._nodes.updateAfter(_),await rM()}}async renderAsync(e,t){ut('Renderer: "renderAsync()" has been deprecated. Use "render()" and "await renderer.init();" when creating the renderer.'),await this.init(),this.render(e,t)}async waitForGPU(){re("Renderer: waitForGPU() has been removed. Read https://github.com/mrdoob/three.js/issues/32012 for more information.")}set inspector(e){this._inspector!==null&&this._inspector.setRenderer(null),this._inspector=e,this._inspector.setRenderer(this)}get inspector(){return this._inspector}set highPrecision(e){let t=this.contextNode.value;e===!0?(t.modelViewMatrix=Yv,t.modelNormalViewMatrix=Kv):this.highPrecision&&(delete t.modelViewMatrix,delete t.modelNormalViewMatrix)}get highPrecision(){let e=this.contextNode.value;return e.modelViewMatrix===Yv&&e.modelNormalViewMatrix===Kv}setMRT(e){return this._mrt=e,this}getMRT(){return this._mrt}getOutputBufferType(){return this._outputBufferType}getColorBufferType(){return ut('Renderer: ".getColorBufferType()" has been renamed to ".getOutputBufferType()".'),this.getOutputBufferType()}_onDeviceLost(e){let t=`THREE.WebGPURenderer: ${e.api} Device Lost:
34
35Message: ${e.message}`;e.reason&&(t+=`
36Reason: ${e.reason}`),re(t),this._isDeviceLost=!0}_renderBundle(e,t,i){let{bundleGroup:r,camera:s,renderList:n}=e,a=this._currentRenderContext,o=this._bundles.get(r,s),l=this.backend.get(o);l.renderContexts===void 0&&(l.renderContexts=new Set);let h=r.version!==l.version,u=l.renderContexts.has(a)===!1||h;if(l.renderContexts.add(a),u){this.backend.beginBundle(a),(l.renderObjects===void 0||h)&&(l.renderObjects=[]),this._currentRenderBundle=o;let{transparentDoublePass:d,transparent:c,opaque:p}=n;this.opaque===!0&&p.length>0&&this._renderObjects(p,s,t,i),this.transparent===!0&&c.length>0&&this._renderTransparents(c,d,s,t,i),this._currentRenderBundle=null,this.backend.finishBundle(a,o),l.version=r.version}else{let{renderObjects:d}=l;for(let c=0,p=d.length;c<p;c++){let m=d[c];this._nodes.needsRefresh(m)&&(this._nodes.updateBefore(m),this._nodes.updateForRender(m),this._bindings.updateForRender(m),this._nodes.updateAfter(m))}}this.backend.addBundle(a,o)}render(e,t){if(this._initialized===!1)throw Error('Renderer: .render() called before the backend is initialized. Use "await renderer.init();" before rendering.');this._renderScene(e,t)}get initialized(){return this._initialized}_getFrameBufferTarget(){let{currentToneMapping:e,currentColorSpace:t}=this,i=e!==0,r=t!==lt.workingColorSpace;if(i===!1&&r===!1)return null;let{width:s,height:n}=this.getDrawingBufferSize(Ed),{depth:a,stencil:o}=this,l=this._outputRenderTarget||this._canvasTarget,h=this._frameBufferTargets.get(l);if(h===void 0){h=new zr(s,n,{depthBuffer:a,stencilBuffer:o,type:this._outputBufferType,format:Br,colorSpace:lt.workingColorSpace,generateMipmaps:!1,minFilter:mi,magFilter:mi,samples:this.samples}),h.isPostProcessingRenderTarget=!0;let g=()=>{l.removeEventListener("dispose",g),h.dispose(),this._frameBufferTargets.delete(l)};l.addEventListener("dispose",g),this._frameBufferTargets.set(l,h)}
36let u=this.getOutputRenderTarget();h.depthBuffer=a,h.stencilBuffer=o,u===null?h.setSize(s,n,1):h.setSize(u.width,u.height,u.depth);let d=this._outputRenderTarget?this._outputRenderTarget.viewport:l._viewport,c=this._outputRenderTarget?this._outputRenderTarget.scissor:l._scissor,p=this._outputRenderTarget?1:l._pixelRatio,m=this._outputRenderTarget?this._outputRenderTarget.scissorTest:l._scissorTest;return h.viewport.copy(d),h.scissor.copy(c),h.viewport.multiplyScalar(p),h.scissor.multiplyScalar(p),h.scissorTest=m,h.multiview=u===null?!1:u.multiview,h.resolveDepthBuffer=u===null?!0:u.resolveDepthBuffer,h._autoAllocateDepthBuffer=u===null?!1:u._autoAllocateDepthBuffer,h}_renderScene(e,t,i=!0){if(this._isDeviceLost===!0)return;let r=i?this._getFrameBufferTarget():null,s=this._nodes.nodeFrame,n=s.renderId,a=this._currentRenderContext,o=this._currentRenderObjectFunction,l=this._handleObjectFunction;this._callDepth++;let h=e.isScene===!0?e:DL,u=this._renderTarget||this._outputRenderTarget,d=this._activeCubeFace,c=this._activeMipmapLevel,p;r===null?p=u:(p=r,this.setRenderTarget(p));let m=this._renderContexts.get(p,this._mrt,this._callDepth);this._currentRenderContext=m,this._currentRenderObjectFunction=this._renderObjectFunction||this.renderObject,this._handleObjectFunction=this._renderObjectDirect,this.info.calls++,this.info.render.calls++,this.info.render.frameCalls++,s.renderId=this.info.calls,this.backend.updateTimeStampUID(m),this.inspector.beginRender(this.backend.getTimestampUID(m),e,t,p);let g=this.xr;if(g.isPresenting===!1){let U=!1;if(this.reversedDepthBuffer===!0&&t.reversedDepth!==!0){if(t._reversedDepth=!0,t.isArrayCamera)for(let z of t.cameras)z._reversedDepth=!0;U=!0}let V=this.coordinateSystem;if(t.coordinateSystem!==V){if(t.coordinateSystem=V,t.isArrayCamera)for(let z of t.cameras)z.coordinateSystem=V;U=!0}if(U===!0&&(t.updateProjectionMatrix(),t.isArrayCamera))for(let z of t.cameras)z.updateProjectionMatrix()}e.matrixWorldAutoUpdate===!0&&e.updateMatrixWorld(),t.parent===null&&t.matrixWorldAutoUpdate===!0&&t.updateMatrixWorld(),g.enabled===!0&&g.isPresenting===!0&&(g.cameraAutoUpdate===!0&&g.updateCamera(t),t=g.getCamera());let f=this._canvasTarget,y=f._viewport,x=f._scissor,b=f._pixelRatio;p!==null&&(y=p.viewport,x=p.scissor,b=1),this.getDrawingBufferSize(Ed),T_.set(0,0,Ed.width,Ed.height);let _=y.minDepth===void 0?0:y.minDepth,T=y.maxDepth===void 0?1:y.maxDepth;m.viewportValue.copy(y).multiplyScalar(b).floor(),m.viewportValue.width>>=c,m.viewportValue.height>>=c,m.viewportValue.minDepth=_,m.viewportValue.maxDepth=T,m.viewport=m.viewportValue.equals(T_)===!1,m.scissorValue.copy(x).multiplyScalar(b).floor(),m.scissor=f._scissorTest&&m.scissorValue.equals(T_)===!1,m.scissorValue.width>>=c,m.scissorValue.height>>=c,m.clippingContext||=new EL,m.clippingContext.updateGlobal(h,t),h.onBeforeRender(this,e,t,p);let w=t.isArrayCamera?S_:w_;t.isArrayCamera||(E0.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),w.setFromProjectionMatrix(E0,t.coordinateSystem,t.reversedDepth));let M=this._renderLists.get(e,t);if(M.begin(),this._projectObject(e,t,0,M,m.clippingContext),M.finish(),this.sortObjects===!0&&M.sort(this._opaqueSort,this._transparentSort),p!==null){this._textures.updateRenderTarget(p,c);let U=this._textures.get(p);m.textures=U.textures,m.depthTexture=U.depthTexture,m.width=U.width,m.height=U.height,m.renderTarget=p,m.depth=p.depthBuffer,m.stencil=p.stencilBuffer}else m.textures=null,m.depthTexture=null,m.width=Ed.width,m.height=Ed.height,m.depth=this.depth,m.stencil=this.stencil;m.width>>=c,m.height>>=c,m.activeCubeFace=d,m.activeMipmapLevel=c,m.occlusionQueryCount=M.occlusionQueryCount,m.scissorValue.max(ro.set(0,0,0,0)),m.scissorValue.x+m.scissorValue.width>m.width&&(m.scissorValue.width=Math.max(m.width-m.scissorValue.x,0)),m.scissorValue.y+m.scissorValue.height>m.height&&(m.scissorValue.height=Math.max(m.height-m.scissorValue.y,0)),this._background.update(h,M,m),m.camera=t,this.backend.beginRender(m);let{bundles:S,lightsNode:R,transparentDoublePass:I,transparent:B,opaque:O}=M;return S.length>0&&this._renderBundles(S,h,R),this.opaque===!0&&O.length>0&&this._renderObjects(O,t,h,R),this.transparent===!0&&B.length>0&&this._renderTransparents(B,I,t,h,R),this.backend.finishRender(m),s.renderId=n,this._currentRenderContext=a,this._currentRenderObjectFunction=o,this._handleObjectFunction=l,this._callDepth--,r!==null&&(this.setRenderTarget(u,d,c),this._renderOutput(p)),h.onAfterRender(this,e,t,p),this.inspector.finishRender(this.backend.getTimestampUID(m)),m}_setXRLayerSize(e,t){this._canvasTarget._width=e,this._canvasTarget._height=t,this.setViewport(0,0,e,t)}_renderOutput(e){let t=this._quad;this._nodes.hasOutputChange(e.texture)&&(t.material.fragmentNode=this._nodes.getOutputNode(e.texture),t.material.needsUpdate=!0);let i=this.autoClear,r=this.xr.enabled;this.autoClear=!1,this.xr.enabled=!1,this._renderScene(t,t.camera,!1),this.autoClear=i,this.xr.enabled=r}getMaxAnisotropy(){return this.backend.capabilities.getMaxAnisotropy()}getActiveCubeFace(){return this._activeCubeFace}getActiveMipmapLevel(){return this._activeMipmapLevel}async setAnimationLoop(e){this._initialized===!1&&await this.init(),this._animation.setAnimationLoop(e)}getAnimationLoop(){return this._animation.getAnimationLoop()}async getArrayBufferAsync(e){return await this.backend.getArrayBufferAsync(e)}getContext(){return this.backend.getContext()}getPixelRatio(){return this._canvasTarget.getPixelRatio()}getDrawingBufferSize(e){return this._canvasTarget.getDrawingBufferSize(e)}getSize(e){return this._canvasTarget.getSize(e)}setPixelRatio(e=1){this._canvasTarget.setPixelRatio(e)}setDrawingBufferSize(e,t,i){this.xr&&this.xr.isPresenting||this._canvasTarget.setDrawingBufferSize(e,t,i)}setSize(e,t,i=!0){this.xr&&this.xr.isPresenting||this._canvasTarget.setSize(e,t,i)}setOpaqueSort(e){this._opaqueSort=e}setTransparentSort(e){this._transparentSort=e}getScissor(e){return this._canvasTarget.getScissor(e)}setScissor(e,t,i,r){this._canvasTarget.setScissor(e,t,i,r)}getScissorTest(){return this._canvasTarget.getScissorTest()}setScissorTest(e){this._canvasTarget.setScissorTest(e),this.backend.setScissorTest(e)}getViewport(e){return this._canvasTarget.getViewport(e)}setViewport(e,t,i,r,s=0,n=1){this._canvasTarget.setViewport(e,t,i,r,s,n)}getClearColor(e){return e.copy(this._clearColor)}
36setClearColor(e,t=1){this._clearColor.set(e),this._clearColor.a=t}getClearAlpha(){return this._clearColor.a}setClearAlpha(e){this._clearColor.a=e}getClearDepth(){return this.reversedDepthBuffer===!0?1-this._clearDepth:this._clearDepth}setClearDepth(e){this._clearDepth=e}getClearStencil(){return this._clearStencil}setClearStencil(e){this._clearStencil=e}isOccluded(e){let t=this._currentRenderContext;return t&&this.backend.isOccluded(t,e)}clear(e=!0,t=!0,i=!0){if(this._initialized===!1)throw Error('Renderer: .clear() called before the backend is initialized. Use "await renderer.init();" before before using this method.');let r=this._renderTarget||this._getFrameBufferTarget(),s=null;if(r!==null){this._textures.updateRenderTarget(r);let n=this._textures.get(r);s=this._renderContexts.get(r),s.textures=n.textures,s.depthTexture=n.depthTexture,s.width=n.width,s.height=n.height,s.renderTarget=r,s.depth=r.depthBuffer,s.stencil=r.stencilBuffer;let a=this.backend.getClearColor();s.clearColorValue.r=a.r,s.clearColorValue.g=a.g,s.clearColorValue.b=a.b,s.clearColorValue.a=a.a,s.clearDepthValue=this.getClearDepth(),s.clearStencilValue=this.getClearStencil(),s.activeCubeFace=this.getActiveCubeFace(),s.activeMipmapLevel=this.getActiveMipmapLevel()}this.backend.clear(e,t,i,s),r!==null&&this._renderTarget===null&&this._renderOutput(r)}clearColor(){this.clear(!0,!1,!1)}clearDepth(){this.clear(!1,!0,!1)}clearStencil(){this.clear(!1,!1,!0)}async clearAsync(e=!0,t=!0,i=!0){ut('Renderer: "clearAsync()" has been deprecated. Use "clear()" and "await renderer.init();" when creating the renderer.'),await this.init(),this.clear(e,t,i)}async clearColorAsync(){ut('Renderer: "clearColorAsync()" has been deprecated. Use "clearColor()" and "await renderer.init();" when creating the renderer.'),this.clear(!0,!1,!1)}async clearDepthAsync(){ut('Renderer: "clearDepthAsync()" has been deprecated. Use "clearDepth()" and "await renderer.init();" when creating the renderer.'),this.clear(!1,!0,!1)}async clearStencilAsync(){ut('Renderer: "clearStencilAsync()" has been deprecated. Use "clearStencil()" and "await renderer.init();" when creating the renderer.'),this.clear(!1,!1,!0)}get needsFrameBufferTarget(){let e=this.currentToneMapping!==0,t=this.currentColorSpace!==lt.workingColorSpace;return e||t}get samples(){return this._samples}get currentSamples(){let e=this._samples;return this._renderTarget===null?this.needsFrameBufferTarget&&(e=0):e=this._renderTarget.samples,e}get currentToneMapping(){return this.isOutputTarget?this.toneMapping:0}get currentColorSpace(){return this.isOutputTarget?this.outputColorSpace:lt.workingColorSpace}get isOutputTarget(){return this._renderTarget===this._outputRenderTarget||this._renderTarget===null}dispose(){if(this._initialized===!0){this.info.dispose(),this.backend.dispose(),this._animation.dispose(),this._objects.dispose(),this._geometries.dispose(),this._pipelines.dispose(),this._nodes.dispose(),this._bindings.dispose(),this._renderLists.dispose(),this._renderContexts.dispose(),this._textures.dispose();for(let e of this._frameBufferTargets.keys())e.dispose();Object.values(this.backend.timestampQueryPool).forEach(e=>{e!==null&&e.dispose()})}this.setRenderTarget(null),this.setAnimationLoop(null)}setRenderTarget(e,t=0,i=0){this._renderTarget=e,this._activeCubeFace=t,this._activeMipmapLevel=i}getRenderTarget(){return this._renderTarget}setOutputRenderTarget(e){this._outputRenderTarget=e}getOutputRenderTarget(){return this._outputRenderTarget}setCanvasTarget(e){this._canvasTarget.removeEventListener("resize",this._onCanvasTargetResize),this._canvasTarget=e,this._canvasTarget.addEventListener("resize",this._onCanvasTargetResize)}getCanvasTarget(){return this._canvasTarget}_resetXRState(){this.backend.setXRTarget(null),this.setOutputRenderTarget(null),this.setRenderTarget(null);for(let e of this._frameBufferTargets.keys())e.dispose()}setRenderObjectFunction(e){this._renderObjectFunction=e}getRenderObjectFunction(){return this._renderObjectFunction}compute(e,t=null){if(this._isDeviceLost===!0)return;if(this._initialized===!1)return de("Renderer: .compute() called before the backend is initialized. Try using .computeAsync() instead."),this.computeAsync(e,t);let i=this._nodes.nodeFrame,r=i.renderId;this.info.calls++,this.info.compute.calls++,this.info.compute.frameCalls++,i.renderId=this.info.calls,this.backend.updateTimeStampUID(e),this.inspector.beginCompute(this.backend.getTimestampUID(e),e);let s=this.backend,n=this._pipelines,a=this._bindings,o=this._nodes,l=Array.isArray(e)?e:[e];if(l[0]===void 0||l[0].isComputeNode!==!0)throw Error("THREE.Renderer: .compute() expects a ComputeNode.");s.beginCompute(e);for(let h of l){if(n.has(h)===!1){let c=()=>{h.removeEventListener("dispose",c),n.delete(h),a.deleteForCompute(h),o.delete(h)};h.addEventListener("dispose",c);let p=h.onInitFunction;p!==null&&p.call(h,{renderer:this})}o.updateForCompute(h),a.updateForCompute(h);let u=a.getForCompute(h),d=n.getForCompute(h,u);s.compute(e,h,u,d,t)}s.finishCompute(e),i.renderId=r,this.inspector.finishCompute(this.backend.getTimestampUID(e))}async computeAsync(e,t=null){this._initialized===!1&&await this.init(),this.compute(e,t)}async hasFeatureAsync(e){return ut('Renderer: "hasFeatureAsync()" has been deprecated. Use "hasFeature()" and "await renderer.init();" when creating the renderer.'),await this.init(),this.hasFeature(e)}async resolveTimestampsAsync(e="render"){return this._initialized===!1&&await this.init(),this.backend.resolveTimestampsAsync(e)}hasFeature(e){if(this._initialized===!1)throw Error('Renderer: .hasFeature() called before the backend is initialized. Use "await renderer.init();" before before using this method.');return this.backend.hasFeature(e)}hasInitialized(){return this._initialized}async initTextureAsync(e){ut('Renderer: "initTextureAsync()" has been deprecated. Use "initTexture()" and "await renderer.init();" when creating the renderer.'),await this.init(),this.initTexture(e)}initTexture(e){if(this._initialized===!1)throw Error('Renderer: .initTexture() called before the backend is initialized. Use "await renderer.init();" before before using this method.');this._textures.updateTexture(e)}initRenderTarget(e){if(this._initialized===!1)throw Error('Renderer: .initRenderTarget() called before the backend is initialized. Use "await renderer.init();" before before using this method.');this._textures.updateRenderTarget(e);let t=this._textures.get(e),i=this._renderContexts.get(e);i.textures=t.textures,i.depthTexture=t.depthTexture,i.width=t.width,i.height=t.height,i.renderTarget=e,i.depth=e.depthBuffer,i.stencil=e.stencilBuffer,this.backend.initRenderTarget(i)}
36copyFramebufferToTexture(e,t=null){if(t!==null)if(t.isVector2)t=ro.set(t.x,t.y,e.image.width,e.image.height).floor();else if(t.isVector4)t=ro.copy(t).floor();else{re("Renderer.copyFramebufferToTexture: Invalid rectangle.");return}else t=ro.set(0,0,e.image.width,e.image.height);let i=this._currentRenderContext,r;i===null?(r=this._renderTarget||this._getFrameBufferTarget(),r!==null&&(this._textures.updateRenderTarget(r),i=this._textures.get(r))):r=i.renderTarget,this._textures.updateTexture(e,{renderTarget:r}),this.backend.copyFramebufferToTexture(e,i,t),this._inspector.copyFramebufferToTexture(e)}copyTextureToTexture(e,t,i=null,r=null,s=0,n=0){this._textures.updateTexture(e),this._textures.updateTexture(t),this.backend.copyTextureToTexture(e,t,i,r,s,n),this._inspector.copyTextureToTexture(e,t)}async readRenderTargetPixelsAsync(e,t,i,r,s,n=0,a=0){return this.backend.copyTextureToBuffer(e.textures[n],t,i,r,s,a)}_projectObject(e,t,i,r,s){if(e.visible===!1)return;if(e.layers.test(t.layers)){if(e.isGroup)i=e.renderOrder,e.isClippingGroup&&e.enabled&&(s=s.getGroupContext(e));else if(e.isLOD)e.autoUpdate===!0&&e.update(t);else if(e.isLight)r.pushLight(e);else if(e.isSprite){let a=t.isArrayCamera?S_:w_;if(!e.frustumCulled||a.intersectsSprite(e,t)){this.sortObjects===!0&&ro.setFromMatrixPosition(e.matrixWorld).applyMatrix4(E0);let{geometry:o,material:l}=e;l.visible&&r.push(e,o,l,i,ro.z,null,s)}}else if(e.isLineLoop)re("Renderer: Objects of type THREE.LineLoop are not supported. Please use THREE.Line or THREE.LineSegments.");else if(e.isMesh||e.isLine||e.isPoints){let a=t.isArrayCamera?S_:w_;if(!e.frustumCulled||a.intersectsObject(e,t)){let{geometry:o,material:l}=e;if(this.sortObjects===!0&&(o.boundingSphere===null&&o.computeBoundingSphere(),ro.copy(o.boundingSphere.center).applyMatrix4(e.matrixWorld).applyMatrix4(E0)),Array.isArray(l)){let h=o.groups;for(let u=0,d=h.length;u<d;u++){let c=h[u],p=l[c.materialIndex];p&&p.visible&&r.push(e,o,p,i,ro.z,c,s)}}else l.visible&&r.push(e,o,l,i,ro.z,null,s)}}}if(e.isBundleGroup===!0&&this.backend.beginBundle!==void 0){let a=r;r=this._renderLists.get(e,t),r.begin(),a.pushBundle({bundleGroup:e,camera:t,renderList:r}),r.finish()}let n=e.children;for(let a=0,o=n.length;a<o;a++)this._projectObject(n[a],t,i,r,s)}_renderBundles(e,t,i){for(let r of e)this._renderBundle(r,t,i)}_renderTransparents(e,t,i,r,s){if(t.length>0){for(let{material:n}of t)n.side=1;this._renderObjects(t,i,r,s,"backSide");for(let{material:n}of t)n.side=0;this._renderObjects(e,i,r,s);for(let{material:n}of t)n.side=2}else this._renderObjects(e,i,r,s)}_renderObjects(e,t,i,r,s=null){for(let n=0,a=e.length;n<a;n++){let{object:o,geometry:l,material:h,group:u,clippingContext:d}=e[n];this._currentRenderObjectFunction(o,i,t,l,h,u,r,d,s)}}_getShadowNodes(e){let t=e.version,i=this._cacheShadowNodes.get(e);if(i===void 0||i.version!==t){let r=e.map!==null,s=e.colorNode&&e.colorNode.isNode,n=e.castShadowNode&&e.castShadowNode.isNode,a=e.maskShadowNode&&e.maskShadowNode.isNode||e.maskNode&&e.maskNode.isNode,o=null,l=null,h=null;if(r||s||n||a){let u,d;if(n?(u=e.castShadowNode.rgb,d=e.castShadowNode.a,this.shadowMap.transmitted!==!0&&ut("Renderer: `shadowMap.transmitted` needs to be set to `true` when using `material.castShadowNode`.")):(u=L(0),d=C(1)),r&&(d=d.mul(qt("map","texture",e).a)),s&&(d=d.mul(e.colorNode.a)),l=Te(u,d),a){let c=e.maskShadowNode||e.maskNode;l=k(([p])=>(c.not().discard(),p))(l)}}e.depthNode&&e.depthNode.isNode&&(h=e.depthNode),e.castShadowPositionNode&&e.castShadowPositionNode.isNode?o=e.castShadowPositionNode:e.positionNode&&e.positionNode.isNode&&(o=e.positionNode),i={version:t,colorNode:l,depthNode:h,positionNode:o},this._cacheShadowNodes.set(e,i)}return i}renderObject(e,t,i,r,s,n,a,o=null,l=null){let h=!1,u,d,c,p;if(e.onBeforeRender(this,t,i,r,s,n),s.allowOverride===!0&&t.overrideMaterial!==null){let m=t.overrideMaterial;if(h=!0,u=m.isNodeMaterial?m.colorNode:null,d=m.isNodeMaterial?m.depthNode:null,c=m.isNodeMaterial?m.positionNode:null,p=t.overrideMaterial.side,s.positionNode&&s.positionNode.isNode&&(m.positionNode=s.positionNode),m.alphaTest=s.alphaTest,m.alphaMap=s.alphaMap,m.transparent=s.transparent||s.transmission>0||s.transmissionNode&&s.transmissionNode.isNode||s.backdropNode&&s.backdropNode.isNode,m.isShadowPassMaterial){let{c
36olorNode:g,depthNode:f,positionNode:y}=this._getShadowNodes(s);this.shadowMap.type===3?m.side=s.shadowSide===null?s.side:s.shadowSide:m.side=s.shadowSide===null?X$[s.side]:s.shadowSide,g!==null&&(m.colorNode=g),f!==null&&(m.depthNode=f),y!==null&&(m.positionNode=y)}s=m}s.transparent===!0&&s.side===2&&s.forceSinglePass===!1?(s.side=1,this._handleObjectFunction(e,s,t,i,a,n,o,"backSide"),s.side=0,this._handleObjectFunction(e,s,t,i,a,n,o,l),s.side=2):this._handleObjectFunction(e,s,t,i,a,n,o,l),h&&(t.overrideMaterial.colorNode=u,t.overrideMaterial.depthNode=d,t.overrideMaterial.positionNode=c,t.overrideMaterial.side=p),e.onAfterRender(this,t,i,r,s,n)}hasCompatibility(e){if(this._initialized===!1)throw Error('Renderer: .hasCompatibility() called before the backend is initialized. Use "await renderer.init();" before using this method.');return this.backend.hasCompatibility(e)}_renderObjectDirect(e,t,i,r,s,n,a,o){let l=this._objects.get(e,t,i,r,s,this._currentRenderContext,a,o);l.drawRange=e.geometry.drawRange,l.group=n,this._currentRenderBundle!==null&&(this.backend.get(this._currentRenderBundle).renderObjects.push(l),l.bundle=this._currentRenderBundle.bundleGroup);let h=this._nodes.needsRefresh(l);h&&(this._nodes.updateBefore(l),this._geometries.updateForRender(l),this._nodes.updateForRender(l),this._bindings.updateForRender(l)),this._pipelines.updateForRender(l),this._pipelines.isReady(l)&&(this.backend.draw(l,this.info),h&&this._nodes.updateAfter(l))}_createObjectPipeline(e,t,i,r,s,n,a,o){if(this._compilationPromises!==null){this._compilationPromises.push({object:e,material:t,scene:i,camera:r,lightsNode:s,group:n,clippingContext:a,passId:o,renderContext:this._currentRenderContext});return}let l=this._objects.get(e,t,i,r,s,this._currentRenderContext,a,o);l.drawRange=e.geometry.drawRange,l.group=n,this._nodes.updateBefore(l),this._geometries.updateForRender(l),this._nodes.updateForRender(l),this._bindings.updateForRender(l),this._pipelines.getForRender(l,this._compilationPromises),this._nodes.updateAfter(l)}_onCanvasTargetResize(){this._initialized&&this.backend.updateSize()}get compile(){return this.compileAsync}},OL=class{constructor(e=""){this.name=e,this.visibility=0}setVisibility(e){this.visibility|=e}getVisibility(){return this.visibility}clone(){return Object.assign(new this.constructor,this)}};function K$(e){return e+(pl-e%pl)%pl}var BL=class extends OL{constructor(e,t=null){super(e),this.isBuffer=!0,this.bytesPerElement=Float32Array.BYTES_PER_ELEMENT,this._buffer=t,this._updateRanges=[]}get updateRanges(){return this._updateRanges}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}get byteLength(){return K$(this._buffer.byteLength)}get buffer(){return this._buffer}update(){return!0}},UL=class extends BL{constructor(e,t=null){super(e,t),this.isUniformBuffer=!0}},Z$=0,VL=class extends UL{constructor(e,t){super("UniformBuffer_"+Z$++,e?e.value:null),this.nodeUniform=e,this.groupNode=t,this.isNodeUniformBuffer=!0}set updateRanges(e){this.nodeUniform.updateRanges=e}get updateRanges(){return this.nodeUniform.updateRanges}addUpdateRange(e,t){this.nodeUniform.addUpdateRange(e,t)}clearUpdateRanges(){this.nodeUniform.clearUpdateRanges()}get buffer(){return this.nodeUniform.value}},J$=class extends UL{constructor(e){super(e),this.isUniformsGroup=!0,this._values=null,this.uniforms=[],this._updateRangeCache=new Map}addUniformUpdateRange(e){let t=e.index;if(this._updateRangeCache.has(t)!==!0){let i=this.updateRanges,r={start:e.offset,count:e.itemSize};i.push(r),this._updateRangeCache.set(t,r)}}clearUpdateRanges(){this._updateRangeCache.clear(),super.clearUpdateRanges()}addUniform(e){return this.uniforms.push(e),this}removeUniform(e){let t=this.uniforms.indexOf(e);return t!==-1&&this.uniforms.splice(t,1),this}get values(){return this._values===null&&(this._values=Array.from(this.buffer)),this._values}get buffer(){let e=this._buffer;if(e===null){let t=this.byteLength;e=new Float32Array(new ArrayBuffer(t)),this._buffer=e}return e}get byteLength(){let e=this.bytesPerElement,t=0;for(let i=0,r=this.uniforms.length;i<r;i++){let s=this.uniforms[i],n=s.boundary,a=s.itemSize*e,o=t%pl,l=o%n,h=o+l;t+=l,h!==0&&pl-h<a&&(t+=pl-h),s.offset=t/e,s.index=i,t+=a}return Math.ceil(t/pl)*pl}update(){let e=!1;for(let t of this.uniforms)this.updateByType(t)===!0&&(e=!0);return e}updateByType(e){if(e.isNumberUniform)return this.updateNumber(e);if(e.isVector2Uniform)return this.updateVector2(e);if(e.isVector3Uniform)return this.updateVector3(e);if(e.isVector4Uniform)return this.updateVector4(e);if(e.isColorUniform)return this.updateColor(e);
36if(e.isMatrix3Uniform)return this.updateMatrix3(e);if(e.isMatrix4Uniform)return this.updateMatrix4(e);re("WebGPUUniformsGroup: Unsupported uniform type.",e)}updateNumber(e){let t=!1,i=this.values,r=e.getValue(),s=e.offset,n=e.getType();if(i[s]!==r){let a=this._getBufferForType(n);a[s]=i[s]=r,t=!0,this.addUniformUpdateRange(e)}return t}updateVector2(e){let t=!1,i=this.values,r=e.getValue(),s=e.offset,n=e.getType();if(i[s+0]!==r.x||i[s+1]!==r.y){let a=this._getBufferForType(n);a[s+0]=i[s+0]=r.x,a[s+1]=i[s+1]=r.y,t=!0,this.addUniformUpdateRange(e)}return t}updateVector3(e){let t=!1,i=this.values,r=e.getValue(),s=e.offset,n=e.getType();if(i[s+0]!==r.x||i[s+1]!==r.y||i[s+2]!==r.z){let a=this._getBufferForType(n);a[s+0]=i[s+0]=r.x,a[s+1]=i[s+1]=r.y,a[s+2]=i[s+2]=r.z,t=!0,this.addUniformUpdateRange(e)}return t}updateVector4(e){let t=!1,i=this.values,r=e.getValue(),s=e.offset,n=e.getType();if(i[s+0]!==r.x||i[s+1]!==r.y||i[s+2]!==r.z||i[s+4]!==r.w){let a=this._getBufferForType(n);a[s+0]=i[s+0]=r.x,a[s+1]=i[s+1]=r.y,a[s+2]=i[s+2]=r.z,a[s+3]=i[s+3]=r.w,t=!0,this.addUniformUpdateRange(e)}return t}updateColor(e){let t=!1,i=this.values,r=e.getValue(),s=e.offset;if(i[s+0]!==r.r||i[s+1]!==r.g||i[s+2]!==r.b){let n=this.buffer;n[s+0]=i[s+0]=r.r,n[s+1]=i[s+1]=r.g,n[s+2]=i[s+2]=r.b,t=!0,this.addUniformUpdateRange(e)}return t}updateMatrix3(e){let t=!1,i=this.values,r=e.getValue().elements,s=e.offset;if(i[s+0]!==r[0]||i[s+1]!==r[1]||i[s+2]!==r[2]||i[s+4]!==r[3]||i[s+5]!==r[4]||i[s+6]!==r[5]||i[s+8]!==r[6]||i[s+9]!==r[7]||i[s+10]!==r[8]){let n=this.buffer;n[s+0]=i[s+0]=r[0],n[s+1]=i[s+1]=r[1],n[s+2]=i[s+2]=r[2],n[s+4]=i[s+4]=r[3],n[s+5]=i[s+5]=r[4],n[s+6]=i[s+6]=r[5],n[s+8]=i[s+8]=r[6],n[s+9]=i[s+9]=r[7],n[s+10]=i[s+10]=r[8],t=!0,this.addUniformUpdateRange(e)}return t}updateMatrix4(e){let t=!1,i=this.values,r=e.getValue().elements,s=e.offset;return eW(i,r,s)===!1&&(this.buffer.set(r,s),Q$(i,r,s),t=!0,this.addUniformUpdateRange(e)),t}_getBufferForType(e){return e==="int"||e==="ivec2"||e==="ivec3"||e==="ivec4"?new Int32Array(this.buffer.buffer):e==="uint"||e==="uvec2"||e==="uvec3"||e==="uvec4"?new Uint32Array(this.buffer.buffer):this.buffer}};function Q$(e,t,i){for(let r=0,s=t.length;r<s;r++)e[i+r]=t[r]}function eW(e,t,i){for(let r=0,s=t.length;r<s;r++)if(e[i+r]!==t[r])return!1;return!0}var tW=0,zL=class extends J${constructor(e,t){super(e),this.id=tW++,this.groupNode=t,this.isNodeUniformsGroup=!0}},GL=class extends OL{constructor(e,t){super(e),this._texture=null,this._onTextureDispose=()=>{this.generation=null,this.version=-1},this.texture=t,this.version=t?t.version:-1,this.generation=null,this.samplerKey="",this.isSampler=!0}set texture(e){this._texture!==e&&(this._texture&&this._texture.removeEventListener("dispose",this._onTextureDispose),this._texture=e,this.generation=null,this.version=-1,this._texture&&this._texture.addEventListener("dispose",this._onTextureDispose))}get texture(){return this._texture}update(){let{texture:e,version:t}=this;return t===e.version?!1:(this.version=e.version,!0)}clone(){let e=super.clone();return e._texture=null,e._onTextureDispose=()=>{e.generation=null,e.version=-1},e.texture=this.texture,e}},iW=0,rW=class extends GL{constructor(e,t){super(e,t),this.id=iW++,this.store=!1,this.mipLevel=0,this.isSampledTexture=!0}},A0=class extends rW{constructor(e,t,i,r=null){super(e,t?t.value:null),this.textureNode=t,this.groupNode=i,this.access=r}update(){let{textureNode:e}=this;return this.texture===e.value?super.update():(this.texture=e.value,!0)}},jL=class extends A0{constructor(e,t,i,r=null){super(e,t,i,r),this.isSampledCubeTexture=!0}},M_=class extends A0{constructor(e,t,i,r=null){super(e,t,i,r),this.isSampledTexture3D=!0}},$L={bitcast_int_uint:new Wi("uint tsl_bitcast_int_to_uint ( int x ) { return floatBitsToUint( intBitsToFloat ( x ) ); }"),bitcast_uint_int:new Wi("uint tsl_bitcast_uint_to_int ( uint x ) { return floatBitsToInt( uintBitsToFloat ( x ) ); }")},sW={textureDimensions:"textureSize",equals:"equal",bitcast_float_int:"floatBitsToInt",bitcast_int_float:"intBitsToFloat",bitcast_uint_float:"uintBitsToFloat",bitcast_float_uint:"floatBitsToUint",bitcast_uint_int:"tsl_bitcast_uint_to_int",bitcast_int_uint:"tsl_bitcast_int_to_uint",floatpack_snorm_2x16:"packSnorm2x16",floatpack_unorm_2x16:"packUnorm2x16",floatpack_float16_2x16:"packHalf2x16",floatunpack_snorm_2x16:"unpackSnorm2x16",floatunpack_unorm_2x16:"unpackUnorm2x16",floatunpack_float16_2x16:"unpackHalf2x16"},WL={low:"lowp",medium:"mediump",high:"highp"},HL={swizzleAssign:!0,storageBuffer:!1},qL={perspective:"smooth",linear:"noperspective"},XL={centroid:"centroid"},YL=`
37precision highp float;
38precision highp int;
39precision highp sampler2D;
40precision highp sampler3D;
41precision highp samplerCube;
42precision highp sampler2DArray;
43
44precision highp usampler2D;
45precision highp usampler3D;
46precision highp usamplerCube;
47precision highp usampler2DArray;
48
49precision highp isampler2D;
50precision highp isampler3D;
51precision highp isamplerCube;
52precision highp isampler2DArray;
53
54precision highp sampler2DShadow;
55precision highp sampler2DArrayShadow;
56precision highp samplerCubeShadow;
57`,nW=class extends SL{constructor(e,t){super(e,t,new I$),this.uniformGroups={},this.transforms=[],this.extensions={},this.builtins={vertex:[],fragment:[],compute:[]}}needsToWorkingColorSpace(e){return e.isVideoTexture===!0&&e.colorSpace!==""}_include(e){let t=$L[e];return t.build(this),this.addInclude(t),t}getMethod(e){return $L[e]!==void 0&&this._include(e),sW[e]||e}getBitcastMethod(e,t){return this.getMethod(`bitcast_${t}_${e}`)}getFloatPackingMethod(e){return this.getMethod(`floatpack_${e}_2x16`)}getFloatUnpackingMethod(e){return this.getMethod(`floatunpack_${e}_2x16`)}getTernary(e,t,i){return`${e} ? ${t} : ${i}`}getOutputStructName(){return""}buildFunctionCode(e){let t=e.layout,i=this.flowShaderNode(e),r=[];
57for(let s of t.inputs)r.push(this.getType(s.type)+" "+s.name);return`${this.getType(t.type)} ${t.name}( ${r.join(", ")} ) {
58
59	${i.vars}
60
61${i.code}
62	return ${i.result};
63
64}`}setupPBO(e){let t=e.value;if(t.pbo===void 0){let i=t.array,r=t.count*t.itemSize,{itemSize:s}=t,n=t.array.constructor.name.toLowerCase().includes("int"),a=n?$1:_g;s===2?a=n?W1:Oo:s===3?a=n?sB:j1:s===4&&(a=n?H1:Br);let o={Float32Array:Pn,Uint8Array:hr,Uint16Array:ku,Uint32Array:ur,Int8Array:Nc,Int16Array:Lc,Int32Array:Do,Uint8ClampedArray:hr},l=2**Math.ceil(Math.log2(Math.sqrt(r/s))),h=Math.ceil(r/s/l);l*h*s<r&&h++;let u=l*h*s,d=new i.constructor(u);d.set(i,0),t.array=d;let c=new Tx(t.array,l,h,a,o[t.array.constructor.name]||1015);c.needsUpdate=!0,c.isPBOTexture=!0;let p=new Yn(c,null,null);p.setPrecision("high"),t.pboNode=p,t.pbo=p.value,this.getUniformFromNode(t.pboNode,"texture",this.shaderStage,this.context.nodeName)}}getPropertyName(e,t=this.shaderStage){return e.isNodeUniform&&e.node.isTextureNode!==!0&&e.node.isBufferNode!==!0?e.name:super.getPropertyName(e,t)}generatePBO(e){let{node:t,indexNode:i}=e,r=t.value;if(this.renderer.backend.has(r)){let h=this.renderer.backend.get(r);h.pbo=r.pbo}let s=this.getUniformFromNode(r.pboNode,"texture",this.shaderStage,this.context.nodeName),n=this.getPropertyName(s);this.increaseUsage(i);let a=i.build(this,"uint"),o=this.getDataFromNode(e),l=o.propertyName;if(l===void 0){let h=this.getVarFromNode(e);l=this.getPropertyName(h);let u=this.getDataFromNode(t),d=u.propertySizeName;d===void 0&&(d=l+"Size",this.getVarFromNode(t,d,"uint"),this.addLineFlowCode(`${d} = uint( textureSize( ${n}, 0 ).x )`,e),u.propertySizeName=d);let{itemSize:c}=r,p="."+_h.join("").slice(0,c),m=`ivec2(${a} % ${d}, ${a} / ${d})`,g=this.generateTextureLoad(null,n,m,"0",null,null),f="vec4";r.pbo.type===1014?f="uvec4":r.pbo.type===1013&&(f="ivec4"),this.addLineFlowCode(`${l} = ${f}(${g})${p}`,e),o.propertyName=l}return l}generateTextureLoad(e,t,i,r,s,n){r===null&&(r="0");let a;return a=s?n?`texelFetchOffset( ${t}, ivec3( ${i}, ${s} ), ${r}, ${n} )`:`texelFetch( ${t}, ivec3( ${i}, ${s} ), ${r} )`:n?`texelFetchOffset( ${t}, ${i}, ${r}, ${n} )`:`texelFetch( ${t}, ${i}, ${r} )`,e!==null&&e.isDepthTexture&&(a+=".x"),a}generateTexture(e,t,i,r,s){return r&&(i=`vec3( ${i}, ${r} )`),e.isDepthTexture?s?`textureOffset( ${t}, ${i}, ${s} ).x`:`texture( ${t}, ${i} ).x`:s?`textureOffset( ${t}, ${i}, ${s} )`:`texture( ${t}, ${i} )`}generateTextureLevel(e,t,i,r,s,n){return s&&(i=`vec3( ${i}, ${s} )`),n?`textureLodOffset( ${t}, ${i}, ${r}, ${n} )`:`textureLod( ${t}, ${i}, ${r} )`}generateTextureBias(e,t,i,r,s,n){return s&&(i=`vec3( ${i}, ${s} )`),n?`textureOffset( ${t}, ${i}, ${n}, ${r} )`:`texture( ${t}, ${i}, ${r} )`}generateTextureGrad(e,t,i,r,s,n){return s&&(i=`vec3( ${i}, ${s} )`),n?`textureGradOffset( ${t}, ${i}, ${r[0]}, ${r[1]}, ${n} )`:`textureGrad( ${t}, ${i}, ${r[0]}, ${r[1]} )`}generateTextureCompare(e,t,i,r,s,n,a=this.shaderStage){if(a==="fragment")return e.isCubeTexture?`texture( ${t}, vec4( ${i}, ${r} ) )`:s?n?`textureOffset( ${t}, vec4( ${i}, ${s}, ${r} ), ${n} )`:`texture( ${t}, vec4( ${i}, ${s}, ${r} ) )`:n?`textureOffset( ${t}, vec3( ${i}, ${r} ), ${n} )`:`texture( ${t}, vec3( ${i}, ${r} ) )`;re(`WebGPURenderer: THREE.DepthTexture.compareFunction() does not support ${a} shader.`)}getVars(e){let t=[],i=this.vars[e];if(i!==void 0)for(let r of i)t.push(`${this.getVar(r.type,r.name,r.count)};`);return t.join(`
65	`)}getUniforms(e){let t=this.uniforms[e],i=[],r={};for(let n of t){let a=null,o=!1;if(n.type==="texture"||n.type==="texture3D"){let l=n.node.value,h="";(l.isDataTexture===!0||l.isData3DTexture===!0)&&(l.type===1014?h="u":l.type===1013&&(h="i")),a=n.type==="texture3D"&&l.isArrayTexture===!1?`${h}sampler3D ${n.name};`:l.compareFunction?l.isArrayTexture===!0?`sampler2DArrayShadow ${n.name};`:`sampler2DShadow ${n.name};`:l.isArrayTexture===!0||l.isDataArrayTexture===!0||l.isCompressedArrayTexture===!0?`${h}sampler2DArray ${n.name};`:`${h}sampler2D ${n.name};`}else if(n.type==="cubeTexture")a=`samplerCube ${n.name};`;else if(n.type==="cubeDepthTexture")a=n.node.value.compareFunction?`samplerCubeShadow ${n.name};`:`samplerCube ${n.name};`;else if(n.type==="buffer"){let l=n.node,h=this.getType(l.bufferType),u=l.bufferCount,d=u>0?u:"";a=`${l.name} {
66	${h} ${n.name}[${d}];
67};
68`}else{let l=n.groupNode.name;if(r[l]===void 0){let h=this.uniformGroups[l];if(h!==void 0){let u=[];for(let d of h.uniforms){let c=d.getType(),p=this.getVectorType(c),m=d.nodeUniform.node.precision,g=`${p} ${d.name};`;m!==null&&(g=WL[m]+" "+g),u.push("	"+g)}r[l]=u}}o=!0}if(!o){let l=n.node.precision;l!==null&&(a=WL[l]+" "+a),a="uniform "+a,i.push(a)}}let s="";for(let n in r){let a=r[n];s+=this._getGLSLUniformStruct(n,a.join(`
69`))+`
70`}return s+=i.join(`
71`),s}getTypeFromAttribute(e){let t=super.getTypeFromAttribute(e);
71if(/^[iu]/.test(t)&&e.gpuType!==1013){let i=e;e.isInterleavedBufferAttribute&&(i=e.data);let r=i.array;r instanceof Uint32Array||r instanceof Int32Array||(t=t.slice(1))}return t}getAttributes(e){let t="";if(e==="vertex"||e==="compute"){let i=this.getAttributesArray(),r=0;for(let s of i)t+=`layout( location = ${r++} ) in ${s.type} ${s.name};
72`}return t}getStructMembers(e){let t=[];for(let i of e.members)t.push(`	${i.type} ${i.name};`);return t.join(`
73`)}getStructs(e){let t=[],i=this.structs[e],r=[];for(let s of i)if(s.output)for(let n of s.members)r.push(`layout( location = ${n.index} ) out ${n.type} ${n.name};`);else{let n="struct "+s.name+` {
74`;n+=this.getStructMembers(s),n+=`
75};
76`,t.push(n)}return r.length===0&&r.push("layout( location = 0 ) out vec4 fragColor;"),`
77`+r.join(`
78`)+`
79
80`+t.join(`
81`)}getVaryings(e){let t="",i=this.varyings;if(e==="vertex"||e==="compute")for(let r of i){e==="compute"&&(r.needsInterpolation=!0);let s=this.getType(r.type);if(r.needsInterpolation)if(r.interpolationType){let n=qL[r.interpolationType]||r.interpolationType,a=XL[r.interpolationSampling]||"";t+=`${n} ${a} out ${s} ${r.name};
82`}else{let n=s.includes("int")||s.includes("uv")||s.includes("iv")?"flat ":"";t+=`${n}out ${s} ${r.name};
83`}else t+=`${s} ${r.name};
84`}else if(e==="fragment"){for(let r of i)if(r.needsInterpolation){let s=this.getType(r.type);if(r.interpolationType){let n=qL[r.interpolationType]||r.interpolationType,a=XL[r.interpolationSampling]||"";t+=`${n} ${a} in ${s} ${r.name};
85`}else{let n=s.includes("int")||s.includes("uv")||s.includes("iv")?"flat ":"";t+=`${n}in ${s} ${r.name};
86`}}}for(let r of this.builtins[e])t+=`${r};
87`;return t}getVertexIndex(){return"uint( gl_VertexID )"}getInstanceIndex(){return"uint( gl_InstanceID )"}getInvocationLocalIndex(){return`uint( gl_InstanceID ) % ${this.object.workgroupSize.reduce((e,t)=>e*t,1)}u`}getSubgroupSize(){re("GLSLNodeBuilder: WebGLBackend does not support the subgroupSize node")}getInvocationSubgroupIndex(){re("GLSLNodeBuilder: WebGLBackend does not support the invocationSubgroupIndex node")}getSubgroupIndex(){re("GLSLNodeBuilder: WebGLBackend does not support the subgroupIndex node")}getDrawIndex(){return this.renderer.backend.extensions.has("WEBGL_multi_draw")?"uint( gl_DrawID )":null}getFrontFacing(){return"gl_FrontFacing"}getFragCoord(){return"gl_FragCoord.xy"}getFragDepth(){return"gl_FragDepth"}enableExtension(e,t,i=this.shaderStage){let r=this.extensions[i]||(this.extensions[i]=new Map);r.has(e)===!1&&r.set(e,{name:e,behavior:t})}getExtensions(e){let t=[];if(e==="vertex"){let r=this.renderer.backend.extensions;this.object.isBatchedMesh&&r.has("WEBGL_multi_draw")&&this.enableExtension("GL_ANGLE_multi_draw","require",e)}let i=this.extensions[e];if(i!==void 0)for(let{name:r,behavior:s}of i.values())t.push(`#extension ${r} : ${s}`);return t.join(`
88`)}getClipDistance(){return"gl_ClipDistance"}isAvailable(e){let t=HL[e];if(t===void 0){let i;switch(t=!1,e){case"float32Filterable":i="OES_texture_float_linear";break;case"clipDistance":i="WEBGL_clip_cull_distance";break}if(i!==void 0){let r=this.renderer.backend.extensions;r.has(i)&&(r.get(i),t=!0)}HL[e]=t}return t}isFlipY(){return!0}enableHardwareClipping(e){this.enableExtension("GL_ANGLE_clip_cull_distance","require"),this.builtins.vertex.push(`out float gl_ClipDistance[ ${e} ]`)}
88enableMultiview(){this.enableExtension("GL_OVR_multiview2","require","fragment"),this.enableExtension("GL_OVR_multiview2","require","vertex"),this.builtins.vertex.push("layout(num_views = 2) in")}registerTransform(e,t){this.transforms.push({varyingName:e,attributeNode:t})}getTransforms(){let e=this.transforms,t="";for(let i=0;i<e.length;i++){let r=e[i],s=this.getPropertyName(r.attributeNode);s&&(t+=`${r.varyingName} = ${s};
89	`)}return t}_getGLSLUniformStruct(e,t){return`
90layout( std140 ) uniform ${e} {
91${t}
92};`}_getGLSLVertexCode(e){return`#version 300 es
93
94${this.getSignature()}
95
96// extensions
97${e.extensions}
98
99// precision
100${YL}
101
102// uniforms
103${e.uniforms}
104
105// varyings
106${e.varyings}
107
108// attributes
109${e.attributes}
110
111// codes
112${e.codes}
113
114void main() {
115
116	// vars
117	${e.vars}
118
119	// transforms
120	${e.transforms}
121
122	// flow
123	${e.flow}
124
125	gl_PointSize = 1.0;
126
127}
128`}_getGLSLFragmentCode(e){return`#version 300 es
129
130${this.getSignature()}
131
132// extensions
133${e.extensions}
134
135// precision
136${YL}
137
138// structs
139${e.structs}
140
141// uniforms
142${e.uniforms}
143
144// varyings
145${e.varyings}
146
147// codes
148${e.codes}
149
150void main() {
151
152	// vars
153	${e.vars}
154
155	// flow
156	${e.flow}
157
158}
159`}buildCode(){let e=this.material===null?{compute:{}}:{fragment:{},vertex:{}};this.sortBindingGroups();for(let t in e){let i=`// code
160
161`;i+=this.flowCode[t];let r=this.flowNodes[t],s=r[r.length-1];for(let a of r){let o=this.getFlowData(a),l=a.name;l&&(i.length>0&&(i+=`
162`),i+=`	// flow -> ${l}
163	`),i+=`${o.code}
164	`,a===s&&t!=="compute"&&(i+=`// result
165	`,t==="vertex"?(i+="gl_Position = ",i+=`${o.result};`):t==="fragment"&&(a.outputNode.isOutputStructNode||(i+="fragColor = ",i+=`${o.result};`)))}let n=e[t];n.extensions=this.getExtensions(t),n.uniforms=this.getUniforms(t),n.attributes=this.getAttributes(t),n.varyings=this.getVaryings(t),n.vars=this.getVars(t),n.structs=this.getStructs(t),n.codes=this.getCodes(t),n.transforms=this.getTransforms(t),n.flow=i}this.material===null?this.computeShader=this._getGLSLVertexCode(e.compute):(this.vertexShader=this._getGLSLVertexCode(e.vertex),this.fragmentShader=this._getGLSLFragmentCode(e.fragment))}getUniformFromNode(e,t,i,r=null){let s=super.getUniformFromNode(e,t,i,r),n=this.getDataFromNode(e,i,this.globalCache),a=n.uniformGPU;if(a===void 0){let o=e.groupNode,l=o.name,h=this.getBindGroupArray(l,i);if(t==="texture")a=new A0(s.name,s.node,o),h.push(a);else if(t==="cubeTexture"||t==="cubeDepthTexture")a=new jL(s.name,s.node,o),h.push(a);else if(t==="texture3D")a=new M_(s.name,s.node,o),h.push(a);else if(t==="buffer"){s.name=`buffer${e.id}`;let u=this.getSharedDataFromNode(e),d=u.buffer;d===void 0&&(e.name=`NodeBuffer_${e.id}`,d=new VL(e,o),d.name=e.name,u.buffer=d),h.push(d),a=d}else{let u=this.uniformGroups[l];u===void 0?(u=new zL(l,o),this.uniformGroups[l]=u,h.push(u)):h.indexOf(u)===-1&&h.push(u),a=this.getNodeUniform(s,t);let d=a.name;u.uniforms.some(c=>c.name===d)||u.addUniform(a)}n.uniformGPU=a}return s}},KL=null,Fp=null,ZL=class{constructor(e={}){this.parameters=Object.assign({},e),this.data=new WeakMap,this.renderer=null,this.domElement=null,this.timestampQueryPool={[Ur.RENDER]:null,[Ur.COMPUTE]:null},this.trackTimestamp=e.trackTimestamp===!0}async init(e){this.renderer=e}get coordinateSystem(){}beginRender(){}finishRender(){}beginCompute(){}finishCompute(){}draw(){}compute(){}createProgram(){}destroyProgram(){}createBindings(){}updateBindings(){}updateBinding(){}createRenderPipeline(){}createComputePipeline(){}needsRenderUpdate(){}getRenderCacheKey(){}createNodeBuilder(){}updateSampler(){}createDefaultTexture(){}createTexture(){}updateTexture(){}generateMipmaps(){}destroyTexture(){}async copyTextureToBuffer(){}copyTextureToTexture(){}copyFramebufferToTexture(){}createAttribute(){}createIndexAttribute(){}createStorageAttribute(){}updateAttribute(){}destroyAttribute(){}getContext(){}updateSize(){}updateViewport(){}updateTimeStampUID(e){let t=this.get(e),i=this.renderer.info.frame,r;r=e.isComputeNode===!0?"c:"+this.renderer.info.compute.frameCalls:"r:"+this.renderer.info.render.frameCalls,t.timestampUID=r+":"+e.id+":f"+i}getTimestampUID(e){return this.get(e).timestampUID}getTimestampFrames(e){let t=this.timestampQueryPool[e];return t?t.getTimestampFrames():[]}_getQueryPool(e){let t=e.startsWith("c:")?Ur.COMPUTE:Ur.RENDER;return this.timestampQueryPool[t]}getTimestamp(e){return this._getQueryPool(e).getTimestamp(e)}hasTimestamp(e){return this._getQueryPool(e).hasTimestamp(e)}isOccluded(){}async resolveTimestampsAsync(e="render"){if(!this.trackTimestamp){ut("WebGPURenderer: Timestamp tracking is disabled.");return}let t=this.timestampQueryPool[e];if(!t)return;let i=await t.resolveQueriesAsync();return this.renderer.info[e].timestamp=i,i}async getArrayBufferAsync(){}async hasFeatureAsync(){}hasFeature(){}getDrawingBufferSize(){return KL||=new ge,this.renderer.getDrawingBufferSize(KL)}setScissorTest(){}getClearColor(){let e=this.renderer;return Fp||=new zb,e.getClearColor(Fp),Fp.getRGB(Fp),Fp}getDomElement(){let e=this.domElement;return e===null&&(e=this.parameters.canvas===void 0?bB():this.parameters.canvas,"setAttribute"in e&&e.setAttribute("data-engine",`three.js r${lh} webgpu`),this.domElement=e),e}hasCompatibility(){return!1}initRenderTarget(){}set(e,t){this.data.set(e,t)}get(e){let t=this.data.get(e);return t===void 0&&(t={},this.data.set(e,t)),t}has(e){return this.data.has(e)}delete(e){this.data.delete(e)}deleteBindGroupData(){}dispose(){}},aW=0,oW=class{constructor(e,t){this.buffers=[e.bufferGPU,t],this.type=e.type,this.bufferType=e.bufferType,this.pbo=e.pbo,this.byteLength=e.byteLength,this.bytesPerElement=e.BYTES_PER_ELEMENT,this.version=e.version,this.isInteger=e.isInteger,this.activeBufferIndex=0,this.baseId=e.id}get id(){return`${this.baseId}|${this.activeBufferIndex}`}get bufferGPU(){return this.buffers[this.activeBufferIndex]}get transformBuffer(){return this.buffers[this.activeBufferIndex^1]}switchBuffers(){this.activeBufferIndex^=1}},lW=class{constructor(e){this.backend=e}createAttribute(e,t){let i=this.backend,{gl:r}=i,s=e.array,n=e.usage||r.STATIC_DRAW,a=e.isInterleavedBufferAttribute?e.data:e,o=i.get(a),l=o.bufferGPU;l===void 0&&(l=this._createBuffer(r,t,s,n),o.bufferGPU=l,o.bufferType=t,o.version=a.version);let h;if(s instanceof Float32Array)h=r.FLOAT;else if(typeof Float16Array<"u"&&s instanceof Float16Array)h=r.HALF_FLOAT;else if(s instanceof Uint16Array)h=e.isFloat16BufferAttribute?r.HA
165LF_FLOAT:r.UNSIGNED_SHORT;else if(s instanceof Int16Array)h=r.SHORT;else if(s instanceof Uint32Array)h=r.UNSIGNED_INT;else if(s instanceof Int32Array)h=r.INT;else if(s instanceof Int8Array)h=r.BYTE;else if(s instanceof Uint8Array)h=r.UNSIGNED_BYTE;else if(s instanceof Uint8ClampedArray)h=r.UNSIGNED_BYTE;else throw Error("THREE.WebGLBackend: Unsupported buffer data format: "+s);let u={bufferGPU:l,bufferType:t,type:h,byteLength:s.byteLength,bytesPerElement:s.BYTES_PER_ELEMENT,version:e.version,pbo:e.pbo,isInteger:h===r.INT||h===r.UNSIGNED_INT||e.gpuType===1013,id:aW++};if(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute){let d=this._createBuffer(r,t,s,n);u=new oW(u,d)}i.set(e,u)}updateAttribute(e){let t=this.backend,{gl:i}=t,r=e.array,s=e.isInterleavedBufferAttribute?e.data:e,n=t.get(s),a=n.bufferType,o=e.isInterleavedBufferAttribute?e.data.updateRanges:e.updateRanges;if(i.bindBuffer(a,n.bufferGPU),o.length===0)i.bufferSubData(a,0,r);else{for(let l=0,h=o.length;l<h;l++){let u=o[l];i.bufferSubData(a,u.start*r.BYTES_PER_ELEMENT,r,u.start,u.count)}s.clearUpdateRanges()}i.bindBuffer(a,null),n.version=s.version}destroyAttribute(e){let t=this.backend,{gl:i}=t;e.isInterleavedBufferAttribute&&t.delete(e.data);let r=t.get(e);i.deleteBuffer(r.bufferGPU),t.delete(e)}async getArrayBufferAsync(e){let t=this.backend,{gl:i}=t,r=e.isInterleavedBufferAttribute?e.data:e,{bufferGPU:s}=t.get(r),n=e.array,a=n.byteLength;i.bindBuffer(i.COPY_READ_BUFFER,s);let o=i.createBuffer();i.bindBuffer(i.COPY_WRITE_BUFFER,o),i.bufferData(i.COPY_WRITE_BUFFER,a,i.STREAM_READ),i.copyBufferSubData(i.COPY_READ_BUFFER,i.COPY_WRITE_BUFFER,0,0,a),await t.utils._clientWaitAsync();let l=new e.array.constructor(n.length);return i.bindBuffer(i.COPY_WRITE_BUFFER,o),i.getBufferSubData(i.COPY_WRITE_BUFFER,0,l),i.deleteBuffer(o),i.bindBuffer(i.COPY_READ_BUFFER,null),i.bindBuffer(i.COPY_WRITE_BUFFER,null),l.buffer}_createBuffer(e,t,i,r){let s=e.createBuffer();return e.bindBuffer(t,s),e.bufferData(t,i,r),e.bindBuffer(t,null),s}},Dp,so,hW=class{constructor(e){this.backend=e,this.gl=this.backend.gl,this.enabled={},this.currentFlipSided=null,this.currentCullFace=null,this.currentProgram=null,this.currentBlendingEnabled=!1,this.currentBlending=null,this.currentBlendSrc=null,this.currentBlendDst=null,this.currentBlendSrcAlpha=null,this.currentBlendDstAlpha=null,this.currentPremultipledAlpha=null,this.currentPolygonOffsetFactor=null,this.currentPolygonOffsetUnits=null,this.currentColorMask=null,this.currentDepthReversed=!1,this.currentDepthFunc=null,this.currentDepthMask=null,this.currentStencilFunc=null,this.currentStencilRef=null,this.currentStencilFuncMask=null,this.currentStencilFail=null,this.currentStencilZFail=null,this.currentStencilZPass=null,this.currentStencilMask=null,this.currentLineWidth=null,this.currentClippingPlanes=0,this.currentVAO=null,this.currentIndex=null,this.currentBoundFramebuffers={},this.currentDrawbuffers=new WeakMap,this.maxTextures=this.gl.getParameter(this.gl.MAX_TEXTURE_IMAGE_UNITS),this.currentTextureSlot=null,this.currentBoundTextures={},this.currentBoundBufferBases={},this._init()}_init(){let e=this.gl;Dp={100:e.FUNC_ADD,101:e.FUNC_SUBTRACT,102:e.FUNC_REVERSE_SUBTRACT},so={200:e.ZERO,201:e.ONE,202:e.SRC_COLOR,204:e.SRC_ALPHA,210:e.SRC_ALPHA_SATURATE,208:e.DST_COLOR,206:e.DST_ALPHA,203:e.ONE_MINUS_SRC_COLOR,205:e.ONE_MINUS_SRC_ALPHA,209:e.ONE_MINUS_DST_COLOR,207:e.ONE_MINUS_DST_ALPHA};let t=e.getParameter(e.SCISSOR_BOX),i=e.getParameter(e.VIEWPORT);this.currentScissor=new yt().fromArray(t),this.currentViewport=new yt().fromArray(i),this._tempVec4=new yt}enable(e){let{enabled:t}=this;t[e]!==!0&&(this.gl.enable(e),t[e]=!0)}disable(e){let{enabled:t}=this;t[e]!==!1&&(this.gl.disable(e),t[e]=!1)}setFlipSided(e){if(this.currentFlipSided!==e){let{gl:t}=this;e?t.frontFace(t.CW):t.frontFace(t.CCW),this.currentFlipSided=e}}setCullFace(e){let{gl:t}=this;e===0?this.disable(t.CULL_FACE):(this.enable(t.CULL_FACE),e!==this.currentCullFace&&(e===1?t.cullFace(t.BACK):e===2?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))),this.currentCullFace=e}setLineWidth(e){let{currentLineWidth:t,gl:i}=this;e!==t&&(i.lineWidth(e),this.currentLineWidth=e)}setMRTBlending(e,t,i){let r=this.gl,s=this.backend.drawBuffersIndexedExt;if(!s){ut("WebGPURenderer: Multiple Render Targets (MRT) blending configuration is not fully supported in compatibility mode. The material blending will be used for all render targets.");return}for(let n=0;n<e.length;n++){let a=e[n],o=null;
165if(t!==null){let l=t.getBlendMode(a.name);l.blending===6?o=i:l.blending!==0&&(o=l)}else o=i;o===null?s.blendFuncSeparateiOES(n,r.ONE,r.ZERO,r.ONE,r.ZERO):this._setMRTBlendingIndex(n,o)}}_setMRTBlendingIndex(e,t){let{gl:i}=this,r=this.backend.drawBuffersIndexedExt,s=t.blending,n=t.blendSrc,a=t.blendDst,o=t.blendEquation,l=t.premultipliedAlpha;if(s===5){let h=t.blendSrcAlpha===null?n:t.blendSrcAlpha,u=t.blendDstAlpha===null?a:t.blendDstAlpha,d=t.blendEquationAlpha===null?o:t.blendEquationAlpha;r.blendEquationSeparateiOES(e,Dp[o],Dp[d]),r.blendFuncSeparateiOES(e,so[n],so[a],so[h],so[u])}else if(r.blendEquationSeparateiOES(e,i.FUNC_ADD,i.FUNC_ADD),l)switch(s){case 1:r.blendFuncSeparateiOES(e,i.ONE,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case 2:r.blendFuncSeparateiOES(e,i.ONE,i.ONE,i.ONE,i.ONE);break;case 3:r.blendFuncSeparateiOES(e,i.ZERO,i.ONE_MINUS_SRC_COLOR,i.ZERO,i.ONE);break;case 4:r.blendFuncSeparateiOES(e,i.DST_COLOR,i.ONE_MINUS_SRC_ALPHA,i.ZERO,i.ONE);break;default:r.blendFuncSeparateiOES(e,i.ONE,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break}else switch(s){case 1:r.blendFuncSeparateiOES(e,i.SRC_ALPHA,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case 2:r.blendFuncSeparateiOES(e,i.SRC_ALPHA,i.ONE,i.ONE,i.ONE);break;case 3:r.blendFuncSeparateiOES(e,i.ZERO,i.ONE_MINUS_SRC_COLOR,i.ZERO,i.ONE);break;case 4:r.blendFuncSeparateiOES(e,i.DST_COLOR,i.ONE_MINUS_SRC_ALPHA,i.ZERO,i.ONE);break;default:r.blendFuncSeparateiOES(e,i.SRC_ALPHA,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break}}setBlending(e,t,i,r,s,n,a,o){let{gl:l}=this;if(e===0){this.currentBlendingEnabled===!0&&(this.disable(l.BLEND),this.currentBlendingEnabled=!1);return}if(this.currentBlendingEnabled===!1&&(this.enable(l.BLEND),this.currentBlendingEnabled=!0),e!==5){if(e!==this.currentBlending||o!==this.currentPremultipledAlpha){if((this.currentBlendEquation!==100||this.currentBlendEquationAlpha!==100)&&(l.blendEquation(l.FUNC_ADD),this.currentBlendEquation=100,this.currentBlendEquationAlpha=100),o)switch(e){case 1:l.blendFuncSeparate(l.ONE,l.ONE_MINUS_SRC_ALPHA,l.ONE,l.ONE_MINUS_SRC_ALPHA);break;case 2:l.blendFunc(l.ONE,l.ONE);break;case 3:l.blendFuncSeparate(l.ZERO,l.ONE_MINUS_SRC_COLOR,l.ZERO,l.ONE);break;case 4:l.blendFuncSeparate(l.DST_COLOR,l.ONE_MINUS_SRC_ALPHA,l.ZERO,l.ONE);break;default:re("WebGLState: Invalid blending: ",e);break}else switch(e){case 1:l.blendFuncSeparate(l.SRC_ALPHA,l.ONE_MINUS_SRC_ALPHA,l.ONE,l.ONE_MINUS_SRC_ALPHA);break;case 2:l.blendFuncSeparate(l.SRC_ALPHA,l.ONE,l.ONE,l.ONE);break;case 3:re("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case 4:re("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:re("WebGLState: Invalid blending: ",e);break}this.currentBlendSrc=null,this.currentBlendDst=null,this.currentBlendSrcAlpha=null,this.currentBlendDstAlpha=null,this.currentBlending=e,this.currentPremultipledAlpha=o}return}s||=t,n||=i,a||=r,(t!==this.currentBlendEquation||s!==this.currentBlendEquationAlpha)&&(l.blendEquationSeparate(Dp[t],Dp[s]),this.currentBlendEquation=t,this.currentBlendEquationAlpha=s),(i!==this.currentBlendSrc||r!==this.currentBlendDst||n!==this.currentBlendSrcAlpha||a!==this.currentBlendDstAlpha)&&(l.blendFuncSeparate(so[i],so[r],so[n],so[a]),this.currentBlendSrc=i,this.currentBlendDst=r,this.currentBlendSrcAlpha=n,this.currentBlendDstAlpha=a),this.currentBlending=e,this.currentPremultipledAlpha=!1}setColorMask(e){this.currentColorMask!==e&&(this.gl.colorMask(e,e,e,e),this.currentColorMask=e)}setDepthTest(e){let{gl:t}=this;e?this.enable(t.DEPTH_TEST):this.disable(t.DEPTH_TEST)}setReversedDepth(e){if(this.currentDepthReversed!==e){let t=this.backend.extensions.get("EXT_clip_control");e?t.clipControlEXT(t.LOWER_LEFT_EXT,t.ZERO_TO_ONE_EXT):t.clipControlEXT(t.LOWER_LEFT_EXT,t.NEGATIVE_ONE_TO_ONE_EXT),this.currentDepthReversed=e}}setDepthMask(e){this.currentDepthMask!==e&&(this.gl.depthMask(e),this.currentDepthMask=e)}setDepthFunc(e){if(this.currentDepthReversed&&(e=sM[e]),this.currentDepthFunc!==e){let{gl:t}=this;switch(e){case 0:t.depthFunc(t.NEVER);break;case 1:t.depthFunc(t.ALWAYS);break;case 2:t.depthFunc(t.LESS);break;case 3:t.depthFunc(t.LEQUAL);break;case 4:t.depthFunc(t.EQUAL);break;case 5:t.depthFunc(t.GEQUAL);break;case 6:t.depthFunc(t.GREATER);break;case 7:t.depthFunc(t.NOTEQUAL);break;default:t.depthFunc(t.LEQUAL)}this.currentDepthFunc=e}}scissor(e,t,i,r){let s=this._tempVec4.set(e,t,i,r);if(this.currentScissor.equals(s)===!1){let{gl:n}=this;n.scissor(s.x,s.y,s.z,s.w),this.currentScissor.copy(s)}}viewport(e,t,i,r){let s=this._tempVec4.set(e,t,i,r);if(this.currentViewport.equals(s)===!1){let{gl:n}=this;n.viewport(s.x,s.y,s.z,s.w),this.currentViewport.copy(s)}}setScissorTest(e){let t=this.gl;e?this.enable(t.SCISSOR_TEST):this.disable(t.SCISSOR_TEST)}setStencilTest(e){let{gl:t}=this;e?this.enable(t.STENCIL_TEST):this.disable(t.STENCIL_TEST)}setStencilMask(e){this.currentStencilMask!==e&&(this.gl.stencilMask(e),this.currentStencilMask=e)}setStencilFunc(e,t,i){(this.currentStencilFunc!==e||this.currentStencilRef!==t||this.currentStencilFuncMask!==i)&&(this.gl.stencilFunc(e,t,i),this.currentStencilFunc=e,this.currentStencilRef=t,this.currentStencilFuncMask=i)}setStencilOp(e,t,i){(this.currentStencilFail!==e||this.currentStencilZFail!==t||this.currentStencilZPass!==i)&&(this.gl.stencilOp(e,t,i),this.currentStencilFail=e,this.currentStencilZFail=t,this.currentStencilZPass=i)}setMaterial(e,t,i){let{gl:r}=this;e.side===2?this.disable(r.CULL_FACE):this.enable(r.CULL_FACE);let s=e.side===1;t&&(s=!s),this.setFlipSided(s),e.blending===1&&e.transparent===!1?this.setBlending(0):this.setBlending(e.blending,e.blendEquation,e.blendSrc,e.blendDst,e.blendEquationAlpha,e.blendSrcAlpha,e.blendDstAlpha,e.premultipliedAlpha),this.setDepthFunc(e.depthFunc),this.setDepthTest(e.depthTest),this.setDepthMask(e.depthWrite),this.setColorMask(e.colorWrite);let n=e.stencilWrite;if(this.setStencilTest(n),n&&(this.setStencilMask(e.stencilWriteMask),this.setStencilFunc(e.stencilFunc,e.stencilRef,e.stencilFuncMask),this.setStencilOp(e.stencilFail,e.stencilZFail,e.stencilZPass)),this.setPolygonOffset(e.polygonOffset,e.polygonOffsetFactor,e.polygonOffsetUnits),e.alphaToCoverage===!0&&this.backend.renderer.currentSamples>0?this.enable(r.SAMPLE_ALPHA_TO_COVERAGE):this.disable(r.SAMPLE_ALPHA_TO_COVERAGE),i>0&&this.currentClippingPlanes!==i){let a=12288;for(let o=0;o<8;o++)o<i?this.enable(a+o):this.disable(a+o)}}setPolygonOffset(e,t,i){let{gl:r}=this;e?(this.enable(r.POLYGON_OFFSET_FILL),(this.currentPolygonOffsetFactor!==t||this.currentPolygonOffsetUnits!==i)&&(r.polygonOffset(t,i),this.currentPolygonOffsetFactor=t,this.currentPolygonOffsetUnits=i)):this.disable(r.POLYGON_OFFSET_FILL)}useProgram(e){return this.currentProgram===e?!1:(this.gl.useProgram(e),this.currentProgram=e,!0)}setVertexState(e,t=null){let i=this.gl;return this.currentVAO!==e||this.currentIndex!==t?(i.bindVertexArray(e),t!==null&&i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,t),this.currentVAO=e,this.currentIndex=t,!0):!1}resetVertexState(){let e=this.gl;e.bindVertexArray(null),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,null),this.currentVAO=null,this.currentIndex=null}bindFramebuffer(e,t){let{gl:i,currentBoundFramebuffers:r}=this;return r[e]===t?!1:(i.bindFramebuffer(e,t),r[e]=t,e===i.DRAW_FRAMEBUFFER&&(r[i.FRAMEBUFFER]=t),e===i.FRAMEBUFFER&&(r[i.DRAW_FRAMEBUFFER]=t),!0)}drawBuffers(e,t){let{gl:i}=this,r=[],s=!1;if(e.textures!==null){r=this.currentDrawbuffers.get(t),r===void 0&&(r=[],this.currentDrawbuffers.set(t,r));let n=e.textures;if(r.length!==n.length||r[0]!==i.COLOR_ATTACHMENT0){for(let a=0,o=n.length;a<o;a++)r[a]=i.COLOR_ATTACHMENT0+a;r.length=n.length,s=!0}}else r[0]!==i.BACK&&(r[0]=i.BACK,s=!0);s&&i.drawBuffers(r)}activeTexture(e){let{gl:t,currentTextureSlot:i,maxTextures:r}=this;e===void 0&&(e=t.TEXTURE0+r-1),i!==e&&(t.activeTexture(e),this.currentTextureSlot=e)}bindTexture(e,t,i){let{gl:r,currentTextureSlot:s,currentBoundTextures:n,maxTextures:a}=this;i===void 0&&(i=s===null?r.TEXTURE0+a-1:s);let o=n[i];o===void 0&&(o={type:void 0,texture:void 0},n[i]=o),(o.type!==e||o.texture!==t)&&(s!==i&&(r.activeTexture(i),this.currentTextureSlot=i),r.bindTexture(e,t),o.type=e,o.texture=t)}bindBufferBase(e,t,i){let{gl:r}=this,s=`${e}-${t}`;return this.currentBoundBufferBases[s]===i?!1:(r.bindBufferBase(e,t,i),this.currentBoundBufferBases[s]=i,!0)}unbindTexture(){let{gl:e,currentTextureSlot:t,currentBoundTextures:i}=this,r=i[t];r!==void 0&&r.type!==void 0&&(e.bindTexture(r.type,null),r.type=void 0,r.texture=void 0)}},uW=class{constructor(e){this.backend=e,this.gl=this.backend.gl,this.extensions=e.extensions}convert(e,t=""){let{gl:i,extensions:r}=this,s,n=lt.getTransfer(t);if(e===1009)return i.UNSIGNED_BYTE;if(e===1017)return i.UNSIGNED_SHORT_4_4_4_4;if(e===1018)return i.UNSIGNED_SHORT_5_5_5_1;if(e===35902)return i.UNSIGNED_INT_5_9_9_9_REV;if(e===35899)return i.UNSIGNED_INT_10F_11F_11F_REV;if(e===1010)return i.BYTE;if(e===1011)return i.SHORT;if(e===1012)return i.UNSIGNED_SHORT;if(e===1013)return i.INT;if(e===1014)return i.UNSIGNED_INT;if(e===1015)return i.FLOAT;if(e===1016)return i.HALF_FLOAT;if(e===1021)return i.ALPHA;if(e===1022)return i.RGB;if(e===1023)return i.RGBA;if(e===1026)return i.DEPTH_COMPONENT;if(e===1027)return i.DEPTH_STENCIL;if(e===1028)return i.RED;if(e===1029)return i.RED_INTEGER;if(e===1030)return i.RG;if(e===1031)return i.RG_INTEGER;if(e===1033)return i.RGBA_INTEGER;if(e===33776||e===33777||e===33778||e===33779)if(n==="srgb")if(s=r.get("WEBGL_compressed_texture_s3tc_srgb"),s!==null){if(e===33776)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(e===33777)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(e===33778)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(e===33779)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(s=r.get("WEBGL_compressed_texture_s3tc"),s!==null){if(e===33776)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(e===33777)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(e===33778)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(e===33779)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(e===35840||e===35841||e===35842||e===35843)if(s=r.get("WEBGL_compressed_texture_pvrtc"),s!==null){if(e===35840)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(e===35841)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(e===35842)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(e===35843)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(e===36196||e===37492||e===37496||e===37488||e===37489||e===37490||e===37491)if(s=r.get("WEBGL_compressed_texture_etc"),s!==null){if(e===36196||e===37492)return n==="srgb"?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(e===37496)return n==="srgb"?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC;
165if(e===37488)return s.COMPRESSED_R11_EAC;if(e===37489)return s.COMPRESSED_SIGNED_R11_EAC;if(e===37490)return s.COMPRESSED_RG11_EAC;if(e===37491)return s.COMPRESSED_SIGNED_RG11_EAC}else return null;if(e===37808||e===37809||e===37810||e===37811||e===37812||e===37813||e===37814||e===37815||e===37816||e===37817||e===37818||e===37819||e===37820||e===37821)if(s=r.get("WEBGL_compressed_texture_astc"),s!==null){if(e===37808)return n==="srgb"?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(e===37809)return n==="srgb"?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(e===37810)return n==="srgb"?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(e===37811)return n==="srgb"?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(e===37812)return n==="srgb"?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(e===37813)return n==="srgb"?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(e===37814)return n==="srgb"?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(e===37815)return n==="srgb"?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(e===37816)return n==="srgb"?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(e===37817)return n==="srgb"?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(e===37818)return n==="srgb"?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(e===37819)return n==="srgb"?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(e===37820)return n==="srgb"?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(e===37821)return n==="srgb"?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(e===36492)if(s=r.get("EXT_texture_compression_bptc"),s!==null){if(e===36492)return n==="srgb"?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT}else return null;if(e===36283||e===36284||e===36285||e===36286)if(s=r.get("EXT_texture_compression_rgtc"),s!==null){if(e===36283)return s.COMPRESSED_RED_RGTC1_EXT;if(e===36284)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(e===36285)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(e===36286)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return e===1020?i.UNSIGNED_INT_24_8:i[e]===void 0?null:i[e]}_clientWaitAsync(){let{gl:e}=this,t=e.fenceSync(e.SYNC_GPU_COMMANDS_COMPLETE,0);return e.flush(),new Promise((i,r)=>{function s(){let n=e.clientWaitSync(t,e.SYNC_FLUSH_COMMANDS_BIT,0);if(n===e.WAIT_FAILED){e.deleteSync(t),r();return}if(n===e.TIMEOUT_EXPIRED){requestAnimationFrame(s);return}e.deleteSync(t),i()}s()})}},JL=!1,N0,C_,QL,dW=class{constructor(e){this.backend=e,this.gl=e.gl,this.extensions=e.extensions,this.defaultTextures={},this._srcFramebuffer=null,this._dstFramebuffer=null,JL===!1&&(this._init(),JL=!0)}_init(){let e=this.gl;N0={[Or]:e.REPEAT,[Fa]:e.CLAMP_TO_EDGE,[vg]:e.MIRRORED_REPEAT},C_={[lr]:e.NEAREST,[ZO]:e.NEAREST_MIPMAP_NEAREST,[JO]:e.NEAREST_MIPMAP_LINEAR,[mi]:e.LINEAR,[QO]:e.LINEAR_MIPMAP_NEAREST,[bg]:e.LINEAR_MIPMAP_LINEAR},QL={512:e.NEVER,519:e.ALWAYS,513:e.LESS,515:e.LEQUAL,514:e.EQUAL,518:e.GEQUAL,516:e.GREATER,517:e.NOTEQUAL}}getGLTextureType(e){let{gl:t}=this,i;return i=e.isCubeTexture===!0?t.TEXTURE_CUBE_MAP:e.isArrayTexture===!0||e.isDataArrayTexture===!0||e.isCompressedArrayTexture===!0?t.TEXTURE_2D_ARRAY:e.isData3DTexture===!0?t.TEXTURE_3D:t.TEXTURE_2D,i}getInternalFormat(e,t,i,r,s=!1){let{gl:n,extensions:a}=this;if(e!==null){if(n[e]!==void 0)return n[e];de("WebGLBackend: Attempt to use non-existing WebGL internal format '"+e+"'")}let o=t;if(t===n.RED&&(i===n.FLOAT&&(o=n.R32F),i===n.HALF_FLOAT&&(o=n.R16F),i===n.UNSIGNED_BYTE&&(o=n.R8),i===n.UNSIGNED_SHORT&&(o=n.R16),i===n.UNSIGNED_INT&&(o=n.R32UI),i===n.BYTE&&(o=n.R8I),i===n.SHORT&&(o=n.R16I),i===n.INT&&(o=n.R32I)),t===n.RED_INTEGER&&(i===n.UNSIGNED_BYTE&&(o=n.R8UI),i===n.UNSIGNED_SHORT&&(o=n.R16UI),i===n.UNSIGNED_INT&&(o=n.R32UI),i===n.BYTE&&(o=n.R8I),i===n.SHORT&&(o=n.R16I),i===n.INT&&(o=n.R32I)),t===n.RG&&(i===n.FLOAT&&(o=n.RG32F),i===n.HALF_FLOAT&&(o=n.RG16F),i===n.UNSIGNED_BYTE&&(o=n.RG8),i===n.UNSIGNED_SHORT&&(o=n.RG16),i===n.UNSIGNED_INT&&(
165o=n.RG32UI),i===n.BYTE&&(o=n.RG8I),i===n.SHORT&&(o=n.RG16I),i===n.INT&&(o=n.RG32I)),t===n.RG_INTEGER&&(i===n.UNSIGNED_BYTE&&(o=n.RG8UI),i===n.UNSIGNED_SHORT&&(o=n.RG16UI),i===n.UNSIGNED_INT&&(o=n.RG32UI),i===n.BYTE&&(o=n.RG8I),i===n.SHORT&&(o=n.RG16I),i===n.INT&&(o=n.RG32I)),t===n.RGB){let l=s?wg:lt.getTransfer(r);i===n.FLOAT&&(o=n.RGB32F),i===n.HALF_FLOAT&&(o=n.RGB16F),i===n.UNSIGNED_BYTE&&(o=n.RGB8),i===n.UNSIGNED_SHORT&&(o=n.RGB16),i===n.UNSIGNED_INT&&(o=n.RGB32UI),i===n.BYTE&&(o=n.RGB8I),i===n.SHORT&&(o=n.RGB16I),i===n.INT&&(o=n.RGB32I),i===n.UNSIGNED_BYTE&&(o=l==="srgb"?n.SRGB8:n.RGB8),i===n.UNSIGNED_SHORT_5_6_5&&(o=n.RGB565),i===n.UNSIGNED_SHORT_5_5_5_1&&(o=n.RGB5_A1),i===n.UNSIGNED_SHORT_4_4_4_4&&(o=n.RGB4),i===n.UNSIGNED_INT_5_9_9_9_REV&&(o=n.RGB9_E5),i===n.UNSIGNED_INT_10F_11F_11F_REV&&(o=n.R11F_G11F_B10F)}if(t===n.RGB_INTEGER&&(i===n.UNSIGNED_BYTE&&(o=n.RGB8UI),i===n.UNSIGNED_SHORT&&(o=n.RGB16UI),i===n.UNSIGNED_INT&&(o=n.RGB32UI),i===n.BYTE&&(o=n.RGB8I),i===n.SHORT&&(o=n.RGB16I),i===n.INT&&(o=n.RGB32I)),t===n.RGBA){let l=s?wg:lt.getTransfer(r);i===n.FLOAT&&(o=n.RGBA32F),i===n.HALF_FLOAT&&(o=n.RGBA16F),i===n.UNSIGNED_BYTE&&(o=n.RGBA8),i===n.UNSIGNED_SHORT&&(o=n.RGBA16),i===n.UNSIGNED_INT&&(o=n.RGBA32UI),i===n.BYTE&&(o=n.RGBA8I),i===n.SHORT&&(o=n.RGBA16I),i===n.INT&&(o=n.RGBA32I),i===n.UNSIGNED_BYTE&&(o=l==="srgb"?n.SRGB8_ALPHA8:n.RGBA8),i===n.UNSIGNED_SHORT_4_4_4_4&&(o=n.RGBA4),i===n.UNSIGNED_SHORT_5_5_5_1&&(o=n.RGB5_A1)}return t===n.RGBA_INTEGER&&(i===n.UNSIGNED_BYTE&&(o=n.RGBA8UI),i===n.UNSIGNED_SHORT&&(o=n.RGBA16UI),i===n.UNSIGNED_INT&&(o=n.RGBA32UI),i===n.BYTE&&(o=n.RGBA8I),i===n.SHORT&&(o=n.RGBA16I),i===n.INT&&(o=n.RGBA32I)),t===n.DEPTH_COMPONENT&&(i===n.UNSIGNED_SHORT&&(o=n.DEPTH_COMPONENT16),i===n.UNSIGNED_INT&&(o=n.DEPTH_COMPONENT24),i===n.FLOAT&&(o=n.DEPTH_COMPONENT32F)),t===n.DEPTH_STENCIL&&i===n.UNSIGNED_INT_24_8&&(o=n.DEPTH24_STENCIL8),(o===n.R16F||o===n.R32F||o===n.RG16F||o===n.RG32F||o===n.RGBA16F||o===n.RGBA32F)&&a.get("EXT_color_buffer_float"),o}setTextureParameters(e,t){let{gl:i,extensions:r,backend:s}=this,n=lt.getPrimaries(lt.workingColorSpace),a=t.colorSpace===""?null:lt.getPrimaries(t.colorSpace),o=t.colorSpace===""||n===a?i.NONE:i.BROWSER_DEFAULT_WEBGL;i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,t.flipY),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultiplyAlpha),i.pixelStorei(i.UNPACK_ALIGNMENT,t.unpackAlignment),i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,o),i.texParameteri(e,i.TEXTURE_WRAP_S,N0[t.wrapS]),i.texParameteri(e,i.TEXTURE_WRAP_T,N0[t.wrapT]),(e===i.TEXTURE_3D||e===i.TEXTURE_2D_ARRAY)&&(t.isArrayTexture||i.texParameteri(e,i.TEXTURE_WRAP_R,N0[t.wrapR])),i.texParameteri(e,i.TEXTURE_MAG_FILTER,C_[t.magFilter]);let l=t.mipmaps!==void 0&&t.mipmaps.length>0,h=t.minFilter===1006&&l?bg:t.minFilter;if(i.texParameteri(e,i.TEXTURE_MIN_FILTER,C_[h]),t.compareFunction&&(i.texParameteri(e,i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE),i.texParameteri(e,i.TEXTURE_COMPARE_FUNC,QL[t.compareFunction])),r.has("EXT_texture_filter_anisotropic")===!0){if(t.magFilter===1003||t.minFilter!==1005&&t.minFilter!==1008||t.type===1015&&r.has("OES_texture_float_linear")===!1)return;if(t.anisotropy>1){let u=r.get("EXT_texture_filter_anisotropic");i.texParameterf(e,u.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(t.anisotropy,s.capabilities.getMaxAnisotropy()))}}}createDefaultTexture(e){let{gl:t,backend:i,defaultTextures:r}=this,s=this.getGLTextureType(e),n=r[s];n===void 0&&(n=t.createTexture(),i.state.bindTexture(s,n),t.texParameteri(s,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(s,t.TEXTURE_MAG_FILTER,t.NEAREST),r[s]=n),i.set(e,{textureGPU:n,glTextureType:s})}createTexture(e,t){let{gl:i,backend:r}=this,{levels:s,width:n,height:a,depth:o}=t,l=r.utils.convert(e.format,e.colorSpace),h=r.utils.convert(e.type),u=this.getInternalFormat(e.internalFormat,l,h,e.colorSpace,e.isVideoTexture),d=i.createTexture(),c=this.getGLTextureType(e);r.state.bindTexture(c,d),this.setTextureParameters(c,e),e.isArrayTexture||e.isDataArrayTexture||e.isCompressedArrayTexture?i.texStorage3D(i.TEXTURE_2D_ARRAY,s,u,n,a,o):e.isData3DTexture?i.texStorage3D(i.TEXTURE_3D,s,u,n,a,o):e.isVideoTexture||i.texStorage2D(c,s,u,n,a),r.set(e,{textureGPU:d,glTextureType:c,glFormat:l,glType:h,glInternalFormat:u})}copyBufferToTexture(e,t){let{gl:i,backend:r}=this,{textureGPU:s,glTextureType:n,glFormat:a,glType:o}=r.get(t),{width:l,height:h}=t.source.data;i.bindBuffer(i.PIXEL_UNPACK_BUFFER,e),r.state.bindTexture(n,s),i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,!1),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),i.texSubImage2D(n,0,0,0,l,h,a,o,0),i.bindBuffer(i.PIXEL_UNPACK_BUFFER,null),r.state.unbindTexture()}updateTexture(e,t){let{gl:i}=this,{width:r,height:s}=t,{textureGPU:n,glTextureType:a,glFormat:o,glType:l,glInternalFormat:h}=this.backend.get(e);if(!(e.isRenderTargetTexture||n===void 0))if(this.backend.state.bindTexture(a,n),this.setTextureParameters(a,e),e.isCompressedTexture){let u=e.mipmaps,d=t.image;for(let c=0;c<u.length;c++){let p=u[c];e.isCompressedArrayTexture?e.format===i.RGBA?i.texSubImage3D(i.TEXTURE_2D_ARRAY,c,0,0,0,p.width,p.height,d.depth,o,l,p.data):o===null?de("WebGLBackend: Attempt to load unsupported compressed texture format in .uploadTexture()"):i.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,c,0,0,0,p.width,p.height,d.depth,o,p.data):o===null?de("WebGLBackend: Unsupported compressed texture format"):i.compressedTexSubImage2D(i.TEXTURE_2D,c,0,0,p.width,p.height,o,p.data)}}else if(e.isCubeTexture){let u=t.images,d=e.mipmaps;for(let c=0;c<6;c++){let p=L0(u[c]);i.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+c,0,0,0,r,s,o,l,p);for(let m=0;m<d.length;m++){let g=d[m],f=L0(g.images[c]);i.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+c,m+1,0,0,f.width,f.height,o,l,f)}}}else if(e.isDataArrayTexture||e.isArrayTexture){let u=t.image;if(e.layerUpdates.size>0){let d=DU(u.width,u.height,e.format,e.type);for(let c of e.layerUpdates){let p=u.data.subarray(c*d/u.data.BYTES_PER_ELEMENT,(c+1)*d/u.data.BYTES_PER_ELEMENT);i.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,c,u.width,u.height,1,o,l,p)}e.clearLayerUpdates()}else i.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,0,u.width,u.height,u.depth,o,l,u.data)}else if(e.isData3DTexture){let u=t.image;i.texSubImage3D(i.TEXTURE_3D,0,0,0,0,u.width,u.height,u.depth,o,l,u.data)}
165else if(e.isVideoTexture)e.update(),i.texImage2D(a,0,h,o,l,t.image);else{let u=e.mipmaps;if(u.length>0)for(let d=0,c=u.length;d<c;d++){let p=u[d],m=L0(p);i.texSubImage2D(a,d,0,0,p.width,p.height,o,l,m)}else{let d=L0(t.image);i.texSubImage2D(a,0,0,0,r,s,o,l,d)}}}generateMipmaps(e){let{gl:t,backend:i}=this,{textureGPU:r,glTextureType:s}=i.get(e);i.state.bindTexture(s,r),t.generateMipmap(s)}deallocateRenderBuffers(e){let{gl:t,backend:i}=this;if(e){let r=i.get(e);if(r.renderBufferStorageSetup=void 0,r.framebuffers){for(let s in r.framebuffers)t.deleteFramebuffer(r.framebuffers[s]);delete r.framebuffers}if(r.depthRenderbuffer&&(t.deleteRenderbuffer(r.depthRenderbuffer),delete r.depthRenderbuffer),r.stencilRenderbuffer&&(t.deleteRenderbuffer(r.stencilRenderbuffer),delete r.stencilRenderbuffer),r.msaaFrameBuffer&&(t.deleteFramebuffer(r.msaaFrameBuffer),delete r.msaaFrameBuffer),r.msaaRenderbuffers){for(let s=0;s<r.msaaRenderbuffers.length;s++)t.deleteRenderbuffer(r.msaaRenderbuffers[s]);delete r.msaaRenderbuffers}}}destroyTexture(e,t=!1){let{gl:i,backend:r}=this,{textureGPU:s,renderTarget:n}=r.get(e);this.deallocateRenderBuffers(n),t===!1&&i.deleteTexture(s),r.delete(e)}copyTextureToTexture(e,t,i=null,r=null,s=0,n=0){let{gl:a,backend:o}=this,{state:l}=this.backend,{textureGPU:h,glTextureType:u,glType:d,glFormat:c}=o.get(t);l.bindTexture(u,h);let p,m,g,f,y,x,b,_,T,w=e.isCompressedTexture?e.mipmaps[n]:e.image;if(i!==null)p=i.max.x-i.min.x,m=i.max.y-i.min.y,g=i.isBox3?i.max.z-i.min.z:1,f=i.min.x,y=i.min.y,x=i.isBox3?i.min.z:0;else{let V=2**-s;p=Math.floor(w.width*V),m=Math.floor(w.height*V),g=e.isDataArrayTexture||e.isArrayTexture?w.depth:e.isData3DTexture?Math.floor(w.depth*V):1,f=0,y=0,x=0}r===null?(b=0,_=0,T=0):(b=r.x,_=r.y,T=r.z),a.pixelStorei(a.UNPACK_FLIP_Y_WEBGL,t.flipY),a.pixelStorei(a.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultiplyAlpha),a.pixelStorei(a.UNPACK_ALIGNMENT,t.unpackAlignment);let M=a.getParameter(a.UNPACK_ROW_LENGTH),S=a.getParameter(a.UNPACK_IMAGE_HEIGHT),R=a.getParameter(a.UNPACK_SKIP_PIXELS),I=a.getParameter(a.UNPACK_SKIP_ROWS),B=a.getParameter(a.UNPACK_SKIP_IMAGES);a.pixelStorei(a.UNPACK_ROW_LENGTH,w.width),a.pixelStorei(a.UNPACK_IMAGE_HEIGHT,w.height),a.pixelStorei(a.UNPACK_SKIP_PIXELS,f),a.pixelStorei(a.UNPACK_SKIP_ROWS,y),a.pixelStorei(a.UNPACK_SKIP_IMAGES,x);let O=e.isDataArrayTexture||e.isData3DTexture||t.isArrayTexture,U=t.isDataArrayTexture||t.isData3DTexture||t.isArrayTexture;if(e.isDepthTexture){let V=o.get(e),z=o.get(t),Z=o.get(V.renderTarget),j=o.get(z.renderTarget),ae=Z.framebuffers[V.cacheKey],W=j.framebuffers[z.cacheKey];l.bindFramebuffer(a.READ_FRAMEBUFFER,ae),l.bindFramebuffer(a.DRAW_FRAMEBUFFER,W);for(let me=0;me<g;me++)O&&(a.framebufferTextureLayer(a.READ_FRAMEBUFFER,a.COLOR_ATTACHMENT0,V.textureGPU,s,x+me),a.framebufferTextureLayer(a.DRAW_FRAMEBUFFER,a.COLOR_ATTACHMENT0,h,n,T+me)),a.blitFramebuffer(f,y,p,m,b,_,p,m,a.DEPTH_BUFFER_BIT,a.NEAREST);l.bindFramebuffer(a.READ_FRAMEBUFFER,null),l.bindFramebuffer(a.DRAW_FRAMEBUFFER,null)}else if(s!==0||e.isRenderTargetTexture||o.has(e)){let V=o.get(e);this._srcFramebuffer===null&&(this._srcFramebuffer=a.createFramebuffer()),this._dstFramebuffer===null&&(this._dstFramebuffer=a.createFramebuffer()),l.bindFramebuffer(a.READ_FRAMEBUFFER,this._srcFramebuffer),l.bindFramebuffer(a.DRAW_FRAMEBUFFER,this._dstFramebuffer);for(let z=0;z<g;z++)O?a.framebufferTextureLayer(a.READ_FRAMEBUFFER,a.COLOR_ATTACHMENT0,V.textureGPU,s,x+z):a.framebufferTexture2D(a.READ_FRAMEBUFFER,a.COLOR_ATTACHMENT0,a.TEXTURE_2D,V.textureGPU,s),U?a.framebufferTextureLayer(a.DRAW_FRAMEBUFFER,a.COLOR_ATTACHMENT0,h,n,T+z):a.framebufferTexture2D(a.DRAW_FRAMEBUFFER,a.COLOR_ATTACHMENT0,a.TEXTURE_2D,h,n),s===0?U?a.copyTexSubImage3D(u,n,b,_,T+z,f,y,p,m):a.copyTexSubImage2D(u,n,b,_,f,y,p,m):a.blitFramebuffer(f,y,p,m,b,_,p,m,a.COLOR_BUFFER_BIT,a.NEAREST);l.bindFramebuffer(a.READ_FRAMEBUFFER,null),l.bindFramebuffer(a.DRAW_FRAMEBUFFER,null)}else U?e.isDataTexture||e.isData3DTexture?a.texSubImage3D(u,n,b,_,T,p,m,g,c,d,w.data):t.isCompressedArrayTexture?a.compressedTexSubImage3D(u,n,b,_,T,p,m,g,c,w.data):a.texSubImage3D(u,n,b,_,T,p,m,g,c,d,w):e.isDataTexture?a.texSubImage2D(a.TEXTURE_2D,n,b,_,p,m,c,d,w.data):e.isCompressedTexture?a.compressedTexSubImage2D(a.TEXTURE_2D,n,b,_,w.width,w.height,c,w.data):a.texSubImage2D(a.TEXTURE_2D,n,b,_,p,m,c,d,w);a.pixelStorei(a.UNPACK_ROW_LENGTH,M),a.pixelStorei(a.UNPACK_IMAGE_HEIGHT,S),a.pixelStorei(a.UNPACK_SKIP_PIXELS,R),a.pixelStorei(a.UNPACK_SKIP_ROWS,I),a.pixelStorei(a.UNPACK_SKIP_IMAGES,B),n===0&&t.generateMipmaps&&a.generateMipmap(u),l.unbindTexture()}copyFramebufferToTexture(e,t,i){let{gl:r}=this,{state:s}=this.backend,{textureGPU:n}=this.backend.get(e),{x:a,y:o,z:l,w:h}=i,u=e.isDepthTexture===!0||t.renderTarget&&t.renderTarget.samples>0,d=t.renderTarget?t.renderTarget.height:this.backend.getDrawingBufferSize().y;if(u){let c=a!==0||o!==0,p,m;if(e.isDepthTexture===!0?(p=r.DEPTH_BUFFER_BIT,m=r.DEPTH_ATTACHMENT,t.stencil&&(p|=r.STENCIL_BUFFER_BIT)):(p=r.COLOR_BUFFER_BIT,m=r.COLOR_ATTACHMENT0),c){let g=this.backend.get(t.renderTarget),f=g.framebuffers[t.getCacheKey()],y=g.msaaFrameBuffer;s.bindFramebuffer(r.DRAW_FRAMEBUFFER,f),s.bindFramebuffer(r.READ_FRAMEBUFFER,y);let x=d-o-h;r.blitFramebuffer(a,x,a+l,x+h,a,x,a+l,x+h,p,r.NEAREST),s.bindFramebuffer(r.READ_FRAMEBUFFER,f),s.bindTexture(r.TEXTURE_2D,n),r.copyTexSubImage2D(r.TEXTURE_2D,0,0,0,a,x,l,h),s.unbindTexture()}else{let g=r.createFramebuffer();s.bindFramebuffer(r.DRAW_FRAMEBUFFER,g),r.framebufferTexture2D(r.DRAW_FRAMEBUFFER,m,r.TEXTURE_2D,n,0),r.blitFramebuffer(0,0,l,h,0,0,l,h,p,r.NEAREST),r.deleteFramebuffer(g)}}else s.bindTexture(r.TEXTURE_2D,n),r.copyTexSubImage2D(r.TEXTURE_2D,0,0,0,a,d-h-o,l,h),s.unbindTexture();e.generateMipmaps&&this.generateMipmaps(e),this.backend._setFramebuffer(t)}setupRenderBufferStorage(e,t,i,r=!1){let{gl:s}=this,n=t.renderTarget,{depthTexture:a,depthBuffer:o,stencilBuffer:l,width:h,height:u}=n;if(s.bindRenderbuffer(s.RENDERBUFFER,e),o&&!l){let d=s.DEPTH_COMPONENT24;r===!0?this.extensions.get("WEBGL_multisampled_render_to_texture").renderbufferStorageMultisampleEXT(s.RENDERBUFFER,n.samples,d,h,u):i>0?(a&&a.isDepthTexture&&a.type===s.FLOAT&&(d=s.DEPTH_COMPONENT32F),s.renderbufferStorageMultisample(s.RENDERBUFFER,i,d,h,u)):s.renderbufferStorage(s.RENDERBUFFER,d,h,u),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.DEPTH_ATTACHMENT,s.RENDERBUFFER,e)}else o&&l&&(i>0?s.renderbufferStorageMultisample(s.RENDERBUFFER,i,s.DEPTH24_STENCIL8,h,u):s.renderbufferStorage(s.RENDERBUFFER,s.DEPTH_STENCIL,h,u),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.DEPTH_STENCIL_ATTACHMENT,s.RENDERBUFFER,e));s.bindRenderbuffer(s.RENDERBUFFER,null)}async copyTextureToBuffer(e,t,i,r,s,n){let{backend:a,gl:o}=this,{textureGPU:l,glFormat:h,glType:u}=this.backend.get(e),d=o.createFramebuffer();a.state.bindFramebuffer(o.READ_FRAMEBUFFER,d);let c=e.isCubeTexture?o.TEXTURE_CUBE_MAP_POSITIVE_X+n:o.TEXTURE_2D;o.framebufferTexture2D(o.READ_FRAMEBUFFER,o.COLOR_ATTACHMENT0,c,l,0);let p=this._getTypedArrayType(u),m=this._getBytesPerTexel(u,h),g=r*s*m,f=o.createBuffer();o.bindBuffer(o.PIXEL_PACK_BUFFER,f),o.bufferData(o.PIXEL_PACK_BUFFER,g,o.STREAM_READ),o.readPixels(t,i,r,s,h,u,0),o.bindBuffer(o.PIXEL_PACK_BUFFER,null),await a.utils._clientWaitAsync();let y=new p(g/p.BYTES_PER_ELEMENT);return o.bindBuffer(o.PIXEL_PACK_BUFFER,f),o.getBufferSubData(o.PIXEL_PACK_BUFFER,0,y),o.bindBuffer(o.PIXEL_PACK_BUFFER,null),a.state.bindFramebuffer(o.READ_FRAMEBUFFER,null),o.deleteFramebuffer(d),y}_getTypedArrayType(e){let{gl:t}=this;if(e===t.UNSIGNED_BYTE)return Uint8Array;
165if(e===t.UNSIGNED_SHORT_4_4_4_4||e===t.UNSIGNED_SHORT_5_5_5_1||e===t.UNSIGNED_SHORT_5_6_5||e===t.UNSIGNED_SHORT)return Uint16Array;if(e===t.UNSIGNED_INT)return Uint32Array;if(e===t.HALF_FLOAT)return Uint16Array;if(e===t.FLOAT)return Float32Array;throw Error(`Unsupported WebGL type: ${e}`)}_getBytesPerTexel(e,t){let{gl:i}=this,r=0;if(e===i.UNSIGNED_BYTE&&(r=1),(e===i.UNSIGNED_SHORT_4_4_4_4||e===i.UNSIGNED_SHORT_5_5_5_1||e===i.UNSIGNED_SHORT_5_6_5||e===i.UNSIGNED_SHORT||e===i.HALF_FLOAT)&&(r=2),(e===i.UNSIGNED_INT||e===i.FLOAT)&&(r=4),t===i.RGBA)return r*4;if(t===i.RGB)return r*3;if(t===i.ALPHA)return r}dispose(){let{gl:e}=this;this._srcFramebuffer!==null&&e.deleteFramebuffer(this._srcFramebuffer),this._dstFramebuffer!==null&&e.deleteFramebuffer(this._dstFramebuffer)}};function L0(e){return e.isDataTexture?e.image.data:typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap||typeof OffscreenCanvas<"u"&&e instanceof OffscreenCanvas?e:e.data}var cW=class{constructor(e){this.backend=e,this.gl=this.backend.gl,this.availableExtensions=this.gl.getSupportedExtensions(),this.extensions={}}get(e){let t=this.extensions[e];return t===void 0&&(t=this.gl.getExtension(e),this.extensions[e]=t),t}has(e){return this.availableExtensions.includes(e)}},pW=class{constructor(e){this.backend=e,this.maxAnisotropy=null,this.maxUniformBlockSize=null}getMaxAnisotropy(){if(this.maxAnisotropy!==null)return this.maxAnisotropy;let e=this.backend.gl,t=this.backend.extensions;if(t.has("EXT_texture_filter_anisotropic")===!0){let i=t.get("EXT_texture_filter_anisotropic");this.maxAnisotropy=e.getParameter(i.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else this.maxAnisotropy=0;return this.maxAnisotropy}getUniformBufferLimit(){if(this.maxUniformBlockSize!==null)return this.maxUniformBlockSize;let e=this.backend.gl;return this.maxUniformBlockSize=e.getParameter(e.MAX_UNIFORM_BLOCK_SIZE),this.maxUniformBlockSize}},e3={WEBGL_multi_draw:"WEBGL_multi_draw",WEBGL_compressed_texture_astc:"texture-compression-astc",WEBGL_compressed_texture_etc:"texture-compression-etc2",WEBGL_compressed_texture_etc1:"texture-compression-etc1",WEBGL_compressed_texture_pvrtc:"texture-compression-pvrtc",WEBGL_compressed_texture_s3tc:"texture-compression-s3tc",EXT_texture_compression_bptc:"texture-compression-bc",EXT_disjoint_timer_query_webgl2:"timestamp-query",OVR_multiview2:"OVR_multiview2"},mW=class{constructor(e){this.gl=e.gl,this.extensions=e.extensions,this.info=e.renderer.info,this.mode=null,this.index=0,this.type=null,this.object=null}render(e,t){let{gl:i,mode:r,object:s,type:n,info:a,index:o}=this;o===0?i.drawArrays(r,e,t):i.drawElements(r,t,n,e),a.update(s,t,1)}renderInstances(e,t,i){let{gl:r,mode:s,type:n,index:a,object:o,info:l}=this;i!==0&&(a===0?r.drawArraysInstanced(s,e,t,i):r.drawElementsInstanced(s,t,n,e,i),l.update(o,t,i))}renderMultiDraw(e,t,i){let{extensions:r,mode:s,object:n,info:a}=this;if(i===0)return;let o=r.get("WEBGL_multi_draw");if(o===null)for(let l=0;l<i;l++)this.render(e[l],t[l]);else{this.index===0?o.multiDrawArraysWEBGL(s,e,0,t,0,i):o.multiDrawElementsWEBGL(s,t,0,this.type,e,0,i);let l=0;for(let h=0;h<i;h++)l+=t[h];a.update(n,l,1)}}renderMultiDrawInstances(e,t,i,r){let{extensions:s,mode:n,object:a,info:o}=this;if(i===0)return;let l=s.get("WEBGL_multi_draw");if(l===null)for(let h=0;h<i;h++)this.renderInstances(e[h],t[h],r[h]);
165else{this.index===0?l.multiDrawArraysInstancedWEBGL(n,e,0,t,0,r,0,i):l.multiDrawElementsInstancedWEBGL(n,t,0,this.type,e,0,r,0,i);let h=0;for(let u=0;u<i;u++)h+=t[u]*r[u];o.update(a,h,1)}}},t3=class{constructor(e=256){this.trackTimestamp=!0,this.maxQueries=e,this.currentQueryIndex=0,this.queryOffsets=new Map,this.isDisposed=!1,this.lastValue=0,this.frames=[],this.pendingResolve=!1,this.timestamps=new Map}getTimestampFrames(){return this.frames}getTimestamp(e){let t=this.timestamps.get(e);return t===void 0&&(de(`TimestampQueryPool: No timestamp available for uid ${e}.`),t=0),t}hasTimestamp(e){return this.timestamps.has(e)}allocateQueriesForContext(){}async resolveQueriesAsync(){}dispose(){}},gW=class extends t3{constructor(e,t,i=2048){if(super(i),this.gl=e,this.type=t,this.ext=e.getExtension("EXT_disjoint_timer_query_webgl2")||e.getExtension("EXT_disjoint_timer_query"),!this.ext){de("EXT_disjoint_timer_query not supported; timestamps will be disabled."),this.trackTimestamp=!1;return}this.queries=[];for(let r=0;r<this.maxQueries;r++)this.queries.push(e.createQuery());this.activeQuery=null,this.queryStates=new Map}allocateQueriesForContext(e){if(!this.trackTimestamp)return null;if(this.currentQueryIndex+2>this.maxQueries)return ut(`WebGLTimestampQueryPool [${this.type}]: Maximum number of queries exceeded, when using trackTimestamp it is necessary to resolves the queries via renderer.resolveTimestampsAsync( THREE.TimestampQuery.${this.type.toUpperCase()} ).`),null;let t=this.currentQueryIndex;return this.currentQueryIndex+=2,this.queryStates.set(t,"inactive"),this.queryOffsets.set(e,t),t}beginQuery(e){if(!this.trackTimestamp||this.isDisposed)return;let t=this.queryOffsets.get(e);if(t==null||this.activeQuery!==null)return;let i=this.queries[t];if(i)try{this.queryStates.get(t)==="inactive"&&(this.gl.beginQuery(this.ext.TIME_ELAPSED_EXT,i),this.activeQuery=t,this.queryStates.set(t,"started"))}catch(r){re("Error in beginQuery:",r),this.activeQuery=null,this.queryStates.set(t,"inactive")}}endQuery(e){if(!this.trackTimestamp||this.isDisposed)return;let t=this.queryOffsets.get(e);if(t!=null&&this.activeQuery===t)try{this.gl.endQuery(this.ext.TIME_ELAPSED_EXT),this.queryStates.set(t,"ended"),this.activeQuery=null}catch(i){re("Error in endQuery:",i),this.queryStates.set(t,"inactive"),this.activeQuery=null}}async resolveQueriesAsync(){if(!this.trackTimestamp||this.pendingResolve)return this.lastValue;this.pendingResolve=!0;try{let e=new Map;for(let[s,n]of this.queryOffsets)if(this.queryStates.get(n)==="ended"){let a=this.queries[n];e.set(s,this.resolveQuery(a))}if(e.size===0)return this.lastValue;let t={},i=[];for(let[s,n]of e){let a=s.match(/^(.*):f(\d+)$/),o=parseInt(a[2]);i.includes(o)===!1&&i.push(o),t[o]===void 0&&(t[o]=0);let l=await n;this.timestamps.set(s,l),t[o]+=l}let r=t[i[i.length-1]];return this.lastValue=r,this.frames=i,this.currentQueryIndex=0,this.queryOffsets.clear(),this.queryStates.clear(),this.activeQuery=null,r}catch(e){return re("Error resolving queries:",e),this.lastValue}finally{this.pendingResolve=!1}}async resolveQuery(e){return new Promise(t=>{if(this.isDisposed){t(this.lastValue);return}let i,r=!1,s=()=>{i&&=(clearTimeout(i),null)},n=o=>{r||(r=!0,s(),t(o))},a=()=>{if(this.isDisposed){n(this.lastValue);return}try{if(this.gl.getParameter(this.ext.GPU_DISJOINT_EXT)){n(this.lastValue);return}if(!this.gl.getQueryParameter(e,this.gl.QUERY_RESULT_AVAILABLE)){i=setTimeout(a,1);return}let o=this.gl.getQueryParameter(e,this.gl.QUERY_RESULT);t(Number(o)/1e6)}catch(o){re("Error checking query:",o),t(this.lastValue)}};a()})}dispose(){if(!this.isDisposed&&(this.isDisposed=!0,this.trackTimestamp)){for(let e of this.queries)this.gl.deleteQuery(e);this.queries=[],this.queryStates.clear(),this.queryOffsets.clear(),this.lastValue=0,this.activeQuery=null}}},R_=class extends ZL{constructor(e={}){super(e),this.isWebGLBackend=!0,this.attributeUtils=null,this.extensions=null,this.capabilities=null,this.textureUtils=null,this.bufferRenderer=null,this.gl=null,this.state=null,this.utils=null,this.vaoCache={},this.transformFeedbackCache={},this.discard=!1,this.disjoint=null,this.parallel=null,this._currentContext=null,this._knownBindings=new WeakSet,this._supportsInvalidateFramebuffer=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),this._xrFramebuffer=null}init(e){super.init(e);let t=this.parameters,i={antialias:e.currentSamples>0,alpha:!0,depth:e.depth,stencil:e.stencil},r=t.context===void 0?e.domElement.getContext("webgl2",i):t.context;function s(n){n.preventDefault();let a={api:"WebGL",message:n.statusMessage||"Unknown reason",reason:null,originalEvent:n};e.onDeviceLost(a)}this._onContextLost=s,e.domElement.addEventListener("webglcontextlost",s,!1),this.gl=r,this.extensions=new cW(this),this.capabilities=new pW(this),this.attributeUtils=new lW(this),this.textureUtils=new dW(this),this.bufferRenderer=new mW(this),this.state=new hW(this),this.utils=new uW(this),this.extensions.get("EXT_color_buffer_float"),this.extensions.get("WEBGL_clip_cull_distance"),this.extensions.get("OES_texture_float_linear"),this.extensions.get("EXT_color_buffer_half_float"),this.extensions.get("WEBGL_multisampled_render_to_texture"),this.extensions.get("WEBGL_render_shared_exponent"),this.extensions.get("WEBGL_multi_draw"),this.extensions.get("OVR_multiview2"),this.extensions.get("EXT_clip_control"),this.disjoint=this.extensions.get("EXT_disjoint_timer_query_webgl2"),this.parallel=this.extensions.get("KHR_parallel_shader_compile"),this.drawBuffersIndexedExt=this.extensions.get("OES_draw_buffers_indexed"),t.reversedDepthBuffer&&(this.extensions.has("EXT_clip_control")?e.reversedDepthBuffer=!0:(de("WebGPURenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer."),e.reversedDepthBuffer=!1)),e.reversedDepthBuffer&&this.state.setReversedDepth(!0)}get coordinateSystem(){return ch}async getArrayBufferAsync(e){return await this.attributeUtils.getArrayBufferAsync(e)}async makeXRCompatible(){this.gl.getContextAttributes().xrCompatible!==!0&&await this.gl.makeXRCompatible()}setXRTarget(e){this._xrFramebuffer=e}setXRRenderTargetTextures(e,t,i=null){let r=this.gl;if(this.set(e.texture,{textureGPU:t,glInternalFormat:r.RGBA8}),i!==null){let s=e.stencilBuffer?r.DEPTH24_STENCIL8:r.DEPTH_COMPONENT24;this.set(e.depthTexture,{textureGPU:i,glInternalFormat:s}),this.extensions.has("WEBGL_multisampled_render_to_texture")===!0&&e._autoAllocateDepthBuffer===!0&&e.multiview===!1&&de("WebGLBackend: Render-to-texture extension was disabled because an external texture was provided"),e._autoAllocateDepthBuffer=!1}}initTimestampQuery(e,t){if(!this.disjoint||!this.trackTimestamp)return;this.timestampQueryPool[e]||(this.timestampQueryPool[e]=new gW(this.gl,e,2048));let i=this.timestampQueryPool[e];i.allocateQueriesForContext(t)!==null&&i.beginQuery(t)}prepareTimestampBuffer(e,t){!this.disjoint||!this.trackTimestamp||this.timestampQueryPool[e].endQuery(t)}getContext(){return this.gl}beginRender(e){let{state:t}=this,i=this.get(e);if(e.viewport)this.updateViewport(e);else{let{width:s,height:n}=this.getDrawingBufferSize();t.viewport(0,0,s,n)}if(e.scissor)this.updateScissor(e);else{let{width:s,height:n}=this.getDrawingBufferSize();t.scissor(0,0,s,n)}this.initTimestampQuery(Ur.RENDER,this.getTimestampUID(e)),i.previousContext=this._currentContext,this._currentContext=e,this._setFramebuffer(e),this.clear(e.clearColor,e.clearDepth,e.clearStencil,e,!1);let r=e.occlusionQueryCount;r>0&&(i.currentOcclusionQueries=i.occlusionQueries,i.currentOcclusionQueryObjects=i.occlusionQueryObjects,i.lastOcclusionObject=null,i.occlusionQueries=Array(r),i.occlusionQueryObjects=Array(r),i.occlusionQueryIndex=0)}finishRender(e){let{gl:t,state:i}=this,r=this.get(e),s=r.previousContext;i.resetVertexState();let n=e.occlusionQueryCount;n>0&&(n>r.occlusionQueryIndex&&t.endQuery(t.ANY_SAMPLES_PASSED),this.resolveOccludedAsync(e));let a=e.textures;if(a!==null)for(let o=0;o<a.length;o++){let l=a[o];l.generateMipmaps&&this.generateMipmaps(l)}if(this._currentContext=s,this._resolveRenderTarget(e),s!==null){if(this._setFramebuffer(s),s.viewport)this.updateViewport(s);else{let{width:o,height:l}=this.getDrawingBufferSize();i.viewport(0,0,o,l)}if(s.scissor)this.updateScissor(s);else{let{width:o,height:l}=this.getDrawingBufferSize();i.scissor(0,0,o,l)}}this.prepareTimestampBuffer(Ur.RENDER,this.getTimestampUID(e))}resolveOccludedAsync(e){let t=this.get(e),{currentOcclusionQueries:i,currentOcclusionQueryObjects:r}=t;if(i&&r){let s=new WeakSet,{gl:n}=this;t.currentOcclusionQueryObjects=null,t.currentOcclusionQueries=null;let a=()=>{let o=0;for(let l=0;l<i.length;l++){let h=i[l];h!==null&&n.getQueryParameter(h,n.QUERY_RESULT_AVAILABLE)&&(n.getQueryParameter(h,n.QUERY_RESULT)===0&&s.add(r[l]),i[l]=null,n.deleteQuery(h),o++)}o<i.length?requestAnimationFrame(a):t.occluded=s};a()}}isOccluded(e,t){let i=this.get(e);return i.occluded&&i.occluded.has(t)}updateViewport(e){let{state:t}=this,{x:i,y:r,width:s,height:n}=e.viewportValue;t.viewport(i,e.height-n-r,s,n)}updateScissor(e){let{state:t}=this,{x:i,y:r,width:s,height:n}=e.scissorValue;t.scissor(i,e.height-n-r,s,n)}setScissorTest(e){this.state.setScissorTest(e)}getClearColor(){let e=super.getClearColor();return e.r*=e.a,e.g*=e.a,e.b*=e.a,e}clear(e,t,i,r=null,s=!0,n=!0){let{gl:a,renderer:o}=this;r===null&&(r={textures:null,clearColorValue:this.getClearColor()});let l=0;if(e&&(l|=a.COLOR_BUFFER_BIT),t&&(l|=a.DEPTH_BUFFER_BIT),i&&(l|=a.STENCIL_BUFFER_BIT),l!==0){let h;h=r.clearColorValue?r.clearColorValue:this.getClearColor();let u=o.getClearDepth(),d=o.getClearStencil();if(t&&this.state.setDepthMask(!0),r.textures===null)a.clearColor(h.r,h.g,h.b,h.a),a.clear(l);else{if(s&&this._setFramebuffer(r),e)for(let c=0;c<r.textures.length;
165c++)c===0?a.clearBufferfv(a.COLOR,c,[h.r,h.g,h.b,h.a]):a.clearBufferfv(a.COLOR,c,[0,0,0,1]);t&&i?a.clearBufferfi(a.DEPTH_STENCIL,0,u,d):t?a.clearBufferfv(a.DEPTH,0,[u]):i&&a.clearBufferiv(a.STENCIL,0,[d]),s&&n&&this._resolveRenderTarget(r)}}}beginCompute(e){let{state:t,gl:i}=this;t.bindFramebuffer(i.FRAMEBUFFER,null),this.initTimestampQuery(Ur.COMPUTE,this.getTimestampUID(e))}compute(e,t,i,r,s=null){let{state:n,gl:a}=this;this.discard===!1&&(n.enable(a.RASTERIZER_DISCARD),this.discard=!0);let{programGPU:o,transformBuffers:l,attributes:h}=this.get(r),u=this._getVaoKey(h),d=this.vaoCache[u];d===void 0?this.vaoCache[u]=this._createVao(h):n.setVertexState(d),n.useProgram(o),this._bindUniforms(i);let c=this._getTransformFeedback(l);a.bindTransformFeedback(a.TRANSFORM_FEEDBACK,c),a.beginTransformFeedback(a.POINTS),s=s===null?t.count:s,Array.isArray(s)?(ut("WebGLBackend.compute(): The count parameter must be a single number, not an array."),s=s[0]):s&&typeof s=="object"&&s.isIndirectStorageBufferAttribute&&(ut("WebGLBackend.compute(): The count parameter must be a single number, not IndirectStorageBufferAttribute"),s=t.count),h[0].isStorageInstancedBufferAttribute?a.drawArraysInstanced(a.POINTS,0,1,s):a.drawArrays(a.POINTS,0,s),a.endTransformFeedback(),a.bindTransformFeedback(a.TRANSFORM_FEEDBACK,null);for(let p=0;p<l.length;p++){let m=l[p];m.pbo&&this.has(m.pbo)&&this.textureUtils.copyBufferToTexture(m.transformBuffer,m.pbo),m.switchBuffers()}}finishCompute(e){let{state:t,gl:i}=this;this.discard=!1,t.disable(i.RASTERIZER_DISCARD),this.prepareTimestampBuffer(Ur.COMPUTE,this.getTimestampUID(e)),this._currentContext&&this._setFramebuffer(this._currentContext)}_isRenderCameraDepthArray(e){return e.depthTexture&&e.depthTexture.isArrayTexture&&e.camera.isArrayCamera}_draw(e,t,i,r,s){e.isBatchedMesh?e._multiDrawInstances===null?this.hasFeature("WEBGL_multi_draw")?t.renderMultiDraw(e._multiDrawStarts,e._multiDrawCounts,e._multiDrawCount):ut("WebGLBackend: WEBGL_multi_draw not supported."):(ut("WebGLBackend: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),t.renderMultiDrawInstances(e._multiDrawStarts,e._multiDrawCounts,e._multiDrawCount,e._multiDrawInstances)):s>1?t.renderInstances(i,r,s):t.render(i,r)}draw(e){let{object:t,pipeline:i,material:r,context:s,hardwareClippingPlanes:n}=e,{programGPU:a}=this.get(i),{gl:o,state:l}=this,h=this.get(s),u=e.getDrawParameters();if(u===null)return;this._bindUniforms(e.getBindings());let d=t.isMesh&&t.matrixWorld.determinant()<0;l.setMaterial(r,d,n),s.mrt!==null&&s.textures!==null&&l.setMRTBlending(s.textures,s.mrt,r),l.useProgram(a);let c=e.getAttributes(),p=this.get(c),m=p.vaoGPU;if(m===void 0){let w=this._getVaoKey(c);m=this.vaoCache[w],m===void 0&&(m=this._createVao(c),this.vaoCache[w]=m,p.vaoGPU=m)}let g=e.getIndex(),f=g===null?null:this.get(g).bufferGPU;l.setVertexState(m,f);let y=h.lastOcclusionObject;if(y!==t&&y!==void 0){if(y!==null&&y.occlusionTest===!0&&(o.endQuery(o.ANY_SAMPLES_PASSED),h.occlusionQueryIndex++),t.occlusionTest===!0){let w=o.createQuery();o.beginQuery(o.ANY_SAMPLES_PASSED,w),h.occlusionQueries[h.occlusionQueryIndex]=w,h.occlusionQueryObjects[h.occlusionQueryIndex]=t}h.lastOcclusionObject=t}let x=this.bufferRenderer;t.isPoints?x.mode=o.POINTS:t.isLineSegments?x.mode=o.LINES:t.isLine?x.mode=o.LINE_STRIP:t.isLineLoop?x.mode=o.LINE_LOOP:r.wireframe===!0?(l.setLineWidth(r.wireframeLinewidth*this.renderer.getPixelRatio()),x.mode=o.LINES):x.mode=o.TRIANGLES;let{vertexCount:b,instanceCount:_}=u,{firstVertex:T}=u;if(x.object=t,g!==null){T*=g.array.BYTES_PER_ELEMENT;let w=this.get(g);x.index=g.count,x.type=w.type}else x.index=0;if(e.camera.isArrayCamera===!0&&e.camera.cameras.length>0&&e.camera.isMultiViewCamera===!1){let w=this.get(e.camera),M=e.camera.cameras,S=e.getBindingGroup("cameraIndex").bindings[0];if(w.indexesGPU===void 0||w.indexesGPU.length!==M.length){let V=new Uint32Array([0,0,0,0]),z=[];for(let Z=0,j=M.length;Z<j;Z++){let ae=o.createBuffer();V[0]=Z,o.bindBuffer(o.UNIFORM_BUFFER,ae),o.bufferData(o.UNIFORM_BUFFER,V,o.STATIC_DRAW),z.push(ae)}w.indexesGPU=z}let R=0;e:for(let V of e.getBindings())for(let z of V.bindings){if(z===S)break e;(z.isUniformsGroup||z.isUniformBuffer)&&R++}let I=this.renderer.getPixelRatio(),B=this._currentContext.renderTarget,O=this._isRenderCameraDepthArray(this._currentContext),U=this._currentContext.activeCubeFace;if(O){let V=this.get(B.depthTexture);if(V.clearedRenderId!==this.renderer._nodes.nodeFrame.renderId){V.clearedRenderId=this.renderer._nodes.nodeFrame.renderId;let{stencilBuffer:z}=B;for(let Z=0,j=M.length;Z<j;Z++)this.renderer._activeCubeFace=Z,this._currentContext.activeCubeFace=Z,this._setFramebuffer(this._currentContext),this.clear(!1,!0,z,this._currentContext,!1,!1);this.renderer._activeCubeFace=U,this._currentContext.activeCubeFace=U}}for(let V=0,z=M.length;V<z;V++){let Z=M[V];if(t.layers.test(Z.layers)){O&&(this.renderer._activeCubeFace=V,this._currentContext.activeCubeFace=V,this._setFramebuffer(this._currentContext));let j=Z.viewport;if(j!==void 0){let ae=j.x*I,W=j.y*I,me=j.width*I,Ce=j.height*I;l.viewport(Math.floor(ae),Math.floor(e.context.height-Ce-W),Math.floor(me),Math.floor(Ce))}l.bindBufferBase(o.UNIFORM_BUFFER,R,w.indexesGPU[V]),this._draw(t,x,T,b,_)}this._currentContext.activeCubeFace=U,this.renderer._activeCubeFace=U}}else this._draw(t,x,T,b,_)}
165needsRenderUpdate(){return!1}getRenderCacheKey(){return""}createDefaultTexture(e){this.textureUtils.createDefaultTexture(e)}createTexture(e,t){this.textureUtils.createTexture(e,t)}updateTexture(e,t){this.textureUtils.updateTexture(e,t)}generateMipmaps(e){this.textureUtils.generateMipmaps(e)}destroyTexture(e,t=!1){this.textureUtils.destroyTexture(e,t)}async copyTextureToBuffer(e,t,i,r,s,n){return this.textureUtils.copyTextureToBuffer(e,t,i,r,s,n)}updateSampler(){return""}createNodeBuilder(e,t){return new nW(e,t)}createProgram(e){let t=this.gl,{stage:i,code:r}=e,s=i==="fragment"?t.createShader(t.FRAGMENT_SHADER):t.createShader(t.VERTEX_SHADER);t.shaderSource(s,r),t.compileShader(s),this.set(e,{shaderGPU:s})}destroyProgram(e){this.delete(e)}createRenderPipeline(e,t){let i=this.gl,r=e.pipeline,{fragmentProgram:s,vertexProgram:n}=r,a=i.createProgram(),o=this.get(s).shaderGPU,l=this.get(n).shaderGPU;if(i.attachShader(a,o),i.attachShader(a,l),i.linkProgram(a),this.set(r,{programGPU:a,fragmentShader:o,vertexShader:l}),t!==null&&this.parallel){let h=new Promise(u=>{let d=this.parallel,c=()=>{i.getProgramParameter(a,d.COMPLETION_STATUS_KHR)?(this._completeCompile(e,r),u()):requestAnimationFrame(c)};c()});t.push(h);return}this._completeCompile(e,r)}_handleSource(e,t){let i=e.split(`
166`),r=[],s=Math.max(t-6,0),n=Math.min(t+6,i.length);for(let a=s;a<n;a++){let o=a+1;r.push(`${o===t?">":" "} ${o}: ${i[a]}`)}return r.join(`
167`)}_getShaderErrors(e,t,i){let r=e.getShaderParameter(t,e.COMPILE_STATUS),s=(e.getShaderInfoLog(t)||"").trim();if(r&&s==="")return"";let n=/ERROR: 0:(\d+)/.exec(s);if(n){let a=parseInt(n[1]);return i.toUpperCase()+`
168
169`+s+`
170
171`+this._handleSource(e.getShaderSource(t),a)}else return s}_logProgramError(e,t,i){if(this.renderer.debug.checkShaderErrors){let r=this.gl,s=(r.getProgramInfoLog(e)||"").trim();if(r.getProgramParameter(e,r.LINK_STATUS)===!1)if(typeof this.renderer.debug.onShaderError=="function")this.renderer.debug.onShaderError(r,e,i,t);else{let n=this._getShaderErrors(r,i,"vertex"),a=this._getShaderErrors(r,t,"fragment");re("THREE.WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(e,r.VALIDATE_STATUS)+`
172
173Program Info Log: `+s+`
174`+n+`
175`+a)}else s!==""&&de("WebGLProgram: Program Info Log:",s)}}_completeCompile(e,t){let{state:i,gl:r}=this,{programGPU:s,fragmentShader:n,vertexShader:a}=this.get(t);r.getProgramParameter(s,r.LINK_STATUS)===!1&&this._logProgramError(s,n,a),i.useProgram(s);let o=e.getBindings();this._setupBindings(o,s),this.set(t,{programGPU:s,pipeline:s})}createComputePipeline(e,t){let{state:i,gl:r}=this,s={stage:"fragment",code:`#version 300 es
176precision highp float;
177void main() {}`};this.createProgram(s);let{computeProgram:n}=e,a=r.createProgram(),o=this.get(s).shaderGPU,l=this.get(n).shaderGPU,h=n.transforms,u=[],d=[];for(let g=0;g<h.length;g++){let f=h[g];u.push(f.varyingName),d.push(f.attributeNode)}r.attachShader(a,o),r.attachShader(a,l),r.transformFeedbackVaryings(a,u,r.SEPARATE_ATTRIBS),r.linkProgram(a),r.getProgramParameter(a,r.LINK_STATUS)===!1&&this._logProgramError(a,o,l),i.useProgram(a),this._setupBindings(t,a);let c=n.attributes,p=[],m=[];for(let g=0;g<c.length;g++){let f=c[g].node.attribute;p.push(f),this.has(f)||this.attributeUtils.createAttribute(f,r.ARRAY_BUFFER)}for(let g=0;g<d.length;g++){let f=d[g].attribute;this.has(f)||this.attributeUtils.createAttribute(f,r.ARRAY_BUFFER);let y=this.get(f);m.push(y)}this.set(e,{programGPU:a,transformBuffers:m,attributes:p})}createBindings(e,t){if(this._knownBindings.has(t)===!1){this._knownBindings.add(t);let i=0,r=0;for(let s of t){this.set(s,{textures:r,uniformBuffers:i});for(let n of s.bindings)n.isUniformBuffer&&i++,n.isSampledTexture&&r++}}this.updateBindings(e,t)}updateBindings(e){let{gl:t}=this;for(let i of e.bindings){let r=this.get(i);if(i.isUniformsGroup||i.isUniformBuffer){let s=i.buffer,{bufferGPU:n}=this.get(s);n===void 0?(n=t.createBuffer(),t.bindBuffer(t.UNIFORM_BUFFER,n),t.bufferData(t.UNIFORM_BUFFER,s.byteLength,t.DYNAMIC_DRAW),this.set(s,{bufferGPU:n})):t.bindBuffer(t.UNIFORM_BUFFER,n);let a=i.updateRanges;if(t.bindBuffer(t.UNIFORM_BUFFER,n),a.length===0)t.bufferData(t.UNIFORM_BUFFER,s,t.DYNAMIC_DRAW);else{let o=kc(s),l=o?1:s.BYTES_PER_ELEMENT;for(let h=0,u=a.length;h<u;h++){let d=a[h],c=d.start*l,p=d.count*l,m=c*(o?s.BYTES_PER_ELEMENT:1);t.bufferSubData(t.UNIFORM_BUFFER,m,s,c,p)}}r.bufferGPU=n,this.set(i,r)}else if(i.isSampledTexture){let{textureGPU:s,glTextureType:n}=this.get(i.texture);r.textureGPU=s,r.glTextureType=n,this.set(i,r)}}}updateBinding(e){let t=this.gl;if(e.isUniformsGroup||e.isUniformBuffer){let i=this.get(e).bufferGPU,r=e.buffer,s=e.updateRanges;if(t.bindBuffer(t.UNIFORM_BUFFER,i),s.length===0)t.bufferData(t.UNIFORM_BUFFER,r,t.DYNAMIC_DRAW);else{let n=kc(r),a=n?1:r.BYTES_PER_ELEMENT;for(let o=0,l=s.length;o<l;o++){let h=s[o],u=h.start*a,d=h.count*a,c=u*(n?r.BYTES_PER_ELEMENT:1);t.bufferSubData(t.UNIFORM_BUFFER,c,r,u,d)}}}}createIndexAttribute(e){let t=this.gl;this.attributeUtils.createAttribute(e,t.ELEMENT_ARRAY_BUFFER)}createAttribute(e){if(this.has(e))return;let t=this.gl;this.attributeUtils.createAttribute(e,t.ARRAY_BUFFER)}createStorageAttribute(e){if(this.has(e))return;let t=this.gl;this.attributeUtils.createAttribute(e,t.ARRAY_BUFFER)}updateAttribute(e){this.attributeUtils.updateAttribute(e)}destroyAttribute(e){this.attributeUtils.destroyAttribute(e)}hasFeature(e){let t=Object.keys(e3).filter(r=>e3[r]===e),i=this.extensions;for(let r=0;r<t.length;r++)if(i.has(t[r]))return!0;return!1}copyTextureToTexture(e,t,i=null,r=null,s=0,n=0){this.textureUtils.copyTextureToTexture(e,t,i,r,s,n)}copyFramebufferToTexture(e,t,i){this.textureUtils.copyFramebufferToTexture(e,t,i)}hasCompatibility(e){return e===ph.TEXTURE_COMPARE?!0:super.hasCompatibility(e)}initRenderTarget(e){let{gl:t,state:i}=this;this._setFramebuffer(e),i.bindFramebuffer(t.FRAMEBUFFER,null)}_setFramebuffer(e){let{gl:t,state:i}=this,r=null;if(e.textures!==null){let s=e.renderTarget,n=this.get(s),{samples:a,depthBuffer:o,stencilBuffer:l}=s,h=s.isCubeRenderTarget===!0,u=s.isRenderTarget3D===!0,d=s.depth>1,c=s.isXRRenderTarget===!0,p=c===!0&&s._hasExternalTextures===!0,m=n.msaaFrameBuffer,g=n.depthRenderbuffer,f=this.extensions.get("WEBGL_multisampled_render_to_texture"),y=this.extensions.get("OVR_multiview2"),x=this._useMultisampledExtension(s),b=mN(e),_;if(h?(n.cubeFramebuffers||={},_=n.cubeFramebuffers[b]):c&&p===!1?_=this._xrFramebuffer:(n.framebuffers||={},_=n.framebuffers[b]),_===void 0){_=t.createFramebuffer(),i.bindFramebuffer(t.FRAMEBUFFER,_);let T=e.textures,w=[];if(h){n.cubeFramebuffers[b]=_;let{textureGPU:S}=this.get(T[0]),R=this.renderer._activeCubeFace,I=this.renderer._activeMipmapLevel;t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+R,S,I)}else{n.framebuffers[b]=_;for(let S=0;S<T.length;S++){let R=T[S],I=this.get(R);I.renderTarget=e.renderTarget,I.cacheKey=b;let B=t.COLOR_ATTACHMENT0+S;if(s.multiview)y.framebufferTextureMultisampleMultiviewOVR(t.FRAMEBUFFER,B,I.textureGPU,0,a,0,2);else if(u||d){let O=this.renderer._activeCubeFace,U=this.renderer._activeMipmapLevel;t.framebufferTextureLayer(t.FRAMEBUFFER,B,I.textureGPU,U,O)}else if(x)f.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,B,t.TEXTURE_2D,I.textureGPU,0,a);else{let O=this.renderer._activeMipmapLevel;t.framebufferTexture2D(t.FRAMEBUFFER,B,t.TEXTURE_2D,I.textureGPU,O)}}}let M=l?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;if(s._autoAllocateDepthBuffer===!0){let S=t.createRenderbuffer();this.textureUtils.setupRenderBufferStorage(S,e,0,x),n.xrDepthRenderbuffer=S,w.push(l?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT),t.bindRenderbuffer(t.RENDERBUFFER,S),t.framebufferRenderbuffer(t.FRAMEBUFFER,M,t.RENDERBUFFER,S)}else if(e.depthTexture!==null){w.push(l?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT);let S=this.get(e.depthTexture);if(S.renderTarget=e.renderTarget,S.cacheKey=b,s.multiview)y.framebufferTextureMultisampleMultiviewOVR(t.FRAMEBUFFER,M,S.textureGPU,0,a,0,2);else if(p&&x)f.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,M,t.TEXTURE_2D,S.textureGPU,0,a);else if(e.depthTexture.isArrayTexture){let R=this.renderer._activeCubeFace;t.framebufferTextureLayer(t.FRAMEBUFFER,M,S.textureGPU,0,R)}else if(e.depthTexture.isCubeTexture){let R=this.renderer._activeCubeFace;t.framebufferTexture2D(t.FRAMEBUFFER,M,t.TEXTURE_CUBE_MAP_POSITIVE_X+R,S.textureGPU,0)}else t.framebufferTexture2D(t.FRAMEBUFFER,M,t.TEXTURE_2D,S.textureGPU,0)}n.depthInvalidationArray=w}else{if(this._isRenderCameraDepthArray(e)){i.bindFramebuffer(t.FRAMEBUFFER,_);let T=this.renderer._activeCubeFace,w=this.get(e.depthTexture),M=l?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;t.framebufferTextureLayer(t.FRAMEBUFFER,M,w.textureGPU,0,T)}if((c||x||s.multiview)&&s._isOpaqueFramebuffer!==!0){i.bindFramebuffer(t.FRAMEBUFFER,_);let T=this.get(e.textures[0]);s.multiview?y.framebufferTextureMultisampleMultiviewOVR(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,T.textureGPU,0,a,0,2):x?f.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,T.textureGPU,0,a):t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,T.textureGPU,0);let w=l?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;if(s._autoAllocateDepthBuffer===!0){let M=n.xrDepthRenderbuffer;t.bindRenderbuffer(t.RENDERBUFFER,M),t.framebufferRenderbuffer(t.FRAMEBUFFER,w,t.RENDERBUFFER,M)}else{let M=this.get(e.depthTexture);s.multiview?y.framebufferTextureMultisampleMultiviewOVR(t.FRAMEBUFFER,w,M.textureGPU,0,a,0,2):x?f.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,w,t.TEXTURE_2D,M.textureGPU,0,a):t.framebufferTexture2D(t.FRAMEBUFFER,w,t.TEXTURE_2D,M.textureGPU,0)}}}if(a>0&&x===!1&&!s.multiview){if(m===void 0){let T=[];m=t.createFramebuffer(),i.bindFramebuffer(t.FRAMEBUFFER,m);let w=[],M=e.textures;for(let S=0;S<M.length;S++){w[S]=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,w[S]),T.push(t.COLOR_ATTACHMENT0+S);let R=e.textures[S],I=this.get(R);t.renderbufferStorageMultisample(t.RENDERBUFFER,a,I.glInternalFormat,e.width,e.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+S,t.RENDERBUFFER,w[S])}if(t.bindRenderbuffer(t.RENDERBUFFER,null),n.msaaFrameBuffer=m,n.msaaRenderbuffers=w,o&&g===void 0){g=t.createRenderbuffer(),this.textureUtils.setupRenderBufferStorage(g,e,a),n.depthRenderbuffer=g;let S=l?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;T.push(S)}n.invalidationArray=T}r=n.msaaFrameBuffer}else r=_;i.drawBuffers(e,_)}i.bindFramebuffer(t.FRAMEBUFFER,r)}_getVaoKey(e){let t="";for(let i=0;i<e.length;i++){let r=this.get(e[i]);t+=":"+r.id}return t}_createVao(e){let{gl:t}=this,i=t.createVertexArray();t.bindVertexArray(i);for(let r=0;r<e.length;r++){let s=e[r],n=this.get(s);t.bindBuffer(t.ARRAY_BUFFER,n.bufferGPU),t.enableVertexAttribArray(r);let a,o;s.isInterleavedBufferAttribute===!0?(a=s.data.stride*n.bytesPerElement,o=s.offset*n.bytesPerElement):(a=0,o=0),n.isInteger?t.vertexAttribIPointer(r,s.itemSize,n.type,a,o):t.vertexAttribPointer(r,s.itemSize,n.type,s.normalized,a,o),s.isInstancedBufferAttribute&&!s.isInterleavedBufferAttribute?t.vertexAttribDivisor(r,s.meshPerAttribute):s.isInterleavedBufferAttribute&&s.data.isInstancedInterleavedBuffer&&t.vertexAttribDivisor(r,s.data.meshPerAttribute)}return t.bindBuffer(t.ARRAY_BUFFER,null),i}_getTransformFeedback(e){let t="";for(let s=0;s<e.length;s++)t+=":"+e[s].id;let i=this.transformFeedbackCache[t];if(i!==void 0)return i;let{gl:r}=this;i=r.createTransformFeedback(),r.bindTransformFeedback(r.TRANSFORM_FEEDBACK,i);for(let s=0;s<e.length;s++){let n=e[s];r.bindBufferBase(r.TRANSFORM_FEEDBACK_BUFFER,s,n.transformBuffer)}return r.bindTransformFeedback(r.TRANSFORM_FEEDBACK,null),this.transformFeedbackCache[t]=i,i}_setupBindings(e,t){let i=this.gl,r=0,s=0;for(let n of e)for(let a of n.bindings)if(a.isUniformsGroup||a.isUniformBuffer){let o=r++,l=i.getUniformBlockIndex(t,a.name);i.uniformBlockBinding(t,l,o)}else if(a.isSampledTexture){let o=s++,l=i.getUniformLocation(t,a.name);i.uniform1i(l,o)}}_bindUniforms(e){let{gl:t,state:i}=this,r=0,s=0;for(let n of e)for(let a of n.bindings){let o=this.get(a);if(a.isUniformsGroup||a.isUniformBuffer){let l=r++;i.bindBufferBase(t.UNIFORM_BUFFER,l,o.bufferGPU)}else if(a.isSampledTexture){let l=s++;i.bindTexture(o.glTextureType,o.textureGPU,t.TEXTURE0+l)}}}_resolveRenderTarget(e){let{gl:t,state:i}=this,r=e.renderTarget;if(e.textures!==null&&r){let s=this.get(r);if(r.samples>0&&this._useMultisampledExtension(r)===!1){let n=s.framebuffers[e.getCacheKey()],a=t.COLOR_BUFFER_BIT;r.resolveDepthBuffer&&(r.depthBuffer&&(a|=t.DEPTH_BUFFER_BIT),r.stencilBuffer&&r.resolveStencilBuffer&&(a|=t.STENCIL_BUFFER_BIT));let o=s.msaaFrameBuffer,l=s.msaaRenderbuffers,h=e.textures,u=h.length>1;if(i.bindFramebuffer(t.READ_FRAMEBUFFER,o),i.bindFramebuffer(t.DRAW_FRAMEBUFFER,n),u)for(let d=0;d<h.length;d++)t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0+d,t.RENDERBUFFER,null),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+d,t.TEXTURE_2D,null,0);for(let d=0;d<h.length;d++){if(u){let{textureGPU:c}=this.get(h[d]);t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.RENDERBUFFER,l[d]),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,c,0)}if(e.scissor){let{x:c,y:p,width:m,height:g}=e.scissorValue,f=e.height-g-p;t.blitFramebuffer(c,f,c+m,f+g,c,f,c+m,f+g,a,t.NEAREST)}else t.blitFramebuffer(0,0,e.width,e.height,0,0,e.width,e.height,a,t.NEAREST)}if(u)for(let d=0;d<h.length;d++){let{textureGPU:c}=this.get(h[d]);t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0+d,t.RENDERBUFFER,l[d]),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+d,t.TEXTURE_2D,c,0)}this._supportsInvalidateFramebuffer===!0&&t.invalidateFramebuffer(t.READ_FRAMEBUFFER,s.invalidationArray)}else if(r.resolveDepthBuffer===!1&&s.framebuffers){let n=s.framebuffers[e.getCacheKey()];i.bindFramebuffer(t.DRAW_FRAMEBUFFER,n),t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,s.depthInvalidationArray)}}}_useMultisampledExtension(e){return e.multiview===!0?!0:e.samples>0&&this.extensions.has("WEBGL_multisampled_render_to_texture")===!0&&e._autoAllocateDepthBuffer!==!1}dispose(){this.textureUtils!==null&&this.textureUtils.dispose();let e=this.extensions.get("WEBGL_lose_context");e&&e.loseContext(),this.renderer.domElement.removeEventListener("webglcontextlost",this._onContextLost)}},P0={PointList:"point-list",LineList:"line-list",LineStrip:"line-strip",TriangleList:"triangle-list"},na=typeof self<"u"&&self.GPUShaderStage?self.GPUShaderStage:{VERTEX:1,FRAGMENT:2,COMPUTE:4},gr={Never:"never",Less:"less",Equal:"equal",LessEqual:"less-equal",Greater:"greater",NotEqual:"not-equal",GreaterEqual:"greater-equal",Always:"always"},Kr={Store:"store"},_t={Load:"load",Clear:"clear"},i3={CCW:"ccw",CW:"cw"},r3={None:"none",Back:"back"},k0={Uint16:"uint16",Uint32:"uint32"},P={R8Unorm:"r8unorm",R8Snorm:"r8snorm",R8Uint:"r8uint",R8Sint:"r8sint",R16Uint:"r16uint",R16Sint:"r16sint",R16Float:"r16float",RG8Unorm:"rg8unorm",RG8Snorm:"rg8snorm",RG8Uint:"rg8uint",RG8Sint:"rg8sint",R32Uint:"r32uint",R32Sint:"r32sint",R32Float:"r32float",RG16Uint:"rg16uint",RG16Sint:"rg16sint",RG16Float:"rg16float",RGBA8Unorm:"rgba8unorm",RGBA8UnormSRGB:"rgba8unorm-srgb",RGBA8Snorm:"rgba8snorm",RGBA8Uint:"rgba8uint",RGBA8Sint:"rgba8sint",BGRA8Unorm:"bgra8unorm",BGRA8UnormSRGB:"bgra8unorm-srgb",RGB9E5UFloat:"rgb9e5ufloat",RGB10A2Unorm:"rgb10a2unorm",RG11B10UFloat:"rg11b10ufloat",RG32Uint:"rg32uint",RG32Sint:"rg32sint",RG32Float:"rg32float",RGBA16Uint:"rgba16uint",RGBA16Sint:"rgba16sint",RGBA16Float:"rgba16float",RGBA32Uint:"rgba32uint",RGBA32Sint:"rgba32sint",RGBA32Float:"rgba32float",Depth16Unorm:"depth16unorm",Depth24Plus:"depth24plus",Depth24PlusStencil8:"depth24plus-stencil8",Depth32Float:"depth32float",Depth32FloatStencil8:"depth32float-stencil8",BC1RGBAUnorm:"bc1-rgba-unorm",BC1RGBAUnormSRGB:"bc1-rgba-unorm-srgb",BC2RGBAUnorm:"bc2-rgba-unorm",BC2RGBAUnormSRGB:"bc2-rgba-unorm-srgb",BC3RGBAUnorm:"bc3-rgba-unorm",BC3RGBAUnormSRGB:"bc3-rgba-unorm-srgb",BC4RUnorm:"bc4-r-unorm",BC4RSnorm:"bc4-r-snorm",BC5RGUnorm:"bc5-rg-unorm",BC5RGSnorm:"bc5-rg-snorm",BC6HRGBUFloat:"bc6h-rgb-ufloat",BC6HRGBFloat:"bc6h-rgb-float",BC7RGBAUnorm:"bc7-rgba-unorm",BC7RGBAUnormSRGB:"bc7-rgba-unorm-srgb",ETC2RGB8Unorm:"etc2-rgb8unorm",ETC2RGB8UnormSRGB:"etc2-rgb8unorm-srgb",ETC2RGB8A1Unorm:
177"etc2-rgb8a1unorm",ETC2RGB8A1UnormSRGB:"etc2-rgb8a1unorm-srgb",ETC2RGBA8Unorm:"etc2-rgba8unorm",ETC2RGBA8UnormSRGB:"etc2-rgba8unorm-srgb",EACR11Unorm:"eac-r11unorm",EACR11Snorm:"eac-r11snorm",EACRG11Unorm:"eac-rg11unorm",EACRG11Snorm:"eac-rg11snorm",ASTC4x4Unorm:"astc-4x4-unorm",ASTC4x4UnormSRGB:"astc-4x4-unorm-srgb",ASTC5x4Unorm:"astc-5x4-unorm",ASTC5x4UnormSRGB:"astc-5x4-unorm-srgb",ASTC5x5Unorm:"astc-5x5-unorm",ASTC5x5UnormSRGB:"astc-5x5-unorm-srgb",ASTC6x5Unorm:"astc-6x5-unorm",ASTC6x5UnormSRGB:"astc-6x5-unorm-srgb",ASTC6x6Unorm:"astc-6x6-unorm",ASTC6x6UnormSRGB:"astc-6x6-unorm-srgb",ASTC8x5Unorm:"astc-8x5-unorm",ASTC8x5UnormSRGB:"astc-8x5-unorm-srgb",ASTC8x6Unorm:"astc-8x6-unorm",ASTC8x6UnormSRGB:"astc-8x6-unorm-srgb",ASTC8x8Unorm:"astc-8x8-unorm",ASTC8x8UnormSRGB:"astc-8x8-unorm-srgb",ASTC10x5Unorm:"astc-10x5-unorm",ASTC10x5UnormSRGB:"astc-10x5-unorm-srgb",ASTC10x6Unorm:"astc-10x6-unorm",ASTC10x6UnormSRGB:"astc-10x6-unorm-srgb",ASTC10x8Unorm:"astc-10x8-unorm",ASTC10x8UnormSRGB:"astc-10x8-unorm-srgb",ASTC10x10Unorm:"astc-10x10-unorm",ASTC10x10UnormSRGB:"astc-10x10-unorm-srgb",ASTC12x10Unorm:"astc-12x10-unorm",ASTC12x10UnormSRGB:"astc-12x10-unorm-srgb",ASTC12x12Unorm:"astc-12x12-unorm",ASTC12x12UnormSRGB:"astc-12x12-unorm-srgb"},E_={ClampToEdge:"clamp-to-edge",Repeat:"repeat",MirrorRepeat:"mirror-repeat"},aa={Linear:"linear",Nearest:"nearest"},rt={Zero:"zero",One:"one",Src:"src",OneMinusSrc:"one-minus-src",SrcAlpha:"src-alpha",OneMinusSrcAlpha:"one-minus-src-alpha",Dst:"dst",OneMinusDst:"one-minus-dst",DstAlpha:"dst-alpha",OneMinusDstAlpha:"one-minus-dst-alpha",SrcAlphaSaturated:"src-alpha-saturated",Constant:"constant",OneMinusConstant:"one-minus-constant"},Uh={Add:"add",Subtract:"subtract",ReverseSubtract:"reverse-subtract",Min:"min",Max:"max"},s3={None:0,All:15},yl={Keep:"keep",Zero:"zero",Replace:"replace",Invert:"invert",IncrementClamp:"increment-clamp",DecrementClamp:"decrement-clamp",IncrementWrap:"increment-wrap",DecrementWrap:"decrement-wrap"},n3={Storage:"storage",ReadOnlyStorage:"read-only-storage"},A_={WriteOnly:"write-only",ReadOnly:"read-only",ReadWrite:"read-write"},a3={NonFiltering:"non-filtering",Comparison:"comparison"},Vh={Float:"float",UnfilterableFloat:"unfilterable-float",Depth:"depth",SInt:"sint",UInt:"uint"},o3={TwoD:"2d",ThreeD:"3d"},Cr={TwoD:"2d",TwoDArray:"2d-array",Cube:"cube",ThreeD:"3d"},fW={All:"all"},I0={Vertex:"vertex",Instance:"instance"},N_={CoreFeaturesAndLimits:"core-features-and-limits",DepthClipControl:"depth-clip-control",Depth32FloatStencil8:"depth32float-stencil8",TextureCompressionBC:"texture-compression-bc",TextureCompressionBCSliced3D:"texture-compression-bc-sliced-3d",TextureCompressionETC2:"texture-compression-etc2",TextureCompressionASTC:"texture-compression-astc",TextureCompressionASTCSliced3D:"texture-compression-astc-sliced-3d",TimestampQuery:"timestamp-query",IndirectFirstInstance:"indirect-first-instance",ShaderF16:"shader-f16",RG11B10UFloat:"rg11b10ufloat-renderable",BGRA8UNormStorage:"bgra8unorm-storage",Float32Filterable:"float32-filterable",Float32Blendable:"float32-blendable",ClipDistances:"clip-distances",DualSourceBlending:"dual-source-blending",Subgroups:"subgroups",TextureFormatsTier1:"texture-formats-tier1",TextureFormatsTier2:"texture-formats-tier2"},l3={"texture-compression-s3tc":"texture-compression-bc","texture-compression-etc1":"texture-compression-etc2"},yW=class extends GL{constructor(e,t,i){super(e,t?t.value:null),this.textureNode=t,this.groupNode=i}update(){let{textureNode:e}=this;return this.texture===e.value?super.update():(this.texture=e.value,!0)}},xW=class extends BL{constructor(e,t){super(e,t?t.array:null),this._attribute=t,this.isStorageBuffer=!0}get attribute(){return this._attribute}},vW=0,bW=class extends xW{constructor(e,t){super("StorageBuffer_"+vW++,e?e.value:null),this.nodeUniform=e,this.access=e?e.access:pr.READ_WRITE,this.groupNode=t}get attribute(){return this.nodeUniform.value}get buffer(){return this.nodeUniform.value.array}},_W=class extends cl{constructor(e){super(),this.device=e,this.mipmapSampler=e.createSampler({minFilter:aa.Linear}),this.flipYSampler=e.createSampler({minFilter:aa.Nearest}),this.flipUniformBuffer=e.createBuffer({size:4,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST}),e.queue.writeBuffer(this.flipUniformBuffer,0,new Uint32Array([1])),this.noFlipUniformBuffer=e.createBuffer({size:4,usage:GPUBufferUsage.UNIFORM}),this.transferPipelines={},this.mipmapShaderModule=e.createShaderModule({label:"mipmap",code:`
178struct VarysStruct {
179	@builtin( position ) Position: vec4f,
180	@location( 0 ) vTex : vec2f,
181	@location( 1 ) @interpolate(flat, either) vBaseArrayLayer: u32,
182};
183
184@group( 0 ) @binding ( 2 )
185var<uniform> flipY: u32;
186
187@vertex
188fn mainVS(
189		@builtin( vertex_index ) vertexIndex : u32,
190		@builtin( instance_index ) instanceIndex : u32 ) -> VarysStruct {
191
192	var Varys : VarysStruct;
193
194	var pos = array(
195		vec2f( -1, -1 ),
196		vec2f( -1,  3 ),
197		vec2f(  3, -1 ),
198	);
199
200	let p = pos[ vertexIndex ];
201	let mult = select( vec2f( 0.5, -0.5 ), vec2f( 0.5, 0.5 ), flipY != 0 );
202	Varys.vTex = p * mult + vec2f( 0.5 );
203	Varys.Position = vec4f( p, 0, 1 );
204	Varys.vBaseArrayLayer = instanceIndex;
205
206	return Varys;
207
208}
209
210@group( 0 ) @binding( 0 )
211var imgSampler : sampler;
212
213@group( 0 ) @binding( 1 )
214var img2d : texture_2d<f32>;
215
216@fragment
217fn main_2d( Varys: VarysStruct ) -> @location( 0 ) vec4<f32> {
218
219	return textureSample( img2d, imgSampler, Varys.vTex );
220
221}
222
223@group( 0 ) @binding( 1 )
224var img2dArray : texture_2d_array<f32>;
225
226@fragment
227fn main_2d_array( Varys: VarysStruct ) -> @location( 0 ) vec4<f32> {
228
229	return textureSample( img2dArray, imgSampler, Varys.vTex, Varys.vBaseArrayLayer );
230
231}
232
233const faceMat = array(
234  mat3x3f(  0,  0,  -2,  0, -2,   0,  1,  1,   1 ),   // pos-x
235  mat3x3f(  0,  0,   2,  0, -2,   0, -1,  1,  -1 ),   // neg-x
236  mat3x3f(  2,  0,   0,  0,  0,   2, -1,  1,  -1 ),   // pos-y
237  mat3x3f(  2,  0,   0,  0,  0,  -2, -1, -1,   1 ),   // neg-y
238  mat3x3f(  2,  0,   0,  0, -2,   0, -1,  1,   1 ),   // pos-z
239  mat3x3f( -2,  0,   0,  0, -2,   0,  1,  1,  -1 ),   // neg-z
240);
241
242@group( 0 ) @binding( 1 )
243var imgCube : texture_cube<f32>;
244
245@fragment
246fn main_cube( Varys: VarysStruct ) -> @location( 0 ) vec4<f32> {
247
248	return textureSample( imgCube, imgSampler, faceMat[ Varys.vBaseArrayLayer ] * vec3f( fract( Varys.vTex ), 1 ) );
249
250}
251`})}getTransferPipeline(e,t){t||="2d-array";let i=`${e}-${t}`,r=this.transferPipelines[i];return r===void 0&&(r=this.device.createRenderPipeline({label:`mipmap-${e}-${t}`,vertex:{module:this.mipmapShaderModule},fragment:{module:this.mipmapShaderModule,entryPoint:`main_${t.replace("-","_")}`,targets:[{format:e}]},layout:"auto"}),this.transferPipelines[i]=r),r}flipY(e,t,i=0){let r=t.format,{width:s,height:n}=t.size,a=this.device.createTexture({size:{width:s,height:n},format:r,usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.TEXTURE_BINDING}),o=this.getTransferPipeline(r,e.textureBindingViewDimension),l=this.getTransferPipeline(r,a.textureBindingViewDimension),h=this.device.createCommandEncoder({}),u=(d,c,p,m,g,f)=>{let y=d.getBindGroupLayout(0),x=this.device.createBindGroup({layout:y,entries:[{binding:0,resource:this.flipYSampler},{binding:1,resource:c.createView({dimension:c.textureBindingViewDimension||"2d-array",baseMipLevel:0,mipLevelCount:1})},{binding:2,resource:{buffer:f?this.flipUniformBuffer:this.noFlipUniformBuffer}}]}),b=h.beginRenderPass({colorAttachments:[{view:m.createView({dimension:"2d",baseMipLevel:0,mipLevelCount:1,baseArrayLayer:g,arrayLayerCount:1}),loadOp:_t.Clear,storeOp:Kr.Store}]});b.setPipeline(d),b.setBindGroup(0,x),b.draw(3,1,0,p),b.end()};u(o,e,i,a,0,!1),u(l,a,0,e,i,!0),this.device.queue.submit([h.finish()]),a.destroy()}generateMipmaps(e,t=null){let i=this.get(e),r=i.layers||this._mipmapCreateBundles(e),s=t||this.device.createCommandEncoder({label:"mipmapEncoder"});this._mipmapRunBundles(s,r),t===null&&this.device.queue.submit([s.finish()]),i.layers=r}_mipmapCreateBundles(e){let t=e.textureBindingViewDimension||"2d-array",i=this.getTransferPipeline(e.format,t),r=i.getBindGroupLayout(0),s=[];for(let n=1;n<e.mipLevelCount;n++)for(let a=0;a<e.depthOrArrayLayers;a++){let o=this.device.createBindGroup({layout:r,entries:[{binding:0,resource:this.mipmapSampler},{binding:1,resource:e.createView({dimension:t,baseMipLevel:n-1,mipLevelCount:1})},{binding:2,resource:{buffer:this.noFlipUniformBuffer}}]}),l={colorAttachments:[{view:e.createView({dimension:"2d",baseMipLevel:n,mipLevelCount:1,baseArrayLayer:a,arrayLayerCount:1}),loadOp:_t.Clear,storeOp:Kr.Store}]},h=this.device.createRenderBundleEncoder({colorFormats:[e.format]});h.setPipeline(i),h.setBindGroup(0,o),h.draw(3,1,0,a),s.push({renderBundles:[h.finish()],passDescriptor:l})}return s}_mipmapRunBundles(e,t){let i=t.length;for(let r=0;r<i;r++){let s=t[r],n=e.beginRenderPass(s.passDescriptor);n.executeBundles(s.renderBundles),n.end()}}},TW={512:"never",513:"less",514:"equal",515:"less-equal",516:"greater",518:"greater-equal",519:"always",517:"not-equal"},wW=[0,1,3,2,4,5],SW=class{constructor(e){this.backend=e,this._passUtils=null,this.defaultTexture={},this.defaultCubeTexture={},this.defaultVideoFrame=null,this._samplerCache=new Map}updateSampler(e){let t=this.backend,i=e.minFilter+"-"+e.magFilter+"-"+e.wrapS+"-"+e.wrapT+"-"+(e.wrapR||"0")+"-"+e.anisotropy+"-"+(e.compareFunction||0),r=this._samplerCache.get(i);if(r===void 0){let n={addressModeU:this._convertAddressMode(e.wrapS),addressModeV:this._convertAddressMode(e.wrapT),addressModeW:this._convertAddressMode(e.wrapR),magFilter:this._convertFilterMode(e.magFilter),minFilter:this._convertFilterMode(e.minFilter),mipmapFilter:this._convertFilterMode(e.minFilter),maxAnisotropy:1};e.isDepthTexture&&e.compareFunction===null&&(n.magFilter=aa.Nearest,n.minFilter=aa.Nearest,n.mipmapFilter=aa.Nearest),n.magFilter===aa.Linear&&n.minFilter===aa.Linear&&n.mipmapFilter===aa.Linear&&(n.maxAnisotropy=e.anisotropy),e.isDepthTexture&&e.compareFunction!==null&&t.hasCompatibility(ph.TEXTURE_COMPARE)&&(n.compare=TW[e.compareFunction]),r={sampler:t.device.createSampler(n),usedTimes:0},this._samplerCache.set(i,r)}let s=t.get(e);if(s.sampler!==r.sampler){if(s.sampler!==void 0){let n=this._samplerCache.get(s.samplerKey);n.usedTimes--,n.usedTimes===0&&this._samplerCache.delete(s.samplerKey)}s.samplerKey=i,s.sampler=r.sampler,r.usedTimes++}
251return i}createDefaultTexture(e){let t,i=L_(e);t=e.isCubeTexture?this._getDefaultCubeTextureGPU(i):this._getDefaultTextureGPU(i),this.backend.get(e).texture=t}createTexture(e,t={}){let i=this.backend,r=i.get(e);if(r.initialized)throw Error("WebGPUTextureUtils: Texture already initialized.");if(e.isExternalTexture){r.texture=e.sourceTexture,r.initialized=!0;return}t.needsMipmaps===void 0&&(t.needsMipmaps=!1),t.levels===void 0&&(t.levels=1),t.depth===void 0&&(t.depth=1);let{width:s,height:n,depth:a,levels:o}=t;e.isFramebufferTexture&&(t.renderTarget?t.format=this.backend.utils.getCurrentColorFormat(t.renderTarget):t.format=this.backend.utils.getPreferredCanvasFormat());let l=this._getDimension(e),h=e.internalFormat||t.format||L_(e,i.device);r.format=h;let{samples:u,primarySamples:d,isMSAA:c}=i.utils.getTextureSampleData(e),p=GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.COPY_SRC;e.isStorageTexture===!0&&(p|=GPUTextureUsage.STORAGE_BINDING),e.isCompressedTexture!==!0&&e.isCompressedArrayTexture!==!0&&h!==P.RGB9E5UFloat&&(p|=GPUTextureUsage.RENDER_ATTACHMENT);let m={label:e.name,size:{width:s,height:n,depthOrArrayLayers:a},mipLevelCount:o,sampleCount:d,dimension:l,format:h,usage:p};if(h===void 0){de("WebGPURenderer: Texture format not supported."),this.createDefaultTexture(e);return}e.isCubeTexture&&(m.textureBindingViewDimension=Cr.Cube);try{r.texture=i.device.createTexture(m)}catch{de("WebGPURenderer: Failed to create texture with descriptor:",m),this.createDefaultTexture(e);return}if(c){let g=Object.assign({},m);g.label+="-msaa",g.sampleCount=u,g.mipLevelCount=1,r.msaaTexture=i.device.createTexture(g)}r.initialized=!0,r.textureDescriptorGPU=m}destroyTexture(e,t=!1){let i=this.backend,r=i.get(e);r.texture!==void 0&&t===!1&&r.texture.destroy(),r.msaaTexture!==void 0&&r.msaaTexture.destroy(),i.delete(e)}generateMipmaps(e,t=null){let i=this.backend.get(e);this._generateMipmaps(i.texture,t)}getColorBuffer(){let e=this.backend,t=e.renderer.getCanvasTarget(),{width:i,height:r}=e.getDrawingBufferSize(),s=e.renderer.currentSamples,n=t.colorTexture,a=e.get(n);if(n.width===i&&n.height===r&&n.samples===s)return a.texture;let o=a.texture;return o&&o.destroy(),o=e.device.createTexture({label:"colorBuffer",size:{width:i,height:r,depthOrArrayLayers:1},sampleCount:e.utils.getSampleCount(e.renderer.currentSamples),format:e.utils.getPreferredCanvasFormat(),usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.COPY_SRC}),n.source.width=i,n.source.height=r,n.samples=s,a.texture=o,o}getDepthBuffer(e=!0,t=!1){let i=this.backend,r=i.renderer.getCanvasTarget(),{width:s,height:n}=i.getDrawingBufferSize(),a=i.renderer.currentSamples,o=r.depthTexture;if(o.width===s&&o.height===n&&o.samples===a&&o.depth===e&&o.stencil===t)return i.get(o).texture;let l=i.get(o).texture,h,u;if(t?(h=uh,u=hh):e&&(h=Da,u=ur),l!==void 0){if(o.image.width===s&&o.image.height===n&&o.format===h&&o.type===u&&o.samples===a)return l;this.destroyTexture(o)}return o.name="depthBuffer",o.format=h,o.type=u,o.image.width=s,o.image.height=n,o.samples=a,this.createTexture(o,{width:s,height:n}),i.get(o).texture}updateTexture(e,t){let i=this.backend.get(e),r=e.mipmaps,{textureDescriptorGPU:s}=i;if(!(e.isRenderTargetTexture||s===void 0)){if(e.isDataTexture)if(r.length>0)for(let n=0,a=r.length;n<a;n++){let o=r[n];this._copyBufferToTexture(o,i.texture,s,0,e.flipY,0,n)}else this._copyBufferToTexture(t.image,i.texture,s,0,e.flipY);else if(e.isArrayTexture||e.isDataArrayTexture||e.isData3DTexture)if(e.layerUpdates&&e.layerUpdates.size>0){for(let n of e.layerUpdates)this._copyBufferToTexture(t.image,i.texture,s,n,e.flipY,n);e.clearLayerUpdates()}else for(let n=0;n<t.image.depth;n++)this._copyBufferToTexture(t.image,i.texture,s,n,e.flipY,n);else if(e.isCompressedTexture||e.isCompressedArrayTexture)this._copyCompressedBufferToTexture(e.mipmaps,i.texture,s);else if(e.isCubeTexture)this._copyCubeMapToTexture(e,i.texture,s);else if(r.length>0)for(let n=0,a=r.length;n<a;n++){let o=r[n];this._copyImageToTexture(o,i.texture,s,0,e.flipY,e.premultiplyAlpha,n)}else this._copyImageToTexture(t.image,i.texture,s,0,e.flipY,e.premultiplyAlpha);i.version=e.version}}async copyTextureToBuffer(e,t,i,r,s,n){let a=this.backend.device,o=this.backend.get(e),l=o.texture,h=o.textureDescriptorGPU.format,u=this._getBytesPerTexel(h),d=r*u;d=Math.ceil(d/256)*256;let c=a.createBuffer({size:(s-1)*d+r*u,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ}),p=a.createCommandEncoder();p.copyTextureToBuffer({texture:l,origin:{x:t,y:i,z:n}},{buffer:c,bytesPerRow:d},{width:r,height:s});let m=this._getTypedArrayType(h);return a.queue.submit([p.finish()]),await c.mapAsync(GPUMapMode.READ),new m(c.getMappedRange())}dispose(){this._samplerCache.clear()}_getDefaultTextureGPU(e){let t=this.defaultTexture[e];if(t===void 0){let i=new Li;i.minFilter=lr,i.magFilter=lr,this.createTexture(i,{width:1,height:1,format:e}),this.defaultTexture[e]=t=i}return this.backend.get(t).texture}_getDefaultCubeTextureGPU(e){let t=this.defaultCubeTexture[e];if(t===void 0){let i=new Xg;i.minFilter=lr,i.magFilter=lr,this.createTexture(i,{width:1,height:1,depth:6}),this.defaultCubeTexture[e]=t=i}return this.backend.get(t).texture}_copyCubeMapToTexture(e,t,i){let r=e.images,s=e.mipmaps;for(let n=0;n<6;n++){let a=r[n],o=e.flipY===!0?wW[n]:n;a.isDataTexture?this._copyBufferToTexture(a.image,t,i,o,e.flipY):this._copyImageToTexture(a,t,i,o,e.flipY,e.premultiplyAlpha);for(let l=0;l<s.length;l++){let h=s[l].images[n];h.isDataTexture?this._copyBufferToTexture(h.image,t,i,o,e.flipY,0,l+1):this._copyImageToTexture(h,t,i,o,e.flipY,e.premultiplyAlpha,l+1)}}}_copyImageToTexture(e,t,i,r,s,n,a=0){let o=this.backend.device,l=a>0?e.width:i.size.width,h=a>0?e.height:i.size.height;try{o.queue.copyExternalImageToTexture({source:e,flipY:s},{texture:t,mipLevel:a,origin:{x:0,y:0,z:r},premultipliedAlpha:n},{width:l,height:h,depthOrArrayLayers:1})}catch{}}_getPassUtils(){let e=this._passUtils;return e===null&&(this._passUtils=e=new _W(this.backend.device)),e}_generateMipmaps(e,t=null){this._getPassUtils().generateMipmaps(e,t)}_flipY(e,t,i=0){this._getPassUtils().flipY(e,t,i)}_copyBufferToTexture(e,t,i,r,s,n=0,a=0){let o=this.backend.device,l=e.data,h=this._getBytesPerTexel(i.format),u=e.width*h;o.queue.writeTexture({texture:t,mipLevel:a,origin:{x:0,y:0,z:r}},l,{offset:e.width*e.height*h*n,bytesPerRow:u},{width:e.width,height:e.height,depthOrArrayLayers:1}),s===!0&&this._flipY(t,i,r)}_copyCompressedBufferToTexture(e,t,i){let r=this.backend.device,s=this._getBlockData(i.format),n=i.size.depthOrArrayLayers>1;for(let a=0;a<e.length;a++){let o=e[a],l=o.width,h=o.height,u=n?i.size.depthOrArrayLayers:1,d=Math.ceil(l/s.width)*s.byteLength,c=d*Math.ceil(h/s.height);for(let p=0;p<u;p++)r.queue.writeTexture({texture:t,mipLevel:a,origin:{x:0,y:0,z:p}},o.data,{offset:p*c,bytesPerRow:d,rowsPerImage:Math.ceil(h/s.height)},{width:Math.ceil(l/s.width)*s.width,height:Math.ceil(h/s.height)*s.height,depthOrArrayLayers:1})}}_getBlockData(e){if(e===P.BC1RGBAUnorm||e===P.BC1RGBAUnormSRGB)return{byteLength:8,width:4,height:4};if(e===P.BC2RGBAUnorm||e===P.BC2RGBAUnormSRGB||e===P.BC3RGBAUnorm||e===P.BC3RGBAUnormSRGB)return{byteLength:16,width:4,height:4};if(e===P.BC4RUnorm||e===P.BC4RSnorm)return{byteLength:8,width:4,height:4};if(e===P.BC5RGUnorm||e===P.BC5RGSnorm||e===P.BC6HRGBUFloat||e===P.BC6HRGBFloat||e===P.BC7RGBAUnorm||e===P.BC7RGBAUnormSRGB)return{byteLength:16,width:4,height:4};if(e===P.ETC2RGB8Unorm||e===P.ETC2RGB8UnormSRGB||e===P.ETC2RGB8A1Unorm||e===P.ETC2RGB8A1UnormSRGB)return{byteLength:8,width:4,height:4};if(e===P.ETC2RGBA8Unorm||e===P.ETC2RGBA8UnormSRGB)return{byteLength:16,width:4,height:4};if(e===P.EACR11Unorm||e===P.EACR11Snorm)return{byteLength:8,width:4,height:4};if(e===P.EACRG11Unorm||e===P.EACRG11Snorm||e===P.ASTC4x4Unorm||e===P.ASTC4x4UnormSRGB)return{byteLength:16,width:4,height:4};if(e===P.ASTC5x4Unorm||e===P.ASTC5x4UnormSRGB)return{byteLength:16,width:5,height:4};if(e===P.ASTC5x5Unorm||e===P.ASTC5x5UnormSRGB)return{byteLength:16,width:5,height:5};if(e===P.ASTC6x5Unorm||e===P.ASTC6x5UnormSRGB)return{byteLength:16,width:6,height:5};if(e===P.ASTC6x6Unorm||e===P.ASTC6x6UnormSRGB)return{byteLength:16,width:6,height:6};if(e===P.ASTC8x5Unorm||e===P.ASTC8x5UnormSRGB)return{byteLength:16,width:8,height:5};if(e===P.ASTC8x6Unorm||e===P.ASTC8x6UnormSRGB)return{byteLength:16,width:8,height:6};if(e===P.ASTC8x8Unorm||e===P.ASTC8x8UnormSRGB)return{byteLength:16,width:8,height:8};if(e===P.ASTC10x5Unorm||e===P.ASTC10x5UnormSRGB)return{byteLength:16,width:10,height:5};if(e===P.ASTC10x6Unorm||e===P.ASTC10x6UnormSRGB)return{byteLength:16,width:10,height:6};if(e===P.ASTC10x8Unorm||e===P.ASTC10x8UnormSRGB)return{byteLength:16,width:10,height:8};if(e===P.ASTC10x10Unorm||e===P.ASTC10x10UnormSRGB)return{byteLength:16,width:10,height:10};if(e===P.ASTC12x10Unorm||e===P.ASTC12x10UnormSRGB)return{byteLength:16,width:12,height:10};if(e===P.ASTC12x12Unorm||e===P.ASTC12x12UnormSRGB)return{byteLength:16,width:12,height:12}}_convertAddressMode(e){let t=E_.ClampToEdge;return e===1e3?t=E_.Repeat:e===1002&&(t=E_.MirrorRepeat),t}_convertFilterMode(e){let t=aa.Linear;return(e===1003||e===1004||e===1005)&&(t=aa.Nearest),t}_getBytesPerTexel(e){if(e===P.R8Unorm||e===P.R8Snorm||e===P.R8Uint||e===P.R8Sint)return 1;if(e===P.R16Uint||e===P.R16Sint||e===P.R16Float||e===P.RG8Unorm||e===P.RG8Snorm||e===P.RG8Uint||e===P.RG8Sint)return 2;if(e===P.R32Uint||e===P.R32Sint||e===P.R32Float||e===P.RG16Uint||e===P.RG16Sint||e===P.RG16Float||e===P.RGBA8Unorm||e===P.RGBA8UnormSRGB||e===P.RGBA8Snorm||e===P.RGBA8Uint||e===P.RGBA8Sint||e===P.BGRA8Unorm||e===P.BGRA8UnormSRGB||e===P.RGB9E5UFloat||e===P.RGB10A2Unorm||e===P.RG11B10UFloat||e===P.Depth32Float||e===P.Depth24Plus||e===P.Depth24PlusStencil8||e===P.Depth32FloatStencil8)return 4;if(e===P.RG32Uint||e===P.RG32Sint||e===P.RG32Float||e===P.RGBA16Uint||e===P.RGBA16Sint||e===P.RGBA16Float)return 8;if(e===P.RGBA32Uint||e===P.RGBA32Sint||e===P.RGBA32Float)return 16}_getTypedArrayType(e){if(e===P.R8Uint)return Uint8Array;
251if(e===P.R8Sint)return Int8Array;if(e===P.R8Unorm)return Uint8Array;if(e===P.R8Snorm)return Int8Array;if(e===P.RG8Uint)return Uint8Array;if(e===P.RG8Sint)return Int8Array;if(e===P.RG8Unorm)return Uint8Array;if(e===P.RG8Snorm)return Int8Array;if(e===P.RGBA8Uint)return Uint8Array;if(e===P.RGBA8Sint)return Int8Array;if(e===P.RGBA8Unorm||e===P.RGBA8UnormSRGB)return Uint8Array;if(e===P.RGBA8Snorm)return Int8Array;if(e===P.R16Uint)return Uint16Array;if(e===P.R16Sint)return Int16Array;if(e===P.RG16Uint)return Uint16Array;if(e===P.RG16Sint)return Int16Array;if(e===P.RGBA16Uint)return Uint16Array;if(e===P.RGBA16Sint)return Int16Array;if(e===P.R16Float||e===P.RG16Float||e===P.RGBA16Float)return Uint16Array;if(e===P.R32Uint)return Uint32Array;if(e===P.R32Sint)return Int32Array;if(e===P.R32Float)return Float32Array;if(e===P.RG32Uint)return Uint32Array;if(e===P.RG32Sint)return Int32Array;if(e===P.RG32Float)return Float32Array;if(e===P.RGBA32Uint)return Uint32Array;if(e===P.RGBA32Sint)return Int32Array;if(e===P.RGBA32Float)return Float32Array;if(e===P.BGRA8Unorm||e===P.BGRA8UnormSRGB)return Uint8Array;
251if(e===P.RGB10A2Unorm||e===P.RGB9E5UFloat||e===P.RG11B10UFloat)return Uint32Array;if(e===P.Depth32Float)return Float32Array;if(e===P.Depth24Plus||e===P.Depth24PlusStencil8)return Uint32Array;if(e===P.Depth32FloatStencil8)return Float32Array}_getDimension(e){let t;return t=e.is3DTexture||e.isData3DTexture?o3.ThreeD:o3.TwoD,t}};function L_(e,t=null){let i=e.format,r=e.type,s=e.colorSpace,n=lt.getTransfer(s),a;if(e.isCompressedTexture===!0||e.isCompressedArrayTexture===!0)switch(i){case b2:case _2:a=n==="srgb"?P.BC1RGBAUnormSRGB:P.BC1RGBAUnorm;break;case T2:a=n==="srgb"?P.BC2RGBAUnormSRGB:P.BC2RGBAUnorm;break;case w2:a=n==="srgb"?P.BC3RGBAUnormSRGB:P.BC3RGBAUnorm;break;case H2:a=P.BC4RUnorm;break;case q2:a=P.BC4RSnorm;break;case X2:a=P.BC5RGUnorm;break;case Y2:a=P.BC5RGSnorm;break;case W2:a=n==="srgb"?P.BC7RGBAUnormSRGB:P.BC7RGBAUnorm;break;case M2:case S2:a=n==="srgb"?P.ETC2RGB8UnormSRGB:P.ETC2RGB8Unorm;break;case C2:a=n==="srgb"?P.ETC2RGBA8UnormSRGB:P.ETC2RGBA8Unorm;break;case R2:a=P.EACR11Unorm;break;case E2:a=P.EACR11Snorm;break;case A2:a=P.EACRG11Unorm;break;case N2:a=P.EACRG11Snorm;break;case L2:a=n==="srgb"?P.ASTC4x4UnormSRGB:P.ASTC4x4Unorm;break;case P2:a=n==="srgb"?P.ASTC5x4UnormSRGB:P.ASTC5x4Unorm;break;case k2:a=n==="srgb"?P.ASTC5x5UnormSRGB:P.ASTC5x5Unorm;break;case I2:a=n==="srgb"?P.ASTC6x5UnormSRGB:P.ASTC6x5Unorm;break;case F2:a=n==="srgb"?P.ASTC6x6UnormSRGB:P.ASTC6x6Unorm;break;case D2:a=n==="srgb"?P.ASTC8x5UnormSRGB:P.ASTC8x5Unorm;break;case O2:a=n==="srgb"?P.ASTC8x6UnormSRGB:P.ASTC8x6Unorm;break;case B2:a=n==="srgb"?P.ASTC8x8UnormSRGB:P.ASTC8x8Unorm;break;case U2:a=n==="srgb"?P.ASTC10x5UnormSRGB:P.ASTC10x5Unorm;break;case V2:a=n==="srgb"?P.ASTC10x6UnormSRGB:P.ASTC10x6Unorm;break;case z2:a=n==="srgb"?P.ASTC10x8UnormSRGB:P.ASTC10x8Unorm;break;case G2:a=n==="srgb"?P.ASTC10x10UnormSRGB:P.ASTC10x10Unorm;break;case j2:a=n==="srgb"?P.ASTC12x10UnormSRGB:P.ASTC12x10Unorm;break;case $2:a=n==="srgb"?P.ASTC12x12UnormSRGB:P.ASTC12x12Unorm;break;case Br:a=n==="srgb"?P.RGBA8UnormSRGB:P.RGBA8Unorm;break;default:re("WebGPURenderer: Unsupported texture format.",i)}else switch(i){case Br:switch(r){case Nc:a=P.RGBA8Snorm;break;case Lc:a=P.RGBA16Sint;break;case ku:a=P.RGBA16Uint;break;case ur:a=P.RGBA32Uint;break;case Do:a=P.RGBA32Sint;break;case hr:a=n==="srgb"?P.RGBA8UnormSRGB:P.RGBA8Unorm;break;case as:a=P.RGBA16Float;break;case Pn:a=P.RGBA32Float;break;default:re("WebGPURenderer: Unsupported texture type with RGBAFormat.",r)}break;case j1:switch(r){case x2:a=P.RGB9E5UFloat;break;case v2:a=P.RG11B10UFloat;break;default:re("WebGPURenderer: Unsupported texture type with RGBFormat.",r)}break;case _g:switch(r){case Nc:a=P.R8Snorm;break;case Lc:a=P.R16Sint;break;case ku:a=P.R16Uint;break;case ur:a=P.R32Uint;break;case Do:a=P.R32Sint;break;case hr:a=P.R8Unorm;break;case as:a=P.R16Float;break;case Pn:a=P.R32Float;break;default:re("WebGPURenderer: Unsupported texture type with RedFormat.",r)}break;case Oo:switch(r){case Nc:a=P.RG8Snorm;break;case Lc:a=P.RG16Sint;break;case ku:a=P.RG16Uint;break;case ur:a=P.RG32Uint;break;case Do:a=P.RG32Sint;break;case hr:a=P.RG8Unorm;break;case as:a=P.RG16Float;break;case Pn:a=P.RG32Float;break;default:re("WebGPURenderer: Unsupported texture type with RGFormat.",r)}break;case Da:switch(r){case ku:a=P.Depth16Unorm;break;case ur:a=P.Depth24Plus;break;case Pn:a=P.Depth32Float;break;default:re("WebGPURenderer: Unsupported texture type with DepthFormat.",r)}break;case uh:switch(r){case hh:a=P.Depth24PlusStencil8;break;case Pn:t&&t.features.has(N_.Depth32FloatStencil8)===!1&&re('WebGPURenderer: Depth textures with DepthStencilFormat + FloatType can only be used with the "depth32float-stencil8" GPU feature.'),a=P.Depth32FloatStencil8;break;default:re("WebGPURenderer: Unsupported texture type with DepthStencilFormat.",r)}break;case $1:switch(r){case Do:a=P.R32Sint;break;case ur:a=P.R32Uint;break;default:re("WebGPURenderer: Unsupported texture type with RedIntegerFormat.",r)}break;case W1:switch(r){case Do:a=P.RG32Sint;break;case ur:a=P.RG32Uint;break;default:re("WebGPURenderer: Unsupported texture type with RGIntegerFormat.",r)}break;case H1:switch(r){case Do:a=P.RGBA32Sint;break;case ur:a=P.RGBA32Uint;break;default:re("WebGPURenderer: Unsupported texture type with RGBAIntegerFormat.",r)}break;default:re("WebGPURenderer: Unsupported texture format.",i)}return a}var MW=/^[fn]*\s*([a-z_0-9]+)?\s*\(([\s\S]*?)\)\s*[\-\>]*\s*([a-z_0-9]+(?:<[\s\S]+?>)?)/i,CW=/([a-z_0-9]+)\s*:\s*([a-z_0-9]+(?:<[\s\S]+?>)?)/gi,h3={f32:"float",i32:"int",u32:"uint",bool:"bool","vec2<f32>":"vec2","vec2<i32>":"ivec2","vec2<u32>":"uvec2","vec2<bool>":"bvec2",vec2f:"vec2",vec2i:"ivec2",vec2u:"uvec2",vec2b:"bvec2","vec3<f32>":"vec3","vec3<i32>":"ivec3","vec3<u32>":"uvec3","vec3<bool>":"bvec3",vec3f:"vec3",vec3i:"ivec3",vec3u:"uvec3",vec3b:"bvec3","vec4<f32>":"vec4","vec4<i32>":"ivec4","vec4<u32>":"uvec4","vec4<bool>":"bvec4",vec4f:"vec4",vec4i:"ivec4",vec4u:"uvec4",vec4b:"bvec4","mat2x2<f32>":"mat2",mat2x2f:"mat2","mat3x3<f32>":"mat3",mat3x3f:"mat3","mat4x4<f32>
251":"mat4",mat4x4f:"mat4",sampler:"sampler",texture_1d:"texture",texture_2d:"texture",texture_2d_array:"texture",texture_multisampled_2d:"cubeTexture",texture_depth_2d:"depthTexture",texture_depth_2d_array:"depthTexture",texture_depth_multisampled_2d:"depthTexture",texture_depth_cube:"depthTexture",texture_depth_cube_array:"depthTexture",texture_3d:"texture3D",texture_cube:"cubeTexture",texture_cube_array:"cubeTexture",texture_storage_1d:"storageTexture",texture_storage_2d:"storageTexture",texture_storage_2d_array:"storageTexture",texture_storage_3d:"storageTexture"},RW=e=>{e=e.trim();let t=e.match(MW);if(t!==null&&t.length===4){let i=t[2],r=[],s=null;for(;(s=CW.exec(i))!==null;)r.push({name:s[1],type:s[2]});let n=[];for(let h=0;h<r.length;h++){let{name:u,type:d}=r[h],c=d;c.startsWith("ptr")?c="pointer":(c.startsWith("texture")&&(c=d.split("<")[0]),c=h3[c]),n.push(new y_(c,u))}let a=e.substring(t[0].length),o=t[3]||"void",l=t[1]===void 0?"":t[1];return{type:h3[o]||o,inputs:n,name:l,inputsCode:i,blockCode:a,outputType:o}}else throw Error("FunctionNode: Function is not a WGSL code.")},EW=class extends b_{constructor(e){let{type:t,inputs:i,name:r,inputsCode:s,blockCode:n,outputType:a}=RW(e);super(t,i,r),this.inputsCode=s,this.blockCode=n,this.outputType=a}getCode(e=this.name){let t=this.outputType==="void"?"":"-> "+this.outputType;return`fn ${e} ( ${this.inputsCode.trim()} ) ${t}`+this.blockCode}},AW=class extends CL{parseFunction(e){return new EW(e)}},NW={[pr.READ_ONLY]:"read",[pr.WRITE_ONLY]:"write",[pr.READ_WRITE]:"read_write"},u3={[Or]:"repeat",[Fa]:"clamp",[vg]:"mirror"},P_={vertex:na.VERTEX,fragment:na.FRAGMENT,compute:na.COMPUTE},d3={instance:!0,swizzleAssign:!1,storageBuffer:!0},LW={"^^":"tsl_xor"},PW={float:"f32",int:"i32",uint:"u32",bool:"bool",color:"vec3<f32>",vec2:"vec2<f32>",ivec2:"vec2<i32>",uvec2:"vec2<u32>",bvec2:"vec2<bool>",vec3:"vec3<f32>",ivec3:"vec3<i32>",uvec3:"vec3<u32>",bvec3:"vec3<bool>",vec4:"vec4<f32>",ivec4:"vec4<i32>",uvec4:"vec4<u32>",bvec4:"vec4<bool>",mat2:"mat2x2<f32>",mat3:"mat3x3<f32>",mat4:"mat4x4<f32>"},c3={},Op={tsl_xor:new Wi("fn tsl_xor( a : bool, b : bool ) -> bool { return ( a || b ) && !( a && b ); }"),mod_float:new Wi("fn tsl_mod_float( x : f32, y : f32 ) -> f32 { return x - y * floor( x / y ); }"),mod_vec2:new Wi("fn tsl_mod_vec2( x : vec2f, y : vec2f ) -> vec2f { return x - y * floor( x / y ); }"),mod_vec3:new Wi("fn tsl_mod_vec3( x : vec3f, y : vec3f ) -> vec3f { return x - y * floor( x / y ); }"),mod_vec4:new Wi("fn tsl_mod_vec4( x : vec4f, y : vec4f ) -> vec4f { return x - y * floor( x / y ); }"),equals_bool:new Wi("fn tsl_equals_bool( a : bool, b : bool ) -> bool { return a == b; }"),equals_bvec2:new Wi("fn tsl_equals_bvec2( a : vec2f, b : vec2f ) -> vec2<bool> { return vec2<bool>( a.x == b.x, a.y == b.y ); }"),equals_bvec3:new Wi("fn tsl_equals_bvec3( a : vec3f, b : vec3f ) -> vec3<bool> { return vec3<bool>( a.x == b.x, a.y == b.y, a.z == b.z ); }"),equals_bvec4:new Wi("fn tsl_equals_bvec4( a : vec4f, b : vec4f ) -> vec4<bool> { return vec4<bool>( a.x == b.x, a.y == b.y, a.z == b.z, a.w == b.w ); }"),repeatWrapping_float:new Wi("fn tsl_repeatWrapping_float( coord: f32 ) -> f32 { return fract( coord ); }"),mirrorWrapping_float:new Wi("fn tsl_mirrorWrapping_float( coord: f32 ) -> f32 { let mirrored = fract( coord * 0.5 ) * 2.0; return 1.0 - abs( 1.0 - mirrored ); }"),clampWrapping_float:new Wi("fn tsl_clampWrapping_float( coord: f32 ) -> f32 { return clamp( coord, 0.0, 1.0 ); }"),biquadraticTexture:new Wi(`
252fn tsl_biquadraticTexture( map : texture_2d<f32>, coord : vec2f, iRes : vec2u, level : u32 ) -> vec4f {
253
254	let res = vec2f( iRes );
255
256	let uvScaled = coord * res;
257	let uvWrapping = ( ( uvScaled % res ) + res ) % res;
258
259	// https://www.shadertoy.com/view/WtyXRy
260
261	let uv = uvWrapping - 0.5;
262	let iuv = floor( uv );
263	let f = fract( uv );
264
265	let rg1 = textureLoad( map, vec2u( iuv + vec2( 0.5, 0.5 ) ) % iRes, level );
266	let rg2 = textureLoad( map, vec2u( iuv + vec2( 1.5, 0.5 ) ) % iRes, level );
267	let rg3 = textureLoad( map, vec2u( iuv + vec2( 0.5, 1.5 ) ) % iRes, level );
268	let rg4 = textureLoad( map, vec2u( iuv + vec2( 1.5, 1.5 ) ) % iRes, level );
269
270	return mix( mix( rg1, rg2, f.x ), mix( rg3, rg4, f.x ), f.y );
271
272}
273`),biquadraticTextureArray:new Wi(`
274fn tsl_biquadraticTexture_array( map : texture_2d_array<f32>, coord : vec2f, iRes : vec2u, layer : u32, level : u32 ) -> vec4f {
275
276	let res = vec2f( iRes );
277
278	let uvScaled = coord * res;
279	let uvWrapping = ( ( uvScaled % res ) + res ) % res;
280
281	// https://www.shadertoy.com/view/WtyXRy
282
283	let uv = uvWrapping - 0.5;
284	let iuv = floor( uv );
285	let f = fract( uv );
286
287	let rg1 = textureLoad( map, vec2u( iuv + vec2( 0.5, 0.5 ) ) % iRes, layer, level );
288	let rg2 = textureLoad( map, vec2u( iuv + vec2( 1.5, 0.5 ) ) % iRes, layer, level );
289	let rg3 = textureLoad( map, vec2u( iuv + vec2( 0.5, 1.5 ) ) % iRes, layer, level );
290	let rg4 = textureLoad( map, vec2u( iuv + vec2( 1.5, 1.5 ) ) % iRes, layer, level );
291
292	return mix( mix( rg1, rg2, f.x ), mix( rg3, rg4, f.x ), f.y );
293
294}
295`)},kW={dFdx:"dpdx",dFdy:"- dpdy",mod_float:"tsl_mod_float",mod_vec2:"tsl_mod_vec2",mod_vec3:"tsl_mod_vec3",mod_vec4:"tsl_mod_vec4",equals_bool:"tsl_equals_bool",equals_bvec2:"tsl_equals_bvec2",equals_bvec3:"tsl_equals_bvec3",equals_bvec4:"tsl_equals_bvec4",inversesqrt:"inverseSqrt",bitcast:"bitcast<f32>",floatpack_snorm_2x16:"pack2x16snorm",floatpack_unorm_2x16:"pack2x16unorm",floatpack_float16_2x16:"pack2x16float",floatunpack_snorm_2x16:"unpack2x16snorm",floatunpack_unorm_2x16:"unpack2x16unorm",floatunpack_float16_2x16:"unpack2x16float"},p3="";(typeof navigator<"u"&&/Firefox|Deno/g.test(navigator.userAgent))!==!0&&(p3+=`diagnostic( off, derivative_uniformity );
296`);var IW=class extends SL{constructor(e,t){super(e,t,new AW),this.uniformGroups={},this.uniformGroupsBindings={},this.builtins={},this.directives={},this.scopedArrays=new Map}_generateTextureSample(e,t,i,r,s,n=this.shaderStage){return n==="fragment"?r?s?`textureSample( ${t}, ${t}_sampler, ${i}, ${r}, ${s} )`:`textureSample( ${t}, ${t}_sampler, ${i}, ${r} )`:s?`textureSample( ${t}, ${t}_sampler, ${i}, ${s} )`:`textureSample( ${t}, ${t}_sampler, ${i} )`:this.generateTextureSampleLevel(e,t,i,"0",r)}generateTextureSampleLevel(e,t,i,r,s,n){return this.isUnfilterable(e)===!1?s?n?`textureSampleLevel( ${t}, ${t}_sampler, ${i}, ${s}, ${r}, ${n} )`:`textureSampleLevel( ${t}, ${t}_sampler, ${i}, ${s}, ${r} )`:n?`textureSampleLevel( ${t}, ${t}_sampler, ${i}, ${r}, ${n} )`:`textureSampleLevel( ${t}, ${t}_sampler, ${i}, ${r} )`:this.isFilteredTexture(e)?this.generateFilteredTexture(e,t,i,n,r,s):this.generateTextureLod(e,t,i,s,n,r)}generateWrapFunction(e){let t=`tsl_coord_${u3[e.wrapS]}S_${u3[e.wrapT]}_${e.is3DTexture||e.isData3DTexture?"3d":"2d"}T`,i=c3[t];if(i===void 0){let r=[],s=e.is3DTexture||e.isData3DTexture?"vec3f":"vec2f",n=`fn ${t}( coord : ${s} ) -> ${s} {
297
298	return ${s}(
299`,a=(o,l)=>{o===1e3?(r.push(Op.repeatWrapping_float),n+=`		tsl_repeatWrapping_float( coord.${l}
299 )`):o===1001?(r.push(Op.clampWrapping_float),n+=`		tsl_clampWrapping_float( coord.${l} )`):o===1002?(r.push(Op.mirrorWrapping_float),n+=`		tsl_mirrorWrapping_float( coord.${l} )`):(n+=`		coord.${l}`,de(`WebGPURenderer: Unsupported texture wrap type "${o}" for vertex shader.`))};a(e.wrapS,"x"),n+=`,
300`,a(e.wrapT,"y"),(e.is3DTexture||e.isData3DTexture)&&(n+=`,
301`,a(e.wrapR,"z")),n+=`
302	);
303
304}
305`,c3[t]=i=new Wi(n,r)}return i.build(this),t}generateArrayDeclaration(e,t){return`array< ${this.getType(e)}, ${t} >`}generateTextureDimension(e,t,i){let r=this.getDataFromNode(e,this.shaderStage,this.globalCache);r.dimensionsSnippet===void 0&&(r.dimensionsSnippet={});let s=r.dimensionsSnippet[i];if(r.dimensionsSnippet[i]===void 0){let n,a,{primarySamples:o}=this.renderer.backend.utils.getTextureSampleData(e),l=o>1;a=e.is3DTexture||e.isData3DTexture?"vec3<u32>":"vec2<u32>",n=l||e.isStorageTexture?t:`${t}${i?`, u32( ${i} )`:""}`,s=new Cf(new Nf(`textureDimensions( ${n} )`,a)),r.dimensionsSnippet[i]=s,(e.isArrayTexture||e.isDataArrayTexture||e.is3DTexture||e.isData3DTexture)&&(r.arrayLayerCount=new Cf(new Nf(`textureNumLayers(${t})`,"u32"))),e.isTextureCube&&(r.cubeFaceCount=new Cf(new Nf("6u","u32")))}return s.build(this)}generateFilteredTexture(e,t,i,r,s="0u",n){let a=this.generateWrapFunction(e),o=this.generateTextureDimension(e,t,s);return r&&(i=`${i} + vec2<f32>(${r}) / ${o}`),n?(this._include("biquadraticTextureArray"),`tsl_biquadraticTexture_array( ${t}, ${a}( ${i} ), ${o}, u32( ${n} ), u32( ${s} ) )`):(this._include("biquadraticTexture"),`tsl_biquadraticTexture( ${t}, ${a}( ${i} ), ${o}, u32( ${s} ) )`)}generateTextureLod(e,t,i,r,s,n="0u"){if(e.isCubeTexture===!0){s&&(i=`${i} + vec3<f32>(${s})`);let c=e.isDepthTexture?"u32":"f32";return`textureSampleLevel( ${t}, ${t}_sampler, ${i}, ${c}( ${n} ) )`}let a=this.generateWrapFunction(e),o=this.generateTextureDimension(e,t,n),l=e.is3DTexture||e.isData3DTexture?"vec3":"vec2",h=l==="vec3"?"vec3<u32>( 1, 1, 1 )":"vec2<u32>( 1, 1 )";s&&(i=`${i} + ${l}<f32>(${s}) / ${l}<f32>( ${o} )`);let u=`${l}<f32>( 0 )`,d=`${l}<f32>( ${o} - ${h} )`;return i=`${l}<u32>( clamp( floor( ${a}( ${i} ) * ${l}<f32>( ${o} ) ), ${u}, ${d} ) )`,this.generateTextureLoad(e,t,i,n,r,null)}generateStorageTextureLoad(e,t,i,r,s,n){n&&(i=`${i} + ${n}`);let a;return a=s?`textureLoad( ${t}, ${i}, ${s} )`:`textureLoad( ${t}, ${i} )`,a}generateTextureLoad(e,t,i,r,s,n){r===null&&(r="0u"),n&&(i=`${i} + ${n}`);let a;return s?a=`textureLoad( ${t}, ${i}, ${s}, u32( ${r} ) )`:(a=`textureLoad( ${t}, ${i}, u32( ${r} ) )`,this.renderer.backend.compatibilityMode&&e.isDepthTexture&&(a+=".x")),a}generateTextureStore(e,t,i,r,s){let n;return n=r?`textureStore( ${t}, ${i}, ${r}, ${s} )`:`textureStore( ${t}, ${i}, ${s} )`,n}isSampleCompare(e){return e.isDepthTexture===!0&&e.compareFunction!==null&&this.renderer.hasCompatibility(ph.TEXTURE_COMPARE)}isUnfilterable(e){return this.getComponentTypeFromTexture(e)!=="float"||!this.isAvailable("float32Filterable")&&e.type===1015||this.isSampleCompare(e)===!1&&e.minFilter===1003&&e.magFilter===1003||this.renderer.backend.utils.getTextureSampleData(e).primarySamples>1}generateTexture(e,t,i,r,s,n=this.shaderStage){let a=null;return a=this.isUnfilterable(e)?this.generateTextureLod(e,t,i,r,s,"0",n):this._generateTextureSample(e,t,i,r,s,n),a}generateTextureGrad(e,t,i,r,s,n,a=this.shaderStage){if(a==="fragment")return s?n?`textureSampleGrad( ${t}, ${t}_sampler, ${i}, ${s}, ${r[0]}, ${r[1]}, ${n} )`:`textureSampleGrad( ${t}, ${t}_sampler, ${i}, ${s}, ${r[0]}, ${r[1]} )`:n?`textureSampleGrad( ${t}, ${t}_sampler, ${i}, ${r[0]}, ${r[1]}, ${n} )`:`textureSampleGrad( ${t}, ${t}_sampler, ${i}, ${r[0]}, ${r[1]} )`;re(`WebGPURenderer: THREE.TextureNode.gradient() does not support ${a} shader.`)}generateTextureCompare(e,t,i,r,s,n,a=this.shaderStage){if(a==="fragment")return e.isDepthTexture===!0&&e.isArrayTexture===!0?n?`textureSampleCompare( ${t}, ${t}_sampler, ${i}, ${s}, ${r}, ${n} )`:`textureSampleCompare( ${t}, ${t}_sampler, ${i}, ${s}, ${r} )`:n?`textureSampleCompare( ${t}, ${t}_sampler, ${i}, ${r}, ${n} )`:`textureSampleCompare( ${t}, ${t}_sampler, ${i}, ${r} )`;re(`WebGPURenderer: THREE.DepthTexture.compareFunction() does not support ${a} shader.`)}generateTextureLevel(e,t,i,r,s,n){return this.isUnfilterable(e)===!1?s?n?`textureSampleLevel( ${t}, ${t}_sampler, ${i}, ${s}, ${r}, ${n} )`:`textureSampleLevel( ${t}, ${t}_sampler, ${i}, ${s}, ${r} )`:n?`textureSampleLevel( ${t}, ${t}_sampler, ${i}, ${r}, ${n} )`:`textureSampleLevel( ${t}, ${t}_sampler, ${i}, ${r} )`:this.isFilteredTexture(e)?this.generateFilteredTexture(e,t,i,n,r,s):this.generateTextureLod(e,t,i,s,n,r)}generateTextureBias(e,t,i,r,s,n,a=this.shaderStage){if(a==="fragment")return s?n?`textureSampleBias( ${t}, ${t}_sampler, ${i}, ${s}, ${r}, ${n} )`:`textureSampleBias( ${t}, ${t}_sampler, ${i}, ${s}, ${r} )`:n?`textureSampleBias( ${t}, ${t}_sampler, ${i}, ${r}, ${n} )`:`textureSampleBias( ${t}, ${t}_sampler, ${i}, ${r} )`;re(`WebGPURenderer: THREE.TextureNode.biasNode does not support ${a} shader.`)}getPropertyName(e,t=this.shaderStage){if(e.isNodeVarying===!0&&e.needsInterpolation===!0){if(t==="vertex")return`varyings.${e.name}`}else if(e.isNodeUniform===!0){let i=e.name,r=e.type;return r==="texture"||r==="cubeTexture"||r==="cubeDepthTexture"||r==="storageTexture"||r==="texture3D"?i:r==="buffer"||r==="storageBuffer"||r==="indirectStorageBuffer"?this.isCu
305stomStruct(e)?i:i+".value":e.groupNode.name+"."+i}return super.getPropertyName(e)}getOutputStructName(){return"output"}getFunctionOperator(e){let t=LW[e];return t===void 0?null:(this._include(t),t)}getNodeAccess(e,t){return t==="compute"?e.access:e.isAtomic===!0?(de("WebGPURenderer: Atomic operations are only supported in compute shaders."),pr.READ_WRITE):pr.READ_ONLY}getStorageAccess(e,t){return NW[this.getNodeAccess(e,t)]}getUniformFromNode(e,t,i,r=null){let s=super.getUniformFromNode(e,t,i,r),n=this.getDataFromNode(e,i,this.globalCache);if(n.uniformGPU===void 0){let a,o=e.groupNode,l=o.name,h=this.getBindGroupArray(l,i);if(t==="texture"||t==="cubeTexture"||t==="cubeDepthTexture"||t==="storageTexture"||t==="texture3D"){let u=null,d=this.getNodeAccess(e,i);if(t==="texture"||t==="storageTexture"?u=e.value.is3DTexture===!0?new M_(s.name,s.node,o,d):new A0(s.name,s.node,o,d):t==="cubeTexture"||t==="cubeDepthTexture"?u=new jL(s.name,s.node,o,d):t==="texture3D"&&(u=new M_(s.name,s.node,o,d)),u.store=e.isStorageTextureNode===!0,u.mipLevel=u.store?e.mipLevel:0,u.setVisibility(P_[i]),e.value.isCubeTexture===!0||this.isUnfilterable(e.value)===!1&&u.store===!1){let c=new yW(`${s.name}_sampler`,s.node,o);c.setVisibility(P_[i]),h.push(c,u),a=[c,u]}else h.push(u),a=[u]}else if(t==="buffer"||t==="storageBuffer"||t==="indirectStorageBuffer"){let u=this.getSharedDataFromNode(e),d=u.buffer;d===void 0&&(d=new(t==="buffer"?VL:bW)(e,o),u.buffer=d),d.setVisibility(d.getVisibility()|P_[i]),h.push(d),a=d,s.name=r||"NodeBuffer_"+s.id}else{let u=this.uniformGroups[l];u===void 0&&(u=new zL(l,o),u.setVisibility(na.VERTEX|na.FRAGMENT|na.COMPUTE),this.uniformGroups[l]=u),h.indexOf(u)===-1&&h.push(u),a=this.getNodeUniform(s,t);let d=a.name;u.uniforms.some(c=>c.name===d)||u.addUniform(a)}n.uniformGPU=a}return s}getBuiltin(e,t,i,r=this.shaderStage){let s=this.builtins[r]||(this.builtins[r]=new Map);return s.has(e)===!1&&s.set(e,{name:e,property:t,type:i}),t}hasBuiltin(e,t=this.shaderStage){return this.builtins[t]!==void 0&&this.builtins[t].has(e)}getVertexIndex(){return this.shaderStage==="vertex"?this.getBuiltin("vertex_index","vertexIndex","u32","attribute"):"vertexIndex"}buildFunctionCode(e){let t=e.layout,i=this.flowShaderNode(e),r=[];for(let n of t.inputs)r.push(n.name+" : "+this.getType(n.type));let s=`fn ${t.name}( ${r.join(", ")} ) -> ${this.getType(t.type)} {
306${i.vars}
307${i.code}
308`;return i.result&&(s+=`	return ${i.result};
309`),s+=`
310}
311`,s}getInstanceIndex(){return this.shaderStage==="vertex"?this.getBuiltin("instance_index","instanceIndex","u32","attribute"):"instanceIndex"}getInvocationLocalIndex(){return this.getBuiltin("local_invocation_index","invocationLocalIndex","u32","attribute")}getSubgroupSize(){return this.enableSubGroups(),this.getBuiltin("subgroup_size","subgroupSize","u32","attribute")}getInvocationSubgroupIndex(){return this.enableSubGroups(),this.getBuiltin("subgroup_invocation_id","invocationSubgroupIndex","u32","attribute")}getSubgroupIndex(){return this.enableSubGroups(),this.getBuiltin("subgroup_id","subgroupIndex","u32","attribute")}getDrawIndex(){return null}getFrontFacing(){return this.getBuiltin("front_facing","isFront","bool")}getFragCoord(){return this.getBuiltin("position","fragCoord","vec4<f32>")+".xy"}getFragDepth(){return"output."+this.getBuiltin("frag_depth","depth","f32","output")}getClipDistance(){return"varyings.hw_clip_distances"}isFlipY(){return!1}enableDirective(e,t=this.shaderStage){(this.directives[t]||(this.directives[t]=new Set)).add(e)}getDirectives(e){let t=[],i=this.directives[e];if(i!==void 0)for(let r of i)t.push(`enable ${r};`);return t.join(`
312`)}enableSubGroups(){this.enableDirective("subgroups")}enableSubgroupsF16(){this.enableDirective("subgroups-f16")}enableClipDistances(){this.enableDirective("clip_distances")}enableShaderF16(){this.enableDirective("f16")}enableDualSourceBlending(){this.enableDirective("dual_source_blending")}enableHardwareClipping(e){this.enableClipDistances(),this.getBuiltin("clip_distances","hw_clip_distances",`array<f32, ${e} >`,"vertex")}getBuiltins(e){let t=[],i=this.builtins[e];if(i!==void 0)for(let{name:r,property:s,type:n}of i.values())t.push(`@builtin( ${r} ) ${s} : ${n}`);return t.join(`,
313	`)}getScopedArray(e,t,i,r){return this.scopedArrays.has(e)===!1&&this.scopedArrays.set(e,{name:e,scope:t,bufferType:i,bufferCount:r}),e}getScopedArrays(e){if(e!=="compute")return;let t=[];for(let{name:i,scope:r,bufferType:s,bufferCount:n}of this.scopedArrays.values()){let a=this.getType(s);t.push(`var<${r}> ${i}: array< ${a}, ${n} >;`)}return t.join(`
314`)}getAttributes(e){let t=[];if(e==="compute"&&(this.getBuiltin("global_invocation_id","globalId","vec3<u32>","attribute"),this.getBuiltin("workgroup_id","workgroupId","vec3<u32>","attribute"),this.getBuiltin("local_invocation_id","localId","vec3<u32>","attribute"),this.getBuiltin("num_workgroups","numWorkgroups","vec3<u32>","attribute"),this.renderer.hasFeature("subgroups")&&(this.enableDirective("subgroups",e),this.getBuiltin("subgroup_size","subgroupSize","u32","attribute"))),e==="vertex"||e==="compute"){let i=this.getBuiltins("attribute");
314i&&t.push(i);let r=this.getAttributesArray();for(let s=0,n=r.length;s<n;s++){let a=r[s],o=a.name,l=this.getType(a.type);t.push(`@location( ${s} ) ${o} : ${l}`)}}return t.join(`,
315	`)}getStructMembers(e){let t=[];for(let i of e.members){let r=e.output?"@location( "+i.index+" ) ":"",s=this.getType(i.type);i.atomic&&(s="atomic< "+s+" >"),t.push(`	${r+i.name} : ${s}`)}return e.output&&t.push(`	${this.getBuiltins("output")}`),t.join(`,
316`)}getStructs(e){let t="",i=this.structs[e];if(i.length>0){let r=[];for(let s of i){let n=`struct ${s.name} {
317`;n+=this.getStructMembers(s),n+=`
318};`,r.push(n)}t=`
319`+r.join(`
320
321`)+`
322`}return t}getVar(e,t,i=null){let r=`var ${t} : `;return i===null?r+=this.getType(e):r+=this.generateArrayDeclaration(e,i),r}getVars(e){let t=[],i=this.vars[e];if(i!==void 0)for(let r of i)t.push(`	${this.getVar(r.type,r.name,r.count)};`);return`
323${t.join(`
324`)}
325`}getVaryings(e){let t=[];if(e==="vertex"&&this.getBuiltin("position","builtinClipSpace","vec4<f32>","vertex"),e==="vertex"||e==="fragment"){let s=this.varyings,n=this.vars[e];for(let a=0;a<s.length;a++){let o=s[a];if(o.needsInterpolation){let l=`@location( ${a} )`;if(o.interpolationType){let h=o.interpolationSampling===null?" )":`, ${o.interpolationSampling} )`;l+=` @interpolate( ${o.interpolationType}${h}`}else/^(int|uint|ivec|uvec)/.test(o.type)&&(l+=" @interpolate(flat, either)");t.push(`${l} ${o.name} : ${this.getType(o.type)}`)}else e==="vertex"&&n.includes(o)===!1&&n.push(o)}}let i=this.getBuiltins(e);i&&t.push(i);let r=t.join(`,
326	`);return e==="vertex"?this._getWGSLStruct("VaryingsStruct","	"+r):r}isCustomStruct(e){let t=e.value,i=e.node,r=(t.isBufferAttribute||t.isInstancedBufferAttribute)&&i.structTypeNode!==null,s=i.value&&i.value.array&&typeof i.value.itemSize=="number"&&i.value.array.length>i.value.itemSize;return r&&!s}getUniforms(e){let t=this.uniforms[e],i=[],r=[],s=[],n={};for(let a of t){let o=a.groupNode.name,l=this.bindingsIndexes[o];if(a.type==="texture"||a.type==="cubeTexture"||a.type==="cubeDepthTexture"||a.type==="storageTexture"||a.type==="texture3D"){let h=a.node.value;(h.isCubeTexture===!0||this.isUnfilterable(h)===!1&&a.node.isStorageTextureNode!==!0)&&(this.isSampleCompare(h)?i.push(`@binding( ${l.binding++} ) @group( ${l.group} ) var ${a.name}_sampler : sampler_comparison;`):i.push(`@binding( ${l.binding++} ) @group( ${l.group} ) var ${a.name}_sampler : sampler;`));let u,d="",{primarySamples:c}=this.renderer.backend.utils.getTextureSampleData(h);if(c>1&&(d="_multisampled"),h.isCubeTexture===!0&&h.isDepthTexture===!0)u="texture_depth_cube";else if(h.isCubeTexture===!0)u="texture_cube<f32>";else if(h.isDepthTexture===!0)u=this.renderer.backend.compatibilityMode&&h.compareFunction===null?`texture${d}_2d<f32>`:`texture_depth${d}_2d${h.isArrayTexture===!0?"_array":""}`;else if(a.node.isStorageTextureNode===!0){let p=L_(h),m=this.getStorageAccess(a.node,e),g=a.node.value.is3DTexture,f=a.node.value.isArrayTexture;u=`texture_storage_${g?"3d":`2d${f?"_array":""}`}<${p}, ${m}>`}else if(h.isArrayTexture===!0||h.isDataArrayTexture===!0||h.isCompressedArrayTexture===!0)u="texture_2d_array<f32>";else if(h.is3DTexture===!0||h.isData3DTexture===!0)u="texture_3d<f32>";else{let p=this.getComponentTypeFromTexture(h).charAt(0);u=`texture${d}_2d<${p}32>`}i.push(`@binding( ${l.binding++} ) @group( ${l.group} ) var ${a.name} : ${u};`)}else if(a.type==="buffer"||a.type==="storageBuffer"||a.type==="indirectStorageBuffer"){let h=a.node,u=this.getType(h.getNodeType(this)),d=h.bufferCount,c=d>0&&a.type==="buffer"?", "+d:"",p=h.isStorageBufferNode?`storage, ${this.getStorageAccess(h,e)}`:"uniform";if(this.isCustomStruct(a))r.push(`@binding( ${l.binding++} ) @group( ${l.group} ) var<${p}> ${a.name} : ${u};`);else{let m=`	value : array< ${h.isAtomic?`atomic<${u}>`:`${u}`}${c} >`;r.push(this._getWGSLStructBinding(a.name,m,p,l.binding++,l.group))}}else{let h=a.groupNode.name;if(n[h]===void 0){let u=this.uniformGroups[h];if(u!==void 0){let d=[];for(let p of u.uniforms){let m=p.getType(),g=this.getType(this.getVectorType(m));d.push(`	${p.name} : ${g}`)}let c=this.uniformGroupsBindings[h];c===void 0&&(c={index:l.binding++,id:l.group},this.uniformGroupsBindings[h]=c),n[h]={index:c.index,id:c.id,snippets:d}}}}}for(let a in n){let o=n[a];s.push(this._getWGSLStructBinding(a,o.snippets.join(`,
327`),"uniform",o.index,o.id))}return[...i,...r,...s].join(`
328`)}buildCode(){let e=this.material===null?{compute:{}}:{fragment:{},vertex:{}};this.sortBindingGroups();for(let t in e){this.shaderStage=t;let i=e[t];i.uniforms=this.getUniforms(t),i.attributes=this.getAttributes(t),i.varyings=this.getVaryings(t),i.structs=this.getStructs(t),i.vars=this.getVars(t),i.codes=this.getCodes(t),i.directives=this.getDirectives(t),i.scopedArrays=this.getScopedArrays(t);let r=`// code
329
330`;r+=this.flowCode[t];let s=this.flowNodes[t],n=s[s.length-1],a=n.outputNode,o=a!==void 0&&a.isOutputStructNode===!0;for(let l of s){let h=this.getFlowData(l),u=l.name;if(u&&(r.length>0&&(r+=`
331`),r+=`	// flow -> ${u}
332`),r+=`${h.code}
333	`,l===n&&t!=="compute"){if(r+=`// result
334
335	`,t==="vertex")r+=`varyings.builtinClipSpace = ${h.result};`;
335else if(t==="fragment")if(o)i.returnType=a.getNodeType(this),i.structs+="var<private> output : "+i.returnType+";",r+=`return ${h.result};`;else{let d="	@location(0) color: vec4<f32>",c=this.getBuiltins("output");c&&(d+=`,
336	`+c),i.returnType="OutputStruct",i.structs+=this._getWGSLStruct("OutputStruct",d),i.structs+=`
337var<private> output : OutputStruct;`,r+=`output.color = ${h.result};
338
339	return output;`}}}i.flow=r}if(this.shaderStage=null,this.material!==null)this.vertexShader=this._getWGSLVertexCode(e.vertex),this.fragmentShader=this._getWGSLFragmentCode(e.fragment);else{let t=this.object.workgroupSize;this.computeShader=this._getWGSLComputeCode(e.compute,t)}}getMethod(e,t=null){let i;return t!==null&&(i=this._getWGSLMethod(e+"_"+t)),i===void 0&&(i=this._getWGSLMethod(e)),i||e}getBitcastMethod(e){return`bitcast<${this.getType(e)}>`}getFloatPackingMethod(e){return this.getMethod(`floatpack_${e}_2x16`)}getFloatUnpackingMethod(e){return this.getMethod(`floatunpack_${e}_2x16`)}getTernary(e,t,i){return`select( ${i}, ${t}, ${e} )`}getType(e){return PW[e]||e}isAvailable(e){let t=d3[e];return t===void 0&&(e==="float32Filterable"?t=this.renderer.hasFeature("float32-filterable"):e==="clipDistance"&&(t=this.renderer.hasFeature("clip-distances")),d3[e]=t),t}_getWGSLMethod(e){return Op[e]!==void 0&&this._include(e),kW[e]}_include(e){let t=Op[e];return t.build(this),this.addInclude(t),t}
339_getWGSLVertexCode(e){return`${this.getSignature()}
340// directives
341${e.directives}
342
343// structs
344${e.structs}
345
346// uniforms
347${e.uniforms}
348
349// varyings
350${e.varyings}
351var<private> varyings : VaryingsStruct;
352
353// codes
354${e.codes}
355
356@vertex
357fn main( ${e.attributes} ) -> VaryingsStruct {
358
359	// vars
360	${e.vars}
361
362	// flow
363	${e.flow}
364
365	return varyings;
366
367}
368`}_getWGSLFragmentCode(e){return`${this.getSignature()}
369// global
370${p3}
371
372// structs
373${e.structs}
374
375// uniforms
376${e.uniforms}
377
378// codes
379${e.codes}
380
381@fragment
382fn main( ${e.varyings} ) -> ${e.returnType} {
383
384	// vars
385	${e.vars}
386
387	// flow
388	${e.flow}
389
390}
391`}_getWGSLComputeCode(e,t){let[i,r,s]=t;return`${this.getSignature()}
392// directives
393${e.directives}
394
395// system
396var<private> instanceIndex : u32;
397
398// locals
399${e.scopedArrays}
400
401// structs
402${e.structs}
403
404// uniforms
405${e.uniforms}
406
407// codes
408${e.codes}
409
410@compute @workgroup_size( ${i}, ${r}, ${s} )
411fn main( ${e.attributes} ) {
412
413	// system
414	instanceIndex = globalId.x
415		+ globalId.y * ( ${i} * numWorkgroups.x )
416		+ globalId.z * ( ${i} * numWorkgroups.x ) * ( ${r} * numWorkgroups.y );
417
418	// vars
419	${e.vars}
420
421	// flow
422	${e.flow}
423
424}
425`}_getWGSLStruct(e,t){return`
426struct ${e} {
427${t}
428};`}_getWGSLStructBinding(e,t,i,r=0,s=0){let n=e+"Struct";return`${this._getWGSLStruct(n,t)}
429@binding( ${r} ) @group( ${s} )
430var<${i}> ${e} : ${n};`}},FW=class{constructor(e){this.backend=e}getCurrentDepthStencilFormat(e){let t;return e.depth&&(t=e.depthTexture===null?e.stencil?P.Depth24PlusStencil8:P.Depth24Plus:this.getTextureFormatGPU(e.depthTexture)),t}getTextureFormatGPU(e){return this.backend.get(e).format}getTextureSampleData(e){let t;if(e.isFramebufferTexture)t=1;else if(e.isDepthTexture&&!e.renderTarget){let r=this.backend.renderer,s=r.getRenderTarget();t=s?s.samples:r.currentSamples}else e.renderTarget&&(t=e.renderTarget.samples);t||=1;let i=t>1&&e.renderTarget!==null&&e.isDepthTexture!==!0&&e.isFramebufferTexture!==!0;return{samples:t,primarySamples:i?1:t,isMSAA:i}}getCurrentColorFormat(e){let t;return t=e.textures===null?this.getPreferredCanvasFormat():this.getTextureFormatGPU(e.textures[0]),t}getCurrentColorFormats(e){return e.textures===null?[this.getPreferredCanvasFormat()]:e.textures.map(t=>this.getTextureFormatGPU(t))}getCurrentColorSpace(e){return e.textures===null?this.backend.renderer.outputColorSpace:e.textures[0].colorSpace}getPrimitiveTopology(e,t){if(e.isPoints)return P0.PointList;if(e.isLineSegments||e.isMesh&&t.wireframe===!0)return P0.LineList;if(e.isLine)return P0.LineStrip;if(e.isMesh)return P0.TriangleList}getSampleCount(e){return e>=4?4:1}
430getSampleCountRenderContext(e){return e.textures===null?this.getSampleCount(this.backend.renderer.currentSamples):this.getSampleCount(e.sampleCount)}getPreferredCanvasFormat(){let e=this.backend.parameters.outputType;if(e===void 0)return navigator.gpu.getPreferredCanvasFormat();if(e===1009)return P.BGRA8Unorm;if(e===1016)return P.RGBA16Float;throw Error("Unsupported output buffer type.")}},m3=new Map([[Int8Array,["sint8","snorm8"]],[Uint8Array,["uint8","unorm8"]],[Int16Array,["sint16","snorm16"]],[Uint16Array,["uint16","unorm16"]],[Int32Array,["sint32","snorm32"]],[Uint32Array,["uint32","unorm32"]],[Float32Array,["float32"]]]);typeof Float16Array<"u"&&m3.set(Float16Array,["float16"]);var DW=new Map([[TM,["float16"]]]),OW=new Map([[Int32Array,"sint32"],[Int16Array,"sint32"],[Uint32Array,"uint32"],[Uint16Array,"uint32"],[Float32Array,"float32"]]),BW=class{constructor(e){this.backend=e}createAttribute(e,t){let i=this._getBufferAttribute(e),r=this.backend,s=r.get(i),n=s.buffer;if(n===void 0){let a=r.device,o=i.array;if(e.normalized===!1){if(o.constructor===Int16Array||o.constructor===Int8Array)o=new Int32Array(o);else if((o.constructor===Uint16Array||o.constructor===Uint8Array)&&(o=new Uint32Array(o),t&GPUBufferUsage.INDEX))for(let u=0;u<o.length;u++)o[u]===65535&&(o[u]=4294967295)}if(i.array=o,(i.isStorageBufferAttribute||i.isStorageInstancedBufferAttribute)&&i.itemSize===3){o=new o.constructor(i.count*4);for(let u=0;u<i.count;u++)o.set(i.array.subarray(u*3,u*3+3),u*4);i.itemSize=4,i.array=o,s._force3to4BytesAlignment=!0}let l=o.byteLength,h=l+(4-l%4)%4;n=a.createBuffer({label:i.name,size:h,usage:t,mappedAtCreation:!0}),new o.constructor(n.getMappedRange()).set(o),n.unmap(),s.buffer=n}}updateAttribute(e){let t=this._getBufferAttribute(e),i=this.backend,r=i.device,s=i.get(t),n=i.get(t).buffer,a=t.array;if(s._force3to4BytesAlignment===!0){a=new a.constructor(t.count*4);for(let l=0;l<t.count;l++)a.set(t.array.subarray(l*3,l*3+3),l*4);t.array=a}let o=t.updateRanges;if(o.length===0)r.queue.writeBuffer(n,0,a,0);else{let l=kc(a),h=l?1:a.BYTES_PER_ELEMENT;for(let u=0,d=o.length;u<d;u++){let c=o[u],p,m;if(s._force3to4BytesAlignment===!0){let f=Math.floor(c.start/3),y=Math.ceil(c.count/3);p=f*4*h,m=y*4*h}else p=c.start*h,m=c.count*h;let g=p*(l?a.BYTES_PER_ELEMENT:1);r.queue.writeBuffer(n,g,a,p,m)}t.clearUpdateRanges()}}createShaderVertexBuffers(e){let t=e.getAttributes(),i=new Map;for(let r=0;r<t.length;r++){let s=t[r],n=s.array.BYTES_PER_ELEMENT,a=this._getBufferAttribute(s),o=i.get(a);if(o===void 0){let u,d;s.isInterleavedBufferAttribute===!0?(u=s.data.stride*n,d=s.data.isInstancedInterleavedBuffer?I0.Instance:I0.Vertex):(u=s.itemSize*n,d=s.isInstancedBufferAttribute?I0.Instance:I0.Vertex),s.normalized===!1&&(s.array.constructor===Int16Array||s.array.constructor===Uint16Array)&&(u=4),o={arrayStride:u,attributes:[],stepMode:d},i.set(a,o)}let l=this._getVertexFormat(s),h=s.isInterleavedBufferAttribute===!0?s.offset*n:0;o.attributes.push({shaderLocation:r,offset:h,format:l})}return Array.from(i.values())}destroyAttribute(e){let t=this.backend;t.get(this._getBufferAttribute(e)).buffer.destroy(),t.delete(e)}async getArrayBufferAsync(e){let t=this.backend,i=t.device,r=t.get(this._getBufferAttribute(e)).buffer,s=r.size,n=i.createBuffer({label:`${e.name}_readback`,size:s,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ}),a=i.createCommandEncoder({label:`readback_encoder_${e.name}`});a.copyBufferToBuffer(r,0,n,0,s);let o=a.finish();i.queue.submit([o]),await n.mapAsync(GPUMapMode.READ);let l=n.getMappedRange(),h=new e.array.constructor(l.slice(0));return n.unmap(),h.buffer}_getVertexFormat(e){let{itemSize:t,normalized:i}=e,r=e.array.constructor,s=e.constructor,n;if(t===1)n=OW.get(r);else{let a=(DW.get(s)||m3.get(r))[+!!i];if(a){let o=r.BYTES_PER_ELEMENT*t,l=Math.floor((o+3)/4)*4/r.BYTES_PER_ELEMENT;if(l%1)throw Error("THREE.WebGPUAttributeUtils: Bad vertex format item size.");n=`${a}x${l}`}}return n||re("WebGPUAttributeUtils: Vertex format not supported yet."),n}_getBufferAttribute(e){return e.isInterleavedBufferAttribute&&(e=e.data),e}},UW=class{constructor(e){this.layoutGPU=e,this.usedTimes=0}},VW=class{constructor(e){this.backend=e,this._bindGroupLayoutCache=new Map}createBindingsLayout(e){let t=this.backend,i=t.device,r=t.get(e);if(r.layout)return r.layout.layoutGPU;let s=this._createLayoutEntries(e),n=id(JSON.stringify(s)),a=this._bindGroupLayoutCache.get(n);return a===void 0&&(a=new UW(i.createBindGroupLayout({entries:s})),this._bindGroupLayoutCache.set(n,a)),a.usedTimes++,r.layout=a,r.layoutKey=n,a.layoutGPU}createBindings(e,t,i,r=0){let{backend:s}=this,n=s.get(e),a=this.createBindingsLayout(e),o;i>0&&(n.groups===void 0&&(n.groups=[],n.versions=[]),n.versions[i]===r&&(o=n.groups[i])),o===void 0&&(o=this.createBindGroup(e,a),i>0&&(n.groups[i]=o,n.versions[i]=r)),n.group=o}updateBinding(e){let t=this.backend,i=t.device,r=e.buffer,s=t.get(e).buffer,n=e.updateRanges;if(n.length===0)i.queue.writeBuffer(s,0,r,0);else{let a=kc(r),o=a?1:r.BYTES_PER_ELEMENT;for(let l=0,h=n.length;l<h;l++){let u=n[l],d=u.start*o,c=u.count*o,p=d*(a?r.BYTES_PER_ELEMENT:1);i.queue.writeBuffer(s,p,r,d,c)}}}createBindGroupIndex(e,t){let i=this.backend.device,r=GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST,s=e[0],n=i.
430createBuffer({label:"bindingCameraIndex_"+s,size:16,usage:r});i.queue.writeBuffer(n,0,e,0);let a=[{binding:0,resource:{buffer:n}}];return i.createBindGroup({label:"bindGroupCameraIndex_"+s,layout:t,entries:a})}createBindGroup(e,t){let i=this.backend,r=i.device,s=0,n=[];for(let a of e.bindings){if(a.isUniformBuffer){let o=i.get(a);if(o.buffer===void 0){let l=a.byteLength,h=GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST,u=[];a.visibility&na.VERTEX&&u.push("vertex"),a.visibility&na.FRAGMENT&&u.push("fragment"),a.visibility&na.COMPUTE&&u.push("compute");let d=`(${u.join(",")})`;o.buffer=r.createBuffer({label:`bindingBuffer${a.id}_${a.name}_${d}`,size:l,usage:h})}n.push({binding:s,resource:{buffer:o.buffer}})}else if(a.isStorageBuffer){let o=i.get(a.attribute).buffer;n.push({binding:s,resource:{buffer:o}})}else if(a.isSampledTexture){let o=i.get(a.texture),l;if(o.externalTexture!==void 0)l=r.importExternalTexture({source:o.externalTexture});else{let h=a.store?1:o.texture.mipLevelCount,u=a.store?a.mipLevel:0,d=`view-${o.texture.width}-${o.texture.height}`;if(o.texture.depthOrArrayLayers>1&&(d+=`-${o.texture.depthOrArrayLayers}`),d+=`-${h}-${u}`,l=o[d],l===void 0){let c=fW.All,p;p=a.isSampledCubeTexture?Cr.Cube:a.isSampledTexture3D?Cr.ThreeD:a.texture.isArrayTexture||a.texture.isDataArrayTexture||a.texture.isCompressedArrayTexture?Cr.TwoDArray:Cr.TwoD,l=o[d]=o.texture.createView({aspect:c,dimension:p,mipLevelCount:h,baseMipLevel:u})}}n.push({binding:s,resource:l})}else if(a.isSampler){let o=i.get(a.texture);n.push({binding:s,resource:o.sampler})}s++}return r.createBindGroup({label:"bindGroup_"+e.name,layout:t,entries:n})}_createLayoutEntries(e){let t=[],i=0;for(let r of e.bindings){let s=this.backend,n={binding:i,visibility:r.visibility};if(r.isUniformBuffer||r.isStorageBuffer){let a={};r.isStorageBuffer&&(r.visibility&na.COMPUTE&&(r.access===pr.READ_WRITE||r.access===pr.WRITE_ONLY)?a.type=n3.Storage:a.type=n3.ReadOnlyStorage),n.buffer=a}else if(r.isSampledTexture&&r.store){let a={};a.format=this.backend.get(r.texture).texture.format;let o=r.access;o===pr.READ_WRITE?a.access=A_.ReadWrite:o===pr.WRITE_ONLY?a.access=A_.WriteOnly:a.access=A_.ReadOnly,r.texture.isArrayTexture?a.viewDimension=Cr.TwoDArray:r.texture.is3DTexture&&(a.viewDimension=Cr.ThreeD),n.storageTexture=a}else if(r.isSampledTexture){let a={},{primarySamples:o}=s.utils.getTextureSampleData(r.texture);if(o>1&&(a.multisampled=!0,r.texture.isDepthTexture||(a.sampleType=Vh.UnfilterableFloat)),r.texture.isDepthTexture)s.compatibilityMode&&r.texture.compareFunction===null?a.sampleType=Vh.UnfilterableFloat:a.sampleType=Vh.Depth;else if(r.texture.isDataTexture||r.texture.isDataArrayTexture||r.texture.isData3DTexture||r.texture.isStorageTexture){let l=r.texture.type;l===1013?a.sampleType=Vh.SInt:l===1014?a.sampleType=Vh.UInt:l===1015&&(this.backend.hasFeature("float32-filterable")?a.sampleType=Vh.Float:a.sampleType=Vh.UnfilterableFloat)}r.isSampledCubeTexture?a.viewDimension=Cr.Cube:r.texture.isArrayTexture||r.texture.isDataArrayTexture||r.texture.isCompressedArrayTexture?a.viewDimension=Cr.TwoDArray:r.isSampledTexture3D&&(a.viewDimension=Cr.ThreeD),n.texture=a}else if(r.isSampler){let a={};r.texture.isDepthTexture&&(r.texture.compareFunction!==null&&s.hasCompatibility(ph.TEXTURE_COMPARE)?a.type=a3.Comparison:a.type=a3.NonFiltering),n.sampler=a}else re(`WebGPUBindingUtils: Unsupported binding "${r}".`);t.push(n),i++}return t}deleteBindGroupData(e){let{backend:t}=this,i=t.get(e);i.layout&&(i.layout.usedTimes--,i.layout.usedTimes===0&&this._bindGroupLayoutCache.delete(i.layoutKey),i.layout=void 0,i.layoutKey=void 0)}dispose(){this._bindGroupLayoutCache.clear()}},zW=class{constructor(e){this.backend=e}getMaxAnisotropy(){return 16}getUniformBufferLimit(){return this.backend.device.limits.maxUniformBufferBindingSize}},GW=class{constructor(e){this.backend=e,this._activePipelines=new WeakMap}setPipeline(e,t){this._activePipelines.get(e)!==t&&(e.setPipeline(t),this._activePipelines.set(e,t))}_getSampleCount(e){return this.backend.utils.getSampleCountRenderContext(e)}createRenderPipeline(e,t){let{object:i,material:r,geometry:s,pipeline:n}=e,{vertexProgram:a,fragmentProgram:o}=n,l=this.backend,h=l.device,u=l.utils,d=l.get(n),c=[];for(let O of e.getBindings()){let{layoutGPU:U}=l.get(O).layout;c.push(U)}let p=l.attributeUtils.createShaderVertexBuffers(e),m;r.blending!==0&&(r.blending!==1||r.transparent!==!1)&&(m=this._getBlending(r));let g={};r.stencilWrite===!0&&(g={compare:this._getStencilCompare(r),failOp:this._getStencilOperation(r.stencilFail),depthFailOp:this._getStencilOperation(r.stencilZFail),passOp:this._getStencilOperation(r.stencilZPass)});let f=this._getColorWriteMask(r),y=[];if(e.context.textures!==null){let O=e.context.textures,U=e.context.mrt;for(let V=0;V<O.length;V++){let z=O[V],Z=u.getTextureFormatGPU(z),j;if(U!==null)if(this.backend.compatibilityMode!==!0){let ae=U.getBlendM
430ode(z.name);ae.blending===6?j=m:ae.blending!==0&&(j=this._getBlending(ae))}else ut("WebGPURenderer: Multiple Render Targets (MRT) blending configuration is not fully supported in compatibility mode. The material blending will be used for all render targets."),j=m;else j=m;y.push({format:Z,blend:j,writeMask:f})}}else{let O=u.getCurrentColorFormat(e.context);y.push({format:O,blend:m,writeMask:f})}let x=l.get(a).module,b=l.get(o).module,_=this._getPrimitiveState(i,s,r),T=this._getDepthCompare(r),w=u.getCurrentDepthStencilFormat(e.context),M=this._getSampleCount(e.context),S={label:`renderPipeline_${r.name||r.type}_${r.id}`,vertex:Object.assign({},x,{buffers:p}),fragment:Object.assign({},b,{targets:y}),primitive:_,multisample:{count:M,alphaToCoverageEnabled:r.alphaToCoverage&&M>1},layout:h.createPipelineLayout({bindGroupLayouts:c})},R={},I=e.context.depth,B=e.context.stencil;if((I===!0||B===!0)&&(I===!0&&(R.format=w,R.depthWriteEnabled=r.depthWrite,R.depthCompare=T),B===!0&&(R.stencilFront=g,R.stencilBack=g,R.stencilReadMask=r.stencilFuncMask,R.stencilWriteMask=r.stencilWriteMask),r.polygonOffset===!0&&(R.depthBias=r.polygonOffsetUnits,R.depthBiasSlopeScale=r.polygonOffsetFactor,R.depthBiasClamp=0),S.depthStencil=R),h.pushErrorScope("validation"),t===null)d.pipeline=h.createRenderPipeline(S),h.popErrorScope().then(O=>{O!==null&&(d.error=!0,re(O.message))});else{let O=new Promise(async U=>{try{d.pipeline=await h.createRenderPipelineAsync(S)}catch{}let V=await h.popErrorScope();V!==null&&(d.error=!0,re(V.message)),U()});t.push(O)}}createBundleEncoder(e,t="renderBundleEncoder"){let{utils:i,device:r}=this.backend,s=i.getCurrentDepthStencilFormat(e),n={label:t,colorFormats:i.getCurrentColorFormats(e),depthStencilFormat:s,sampleCount:this._getSampleCount(e)};return r.createRenderBundleEncoder(n)}createComputePipeline(e,t){let i=this.backend,r=i.device,s=i.get(e.computeProgram).module,n=i.get(e),a=[];for(let o of t){let{layoutGPU:l}=i.get(o).layout;a.push(l)}n.pipeline=r.createComputePipeline({compute:s,layout:r.createPipelineLayout({bindGroupLayouts:a})})}_getBlending(e){let t,i,r=e.blending,s=e.blendSrc,n=e.blendDst,a=e.blendEquation;if(r===5){let o=e.blendSrcAlpha===null?s:e.blendSrcAlpha,l=e.blendDstAlpha===null?n:e.blendDstAlpha,h=e.blendEquationAlpha===null?a:e.blendEquationAlpha;t={srcFactor:this._getBlendFactor(s),dstFactor:this._getBlendFactor(n),operation:this._getBlendOperation(a)},i={srcFactor:this._getBlendFactor(o),dstFactor:this._getBlendFactor(l),operation:this._getBlendOperation(h)}}else{let o=e.premultipliedAlpha,l=(h,u,d,c)=>{t={srcFactor:h,dstFactor:u,operation:Uh.Add},i={srcFactor:d,dstFactor:c,operation:Uh.Add}};if(o)switch(r){case 1:l(rt.One,rt.OneMinusSrcAlpha,rt.One,rt.OneMinusSrcAlpha);break;case 2:l(rt.One,rt.One,rt.One,rt.One);break;case 3:l(rt.Zero,rt.OneMinusSrc,rt.Zero,rt.One);break;case 4:l(rt.Dst,rt.OneMinusSrcAlpha,rt.Zero,rt.One);break}else switch(r){case 1:l(rt.SrcAlpha,rt.OneMinusSrcAlpha,rt.One,rt.OneMinusSrcAlpha);break;case 2:l(rt.SrcAlpha,rt.One,rt.One,rt.One);break;case 3:re(`WebGPURenderer: "SubtractiveBlending" requires "${e.isMaterial?"material":"blendMode"}.premultipliedAlpha = true".`);break;case 4:re(`WebGPURenderer: "MultiplyBlending" requires "${e.isMaterial?"material":"blendMode"}.premultipliedAlpha = true".`);break}}if(t!==void 0&&i!==void 0)return{color:t,alpha:i};re("WebGPURenderer: Invalid blending: ",r)}_getBlendFactor(e){let t;switch(e){case 200:t=rt.Zero;break;case 201:t=rt.One;break;case 202:t=rt.Src;break;case 203:t=rt.OneMinusSrc;break;case 204:t=rt.SrcAlpha;break;case 205:t=rt.OneMinusSrcAlpha;break;case 208:t=rt.Dst;break;case 209:t=rt.OneMinusDst;break;case 206:t=rt.DstAlpha;break;case 207:t=rt.OneMinusDstAlpha;break;case 210:t=rt.SrcAlphaSaturated;break;case F8:t=rt.Constant;break;case D8:t=rt.OneMinusConstant;break;default:re("WebGPURenderer: Blend factor not supported.",e)}return t}_getStencilCompare(e){let t,i=e.stencilFunc;switch(i){case 512:t=gr.Never;break;case 519:t=gr.Always;break;case 513:t=gr.Less;break;case 515:t=gr.LessEqual;break;case 514:t=gr.Equal;break;case 518:t=gr.GreaterEqual;break;case 516:t=gr.Greater;break;case 517:t=gr.NotEqual;break;default:re("WebGPURenderer: Invalid stencil function.",i)}return t}_getStencilOperation(e){let t;switch(e){case Sg:t=yl.Keep;break;case 0:t=yl.Zero;break;case cB:t=yl.Replace;break;case yB:t=yl.Invert;break;case pB:t=yl.IncrementClamp;break;case mB:t=yl.DecrementClamp;break;case gB:t=yl.IncrementWrap;break;case fB:t=yl.DecrementWrap;break;default:re("WebGPURenderer: Invalid stencil operation.",t)}return t}_getBlendOperation(e){let t;switch(e){case 100:t=Uh.Add;break;case 101:t=Uh.Subtract;break;case 102:t=Uh.ReverseSubtract;break;case 103:t=Uh.Min;break;case 104:t=Uh.Max;break;default:re("WebGPUPipelineUtils: Blend equation not supported.",e)}return t}_getPrimitiveState(e,t,i){let r={};r.topology=this.backend.utils.getPrimitiveTopology(e,i),t.index!==null&&e.isLine
430===!0&&e.isLineSegments!==!0&&(r.stripIndexFormat=t.index.array instanceof Uint16Array?k0.Uint16:k0.Uint32);let s=i.side===1;return e.isMesh&&e.matrixWorld.determinant()<0&&(s=!s),r.frontFace=s===!0?i3.CW:i3.CCW,r.cullMode=i.side===2?r3.None:r3.Back,r}_getColorWriteMask(e){return e.colorWrite===!0?s3.All:s3.None}_getDepthCompare(e){let t;if(e.depthTest===!1)t=gr.Always;else{let i=this.backend.parameters.reversedDepthBuffer?sM[e.depthFunc]:e.depthFunc;switch(i){case 0:t=gr.Never;break;case 1:t=gr.Always;break;case 2:t=gr.Less;break;case 3:t=gr.LessEqual;break;case 4:t=gr.Equal;break;case 5:t=gr.GreaterEqual;break;case 6:t=gr.Greater;break;case 7:t=gr.NotEqual;break;default:re("WebGPUPipelineUtils: Invalid depth function.",i)}}return t}},jW=class extends t3{constructor(e,t,i=2048){super(i),this.device=e,this.type=t,this.querySet=this.device.createQuerySet({type:"timestamp",count:this.maxQueries,label:`queryset_global_timestamp_${t}`});let r=this.maxQueries*8;this.resolveBuffer=this.device.createBuffer({label:`buffer_timestamp_resolve_${t}`,size:r,usage:GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC}),this.resultBuffer=this.device.createBuffer({label:`buffer_timestamp_result_${t}`,size:r,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ})}allocateQueriesForContext(e){if(!this.trackTimestamp||this.isDisposed)return null;if(this.currentQueryIndex+2>this.maxQueries)return ut(`WebGPUTimestampQueryPool [${this.type}]: Maximum number of queries exceeded, when using trackTimestamp it is necessary to resolves the queries via renderer.resolveTimestampsAsync( THREE.TimestampQuery.${this.type.toUpperCase()} ).`),null;let t=this.currentQueryIndex;return this.currentQueryIndex+=2,this.queryOffsets.set(e,t),t}async resolveQueriesAsync(){if(!this.trackTimestamp||this.currentQueryIndex===0||this.isDisposed)return this.lastValue;if(this.pendingResolve)return this.pendingResolve;this.pendingResolve=this._resolveQueries();try{return await this.pendingResolve}finally{this.pendingResolve=null}}async _resolveQueries(){if(this.isDisposed)return this.lastValue;try{if(this.resultBuffer.mapState!=="unmapped")return this.lastValue;let e=new Map(this.queryOffsets),t=this.currentQueryIndex,i=t*8;this.currentQueryIndex=0,this.queryOffsets.clear();let r=this.device.createCommandEncoder();r.resolveQuerySet(this.querySet,0,t,this.resolveBuffer,0),r.copyBufferToBuffer(this.resolveBuffer,0,this.resultBuffer,0,i);let s=r.finish();if(this.device.queue.submit([s]),this.resultBuffer.mapState!=="unmapped")return this.lastValue;if(await this.resultBuffer.mapAsync(GPUMapMode.READ,0,i),this.isDisposed)return this.resultBuffer.mapState==="mapped"&&this.resultBuffer.unmap(),this.lastValue;let n=new BigUint64Array(this.resultBuffer.getMappedRange(0,i)),a={},o=[];for(let[h,u]of e){let d=h.match(/^(.*):f(\d+)$/),c=parseInt(d[2]);o.includes(c)===!1&&o.push(c),a[c]===void 0&&(a[c]=0);let p=n[u],m=n[u+1],g=Number(m-p)/1e6;this.timestamps.set(h,g),a[c]+=g}let l=a[o[o.length-1]];return this.resultBuffer.unmap(),this.lastValue=l,this.frames=o,l}catch(e){return re("Error resolving queries:",e),this.resultBuffer.mapState==="mapped"&&this.resultBuffer.unmap(),this.lastValue}}async dispose(){if(!this.isDisposed){if(this.isDisposed=!0,this.pendingResolve)try{await this.pendingResolve}catch(e){re("Error waiting for pending resolve:",e)}if(this.resultBuffer&&this.resultBuffer.mapState==="mapped")try{this.resultBuffer.unmap()}catch(e){re("Error unmapping buffer:",e)}this.querySet&&=(this.querySet.destroy(),null),this.resolveBuffer&&=(this.resolveBuffer.destroy(),null),this.resultBuffer&&=(this.resultBuffer.destroy(),null),this.queryOffsets.clear(),this.pendingResolve=null}}},$W=class extends ZL{constructor(e={}){super(e),this.isWebGPUBackend=!0,this.parameters.alpha=e.alpha===void 0?!0:e.alpha,this.parameters.requiredLimits=e.requiredLimits===void 0?{}:e.requiredLimits,this.compatibilityMode=null,this.device=null,this.defaultRenderPassdescriptor=null,this.utils=new FW(this),this.attributeUtils=new BW(this),this.bindingUtils=new VW(this),this.capabilities=new zW(this),this.pipelineUtils=new GW(this),this.textureUtils=new SW
430(this),this.occludedResolveCache=new Map;let t=typeof navigator>"u"?!0:/Android/.test(navigator.userAgent)===!1;this._compatibility={[ph.TEXTURE_COMPARE]:t}}async init(e){await super.init(e);let t=this.parameters,i;if(t.device===void 0){let r={powerPreference:t.powerPreference,featureLevel:"compatibility"},s=typeof navigator<"u"?await navigator.gpu.requestAdapter(r):null;if(s===null)throw Error("WebGPUBackend: Unable to create WebGPU adapter.");let n=Object.values(N_),a=[];for(let l of n)s.features.has(l)&&a.push(l);let o={requiredFeatures:a,requiredLimits:t.requiredLimits};i=await s.requestDevice(o)}else i=t.device;this.compatibilityMode=!i.features.has("core-features-and-limits"),this.compatibilityMode&&(e._samples=0),i.lost.then(r=>{if(r.reason==="destroyed")return;let s={api:"WebGPU",message:r.message||"Unknown reason",reason:r.reason||null,originalEvent:r};e.onDeviceLost(s)}),this.device=i,this.trackTimestamp=this.trackTimestamp&&this.hasFeature(N_.TimestampQuery),this.updateSize()}get context(){let e=this.renderer.getCanvasTarget(),t=this.get(e),i=t.context;if(i===void 0){let r=this.parameters;i=e.isDefaultCanvasTarget===!0&&r.context!==void 0?r.context:e.domElement.getContext("webgpu"),"setAttribute"in e.domElement&&e.domElement.setAttribute("data-engine",`three.js r${lh} webgpu`);let s=r.alpha?"premultiplied":"opaque",n=r.outputType===1016?"extended":"standard";i.configure({device:this.device,format:this.utils.getPreferredCanvasFormat(),usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.COPY_SRC,alphaMode:s,toneMapping:{mode:n}}),t.context=i}return i}get coordinateSystem(){return eM}async getArrayBufferAsync(e){return await this.attributeUtils.getArrayBufferAsync(e)}getContext(){return this.context}_getDefaultRenderPassDescriptor(){let e=this.renderer,t=e.getCanvasTarget(),i=this.get(t),r=e.currentSamples,s=i.descriptor;if(s===void 0||i.samples!==r){s={colorAttachments:[{view:null}]},(e.depth===!0||e.stencil===!0)&&(s.depthStencilAttachment={view:this.textureUtils.getDepthBuffer(e.depth,e.stencil).createView()});let a=s.colorAttachments[0];r>0?a.view=this.textureUtils.getColorBuffer().createView():a.resolveTarget=void 0,i.descriptor=s,i.samples=r}let n=s.colorAttachments[0];return r>0?n.resolveTarget=this.context.getCurrentTexture().createView():n.view=this.context.getCurrentTexture().createView(),s}_isRenderCameraDepthArray(e){return e.depthTexture&&e.depthTexture.image.depth>1&&e.camera.isArrayCamera}_getRenderPassDescriptor(e,t={}){let i=e.renderTarget,r=this.get(i),s=r.descriptors;(s===void 0||r.width!==i.width||r.height!==i.height||r.samples!==i.samples)&&(s={},r.descriptors=s);let n=e.getCacheKey(),a=s[n];if(a===void 0){let l=e.textures,h=[],u,d=this._isRenderCameraDepthArray(e);for(let c=0;c<l.length;c++){let p=this.get(l[c]),m={label:`colorAttachment_${c}`,baseMipLevel:e.activeMipmapLevel,mipLevelCount:1,baseArrayLayer:e.activeCubeFace,arrayLayerCount:1,dimension:Cr.TwoD};if(i.isRenderTarget3D)u=e.activeCubeFace,m.baseArrayLayer=0,m.dimension=Cr.ThreeD,m.depthOrArrayLayers=l[c].image.depth;else if(i.isRenderTarget&&l[c].image.depth>1)if(d===!0){let g=e.camera.cameras;for(let f=0;f<g.length;f++){let y={...m,baseArrayLayer:f,arrayLayerCount:1,dimension:Cr.TwoD},x=p.texture.createView(y);h.push({view:x,resolveTarget:void 0,depthSlice:void 0})}}else m.dimension=Cr.TwoDArray,m.depthOrArrayLayers=l[c].image.depth;if(d!==!0){let g=p.texture.createView(m),f,y;p.msaaTexture===void 0?(f=g,y=void 0):(f=p.msaaTexture.createView(),y=g),h.push({view:f,resolveTarget:y,depthSlice:u})}}if(a={textureViews:h},e.depth){let c=this.get(e.depthTexture),p={};(e.depthTexture.isArrayTexture||e.depthTexture.isCubeTexture)&&(p.dimension=Cr.TwoD,p.arrayLayerCount=1,p.baseArrayLayer=e.activeCubeFace),a.depthStencilView=c.texture.createView(p)}s[n]=a,r.width=i.width,r.height=i.height,r.samples=i.samples,r.activeMipmapLevel=e.activeMipmapLevel,r.activeCubeFace=e.activeCubeFace}let o={colorAttachments:[]};for(let l=0;l<a.textureViews.length;l++){let h=a.textureViews[l],u={r:0,g:0,b:0,a:1};l===0&&t.clearValue&&(u=t.clearValue),o.colorAttachments.push({view:h.view,depthSlice:h.depthSlice,resolveTarget:h.resolveTarget,loadOp:t.loadOp||_t.Load,storeOp:t.storeOp||Kr.Store,clearValue:u})}return a.depthStencilView&&(o.depthStencilAttachment={view:a.depthStencilView}),o}beginRender(e){let t=this.get(e),i=this.device,r=e.occlusionQueryCount,s;r>0&&(t.currentOcclusionQuerySet&&t.currentOcclusionQuerySet.destroy(),t.currentOcclusionQueryBuffer&&t.currentOcclusionQueryBuffer.destroy(),t.currentOcclusionQuerySet=t.occlusionQuerySet,t.currentOcclusionQueryBuffer=t.occlusionQueryBuffer,t.currentOcclusionQueryObjects=t.occlusionQueryObjects,s=i.createQuerySet({type:"occlusion",count:r,label:`occlusionQuerySet_${e.id}`}),t.occlusionQuerySet=s,t.occlusionQueryIndex=0,t.occlusionQueryObjects=Array(r),t.lastOcclusionObject=null);let n;n=e.textures===null?this._getDefaultRenderPassDescriptor():this._getRenderPassDescriptor(e,{loadOp:_t.Load}),this.initTimestampQuery(Ur.RENDER,this.getTimestampUID(e),n),n.occlusionQuerySet=s;let a=n.depthStencilAttachment;if(e.textures!==null){let l=n.colorAttachments;for(let h=0;h<l.length;h++){let u=l[h];e.clearColor?(u.clearValue=h===0?e.clearColorValue:{r:0,g:0,b:0,a:1},u.loadOp=_t.Clear):u.loadOp=_t.Load,u.storeOp=Kr.Store}}else{let l=n.colorAttachments[0];e.clearColor?(l.clearValue=e.clearColorValue,l.loadOp=_t.Clear):l.loadOp=_t.Load,l.storeOp=Kr.Store}e.depth&&(e.clearDepth?(a.depthClearValue=e.clearDepthValue,a.depthLoadOp=_t.Clear):a.depthLoadOp=_t.Load,a.depthStoreOp=Kr.Store),e.stencil&&(e.clearStencil?(a.stencilClearValue=e.clearStencilValue,a.stencilLoadOp=_t.Clear):a.stencilLoadOp=_t.Load,a.stencilStoreOp=Kr.Store);let o=i.createCommandEncoder({label:"renderContext_"+e.id});if(this._isRenderCameraDepthArray(e)===!0){let l=e.camera.cameras;!t.layerDescriptors||t.layerDescriptors.length!==l.length?this._createDepthLayerDescriptors(e,t,n,l):this._updateDepthLayerDescriptors(e,t,l),t.bundleEncoders=[],t.bundleSets=[];for(let h=0;h<l.length;h++){let u=this.pipelineUtils.createBundleEncoder(e,"renderBundleArrayCamera_"+h);t.bundleEncoders.push(u),t.bundleSets.push({attributes:{},bindingGroups:[],pipeline:null,index:null})}t.currentPass=null}else t.currentPass=o.beginRenderPass(n),e.viewport&&this.updateViewport(e),e.scissor&&this.updateScissor(e);t.descriptor=n,t.encoder=o,t.currentSets={attributes:{},bindingGroups:[],pipeline:null,index:null},t.renderBundles=[]}_createDepthLayerDescriptors(e,t,i,r){let s=i.depthStencilAttachment;t.layerDescriptors=[];let n=this.get(e.depthTexture);n.viewCache||=[];for(let a=0;a<r.length;a++){let o={...i,colorAttachments:[{...i.colorAttachments[0],view:i.colorAttachments[a].view}]};if(i.depthStencilAttachment){let l=a;n.viewCache[l]||(n.viewCache[l]=n.texture.createView({dimension:Cr.TwoD,baseArrayLayer:a,arrayLayerCount:1})),o.depthStencilAttachment={view:n.viewCache[l],depthLoadOp:s.depthLoadOp||_t.Clear,depthStoreOp:s.depthStoreOp||Kr.Store,depthClearValue:s.depthClearValue||1},e.stencil&&(o.depthStencilAttachment.stencilLoadOp=s.stencilLoadOp,o.depthStencilAttachment.stencilStoreOp=s.stencilStoreOp,o.depthStencilAttachment.stencilClearValue=s.stencilClearValue)}else o.depthStencilAttachment={...s};t.layerDescriptors.push(o)}}_updateDepthLayerDescriptors(e,t,i){for(let r=0;r<i.length;r++){let s=t.layerDescriptors[r];if(s.depthStencilAttachment){let n=s.depthStencilAttachment;e.depth&&(e.clearDepth?(n.depthClearValue=e.clearDepthValue,n.depthLoadOp=_t.Clear):n.depthLoadOp=_t.Load),e.stencil&&(e.clearStencil?(n.stencilClearValue=e.clearStencilValue,n.stencilLoadOp=_t.Clear):n.stencilLoadOp=_t.Load)}}}finishRender(e){let t=this.get(e),i=e.occlusionQueryCount;t.renderBundles.length>0&&t.currentPass.executeBundles(t.renderBundles),i>t.occlusionQueryIndex&&t.currentPass.endOcclusionQuery();let r=t.encoder;if(this._isRenderCameraDepthArray(e)===!0){let s=[];for(let n=0;n<t.bundleEncoders.length;n++){let a=t.bundleEncoders[n];s.push(a.finish())}for(let n=0;n<t.layerDescriptors.length;n++)if(n<s.length){let a=t.layerDescriptors[n],o=r.beginRenderPass(a);if(e.viewport){let{x:l,y:h,width:u,height:d,minDepth:c,maxDepth:p}=e.viewportValue;o.setViewport(l,h,u,d,c,p)}if(e.scissor){let{x:l,y:h,width:u,height:d}=e.scissorValue;
430o.setScissorRect(l,h,u,d)}o.executeBundles([s[n]]),o.end()}}else t.currentPass&&t.currentPass.end();if(i>0){let s=i*8,n=this.occludedResolveCache.get(s);n===void 0&&(n=this.device.createBuffer({size:s,usage:GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC}),this.occludedResolveCache.set(s,n));let a=this.device.createBuffer({size:s,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ});t.encoder.resolveQuerySet(t.occlusionQuerySet,0,i,n,0),t.encoder.copyBufferToBuffer(n,0,a,0,s),t.occlusionQueryBuffer=a,this.resolveOccludedAsync(e)}if(this.device.queue.submit([t.encoder.finish()]),e.textures!==null){let s=e.textures;for(let n=0;n<s.length;n++){let a=s[n];a.generateMipmaps===!0&&this.textureUtils.generateMipmaps(a)}}}isOccluded(e,t){let i=this.get(e);return i.occluded&&i.occluded.has(t)}async resolveOccludedAsync(e){let t=this.get(e),{currentOcclusionQueryBuffer:i,currentOcclusionQueryObjects:r}=t;if(i&&r){let s=new WeakSet;t.currentOcclusionQueryObjects=null,t.currentOcclusionQueryBuffer=null,await i.mapAsync(GPUMapMode.READ);let n=i.getMappedRange(),a=new BigUint64Array(n);for(let o=0;o<r.length;o++)a[o]===BigInt(0)&&s.add(r[o]);i.destroy(),t.occluded=s}}updateViewport(e){let{currentPass:t}=this.get(e),{x:i,y:r,width:s,height:n,minDepth:a,maxDepth:o}=e.viewportValue;t.setViewport(i,r,s,n,a,o)}updateScissor(e){let{currentPass:t}=this.get(e),{x:i,y:r,width:s,height:n}=e.scissorValue;t.setScissorRect(i,r,s,n)}getClearColor(){let e=super.getClearColor();return this.renderer.alpha===!0&&(e.r*=e.a,e.g*=e.a,e.b*=e.a),e}clear(e,t,i,r=null){let s=this.device,n=this.renderer,a=[],o,l,h,u;if(e){let c=this.getClearColor();l={r:c.r,g:c.g,b:c.b,a:c.a}}if(r===null){h=n.depth,u=n.stencil;let c=this._getDefaultRenderPassDescriptor();if(e){a=c.colorAttachments;let p=a[0];p.clearValue=l,p.loadOp=_t.Clear,p.storeOp=Kr.Store}(h||u)&&(o=c.depthStencilAttachment)}else{h=r.depth,u=r.stencil;let c={loadOp:e?_t.Clear:_t.Load,clearValue:e?l:void 0};h&&(c.depthLoadOp=t?_t.Clear:_t.Load,c.depthClearValue=t?n.getClearDepth():void 0,c.depthStoreOp=Kr.Store),u&&(c.stencilLoadOp=i?_t.Clear:_t.Load,c.stencilClearValue=i?n.getClearStencil():void 0,c.stencilStoreOp=Kr.Store);let p=this._getRenderPassDescriptor(r,c);a=p.colorAttachments,o=p.depthStencilAttachment}h&&o&&(t?(o.depthLoadOp=_t.Clear,o.depthClearValue=n.getClearDepth(),o.depthStoreOp=Kr.Store):(o.depthLoadOp=_t.Load,o.depthStoreOp=Kr.Store)),u&&o&&(i?(o.stencilLoadOp=_t.Clear,o.stencilClearValue=n.getClearStencil(),o.stencilStoreOp=Kr.Store):(o.stencilLoadOp=_t.Load,o.stencilStoreOp=Kr.Store));let d=s.createCommandEncoder({label:"clear"});d.beginRenderPass({colorAttachments:a,depthStencilAttachment:o}).end(),s.queue.submit([d.finish()])}beginCompute(e){let t=this.get(e),i={label:"computeGroup_"+e.id};this.initTimestampQuery(Ur.COMPUTE,this.getTimestampUID(e),i),t.cmdEncoderGPU=this.device.createCommandEncoder({label:"computeGroup_"+e.id}),t.passEncoderGPU=t.cmdEncoderGPU.beginComputePass(i)}compute(e,t,i,r,s=null){let n=this.get(t),{passEncoderGPU:a}=this.get(e),o=this.get(r).pipeline;this.pipelineUtils.setPipeline(a,o);for(let l=0,h=i.length;l<h;l++){let u=i[l],d=this.get(u);a.setBindGroup(l,d.group)}if(s===null&&(s=t.count),s&&typeof s=="object"&&s.isIndirectStorageBufferAttribute){let l=this.get(s).buffer;a.dispatchWorkgroupsIndirect(l,0);return}if(typeof s=="number"){let l=s;if(n.dispatchSize===void 0||n.count!==l){n.dispatchSize=[0,1,1],n.count=l;let h=t.workgroupSize,u=h[0];for(let p=1;p<h.length;p++)u*=h[p];let d=Math.ceil(l/u),c=this.device.limits.maxComputeWorkgroupsPerDimension;s=[d,1,1],d>c&&(s[0]=Math.min(d,c),s[1]=Math.ceil(d/c)),n.dispatchSize=s}s=n.dispatchSize}a.dispatchWorkgroups(s[0],s[1]||1,s[2]||1)}finishCompute(e){let t=this.get(e);t.passEncoderGPU.end(),this.device.queue.submit([t.cmdEncoderGPU.finish()])}_draw(e,t,i,r,s,n,a,o,l){let{object:h,material:u,context:d}=e,c=e.getIndex(),p=c!==null;this.pipelineUtils.setPipeline(o,r),l.pipeline=r;let m=l.bindingGroups;for(let g=0,f=s.length;g<f;g++){let y=s[g],x=this.get(y);m[g]!==y.id&&(o.setBindGroup(g,x.group),m[g]=y.id)}if(p===!0&&l.index!==c){let g=this.get(c).buffer,f=c.array instanceof Uint16Array?k0.Uint16:k0.Uint32;o.setIndexBuffer(g,f),l.index=c}for(let g=0,f=n.length;g<f;g++){let y=n[g];if(l.attributes[g]!==y){let x=this.get(y).buffer;o.setVertexBuffer(g,x),l.attributes[g]=y}}if(d.stencil===!0&&u.stencilWrite===!0&&i.currentStencilRef!==u.stencilRef&&(o.setStencilReference(u.stencilRef),i.currentStencilRef=u.stencilRef),h.isBatchedMesh===!0){let g=h._multiDrawStarts,f=h._multiDrawCounts,y=h._multiDrawCount,x=h._multiDrawInstances;x!==null&&ut("WebGPUBackend: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection.");let b=p===!0?c.array.BYTES_PER_ELEMENT:1;u.wireframe&&(b=h.geometry.attributes.position.count>65535?4:2);for(let _=0;_<y;
430_++){let T=x?x[_]:1,w=T>1?0:_;p===!0?o.drawIndexed(f[_],T,g[_]/b,0,w):o.draw(f[_],T,g[_],w),t.update(h,f[_],T)}}else if(p===!0){let{vertexCount:g,instanceCount:f,firstVertex:y}=a,x=e.getIndirect();if(x!==null){let b=this.get(x).buffer,_=e.getIndirectOffset(),T=Array.isArray(_)?_:[_];for(let w=0;w<T.length;w++)o.drawIndexedIndirect(b,T[w])}else o.drawIndexed(g,f,y,0,0);t.update(h,g,f)}else{let{vertexCount:g,instanceCount:f,firstVertex:y}=a,x=e.getIndirect();if(x!==null){let b=this.get(x).buffer,_=e.getIndirectOffset(),T=Array.isArray(_)?_:[_];for(let w=0;w<T.length;w++)o.drawIndirect(b,T[w])}else o.draw(g,f,y,0);t.update(h,g,f)}}draw(e,t){let{object:i,context:r,pipeline:s}=e,n=this.get(r),a=this.get(s),o=a.pipeline;if(a.error===!0)return;let l=e.getDrawParameters();if(l===null)return;let h=e.getBindings(),u=e.getVertexBuffers();if(e.camera.isArrayCamera&&e.camera.cameras.length>0){let d=this.get(e.camera),c=e.camera.cameras,p=e.getBindingGroup("cameraIndex");if(d.indexesGPU===void 0||d.indexesGPU.length!==c.length){let g=this.get(p),f=[],y=new Uint32Array([0,0,0,0]);for(let x=0,b=c.length;x<b;x++){y[0]=x;let{layoutGPU:_}=g.layout,T=this.bindingUtils.createBindGroupIndex(y,_);f.push(T)}d.indexesGPU=f}let m=this.renderer.getPixelRatio();for(let g=0,f=c.length;g<f;g++){let y=c[g];if(i.layers.test(y.layers)){let x=y.viewport,b=n.currentPass,_=n.currentSets;if(n.bundleEncoders){let T=n.bundleEncoders[g],w=n.bundleSets[g];b=T,_=w}if(x&&b.setViewport(Math.floor(x.x*m),Math.floor(x.y*m),Math.floor(x.width*m),Math.floor(x.height*m),r.viewportValue.minDepth,r.viewportValue.maxDepth),p&&d.indexesGPU){let T=h.indexOf(p);b.setBindGroup(T,d.indexesGPU[g]),_.bindingGroups[T]=p.id}this._draw(e,t,n,o,h,u,l,b,_)}}}else if(n.currentPass){if(n.occlusionQuerySet!==void 0){let d=n.lastOcclusionObject;d!==i&&(d!==null&&d.occlusionTest===!0&&(n.currentPass.endOcclusionQuery(),n.occlusionQueryIndex++),i.occlusionTest===!0&&(n.currentPass.beginOcclusionQuery(n.occlusionQueryIndex),n.occlusionQueryObjects[n.occlusionQueryIndex]=i),n.lastOcclusionObject=i)}this._draw(e,t,n,o,h,u,l,n.currentPass,n.currentSets)}}needsRenderUpdate(e){let t=this.get(e),{object:i,material:r}=e,s=this.utils,n=s.getSampleCountRenderContext(e.context),a=s.getCurrentColorSpace(e.context),o=s.getCurrentColorFormat(e.context),l=s.getCurrentDepthStencilFormat(e.context),h=s.getPrimitiveTopology(i,r),u=!1;return(t.material!==r||t.materialVersion!==r.version||t.transparent!==r.transparent||t.blending!==r.blending||t.premultipliedAlpha!==r.premultipliedAlpha||t.blendSrc!==r.blendSrc||t.blendDst!==r.blendDst||t.blendEquation!==r.blendEquation||t.blendSrcAlpha!==r.blendSrcAlpha||t.blendDstAlpha!==r.blendDstAlpha||t.blendEquationAlpha!==r.blendEquationAlpha||t.colorWrite!==r.colorWrite||t.depthWrite!==r.depthWrite||t.depthTest!==r.depthTest||t.depthFunc!==r.depthFunc||t.stencilWrite!==r.stencilWrite||t.stencilFunc!==r.stencilFunc||t.stencilFail!==r.stencilFail||t.stencilZFail!==r.stencilZFail||t.stencilZPass!==r.stencilZPass||t.stencilFuncMask!==r.stencilFuncMask||t.stencilWriteMask!==r.stencilWriteMask||t.side!==r.side||t.alphaToCoverage!==r.alphaToCoverage||t.sampleCount!==n||t.colorSpace!==a||t.colorFormat!==o||t.depthStencilFormat!==l||t.primitiveTopology!==h||t.clippingContextCacheKey!==e.clippingContextCacheKey)&&(t.material=r,t.materialVersion=r.version,t.transparent=r.transparent,t.blending=r.blending,t.premultipliedAlpha=r.premultipliedAlpha,t.blendSrc=r.blendSrc,t.blendDst=r.blendDst,t.blendEquation=r.blendEquation,t.blendSrcAlpha=r.blendSrcAlpha,t.blendDstAlpha=r.blendDstAlpha,t.blendEquationAlpha=r.blendEquationAlpha,t.colorWrite=r.colorWrite,t.depthWrite=r.depthWrite,t.depthTest=r.depthTest,t.depthFunc=r.depthFunc,t.stencilWrite=r.stencilWrite,t.stencilFunc=r.stencilFunc,t.stencilFail=r.stencilFail,t.stencilZFail=r.stencilZFail,t.stencilZPass=r.stencilZPass,t.stencilFuncMask=r.stencilFuncMask,t.stencilWriteMask=r.stencilWriteMask,t.side=r.side,t.alphaToCoverage=r.alphaToCoverage,t.sampleCount=n,t.colorSpace=a,t.colorFormat=o,t.depthStencilFormat=l,t.primitiveTopology=h,t.clippingContextCacheKey=e.clippingContextCacheKey,u=!0),u}getRenderCacheKey(e){let{object:t,material:i}
430=e,r=this.utils,s=e.context,n=t.isMesh&&t.matrixWorld.determinant()<0;return[i.transparent,i.blending,i.premultipliedAlpha,i.blendSrc,i.blendDst,i.blendEquation,i.blendSrcAlpha,i.blendDstAlpha,i.blendEquationAlpha,i.colorWrite,i.depthWrite,i.depthTest,i.depthFunc,i.stencilWrite,i.stencilFunc,i.stencilFail,i.stencilZFail,i.stencilZPass,i.stencilFuncMask,i.stencilWriteMask,i.side,n,r.getSampleCountRenderContext(s),r.getCurrentColorSpace(s),r.getCurrentColorFormat(s),r.getCurrentDepthStencilFormat(s),r.getPrimitiveTopology(t,i),e.getGeometryCacheKey(),e.clippingContextCacheKey].join()}updateSampler(e){return this.textureUtils.updateSampler(e)}createDefaultTexture(e){return this.textureUtils.createDefaultTexture(e)}createTexture(e,t){this.textureUtils.createTexture(e,t)}updateTexture(e,t){this.textureUtils.updateTexture(e,t)}generateMipmaps(e){this.textureUtils.generateMipmaps(e)}destroyTexture(e,t=!1){this.textureUtils.destroyTexture(e,t)}async copyTextureToBuffer(e,t,i,r,s,n){return this.textureUtils.copyTextureToBuffer(e,t,i,r,s,n)}initTimestampQuery(e,t,i){if(!this.trackTimestamp)return;this.timestampQueryPool[e]||(this.timestampQueryPool[e]=new jW(this.device,e,2048));let r=this.timestampQueryPool[e],s=r.allocateQueriesForContext(t);i.timestampWrites={querySet:r.querySet,beginningOfPassWriteIndex:s,endOfPassWriteIndex:s+1}}createNodeBuilder(e,t){return new IW(e,t)}createProgram(e){let t=this.get(e);t.module={module:this.device.createShaderModule({code:e.code,label:e.stage+(e.name===""?"":`_${e.name}`)}),entryPoint:"main"}}destroyProgram(e){this.delete(e)}createRenderPipeline(e,t){this.pipelineUtils.createRenderPipeline(e,t)}createComputePipeline(e,t){this.pipelineUtils.createComputePipeline(e,t)}beginBundle(e){let t=this.get(e);t._currentPass=t.currentPass,t._currentSets=t.currentSets,t.currentSets={attributes:{},bindingGroups:[],pipeline:null,index:null},t.currentPass=this.pipelineUtils.createBundleEncoder(e)}finishBundle(e,t){let i=this.get(e),r=i.currentPass.finish();this.get(t).bundleGPU=r,i.currentSets=i._currentSets,i.currentPass=i._currentPass}addBundle(e,t){this.get(e).renderBundles.push(this.get(t).bundleGPU)}createBindings(e,t,i,r){this.bindingUtils.createBindings(e,t,i,r)}updateBindings(e,t,i,r){this.bindingUtils.createBindings(e,t,i,r)}updateBinding(e){this.bindingUtils.updateBinding(e)}deleteBindGroupData(e){this.bindingUtils.deleteBindGroupData(e)}createIndexAttribute(e){let t=GPUBufferUsage.INDEX|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST;(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)&&(t|=GPUBufferUsage.STORAGE),this.attributeUtils.createAttribute(e,t)}createAttribute(e){this.attributeUtils.createAttribute(e,GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}createStorageAttribute(e){this.attributeUtils.createAttribute(e,GPUBufferUsage.STORAGE|GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}createIndirectStorageAttribute(e){this.attributeUtils.createAttribute(e,GPUBufferUsage.STORAGE|GPUBufferUsage.INDIRECT|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}updateAttribute(e){this.attributeUtils.updateAttribute(e)}destroyAttribute(e){this.attributeUtils.destroyAttribute(e)}updateSize(){this.delete(this.renderer.getCanvasTarget())}hasFeature(e){return l3[e]!==void 0&&(e=l3[e]),this.device.features.has(e)}copyTextureToTexture(e,t,i=null,r=null,s=0,n=0){let a=0,o=0,l=0,h=0,u=0,d=0,c=e.image.width,p=e.image.height,m=1;i!==null&&(i.isBox3===!0?(h=i.min.x,u=i.min.y,d=i.min.z,c=i.max.x-i.min.x,p=i.max.y-i.min.y,m=i.max.z-i.min.z):(h=i.min.x,u=i.min.y,c=i.max.x-i.min.x,p=i.max.y-i.min.y,m=1)),r!==null&&(a=r.x,o=r.y,l=r.z||0);let g=this.device.createCommandEncoder({label:"copyTextureToTexture_"+e.id+"_"+t.id}),f=this.get(e).texture,y=this.get(t).texture;g.copyTextureToTexture({texture:f,mipLevel:s,origin:{x:h,y:u,z:d}},{texture:y,mipLevel:n,origin:{x:a,y:o,z:l}},[c,p,m]),this.device.queue.submit([g.finish()]),n===0&&t.generateMipmaps&&this.textureUtils.generateMipmaps(t)}copyFramebufferToTexture(e,t,i){let r=this.get(t),s=null;s=t.renderTarget?e.isDepthTexture?this.get(t.depthTexture).texture:this.get(t.textures[0]).texture:e.isDepthTexture?this.textureUtils.getDepthBuffer(t.depth,t.stencil):this.context.getCurrentTexture();let n=this.get(e).texture;if(s.format!==n.format){re("WebGPUBackend: copyFramebufferToTexture: Source and destination formats do not match.",s.format,n.format);return}let a;if(r.currentPass?(r.currentPass.end(),a=r.encoder):a=this.device.createCommandEncoder({label:"copyFramebufferToTexture_"+e.id}),a.copyTextureToTexture({texture:s,origin:[i.x,i.y,0]},{texture:n},[i.z,i.w]),e.generateMipmaps&&this.textureUtils.generateMipmaps(e,a),r.currentPass){let{descriptor:o}=r;for(let l=0;l<o.colorAttachments.length;l++)o.colorAttachments[l].loadOp=_t.Load;t.depth&&(o.depthStencilAttachment.depthLoadOp=_t.Load),t.stencil&&(o.depthStencilAttachment.stencilLoadOp=_t.Load),r.currentPass=a.beginRenderPass(o),r.currentSets={attributes:{},bindingGroups:[],pipeline:null,index:null},t.viewport&&this.updateViewport(t),t.scissor&&this.updateScissor(t)}
430else this.device.queue.submit([a.finish()])}hasCompatibility(e){return this._compatibility[e]===void 0?super.hasCompatibility(e):this._compatibility[e]}dispose(){if(this.bindingUtils.dispose(),this.textureUtils.dispose(),this.occludedResolveCache){for(let e of this.occludedResolveCache.values())e.destroy();this.occludedResolveCache.clear()}if(this.timestampQueryPool)for(let e of Object.values(this.timestampQueryPool))e!==null&&e.dispose();this.parameters.device===void 0&&this.device!==null&&this.device.destroy()}},WW=class extends zx{constructor(e,t,i,r,s,n){super(e,t,i,r,s,n),this.iesMap=null}copy(e,t){return super.copy(e,t),this.iesMap=e.iesMap,this}},HW=class extends zx{constructor(e,t,i,r,s,n){super(e,t,i,r,s,n),this.aspect=null}copy(e,t){return super.copy(e,t),this.aspect=e.aspect,this}},qW=class extends AL{constructor(){super(),this.addMaterial(Mz,"MeshPhongMaterial"),this.addMaterial(aN,"MeshStandardMaterial"),this.addMaterial(g8,"MeshPhysicalMaterial"),this.addMaterial(v8,"MeshToonMaterial"),this.addMaterial(Qn,"MeshBasicMaterial"),this.addMaterial(wz,"MeshLambertMaterial"),this.addMaterial(mz,"MeshNormalMaterial"),this.addMaterial(_8,"MeshMatcapMaterial"),this.addMaterial(uz,"LineBasicMaterial"),this.addMaterial(cz,"LineDashedMaterial"),this.addMaterial(M8,"PointsMaterial"),this.addMaterial(Ub,"SpriteMaterial"),this.addMaterial(A8,"ShadowMaterial"),this.addLight($9,gU),this.addLight(T$,yU),this.addLight(E$,vU),this.addLight(x_,zx),this.addLight(_$,xU),this.addLight(w$,cU),this.addLight(M$,_U),this.addLight(S$,WW),this.addLight(R$,HW),this.addToneMapping(kN,1),this.addToneMapping(IN,2),this.addToneMapping(FN,3),this.addToneMapping(DN,4),this.addToneMapping(ON,6),this.addToneMapping(BN,7)}},F0=class extends Y${constructor(e={}){let t;e.forceWebGL?t=R_:(t=$W,e.getFallback=()=>(de("WebGPURenderer: WebGPU is not available, running under WebGL2 backend."),new R_(e)));let i=new t(e);super(i,e),this.library=new qW,this.isWebGPURenderer=!0,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}},XW=class extends Gr{constructor(){super(),this.isBundleGroup=!0,this.type="BundleGroup",this.static=!0,this.version=0}set needsUpdate(e){e===!0&&this.version++}},YW=class{constructor(e,t=Te(0,0,1,1)){this.renderer=e,this.outputNode=t,this.outputColorTransform=!0,this.needsUpdate=!0;let i=new Ot;i.name="RenderPipeline",this._quadMesh=new _d(i),this._quadMesh.name="Render Pipeline",this._context=null}render(){let e=this.renderer;this._update(),this._context.onBeforeRenderPipeline!==null&&this._context.onBeforeRenderPipeline();let t=e.toneMapping,i=e.outputColorSpace;e.toneMapping=0,e.outputColorSpace=lt.workingColorSpace;let r=e.xr.enabled;e.xr.enabled=!1,this._quadMesh.render(e),e.xr.enabled=r,e.toneMapping=t,e.outputColorSpace=i,this._context.onAfterRenderPipeline!==null&&this._context.onAfterRenderPipeline()}get context(){return this._context}dispose(){this._quadMesh.material.dispose()}_update(){if(this.needsUpdate===!0){let e=this.renderer,t=e.toneMapping,i=e.outputColorSpace,r={renderPipeline:this,onBeforeRenderPipeline:null,onAfterRenderPipeline:null},s=this.outputNode;this.outputColorTransform===!0?(s=s.context(r),s=Lf(s,t,i)):(r.toneMapping=t,r.outputColorSpace=i,s=s.context(r)),this._context=r,this._quadMesh.material.fragmentNode=s,this._quadMesh.material.needsUpdate=!0,this.needsUpdate=!1}}async renderAsync(){ut('RenderPipeline: "renderAsync()" has been deprecated. Use "render()" and "await renderer.init();" when creating the renderer.'),await this.renderer.init(),this.render()}},KW=class extends YW{constructor(e,t){ut('PostProcessing: "PostProcessing" has been renamed to "RenderPipeline". Please update your code to use "THREE.RenderPipeline" instead.'),super(e,t)}},g3=class{constructor(e,t){this.uid=e,this.cid=e.match(/^(.*):f(\d+)$/)[1],this.name=t,this.timestamp=0,this.cpu=0,this.gpu=0,this.fps=0,this.children=[],this.parent=null}},ZW=class extends g3{constructor(e,t,i,r){let s=t.name;s===""&&(t.isScene?s="Scene":t.isQuadMesh&&(s="QuadMesh")),super(e,s),this.scene=t,this.camera=i,this.renderTarget=r,this.isRenderStats=!0}},JW=class extends g3{constructor(e,t){super(e,t.name),this.computeNode=t,this.isComputeStats=!0}},QW=class extends Dv{constructor(){super(),this.currentFrame=null,this.currentRender=null,this.currentNodes=null,this.lastFrame=null,this.frames=[],this.framesLib={},this.maxFrames=512,this._lastFinishTime=0,this._resolveTimestampPromise=null,this.isRendererInspector=!0}getParent(){return this.currentRender||this.getFrame()}begin(){this.currentFrame=this._createFrame(),this.currentRender=this.currentFrame,this.currentNodes=[]}finish(){let e=performance.now(),t=this.currentFrame;t.finishTime=e,t.deltaTime=e-(this._lastFinishTime>0?this._lastFinishTime:e),this.addFrame(t),this.fps=this._getFPS(),this.lastFrame=t,this.currentFrame=null,this.currentRender=null,this.currentNodes=null,this._lastFinishTime=e}_getFPS(){let e=0,t=0;for(let i=this.frames.length-1;i>=0;i--){let r=this.frames[i];if(e++,t+=r.deltaTime,t>=1e3)break}return e*1e3/t}_createFrame(){return{frameId:this.nodeFrame.frameId,resolvedCompute:!1,resolvedRender:!1,deltaTime:0,startTime:performance.now(),finishTime:0,miscellaneous:0,children:[],renders:[],computes:[]}}getFrame(){return this.currentFrame||this.lastFrame}getFrameById(e){return this.framesLib[e]||null}resolveViewer(){}resolveFrame(){}async resolveTimestamp(){return this._resolveTimestampPromise===null&&(this._resolveTimestampPromise=new Promise(e=>{requestAnimationFrame(async()=>{let t=this.getRenderer();await t.resolveTimestampsAsync(Ur.COMPUTE),await t.resolveTimestampsAsync(Ur.RENDER);let i=t.backend.getTimestampFrames(Ur.COMPUTE),r=t.backend.getTimestampFrames(Ur.RENDER),s=[...new Set([...i,...r])];for(let n of s){let a=this.getFrameById(n);if(a!==null){if(a.resolvedCompute===!1)if(a.computes.length>0){if(i.includes(n)){for(let o of a.computes)t.backend.hasTimestamp(o.uid)?o.gpu=t.backend.getTimestamp(o.uid):(o.gpu=0,o.gpuNotAvailable=!0);a.resolvedCompute=!0}}else a.resolvedCompute=!0;if(a.resolvedRender===!1)if(a.renders.length>0){if(r.includes(n)){for(let o of a.renders)t.backend.hasTimestamp(o.uid)?o.gpu=t.backend.getTimestamp(o.uid):(o.gpu=0,o.gpuNotAvailable=!0);a.resolvedRender=!0}}else a.resolvedRender=!0;a.resolvedCompute===!0&&a.resolvedRender===!0&&this.resolveFrame(a)}}this._resolveTimestampPromise=null,e()})})),this._resolveTimestampPromise}get isAvailable(){return this.getRenderer()!==null}addFrame(e){if(this.frames.length>=this.maxFrames){let t=this.frames.shift();delete this.framesLib[t.frameId]}this.frames.push(e),this.framesLib[e.frameId]=e,this.isAvailable&&(this.resolveViewer(),this.resolveTimestamp())}inspect(e){let t=this.currentNodes;
430t===null?ut('RendererInspector: Unable to inspect node outside of frame scope. Use "renderer.setAnimationLoop()".'):t.push(e)}beginCompute(e,t){let i=this.getFrame();if(!i)return;let r=new JW(e,t);r.timestamp=performance.now(),r.parent=this.currentCompute||this.getParent(),i.computes.push(r),this.currentRender===null?i.children.push(r):this.currentRender.children.push(r),this.currentCompute=r}finishCompute(){if(!this.getFrame())return;let e=this.currentCompute;e.cpu=performance.now()-e.timestamp,this.currentCompute=e.parent.isComputeStats?e.parent:null}beginRender(e,t,i,r){let s=this.getFrame();if(!s)return;let n=new ZW(e,t,i,r);n.timestamp=performance.now(),n.parent=this.getParent(),s.renders.push(n),this.currentRender===null?s.children.push(n):this.currentRender.children.push(n),this.currentRender=n}finishRender(){if(!this.getFrame())return;let e=this.currentRender;e.cpu=performance.now()-e.timestamp,this.currentRender=e.parent}},eH=class{static init(){if(document.getElementById("profiler-styles"))return;let e=document.createElement("style");e.id="profiler-styles",e.textContent=`
431:root {
432	--profiler-bg: #1e1e24f5;
433	--profiler-header-bg: #2a2a33aa;
434	--profiler-header: #2a2a33;
435	--profiler-border: #4a4a5a;
436	--text-primary: #e0e0e0;
437	--text-secondary: #9a9aab;
438	--accent-color: #00aaff;
439	--color-green: #4caf50;
440	--color-yellow: #ffc107;
441	--color-red: #f44336;
442	--color-fps: rgb(63, 81, 181);
443	--color-call: rgba(255, 185, 34, 1);
444	--font-family: 'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
445	--font-mono: 'Fira Code', 'Courier New', Courier, monospace;
446}
447
448@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;
448600&family=Fira+Code&display=swap');
449
450#profiler-panel *, #profiler-toggle * {
451	text-transform: initial;
452	line-height: normal;
453	box-sizing: border-box;
454	-webkit-font-smoothing: antialiased;
455	-moz-osx-font-smoothing: grayscale;
456}
457
458#profiler-toggle {
459	position: fixed;
460	top: 15px;
461	right: 15px;
462	background-color: rgba(30, 30, 36, 0.85);
463	border: 1px solid #4a4a5a54;
464	border-radius: 12px 6px 6px 12px;
465	color: var(--text-primary);
466	cursor: pointer;
467	z-index: 1001;
468	transition: all 0.2s ease-in-out;
469	/*font-size: 14px;*/
470	font-size: 15px;
471	backdrop-filter: blur(8px);
472	box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
473	display: flex;
474	align-items: stretch;
475	padding: 0;
476	overflow: hidden;
477	font-family: var(--font-family);
478}
479
480#profiler-toggle.position-right.panel-open {
481	right: auto;
482	left: 15px;
483	border-radius: 6px 12px 12px 6px;
484	flex-direction: row-reverse;
485}
486
487#profiler-toggle.position-right.panel-open #builtin-tabs-container {
488	border-right: none;
489	border-left: 1px solid #262636;
490}
491
492#profiler-toggle:hover {
493	border-color: var(--accent-color);
494}
495
496#profiler-toggle.panel-open #toggle-icon {
497	background-color: rgba(0, 170, 255, 0.2);
498	color: var(--accent-color);
499}
500
501#toggle-icon {
502	display: flex;
503	align-items: center;
504	justify-content: center;
505	width: 40px;
506	font-size: 20px;
507	transition: background-color 0.2s;
508}
509
510#profiler-toggle:hover #toggle-icon {
511	background-color: rgba(255, 255, 255, 0.05);
512}
513
514#profiler-toggle.panel-open:hover #toggle-icon {
515	background-color: rgba(0, 170, 255, 0.3);
516}
517
518.toggle-separator {
519	width: 1px;
520	background-color: var(--profiler-border);
521}
522
523#toggle-text {
524	display: flex;
525	align-items: baseline;
526	padding: 8px 14px;
527	min-width: 80px;
528	justify-content: right;
529}
530
531#toggle-text .fps-label {
532	font-size: 0.7em;
533	margin-left: 10px;
534    color: #999;
535}
536
537#builtin-tabs-container {
538	display: flex;
539	align-items: stretch;
540	gap: 0;
541	border-right: 1px solid #262636;
542	order: -1;
543}
544
545.builtin-tab-btn {
546	background: transparent;
547	border: none;
548	color: var(--text-secondary);
549	cursor: pointer;
550	padding: 8px 14px;
551	font-family: var(--font-family);
552	font-size: 13px;
553	font-weight: 600;
554	transition: all 0.2s;
555	display: flex;
556	align-items: center;
557	justify-content: center;
558	min-width: 32px;
559	position: relative;
560}
561
562.builtin-tab-btn svg {
563	width: 20px;
564	height: 20px;
565	stroke: currentColor;
566}
567
568.builtin-tab-btn:hover {
569	background-color: rgba(255, 255, 255, 0.08);
570	color: var(--accent-color);
571}
572
573.builtin-tab-btn:active {
574	background-color: rgba(255, 255, 255, 0.12);
575}
576
577.builtin-tab-btn.active {
578	background-color: rgba(0, 170, 255, 0.2);
579	color: var(--accent-color);
580}
581
582.builtin-tab-btn.active:hover {
583	background-color: rgba(0, 170, 255, 0.3);
584}
585
586#profiler-mini-panel {
587	position: fixed;
588	top: 60px;
589	right: 15px;
590	background-color: rgba(30, 30, 36, 0.85);
591	border: 1px solid #4a4a5a54;
592	border-radius: 8px;
593	color: var(--text-primary);
594	z-index: 9999;
595	backdrop-filter: blur(8px);
596	box-shadow: 0 6px 24px rgba(0, 0, 0, 0.5);
597	font-family: var(--font-family);
598	font-size: 11px;
599	width: 350px;
600	max-height: calc(100vh - 100px);
601	overflow-y: auto;
602	overflow-x: hidden;
603	display: none;
604	opacity: 0;
605	transform: translateY(-10px) scale(0.98);
606	transition: opacity 0.25s cubic-bezier(0.4, 0, 0.2, 1), 
607	            transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
608}
609
610#profiler-mini-panel.position-right.panel-open {
611	right: auto;
612	left: 15px;
613}
614
615#profiler-mini-panel.visible {
616	display: block;
617	opacity: 1;
618	transform: translateY(0) scale(1);
619}
620
621#profiler-mini-panel::-webkit-scrollbar {
622	width: 6px;
623}
624
625#profiler-mini-panel::-webkit-scrollbar-track {
626	background: transparent;
627}
628
629#profiler-mini-panel::-webkit-scrollbar-thumb {
630	background: rgba(255, 255, 255, 0.15);
631	border-radius: 3px;
632	transition: background 0.2s;
633}
634
635#profiler-mini-panel::-webkit-scrollbar-thumb:hover {
636	background: rgba(255, 255, 255, 0.25);
637}
638
639.mini-panel-content {
640	padding: 0;
641	font-size: 11px;
642	line-height: 1.5;
643	font-family: var(--font-mono);
644	letter-spacing: 0.3px;
645	user-select: none;
646	-webkit-user-select: none;
647}
648
649.mini-panel-content .profiler-content {
650	display: block !important;
651	background: transparent;
652}
653
654.mini-panel-content .list-scroll-wrapper {
655	max-height: calc(100vh - 120px);
656	overflow-y: auto;
657	overflow-x: hidden;
658}
659
660.mini-panel-content .list-scroll-wrapper::-webkit-scrollbar {
661	width: 4px;
662}
663
664.mini-panel-content .list-scroll-wrapper::-webkit-scrollbar-track {
665	background: transparent;
666}
667
668.mini-panel-content .list-scroll-wrapper::-webkit-scrollbar-thumb {
669	background: rgba(255, 255, 255, 0.1);
670	border-radius: 2px;
671}
672
673.mini-panel-content .list-scroll-wrapper::-webkit-scrollbar-thumb:hover {
674	background: rgba(255, 255, 255, 0.2);
675}
676
677.mini-panel-content .parameters {
678	background: transparent;
679	border: none;
680	box-shadow: none;
681	padding: 4px;
682}
683
684.mini-panel-content .list-container.parameters {
685	padding: 2px 6px 0px 6px !important;
686}
687
688.mini-panel-content .list-header {
689	display: none;
690	padding: 2px 4px;
691	font-size: 11px;
692	font-weight: 600;
693	text-transform: uppercase;
694	letter-spacing: 0.5px;
695}
696
697.mini-panel-content .list-item {
698	border-bottom: 1px solid rgba(74, 74, 90, 0.2);
699	transition: background-color 0.15s;
700}
701
702.mini-panel-content .list-item:last-child {
703	border-bottom: none;
704}
705
706.mini-panel-content .list-item:hover {
707	background-color: rgba(255, 255, 255, 0.04);
708}
709
710.mini-panel-content .list-item.actionable:hover {
711	background-color: rgba(255, 255, 255, 0.06);
712	cursor: pointer;
713}
714
715/* Style adjustments for lil-gui look */
716.mini-panel-content .item-row {
717	padding: 3px 8px;
718	min-height: 24px;
719}
720
721.mini-panel-content .list-item-row {
722	padding: 1px 4px;
723	gap: 8px;
724	min-height: 21px;
725	align-items: center;
726}
727
728.mini-panel-content input[type="checkbox"] {
729	width: 12px;
730	height: 12px;
731}
732
733.mini-panel-content input[type="range"] {
734	height: 18px;
735}
736
737.mini-panel-content .value-number input,
738.mini-panel-content .value-slider input {
739	background-color: rgba(0, 0, 0, 0.3);
740	border: 1px solid rgba(74, 74, 90, 0.5);
741	font-size: 10px;
742}
743
744.mini-panel-content .value-number input:focus,
745.mini-panel-content .value-slider input:focus {
746	border-color: var(--accent-color);
747}
748
749.mini-panel-content .value-slider {
750	gap: 6px;
751}
752
753/* Compact nested items */
754.mini-panel-content .list-item .list-item {
755	margin-left: 8px;
756}
757
758.mini-panel-content .list-item .list-item .item-row,
759.mini-panel-content .list-item .list-item .list-item-row {
760	padding: 2px 6px;
761	min-height: 22px;
762}
763
764/* Compact collapsible headers */
765.mini-panel-content .collapsible .item-row,
766.mini-panel-content .list-item-row.collapsible {
767	padding: 2px 8px;
768	font-weight: 600;
769	min-height: 16px;
770	display: flex;
771	align-items: center;
772}
773
774.mini-panel-content .collapsible-icon {
775	font-size: 10px;
776	width: 14px;
777	height: 14px;
778}
779
780.mini-panel-content .param-control input[type="range"] {
781	height: 12px;
782	margin-top: 1px;
783	padding-top: 5px;
784	user-select: none;
785	-webkit-user-select: none;
786	outline: none;
787}
788
789.mini-panel-content .param-control input[type="range"]::-webkit-slider-thumb {
790	width: 14px;
791	height: 14px;
792	margin-top: -5px;
793	user-select: none;
794	-webkit-user-select: none;
795}
796
797.mini-panel-content .param-control input[type="range"]::-moz-range-thumb {
798	width: 14px;
799	height: 14px;
800	user-select: none;
801	-moz-user-select: none;
802}
803
804.mini-panel-content .list-children-container {
805	padding-left: 0;
806}
807
808.mini-panel-content .param-control input[type="number"] {
809	flex-basis: 60px !important;
810}
811
812.mini-panel-content .param-control {
813	align-items: center;
814}
815
816.mini-panel-content .param-control select {
817	font-size: 11px;
818}
819
820.mini-panel-content .list-item-wrapper {
821	margin-top: 0;
822	margin-bottom: 0;
823}
824
825#profiler-panel {
826	position: fixed;
827	z-index: 1001 !important;
828	bottom: 0;
829	left: 0;
830	right: 0;
831	height: 350px;
832	background-color: var(--profiler-bg);
833	backdrop-filter: blur(8px);
834	border-top: 2px solid var(--profiler-border);
835	color: var(--text-primary);
836	display: flex;
837	flex-direction: column;
838	z-index: 1000;
839	/*box-shadow: 0 -5px 25px rgba(0, 0, 0, 0.5);*/
840	transform: translateY(100%);
841	transition: transform 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94), height 0.3s ease-out, width 0.3s ease-out;
842	font-family: var(--font-mono);
843}
844
845#profiler-panel.resizing,
846#profiler-panel.dragging {
847	transition: none;
848}
849
850#profiler-panel.visible {
851	transform: translateY(0);
852}
853
854#profiler-panel.maximized {
855	height: 100vh;
856}
857
858/* Position-specific styles */
859#profiler-panel.position-top {
860	bottom: auto;
861	top: 0;
862	border-top: none;
863	border-bottom: 2px solid var(--profiler-border);
864	transform: translateY(-100%);
865}
866
867#profiler-panel.position-top.visible {
868	transform: translateY(0);
869}
870
871#profiler-panel.position-bottom {
872	/* Default position - already defined above */
873}
874
875#profiler-panel.position-left {
876	top: 0;
877	bottom: 0;
878	left: 0;
879	right: auto;
880	width: 350px;
881	height: 100%;
882	border-top: none;
883	border-right: 2px solid var(--profiler-border);
884	transform: translateX(-100%);
885}
886
887#profiler-panel.position-left.visible {
888	transform: translateX(0);
889}
890
891#profiler-panel.position-right {
892	top: 0;
893	bottom: 0;
894	left: auto;
895	right: 0;
896	width: 350px;
897	height: 100%;
898	border-top: none;
899	border-left: 2px solid var(--profiler-border);
900	transform: translateX(100%);
901}
902
903#profiler-panel.position-right.visible {
904	transform: translateX(0);
905}
906
907#profiler-panel.position-floating {
908	border: 2px solid var(--profiler-border);
909	border-radius: 8px;
910	box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
911	transform: none !important;
912	overflow: hidden;
913}
914
915#profiler-panel.position-floating.visible {
916	transform: none !important;
917}
918
919#profiler-panel.position-floating .profiler-header {
920	border-radius: 6px 6px 0 0;
921}
922
923#profiler-panel.position-floating .panel-resizer {
924	bottom: 0;
925	right: 0;
926	top: auto;
927	left: auto;
928	width: 16px;
929	height: 16px;
930	cursor: nwse-resize;
931	border-radius: 0 0 6px 0;
932}
933
934#profiler-panel.position-floating .panel-resizer::after {
935	content: '';
936	position: absolute;
937	right: 2px;
938	bottom: 2px;
939	width: 10px;
940	height: 10px;
941	background: linear-gradient(135deg, transparent 0%, transparent 45%, var(--profiler-border) 45%, var(--profiler-border) 55%, transparent 55%);
942}
943
944
945.panel-resizer {
946	position: absolute;
947	top: -2px;
948	left: 0;
949	width: 100%;
950	height: 5px;
951	cursor: ns-resize;
952	z-index: 1001;
953	touch-action: none;
954}
955
956#profiler-panel.position-top .panel-resizer {
957	top: auto;
958	bottom: -2px;
959}
960
961#profiler-panel.position-left .panel-resizer {
962	top: 0;
963	left: auto;
964	right: -2px;
965	width: 5px;
966	height: 100%;
967	cursor: ew-resize;
968}
969
970#profiler-panel.position-right .panel-resizer {
971	top: 0;
972	left: -2px;
973	right: auto;
974	width: 5px;
975	height: 100%;
976	cursor: ew-resize;
977}
978
979.profiler-header {
980	display: flex;
981	background-color: var(--profiler-header-bg);
982	border-bottom: 1px solid var(--profiler-border);
983	flex-shrink: 0;
984	justify-content: space-between;
985	align-items: stretch;
986
987	overflow-x: auto;
988	overflow-y: hidden;
989	width: calc(100% - 134px);
990	height: 38px;
991	user-select: none;
992	-webkit-user-select: none;
993}
994
995/* Adjust header width based on panel position */
996#profiler-panel.position-right .profiler-header,
997#profiler-panel.position-left .profiler-header {
998	width: calc(100% - 134px);
999}
1000
1001#profiler-panel.position-bottom .profiler-header,
1002#profiler-panel.position-top .profiler-header {
1003	width: calc(100% - 134px);
1004}
1005
1006/* Adjust header width when position toggle button is hidden (mobile) */
1007#profiler-panel.hide-position-toggle .profiler-header {
1008	width: calc(100% - 90px);
1009}
1010
1011/* ===== RULES FOR WHEN THERE ARE NO TABS ===== */
1012
1013/* Horizontal mode (bottom/top) without tabs */
1014#profiler-panel.position-bottom.no-tabs:not(.maximized),
1015#profiler-panel.position-top.no-tabs:not(.maximized) {
1016	height: 38px !important;
1017	min-height: 38px !important;
1018}
1019
1020#profiler-panel.position-bottom.no-tabs .profiler-header,
1021#profiler-panel.position-top.no-tabs .profiler-header {
1022	width: 100%;
1023	height: 38px;
1024	border-bottom: none;
1025}
1026
1027#profiler-panel.position-bottom.no-tabs .profiler-content-wrapper,
1028#profiler-panel.position-top.no-tabs .profiler-content-wrapper {
1029	display: none;
1030}
1031
1032#profiler-panel.position-bottom.no-tabs .panel-resizer,
1033#profiler-panel.position-top.no-tabs .panel-resizer {
1034	display: none;
1035}
1036
1037/* Vertical mode (right/left) without tabs */
1038#profiler-panel.position-right.no-tabs:not(.maximized),
1039#profiler-panel.position-left.no-tabs:not(.maximized) {
1040	width: 45px !important;
1041	min-width: 45px !important;
1042}
1043
1044/* Vertical layout for header when no tabs */
1045#profiler-panel.position-right.no-tabs .profiler-header,
1046#profiler-panel.position-left.no-tabs .profiler-header {
1047	width: 100%;
1048	flex-direction: column;
1049	height: 100%;
1050	border-bottom: none;
1051}
1052
1053/* Vertical layout for controls when no tabs */
1054#profiler-panel.position-right.no-tabs .profiler-controls,
1055#profiler-panel.position-left.no-tabs .profiler-controls {
1056	position: static;
1057	flex-direction: column-reverse;
1058	justify-content: flex-end;
1059	width: 100%;
1060	height: 100%;
1061	border-bottom: none;
1062	border-left: none;
1063	background: transparent;
1064}
1065
1066#profiler-panel.position-right.no-tabs .profiler-controls button,
1067#profiler-panel.position-left.no-tabs .profiler-controls button {
1068	width: 100%;
1069	height: 45px;
1070	border-left: none;
1071	border-top: none;
1072	border-bottom: 1px solid var(--profiler-border);
1073}
1074
1075#profiler-panel.position-right.no-tabs .profiler-content-wrapper,
1076#profiler-panel.position-left.no-tabs .profiler-content-wrapper {
1077	display: none;
1078}
1079
1080#profiler-panel.position-right.no-tabs .profiler-tabs,
1081#profiler-panel.position-left.no-tabs .profiler-tabs {
1082	display: none;
1083}
1084
1085#profiler-panel.position-right.no-tabs .panel-resizer,
1086#profiler-panel.position-left.no-tabs .panel-resizer {
1087	display: none;
1088}
1089
1090/* Hide position toggle on mobile without tabs */
1091#profiler-panel.hide-position-toggle.position-right.no-tabs:not(.maximized),
1092#profiler-panel.hide-position-toggle.position-left.no-tabs:not(.maximized) {
1093	width: 45px !important;
1094	min-width: 45px !important;
1095}
1096
1097/* Hide drag indicator on mobile devices */
1098#profiler-panel.hide-position-toggle .tab-btn.active::before {
1099	display: none;
1100}
1101
1102.profiler-header::-webkit-scrollbar {
1103	width: 8px;
1104	height: 8px;
1105}
1106
1107.profiler-header::-webkit-scrollbar-track {
1108	background: transparent;
1109}
1110
1111.profiler-header::-webkit-scrollbar-thumb {
1112	background-color: rgba(0, 0, 0, 0.25);
1113	border-radius: 10px;
1114	transition: background 0.3s ease;
1115}
1116
1117.profiler-header::-webkit-scrollbar-thumb:hover {
1118	background-color: rgba(0, 0, 0, 0.4);
1119}
1120
1121.profiler-header::-webkit-scrollbar-corner {
1122	background: transparent;
1123}
1124
1125#profiler-panel.dragging .profiler-header {
1126	cursor: grabbing !important;
1127}
1128
1129#profiler-panel.dragging {
1130	opacity: 0.8;
1131}
1132
1133.profiler-tabs {
1134	display: flex;
1135	cursor: grab;
1136	position: relative;
1137}
1138
1139.profiler-tabs:active {
1140	cursor: grabbing;
1141}
1142
1143.profiler-tabs::-webkit-scrollbar {
1144	width: 8px;
1145	height: 8px;
1146}
1147
1148.profiler-tabs::-webkit-scrollbar-track {
1149	background: transparent;
1150}
1151
1152.profiler-tabs::-webkit-scrollbar-thumb {
1153	background-color: rgba(0, 0, 0, 0.25);
1154	border-radius: 10px;
1155	transition: background 0.3s ease;
1156}
1157
1158.profiler-tabs::-webkit-scrollbar-thumb:hover {
1159	background-color: rgba(0, 0, 0, 0.4);
1160}
1161
1162.profiler-tabs::-webkit-scrollbar-corner {
1163	background: transparent;
1164}
1165
1166.profiler-controls {
1167	display: flex;
1168	position: absolute;
1169	right: 0;
1170	top: 0;
1171	height: 38px;
1172	background: var(--profiler-header-bg);
1173	border-bottom: 1px solid var(--profiler-border);
1174}
1175
1176.tab-btn {
1177	position: relative;
1178	background: transparent;
1179	border: none;
1180	/*border-right: 1px solid var(--profiler-border);*/
1181	color: var(--text-secondary);
1182	padding: 8px 18px;
1183	cursor: default;
1184	display: flex;
1185	align-items: center;
1186	font-family: var(--font-family);
1187	font-weight: 600;
1188	font-size: 14px;
1189	user-select: none;
1190	transition: opacity 0.2s, transform 0.2s;
1191	touch-action: none;
1192}
1193
1194.tab-btn.active {
1195	border-bottom: 2px solid var(--accent-color);
1196	color: white;
1197}
1198
1199.tab-btn.active::before {
1200	content: '\u22EE\u22EE';
1201	position: absolute;
1202	left: 3px;
1203	top: calc(50% - .1rem);
1204	transform: translateY(-50%);
1205	color: var(--profiler-border);
1206	font-size: 18px;
1207	letter-spacing: -2px;
1208	opacity: 0.6;
1209}
1210
1211.tab-btn.no-detach.active::before {
1212	display: none;
1213}
1214
1215#floating-btn,
1216#maximize-btn,
1217#hide-panel-btn {
1218	background: transparent;
1219	border: none;
1220	border-left: 1px solid var(--profiler-border);
1221	color: var(--text-secondary);
1222	width: 45px;
1223	height: 100%;
1224	cursor: pointer;
1225	transition: all 0.2s;
1226	display: flex;
1227	align-items: center;
1228	justify-content: center;
1229	flex-shrink: 0;
1230}
1231
1232/* Disable transitions in vertical mode to avoid broken animations */
1233#profiler-panel.position-right #floating-btn,
1234#profiler-panel.position-right #maximize-btn,
1235#profiler-panel.position-right #hide-panel-btn,
1236#profiler-panel.position-left #floating-btn,
1237#profiler-panel.position-left #maximize-btn,
1238#profiler-panel.position-left #hide-panel-btn {
1239	transition: background-color 0.2s, color 0.2s;
1240}
1241
1242#floating-btn:hover,
1243#maximize-btn:hover,
1244#hide-panel-btn:hover {
1245	background-color: rgba(255, 255, 255, 0.1);
1246	color: var(--text-primary);
1247}
1248
1249/* Hide maximize button when there are no tabs */
1250#profiler-panel.position-right.no-tabs #maximize-btn,
1251#profiler-panel.position-left.no-tabs #maximize-btn,
1252#profiler-panel.position-bottom.no-tabs #maximize-btn,
1253#profiler-panel.position-top.no-tabs #maximize-btn {
1254	display: none !important;
1255}
1256
1257.profiler-content-wrapper {
1258	flex-grow: 1;
1259	overflow: hidden;
1260	position: relative;
1261}
1262
1263.profiler-content {
1264	position: absolute;
1265	top: 0;
1266	left: 0;
1267	width: 100%;
1268	height: 100%;
1269	overflow-y: auto;
1270	font-size: 13px;
1271	visibility: hidden;
1272	opacity: 0;
1273	transition: opacity 0.2s, visibility 0.2s;
1274	box-sizing: border-box;
1275	display: flex;
1276	flex-direction: column;
1277	user-select: none;
1278	-webkit-user-select: none;
1279}
1280
1281.profiler-content.active {
1282	visibility: visible;
1283	opacity: 1;
1284}
1285
1286.profiler-content {
1287	overflow: auto; /* make sure scrollbars can appear */
1288}
1289
1290.profiler-content::-webkit-scrollbar {
1291	width: 8px;
1292	height: 8px;
1293}
1294
1295.profiler-content::-webkit-scrollbar-track {
1296	background: transparent;
1297}
1298
1299.profiler-content::-webkit-scrollbar-thumb {
1300	background-color: rgba(0, 0, 0, 0.25);
1301	border-radius: 10px;
1302	transition: background 0.3s ease;
1303}
1304
1305.profiler-content::-webkit-scrollbar-thumb:hover {
1306	background-color: rgba(0, 0, 0, 0.4);
1307}
1308
1309.profiler-content::-webkit-scrollbar-corner {
1310	background: transparent;
1311}
1312
1313.profiler-content {
1314	scrollbar-width: thin; /* "auto" | "thin" */
1315	scrollbar-color: rgba(0, 0, 0, 0.25) transparent;
1316}
1317
1318.list-item-row {
1319	display: grid;
1320	align-items: center;
1321	padding: 4px 8px;
1322	border-radius: 3px;
1323	transition: background-color 0.2s;
1324	gap: 10px;
1325	border-bottom: none;
1326	user-select: none;
1327	-webkit-user-select: none;
1328}
1329
1330.parameters .list-item-row {
1331	min-height: 31px;
1332}
1333
1334.mini-panel-content .parameters .list-item-row {
1335	min-height: 21px;
1336}
1337
1338.list-item-wrapper {
1339	margin-top: 2px;
1340	margin-bottom: 2px;
1341	user-select: none;
1342	-webkit-user-select: none;
1343}
1344
1345.list-item-wrapper:first-child {
1346	/*margin-top: 0;*/
1347}
1348
1349.list-item-wrapper:not(.header-wrapper):nth-child(odd) > .list-item-row {
1350	background-color: rgba(0,0,0,0.1);
1351}
1352
1353.list-item-wrapper.header-wrapper>.list-item-row {
1354	color: var(--accent-color);
1355	background-color: rgba(0, 170, 255, 0.1);
1356}
1357
1358.list-item-wrapper.header-wrapper>.list-item-row>.list-item-cell:first-child {
1359	font-weight: 600;
1360	line-height: 1;
1361}
1362
1363.list-item-row.collapsible,
1364.list-item-row.actionable {
1365	cursor: pointer;
1366}
1367
1368.list-item-row.collapsible {
1369	background-color: rgba(0, 170, 255, 0.15) !important;
1370	min-height: 23px;
1371}
1372
1373.list-item-row.collapsible.alert,
1374.list-item-row.alert {
1375	background-color: rgba(244, 67, 54, 0.1) !important;
1376}
1377
1378@media (hover: hover) {
1379
1380	.list-item-row:hover:not(.collapsible):not(.no-hover),
1381	.list-item-row:hover:not(.no-hover),
1382	.list-item-row.actionable:hover,
1383	.list-item-row.collapsible.actionable:hover {
1384		background-color: rgba(255, 255, 255, 0.05) !important;
1385	}
1386
1387	.list-item-row.collapsible:hover {
1388		background-color: rgba(0, 170, 255, 0.25) !important;
1389	}
1390
1391}
1392
1393.list-item-cell {
1394	white-space: pre;
1395	display: flex;
1396	align-items: center;
1397	user-select: none;
1398	-webkit-user-select: none;
1399}
1400
1401.list-item-cell:not(:first-child) {
1402	justify-content: flex-end;
1403	font-weight: 600;
1404}
1405
1406.list-header {
1407	display: grid;
1408	align-items: center;
1409	padding: 4px 8px;
1410	font-weight: 600;
1411	color: var(--text-secondary);
1412	padding-bottom: 6px;
1413	border-bottom: 1px solid var(--profiler-border);
1414	margin-bottom: 5px;
1415	gap: 10px;
1416	user-select: none;
1417	-webkit-user-select: none;
1418}
1419
1420.list-item-wrapper.section-start {
1421	margin-top: 5px;
1422	margin-bottom: 5px;
1423}
1424
1425.list-header .list-header-cell:not(:first-child) {
1426	text-align: right;
1427}
1428
1429.list-children-container {
1430	padding-left: 1.5em;
1431	overflow: hidden;
1432	transition: max-height 0.1s ease-out;
1433	margin-top: 2px;
1434}
1435
1436.list-children-container.closed {
1437	max-height: 0;
1438}
1439
1440.item-toggler {
1441	display: inline-block;
1442	margin-right: 0.8em;
1443	text-align: left;
1444}
1445
1446.list-item-row.open .item-toggler::before {
1447	content: '-';
1448}
1449
1450.list-item-row:not(.open) .item-toggler::before {
1451	content: '+';
1452}
1453
1454.list-item-cell .value.good {
1455	color: var(--color-green);
1456}
1457
1458.list-item-cell .value.warn {
1459	color: var(--color-yellow);
1460}
1461
1462.list-item-cell .value.bad {
1463	color: var(--color-red);
1464}
1465
1466.list-scroll-wrapper {
1467	overflow-x: auto;
1468	width: 100%;
1469	user-select: none;
1470	-webkit-user-select: none;
1471}
1472
1473.list-container.parameters .list-item-row:not(.collapsible) {
1474}
1475
1476.graph-container {
1477	width: 100%;
1478	box-sizing: border-box;
1479	padding: 8px 0;
1480	position: relative;
1481}
1482
1483.graph-svg {
1484	width: 100%;
1485	height: 80px;
1486	background-color: var(--profiler-header);
1487	border: 1px solid var(--profiler-border);
1488	border-radius: 4px;
1489}
1490
1491.graph-path {
1492	stroke-width: 2;
1493	fill-opacity: 0.4;
1494}
1495
1496.console-header {
1497	padding: 10px;
1498	border-bottom: 1px solid var(--profiler-border);
1499	display: flex;
1500	gap: 20px;
1501	flex-shrink: 0;
1502	align-items: center;
1503	justify-content: space-between;
1504}
1505
1506.console-buttons-group {
1507	display: flex;
1508	gap: 20px;
1509}
1510
1511.console-filter-input {
1512	background-color: var(--profiler-bg);
1513	border: 1px solid var(--profiler-border);
1514	color: var(--text-primary);
1515	border-radius: 4px;
1516	padding: 4px 8px;
1517	font-family: var(--font-mono);
1518	flex-grow: 1;
1519	max-width: 300px;
1520	border-radius: 15px;
1521}
1522
1523.console-filter-input:focus {
1524	outline: none;
1525	border-color: var(--text-secondary);
1526}
1527
1528.console-copy-button {
1529	background: transparent;
1530	border: none;
1531	color: var(--text-secondary);
1532	cursor: pointer;
1533	padding: 4px;
1534	display: flex;
1535	align-items: center;
1536	justify-content: center;
1537	border-radius: 4px;
1538	transition: color 0.2s, background-color 0.2s;
1539}
1540
1541.console-copy-button:hover {
1542	color: var(--text-primary);
1543	background-color: var(--profiler-hover);
1544}
1545
1546.console-copy-button.copied {
1547	color: var(--color-green);
1548}
1549
1550#console-log {
1551	display: flex;
1552	flex-direction: column;
1553	gap: 4px;
1554	padding: 10px;
1555	overflow-y: auto;
1556	flex-grow: 1;
1557	user-select: text;
1558	-webkit-user-select: text;
1559}
1560
1561.log-message {
1562	padding: 2px 5px;
1563	white-space: pre-wrap;
1564	word-break: break-all;
1565	border-radius: 3px;
1566	line-height: 1.5 !important;
1567}
1568
1569.log-message.hidden {
1570	display: none;
1571}
1572
1573.log-message.info {
1574	color: var(--text-primary);
1575}
1576
1577.log-message.warn {
1578	color: var(--color-yellow);
1579}
1580
1581.log-message.error {
1582	color: #f9dedc;
1583	background-color: rgba(244, 67, 54, 0.1);
1584}
1585
1586.log-prefix {
1587	color: var(--text-secondary);
1588	margin-right: 8px;
1589}
1590
1591.log-code {
1592	background-color: rgba(255, 255, 255, 0.1);
1593	border-radius: 3px;
1594	padding: 1px 4px;
1595}
1596
1597.thumbnail-container {
1598	display: flex;
1599	align-items: center;
1600}
1601
1602.thumbnail-svg {
1603	width: 40px;
1604	height: 22.5px;
1605	flex-shrink: 0;
1606	margin-right: 8px;
1607}
1608
1609.param-control {
1610	display: flex;
1611	align-items: center;
1612	justify-content: flex-end;
1613	gap: 10px;
1614	width: 100%;
1615}
1616
1617.param-control input,
1618.param-control select,
1619.param-control button {
1620	background-color: var(--profiler-bg);
1621	border: 1px solid var(--profiler-border);
1622	color: var(--text-primary);
1623	border-radius: 4px;
1624	padding: 4px 6px;
1625	padding-bottom: 2px;
1626	font-family: var(--font-mono);
1627	width: 100%;
1628	box-sizing: border-box;
1629}
1630
1631.param-control input:focus {
1632	outline: none;
1633	border-color: var(--accent-color);
1634}
1635
1636.param-control select {
1637	padding-top: 3px;
1638	padding-bottom: 1px;
1639}
1640
1641.param-control input[type="number"] {
1642	cursor: ns-resize;
1643}
1644
1645.param-control input[type="color"] {
1646	padding: 2px;
1647}
1648
1649.param-control button {
1650	cursor: pointer;
1651	transition: background-color 0.2s;
1652}
1653
1654.param-control button:hover {
1655	background-color: var(--profiler-header);
1656}
1657
1658.param-control-vector {
1659	display: flex;
1660	gap: 5px;
1661}
1662
1663.custom-checkbox {
1664	display: inline-flex;
1665	align-items: center;
1666	cursor: pointer;
1667	gap: 8px;
1668	will-change: transform;
1669}
1670
1671.custom-checkbox input {
1672	display: none;
1673}
1674
1675.custom-checkbox .checkmark {
1676	width: 14px;
1677	height: 14px;
1678	border: 1px solid var(--accent-color);
1679	border-radius: 3px;
1680	display: inline-flex;
1681	justify-content: center;
1682	align-items: center;
1683	transition: background-color 0.2s, border-color 0.2s;
1684}
1685
1686.custom-checkbox .checkmark::after {
1687	content: '';
1688	width: 6px;
1689	height: 6px;
1690	background-color: var(--accent-color);
1691	border-radius: 1px;
1692	display: block;
1693	transform: scale(0);
1694	transition: transform 0.2s;
1695}
1696
1697.custom-checkbox input:checked+.checkmark {
1698	border-color: var(--accent-color);
1699}
1700
1701.custom-checkbox input:checked+.checkmark::after {
1702	transform: scale(1);
1703}
1704
1705.param-control input[type="range"] {
1706	-webkit-appearance: none;
1707	appearance: none;
1708	width: 100%;
1709	height: 16px;
1710	background: var(--profiler-header);
1711	border-radius: 5px;
1712	border: 1px solid var(--profiler-border);
1713	outline: none;
1714	padding: 0px;
1715	padding-top: 8px;
1716}
1717
1718.param-control input[type="range"]::-webkit-slider-thumb {
1719	-webkit-appearance: none;
1720	appearance: none;
1721	width: 18px;
1722	height: 18px;
1723	background: var(--profiler-bg);
1724	border: 1px solid var(--accent-color);
1725	border-radius: 3px;
1726	cursor: pointer;
1727	margin-top: -8px;
1728}
1729
1730.param-control input[type="range"]::-moz-range-thumb {
1731	width: 18px;
1732	height: 18px;
1733	background: var(--profiler-bg);
1734	border: 2px solid var(--accent-color);
1735	border-radius: 3px;
1736	cursor: pointer;
1737}
1738
1739.param-control input[type="range"]::-moz-range-track {
1740	width: 100%;
1741	height: 16px;
1742	background: var(--profiler-header);
1743	border-radius: 5px;
1744	border: 1px solid var(--profiler-border);
1745}
1746
1747/* Override .param-control styles for mini-panel-content */
1748.mini-panel-content input,
1749.mini-panel-content select,
1750.mini-panel-content button {
1751	padding: 2px 4px;
1752	height: 21px;
1753	line-height: 1.4;
1754	padding-top: 4px;
1755}
1756
1757.mini-panel-content .param-control input,
1758.mini-panel-content .param-control select,
1759.mini-panel-content .param-control button {
1760	background-color: #1e1e24c2;
1761	line-height: 1.0;
1762}
1763
1764.mini-panel-content .param-control select {
1765	padding: 2px 2px;
1766	padding-top: 3px;
1767}
1768
1769.mini-panel-content .param-control input[type="number"]::-webkit-outer-spin-button,
1770.mini-panel-content .param-control input[type="number"]::-webkit-inner-spin-button {
1771	-webkit-appearance: none;
1772	margin: 0;
1773}
1774
1775.mini-panel-content .param-control input[type="number"] {
1776	-moz-appearance: textfield;
1777}
1778
1779.mini-panel-content .list-item-cell span {
1780	position: relative;
1781	top: 1px;
1782	margin-left: 2px;
1783}
1784
1785.mini-panel-content .custom-checkbox .checkmark {
1786	width: 12px;
1787	height: 12px;
1788	margin-bottom: 2px;
1789	will-change: transform;
1790}
1791
1792.mini-panel-content .list-container.parameters .list-item-row:not(.collapsible) {
1793	margin-bottom: 2px;
1794}
1795
1796@media screen and (max-width: 450px) and (orientation: portrait) {
1797
1798	.console-filter-input {
1799		max-width: 100px;
1800	}
1801
1802}
1803
1804/* Touch device optimizations */
1805@media (hover: none) and (pointer: coarse) {
1806
1807	.panel-resizer {
1808		top: -10px !important;
1809		height: 20px !important;
1810	}
1811
1812	#profiler-panel.position-top .panel-resizer {
1813		top: auto !important;
1814		bottom: -10px !important;
1815		height: 20px !important;
1816	}
1817
1818	#profiler-panel.position-left .panel-resizer {
1819		right: -10px !important;
1820		width: 20px !important;
1821		height: 100% !important;
1822	}
1823
1824	#profiler-panel.position-right .panel-resizer {
1825		left: -10px !important;
1826		width: 20px !important;
1827		height: 100% !important;
1828	}
1829
1830	.detached-tab-resizer-top,
1831	.detached-tab-resizer-bottom {
1832		height: 10px !important;
1833	}
1834
1835	.detached-tab-resizer-left,
1836	.detached-tab-resizer-right {
1837		width: 10px !important;
1838	}
1839
1840}
1841
1842.drag-preview-indicator {
1843	position: fixed;
1844	background-color: rgba(0, 170, 255, 0.2);
1845	border: 2px dashed var(--accent-color);
1846	z-index: 999;
1847	pointer-events: none;
1848	transition: all 0.2s ease-out;
1849}
1850
1851/* Detached Tab Windows */
1852.detached-tab-panel {
1853	position: fixed;
1854	width: 500px;
1855	height: 400px;
1856	background: var(--profiler-bg);
1857	border: 1px solid var(--profiler-border);
1858	border-radius: 8px;
1859	box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
1860	z-index: 1002;
1861	display: flex;
1862	flex-direction: column;
1863	backdrop-filter: blur(10px);
1864	overflow: hidden;
1865	opacity: 1;
1866	visibility: visible;
1867	transition: opacity 0.2s, visibility 0.2s;
1868}
1869
1870#profiler-panel:not(.visible) ~ * .detached-tab-panel,
1871body:has(#profiler-panel:not(.visible)) .detached-tab-panel {
1872	opacity: 0;
1873	visibility: hidden;
1874	pointer-events: none;
1875}
1876
1877.detached-tab-header {
1878	background: var(--profiler-header-bg);
1879	padding: 0 7px 0 15px;
1880	font-family: var(--font-family);
1881	font-size: 14px;
1882	color: var(--text-primary);
1883	font-weight: 600;
1884	display: flex;
1885	justify-content: space-between;
1886	align-items: center;
1887	border-bottom: 1px solid var(--profiler-border);
1888	cursor: grab;
1889	user-select: none;
1890	height: 38px;
1891	flex-shrink: 0;
1892	-webkit-font-smoothing: antialiased;
1893	-moz-osx-font-smoothing: grayscale;
1894	touch-action: none;
1895}
1896
1897.detached-tab-header:active {
1898	cursor: grabbing;
1899}
1900
1901.detached-header-controls {
1902	display: flex;
1903	gap: 5px;
1904}
1905
1906.detached-reattach-btn {
1907	background: transparent;
1908	border: none;
1909	color: var(--text-secondary);
1910	font-family: var(--font-family);
1911	font-size: 18px;
1912	line-height: 1;
1913	cursor: pointer;
1914	padding: 4px 8px;
1915	border-radius: 4px;
1916	transition: all 0.2s;
1917	display: flex;
1918	align-items: center;
1919	justify-content: center;
1920	-webkit-font-smoothing: antialiased;
1921	-moz-osx-font-smoothing: grayscale;
1922}
1923
1924.detached-reattach-btn:hover {
1925	background: rgba(0, 170, 255, 0.2);
1926	color: var(--accent-color);
1927}
1928
1929.detached-tab-content {
1930	flex: 1;
1931	overflow: auto;
1932	position: relative;
1933	background: var(--profiler-bg);
1934}
1935
1936.detached-tab-content::-webkit-scrollbar {
1937	width: 8px;
1938	height: 8px;
1939}
1940
1941.detached-tab-content::-webkit-scrollbar-track {
1942	background: transparent;
1943}
1944
1945.detached-tab-content::-webkit-scrollbar-thumb {
1946	background-color: rgba(0, 0, 0, 0.25);
1947	border-radius: 10px;
1948	transition: background 0.3s ease;
1949}
1950
1951.detached-tab-content::-webkit-scrollbar-thumb:hover {
1952	background-color: rgba(0, 0, 0, 0.4);
1953}
1954
1955.detached-tab-content::-webkit-scrollbar-corner {
1956	background: transparent;
1957}
1958
1959.detached-tab-content .profiler-content {
1960	display: block !important;
1961	height: 100%;
1962	visibility: visible !important;
1963	opacity: 1 !important;
1964	position: relative !important;
1965}
1966
1967.detached-tab-content .profiler-content > * {
1968	font-family: var(--font-mono);
1969	color: var(--text-primary);
1970}
1971
1972.detached-tab-resizer {
1973	position: absolute;
1974	bottom: 0;
1975	right: 0;
1976	width: 20px;
1977	height: 20px;
1978	cursor: nwse-resize;
1979	z-index: 10;
1980	touch-action: none;
1981}
1982
1983.detached-tab-resizer::after {
1984	content: '';
1985	position: absolute;
1986	bottom: 2px;
1987	right: 2px;
1988	width: 12px;
1989	height: 12px;
1990	border-right: 2px solid var(--profiler-border);
1991	border-bottom: 2px solid var(--profiler-border);
1992	border-bottom-right-radius: 6px;
1993	opacity: 0.5;
1994}
1995
1996.detached-tab-resizer:hover::after {
1997	opacity: 1;
1998	border-color: var(--accent-color);
1999}
2000
2001/* Edge resizers */
2002.detached-tab-resizer-top {
2003	position: absolute;
2004	top: 0;
2005	left: 0;
2006	right: 0;
2007	height: 5px;
2008	cursor: ns-resize;
2009	z-index: 10;
2010	touch-action: none;
2011}
2012
2013.detached-tab-resizer-right {
2014	position: absolute;
2015	top: 0;
2016	right: 0;
2017	bottom: 0;
2018	width: 5px;
2019	cursor: ew-resize;
2020	z-index: 10;
2021	touch-action: none;
2022}
2023
2024.detached-tab-resizer-bottom {
2025	position: absolute;
2026	bottom: 0;
2027	left: 0;
2028	right: 0;
2029	height: 5px;
2030	cursor: ns-resize;
2031	z-index: 10;
2032	touch-action: none;
2033}
2034
2035.detached-tab-resizer-left {
2036	position: absolute;
2037	top: 0;
2038	left: 0;
2039	bottom: 0;
2040	width: 5px;
2041	cursor: ew-resize;
2042	z-index: 10;
2043	touch-action: none;
2044}
2045
2046/* Input number spin buttons - hide arrows */
2047/* Chrome, Safari, Edge, Opera */
2048#profiler-panel input[type="number"]::-webkit-outer-spin-button,
2049#profiler-panel input[type="number"]::-webkit-inner-spin-button,
2050.detached-tab-content input[type="number"]::-webkit-outer-spin-button,
2051.detached-tab-content input[type="number"]::-webkit-inner-spin-button {
2052	-webkit-appearance: none;
2053	margin: 0;
2054}
2055
2056/* Firefox */
2057#profiler-panel input[type="number"],
2058.detached-tab-content input[type="number"] {
2059	-moz-appearance: textfield;
2060}
2061
2062.panel-action-btn {
2063	background: transparent;
2064	color: var(--text-primary);
2065	border: 1px solid var(--profiler-border);
2066	border-radius: 4px;
2067	padding: 6px 12px;
2068	cursor: pointer;
2069	font-family: var(--font-family);
2070	font-size: 12px;
2071	transition: background-color 0.2s;
2072	display: flex;
2073	align-items: center;
2074	justify-content: center;
2075}
2076
2077.panel-action-btn:hover {
2078	background-color: rgba(255, 255, 255, 0.05);
2079}
2080`,document.head.appendChild(e)}},tH=class extends Ds{constructor(){super(),this.tabs={},this.activeTabId=null,this.isResizing=!1,this.lastHeightBottom=350,this.lastWidthRight=450,this.position="bottom",this.detachedWindows=[],this.isMobile=this.detectMobile(),this.maxZIndex=1002,this.nextTabOriginalIndex=0,eH.init(),this.setupShell(),this.setupResizing(),this.isMobile&&this.setupOrientationListener(),this.setupWindowResizeListener()}getSize(){return this.panel.classList.contains("visible")===!1||this.panel.classList.contains("no-tabs")?{width:0,height:0}:this.position==="right"?{width:this.panel.offsetWidth,height:0}:{width:0,height:this.panel.offsetHeight}}detectMobile(){let e=navigator.userAgent||navigator.vendor||window.opera,t=/android|webos|iphone|ipad|ipod|blackberry|iemobile|opera mini/i.test(e),i="ontouchstart"in window||navigator.maxTouchPoints>0,r=window.innerWidth<=768;return t||i&&r}setupOrientationListener(){let e=()=>{let t=window.innerWidth>window.innerHeight?"right":"bottom";this.position!==t&&this.setPosition(t)};e(),window.addEventListener("orientationchange",e),window.addEventListener("resize",e)}setupWindowResizeListener(){let e=()=>{this.detachedWindows.forEach(i=>{this.constrainWindowToBounds(i.panel)})},t=()=>{if(this.panel.classList.contains("maximized"))return;let i=window.innerWidth,r=window.innerHeight;if(this.position==="bottom"){let s=this.panel.offsetHeight,n=r-50;s>n&&(this.panel.style.height=`${n}px`,this.lastHeightBottom=n)}else if(this.position==="right"){let s=this.panel.offsetWidth,n=i-50;s>n&&(this.panel.style.width=`${n}px`,this.lastWidthRight=n)}};window.addEventListener("resize",()=>{e(),t()})}constrainWindowToBounds(e){let t=window.innerWidth,i=window.innerHeight,r=e.offsetWidth,s=e.offsetHeight,n=parseFloat(e.style.left)||e.offsetLeft||0,a=parseFloat(e.style.top)||e.offsetTop||0,o=r/2,l=s/2;n+r>t+o&&(n=t+o-r),n<-o&&(n=-o),a+s>i+l&&(a=i+l-s),a<-l&&(a=-l),e.style.left=`${n}px`,e.style.top=`${a}px`}setupShell(){this.domElement=document.createElement("div"),this.domElement.id="profiler-shell",this.toggleButton=document.createElement("button"),this.toggleButton.id="profiler-toggle",this.toggleButton.innerHTML=`
2081<span id="builtin-tabs-container"></span>
2082<span id="toggle-text">
2083	<span id="fps-counter">-</span>
2084	<span class="fps-label">FPS</span>
2085</span>
2086<span id="toggle-icon">
2087	<svg  xmlns="http://www.w3.org/2000/svg"  width="24"  height="24"  viewBox="0 0 24 24"  fill="none"  stroke="currentColor"  stroke-width="2"  stroke-linecap="round"  stroke-linejoin="round"  class="icon icon-tabler icons-tabler-outline icon-tabler-device-ipad-horizontal-search"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M11.5 20h-6.5a2 2 0 0 1 -2 -2v-12a2 2 0 0 1 2 -2h14a2 2 0 0 1 2 2v5.5" /><path d="M9 17h2" /><path d="M18 18m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0" /><path d="M20.2 20.2l1.8 1.8" /></svg>
2088</span>
2089`,this.toggleButton.onclick=()=>this.togglePanel(),this.builtinTabsContainer=this.toggleButton.querySelector("#builtin-tabs-container"),this.miniPanel=document.createElement("div"),this.miniPanel.id="profiler-mini-panel",this.miniPanel.className="profiler-mini-panel",this.panel=document.createElement("div"),this.panel.id="profiler-panel";let e=document.createElement("div");e.className="profiler-header",this.tabsContainer=document.createElement("div"),this.tabsContainer.className="profiler-tabs";let t=document.createElement("div");
2089t.className="profiler-controls",this.floatingBtn=document.createElement("button"),this.floatingBtn.id="floating-btn",this.floatingBtn.title="Switch to Right Side",this.floatingBtn.innerHTML='<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="2" ry="2"></rect><line x1="15" y1="3" x2="15" y2="21"></line></svg>',this.floatingBtn.onclick=()=>this.togglePosition(),this.isMobile&&(this.floatingBtn.style.display="none",this.panel.classList.add("hide-position-toggle")),this.maximizeBtn=document.createElement("button"),this.maximizeBtn.id="maximize-btn",this.maximizeBtn.innerHTML='<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M8 3H5a2 2 0 0 0-2 2v3m18 0V5a2 2 0 0 0-2-2h-3m0 18h3a2 2 0 0 0 2-2v-3M3 16v3a2 2 0 0 0 2 2h3"/></svg>',this.maximizeBtn.onclick=()=>this.toggleMaximize();let i=document.createElement("button");i.id="hide-panel-btn",i.textContent="-",i.onclick=()=>this.togglePanel(),t.append(this.floatingBtn,this.maximizeBtn,i),e.append(this.tabsContainer,t),this.contentWrapper=document.createElement("div"),this.contentWrapper.className="profiler-content-wrapper";let r=document.createElement("div");r.className="panel-resizer",this.panel.append(r,e,this.contentWrapper),this.domElement.append(this.toggleButton,this.miniPanel,this.panel),this.panel.classList.add(`position-${this.position}`),this.position==="right"&&(this.toggleButton.classList.add("position-right"),this.miniPanel.classList.add("position-right"))}setupResizing(){let e=this.panel.querySelector(".panel-resizer");e.addEventListener("pointerdown",t=>{this.isResizing=!0,this.panel.classList.add("resizing"),e.setPointerCapture(t.pointerId);let i=t.clientX,r=t.clientY,s=this.panel.offsetHeight,n=this.panel.offsetWidth,a=l=>{if(!this.isResizing)return;l.preventDefault();let h=l.clientX,u=l.clientY;if(this.position==="bottom"){let d=s-(u-r);d>100&&d<window.innerHeight-50&&(this.panel.style.height=`${d}px`)}else if(this.position==="right"){let d=n-(h-i);d>200&&d<window.innerWidth-50&&(this.panel.style.width=`${d}px`)}this.dispatchEvent({type:"resize"})},o=()=>{this.isResizing=!1,this.panel.classList.remove("resizing"),e.removeEventListener("pointermove",a),e.removeEventListener("pointerup",o),e.removeEventListener("pointercancel",o),this.panel.classList.contains("maximized")||(this.position==="bottom"?this.lastHeightBottom=this.panel.offsetHeight:this.position==="right"&&(this.lastWidthRight=this.panel.offsetWidth),this.saveLayout())};e.addEventListener("pointermove",a),e.addEventListener("pointerup",o),e.addEventListener("pointercancel",o)})}toggleMaximize(){this.panel.classList.contains("maximized")?(this.panel.classList.remove("maximized"),this.position==="bottom"?(this.panel.style.height=`${this.lastHeightBottom}px`,this.panel.style.width="100%"):this.position==="right"&&(this.panel.style.height="100%",this.panel.style.width=`${this.lastWidthRight}px`),this.maximizeBtn.innerHTML='<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M8 3H5a2 2 0 0 0-2 2v3m18 0V5a2 2 0 0 0-2-2h-3m0 18h3a2 2 0 0 0 2-2v-3M3 16v3a2 2 0 0 0 2 2h3"/></svg>'):(this.position==="bottom"?this.lastHeightBottom=this.panel.offsetHeight:this.position==="right"&&(this.lastWidthRight=this.panel.offsetWidth),this.panel.classList.add("maximized"),this.position==="bottom"?(this.panel.style.height="100vh",this.panel.style.width="100%"):this.position==="right"&&(this.panel.style.height="100%",this.panel.style.width="100vw"),this.maximizeBtn.innerHTML='<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="8" y="8" width="12" height="12" rx="2" ry="2"></rect><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"></path></svg>'),this.dispatchEvent({type:"resize"})}hide(){this.miniPanel.classList.remove("visible"),this.miniPanel.querySelectorAll(".mini-panel-content").forEach(e
2089=>{e.style.display="none"}),this.builtinTabsContainer.querySelectorAll(".builtin-tab-btn").forEach(e=>{e.classList.remove("active")})}show(e){if(this.hide(),e.builtinButton.classList.add("active"),!e.miniContent.firstChild){let t=e.content.querySelector(".list-scroll-wrapper")||e.content.firstElementChild;t&&e.miniContent.appendChild(t)}e.miniContent.style.display="block",this.miniPanel.classList.add("visible")}addTab(e){this.tabs[e.id]=e,e.originalIndex=this.nextTabOriginalIndex++,e.allowDetach===!1&&e.button.classList.add("no-detach"),e.onVisibilityChange=()=>this.updatePanelSize(),this.setupTabDragAndDrop(e),e.builtin||this.tabsContainer.appendChild(e.button),this.contentWrapper.appendChild(e.content),e.isVisible||(e.button.style.display="none",e.content.style.display="none"),e.builtin&&this.addBuiltinTab(e),this.updatePanelSize()}addBuiltinTab(e){let t=document.createElement("button");t.className="builtin-tab-btn",e.icon?t.innerHTML=e.icon:t.textContent=e.button.textContent.charAt(0).toUpperCase(),t.title=e.button.textContent;let i=document.createElement("div");i.className="mini-panel-content",i.style.display="none",e.builtinButton=t,e.miniContent=i,this.miniPanel.appendChild(i),t.onclick=r=>{r.stopPropagation(),i.style.display!=="none"&&i.children.length>0?this.hide():this.show(e)},this.builtinTabsContainer.appendChild(t),e.builtinButton=t,e.miniContent=i,e.profiler=this,e.isVisible||(t.style.display="none",i.style.display="none",Array.from(this.builtinTabsContainer.querySelectorAll(".builtin-tab-btn")).some(r=>r.style.display!=="none")||(this.builtinTabsContainer.style.display="none"))}updatePanelSize(){Object.values(this.tabs).some(e=>!e.isDetached&&e.isVisible)?(this.panel.classList.remove("no-tabs"),Object.keys(this.tabs).length>0&&(this.position==="bottom"?parseInt(this.panel.style.height)===38&&(this.panel.style.height=`${this.lastHeightBottom}px`):this.position==="right"&&parseInt(this.panel.style.width)===45&&(this.panel.style.width=`${this.lastWidthRight}px`))):(this.panel.classList.add("no-tabs"),this.panel.classList.contains("maximized")&&(this.panel.classList.remove("maximized"),this.maximizeBtn.innerHTML='<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M8 3H5a2 2 0 0 0-2 2v3m18 0V5a2 2 0 0 0-2-2h-3m0 18h3a2 2 0 0 0 2-2v-3M3 16v3a2 2 0 0 0 2 2h3"/></svg>'),this.position==="bottom"?this.panel.style.height="38px":this.position==="right"&&(this.panel.style.width="45px")),this.dispatchEvent({type:"resize"})}setupTabDragAndDrop(e){if(this.isMobile){e.button.addEventListener("click",()=>{this.setActiveTab(e.id)});return}if(e.allowDetach===!1){e.button.addEventListener("click",()=>{this.setActiveTab(e.id)}),e.button.style.cursor="default";return}let t=!1,i,r,s=!1,n=null,a=h=>{i=h.clientX,r=h.clientY,t=!1,s=!1,e.button.setPointerCapture(h.pointerId)},o=h=>{let u=h.clientX,d=h.clientY,c=Math.abs(u-i),p=Math.abs(d-r);!t&&(c>10||p>10)&&(t=!0,e.button.style.cursor="grabbing",e.button.style.opacity="0.5",e.button.style.transform="scale(1.05)",n=this.createPreviewWindow(e,u,d),n.style.opacity="0.8"),t&&n&&(s=!0,h.preventDefault(),n.style.left=`${u-200}px`,n.style.top=`${d-20}px`)},l=()=>{if(t&&s&&n){n.parentNode&&n.parentNode.removeChild(n);let h=parseInt(n.style.left)+200,u=parseInt(n.style.top)+20;this.detachTab(e,h,u)}else s||this.setActiveTab(e.id),n&&n.parentNode&&n.parentNode.removeChild(n);e.button.style.opacity="",e.button.style.transform="",e.button.style.cursor="",t=!1,s=!1,n=null,e.button.removeEventListener("pointermove",o),e.button.removeEventListener("pointerup",l),e.button.removeEventListener("pointercancel",l)};e.button.addEventListener("pointerdown",h=>{a(h),e.button.addEventListener("pointermove",o),e.button.addEventListener("pointerup",l),e.button.addEventListener("pointercancel",l)}),e.button.style.cursor="grab"}createPreviewWindow(e,t,i){let r=document.createElement("div");r.className="detached-tab-panel",r.style.left=`${t-200}px`,r.style.top=`${i-20}px`,r.style.pointerEvents="none",this.maxZIndex++,r.style.setProperty("z-index",this.maxZIndex,"important");let s=document.createElement("div");s.className="detached-tab-header";let n=document.createElement("span");n.textContent=e.button.textContent.replace("\u21F1","").trim(),s.appendChild(n);let a=document.createElement("div");
2089a.className="detached-header-controls";let o=document.createElement("button");o.className="detached-reattach-btn",o.innerHTML="\u21A9",a.appendChild(o),s.appendChild(a);let l=document.createElement("div");l.className="detached-tab-content";let h=document.createElement("div");return h.className="detached-tab-resizer",r.appendChild(h),r.appendChild(s),r.appendChild(l),document.body.appendChild(r),r}detachTab(e,t,i){if(e.isDetached||e.allowDetach===!1)return;let r=Array.from(this.tabsContainer.children).map(o=>Object.keys(this.tabs).find(l=>this.tabs[l].button===o)).filter(o=>o!==void 0),s=r.indexOf(e.id),n=null;if(this.activeTabId===e.id){e.setActive(!1);let o=r.filter(l=>l!==e.id&&!this.tabs[l].isDetached&&this.tabs[l].isVisible);if(o.length>0){for(let l=s-1;l>=0;l--)if(o.includes(r[l])){n=r[l];break}if(!n){for(let l=s+1;l<r.length;l++)if(o.includes(r[l])){n=r[l];break}}n||=o[0]}}e.button.parentNode&&e.button.parentNode.removeChild(e.button),e.content.parentNode&&e.content.parentNode.removeChild(e.content);let a=this.createDetachedWindow(e,t,i);
2089this.detachedWindows.push(a),e.isDetached=!0,e.detachedWindow=a,n?this.setActiveTab(n):this.activeTabId===e.id&&(this.activeTabId=null),this.updatePanelSize(),this.saveLayout()}createDetachedWindow(e,t,i){let r=window.innerWidth,s=window.innerHeight,n=t-200,a=i-20;n+400>r&&(n=r-400),n<0&&(n=0),a+300>s&&(a=s-300),a<0&&(a=0);let o=document.createElement("div");o.className="detached-tab-panel",o.style.left=`${n}px`,o.style.top=`${a}px`,this.panel.classList.contains("visible")||(o.style.opacity="0",o.style.visibility="hidden",o.style.pointerEvents="none"),e.isVisible||(o.style.display="none");let l=document.createElement("div");l.className="detached-tab-header";let h=document.createElement("span");h.textContent=e.button.textContent.replace("\u21F1","").trim(),l.appendChild(h);let u=document.createElement("div");u.className="detached-header-controls";let d=document.createElement("button");d.className="detached-reattach-btn",d.innerHTML="\u21A9",d.title="Reattach to main panel",d.onclick=()=>this.reattachTab(e),u.appendChild(d),l.appendChild(u);let c=document.createElement("div");c.className="detached-tab-content",c.appendChild(e.content),e.content.style.display="block",e.content.classList.add("active");let p=document.createElement("div");p.className="detached-tab-resizer-top";let m=document.createElement("div");m.className="detached-tab-resizer-right";let g=document.createElement("div");g.className="detached-tab-resizer-bottom";let f=document.createElement("div");f.className="detached-tab-resizer-left";let y=document.createElement("div");return y.className="detached-tab-resizer",o.appendChild(p),o.appendChild(m),o.appendChild(g),o.appendChild(f),o.appendChild(y),o.appendChild(l),o.appendChild(c),document.body.appendChild(o),this.setupDetachedWindowDrag(o,l,e),this.setupDetachedWindowResize(o,p,m,g,f,y),o.style.setProperty("z-index",this.maxZIndex,"important"),{panel:o,tab:e}}bringWindowToFront(e){this.maxZIndex++,e.style.setProperty("z-index",this.maxZIndex,"important")}setupDetachedWindowDrag(e,t,i){let r=!1,s,n,a,o;e.addEventListener("pointerdown",()=>{this.bringWindowToFront(e)});let l=d=>{if(d.target.classList.contains("detached-reattach-btn"))return;this.bringWindowToFront(e),r=!0,t.style.cursor="grabbing",t.setPointerCapture(d.pointerId),s=d.clientX,n=d.clientY;let c=e.getBoundingClientRect();a=c.left,o=c.top},h=d=>{if(!r)return;d.preventDefault();let c=d.clientX,p=d.clientY,m=c-s,g=p-n,f=a+m,y=o+g,x=window.innerWidth,b=window.innerHeight,_=e.offsetWidth,T=e.offsetHeight,w=_/2,M=T/2;f+_>x+w&&(f=x+w-_),f<-w&&(f=-w),y+T>b+M&&(y=b+M-T),y<-M&&(y=-M),e.style.left=`${f}px`,e.style.top=`${y}px`;let S=this.panel.getBoundingClientRect();c>=S.left&&c<=S.right&&p>=S.top&&p<=S.bottom?(e.style.opacity="0.5",this.panel.style.outline="2px solid var(--accent-color)"):(e.style.opacity="",this.panel.style.outline="")},u=d=>{if(!r)return;r=!1,t.style.cursor="",e.style.opacity="",this.panel.style.outline="";let c=d.clientX,p=d.clientY;if(c!==void 0&&p!==void 0){let m=this.panel.getBoundingClientRect();c>=m.left&&c<=m.right&&p>=m.top&&p<=m.bottom&&i?this.reattachTab(i):this.saveLayout()}t.removeEventListener("pointermove",h),t.removeEventListener("pointerup",u),t.removeEventListener("pointercancel",u)};t.addEventListener("pointerdown",d=>{l(d),t.addEventListener("pointermove",h),t.addEventListener("pointerup",u),t.addEventListener("pointercancel",u)}),t.style.cursor="grab"}setupDetachedWindowResize(e,t,i,r,s,n){let a=(o,l)=>{let h=!1,u,d,c,p,m,g,f=b=>{b.preventDefault(),b.stopPropagation(),h=!0,this.bringWindowToFront(e),o.setPointerCapture(b.pointerId),u=b.clientX,d=b.clientY,c=e.offsetWidth,p=e.offsetHeight,m=e.offsetLeft,g=e.offsetTop},y=b=>{if(!h)return;b.preventDefault();let _=b.clientX,T=b.clientY,w=_-u,M=T-d,S=window.innerWidth,R=window.innerHeight;if(l==="right"||l==="corner"){let I=c+w,B=S-m;I>=250&&I<=B&&(e.style.width=`${I}px`)}if(l==="bottom"||l==="corner"){let I=p+M,B=R-g;I>=150&&I<=B&&(e.style.height=`${I}px`)}if(l==="left"){let I=c-w,B=m+c-250;if(I>=250){let O=m+w;O>=0&&O<=B&&(e.style.width=`${I}px`,e.style.left=`${O}px`)}}if(l==="top"){let I=p-M,B=g+p-150;if(I>=150){let O=g+M;O>=0&&O<=B&&(e.style.height=`${I}px`,e.style.top=`${O}px`)}}},x=()=>{h=!1,o.removeEventListener("pointermove",y),o.removeEventListener("pointerup",x),o.removeEventListener("pointercancel",x),this.saveLayout()};o.addEventListener("pointerdown",b=>{f(b),o.addEventListener("pointermove",y),o.addEventListener("pointerup",x),o.addEventListener("pointercancel",x)})};a(t,"top"),a(i,"right"),a(r,"bottom"),a(s,"left"),a(n,"corner")}reattachTab(e){if(!e.isDetached)return;if(e.detachedWindow){let s=this.detachedWindows.indexOf(e.detachedWindow);s>-1&&this.detachedWindows.splice(s,1),e.detachedWindow.panel.parentNode&&e.detachedWindow.panel.parentNode.removeChild(e.detachedWindow.panel),e.detachedWindow=null}e.isDetached=!1;let t=Object.values(this.tabs).filter(s=>s.originalIndex!==void 0&&s.isVisible).sort((s,n)=>s.originalIndex-n.originalIndex),i=Array.from(this.tabsContainer.children),r=0;for(let s of t){if(s.id===e.id)break;s.isDetached||r++}r>=i.length||i.length===0?this.tabsContainer.appendChild(e.button):this.tabsContainer.insertBefore(e.button,i[r]),this.contentWrapper.appendChild(e.content),this.setActiveTab(e.id),this.updatePanelSize(),this.saveLayout()}setActiveTab(e){this.activeTabId&&this.tabs[this.activeTabId]&&!this.tabs[this.activeTabId].isDetached&&this.tabs[this.activeTabId].setActive(!1),this.activeTabId=e,this.tabs[e]&&this.tabs[e].setActive(!0),this.saveLayout()}togglePanel(){this.panel.classList.toggle("visible"),this.toggleButton.classList.toggle("panel-open"),this.miniPanel.classList.toggle("panel-open");let e=this.panel.classList.contains("visible");this.detachedWindows.forEach(t=>{e?(t.panel.style.opacity="",t.panel.style.visibility="",t.panel.style.pointerEvents=""):(t.panel.style.opacity="0",t.panel.style.visibility="hidden",t.panel.style.pointerEvents="none")}),this.dispatchEvent({type:"resize"}),this.saveLayout()}togglePosition(){let e=this.position==="bottom"?"right":"bottom";this.setPosition(e)}setPosition(e){if(this.position===e)return;this.panel.style.transition="none";let t=this.panel.classList.contains("maximized");e==="right"?(this.position="right",this.floatingBtn.classList.add("active"),this.floatingBtn.innerHTML='<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="2" ry="2"></rect><path d="M3 15h18"></path></svg>',this.floatingBtn.title="Switch to Bottom",this.panel.classList.remove("position-bottom"),this.panel.classList.add("position-right"),this.toggleButton.classList.add("position-right"),this.miniPanel.classList.add("position-right"),this.panel.style.bottom="",this.panel.style.top="0",this.panel.style.right="0",this.panel.style.left="",t?(this.panel.style.width="100vw",this.panel.style.height="100%"):(this.panel.style.width=`${this.lastWidthRight}px`,this.panel.style.height="100%")):(this.position="bottom",this.floatingBtn.classList.remove("active"),this.floatingBtn.innerHTML='<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="2" ry="2"></rect><line x1="15" y1="3" x2="15" y2="21"></line></svg>',this.floatingBtn.title="Switch to Right Side",this.panel.classList.remove("position-right"),this.panel.classList.add("position-bottom"),this.toggleButton.classList.remove("position-right"),this.miniPanel.classList.remove("position-right"),this.panel.style.top="",this.panel.style.right="",this.panel.style.bottom="0",this.panel.style.left="0",t?(this.panel.style.width="100%",this.panel.style.height="100vh"):(this.panel.style.width="100%",this.panel.style.height=`${this.lastHeightBottom}px`)),setTimeout(()=>{this.panel.style.transition=""},50),this.updatePanelSize(),this.saveLayout()}saveLayout(){if(this.isLoadingLayout)return;let e={position:this.position,lastHeightBottom:this.lastHeightBottom,lastWidthRight:this.lastWidthRight,activeTabId:this.activeTabId,detachedTabs:[],isVisible:this.panel.classList.contains("visible")};this.detachedWindows.forEach(t=>{let i=t.tab,r=t.panel,s=parseFloat(r.style.left)||r.offsetLeft||0,n=parseFloat(r.style.top)||r.offsetTop||0,a=r.offsetWidth,o=r.offsetHeight;e.detachedTabs.push({tabId:i.id,originalIndex:i.originalIndex===void 0?0:i.originalIndex,left:s,top:n,width:a,height:o})});try{let t=localStorage.getItem("threejs-inspector"),i=JSON.parse(t||"{}");
2089i.layout=e,localStorage.setItem("threejs-inspector",JSON.stringify(i))}catch(t){console.warn("Failed to save profiler layout:",t)}}loadLayout(){this.isLoadingLayout=!0;try{let e=localStorage.getItem("threejs-inspector");if(!e)return;let t=JSON.parse(e).layout;if(!t)return;if(t.detachedTabs&&t.detachedTabs.length>0){let s=window.innerWidth,n=window.innerHeight;t.detachedTabs=t.detachedTabs.map(a=>{let{left:o,top:l,width:h,height:u}=a;h>s&&(h=s-100),u>n&&(u=n-100);let d=h/2,c=u/2;return o+h>s+d&&(o=s+d-h),o<-d&&(o=-d),l+u>n+c&&(l=n+c-u),l<-c&&(l=-c),{...a,left:o,top:l,width:h,height:u}})}t.position&&(this.position=t.position),t.lastHeightBottom&&(this.lastHeightBottom=t.lastHeightBottom),t.lastWidthRight&&(this.lastWidthRight=t.lastWidthRight);let i=window.innerWidth,r=window.innerHeight;this.lastHeightBottom>r-50&&(this.lastHeightBottom=r-50),this.lastWidthRight>i-50&&(this.lastWidthRight=i-50),this.position==="right"?(this.floatingBtn.classList.add("active"),this.floatingBtn.innerHTML='<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="2" ry="2"></rect><path d="M3 15h18"></path></svg>',this.floatingBtn.title="Switch to Bottom",this.panel.classList.remove("position-bottom"),this.panel.classList.add("position-right"),this.toggleButton.classList.add("position-right"),this.miniPanel.classList.add("position-right"),this.panel.style.bottom="",this.panel.style.top="0",this.panel.style.right="0",this.panel.style.left="",this.panel.style.width=`${this.lastWidthRight}px`,this.panel.style.height="100%"):this.panel.style.height=`${this.lastHeightBottom}px`,t.isVisible&&(this.panel.classList.add("visible"),this.toggleButton.classList.add("panel-open")),t.activeTabId&&this.setActiveTab(t.activeTabId),t.detachedTabs&&t.detachedTabs.length>0&&(this.pendingDetachedTabs=t.detachedTabs,this.restoreDetachedTabs()),this.updatePanelSize(),this.panel.classList.contains("visible")&&this.miniPanel.classList.add("panel-open")}catch(e){console.warn("Failed to load profiler layout:",e)}finally{this.isLoadingLayout=!1}}restoreDetachedTabs(){if(!(!this.pendingDetachedTabs||this.pendingDetachedTabs.length===0)){if(this.pendingDetachedTabs.forEach(e=>{let t=this.tabs[e.tabId];if(!t||t.isDetached)return;e.originalIndex!==void 0&&(t.originalIndex=e.originalIndex),t.button.parentNode&&t.button.parentNode.removeChild(t.button),t.content.parentNode&&t.content.parentNode.removeChild(t.content);let i=this.createDetachedWindow(t,0,0);i.panel.style.left=`${e.left}px`,i.panel.style.top=`${e.top}px`,i.panel.style.width=`${e.width}px`,i.panel.style.height=`${e.height}px`,this.constrainWindowToBounds(i.panel),this.detachedWindows.push(i),t.isDetached=!0,t.detachedWindow=i}),this.pendingDetachedTabs=null,this.detachedWindows.forEach(e=>{let t=parseInt(getComputedStyle(e.panel).zIndex)||0;t>this.maxZIndex&&(this.maxZIndex=t)}),!this.activeTabId||!this.tabs[this.activeTabId]||this.tabs[this.activeTabId].isDetached||!this.tabs[this.activeTabId].isVisible){let e=Object.keys(this.tabs).filter(t=>!this.tabs[t].isDetached&&this.tabs[t].isVisible);if(e.length>0){let t=Array.from(this.tabsContainer.children).map(i=>Object.keys(this.tabs).find(r=>this.tabs[r].button===i)).filter(i=>i!==void 0&&!this.tabs[i].isDetached&&this.tabs[i].isVisible);this.setActiveTab(t[0]||e[0])}else this.activeTabId=null}this.updatePanelSize()}}},Ad=class extends Ds{constructor(e,t={}){super(),this.id=e.toLowerCase(),this.button=document.createElement("button"),this.button.className="tab-btn",this.button.textContent=e,this.content=document.createElement("div"),this.content.id=`${this.id}-content`,this.content.className="profiler-content",this.isActive=!1,this.isVisible=!0,this.isDetached=!1,this.detachedWindow=null,this.allowDetach=t.allowDetach===void 0?!0:t.allowDetach,this.builtin=t.builtin===void 0?!1:t.builtin,this.icon=t.icon||null,this.builtinButton=null,this.miniContent=null,this.profiler=null,this.onVisibilityChange=null}setActive(e){this.button.classList.toggle("active",e),this.content.classList.toggle("active",e),this.isActive=e}show(){this.content.style.display="",this.button.style.display="",this.isVisible=!0,this.isDetached&&this.detachedWindow&&(this.detachedWindow.panel.style.display=""),this.onVisibilityChange&&this.onVisibilityChange(),this.showBuiltin()}hide(){this.content.style.display="none",this.button.style.display="none",this.isVisible=!1,this.isDetached&&this.detachedWindow&&(this.detachedWindow.panel.style.display="none"),this.onVisibilityChange&&this.onVisibilityChange(),this.hideBuiltin()}showBuiltin(){if(this.builtin&&(this.profiler&&this.profiler.builtinTabsContainer&&(this.profiler.builtinTabsContainer.style.display=""),this.builtinButton&&(this.builtinButton.style.display=""),this.miniContent&&this.profiler)){
2089if(this.profiler.miniPanel.querySelectorAll(".mini-panel-content").forEach(e=>{e.style.display="none"}),this.profiler.builtinTabsContainer.querySelectorAll(".builtin-tab-btn").forEach(e=>{e.classList.remove("active")}),this.builtinButton&&this.builtinButton.classList.add("active"),!this.miniContent.firstChild){let e=this.content.querySelector(".list-scroll-wrapper")||this.content.firstElementChild;e&&this.miniContent.appendChild(e)}this.miniContent.style.display="block",this.profiler.miniPanel.classList.add("visible")}}hideBuiltin(){this.builtin&&(this.builtinButton&&(this.builtinButton.style.display="none"),this.miniContent&&(this.miniContent.style.display="none",this.miniContent.firstChild&&this.content.appendChild(this.miniContent.firstChild)),this.builtinButton&&this.builtinButton.classList.remove("active"),this.profiler&&(Array.from(this.profiler.miniPanel.querySelectorAll(".mini-panel-content")).some(e=>e.style.display!=="none")||this.profiler.miniPanel.classList.remove("visible"),Array.from(this.profiler.builtinTabsContainer.querySelectorAll(".builtin-tab-btn")).some(e=>e.style.display!=="none")||(this.profiler.builtinTabsContainer.style.display="none")))}},D0=class{constructor(...e){this.headers=e,this.children=[],this.domElement=document.createElement("div"),this.domElement.className="list-container",this.domElement.style.padding="10px",this.id=`list-${Math.random().toString(36).substr(2,9)}`,this.domElement.dataset.listId=this.id,this.gridStyleElement=document.createElement("style"),this.domElement.appendChild(this.gridStyleElement);let t=document.createElement("div");t.className="list-header",this.headers.forEach(i=>{let r=document.createElement("div");r.className="list-header-cell",r.textContent=i,t.appendChild(r)}),this.domElement.appendChild(t)}setGridStyle(e){this.gridStyleElement.textContent=`
2090[data-list-id="${this.id}"] > .list-header,
2091[data-list-id="${this.id}"] .list-item-row {
2092	grid-template-columns: ${e};
2093}
2094`}add(e){e.parent!==null&&e.parent.remove(e),e.domElement.classList.add("header-wrapper","section-start"),e.parent=this,this.children.push(e),this.domElement.appendChild(e.domElement)}remove(e){let t=this.children.indexOf(e);return t!==-1&&(this.children.splice(t,1),this.domElement.removeChild(e.domElement),e.parent=null),this}},k_=class{constructor(e=512){this.maxPoints=e,this.lines={},this.limit=0,this.limitIndex=0,this.domElement=document.createElementNS("http://www.w3.org/2000/svg","svg"),this.domElement.setAttribute("class","graph-svg")}addLine(e,t){let i=document.createElementNS("http://www.w3.org/2000/svg","path");i.setAttribute("class","graph-path"),i.style.stroke=t,i.style.fill=t,this.domElement.appendChild(i),this.lines[e]={path:i,color:t,points:[]}}addPoint(e,t){let i=this.lines[e];i&&(i.points.push(t),i.points.length>this.maxPoints&&i.points.shift(),t>this.limit&&(this.limit=t,this.limitIndex=0))}resetLimit(){this.limit=0,this.limitIndex=0}update(){let e=this.domElement.clientWidth,t=this.domElement.clientHeight;if(e===0)return;let i=e/(this.maxPoints-1);for(let r in this.lines){let s=this.lines[r],n=`M 0,${t}`;for(let o=0;o<s.points.length;o++){let l=o*i,h=t-s.points[o]/this.limit*t;n+=` L ${l},${h}`}n+=` L ${(s.points.length-1)*i},${t} Z`;let a=e-(s.points.length-1)*i;s.path.setAttribute("transform",`translate(${a}, 0)`),s.path.setAttribute("d",n)}this.limitIndex++>this.maxPoints&&this.resetLimit()}},Bt=class{constructor(...e){this.children=[],this.isOpen=!0,this.childrenContainer=null,this.parent=null,this.domElement=document.createElement("div"),this.domElement.className="list-item-wrapper",this.itemRow=document.createElement("div"),this.itemRow.className="list-item-row",this.userData={},this.data=e,this.data.forEach(t=>{let i=document.createElement("div");i.className="list-item-cell",t instanceof HTMLElement?i.appendChild(t):i.append(String(t)),this.itemRow.appendChild(i)}),this.domElement.appendChild(this.itemRow),this.onItemClick=this.onItemClick.bind(this)}onItemClick(e){e.target.closest("button, a, input, label")||this.toggle()}add(e,t=this.children.length){return e.parent!==null&&e.parent.remove(e),e.parent=this,this.children.splice(t,0,e),this.itemRow.classList.add("collapsible"),this.childrenContainer||(this.childrenContainer=document.createElement("div"),this.childrenContainer.className="list-children-container",this.childrenContainer.classList.toggle("closed",!this.isOpen),this.domElement.appendChild(this.childrenContainer),this.itemRow.addEventListener("click",this.onItemClick)),this.childrenContainer.insertBefore(e.domElement,this.childrenContainer.children[t]||null),this.updateToggler(),this}remove(e){let t=this.children.indexOf(e);return t!==-1&&(this.children.splice(t,1),this.childrenContainer.removeChild(e.domElement),e.parent=null,this.children.length===0&&(this.itemRow.classList.remove("collapsible"),this.itemRow.removeEventListener("click",this.onItemClick),this.childrenContainer.remove(),this.childrenContainer=null),this.updateToggler()),this}updateToggler(){let e=this.itemRow.querySelector(".list-item-cell:first-child"),t=this.itemRow.querySelector(".item-toggler");this.children.length>0?(t||(t=document.createElement("span"),t.className="item-toggler",e.prepe
2094nd(t)),this.isOpen&&this.itemRow.classList.add("open")):t&&t.remove()}toggle(){return this.isOpen=!this.isOpen,this.itemRow.classList.toggle("open",this.isOpen),this.childrenContainer&&this.childrenContainer.classList.toggle("closed",!this.isOpen),this}close(){return this.isOpen&&this.toggle(),this}};function mt(e=null){let t=document.createElement("span");return t.className="value",e!==null&&(t.id=e),t}function Ut(e,t){let i=e instanceof HTMLElement?e:document.getElementById(e);i&&i.textContent!==t&&(i.textContent=t)}function iH(e){let t=e.lastIndexOf("/");return t===-1?{path:"",name:e.trim()}:{path:e.substring(0,t).trim(),name:e.substring(t+1).trim()}}function rH(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1 $2").trim()}function Nd(e,t=2){if(e===0)return"0 Bytes";let i=1024,r=t<0?0:t,s=["Bytes","KB","MB","GB","TB","PB","EB","ZB","YB"],n=Math.floor(Math.log(e)/Math.log(i));return parseFloat((e/i**n).toFixed(r))+" "+s[n]}var sH=class extends Ad{constructor(e={}){super("Performance",e);let t=new D0("Name","CPU","GPU","Total");t.setGridStyle("minmax(200px, 2fr) 80px 80px 80px"),t.domElement.style.minWidth="600px";let i=document.createElement("div");i.className="list-scroll-wrapper",i.appendChild(t.domElement),this.content.appendChild(i);let r=document.createElement("div");r.className="graph-container";let s=new k_;s.addLine("fps","var( --color-fps )"),r.append(s.domElement);let n=new Bt("Graph Stats",mt(),mt(),mt("graph-fps-counter"));t.add(n);let a=new Bt(r);a.itemRow.childNodes[0].style.gridColumn="1 / -1",n.add(a);let o=new Bt("Frame Stats",mt(),mt(),mt());t.add(o);let l=new Bt("Miscellaneous & Idle",mt(),mt(),mt());l.domElement.firstChild.style.backgroundColor="#00ff0b1a",l.domElement.firstChild.classList.add("no-hover"),o.add(l),this.notInUse=new Map,this.frameStats=o,this.graphStats=n,this.graph=s,this.miscellaneous=l,this.currentRender=null,this.currentItem=null,this.frameItems=new Map}resolveStats(e,t){let i=e.getStatsData(t.cid),r=i.item;if(r===void 0)r=new Bt(mt(),mt(),mt(),mt()),t.name?t.isComputeStats===!0&&(t.name=`${t.name} [ Compute ]`):t.name=`Unnamed ${t.cid}`,r.userData.name=t.name,this.currentItem.add(r),i.item=r;else{r.userData.name=t.name,this.notInUse.has(t.cid)&&(r.domElement.firstElementChild.classList.remove("alert"),this.notInUse.delete(t.cid));let a=t.parent.children.indexOf(t);(r.parent===null||r.parent.children.indexOf(r)!==a)&&this.currentItem.add(r,a)}let s=r.userData.name;t.isComputeStats&&(s+=" [ Compute ]"),Ut(r.data[0],s),Ut(r.data[1],i.cpu.toFixed(2)),Ut(r.data[2],t.gpuNotAvailable===!0?"-":i.gpu.toFixed(2)),Ut(r.data[3],i.total.toFixed(2));let n=this.currentItem;this.currentItem=r;for(let a of t.children)this.resolveStats(e,a);this.currentItem=n,this.frameItems.set(t.cid,r)}updateGraph(e){this.graph.addPoint("fps",e.fps),this.graph.update()}addNotInUse(e,t){t.domElement.firstElementChild.classList.add("alert"),this.notInUse.set(e,{item:t,time:performance.now()}),this.updateNotInUse(e)}updateNotInUse(e){let{item:t,time:i}=this.notInUse.get(e),r=performance.now(),s=5-Math.floor((r-i)/1e3);if(s>=0){let n="*".repeat(Math.max(0,s));Ut(t.domElement.querySelector(".list-item-cell .value"),t.userData.name+" (not in use) "+n)}else t.domElement.firstElementChild.classList.remove("alert"),t.parent.remove(t),this.notInUse.delete(e)}updateText(e,t){let i=new Map(this.frameItems);this.frameItems.clear(),this.currentItem=this.frameStats;for(let r of t.children)this.resolveStats(e,r);for(let[r,s]of i)this.frameItems.has(r)||(this.addNotInUse(r,s),i.delete(r));for(let r of this.notInUse.keys())this.updateNotInUse(r);Ut("graph-fps-counter",e.fps.toFixed()+" FPS"),Ut(this.frameStats.data[1],t.cpu.toFixed(2)),Ut(this.frameStats.data[2],t.gpu.toFixed(2)),Ut(this.frameStats.data[3],t.total.toFixed(2)),Ut(this.miscellaneous.data[1],t.miscellaneous.toFixed(2)),Ut(this.miscellaneous.data[2],"-"),Ut(this.miscellaneous.data[3],t.miscellaneous.toFixed(2)),this.currentItem=null}},nH=class extends Ad{constructor(e={}){super("Memory",e);let t=new D0("Name","Count","Size");t.setGridStyle("minmax(200px, 2fr) 60px 100px"),t.domElement.style.minWidth="300px";let i=document.createElement("div");i.className="list-scroll-wrapper",i.appendChild(t.domElement),this.content.appendChild(i);let r=document.createElement("div");r.className="graph-container";let s=new k_;s.addLine("total","var( --color-yellow )"),r.append(s.domElement);let n=new Bt("Graph Stats","","");t.add(n);let a=new Bt(r);a.itemRow.childNodes[0].style.gridColumn="1 / -1",n.add(a),this.memoryStats=new Bt("Renderer Info","",mt()),this.memoryStats.domElement.firstChild.classList.add("no-hover"),t.add(this.memoryStats),this.attributes=new Bt("Attributes",mt(),mt()),this.memoryStats.add(this.attributes),this.geometries=new Bt("Geometries",mt(),"N/A"),this.memoryStats.add(this.geometries),this.indexAttributes=new Bt("Index Attributes",mt(),mt()),this.memoryStats.add(this.indexAttributes),this.indirectStorageAttributes=new Bt("Indirect Storage Attributes",mt(),mt()),this.memoryStats.add(this.indirectStorageAttributes),this.programs=new Bt("Programs",mt(),"N/A"),this.memoryStats.add(this.programs),this.renderTargets=new Bt("Render Targets",mt(),"N/A"),this.memoryStats.add(this.renderTargets),this.storageAttributes=new Bt("Storage Attributes",mt(),mt()),this.memoryStats.add(this.storageAttributes),this.textures=new Bt("Textures",mt(),mt()),this.memoryStats.add(this.textures),this.graph=s}updateGraph(e){let t=e.getRenderer();if(!t)return;let i=t.info.memory;this.graph.addPoint("total",i.total),this.graph.limit===0&&(this.graph.limit=1),this.graph.update()}updateText(e){let t=e.getRenderer();if(!t)return;let i=t.info.memory;Ut(this.memoryStats.data[2],Nd(i.total)),Ut(this.attributes.data[1],i.attributes.toString()),Ut(this.attributes.data[2],Nd(i.attributesSize)),Ut(this.geometries.data[1],i.geometries.toString()),Ut(this.indexAttributes.data[1],i.indexAttributes.toString()),Ut(this.indexAttributes.data[2],Nd(i.indexAttributesSize)),Ut(this.indirectStorageAttributes.data[1],i.indirectStorageAttributes.toString()),Ut(this.indirectStorageAttributes.data[2],Nd(i.indirectStorageAttributesSize)),Ut(this.programs.data[1],i.programs.toString()),Ut(this.renderTargets.data[1],i.renderTargets.toString()),Ut(this.storageAttributes.data[1],i.storageAttributes.toString()),Ut(this.storageAttributes.data[2],Nd(i.storageAttributesSize)),Ut(this.textures.data[1],i.textures.toString()),Ut(this.textures.data[2],Nd(i.texturesSize))}},aH=class extends Ad{constructor(e={}){super("Console",e),this.filters={info:!0,warn:!0,error:!0},this.filterText="",this.buildHeader(),this.logContainer=document.createElement("div"),this.logContainer.id="c
2094onsole-log",this.content.appendChild(this.logContainer)}buildHeader(){let e=document.createElement("div");e.className="console-header";let t=document.createElement("input");t.type="text",t.className="console-filter-input",t.placeholder="Filter...",t.addEventListener("input",s=>{this.filterText=s.target.value.toLowerCase(),this.applyFilters()});let i=document.createElement("button");i.className="console-copy-button",i.title="Copy all",i.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"></rect><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"></path></svg>',i.addEventListener("click",()=>this.copyAll(i));let r=document.createElement("div");r.className="console-buttons-group",Object.keys(this.filters).forEach(s=>{let n=document.createElement("label");n.className="custom-checkbox",n.style.color=`var(--${s==="info"?"text-primary":"color-"+(s==="warn"?"yellow":"red")})`;let a=document.createElement("input");a.type="checkbox",a.checked=this.filters[s],a.dataset.type=s;let o=document.createElement("span");o.className="checkmark",n.appendChild(a),n.appendChild(o),n.append(s.charAt(0).toUpperCase()+s.slice(1)),r.appendChild(n)}),r.addEventListener("change",s=>{let n=s.target.dataset.type;n in this.filters&&(this.filters[n]=s.target.checked,this.applyFilters())}),r.appendChild(i),e.appendChild(t),e.appendChild(r),this.content.appendChild(e)}applyFilters(){this.logContainer.querySelectorAll(".log-message").forEach(e=>{let t=e.dataset.type,i=e.dataset.rawText.toLowerCase(),r=this.filters[t],s=i.includes(this.filterText);e.classList.toggle("hidden",!(r&&s))})}copyAll(e){let t=this.logContainer.ownerDocument.defaultView.getSelection(),i=t.toString(),r=i&&this.logContainer.contains(t.anchorNode),s;if(r)s=i;else{let n=this.logContainer.querySelectorAll(".log-message:not(.hidden)");s=Array.from(n).map(a=>a.dataset.rawText).join(`
2095`)}navigator.clipboard.writeText(s),e.classList.add("copied"),setTimeout(()=>e.classList.remove("copied"),350)}_getIcon(e,t){let i;return t==="tip"?i="\u{1F4AD}":t==="tsl"?i="\u2728":t==="webgpurenderer"?i="\u{1F3A8}":e==="warn"?i="\u26A0\uFE0F":e==="error"?i="\u{1F534}":e==="info"&&(i="\u2139\uFE0F"),i}_formatMessage(e,t){let i=document.createDocumentFragment(),r=t.match(/^([\w\.]+:\s)/),s=t;if(r){let a=r[0],o=a.slice(0,-2).split("."),l=(o.length>1?o[o.length-1]:o[0])+":",h=this._getIcon(e,l.split(":")[0].toLowerCase());i.appendChild(document.createTextNode(h+" "));let u=document.createElement("span");u.className="log-prefix",u.textContent=l,i.appendChild(u),s=t.substring(a.length)}let n=s.split(/(".*?"|'.*?'|`.*?`)/g).map(a=>a.trim()).filter(Boolean);return n.forEach((a,o)=>
2095{if(/^("|'|`)/.test(a)){let l=document.createElement("span");l.className="log-code",l.textContent=a.slice(1,-1),i.appendChild(l)}else o>0&&(a=" "+a),o<n.length-1&&(a+=" "),i.appendChild(document.createTextNode(a))}),i}addMessage(e,t){let i=document.createElement("div");i.className=`log-message ${e}`,i.dataset.type=e,i.dataset.rawText=t,i.appendChild(this._formatMessage(e,t));let r=this.filters[e],s=t.toLowerCase().includes(this.filterText);i.classList.toggle("hidden",!(r&&s)),this.logContainer.appendChild(i),this.logContainer.scrollTop=this.logContainer.scrollHeight,this.logContainer.children.length>200&&this.logContainer.removeChild(this.logContainer.firstChild)}},zh=class extends Ds{constructor(){super(),this.domElement=document.createElement("div"),this.domElement.className="param-control",this._onChangeFunction=null,this.addEventListener("change",e=>{requestAnimationFrame(()=>{this._onChangeFunction&&this._onChangeFunction(e.value)})})}setValue(){return this.dispatchChange(),this}getValue(){return null}dispatchChange(){this.dispatchEvent({type:"change",value:this.getValue()})}onChange(e){return this._onChangeFunction=e,this}},f3=class extends zh{constructor({value:e=0,step:t=.1,min:i=-1/0,max:r=1/0}){super(),this.input=document.createElement("input"),this.input.type="number",this.input.value=e,this.input.step=t,this.input.min=i,this.input.max=r,this.input.addEventListener("change",this._onChangeValue.bind(this)),this.domElement.appendChild(this.input),this.addDragHandler()}_onChangeValue(){let e=parseFloat(this.input.value),t=parseFloat(this.input.min),i=parseFloat(this.input.max);e>i?this.input.value=i:(e<t||isNaN(e))&&(this.input.value=t),this.dispatchChange()}addDragHandler(){let e=!1,t,i;this.input.addEventListener("mousedown",r=>{e=!0,t=r.clientY,i=parseFloat(this.input.value),document.body.style.cursor="ns-resize"}),document.addEventListener("mousemove",r=>{if(e){let s=t-r.clientY,n=parseFloat(this.input.step)||1,a=parseFloat(this.input.min),o=parseFloat(this.input.max),l=n;!isNaN(o)&&isFinite(a)&&(l=(o-a)/100);let h=s*l,u=i+h;u=Math.max(a,Math.min(u,o));let d=(String(n).split(".")[1]||[]).length;this.input.value=u.toFixed(d),this.input.dispatchEvent(new Event("input")),this.dispatchChange()}}),document.addEventListener("mouseup",()=>{e&&(e=!1,document.body.style.cursor="default")})}setValue(e){return this.input.value=e,super.setValue(e)}getValue(){return parseFloat(this.input.value)}},oH=class extends zh{constructor({value:e=!1}){super();let t=document.createElement("label");t.className="custom-checkbox";let i=document.createElement("input");i.type="checkbox",i.checked=e,this.checkbox=i;let r=document.createElement("span");r.className="checkmark",t.appendChild(i),t.appendChild(r),this.domElement.appendChild(t),i.addEventListener("change",()=>{this.dispatchChange()})}setValue(e){return this.checkbox.value=e,super.setValue(e)}getValue(){return this.checkbox.checked}},lH=class extends zh{constructor({value:e=0,min:t=0,max:i=1,step:r=.01}){super(),this.slider=document.createElement("input"),this.slider.type="range",this.slider.min=t,this.slider.max=i,this.slider.step=r;let s=new f3({value:e,min:t,max:i,step:r});this.numberInput=s.input,this.numberInput.style.flexBasis="80px",this.numberInput.style.flexShrink="0",this.slider.value=e,this.domElement.append(this.slider,this.numberInput),this.slider.addEventListener("input",()=>{this.numberInput.value=this.slider.value,this.dispatchChange()}),s.addEventListener("change",()=>{this.slider.value=parseFloat(this.numberInput.value),this.dispatchChange()})}setValue(e){return this.slider.value=e,this.numberInput.value=e,super.setValue(e)}getValue(){return parseFloat(this.slider.value)}step(e){return this.slider.step=e,this.numberInput.step=e,this}},hH=class extends zh{constructor({options:e=[],value:t=""}){super();let i=document.createElement("select"),r=(s,n)=>{let a=document.createElement("option");
2095return a.value=s,a.textContent=s,n==t&&(a.selected=!0),i.appendChild(a),a};Array.isArray(e)?e.forEach(s=>r(s,s)):Object.entries(e).forEach(([s,n])=>r(s,n)),this.domElement.appendChild(i),i.addEventListener("change",()=>{this.dispatchChange()}),this.options=e,this.select=i}getValue(){let e=this.options;return Array.isArray(e)?e[this.select.selectedIndex]:e[this.select.value]}},uH=class extends zh{constructor({value:e="#ffffff"}){super();let t=document.createElement("input");t.type="color",t.value=this._getColorHex(e),this.colorInput=t,this._value=e,t.addEventListener("input",()=>{let i=t.value;this._value.isColor?this._value.setHex(parseInt(i.slice(1),16)):this._value=i,this.dispatchChange()}),this.domElement.appendChild(t)}_getColorHex(e){return e.isColor&&(e=e.getHex()),typeof e=="number"?e=`#${e.toString(16)}`:e[0]!=="#"&&(e="#"+e),e}getValue(){let e=this._value;return typeof e=="string"&&(e=parseInt(e.slice(1),16)),e}},dH=class extends zh{constructor({text:e="Button",value:t=()=>{}}){super();let i=document.createElement("button");i.textContent=e,i.onclick=t,this.domElement.appendChild(i)}},cH=class extends zh{constructor({value:e=""}){super();let t=document.createElement("input");t.type="text",t.value=e,this.input=t,t.addEventListener("input",()=>{this.dispatchChange()}),this.domElement.appendChild(t)}setValue(e){return this.input.value=e,super.setValue(e)}getValue(){return this.input.value}},pH=class pO{constructor(t,i){this.parameters=t,this.name=i,this.paramList=new Bt(i),this.objects=[]}close(){return this.paramList.close(),this}add(t,i,...r){let s=typeof t[i],n=null;return typeof r[0]=="object"?n=this.addSelect(t,i,r[0]):s==="number"?n=r.length>=2?this.addSlider(t,i,...r):this.addNumber(t,i,...r):s==="boolean"?n=this.addBoolean(t,i):s==="string"?n=this.addString(t,i):s==="function"&&(n=this.addButton(t,i,...r)),n}_addParameter(t,i,r,s){r.name=n=>(s.data[0].textContent=n,r),r.listen=()=>{let n=()=>{let a=r.getValue(),o=t[i];a!==o&&r.setValue(o),requestAnimationFrame(n)};return requestAnimationFrame(n),r},this._registerParameter(t,i,r,s)}_registerParameter(t,i,r,s){this.objects.push({object:t,key:i,editor:r,subItem:s})}addString(t,i){let r=t[i],s=new cH({value:r});s.addEventListener("change",({value:o})=>{t[i]=o});let n=mt();n.textContent=i;let a=new Bt(n,s.domElement);return this.paramList.add(a),a.domElement.firstChild.classList.add("actionable"),this._addParameter(t,i,s,a),s}addFolder(t){let i=new pO(this.parameters,t);return this.paramList.add(i.paramList),i}addBoolean(t,i){let r=t[i],s=new oH({value:r});s.addEventListener("change",({value:l})=>{t[i]=l});let n=mt();n.textContent=i;let a=new Bt(n,s.domElement);this.paramList.add(a);let o=a.domElement.firstChild;return o.classList.add("actionable"),o.addEventListener("click",l=>{if(l.target.closest("label"))return;let h=o.querySelector('input[type="checkbox"]');h&&(h.checked=!h.checked,h.dispatchEvent(new Event("change")))}),this._addParameter(t,i,s,a),s}addSelect(t,i,r){let s=t[i],n=new hH({options:r,value:s});n.addEventListener("change",({value:l})=>{t[i]=l});let a=mt();a.textContent=i;let o=new Bt(a,n.domElement);return this.paramList.add(o),o.domElement.firstChild.classList.add("actionable"),this._addParameter(t,i,n,o),n}addColor(t,i){let r=t[i],s=new uH({value:r});s.addEventListener("change",({value:o})=>{t[i]=o});let n=mt();n.textContent=i;let a=new Bt(n,s.domElement);return this.paramList.add(a),a.domElement.firstChild.classList.add("actionable"),this._addParameter(t,i,s,a),s}addSlider(t,i,r=0,s=1,n=.01){let a=t[i],o=new lH({value:a,min:r,max:s,step:n});o.addEventListener("change",({value:u})=>{t[i]=u});let l=mt();l.textContent=i;let h=new Bt(l,o.domElement);return this.paramList.add(h),h.domElement.firstChild.classList.add("actionable"),this._addParameter(t,i,o,h),o}addNumber(t,i,...r){let s=t[i],[n,a]=r,o=new f3({value:s,min:n,max:a});o.addEventListener("change",({value:u})=>{t[i]=u});let l=mt();l.textContent=i;let h=new Bt(l,o.domElement);return this.paramList.add(h),h.domElement.firstChild.classList.add("actionable"),this._addParameter(t,i,o,h),o}addButton(t,i){let r=t[i],s=new dH({text:i,value:r});s.addEventListener("change",({value:a})=>{t[i]=a});let n=new Bt(s.domElement);return n.itemRow.childNodes[0].style.gridColumn="1 / -1",this.paramList.add(n),n.domElement.firstChild.classList.add("actionable"),s.name=a=>(s.domElement.childNodes[0].textContent=a,s),this._registerParameter(t,i,s,n),s}},y3=class extends Ad{constructor(e={}){super(e.name||"Parameters",e);let t=new D0("Property","Value");t.domElement.classList.add("parameters"),t.setGridStyle(".5fr 1fr"),t.domElement.style.minWidth="300px";let i=document.createElement("div");i.className="list-scroll-wrapper",i.appendChild(t.domElement),this.content.appendChild(i),this.paramList=t,this.groups=[]}createGroup(e){let t=new pH(this,e);return this.paramList.add(t.paramList),this.groups.push(t),t}},x3=F0.prototype.init;function v3(e){e?F0.prototype.init=async function(){if(this.backend.isWebGLBackend!==!0){let t=this.backend.parameters;this.backend=new R_(t)}return x3.call(this)}:F0.prototype.init=x3}function mH(){let e={};try{e=JSON.parse(localStorage.getItem("threejs-inspector")||"{}").settings||{}}catch(t){console.error("Failed to load settings:",t)}return{forceWebGL:e.forceWebGL||!1,captureStackTrace:e.captureStackTrace||!1}}function b3(e){try{let t=JSON.parse(localStorage.getItem("threejs-inspector")||"{}");t.settings=e,localStorage.setItem("threejs-inspector",JSON.stringify(t))}catch(t){console.error("Failed to save settings:",t)}}var Ld=mH();Ld.forceWebGL&&v3(!0),Ld.captureStackTrace&&(ve.captureStackTrace=!0);var gH=class extends y3{constructor(){super({name:"Settings"});let e=this.createGroup("Renderer");e.add(Ld,"forceWebGL").name("Force WebGL").onChange(t=>{v3(t),b3(Ld),location.reload()}),e.add(Ld,"captureStackTrace").name("Capture Stack Trace").onChange(t=>{ve.captureStackTrace=t,b3(Ld),location.reload()})}},fH=class extends Ad{constructor(e={}){super("Viewer",e);let t=new D0("Viewer","Name");t.setGridStyle("150px minmax(200px, 2fr)"),t.domElement.style.minWidth="400px";let i=document.createElement("div");i.className="list-scroll-wrapper",i.appendChild(t.domElement),this.content.appendChild(i);let r=new Bt("Nodes");t.add(r),this.itemLibrary=new Map,this.folderLibrary=new Map,this.currentDataList=[],this.nodeList=t,this.nodes=r}getFolder(e){let t=this.folderLibrary.get(e);return t===void 0&&(t=new Bt(e),this.folderLibrary.set(e,t),this.nodeList.add(t)),t}addNodeItem(e){let t=this.itemLibrary.get(e.id);if(t===void 0){let i=e.name,r=e.canvasTarget.domElement;t=new Bt(r,i),t.itemRow.children[1].style["justify-content"]="flex-start",this.itemLibrary.set(e.id,t)}return t}update(e,t){if(!this.isActive&&!this.isDetached)return;let i=[...this.currentDataList];for(let s of i)if(this.itemLibrary.has(s.id)&&t.indexOf(s)===-1){let n=this.itemLibrary.get(s.id),a=n.parent;a.remove(n),this.folderLibrary.has(a.data[0])&&a.children.length===0&&(a.parent.remove(a),this.folderLibrary.delete(a.data[0])),this.itemLibrary.delete(s.id)}let r={};for(let s of t){let n=this.addNodeItem(s),a=e.getCanvasTarget(),o=s.path;if(o){let h=this.getFolder(o);r[o]===void 0&&(r[o]=0),(h.parent===null||n.parent!==h||h.children.indexOf(n)!==r[o])&&h.add(n),r[o]++}else n.parent||this.nodes.add(n);this.currentDataList=t;let l=v0.resetRendererState(e);
2095e.toneMapping=0,e.outputColorSpace=Pc,e.setCanvasTarget(s.canvasTarget),s.quad.render(e),e.setCanvasTarget(a),v0.restoreRendererState(e,l)}}},_3=500,yH=class extends Ad{constructor(e={}){super("Timeline",e),this.isRecording=!1,this.frames=[],this.currentFrame=null,this.isHierarchicalView=!0,this.originalBackend=null,this.originalMethods=new Map,this.renderer=null,this.graph=new k_(_3),this.graph.addLine("fps","var( --color-fps )"),this.graph.addLine("calls","var( --color-call )"),this.buildHeader(),this.buildUI(),window.addEventListener("resize",()=>{!this.isRecording&&this.frames.length>0&&this.renderSlider()})}buildHeader(){let e=document.createElement("div");e.className="console-header",this.recordButton=document.createElement("button"),this.recordButton.className="console-copy-button",this.recordButton.title="Record",this.recordButton.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"></circle><circle cx="12" cy="12" r="4" fill="currentColor"></circle></svg>',this.recordButton.style.padding="0 10px",this.recordButton.style.lineHeight="24px",this.recordButton.style.display="flex",this.recordButton.style.alignItems="center",this.recordButton.addEventListener("click",()=>this.toggleRecording());let t=document.createElement("button");t.className="console-copy-button",t.title="Clear",t.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="3 6 5 6 21 6"></polyline><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"></path><line x1="10" y1="11" x2="10" y2="17"></line><line x1="14" y1="11" x2="14" y2="17"></line></svg>',t.style.padding="0 10px",t.style.lineHeight="24px",t.style.display="flex",t.style.alignItems="center",t.addEventListener("click",()=>this.clear()),this.viewModeButton=document.createElement("button"),this.viewModeButton.className="console-copy-button",this.viewModeButton.title="Toggle View Mode",this.viewModeButton.textContent="Mode: Hierarchy",this.viewModeButton.style.padding="0 10px",this.viewModeButton.style.lineHeight="24px",this.viewModeButton.addEventListener("click",()=>{this.isHierarchicalView=!this.isHierarchicalView,this.viewModeButton.textContent=this.isHierarchicalView?"Mode: Hierarchy":"Mode: Counts",this.selectedFrameIndex!==void 0&&this.selectedFrameIndex!==-1&&this.selectFrame(this.selectedFrameIndex)}),this.recordRefreshButton=document.createElement("button"),this.recordRefreshButton.className="console-copy-button",this.recordRefreshButton.title="Refresh & Record",this.recordRefreshButton.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8"></path><path d="M21 3v5h-5"></path><circle cx="12" cy="12" r="3" fill="currentColor"></circle></svg>',this.recordRefreshButton.style.padding="0 10px",this.recordRefreshButton.style.lineHeight="24px",this.recordRefreshButton.style.display="flex",this.recordRefreshButton.style.alignItems="center",this.recordRefreshButton.addEventListener("click",()=>{let s=JSON.parse(localStorage.getItem("threejs-inspector")||"{}");s.timeline=s.timeline||{},s.timeline.recording=!0,localStorage.setItem("threejs-inspector",JSON.stringify(s)),window.location.reload()}),this.exportButton=document.createElement("button"),this.exportButton.className="console-copy-button",this.exportButton.title="Export",this.exportButton.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"></path><polyline points="7 10 12 15 17 10"></polyline><line x1="12" y1="15" x2="12" y2="3"></line></svg>',this.exportButton.style.padding="0 10px",this.exportButton.style.lineHeight="24px",this.exportButton.style.display="flex",this.exportButton.style.alignItems="center",this.exportButton.addEventListener("click",()=>this.exportData());let i=document.createElement("div");
2095i.className="console-buttons-group",i.appendChild(this.viewModeButton),i.appendChild(this.recordButton),i.appendChild(this.recordRefreshButton),i.appendChild(this.exportButton),i.appendChild(t),e.style.display="flex",e.style.justifyContent="space-between",e.style.padding="6px",e.style.borderBottom="1px solid var(--border-color)";let r=document.createElement("div");r.textContent="Backend Calls Timeline",r.style.color="var(--text-primary)",r.style.alignSelf="center",r.style.paddingLeft="5px",this.frameInfo=document.createElement("span"),this.frameInfo.style.marginLeft="15px",this.frameInfo.style.fontFamily="monospace",this.frameInfo.style.color="var(--text-secondary)",this.frameInfo.style.fontSize="12px",r.appendChild(this.frameInfo),e.appendChild(r),e.appendChild(i),this.content.appendChild(e)}buildUI(){let e=document.createElement("div");e.style.display="flex",e.style.flexDirection="column",e.style.height="calc(100% - 37px)",e.style.width="100%";let t=document.createElement("div");t.style.height="60px",t.style.minHeight="60px",t.style.borderBottom="1px solid var(--border-color)",t.style.backgroundColor="var(--background-color)",this.graphSlider=document.createElement("div"),this.graphSlider.style.height="100%",this.graphSlider.style.margin="0 10px",this.graphSlider.style.position="relative",this.graphSlider.style.cursor="crosshair",t.appendChild(this.graphSlider),this.graph.domElement.style.width="100%",this.graph.domElement.style.height="100%",this.graphSlider.appendChild(this.graph.domElement),this.hoverIndicator=document.createElement("div"),this.hoverIndicator.style.position="absolute",this.hoverIndicator.style.top="0",this.hoverIndicator.style.bottom="0",this.hoverIndicator.style.width="1px",this.hoverIndicator.style.backgroundColor="rgba(255, 255, 255, 0.3)",this.hoverIndicator.style.pointerEvents="none",this.hoverIndicator.style.display="none",this.hoverIndicator.style.zIndex="9",this.hoverIndicator.style.transform="translateX(-50%)",this.graphSlider.appendChild(this.hoverIndicator),this.playhead=document.createElement("div"),this.playhead.style.position="absolute",this.playhead.style.top="0",this.playhead.style.bottom="0",this.playhead.style.width="2px",this.playhead.style.backgroundColor="var(--color-red)",this.playhead.style.boxShadow="0 0 4px rgba(255,0,0,0.5)",this.playhead.style.pointerEvents="none",this.playhead.style.display="none",this.playhead.style.zIndex="10",this.playhead.style.transform="translateX(-50%)",this.graphSlider.appendChild(this.playhead);let i=document.createElement("div");i.style.position="absolute",i.style.top="0",i.style.left="50%",i.style.transform="translate(-50%, 0)",i.style.width="0",i.style.height="0",i.style.borderLeft="6px solid transparent",i.style.borderRight="6px solid transparent",i.style.borderTop="8px solid var(--color-red)",this.playhead.appendChild(i),this.graphSlider.tabIndex=0,this.graphSlider.style.outline="none";let r=!1,s=a=>{if(this.frames.length===0)return;let o=this.graphSlider.getBoundingClientRect(),l=a.clientX-o.left;l=Math.max(0,Math.min(l,o.width)),this.fixedScreenX=l;let h=this.graph.lines.calls.points.length;if(h===0)return;let u=o.width/(this.graph.maxPoints-1),d=o.width-(h-1)*u,c=Math.round((l-d)/u);c=Math.max(0,Math.min(c,h-1)),c>=h-2?this.isTrackingLatest=!0:this.isTrackingLatest=!1;let p=c;this.frames.length>h&&(p+=this.frames.length-h),this.playhead.style.display="block",this.selectFrame(p)};this.graphSlider.addEventListener("mousedown",a=>
2095{r=!0,this.isManualScrubbing=!0,this.graphSlider.focus(),s(a)}),this.graphSlider.addEventListener("mouseenter",()=>{this.frames.length>0&&!this.isRecording&&(this.hoverIndicator.style.display="block")}),this.graphSlider.addEventListener("mouseleave",()=>{this.hoverIndicator.style.display="none"}),this.graphSlider.addEventListener("mousemove",a=>{if(this.frames.length===0||this.isRecording)return;let o=this.graphSlider.getBoundingClientRect(),l=a.clientX-o.left;l=Math.max(0,Math.min(l,o.width));let h=this.graph.lines.calls.points.length;if(h>0){let u=o.width/(this.graph.maxPoints-1),d=o.width-(h-1)*u,c=Math.round((l-d)/u);c=Math.max(0,Math.min(c,h-1));let p=d+c*u;p=Math.max(1,Math.min(p,o.width-1)),this.hoverIndicator.style.left=p+"px"}else{let u=Math.max(1,Math.min(l,o.width-1));this.hoverIndicator.style.left=u+"px"}}),this.graphSlider.addEventListener("keydown",a=>{if(this.frames.length===0||this.isRecording)return;let o=this.selectedFrameIndex;if(a.key==="ArrowLeft"?(o=Math.max(0,this.selectedFrameIndex-1),a.preventDefault()):a.key==="ArrowRight"&&(o=Math.min(this.frames.length-1,this.selectedFrameIndex+1),a.preventDefault()),o!==this.selectedFrameIndex){this.selectFrame(o);let l=this.graph.lines.calls.points.length;if(l>0){let h=o;this.frames.length>l&&(h=o-(this.frames.length-l)),h>=l-2?this.isTrackingLatest=!0:this.isTrackingLatest=!1;let u=this.graphSlider.getBoundingClientRect(),d=u.width/(this.graph.maxPoints-1),c=u.width-(l-1)*d;this.fixedScreenX=c+h*d}}}),window.addEventListener("mousemove",a=>{if(r){s(a);let o=this.graphSlider.getBoundingClientRect(),l=a.clientX-o.left;l=Math.max(0,Math.min(l,o.width));let h=this.graph.lines.calls.points.length;if(h>0){let u=o.width/(this.graph.maxPoints-1),d=o.width-(h-1)*u,c=Math.round((l-d)/u);c=Math.max(0,Math.min(c,h-1));let p=d+c*u;p=Math.max(1,Math.min(p,o.width-1)),this.hoverIndicator.style.left=p+"px"}else{let u=Math.max(1,Math.min(l,o.width-1));this.hoverIndicator.style.left=u+"px"}}}),window.addEventListener("mouseup",()=>{r=!1,this.isManualScrubbing=!1}),e.appendChild(t);let n=document.createElement("div");n.style.flex="1",n.style.display="flex",n.style.flexDirection="column",n.style.overflow="hidden",this.timelineTrack=document.createElement("div"),this.timelineTrack.style.flex="1",this.timelineTrack.style.overflowY="auto",this.timelineTrack.style.margin="10px",this.timelineTrack.style.backgroundColor="var(--background-color)",n.appendChild(this.timelineTrack),e.appendChild(n),this.content.appendChild(e)}setRenderer(e){this.renderer=e;let t=JSON.parse(localStorage.getItem("threejs-inspector")||"{}");t.timeline&&t.timeline.recording&&(t.timeline.recording=!1,localStorage.setItem("threejs-inspector",JSON.stringify(t)),this.toggleRecording())}toggleRecording(){if(!this.renderer){console.warn("Timeline: No renderer defined.");return}this.isRecording=!this.isRecording,this.isRecording?(this.recordButton.title="Stop",this.recordButton.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="2" ry="2"></rect></svg>',this.recordButton.style.color="var(--color-red)",this.startRecording()):(this.recordButton.title="Record",this.recordButton.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"></circle><circle cx="12" cy="12" r="4" fill="currentColor"></circle></svg>',this.recordButton.style.color="",this.stopRecording(),this.renderSlider())}startRecording(){this.frames=[],this.currentFrame=null,this.selectedFrameIndex=-1,this.fixedScreenX=0,this.isTrackingLatest=!0,this.isManualScrubbing=!1,this.clear(),this.frameInfo.textContent="Recording...";let e=this.renderer.backend,t=Object.getOwnPropertyNames(Object.getPrototypeOf(e)).filter(i=>i!=="constructor");for(let i of t){let r=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(e),i);if(r&&(r.get||r.set))continue;let s=e[i];typeof s=="function"&&typeof i=="string"&&(this.originalMethods.set(i,s),e[i]=(...n)=>{if(i.toLowerCase().includes("timestamp")||i.startsWith("get")||i.startsWith("set")||i.startsWith("has")||i.startsWith("_")||i.startsWith("needs"))return s.apply(e,n);let a=this.renderer.info.frame;if((!this.currentFrame||this.currentFrame.id!==a)&&(this.currentFrame&&(this.currentFrame.fps=this.renderer.inspector?this.renderer.inspector.fps:0,isFinite(this.currentFrame.fps)||(this.currentFrame.fps=0),this.graph.addPoint("calls",this.currentFrame.calls.length),this.graph.addPoint("fps",this.currentFrame.fps),this.graph.update()),this.currentFrame={id:a,calls:[],fps:0},this.frames.push(this.currentFrame),this.frames.length>_3&&this.frames.shift(),!this.isManualScrubbing)){if(this.isTrackingLatest){let u=this.frames.length>1?this.frames.length-2:0;this.selectFrame(u)}else if(this.selectedFrameIndex!==-1){let u=this.graph.lines.calls.points.length;if(u>0){let d=this.graphSlider.getBoundingClientRect(),c=d.width/(this.graph.maxPoints-1),p=d.width-(u-1)*c,m=Math.round((this.fixedScreenX-p)/c);m=Math.max(0,Math.min(m,u-1));let g=m;this.frames.length>u&&(g+=this.frames.length-u),this.selectFrame(g)}}}let o=i;i==="beginRender"?this.renderer.inspector&&this.renderer.inspector.currentRender&&(o+=" - "+this.renderer.inspector.currentRender.name):i==="beginCompute"&&this.renderer.inspector&&this.renderer.inspector.currentCompute&&(o+=" - "+this.renderer.inspector.currentCompute.name);let l={method:o},h=this.getCallDetail(i,n);return h&&(l.details=h),this.currentFrame.calls.push(l),s.apply(e,n)})}}stopRecording(){if(this.originalMethods.size>0){let e=this.renderer.backend;for(let[t,i]of this.originalMethods.entries())e[t]=i;this.originalMethods.clear(),this.currentFrame&&(this.currentFrame.fps=this.renderer.inspector?this.renderer.inspector.fps:0)}}clear(){this.frames=[],this.timelineTrack.innerHTML="",this.playhead.style.display="none",this.frameInfo.textContent="",this.graph.lines.calls.points=[],this.graph.lines.fps.points=[],this.graph.resetLimit(),this.graph.update()}exportData(){if(this.frames.length===0)return;let e=JSON.stringify(this.frames,null,"	"),t=new Blob([e],{type:"application/json"}),i=URL.createObjectURL(t),r=document.createElement("a");r.href=i,r.download="threejs-timeline.json",r.click(),URL.revokeObjectURL(i)}getCallDetail(e,t){switch(e){case"draw":{let i=t[0];if(!i)return null;let r={};return i.object&&(r.object=i.object.name||i.object.type,i.object.count>1&&(r.instance=i.object.count)),i.material&&(r.material=i.material.name||i.material.type),i.geometry&&(r.geometry=i.geometry.name||void 0),i.camera&&(r.camera=i.camera.name||i.camera.t
2095ype),r}case"updateBinding":{let i=t[0];return i?.name?{binding:i.name}:null}case"createProgram":{let i=t[0];return i?{stage:i.stage,name:i.name||void 0}:null}case"createBindings":{let i=t[0];return i?.name?{group:i.name}:null}case"createTexture":case"destroyTexture":{let i=t[0];return i?.name?{texture:i.name}:null}}return null}formatDetails(e){let t=[];for(let i in e)e[i]!==void 0&&t.push(`<span style="opacity: 0.5">${i}:</span> <span style="color: var(--text-secondary); opacity: 1">${e[i]}</span>`);return t.length===0?"":`<span style="font-size: 11px; margin-left: 8px; color: var(--text-secondary); opacity: 1;">{ ${t.join('<span style="opacity: 0.5">, </span>')} }</span>`}renderSlider(){if(this.frames.length===0){this.playhead.style.display="none",this.frameInfo.textContent="";return}this.graph.lines.calls.points=[],this.graph.lines.fps.points=[],this.graph.resetLimit();let e=this.frames;e.length>this.graph.maxPoints&&(e=e.slice(-this.graph.maxPoints),this.frames=e);for(let i=0;i<e.length;i++)this.graph.addPoint("calls",e[i].calls.length),this.graph.addPoint("fps",e[i].fps||0);this.graph.update(),this.playhead.style.display="block";let t=0;this.selectedFrameIndex!==-1&&this.selectedFrameIndex<this.frames.length?t=this.selectedFrameIndex:this.frames.length>0&&(t=this.frames.length-1),this.selectFrame(t)}selectFrame(e){if(e<0||e>=this.frames.length)return;this.selectedFrameIndex=e;let t=this.frames[e];this.renderTimelineTrack(t),this.frameInfo.textContent="Frame: "+t.id+" ["+t.calls.length+" calls] ["+(t.fps||0).toFixed(1)+" FPS]";let i=this.graphSlider.getBoundingClientRect(),r=this.graph.lines.calls.points.length;if(r>0){let s=i.width/(this.graph.maxPoints-1),n=e;this.frames.length>r&&(n=e-(this.frames.length-r));let a=i.width-(r-1)*s+n*s;a=Math.max(1,Math.min(a,i.width-1)),this.playhead.style.left=a+"px",this.playhead.style.display="block"}}renderTimelineTrack(e){if(this.timelineTrack.innerHTML="",!e||e.calls.length===0)return;this.collapsedGroups||=new Set;let t=document.createDocumentFragment();if(this.isHierarchicalView){let i=[],r=null;for(let a=0;a<e.calls.length;a++){let o=e.calls[a],l=o.method.startsWith("begin")||o.method.startsWith("finish"),h=o.details?this.formatDetails(o.details):"";r&&r.method===o.method&&r.formatedDetails===h&&!l?r.count++:(r={method:o.method,count:1,formatedDetails:h},i.push(r))}let s=0,n=[{element:t,isCollapsed:!1,id:""}];for(let a=0;a<i.length;a++){let o=i[a],l=document.createElement("div");l.style.padding="4px 8px",l.style.margin="2px 0",l.style.marginLeft=s*24+"px",l.style.borderLeft="4px solid "+this.getColorForMethod(o.method),l.style.backgroundColor="rgba(255, 255, 255, 0.03)",l.style.fontFamily="monospace",l.style.fontSize="12px",l.style.color="var(--text-primary)",l.style.whiteSpace="nowrap",l.style.overflow="hidden",l.style.textOverflow="ellipsis",l.style.display="flex",l.style.alignItems="center";let h=n[n.length-1];if(h.isCollapsed||t.appendChild(l),o.method.startsWith("begin")){let u=h.id+"/"+o.method+"-"+a,d=this.collapsedGroups.has(u),c=document.createElement("span");c.textContent=d?"[ + ]":"[ - ]",c.style.fontSize="10px",c.style.marginRight="10px",c.style.cursor="pointer",c.style.width="26px",c.style.display="inline-block",c.style.textAlign="center",l.appendChild(c),l.style.cursor="pointer";let p=document.createElement("span");p.innerHTML=o.method+(o.formatedDetails?o.formatedDetails:"")+(o.count>1?` <span style="opacity: 0.5">( ${o.count} )</span>`:""),l.appendChild(p),l.addEventListener("click",m=>{m.stopPropagation(),d?this.collapsedGroups.delete(u):this.collapsedGroups.add(u),this.renderTimelineTrack(this.frames[this.selectedFrameIndex])}),s++,n.push({element:l,isCollapsed:h.isCollapsed||d,id:u})}else o.method.startsWith("finish")?(l.innerHTML=o.method+(o.formatedDetails?o.formatedDetails:"")+(o.count>1?` <span style="opacity: 0.5">( ${o.count} )</span>`:""),s=Math.max(0,s-1),n.pop()):l.innerHTML=o.method+(o.formatedDetails?o.formatedDetails:"")+(o.count>1?` <span style="opacity: 0.5">( ${o.count} )</span>`:"")}}else{let i={};for(let s=0;s<e.calls.length;s++){let n=e.calls[s].method;n.startsWith("finish")||(i[n]=(i[n]||0)+1)}let r=Object.keys(i).map(s=>({method:s,count:i[s]}));r.sort((s,n)=>n.count-s.count);for(let s=0;s<r.length;s++){let n=r[s],a=document.createElement("div");a.style.padding="4px 8px",a.style.margin="2px 0",a.style.borderLeft="4px solid "+this.getColorForMethod(n.method),a.style.backgroundColor="rgba(255, 255, 255, 0.03)",a.style.fontFamily="monospace",a.style.fontSize="12px",a.style.color="var(--text-primary)",a.style.whiteSpace="nowrap",a.style.overflow="hidden",a.style.textOverflow="ellipsis",a.textContent=n.method+(n.count>1?` ( ${n.count} )`:""),t.appendChild(a)}}this.timelineTrack.appendChild(t)}getColorForMethod(e){return e.startsWith("begin")?"var(--color-green)":e.startsWith("finish")||e.startsWith("destroy")?"var(--color-red)":e.startsWith("draw")||e.startsWith("compute")||e.startsWith("create")||e.startsWith("generate")?"var(--color-yellow)":"var(--text-secondary)"}};v.BRDF_GGX,v.BRDF_Lambert,v.BasicPointShadowFilter,v.BasicShadowFilter,v.Break,v.Const,v.Continue,v.DFGLUT,v.D_GGX;var oa=v.Discard;v.EPSILON,v.F_Schlick;var Vt=v.Fn;v.INFINITY;var Pd=v.If;v.Loop,v.NodeAccess,v.NodeShaderStage,v.NodeType,v.NodeUpdateType,v.PCFShadowFilter,v.PCFSoftShadowFilter,v.PI,v.PI2,v.TWO_PI,v.HALF_PI,v.PointShadowFilter,v.Return,v.Schlick_to_F0,v.ShaderNode,v.Stack,v.Switch,v.TBNViewMatrix,v.VSMShadowFilter,v.V_GGX_SmithCorrelated,v.Var,v.VarIntent;var xH=v.abs;v.acesFilmicToneMapping,v.acos,v.add,v.addMethodChaining,v.addNodeElement,v.agxToneMapping,v.all,v.alphaT,v.and,v.anisotropy,v.anisotropyB,v.anisotropyT,v.any,v.append,v.array,v.arrayBuffer,v.asin,v.assign;var O0=v.atan;v.atomicAdd,v.atomicAnd,v.atomicFunc,v.atomicLoad,v.atomicMax,v.atomicMin,v.atomicOr,v.atomicStore,v.atomicSub,v.atomicXor,v.attenuationColor,v.attenuationDistance;var xl=v.attribute;v.attributeArray,v.backgroundBlurriness,v.backgroundIntensity,v.backgroundRotation,v.batch,v.bentNormalView,v.billboarding,v.bitAnd,v.bitNot,v.bitOr,v.bitXor,v.bitangentGeometry,v.bitangentLocal,v.bitangentView,v.bitangentWorld,v.bitcast,v.blendBurn,v.blendColor,v.blendDodge,v.blendOverlay,v.blendScreen,v.blur,v.bool,v.buffer,v.bufferAttribute,v.bumpMap,v.builtin,v.builtinAOContext,v.builtinShadowContext,v.bvec2,v.bvec3,v.bvec4,v.bypass,v.cache,v.call,v.cameraFar,v.cameraIndex,v.cameraNear,v.cameraNormalMatrix,v.cameraPosition;var T3=v.cameraProjectionMatrix;v.cameraProjectionMatrixInverse,v.cameraViewMatrix,v.cameraViewport;var vH=v.cameraWorldMatrix;v.cbrt,v.cdl,v.ceil,v.checker,v.cineonToneMapping,v.clamp,v.clearcoat,v.clearcoatNormalView,v.clearcoatRoughness,v.clipSpace,v.code,v.color,v.colorSpaceToWorking,v.colorToDirection,v.compute,v.computeKernel,v.computeSkinning,v.context,v.convert,v.convertColorSpace;var bH=v.convertToTexture;v.countLeadingZeros,v.countOneBits,v.countTrailingZeros;var I_=v.cos;v.cross,v.cubeTexture,v.cubeTextureBase,v.dFdx,v.dFdy,v.dashSize,v.debug,v.decrement,v.decrementBefore,v.defaultBuildStages,v.defaultShaderStages,v.defined,v.degrees,v.deltaTime,v.densityFog,v.densityFogFactor,v.depth,v.depthPass,v.determinant,v.difference,v.diffuseColor,v.directPointLight,v.directionToColor,v.directionToFaceDirection,v.dispersion,v.distance,v.div,v.dot,v.drawIndex,v.dynamicBufferAttribute,v.element,v.emissive,v.equal,v.equirectUV,v.exp,v.exp2,v.exponentialHeightFogFactor,v.expression,v.faceDirection,v.faceForward,v.faceforward;var Be=v.float;v.floatBitsToInt,v.floatBitsToUint;var F_=v.floor;v.fog,v.fract,v.frameGroup,v.frameId,v.frontFacing,v.fwidth,v.gain,v.gapSize,v.getConstNodeType,v.getCurrentStack,v.getDirection,v.getDistanceAttenuation,v.getGeometryRoughness,v.getNormalFromDepth,v.interleavedGradientNoise,v.vogelDiskSample,v.getParallaxCorrectNormal,v.getRoughness,v.getScreenPosition,v.getShIrradianceAt,v.getShadowMaterial,v.getShadowRenderObjectFunction,v.getTextureIndex,v.getViewPosition,v.globalId,v.glsl,v.glslFn,v.grayscale,v.greaterThan,v.greaterThanEqual,v.hash,v.highpModelNormalViewMatrix,v.highpModelViewMatrix,v.hue,v.increment,v.incrementBefore,v.instance;var qi=v.instanceIndex,w3=v.instancedArray,vl=v.instancedBufferAttribute;v.instancedDynamicBufferAttribute,v.instancedMesh,v.int,v.intBitsToFloat,v.inverse,v.inverseSqrt,v.inversesqrt,v.invocationLocalIndex,v.invocationSubgroupIndex,v.ior,v.iridescence,v.iridescenceIOR,v.iridescenceThickness,v.ivec2,v.ivec3,v.ivec4,v.js,v.label,v.length,v.lengthSq,v.lessThan,v.lessThanEqual,v.lightPosition,v.lightProjectionUV,v.lightShadowMatrix,v.lightTargetDirection,v.lightTargetPosition,v.lightViewPosition,v.lightingContext,v.lights,v.linearDepth,v.linearToneMapping,v.localId,v.log,v.log2,v.logarithmicDepthToViewZ,v.luminance,v.mat2,v.mat3,v.mat4,v.matcapUV,v.materialAO,v.materialAlphaTest,v.materialAnisotropy,v.materialAnisotropyVector,v.materialAttenuationColor,v.materialAttenuationDistance,v.materialClearcoat,v.materialClearcoatNormal,v.materialClearcoatRoughness,v.materialColor,v.materialDispersion,v.materialEmissive,v.materialEnvIntensity,v.materialEnvRotation,v.materialIOR,v.materialIridescence,v.materialIridescenceIOR,v.materialIridescenceThickness,v.materialLightMap,v.materialLineDashOffset,v.materialLineDashSize,v.materialLineGapSize,v.materialLineScale,v.materialLineWidth,v.materialMetalness,v.materialNormal;var D_=v.materialOpacity;v.materialPointSize,v.materialReference,v.materialReflectivity,v.materialRefractionRatio,v.materialRotation,v.materialRoughness,v.materialSheen,v.materialSheenRoughness,v.materialShininess,v.materialSpecular,v.materialSpecularColor,v.materialSpecularIntensity,v.materialSpecularStrength,v.materialThickness,v.materialTransmission;var kd=v.max;
2095v.maxMipLevel,v.mediumpModelViewMatrix,v.metalness;var _H=v.min,no=v.mix;v.mixElement;var S3=v.mod;v.modInt,v.modelDirection,v.modelNormalMatrix,v.modelPosition,v.modelRadius,v.modelScale;var B0=v.modelViewMatrix;v.modelViewPosition,v.modelViewProjection,v.modelWorldMatrix;var TH=v.modelWorldMatrixInverse;v.morphReference,v.mrt,v.mul,v.mx_aastep,v.mx_add,v.mx_atan2,v.mx_cell_noise_float,v.mx_contrast,v.mx_divide,v.mx_fractal_noise_float,v.mx_fractal_noise_vec2,v.mx_fractal_noise_vec3,v.mx_fractal_noise_vec4,v.mx_frame,v.mx_heighttonormal,v.mx_hsvtorgb,v.mx_ifequal,v.mx_ifgreater,v.mx_ifgreatereq,v.mx_invert,v.mx_modulo,v.mx_multiply,v.mx_noise_float,v.mx_noise_vec3,v.mx_noise_vec4,v.mx_place2d,v.mx_power,v.mx_ramp4,v.mx_ramplr,v.mx_ramptb,v.mx_rgbtohsv,v.mx_rotate2d,v.mx_rotate3d,v.mx_safepower,v.mx_separate,v.mx_splitlr,v.mx_splittb,v.mx_srgb_texture_to_lin_rec709,v.mx_subtract,v.mx_timer,v.mx_transform_uv,v.mx_unifiednoise2d,v.mx_unifiednoise3d,v.mx_worley_noise_float,v.mx_worley_noise_vec2,v.mx_worley_noise_vec3,v.negate,v.neutralToneMapping,v.nodeArray,v.nodeImmutable;var wH=v.nodeObject;v.nodeObjectIntent,v.nodeObjects,v.nodeProxy,v.nodeProxyIntent,v.normalFlat,v.normalGeometry,v.normalLocal,v.normalMap,v.normalView,v.normalViewGeometry,v.normalWorld,v.normalWorldGeometry;var U0=v.normalize;v.not,v.notEqual,v.numWorkgroups,v.objectDirection,v.objectGroup,v.objectPosition,v.objectRadius,v.objectScale,v.objectViewPosition,v.objectWorldMatrix,v.OnBeforeObjectUpdate,v.OnBeforeMaterialUpdate,v.OnObjectUpdate;var SH=v.OnMaterialUpdate;v.oneMinus,v.or,v.orthographicDepthToViewZ,v.oscSawtooth,v.oscSine,v.oscSquare,v.oscTriangle,v.output,v.outputStruct,v.overloadingFn,v.packHalf2x16,v.packSnorm2x16,v.packUnorm2x16,v.parabola,v.parallaxDirection,v.parallaxUV,v.parameter;var MH=v.pass,CH=v.passTexture;v.pcurve,v.perspectiveDepthToViewZ,v.pmremTexture,v.pointShadow,v.pointUV,v.pointWidth;var V0=v.positionGeometry;v.positionLocal,v.positionPrevious,v.positionView,v.positionViewDirection,v.positionWorld,v.positionWorldDirection,v.posterize,v.pow,v.pow2,v.pow3,v.pow4,v.premultiplyAlpha,v.property,v.radians;var ao=v.rand;v.range,v.rangeFog,v.rangeFogFactor,v.reciprocal,v.reference,v.referenceBuffer,v.reflect,v.reflectVector,v.reflectView,v.reflector,v.refract,v.refractVector,v.refractView,v.reinhardToneMapping;var Gh=v.remap,z0=v.remapClamp;v.renderGroup;var RH=v.renderOutput;v.rendererReference,v.replaceDefaultUV,v.rotate;var EH=v.rotateUV;v.roughness,v.round,v.rtt,v.sRGBTransferEOTF,v.sRGBTransferOETF,v.sample,v.sampler,v.samplerComparison,v.saturate,v.saturation,v.screen,v.screenCoordinate,v.screenDPR,v.screenSize;var Ms=v.screenUV;v.select,v.setCurrentStack,v.setName,v.shaderStages,v.shadow,v.shadowPositionWorld,v.shapeCircle,v.sharedUniformGroup,v.sheen,v.sheenRoughness,v.shiftLeft,v.shiftRight,v.shininess;var AH=v.sign,G0=v.sin;v.sinc,v.skinning;var O_=v.smoothstep;v.smoothstepElement,v.specularColor,v.specularF90,v.spherizeUV,v.split,v.spritesheetUV;var M3=v.sqrt;v.stack;var Ks=v.step;v.stepElement,v.storage,v.storageBarrier,v.storageTexture,v.string,v.struct,v.sub,v.subgroupAdd,v.subgroupAll,v.subgroupAnd,v.subgroupAny,v.subgroupBallot,v.subgroupBroadcast,v.subgroupBroadcastFirst,v.subBuild,v.subgroupElect,v.subgroupExclusiveAdd,v.subgroupExclusiveMul,v.subgroupInclusiveAdd,v.subgroupInclusiveMul,v.subgroupIndex,v.subgroupMax,v.subgroupMin,v.subgroupMul,v.subgroupOr,v.subgroupShuffle,v.subgroupShuffleDown,v.subgroupShuffleUp,v.subgroupShuffleXor,v.subgroupSize,v.subgroupXor,v.tan,v.tangentGeometry,v.tangentLocal,v.tangentView,v.tangentWorld;var Fi=v.texture;v.texture3D,v.textureBarrier,v.textureBicubic,v.textureBicubicLevel,v.textureCubeUV,v.textureLoad,v.textureSize,v.textureLevel,v.textureStore,v.thickness;var jh=v.time;v.toneMapping,v.toneMappingExposure,v.toonOutlinePass,v.transformDirection,v.transformNormal,v.transformNormalToView,v.transformedClearcoatNormalView,v.transformedNormalView,v.transformedNormalWorld,v.transmission,v.transpose,v.triNoise3D,v.triplanarTexture,v.triplanarTextures,v.trunc,v.uint,v.uintBitsToFloat;var Le=v.uniform;v.uniformArray,v.uniformCubeTexture,v.uniformGroup,v.uniformFlow,v.uniformTexture,v.unpackHalf2x16,v.unpackSnorm2x16,v.unpackUnorm2x16,v.unpremultiplyAlpha,v.userData;var la=v.uv;v.uvec2,v.uvec3,v.uvec4;var C3=v.varying,B_=v.varyingProperty,Je=v.vec2,fn=v.vec3,ai=v.vec4;v.vectorComponents,v.velocity,v.vertexColor,v.vertexIndex,v.vertexStage,v.vibrance,v.viewZToLogarithmicDepth,v.viewZToOrthographicDepth,v.viewZToPerspectiveDepth,v.viewZToReversedOrthographicDepth,v.viewZToReversedPerspectiveDepth,v.viewport,v.viewportCoordinate,v.viewportDepthTexture,v.viewportLinearDepth,v.viewportMipTexture,v.viewportOpaqueMipTexture,v.viewportResolution,v.viewportSafeUV,v.viewportSharedTexture,v.viewportSize,v.viewportTexture,v.viewportUV,v.wgsl,v.wgslFn,v.workgroupArray,v.workgroupBarrier,v.workgroupId,v.workingToColorSpace,v.xor;var NH=Vt(([e,t])=>{let i=Le(0);SH(()=>{let{width:n,height:a}=t.value;i.value=n/a});let r=e.sub(.5),s=Je(r.x.div(i),r.y).add(.5);return fn(s,Ks(0,s.x).mul(Ks(s.x,1)).mul(Ks(0,s.y)).mul(Ks(s.y,1)))}),LH=class extends QW{constructor(){super();let e=new tH;e.addEventListener("resize",l=>this.dispatchEvent(l));let t=new y3({builtin:!0,icon:'<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M14 6m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0" /><path d="M4 6l8 0" /><path d="M16 6l4 0" /><path d="M8 12m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0" /><path d="M4 12l2 0" /><path d="M10 12l10 0" /><path d="M17 18m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0" /><path d="M4 18l11 0" /><path d="M19 18l1 0" /></svg>'});t.hide(),e.addTab(t);let i=new fH;i.hide(),e.addTab(i);let r=new sH;e.addTab(r);let s=new nH;e.addTab(s);let n=new yH;e.addTab(n);let a=new aH;e.addTab(a);let o=new gH;e.addTab(o),e.loadLayout(),e.activeTabId||e.setActiveTab(r.id),this.statsData=new Map,this.canvasNodes=new Map,this.profiler=e,this.performance=r,this.memory=s,this.console=a,this.parameters=t,this.viewer=i,this.timeline=n,this.once={},this.displayCycle={text:{needsUpdate:!1,duration:.25,time:0},graph:{needsUpdate:!1,duration:.02,time:0}}}get domElement(){return this.profiler.domElement}hide(){this.profiler.hide()}show(){this.profiler.show()}getSize(){return this.profiler.getSize()}setActiveTab(e){return this.profiler.setActiveTab(e.id),this}addTab(e){return this.profiler.addTab(e),this}removeTab(e){return this.profiler.removeTab(e),this}resolveConsoleOnce(e,t){let i=e+t;this.once[i]!==!0&&(this.resolveConsole(e,t),this.once[i]=!0)}resolveConsole(e,t,i=null){switch(e){case"log":this.console.addMessage("info",t),console.log(t);break;case"warn":this.console.addMessage("warn",t),i&&i.isStackTrace?console.warn(i.getError(t)):console.warn(t);break;case"error":this.console.addMessage("error",t),i&&i.isStackTrace?console.error(i.getError(t)):console.error(t);break}}init(){let e=this.getRenderer(),t=`THREE.WebGPURenderer: ${lh} [ "`;e.backend.isWebGPUBackend?t+="WebGPU":e.backend.isWebGLBackend&&(t+="WebGL2"),t+='" ]',this.console.addMessage("info",t),e.inspector.domElement.parentElement===null&&e.domElement.parentElement!==null&&e.domElement.parentElement.appendChild(e.inspector.domElement)}setRenderer(e){return super.setRenderer(e),e!==null&&(_B(this.resolveConsole.bind(this)),this.isAvailable&&(e.init().then(()=>{e.backend.trackTimestamp=!0,e.hasFeature("timestamp-query")!==!0&&this.console.addMessage("error","THREE.Inspector: GPU Timestamp Queries not available.")}),this.timeline.setRenderer(e))),this}createParameters(e){return this.parameters.isVisible===!1&&this.parameters.show(),this.parameters.createGroup(e)}getStatsData(e){let t=this.statsData.get(e);return t===void 0&&(t={},this.statsData.set(e,t)),t}resolveStats(e){let t=this.getStatsData(e.cid);t.initialized!==!0&&(t.cpu=e.cpu,t.gpu=e.gpu,t.stats=[],t.initialized=!0),t.stats.length>this.maxFrames&&t.stats.shift(),t.stats.push(e),t.cpu=this.getAverageDeltaTime(t,"cpu"),t.gpu=this.getAverageDeltaTime(t,"gpu"),t.total=t.cpu+t.gpu;for(let i of e.children){this.resolveStats(i);let r=this.getStatsData(i.cid);t.cpu+=r.cpu,t.gpu+=r.gpu,t.total+=r.total}}getCanvasDataByNode(e){let t=this.canvasNodes.get(e);if(t===void 0){let i=this.getRenderer(),r=new FL(document.createElement("canvas"));r.setPixelRatio(window.devicePixelRatio),r.setSize(140,140);let s=e.id,{path:n,name:a}=iH(rH(e.getName()||"(unnamed)")),o=ai(fn(e.context({getUV:u=>{let d=NH(Ms,u),c=d.xy,p=d.z;return c.mul(p)}})),1);o=RH(o,0,i.outputColorSpace),o=o.context({inspector:!0});let l=new Ot;l.outputNode=o;let h=new _d(l);h.name="Viewer - "+a,t={id:s,name:a,path:n,node:e,quad:h,canvasTarget:r,material:l},this.canvasNodes.set(e,t)}return t}resolveViewer(){let e=this.currentNodes,t=this.getRenderer();if(e.length===0)return;if(!t.backend.isWebGPUBackend){this.resolveConsoleOnce("warn","Inspector: Viewer is only available with WebGPU.");return}this.viewer.isVisible||this.viewer.show();let i=e.map(r=>this.getCanvasDataByNode(r));this.viewer.update(t,i)}getAverageDeltaTime(e,t,i=this.fps){let r=e.stats,s=0,n=0;for(let a=r.length-1;a>=0&&n<i;a--){let o=r[a][t];o>0&&(s+=o,n++)}return n>0?s/n:0}resolveFrame(e){let t=this.getFrameById(e.frameId+1);if(t){e.cpu=0,e.gpu=0,e.total=0;for(let i of e.children){this.resolveStats(i);let r=this.getStatsData(i.cid);e.cpu+=r.cpu,e.gpu+=r.gpu,e.total+=r.total}e.deltaTime=t.startTime-e.startTime,e.miscellaneous=e.deltaTime-e.total,e.miscellaneous<0&&(e.miscellaneous=0),this.updateCycle(this.displayCycle.text),this.updateCycle(this.displayCycle.graph),this.displayCycle.text.needsUpdate&&(Ut("fps-counter",this.fps.toFixed()),this.performance.updateText(this,e),this.memory.updateText(this)),this.displayCycle.graph.needsUpdate&&(this.performance.updateGraph(this,e),this.memory.updateGraph(this)),this.displayCycle.text.needsUpdate=!1,this.displayCycle.graph.needsUpdate=!1}}updateCycle(e){e.time+=this.nodeFrame.deltaTime,e.time>=e.duration&&(e.needsUpdate=!0,e.time=0)}};function PH(){if(typeof document>"u")return"";try{let e=document.createElement("canvas"),t=e.getContext("webgl")||e.getContext("experimental-webgl");
2095if(!t)return"";let i=t.getExtension("WEBGL_debug_renderer_info");return i?String(t.getParameter(i.UNMASKED_RENDERER_WEBGL)||""):""}catch{return""}}function R3(e="",t=null){return t?.vendor&&/img-tec/i.test(t.vendor)||t?.architecture&&/d-series|b-series/i.test(t.architecture)?!0:/PowerVR|IMG[\s-]?BXM|Imagination|img-tec/i.test(e)}async function kH(){if(typeof navigator>"u"||!navigator.gpu)return{supported:!1,reason:"no-gpu"};try{let e=await navigator.gpu.requestAdapter();if(!e)return{supported:!1,reason:"no-adapter"};let t=e.info||null;if(R3("",t))return{supported:!1,reason:"powervr-img",adapterInfo:t};let i=await e.requestDevice({requiredFeatures:Array.from(e.features)});return i.features.has("core-features-and-limits")?{supported:!0,reason:"ok",device:i,adapterInfo:t}:(i.destroy(),{supported:!1,reason:"compatibility-mode",adapterInfo:t})}catch(e){return{supported:!1,reason:e.message||"error"}}}async function IH(){let e=PH();if(typeof window<"u"&&window.location.search.includes("webgl"))return{force:!0,reason:"url",renderer:e};if(R3(e))return{force:!0,reason:"powervr-img",renderer:e};let t=await kH();return t.supported?{force:!1,reason:"ok",device:t.device,renderer:e,adapterInfo:t.adapterInfo}:{force:!0,reason:t.reason,renderer:e,adapterInfo:t.adapterInfo}}var FH=window.location.search.includes("stats"),q=new class{constructor(){this.scene=new Oc,this.renderTime=1,this.frustumSize=1,this.camera=new rf(-1,1,1,-1,0,100),this.camera.position.set(0,0,10),this.camera.lookAt(0,0,0),this._disposalQueue=new Set,this._drainScheduled=!1,this._isRenderingMain=!1}getAntialiasSetting(){let e=y2();return!Fs&&(!Number.isFinite(e)||e<=2)}applyDisplaySettings=()=>{this.renderer&&(this.renderer.setPixelRatio(N.devicePixelRatio),this.renderer.setSize(N.width,N.height),this.scheduleRender())};async initRender(e={}){if(!this.renderer){let t=await IH(),i=t.force,r=i?void 0:t.device;this.renderer=new F0({antialias:this.getAntialiasSetting(),logarithmicDepthBuffer:!1,alpha:!1,forceWebGL:i,device:r}),await this.renderer.init(),Ps.log(`THREE VERSION: ${lh}, BackEnd ${this.isWebGPU?"WebGPU":"WebGL2"} (reason: ${t.reason}${t.renderer?`, gpu: ${t.renderer}`:""})`),this.applyDisplaySettings(),this.renderer.setClearColor(e.background||14540253,1),this.renderer.domElement.classList.add("three"),this.renderer.domElement.style.position="absolute",this.renderer.domElement.style.inset="0",this.renderer.domElement.style.zIndex="1",this.renderer.domElement.style.pointerEvents="none",this.renderer.domElement.style.userSelect="none",this.renderer.domElement.style.touchAction="none",(e.domElement||document.body.querySelector("#map")||document.body).appendChild(this.renderer.domElement),FH&&(this.renderer.inspector=new LH,this.renderer.inspector.init())}this.isPaused=!1,N.onResize.add(this.resize),N.onAfterUpdate.add(this.update),this.scheduleRender(0)}update=e=>{this.isPaused||!this.renderer||(this.control?.update(e),this.renderTime>0&&this.render(),this.renderTime-=e)};render=async()=>{this._isRenderingMain=!0,this.stats?(await this.renderer.render(this.scene,this.camera),this.renderer.resolveTimestampsAsync(Ur.RENDER),this.stats.update()):this.renderer.render(this.scene,this.camera),this.drainDisposalQueue(),this._isRenderingMain=!1};scheduleRender=(e=350)=>{this.renderTime=Math.max(e,this.renderTime)};add=e=>{this.scene.add(e)};remove=e=>{this.scene.remove(e)};removeAll=()=>{for(;this.scene.children.length>0;)this.scene.remove(this.scene.children[0])};pause=()=>{this.isPaused||(this.isPaused=!0,this.control&&(this.control.isActive=!1))};resume=()=>{this.isPaused&&(this.isPaused=!1,this.control&&(this.control.isActive=!0))};resize=()=>{let e=N.width/N.height;this.camera.isOrthographicCamera?(this.camera.left=-this.frustumSize/2,this.camera.right=this.frustumSize/2,this.camera.top=this.frustumSize/2,this.camera.bottom=-this.frustumSize/2):this.camera.aspect=e,this.camera.updateProjectionMatrix(),this.applyDisplaySettings(),this.render()};set fov(e){this.camera.fov=e,this.camera.updateProjectionMatrix()}get fov(){return this.camera.fov}dispose(){this.removeAll(),this.control?.disable(),N.onResize.remove(this.resize),N.onUpdate.remove(this.render),this.stats&&=(this.stats.dom.remove(),null),this.renderer&&=(this.renderer.domElement.remove(),this.renderer.clear(),this.renderer.dispose(),null),this.scene=null,this.camera=null}queueForSafeDispose(e){e&&this._disposalQueue.add(e)}drainDisposalQueue(){this._drainScheduled||!this._disposalQueue||this._disposalQueue.size===0||(this._drainScheduled=!0,requestAnimationFrame(()=>{requestAnimationFrame(()=>
2095{try{this._disposalQueue.forEach(e=>{try{e&&typeof e.dispose=="function"&&e.dispose()}catch(t){console.warn("[Stage3D] Error disposing queued resource",t)}}),this._disposalQueue.clear()}finally{this._drainScheduled=!1}})}))}get isRenderingMain(){return this._isRenderingMain}async gpuUpload(e){this.compileScene=this.compileScene||new Oc,this.compileCamera=this.compileCamera||new os(60,N.width/N.height,1e-4,1e4),this.compileCamera.position.set(0,0,1e4),this.compileCamera.lookAt(0,0,0),this.compileGeometry=this.compileGeometry||new Un(1,1),this.compileMeshs=[],this.compileScene.environment=this.scene.environment;let t=[];for(let i of e)if(i&&!i.isLight&&!i.isCamera)if(i.isTexture)if(i.needsUpdate=!0,this.renderer.initTexture)this.renderer.initTexture?.(i);else{let r=new xt(this.compileGeometry,new Qn({map:i}));r.frustumCulled=!1,this.compileMeshs.push(r),this.compileScene.add(r)}else if(i.isMaterial){let r=new xt(this.compileGeometry,i);this.compileScene.add(r)}else i.isObject3D&&(t.push({parent:i.parent,frustumCulled:i.frustumCulled}),i.frustumCulled=!1,this.compileScene.add(i));return this.renderer.compileAsync(this.compileScene,this.compileCamera,this.scene).then(()=>{let i=0;for(let r of e)r&&(r.isLight||r.isCamera||r.isMaterial||r.isTexture||(t[i]&&(t[i].parent&&t[i].parent.add(r),r.frustumCulled=t[i].frustumCulled),i++));for(let r of this.compileMeshs)r.parent.remove(r),r.material.dispose();this.compileMeshs=[]})}async gpuUploadTexture(e){if(!e||!e.isTexture){console.warn("[Stage3D] gpuUploadTexture: Invalid texture provided.",e);return}return this.renderer.initTexture(e)}screenshot(e=!0){e&&this.render();let{promise:t,resolve:i,reject:r}=Promise.withResolvers();return this.renderer.domElement.toBlob(s=>{let n=new Image,a=URL.createObjectURL(s);n.onload=()=>{URL.revokeObjectURL(a),i(n)},n.src=a},"image/png",100),t}get isWebGPU(){return this.renderer?.backend?.isWebGPUBackend===!0&&this.renderer.backend.compatibilityMode!==!0}},U_={none:0,error:1,warn:2,info:3,debug:4},DH=window.__APP_LOAD_START||performance.now(),E3=class{constructor(e=""){this.prefix=e}shouldLog(e){return U_[bI.value]||U_.info,U_[e],0}getTimestamp(){return`[${(performance.now()-DH).toFixed(0)}ms]`}debug(...e){this.shouldLog("debug")&&console.log(this.getTimestamp(),this.prefix,...e)}info(...e){this.shouldLog("info")&&console.log(this.getTimestamp(),this.prefix,...e)}warn(...e){this.shouldLog("warn")&&console.warn(this.getTimestamp(),this.prefix,...e)}error(...e){this.shouldLog("error")&&console.error(this.getTimestamp(),this.prefix,...e)}time(e){this.shouldLog("debug")&&console.time(e)}timeEnd(e){this.shouldLog("debug")&&console.timeEnd(e)}};function Id(e){return new E3(e)}new E3;function OH(e,t){if(!(e instanceof Date)||isNaN(e))throw Error("Invalid date provided");if(!t)throw Error("Timezone parameter is required");try{Intl.DateTimeFormat("en-US",{timeZone:t})}catch{throw Error("Invalid timezone provided")}return new Date(e.toLocaleString("en-US",{timeZone:t,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}))}var BH=class{constructor(e){this.id=e.id,this.name=e.name,this.order=e.order,this.layers=[]}addLayer(e){this.layers.push(e)}},A3=new class{groups=[];init(e){if(!e){console.warn("No group data provided to GroupManager");return}if(e)for(let t of e)this.groups.push(new BH(t))}getGroupByID(e){return this.groups.find(t=>t.id===e)}},UH=class{constructor(e){this.id=e.id,this.name=e.name,this.param=e.param}toString(){return`LegendType-${this.id} ${this.name}`}},VH=class{constructor(e){this.id=e.id,this.name=e.name}toString(){return`LegendUnit-${this.id} ${this.name}`}},zH=class{constructor(e){if(this.id=e.id,this.type=$h.getLegendTypeByID(e.type),this.unit=$h.getLegendUnitByID(e.unit),this.values=e.values,this.hexColors=e.colors_hexa,this.hexColors)for(let t=0;t<this.hexColors.length;t++){let i=this.hexColors[t];if(i.startsWith("#")||(i="#"+i),i.length===9){let r=i.substring(1,3),s=parseInt(r,16).toString(16).padStart(2,"0").toUpperCase();i="#"+i.substring(3)+s}this.hexColors[t]=i}this.textColors=e.text_hexa,this.name=this.unit.name}toString(){return`Legend-${this.id} : ${this.unit.name} ${this.type.name}`}},$h=new class{legends=[];types=[];units=[];init(e){if(!e){console.warn("No legend data provided to LegendsManager");return}for(let t of e.types){let i=new UH(t);this.types.push(i)}for(let t of e.units)for(let i of t){let r=new VH(i);this.units.push(r)}for(let t of e.legends){let i=new zH(t);this.legends.push(i)}}getLegendTypeByID(e){return this.types.find(t=>
2095t.id===e)}getLegendUnitByID(e){return this.units.find(t=>t.id===e)}getLegendByID(e){return this.legends.find(t=>t.id===e)}},GH=class{constructor(e){this.id=e.id,this.name=e.name,this.hideInPlayMode=e.hide_in_playmode,this.param=e.param}},N3=new class{overlays=[];init(e){if(!e){console.warn("No overlay data provided to OverlayManager");return}for(let t=0;t<e.length;t++)for(let i of e[t])this.overlays.push(new GH(i))}getOverlayByID(e){return this.overlays.find(t=>t.id===e)}},jH=class{constructor(e){this.id=e.id,this.name=e.name,this.bounds=e.bounds,this.dateRunFormat=e.date_run_format,this.dateRunTZLocale=e.date_run_tz_locale,this.endDate=e.end_date,this.lastRun=e.last_run,this.lastUpdate=e.last_update,this.nextRun=e.next_run,this.nextUpdate=e.next_update,this.resolution=e.resolution,this.startDate=e.start_date,this.fallback=null,this.forecastDates=[],this.timeReference="",this.jsonLoaded=!1,this.json={}}async loadExtraData(){this.json=await TI(`${dw.value}/${this.name}`),this.jsonLoaded=!0;let e=(this.json.content.contenu||this.json.contenu||this.json.content).models[0];if(this.fallback=e.chronologic_fallback,this.forecastDates=e.forecast_date,Array.isArray(this.forecastDates))for(let t of this.forecastDates)t._date||=new Date(t.datetime.split("+")[0]);return this.startDate=e.start_date,this.endDate=e.end_date,this.timeReference=e.time_reference,this.json}async loadParamsData(){}toString(){}},V_=new class{models=[];init(e){if(!e){console.warn("No model data provided to ModelManager");return}for(let t of e){let i=new jH(t);this.models.push(i)}}getModelByID(e){return this.models.find(t=>t.id===e)}};Id("[ProviderManager]");var $H=class{constructor(e){this.startDate=e.start_date,this.endDate=e.end_date,this.name=e.name,this.logo=e.logo,this.flag=e.flag,this.source=e.source,this.tileType="";let t=e.params[0];if(this.model=V_.getModelByID(t.model_id),this.layerName=t.param,this.id=e.provider_id+"-"+this.layerName,this.legends=null,t.legends.length>0){this.legends=[];for(let i of t.legends){let r=$h.getLegendByID(i.legend_id);this.legends.push({legend:r,name:i.name})}}this.isLoaded=!1}toString(){return`Provider-${this.id} - ${this.name}: ${this.layerName}`}async loadExtraData(){await this.model.loadExtraData();let e=await TI(`${dw.value}/${this.model.name}/${this.layerName}`);if(e=e?.content?.contenu?.parameters?.[0]??e?.content?.parameters?.[0],this.tileType=e.source_structure,this.backgroundColor=e.background_color,this.backgroundLayer=e.background_layer=="NO"?null:e.background_layer,this.foregroundLayer=e.foreground_layer=="NO"?null:e.foreground_layer,this.backgroundColor=="BlueMarbleMC"&&(this.backgroundColor="BlueMarble"),this.foregroundLayer=="BlueMarbleMC"&&(this.foregroundLayer="BlueMarble"),this.zoomCorrespondances=e.source_zoom_correspondance,this.zoomCorrespondances){this.minZoom=3,this.maxZoom=0;for(let t=0;t<this.zoomCorrespondances.length;t++)this.minZoom=Math.min(this.zoomCorrespondances[t],this.minZoom),this.maxZoom=Math.max(this.zoomCorrespondances[t],this.maxZoom)}else this.minZoom=0,this.maxZoom=0;this.foregroundLayer=e.foreground_layer,this.backgroundLayer=e.background_layer,(this.backgroundLayer=="BlueMarbleMC"||this.backgroundLayer=="esri-worldimagery"||this.backgroundLayer=="BlueMarbleMCWebp")&&(pu.value=this.backgroundLayer,this.backgroundLayer="BlueMarble"),this.backgroundColor=e.background_color,e.legends_infos&&e.legends_infos.length>0&&(this.domain=e.legends_infos[0].domain),this.isLoaded=!0}get forecastDates(){return this.model.forecastDates}},L3=new class{providers=[];init(e){for(let t of e)this.add(t)}add(e){let t=new $H(e);return this.providers.push(t),t}getProviderByID(e){return this.providers.find(t=>t.id===e)}},WH=class{constructor(e){this.id=e.id,this.timeZone=e.debug_time_zone,this.startDate=e.start_date,this.endDate=e.end_date,this.currentDate=e.display_date,this.primaryGranularity=e.primary_granularity,this.primaryLabelFormat=e.primary_label_format,this.primaryLabelGranularity=e.primary_label_granularity,this.secondaryGranularity=e.secondary_granularity,this.secondaryLabelFormat=e.secondary_label_format,this.secondaryLabelGranularity=e.secondary_label_granularity,this.cursorGranularity=e.cursor_granularity,this.cursorFormat=e.cursor_format,this.isPlayable=e.play,this.playGranularity=e.play_granularity,this.playSpeed=e.play_speed,this.markerNow=e.marker_now}toString(){return`Timeline from ${this.startDate} to ${this.endDate}`}},z_=e=>{let t=e.start??0,i=Object.entries(e).filter(([r])=>r!=="start").map(([r,s])=>[Number(r),s]).sort((r,s)=>r[0]-s[0]);return r=>{let s=t;for(let[n,a]of i){if(r<n)break;s=a}return s}},HH=(e={})=>{let{providerRef:t,provider:i,correspondances:r,fallback:s={},start:n,incrementStart:a}=e,o=a??s.incrementStart??5,l=null,h=[],u=new Map,d=()=>Array.isArray(r)?r:Array.isArray(t?.value?.zoomCorrespondances)?t.value.zoomCorrespondances:Array.isArray(i?.zoomCorrespondances)?i.zoomCorrespondances:[],c=()=>{let p=d();p!==l&&(l=p,Array.isArray(p)&&p.length>0?(h=p.map(m=>Number.isFinite(m)?m:0),u=new Map,h.forEach((m,g)=>{u.has(m)||u.set(m,g)})):(h=[],u=new Map))};return p=>{if(c(),h.length===0)return p<o?2:p-o+2;let m=Math.max(0,Math.min(p,h.length-1)),g=Math.floor(m),f=h[g];return g-(u.get(f)??g)+2}};function G_(e){let t=Object.create(null);for(let i of e.split(","))t[i]=1;return i=>i in t}var zt={},Fd=[],ha=()=>{},P3=()=>!1,j0=e=>e.charCodeAt(0)===111&&e.charCodeAt(1)===110&&(e.charCodeAt(2)>122||e.charCodeAt(2)<97),$0=e=>e.startsWith("onUpdate:"),sr=Object.assign,j_=(e,t)=>{let i=e.indexOf(t);i>-1&&e.splice(i,1)},qH=Object.prototype.hasOwnProperty,Rt=(e,t)=>
vendor: 13,764 bytes, line 2095
2095qH.call(e,t),Ue=Array.isArray,Dd=e=>Bp(e)==="[object Map]",k3=e=>Bp(e)==="[object Set]",I3=e=>Bp(e)==="[object Date]",ze=e=>typeof e=="function",xi=e=>typeof e=="string",ua=e=>typeof e=="symbol",Gt=e=>typeof e=="object"&&!!e,F3=e=>(Gt(e)||ze(e))&&ze(e.then)&&ze(e.catch),D3=Object.prototype.toString,Bp=e=>D3.call(e),XH=e=>Bp(e).slice(8,-1),O3=e=>Bp(e)==="[object Object]",$_=e=>xi(e)&&e!=="NaN"&&e[0]!=="-"&&""+parseInt(e,10)===e,Up=G_(",key,ref,ref_for,ref_key,onVnodeBeforeMount,onVnodeMounted,onVnodeBeforeUpdate,onVnodeUpdated,onVnodeBeforeUnmount,onVnodeUnmounted"),W0=e=>{let t=Object.create(null);return(i=>t[i]||(t[i]=e(i)))},YH=/-\w/g,Zr=W0(e=>e.replace(YH,t=>t.slice(1).toUpperCase())),KH=/\B([A-Z])/g,Wh=W0(e=>e.replace(KH,"-$1").toLowerCase()),H0=W0(e=>e.charAt(0).toUpperCase()+e.slice(1)),W_=W0(e=>e?`on${H0(e)}`:""),da=(e,t)=>!Object.is(e,t),H_=(e,...t)=>{for(let i=0;i<e.length;i++)e[i](...t)},B3=(e,t,i,r=!1)=>{Object.defineProperty(e,t,{configurable:!0,enumerable:!1,writable:r,value:i})},ZH=e=>{let t=parseFloat(e);return isNaN(t)?e:t},JH,q0=()=>JH||=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{};function bl(e){if(Ue(e)){let t={};for(let i=0;i<e.length;i++){let r=e[i],s=xi(r)?iq(r):bl(r);if(s)for(let n in s)t[n]=s[n]}return t}else if(xi(e)||Gt(e))return e}var QH=/;(?![^(]*\))/g,eq=/:([^]+)/,tq=/\/\*[^]*?\*\//g;function iq(e){let t={};return e.replace(tq,"").split(QH).forEach(i=>{if(i){let r=i.split(eq);r.length>1&&(t[r[0].trim()]=r[1].trim())}}),t}function Vp(e){let t="";if(xi(e))t=e;else if(Ue(e))for(let i=0;i<e.length;i++){let r=Vp(e[i]);r&&(t+=r+" ")}else if(Gt(e))for(let i in e)e[i]&&(t+=i+" ");return t.trim()}var U3="itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly",rq=G_(U3);U3+"";function V3(e){return!!e||e===""}function sq(e,t){if(e.length!==t.length)return!1;let i=!0;for(let r=0;i&&r<e.length;r++)i=q_(e[r],t[r]);return i}function q_(e,t){if(e===t)return!0;let i=I3(e),r=I3(t);if(i||r)return i&&r?e.getTime()===t.getTime():!1;if(i=ua(e),r=ua(t),i||r)return e===t;if(i=Ue(e),r=Ue(t),i||r)return i&&r?sq(e,t):!1;if(i=Gt(e),r=Gt(t),i||r){if(!i||!r||Object.keys(e).length!==Object.keys(t).length)return!1;for(let s in e){let n=e.hasOwnProperty(s),a=t.hasOwnProperty(s);if(n&&!a||!n&&a||!q_(e[s],t[s]))return!1}}return String(e)===String(t)}var z3=e=>!!(e&&e.__v_isRef===!0),Od=e=>xi(e)?e:e==null?"":Ue(e)||Gt(e)&&(e.toString===D3||!ze(e.toString))?z3(e)?Od(e.value):JSON.stringify(e,G3,2):String(e),G3=(e,t)=>z3(t)?G3(e,t.value):Dd(t)?{[`Map(${t.size})`]:[...t.entries()].reduce((i,[r,s],n)=>(i[X_(r,n)+" =>"]=s,i),{})}:k3(t)?{[`Set(${t.size})`]:[...t.values()].map(i=>X_(i))}:ua(t)?X_(t):Gt(t)&&!Ue(t)&&!O3(t)?String(t):t,X_=(e,t="")=>ua(e)?`Symbol(${e.description??t})`:e,Rr,nq=class{constructor(e=!1){this.detached=e,this._active=!0,this._on=0,this.effects=[],this.cleanups=[],this._isPaused=!1,this._warnOnRun=!0,this.__v_skip=!0,!e&&Rr&&(Rr.active?(this.parent=Rr,this.index=(Rr.scopes||=[]).push(this)-1):(this._active=!1,this._warnOnRun=!1))}get active(){return this._active}pause(){if(this._active){this._isPaused=!0;let e,t;if(this.scopes)for(e=0,t=this.scopes.length;e<t;e++)this.scopes[e].pause();for(e=0,t=this.effects.length;e<t;e++)this.effects[e].pause()}}resume(){if(this._active&&this._isPaused){this._isPaused=!1;let e,t;if(this.scopes)for(e=0,t=this.scopes.length;e<t;e++)this.scopes[e].resume();for(e=0,t=this.effects.length;e<t;e++)this.effects[e].resume()}}run(e){if(this._active){let t=Rr;try{return Rr=this,e()}finally{Rr=t}}}on(){++this._on===1&&(this.prevScope=Rr,Rr=this)}off(){if(this._on>0&&--this._on===0){if(Rr===this)Rr=this.prevScope;else{let e=Rr;for(;e;){if(e.prevScope===this){e.prevScope=this.prevScope;break}e=e.prevScope}}this.prevScope=void 0}}stop(e){if(this._active){this._active=!1;let t,i;for(t=0,i=this.effects.length;t<i;t++)this.effects[t].stop();for(this.effects.length=0,t=0,i=this.cleanups.length;t<i;t++)this.cleanups[t]();if(this.cleanups.length=0,this.scopes){for(t=0,i=this.scopes.length;t<i;t++)this.scopes[t].stop(!0);this.scopes.length=0}if(!this.detached&&this.parent&&!e){let r=this.parent.scopes.pop();r&&r!==this&&(this.parent.scopes[this.index]=r,r.index=this.index)}this.parent=void 0}}};function aq(){return Rr}var Xt,Y_=new WeakSet,j3=class{constructor(e){this.fn=e,this.deps=void 0,this.depsTail=void 0,this.flags=5,this.next=void 0,this.cleanup=void 0,this.scheduler=void 0,Rr&&(Rr.active?Rr.effects.push(this):this.flags&=-2)}pause(){this.flags|=64}resume(){this.flags&64&&(this.flags&=-65,Y_.has(this)&&(Y_.delete(this),this.trigger()))}notify(){this.flags&2&&!(this.flags&32)||this.flags&8||W3(this)}run(){if(!(this.flags&1))return this.fn();this.flags|=2,K3(this),H3(this);let e=Xt,t=yn;Xt=this,yn=!0;try{return this.fn()}finally{q3(this),Xt=e,yn=t,this.flags&=-3}}stop(){if(this.flags&1){for(let e=this.deps;e;e=e.nextDep)Q_(e);this.deps=this.depsTail=void 0,K3(this),this.onStop&&this.onStop(),this.flags&=-2}}trigger(){this.flags&64?Y_.add(this):this.scheduler?this.scheduler():this.runIfDirty()}runIfDirty(){J_(this)&&this.run()}get dirty(){return J_(this)}},$3=0,zp,Gp;function W3(e,t=!1){if(e.flags|=8,t){e.next=Gp,Gp=e;return}e.next=zp,zp=e}function K_(){$3++}function Z_(){if(--$3>0)return;if(Gp){let t=Gp;for(Gp=void 0;t;){let i=t.next;t.next=void 0,t.flags&=-9,t=i}}let e;for(;zp;){let t=zp;for(zp=void 0;t;){let i=t.next;if(t.next=void 0,t.flags&=-9,t.flags&1)try{t.trigger()}catch(r){e||=r}t=i}}if(e)throw e}function H3(e){for(let t=e.deps;t;t=t.nextDep)t.version=-1,t.prevActiveLink=t.dep.activeLink,t.dep.activeLink=t}function q3(e){let t,i=e.depsTail,r=i;for(;r;){let s=r.prevDep;r.version===-1?(r===i&&(i=s),Q_(r),oq(r)):t=r,r.dep.activeLink=r.prevActiveLink,r.prevActiveLink=void 0,r=s}e.deps=t,e.depsTail=i}function J_(e){for(let t=e.deps;t;t=t.nextDep)if(t.dep.version!==t.version||t.dep.computed&&(X3(t.dep.computed)||t.dep.version!==t.version))return!0;return!!e._dirty}function X3(e){if(e.flags&4&&!(e.flags&16)||(e.flags&=-17,e.globalVersion===jp)||(e.globalVersion=jp,!e.isSSR&&e.flags&128&&(!e.deps&&!e._dirty||!J_(e))))return;e.flags|=2;let t=e.dep,i=Xt,r=yn;Xt=e,yn=!0;try{H3(e);let s=e.fn(e._value);(t.version===0||da(s,e._value))&&(e.flags|=128,e._value=s,t.version++)}catch(s){throw t.version++,s}finally{Xt=i,yn=r,q3(e),e.flags&=-3}}function Q_(e,t=!1){let{dep:i,prevSub:r,nextSub:s}=e;if(r&&(r.nextSub=s,e.prevSub=void 0),s&&(s.prevSub=r,e.nextSub=void 0),i.subs===e&&(i.subs=r,!r&&i.computed)){i.computed.flags&=-5;for(let n=i.computed.deps;n;n=n.nextDep)Q_(n,!0)}!t&&!--i.sc&&i.map&&i.map.delete(i.key)}function oq(e){let{prevDep:t,nextDep:i}=e;t&&(t.nextDep=i,e.prevDep=void 0),i&&(i.prevDep=t,e.nextDep=void 0)}var yn=!0,Y3=[];function oo(){Y3.push(yn),yn=!1}function lo(){let e=Y3.pop();yn=e===void 0?!0:e}function K3(e){let{cleanup:t}=e;if(e.cleanup=void 0,t){let i=Xt;Xt=void 0;try{t()}finally{Xt=i}}}var jp=0,lq=class{constructor(e,t){this.sub=e,this.dep=t,this.version=t.version,this.nextDep=this.prevDep=this.nextSub=this.prevSub=this.prevActiveLink=void 0}},eT=class{constructor(e){this.computed=e,this.version=0,this.activeLink=void 0,this.subs=void 0,this.map=void 0,this.key=void 0,this.sc=0,this.__v_skip=!0}track(e){if(!Xt||!yn||Xt===this.computed)return;let t=this.activeLink;if(t===void 0||t.sub!==Xt)t=this.activeLink=new lq(Xt,this),Xt.deps?(t.prevDep=Xt.depsTail,Xt.depsTail.nextDep=t,Xt.depsTail=t):Xt.deps=Xt.depsTail=t,Z3(t);else if(t.version===-1&&(t.version=this.version,t.nextDep)){let i=t.nextDep;i.prevDep=t.prevDep,t.prevDep&&(t.prevDep.nextDep=i),t.prevDep=Xt.depsTail,t.nextDep=void 0,Xt.depsTail.nextDep=t,Xt.depsTail=t,Xt.deps===t&&(Xt.deps=i)}return t}trigger(e){this.version++,jp++,this.notify(e)}notify(e){K_();try{for(let t=this.subs;t;t=t.prevSub)t.sub.notify()&&t.sub.dep.notify()}finally{Z_()}}};function Z3(e){if(e.dep.sc++,e.sub.flags&4){let t=e.dep.computed;if(t&&!e.dep.subs){t.flags|=20;for(let r=t.deps;r;r=r.nextDep)Z3(r)}let i=e.dep.subs;i!==e&&(e.prevSub=i,i&&(i.nextSub=e)),e.dep.subs=e}}var tT=new WeakMap,Hh=Symbol(""),iT=Symbol(""),$p=Symbol("");function Er(e,t,i){if(yn&&Xt){let r=tT.get(e);r||tT.set(e,r=new Map);let s=r.get(i);s||(r.set(i,s=new eT),s.map=r,s.key=i),s.track()}}function ho(e,t,i,r,s,n){let a=tT.get(e);if(!a){jp++;return}let o=l=>{l&&l.trigger()};if(K_(),t==="clear")a.forEach(o);else{let l=Ue(e),h=l&&$_(i);if(l&&i==="length"){let u=Number(r);a.forEach((d,c)=>{(c==="length"||c===$p||!ua(c)&&c>=u)&&o(d)})}else switch((i!==void 0||a.has(void 0))&&o(a.get(i)),h&&o(a.get($p)),t){case"add":l?h&&o(a.get("length")):(o(a.get(Hh)),Dd(e)&&o(a.get(iT)));break;case"delete":l||(o(a.get(Hh)),Dd(e)&&o(a.get(iT)));break;case"set":Dd(e)&&o(a.get(Hh));break}}Z_()}function Bd(e){let t=Et(e);return t===e?t:(Er(t,"iterate",$p),xn(e)?t:t.map(co))}function rT(e){return Er(e=Et(e),"iterate",$p),e}function ca(e,t){return _l(e)?K0(Ud(e)?co(t):t):co(t)}var hq={__proto__:null,[Symbol.iterator](){return sT(this,Symbol.iterator,e=>ca(this,e))},concat(...e){return Bd(this).concat(...e.map(t=>Ue(t)?Bd(t):t))},entries(){return sT(this,"entries",e=>(e[1]=ca(this,e[1]),e))},every(e,t){return uo(this,"every",e,t,void 0,arguments)},filter(e,t){return uo(this,"filter",e,t,i=>i.map(r=>ca(this,r)),arguments)},find(e,t){return uo(this,"find",e,t,i=>ca(this,i),arguments)},findIndex(e,t){return uo(this,"findIndex",e,t,void 0,arguments)},findLast(e,t){return uo(this,"findLast",e,t,i=>ca(this,i),arguments)},findLastIndex(e,t){return uo(this,"findLastIndex",e,t,void 0,arguments)},forEach(e,t){return uo(this,"forEach",e,t,void 0,arguments)},includes(...e){return nT(this,"includes",e)},indexOf(...e){return nT(this,"indexOf",e)},join(e){return Bd(this).join(e)},lastIndexOf(...e){return nT(this,"lastIndexOf",e)},map(e,t){return uo(this,"map",e,t,void 0,arguments)},pop(){return Wp(this,"pop")},push(...e){return Wp(this,"push",e)},reduce(e,...t){return J3(this,"reduce",e,t)},reduceRight(e,...t){return J3(this,"reduceRight",e,t)},shift(){return Wp(this,"shift")},some(e,t){return uo(this,"some",e,t,void 0,arguments)},splice(...e){return Wp(this,"splice",e)},toReversed(){return Bd(this).toReversed()},toSorted(e){return Bd(this).toSorted(e)},toSpliced(...e){return Bd(this).toSpliced(...e)},unshift(...e){return Wp(this,"unshift",e)},values(){return sT(this,"values",e=>ca(this,e))}};function sT(e,t,i){let r=rT(e),s=r[t]();return r!==e&&!xn(e)&&(s._next=s.next,s.next=()=>{let n=s._next();return n.done||(n.value=i(n.value)),n}),s}var uq=Array.prototype;function uo(e,t,i,r,s,n){let a=rT(e),o=a!==e&&!xn(e),l=a[t];if(l!==uq[t]){let d=l.apply(e,n);return o?co(d):d}let h=i;a!==e&&(o?h=function(d,c){return i.call(this,ca(e,d),c,e)}:i.length>2&&(h=function(d,c){return i.call(this,d,c,e)}));let u=l.call(a,h,r);return o&&s?s(u):u}function J3(e,t,i,r){let s=rT(e),n=s!==e&&!xn(e),a=i,o=!1;s!==e&&(n?(o=r.length===0,a=function(h,u,d){return o&&(o=!1,h=ca(e,h)),i.call(this,h,ca(e,u),d,e)}):i.length>3&&(a=function(h,u,d){return i.call(this,h,u,d,e)}));let l=s[t](a,...r);return o?ca(e,l):l}function nT(e,t,i){let r=Et(e);Er(r,"iterate",$p);let s=r[t](...i);return(s===-1||s===!1)&&dT(i[0])?(i[0]=Et(i[0]),r[t](...i)):s}function Wp(e,t,i=[]){oo(),K_();let r=Et(e)[t].apply(e,i);return Z_(),lo(),r}var dq=G_("__proto__,__v_isRef,__isVue"),Q3=new Set(Object.getOwnPropertyNames(Symbol).filter(e=>e!=="arguments"&&e!=="caller").map(e=>Symbol[e]).filter(ua));function cq(e){ua(e)||(e=String(e));let t=Et(this);return Er(t,"has",e),t.hasOwnProperty(e)}var eP=class{constructor(e=!1,t=!1){this._isReadonly=e,this._isShallow=t}get(e,t,i){if(t==="__v_skip")return e.__v_skip;let r=this._isReadonly,s=this._isShallow;if(t==="__v_isReactive")return!r;if(t==="__v_isReadonly")return r;if(t==="__v_isShallow")return s;if(t==="__v_raw")return i===(r?s?Tq:sP:s?rP:iP).get(e)||Object.getPrototypeOf(e)===Object.getPrototypeOf(i)?e:void 0;let n=Ue(e);if(!r){let o;if(n&&(o=hq[t]))return o;if(t==="hasOwnProperty")return cq}let a=Reflect.get(e,t,Ar(e)?e:i);if((ua(t)?Q3.has(t):dq(t))||(r||Er(e,"get",t),s))return a;if(Ar(a)){let o=n&&$_(t)?a:a.value;return r&&Gt(o)?hT(o):o}return Gt(a)?r?hT(a):lT(a):a}},tP=class extends eP{constructor(e=!1){super(!1,e)}set(e,t,i,r){let s=e[t],n=Ue(e)&&$_(t);if(!this._isShallow){let l=_l(s);if(!xn(i)&&!_l(i)&&(s=Et(s),i=Et(i)),!n&&Ar(s)&&!Ar(i))return l||(s.value=i),!0}let a=n?Number(t)<e.length:Rt(e,t),o=Reflect.set(e,t,i,Ar(e)?e:r);return e===Et(r)&&(a?da(i,s)&&ho(e,"set",t,i,s):ho(e,"add",t,i)),o}deleteProperty(e,t){let i=Rt(e,t),r=e[t],s=Reflect.deleteProperty(e,t);return s&&i&&ho(e,"delete",t,void 0,r),s}has(e,t){let i=Reflect.has(e,t);return(!ua(t)||!Q3.has(t))&&Er(e,"has",t),i}ownKeys(e){return Er(e,"iterate",Ue(e)?"length":Hh),Reflect.ownKeys(e)}},pq=class extends eP{constructor(e=!1){super(!0,e)}set(e,t){return!0}deleteProperty(e,t){return!0}},mq=new tP,gq=new pq,fq=new tP(!0),aT=e=>e,X0=e=>Reflect.getPrototypeOf(e);function yq(e,t,i){return function(...r){let s=this.__v_raw,n=Et(s),a=Dd(n),o=e==="entries"||e===Symbol.iterator&&a,l=e==="keys"&&a,h=s[e](...r),u=i?aT:t?K0:co;return!t&&Er(n,"iterate",l?iT:Hh),sr(Object.create(h),{next(){let{value:d,done:c}=h.next();return c?{value:d,done:c}:{value:o?[u(d[0]),u(d[1])]:u(d),done:c}}})}}function Y0(e){return function(...t){return e==="delete"?!1:e==="clear"?void 0:this}}function xq(e,t){let i={get(r){let s=this.__v_raw,n=Et(s),a=Et(r);e||(da(r,a)&&Er(n,"get",r),Er(n,"get",a));let{has:o}=X0(n),l=t?aT:e?K0:co;if(o.call(n,r))return l(s.get(r));if(o.call(n,a))return l(s.get(a));s!==n&&s.get(r)},get size(){let r=this.__v_raw;return!e&&Er(Et(r),"iterate",Hh),r.size},has(r){let s=this.__v_raw,n=Et(s),a=Et(r);return e||(da(r,a)&&Er(n,"has",r),Er(n,"has",a)),r===a?s.has(r):s.has(r)||s.has(a)}
vendor: 9,008 bytes, line 2095
2095,forEach(r,s){let n=this,a=n.__v_raw,o=Et(a),l=t?aT:e?K0:co;return!e&&Er(o,"iterate",Hh),a.forEach((h,u)=>r.call(s,l(h),l(u),n))}};return sr(i,e?{add:Y0("add"),set:Y0("set"),delete:Y0("delete"),clear:Y0("clear")}:{add(r){let s=Et(this),n=X0(s),a=Et(r),o=!t&&!xn(r)&&!_l(r)?a:r;return n.has.call(s,o)||da(r,o)&&n.has.call(s,r)||da(a,o)&&n.has.call(s,a)||(s.add(o),ho(s,"add",o,o)),this},set(r,s){!t&&!xn(s)&&!_l(s)&&(s=Et(s));let n=Et(this),{has:a,get:o}=X0(n),l=a.call(n,r);l||=(r=Et(r),a.call(n,r));let h=o.call(n,r);return n.set(r,s),l?da(s,h)&&ho(n,"set",r,s,h):ho(n,"add",r,s),this},delete(r){let s=Et(this),{has:n,get:a}=X0(s),o=n.call(s,r);o||=(r=Et(r),n.call(s,r));let l=a?a.call(s,r):void 0,h=s.delete(r);return o&&ho(s,"delete",r,void 0,l),h},clear(){let r=Et(this),s=r.size!==0,n=r.clear();return s&&ho(r,"clear",void 0,void 0,void 0),n}}),["keys","values","entries",Symbol.iterator].forEach(r=>{i[r]=yq(r,e,t)}),i}function oT(e,t){let i=xq(e,t);return(r,s,n)=>s==="__v_isReactive"?!e:s==="__v_isReadonly"?e:s==="__v_raw"?r:Reflect.get(Rt(i,s)&&s in r?i:r,s,n)}var vq={get:oT(!1,!1)},bq={get:oT(!1,!0)},_q={get:oT(!0,!1)},iP=new WeakMap,rP=new WeakMap,sP=new WeakMap,Tq=new WeakMap;function wq(e){switch(e){case"Object":case"Array":return 1;case"Map":case"Set":case"WeakMap":case"WeakSet":return 2;default:return 0}}function lT(e){return _l(e)?e:uT(e,!1,mq,vq,iP)}function Sq(e){return uT(e,!1,fq,bq,rP)}function hT(e){return uT(e,!0,gq,_q,sP)}function uT(e,t,i,r,s){if(!Gt(e)||e.__v_raw&&!(t&&e.__v_isReactive)||e.__v_skip||!Object.isExtensible(e))return e;let n=s.get(e);if(n)return n;let a=wq(XH(e));if(a===0)return e;let o=new Proxy(e,a===2?r:i);return s.set(e,o),o}function Ud(e){return _l(e)?Ud(e.__v_raw):!!(e&&e.__v_isReactive)}function _l(e){return!!(e&&e.__v_isReadonly)}function xn(e){return!!(e&&e.__v_isShallow)}function dT(e){return e?!!e.__v_raw:!1}function Et(e){let t=e&&e.__v_raw;return t?Et(t):e}function Mq(e){return!Rt(e,"__v_skip")&&Object.isExtensible(e)&&B3(e,"__v_skip",!0),e}var co=e=>Gt(e)?lT(e):e,K0=e=>Gt(e)?hT(e):e;function Ar(e){return e?e.__v_isRef===!0:!1}function Ae(e){return Cq(e,!1)}function Cq(e,t){return Ar(e)?e:new Rq(e,t)}var Rq=class{constructor(e,t){this.dep=new eT,this.__v_isRef=!0,this.__v_isShallow=!1,this._rawValue=t?e:Et(e),this._value=t?e:co(e),this.__v_isShallow=t}get value(){return this.dep.track(),this._value}set value(e){let t=this._rawValue,i=this.__v_isShallow||xn(e)||_l(e);e=i?e:Et(e),da(e,t)&&(this._rawValue=e,this._value=i?e:co(e),this.dep.trigger())}};function Eq(e){return Ar(e)?e.value:e}var Aq={get:(e,t,i)=>t==="__v_raw"?e:Eq(Reflect.get(e,t,i)),set:(e,t,i,r)=>{let s=e[t];return Ar(s)&&!Ar(i)?(s.value=i,!0):Reflect.set(e,t,i,r)}};function nP(e){return Ud(e)?e:new Proxy(e,Aq)}var Nq=class{constructor(e,t,i){this.fn=e,this.setter=t,this._value=void 0,this.dep=new eT(this),this.__v_isRef=!0,this.deps=void 0,this.depsTail=void 0,this.flags=16,this.globalVersion=jp-1,this.next=void 0,this.effect=this,this.__v_isReadonly=!t,this.isSSR=i}notify(){if(this.flags|=16,!(this.flags&8)&&Xt!==this)return W3(this,!0),!0}get value(){let e=this.dep.track();return X3(this),e&&(e.version=this.dep.version),this._value}set value(e){this.setter&&this.setter(e)}};function Lq(e,t,i=!1){let r,s;return ze(e)?r=e:(r=e.get,s=e.set),new Nq(r,s,i)}var Z0={},J0=new WeakMap,qh=void 0;function Pq(e,t=!1,i=qh){if(i){let r=J0.get(i);r||J0.set(i,r=[]),r.push(e)}}function kq(e,t,i=zt){let{immediate:r,deep:s,once:n,scheduler:a,augmentJob:o,call:l}=i,h=_=>s?_:xn(_)||s===!1||s===0?po(_,1):po(_),u,d,c,p,m=!1,g=!1;if(Ar(e)?(d=()=>e.value,m=xn(e)):Ud(e)?(d=()=>h(e),m=!0):Ue(e)?(g=!0,m=e.some(_=>Ud(_)||xn(_)),d=()=>e.map(_=>{if(Ar(_))return _.value;if(Ud(_))return h(_);if(ze(_))return l?l(_,2):_()})):d=ze(e)?t?l?()=>l(e,2):e:()=>{if(c){oo();try{c()}finally{lo()}}let _=qh;qh=u;try{return l?l(e,3,[p]):e(p)}finally{qh=_}}:ha,t&&s){let _=d,T=s===!0?1/0:s;d=()=>po(_(),T)}let f=aq(),y=()=>{u.stop(),f&&f.active&&j_(f.effects,u)};if(n&&t){let _=t;t=(...T)=>{_(...T),y()}}let x=g?Array(e.length).fill(Z0):Z0,b=_=>{if(!(!(u.flags&1)||!u.dirty&&!_))if(t){let T=u.run();if(s||m||(g?T.some((w,M)=>da(w,x[M])):da(T,x))){c&&c();let w=qh;qh=u;try{let M=[T,x===Z0?void 0:g&&x[0]===Z0?[]:x,p];x=T,l?l(t,3,M):t(...M)}finally{qh=w}}}else u.run()};return o&&o(b),u=new j3(d),u.scheduler=a?()=>a(b,!1):b,p=_=>Pq(_,!1,u),c=u.onStop=()=>{let _=J0.get(u);if(_){if(l)l(_,4);else for(let T of _)T();J0.delete(u)}},t?r?b(!0):x=u.run():a?a(b.bind(null,!0),!0):u.run(),y.pause=u.pause.bind(u),y.resume=u.resume.bind(u),y.stop=y,y}function po(e,t=1/0,i){if(t<=0||!Gt(e)||e.__v_skip||(i||=new Map,(i.get(e)||0)>=t))return e;if(i.set(e,t),t--,Ar(e))po(e.value,t,i);else if(Ue(e))for(let r=0;r<e.length;r++)po(e[r],t,i);else if(k3(e)||Dd(e))e.forEach(r=>{po(r,t,i)});else if(O3(e)){for(let r in e)po(e[r],t,i);for(let r of Object.getOwnPropertySymbols(e))Object.prototype.propertyIsEnumerable.call(e,r)&&po(e[r],t,i)}return e}function Hp(e,t,i,r){try{return r?e(...r):e()}catch(s){Q0(s,t,i)}}function vn(e,t,i,r){if(ze(e)){let s=Hp(e,t,i,r);return s&&F3(s)&&s.catch(n=>{Q0(n,t,i)}),s}if(Ue(e)){let s=[];for(let n=0;n<e.length;n++)s.push(vn(e[n],t,i,r));return s}}function Q0(e,t,i,r=!0){let s=t?t.vnode:null,{errorHandler:n,throwUnhandledErrorInProduction:a}=t&&t.appContext.config||zt;if(t){let o=t.parent,l=t.proxy,h=`https://vuejs.org/error-reference/#runtime-${i}`;for(;o;){let u=o.ec;if(u){for(let d=0;d<u.length;d++)if(u[d](e,l,h)===!1)return}o=o.parent}if(n){oo(),Hp(n,null,10,[e,l,h]),lo();return}}Iq(e,i,s,r,a)}function Iq(e,t,i,r=!0,s=!1){if(s)throw e;console.error(e)}var Jr=[],pa=-1,Vd=[],Tl=null,zd=0,aP=Promise.resolve(),cT=null;function Fq(e){let t=cT||aP;return e?t.then(this?e.bind(this):e):t}function Dq(e){let t=pa+1,i=Jr.length;for(;t<i;){let r=t+i>>>1,s=Jr[r],n=qp(s);n<e||n===e&&s.flags&2?t=r+1:i=r}return t}function pT(e){if(!(e.flags&1)){let t=qp(e),i=Jr[Jr.length-1];!i||!(e.flags&2)&&t>=qp(i)?Jr.push(e):Jr.splice(Dq(t),0,e),e.flags|=1,oP()}}function oP(){cT||=aP.then(uP)}function Oq(e){Ue(e)?Vd.push(...e):Tl&&e.id===-1?Tl.splice(zd+1,0,e):e.flags&1||(Vd.push(e),e.flags|=1),oP()}function lP(e,t,i=pa+1){for(;i<Jr.length;i++){let r=Jr[i];if(r&&r.flags&2){if(e&&r.id!==e.uid)continue;Jr.splice(i,1),i--,r.flags&4&&(r.flags&=-2),r(),r.flags&4||(r.flags&=-2)}}}function hP(e){if(Vd.length){let t=[...new Set(Vd)].sort((i,r)=>qp(i)-qp(r));if(Vd.length=0,Tl){Tl.push(...t);return}for(Tl=t,zd=0;zd<Tl.length;zd++){let i=Tl[zd];i.flags&4&&(i.flags&=-2),i.flags&8||i(),i.flags&=-2}Tl=null,zd=0}}var qp=e=>e.id==null?e.flags&2?-1:1/0:e.id;function uP(e){try{for(pa=0;pa<Jr.length;pa++){let t=Jr[pa];t&&!(t.flags&8)&&(t.flags&4&&(t.flags&=-2),Hp(t,t.i,t.i?15:14),t.flags&4||(t.flags&=-2))}}finally{for(;pa<Jr.length;pa++){let t=Jr[pa];t&&(t.flags&=-2)}pa=-1,Jr.length=0,hP(e),cT=null,(Jr.length||Vd.length)&&uP(e)}}var Cs=null,dP=null;function ey(e){let t=Cs;return Cs=e,dP=e&&e.type.__scopeId||null,t}function Bq(e,t=Cs,i){if(!t||e._n)return e;let r=(...s)=>{r._d&&XP(-1);let n=ey(t),a;try{a=e(...s)}finally{ey(n),r._d&&XP(1)}return a};return r._n=!0,r._c=!0,r._d=!0,r}function mT(e,t){if(Cs===null)return e;let i=dy(Cs),r=e.dirs||=[];for(let s=0;s<t.length;s++){let[n,a,o,l=zt]=t[s];n&&(ze(n)&&(n={mounted:n,updated:n}),n.deep&&po(a),r.push({dir:n,instance:i,value:a,oldValue:void 0,arg:o,modifiers:l}))}return e}function Xh(e,t,i,r){let s=e.dirs,n=t&&t.dirs;for(let a=0;a<s.length;a++){let o=s[a];n&&(o.oldValue=n[a].value);let l=o.dir[r];l&&(oo(),vn(l,i,8,[e.el,o,e,t]),lo())}}function Uq(e,t){if(Nr){let i=Nr.provides,r=Nr.parent&&Nr.parent.provides;r===i&&(i=Nr.provides=Object.create(r)),i[e]=t}}function ty(e,t,i=!1){let r=GX();if(r||Gd){let s=Gd?Gd._context.provides:r?r.parent==null||r.ce?r.vnode.appContext&&r.vnode.appContext.provides:r.parent.provides:void 0;if(s&&e in s)return s[e];if(arguments.length>1)return i&&ze(t)?t.call(r&&r.proxy):t}}var Vq=Symbol.for("v-scx"),zq=()=>ty(Vq);function mo(e,t,i){return cP(e,t,i)}function cP(e,t,i=zt){let{immediate:r,deep:s,flush:n,once:a}=i,o=sr({},i),l=t&&r||!t&&n!=="post",h;if(sm){if(n==="sync"){let p=zq();h=p.__watcherHandles||=[]}else if(!l){let p=()=>{};return p.stop=ha,p.resume=ha,p.pause=ha,p}}let u=Nr;o.call=(p,m,g)=>vn(p,u,m,g);let d=!1;n==="post"?o.scheduler=p=>{es(p,u&&u.suspense)}:n!=="sync"&&(d=!0,o.scheduler=(p,m)=>{m?p():pT(p)}),o.augmentJob=p=>{t&&(p.flags|=4),d&&(p.flags|=2,u&&(p.id=u.uid,p.i=u))};let c=kq(e,t,o);return sm&&(h?h.push(c):l&&c()),c}function Gq(e,t,i){let r=this.proxy,s=xi(e)?e.includes(".")?pP(r,e):()=>r[e]:e.bind(r,r),n;ze(t)?n=t:(n=t.handler,i=t);let a=rm(this),o=cP(s,n.bind(r),i);return a(),o}function pP(e,t){let i=t.split(".");return()=>{let r=e;for(let s=0;s<i.length&&r;s++)r=r[i[s]];return r}}var wl=new WeakMap,mP=Symbol("_vte"),jq=e=>e.__isTeleport,Yh=e=>e&&(e.disabled||e.disabled===""),$q=e=>e&&(e.defer||e.defer===""),gP=e=>typeof SVGElement<"u"&&e instanceof SVGElement,fP=e=>typeof MathMLElement=="function"&&e instanceof MathMLElement,gT=(e,t)=>
vendor: 3,899 bytes, line 2095
2095{let i=e&&e.to;return xi(i)?t?t(i):null:i},Wq={name:"Teleport",__isTeleport:!0,process(e,t,i,r,s,n,a,o,l,h){let{mc:u,pc:d,pbc:c,o:{insert:p,querySelector:m,createText:g,createComment:f,parentNode:y}}=h,x=Yh(t.props),{dynamicChildren:b}=t,_=(M,S,R)=>{M.shapeFlag&16&&u(M.children,S,R,s,n,a,o,l)},T=(M=t)=>{let S=Yh(M.props),R=M.target=gT(M.props,m),I=fT(R,M,g,p);R&&(a!=="svg"&&gP(R)?a="svg":a!=="mathml"&&fP(R)&&(a="mathml"),s&&s.isCE&&(s.ce._teleportTargets||(s.ce._teleportTargets=new Set)).add(R),S||(_(M,R,I),Xp(M,!1)))},w=M=>{let S=()=>{wl.get(M)===S&&(wl.delete(M),Yh(M.props)&&(_(M,y(M.el)||i,M.anchor),Xp(M,!0)),T(M))};wl.set(M,S),es(S,n)};if(e==null){let M=t.el=g(""),S=t.anchor=g("");if(p(M,i,r),p(S,i,r),$q(t.props)||n&&n.pendingBranch){w(t);return}x&&(_(t,i,S),Xp(t,!0)),T()}else{t.el=e.el;let M=t.anchor=e.anchor,S=wl.get(e);if(S){S.flags|=8,wl.delete(e),w(t);return}t.targetStart=e.targetStart;let R=t.target=e.target,I=t.targetAnchor=e.targetAnchor,B=Yh(e.props),O=B?i:R,U=B?M:I;if(a==="svg"||gP(R)?a="svg":(a==="mathml"||fP(R))&&(a="mathml"),b?(c(e.dynamicChildren,b,O,s,n,a,o),NT(e,t,!0)):l||d(e,t,O,U,s,n,a,o,!1),x)B?t.props&&e.props&&t.props.to!==e.props.to&&(t.props.to=e.props.to):iy(t,i,M,h,1);else if((t.props&&t.props.to)!==(e.props&&e.props.to)){let V=t.target=gT(t.props,m);V&&iy(t,V,null,h,0)}else B&&iy(t,R,I,h,1);Xp(t,x)}},remove(e,t,i,{um:r,o:{remove:s}},n){let{shapeFlag:a,children:o,anchor:l,targetStart:h,targetAnchor:u,target:d,props:c}=e,p=n||!Yh(c),m=wl.get(e);if(m&&(m.flags|=8,wl.delete(e)),d&&(s(h),s(u)),n&&s(l),!m&&a&16)for(let g=0;g<o.length;g++){let f=o[g];r(f,t,i,p,!!f.dynamicChildren)}},move:iy,hydrate:Hq};function iy(e,t,i,{o:{insert:r},m:s},n=2){n===0&&r(e.targetAnchor,t,i);let{el:a,anchor:o,shapeFlag:l,children:h,props:u}=e,d=n===2;if(d&&r(a,t,i),!wl.has(e)&&(!d||Yh(u))&&l&16)for(let c=0;c<h.length;c++)s(h[c],t,i,2);d&&r(o,t,i)}function Hq(e,t,i,r,s,n,{o:{nextSibling:a,parentNode:o,querySelector:l,insert:h,createText:u}},d){function c(f,y){let x=y;for(;x;){if(x&&x.nodeType===8){if(x.data==="teleport start anchor")t.targetStart=x;else if(x.data==="teleport anchor"){t.targetAnchor=x,f._lpa=t.targetAnchor&&a(t.targetAnchor);break}}x=a(x)}}function p(f,y){y.anchor=d(a(f),y,o(f),i,r,s,n)}let m=t.target=gT(t.props,l),g=Yh(t.props);if(m){let f=m._lpa||m.firstChild;t.shapeFlag&16&&(g?(p(e,t),c(m,f),t.targetAnchor||fT(m,t,u,h,o(e)===m?e:null)):(t.anchor=a(e),c(m,f),t.targetAnchor||fT(m,t,u,h),d(f&&a(f),t,m,i,r,s,n))),Xp(t,g)}else g&&t.shapeFlag&16&&(p(e,t),t.targetStart=e,t.targetAnchor=a(e));return t.anchor&&a(t.anchor)}var yP=Wq;function Xp(e,t){let i=e.ctx;if(i&&i.ut){let r,s;for(t?(r=e.el,s=e.anchor):(r=e.targetStart,s=e.targetAnchor);r&&r!==s;)r.nodeType===1&&r.setAttribute("data-v-owner",i.uid),r=r.nextSibling;i.ut()}}function fT(e,t,i,r,s=null){let n=t.targetStart=i(""),a=t.targetAnchor=i("");return n[mP]=a,e&&(r(n,e,s),r(a,e,s)),a}var yT=Symbol("_leaveCb");function xT(e,t){e.shapeFlag&6&&e.component?(e.transition=t,xT(e.component.subTree,t)):e.shapeFlag&128?(e.ssContent.transition=t.clone(e.ssContent),e.ssFallback.transition=t.clone(e.ssFallback)):e.transition=t}function xP(e){e.ids=[e.ids[0]+e.ids[2]+++"-",0,0]}function vP(e,t){let i;return!!((i=Object.getOwnPropertyDescriptor(e,t))&&!i.configurable)}var ry=new WeakMap;function Yp(e,t,i,r,s=!1){if(Ue(e)){e.forEach((g,f)=>Yp(g,t&&(Ue(t)?t[f]:t),i,r,s));return}if(Kp(r)&&!s){r.shapeFlag&512&&r.type.__asyncResolved&&r.component.subTree.component&&Yp(e,t,i,r.component.subTree);return}let n=r.shapeFlag&4?dy(r.component):r.el,a=s?null:n,{i:o,r:l}=e,h=t&&t.r,u=o.refs===zt?o.refs={}:o.refs,d=o.setupState,c=Et(d),p=d===zt?P3:g=>vP(u,g)?!1:Rt(c,g),m=(g,f)=>!(f&&vP(u,f));if(h!=null&&h!==l){if(bP(t),xi(h))u[h]=null,p(h)&&(d[h]=null);else if(Ar(h)){let g=t;m(h,g.k)&&(h.value=null),g.k&&(u[g.k]=null)}}if(ze(l))Hp(l,o,12,[a,u]);else{let g=xi(l),f=Ar(l);if(g||f){let y=()=>
vendor: 4,086 bytes, line 2095
2095{if(e.f){let x=g?p(l)?d[l]:u[l]:m(l)||!e.k?l.value:u[e.k];if(s)Ue(x)&&j_(x,n);else if(Ue(x))x.includes(n)||x.push(n);else if(g)u[l]=[n],p(l)&&(d[l]=u[l]);else{let b=[n];m(l,e.k)&&(l.value=b),e.k&&(u[e.k]=b)}}else g?(u[l]=a,p(l)&&(d[l]=a)):f&&(m(l,e.k)&&(l.value=a),e.k&&(u[e.k]=a))};if(a){let x=()=>{y(),ry.delete(e)};x.id=-1,ry.set(e,x),es(x,i)}else bP(e),y()}}}function bP(e){let t=ry.get(e);t&&(t.flags|=8,ry.delete(e))}q0().requestIdleCallback,q0().cancelIdleCallback;var Kp=e=>!!e.type.__asyncLoader,_P=e=>e.type.__isKeepAlive;function qq(e,t){TP(e,"a",t)}function Xq(e,t){TP(e,"da",t)}function TP(e,t,i=Nr){let r=e.__wdc||=()=>{let s=i;for(;s;){if(s.isDeactivated)return;s=s.parent}return e()};if(sy(t,r,i),i){let s=i.parent;for(;s&&s.parent;)_P(s.parent.vnode)&&Yq(r,t,i,s),s=s.parent}}function Yq(e,t,i,r){let s=sy(t,e,r,!0);wP(()=>{j_(r[t],s)},i)}function sy(e,t,i=Nr,r=!1){if(i){let s=i[e]||(i[e]=[]),n=t.__weh||=(...a)=>{oo();let o=rm(i),l=vn(t,i,e,a);return o(),lo(),l};return r?s.unshift(n):s.push(n),n}}var go=e=>(t,i=Nr)=>{(!sm||e==="sp")&&sy(e,(...r)=>t(...r),i)},Kq=go("bm"),Zq=go("m"),Jq=go("bu"),Qq=go("u"),eX=go("bum"),wP=go("um"),tX=go("sp"),iX=go("rtg"),rX=go("rtc");function sX(e,t=Nr){sy("ec",e,t)}var SP="components";function vT(e,t){return aX(SP,e,!0,t)||e}var nX=Symbol.for("v-ndc");function aX(e,t,i=!0,r=!1){let s=Cs||Nr;if(s){let n=s.type;if(e===SP){let o=qX(n,!1);if(o&&(o===t||o===Zr(t)||o===H0(Zr(t))))return n}let a=MP(s[e]||n[e],t)||MP(s.appContext[e],t);return!a&&r?n:a}}function MP(e,t){return e&&(e[t]||e[Zr(t)]||e[H0(Zr(t))])}var bT=e=>e?QP(e)?dy(e):bT(e.parent):null,Zp=sr(Object.create(null),{$:e=>e,$el:e=>e.vnode.el,$data:e=>e.data,$props:e=>e.props,$attrs:e=>e.attrs,$slots:e=>e.slots,$refs:e=>e.refs,$parent:e=>bT(e.parent),$root:e=>bT(e.root),$host:e=>e.ce,$emit:e=>e.emit,$options:e=>wT(e),$forceUpdate:e=>e.f||=()=>{pT(e.update)},$nextTick:e=>e.n||=Fq.bind(e.proxy),$watch:e=>Gq.bind(e)}),_T=(e,t)=>e!==zt&&!e.__isScriptSetup&&Rt(e,t),oX={get({_:e},t){if(t==="__v_skip")return!0;let{ctx:i,setupState:r,data:s,props:n,accessCache:a,type:o,appContext:l}=e;if(t[0]!=="$"){let c=a[t];if(c!==void 0)switch(c){case 1:return r[t];case 2:return s[t];case 4:return i[t];case 3:return n[t]}else{if(_T(r,t))return a[t]=1,r[t];if(s!==zt&&Rt(s,t))return a[t]=2,s[t];if(Rt(n,t))return a[t]=3,n[t];if(i!==zt&&Rt(i,t))return a[t]=4,i[t];TT&&(a[t]=0)}}let h=Zp[t],u,d;if(h)return t==="$attrs"&&Er(e.attrs,"get",""),h(e);if((u=o.__cssModules)&&(u=u[t]))return u;if(i!==zt&&Rt(i,t))return a[t]=4,i[t];if(d=l.config.globalProperties,Rt(d,t))return d[t]},set({_:e},t,i){let{data:r,setupState:s,ctx:n}=e;return _T(s,t)?(s[t]=i,!0):r!==zt&&Rt(r,t)?(r[t]=i,!0):Rt(e.props,t)||t[0]==="$"&&t.slice(1)in e?!1:(n[t]=i,!0)},has({_:{data:e,setupState:t,accessCache:i,ctx:r,appContext:s,props:n,type:a}},o){let l;return!!(i[o]||e!==zt&&o[0]!=="$"&&Rt(e,o)||_T(t,o)||Rt(n,o)||Rt(r,o)||Rt(Zp,o)||Rt(s.config.globalProperties,o)||(l=a.__cssModules)&&l[o])},defineProperty(e,t,i){return i.get==null?Rt(i,"value")&&this.set(e,t,i.value,null):e._.accessCache[t]=0,Reflect.defineProperty(e,t,i)}};function CP(e){return Ue(e)?e.reduce((t,i)=>(t[i]=null,t),{}):e}var TT=!0;function lX(e){let t=wT(e),i=e.proxy,r=e.ctx;TT=!1,t.beforeCreate&&RP(t.beforeCreate,e,"bc");let{data:s,computed:n,methods:a,watch:o,provide:l,inject:h,created:u,beforeMount:d,mounted:c,beforeUpdate:p,updated:m,activated:g,deactivated:f,beforeDestroy:y,beforeUnmount:x,destroyed:b,unmounted:_,render:T,renderTracked:w,renderTriggered:M,errorCaptured:S,serverPrefetch:R,expose:I,inheritAttrs:B,components:O,directives:U,filters:V}=t;if(h&&hX(h,r,null),a)for(let Z in a){let j=a[Z];ze(j)&&(r[Z]=j.bind(i))}if(s){let Z=s.call(i,i);Gt(Z)&&(e.data=lT(Z))}if(TT=!0,n)for(let Z in n){let j=n[Z],ae=sk({get:ze(j)?j.bind(i,i):ze(j.get)?j.get.bind(i,i):ha,set:!ze(j)&&ze(j.set)?j.set.bind(i):ha});Object.defineProperty(r,Z,{enumerable:!0,configurable:!0,get:()=>ae.value,set:W=>ae.value=W})}if(o)for(let Z in o)EP(o[Z],r,i,Z);if(l){let Z=ze(l)?l.call(i):l;Reflect.ownKeys(Z).forEach(j=>{Uq(j,Z[j])})}u&&RP(u,e,"c");
vendor: 13,198 bytes, line 2095
2095function z(Z,j){Ue(j)?j.forEach(ae=>Z(ae.bind(i))):j&&Z(j.bind(i))}if(z(Kq,d),z(Zq,c),z(Jq,p),z(Qq,m),z(qq,g),z(Xq,f),z(sX,S),z(rX,w),z(iX,M),z(eX,x),z(wP,_),z(tX,R),Ue(I))if(I.length){let Z=e.exposed||={};I.forEach(j=>{Object.defineProperty(Z,j,{get:()=>i[j],set:ae=>i[j]=ae,enumerable:!0})})}else e.exposed||={};T&&e.render===ha&&(e.render=T),B!=null&&(e.inheritAttrs=B),O&&(e.components=O),U&&(e.directives=U),R&&xP(e)}function hX(e,t,i=ha){Ue(e)&&(e=ST(e));for(let r in e){let s=e[r],n;n=Gt(s)?"default"in s?ty(s.from||r,s.default,!0):ty(s.from||r):ty(s),Ar(n)?Object.defineProperty(t,r,{enumerable:!0,configurable:!0,get:()=>n.value,set:a=>n.value=a}):t[r]=n}}function RP(e,t,i){vn(Ue(e)?e.map(r=>r.bind(t.proxy)):e.bind(t.proxy),t,i)}function EP(e,t,i,r){let s=r.includes(".")?pP(i,r):()=>i[r];if(xi(e)){let n=t[e];ze(n)&&mo(s,n)}else if(ze(e))mo(s,e.bind(i));else if(Gt(e))if(Ue(e))e.forEach(n=>EP(n,t,i,r));else{let n=ze(e.handler)?e.handler.bind(i):t[e.handler];ze(n)&&mo(s,n,e)}}function wT(e){let t=e.type,{mixins:i,extends:r}=t,{mixins:s,optionsCache:n,config:{optionMergeStrategies:a}}=e.appContext,o=n.get(t),l;return o?l=o:!s.length&&!i&&!r?l=t:(l={},s.length&&s.forEach(h=>ny(l,h,a,!0)),ny(l,t,a)),Gt(t)&&n.set(t,l),l}function ny(e,t,i,r=!1){let{mixins:s,extends:n}=t;n&&ny(e,n,i,!0),s&&s.forEach(a=>ny(e,a,i,!0));for(let a in t)if(!(r&&a==="expose")){let o=uX[a]||i&&i[a];e[a]=o?o(e[a],t[a]):t[a]}return e}var uX={data:AP,props:NP,emits:NP,methods:Jp,computed:Jp,beforeCreate:Qr,created:Qr,beforeMount:Qr,mounted:Qr,beforeUpdate:Qr,updated:Qr,beforeDestroy:Qr,beforeUnmount:Qr,destroyed:Qr,unmounted:Qr,activated:Qr,deactivated:Qr,errorCaptured:Qr,serverPrefetch:Qr,components:Jp,directives:Jp,watch:cX,provide:AP,inject:dX};function AP(e,t){return t?e?function(){return sr(ze(e)?e.call(this,this):e,ze(t)?t.call(this,this):t)}:t:e}function dX(e,t){return Jp(ST(e),ST(t))}function ST(e){if(Ue(e)){let t={};for(let i=0;i<e.length;i++)t[e[i]]=e[i];return t}return e}function Qr(e,t){return e?[...new Set([].concat(e,t))]:t}function Jp(e,t){return e?sr(Object.create(null),e,t):t}function NP(e,t){return e?Ue(e)&&Ue(t)?[...new Set([...e,...t])]:sr(Object.create(null),CP(e),CP(t??{})):t}function cX(e,t){if(!e)return t;if(!t)return e;let i=sr(Object.create(null),e);for(let r in t)i[r]=Qr(e[r],t[r]);return i}function LP(){return{app:null,config:{isNativeTag:P3,performance:!1,globalProperties:{},optionMergeStrategies:{},errorHandler:void 0,warnHandler:void 0,compilerOptions:{}},mixins:[],components:{},directives:{},provides:Object.create(null),optionsCache:new WeakMap,propsCache:new WeakMap,emitsCache:new WeakMap}}var pX=0;function mX(e,t){return function(i,r=null){ze(i)||(i=sr({},i)),r!=null&&!Gt(r)&&(r=null);let s=LP(),n=new WeakSet,a=[],o=!1,l=s.app={_uid:pX++,_component:i,_props:r,_container:null,_context:s,_instance:null,version:YX,get config(){return s.config},set config(h){},use(h,...u){return n.has(h)||(h&&ze(h.install)?(n.add(h),h.install(l,...u)):ze(h)&&(n.add(h),h(l,...u))),l},mixin(h){return s.mixins.includes(h)||s.mixins.push(h),l},component(h,u){return u?(s.components[h]=u,l):s.components[h]},directive(h,u){return u?(s.directives[h]=u,l):s.directives[h]},mount(h,u,d){if(!o){let c=l._ceVNode||bn(i,r);return c.appContext=s,d===!0?d="svg":d===!1&&(d=void 0),u&&t?t(c,h):e(c,h,d),o=!0,l._container=h,h.__vue_app__=l,dy(c.component)}},onUnmount(h){a.push(h)},unmount(){o&&(vn(a,l._instance,16),e(null,l._container),delete l._container.__vue_app__)},provide(h,u){return s.provides[h]=u,l},runWithContext(h){let u=Gd;Gd=l;try{return h()}finally{Gd=u}}};return l}}var Gd=null,gX=(e,t)=>t==="modelValue"||t==="model-value"?e.modelModifiers:e[`${t}Modifiers`]||e[`${Zr(t)}Modifiers`]||e[`${Wh(t)}Modifiers`];function fX(e,t,...i){if(e.isUnmounted)return;let r=e.vnode.props||zt,s=i,n=t.startsWith("update:"),a=n&&gX(r,t.slice(7));a&&(a.trim&&(s=i.map(u=>xi(u)?u.trim():u)),a.number&&(s=i.map(ZH)));let o,l=r[o=W_(t)]||r[o=W_(Zr(t))];!l&&n&&(l=r[o=W_(Wh(t))]),l&&vn(l,e,6,s);let h=r[o+"Once"];if(h){if(!e.emitted)e.emitted={};else if(e.emitted[o])return;e.emitted[o]=!0,vn(h,e,6,s)}}var yX=new WeakMap;function PP(e,t,i=!1){let r=i?yX:t.emitsCache,s=r.get(e);if(s!==void 0)return s;let n=e.emits,a={},o=!1;if(!ze(e)){let l=h=>{let u=PP(h,t,!0);u&&(o=!0,sr(a,u))};!i&&t.mixins.length&&t.mixins.forEach(l),e.extends&&l(e.extends),e.mixins&&e.mixins.forEach(l)}return!n&&!o?(Gt(e)&&r.set(e,null),null):(Ue(n)?n.forEach(l=>a[l]=null):sr(a,n),Gt(e)&&r.set(e,a),a)}function ay(e,t){return!e||!j0(t)?!1:(t=t.slice(2).replace(/Once$/,""),Rt(e,t[0].toLowerCase()+t.slice(1))||Rt(e,Wh(t))||Rt(e,t))}function MT(e){let{type:t,vnode:i,proxy:r,withProxy:s,propsOptions:[n],slots:a,attrs:o,emit:l,render:h,renderCache:u,props:d,data:c,setupState:p,ctx:m,inheritAttrs:g}=e,f=ey(e),y,x;try{if(i.shapeFlag&4){let _=s||r,T=_;y=ma(h.call(T,_,u,d,p,c,m)),x=o}else{let _=t;y=ma(_.length>1?_(d,{attrs:o,slots:a,emit:l}):_(d,null)),x=t.props?o:xX(o)}}catch(_){Qp.length=0,Q0(_,e,1),y=bn(Sl)}let b=y;if(x&&g!==!1){let _=Object.keys(x),{shapeFlag:T}=b;_.length&&T&7&&(n&&_.some($0)&&(x=vX(x,n)),b=jd(b,x,!1,!0))}return i.dirs&&(b=jd(b,null,!1,!0),b.dirs=b.dirs?b.dirs.concat(i.dirs):i.dirs),i.transition&&xT(b,i.transition),y=b,ey(f),y}var xX=e=>{let t;for(let i in e)(i==="class"||i==="style"||j0(i))&&((t||={})[i]=e[i]);return t},vX=(e,t)=>{let i={};for(let r in e)(!$0(r)||!(r.slice(9)in t))&&(i[r]=e[r]);return i};function bX(e,t,i){let{props:r,children:s,component:n}=e,{props:a,children:o,patchFlag:l}=t,h=n.emitsOptions;if(t.dirs||t.transition)return!0;if(i&&l>=0){if(l&1024)return!0;if(l&16)return r?kP(r,a,h):!!a;if(l&8){let u=t.dynamicProps;for(let d=0;d<u.length;d++){let c=u[d];if(IP(a,r,c)&&!ay(h,c))return!0}}}else return(s||o)&&(!o||!o.$stable)?!0:r===a?!1:r?a?kP(r,a,h):!0:!!a;return!1}function kP(e,t,i){let r=Object.keys(t);if(r.length!==Object.keys(e).length)return!0;for(let s=0;s<r.length;s++){let n=r[s];if(IP(t,e,n)&&!ay(i,n))return!0}return!1}function IP(e,t,i){let r=e[i],s=t[i];return i==="style"&&Gt(r)&&Gt(s)?!q_(r,s):r!==s}function _X({vnode:e,parent:t,suspense:i},r){for(;t;){let s=t.subTree;if(s.suspense&&s.suspense.activeBranch===e&&(s.suspense.vnode.el=s.el=r,e=s),s===e)(e=t.vnode).el=r,t=t.parent;else break}i&&i.activeBranch===e&&(i.vnode.el=r)}var FP={},DP=()=>Object.create(FP),OP=e=>Object.getPrototypeOf(e)===FP;function TX(e,t,i,r=!1){let s={},n=DP();e.propsDefaults=Object.create(null),BP(e,t,s,n);for(let a in e.propsOptions[0])a in s||(s[a]=void 0);i?e.props=r?s:Sq(s):e.type.props?e.props=s:e.props=n,e.attrs=n}function wX(e,t,i,r){let{props:s,attrs:n,vnode:{patchFlag:a}}=e,o=Et(s),[l]=e.propsOptions,h=!1;if((r||a>0)&&!(a&16)){if(a&8){let u=e.vnode.dynamicProps;for(let d=0;d<u.length;d++){let c=u[d];if(ay(e.emitsOptions,c))continue;let p=t[c];if(l)if(Rt(n,c))p!==n[c]&&(n[c]=p,h=!0);else{let m=Zr(c);s[m]=CT(l,o,m,p,e,!1)}else p!==n[c]&&(n[c]=p,h=!0)}}}else{BP(e,t,s,n)&&(h=!0);let u;for(let d in o)(!t||!Rt(t,d)&&((u=Wh(d))===d||!Rt(t,u)))&&(l?i&&(i[d]!==void 0||i[u]!==void 0)&&(s[d]=CT(l,o,d,void 0,e,!0)):delete s[d]);if(n!==o)for(let d in n)(!t||!Rt(t,d))&&(delete n[d],h=!0)}h&&ho(e.attrs,"set","")}function BP(e,t,i,r){let[s,n]=e.propsOptions,a=!1,o;if(t)for(let l in t){if(Up(l))continue;let h=t[l],u;s&&Rt(s,u=Zr(l))?!n||!n.includes(u)?i[u]=h:(o||={})[u]=h:ay(e.emitsOptions,l)||(!(l in r)||h!==r[l])&&(r[l]=h,a=!0)}if(n){let l=Et(i),h=o||zt;for(let u=0;u<n.length;u++){let d=n[u];i[d]=CT(s,l,d,h[d],e,!Rt(h,d))}}return a}function CT(e,t,i,r,s,n){let a=e[i];if(a!=null){let o=Rt(a,"default");if(o&&r===void 0){let l=a.default;if(a.type!==Function&&!a.skipFactory&&ze(l)){let{propsDefaults:h}=s;if(i in h)r=h[i];else{let u=rm(s);r=h[i]=l.call(null,t),u()}}else r=l;s.ce&&s.ce._setProp(i,r)}a[0]&&(n&&!o?r=!1:a[1]&&(r===""||r===Wh(i))&&(r=!0))}return r}var SX=new WeakMap;function UP(e,t,i=!1){let r=i?SX:t.propsCache,s=r.get(e);if(s)return s;let n=e.props,a={},o=[],l=!1;if(!ze(e)){let u=d=>{l=!0;let[c,p]=UP(d,t,!0);sr(a,c),p&&o.push(...p)};!i&&t.mixins.length&&t.mixins.forEach(u),e.extends&&u(e.extends),e.mixins&&e.mixins.forEach(u)}if(!n&&!l)return Gt(e)&&r.set(e,Fd),Fd;if(Ue(n))for(let u=0;u<n.length;u++){let d=Zr(n[u]);VP(d)&&(a[d]=zt)}else if(n)for(let u in n){let d=Zr(u);if(VP(d)){let c=n[u],p=a[d]=Ue(c)||ze(c)?{type:c}:sr({},c),m=p.type,g=!1,f=!0;if(Ue(m))for(let y=0;y<m.length;++y){let x=m[y],b=ze(x)&&x.name;if(b==="Boolean"){g=!0;break}else b==="String"&&(f=!1)}else g=ze(m)&&m.name==="Boolean";p[0]=g,p[1]=f,(g||Rt(p,"default"))&&o.push(d)}}let h=[a,o];return Gt(e)&&r.set(e,h),h}function VP(e){return e[0]!=="$"&&!Up(e)}var RT=e=>e==="_"||e==="_ctx"||e==="$stable",ET=e=>Ue(e)?e.map(ma):[ma(e)],MX=(e,t,i)=>{if(t._n)return t;let r=Bq((...s)=>ET(t(...s)),i);return r._c=!1,r},zP=(e,t,i)=>{let r=e._ctx;for(let s in e){if(RT(s))continue;let n=e[s];if(ze(n))t[s]=MX(s,n,r);else if(n!=null){let a=ET(n);t[s]=()=>a}}},GP=(e,t)=>{let i=ET(t);e.slots.default=()=>i},jP=(e,t,i)=>{for(let r in t)(i||!RT(r))&&(e[r]=t[r])},CX=(e,t,i)=>{let r=e.slots=DP();if(e.vnode.shapeFlag&32){let s=t._;s?(jP(r,t,i),i&&B3(r,"_",s,!0)):zP(t,r)}else t&&GP(e,t)},RX=(e,t,i)=>{let{vnode:r,slots:s}=e,n=!0,a=zt;if(r.shapeFlag&32){let o=t._;o?i&&o===1?n=!1:jP(s,t,i):(n=!t.$stable,zP(t,s)),a=t}else t&&(GP(e,t),a={default:1});if(n)for(let o in s)!RT(o)&&a[o]==null&&delete s[o]},es=PX;function EX(e){return AX(e)}function AX(e,t){let i=q0();i.__VUE__=!0;let{insert:r,remove:s,patchProp:n,createElement:a,createText:o,createComment:l,setText:h,setElementText:u,parentNode:d,nextSibling:c,setScopeId:p=ha,insertStaticContent:m}=e,g=(E,D,$,Q=null,Y=null,J=null,ce=void 0,ee=null,le=!!D.dynamicChildren)=>{if(E===D)return;E&&!im(E,D)&&(Q=Nt(E),Qe(E,Y,J,!0),E=null),D.patchFlag===-2&&(le=!1,D.dynamicChildren=null);let{type:te,ref:Me,shapeFlag:ye}=D;switch(te){case oy:f(E,D,$,Q);break;case Sl:y(E,D,$,Q);break;case ly:E??x(D,$,Q,ce);break;case fo:O(E,D,$,Q,Y,J,ce,ee,le);break;default:ye&1?T(E,D,$,Q,Y,J,ce,ee,le):ye&6?U(E,D,$,Q,Y,J,ce,ee,le):(ye&64||ye&128)&&te.process(E,D,$,Q,Y,J,ce,ee,le,Kt)}Me!=null&&Y?Yp(Me,E&&E.ref,J,D||E,!D):Me==null&&E&&E.ref!=null&&Yp(E.ref,null,J,E,!0)},f=(E,D,$,Q)=>{if(E==null)r(D.el=o(D.children),$,Q);else{let Y=D.el=E.el;D.children!==E.children&&h(Y,D.children)}},y=(E,D,$,Q)=>{E==null?r(D.el=l(D.children||""),$,Q):D.el=E.el},x=(E,D,$,Q)=>{[E.el,E.anchor]=m(E.children,D,$,Q,E.el,E.anchor)},b=({el:E,anchor:D},$,Q)=>{let Y;for(;E&&E!==D;)Y=c(E),r(E,$,Q),E=Y;r(D,$,Q)},_=({el:E,anchor:D})=>{let $;for(;E&&E!==D;)$=c(E),s(E),E=$;s(D)},T=(E,D,$,Q,Y,J,ce,ee,le)=>{if(D.type==="svg"?ce="svg":D.type==="math"&&(ce="mathml"),E==null)w(D,$,Q,Y,J,ce,ee,le);else{let te=E.el&&E.el._isVueCE?E.el:null;try{te&&te._beginPatch(),R(E,D,Y,J,ce,ee,le)}finally{te&&te._endPatch()}}},w=(E,D,$,Q,Y,J,ce,ee)=>{let le,te,{props:Me,shapeFlag:ye,transition:_e,dirs:Ee}=E;if(le=E.el=a(E.type,J,Me&&Me.is,Me),ye&8?u(le,E.children):ye&16&&S(E.children,le,null,Q,Y,AT(E,J),ce,ee),Ee&&Xh(E,null,Q,"created"),M(le,E,E.scopeId,ce,Q),Me){for(let St in Me)St!=="value"&&!Up(St)&&n(le,St,null,Me[St],J,Q);"value"in Me&&n(le,"value",null,Me.value,J),(te=Me.onVnodeBeforeMount)&&ga(te,Q,E)}Ee&&Xh(E,null,Q,"beforeMount");let Ye=NX(Y,_e);Ye&&_e.beforeEnter(le),r(le,D,$),((te=Me&&Me.onVnodeMounted)||Ye||Ee)&&es(()=>{te&&ga(te,Q,E),Ye&&_e.enter(le),Ee&&Xh(E,null,Q,"mounted")},Y)},M=(E,D,$,Q,Y)=>{if($&&p(E,$),Q)for(let J=0;J<Q.length;J++)p(E,Q[J]);if(Y){let J=Y.subTree;if(D===J||qP(J.type)&&(J.ssContent===D||J.ssFallback===D)){let ce=Y.vnode;M(E,ce,ce.scopeId,ce.slotScopeIds,Y.parent)}}},S=(E,D,$,Q,Y,J,ce,ee,le=0)=>{for(let te=le;te<E.length;te++)g(null,E[te]=ee?yo(E[te]):ma(E[te]),D,$,Q,Y,J,ce,ee)},R=(E,D,$,Q,Y,J,ce)=>{let ee=D.el=E.el,{patchFlag:le,dynamicChildren:te,dirs:Me}=D;le|=E.patchFlag&16;let ye=E.props||zt,_e=D.props||zt,Ee;if($&&Kh($,!1),(Ee=_e.onVnodeBeforeUpdate)&&ga(Ee,$,D,E),Me&&Xh(D,E,$,"beforeUpdate"),$&&Kh($,!0),(ye.innerHTML&&_e.innerHTML==null||ye.textContent&&_e.textContent==null)&&u(ee,""),te?I(E.dynamicChildren,te,ee,$,Q,AT(D,Y),J):ce||ae(E,D,ee,null,$,Q,AT(D,Y),J,!1),le>0){if(le&16)B(ee,ye,_e,$,Y);else if(le&2&&ye.class!==_e.class&&n(ee,"class",null,_e.class,Y),le&4&&n(ee,"style",ye.style,_e.style,Y),le&8){let Ye=D.dynamicProps;for(let St=0;St<Ye.length;St++){let ct=Ye[St],Ft=ye[ct],Dt=_e[ct];(Dt!==Ft||ct==="value")&&n(ee,ct,Ft,Dt,Y,$)}}le&1&&E.children!==D.children&&u(ee,D.children)}else!ce&&te==null&&B(ee,ye,_e,$,Y);((Ee=_e.onVnodeUpdated)||Me)&&es(()=>{Ee&&ga(Ee,$,D,E),Me&&Xh(D,E,$,"updated")},Q)},I=(E,D,$,Q,Y,J,ce)=>{for(let ee=0;ee<D.length;ee++){let le=E[ee],te=D[ee];g(le,te,le.el&&(le.type===fo||!im(le,te)||le.shapeFlag&198)?d(le.el):$,null,Q,Y,J,ce,!0)}},B=(E,D,$,Q,Y)=>{if(D!==$){if(D!==zt)for(let J in D)!Up(J)&&!(J in $)&&n(E,J,D[J],null,Y,Q);for(let J in $){if(Up(J))continue;let ce=$[J],ee=D[J];ce!==ee&&J!=="value"&&n(E,J,ee,ce,Y,Q)}"value"in $&&n(E,"value",D.value,$.value,Y)}},O=(E,D,$,Q,Y,J,ce,ee,le)=>{let te=D.el=E?E.el:o(""),Me=D.anchor=E?E.anchor:o(""),{patchFlag:ye,dynamicChildren:_e,slotScopeIds:Ee}=D;Ee&&(ee=ee?ee.concat(Ee):Ee),E==null?(r(te,$,Q),r(Me,$,Q),S(D.children||[],$,Me,Y,J,ce,ee,le)):ye>0&&ye&64&&_e&&E.dynamicChildren&&E.dynamicChildren.length===_e.length?(
vendor: 8,373 bytes, line 2095
2095I(E.dynamicChildren,_e,$,Y,J,ce,ee),(D.key!=null||Y&&D===Y.subTree)&&NT(E,D,!0)):ae(E,D,$,Me,Y,J,ce,ee,le)},U=(E,D,$,Q,Y,J,ce,ee,le)=>{D.slotScopeIds=ee,E==null?D.shapeFlag&512?Y.ctx.activate(D,$,Q,ce,le):V(D,$,Q,Y,J,ce,le):z(E,D,le)},V=(E,D,$,Q,Y,J,ce)=>{let ee=E.component=zX(E,Q,Y);if(_P(E)&&(ee.ctx.renderer=Kt),jX(ee,!1,ce),ee.asyncDep){if(Y&&Y.registerDep(ee,Z,ce),!E.el){let le=ee.subTree=bn(Sl);y(null,le,D,$),E.placeholder=le.el}}else Z(ee,E,D,$,Y,J,ce)},z=(E,D,$)=>{let Q=D.component=E.component;if(bX(E,D,$))if(Q.asyncDep&&!Q.asyncResolved){j(Q,D,$);return}else Q.next=D,Q.update();else D.el=E.el,Q.vnode=D},Z=(E,D,$,Q,Y,J,ce)=>{let ee=()=>{if(E.isMounted){let{next:ye,bu:_e,u:Ee,parent:Ye,vnode:St}=E;{let Ei=$P(E);if(Ei){ye&&(ye.el=St.el,j(E,ye,ce)),Ei.asyncDep.then(()=>{es(()=>{E.isUnmounted||te()},Y)});return}}let ct=ye,Ft;Kh(E,!1),ye?(ye.el=St.el,j(E,ye,ce)):ye=St,_e&&H_(_e),(Ft=ye.props&&ye.props.onVnodeBeforeUpdate)&&ga(Ft,Ye,ye,St),Kh(E,!0);let Dt=MT(E),br=E.subTree;E.subTree=Dt,g(br,Dt,d(br.el),Nt(br),E,Y,J),ye.el=Dt.el,ct===null&&_X(E,Dt.el),Ee&&es(Ee,Y),(Ft=ye.props&&ye.props.onVnodeUpdated)&&es(()=>ga(Ft,Ye,ye,St),Y)}else{let ye,{el:_e,props:Ee}=D,{bm:Ye,m:St,parent:ct,root:Ft,type:Dt}=E,br=Kp(D);if(Kh(E,!1),Ye&&H_(Ye),!br&&(ye=Ee&&Ee.onVnodeBeforeMount)&&ga(ye,ct,D),Kh(E,!0),_e&&bi){let Ei=()=>{E.subTree=MT(E),bi(_e,E.subTree,E,Y,null)};br&&Dt.__asyncHydrate?Dt.__asyncHydrate(_e,E,Ei):Ei()}else{Ft.ce&&Ft.ce._hasShadowRoot()&&Ft.ce._injectChildStyle(Dt,E.parent?E.parent.type:void 0);let Ei=E.subTree=MT(E);g(null,Ei,$,Q,E,Y,J),D.el=Ei.el}if(St&&es(St,Y),!br&&(ye=Ee&&Ee.onVnodeMounted)){let Ei=D;es(()=>ga(ye,ct,Ei),Y)}(D.shapeFlag&256||ct&&Kp(ct.vnode)&&ct.vnode.shapeFlag&256)&&E.a&&es(E.a,Y),E.isMounted=!0,D=$=Q=null}};E.scope.on();let le=E.effect=new j3(ee);E.scope.off();let te=E.update=le.run.bind(le),Me=E.job=le.runIfDirty.bind(le);Me.i=E,Me.id=E.uid,le.scheduler=()=>pT(Me),Kh(E,!0),te()},j=(E,D,$)=>{D.component=E;let Q=E.vnode.props;E.vnode=D,E.next=null,wX(E,D.props,Q,$),RX(E,D.children,$),oo(),lP(E),lo()},ae=(E,D,$,Q,Y,J,ce,ee,le=!1)=>{let te=E&&E.children,Me=E?E.shapeFlag:0,ye=D.children,{patchFlag:_e,shapeFlag:Ee}=D;if(_e>0){if(_e&128){me(te,ye,$,Q,Y,J,ce,ee,le);return}else if(_e&256){W(te,ye,$,Q,Y,J,ce,ee,le);return}}Ee&8?(Me&16&&it(te,Y,J),ye!==te&&u($,ye)):Me&16?Ee&16?me(te,ye,$,Q,Y,J,ce,ee,le):it(te,Y,J,!0):(Me&8&&u($,""),Ee&16&&S(ye,$,Q,Y,J,ce,ee,le))},W=(E,D,$,Q,Y,J,ce,ee,le)=>{E||=Fd,D||=Fd;let te=E.length,Me=D.length,ye=Math.min(te,Me),_e;for(_e=0;_e<ye;_e++){let Ee=D[_e]=le?yo(D[_e]):ma(D[_e]);g(E[_e],Ee,$,null,Y,J,ce,ee,le)}te>Me?it(E,Y,J,!0,!1,ye):S(D,$,Q,Y,J,ce,ee,le,ye)},me=(E,D,$,Q,Y,J,ce,ee,le)=>{let te=0,Me=D.length,ye=E.length-1,_e=Me-1;for(;te<=ye&&te<=_e;){let Ee=E[te],Ye=D[te]=le?yo(D[te]):ma(D[te]);if(im(Ee,Ye))g(Ee,Ye,$,null,Y,J,ce,ee,le);else break;te++}for(;te<=ye&&te<=_e;){let Ee=E[ye],Ye=D[_e]=le?yo(D[_e]):ma(D[_e]);if(im(Ee,Ye))g(Ee,Ye,$,null,Y,J,ce,ee,le);else break;ye--,_e--}if(te>ye){if(te<=_e){let Ee=_e+1,Ye=Ee<Me?D[Ee].el:Q;for(;te<=_e;)g(null,D[te]=le?yo(D[te]):ma(D[te]),$,Ye,Y,J,ce,ee,le),te++}}else if(te>_e)for(;te<=ye;)Qe(E[te],Y,J,!0),te++;else{let Ee=te,Ye=te,St=new Map;for(te=Ye;te<=_e;te++){let _i=D[te]=le?yo(D[te]):ma(D[te]);_i.key!=null&&St.set(_i.key,te)}let ct,Ft=0,Dt=_e-Ye+1,br=!1,Ei=0,An=Array(Dt);for(te=0;te<Dt;te++)An[te]=0;for(te=Ee;te<=ye;te++){let _i=E[te];if(Ft>=Dt){Qe(_i,Y,J,!0);continue}let Wt;if(_i.key!=null)Wt=St.get(_i.key);else for(ct=Ye;ct<=_e;ct++)if(An[ct-Ye]===0&&im(_i,D[ct])){Wt=ct;break}Wt===void 0?Qe(_i,Y,J,!0):(An[Wt-Ye]=te+1,Wt>=Ei?Ei=Wt:br=!0,g(_i,D[Wt],$,null,Y,J,ce,ee,le),Ft++)}let Aa=br?LX(An):Fd;for(ct=Aa.length-1,te=Dt-1;te>=0;te--){let _i=Ye+te,Wt=D[_i],Io=D[_i+1],Na=_i+1<Me?Io.el||HP(Io):Q;An[te]===0?g(null,Wt,$,Na,Y,J,ce,ee,le):br&&(ct<0||te!==Aa[ct]?Ce(Wt,$,Na,2):ct--)}}},Ce=(E,D,$,Q,Y=null)=>{let{el:J,type:ce,transition:ee,children:le,shapeFlag:te}=E;if(te&6){Ce(E.component.subTree,D,$,Q);return}if(te&128){E.suspense.move(D,$,Q);return}if(te&64){ce.move(E,D,$,Kt);return}if(ce===fo){r(J,D,$);for(let Me=0;Me<le.length;Me++)Ce(le[Me],D,$,Q);r(E.anchor,D,$);return}if(ce===ly){b(E,D,$);return}if(Q!==2&&te&1&&ee)if(Q===0)ee.persisted&&!J[yT]?r(J,D,$):(ee.beforeEnter(J),r(J,D,$),es(()=>ee.enter(J),Y));else{let{leave:Me,delayLeave:ye,afterLeave:_e}=ee,Ee=()=>{E.ctx.isUnmounted?s(J):r(J,D,$)},Ye=()=>{let St=J._isLeaving||!!J[yT];J._isLeaving&&J[yT](!0),ee.persisted&&!St?Ee():Me(J,()=>{Ee(),_e&&_e()})};ye?ye(J,Ee,Ye):Ye()}else r(J,D,$)},Qe=(E,D,$,Q=!1,Y=!1)=>{let{type:J,props:ce,ref:ee,children:le,dynamicChildren:te,shapeFlag:Me,patchFlag:ye,dirs:_e,cacheIndex:Ee,memo:Ye}=E;if(ye===-2&&(Y=!1),ee!=null&&(oo(),Yp(ee,null,$,E,!0),lo()),Ee!=null&&(D.renderCache[Ee]=void 0),Me&256){D.ctx.deactivate(E);return}let St=Me&1&&_e,ct=!Kp(E),Ft;if(ct&&(Ft=ce&&ce.onVnodeBeforeUnmount)&&ga(Ft,D,E),Me&6)et(E.component,$,Q);else{if(Me&128){E.suspense.unmount($,Q);return}St&&Xh(E,null,D,"beforeUnmount"),Me&64?E.type.remove(E,D,$,Kt,Q):te&&!te.hasOnce&&(J!==fo||ye>0&&ye&64)?it(te,D,$,!1,!0):(J===fo&&ye&384||!Y&&Me&16)&&it(le,D,$),Q&&oe(E)}let Dt=Ye!=null&&Ee==null;(ct&&(Ft=ce&&ce.onVnodeUnmounted)||St||Dt)&&es(()=>{Ft&&ga(Ft,D,E),St&&Xh(E,null,D,"unmounted"),Dt&&(E.el=null)},$)},oe=E=>{let{type:D,el:$,anchor:Q,transition:Y}=E;if(D===fo){dt($,Q);return}if(D===ly){_(E);return}let J=()=>{s($),Y&&!Y.persisted&&Y.afterLeave&&Y.afterLeave()};if(E.shapeFlag&1&&Y&&!Y.persisted){let{leave:ce,delayLeave:ee}=Y,le=()=>ce($,J);ee?ee(E.el,J,le):le()}else J()},dt=(E,D)=>{let $;for(;E!==D;)$=c(E),s(E),E=$;s(D)},et=(E,D,$)=>{let{bum:Q,scope:Y,job:J,subTree:ce,um:ee,m:le,a:te}=E;WP(le),WP(te),Q&&H_(Q),Y.stop(),J&&(J.flags|=8,Qe(ce,E,D,$)),ee&&es(ee,D),es(()=>{E.isUnmounted=!0},D)},it=(E,D,$,Q=!1,Y=!1,J=0)=>{for(let ce=J;ce<E.length;ce++)Qe(E[ce],D,$,Q,Y)},Nt=E=>{if(E.shapeFlag&6)return Nt(E.component.subTree);if(E.shapeFlag&128)return E.suspense.next();let D=c(E.anchor||E.el),$=D&&D[mP];return $?c($):D},ci=!1,Ri=(E,D,$)=>{let Q;E==null?D._vnode&&(Qe(D._vnode,null,null,!0),Q=D._vnode.component):g(D._vnode||null,E,D,null,null,null,$),D._vnode=E,ci||=(ci=!0,lP(Q),hP(),!1)},Kt={p:g,um:Qe,m:Ce,r:oe,mt:V,mc:S,pc:ae,pbc:I,n:Nt,o:e},Fr,bi;return t&&([Fr,bi]=t(Kt)),{render:Ri,hydrate:Fr,createApp:mX(Ri,Fr)}}function AT({type:e,props:t},i){return i==="svg"&&e==="foreignObject"||i==="mathml"&&e==="annotation-xml"&&t&&t.encoding&&t.encoding.includes("html")?void 0:i}function Kh({effect:e,job:t},i){i?(e.flags|=32,t.flags|=4):(e.flags&=-33,t.flags&=-5)}function NX(e,t){return(!e||e&&!e.pendingBranch)&&t&&!t.persisted}function NT(e,t,i=!1){let r=e.children,s=t.children;if(Ue(r)&&Ue(s))for(let n=0;n<r.length;n++){let a=r[n],o=s[n];o.shapeFlag&1&&!o.dynamicChildren&&((o.patchFlag<=0||o.patchFlag===32)&&(o=s[n]=yo(s[n]),o.el=a.el),!i&&o.patchFlag!==-2&&NT(a,o)),o.type===oy&&(o.patchFlag===-1&&(o=s[n]=yo(o)),o.el=a.el),o.type===Sl&&!o.el&&(o.el=a.el)}}function LX(e){let t=e.slice(),i=[0],r,s,n,a,o,l=e.length;for(r=0;r<l;r++){let h=e[r];if(h!==0){if(s=i[i.length-1],e[s]<h){t[r]=s,i.push(r);continue}for(n=0,a=i.length-1;n<a;)o=n+a>>1,e[i[o]]<h?n=o+1:a=o;h<e[i[n]]&&(n>0&&(t[r]=i[n-1]),i[n]=r)}}for(n=i.length,a=i[n-1];n-- >0;)i[n]=a,a=t[a];return i}function $P(e){let t=e.subTree.component;if(t)return t.asyncDep&&!t.asyncResolved?t:$P(t)}function WP(e){if(e)for(let t=0;t<e.length;t++)e[t].flags|=8}function HP(e){if(e.placeholder)return e.placeholder;let t=e.component;return t?HP(t.subTree):null}var qP=e=>e.__isSuspense;function PX(e,t){t&&t.pendingBranch?Ue(e)?t.effects.push(...e):t.effects.push(e):Oq(e)}var fo=Symbol.for("v-fgt"),oy=Symbol.for("v-txt"),Sl=Symbol.for("v-cmt"),ly=Symbol.for("v-stc"),Qp=[],Rs=null;function Di(e=!1){Qp.push(Rs=e?null:[])}function kX(){Qp.pop(),Rs=Qp[Qp.length-1]||null}var em=1;function XP(e,t=!1){em+=e,e<0&&Rs&&t&&(Rs.hasOnce=!0)}function YP(e){return e.dynamicChildren=em>0?Rs||Fd:null,kX(),em>0&&Rs&&Rs.push(e),e}function ts(e,t,i,r,s,n){return YP(Tt(e,t,i,r,s,n,!0))}function tm(e,t,i,r,s){return YP(bn(e,t,i,r,s,!0))}function KP(e){return e?e.__v_isVNode===!0:!1}function im(e,t){return e.type===t.type&&e.key===t.key}var ZP=({key:e})=>e??null,hy=({ref:e,ref_key:t,ref_for:i})=>(typeof e=="number"&&(e=""+e),e==null?null:xi(e)||Ar(e)||ze(e)?{i:Cs,r:e,k:t,f:!!i}:e);function Tt(e,t=null,i=null,r=0,s=null,n=e===fo?0:1,a=!1,o=!1){let l={__v_isVNode:!0,__v_skip:!0,t
vendor: 4,654 bytes, line 2095
2095ype:e,props:t,key:t&&ZP(t),ref:t&&hy(t),scopeId:dP,slotScopeIds:null,children:i,component:null,suspense:null,ssContent:null,ssFallback:null,dirs:null,transition:null,el:null,anchor:null,target:null,targetStart:null,targetAnchor:null,staticCount:0,shapeFlag:n,patchFlag:r,dynamicProps:s,dynamicChildren:null,appContext:null,ctx:Cs};return o?(LT(l,i),n&128&&e.normalize(l)):i&&(l.shapeFlag|=xi(i)?8:16),em>0&&!a&&Rs&&(l.patchFlag>0||n&6)&&l.patchFlag!==32&&Rs.push(l),l}var bn=IX;function IX(e,t=null,i=null,r=0,s=null,n=!1){if((!e||e===nX)&&(e=Sl),KP(e)){let o=jd(e,t,!0);return i&&LT(o,i),em>0&&!n&&Rs&&(o.shapeFlag&6?Rs[Rs.indexOf(e)]=o:Rs.push(o)),o.patchFlag=-2,o}if(XX(e)&&(e=e.__vccOpts),t){t=FX(t);let{class:o,style:l}=t;o&&!xi(o)&&(t.class=Vp(o)),Gt(l)&&(dT(l)&&!Ue(l)&&(l=sr({},l)),t.style=bl(l))}let a=xi(e)?1:qP(e)?128:jq(e)?64:Gt(e)?4:ze(e)?2:0;return Tt(e,t,i,r,s,a,n,!0)}function FX(e){return e?dT(e)||OP(e)?sr({},e):e:null}function jd(e,t,i=!1,r=!1){let{props:s,ref:n,patchFlag:a,children:o,transition:l}=e,h=t?BX(s||{},t):s,u={__v_isVNode:!0,__v_skip:!0,type:e.type,props:h,key:h&&ZP(h),ref:t&&t.ref?i&&n?Ue(n)?n.concat(hy(t)):[n,hy(t)]:hy(t):n,scopeId:e.scopeId,slotScopeIds:e.slotScopeIds,children:o,target:e.target,targetStart:e.targetStart,targetAnchor:e.targetAnchor,staticCount:e.staticCount,shapeFlag:e.shapeFlag,patchFlag:t&&e.type!==fo?a===-1?16:a|16:a,dynamicProps:e.dynamicProps,dynamicChildren:e.dynamicChildren,appContext:e.appContext,dirs:e.dirs,transition:l,component:e.component,suspense:e.suspense,ssContent:e.ssContent&&jd(e.ssContent),ssFallback:e.ssFallback&&jd(e.ssFallback),placeholder:e.placeholder,el:e.el,anchor:e.anchor,ctx:e.ctx,ce:e.ce};return l&&r&&xT(u,l.clone(u)),u}function DX(e=" ",t=0){return bn(oy,null,e,t)}function OX(e,t){let i=bn(ly,null,e);return i.staticCount=t,i}function $d(e="",t=!1){return t?(Di(),tm(Sl,null,e)):bn(Sl,null,e)}function ma(e){return e==null||typeof e=="boolean"?bn(Sl):Ue(e)?bn(fo,null,e.slice()):KP(e)?yo(e):bn(oy,null,String(e))}function yo(e){return e.el===null&&e.patchFlag!==-1||e.memo?e:jd(e)}function LT(e,t){let i=0,{shapeFlag:r}=e;if(t==null)t=null;else if(Ue(t))i=16;else if(typeof t=="object")if(r&65){let s=t.default;s&&(s._c&&(s._d=!1),LT(e,s()),s._c&&(s._d=!0));return}else{i=32;let s=t._;!s&&!OP(t)?t._ctx=Cs:s===3&&Cs&&(Cs.slots._===1?t._=1:(t._=2,e.patchFlag|=1024))}else ze(t)?(t={default:t,_ctx:Cs},i=32):(t=String(t),r&64?(i=16,t=[DX(t)]):i=8);e.children=t,e.shapeFlag|=i}function BX(...e){let t={};for(let i=0;i<e.length;i++){let r=e[i];for(let s in r)if(s==="class")t.class!==r.class&&(t.class=Vp([t.class,r.class]));else if(s==="style")t.style=bl([t.style,r.style]);else if(j0(s)){let n=t[s],a=r[s];a&&n!==a&&!(Ue(n)&&n.includes(a))?t[s]=n?[].concat(n,a):a:a==null&&n==null&&!$0(s)&&(t[s]=a)}else s!==""&&(t[s]=r[s])}return t}function ga(e,t,i,r=null){vn(e,t,7,[i,r])}var UX=LP(),VX=0;function zX(e,t,i){let r=e.type,s=(t?t.appContext:e.appContext)||UX,n={uid:VX++,vnode:e,type:r,parent:t,appContext:s,root:null,next:null,subTree:null,effect:null,update:null,job:null,scope:new nq(!0),render:null,proxy:null,exposed:null,exposeProxy:null,withProxy:null,provides:t?t.provides:Object.create(s.provides),ids:t?t.ids:["",0,0],accessCache:null,renderCache:[],components:null,directives:null,propsOptions:UP(r,s),emitsOptions:PP(r,s),emit:null,emitted:null,propsDefaults:zt,inheritAttrs:r.inheritAttrs,ctx:zt,data:zt,props:zt,attrs:zt,slots:zt,refs:zt,setupState:zt,setupContext:null,suspense:i,suspenseId:i?i.pendingId:0,asyncDep:null,asyncResolved:!1,isMounted:!1,isUnmounted:!1,isDeactivated:!1,bc:null,c:null,bm:null,m:null,bu:null,u:null,um:null,bum:null,da:null,a:null,rtg:null,rtc:null,ec:null,sp:null};return n.ctx={_:n},n.root=t?t.root:n,n.emit=fX.bind(null,n),e.ce&&e.ce(n),n}var Nr=null,GX=()=>Nr||Cs,uy,PT;{let e=q0(),t=(i,r)=>{let s;return(s=e[i])||(s=e[i]=[]),s.push(r),n=>{s.length>1?s.forEach(a=>a(n)):s[0](n)}};uy=t("__VUE_INSTANCE_SETTERS__",i=>Nr=i),PT=t("__VUE_SSR_SETTERS__",i=>sm=i)}var rm=e=>{let t=Nr;return uy(e),e.scope.on(),()=>{e.scope.off(),uy(t)}},JP=()=>{Nr&&Nr.scope.off(),uy(null)};function QP(e){return e.vnode.shapeFlag&4}var sm=!1;function jX(e,t=!1,i=!1){t&&PT(t);let{props:r,children:s}=e.vnode,n=QP(e);TX(e,r,n,t),CX(e,s,i||t);let a=n?$X(e,t):void 0;return t&&PT(!1),a}function $X(e,t){let i=e.type;e.accessCache=Object.create(null),e.proxy=new Proxy(e.ctx,oX);let{setup:r}=i;if(r){oo();let s=e.setupContext=r.length>1?HX(e):null,n=rm(e),a=Hp(r,e,0,[e.props,s]),o=F3(a);if(lo(),n(),(o||e.sp)&&!Kp(e)&&xP(e),o){if(a.then(JP,JP),t)return a.then(l=>{ek(e,l,t)}).catch(l=>{Q0(l,e,0)});e.asyncDep=a}else ek(e,a,t)}else rk(e,t)}
vendor: 1,705 bytes, line 2095
2095function ek(e,t,i){ze(t)?e.type.__ssrInlineRender?e.ssrRender=t:e.render=t:Gt(t)&&(e.setupState=nP(t)),rk(e,i)}var tk,ik;function rk(e,t,i){let r=e.type;if(!e.render){if(!t&&tk&&!r.render){let s=r.template||wT(e).template;if(s){let{isCustomElement:n,compilerOptions:a}=e.appContext.config,{delimiters:o,compilerOptions:l}=r;r.render=tk(s,sr(sr({isCustomElement:n,delimiters:o},a),l))}}e.render=r.render||ha,ik&&ik(e)}{let s=rm(e);oo();try{lX(e)}finally{lo(),s()}}}var WX={get(e,t){return Er(e,"get",""),e[t]}};function HX(e){return{attrs:new Proxy(e.attrs,WX),slots:e.slots,emit:e.emit,expose:t=>{e.exposed=t||{}}}}function dy(e){return e.exposed?e.exposeProxy||=new Proxy(nP(Mq(e.exposed)),{get(t,i){if(i in t)return t[i];if(i in Zp)return Zp[i](e)},has(t,i){return i in t||i in Zp}}):e.proxy}function qX(e,t=!0){return ze(e)?e.displayName||e.name:e.name||t&&e.__name}function XX(e){return ze(e)&&"__vccOpts"in e}var sk=(e,t)=>Lq(e,t,sm),YX="3.5.35",kT=void 0,nk=typeof window<"u"&&window.trustedTypes;if(nk)try{kT=nk.createPolicy("vue",{createHTML:e=>e})}catch{}var ak=kT?e=>kT.createHTML(e):e=>e,KX="http://www.w3.org/2000/svg",ZX="http://www.w3.org/1998/Math/MathML",xo=typeof document<"u"?document:null,ok=xo&&xo.createElement("template"),JX={insert:(e,t,i)=>{t.insertBefore(e,i||null)},remove:e=>{let t=e.parentNode;t&&t.removeChild(e)},createElement:(e,t,i,r)=>{let s=t==="svg"?xo.createElementNS(KX,e):t==="mathml"?xo.createElementNS(ZX,e):i?xo.createElement(e,{is:i}):xo.createElement(e);return e==="select"&&r&&r.multiple!=null&&s.setAttribute("multiple",r.multiple),s},createText:e=>xo.createTextNode(e),createComment:e=>xo.createComment(e),setText:(e,t)=>{e.nodeValue=t},setElementText:(e,t)=>
vendor: 4,217 bytes, line 2095
2095{e.textContent=t},parentNode:e=>e.parentNode,nextSibling:e=>e.nextSibling,querySelector:e=>xo.querySelector(e),setScopeId(e,t){e.setAttribute(t,"")},insertStaticContent(e,t,i,r,s,n){let a=i?i.previousSibling:t.lastChild;if(s&&(s===n||s.nextSibling))for(;t.insertBefore(s.cloneNode(!0),i),!(s===n||!(s=s.nextSibling)););else{ok.innerHTML=ak(r==="svg"?`<svg>${e}</svg>`:r==="mathml"?`<math>${e}</math>`:e);let o=ok.content;if(r==="svg"||r==="mathml"){let l=o.firstChild;for(;l.firstChild;)o.appendChild(l.firstChild);o.removeChild(l)}t.insertBefore(o,i)}return[a?a.nextSibling:t.firstChild,i?i.previousSibling:t.lastChild]}},QX=Symbol("_vtc");function eY(e,t,i){let r=e[QX];r&&(t=(t?[t,...r]:[...r]).join(" ")),t==null?e.removeAttribute("class"):i?e.setAttribute("class",t):e.className=t}var cy=Symbol("_vod"),lk=Symbol("_vsh"),IT={name:"show",beforeMount(e,{value:t},{transition:i}){e[cy]=e.style.display==="none"?"":e.style.display,i&&t?i.beforeEnter(e):nm(e,t)},mounted(e,{value:t},{transition:i}){i&&t&&i.enter(e)},updated(e,{value:t,oldValue:i},{transition:r}){!t!=!i&&(r?t?(r.beforeEnter(e),nm(e,!0),r.enter(e)):r.leave(e,()=>{nm(e,!1)}):nm(e,t))},beforeUnmount(e,{value:t}){nm(e,t)}};function nm(e,t){e.style.display=t?e[cy]:"none",e[lk]=!t}var tY=Symbol(""),iY=/(?:^|;)\s*display\s*:/;function rY(e,t,i){let r=e.style,s=xi(i),n=!1;if(i&&!s){if(t)if(xi(t))for(let a of t.split(";")){let o=a.slice(0,a.indexOf(":")).trim();i[o]??am(r,o,"")}else for(let a in t)i[a]??am(r,a,"");for(let a in i){a==="display"&&(n=!0);let o=i[a];o==null?am(r,a,""):nY(e,a,!xi(t)&&t?t[a]:void 0,o)||am(r,a,o)}}else if(s){if(t!==i){let a=r[tY];a&&(i+=";"+a),r.cssText=i,n=iY.test(i)}}else t&&e.removeAttribute("style");cy in e&&(e[cy]=n?r.display:"",e[lk]&&(r.display="none"))}var hk=/\s*!important$/;function am(e,t,i){if(Ue(i))i.forEach(r=>am(e,t,r));else if(i??="",t.startsWith("--"))e.setProperty(t,i);else{let r=sY(e,t);hk.test(i)?e.setProperty(Wh(r),i.replace(hk,""),"important"):e[r]=i}}var uk=["Webkit","Moz","ms"],FT={};function sY(e,t){let i=FT[t];if(i)return i;let r=Zr(t);if(r!=="filter"&&r in e)return FT[t]=r;r=H0(r);for(let s=0;s<uk.length;s++){let n=uk[s]+r;if(n in e)return FT[t]=n}return t}function nY(e,t,i,r){return e.tagName==="TEXTAREA"&&(t==="width"||t==="height")&&xi(r)&&i===r}var dk="http://www.w3.org/1999/xlink";function ck(e,t,i,r,s,n=rq(t)){r&&t.startsWith("xlink:")?i==null?e.removeAttributeNS(dk,t.slice(6,t.length)):e.setAttributeNS(dk,t,i):i==null||n&&!V3(i)?e.removeAttribute(t):e.setAttribute(t,n?"":ua(i)?String(i):i)}function pk(e,t,i,r,s){if(t==="innerHTML"||t==="textContent"){i!=null&&(e[t]=t==="innerHTML"?ak(i):i);return}let n=e.tagName;if(t==="value"&&n!=="PROGRESS"&&!n.includes("-")){let o=n==="OPTION"?e.getAttribute("value")||"":e.value,l=i==null?e.type==="checkbox"?"on":"":String(i);(o!==l||!("_value"in e))&&(e.value=l),i??e.removeAttribute(t),e._value=i;return}let a=!1;if(i===""||i==null){let o=typeof e[t];o==="boolean"?i=V3(i):i==null&&o==="string"?(i="",a=!0):o==="number"&&(i=0,a=!0)}try{e[t]=i}catch{}a&&e.removeAttribute(s||t)}function aY(e,t,i,r){e.addEventListener(t,i,r)}function oY(e,t,i,r){e.removeEventListener(t,i,r)}var mk=Symbol("_vei");function lY(e,t,i,r,s=null){let n=e[mk]||(e[mk]={}),a=n[t];if(r&&a)a.value=r;else{let[o,l]=hY(t);r?aY(e,o,n[t]=cY(r,s),l):a&&(oY(e,o,a,l),n[t]=void 0)}}var gk=/(?:Once|Passive|Capture)$/;function hY(e){let t;if(gk.test(e)){t={};let i;for(;i=e.match(gk);)e=e.slice(0,e.length-i[0].length),t[i[0].toLowerCase()]=!0}return[e[2]===":"?e.slice(3):Wh(e.slice(2)),t]}var fk=0,uY=Promise.resolve(),dY=()=>fk||=(uY.then(()=>fk=0),Date.now());function cY(e,t){let i=r=>{if(!r._vts)r._vts=Date.now();else if(r._vts<=i.attached)return;let s=i.value;if(Ue(s)){let n=r.stopImmediatePropagation;r.stopImmediatePropagation=()=>{n.call(r),r._stopped=!0};let a=s.slice(),o=[r];for(let l=0;l<a.length&&!r._stopped;l++){let h=a[l];h&&vn(h,t,5,o)}}else vn(s,t,5,[r])};return i.value=e,i.attached=dY(),i}var yk=e=>e.charCodeAt(0)===111&&e.charCodeAt(1)===110&&e.charCodeAt(2)>96&&e.charCodeAt(2)<123,pY=(e,t,i,r,s,n)=>{let a=s==="svg";t==="class"?eY(e,r,a):t==="style"?rY(e,i,r):j0(t)?$0(t)||lY(e,t,i,r,n):(t[0]==="."?(t=t.slice(1),!0):t[0]==="^"?(t=t.
2095slice(1),!1):mY(e,t,r,a))?(pk(e,t,r),!e.tagName.includes("-")&&(t==="value"||t==="checked"||t==="selected")&&ck(e,t,r,a,n,t!=="value")):e._isVueCE&&(gY(e,t)||e._def.__asyncLoader&&(/[A-Z]/.test(t)||!xi(r)))?pk(e,Zr(t),r,n,t):(t==="true-value"?e._trueValue=r:t==="false-value"&&(e._falseValue=r),ck(e,t,r,a))};function mY(e,t,i,r){if(r)return!!(t==="innerHTML"||t==="textContent"||t in e&&yk(t)&&ze(i));if(t==="spellcheck"||t==="draggable"||t==="translate"||t==="autocorrect"||t==="sandbox"&&e.tagName==="IFRAME"||t==="form"||t==="list"&&e.tagName==="INPUT"||t==="type"&&e.tagName==="TEXTAREA")return!1;if(t==="width"||t==="height"){let s=e.tagName;if(s==="IMG"||s==="VIDEO"||s==="CANVAS"||s==="SOURCE")return!1}return yk(t)&&xi(i)?!1:t in e}function gY(e,t){let i=e._def.props;if(!i)return!1;let r=Zr(t);return Array.isArray(i)?i.some(s=>Zr(s)===r):Object.keys(i).some(s=>Zr(s)===r)}var fY=sr({patchProp:pY},JX),yY;function xY(){return yY||=EX(fY)}var vY=((...e)=>{let t=xY().createApp(...e),{mount:i}=t;return t.mount=r=>{let s=_Y(r);if(!s)return;let n=t._component;!ze(n)&&!n.render&&!n.template&&(n.template=s.innerHTML),s.nodeType===1&&(s.textContent="");let a=i(s,!1,bY(s));return s instanceof Element&&(s.removeAttribute("v-cloak"),s.setAttribute("data-v-app","")),a},t});function bY(e){if(e instanceof SVGElement)return"svg";if(typeof MathMLElement=="function"&&e instanceof MathMLElement)return"mathml"}function _Y(e){return xi(e)?document.querySelector(e):e}var DT=Id("[LayerData]"),fa=class mO{constructor(){this.baseUrl=cI.value,this.imageFormat="webp",this.name="name not defined",this.paramName="",this.legends=null,this.haveSnow=!1,this.timeline=null,this.providers=[],this.overlays=[],this.zoomFactor=4,this.sizeFactor=1,this.stepForecast=5,this.fadeDuration=.4,this.delayBetween=0,this.directRender=!1,this.canStackLayer=!1,this.opticalFlowLayer=null,this.selectedProvider=Ae({}),this.isImageLayer=!1,this.isObjectLayer=!1,this.isWaterLayer=!1,this.showExtentLine=!0,this.colorOptions={srgb:!1,stepColor:0,blending:"normal",gradientMode:"non-linear",useGradient:!0,alphaTest:.01,blackIsAlpha:!1,blueIsAlpha:!1,blackAlphaMin:.015,blackAlphaMax:.025},this.minZoom=3,this.maxZoom=13,this.getBlur=HH({providerRef:this.selectedProvider,fallback:{start:0,incrementStart:5}}),this.type="dataTile"}onBeforeShow(t){}onAfterShow(t){}onBeforeHide(t){}onAfterHide(t){}initFromData=async t=>(this.id=t.id,this.displayName=t.name,this.name=t.name,this.timeline=new WH(t.timeline),this.initGroups(t),this.initOverlays(t),this.initLegends(t),this.initProviders(t),this.selectedProvider.value=this.providers.length>0?this.providers[0]:null,this.selectedProvider.value||DT.warn(`[WARNING] : Layer-${this.id} ${this.name} - No Provider found`),new Promise(async(i,r)=>{switch(await this.loadExtraData(),this.name){case"cloud_t":this.colorOptions.blueIsAlpha=!0,this.colorOptions.useGradient=!1;break;case"prmsl":this.stepForecast=3;break;case"radar":this.transparentTiles=!0,this.getBlur=z_({start:0,7:1,9:2,10:3,12:4}),this.baseUrl="https://static5.mclcm.net/images/dynmap/obs",this.zoomFactor=1,this.stepForecast=1,this.overrideRenderOrder=5e5,this.colorOptions.gradientMode="linear",this.colorOptions.gradientMode="non-linear",this.haveSnow=!0,this.fadeDuration=.5,this.colorOptions.alphaTest=.07,this.valueConversion=s=>.715*Math.exp(.0167*s.b)-.715,this.showExtentLine=!1;break;case"mervent":case"houle_cm":case"mervent_cm":case"vaguemax_cm":case"vague_cm":this.colorOptions.particleMask=!0,this.isWaterLayer=!0;break;case"pm10":break;case"pm25":break;case"so2":break;case"o3":break;case"no2":break;case"co":break;case"rh2m":break;case"caqi":break;case"aqi":break;case"atmo":break;case"rafale":break;case"vent_kmh":break;case"eumetsat":this.transparentTiles=!0,this.baseUrl="https://static5.mclcm.net/images/dynmap/obs",this.zoomFactor=2,this.stepForecast=1,this.colorOptions.blueIsAlpha=!0,this.fadeDuration=.35,this.immediateFade=!1,this.overrideRenderOrder=499999,this.directRender=!1,this.getBlur=z_({start:0,6:1,7:4,8:6,9:8});break;case"risque_precip":this.valueConversion=s=>{let n=s.b,a=this.provider?.value?.domain?.maxColorValue||231,o=Math.min(n/a,1),l=this.legends[this.colorOptions.legendIndex||0]?.values||[],h=l.length?Math.min(...l):0;return h+o*(90-h)};break;case"precip":this.colorOptions.alphaMode="multiply",this.colorOptions.gradientMode="non-linear",this.colorOptions.powPercent=2,this.colorOptions.discardAlpha=!0,this.colorOptions.alphaTest=.103,this.haveSnow=!0,this.valueConversion=s=>.715*Math.exp(.0167*s.b)-.715,this.zoomFactor=4,this.stepForecast=2;break;case"cumul_precip_hloc":this.colorOptions.alphaMode="multiply",this.colorOptions.gradientMode="non-linear",this.colorOptions.powPercent=2,this.colorOptions.discardAlpha=!0,this.zoomFactor=4,this.stepForecast=2,this.valueConversion=s=>.615*Math.exp(.0243*s.b)-.615;break;case"t2m":this.valueConversion=s=>-40+(s.b/255)**1.15*90;break;case"tres":this.valueConversion=s=>-40+(s.b/255)**1.15*90;break;case"tmer":this.isWaterLayer=!0,this.valueConversion=s=>-2+(s.b/255)**1*37;break;case"tsol":this.valueConversion=s=>-40+(s.b/255)**1.15*90;break;case"ht0":break;case"uvi":break;case"visi":break;case"orage":break;case"risque_precip":break;case"foudre":this.isParticleLayer=!0,this.getBlur=z_({start:0}),this.minZoom=0,this.maxZoom=0,this.overrideRenderOrder=10000001,this.imageUrl="https://static5.mclcm.net/images/mc2020/bundles/map/particle2.jpg",this.getUrl=(s,n)=>`https://static5.mclcm.net/images/dynmap/obs/foudre/pointee/${s}/foudre/${n}/0/0/1.json`,this.initParticles=async(s,n)=>{let a=[];Bi.value++;try{let o=await fetch(hi(n.getURL()));if(!o.ok)throw Error(`HTTP error! status: ${o.status}`);let l=await o.json();
2095(Array.isArray(l)?l:Object.values(l)).forEach(h=>{h.lat&&h.lon&&a.push({position:[parseFloat(h.lon),parseFloat(h.lat)],type:h.type||"m-10"})})}catch(o){DT.warn(`Failed to load lightning data: ${o.message}`)}finally{setTimeout(()=>{Bi.value--},32)}s.addParticles({imageUrl:this.imageUrl,data:a})};break}i()}));initGroups=t=>{this.group=A3.getGroupByID(t.group),this.group&&this.group.addLayer(this)};initOverlays=t=>{for(let i of t.overlays)this.overlays.push(N3.getOverlayByID(i))};initLegends=t=>{let i=t.providers[0].params[0].legends;if(i.length,i.length>0){this.legends=[];for(let r of i)this.legends.push($h.getLegendByID(r.legend_id))}};initProviders=t=>{for(let i of t.providers){let r=L3.getProviderByID(i.provider_id);r?console.log("provider found"):r=L3.add(i),this.providers.push(r)}this.name=this.providers[0].layerName};loadExtraData=async()=>{!this.isLoaded&&this.selectedProvider.value.loadExtraData&&await this.selectedProvider.value.loadExtraData()};get isLoaded(){return this.selectedProvider.value.isLoaded}get layerName(){return this.selectedProvider.value?this.selectedProvider.value.layerName:(DT.warn(`[WARNING] : Layer-${this.id} ${this.name} - No Provider`),"provider not defined")}get modelName(){return this.selectedProvider.value?this.selectedProvider.value.model?this.selectedProvider.value.model.name:"model not defined":"provider not defined"}getProvider=()=>this.selectedProvider;formatDate(t){let i=OH(new Date(t),"Europe/Paris");return`${i.getFullYear()}${String(i.getMonth()+1).padStart(2,"0")}${String(i.getDate()).padStart(2,"0")}0000`}getBaseUrl=(t,i,r=null,s=null)=>(r||=this.modelName,s=s||this.urlLayerName||this.layerName,`${this.baseUrl}/${r}/${t}/${s}/${i}/`);getUrl=(t,i)=>{if(t!==void 0&&i!==void 0){let r=hi(this.getBaseUrl(t,i));return Pu?`${r}{z}%2F{x}%2F{y}${encodeURIComponent("."+this.imageFormat)}`:`${r}{z}/{x}/{y}.${this.imageFormat}`}else return console.warn("undefined run | echeance"),null};toString=()=>`${this.name}: ${this.providers.length}
2095providers`;clone=(t=!1)=>{let i=new mO;for(let r of["id","name","baseUrl","imageFormat","paramName","zoomFactor","sizeFactor","stepForecast","fadeDuration","delayBetween","isImageLayer","isObjectLayer","isWaterLayer","minZoom","maxZoom","type","urlLayerName","isParticleLayer","imageUrl","overrideRenderOrder","timeline","legends","legendsSnow","opticalFlowLayer"])this[r]!==void 0&&(i[r]=this[r]);return i.colorOptions=JSON.parse(JSON.stringify(this.colorOptions||{})),i.selectedProvider=t?Ae(this.selectedProvider.value):this.selectedProvider,i.providers=t?[...this.providers]:this.providers,i.overlays=[...this.overlays],this.group&&(i.group=this.group.clone?this.group.clone():this.group),i}},xk={info:1,warn:2,error:3,none:4},TY=xk.info;function vk(...e){TY>xk.warn||console.warn(...e)}var nr={UNKNOWN:0,INTERSECTING:1,ABOVE:2,RIGHT:4,BELOW:8,LEFT:16};function OT(e){let t=ya();for(let i=0,r=e.length;i<r;++i)lm(t,e[i]);return t}function wY(e,t,i){return Ml(Math.min.apply(null,e),Math.min.apply(null,t),Math.max.apply(null,e),Math.max.apply(null,t),i)}function Zh(e,t,i){return i?(i[0]=e[0]-t,i[1]=e[1]-t,i[2]=e[2]+t,i[3]=e[3]+t,i):[e[0]-t,e[1]-t,e[2]+t,e[3]+t]}function bk(e,t){return t?(t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t):e.slice()}function Wd(e,t,i){let r,s;return r=t<e[0]?e[0]-t:e[2]<t?t-e[2]:0,s=i<e[1]?e[1]-i:e[3]<i?i-e[3]:0,r*r+s*s}function Hd(e,t){return BT(e,t[0],t[1])}function SY(e,t){return e[0]<=t[0]&&t[2]<=e[2]&&e[1]<=t[1]&&t[3]<=e[3]}function BT(e,t,i){return e[0]<=t&&t<=e[2]&&e[1]<=i&&i<=e[3]}function UT(e,t){let i=e[0],r=e[1],s=e[2],n=e[3],a=t[0],o=t[1],l=nr.UNKNOWN;return a<i?l|=nr.LEFT:a>s&&(l|=nr.RIGHT),o<r?l|=nr.BELOW:o>n&&(l|=nr.ABOVE),l===nr.UNKNOWN&&(l=nr.INTERSECTING),l}function ya(){return[1/0,1/0,-1/0,-1/0]}function Ml(e,t,i,r,s){return s?(s[0]=e,s[1]=t,s[2]=i,s[3]=r,s):[e,t,i,r]}function om(e){return Ml(1/0,1/0,-1/0,-1/0,e)}function _k(e,t){let i=e[0],r=e[1];return Ml(i,r,i,r,t)}function VT(e,t,i,r,s){return Tk(om(s),e,t,i,r)}function py(e,t){return e[0]==t[0]&&e[2]==t[2]&&e[1]==t[1]&&e[3]==t[3]}function MY(e,t){return t[0]<e[0]&&(e[0]=t[0]),t[2]>e[2]&&(e[2]=t[2]),t[1]<e[1]&&(e[1]=t[1]),t[3]>e[3]&&(e[3]=t[3]),e}function lm(e,t){t[0]<e[0]&&(e[0]=t[0]),t[0]>e[2]&&(e[2]=t[0]),t[1]<e[1]&&(e[1]=t[1]),t[1]>e[3]&&(e[3]=t[1])}function Tk(e,t,i,r,s){for(;i<r;i+=s)CY(e,t[i],t[i+1]);return e}function CY(e,t,i){e[0]=Math.min(e[0],t),e[1]=Math.min(e[1],i),e[2]=Math.max(e[2],t),e[3]=Math.max(e[3],i)}function wk(e,t){let i;return i=t(my(e)),i||(i=t(gy(e)),i)||(i=t(fy(e)),i)||(i=t(Cl(e)),i)?i:!1}function zT(e){let t=0;return qd(e)||(t=Jt(e)*is(e)),t}function my(e){return[e[0],e[1]]}function gy(e){return[e[2],e[1]]}function Jh(e){return[(e[0]+e[2])/2,(e[1]+e[3])/2]}function RY(e,t){let i;if(t==="bottom-left")i=my(e);else if(t==="bottom-right")i=gy(e);else if(t==="top-left")i=Cl(e);else if(t==="top-right")i=fy(e);else throw Error("Invalid corner");return i}function GT(e,t,i,r,s){let[n,a,o,l,h,u,d,c]=Sk(e,t,i,r);return Ml(Math.min(n,o,h,d),Math.min(a,l,u,c),Math.max(n,o,h,d),Math.max(a,l,u,c),s)}function Sk(e,t,i,r){let s=t*r[0]/2,n=t*r[1]/2,a=Math.cos(i),o=Math.sin(i),l=s*a,h=s*o,u=n*a,d=n*o,c=e[0],p=e[1];return[c-l+d,p-h-u,c-l-d,p-h+u,c+l-d,p+h+u,c+l+d,p+h-u,c-l+d,p-h-u]}function is(e){return e[3]-e[1]}function ds(e,t,i){let r=i||ya();return Xi(e,t)?(e[0]>t[0]?r[0]=e[0]:r[0]=t[0],e[1]>t[1]?r[1]=e[1]:r[1]=t[1],e[2]<t[2]?r[2]=e[2]:r[2]=t[2],e[3]<t[3]?r[3]=e[3]:r[3]=t[3]):om(r),r}function Cl(e){return[e[0],e[3]]}function fy(e){return[e[2],e[3]]}function Jt(e){return e[2]-e[0]}function Xi(e,t){return e[0]<=t[2]&&e[2]>=t[0]&&e[1]<=t[3]&&e[3]>=t[1]}function qd(e){return e[2]<e[0]||e[3]<e[1]}function EY(e,t){return t?(t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t):e}function AY(e,t,i){let r=!1,s=UT(e,t),n=UT(e,i);if(s===nr.INTERSECTING||n===nr.INTERSECTING)r=!0;else{let a=e[0],o=e[1],l=e[2],h=e[3],u=t[0],d=t[1],c=i[0],p=i[1],m=(p-d)/(c-u),g,f;n&nr.ABOVE&&!(s&nr.ABOVE)&&(g=c-(p-h)/m,r=g>=a&&g<=l),!r&&n&nr.RIGHT&&!(s&nr.RIGHT)&&(f=p-(c-l)*m,r=f>=o&&f<=h),!r&&n&nr.BELOW&&!(s&nr.BELOW)&&(g=c-(p-o)/m,r=g>=a&&g<=l),!r&&n&nr.LEFT&&!(s&nr.LEFT)&&(f=p-(c-a)*m,r=f>=o&&f<=h)}return r}function NY(e,t,i,r){if(qd(e))return om(i);let s=[];if(r>1){let o=e[2]-e[0],l=e[3]-e[1];for(let h=0;h<r;++h)s.push(e[0]+o*h/r,e[1],e[2],e[1]+l*h/r,e[2]-o*h/r,e[3],e[0],e[3]-l*h/r)}else s=[e[0],e[1],e[2],e[1],e[2],e[3],e[0],e[3]];t(s,s,2);let n=[],a=[];for(let o=0,l=s.length;o<l;o+=2)n.push(s[o]),a.push(s[o+1]);return wY(n,a,i)}function LY(e,t){let i=t.getExtent(),r=Jh(e);if(t.canWrapX()&&(r[0]<i[0]||r[0]>
2095=i[2])){let s=Jt(i),n=Math.floor((r[0]-i[0])/s)*s;e[0]-=n,e[2]-=n}return e}function PY(e,t,i){if(t.canWrapX()){let r=t.getExtent();if(!isFinite(e[0])||!isFinite(e[2]))return[[r[0],e[1],r[2],e[3]]];LY(e,t);let s=Jt(r);if(Jt(e)>s&&!i)return[[r[0],e[1],r[2],e[3]]];if(e[0]<r[0])return[[e[0]+s,e[1],r[2],e[3]],[r[0],e[1],e[2],e[3]]];if(e[2]>r[2])return[[e[0],e[1],r[2],e[3]],[r[0],e[1],e[2]-s,e[3]]]}return[e]}function ri(e,t,i){return Math.min(Math.max(e,t),i)}function kY(e,t,i,r,s,n){let a=s-i,o=n-r;if(a!==0||o!==0){let l=((e-i)*a+(t-r)*o)/(a*a+o*o);l>1?(i=s,r=n):l>0&&(i+=a*l,r+=o*l)}return Qh(e,t,i,r)}function Qh(e,t,i,r){let s=i-e,n=r-t;return s*s+n*n}function IY(e){let t=e.length;for(let r=0;r<t;r++){let s=r,n=Math.abs(e[r][r]);for(let o=r+1;o<t;o++){let l=Math.abs(e[o][r]);l>n&&(n=l,s=o)}if(n===0)return null;let a=e[s];e[s]=e[r],e[r]=a;for(let o=r+1;o<t;o++){let l=-e[o][r]/e[r][r];for(let h=r;h<t+1;h++)r==h?e[o][h]=0:e[o][h]+=l*e[r][h]}}let i=Array(t);for(let r=t-1;r>=0;r--){i[r]=e[r][t]/e[r][r];for(let s=r-1;s>=0;s--)e[s][t]-=e[s][r]*i[r]}return i}function Mk(e){return e*180/Math.PI}function Rl(e){return e*Math.PI/180}function eu(e,t){let i=e%t;return i*t<0?i+t:i}function Es(e,t,i){return e+i*(t-e)}function yy(e,t){let i=10**t;return Math.round(e*i)/i}function xy(e,t){return Math.floor(yy(e,t))}function vy(e,t){return Math.ceil(yy(e,t))}function jT(e,t,i){if(e>=t&&e<i)return e;let r=i-t;return((e-t)%r+r)%r+t}function FY(e,t){return e[0]+=+t[0],e[1]+=+t[1],e}function by(e,t){let i=!0;for(let r=e.length-1;r>=0;--r)if(e[r]!=t[r]){i=!1;break}return i}function $T(e,t){let i=Math.cos(t),r=Math.sin(t),s=e[0]*i-e[1]*r,n=e[1]*i+e[0]*r;return e[0]=s,e[1]=n,e}function DY(e,t){return e[0]*=t,e[1]*=t,e}function Ck(e,t){if(t.canWrapX()){let i=Jt(t.getExtent()),r=OY(e,t,i);r&&(e[0]-=r*i)}return e}function OY(e,t,i){let r=t.getExtent(),s=0;return t.canWrapX()&&(e[0]<r[0]||e[0]>r[2])&&(i||=Jt(r),s=Math.floor((e[0]-r[0])/i)),s}function BY(e,t,i){let r=Math.sqrt((t[0]-e[0])*(t[0]-e[0])+(t[1]-e[1])*(t[1]-e[1])),s=[(t[0]-e[0])/r,(t[1]-e[1])/r],n=[-s[1],s[0]],a=Math.sqrt((i[0]-e[0])*(i[0]-e[0])+(i[1]-e[1])*(i[1]-e[1])),o=[(i[0]-e[0])/a,(i[1]-e[1])/a],l=r===0||a===0?0:Math.acos(ri(o[0]*s[0]+o[1]*s[1],-1,1));return l=Math.max(l,1e-5),o[0]*n[0]+o[1]*n[1]>0?l:Math.PI*2-l}var hm={radians:6370997/(2*Math.PI),degrees:2*Math.PI*6370997/360,ft:.3048,m:1,"us-ft":1200/3937},_y=class{constructor(e){this.code_=e.code,this.units_=e.units,this.extent_=e.extent===void 0?null:e.extent,this.worldExtent_=e.worldExtent===void 0?null:e.worldExtent,this.axisOrientation_=e.axisOrientation===void 0?"enu":e.axisOrientation,this.global_=e.global===void 0?!1:e.global,this.canWrapX_=!!(this.global_&&this.extent_),this.getPointResolutionFunc_=e.getPointResolution,this.defaultTileGrid_=null,this.metersPerUnit_=e.metersPerUnit}canWrapX(){return this.canWrapX_}getCode(){return this.code_}getExtent(){return this.extent_}getUnits(){return this.units_}getMetersPerUnit(){return this.metersPerUnit_||hm[this.units_]}getWorldExtent(){return this.worldExtent_}getAxisOrientation(){return this.axisOrientation_}isGlobal(){return this.global_}setGlobal(e){this.global_=e,this.canWrapX_=!!(e&&this.extent_)}getDefaultTileGrid(){return this.defaultTileGrid_}setDefaultTileGrid(e){this.defaultTileGrid_=e}setExtent(e){this.extent_=e,this.canWrapX_=!!(this.global_&&e)}setWorldExtent(e){this.worldExtent_=e}setGetPointResolution(e){this.getPointResolutionFunc_=e}getPointResolutionFunc(){return this.getPointResolutionFunc_}},um=6378137,Xd=Math.PI*um,UY=[-Xd,-Xd,Xd,Xd],VY=[-180,-85,180,85],Ty=um*Math.log(Math.tan(Math.PI/2)),Yd=class extends _y{constructor(e){super({code:e,units:"m",extent:UY,global:!0,worldExtent:VY,getPointResolution:function(t,i){return t/Math.cosh(i[1]/um)}})}},Rk=[new Yd("EPSG:3857"),new Yd("EPSG:102100"),new Yd("EPSG:102113"),new Yd("EPSG:900913"),new Yd("http://www.opengis.net/def/crs/EPSG/0/3857"),new Yd("http://www.opengis.net/gml/srs/epsg.xml#3857")];function zY(e,t,i,r){let s=e.length;i=i>1?i:2,r??=i,t===void 0&&(t=i>2?e.slice():Array(s));for(let n=0;n<s;n+=r){t[n]=Xd*e[n]/180;let a=um*Math.log(Math.tan(Math.PI*(+e[n+1]+90)/360));a>Ty?a=Ty:a<-Ty&&(a=-Ty),t[n+1]=a}return t}function GY(e,t,i,r){let s=e.length;i=i>1?i:2,r??=i,t===void 0&&(t=i>2?e.slice():Array(s));for(let n=0;n<s;n+=r)t[n]=180*e[n]/Xd,t[n+1]=360*Math.atan(Math.exp(e[n+1]/um))/Math.PI-90;return t}var jY=6378137,Ek=[-180,-90,180,90],$Y=Math.PI*jY/180,tu=class extends _y{constructor(e,t){super({code:e,units:"degrees",extent:Ek,axisOrientation:t,global:!0,metersPerUnit:$Y,worldExtent:Ek})}},Ak=[new tu("CRS:84"),new tu("EPSG:4326","neu"),new tu("urn:ogc:def:crs:OGC:1.3:CRS84"),new tu("urn:ogc:def:crs:OGC:2:84"),new tu("http://www.opengis.net/def/crs/OGC/1.3/CRS84"),new tu("http://www.opengis.net/gml/srs/epsg.xml#4326","neu"),new tu("http://www.opengis.net/def/crs/EPSG/0/4326","neu")],WT={};function WY(e){return WT[e]||WT[e.replace(/urn:(x-)?ogc:def:crs:EPSG:(.*:)?(\w+)$/,"EPSG:$3")]||null}function HY(e,t){WT[e]=t}function dm(e){for(let t in e)delete e[t]}function wy(e){let t;for(t in e)return!1;return!t}var Kd={};function cm(e,t,i){let r=e.getCode(),s=t.getCode();r in Kd||(Kd[r]={}),Kd[r][s]=i}function HT(e,t){return e in Kd&&t in Kd[e]?Kd[e][t]:null}var Sy=.9996,_n=.00669438,Nk=_n*_n,Lk=Nk*_n,iu=_n/(1-_n),Pk=Math.sqrt(1-_n),Zd=(1-Pk)/(1+Pk),kk=Zd*Zd,qT=kk*Zd,XT=qT*Zd,Ik=XT*Zd,Fk=1-_n/4-3*Nk/64-5*Lk/256,qY=.002514607064228144,XY=26390466021299826e-22,YY=35*Lk/3072,KY=3/2*Zd-27/32*qT+269/512*Ik,ZY=21
2095/16*kk-55/32*XT,JY=151/96*qT-417/128*Ik,QY=1097/512*XT,My=6378137;function eK(e,t,i){let r=e-5e5,s=(i.north?t:t-1e7)/Sy/(My*Fk),n=s+KY*Math.sin(2*s)+ZY*Math.sin(4*s)+JY*Math.sin(6*s)+QY*Math.sin(8*s),a=Math.sin(n),o=a*a,l=Math.cos(n),h=a/l,u=h*h,d=u*u,c=1-_n*o,p=My/Math.sqrt(1-_n*o),m=(1-_n)/c,g=iu*l**2,f=g*g,y=r/(p*Sy),x=y*y,b=x*y,_=b*y,T=_*y,w=T*y,M=n-h/m*(x/2-_/24*(5+3*u+10*g-4*f-9*iu))+w/720*(61+90*u+298*g+45*d-252*iu-3*f),S=(y-b/6*(1+2*u+g)+T/120*(5-2*g+28*u-3*f+8*iu+24*d))/l;return S=jT(S+Rl(Bk(i.number)),-Math.PI,Math.PI),[Mk(S),Mk(M)]}var Dk=-80,Ok=84,tK=-180,iK=180;function rK(e,t,i){e=jT(e,tK,iK),t<Dk?t=Dk:t>Ok&&(t=Ok);let r=Rl(t),s=Math.sin(r),n=Math.cos(r),a=s/n,o=a*a,l=o*o,h=Rl(e),u=Rl(Bk(i.number)),d=My/Math.sqrt(1-_n*s**2),c=iu*n**2,p=n*jT(h-u,-Math.PI,Math.PI),m=p*p,g=m*p,f=g*p,y=f*p,x=y*p,b=My*(Fk*r-qY*Math.sin(2*r)+XY*Math.sin(4*r)-YY*Math.sin(6*r)),_=Sy*d*(p+g/6*(1-o+c)+y/120*(5-18*o+l+72*c-58*iu))+5e5,T=Sy*(b+d*a*(m/2+f/24*(5-o+9*c+4*c**2)+x/720*(61-58*o+l+600*c-330*iu)));return i.north||(T+=1e7),[_,T]}function Bk(e){return(e-1)*6-180+3}var sK=[/^EPSG:(\d+)$/,/^urn:ogc:def:crs:EPSG::(\d+)$/,/^http:\/\/www\.opengis\.net\/def\/crs\/EPSG\/0\/(\d+)$/];function Uk(e){let t=0;for(let s of sK){let n=e.match(s);if(n){t=parseInt(n[1]);break}}if(!t)return null;let i=0,r=!1;return t>32700&&t<32761?i=t-32700:t>32600&&t<32661&&(r=!0,i=t-32600),i?{number:i,north:r}:null}function Vk(e,t){return function(i,r,s,n){let a=i.length;s=s>1?s:2,n??=s,r||=s>2?i.slice():Array(a);for(let o=0;o<a;o+=n){let l=i[o],h=i[o+1],u=e(l,h,t);r[o]=u[0],r[o+1]=u[1]}return r}}function nK(e){return Uk(e)?new _y({code:e,units:"m"}):null}function aK(e){let t=Uk(e.getCode());return t?{forward:Vk(rK,t),inverse:Vk(eK,t)}:null}function zk(e,t,i){i||=63710088e-1;let r=Rl(e[1]),s=Rl(t[1]),n=(s-r)/2,a=Rl(t[0]-e[0])/2,o=Math.sin(n)*Math.sin(n)+Math.sin(a)*Math.sin(a)*Math.cos(r)*Math.cos(s);return 2*i*Math.atan2(Math.sqrt(o),Math.sqrt(1-o))}var oK=[aK],lK=[nK],YT=!0;function Gk(e){YT=!(e===void 0||e)}function KT(e,t){if(t!==void 0){for(let i=0,r=e.length;i<r;++i)t[i]=e[i];t=t}else t=e.slice();return t}function ZT(e){HY(e.getCode(),e),cm(e,e,KT)}function hK(e){e.forEach(ZT)}function Oi(e){if(typeof e!="string")return e;let t=WY(e);if(t)return t;for(let i of lK){let r=i(e);if(r)return r}return null}function jk(e,t,i,r){e=Oi(e);let s,n=e.getPointResolutionFunc();if(n){if(s=n(t,i),r&&r!==e.getUnits()){let a=e.getMetersPerUnit();a&&(s=s*a/hm[r])}}else{let a=e.getUnits();if(a=="degrees"&&!r||r=="degrees")s=t;else{let o=Cy(e,Oi("EPSG:4326"));if(!o&&a!=="degrees")s=t*e.getMetersPerUnit();else{let h=[i[0]-t/2,i[1],i[0]+t/2,i[1],i[0],i[1]-t/2,i[0],i[1]+t/2];h=o(h,h,2),s=(zk(h.slice(0,2),h.slice(2,4))+zk(h.slice(4,6),h.slice(6,8)))/2}let l=r?hm[r]:e.getMetersPerUnit();l!==void 0&&(s/=l)}}return s}function $k(e){hK(e),e.forEach(function(t){e.forEach(function(i){t!==i&&cm(t,i,KT)}
2095)})}function uK(e,t,i,r){e.forEach(function(s){t.forEach(function(n){cm(s,n,i),cm(n,s,r)})})}function JT(e,t){return e?typeof e=="string"?Oi(e):e:Oi(t)}function dK(e){return(function(t,i,r,s){let n=t.length;r=r===void 0?2:r,s??=r,i=i===void 0?Array(n):i;for(let a=0;a<n;a+=s){let o=e(t.slice(a,a+r)),l=o.length;for(let h=0,u=s;h<u;++h)i[a+h]=h>=l?t[a+h]:o[h]}return i})}function Jd(e,t){return Gk(),El(e,"EPSG:4326",t===void 0?"EPSG:3857":t)}function QT(e,t){let i=El(e,t===void 0?"EPSG:3857":t,"EPSG:4326"),r=i[0];return(r<-180||r>180)&&(i[0]=eu(r+180,360)-180),i}function As(e,t){if(e===t)return!0;let i=e.getUnits()===t.getUnits();return(e.getCode()===t.getCode()||Cy(e,t)===KT)&&i}function Cy(e,t){let i=e.getCode(),r=t.getCode(),s=HT(i,r);if(s)return s;let n=null,a=null;for(let l of oK)n||=l(e),a||=l(t);if(!n&&!a)return null;let o="EPSG:4326";if(a)if(n)s=ew(n.inverse,a.forward);else{let l=HT(i,o);l&&(s=ew(l,a.forward))}else{let l=HT(o,r);l&&(s=ew(n.inverse,l))}return s&&(ZT(e),ZT(t),cm(e,t,s)),s}function ew(e,t){return function(i,r,s,n){return r=e(i,r,s,n),t(r,r,s,n)}}function ru(e,t){return Cy(Oi(e),Oi(t))}function El(e,t,i){let r=ru(t,i);if(!r){let s=Oi(t).getCode(),n=Oi(i).getCode();throw Error(`No transform available between ${s} and ${n}`)}return r(e,void 0,e.length)}function Ns(e,t,i,r){return NY(e,ru(t,i),void 0,r)}var xa=null;function cK(e){xa=Oi(e)}function Wk(){return xa}function pK(){cK("EPSG:4326")}function tw(e,t){return xa?El(e,t,xa):e}function vo(e,t){return xa?El(e,xa,t):(YT&&!by(e,[0,0])&&e[0]>=-180&&e[0]<=180&&e[1]>=-90&&e[1]<=90&&(YT=!1,vk("Call useGeographic() from ol/proj once to work with [longitude, latitude] coordinates.")),e)}function Hk(e,t){return xa?Ns(e,t,xa):e}function su(e,t){return xa?Ns(e,xa,t):e}function mK(){$k(Rk),$k(Ak),uK(Ak,Rk,zY,GY)}mK();var Al=(e,t=100)=>{let i;return(...r)=>{clearTimeout(i),i=setTimeout(()=>e(...r),t)}};function ft(e,t,i,r,s){if(s){let a=i;i=function(o){return e.removeEventListener(t,i),a.call(r??this,o)}}else r&&r!==e&&(i=i.bind(r));let n={target:e,type:t,listener:i};return e.addEventListener(t,i),n}function Ry(e,t,i,r){return ft(e,t,i,r,!0)}function oi(e){e&&e.target&&(e.target.removeEventListener(e.type,e.listener),dm(e))}var De={CHANGE:"change",ERROR:"error",BLUR:"blur",CLEAR:"clear",CONTEXTMENU:"contextmenu",CLICK:"click",DBLCLICK:"dblclick",DRAGENTER:"dragenter",DRAGOVER:"dragover",DROP:"drop",FOCUS:"focus",KEYDOWN:"keydown",KEYPRESS:"keypress",LOAD:"load",RESIZE:"resize",TOUCHMOVE:"touchmove",WHEEL:"wheel"},Ey=class{constructor(){this.disposed=!1}dispose(){this.disposed||(this.disposed=!0,this.disposeInternal())}disposeInternal(){}};function gK(e,t,i){let r,s;i||=va;let n=0,a=e.length,o=!1;for(;n<a;)r=n+(a-n>>1),s=+i(e[r],t),s<0?n=r+1:(a=r,o=!s);return o?n:~n}function va(e,t){return e>t?1:e<t?-1:0}function fK(e,t){return e<t?1:e>t?-1:0}function iw(e,t,i){if(e[0]<=t)return 0;let r=e.length;if(t<=e[r-1])return r-1;if(typeof i=="function"){for(let s=1;s<r;++s){let n=e[s];if(n===t)return s;if(n<t)return i(t,e[s-1],n)>0?s-1:s}return r-1}if(i>0){for(let s=1;s<r;++s)if(e[s]<t)return s-1;return r-1}if(i<0){for(let s=1;s<r;++s)if(e[s]<=t)return s;return r-1}for(let s=1;s<r;++s){if(e[s]==t)return s;if(e[s]<t)return e[s-1]-t<t-e[s]?s-1:s}return r-1}function yK(e,t,i){for(;t<i;){let r=e[t];e[t]=e[i],e[i]=r,++t,--i}}function bo(e,t){let i=Array.isArray(t)?t:[t],r=i.length;for(let s=0;s<r;s++)e[e.length]=i[s]}function nu(e,t){let i=e.length;if(i!==t.length)return!1;for(let r=0;r<i;r++)if(e[r]!==t[r])return!1;return!0}function xK(e,t,i){let r=t||va;return e.every(function(s,n){if(n===0)return!0;let a=r(e[n-1],s);return!(a>0||i&&a===0)})}function Ay(){return!0}function Ny(){return!1}function Ly(){}function qk(e){let t,i,r;return function(){let s=Array.prototype.slice.call(arguments);return(!i||this!==r||!nu(s,i))&&(r=this,i=s,t=e.apply(this,arguments)),t}}function vK(e){function t(){let i;try{i=e()}catch(r){return Promise.reject(r)}return i instanceof Promise?i:Promise.resolve(i)}return t()}var Nl=class{constructor(e){this.propagationStopped,this.defaultPrevented,this.type=e,this.target=null}preventDefault(){this.defaultPrevented=!0}
2095stopPropagation(){this.propagationStopped=!0}},pm=class extends Ey{constructor(e){super(),this.eventTarget_=e,this.pendingRemovals_=null,this.dispatching_=null,this.listeners_=null}addEventListener(e,t){if(!e||!t)return;let i=this.listeners_||={},r=i[e]||(i[e]=[]);r.includes(t)||r.push(t)}dispatchEvent(e){let t=typeof e=="string",i=t?e:e.type,r=this.listeners_&&this.listeners_[i];if(!r)return;let s=t?new Nl(e):e;s.target||=this.eventTarget_||this;let n=this.dispatching_||={},a=this.pendingRemovals_||={};i in n||(n[i]=0,a[i]=0),++n[i];let o;for(let l=0,h=r.length;l<h;++l)if(o="handleEvent"in r[l]?r[l].handleEvent(s):r[l].call(this,s),o===!1||s.propagationStopped){o=!1;break}if(--n[i]===0){let l=a[i];for(delete a[i];l--;)this.removeEventListener(i,Ly);delete n[i]}return o}disposeInternal(){this.listeners_&&dm(this.listeners_)}getListeners(e){return this.listeners_&&this.listeners_[e]||void 0}hasListener(e){return this.listeners_?e?e in this.listeners_:Object.keys(this.listeners_).length>0:!1}removeEventListener(e,t){if(!this.listeners_)return;let i=this.listeners_[e];if(!i)return;let r=i.indexOf(t);r!==-1&&(this.pendingRemovals_&&e in this.pendingRemovals_?(i[r]=Ly,++this.pendingRemovals_[e]):(i.splice(r,1),i.length===0&&delete this.listeners_[e]))}},mm=class extends pm{constructor(){super(),this.on=this.onInternal,this.once=this.onceInternal,this.un=this.unInternal,this.revision_=0}changed(){++this.revision_,this.dispatchEvent(De.CHANGE)}getRevision(){return this.revision_}onInternal(e,t){if(Array.isArray(e)){let i=e.length,r=Array(i);for(let s=0;s<i;++s)r[s]=ft(this,e[s],t);return r}return ft(this,e,t)}onceInternal(e,t){let i;if(Array.isArray(e)){let r=e.length;i=Array(r);for(let s=0;s<r;++s)i[s]=Ry(this,e[s],t)}else i=Ry(this,e,t);return t.ol_key=i,i}unInternal(e,t){let i=t.ol_key;if(i)Qd(i);else if(Array.isArray(e))for(let r=0,s=e.length;r<s;++r)this.removeEventListener(e[r],t);else this.removeEventListener(e,t)}};mm.prototype.on,mm.prototype.once,mm.prototype.un;function Qd(e){if(Array.isArray(e))for(let t=0,i=e.length;t<i;++t)oi(e[t]);else oi(e)}var Xk=2114937,bK=3449312,rw=new Map;function Yk(e){return typeof e=="number"?`#${e.toString(16).padStart(6,"0")}`:typeof e=="string"&&e.startsWith("#")?e:`#${Xk.toString(16).padStart(6,"0")}`}function Kk(e=Xk){let t=typeof e=="number"?e:Yk(e);if(rw.has(t))return rw.get(t);let i=`<svg xmlns="http://www.w3.org/2000/svg" width="133.3" height="192" viewBox="0 0 133.3 192">
2096  <path fill="${Yk(e)}" d="M66.6,2.3C31.2,2.3,2.3,31.2,2.3,66.6c0,14.1,10.4,38.8,30.2,71.5c15.6,25.8,31.7,47.7,32.4,48.6l1.7,2.3l1.7-2.3c0.7-0.9,16.7-22.8,32.4-48.6c19.8-32.7,30.2-57.4,30.2-71.5C130.9,31.2,102.1,2.3,66.6,2.3z"/>
2097  <path fill="#FFFFFF" d="M66.6,4.7C32.5,4.7,4.7,32.5,4.7,66.6c0,9.5,5.2,29.5,29.9,70.3c14.9,24.6,30.2,45.7,32.1,48.2c1.9-2.5,17.2-23.6,32.1-48.2c24.7-40.8,29.9-60.7,29.9-70.3C128.6,32.5,100.8,4.7,66.6,4.7 M66.6,0c36.7,0,66.6,29.9,66.6,66.6c0,35.4-60.5,118-63,121.5l-2.4,3.3c-0.3,0.4-0.7,0.6-1.2,0.6c-0.5,0-0.9-0.2-1.2-0.6l-2.4-3.3C60.5,184.6,0,102,0,66.6C0,29.9,29.9,0,66.6,0z"/>
2098  <path fill="#FFFFFF" d="M105.9,60.8L89,77.3l3.8,23.9c0.2,1.3-0.3,2.6-1.4,3.4c-0.6,0.4-1.3,0.6-2,0.6c-0.5,0-1.1-0.1-1.6-0.4L66.6,93.7l-21.2,11.1c-1.2,0.6-2.6,0.5-3.6-0.3c-1.1-0.8-1.6-2.1-1.4-3.4l3.8-23.9L27.3,60.8c-0.9-0.9-1.3-2.3-0.9-3.5c0.4-1.2,1.5-2.2,2.8-2.4l23.5-3.8L63.5,30c0.6-1.2,1.8-1.9,3.2-1.9c1.3,0,2.5,0.8,3.1,2l9.7,21.1l24.6,3.8c1.3,0.2,2.4,1.1,2.8,2.4C107.2,58.5,106.9,59.9,105.9,60.8z"/>
2099</svg>`,r=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(i)}`;return rw.set(t,r),r}function Zk(e){return e.iconUrl?e.iconUrl:Kk(e.color??2114937)}var Jk=360,_K=6;function TK(e,t){if(e.type==="icon")return 1;if(e.type==="custom"&&window._customMarkersScaleWithZoom===!0){let i=t.getResolution(),r=t.getResolutionForZoom(_K);if(i&&r)return r/i}return 1}function wK(e){return`${e.lat}|${e.lon}|${e.className||""}`}var SK=class{constructor(){this.root=document.createElement("div"),this.root.className="mapjs-marker-overlay",Object.assign(this.root.style,{position:"absolute",top:"0",left:"0",width:"100%",height:"100%",pointerEvents:"none",overflow:"hidden",zIndex:"5"}),this.entries=new Map,this.viewport=null,this._postRenderKey=null,this._moveEndKey=null,this._resolutionKey=null,this._centerKey=null,this._map=null,this._opacity=1,this._getOpacity=null}mount(e){if(e&&(this.viewport||(this.viewport=e.getViewport(),this.viewport.style.position||="relative",this.viewport.appendChild(this.root)),this._map!==e)){this.unmountListeners(),this._map=e;let t=()=>{let i=typeof this._getOpacity=="function"?this._getOpacity():this._opacity;this.updatePositions(e,i)};this._postRenderKey=e.on("postrender",t),this._moveEndKey=e.on("moveend",t),this._resolutionKey=e.getView().on("change:resolution",t),this._centerKey=e.getView().on("change:center",t)}}unmountListeners(){this._postRenderKey&&=(Qd(this._postRenderKey),null),this._moveEndKey&&=(Qd(this._moveEndKey),null),this._resolutionKey&&=(Qd(this._resolutionKey),null),this._centerKey&&=(Qd(this._centerKey),null)}getMarkerZoomScale(e,t){return TK(e,t)}createElement(e){let t=e.iconSize||[25,36],i=e.iconAnchor||[12,34],[r,s]=t,[n,a]=i,o=document.createElement("div");
2099o.className=["mapjs-marker-position",e.className].filter(Boolean).join(" "),Object.assign(o.style,{position:"absolute",left:"0",top:"0",display:"none",pointerEvents:"none",willChange:"transform"});let l=document.createElement("img");return l.className="mapjs-marker-icon",l.draggable=!1,l.alt="",l.decoding="async",l.src=Zk(e),l.style.width=`${r}px`,l.style.height=`${s}px`,l.style.display="block",o.appendChild(l),{positionDiv:o,img:l,anchorX:n,anchorY:a,width:r,height:s}}updateEntry(e,t){t.marker=e;let i=e.iconSize||[25,36],r=e.iconAnchor||[12,34],[s,n]=i,[a,o]=r;t.anchorX=a,t.anchorY=o,t.width=s,t.height=n,t.img.style.width=`${s}px`,t.img.style.height=`${n}px`;let l=Zk(e);t.img.src!==l&&(t.img.src=l)}sync(e,t,i=1){if(!e)return;this.mount(e),this._opacity=i;let r=new Set;for(let s of t){let n=wK(s);if(r.add(n),this.entries.has(n))this.updateEntry(s,this.entries.get(n));else{let a=this.createElement(s);this.root.appendChild(a.positionDiv),this.entries.set(n,{marker:s,...a})}}for(let[s,n]of this.entries)r.has(s)||(n.positionDiv.remove(),this.entries.delete(s));this.updatePositions(e,i),e.render&&e.render()}updatePositions(e,t=1){if(!e||this.entries.size===0)return;this._opacity=t;let i=e.getView(),[r,s,n,a]=i.calculateExtent(e.getSize()),o=e.getSize();if(!o)return;let l=t>.001;for(let h of this.entries.values()){let{marker:u,positionDiv:d,anchorX:c,anchorY:p}=h;if(!l){d.style.display="none";continue}let m=this.getMarkerZoomScale(u,i),g=u.lon,f=u.lat;if(g+=Math.round((r-g)/Jk)*Jk,!(g>=r&&g<=n&&f>=s&&f<=a)){d.style.display="none";continue}let y=e.getPixelFromCoordinate([g,f]);if(!y){d.style.display="none";continue}let[x,b]=y;if(!(x>=0&&x<=o[0]&&b>=0&&b<=o[1])){d.style.display="none";continue}d.style.display="block",d.style.opacity=String(t),d.style.transform=`translate(${x}px, ${b}px) translate(${-c*m}px, ${-p*m}px) scale(${m})`}}dispose(){this.unmountListeners();for(let e of this.entries.values())e.positionDiv.remove();this.entries.clear(),this.root.parentNode&&this.root.parentNode.removeChild(this.root),this.viewport=null,this._map=null}},MK=class extends fa{constructor(){super(),this.name="markers",this.colorOptions.blur=0,this.minZoom=0,this.maxZoom=20,this.overrideRenderOrder=1e7,this.isObjectLayer=!0,this.directRender=!0,this.markers=[],this.textureLoader=new Wo,this.markerTexture="",this.baseSize={pin:6e4,star:{inner:45e3,outer:105e3},circle:{inner:54e3,outer:9e4,thickness:4500},icon:135e3},this.raycaster=new FU,this.mouse=new ge,this.textureCache=new Map,this._onZoomChange=null,this.domOverlay=new SK}isDomMarker(e){return e.type==="icon"||e.type==="custom"}getDomMarkers(){return this.markers.filter(e=>this.isDomMarker(e))}getGpuMarkers(){return this.markers.filter(e=>!this.isDomMarker(e))}syncDomMarkers(){let e=this.objectLayer?.master?.openLayerMap;if(!e){this.domOverlay.dispose();return}this.domOverlay._getOpacity=()=>{let t=this.objectLayer?.master;return t?.visible?t.opacity>.001?t.opacity:1:0},this.domOverlay.sync(e,this.getDomMarkers(),this.domOverlay._getOpacity())}clearTextureCache(){this.textureCache.clear()}getScaleFactor(){if(!this.objectLayer||!this.objectLayer.master||!this.objectLayer.master.openLayerMap)return 1;let e=this.objectLayer.master.openLayerMap.getView().getZoom(),t=Math.max(.01,5*.65**e),i={3:1.4,4:1.2,5:.8,6:.5,7:.3,8:.2,9:.08,10:.05,11:.03,12:.02,13:.008};function r(s){let n=Math.floor(s),a=Math.ceil(s);if(i[n]!==void 0&&i[a]!==void 0){let o=i[n],l=i[a],h=s-n;return o+(l-o)*h}return i[Math.round(s)]||1}return{base:t,icon:r(e)}}createPinGeometry(e=1){let t=this.baseSize.pin*e,i=t*.8,r=t*2.2,s=t*.4,n=s,a=r,o=-s,l=new Kg,h=Math.PI;Math.PI*3;let u=i*Math.cos(h),d=i*Math.sin(h)+a;l.moveTo(u,d);for(let p=0;p<=64;p++){let m=h+p/64*Math.PI*2,g=i*Math.cos(m),f=i*Math.sin(m)+a;l.lineTo(g,f)}l.lineTo(0,n),l.lineTo(i*1.01,a),l.lineTo(u,d),l.closePath();let c=new Dx(l);return c.translate(0,o,0),{pin:c}}createStarGeometry(e=1){let t=this.baseSize.star.inner*e,i=this.baseSize.star.outer*e,r=new Kg,s=Math.PI/5;for(let n=0;n<10;n++){let a=n%2==0?i:t,o=s*n-Math.PI/2,l=Math.cos(o)*a,h=Math.sin(o)*a;n===0?r.moveTo(l,h):r.lineTo(l,h)}return r.closePath(),new Dx(r)}createCircleGeometries(e=1){let t=this.baseSize.circle.inner*e,i=this.baseSize.circle.outer*e;return{outer:new W4(i-this.baseSize.circle.thickness*e,i,32),inner:new c4(t,32)}}createStarPinGeometry(e=1){let t=this.createPinGeometry(e),i=.38*e,r=this.createStarGeometry(i),s=this.baseSize.pin*e;return r.translate(0,s,0),{pin:t.pin,star:r}}disposeContainerMeshes(){let e=this.objectLayer?.container;if(e){for(let t of e.children){if(!t.isMesh)continue;t.geometry?.dispose();let i=t.material;
2099Array.isArray(i)?i.forEach(r=>r?.dispose()):i?.dispose()}e.clear()}}getMarkerScaleType(e){return e.type==="icon"||e.type==="custom"?"icon":"base"}tagMeshScale(e,t,i){let r=this.getMarkerScaleType(t);e.userData.markerScaleType=r,e.userData.markerScaleFactor=i[r],e.scale.set(1,1,1)}refreshMeshWorldBoundingBox(e){if(!e.geometry)return;e.geometry.computeBoundingBox();let t=e.geometry.boundingBox.clone();t.min.x*=e.scale.x,t.max.x*=e.scale.x,t.min.y*=e.scale.y,t.max.y*=e.scale.y,t.translate(e.position),e.userData.boundingBox=t}updateMarkerScales(){if(!this.objectLayer?.container?.children.length)return;let e=this.getScaleFactor();if(typeof e=="object"){for(let t of this.objectLayer.container.children){if(!t.isMesh)continue;let i=t.userData.markerScaleFactor;if(i==null)continue;let r=e[t.userData.markerScaleType||"icon"]/i;t.scale.set(r,r,1),this.refreshMeshWorldBoundingBox(t)}q.scheduleRender()}}async addMeshesForMarkers(e){if(!this.objectLayer||e.length===0)return;let t=e.filter(s=>!this.isDomMarker(s));if(t.length===0)return;let i=this.getScaleFactor(),r=typeof i=="object";for(let s of t){let n=Jd([s.lon,s.lat]),a=await this.createMarkerMesh(s,n);for(let o of a)r&&this.tagMeshScale(o,s,i),this.refreshMeshWorldBoundingBox(o),this.objectLayer.add(o,{noCopy:!0})}}async appendMarkers(e){await this.addMeshesForMarkers(e),this.syncDomMarkers(),q.scheduleRender()}async updateMarkers(){this.objectLayer&&(this.disposeContainerMeshes(),await this.addMeshesForMarkers(this.markers),this.syncDomMarkers(),q.scheduleRender())}async removeMarkersByType(e){let t=this.markers.length;this.markers=this.markers.filter(i=>i.type!==e),this.objectLayer&&this.markers.length<t&&await this.updateMarkers()}async removeMarkerById(e){let t=this.markers.length;this.markers=this.markers.filter(i=>i.id!==e),this.objectLayer&&this.markers.length<t&&await this.updateMarkers()}async createMarkerMesh(e,t,i=1){let r=this.getScaleFactor(),s,n;switch(e.type){case"pin":{let a=this.createPinGeometry(r.base),o=new ji({color:e.color||16711680,transparent:!0,depthTest:!1,opacity:1}),l=new ji({color:16711680,transparent:!0,depthTest:!1,opacity:1}),h=new xt(a.pin,o),u=new xt(a.ring,l);return h.position.set(t[0],t[1],0),u.position.set(t[0],t[1],0),h.renderOrder=this.overrideRenderOrder+1,u.renderOrder=this.overrideRenderOrder+2,[h,u]}case"starpin":{let a=this.createStarPinGeometry(r.base),o=new ji({color:e.color||3449312,transparent:!0,depthTest:!1,opacity:1}),l=new xt(a.pin,o);l.position.set(t[0],t[1],0),l.renderOrder=this.overrideRenderOrder+1;let h=new ji({color:16777215,transparent:!0,depthTest:!1,opacity:1}),u=new xt(a.star,h),d=this.baseSize.pin*r.base*.7;return u.position.set(t[0],t[1]+d,.1),u.renderOrder=this.overrideRenderOrder+2,[l,u]}case"star":{let a=r.base*1.15,o=new xt(this.createStarGeometry(a),new ji({color:e.borderColor||16777215,transparent:!0,depthTest:!1,opacity:1}));o.position.set(t[0],t[1],0),o.renderOrder=this.overrideRenderOrder+1;let l=new xt(this.createStarGeometry(r.base),new ji({color:e.color||16761856,transparent:!0,depthTest:!1,opacity:1}));return l.position.set(t[0],t[1],0),l.renderOrder=this.overrideRenderOrder+2,[o,l]}case"circle":{let a=this.createCircleGeometries(r.base),o=new ji({color:16777215,transparent:!0,depthTest:!1,opacity:1}),l=new xt(a.outer,o),h=new ji({color:e.color||255,transparent:!0,depthTest:!1,opacity:1}),u=new xt(a.inner,h);return l.position.set(t[0],t[1],0),u.position.set(t[0],t[1],0),l.renderOrder=this.overrideRenderOrder+1,u.renderOrder=this.overrideRenderOrder+2,[l,u]}case"custom":{let a,o,l=0,h=0;if(e.iconSize&&Array.isArray(e.iconSize)&&e.iconSize.length===2){let[c,p]=e.iconSize,m=window._markerPixelScale||3e3,g=m;if(window._customMarkersScaleWithZoom===!0&&(g=m*r.icon),a=c*g,o=p*g,e.iconAnchor&&Array.isArray(e.iconAnchor)&&e.iconAnchor.length===2){let[f,y]=e.iconAnchor;l=(c/2-f)*g,h=(p-y)*g}}else{let c=this.baseSize.icon*r.icon;a=c/1.4,o=c,h=o/2}let u;if(e.iconUrl){let c=`custom_${e.iconUrl}`;if(u=this.textureCache.get(c),u)(!u.image||u.image.width===0||u.image.height===0)&&(console.warn("LayerDataMarkers: Cached texture is invali
2099d, clearing cache and recreating"),this.textureCache.delete(c),u=null);else try{u=await this.loadCustomTexture(e.iconUrl),u&&u.image?this.textureCache.set(c,u):(console.warn("LayerDataMarkers: Custom texture creation failed, falling back to default"),u=null)}catch(p){console.warn("LayerDataMarkers: Error loading custom texture, falling back to default:",p),u=null}}if(!u){let c=e.color?`#${e.color.toString(16).padStart(6,"0")}`:"#204579",p=`default_${c}`;u=this.textureCache.get(p),u||(u=await this.loadMarkerTexture(c),this.textureCache.set(p,u))}if(!e.iconSize||!Array.isArray(e.iconSize)||e.iconSize.length!==2)if(u&&u.image){let c=u.image.width/u.image.height;a=size*c,o=size}else a=size/1.4,o=size;s=new Un(a,o),l!==0||h!==0?s.translate(l,h,0):s.translate(0,o/2,0),n=new ji({map:u,transparent:!0,opacity:1,depthTest:!1,side:2});let d=new xt(s,n);return d.position.set(t[0],t[1],0),d.renderOrder=this.overrideRenderOrder+1,[d]}default:{let a=this.baseSize.icon*r.icon,o;if(e.iconUrl){let d=`custom_${e.iconUrl}`;if(o=this.textureCache.get(d),o)(!o.image||o.image.width===0||o.image.height===0)&&(console.warn("LayerDataMarkers: Cached texture is invalid, clearing cache and recreating"),this.textureCache.delete(d),o=null);else try{o=await this.loadCustomTexture(e.iconUrl),o&&o.image?this.textureCache.set(d,o):(console.warn("LayerDataMarkers: Custom texture creation failed, falling back to default"),o=null)}catch(c){console.warn("LayerDataMarkers: Error loading custom texture, falling back to default:",c),o=null}}if(!o){let d=e.color?`#${e.color.toString(16).padStart(6,"0")}`:"#204579",c=`default_${d}`;o=this.textureCache.get(c),o||(o=await this.loadMarkerTexture(d),this.textureCache.set(c,o))}let l,h;o&&o.image?(l=a*(o.image.width/o.image.height),h=a):(l=a/1.4,h=a),s=new Un(l,h),s.translate(0,h/2,0),n=new ji({map:o,transparent:!0,opacity:1,depthTest:!1,side:2});let u=new xt(s,n);return u.position.set(t[0],t[1],0),u.renderOrder=this.overrideRenderOrder+1,[u]}}}loadMarkerTexture(e="#204579"){let t=`
2100<svg xmlns="http://www.w3.org/2000/svg" width="133.3" height="192" viewBox="0 0 133.3 192">
2101  <path fill="${e}" d="M66.6,2.3C31.2,2.3,2.3,31.2,2.3,66.6c0,14.1,10.4,38.8,30.2,71.5c15.6,25.8,31.7,47.7,32.4,48.6l1.7,2.3l1.7-2.3c0.7-0.9,16.7-22.8,32.4-48.6c19.8-32.7,30.2-57.4,30.2-71.5C130.9,31.2,102.1,2.3,66.6,2.3z"/>
2102  <path fill="#FFFFFF" d="M66.6,4.7C32.5,4.7,4.7,32.5,4.7,66.6c0,9.5,5.2,29.5,29.9,70.3c14.9,24.6,30.2,45.7,32.1,48.2c1.9-2.5,17.2-23.6,32.1-48.2c24.7-40.8,29.9-60.7,29.9-70.3C128.6,32.5,100.8,4.7,66.6,4.7 M66.6,0c36.7,0,66.6,29.9,66.6,66.6c0,35.4-60.5,118-63,121.5l-2.4,3.3c-0.3,0.4-0.7,0.6-1.2,0.6c-0.5,0-0.9-0.2-1.2-0.6l-2.4-3.3C60.5,184.6,0,102,0,66.6C0,29.9,29.9,0,66.6,0z"/>
2103  <path fill="#FFFFFF" d="M105.9,60.8L89,77.3l3.8,23.9c0.2,1.3-0.3,2.6-1.4,3.4c-0.6,0.4-1.3,0.6-2,0.6c-0.5,0-1.1-0.1-1.6-0.4L66.6,93.7l-21.2,11.1c-1.2,0.6-2.6,0.5-3.6-0.3c-1.1-0.8-1.6-2.1-1.4-3.4l3.8-23.9L27.3,60.8c-0.9-0.9-1.3-2.3-0.9-3.5c0.4-1.2,1.5-2.2,2.8-2.4l23.5-3.8L63.5,30c0.6-1.2,1.8-1.9,3.2-1.9c1.3,0,2.5,0.8,3.1,2l9.7,21.1l24.6,3.8c1.3,0.2,2.4,1.1,2.8,2.4C107.2,58.5,106.9,59.9,105.9,60.8z"/>
2104</svg>`,i=new Blob([t],{type:"image/svg+xml"}),r=URL.createObjectURL(i),s=new Image;return new Promise((n,a)=>{s.onload=()=>{let o=new Li(s);o.colorSpace=Gi,o.needsUpdate=!0,URL.revokeObjectURL(r),n(o)},s.onerror=o=>{console.error("Failed to load marker texture:",o),URL.revokeObjectURL(r),a(o)},s.src=r})}async loadCustomTexture(e){return new Promise((t,i)=>{let r=setTimeout(()=>{console.warn("Texture loading timeout, falling back to default:",e),t(null)},1e4);fetch(e,{mode:"cors",headers:{Accept:"image/svg+xml, image/*, */*"}}).then(s=>{if(!s.ok)throw Error(`HTTP ${s.status}: ${s.statusText}`);return s.text()}).then(s=>{let n=new Blob([s],{type:"image/svg+xml"}),a=URL.createObjectURL(n),o=new Image;o.crossOrigin="anonymous",o.onload=()=>{clearTimeout(r);try{if(!o.complete||o.naturalWidth===0||o.naturalHeight===0){console.warn("LayerDataMarkers: Invalid image dimensions, trying canvas method"),URL.revokeObjectURL(a),this.createTextureViaCanvas(o).then(t).catch(()=>{console.warn("LayerDataMarkers: Canvas method failed, trying WebGL fallback"),this.createWebGLTexture(o).then(t).cat
2104ch(()=>t(null))});return}this.createWebGPUCompatibleTexture(o,e).then(l=>{URL.revokeObjectURL(a),t(l)}).catch(()=>{URL.revokeObjectURL(a),t(null)})}catch(l){console.warn("LayerDataMarkers: Failed to create texture from fetched SVG, trying canvas method:",l),URL.revokeObjectURL(a),this.createTextureViaCanvas(o).then(t).catch(()=>{console.warn("LayerDataMarkers: Canvas method failed, trying WebGL fallback"),this.createWebGLTexture(o).then(t).catch(()=>t(null))})}},o.onerror=l=>{clearTimeout(r),console.warn("LayerDataMarkers: Failed to load image from fetched SVG:",l),URL.revokeObjectURL(a),t(null)},o.src=a}).catch(s=>{clearTimeout(r);let n=new Image;n.crossOrigin="anonymous",n.onload=()=>{try{if(!n.complete||n.naturalWidth===0||n.naturalHeight===0){console.warn("LayerDataMarkers: Invalid image dimensions from direct loading, trying canvas method"),this.createTextureViaCanvas(n).then(t).catch(()=>{console.warn("LayerDataMarkers: Canvas method failed, trying WebGL fallback"),this.createWebGLTexture(n).then(t).catch(()=>t(null))});return}this.createWebGPUCompatibleTexture(n,e).then(a=>{t(a)}).catch(()=>{t(null)})}catch{this.createTextureViaCanvas(n).then(t).catch(()=>{this.createWebGLTexture(n).then(t).catch(()=>t(null))})}},n.onerror=a=>{console.warn("LayerDataMarkers: Direct image loading also failed:",a),t(null)},n.src=e})})}async createTextureViaCanvas(e){return new Promise((t,i)=>{try{let r=document.createElement("canvas"),s=r.getContext("2d");r.width=e.naturalWidth||e.width,r.height=e.naturalHeight||e.height,s.drawImage(e,0,0);let n=new Li(r);
2104n.colorSpace=Gi,n.needsUpdate=!0,t(n)}catch(r){i(r)}})}async createWebGLTexture(e){return new Promise((t,i)=>{try{let r=document.createElement("canvas"),s=r.getContext("2d");r.width=e.naturalWidth||e.width,r.height=e.naturalHeight||e.height,s.drawImage(e,0,0);let n=new Li(r);n.colorSpace=Gi,n.needsUpdate=!0,n.isWebGLTexture=!0,t(n)}catch(r){i(r)}})}async createWebGPUCompatibleTexture(e,t){return new Promise((i,r)=>{try{if(this.isExternalTexture(t)){this.createWebGLTexture(e).then(i).catch(r);return}let s=new Li(e);s.colorSpace=Gi,s.needsUpdate=!0,this.isWebGPUAvailable()&&this.isTextureWebGPUCompatible(s)?i(s):this.createWebGLTexture(e).then(i).catch(r)}catch{this.createWebGLTexture(e).then(i).catch(r)}})}isWebGPUAvailable(){return typeof navigator<"u"&&navigator.gpu!==void 0}isTextureWebGPUCompatible(e){try{return e&&e.image&&e.image.width>0&&e.image.height>0}catch{return!1}}isExternalTexture(e){return e&&(e.startsWith("http://")||e.startsWith("https://")||e.startsWith("//"))}async init(e){Bi.value++,this.objectLayer=e,this.clearTextureCache(),this.markerTexture=await this.loadMarkerTexture();try{if(this.markers.length>0?await this.updateMarkers():(this.disposeContainerMeshes(),this.syncDomMarkers()),e.master&&e.master.openLayerMap){let t=e.master.openLayerMap.getView();this._onZoomChange=Al(()=>{this.updateMarkerScales();let i=e.master.openLayerMap,r=e.master?.opacity??1;typeof this.domOverlay._getOpacity=="function"?this.domOverlay.updatePositions(i,this.domOverlay._getOpacity()):this.domOverlay.updatePositions(i,r)},50),t.on("change:resolution",this._onZoomChange)}}finally{setTimeout(()=>{Bi.value--},32)}}getUrl=(e,t)=>
2104""},CK=class extends fa{constructor(){super(),this.baseUrl="https://a.basemaps.cartocdn.com/light_only_labels/",this.name="cities",this.directRender=!0,this.overrideRenderOrder=10000001,this.colorOptions.blur=0,this.zoomFactor=1,this.sizeFactor=1,this.imageFormat="png",this.colorOptions.srgb=!0,this.colorOptions.blending="substract"}getUrl=(e,t)=>Pu&&To.value?`${hi(this.baseUrl)}{z}%2F{x}%2F{y}${encodeURIComponent("."+this.imageFormat)}`:`${hi(this.baseUrl)}{z}/{x}/{y}.${this.imageFormat}`};function Qk(e,t,i=-.5,r=.001){let s=e.length/3;if(s<3)return e;let n=Math.max(0,Math.min(r,.5)),a=null,o=(h,u,d)=>{a&&a.push(h,u,d)},l=h=>{if(!a){a=[];for(let u=0;u<h*3;u++)a.push(e[u])}};for(let h=0;h<s;h++){let u=e[h*3],d=e[h*3+1],c=e[h*3+2];if(!t&&(h===0||h===s-1)){o(u,d,c);continue}let p=h===0?s-1:h-1,m=h===s-1?0:h+1,g=e[p*3],f=e[p*3+1],y=e[p*3+2],x=e[m*3],b=e[m*3+1],_=e[m*3+2],T=u-g,w=d-f,M=c-y,S=x-u,R=b-d,I=_-c,B=Math.hypot(T,w,M),O=Math.hypot(S,R,I);if(B<1e-6||O<1e-6){o(u,d,c);continue}if((T*S+w*R+M*I)/(B*O)>=i){o(u,d,c);continue}l(h),a.push(u+(g-u)*n,d+(f-d)*n,c+(y-c)*n,u+(x-u)*n,d+(b-d)*n,c+(_-c)*n)}return a?new Float32Array(a):e}var RK=class extends $r{constructor(e=null){super(),this.type="MeshLine",this.isMeshLine=!0,e&&this.buildLine(e)}buildLine(e={}){this.options={needsPositions:!0,needsPrevious:!0,needsNext:!0,needsUV:!1,needsSide:!0,needsProgress:!0,needsWidth:!1,needsVertexColor:!1,smoothSharpBends:!1,verbose:!1,...e},this.widthCallback=this.options.widthCallback||null,this._attrs={},this._lineCount=0,this._lines=[],this._lineLoops=[],this.boundingBoxes=[],this.options.lines&&this.setLines(this.options.lines)}setLines(e){if(!e)throw Error("[MeshLine] Lines data required");e=tI(e);let t=typeof this.options.closed=="boolean",i=this.options.closed,r=t?null:[],s=[],n=this.options.smoothSharpBends===!0&&!this.options.gpuPositionNode,a=this.options.smoothSharpBendsThreshold??-.5,o=this.options.smoothSharpBendsAlpha??.001;for(let l=0;l<e.length;l++){let h=e[l];if(!h||h.length===0)continue;let u=eI(h),d=(t?i:i?.[l]??!1)&&u.length>=9;if(n&&(u=Qk(u,d,a,o)),d){let c=new Float32Array(u.length+3);c.set(u),c[u.length]=u[0],c[u.length+1]=u[1],c[u.length+2]=u[2],u=c}s.push(u),t||r.push(d)}this._lines=s,this._lineLoops=t?i:r,this._isSingleLoopValue=t,this._lineCount=s.length,this.build()}setOrUpdateAttribute(e,t,i,r=dh){let s=this._attrs[e];if(s&&s.array.length===t.length)s.copyArray(t),s.needsUpdate=!0;else{s&&this.deleteAttribute(e);let n=new jr(t,i);n.setUsage(r),this._attrs[e]=n,this.setAttribute(e,n)}}setUsage(e,t=null){for(let[i,r]of Object.entries(this._attrs))(t==null||i===t)&&r.setUsage(e)}build(){let e=this._lines,t=this._lineLoops;if(!e||e.length===0)return;this._maxWidthMultiplier=1;let i=this.options.usage??(this.options.gpuPositionNode?35044:35040),r=0,s=0;for(let b of e){let _=b.length/3;_>=2&&(r+=_*2,s+=(_-1)*6)}if(r===0)return;let n,a,o,l,h,u,d,c;this.options.needsPositions&&(n=new Float32Array(r*3)),this.options.needsPrevious&&(a=new Float32Array(r*3)),this.options.needsNext&&(o=new Float32Array(r*3)),this.options.needsSide&&(l=new Float32Array(r)),this.options.needsWidth&&(h=new Float32Array(r)),this.options.needsUV&&(u=new Float32Array(r*2)),this.options.needsProgress&&(d=new Float32Array(r)),this.options.needsVertexColor&&this.options.vertexColors&&(c=new Float32Array(r*3));let p=new(r>65535?Uint32Array:Uint16Array)(s),m=0,g=0,f=0;for(let b=0;b<e.length;b++){let _=e[b],T=this._isSingleLoopValue?t:t[b],w=_.length/3;if(w<2)continue;let M=w>1?1/(w-1):0;for(let S=0;S<w;S++){let R=S*3,I=_[R],B=_[R+1],O=_[R+2],U=M*S;if(n&&(n[m*3]=I,n[m*3+1]=B,n[m*3+2]=O,n[m*3+3]=I,n[m*3+4]=B,n[m*3+5]=O),l&&(l[m]=1,l[m+1]=-1),h){let j=this.widthCallback?this.widthCallback(U):1;this._maxWidthMultiplier=Math.max(this._maxWidthMultiplier,Math.abs(j)),h[m]=j,h[m+1]=j}if(u&&(u[m*2]=U,u[m*2+1]=0,u[m*2+2]=U,u[m*2+3]=1),d&&(d[m]=U,d[m+1]=U),c&&this.options.vertexColors){let j=this.options.vertexColors;if((j instanceof Float32Array||Array.isArray(j)&&typeof j[0]=="number")&&j.length>S*3){let ae=S*3,W=m*3;c[W]=c[W+3]=j[ae],c[W+1]=c[W+4]=j[ae+1],c[W+2]=c[W+5]=j[ae+2]}}let V,z,Z;if(S===0)if(T){let j=(w-2)*3;V=_[j],z=_[j+1],Z=_[j+2]}else if(w>1){let j=_[3],ae=_[4],W=_[5];V=2*I-j,z=2*B-ae,Z=2*O-W}else V=I,z=B,Z=O;else{let j=(S-1)*3;V=_[j],z=_[j+1],Z=_[j+2]}if(a&&(a[m*3]=V,a[m*3+1]=z,a[m*3+2]=Z,a[m*3+3]=V,a[m*3+4]=z,a[m*3+5]=Z),o){let j,ae,W;if(S===w-1)if(T)j=_[3],ae=_[4],W=_[5];else if(w>1){let me=(w-2)*3,Ce=_[me],Qe=_[me+1],oe=_[me+2];
2104j=2*I-Ce,ae=2*B-Qe,W=2*O-oe}else j=I,ae=B,W=O;else{let me=(S+1)*3;j=_[me],ae=_[me+1],W=_[me+2]}o[m*3]=j,o[m*3+1]=ae,o[m*3+2]=W,o[m*3+3]=j,o[m*3+4]=ae,o[m*3+5]=W}m+=2}for(let S=0;S<w-1;S++){let R=f+S*2;p[g++]=R,p[g++]=R+1,p[g++]=R+2,p[g++]=R+2,p[g++]=R+1,p[g++]=R+3}f+=w*2}n&&this.setOrUpdateAttribute("position",n,3,i),a&&this.setOrUpdateAttribute("previous",a,3,i),o&&this.setOrUpdateAttribute("next",o,3,i),l&&this.setOrUpdateAttribute("side",l,1),h&&this.setOrUpdateAttribute("width",h,1),u&&this.setOrUpdateAttribute("uv",u,2),d&&this.setOrUpdateAttribute("progress",d,1),c&&this.setOrUpdateAttribute("vertexColor",c,3);let y=new jr(p,1),x=this.getIndex();if(x&&x.count===y.count?(x.copyArray(p),x.needsUpdate=!0):this.setIndex(y),this.options.frustumCulled===!1?(this.boundingBoxes=[],this.boundingBox=null,this.boundingSphere=null):(this.computeBoundingBoxes(),this.computeBoundingSphere()),this.options.verbose){let b=Object.keys(this._attrs);console.log(`[MeshLine] geometry built with attributes: ${b.join(", ")}`)}}computeBoundingBoxes(){if(!this._lines||this._lines.length===0)return;let e=this.getBoundingPadding();this.boundingBoxes=this._lines.map((t,i)=>{let r=(this.boundingBoxes[i]||new Fn).setFromArray(t);return e>0&&r.expandByScalar(e),r})}getBoundingPadding(){if(this.options?.sizeAttenuation===!1)return 0;let e=Number(this.options?.lineWidth??0);if(!Number.isFinite(e)||e<=0)return 0;let t=Number(this.options?.miterLimit??4),i=Number(this._maxWidthMultiplier??1);return e*Math.max(1,t)*.5*Math.max(1,i)}computeBoundingBox(){if(!(!this.boundingBoxes||this.boundingBoxes.length===0)){if(this.boundingBox||=new Fn,!this.boundingBoxes.length){this.boundingBox?.makeEmpty();return}this.boundingBox.copy(this.boundingBoxes[0]);for(let e=1;e<this.boundingBoxes.length;e++)this.boundingBox.union(this.boundingBoxes[e])}}computeBoundingSphere(){this.boundingBox||this.computeBoundingBox(),this.boundingSphere||=new ja,this.boundingBox?.getBoundingSphere(this.boundingSphere)}dispose(){this._attrs={},super.dispose()}setPositions(e,t=!1){if(!e)return;e=tI(e);let i=this.options.smoothSharpBends===!0&&!this.options.gpuPositionNode,r=this.options.smoothSharpBendsThreshold??-.5,s=this.options.smoothSharpBendsAlpha??.001,n=e.map((p,m)=>{let g=eI(p),f=this._isSingleLoopValue?this._lineLoops:this._lineLoops?.[m]??!1;if(i&&(g=Qk(g,f,r,s)),f&&g.length>=9){let y=new Float32Array(g.length+3);y.set(g),y[g.length]=g[0],y[g.length+1]=g[1],y[g.length+2]=g[2],g=y}return g});if(n.length!==this._lines.length){this.setLines(e);return}for(let p=0;p<n.length;p++)if(n[p].length!==this._lines[p].length){this.setLines(e);return}let a=this.getAttribute("position");if(!a){this.setLines(n);return}let o=this.getAttribute("previous"),l=this.getAttribute("next"),h=a.array,u=o?o.array:null,d=l?l.array:null,c=0;for(let p=0;p<n.length;p++){let m=n[p],g=this._isSingleLoopValue?this._lineLoops:this._lineLoops[p],f=m.length/3;for(let y=0;y<f;y++){let x=y*3,b=m[x],_=m[x+1],T=m[x+2];if(this.writePair(h,c,b,_,T),u){let w,M,S;if(y===0)if(g){let R=(f-2)*3;w=m[R],M=m[R+1],S=m[R+2]}else if(f>1){let R=m[3],I=m[4],B=m[5];w=2*b-R,M=2*_-I,S=2*T-B}else w=b,M=_,S=T;else{let R=(y-1)*3;w=m[R],M=m[R+1],S=m[R+2]}this.writePair(u,c,w,M,S)}if(d){let w,M,S;if(y===f-1)if(g)w=m[3],M=m[4],S=m[5];else if(f>1){let R=(f-2)*3,I=m[R],B=m[R+1],O=m[R+2];w=2*b-I,M=2*_-B,S=2*T-O}else w=b,M=_,S=T;else{let R=(y+1)*3;w=m[R],M=m[R+1],S=m[R+2]}this.writePair(d,c,w,M,S)}c+=2}}a.needsUpdate=!0,o&&(o.needsUpdate=!0),l&&(l.needsUpdate=!0),this._lines=n,t&&(this.computeBoundingBoxes(),this.computeBoundingBox(),this.computeBoundingSphere())}writePair=(e,t,i,r,s)=>{let n=t*3;e[n]=i,e[n+1]=r,e[n+2]=s,e[n+3]=i,e[n+4]=r,e[n+5]=s}},EK=!1,eI=e=>{if(e instanceof Float32Array)return e;if(e instanceof $r)return e.getAttribute("position").array;if(EK||=(console.warn("[MeshLine] Use Float32Array for positions to avoid array conversion & get optimal performance"),!0),Array.isArray(e)&&typeof e[0]=="number")return new Float32Array(e);let t=new Float32Array(e.length*3),i=0;for(let r=0;r<e.length;r++){let s=e[r];s instanceof F?(t[i++]=s.x,t[i++]=s.y,t[i++]=s.z):s instanceof ge?(t[i++]=s.x,t[i++]=s.y,t[i++]=0):Array.isArray(s)?(t[i++]=s[0]??0,t[i++]=s[1]??
21040,t[i++]=s[2]??0):s&&typeof s=="object"&&typeof s.x=="number"&&typeof s.y=="number"?(t[i++]=s.x,t[i++]=s.y,t[i++]=s.z??0):console.warn(`[MeshLine] Invalid point: ${s}`)}return i===t.length?t:t.subarray(0,i)},AK=e=>Array.isArray(e)&&typeof e[0]=="number"&&typeof e[1]=="number"&&e.length<=4,NK=e=>e instanceof F||e instanceof ge||e&&typeof e=="object"&&typeof e.x=="number"&&typeof e.y=="number",LK=e=>{if(!Array.isArray(e))return!1;if(e.length===0)return!0;let t=e[0];return typeof t=="number"||AK(t)||NK(t)},tI=e=>e instanceof Float32Array||e instanceof $r||LK(e)?[e]:e,sw=Vt(([e,t])=>{let i=Be(t).toVar(),r=ai(e).toVar(),s=Je(r.xy.div(r.w)).toVar("ndc");return Je(s.x.mul(i),s.y).toVar("res")}).setLayout({name:"fix",type:"vec2",inputs:[{name:"i",type:"vec4"},{name:"aspect",type:"float"}]}),nw=xl("side","float"),aw=xl("progress","float"),PK=xl("vertexColor","vec3"),kK=xl("width","float"),IK=B_("float","vWidth"),_o=B_("float","vProgress"),iI=B_("vec4","vColor"),FK=class extends Qn{constructor(e=null){super(),this.type="MeshLineNodeMaterial",this.isMeshLineNodeMaterial=!0,e&&this.buildLine(e)}buildLine(e={}){this.options={...e},this._segments=e.segments??100,this._needsWidth=e.needsWidth??!1,this.gradient=null,this.opacity=null,this.map=null,this.alphaMap=null,this.mapOffset=null,this.repeat=null,this.dashCount=null,this.dashRatio=null,this.dashOffset=null,this.depthWrite=e.depthWrite??!0,this.depthTest=e.depthTest??!0,this.wireframe=e.wireframe??!1,this.alphaTest=e.alphaTest??0,this.sizeAttenuation=e.sizeAttenuation??!0,this.resolution=Le(e.resolution??new ge(1,1)),this.lineWidth=Le(e.lineWidth??1),this.color=Le(new Ke(e.color??16777215)),this.dpr=Le(e.dpr??(typeof window<"u"&&window.devicePixelRatio||1)),e.gradientColor!=null&&(this.gradient=Le(new Ke(e.gradientColor)));let t=e.alphaMap!=null||(e.opacity??1)<1;this.transparent=t||(e.transparent??!1),this.transparent&&(this.opacity=Le(e.opacity??1)),e.map&&(this.map=Fi(e.map)),e.alphaMap&&(this.alphaMap=Fi(e.alphaMap)),(e.map||e.alphaMap)&&(this.mapOffset=Le(e.mapOffset??new ge(0,0)),this.repeat=Le(e.repeat??new ge(1,1))),e.dashCount&&(this.dashCount=Le(e.dashCount),this.dashRatio=Le(e.dashRatio??e.dashLength??.5),this.dashOffset=Le(e.dashOffset??0)),this._miterLimit=e.miterLimit??4,this._miterThreshold=Le(2/this._miterLimit),this.gpuPositionNode=e.gpuPositionNode??null,this.depthWrite=e.depthWrite??!this.transparent,this.positionFn=e.positionFn??null,this.previousFn=e.previousFn??null,this.nextFn=e.nextFn??null,this.widthFn=e.widthFn??null,this.normalFn=e.normalFn??null,this.colorFn=e.colorFn??null,this.gradientFn=e.gradientFn??null,this.opacityFn=e.opacityFn??null,this.dashFn=e.dashFn??null,this.uvFn=e.uvFn??null,this.vertexFn=e.vertexFn??null,this.fragmentColorFn=e.fragmentColorFn??null,this.fragmentAlphaFn=e.fragmentAlphaFn??null,this.discardFn=e.discardFn??null,this.needsUpdate=!0}dispose(){super.dispose()}get miterLimit(){return this._miterLimit}set miterLimit(e){this._miterLimit=e,this._miterThreshold&&(this._miterThreshold.value=2/e)}setShadow(e){e!==this._shadowEnabled&&(this._shadowEnabled=e,e?(this.shadowSide=2,this.buildShadowPositionNode()):(this.castShadowPositionNode=null,this.maskShadowNode=null,this.shadowNode=null,this.shadowSide=null),this.needsUpdate=!0)}getLinePositions(e){let t=this.gpuPositionNode?this.gpuPositionNode(e,Be(0)):V0,i=this.gpuPositionNode?this.gpuPositionNode(e.sub(1/this._segments),Be(0)):xl("previous","vec3"),r=this.gpuPositionNode?this.gpuPositionNode(e.add(1/this._segments),Be(0)):xl("next","vec3");return this.positionFn&&(t=this.positionFn(t,e),i=this.positionFn(i,e),r=this.positionFn(r,e)),this.previousFn&&(i=this.previousFn(i,e)),this.nextFn&&(r=this.nextFn(r,e)),{pos:t,previous:i,next:r}}getLineWidth(e,t,i){return this._needsWidth&&(e=e.mul(kK)),this.widthFn&&(e=this.widthFn(e,t,i)),e}buildShadowPositionNode(){this.castShadowPositionNode=Vt(()=>{let e=aw,t=nw,{pos:i,previous:r,next:s}=this.getLinePositions(e),n=B0.mul(ai(i,1)).xyz,a=B0.mul(ai(r,1)).xyz,o=B0.mul(ai(s,1)).xyz,l=U0(n.sub(a)),h=U0(o.sub(n)),u=U0(l.add(h)),d=U0(fn(u.y.negate(),u.x,0)),c=this.getLineWidth(this.lineWidth.mul(.5),e,t),p=n.add(d.mul(t.mul(c))),m=vH.mul(ai(p,1));return TH.mul(m).xyz})(),this.maskShadowNode=null,this.dashCount&&(this.maskShadowNode=Vt(()=>{let e=C3(aw),t=S3(e.mul(this.dashCount).add(this.dashOffset),Be(1)).toVar("cyclePosition");return this.dashFn&&t.assign(this.dashFn(t,e,C3(nw))),Ks(t,this.dashRatio).greaterThan(.001)})())}setup(e){this.setupShaders(e),super.setup(e)}setupShaders({}){let e=aw.toVar("varProgress"),t=nw.toVar("varSide"),{pos:i,previous:r,next:s}=this.getLinePositions(e);this.vertexNode=Vt(()=>{let a=ai(this.color,1).toVar("color");this.options.needsVertexColor&&a.rgb.mulAssign(PK),this.colorFn&&a.assign(this.colorFn(a,e,t)),iI.assign(a),(this.gradient||this.dashCount||this.gradientFn||this.opacityFn||this.dashFn||this.uvFn||this.fragmentColorFn||this.fragmentAlphaFn||this.discardFn)&&_o.assign(e);let o=this.resolution.x.div(this.resolution.y).toVar("aspect"),l=T3.mul(B0).toVar("mvpMatrix"),h=l.mul(ai(i,1)).toVar("finalPosition"),u=l.mul(ai(r,1)).toVar("prevPos"),d=l.mul(ai(s,1)).toVar("nextPos"),c=sw(h,o).toVar("currentP"),p=sw(u,o).toVar("prevP"),m=sw(d,o).toVar("nextP"),g=c.sub(p).toVar("delta1Raw"),f=m.sub(c).toVar("delta2Raw"),y=Be(1).sub(Ks(Be(1e-4),e)).toVar("atStart"),x=Ks(Be(.9999),e).toVar("atEnd"),b=no(g,f,y).toVar("delta1"),_=no(f,g,x).toVar("delta2"),T=this.getLineWidth(this.lineWidth,e,t).toVar("w");IK.assign(T);let w=Be(1e-4),M=b.length().toVar("delta1Len"),S=_.length().toVar("delta2Len"),R=Je(1,0).toVar("dirFallback"),I=b.div(kd(M,w)).toVar("dir1Raw"),B=_.div(kd(S,w)).toVar("dir2Raw"),O=no(no(R,B,Ks(w,S)),I,Ks(w,M)).toVar("dir1"),U=no(O,B,Ks(w,S)).toVar("dir2"),V=O.add(U).toVar("dirSum"),z=V.length().toVar("dirSumLen"),Z=Je(V.y.negate(),V.x).toVar("perpRaw"),j=no(Je(O.y.negate(),O.x).toVar("perpFallback"),Z.div(kd(z,Be(1e-4))),Ks(Be(.001),z)).toVar("unitPerp"),ae=T.div(kd(z,this._miterThreshold)).toVar("miterHalfWidth"),W=ai(0,0,0,1).toVar("normal");if(W.xy.assign(j.mul(ae)),this.normalFn){let me=Je(j.y,j.x.negate()).toVar("dir");W.assign(this.normalFn(W,me,O,U,e,t))}return this.sizeAttenuation?W.xy.assign(T3.mul(ai(W.xy,0,0)).xy):(W.x.divAssign(o),W.xy.mulAssign(h.w.mul(2).div(this.resolution.y))),h.xy.addAssign(W.xy.mul(t)),this.vertexFn&&h.assign(this.vertexFn(h,W,e,t)),h})();let n;(this.map&&this.map.value||this.alphaMap&&this.alphaMap.value||this.uvFn||this.fragmentColorFn||this.fragmentAlphaFn||this.discardFn)&&(n=la().mul(this.repeat||Je(1,1)).add(this.mapOffset||Je(0,0)).toVar("uvCoords"),this.uvFn&&(n=this.uvFn(n,_o,t))),this.colorNode=Vt(()=>{let a=iI.toVar("color");
2104if(this.gradient){let o=_o.toVar("gradientFactor");this.gradientFn&&o.assign(this.gradientFn(o,t)),a.rgb.assign(no(a.rgb,this.gradient,o))}return this.map&&this.map.value&&a.mulAssign(this.map.sample(n)),this.fragmentColorFn&&a.assign(this.fragmentColorFn(a,n,_o,t)),a})(),this.opacityNode=Vt(()=>{let a=Be(1).toVar("alpha");if(this.alphaMap&&this.alphaMap.value&&a.mulAssign(this.alphaMap.sample(n).r),this.opacity&&a.mulAssign(this.opacity),this.opacityFn&&a.assign(this.opacityFn(a,_o,t)),oa(a.lessThan(this.alphaTest)),this.dashCount){let o=S3(_o.mul(this.dashCount).add(this.dashOffset),Be(1)).toVar("cyclePosition");this.dashFn&&o.assign(this.dashFn(o,_o,t)),oa(Ks(o,this.dashRatio).lessThan(.001))}return this.discardFn&&oa(this.discardFn(_o,t,n)),this.fragmentAlphaFn&&a.assign(this.fragmentAlphaFn(a,n,_o,t)),a})()}copy(e){return super.copy(e),e.options&&this.buildLine({...e.options}),this.transparent=e.transparent,this.depthWrite=e.depthWrite,this.depthTest=e.depthTest,this.wireframe=e.wireframe,this.alphaTest=e.alphaTest,this.sizeAttenuation=e.sizeAttenuation,e.lineWidth&&this.lineWidth&&(this.lineWidth.value=e.lineWidth.value),e.opacity&&this.opacity&&(this.opacity.value=e.opacity.value),e.map&&this.map&&(this.map.value=e.map.value),e.alphaMap&&this.alphaMap&&(this.alphaMap.value=e.alphaMap.value),e.gradient&&this.gradient&&this.gradient.value.copy(e.gradient.value),e.dashCount&&this.dashCount&&(this.dashCount.value=e.dashCount.value),e.dashRatio&&this.dashRatio&&(this.dashRatio.value=e.dashRatio.value),e.dashOffset&&this.dashOffset&&(this.dashOffset.value=e.dashOffset.value),e._miterLimit!==void 0&&this._miterThreshold&&(this.miterLimit=e._miterLimit),e.color&&this.color&&this.color.value.copy(e.color.value),e.resolution&&this.resolution&&this.resolution.value.copy(e.resolution.value),e.repeat&&this.repeat&&this.repeat.value.copy(e.repeat.value),e.mapOffset&&this.mapOffset&&this.mapOffset.value.copy(e.mapOffset.value),e.dpr&&this.dpr&&(this.dpr.value=e.dpr.value),this.positionFn=e.positionFn,this.previousFn=e.previousFn,this.nextFn=e.nextFn,this.widthFn=e.widthFn,this.normalFn=e.normalFn,this.colorFn=e.colorFn,this.gradientFn=e.gradientFn,this.opacityFn=e.opacityFn,this.dashFn=e.dashFn,this.uvFn=e.uvFn,this.vertexFn=e.vertexFn,this.fragmentColorFn=e.fragmentColorFn,this.fragmentAlphaFn=e.fragmentAlphaFn,this.discardFn=e.discardFn,this.gpuPositionNode=e.gpuPositionNode,this}static get type(){return"MeshLineNodeMaterial"}};function rI(e=1,t=2,i=!1){let r=new Float32Array((t+1)*3);for(let s=0;s<=t;s++){let n=s/t,a=s*3;r[a]=i?0:n*e,r[a+1]=i?n*e:0,r[a+2]=0}return r}var sI=new $e,ow=new bx,Py=new ja,ky=new F,Iy=new F,Fy=new F,lw=new F,Dy=typeof window<"u",DK=()=>Dy&&window.devicePixelRatio||1,nI=()=>Dy?window.innerWidth:1024,aI=()=>Dy?window.innerHeight:768,OK=rI(2),Ll=class extends xt{constructor(e={}){super(new RK,new FK),this._options={segments:1,closed:!1,color:16777215,lineWidth:.3,widthCallback:null,sizeAttenuation:!0,opacity:1,alphaTest:0,transparent:!1,wireframe:!1,gradientColor:null,map:null,mapOffset:null,alphaMap:null,vertexColors:null,dashCount:null,dashRatio:null,dashOffset:0,dpr:DK(),frustumCulled:!0,verbose:!1,renderWidth:nI(),renderHeight:aI(),gpuPositionNode:null,usage:null,instanceCount:-1,shadow:!1,smoothSharpBends:!1},this._built=!1,this.onBeforeRender=this._onBeforeRender,this.configure(e??{})}configure(e={}){if(e??={},e.segments!==void 0&&this.segments(e.segments),e.lines!==void 0||e.closed!==void 0){let t=e.lines??this._options.lines,i=e.closed??this._options.closed;this.lines(t,i)}return e.vertexColors!==void 0&&this.vertexColors(e.vertexColors),e.color!==void 0&&this.color(e.color),e.lineWidth!==void 0&&this.lineWidth(e.lineWidth),e.widthCallback!==void 0&&this.widthCallback(e.widthCallback),e.sizeAttenuation!==void 0&&this.sizeAttenuation(e.sizeAttenuation),e.gradientColor!==void 0&&this.gradientColor(e.gradientColor),e.map!==void 0&&this.map(e.map),e.mapOffset!==void 0&&this.mapOffset(e.mapOffset),e.alphaMap!==void 0&&this.alphaMap(e.alphaMap),e.opacity!==void 0&&this.opacity(e.opacity),e.alphaTest!==void 0&&this.alphaTest(e.alphaTest),e.transparent!==void 0&&this.transparent
2104(e.transparent),e.wireframe!==void 0&&this.wireframe(e.wireframe),e.shadow!==void 0&&this.shadow(e.shadow),e.dpr!==void 0&&this.dpr(e.dpr),e.frustumCulled!==void 0&&this.setFrustumCulled(e.frustumCulled),e.verbose!==void 0&&this.verbose(e.verbose),(e.renderWidth!==void 0||e.renderHeight!==void 0)&&this.renderSize(e.renderWidth,e.renderHeight),(e.dash||e.dashCount!==void 0||e.dashRatio!==void 0||e.dashOffset!==void 0)&&this.dash(e.dash??{count:e.dashCount??this._options.dashCount,ratio:e.dashRatio??this._options.dashRatio??.5,offset:e.dashOffset??this._options.dashOffset}),e.join&&this.join(e.join),e.smoothSharpBends!==void 0&&this.smoothSharpBends(e.smoothSharpBends),e.smoothSharpBendsAlpha!==void 0&&this.smoothSharpBendsAlpha(e.smoothSharpBendsAlpha),e.smoothSharpBendsThreshold!==void 0&&this.smoothSharpBendsThreshold(e.smoothSharpBendsThreshold),e.dynamic!==void 0&&this.dynamic(e.dynamic),e.autoResize&&this.autoResize(e.autoResize),e.gpuPositionNode!==void 0&&this.gpuPositionNode(e.gpuPositionNode),e.usage!==void 0&&this.usage(e.usage),e.instanceCount!==void 0&&this.instances(e.instanceCount),e.needsUV!==void 0&&this.needsUV(e.needsUV),e.needsWidth!==void 0&&this.needsWidth(e.needsWidth),e.needsProgress!==void 0&&this.needsProgress(e.needsProgress),e.needsPrevious!==void 0&&this.needsPrevious(e.needsPrevious),e.needsNext!==void 0&&this.needsNext(e.needsNext),e.needsSide!==void 0&&this.needsSide(e.needsSide),e.needsVertexColor!==void 0&&this.needsVertexColor(e.needsVertexColor),e.positionFn!==void 0&&this.positionFn(e.positionFn),e.previousFn!==void 0&&this.previousFn(e.previousFn),e.nextFn!==void 0&&this.nextFn(e.nextFn),e.widthFn!==void 0&&this.widthFn(e.widthFn),e.normalFn!==void 0&&this.normalFn(e.normalFn),e.colorFn!==void 0&&this.colorFn(e.colorFn),e.gradientFn!==void 0&&this.gradientFn(e.gradientFn),e.opacityFn!==void 0&&this.opacityFn(e.opacityFn),e.dashFn!==void 0&&this.dashFn(e.dashFn),e.uvFn!==void 0&&this.uvFn(e.uvFn),e.vertexFn!==void 0&&this.vertexFn(e.vertexFn),e.fragmentColorFn!==void 0&&this.fragmentColorFn(e.fragmentColorFn),e.fragmentAlphaFn!==void 0&&this.fragmentAlphaFn(e.fragmentAlphaFn),e.discardFn!==void 0&&this.discardFn(e.discardFn),this}lines(e,t=this._options.closed){let i=t!==this._options.closed;return this._options.lines=e,this._options.closed=t,this._built&&(this.geometry.options.closed=t,i?this.geometry.setLines(e):this.geometry.setPositions(e,!1)),this}segments(e){return this._options.segments=e,this}closed(e){return this._options.closed=e,this}color(e){return this._options.color=e,this.material.color?.value?.set&&this.material.color.value.set(e),this}lineWidth(e){return this._options.lineWidth=e,this.material.lineWidth&&(this.material.lineWidth.value=e),this}widthCallback(e){return this._options.widthCallback=e,this}sizeAttenuation(e){return this._options.sizeAttenuation=e,this}shadow(e){return this._options.shadow=e,this._built&&this.material&&this.material.setShadow(e),this.castShadow=!!e,this}opacity(e){this._options.opacity=e;let t=this.material.opacity;return t&&typeof t=="object"&&"value"in t?this.material.opacity.value=e:this._built&&e<1&&this.rebuild(),this}alphaTest(e){return this._options.alphaTest=e,this.material.alphaTest=e,this}
2104transparent(e){return this._options.transparent=e,this.material.transparent=e,this}wireframe(e){return this._options.wireframe=e,this.material.wireframe=e,this}join({type:e="miter",limit:t=4}={}){return this._options.miterLimit=t,this._built&&this.material&&(this.material.miterLimit=t),this}smoothSharpBends(e){return this._options.smoothSharpBends=e,this._built&&(this.geometry.options.smoothSharpBends=e,this._options.lines&&this.geometry.setLines(this._options.lines)),this}smoothSharpBendsAlpha(e){return this._options.smoothSharpBendsAlpha=e,this._built&&(this.geometry.options.smoothSharpBendsAlpha=e,this._options.lines&&this.geometry.setLines(this._options.lines)),this}smoothSharpBendsThreshold(e){return this._options.smoothSharpBendsThreshold=e,this._built&&(this.geometry.options.smoothSharpBendsThreshold=e,this._options.lines&&this.geometry.setLines(this._options.lines)),this}gradientColor(e){let t=!!this.material.gradient;return this._options.gradientColor=e,this._built&&t!==(e!=null)?this.rebuild():(this.material.gradient&&this.material.gradient.value.set(e),this)}map(e){let t=!!this.material.map;return this._options.map=e,this._built&&t!==!!e?this.rebuild():(this.material.map&&(this.material.map.value=e),this)}mapOffset(e){return this._options.mapOffset=e,this.material.mapOffset&&(e?this.material.mapOffset.value.copy(e):this.material.mapOffset.value.set(0,0)),this}alphaMap(e){let t=!!this.material.alphaMap;return this._options.alphaMap=e,this._built&&t!==!!e?this.rebuild():(this.material.alphaMap&&(this.material.alphaMap.value=e),this)}dash(e){let{count:t,ratio:i=.5,offset:r=0}=e||{},s=!!this.material.dashCount;return this._options.dashCount=t,this._options.dashRatio=i,this._options.dashOffset=r,this._built&&s!==!!t?this.rebuild():(this._built&&this.material.dashCount&&(this.material.dashCount.value=t,this.material.dashRatio.value=i,this.material.dashOffset.value=r),this)}dpr(e){return this._options.dpr=e,this.material.dpr&&(this.material.dpr.value=e),this}dynamic(e){return this._options.usage=e?xB:dh,this._built&&this.geometry?.setUsage&&this.geometry.setUsage(this._options.usage),this}setFrustumCulled(e){return this._options.frustumCulled=e,this.frustumCulled=e,this}verbose(e){return this._options.verbose=e,this}renderSize(e,t){return this._options.renderWidth=e,this._options.renderHeight=t,this}gpuPositionNode(e){return this._options.gpuPositionNode=e,this}usage(e){return this._options.usage=e,this}instances(e){return this._options.instanceCount=e,this._warnIfBuilt("instance count"),this}needsUV(e){return this._options.needsUV=e,this._warnIfBuilt("UV needs"),this}needsWidth(e){return this._options.needsWidth=e,this._warnIfBuilt("width needs"),this}needsProgress(e){return this._options.needsProgress=e,this._warnIfBuilt("progress needs"),this}needsPrevious(e){return this._options.needsPrevious=e,this._warnIfBuilt("previous needs"),this}needsNext(e){return this._options.needsNext=e,this._warnIfBuilt("next needs"),this}needsSide(e){return this._options.needsSide=e,this._warnIfBuilt("side needs"),this}needsVertexColor(e){return this._options.needsVertexColor=e,this._warnIfBuilt("color needs"),this}positionFn(e){return this._options.positionFn=e,this._built=!1,this}previousFn(e){return this._options.previousFn=e,this._built=!1,this}nextFn(e){return this._options.nextFn=e,this._built=!1,this}widthFn(e){return this._options.widthFn=e,this._built=!1,this}normalFn(e){return this._options.normalFn=e,this._built=!1,this}colorFn(e){return this._options.colorFn=e,this._built=!1,this}gradientFn(e){return this._options.gradientFn=e,this._built=!1,this}opacityFn(e){return this._options.opacityFn=e,this._built=!1,this}dashFn(e){return this._options.dashFn=e,this._built=!1,this}uvFn(e){return this._options.uvFn=e,this._built=!1,this}vertexFn(e){return this._options.vertexFn=e,this._built=!1,this}fragmentColorFn(e){return this._options.fragmentColorFn=e,this._built=!1,this}fragmentAlphaFn(e){return this._options.fragmentAlphaFn=e,this._built=!1,this}discardFn(e){return this._options.discardFn=e,this._built=!1,this}vertexColors(e){return this._options.vertexColors=e,this}build(){let e=this._options;e.lines=e.lines??(e.segments?rI(1,e.segments):OK);let t={...e,needsWidth:!!(e.needsWidth||e.widthCallback),needsProgress:e.needsProgress??!0,needsSide:e.needsSide??!0,needsUV:!!(e.needsUV||e.map||e.alphaMap||e.uvFn||e.fragmentColorFn||e.fragmentAlphaFn||e.discardFn),needsVertexColor:!!(e.needsVertexColor||e.vertexColors),needsPrevious:e.needsPrevious??!e.gpuPositionNode,needsNext:e.needsNext??!e.gpuPositionNode};return this.geometry.buildLine(t),this.material.buildLine(t),e.shadow&&(this.material.setShadow(!0),this.castShadow=!0),t.instanceCount!=-1&&(this.count=t.instanceCount),this.frustumCulled=t.frustumCulled,e.opacity===void 0?this.uOpacity=Le(1):e.opacity.isNode?this.uOpacity=e.opacity:typeof e.o
2104pacity=="number"&&(this.uOpacity=Le(e.opacity)),this.resize(t.renderWidth,t.renderHeight),this._built=!0,this}_onBeforeRender(){this.ensureBuilt()}setPositions(e,t=!1){this.ensureBuilt(),this.geometry.setPositions(e,t)}addVertexAttribute(e,t=1){this.ensureBuilt();let i=this.geometry.getAttribute("position").count,r=new Float32Array(i*t);return this.geometry.setOrUpdateAttribute(e,r,t),this.geometry.getAttribute(e)}addInstanceAttribute(e,t=1){this.ensureBuilt();let i=new cr(new Float32Array(this.count*t),t);return this.geometry.setAttribute(e,i),i}setInstanceValue(e,t,i){let r=this.geometry.getAttribute(e);if(!r){console.warn(`MeshLine: Attribute ${e} not found. Make sure to add it first using addInstanceAttribute().`);return}if(t<0||t>=this.count){console.warn(`MeshLine: Instance index ${t} out of bounds [0, ${this.count})`);return}let s=t*r.itemSize,n=r.array;if(typeof i=="number")n[s]=i;else if(Array.isArray(i)){let a=Math.min(r.itemSize,i.length);for(let o=0;o<a;o++)n[s+o]=i[o]}else i&&typeof i=="object"&&("x"in i&&(n[s]=i.x),"y"in i&&r.itemSize>1&&(n[s+1]=i.y),"z"in i&&r.itemSize>2&&(n[s+2]=i.z),"w"in i&&r.itemSize>3&&(n[s+3]=i.w));r.needsUpdate=!0}resize(e=nI(),t=aI()){this.material&&this.material.resolution&&this.material.resolution.value.set(e,t)}autoResize(e=Dy?window:null){return e?(this._autoResizeHandler&&=(this._autoResizeTarget?.removeEventListener("resize",this._autoResizeHandler),null),this._autoResizeHandler=()=>{this.resize(e.innerWidth,e.innerHeight)},e.addEventListener("resize",this._autoResizeHandler),this._autoResizeTarget=e,this):(console.warn("MeshLine: autoResize requires a valid target in SSR/Node environments"),this)}_warnIfBuilt=e=>{this._built&&console.warn(`MeshLine: Changing ${e} after build is not supported yet.`)};ensureBuilt(){return this._built||this.build(),this}rebuild(){return this._built=!1,this.build()}raycast(e,t){this.ensureBuilt();let i=this.geometry,r=this.matrixWorld,s=e.params.Line||{},n=s.threshold??1,a=s.firstHitOnly===!0||e.firstHitOnly===!0,o=i.getAttribute("instanceStart"),l=i.getAttribute("instanceEnd"),h=!!(o&&l&&o.isInstancedBufferAttribute),u=!!(i._lines&&i._lines.length>0);if(!h){if(!u)return;if(this._options.gpuPositionNode){this._warnedGpuRaycast||=(console.info("MeshLine.raycast: GPU-positioned lines are not raycastable \u2014 use MeshLinePicker."),!0);return}if(i.boundingSphere===null&&i.computeBoundingSphere(),i.boundingSphere!==null&&i.boundingSphere.radius>0&&(Py.copy(i.boundingSphere),Py.applyMatrix4(r),Py.radius+=n,e.ray.intersectsSphere(Py)===!1))return}
2104sI.copy(r).invert(),ow.copy(e.ray).applyMatrix4(sI);let d=n/((this.scale.x+this.scale.y+this.scale.z)/3||1),c=d*d,p=e.near,m=e.far,g=p*p,f=Number.isFinite(m)?m*m:1/0,y=e.ray.origin,x=null,b=1/0,_=(T,w,M)=>{Fy.applyMatrix4(r);let S=y.distanceToSquared(Fy);if(S<g||S>f)return;let R=Math.sqrt(S),I={distance:R,point:lw.clone().applyMatrix4(r),index:T,face:null,faceIndex:null,object:this};if(w!==void 0&&(I.lineIndex=w),M!==void 0&&(I.instanceId=M),a){if(R>=b)return;b=R,x=I;return}t.push(I)};if(h){let T=o.count;for(let w=0;w<T;w++)ky.fromBufferAttribute(o,w),Iy.fromBufferAttribute(l,w),!(ow.distanceSqToSegment(ky,Iy,Fy,lw)>c)&&_(0,void 0,w)}else for(let T=0;T<i._lines.length;T++){let w=i._lines[T],M=w.length/3;for(let S=0;S<M-1;S++){let R=S*3,I=(S+1)*3;ky.set(w[R],w[R+1],w[R+2]),Iy.set(w[I],w[I+1],w[I+2]),!(ow.distanceSqToSegment(ky,Iy,Fy,lw)>c)&&_(S,T)}}a&&x&&t.push(x)}dispose=()=>{this.parent?.remove(this),this.geometry?.dispose(),this.material?.dispose(),this._autoResizeHandler&&this._autoResizeTarget&&(this._autoResizeTarget.removeEventListener("resize",this._autoResizeHandler),this._autoResizeHandler=null,this._autoResizeTarget=null),this.instanceMatrix&&this.instanceMatrix.dispose(),this.instanceColor&&this.instanceColor.dispose(),this._built=!1}},oI=UO(OO(((e,t)=>{(function(){function i(l,h){var u=l.x-h.x,d=l.y-h.y;return u*u+d*d}function r(l,h,u){var d=h.x,c=h.y,p=u.x-d,m=u.y-c;if(p!==0||m!==0){var g=((l.x-d)*p+(l.y-c)*m)/(p*p+m*m);g>1?(d=u.x,c=u.y):g>0&&(d+=p*g,c+=m*g)}return p=l.x-d,m=l.y-c,p*p+m*m}function s(l,h){for(var u=l[0],d=[u],c,p=1,m=l.length;p<m;p++)c=l[p],i(c,u)>h&&(d.push(c),u=c);return u!==c&&d.push(c),d}function n(l,h,u,d,c){for(var p=d,m,g=h+1;g<u;g++){var f=r(l[g],l[h],l[u]);f>p&&(m=g,p=f)}p>d&&(m-h>1&&n(l,h,m,d,c),c.push(l[m]),u-m>1&&n(l,m,u,d,c))}function a(l,h){var u=l.length-1,d=[l[0]];return n(l,0,u,h,d),d.push(l[u]),d}function o(l,h,u){if(l.length<=2)return l;var d=h===void 0?1:h*h;return l=u?l:s(l,d),l=a(l,d),l}typeof define=="function"&&define.amd?define(function(){return o}):t===void 0?typeof self<"u"?self.simplify=o:window.simplify=o:(t.exports=o,t.exports.default=o)})()}))(),1),gm=([e,t])=>El([t,e],"EPSG:4326","EPSG:3857"),lI=(e,t=.05,i=!0)=>(0,oI.default)(e.map(([r,s])=>({x:r,y:s})),t,i).map(({x:r,y:s})=>gm([r,s])),hI=(e,t)=>{if(e.length<2)return e;let i=[e[0]],r=0,s=0;for(let n=1;n<e.length;n++){let[a,o]=e[n-1],[l,h]=e[n],u=Math.sqrt((l-a)**2+(h-o)**2),d=s+u;for(;r+t<=d;){r+=t;let c=(r-s)/u,p=a+(l-a)*c,m=o+(h-o)*c;i.push([p,m])}s=d}return i},BK=(e,{opacity:t=.8,color:i=0}={})=>{let[r,s]=gm([-85,-180]),[n,a]=gm([-85,180]),[o,l]=gm([85,180]),[h,u]=gm([85,-180]),d=new Kg;d.moveTo(r,s),d.lineTo(n,a),d.lineTo(o,l),d.lineTo(h,u),d.lineTo(r,s);let c=new Px;return lI(e).forEach(([p,m],g)=>g?c.lineTo(p,m):c.moveTo(p,m)),d.holes.push(c),new xt(new Dx(d),new ji({color:i,opacity:t,transparent:!0,depthWrite:!1}))},fm=e=>{let t=new Float32Array(e.length*3);for(let i=0,r=0;i<e.length;i++){let[s,n]=e[i];t[r++]=s,t[r++]=n,t[r++]=0}return t},UK={cold:255,warm:16711680,occluded:8388736,stationary:null};function hw(e,t){if(!e||!t)throw Error("Run and echeance parameters are required to build frontologie URL");return`https://static5.mclcm.net/images/dynmap/models/frontologie/${e}/frontologie/${t}/0/0/fronts_monde.json`}function VK(e){let t=new Map,i=new Map,r=null;return{async fetchFrontData(s,n,a=null){let o=hw(s,n);if(i.has(o))return i.get(o);if(t.has(o))return t.get(o);if(r===o&&i.has(o))return i.get(o);let l=(async()=>{try{let h=await fetch(e(o));if(!h.ok){if(console.error("[Frontologie] Failed to fetch URL:",o,"Status:",h.status),h.status===404&&a){console.warn("[Frontologie] Trying to fallback to an earlier available forecast...");let d=await a(s,n);return i.set(o,d),r=o,d}throw Error(`Failed to fetch frontologie data: ${h.statusText}`)}let u=await h.json();return i.set(o,u),r=o,u}finally{t.delete(o)}})();return t.set(o,l),l},getLastLoadedUrl(){return r},clearCache(){t.clear(),i.clear(),r=null}}}async function zK(e,t,i,r){if(!i)throw Error("No forecast dates available for fallback");let s=i.findIndex(n=>n.date_model_run===e&&n.date_ech===t);console.log(`[Frontologie] Trying fallback from index ${s}...`);for(let n=s-1;n>=0;n--){let{date_model_run:a,date_ech:o}=i[n],l=hw(a,o);try{let h=await fetch(r(l));if(h.ok)return console.log(`[Frontologie] Successfully loaded fallback at index ${n}`),await h.json()}catch{}}throw Error("No available frontologie forecast found on server")}var GK=class Ec extends fa{lines=null;onResizeHandler=null;onUpdateHandler=null;objectLayer=null;textureCold=null;textureHot=null;textureOccluded=null;textureStationary=null;map=null;static uScale=null;#n=null;#o=null;#u=!1;#l=null;#s=new Set;constructor(){super(),this.name="frontologie",this.isObjectLayer=!0,this.directRender=!0,this.minZoom=0,this.maxZoom=0,this.overrideRenderOrder=100000001,this.useOverlayIsobars=!0,this.overlays=[{id:5}],Ec.uScale=Ec.uScale||Le(1),this.#n=VK(hi);let t=new Wo;this.textureCold=t.load("https://static5.mclcm.net/images/mc2020/bundles/map/frontologie_cold.png",i=>{i.wrapS=Or,i.wrapT=Or}),this.textureHot=t.load("https://static5.mclcm.net/images/mc2020/bundles/map/frontologie_hot.png",i=>{i.wrapS=Or,i.wrapT=Or}),this.textureOccluded=t.load("https://static5.mclcm.net/images/mc2020/bundles/map/frontologie_occluded.png",i=>{i.wrapS=Or,i.wrapT=Or}),this.textureStationary=t.load("https://static5.mclcm.net/images/mc2020/bundles/map/frontologie_stationary.png",i=>{i.wrapS=Or,i.wrapT=Or})}convertToFloat32Positions=t=>fm(hI(t,5e4));init(t,i){this.objectLayer=t,this.layer=i,t.master&&t.master.openLayerMap&&(this.map=t.master.openLayerMap),this.onUpdateHandler=()=>{if(this.map&&Ec.uScale){let r=this.getScaleFromZoom();Ec.uScale.value=r}}
2104,N.onUpdate.add(this.onUpdateHandler)}async fetchFrontData(t,i){let r=this.layer?.provider?.value?.forecastDates?async(s,n)=>await zK(s,n,this.layer.provider.value.forecastDates,hi):null;return await this.#n.fetchFrontData(t,i,r)}async updateFrontLines(t,i){if(!t||!i)return;let r=hw(t,i);if(!(this.#n.getLastLoadedUrl()===r&&this.lines)){if(this.#u){this.#l={run:t,echeance:i};return}this.#u=!0,this.#l=null;try{let s=await this.fetchFrontData(t,i);if(await this.clearLines(),this.objectLayer&&this.objectLayer.container){let n=[];this.objectLayer.container.traverse(a=>{a.userData&&a.userData.frontType&&n.push(a)}),n.length>0&&(console.warn(`[Frontologie] ${n.length} lines still in container before createFrontLines(), forcing cleanup`),n.forEach(a=>{if(a.parent&&a.parent.remove(a),a&&typeof a.dispose=="function")try{a.dispose()}catch(o){console.warn("[Frontologie] Error disposing line during verification:",o)}}))}if(this.createFrontLines(s),this.objectLayer&&this.objectLayer.getRenderer){let n=this.objectLayer.getRenderer();requestAnimationFrame(()=>{n&&n.lastFrameState&&(n.updateImage(n.lastFrameState),n.needsRender=!0),this.map&&this.map.render()})}}catch(s){console.error("Error loading frontologie data:",s)}finally{if(this.#u=!1,this.#l){let s=this.#l;this.#l=null,setTimeout(()=>{this.updateFrontLines(s.run,s.echeance)},0)}}}}calculateLineLength(t){let i=0;for(let r=0;r<t.length-3;r+=3){let s=t[r+3]-t[r],n=t[r+4]-t[r+1];i+=Math.sqrt(s*s+n*n)}return i}getScaleFromZoom(){return this.map?2**(this.map.getView().getZoom()-4)*.6:1}createFrontLines(t){if(!this.objectLayer)return;let i={cold:{positions:[],lengths:[],directions:[]},warm:{positions:[],lengths:[],directions:[]},occluded:{positions:[],lengths:[],directions:[]},stationary:{positions:[],lengths:[],directions:[]}};Object.entries(t).forEach(([s,n])=>{i[s]&&n.forEach(a=>{let{points:o,direction:l}=a;if(!o||o.length<2)return;let h=this.convertToFloat32Positions(o),u=this.calculateLineLength(h);i[s].positions.push(h),i[s].lengths.push(u),i[s].directions.push(l)})});let r=[];if(Object.entries(i).forEach(([s,n])=>{if(n.positions.length===0)return;n.positions.reduce((g,f)=>g+f.length/3,0);let a=null,o=1;s==="cold"?a=this.textureCold:s==="warm"?a=this.textureHot:s==="occluded"?(a=this.textureOccluded,o=2):s==="stationary"&&(a=this.textureStationary,o=2);let l=new Ll().lines(n.positions).sizeAttenuation(!1).lineWidth(Fs?10:40).transparent(!0).opacity(1).renderSize(N.width*N.devicePixelRatio,N.height*N.devicePixelRatio);a&&l.map(a).uvFn(Vt(({uv:g})=>{let f=xl("direction","float").greaterThan(.5).select(g.y.oneMinus(),g.y),y=xl("lineLength","float").div(2e5);return Je(g.x.mul(y).mul(Ec.uScale).div(o),f)}));let h=UK[s]||16777215;l.color(h);let u=l.build(),d=u.geometry.attributes.position.count,c=new Float32Array(d),p=new Float32Array(d),m=0;n.positions.forEach((g,f)=>{let y=g.length/3*2,x=n.lengths[f],b=+(n.directions[f]==="left");for(let _=0;_<y;_++)m+_<d&&(c[m+_]=x,p[m+_]=b);m+=y}),u.geometry.setAttribute("lineLength",new Ht(c,1)),u.geometry.setAttribute("direction",new Ht(p,1)),u.renderOrder=2,u.userData.frontType=s,u.userData.lineLengths=n.lengths,r.push(u),this.objectLayer.add(u)}),this.lines=r,this.objectLayer&&this.objectLayer.getRenderer){let s=this.objectLayer.getRenderer();s&&s.lastFrameState&&(s.updateImage(s.lastFrameState),s.needsRender=!0,s.initialRender=!0)}this.map&&requestAnimationFrame(()=>{this.map&&this.map.render()}),setTimeout(()=>{this.layer?.currentLayer?.onContentReady&&this.layer.currentLayer.onContentReady.dispatch()},0),this.onResizeHandler&&=(N.onResize.remove(this.onResizeHandler),null),this.onResizeHandler=()=>{this.lines&&this.lines.forEach(s=>{s&&typeof s.resize=="function"&&s.resize(N.width*N.devicePixelRatio,N.height*N.devicePixelRatio)})},N.onResize.add(this.onResizeHandler)}async clearLines(){if(this.onResizeHandler&&=(N.onResize.remove(this.onResizeHandler),null),this.lines&&this.lines.forEach(t=>{this.#s.add(t),t.userData._isBeingRemoved=!0,t.visible=!1,t.userData&&t.userData._copies&&t.userData._copies.forEach(i=>{this.#s.add(i),i.userData&&(i.userData._isBeingRemoved=!0),i.visible=!1})}),this.objectLayer&&this.objectLayer.container){let t=this.objectLayer.container,i=[];t.traverse(r=>{r.userData&&r.userData.frontType&&(i.push(r),this.#s.add(r),r.userData._isBeingRemoved=!0,r.visible=!1)}
2104),i.forEach(r=>{r.parent&&r.parent.remove(r),r&&typeof r.dispose=="function"&&r.dispose(),this.#s.delete(r),r.userData&&delete r.userData._isBeingRemoved}),i.length>0&&console.log(`[Frontologie] Removed ${i.length} line objects from container`)}if(this.lines){let t=[...this.lines];for(let i of t)if(this.objectLayer&&i){try{this.objectLayer.remove(i)}catch(r){console.warn("[Frontologie] Error removing line via objectLayer:",r)}if(i&&typeof i.dispose=="function")try{i.dispose()}catch(r){console.warn("[Frontologie] Error disposing line:",r)}this.#s.delete(i),i.userData&&delete i.userData._isBeingRemoved}}if(this.lines=null,this.objectLayer&&this.objectLayer.container){let t=[];this.objectLayer.container.traverse(i=>{i.userData&&i.userData.frontType&&t.push(i)}),t.length>0&&(console.warn(`[Frontologie] ${t.length} lines STILL in container after clearLines(), forcing removal`),t.forEach(i=>{if(this.#s.add(i),i.userData._isBeingRemoved=!0,i.visible=!1,i.parent&&i.parent.remove(i),i&&typeof i.dispose=="function")try{i.dispose()}catch(r){console.warn("[Frontologie] Error disposing remaining line:",r)}this.#s.delete(i),delete i.userData._isBeingRemoved}))}return this.#s.clear(),Promise.resolve()}disposeLayerResources=async()=>{await this.clearLines()};dispose(){if(this.onResizeHandler&&=(N.onResize.remove(this.onResizeHandler),null),this.onUpdateHandler&&=(N.onUpdate.remove(this.onUpdateHandler),null),this.#o&&=(this.#o(),null),this.lines){let t=[...this.lines];this.lines=null,t.forEach(i=>{this.objectLayer&&this.objectLayer.remove(i),i&&typeof i.dispose=="function"&&i.dispose()})}this.#n&&this.#n.clearCache(),this.textureCold?.dispose(),this.textureCold=null,this.textureHot?.dispose(),this.textureHot=null,this.textureOccluded?.dispose(),this.textureOccluded=null,this.textureStationary?.dispose(),this.textureStationary=null,this.objectLayer=null,this.map=null,this.layer=null}getUrl=(t,i)=>t&&i?`frontologie://${t}/${i}`:"frontologie://static";onAfterShow(t){if(this.useOverlayIsobars&&t.isobares&&t.setOverlayVisible("isobars",!0),this.objectLayer&&t.currentForecastDate?.value){let i=t.currentForecastDate.value;i.date_model_run&&i.date_ech&&this.updateFrontLines(i.date_model_run,i.date_ech)}t.currentForecastDate&&!this.#o&&(this.#o=mo(t.currentForecastDate,i=>{i&&this.objectLayer&&i.date_model_run&&i.date_ech&&this.updateFrontLines(i.date_model_run,i.date_ech)}))}},ec=new class gO{static layerClassRegistry={frontologie:GK};layers=[];layerDataQueue=new Map;loadingPromises=new Map;isPreloadingStarted=!1;async init(t,i={}){if(this.layerDataById=new Map,!t){console.warn("[LayerDataManager] No layer data provided to LayerDataManager");return}t.forEach(r=>{let s=null;r.providers&&r.providers[0]&&r.providers[0].params&&r.providers[0].params[0]&&(s=r.providers[0].params[0].param,r._technicalId=s),r.id&&(this.layerDataById.set(r.id,r),this.layerDataQueue.set(r.id,r)),this.layerDataQueue.set(r.name,r),s&&this.layerDataQueue.set(s,r)})}async loadLayer(t){let i=this.layers.find(a=>a.name===t||a.id===t||a.displayName===t);if(i)return i;let r=this.layerDataQueue.get(t);if(!r)return null;let s=r.id||t;if(this.loadingPromises.has(s))return this.loadingPromises.get(s);let n=this._loadLayerData(r);this.loadingPromises.set(s,n);try{let a=await n;return this.layers.push(a),r.id&&this.layerDataById&&this.layerDataById.delete(r.id),this.layerDataQueue.delete(r.name),r.id&&this.layerDataQueue.delete(r.id),a.name&&a.name!==r.name&&this.layerDataQueue.delete(a.name),this.loadingPromises.delete(s),a}catch(a){return console.error(`[LayerDataManager] Failed to load layer '${t}':`,a),this.loadingPromises.delete(s),null}}async _loadLayerData(t){let i=t._technicalId||t.name,r=new(gO.layerClassRegistry[i]||fa);return await r.initFromData(t),r}async loadLayers(t){let i=t.map(r=>this.loadLayer(r));return Promise.all(i)}async preloadRemainingLayers(){if(this.isPreloadingStarted)return 0;this.isPreloadingStarted=!0;let t=this.layerDataById?Array.from(this.layerDataById.keys()):[];return t.length===0?0:(await this.loadLayers(t),t.length)}getLayerByID(t){return this.layers.find(i=>i.id===t)}
2104getLayerByName(t){return this.layers.find(i=>i.name===t)}isLayerLoaded(t){return this.layers.some(i=>i.name===t)}getLoadedLayerNames(){return this.layers.map(t=>t.name)}getAllLayerNames(){let t=this.getLoadedLayerNames(),i=Array.from(this.layerDataQueue.keys());return[...new Set([...t,...i])]}getAllLayerMetadata(){let t=[],i=new Set;for(let r of this.layers){let s=`${r.id}-${r.name}`;i.has(s)||(i.add(s),t.push({name:r.name,displayName:r.displayName||r.name,id:r.id,_loaded:!0,_instance:r}))}if(this.layerDataById)for(let[r,s]of this.layerDataById)this.layers.some(n=>n.id===r)||t.push({name:s._technicalId||s.name,displayName:s.name,id:s.id,_loaded:!1,_data:s});return t}getLayerMetadataByNameOrId(t){for(let i of this.layers)if(i.name===t||i.id===t)return{name:i.name,id:i.id,_loaded:!0,_instance:i};for(let[i,r]of this.layerDataQueue)if(r.name===t||r.id===t)return{name:r.name,id:r.id,_loaded:!1,_data:r};return null}toArray(){return this.layers.map(t=>t.toString())}toArrayForCompactTable(){return this.layers.map(t=>({Layer:t.toString(),Providers:t.providers.map(i=>i.name).join(", ")}))}toString(){return this.layers.map(t=>t.toString()).join(`
2105`)}},jK={dbName:"MapJSResourceCacheDB",storeName:"resources",cacheVersion:"1.0.0",expiryTime:3600*1e3,modelJsonExpiryTime:300*1e3,jsonExpiryTime:3600*1e3,disableJsonCache:!1,debug:!1,maxRetries:3,retryDelay:500,defaultTimeout:1e4,cleanupInterval:180*1e3,maxCacheSize:256*1024*1024,maxEntries:5e3},uw=["MapDataMarine","BlueMarble","borders","cities"],$K=class{constructor(e={}){this.config={...jK,...e},this.logger=Id("[ResourceCache]"),this.checkVersionAndInit(),this.blobUrls=new Map,this.pendingRequests=new Map,this.lastActivityTime=Date.now(),this.activityCount=0,this.startCleanupTimer()}checkVersionAndInit(){let e=localStorage.getItem("mapjs-cache-version");!e||e!==this.config.cacheVersion?(this.dbPromise=this.clearAndOpenDatabase(),localStorage.setItem("mapjs-cache-version",this.config.cacheVersion)):this.dbPromise=this.openDatabase(),this.dbPromise.then(()=>{"requestIdleCallback"in window?requestIdleCallback(()=>{let t=performance.now();this.cleanupExpiredCache().then(i=>{let r=performance.now();this.logger.debug(`Deferred cleanup completed in ${(r-t).toFixed(2)}ms, removed ${i} entries`)}).catch(i=>{this.logger.error(`Error during deferred cleanup: ${i.message}`)})},{timeout:2e3}):setTimeout(()=>{this.cleanupExpiredCache().then(t=>{}).catch(t=>{this.logger.error(`Error during deferred cleanup: ${t.message}`)})},1e3)})}async clearAndOpenDatabase(){let e=performance.now();return this.logger.debug("Clearing database and opening fresh..."),await new Promise((t,i)=>{let r=indexedDB.deleteDatabase(this.config.dbName);r.onsuccess=()=>{let s=performance.now();this.logger.debug(`Database deleted successfully in ${(s-e).toFixed(2)}ms`),t()},r.onerror=s=>{this.logger.error(`Error deleting database: ${s.target.error}`),i(s.target.error)}}),this.openDatabase()}async openDatabase(){return performance.now(),new Promise((e,t)=>{let i=indexedDB.open(this.config.dbName,2);i.onupgradeneeded=r=>{let s=r.target.result;if(!s.objectStoreNames.contains(this.config.storeName)){let n=s.createObjectStore(this.config.storeName);n.createIndex("timestamp","timestamp"),n.createIndex("type","type"),n.createIndex("lastAccessed","lastAccessed"),n.createIndex("size","size"),this.logger.debug(`Created object store: ${this.config.storeName}`)}},i.onsuccess=r=>{e(r.target.result)},i.onerror=r=>{this.logger.error(`Error opening database: ${r.target.error}`),t(Error(`Failed to open database: ${r.target.error}`))}})}async getFromCache(e){this.trackActivity();try{let t=await this.dbPromise;return new Promise((i,r)=>{let s=t.transaction(this.config.storeName,"readonly").objectStore(this.config.storeName).get(e);s.onsuccess=()=>{let n=s.result;if(n)if(this.isExpired(n,e)){let a=Date.now()-n.timestamp,o=Math.floor(a/6e4);this.logger.debug(`Cache expired: ${e} (age: ${o} min)`),this.deleteFromCache(e).catch(()=>{}),i(null)}else{let a=Date.now()-n.timestamp,o=Math.floor(a/6e4);this.logger.debug(`Cache hit: ${e} (age: ${o} min)`),this.updateLastAccessed(e).catch(()=>{}),i(n)}else this.logger.debug(`Cache miss: ${e}`),i(null)},s.onerror=()=>r(s.error)})}catch(t){return this.logger.error(`Cache retrieval error: ${t.message}`),null}}async saveToCache(e,t,i={}){this.trackActivity();try{let r=await this.dbPromise;return new Promise((s,n)=>{let a=r.transaction(this.config.storeName,"readwrite").objectStore(this.config.storeName),o={...t,...i,timestamp:Date.now(),lastAccessed:Date.now(),key:e},l=a.put(o,e);l.onsuccess=async()=>{this.logger.debug(`Saved to cache: ${e}`),await this.enforceStorageLimits(),s()},l.onerror=()=>n(l.error)})}catch(r){throw this.logger.error(`Cache save error: ${r.message}`,"error"),r}}async deleteFromCache(e){try{let t=await this.dbPromise;return new Promise((i,r)=>{let s=t.transaction(this.config.storeName,"readwrite").objectStore(this.config.storeName).delete(e);s.onsuccess=()=>i(),s.onerror=()=>r(s.error)})}catch(t){this.logger.error(`Delete error: ${t.message}`,"error")}}async updateLastAccessed(e){try{let t=(await this.dbPromise).transaction(this.config.storeName,"readwrite").objectStore(this.config.storeName),i=t.get(e);i.onsuccess=()=>{let r=i.result;r&&(r.lastAccessed=Date.now(),t.put(r,e))}}catch(t){this.logger.error(`Update lastAccessed error: ${t.message}`,"error")}}isExpired(e,t){let i=e.layerName||"",r=e.zoomLevel;if(uw.includes(i)&&r!==void 0&&r<7)return!1;let s=Date.now()-e.timestamp,n=this.config.expiryTime;return e.type==="json"&&t?n=t.includes("/models/")||t.includes("map_engine/models")?this.config.modelJsonExpiryTime:this.config.jsonExpiryTime:e.type==="image"&&r!==void 0&&r>7&&(n=this.config.expiryTime/2),s>=n}parseContentType(e){let t=e.headers.get("content-type")||"";return t.includes("application/json")?"json":t.startsWith("image/")?"image":t.includes("text/")?"text":"binary"}async fetchWithRetry(e,t={},i=0){try{let r=new AbortController,s=t.timeout||this.config.defaultTimeout,n=setTimeout(()=>r.abort(),s),a=await fetch(e,{...t,signal:r.signal,mode:"cors",credentials:"omit"});if(clearTimeout(n),!a.ok)throw Error(`HTTP ${a.status}: ${a.statusText}`);return a}catch(r){let s=r.message&&(r.message.includes("NGHTTP2_PROTOCOL_ERROR")||r.message.includes("Stream closed")||r.message.includes("ERR_HTTP2_STREAM_ERROR"));if(i<this.config.maxRetries){this.logger.debug(`Retry ${i+1}/${this.config.maxRetries} for ${e} (${r.message})`);let n=s?this.config.retryDelay*(i+1)*2:this.config.retryDelay*(i+1);return await this.delay(n),this.fetchWithRetry(e,t,i+1)}throw r}}delay(e){return new Promise(t=>setTimeout(t,e))}createBlobUrl(e){let t=URL.createObjectURL(e);return this.blobUrls.set(t,Date.now()),t}revokeBlobUrl(e){this.blobUrls.has(e)&&(URL.revokeObjectURL(e),this.blobUrls.delete(e))}trackActivity(){this.lastActivityTime=Date.now(),this.activityCount++}getActivityLevel(){let e=(Date.now()-this.lastActivityTime)/6e4;return e<1?"high":e<5?"medium":"low"}startCleanupTimer(){let e=()=>{let t=this.getActivityLevel(),i=this.config.cleanupInterval;switch(t){case"high":i=3e4,this.logger.debug("High activity detected, postponing cleanup");break;case"medium":this.cleanupBlobUrls(),this.cleanupExpiredCache(),i=this.config.cleanupInterval;break;case"low":this.cleanupBlobUrls(),this.cleanupExpiredCache(),this.enforceStorageLimits().catch(()=>{}),i=this.config.cleanupInterval*2;break}
2105this.activityCount=0,setTimeout(e,i)};setTimeout(e,this.config.cleanupInterval)}cleanupBlobUrls(){let e=Date.now(),t=this.config.expiryTime;for(let[i,r]of this.blobUrls)e-r>t&&this.revokeBlobUrl(i)}async enforceStorageLimits(){try{let e=await this.getCacheStats();if(e.totalEntries<=this.config.maxEntries&&e.totalSize<=this.config.maxCacheSize)return;this.logger.debug(`Enforcing storage limits: ${e.totalEntries} entries, ${(e.totalSize/1024/1024).toFixed(2)}MB`);let t=(await this.dbPromise).transaction(this.config.storeName,"readwrite").objectStore(this.config.storeName).index("lastAccessed"),i=[],r=t.openCursor();await new Promise((l,h)=>{r.onsuccess=u=>{let d=u.target.result;d?(i.push({key:d.primaryKey,value:d.value}),d.continue()):l()},r.onerror=h});let s=Math.max(0,e.totalEntries-this.config.maxEntries+100),n=Math.max(0,e.totalSize-this.config.maxCacheSize+50*1024*1024),a=0,o=0;for(let l of i)if(!uw.includes(l.value.layerName||"")){if(a>=s&&o>=n)break;await this.deleteFromCache(l.key),a++,o+=l.value.size||0}this.logger.debug(`LRU eviction complete: removed ${a} entries, ${(o/1024/1024).toFixed(2)}MB`)}catch(e){this.logger.error(`Storage limit enforcement error: ${e.message}`,"error")}}async cleanupExpiredCache(){let e=performance.now();this.logger.debug("Starting cache cleanup...");try{let t=await this.dbPromise,i=0,r=0;return new Promise((s,n)=>{let a=t.transaction(this.config.storeName,"readwrite"),o=a.objectStore(this.config.storeName).openCursor();o.onsuccess=l=>{let h=l.target.result;if(h){r++,r%100==0&&performance.now()-e;let u=h.value,d=h.key;if(uw.includes(u.layerName||"")){h.continue();return}this.isExpired(u,d)&&(h.delete(),i++,this.config.debug&&this.logger.debug(`Deleted expired entry: ${d}`)),h.continue()}else{let u=performance.now();this.logger.debug(`Cleanup completed: ${i} entries removed from ${r} total entries in ${(u-e).toFixed(2)}ms`),s(i)}},o.onerror=()=>{this.logger.error(`Cleanup error: ${o.error}`),n(o.error)},a.oncomplete=()=>{this.config.debug&&this.logger.debug("Transaction completed successfully")},a.onerror=()=>{this.logger.error(`Transaction error: ${a.error}`),n(a.error)}})}catch(t){let i=performance.now();throw this.logger.error(`Cleanup error after ${(i-e).toFixed(2)}ms: ${t.message}`),t}}async loadJSON(e,t={}){let{useCache:i=!0,saveCache:r=!0,proxy:s=null,timeout:n,forceRefresh:a=!1,...o}=t;try{let l=i&&!this.config.disableJsonCache,h=r&&!this.config.disableJsonCache;if(l&&!a){let d=await this.getFromCache(e);if(d&&d.type==="json")return d.data}if(this.pendingRequests.has(e))return this.pendingRequests.get(e);let u=(async()=>{let d=s&&!e.includes(s)?`${s}?url=${encodeURIComponent(e)}`:e,c=await this.fetchWithRetry(d,{timeout:n,...o}),p=await c.json();return h&&await this.saveToCache(e,{type:"json",data:p,contentType:c.headers.get("content-type"),size:JSON.stringify(p).length}),p})();this.pendingRequests.set(e,u);try{return await u}finally{this.pendingRequests.delete(e)}}catch(l){throw this.logger.error(`Failed to load JSON from ${e}: ${l.message}`,"error"),l}}async loadImage(e,t={}){let{useCache:i=!0,saveCache:r=!0,proxy:s=null,timeout:n,forceRefresh:a=!1,returnType:o="url",layerName:l="",zoomLevel:h=null,...u}=t;if(e.includes("/proxy?url=")&&e.match(/\/\d+,\d+,\d+$/)){let d=e.match(/(.+\/proxy\?url=)([^\/]+)(\/(\d+),(\d+),(\d+))$/);if(d){let c=d[1],p=d[2],m=d[4],g=d[5],f=d[6],y=decodeURIComponent(p);y=y.replace(/{z}.*$/,`${m}/${g}/${-f}.webp`),e=`${c}${encodeURIComponent(y)}`}}try{if(i&&!a){let c=await this.getFromCache(e);if(c&&c.type==="image")return o==="blob"?c.blob:o==="base64"?c.base64:this.createBlobUrl(c.blob)}if(this.pendingRequests.has(e))return this.pendingRequests.get(e);let d=(async()=>{let c=null;try{let p=s&&!e.includes(s)?`${s}?url=${encodeURIComponent(e)}`:e,m=await this.fetchWithRetry(p,{timeout:n,...u}),g=await m.blob(),f=null;return(r||o==="base64")&&(f=await this.blobToBase64(g)),r&&await this.saveToCache(e,{type:"image",blob:g,base64:f,contentType:m.headers.get("content-type"),size:g.size,layerName:l,zoomLevel:h}),o==="blob"?g:o==="base64"?f:(c=this.createBlobUrl(g),c)}catch(p){throw c&&this.revokeBlobUrl(c),p}})();this.pendingRequests.set(e,d);try{return await d}finally{this.pendingRequests.delete(e)}}catch(d){throw this.logger.error(`Failed to load image from ${e}: ${d.message}`,"error"),d}}async blobToBase64(e){return new Promise((t,i)=>{let r=new FileReader;r.onloadend=()=>
2105t(r.result),r.onerror=i,r.readAsDataURL(e)})}async loadMultiple(e,t={}){let i=e.map(r=>/\.(jpg|jpeg|png|gif|webp|svg)$/i.test(r)?this.loadImage(r,t):this.loadJSON(r,t));return Promise.all(i)}async preload(e,t={}){let i=await this.loadMultiple(e,{...t,saveCache:!0});return this.logger.debug(`Preloaded ${i.length} resources`),i}async getCacheStats(){try{let e=(await this.dbPromise).transaction(this.config.storeName,"readonly").objectStore(this.config.storeName);return new Promise(t=>{let i={totalEntries:0,totalSize:0,byType:{}},r=e.openCursor();r.onsuccess=s=>{let n=s.target.result;if(n){let a=n.value;i.totalEntries++;let o=a.size||0;i.totalSize+=o;let l=a.type||"unknown";i.byType[l]=(i.byType[l]||0)+1,n.continue()}else t(i)}})}catch(e){return this.logger.error(`Stats error: ${e.message}`,"error"),null}}async clearCache(){this.logger.debug("Clearing entire cache");for(let e of this.blobUrls.keys())URL.revokeObjectURL(e);this.blobUrls.clear();try{let e=(await this.dbPromise).transaction(this.config.storeName,"readwrite").objectStore(this.config.storeName);await new Promise((t,i)=>{let r=e.clear();r.onsuccess=t,r.onerror=i}),this.logger.debug("Cache cleared successfully")}catch(e){throw this.logger.error(`Clear cache error: ${e.message}`,"error"),e}}async clearModelCache(){this.logger.debug("Clearing model-related cache");let e=0;try{let t=(await this.dbPromise).transaction(this.config.storeName,"readwrite").objectStore(this.config.storeName),i=await new Promise((r,s)=>{let n=t.getAllKeys();n.onsuccess=()=>r(n.result),n.onerror=s});for(let r of i)(r.includes("/models/")||r.includes("map_engine/models"))&&(await new Promise((s,n)=>{let a=t.delete(r);a.onsuccess=s,a.onerror=n}),e++,this.logger.debug(`Deleted model cache: ${r}`));return this.logger.debug(`Model cache cleared: ${e} entries removed`),e}catch(t){throw this.logger.error(`Clear model cache error: ${t.message}`,"error"),t}}setDebug(e){this.config.debug=e,this.logger.debug(`Debug mode ${e?"enabled":"disabled"}`)}async getCacheInfo(){return{...await this.getCacheStats(),config:{modelJsonExpiry:`${this.config.modelJsonExpiryTime/6e4} minutes`,jsonExpiry:`${this.config.jsonExpiryTime/6e4} minutes`,defaultExpiry:`${this.config.expiryTime/6e4} minutes (${this.config.expiryTime/36e5} hours)`,jsonCacheDisabled:this.config.disableJsonCache}}}setJsonCacheEnabled(e){return this.config.disableJsonCache=!e,this.logger.debug(`JSON caching ${e?"enabled":"disabled"}`),!this.config.disableJsonCache}isJsonCacheEnabled(){return!this.config.disableJsonCache}dispose(){for(let e of this.blobUrls.keys())URL.revokeObjectURL(e);this.blobUrls.clear(),this.pendingRequests.clear(),this.logger.debug("ResourceCache disposed")}async clearJsonCache(){this.logger.debug("Clearing all JSON cache entries");let e=0;try{let t=(await this.dbPromise).transaction(this.config.storeName,"readwrite").objectStore(this.config.storeName),i=await new Promise((r,s)=>{let n=t.openCursor(),a=[];n.onsuccess=o=>{let l=o.target.result;l?(a.push({key:l.key,value:l.value}),l.continue()):r(a)},n.onerror=s});for(let{key:r,value:s}of i)s.type==="json"&&(await new Promise((n,a)=>{let o=t.delete(r);o.onsuccess=n,o.onerror=a}),e++,this.logger.debug(`Deleted JSON cache: ${r}`));return this.logger.debug(`JSON cache cleared: ${e} entries removed`),e}catch(t){throw this.logger.error(`Clear JSON cache error: ${t.message}`,"error"),t}}async load(e,t=!1,i=!1,r=null,s=0,n=""){let a={useCache:t,saveCache:i,proxy:r,timeout:s||void 0,layerName:n};if(/\.(jpg|jpeg|png|gif|webp|svg)$/i.test(e))return this.loadImage(e,a);if(/\.json$/i.test(e))return this.loadJSON(e,a);{let o=null;try{let l=await this.fetchWithRetry(r&&!e.includes(r)?`${r}?url=${encodeURIComponent(e)}`:e,{timeout:s}),h=this.parseContentType(l);if(h==="json"){let u=await l.json();return i&&await this.saveToCache(e,{type:"json",data:u}),u}else if(h==="image"){let u=await l.blob();return o=this.createBlobUrl(u),i&&await this.saveToCache(e,{type:"image",blob:u}),o}else{let u=await l.text();return i&&await this.saveToCache(e,{type:"text",data:u}),u}}catch(l){throw o&&this.revokeBlobUrl(o),l}}}getCacheVersion(){return this.config.cacheVersion}
2105async setCacheVersion(e){e!==this.config.cacheVersion&&(this.config.cacheVersion=e,localStorage.setItem("mapjs-cache-version",e),await this.clearCache(),this.logger.debug(`Cache cleared due to version change to ${e}`))}},To=Ae(null),dw=Ae(""),uI=Ae(""),dI=Ae(""),cI=Ae(""),Yi=Ae(!1),tc=Ae(!0),au=Ae(!0),ba=Ae("default"),Pl=Ae("default"),li=Ae(null),ic=Ae(!1),Lr=Ae({x:0,y:0}),kl=Ae(!0),pI=Ae(!1),Oy=Ae(!0),mI=Ae(!1),Mi=Ae("user"),gI="monde_ens__mc";function fI(e){return Mi.value==="screenshot"?gI:e}var ou=Ae(2),yI=Ae("mm/h"),cw=Ae(!0),pw=Ae(!0),By=Ae(!0),mw=Ae(!0),gw=Ae(!0),fw=Ae(!0),xI=Ae(!1),vI=Ae({temperature:"\xB0c",speed:"km/h",precipitation:"mm",radar:"mm/h",pressure:"hpa",distance:"km",height:"m"}),lu=Ae(Fs?1.5:3),hu=Ae(Fs?1.5:3),ym=Ae(2),Uy=Ae(1),Vy=Ae(1),xm=Ae(16777215),vm=Ae(16777215),uu=Ae(16777215),du=Ae(16777215),Oe=Ae(null),cu=Ae(!1),bI=Ae("none"),Tn=Ae("monde_ens__mc"),wo=Ae(""),_I=Ae(""),WK=Ae([]),HK=Ae([]),bm=Ae([]),pu=Ae("esri-worldimagery"),Il=Ae(""),Fl=Ae(""),Bi=Ae(0),mu=Ae([]);function hi(e){return To.value?e.includes(To.value)?e:`${To.value}?url=${encodeURIComponent(e)}`:e}var yw=new $K({cacheVersion:"1.0.1"});async function TI(e,t=!0){try{return await yw.load(hi(e),t,!1,null)}catch(i){console.error("Error loading data:",i)}}async function wI(){performance.now();let e=uI.value,[t,i]=await Promise.all([yw.loadJSON(e,{proxy:To.value}),yw.loadJSON(dI.value,{proxy:To.value})]),r=t?.contenu??t?.content,s=i?.contenu??i?.content;if(r.contenu&&(r=r.contenu),r.content&&(r=r.content),s.contenu&&(s=s.contenu),s.content&&(s=s.content),!r||!r.models||!r.parameters){console.warn("Invalid parameters data format",r);return}if(!s||!s.legends){console.warn("Invalid legends data format",s);return}await V_.init(r.models),await A3.init(r.groups),await N3.init(r.overlays),await $h.init(s),await ec.init(r.parameters);let n=r.parameters.length;MapJS.log(`${n} layers ready for on-demand loading`);let a=ec.getAllLayerMetadata();for(let l of a)mu.value.push(l);mu.value.push(new CK),mu.value.push(new MK);let o=async(l,h)=>{let u=ec.getLayerByName(l);if(u||=await ec.loadLayer(l),!u)return;let d=u.clone();d.name=h,d.urlLayerName=h,d.colorOptions.useGradient=!1,d.colorOptions.blur=0,d.overlays=[],u.UVDataLayer=d};await Promise.all([o("vent_kmh","vent_kmh_component"),o("rafale","rafale_component"),o("houle_cm","houle_component"),o("vague_cm","vague_component"),o("mervent_cm","mervent_component"),o("vaguemax_cm","vague_component")])}var qK={proxy:To,pickerEnabled:Yi,pickerShowLocation:au,pickerBehavior:ba,pickerAppearance:Pl,pickerFixedPosition:li,pickerIsDragging:ic,pickerCurrentPosition:Lr,pickerValue:Oe,pickerValueBoxVisible:cu,panEnabled:kl,zoomEnabled:Oy,touchZoomEnabled:cw,doubleClickZoomEnabled:pw,scrollWheelZoomEnabled:By,boxZoomEnabled:mw,keyboardEnabled:gw,tapEnabled:fw,currentModel:Tn,currentLayers:WK,currentOverlays:HK,layers:mu,fetchModels:wI,currentBG:pu,currentLayer:Il,activeLayer:Fl,unitPreferences:vI},Zs={ADD:"add",REMOVE:"remove"},_m={PROPERTYCHANGE:"propertychange"};function qe(){throw Error("Unimplemented abstract method.")}var XK=0;function At(e){return e.ol_uid||=String(++XK)}var SI=class extends Nl{constructor(e,t,i){super(e),this.key=t,this.oldValue=i}},_a=class extends mm{constructor(e){super(),this.on,this.once,this.un,At(this),this.values_=null,e!==void 0&&this.setProperties(e)}get(e){let t;return this.values_&&this.values_.hasOwnProperty(e)&&(t=this.values_[e]),t}getKeys(){return this.values_&&Object.keys(this.values_)||[]}getProperties(){return this.values_&&Object.assign({},this.values_)||{}}getPropertiesInternal(){return this.values_}hasProperties(){return!!this.values_}notify(e,t){let i;i=`change:${e}`,this.hasListener(i)&&this.dispatchEvent(new SI(i,e,t)),i=_m.PROPERTYCHANGE,this.hasListener(i)&&this.dispatchEvent(new SI(i,e,t))}addChangeListener(e,t){this.addEventListener(`change:${e}`,t)}removeChangeListener(e,t){this.removeEventListener(`change:${e}`,t)}set(e,t,i){let r=this.values_||={};if(i)r[e]=t;else{let s=r[e];r[e]=t,s!==t&&this.notify(e,s)}}setProperties(e,t){for(let i in e)this.set(i,e[i],t)}
2105applyProperties(e){e.values_&&Object.assign(this.values_||={},e.values_)}unset(e,t){if(this.values_&&e in this.values_){let i=this.values_[e];delete this.values_[e],wy(this.values_)&&(this.values_=null),t||this.notify(e,i)}}},MI={LENGTH:"length"},zy=class extends Nl{constructor(e,t,i){super(e),this.element=t,this.index=i}},wn=class extends _a{constructor(e,t){if(super(),this.on,this.once,this.un,t||={},this.unique_=!!t.unique,this.array_=e??[],this.unique_)for(let i=1,r=this.array_.length;i<r;++i)this.assertUnique_(this.array_[i],i);this.updateLength_()}clear(){for(;this.getLength()>0;)this.pop()}extend(e){for(let t=0,i=e.length;t<i;++t)this.push(e[t]);return this}forEach(e){let t=this.array_;for(let i=0,r=t.length;i<r;++i)e(t[i],i,t)}getArray(){return this.array_}item(e){return this.array_[e]}getLength(){return this.get(MI.LENGTH)}insertAt(e,t){if(e<0||e>this.getLength())throw Error("Index out of bounds: "+e);this.unique_&&this.assertUnique_(t),this.array_.splice(e,0,t),this.updateLength_(),this.dispatchEvent(new zy(Zs.ADD,t,e))}pop(){return this.removeAt(this.getLength()-1)}push(e){let t=this.getLength();return this.insertAt(t,e),this.getLength()}remove(e){let t=this.array_;for(let i=0,r=t.length;i<r;++i)if(t[i]===e)return this.removeAt(i)}removeAt(e){if(e<0||e>=this.getLength())return;let t=this.array_[e];return this.array_.splice(e,1),this.updateLength_(),this.dispatchEvent(new zy(Zs.REMOVE,t,e)),t}setAt(e,t){if(e>=this.getLength()){this.insertAt(e,t);return}if(e<0)throw Error("Index out of bounds: "+e);this.unique_&&this.assertUnique_(t,e);let i=this.array_[e];this.array_[e]=t,this.dispatchEvent(new zy(Zs.REMOVE,i,e)),this.dispatchEvent(new zy(Zs.ADD,t,e))}updateLength_(){this.set(MI.LENGTH,this.array_.length)}assertUnique_(e,t){let i=this.array_;for(let r=0,s=i.length;r<s;++r)if(i[r]===e&&r!==t)throw Error("Duplicate item added to a unique collection")}},rc=class extends Nl{constructor(e,t,i){super(e),this.map=t,this.frameState=i===void 0?null:i}},Dl=class extends rc{constructor(e,t,i,r,s,n){super(e,t,s),this.originalEvent=i,this.pixel_=null,this.coordinate_=null,this.dragging=r===void 0?!1:r,this.activePointers=n}get pixel(){return this.pixel_||=this.map.getEventPixel(this.originalEvent),this.pixel_}set pixel(e){this.pixel_=e}get coordinate(){return this.coordinate_||=this.map.getCoordinateFromPixel(this.pixel),this.coordinate_}set coordinate(e){this.coordinate_=e}preventDefault(){super.preventDefault(),"preventDefault"in this.originalEvent&&this.originalEvent.preventDefault()}stopPropagation(){super.stopPropagation(),"stopPropagation"in this.originalEvent&&this.originalEvent.stopPropagation()}},vi={SINGLECLICK:"singleclick",CLICK:De.CLICK,DBLCLICK:De.DBLCLICK,POINTERDRAG:"pointerdrag",POINTERMOVE:"pointermove",POINTERDOWN:"pointerdown",POINTERUP:"pointerup",POINTEROVER:"pointerover",POINTEROUT:"pointerout",POINTERENTER:"pointerenter",POINTERLEAVE:"pointerleave",POINTERCANCEL:"pointercancel"},gu=typeof navigator<"u"&&navigator.userAgent!==void 0?navigator.userAgent.toLowerCase():"";gu.includes("safari")&&!gu.includes("chrom")&&(gu.includes("version/15.4")||/cpu (os|iphone os) 15_4 like mac os x/.test(gu));var YK=gu.includes("webkit")&&!gu.includes("edge"),xw=gu.includes("macintosh"),KK=typeof devicePixelRatio<"u"?devicePixelRatio:1,Js=typeof WorkerGlobalScope<"u"&&typeof OffscreenCanvas<"u"&&self instanceof WorkerGlobalScope,CI=typeof Image<"u"&&Image.prototype.decode,RI=(function(){let e=!1;try{let t=Object.defineProperty({},"passive",{get:function(){e=!0}});window.addEventListener("_",null,t),window.removeEventListener("_",null,t)}catch{}return e})(),vw={POINTERMOVE:"pointermove",POINTERDOWN:"pointerdown",POINTERUP:"pointerup",POINTEROVER:"pointerover",POINTEROUT:"pointerout",POINTERENTER:"pointerenter",POINTERLEAVE:"pointerleave",POINTERCANCEL:"pointercancel"},ZK=class extends pm{constructor(e,t){super(e),this.map_=e,this.clickTimeoutId_,this.emulateClicks_=!1,this.dragging_=!1,this.dragListenerKeys_=[],this.moveTolerance_=t===void 0?1:t,this.down_=null;let i=this.map_.getViewport();this.activePointers_=[],this.trackedTouches_={},this.element_=i,this.pointerdownListenerKey_=ft(i,vw.POINTERDOWN,this.handlePointerDown_,this),this.originalPointerMoveEvent_,this.relayedListenerKey_=ft(i,vw.POINTERMOVE,this.relayMoveEvent_,this),this.boundHandleTouchMove_=this.handleTouchMove_.bind(this),this.element_.addEventListener(
2105De.TOUCHMOVE,this.boundHandleTouchMove_,RI?{passive:!1}:!1)}emulateClick_(e){let t=new Dl(vi.CLICK,this.map_,e);this.dispatchEvent(t),this.clickTimeoutId_===void 0?this.clickTimeoutId_=setTimeout(()=>{this.clickTimeoutId_=void 0;let i=new Dl(vi.SINGLECLICK,this.map_,e);this.dispatchEvent(i)},250):(clearTimeout(this.clickTimeoutId_),this.clickTimeoutId_=void 0,t=new Dl(vi.DBLCLICK,this.map_,e),this.dispatchEvent(t))}updateActivePointers_(e){let t=e,i=t.pointerId;if(t.type==vi.POINTERUP||t.type==vi.POINTERCANCEL){delete this.trackedTouches_[i];for(let r in this.trackedTouches_)if(this.trackedTouches_[r].target!==t.target){delete this.trackedTouches_[r];break}}else(t.type==vi.POINTERDOWN||t.type==vi.POINTERMOVE)&&(this.trackedTouches_[i]=t);this.activePointers_=Object.values(this.trackedTouches_)}handlePointerUp_(e){this.updateActivePointers_(e);let t=new Dl(vi.POINTERUP,this.map_,e,void 0,void 0,this.activePointers_);this.dispatchEvent(t),this.emulateClicks_&&!t.defaultPrevented&&!this.dragging_&&this.isMouseActionButton_(e)&&this.emulateClick_(this.down_),this.activePointers_.length===0&&(this.dragListenerKeys_.forEach(oi),this.dragListenerKeys_.length=0,this.dragging_=!1,this.down_=null)}isMouseActionButton_(e){return e.button===0}handlePointerDown_(e){this.emulateClicks_=this.activePointers_.length===0,this.updateActivePointers_(e);let t=new Dl(vi.POINTERDOWN,this.map_,e,void 0,void 0,this.activePointers_);if(this.dispatchEvent(t),this.down_=new PointerEvent(e.type,e),Object.defineProperty(this.down_,"target",{writable:!1,value:e.target}),this.dragListenerKeys_.length===0){let i=this.map_.getOwnerDocument();this.dragListenerKeys_.push(ft(i,vi.POINTERMOVE,this.handlePointerMove_,this),ft(i,vi.POINTERUP,this.handlePointerUp_,this),ft(this.element_,vi.POINTERCANCEL,this.handlePointerUp_,this)),this.element_.getRootNode&&this.element_.getRootNode()!==i&&this.dragListenerKeys_.push(ft(this.element_.getRootNode(),vi.POINTERUP,this.handlePointerUp_,this))}}handlePointerMove_(e){if(this.isMoving_(e)){this.updateActivePointers_(e),this.dragging_=!0;let t=new Dl(vi.POINTERDRAG,this.map_,e,this.dragging_,void 0,this.activePointers_);this.dispatchEvent(t)}}relayMoveEvent_(e){this.originalPointerMoveEvent_=e;let t=!!(this.down_&&this.isMoving_(e));this.dispatchEvent(new Dl(vi.POINTERMOVE,this.map_,e,t))}handleTouchMove_(e){let t=this.originalPointerMoveEvent_;(!t||t.defaultPrevented)&&(typeof e.cancelable!="boolean"||e.cancelable===!0)&&e.preventDefault()}isMoving_(e){return this.dragging_||Math.abs(e.clientX-this.down_.clientX)>this.moveTolerance_||Math.abs(e.clientY-this.down_.clientY)>this.moveTolerance_}disposeInternal(){this.relayedListenerKey_&&=(oi(this.relayedListenerKey_),null),this.element_.removeEventListener(De.TOUCHMOVE,this.boundHandleTouchMove_),this.pointerdownListenerKey_&&=(oi(this.pointerdownListenerKey_),null),this.dragListenerKeys_.forEach(oi),this.dragListenerKeys_.length=0,this.element_=null,super.disposeInternal()}},Ol={POSTRENDER:"postrender",MOVESTART:"movestart",MOVEEND:"moveend",LOADSTART:"loadstart",LOADEND:"loadend"},Pr={LAYERGROUP:"layergroup",SIZE:"size",TARGET:"target",VIEW:"view"},he={IDLE:0,LOADING:1,LOADED:2,ERROR:3,EMPTY:4};function It(e,t){if(!e)throw Error(t)}var JK=1/0,QK=class{constructor(e,t){this.priorityFunction_=e,this.keyFunction_=t,this.elements_=[],this.priorities_=[],this.queuedElements_={}}clear(){this.elements_.length=0,this.priorities_.length=0,dm(this.queuedElements_)}dequeue(){let e=this.elements_,t=this.priorities_,i=e[0];e.length==1?(e.length=0,t.length=0):(e[0]=e.pop(),t[0]=t.pop(),this.siftUp_(0));let r=this.keyFunction_(i);return delete this.queuedElements_[r],i}enqueue(e){It(!(this.keyFunction_(e)in this.queuedElements_),"Tried to enqueue an `element` that was already added to the queue");let t=this.priorityFunction_(e);return t==1/0?!1:(this.elements_.push(e),this.priorities_.push(t),this.queuedElements_[this.keyFunction_(e)]=!0,this.siftDown_(0,this.elements_.length-1),!0)}getCount(){return this.elements_.length}getLeftChildIndex_(e){return e*2+1}getRightChildIndex_(e){return e*2+2}getParentIndex_(e){return e-1>>1}heapify_(){let e;for(e=(this.elements_.length>>1)-1;e>=0;e--)this.siftUp_(e)}isEmpty(){return this.elements_.length===0}isKeyQueued(e){return e in this.queuedElements_}isQueued(e){return this.isKeyQueued(this.keyFunction_(e))}siftUp_(e){let t=this.elements_,i=this.priorities_,r=t.length,s=t[e],n=i[e],a=e;for(;e<r>>1;){let o=this.getLeftChildIndex_(e),l=this.getRightChildIndex_(e),h=l<r&&i[l]<i[o]?l:o;t[e]=t[h],i[e]=i[h],e=h}t[e]=s,i[e]=n,this.siftDown_(a,e)}siftDown_(e,t){let i=this.elements_,r=this.priorities_,s=i[t],n=r[t];for(;t>e;){let a=this.getParentIndex_(t);if(r[a]>n)i[t]=i[a],r[t]=r[a],t=a;else break}i[t]=s,r[t]=n}reprioritize(){let e=this.priorityFunction_,t=this.elements_,i=this.priorities_,r=0,s=t.length,n,a,o;for(a=0;a<s;++a)n=t[a],o=e(n),o==1/0?delete this.queuedElements_[this.keyFunction_(n)]:(i[r]=o,t[r++]=n);t.length=r,i.length=r,this.heapify_()}},eZ=class extends QK{constructor(e,t){super(i=>e.apply(null,i),i=>i[0].getKey()),this.boundHandleTileChange_=this.handleTileChange.bind(this),this.tileChangeCallback_=t,this.tilesLoading_=0,this.tilesLoadingKeys_={}}enqueue(e){let t=super.enqueue(e);
2105return t&&e[0].addEventListener(De.CHANGE,this.boundHandleTileChange_),t}getTilesLoading(){return this.tilesLoading_}handleTileChange(e){let t=e.target,i=t.getState();if(i===he.LOADED||i===he.ERROR||i===he.EMPTY){i!==he.ERROR&&t.removeEventListener(De.CHANGE,this.boundHandleTileChange_);let r=t.getKey();r in this.tilesLoadingKeys_&&(delete this.tilesLoadingKeys_[r],--this.tilesLoading_),this.tileChangeCallback_()}}loadMoreTiles(e,t){let i=0;for(;this.tilesLoading_<e&&i<t&&this.getCount()>0;){let r=this.dequeue()[0],s=r.getKey();r.getState()===he.IDLE&&!(s in this.tilesLoadingKeys_)&&(this.tilesLoadingKeys_[s]=!0,++this.tilesLoading_,++i,r.load())}}};function tZ(e,t,i,r,s){if(!e||!(i in e.wantedTiles)||!e.wantedTiles[i][t.getKey()])return JK;let n=e.viewState.center,a=r[0]-n[0],o=r[1]-n[1];return 65536*Math.log(s)+Math.sqrt(a*a+o*o)/s}var ar={ANIMATING:0,INTERACTING:1},Sn={CENTER:"center",RESOLUTION:"resolution",ROTATION:"rotation"};function EI(e,t,i){return(function(r,s,n,a,o){if(!r)return;if(!s&&!t)return r;let l=t?0:n[0]*s,h=t?0:n[1]*s,u=o?o[0]:0,d=o?o[1]:0,c=e[0]+l/2+u,p=e[2]-l/2+u,m=e[1]+h/2+d,g=e[3]-h/2+d;c>p&&(c=(p+c)/2,p=c),m>g&&(m=(g+m)/2,g=m);let f=ri(r[0],c,p),y=ri(r[1],m,g);if(a&&i&&s){let x=30*s;f+=-x*Math.log(1+Math.max(0,c-r[0])/x)+x*Math.log(1+Math.max(0,r[0]-p)/x),y+=-x*Math.log(1+Math.max(0,m-r[1])/x)+x*Math.log(1+Math.max(0,r[1]-g)/x)}return[f,y]})}function iZ(e){return e}function AI(e){return e**3}function sc(e){return 1-AI(1-e)}function rZ(e){return 3*e*e-2*e*e*e}function sZ(e){return e}var NI=[,,,,,,];function Qs(){return[1,0,0,1,0,0]}function LI(e){return _w(e,1,0,0,1,0,0)}function bw(e,t){let i=e[0],r=e[1],s=e[2],n=e[3],a=e[4],o=e[5],l=t[0],h=t[1],u=t[2],d=t[3],c=t[4],p=t[5];return e[0]=i*l+s*h,e[1]=r*l+n*h,e[2]=i*u+s*d,e[3]=r*u+n*d,e[4]=i*c+s*p+a,e[5]=r*c+n*p+o,e}function _w(e,t,i,r,s,n,a){return e[0]=t,e[1]=i,e[2]=r,e[3]=s,e[4]=n,e[5]=a,e}function nZ(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e}function Ki(e,t){let i=t[0],r=t[1];return t[0]=e[0]*i+e[2]*r+e[4],t[1]=e[1]*i+e[3]*r+e[5],t}function Tw(e,t,i){return bw(e,_w(NI,t,0,0,i,0,0))}function aZ(e,t,i){return bw(e,_w(NI,1,0,0,1,t,i))}function So(e,t,i,r,s,n,a,o){let l=Math.sin(n),h=Math.cos(n);return e[0]=r*h,e[1]=s*l,e[2]=-r*l,e[3]=s*h,e[4]=a*r*h-o*r*l+t,e[5]=a*s*l+o*s*h+i,e}function PI(e,t){let i=oZ(t);It(i!==0,"Transformation matrix cannot be inverted");let r=t[0],s=t[1],n=t[2],a=t[3],o=t[4],l=t[5];return e[0]=a/i,e[1]=-s/i,e[2]=-n/i,e[3]=r/i,e[4]=(n*l-a*o)/i,e[5]=-(r*l-s*o)/i,e}function oZ(e){return e[0]*e[3]-e[1]*e[2]}var lZ=[1e5,1e5,1e5,1e5,2,2];function hZ(e){return"matrix("+e.join(", ")+")"}function ww(e){return e.substring(7,e.length-1).split(",").map(parseFloat)}function uZ(e,t){let i=ww(e),r=ww(t);for(let s=0;s<6;++s)if(Math.round((i[s]-r[s])*lZ[s])!==0)return!1;return!0}function Bl(e,t,i,r,s,n,a){n||=[],a||=2;let o=0;for(let l=t;l<i;l+=r){let h=e[l],u=e[l+1];n[o++]=s[0]*h+s[2]*u+s[4],n[o++]=s[1]*h+s[3]*u+s[5];for(let d=2;d<a;d++)n[o++]=e[l+d]}return n&&n.length!=o&&(n.length=o),n}function kI(e,t,i,r,s,n,a){a||=[];let o=Math.cos(s),l=Math.sin(s),h=n[0],u=n[1],d=0;for(let c=t;c<i;c+=r){let p=e[c]-h,m=e[c+1]-u;a[d++]=h+p*o-m*l,a[d++]=u+p*l+m*o;for(let g=c+2;g<c+r;++g)a[d++]=e[g]}return a&&a.length!=d&&(a.length=d),a}function dZ(e,t,i,r,s,n,a,o){o||=[];let l=a[0],h=a[1],u=0;for(let d=t;d<i;d+=r){let c=e[d]-l,p=e[d+1]-h;o[u++]=l+s*c,o[u++]=h+n*p;for(let m=d+2;m<d+r;++m)o[u++]=e[m]}return o&&o.length!=u&&(o.length=u),o}function cZ(e,t,i,r,s,n,a){a||=[];let o=0;for(let l=t;l<i;l+=r){a[o++]=e[l]+s,a[o++]=e[l+1]+n;for(let h=l+2;h<l+r;++h)a[o++]=e[h]}return a&&a.length!=o&&(a.length=o),a}var II=Qs(),pZ=[NaN,NaN],mZ=class extends _a{constructor(){super(),this.extent_=ya(),this.extentRevision_=-1,this.simplifiedGeometryMaxMinSquaredTolerance=0,this.simplifiedGeometryRevision=0,this.simplifyTransformedInternal=qk((e,t,i)=>{if(!i)return this.getSimplifiedGeometry(t);let r=this.clone();return r.applyTransform(i),r.getSimplifiedGeometry(t)})}simplifyTransformed(e,t){return this.simplifyTransformedInternal(this.getRevision(),e,t)}clone(){return qe()}closestPointXY(e,t,i,r){return qe()}containsXY(e,t){return this.closestPointXY(e,t,pZ,Number.MIN_VALUE)===0}getClosestPoint(e,t){return t||=[NaN,NaN],this.closestPointXY(e[0],e[1],t,1/0),t}intersectsCoordinate(e){return this.containsXY(e[0],e[1])}computeExtent(e){return qe()}getExtent(e){if(this.extentRevision_!=this.getRevision()){let t=this.computeExtent(this.extent_);(isNaN(t[0])||isNaN(t[1]))&&om(t),this.extentRevision_=this.getRevision()}return EY(this.extent_,e)}rotate(e,t){qe()}scale(e,t,i){qe()}
2105simplify(e){return this.getSimplifiedGeometry(e*e)}getSimplifiedGeometry(e){return qe()}getType(){return qe()}applyTransform(e){qe()}intersectsExtent(e){return qe()}translate(e,t){qe()}transform(e,t){let i=Oi(e),r=i.getUnits()=="tile-pixels"?function(s,n,a){let o=i.getExtent(),l=i.getWorldExtent(),h=is(l)/is(o);So(II,l[0],l[3],h,-h,0,0,0);let u=Bl(s,0,s.length,a,II,n),d=ru(i,t);return d?d(u,u,a):u}:ru(i,t);return this.applyTransform(r),this}},fu=class extends mZ{constructor(){super(),this.layout="XY",this.stride=2,this.flatCoordinates}computeExtent(e){return VT(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,e)}getCoordinates(){return qe()}getFirstCoordinate(){return this.flatCoordinates.slice(0,this.stride)}getFlatCoordinates(){return this.flatCoordinates}getLastCoordinate(){return this.flatCoordinates.slice(this.flatCoordinates.length-this.stride)}getLayout(){return this.layout}getSimplifiedGeometry(e){if(this.simplifiedGeometryRevision!==this.getRevision()&&(this.simplifiedGeometryMaxMinSquaredTolerance=0,this.simplifiedGeometryRevision=this.getRevision()),e<0||this.simplifiedGeometryMaxMinSquaredTolerance!==0&&e<=this.simplifiedGeometryMaxMinSquaredTolerance)return this;let t=this.getSimplifiedGeometryInternal(e);return t.getFlatCoordinates().length<this.flatCoordinates.length?t:(this.simplifiedGeometryMaxMinSquaredTolerance=e,this)}getSimplifiedGeometryInternal(e){return this}getStride(){return this.stride}setFlatCoordinates(e,t){this.stride=FI(e),this.layout=e,this.flatCoordinates=t}setCoordinates(e,t){qe()}setLayout(e,t,i){let r;if(e)r=FI(e);else{for(let s=0;s<i;++s){if(t.length===0){this.layout="XY",this.stride=2;return}t=t[0]}r=t.length,e=gZ(r)}this.layout=e,this.stride=r}applyTransform(e){this.flatCoordinates&&(e(this.flatCoordinates,this.flatCoordinates,this.layout.startsWith("XYZ")?3:2,this.stride),this.changed())}rotate(e,t){let i=this.getFlatCoordinates();if(i){let r=this.getStride();kI(i,0,i.length,r,e,t,i),this.changed()}}scale(e,t,i){t===void 0&&(t=e),i||=Jh(this.getExtent());let r=this.getFlatCoordinates();if(r){let s=this.getStride();dZ(r,0,r.length,s,e,t,i,r),this.changed()}}translate(e,t){let i=this.getFlatCoordinates();if(i){let r=this.getStride();cZ(i,0,i.length,r,e,t,i),this.changed()}}};function gZ(e){let t;return e==2?t="XY":e==3?t="XYZ":e==4&&(t="XYZM"),t}function FI(e){let t;return e=="XY"?t=2:e=="XYZ"||e=="XYM"?t=3:e=="XYZM"&&(t=4),t}function fZ(e,t,i){let r=e.getFlatCoordinates();if(!r)return null;let s=e.getStride();return Bl(r,0,r.length,s,t,i)}function DI(e,t,i,r){let s=0,n=e[i-r],a=e[i-r+1],o=0,l=0;for(;t<i;t+=r){let h=e[t]-n,u=e[t+1]-a;s+=l*h-o*u,o=h,l=u}return s/2}function OI(e,t,i,r){let s=0;for(let n=0,a=i.length;n<a;++n){let o=i[n];s+=DI(e,t,o,r),t=o}return s}function yZ(e,t,i,r){let s=0;for(let n=0,a=i.length;n<a;++n){let o=i[n];s+=OI(e,t,o,r),t=o[o.length-1]}return s}function BI(e,t,i,r,s,n,a){let o=e[t],l=e[t+1],h=e[i]-o,u=e[i+1]-l,d;if(h===0&&u===0)d=t;else{let c=((s-o)*h+(n-l)*u)/(h*h+u*u);if(c>1)d=i;else if(c>0){for(let p=0;p<r;++p)a[p]=Es(e[t+p],e[i+p],c);a.length=r;return}else d=t}for(let c=0;c<r;++c)a[c]=e[d+c];a.length=r}function Sw(e,t,i,r,s){let n=e[t],a=e[t+1];for(t+=r;t<i;t+=r){let o=e[t],l=e[t+1],h=Qh(n,a,o,l);h>s&&(s=h),n=o,a=l}return s}function Mw(e,t,i,r,s){for(let n=0,a=i.length;n<a;++n){let o=i[n];s=Sw(e,t,o,r,s),t=o}return s}function xZ(e,t,i,r,s){for(let n=0,a=i.length;n<a;++n){let o=i[n];s=Mw(e,t,o,r,s),t=o[o.length-1]}return s}function Cw(e,t,i,r,s,n,a,o,l,h,u){if(t==i)return h;let d,c;if(s===0){if(c=Qh(a,o,e[t],e[t+1]),c<h){for(d=0;d<r;++d)l[d]=e[t+d];return l.length=r,c}return h}u||=[NaN,NaN];let p=t+r;for(;p<i;)if(BI(e,p-r,p,r,a,o,u),c=Qh(a,o,u[0],u[1]),c<h){for(h=c,d=0;d<r;++d)l[d]=u[d];l.length=r,p+=r}else p+=r*Math.max((Math.sqrt(c)-Math.sqrt(h))/s|0,1);if(n&&(BI(e,i-r,t,r,a,o,u),c=Qh(a,o,u[0],u[1]),c<h)){for(h=c,d=0;d<r;++d)l[d]=u[d];l.length=r}return h}function Rw(e,t,i,r,s,n,a,o,l,h,u){u||=[NaN,NaN];for(let d=0,c=i.length;d<c;++d){let p=i[d];h=Cw(e,t,p,r,s,n,a,o,l,h,u),t=p}return h}function vZ(e,t,i,r,s,n,a,o,l,h,u){u||=[NaN,NaN];
2105for(let d=0,c=i.length;d<c;++d){let p=i[d];h=Rw(e,t,p,r,s,n,a,o,l,h,u),t=p[p.length-1]}return h}function bZ(e,t,i,r){for(let s=0,n=i.length;s<n;++s)e[t++]=i[s];return t}function Gy(e,t,i,r){for(let s=0,n=i.length;s<n;++s){let a=i[s];for(let o=0;o<r;++o)e[t++]=a[o]}return t}function Ew(e,t,i,r,s){s||=[];let n=0;for(let a=0,o=i.length;a<o;++a){let l=Gy(e,t,i[a],r);s[n++]=l,t=l}return s.length=n,s}function _Z(e,t,i,r,s){s||=[];let n=0;for(let a=0,o=i.length;a<o;++a){let l=Ew(e,t,i[a],r,s[n]);l.length===0&&(l[0]=t),s[n++]=l,t=l[l.length-1]}return s.length=n,s}function Ul(e,t,i,r,s){s=s===void 0?[]:s;let n=0;for(let a=t;a<i;a+=r)s[n++]=e.slice(a,a+r);return s.length=n,s}function Tm(e,t,i,r,s){s=s===void 0?[]:s;let n=0;for(let a=0,o=i.length;a<o;++a){let l=i[a];s[n++]=Ul(e,t,l,r,s[n]),t=l}return s.length=n,s}function Aw(e,t,i,r,s){s=s===void 0?[]:s;let n=0;for(let a=0,o=i.length;a<o;++a){let l=i[a];s[n++]=l.length===1&&l[0]===t?[]:Tm(e,t,l,r,s[n]),t=l[l.length-1]}return s.length=n,s}function jy(e,t,i,r,s,n,a){let o=(i-t)/r;if(o<3){for(;t<i;t+=r)n[a++]=e[t],n[a++]=e[t+1];return a}let l=Array(o);l[0]=1,l[o-1]=1;let h=[t,i-r],u=0;for(;h.length>0;){let d=h.pop(),c=h.pop(),p=0,m=e[c],g=e[c+1],f=e[d],y=e[d+1];for(let x=c+r;x<d;x+=r){let b=e[x],_=e[x+1],T=kY(b,_,m,g,f,y);T>p&&(u=x,p=T)}p>s&&(l[(u-t)/r]=1,c+r<u&&h.push(c,u),u+r<d&&h.push(u,d))}for(let d=0;d<o;++d)l[d]&&(n[a++]=e[t+d*r],n[a++]=e[t+d*r+1]);return a}function UI(e,t,i,r,s,n,a,o){for(let l=0,h=i.length;l<h;++l){let u=i[l];a=jy(e,t,u,r,s,n,a),o.push(a),t=u}return a}function yu(e,t){return t*Math.round(e/t)}function TZ(e,t,i,r,s,n,a){if(t==i)return a;let o=yu(e[t],s),l=yu(e[t+1],s);t+=r,n[a++]=o,n[a++]=l;let h,u;do if(h=yu(e[t],s),u=yu(e[t+1],s),t+=r,t==i)return n[a++]=h,n[a++]=u,a;while(h==o&&u==l);for(;t<i;){let d=yu(e[t],s),c=yu(e[t+1],s);if(t+=r,d==h&&c==u)continue;let p=h-o,m=u-l,g=d-o,f=c-l;if(p*f==m*g&&(p<0&&g<p||p==g||p>0&&g>p)&&(m<0&&f<m||m==f||m>0&&f>m)){h=d,u=c;continue}n[a++]=h,n[a++]=u,o=h,l=u,h=d,u=c}return n[a++]=h,n[a++]=u,a}function Nw(e,t,i,r,s,n,a,o){for(let l=0,h=i.length;l<h;++l){let u=i[l];a=TZ(e,t,u,r,s,n,a),o.push(a),t=u}return a}function wZ(e,t,i,r,s,n,a,o){for(let l=0,h=i.length;l<h;++l){let u=i[l],d=[];a=Nw(e,t,u,r,s,n,a,d),o.push(d),t=u[u.length-1]}return a}var VI=class n2 extends fu{constructor(t,i){super(),this.maxDelta_=-1,this.maxDeltaRevision_=-1,i!==void 0&&!Array.isArray(t[0])?this.setFlatCoordinates(i,t):this.setCoordinates(t,i)}clone(){return new n2(this.flatCoordinates.slice(),this.layout)}closestPointXY(t,i,r,s){return s<Wd(this.getExtent(),t,i)?s:(this.maxDeltaRevision_!=this.getRevision()&&(this.maxDelta_=Math.sqrt(Sw(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),Cw(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,this.maxDelta_,!0,t,i,r,s))}getArea(){return DI(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getCoordinates(){return Ul(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getSimplifiedGeometryInternal(t){let i=[];return i.length=jy(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,t,i,0),new n2(i,"XY")}getType(){return"LinearRing"}intersectsExtent(t){return!1}setCoordinates(t,i){this.setLayout(i,t,1),this.flatCoordinates||=[],this.flatCoordinates.length=Gy(this.flatCoordinates,0,t,this.stride),this.changed()}},$y=class fO extends fu{constructor(t,i){super(),this.setCoordinates(t,i)}clone(){let t=new fO(this.flatCoordinates.slice(),this.layout);return t.applyProperties(this),t}closestPointXY(t,i,r,s){let n=this.flatCoordinates,a=Qh(t,i,n[0],n[1]);if(a<s){let o=this.stride;for(let l=0;l<o;++l)r[l]=n[l];return r.length=o,a}return s}getCoordinates(){return this.flatCoordinates.slice()}computeExtent(t){return _k(this.flatCoordinates,t)}getType(){return"Point"}intersectsExtent(t){return BT(t,this.flatCoordinates[0],this.flatCoordinates[1])}setCoordinates(t,i){this.setLayout(i,t,0),this.flatCoordinates||=[],this.flatCoordinates.length=bZ(this.flatCoordinates,0,t,this.stride),this.changed()}};function SZ(e,t,i,r,s){return!wk(s,function(n){return!xu(e,t,i,r,n[0],n[1])})}function xu(e,t,i,r,s,n){let a=0,o=e[i-r],l=e[i-r+1];for(;t<i;t+=r){let h=e[t],u=e[t+1];l<=n?u>n&&(h-o)*(n-l)-(s-o)*(u-l)>0&&a++:u<=n&&(h-o)*(n-l)-(s-o)*(u-l)<0&&a--,o=h,l=u}return a!==0}function Lw(e,t,i,r,s,n){if(i.length===0||!xu(e,t,i[0],r,s,n))return!1;for(let a=1,o=i.length;a<o;++a)if(xu(e,i[a-1],i[a],r,s,n))return!1;return!0}function MZ(e,t,i,r,s,n){if(i.length===0)return!1;for(let a=0,o=i.length;a<o;++a){let l=i[a];if(Lw(e,t,l,r,s,n))return!0;t=l[l.length-1]}return!1}function Pw(e,t,i,r,s,n,a){let o,l,h,u,d,c,p,m=s[n+1],g=[];for(let x=0,b=i.length;x<b;++x){let _=i[x];for(u=e[_-r],c=e[_-r+1],o=t;o<_;
2105o+=r)d=e[o],p=e[o+1],(m<=c&&p<=m||c<=m&&m<=p)&&(h=(m-c)/(p-c)*(d-u)+u,g.push(h)),u=d,c=p}let f=NaN,y=-1/0;for(g.sort(va),u=g[0],o=1,l=g.length;o<l;++o){d=g[o];let x=Math.abs(d-u);x>y&&(h=(u+d)/2,Lw(e,t,i,r,h,m)&&(f=h,y=x)),u=d}return isNaN(f)&&(f=s[n]),a?(a.push(f,m,y),a):[f,m,y]}function zI(e,t,i,r,s){let n=[];for(let a=0,o=i.length;a<o;++a){let l=i[a];n=Pw(e,t,l,r,s,2*a,n),t=l[l.length-1]}return n}function GI(e,t,i,r,s){let n;for(t+=r;t<i;t+=r)if(n=s(e.slice(t-r,t),e.slice(t,t+r)),n)return n;return!1}function Wy(e,t,i,r,s,n){return n??=Tk(ya(),e,t,i,r),Xi(s,n)?n[0]>=s[0]&&n[2]<=s[2]||n[1]>=s[1]&&n[3]<=s[3]?!0:GI(e,t,i,r,function(a,o){return AY(s,a,o)}):!1}function CZ(e,t,i,r,s){for(let n=0,a=i.length;n<a;++n){if(Wy(e,t,i[n],r,s))return!0;t=i[n]}return!1}function jI(e,t,i,r,s){return!!(Wy(e,t,i,r,s)||xu(e,t,i,r,s[0],s[1])||xu(e,t,i,r,s[0],s[3])||xu(e,t,i,r,s[2],s[1])||xu(e,t,i,r,s[2],s[3]))}function $I(e,t,i,r,s){if(!jI(e,t,i[0],r,s))return!1;if(i.length===1)return!0;for(let n=1,a=i.length;n<a;++n)if(SZ(e,i[n-1],i[n],r,s)&&!Wy(e,i[n-1],i[n],r,s))return!1;return!0}function RZ(e,t,i,r,s){for(let n=0,a=i.length;n<a;++n){let o=i[n];if($I(e,t,o,r,s))return!0;t=o[o.length-1]}return!1}function EZ(e,t,i,r){for(;t<i-r;){for(let s=0;s<r;++s){let n=e[t+s];e[t+s]=e[i-r+s],e[i-r+s]=n}t+=r,i-=r}}function kw(e,t,i,r){let s=0,n=e[i-r],a=e[i-r+1];for(;t<i;t+=r){let o=e[t],l=e[t+1];s+=(o-n)*(l+a),n=o,a=l}return s===0?void 0:s>0}function WI(e,t,i,r,s){s=s===void 0?!1:s;for(let n=0,a=i.length;n<a;++n){let o=i[n],l=kw(e,t,o,r);if(n===0){if(s&&l||!s&&!l)return!1}else if(s&&!l||!s&&l)return!1;t=o}return!0}function AZ(e,t,i,r,s){for(let n=0,a=i.length;n<a;++n){let o=i[n];if(!WI(e,t,o,r,s))return!1;o.length&&(t=o[o.length-1])}return!0}function Iw(e,t,i,r,s){s=s===void 0?!1:s;for(let n=0,a=i.length;n<a;++n){let o=i[n],l=kw(e,t,o,r);(n===0?s&&l||!s&&!l:s&&!l||!s&&l)&&EZ(e,t,o,r),t=o}return t}function HI(e,t,i,r,s){for(let n=0,a=i.length;n<a;++n)t=Iw(e,t,i[n],r,s);return t}function qI(e,t){let i=[],r=0,s=0,n;for(let a=0,o=t.length;a<o;++a){let l=t[a],h=kw(e,r,l,2);if(n===void 0&&(n=h),h===n)i.push(t.slice(s,a+1));else{if(i.length===0)continue;i[i.length-1].push(t[s])}s=a+1,r=l}return i}var wm=class a2 extends fu{constructor(t,i,r){super(),this.ends_=[],this.flatInteriorPointRevision_=-1,this.flatInteriorPoint_=null,this.maxDelta_=-1,this.maxDeltaRevision_=-1,this.orientedRevision_=-1,this.orientedFlatCoordinates_=null,i!==void 0&&r?(this.setFlatCoordinates(i,t),this.ends_=r):this.setCoordinates(t,i)}appendLinearRing(t){this.flatCoordinates?bo(this.flatCoordinates,t.getFlatCoordinates()):this.flatCoordinates=t.getFlatCoordinates().slice(),this.ends_.push(this.flatCoordinates.length),this.changed()}clone(){let t=new a2(this.flatCoordinates.slice(),this.layout,this.ends_.slice());return t.applyProperties(this),t}closestPointXY(t,i,r,s){return s<Wd(this.getExtent(),t,i)?s:(this.maxDeltaRevision_!=this.getRevision()&&(this.maxDelta_=Math.sqrt(Mw(this.flatCoordinates,0,this.ends_,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),Rw(this.flatCoordinates,0,this.ends_,this.stride,this.maxDelta_,!0,t,i,r,s))}containsXY(t,i){return Lw(this.getOrientedFlatCoordinates(),0,this.ends_,this.stride,t,i)}getArea(){return OI(this.getOrientedFlatCoordinates(),0,this.ends_,this.stride)}getCoordinates(t){let i;return t===void 0?i=this.flatCoordinates:(i=this.getOrientedFlatCoordinates().slice(),Iw(i,0,this.ends_,this.stride,t)),Tm(i,0,this.ends_,this.stride)}getEnds(){return this.ends_}getFlatInteriorPoint(){if(this.flatInteriorPointRevision_!=this.getRevision()){let t=Jh(this.getExtent());this.flatInteriorPoint_=Pw(this.getOrientedFlatCoordinates(),0,this.ends_,this.stride,t,0),this.flatInteriorPointRevision_=this.getRevision()}return this.flatInteriorPoint_}getInteriorPoint(){return new $y(this.getFlatInteriorPoint(),"XYM")}getLinearRingCount(){return this.ends_.length}getLinearRing(t){return t<0||this.ends_.length<=t?null:new VI(this.flatCoordinates.slice(t===0?0:this.ends_[t-1],this.ends_[t]),this.layout)}getLinearRings(){let t=this.layout,i=this.flatCoordinates,r=this.ends_,s=[],n=0;for(let a=0,o=r.length;a<o;++a){let l=r[a],h=new VI(i.slice(n,l),t);s.push(h),n=l}return s}getOrientedFlatCoordinates(){if(this.orientedRevision_!=this.getRevision()){let t=this.flatCoordinates;WI(t,0,this.ends_,this.stride)?this.orientedFlatCoordinates_=t:(this.orientedFlatCoordinates_=t.slice(),this.orientedFlatCoordinates_.length=Iw(this.orientedFlatCoordinates_,0,this.ends_,this.stride)),this.orientedRevision_=this.getRevision()}return this.orientedFlatCoordinates_}getSimplifiedGeometryInternal(t){let i=[],r=[];return i.length=Nw(this.flatCoordinates,0,this.ends_,this.stride,Math.sqrt(t),i,0,r),new a2(i,"XY",r)}getType(){return"Polygon"}intersectsExtent(t){return $I(this.getOrientedFlatCoordinates(),0,this.ends_,this.stride,t)}setCoordinates(t,i){this.setLayout(i,t,2),this.flatCoordinates||=[];let r=Ew(this.flatCoordinates,0,t,this.stride,this.ends_);this.flatCoordinates.length=r.length===0?0:r[r.length-1],this.changed()}};function XI(e){if(qd(e))throw Error("Cannot create polygon from empty extent");let t=e[0],i=e[1],r=e[2],s=e[3],n=[t,i,t,s,r,s,r,i,t,i];return new wm(n,"XY",[n.length])}function Fw(e,t,i,r){let s=Jt(t)/i[0],n=is(t)/i[1];return r?Math.min(e,Math.max(s,n)):Math.min(e,Math.min(s,n))}function Dw(e,t,i){let r=Math.min(e,t);return r*=Math.log(1+50*Math.max(0,e/t-1))/50+1,i&&(r=Math.max(r,
2105i),r/=Math.log(1+50*Math.max(0,i/e-1))/50+1),ri(r,i/2,t*2)}function NZ(e,t,i,r){return t=t===void 0?!0:t,(function(s,n,a,o){if(s!==void 0){let l=e[0],h=e[e.length-1],u=i?Fw(l,i,a,r):l;if(o)return t?Dw(s,u,h):ri(s,h,u);let d=Math.floor(iw(e,Math.min(u,s),n));return e[d]>u&&d<e.length-1?e[d+1]:e[d]}})}function LZ(e,t,i,r,s,n){return r=r===void 0?!0:r,i=i===void 0?0:i,(function(a,o,l,h){if(a!==void 0){let u=s?Fw(t,s,l,n):t;if(h)return r?Dw(a,u,i):ri(a,i,u);let d=1e-9,c=Math.ceil(Math.log(t/u)/Math.log(e)-d),p=-o*(.5-d)+.5,m=Math.floor(Math.log(t/Math.min(u,a))/Math.log(e)+p);return ri(t/e**+Math.max(c,m),i,u)}})}function YI(e,t,i,r,s){return i=i===void 0?!0:i,(function(n,a,o,l){if(n!==void 0){let h=r?Fw(e,r,o,s):e;return!i||!l?ri(n,t,h):Dw(n,h,t)}})}function Ow(e){if(e!==void 0)return 0}function KI(e){if(e!==void 0)return e}function PZ(e){let t=2*Math.PI/e;return(function(i,r){if(r)return i;if(i!==void 0)return i=Math.floor(i/t+.5)*t,i})}function kZ(e){let t=e===void 0?Rl(5):e;return(function(i,r){return r||i===void 0?i:Math.abs(i)<=t?0:i})}var Bw=0,Ta=class extends _a{constructor(e){super(),this.on,this.once,this.un,e=Object.assign({},e),this.hints_=[0,0],this.animations_=[],this.updateAnimationKey_,this.projection_=JT(e.projection,"EPSG:3857"),this.viewportSize_=[100,100],this.targetCenter_=null,this.targetResolution_,this.targetRotation_,this.nextCenter_=null,this.nextResolution_,this.nextRotation_,this.cancelAnchor_=void 0,e.projection&&Gk(),e.center&&=vo(e.center,this.projection_),e.extent&&=su(e.extent,this.projection_),this.applyOptions_(e)}applyOptions_(e){let t=Object.assign({},e);for(let a in Sn)delete t[a];this.setProperties(t,!0);let i=FZ(e);this.maxResolution_=i.maxResolution,this.minResolution_=i.minResolution,this.zoomFactor_=i.zoomFactor,this.resolutions_=e.resolutions,this.padding_=e.padding,this.minZoom_=i.minZoom;let r=IZ(e),s=i.constraint,n=DZ(e);this.constraints_={center:r,resolution:s,rotation:n},this.setRotation(e.rotation===void 0?0:e.rotation),this.setCenterInternal(e.center===void 0?null:e.center),e.resolution===void 0?e.zoom!==void 0&&this.setZoom(e.zoom):this.setResolution(e.resolution)}get padding(){return this.padding_}set padding(e){let t=this.padding_;this.padding_=e;let i=this.getCenterInternal();if(i){let r=e||[0,0,0,0];t||=[0,0,0,0];let s=this.getResolution(),n=s/2*(r[3]-t[3]+t[1]-r[1]),a=s/2*(r[0]-t[0]+t[2]-r[2]);this.setCenterInternal([i[0]+n,i[1]-a])}}getUpdatedOptions_(e){let t=this.getProperties();return t.resolution===void 0?t.zoom=this.getZoom():t.resolution=this.getResolution(),t.center=this.getCenterInternal(),t.rotation=this.getRotation(),Object.assign({},t,e)}animate(e){this.isDef()&&!this.getAnimating()&&this.resolveConstraints(0);let t=Array(arguments.length);for(let i=0;i<t.length;++i){let r=arguments[i];r.center&&(r=Object.assign({},r),r.center=vo(r.center,this.getProjection())),r.anchor&&(r=Object.assign({},r),r.anchor=vo(r.anchor,this.getProjection())),t[i]=r}this.animateInternal.apply(this,t)}animateInternal(e){let t=arguments.length,i;t>1&&typeof arguments[t-1]=="function"&&(i=arguments[t-1],--t);let r=0;for(;r<t&&!this.isDef();++r){let h=arguments[r];h.center&&this.setCenterInternal(h.center),h.zoom===void 0?h.resolution&&this.setResolution(h.resolution):this.setZoom(h.zoom),h.rotation!==void 0&&this.setRotation(h.rotation)}if(r===t){i&&Hy(i,!0);return}let s=Date.now(),n=this.targetCenter_.slice(),a=this.targetResolution_,o=this.targetRotation_,l=[];for(;r<t;++r){let h=arguments[r],u={start:s,complete:!1,anchor:h.anchor,duration:h.duration===void 0?1e3:h.duration,easing:h.easing||rZ,callback:i};if(h.center&&(u.sourceCenter=n,u.targetCenter=h.center.slice(),n=u.targetCenter),h.zoom===void 0?h.resolution&&(u.sourceResolution=a,u.targetResolution=h.resolution,a=u.targetResolution):(u.sourceResolution=a,u.targetResolution=this.getResolutionForZoom(h.zoom),a=u.targetResolution),h.rotation!==void 0){u.sourceRotation=o;let d=eu(h.rotation-o+Math.PI,2*Math.PI)-Math.PI;u.targetRotation=o+d,o=u.targetRotation}OZ(u)?u.complete=!0:s+=u.duration,l.push(u)}this.animations_.push(l),this.setHint(ar.ANIMATING,1),this.updateAnimations_()}getAnimating(){return this.hints_[ar.ANIMATING]>0}getInteracting(){return this.hints_[ar.INTERACTING]>0}cancelAnimations(){this.setHint(ar.ANIMATING,-this.hints_[ar.ANIMATING]);let e;for(let t=0,i=this.animations_.length;t<i;++t){let r=this.animations_[t];if(r[0].callback&&Hy(r[0].callback,!1),!e)for(let s=0,n=r.length;s<n;++s){let a=r[s];if(!a.complete){e=a.anchor;break}}}this.animations_.length=0,this.cancelAnchor_=e,this.nextCenter_=null,this.nextResolution_=NaN,this.nextRotation_=NaN}updateAnimations_(){if(this.updateAnimationKey_!==void 0&&(cancelAnimationFrame(this.updateAnimationKey_),this.updateAnimationKey_=void 0),!this.getAnimating())return;let e=Date.now(),t=!1;for(let i=this.animations_.length-1;i>=0;--i){let r=this.animations_[i],s=!0;for(let n=0,a=r.length;n<a;++n){let o=r[n];if(o.complete)continue;let l=e-o.start,h=o.duration>0?l/o.duration:1;h>=1?(o.complete=!0,h=1):s=!1;let u=o.easing(h);if(o.sourceCenter){let d=o.sourceCenter[0],c=o.sourceCenter[1],p=o.targetCenter[0],m=o.targetCenter[1];this.nextCenter_=o.targetCenter;let g=d+u*(p-d),f=c+u*(m-c);this.targetCenter_=[g,f]}if(o.sourceResolution&&o.targetResolution){let d=u===1?o.targetResolution:o.sourceResolution+u*(o.targetResolution-o.sourceResolution);if(o.anchor){let c=this.getViewportSize_(this.getRotation()),p=this.constraints_.resolution(d,0,c,!0);
2105this.targetCenter_=this.calculateCenterZoom(p,o.anchor)}this.nextResolution_=o.targetResolution,this.targetResolution_=d,this.applyTargetState_(!0)}if(o.sourceRotation!==void 0&&o.targetRotation!==void 0){let d=u===1?eu(o.targetRotation+Math.PI,2*Math.PI)-Math.PI:o.sourceRotation+u*(o.targetRotation-o.sourceRotation);if(o.anchor){let c=this.constraints_.rotation(d,!0);this.targetCenter_=this.calculateCenterRotate(c,o.anchor)}this.nextRotation_=o.targetRotation,this.targetRotation_=d}if(this.applyTargetState_(!0),t=!0,!o.complete)break}if(s){this.animations_[i]=null,this.setHint(ar.ANIMATING,-1),this.nextCenter_=null,this.nextResolution_=NaN,this.nextRotation_=NaN;let n=r[0].callback;n&&Hy(n,!0)}}this.animations_=this.animations_.filter(Boolean),t&&this.updateAnimationKey_===void 0&&(this.updateAnimationKey_=requestAnimationFrame(this.updateAnimations_.bind(this)))}calculateCenterRotate(e,t){let i,r=this.getCenterInternal();return r!==void 0&&(i=[r[0]-t[0],r[1]-t[1]],$T(i,e-this.getRotation()),FY(i,t)),i}calculateCenterZoom(e,t){let i,r=this.getCenterInternal(),s=this.getResolution();return r!==void 0&&s!==void 0&&(i=[t[0]-e*(t[0]-r[0])/s,t[1]-e*(t[1]-r[1])/s]),i}getViewportSize_(e){let t=this.viewportSize_;if(e){let i=t[0],r=t[1];return[Math.abs(i*Math.cos(e))+Math.abs(r*Math.sin(e)),Math.abs(i*Math.sin(e))+Math.abs(r*Math.cos(e))]}return t}setViewportSize(e){this.viewportSize_=Array.isArray(e)?e.slice():[100,100],this.getAnimating()||this.resolveConstraints(0)}getCenter(){let e=this.getCenterInternal();return e&&tw(e,this.getProjection())}getCenterInternal(){return this.get(Sn.CENTER)}getConstraints(){return this.constraints_}getConstrainResolution(){return this.get("constrainResolution")}getHints(e){return e===void 0?this.hints_.slice():(e[0]=this.hints_[0],e[1]=this.hints_[1],e)}calculateExtent(e){return Hk(this.calculateExtentInternal(e),this.getProjection())}calculateExtentInternal(e){e||=this.getViewportSizeMinusPadding_();let t=this.getCenterInternal();It(t,"The view center is not defined");let i=this.getResolution();It(i!==void 0,"The view resolution is not defined");let r=this.getRotation();return It(r!==void 0,"The view rotation is not defined"),GT(t,i,r,e)}getMaxResolution(){return this.maxResolution_}getMinResolution(){return this.minResolution_}getMaxZoom(){return this.getZoomForResolution(this.minResolution_)}setMaxZoom(e){this.applyOptions_(this.getUpdatedOptions_({maxZoom:e}))}getMinZoom(){return this.getZoomForResolution(this.maxResolution_)}setMinZoom(e){this.applyOptions_(this.getUpdatedOptions_({minZoom:e}))}setConstrainResolution(e){this.applyOptions_(this.getUpdatedOptions_({constrainResolution:e}))}getProjection(){return this.projection_}getResolution(){return this.get(Sn.RESOLUTION)}getResolutions(){return this.resolutions_}getResolutionForExtent(e,t){return this.getResolutionForExtentInternal(su(e,this.getProjection()),t)}getResolutionForExtentInternal(e,t){t||=this.getViewportSizeMinusPadding_();let i=Jt(e)/t[0],r=is(e)/t[1];return Math.max(i,r)}getResolutionForValueFunction(e){e||=2;let t=this.getConstrainedResolution(this.maxResolution_),i=this.minResolution_,r=Math.log(t/i)/Math.log(e);return(function(s){return t/e**+(s*r)})}getRotation(){return this.get(Sn.ROTATION)}getValueForResolutionFunction(e){let t=Math.log(e||2),i=this.getConstrainedResolution(this.maxResolution_),r=this.minResolution_,s=Math.log(i/r)/t;return(function(n){return Math.log(i/n)/t/s})}getViewportSizeMinusPadding_(e){let t=this.getViewportSize_(e),i=this.padding_;return i&&(t=[t[0]-i[1]-i[3],t[1]-i[0]-i[2]]),t}getState(){let e=this.getProjection(),t=this.getResolution(),i=this.getRotation(),r=this.getCenterInternal(),s=this.padding_;if(s){let n=this.getViewportSizeMinusPadding_();r=Uw(r,this.getViewportSize_(),[n[0]/2+s[3],n[1]/2+s[0]],t,i)}return{center:r.slice(0),projection:e===void 0?null:e,resolution:t,nextCenter:this.nextCenter_,nextResolution:this.nextResolution_,nextRotation:this.nextRotation_,rotation:i,zoom:this.getZoom()}}getViewStateAndExtent(){return{viewState:this.getState(),extent:this.calculateExtent()}}getZoom(){let e,t=this.getResolution();return t!==void 0&&(e=this.getZoomForResolution(t)),e}getZoomForResolution(e){let t=this.minZoom_||0,i,r;if(this.resolutions_){let s=iw(this.resolutions_,e,1);t=s,i=this.resolutions_[s],r=s==this.resolutions_.length-1?2:i/this.resolutions_[s+1]}else i=this.maxResolution_,r=this.zoomFactor_;return t+Math.log(i/e)/Math.log(r)}getResolutionForZoom(e){if(this.resolutions_?.length){if(this.resolutions_.length===1)return this.resolutions_[0];let t=ri(Math.floor(e),0,this.resolutions_.length-2),i=this.resolutions_[t]/this.resolutions_[t+1];return this.resolutions_[t]/i**+ri(e-t,0,1)}return this.maxResolution_/this.zoomFactor_**+(e-this.minZoom_)}
2105fit(e,t){let i;if(It(Array.isArray(e)||typeof e.getSimplifiedGeometry=="function","Invalid extent or geometry provided as `geometry`"),Array.isArray(e))It(!qd(e),"Cannot fit empty extent provided as `geometry`"),i=XI(su(e,this.getProjection()));else if(e.getType()==="Circle"){let r=su(e.getExtent(),this.getProjection());i=XI(r),i.rotate(this.getRotation(),Jh(r))}else{let r=Wk();i=r?e.clone().transform(r,this.getProjection()):e}this.fitInternal(i,t)}rotatedExtentForGeometry(e){let t=this.getRotation(),i=Math.cos(t),r=Math.sin(-t),s=e.getFlatCoordinates(),n=e.getStride(),a=1/0,o=1/0,l=-1/0,h=-1/0;for(let u=0,d=s.length;u<d;u+=n){let c=s[u]*i-s[u+1]*r,p=s[u]*r+s[u+1]*i;a=Math.min(a,c),o=Math.min(o,p),l=Math.max(l,c),h=Math.max(h,p)}return[a,o,l,h]}fitInternal(e,t){t||={};let i=t.size;i||=this.getViewportSizeMinusPadding_();let r=t.padding===void 0?[0,0,0,0]:t.padding,s=t.nearest===void 0?!1:t.nearest,n;n=t.minResolution===void 0?t.maxZoom===void 0?0:this.getResolutionForZoom(t.maxZoom):t.minResolution;let a=this.rotatedExtentForGeometry(e),o=this.getResolutionForExtentInternal(a,[i[0]-r[1]-r[3],i[1]-r[0]-r[2]]);o=isNaN(o)?n:Math.max(o,n),o=this.getConstrainedResolution(o,+!s);let l=this.getRotation(),h=Math.sin(l),u=Math.cos(l),d=Jh(a);d[0]+=(r[1]-r[3])/2*o,d[1]+=(r[0]-r[2])/2*o;let c=d[0]*u-d[1]*h,p=d[1]*u+d[0]*h,m=this.getConstrainedCenter([c,p],o),g=t.callback?t.callback:Ly;t.duration===void 0?(this.targetResolution_=o,this.targetCenter_=m,this.applyTargetState_(!1,!0),Hy(g,!0)):this.animateInternal({resolution:o,center:m,duration:t.duration,easing:t.easing},g)}centerOn(e,t,i){this.centerOnInternal(vo(e,this.getProjection()),t,i)}centerOnInternal(e,t,i){this.setCenterInternal(Uw(e,t,i,this.getResolution(),this.getRotation()))}calculateCenterShift(e,t,i,r){let s,n=this.padding_;if(n&&e){let a=this.getViewportSizeMinusPadding_(-i),o=Uw(e,r,[a[0]/2+n[3],a[1]/2+n[0]],t,i);s=[e[0]-o[0],e[1]-o[1]]}return s}isDef(){return!!this.getCenterInternal()&&this.getResolution()!==void 0}adjustCenter(e){let t=tw(this.targetCenter_,this.getProjection());this.setCenter([t[0]+e[0],t[1]+e[1]])}adjustCenterInternal(e){let t=this.targetCenter_;this.setCenterInternal([t[0]+e[0],t[1]+e[1]])}adjustResolution(e,t){t&&=vo(t,this.getProjection()),this.adjustResolutionInternal(e,t)}adjustResolutionInternal(e,t){let i=this.getAnimating()||this.getInteracting(),r=this.getViewportSize_(this.getRotation()),s=this.constraints_.resolution(this.targetResolution_*e,0,r,i);t&&(this.targetCenter_=this.calculateCenterZoom(s,t)),this.targetResolution_*=e,this.applyTargetState_()}adjustZoom(e,t){this.adjustResolution(this.zoomFactor_**+-e,t)}adjustRotation(e,t){t&&=vo(t,this.getProjection()),this.adjustRotationInternal(e,t)}adjustRotationInternal(e,t){let i=this.getAnimating()||this.getInteracting(),r=this.constraints_.rotation(this.targetRotation_+e,i);t&&(this.targetCenter_=this.calculateCenterRotate(r,t)),this.targetRotation_+=e,this.applyTargetState_()}setCenter(e){this.setCenterInternal(e&&vo(e,this.getProjection()))}setCenterInternal(e){this.targetCenter_=e,this.applyTargetState_()}setHint(e,t){return this.hints_[e]+=t,this.changed(),this.hints_[e]}setResolution(e){this.targetResolution_=e,this.applyTargetState_()}setRotation(e){this.targetRotation_=e,this.applyTargetState_()}setZoom(e){this.setResolution(this.getResolutionForZoom(e))}applyTargetState_(e,t){let i=this.getAnimating()||this.getInteracting()||t,r=this.constraints_.rotation(this.targetRotation_,i),s=this.getViewportSize_(r),n=this.constraints_.resolution(this.targetResolution_,0,s,i),a=this.constraints_.center(this.targetCenter_,n,s,i,this.calculateCenterShift(this.targetCenter_,n,r,s));this.get(Sn.ROTATION)!==r&&this.set(Sn.ROTATION,r),this.get(Sn.RESOLUTION)!==n&&(this.set(Sn.RESOLUTION,n),this.set("zoom",this.getZoom(),!0)),(!a||!this.get(Sn.CENTER)||!by(this.get(Sn.CENTER),a))&&this.set(Sn.CENTER,a),this.getAnimating()&&!e&&this.cancelAnimations(),this.cancelAnchor_=void 0}resolveConstraints(e,t,i){e=e===void 0?200:e;let r=t||0,s=this.constraints_.rotation(this.targetRotation_),n=this.getViewportSize_(s),a=this.constraints_.resolution(this.targetResolution_,r,n),o=this.constraints_.center(this.targetCenter_,a,n,!1,this.calculateCenterShift(this.targetCenter_,a,s,n));if(e===0&&!this.cancelAnchor_){this.targetResolution_=a,this.targetRotation_=s,this.targetCenter_=o,this.applyTargetState_();return}i||=e===0?this.cancelAnchor_:void 0,this.cancelAnchor_=void 0,(this.getResolution()!==a||this.getRotation()!==s||!this.getCenterInternal()||!by(this.getCenterInternal(),o))&&(this.getAnimating()&&this.cancelAnimations(),this.animateInternal({rotation:s,center:o,resolution:a,duration:e,easing:sc,anchor:i}))}beginInteraction(){this.resolveConstraints(0),this.setHint(ar.INTERACTING,1)}endInteraction(e,t,i){i&&=vo(i,this.getProjection()),this.endInteractionInternal(e,t,i)}endInteractionInternal(e,t,i){this.getInteracting()&&(this.setHint(ar.INTERACTING,-1),this.resolveConstraints(e,t,i))}getConstrainedCenter(e,t){let i=this.getViewportSize_(this.getRotation());return this.constraints_.center(e,t||this.getResolution(),i)}getConstrainedZoom(e,t){let i=this.getResolutionForZoom(e);return this.getZoomForResolution(this.getConstrainedResolution(i,t))}getConstrainedResolution(e,t){t||=0;let i=this.getViewportSize_(this.getRotation());return this.constraints_.resolution(e,t,i)}};function Hy(e,t){setTimeout(function(){e(t)},0)}function IZ(e){if(e.extent!==void 0){let i=e.smoothExtentConstraint===void 0?!0:e.smoothExtentConstraint;return EI(e.extent,e.constrainOnlyCenter,i)}let t=JT(e.projection,"EPSG:3857");if(e.multiWorld!==!0&&t.isGlobal()){let i=t.getExtent().slice();return i[0]=-1/0,i[2]=1/0,EI(i,!1,!1)}return iZ}function FZ(e){let t,i,r,s=e.minZoom===void 0?Bw:e.minZoom,n=e.maxZoom===void 0?28:e.maxZoom,a=e.zoomFactor===void 0?2:e.zoomFactor,o=e.multiWorld===void 0?!1:e.multiWorld,l=e.smoothResolutionConstraint===void 0?!0:e.smoothResolutionConstraint,h=e.showFullExtent===void 0?!1:e.showFullExtent,u=JT(e.projection,"EPSG:3857"),d=u.getExtent(),c=e.constrainOnlyCenter,p=e.extent;if(!o&&!p&&u.isGlobal()&&(c=!1,p=d),e.resolutions!==void 0){let m=e.resolutions;i=m[s],r=m[n]===void 0?m[m.length-1]:m[n],t=e.constrainResolution?NZ(m,l,!c&&p,h):YI(i,r,l,!c&&p,h)}else{let m=(d?Math.max(Jt(d),is(d)):360*hm.degrees/u.getMetersPerUnit())/256/2**Bw,g=m/2**(28-Bw);i=e.maxResolution,i===void 0?i=m/a**+s:s=0,r=e.minResolution,r===void 0&&(r=e.maxZoom===void 0?g:e.maxResolution===void 0?m/a**+n:i/a**+n),n=s+Math.floor(Math.log(i/r)/Math.log(a)),r=i/a**+(n-s),t=e.constrainResolution?LZ(a,i,r,l,!c&&p,h):YI(i,r,l,!c&&p,h)}return{constraint:t,maxResolution:i,minResolution:r,minZoom:s,zoomFactor:a}}function DZ(e){if(e.enableRotation===void 0||e.enableRotation){let t=e.constrainRotation;return t===void 0||t===!0?kZ():t===!1?KI:typeof t=="number"?PZ(t):KI}return Ow}function OZ(e){return!(e.sourceCenter&&e.targetCenter&&!by(e.sourceCenter,e.targetCenter)||e.sourceResolution!==e.targetResolution||e.sourceRotation!==e.targetRotation)}function Uw(e,t,i,r,s){let n=Math.cos(-s),a=Math.sin(-s),o=e[0]*n-e[1]*a,l=e[1]*n+e[0]*a;return o+=(t[0]/2-i[0])*r,l+=(i[1]-t[1]/2)*r,a=-a,[o*n-l*a,l*n+o*a]}var qy="ol-hidden",Xy="ol-unselectable",Vw="ol-control",ZI="ol-collapsed",BZ=new RegExp(["^\\s*(?=(?
2105:(?:[-a-z]+\\s*){0,2}(italic|oblique))?)","(?=(?:(?:[-a-z]+\\s*){0,2}(small-caps))?)","(?=(?:(?:[-a-z]+\\s*){0,2}(bold(?:er)?|lighter|[1-9]00 ))?)","(?:(?:normal|\\1|\\2|\\3)\\s*){0,3}((?:xx?-)?","(?:small|large)|medium|smaller|larger|[\\.\\d]+(?:\\%|in|[cem]m|ex|p[ctx]))","(?:\\s*\\/\\s*(normal|[\\.\\d]+(?:\\%|in|[cem]m|ex|p[ctx])?))",`?\\s*([-,\\"\\'\\sa-z0-9]+?)\\s*$`].join(""),"i"),JI=["style","variant","weight","size","lineHeight","family"],zw={normal:400,bold:700},Gw=function(e){let t=e.match(BZ);if(!t)return null;let i={lineHeight:"normal",size:"1.2em",style:"normal",weight:"400",variant:"normal"};for(let r=0,s=JI.length;r<s;++r){let n=t[r+1];n!==void 0&&(i[JI[r]]=typeof n=="string"?n.trim():n)}return isNaN(Number(i.weight))&&i.weight in zw&&(i.weight=zw[i.weight]),i.families=i.family.split(/,\s?/).map(r=>r.trim().replace(/^['"]|['"]$/g,"")),i};function Ui(e,t,i,r){let s;return s=i&&i.length?i.shift():Js?new class extends OffscreenCanvas{style={}}(e??300,t??150):document.createElement("canvas"),e&&(s.width=e),t&&(s.height=t),s.getContext("2d",r)}var QI;function Yy(){return QI||=Ui(1,1),QI}function Ky(e){let t=e.canvas;t.width=1,t.height=1,e.clearRect(0,0,1,1)}function eF(e,t){let i=t.parentNode;i&&i.replaceChild(e,t)}function UZ(e){for(;e.lastChild;)e.lastChild.remove()}function VZ(e,t){let i=e.childNodes;for(let r=0;;++r){let s=i[r],n=t[r];
2105if(!s&&!n)break;if(s!==n){if(!s){e.appendChild(n);continue}if(!n){e.removeChild(s),--r;continue}e.insertBefore(n,s)}}}function tF(){return new Proxy({childNodes:[],appendChild:function(e){return this.childNodes.push(e),e},remove:function(){},removeChild:function(e){let t=this.childNodes.indexOf(e);if(t===-1)throw Error("Node to remove was not found");return this.childNodes.splice(t,1),e},insertBefore:function(e,t){let i=this.childNodes.indexOf(t);if(i===-1)throw Error("Reference node not found");return this.childNodes.splice(i,0,e),e},style:{}},{get(e,t,i){return t==="firstElementChild"?e.childNodes.length>0?e.childNodes[0]:null:Reflect.get(e,t,i)}})}function Vl(e){return typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&e instanceof OffscreenCanvas}var jw=class extends _a{constructor(e){super();let t=e.element;t&&!e.target&&!t.style.pointerEvents&&(t.style.pointerEvents="auto"),this.element=t||null,this.target_=null,this.map_=null,this.listenerKeys=[],e.render&&(this.render=e.render),e.target&&this.setTarget(e.target)}disposeInternal(){this.element?.remove(),super.disposeInternal()}getMap(){return this.map_}setMap(e){this.map_&&this.element?.remove();for(let t=0,i=this.listenerKeys.length;t<i;++t)oi(this.listenerKeys[t]);if(this.listenerKeys.length=0,this.map_=e,e){let t=this.target_??e.getOverlayContainerStopEvent();this.element&&t.appendChild(this.element),this.render!==Ly&&this.listenerKeys.push(ft(e,Ol.POSTRENDER,this.render,this)),e.render()}}render(e){}setTarget(e){this.target_=typeof e=="string"?document.getElementById(e):e}},zZ=class extends jw{constructor(e){e||={},super({element:document.createElement("div"),render:e.render,target:e.target}),this.ulElement_=document.createElement("ul"),this.collapsed_=e.collapsed===void 0?!0:e.collapsed,this.userCollapsed_=this.collapsed_,this.overrideCollapsible_=e.collapsible!==void 0,this.collapsible_=e.collapsible===void 0?!0:e.collapsible,this.collapsible_||(this.collapsed_=!1),this.attributions_=e.attributions;let t=e.className===void 0?"ol-attribution":e.className,i=e.tipLabel===void 0?"Attributions":e.tipLabel,r=e.expandClassName===void 0?t+"-expand":e.expandClassName,s=e.collapseLabel===void 0?"\u203A":e.collapseLabel,n=e.collapseClassName===void 0?t+"-collapse":e.collapseClassName;typeof s=="string"?(this.collapseLabel_=document.createElement("span"),this.collapseLabel_.textContent=s,this.collapseLabel_.className=n):this.collapseLabel_=s;let a=e.label===void 0?"i":e.label;typeof a=="string"?(this.label_=document.createElement("span"),this.label_.textContent=a,this.label_.className=r):this.label_=a;let o=this.collapsible_&&!this.collapsed_?this.collapseLabel_:this.label_;this.toggleButton_=document.createElement("button"),this.toggleButton_.setAttribute("type","button"),this.toggleButton_.setAttribute("aria-expanded",String(!this.collapsed_)),this.toggleButton_.title=i,this.toggleButton_.appendChild(o),this.toggleButton_.addEventListener(De.CLICK,this.handleClick_.bind(this),!1);let l=t+" "+Xy+" "+Vw+(this.collapsed_&&this.collapsible_?" "+ZI:"")+(this.collapsible_?"":" ol-uncollapsible"),h=this.element;h.className=l,h.appendChild(this.toggleButton_),h.appendChild(this.ulElement_),this.renderedAttributions_=[],this.renderedVisible_=!0}collectSourceAttributions_(e){let t=this.getMap().getAllLayers(),i=new Set(t.flatMap(r=>r.getAttributions(e)));if(this.attributions_!==void 0&&(Array.isArray(this.attributions_)?this.attributions_.forEach(r=>i.add(r)):i.add(this.attributions_)),!this.overrideCollapsible_){let r=!t.some(s=>s.getSource()?.getAttributionsCollapsible()===!1);this.setCollapsible(r)}return Array.from(i)}async updateElement_(e){if(!e){this.renderedVisible_&&=(this.element.style.display="none",!1);return}let t=await Promise.all(this.collectSourceAttributions_(e).map(r=>vK(()=>r))),i=t.length>0;if(this.renderedVisible_!=i&&(this.element.style.display=i?"":"none",this.renderedVisible_=i),!nu(t,this.renderedAttributions_)){UZ(this.ulElement_);for(let r=0,s=t.length;r<s;++r){let n=document.createElement("li");n.innerHTML=t[r],this.ulElement_.appendChild(n)}this.renderedAttributions_=t}}handleClick_(e){e.preventDefault(),this.handleToggle_(),this.userCollapsed_=this.collapsed_}handleToggle_(){this.element.classList.toggle(ZI),this.collapsed_?eF(this.collapseLabel_,this.label_):eF(this.label_,this.collapseLabel_),this.collapsed_=!this.collapsed_,this.toggleButton_.setAttribute("aria-expanded",String(!this.collapsed_))}getCollapsible(){return this.collapsible_}setCollapsible(e){this.collapsible_!==e&&(this.collapsible_=e,this.element.classList.toggle("ol-uncollapsible"),this.userCollapsed_&&this.handleToggle_())}setCollapsed(e){this.userCollapsed_=e,!(!this.collapsible_||this.collapsed_===e)&&this.handleToggle_()}getCollapsed(){return this.collapsed_}render(e){this.updateElement_(e.frameState)}},GZ=class extends jw{constructor(e){e||={},super({element:document.createElement("div"),render:e.render,target:e.target});let t=e.className===void 0?"ol-rotate":e.className,i=e.label===void 0?"\u21E7":e.label,r=e.compassClassName===void 0?"ol-compass":e.compassClassName;this.label_=null,typeof i=="string"?(this.label_=document.createElement("span"),this.label_.className=r,this.label_.textContent=i):(this.label_=i,this.label_.classList.add(r));let s=e.tipLabel?e.tipLabel:"Reset rotation",n=document.createElement("button");n.className=t+"-reset",n.setAttribute("type","button"),n.title=s,n.appendChild(this.label_),n.addEventListener(
2105De.CLICK,this.handleClick_.bind(this),!1);let a=t+" "+Xy+" "+Vw,o=this.element;o.className=a,o.appendChild(n),this.callResetNorth_=e.resetNorth?e.resetNorth:void 0,this.duration_=e.duration===void 0?250:e.duration,this.autoHide_=e.autoHide===void 0?!0:e.autoHide,this.rotation_=void 0,this.autoHide_&&this.element.classList.add(qy)}handleClick_(e){e.preventDefault(),this.callResetNorth_===void 0?this.resetNorth_():this.callResetNorth_()}resetNorth_(){let e=this.getMap().getView();if(!e)return;let t=e.getRotation();t!==void 0&&(this.duration_>0&&t%(2*Math.PI)!=0?e.animate({rotation:0,duration:this.duration_,easing:sc}):e.setRotation(0))}render(e){let t=e.frameState;if(!t)return;let i=t.viewState.rotation;if(i!=this.rotation_){let r="rotate("+i+"rad)";if(this.autoHide_){let s=this.element.classList.contains(qy);!s&&i===0?this.element.classList.add(qy):s&&i!==0&&this.element.classList.remove(qy)}this.label_.style.transform=r}this.rotation_=i}},jZ=class extends jw{constructor(e){e||={},super({element:document.createElement("div"),target:e.target});let t=e.className===void 0?"ol-zoom":e.className,i=e.delta===void 0?1:e.delta,r=e.zoomInClassName===void 0?t+"-in":e.zoomInClassName,s=e.zoomOutClassName===void 0?t+"-out":e.zoomOutClassName,n=e.zoomInLabel===void 0?"+":e.zoomInLabel,a=e.zoomOutLabel===void 0?"\u2013":e.zoomOutLabel,o=e.zoomInTipLabel===void 0?"Zoom in":e.zoomInTipLabel,l=e.zoomOutTipLabel===void 0?"Zoom out":e.zoomOutTipLabel,h=document.createElement("button");h.className=r,h.setAttribute("type","button"),h.title=o,h.appendChild(typeof n=="string"?document.createTextNode(n):n),h.addEventListener(De.CLICK,this.handleClick_.bind(this,i),!1);let u=document.createElement("button");u.className=s,u.setAttribute("type","button"),u.title=l,u.appendChild(typeof a=="string"?document.createTextNode(a):a),u.addEventListener(De.CLICK,this.handleClick_.bind(this,-i),!1);let d=t+" "+Xy+" "+Vw,c=this.element;c.className=d,c.appendChild(h),c.appendChild(u),this.duration_=e.duration===void 0?250:e.duration}handleClick_(e,t){t.preventDefault(),this.zoomByDelta_(e)}zoomByDelta_(e){let t=this.getMap().getView();if(!t)return;let i=t.getZoom();if(i!==void 0){let r=t.getConstrainedZoom(i+e);this.duration_>0?(t.getAnimating()&&t.cancelAnimations(),t.animate({zoom:r,duration:this.duration_,easing:sc})):t.setZoom(r)}}};function $Z(e){e||={};let t=new wn;return(e.zoom===void 0||e.zoom)&&t.push(new jZ(e.zoomOptions)),(e.rotate===void 0||e.rotate)&&t.push(new GZ(e.rotateOptions)),(e.attribution===void 0||e.attribution)&&t.push(new zZ(e.attributionOptions)),t}var WZ=class{constructor(e,t,i){this.decay_=e,this.minVelocity_=t,this.delay_=i,this.points_=[],this.angle_=0,this.initialVelocity_=0}begin(){this.points_.length=0,this.angle_=0,this.initialVelocity_=0}update(e,t){this.points_.push(e,t,Date.now())}end(){if(this.points_.length<6)return!1;let e=Date.now()-this.delay_,t=this.points_.length-3;if(this.points_[t+2]<e)return!1;let i=t-3;for(;i>0&&this.points_[i+2]>e;)i-=3;let r=this.points_[t+2]-this.points_[i+2];if(r<1e3/60)return!1;let s=this.points_[t]-this.points_[i],n=this.points_[t+1]-this.points_[i+1];return this.angle_=Math.atan2(n,s),this.initialVelocity_=Math.sqrt(s*s+n*n)/r,this.initialVelocity_>this.minVelocity_}getDistance(){return(this.minVelocity_-this.initialVelocity_)/this.decay_}getAngle(){return this.angle_}},iF={ACTIVE:"active"},Sm=class extends _a{constructor(e){super(),this.on,this.once,this.un,e&&e.handleEvent&&(this.handleEvent=e.handleEvent),this.map_=null,this.setActive(!0)}getActive(){return this.get(iF.ACTIVE)}getMap(){return this.map_}handleEvent(e){return!0}setActive(e){this.set(iF.ACTIVE,e)}setMap(e){this.map_=e}};function HZ(e,t,i){let r=e.getCenterInternal();if(r){let s=[r[0]+t[0],r[1]+t[1]];e.animateInternal({duration:i===void 0?250:i,easing:sZ,center:e.getConstrainedCenter(s)})}}function $w(e,t,i,r){let s=e.getZoom();if(s===void 0)return;let n=e.getConstrainedZoom(s+t),a=e.getResolutionForZoom(n);e.getAnimating()&&e.cancelAnimations(),e.animate({resolution:a,anchor:i,duration:r===void 0?250:r,easing:sc})}var Mm=class extends Sm{constructor(e){super(),e||={},this.delta_=e.delta?e.delta:1,this.duration_=e.duration===void 0?250:e.duration}handleEvent(e){let t=!1;if(e.type==vi.DBLCLICK){let i=e.originalEvent,r=e.map,s=e.coordinate,n=i.shiftKey?-this.delta_:this.delta_;$w(r.getView(),n,s,this.duration_),i.preventDefault(),t=!0}return!t}};function Ww(e){let t=arguments;return function(i){let r=!0;for(let s=0,n=t.length;s<n&&(r&&=t[s](i),r);++s);return r}}var qZ=function(e){let t=e.originalEvent;return t.altKey&&!(t.metaKey||t.ctrlKey)&&t.shiftKey},XZ=function(e){let t=e.map.getTargetElement(),i=t.getRootNode(),r=e.map.getOwnerDocument().activeElement;return i instanceof ShadowRoot?i.host.contains(r):t.contains(r)},rF=function(e){let t=e.map.getTargetElement(),i=t.getRootNode();return(i instanceof ShadowRoot?i.host:t).hasAttribute("tabindex")?XZ(e):!0},YZ=Ay,sF=function(e){let t=e.originalEvent;return"pointerId"in t&&t.button==0&&!(YK&&xw&&t.ctrlKey)},nF=function(e){let t=e.originalEvent;return!t.altKey&&!(t.metaKey||t.ctrlKey)&&!t.shiftKey},aF=function(e){let t=e.originalEvent;
2105return!t.altKey&&(xw?t.metaKey:t.ctrlKey)&&!t.shiftKey},KZ=function(e){let t=e.originalEvent;return xw?t.metaKey:t.ctrlKey},ZZ=function(e){let t=e.originalEvent;return!t.altKey&&!(t.metaKey||t.ctrlKey)&&t.shiftKey},oF=function(e){let t=e.originalEvent,i=t.target.tagName;return i!=="INPUT"&&i!=="SELECT"&&i!=="TEXTAREA"&&!t.target.isContentEditable},Hw=function(e){let t=e.originalEvent;return"pointerId"in t&&t.pointerType=="mouse"},JZ=function(e){let t=e.originalEvent;return"pointerId"in t&&t.isPrimary&&t.button===0},Cm=class extends Sm{constructor(e){e||={},super(e),e.handleDownEvent&&(this.handleDownEvent=e.handleDownEvent),e.handleDragEvent&&(this.handleDragEvent=e.handleDragEvent),e.handleMoveEvent&&(this.handleMoveEvent=e.handleMoveEvent),e.handleUpEvent&&(this.handleUpEvent=e.handleUpEvent),e.stopDown&&(this.stopDown=e.stopDown),this.handlingDownUpSequence=!1,this.targetPointers=[]}getPointerCount(){return this.targetPointers.length}handleDownEvent(e){return!1}handleDragEvent(e){}handleEvent(e){if(!e.originalEvent)return!0;let t=!1;if(this.updateTrackedPointers_(e),this.handlingDownUpSequence){if(e.type==vi.POINTERDRAG)this.handleDragEvent(e),e.originalEvent.preventDefault();else if(e.type==vi.POINTERUP){let i=this.handleUpEvent(e);this.handlingDownUpSequence=i&&this.targetPointers.length>0}}else if(e.type==vi.POINTERDOWN){let i=this.handleDownEvent(e);this.handlingDownUpSequence=i,t=this.stopDown(i)}else e.type==vi.POINTERMOVE&&this.handleMoveEvent(e);return!t}handleMoveEvent(e){}handleUpEvent(e){return!1}stopDown(e){return e}updateTrackedPointers_(e){e.activePointers&&(this.targetPointers=e.activePointers)}};function qw(e){let t=e.length,i=0,r=0;for(let s=0;s<t;s++)i+=e[s].clientX,r+=e[s].clientY;return{clientX:i/t,clientY:r/t}}var wa=class extends Cm{constructor(e){super({stopDown:Ny}),e||={},this.kinetic_=e.kinetic,this.lastCentroid=null,this.lastPointersCount_,this.panning_=!1;let t=e.condition?e.condition:Ww(nF,JZ);this.condition_=e.onFocusOnly?Ww(rF,t):t,this.noKinetic_=!1}handleDragEvent(e){let t=e.map;this.panning_||(this.panning_=!0,t.getView().beginInteraction());let i=this.targetPointers,r=t.getEventPixel(qw(i));if(i.length==this.lastPointersCount_){if(this.kinetic_&&this.kinetic_.update(r[0],r[1]),this.lastCentroid){let s=[this.lastCentroid[0]-r[0],r[1]-this.lastCentroid[1]],n=e.map.getView();DY(s,n.getResolution()),$T(s,n.getRotation()),n.adjustCenterInternal(s)}}else this.kinetic_&&this.kinetic_.begin();this.lastCentroid=r,this.lastPointersCount_=i.length,e.originalEvent.preventDefault()}handleUpEvent(e){let t=e.map,i=t.getView();if(this.targetPointers.length===0){if(!this.noKinetic_&&this.kinetic_&&this.kinetic_.end()){let r=this.kinetic_.getDistance(),s=this.kinetic_.getAngle(),n=i.getCenterInternal(),a=t.getPixelFromCoordinateInternal(n),o=t.getCoordinateFromPixelInternal([a[0]-r*Math.cos(s),a[1]-r*Math.sin(s)]);i.animateInternal({center:i.getConstrainedCenter(o),duration:500,easing:sc})}return this.panning_&&(this.panning_=!1,i.endInteraction()),!1}return this.kinetic_&&this.kinetic_.begin(),this.lastCentroid=null,!0}handleDownEvent(e){if(this.targetPointers.length>0&&this.condition_(e)){let t=e.map.getView();return this.lastCentroid=null,t.getAnimating()&&t.cancelAnimations(),this.kinetic_&&this.kinetic_.begin(),this.noKinetic_=this.targetPointers.length>1,!0}return!1}},QZ=class extends Cm{constructor(e){e||={},super({stopDown:Ny}),this.condition_=e.condition?e.condition:qZ,this.lastAngle_=void 0,this.duration_=e.duration===void 0?250:e.duration}handleDragEvent(e){if(!Hw(e))return;let t=e.map,i=t.getView();if(i.getConstraints().rotation===Ow)return;let r=t.getSize(),s=e.pixel,n=Math.atan2(r[1]/2-s[1],s[0]-r[0]/2);if(this.lastAngle_!==void 0){let a=n-this.lastAngle_;i.adjustRotationInternal(-a)}this.lastAngle_=n}handleUpEvent(e){return Hw(e)?(e.map.getView().endInteraction(this.duration_),!1):!0}handleDownEvent(e){return Hw(e)&&sF(e)&&this.condition_(e)?(e.map.getView().beginInteraction(),this.lastAngle_=void 0,!0):!1}},eJ=class extends Ey{constructor(e){super(),this.geometry_=null,this.element_=document.createElement("div"),this.element_.style.position="absolute",this.element_.style.pointerEvents="auto",this.element_.className="ol-box "+e,this.map_=null,this.startPixel_=null,this.endPixel_=null}disposeInternal(){this.setMap(null)}render_(){let e=this.startPixel_,t=this.endPixel_,i=this.element_.style;i.left=Math.min(e[0],t[0])+"px",i.top=Math.min(e[1],t[1])+"px",i.width=Math.abs(t[0]-e[0])+"px",i.height=Math.abs(t[1]-e[1])+"px"}setMap(e){if(this.map_){this.map_.getOverlayContainer().removeChild(this.element_);let t=this.element_.style;t.left="inherit",t.top="inherit",t.width="inherit",t.height="inherit"}this.map_=e,this.map_&&this.map_.getOverlayContainer().appendChild(this.element_)}setPixels(e,t){this.startPixel_=e,this.endPixel_=t,this.createOrUpdateGeometry(),this.render_()}createOrUpdateGeometry(){if(!this.map_)return;let e=this.startPixel_,t=this.endPixel_,i=[e,[e[0],t[1]],t,[t[0],e[1]]].map(this.map_.getCoordinateFromPixelInternal,this.map_);i[4]=i[0].slice(),this.geometry_?this.geometry_.setCoordinates([i]):this.geometry_=new wm([i])}getGeometry(){return this.geometry_}},nc={BOXSTART:"boxstart",BOXDRAG:"boxdrag",BOXEND:"boxend",BOXCANCEL:"boxcancel"}
2105,Rm=class extends Nl{constructor(e,t,i){super(e),this.coordinate=t,this.mapBrowserEvent=i}},tJ=class extends Cm{constructor(e){super(),this.on,this.once,this.un,e??={},this.box_=new eJ(e.className||"ol-dragbox"),this.minArea_=e.minArea??64,e.onBoxEnd&&(this.onBoxEnd=e.onBoxEnd),this.startPixel_=null,this.condition_=e.condition??sF,this.boxEndCondition_=e.boxEndCondition??this.defaultBoxEndCondition}defaultBoxEndCondition(e,t,i){let r=i[0]-t[0],s=i[1]-t[1];return r*r+s*s>=this.minArea_}getGeometry(){return this.box_.getGeometry()}handleDragEvent(e){this.startPixel_&&(this.box_.setPixels(this.startPixel_,e.pixel),this.dispatchEvent(new Rm(nc.BOXDRAG,e.coordinate,e)))}handleUpEvent(e){if(!this.startPixel_)return!1;let t=this.boxEndCondition_(e,this.startPixel_,e.pixel);return t&&this.onBoxEnd(e),this.dispatchEvent(new Rm(t?nc.BOXEND:nc.BOXCANCEL,e.coordinate,e)),this.box_.setMap(null),this.startPixel_=null,!1}handleDownEvent(e){return this.condition_(e)?(this.startPixel_=e.pixel,this.box_.setMap(e.map),this.box_.setPixels(this.startPixel_,this.startPixel_),this.dispatchEvent(new Rm(nc.BOXSTART,e.coordinate,e)),!0):!1}onBoxEnd(e){}setActive(e){e||(this.box_.setMap(null),this.startPixel_&&=(this.dispatchEvent(new Rm(nc.BOXCANCEL,this.startPixel_,null)),null)),super.setActive(e)}setMap(e){this.getMap()&&(this.box_.setMap(null),this.startPixel_&&=(this.dispatchEvent(new Rm(nc.BOXCANCEL,this.startPixel_,null)),null)),super.setMap(e)}},Em=class extends tJ{constructor(e){e||={};let t=e.condition?e.condition:ZZ;super({condition:t,className:e.className||"ol-dragzoom",minArea:e.minArea}),this.duration_=e.duration===void 0?200:e.duration,this.out_=e.out===void 0?!1:e.out}onBoxEnd(e){let t=this.getMap().getView(),i=this.getGeometry();if(this.out_){let r=t.rotatedExtentForGeometry(i),s=t.getResolutionForExtentInternal(r),n=t.getResolution()/s;i=i.clone(),i.scale(n*n)}t.fitInternal(i,{duration:this.duration_,easing:sc})}},vu={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",DOWN:"ArrowDown"},bu=class extends Sm{constructor(e){super(),e||={},this.defaultCondition_=function(t){return nF(t)&&oF(t)},this.condition_=e.condition===void 0?this.defaultCondition_:e.condition,this.duration_=e.duration===void 0?100:e.duration,this.pixelDelta_=e.pixelDelta===void 0?128:e.pixelDelta}handleEvent(e){let t=!1;if(e.type==De.KEYDOWN){let i=e.originalEvent,r=i.key;if(this.condition_(e)&&(r==vu.DOWN||r==vu.LEFT||r==vu.RIGHT||r==vu.UP)){let s=e.map.getView(),n=s.getResolution()*this.pixelDelta_,a=0,o=0;r==vu.DOWN?o=-n:r==vu.LEFT?a=-n:r==vu.RIGHT?a=n:o=n;let l=[a,o];$T(l,s.getRotation()),HZ(s,l,this.duration_),i.preventDefault(),t=!0}}return!t}},Am=class extends Sm{constructor(e){super(),e||={},this.condition_=e.condition?e.condition:function(t){return!KZ(t)&&oF(t)},this.delta_=e.delta?e.delta:1,this.duration_=e.duration===void 0?100:e.duration}handleEvent(e){let t=!1;if(e.type==De.KEYDOWN||e.type==De.KEYPRESS){let i=e.originalEvent,r=i.key;if(this.condition_(e)&&(r==="+"||r==="-")){let s=e.map,n=r==="+"?this.delta_:-this.delta_;$w(s.getView(),n,void 0,this.duration_),i.preventDefault(),t=!0}}return!t}},iJ=40,rJ=300,sJ=3,Sa=class extends Sm{constructor(e){e||={},super(e),this.totalDelta_=0,this.lastDelta_=0,this.maxDelta_=e.maxDelta===void 0?1:e.maxDelta,this.duration_=e.duration===void 0?250:e.duration,this.timeout_=e.timeout===void 0?80:e.timeout,this.useAnchor_=e.useAnchor===void 0?!0:e.useAnchor,this.constrainResolution_=e.constrainResolution===void 0?!1:e.constrainResolution;let t=e.condition?e.condition:YZ;this.condition_=e.onFocusOnly?Ww(rF,t):t,this.lastAnchor_=null,this.startTime_=void 0,this.timeoutId_,this.mode_=void 0,this.trackpadEventGap_=400,this.trackpadTimeoutId_,this.deltaPerZoom_=300,this.ctrlKeyPressed_=!1,this.ctrlKeyListenerKeys_=[]}setMap(e){if(this.ctrlKeyListenerKeys_.forEach(oi),this.ctrlKeyListenerKeys_.length=0,this.ctrlKeyPressed_=!1,super.setMap(e),e){let t=e.getOwnerDocument();this.ctrlKeyListenerKeys_.push(ft(t,"keydown",i=>{i.key==="Control"&&(this.ctrlKeyPressed_=!0)}),ft(t,"keyup",i=>{i.key==="Control"&&(this.ctrlKeyPressed_=!1)}))}}endInteraction_(){this.trackpadTimeoutId_=void 0;let e=this.getMap();if(!e)return;let t=e.getView(),i=this.lastDelta_?this.lastDelta_>0?1:-1:0;t.endInteraction(this.constrainResolution_||t.getConstrainResolution()?100:void 0,i,this.lastAnchor_?e.getCoordinateFromPixel(this.lastAnchor_):null)}handleEvent(e){if(!this.condition_(e)||e.type!==De.WHEEL)return!0;let t=e.map,i=e.originalEvent;i.preventDefault();let r=i.ctrlKey&&!this.ctrlKeyPressed_;i.ctrlKey||(this.ctrlKeyPressed_=!1),this.useAnchor_&&(this.lastAnchor_=e.pixel);let s=i.deltaY;switch(i.deltaMode){case WheelEvent.DOM_DELTA_LINE:s*=iJ;break;case WheelEvent.DOM_DELTA_PAGE:s*=rJ;break;default:}if(s===0)return!1;this.lastDelta_=s;let n=Date.now();this.startTime_===void 0&&(this.startTime_=n),(!this.mode_||n-this.startTime_>this.trackpadEventGap_)&&(this.mode_=Math.abs(s)<4?"trackpad":"wheel");let a=t.getView();if(this.mode_==="trackpad")return this.trackpadTimeoutId_?clearTimeout(this.trackpadTimeoutId_):(a.getAnimating()&&a.cancelAnimations(),a.beginInteraction()),this.trackpadTimeoutId_=setTimeout(this.endInteraction_.bind(this),this.timeout_),r&&(s*=sJ),a.adjustZoom(-s/this.deltaPerZoom_,this.lastAnchor_?t.getCoordinateFromPixel(this.lastAnchor_):null),this.startTime_=n,!1;this.totalDelta_+=s;let o=Math.max(this.timeout_-(n-this.startTime_),0);return clearTimeout(this.timeoutId_),this.timeoutId_=setTimeout(this.handleWheelZoom_.bind(this,t),o),!1}handleWheelZoom_(e){let t=e.getView();t.getAnimating()&&t.cancelAnimations();
2105let i=-ri(this.totalDelta_,-this.maxDelta_*this.deltaPerZoom_,this.maxDelta_*this.deltaPerZoom_)/this.deltaPerZoom_;(t.getConstrainResolution()||this.constrainResolution_)&&(i=i?i>0?1:-1:0),$w(t,i,this.lastAnchor_?e.getCoordinateFromPixel(this.lastAnchor_):null,this.duration_),this.mode_=void 0,this.totalDelta_=0,this.lastAnchor_=null,this.startTime_=void 0,this.timeoutId_=void 0}setMouseAnchor(e){this.useAnchor_=e,e||(this.lastAnchor_=null)}},nJ=class extends Cm{constructor(e){e||={};let t=e;t.stopDown||=Ny,super(t),this.anchor_=null,this.lastAngle_=void 0,this.rotating_=!1,this.rotationDelta_=0,this.threshold_=e.threshold===void 0?.3:e.threshold,this.duration_=e.duration===void 0?250:e.duration}handleDragEvent(e){let t=0,i=this.targetPointers[0],r=this.targetPointers[1],s=Math.atan2(r.clientY-i.clientY,r.clientX-i.clientX);if(this.lastAngle_!==void 0){let o=s-this.lastAngle_;this.rotationDelta_+=o,!this.rotating_&&Math.abs(this.rotationDelta_)>this.threshold_&&(this.rotating_=!0),t=o}this.lastAngle_=s;let n=e.map,a=n.getView();a.getConstraints().rotation!==Ow&&(this.anchor_=n.getCoordinateFromPixelInternal(n.getEventPixel(qw(this.targetPointers))),this.rotating_&&(n.render(),a.adjustRotationInternal(t,this.anchor_)))}handleUpEvent(e){return this.targetPointers.length<2?(e.map.getView().endInteraction(this.duration_),!1):!0}handleDownEvent(e){if(this.targetPointers.length>=2){let t=e.map;return this.anchor_=null,this.lastAngle_=void 0,this.rotating_=!1,this.rotationDelta_=0,this.handlingDownUpSequence||t.getView().beginInteraction(),!0}return!1}},Nm=class extends Cm{constructor(e){e||={};let t=e;t.stopDown||=Ny,super(t),this.anchor_=null,this.duration_=e.duration===void 0?400:e.duration,this.lastDistance_=void 0,this.lastScaleDelta_=1}handleDragEvent(e){let t=1,i=this.targetPointers[0],r=this.targetPointers[1],s=i.clientX-r.clientX,n=i.clientY-r.clientY,a=Math.sqrt(s*s+n*n);this.lastDistance_!==void 0&&(t=this.lastDistance_/a),this.lastDistance_=a;let o=e.map,l=o.getView();t!=1&&(this.lastScaleDelta_=t),this.anchor_=o.getCoordinateFromPixelInternal(o.getEventPixel(qw(this.targetPointers))),o.render(),l.adjustResolutionInternal(t,this.anchor_)}handleUpEvent(e){if(this.targetPointers.length<2){let t=e.map.getView(),i=this.lastScaleDelta_>1?1:-1;return t.endInteraction(this.duration_,i),!1}return!0}handleDownEvent(e){if(this.targetPointers.length>=2){let t=e.map;return this.anchor_=null,this.lastDistance_=void 0,this.lastScaleDelta_=1,this.handlingDownUpSequence||t.getView().beginInteraction(),!0}return!1}};function aJ(e){e||={};let t=new wn,i=new WZ(-.005,.05,100);return(e.altShiftDragRotate===void 0||e.altShiftDragRotate)&&t.push(new QZ),(e.doubleClickZoom===void 0||e.doubleClickZoom)&&t.push(new Mm({delta:e.zoomDelta,duration:e.zoomDuration})),(e.dragPan===void 0||e.dragPan)&&t.push(new wa({onFocusOnly:e.onFocusOnly,kinetic:i})),(e.pinchRotate===void 0||e.pinchRotate)&&t.push(new nJ),(e.pinchZoom===void 0||e.pinchZoom)&&t.push(new Nm({duration:e.zoomDuration})),(e.keyboard===void 0||e.keyboard)&&(t.push(new bu),t.push(new Am({delta:e.zoomDelta,duration:e.zoomDuration}))),(e.mouseWheelZoom===void 0||e.mouseWheelZoom)&&t.push(new Sa({onFocusOnly:e.onFocusOnly,duration:e.zoomDuration})),(e.shiftDragZoom===void 0||e.shiftDragZoom)&&t.push(new Em({duration:e.zoomDuration})),t}var Pt={OPACITY:"opacity",VISIBLE:"visible",EXTENT:"extent",Z_INDEX:"zIndex",MAX_RESOLUTION:"maxResolution",MIN_RESOLUTION:"minResolution",MAX_ZOOM:"maxZoom",MIN_ZOOM:"minZoom",SOURCE:"source",MAP:"map"},lF=class extends _a{constructor(e){super(),this.on,this.once,this.un,this.background_=e.background;let t=Object.assign({},e);typeof e.properties=="object"&&(delete t.properties,Object.assign(t,e.properties)),t[Pt.OPACITY]=e.opacity===void 0?1:e.opacity,It(typeof t[Pt.OPACITY]=="number","Layer opacity must be a number"),t[Pt.VISIBLE]=e.visible===void 0?!0:e.visible,t[Pt.Z_INDEX]=e.zIndex,t[Pt.MAX_RESOLUTION]=e.maxResolution===void 0?1/0:e.maxResolution,t[Pt.MIN_RESOLUTION]=e.minResolution===void 0?0:e.minResolution,t[Pt.MIN_ZOOM]=e.minZoom===void 0?-1/0:e.minZoom,t[Pt.MAX_ZOOM]=e.maxZoom===void 0?1/0:e.maxZoom,this.className_=t.className===void 0?"ol-layer":t.className,delete t.className,this.setProperties(t),this.state_=null}
2105getBackground(){return this.background_}getClassName(){return this.className_}getLayerState(e){let t=this.state_||{layer:this,managed:e===void 0?!0:e},i=this.getZIndex();return t.opacity=ri(Math.round(this.getOpacity()*100)/100,0,1),t.visible=this.getVisible(),t.extent=this.getExtent(),t.zIndex=i===void 0&&!t.managed?1/0:i,t.maxResolution=this.getMaxResolution(),t.minResolution=Math.max(this.getMinResolution(),0),t.minZoom=this.getMinZoom(),t.maxZoom=this.getMaxZoom(),this.state_=t,t}getLayersArray(e){return qe()}getLayerStatesArray(e){return qe()}getExtent(){return this.get(Pt.EXTENT)}getMaxResolution(){return this.get(Pt.MAX_RESOLUTION)}getMinResolution(){return this.get(Pt.MIN_RESOLUTION)}getMinZoom(){return this.get(Pt.MIN_ZOOM)}getMaxZoom(){return this.get(Pt.MAX_ZOOM)}getOpacity(){return this.get(Pt.OPACITY)}getSourceState(){return qe()}getVisible(){return this.get(Pt.VISIBLE)}getZIndex(){return this.get(Pt.Z_INDEX)}setBackground(e){this.background_=e,this.changed()}setExtent(e){this.set(Pt.EXTENT,e)}setMaxResolution(e){this.set(Pt.MAX_RESOLUTION,e)}setMinResolution(e){this.set(Pt.MIN_RESOLUTION,e)}setMaxZoom(e){this.set(Pt.MAX_ZOOM,e)}setMinZoom(e){this.set(Pt.MIN_ZOOM,e)}setOpacity(e){It(typeof e=="number","Layer opacity must be a number"),this.set(Pt.OPACITY,e)}setVisible(e){this.set(Pt.VISIBLE,e)}setZIndex(e){this.set(Pt.Z_INDEX,e)}disposeInternal(){this.state_&&=(this.state_.layer=null,null),super.disposeInternal()}},zl={ADDLAYER:"addlayer",REMOVELAYER:"removelayer"},Gl=class extends Nl{constructor(e,t){super(e),this.layer=t}},Xw={LAYERS:"layers"},_u=class yO extends lF{constructor(t){t||={};let i=Object.assign({},t);delete i.layers;let r=t.layers;super(i),this.on,this.once,this.un,this.layersListenerKeys_=[],this.listenerKeys_={},this.addChangeListener(Xw.LAYERS,this.handleLayersChanged_),r?Array.isArray(r)?r=new wn(r.slice(),{unique:!0}):It(typeof r.getArray=="function","Expected `layers` to be an array or a `Collection`"):r=new wn(void 0,{unique:!0}),this.setLayers(r)}handleLayerChange_(){this.changed()}handleLayersChanged_(){this.layersListenerKeys_.forEach(oi),this.layersListenerKeys_.length=0;let t=this.getLayers();this.layersListenerKeys_.push(ft(t,Zs.ADD,this.handleLayersAdd_,this),ft(t,Zs.REMOVE,this.handleLayersRemove_,this));for(let r in this.listenerKeys_)this.listenerKeys_[r].forEach(oi);dm(this.listenerKeys_);let i=t.getArray();for(let r=0,s=i.length;r<s;r++){let n=i[r];this.registerLayerListeners_(n),this.dispatchEvent(new Gl(zl.ADDLAYER,n))}this.changed()}registerLayerListeners_(t){let i=[ft(t,_m.PROPERTYCHANGE,this.handleLayerChange_,this),ft(t,De.CHANGE,this.handleLayerChange_,this)];t instanceof yO&&i.push(ft(t,zl.ADDLAYER,this.handleLayerGroupAdd_,this),ft(t,zl.REMOVELAYER,this.handleLayerGroupRemove_,this)),this.listenerKeys_[At(t)]=i}handleLayerGroupAdd_(t){this.dispatchEvent(new Gl(zl.ADDLAYER,t.layer))}handleLayerGroupRemove_(t){this.dispatchEvent(new Gl(zl.REMOVELAYER,t.layer))}handleLayersAdd_(t){let i=t.element;this.registerLayerListeners_(i),this.dispatchEvent(new Gl(zl.ADDLAYER,i)),this.changed()}handleLayersRemove_(t){let i=t.element,r=At(i);this.listenerKeys_[r].forEach(oi),delete this.listenerKeys_[r],this.dispatchEvent(new Gl(zl.REMOVELAYER,i)),this.changed()}getLayers(){return this.get(Xw.LAYERS)}setLayers(t){let i=this.getLayers();if(i){let r=i.getArray();for(let s=0,n=r.length;s<n;++s)this.dispatchEvent(new Gl(zl.REMOVELAYER,r[s]))}this.set(Xw.LAYERS,t)}getLayersArray(t){return t=t===void 0?[]:t,this.getLayers().forEach(function(i){i.getLayersArray(t)}),t}getLayerStatesArray(t){let i=t===void 0?[]:t,r=i.length;this.getLayers().forEach(function(a){a.getLayerStatesArray(i)});let s=this.getLayerState(),n=s.zIndex;!t&&s.zIndex===void 0&&(n=0);for(let a=r,o=i.length;a<o;a++){let l=i[a];l.opacity*=s.opacity,l.visible=l.visible&&s.visible,l.maxResolution=Math.min(l.maxResolution,s.maxResolution),l.minResolution=Math.max(l.minResolution,s.minResolution),l.minZoom=Math.max(l.minZoom,s.minZoom),l.maxZoom=Math.min(l.maxZoom,s.maxZoom),s.extent!==void 0&&(l.extent===void 0?l.extent=s.extent:l.extent=ds(l.extent,s.extent)),l.zIndex===void 0&&(l.zIndex=n)}return i}getSourceState(){return"ready"}},Ma={PRERENDER:"prerender",POSTRENDER:"postrender",PRECOMPOSE:"precompose",POSTCOMPOSE:"postcompose",RENDERCOMPLETE:"rendercomplete"},Zy=class extends lF{constructor(e){let t=Object.assign({},e);delete t.source,super(t),this.on,this.once,this.un,this.mapPrecomposeKey_=null,this.mapRenderKey_=null,this.sourceChangeKey_=null,this.renderer_=null,this.sourceReady_=!1,this.rendered=!1,e.render&&(this.render=e.render),e.map&&this.setMap(e.map),this.addChangeListener(Pt.SOURCE,this.handleSourcePropertyChange_);let i=e.source?e.source:null;this.setSource(i)}getLayersArray(e){return e||=[],e.push(this),e}getLayerStatesArray(e){return e||=[],e.push(this.getLayerState()),e}getSource(){return this.get(Pt.SOURCE)||null}
2105getRenderSource(){return this.getSource()}getSourceState(){let e=this.getSource();return e?e.getState():"undefined"}handleSourceChange_(){this.changed(),!(this.sourceReady_||this.getSource().getState()!=="ready")&&(this.sourceReady_=!0,this.dispatchEvent("sourceready"))}handleSourcePropertyChange_(){this.sourceChangeKey_&&=(oi(this.sourceChangeKey_),null),this.sourceReady_=!1;let e=this.getSource();e&&(this.sourceChangeKey_=ft(e,De.CHANGE,this.handleSourceChange_,this),e.getState()==="ready"&&(this.sourceReady_=!0,setTimeout(()=>{this.dispatchEvent("sourceready")},0))),this.changed()}getFeatures(e){return this.renderer_?this.renderer_.getFeatures(e):Promise.resolve([])}getData(e){return!this.renderer_||!this.rendered?null:this.renderer_.getData(e)}isVisible(e){let t,i=this.getMapInternal();!e&&i&&(e=i.getView()),t=e instanceof Ta?{viewState:e.getState(),extent:e.calculateExtent()}:e,!t.layerStatesArray&&i&&(t.layerStatesArray=i.getLayerGroup().getLayerStatesArray());let r;if(t.layerStatesArray){if(r=t.layerStatesArray.find(n=>n.layer===this),!r)return!1}else r=this.getLayerState();let s=this.getExtent();return Yw(r,t.viewState)&&(!s||Xi(s,t.extent))}getAttributions(e){if(!this.isVisible(e))return[];let t=this.getSource()?.getAttributions();if(!t)return[];let i=t(e instanceof Ta?e.getViewStateAndExtent():e);return Array.isArray(i)||(i=[i]),i}render(e,t){let i=this.getRenderer();return i.prepareFrame(e)?(this.rendered=!0,i.renderFrame(e,t)):null}unrender(){this.rendered=!1}getDeclutter(){}renderDeclutter(e,t){}renderDeferred(e){let t=this.getRenderer();t&&t.renderDeferred(e)}setMapInternal(e){e||this.unrender(),this.set(Pt.MAP,e)}getMapInternal(){return this.get(Pt.MAP)}setMap(e){this.mapPrecomposeKey_&&=(oi(this.mapPrecomposeKey_),null),e||this.changed(),this.mapRenderKey_&&=(oi(this.mapRenderKey_),null),e&&(this.mapPrecomposeKey_=ft(e,Ma.PRECOMPOSE,this.handlePrecompose_,this),this.mapRenderKey_=ft(this,De.CHANGE,e.render,e),this.changed())}handlePrecompose_(e){let t=e.frameState.layerStatesArray,i=this.getLayerState(!1);It(!t.some(r=>r.layer===i.layer),"A layer can only be added to the map once. Use either `layer.setMap()` or `map.addLayer()`, not both."),t.push(i)}setSource(e){this.set(Pt.SOURCE,e)}getRenderer(){return this.renderer_||=this.createRenderer(),this.renderer_}hasRenderer(){return!!this.renderer_}createRenderer(){return null}clearRenderer(){this.renderer_&&(this.renderer_.dispose(),delete this.renderer_)}disposeInternal(){this.clearRenderer(),this.setSource(null),super.disposeInternal()}};function Yw(e,t){if(!e.visible)return!1;let i=t.resolution;if(i<e.minResolution||i>=e.maxResolution)return!1;let r=t.zoom;return r>e.minZoom&&r<=e.maxZoom}function hF(e,t,i=0,r=e.length-1,s=oJ){for(;r>i;){if(r-i>600){let l=r-i+1,h=t-i+1,u=Math.log(l),d=.5*Math.exp(2*u/3),c=.5*Math.sqrt(u*d*(l-d)/l)*(h-l/2<0?-1:1);hF(e,t,Math.max(i,Math.floor(t-h*d/l+c)),Math.min(r,Math.floor(t+(l-h)*d/l+c)),s)}let n=e[t],a=i,o=r;for(Lm(e,i,t),s(e[r],n)>0&&Lm(e,i,r);a<o;){for(Lm(e,a,o),a++,o--;s(e[a],n)<0;)a++;for(;s(e[o],n)>0;)o--}s(e[i],n)===0?Lm(e,i,o):(o++,Lm(e,o,r)),o<=t&&(i=o+1),t<=o&&(r=o-1)}}function Lm(e,t,i){let r=e[t];e[t]=e[i],e[i]=r}function oJ(e,t){return e<t?-1:+(e>t)}var lJ=class{constructor(e=9){this._maxEntries=Math.max(4,e),this._minEntries=Math.max(2,Math.ceil(this._maxEntries*.4)),this.clear()}all(){return this._all(this.data,[])}search(e){let t=this.data,i=[];if(!Qy(e,t))return i;let r=this.toBBox,s=[];for(;t;){for(let n=0;n<t.children.length;n++){let a=t.children[n],o=t.leaf?r(a):a;Qy(e,o)&&(t.leaf?i.push(a):Zw(e,o)?this._all(a,i):s.push(a))}t=s.pop()}return i}collides(e){let t=this.data;if(!Qy(e,t))return!1;let i=[];for(;t;){for(let r=0;r<t.children.length;r++){let s=t.children[r],n=t.leaf?this.toBBox(s):s;
2105if(Qy(e,n)){if(t.leaf||Zw(e,n))return!0;i.push(s)}}t=i.pop()}return!1}load(e){if(!(e&&e.length))return this;if(e.length<this._minEntries){for(let i=0;i<e.length;i++)this.insert(e[i]);return this}let t=this._build(e.slice(),0,e.length-1,0);if(!this.data.children.length)this.data=t;else if(this.data.height===t.height)this._splitRoot(this.data,t);else{if(this.data.height<t.height){let i=this.data;this.data=t,t=i}this._insert(t,this.data.height-t.height-1,!0)}return this}insert(e){return e&&this._insert(e,this.data.height-1),this}clear(){return this.data=oc([]),this}remove(e,t){if(!e)return this;let i=this.data,r=this.toBBox(e),s=[],n=[],a,o,l;for(;i||s.length;){if(i||(i=s.pop(),o=s[s.length-1],a=n.pop(),l=!0),i.leaf){let h=hJ(e,i.children,t);if(h!==-1)return i.children.splice(h,1),s.push(i),this._condense(s),this}!l&&!i.leaf&&Zw(i,r)?(s.push(i),n.push(a),a=0,o=i,i=i.children[0]):o?(a++,i=o.children[a],l=!1):i=null}return this}toBBox(e){return e}compareMinX(e,t){return e.minX-t.minX}compareMinY(e,t){return e.minY-t.minY}toJSON(){return this.data}fromJSON(e){return this.data=e,this}_all(e,t){let i=[];for(;e;)e.leaf?t.push(...e.children):i.push(...e.children),e=i.pop();return t}_build(e,t,i,r){let s=i-t+1,n=this._maxEntries,a;if(s<=n)return a=oc(e.slice(t,i+1)),ac(a,this.toBBox),a;r||(r=Math.ceil(Math.log(s)/Math.log(n)),n=Math.ceil(s/n**(r-1))),a=oc([]),a.leaf=!1,a.height=r;let o=Math.ceil(s/n),l=o*Math.ceil(Math.sqrt(n));uF(e,t,i,l,this.compareMinX);for(let h=t;h<=i;h+=l){let u=Math.min(h+l-1,i);uF(e,h,u,o,this.compareMinY);for(let d=h;d<=u;d+=o){let c=Math.min(d+o-1,u);a.children.push(this._build(e,d,c,r-1))}}return ac(a,this.toBBox),a}_chooseSubtree(e,t,i,r){for(;r.push(t),!(t.leaf||r.length-1===i);){let s=1/0,n=1/0,a;for(let o=0;o<t.children.length;o++){let l=t.children[o],h=Kw(l),u=cJ(e,l)-h;u<n?(n=u,s=h<s?h:s,a=l):u===n&&h<s&&(s=h,a=l)}t=a||t.children[0]}return t}_insert(e,t,i){let r=i?e:this.toBBox(e),s=[],n=this._chooseSubtree(r,this.data,t,s);for(n.children.push(e),km(n,r);t>=0&&s[t].children.length>this._maxEntries;)this._split(s,t),t--;this._adjustParentBBoxes(r,s,t)}_split(e,t){let i=e[t],r=i.children.length,s=this._minEntries;this._chooseSplitAxis(i,s,r);let n=this._chooseSplitIndex(i,s,r),a=oc(i.children.splice(n,i.children.length-n));a.height=i.height,a.leaf=i.leaf,ac(i,this.toBBox),ac(a,this.toBBox),t?e[t-1].children.push(a):this._splitRoot(i,a)}_splitRoot(e,t){this.data=oc([e,t]),this.data.height=e.height+1,this.data.leaf=!1,ac(this.data,this.toBBox)}_chooseSplitIndex(e,t,i){let r,s=1/0,n=1/0;for(let a=t;a<=i-t;a++){let o=Pm(e,0,a,this.toBBox),l=Pm(e,a,i,this.toBBox),h=pJ(o,l),u=Kw(o)+Kw(l);h<s?(s=h,r=a,n=u<n?u:n):h===s&&u<n&&(n=u,r=a)}return r||i-t}_chooseSplitAxis(e,t,i){let r=e.leaf?this.compareMinX:uJ,s=e.leaf?this.compareMinY:dJ;this._allDistMargin(e,t,i,r)<this._allDistMargin(e,t,i,s)&&e.children.sort(r)}_allDistMargin(e,t,i,r){e.children.sort(r);let s=this.toBBox,n=Pm(e,0,t,s),a=Pm(e,i-t,i,s),o=Jy(n)+Jy(a);for(let l=t;l<i-t;l++){let h=e.children[l];km(n,e.leaf?s(h):h),o+=Jy(n)}for(let l=i-t-1;l>=t;l--){let h=e.children[l];km(a,e.leaf?s(h):h),o+=Jy(a)}return o}_adjustParentBBoxes(e,t,i){for(let r=i;r>=0;r--)km(t[r],e)}_condense(e){for(let t=e.length-1,i;t>=0;t--)e[t].children.length===0?t>0?(i=e[t-1].children,i.splice(i.indexOf(e[t]),1)):this.clear():ac(e[t],this.toBBox)}};function hJ(e,t,i){if(!i)return t.indexOf(e);for(let r=0;r<t.length;r++)if(i(e,t[r]))return r;return-1}function ac(e,t){Pm(e,0,e.children.length,t,e)}function Pm(e,t,i,r,s){s||=oc(null),s.minX=1/0,s.minY=1/0,s.maxX=-1/0,s.maxY=-1/0;for(let n=t;n<i;n++){let a=e.children[n];km(s,e.leaf?r(a):a)}return s}function km(e,t){return e.minX=Math.min(e.minX,t.minX),e.minY=Math.min(e.minY,t.minY),e.maxX=Math.max(e.maxX,t.maxX),e.maxY=Math.max(e.maxY,t.maxY),e}function uJ(e,t){return e.minX-t.minX}function dJ(e,t){return e.minY-t.minY}function Kw(e){return(e.maxX-e.minX)*(e.maxY-e.minY)}function Jy(e){return e.maxX-e.minX+(e.maxY-e.minY)}function cJ(e,t){return(Math.max(t.maxX,e.maxX)-Math.min(t.minX,e.minX))*(Math.max(t.maxY,e.maxY)-Math.min(t.minY,e.minY))}function pJ(e,t){let i=Math.max(e.minX,t.minX),r=Math.max(e.minY,t.minY),s=Math.min(e.maxX,t.maxX),n=Math.min(e.maxY,t.maxY);return Math.max(0,s-i)*Math.max(0,n-r)}function Zw(e,t){return e.minX<=t.minX&&e.minY<=t.minY&&t.maxX<=e.maxX&&t.maxY<=e.maxY}function Qy(e,t){return t.minX<=e.maxX&&t.minY<=e.maxY&&t.maxX>=e.minX&&t.maxY>=e.minY}function oc(e){return{children:e,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function uF(e,t,i,r,s){let n=[t,i];for(;n.length;){if(i=n.pop(),t=n.pop(),i-t<=r)continue;let a=t+Math.ceil((i-t)/r/2)*r;hF(e,a,t,i,s),n.push(t,a,a,i)}}var Jw=[NaN,NaN,NaN,0],dF;function mJ(){return dF||=Ui(1,1,void 0,{willReadFrequently:!0,desynchronized:!0}),dF}var gJ=/^rgba?\(\s*(\d+%?)\s+(\d+%?)\s+(\d+%?)(?:\s*\/\s*(\d+%|\d*\.\d+|[01]))?\s*\)$/i,fJ=/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)(?:\s*,\s*(\d+%|\d*\.\d+|[01]))?\s*\)$/i,yJ=/^rgba?\(\s*(\d+%)\s*,\s*(\d+%)\s*,\s*(\d+%)(?:\s*,\s*(\d+%|\d*\.\d+|[01]))?\s*\)$/i,xJ=/^#([\da-f]{3,4}|[\da-f]{6}|[\da-f]{8})$/i;function e1(e,t){return e.endsWith("%")?Number(e.substring(0,e.length-1))/t:Number(e)}function Im(e){throw Error('failed to parse "'+e+'" as color')}function cF(e){if(e.toLowerCase().startsWith("rgb")){let n=e.match(fJ)||e.match(gJ)||e.match(yJ);if(n){let a=n[4],o=100/255;return[ri(e1(n[1],o)+.5|0,0,255),ri(e1(n[2],o)+.5|0,0,255),ri(e1(n[3],o)+.5|0,0,255),a===void 0?1:ri(e1(a,100),0,1)]}Im(e)}if(e.startsWith("#")){if(xJ.test(e)){let n=e.substring(1),a=n.length<=4?1:2,o=[0,0,0,255];for(let l=0,h=n.length;l<h;l+=a){let u=parseInt(n.substring(l,l+a),16);a===1&&(u+=u<<4),o[l/a]=u}return o[3]/=255,o}Im(e)}let t=mJ();t.fillStyle="#abcdef";let i=t.fillStyle;t.fillStyle=e,t.fillStyle===i&&(t.fillStyle="#fedcba",i=t.fillStyle,t.fillStyle=e,t.fillStyle===i&&Im(e));let r=t.fillStyle;if(r.startsWith("#")||r.startsWith("rgba"))return cF(r);t.clearRect(0,0,1,1),t.fillRect(0,0,1,1);let s=Array.from(t.getImageData(0,0,1,1).data);return s[3]=yy(s[3]/255,3),s}function vJ(e){return typeof e=="string"?e:nS(e)}var bJ=1024,Fm={},Qw=0;function _J(e){if(e.length===4)return e;let t=e.slice();return t[3]=1,t}function eS(e){return e>.0031308?e**(1/2.4)*269.025-14.025:e*3294.6}function tS(e){return e>.2068965?e**3:(e-4/29)*(108/841)}function iS(e){return e>10.314724?((e+14.025)/269.025)**2.4:e/3294.6}function rS(e){return e>.0088564?e**(1/3):e/(108/841)+4/29}function pF(e){let t=iS(e[0]),i=iS(e[1]),r=iS(e[2]),s=rS(t*.222488403+i*.716873169+r*.06060791),n=500*(rS(t*.452247074+i*.399439023+r*.148375274)-s),a=200*(s-rS(t*.016863605+i*.117638439+r*.865350722)),o=180/Math.PI*Math.atan2(a,n);return[116*s-16,Math.sqrt(n*n+a*a),o<0?o+360:o,e[3]]}function TJ(e){let t=(e[0]+16)/116,i=e[1],r=e[2]*Math.PI/180,s=tS(t),n=tS(t+i/500*Math.cos(r)),a=tS(t-i/200*Math.sin(r)),o=eS(n*3.021973625-s*1.617392459-a*.404875592),l=eS(n*-.943766287+s*1.916279586+a*.027607165),h=eS(n*.069407491-s*.22898585+a*1.159737864);return[ri(o+.5|0,0,255),ri(l+.5|0,0,255),ri(h+.5|0,0,255),e[3]]}function sS(e){if(e==="none")return Jw;if(Fm.hasOwnProperty(e))return Fm[e];
2105if(Qw>=bJ){let i=0;for(let r in Fm)i++&3||(delete Fm[r],--Qw)}let t=cF(e);t.length!==4&&Im(e);for(let i of t)isNaN(i)&&Im(e);return Fm[e]=t,++Qw,t}function Tu(e){return Array.isArray(e)?e:sS(e)}function nS(e){let t=e[0];t!=(t|0)&&(t=t+.5|0);let i=e[1];i!=(i|0)&&(i=i+.5|0);let r=e[2];r!=(r|0)&&(r=r+.5|0);let s=e[3]===void 0?1:Math.round(e[3]*1e3)/1e3;return"rgba("+t+","+i+","+r+","+s+")"}function mF(e){return e[0]>0&&e[1]>0}function wJ(e,t,i){return i===void 0&&(i=[0,0]),i[0]=e[0]*t+.5|0,i[1]=e[1]*t+.5|0,i}function kr(e,t){return Array.isArray(e)?e:(t===void 0?t=[e,e]:(t[0]=e,t[1]=e),t)}var wu=0,rs=1<<wu++,at=1<<wu++,cs=1<<wu++,Mn=1<<wu++,Su=1<<wu++,Dm=1<<wu++,t1=2**wu-1,aS={[rs]:"boolean",[at]:"number",[cs]:"string",[Mn]:"color",[Su]:"number[]",[Dm]:"size"},SJ=Object.keys(aS).map(Number).sort(va);function MJ(e){return e in aS}function Om(e){let t=[];for(let i of SJ)Bm(e,i)&&t.push(aS[i]);return t.length===0?"untyped":t.length<3?t.join(" or "):t.slice(0,-1).join(", ")+", or "+t[t.length-1]}function Bm(e,t){return(e&t)===t}function jl(e,t){return e===t}var Zi=class{constructor(e,t){if(!MJ(e))throw Error(`literal expressions must have a specific type, got ${Om(e)}`);this.type=e,this.value=t}},CJ=class{constructor(e,t,...i){this.type=e,this.operator=t,this.args=i}};function gF(){return{variables:new Set,properties:new Set,featureId:!1,geometryType:!1,mCoordinate:!1,mapState:!1}}function fr(e,t,i){switch(typeof e){case"boolean":if(jl(t,cs))return new Zi(cs,e?"true":"false");if(!Bm(t,rs))throw Error(`got a boolean, but expected ${Om(t)}`);return new Zi(rs,e);case"number":if(jl(t,Dm))return new Zi(Dm,kr(e));if(jl(t,rs))return new Zi(rs,!!e);if(jl(t,cs))return new Zi(cs,e.toString());if(!Bm(t,at))throw Error(`got a number, but expected ${Om(t)}`);return new Zi(at,e);case"string":if(jl(t,Mn))return new Zi(Mn,sS(e));if(jl(t,rs))return new Zi(rs,!!e);if(!Bm(t,cs))throw Error(`got a string, but expected ${Om(t)}`);return new Zi(cs,e);default:}if(!Array.isArray(e))throw Error("expression must be an array or a primitive value");if(e.length===0)throw Error("empty expression");if(typeof e[0]=="string")return BJ(e,t,i);for(let r of e)if(typeof r!="number")throw Error("expected an array of numbers");if(jl(t,Dm)){if(e.length!==2)throw Error(`expected an array of two values for a size, got ${e.length}`);return new Zi(Dm,e)}if(jl(t,Mn)){if(e.length===3)return new Zi(Mn,[...e,1]);if(e.length===4)return new Zi(Mn,e);throw Error(`expected an array of 3 or 4 values for a color, got ${e.length}`)}if(!Bm(t,Su))throw Error(`got an array of numbers, but expected ${Om(t)}`);return new Zi(Su,e)}var X={Get:"get",Var:"var",Concat:"concat",GeometryType:"geometry-type",LineMetric:"line-metric",Any:"any",All:"all",Not:"!",Resolution:"resolution",Zoom:"zoom",Time:"time",Equal:"==",NotEqual:"!=",GreaterThan:">",GreaterThanOrEqualTo:">=",LessThan:"<",LessThanOrEqualTo:"<=",Multiply:"*",Divide:"/",Add:"+",Subtract:"-",Clamp:"clamp",Mod:"%",Pow:"^",Abs:"abs",Floor:"floor",Ceil:"ceil",Round:"round",Sin:"sin",Cos:"cos",Atan:"atan",Sqrt:"sqrt",Match:"match",Between:"between",Interpolate:"interpolate",Coalesce:"coalesce",Case:"case",In:"in",Number:"number",String:"string",Array:"array",Color:"color",Id:"id",Band:"band",Palette:"palette",ToString:"to-string",Has:"has"},RJ={[X.Get]:Ie(We(1,1/0),fF),[X.Var]:Ie(We(1,1),EJ),[X.Has]:Ie(We(1,1/0),fF),[X.Id]:Ie(AJ,lc),[X.Concat]:Ie(We(2,1/0),wt(cs)),[X.GeometryType]:Ie(NJ,lc),[X.LineMetric]:Ie(LJ,lc),[X.Resolution]:Ie(oS,lc),[X.Zoom]:Ie(oS,lc),[X.Time]:Ie(oS,lc),[X.Any]:Ie(We(2,1/0),wt(rs)),[X.All]:Ie(We(2,1/0),wt(rs)),[X.Not]:Ie(We(1,1),wt(rs)),[X.Equal]:Ie(We(2,2),wt(t1)),[X.NotEqual]:Ie(We(2,2),wt(t1)),[X.GreaterThan]:Ie(We(2,2),wt(at)),[X.GreaterThanOrEqualTo]:Ie(We(2,2),wt(at)),[X.LessThan]:Ie(We(2,2),wt(at)),[X.LessThanOrEqualTo]:Ie(We(2,2),wt(at)),[X.Multiply]:Ie(We(2,1/0),yF),[X.Coalesce]:Ie(We(2,1/0),yF),[X.Divide]:Ie(We(2,2),wt(at)),[X.Add]:Ie(We(2,1/0),wt(at)),[X.Subtract]:Ie(We(2,2),wt(at)),[X.Clamp]:Ie(We(3,3),wt(at)),[X.Mod]:Ie(We(2,2),wt(at)),[X.Pow]:Ie(We(2,2),wt(at)),[X.Abs]:Ie(We(1,1),wt(at)),[X.Floor]:Ie(We(1,1),wt(at)),[X.Ceil]:Ie(We(1,1),wt(at)),[X.Round]:Ie(We(1,1),wt(at)),[X.Sin]:Ie(We(1,1),wt(at)),[X.Cos]:Ie(We(1,1),wt(at)),[X.Atan]:Ie(We(1,2),wt(at)),[X.Sqrt]:Ie(We(1,1),wt(at)),[X.Match]:Ie(We(4,1/0),xF,kJ),[X.Between]:Ie(We(3,3),wt(at)),[X.Interpolate]:Ie(We(6,1/0),xF,IJ),[X.Case]:Ie(We(3,1/0),PJ,FJ),[X.In]:Ie(We(2,2),DJ),[X.Number]:Ie(We(1,1/0),wt(t1)),[X.String]:Ie(We(1,1/0),wt(t1)),[X.Array]:Ie(We(1,1/0),wt(at)),[X.Color]:Ie(We(1,4),wt(at)),[X.Band]:Ie(We(1,3),wt(at)),[X.Palette]:Ie(We(2,2),OJ),[X.ToString]:Ie(We(1,1),wt(rs|at|cs|Mn))};function fF(e,t,i){let r=e.length-1,s=Array(r);for(let n=0;n<r;++n){let a=e[n+1];switch(typeof a){case"number":s[n]=new Zi(at,a);break;case"string":s[n]=new Zi(cs,a);break;default:throw Error(`expected a string key or numeric array index for a get operation, got ${a}`)}n===0&&i.properties.add(String(a))}return s}function EJ(e,t,i){let r=e[1];if(typeof r!="string")throw Error("expected a string argument for var operation");return i.variables.add(r),[new Zi(cs,r)]}function AJ(e,t,i){i.featureId=!0}function NJ(e,t,i){i.geometryType=!0}function LJ(e,t,i){i.mCoordinate=!0}function oS(e,t,i){i.mapState=!0}function lc(e,t,i){let r=e[0];if(e.length!==1)throw Error(`expected no arguments for ${r} operation`);return[]}function We(e,t){return function(i,r,s){let n=i[0],a=i.length-1;if(e===t){if(a!==e)throw Error(`expected ${e} argument${e===1?"":"s"} for ${n}, got ${a}`)}else if(a<e||a>t){let o=t===1/0?`${e} or more`:`${e} to ${t}`;throw Error(`expected ${o} arguments for ${n}, got ${a}`)}}}function yF(e,t,i){let r=e.length-1,s=Array(r);for(let n=0;n<r;++n)s[n]=fr(e[n+1],t,i);return s}function wt(e){return function(t,i,r){let s=t.length-1,n=Array(s);for(let a=0;a<s;++a)n[a]=fr(t[a+1],e,r);return n}}function PJ(e,t,i){let r=e[0],s=e.length-1;if(s%2==0)throw Error(`expected an odd number of arguments for ${r}, got ${s} instead`)}function xF(e,t,i){let r=e[0],s=e.length-1;if(s%2==1)throw Error(`expected an even number of arguments for operation ${r}, got ${s} instead`)}function kJ(e,t,i){let r=e.length-1,s=cs|at|rs,n=fr(e[1],s,i),a=fr(e[e.length-1],t,i),o=Array(r-2);for(let l=0;l<r-2;l+=2){try{o[l]=fr(e[l+2],n.type,i)}catch(h){throw Error(`failed to parse argument ${l+1} of match expression: ${h.message}`)}try{let h=fr(e[l+3],a.type,i);o[l+1]=h}catch(h){throw Error(`failed to parse argument ${l+2} of match expression: ${h.message}`)}}return[n,...o,a]}function IJ(e,t,i){let r=e[1],s;switch(r[0]){case"linear":s=1;break;case"exponential":let l=r[1];if(typeof l!="number"||l<=0)throw Error(`expected a number base for exponential interpolation, got ${JSON.stringify(l)} instead`);s=l;break;default:throw Error(`invalid interpolation type: ${JSON.stringify(r)}`)}let n=new Zi(at,s),a;try{a=fr(e[2],at,i)}catch(l){throw Error(`failed to parse argument 1 in interpolate expression: ${l.message}`)}let o=Array(e.length-3);for(let l=0;l<o.length;l+=2){try{o[l]=fr(e[l+3],at,i)}catch(h){throw Error(`failed to parse argument ${l+2} for interpolate expression: ${h.message}`)}try{let h=fr(e[l+4],t,i);o[l+1]=h}catch(h){throw Error(`failed to parse argument ${l+3} for interpolate expression: ${h.message}`)}}return[n,a,...o]}function FJ(e,t,i){let r=fr(e[e.length-1],t,i),s=Array(e.length-1);for(let n=0;n<s.length-1;n+=2){try{s[n]=fr(e[n+1],rs,i)}catch(a){throw Error(`failed to parse argument ${n} of case expression: ${a.message}`)}try{let a=fr(e[n+2],r.type,i);s[n+1]=a}catch(a){throw Error(`failed to parse argument ${n+1}
2105 of case expression: ${a.message}`)}}return s[s.length-1]=r,s}function DJ(e,t,i){let r=e[2];if(!Array.isArray(r))throw Error('the second argument for the "in" operator must be an array');let s;if(r[0]==="literal"){if(r=r[1],!Array.isArray(r))throw Error('failed to parse "in" expression: the literal operator must be followed by an array')}else if(typeof r[0]=="string")throw Error('for the "in" operator, a string array should be wrapped in a "literal" operator to disambiguate from expressions');s=typeof r[0]=="string"?cs:at;let n=Array(r.length);for(let a=0;a<n.length;a++)try{n[a]=fr(r[a],s,i)}catch(o){throw Error(`failed to parse haystack item ${a} for "in" expression: ${o.message}`)}return[fr(e[1],s,i),...n]}function OJ(e,t,i){let r;try{r=fr(e[1],at,i)}catch(a){throw Error(`failed to parse first argument in palette expression: ${a.message}`)}let s=e[2];if(!Array.isArray(s))throw Error("the second argument of palette must be an array");let n=Array(s.length);for(let a=0;a<n.length;a++){let o;try{o=fr(s[a],Mn,i)}catch(l){throw Error(`failed to parse color at index ${a} in palette expression: ${l.message}`)}if(!(o instanceof Zi))throw Error(`the palette color at index ${a} must be a literal value`);n[a]=o}return[r,...n]}function Ie(...e){return function(t,i,r){let s=t[0],n;for(let a=0;a<e.length;a++){let o=e[a](t,i,r);if(a==e.length-1){if(!o)throw Error("expected last argument validator to return the parsed args");n=o}}return new CJ(i,s,...n)}}function BJ(e,t,i){let r=e[0],s=RJ[r];if(!s)throw Error(`unknown operator: ${r}`);return s(e,t,i)}function vF(e){if(!e)return"";let t=e.getType();switch(t){case"Point":case"LineString":case"Polygon":return t;case"MultiPoint":case"MultiLineString":case"MultiPolygon":return t.substring(5);case"Circle":return"Polygon";
2105case"GeometryCollection":return vF(e.getGeometries()[0]);default:return""}}function bF(){return{variables:{},properties:{},resolution:NaN,featureId:null,geometryType:""}}function Ca(e,t,i){return Cn(fr(e,t,i),i)}function Cn(e,t){if(e instanceof Zi){if(e.type===Mn&&typeof e.value=="string"){let r=sS(e.value);return function(){return r}}return function(){return e.value}}let i=e.operator;switch(i){case X.Number:case X.String:case X.Coalesce:return UJ(e,t);case X.Get:case X.Var:case X.Has:return VJ(e,t);case X.Id:return r=>r.featureId;case X.GeometryType:return r=>r.geometryType;case X.Concat:{let r=e.args.map(s=>Cn(s,t));return s=>"".concat(...r.map(n=>n(s).toString()))}case X.Resolution:return r=>r.resolution;case X.Any:case X.All:case X.Between:case X.In:case X.Not:return GJ(e,t);case X.Equal:case X.NotEqual:case X.LessThan:case X.LessThanOrEqualTo:case X.GreaterThan:case X.GreaterThanOrEqualTo:return zJ(e,t);case X.Multiply:case X.Divide:case X.Add:case X.Subtract:case X.Clamp:case X.Mod:case X.Pow:case X.Abs:case X.Floor:case X.Ceil:case X.Round:case X.Sin:case X.Cos:case X.Atan:case X.Sqrt:return jJ(e,t);case X.Case:return $J(e,t);case X.Match:return WJ(e,t);case X.Interpolate:return HJ(e,t);case X.ToString:return qJ(e,t);default:throw Error(`Unsupported operator ${i}`)}}function UJ(e,t){let i=e.operator,r=e.args.length,s=Array(r);for(let n=0;n<r;++n)s[n]=Cn(e.args[n],t);switch(i){case X.Coalesce:return n=>{for(let a=0;a<r;++a){let o=s[a](n);if(o!=null)return o}throw Error("Expected one of the values to be non-null")};case X.Number:case X.String:return n=>{for(let a=0;a<r;++a){let o=s[a](n);if(typeof o===i)return o}throw Error(`Expected one of the values to be a ${i}`)};default:throw Error(`Unsupported assertion operator ${i}`)}}function VJ(e,t){let i=e.args[0].value;switch(e.operator){case X.Get:return r=>{let s=e.args,n=r.properties[i];for(let a=1,o=s.length;a<o;++a){let l=s[a].value;n=n[l]}return n};case X.Var:return r=>r.variables[i];case X.Has:return r=>{let s=e.args;if(!(i in r.properties))return!1;let n=r.properties[i];for(let a=1,o=s.length;a<o;++a){let l=s[a].value;if(!n||!Object.hasOwn(n,l))return!1;n=n[l]}return!0};default:throw Error(`Unsupported accessor operator ${e.operator}`)}}function zJ(e,t){let i=e.operator,r=Cn(e.args[0],t),s=Cn(e.args[1],t);switch(i){case X.Equal:return n=>r(n)===s(n);case X.NotEqual:return n=>r(n)!==s(n);case X.LessThan:return n=>r(n)<s(n);case X.LessThanOrEqualTo:return n=>r(n)<=s(n);case X.GreaterThan:return n=>r(n)>s(n);case X.GreaterThanOrEqualTo:return n=>r(n)>=s(n);default:throw Error(`Unsupported comparison operator ${i}`)}}function GJ(e,t){let i=e.operator,r=e.args.length,s=Array(r);for(let n=0;n<r;++n)s[n]=Cn(e.args[n],t);switch(i){case X.Any:return n=>{for(let a=0;a<r;++a)if(s[a](n))return!0;return!1};case X.All:return n=>{for(let a=0;a<r;++a)if(!s[a](n))return!1;return!0};case X.Between:return n=>{let a=s[0](n),o=s[1](n),l=s[2](n);return a>=o&&a<=l};case X.In:return n=>{let a=s[0](n);for(let o=1;o<r;++o)if(a===s[o](n))return!0;return!1};case X.Not:return n=>!s[0](n);default:throw Error(`Unsupported logical operator ${i}`)}}function jJ(e,t){let i=e.operator,r=e.args.length,s=Array(r);for(let n=0;n<r;++n)s[n]=Cn(e.args[n],t);switch(i){case X.Multiply:return n=>{let a=1;for(let o=0;o<r;++o)a*=s[o](n);return a};case X.Divide:return n=>s[0](n)/s[1](n);case X.Add:return n=>{let a=0;for(let o=0;o<r;++o)a+=s[o](n);return a};case X.Subtract:return n=>s[0](n)-s[1](n);case X.Clamp:return n=>{let a=s[0](n),o=s[1](n);if(a<o)return o;let l=s[2](n);return a>l?l:a};case X.Mod:return n=>s[0](n)%s[1](n);case X.Pow:return n=>s[0](n)**+s[1](n);case X.Abs:return n=>Math.abs(s[0](n));case X.Floor:return n=>Math.floor(s[0](n));case X.Ceil:return n=>Math.ceil(s[0](n));case X.Round:return n=>Math.round(s[0](n));case X.Sin:return n=>Math.sin(s[0](n));case X.Cos:return n=>Math.cos(s[0](n));case X.Atan:return r===2?n=>Math.atan2(s[0](n),s[1](n)):n=>Math.atan(s[0](n));case X.Sqrt:return n=>Math.sqrt(s[0](n));default:throw Error(`Unsupported numeric operator ${i}`)}}function $J(e,t){let i=e.args.length,r=Array(i);for(let s=0;s<i;++s)r[s]=Cn(e.args[s],t);return s=>{for(let n=0;n<i-1;n+=2)if(r[n](s))return r[n+1](s);return r[i-1](s)}}function WJ(e,t){let i=e.args.length,r=Array(i);for(let s=0;s<i;++s)r[s]=Cn(e.args[s],t);return s=>{let n=r[0](s);for(let a=1;a<i-1;a+=2)if(n===r[a](s))return r[a+1](s);return r[i-1](s)}}function HJ(e,t){let i=e.args.length,r=Array(i);for(let s=0;s<i;++s)r[s]=Cn(e.args[s],t);return s=>{let n=r[0](s),a=r[1](s),o,l;for(let h=2;h<i;h+=2){let u=r[h](s),d=r[h+1](s),c=Array.isArray(d);
2105if(c&&(d=_J(d)),u>=a)return h===2?d:c?XJ(n,a,o,l,u,d):Um(n,a,o,l,u,d);o=u,l=d}return l}}function qJ(e,t){let i=e.operator,r=e.args.length,s=Array(r);for(let n=0;n<r;++n)s[n]=Cn(e.args[n],t);if(i===X.ToString)return n=>{let a=s[0](n);return e.args[0].type===Mn?nS(a):a.toString()};throw Error(`Unsupported convert operator ${i}`)}function Um(e,t,i,r,s,n){let a=s-i;if(a===0)return r;let o=t-i;return r+(e===1?o/a:(e**+o-1)/(e**+a-1))*(n-r)}function XJ(e,t,i,r,s,n){if(s-i===0)return r;let a=pF(r),o=pF(n),l=o[2]-a[2];return l>180?l-=360:l<-180&&(l+=360),TJ([Um(e,t,i,a[0],s,o[0]),Um(e,t,i,a[1],s,o[1]),a[2]+Um(e,t,i,0,s,l),Um(e,t,i,r[3],s,n[3])])}var Ge={IDLE:0,LOADING:1,LOADED:2,ERROR:3,EMPTY:4};function YJ(e,t,i){let r=e,s=!0,n=!1,a=!1,o=[Ry(r,De.LOAD,function(){a=!0,n||t()})];return r.src&&CI?(n=!0,r.decode().then(function(){s&&t()}).catch(function(l){s&&(a?t():i())})):o.push(Ry(r,De.ERROR,i)),function(){s=!1,o.forEach(oi)}}function KJ(e,t){return new Promise((i,r)=>{function s(){a(),i(e)}function n(){a(),r(Error("Image load error"))}function a(){e.removeEventListener("load",s),e.removeEventListener("error",n)}e.addEventListener("load",s),e.addEventListener("error",n),t&&(e.src=t)})}function ZJ(e,t){return t&&(e.src=t),e.src&&CI?new Promise((i,r)=>e.decode().then(()=>i(e)).catch(s=>e.complete&&e.width?i(e):r(s))):KJ(e)}var JJ=class{constructor(){this.cache_={},this.patternCache_={},this.cacheSize_=0,this.maxCacheSize_=1024}clear(){this.cache_={},this.patternCache_={},this.cacheSize_=0}canExpireCache(){return this.cacheSize_>this.maxCacheSize_}expire(){if(this.canExpireCache()){let e=0;for(let t in this.cache_){let i=this.cache_[t];!(e++&3)&&!i.hasListener()&&(delete this.cache_[t],delete this.patternCache_[t],--this.cacheSize_)}}}get(e,t){let i=lS(e,t);return i in this.cache_?this.cache_[i]:null}getPattern(e,t){let i=lS(e,t);return i in this.patternCache_?this.patternCache_[i]:null}set(e,t,i,r){let s=lS(e,t),n=s in this.cache_;this.cache_[s]=i,r&&(i.getImageState()===Ge.IDLE&&i.load(),i.getImageState()===Ge.LOADING?i.ready().then(()=>{this.patternCache_[s]=Yy().createPattern(i.getImage(1),"repeat")}):this.patternCache_[s]=Yy().createPattern(i.getImage(1),"repeat")),n||++this.cacheSize_}setSize(e){this.maxCacheSize_=e,this.expire()}};function lS(e,t){let i=t?Tu(t):"null";return e+":"+i}var en=new JJ,i1=null,_F=class extends pm{constructor(e,t,i,r,s){super(),this.hitDetectionImage_=null,this.image_=e,this.crossOrigin_=i?.crossOrigin,this.referrerPolicy_=i?.referrerPolicy,this.canvas_={},this.color_=s,this.imageState_=r===void 0?Ge.IDLE:r,this.size_=e&&e.width&&e.height?[e.width,e.height]:null,this.src_=t,this.tainted_,this.ready_=null}initializeImage_(){this.image_=new Image,this.crossOrigin_!==null&&(this.image_.crossOrigin=this.crossOrigin_),this.referrerPolicy_!==void 0&&(this.image_.referrerPolicy=this.referrerPolicy_)}isTainted_(){if(this.tainted_===void 0&&this.imageState_===Ge.LOADED){i1||=Ui(1,1,void 0,{willReadFrequently:!0}),i1.drawImage(this.image_,0,0);try{i1.getImageData(0,0,1,1),this.tainted_=!1}catch{i1=null,this.tainted_=!0}}return this.tainted_===!0}dispatchChangeEvent_(){this.dispatchEvent(De.CHANGE)}handleImageError_(){this.imageState_=Ge.ERROR,this.dispatchChangeEvent_()}handleImageLoad_(){this.imageState_=Ge.LOADED,this.size_=[this.image_.width,this.image_.height],this.dispatchChangeEvent_()}getImage(e){return this.image_||this.initializeImage_(),this.replaceColor_(e),this.canvas_[e]?this.canvas_[e]:this.image_}setImage(e){this.image_=e}getPixelRatio(e){return this.replaceColor_(e),this.canvas_[e]?e:1}getImageState(){return this.imageState_}getHitDetectionImage(){if(this.image_||this.initializeImage_(),!this.hitDetectionImage_)if(this.isTainted_()){let e=this.size_[0],t=this.size_[1],i=Ui(e,t);i.fillRect(0,0,e,t),this.hitDetectionImage_=i.canvas}else this.hitDetectionImage_=this.image_;return this.hitDetectionImage_}getSize(){return this.size_}getSrc(){return this.src_}load(){if(this.imageState_===Ge.IDLE){this.image_||this.initializeImage_(),this.imageState_=Ge.LOADING;try{this.src_!==void 0&&(this.image_.src=this.src_)}catch{this.handleImageError_()}this.image_ instanceof HTMLImageElement&&ZJ(this.image_,this.src_).then(e=>{this.image_=e,this.handleImageLoad_()}).catch(this.handleImageError_.bind(this))}}replaceColor_(e){if(!this.color_||this.canvas_[e]||this.imageState_!==Ge.LOADED)return;let t=this.image_,i=Ui(Math.ceil(t.width*e),Math.ceil(t.height*e)),r=i.canvas;i.scale(e,e),i.drawImage(t,0,0),i.globalCompositeOperation="multiply",i.fillStyle=vJ(this.color_),i.fillRect(0,0,r.width/e,r.height/e),i.globalCompositeOperation="destination-in",i.drawImage(t,0,0),this.canvas_[e]=r}ready(){return this.ready_||=new Promise(e=>{if(this.imageState_===Ge.LOADED||this.imageState_===Ge.ERROR)e();else{let t=()=>{(this.imageState_===Ge.LOADED||this.imageState_===Ge.ERROR)&&(this.removeEventListener(
2105De.CHANGE,t),e())};this.addEventListener(De.CHANGE,t)}}),this.ready_}};function Vm(e,t,i,r,s,n){let a=t===void 0?void 0:en.get(t,s);return a||(a=new _F(e,e&&"src"in e?e.src||void 0:t,i,r,s),en.set(t,s,a,n)),n&&a&&!en.getPattern(t,s)&&en.set(t,s,a,n),a}function Ra(e){return e?Array.isArray(e)?nS(e):typeof e=="object"&&"src"in e?QJ(e):e:null}function QJ(e){if(!e.offset||!e.size)return en.getPattern(e.src,e.color);let t=e.src+":"+e.offset,i=en.getPattern(t,e.color);if(i)return i;let r=en.get(e.src,null);if(r.getImageState()!==Ge.LOADED)return null;let s=Ui(e.size[0],e.size[1]);return s.drawImage(r.getImage(1),e.offset[0],e.offset[1],e.size[0],e.size[1],0,0,e.size[0],e.size[1]),Vm(s.canvas,t,void 0,Ge.LOADED,e.color,!0),en.getPattern(t,e.color)}var eQ="10px sans-serif",tn="#000",r1="round",Mo=[],s1="round",$l="#000",TF="center",tQ="middle",Mu=[0,0,0,0],hc=new _a,n1=null,wF,hS={},iQ=new Set(["serif","sans-serif","monospace","cursive","fantasy","system-ui","ui-serif","ui-sans-serif","ui-monospace","ui-rounded","emoji","math","fangsong"]);function rQ(e,t,i){return`${e} ${t} 16px "${i}"`}var sQ=(function(){let e,t;async function i(s){await t.ready;let n=await t.load(s);if(n.length===0)return!1;let a=Gw(s),o=a.families[0].toLowerCase(),l=a.weight;return n.some(h=>{let u=h.family.replace(/^['"]|['"]$/g,"").toLowerCase(),d=zw[h.weight]||h.weight;return u===o&&h.style===a.style&&d==l})}async function r(){await t.ready;let s=!0,n=hc.getProperties(),a=Object.keys(n).filter(o=>n[o]<100);for(let o=a.length-1;o>=0;--o){let l=a[o],h=n[l];h<100&&(await i(l)?(dm(hS),hc.set(l,100)):(h+=10,hc.set(l,h,!0),h<100&&(s=!1)))}e=void 0,s||(e=setTimeout(r,100))}return async function(s){t||=Js?self.fonts:document.fonts;let n=Gw(s);if(!n)return;let a=n.families,o=!1;for(let l of a){if(iQ.has(l))continue;let h=rQ(n.style,n.weight,l);hc.get(h)===void 0&&(hc.set(h,0,!0),o=!0)}o&&(clearTimeout(e),e=setTimeout(r,100))}})(),nQ=(function(){let e;return function(t){let i=hS[t];if(i==null){if(Js){let r=Gw(t),s=SF(t,"\u017Dg");i=(isNaN(Number(r.lineHeight))?1.2:Number(r.lineHeight))*(s.actualBoundingBoxAscent+s.actualBoundingBoxDescent)}else e||(e=document.createElement("div"),e.innerHTML="M",e.style.minHeight="0",e.style.maxHeight="none",e.style.height="auto",e.style.padding="0",e.style.border="none",e.style.position="absolute",e.style.display="block",e.style.left="-99999px"),e.style.font=t,document.body.appendChild(e),i=e.offsetHeight,document.body.removeChild(e);hS[t]=i}return i}})();function SF(e,t){return n1||=Ui(1,1),e!=wF&&(n1.font=e,wF=n1.font),n1.measureText(t)}function MF(e,t){return SF(e,t).width}function CF(e,t,i){if(t in i)return i[t];let r=t.split(`
2106`).reduce((s,n)=>Math.max(s,MF(e,n)),0);return i[t]=r,r}function aQ(e,t){let i=[],r=[],s=[],n=0,a=0,o=0,l=0;for(let h=0,u=t.length;h<=u;h+=2){let d=t[h];if(d===`
2107`||h===u){n=Math.max(n,a),s.push(a),a=0,o+=l,l=0;continue}let c=t[h+1]||e.font,p=MF(c,d);i.push(p),a+=p;let m=nQ(c);r.push(m),l=Math.max(l,m)}return{width:n,height:o,widths:i,heights:r,lineWidths:s}}function oQ(e,t,i,r,s,n,a,o,l,h,u){e.save(),i!==1&&(e.globalAlpha===void 0?e.globalAlpha=d=>d.globalAlpha*=i:e.globalAlpha*=i),t&&e.transform.apply(e,t),r.contextInstructions?(e.translate(l,h),e.scale(u[0],u[1]),lQ(r,e)):u[0]<0||u[1]<0?(e.translate(l,h),e.scale(u[0],u[1]),e.drawImage(r,s,n,a,o,0,0,a,o)):e.drawImage(r,s,n,a,o,l,h,a*u[0],o*u[1]),e.restore()}function lQ(e,t){let i=e.contextInstructions;for(let r=0,s=i.length;r<s;r+=2)Array.isArray(i[r+1])?t[i[r]].apply(t,i[r+1]):t[i[r]]=i[r+1]}var RF=class xO{constructor(t){this.opacity_=t.opacity,this.rotateWithView_=t.rotateWithView,this.rotation_=t.rotation,this.scale_=t.scale,this.scaleArray_=kr(t.scale),this.displacement_=t.displacement,this.declutterMode_=t.declutterMode}clone(){let t=this.getScale();return new xO({opacity:this.getOpacity(),scale:Array.isArray(t)?t.slice():t,rotation:this.getRotation(),rotateWithView:this.getRotateWithView(),displacement:this.getDisplacement().slice(),declutterMode:this.getDeclutterMode()})}getOpacity(){return this.opacity_}getRotateWithView(){return this.rotateWithView_}getRotation(){return this.rotation_}getScale(){return this.scale_}getScaleArray(){return this.scaleArray_}getDisplacement(){return this.displacement_}getDeclutterMode(){return this.declutterMode_}getAnchor(){return qe()}getImage(t){return qe()}getHitDetectionImage(){return qe()}getPixelRatio(t){return 1}getImageState(){return qe()}getImageSize(){return qe()}getOrigin(){return qe()}getSize(){return qe()}setDisplacement(t){this.displacement_=t}setOpacity(t){this.opacity_=t}setRotateWithView(t){this.rotateWithView_=t}setRotation(t){this.rotation_=t}setScale(t){this.scale_=t,this.scaleArray_=kr(t)}listenImageChange(t){qe()}load(){qe()}unlistenImageChange(t){qe()}ready(){return Promise.resolve()}},EF=class vO extends RF{constructor(t){super({opacity:1,rotateWithView:t.rotateWithView===void 0?!1:t.rotateWithView,rotation:t.rotation===void 0?0:t.rotation,scale:t.scale===void 0?1:t.scale,displacement:t.displacement===void 0?[0,0]:t.displacement,declutterMode:t.declutterMode}),this.hitDetectionCanvas_=null,this.fill_=t.fill===void 0?null:t.fill,this.origin_=[0,0],this.points_=t.points,this.radius=t.radius,this.radius2_=t.radius2,this.angle_=t.angle===void 0?0:t.angle,this.stroke_=t.stroke===void 0?null:t.stroke,this.size_,this.renderOptions_,this.imageState_=this.fill_&&this.fill_.loading()?Ge.LOADING:Ge.LOADED,this.imageState_===Ge.LOADING&&this.ready().then(()=>this.imageState_=Ge.LOADED),this.render()}clone(){let t=this.getScale(),i=new vO({fill:this.getFill()?this.getFill().clone():void 0,points:this.getPoints(),radius:this.getRadius(),radius2:this.getRadius2(),angle:this.getAngle(),stroke:this.getStroke()?this.get
2107Stroke().clone():void 0,rotation:this.getRotation(),rotateWithView:this.getRotateWithView(),scale:Array.isArray(t)?t.slice():t,displacement:this.getDisplacement().slice(),declutterMode:this.getDeclutterMode()});return i.setOpacity(this.getOpacity()),i}getAnchor(){let t=this.size_,i=this.getDisplacement(),r=this.getScaleArray();return[t[0]/2-i[0]/r[0],t[1]/2+i[1]/r[1]]}getAngle(){return this.angle_}getFill(){return this.fill_}setFill(t){this.fill_=t,this.render()}getHitDetectionImage(){return this.hitDetectionCanvas_||=this.createHitDetectionCanvas_(this.renderOptions_),this.hitDetectionCanvas_}getImage(t){let i=this.fill_?.getKey(),r=`${t},${this.angle_},${this.radius},${this.radius2_},${this.points_},${i}`+Object.values(this.renderOptions_).join(","),s=en.get(r,null)?.getImage(1);if(!s){let n=this.renderOptions_,a=Math.ceil(n.size*t),o=Ui(a,a);this.draw_(n,o,t),s=o.canvas;let l=new _F(s,void 0,null,Ge.LOADED,null);en.set(r,null,l),createImageBitmap(s).then(h=>{l.setImage(h)})}return s}getPixelRatio(t){return t}getImageSize(){return this.size_}getImageState(){return this.imageState_}getOrigin(){return this.origin_}getPoints(){return this.points_}getRadius(){return this.radius}setRadius(t){this.radius!==t&&(this.radius=t,this.render())}getRadius2(){return this.radius2_}setRadius2(t){this.radius2_!==t&&(this.radius2_=t,this.render())}getSize(){return this.size_}getStroke(){return this.stroke_}setStroke(t){this.stroke_=t,this.render()}listenImageChange(t){}load(){}unlistenImageChange(t){}calculateLineJoinSize_(t,i,r){if(i===0||this.points_===1/0||t!=="bevel"&&t!=="miter")return i;let s=this.radius,n=this.radius2_===void 0?s:this.radius2_;if(s<n){let _=s;s=n,n=_}let a=this.radius2_===void 0?this.points_:this.points_*2,o=2*Math.PI/a,l=n*Math.sin(o),h=Math.sqrt(n*n-l*l),u=s-h,d=Math.sqrt(l*l+u*u),c=d/l;if(t==="miter"&&c<=r)return c*i;let p=i/2/c,m=i/2*(u/d),g=Math.sqrt((s+p)*(s+p)+m*m)-s;if(this.radius2_===void 0||t==="bevel")return g*2;let f=s*Math.sin(o),y=Math.sqrt(s*s-f*f),x=n-y,b=Math.sqrt(f*f+x*x)/f;if(b<=r){let _=b*i/2-n-s;return 2*Math.max(g,_)}return g*2}createRenderOptions(){let t=r1,i=s1,r=0,s=null,n=0,a,o=0;this.stroke_&&(a=Ra(this.stroke_.getColor()??"#000"),o=this.stroke_.getWidth()??1,s=this.stroke_.getLineDash(),n=this.stroke_.getLineDashOffset()??0,i=this.stroke_.getLineJoin()??"round",t=this.stroke_.getLineCap()??"round",r=this.stroke_.getMiterLimit()??10);let l=this.calculateLineJoinSize_(i,o,r),h=Math.max(this.radius,this.radius2_||0),u=Math.ceil(2*h+l);return{strokeStyle:a,strokeWidth:o,size:u,lineCap:t,lineDash:s,lineDashOffset:n,lineJoin:i,miterLimit:r}}render(){this.renderOptions_=this.createRenderOptions();let t=this.renderOptions_.size;this.hitDetectionCanvas_=null,this.size_=[t,t]}draw_(t,i,r){if(i.scale(r,r),i.translate(t.size/2,t.size/2),this.createPath_(i),this.fill_){let s=this.fill_.getColor();s===null&&(s=tn),i.fillStyle=Ra(s),i.fill()}t.strokeStyle&&(i.strokeStyle=t.strokeStyle,i.lineWidth=t.strokeWidth,t.lineDash&&(i.setLineDash(t.lineDash),i.lineDashOffset=t.lineDashOffset),i.lineCap=t.lineCap,i.lineJoin=t.lineJoin,i.miterLimit=t.miterLimit,i.stroke())}createHitDetectionCanvas_(t){let i;if(this.fill_){let r=this.fill_.getColor(),s=0;typeof r=="string"&&(r=Tu(r)),r===null?s=1:Array.isArray(r)&&(s=r.length===4?r[3]:1),s===0&&(i=Ui(t.size,t.size),this.drawHitDetectionCanvas_(t,i))}return i?i.canvas:this.getImage(1)}createPath_(t){let i=this.points_,r=this.radius;if(i===1/0)t.arc(0,0,r,0,2*Math.PI);else{let s=this.radius2_===void 0?r:this.radius2_;this.radius2_!==void 0&&(i*=2);let n=this.angle_-Math.PI/2,a=2*Math.PI/i;for(let o=0;o<i;o++){let l=n+o*a,h=o%2==0?r:s;t.lineTo(h*Math.cos(l),h*Math.sin(l))}t.closePath()}}drawHitDetectionCanvas_(t,i){i.translate(t.size/2,t.size/2),this.createPath_(i),i.fillStyle=tn,i.fill(),t.strokeStyle&&(i.strokeStyle=t.strokeStyle,i.lineWidth=t.strokeWidth,t.lineDash&&(i.setLineDash(t.lineDash),i.lineDashOffset=t.lineDashOffset),i.lineJoin=t.lineJoin,i.miterLimit=t.miterLimit,i.stroke())}ready(){return this.fill_?this.fill_.ready():Promise.resolve()}}
2107,AF=class bO extends EF{constructor(t){t||={radius:5},super({points:1/0,fill:t.fill,radius:t.radius,stroke:t.stroke,scale:t.scale===void 0?1:t.scale,rotation:t.rotation===void 0?0:t.rotation,rotateWithView:t.rotateWithView===void 0?!1:t.rotateWithView,displacement:t.displacement===void 0?[0,0]:t.displacement,declutterMode:t.declutterMode})}clone(){let t=this.getScale(),i=new bO({fill:this.getFill()?this.getFill().clone():void 0,stroke:this.getStroke()?this.getStroke().clone():void 0,radius:this.getRadius(),scale:Array.isArray(t)?t.slice():t,rotation:this.getRotation(),rotateWithView:this.getRotateWithView(),displacement:this.getDisplacement().slice(),declutterMode:this.getDeclutterMode()});return i.setOpacity(this.getOpacity()),i}},zm=class _O{constructor(t){t||={},this.patternImage_=null,this.color_=null,t.color!==void 0&&this.setColor(t.color)}clone(){let t=this.getColor();return new _O({color:Array.isArray(t)?t.slice():t||void 0})}getColor(){return this.color_}setColor(t){if(typeof t=="object"&&t&&"src"in t){let i=Vm(null,t.src,{crossOrigin:"anonymous"},void 0,t.offset?null:t.color?t.color:null,!(t.offset&&t.size));i.ready().then(()=>{this.patternImage_=null}),i.getImageState()===Ge.IDLE&&i.load(),i.getImageState()===Ge.LOADING&&(this.patternImage_=i)}this.color_=t}getKey(){let t=this.getColor();return t?t instanceof CanvasPattern||t instanceof CanvasGradient?At(t):typeof t=="object"&&"src"in t?t.src+":"+t.offset:Tu(t).toString():""}loading(){return!!this.patternImage_}ready(){return this.patternImage_?this.patternImage_.ready():Promise.resolve()}};function NF(e,t,i,r){return i!==void 0&&r!==void 0?[i/e,r/t]:i===void 0?r===void 0?1:r/t:i/e}var LF=class TO extends RF{constructor(t){t||={};let i=t.opacity===void 0?1:t.opacity,r=t.rotation===void 0?0:t.rotation,s=t.scale===void 0?1:t.scale,n=t.rotateWithView===void 0?!1:t.rotateWithView;super({opacity:i,rotation:r,scale:s,displacement:t.displacement===void 0?[0,0]:t.displacement,rotateWithView:n,declutterMode:t.declutterMode}),this.anchor_=t.anchor===void 0?[.5,.5]:t.anchor,this.normalizedAnchor_=null,this.anchorOrigin_=t.anchorOrigin===void 0?"top-left":t.anchorOrigin,this.anchorXUnits_=t.anchorXUnits===void 0?"fraction":t.anchorXUnits,this.anchorYUnits_=t.anchorYUnits===void 0?"fraction":t.anchorYUnits,this.crossOrigin_=t.crossOrigin===void 0?null:t.crossOrigin,this.referrerPolicy_=t.referrerPolicy;let a=t.img===void 0?null:t.img,o=t.src;It(!(o!==void 0&&a),"`image` and `src` cannot be provided at the same time"),(o===void 0||o.length===0)&&a&&(o=a.src||At(a)),It(o!==void 0&&o.length>0,"A defined and non-empty `src` or `image` must be provided"),It(!((t.width!==void 0||t.height!==void 0)&&t.scale!==void 0),"`width` or `height` cannot be provided together with `scale`");let l;if(t.src===void 0?a!==void 0&&(l="complete"in a?a.complete?a.src?Ge.LOADED:Ge.IDLE:Ge.LOADING:Ge.LOADED):l=Ge.IDLE,this.color_=t.color===void 0?null:Tu(t.color),this.iconImage_=Vm(a,o,{crossOrigin:this.crossOrigin_,referrerPolicy:this.referrerPolicy_},l,this.color_),this.offset_=t.offset===void 0?[0,0]:t.offset,this.offsetOrigin_=t.offsetOrigin===void 0?"top-left":t.offsetOrigin,this.origin_=null,this.size_=t.size===void 0?null:t.size,this.initialOptions_,t.width!==void 0||t.height!==void 0){let h,u;if(t.size)[h,u]=t.size;else{let d=this.getImage(1);if(d.width&&d.height)h=d.width,u=d.height;else if(d instanceof HTMLImageElement){this.initialOptions_=t;let c=()=>{if(this.unlistenImageChange(c),!this.initialOptions_)return;let p=this.iconImage_.getSize();this.setScale(NF(p[0],p[1],t.width,t.height))};this.listenImageChange(c);return}}h!==void 0&&this.setScale(NF(h,u,t.width,t.height))}}clone(){let t,i,r;return this.initialOptions_?(i=this.initialOptions_.width,r=this.initialOptions_.height):(t=this.getScale(),t=Array.isArray(t)?t.slice():t),new TO({anchor:this.anchor_.slice(),anchorOrigin:this.anchorOrigin_,anchorXUnits:this.anchorXUnits_,anchorYUnits:this.anchorYUnits_,color:this.color_&&this.color_.slice?this.color_.slice():this.color_||void 0,crossOrigin:this.crossOrigin_,referrerPolicy:this.referrerPolicy_,offset:this.offset_.slice(),offsetOrigin:this.offsetOrigin_,opacity:this.getOpacity(),rotateWithView:this.getRotateWithView(),rotation:this.getRotation(),scale:t,width:i,height:r,size:this.size_===null?void 0:this.size_.slice(),src:this.getSrc(),displacement:this.getDisplacement().slice(),declutterMode:this.getDeclutterMode()})}getAnchor(){let t=this.normalizedAnchor_;if(!t){t=this.anchor_;let s=this.getSize();if(this.anchorXUnits_=="fraction"||this.anchorYUnits_=="fraction"){if(!s)return null;t=this.anchor_.slice(),this.anchorXUnits_=="fraction"&&(t[0]*=s[0]),this.anchorYUnits_=="fraction"&&(t[1]*=s[1])}if(this.anchorOrigin_!="top-left"){if(!s)return null;t===this.anchor_&&(t=this.anchor_.slice()),(this.anchorOrigin_=="top-right"||this.anchorOrigin_=="bottom-right")&&(t[0]=-t[0]+s[0]),(this.anchorOrigin_=="bottom-left"||this.anchorOrigin_=="bottom-right")&&(t[1]=-t[1]+s[1])}this.normalizedAnchor_=t}let i=this.getDisplacement(),r=this.getScaleArray();return[t[0]-i[0]/r[0],t[1]+i[1]/r[1]]}setAnchor(t){this.anchor_=t,this.normalizedAnchor_=null}getColor(){return this.color_}setColor(t){let i=t?Tu(t):null;if(this.color_===i||this.color_&&i&&this.color_.length===i.length&&this.color_.every((a,o)=>a===i[o]))return;this.color_=i;let r=this.getSrc(),s=r===void 0?this.getHitDetectionImage():null,n=r===void 0?this.iconImage_.getImageState():Ge.IDLE;this.iconImage_=Vm(s,r,{crossOrigin:this.crossOrigin_,referrerPolicy:this.referrerPolicy_},n,this.color_)}getImage(t){return this.iconImage_.getImage(t)}getPixelRatio(t){return this.iconImage_.getPixelRatio(t)}getImageSize(){return this.iconImage_.getSize()}getImageState(){return this.iconImage_.getImageState()}getHitDetectionImage(){return this.iconImage_.getHitDetectionImage()}getOrigin(){if(this.origin_)return this.origin_;let t=this.offset_;if(this.offsetOrigin_!="top-left"){let i=this.getSize(),r=this.iconImage_.getSize();if(!i||!r)return null;t=t.slice(),(this.offsetOrigin_=="top-right"||this.offsetOrigin_=="bottom-right")&&(t[0]=r[0]-i[0]-t[0]),(this.offsetOrigin_=="bottom-left"||this.offsetOrigin_=="bottom-right")&&(t[1]=r[1]-i[1]-t[1])}return this.origin_=t,this.origin_}getSrc(){return this.iconImage_.getSrc()}setSrc(t){this.iconImage_=Vm(null,t,{crossOrigin:this.crossOrigin_,referrerPolicy:this.referrerPolicy_},Ge.IDLE,this.color_)}getSize(){return this.size_?this.size_:this.iconImage_.getSize()}getWidth(){let t=this.getScaleArray();if(this.size_)return this.size_[0]*t[0];if(this.iconImage_.getImageState()==Ge.LOADED)return this.iconImage_.getSize()[0]*t[0]}getHeight(){let t=this.getScaleArray();if(this.size_)return this.size_[1]*t[1];if(this.iconImage_.getImageState()==Ge.LOADED)return this.iconImage_.getSize()[1]*t[1]}setScale(t){delete this.initialOptions_,super.setScale(t)}
2107listenImageChange(t){this.iconImage_.addEventListener(De.CHANGE,t)}load(){this.iconImage_.load()}unlistenImageChange(t){this.iconImage_.removeEventListener(De.CHANGE,t)}ready(){return this.iconImage_.ready()}},uS=class wO{constructor(t){t||={},this.color_=t.color===void 0?null:t.color,this.lineCap_=t.lineCap,this.lineDash_=t.lineDash===void 0?null:t.lineDash,this.lineDashOffset_=t.lineDashOffset,this.lineJoin_=t.lineJoin,this.miterLimit_=t.miterLimit,this.offset_=t.offset,this.width_=t.width}clone(){let t=this.getColor();return new wO({color:Array.isArray(t)?t.slice():t||void 0,lineCap:this.getLineCap(),lineDash:this.getLineDash()?this.getLineDash().slice():void 0,lineDashOffset:this.getLineDashOffset(),lineJoin:this.getLineJoin(),miterLimit:this.getMiterLimit(),offset:this.getOffset(),width:this.getWidth()})}getColor(){return this.color_}getLineCap(){return this.lineCap_}getLineDash(){return this.lineDash_}getLineDashOffset(){return this.lineDashOffset_}getLineJoin(){return this.lineJoin_}getMiterLimit(){return this.miterLimit_}getOffset(){return this.offset_}getWidth(){return this.width_}setColor(t){this.color_=t}setLineCap(t){this.lineCap_=t}setLineDash(t){this.lineDash_=t}setLineDashOffset(t){this.lineDashOffset_=t}setLineJoin(t){this.lineJoin_=t}setMiterLimit(t){this.miterLimit_=t}setOffset(t){this.offset_=t}setWidth(t){this.width_=t}},uc=class SO{constructor(t){t||={},this.geometry_=null,this.geometryFunction_=kF,t.geometry!==void 0&&this.setGeometry(t.geometry),this.fill_=t.fill===void 0?null:t.fill,this.image_=t.image===void 0?null:t.image,this.renderer_=t.renderer===void 0?null:t.renderer,this.hitDetectionRenderer_=t.hitDetectionRenderer===void 0?null:t.hitDetectionRenderer,this.stroke_=t.stroke===void 0?null:t.stroke,this.text_=t.text===void 0?null:t.text,this.zIndex_=t.zIndex}clone(){let t=this.getGeometry();return t&&typeof t=="object"&&(t=t.clone()),new SO({geometry:t??void 0,fill:this.getFill()?this.getFill().clone():void 0,image:this.getImage()?this.getImage().clone():void 0,renderer:this.getRenderer()??void 0,stroke:this.getStroke()?this.getStroke().clone():void 0,text:this.getText()?this.getText().clone():void 0,zIndex:this.getZIndex()})}getRenderer(){return this.renderer_}setRenderer(t){this.renderer_=t}setHitDetectionRenderer(t){this.hitDetectionRenderer_=t}getHitDetectionRenderer(){return this.hitDetectionRenderer_}getGeometry(){return this.geometry_}getGeometryFunction(){return this.geometryFunction_}getFill(){return this.fill_}setFill(t){this.fill_=t}getImage(){return this.image_}setImage(t){this.image_=t}getStroke(){return this.stroke_}setStroke(t){this.stroke_=t}getText(){return this.text_}setText(t){this.text_=t}getZIndex(){return this.zIndex_}setGeometry(t){typeof t=="function"?this.geometryFunction_=t:typeof t=="string"?this.geometryFunction_=function(i){return i.get(t)}:t?t!==void 0&&(this.geometryFunction_=function(){return t}):this.geometryFunction_=kF,this.geometry_=t}setZIndex(t){this.zIndex_=t}};function hQ(e){let t;if(typeof e=="function")t=e;else{let i;Array.isArray(e)?i=e:(It(typeof e.getZIndex=="function","Expected an `Style` or an array of `Style`"),i=[e]),t=function(){return i}}return t}var dS=null;function PF(e,t){if(!dS){let i=new zm({color:"rgba(255,255,255,0.4)"}),r=new uS({color:"#3399CC",width:1.25});dS=[new uc({image:new AF({fill:i,stroke:r,radius:5}),fill:i,stroke:r})]}return dS}function kF(e){return e.getGeometry()}var uQ="#333",IF=class MO{constructor(t){t||={},this.font_=t.font,this.rotation_=t.rotation,this.rotateWithView_=t.rotateWithView,this.keepUpright_=t.keepUpright,this.scale_=t.scale,this.scaleArray_=kr(t.scale===void 0?1:t.scale),this.text_=t.text,this.textAlign_=t.textAlign,this.justify_=t.justify,this.repeat_=t.repeat,this.textBaseline_=t.textBaseline,this.fill_=t.fill===void 0?new zm({color:uQ}):t.fill,this.maxAngle_=t.maxAngle===void 0?Math.PI/4:t.maxAngle,this.placement_=t.placement===void 0?"point":t.placement,this.overflow_=!!t.overflow,this.stroke_=t.stroke===void 0?null:t.stroke,this.offsetX_=t.offsetX===void 0?0:t.offsetX,this.offsetY_=t.offsetY===void 0?0:t.offsetY,this.backgroundFill_=t.backgroundFill?t.backgroundFill:null,this.backgroundStroke_=t.backgroundStroke?t.backgroundStroke:null,this.padding_=t.padding===void 0?null:t.padding,this.declutterMode_=t.declutterMode}clone(){let t=this.getScale();return new MO({font:this.getFont(),placement:this.getPlacement(),repeat:this.getRepeat(),maxAngle:this.getMaxAngle(),overflow:this.getOverflow(),rotation:this.getRotation(),rotateWithView:this.getRotateWithView(),keepUpright:this.getKeepUpright(),scale:Array.isArray(t)?t.slice():t,text:this.getText(),textAlign:this.getTextAlign(),justify:this.getJustify(),textBaseline:this.getTextBaseline(),fill:this.getFill()instanceof zm?this.getFill().clone():this.getFill(),stroke:this.getStroke()?this.get
2107Stroke().clone():void 0,offsetX:this.getOffsetX(),offsetY:this.getOffsetY(),backgroundFill:this.getBackgroundFill()?this.getBackgroundFill().clone():void 0,backgroundStroke:this.getBackgroundStroke()?this.getBackgroundStroke().clone():void 0,padding:this.getPadding()||void 0,declutterMode:this.getDeclutterMode()})}getOverflow(){return this.overflow_}getFont(){return this.font_}getMaxAngle(){return this.maxAngle_}getPlacement(){return this.placement_}getRepeat(){return this.repeat_}getOffsetX(){return this.offsetX_}getOffsetY(){return this.offsetY_}getFill(){return this.fill_}getRotateWithView(){return this.rotateWithView_}getKeepUpright(){return this.keepUpright_}getRotation(){return this.rotation_}getScale(){return this.scale_}getScaleArray(){return this.scaleArray_}getStroke(){return this.stroke_}getText(){return this.text_}getTextAlign(){return this.textAlign_}getJustify(){return this.justify_}getTextBaseline(){return this.textBaseline_}getBackgroundFill(){return this.backgroundFill_}getBackgroundStroke(){return this.backgroundStroke_}getPadding(){return this.padding_}getDeclutterMode(){return this.declutterMode_}setOverflow(t){this.overflow_=t}setFont(t){this.font_=t}setMaxAngle(t){this.maxAngle_=t}setOffsetX(t){this.offsetX_=t}setOffsetY(t){this.offsetY_=t}setPlacement(t){this.placement_=t}setRepeat(t){this.repeat_=t}setRotateWithView(t){this.rotateWithView_=t}setKeepUpright(t){this.keepUpright_=t}setFill(t){this.fill_=t}setRotation(t){this.rotation_=t}setScale(t){this.scale_=t,this.scaleArray_=kr(t===void 0?1:t)}setStroke(t){this.stroke_=t}setText(t){this.text_=t}setTextAlign(t){this.textAlign_=t}setJustify(t){this.justify_=t}setTextBaseline(t){this.textBaseline_=t}setBackgroundFill(t){this.backgroundFill_=t}setBackgroundStroke(t){this.backgroundStroke_=t}setPadding(t){this.padding_=t}};function dQ(e){return!0}function cQ(e){let t=gF(),i=pQ(e,t),r=bF();return function(s,n){if(r.properties=s.getPropertiesInternal(),r.resolution=n,t.featureId){let a=s.getId();a===void 0?r.featureId=null:r.featureId=a}return t.geometryType&&(r.geometryType=vF(s.getGeometry())),i(r)}}function FF(e){let t=gF(),i=e.length,r=Array(i);for(let a=0;a<i;++a)r[a]=cS(e[a],t);let s=bF(),n=Array(i);return function(a,o){if(s.properties=a.getPropertiesInternal(),s.resolution=o,t.featureId){let h=a.getId();h===void 0?s.featureId=null:s.featureId=h}let l=0;for(let h=0;h<i;++h){let u=r[h](s);u&&(n[l]=u,l+=1)}return n.length=l,n}}function pQ(e,t){let i=e.length,r=Array(i);for(let s=0;s<i;++s){let n=e[s],a="filter"in n?Ca(n.filter,rs,t):dQ,o;if(Array.isArray(n.style)){let l=n.style.length;o=Array(l);for(let h=0;h<l;++h)o[h]=cS(n.style[h],t)}else o=[cS(n.style,t)];r[s]={filter:a,styles:o}}return function(s){let n=[],a=!1;for(let o=0;o<i;++o){let l=r[o].filter;if(l(s)&&!(e[o].else&&a)){a=!0;for(let h of r[o].styles){let u=h(s);u&&n.push(u)}}}return n}}function cS(e,t){let i=Gm(e,"",t),r=jm(e,"",t),s=mQ(e,t),n=gQ(e,t),a=yr(e,"z-index",t);if(!i&&!r&&!s&&!n&&!wy(e))throw Error("No fill, stroke, point, or text symbolizer properties in style: "+JSON.stringify(e));let o=new uc;return function(l){let h=!0;if(i){let u=i(l);u&&(h=!1),o.setFill(u)}if(r){let u=r(l);u&&(h=!1),o.setStroke(u)}if(s){let u=s(l);u&&(h=!1),o.setText(u)}if(n){let u=n(l);u&&(h=!1),o.setImage(u)}return a&&o.setZIndex(a(l)),h?null:o}}function Gm(e,t,i){let r;if(t+"fill-pattern-src"in e)r=vQ(e,t+"fill-",i);else{if(e[t+"fill-color"]==="none")return n=>null;r=a1(e,t+"fill-color",i)}if(!r)return null;let s=new zm;return function(n){let a=r(n);return a===Jw?null:(s.setColor(a),s)}}function jm(e,t,i){let r=yr(e,t+"stroke-width",i),s=a1(e,t+"stroke-color",i);if(!r&&!s)return null;let n=Ro(e,t+"stroke-line-cap",i),a=Ro(e,t+"stroke-line-join",i),o=DF(e,t+"stroke-line-dash",i),l=yr(e,t+"stroke-line-dash-offset",i),h=yr(e,t+"stroke-miter-limit",i),u=yr(e,t+"stroke-offset",i),d=new uS;return function(c){if(s){let p=s(c);if(p===Jw)return null;d.setColor(p)}if(r&&d.setWidth(r(c)),n){let p=n(c);if(p!=="butt"&&p!=="round"&&p!=="square")throw Error("Expected butt, round, or square line cap");d.setLineCap(p)}if(a){let p=a(c);if(p!=="bevel"&&p!=="round"&&p!=="miter")throw Error("Expected bevel, round, or miter line join");d.setLineJoin(p)}return o&&d.setLineDash(o(c)),l&&d.setLineDashOffset(l(c)),h&&d.setMiterLimit(h(c)),u&&d.setOffset(u(c)),d}}function mQ(e,t){let i="text-",r=Ro(e,"text-value",t);if(!r)return null;let s=Gm(e,i,t),n=Gm(e,"text-background-",t),a=jm(e,i,t),o=jm(e,"text-background-",t),l=Ro(e,"text-font",t),h=yr(e,"text-max-angle",t),u=yr(e,"text-offset-x",t),d=yr(e,"text-offset-y",t),c=dc(e,"text-overflow",t),p=Ro(e,"text-placement",t),m=yr(e,"text-repeat",t),g=l1(e,"text-scale",t),f=dc(e,"text-rotate-with-view",t),y=yr(e,"text-rotation",t),x=Ro(e,"text-align",t),b=Ro(e,"text-justify",t),_=Ro(e,"text-baseline",t),T=dc(e,"text-keep-upright",t),w=DF(e,"text-padding",t),M=new IF({declutterMode:h1(e,"text-declutter-mode")});return function(S){if(M.setText(r(S)),s&&M.setFill(s(S)),n&&M.setBackgroun
2107dFill(n(S)),a&&M.setStroke(a(S)),o&&M.setBackgroundStroke(o(S)),l&&M.setFont(l(S)),h&&M.setMaxAngle(h(S)),u&&M.setOffsetX(u(S)),d&&M.setOffsetY(d(S)),c&&M.setOverflow(c(S)),p){let R=p(S);if(R!=="point"&&R!=="line")throw Error("Expected point or line for text-placement");M.setPlacement(R)}if(m&&M.setRepeat(m(S)),g&&M.setScale(g(S)),f&&M.setRotateWithView(f(S)),y&&M.setRotation(y(S)),x){let R=x(S);if(R!=="left"&&R!=="center"&&R!=="right"&&R!=="end"&&R!=="start")throw Error("Expected left, right, center, start, or end for text-align");M.setTextAlign(R)}if(b){let R=b(S);if(R!=="left"&&R!=="right"&&R!=="center")throw Error("Expected left, right, or center for text-justify");M.setJustify(R)}if(_){let R=_(S);if(R!=="bottom"&&R!=="top"&&R!=="middle"&&R!=="alphabetic"&&R!=="hanging")throw Error("Expected bottom, top, middle, alphabetic, or hanging for text-baseline");M.setTextBaseline(R)}return w&&M.setPadding(w(S)),T&&M.setKeepUpright(T(S)),M}}function gQ(e,t){return"icon-src"in e?fQ(e,t):"shape-points"in e?yQ(e,t):"circle-radius"in e?xQ(e,t):null}function fQ(e,t){let i="icon-src",r=VF(e[i],i),s=o1(e,"icon-anchor",t),n=l1(e,"icon-scale",t),a=yr(e,"icon-opacity",t),o=o1(e,"icon-displacement",t),l=yr(e,"icon-rotation",t),h=dc(e,"icon-rotate-with-view",t),u=BF(e,"icon-anchor-origin"),d=UF(e,"icon-anchor-x-units"),c=UF(e,"icon-anchor-y-units"),p=Co(e,"icon-color"),m,g=null;p!==void 0&&(Array.isArray(p)&&p.length>0&&typeof p[0]=="string"?g=a1(e,"icon-color",t):m=zF(p,"icon-color"));let f=_Q(e,"icon-cross-origin"),y=TQ(e,"icon-offset"),x=BF(e,"icon-offset-
2107origin"),b=pS(e,"icon-width"),_={src:r,anchorOrigin:u,anchorXUnits:d,anchorYUnits:c,crossOrigin:f,offset:y,offsetOrigin:x,height:pS(e,"icon-height"),width:b,size:bQ(e,"icon-size"),declutterMode:h1(e,"icon-declutter-mode")},T=null;return function(w){if(T)g&&T.setColor(g(w));else{let M=g?g(w):m;T=new LF(M===void 0?Object.assign({},_):Object.assign({},_,{color:M}))}return a&&T.setOpacity(a(w)),o&&T.setDisplacement(o(w)),l&&T.setRotation(l(w)),h&&T.setRotateWithView(h(w)),n&&T.setScale(n(w)),s&&T.setAnchor(s(w)),T}}function yQ(e,t){let i="shape-",r="shape-points",s="shape-radius",n=mS(e[r],r);if(!(s in e))throw Error(`Expected a number for ${s}`);let a=yr(e,s,t),o=typeof e[s]=="number"?e[s]:5,l="shape-radius2",h=yr(e,l,t),u=typeof e[l]=="number"?e[l]:void 0,d=Gm(e,i,t),c=jm(e,i,t),p=l1(e,"shape-scale",t),m=o1(e,"shape-displacement",t),g=yr(e,"shape-rotation",t),f=dc(e,"shape-rotate-with-view",t),y=new EF({points:n,radius:o,radius2:u,angle:pS(e,"shape-angle"),declutterMode:h1(e,"shape-declutter-mode")});return function(x){return a&&y.setRadius(a(x)),h&&y.setRadius2(h(x)),d&&y.setFill(d(x)),c&&y.setStroke(c(x)),m&&y.setDisplacement(m(x)),g&&y.setRotation(g(x)),f&&y.setRotateWithView(f(x)),p&&y.setScale(p(x)),y}}function xQ(e,t){let i="circle-",r=Gm(e,i,t),s=jm(e,i,t),n=yr(e,"circle-radius",t),a=l1(e,"circle-scale",t),o=o1(e,"circle-displacement",t),l=yr(e,"circle-rotation",t),h=dc(e,"circle-rotate-with-view",t),u=new AF({radius:5,declutterMode:h1(e,"circle-declutter-mode")});return function(d){return n&&u.setRadius(n(d)),r&&u.setFill(r(d)),s&&u.setStroke(s(d)),o&&u.setDisplacement(o(d)),l&&u.setRotation(l(d)),h&&u.setRotateWithView(h(d)),a&&u.setScale(a(d)),u}}function Co(e,t){if(!(t in e))return;let i=e[t];return i===void 0?void 0:i}function yr(e,t,i){let r=Co(e,t);if(r===void 0)return;let s=Ca(r,at,i);return function(n){return mS(s(n),t)}}function Ro(e,t,i){let r=Co(e,t);if(r===void 0)return null;let s=Ca(r,cs,i);return function(n){return VF(s(n),t)}}function vQ(e,t,i){let r=Ro(e,t+"pattern-src",i),s=OF(e,t+"pattern-offset",i),n=OF(e,t+"pattern-size",i),a=a1(e,t+"color",i);return function(o){return{src:r(o),offset:s&&s(o),size:n&&n(o),color:a&&a(o)}}}function dc(e,t,i){let r=Co(e,t);if(r===void 0)return null;let s=Ca(r,rs,i);return function(n){let a=s(n);if(typeof a!="boolean")throw Error(`Expected a boolean for ${t}`);return a}}function a1(e,t,i){let r=Co(e,t);if(r===void 0)return null;let s=Ca(r,Mn,i);return function(n){return zF(s(n),t)}}function DF(e,t,i){let r=Co(e,t);if(r===void 0)return null;if(Array.isArray(r)&&(r.length===0||typeof r[0]!="string")){let n=r.map((a,o)=>{if(typeof a=="number")return()=>a;let l=Ca(a,at,i);return function(h){return mS(l(h),`${t}[${o}]`)}});return function(a){let o=Array(n.length);for(let l=0;l<n.length;++l)o[l]=n[l](a);return o}}let s=Ca(r,Su,i);return function(n){return $m(s(n),t)}}function o1(e,t,i){let r=Co(e,t);if(r===void 0)return null;let s=Ca(r,Su,i);return function(n){let a=$m(s(n),t);if(a.length!==2)throw Error(`Expected two numbers for ${t}`);return a}}function OF(e,t,i){let r=Co(e,t);if(r===void 0)return null;let s=Ca(r,Su,i);return function(n){return GF(s(n),t)}}function l1(e,t,i){let r=Co(e,t);if(r===void 0)return null;let s=Ca(r,Su|at,i);return function(n){return wQ(s(n),t)}}function pS(e,t){let i=e[t];if(i!==void 0){if(typeof i!="number")throw Error(`Expected a number for ${t}`);return i}}function bQ(e,t){let i=e[t];if(i!==void 0){if(typeof i=="number")return kr(i);if(!Array.isArray(i)||i.length!==2||typeof i[0]!="number"||typeof i[1]!="number")throw Error(`Expected a number or size array for ${t}`);return i}}function _Q(e,t){let i=e[t];if(i!==void 0){if(typeof i!="string")throw Error(`Expected a string for ${t}`);return i}}function BF(e,t){let i=e[t];if(i!==void 0){if(i!=="bottom-left"&&i!=="bottom-right"&&i!=="top-left"&&i!=="top-right")throw Error(`Expected bottom-left, bottom-right, top-left, or top-right for ${t}`);return i}}function UF(e,t){let i=e[t];if(i!==void 0){if(i!=="pixels"&&i!=="fraction")throw Error(`Expected pixels or fraction for ${t}`);return i}}function TQ(e,t){let i=e[t];if(i!==void 0)return $m(i,t)}function h1(e,t){let i=e[t];
2107if(i!==void 0){if(typeof i!="string")throw Error(`Expected a string for ${t}`);if(i!=="declutter"&&i!=="obstacle"&&i!=="none")throw Error(`Expected declutter, obstacle, or none for ${t}`);return i}}function $m(e,t){if(!Array.isArray(e))throw Error(`Expected an array for ${t}`);let i=e.length;for(let r=0;r<i;++r)if(typeof e[r]!="number")throw Error(`Expected an array of numbers for ${t}`);return e}function VF(e,t){if(typeof e!="string")throw Error(`Expected a string for ${t}`);return e}function mS(e,t){if(typeof e!="number")throw Error(`Expected a number for ${t}`);return e}function zF(e,t){if(typeof e=="string")return e;let i=$m(e,t),r=i.length;if(r<3||r>4)throw Error(`Expected a color with 3 or 4 values for ${t}`);return i}function GF(e,t){let i=$m(e,t);if(i.length!==2)throw Error(`Expected an array of two numbers for ${t}`);return i}function wQ(e,t){return typeof e=="number"?e:GF(e,t)}var jF={RENDER_ORDER:"renderOrder"},$F=class extends Zy{constructor(e){e||={};let t=Object.assign({},e);delete t.style,delete t.renderBuffer,delete t.updateWhileAnimating,delete t.updateWhileInteracting,super(t),this.declutter_=e.declutter?String(e.declutter):void 0,this.renderBuffer_=e.renderBuffer===void 0?100:e.renderBuffer,this.style_=null,this.styleFunction_=void 0,this.setStyle(e.style),this.updateWhileAnimating_=e.updateWhileAnimating===void 0?!1:e.updateWhileAnimating,this.updateWhileInteracting_=e.updateWhileInteracting===void 0?!1:e.updateWhileInteracting}getDeclutter(){return this.declutter_}getFeatures(e){return super.getFeatures(e)}getRenderBuffer(){return this.renderBuffer_}getRenderOrder(){return this.get(jF.RENDER_ORDER)}getStyle(){return this.style_}getStyleFunction(){return this.styleFunction_}getUpdateWhileAnimating(){return this.updateWhileAnimating_}getUpdateWhileInteracting(){return this.updateWhileInteracting_}renderDeclutter(e,t){let i=this.getDeclutter();i in e.declutter||(e.declutter[i]=new lJ(9)),this.getRenderer().renderDeclutter(e,t)}setRenderOrder(e){this.set(jF.RENDER_ORDER,e)}setStyle(e){this.style_=e===void 0?PF:e;let t=SQ(e);this.styleFunction_=e===null?void 0:hQ(t),this.changed()}setDeclutter(e){this.declutter_=e?String(e):void 0,this.changed()}};function SQ(e){if(e===void 0)return PF;if(!e)return null;if(typeof e=="function"||e instanceof uc)return e;if(!Array.isArray(e))return FF([e]);if(e.length===0)return[];let t=e.length,i=e[0];if(i instanceof uc){let r=Array(t);for(let s=0;s<t;++s){let n=e[s];if(!(n instanceof uc))throw Error("Expected a list of style instances");r[s]=n}return r}if("style"in i){let r=Array(t);for(let s=0;s<t;++s){let n=e[s];if(!("style"in n))throw Error("Expected a list of rules with a style property");r[s]=n}return cQ(r)}return FF(e)}var WF=class extends Nl{constructor(e,t,i,r){super(e),this.inversePixelTransform=t,this.frameState=i,this.context=r}},MQ=class extends Ey{constructor(e){super(),this.map_=e}dispatchRenderEvent(e,t){qe()}calculateMatrices2D(e){let t=e.viewState,i=e.coordinateToPixelTransform,r=e.pixelToCoordinateTransform;So(i,e.size[0]/2,e.size[1]/2,1/t.resolution,-1/t.resolution,-t.rotation,-t.center[0],-t.center[1]),PI(r,i)}forEachFeatureAtCoordinate(e,t,i,r,s,n,a,o){let l,h=t.viewState;function u(b,_,T,w){return s.call(n,_,b?T:null,w)}let d=h.projection,c=Ck(e.slice(),d),p=[[0,0]];if(d.canWrapX()&&r){let b=Jt(d.getExtent());p.push([-b,0],[b,0])}let m=t.layerStatesArray,g=m.length,f=[],y=[];for(let b=0;b<p.length;b++)for(let _=g-1;_>=0;--_){let T=m[_],w=T.layer;if(w.hasRenderer()&&Yw(T,h)&&a.call(o,w)){let M=w.getRenderer(),S=w.getSource();if(M&&S){let R=S.getWrapX()?c:e,I=u.bind(null,T.managed);y[0]=R[0]+p[b][0],y[1]=R[1]+p[b][1],l=M.forEachFeatureAtCoordinate(y,t,i,I,f)}if(l)return l}}if(f.length===0)return;let x=1/f.length;return f.forEach((b,_)=>b.distanceSq+=_*x),f.sort((b,_)=>b.distanceSq-_.distanceSq),f.some(b=>l=b.callback(b.feature,b.layer,b.geometry)),l}hasFeatureAtCoordinate(e,t,i,r,s,n){return this.forEachFeatureAtCoordinate(e,t,i,r,Ay,this,s,n)!==void 0}getMap(){return this.map_}renderFrame(e){qe()}scheduleExpireIconCache(e){en.canExpireCache()&&e.postRenderFunctions.push(CQ)}};function CQ(e,t){en.expire()}var RQ=class extends MQ{constructor(e){super(e),this.fontChangeListenerKey_=ft(hc,_m.PROPERTYCHANGE,e.redrawText,e),this.element_=Js?tF():document.createElement("div");let t=this.element_.style;t.position="absolute",t.width="100%",t.height="100%",t.zIndex="0",this.element_.className=Xy+" ol-layers";let i=e.getViewport();i&&i.insertBefore(this.element_,i.firstChild||null),this.children_=[],this.renderedVisible_=!0}
2107dispatchRenderEvent(e,t){let i=this.getMap();if(i.hasListener(e)){let r=new WF(e,void 0,t);i.dispatchEvent(r)}}disposeInternal(){oi(this.fontChangeListenerKey_),this.element_.remove(),super.disposeInternal()}renderFrame(e){if(!e){this.renderedVisible_&&=(this.element_.style.display="none",!1);return}this.calculateMatrices2D(e),this.dispatchRenderEvent(Ma.PRECOMPOSE,e);let t=e.layerStatesArray.sort((a,o)=>a.zIndex-o.zIndex);t.some(a=>a.layer instanceof $F&&a.layer.getDeclutter())&&(e.declutter={});let i=e.viewState;this.children_.length=0;let r=[],s=null;for(let a=0,o=t.length;a<o;++a){let l=t[a];e.layerIndex=a;let h=l.layer,u=h.getSourceState();if(!Yw(l,i)||u!="ready"&&u!="undefined"){h.unrender();continue}let d=h.render(e,s);d&&(d!==s&&(this.children_.push(d),s=d),r.push(l))}this.declutter(e,r),VZ(this.element_,this.children_);let n=this.getMap().getTargetElement();if(Vl(n)){let a=n.getContext("2d");for(let o of this.children_){let l=o.firstElementChild||o,h=o.style.backgroundColor;if(h&&(!Vl(l)||l.width>0)&&(a.fillStyle=h,a.fillRect(0,0,n.width,n.height)),Vl(l)&&l.width>0){a.save();let u=o.style.opacity||l.style.opacity;a.globalAlpha=u===""?1:Number(u);let d=l.style.transform;if(d)a.transform(...ww(d));else{let c=parseFloat(l.style.width)/l.width,p=parseFloat(l.style.height)/l.height;a.transform(c,0,0,p,0,0)}a.drawImage(l,0,0),a.restore()}}}this.dispatchRenderEvent(Ma.POSTCOMPOSE,e),this.renderedVisible_||=(this.element_.style.display="",!0),this.scheduleExpireIconCache(e)}declutter(e,t){if(e.declutter){for(let i=t.length-1;i>=0;--i){let r=t[i],s=r.layer;s.getDeclutter()&&s.renderDeclutter(e,r)}t.forEach(i=>i.layer.renderDeferred(e))}}};function HF(e){if(e instanceof Zy){e.setMapInternal(null);return}e instanceof _u&&e.getLayers().forEach(HF)}function qF(e,t){if(e instanceof Zy){e.setMapInternal(t);return}if(e instanceof _u){let i=e.getLayers().getArray();for(let r=0,s=i.length;r<s;++r)qF(i[r],t)}}var XF=class extends _a{constructor(e){super(),e||={},this.on,this.once,this.un;let t=EQ(e);this.renderComplete_=!1,this.loaded_=!0,this.boundHandleBrowserEvent_=this.handleBrowserEvent.bind(this),this.maxTilesLoading_=e.maxTilesLoading===void 0?16:e.maxTilesLoading,this.pixelRatio_=e.pixelRatio===void 0?KK:e.pixelRatio,this.postRenderTimeoutHandle_,this.animationDelayKey_,this.animationDelay_=this.animationDelay_.bind(this),this.coordinateToPixelTransform_=Qs(),this.pixelToCoordinateTransform_=Qs(),this.frameIndex_=0,this.frameState_=null,this.previousExtent_=null,this.viewPropertyListenerKey_=null,this.viewChangeListenerKey_=null,this.layerGroupPropertyListenerKeys_=null,Js||(this.viewport_=document.createElement("div"),this.viewport_.className="ol-viewport"+("ontouchstart"in window?" ol-touch":""),this.viewport_.style.position="relative",this.viewport_.style.overflow="hidden",this.viewport_.style.width="100%",this.viewport_.style.height="100%",this.overlayContainer_=document.createElement("div"),this.overlayContainer_.style.position="absolute",this.overlayContainer_.style.zIndex="0",this.overlayContainer_.style.width="100%",this.overlayContainer_.style.height="100%",this.overlayContainer_.style.pointerEvents="none",this.overlayContainer_.className="ol-overlaycontainer",this.viewport_.appendChild(this.overlayContainer_),this.overlayContainerStopEvent_=document.createElement("div"),this.overlayContainerStopEvent_.style.position="absolute",this.overlayContainerStopEvent_.style.zIndex="0",this.overlayContainerStopEvent_.style.width="100%",this.overlayContainerStopEvent_.style.height="100%",this.overlayContainerStopEvent_.style.pointerEvents="none",this.overlayContainerStopEvent_.className="ol-overlaycontainer-stopevent",this.viewport_.appendChild(this.overlayContainerStopEvent_)),this.mapBrowserEventHandler_=null,this.moveTolerance_=e.moveTolerance,this.keyboardEventTarget_=t.keyboardEventTarget,this.targetChangeHandlerKeys_=null,this.targetElement_=null,Js||(this.resizeObserver_=new ResizeObserver(()=>this.updateSize())),this.controls=t.controls||(Js?new wn:$Z()),this.interactions=t.interactions||(Js?new wn:aJ({onFocusOnly:!0}
2107)),this.overlays_=t.overlays,this.overlayIdIndex_={},this.renderer_=null,this.postRenderFunctions_=[],this.tileQueue_=new eZ(this.getTilePriority.bind(this),this.handleTileChange_.bind(this)),this.addChangeListener(Pr.LAYERGROUP,this.handleLayerGroupChanged_),this.addChangeListener(Pr.VIEW,this.handleViewChanged_),this.addChangeListener(Pr.SIZE,this.handleSizeChanged_),this.addChangeListener(Pr.TARGET,this.handleTargetChanged_),this.setProperties(t.values);let i=this;e.view&&!(e.view instanceof Ta)&&e.view.then(function(r){i.setView(new Ta(r))}),this.controls.addEventListener(Zs.ADD,r=>{r.element.setMap(this)}),this.controls.addEventListener(Zs.REMOVE,r=>{r.element.setMap(null)}),this.interactions.addEventListener(Zs.ADD,r=>{r.element.setMap(this)}),this.interactions.addEventListener(Zs.REMOVE,r=>{r.element.setMap(null)}),this.overlays_.addEventListener(Zs.ADD,r=>{this.addOverlayInternal_(r.element)}),this.overlays_.addEventListener(Zs.REMOVE,r=>{let s=r.element.getId();s!==void 0&&delete this.overlayIdIndex_[s.toString()],r.element.setMap(null)}),this.controls.forEach(r=>{r.setMap(this)}),this.interactions.forEach(r=>{r.setMap(this)}),this.overlays_.forEach(this.addOverlayInternal_.bind(this))}addControl(e){this.getControls().push(e)}addInteraction(e){this.getInteractions().push(e)}addLayer(e){this.getLayerGroup().getLayers().push(e)}handleLayerAdd_(e){qF(e.layer,this)}addOverlay(e){this.getOverlays().push(e)}addOverlayInternal_(e){let t=e.getId();t!==void 0&&(this.overlayIdIndex_[t.toString()]=e),e.setMap(this)}disposeInternal(){this.controls.clear(),this.interactions.clear(),this.overlays_.clear(),this.resizeObserver_?.disconnect(),this.setTarget(null),super.disposeInternal()}forEachFeatureAtPixel(e,t,i){if(!this.frameState_||!this.renderer_)return;let r=this.getCoordinateFromPixelInternal(e);i=i===void 0?{}:i;let s=i.hitTolerance===void 0?0:i.hitTolerance,n=i.layerFilter===void 0?Ay:i.layerFilter,a=i.checkWrapped!==!1;return this.renderer_.forEachFeatureAtCoordinate(r,this.frameState_,s,a,t,null,n,null)}getFeaturesAtPixel(e,t){let i=[];return this.forEachFeatureAtPixel(e,function(r){i.push(r)},t),i}getAllLayers(){let e=[];function t(i){i.forEach(function(r){r instanceof _u?t(r.getLayers()):e.push(r)})}return t(this.getLayers()),e}hasFeatureAtPixel(e,t){if(!this.frameState_||!this.renderer_)return!1;let i=this.getCoordinateFromPixelInternal(e);t=t===void 0?{}:t;let r=t.layerFilter===void 0?Ay:t.layerFilter,s=t.hitTolerance===void 0?0:t.hitTolerance,n=t.checkWrapped!==!1;return this.renderer_.hasFeatureAtCoordinate(i,this.frameState_,s,n,r,null)}getEventCoordinate(e){return this.getCoordinateFromPixel(this.getEventPixel(e))}getEventCoordinateInternal(e){return this.getCoordinateFromPixelInternal(this.getEventPixel(e))}getEventPixel(e){let t=this.viewport_.getBoundingClientRect(),i=this.getSize(),r=t.width/i[0],s=t.height/i[1],n="changedTouches"in e?e.changedTouches[0]:e;return[(n.clientX-t.left)/r,(n.clientY-t.top)/s]}getTarget(){return this.get(Pr.TARGET)}getTargetElement(){return this.targetElement_}getCoordinateFromPixel(e){return tw(this.getCoordinateFromPixelInternal(e),this.getView().getProjection())}getCoordinateFromPixelInternal(e){let t=this.frameState_;return t?Ki(t.pixelToCoordinateTransform,e.slice()):null}getControls(){return this.controls}getOverlays(){return this.overlays_}getOverlayById(e){let t=this.overlayIdIndex_[e.toString()];return t===void 0?null:t}getInteractions(){return this.interactions}getLayerGroup(){return this.get(Pr.LAYERGROUP)}setLayers(e){let t=this.getLayerGroup();if(e instanceof wn){t.setLayers(e);return}let i=t.getLayers();i.clear(),i.extend(e)}getLayers(){return this.getLayerGroup().getLayers()}getLoadingOrNotReady(){let e=this.getLayerGroup().getLayerStatesArray();for(let t=0,i=e.length;t<i;++t){let r=e[t];if(!r.visible)continue;let s=r.layer.getRenderer();if(s&&!s.ready)return!0;let n=r.layer.getSource();if(n&&n.loading)return!0}return!1}getPixelFromCoordinate(e){let t=vo(e,this.getView().getProjection());return this.getPixelFromCoordinateInternal(t)}getPixelFromCoordinateInternal(e){let t=this.frameState_;return t?Ki(t.coordinateToPixelTransform,e.slice(0,2)):null}getPixelRatio(){return this.pixelRatio_}setPixelRatio(e){this.pixelRatio_!==e&&(this.pixelRatio_=e,this.render())}getRenderer(){return this.renderer_}getSize(){return this.get(Pr.SIZE)}getView(){return this.get(Pr.VIEW)}getViewport(){return this.viewport_}getOverlayContainer(){return this.overlayContainer_}getOverlayContainerStopEvent(){return this.overlayContainerStopEvent_}getOwnerDocument(){let e=this.getTargetElement();return e?e.ownerDocument:document}getTilePriority(e,t,i,r){return tZ(this.frameState_,e,t,i,r)}handleBrowserEvent(e,t){t||=e.type;let i=new Dl(t,this,e);this.handleMapBrowserEvent(i)}handleMapBrowserEvent(e){if(!this.frameState_)return;let t=e.originalEvent,i=t.type;if(i===vw.POINTERDOWN||i===De.WHEEL||i===De.KEYDOWN){let r=this.getOwnerDocument(),s=this.viewport_.getRootNode?this.viewport_.getRootNode():r,n=t.target,a=s instanceof ShadowRoot?s.host===n?s.host.ownerDocument:s:s===r?r.documentElement:s;if(this.overlayContainerStopEvent_.contains(n)||!a.contains(n))return}if(e.frameState=this.frameState_,this.dispatchEvent(e)!==!1){let r=this.getInteractions().getArray().slice();for(let s=r.length-1;s>=0;s--){let n=r[s];if(!(n.getMap()!==this||!n.getActive()||!this.getTargetElement())&&(!n.handleEvent(e)||e.propagationStopped))break}}}handlePostRender(){let e=this.frameState_,t=this.tileQueue_;if(!t.isEmpty()){let r=this.maxTilesLoading_,s=r,n=e?e.viewHints:void 0,a=n?n[ar.ANIMATING]||n[ar.INTERACTING]:!1;if(a){let o=Date.now()-e.time>8;r=o?0:8,s=o?0:2}t.getTilesLoading()<r&&(a&&t.reprioritize(),t.loadMoreTiles(r,s))}e&&this.renderer_&&!e.animate&&(this.renderComplete_?(this.hasListener(Ma.RENDERCOMPLETE)&&this.renderer_.dispatchRenderEvent(Ma.RENDERCOMPLETE,e),this.loaded_===!1&&(this.loaded_=!0,this.dispatchEvent(new rc(Ol.LOADEND,this,e)))):this.loaded_===!0&&(this.loaded_=!1,this.dispatchEvent(new rc(Ol.LOADSTART,this,e))));let i=this.postRenderFunctions_;if(e)for(let r=0,s=i.length;r<s;++r)i[r](this,e);i.length=0}handleSizeChanged_(){this.getView()&&!this.getView().getAnimating()&&this.getView().resolveConstraints(0),this.render()}handleTargetChanged_(){if(this.mapBrowserEventHandler_){for(let i=0,r=this.targetChangeHandlerKeys_.length;i<r;++i)oi(this.targetChangeHandlerKeys_[i]);this.targetChangeHandlerKeys_=null,this.viewport_.removeEventListener(
2107De.CONTEXTMENU,this.boundHandleBrowserEvent_),this.viewport_.removeEventListener(De.WHEEL,this.boundHandleBrowserEvent_),this.mapBrowserEventHandler_.dispose(),this.mapBrowserEventHandler_=null,this.viewport_.remove()}if(this.targetElement_&&!Vl(this.targetElement_)){this.resizeObserver_?.unobserve(this.targetElement_);let i=this.targetElement_.getRootNode();i instanceof ShadowRoot&&this.resizeObserver_.unobserve(i.host),this.setSize(void 0)}let e=this.getTarget(),t=typeof e=="string"?document.getElementById(e):e;if(this.targetElement_=t,!t)this.renderer_&&=(clearTimeout(this.postRenderTimeoutHandle_),this.postRenderTimeoutHandle_=void 0,this.postRenderFunctions_.length=0,this.renderer_.dispose(),null),this.animationDelayKey_&&=(cancelAnimationFrame(this.animationDelayKey_),void 0);else{if(Vl(t)||t.appendChild(this.viewport_),this.renderer_||=new RQ(this),!Vl(t)){this.mapBrowserEventHandler_=new ZK(this,this.moveTolerance_);for(let r in vi)this.mapBrowserEventHandler_.addEventListener(vi[r],this.handleMapBrowserEvent.bind(this));this.viewport_.addEventListener(De.CONTEXTMENU,this.boundHandleBrowserEvent_,!1),this.viewport_.addEventListener(De.WHEEL,this.boundHandleBrowserEvent_,RI?{passive:!1}:!1);let i;if(this.keyboardEventTarget_)i=this.keyboardEventTarget_;else{let r=t.getRootNode();i=r instanceof ShadowRoot?r.host:t}if(this.targetChangeHandlerKeys_=[ft(i,De.KEYDOWN,this.handleBrowserEvent,this),ft(i,De.KEYPRESS,this.handleBrowserEvent,this)],t instanceof HTMLElement){let r=t.getRootNode();r instanceof ShadowRoot&&this.resizeObserver_.observe(r.host),this.resizeObserver_?.observe(t)}}this.updateSize()}}handleTileChange_(){this.render()}handleViewPropertyChanged_(){this.render()}handleViewChanged_(){this.viewPropertyListenerKey_&&=(oi(this.viewPropertyListenerKey_),null),this.viewChangeListenerKey_&&=(oi(this.viewChangeListenerKey_),null);let e=this.getView();e&&(this.updateViewportSize_(this.getSize()),this.viewPropertyListenerKey_=ft(e,_m.PROPERTYCHANGE,this.handleViewPropertyChanged_,this),this.viewChangeListenerKey_=ft(e,De.CHANGE,this.handleViewPropertyChanged_,this),e.resolveConstraints(0)),this.render()}handleLayerGroupChanged_(){this.layerGroupPropertyListenerKeys_&&=(this.layerGroupPropertyListenerKeys_.forEach(oi),null);let e=this.getLayerGroup();e&&(this.handleLayerAdd_(new Gl("addlayer",e)),this.layerGroupPropertyListenerKeys_=[ft(e,_m.PROPERTYCHANGE,this.render,this),ft(e,De.CHANGE,this.render,this),ft(e,"addlayer",this.handleLayerAdd_,this),ft(e,"removelayer",this.handleLayerRemove_,this)]),this.render()}isRendered(){return!!this.frameState_}animationDelay_(){this.animationDelayKey_=void 0,this.renderFrame_(Date.now())}renderSync(){this.animationDelayKey_&&cancelAnimationFrame(this.animationDelayKey_),this.animationDelay_()}redrawText(){if(!this.frameState_)return;let e=this.frameState_.layerStatesArray;for(let t=0,i=e.length;t<i;++t){let r=e[t].layer;r.hasRenderer()&&r.getRenderer().handleFontsChanged()}}render(){this.renderer_&&this.animationDelayKey_===void 0&&(this.animationDelayKey_=requestAnimationFrame(this.animationDelay_))}removeControl(e){return this.getControls().remove(e)}removeInteraction(e){return this.getInteractions().remove(e)}removeLayer(e){return this.getLayerGroup().getLayers().remove(e)}handleLayerRemove_(e){HF(e.layer)}removeOverlay(e){return this.getOverlays().remove(e)}renderFrame_(e){let t=this.getSize(),i=this.getView(),r=this.frameState_,s=null;if(t!==void 0&&mF(t)&&i&&i.isDef()){let n=i.getHints(this.frameState_?this.frameState_.viewHints:void 0),a=i.getState();if(s={animate:!1,coordinateToPixelTransform:this.coordinateToPixelTransform_,declutter:null,extent:GT(a.center,a.resolution,a.rotation,t),index:this.frameIndex_++,layerIndex:0,layerStatesArray:this.getLayerGroup().getLayerStatesArray(),pixelRatio:this.pixelRatio_,pixelToCoordinateTransform:this.pixelToCoordinateTransform_,postRenderFunctions:[],size:t,tileQueue:this.tileQueue_,time:e,usedTiles:{},viewState:a,viewHints:n,wantedTiles:{},mapId:At(this),renderTargets:{}},a.nextCenter&&a.nextResolution){let o=isNaN(a.nextRotation)?a.rotation:a.nextRotation;s.nextExtent=GT(a.nextCenter,a.nextResolution,o,t)}}this.frameState_=s,this.renderer_.renderFrame(s),s&&(s.animate&&this.render(),Array.prototype.push.apply(this.postRenderFunctions_,s.postRenderFunctions),r&&(!this.previousExtent_||!qd(this.previousExtent_)&&!py(s.extent,this.previousExtent_))&&(this.dispatchEvent(new rc(Ol.MOVESTART,this,r)),this.previousExtent_=om(this.previousExtent_)),this.previousExtent_&&!s.viewHints[ar.ANIMATING]&&!s.viewHints[ar.INTERACTING]&&!py(s.extent,this.previousExtent_)&&(this.dispatchEvent(new rc(Ol.MOVEEND,this,s)),bk(s.extent,this.previousExtent_))),this.dispatchEvent(new rc(Ol.POSTRENDER,this,s)),this.renderComplete_=(this.hasListener(Ol.LOADSTART)||this.hasListener(Ol.LOADEND)||this.hasListener(Ma.RENDERCOMPLETE))&&!this.tileQueue_.getTilesLoading()&&!this.tileQueue_.getCount()&&!this.getLoadingOrNotReady(),this.postRenderTimeoutHandle_||=setTimeout(()=>{this.postRenderTimeoutHandle_=void 0,this.handlePostRender()},0)}setLayerGroup(e){let t=this.getLayerGroup();t&&this.handleLayerRemove_(new Gl("removelayer",t)),this.set(Pr.LAYERGROUP,e)}setSize(e){this.set(Pr.SIZE,e)}setTarget(e){this.set(Pr.TARGET,e)}setView(e){if(!e||e instanceof Ta){this.set(Pr.VIEW,e);return}this.set(Pr.VIEW,new Ta);let t=this;e.then(function(i){t.setView(new Ta(i))})}updateSize(){let e=this.getTargetElement(),t;if(e){let r,s;if(Vl(e)){let n=e.getContext("2d").getTransform();
2107r=e.width/n.a,s=e.height/n.d}else{let n=getComputedStyle(e);r=e.offsetWidth-parseFloat(n.borderLeftWidth)-parseFloat(n.paddingLeft)-parseFloat(n.paddingRight)-parseFloat(n.borderRightWidth),s=e.offsetHeight-parseFloat(n.borderTopWidth)-parseFloat(n.paddingTop)-parseFloat(n.paddingBottom)-parseFloat(n.borderBottomWidth)}!isNaN(r)&&!isNaN(s)&&(t=[Math.max(0,r),Math.max(0,s)],!mF(t)&&(e.offsetWidth||e.offsetHeight||e.getClientRects().length)&&vk("No map visible because the map container's width or height are 0."))}let i=this.getSize();t&&(!i||!nu(t,i))&&(this.updateViewportSize_(t),this.setSize(t))}updateViewportSize_(e){let t=this.getView();t&&t.setViewportSize(e)}};function EQ(e){let t=null;e.keyboardEventTarget!==void 0&&(t=typeof e.keyboardEventTarget=="string"?document.getElementById(e.keyboardEventTarget):e.keyboardEventTarget);let i={},r=e.layers&&typeof e.layers.getLayers=="function"?e.layers:new _u({layers:e.layers});i[Pr.LAYERGROUP]=r,i[Pr.TARGET]=e.target,i[Pr.VIEW]=e.view instanceof Ta?e.view:new Ta;let s;e.controls!==void 0&&(Array.isArray(e.controls)?s=new wn(e.controls.slice()):(It(typeof e.controls.getArray=="function","Expected `controls` to be an array or an `ol/Collection.js`"),s=e.controls));let n;e.interactions!==void 0&&(Array.isArray(e.interactions)?n=new wn(e.interactions.slice()):(It(typeof e.interactions.getArray=="function","Expected `interactions` to be an array or an `ol/Collection.js`"),n=e.interactions));let a;return e.overlays===void 0?a=new wn:Array.isArray(e.overlays)?a=new wn(e.overlays.slice()):(It(typeof e.overlays.getArray=="function","Expected `overlays` to be an array or an `ol/Collection.js`"),a=e.overlays),{controls:s,interactions:n,keyboardEventTarget:t,overlays:a,values:i}}function Wm(){let e=[];return{add(t,i,r){let s=mo(t,i,r);return e.push(s),s},dispose(){e.forEach(t=>t()),e.length=0}}}var Wl={PRELOAD:"preload",USE_INTERIM_TILES_ON_ERROR:"useInterimTilesOnError"},u1=class extends Zy{constructor(e){e||={};let t=Object.assign({},e),i=e.cacheSize;delete e.cacheSize,delete t.preload,delete t.useInterimTilesOnError,super(t),this.on,this.once,this.un,this.cacheSize_=i,this.setPreload(e.preload===void 0?0:e.preload),this.setUseInterimTilesOnError(e.useInterimTilesOnError===void 0?!0:e.useInterimTilesOnError)}getCacheSize(){return this.cacheSize_}getPreload(){return this.get(Wl.PRELOAD)}setPreload(e){this.set(Wl.PRELOAD,e)}getUseInterimTilesOnError(){return this.get(Wl.USE_INTERIM_TILES_ON_ERROR)}setUseInterimTilesOnError(e){this.set(Wl.USE_INTERIM_TILES_ON_ERROR,e)}getData(e){return super.getData(e)}},AQ=5,Hm=class extends mm{constructor(e){super(),this.ready=!0,this.boundHandleImageChange_=this.handleImageChange_.bind(this),this.layer_=e,this.staleKeys_=[],this.maxStaleKeys=AQ}getStaleKeys(){return this.staleKeys_}prependStaleKey(e){this.staleKeys_.unshift(e),this.staleKeys_.length>this.maxStaleKeys&&(this.staleKeys_.length=this.maxStaleKeys)}getFeatures(e){return qe()}getData(e){return null}prepareFrame(e){return qe()}renderFrame(e,t){return qe()}forEachFeatureAtCoordinate(e,t,i,r,s){}getLayer(){return this.layer_}handleFontsChanged(){}handleImageChange_(e){let t=e.target;(t.getState()===Ge.LOADED||t.getState()===Ge.ERROR)&&this.renderIfReadyAndVisible()}loadImage(e){let t=e.getState();return t!=Ge.LOADED&&t!=Ge.ERROR&&e.addEventListener(De.CHANGE,this.boundHandleImageChange_),t==Ge.IDLE&&(e.load(),t=e.getState()),t==Ge.LOADED}renderIfReadyAndVisible(){let e=this.getLayer();e&&e.getVisible()&&e.getSourceState()==="ready"&&e.changed()}renderDeferred(e){}disposeInternal(){delete this.layer_,super.disposeInternal()}};function Eo(e,t,i,r){return r===void 0?[e,t,i]:(r[0]=e,r[1]=t,r[2]=i,r)}function YF(e,t,i){return e+"/"+t+"/"+i}function NQ(e){return YF(e[0],e[1],e[2])}function d1(e,t,i,r,s){return`${At(e)},${t},${YF(i,r,s)}`}function LQ(e){return PQ(e[0],e[1],e[2])}function PQ(e,t,i){return(t<<e)+i}function kQ(e,t){let i=e[0],r=e[1],s=e[2];if(t.getMinZoom()>i||i>t.getMaxZoom())return!1;let n=t.getFullTileRange(i);return n?n.containsXY(r,s):!0}var Ao=new Map,IQ=new Un,gS=class extends pm{constructor(e){super(e),this.alpha=0,this.hasRenderedAtLeastOnce=!1,this.container=e.container,this.tile=e.tile,this.tileGrid=e.tileGrid,this.threejsLayer=e.threejsLayer,this.master=e.threejsLayer.master,this.srgb=this.master.data.colorOptions.srgb,this.renderOrder=Math.max(0,this.master.renderOrder),this.zoomLevel=this.tile.tileCoord[0],this.plane=new xt(IQ,new Qn({transparent:!0,depthWrite:!1,map:null,alphaTest:.01,color:16777215})),this.plane.visible=!1,this.tileSize=this.tileGrid.getTileSize(this.tile.tileCoord[0]),this.loaded=this.tile.getState()===he.LOADED,this.ready=!1,this._pendingOperations=new Set,this._disposed=!1;let t=this.tile.getImage();t instanceof Image&&!t.crossOrigin&&(t.crossOrigin="anonymous"),this.tile.getState()===he.LOADED?this.handleTileChange_():this.tile.addEventListener(
2107De.CHANGE,this.handleTileChange_)}handleTileChange_=async()=>{let e=this.tile.getState();if(e==he.LOADING||e==he.IDLE||this._disposed)return;this.tile.removeEventListener(De.CHANGE,this.handleTileChange_);let t=this.tile.getKey();if(e==he.ERROR||e==he.EMPTY||e==he.ABORT)return;if(this.loaded=!0,this.ready=!0,this.threejsLayer.currentTileZoom>=0){let s=this.zoomLevel,n=this.threejsLayer.currentTileZoom;if(Math.abs(s-n)>1)return}if(Ao.has(t)){if(this._disposed)return;let s=Ao.get(t);s.count++;let n=Fi(s.texture);this.plane.material.colorNode=n.rgb,this.plane.material.opacityNode=n.a.mul(D_),N.onUpdate.add(this.update),!this.plane.parent&&this.container&&(this.plane.renderOrder=this.zoomLevel,this.container.add(this.plane),this.hasRenderedAtLeastOnce=!0);return}let i=this.tile.getImage(),r=Symbol("createImageBitmap");this._pendingOperations.add(r),createImageBitmap(i,{imageOrientation:"none"}).then(s=>{if(this._disposed||!this._pendingOperations.has(r)){s.close?.();return}if(this._pendingOperations.delete(r),this.tile==null)return;let n=new Li(s);n.needsUpdate=!0,n.generateMipmaps=!1,n.minFilter=mi,n.magFilter=mi,n.colorSpace
2107=this.srgb?Gi:"",n.anisotropy=1,Ao.set(t,{texture:n,count:1});let a=Symbol("gpuUpload");this._pendingOperations.add(a),q.gpuUploadTexture(n).then(()=>{if(this._disposed||!this._pendingOperations.has(a)){let o=Ao.get(t);o&&(o.count--,o.count===0&&(q.queueForSafeDispose(o.texture),Ao.delete(t)));return}if(this._pendingOperations.delete(a),this.tile!=null){if(this.threejsLayer.currentTileZoom>=0){let o=this.zoomLevel,l=this.threejsLayer.currentTileZoom;if(Math.abs(o-l)>1){let h=Ao.get(t);h&&(h.count--,h.count===0&&(q.queueForSafeDispose(h.texture),Ao.delete(t)));return}}this.plane.material.colorNode=Fi(n).rgb,this.plane.material.opacityNode=Fi(n).a.mul(D_),N.onUpdate.add(this.update),this.plane.renderOrder=this.zoomLevel,this.container.add(this.plane),this.hasRenderedAtLeastOnce=!0}}).catch(o=>{this._pendingOperations.delete(a),console.error("Error during GPU upload:",o)})}).catch(s=>{this._pendingOperations.delete(r),console.error("Error creating ImageBitmap:",s)})};hide=()=>{this.plane.visible=!1};update=e=>{if(!this.plane)return;let t=this.plane.material.opacity;this.threejsLayer.master.isPlaying||!this.threejsLayer.master.fadeInTiles?this.plane.material.opacity=1:(this.plane.material.opacity=this.alpha,this.threejsLayer.master.directRender&&(this.plane.material.opacity*=this.threejsLayer.master.opacity*this.threejsLayer.master.tileOpacity)),t!=this.plane.material.opacity&&(this.threejsLayer.needsRender=!0)};dispose(){if(this.tile!==null){if(this._disposed=!0,this._pendingOperations.clear(),N.onUpdate.remove(this.update),this.tile.removeEventListener(De.CHANGE,this.handleTileChange_),this.plane&&this.plane.parent&&this.container.remove(this.plane),this.plane){let e=this.tile.getKey(),t=Ao.get(e);t&&(t.count--,t.count===0&&(q.queueForSafeDispose(t.texture),Ao.delete(e))),this.plane.material&&(this.plane.material.colorNode=null,this.plane.material.opacityNode=null,q.queueForSafeDispose(this.plane.material)),this.plane.geometry=null,this.plane.material=null}this.plane=null,this.tile=null,this.tileGrid=null,this.threejsLayer=null,this.master=null,this.container=null,super.dispose()}}};Math.PI*2;var FQ=(e,t=0,i=1)=>Math.max(t,Math.min(e,i)),KF=(e,t,i)=>(e-t)/(i-t),qm=e=>((e+180)%360+360)%360-180;function Xm(e,t){let i=e.layerStatesArray[e.layerIndex];i.extent&&(t=ds(t,su(i.extent,e.viewState.projection)));let r=i.layer.getRenderSource();if(r&&!r.getWrapX()){let s=r.getTileGridForProjection(e.viewState.projection).getExtent();s&&(t=ds(t,s))}return t}function Ym(e,t){return`${e.getKey()},${NQ(t)}`}var Km=class En{static instance=null;static initialPoolSize=8;static maxPoolSize=16;constructor(t=En.initialPoolSize){if(En.instance)return En.instance;this.checkOutCount=0,this.maxConcurrentCheckouts=0,this.pool=new m2(()=>new zr(N.width*N.devicePixelRatio,N.height*N.devicePixelRatio,{depthBuffer:!1,stencilBuffer:!1,samples:1,alpha:!0,generateMipmaps:!0,type:hr,colorSpace:""}),t,!0),En.instance=this}static getInstance(){return En.instance||new En,En.instance}checkOut(t=""){this.checkOutCount++,this.maxConcurrentCheckouts=Math.max(this.maxConcurrentCheckouts,this.checkOutCount);let i=this.pool.checkOut();return this.pool.size===0&&this.checkOutCount>=En.maxPoolSize-2&&console.warn(`RenderTargetPool: Near max capacity! ${this.checkOutCount} RTs checked out, max: ${En.maxPoolSize}`),i}checkIn(t,i=""){this.checkOutCount--,this.pool.checkIn(t)}dispose(){this.pool&&=(this.pool.dispose(),null),En.instance=null}getStats(){if(!this.pool)return{available:0,inUse:0,total:0,maxConcurrent:0};let t=this.pool.size,i=this.checkOutCount;return{available:t,inUse:i,total:t+i,maxConcurrent:this.maxConcurrentCheckouts}}},ps=typeof window<"u"&&(window.location.search.includes("tiledebug")||!1),ZF=typeof window<"u"&&window.location.search.includes("tiledebug=verbose"),fS=0,DQ=0,Ls=-1,yS=0,JF=200,OQ=12e3,BQ=200,UQ=100,VQ=100,Hl=0,QF=16,zQ=100,e5=class fg extends Hm{static instances=[];constructor(t,i={},r){super(t),this.options=i,this.master=r,this.loadPriority=this.getPriority(),this.renderTarget=null,this.container=window.location.search.includes("bundle")?new XW:new Gr,this.container.renderOrder=this.master.renderOrder,this.srgb=this.master.data.colorOptions.srgb,this.onTilesLoaded=new je,this.onContentReady=new je,this.tmpTileCoord=Eo(0,0,0),this.loadRequireTiles=new Map,this.activeTiles=new Map,this.fadingTiles=new Map,this.tempTileRange_={minX:0,minY:0,maxX:0,maxY:0},this.currentZoom=-1,this.currentTileZoom=-1,this.currentSourceKey=null,this.zoomSettledAt=0,this.zoomTransitionDelay=VQ,this.zoomSettled=!1,this.initialLoadComplete=!1,this.isPreloadingBatch=!1,this._lastPreloadTickAt=0,this._prevMoving=!1,this._onMoveEndPreload=()=>{this._debug("idle-preload: moveend trigger"),this._lastPreloadTickAt=0,this.maybeIdlePreloadTick()},ue.openLayerMap?.on?.("moveend",this._onMoveEndPreload),this.loadingTilesCount=0,this.allTilesLoaded=!1,this.allTilesDisplayed=!1,this.totalTilesLoaded=0,this.visibleTileCount=0,this._debug=(...s)=>{if(ps){if(!ZF){let n=String(s[0]??"");for(let a of["tick","trigger","enqueue","skip (busy)","moving->idle","tileload","create rep"])if(n.includes(a))return}console.log(`[${this.master?.name||"tile"}]`,...s)}},this.disposeOnlyWhenStable=!0,this.pendingDisposals=new Set,this.tileSource=this.getLayer().getRenderSource(),this.tileSource.on("tileloadstart",this.onTileLoadStart),this.tileSource.on("tileloadend",this.onTileLoadEnd),this.tileSource.on("tileloaderror",this.onTileError),this.resizeHandler=Al(()=>this.resize(),350),N.onResize.add(this.resizeHandler),fg.instances||=[],fg.instances.push(this)}render(t){super.render(t)}resize=()=>{let t=this.master?.isUVDataLayer||!1,i=this.master?.currentLayer===this.getLayer();this.master?.visible&&i&&(t&&this.master?.parentLayer&&!(this.master.parentLayer.arrows?.immediateVisible||this.master.parentLayer.barbules?.immediateVisible||this.master.parentLayer.particles?.immediateVisible)||this.renderTarget&&setTimeout(()=>{let r=N.width*N.devicePixelRatio,s=N.height*N.devicePixelRatio;this.renderTarget.setSize(r,s),setTimeout(()=>{this.render3d()},1)},1))};initRT=()=>{this.master.directRender||this.renderTarget||(this.renderTarget=Km.getInstance().checkOut(),this.firstRen
2107derTracked||(this.firstRenderTracked=!0,Bi.value++),this.render3d())};releaseRT=()=>{this.renderTarget&&=(Km.getInstance().checkIn(this.renderTarget),null)};getPriority=()=>DQ++;render3d=()=>{if(this.master.directRender){q.scheduleRender(150);return}this.initRT(),q.renderer.setClearColor(0,0),q.renderer.setRenderTarget(this.renderTarget),q.renderer.render(this.container,q.camera),this.firstRenderTracked&&!this.firstRenderCompleted&&(this.firstRenderCompleted=!0,Bi.value--),q.renderer.setRenderTarget(null),q.renderer.setClearColor(14540253,1),q.scheduleRender()};reinitialize=()=>{this.isInitialized||(this.isInitialized=!0,N.onUpdate.add(this.update),this.needsRender=!0,this.zoomSettledAt=performance.now(),this.zoomSettled=!1,this.render3d())};update=t=>{this.master.opacity<.001||(this.updateZoomSettling(t),this.updateActiveTiles(t),this.updateFadingTiles(t),this.processePendingDisposals(),this.maybeIdlePreloadTick(),this._prevMoving&&!this.master.isMoving&&(this._debug("idle-preload: moving->idle trigger"),this._lastPreloadTickAt=0,this.maybeIdlePreloadTick()),this._prevMoving=this.master.isMoving,this.cleanupAbandonedTiles(),this.needsRender&&=(this.render3d(),!1))};maybeIdlePreloadTick(){if(this.loadingTilesCount===0&&this.loadRequireTiles.size>0&&(this.cleanupAbandonedTiles(),this.loadRequireTiles.size>0)){let m=!1;if(this.loadRequireTiles.forEach(g=>{let f=Ym(this.getLayer().getRenderSource(),g.tileCoord);(this.activeTiles.has(f)||this.fadingTiles.has(f))&&(m=!0)}),!m)ps&&this._debug("idle-preload: force clear required",this.loadRequireTiles.size),this.loadRequireTiles.clear(),this.maybeUnlock();else{ps&&this._debug("idle-preload: keeping required tiles",this.loadRequireTiles.size);let g=0;this.loadRequireTiles.forEach(f=>{f.getState()===he.IDLE&&(f.load(),g++,ps&&this._debug("idle-preload: manually load stuck tile",f.getKey()))}),ps&&g>0&&this._debug("idle-preload: triggered",g,"stuck IDLE tiles")}}if(this.loadingTilesCount!==0||this.loadRequireTiles.size!==0){ps&&this._debug("idle-preload: skip (busy)",{loading:this.loadingTilesCount,required:this.loadRequireTiles.size});return}let t=performance.now();if(t-this._lastPreloadTickAt<zQ)return;this._lastPreloadTickAt=t,ps&&this._debug("idle-preload: tick",{loading:this.loadingTilesCount,required:this.loadRequireTiles.size});let i=ue.openLayerMap;if(!i)return;let r=i.getView(),s=ue.getCurrentExtent(),n=this.getLayer().getRenderSource(),a=n.getTileGridForProjection(r.getProjection()),o=r.getResolution(),l=a.getZForResolution(o),h=l%1>=.1?Math.ceil(l):Math.floor(l),u=a.getTileRangeForExtentAndZ(s,h,this.tempTileRange_);ps&&this._debug("idle-preload: trigger",{z:h,extent:[...s],baseRange:u});let d={minX:u.minX-Hl,maxX:u.maxX+Hl,minY:u.minY-Hl,maxY:u.maxY+Hl},c=(m,g)=>m>=u.minX&&m<=u.maxX&&g>=u.minY&&g<=u.maxY,p=0;this.isPreloadingBatch=!0;for(let m=d.minX;m<=d.maxX;m++)for(let g=d.minY;g<=d.maxY;g++){if(c(m,g))continue;let f=Eo(h,m,g,this.tmpTileCoord),y=this.wrapTileCoord(f,h),x=a.getTileCoordExtent(y);if(ds(a.getExtent(),x)[0]==1/0)continue;let b=Ym(n,f),_=this.activeTiles.get(b)||this.fadingTiles.get(b);if(!_){let[w,M,S]=f,R=n.getTile(w,M,S,N.devicePixelRatio||1,r.getProjection());if(!R)continue;_=new gS({tile:R,tileGrid:n.getTileGridForProjection(r.getProjection()),container:this.container,threejsLayer:this}),_.sourceKey=n.getKey(),_.customAlpha=1,_.alpha=1,_.fadingIn=!1,_.renderOrder=fS++,this.activeTiles.set(b,_),ps&&this._debug("idle-preload: create rep",b,f.join(","))}let T=_.tile;if(T.getState()===he.IDLE&&(T.load(),p++,ps&&this._debug("idle-preload: load()",T.getKey()),p>=QF)){this.isPreloadingBatch=!1;return}}this.isPreloadingBatch=!1,ZF&&p===0&&this._debug("idle-preload: no candidates")}updateZoomSettling(t){if(this.zoomSettledAt===0)return;let i=performance.now()-this.zoomSettledAt,r=this.zoomSettled;this.zoomSettled=i>this.zoomTransitionDelay,this.zoomSettled&&!r&&(this.needsRender=!0,ue.openLayerMap.render())}updateActiveTiles(t){let i=t/BQ;this.activeTiles.forEach(r=>{r.update&&r.update(t),r.fadingIn&&r.ready&&(r.plane?.material?.colorNode||r.plane?.material?.map)&&(r.customAlpha=Math.min(1,r.customAlpha+i),r.customAlpha>=1&&(r.customAlpha=1,r.fadingIn=!1),r.alpha=r.customAlpha)})}updateFadingTiles(t){if(this.fadingTiles.size===0)return;let i=t/UQ,r=this.isSystemStable(),s=[];
2107this.fadingTiles.forEach((n,a)=>{n.update&&n.update(t),n.fadeAlpha===void 0&&(n.fadeAlpha=1),n.fadeAlpha=Math.max(0,n.fadeAlpha-i),n.plane?.material&&(n.alpha=n.fadeAlpha),n.fadeAlpha<=0&&r&&(this._debug("faded->dispose",n.tile?.getKey()),this.safeTileDisposal(n),s.push(a))}),s.forEach(n=>this.fadingTiles.delete(n)),s.length>0&&this.updateVisibleTileCount()}onTileLoadStart=t=>{if(t&&t.tile){let i=t.tile.getKey();t.tile._loadStartedAt=performance.now(),this.loadRequireTiles.has(i)&&this.loadRequireTiles.delete(i)}this.loadingTilesCount++,t&&t.tile,Bi.value++,this.maybeUnlock(),this.allTilesLoaded=!1};onTileError=t=>{if(t&&t.tile){let i=t.tile.getKey();this.loadRequireTiles.has(i)&&this.loadRequireTiles.delete(i);let r=t.tile;r&&(r._hasError=!0,console.warn(`Tile load error for ${this.master.name}: ${i}`),this._debug("tileloaderror",i))}this.onTileLoadEnd(t)};onTileLoadEnd=t=>{this.loadingTilesCount--,t&&t.tile,setTimeout(()=>{Bi.value--},1),this.totalTilesLoaded++,this.maybeUnlock(),this.loadingTilesCount===0&&(this.allTilesLoaded=!0,Ls=-1,this.onTilesLoaded.dispatch(),this._lastPreloadTickAt=0)};renderFrame(t){let{viewState:i,time:r}=t,s=this.getLayer().getRenderSource(),n=s.getTileGridForProjection(i.projection),a=Xm(t,t.extent),o=Math.max(3,i.zoom),l=s.getKey();this.updateZoomState(o,l);let h=i.resolution,u=n.getZForResolution(h);this.master.name=="radar"||this.master.name;let d=u%1>=.1?Math.ceil(u):Math.floor(u);this.currentTileZoom=d,this.handleTileFading(d,l);let c=!this.initialLoadComplete;(this.zoomSettled||c)&&this.enqueueTiles(t,a,d),this.drawTiles(t,a,n),this.checkTilesDisplayed(),this.updateInitialLoadState(),this.updateVisibleTileCount(),this.needsRender=!0,this.loadingTilesCount===0&&this.loadRequireTiles.size===0&&!this.master.isMoving&&(this._debug("preload: trigger",{z:d,extent:[...a]}),this.preloadTiles(t,a,d))}updateZoomState(t,i){let r=Math.abs(t-this.currentZoom)>.001,s=this.currentSourceKey!==i;(r||s)&&(this.currentZoom=t,this.currentSourceKey=i,this.zoomSettledAt=performance.now(),this.zoomSettled=!1)}handleTileFading(t,i){if(!this.zoomSettled)return;let r=this.master.data.transparentTiles===!0,s=new Set,n=new Set,a=new Set;this.activeTiles.forEach((p,m)=>{p.sourceKey!==i&&a.add(m),p.tile.tileCoord[0]===t&&p.sourceKey===i&&(s.add(m),p.ready&&(p.plane?.material?.colorNode||p.plane?.material?.map)&&n.add(m))});let o=s.size>0&&s.size===n.size,l=r?n.size>=1:o,h=performance.now()-this.zoomSettledAt>1e3,u=n.size>0&&n.size/Math.max(1,s.size)>=.8,d=l&&(o||r&&a.size>0),c=h&&u&&n.size>0;if(d||c){let p=[],m=[];this.activeTiles.forEach((g,f)=>{let y=g.tile.tileCoord[0],x=g.sourceKey!==i,b=y!==t;if(x||b)if(b){if(y===4&&!this.master.isPlaying&&this.master.data.keepZoom4)return;r?m.push({rep:g,key:f,reason:`instant-cut-zoom(${y}!=${t})`}):p.push({rep:g,key:f,reason:`different-zoom-level(${y}!=${t})`})}else x&&p.push({rep:g,key:f,reason:"different-source"})}),m.forEach(({rep:g,key:f,reason:y})=>{if(this.activeTiles.has(f)){this.activeTiles.delete(f),this._debug("instant dispose (zoom)",g.tile?.getKey(),y);let x=g.tile.getKey();this.loadRequireTiles.has(x)&&this.loadRequireTiles.delete(x),this.safeTileDisposal(g)}}),p.forEach(({rep:g,key:f,reason:y})=>{if(this.activeTiles.has(f)){g.fadeAlpha=g.customAlpha===void 0?1:g.customAlpha,g.fadingIn=!1,this.fadingTiles.set(f,g),this.activeTiles.delete(f),this._debug("start fade",g.tile?.getKey(),y);let x=g.tile.getKey();this.loadRequireTiles.has(x)&&this.loadRequireTiles.delete(x)}}),this.updateVisibleTileCount()}}drawTiles(t,i,r){this.activeTiles.forEach(s=>{this.drawTile(t,s,i,r)}),this.fadingTiles.forEach(s=>{this.drawTile(t,s,i,r)})}checkTilesDisplayed(){let t=!0;this.activeTiles.forEach(i=>{i.ready||(t=!1)}),t&&this.allTilesLoaded&&this.fadingTiles.size===0?(this.allTilesDisplayed||this.onContentReady.dispatch(),this.allTilesDisplayed=!0):this.allTilesDisplayed=!1}updateInitialLoadState(){!this.initialLoadComplete&&this.zoomSettled&&this.activeTiles.size>0&&(this.initialLoadComplete=!0)}wrapTileCoord(t,i){let r=2**i,s=t[1],n=t[2],a=s%r;return a<0&&(a+=r),Eo(i,a,n)}preloadTiles(t,i,r){let{viewState:s}=t,n=this.getLayer().getRenderSource(),a=n.getTileGridForProjection(s.projection),o=At(n);t.wantedTiles[o]||(t.wantedTiles[o]={});let l=t.wantedTiles[o],h=a.getTileRangeForExtentAndZ(i,r,this.tempTileRange_),u={minX:h.minX-Hl,maxX:h.maxX+Hl,minY:h.minY-Hl,maxY:h.maxY+Hl},d=ue.openLayerMap?.getView?.()?.getCenter?.()||t.viewState.center,c=this._prevCenter||d,p=d[0]-c[0],m=d[1]-c[1];this._prevCenter=d,Math.abs(p)>Math.abs(m)?p>0?u.maxX+=1:--u.minX:Math.abs(m)>0&&(m>0?u.maxY+=1:--u.minY);let g=(y,x)=>y>=h.minX&&y<=h.maxX&&x>=h.minY&&x<=h.maxY,f=0;this.isPreloadingBatch=!0;for(let y=u.minX;y<=u.maxX;y++)for(let x=u.minY;x<=u.maxY;x++){if(g(y,x))continue;let b=Eo(r,y,x,this.tmpTileCoord),_=this.wrapTileCoord(b,r),T=a.getTileCoordExtent(_);
2107if(ds(a.getExtent(),T)[0]==1/0)continue;let w=Ym(n,b),M=this.activeTiles.get(w)||this.fadingTiles.get(w);if(!M){let[R,I,B]=b,O=n.getTile(R,I,B,t.pixelRatio,s.projection);if(!O)continue;M=new gS({tile:O,tileGrid:n.getTileGridForProjection(s.projection),container:this.container,threejsLayer:this}),M.sourceKey=n.getKey(),M.customAlpha=1,M.alpha=1,M.fadingIn=!1,M.renderOrder=fS++,this.activeTiles.set(w,M),ps&&this._debug("preload: create rep",w,b.join(","))}let S=M.tile.getKey();if(l[S]=!0,M.tile.getState()===he.IDLE&&!t.tileQueue.isKeyQueued(S)&&(this.loadRequireTiles.set(S,M.tile),t.tileQueue.enqueue([M.tile,o,a.getTileCoordCenter(b),a.getResolution(r)]),t.tileQueue.reprioritize(),f++,f>=QF)){this.isPreloadingBatch=!1;return}}this.isPreloadingBatch=!1}enqueueTiles=(t,i,r)=>{let{viewState:s}=t,n=this.getLayer().getRenderSource(),a=n.getTileGridForProjection(s.projection),o=At(n);t.wantedTiles[o]||(t.wantedTiles[o]={});let l=t.wantedTiles[o],h=a.getTileRangeForExtentAndZ(i,r,this.tempTileRange_),u=a.getResolution(r),d=a.getExtent();for(let c=h.minX;c<=h.maxX;c++)for(let p=h.minY;p<=h.maxY;p++){let m=Eo(r,c,p,this.tmpTileCoord),g=this.wrapTileCoord(m,r);if(ds(d,a.getTileCoordExtent(g))[0]==1/0)continue;let f=Ym(n,m),y=this.getOrCreateTileRepresentation(f,n,m,t,s);y&&this.enqueueTileLoad(y,l,o,a,m,u,t)}};getOrCreateTileRepresentation(t,i,r,s,n){let a=this.activeTiles.get(t);if(!a&&(a=this.fadingTiles.get(t),a&&a.tile.key===i.getKey()&&this.fadingTiles.has(t)))return this.fadingTiles.delete(t),this.activeTiles.set(t,a),this._debug("revive from fading",a.tile?.getKey()),a.customAlpha=a.fadeAlpha===void 0?a.customAlpha||0:a.fadeAlpha,a.fadingIn=!0,a.fadeAlpha=void 0,a;if(!a||a.tile.key!==i.getKey()){let[o,l,h]=r,u=i.getTile(o,l,h,s.pixelRatio,n.projection);if(!u)return null;a=new gS({tile:u,tileGrid:i.getTileGridForProjection(n.projection),container:this.container,threejsLayer:this}),this._debug("create rep",t,"coord=",r.join(",")),a.sourceKey=i.getKey(),a.customAlpha=0,a.fadingIn=!0,a.renderOrder=fS++,this.activeTiles.set(t,a)}return a}enqueueTileLoad(t,i,r,s,n,a,o){let l=t.tile.getKey();i[l]=!0;let h=t.tile.getState();if(h===he.LOADED||h===he.ERROR||h===he.EMPTY){this.loadRequireTiles.has(l)&&(this.loadRequireTiles.delete(l),this.maybeUnlock());return}if(h===he.IDLE)if(o.tileQueue.isKeyQueued(l))this.loadRequireTiles.has(l)||this.loadRequireTiles.set(l,t.tile);else{if(!this.isPreloadingBatch&&Ls!=-1&&Ls!=this.loadPriority&&performance.now()-yS<JF){ps&&this._debug("skip enqueue (locked by other layer)",l);return}this.loadRequireTiles.has(l)||this.loadRequireTiles.set(l,t.tile),o.tileQueue.enqueue([t.tile,r,s.getTileCoordCenter(n),a]),o.tileQueue.reprioritize(),ps&&this._debug("enqueue (ensure queued)",l),Ls!=this.loadPriority&&this.loadRequireTiles.size&&!this.isPreloadingBatch&&(Ls=this.loadPriority,yS=performance.now(),ps&&this._debug("acquire lock; required=",this.loadRequireTiles.size))}}maybeUnlock(){Ls===this.loadPriority&&this.loadRequireTiles.size===0&&this.loadingTilesCount===0&&(Ls=-1),Ls===this.loadPriority&&performance.now()-yS>JF&&(Ls=-1,this.master.openLayerMap.render())}prepareFrame(t){return this.prepareFrameInternal(t)}prepareFrameInternal(t){this.projection_!==t.viewState.projection&&(this.activeTiles.forEach(r=>this.safeTileDisposal(r)),this.activeTiles.clear(),this.fadingTiles.forEach(r=>this.safeTileDisposal(r)),this.fadingTiles.clear(),this.loadRequireTiles.clear(),this.currentSourceKey=null,this.initialLoadComplete=!1,this.allTilesLoaded=!1,this.allTilesDisplayed=!1,this.zoomSettled=!1,this.zoomSettledAt=0,Ls===this.loadPriority&&(Ls=-1),this.projection_=t.viewState.projection,this.needsRender=!0);let i=this.getLayer()?.getRenderSource();return!i||qd(Xm(t,t.extent))?!1:i.getState()==="ready"}drawTile=(t,i,r,s)=>{let n=i.plane?.material;if(!i.ready||!(n?.colorNode||n?.map))return;let a=i.tile.tileCoord,o=s.getTileCoordExtent(a),[l,h,u,d]=r,[c,p,m,g]=o,f=l,y=u,x=h,b=d,_=y-f,T=b-x;if(!isFinite(_)||!isFinite(T)||_<=1e-9||T<=1e-9){let U=t.viewState.center,V=t.size||ue.openLayerMap.getSize()||[N.width,N.height],z=t.viewState.resolution,Z=z*V[0],j=z*V[1];f=U[0]-Z/2,y=U[0]+Z/2,x=U[1]-j/2,b=U[1]+j/2,_=Z,T=j}let w=(m-c)/_,M=(g-p)/T,S=KF((c+m)/2,f,y)-.5,R=KF((p+g)/2,x,b)-.5,I=a[0]*.001;i.plane&&!i.plane.parent&&(i.plane.position.set(S,R,I),i.plane.scale.set(w,M,1),this.container.add(i.plane));let B=i.plane.position,O=i.plane.scale;(B.x!==S||B.y!==R||O.x!==w||O.y!==M)&&(i.plane.position.set(S,R,I),i.plane.scale.set(w,M,1),i.plane.visible=!0,i.hasRenderedAtLeastOnce=!0)};disposeResources=()=>{this._onMoveEndPreload&&ue.openLayerMap?.un&&ue.openLayerMap.un("moveend",this._onMoveEndPreload),N.onUp
2107date.remove(this.update),this.resizeHandler&&=(N.onResize.remove(this.resizeHandler),null),this.tileSource&&=(this.tileSource.un("tileloadstart",this.onTileLoadStart),this.tileSource.un("tileloadend",this.onTileLoadEnd),this.tileSource.un("tileloaderror",this.onTileError),null),Ls==this.loadPriority&&(Ls=-1);let t=fg.instances.indexOf(this);for(t>-1&&fg.instances.splice(t,1),this.activeTiles.forEach(i=>i.dispose()),this.activeTiles.clear(),this.fadingTiles.forEach(i=>i.dispose()),this.fadingTiles.clear(),this.pendingDisposals.forEach(i=>i.dispose()),this.pendingDisposals.clear(),this.loadRequireTiles.clear(),this.releaseRT();this.container.children.length>0;){let i=this.container.children[0];this.container.remove(i)}this.allTilesLoaded=!1,this.allTilesDisplayed=!1,this.initialLoadComplete=!1,this.needsRender=!1,this.isInitialized=!1,this.visibleTileCount=0};updateVisibleTileCount(){this.visibleTileCount=this.activeTiles.size+this.fadingTiles.size+this.pendingDisposals.size}isSystemStable(){return this.allTilesLoaded&&this.zoomSettled&&!this.master.isMoving&&!this.master.isPlaying&&Bi.value===0}processePendingDisposals(){q.isRenderingMain||(!this.disposeOnlyWhenStable||this.isSystemStable())&&(Array.from(this.pendingDisposals).slice(0,6).forEach(t=>{if(t._disposed){this.pendingDisposals.delete(t);return}let i=t.tile?.getKey();i&&this.loadRequireTiles.has(i)&&this.loadRequireTiles.delete(i),t._disposed=!0,this._debug("dispose now",t.tile?.getKey()),t.dispose(),this.pendingDisposals.delete(t)}),this.updateVisibleTileCount())}safeTileDisposal(t){if(!t||t._disposed)return;let i=t.tile?.getKey();i&&this.loadRequireTiles.has(i)&&this.loadRequireTiles.delete(i);try{t.plane&&t.plane.parent&&(t.plane.visible=!1,t.plane.material&&(t.plane.material.map=null,t.plane.material.colorNode=null),t.plane.parent.remove(t.plane))}catch(r){console.warn("Error detaching tile before disposal",r)}t._detached=!0,this.pendingDisposals.add(t)}cleanupAbandonedTiles(){if(!this.zoomSettled)return;let t=[];this.loadRequireTiles.forEach((i,r)=>{let s=i.getState();if(s!==he.IDLE&&s!==he.LOADING){t.push(r);return}if(s===he.LOADING&&performance.now()-(i._loadStartedAt||0)>OQ){t.push(r);return}let n=i.tileCoord[0],a=this.currentZoom;if(this.zoomSettled&&Math.abs(n-a)>1){t.push(r);return}if(this.currentSourceKey&&!i.key.includes(this.currentSourceKey)){t.push(r);return}let o=!1,l=Ym(this.getLayer().getRenderSource(),i.tileCoord);if(this.activeTiles.has(l)||this.fadingTiles.has(l)){let h=this.activeTiles.get(l)||this.fadingTiles.get(l);h&&h.tile===i&&(o=!0)}!o&&s===he.IDLE&&t.push(r)}),t.forEach(i=>{this.loadRequireTiles.delete(i)}),t.length,this.maybeUnlock()}},GQ=class extends u1{constructor(e,t){super(e),this.master=t}createRenderer(){return new e5(this,{},this.master)}initRT=()=>this.getRenderer().initRT();releaseRT=()=>this.getRenderer().releaseRT();disposeResources=()=>this.getRenderer().disposeResources();reinitialize=()=>this.getRenderer().reinitialize();set opacity(e){this.getRenderer().opacity=e}get opacity(){return this.getRenderer().opacity}get texture(){return this.renderTarget?this.renderTarget.texture:null}get renderTarget(){return this.getRenderer().renderTarget}get container(){return this.getRenderer().container}get onTilesLoaded(){return this.getRenderer().onTilesLoaded}get onContentReady(){return this.getRenderer().onContentReady}get allTilesLoaded(){return this.getRenderer().allTilesLoaded}get allTilesDisplayed(){return this.getRenderer().allTilesDisplayed}get disposeOnlyWhenStable(){return this.getRenderer().disposeOnlyWhenStable}set disposeOnlyWhenStable(e){this.getRenderer().disposeOnlyWhenStable=e}get pendingDisposalsCount(){return this.getRenderer().pendingDisposals.size}},xS=class{constructor(e,t,i,r){this.minX=e,this.maxX=t,this.minY=i,this.maxY=r}contains(e){return this.containsXY(e[1],e[2])}containsTileRange(e){return this.minX<=e.minX&&e.maxX<=this.maxX&&this.minY<=e.minY&&e.maxY<=this.maxY}containsXY(e,t){return this.minX<=e&&e<=this.maxX&&this.minY<=t&&t<=this.maxY}equals(e){return this.minX==e.minX&&this.minY==e.minY&&this.maxX==e.maxX&&this.maxY==e.maxY}extend(e){e.minX<this.minX&&(this.minX=e.minX),e.maxX>this.maxX&&(this.maxX=e.maxX),e.minY<this.minY&&(this.minY=e.minY),e.maxY>this.maxY&&(this.maxY=e.maxY)}
2107getHeight(){return this.maxY-this.minY+1}getSize(){return[this.getWidth(),this.getHeight()]}getWidth(){return this.maxX-this.minX+1}intersects(e){return this.minX<=e.maxX&&this.maxX>=e.minX&&this.minY<=e.maxY&&this.maxY>=e.minY}};function cc(e,t,i,r,s){return s===void 0?new xS(e,t,i,r):(s.minX=e,s.maxX=t,s.minY=i,s.maxY=r,s)}var pc=[0,0,0],ql=5,c1=class{constructor(e){this.minZoom=e.minZoom===void 0?0:e.minZoom,this.resolutions_=e.resolutions,It(xK(this.resolutions_,(r,s)=>s-r,!0),"`resolutions` must be sorted in descending order");let t;if(!e.origins){for(let r=0,s=this.resolutions_.length-1;r<s;++r)if(!t)t=this.resolutions_[r]/this.resolutions_[r+1];else if(this.resolutions_[r]/this.resolutions_[r+1]!==t){t=void 0;break}}this.zoomFactor_=t,this.maxZoom=this.resolutions_.length-1,this.origin_=e.origin===void 0?null:e.origin,this.origins_=null,e.origins!==void 0&&(this.origins_=e.origins,It(this.origins_.length==this.resolutions_.length,"Number of `origins` and `resolutions` must be equal"));let i=e.extent;i!==void 0&&!this.origin_&&!this.origins_&&(this.origin_=Cl(i)),It(!this.origin_&&this.origins_||this.origin_&&!this.origins_,"Either `origin` or `origins` must be configured, never both"),this.tileSizes_=null,e.tileSizes!==void 0&&(this.tileSizes_=e.tileSizes,It(this.tileSizes_.length==this.resolutions_.length,"Number of `tileSizes` and `resolutions` must be equal")),this.tileSize_=e.tileSize===void 0?this.tileSizes_?null:256:e.tileSize,It(!this.tileSize_&&this.tileSizes_||this.tileSize_&&!this.tileSizes_,"Either `tileSize` or `tileSizes` must be configured, never both"),this.extent_=i===void 0?null:i,this.fullTileRanges_=null,this.tmpSize_=[0,0],this.tmpExtent_=[0,0,0,0],e.sizes===void 0?i&&this.calculateTileRanges_(i):this.fullTileRanges_=e.sizes.map((r,s)=>{let n=new xS(Math.min(0,r[0]),Math.max(r[0]-1,-1),Math.min(0,r[1]),Math.max(r[1]-1,-1));if(i){let a=this.getTileRangeForExtentAndZ(i,s);n.minX=Math.max(a.minX,n.minX),n.maxX=Math.min(a.maxX,n.maxX),n.minY=Math.max(a.minY,n.minY),n.maxY=Math.min(a.maxY,n.maxY)}return n})}forEachTileCoord(e,t,i){let r=this.getTileRangeForExtentAndZ(e,t);for(let s=r.minX,n=r.maxX;s<=n;++s)for(let a=r.minY,o=r.maxY;a<=o;++a)i([t,s,a])}forEachTileCoordParentTileRange(e,t,i,r){let s,n,a,o=null,l=e[0]-1;for(this.zoomFactor_===2?(n=e[1],a=e[2]):o=this.getTileCoordExtent(e,r);l>=this.minZoom;){if(n!==void 0&&a!==void 0?(n=Math.floor(n/2),a=Math.floor(a/2),s=cc(n,n,a,a,i)):s=this.getTileRangeForExtentAndZ(o,l,i),t(l,s))return!0;--l}return!1}getExtent(){return this.extent_}getMaxZoom(){return this.maxZoom}getMinZoom(){return this.minZoom}getOrigin(e){return this.origin_?this.origin_:this.origins_[e]}getOrigins(){return this.origins_}getResolution(e){return this.resolutions_[e]}getResolutions(){return this.resolutions_}getTileCoordChildTileRange(e,t,i){if(e[0]<this.maxZoom){if(this.zoomFactor_===2){let s=e[1]*2,n=e[2]*2;return cc(s,s+1,n,n+1,t)}let r=this.getTileCoordExtent(e,i||this.tmpExtent_);return this.getTileRangeForExtentAndZ(r,e[0]+1,t)}return null}getTileRangeForTileCoordAndZ(e,t,i){if(t>this.maxZoom||t<this.minZoom)return null;let r=e[0],s=e[1],n=e[2];if(t===r)return cc(s,n,s,n,i);if(this.zoomFactor_){let o=this.zoomFactor_**+(t-r),l=Math.floor(s*o),h=Math.floor(n*o);return t<r?cc(l,l,h,h,i):cc(l,Math.floor(o*(s+1))-1,h,Math.floor(o*(n+1))-1,i)}let a=this.getTileCoordExtent(e,this.tmpExtent_);return this.getTileRangeForExtentAndZ(a,t,i)}getTileRangeForExtentAndZ(e,t,i){this.getTileCoordForXYAndZ_(e[0],e[3],t,!1,pc);let r=pc[1],s=pc[2];this.getTileCoordForXYAndZ_(e[2],e[1],t,!0,pc);let n=pc[1],a=pc[2];return cc(r,n,s,a,i)}getTileCoordCenter(e){let t=this.getOrigin(e[0]),i=this.getResolution(e[0]),r=kr(this.getTileSize(e[0]),this.tmpSize_);return[t[0]+(e[1]+.5)*r[0]*i,t[1]-(e[2]+.5)*r[1]*i]}getTileCoordExtent(e,t){let i=this.getOrigin(e[0]),r=this.getResolution(e[0]),s=kr(this.getTileSize(e[0]),this.tmpSize_),n=i[0]+e[1]*s[0]*r,a=i[1]-(e[2]+1)*s[1]*r;return Ml(n,a,n+s[0]*r,a+s[1]*r,t)}getTileCoordForCoordAndResolution(e,t,i){return this.getTileCoordForXYAndResolution_(e[0],e[1],t,!1,i)}getTileCoordForXYAndResolution_(e,t,i,r,s){let n=this.getZForResolution(i),a=i/this.getResolution(n),o=this.getOrigin(n),l=kr(this.getTileSize(n),this.tmpSize_),h=a*(e-o[0])/i/l[0],u=a*(o[1]-t)/i/l[1];return r?(h=vy(h,ql)-1,u=vy(u,ql)-1):(h=xy(h,ql),u=xy(u,ql)),Eo(n,h,u,s)}getTileCoordForXYAndZ_(e,t,i,r,s){let n=this.getOrigin(i),a=this.getResolution(i),o=kr(this.getTileSize(i),this.tmpSize_),l=(e-n[0])/a/o[0],h=(n[1]-t)/a/o[1];return r?(l=vy(l,ql)-1,h=vy(h,ql)-1):(l=xy(l,ql),h=xy(h,ql)),Eo(i,l,h,s)}getTileCoordForCoordAndZ(e,t,i){return this.getTileCoordForXYAndZ_(e[0],e[1],t,!1,i)}getTileCoordResolution(e){return this.resolutions_[e[0]]}getTileSize(e){return this.tileSize_?this.tileSize_:this.tileSizes_[e]}getFullTileRange(e){return this.fullTileRanges_?this.fullTileRanges_[e]:this.extent_?this.getTileRangeForExtentAndZ(this.extent_,e):null}getZForResolution(e,t){return ri(iw(this.resolutions_,e,t||0),this.minZoom,this.maxZoom)}tileCoordIntersectsViewport(e,t){return jI(t,0,t.length,2,this.getTileCoordExtent(e))}calculateTileRanges_(e){let t=this.resolutions_.length,i=Array(t);for(let r=this.minZoom;r<t;++r)i[r]=this.getTileRangeForExtentAndZ(e,r);this.fullTileRanges_=i}};function vS(e){let t=e.getDefaultTileGrid();return t||(t=WQ(e),e.setDefaultTileGrid(t)),t}function jQ(e,t,i){let r=t[0],s=e.getTileCoordCenter(t),n=p1(i);if(!Hd(n,s)){let a=Jt(n),o=Math.ceil((n[0]-s[0])/a);return s[0]+=a*o,e.getTileCoordForCoordAndZ(s,r)}return t}function $Q(e,t,i,r){r=r===void 0?"top-left":r;let s=i5(e,t,i);return new c1({extent:e,origin:RY(e,r),resolutions:s,tileSize:i})}function t5(e){let t=e||{},i=t.extent||Oi("EPSG:3857").getExtent();return new c1({extent:i,minZoom:t.minZoom,tileSize:t.tileSize,resolutions:i5(i,t.maxZoom,t.tileSize,t.maxResolution)})}function i5(e,t,i,r){t=t===void 0?42:t,i=kr(i===void 0?256:i);let s=is(e),n=Jt(e);r=r>0?r:Math.max(n/i[0],s/i[1]);let a=t+1,o=Array(a);for(let l=0;l<a;++l)o[l]=r/2**l;return o}function WQ(e,t,i,r){return $Q(p1(e),t,i,r)}function p1(e){e=Oi(e);let t=e.getExtent();if(!t){let i=180*hm.degrees/e.getMetersPerUnit();t=Ml(-i,-i,i,i)}return t}var Zm=class extends pm{constructor(e,t,i){super(),i||={},this.tileCoord=e,this.state=t,this.key="",this.transition_=i.transition===void 0?250:i.transition,this.transitionStarts_={},this.interpolate=!!i.interpolate}changed(){this.dispatchEvent(De.CHANGE)}release(){this.setState(he.EMPTY)}getKey(){return this.key+"/"+this.tileCoord}getTileCoord(){return this.tileCoord}getState(){return this.state}setState(e){if(this.state!==he.EMPTY){if(this.state!==he.ERROR&&this.state>e)throw Error("Tile load sequence violation");this.state=e,this.changed()}}load(){qe()}getAlpha(e,t){if(!this.transition_)return 1;let i=this.transitionStarts_[e];if(!i)i=t,this.transitionStarts_[e]=i;else if(i===-1)return 1;let r=t-i+1e3/60;return r>=this.transition_?1:AI(r/this.transition_)}inTransition(e){return this.transition_?this.transitionStarts_[e]!==-1:!1}endTransition(e){this.transition_&&(this.transitionStarts_[e]=-1)}disposeInternal(){this.release(),super.disposeInternal()}},r5=class extends Zm{constructor(e,t,i,r,s,n){super(e,t,n),this.crossOrigin_=r?.crossOrigin,this.referrerPolicy_=r?.referrerPolicy,this.src_=i,this.key=i,this.image_,Js?this.image_=new OffscreenCanvas(1,1):(this.image_=new Image,this.crossOrigin_!==null&&(this.image_.crossOrigin=this.crossOrigin_),this.referrerPolicy_!==void 0&&(this.image_.referrerPolicy=this.referrerPolicy_)),this.unlisten_=null,this.tileLoadFunction_=s}getImage(){return this.image_}setImage(e){this.image_=e,this.state=he.LOADED,this.unlistenImage_(),this.changed()}getCrossOrigin(){return this.crossOrigin_}getReferrerPolicy(){return this.referrerPolicy_}handleImageError_(){this.state=he.ERROR,this.unlistenImage_(),this.image_=HQ(),this.changed()}handleImageLoad_(){if(Js)this.state=he.LOADED;else{let e=this.image_;
2107e.naturalWidth&&e.naturalHeight?this.state=he.LOADED:this.state=he.EMPTY}this.unlistenImage_(),this.changed()}load(){this.state==he.ERROR&&(this.state=he.IDLE,this.image_=new Image,this.crossOrigin_!==null&&(this.image_.crossOrigin=this.crossOrigin_),this.referrerPolicy_!==void 0&&(this.image_.referrerPolicy=this.referrerPolicy_)),this.state==he.IDLE&&(this.state=he.LOADING,this.changed(),this.tileLoadFunction_(this,this.src_),this.unlisten_=YJ(this.image_,this.handleImageLoad_.bind(this),this.handleImageError_.bind(this)))}unlistenImage_(){this.unlisten_&&=(this.unlisten_(),null)}disposeInternal(){this.unlistenImage_(),this.image_=null,super.disposeInternal()}};function HQ(){let e=Ui(1,1);return e.fillStyle="rgba(0,0,0,0)",e.fillRect(0,0,1,1),e.canvas}var bS,mc=[];function s5(e,t,i,r,s){e.beginPath(),e.moveTo(0,0),e.lineTo(t,i),e.lineTo(r,s),e.closePath(),e.save(),e.clip(),e.fillRect(0,0,Math.max(t,r)+1,Math.max(i,s)),e.restore()}function _S(e,t){return Math.abs(e[t*4]-210)>2||Math.abs(e[t*4+3]-.75*255)>2}function qQ(){if(bS===void 0){let e=Ui(6,6,mc);e.globalCompositeOperation="lighter",e.fillStyle="rgba(210, 0, 0, 0.75)",s5(e,4,5,4,0),s5(e,4,5,0,5);let t=e.getImageData(0,0,3,3).data;bS=_S(t,0)||_S(t,4)||_S(t,8),Ky(e),mc.push(e.canvas)}return bS}function n5(e,t,i,r){let s=El(i,t,e),n=jk(t,r,i),a=t.getMetersPerUnit();a!==void 0&&(n*=a);let o=e.getMetersPerUnit();o!==void 0&&(n/=o);let l=e.getExtent();if(!l||Hd(l,s)){let h=jk(e,n,s)/n;isFinite(h)&&h>0&&(n/=h)}return n}function XQ(e,t,i,r){let s=n5(e,t,Jh(i),r);return(!isFinite(s)||s<=0)&&wk(i,function(n){return s=n5(e,t,n,r),isFinite(s)&&s>0}),s}function YQ(e,t,i,r,s,n,a,o,l,h,u,d,c,p){let m=Ui(Math.round(i*e),Math.round(i*t),mc);if(d||(m.imageSmoothingEnabled=!1),l.length===0)return m.canvas;m.scale(i,i);function g(T){return Math.round(T*i)/i}m.globalCompositeOperation="lighter";let f=ya();l.forEach(function(T,w,M){MY(f,T.extent)});let y,x=i/r,b=(d?1:1+2**-24)/x;if(!c||l.length!==1||h!==0){if(y=Ui(Math.round(Jt(f)*x),Math.round(is(f)*x),mc),d||(y.imageSmoothingEnabled=!1),s&&p){let T=(s[0]-f[0])*x,w=-(s[3]-f[3])*x,M=Jt(s)*x,S=is(s)*x;y.rect(T,w,M,S),y.clip()}l.forEach(function(T,w,M){if(T.image.width>0&&T.image.height>0){if(T.clipExtent){y.save();let O=(T.clipExtent[0]-f[0])*x,U=-(T.clipExtent[3]-f[3])*x,V=Jt(T.clipExtent)*x,z=is(T.clipExtent)*x;y.rect(d?O:Math.round(O),d?U:Math.round(U),d?V:Math.round(O+V)-Math.round(O),d?z:Math.round(U+z)-Math.round(U)),y.clip()}let S=(T.extent[0]-f[0])*x,R=-(T.extent[3]-f[3])*x,I=Jt(T.extent)*x,B=is(T.extent)*x;y.drawImage(T.image,h,h,T.image.width-2*h,T.image.height-2*h,d?S:Math.round(S),d?R:Math.round(R),d?I:Math.round(S+I)-Math.round(S),d?B:Math.round(R+B)-Math.round(R)),T.clipExtent&&y.restore()}})}let _=Cl(a);
2107return o.getTriangles().forEach(function(T,w,M){let S=T.source,R=T.target,I=S[0][0],B=S[0][1],O=S[1][0],U=S[1][1],V=S[2][0],z=S[2][1],Z=g((R[0][0]-_[0])/n),j=g(-(R[0][1]-_[1])/n),ae=g((R[1][0]-_[0])/n),W=g(-(R[1][1]-_[1])/n),me=g((R[2][0]-_[0])/n),Ce=g(-(R[2][1]-_[1])/n),Qe=I,oe=B;I=0,B=0,O-=Qe,U-=oe,V-=Qe,z-=oe;let dt=IY([[O,U,0,0,ae-Z],[V,z,0,0,me-Z],[0,0,O,U,W-j],[0,0,V,z,Ce-j]]);if(!dt)return;if(m.save(),m.beginPath(),qQ()||!d){m.moveTo(ae,W);let it=Z-ae,Nt=j-W;for(let ci=0;ci<4;ci++)m.lineTo(ae+g((ci+1)*it/4),W+g(ci*Nt/3)),ci!=3&&m.lineTo(ae+g((ci+1)*it/4),W+g((ci+1)*Nt/3));m.lineTo(me,Ce)}else m.moveTo(ae,W),m.lineTo(Z,j),m.lineTo(me,Ce);m.clip(),m.transform(dt[0],dt[2],dt[1],dt[3],Z,j),m.translate(f[0]-Qe,f[3]-oe);let et;if(y)et=y.canvas,m.scale(b,-b);else{let it=l[0],Nt=it.extent;et=it.image,m.scale(Jt(Nt)/et.width,-is(Nt)/et.height)}m.drawImage(et,0,0),m.restore()}),y&&(Ky(y),mc.push(y.canvas)),u&&(m.save(),m.globalCompositeOperation="source-over",m.strokeStyle="black",m.lineWidth=1,o.getTriangles().forEach(function(T,w,M){let S=T.target,R=(S[0][0]-_[0])/n,I=-(S[0][1]-_[1])/n,B=(S[1][0]-_[0])/n,O=-(S[1][1]-_[1])/n,U=(S[2][0]-_[0])/n,V=-(S[2][1]-_[1])/n;m.beginPath(),m.moveTo(B,O),m.lineTo(R,I),m.lineTo(U,V),m.closePath(),m.stroke()}),m.restore()),m.canvas}var KQ=10,a5=.25,ZQ=class{constructor(e,t,i,r,s,n,a){this.sourceProj_=e,this.targetProj_=t;let o={},l=a?dK(x=>Ki(a,El(x,this.targetProj_,this.sourceProj_))):ru(this.targetProj_,this.sourceProj_);this.transformInv_=function(x){let b=x[0]+"/"+x[1];return o[b]||(o[b]=l(x)),o[b]},this.maxSourceExtent_=r,this.errorThresholdSquared_=s*s,this.triangles_=[],this.wrapsXInSource_=!1,this.canWrapXInSource_=this.sourceProj_.canWrapX()&&!!r&&!!this.sourceProj_.getExtent()&&Jt(r)>=Jt(this.sourceProj_.getExtent()),this.sourceWorldWidth_=this.sourceProj_.getExtent()?Jt(this.sourceProj_.getExtent()):null,this.targetWorldWidth_=this.targetProj_.getExtent()?Jt(this.targetProj_.getExtent()):null;let h=Cl(i),u=fy(i),d=gy(i),c=my(i),p=this.transformInv_(h),m=this.transformInv_(u),g=this.transformInv_(d),f=this.transformInv_(c),y=KQ+(n?Math.max(0,Math.ceil(Math.log2(zT(i)/(n*n*256*256)))):0);if(this.addQuad_(h,u,d,c,p,m,g,f,y),this.wrapsXInSource_){let x=1/0;this.triangles_.forEach(function(b,_,T){x=Math.min(x,b.source[0][0],b.source[1][0],b.source[2][0])}),this.triangles_.forEach(b=>{if(Math.max(b.source[0][0],b.source[1][0],b.source[2][0])-x>this.sourceWorldWidth_/2){let _=[[b.source[0][0],b.source[0][1]],[b.source[1][0],b.source[1][1]],[b.source[2][0],b.source[2][1]]];_[0][0]-x>this.sourceWorldWidth_/2&&(_[0][0]-=this.sourceWorldWidth_),_[1][0]-x>this.sourceWorldWidth_/2&&(_[1][0]-=this.sourceWorldWidth_),_[2][0]-x>this.sourceWorldWidth_/2&&(_[2][0]-=this.sourceWorldWidth_);let T=Math.min(_[0][0],_[1][0],_[2][0]);Math.max(_[0][0],_[1][0],_[2][0])-T<this.sourceWorldWidth_/2&&(b.source=_)}})}o={}}addTriangle_(e,t,i,r,s,n){this.triangles_.push({source:[r,s,n],target:[e,t,i]})}addQuad_(e,t,i,r,s,n,a,o,l){let h=OT([s,n,a,o]),u=this.sourceWorldWidth_?Jt(h)/this.sourceWorldWidth_:null,d=this.sourceWorldWidth_,c=this.sourceProj_.canWrapX()&&u>.5&&u<1,p=!1;if(l>0&&(this.targetProj_.isGlobal()&&this.targetWorldWidth_&&(p=Jt(OT([e,t,i,r]))/this.targetWorldWidth_>a5||p),!c&&this.sourceProj_.isGlobal()&&u&&(p=u>a5||p)),!p&&this.maxSourceExtent_&&isFinite(h[0])&&isFinite(h[1])&&isFinite(h[2])&&isFinite(h[3])&&!Xi(h,this.maxSourceExtent_))return;let m=0;if(!p&&(!isFinite(s[0])||!isFinite(s[1])||!isFinite(n[0])||!isFinite(n[1])||!isFinite(a[0])||!isFinite(a[1])||!isFinite(o[0])||!isFinite(o[1]))){if(l>0)p=!0;else if(m=(!isFinite(s[0])||!isFinite(s[1])?8:0)+(!isFinite(n[0])||!isFinite(n[1])?4:0)+(!isFinite(a[0])||!isFinite(a[1])?2:0)+ +(!isFinite(o[0])||!isFinite(o[1])),m!=1&&m!=2&&m!=4&&m!=8)return}if(l>0){if(!p){let g=[(e[0]+i[0])/2,(e[1]+i[1])/2],f=this.transformInv_(g),y;y=c?(eu(s[0],d)+eu(a[0],d))/2-eu(f[0],d):(s[0]+a[0])/2-f[0];let x=(s[1]+a[1])/2-f[1];p=y*y+x*x>this.errorThresholdSquared_}if(p){if(Math.abs(e[0]-i[0])<=Math.abs(e[1]-i[1])){let g=[(t[0]+i[0])/2,(t[1]+i[1])/2],f=this.transformInv_(g),y=[(r[0]+e[0])/2,(r[1]+e[1])/2],x=this.transformInv_(y);this.addQuad_(e,t,g,y,s,n,f,x,l-1),this.addQuad_(y,g,i,r,x,f,a,o,l-1)}else{let g=[(e[0]+t[0])/2,(e[1]+t[1])/2],f=this.transformInv_(g),y=[(i[0]+r[0])/2,(i[1]+r[1])/2],x=this.transformInv_(y);this.addQuad_(e,g,y,r,s,f,x,o,l-1),this.addQuad_(g,t,i,y,f,n,a,x,l-1)}return}}
2107if(c){if(!this.canWrapXInSource_)return;this.wrapsXInSource_=!0}m&11||this.addTriangle_(e,i,r,s,a,o),m&14||this.addTriangle_(e,i,t,s,a,n),m&&(m&13||this.addTriangle_(t,r,e,n,o,s),m&7||this.addTriangle_(t,r,i,n,o,a))}calculateSourceExtent(){let e=ya();return this.triangles_.forEach(function(t,i,r){let s=t.source;lm(e,s[0]),lm(e,s[1]),lm(e,s[2])}),e}getTriangles(){return this.triangles_}},JQ=.5,o5=class extends Zm{constructor(e,t,i,r,s,n,a,o,l,h,u,d){super(s,he.IDLE,d),this.renderEdges_=u===void 0?!1:u,this.pixelRatio_=a,this.gutter_=o,this.canvas_=null,this.sourceTileGrid_=t,this.targetTileGrid_=r,this.wrappedTileCoord_=n||s,this.sourceTiles_=[],this.sourcesListenerKeys_=null,this.sourceZ_=0,this.clipExtent_=e.canWrapX()?e.getExtent():void 0;let c=r.getTileCoordExtent(this.wrappedTileCoord_),p=this.targetTileGrid_.getExtent(),m=this.sourceTileGrid_.getExtent(),g=p?ds(c,p):c;if(zT(g)===0){this.state=he.EMPTY;return}let f=e.getExtent();f&&(m=m?ds(m,f):f);let y=r.getResolution(this.wrappedTileCoord_[0]),x=XQ(e,i,g,y);if(!isFinite(x)||x<=0){this.state=he.EMPTY;return}let b=h===void 0?JQ:h;if(this.triangulation_=new ZQ(e,i,g,m,x*b,y),this.triangulation_.getTriangles().length===0){this.state=he.EMPTY;return}this.sourceZ_=t.getZForResolution(x);let _=this.triangulation_.calculateSourceExtent();if(m&&(e.canWrapX()?(_[1]=ri(_[1],m[1],m[3]),_[3]=ri(_[3],m[1],m[3])):_=ds(_,m)),!zT(_))this.state=he.EMPTY;else{let T=0,w=0;e.canWrapX()&&(T=Jt(f),w=Math.floor((_[0]-f[0])/T)),PY(_.slice(),e,!0).forEach(M=>{let S=t.getTileRangeForExtentAndZ(M,this.sourceZ_);for(let R=S.minX;R<=S.maxX;R++)for(let I=S.minY;I<=S.maxY;I++){let B=w*T;this.sourceTiles_.push({getTile:()=>l(this.sourceZ_,R,I,a),offset:B})}++w}),this.sourceTiles_.length===0&&(this.state=he.EMPTY)}}getImage(){return this.canvas_}reproject_(){let e=[];
2107if(this.sourceTiles_.forEach(t=>{let i=t.tile;if(i&&i.getState()==he.LOADED){let r=this.sourceTileGrid_.getTileCoordExtent(i.tileCoord);r[0]+=t.offset,r[2]+=t.offset;let s=this.clipExtent_?.slice();s&&(s[0]+=t.offset,s[2]+=t.offset),e.push({extent:r,clipExtent:s,image:i.getImage()})}}),this.sourceTiles_.length=0,e.length===0)this.state=he.ERROR;else{let t=this.wrappedTileCoord_[0],i=this.targetTileGrid_.getTileSize(t),r=typeof i=="number"?i:i[0],s=typeof i=="number"?i:i[1],n=this.targetTileGrid_.getResolution(t),a=this.sourceTileGrid_.getResolution(this.sourceZ_),o=this.targetTileGrid_.getTileCoordExtent(this.wrappedTileCoord_);this.canvas_=YQ(r,s,this.pixelRatio_,a,this.sourceTileGrid_.getExtent(),n,o,this.triangulation_,e,this.gutter_,this.renderEdges_,this.interpolate),this.state=he.LOADED}this.changed()}load(){for(let e of this.sourceTiles_)e.tile=e.getTile();if(this.state==he.IDLE){this.state=he.LOADING,this.changed();let e=0;this.sourcesListenerKeys_=[],this.sourceTiles_.forEach(({tile:t})=>{let i=t.getState();if(i==he.IDLE||i==he.LOADING){e++;let r=ft(t,De.CHANGE,s=>{let n=t.getState();(n==he.LOADED||n==he.ERROR||n==he.EMPTY)&&(oi(r),e--,e===0&&(this.unlistenSources_(),this.reproject_()))});this.sourcesListenerKeys_.push(r)}}),e===0?setTimeout(this.reproject_.bind(this),0):this.sourceTiles_.forEach(function({tile:t},i,r){t.getState()==he.IDLE&&t.load()})}}unlistenSources_(){this.sourcesListenerKeys_.forEach(oi),this.sourcesListenerKeys_=null}release(){this.canvas_&&=(Ky(this.canvas_.getContext("2d")),mc.push(this.canvas_),null),this.sourceTiles_.length=0,super.release()}},QQ=/\{z\}/g,eee=/\{x\}/g,tee=/\{y\}/g,iee=/\{-y\}/g;function ree(e,t,i,r,s){return e.replace(QQ,t.toString()).replace(eee,i.toString()).replace(tee,r.toString()).replace(iee,function(){if(s===void 0)throw Error("If the URL template has a {-y} placeholder, the grid extent must be known");return(s-r).toString()})}function see(e){let t=[],i=/\{([a-z])-([a-z])\}/.exec(e);if(i){let r=i[1].charCodeAt(0),s=i[2].charCodeAt(0),n;for(n=r;n<=s;++n)t.push(e.replace(i[0],String.fromCharCode(n)));return t}if(i=/\{(\d+)-(\d+)\}/.exec(e),i){let r=parseInt(i[2],10);for(let s=parseInt(i[1],10);s<=r;s++)t.push(e.replace(i[0],s.toString()));return t}return t.push(e),t}function nee(e,t){return(function(i,r,s){if(!i)return;let n,a=i[0];if(t){let o=t.getFullTileRange(a);o&&(n=o.getHeight()-1)}return ree(e,a,i[1],i[2],n)})}function aee(e,t){let i=e.length,r=Array(i);for(let s=0;s<i;++s)r[s]=nee(e[s],t);return oee(r)}function oee(e){return e.length===1?e[0]:(function(t,i,r){if(t)return e[eu(LQ(t),e.length)](t,i,r)})}var lee=class extends _a{constructor(e){super(),this.projection=Oi(e.projection),this.attributions_=l5(e.attributions),this.attributionsCollapsible_=e.attributionsCollapsible??!0,this.loading=!1,this.state_=e.state===void 0?"ready":e.state,this.wrapX_=e.wrapX===void 0?!1:e.wrapX,this.interpolate_=!!e.interpolate,this.viewResolver=null,this.viewRejector=null;let t=this;this.viewPromise_=new Promise(function(i,r){t.viewResolver=i,t.viewRejector=r})}getAttributions(){return this.attributions_}getAttributionsCollapsible(){return this.attributionsCollapsible_}getProjection(){return this.projection}getResolutions(e){return null}getView(){return this.viewPromise_}getState(){return this.state_}getWrapX(){return this.wrapX_}getInterpolate(){return this.interpolate_}refresh(){this.changed()}setAttributions(e){this.attributions_=l5(e),this.changed()}setState(e){this.state_=e,this.changed()}};function l5(e){return e?typeof e=="function"?e:(Array.isArray(e)||(e=[e]),t=>e):null}var hee=class extends lee{constructor(e){super({attributions:e.attributions,attributionsCollapsible:e.attributionsCollapsible,projection:e.projection,state:e.state,wrapX:e.wrapX,interpolate:e.interpolate}),this.on,this.once,this.un,this.tilePixelRatio_=e.tilePixelRatio===void 0?1:e.tilePixelRatio,this.tileGrid=e.tileGrid===void 0?null:e.tileGrid,this.tileGrid&&kr(this.tileGrid.getTileSize(this.tileGrid.getMinZoom()),[256,256]),this.tmpSize=[0,0],this.key_=e.key||At(this),this.tileOptions={transition:e.transition,interpolate:e.interpolate},this.zDirection=e.zDirection?e.zDirection:0}getGutterForProjection(e){return 0}getKey(){return this.key_}setKey(e){this.key_!==e&&(this.key_=e,this.changed())}getResolutions(e){let t=e?this.getTileGridForProjection(e):this.tileGrid;return t?t.getResolutions():null}getTile(e,t,i,r,s,n){return qe()}getTileGrid(){return this.tileGrid}getTileGridForProjection(e){return this.tileGrid?this.tileGrid:vS(e)}getTilePixelRatio(e){return this.tilePixelRatio_}getTilePixelSize(e,t,i){let r=this.getTileGridForProjection(i),s=this.getTilePixelRatio(t),n=kr(r.getTileSize(e),this.tmpSize);return s==1?n:wJ(n,s,this.tmpSize)}getTileCoordForTileUrlFunction(e,t){let i=t===void 0?this.getProjection():t,r=t===void 0&&this.tileGrid||this.getTileGridForProjection(i);return this.getWrapX()&&i.isGlobal()&&(e=jQ(r,e,i)),kQ(e,r)?e:null}clear(){}refresh(){this.clear(),super.refresh()}}
2107,uee=class extends Nl{constructor(e,t){super(e),this.tile=t}},TS={TILELOADSTART:"tileloadstart",TILELOADEND:"tileloadend",TILELOADERROR:"tileloaderror"},h5=class CO extends hee{constructor(t){super({attributions:t.attributions,cacheSize:t.cacheSize,projection:t.projection,state:t.state,tileGrid:t.tileGrid,tilePixelRatio:t.tilePixelRatio,wrapX:t.wrapX,transition:t.transition,interpolate:t.interpolate,key:t.key,attributionsCollapsible:t.attributionsCollapsible,zDirection:t.zDirection}),this.generateTileUrlFunction_=this.tileUrlFunction===CO.prototype.tileUrlFunction,this.tileLoadFunction=t.tileLoadFunction,t.tileUrlFunction&&(this.tileUrlFunction=t.tileUrlFunction),this.urls=null,t.urls?this.setUrls(t.urls):t.url&&this.setUrl(t.url),this.tileLoadingKeys_={}}getTileLoadFunction(){return this.tileLoadFunction}getTileUrlFunction(){return Object.getPrototypeOf(this).tileUrlFunction===this.tileUrlFunction?this.tileUrlFunction.bind(this):this.tileUrlFunction}getUrls(){return this.urls}handleTileChange(t){let i=t.target,r=At(i),s=i.getState(),n;s==he.LOADING?(this.tileLoadingKeys_[r]=!0,n=TS.TILELOADSTART):r in this.tileLoadingKeys_&&(delete this.tileLoadingKeys_[r],n=s==he.ERROR?TS.TILELOADERROR:s==he.LOADED?TS.TILELOADEND:void 0),n!=null&&this.dispatchEvent(new uee(n,i))}setTileLoadFunction(t){this.tileLoadFunction=t,this.changed()}setTileUrlFunction(t,i){this.tileUrlFunction=t,i===void 0?this.changed():this.setKey(i)}setUrl(t){let i=see(t);this.urls=i,this.setUrls(i)}setUrls(t){this.urls=t;let i=t.join(`
2108`);this.generateTileUrlFunction_?this.setTileUrlFunction(aee(t,this.tileGrid),i):this.setKey(i)}tileUrlFunction(t,i,r){}},dee=class extends h5{constructor(e){super({attributions:e.attributions,cacheSize:e.cacheSize,projection:e.projection,state:e.state,tileGrid:e.tileGrid,tileLoadFunction:e.tileLoadFunction?e.tileLoadFunction:cee,tilePixelRatio:e.tilePixelRatio,tileUrlFunction:e.tileUrlFunction,url:e.url,urls:e.urls,wrapX:e.wrapX,transition:e.transition,interpolate:e.interpolate===void 0?!0:e.interpolate,key:e.key,attributionsCollapsible:e.attributionsCollapsible,zDirection:e.zDirection}),this.crossOrigin=e.crossOrigin===void 0?null:e.crossOrigin,this.referrerPolicy=e.referrerPolicy,this.tileClass=e.tileClass===void 0?r5:e.tileClass,this.tileGridForProjection={},this.reprojectionErrorThreshold_=e.reprojectionErrorThreshold,this.renderReprojectionEdges_=!1}getGutterForProjection(e){return this.getProjection()&&e&&!As(this.getProjection(),e)?0:this.getGutter()}getGutter(){return 0}getKey(){let e=super.getKey();return this.getInterpolate()||(e+=":disable-interpolation"),e}getTileGridForProjection(e){let t=this.getProjection();if(this.tileGrid&&(!t||As(t,e)))return this.tileGrid;let i=At(e);return i in this.tileGridForProjection||(this.tileGridForProjection[i]=vS(e)),this.tileGridForProjection[i]}createTile_(e,t,i,r,s,n){let a=[e,t,i],o=this.getTileCoordForTileUrlFunction(a,s),l=o?this.tileUrlFunction(o,r,s):void 0,h=new this.tileClass(a,l===void 0?he.EMPTY:he.IDLE,l===void 0?"":l,{crossOrigin:this.crossOrigin,referrerPolicy:this.referrerPolicy},this.tileLoadFunction,this.tileOptions);return h.key=n,h.addEventListener(De.CHANGE,this.handleTileChange.bind(this)),h}getTile(e,t,i,r,s,n){let a=this.getProjection();if(!a||!s||As(a,s))return this.getTileInternal(e,t,i,r,a||s);let o=[e,t,i],l=this.getKey(),h=new o5(a,this.getTileGridForProjection(a),s,this.getTileGridForProjection(s),o,this.getTileCoordForTileUrlFunction(o,s),this.getTilePixelRatio(r),this.getGutter(),(u,d,c,p)=>this.getTileInternal(u,d,c,p,a,n),this.reprojectionErrorThreshold_,this.renderReprojectionEdges_,this.tileOptions);return h.key=l,h}getTileInternal(e,t,i,r,s,n){let a=this.getKey(),o=d1(this,a,e,t,i);if(n&&n.containsKey(o))return n.get(o);let l=this.createTile_(e,t,i,r,s,a);return n?.set(o,l),l}
2108setRenderReprojectionEdges(e){this.renderReprojectionEdges_!=e&&(this.renderReprojectionEdges_=e,this.changed())}setTileGridForProjection(e,t){let i=Oi(e);if(i){let r=At(i);r in this.tileGridForProjection||(this.tileGridForProjection[r]=t)}}};function cee(e,t){if(Js){let i=e.getCrossOrigin(),r="same-origin",s="same-origin";i==="anonymous"||i===""?(r="cors",s="omit"):i==="use-credentials"&&(r="cors",s="include");let n={mode:r,credentials:s,referrerPolicy:e.getReferrerPolicy()};fetch(t,n).then(a=>{if(!a.ok)throw Error(`HTTP ${a.status}`);return a.blob()}).then(a=>createImageBitmap(a)).then(a=>{let o=e.getImage();o.width=a.width,o.height=a.height,o.getContext("2d").drawImage(a,0,0),a.close?.(),o.dispatchEvent(new Event("load"))}).catch(()=>{e.getImage().dispatchEvent(new Event("error"))});return}e.getImage().src=t}var pee=class extends dee{constructor(e){e||={};let t=e.projection===void 0?"EPSG:3857":e.projection,i=e.tileGrid===void 0?t5({extent:p1(t),maxResolution:e.maxResolution,maxZoom:e.maxZoom,minZoom:e.minZoom,tileSize:e.tileSize}):e.tileGrid;super({attributions:e.attributions,cacheSize:e.cacheSize,crossOrigin:e.crossOrigin,referrerPolicy:e.referrerPolicy,interpolate:e.interpolate,projection:t,reprojectionErrorThreshold:e.reprojectionErrorThreshold,tileGrid:i,tileLoadFunction:e.tileLoadFunction,tilePixelRatio:e.tilePixelRatio,tileUrlFunction:e.tileUrlFunction,url:e.url,urls:e.urls,wrapX:e.wrapX===void 0?!0:e.wrapX,transition:e.transition,attributionsCollapsible:e.attributionsCollapsible,zDirection:e.zDirection}),this.gutter_=e.gutter===void 0?0:e.gutter}getGutter(){return this.gutter_}},Xl=typeof window<"u",u5=Xl?window:null,Jm=Xl?document:null,Qt={OBJECT:0,ATTRIBUTE:1,CSS:2,TRANSFORM:3,CSS_VAR:4},ot={NUMBER:0,UNIT:1,COLOR:2,COMPLEX:3},rn={NONE:0,AUTO:1,FORCE:2},xr={replace:0,none:1,blend:2},d5=Symbol(),Qm=Symbol(),c5=Symbol(),m1=Symbol(),mee=Symbol(),ss=1e-11,wS=1e12,eg=1e3,p5=(()=>{let e=new Map;return e.set("x","translateX"),e.set("y","translateY"),e.set("z","translateZ"),e})(),g1=["perspective","translateX","translateY","translateZ","rotate","rotateX","rotateY","rotateZ","scale","scaleX","scaleY","scaleZ","skew","skewX","skewY"],gee=g1.reduce((e,t)=>({...e,[t]:t+"("}),{}),sn=()=>{},fee=/\)\s*[-.\d]/,yee=/(^#([\da-f]{3}){1,2}$)|(^#([\da-f]{4}){1,2}$)/i,xee=/rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/i,vee=/rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(-?\d+|-?\d*.\d+)\s*\)/i,bee=/hsl\(\s*(-?\d+|-?\d*.\d+)\s*,\s*(-?\d+|-?\d*.\d+)%\s*,\s*(-?\d+|-?\d*.\d+)%\s*\)/i,_ee=/hsla\(\s*(-?\d+|-?\d*.\d+)\s*,\s*(-?\d+|-?\d*.\d+)%\s*,\s*(-?\d+|-?\d*.\d+)%\s*,\s*(-?\d+|-?\d*.\d+)\s*\)/i,m5=/[-+]?\d*\.?\d+(?:e[-+]?\d)?/gi,Tee=/^([-+]?\d*\.?\d+(?:e[-+]?\d+)?)([a-z]+|%)$/i,wee=/([a-z])([A-Z])/g,See=/var\(\s*(--[\w-]+)(?:\s*,\s*([^)]+))?\s*\)/,f1={id:null,keyframes:null,playbackEase:null,playbackRate:1,frameRate:240,loop:0,reversed:!1,alternate:!1,autoplay:!0,persist:!1,duration:eg,delay:0,loopDelay:0,ease:"out(2)",composition:xr.replace,modifier:e=>e,onBegin:sn,onBeforeUpdate:sn,onUpdate:sn,onLoop:sn,onPause:sn,onComplete:sn,onRender:sn},SS={current:null,root:Jm},Ji={defaults:f1,precision:4,timeScale:1,tickThreshold:200,editor:null},g5={version:"4.4.1",engine:null};Xl&&(u5.AnimeJS||=[],u5.AnimeJS.push(g5));var f5=e=>e.replace(wee,"$1-$2").toLowerCase(),Yl=(e,t)=>e.indexOf(t)===0,gc=Date.now,fc=Array.isArray,MS=e=>e&&e.constructor===Object,Mee=e=>typeof e=="number"&&!isNaN(e),tg=e=>typeof e=="string",ig=e=>typeof e=="function",ui=e=>e===void 0,rg=e=>ui(e)||e===null,y5=e=>Xl&&e instanceof SVGElement,x5=e=>yee.test(e),v5=e=>Yl(e,"rgb"),b5=e=>Yl(e,"hsl"),Cee=e=>x5(e)||(v5(e)||b5(e))&&(e[e.length-1]===")"||!fee.test(e)),y1=e=>!Ji.defaults.hasOwnProperty(e),Ree=["opacity","rotate","overflow","color"],Eee=(e,t)=>{if(Ree.includes(t))return!1;if(e.getAttribute(t)||t in e){if(t==="scale"){let i=e.parentNode;return i&&i.tagName==="filter"}return!0}},yc=Math.pow,Aee=Math.sqrt,Nee=Math.sin,Lee=Math.cos,Pee=Math.floor,kee=Math.asin,CS=Math.PI,_5=Math.round,ns=(e,t,i)=>e<t?t:e>i?i:e,Vi=(e,t)=>{if(t<0)return e;if(!t)return _5(e);let i=10**t;return _5(e*i)/i},Cu=(e,t,i)=>e+(t-e)*i,RS=e=>e===1/0?wS:e===-1/0?-wS:e,sg=e=>e<=1e-11?ss:RS(Vi(e,11)),Ir=e=>fc(e)?[...e]:e,Iee=(e,t)=>
2108{let i={...e};for(let r in t){let s=e[r];i[r]=ui(s)?t[r]:s}return i},Ci=(e,t,i,r="_prev",s="_next")=>{let n=e._head,a=s;for(i&&(n=e._tail,a=r);n;){let o=n[a];t(n),n=o}},Kl=(e,t,i="_prev",r="_next")=>{let s=t[i],n=t[r];s?s[r]=n:e._head=n,n?n[i]=s:e._tail=s,t[i]=null,t[r]=null},xc=(e,t,i,r="_prev",s="_next")=>{let n=e._tail;for(;n&&i&&i(n,t);)n=n[r];let a=n?n[s]:e._head;n?n[s]=t:e._head=t,a?a[r]=t:e._tail=t,t[r]=n,t[s]=a},Fee=(e,t,i)=>{let r=e.style.transform;if(r){let s=e[m1],n=0,a=r.length,o;for(;n<a;){for(;n<a&&r.charCodeAt(n)===32;)n++;if(n>=a)break;let h=n;for(;n<a&&r.charCodeAt(n)!==40;)n++;if(n>=a)break;let u=r.substring(h,n),d=1,c=n+1,p=-1,m=-1;for(n++;n<a&&d>0;){let f=r.charCodeAt(n);f===40?d++:f===41?d--:f===44&&d===1&&(p===-1?p=n:m===-1&&(m=n)),n++}let g=n-1;u==="translate"||u==="translate3d"?(p===-1?s.translateX=r.substring(c,g).trim():(s.translateX=r.substring(c,p).trim(),m===-1?s.translateY=r.substring(p+1,g).trim():(s.translateY=r.substring(p+1,m).trim(),s.translateZ=r.substring(m+1,g).trim())),o=r.substring(c,g)):u==="scale"||u==="scale3d"?p===-1?s.scale=r.substring(c,g).trim():(s.scaleX=r.substring(c,p).trim(),m===-1?s.scaleY=r.substring(p+1,g).trim():(s.scaleY=r.substring(p+1,m).trim(),s.scaleZ=r.substring(m+1,g).trim())):s[u]=r.substring(c,g)}if(t==="translate3d"&&o)return i&&(i[t]=o),o;let l=s[t];if(!ui(l))return i&&(i[t]=l),l}return t==="translate3d"?"0px, 0px, 0px":t==="rotate3d"?"0, 0, 0, 0deg":Yl(t,"scale")?"1":Yl(t,"rotate")||Yl(t,"skew")?"0deg":"0px"},T5=e=>{let t="";for(let i=0,r=g1.length;i<r;i++){let s=g1[i],n=e[s];if(n!==void 0){if(s==="translateX"){let a=e.translateY;if(a!==void 0){let o=e.translateZ;o===void 0?(t+=`translate(${n},${a}) `,i+=1):(t+=`translate3d(${n},${a},${o}) `,i+=2);continue}}if(s==="scaleX"&&e.scale===void 0){let a=e.scaleY;if(a!==void 0){let o=e.scaleZ;o===void 0?(t+=`scale(${n},${a}) `,i+=1):(t+=`scale3d(${n},${a},${o}) `,i+=2);continue}}t+=`${gee[s]}${n}) `}s==="rotateZ"&&e.rotate3d!==void 0&&(t+=`rotate3d(${e.rotate3d}) `)}return e.matrix!==void 0&&(t+=`matrix(${e.matrix}) `),e.matrix3d!==void 0&&(t+=`matrix3d(${e.matrix3d}) `),t},Dee=e=>{let t=xee.exec(e)||vee.exec(e),i=ui(t[4])?1:+t[4];return[+t[1],+t[2],+t[3],i]},Oee=e=>{let t=e.length,i=t===4||t===5;return[+("0x"+e[1]+e[i?1:2]),+("0x"+e[i?2:3]+e[i?2:4]),+("0x"+e[i?3:5]+e[i?3:6]),t===5||t===9?+(("0x"+e[i?4:7]+e[i?4:8])/255).toFixed(3):1]},ES=(e,t,i)=>(i<0&&(i+=1),i>1&&--i,i<1/6?e+(t-e)*6*i:i<1/2?t:i<2/3?e+(t-e)*(2/3-i)*6:e),Bee=e=>{let t=bee.exec(e)||_ee.exec(e),i=t[1]/360,r=t[2]/100,s=t[3]/100,n=ui(t[4])?1:+t[4],a,o,l;if(r===0)a=o=l=s;else{let h=s<.5?s*(1+r):s+r-s*r,u=2*s-h;a=Vi(ES(u,h,i+1/3)*255,0),o=Vi(ES(u,h,i)*255,0),l=Vi(ES(u,h,i-1/3)*255,0)}return[a,o,l,n]},Uee=e=>v5(e)?Dee(e):x5(e)?Oee(e):b5(e)?Bee(e):[0,0,0,1],vr=(e,t)=>ui(e)?t:e,No=(e,t,i,r,s,n)=>{let a;if(ig(e))a=()=>{let o=e(t,i,r,n);return isNaN(+o)?o||0:+o};else if(tg(e)&&Yl(e,"var("))a=()=>{let o=e.match(See),l=o[1],h=o[2],u=getComputedStyle(t)?.getPropertyValue(l);return(!u||u.trim()==="")&&h&&(u=h.trim()),u||0};else return e;return s&&(s.func=a),a()},w5=(e,t)=>e[Qm]?e[c5]&&Eee(e,t)?Qt.ATTRIBUTE:g1.includes(t)||p5.get(t)?Qt.TRANSFORM:Yl(t,"--")?Qt.CSS_VAR:t in e.style?Qt.CSS:t in e?Qt.OBJECT:Qt.ATTRIBUTE:Qt.OBJECT,S5=(e,t,i)=>{let r=e.style[t];r&&i&&(i[t]=r);let s=r||getComputedStyle(e[mee]||e).getPropertyValue(t);return s==="auto"?"0":s},ng=(e,t,i,r)=>{let s=ui(i)?w5(e,t):i;if(s===Qt.OBJECT){let n=e[t];return n&&r&&(r[t]=n),n||0}if(s===Qt.ATTRIBUTE){let n=e.getAttribute(t);return n&&r&&(r[t]=n),n}return s===Qt.TRANSFORM?Fee(e,t,r):s===Qt.CSS_VAR?S5(e,t,r).trimStart():S5(e,t,r)},AS=(e,t,i)=>i==="-"?e-t:i==="+"?e+t:e*t,NS=()=>({t:ot.NUMBER,n:0,u:null,o:null,d:null,s:null}),Rn=(e,t)=>{if(t.t=ot.NUMBER,t.n=0,t.u=null,t.o=null,t.d=null,t.s=null,!e)return t;let i=+e;if(isNaN(i)){let r=e;r[1]==="="&&(t.o=r[0],r=r.slice(2));let s=r.includes(" ")?!1:Tee.exec(r);if(s)return t.t=ot.UNIT,t.n=+s[1],t.u=s[2],t;if(t.o)return t.n=+r,t;if(Cee(r))return t.t=ot.COLOR,t.d=Uee(r),t;{let n=r.match(m5);return t.t=ot.COMPLEX,t.d=n?n.map(Number):[],t.s=r.split(m5)||[],t}}else return t.n=i,t},M5=(e,t)=>(t.t=e._valueType,t.n=e._toNumber,t.u=e._unit,t.o=null,t.d=Ir(e._toNumbers),t.s=Ir(e._strings),t),Ru=NS(),C5=(e,t,i)=>{let r=e._modifier,s=e._fromNumbers,n=e._toNumbers,a=Vi(ns(r(Cu(s[0],n[0],t)),0,255),0),o=Vi(ns(r(Cu(s[1],n[1],t)),0,255),0),l=Vi(ns(r(Cu(s[2],n[2],t)),0,255),0),h=ns(r(Vi(Cu(s[3],n[3],t),i)),0,1);if(e._composition!==xr.none){let u=e._numbers;u[0]=a,u[1]=o,u[2]=l,u[3]=h}return`rgba(${a},${o},${l},${h})`},R5=(e,t,i)=>{let r=e._modifier,s=e._fromNumbers,n=e._toNumbers,a=e._strings,o=e._composition!==xr.none,l=a[0];for(let h=0,u=n.length;h<u;h++){let d=r(Vi(Cu(s[h],n[h],t),i)),c=a[h+1];l+=`${c?d+c:d}`,o&&(e._numbers[h]=d)}return l},x1=(e,t,i,r,s)=>{let n=e.parent,a=e.duration,o=e.completed,l=e.iterationDuration,h=e.iterationCount,u=e._currentIteration,d=e._loopDelay,c=e._reversed,p=e._alternate,m=e._hasChildren,g=e._delay,f=e._currentTime,y=g+l,x=t-g,b=ns(f,-g,a),_=ns(x,-g,a),T=x-f,w=_>0,M=_>=a,S=a<=ss,R=s===rn.FORCE,I=0,B=x,O=0;h>1&&(e._currentIteration=ns(~~(_/(l+(M?0:d))),0,h),M&&e._currentIteration--,I=e._currentIteration%2,B=_%(l+d)||0);let U=c^(p&&I),V=e._ease,z=M?U?0:a:U?l-B:B;V&&(z=l*V(z/l)||0);let Z=(n?n.backwards:x<f)?!U:!!U;if(e._currentTime=x,e._iterationTime=z,e.backwards=Z,w&&!e.began?(e.began=!0,!i&&!(n&&(Z||!n.began))&&e.onBegin(e)):x<=0&&(e.began=!1),!i&&!m&&w&&e._currentIteration!==u&&e.onLoop(e),R||s===rn.AUTO&&(t>=g&&t<=y||t<=g&&b>g||t>=y&&b!==a)||z>=y&&b!==a||z<=g&&b>
21080||t<=b&&b===a&&o||M&&!o&&S){if(w&&(e.computeDeltaTime(b),i||e.onBeforeUpdate(e)),!m){let j=R||(Z?T*-1:T)>=Ji.tickThreshold,ae=e._offset+(n?n._offset:0)+g+z,W=e._head,me,Ce,Qe,oe,dt=0;for(;W;){let et=W._composition,it=W._currentTime,Nt=W._changeDuration,ci=W._absoluteStartTime+W._changeDuration,Ri=W._nextRep,Kt=W._prevRep,Fr=et!==xr.none;if((j||(it!==Nt||ae<=ci+(Ri?Ri._delay:0))&&(it!==0||ae>=W._absoluteStartTime))&&(!Fr||!W._isOverridden&&(!W._isOverlapped||ae<=ci)&&(!Ri||Ri._isOverridden||ae<=Ri._absoluteStartTime)&&(!Kt||Kt._isOverridden||ae>=Kt._absoluteStartTime+Kt._changeDuration+W._delay))){let bi=W._currentTime=ns(z-W._startTime,0,Nt),E=W._ease(bi/W._updateDuration),D=W._modifier,$=W._valueType,Q=W._tweenType,Y=Q===Qt.OBJECT,J=$===ot.NUMBER,ce=J&&Y||E===0||E===1?-1:Ji.precision,ee,le;if(J?ee=le=D(Vi(Cu(W._fromNumber,W._toNumber,E),ce)):$===ot.UNIT?(le=D(Vi(Cu(W._fromNumber,W._toNumber,E),ce)),ee=`${le}${W._unit}`):$===ot.COLOR?ee=C5(W,E,ce):$===ot.COMPLEX&&(ee=R5(W,E,ce)),Fr&&(W._number=le),!r&&et!==xr.blend){let te=W.property;me=W.target,Y?me[te]=ee:Q===Qt.ATTRIBUTE?me.setAttribute(te,ee):(Ce=me.style,Q===Qt.TRANSFORM?(me!==Qe&&(Qe=me,oe=me[m1]),oe[te]=ee,dt=1):Q===Qt.CSS?Ce[te]=ee:Q===Qt.CSS_VAR&&Ce.setProperty(te,ee)),w&&(O=1)}else W._value=ee}dt&&W._renderTransforms&&(Ce.transform=T5(oe),dt=0),W=W._next}!i&&O&&e.onRender(e)}!i&&w&&e.onUpdate(e)}return n&&S?!i&&(n.began&&!Z&&x>0&&!o||Z&&x<=1e-11&&o)&&(e.onComplete(e),e.completed=!Z):w&&M?h===1/0?e._startTime+=e.duration:e._currentIteration>=h-1&&(e.paused=!0,!o&&!m&&(e.completed=!0,!i&&!(n&&(Z||!n.began))&&(e.onComplete(e),e._resolve(e)))):e.completed=!1,O},vc=(e,t,i,r,s)=>{let n=e._currentIteration;if(x1(e,t,i,r,s),e._hasChildren){let a=e,o=a.backwards,l=r?t:a._iterationTime,h=gc(),u=0,d=!0;if(!r&&a._currentIteration!==n){let c=a.iterationDuration;Ci(a,p=>{if(!o)!p.completed&&!p.backwards&&p._currentTime<p.iterationDuration&&x1(p,c,i,1,rn.FORCE),p.began=!1,p.completed=!1;else{let m=p.duration,g=p._offset+p._delay,f=g+m;!i&&m<=1e-11&&(!g||f===c)&&p.onComplete(p)}}),i||a.onLoop(a)}Ci(a,c=>{let p=Vi((l-c._offset)*c._speed,12),m=c._fps<a._fps?c.requestTick(h):s;u+=x1(c,p,i,r,m),!c.completed&&d&&(d=!1)},o),!i&&u&&a.onRender(a),(d||o)&&a._currentTime>=a.duration&&(a.paused=!0,a.completed||(a.completed=!0,i||(a.onComplete(a),a._resolve(a))))}},E5={},A5=(e,t,i)=>{if(i===Qt.TRANSFORM)return p5.get(e)||e;if(i===Qt.CSS||i===Qt.ATTRIBUTE&&y5(t)&&e in t.style){let r=E5[e];if(r)return r;{let s=e&&f5(e);return E5[e]=s,s}}else return e},N5=(e,t=!1)=>{if(e._hasChildren)Ci(e,i=>N5(i,t),!0);else{let i=e;i.pause(),Ci(i,r=>{let s=r.property,n=r.target,a=r._tweenType,o=r._inlineValue,l=rg(o)||o==="";if(a===Qt.OBJECT)!t&&!l&&(n[s]=o);else if(n[Qm])if(a===Qt.ATTRIBUTE)t||(l?n.removeAttribute(s):n.setAttribute(s,o));else{let h=n.style;if(a===Qt.TRANSFORM){let u=n[m1];l?delete u[s]:u[s]=o,r._renderTransforms&&(Object.keys(u).length?h.transform=T5(u):h.removeProperty("transform"))}else l?h.removeProperty(f5(s)):h[s]=o}n[Qm]&&i._tail===r&&i.targets.forEach(h=>{h.getAttribute&&h.getAttribute("style")===""&&h.removeAttribute("style")})})}return e},L5=class{constructor(e=0){this.deltaTime=0,this._currentTime=e,this._lastTickTime=e,this._startTime=e,this._lastTime=e,this._scheduledTime=0,this._frameDuration=eg/240,this._fps=240,this._speed=1,this._hasChildren=!1,this._head=null,this._tail=null}get fps(){return this._fps}set fps(e){let t=this._frameDuration,i=+e,r=i<1e-11?ss:i,s=eg/r;r>f1.frameRate&&(f1.frameRate=r),this._fps=r,this._frameDuration=s,this._scheduledTime+=s-t}get speed(){return this._speed}set speed(e){let t=+e;this._speed=t<1e-11?ss:t}requestTick(e){let t=this._scheduledTime;if(this._lastTickTime=e,e<t)return rn.NONE;let i=this._frameDuration,r=e-t;return this._scheduledTime+=r<i?i:r,rn.AUTO}computeDeltaTime(e){let t=e-this._lastTime;return this.deltaTime=t,this._lastTime=e,t}},bc={animation:null,update:sn},Vee=e=>{let t=bc.animation;return t||(t={duration:ss,computeDeltaTime:sn,_offset:0,_delay:0,_head:null,_tail:null},bc.animation=t,bc.update=()=>{e.forEach(i=>{for(let r in i){let s=i[r],n=s._head;if(n){let a=n._valueType,o=a===ot.COMPLEX||a===ot.COLOR?Ir(n._fromNumbers):null,l=n._fromNumber,h=s._tail;for(;h&&h!==n;){if(o)for(let u=0,d=h._numbers.length;u<d;u++)o[u]+=h._numbers[u];else l+=h._number;h=h._prevAdd}n._toNumber=l,n._toNumbers=o}}}),x1(t,1,1,0,rn.FORCE)}),t},P5=Xl?requestAnimationFrame:setImmediate,zee=Xl?cancelAnimationFrame:clearImmediate,Gee=class extends L5{constructor(e){super(e),this.useDefaultMainLoop=!0,this.pauseOnDocumentHidden=!0,this.defaults=f1,this.paused=!0,this.reqId=0}update(){let e=this._currentTime=gc();
2108if(this.requestTick(e)){this.computeDeltaTime(e);let t=this._speed,i=this._fps,r=this._head;for(;r;){let s=r._next;r.paused?(Kl(this,r),this._hasChildren=!!this._tail,r._running=!1,r.completed&&!r._cancelled&&r.cancel()):vc(r,(e-r._startTime)*r._speed*t,0,0,r._fps<i?r.requestTick(e):rn.AUTO),r=s}bc.update()}}wake(){return this.useDefaultMainLoop&&!this.reqId&&(this.requestTick(gc()),this.reqId=P5(k5)),this}pause(){if(this.reqId)return this.paused=!0,jee()}resume(){if(this.paused)return this.paused=!1,Ci(this,e=>e.resetTime()),this.wake()}get speed(){return this._speed*(Ji.timeScale===1?1:eg)}set speed(e){this._speed=e*Ji.timeScale,Ci(this,t=>t.speed=t._speed)}get timeUnit(){return Ji.timeScale===1?"ms":"s"}set timeUnit(e){let t=.001,i=e==="s",r=i?t:1;if(Ji.timeScale!==r){Ji.timeScale=r,Ji.tickThreshold=200*r;let s=i?t:eg;this.defaults.duration*=s,this._speed*=s}}get precision(){return Ji.precision}set precision(e){Ji.precision=e}},or=(()=>{let e=new Gee(gc());return Xl&&(g5.engine=e,Jm.addEventListener("visibilitychange",()=>{e.pauseOnDocumentHidden&&(Jm.hidden?e.pause():e.resume())})),e})(),k5=()=>{or._head?(or.reqId=P5(k5),or.update()):or.reqId=0},jee=()=>(zee(or.reqId),or.reqId=0,or),v1={_rep:new WeakMap,_add:new Map},LS=(e,t,i="_rep")=>{let r=v1[i],s=r.get(e);return s||(s={},r.set(e,s)),s[t]?s[t]:s[t]={_head:null,_tail:null}},$ee=(e,t)=>e._isOverridden||e._absoluteStartTime>t._absoluteStartTime,b1=e=>{e._isOverlapped=1,e._isOverridden=1,e._changeDuration=ss,e._currentTime=ss},I5=(e,t)=>{let i=e._composition;if(i===xr.replace){let r=e._absoluteStartTime;xc(t,e,$ee,"_prevRep","_nextRep");let s=e._prevRep;if(s){let n=s.parent,a=s._absoluteStartTime+s._changeDuration;if(e.parent.id!==n.id&&n.iterationCount>1&&a+(n.duration-n.iterationDuration)>r){b1(s);let h=s._prevRep;for(;h&&h.parent.id===n.id;)b1(h),h=h._prevRep}let o=r-e._delay;if(a>o){let h=s._startTime,u=Vi(o-(a-(h+s._updateDuration))-h,12);s._changeDuration=u,s._currentTime=u,s._isOverlapped=1,u<1e-11&&b1(s)}let l=!0;if(Ci(n,h=>{h._isOverlapped||(l=!1)}),l){let h=n.parent;if(h){let u=!0;Ci(h,d=>{d!==n&&Ci(d,c=>{c._isOverlapped||(u=!1)})}),u&&h.cancel()}else n.cancel()}}}else if(i===xr.blend){let r=LS(e.target,e.property,"_add"),s=Vee(v1._add),n=r._head;n||(n={...e},n._composition=xr.replace,n._updateDuration=ss,n._startTime=0,n._numbers=Ir(e._fromNumbers),n._number=0,n._next=null,n._prev=null,xc(r,n),xc(s,n));let a=e._toNumber;if(e._fromNumber=n._fromNumber-a,e._toNumber=0,e._numbers=Ir(e._fromNumbers),e._number=0,n._fromNumber=a,e._toNumbers){let o=Ir(e._toNumbers);o&&o.forEach((l,h)=>{e._fromNumbers[h]=n._fromNumbers[h]-l,e._toNumbers[h]=0}),n._fromNumbers=o}xc(r,e,null,"_prevAdd","_nextAdd")}return e},F5=e=>{let t=e._composition;if(t!==xr.none){let i=e.target,r=e.property,s=v1._rep.get(i)[r];if(Kl(s,e,"_prevRep","_nextRep"),t===xr.blend){let n=v1._add,a=n.get(i);if(!a)return;let o=a[r],l=bc.animation;Kl(o,e,"_prevAdd","_nextAdd");let h=o._head;if(h&&h===o._tail){Kl(o,h,"_prevAdd","_nextAdd"),Kl(l,h);let u=!0;for(let d in a)if(a[d]._head){u=!1;break}u&&n.delete(i)}}}return e},D5=(e,t,i)=>{let r=!1;return Ci(t,s=>{let n=s.target;if(e.includes(n)){let a=s.property,o=s._tweenType,l=A5(i,n,o);(!l||l&&l===a)&&(s.parent._tail===s&&s._tweenType===Qt.TRANSFORM&&s._prev&&s._prev._tweenType===Qt.TRANSFORM&&(s._prev._renderTransforms=1),Kl(t,s),F5(s),r=!0)}},!0),r},O5=(e,t,i)=>{let r=t||or,s;if(r._hasChildren){let n=0;Ci(r,a=>{if(!a._hasChildren)if(s=D5(e,a,i),s&&!a._head)a.cancel(),Kl(r,a);else{let o=a._offset+a._delay+a.duration;o>n&&(n=o)}a._head?O5(e,a,i):a._hasChildren=!1},!0),ui(r.iterationDuration)||(r.iterationDuration=n)}else s=D5(e,r,i);s&&!r._head&&(r._hasChildren=!1,r.cancel&&r.cancel())},B5=e=>(e.paused=!0,e.began=!1,e.completed=!1,e),PS=e=>(e._cancelled&&(e._hasChildren?Ci(e,PS):Ci(e,t=>{t._composition!==xr.none&&I5(t,LS(t.target,t.property))}),e._cancelled=0),e),U5=0,Wee=(e,t)=>e._priority>t._priority,Hee=class extends L5{constructor(e={},t=null,i=0){super(0),++U5;let{id:r,delay:s,duration:n,reversed:a,alternate:o,loop:l,loopDelay:h,autoplay:u,frameRate:d,playbackRate:c,priority:p,onComplete:m,onLoop:g,onPause:f,onBegin:y,onBeforeUpdate:x,onUpdate:b}=e;SS.current&&SS.current.register(this);let _=t?0:or._lastTickTime,T=t?t.defaults:Ji.defaults,w=ig(s)||ui(s)?T.delay:+s,M=ig(n)||ui(n)?1/0:+n,S=vr(l,T.loop),R=vr(h,T.loopDelay),I=S===!0||S===1/0||S<0?1/0:S+1,B=0;t?B=i:(or.reqId||or.requestTick(gc()),B=(or._lastTickTime-or._startTime)*Ji.timeScale),this.id=ui(r)?U5:r,this.parent=t,this.duration=RS((M+R)*I-R)||1e-11,this.backwards=!1,this.paused=!0,this.began=!1,this.completed=!1,this.onBegin=y||T.onBegin,this.onBeforeUpdate=x||T.onBeforeUpdate,this.onUpdate=b||T.onUpdate,this.onLoop=g||T.onLoop,this.onPause=f||T.onPause,this.onComplete=m||T.onComplete,this.iterationDuration=M,this.iterationCount=I,this._autoplay=t?!1:vr(u,T.autoplay),this._offset=B,this._delay=w,this._loopDelay=R,this._iterationTime=0,this._currentIteration=0,this._resolve=sn,this._running=!1,this._reversed=+vr(a,T.reversed),this._reverse=this._reversed,this._cancelled=0,this._alternate=vr(o,T.alternate),this._prev=null,this._next=null,this._lastTickTime=_,this._startTime=_,this._lastTime=_,this._fps=vr(d,T.frameRate),this._speed=vr(c,T.playbackRate),this._priority=+vr(p,1)}get cancelled(){return!!this._cancelled}set cancelled(e){e?this.cancel():this.reset(!0).play()}get currentTime(){return ns(Vi(this._currentTime,Ji.precision),-this._delay,this.duration)}set currentTime(e){let t=this.paused;this.pause().seek(+e),t||this.resume()}get iterationCurrentTime(){return ns(Vi(this._iterationTime,Ji.precision),0,this.iterationDuration)}set iterationCurrentTime(e){this.currentTime=this.iterationDuration*this._currentIteration+e}get progress(){return ns(Vi(this._currentTime/this.duration,10),0,1)}set progress(e){this.currentTime=this.duration*e}get iterationProgress(){return ns(Vi(this._iterationTime/this.iterationDuration,10),0,1)}set iterationProgress(e){let t=this.iterationDuration;this.currentTime=t*this._currentIteration+t*e}get currentIteration(){return this._currentIteration}set currentIteration(e){this.currentTime=this.iterationDuration*ns(+e,0,this.iterationCount-1)}get reversed(){return!!this._reversed}set reversed(e){e?this.reverse():this.play()}get speed(){return super.speed}set speed(e){super.speed=e,this.resetTime()}reset(e=!1){return PS(this),this._reversed&&!this._reverse&&(this.reversed=!1),this._iterationTime=this.iterationDuration,vc(this,0,1,~~e,rn.FORCE),B5(this),this._hasChildren&&Ci(this,B5),this}init(e=!1){this.fps=this._fps,this.speed=this._speed,!e&&this._hasChildren&&vc(this,this.duration,1,~~e,rn.FORCE),this.reset(e);let t=this._autoplay;return t===!0?this.resume():t&&!ui(t.linked)&&t.link(this),this}resetTime(){let e=1/(this._speed*or._speed);return this._startTime=gc()-(this._currentTime+this._delay)*e,this}pause(){return this.paused?this:(this.paused=!0,this.onPause(this),this)}resume(){return this.paused?(this.paused=!1,this.duration<=1e-11&&!this._hasChildren?vc(this,ss,0,0,rn.FORCE):(this._running||=(xc(or,this,Wee),or._hasChildren=!0,!0),this.resetTime(),this._startTime-=12,or.wake()),this):this}restart(){return this.reset().resume()}seek(e,t=0,i=0){PS(this),this.completed=!1;let r=this.paused;return this.paused=!0,vc(this,e+this._delay,~~t,~~i,rn.AUTO),r?this:this.resume()}alternate(){let e=this._reversed,t=this.iterationCount,i=this.iterationDuration,r=t===1/0?Pee(wS/i):t;return this._reversed=+(this._alternate&&!(r%2)?e:!e),t===1/0?this.iterationProgress=this._reversed?1-this.iterationProgress:this.iterationProgress:this.seek(i*r-this._currentTime),this.resetTime(),this}play(){return this._reversed&&this.alternate(),this.resume()}reverse(){return this._reversed||this.alternate(),this.resume()}cancel(){return this._hasChildren?Ci(this,e=>e.cancel(),!0):Ci(this,F5),this._cancelled=1,this.pause()}stretch(e){let t=this.duration,i=sg(e);if(t===i)return this;let r=e/t,s=e<=ss;return this.duration=s?ss:i,this.iterationDuration=s?ss:sg(this.iterationDuration*r),this._offset*=r,this._delay*=r,this._loopDelay*=r,this}revert(){vc(this,0,1,0,rn.AUTO);let e=this._autoplay;return e&&e.linked&&e.linked===this&&e.revert(),this.cancel()}complete(e=0){return this.seek(this.duration,e).cancel()}then(e=sn){let t=this.then,i=()=>{this.then=null,e(this),this.then=t,this._resolve=sn};return new Promise(r=>(this._resolve=()=>r(i()),this.completed&&this._resolve(),this))}};function V5(e){let t=tg(e)?SS.root.querySelectorAll(e):e;if(t instanceof NodeList||t instanceof HTMLCollection)return t}function z5(e){if(rg(e))return[];if(!Xl)return fc(e)&&e.flat(1/0)||[e];if(fc(e)){let i=e.flat(1/0),r=[];for(let s=0,n=i.length;s<n;s++){let a=i[s];if(!rg(a)){let o=V5(a);if(o)for(let l=0,h=o.length;l<h;l++){let u=o[l];if(!rg(u)){let d=!1;for(let c=0,p=r.length;c<p;c++)if(r[c]===u){d=!0;break}d||r.push(u)}}else{let l=!1;for(let h=0,u=r.length;h<u;h++)if(r[h]===a){l=!0;break}l||r.push(a)}}}return r}let t=V5(e);return t?Array.from(t):[e]}function qee(e){let t=z5(e),i=t.length;if(i)for(let r=0;r<i;r++){let s=t[r];
2108if(!s[d5]){s[d5]=!0;let n=y5(s);(s.nodeType||n)&&(s[Qm]=!0,s[c5]=n,s[m1]={})}}return t}var kS={deg:1,rad:180/CS,turn:360},G5={},j5=(e,t,i,r=!1)=>{let s=t.u,n=t.n;if(t.t===ot.UNIT&&s===i)return t;let a=n+s+i,o=G5[a];if(!ui(o)&&!r)t.n=o;else{let l;if(s in kS)l=n*kS[s]/kS[i];else{let h=e.cloneNode(),u=e.parentNode,d=u&&u!==Jm?u:Jm.body;d.appendChild(h);let c=h.style;c.width=100+s;let p=h.offsetWidth||100;c.width=100+i;let m=p/(h.offsetWidth||100);d.removeChild(h),l=m*n}t.n=l,G5[a]=l}return t.t,ot.UNIT,t.u=i,t},Zl=e=>e,ag=(e=1.68)=>t=>yc(t,+e),IS={in:e=>t=>e(t),out:e=>t=>1-e(1-t),inOut:e=>t=>t<.5?e(t*2)/2:1-e(t*-2+2)/2,outIn:e=>t=>t<.5?(1-e(1-t*2))/2:(e(t*2-1)+1)/2},Xee=CS/2,$5=CS*2,W5={"":ag,Quad:ag(2),Cubic:ag(3),Quart:ag(4),Quint:ag(5),Sine:e=>1-Lee(e*Xee),Circ:e=>1-Aee(1-e*e),Expo:e=>e?yc(2,10*e-10):0,Bounce:e=>{let t,i=4;for(;e<((t=yc(2,--i))-1)/11;);return 1/yc(4,3-i)-7.5625*yc((t*3-2)/22-e,2)},Back:(e=1.7)=>t=>(+e+1)*t*t*t-+e*t*t,Elastic:(e=1,t=.3)=>{let i=ns(+e,1,10),r=ns(+t,ss,2),s=r/$5*kee(1/i),n=$5/r;return a=>a===0||a===1?a:-i*yc(2,-10*(1-a))*Nee((1-a-s)*n)}},FS=(()=>{let e={linear:Zl,none:Zl};for(let t in IS)for(let i in W5){let r=W5[i],s=IS[t];e[t+i]=i===""||i==="Back"||i==="Elastic"?(n,a)=>s(r(n,a)):s(r)}return e})(),_1={linear:Zl,none:Zl},Yee=e=>{if(_1[e])return _1[e];if(e.indexOf("(")<=-1){let t=IS[e]||e.includes("Back")||e.includes("Elastic")?FS[e]():FS[e];return t?_1[e]=t:Zl}else{let t=e.slice(0,-1).split("("),i=FS[t[0]];return i?_1[e]=i(...t[1].split(",")):Zl}},H5=["steps(","irregular(","linear(","cubicBezier("],q5=e=>{if(tg(e)){for(let t=0,i=H5.length;t<i;t++)if(Yl(e,H5[t]))return console.warn(`String syntax for \`ease: "${e}"\` has been removed from the core and replaced by importing and passing the easing function directly: \`ease: ${e}\``),Zl}return ig(e)?e:tg(e)?Yee(e):Zl},ke=NS(),Xe=NS(),_c={},T1={func:null},DS={func:null},w1=[null],Tc=[null,null],S1={to:null},Kee=0,X5=0,Jl,Ea,Zee=(e,t)=>{let i={};if(fc(e)){let r=[].concat(...e.map(s=>Object.keys(s))).filter(y1);for(let s=0,n=r.length;s<n;s++){let a=r[s];i[a]=e.map(o=>{let l={};for(let h in o){let u=o[h];y1(h)?h===a&&(l.to=u):l[h]=u}return l})}}else{let r=vr(t.duration,Ji.defaults.duration);Object.keys(e).map(s=>({o:parseFloat(s)/100,p:e[s]})).sort((s,n)=>s.o-n.o).forEach(s=>{let n=s.o,a=s.p;for(let o in a)if(y1(o)){let l=i[o];l||=i[o]=[];let h=n*r,u=l.length,d=l[u-1],c={to:a[o]},p=0;for(let m=0;m<u;m++)p+=l[m].duration;u===1&&(c.from=d.to),a.ease&&(c.ease=a.ease),c.duration=h-(u?p:0),l.push(c)}return s});for(let s in i){let n=i[s],a;for(let o=0,l=n.length;o<l;o++){let h=n[o],u=h.ease;h.ease=a||void 0,a=u}n[0].duration||n.shift()}}return i},Jee=class extends Hee{constructor(e,t,i,r,s=!1,n=0,a){super(t,i,r),++X
21085;let o=qee(e),l=o.length,h=t.keyframes,u=h?Iee(Zee(h,t),t):t,{id:d,delay:c,duration:p,ease:m,playbackEase:g,modifier:f,composition:y,onRender:x}=u,b=i?i.defaults:Ji.defaults,_=vr(m,b.ease),T=vr(g,b.playbackEase),w=T?q5(T):null,M=!ui(_.ease),S=M?_.ease:vr(m,w?"linear":b.ease),R=M?_.settlingDuration:vr(p,b.duration),I=vr(c,b.delay),B=f||b.modifier,O=ui(y)&&l>=1e3?xr.none:ui(y)?b.composition:y,U=this._offset+(i?i._offset:0);M&&(_.parent=this);let V=NaN,z=NaN,Z=0,j=0;for(let ae=0;ae<l;ae++){let W=o[ae],me=n||ae,Ce=a||o,Qe=NaN,oe=NaN;for(let dt in u)if(y1(dt)){let et=w5(W,dt),it=A5(dt,W,et),Nt=u[dt],ci=fc(Nt);if(s&&!ci&&(Tc[0]=Nt,Tc[1]=Nt,Nt=Tc),ci){let D=Nt.length,$=!MS(Nt[0]);D===2&&$?(S1.to=Nt,w1[0]=S1,Jl=w1):D>2&&$?(Jl=[],Nt.forEach((Q,Y)=>{Y?Y===1?(Tc[1]=Q,Jl.push(Tc)):Jl.push(Q):Tc[0]=Q})):Jl=Nt}else w1[0]=Nt,Jl=w1;let Ri=null,Kt=null,Fr=NaN,bi=0,E=0;for(let D=Jl.length;E<D;E++){let $=Jl[E];MS($)?Ea=$:(S1.to=$,Ea=S1),T1.func=null,DS.func=null;let Q=No(vr(Ea.composition,O),W,me,Ce,null,null),Y=Mee(Q)?Q:xr[Q];!Ri&&Y!==xr.none&&(Ri=LS(W,it));let J=Ri?Ri._tail:null,ce=i&&J&&J.parent.parent===i?J:Kt,ee=No(Ea.to,W,me,Ce,T1,ce),le;MS(ee)&&!ui(ee.to)?(Ea=ee,le=ee.to):le=ee;let te=No(Ea.from,W,me,Ce,null,ce),Me=Ea.ease||S,ye=No(Me,W,me,Ce,null,ce),_e=ig(ye)||tg(ye)?ye:Me,Ee=!ui(_e)&&!ui(_e.ease),Ye=Ee?_e.ease:_e,St=Ee?_e.settlingDuration:No(vr(Ea.duration,D>1?No(R,W,me,Ce,null,ce)/D:R),W,me,Ce,null,ce),ct=No(vr(Ea.delay,E?0:I),W,me,Ce,null,ce),Ft=Ea.modifier||B,Dt=!ui(te),br=!ui(le),Ei=fc(le),An=Ei||Dt&&br,Aa=Kt?bi+ct:ct,_i=Vi(U+Aa,12);!j&&(Dt||Ei)&&(j=1);let Wt=Kt;if(Y!==xr.none){let ht=Ri._head;for(;ht&&!ht._isOverridden&&ht._absoluteStartTime<=_i;)if(Wt=ht,ht=ht._nextRep,ht&&ht._absoluteStartTime>=_i)for(;ht;)b1(ht),ht=ht._nextRep}if(An){Rn(Ei?No(le[0],W,me,Ce,DS,ce):te,ke),Rn(Ei?No(le[1],W,me,Ce,T1,ce):le,Xe);let ht=ng(W,it,et,_c);ke.t===ot.NUMBER&&(Wt?Wt._valueType===ot.UNIT&&(ke.t=ot.UNIT,ke.u=Wt._unit):(Rn(ht,Ru),Ru.t===ot.UNIT&&(ke.t=ot.UNIT,ke.u=Ru.u)))}else br?Rn(le,Xe):Kt?M5(Kt,Xe):Rn(i&&Wt&&Wt.parent.parent===i?Wt._value:ng(W,it,et,_c),Xe),Dt?Rn(te,ke):Kt?M5(Kt,ke):Rn(i&&Wt&&Wt.parent.parent===i?Wt._value:ng(W,it,et,_c),ke);if(ke.o&&(ke.n=AS(Wt?Wt._toNumber:Rn(ng(W,it,et,_c),Ru).n,ke.n,ke.o)),Xe.o&&(Xe.n=AS(ke.n,Xe.n,Xe.o)),ke.t!==Xe.t){if(ke.t===ot.COMPLEX||Xe.t===ot.COMPLEX){let ht=ke.t===ot.COMPLEX?ke:Xe,zi=ke.t===ot.COMPLEX?Xe:ke;zi.t=ot.COMPLEX,zi.s=Ir(ht.s),zi.d=ht.d.map(()=>zi.n)}else if(ke.t===ot.UNIT||Xe.t===ot.UNIT){let ht=ke.t===ot.UNIT?ke:Xe,zi=ke.t===ot.UNIT?Xe:ke;zi.t=ot.UNIT,zi.u=ht.u}else if(ke.t===ot.COLOR||Xe.t===ot.COLOR){let ht=ke.t===ot.COLOR?ke:Xe,zi=ke.t===ot.COLOR?Xe:ke;zi.t=ot.COLOR,zi.s=ht.s,zi.d=[0,0,0,1]}}if(ke.u!==Xe.u){let ht=Xe.u?ke:Xe;ht=j5(W,ht,Xe.u?Xe.u:ke.u,!1)}if(Xe.d&&ke.d&&Xe.d.length!==ke.d.length){let ht=ke.d.length>Xe.d.length?ke:Xe,zi=ht===ke?Xe:ke;zi.d=ht.d.map((V1,Nn)=>ui(zi.d[Nn])?0:zi.d[Nn]),zi.s=Ir(ht.s)}let Io=Vi(+St||1e-11,12),Na=_c[it];rg(Na)||(_c[it]=null);let Ai={parent:this,id:Kee++,property:it,target:W,_value:null,_toFunc:T1.func,_fromFunc:DS.func,_ease:q5(Ye),_fromNumbers:Ir(ke.d),_toNumbers:Ir(Xe.d),_strings:Ir(Xe.s),_fromNumber:ke.n,_toNumber:Xe.n,_numbers:Ir(ke.d),_number:ke.n,_unit:Xe.u,_modifier:Ft,_currentTime:0,_startTime:Aa,_delay:+ct,_updateDuration:Io,_changeDuration:Io,_absoluteStartTime:_i,_tweenType:et,_valueType:Xe.t,_composition:Y,_isOverlapped:0,_isOverridden:0,_renderTransforms:0,_inlineValue:Na,_prevRep:null,_nextRep:null,_prevAdd:null,_nextAdd:null,_prev:null,_next:null};Y!==xr.none&&I5(Ai,Ri);let La=Ai._valueType;La===ot.COMPLEX?Ai._value=R5(Ai,1,-1):La===ot.COLOR?Ai._value=C5(Ai,1,-1):La===ot.UNIT?Ai._value=`${Ft(Ai._toNumber)}${Ai._unit}`:Ai._value=Ft(Ai._toNumber),isNaN(Fr)&&(Fr=Ai._startTime),bi=Vi(Aa+Io,12),Kt=Ai,Z++,xc(this,Ai)}(isNaN(z)||Fr<z)&&(z=Fr),(isNaN(V)||bi>V)&&(V=bi),et===Qt.TRANSFORM&&(Qe=Z-E,oe=Z)}if(!isNaN(Qe)){let dt=0;Ci(this,et=>{dt>=Qe&&dt<oe&&(et._renderTransforms=1,et._composition===xr.blend&&Ci(bc.animation,it=>{it.id===et.id&&(it._renderTransforms=1)})),dt++})}}l||console.warn("No target found. Make sure the element you're trying to animate is accessible before creating your animation."),z?(Ci(this,ae=>{ae._startTime-ae._delay||(ae._delay-=z),ae._startTime-=z}),V-=z):z=0,V||(V=ss,this.iterationCount=0),this.targets=o,this.id=ui(d)?X5:d,this.duration=V===1e-11?ss:RS((V+this._loopDelay)*this.iterationCount-this._loopDelay)||1e-11,this.onRender=x||b.onRender,this._ease=w,this._delay=z,this.iterationDuration=V,!this._autoplay&&j&&this.onRender(this)}stretch(e){let t=this.duration;if(t===sg(e))return this;let i=e/t;return Ci(this,r=>{r._updateDuration=sg(r._updateDuration*i),r._changeDuration=sg(r._changeDuration*i),r._currentTime*=i,r._startTime*=i,r._absoluteStartTime*=i}),super.stretch(e)}refresh(){return Ci(this,e=>{let t=e._toFunc,i=e._fromFunc;(t||i)&&(i?(Rn(i(),ke),ke.u!==e._unit&&e.target[Qm]&&j5(e.target,ke,e._unit,!0),e._fromNumbers=Ir(ke.d),e._fromNumber=ke.n):t&&(Rn(ng(e.target,e.property,e._tweenType),Ru),e._fromNumbers=Ir(Ru.d),e._fromNumber=Ru.n),t&&(Rn(t(),Xe),e._toNumbers=Ir(Xe.d),e._strings=Ir(Xe.s),e._toNumber=Xe.o?AS(e._fromNumber,Xe.n,Xe.o):Xe.n))}),this.duration===1e-11&&this.restart(),this}revert(){return super.revert(),N5(this)}then(e){return super.then(e)}},Ql=(e,t)=>Ji.editor?Ji.editor.addAnimation(e,t):new Jee(e,t,null,0,!1).init(),Y5={_head:null,_tail:null},Qee=(e,t,i)=>{let r=Y5._head,s;for(;r;){let n=r._next,a=r.$el===e,o=!t||r.property===t,l=!i||r.parent===i;if(a&&o&&l){s=r.animation;
2108try{s.commitStyles()}catch{}s.cancel(),Kl(Y5,r);let h=r.parent;h&&(h._completed++,h.animations.length===h._completed&&(h.completed=!0,h.paused=!0,h.muteCallbacks||(h.onComplete(h),h._resolve(h))))}r=n}return s},Eu=(e,t,i)=>{let r=z5(e);for(let s=0,n=r.length;s<n;s++)Qee(r[s],i,t&&t.controlAnimation&&t);return O5(r,t,i),r},gt={isDown:!1,x:N.width*.5,y:N.height*.5,moveX:N.width*.5,moveY:N.height*.5,isMoveX:!1,isMoveY:!1,e:null,downStart:0,downEnd:0,percentX:.5,percentY:.5,normalizedX:0,normalizedY:0,totalDistance:0},ete={x:gt.x,y:gt.y},[OS,M1,BS,US,tte,ite]=[,,,,,,].fill().map(()=>new je),rte=[];function og(e){return Object.assign(gt,{x:e.x,y:e.y,moveX:e.x-gt.x,moveY:e.y-gt.y,percentX:e.x/N.width,percentY:e.y/N.height,normalizedX:(e.x/N.width-.5)*2,normalizedY:(e.y/N.height-.5)*2,e}),!gt.isMoveX&&!gt.isMoveY&&(Math.abs(gt.moveX)>Math.abs(gt.moveY)&&Math.abs(gt.moveX)>15?gt.isMoveX=!0:Math.abs(gt.moveY)>Math.abs(gt.moveX)&&Math.abs(gt.moveY)>15&&(gt.isMoveY=!0)),gt.totalDistance+=Math.abs(gt.moveX)+Math.abs(gt.moveY),gt}function C1(){Object.assign(gt,{isDown:!1,moveX:0,moveY:0,isMoveX:!1,isMoveY:!1,downEnd:Date.now()})}function eh(e,t,i){e.addEventListener(t,i),rte.push({target:e,event:t,handler:i})}if(typeof window<"u"){let e=()=>{C1(),ite.dispatch()};eh(window,"blur",e),eh(window,"pointerleave",e),eh(window,"pointerdown",t=>{Object.assign(gt,{isDown:!0,downStart:Date.now(),x:t.x,y:t.y,totalDistance:0}),OS.dispatch(og(t))}),eh(window,"pointermove",t=>{Object.assign(ete,gt),BS.dispatch(og(t))}),eh(window,"pointerup",t=>{C1(),M1.dispatch(og(t))}),eh(window,"pointercancel",t=>{C1(),M1.dispatch(og(t))}),eh(window,"click",t=>{gt.downEnd-gt.downStart<=300&&gt.totalDistance<=10&&US.dispatch(og(t))})}typeof document<"u"&&eh(document.body,"pointerenter",()=>{C1(),tte.dispatch()});var K5=Vt(([e,t])=>{let i=t.xy.add(1).div(2).toVar();i.y=i.y.oneMinus();let r=e.sample(i).rgb.toVar(),s=Gh(r.b,0,1,-75,75).toVar();return O0(Gh(r.r,0,1,-75,75).toVar(),s).toVar()}),ste=class o2 extends Gr{constructor(t){super(),this.layer=t,this.visible=!1,this.immediateVisible=!1,this.needsResize=!1,this.uToggleOpacity=Le(0),this.uOpacity=Le(0),this.uExtends=Le(ai(0,0,1,1));let i=o2.map||=new Wo().load(hi("https://static5.mclcm.net/images/mc2020/bundles/map/sprite_arrow.png"));this._dataMap=Fi(i),this.material=new Qn({map:i,transparent:!0,alphaTest:.1}),this.geometry=new Un(2,2),this.gridSize=Mi.value==="screenshot"?30:53;let r=bm.value[0]??N.width,s=bm.value[1]??N.height;this.uWidth=Le(r),this.uHeight=Le(s),this.uSize=Le(this.gridSize/r),this.aspectRatio=Le(r/s),this.uScale=Le(.75);let{instanced:n,iba:a,positionAttribute:o}=this.createGrid(r,s);this.instanced=n,this.positionAttribute=o,this.updateShaderNodes(a),this.add(this.instanced),this.scale.setScalar(.5),this.renderOrder=999997,this.debouncedResize=Al((l,h)=>{if(!this.immediateVisible){this.needsResize=!0;return}this.uWidth.value=l,this.uHeight.value=h,this.uSize.value=this.gridSize/l,this.aspectRatio.value=l/h,this.updateGridPositions(l,h),this.needsResize=!1,this.instanced.visible=this.immediateVisible},350),N.onResize.add(()=>{if(!this.immediateVisible){this.needsResize=!0;return}this.instanced&&(this.instanced.visible=!1),this.debouncedResize(N.width,N.height)}),N.onUpdate.add(this.update)}updateShaderNodes(t){let i=V0.xy.toVar(),r=Je(i.x,i.y),s=O0(r.y,r.x).add(K5(this._dataMap,t));s=s.add(Math.PI/2),this.material.positionNode=Vt(()=>{let a=t.xy.add(1).div(2).toVar("mapUV");a.y.assign(a.y.oneMinus());let o=this._dataMap.sample(a).rgb.toVar("col"),l=fn(0).toVar();return Pd(o.r.equal(0).and(o.g.equal(0)).and(o.b.equal(0)),()=>{}).Else(()=>{l.assign(fn(I_(s).div(this.aspectRatio),G0(s),0).mul(this.uSize).mul(this.uScale).add(t.div(this.aspectRatio)).mul(this.aspectRatio))}),l})(),this.material.colorNode=Vt(()=>(oa(Ms.x.lessThan(this.uExtends.x).or(Ms.y.lessThan(this.uExtends.y)).or(Ms.x.greaterThan(this.uExtends.z)).or(Ms.y.greaterThan(this.uExtends.w))),fn(0)))();let n=o2.map;this.material.opacityNode=Fi(n).a.mul(D_).mul(this.uOpacity).mul(this.uToggleOpacity).mul(.9)}createGrid(t,i){let r=Math.ceil(t/this.gridSize),s=r*Math.ceil(i/this.gridSize),n=new wx(this.geometry,this.material,s);n.instanceMatrix.setUsage(an);let a=[];for(let l=0;l<s;l++){let h=l%r*this.gridSize,u=Math.floor(l/r)*this.gridSize,d=2/t*h-1,c=1-2/i*u;a.push(d,c,0)}let o=new cr(new Float32Array(a),3);return{instanced:n,iba:vl(o),positionAttribute:o}}updateGridPositions(t,i){if(!this.positionAttribute)return;let r=Math.ceil(t/this.gridSize),s=r*Math.ceil(i/this.gridSize);if(s!==this.positionAttribute.count){this.regenerateGrid(t,i);return}let n=this.positionAttribute.array;for(let a=0;a<s;a++){let o=a%r*this.gridSize,l=Math.floor(a/r)*this.gridSize,h=2/t*o-1,u=1-2/i*l;n[a*3]=h,n[a*3+1]=u,n[a*3+2]=0}this.positionAttribute.needsUpdate=!0,q.scheduleRender()}regenerateGrid(t,i){this.instanced&&(this.remove(this.instanced),this.instanced.geometry&&this.instanced.geometry.dispose());let{instanced:r,iba:s,positionAttribute:n}=this.createGrid(t,i);this.instanced=r,this.positionAttribute=n,this.updateShaderNodes(s),this.add(this.instanced),q.scheduleRender()}update=()=>{!this.visible||!this._dataMap.value||(Mi.value=="screenshot"?this.uOpacity.value=this.layer.opacity:this.layer.isMoving||this.layer.opacity<1&&this.layer.animationCompleted?this.uOpacity.value+=(0-this.uOpacity.value)*.1:this.uOpacity.value+=(1-this.uOpacity.value)*.1)};set dataMap(t){this._dataMap.value=t,q.scheduleRender()}setVisible(t){this.immediateVisible!=t&&(this.immediateVisible=t,t&&this.needsResize&&(this.uWidth.value=N.width,this.uHeight.value=N.height,this.uSize.value=this.gridSize/N.width,this.aspectRatio.value=N.width/N.height,this.updateGridPositions(N.width,N.height),this.needsResize=!1),Mi.value=="screenshot"?(this.uToggleOpacity.value=+!!t,this.visible=t):(Eu(this.uToggleOpacity),Ql(this.uToggleOpacity,{value:+!!t,duration:.3,ease:"outQuad",onUpdate:()=>{q.scheduleRender()},onComplete:()=>{this.visible=t}})))}set opacity(t){this.material.opacity=t}get opacity(){return this.material.opacity}dispose(){this._disposed||(this._disposed=!0,N.onUpdate.remove(this.update),this.instanced&&(this.instanced.geometry&&this.instanced.geometry.dispose(),this.instanced.material&&this.instanced.material.dispose()),this.material&&=(this.material.dispose(),null),this.instanced=null,this.dataRT=null,this.uDataRT=null,this.uToggleOpacity=null,this.uBounds=null,this.uRelativeBounds=null,this.uNormalizeBounds=null,this.uResolution=null,this.uMode=null,this.parent=null)}},nte=class RO extends Gr{constructor(t){super(),this.layer=t,this.visible=!1,this.immediateVisible=!1,this.needsResize=!1,this.uToggleOpacity=Le(0),this.uOpacity=Le(0),this.uOpacityMoving=Le(1),this.uExtends=Le(ai(0,0,1,1));let i=RO.map||=new Wo().load(hi("https://static5.mclcm.net/images/mc2020/bundles/map/sprite_barb_v2.png"));i.wrapS=i.wrapT=Or,i.minFilter=i.magFilter=mi,i.anisotropy=16;let r=Fi(i);this._dataMap=Fi(i),this.material=new Qn({map:i,transparent:!0,opacity:1,depthWrite:!1}),this.gridSize=Mi.value==="screenshot"?30:53,this.geometry=new Un(1,1);let s=bm.value[0]??N.width,n=bm.value[1]??N.height;this.uWidth=Le(s),this.uHeight=Le(n),this.uSize=Le(this.gridSize/s),this.aspectRatio=Le(s/n),this.uScale=Le(1);let{instanced:a,iba:o,positionAttribute:l}=this.createGrid(s,n);this.instanced=a,this.positionAttribute=l,this.uMap=r,this.updateShaderNodes(o),this.add(this.instanced),this.scale.setScalar(.5),this.renderOrder=999998,this.debouncedResize=Al((h,u)=>{if(!this.immediateVisible){this.needsResize=!0;return}this.uWidth.value=h,this.uHeight.value=u,this.uSize.value=this.gridSize/h,this.aspectRatio.value=h/u,this.updateGridPositions(h,u),this.needsResize=!1,this.instanced.visible=this.immediateVisible},350),N.onResize.add(()=>
2108{if(!this.immediateVisible){this.needsResize=!0;return}this.instanced&&(this.instanced.visible=!1),this.debouncedResize(N.width,N.height)}),N.onUpdate.add(this.update)}updateShaderNodes(t){let i=V0.xy.toVar(),r=Je(i.x,i.y),s=O0(r.y,r.x).add(K5(this._dataMap,t)).toVar();s=s.add(-Math.PI/2),this.material.positionNode=Vt(()=>{let a=t.xy.add(1).div(2).toVar();a.y=a.y.oneMinus();let o=this._dataMap.sample(a).rgb.toVar(),l=fn(0).toVar();return Pd(o.r.equal(0).and(o.g.equal(0)).and(o.b.equal(0)),()=>{}).Else(()=>{l.assign(fn(I_(s).div(this.aspectRatio),G0(s),0).mul(this.uSize).mul(this.uScale).add(t.div(this.aspectRatio)).mul(this.aspectRatio))}),l})();let n=Vt(()=>{let a=t.xy.add(1).div(2).toVar("mapUV");a.y.assign(a.y.oneMinus());let o=this._dataMap.sample(a).toVar("col"),l=la().x.oneMinus().mul(1/10).toVar(),h=la().y.mul(1/4).toVar(),u=ai().toVar(),d=Gh(o.b,0,1,-75,75).toVar("U"),c=Gh(o.r,0,1,-75,75).toVar("V"),p=F_(z0(M3(d.mul(d).add(c.mul(c))).toVar("speedRaw"),0,106.066,0,1).toVar("normalizedSpeed").mul(22)).toVar("idx"),m=l.add(p.mod(10).div(10)).toVar("x"),g=h.add(F_(p.div(10)).mul(1/4)).toVar("y"),f=this.uMap.sample(Je(m,g.oneMinus())).toVar("c");return oa(f.a.lessThan(.05)),u.assign(f),u});this.material.opacityNode=Vt(()=>n().a.mul(this.uOpacityMoving).mul(this.uToggleOpacity).toVar("opacity"))(),this.material.colorNode=Vt(()=>(oa(Ms.x.lessThan(this.uExtends.x).or(Ms.y.lessThan(this.uExtends.y)).or(Ms.x.greaterThan(this.uExtends.z)).or(Ms.y.greaterThan(this.uExtends.w))),fn(0)))()}createGrid(t,i){let r=Math.ceil(t/this.gridSize),s=r*Math.ceil(i/this.gridSize),n=new wx(this.geometry,this.material,s);n.instanceMatrix.setUsage(an);let a=[];for(let l=0;l<s;l++){let h=l%r*this.gridSize,u=Math.floor(l/r)*this.gridSize,d=2/t*h-1,c=1-2/i*u;a.push(d,c,0)}let o=new cr(new Float32Array(a),3);return{instanced:n,iba:vl(o),positionAttribute:o}}updateGridPositions(t,i){if(!this.positionAttribute)return;let r=Math.ceil(t/this.gridSize),s=r*Math.ceil(i/this.gridSize);if(s!==this.positionAttribute.count){this.regenerateGrid(t,i);return}let n=this.positionAttribute.array;for(let a=0;a<s;a++){let o=a%r*this.gridSize,l=Math.floor(a/r)*this.gridSize,h=2/t*o-1,u=1-2/i*l;n[a*3]=h,n[a*3+1]=u,n[a*3+2]=0}this.positionAttribute.needsUpdate=!0,q.scheduleRender()}regenerateGrid(t,i){this.instanced&&(this.remove(this.instanced),this.instanced.geometry&&this.instanced.geometry.dispose());let{instanced:r,iba:s,positionAttribute:n}=this.createGrid(t,i);this.instanced=r,this.positionAttribute=n,this.updateShaderNodes(s),this.add(this.instanced),q.scheduleRender()}update=()=>{if(!(!this.visible||!this._dataMap.value))if(Mi.value=="screenshot")this.uOpacity.value=this.layer.opacity;else if(this.layer.isMoving){this.uOpacityMoving.value+=(0-this.uOpacityMoving.value)*.1;return}else if(this.layer.opacity<1&&this.layer.animationCompleted){this.uOpacityMoving.value+=(0-this.uOpacityMoving.value)*.1;return}else this.uOpacityMoving.value+=(1-this.uOpacityMoving.value)*.1};set dataMap(t){this._dataMap.value=t,q.scheduleRender()}setVisible(t){this.immediateVisible!=t&&(this.immediateVisible=t,t&&this.needsResize&&(this.uWidth.value=N.width,this.uHeight.value=N.height,this.uSize.value=this.gridSize/N.width,this.aspectRatio.value=N.width/N.height,this.updateGridPositions(N.width,N.height),this.needsResize=!1),Mi.value=="screenshot"?(this.uToggleOpacity.value=+!!t,this.visible=t):(Eu(this.uToggleOpacity),t&&(this.visible=t),Ql(this.uToggleOpacity,{value:+!!t,duration:.3,ease:"outQuad",onUpdate:()=>{q.scheduleRender()},onComplete:()=>{this.visible=t}})))}set opacity(t){this.uOpacity.value=t}get opacity(){return this.uOpacity.value}dispose(){this._disposed||(this._disposed=!0,N.onUpdate.remove(this.update),this.instanced&&(this.instanced.geometry&&this.instanced.geometry.dispose(),this.instanced.material&&this.instanced.material.dispose()),this.material&&=(this.material.dispose(),null),this.instanced=null,this.dataRT=null,this.uDataRT=null,this.uToggleOpacity=null,this.uOpacity=null,this.uTime=null,this.uBounds=null,this.uRelativeBounds=null,this.uNormalizeBounds=null,this.uResolution=null,this.uMode=null,this.parent=null)}},VS=new ge,Z5=new _d,zS,ate=class extends ei{static get type(){return"AfterImageNode"}constructor(e,t=.96){super("vec4"),this.textureNode=e,this.textureNodeOld=Fi(null),this.damp=Le(t),this._compRT=new zr(1,1,{depthBuffer:!1}),this._compRT.texture.name="AfterImageNode.comp",this._oldRT=new zr(1,1,{depthBuffer:!1}),this._oldRT.texture.name="AfterImageNode.old",this._textureNode=CH(this,this._compRT.texture),this.updateBeforeType=Re.FRAME}getTextureNode(){return this._textureNode}setSize(e,t){this._compRT.setSize(e,t),this._oldRT.setSize(e,t)}updateBefore(e){let{renderer:t}=e;zS=v0.resetRendererState(t,zS);let i=this.textureNode,r=i.value.type;this._compRT.texture.type=r,this._oldRT.texture.type=r,t.getDrawingBufferSize(VS),this.setSize(VS.x,VS.y);let s=i.value;this.textureNodeOld.value=this._oldRT.texture,Z5.material=this._materialComposed,t.setRenderTarget(this._compRT),Z5.render(t);let n=this._oldRT;this._oldRT=this._compRT,this._compRT=n,i.value=s,v0.restoreRendererState(t,zS)}setup(e){let t=this.textureNode,i=this.textureNodeOld;i.uvNode=t.uvNode||la();let r=Vt(()=>{let a=i.sample().toVar(),o=t.sample().toVar(),l=Be(.1).toConst(),h=kd(AH(a.sub(l)),0);
2108return a.mulAssign(this.damp.mul(h)),kd(o,a)}),s=this._materialComposed||=new Ot;s.name="AfterImage",s.fragmentNode=r();let n=e.getNodeProperties(this);return n.textureNode=t,this._textureNode}dispose(){this._compRT.dispose(),this._oldRT.dispose()}},ote=(e,t)=>wH(new ate(bH(e),t)),J5=new Un(1,1),lte=class l2 extends Gr{constructor(t,i=!1){super(),this.layer=t,this.isWater=i,this.visible=!1,this.immediateVisible=!1,this.needsResize=!1,this.pendingResize=null,this.init()}init(){let t=null;this.nodeMap=null,this.isWater?(t=l2.waterMap||=new Wo().load(hi("https://static5.mclcm.net/images/mc2020/bundles/map/particle-wave3.png")),this.nodeMap=Fi(t)):(t=l2.map||=new Wo().load(hi("https://static5.mclcm.net/images/mc2020/bundles/map/particle2.jpg")),this.nodeMap=Fi(t)),this.windowWidth=Le(N.width*N.devicePixelRatio),this.windowHeight=Le(N.height*N.devicePixelRatio),this._dataMap=Fi(t),this._colorMap=Fi(t),this.uOpacity=Le(0),this.uToggleOpacity=Le(1),this.uQuadOpacity=Le(.5),this.uExtends=Le(ai(0,0,1,1)),this.speed=Le(2),this.lastTime=performance.now(),this.postFxRT=new zr(N.width*N.devicePixelRatio,N.height*N.devicePixelRatio,{minFilter:mi,magFilter:mi,format:Br,samples:1,generateMipmaps:!1});let i=new Qn({transparent:!0,blending:2,depthWrite:!1}),r=this.isWater?40:25,s=Math.ceil(N.width/r),n=s*Math.ceil(N.height/r);this.instanced=new wx(J5,i,n),this.instanced.instanceMatrix.setUsage(an),this.instanced.scale.setScalar(.5);let a=w3(n,"vec3"),o=w3(n,"float"),l=Vt(()=>{let c=a.element(qi),p=c.xy.add(1).div(2).toVar();p.y=p.y.oneMinus();let m=this._dataMap.sample(p).rgb.toVar(),g=Gh(Be(m.b),0,1,-75,75).toVar(),f=Gh(Be(m.r),0,1,-75,75).toVar(),y=z0(M3(g.mul(g).add(f.mul(f))).toVar(),0,50/(N.devicePixelRatio===1?1:2),0,1).toVar(),x=O0(f,g).toVar();c.z.assign(x);let b=Gh(y,0,1,.1,2);c.x=c.x.add(I_(x).mul(this.speed.mul(.001).mul(b))),c.y=c.y.add(G0(x).mul(this.speed.mul(.001).mul(b)));
2108let _=o.element(qi),T=_.add(this.speed.mul(this.isWater?.003:.01)).toVar();Pd(T.greaterThan(1),()=>{c.x=ao(c.xy.add(jh).add(qi)).sub(.5).mul(2),c.y=ao(c.xy.add(jh.mul(2)).add(qi.mul(.7))).sub(.5).mul(2),_.x=ao(Je(jh,qi)).mul(.3)}).Else(()=>{_.x=T}),Pd(m.r.equal(0).and(m.g.equal(0)).and(m.b.equal(0)),()=>{c.x=ao(c.xy.add(jh).add(qi)).sub(.5).mul(2),c.y=ao(c.xy.add(jh.mul(2)).add(qi.mul(.7))).sub(.5).mul(2),_.x.assign(ao(Je(jh,qi)).mul(.2))})});this.computeNode=l().compute(n),this.computeNode.onInit(({renderer:c})=>{this.precompute=Vt(()=>{let p=Be(qi).mod(s).mul(r).toVar(),m=F_(Be(qi).div(s)).mul(r).toVar(),g=a.element(qi);g.x=p.mul(2/N.width).sub(1),g.y=Be(1).sub(m.mul(2/N.height)),o.element(qi).assign(ao(g.xy.add(Be(qi).mul(.1337))).mul(10));let f=g.xy.add(1).div(2).toVar();f.y=f.y.oneMinus();let y=this._dataMap.sample(f).rgb.toVar();Pd(y.r.equal(0).and(y.g.equal(0)).and(y.b.equal(0)),()=>{o.element(qi).assign(0)})}),c.computeAsync(this.precompute().compute(n))}),i.positionNode=Vt(()=>{let c=this.isWater?1.5:.5,p=a.element(qi),m=Be(1).div(this.windowWidth.div(16)).toVar("sizeX"),g=Be(1).div(this.windowHeight.div(16)).toVar("sizeY");return V0.mul(Je(m,g)).toVar("posGeometry").mul(1).mul(c).add(p).toVar("pos")})(),i.colorNode=Vt(()=>{let c=a.element(qi);return this.nodeMap.sample(EH(la(),c.z.negate().add(Math.PI/2))).rgb.toVar()})(),i.opacityNode=Vt(()=>{let c=this.nodeMap.sample(la()).a,p=o.element(qi).toVar("life"),m=z0(ao(Be(qi).mul(.123)),0,1,.15,.25).toVar("fadeInThreshold"),g=z0(ao(Be(qi).mul(.789)),0,1,.75,.85).toVar("fadeOutThreshold");return c.mul(O_(0,m,p).mul(O_(g,1,p).oneMinus())).toVar()})(),this.isFinish=!0,this.lastTime=performance.now(),this.postProcessing=new KW(q.renderer);let h=new Oc;h.add(this.instanced);let u=MH(h,q.camera);this.afterPass=ote(u.getTextureNode(),.99),this.postProcessing.outputNode=this.afterPass,this.add(this.renderQuad=new xt(J5,new Qn({side:1,map:this.postFxRT.texture,transparent:!0,opacity:0,depthWrite:!1})));let d=Fi(this.postFxRT.texture);this.renderQuad.rotation.x=Math.PI,this.renderQuad.material.colorNode=Vt(()=>{let c=la().toVar();return oa(c.x.lessThan(this.uExtends.x).or(c.y.lessThan(this.uExtends.y)).or(c.x.greaterThan(this.uExtends.z)).or(c.y.greaterThan(this.uExtends.w))),fn(0)})(),this.renderQuad.material.opacityNode=Vt(()=>d.sample(la()).r.mul(.8).mul(this.uQuadOpacity).mul(this.uOpacity).mul(this.uToggleOpacity))(),this.renderOrder=999996,this.resizeHandler=Al(()=>this.resize(),350),N.onUpdate.add(this.update),N.onResize.add(this.resizeHandler)}update=async()=>{if(!this.visible||!this.isFinish||!this.layer.visible||this.pendingResize||this.layer.opacity<=.01&&this.uQuadOpacity.value<=.01||this.parent&&!this.parent.visible)return;let t=performance.now(),i=t-this.lastTime;if(Mi.value=="screenshot")this.uQuadOpacity.value=this.layer.opacity;else if(this.layer.isMoving||!this.layer.animationCompleted||this.layer.opacity<1){if(this.uQuadOpacity.value+=(0-this.uQuadOpacity.value)*.1,this.afterPass&&(this.afterPass.damp.value=0),this.uQuadOpacity.value<.01)return}else this.uQuadOpacity.value+=(1-this.uQuadOpacity.value)*.1;if(this.speed.value=i/16.666,this.lastTime=t,this.isFinish=!1,await q.renderer.computeAsync(this.computeNode),q.renderer.setClearColor(0,0),q.renderer.setRenderTarget(this.postFxRT),this.postProcessing.render(),q.renderer.setRenderTarget(null),q.renderer.setClearColor(14540253,1),q.scheduleRender(),this.afterPass){let r=this.isWater?.98:.97;this.afterPass.damp.value=r**(i/16.666)}this.isFinish=!0};updateColorMap(t){this.visible}set dataMap(t){this._dataMap.value=t,q.scheduleRender()}set colorMap(t){this._colorMap.value=t,q.scheduleRender()}setVisible(t,i){this.immediateVisible!=t&&(this.visible&&this.reset(),this.immediateVisible=t,t&&this.needsResize&&this.resize(),Mi.value=="screenshot"?(this.uToggleOpacity.value=+!!t,this.visible=t,this.renderQuad.visible=t):(Eu(this.uToggleOpacity),t&&(this.visible=t,this.renderQuad.visible=t),Ql(this.uToggleOpacity,{value:+!!t,duration:.3,ease:"outQuad",onComplete:()=>{this.visible=t,this.renderQuad.visible=t}})))}set opacity(t){this.uOpacity.value!=t&&(this.uOpacity.value==0&&(this.afterPass&&(this.afterPass.damp.value=0),this.uQuadOpacity.value=0),this.uOpacity.value=t)}get opacity(){return this.uOpacity.value}resize=()=>{if(!this.immediateVisible){this.needsResize=!0;return}this.pendingResize={width:N.width*N.devicePixelRatio,height:N.height*N.devicePixelRatio},this.windowWidth.value=N.width,this.windowHeight.value=N.height,this.needsResize=!1,requestAnimationFrame(()=>{this.pendingResize&&=(this.postFxRT?.setSize(this.pendingResize.width,this.pendingResize.height),this.colorMapRT?.setSize(this.pendingResize.width,this.pendingResize.height),null)})};reset=async()=>{this.lastTime=performance.now(),this.isFinish=!0};dispose(){this._disposed||(this._disposed=!0,N.onUpdate.remove(this.update),N.onResize.remove(this.resizeHandler),this.instanced&&(this.instanced.geometry&&this.instanced.geometry.dispose(),this.instanced.material&&this.instanced.material.dispose()),this.postFxRT&&=(this.postFxRT.dispose(),null),this.renderQuad&&(this.renderQuad.geometry&&this.renderQuad.geometry.dispose(),this.renderQuad.material&&this.renderQuad.material.dispose()),this.instanced=null,this.renderQuad=null,this.parent=null,this.computeNode=null,this.postProcessMaterial=null,this.nodeMap=null)}};function hte(e,t=3,i=!1){if(e.length<2||t<=0)return e;let r=e;for(let s=0;s<t;s++){let n=[];i||n.push(r[0]);let a=i?r.length:r.length-1;for(let o=0;o<a;o++){let[l,h]=r[o],[u,d]=r[(o+1)%r.length];!i&&(o===0||o===r.length-2)?o===0?n.push([.25*l+.75*u,.25*h+.75*d]):n.push([.75*l+.25*u,.75*h+.25*d]):(n.push([.75*l+.25*u,.75*h+.25*d]),n.push([.25*l+.75*u,.25*h+.75*d]))}i||n.push(r[r.length-1]),r=n}return r}function Q5(e,t=1e4,i=!0){return(0,oI.default)(e.map(([r,s])=>({x:r,y:s})),t,i).map(({x:r,y:s})=>[r,s])}var eD=3e4,ute=2e6,lg=2*Math.PI*6378137,dte=120**2,tD=e=>Jd(e),cte=(e,t=2)=>hte(e,t,!1);function pte(e){let t=parseInt(e.slice(0,4),10),i=parseInt(e.slice(4,6),10)-1,r=parseInt(e.slice(6,8),10),s=parseInt(e.slice(8,10),10),n=parseInt(e.slice(10,12),10),a=new Date(t,i,r,s,n);return a.setTime(a.getTime()-360*60*1e3),`${a.getFullYear()}${String(a.getMonth()+1).padStart(2,"0")}${String(a.getDate()).padStart(2,"0")}${String(a.getHours()).padStart(2,"0")}${String(a.getMinutes()).padStart(2,"0")}`}function mte(e,t){let i=gte(Q5(e.map(tD),eD,!0));for(let r=0;r<i.length;r++){let s=i[r];ym.value>0?t.push(fm(cte(s,ym.value))):t.push(fm(s))}}function gte(e,t=ute){let i=[],r=[e[0]],[s,n]=e[0];
2108return e.slice(1).forEach(([a,o])=>{(Math.abs(a-s)>t||Math.abs(o-n)>t)&&(r.length>1&&i.push([...r]),r.length=0),r.push([a,o]),s=a,n=o}),r.length>1&&i.push(r),i}function iD(e,t){let i=[];for(let r of e)for(let s=-t;s<=t;s++){if(s===0){i.push(r);continue}let n=s*lg,a=new Float32Array(r.length);for(let o=0;o<r.length;o+=3)a[o]=r[o]+n,a[o+1]=r[o+1],a[o+2]=r[o+2];i.push(a)}return i}function fte(e,t){let i=Q5(t.map(tD),eD,!0).map(([s,n])=>({x:s,y:n})),r=document.createElement("div");return r.textContent=e,r.style.position="absolute",r.style.transform="translate(-50%,-50%)",r.style.color="#040487",r.style.fontSize="10px",r.style.fontWeight="700",r.style.textShadow=`
2109		-0.5px -0.5px #FFF,
2110		0.5px -0.5px #FFF,
2111		-0.5px 0.5px #FFF,
2112		0.5px 0.5px #FFF
2113	`,r.style.fontFamily='"Helvetica Neue", Arial, Helvetica, sans-serif',{div:r,coords:i.map(({x:s,y:n})=>[s,n])}}function yte(e,t,i,r,s,n,a){let o=[],{minX:l,minY:h,maxX:u,maxY:d}=a;e.forEach(({div:c,value:p,coords:m})=>{let g=!1;for(let f=0;f<m.length&&!g;f++){let[y,x]=m[f];if(y+=Math.round((i-y)/lg)*lg,y<i||y>s||x<r||x>n)continue;let[b,_]=QT([y,x]),[T,w]=t.getPixelFromCoordinate([b,_]);T<l||T>u||w<h||w>d||o.some(([M,S,R])=>R===p&&(M-T)**2+(S-w)**2<dte)||(c.style.transform=`translate(${T}px, ${w}px) translate(-50%, -50%)`,c.style.display="block",o.push([T,w,p]),g=!0)}g||(c.style.display="none")})}function xte(e){let{type:t,value:i}=e,r=t,s=i==null?"":String(i),n=document.createElement("div");n.className="extremum-position",n.style.position="absolute",n.style.transform="translate(-50%, -50%)",n.style.display="none",n.style.pointerEvents="none",n.style.zIndex="10";let a=document.createElement("div");a.className="extremum-marker",a.style.width="48px",a.style.height="48px",a.style.borderRadius="50%",a.style.display="flex",a.style.flexDirection="column",a.style.alignItems="center",a.style.justifyContent="center",a.style.fontFamily='"Helvetica Neue", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif',a.style.fontWeight="700",a.style.lineHeight="1",a.style.transition="all 0.3s cubic-bezier(0.4, 0, 0.2, 1)",a.style.transformOrigin="center center",t==="A"?(a.style.background="linear-gradient(135deg, #ff6b6b 0%, #d32f2f 100%)",a.style.border="2px solid #fff",a.style.boxShadow=`
2114			0 4px 12px rgba(211, 47, 47, 0.3),
2115			0 2px 4px rgba(0, 0, 0, 0.1),
2116			inset 0 1px 2px rgba(255, 255, 255, 0.3)
2117		`):(a.style.background="linear-gradient(135deg, #42a5f5 0%, #1565c0 100%)",a.style.border="2px solid #fff",a.style.boxShadow=`
2118			0 4px 12px rgba(21, 101, 192, 0.3),
2119			0 2px 4px rgba(0, 0, 0, 0.1),
2120			inset 0 1px 2px rgba(255, 255, 255, 0.3)
2121		`);let o=document.createElement("div");o.style.display="flex",o.style.flexDirection="column",o.style.alignItems="center",o.style.gap="2px";let l=document.createElement("div");l.textContent=r,l.style.fontSize="18px",l.style.fontWeight="800",l.style.color="#ffffff",l.style.textShadow="0 1px 2px rgba(0, 0, 0, 0.2)",l.style.letterSpacing="-0.5px";let h=document.createElement("div");return h.textContent=s,h.style.fontSize="10px",h.style.fontWeight="600",h.style.color="rgba(255, 255, 255, 0.95)",h.style.textShadow="0 1px 2px rgba(0, 0, 0, 0.2)",o.appendChild(l),o.appendChild(h),a.appendChild(o),n.appendChild(a),n}function vte(e,t,i,r,s,n,a,o,l){if(e.length===0)return;let h=t.getView().getZoom(),u=1;h>=2&&h<=6?u=.4+(h-2)*.15:h<2&&(u=.4);let{minX:d,minY:c,maxX:p,maxY:m}=a;e.forEach(({div:g,lat:f,lon:y,type:x,value:b})=>{if(l){let[_,T]=Jd([y,f]);if(_+=Math.round((i-_)/lg)*lg,_>=i&&_<=s&&T>=r&&T<=n){let[w,M]=QT([_,T]),[S,R]=t.getPixelFromCoordinate([w,M]);S>=d&&S<=p&&R>=c&&R<=m?(g.style.transform=`translate(${S}px, ${R}px) translate(-50%, -50%) scale(${u})`,g.style.display="block",g.style.opacity=o):g.style.display="none"}else g.style.display="none"}else g.style.display="none"})}var bte=class extends Gr{json=null;state="idle";lastFailedUrl=null;renderOrder=999995;#n=new Map;#o=new Map;#u=new Map;#l=new Map;#s=null;#p=null;#m=new Map;_lastFrameState=null;_postRenderKey=null;uOpacity=Le(0);uToggleOpacity=Le(0);uExtends=Le(ai(0,0,1,1));uBlur=0;#e=null;#t=null;#i=null;#r=null;#d=[];#c=[];#v=1;#b=1;#g=null;#f=null;#h=[];#a=Object.assign(document.createElement("div"),{className:"isobar-labels",style:"position:absolute;top:0;left:0;width:100%;height:100%;pointer-events:none;font:11px/1 monospace;color:#fff;text-shadow:0 0 2px #000"});#_=[];#y=null;constructor(e){super(),this.layer=e,this.visible=!1,this.immediateVisible=!1,this.needsResize=!1,this.watchers=Wm();let t=this.layer.provider.value.model.name;this.watchers.add(this.layer.provider,()=>{setTimeout(()=>{if(!this.layer.provider.value)return;let i=this.layer.provider.value.model.name;["monde_ens_marine","monde_cams","europe_cams"].includes(i)&&(i="monde_ens_mc"),t!==i&&(t=i,this.reset(),this.visible&&this.loadJson())},1)}),this.reset(),this.watchers.add(lu,()=>{this.#e&&(this.#e.material.lineWidth.value=lu.value),this.#i&&(this.#i.material.lineWidth.value=lu.value)}),this.watchers.add(hu,()=>{this.#t&&(this.#t.material.lineWidth.value=hu.value),this.#r&&(this.#r.material.lineWidth.value=hu.value)}),this.watchers.add(xm,()=>{this.#e?.material?.color&&(this.#e.material.color.value.set(xm.value),q.scheduleRender())}),this.watchers.add(vm,()=>{this.#t?.material?.color&&(this.#t.material.color.value.set(vm.value),q.scheduleRender())}),this.watchers.add(uu,()=>{this.#e?.material&&(this.#e.material.gradient?this.#e.material.gradient.value?this.#e.material.gradient.value.set(uu.value):this.#e.material.gradient.value=new Ke(uu.value):this.#e.material.gradient=Le(new Ke(uu.value)),q.scheduleRender())}),this.watchers.add(du,()=>{this.#t?.material&&(this.#t.material.gradient?this.#t.material.gradient.value?this.#t.material.gradient.value.set(du.value):this.#t.material.gradient.value=new Ke(du.value):this.#t.material.gradient=Le(new Ke(du.value)),q.scheduleRender())}),this.watchers.add(ym,()=>{this.state!="loading"&&this.json&&(this.reset(),this.visible&&this.loadJson())}),this.layer.currentForecastDate&&this.watchers.add(this.layer.currentForecastDate,i=>{this.visible&&i&&i.date_model_run&&i.date_ech&&(this.state==="idle"||this.state==="error")&&(this.json=null,this.state="idle",this.loadJson())}
2121),N.onUpdate.add(this.update),N.onResize.add(this.resize)}resize=()=>{if(!this.immediateVisible){this.needsResize=!0;return}this.#e?.resize(N.width,N.height),this.#t?.resize(N.width,N.height),this.#i?.resize(N.width,N.height),this.#r?.resize(N.width,N.height),this.needsResize=!1};reset(){this.json=null,this.state="idle",this.lastFailedUrl=null,this.remove(this.#e,this.#t,this.#i,this.#r),this.#e?.dispose(),this.#t?.dispose(),this.#i?.dispose(),this.#r?.dispose(),this.#a.innerHTML="",this.#_.length=0,this.#d.length=0,this.#c.length=0,this.#i=new Ll().lineWidth(lu.value).transparent(!0).color(2852390023).sizeAttenuation(!1).renderSize(N.width,N.height).build(),this.#r=new Ll().lineWidth(hu.value).transparent(!0).color(2852390023).sizeAttenuation(!1).renderSize(N.width,N.height).build(),this.#e=new Ll().lineWidth(lu.value).transparent(!0).color(xm.value).gradientColor(uu.value).sizeAttenuation(!1).renderSize(N.width,N.height).build(),this.#t=new Ll().lineWidth(hu.value).transparent(!0).color(vm.value).gradientColor(du.value).sizeAttenuation(!1).renderSize(N.width,N.height).build(),this.#e.material.opacity=this.uOpacity.mul(this.uToggleOpacity).mul(Uy.value),this.#t.material.opacity=this.uOpacity.mul(this.uToggleOpacity).mul(Vy.value),this.#i.material.opacity=this.uOpacity.mul(this.uToggleOpacity).mul(Fs?.9:Uy.value),this.#r.material.opacity=this.uOpacity.mul(this.uToggleOpacity).mul(Fs?.9:Vy.value);let e=Vt(()=>Ms.x.lessThan(this.uExtends.x).or(Ms.y.lessThan(this.uExtends.y)).or(Ms.x.greaterThan(this.uExtends.z)).or(Ms.y.greaterThan(this.uExtends.w)))();this.#t.material.discardConditionNode=this.#e.material.discardConditionNode=e,this.#r.material.discardConditionNode=this.#i.material.discardConditionNode=e,this.#i.renderOrder=this.renderOrder+1,this.#r.renderOrder=this.renderOrder+1,this.#e.renderOrder=this.renderOrder,this.#t.renderOrder=this.renderOrder,this.#e.material.depthTest=!1,this.#t.material.depthTest=!1,this.#i.material.depthTest=!1,this.#r.material.depthTest=!1,this.#h.forEach(({div:t})=>{t.parentNode&&t.parentNode.removeChild(t)}),this.#h.length=0}update=()=>{let e=this.layer.openLayerMap;if(!e)return;this._postRenderKey||=e.on("postrender",m=>{this._lastFrameState=m.frameState});let t=!1;this.#y||(this.#y=e.getViewport(),this.#y.style.position||="relative",this.#y.append(this.#a),t=!0);let i;i=this._lastFrameState?.extent?this._lastFrameState.extent:Ns(e.getView().calculateExtent(e.getSize()),"EPSG:4326","EPSG:3857");let[r,s,n,a]=i,o=1/(n-r),l=1/(a-s);(this.scale.x!==o||this.scale.y!==l)&&(this.scale.set(o,l,1),this.#v=o,this.#b=l,this.#T(),t=!0);let h=-r*o-.5,u=-s*l-.5;if((Math.abs(this.position.x-h)>.001||Math.abs(this.position.y-u)>.001)&&(this.position.set(h,u,0),t=!0),this.visible&&!this.json&&this.state==="idle"){this.loadJson();return}if(!this.visible||!this.json&&this.state!=="loading")return;t=!0;let d=this.layer.animationCompleted&&this.layer.opacity===1?1:0,c=this.uOpacity.value,p=d-this.uOpacity.value;if(Math.abs(p)>.001&&(this.uOpacity.value+=p*.1,t=!0),Math.abs(this.uOpacity.value-c)>.001&&(t=!0),this.#h.length>0){let m=this.uOpacity.value*this.uToggleOpacity.value,g=this.visible&&m>.5,f={minX:this.uExtends.value.x*N.width,minY:this.uExtends.value.y*N.height,maxX:this.uExtends.value.z*N.width,maxY:this.uExtends.value.w*N.height};vte(this.#h,e,r,s,n,a,f,m,g)}if(this.visible&&this.uOpacity.value>.99&&this.uToggleOpacity.value>.99){this.#a.style.display!=="block"&&(this.#a.style.display="block",t=!0);let m={minX:this.uExtends.value.x*N.width,minY:this.uExtends.value.y*N.height,maxX:this.uExtends.value.z*N.width,maxY:this.uExtends.value.w*N.height};yte(this.#_,e,r,s,n,a,m)}else this.#a.style.display!=="none"&&(this.#a.style.display="none",t=!0);t&&q.scheduleRender()};async loadJson(){if(!this.visible||!this.layer.currentForecastDate.value)return;let{date_model_run:e,date_ech:t}=this.layer.currentForecastDate.value||{},i=this.layer.provider.value.model.name,r=this.layer.data?.name==="frontologie",s=["monde_ens_marine","monde_cams","europe_cams"],n=e;if(r){let u=V_.models.find(d=>d.name==="monde_gfs__brut");if(u){if(!u.jsonLoaded)if(this.#m.has("monde_gfs__brut"))await this.#m.get("monde_gfs__brut");else{let d=u.loadExtraData().finally(()=>{this.#m.delete("monde_gfs__brut")});this.#m.set("monde_gfs__brut",d),await d}if(u.forecastDates&&Array.isArray(u.forecastDates)){let d=u.forecastDates.find(c=>c.date_ech===t);d&&(n=d.date_model_run)}}i="monde_gfs__brut"}else s.includes(i)&&(i="monde_ens__mc",n=pte(e));let a=this.layer.data.getBaseUrl(n,t,i,"prmsl"),o=hi(`${a}isobare.json`),l=hi(`${a}extremums.json`);if(this.lastFailedUrl===o||this.#s===o&&this.json)return;if(this.#u.has(o)){let u=this.#u.get(o);this.buildMeshes(u),q.scheduleRender(),this.json=u,this.state="idle",this.#s=o,this.#w(l);return}if(this.#n.has(o)){this.#n.get(o).then(u=>{this.buildMeshes(u),q.scheduleRender(),this.json=u,this.state="idle",this.#s=o,this.#w(l)}).catch(u=>{console.warn("[Isobars] Failed to load (from pending):",o,u.message),this.state="error",this.lastFailedUrl=o});return}this.state="loading",Bi.value++;let h=fetch(o).then(u=>{if(!u.ok)throw Error(`HTTP ${u.status}: ${u.statusText}`);return u.json()}).then(u=>(this.#u.set(o,u),this.#s=o,this.lastFailedUrl=null,u)).catch(u=>{throw console.warn("[Isobars] Failed to load:",o,u.message),this.state="error",this.lastFailedUrl=o,u}).finally(()=>{this.#n.delete(o),setTimeout(()=>{Bi.value--},32)}
2121);this.#n.set(o,h),h.then(u=>{this.buildMeshes(u),q.scheduleRender(),this.json=u,this.state="idle",this.#w(l)}).catch(()=>{})}buildMeshes(e){Array.from({length:30},(i,r)=>945+r*5).forEach(i=>{let r=i===1015?this.#d:this.#c,s=e[`${i}.0`]??[],n=i%15==0||i===1015;s.forEach(a=>{if(mte(a,r),!n)return;let{div:o,coords:l}=fte(i,a);this.#a.append(o),this.#_.push({div:o,value:i,coords:l})})}),this.#M();let t=[];this.#i&&t.push(this.#i),this.#r&&t.push(this.#r),this.#e&&t.push(this.#e),this.#t&&t.push(this.#t),this.add(...t)}#M(){if(this.#d.length>0){let e=iD(this.#d,ou.value);this.#g=e,this.#e.geometry.setLines(e),this.#T(),this.#x(this.#e,this.#d),this.#i&&this.#x(this.#i,this.#d)}if(this.#c.length>0){let e=iD(this.#c,ou.value);this.#f=e,this.#t.geometry.setLines(e),this.#T(),this.#x(this.#t,this.#c),this.#r&&this.#x(this.#r,this.#c)}this.#d.length=0,this.#c.length=0}#T(){if(!this.#i&&!this.#r||!this.#g&&!this.#f)return;let e=this.#v>0?this.#v:this.scale.x||1,t=this.#b>0?this.#b:this.scale.y||1,i=(r,s)=>{if(r.length<6)return r;let n=new Float32Array(r.length),a=s/N.width/e,o=s/N.height/t,l=Math.max(a,o);n[0]=r[0],n[1]=r[1],n[2]=r[2];for(let u=3;u<r.length-3;u+=3){let d=r[u-3],c=r[u-2],p=r[u],m=r[u+1],g=r[u+3],f=r[u+4],y=p-d,x=m-c,b=g-p,_=f-m,T=(y+b)*.5,w=(x+_)*.5,M=Math.sqrt(T*T+w*w);if(M>1e-4){let S=-w/M,R=T/M;n[u]=p+S*l,n[u+1]=m+R*l,n[u+2]=r[u+2]}else n[u]=p,n[u+1]=m,n[u+2]=r[u+2]}let h=r.length-3;return n[h]=r[h],n[h+1]=r[h+1],n[h+2]=r[h+2],n};if(this.#i&&this.#g){let r=this.#g.map(s=>i(s,1.5));this.#i.geometry.setLines(r)}if(this.#r&&this.#f){let r=this.#f.map(s=>i(s,1.5));this.#r.geometry.setLines(r)}}#x(e,t){e.geometry.boundingBox||(e.geometry.boundingBox=new Fn),e.geometry.boundingBox.makeEmpty();for(let i of t)for(let r=0;r<i.length;r+=3)e.geometry.boundingBox.expandByPoint({x:i[r],y:i[r+1],z:i[r+2]});e.geometry.boundingSphere||(e.geometry.boundingSphere=new ja),e.geometry.boundingBox.getBoundingSphere(e.geometry.boundingSphere)}setVisible(e){if(this.immediateVisible===e)return;this.immediateVisible=e,e&&this.needsResize&&this.resize();let t=()=>{this.visible=e,e||(this.#a.style.display="none")};!Mi.value||Mi.value!=="screenshot"?(e&&(this.visible=!0),Eu(this.uToggleOpacity),Ql(this.uToggleOpacity,{value:+!!e,duration:.1,ease:"outQuad",onUpdate:()=>q.scheduleRender(),onComplete:t})):(this.#e.material.lineWidth.value=4,this.#t.material.lineWidth.value=3,this.#i&&(this.#i.material.lineWidth.value=5),this.#r&&(this.#r.material.lineWidth.value=4),this.uToggleOpacity.value=+!!e,t())}set dataMap(e){}set opacity(e){}get opacity(){return 1}dispose(){if(!this._disposed){for(this._disposed=!0,this.watchers.dispose(),this._postRenderKey&&=(Qd(this._postRenderKey),null),this._lastFrameState=null,N.onUpdate.remove(this.update),N.onResize.remove(this.resize),this.#a?.parentNode&&this.#a.parentNode.removeChild(this.#a);this.children.length>0;)this.remove(this.children[0]);this.#e?.dispose(),this.#t?.dispose(),this.#i?.dispose(),this.#r?.dispose(),this.#h.forEach(({div:e})=>{e.parentNode&&e.parentNode.removeChild(e)}),this.#h.length=0,this.#n.clear(),this.#o.clear(),this.#u.clear(),this.#l.clear(),this.#m.clear(),this.#s=null,this.#p=null}}#w(e){if(this.#p===e&&this.#h.length>0)return;if(this.#l.has(e)){let i=this.#l.get(e);this.#S(i),this.#p=e;return}if(this.#o.has(e)){this.#o.get(e).then(i=>{this.#S(i),this.#p=e}).catch(i=>{console.error("[Isobars] Failed to load extremums (from pending):",e,i)});return}let t=fetch(e).then(i=>{if(!i.ok)throw Error(`HTTP ${i.status}: ${i.statusText}`);return i.json()}).then(i=>(this.#l.set(e,i),this.#p=e,i)).catch(i=>{throw console.error("[Isobars] extremums.json:",i),i}).finally(()=>{this.#o.delete(e)});this.#o.set(e,t),t.then(i=>{this.#S(i)}).catch(()=>{})}#S(e){this.#h.forEach(({div:t})=>{t.parentNode&&t.parentNode.removeChild(t)}),this.#h.length=0,e.forEach(t=>{let i=xte(t);i&&(this.#a.append(i),this.#h.push({div:i,lat:parseFloat(t.lat),lon:parseFloat(t.lon),type:t.type,value:t.value}))}),q.scheduleRender()}},rD=class extends u4{constructor(e=64,t=256){let i=document.createElement("canvas");i.width=e,i.height=t,super(i),this.ctx=i.getContext("2d",{alpha:!0}),this.ctx.clearRect(0,0,e,t),this.canvas=i,this.anisotropy=1,this.generateMipmaps=!1,this.colorSpace
2121="",this._disposed=!1}debug(){this.canvas.style.position="absolute",this.canvas.style.top="0px",this.canvas.style.left="0px",this.canvas.style.zIndex="10000000",console.log(this.pos),document.body.append(this.canvas)}updateGradient(e,t,i="linear",r=null){if(this._disposed){console.warn("GradientTexture is disposed, cannot update gradient.");return}this.colorSpace=Gi;let s=this.ctx,n=this.canvas.height,a=s.createLinearGradient(0,0,0,n),o=Math.max(...t),l=Math.min(...t),h=o-l,u=t.map(d=>(d-l)/h);r&&(u=r.map(d=>(d-0)/255)),this.pos=[],e.forEach((d,c)=>{let p=0;p=i=="linear"?c/e.length:u[c],this.pos.push(p),a.addColorStop(FQ(p),d)}),s.fillStyle=a,s.fillRect(0,0,this.canvas.width,n),this.needsUpdate=!0}dispose(){this._disposed||(this._disposed=!0,super.dispose(),this.canvas&&=(this.canvas.parentNode&&this.canvas.parentNode.removeChild(this.canvas),this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height),this.ctx=null,null),this.pos=null)}},jt=new class{constructor(){this.conversions={temperature:{"\xB0c":{symbol:"\xB0C",toBase:e=>e,fromBase:e=>e},"\xB0f":{symbol:"\xB0F",toBase:e=>(e-32)*5/9,fromBase:e=>e*9/5+32}},speed:{"km/h":{symbol:"km/h",toBase:e=>e,fromBase:e=>e},nd:{symbol:"nd",toBase:e=>e*1.852,fromBase:e=>e/1.852},"m/s":{symbol:"m/s",toBase:e=>e*3.6,fromBase:e=>e/3.6}
2121,mph:{symbol:"MPH",toBase:e=>e*1.60934,fromBase:e=>e/1.60934},bft:{symbol:"Bft",toBase:e=>this.beaufortToKmh(e),fromBase:e=>this.kmhToBeaufort(e)}},precipitation:{mm:{symbol:"mm",toBase:e=>e,fromBase:e=>e},cm:{symbol:"cm",toBase:e=>e,fromBase:e=>e}},radar:{"mm/h":{symbol:"mm/h",toBase:e=>e,fromBase:e=>e},"cm/h":{symbol:"cm/h",toBase:e=>e,fromBase:e=>e}},pressure:{hpa:{symbol:"hPa",toBase:e=>e,fromBase:e=>e}},distance:{km:{symbol:"km",toBase:e=>e,fromBase:e=>e},mi:{symbol:"mi",toBase:e=>e*1.60934,fromBase:e=>e/1.60934}},height:{m:{symbol:"m",toBase:e=>e,fromBase:e=>e},ft:{symbol:"ft",toBase:e=>e*.3048,fromBase:e=>e/.3048}},roundvalue:{"":{symbol:"",toBase:e=>e,fromBase:e=>e}}},this.parameterMap={t2m:"temperature",tres:"temperature",tsol:"temperature",tmer:"temperature",vent_kmh:"speed",rafale:"speed",wind:"speed",windspeed:"speed",precip:"precipitation",radar:"radar",cumul_precip_hloc:"precipitation",pression:"pressure",pressure:"pressure",prmsl:"pressure",houle_cm:"height",vague_cm:"height",mervent_cm:"height",vaguemax_cm:"height",ht0:"height",visi:"distance",atmo:"roundvalue",aqi:"roundvalue",caqi:"roundvalue",co:"roundvalue",no2:"roundvalue",o3:"roundvalue",so2:"roundvalue",pm25:"roundvalue",pm10:"roundvalue"},this.defaultUnits={temperature:"\xB0c",speed:"km/h",precipitation:"mm",pressure:"hpa",distance:"km",height:"m",roundvalue:""},this.preferences={...this.defaultUnits},this.normalizations={kmh:"km/h",kph:"km/h",knots:"nd",kt:"nd",kts:"nd",ms:"m/s",beaufort:"bft",celsius:"\xB0c",fahrenheit:"\xB0f",c:"\xB0c",f:"\xB0f",hPa:"hpa",miles:"mi",feet:"ft",meters:"m"},this.beaufortScale=[2,6,12,20,29,39,50,62,75,89,103,118,134,150,167,184]}beaufortToKmh(e){let t=Math.min(Math.max(0,Math.round(e)),16);return t===0?0:this.beaufortScale[t-1]}kmhToBeaufort(e){if(e<2)return 0;for(let t=0;t<this.beaufortScale.length;t++)if(e<this.beaufortScale[t])return t+1;return 16}normalizeUnit(e){if(!e)return e;let t=e.toLowerCase();return this.normalizations[t]||t}detectUnitType(e){let t=this.normalizeUnit(e);for(let[i,r]of Object.entries(this.conversions))if(t in r)return i;for(let[i,r]of Object.entries({speed:/m\/s|km\/h|mph|nd|bft/,temperature:/°|celsius|fahrenheit/,precipitation:/mm|cm/,radar:/(mm|cm)\/h/,pressure:/hpa|mb/,distance:/km|mi/,height:/^(m|ft)$/}))if(r.test(e))return i;return null}convert(e,t,i,r=null){if(e==null||isNaN(e)||(t=this.normalizeUnit(t),i=this.normalizeUnit(i),t===i))return e;if(r||=this.detectUnitType(t),!r)return console.warn(`Cannot detect unit type for: ${t}`),e;let s=this.conversions[r];s?.[t]||(t=this.defaultUnits[r]),r==="radar"&&t===void 0&&(t="mm/h");let n=s[t].toBase(e);return s[i].fromBase(n)}getUnitTypeForParameter(e){let t=e?.toLowerCase().replace(/[_-]/g,"");return this.parameterMap[t]||this.parameterMap[e]||null}setPreferences(e){this.preferences={...this.preferences,...e}}getPreferredUnit(e){return this.preferences[e]||this.defaultUnits[e]}getDefaultUnit(e){return this.defaultUnits[e]}convertToPreferred(e,t,i){let r=this.normalizeUnit(t),s=this.getUnitTypeForParameter(i)||this.detectUnitType(r);if(!s)return{value:e,unit:t};let n=this.getPreferredUnit(s);return{value:this.convert(e,r,n,s),unit:n,symbol:this.getUnitSymbol(n,s)}}getUnitSymbol(e,t){return t||=this.detectUnitType(e),this.conversions[t]?.[e]?.symbol||e}formatValue(e,t){return e==null||isNaN(e)?t==="precipitation"||t==="radar"||t==="temperature"||t==="speed"?"0.0":t==="pressure"||t==="roundvalue"?"0":"0.0":t==="speed"&&this.getPreferredUnit("speed")==="bft"?Math.round(e).toString():e===0?t==="precipitation"||t==="radar"||t==="temperature"||t==="speed"?"0.0":t==="pressure"||t==="roundvalue"?"0":"0.0":e.toFixed(t==="temperature"?1:t==="speed"?+(e<10):t==="precipitation"||t==="radar"?e<1?2:+(e<10):t==="pressure"?0:t==="distance"?e<1?2:+(e<10):t==="height"?+(e<100):t==="roundvalue"?0:1)}getAvailableUnits(e){return Object.keys(this.conversions[e]||{})}},_te="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/58BAQUBAKgBTk0AAAAASUVORK5CYII=",sD=new Image;sD.src=_te;var nD=new Li(sD),Tte=class extends Qn{constructor(e){super({transparent:!0,depthWrite:!1,opacity:0}
2121),this.layer=e,this.options=e.data.colorOptions,this.useGradient=this.layer.data.legends?this.options.useGradient:!1,this.useGradient&&this.updateGradient(),this.uTxtFrom=Fi(nD),this.uTxtTo=Fi(nD),this.uPercent=Le(1),this.uExtends=Le(ai(0,0,1,1)),this.uBlur=Le(this.options.blur/N.width),this.uIsPanning=Le(0),this.watchers=Wm(),this.watchers.add(this.layer.percent,t=>{this.uPercent.value=this.layer.percent.value}),this.update()}getLegendForRender=()=>{let e=this.layer?.data?.legends;if(!Array.isArray(e)||e.length===0)return null;let t=e[this.options.legendIndex||0];if(!t)return null;try{let i=(this.layer?.data?.name||"").toLowerCase(),r=jt.getUnitTypeForParameter(i),s={"%":12,"mm/h":19,mm:9,"cm/h":26,cm:10,"\xB0c":17,"km/h":1,m:6,km:25,hpa:14,"\xB5g/m3":20}[jt.getDefaultUnit(r)||jt.getPreferredUnit(r)];if(s!=null){let n=t?.type?.id,a=$h.legends?.find(o=>o?.type?.id===n&&o?.unit?.id===s);a?.values?.length&&a?.hexColors?.length&&(t=a)}}catch{}return t};update=()=>{this.colorNode=this.colorNodeFn(),this.updateBlendMode(),this.needsUpdate=!0};colorNodeFn=Vt(()=>{let e=null,t=null,i=la().flipY().toVar(),r=this.uBlur.toVar();oa(i.x.lessThan(this.uExtends.x.add(r)).or(i.y.lessThan(this.uExtends.y.add(r))).or(i.x.greaterThan(this.uExtends.z.sub(r))).or(i.y.greaterThan(this.uExtends.w.sub(r))));let s=(()=>{let a=new URLSearchParams(window.location.search),o=a.get("blur");return o==="none"?"none":o==="kawase"?"kawase":o==="dynamic"?"dynamic":o==="box"?"box":o==="tent"?"tent":o==="gaussian"?"gaussian":o==="poisson"?"poisson":o==="circular"?"circular":o==="bilinear"?"bilinear":a.has("noblur")?"none":"poisson"})();if(this.options.blur!==void 0&&s!=="none"){let a=(o,l,h)=>o.sample(i.add(Je(r.mul(l),r.mul(h)))).level(Be(0));if(s==="kawase"){let o=Be(.2),l=Be(.1),h=Be(.05),u=Be(.05);e=a(this.uTxtFrom,0,0).mul(o).add(a(this.uTxtFrom,0,-1.5).mul(l)).add(a(this.uTxtFrom,1.5,0).mul(l)).add(a(this.uTxtFrom,0,1.5).mul(l)).add(a(this.uTxtFrom,-1.5,0).mul(l)).add(a(this.uTxtFrom,-1,-1).mul(h)).add(a(this.uTxtFrom,1,-1).mul(h)).add(a(this.uTxtFrom,1,1).mul(h)).add(a(this.uTxtFrom,-1,1).mul(h)).add(a(this.uTxtFrom,0,-2.5).mul(u)).add(a(this.uTxtFrom,2.5,0).mul(u)).add(a(this.uTxtFrom,0,2.5).mul(u)).add(a(this.uTxtFrom,-2.5,0).mul(u)).toVar("fromTxt"),t=a(this.uTxtTo,0,0).mul(o).add(a(this.uTxtTo,0,-1.5).mul(l)).add(a(this.uTxtTo,1.5,0).mul(l)).add(a(this.uTxtTo,0,1.5).mul(l)).add(a(this.uTxtTo,-1.5,0).mul(l)).add(a(this.uTxtTo,-1,-1).mul(h)).add(a(this.uTxtTo,1,-1).mul(h)).add(a(this.uTxtTo,1,1).mul(h)).add(a(this.uTxtTo,-1,1).mul(h)).add(a(this.uTxtTo,0,-2.5).mul(u)).add(a(this.uTxtTo,2.5,0).mul(u)).add(a(this.uTxtTo,0,2.5).mul(u)).add(a(this.uTxtTo,-2.5,0).mul(u)).toVar("toTxt")}else if(s==="box")e=a(this.uTxtFrom,0,0).mul(.2).add(a(this.uTxtFrom,-1,0).mul(.2)).add(a(this.uTxtFrom,1,0).mul(.2)).add(a(this.uTxtFrom,0,-1).mul(.2)).add(a(this.uTxtFrom,0,1).mul(.2)).toVar("fromTxt"),t=a(this.uTxtTo,0,0).mul(.2).add(a(this.uTxtTo,-1,0).mul(.2)).add(a(this.uTxtTo,1,0).mul(.2)).add(a(this.uTxtTo,0,-1).mul(.2)).add(a(this.uTxtTo,0,1).mul(.2)).toVar("toTxt");else if(s==="tent"){let o=Be(.25),l=Be(2/16),h=Be(1/16);e=a(this.uTxtFrom,0,0).mul(o).add(a(this.uTxtFrom,-1,0).mul(l)).add(a(this.uTxtFrom,1,0).mul(l)).add(a(this.uTxtFrom,0,-1).mul(l)).add(a(this.uTxtFrom,0,1).mul(l)).add(a(this.uTxtFrom,-1,-1).mul(h)).add(a(this.uTxtFrom,1,-1).mul(h)).add(a(this.uTxtFrom,-1,1).mul(h)).add(a(this.uTxtFrom,1,1).mul(h)).toVar("fromTxt"),t=a(this.uTxtTo,0,0).mul(o).add(a(this.uTxtTo,-1,0).mul(l)).add(a(this.uTxtTo,1,0).mul(l)).add(a(this.uTxtTo,0,-1).mul(l)).add(a(this.uTxtTo,0,1).mul(l)).add(a(this.uTxtTo,-1,-1).mul(h)).add(a(this.uTxtTo,1,-1).mul(h)).add(a(this.uTxtTo,-1,1).mul(h)).add(a(this.uTxtTo,1,1).mul(h)).toVar("toTxt")}else if(s==="gaussian"){let o=Be(.25),l=Be(.125),h=Be(.0625);e=a(this.uTxtFrom,0,0).mul(o).add(a(this.uTxtFrom,-1,0).mul(l)).add(a(this.uTxtFrom,1,0).mul(l)).add(a(this.uTxtFrom,0,-1).mul(l)).add(a(this.uTxtFrom,0,1).mul(l)).add(a(this.uTxtFrom,-1,-1).mul(h)).add(a(this.uTxtFrom,1,-1).mul(h)).add(a(this.uTxtFrom,-1,1).mul(h)).add(a(this.uTxtFrom,1,1).mul(h)).toVar("fromTxt"),t=a(this.uTxtTo,0,0).mul(o).add(a(this.uTxtTo,-1,0).mul(l)).add(a(this.uTxtTo,1,0).mul(l)).add(a(this.uTxtTo,0,-1).mul(l)).add(a(this.uTxtTo,0,1).mul(l)).add(a(this.uTxtTo,-1,-1).mul(h)).add(a(this.uTxtTo,1,-1).mul(h)).add(a(this.uTxtTo,-1,1).mul(h)).add(a(this.uTxtTo,1,1).mul(h)).toVar("toTxt")}else if(s==="poisson"){let o=Be(.08333333333333333);e=a(this.uTxtFrom,0,0).mul(o).add(a(this.uTxtFrom,-.94,.34).mul(o)).add(a(this.uTxtFrom,.81,-.59).mul(o)).add(a(this.uTxtFrom,-.38,-.92).mul(o)).add(a(this.uTxtFrom,.97,.24).mul(o)).add(a(this.uTxtFrom,-.71,.71).mul(o)).add(a(this.uTxtFrom,.17,.98).mul(o)).add(a(this.uTxtFrom,.44,-.9).mul(o)).add(a(this.uTxtFrom,-.98,-.17).mul(o)).add(a(this.uTxtFrom,.59,.81).mul(o)).add(a(this.uTxtFrom,-.24,.97).mul(o)).add(a(this.uTxtFrom,-.59,-.81).mul(o)).toVar("fromTxt"),t=a(this.uTxtTo,0,0).mul(o).add(a(this.uTxtTo,-.94,.34).mul(o)).add(a(this.uTxtTo,.81,-.59).mul(o)).add(a(this.uTxtTo,-.38,-.92).mul(o)).add(a(this.uTxtTo,.97,.24).mul(o)).add(a(this.uTxtTo,-.71,.71).mul(o)).add(a(this.uTxtTo,.17,.98).mul(o)).add(a(this.uTxtTo,.44,-.9).mul(o)).add(a(this.uTxtTo,-.98,-.17).mul(o)).add(a(this.uTxtTo,.59,.81).mul(o)).add(a(this.uTxtTo,-.24,.97).mul(o)).add(a(this.uTxtTo,-.59,-.81).mul(o)).toVar("toTxt")}else if(s==="circular"){let o=Be(.125),l=Be(1);e=a(this.uTxtFrom,l,0).mul(o).add(a(this.uTxtFrom,.707,.707).mul(o)).add(a(this.uTxtFrom,0,l).mul(o)).add(a(this.uTxtFrom,-.707,.707).mul(o)).add(a(this.uTxtFrom,l.negate(),0).mul(o)).add(a(this.uTxtFrom,-.707,-.707).mul(o)).add(a(this.uTxtFrom,0,l.negate()).mul(o)).add(a(this.uTxtFrom,.707,-.707).mul(o)).toVar("fromTxt"),t=a(this.uTxtTo,l,0).mul(o).add(a(this.uTxtTo,.707,.707).mul(o)).add(a(this.uTxtTo,0,l).mul(o)).add(a(this.uTxtTo,-.707,.707).mul(o)).add(a(this.uTxtTo,l.negate(),0).mul(o)).add(a(this.uTxtTo,-.707,-.707).mul(o)).add(a(this.uTxtTo,0,l.negate()).mul(o)).add(a(this.uTxtTo,.707,-.707).mul(o)).toVar("toTxt")}else if(s==="bilinear"){let o=Be(.25);e=a(this.uTxtFrom,.5,.5).mul(o).add(a(this.uTxtFrom,-.5,.5).mul(o)).add(a(this.uTxtFrom,.5,-.5).mul(o)).add(a(this.uTxtFrom,-.5,-.5).mul(o)).toVar("fromTxt"),t=a(this.uTxtTo,.5,.5).mul(o).add(a(this.uTxtTo,-.5,.5).mul(o)).add(a(this.uTxtTo,.5,-.5).mul(o)).add(a(this.uTxtTo,-.5,-.5).mul(o)).toVar("toTxt")}else if(s==="dynamic"){let o=this.uIsPanning.greaterThan(.5);e=ai(0).toVar("fromTxt"),t=ai(0).toVar("toTxt"),Pd(o,()=>{let l=Be(.2),h=Be(.1),u=Be(.05),d=Be(.05);e.assign(a(this.uTxtFrom,0,0).mul(l).add(a(this.uTxtFrom,0,-1.5).mul(h)).add(a(this.uTxtFrom,1.5,0).mul(h)).add(a(this.uTxtFrom,0,1.5).mul(h)).add(a(this.uTxtFrom,-1.5,0).mul(h)).add(a(this.uTxtFrom,-1,-1).mul(u)).add(a(this.uTxtFrom,1,-1).mul(u)).add(a(this.uTxtFrom,1,1).mul(u)).add(a(this.uTxtFrom,-1,1).mul(u)).add(a(this.uTxtFrom,0,-2.5).mul(d)).add(a(this.uTxtFrom,2.5,0).mul(d)).add(a(this.uTxtFrom,0,2.5).mul(d)).add(a(this.uTxtFrom,-2.5,0).mul(d))),t.assign(a(this.uTxtTo,0,0).mul(l).add(a(this.uTxtTo,0,-1.5).mul(h)).add(a(this.uTxtTo,1.5,0).mul(h)).add(a(this.uTxtTo,0,1.5).mul(h)).add(a(this.uTxtTo,-1.5,0).mul(h)).add(a(this.uTxtTo,-1,-1).mul(u)).add(a(this.uTxtTo,1,-1).mul(u)).add(a(this.uTxtTo,1,1).mul(u)).add(a(this.uTxtTo,-1,1).mul(u)).add(a(this.uTxtTo,0,-2.5).mul(d)).add(a(this.uTxtTo,2.5,0).mul(d)).add(a(this.uTxtTo,0,2.5).mul(d)).add(a(this.uTxtTo,-2.5,0).mul(d)))}).Else(()=>{let l=Je(r,r).toVar();e.assign(this.uTxtFrom.sample(i.add(Je(r,r).mul(.5))).grad(l,l).mul(.25).add(this.uTxtFrom.sample(i.add(Je(r,r.negate()).mul(.5))).grad(l,l).mul(.25)).add(this.uTxtFrom.sample(i.add(Je(r.negate(),r).mul(.5))).grad(l,l).mul(.25)).add(this.uTxtFrom.sample(i.add(Je(r.negate(),r.negate()).mul(.5))).grad(l,l).mul(.25))),t.assign(this.uTxtTo.sample(i.add(Je(r,r).mul(.5))).grad(l,l).mul(.25).add(this.uTxtTo.sample(i.add(Je(r,r.negate()).mul(.5))).grad(l,l).mul(.25)).add(this.uTxtTo.sample(i.add(Je(r.negate(),r).mul(.5))).grad(l,l).mul(.25)).add(this.uTxtTo.sample(i.add(Je(r.negate(),r.negate()).mul(.5))).grad(l,l).mul(.25)))})}else{let o=Je(r,r).toVar();e=this.uTxtFrom.sample(i.add(Je(r,r).mul(.5))).grad(o,o).mul(.25).add(this.uTxtFrom.sample(i.add(Je(r,r.negate()).mul(.5))).grad(o,o).mul(.25)).add(this.uTxtFrom.sample(i.add(Je(r.negate(),r).mul(.5))).grad(o,o).mul(.25)).add(this.uTxtFrom.sample(i.add(Je(r.negate(),r.negate()).mul(.5))).grad(o,o).mul(.25)).toVar("fromTxt"),t=this.uTxtTo.sample(i.add(Je(r,r).mul(.5))).grad(o,o).mul(.25).add(this.uTxtTo.sample(i.add(Je(r,r.negate()).mul(.5))).grad(o,o).mul(.25)).add(this.uTxtTo.sample(i.add(Je(r.negate(),r).mul(.5))).grad(o,o).mul(.25)).add(this.uTxtTo.sample(i.add(Je(r.negate(),r.negate()).mul(.5))).grad(o,o).mul(.25)).toVar("toTxt")}}else e=this.uTxtFrom.sample(i).toVar("fromTxt"),t=this.uTxtTo.sample(i).toVar("toTxt");let n=no(e,t,this.uPercent).toVar("txt");if(oa(n.a.lessThan(this.options.alphaTest)),this.useGradient)if(this.layer.data.haveSnow){let a=n.b.oneMinus().toVar(),o=n.r.oneMinus().toVar();this.options.stepColor>0&&(a=a.mul(this.options.stepColor).round().div(this.options.stepColor),o=o.mul(this.options.stepColor).round().div(this.options.stepColor));let l=ai(this.uGradientTxt.sample(Je(.5,a))),h=ai(this.uGradientSnowTxt.sample(Je(.5,o)));n=no(l,h,h.a)}else{let a=(this.options.useRedChannel?n.r:n.b).oneMinus().toVar();this.options.stepColor>0&&(a=a.mul(this.options.stepColor).round().div(this.options.stepColor)),n=ai(this.uGradientTxt.sample(Je(.5,a)))}if(this.options.blueIsAlpha&&(n.a.mulAssign(n.b),n.rgb.assign(fn(n.b))),oa(n.a.lessThan(this.options.alphaTest)),this.options.blackIsAlpha){let a=O_(this.options.blackAlphaMin,this.options.blackAlphaMax,n.b.oneMinus());n.a.mulAssign(a)}return n});updateGradient=()=>{if(this.useGradient){let e=this.getLegendForRender();if(!e)return;if(this.gradient||=new rD,this.gradient.updateGradient(e.hexColors,e.values,this.options.gradientMode,this.layer.provider.value.domain),this.uGradientTxt=Fi(this.gradient),this.layer.data.haveSnow){let t=this.layer.data.legends[1];this.gradientSnow||(this.gradientSnow=new rD,this.gradientSnow.debugLabel=this.layer.data.name),this.gradientSnow.updateGradient(t.hexColors,t.values,this.options.gradientMode,this.layer.provider.value.domain),this.uGradientSnowTxt=Fi(this.gradientSnow)}}};updateBlendMode=()=>{switch(this.options.blending){case"additive":this.blending=2;break;case"multiply":this.blending=4;break;case"subtract":this.blending=3;break;default:this.blending=1}};setBlur=e=>{this.uBlur.value=e/N.width};setPanning=e=>{this.uIsPanning.value=+!!e};dispose(){this.watchers.dispose(),this.gradient?.dispose(),this.gradient=null,this.gradientSnow?.dispose(),this.gradientSnow=null,this.layer=null,this.options=null,this.uTxtFrom=null,this.uTxtTo=null,this.uPercent=null,this.uExtends=null,this.uBlur=null,this.uIsPanning=null,this.uGradientTxt=null,this.uGradientSnowTxt=null,super.dispose()}},wte=class extends Hm{constructor(e,t={},i){super(e),this.options=t,this.master=i,this.openLayerMap=i.openLayerMap,this.renderTarget=null,this.renderTargetPool=Km.getInstance(),this.container=new Gr,this.onImageLoaded=new je,this.allTilesDisplayed=!1,this.images=[],this.savedImageOptions=[],this.lastFrameState=null,this.resizeHandler=Al(()=>this.resize(),350),N.onResize.add(this.resizeHandler),N.onUpdate.add(this.update)}getViewportExtent(){let e=this.openLayerMap.getView(),t=this.openLayerMap.getSize();if(!t)throw Error("Map size is not available.");return e.calculateExtent(t)}prepareFrame(e){return!0}renderFrame(e){this.updateImage(e)}render(){super.render(frameState)}updateImage=e=>{if(this.lastFrameState=e,!this.lastFrameState||!this.images.length)return;let[t,i,r,s]=Xm(e,e.extent),n=r-t,a=s-i,o=1/n,l=1/a,h=this.openLayerMap.getView().getProjection().getCode(),u=(d,c)=>(d%c+c)%c;
2121this.images.forEach(({opts:d,meshes:c})=>{let[p,m,g,f]=Ns(d.extent,"EPSG:4326",h),y=g-p,x=f-m,[b,_,T,w]=Ns([-180,-85,180,85],"EPSG:4326",h),M=T-b;w-_;let S=M*o,R=y*o,I=x*l,B=(p-t)*o+R/2-.5,O=(m-i)*l+I/2-.5,U=R/2,V=u(B+U,S)-U;Object.values(c).forEach(z=>z.scale.set(R,I,1)),c.center.position.set(V,O,0),c.left.position.set(V-S,O,0),c.right.position.set(V+S,O,0)}),this.needsRender=!0};initRT=()=>{this.renderTarget||=this.renderTargetPool.checkOut()};releaseRT=()=>{this.renderTarget&&=(this.renderTargetPool.checkIn(this.renderTarget),null)};resize=()=>{this.renderTarget&&(this.renderTarget.setSize(N.width,N.height),setTimeout(()=>{this.render3d()},1))};update=e=>{this.master.opacity<.001||this.needsRender&&this.render3d()};render3d=()=>{this.needsRender=!1,this.initRT(),q.renderer.setClearColor(0,0),q.renderer.setRenderTarget(this.renderTarget),q.renderer.render(this.container,q.camera),q.renderer.setRenderTarget(null),q.renderer.setClearColor(14540253,1),q.scheduleRender()};addImage=e=>{this.savedImageOptions.push({...e})};loadImages=()=>{this.savedImageOptions.forEach(e=>{Bi.value++,new Wo().load(e.imageUrl,t=>{Bi.value--,e.repeat&&(t.wrapS=Or,t.wrapT=Or,t.repeat.set(e.repeatX||1,e.repeatY||1),t.colorSpace=Gi);let i=new Un(1,1),r=new Qn({map:t,transparent:!0}),s={center:new xt(i,r),left:new xt(i,r),right:new xt(i,r)};this.container.add(s.left,s.center,s.right),this.images.push({opts:e,meshes:s}),this.needsRender=!0,this.updateImage(this.lastFrameState),this.onImageLoaded.dispatch(),this.allTilesDisplayed=!0})})};disposeResources=()=>{N.onUpdate.remove(this.update),this.images.forEach(({meshes:e})=>{Object.values(e).forEach(t=>{t.geometry.dispose(),t.material.map.dispose(),t.material.dispose(),this.container.remove(t)})}),this.images.length=0,this.releaseRT(),this.allTilesDisplayed=!1,this.needsRender=!1,this.isInit=!1};reinitialize=()=>{this.isInit||(this.isInit=!0,N.onUpdate.add(this.update),this.needsRender=!0,this.loadImages())}},Ste=class extends u1{constructor(e,t,i){super(e),this.imgOption=t,this.master=i}createRenderer(){return new wte(this,this.imgOption,this.master)}initRT=()=>this.getRenderer().initRT();releaseRT=()=>this.getRenderer().releaseRT();addImage=e=>this.getRenderer().addImage(e);disposeResources=()=>this.getRenderer().disposeResources();reinitialize=()=>this.getRenderer().reinitialize();get texture(){return this.renderTarget?this.renderTarget.texture:null}get renderTarget(){return this.getRenderer().renderTarget}get container(){return this.getRenderer().container}get onImageLoaded(){return this.getRenderer().onImageLoaded}get onContentReady(){return this.getRenderer().onImageLoaded}},Mte=class extends Hm{constructor(e,t={},i){super(e),this.options=t,this.master=i,this.openLayerMap=i.openLayerMap,this.renderTarget=null,this.renderTargetPool=Km.getInstance(),this.container=new Gr,this.onImageLoaded=new je,this.allTilesDisplayed=!1,this.lastFrameState=null,this.resizeHandler=Al(()=>this.resize(),350),N.onResize.add(this.resizeHandler),N.onUpdate.add(this.update)}getViewportExtent(){let e=this.openLayerMap.getView(),t=this.openLayerMap.getSize();if(!t)throw Error("Map size is not available.");return e.calculateExtent(t)}prepareFrame(e){return!0}renderFrame(e){this.updateImage(e)}render(){super.render(frameState)}updateImage=e=>{if(this.lastFrameState=e,!this.lastFrameState)return;let[t,i,r,s]=Xm(e,e.extent),n=r-t,a=s-i,o=1/n,l=1/a,h=this.openLayerMap.getView(),u=h.getProjection().getCode();if(this.updatePixelScale(),this.uZoomBoost){let d=h.getZoom()||0;this.uZoomBoost.value=Math.min(Math.max(1+Math.max(0,d-5)*.15,1),3)}if(this.data&&this.positionAttribute){let d=this.positionAttribute.array;for(let c=0;c<this.data.length;c++){let[p,m]=this.data[c].position,[g,f]=El([p,m],"EPSG:4326",u);d[c*3]=(g-t)*o-.5,d[c*3+1]=(f-i)*l-.5,d[c*3+2]=0}this.positionAttribute.needsUpdate=!0}this.needsRender=!0};initRT=()=>{this.renderTarget||=this.renderTargetPool.checkOut()};releaseRT=()=>{this.renderTarget&&=(this.renderTargetPool.checkIn(this.renderTarget),null)};updatePixelScale=()=>{!N.width||!N.height||(this.uPixelSize&&(this.uPixelSize.value=24/N.width),this.uAspect&&(this.uAspect.value=N.width/N.height),this.particles&&this.particles.scale.set(1,1,1))};resize=()=>{if(this.updatePixelScale(),this.renderTarget){let e=N.width*N.devicePixelRatio,t=N.height*N.devicePixelRatio;this.renderTarget.setSize(e,t),setTimeout(()=>{this.render3d()},1)}};update=e=>{this.master.opacity<1||this.render3d()};render3d=()=>{this.renderTarget&&(q.renderer.setClearColor(0,0),q.renderer.setRenderTarget(this.renderTarget),q.renderer.render(this.container,q.camera),q.renderer.setRenderTarget(null),q.renderer.setClearColor(14540253,1),q.scheduleRender())};addParticles=e=>{this.savedParticleOptions={...e},this.isInit&&this.loadParticles()};loadParticles=()=>
2121{if(!this.savedParticleOptions)return;let e=this.savedParticleOptions;if(e.data.length===0){this.onImageLoaded.dispatch();return}Bi.value++,new Wo().load(e.imageUrl,t=>{Bi.value--,this.data=e.data;let i=this.data.length,r=new Float32Array(i*3),s=new Float32Array(i*3),n=new Float32Array(i),a=new Float32Array(i),o=new Float32Array(i),l=new Float32Array(i);this.positionAttribute=new cr(r,3),this.positionAttribute.setUsage(an),this.colorAttribute=new cr(s,3),this.colorAttribute.setUsage(an),this.scaleAttribute=new cr(n,1),this.scaleAttribute.setUsage(an),this.animAttribute=new cr(a,1),this.animAttribute.setUsage(an),this.alphaAttribute=new cr(o,1),this.alphaAttribute.setUsage(an),this.phaseAttribute=new cr(l,1),this.phaseAttribute.setUsage(an);for(let x=0;x<i;x++){let b=this.data[x];switch(r[x*3]=0,r[x*3+1]=0,r[x*3+2]=0,l[x]=Math.random()*Math.PI*2,b.type){case"m-0":s[x*3]=1,s[x*3+1]=0,s[x*3+2]=0,n[x]=1.15,a[x]=1,o[x]=1;break;case"m-5":s[x*3]=252/255,s[x*3+1]=95/255,s[x*3+2]=28/255,n[x]=.75,a[x]=.25,o[x]=.85;break;default:case"m-10":s[x*3]=252/255,s[x*3+1]=237/255,s[x*3+2]=28/255,n[x]=.6,a[x]=0,o[x]=.7;break}}let h=new Ub({sizeAttenuation:!1,map:t,transparent:!0,depthTest:!1,depthWrite:!1});h.positionNode=Vt(()=>vl(this.positionAttribute,"vec3").xyz)(),this.uPixelSize=Le(24/Math.max(N.width,1)),this.uAspect=Le(N.width/Math.max(N.height,1)),this.uZoomBoost=Le(1);let u=vl(this.phaseAttribute,"float"),d=vl(this.animAttribute,"float"),c=vl(this.scaleAttribute,"float"),p=vl(this.alphaAttribute,"float"),m=this.uPixelSize.mul(this.uZoomBoost).mul(xH(G0(jh.mul(2.2).add(u)).mul(d)).mul(.5).add(1)).mul(c);h.scaleNode=Je(m,m.mul(this.uAspect));let g=Fi(t).sample(la());h.colorNode=Vt(()=>vl(this.colorAttribute,"vec3").rgb)();let f=g.r.smoothstep(.04,.22).mul(.4),y=g.r.smoothstep(.5,.85).mul(.85);h.opacityNode=_H(f.add(y),1).mul(p),this.particles=new i4(h),this.particles.count=i,this.container.add(this.particles),this.updatePixelScale(),this.needsRender=!0,this.updateImage(this.lastFrameState),this.render3d(),this.onImageLoaded.dispatch(),this.allTilesDisplayed=!0})};disposeResources=()=>{N.onUpdate.remove(this.update),this.positionAttribute&&=null,this.colorAttribute&&=null,this.scaleAttribute&&=null,this.alphaAttribute&&=null,this.phaseAttribute&&=null,this.particles&&=(this.particles.material.map.dispose(),this.particles.material.dispose(),this.container.remove(this.particles),null),this.releaseRT(),this.data=null,this.allTilesDisplayed=!1,this.needsRender=!1,this.isInit=!1};reinitialize=()=>{this.isInit||(this.isInit=!0,N.onUpdate.add(this.update),this.needsRender=!0,this.loadParticles())}},Cte=class extends u1{constructor(e,t,i){super(e),this.imgOption=t,this.master=i}createRenderer(){return new Mte(this,this.imgOption,this.master)}initRT=()=>this.getRenderer().initRT();releaseRT=()=>this.getRenderer().releaseRT();addParticles=e=>this.getRenderer().addParticles(e);disposeResources=()=>this.getRenderer().disposeResources();reinitialize=()=>this.getRenderer().reinitialize();get texture(){return this.renderTarget?this.renderTarget.texture:null}get renderTarget(){return this.getRenderer().renderTarget}get container(){return this.getRenderer().container}get onImageLoaded(){return this.getRenderer().onImageLoaded}get onContentReady(){return this.getRenderer().onImageLoaded}},aD=class{drawCustom(e,t,i,r,s){}drawGeometry(e){}setStyle(e){}drawCircle(e,t,i){}drawFeature(e,t,i){}drawGeometryCollection(e,t,i){}drawLineString(e,t,i){}drawMultiLineString(e,t,i){}drawMultiPoint(e,t,i){}drawMultiPolygon(e,t,i){}drawPoint(e,t,i){}drawPolygon(e,t,i){}drawText(e,t,i){}setFillStrokeStyle(e,t){}setImageStyle(e,t){}setTextStyle(e,t){}},Ne={BEGIN_GEOMETRY:0,BEGIN_PATH:1,CIRCLE:2,CLOSE_PATH:3,CUSTOM:4,DRAW_CHARS:5,DRAW_IMAGE:6,END_GEOMETRY:7,FILL:8,MOVE_TO_LINE_TO:9,SET_FILL_STYLE:10,SET_STROKE_STYLE:11,STROKE:12},R1=[Ne.FILL],th=[Ne.STROKE],Au=[Ne.BEGIN_PATH],oD=[Ne.CLOSE_PATH],hg=class extends aD{constructor(e,t,i,r){super(),this.tolerance=e,this.maxExtent=t,this.pixelRatio=r,this.maxLineWidth=0,this.resolution=i,this.beginGeometryInstruction1_=null,this.beginGeometryInstruction2_=null,this.bufferedMaxExtent_=null,this.instructions=[],this.coordinates=[],this.tmpCoordinate_=[],this.hitDetectionInstructions=[],this.state={}}applyPixelRatio(e){let t=this.pixelRatio;return t==1?e:e.map(function(i){return i*t})}appendFlatPointCoordinates(e,t){let i=this.getBufferedMaxExtent(),r=this.tmpCoordinate_,s=this.coordinates,n=s.length;for(let a=0,o=e.length;a<o;a+=t)r[0]=e[a],r[1]=e[a+1],Hd(i,r)&&(s[n++]=r[0],s[n++]=r[1]);return n}appendFlatLineCoordinates(e,t,i,r,s,n){let a=this.coordinates,o=a.length,l=this.getBufferedMaxExtent();n&&(t+=r);let h=e[t],u=e[t+1],d=this.tmpCoordinate_,c=!0,p,m,g;for(p=t+r;p<i;p+=r)d[0]=e[p],d[1]=e[p+1],g=UT(l,d),g===m?g===nr.INTERSECTING?(a[o++]=d[0],a[o++]=d[1],c=!1):c=!0:(c&&=(a[o++]=h,a[o++]=u,!1),a[o++]=d[0],a[o++]=d[1]),h=d[0],u=d[1],m=g;return(s&&c||p===t+r)&&(a[o++]=h,a[o++]=u),o}drawCustomCoordinates_(e,t,i,r,s){for(let n=0,a=i.length;n<a;++n){let o=i[n],l=this.appendFlatLineCoordinates(e,t,o,r,!1,!1);s.push(l),t=o}return t}drawCustom(e,t,i,r,s){this.beginGeometry(e,t,s);let n=e.getType(),a=e.getStride(),o=this.coordinates.length,l,h,u,d,c;switch(n){case"MultiPolygon":l=e.getOrientedFlatCoordinates(),d=[];let p=e.getEndss();c=0;for(let m=0,g=p.length;m<g;++m){let f=[];c=this.drawCustomCoordinates_(l,c,p[m],a,f),d.push(f)}this.instructions.push([Ne.CUSTOM,o,d,e,i,Aw,s]),this.hitDetectionInstructions.push([Ne.CUSTOM,o,d,e,r||i,Aw,s]);break;case"Polygon":case"MultiLineString":u=[],l=n=="Polygon"?e.getOrientedFlatCoordinates():e.getFlatCoordinates(),c=this.drawCustomCoordinates_(l,0,e.getEnds(),a,u),this.instructions.push([Ne.CUSTOM,o,u,e,i,Tm,s]),this.hitDetectionInstructions.push([Ne.CUSTOM,o,u,e,r||i,Tm,s]);break;
2121case"LineString":case"Circle":l=e.getFlatCoordinates(),h=this.appendFlatLineCoordinates(l,0,l.length,a,!1,!1),this.instructions.push([Ne.CUSTOM,o,h,e,i,Ul,s]),this.hitDetectionInstructions.push([Ne.CUSTOM,o,h,e,r||i,Ul,s]);break;case"MultiPoint":l=e.getFlatCoordinates(),h=this.appendFlatPointCoordinates(l,a),h>o&&(this.instructions.push([Ne.CUSTOM,o,h,e,i,Ul,s]),this.hitDetectionInstructions.push([Ne.CUSTOM,o,h,e,r||i,Ul,s]));break;case"Point":l=e.getFlatCoordinates(),this.coordinates.push(l[0],l[1]),h=this.coordinates.length,this.instructions.push([Ne.CUSTOM,o,h,e,i,void 0,s]),this.hitDetectionInstructions.push([Ne.CUSTOM,o,h,e,r||i,void 0,s]);break;default:}this.endGeometry(t)}beginGeometry(e,t,i){this.beginGeometryInstruction1_=[Ne.BEGIN_GEOMETRY,t,0,e,i],this.instructions.push(this.beginGeometryInstruction1_),this.beginGeometryInstruction2_=[Ne.BEGIN_GEOMETRY,t,0,e,i],this.hitDetectionInstructions.push(this.beginGeometryInstruction2_)}finish(){return{instructions:this.instructions,hitDetectionInstructions:this.hitDetectionInstructions,coordinates:this.coordinates}}reverseHitDetectionInstructions(){let e=this.hitDetectionInstructions;e.reverse();let t,i=e.length,r,s,n=-1;for(t=0;t<i;++t)r=e[t],s=r[0],s==Ne.END_GEOMETRY?n=t:s==Ne.BEGIN_GEOMETRY&&(r[2]=t,yK(this.hitDetectionInstructions,n,t),n=-1)}fillStyleToState(e,t={}){if(e){let i=e.getColor();t.fillPatternScale=i&&typeof i=="object"&&"src"in i?this.pixelRatio:1,t.fillStyle=Ra(i||"#000")??void 0}else t.fillStyle=void 0;return t}strokeStyleToState(e,t={}){if(e){t.strokeStyle=Ra(e.getColor()||$l);let i=e.getLineCap();t.lineCap=i===void 0?r1:i;let r=e.getLineDash();t.lineDash=r?r.slice():Mo,t.lineDashOffset=e.getLineDashOffset()||0;let s=e.getLineJoin();t.lineJoin=s===void 0?s1:s;let n=e.getWidth();t.lineWidth=n===void 0?1:n;let a=e.getMiterLimit();t.miterLimit=a===void 0?10:a,t.strokeOffset=e.getOffset()??0,t.lineWidth>this.maxLineWidth&&(this.maxLineWidth=t.lineWidth,this.bufferedMaxExtent_=null)}else t.strokeStyle=void 0,t.lineCap=void 0,t.lineDash=null,t.lineDashOffset=void 0,t.lineJoin=void 0,t.lineWidth=void 0,t.miterLimit=void 0,t.strokeOffset=void 0;return t}setFillStrokeStyle(e,t){let i=this.state;this.fillStyleToState(e,i),this.strokeStyleToState(t,i)}createFill(e){let t=e.fillStyle,i=[Ne.SET_FILL_STYLE,t];return typeof t!="string"&&i.push(e.fillPatternScale),i}applyStroke(e){this.instructions.push(this.createStroke(e))}createStroke(e){return[Ne.SET_STROKE_STYLE,e.strokeStyle,e.lineWidth*this.pixelRatio,e.lineCap,e.lineJoin,e.miterLimit,e.lineDash?this.applyPixelRatio(e.lineDash):null,e.lineDashOffset*this.pixelRatio]}updateFillStyle(e,t){let i=e.fillStyle;(i!==void 0&&typeof i!="string"||e.currentFillStyle!=i)&&(this.instructions.push(t.call(this,e)),e.currentFillStyle=i)}updateStrokeStyle(e,t){let i=e.strokeStyle,r=e.lineCap,s=e.lineDash,n=e.lineDashOffset,a=e.lineJoin,o=e.lineWidth,l=e.miterLimit,h=e.strokeOffset;(e.currentStrokeStyle!=i||e.currentLineCap!=r||s!=e.currentLineDash&&!nu(e.currentLineDash,s)||e.currentLineDashOffset!=n||e.currentLineJoin!=a||e.currentLineWidth!=o||e.currentMiterLimit!=l||e.currentStrokeOffset!=h)&&(t.call(this,e),e.currentStrokeStyle=i,e.currentLineCap=r,e.currentLineDash=s,e.currentLineDashOffset=n,e.currentLineJoin=a,e.currentLineWidth=o,e.currentMiterLimit=l,e.currentStrokeOffset=h)}endGeometry(e){this.beginGeometryInstruction1_[2]=this.instructions.length,this.beginGeometryInstruction1_=null,this.beginGeometryInstruction2_[2]=this.hitDetectionInstructions.length,this.beginGeometryInstruction2_=null;let t=[Ne.END_GEOMETRY,e];this.instructions.push(t),this.hitDetectionInstructions.push(t)}getBufferedMaxExtent(){if(!this.bufferedMaxExtent_&&(this.bufferedMaxExtent_=bk(this.maxExtent),this.maxLineWidth>0)){let e=this.resolution*(this.maxLineWidth+1)/2;Zh(this.bufferedMaxExtent_,e,this.bufferedMaxExtent_)}return this.bufferedMaxExtent_}},Rte=class extends hg{constructor(e,t,i,r){super(e,t,i,r),this.hitDetectionImage_=null,this.image_=null,this.imagePixelRatio_=void 0,this.anchorX_=void 0,this.anchorY_=void 0,this.height_=void 0,this.opacity_=void 0,this.originX_=void 0,this.originY_=void 0,this.rotateWithView_=void 0,this.rotation_=void 0,this.scale_=void 0,this.width_=void 0,this.declutterMode_=void 0,this.declutterImageWithText_=void 0}drawPoint(e,t,i){if(!this.image_||this.maxExtent&&!Hd(this.maxExtent,e.getFlatCoordinates()))return;this.beginGeometry(e,t,i);let r=e.getFlatCoordinates(),s=e.getStride(),n=this.coordinates.length,a=this.appendFlatPointCoordinates(r,s);this.instructions.push([Ne.DRAW_IMAGE,n,a,this.image_,this.anchorX_*this.imagePixelRatio_,this.anchorY_*this.imagePixelRatio_,Math.
2121ceil(this.height_*this.imagePixelRatio_),this.opacity_,this.originX_*this.imagePixelRatio_,this.originY_*this.imagePixelRatio_,this.rotateWithView_,this.rotation_,[this.scale_[0]*this.pixelRatio/this.imagePixelRatio_,this.scale_[1]*this.pixelRatio/this.imagePixelRatio_],Math.ceil(this.width_*this.imagePixelRatio_),this.declutterMode_,this.declutterImageWithText_]),this.hitDetectionInstructions.push([Ne.DRAW_IMAGE,n,a,this.hitDetectionImage_,this.anchorX_,this.anchorY_,this.height_,1,this.originX_,this.originY_,this.rotateWithView_,this.rotation_,this.scale_,this.width_,this.declutterMode_,this.declutterImageWithText_]),this.endGeometry(t)}drawMultiPoint(e,t,i){if(!this.image_)return;this.beginGeometry(e,t,i);let r=e.getFlatCoordinates(),s=[];for(let o=0,l=r.length;o<l;o+=e.getStride())(!this.maxExtent||Hd(this.maxExtent,r.slice(o,o+2)))&&s.push(r[o],r[o+1]);let n=this.coordinates.length,a=this.appendFlatPointCoordinates(s,2);this.instructions.push([Ne.DRAW_IMAGE,n,a,this.image_,this.anchorX_*this.imagePixelRatio_,this.anchorY_*this.imagePixelRatio_,Math.ceil(this.height_*this.imagePixelRatio_),this.opacity_,this.originX_*this.imagePixelRatio_,this.originY_*this.imagePixelRatio_,this.rotateWithView_,this.rotation_,[this.scale_[0]*this.pixelRatio/this.imagePixelRatio_,this.scale_[1]*this.pixelRatio/this.imagePixelRatio_],Math.ceil(this.width_*this.imagePixelRatio_),this.declutterMode_,this.declutterImageWithText_]),this.hitDetectionInstructions.push([Ne.DRAW_IMAGE,n,a,this.hitDetectionImage_,this.anchorX_,this.anchorY_,this.height_,1,this.originX_,this.originY_,this.rotateWithView_,this.rotation_,this.scale_,this.width_,this.declutterMode_,this.declutterImageWithText_]),this.endGeometry(t)}finish(){return this.reverseHitDetectionInstructions(),this.anchorX_=void 0,this.anchorY_=void 0,this.hitDetectionImage_=null,this.image_=null,this.imagePixelRatio_=void 0,this.height_=void 0,this.scale_=void 0,this.opacity_=void 0,this.originX_=void 0,this.originY_=void 0,this.rotateWithView_=void 0,this.rotation_=void 0,this.width_=void 0,super.finish()}setImageStyle(e,t){let i=e.getAnchor(),r=e.getSize(),s=e.getOrigin();this.imagePixelRatio_=e.getPixelRatio(this.pixelRatio),this.anchorX_=i[0],this.anchorY_=i[1],this.hitDetectionImage_=e.getHitDetectionImage(),this.image_=e.getImage(this.pixelRatio),this.height_=r[1],this.opacity_=e.getOpacity(),this.originX_=s[0],this.originY_=s[1],this.rotateWithView_=e.getRotateWithView(),this.rotation_=e.getRotation(),this.scale_=e.getScaleArray(),this.width_=r[0],this.declutterMode_=e.getDeclutterMode(),this.declutterImageWithText_=t}},Ete=class extends hg{constructor(e,t,i,r){super(e,t,i,r)}drawFlatCoordinates_(e,t,i,r,s){let n=this.coordinates.length,a=this.appendFlatLineCoordinates(e,t,i,r,!1,!1);return this.instructions.push([Ne.MOVE_TO_LINE_TO,n,a,s*this.pixelRatio]),this.hitDetectionInstructions.push([Ne.MOVE_TO_LINE_TO,n,a,s]),i}drawLineString(e,t,i){let r=this.state,s=r.strokeStyle,n=r.lineWidth,a=r.strokeOffset;if(s===void 0||n===void 0)return;this.updateStrokeStyle(r,this.applyStroke),this.beginGeometry(e,t,i),this.hitDetectionInstructions.push([Ne.SET_STROKE_STYLE,$l,r.lineWidth,r.lineCap,r.lineJoin,r.miterLimit,Mo,0],Au);let o=e.getFlatCoordinates(),l=e.getStride();this.drawFlatCoordinates_(o,0,o.length,l,a),this.hitDetectionInstructions.push(th),this.endGeometry(t)}drawMultiLineString(e,t,i){let r=this.state,s=r.strokeStyle,n=r.lineWidth,a=r.strokeOffset;if(s===void 0||n===void 0)return;this.updateStrokeStyle(r,this.applyStroke),this.beginGeometry(e,t,i),this.hitDetectionInstructions.push([Ne.SET_STROKE_STYLE,$l,r.lineWidth,r.lineCap,r.lineJoin,r.miterLimit,Mo,0],Au);let o=e.getEnds(),l=e.getFlatCoordinates(),h=e.getStride(),u=0;for(let d=0,c=o.length;d<c;++d)u=this.drawFlatCoordinates_(l,u,o[d],h,a);this.hitDetectionInstructions.push(th),this.endGeometry(t)}finish(){let e=this.state;return e.lastStroke!=null&&e.lastStroke!=this.coordinates.length&&this.instructions.push(th),this.reverseHitDetectionInstructions(),this.state=null,super.finish()}applyStroke(e){e.lastStroke!=null&&e.lastStroke!=this.coordinates.length&&(this.instructions.push(th),e.lastStroke=this.coordinates.length),e.lastStroke=0,super.applyStroke(e),this.instructions.push(Au)}},lD=class extends hg{constructor(e,t,i,r){super(e,t,i,r)}drawFlatCoordinatess_(e,t,i,r,s){let n=this.state,a=n.fillStyle!==void 0,o=n.strokeStyle!==void 0,l=i.length;this.instructions.push(Au),this.hitDetectionInstructions.push(Au);for(let h=0;h<l;++h){let u=i[h],d=this.coordinates.length,c=this.appendFlatLineCoordinates(e,t,u,r,!0,!o);this.instructions.push([Ne.MOVE_TO_LINE_TO,d,c,s*this.pixelRatio,!0]),this.hitDetectionInstructions.push([Ne.MOVE_TO_LINE_TO,d,c,s,!0]),o&&(this.instructions.push(oD),this.hitDetectionInstructions.push(oD)),t=u}return a&&(this.instructions.push(R1),this.hitDetectionInstructions.push(R1)),o&&(this.instructions.push(th),this.hitDetectionInstructions.push(th)),t}drawCircle(e,t,i){let r=this.state,s=r.fillStyle,n=r.strokeStyle,a=r.
2121strokeOffset;if(s===void 0&&n===void 0||this.handleStrokeOffset_(()=>this.drawCircle(e,t,i)))return;this.setFillStrokeStyles_(),this.beginGeometry(e,t,i),r.fillStyle!==void 0&&this.hitDetectionInstructions.push([Ne.SET_FILL_STYLE,tn]),r.strokeStyle!==void 0&&this.hitDetectionInstructions.push([Ne.SET_STROKE_STYLE,$l,r.lineWidth,r.lineCap,r.lineJoin,r.miterLimit,Mo,0]);let o=e.getFlatCoordinates(),l=e.getStride(),h=this.coordinates.length;this.appendFlatLineCoordinates(o,0,o.length,l,!1,!1);let u=[Ne.CIRCLE,h,a];this.instructions.push(Au,u),this.hitDetectionInstructions.push(Au,u),r.fillStyle!==void 0&&(this.instructions.push(R1),this.hitDetectionInstructions.push(R1)),r.strokeStyle!==void 0&&(this.instructions.push(th),this.hitDetectionInstructions.push(th)),this.endGeometry(t)}drawPolygon(e,t,i){let r=this.state,s=r.fillStyle,n=r.strokeStyle,a=r.strokeOffset;if(s===void 0&&n===void 0||this.handleStrokeOffset_(()=>this.drawPolygon(e,t,i)))return;this.setFillStrokeStyles_(),this.beginGeometry(e,t,i),r.fillStyle!==void 0&&this.hitDetectionInstructions.push([Ne.SET_FILL_STYLE,tn]),r.strokeStyle!==void 0&&this.hitDetectionInstructions.push([Ne.SET_STROKE_STYLE,$l,r.lineWidth,r.lineCap,r.lineJoin,r.miterLimit,Mo,0]);let o=e.getEnds(),l=e.getOrientedFlatCoordinates(),h=e.getStride();this.drawFlatCoordinatess_(l,0,o,h,a),this.endGeometry(t)}drawMultiPolygon(e,t,i){let r=this.state,s=r.fillStyle,n=r.strokeStyle,a=r.strokeOffset;if(s===void 0&&n===void 0||this.handleStrokeOffset_(()=>this.drawMultiPolygon(e,t,i)))return;this.setFillStrokeStyles_(),this.beginGeometry(e,t,i),r.fillStyle!==void 0&&this.hitDetectionInstructions.push([Ne.SET_FILL_STYLE,tn]),r.strokeStyle!==void 0&&this.hitDetectionInstructions.push([Ne.SET_STROKE_STYLE,$l,r.lineWidth,r.lineCap,r.lineJoin,r.miterLimit,Mo,0]);let o=e.getEndss(),l=e.getOrientedFlatCoordinates(),h=e.getStride(),u=0;for(let d=0,c=o.length;d<c;++d)u=this.drawFlatCoordinatess_(l,u,o[d],h,a);this.endGeometry(t)}finish(){this.reverseHitDetectionInstructions(),this.state=null;let e=this.tolerance;if(e!==0){let t=this.coordinates;for(let i=0,r=t.length;i<r;++i)t[i]=yu(t[i],e)}return super.finish()}setFillStrokeStyles_(){let e=this.state;this.updateFillStyle(e,this.createFill),this.updateStrokeStyle(e,this.applyStroke)}handleStrokeOffset_(e){let t=this.state,i=t.fillStyle,r=t.strokeStyle,s=t.strokeOffset;return Math.abs(s)>0&&i!==void 0&&r!==void 0?(t.strokeStyle=void 0,t.strokeOffset=0,e(),t.fillStyle=void 0,t.strokeStyle=r,t.strokeOffset=s,e(),t.fillStyle=i,!0):!1}};function Ate(e,t,i,r,s){let n=[],a=i,o=0,l=t.slice(i,2);for(;o<e&&a+s<r;){let[h,u]=l.slice(-2),d=t[a+s],c=t[a+s+1],p=Math.sqrt((d-h)*(d-h)+(c-u)*(c-u));if(o+=p,o>=e){let m=(e-o+p)/p,g=Es(h,d,m),f=Es(u,c,m);l.push(g,f),n.push(l),l=[g,f],o==e&&(a+=s),o=0}else if(o<e)l.push(t[a+s],t[a+s+1]),a+=s;else{let m=p-o,g=Es(h,d,m/p),f=Es(u,c,m/p);l.push(g,f),n.push(l),l=[g,f],o=0,a+=s}}return o>0&&n.push(l),n}function Nte(e,t,i,r,s){let n=i,a=i,o=0,l=0,h=i,u,d,c,p,m,g,f,y,x,b;for(d=i;d<r;d+=s){let _=t[d],T=t[d+1];m!==void 0&&(x=_-m,b=T-g,p=Math.sqrt(x*x+b*b),f!==void 0&&(l+=c,u=Math.acos((f*x+y*b)/(c*p)),u>e&&(l>o&&(o=l,n=h,a=d),l=0,h=d-s)),c=p,f=x,y=b),m=_,g=T}return l+=p,l>o?[h,d]:[n,a]}var E1={left:0,center:.5,right:1,top:0,middle:.5,hanging:.2,alphabetic:.8,ideographic:.8,bottom:1},Lte={Circle:lD,Default:hg,Image:Rte,LineString:Ete,Polygon:lD,Text:class extends hg{constructor(e,t,i,r){super(e,t,i,r),this.labels_=null,this.text_="",this.textOffsetX_=0,this.textOffsetY_=0,this.textRotateWithView_=void 0,this.textKeepUpright_=void 0,this.textRotation_=0,this.textFillState_=null,this.fillStates={},this.fillStates[tn]={fillStyle:tn},this.textStrokeState_=null,this.strokeStates={},this.textState_={},this.textStates={},this.textKey_="",this.fillKey_="",this.strokeKey_="",this.declutterMode_=void 0,this.declutterImageWithText_=void 0}finish(){let e=super.finish();return e.textStates=this.textStates,e.fillStates=this.fillStates,e.strokeStates=this.strokeStates,e}drawText(e,t,i){let r=this.textFillState_,s=this.textStrokeState_,n=this.textState_;if(this.text_===""||!n||!r&&!s)return;let a=this.coordinates,o=a.length,l=e.getType(),h=null,u=e.getStride();if(n.placement==="line"&&(l=="LineString"||l=="MultiLineString"||l=="Polygon"||l=="MultiPolygon")){if(!Xi(this.maxExtent,e.getExtent()))return;let d;if(h=e.getFlatCoordinates(),l=="LineString")d=[h.length];else if(l=="MultiLineString")d=e.getEnds();else if(l=="Polygon")d=e.getEnds().slice(0,1);else if(l=="MultiPolygon"){let g=e.getEndss();d=[];for(let f=0,y=g.length;f<y;++f)d.push(g[f][0])}this.beginGeometry(e,t,i);let c=n.repeat,p=c?void 0:n.textAlign,m=0;for(let g=0,f=d.length;g<f;++g){let y;y=c?Ate(c*this.resolution,h,m,d[g],u):[h.slice(m,d[g])];for(let x=0,b=y.length;x<b;++x){let _=y[x],T=0,w=_.length;if(p==null){let S=Nte(n.maxAngle,_,0,_.length,2);T=S[0],w=S[1]}for(let S=T;S<w;S+=u)a.push(_[S],_[S+1]);let M=a.length;m=d[g],this.drawChars_(o,M),o=M}}this.endGeometry(t)}else{let d=n.overflow?null:[];switch(l){case"Point":case"MultiPoint":h=e.getFlatCoordinates();break;case"LineString":h=e.getFlatMidpoint();break;case"Circle":h=e.getCenter();break;case"MultiLineString":h=e.getFlatMidpoints(),u=2;break;case"Polygon":h=e.getFlatInteriorPoint(),n.overflow||d.push(h[2]/this.resolution),u=3;break;case"MultiPolygon":let b=e.getFlatInteriorPoints();h=[];for(let _=0,T=b.length;_<T;_+=3)n.overflow||d.push(b[_+2]/this.resolution),h.push(b[_],b[_+1]);if(h.length===0)return;u=2;break;default:}let c=this.appendFlatPointCoordinates(h,u);if(c===o)return;if(d&&(c-o)/2!==h.length/u){let b=o/2;d=d.filter((_,T)=>{let w=a[(b+T)*2]===h[T*u]&&a[(b+T)*2+1]===h[T*u+1];return w||--b,w})}this.saveTextStates_();let p=n.backgroundFill?this.createFill(this.fillStyleToState(n.backgroundFill)):null,m=n.backgroundStroke?this.createStroke(this.strokeStyleToState(n.backgroundStroke)):null;this.beginGeometry(e,t,i);let g=n.padding;if(g!=Mu&&(n.scale[0]<0||n.scale[1]<0)){let b=n.padding[0],_=n.padding[1],T=n.padding[2],w=n.padding[3];n.scale[0]<0&&(_=-_,w=-w),n.scale[1]<0&&(b=-b,T=-T),g=[b,_,T,w]}let f=this.pixelRatio;this.instructions.push([Ne.DRAW_IMAGE,o,c,null,NaN,NaN,NaN,1,0,0,this.textRotateWithView_,this.textRotation_,[1,1],NaN,this.declutterMode_,this.declutterImageWithText_,g==Mu?Mu:g.map(function(b){return b*f}),p,m,this.text_,this.textKey_,this.strokeKey_,this.fillKey_,this.textOffsetX_,this.textOffsetY_,d]);let y=1/f,x=p?p.slice(0):null;x&&(x[1]=tn),this.hitDetectionInstructions.push([Ne.DRAW_IMAGE,o,c,null,NaN,NaN,NaN,1,0,0,this.textRotateWithView_,this.textRotation_,[y,y],NaN,this.declutterMode_,this.declutterImageWithText_,g,x,m,this.text_,this.textKey_,this.strokeKey_,this.fillKey_?tn:this.fillKey_,this.textOffsetX_,this.textOffsetY_,d]),this.endGeometry(t)}}saveTextStates_(){let e=this.textStrokeState_,t=this.textState_,i=this.textFillState_,r=this.strokeKey_;e&&(r in this.strokeStates||(this.strokeStates[r]={strokeStyle:e.strokeStyle,lineCap:e.lineCap,lineDashOffset:e.lineDashOffset,lineWidth:e.lineWidth,lineJoin:e.lineJoin,miterLimit:e.miterLimit,lineDash:e.lineDash}));let s=this.textKey_;s in this.textStates||(this.textStates[s]={font:t.font,textAlign:t.textAlign||"center",justify:t.justify,textBaseline:t.textBaseline||"middle",scale:t.scale});let n=this.fillKey_;i&&(n in this.fillStates||(this.fillStates[n]={fillStyle:i.fillStyle}))}drawChars_(e,t){let i=this.textStrokeState_,r=this.textState_,s=this.strokeKey_,n=this.textKey_,a=this.fillKey_;this.saveTextStates_();let o=this.pixelRatio,l=E1[r.textBaseline],h=this.textOffsetY_*o,u=this.text_,d=i?i.lineWidth*Math.abs(r.scale[0])/2:0;this.instructions.push([Ne.DRAW_CHARS,e,t,l,r.overflow,a,r.maxAngle,o,h,s,d*o,u,
2121n,1,this.declutterMode_,this.textKeepUpright_]),this.hitDetectionInstructions.push([Ne.DRAW_CHARS,e,t,l,r.overflow,a&&tn,r.maxAngle,o,h,s,d*o,u,n,1/o,this.declutterMode_,this.textKeepUpright_])}setTextStyle(e,t){let i,r,s;if(!e)this.text_="";else{let n=e.getFill();n?(r=this.textFillState_,r||(r={},this.textFillState_=r),r.fillStyle=Ra(n.getColor()||"#000")):(r=null,this.textFillState_=r);let a=e.getStroke();if(!a)s=null,this.textStrokeState_=s;else{s=this.textStrokeState_,s||(s={},this.textStrokeState_=s);let m=a.getLineDash(),g=a.getLineDashOffset(),f=a.getWidth(),y=a.getMiterLimit();s.lineCap=a.getLineCap()||"round",s.lineDash=m?m.slice():Mo,s.lineDashOffset=g===void 0?0:g,s.lineJoin=a.getLineJoin()||"round",s.lineWidth=f===void 0?1:f,s.miterLimit=y===void 0?10:y,s.strokeStyle=Ra(a.getColor()||"#000")}i=this.textState_;let o=e.getFont()||"10px sans-serif";sQ(o);let l=e.getScaleArray();i.overflow=e.getOverflow(),i.font=o,i.maxAngle=e.getMaxAngle(),i.placement=e.getPlacement(),i.textAlign=e.getTextAlign(),i.repeat=e.getRepeat(),i.justify=e.getJustify(),i.textBaseline=e.getTextBaseline()||"middle",i.backgroundFill=e.getBackgroundFill(),i.backgroundStroke=e.getBackgroundStroke(),i.padding=e.getPadding()||Mu,i.scale=l===void 0?[1,1]:l;let h=e.getOffsetX(),u=e.getOffsetY(),d=e.getRotateWithView(),c=e.getKeepUpright(),p=e.getRotation();this.text_=e.getText()||"",this.textOffsetX_=h===void 0?0:h,this.textOffsetY_=u===void 0?0:u,this.textRotateWithView_=d===void 0?!1:d,this.textKeepUpright_=c===void 0?!0:c,this.textRotation_=p===void 0?0:p,this.strokeKey_=s?(typeof s.strokeStyle=="string"?s.strokeStyle:At(s.strokeStyle))+s.lineCap+s.lineDashOffset+"|"+s.lineWidth+s.lineJoin+s.miterLimit+"["+s.lineDash.join()+"]":"",this.textKey_=i.font+i.scale+(i.textAlign||"?")+(i.repeat||"?")+(i.justify||"?")+(i.textBaseline||"?"),this.fillKey_=r&&r.fillStyle?typeof r.fillStyle=="string"?r.fillStyle:"|"+At(r.fillStyle):""}this.declutterMode_=e.getDeclutterMode(),this.declutterImageWithText_=t}}},Pte=class{constructor(e,t,i,r){this.tolerance_=e,this.maxExtent_=t,this.pixelRatio_=r,this.resolution_=i,this.buildersByZIndex_={}}finish(){let e={};for(let t in this.buildersByZIndex_){e[t]=e[t]||{};let i=this.buildersByZIndex_[t];for(let r in i){let s=i[r].finish();e[t][r]=s}}return e}getBuilder(e,t){let i=e===void 0?"0":e.toString(),r=this.buildersByZIndex_[i];r===void 0&&(r={},this.buildersByZIndex_[i]=r);let s=r[t];if(s===void 0){let n=Lte[t];s=new n(this.tolerance_,this.maxExtent_,this.resolution_,this.pixelRatio_),r[t]=s}return s}};function GS(e,t,i,r){let s=e[t],n=e[t+1],a=0;for(let o=t+r;o<i;o+=r){let l=e[o],h=e[o+1];a+=Math.sqrt((l-s)*(l-s)+(h-n)*(h-n)),s=l,n=h}return a}function hD(e,t,i,r,s,n,a,o){a??=[],o??=r;let l=e[t+r],h=e[t+r+1],u=e[i-2*r],d=e[i-2*r+1],c,p,m,g,f,y,x,b,_=0;for(let T=t;T<i;T+=r){m=c,g=p,f=void 0,y=void 0,T+r<i&&(f=e[T+r],y=e[T+r+1]),n&&T===t&&(m=u,g=d),n&&T===i-r&&(f=l,y=h),c=e[T],p=e[T+1],[x,b]=kte(c,p,m,g,f,y,s),a[_++]=x,a[_++]=b;for(let w=2;w<o;w++)a[_++]=e[T+w]}return a.length!=_&&(a.length=_),a}function kte(e,t,i,r,s,n,a){let o,l;i!==void 0&&r!==void 0?(o=e-i,l=t-r):s!==void 0&&n!==void 0?(o=s-e,l=n-t):(o=1,l=0);let h=Math.hypot(o,l),u=o/h,d=l/h;if(o=-d,l=u,i===void 0||r===void 0||s===void 0||n===void 0)return[e+o*a,t+l*a];let c=BY([e,t],[i,r],[s,n]);if(Math.cos(c)>.998)return[e+u*a,t+d*a];let p=Math.cos(c/2),m=Math.sin(c/2),g=m*o+p*l,f=-p*o+m*l,y=1/m*g,x=1/m*f;return[e+y*a,t+x*a]}function uD(e,t){for(let i=0,r=e.length-2;i<r;i+=t)for(let s=e.length-2*t;s>i+t;s-=t){let n=e[i],a=e[i+1],o=e[i+t],l=e[i+t+1],h=e[s],u=e[s+1],d=e[s+t],c=e[s+t+1],p=(c-u)*(o-n)-(d-h)*(l-a);if(p===0)continue;let m=((d-h)*(a-u)-(c-u)*(n-h))/p,g=((o-n)*(a-u)-(l-a)*(n-h))/p;if(m>0&&m<1&&g>0&&g<1){let f=n+m*(o-n),y=a+m*(l-a);e[i+t]=f,e[i+t+1]=y,e.splice(i+2*t,s-i-t);break}}return e}function Ite(e,t,i,r,s,n,a,o,l,h,u,d,c=!0){let p=e[t],m=e[t+1],g=0,f=0,y=0,x=0;function b(){g=p,f=m,t+=r,p=e[t],m=e[t+1],x+=y,y=Math.sqrt((p-g)*(p-g)+(m-f)*(m-f))}do b();while(t<i-r&&x+y<n);let _=y===0?0:(n-x)/y,T=Es(g,p,_),w=Es(f,m,_),M=t-r,S=x,R=n+o*l(h,s,u);for(;t<i-r&&x+y<R;)b();_=y===0?0:(R-x)/y;let I=Es(g,p,_),B=Es(f,m,_),O=!1;if(c)if(d){let j=[T,w,I,B];kI(j,0,4,2,d,j,j),O=j[0]>j[2]}else O=T>I;let U=Math.PI,V=[],z=M+r===t;t=M,y=0,x=S,p=e[t],m=e[t+1];let Z;if(z)return b(),Z=Math.atan2(m-f,p-g),O&&(Z+=Z>0?-U:U),V[0]=[(I+T)/2,(B+w)/2,(R-n)/2,Z,s],V;s=s.replace(/\n/g," ");for(let j=0,ae=s.length;j<ae;){b();let W=Math.atan2(m-f,p-g);if(O&&(W+=W>0?-U:U),Z!==void 0){let et=W-Z;if(et+=et>U?-2*U:et<-U?2*U:0,Math.abs(et)>a)return null}Z=W;let me=j,Ce=0;for(;j<ae;++j){let et=O?ae-j-1:j,it=o*l(h,s[et],u);if(t+r<i&&x+y<n+Ce+it/2)break;Ce+=it}if(j===me)continue;let Qe=O?s.substring(ae-me,ae-j):s.substring(me,j);_=y===0?0:(n+Ce/2-x)/y;let oe=Es(g,p,_),dt=Es(f,m,_);V.push([oe,dt,Ce/2,W,Qe]),n+=Ce}return V}var jS=class{constructor(){this.instructions_=[],this.zIndex=0,this.offset_=0,this.context_=new Proxy(Yy(),{get:(e,t)=>{if(typeof Yy()[t]=="function")return this.push_(t),this.pushMethodArgs_},set:(e,t,i)=>(this.push_(t,i),!0)})}push_(...e){let t=this.instructions_,i=this.zIndex+this.offset_;t[i]||(t[i]=[]),t[i].push(...e)}pushMethodArgs_=(...e)=>(this.push_(e),this);pushFunction(e){this.push_(e)}getContext(){return this.context_}draw(e){this.instructions_.forEach(t=>{for(let i=0,r=t.length;i<r;++i){let s=t[i];if(typeof s=="function"){s(e);continue}let n=t[++i];if(typeof e[s]=="function")e[s](...n);else{if(typeof n=="function"){e[s]=n(e);continue}e[s]=n}}})}clear(){this.instructions_.length=0,this.zIndex=0,this.offset_=0}offset(){this.offset_=this.instructions_.length,this.zIndex=0}},wc=ya(),ih=[],Lo=[],Po=[],rh=[];function dD(e){return e[3].declutterBox}var cD=RegExp("[\u0591-\u08FF\uFB1D-\uFDFF\uFE70-\uFEFC\u0800-\u0FFF\uE800-\uEFFF]");function $S(e,t){return t==="start"?t=cD.test(e)?"right":"left":t==="end"&&(t=cD.test(e)?"left":"right"),E1[t]}function Fte(e,t,i){return i>0&&e.push(`
2122`,""),e.push(t,""),e}function Dte(e,t,i){return i%2==0&&(e+=t),e}var Ote=class{constructor(e,t,i,r,s){this.overlaps=i,this.pixelRatio=t,this.resolution=e,this.alignAndScaleFill_,this.instructions=r.instructions,this.coordinates=r.coordinates,this.coordinateCache_={},this.renderedTransform_=Qs(),this.hitDetectionInstructions=r.hitDetectionInstructions,this.pixelCoordinates_=null,this.viewRotation_=0,this.fillStates=r.fillStates||{},this.strokeStates=r.strokeStates||{},this.textStates=r.textStates||{},this.widths_={},this.labels_={},this.zIndexContext_=s?new jS:null}getZIndexContext(){return this.zIndexContext_}createLabel(e,t,i,r){let s=e+t+i+r;if(this.labels_[s])return this.labels_[s];let n=r?this.strokeStates[r]:null,a=i?this.fillStates[i]:null,o=this.textStates[t],l=this.pixelRatio,h=[o.scale[0]*l,o.scale[1]*l],u=o.justify?E1[o.justify]:$S(Array.isArray(e)?e[0]:e,o.textAlign||"center"),d=r&&n.lineWidth?n.lineWidth:0,c=Array.isArray(e)?e:String(e).split(`
2123`).reduce(Fte,[]),{width:p,height:m,widths:g,heights:f,lineWidths:y}=aQ(o,c),x=p+d,b=[],_=(x+2)*h[0],T=(m+d)*h[1],w={width:_<0?Math.floor(_):Math.ceil(_),height:T<0?Math.floor(T):Math.ceil(T),contextInstructions:b};(h[0]!=1||h[1]!=1)&&b.push("scale",h),r&&(b.push("strokeStyle",n.strokeStyle),b.push("lineWidth",d),b.push("lineCap",n.lineCap),b.push("lineJoin",n.lineJoin),b.push("miterLimit",n.miterLimit),b.push("set
2123LineDash",[n.lineDash]),b.push("lineDashOffset",n.lineDashOffset)),i&&b.push("fillStyle",a.fillStyle),b.push("textBaseline","middle"),b.push("textAlign","center");let M=.5-u,S=u*x+M*d,R=[],I=[],B=0,O=0,U=0,V=0,z;for(let Z=0,j=c.length;Z<j;Z+=2){let ae=c[Z];if(ae===`
2124`){O+=B,B=0,S=u*x+M*d,++V;continue}let W=c[Z+1]||o.font;W!==z&&(r&&R.push("font",W),i&&I.push("font",W),z=W),B=Math.max(B,f[U]);let me=[ae,S+M*g[U]+u*(g[U]-y[V]),.5*(d+B)+O];S+=g[U],r&&R.push("strokeText",me),i&&I.push("fillText",me),++U}return Array.prototype.push.apply(b,R),Array.prototype.push.apply(b,I),this.labels_[s]=w,w}replayTextBackground_(e,t,i,r,s,n,a){e.beginPath(),e.moveTo.apply(e,t),e.lineTo.apply(e,i),e.lineTo.apply(e,r),e.lineTo.apply(e,s),e.lineTo.apply(e,t),n&&(this.alignAndScaleFill_=n[2],e.fillStyle=n[1],this.fill_(e)),a&&(this.setStrokeStyle_(e,a),e.stroke())}calculateImageOrLabelDimensions_(e,t,i,r,s,n,a,o,l,h,u,d,c,p,m,g){a*=d[0],o*=d[1];let f=i-a,y=r-o,x=s+l>e?e-l:s,b=n+h>t?t-h:n,_=p[3]+x*d[0]+p[1],T=p[0]+b*d[1]+p[2],w=f-p[3],M=y-p[0];(m||u!==0)&&(ih[0]=w,rh[0]=w,ih[1]=M,Lo[1]=M,Lo[0]=w+_,Po[0]=Lo[0],Po[1]=M+T,rh[1]=Po[1]);let S;return u===0?Ml(Math.min(w,w+_),Math.min(M,M+T),Math.max(w,w+_),Math.max(M,M+T),wc):(S=So(Qs(),i,r,1,1,u,-i,-r),Ki(S,ih),Ki(S,Lo),Ki(S,Po),Ki(S,rh),Ml(Math.min(ih[0],Lo[0],Po[0],rh[0]),Math.min(ih[1],Lo[1],Po[1],rh[1]),Math.max(ih[0],Lo[0],Po[0],rh[0]),Math.max(ih[1],Lo[1],Po[1],rh[1]),wc)),c&&(f=Math.round(f),y=Math.round(y)),{drawImageX:f,drawImageY:y,drawImageW:x,drawImageH:b,originX:l,originY:h,declutterBox:{minX:wc[0],minY:wc[1],maxX:wc[2],maxY:wc[3],value:g},canvasTransform:S,scale:d}}replayImageOrLabel_(e,t,i,r,s,n,a){let o=!!(n||a),l=r.declutterBox,h=a?a[2]*r.scale[0]/2:0;return l.minX-h<=t[0]&&l.maxX+h>=0&&l.minY-h<=t[1]&&l.maxY+h>=0&&(o&&this.replayTextBackground_(e,ih,Lo,Po,rh,n,a),oQ(e,r.canvasTransform,s,i,r.originX,r.originY,r.drawImageW,r.drawImageH,r.drawImageX,r.drawImageY,r.scale)),!0}fill_(e){let t=this.alignAndScaleFill_;if(t){let i=Ki(this.renderedTransform_,[0,0]),r=512*this.pixelRatio;e.save(),e.translate(i[0]%r,i[1]%r),t!==1&&e.scale(t,t)}e.fill(),t&&e.restore()}setStrokeStyle_(e,t){e.strokeStyle=t[1],t[1]&&(e.lineWidth=t[2],e.lineCap=t[3],e.lineJoin=t[4],e.miterLimit=t[5],e.lineDashOffset=t[7],e.setLineDash(t[6]))}drawLabelWithPointPlacement_(e,t,i,r){let s=this.textStates[t],n=this.createLabel(e,t,r,i),a=this.strokeStates[i],o=this.pixelRatio,l=$S(Array.isArray(e)?e[0]:e,s.textAlign||"center"),h=E1[s.textBaseline||"middle"],u=a&&a.lineWidth?a.lineWidth:0;return{label:n,anchorX:l*(n.width/o-2*s.scale[0])+2*(.5-l)*u,anchorY:h*n.height/o+2*(.5-h)*u}}execute_(e,t,i,r,s,n,a,o){let l=this.zIndexContext_,h;this.pixelCoordinates_&&nu(i,this.renderedTransform_)?h=this.pixelCoordinates_:(this.pixelCoordinates_||=[],h=Bl(this.coordinates,0,this.coordinates.length,2,i,this.pixelCoordinates_),nZ(this.renderedTransform_,i));let u=0,d=r.length,c=0,p,m=[],g,f,y,x,b,_,T,w,M,S,R,I,B,O=0,U=0,V=this.coordinateCache_,z=this.viewRotation_,Z=Math.round(Math.atan2(-i[1],i[0])*1e12)/1e12,j={context:e,pixelRatio:this.pixelRatio,resolution:this.resolution,rotation:z},ae=this.instructions!=r||this.overlaps?0:200,W,me,Ce,Qe;for(;u<d;){let oe=r[u];switch(oe[0]){case Ne.BEGIN_GEOMETRY:W=oe[1],Qe=oe[3],W.getGeometry()?a!==void 0&&!Xi(a,Qe.getExtent())?u=oe[2]+1:++u:u=oe[2],l&&(l.zIndex=oe[4]);break;case Ne.BEGIN_PATH:O>ae&&(this.fill_(e),O=0),U>ae&&(e.stroke(),U=0),!O&&!U&&(e.beginPath(),b=NaN,_=NaN),++u;break;case Ne.CIRCLE:c=oe[1],y=oe[2]??0;let dt=h[c],et=h[c+1],it=h[c+2]-y,Nt=h[c+3]-y,ci=it-dt,Ri=Nt-et,Kt=Math.sqrt(ci*ci+Ri*Ri);e.moveTo(dt+Kt,et),e.arc(dt,et,Kt,0,2*Math.PI,!0),++u;break;case Ne.CLOSE_PATH:e.closePath(),++u;break;case Ne.CUSTOM:c=oe[1],p=oe[2];let Fr=oe[3],bi=oe[4],E=oe[5];j.geometry=Fr,j.feature=W,u in V||(V[u]=[]);let D=V[u];E?E(h,c,p,2,D):(D[0]=h[c],D[1]=h[c+1],D.length=2),l&&(l.zIndex=oe[6]),bi(D,j),++u;break;case Ne.DRAW_IMAGE:c=oe[1],p=oe[2],M=oe[3],g=oe[4],f=oe[5];let $=oe[6],Q=oe[7],Y=oe[8],J=oe[9],ce=oe[10],ee=oe[11],le=oe[12],te=oe[13];x=oe[14]||"declutter";let Me=oe[15];if(!M&&oe.length>=20){S=oe[19],R=oe[20],I=oe[21],B=oe[22];let Ni=this.drawLabelWithPointPlacement_(S,R,I,B);M=Ni.label,oe[3]=M;let oh=oe[23];g=(Ni.anchorX-oh)*this.pixelRatio,oe[4]=g;let ks=oe[24];f=(Ni.anchorY-ks)*this.pixelRatio,oe[5]=f,$=M.height,oe[6]=$,te=M.width,oe[13]=te}let ye;oe.length>25&&(ye=oe[25]);let _e,Ee,Ye;oe.length>17?(_e=oe[16],Ee=oe[17],Ye=oe[18]):(_e=Mu,Ee=null,Ye=null),ce&&Z?ee+=z:!ce&&!Z&&(ee-=z);let St=0;for(;c<p;c+=2){if(ye&&ye[St++]<te/this.pixelRatio)continue;let Ni=this.calculateImageOrLabelDimensions_(M.width,M.height,h[c],h[c+1],te,$,g,f,Y,J,ee,le,
2124s,_e,!!Ee||!!Ye,W),oh=[e,t,M,Ni,Q,Ee,Ye];if(o){let ks,Ln,Is;if(Me){let pi=p-c;if(!Me[pi]){Me[pi]={args:oh,declutterMode:x};continue}let Dr=Me[pi];ks=Dr.args,Ln=Dr.declutterMode,delete Me[pi],Is=dD(ks)}let Pa,ka;if(ks&&(Ln!=="declutter"||!o.collides(Is))&&(Pa=!0),(x!=="declutter"||!o.collides(Ni.declutterBox))&&(ka=!0),Ln==="declutter"&&x==="declutter"){let pi=Pa&&ka;Pa=pi,ka=pi}Pa&&(Ln!=="none"&&o.insert(Is),this.replayImageOrLabel_.apply(this,ks)),ka&&(x!=="none"&&o.insert(Ni.declutterBox),this.replayImageOrLabel_.apply(this,oh))}else this.replayImageOrLabel_.apply(this,oh)}++u;break;case Ne.DRAW_CHARS:let ct=oe[1],Ft=oe[2],Dt=oe[3],br=oe[4];B=oe[5];let Ei=oe[6],An=oe[7],Aa=oe[8];I=oe[9];let _i=oe[10];S=oe[11],Array.isArray(S)&&(S=S.reduce(Dte,"")),R=oe[12];let Wt=[oe[13],oe[13]];x=oe[14]||"declutter";let Io=oe[15],Na=this.textStates[R],Ai=Na.font,La=[Na.scale[0]*An,Na.scale[1]*An],ht;Ai in this.widths_?ht=this.widths_[Ai]:(ht={},this.widths_[Ai]=ht);let zi=GS(h,ct,Ft,2),V1=Math.abs(La[0])*CF(Ai,S,ht);if(br||V1<=zi){let Ni=this.textStates[R].textAlign,oh=(zi-V1)*$S(S,Ni),ks=Ite(h,ct,Ft,2,S,oh,Ei,Math.abs(La[0]),CF,Ai,ht,Z?0:this.viewRotation_,Io);e:if(ks){let Ln=[],Is,Pa,ka,pi,Dr;if(I)for(Is=0,Pa=ks.length;Is<Pa;++Is){Dr=ks[Is],ka=Dr[4],pi=this.createLabel(ka,R,"",I),g=Dr[2]+(La[0]<0?-_i:_i),f=Dt*pi.height+(.5-Dt)*2*_i*La[1]/La[0]-Aa;let Ia=this.calculateImageOrLabelDimensions_(pi.width,pi.height,Dr[0],Dr[1],pi.width,pi.height,g,f,0,0,Dr[3],Wt,!1,Mu,!1,W);if(o&&x==="declutter"&&o.collides(Ia.declutterBox))break e;Ln.push([e,t,pi,Ia,1,null,null])}if(B)for(Is=0,Pa=ks.length;Is<Pa;++Is){Dr=ks[Is],ka=Dr[4],pi=this.createLabel(ka,R,B,""),g=Dr[2],f=Dt*pi.height-Aa;let Ia=this.calculateImageOrLabelDimensions_(pi.width,pi.height,Dr[0],Dr[1],pi.width,pi.height,g,f,0,0,Dr[3],Wt,!1,Mu,!1,W);if(o&&x==="declutter"&&o.collides(Ia.declutterBox))break e;Ln.push([e,t,pi,Ia,1,null,null])}o&&x!=="none"&&o.load(Ln.map(dD));for(let Ia=0,LO=Ln.length;Ia<LO;++Ia)this.replayImageOrLabel_.apply(this,Ln[Ia])}}++u;break;case Ne.END_GEOMETRY:if(n!==void 0){W=oe[1];let Ni=n(W,Qe,x);if(Ni)return Ni}++u;break;case Ne.FILL:ae?O++:this.fill_(e),++u;break;case Ne.MOVE_TO_LINE_TO:c=oe[1],p=oe[2],y=oe[3];let Nn,Ac,xg;if(y){let Ni=oe[4]??!1;hD(h,c,p,2,y,Ni,m),uD(m,2),Nn=m,Ac=0,xg=Nn.length}else Nn=h,Ac=c,xg=p;me=Nn[Ac],Ce=Nn[Ac+1],e.moveTo(me,Ce),b=me+.5|0,_=Ce+.5|0;for(let Ni=Ac+2;Ni<xg;Ni+=2)me=Nn[Ni],Ce=Nn[Ni+1],T=me+.5|0,w=Ce+.5|0,(Ni==xg-2||T!==b||w!==_)&&(e.lineTo(me,Ce),b=T,_=w);++u;break;case Ne.SET_FILL_STYLE:this.alignAndScaleFill_=oe[2],O?(this.fill_(e),O=0,U&&=(e.stroke(),0)):U&&oe[1]&&(e.stroke(),U=0),e.fillStyle=oe[1],++u;break;case Ne.SET_STROKE_STYLE:O&&oe[1]&&(this.fill_(e),O=0),U&&=(e.stroke(),0),this.setStrokeStyle_(e,oe),++u;break;case Ne.STROKE:ae?U++:e.stroke(),++u;break;default:++u;break}}O&&this.fill_(e),U&&e.stroke()}execute(e,t,i,r,s,n){this.viewRotation_=r,this.execute_(e,t,i,this.instructions,s,void 0,void 0,n)}executeHitDetection(e,t,i,r,s){return this.viewRotation_=i,this.execute_(e,[e.canvas.width,e.canvas.height],t,this.hitDetectionInstructions,!0,r,s)}},Sc=["Polygon","Circle","LineString","Image","Text","Default"],WS=["Image","Text"];Sc.filter(e=>!WS.includes(e));var pD=!1,mD=!1;function Bte(){let e=0,t=i=>{let r=Ui(1,1,null,{willReadFrequently:i}),s=0,n=performance.now();for(;performance.now()-n<50;++s)r.fillStyle=`rgba(255,0,${s%256},1)`,r.fillRect(0,0,1,1),r.getImageData(0,0,1,1);return e=s>e?s:e,s};pD={[t(!0)]:!0,[t(!1)]:!1,[t(void 0)]:void 0}[e],mD=!0}var Ute=class{constructor(e,t,i,r,s,n,a){this.maxExtent_=e,this.overlaps_=r,this.pixelRatio_=i,this.resolution_=t,this.renderBuffer_=n,this.executorsByZIndex_={},this.hitDetectionContext_=null,this.hitDetectionTransform_=Qs(),this.renderedContext_=null,this.deferredZIndexContexts_={},this.createExecutors_(s,a)}clip(e,t){let i=this.getClipCoords(t);e.beginPath(),e.moveTo(i[0],i[1]),e.lineTo(i[2],i[3]),e.lineTo(i[4],i[5]),e.lineTo(i[6],i[7]),e.clip()}createExecutors_(e,t){for(let i in e){let r=this.executorsByZIndex_[i];r===void 0&&(r={},this.executorsByZIndex_[i]=r);let s=e[i];for(let n in s){let a=s[n];
2124r[n]=new Ote(this.resolution_,this.pixelRatio_,this.overlaps_,a,t)}}}hasExecutors(e){for(let t in this.executorsByZIndex_){let i=this.executorsByZIndex_[t];for(let r=0,s=e.length;r<s;++r)if(e[r]in i)return!0}return!1}forEachFeatureAtCoordinate(e,t,i,r,s,n){mD===!1&&Bte(),r=Math.round(r);let a=r*2+1,o=So(this.hitDetectionTransform_,r+.5,r+.5,1/t,-1/t,-i,-e[0],-e[1]),l=!this.hitDetectionContext_;l&&(this.hitDetectionContext_=Ui(a,a,null,{willReadFrequently:pD}));let h=this.hitDetectionContext_;h.canvas.width!==a||h.canvas.height!==a?(h.canvas.width=a,h.canvas.height=a):l||h.clearRect(0,0,a,a);let u;this.renderBuffer_!==void 0&&(u=ya(),lm(u,e),Zh(u,t*(this.renderBuffer_+r),u));let d=Vte(r),c;function p(_,T,w){let M=h.getImageData(0,0,a,a).data;for(let S=0,R=d.length;S<R;S++)if(M[d[S]]>0){if(!n||w==="none"||c!=="Image"&&c!=="Text"||n.includes(_)){let I=(d[S]-3)/4,B=r-I%a,O=r-(I/a|0),U=s(_,T,B*B+O*O);if(U)return U}h.clearRect(0,0,a,a);break}}let m=Object.keys(this.executorsByZIndex_).map(Number);m.sort(va);let g,f,y,x,b;for(g=m.length-1;g>=0;--g){let _=m[g].toString();for(y=this.executorsByZIndex_[_],f=Sc.length-1;f>=0;--f)if(c=Sc[f],x=y[c],x!==void 0&&(b=x.executeHitDetection(h,o,i,p,u),b))return b}}getClipCoords(e){let t=this.maxExtent_;if(!t)return null;let i=t[0],r=t[1],s=t[2],n=t[3],a=[i,r,i,n,s,n,s,r];return Bl(a,0,8,2,e,a),a}isEmpty(){return wy(this.executorsByZIndex_)}execute(e,t,i,r,s,n,a){let o=Object.keys(this.executorsByZIndex_).map(Number);o.sort(a?fK:va),n||=Sc;let l=Sc.length;for(let h=0,u=o.length;h<u;++h){let d=o[h].toString(),c=this.executorsByZIndex_[d];for(let p=0,m=n.length;p<m;++p){let g=n[p],f=c[g];if(f!==void 0){let y=a===null?void 0:f.getZIndexContext(),x=y?y.getContext():e,b=this.maxExtent_&&g!=="Image"&&g!=="Text";if(b&&(x.save(),this.clip(x,i)),!y||g==="Text"||g==="Image"?f.execute(x,t,i,r,s,a):y.pushFunction(_=>f.execute(_,t,i,r,s,a)),b&&x.restore(),y){y.offset();let _=o[h]*l+Sc.indexOf(g);this.deferredZIndexContexts_[_]||(this.deferredZIndexContexts_[_]=[]),this.deferredZIndexContexts_[_].push(y)}}}}this.renderedContext_=e}getDeferredZIndexContexts(){return this.deferredZIndexContexts_}getRenderedContext(){return this.renderedContext_}renderDeferred(){let e=this.deferredZIndexContexts_,t=Object.keys(e).map(Number).sort(va);for(let i=0,r=t.length;i<r;++i)e[t[i]].forEach(s=>{s.draw(this.renderedContext_),s.clear()}),e[t[i]].length=0}},HS={};function Vte(e){if(HS[e]!==void 0)return HS[e];let t=e*2+1,i=e*e,r=Array(i+1);for(let n=0;n<=e;++n)for(let a=0;a<=e;++a){let o=n*n+a*a;if(o>i)break;let l=r[o];l||(l=[],r[o]=l),l.push(((e+n)*t+(e+a))*4+3),n>0&&l.push(((e-n)*t+(e+a))*4+3),a>0&&(l.push(((e+n)*t+(e-a))*4+3),n>0&&l.push(((e-n)*t+(e-a))*4+3))}let s=[];for(let n=0,a=r.length;n<a;++n)r[n]&&s.push(...r[n]);return HS[e]=s,s}var zte=class extends aD{constructor(e,t,i,r,s,n,a){super(),this.context_=e,this.pixelRatio_=t,this.extent_=i,this.transform_=r,this.transformRotation_=r?yy(Math.atan2(r[1],r[0]),10):0,this.viewRotation_=s,this.squaredTolerance_=n,this.userTransform_=a,this.contextFillState_=null,this.contextStrokeState_=null,this.contextTextState_=null,this.fillState_=null,this.strokeState_=null,this.image_=null,this.imageAnchorX_=0,this.imageAnchorY_=0,this.imageHeight_=0,this.imageOpacity_=0,this.imageOriginX_=0,this.imageOriginY_=0,this.imageRotateWithView_=!1,this.imageRotation_=0,this.imageScale_=[0,0],this.imageWidth_=0,this.text_="",this.textOffsetX_=0,this.textOffsetY_=0,this.textRotateWithView_=!1,this.textRotation_=0,this.textScale_=[0,0],this.textFillState_=null,this.textStrokeState_=null,this.textState_=null,this.pixelCoordinates_=[],this.tmpLocalTransform_=Qs()}drawImages_(e,t,i,r){if(!this.image_)return;let s=Bl(e,t,i,r,this.transform_,this.pixelCoordinates_),n=this.context_,a=this.tmpLocalTransform_,o=n.globalAlpha;this.imageOpacity_!=1&&(n.globalAlpha=o*this.imageOpacity_);let l=this.imageRotation_;this.transformRotation_===0&&(l-=this.viewRotation_),this.imageRotateWithView_&&(l+=this.viewRotation_);for(let h=0,u=s.length;h<u;h+=2){let d=s[h]-this.imageAnchorX_,c=s[h+1]-this.imageAnchorY_;if(l!==0||this.imageScale_[0]!=1||this.imageScale_[1]!=1){let p=d+this.imageAnchorX_,m=c+this.imageAnchorY_;So(a,p,m,1,1,l,-p,-m),n.save(),n.transform.apply(n,a),n.translate(p,m),n.scale(this.imageScale_[0],this.imageScale_[1]),n.drawImage(this.image_,this.imageOriginX_,this.imageOriginY_,this.imageWidth_,this.imageHeight_,-this.imageAnchorX_,-this.imageAnchorY_,this.imageWidth_,this.imageHeight_),n.restore(
2124)}else n.drawImage(this.image_,this.imageOriginX_,this.imageOriginY_,this.imageWidth_,this.imageHeight_,d,c,this.imageWidth_,this.imageHeight_)}this.imageOpacity_!=1&&(n.globalAlpha=o)}drawText_(e,t,i,r){if(!this.textState_||this.text_==="")return;this.textFillState_&&this.setContextFillState_(this.textFillState_),this.textStrokeState_&&this.setContextStrokeState_(this.textStrokeState_),this.setContextTextState_(this.textState_);let s=Bl(e,t,i,r,this.transform_,this.pixelCoordinates_),n=this.context_,a=this.textRotation_;for(this.transformRotation_===0&&(a-=this.viewRotation_),this.textRotateWithView_&&(a+=this.viewRotation_);t<i;t+=r){let o=s[t]+this.textOffsetX_,l=s[t+1]+this.textOffsetY_;a!==0||this.textScale_[0]!=1||this.textScale_[1]!=1?(n.save(),n.translate(o-this.textOffsetX_,l-this.textOffsetY_),n.rotate(a),n.translate(this.textOffsetX_,this.textOffsetY_),n.scale(this.textScale_[0],this.textScale_[1]),this.textStrokeState_&&n.strokeText(this.text_,0,0),this.textFillState_&&n.fillText(this.text_,0,0),n.restore()):(this.textStrokeState_&&n.strokeText(this.text_,o,l),this.textFillState_&&n.fillText(this.text_,o,l))}}moveToLineTo_(e,t,i,r,s,n){let a=this.context_,o=Bl(e,t,i,r,this.transform_,this.pixelCoordinates_);Math.abs(n)>0&&(o=hD(o,0,o.length,2,n,s,o),uD(o,2)),a.moveTo(o[0],o[1]);let l=o.length;s&&(l-=2);for(let h=2;h<l;h+=2)a.lineTo(o[h],o[h+1]);return s&&a.closePath(),i}drawRings_(e,t,i,r,s){for(let n=0,a=i.length;n<a;++n)t=this.moveToLineTo_(e,t,i[n],r,!0,s);return t}drawCircle(e){if(this.squaredTolerance_&&(e=e.simplifyTransformed(this.squaredTolerance_,this.userTransform_)),Xi(this.extent_,e.getExtent())){if(this.fillState_||this.strokeState_){this.fillState_&&this.setContextFillState_(this.fillState_),this.strokeState_&&this.setContextStrokeState_(this.strokeState_);let t=fZ(e,this.transform_,this.pixelCoordinates_),i=t[2]-t[0],r=t[3]-t[1],s=Math.sqrt(i*i+r*r),n=this.context_;n.beginPath(),n.arc(t[0],t[1],s,0,2*Math.PI),this.fillState_&&n.fill(),this.strokeState_&&n.stroke()}this.text_!==""&&this.drawText_(e.getCenter(),0,2,2)}}setStyle(e){this.setFillStrokeStyle(e.getFill(),e.getStroke()),this.setImageStyle(e.getImage()),this.setTextStyle(e.getText())}setTransform(e){this.transform_=e}drawGeometry(e){switch(e.getType()){case"Point":this.drawPoint(e);break;case"LineString":this.drawLineString(e);break;case"Polygon":this.drawPolygon(e);break;case"MultiPoint":this.drawMultiPoint(e);break;case"MultiLineString":this.drawMultiLineString(e);break;case"MultiPolygon":this.drawMultiPolygon(e);break;case"GeometryCollection":this.drawGeometryCollection(e);break;case"Circle":this.drawCircle(e);break;default:}}drawFeature(e,t){let i=t.getGeometryFunction()(e);i&&(this.setStyle(t),this.drawGeometry(i))}drawGeometryCollection(e){let t=e.getGeometriesArray();for(let i=0,r=t.length;i<r;++i)this.drawGeometry(t[i])}drawPoint(e){this.squaredTolerance_&&(e=e.simplifyTransformed(this.squaredTolerance_,this.userTransform_));let t=e.getFlatCoordinates(),i=e.getStride();this.image_&&this.drawImages_(t,0,t.length,i),this.text_!==""&&this.drawText_(t,0,t.length,i)}drawMultiPoint(e){this.squaredTolerance_&&(e=e.simplifyTransformed(this.squaredTolerance_,this.userTransform_));let t=e.getFlatCoordinates(),i=e.getStride();this.image_&&this.drawImages_(t,0,t.length,i),this.text_!==""&&this.drawText_(t,0,t.length,i)}drawLineString(e){if(this.squaredTolerance_&&(e=e.simplifyTransformed(this.squaredTolerance_,this.userTransform_)),Xi(this.extent_,e.getExtent())){if(this.strokeState_){this.setContextStrokeState_(this.strokeState_);let t=this.context_,i=e.getFlatCoordinates();t.beginPath(),this.moveToLineTo_(i,0,i.length,e.getStride(),!1,this.strokeState_.strokeOffset),t.stroke()}if(this.text_!==""){let t=e.getFlatMidpoint();this.drawText_(t,0,2,2)}}}drawMultiLineString(e){this.squaredTolerance_&&(e=e.simplifyTransformed(this.squaredTolerance_,this.userTransform_));let t=e.getExtent();if(Xi(this.extent_,t)){if(this.strokeState_){this.setContextStrokeState_(this.strokeState_);let i=this.context_,r=e.getFlatCoordinates(),s=0,n=e.getEnds(),a=e.getStride();i.beginPath();for(let o=0,l=n.length;o<l;++o)s=this.moveToLineTo_(r,s,n[o],a,!1,this.strokeState_.strokeOffset);i.stroke()}if(this.text_!==""){let i=e.getFlatMidpoints();this.drawText_(i,0,i.length,2)}}}drawPolygon(e){if(this.squaredTolerance_&&(e=e.simplifyTransformed(this.squaredTolerance_,this.userTransform_)),Xi(this.extent_,e.getExtent())){if(this.strokeState_||this.fillState_){this.fillState_&&this.setContextFillState_(this.fillState_),this.strokeState_&&this.setContextStrokeState_(this.strokeState_);let t=this.context_;t.beginPath(),this.drawRings_(e.getOrientedFlatCoordinates(),0,e.getEnds(),e.getStride(),this.strokeState_?.strokeOffset),this.fillState_&&t.fill(),this.strokeState_&&t.stroke()}if(this.text_!==""){let t=e.getFlatInteriorPoint();this.drawText_(t,0,2,2)}}}drawMultiPolygon(e){if(this.squaredTolerance_&&(e=e.simplifyTransformed(this.squaredTolerance_,this.userTransform_)),Xi(this.extent_,e.getExtent())){if(this.strokeState_||this.fillState_){this.fillState_&&this.setContextFillState_(this.fillState_),this.strokeState_&&this.setContextStrokeState_(this.strokeState_);let t=this.context_,i=e.getOrientedFlatCoordinates(),r=0,s=e.getEndss(),n=e.getStride();t.beginPath();for(let a=0,o=s.length;a<o;++a){let l=s[a];r=this.drawRings_(i,r,l,n,this.strokeState_?.strokeOffset)}this.fillState_&&t.fill(),this.strokeState_&&t.stroke()}if(this.text_!==""){let t=e.getFlatInteriorPoints();this.drawText_(t,0,t.length,2)}}}setContextFillState_(e){let t=this.context_,i=this.contextFillState_;i?i.fillStyle!=e.fillStyle&&(i.fillStyle=e.fillStyle,t.fillStyle=e.fillStyle):(t.fillStyle=e.fillStyle,this.contextFillState_={fillStyle:e.fillStyle})}setContextStrokeState_(e){let t=this.context_,i=this.contextStrokeState_;i?(i.lineCap!=e.lineCap&&(i.lineCap=e.lineCap,t.lineCap=e.lineCap),nu(i.lineDash,e.lineDash)||t.setLineDash(i.lineDash=e.lineDash),i.lineDashOffset!=e.lineDashOffset&&(i.lineDashOffset=e.lineDashOffset,t.lineDashOffset=e.lineDashOffset),i.lineJoin!=e.lineJoin&&(i.lineJoin=e.lineJoin,t.lineJoin=e.lineJoin),i.lineWidth!=e.lineWidth&&(i.lineWidth=e.lineWidth,t.lineWidth=e.lineWidth),i.miterLimit!=e.miter
2124Limit&&(i.miterLimit=e.miterLimit,t.miterLimit=e.miterLimit),i.strokeStyle!=e.strokeStyle&&(i.strokeStyle=e.strokeStyle,t.strokeStyle=e.strokeStyle)):(t.lineCap=e.lineCap,t.setLineDash(e.lineDash),t.lineDashOffset=e.lineDashOffset,t.lineJoin=e.lineJoin,t.lineWidth=e.lineWidth,t.miterLimit=e.miterLimit,t.strokeStyle=e.strokeStyle,this.contextStrokeState_={lineCap:e.lineCap,lineDash:e.lineDash,lineDashOffset:e.lineDashOffset,lineJoin:e.lineJoin,lineWidth:e.lineWidth,miterLimit:e.miterLimit,strokeStyle:e.strokeStyle})}setContextTextState_(e){let t=this.context_,i=this.contextTextState_,r=e.textAlign?e.textAlign:TF;i?(i.font!=e.font&&(i.font=e.font,t.font=e.font),i.textAlign!=r&&(i.textAlign=r,t.textAlign=r),i.textBaseline!=e.textBaseline&&(i.textBaseline=e.textBaseline,t.textBaseline=e.textBaseline)):(t.font=e.font,t.textAlign=r,t.textBaseline=e.textBaseline,this.contextTextState_={font:e.font,textAlign:r,textBaseline:e.textBaseline})}setFillStrokeStyle(e,t){if(!e)this.fillState_=null;else{let i=e.getColor();this.fillState_={fillStyle:Ra(i||tn)}}if(!t)this.strokeState_=null;else{let i=t.getColor(),r=t.getLineCap(),s=t.getLineDash(),n=t.getLineDashOffset(),a=t.getLineJoin(),o=t.getWidth(),l=t.getMiterLimit(),h=s||Mo,u=t.getOffset();this.strokeState_={lineCap:r===void 0?r1:r,lineDash:this.pixelRatio_===1?h:h.map(d=>d*this.pixelRatio_),lineDashOffset:(n||0)*this.pixelRatio_,lineJoin:a===void 0?s1:a,lineWidth:(o===void 0?1:o)*this.pixelRatio_,miter
2124Limit:l===void 0?10:l,strokeStyle:Ra(i||$l),strokeOffset:(u??0)*this.pixelRatio_}}}setImageStyle(e){let t;if(!e||!(t=e.getSize())){this.image_=null;return}let i=e.getPixelRatio(this.pixelRatio_),r=e.getAnchor(),s=e.getOrigin();this.image_=e.getImage(this.pixelRatio_),this.imageAnchorX_=r[0]*i,this.imageAnchorY_=r[1]*i,this.imageHeight_=t[1]*i,this.imageOpacity_=e.getOpacity(),this.imageOriginX_=s[0],this.imageOriginY_=s[1],this.imageRotateWithView_=e.getRotateWithView(),this.imageRotation_=e.getRotation();let n=e.getScaleArray();this.imageScale_=[n[0]*this.pixelRatio_/i,n[1]*this.pixelRatio_/i],this.imageWidth_=t[0]*i}setTextStyle(e){if(!e)this.text_="";else{let t=e.getFill();if(!t)this.textFillState_=null;else{let c=t.getColor();this.textFillState_={fillStyle:Ra(c||tn)}}let i=e.getStroke();if(!i)this.textStrokeState_=null;else{let c=i.getColor(),p=i.getLineCap(),m=i.getLineDash(),g=i.getLineDashOffset(),f=i.getLineJoin(),y=i.getWidth(),x=i.getMiterLimit();this.textStrokeState_={lineCap:p===void 0?r1:p,lineDash:m||Mo,lineDashOffset:g||0,lineJoin:f===void 0?s1:f,lineWidth:y===void 0?1:y,miterLimit:x===void 0?10:x,strokeStyle:Ra(c||$l)}}let r=e.getFont(),s=e.getOffsetX(),n=e.getOffsetY(),a=e.getRotateWithView(),o=e.getRotation(),l=e.getScaleArray(),h=e.getText(),u=e.getTextAlign(),d=e.getTextBaseline();this.textState_={font:r===void 0?eQ:r,textAlign:u===void 0?TF:u,textBaseline:d===void 0?tQ:d},this.text_=h===void 0?"":Array.isArray(h)?h.reduce((c,p,m)=>c+=m%2?" ":p,""):h,this.textOffsetX_=s===void 0?0:this.pixelRatio_*s,this.textOffsetY_=n===void 0?0:this.pixelRatio_*n,this.textRotateWithView_=a===void 0?!1:a,this.textRotation_=o===void 0?0:o,this.textScale_=[this.pixelRatio_*l[0],this.pixelRatio_*l[1]]}}},sh=.5;function Gte(e,t,i,r,s,n,a,o,l){let h=l?Hk(s,l):s,u=Ui(e[0]*sh,e[1]*sh);u.imageSmoothingEnabled=!1;let d=u.canvas,c=new zte(u,sh,s,null,a,o,l?Cy(Wk(),l):null),p=i.length,m=Math.floor((256*256*256-1)/p),g={};for(let y=1;y<=p;++y){let x=i[y-1],b=x.getStyleFunction()||r;if(!b)continue;let _=b(x,n);if(!_)continue;Array.isArray(_)||(_=[_]);let T=(y*m).toString(16).padStart(7,"#00000");for(let w=0,M=_.length;w<M;++w){let S=_[w],R=S.getGeometryFunction()(x);if(!R||!Xi(h,R.getExtent()))continue;let I=S.clone(),B=I.getFill();B&&B.setColor(T);let O=I.getStroke();O&&(O.setColor(T),O.setLineDash(null)),I.setText(void 0);let U=S.getImage();if(U){let j=U.getImageSize();if(!j)continue;let ae=Ui(j[0],j[1],void 0,{alpha:!1}),W=ae.canvas;ae.fillStyle=T,ae.fillRect(0,0,W.width,W.height),I.setImage(new LF({img:W,anchor:U.getAnchor(),anchorXUnits:"pixels",anchorYUnits:"pixels",offset:U.getOrigin(),opacity:1,size:U.getSize(),scale:U.getScale(),rotation:U.getRotation(),rotateWithView:U.getRotateWithView()}))}let V=I.getZIndex()||0,z=g[V];z||(z={},g[V]=z,z.Polygon=[],z.Circle=[],z.LineString=[],z.Point=[]);let Z=R.getType();if(Z==="GeometryCollection"){let j=R.getGeometriesArrayRecursive();for(let ae=0,W=j.length;ae<W;++ae){let me=j[ae];z[me.getType().replace("Multi","")].push(me,I)}}else z[Z.replace("Multi","")].push(R,I)}}let f=Object.keys(g).map(Number).sort(va);for(let y=0,x=f.length;y<x;++y){let b=g[f[y]];for(let _ in b){let T=b[_];for(let w=0,M=T.length;w<M;w+=2){c.setStyle(T[w+1]);for(let S=0,R=t.length;S<R;++S)c.setTransform(t[S]),c.drawGeometry(T[w])}}}return u.getImageData(0,0,d.width,d.height)}function jte(e,t,i){let r=[];if(i){let s=Math.floor(Math.round(e[0])*sh),n=Math.floor(Math.round(e[1])*sh),a=(ri(s,0,i.width-1)+ri(n,0,i.height-1)*i.width)*4,o=i.data[a],l=i.data[a+1],h=i.data[a+2]+256*(l+256*o),u=Math.floor((256*256*256-1)/t.length);h&&h%u===0&&r.push(t[h/u-1])}return r}var $te=.5,gD={Point:Qte,LineString:Kte,Polygon:tie,MultiPoint:eie,MultiLineString:Zte,MultiPolygon:Jte,GeometryCollection:Yte,Circle:qte};function Wte(e,t){let i=Hte(e,t);return i*i}function Hte(e,t){return $te*e/t}function qte(e,t,i,r,s){let n=i.getFill(),a=i.getStroke();if(n||a){let l=e.getBuilder(i.getZIndex(),"Circle");l.setFillStrokeStyle(n,a),l.drawCircle(t,r,s)}let o=i.getText();if(o&&o.getText()){let l=e.getBuilder(i.getZIndex(),"Text");l.setTextStyle(o),l.drawText(t,r,s)}}function fD(e,t,i,r,s,n,a,o){let l=[],h=i.getImage();if(h){let c=!0,p=h.getImageState();p==Ge.LOADED||p==Ge.ERROR?c=!1:p==Ge.IDLE&&h.load(),c&&l.push(h.ready())}let u=i.getFill();u&&u.loading()&&l.push(u.ready());let d=l.length>0;return d&&Promise.all(l).then(()=>s(null)),Xte(e,t,i,r,n,a,o),d}function Xte(e,t,i,r,s,n,a){let o=i.getGeometryFunction()(t);if(!o)return;let l=o.simplifyTransformed(r,s);if(i.getRenderer())yD(e,l,i,t,a);else{let h=gD[l.getType()];h(e,l,i,t,a,n)}}function yD(e,t,i,r,s){if(t.getType()=="GeometryCollection"){let n=t.getGeometries();for(let a=0,o=n.length;a<o;++a)yD(e,n[a],i,r,s);return}e.getBuilder(i.getZIndex(),"Default").drawCustom(t,r,i.getRenderer(),i.getHitDetectionRenderer(),s)}function Yte(e,t,i,r,s,n){let a=t.getGeometriesArray(),o,l;for(o=0,l=a.length;o<l;++o){let h=gD[a[o].getType()];h(e,a[o],i,r,s,n)}}function Kte(e,t,i,r,s){let n=i.getStroke();if(n){let o=e.getBuilder(i.getZIndex(),"LineString");o.setFillStrokeStyle(null,n),o.drawLineString(t,r,s)}let a=i.getText();if(a&&a.getText()){let o=e.getBuilder(i.getZIndex(),"Text");o.setTextStyle(a),o.drawText(t,r,s)}}function Zte(e,t,i,r,s){let n=i.getStroke();if(n){let o=e.getBuilder(i.getZIndex(),"LineString");o.setFillStrokeStyle(null,n),o.drawMultiLineString(t,r,s)}let a=i.getText();if(a&&a.getText()){let o=e.getBuilder(i.getZIndex(),"Text");o.setTextStyle(a),o.drawText(t,r,s)}}function Jte(e,t,i,r,s){let n=i.getFill(),a=i.getStroke();if(a||n){let l=e.getBuilder(i.getZIndex(),"Polygon");l.setFillStrokeStyle(n,a),l.drawMultiPolygon(t,r,s)}let o=i.getText();if(o&&o.getText()){let l=e.getBuilder(i.getZIndex(),"Text");l.setTextStyle(o),l.drawText(t,r,s)}}function Qte(e,t,i,r,s,n){let a=i.getImage(),o=i.getText(),l=o&&o.getText(),h=n&&a&&l?{}:void 0;if(a){if(a.getImageState()!=Ge.LOADED)return;let u=e.getBuilder(i.getZIndex(),"Image");u.setImageStyle(a,h),u.drawPoint(t,r,s)}if(l){let u=e.getBuilder(i.getZIndex(),"Text");u.setTextStyle(o,h),u.drawText(t,r,s)}}function eie(e,t,i,r,s,n){let a=i.getImage(),o=a&&a.getOpacity()!==0,l=i.getText(),h=l&&l.getText(),u=n&&o&&h?{}:void 0;if(o){if(a.getImageState()!=Ge.LOADED)return;let d=e.getBuilder(i.getZIndex(),"Image");d.setImageStyle(a,u),d.drawMultiPoint(t,r,s)}if(h){let d=e.getBuilder(i.getZIndex(),"Text");d.setTextStyle(l,u),d.drawText(t,r,s)}}function tie(e,t,i,r,s){let n=i.getFill(),a=i.getStroke();if(n||a){let l=e.getBuilder(i.getZIndex(),"Polygon");l.setFillStrokeStyle(n,a),l.drawPolygon(t,r,s)}let o=i.getText();if(o&&o.getText()){let l=e.getBuilder(i.getZIndex(),"Text");l.setTextStyle(o),l.drawText(t,r,s)}}function qS(e){return e instanceof Image||e instanceof HTMLCanvasElement||e instanceof HTMLVideoElement||e instanceof ImageBitmap?e:null}var iie=Error("disposed"),rie=[256,256],xD=class extends Zm{constructor(e){let t=he.IDLE;super(e.tileCoord,t,{transition:e.transition,interpolate:e.interpolate}),this.loader_=e.loader,this.data_=null,this.error_=null,this.size_=e.size||null,this.controller_=e.controller||null}getSize(){if(this.size_)return this.size_;let e=qS(this.data_);return e?[e.width,e.height]:rie}getData(){return this.data_}getError(){return this.error_}load(){if(this.state!==he.IDLE&&this.state!==he.ERROR)return;this.state=he.LOADING,this.changed();let e=this;this.loader_().then(function(t){e.data_=t,e.state=he.LOADED,e.changed()}).catch(function(t){e.error_=t,e.state=he.ERROR,e.changed()})}disposeInternal(){this.controller_&&=(this.controller_.abort(iie),null),super.disposeInternal()}},vD=class{constructor(e){this.highWaterMark=e===void 0?2048:e,this.count_=0,this.entries_={},this.oldest_=null,this.newest_=null}deleteOldest(){let e=this.pop();e instanceof Ey&&e.dispose()}canExpireCache(){return this.highWaterMark>0&&this.getCount()>this.highWaterMark}expireCache(e){for(;this.canExpireCache();)this.deleteOldest()}clear(){for(;this.oldest_;)this.deleteOldest()}containsKey(e){return this.entries_.hasOwnProperty(e)}forEach(e){let t=this.oldest_;for(;t;)e(t.value_,t.key_,this),t=t.newer}get(e,t){let i=this.entries_[e];return It(i!==void 0,"Tried to get a value for a key that does not exist in the cache"),i===this.newest_||(i===this.oldest_?(this.oldest_=this.oldest_.newer,this.oldest_.older=null):(i.newer.older=i.older,i.older.newer=i.newer),i.newer=null,i.older=this.newest_,this.newest_.newer=i,this.newest_=i),i.value_}remove(e){let t=this.entries_[e];return It(t!==void 0,"Tried to get a value for a key that does not exist in the cache"),t===this.newest_?(this.newest_=t.older,this.newest_&&(this.newest_.newer=null)):t===this.oldest_?(this.oldest_=t.newer,this.oldest_&&(this.oldest_.older=null)):(t.newer.older=t.older,t.older.newer=t.newer),delete this.entries_[e],--this.count_,t.value_}getCount(){return this.count_}getKeys(){let e=Array(this.count_),t=0,i;for(i=this.newest_;i;i=i.older)e[t++]=i.key_;return e}getValues(){let e=Array(this.count_),t=0,i;for(i=this.newest_;i;i=i.older)e[t++]=i.value_;return e}peekLast(){return this.oldest_.value_}peekLastKey(){return this.oldest_.key_}peekFirstKey(){return this.newest_.key_}peek(e){return this.entries_[e]?.value_}pop(){let e=this.oldest_;return delete this.entries_[e.key_],e.newer&&(e.newer.older=null),this.oldest_=e.newer,this.oldest_||(this.newest_=null),--this.count_,e.value_}replace(e,t){this.get(e),this.entries_[e].value_=t}set(e,t){It(!(e in this.entries_),"Tried to set a value for a key that is used already");let i={key_:e,newer:null,older:this.newest_,value_:t};this.newest_?this.newest_.newer=i:this.oldest_=i,this.newest_=i,this.entries_[e]=i,++this.count_}setSize(e){this.highWaterMark=e}},Mc=null;function sie(){Mc=Ui(1,1,void 0,{willReadFrequently:!0})}var nie=class extends Hm{constructor(e){super(e),this.container=null,this.renderedResolution,this.tempTransform=Qs(),this.pixelTransform=Qs(),this.inversePixelTransform=Qs(),this.context=null,this.deferredContext_=null,this.containerReused=!1,this.frameState=null}getImageData(e,t,i){Mc||sie(),Mc.clearRect(0,0,1,1);let r;try{Mc.drawImage(e,t,i,1,1,0,0,1,1),r=Mc.getImageData(0,0,1,1).data}catch{return Mc=null,null}return r}
2124getBackground(e){let t=this.getLayer().getBackground();return typeof t=="function"&&(t=t(e.viewState.resolution)),t||void 0}useContainer(e,t,i){let r=this.getLayer().getClassName(),s,n;if(e&&e.className===r&&(!i||e&&e.style.backgroundColor&&nu(Tu(e.style.backgroundColor),Tu(i)))){let a=e.firstElementChild;Vl(a)&&(n=a.getContext("2d"))}if(n&&uZ(n.canvas.style.transform,t)?(this.container=e,this.context=n,this.containerReused=!0):this.containerReused?(this.container=null,this.context=null,this.containerReused=!1):this.container&&(this.container.style.backgroundColor=null),!this.container){s=Js?tF():document.createElement("div"),s.className=r;let a=s.style;a.position="absolute",a.width="100%",a.height="100%",n=Ui();let o=n.canvas;s.appendChild(o),a=o.style,a.position="absolute",a.left="0",a.transformOrigin="top left",this.container=s,this.context=n}!this.containerReused&&i&&!this.container.style.backgroundColor&&(this.container.style.backgroundColor=i)}clipUnrotated(e,t,i){let r=Cl(i),s=fy(i),n=gy(i),a=my(i);Ki(t.coordinateToPixelTransform,r),Ki(t.coordinateToPixelTransform,s),Ki(t.coordinateToPixelTransform,n),Ki(t.coordinateToPixelTransform,a);let o=this.inversePixelTransform;Ki(o,r),Ki(o,s),Ki(o,n),Ki(o,a),e.save(),e.beginPath(),e.moveTo(Math.round(r[0]),Math.round(r[1])
2124),e.lineTo(Math.round(s[0]),Math.round(s[1])),e.lineTo(Math.round(n[0]),Math.round(n[1])),e.lineTo(Math.round(a[0]),Math.round(a[1])),e.clip()}prepareContainer(e,t){let i=e.extent,r=e.viewState.resolution,s=e.viewState.rotation,n=e.pixelRatio,a=Math.round(Jt(i)/r*n),o=Math.round(is(i)/r*n);So(this.pixelTransform,e.size[0]/2,e.size[1]/2,1/n,1/n,s,-a/2,-o/2),PI(this.inversePixelTransform,this.pixelTransform);let l=hZ(this.pixelTransform);if(this.useContainer(t,l,this.getBackground(e)),!this.containerReused){let h=this.context.canvas;h.width!=a||h.height!=o?(h.width=a,h.height=o):this.context.clearRect(0,0,a,o),l!==h.style.transform&&(h.style.transform=l)}}dispatchRenderEvent_(e,t,i){let r=this.getLayer();if(r.hasListener(e)){let s=new WF(e,this.inversePixelTransform,i,t);r.dispatchEvent(s)}}preRender(e,t){this.frameState=t,!t.declutter&&this.dispatchRenderEvent_(Ma.PRERENDER,e,t)}postRender(e,t){t.declutter||this.dispatchRenderEvent_(Ma.POSTRENDER,e,t)}renderDeferredInternal(e){}getRenderContext(e){return e.declutter&&!this.deferredContext_&&(this.deferredContext_=new jS),e.declutter?this.deferredContext_.getContext():this.context}renderDeferred(e){e.declutter&&(this.dispatchRenderEvent_(Ma.PRERENDER,this.context,e),e.declutter&&this.deferredContext_&&(this.deferredContext_.draw(this.context),this.deferredContext_.clear()),this.renderDeferredInternal(e),this.dispatchRenderEvent_(Ma.POSTRENDER,this.context,e))}getRenderTransform(e,t,i,r,s,n,a){let o=s/2,l=n/2,h=r/t,u=-h,d=-e[0]+a,c=-e[1];return So(this.tempTransform,o,l,h,u,-i,d,c)}disposeInternal(){delete this.frameState,super.disposeInternal()}};function XS(e,t,i){if(!(i in e))return e[i]=new Set([t]),!0;let r=e[i],s=r.has(t);return s||r.add(t),!s}function aie(e,t,i){let r=e[i];return r?r.delete(t):!1}function bD(e,t){let i=e.layerStatesArray[e.layerIndex];i.extent&&(t=ds(t,su(i.extent,e.viewState.projection)));let r=i.layer.getRenderSource();if(!r.getWrapX()){let s=r.getTileGridForProjection(e.viewState.projection).getExtent();s&&(t=ds(t,s))}return t}var oie=class extends nie{constructor(e,t){super(e),t||={},this.extentChanged=!0,this.renderComplete=!1,this.renderedExtent_=null,this.renderedPixelRatio,this.renderedProjection=null,this.renderedTiles=[],this.renderedSourceKey_,this.renderedSourceRevision_,this.tempExtent=ya(),this.tempTileRange_=new xS(0,0,0,0),this.tempTileCoord_=Eo(0,0,0);let i=t.cacheSize===void 0?512:t.cacheSize;this.tileCache_=new vD(i),this.sourceTileCache_=null,this.layerExtent=null,this.maxStaleKeys=i*.5}getTileCache(){return this.tileCache_}getSourceTileCache(){return this.sourceTileCache_||=new vD(512),this.sourceTileCache_}getOrCreateTile(e,t,i,r){let s=this.tileCache_,n=this.getLayer().getSource(),a=d1(n,n.getKey(),e,t,i),o;if(s.containsKey(a))o=s.get(a);else{let l=r.viewState.projection,h=n.getProjection();if(o=n.getTile(e,t,i,r.pixelRatio,l,!h||As(h,l)?void 0:this.getSourceTileCache()),!o)return null;s.set(a,o)}return o}getTile(e,t,i,r){return this.getOrCreateTile(e,t,i,r)||null}getData(e){let t=this.frameState;if(!t)return null;let i=this.getLayer(),r=Ki(t.pixelToCoordinateTransform,e.slice()),s=i.getExtent();if(s&&!Hd(s,r))return null;let n=t.viewState,a=i.getRenderSource(),o=a.getTileGridForProjection(n.projection),l=a.getTilePixelRatio(t.pixelRatio);for(let h=o.getZForResolution(n.resolution);h>=o.getMinZoom();--h){let u=o.getTileCoordForCoordAndZ(r,h),d=this.getTile(h,u[1],u[2],t);if(!d||d.getState()!==he.LOADED)continue;let c=o.getOrigin(h),p=kr(o.getTileSize(h)),m=o.getResolution(h),g;if(d instanceof r5||d instanceof o5)g=d.getImage();else if(d instanceof xD){if(g=qS(d.getData()),!g)continue}else continue;let f=Math.floor(l*((r[0]-c[0])/m-u[1]*p[0])),y=Math.floor(l*((c[1]-r[1])/m-u[2]*p[1])),x=Math.round(l*a.getGutterForProjection(n.projection));return this.getImageData(g,f+x,y+x)}return null}prepareFrame(e){this.renderedProjection?e.viewState.projection!==this.renderedProjection&&(this.tileCache_.clear(),this.renderedProjection=e.viewState.projection):this.renderedProjection=e.viewState.projection;let t=this.getLayer().getSource();if(!t)return!1;let i=t.getRevision();return this.renderedSourceRevision_?this.renderedSourceRevision_!==i&&(this.renderedSourceRevision_=i,this.renderedSourceKey_===t.getKey()&&(this.tileCache_.clear(),this.sourceTileCache_?.clear())):this.renderedSourceRevision_=i,!0}
2124enqueueTilesForNextExtent(){return!0}enqueueTiles(e,t,i,r,s){let n=e.viewState,a=this.getLayer(),o=a.getRenderSource(),l=o.getTileGridForProjection(n.projection),h=At(o);h in e.wantedTiles||(e.wantedTiles[h]={});let u=e.wantedTiles[h],d=a.getMapInternal(),c=Math.max(i-s,l.getMinZoom(),l.getZForResolution(Math.min(a.getMaxResolution(),d?d.getView().getResolutionForZoom(Math.max(a.getMinZoom(),0)):l.getResolution(0)),o.zDirection)),p=n.rotation,m=p?Sk(n.center,n.resolution,p,e.size):void 0;for(let g=i;g>=c;--g){let f=l.getTileRangeForExtentAndZ(t,g,this.tempTileRange_),y=l.getResolution(g);for(let x=f.minX;x<=f.maxX;++x)for(let b=f.minY;b<=f.maxY;++b){if(p&&!l.tileCoordIntersectsViewport([g,x,b],m))continue;let _=this.getTile(g,x,b,e);if(!_||!XS(r,_,g))continue;let T=_.getKey();if(u[T]=!0,_.getState()===he.IDLE&&!e.tileQueue.isKeyQueued(T)){let w=Eo(g,x,b,this.tempTileCoord_);e.tileQueue.enqueue([_,h,l.getTileCoordCenter(w),y])}}}}findStaleTile_(e,t){let i=this.tileCache_,r=e[0],s=e[1],n=e[2],a=this.getStaleKeys();for(let o=0;o<a.length;++o){let l=d1(this.getLayer().getSource(),a[o],r,s,n);if(i.containsKey(l)){let h=i.peek(l);if(h.getState()===he.LOADED)return h.endTransition(At(this)),XS(t,h,r),!0}}return!1}findAltTiles_(e,t,i,r){let s=e.getTileRangeForTileCoordAndZ(t,i,this.tempTileRange_);if(!s)return!1;let n=!0,a=this.tileCache_,o=this.getLayer().getRenderSource(),l=o.getKey();for(let h=s.minX;h<=s.maxX;++h)for(let u=s.minY;u<=s.maxY;++u){let d=d1(o,l,i,h,u),c=!1;if(a.containsKey(d)){let p=a.peek(d);p.getState()===he.LOADED&&(XS(r,p,i),c=!0)}c||(n=!1)}return n}renderFrame(e,t){this.renderComplete=!0;let i=e.layerStatesArray[e.layerIndex],r=e.viewState,s=r.projection,n=r.resolution,a=r.center,o=e.pixelRatio,l=this.getLayer(),h=l.getSource(),u=h.getTileGridForProjection(s),d=u.getZForResolution(n,h.zDirection),c=u.getResolution(d),p=h.getKey();this.renderedSourceKey_?this.renderedSourceKey_!==p&&(this.prependStaleKey(this.renderedSourceKey_),this.renderedSourceKey_=p):this.renderedSourceKey_=p;let m=e.extent,g=h.getTilePixelRatio(o);this.prepareContainer(e,t);let f=this.context.canvas.width,y=this.context.canvas.height;this.layerExtent=i.extent?su(i.extent,s):null,this.layerExtent&&(m=ds(m,this.layerExtent));let x=c*f/2/g,b=c*y/2/g,_=[a[0]-x,a[1]-b,a[0]+x,a[1]+b],T={};this.renderedTiles.length=0;let w=l.getPreload();if(e.nextExtent&&this.enqueueTilesForNextExtent()){let Z=u.getZForResolution(r.nextResolution,h.zDirection),j=bD(e,e.nextExtent);this.enqueueTiles(e,j,Z,T,w)}let M=bD(e,m);if(this.enqueueTiles(e,M,d,T,0),w>0&&setTimeout(()=>{this.enqueueTiles(e,M,d-1,T,w-1)},0),!(d in T))return this.container;let S=At(this),R=e.time;for(let Z of T[d]){let j=Z.getState();if(j===he.EMPTY)continue;let ae=Z.tileCoord;if(j===he.LOADED&&Z.getAlpha(S,R)===1){Z.endTransition(S);continue}if(j!==he.ERROR&&(this.renderComplete=!1),this.findStaleTile_(ae,T)){aie(T,Z,d),e.animate=!0;continue}if(this.findAltTiles_(u,ae,d+1,T))continue;let W=u.getMinZoom();for(let me=d-1;me>=W&&!this.findAltTiles_(u,ae,me,T);--me);}let I=c/n*o/g,B=this.getRenderContext(e);So(this.tempTransform,f/2,y/2,I,I,0,-f/2,-y/2),this.layerExtent&&this.clipUnrotated(B,e,this.layerExtent),h.getInterpolate()||(B.imageSmoothingEnabled=!1),this.preRender(B,e);let O=Object.keys(T).map(Number);O.sort(va);let U,V=[],z=[];for(let Z=O.length-1;Z>=0;--Z){let j=O[Z],ae=h.getTilePixelSize(j,o,s),W=u.getResolution(j)/c,me=ae[0]*W*I,Ce=ae[1]*W*I,Qe=u.getTileCoordForCoordAndZ(Cl(_),j),oe=u.getTileCoordExtent(Qe),dt=Ki(this.tempTransform,[g*(oe[0]-_[0])/c,g*(_[3]-oe[3])/c]),et=g*h.getGutterForProjection(s);for(let it of T[j]){if(it.getState()!==he.LOADED)continue;let Nt=it.tileCoord,ci=Qe[1]-Nt[1],Ri=Math.round(dt[0]-(ci-1)*me),Kt=Qe[2]-Nt[2],Fr=Math.round(dt[1]-(Kt-1)*Ce),bi=Math.round(dt[0]-ci*me),E=Math.round(dt[1]-Kt*Ce),D=Ri-bi,$=Fr-E,Q=O.length===1,Y=!1;U=[bi,E,bi+D,E,bi+D,E+$,bi,E+$];for(let J=0,ce=V.length;J<ce;++J)if(!Q&&j<z[J]){let ee=V[J];Xi([bi,E,bi+D,E+$],[ee[0],ee[3],ee[4],ee[7]])&&(Y||=(B.save(),!0),B.beginPath(),B.moveTo(U[0],U[1]),B.lineTo(U[2],U[3]),B.lineTo(U[4],U[5]),B.lineTo(U[6],U[7]),B.moveTo(ee[6],ee[7]),B.lineTo(ee[4],ee[5]),B.lineTo(ee[2],ee[3]),B.lineTo(ee[0],ee[1]),B.clip())}V.push(U),z.push(j),this.drawTile(it,e,bi,E,D,$,et,Q),Y&&B.restore(
2124),this.renderedTiles.unshift(it),this.updateUsedTiles(e.usedTiles,h,it)}}return this.renderedResolution=c,this.extentChanged=!this.renderedExtent_||!py(this.renderedExtent_,_),this.renderedExtent_=_,this.renderedPixelRatio=o,this.postRender(this.context,e),this.layerExtent&&B.restore(),B.imageSmoothingEnabled=!0,this.renderComplete&&e.postRenderFunctions.push((Z,j)=>{let ae=At(h),W=j.wantedTiles[ae],me=W?Object.keys(W).length:0;this.updateCacheSize(me),this.tileCache_.expireCache(),this.sourceTileCache_?.expireCache()}),this.container}updateCacheSize(e){this.tileCache_.highWaterMark=Math.max(this.tileCache_.highWaterMark,e*2)}drawTile(e,t,i,r,s,n,a,o){let l;if(e instanceof xD){if(l=qS(e.getData()),!l)throw Error("Rendering array data is not yet supported")}else l=this.getTileImage(e);if(!l)return;let h=this.getRenderContext(t),u=At(this),d=t.layerStatesArray[t.layerIndex],c=d.opacity*(o?e.getAlpha(u,t.time):1),p=c!==h.globalAlpha;p&&(h.save(),h.globalAlpha=c),h.drawImage(l,a,a,l.width-2*a,l.height-2*a,i,r,s,n),p&&h.restore(
2124),c===d.opacity?o&&e.endTransition(u):t.animate=!0}getImage(){let e=this.context;return e?e.canvas:null}getTileImage(e){return e.getImage()}updateUsedTiles(e,t,i){let r=At(t);r in e||(e[r]={}),e[r][i.getKey()]=!0}},lie={image:["Polygon","Circle","LineString","Image","Text"],hybrid:["Polygon","LineString"],vector:[]},_D={hybrid:["Image","Text","Default"],vector:["Polygon","Circle","LineString","Image","Text","Default"]},hie=class extends oie{constructor(e,t){super(e,t),this.boundHandleStyleImageChange_=this.handleStyleImageChange_.bind(this),this.renderedLayerRevision_,this.renderedPixelToCoordinateTransform_=null,this.renderedRotation_,this.renderedOpacity_=1,this.tmpTransform_=Qs(),this.tileClipContexts_=null}enqueueTilesForNextExtent(){return this.getLayer().getRenderMode()!=="vector"}drawTile(e,t,i,r,s,n,a,o){this.updateExecutorGroup_(e,t.pixelRatio,t.viewState.projection),this.tileImageNeedsRender_(e)&&this.renderTileImage_(e,t),super.drawTile(e,t,i,r,s,n,a,o)}getTile(e,t,i,r){let s=this.getOrCreateTile(e,t,i,r);if(!s)return null;let n=r.viewState,a=n.resolution,o=r.viewHints,l=this.getLayer().getSource(),h=l.getTileGridForProjection(n.projection),u=!(o[ar.ANIMATING]||o[ar.INTERACTING]),d=h.getZForResolution(a,l.zDirection)===e;return u&&d?s.wantedResolution=a:s.wantedResolution||=h.getResolution(e),s}prepareFrame(e){let t=this.getLayer().getRevision();return this.renderedLayerRevision_!==t&&(this.renderedLayerRevision_=t,this.renderedTiles.length=0),super.prepareFrame(e)}updateExecutorGroup_(e,t,i){let r=this.getLayer(),s=r.getRevision(),n=r.getRenderOrder()||null,a=e.wantedResolution,o=e.getReplayState(r);if(!o.dirty&&o.renderedResolution===a&&o.renderedRevision==s&&o.renderedPixelRatio===t&&o.renderedRenderOrder==n)return;let l=r.getSource(),h=!!r.getDeclutter(),u=l.getTileGrid(),d=l.getTileGridForProjection(i).getTileCoordExtent(e.wrappedTileCoord),c=l.getSourceTiles(t,i,e),p=At(r);delete e.hitDetectionImageData[p],e.executorGroups[p]=[],o.dirty=!1;for(let m=0,g=c.length;m<g;++m){let f=c[m];if(f.getState()!=he.LOADED)continue;let y=l.getProjection(),x=f.tileCoord,b=u.getTileCoordExtent(x);i&&y&&!As(i,y)&&(b=Ns(b,y,i,32));let _=ds(d,b),T=Zh(_,r.getRenderBuffer()*a,this.tempExtent),w=py(b,_)?null:T,M=new Pte(0,_,a,t),S=Wte(a,t),R=function(U,V){let z,Z=U.getStyleFunction()||r.getStyleFunction();if(Z&&(z=Z(U,a)),z){let j=this.renderFeature(U,S,z,M,h,V);o.dirty=o.dirty||j}},I=f.getFeatures();n&&n!==o.renderedRenderOrder&&I.sort(n);for(let U=0,V=I.length;U<V;++U){let z=I[U];i&&f.projection&&!As(i,f.projection)&&(z=z.clone(),z.getGeometry().applyTransform(ru(f.projection,i))),(!w||Xi(w,z.getGeometry().getExtent()))&&R.call(this,z,U)}let B=M.finish(),O=new Ute(r.getRenderMode()!=="vector"&&h&&c.length===1?null:_,a,t,l.getOverlaps(),B,r.getRenderBuffer(),!0);e.executorGroups[p].push(O)}o.renderedRevision=s,o.renderedPixelRatio=t,o.renderedRenderOrder=n,o.renderedResolution=a}forEachFeatureAtCoordinate(e,t,i,r,s){let n=t.viewState.resolution,a=t.viewState.rotation;i??=0;let o=this.getLayer(),l=o.getSource().getTileGridForProjection(t.viewState.projection),h=o.getRenderBuffer(),u=OT([e]);Zh(u,n*(h+i),u);let d={},c=function(x,b,_){let T=x.getId();T===void 0&&(T=At(x));let w=d[T];if(w){if(w!==!0&&_<w.distanceSq){if(_===0)return d[T]=!0,s.splice(s.lastIndexOf(w),1),r(x,o,b);w.geometry=b,w.distanceSq=_}}else{if(_===0)return d[T]=!0,r(x,o,b);s.push(d[T]={feature:x,layer:o,geometry:b,distanceSq:_,callback:r})}},p=this.renderedTiles,m=At(o),g=o.getDeclutter(),f=g?t.declutter?.[g]?.all().map(x=>x.value):null,y;e:for(let x=p.length-1;x>=0;--x){let b=p[x];if(!Xi(l.getTileCoordExtent(b.wrappedTileCoord),u))continue;let _=b.executorGroups[m];for(let T=0,w=_.length;T<w;++T)if(y=_[T].forEachFeatureAtCoordinate(e,n,a,i,c,f),y)break e}return y}getFeatures(e){return this.renderedTiles.length===0?Promise.resolve([]):new Promise((t,i)=>{let r=this.getLayer(),s=r.getSource(),n=this.renderedProjection,a=n.getExtent(),o=this.renderedResolution,l=s.getTileGridForProjection(n),h=Ki(this.renderedPixelToCoordinateTransform_,e.slice()),u=l.getTileCoordForCoordAndResolution(h,o).toString(),d=this.renderedTiles.find(y=>y.tileCoord.toString()===u&&y.getState()===he.LOADED);if(!d||d.loadingSourceTiles>0){t([]);return}s.getWrapX()&&n.canWrapX()&&!SY(a,l.getTileCoordExtent(d.tileCoord))&&Ck(h,n);let c=At(r),p=Cl(l.getTileCoordExtent(d.wrappedTileCoord)),m=[(h[0]-p[0])/o,(p[1]-h[1])/o],g=d.getSourceTiles().reduce((y,x)=>y.concat(x.getFeatures()),[]),f=d.hitDetectionImageData[c];if(!f){let y=kr(l.getTileSize(l.getZForResolution(o,s.zDirection))),x=this.renderedRotation_;f=Gte(y,[this.getRenderTransform(l.getTileCoordCenter(d.wrappedTileCoord),o,0,sh,y[0]*sh,y[1]
2124*sh,0)],g,r.getStyleFunction(),l.getTileCoordExtent(d.wrappedTileCoord),d.getReplayState(r).renderedResolution,x),d.hitDetectionImageData[c]=f}t(jte(m,g,f))})}getFeaturesInExtent(e){let t=[],i=this.getTileCache();if(i.getCount()===0)return t;let r=this.getLayer().getSource().getTileGridForProjection(this.frameState.viewState.projection),s=r.getZForResolution(this.renderedResolution),n={};return i.forEach(a=>{if(a.tileCoord[0]!==s||a.getState()!==he.LOADED)return;let o=a.getSourceTiles();for(let l=0,h=o.length;l<h;++l){let u=o[l],d=u.getKey();if(d in n)continue;n[d]=!0;let c=u.tileCoord;if(Xi(e,r.getTileCoordExtent(c))){let p=u.getFeatures();if(p)for(let m=0,g=p.length;m<g;++m){let f=p[m];Xi(e,f.getGeometry().getExtent())&&t.push(f)}}}}),t}handleFontsChanged(){let e=this.getLayer();e.getVisible()&&this.renderedLayerRevision_!==void 0&&e.changed()}handleStyleImageChange_(e){this.renderIfReadyAndVisible()}renderDeclutter(e,t){let i=this.context,r=i.globalAlpha;i.globalAlpha=t.opacity;let s=e.viewHints,n=!(s[ar.ANIMATING]||s[ar.INTERACTING]),a=[this.context.canvas.width,this.context.canvas.height],o=this.getLayer().getDeclutter(),l=o?e.declutter?.[o]:void 0,h=At(this.getLayer()),u=this.renderedTiles;for(let d=0,c=u.length;d<c;++d){let p=u[d],m=p.executorGroups[h];if(m)for(let g=m.length-1;g>=0;--g)m[g].execute(this.context,a,this.getTileRenderTransform(p,e),e.viewState.rotation,n,WS,l)}i.globalAlpha=r}renderDeferredInternal(e){let t=this.renderedTiles,i=At(this.getLayer()),r=t.reduce((o,l,h)=>(l.executorGroups[i].forEach(u=>o.push({executorGroup:u,index:h})),o),[]),s=r.map(({executorGroup:o})=>o.getDeferredZIndexContexts()),n={};for(let o=0,l=r.length;o<l;++o){let h=r[o].executorGroup.getDeferredZIndexContexts();for(let u in h)n[u]=!0}let a=Object.keys(n).map(Number).sort(va);this.layerExtent&&this.clipUnrotated(this.context,e,this.layerExtent),a.forEach(o=>{s.forEach((l,h)=>{l[o]&&(l[o].forEach(u=>{let{executorGroup:d,index:c}=r[h],p=d.getRenderedContext(),m=p.globalAlpha;p.globalAlpha=this.renderedOpacity_;let g=this.tileClipContexts_[c];g&&g.draw(p),u.draw(p),g&&p.restore(),p.globalAlpha=m,u.clear()}),l[o].length=0)})}),this.layerExtent&&this.context.restore()}getTileRenderTransform(e,t){let i=t.pixelRatio,r=t.viewState,s=r.center,n=r.resolution,a=r.rotation,o=t.size,l=Math.round(o[0]*i),h=Math.round(o[1]*i),u=this.getLayer().getSource().getTileGridForProjection(t.viewState.projection),d=e.tileCoord,c=u.getTileCoordExtent(e.wrappedTileCoord),p=u.getTileCoordExtent(d,this.tempExtent)[0]-c[0];return bw(Tw(this.inversePixelTransform.slice(),1/i,1/i),this.getRenderTransform(s,n,a,i,l,h,p))}postRender(e,t){let i=t.viewHints,r=!(i[ar.ANIMATING]||i[ar.INTERACTING]);this.renderedPixelToCoordinateTransform_=t.pixelToCoordinateTransform.slice(),this.renderedRotation_=t.viewState.rotation,this.renderedOpacity_=t.layerStatesArray[t.layerIndex].opacity;let s=this.getLayer(),n=s.getRenderMode(),a=e.globalAlpha;e.globalAlpha=this.renderedOpacity_;let o=s.getDeclutter(),l=o?_D[n].filter(b=>!WS.includes(b)):_D[n],h=t.viewState,u=h.rotation;this.layerExtent&&this.clipUnrotated(e,t,this.layerExtent);let d=s.getSource(),c=d.getTileGridForProjection(h.projection).getZForResolution(h.resolution,d.zDirection),p=this.renderedTiles,m=[],g=[],f=[],y=At(s),x=!0;for(let b=p.length-1;b>=0;--b){let _=p[b];x&&=!_.getReplayState(s).dirty;let T=_.executorGroups[y].filter(O=>O.hasExecutors(l));if(T.length===0)continue;let w=this.getTileRenderTransform(_,t),M=_.tileCoord[0],S=!1,R=T[0].getClipCoords(w),I=e,B;if(R){B=new jS,I=B.getContext();for(let O=0,U=m.length;O<U;++O)if(c!==M&&M<g[O]){let V=m[O];Xi([R[0],R[3],R[4],R[7]],[V[0],V[3],V[4],V[7]])&&(S||=(I.save(),!0),I.beginPath(),I.moveTo(R[0],R[1]),I.lineTo(R[2],R[3]),I.lineTo(R[4],R[5]),I.lineTo(R[6],R[7]),I.moveTo(V[6],V[7]),I.lineTo(V[4],V[5]),I.lineTo(V[2],V[3]),I.lineTo(V[0],V[1]),I.clip())}m.push(R),g.push(M)}for(let O=0,U=T.length;O<U;++O)T[O].execute(e,[e.canvas.width,e.canvas.height],w,u,r,l,t.declutter?.[o]);S&&(I===e?I.restore():f[b]=B)}this.layerExtent&&e.restore(),e.globalAlpha=a,this.ready=x,this.tileClipContexts_=f,t.declutter||this.renderDeferredInternal(t),super.postRender(e,t)}renderFeature(e,t,i,r,s,n){if(!i)return!1;let a=!1;if(Array.isArray(i))for(let o=0,l=i.length;o<l;++o)a=fD(r,e,i[o],t,this.boundHandleStyleImageChange_,void 0,s,n)||a;else a=fD(r,e,i,t,this.boundHandleStyleImageChange_,void 0,s,n);return a}tileImageNeedsRender_(e){let t=this.getLayer();if(t.getRenderMode()==="vector")return!1;let i=e.getReplayState(t),r=t.getRevision(),s=e.wantedResolution;return i.renderedTileResolution!==s||i.renderedTileRevision!==r}renderTileImage_(e,t){let i=this.getLayer(),r=e.getReplayState(i),s=i.getRevision(),n=e.executorGroups[At(i)];r.renderedTileRevision=s;let a=e.wrappedTileCoord,o=a[0],l=i.getSource(),h=t.pixelRatio,u=t.viewState.projection,d=l.getTileGridForProjection(u),c=d.getResolution(e.tileCoord[0]),p=t.pixelRatio/e.wantedResolution*c,m=d.getResolution(o),g=e.getContext();h=Math.round(Math.max(h,p/h));let f=l.getTilePixelSize(o,h,u);g.canvas.width=f[0],g.canvas.height=f[1];let y=h/p;if(y!==1){let T=LI(this.tmpTransform_);Tw(T,y,y),g.setTransform.apply(g,T)}let x=d.getTileCoordExtent(a,this.tempExtent),b=p/m,_=LI(this.tmpTransform_);Tw(_,b,-b),aZ(_,-x[0],-x[3]);for(let T=0,w=n.length;T<w;++T)n[T].execute(g,[g.canvas.width*y,g.canvas.height*y],_,0,!0,lie[i.getRenderMode()],null);r.renderedTileResolution=e.wantedResolution}},uie=class extends $F{constructor(e){e||={};let t=Object.assign({},e);delete t.preload;let i=e.cacheSize===void 0?0:e.cacheSize;delete e.cacheSize,delete t.useInterimTilesOnError,super(t),this.on,this.once,this.un,this.cacheSize_=i;let r=e.renderMode||"hybrid";It(r=="hybrid"||r=="vector","`renderMode` must be `'hybrid'` or `'vector'`"),this.renderMode_=r,this.setPreload(e.preload?e.preload:0),this.setUseInterimTilesOnError(e.useInterimTilesOnError===void 0?!0:e.useInterimTilesOnError),this.getBackgroun
2124d,this.setBackground}createRenderer(){return new hie(this,{cacheSize:this.cacheSize_})}getFeatures(e){return super.getFeatures(e)}getFeaturesInExtent(e){return this.getRenderer().getFeaturesInExtent(e)}getRenderMode(){return this.renderMode_}getPreload(){return this.get(Wl.PRELOAD)}getUseInterimTilesOnError(){return this.get(Wl.USE_INTERIM_TILES_ON_ERROR)}setPreload(e){this.set(Wl.PRELOAD,e)}setUseInterimTilesOnError(e){this.set(Wl.USE_INTERIM_TILES_ON_ERROR,e)}},TD=[],die=class extends Zm{constructor(e,t,i,r,s){super(e,t,{transition:0}),this.context_=null,this.executorGroups={},this.loadingSourceTiles=0,this.hitDetectionImageData={},this.replayState_={},this.sourceTiles=[],this.errorTileKeys={},this.wantedResolution,this.getSourceTiles=r.bind(void 0,this),this.removeSourceTiles_=s,this.wrappedTileCoord=i}getContext(){return this.context_||=Ui(1,1,TD),this.context_}hasContext(){return!!this.context_}getImage(){return this.hasContext()?this.getContext().canvas:null}getReplayState(e){let t=At(e);return t in this.replayState_||(this.replayState_[t]={dirty:!1,renderedRenderOrder:null,renderedResolution:NaN,renderedPixelRatio:NaN,renderedRevision:-1,renderedTileResolution:NaN,renderedTileRevision:-1,renderedTileZ:-1}),this.replayState_[t]}load(){this.getSourceTiles()}release(){this.context_&&=(Ky(this.context_),TD.push(this.context_.canvas),null),this.removeSourceTiles_(this),this.sourceTiles.length=0,super.release()}},cie=class extends Zm{constructor(e,t,i,r,s,n){super(e,t,n),this.extent=null,this.format_=r,this.features_=null,this.loader_,this.projection=null,this.resolution,this.tileLoadFunction_=s,this.url_=i,this.key=i}getTileUrl(){return this.url_}getFormat(){return this.format_}getFeatures(){return this.features_}load(){this.state==he.IDLE&&(this.setState(he.LOADING),this.tileLoadFunction_(this,this.url_),this.loader_&&this.loader_(this.extent,this.resolution,this.projection))}onLoad(e,t){this.setFeatures(e)}onError(){this.setState(he.ERROR)}setFeatures(e){this.features_=e,this.setState(he.LOADED)}setLoader(e){this.loader_=e}},pie=!1;function mie(e,t,i,r,s,n,a){let o=new XMLHttpRequest;o.open("GET",typeof e=="function"?e(i,r,s):e,!0),t.getType()=="arraybuffer"&&(o.responseType="arraybuffer"),o.withCredentials=pie,o.onload=function(l){if(!o.status||o.status>=200&&o.status<300){let h=t.getType();try{let u;h=="text"||h=="json"?u=o.responseText:h=="xml"?u=o.responseXML||o.responseText:h=="arraybuffer"&&(u=o.response),u?n(t.readFeatures(u,{extent:i,featureProjection:s}),t.readProjection(u)):a()}catch{a()}}else a()},o.onerror=a,o.send()}var gie=class extends h5{constructor(e){let t=e.projection||"EPSG:3857",i=e.extent||p1(t),r=e.tileGrid||t5({extent:i,maxResolution:e.maxResolution,maxZoom:e.maxZoom===void 0?22:e.maxZoom,minZoom:e.minZoom,tileSize:e.tileSize||512});super({attributions:e.attributions,attributionsCollapsible:e.attributionsCollapsible,cacheSize:e.cacheSize,interpolate:!0,projection:t,state:e.state,tileGrid:r,tileLoadFunction:e.tileLoadFunction?e.tileLoadFunction:fie,tileUrlFunction:e.tileUrlFunction,url:e.url,urls:e.urls,wrapX:e.wrapX===void 0?!0:e.wrapX,transition:e.transition,zDirection:e.zDirection===void 0?1:e.zDirection}),this.format_=e.format?e.format:null,this.tileKeysBySourceTileUrl_={},this.sourceTiles_={},this.overlaps_=e.overlaps==null?!0:e.overlaps,this.tileClass=e.tileClass?e.tileClass:cie,this.tileGrids_={}}getOverlaps(){return this.overlaps_}getSourceTiles(e,t,i,r){if(i.getState()===he.IDLE){i.setState(he.LOADING);let s=i.wrappedTileCoord,n=this.getTileGridForProjection(t),a=n.getTileCoordExtent(s),o=s[0],l=n.getResolution(o);Zh(a,-l,a);let h=this.projection;t&&this.projection&&!As(t,h)&&(a=Ns(a,t,h));let u=this.tileGrid,d=u.getExtent();d&&ds(a,d,a);let c=l;t&&h&&!As(t,h)&&(c=l/h.getMetersPerUnit()/t.getMetersPerUnit());let p=u.getZForResolution(c,this.zDirection),m=r||this.tileUrlFunction;u.forEachTileCoord(a,p,g=>{let f=m(g,e,t);this.sourceTiles_[f]||(this.sourceTiles_[f]=new this.tileClass(g,f?he.IDLE:he.EMPTY,f,this.format_,this.tileLoadFunction));let y=this.sourceTiles_[f];i.sourceTiles.push(y),this.tileKeysBySourceTileUrl_[f]||(this.tileKeysBySourceTileUrl_[f]=[]),this.tileKeysBySourceTileUrl_[f].push(i.getKey());let x=y.getState();if(x<he.LOADED){let b=_=>{this.handleTileChange(_);let T=y.getState();if(T===he.LOADED||T===he.ERROR){let w=y.getKey();w in i.errorTileKeys?y.getState()===he.LOADED&&delete i.errorTileKeys[w]:i.loadingSourceTiles--,T===he.ERROR?i.errorTileKeys[w]=!0:y.removeEventListener(
2124De.CHANGE,b),i.loadingSourceTiles===0&&i.setState(wy(i.errorTileKeys)?he.LOADED:he.ERROR)}};y.addEventListener(De.CHANGE,b),i.loadingSourceTiles++}x===he.IDLE&&(y.extent=u.getTileCoordExtent(g),y.projection=this.projection,y.resolution=u.getResolution(g[0]),y.load())}),i.loadingSourceTiles||i.setState(i.sourceTiles.some(g=>g.getState()===he.ERROR)?he.ERROR:he.LOADED)}return i.sourceTiles}removeSourceTiles(e){let t=e.getKey(),i=e.sourceTiles;for(let r=0,s=i.length;r<s;++r){let n=i[r].getTileUrl();if(!this.tileKeysBySourceTileUrl_[n])return;let a=this.tileKeysBySourceTileUrl_[n].indexOf(t);a!==-1&&(this.tileKeysBySourceTileUrl_[n].splice(a,1),this.tileKeysBySourceTileUrl_[n].length===0&&(delete this.tileKeysBySourceTileUrl_[n],delete this.sourceTiles_[n]))}}getTile(e,t,i,r,s){let n=[e,t,i],a=this.getTileCoordForTileUrlFunction(n,s),o=this.getTileGrid().getExtent(),l=this.projection,h=this.getTileGridForProjection(s);if(a&&o){let p=h.getTileCoordExtent(a);Zh(p,-h.getResolution(e),p),Xi(o,!s||!l||As(s,l)?p:Ns(p,s,l))||(a=null)}let u=!0;if(a!==null){let p=this.tileGrid,m=h.getResolution(e),g=m;s&&l&&!As(s,l)&&(g=m/l.getMetersPerUnit()/s.getMetersPerUnit());let f=p.getZForResolution(g,1),y=h.getTileCoordExtent(a);Zh(y,-m,y),p.forEachTileCoord(!s||!l||As(s,l)?y:Ns(y,s,l),f,x=>{u&&=!this.tileUrlFunction(x,r,l)})}let d=this.tileUrlFunction,c=new die(n,u?he.EMPTY:he.IDLE,a,p=>this.getSourceTiles(r,s,p,d),this.removeSourceTiles.bind(this));return c.key=this.getKey(),c}getTileGridForProjection(e){let t=e.getCode(),i=this.tileGrids_[t];if(!i){let r=this.projection;if(r!==null&&!As(r,e))return vS(e);let s=this.tileGrid,n=s.getResolutions().slice(),a=n.map(function(l,h){return s.getOrigin(h)}),o=n.map(function(l,h){return s.getTileSize(h)});for(let l=n.length;l<43;++l)n.push(n[l-1]/2),a.push(a[l-1]),o.push(o[l-1]);i=new c1({extent:s.getExtent(),origins:a,resolutions:n,tileSizes:o}),this.tileGrids_[t]=i}return i}getTilePixelRatio(e){return e}getTilePixelSize(e,t,i){let r=kr(this.getTileGridForProjection(i).getTileSize(e),this.tmpSize);return[Math.round(r[0]*t),Math.round(r[1]*t)]}setOverlaps(e){this.overlaps_=e,this.changed()}};function fie(e,t){e.setLoader(function(i,r,s){mie(t,e.getFormat(),i,r,s,e.onLoad.bind(e),e.onError.bind(e))})}var YS=65536*65536,wD=1/YS,yie=12,SD=typeof TextDecoder>"u"?null:new TextDecoder("utf-8"),KS=0,A1=1,ug=2,N1=5,xie=class{constructor(e=new Uint8Array(16)){this.buf=ArrayBuffer.isView(e)?e:new Uint8Array(e),this.dataView=new DataView(this.buf.buffer),this.pos=0,this.type=0,this.length=this.buf.length}readFields(e,t,i=this.length){for(;this.pos<i;){let r=this.readVarint(),s=r>>3,n=this.pos;this.type=r&7,e(s,t,this),this.pos===n&&this.skip(r)}return t}readMessage(e,t){return this.readFields(e,t,this.readVarint()+this.pos)}readFixed32(){let e=this.dataView.getUint32(this.pos,!0);return this.pos+=4,e}readSFixed32(){let e=this.dataView.getInt32(this.pos,!0);return this.pos+=4,e}readFixed64(){let e=this.dataView.getUint32(this.pos,!0)+this.dataView.getUint32(this.pos+4,!0)*YS;return this.pos+=8,e}readSFixed64(){let e=this.dataView.getUint32(this.pos,!0)+this.dataView.getInt32(this.pos+4,!0)*YS;return this.pos+=8,e}readFloat(){let e=this.dataView.getFloat32(this.pos,!0);return this.pos+=4,e}readDouble(){let e=this.dataView.getFloat64(this.pos,!0);return this.pos+=8,e}readVarint(e){let t=this.buf,i,r;return r=t[this.pos++],i=r&127,r<128||(r=t[this.pos++],i|=(r&127)<<7,r<128)||(r=t[this.pos++],i|=(r&127)<<14,r<128)||(r=t[this.pos++],i|=(r&127)<<21,r<128)?i:(r=t[this.pos],i|=(r&15)<<28,vie(i,e,this))}readVarint64(){return this.readVarint(!0)}readSVarint(){let e=this.readVarint();return e%2==1?(e+1)/-2:e/2}readBoolean(){return!!this.readVarint()}readString(){let e=this.readVarint()+this.pos,t=this.pos;return this.pos=e,e-t>=yie&&SD?SD.decode(this.buf.subarray(t,e)):kie(this.buf,t,e)}readBytes(){let e=this.readVarint()+this.pos,t=this.buf.subarray(this.pos,e);return this.pos=e,t}readPackedVarint(e=[],t){let i=this.readPackedEnd();for(;this.pos<i;)e.push(this.readVarint(t));return e}readPackedSVarint(e=[]){let t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readSVarint());return e}readPackedBoolean(e=[]){let t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readBoolean());return e}readPackedFloat(e=[]){let t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readFloat());return e}readPackedDouble(e=[]){let t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readDouble());return e}readPackedFixed32(e=[]){let t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readFixed32());return e}readPackedSFixed32(e=[]){let t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readSFixed32());return e}readPackedFixed64(e=[]){let t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readFixed64());return e}readPackedSFixed64(e=[]){let t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readSFixed64());return e}readPackedEnd(){return this.type===ug?this.readVarint()+this.pos:this.pos+1}skip(e){let t=e&7;if(t===KS)for(;this.buf[this.pos++]>127;);else if(t===ug)this.pos=this.readVarint()+this.pos;else if(t===N1)this.pos+=4;else if(t===A1)this.pos+=8;else throw Error(`Unimplemented type: ${t}`)}writeTag(e,t){this.writeVarint(e<<3|t)}realloc(e){let t=this.length||16;for(;t<this.pos+e;)t*=2;if(t!==this.length){let i=new Uint8Array(t);i.set(this.buf),this.buf=i,this.dataView=new DataView(i.buffer),this.length=t}}finish(){return this.length=this.pos,this.pos=0,this.buf.subarray(0,this.length)}writeFixed32(e){this.realloc(4),this.dataView.setInt32(this.pos,e,!0),this.pos+=4}writeSFixed32(e){this.realloc(4),this.dataView.setInt32(this.pos,e,!0),this.pos+=4}
vendor: 4,336 bytes, line 2124
2124writeFixed64(e){this.realloc(8),this.dataView.setInt32(this.pos,e&-1,!0),this.dataView.setInt32(this.pos+4,Math.floor(e*wD),!0),this.pos+=8}writeSFixed64(e){this.realloc(8),this.dataView.setInt32(this.pos,e&-1,!0),this.dataView.setInt32(this.pos+4,Math.floor(e*wD),!0),this.pos+=8}writeVarint(e){if(e=+e||0,e>268435455||e<0){_ie(e,this);return}this.realloc(4),this.buf[this.pos++]=e&127|(e>127?128:0),!(e<=127)&&(this.buf[this.pos++]=(e>>>=7)&127|(e>127?128:0),!(e<=127)&&(this.buf[this.pos++]=(e>>>=7)&127|(e>127?128:0),!(e<=127)&&(this.buf[this.pos++]=e>>>7&127)))}writeSVarint(e){this.writeVarint(e<0?-e*2-1:e*2)}writeBoolean(e){this.writeVarint(+e)}writeString(e){e=String(e),this.realloc(e.length*4),this.pos++;let t=this.pos;this.pos=Iie(this.buf,e,this.pos);let i=this.pos-t;i>=128&&MD(t,i,this),this.pos=t-1,this.writeVarint(i),this.pos+=i}writeFloat(e){this.realloc(4),this.dataView.setFloat32(this.pos,e,!0),this.pos+=4}writeDouble(e){this.realloc(8),this.dataView.setFloat64(this.pos,e,!0),this.pos+=8}writeBytes(e){let t=e.length;this.writeVarint(t),this.realloc(t);for(let i=0;i<t;i++)this.buf[this.pos++]=e[i]}writeRawMessage(e,t){this.pos++;let i=this.pos;e(t,this);let r=this.pos-i;r>=128&&MD(i,r,this),this.pos=i-1,this.writeVarint(r),this.pos+=r}writeMessage(e,t,i){this.writeTag(e,ug),this.writeRawMessage(t,i)}writePackedVarint(e,t){t.length&&this.writeMessage(e,Sie,t)}writePackedSVarint(e,t){t.length&&this.writeMessage(e,Mie,t)}writePackedBoolean(e,t){t.length&&this.writeMessage(e,Eie,t)}writePackedFloat(e,t){t.length&&this.writeMessage(e,Cie,t)}writePackedDouble(e,t){t.length&&this.writeMessage(e,Rie,t)}writePackedFixed32(e,t){t.length&&this.writeMessage(e,Aie,t)}writePackedSFixed32(e,t){t.length&&this.writeMessage(e,Nie,t)}writePackedFixed64(e,t){t.length&&this.writeMessage(e,Lie,t)}writePackedSFixed64(e,t){t.length&&this.writeMessage(e,Pie,t)}writeBytesField(e,t){this.writeTag(e,ug),this.writeBytes(t)}writeFixed32Field(e,t){this.writeTag(e,N1),this.writeFixed32(t)}writeSFixed32Field(e,t){this.writeTag(e,N1),this.writeSFixed32(t)}writeFixed64Field(e,t){this.writeTag(e,A1),this.writeFixed64(t)}writeSFixed64Field(e,t){this.writeTag(e,A1),this.writeSFixed64(t)}writeVarintField(e,t){this.writeTag(e,KS),this.writeVarint(t)}writeSVarintField(e,t){this.writeTag(e,KS),this.writeSVarint(t)}writeStringField(e,t){this.writeTag(e,ug),this.writeString(t)}writeFloatField(e,t){this.writeTag(e,N1),this.writeFloat(t)}writeDoubleField(e,t){this.writeTag(e,A1),this.writeDouble(t)}writeBooleanField(e,t){this.writeVarintField(e,+t)}};function vie(e,t,i){let r=i.buf,s,n;if(n=r[i.pos++],s=(n&112)>>4,n<128||(n=r[i.pos++],s|=(n&127)<<3,n<128)||(n=r[i.pos++],s|=(n&127)<<10,n<128)||(n=r[i.pos++],s|=(n&127)<<17,n<128)||(n=r[i.pos++],s|=(n&127)<<24,n<128)||(n=r[i.pos++],s|=(n&1)<<31,n<128))return bie(e,s,t);throw Error("Expected varint not more than 10 bytes")}function bie(e,t,i){return i?t*4294967296+(e>>>0):(t>>>0)*4294967296+(e>>>0)}function _ie(e,t){let i,r;if(e>=0?(i=e%4294967296|0,r=e/4294967296|0):(i=~(-e%4294967296),r=~(-e/4294967296),i^4294967295?i=i+1|0:(i=0,r=r+1|0)),e>=18446744073709552e3||e<-18446744073709552e3)throw Error("Given varint doesn't fit into 10 bytes");t.realloc(10),Tie(i,r,t),wie(r,t)}function Tie(e,t,i){i.buf[i.pos++]=e&127|128,e>>>=7,i.buf[i.pos++]=e&127|128,e>>>=7,i.buf[i.pos++]=e&127|128,e>>>=7,i.buf[i.pos++]=e&127|128,e>>>=7,i.buf[i.pos]=e&127}function wie(e,t){let i=(e&7)<<4;t.buf[t.pos++]|=i|((e>>>=3)?128:0),e&&(t.buf[t.pos++]=e&127|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=e&127|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=e&127|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=e&127|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=e&127)))))}function MD(e,t,i){let r=t<=16383?1:t<=2097151?2:t<=268435455?3:Math.floor(Math.log(t)/(Math.LN2*7));i.realloc(r);for(let s=i.pos-1;s>=e;s--)i.buf[s+r]=i.buf[s]}function Sie(e,t){for(let i=0;i<e.length;i++)t.writeVarint(e[i])}function Mie(e,t){for(let i=0;i<e.length;i++)t.writeSVarint(e[i])}function Cie(e,t){for(let i=0;i<e.length;i++)t.writeFloat(e[i])}function Rie(e,t){for(let i=0;i<e.length;i++)t.writeDouble(e[i])}function Eie(e,t){for(let i=0;i<e.length;i++)t.writeBoolean(e[i])}function Aie(e,t){for(let i=0;i<e.length;i++)t.writeFixed32(e[i])}function Nie(e,t){for(let i=0;i<e.length;i++)t.writeSFixed32(e[i])}function Lie(e,t){for(let i=0;i<e.length;
2124i++)t.writeFixed64(e[i])}function Pie(e,t){for(let i=0;i<e.length;i++)t.writeSFixed64(e[i])}function kie(e,t,i){let r="",s=t;for(;s<i;){let n=e[s],a=null,o=n>239?4:n>223?3:n>191?2:1;if(s+o>i)break;let l,h,u;o===1?n<128&&(a=n):o===2?(l=e[s+1],(l&192)==128&&(a=(n&31)<<6|l&63,a<=127&&(a=null))):o===3?(l=e[s+1],h=e[s+2],(l&192)==128&&(h&192)==128&&(a=(n&15)<<12|(l&63)<<6|h&63,(a<=2047||a>=55296&&a<=57343)&&(a=null))):o===4&&(l=e[s+1],h=e[s+2],u=e[s+3],(l&192)==128&&(h&192)==128&&(u&192)==128&&(a=(n&15)<<18|(l&63)<<12|(h&63)<<6|u&63,(a<=65535||a>=1114112)&&(a=null))),a===null?(a=65533,o=1):a>65535&&(a-=65536,r+=String.fromCharCode(a>>>10&1023|55296),a=56320|a&1023),r+=String.fromCharCode(a),s+=o}return r}function Iie(e,t,i){for(let r=0,s,n;r<t.length;r++){if(s=t.charCodeAt(r),s>55295&&s<57344)if(n)if(s<56320){e[i++]=239,e[i++]=191,e[i++]=189,n=s;continue}else s=n-55296<<10|s-56320|65536,n=null;else{s>56319||r+1===t.length?(e[i++]=239,e[i++]=191,e[i++]=189):n=s;continue}else n&&=(e[i++]=239,e[i++]=191,e[i++]=189,null);s<128?e[i++]=s:(s<2048?e[i++]=s>>6|192:(s<65536?e[i++]=s>>12|224:(e[i++]=s>>18|240,e[i++]=s>>12&63|128),e[i++]=s>>6&63|128),e[i++]=s&63|128)}return i}function L1(e,t,i,r,s,n,a){let o,l,h=(i-t)/r;if(h===1)o=t;else if(h===2)o=t,l=s;else if(h!==0){let u=e[t],d=e[t+1],c=0,p=[0];for(let f=t+r;f<i;f+=r){let y=e[f],x=e[f+1];c+=Math.sqrt((y-u)*(y-u)+(x-d)*(x-d)),p.push(c),u=y,d=x}let m=s*c,g=gK(p,m);g<0?(l=(m-p[-g-2])/(p[-g-1]-p[-g-2]),o=t+(-g-2)*r):o=t+g*r}a=a>1?a:2,n||=Array(a);for(let u=0;u<a;++u)n[u]=o===void 0?NaN:l===void 0?e[o+u]:Es(e[o+u],e[o+r+u],l);return n}function ZS(e,t,i,r,s,n){if(i==t)return null;let a;if(s<e[t+r-1])return n?(a=e.slice(t,t+r),a[r-1]=s,a):null;if(e[i-1]<s)return n?(a=e.slice(i-r,i),a[r-1]=s,a):null;if(s==e[t+r-1])return e.slice(t,t+r);let o=t/r,l=i/r;for(;o<l;){let c=o+l>>1;s<e[(c+1)*r-1]?l=c:o=c+1}let h=e[o*r-1];if(s==h)return e.slice((o-1)*r,(o-1)*r+r);let u=e[(o+1)*r-1],d=(s-h)/(u-h);a=[];for(let c=0;c<r-1;++c)a.push(Es(e[(o-1)*r+c],e[o*r+c],d));return a.push(s),a}function Fie(e,t,i,r,s,n,a){if(a)return ZS(e,t,i[i.length-1],r,s,n);let o;if(s<e[r-1])return n?(o=e.slice(0,r),o[r-1]=s,o):null;if(e[e.length-1]<s)return n?(o=e.slice(e.length-r),o[r-1]=s,o):null;for(let l=0,h=i.length;l<h;++l){let u=i[l];if(t!=u){if(s<e[t+r-1])return null;if(s<=e[u-1])return ZS(e,t,u,r,s,!1);t=u}}return null}var JS=class h2 extends fu{constructor(t,i){super(),this.flatMidpoint_=null,this.flatMidpointRevision_=-1,this.maxDelta_=-1,this.maxDeltaRevision_=-1,i!==void 0&&!Array.isArray(t[0])?this.setFlatCoordinates(i,t):this.setCoordinates(t,i)}appendCoordinate(t){bo(this.flatCoordinates,t),this.changed()}clone(){let t=new h2(this.flatCoordinates.slice(),this.layout);return t.applyProperties(this),t}closestPointXY(t,i,r,s){return s<Wd(this.getExtent(),t,i)?s:(this.maxDeltaRevision_!=this.getRevision()&&(this.maxDelta_=Math.sqrt(Sw(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),Cw(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,this.maxDelta_,!1,t,i,r,s))}forEachSegment(t){return GI(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,t)}getCoordinateAtM(t,i){return this.layout!="XYM"&&this.layout!="XYZM"?null:(i=i===void 0?!1:i,ZS(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,t,i))}getCoordinates(){return Ul(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getCoordinateAt(t,i){return L1(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,t,i,this.stride)}getLength(){return GS(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getFlatMidpoint(){return this.flatMidpointRevision_!=this.getRevision()&&(this.flatMidpoint_=this.getCoordinateAt(.5,this.flatMidpoint_??void 0),this.flatMidpointRevision_=this.getRevision()),this.flatMidpoint_}getSimplifiedGeometryInternal(t){let i=[];return i.length=jy(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,t,i,0),new h2(i,"XY")}getType(){return"LineString"}intersectsExtent(t){return Wy(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,t,this.getExtent())}setCoordinates(t,i){this.setLayout(i,t,1),this.flatCoordinates||=[],this.flatCoordinates.length=Gy(this.flatCoordinates,0,t,this.stride),this.changed()}},Die=class u2 extends fu{constructor(t,i,r){if(super(),this.ends_=[],this.maxDelta_=-1,this.maxDeltaRevision_=-1,Array.isArray(t[0]))this.setCoordinates(t,i);else if(i!==void 0&&r)this.setFlatCoordinates(i,t),this.ends_=r;else{let s=t,n=[],a=[];for(let l=0,h=s.length;l<h;++l){let u=s[l];bo(n,u.getFlatCoordinates()),a.push(n.length)}let o=s.length===0?this.getLayout():s[0].getLayout();this.setFlatCoordinates(o,n),this.ends_=a}}appendLineString(t){bo(this.flatCoordinates,t.getFlatCoordinates().slice()),this.ends_.push(this.flatCoordinates.length),this.changed()}clone(){let t=new u2(this.flatCoordinates.slice(),this.layout,this.ends_.slice());return t.applyProperties(this),t}closestPointXY(t,i,r,s){return s<Wd(this.getExtent(),t,i)?s:(this.maxDeltaRevision_!=this.getRevision()&&(this.maxDelta_=Math.sqrt(Mw(this.flatCoordinates,0,this.ends_,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),Rw(this.flatCoordinates,0,this.ends_,this.stride,this.maxDelta_,!1,t,i,r,s
2124))}getCoordinateAtM(t,i,r){return this.layout!="XYM"&&this.layout!="XYZM"||this.flatCoordinates.length===0?null:(i=i===void 0?!1:i,r=r===void 0?!1:r,Fie(this.flatCoordinates,0,this.ends_,this.stride,t,i,r))}getCoordinates(){return Tm(this.flatCoordinates,0,this.ends_,this.stride)}getEnds(){return this.ends_}getLineString(t){return t<0||this.ends_.length<=t?null:new JS(this.flatCoordinates.slice(t===0?0:this.ends_[t-1],this.ends_[t]),this.layout)}getLineStrings(){let t=this.flatCoordinates,i=this.ends_,r=this.layout,s=[],n=0;for(let a=0,o=i.length;a<o;++a){let l=i[a],h=new JS(t.slice(n,l),r);s.push(h),n=l}return s}getLength(){let t=this.ends_,i=0,r=0;for(let s=0,n=t.length;s<n;++s)r+=GS(this.flatCoordinates,i,t[s],this.stride),i=t[s];return r}getFlatMidpoints(){let t=[],i=this.flatCoordinates,r=0,s=this.ends_,n=this.stride;for(let a=0,o=s.length;a<o;++a){let l=s[a];bo(t,L1(i,r,l,n,.5)),r=l}return t}getSimplifiedGeometryInternal(t){let i=[],r=[];return i.length=UI(this.flatCoordinates,0,this.ends_,this.stride,t,i,0,r),new u2(i,"XY",r)}getType(){return"MultiLineString"}intersectsExtent(t){return CZ(this.flatCoordinates,0,this.ends_,this.stride,t)}setCoordinates(t,i){this.setLayout(i,t,2),this.flatCoordinates||=[];let r=Ew(this.flatCoordinates,0,t,this.stride,this.ends_);this.flatCoordinates.length=r.length===0?0:r[r.length-1],this.changed()}},CD=class EO extends fu{constructor(t,i){super(),i&&!Array.isArray(t[0])?this.setFlatCoordinates(i,t):this.setCoordinates(t,i)}appendPoint(t){bo(this.flatCoordinates,t.getFlatCoordinates()),this.changed()}clone(){let t=new EO(this.flatCoordinates.slice(),this.layout);return t.applyProperties(this),t}closestPointXY(t,i,r,s){if(s<Wd(this.getExtent(),t,i))return s;let n=this.flatCoordinates,a=this.stride;for(let o=0,l=n.length;o<l;o+=a){let h=Qh(t,i,n[o],n[o+1]);if(h<s){s=h;for(let u=0;u<a;++u)r[u]=n[o+u];r.length=a}}return s}getCoordinates(){return Ul(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getPoint(t){let i=this.flatCoordinates.length/this.stride;return t<0||i<=t?null:new $y(this.flatCoordinates.slice(t*this.stride,(t+1)*this.stride),this.layout)}getPoints(){let t=this.flatCoordinates,i=this.layout,r=this.stride,s=[];for(let n=0,a=t.length;n<a;n+=r){let o=new $y(t.slice(n,n+r),i);s.push(o)}return s}getType(){return"MultiPoint"}intersectsExtent(t){let i=this.flatCoordinates,r=this.stride;for(let s=0,n=i.length;s<n;s+=r){let a=i[s],o=i[s+1];if(BT(t,a,o))return!0}return!1}setCoordinates(t,i){this.setLayout(i,t,1),this.flatCoordinates||=[],this.flatCoordinates.length=Gy(this.flatCoordinates,0,t,this.stride),this.changed()}};function RD(e,t,i,r){let s=[],n=ya();for(let a=0,o=i.length;a<o;++a){let l=i[a];n=VT(e,t,l[0],r),s.push((n[0]+n[2])/2,(n[1]+n[3])/2),t=l[l.length-1]}return s}var Oie=class d2 extends fu{constructor(t,i,r){if(super(),this.endss_=[],this.flatInteriorPointsRevision_=-1,this.flatInteriorPoints_=null,this.maxDelta_=-1,this.maxDeltaRevision_=-1,this.orientedRevision_=-1,this.orientedFlatCoordinates_=null,!r&&!Array.isArray(t[0])){let s=t,n=[],a=[];for(let o=0,l=s.length;o<l;++o){let h=s[o],u=n.length,d=h.getEnds();for(let c=0,p=d.length;c<p;++c)d[c]+=u;bo(n,h.getFlatCoordinates()),a.push(d)}i=s.length===0?this.getLayout():s[0].getLayout(),t=n,r=a}i!==void 0&&r?(this.setFlatCoordinates(i,t),this.endss_=r):this.setCoordinates(t,i)}appendPolygon(t){let i;if(!this.flatCoordinates)this.flatCoordinates=t.getFlatCoordinates().slice(),i=t.getEnds().slice(),this.endss_.push();else{let r=this.flatCoordinates.length;bo(this.flatCoordinates,t.getFlatCoordinates()),i=t.getEnds().slice();for(let s=0,n=i.length;s<n;++s)i[s]+=r}this.endss_.push(i),this.changed()}clone(){let t=this.endss_.length,i=Array(t);for(let s=0;s<t;++s)i[s]=this.endss_[s].slice();let r=new d2(this.flatCoordinates.slice(),this.layout,i);return r.applyProperties(this),r}closestPointXY(t,i,r,s){return s<Wd(this.getExtent(),t,i)?s:(this.maxDeltaRevision_!=this.getRevision()&&(this.maxDelta_=Math.sqrt(xZ(this.flatCoordinates,0,this.endss_,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),vZ(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride,this.maxDelta_,!0,t,i,r,s
2124))}containsXY(t,i){return MZ(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride,t,i)}getArea(){return yZ(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride)}getCoordinates(t){let i;return t===void 0?i=this.flatCoordinates:(i=this.getOrientedFlatCoordinates().slice(),HI(i,0,this.endss_,this.stride,t)),Aw(i,0,this.endss_,this.stride)}getEndss(){return this.endss_}getFlatInteriorPoints(){if(this.flatInteriorPointsRevision_!=this.getRevision()){let t=RD(this.flatCoordinates,0,this.endss_,this.stride);this.flatInteriorPoints_=zI(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride,t),this.flatInteriorPointsRevision_=this.getRevision()}return this.flatInteriorPoints_}getInteriorPoints(){return new CD(this.getFlatInteriorPoints().slice(),"XYM")}getOrientedFlatCoordinates(){if(this.orientedRevision_!=this.getRevision()){let t=this.flatCoordinates;AZ(t,0,this.endss_,this.stride)?this.orientedFlatCoordinates_=t:(this.orientedFlatCoordinates_=t.slice(),this.orientedFlatCoordinates_.length=HI(this.orientedFlatCoordinates_,0,this.endss_,this.stride)),this.orientedRevision_=this.getRevision()}return this.orientedFlatCoordinates_}getSimplifiedGeometryInternal(t){let i=[],r=[];return i.length=wZ(this.flatCoordinates,0,this.endss_,this.stride,Math.sqrt(t),i,0,r),new d2(i,"XY",r)}getPolygon(t){if(t<0||this.endss_.length<=t)return null;let i;if(t===0)i=0;else{let n=this.endss_[t-1];i=n[n.length-1]}let r=this.endss_[t].slice(),s=r[r.length-1];if(i!==0)for(let n=0,a=r.length;n<a;++n)r[n]-=i;return new wm(this.flatCoordinates.slice(i,s),this.layout,r)}getPolygons(){let t=this.layout,i=this.flatCoordinates,r=this.endss_,s=[],n=0;for(let a=0,o=r.length;a<o;++a){let l=r[a].slice(),h=l[l.length-1];if(n!==0)for(let d=0,c=l.length;d<c;++d)l[d]-=n;let u=new wm(i.slice(n,h),t,l);s.push(u),n=h}return s}getType(){return"MultiPolygon"}intersectsExtent(t){return RZ(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride,t)}setCoordinates(t,i){this.setLayout(i,t,3),this.flatCoordinates||=[];let r=_Z(this.flatCoordinates,0,t,this.stride,this.endss_);if(r.length===0)this.flatCoordinates.length=0;else{let s=r[r.length-1];this.flatCoordinates.length=s.length===0?0:s[s.length-1]}this.changed()}},Bie=class AO extends _a{constructor(t){if(super(),this.on,this.once,this.un,this.id_=void 0,this.geometryName_="geometry",this.style_=null,this.styleFunction_=void 0,this.geometryChangeKey_=null,this.addChangeListener(this.geometryName_,this.handleGeometryChanged_),t)if(typeof t.getSimplifiedGeometry=="function"){let i=t;this.setGeometry(i)}else{let i=t;this.setProperties(i)}}clone(){let t=new AO,i=this.geometryName_;t.setGeometryName(i);let r=this.getPropertiesInternal();if(r){let n=this.getGeometry();for(let a in r)a===i&&n?t.set(a,n.clone()):t.set(a,r[a],!0)}let s=this.getStyle();return s&&t.setStyle(s),t}getGeometry(){return this.get(this.geometryName_)}getId(){return this.id_}getGeometryName(){return this.geometryName_}getStyle(){return this.style_}getStyleFunction(){return this.styleFunction_}handleGeometryChange_(){this.changed()}handleGeometryChanged_(){this.geometryChangeKey_&&=(oi(this.geometryChangeKey_),null);let t=this.getGeometry();t&&(this.geometryChangeKey_=ft(t,De.CHANGE,this.handleGeometryChange_,this)),this.changed()}setGeometry(t){this.set(this.geometryName_,t)}setStyle(t){this.style_=t,this.styleFunction_=t?Uie(t):void 0,this.changed()}setId(t){this.id_=t,this.changed()}setGeometryName(t){t!==this.geometryName_&&(this.removeChangeListener(this.geometryName_,this.handleGeometryChanged_),this.geometryName_=t,this.addChangeListener(this.geometryName_,this.handleGeometryChanged_),this.handleGeometryChanged_())}};function Uie(e){if(typeof e=="function")return e;let t;return Array.isArray(e)?t=e:(It(typeof e.getZIndex=="function","Expected an `ol/style/Style` or an array of `ol/style/Style.js`"),t=[e]),function(){return t}}var ED=Qs(),P1=class c2{constructor(t,i,r,s,n,a){this.styleFunction,this.extent_,this.id_=a,this.type_=t,this.flatCoordinates_=i,this.flatInteriorPoints_=null,this.flatMidpoints_=null,this.ends_=r||null,this.properties_=n,this.squaredTolerance_,this.stride_=s,this.simplifiedGeometry_}get(t){return this.properties_[t]}getExtent(){return this.extent_||=this.type_==="Point"?_k(this.flatCoordinates_):VT(this.flatCoordinates_,0,this.flatCoordinates_.length,this.stride_),this.extent_}getFlatInteriorPoint(){if(!this.flatInteriorPoints_){let t=Jh(this.getExtent());this.flatInteriorPoints_=Pw(this.flatCoordinates_,0,this.ends_,this.stride_,t,0)}return this.flatInteriorPoints_}getFlatInteriorPoints(){if(!this.flatInteriorPoints_){let t=qI(this.flatCoordinates_,this.ends_),i=RD(this.flatCoordinates_,0,t,this.stride_);this.flatInteriorPoints_=zI(this.flatCoordinates_,0,t,this.stride_,i)}return this.flatInteriorPoints_}getFlatMidpoint(){return this.flatMidpoints_||=L1(this.flatCoordinates_,0,this.flatCoordinates_.length,this.stride_,.5),this.flatMidpoints_}getFlatMidpoints(){if(!this.flatMidpoints_){this.flatMidpoints_=[];let t=this.flatCoordinates_,i=0,r=this.ends_;for(let s=0,n=r.length;s<n;++s){let a=r[s],o=L1(t,i,a,this.stride_,.5);bo(this.flatMidpoints_,o),i=a}}return this.flatMidpoints_}getId(){return this.id_}getOrientedFlatCoordinates(){return this.flatCoordinates_}getGeometry(){return this}getSimplifiedGeometry(t){return this}simplifyTransformed(t,i){return this}getProperties(){return this.properties_}getPropertiesInternal(){return this.properties_}getStride(){return this.stride_}getStyleFunction(){return this.styleFunction}getType(){return this.type_}transform(t){t=Oi(t);let i=t.getExtent(),r=t.getWorldExtent();if(i&&r){let s=is(r)/is(i);So(ED,r[0],r[3],s,-s,0,0,0),Bl(this.flatCoordinates_,0,this.flatCoordinates_.length,this.stride_,
2124ED,this.flatCoordinates_)}}applyTransform(t){t(this.flatCoordinates_,this.flatCoordinates_,this.stride_)}clone(){return new c2(this.type_,this.flatCoordinates_.slice(),this.ends_?.slice(),this.stride_,Object.assign({},this.properties_),this.id_)}getEnds(){return this.ends_}enableSimplifyTransformed(){return this.simplifyTransformed=qk((t,i)=>{if(t===this.squaredTolerance_)return this.simplifiedGeometry_;this.simplifiedGeometry_=this.clone(),i&&this.simplifiedGeometry_.applyTransform(i);let r=this.simplifiedGeometry_.getFlatCoordinates(),s;switch(this.type_){case"LineString":r.length=jy(r,0,this.simplifiedGeometry_.flatCoordinates_.length,this.simplifiedGeometry_.stride_,t,r,0),s=[r.length];break;case"MultiLineString":s=[],r.length=UI(r,0,this.simplifiedGeometry_.ends_,this.simplifiedGeometry_.stride_,t,r,0,s);break;case"Polygon":s=[],r.length=Nw(r,0,this.simplifiedGeometry_.ends_,this.simplifiedGeometry_.stride_,Math.sqrt(t),r,0,s);break;default:}return s&&(this.simplifiedGeometry_=new c2(this.type_,r,s,this.stride_,this.properties_,this.id_)),this.squaredTolerance_=t,this.simplifiedGeometry_}),this}};P1.prototype.getFlatCoordinates=P1.prototype.getOrientedFlatCoordinates;var Vie=class{constructor(){this.dataProjection=void 0,this.defaultFeatureProjection=void 0,this.featureClass=Bie,this.supportedMediaTypes=null}getReadOptions(e,t){if(t){let i=t.dataProjection?Oi(t.dataProjection):this.readProjection(e);t.extent&&i&&i.getUnits()==="tile-pixels"&&(i=Oi(i),i.setWorldExtent(t.extent)),t={dataProjection:i,featureProjection:t.featureProjection}}return this.adaptOptions(t)}adaptOptions(e){return Object.assign({dataProjection:this.dataProjection,featureProjection:this.defaultFeatureProjection,featureClass:this.featureClass},e)}getType(){return qe()}readFeature(e,t){return qe()}readFeatures(e,t){return qe()}readGeometry(e,t){return qe()}readProjection(e){return qe()}writeFeature(e,t){return qe()}writeFeatures(e,t){return qe()}writeGeometry(e,t){return qe()}};function zie(e,t,i){let r=i?Oi(i.featureProjection):null,s=i?Oi(i.dataProjection):null,n=e;if(r&&s&&!As(r,s)){t&&(n=e.clone());let a=t?r:s,o=t?s:r;a.getUnits()==="tile-pixels"?n.transform(a,o):n.applyTransform(ru(a,o))}if(t&&i&&i.decimals!==void 0){let a=10**i.decimals;n===e&&(n=e.clone()),n.applyTransform(function(o){for(let l=0,h=o.length;l<h;++l)o[l]=Math.round(o[l]*a)/a;return o})}return n}var Gie=class extends Vie{constructor(e){super(),e||={},this.dataProjection=new _y({code:"",units:"tile-pixels"}),this.featureClass=e.featureClass?e.featureClass:P1,this.geometryName_=e.geometryName,this.layerName_=e.layerName?e.layerName:"layer",this.layers_=e.layers?e.layers:null,this.idProperty_=e.idProperty,this.supportedMediaTypes=["application/vnd.mapbox-vector-tile","application/x-protobuf"]}readRawGeometry_(e,t,i,r){e.pos=t.geometry;let s=e.readVarint()+e.pos,n=1,a=0,o=0,l=0,h=0,u=0;for(;e.pos<s;){if(!a){let d=e.readVarint();n=d&7,a=d>>3}if(a--,n===1||n===2)o+=e.readSVarint(),l+=e.readSVarint(),n===1&&h>u&&(r.push(h),u=h),i.push(o,l),h+=2;else if(n===7)h>u&&(i.push(i[u],i[u+1]),h+=2);else throw Error("Invalid command found in the PBF")}h>u&&(r.push(h),u=h)}createFeature_(e,t,i){let r=t.type;if(r===0)return null;let s,n=t.properties,a;this.idProperty_?(a=n[this.idProperty_],delete n[this.idProperty_]):a=t.id,n[this.layerName_]=t.layer.name;let o=[],l=[];this.readRawGeometry_(e,t,o,l);let h=qie(r,l.length);if(this.featureClass===P1)s=new this.featureClass(h,o,l,2,n,a),s.transform(i.dataProjection);else{let u;if(h=="Polygon"){let p=qI(o,l);u=p.length>1?new Oie(o,"XY",p):new wm(o,"XY",l)}else u=h==="Point"?new $y(o,"XY"):h==="LineString"?new JS(o,"XY"):h==="MultiPoint"?new CD(o,"XY"):h==="MultiLineString"?new Die(o,"XY",l):null;let d=this.featureClass;s=new d,this.geometryName_&&s.setGeometryName(this.geometryName_);let c=zie(u,!1,i);s.setGeometry(c),a!==void 0&&s.setId(a),s.setProperties(n,!0)}return s}getType(){return"arraybuffer"}readFeatures(e,t){let i=this.layers_;t=this.adaptOptions(t);let r=Oi(t.dataProjection);r.setWorldExtent(t.extent),t.dataProjection=r;let s=new xie(e),n=s.readFields(jie,{}),a=[];for(let o in n){if(i&&!i.includes(o))continue;let l=n[o],h=l?[0,0,l.extent,l.extent]:null;r.setExtent(h);for(let u=0,d=l.length;u<d;++u){let c=Hie(s,l,u),p=this.createFeature_(s,c,t);p!==null&&a.push(p)}}return a}readProjection(e){return this.dataProjection}setLayers(e){this.layers_=e}};function jie(e,t,i){if(e===3){let r={keys:[],values:[],features:[]},s=i.readVarint()+i.pos;i.readFields($ie,r,s),r.length=r.features.length,r.length&&(t[r.name]=r)}}function $ie(e,t,i){if(e===15)t.version=i.readVarint();else if(e===1)t.name=i.readString();else if(e===5)t.extent=i.readVarint();else if(e===2)t.features.push(i.pos);else if(e===3)t.keys.push(i.readString());else if(e===4){let r=null,s=i.readVarint()+i.pos;for(;i.pos<s;)e=i.readVarint()>>3,r=e===1?i.readString():e===2?i.readFloat():e===3?i.readDouble():e===4?i.readVarint64():e===5?i.readVarint():e===6?i.readSVarint():e===7?i.readBoolean():null;t.values.push(r)}}function Wie(e,t,i){if(e==1)t.id=i.readVarint();else if(e==2){let r=i.readVarint()+i.pos;for(;i.pos<r;){let s=t.layer.keys[i.readVarint()],n=t.layer.values[i.readVarint()];t.properties[s]=n}}else e==3?t.type=i.readVarint():e==4&&(t.geometry=i.pos)}function Hie(e,t,i){e.pos=t.features[i];let r=e.readVarint()+e.pos,s={layer:t,type:0,properties:{}};return e.readFields(Wie,s,r),s}function qie(e,t){let i;return e===1?i=t===1?"Point":"MultiPoint":e===2?i=t===1?"LineString":"MultiLineString":e===3&&(i="Polygon"),i}var dg=!1,AD=null;typeof window<"u"&&N.onResize.add(()=>{dg=!0,clearTimeout(AD),AD=setTimeout(()=>{dg=!1},300)});function QS(){return N.devicePixelRatio||1}async function ND(e){return e.renderTarget?(e.renderTarget.width!==N.width||e.renderTarget.height!==N.height)&&(e.renderTarget.dispose(),await new Promise(t=>setTimeout(t,50)),e.renderTarget=new zr(N.width,N.height,{depthBuffer:!1,stencilBuffer:!1,samples:1,alpha:!0,minFilter:mi,magFilter:mi,format:Br,type:hr,colorSpace:""})):e.renderTarget=new zr(N.width,N.height,{depthBuffer:!1,stencilBuffer:!1,samples:1,alpha:!0,minFilter:mi,magFilter:mi,format:Br,type:hr,colorSpace:""}),e.currentLayer.renderTarget||e.currentLayer.initRT?.(),e.currentLayer.render3d&&e.currentLayer.render3d(),!!e.currentLayer.renderTarget}async function LD(e,t,i){let r=e.currentLayer.renderTarget.width,s=e.currentLayer.renderTarget.height,n=QS(),a=t*n,o=i*n,l=Math.max(0,Math.min(a,r-1)),h=Math.max(0,Math.min(o,s-1)),u=N.height*n-o-1,d=Math.max(0,Math.min(u,s-1)),[c,p,m,g]=await q.renderer.readRenderTargetPixelsAsync(e.currentLayer.renderTarget,l,h,1,1),[f,y,x,b]=await q.renderer.readRenderTargetPixelsAsync(e.currentLayer.renderTarget,l,d,1,1);return{r:c,g:p,b:m,a:g,flippedY:d}}function PD(e,t,i){if(!e.openLayerMap)return null;let r=e.openLayerMap.getCoordinateFromPixel([t,i]);if(!r)return null;let s;s=Math.abs(r[1])<=90&&Math.abs(r[0])<1e6?r:QT(r);let n=s[0];for(;n>180;)n-=360;for(;n<-180;)n+=360;return{latLon:{lon:n,lat:s[1]},coordinate:r,normalizedLon:n}}function Xie(e,t,i){if(!e.currentLayer||!e.currentLayer.getRenderSource||!i)return null;try{let r=e.currentLayer.getRenderSource(),s=t.getView().getProjection(),n=r.getTileGridForProjection(s),a=t.getView().getResolution(),o=Math.round(n.getZForResolution(a)),l=[i.normalizedLon,i.latLon.lat],h=l;s.getCode()!=="EPSG:4326"&&(h=Jd(l,s));let u=n.getTileCoordForCoordAndZ(h,o);if(!u)return null;let d=Yie(e,n,h,o,u),c=Kie(e,r,s,h);return c&&(d=c),e.currentLayer._url&&d&&(d.url=e.currentLayer._url.replace("{z}",d.z).replace("{x}",d.x).replace("{y}",d.y)),d}catch{return null}}function Yie(e,t,i,r,s){let n=e.currentLayer.currentZoom===void 0?r:e.currentLayer.currentZoom;if(n!==r){let a=t.getTileCoordForCoordAndZ(i,n);if(a)return{x:a[1],y:a[2],z:a[0]}}return{x:s[1],y:s[2],z:s[0]}}function Kie(e,t,i,r){if(!e.currentLayer.activeTiles||!r)return null;let s=null,n=1/0;
2124return e.currentLayer.activeTiles.forEach(a=>{let o=a.tile;if(!o||!o.tileCoord)return;let l=t.getTileGridForProjection(i).getTileCoordExtent(o.tileCoord);if(r[0]>=l[0]&&r[0]<=l[2]&&r[1]>=l[1]&&r[1]<=l[3]){let h=(l[0]+l[2])/2,u=(l[1]+l[3])/2,d=Math.sqrt((r[0]-h)**2+(r[1]-u)**2);d<n&&(n=d,s=o)}}),s&&s.tileCoord?{x:s.tileCoord[1],y:s.tileCoord[2],z:s.tileCoord[0]}:null}async function Zie(e,t,i){if(dg||!e.renderTarget||!e.renderTarget.texture)return{colorR:0,colorG:0,colorB:0,colorA:0};try{if(e.renderTarget.width!==N.width||e.renderTarget.height!==N.height)return{colorR:0,colorG:0,colorB:0,colorA:0};q.renderer.setClearColor(0,0),q.renderer.setRenderTarget(e.renderTarget),q.renderer.render(e.quad,q.camera),q.renderer.setRenderTarget(null),q.renderer.setClearColor(14540253,1)}catch(m){return console.warn("Error rendering visual pixels, likely due to resize:",m),q.renderer.setRenderTarget(null),q.renderer.setClearColor(14540253,1),{colorR:0,colorG:0,colorB:0,colorA:0}}let r=QS(),s=t*r,n=i*r,a=e.renderTarget.width,o=e.renderTarget.height,l=Math.max(0,Math.min(s,a-1)),h=Math.max(0,Math.min(n,o-1)),[u,d,c,p]=await q.renderer.readRenderTargetPixelsAsync(e.renderTarget,l,h,1,1);return{colorR:u,colorG:d,colorB:c,colorA:p}}function Jie(e,t){if(!e.data.legends||!e.provider||!e.provider.value)return{};let i=e.data.legends[e.data.colorOptions.legendIndex||0],r=e.provider.value;if(!i.values||i.values.length===0)return{};let s=bI?.value==="debug",n="index",a={typeId:i?.type?.id,unitId:i?.unit?.id,unitName:i?.unit?.name,valuesLen:i?.values?.length,values:i?.values};try{let w=(e?.data?.name||"").toLowerCase(),M=jt.getUnitTypeForParameter(w);if(w==="ht0"){let S=jt.getPreferredUnit(M),R=S==="ft"?24:13,I=e.data.legends.find(B=>B?.unit?.id===R);I?.values?.length&&(i=I,n=`ht0(unitId=>${R})`),s&&console.log("[PickerDebug] legend preference",{layer:e?.data?.name,parameterName:w,targetUnit:S,targetUnitId:R,selectedUnitId:i?.unit?.id,valuesLen:i?.values?.length})}else{let S=jt.getDefaultUnit(M)||jt.getPreferredUnit(M),R={"%":12,"mm/h":19,mm:9,"cm/h":26,cm:10,"\xB0c":17,"km/h":1,m:6,km:25,hpa:14,"\xB5g/m3":20}[S],I=i?.type?.id,B=$h.legends||[],O=[];if(R!=null&&(O=B.filter(V=>V?.unit?.id===R&&(I==null||V?.type?.id===I))),O.length===0&&S){let V=jt.normalizeUnit(S);O=B.filter(z=>jt.normalizeUnit(z?.unit?.name)===V&&(I==null||z?.type?.id===I))}O.length===0&&R!=null&&(O=B.filter(V=>V?.unit?.id===R));let U=O[0];U?.values?.length&&(i=U,n=`targetUnit(${S}${R==null?"":`=>${R}`})`),s&&console.log("[PickerDebug] legend preference",{layer:e?.data?.name,parameterName:w,unitTypePref:M,targetUnit:S,targetUnitId:R,currentTypeId:I,candidates:O.slice(0,5).map(V=>({typeId:V?.type?.id,unitId:V?.unit?.id,unitName:V?.unit?.name,valuesLen:V?.values?.length})),candidatesCount:O.length})}}catch(w){s&&console.log("[PickerDebug] legend preference error",{layer:e?.data?.name,error:String(w)})}let o=e.data.colorOptions.useRedChannel?t.r:t.b,l=i.values,h,u,d;if(t.a===0||t.r===0&&t.g===0&&t.b===0&&t.a!==255)return{};if(e.data.valueConversion&&typeof e.data.valueConversion=="function")h=e.data.valueConversion(t),u=l&&l.length>0?Math.min(...l):0,d=l&&l.length>0?Math.max(...l):100;else{u=Math.min(...l),d=Math.max(...l);let w=Math.min(o/255,1);h=u+w*(d-u)}s&&console.log("[PickerDebug] legend selection",{layer:e?.data?.name,legendIndex:e?.data?.colorOptions?.legendIndex,reason:n,initial:a,selected:{typeId:i?.type?.id,unitId:i?.unit?.id,unitName:i?.unit?.name,valuesLen:i?.values?.length,values:i?.values},channel:e?.data?.colorOptions?.useRedChannel?"r":"b",rgba:{r:t?.r,g:t?.g,b:t?.b,a:t?.a},min:u,max:d,actualValue:h});let c=e.data.displayName||e.name,p=(e?.data?.name||"").toLowerCase(),m=jt.getUnitTypeForParameter(p),g=i.unit?.name||r.unit||"",f=h,y=u,x=d;if(m&&g){let w=jt.getDefaultUnit(m);w&&w!==g&&(f=jt.convert(h,g,w,m),y=jt.convert(u,g,w,m),x=jt.convert(d,g,w,m),g=w)}let b=`${f.toFixed(2)} ${g}`,_={"%":12,"mm/h":19,mm:9,"cm/h":26,cm:10,"\xB0c":17,"km/h":1,m:6,km:25,hpa:14,"\xB5g/m3":20};(p==="radar"||p==="precip")&&(g=yI.value);let T=_[g]??g;return p==="ht0"&&(T=g==="ft"?24:13),p==="precip"&&T!==10&&(T=9),s&&console.log("[PickerDebug] output",{layer:e?.data?.name,unitType:m,unit:g,unit_id:T,value:f,min:y,max:x,formattedValue:b}),{value:f,min:y,max:x,unit:g,parameter:c,formattedValue:b,unit_id:T}}async function Qie(e,t,i,r){if(!e.UVDataLayer||!e.UVDataLayer.currentLayer||(e.UVDataLayer.render3d&&e.UVDataLayer.render3d(),!e.UVDataLayer.currentLayer.renderTarget))return null;let s=QS(),n=i*s,a=r*s,o=e.UVDataLayer.currentLayer.renderTarget,l=o.width,h=o.height,u=Math.max(0,Math.min(n,l-1)),d=Math.max(0,Math.min(a,h-1)),[c,p,m,g]=await q.renderer.readRenderTargetPixelsAsync(o,u,d,1,1),f=m,y=c,x,b;x=f/255*150+-75,b=y/255*150+-75;let _=Math.sqrt(x*x+b*b),T=Math.atan2(b,x)*180/Math.PI;T=(T+360)%360;let w=(T+180)%360;return{speed:{value:_,unit:t.unit||"km/h",formatted:`${_.toFixed(1)} ${t.unit||"km/h"}`},direction:{value:T,unit:"\xB0",formatted:`${T.toFixed(0)}\xB0`,from:w,fromFormatted:`${w.toFixed(0)}\xB0`},u:x,v:b,rawU:f,rawV:y,rawRGBA:{r:c,g:p,b:m,a:g}}}async function kD(e,t,i,r=!1,s=null){if(dg)return null;if(!r){if(e.isReadingPixel)return null;e.isReadingPixel=!0}if(!e.currentLayer)return r||(e.isReadingPixel=!1),null;try{if(!await ND(e))return r||(e.isReadingPixel=!1),null}catch(g){return console.warn("Error initializing render target:",g),r||(e.isReadingPixel=!1),null}let n=await LD(e,t,i),a={r:n.r,g:n.g,b:n.b,a:n.a},o,l;s?(l={lon:s.lon,lat:s.lat},o={latLon:l,normalizedLon:s.lon}):(o=PD(e,t,i),l=o?.latLon||null);let h=e.openLayerMap?Xie(e,e.openLayerMap,o):null,u=await Zie(e,t,i);Object.assign(a,u);let d=Jie(e,n);Object.assign(a,d);let c=(e?.data?.name||"").toLowerCase(),p=jt.getUnitTypeForParameter(c);if(c==="radar"||c==="precip"){let g=c==="radar"?n.r===0?"mm/h":"cm/h":n.r===0?"mm":"cm";yI.value=c==="radar"?n.r===0?"mm/h":"cm/h":n.r===0?"mm":"cm";let f=a.unit||jt.getPreferredUnit(p);a.value=jt.convert(a.value,f,g,p),a.unit=g,a.symbol=jt.getUnitSymbol(g,p),a.lockUnit=!0}let m=await Qie(e,a,t,i);if(m&&(a.uvData=m),a.x=t,a.y=i,a.tileInfo=h,a.latLon=l,a.parameter=e.data.name,e.isReadingPixel=!1,r||(e.isReadingPixel=!1),r)return a;Oe.value=a}async function ere(e,t,i){if(dg||!e||!e.currentLayer)return null;try{if(!await ND(e))return null}catch(r){return console.warn("Error initializing render target for raw read:",r),null}try{let{r,g:s,b:n,a}=await LD(e,t,i),o=null;try{o=PD(e,t,i)?.latLon||null}catch{}return o?{r,g:s,b:n,a,latLon:o}:{r,g:s,b:n,a}}catch(r){return console.warn("Error reading raw pixel:",r),null}}var e2=2*Math.PI*6378137,tre=e=>e.isMesh?new xt(e.geometry,e.material):e.clone(!1),ire=class extends Hm{constructor(e,t){super(e),this.master=t,this.openLayerMap=t.o
2124penLayerMap,this.container=new Gr,this.renderTarget=null,this.needsRender=!1,this.container.renderOrder=this.master.renderOrder,this.initialRender=!1,this.resizeHandler=Al(()=>this.resize(),350),N.onResize.add(this.resizeHandler),N.onUpdate.add(this.update)}prepareFrame(e){return!0}renderFrame(e){this.updateImage(e),this.container.children.length>0&&!this.needsRender&&(this.needsRender=!0)}render(){super.render(frameState)}updateImage=e=>{if(this.lastFrameState=e,!this.container.children.length)return;let[t,i,r,s]=Xm(e,e.extent),n=r-t,a=s-i,o=1/n,l=1/a;this.container.scale.set(o,l,1),this.container.position.set(-t*o-.5,-i*l-.5,0),this.container.children.forEach(h=>{let u=h.userData.boundingBox,d=h.userData.shift||0;if(u){let c=u.min.x+d*e2,p=u.max.x+d*e2>=t&&c<=r,m=u.max.y>=i&&u.min.y<=s;h.visible=p&&m}}),this.needsRender=!0};update=e=>{if(this.master.opacity===0){this.container.parent&&q.remove(this.container);return}else this.container.parent||q.add(this.container);this.updateOpacity(),this.initialRender&&this.lastFrameState&&(this.updateImage(this.lastFrameState),this.initialRender=!1),this.needsRender&&(this.needsRender=!1,q.scheduleRender())};resize=()=>{this.renderTarget&&setTimeout(()=>{let e=N.width*N.devicePixelRatio,t=N.height*N.devicePixelRatio;this.renderTarget.setSize(e,t),setTimeout(()=>{this.render3d()},1)},1)};#n=e=>{e.geometry.computeBoundingBox();let t=e.geometry.boundingBox.clone(),i=[];for(let r=-ou.value;r<=ou.value;r++){let s=r===0?e:tre(e);s.userData.boundingBox=t,s.userData.shift=r,s.position.x+=r*e2,this.container.add(s),i.push(s)}e.userData._copies=i};add=(e,{noCopy:t=!1}={})=>{t?this.container.add(e):this.#n(e);let i=r=>{r.isMesh&&r.material&&r.material.transparent&&r.material.originalOpacity===void 0&&(r.material.opacity&&r.material.opacity.isNode?r.material.originalOpacity=r.material.opacity.value:r.material.originalOpacity=r.material.opacity)};e.isMesh?i(e):e.traverse(i),this.needsRender=!0,this.initialRender=!0,q.scheduleRender()};remove=e=>{(e.userData._copies||[e]).forEach(t=>this.container.remove(t)),this.needsRender=!0};updateOpacity=()=>{let e=this.master.opacity;this.container.traverse(t=>{t.isMesh&&t.material&&t.material.transparent&&t.material.originalOpacity&&(t.material.opacity&&t.material.opacity.isNode?t.material.opacity.value=e*t.material.originalOpacity:t.material.opacity=e*t.material.originalOpacity)}),this.lastOpacity!==e&&(this.lastOpacity=e,q.scheduleRender())};initRT=()=>{};releaseRT=()=>{};addObject=e=>{this.container.add(e),this.needsRender=!0};removeObject=e=>{this.container.remove(e),this.needsRender=!0};clear=()=>{this.container.clear(),this.needsRender=!0}},rre=class extends u1{constructor(e,t){super(e),this.master=t}createRenderer(){return new ire(this,this.master)}initRT=()=>this.getRenderer().initRT();releaseRT=()=>this.getRenderer().releaseRT();addObject=e=>this.getRenderer().addObject(e);removeObject=e=>this.getRenderer().removeObject(e);clear=()=>this.getRenderer().clear();add=(e,t)=>this.getRenderer().add(e,t);remove=e=>this.getRenderer().remove(e);get texture(){return this.renderTarget?.texture}get renderTarget(){return this.getRenderer().renderTarget}get container(){return this.getRenderer().container}},sre=class NO extends Gr{constructor(t){super(),this.layer=t,this.line=null,this.renderOrder=999999,this._lastFrameState=null,this._postRenderKey=null}attach(){let t=this.layer.srcExtent4326;if(!t)return!1;let[i]=t,[r]=this.layer.openLayerMap.getView().getProjection().getExtent();if(i<=r+2e5)return!1;if(q.scene&&q.scene.children)for(let s=q.scene.children.length-1;s>=0;s--){let n=q.scene.children[s];n instanceof NO&&n.layer===this.layer&&n.dispose()}return this.updateLine(),this.visible=!0,q.add(this),N.onUpdate.add(this.update),!0}updateLine(){let t=this.layer.blur||0,i=this.layer.openLayerMap.getView(),r=i.getResolution(),s=N.width,n=N.height,a=this.layer.srcExtent4326;if(this.line&&this._lastSrcExtent===a&&Math.abs((this._lastBlur||0)-t)<.01&&Math.abs((this._lastRes||0)-r)<1e-6&&this._lastWidth===s&&this._lastHeight===n||(this._lastBlur=t,this._lastRes=r,this._lastWidth=s,this._lastHeight=n,this._lastSrcExtent=a,this.line&&=(this.remove(this.line),this.line.geometry?.dispose(),this.line.material?.dispose(),null),!a))return;let[o,l,h,u]=a,[d]=i.getProjection().getExtent();if(o<=d+2e5)return;let c=0,p=0;t&&s>0&&(c=(t-1)*r,p=(t*n/s-1)*r);let m=fm([[o+c,l+p],[h-c,l+p],[h-c,u-p],[o+c,u-p]]);this.line=new Ll().lines(m).sizeAttenuation(!1).lineWidth(2).transparent
2124(!0).closed(!0).color(4474043).build(),this.line.renderOrder=this.renderOrder,this.add(this.line)}update=()=>{if(!this.visible||!this.line)return;let t=this.layer.openLayerMap;if(!t)return;this._postRenderKey||=t.on("postrender",h=>{this._lastFrameState=h.frameState});let i;i=this._lastFrameState?.extent?this._lastFrameState.extent:Ns(t.getView().calculateExtent(t.getSize()),"EPSG:4326","EPSG:3857");let[r,s,n,a]=i,o=1/(n-r),l=1/(a-s);this.scale.set(o,l,1),this.position.set(-r*o-.5,-s*l-.5,0),this.line?.resize?.(N.width*N.devicePixelRatio,N.height*N.devicePixelRatio),q.scheduleRender()};setVisible(t){this.visible=t,t&&!this.line&&this.updateLine()}dispose(){this._postRenderKey&&=(this.layer.openLayerMap?.un("postrender",this._postRenderKey),null),this.line&&=(this.remove(this.line),this.line.geometry?.dispose(),this.line.material?.dispose(),null),N.onUpdate.remove(this.update),q.remove(this)}},nre=new Un(1,1,1,1),t2=class yg{static renderOrder=1;_pendingForecast=null;_deferTileLoad=!1;constructor(t,i){if(this.openLayerMap=t,this.logger=Id(`[Layer ${i.name}]`),this.tileGroup=new _u,this.imageGroup=new _u,this.particleGroup=new _u,this.data=i,this.animationCompleted=!1,this.onAnimationComplete=new je,this.hiddenLayer=null,this.directRender=this.data.directRender,window.location.search.includes("forceRT")?this.directRender=!1:window.location.search.includes("directRender")&&(this.directRender=!0),this.visible=!1,this.immediateVisible=!1,this.opacity=0,this.tileOpacity=1,this.fadeInTiles=!0,this.isReadingPixel=!1,this.logNextValue=!1,this.extentLine=null,this.currentZoom=this.openLayerMap.getView().getZoom(),this.updateLayerBlur(this.currentZoom),this.onClickHandler=()=>{this.logNextValue=!0},US.add(this.onClickHandler),this.container=new Gr,this.container.renderOrder=this.data.overrideRenderOrder?this.data.overrideRenderOrder:yg.renderOrder,i.opticalFlowLayer&&this.addOpticalFlow(new yg(t,i.opticalFlowLayer)),i.UVDataLayer&&this.addUVData(new yg(t,i.UVDataLayer)),i.overlays)for(let r of i.overlays)r.id==2&&this.addParticles(),r.id==3&&this.addArrows(),r.id==4&&this.addBarbules(),r.id==5&&this.addIsobares();this.layers={},this.overlays={},this.currentLayer=null,this.prevLayer=null,this.percent=Ae(1),this.currentForecastDate=Ae(null),this.currentForecastIndex=0,this.watchers=Wm(),this._onMoveStart=()=>{this.isMoving=!0,this.material?.setPanning?.(!0)},this._onMoveEnd=()=>{if(this.isMoving=!1,setTimeout(()=>{this.isMoving||this.material?.setPanning?.(!1)},1),this.isInit){let r=this.openLayerMap.getView().getZoom();this.currentZoom!==r&&(this.currentZoom=r,this.updateLayerBlur(r))}},this.directRender||(this.material=new Tte(this),this.container.add(this.quad=new xt(nre,this.material)),this.quad.renderOrder=5e6),this.isInit=!1,N.onUpdate.add(this.update),this.openLayerMap.on("movestart",this._onMoveStart),this.openLayerMap.on("moveend",this._onMoveEnd)}init=async()=>{if(this.isInit)return;window.location.search.includes("datalayer")?(this.isUVDataLayer||this.isOpticalFlowLayer||!this.UVDataLayer&&!this.opticalFlowLayer)&&q.add(this.container):!this.isUVDataLayer&&!this.isOpticalFlowLayer&&q.add(this.container),await this.data.loadExtraData();let t=this.provider,i=t?.value?.forecastDates?.length>0;if(t&&i){let r=wo.value,s=r?new Date(r):null;if(s&&!isNaN(s.getTime())){let n=this.findClosestForecastFloor(s);n?(this.currentForecastDate.value=n,this.currentForecastIndex=t.value.forecastDates.indexOf(n),this._deferTileLoad=!1):this._deferTileLoad=!0}else this._deferTileLoad=!0;this.watchers.add(t,async()=>{if(!t.value?.forecastDates?.length)return;if(this._deferTileLoad&&!wo.value){this.updateExtent();return}let n=wo.value?new Date(wo.value):null,a=null;if(n&&!isNaN(n.getTime())&&(a=this.findClosestForecastFloor(n)),!a){if(this._deferTileLoad){this.updateExtent();return}let o=new Date(t.value.startDate);if(!wo.value&&["radar","eumetsat","foudre"].includes(this.data.name)){let h=new Date,u=h.getUTCFullYear(),d=h.getUTCMonth()+1,c=h.getUTCDate(),p=h.getUTCHours(),m=h.getUTCMinutes();o=new Date(`${u}-${String(d).padStart(2,"0")}-${String(c).padStart(2,"0")}T${String(p).padStart(2,"0")}
2124:${String(m).padStart(2,"0")}:00Z`)}let l=t.value.forecastDates.findIndex(({datetime:h})=>new Date(h).getTime()===o.getTime());if(l===-1){let h=0,u=Math.abs(new Date(t.value.forecastDates[0].datetime).getTime()-o.getTime());for(let d=1;d<t.value.forecastDates.length;d++){let c=Math.abs(new Date(t.value.forecastDates[d].datetime).getTime()-o.getTime());c<u&&(u=c,h=d)}l=h}a=t.value.forecastDates[l]}this.currentForecastDate.value=a,this.currentForecastIndex=t.value.forecastDates.indexOf(a),this.updateExtent(),this._deferTileLoad&&wo.value&&(this._deferTileLoad=!1),this._deferTileLoad||this.updateLayer()}),this.watchers.add(this.currentForecastDate,()=>{if(!this._deferTileLoad&&(this.updateLayer(),this.isobares)){let n=this.isobares.visible;this.isobares.setVisible(!1),setTimeout(()=>{this.isobares.dispose(),this.container.remove(this.isobares),this.isobares=null,this.addIsobares(),n&&this.isobares.setVisible(!0)},300)}})}else this._deferTileLoad=!1;this.isInit=!0,this._deferTileLoad||this.updateLayer(),this.addExtentLine()};findClosestForecastFloor(t){let i=this.provider?.value?.forecastDates;if(!i?.length||!(t instanceof Date)||isNaN(t.getTime()))return null;let r=null,s=0,n=i.length-1;for(;s<=n;){let a=Math.floor((s+n)/2);(i[a]._date??new Date(i[a].datetime))<=t?(r=i[a],s=a+1):n=a-1}return r}updateLayer=()=>{if(this._deferTileLoad)return;let t=this.getURL();this.addLayer(t)};addLayer(t){this.animationCompleted=!1;let i=!!this.layers[t],r=this.layers[t]||this.addMapLayer(t);if(i&&(r.setVisible(!0),this.visible&&!this.directRender&&!this.isUVDataLayer&&!this.isOpticalFlowLayer&&r.initRT?.(),r.getRenderer&&r.getRenderer())){let s=r.getRenderer();s.checkTilesDisplayed&&s.checkTilesDisplayed()}if(r.reinitialize(),this.currentLayer)if(r!==this.currentLayer&&this.data.disposeLayerResources&&this.data.disposeLayerResources(),this.prevLayer=this.currentLayer,this.percent.value=0,r.getSource().changed(),r.allTilesDisplayed)this.prepareAnimation();else{let s=null,n=!1,a=()=>{n||(n=!0,s&&clearTimeout(s),this.prepareAnimation())};s=setTimeout(()=>{this.logger.warn("Content loading timeout, forcing animation completion"),a()},1e3),r.onContentReady?.once(()=>{a()})}else{let s=!1,n=()=>{s||(s=!0,clearTimeout(a),this.animatePercent())},a=setTimeout(()=>{s||(window.location.search.includes("extra=map")&&console.warn("Content did not load in time, forcing animation complete."),n())},500);r.onContentReady?.once(n)}r.onContentReady.addOnce(()=>{setTimeout(this.updateParticles,1)}),this.currentLayer=r,this.currentLayer.setVisible(!0),this.visible&&!this.directRender&&!this.isUVDataLayer&&!this.isOpticalFlowLayer&&this.currentLayer.initRT(),this.updateTextureRef()}prepareAnimation=()=>{ue.animationSyncEnabled&&ue.registerLayerReadyForAnimation(this)||this.animatePercent()};startAnimation=()=>{this.animatePercent()};animatePercent=()=>{this.isAnimating=!0,Eu(this.percent,"value");let t=Mi.value=="screenshot"?.01:this.data.fadeDuration;this.data.immediateFade&&(t=.01),Mi.value!=="screenshot"&&!this.data.immediateFade&&(t=Math.max(t,.1)),Ql(this.percent,{value:[0,1],ease:"linear",duration:t,onUpdate:()=>{q.scheduleRender()},onComplete:()=>{if(q.scheduleRender(),this.updateParticles(),this.prevLayer&&this.prevLayer!==this.currentLayer&&(this.prevLayer.setVisible(!1),this.prevLayer.releaseRT?.()),this.prevLayer=null,this.animationCompleted=!0,this.releaseInactiveCachedLayersRT(),this.opacity==1&&N.onAfterUpdate.addOnce(()=>{this.onAnimationComplete.dispatch()}),this._pendingForecast){let i=this._pendingForecast;this._pendingForecast=null,this.setForecast(i)}}})};addMapLayer(t){let i=Object.keys(this.layers);if(i.length>=2)for(let a of i){let o=this.layers[a];if(o!==this.currentLayer&&o!==this.prevLayer){delete this.layers[a],this.openLayerMap.removeLayer(o),o.disposeResources&&o.disposeResources();break}}let r=this.getXYZSource(t),s=null;this.data.name==="cities"&&!mI.value?s=this.getcityLayer():this.data.isObjectLayer?(s=new rre({source:r},this),this.data.init(s,this)):this.data.isImageLayer?(s=new Ste({source:r},{},this),this.data.initImages(s,this)):this.data.isParticleLayer?(s=new Cte({source:r},{},this),this.data.initParticles(s,this)):s=new GQ({source:r},this),s._url=t,s.reinitialize||=()=>{},s.disposeResources||=()=>{},s.releaseRT||=()=>{},s.initRT||=()=>{},s.onContentReady||=new je,s.onAnimationComplete||=new je;let n=this.openLayerMap.getLayers().getArray().some(a=>a===s);return this.layers[t]=s,n||this.openLayerMap.addLayer(s),this.directRender&&s.container&&this.container.add(s.container),s}getcityLayer(){return new uie({declutter:!0,source:new gie({format:new Gie,url:"https://basemaps.arcgis.com/arcgis/rest/services/World_Basemap_v2/VectorTileServer/tile/{z}/{y}/{x}.pbf",tilePixelRatio:1,preload:4}),style:function(t){if((t.get("layer")==="City small scale"||t.get("layer")==="City large scale")&&t.get("SelectionPriority")<114){let i=t.get("_name_fr")||t.get("_name");if(i)return new uc({text:new IF({text:i,font:"12px Arial",fill:new zm({color:"white"}),stroke:new uS({color:"black",width:1})})})}return null}})}getXYZSource(t){let i=[],r=[],s=this.provider.value,n=parseInt(s.maxZoom||this.data.maxZoom||13),a=this.data.zoomFactor,o=this.data.sizeFactor;for(let d=0;d<=n;d++){let c=Math.min(d,n),p=this.openLayerMap.getView().getResolutionForZoom(c);i.push(p/a/o),r.push(256*a*o)}this.updateExtent();let l=this.openLayerMap.getView().getProjection().getExtent(),h=this.srcExtent4326?this.srcExtent4326:l,u=[l[0],l[3]];return new pee({url:t,tileGrid:new c1({extent:h,resolutions:i,tileSize:r[0],origin:u}),crossOrigin:"anonymous",transition:0,tileLoadFunction:async(d,c)=>{let p=d.getImage();p.crossOrigin="anonymous",p.fetchPriority="high",p.decoding="async",d.tileCoord&&d.tileCoord[0],p.src=c}})}updateExtent(){if(this.provider.value&&this.provider.value.model&&this.provider.value.model.boun
2124ds){let i=function(s){return Math.max(Math.min(s,85.05112878),-85.05112878)},t=this.provider.value.model.bounds,r={nw:{lat:i(t.nw.lat),lon:t.nw.lon},se:{lat:i(t.se.lat),lon:t.se.lon}};this.srcExtent=[r.nw.lon,r.se.lat,r.se.lon,r.nw.lat],this.srcExtent4326=Ns(this.srcExtent,"EPSG:4326","EPSG:3857")}else this.srcExtent=null;this.srcExtent&&(this.name=="radar"||this.name=="radar_snow")&&(this.srcExtent=[-12,34,34,72],this.srcExtent4326=Ns(this.srcExtent,"EPSG:4326","EPSG:3857"))}getURL=()=>{let t=null;return t=this.currentForecastDate.value?this.data.getUrl(this.currentForecastDate.value.date_model_run,this.currentForecastDate.value.date_ech):this.data.getUrl(),t};async setVisible(t,i=!1){if(!(this.visible==t&&!i)){if(this.visible=t,this.immediateVisible=t,t?(this.data.onBeforeShow?.(this),await this.init(),this.currentLayer&&(this.container.renderOrder=this.data.overrideRenderOrder?this.data.overrideRenderOrder:yg.renderOrder++),this.currentLayer&&this.currentLayer.reinitialize&&this.currentLayer?.reinitialize(),this.prevLayer&&this.prevLayer.reinitialize&&this.prevLayer?.reinitialize(),!this.isUVDataLayer&&!this.isOpticalFlowLayer&&(this.prevLayer?.initRT(),this.currentLayer?.initRT()),Il.value=this.name,this.data.onAfterShow?.(this),this.extentLine?.setVisible(!0)):(this.data.onBeforeHide?.(this),this.pause(),this.extentLine?.setVisible(!1)),Mi.value=="screenshot"){let r=+!!t;this.opacity=r,this.barbules&&(this.barbules.opacity=r),this.arrows&&(this.arrows.opacity=r),this.particles&&(this.particles.opacity=r),this.isobares&&(this.isobares.opacity=r),q.scheduleRender()}else Eu(this,"opacity"),Ql(this,{opacity:+!!t,duration:Mi.value=="screenshot"?.01:.35,onUpdate:r=>{q.scheduleRender(),this.updateParticles()},onComplete:()=>{q.scheduleRender(),t?this.updateParticles():(this.prevLayer?.disposeResources(),this.currentLayer?.disposeResources(),Il.value===this.name&&(Il.value=""),this.data.onAfterHide?.(this)),this.animationCompleted&&this.opacity==1&&this.onAnimationComplete.dispatch()}});t&&(this.updateTextureRef(),this.updateRenderMaterial()),this.opticalLayer?.setVisible(t),this.UVDataLayer?.setVisible(t),t?ue.onShow.dispatch(this.name):ue.onHide.dispatch(this.name)}}updateGradient=()=>{this.directRender||this.quad.material.updateGradient()};updateRenderMaterial=()=>{this.quad?.material.update(),q.scheduleRender()};updateTextureRef=()=>{this.directRender||(this.currentLayer&&this.currentLayer.texture&&(this.quad.material.uTxtTo.value=this.currentLayer.texture,this.UVDataLayer||(this.arrows&&(this.arrows.dataMap=this.currentLayer.texture),this.barbules&&(this.barbules.dataMap=this.currentLayer.texture),this.particles&&(this.particles.dataMap=this.currentLayer.texture),this.isobares&&(this.isobares.dataMap=this.currentLayer.texture)),this.isUVDataLayer&&(this.parentLayer.arrows&&(this.parentLayer.arrows.dataMap=this.currentLayer.texture),this.parentLayer.barbules&&(this.parentLayer.barbules.dataMap=this.currentLayer.texture),this.parentLayer.particles&&(this.parentLayer.particles.dataMap=this.currentLayer.texture),this.parentLayer.isobares&&(this.parentLayer.isobares.dataMap=this.currentLayer.texture))),this.prevLayer&&this.prevLayer.texture&&(this.quad.material.uTxtFrom.value=this.prevLayer.texture,q.isWebGPU||this.quad.material.update()))};updateParticles=()=>{!this.particles||this.directRender};update=t=>{this.container.visible=this.opacity>1e-6,this.quad&&(this.quad.material.opacity=this.opacity*this.tileOpacity),this.particles&&(this.particles.opacity=this.opacity),this.arrows&&(this.arrows.opacity=this.opacity),this.barbules&&(this.barbules.opacity=this.opacity),this.isobares&&(this.isobares.opacity=this.opacity),this.updateLayerExtends(),this.currentLayer?.setVisible(this.container.visible),this.prevLayer?.setVisible(this.container.visible),this.visible&&(this.updateLayerBlur(this.currentZoom),this.isPlaying&&(this.shouldNext-=t,this.shouldNext<=0&&this.animationCompleted&&(this.shouldNext=this.data.delayBetween*1e3,this.nextForecast())))};async getValuePixel(t,i,r=!1,s=null){return await kD(this,t,i,r,s)}addOpticalFlow=t=>{this.opticalLayer||(t.isOpticalFlowLayer=!0,this.opticalLayer=t,this.opticalLayer.parentLayer=this)};addUVData=t=>{this.UVDataLayer||(t.isUVDataLayer=!0,this.UVDataLayer=t,this.UVDataLayer.parentLayer=this)};addIsobares=()=>{this.isobares||(this.isobares=new bte(this),this.container.add(this.isobares))};addParticles=()=>{this.particles||(this.particles=new lte(this,this.data.isWaterLayer),this.container.add(this.particles))};addArrows=()=>{this.arrows||(this.arrows=new ste(this),this.container.add(this.arrows))};addBarbules=()=>{this.barbules||(this.barbules=new nte(this),this.container.add(this.barbules))};setOverlayVisible=(t,i)=>{if(t=="particles")t=2;else if(t=="arrows")t=3;else if(t=="barbs")t=4;else if(t=="isobars")t=5;else if(typeof t=="string"){console.warn(`Unknown overlay type: ${t}`);return}if(this.isobares&&t==5){this.isobares.setVisible(i);return}this.particles&&(t==2?this.particles.setVisible(i):i&&this.particles.setVisible(!1)),this.arrows&&(t==3?this.arrows.setVisible(i):i&&this.arrows.setVisible(!1)),this.barbules&&(t==4?this.barbules.setVisible(i):i&&this.barbules.setVisible(!1))};setTileOpacity=t=>{Ql(this,{tileOpacity:t,duration:.2,onUpdate:()=>{q.scheduleRender()}})};play(t=0){this.visible&&(this.fadeInTiles=!1,this.isPlaying=!0,this.shouldNext=0,this.playPadding=t)}pause(){this.fadeInTiles=!0,this.isPlaying=!1,this.shouldNext=0}nextForecast=()=>{if(!this.animationCompleted){this.opacity==1&&this.logger.warn("animation not completed");return}this.animationCompleted=!1,this.UVDataLayer&&this.UVDataLayer.nextForecast(),this.opticalLayer&&this.opticalLayer.nextForecast();let t=this.provider;t&&t.value.forecastDates&&(this.currentForecastIndex+=this.data.stepForecast,this.currentForecastIndex%=t.value.forecastDates.length,this.currentForecastDate.value=t.value.forecastDates[this.currentForecastIndex],this.fadeInTiles=!1)};prevForecast=()=>{if(!this.animationCompleted){this.opacity==1&&this.logger.warn("animation not completed");return}this.animationCompleted=!1,this.UVDataLayer&&this.UVDataLayer.prevForecast(),this.opticalLayer&&this.opticalLayer.prevForecast();let t=this.provider;t&&t.value.forecastDates&&(this.currentForecastIndex-=this.data.stepForecast,this.currentForecastIndex<0&&(this.currentForecastIndex=t.value.forecastDates.length-1),this.currentForecastDate.value=t.value.forecastDates[this.currentForecastIndex],this.fadeInTiles=!1)};releaseInactiveCachedLayersRT=()=>{let t=Object.keys(this.layers);for(let i of t){let r=this.layers[i];r!==this.currentLayer&&r!==this.prevLayer&&r.releaseRT?.()}};setForecast=async t=>{this.UVDataLayer&&this.UVDataLayer.setForecast(t),this.opticalLayer&&this.opticalLayer.setForecast(t);let i=this.provider.value;if(!i?.forecastDates?.length)return;let r=new Date(t);if(isNaN(r.getTime())){this.logger.warn("setForecast: invalid dateTime",t);return}let s=i.forecastDates[0]._date,n=i.forecastDates[i.forecastDates.length-1]._date;if(!["radar","eumetsat","foudre"].includes(this.data.name)&&(r<s||r>n)){let o=this.data.providers[1],l=this.data.providers[1].model.fallback;if(o!==i){o.isLoaded||await o.loadExtraData(),this.data.selectedProvider.value=o,this.provider.value=o,setTimeout(()=>{this.setForecast(t),Ps.onChronologicFallback.dispatch(l)},0);return}}let a=this.findClosestForecastFloor(r);if(a&&this.currentForecastDate.value===a){this._pendingForecast=null,this._deferTileLoad&&(this._deferTileLoad=!1,this.updateLayer());return}if(!this.animationCompleted&&!this._deferTileLoad){this._pendingForecast=t;return}this._deferTileLoad=!1,this.currentForecastDate.value=a,this.currentForecastIndex=a?i.forecastDates.indexOf(a):-1,this.fadeInTiles=!1};async setModel(t){let i=this.data.providers.find(r=>r.model.name===t);if(i||=this.data.providers[0],i){if(i===this.provider.value)return;i.isLoaded||await i.loadExtraData(),this.provider.value=i}}updateLayerBlur=t=>{if(!Il.value||!this.data.getBlur)return;let i=this.data.getBlur(t);this.data.colorOptions&&(this.data.colorOptions.blur=i),this.material&&(this.material.options.blur=i,this.material.setBlur(i),this.updateLayerExtends(),this.extentLine?.updateLine(),q.scheduleRender())};updateLayerExtends=()=>
2124{if(!this.material?.uExtends||!this.srcExtent4326)return;let t=this.openLayerMap.getView(),i=this.openLayerMap.getSize(),[r,s,n,a]=Ns(t.calculateExtent(i),"EPSG:4326","EPSG:3857"),[o,,l]=t.getProjection().getExtent(),h=l-o,[u,d,c,p]=this.srcExtent4326,m=(r+n)/2,g=(u+c)/2,f=Math.round((m-g)/h);if(r-=f*h,n-=f*h,u<=o+2e5){let T=this.blur/N.width,w=this.blur/N.height;this.material.uExtends.value.set(-T,-w,1+T,1+w),this.isobares?.uExtends.value.set(0,0,1,1),this.arrows?.uExtends.value.set(0,0,1,1),this.barbules?.uExtends.value.set(0,0,1,1),this.particles?.uExtends.value.set(0,0,1,1),this.extentLine?.uExtends?.value?.set(0,0,1,1);return}let y=(u-r)/(n-r),x=(p-s)/(a-s),b=(c-r)/(n-r),_=(d-s)/(a-s);this.material.uExtends.value.set(y,1-x,b,1-_),this.isobares?.uExtends.value.set(y+this.blur/N.width,1-x+this.blur/N.height,b-this.blur/N.width,1-_-this.blur/N.height),this.particles?.uExtends.value.set(y+this.blur/N.width,1-x+this.blur/N.height,b-this.blur/N.width,1-_-this.blur/N.height),this.arrows?.uExtends.value.set(y+this.blur/N.width,1-x+this.blur/N.height,b-this.blur/N.width,1-_-this.blur/N.height),this.barbules?.uExtends.value.set(y+this.blur/N.width,1-x+this.blur/N.height,b-this.blur/N.width,1-_-this.blur/N.height)};addExtentLine=()=>{if(this.isUVDataLayer||this.isOpticalFlowLayer||this.data?.showExtentLine===!1)return;this.extentLine&&=(this.extentLine.dispose(),null);let t=new sre(this);t.attach()&&(this.extentLine=t)};dispose=()=>{this.watchers.dispose(),N.onUpdate.remove(this.update),US.remove(this.onClickHandler),this.openLayerMap.un("movestart",this._onMoveStart),this.openLayerMap.un("moveend",this._onMoveEnd),this.extentLine&&=(this.extentLine.dispose(),null);for(let t in this.layers)this.layers[t].disposeResources&&this.layers[t].disposeResources(),this.openLayerMap.removeLayer(this.layers[t]);this.material?.dispose(),this.material=null,this.quad&&=(this.quad.geometry&&this.quad.geometry.dispose(),null),this.particles&&=(this.particles.dispose(),null),this.arrows&&=(this.arrows.dispose(),null),this.barbules&&=(this.barbules.dispose(),null),this.isobares&&=(this.isobares.dispose(),null),q.remove(this.container),this.opticalLayer&&=(this.opticalLayer.dispose(),null),this.UVDataLayer&&=(this.UVDataLayer.dispose(),null),this.layers={},this.currentLayer=null,this.prevLayer=null,this.openLayerMap=null,this.data=null,this.container=null,this.tileGroup=null,this.imageGroup=null,this.particleGroup=null,this.percent=null,this.currentForecastDate=null,this.onAnimationComplete=null};get isLoading(){return this.currentLayer&&this.currentLayer.isLoading}get hasForecastDates(){return this.provider&&this.provider.value&&this.provider.value.forecastDates&&this.provider.value.forecastDates.length>0}get label(){return this.data.displayName}get name(){return this.data.name||this.provider.value.label||this.provider.value.layerName||this.label}get backgroundLayer(){return this.provider&&this.provider.value?this.provider.value.backgroundLayer:null}get foregroundLayer(){return this.provider&&this.provider.value?this.provider.value.foregroundLayer:null}get provider(){return this.data.getProvider()||null}get modelId(){return!this.provider||!this.provider.value||!this.provider.value.model?null:this.provider.value.model.name}get blur(){return this.data.colorOptions.blur}get renderOrder(){return this.container.renderOrder}},are=class extends fa{constructor(){super(),this.baseUrl="https://static5.mclcm.net/lcm2018/mapTiles/BordersMC/",this.name="borders",this.overrideRenderOrder=1e7,this.colorOptions.blur=0,this.zoomFactor=1,this.maxZoom=12,this.colorOptions.srgb=!0,this.imageFormat="webp",this.directRender=!0,this.keepZoom4=!1}getUrl=()=>Pu?`${hi(this.baseUrl)}{z}%2F{x}%2F{-y}${encodeURIComponent("."+this.imageFormat)}`:`${hi(this.baseUrl)}{z}/{x}/{-y}.${this.imageFormat}`},ore=class{constructor({id:e="esri-copyright",text:t,containerSelector:i}={}){this.id=e,this.text=t||"Tiles \xA9 Esri \u2014 Source: Esri, USGS, NOAA",this.containerSelector=i||'[id^="map-container-"],#mapContainer,#interactive',this.element=null}ensure(){this.element||this.create()}create(){let e=document.createElement("div");e.id=this.id,e.textContent=this.text,Object.assign(e.style,{position:"absolute",bottom:"0px",right:"0px",backgroundColor:"hsla(0, 0%, 100%, .5)",color:"black",padding:"2px 2px",fontSize:"10px",fontFamily:"Arial, sans-serif",borderRadius:"0px",zIndex:"1000",pointerEvents:"none",userSelect:"none",display:"none",margin:"0 !important",lineHeight:"1"}),(document.querySelector(this.containerSelector)||document.body).appendChild(e),this.element=e}show(){this.element||this.create(),this.element.style.display="block"}hide(){this.element&&(this.element.style.display="none")}remove(){this.element&&=(this.element.remove(),null)}},lre=class extends fa{constructor(){super(),pu.value=="esri-worldimagery"?(this.baseUrl="https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/",this.copyright=new ore({id:"esri-copyright",text:"Tiles \xA9 Esri \u2014 Source: Esri, USGS, NOAA"})):pu.value=="BlueMarbleMCWebp"?this.baseUrl="https://static5.mclcm.net/lcm2018/mapTiles/BlueMarbleMCWebp/":this.baseUrl="https://static5.mclcm.net/lcm2018/mapTiles/BlueMarbleMC/",this.maxZoom=12,this.name="BlueMarble",this.directRender=!0,this.zoomFactor=1,this.colorOptions.blur=0,this.colorOptions.srgb=!0,this.overrideRenderOrder=-1,this.keepZoom4=!0}onBeforeShow(e){}onAfterShow(e){pu.value=="esri-worldimagery"&&this.copyright?.show()}onAfterHide(e){this.copyright?.remove()}getUrl=(e,t)=>
2124Pu&&To.value?`${hi(this.baseUrl)}{z}%2F{y}%2F{x}`:pu.value=="esri-worldimagery"?`${hi(this.baseUrl)}{z}/{y}/{x}`:pu.value=="BlueMarbleMCWebp"?`${hi(this.baseUrl)}{z}/{x}/{-y}.webp`:`${hi(this.baseUrl)}{z}/{x}/{-y}.png`},hre=class extends fa{constructor(){super(),this.baseUrl="https://static5.mclcm.net/lcm2018/mapTiles/MapDataMarineMC/",this.name="MapDataMarine",this.overrideRenderOrder=1e6,this.colorOptions.blur=0,this.colorOptions.srgb=!0,this.zoomFactor=1,this.maxZoom=12,this.directRender=!1,this.imageFormat="webp"}getUrl=(e,t)=>Pu?`${hi(this.baseUrl)}{z}%2F{x}%2F{-y}${encodeURIComponent("."+this.imageFormat)}`:`${hi(this.baseUrl)}{z}/{x}/{-y}${"."+this.imageFormat}`},ure=class extends fa{constructor(){super(),this.name="mask",this.colorOptions.blur=0,this.minZoom=0,this.maxZoom=0,this.overrideRenderOrder=500001,this.isObjectLayer=!0,this.directRender=!0}init(e){let t=[[51.104,-11.998],[53.463,-11.997],[53.523,-11.938],[53.55,-11.842],[53.705,-11.666],[53.713,-11.601],[53.887,-11.363],[53.957,-11.148],[54.038,-11.061],[54.077,-10.851],[54.292,-10.235],[54.345,-10.19],[54.553,-10.153],[54.825,-10.032],[54.909,-9.936],[55.158,-9.759],[55.551,-9.275],[55.763,-8.882],[55.842,-8.829],[55.903,-8.839],[55.997,-8.939],[56.089,-9.095],[56.098,-9.215],[56.161,-9.247],[56.25,-9.367],[56.31,-9.517],[56.432,-9.64],[56.522,-9.79],[56.658,-9.893],[56.764,-10.032],[57.004,-10.182],[57.036,-10.244],[57.369,-10.395],[57.828,-10.463],[57.891,-10.517],[57.972,-10.516],[58.028,-10.463],[58.457,-10.395],[58.623,-10.308],[58.699,-10.304],[58.904,-10.116],[59.062,-10.032],[59.116,-9.936],[59.365,-9.699],[59.454,-9.549],[59.577,-9.426],[59.617,-9.302],[59.758,-9.124],[59.797,-8.975],[59.97,-8.67],[59.974,-8.563],[60.152,-8.155],[60.186,-7.898],[60.333,-7.4],[60.364,-7.24],[60.364,-6.865],[60.395,-6.786],[60.395,-6.32],[60.425,-6.242],[60.425,-5.894],[60.364,-5.482],[60.363,-5.069],[60.152,-4.132],[60.035,-3.875],[59.94,-3.527],[59.797,-3.312],[59.788,-3.194],[59.676,-3.07],[59.607,-2.891],[59.545,-2.859],[59.464,-2.727],[59.517,-2.428],[59.487,-2.336],[59.517,-2.247],[59.517,-1.778],[59.487,-1.7],[59.425,-.711],[59.334,-.319],[59.248,-.122],[59.244,.045],[59.157,.211],[59.153,.287],[59.101,.35],[59.062,.559],[58.955,.701],[58.699,1.225],[58.575,1.349],[58.517,1.467],[58.366,1.588],[58.336,1.679],[58.124,1.861],[57.997,1.918],[57.791,2.072],[57.453,2.171],[57.308,2.254],[56.794,2.254],[56.708,2.171],[56.491,2.133],[56.098,1.951],[56.005,1.828],[55.867,1.728],[55.806,1.718],[55.656,1.814],[55.527,1.976],[55.188,2.284],[54.76,2.444],[54.643,2.526],[54.276,2.534],[54.112,2.661],[54.038,2.799],[53.705,3.071],[53.463,3.192],[53.156,3.261],[53.093,3.314],[52.715,3.314],[52.652,3.261],[52.524,3.239],[52.439,3.31],[52.415,3.432],[52.432,3.598],[52.46,3.653],[52.546,3.682],[55.549,3.09],[55.695,5.596],[55.793,9.079],[55.907,9.113],[56.194,9.015],[56.369,8.989],[56.432,8.915],[56.266,7.898],[56.239,6.836],[56.288,6.275],[56.388,5.692],[56.636,4.85],[56.876,4.323],[57.207,3.813],[57.623,3.396],[57.95,3.2],[58.298,2.265],[58.525,1.849],[58.734,1.549],[58.962,1.296],[59.18,1.115],[59.349,1.005],[59.691,.873],[60.037,.847],[60.293,.9],[60.569,1.03],[60.919,1.329],[61.009,1.355],[61.368,.975],[61.705,.719],[62.087,.576],[62.424,.567],[62.717,.657],[63.09,.908],[63.435,1.313],[63.715,1.81],[63.987,2.522],[64.203,3.43],[64.335,4.579],[64.351,5.533],[64.634,5.786],[64.865,6.066],[65.165,6.584],[65.272,6.835],[65.343,6.883],[65.574,6.919],[65.832,7.037],[66.324,7.465],[66.414,7.427],[66.606,7.135],[66.869,6.842],[67.234,6.585],[67.457,6.511],[67.754,6.502],[67.974,6.568],[68.223,6.721],[68.43,6.917],[68.612,7.15],[68.973,7.826],[69.285,8.764],[69.526,9.948],[69.874,10.155],[70.101,10.377],[70.331,10.686],[70.639,11.297],[70.852,11.905],[70.993,12.429],[71.2,13.538],[71.338,14.939],[71.366,16.303],[71.654,16.693],[71.953,17.296],[72.229,18.149],[72.431,19.02],[72.63,20.461],[72.717,22.032],[72.716,22.84],[72.663,23.959],[72.566,24.927],[72.4,25.941],[72.545,27.079],[72.621,28.364],[72.325,32.385],[72.104,33.332],[71.925,33.875],[71.71,34.376],[71.358,34.931],[71.14,35.147],[70.881,35.304],[70.578,35.356],[70.403,35.325],[70.199,35.237],[69.778,34.871],[69.507,34.489],[69.252,34.002],[69.018,33.414],[68.777,32.604],[68.596,31.725],[68.54,31.656],[68.428,31.677],[68.142,32.099],[67.833,32.393],[67.481,32.573],[67.227,32.605],[67.071,32.588],[66.805,32.494],[66.384,32.179],[66.011,31.705],[65.894,31.69],[65.851,31.736],[65.586,32.696],[65.366,33.227],[65.111,33.681],[64.962,33.887],[64.741,34.112],[59.785,31.123],[59.754,30.929],[59.385,30.345],[59.117,29.733],[58.884,28.938],[58.729,28.014],[58.516,27.536],[58.242,26.632],[58.098,25.782],[58.046,25.015],[58.051,24.503],[58.139,23.572],[58.032,23.088],[57.935,22.359],[57.878,22.294],[57.345,22.364],[57.082,22.326],[56.871,22.249],[56.448,21.975],[56.166,21.68],[55.993,21.448],[55.896,21.41],[55.841,21.439],[55.548,21.804],[55.278,22.036],[54.926,22.228],[54.503,22.342],[54.27,23.067],[53.932,23.722],[53.569,24.147],[53.128,24.476],[52.813,24.603],[52.443,24.646],[52.137,24.615],[51.893,24.516],[51.758,24.5],[51.387,24.971],[51.09,25.224],[50.757,25.419],[50.41,25.522],[49.994,25.535],[49.799,25.495],[49.467,25.368],[49.115,25.143],[48.784,24.824],[48.442,24.339],[48.201,23.843],[47.965,23.058],[47.87,22.345],[47.858,21.893],[47.965,21.018],[48.138,20.418],[48.149,20.288],[47.966,19.508],[47.764,19.216],[47.45,18.587],[47.199,17.722],[47.162,17.454],[47.162,17.089],[47.187,16.063],[47.231,15.683],[47.126,15.61],[46.809,15.571],[46.369,15.571],[46.123,15.504],[45.672,15.229],[45.372,14.916],[45.143,14.556],[44.982,14.2],[44.844,13.723],[44.717,13.513],[44.626,13.513],[44.582,13.557],[44.416,14.051],[44.219,14.435],[44,14.728],[43.72,14.997],[43.629,15.478],[43.493,15.859],[43.306,16.216],[43.039,16.551],[42.667,16.843],[42.433,16.953],[42.178,17.019],[41.849,17.033],[41.621,16.992],[41.265,16.855],[41.183,16.876],[41.018,17.565],[40.865,17.917],[40.68,18.229],[40.525,18.415],[40.214,18.681],[39.74,18.894],[39.522,18.934],[39.165,18.92],[38.891,18.854],[38.548,18.671],[38.262,18.442],[37.961,18.056],[37.751,17.632],[37.588,17.073],[37.502,17.044],[37.249,17.087],[36.964,17.086],[36.636,17.006],[36.303,16.844],[35.903,16.498],[35.709,16.243],[35.494,15.806],[35.367,15.398],[35.303,14.951],[35.331,14.428],[35.477,13.896],[35.696,13.445],[35.992,13.077],[36.33,12.809],[36.727,12.634],[37.091,12.58],[37.43,12.607],[37.7,12.694],[38.097,12.94],[38.356,13.196],[38.547,13.475],[38.681,13.725],[38.852,14.279],[38.906,14.347],[39.255,14.295],[39.595,14.308],[39.871,14.378],[39.971,14.334],[40.042,13.847],[40.126,13.642],[40.304,13.351],[40.133,12.625],[40.119,11.904],[40.055,11.84],[39.539,11.794],[39.17,11.646],[38.859,11.412],[38.536,11.037],[38.288,10.584],[38.143,10.107],[38.088,9.634],[38.124,8.985],[38.189,8.698],[38.36,8.252],[38.485,8.02
21246],[38.728,7.702],[38.974,7.476],[39.133,7.375],[39.384,7.082],[39.617,6.907],[39.842,6.771],[40.249,6.645],[40.566,6.248],[40.912,5.948],[41.033,5.359],[41.17,4.897],[41.089,4.766],[40.982,4.742],[40.572,5.205],[40.266,5.423],[40.045,5.534],[39.718,5.643],[39.172,5.666],[38.73,5.555],[38.508,5.444],[38.184,5.207],[37.963,4.986],[37.657,4.528],[37.547,4.329],[37.54,4.252],[37.394,3.916],[37.262,3.272],[37.284,2.323],[37.35,1.949],[37.476,1.632],[37.482,1.52],[37.201,.923],[37.184,.775],[37.047,.675],[36.648,.697],[36.397,.652],[35.899,.478],[35.692,.34],[35.352,.022],[35.152,-.244],[34.867,-.793],[34.736,-1.207],[34.668,-1.653],[34.647,-2.145],[34.691,-2.628],[34.825,-3.091],[34.67,-3.386],[34.517,-3.887],[34.451,-4.288],[34.429,-4.76],[34.451,-5.064],[34.539,-5.53],[34.626,-5.813],[34.801,-6.207],[34.923,-6.418],[35.154,-6.714],[35.413,-6.95],[35.588,-7.061],[35.694,-7.492],[35.825,-7.818],[36.067,-8.236],[36.39,-8.604],[36.787,-8.89],[37.25,-9.067],[37.833,-9.09],[38.127,-9.023],[38.433,-8.878],[38.57,-8.847],[38.664,-8.914],[39.125,-9.067],[39.649,-9.089],[40.127,-8.966],[40.592,-8.673],[40.839,-8.43],[40.926,-8.424],[40.985,-8.488],[41.034,-9.061],[41.168,-9.631],[41.341,-10.066],[41.754,-10.697],[42.129,-11.028],[42.5,-11.246],[42.827,-11.355],[43.008,-11.378],[43.511,-11.355],[43.816,-11.268],[43.98,-11.185],[44.285,-10.975],[44.592,-10.691],[44.822,-10.393],[45.063,-9.935],[45.173,-9.646],[45.287,-9.048],[45.327,-8.963],[45.348,-8.232],[45.291,-7.833],[45.543,-7.1],[45.632,-6.5],[45.61,-5.939],[45.631,-5.853],[45.543,-5.325],[45.432,-4.93],[45.231,-4.469],[45.458,-3.859],[45.697,-3.74],[45.79,-3.74],[45.864,-3.864],[46.027,-4.493],[46.182,-4.866],[46.232,-5.335],[46.414,-6.028],[46.664,-6.585],[47.074,-7.177],[47.358,-7.461],[47.597,-7.632],[48.074,-7.848],[48.482,-7.92],[48.804,-8.307],[48.881,-8.351],[48.925,-8.428],[49.105,-8.517],[49.137,-8.579],[49.349,-8.67],[49.62,-8.73],[50.076,-8.716],[50.148,-8.761],[50.195,-9.783],[50.404,-10.561],[50.408,-10.699],[50.576,-11.022],[50.59,-11.152],[50.68,-11.333],[51.104,-11.998]],i=BK(t,{opacity:.3,color:0});e.add(i);let r=fm(hI(lI(t),5e4)),s=new Ll().lines(r).sizeAttenuation(!1).lineWidth(2).transparent(!0).closed(!0).dash({count:500,ratio:.5}).color(4474043).build();s.userData.boundingBox=s.geometry.boundingBox,s.renderOrder=2,e.add(s),N.onResize.add(()=>{s?.resize(N.width*N.devicePixelRatio,N.height*N.devicePixelRatio)})}getUrl=(e,t)=>
2124""},dre=class extends fa{constructor(){super(),this.baseUrl="https://static5.mclcm.net/lcm2018/mapTiles/MapDataTerrestreMC/",this.name="MapDataTerrestre",this.overrideRenderOrder=1e6,this.colorOptions.blur=0,this.colorOptions.srgb=!0,this.zoomFactor=1,this.maxZoom=12,this.directRender=!1,this.imageFormat="webp"}getUrl=(e,t)=>Pu?`${hi(this.baseUrl)}{z}%2F{x}%2F{-y}${encodeURIComponent("."+this.imageFormat)}`:`${hi(this.baseUrl)}{z}/{x}/{-y}${"."+this.imageFormat}`},cre=`<svg viewBox="0 0 75.2 192" xmlns="http://www.w3.org/2000/svg">
2125<g>
2126	<path fill="var(--boat-stroke)" d="M65.3,36c-1.7-21-2.5-23.3-4-24.4C54,8.2,45.9,6.7,37.9,7.4h-0.5c-8-0.6-16.1,0.8-23.4,4.2
2127		c-1.5,1.1-2.5,6.1-4.2,27.1C8.9,49,8.4,61.7,8.4,70.4c0.3,16.3,3.8,37.6,6.3,53.7c4.5,22.8,22.9,60.8,22.9,60.8
2128		s18.2-37.8,22.7-60.6c2.5-16.1,6-40.3,6.3-56.6C66.6,58.9,66.1,46.2,65.3,36z"/>
2129	<path fill="currentColor" d="M45.6,134.1c-0.1-0.6-0.5-1.1-1.1-1.2l-0.2,0c-4.4-0.9-8.9-0.9-13.3,0l-0.2,0c-0.6,0.1-1,0.6-1.1,1.1l0,0.2
2130		c-0.3,2.4-0.4,4.9-0.4,7.3l0,0c0,2.4,0.1,4.9,0.4,7.3v0.2c0.
21301,0.6,0.5,1.1,1,1.2l0.2,0c4.4,1.1,9,1.1,13.5,0l0.3-0.1
2131		c0.5-0.1,0.9-0.6,1-1.1v-0.3c0.5-4.8,0.5-9.7,0-14.5V134.1z M42.8,147.8c-3.4,0.7-6.9,0.7-10.3,0c-0.4-4.1-0.4-8.1,0-12.2
2132		c3.4-0.5,6.9-0.5,10.3,0C43.1,139.6,43.1,143.7,42.8,147.8z"/>
2133	<path fill="currentColor" d="M56.9,43.5c-0.1-0.9-1.4-12.6-1.4-12.6c-0.1-4.1-3.4-7.4-7.5-7.7H27.2c-4.1,0.2-7.4,3.5-7.5,7.6c0,0-1.9,11.9-2.1,12.8
2134		c-1.8,1.8-2.8,4.2-2.8,6.8c-0.4,5.6-0.7,12.3-0.7,19.4c-0.1,11.1,0.5,22.3,1.7,33.3c0.6,9.2,8.2,16.5,17.5,16.6l8.3,0
2135		c9.3-0.2,16.8-7.4,17.5-16.6C60.5,92,61,80.9,61,69.8c0-7-0.2-13.7-0.7-19.4C60.3,47.7,59,45.2,56.9,43.5z M44.9,69.9v-1h0.5
2136		c0.4,0,0.7,0,1.1-0.1c0.1,0,0.2,0,0.3,0c0.3,0,0.6-0.1,0.9-0.1c0.1,0,0.1,0,0.2,0c0.4-0.1,0.7-0.2,1-0.2c0.1,0,0.2,0,0.2-0.1
2137		c0.3-0.1,0.5-0.2,0.8-0.3l0.3-0.1c0.3-0.1,0.7-0.3,1-0.4l0.1-0.1c0.3-0.1,0.6-0.3,0.8-0.5l0.2-0.2c0.3-0.2,0.5-0.3,0.7-0.5l0.1-0.1
2138		c0.3-0.2,0.5-0.4,0.8-0.7l0.2-0.2c0.2-0.2,0.4-0.4,0.6-0.6l0.2-0.2c0.2-0.3,0.5-0.5,0.7-0.8l0.1-0.2c0.2-0.2,0.3-0.5,0.5-0.7
2139		l0.2-0.2l0.1-0.1c0,0.7,0,1.3,0,2l0,5.3H44.9z M52.5,71.9l-0.6,19c0.3,4.3-2.8,8-7,8.6V71.9H52.5z M44.9,67v-8.9l11.5,0
2140		c-0.1,0.3-0.2,0.7-0.2,1l-0.1,0.3c-0.1,0.2-0.2,0.5-0.2,0.7l-0.2,0.3c-0.1,0.2-0.2,0.4-0.3,0.5c-0.1,0.2-0.1,0.2-0.2,0.4
2141		c-0.1,0.1-0.2,0.3-0.3,0.5c-0.1,0.2-0.2,0.2-0.2,0.3s-0.2,0.3-0.3,0.5l-0.3,0.3c-0.1,0.1-0.2,0.3-0.4,0.4l-0.3,0.3
2142		c-0.1,0.1-0.3,0.3-0.4,0.4l-0.3,0.3c-0.1,0.1-0.3,0.2-0.4,0.3L52,64.9c-0.1,0.1-0.3,0.2-0.5,0.3c-0.2,0.1-0.2,0.2-0.4,0.2
2143		c-0.1,0.1-0.3,0.2-0.5,0.3c-0.2,0.1-0.3,0.1-0.4,0.2S50,66,49.8,66.1c-0.2,0.1-0.3,0.1-0.4,0.2c-0.1,0.1-0.4,0.1-0.5,0.2
2144		c-0.2,0.1-0.3,0.1-0.4,0.1c-0.1,0-0.4,0.1-0.6,0.1c-0.2,0-0.3,0.1-0.4,0.1c-0.2,0-0.4,0.1-0.7,0.1c-0.1,0-0.2,0-0.3,0
2145		c-0.3,0-0.7,0.1-1,0.1H44.9z M21.5,46.4c0.2-0.5,2-13.4,2-13.4l0,0c0.1-2.3,1.9-4.2,4.2-4.4h19.8c2.3,0.1,4.1,2,4.2,4.4
2146		c0,0,1.3,12.9,1.5,13.4c0.2,0.8,2.7,0.9,3,5.2c0.1,1.4,0.2,3,0.3,4.5H42.9l0,28.1H32.2V56.2H18.8c0.1-1.6,0.2-3.1,0.3-4.5
2147		C19.4,47.3,21.3,47.2,21.5,46.4z M42.9,86.2v13.3l-10.7,0V86.2H42.9z M22.7,71.9h7.6v27.6c-4.2-0.6-7.3-4.4-7-8.6l0,0L22.7,71.9z
2148		 M18.5,69.9v-2.1c0-1.7,0-3.3,0.1-4.9l0,0l0.2,0.2c0.2,0.2,0.3,0.5,0.5,0.7l0.2,0.2c0.2,0.3,0.4,0.5,0.7,0.8l0.2,0.2
2149		c0.2,0.2,0.4,0.4,0.6,0.6l0.2,0.2c0.3,0.2,0.5,0.4,0.8,0.6l0.1,0c0.3,0.2,0.5,0.4,0.8,0.5l0.3,0.2c0.3,0.1,0.5,0.3,0.8,0.4l0.2,0.1
2150		c0.3,0.2,0.6,0.3,1,0.4l0.2,0.1c0.3,0.1,0.5,0.2,0.8,0.3c0.1,0,0.2,0,0.3,0.1c0.3,0.1,0.7,0.2,1,0.2c0.1,0,0.1,0,0.2,0
2151		c0.3,0.1,0.6,0.1,0.9,0.1c0.1,0,0.2,0,0.3,0c0.4,0,0.7,0,1.1,0h0.7v1L18.5,69.9z M29.6,67c-0.3,0-0.7,0-1,0v0c-0.1,0-0.2,0-0.3,0
2152		c-0.2,0-0.4-0.1-0.7-0.1c-0.1,0-0.3-0.1-0.4-0.1c-0.1,0-0.4-0.1-0.6-0.1c-0.2-0.1-0.3-0.1-0.4-0.1c-0.1,0-0.4-0.1-0.5-0.2
2153		c-0.2-0.1-0.3-0.1-0.4-0.2c-0.1-0.1-0.3-0.1-0.5-0.2c-0.2-0.1-0.3-0.1-0.4-0.2c-0.1-0.1-0.3-0.2-0.5-0.3c-0.2-0.1-0.2-0.2-0.4-0.2
2154		c-0.1-0.1-0.3-0.2-0.4-0.3c-0.1-0.1-0.2-0.2-0.4-0.3c-0.1-0.1-0.3-0.2-0.4-0.3c-0.1-0.1-0.2-0.2-0.3-0.3c-0.1-0.1-0.3-0.2-0.4-0.4
2155		l-0.3-0.3L21,63l-0.3-0.3c-0.1-0.1-0.2-0.3-0.3-0.4l-0.2-0.4c-0.1-0.2-0.2-0.3-0.3-0.5L19.6,61c-0.1-0.2-0.2-0.3-0.2-0.5l-0.2-0.4
2156		c-0.1-0.2-0.1-0.4-0.2-0.5l-0.1-0.4c-0.1-0.2-0.1-0.4-0.2-0.5c0-0.1,0-0.1,0-0.2c0-0.1,0-0.2,0-0.3h11.6V67H29.6z M41.6,114.4h-7.9
2157		c-7.3-0.2-13.2-5.9-13.6-13.2c-1.1-9.7-1.5-19.5-1.5-29.3h2.3l0.6,19c-0.3,5.3,3.6,10,8.9,10.6h14.5c5.3-0.6,9.2-5.2,8.9-10.6
2158		l0.7-19h2.3c0,9.8-0.5,19.6-1.6,29.3C54.8,108.5,48.8,114.2,41.6,114.4z"/>
2159	<path fill="currentColor" d="M37.9,4c12.6,0,22.3,1.6,26.5,4.4c1.7,1.1,2.6,3.4,3.5,9c0.6,3.6,1.2,8.7,1.8,15.1
2160		c0.9,10.8,1.5,24.2,1.5,33.4c-0.4,17.2-2.1,34.5-4.9,51.4c-5.5,32.8-24.9,67.9-25.6,69.2c-0.3,0.5-0.7,0.9-1.2,1.2
2161		c-0.6,0.3-1.2,0.5-1.8,0.5c-1.3,0-2.4-0.7-3.1-1.7c-1.2-2.2-20.2-37-25.6-69.2C6,100.2,4.4,82.9,4,65.7c0-9.2,0.6-22.6,1.5-33.4
2162		C6,26.1,6.6,21.1,7.3,17.3c0.9-5.5,1.9-7.9,3.5-9C15.1,5.6,24.7,4,37.3,4H37.9 M37.9,0h-0.6c-7.8,0-22,0.7-28.7,5
2163		c-3.1,2-4.3,5.6-5.3,11.6C2.7,20.5,2.1,25.7,1.6,32C0.6,42.9,0,56.5,0,65.8c0.4,17.4,2.1,34.8,5,52c5.5,33.2,25.3,69,26.1,70.5
2164		c1.4,2.4,3.9,3.7,6.5,3.7c1.3,0,2.6-0.3,3.8-1c1.1-0.6,2-1.6,2.7-2.6c0.9-1.5,20.6-37.3,26.1-70.5c2.9-17.2,4.6-34.6,5-52
2165		c0-9.3-0.6-22.8-1.6-33.7c-0.6-6.3-1.2-11.5-1.8-15.4c-1-6-2.2-9.6-5.3-11.
21656C59.9,0.7,45.7,0,37.9,0L37.9,0z"/>
2166	<path fill="currentColor" d="M71.3,65.7c0-9.2-0.6-22.6-1.5-33.4c-0.6-6.4-1.2-11.4-1.8-15.1c-0.9-5.5-1.9-7.9-3.5-9C60.1,5.6,50.5,4,37.9,4h-0.6
2167		C24.7,4,15.1,5.6,10.8,8.3c-1.7,1.1-2.6,3.4-3.5,9C6.6,21.1,6,26.1,5.5,32.4C4.6,43.2,4,56.6,4,65.7c0.4,17.2,2.1,34.5,4.9,51.4
2168		c5.4,32.2,24.4,67,25.6,69.2c0.6,1.1,1.8,1.7,3.1,1.7c0.6,0,1.3-0.2,1.8-0.5c0.5-0.3,0.9-0.7,1.2-1.2c0.7-1.3,20.2-36.4,25.6-69.2
2169		C69.2,100.2,70.9,82.9,71.3,65.7z M15.2,12.4c7-3,14.6-4.3,22.2-3.7h0.5C45.4,8.1,53,9.4,60,12.4c1.7,1.2,3.1,13.1,4,26.3l-2-0.9
2170		c-0.7-0.3-1.1-0.9-1.2-1.7c-1.4-19.9-3-21-3.6-21.4c-6.1-2.7-12.8-3.8-19.5-3.3h-0.4C30.7,10.9,24,12,17.9,14.7
2171		c-0.5,0.4-2.2,1.5-3.6,21.4c-0.1,0.7-0.5,1.4-1.1,1.7l-1.9,0.9C12.1,25.6,13.5,13.6,15.2,12.4z M37.6,183.3
2172		c-4.7-9.4-8.8-19.2-12.4-29.1l1.5-0.6c0.2-0.1,0.4-0.1,0.5,0c0.2,0.1,0.3,0.2,0.4,0.4c2.6,6.6,5.1,12.2,6.7,15.7
2173		c0.3,0.7,0.9,1.3,1.7,1.7c1.7,0.8,3.8,0.1,4.6-1.7c1.6-3.5,4.1-9.1,6.7-15.8c0.1-0.2,0.2-0.3,0.4-0.4c0.2-0.1,0.4-0.1,0.5,0
2174		l1.7,0.7C46.4,164.1,42.3,173.8,37.6,183.3z M65,66.4c-0.4,16.7-1.9,33.4-4.5,49.9c-2.5,12.5-5.9,24.7-10.1,36.7l-1.6-0.7
2175		c0,0,0,0-0.1,0c-1-0.4-2.2,0.1-2.6,1.1c-2.6,6.6-5.1,12.2-6.7,15.7c-0.2,0.4-0.6,0.8-1,1c-1.1,0.5-2.4,0.1-2.9-1
2176		c-1.6-3.5-4.1-9.1-6.7-15.7c-0.2-0.5-0.6-0.9-1.1-1.1c-0.5-0.2-1.1-0.2-1.6,0l-1.5,0.7c-4.2-11.9-7.6-24.1-10.1-36.6
2177		c-2.6-16.5-4.1-33.2-4.5-49.9c0-6.8,0.3-16.7,1-26.2l2.5-1.2c1.1-0.5,1.8-1.6,1.9-2.8c1.3-18.7,2.9-20.3,3-20.4
2178		c5.9-2.6,12.3-3.6,18.7-3.1h0.4c6.4-0.6,12.8,0.5,18.7,3.1c0.2,0.1,1.7,1.8,3,20.4c0.1,1.2,0.8,2.3,1.9,2.8l2.6,1.2
2179		C64.7,49.7,65,59.6,65,66.4L65,66.4z"/>
2180</g>
2181</svg>`,ms=new class{constructor(){this.styleId="mapjs-routing-styles",this.customStyles={},this.onStyleChange=null,this.styles=this.getStyles()}getStyles(){return this.mergeStyles({waypoint:{position:"absolute",transform:"translate(-50%, -50%)",pointerEvents:"auto",cursor:"grab",zIndex:21,touchAction:"none"},circle:{width:"32px",height:"32px",borderRadius:"50%",background:"linear-gradient(135deg, #42a5f5 0%, #1565c0 100%)",border:"2px solid #fff",boxShadow:"0 4px 12px rgba(21, 101, 192, 0.3), 0 2px 4px rgba(0, 0, 0, 0.1), inset 0 1px 2px rgba(255, 255, 255, 0.3)",display:"flex",alignItems:"center",justifyContent:"center",fontFamily:'"Helvetica Neue", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif',fontWeight:700,fontSize:"12px",color:"#fff",textShadow:"0 1px 2px rgba(0, 0, 0, 0.2)",transition:"all 0.2s cubic-bezier(0.4, 0, 0.2, 1)",userSelect:"none"},circleSelected:{width:"40px",height:"40px",boxShadow:"0 4px 12px rgba(21, 101, 192, 0.3), 0 2px 4px rgba(0, 0, 0, 0.1), inset 0 1px 2px rgba(255, 255, 255, 0.3), 0 0 0 4px rgba(21, 101, 192, 0.4)"},removeButton:{position:"absolute",top:"-8px",right:"-8px",width:"20px",height:"20px",borderRadius:"50%",background:"linear-gradient(135deg, #ff6b6b 0%, #d32f2f 100%)",border:"2px solid #fff",boxShadow:"0 2px 6px rgba(211, 47, 47, 0.3)",alignItems:"center",justifyContent:"center",cursor:"pointer",pointerEvents:"auto",fontSize:"12px",color:"#fff",fontWeight:700,lineHeight:1},segmentLabel:{position:"absolute",pointerEvents:"none",zIndex:20,fontFamily:'"Helvetica Neue", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif',fontWeight:600,fontSize:"11px",color:"#1565c0",background:"rgba(255, 255, 255, 0.85)",padding:"2px 6px",borderRadius:"8px",whiteSpace:"nowrap",textShadow:"none",boxShadow:"0 1px 3px rgba(0, 0, 0, 0.1)",minPixelDistance:100},label:{},line:{lineWidth:3,color:1402304},boat:{fill:"#021B5F",stroke:"#ffffff",strokeWidth:2,width:20,height:51,anchor:"center",headingOffset:180,svg:null}},this.customStyles)}mergeStyles(e,t){let i={...e};for(let r in t)typeof t[r]=="object"&&!Array.isArray(t[r])?i[r]={...e[r],...t[r]}:i[r]=t[r];return i}generateCSS(){let e=this.styles,t={...e.circle,...e.circleSelected},{html:i,...r}=e.removeButton,{minPixelDistance:s,...n}=e.segmentLabel,a=e.boat;return`
2182			.routing-waypoint {
2183				${this.objToCSS(e.waypoint)}
2184			}
2185			.routing-waypoint-circle {
2186				${this.objToCSS(e.circle)}
2187			}
2188			.routing-waypoint-circle--selected {
2189				${this.objToCSS(t)}
2190			}
2191			.routing-waypoint-label {
2192				${this.objToCSS(e.label)}
2193			}
2194			.routing-waypoint-remove {
2195				${this.objToCSS(r)}
2196			}
2197			.routing-segment-label {
2198				${this.objToCSS(n)}
2199			}
2200			.routing-boat {
2201				position: absolute;
2202				pointer-events: none;
2203				z-index: 22;
2204				width: ${a.width}px;
2205				height: ${a.height}px;
2206				transform-origin: 50% 50%;
2207				color: ${a.fill};
2208				--boat-stroke: ${a.stroke};
2209				--boat-stroke-width: ${a.strokeWidth};
2210			}
2211			.routing-boat svg {
2212				width: 100%;
2213				height: 100%;
2214				display: block;
2215				overflow: visible;
2216			}
2217		`}objToCSS(e){return Object.entries(e).map(([t,i])=>`${t.replace(/([A-Z])/g,"-$1").toLowerCase()}: ${i};`).join(`
2218`)}injectStyles(){this.removeStyles();let e=document.createElement("style");e.id=this.styleId,e.textContent=this.generateCSS(),document.head.appendChild(e)}removeStyles(){let e=document.getElementById(this.styleId);e&&e.remove()}setCustomStyles(e){this.customStyles=e,this.styles=this.getStyles(),this.injectStyles(),this.onStyleChange?.()}setBoatStyle(e){this.setCustomStyles({...this.customStyles,boat:{...this.customStyles.boat||{},...e}})}getLineStyle(){return this.styles.line}getBoatSVG(){return this.styles.boat?.svg?this.styles.boat.svg:cre}},pre=class extends fa{constructor(){super(),this.name="routing",this.colorOptions.blur=0,this.minZoom=0,this.maxZoom=20,this.overrideRenderOrder=1000010,this.isObjectLayer=!0,this.directRender=!0,this.showExtentLine=!1,this.line=null,this._pendingWaypoints=null}init(e,t){this.objectLayer=e,this.layerWrapper=t,N.onResize.add(this.onResize),this._pendingWaypoints&&=(this.renderLine(this._pe
2218ndingWaypoints),null)}renderLine(e){if(this.line&&this.objectLayer&&(this.objectLayer.remove(this.line),this.line=null),!this.objectLayer){this._pendingWaypoints=e;return}if(e.length<2)return;let t=new Float32Array(e.length*3);for(let a=0;a<e.length;a++){let[o,l]=Jd([e[a].lon,e[a].lat]);t[a*3]=o,t[a*3+1]=l,t[a*3+2]=0}let i=ms.getLineStyle(),r=N.devicePixelRatio||1,s=N.width*r,n=N.height*r;this.line=new Ll().lines(t).join({type:"miter",limit:8,quality:"high"}).sizeAttenuation(!1).lineWidth(i.lineWidth).transparent(!0).color(i.color).dpr(r).renderSize(s,n).build(),this.line.userData.boundingBox=this.line.geometry.boundingBox,this.line.renderOrder=this.overrideRenderOrder,this.objectLayer.add(this.line),this.line.resize(s,n)}onResize=()=>{if(this.line){let e=N.devicePixelRatio||1;this.line.dpr(e),this.line.resize(N.width*e,N.height*e)}};dispose(){N.onResize.remove(this.onResize)}getUrl=(e,t)=>""},mre=["borders","cities","bluemarble","mapdataterrestre","markers"],gre=class{constructor(e){this.layerManager=e,this._pickerDirty=!0,this._lastPickerX=null,this._lastPickerY=null,this._lastFixedLonLat=null,this._lastCenterCoord=null,this._lastCenterZoom=null,this._tileLoadHandler=null,this._tileSource=null,this._updateHandler=null,this._unwatchActiveLayer=null,this._animationCompleteHandler=null}init(){let e=()=>{this.markDirty()};this._unwatchActiveLayer=mo(Fl,t=>{if(this.markDirty(!0),this._lastPickerX=null,this._lastPickerY=null,this._lastFixedLonLat=null,this._lastCenterCoord=null,this._lastCenterZoom=null,this._tileSource&&this._tileLoadHandler&&(this._tileSource.un("tileloadend",this._tileLoadHandler),this._tileSource=null,this._tileLoadHandler=null),t){let i=this.layerManager.getLayerByName(t);i?.currentLayer?.tileSource&&(this._tileSource=i.currentLayer.tileSource,this._tileLoadHandler=e,this._tileSource.on("tileloadend",this._tileLoadHandler))}},{immediate:!0}),this._updateHandler=()=>this._update(),this._animationCompleteHandler=()=>{this.markDirty()},this.layerManager.onAnimationComplete.add(this._animationCompleteHandler),this._unwatchCurrentModel=mo(Tn,()=>{this.markDirty(!0)}),this._unwatchCurrentForecast=mo(wo,()=>{this.markDirty(!0)}),N.onUpdate.add(this._updateHandler)}markDirty(e=!1){if(e){this._pickerDirty=!0;return}(ba.value?.toLowerCase()||"default").includes("lonlat")||(this._pickerDirty=!0)}_update(){if(this.layerManager.isAnyVisibleLayerAnimating())return;let e=Fl.value||this.layerManager.lastLayer;if(!Yi.value||!e){Oe.value=null;return}let t=mre.includes(e.toLowerCase()),i=this.layerManager.openLayerMap?.getViewport()?.getBoundingClientRect?.(),r=ba.value?.toLowerCase()||"default",s,n;if(r==="default")s=i?gt.x-i.left:gt.x,n=i?gt.y-i.top:gt.y,(s!==this._lastPickerX||n!==this._lastPickerY)&&(this._pickerDirty=!0,this._lastPickerX=s,this._lastPickerY=n);else if(r.includes("lonlat")){let l=li.value;if(l&&l.lon!==void 0&&l.lat!==void 0){let h={lon:l.lon,lat:l.lat};if(this.layerManager.openLayerMap)try{let u=this.layerManager.openLayerMap.getPixelFromCoordinate([l.lon,l.lat]);u?(s=u[0],n=u[1]):(s=0,n=0)}catch(u){console.warn("[PickerUpdateManager] Failed to convert lon/lat to pixel:",u),s=0,n=0}else s=0,n=0;(!this._lastFixedLonLat||Math.abs(this._lastFixedLonLat.lon-h.lon)>1e-4||Math.abs(this._lastFixedLonLat.lat-h.lat)>1e-4)&&(this._pickerDirty=!0,this._lastFixedLonLat={lon:h.lon,lat:h.lat})}else{let h=Lr.value;s=h?.x??0,n=h?.y??0}}else if(r==="centerxy"){let l=Lr.value;if(s=l?.x??0,n=l?.y??0,this.layerManager.openLayerMap?.getView){let h=this.layerManager.openLayerMap.getView();if(h){let u=h.getCenter?.(),d=h.getZoom?.(),c=!1,p=!1;u&&u.length>=2&&(!this._lastCenterCoord||this._lastCenterCoord[0]!==u[0]||this._lastCenterCoord[1]!==u[1])&&(c=!0,this._lastCenterCoord=[u[0],u[1]]),typeof d=="number"&&(this._lastCenterZoom===null||this._lastCenterZoom!==d)&&(p=!0,this._lastCenterZoom=d),(c||p)&&(this._pickerDirty=!0)}}}else{let l=Lr.value;s=l?.x??0,n=l?.y??0,(s!==this._lastPickerX||n!==this._lastPickerY)&&(this._pickerDirty=!0,this._lastPickerX=s,this._lastPickerY=n)}if(!this._pickerDirty)return;if(this._pickerDirty=!1,s<0||n<0){Oe.value=null;return}if(t){Oe.value=null;return}let a=this.layerManager.getLayerByName(e);
2218if(!a)return;let o=["eumetsat","foudre"];if(a.data.legends===null&&!o.includes(e.toLowerCase())){Oe.value&&(Oe.value.value=null,window.mapJS.onPickerValueChange.dispatch(Oe.value)),Oe.value=null;return}if(o.includes(e.toLowerCase())){let l=this.layerManager.getLayerByName("radar");if(l&&l.visible)a=l;else if(a.data.legends===null){Oe.value&&(Oe.value.value=null,window.mapJS.onPickerValueChange.dispatch(Oe.value)),Oe.value=null;return}}if(a){let l=this.layerManager.getMaskLayerForLayer(a);this.layerManager.checkMaskAndGetValue(a,l,s,n).catch(h=>{console.warn("Error in checkMaskAndGetValue:",h)})}}dispose(){this._updateHandler&&N.onUpdate.remove(this._updateHandler),this._updateHandler=null,this._animationCompleteHandler&&this.layerManager.onAnimationComplete.remove(this._animationCompleteHandler),this._animationCompleteHandler=null,this._unwatchActiveLayer?.(),this._unwatchActiveLayer=null,this._unwatchCurrentModel?.(),this._unwatchCurrentModel=null,this._unwatchCurrentForecast?.(),this._unwatchCurrentForecast=null,this._tileSource?.un("tileloadend",this._tileLoadHandler),this._tileSource=null,this._tileLoadHandler=null}},$t=Id("[LayerManager]"),ue=new class{constructor(){this.onUpdate=new je,this.onHide=new je,this.onShow=new je,this.onLayerAdded=new je,this.onLayerRemoved=new je,this.onAnimationComplete=new je,this.openLayerMap=new XF({maxTilesLoading:128}),this.layers=new Map,this.lastLayer=null,this.lastRenderTime=0,this.watchers=Wm(),this.layersReadyForAnimation=new Set,this.layersAnimating=new Set,this.animationSyncEnabled=!0,this.syncAnimationTimeout=null,this._pickerToggleViewport=null,this._pickerTogglePointerDownHandler=null,this._pickerTogglePointerMoveHandler=null,this._pickerTogglePointerUpHandler=null,this._pickerToggleTouchStartHandler=null,this._pickerToggleTouchMoveHandler=null,this._pickerToggleTouchEndHandler=null,this._pickerTogglePointerStartPos=null,this._pickerToggleTouchStartPos=null,this._pickerTogglePointerMoved=!1,this._pickerToggleTouchMoved=!1}async init(e){performance.now(),this.options=e,this.mode=e.mode,performance.now(),this.initMap(),performance.now(),await this.initLayers(),this.listenStore(),this.initPicker()}initMapOnly(e){this.options=e,this.mode=e.mode,this.initMap(),Ps.onMapReady.addOnce(this.startPreloading),setTimeout(()=>{this.openLayerMap?.updateSize()},0)}async initStaticLayersEarly(){let e=[{Class:are,name:"borders"},{Class:lre,name:"BlueMarble"},{Class:hre,name:"MapDataMarine"},{Class:dre,name:"MapDataTerrestre"},{Class:ure,name:"mask"},{Class:pre,name:"routing"}];for(let t of e){if(this.layers.has(t.name))continue;let i=new t.Class;mu.value.push(i);let r=new t2(this.openLayerMap,i);r.onAnimationComplete.add(this.onLayerAnimationComplete),this.layers.set(r.name,r),this.onLayerAdded.dispatch(r)}}async initLayersAndComplete(){await this.initLayers(),this.listenStore(),this.initPicker()}listenStore(){this.watchers.add(kl,e=>{this.openLayerMap.getInteractions().forEach(t=>{(t instanceof wa||t instanceof bu)&&t.setActive(e)})}),this.watchers.add(pI,e=>{e?this.twoFingersInteraction():this.restoreDefaultDragInteraction()}),this.watchers.add(Oy,e=>{this.openLayerMap.getInteractions().forEach(t=>{(t instanceof Mm||t instanceof Nm||t instanceof Am||t instanceof Sa||t instanceof Em)&&t.setActive(e)})}),this.watchers.add(cw,e=>{this.openLayerMap.getInteractions().forEach(t=>{t instanceof Nm&&t.setActive(e)})}),this.watchers.add(pw,e=>{this.openLayerMap.getInteractions().forEach(t=>{t instanceof Mm&&t.setActive(e)})}),this.watchers.add(By,e=>{this.openLayerMap.getInteractions().forEach(t=>{t instanceof Sa&&t.setActive(e)})}),this.watchers.add(mw,e=>{this.openLayerMap.getInteractions().forEach(t=>{t instanceof Em&&t.setActive(e)})}),this.watchers.add(gw,e=>{this.openLayerMap.getInteractions().forEach(t=>{(t instanceof bu||t instanceof Am)&&t.setActive(e)})}),this.watchers.add(fw,e=>{let t=this.openLayerMap.getViewport();e?t._tapBlocker&&=(t.removeEventListener("click",t._tapBlocker,!0),t.removeEventListener("touchend",t._tapBlocker,!0),null):t._tapBlocker||(t._tapBlocker=i=>{i.stopPropagation(),i.preventDefault()},t.addEventListener("click",t._tapBlocker,!0),t.addEventListener("touchend",t._tapBlocker,!0))}),mo(ic,e=>
2218{this.openLayerMap&&this.openLayerMap.getInteractions().forEach(t=>{(t instanceof wa||t instanceof bu)&&(e?(t._pickerDragOriginalState=t.getActive(),t.setActive(!1)):t._pickerDragOriginalState!==void 0&&(t.setActive(t._pickerDragOriginalState),delete t._pickerDragOriginalState))})})}initPicker(){this.pickerUpdateManager||(this.pickerUpdateManager=new gre(this),this.pickerUpdateManager.init())}initMap(){pK();let e=this.options.domElement||document.body.querySelector("#map");e||console.warn("No map element found"),this.openLayerMap=new XF({target:e,view:new Ta({center:this.options.latlon.reverse(),zoom:this.options.zoom||4,minZoom:3,maxZoom:13,enableRotation:!1,extent:[-180*(1+ou.value*2),-85,180*(1+ou.value*2),85]}),controls:[]});let t=this.openLayerMap.getViewport();if(t.style.position="absolute",t.style.zIndex="100",t.style.userSelect="none",t.style.webkitUserSelect="none",t.style.webkitTouchCallout="none",t.style.MozUserSelect="none",t.style.msUserSelect="none",this.options?.platform==="web"&&(this._pickerToggleViewport&&this._pickerToggleViewport!==t&&this._detachPickerToggleListeners(),!this._pickerToggleViewport)){this._pickerToggleViewport=t;let r=n=>n?.closest?!!n.closest(".mapjs-picker, .mapjs-picker-icon, .mapjs-picker-valuebox"):!1,s=n=>{ic.value||r(n?.target)||(tc.value=!tc.value)};Fs?(this._pickerToggleTouchStartHandler=n=>{if(ic.value)return;let a=n?.changedTouches?.[0]||n?.touches?.[0];a&&(this._pickerToggleTouchMoved=!1,this._pickerToggleTouchStartPos={x:a.clientX,y:a.clientY})},this._pickerToggleTouchMoveHandler=n=>{if(!this._pickerToggleTouchStartPos)return;let a=n?.changedTouches?.[0]||n?.touches?.[0];if(!a)return;let o=a.clientX-this._pickerToggleTouchStartPos.x,l=a.clientY-this._pickerToggleTouchStartPos.y;o*o+l*l>100&&(this._pickerToggleTouchMoved=!0)},this._pickerToggleTouchEndHandler=n=>{this._pickerToggleTouchMoved||s(n)},t.addEventListener("touchstart",this._pickerToggleTouchStartHandler,!0),t.addEventListener("touchmove",this._pickerToggleTouchMoveHandler,!0),t.addEventListener("touchend",this._pickerToggleTouchEndHandler,!0)):(this._pickerTogglePointerDownHandler=n=>{n?.button!==void 0&&n.button!==0||(this._pickerTogglePointerMoved=!1,this._pickerTogglePointerStartPos={x:n.clientX,y:n.clientY})},this._pickerTogglePointerMoveHandler=n=>{if(!this._pickerTogglePointerStartPos)return;let a=n.clientX-this._pickerTogglePointerStartPos.x,o=n.clientY-this._pickerTogglePointerStartPos.y;a*a+o*o>100&&(this._pickerTogglePointerMoved=!0)},this._pickerTogglePointerUpHandler=n=>{n?.button!==void 0&&n.button!==0||this._pickerTogglePointerMoved||s(n)},t.addEventListener("pointerdown",this._pickerTogglePointerDownHandler,!0),t.addEventListener("pointermove",this._pickerTogglePointerMoveHandler,!0),t.addEventListener("pointerup",this._pickerTogglePointerUpHandler,!0))}this.openLayerMap.on("error",()=>{console.log("error")});let i=this.openLayerMap.getView().getZoom();this.moving=!1,this.openLayerMap.on("movestart",this.onMoveStart),this.openLayerMap.on("moveend",r=>this.onMoveEnd(r,()=>i,s=>{i=s})),this._renderUpdateHandler=()=>{performance.now()-this.lastRenderTime>4e3&&(this.lastRenderTime=performance.now(),this.openLayerMap.render(),q.scheduleRender(1)),this.moving&&q.scheduleRender()},N.onUpdate.add(this._renderUpdateHandler),this.view=this.openLayerMap.getView()}_detachPickerToggleListeners(){let e=this._pickerToggleViewport;e&&(this._pickerTogglePointerDownHandler&&e.removeEventListener("pointerdown",this._pickerTogglePointerDownHandler,!0),this._pickerTogglePointerMoveHandler&&e.removeEventListener("pointermove",this._pickerTogglePointerMoveHandler,!0),this._pickerTogglePointerUpHandler&&e.removeEventListener("pointerup",this._pickerTogglePointerUpHandler,!0),this._pickerToggleTouchStartHandler&&e.removeEventListener("touchstart",this._pickerToggleTouchStartHandler,!0),this._pickerToggleTouchMoveHandler&&e.removeEventListener("touchmove",this._pickerToggleTouchMoveHandler,!0),this._pickerToggleTouchEndHandler&&e.removeEventListener("touchend",this._pickerToggleTouchEndHandler,!0),this._pickerToggleViewport=null,this._pickerTogglePointerDownHandler=null,this._pickerTogglePointerMoveHandler=null,this._pickerTogglePointerUpHandler=null,this._pickerToggleTouchStartHandler=null,this._pickerToggleTouchMoveHandler=null,this._pickerToggleTouchEndHandler=null,this._pickerTogglePointerStartPos=null,this._pickerToggleTouchStartPos=null,this._pickerTogglePointerMoved=!1,this._pickerToggleTouchMoved=!1)}twoFingersInteraction(){Fs&&(this.openLayerMap.getInteractions().forEac
2218h(e=>{(e instanceof wa||e instanceof Sa)&&this.openLayerMap.getInteractions().remove(e)}),this.openLayerMap.getInteractions().push(new wa({condition:function(e){return this.getPointerCount()===2||aF(e)}})),this.openLayerMap.getInteractions().push(new Sa({condition:aF})))}restoreDefaultDragInteraction(){this.openLayerMap.getInteractions().forEach(e=>{(e instanceof wa||e instanceof Sa)&&this.openLayerMap.getInteractions().remove(e)}),this.openLayerMap.getInteractions().push(new wa({})),this.openLayerMap.getInteractions().push(new Sa),this.openLayerMap.getInteractions().forEach(e=>{e instanceof wa&&e.setActive(kl.value),e instanceof Sa&&e.setActive(By.value)})}openLayerInteraction(e,t=!1){this.openLayerMap&&(this.openLayerMap.getInteractions().forEach(i=>{(i instanceof wa||i instanceof bu)&&i.setActive(!!e)}),t?this.twoFingersInteraction():this.restoreDefaultDragInteraction())}setZoomInteractionsEnabled(e){this.openLayerMap&&this.openLayerMap.getInteractions().forEach(t=>{(t instanceof Mm||t instanceof Nm||t instanceof Am||t instanceof Sa||t instanceof Em)&&t.setActive(!!e)})}setTouchZoomEnabled(e){this.openLayerMap&&this.openLayerMap.getInteractions().forEach(t=>{t instanceof Nm&&t.setActive(!!e)})}setDoubleClickZoomEnabled(e){this.openLayerMap&&this.openLayerMap.getInteractions().forEach(t=>{t instanceof Mm&&t.setActive(!!e)})}setScrollWheelZoomEnabled(e){this.openLayerMap&&this.openLayerMap.getInteractions().forEach(t=>{t instanceof Sa&&t.setActive(!!e)})}setBoxZoomEnabled(e){this.openLayerMap&&this.openLayerMap.getInteractions().forEach(t=>{t instanceof Em&&t.setActive(!!e)})}setPanEnabled(e){this.openLayerMap&&this.openLayerMap.getInteractions().forEach(t=>{(t instanceof wa||t instanceof bu)&&t.setActive(!!e)})}setKeyboardEnabled(e){this.openLayerMap&&this.openLayerMap.getInteractions().forEach(t=>{(t instanceof bu||t instanceof Am)&&t.setActive(!!e)})}forceBlueMarbleBounds(){let e=null;for(let i of this.layers.values())if(i.visible&&i.srcExtent4326&&i.name!=="BlueMarble"){if(i.name=="radar")continue;e=i;break}let t=this.getLayerByName("BlueMarble");t&&t.visible&&(e?t.srcExtent4326=e.srcExtent4326:t.srcExtent4326=[-2003750834e-2,-2003750834e-2,2003750834e-2,2003750834e-2],t.updateLayerExtends())}async checkOutOfBounds(){let e=this.openLayerMap.getView().getCenter();if(!e)return;let[t,i]=[qm(e[0]),e[1]],r=this.getLayerByName(Fl.value);if(!r||(!Array.isArray(r.srcExtent)||r.srcExtent.length!==4)&&(r.updateExtent?.(),!Array.isArray(r.srcExtent)||r.srcExtent.length!==4))return;let[s,n,a,o]=r.srcExtent;if(t<s||t>a||i>o||i<n){let l=r.data.providers[0].model.fallback;if(r.data.providers&&r.data.providers.length>0){let h=r.data.providers.find(u=>u.model.name===l);h&&(h.isLoaded||await h.loadExtraData(),r.data.selectedProvider.value=h)}Ps.onGeographicFallback.dispatch(l)}}async initLayers(){let e=["cities"],t=mu.value.filter(i=>e.includes(i.name));for(let i of t){if(this.layers.has(i.name))continue;let r=new t2(this.openLayerMap,i);r.onAnimationComplete.add(this.onLayerAnimationComplete),this.layers.set(r.name,r),this.onLayerAdded.dispatch(r)}}async getOrCreateLayer(e){let t=this.layers.get(e);if(t)return t;for(let[n,a]of this.layers)if(a.data&&a.data.id===e)return a;let i=mu.value.find(n=>n.name===e||n.id===e);if(!i)return console.warn(`[LayerManager] Layer data for '${e}' not found (tried both name and id)`),null;let r;if(i._loaded&&i._instance)r=i._instance;else if(i._data||i.initFromData){if(i.initFromData)r=i;else if(r=await ec.loadLayer(i.name),!r)return console.error(`[LayerManager] Failed to load layer data for '${e}'`),null}else return console.error(`[LayerManager] Invalid layer metadata for '${e}'`),null;let s=new t2(this.openLayerMap,r);return s.onAnimationComplete.add(this.onLayerAnimationComplete),this.layers.set(s.name,s),this.onLayerAdded.dispatch(s),s}startPreloading=async()=>{if(this.preloadingStarted)return;this.preloadingStarted=!0;let e=await ec.preloadRemainingLayers();e>0&&Ps.log(`${e} layers preloaded`)};onLayerAnimationComplete=()=>{for(let e of this.layers.values())if(e.visible&&(!e.animationCompleted||e.opacity<1))return;this.onAnimationComplete.dispatch()};isAnyVisibleLayerAnimating(){for(let e of this.layers.values())if(e.visible&&(!e.animationCompleted||e.opacity<1))return!0;return!1}async setVisibleLayer(e,t=!0){Bi.value++;let i;try{if(i=await this.getOrCreateLayer(e),!i){console.warn(`[LayerManager] Failed to create layer '${e}'`);return}if(this.lastLayer=e,t&&!["borders","BlueMarble","MapDataMarine","MapDataTerrestre","mask","markers","cities","routing"].includes(e)&&(Fl.value=e),t){for(let r of this.layers.values())this.isCompatible(i,r)||r.setVisible(!1,!1);this.applyCompanionLayers(i,!0)}else this.applyCompanionLayers(i,!1);await i?.setVisible(t,!0)}finally{Bi.value--}if(t&&i&&i.modelId&&Mi.value!=="screenshot"&&i.modelId!=Tn.value&&(
2218await i.setModel(Tn.value),i.modelId!=Tn.value&&(await this.setModel(i.modelId),Tn.value=i.modelId)),this.updateBordersOpacity(),this.forceBlueMarbleBounds(),t){let r=this.getLayerByName(this.lastLayer);r&&r.srcExtent&&this.checkOutOfBounds()}}isCompatible(e,t){if(!e||!t||e.name===t.name)return!0;let i=new Set(["markers","borders","cities","routing"]);if(i.has(t.name)||i.has(e.name)||e.name==="precip"&&t.name==="precip_snow"||e.name==="precip_snow"&&t.name==="precip")return!0;let r=new Set(["radar","radar_snow","eumetsat","BlueMarble","foudre","mask"]);return!!(r.has(e.name)&&r.has(t.name)||e.name==="precip"&&t.name==="BlueMarble"||e.name==="BlueMarble"&&t.name==="precip"||t.backgroundLayer===e.name||t.foregroundLayer===e.name||e.backgroundLayer===t.name||e.foregroundLayer===t.name)}applyCompanionLayers(e,t){e&&(t?(e.backgroundLayer&&this.getLayerByName(e.backgroundLayer)?.setVisible(!0,!0),(e.name==="radar"||e.name==="radar_snow")&&this.getLayerByName("mask")?.setVisible(!0,!0),e.foregroundLayer&&this.getLayerByName(e.foregroundLayer)?.setVisible(!0,!0)):(e.name==="radar"||e.name==="radar_snow")&&this.getLayerByName("mask")?.setVisible(!1,!1))}onMoveStart=()=>{this.moving=!0,this.pause()};onMoveEnd=(e,t,i)=>{this.moving=!1,this.pickerUpdateManager?.markDirty(),this.forceBlueMarbleBounds();let r=this.openLayerMap.getView().getZoom(),s=this.openLayerMap.getView().getCenter(),n=[qm(s[0]),s[1]];Ps.onMapMove.dispatch(n,r),t()!=r&&(i(r),Ps.onZoom.dispatch(r));let a=this.getLayerByName(Fl.value);a&&a.srcExtent&&this.checkOutOfBounds()};setOverlayVisible(e,t){this.getLayerByName(this.lastLayer)?.setOverlayVisible(e,t),this.updateBordersOpacity(),q.scheduleRender()}updateBordersOpacity(){let e=1;for(let t of this.layers.values())t.visible&&t.isobares&&t.isobares.immediateVisible&&(e=1);this.getLayerByName("borders")?.setTileOpacity(e)}isLayerVisible(e){let t=this.layers.get(e);return t?t.visible:!1}getLayerByName(e){let t=this.layers.get(e);if(t)return t;for(let[i,r]of this.layers)if(r.data&&(r.data.id===e||r.data.displayName===e))return r;return null}getMaskLayerForLayer(e){if(!e||!e.data)return null;let t=e.data.isWaterLayer?"MapDataMarine":"MapDataTerrestre";return this.getLayerByName(t)}async checkMaskAndGetValue(e,t,i,r){if(!e)return;let s=parseInt(i),n=parseInt(r),a=Ps.options.platform==="web";if(!t){try{cu.value=a,await e.getValuePixel(s,n)}catch(l){console.warn("Failed to get value pixel from layer:",l)}return}let o=await ere(t,s,n);if(o&&o.a>.01){let l=o.latLon||null;Ps.options.platform==="web"?Fs?(cu.value=!1,Oe.value=l?{latLon:l}:{}):Oe.value=null:(cu.value=!1,Oe.value=l?{latLon:l}:{})}else cu.value=a,await e.getValuePixel(s,n)}async setModel(e){let t=[];for(let i of this.layers.values())i&&t.push(i.setModel(e));return Promise.all(t)}getCurrentExtent(){let e=this.openLayerMap.getView(),t=this.openLayerMap.getSize();if(!t)throw Error("Map size is not available.");let i=e.calculateExtent(t);return i[0]=qm(i[0]),i[2]=qm(i[2]),i}setForecast=e=>{for(let t of this.layers.values())t.hasForecastDates&&t.setForecast(e)};play=(e=0)=>{$t.info(`play with padding: ${e} minutes`);for(let t of this.layers.values())t.hasForecastDates&&t.play(e)};pause=()=>{for(let e of this.layers.values())e.hasForecastDates&&e.pause()};prevForecast=()=>{$t.time("prevForecast"),this.animationSyncEnabled&&($t.time("prepareSynchronizedAnimation"),this.prepareSynchronizedAnimation(),$t.timeEnd("prepareSynchronizedAnimation")),$t.time("layer prevForecast calls");for(let e of this.layers.values())e.hasForecastDates&&($t.time(`${e.name} prevForecast`),e.prevForecast(),$t.timeEnd(`${e.name} prevForecast`));$t.timeEnd("layer prevForecast calls"),this.animationSyncEnabled&&($t.time("startSynchronizedAnimation"),this.startSynchronizedAnimation(),$t.timeEnd("startSynchronizedAnimation")),$t.timeEnd("prevForecast")};nextForecast=()=>{$t.time("nextForecast"),this.animationSyncEnabled&&($t.time("prepareSynchronizedAnimation"),this.prepareSynchronizedAnimation(),$t.timeEnd("prepareSynchronizedAnimation")),$t.time("layer nextForecast calls");for(let e of this.layers.values())e.hasForecastDates&&($t.time(`${e.name} nextForecast`),e.nextForecast(),$t.timeEnd(`${e.name} nextForecast`));
2218$t.timeEnd("layer nextForecast calls"),this.animationSyncEnabled&&($t.time("startSynchronizedAnimation"),this.startSynchronizedAnimation(),$t.timeEnd("startSynchronizedAnimation")),$t.timeEnd("nextForecast")};prepareSynchronizedAnimation(){this.layersReadyForAnimation.clear(),this.layersAnimating.clear(),this.syncAnimationTimeout&&=(clearTimeout(this.syncAnimationTimeout),null);let e=0;for(let t of this.layers.values())t.visible&&t.opacity>0&&t.hasForecastDates&&(t._waitingForSync=!0,t._syncAnimationReady=!1,e++,$t.debug(`Marked ${t.name} for sync`));$t.debug(`Total layers marked for sync: ${e}`)}startSynchronizedAnimation(){this.syncAnimationTimeout=setTimeout(()=>{$t.warn("Forcing synchronized animation after timeout"),this.triggerSynchronizedAnimation()},2e3)}registerLayerReadyForAnimation(e){if(!this.animationSyncEnabled||!e._waitingForSync)return!1;this.layersReadyForAnimation.add(e),e._syncAnimationReady=!0;let t=!0,i=0,r=0;for(let s of this.layers.values())s._waitingForSync&&(i++,s._syncAnimationReady?r++:(t=!1,$t.debug(`Layer ${s.name} is waiting but not ready`)));return $t.debug(`Sync status: ${r}/${i} layers ready`),t&&i>0&&($t.debug("All layers ready, triggering synchronized animation"),this.triggerSynchronizedAnimation()),!0}triggerSynchronizedAnimation(){this.syncAnimationTimeout&&=(clearTimeout(this.syncAnimationTimeout),null);for(let e of this.layers.values())e._waitingForSync&&(e._waitingForSync=!1,e._syncAnimationReady=!1,e.startAnimation());this.layersReadyForAnimation.clear()}dispose=()=>{this._detachPickerToggleListeners(),this.watchers.dispose(),this.pickerUpdateManager&&this.pickerUpdateManager.dispose(),this._renderUpdateHandler&&N.onUpdate.remove(this._renderUpdateHandler);for(let[e,t]of this.layers.entries())t&&t.dispose();this.layers.clear(),this.onUpdate.removeAll(),this.onHide.removeAll(),this.onShow.removeAll(),this.onAnimationComplete.removeAll(),this.openLayerMap&&(this.openLayerMap.getInteractions().getArray().slice().forEach(e=>{this.openLayerMap.removeInteraction(e)}),this.openLayerMap.getLayers().getArray().slice().forEach(e=>{this.openLayerMap.removeLayer(e)}),this.openLayerMap.setTarget(null)),this.lastLayer=null};get paramId(){return this.lastLayer||"none"}get modelId(){let e=this.getLayerByName(this.lastLayer);return e?e.modelId:"none"}},ID=new je,FD=new je,k1={onUp:FD,onDown:ID,crtlKey:!1,altKey:!1};typeof window<"u"&&(window.addEventListener("keydown",e=>{k1.crtlKey=e.ctrlKey,k1.altKey=e.altKey,ID.dispatch(e.key,e)}),window.addEventListener("keyup",e=>{FD.dispatch(e.key,e)}));var cg=new class{constructor(){this.styleId="mapjs-picker-styles",this.customStyles={},this.publisher=null,this.styles=this.getStyles()}getBackgroundColor(){return this.publisher==="meteoconsult"?"rgba(0, 85, 95, .6)":this.publisher==="meteoconsultmarine"?"rgba(6, 67, 108, .6)":this.publisher==="lachainemeteo"?"rgba(36, 47, 94, .6)":"rgba(10, 90, 150, 0.7)"}getStyles(){let e=this.getBackgroundColor(),t={base:{position:"absolute",zIndex:1e3,pointerEvents:"none",color:"#ffffff",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif',fontSize:"12px",background:e,backdropFilter:"none",borderRadius:"2px",padding:"0px 5px",whiteSpace:"nowrap",minWidth:"120px"},container:{display:"flex",flexDirection:"column",gap:"2px"},location:{fontSize:"13px",fontweight:700,color:"rgba(255, 255, 255, 1)",borderBottom:"1px solid rgba(255, 255, 255, 0.1)",display:"flex",alignItems:"center",gap:"4px",lineHeight:"19px"},icon:{width:"28px",height:"28px",borderRadius:"6px",background:"transparent",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},value:{fontSize:"14px",fontWeight:"500",letterSpacing:"0.3px",display:"flex",alignItems:"center",gap:"3px"},unit:{fontSize:"13px",fontWeight:"500",opacity:"0.9"},pointer:{position:"absolute",left:"50%",transform:"translateX(-50%)",width:"0",height:"0",borderLeft:"16px solid transparent",borderRight:"16px solid transparent",borderTop:`12px solid ${e}`,filter:"drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2))"}};return this.mergeStyles(t,this.customStyles)}mergeStyles(e,t){let i={...e};for(let r in t)typeof t[r]=="object"&&!Array.isArray(t[r])?i[r]={...e[r],...t[r]}:i[r]=t[r];return i}generateCSS(){let e=this.styles;return`
2219			.mapjs-picker {
2220				${this.objToCSS(e.base)}
2221			}
2222			.mapjs-picker__container {
2223				${this.objToCSS(e.container)}
2224			}
2225			.mapjs-picker__location {
2226				${this.objToCSS(e.location)}
2227			}
2228			.mapjs-picker__location-icon {
2229				width: 12px;
2230				height: 12px;
2231				opacity: 0.7;
2232			}
2233			.mapjs-picker__coordinates {
2234				font-family: 'SF Mono', Monaco, 'Courier New', monospace;
2235				letter-spacing: 0.5px;
2236			}
2237			.mapjs-picker__value-group {
2238				display: flex;
2239				align-items: center;
2240				gap: 8px;
2241				min-height: 25px;
2242				margin: 0 auto;
2243				line-height : 0;
2244				margin-bottom : 3px;
2245			}
2246			.mapjs-picker__icon {
2247				${this.objToCSS(e.icon)}
2248			}
2249			.mapjs-picker__icon svg {
2250				width: 16px;
2251				height: 16px;
2252				filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.2));
2253			}
2254			.mapjs-picker__value-container {
2255				display: flex;
2256				flex-direction: column;
2257				gap: 2px;
2258			}
2259			.mapjs-picker__value {
2260				${this.objToCSS(e.value)}
2261				align-items: center;
2262			}
2263			.mapjs-picker__value-number {
2264				font-variant-numeric: tabular-nums;
2265			}
2266			.mapjs-picker__unit {
2267				${this.objToCSS(e.unit)}
2268			}
2269			.mapjs-picker__converted {
2270				font-size: 11px;
2271				color: rgba(255, 255, 255, 0.8);
2272				opacity: 0.8;
2273			}
2274			.mapjs-picker__wind-arrow {
2275				display: inline-flex;
2276				align-items: center;
2277				justify-content: center;
2278				width: 26px;
2279				height: 26px;
2280				margin-right: 2px;
2281				vertical-align: middle;
2282			}
2283			.mapjs-picker__wind-arrow svg {
2284				width: 26px;
2285				height: 26px;
2286				filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.3));
2287			}
2288			.mapjs-picker__pointer {
2289				${this.objToCSS(e.pointer)}
2290			}
2291			/* pointer uses border triangle; no pseudo-element */
2292
2293			/* Prevent default touch behaviors on mobile when dragging */
2294			.mapjs-picker.draggable,
2295			.mapjs-picker-icon.draggable {
2296				touch-action: none;
2297				-ms-touch-action: none;
2298			}
2299
2300			/* Prevent iOS text selection menu (copy/paste) on long press */
2301			.mapjs-picker,
2302			.mapjs-picker *,
2303			.mapjs-picker-icon,
2304			.mapjs-picker-icon * {
2305				user-select: none;
2306				-webkit-user-select: none;
2307				-webkit-touch-callout: none;
2308				-moz-user-select: none;
2309				-ms-user-select: none;
2310			}
2311		`}objToCSS(e){return Object.entries(e).map(([t,i])=>`${t.replace(/([A-Z])/g,"-$1").toLowerCase()}: ${i};`).join(`
2312`)}injectStyles(){this.removeStyles();let e=document.createElement("style");e.id=this.styleId,e.textContent=this.generateCSS(),document.head.appendChild(e)}removeStyles(){let e=document.getElementById(this.styleId);e&&e.remove()}setCustomStyles(e){this.customStyles=e,this.styles=this.getStyles(),this.injectStyles()}setPublisher(e){this.publisher!==e&&(this.publisher=e,this.styles=this.getStyles(),this.injectStyles())}},I1=(e,t)=>{let i=e.__vccOpts||e;for(let[r,s]of t)i[r]=s;return i},fre={},yre={width:"30",height:"30",viewBox:"0 0 30 30",xmlns:"http://www.w3.org/2000/svg",class:"cross-icon"};function xre(e,t){return Di(),ts("svg",yre,[...t[0]||=[Tt("line",{x1:"0",y1:"15",x2:"30",y2:"15",stroke:"white","stroke-width":"1","stroke-linecap":"round"},null,-1),Tt("line",{x1:"15",y1:"0",x2:"15",y2:"30",stroke:"white","stroke-width":"1","stroke-linecap":"round"},null,-1)]])}var vre=I1(fre,[["render",xre],["__scopeId","data-v-bfa64c90"]]),bre={width:"30",height:"30",viewBox:"0 0 30 30",xmlns:"http://www.w3.org/2000/svg",class:"target-icon"},_re=["stroke"],Tre=["fill"],wre=["stroke"],Sre=["stroke"],Mre=["stroke"],Cre=["stroke"],Rre=I1({__name:"TargetIcon",setup(e){let t=sk(()=>{switch(_I.value){case"meteoconsultmarine":return"#021B5F";case"meteoconsult":return"#003236";default:return"white"}});return(i,r)=>(Di(),ts("svg",bre,[r[0]||=OX('<circle cx="15" cy="15" r="11" fill="none" stroke="white" stroke-width="2.5" data-v-b1aa0a44></circle><circle cx="15" cy="15" r="2" fill="white" data-v-b1aa0a44></circle><line x1="15" y1="0" x2="15" y2="4" stroke="white" stroke-width="2.5" stroke-linecap="round" data-v-b1aa0a44></line><line x1="15" y1="26" x2="15" y2="30" stroke="white" stroke-width="2.5" stroke-linecap="round" data-v-b1aa0a44></line><line x1="0" y1="15" x2="4" y2="15" stroke="white" stroke-width="2.5" stroke-linecap="round" data-v-b1aa0a44></line><line x1="26" y1="15" x2="30" y2="15" stroke="white" stroke-width="2.5" stroke-linecap="round" data-v-b1aa0a44></line>',6),Tt("circle",{cx:"15",cy:"15",r:"11",fill:"none",stroke:t.value,"stroke-width":"1.5"},null,8,_re),Tt("circle",{cx:"15",cy:"15",r:"2",fill:t.value},null,8,Tre),Tt("line",{x1:"15",y1:"0",x2:"15",y2:"4",stroke:t.value,"stroke-width":"1.5","stroke-linecap":"round"},null,8,wre),Tt("line",{x1:"15",y1:"26",x2:"15",y2:"30",stroke:t.value,"stroke-width":"1.5","stroke-linecap":"round"},null,8,Sre),Tt("line",{x1:"0",y1:"15",x2:"4",y2:"15",stroke:t.value,"stroke-width":"1.5","stroke-linecap":"round"},null,8,Mre),Tt("line",{x1:"26",y1:"15",x2:"30",y2:"15",stroke:t.value,"stroke-width":"1.5","stroke-linecap":"round"},null,8,Cre)]))}},[["__scopeId","data-v-b1aa0a44"]]),Ere={name:"PickerValueBox",props:{teleportTarget:{type:[String,Object],default:".ol-viewport"}},data(){return{value:Oe.value,showLocation:au.value,enabled:Yi.value,display:Pl.value,currentRotation:0,anchor:Lr.value}},computed:{isVisible(){return this.enabled&&this.value!==null&&tc.value===!0&&cu.value===!0&&(this.display==="cross"||this.display==="target")},valueBoxStyle(){let e=(typeof this.teleportTarget=="string"?document.querySelector(this.teleportTarget):this.teleportTarget)?.getBoundingClientRect?.()||null,t=this.anchor?.x??0,i=this.anchor?.y??0,r=this.$refs.valueBoxElement,s=r?.offsetWidth||0,n=r?.offsetHeight||0;if(e&&s){let o=s/2+8,l=e.width-s/2-8;t=Math.min(l,Math.max(o,t))}let a=!e||!n||i-(n+10+15)>=8?"calc(-100% - 25px)":"25px";return{left:`${t}px`,top:`${i}px`,transform:`translate(-50%, ${a})`,pointerEvents:"none",zIndex:1e3}},converted(){return this.value?.lockUnit?{value:this.value?.value??0,unit:this.value?.unit||"",symbol
2312:this.value?.symbol||this.value?.unit||""}:this.value?.value==null&&!this.value?.unit?null:jt.convertToPreferred(this.value?.value||0,this.value.unit||"",this.value.parameter||"")},formattedValue(){if(!this.converted||this.converted.value==null)return"0";let e=this.converted.value,t=jt.getUnitTypeForParameter(this.value?.parameter||"");return jt.formatValue(e,t)},convertedUnit(){if(this.converted?.symbol||this.converted?.unit)return this.converted.symbol||this.converted.unit;let e=jt.getUnitTypeForParameter(this.value?.parameter||"");return e==="precipitation"?"mm/h":e==="temperature"?"\xB0C":e==="speed"?"km/h":e==="pressure"?"hPa":this.value?.unit||""},windRotation(){return this.currentRotation},icon(){return this.value?this.getParameterIcon(this.value):null}},methods:{formatCoordinates(e){return e?`${e.lat.toFixed(2)}\xB0, ${e.lon.toFixed(2)}\xB0`:""},getParameterIcon(e){let t="rgb(255,255,255,0.8)",i={temperature:`
2313					<svg viewBox="0 0 64 64" fill="none">
2314						<path d="M32 4C28.6863 4 26 6.68629 26 10V40.3431C22.6131 42.4696 20.5 46.0213 20.5 50C20.5 56.3513 25.6487 61.5 32 61.5C38.3513 61.5 43.5 56.3513 43.5 50C43.5 46.0213 41.3869 42.4696 38 40.3431V10C38 6.68629 35.3137 4 32 4Z" stroke="${t}" stroke-width="2.5" fill="none" opacity="0.9"/>
2315						<rect x="30" y="18" width="4" height="24" fill="${t}" opacity="0.9"/>
2316						<circle cx="32" cy="50" r="8" fill="${t}"/>
2317						<line x1="42" y1="16" x2="48" y2="16" stroke="${t}" stroke-width="2" stroke-linecap="round" opacity="0.7"/>
2318						<line x1="42" y1="22" x2="46" y2="22" stroke="${t}" stroke-width="2" stroke-linecap="round" opacity="0.7"/>
2319						<line x1="42" y1="28" x2="48" y2="28" stroke="${t}" stroke-width="2" stroke-linecap="round" opacity="0.7"/>
2320						<line x1="42" y1="34" x2="46" y2="34" stroke="${t}" stroke-width="2" stroke-linecap="round" opacity="0.7"/>
2321					</svg>
2322				`,rain:`
2323					<svg version="1.2" baseProfile="tiny" id="Calque_1"
2324	 xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
2325	 viewBox="0 0 192 192" overflow="visible" xml:space="preserve" fill="white">
2326<g>
2327	<g id="Groupe_1231_1_" transform="translate(-198.648 -297)">
2328		<path id="Trac\xE9_2164_1_" fill-rule="evenodd" d="M273,345.8c0,0-64.5,61.6-72.1,85.2c-7.4,22.6,4.1,47.1,26.1,55.7
2329			c21.9,7.5,45.8-4.3,53.2-26.4c0.2-0.5,0.3-0.9,0.4-1.4C288.2,435.8,273,345.8,273,345.8z"/>
2330	</g>
2331	<g id="Groupe_1231_2_" transform="translate(-198.648 -297)">
2332		<path id="Trac\xE9_2164_2_" fill-rule="evenodd" d="M380.9,297c0,0-64.5,61.6-72.1,85.2c-7.4,22.6,4.1,47.1,26.1,55.7
2333			c21.9,7.5,45.8-4.3,53.2-26.4c0.2-0.5,0.3-0.9,0.4-1.4C396.1,387,380.9,297,380.9,297z"/>
2334	</g>
2335</g>
2336</svg>
2337				`,snow:`
2338					<svg version="1.2" baseProfile="tiny" id="Calque_1"
2339	 xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
2340	 viewBox="0 0 192 192" overflow="visible" xml:space="preserve" fill="white">
2341<path id="Trac\xE9_2158_1_" d="M185.6,106l-39.6,10.9l-39.7-21l39.7-21.1l39.6,10.9c0.4,0.1,0.9,0.2,1.4,0.2c2.2,0,4.1-1.3,4.8-3.4
2342	c0.7-2.5-0.7-5.1-3.2-5.8c0,0-0.1,0-0.1,0l-30.1-8.3l23.6-12.5c2.3-1.2,3.2-3.9,2-6.2c0-0.1-0.1-0.1-0.1-0.2
2343	c-1.4-2.3-4.3-3.1-6.7-1.9l-23.6,12.5l8.6-28.8c0.7-2.5-0.7-5.1-3.2-5.8c0,0-0.1,0-0.1,0c-2.6-0.7-5.3,0.7-6.1,3.2l-11.4,37.9
2344	l-40.2,21.3v-44L130.1,16c1.9-1.7,2-4.6,0.2-6.5c-0.1-0.1-0.1-0.1-0.2-0.2c-2-1.9-5-1.9-7,0l-22.2,21.2V4.7C100.9,2.1,98.7-0.1,96,0
2345	c0,0,0,0,0,0c-2.7-0.1-4.9,2.1-5,4.7c0,0,0,0,0,0v25.8L68.8,9.3c-2-1.9-5-1.9-7,0c-1.9,1.7-2,4.6-0.2,6.5c0.1,0.1,0.1,0.1,0.2,0.2
2346	L91,43.9v44L50.8,66.6L39.4,28.7c-0.8-2.6-3.5-4-6.1-3.2c-2.5,0.6-4.1,3.2-3.4,5.7c0,0,0,0.1,0,0.1l8.6,28.8L14.9,47.6
2347	c-2.4-1.3-5.3-0.4-6.7,1.9c-1.3,2.2-0.5,5,1.7,6.3c0.1,0,0.1,0.1,0.2,0.1l23.6,12.5L3.6,76.7c-2.5,0.6-4.1,3.2-3.4,5.7
2348	c0,0,0,0.1,0,0.1C0.8,84.6,2.8,86,5,86c0.5,0,0.9-0.1,1.4-0.2l39.7-11l39.7,21.1l-39.7,21L6.3,106c-2.6-0.7-5.3,0.7-6.1,3.2
2349	c-0.7,2.5,0.7,5.1,3.2,5.8c0,0,0.1,0,0.1,0l30.1,8.3l-23.6,12.5c-2.3,1.2-3.2,3.9-2,6.2c0,0.1,0.1,0.1,0.1,0.2
2350	c0.9,1.5,2.6,2.5,4.3,2.4c0.8,0,1.7-0.2,2.4-0.6l23.6-12.5l-8.6,28.8c-0.7,2.5,0.7,5.1,3.2,5.8c0,0,0.1,0,0.1,0
2351	c0.4,0.1,0.9,0.2,1.4,0.2c2.2,0,4.1-1.3,4.8-3.4l11.4-37.9l40.2-21.3v44l-29.3,27.9c-1.9,1.7-2,4.6-0.2,6.5c0.1,0.1,0.1,0.1,0.2,0.2
2352	c2,1.9,5,1.9,7,0L91,161.3v25.7c0,2.7,2.2,4.9,5,4.9c2.7,0,5-2.2,5-4.9v-25.7l22.2,21.2c2,1.9,5,1.9,7,0c1.9-1.7,2-4.6,0.2-6.5
2353	c-0.1-0.1-0.1-0.1-0.2-0.2l-29.2-27.9v-44l40.2,21.3l11.4,37.9c0.7,2.1,2.6,3.5,4.8,3.4c0.5,0,0.9-0.1,1.4-0.2
2354	c2.5-0.6,4.1-3.2,3.4-5.7c0,0,0-0.1,0-0.1l-8.6-28.8l23.6,12.5c0.7,0.4,1.6,0.6,2.4,0.6c1.8,0,3.4-0.9,4.3-2.4
2355	c1.3-2.2,0.5-5,1.7-6.3c-0.1,0-0.1-0.1-0.2-0.1l-23.6-12.5l30.1-8.3c2.5-0.6,4.1-3.2,3.4-5.7c0,0,0-0.1,0-0.1
2356	C191,106.7,188.2,105.2,185.6,106z"/>
2357</svg>
2358				`,wind:`
2359					<svg viewBox="0 0 24 24" fill="none">
2360						<path d="M5 9h8.5a2.5 2.5 0 0 0 0-5c-1.38 0-2.5 1.12-2.5 2.5" stroke="${t}" stroke-width="2.5" stroke-linecap="round" opacity="0.7"/>
2361						<path d="M3 12h15.5a2.5 2.5 0 0 1 0 5c-1.38 0-2.5-1.12-2.5-2.5" stroke="${t}" stroke-width="2.5" stroke-linecap="round" opacity="0.95"/>
2362						<path d="M5 15h8.5a2.5 2.5 0 0 1 0 5c-1.38 0-2.5-1.12-2.5-2.5" stroke="${t}" stroke-width="2.5" stroke-linecap="round" opacity="0.5"/>
2363					</svg>
2364				`,pressure:`
2365					<svg viewBox="0 0 24 24" fill="none">
2366						<circle cx="12" cy="12" r="9" stroke="${t}" stroke-width="2" opacity="0.8"/>
2367						<circle cx="12" cy="12" r="6.5" stroke="${t}" stroke-width="1" opacity="0.3"/>
2368						<circle cx="12" cy="12" r="2" fill="${t}"/>
2369						<path d="M12 3v7" stroke="${t}" stroke-width="2.5" stroke-linecap="round"/>
2370						<path d="M12 14v4" stroke="${t}" stroke-width="1.5" stroke-linecap="round" opacity="0.5"/>
2371						<path d="M6 12h4" stroke="${t}" stroke-width="1.5" stroke-linecap="round" opacity="0.5"/>
2372						<path d="M14 12h4" stroke="${t}" stroke-width="1.5" stroke-linecap="round" opacity="0.5"/>
2373						<path d="M8.5 8.5l2 2" stroke="${t}" stroke-width="1" stroke-linecap="round" opacity="0.4"/>
2374						<path d="M13.5 13.5l2 2" stroke="${t}" stroke-width="1" stroke-linecap="round" opacity="0.4"/>
2375						<path d="M15.5 8.5l-2 2" stroke="${t}" stroke-width="1" stroke-linecap="round" opacity="0.4"/>
2376						<path d="M10.5 13.5l-2 2" stroke="${t}" stroke-width="1" stroke-linecap="round" opacity="0.4"/>
2377					</svg>
2378				`},r={precip:"rain",radar:"rain",radar_snow:"snow"}[e.parameter]||null;if(r==="rain"&&(e.parameter==="radar"||e.parameter==="precip")){let s=e.unit||e.symbol||this.convertedUnit;(s==="cm/h"||s==="cm")&&(r="snow")}return r?i[r]:null}},created(){this.$watch(()=>Oe.value,e=>{if(this.value=e,!ue.isAnyVisibleLayerAnimating()&&e?.uvData){let t=270-parseFloat(e.uvData.direction.fromFormatted||0)-this.currentRotation;for(;t>180;)t-=360;for(;t<-180;)t+=360;this.currentRotation+=t}},{immediate:!0}),this.$watch(()=>au.value,e=>{this.showLocation=e},{immediate:!0}),this.$watch(()=>Yi.value,e=>{this.enabled=e},{immediate:!0}),this.$watch(()=>Pl.value,e=>{this.display=e},{immediate:!0}),this.$watch(()=>Lr.value,e=>{this.anchor=e},{immediate:!0,deep:!0})}},Are={class:"mapjs-picker-valuebox__container"},Nre={key:0,class:"mapjs-picker-valuebox__value-group"},Lre=["innerHTML"],Pre={class:"mapjs-picker-valuebox__value-container"},kre={class:"mapjs-picker-valuebox__value"},Ire={key:0,class:"mapjs-picker-valuebox__wind-arrow"},Fre=["fill"],Dre={class:"mapjs-picker-valuebox__value-number"},Ore={class:"mapjs-picker-valuebox__unit"},Bre={key:1,class:"mapjs-picker-valuebox__value-group"};function Ure(e,t,i,r,s,n){return Di(),tm(yP,{to:i.teleportTarget},[mT(Tt("div",{ref:"valueBoxElement",class:"mapjs-picker-valuebox",style:bl(n.valueBoxStyle)},[Tt("div",Are,[s.value?.value===void 0?(Di(),ts("div",Bre,[...t[0]||=[Tt("div",{class:"mapjs-picker-valuebox__value"},[Tt("span",{class:"mapjs-picker-valuebox__value-number"},"No data")],-1)]])):(Di(),ts("div",Nre,[n.icon?(Di(),ts("div",{key:0,class:"mapjs-picker-valuebox__icon",innerHTML:n.icon},null,8,Lre)):$d("",!0),Tt("div",Pre,[Tt("div",kre,[s.value.uvData?(Di(),ts("span",Ire,[(Di(),ts("svg",{viewBox:"0 0 24 24",style:bl(`transform: rotate(${n.windRotation}deg); transition: transform 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);`)},[Tt("polygon",{points:"12,3 18,18 12,14 6,18",fill:`rgb(${s.value.colorR}, ${s.value.colorG}, ${s.value.colorB})`,opacity:"0.95",stroke:"white","stroke-width":"1","stroke-linejoin":"round"},null,8,Fre)],4))])):$d("",!0),Tt("span",Dre,Od(n.formattedValue),1),Tt("span",Ore,Od(n.convertedUnit),1)])])]))])],4),[[IT,n.isVisible]])],8,["to"])}var Vre={name:"PickerComponent",components:{CrossIcon:vre,TargetIcon:Rre,PickerValueBox:I1(Ere,[["render",Ure],["__scopeId","data-v-700dff50"]])},props:{teleportTarget:{type:[String,Object],default:".ol-viewport"}},data(){return{value:Oe.value,showLocation:au.value,enabled:Yi.value,mode:ba.value,displayMode:Pl.value,position:{x:0,y:0},updateFrame:null,currentRotation:0,isDragging:!1,dragOffset:{x:0,y:0},lastUpdateTime:0,isTouchDevice:!1,lastDragValue:null,dragValueCheckTimeout:null,initialValueDispatched:!1}},computed:{isVisible(){return this.enabled&&this.value!==null&&tc.value===!0},pickerStyle(){return{left:`${this.position.x}px`,top:`${this.position.y}px`,transform:"translate(-50%, calc(-100% - 14px))",cursor:this.isDraggableMode?"grab":"default",pointerEvents:this.isDraggableMode?"auto":"none"}},pickerIconStyle(){return{left:`${this.position.x}px`,top:`${this.position.y}px`,transform:"translate(-50%, -50%)",cursor:this.isDraggableMode?"grab":"default"}},isDraggableMode(){return this.mode.includes("dragndrop")||this.mode.includes("combine")},converted(){return this.value?.lockUnit?{value:this.value?.value??0,unit:this.value?.unit||"",symbol
2378:this.value?.symbol||this.value?.unit||""}:this.value?.value==null&&!this.value?.unit?null:jt.convertToPreferred(this.value?.value||0,this.value.unit||"",this.value.parameter||"")},formattedValue(){if(!this.converted||this.converted.value==null)return"0";let e=this.converted.value,t=jt.getUnitTypeForParameter(this.value?.parameter||"");return jt.formatValue(e,t)},convertedUnit(){if(this.converted?.symbol||this.converted?.unit)return this.converted.symbol||this.converted.unit;let e=jt.getUnitTypeForParameter(this.value?.parameter||"");return e==="precipitation"?"mm/h":e==="temperature"?"\xB0C":e==="speed"?"km/h":e==="pressure"?"hPa":this.value?.unit||""},windRotation(){return this.currentRotation},icon(){return this.value?this.getParameterIcon(this.value):null}},methods:{handlePointerDown(e){this.isDraggableMode&&(this.isTouchDevice=!1,this.handleDragStart(e))},handleTouchStart(e){if(this.isDraggableMode){this.isTouchDevice=!0;let t=e.touches[0];if(t){let i={clientX:t.clientX,clientY:t.clientY,preventDefault:()=>e.preventDefault()};this.handleDragStart(i)}}},handleDragStart(e){this.isDragging=!0,ic.value=!0,this.lastDragValue=Oe.value?{value:Oe.value.value,parameter:Oe.value.parameter}:null,this.dragOffset={x:e.clientX-this.position.x,y:e.clientY-this.position.y},this.isTouchDevice?(document.addEventListener("touchmove",this.handleTouchMove,{passive:!1}),document.addEventListener("touchend",this.handleTouchEnd)):(document.addEventListener("pointermove",this.handleDragMove),document.addEventListener("pointerup",this.handleDragEnd)),e.preventDefault()},handleDragMove(e){if(!this.isDragging)return;let t=typeof this.teleportTarget=="string"?document.querySelector(this.teleportTarget):this.teleportTarget,i=e.clientX,r=e.clientY;if(t&&t.getBoundingClientRect){let a=t.getBoundingClientRect();i-=a.left,r-=a.top}this.position={x:i,y:r};let s=this.isTouchDevice?33:50,n=Date.now();if(n-this.lastUpdateTime>=s){if(this.lastUpdateTime=n,Lr.value={x:i,y:r},this.mode.includes("lonlat")){let a=this.screenToLonLat(i,r);a&&(li.value=a)}else li.value={x:i,y:r};this.dragValueCheckTimeout&&clearTimeout(this.dragValueCheckTimeout),this.dragValueCheckTimeout=setTimeout(()=>{this.isDragging&&window.MapJS&&Oe.value&&(!this.lastDragValue||this.lastDragValue.value!==Oe.value.value||this.lastDragValue.parameter!==Oe.value.parameter)&&(this.lastDragValue={value:Oe.value.value,parameter:Oe.value.parameter})},0)}},handleTouchMove(e){if(e.preventDefault(),!this.isDragging)return;let t=e.touches[0];if(!t)return;let i={clientX:t.clientX,clientY:t.clientY};this.handleDragMove(i)},handleDragEnd(){if(this.isDragging){if(this.isDragging=!1,ic.value=!1,this.dragValueCheckTimeout&&=(clearTimeout(this.dragValueCheckTimeout),null),Lr.value={x:this.position.x,y:this.position.y},this.mode.includes("lonlat")){let e=this.screenToLonLat(this.position.x,this.position.y);e&&(li.value=e)}else li.value={x:this.position.x,y:this.position.y};this.isTouchDevice?(document.removeEventListener("touchmove",this.handleTouchMove),document.removeEventListener("touchend",this.handleTouchEnd)):(document.removeEventListener("pointermove",this.handleDragMove),document.removeEventListener("pointerup",this.handleDragEnd)),setTimeout(()=>{window.MapJS&&Oe.value&&(!this.lastDragValue||this.lastDragValue.value!==Oe.value.value||(this.lastDragValue.parameter,Oe.value.parameter),this.lastDragValue=null)},100)}},handleTouchEnd(e){e.preventDefault(),this.handleDragEnd()},screenToLonLat(e,t){if(!ue.openLayerMap)return null;try{let i=ue.openLayerMap.getCoordinateFromPixel([e,t]);if(i)return{lon:i[0],lat:i[1]}}catch(i){return console.warn("[PickerComponent] screenToLonLat failed:",i),null}return null},lonLatToScreen(e,t){if(!ue.openLayerMap)return null;try{let i=ue.openLayerMap.getPixelFromCoordinate([e,t]);if(i)return{x:i[0],y:i[1]}}catch(i){return console.warn("[PickerComponent] lonLatToScreen failed:",i),null}return null},formatCoordinates(e){return e?`${e.lat.toFixed(2)}\xB0, ${e.lon.toFixed(2)}\xB0`:""},getParameterIcon(e){let t="rgb(255,255,255,0.8)",i={temperature:`
2379					<svg viewBox="0 0 64 64" fill="none">
2380						<path d="M32 4C28.6863 4 26 6.68629 26 10V40.3431C22.6131 42.4696 20.5 46.02
238013 20.5 50C20.5 56.3513 25.6487 61.5 32 61.5C38.3513 61.5 43.5 56.3513 43.5 50C43.5 46.0213 41.3869 42.4696 38 40.3431V10C38 6.68629 35.3137 4 32 4Z" stroke="${t}" stroke-width="2.5" fill="none" opacity="0.9"/>
2381						<rect x="30" y="18" width="4" height="24" fill="${t}" opacity="0.9"/>
2382						<circle cx="32" cy="50" r="8" fill="${t}"/>
2383						<!-- Temperature scale lines -->
2384						<line x1="42" y1="16" x2="48" y2="16" stroke="${t}" stroke-width="2" stroke-linecap="round" opacity="0.7"/>
2385						<line x1="42" y1="22" x2="46" y2="22" stroke="${t}" stroke-width="2" stroke-linecap="round" opacity="0.7"/>
2386						<line x1="42" y1="28" x2="48" y2="28" stroke="${t}" stroke-width="2" stroke-linecap="round" opacity="0.7"/>
2387						<line x1="42" y1="34" x2="46" y2="34" stroke="${t}" stroke-width="2" stroke-linecap="round" opacity="0.7"/>
2388					</svg>
2389				`,rain:`
2390					<svg version="1.2" baseProfile="tiny" id="Calque_1"
2391	 xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
2392	 viewBox="0 0 192 192" overflow="visible" xml:space="preserve" fill="white">
2393<g>
2394	<g id="Groupe_1231_1_" transform="translate(-198.648 -297)">
2395		<path id="Trac\xE9_2164_1_" fill-rule="evenodd" d="M273,345.8c0,0-64.5,61.6-72.1,85.2c-7.4,22.6,4.1,47.1,26.1,55.7
2396			c21.9,7.5,45.8-4.3,53.2-26.4c0.2-0.5,0.3-0.9,0.4-1.4C288.2,435.8,273,345.8,273,345.8z"/>
2397	</g>
2398	<g id="Groupe_1231_2_" transform="translate(-198.648 -297)">
2399		<path id="Trac\xE9_2164_2_" fill-rule="evenodd" d="M380.9,297c0,0-64.5,61.6-72.1,85.2c-7.4,22.6,4.1,47.1,26.1,55.7
2400			c21.9,7.5,45.8-4.3,53.2-26.4c0.2-0.5,0.3-0.9,0.4-1.4C396.1,387,380.9,297,380.9,297z"/>
2401	</g>
2402</g>
2403</svg>
2404				`,snow:`
2405					<svg version="1.2" baseProfile="tiny" id="Calque_1"
2406	 xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
2407	 viewBox="0 0 192 192" overflow="visible" xml:space="preserve" fill="white">
2408<path id="Trac\xE9_2158_1_" d="M185.6,106l-39.6,10.9l-39.7-21l39.7-21.1l39.6,10.9c0.4,0.1,0.9,0.2,1.4,0.2c2.2,0,4.1-1.3,4.8-3.4
2409	c0.7-2.5-0.7-5.1-3.2-5.8c0,0-0.1,0-0.1,0l-30.1-8.3l23.6-12.5c2.3-1.2,3.2-3.9,2-6.2c0-0.1-0.1-0.1-0.1-0.2
2410	c-1.4-2.3-4.3-3.1-6.7-1.9l-23.6,12.5l8.6-28.8c0.7-2.5-0.7-5.1-3.2-5.8c0,0-0.1,0-0.1,0c-2.6-0.7-5.3,0.7-6.1,3.2l-11.4,37.9
2411	l-40.2,21.3v-44L130.1,16c1.9-1.7,2-4.6,0.2-6.5c-0.1-0.1-0.1-0.1-0.2-0.2c-2-1.9-5-1.9-7,0l-22.2,21.2V4.7C100.9,2.1,98.7-0.1,96,0
2412	c0,0,0,0,0,0c-2.7-0.1-4.9,2.1-5,4.7c0,0,0,0,0,0v25.8L68.8,9.3c-2-1.9-5-1.9-7,0c-1.9,1.7-2,4.6-0.2,6.5c0.1,0.1,0.1,0.1,0.2,0.2
2413	L91,43.9v44L50.8,66.6L39.4,28.7c-0.8-2.6-3.5-4-6.1-3.2c-2.5,0.6-4.1,3.2-3.4,5.7c0,0,0,0.1,0,0.1l8.6,28.8L14.9,47.6
2414	c-2.4-1.3-5.3-0.4-6.7,1.9c-1.3,2.2-0.5,5,1.7,6.3c0.1,0,0.1,0.1,0.2,0.1l23.6,12.5L3.6,76.7c-2.5,0.6-4.1,3.2-3.4,5.7
2415	c0,0,0,0.1,0,0.1C0.8,84.6,2.8,86,5,86c0.5,0,0.9-0.1,1.4-0.2l39.7-11l39.7,21.1l-39.7,21L6.3,106c-2.6-0.7-5.3,0.7-6.1,3.2
2416	c-0.7,2.5,0.7,5.1,3.2,5.8c0,0,0.1,0,0.1,0l30.1,8.3l-23.6,12.5c-2.3,1.2-3.2,3.9-2,6.2c0,0.1,0.1,0.1,0.1,0.2
2417	c0.9,1.5,2.6,2.5,4.3,2.4c0.8,0,1.7-0.2,2.4-0.6l23.6-12.5l-8.6,28.8c-0.7,2.5,0.7,5.1,3.2,5.8c0,0,0.1,0,0.1,0
2418	c0.4,0.1,0.9,0.2,1.4,0.2c2.2,0,4.1-1.3,4.8-3.4l11.4-37.9l40.2-21.3v44l-29.3,27.9c-1.9,1.7-2,4.6-0.2,6.5c0.1,0.1,0.1,0.1,0.2,0.2
2419	c2,1.9,5,1.9,7,0L91,161.3v25.7c0,2.7,2.2,4.9,5,4.9c2.7,0,5-2.2,5-4.9v-25.7l22.2,21.2c2,1.9,5,1.9,7,0c1.9-1.7,2-4.6,0.2-6.5
2420	c-0.1-0.1-0.1-0.1-0.2-0.2l-29.2-27.9v-44l40.2,21.3l11.4,37.9c0.7,2.1,2.6,3.5,4.8,3.4c0.5,0,0.9-0.1,1.4-0.2
2421	c2.5-0.6,4.1-3.2,3.4-5.7c0,0,0-0.1,0-0.1l-8.6-28.8l23.6,12.5c0.7,0.4,1.6,0.6,2.4,0.6c1.8,0,3.4-0.9,4.3-2.4
2422	c1.3-2.2,0.5-5-1.7-6.3c-0.1,0-0.1-0.1-0.2-0.1l-23.6-12.5l30.1-8.3c2.5-0.6,4.1-3.2,3.4-5.7c0,0,0-0.1,0-0.1
2423	C191,106.7,188.2,105.2,185.6,106z"/>
2424</svg>
2425				`,pressure:`
2426					<svg viewBox="0 0 24 24" fill="none">
2427						<circle cx="12" cy="12" r="9" stroke="${t}" stroke-width="2" opacity="0.8"/>
2428						<circle cx="12" cy="12" r="6.5" stroke="${t}" stroke-width="1" opacity="0.3"/>
2429						<circle cx="12" cy="12" r="2" fill="${t}"/>
2430						<path d="M12 3v7" stroke="${t}" stroke-width="2.5" stroke-linecap="round"/>
2431						<path d="M12 14v4" stroke="${t}" stroke-width="1.5" stroke-linecap="round" opacity="0.5"/>
2432						<path d="M6 12h4" stroke="${t}" stroke-width="1.5" stroke-linecap="round" opacity="0.5"/>
2433						<path d="M14 12h4" stroke="${t}" stroke-width="1.5" stroke-linecap="round" opacity="0.5"/>
2434						<path d="M8.5 8.5l2 2" stroke="${t}" stroke-width="1" stroke-linecap="round" opacity="0.4"/>
2435						<path d="M13.5 13.5l2 2" stroke="${t}" stroke-width="1" stroke-linecap="round" opacity="0.4"/>
2436						<path d="M15.5 8.5l-2 2" stroke="${t}" stroke-width="1" stroke-linecap="round" opacity="0.4"/>
2437						<path d="M10.5 13.5l-2 2" stroke="${t}" stroke-width="1" stroke-linecap="round" opacity="0.4"/>
2438					</svg>
2439				`},r={t2m:"temperature",tres:"temperature",tsol:"temperature",tmer:"temperature",tmax:"temperature",tmin:"temperature",precip:"rain",radar:"rain",rain:"rain",radar_snow:"snow",pression:"pressure",pressure:"pressure"}[e.parameter]||null;if(r==="rain"&&(e.parameter==="radar"||e.parameter==="precip")){let s=e.unit||e.symbol||this.convertedUnit;(s==="cm/h"||s==="cm")&&(r="snow")}return r?i[r]:null},updatePosition(){if(!this.enabled){this.updateFrame=null;return}if(this.isDragging){this.updateFrame=requestAnimationFrame(()=>this.updatePosition());return}let e=(typeof this.teleportTarget=="string"?document.querySelector(this.teleportTarget):this.teleportTarget)?.getBoundingClientRect?.()||null;switch(this.mode){case"default":{let t=gt.x,i=gt.y;e&&(t-=e.left,i-=e.top),this.position={x:t,y:i};break}case"centerxy":e&&(this.position={x:e.width/2,y:e.height/2});break;case"longpressxy":case"dragndropxy":li.value&&li.value.x!==void 0?this.position={x:li.value.x,y:li.value.y}:this.mode.includes("dragndrop")&&e&&(this.position={x:e.width/2,y:e.height/2},li.value={x:this.position.x,y:this.position.y});break;case"longpresslonlat":case"dragndroplonlat":case"combinelonlat":if(li.value&&li.value.lon!==void 0){let t=this.lonLatToScreen(li.value.lon,li.value.lat);if(t&&e){this.position=t,t.x>=0&&t.x<=e.width&&t.y>=0&&t.y<=e.height?Lr.value={x:t.x,y:t.y}:Lr.value={x:-1e3,y:-1e3},this.updateFrame=requestAnimationFrame(()=>this.updatePosition());return}}else if((this.mode.includes("dragndrop")||this.mode.includes("combine"))&&e){let t=e.width/2,i=e.height/2;this.position={x:t,y:i};let r=this.screenToLonLat(t,i);r&&(li.value=r)}break}Lr.value={x:this.position.x,y:this.position.y},this.updateFrame=requestAnimationFrame(()=>this.updatePosition())},initializePosition(){let e=(typeof this.teleportTarget=="string"?document.querySelector(this.teleportTarget):this.teleportTarget)?.getBoundingClientRect?.()||null;if(e&&this.mode!=="default")if(this.position={x:e.width/2,y:e.height/2},Lr.value={x:this.position.x,y:this.position.y},this.mode.includes("lonlat")){let t=this.screenToLonLat(this.position.x,this.position.y);t?li.value=t:setTimeout(()=>{let i=this.screenToLonLat(this.position.x,this.position.y);i&&(li.value=i)},500)}else this.mode!=="centerxy"&&(li.value={x:this.position.x,y:this.position.y})}},watch:{},created(){this.$pickerValue=Oe,this.$pickerEnabled=Yi,this.$pickerShowLocation=au,this.$pickerBehavior=ba,this.$pickerAppearance=Pl,this.$watch(()=>Oe.value,e=>{if(this.value=e,!ue.isAnyVisibleLayerAnimating()&&e?.uvData){let t=270-parseFloat(e.uvData.direction.fromFormatted||0)-this.currentRotation;for(;t>180;)t-=360;for(;t<-180;)t+=360;this.currentRotation+=t}},{immediate:!0}),this.$watch(()=>au.value,e=>{this.showLocation=e},{immediate:!0}),this.$watch(()=>ba.value,e=>{this.mode=e,this.$nextTick(()=>{this.initializePosition()})},{immediate:!0}),this.$watch(()=>Pl.value,e=>{this.displayMode=e},{immediate:!0}),this.$watch(()=>Yi.value,e=>{this.enabled=e,e?this.updateFrame||=requestAnimationFrame(()=>this.updatePosition()):this.updateFrame&&=(cancelAnimationFrame(this.updateFrame),null)},{immediate:!0})},mounted(){document.getElementById("mapjs-picker-styles")||cg.injectStyles(),this.initializePosition(),this.enabled&&!this.updateFrame&&(this.updateFrame=requestAnimationFrame(()=>this.updatePosition()))},unmounted(){this.updateFrame&&=(cancelAnimationFrame(this.updateFrame),null)}},zre={class:"mapjs-picker__container"},Gre={key:0,class:"mapjs-picker__location"},jre={class:"mapjs-picker__coordinates"},$re={key:1,class:"mapjs-picker__value-group"},Wre=["innerHTML"],Hre={class:"mapjs-picker__value-container"},qre={class:"mapjs-picker__value"},Xre={key:0,class:"mapjs-picker__wind-arrow"},Yre=["fill"],Kre={class:"mapjs-picker__value-number"},Zre={class:"mapjs-picker__unit"},Jre={key:2,class:"mapjs-picker__value-group"};function Qre(e,t,i,r,s,n){let a=vT("CrossIcon"),o=vT("TargetIcon"),l=vT("PickerValueBox");return Di(),tm(yP,{to:i.teleportTarget},[s.displayMode==="default"?mT((Di(),ts("div",{key:0,ref:"pickerElement",class:Vp(["mapjs-picker",{draggable:n.isDraggableMode}]),style:bl(n.pickerStyle),onPointerdown:t[0]||=(...h)=>n.handlePointerDown&&n.handlePointerDown(...h),onTouchstart:t[1]||=(...h)=>n.handleTouchStart&&n.handleTouchStart(...h)},[Tt("div",zre,[s.showLocation&&s.value?.latLon?(Di(),ts("div",Gre,[t[4]||=Tt("svg",{class:"mapjs-picker__location-icon",viewBox:"0 0 24 24",fill:"
2439currentColor"},[Tt("path",{d:"M12 2C8.13 2 5 5.13 5 9c0 5.25 7 13 7 13s7-7.75 7-13c0-3.87-3.13-7-7-7zm0 9.5c-1.38 0-2.5-1.12-2.5-2.5s1.12-2.5 2.5-2.5 2.5 1.12 2.5 2.5-1.12 2.5-2.5 2.5z"})],-1),Tt("span",jre,Od(n.formatCoordinates(s.value.latLon)),1)])):$d("",!0),s.value?.value===void 0?(Di(),ts("div",Jre,[...t[5]||=[Tt("div",{class:"mapjs-picker__value"},[Tt("span",{class:"mapjs-picker__value-number"},"No data")],-1)]])):(Di(),ts("div",$re,[n.icon?(Di(),ts("div",{key:0,class:"mapjs-picker__icon",innerHTML:n.icon},null,8,Wre)):$d("",!0),Tt("div",Hre,[Tt("div",qre,[s.value.uvData?(Di(),ts("span",Xre,[(Di(),ts("svg",{viewBox:"0 0 24 24",style:bl(`transform: rotate(${n.windRotation}deg); transition: transform 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);`)},[Tt("polygon",{points:"12,3 18,18 12,14 6,18",fill:`rgb(${s.value.colorR}, ${s.value.colorG}, ${s.value.colorB})`,opacity:"0.95",stroke:"white","stroke-width":"1","stroke-linejoin":"round"},null,8,Yre)],4))])):$d("",!0),Tt("span",Kre,Od(n.formattedValue),1),Tt("span",Zre,Od(n.convertedUnit),1)])])]))]),t[6]||=Tt("div",{class:"mapjs-picker__pointer"},null,-1)],38)),[[IT,n.isVisible]]):mT((Di(),ts("div",{key:1,ref:"pickerIconElement",class:Vp(["mapjs-picker-icon",{draggable:n.isDraggableMode}]),style:bl(n.pickerIconStyle),onPointerdown:t[2]||=(...h)=>n.handlePointerDown&&n.handlePointerDown(...h),onTouchstart:t[3]||=(...h)=>n.handleTouchStart&&n.handleTouchStart(...h)},[s.displayMode==="cross"?(Di(),tm(a,{key:0})):s.displayMode==="target"?(Di(),tm(o,{key:1})):$d("",!0)],38)),[[IT,n.isVisible]]),bn(l,{"teleport-target":i.teleportTarget},null,8,["teleport-target"])],8,["to"])}var ese=I1(Vre,[["render",Qre],["__scopeId","data-v-5b28b63b"]]),DD=500,tse=300,OD=10,ise=class{constructor(e){this.element=e,this.longPressTimer=null,this.longPressPosition=null,this.longPressFired=!1,this.lastTapTime=0,this.lastTapPosition=null,this.onLongPress=null,this.onDoubleTap=null,this.handlePointerDown=this.handlePointerDown.bind(this),this.handlePointerMove=this.handlePointerMove.bind(this),this.handlePointerUp=this.handlePointerUp.bind(this),this.handlePointerCancel=this.handlePointerCancel.bind(this),this.handleTouchStart=this.handleTouchStart.bind(this),this.handleTouchMove=this.handleTouchMove.bind(this),this.attach()}attach(){this.element.addEventListener("pointerdown",this.handlePointerDown),this.element.addEventListener("pointermove",this.handlePointerMove),this.element.addEventListener("pointerup",this.handlePointerUp),this.element.addEventListener("pointercancel",this.handlePointerCancel),this.element.addEventListener("touchstart",this.handleTouchStart,{passive:!1}),this.element.addEventListener("touchmove",this.handleTouchMove,{passive:!1})}detach(){this.element.removeEventListener("pointerdown",this.handlePointerDown),this.element.removeEventListener("pointermove",this.handlePointerMove),this.element.removeEventListener("pointerup",this.handlePointerUp),this.element.removeEventListener("pointercancel",this.handlePointerCancel),this.element.removeEventListener("touchstart",this.handleTouchStart),this.element.removeEventListener("touchmove",this.handleTouchMove),this.clearLongPress()}handlePointerDown(e){this.clearLongPress(),this.longPressPosition={x:e.clientX,y:e.clientY},this.longPressTimer=setTimeout(()=>{this.onLongPress&&this.longPressPosition&&(this.longPressFired=!0,e.preventDefault&&e.preventDefault(),this._touchStartEvent&&this._touchStartEvent.preventDefault&&this._touchStartEvent.preventDefault(),this._preventDefaultTimeout&&=(clearTimeout(this._preventDefaultTimeout),null),this.onLongPress({x:this.longPressPosition.x,y:this.longPressPosition.y,event:e}))},DD)}handlePointerMove(e){if(this.longPressPosition){let t=e.clientX-this.longPressPosition.x,i=e.clientY-this.longPressPosition.y;Math.sqrt(t*t+i*i)>OD&&this.clearLongPress()}}handlePointerUp(e){let t=Date.now(),i={x:e.clientX,y:e.clientY},r=this.longPressFired;if(this.clearLongPress(),!r){if(t-this.lastTapTime<tse&&this.lastTapPosition){let s=i.x-this.lastTapPosition.x,n=i.y-this.lastTapPosition.y;
2439if(Math.sqrt(s*s+n*n)<OD*2){this.onDoubleTap&&this.onDoubleTap({x:i.x,y:i.y,event:e}),this.lastTapTime=0,this.lastTapPosition=null;return}}this.lastTapTime=t,this.lastTapPosition=i}}handlePointerCancel(){this.clearLongPress()}handleTouchStart(e){this.onLongPress&&(this._touchStartEvent=e,this._preventDefaultTimeout=setTimeout(()=>{this.longPressTimer&&this._touchStartEvent&&this._touchStartEvent.preventDefault()},DD-150))}handleTouchMove(e){this.longPressTimer&&e.preventDefault()}clearLongPress(){this.longPressTimer&&=(clearTimeout(this.longPressTimer),null),this._preventDefaultTimeout&&=(clearTimeout(this._preventDefaultTimeout),null),this.longPressPosition=null,this.longPressFired=!1,this._touchStartEvent=null}destroy(){this.detach(),this.onLongPress=null,this.onDoubleTap=null}},rse=class{constructor(e=null){this.app=null,this.mountPoint=null,this.gestureDetector=null,this.containerElement=e||document.body,this.initializeApp()}initializeApp(){this.mountPoint=document.createElement("div"),this.mountPoint.id="mapjs-picker-mount",this.containerElement.appendChild(this.mountPoint),this.app=vY(ese,{teleportTarget:this.containerElement}),this.app.mount(this.mountPoint),cg.injectStyles(),this.gestureDetector=new ise(this.containerElement),this.gestureDetector.onLongPress=this.handleLongPress.bind(this),this.gestureDetector.onDoubleTap=this.handleDoubleTap.bind(this)}setContainer(e){e&&e!==this.containerElement&&(this.containerElement=e,this.dispose(),this.initializeApp())}enable(){Yi.value=!0}disable(){Yi.value=!1}handleLongPress(e){let t=ba.value;if(!t.includes("longpress")&&!t.includes("combine"))return;let i=Oe.value?{value:Oe.value.value,parameter:Oe.value.parameter}:null;if(t.includes("lonlat")){if(ue.openLayerMap)try{let n=ue.openLayerMap.getCoordinateFromPixel([e.x,e.y]);n&&(li.value={lon:n[0],lat:n[1]},Lr.value={x:e.x,y:e.y})}catch(n){console.warn("[Picker] Failed to convert coordinates:",n)}}else li.value={x:e.x,y:e.y},Lr.value={x:e.x,y:e.y};let r=0,s=()=>{r++,!(window.MapJS&&Oe.value&&(!i||i.value!==Oe.value.value||i.parameter!==Oe.value.parameter||r>=20))&&r<20&&setTimeout(s,50)};setTimeout(s,50)}handleDoubleTap(e){let t=ba.value;if(!t.includes("longpress")&&!t.includes("combine"))return;let i=Oe.value?{value:Oe.value.value,parameter:Oe.value.parameter}:null;if(t.includes("lonlat")){if(ue.openLayerMap)try{let n=ue.openLayerMap.getCoordinateFromPixel([e.x,e.y]);n&&(li.value={lon:n[0],lat:n[1]},Lr.value={x:e.x,y:e.y})}catch(n){console.warn("[Picker] Failed to convert coordinates:",n)}}else li.value={x:e.x,y:e.y},Lr.value={x:e.x,y:e.y};let r=0,s=()=>{r++,!(window.MapJS&&Oe.value&&(!i||i.value!==Oe.value.value||i.parameter!==Oe.value.parameter||r>=20))&&r<20&&setTimeout(s,50)};setTimeout(s,50)}dispose(){this.gestureDetector&&=(this.gestureDetector.destroy(),null),this.app&&=(this.app.unmount(),null),this.mountPoint&&this.mountPoint.parentNode&&(this.mountPoint.remove(),this.mountPoint=null),cg.removeStyles()}},sse=class{constructor(e={}){this.getZoom=e.getZoom||null}enable(){this._enabled||(this._enabled=!0,this.create(),this._updateFn=()=>this.update(),N.onAfterUpdate.add(this._updateFn))}disable(){this._enabled&&(this._enabled=!1,this._updateFn&&=(N.onAfterUpdate.remove(this._updateFn),null),this.destroy())}dispose(){this.disable()}create(){if(this.statsDiv)return;let e=document.createElement("div");e.id="map-stats",Object.assign(e.style,{position:"absolute",top:"48px",left:"0",background:"rgba(0,0,0,0.7)",color:"#0f0",padding:"32px",fontSize:"12px",zIndex:"10000",width:"270px",whiteSpace:"pre-wrap",fontFamily:"monospace",boxSizing:"border-box",textAlign:"left"}),document.body.appendChild(e),this.statsDiv=e}destroy(){this.statsDiv&&=(document.body.removeChild(this.statsDiv),null)}update(){if(!this.statsDiv)return;let e="-";try{let d=this.getZoom?this.getZoom():void 0;typeof d=="number"&&isFinite(d)&&(e=d.toFixed(2))}catch{}let t=0,i=0;e5.instances.forEach(d=>{d.master.visible&&(t+=d.visibleTileCount||0),i+=d.totalTilesLoaded||0});let r=Km.getInstance().getStats(),s=r.inUse,n=r.available,a=q.lastRenderTime==null?"-":`${q.lastRenderTime.toFixed(1)}ms`,o=Bi.value,l=q.renderer.info?.memory?.geometries??"-",h=q.renderer.info?.memory?.textures??"-",u=q.renderer.info?.render?.drawCalls??"-";this.statsDiv.innerText=`Zoom: ${e}
2440Tiles visible: ${t}
2441Total loaded: ${i}
2442Geometries: ${l}
2443Textures: ${h}
2444Draw calls: ${u}
2445RT pool (used/free): ${s}/${n}
2446Render time: ${a}
2447Pending loads: ${o}`}};function BD(e){let t=bK;return{lat:e.lat,lon:e.lon,type:"icon",color:t,iconUrl:Kk(t),iconSize:[25,36],iconAnchor:[12,34],className:"bookmarkMarker"}}var nse=class{constructor(e){this.mapJS=e}
2447getCookie(e){let t=RegExp("(^|; )"+e+"=([^;]+)"),i=document.cookie.match(t);return i?decodeURIComponent(i[2]):null}setSavedBookmarkCookie(e){let t=JSON.stringify(e),i=encodeURIComponent(t),r=new Date(Date.now()+7*864e5).toUTCString();document.cookie=`savedBookmark=${i}; expires=${r}; path=/; SameSite=Lax`}addBookmarker(){let e=this.getCookie("savedBookmark");if(e)try{let t=JSON.parse(e).map(BD);this.mapJS.addMarkers(t)}catch(t){this.mapJS._debugMode&&console.error("Failed to parse savedBookmark cookie:",t)}}},i2=class{constructor(){this._ensureStyles()}_ensureStyles(){if(!document.getElementById("mapjs-loader-styles")){let e=document.createElement("style");e.id="mapjs-loader-styles",e.textContent=`
2448				@keyframes mapjs-spin {
2449					0% { transform: rotate(0deg); }
2450					100% { transform: rotate(360deg); }
2451				}
2452			`,document.head.appendChild(e)}}createLoader(e={}){let{containerId:t=null,spinnerColor:i="#DDD",backgroundColor:r="transparent"}=e,s=document.createElement("div");s.id="mapjs-loader",Object.assign(s.style,{position:"fixed",top:"0",left:"0",width:"100%",height:"100%",backgroundColor:r,display:"flex",justifyContent:"center",alignItems:"center",zIndex:"999999",opacity:"0",transition:"opacity 0.3s ease-in-out"});let n=document.createElement("div");Object.assign(n.style,{width:"50px",height:"50px",border:`3px solid ${i}20`,borderTop:`3px solid ${i}`,borderRadius:"50%",animation:"mapjs-spin 1s linear infinite"}),s.appendChild(n);let a=t?document.getElementById(t):document.body;return a?a.appendChild(s):document.body.appendChild(s),{element:s,progressBar:null,percentageText:null,messageElement:null,show(){s.style.opacity="1"},hide(){s.style.opacity="0",setTimeout(()=>{s.parentNode&&s.parentNode.removeChild(s)},300)},updateProgress(o){},updateMessage(o){},setState(o,l=null){}}}createSimpleLoader(e={}){let{containerId:t=null,message:i="Loading...",color:r="#4CAF50"}=e,s=document.createElement("div");s.id="mapjs-simple-loader",Object.assign(s.style,{position:"fixed",top:"0",left:"0",width:"100%",height:"100%",backgroundColor:"rgba(0, 0, 0, 0.8)",display:"flex",justifyContent:"center",alignItems:"center",zIndex:"999999",fontFamily:"Arial, sans-serif",opacity:"0",transition:"opacity 0.3s ease-in-out"});let n=document.createElement("div");Object.assign(n.style,{textAlign:"center",color:"#ffffff"});let a=document.createElement("div");Object.assign(a.style,{width:"40px",height:"40px",border:`3px solid ${r}20`,borderTop:`3px solid ${r}`,borderRadius:"50%",animation:"mapjs-spin 1s linear infinite",margin:"0 auto 15px auto"});let o=document.createElement("div");o.textContent=i,Object.assign(o.style,{fontSize:"14px",fontWeight:"500"}),n.appendChild(a),n.appendChild(o),s.appendChild(n);let l=t?document.getElementById(t):document.body;return l?l.appendChild(s):document.body.appendChild(s),{element:s,messageElement:o,show(){s.style.opacity="1"},hide(){s.style.opacity="0",setTimeout(()=>{s.parentNode&&s.parentNode.removeChild(s)},300)},updateMessage(h){o.textContent=h}}}};function ase(e){let t=window.L;window.L=new Proxy({marker:function(i,r={}){let[s,n]=i;return{latlng:{lat:s,lng:n},options:r,getLatLng:function(){return this.latlng},setLatLng:function(a){return this.latlng={lat:a[0],lng:a[1]},this},addTo:function(){return this},remove:function(){return this},prepare:function(){return e.prepareMarker(this)},addToMap:function(){let a=this.prepare();return e.addPreparedMarker(a),this._markerId=a,this},removeFromMap:function(){return this._markerId&&=(e.removePreparedMarker(this._markerId),null),this}}},icon:function(i={}){return{options:{iconUrl:i.iconUrl||"",iconSize:i.iconSize||[25,36],iconAnchor:i.iconAnchor||[12,34],className:i.className||"customMarker",...i}}},divIcon:function(i={}){return{options:{html:i.html||"",className:i.className||"customDivIcon",iconSize:i.iconSize||[25,36],iconAnchor:i.iconAnchor||[12,34],...i}}},latLngBounds:function(i,r){let s;if(Array.isArray(i)&&Array.isArray(r))s={south:Math.min(i[0],r[0]),west:Math.min(i[1],r[1]),north:Math.max(i[0],r[0]),east:Math.max(i[1],r[1])};else if(i&&typeof i=="object"&&"getSouthWest"in i){let n=i.getSouthWest
2452(),a=i.getNorthEast();s={south:n.lat,west:n.lng,north:a.lat,east:a.lng}}else if(i&&Array.isArray(i)){let n=i.map(o=>o[0]),a=i.map(o=>o[1]);s={south:Math.min(...n),west:Math.min(...a),north:Math.max(...n),east:Math.max(...a)}}else s={south:0,west:0,north:0,east:0};return{_bounds:s,getSouthWest(){return{lat:s.south,lng:s.west}},getNorthEast(){return{lat:s.north,lng:s.east}},getCenter(){return{lat:(s.south+s.north)/2,lng:(s.west+s.east)/2}},getBounds(){return[[s.south,s.west],[s.north,s.east]]},contains(n){let a=typeof n=="object"&&"lat"in n?n.lat:n[0],o=typeof n=="object"&&"lng"in n?n.lng:n[1];return a>=s.south&&a<=s.north&&o>=s.west&&o<=s.east},extend(n){let a=typeof n=="object"&&"lat"in n?n.lat:n[0],o=typeof n=="object"&&"lng"in n?n.lng:n[1];return s.south=Math.min(s.south,a),s.north=Math.max(s.north,a),s.west=Math.min(s.west,o),s.east=Math.max(s.east,o),this},intersects(n){let a=n._bounds||n;return!(s.south>a.north||s.north<a.south||s.west>a.east||s.east<a.west)},overlaps(n){return this.intersects(n)},getSize(){return{x:s.east-s.west,y:s.north-s.south}},isValid(){return s.south<=s.north&&s.west<=s.east},pad(n){let a=(s.north-s.south)*n,o=(s.east-s.west)*n;return s.south-=a,s.north+=a,s.west-=o,s.east+=o,this},toString(){return`LatLngBounds(${s.south}, ${s.west}, ${s.north}, ${s.east})`}}},markerAndAdd:function(i,r={}){return this.marker(i,r).addToMap()},getMapJS:function(){return e}},{get:function(i,r){if(r in i)return i[r];if(t&&r in t)return t[r]}})}var ose=class{constructor(e){this.mapJS=e,this.logger=e.logger,this._markerCounter=0,this._preparedMarkers=new Map,this._geolocationMarkerIds=new Set,this._autoShowPreparedMarkers=!0,this._pendingShowIds=new Set,this._flushShowScheduled=!1}async prepareMarker(e,t=!1){let i=e.getLatLng?e.getLatLng():e.latlng,r=i.lat,s=i.lng,n=this.findMarkerAtCoordinates(r,s);if(n)return this.mapJS.log("prepareMarker: marker already exists at coordinates",r,s,"with ID:",n),n;let a=`marker.${++this._markerCounter}`,o=null,l=[25,36],h=[12,34],u="customMarker";if(e){if(e.options&&e.options.icon){let c=e.options.icon;c.options?(o=c.options.iconUrl,l=c.options.iconSize||l,h=c.options.iconAnchor||h,u=c.options.className||u):c.iconUrl&&(o=c.iconUrl,l=c.iconSize||l,h=c.iconAnchor||h,u=c.className||u)}!o&&e.iconUrl&&(o=e.iconUrl,l=e.iconSize||l,h=e.iconAnchor||h,u=e.className||u),!o&&typeof e=="object"&&!e.getLatLng&&e.icon&&e.icon.iconUrl&&(o=e.icon.iconUrl,l=e.icon.iconSize||l,h=e.icon.iconAnchor||h,u=e.icon.className||u)}let d={lat:r,lon:s,type:"icon",color:16766720,iconUrl:o,iconSize:l,iconAnchor:h,className:u,originalMarker:e};return this._preparedMarkers.set(a,d),(t||this._autoShowPreparedMarkers)&&this._queueAutoShow(a),a}_queueAutoShow(e){this._pendingShowIds.add(e),!this._flushShowScheduled&&(this._flushShowScheduled=!0,queueMicrotask(()=>this._flushPendingShows()))}async _flushPendingShows(){this._flushShowScheduled=!1;let e=[...this._pendingShowIds];this._pendingShowIds.clear(),e.length>0&&await this.addPreparedMarkers(e)}findMarkerAtCoordinates(e,t){for(let[i,r]of this._preparedMarkers)if(r.lat===e&&r.lon===t)return i;return null}async addPreparedMarkers(e){let t=[];for(let i of e){let r=this._preparedMarkers.get(i);r?t.push(r):this.logger.warn("Marker not found:",i)}t.length>0&&(await this.mapJS.addMarkers(t),this.mapJS.log("addPreparedMarkers",t.length))}async addPreparedMarker(e){return this.addPreparedMarkers([e])}removePreparedMarker(e){let t=this._preparedMarkers.get(e);if(t){this._preparedMarkers.delete(e);let i=this.mapJS.getMarkersLayer();if(i&&i.data&&i.data.markers){let r=i.data.markers.findIndex(s=>s.lat===t.lat&&s.lon===t.lon&&s.originalMarker===t.originalMarker);r!==-1&&(i.data.markers.splice(r,1),i.currentLayer&&(i.data.updateMarkers(),window.stage3d&&window.stage3d.scheduleRender&&window.stage3d.scheduleRender()))}this.mapJS.log("removePreparedMarker",e)}else this.logger.warn("Marker not found:",e)}getPreparedMarkerIds(){return Array.from(this._preparedMarkers.keys())}async clearPreparedMarkers(){this._preparedMarkers.clear(),this.mapJS.removeMarkers();let e=this.mapJS.getMarkersLayer();e&&e.currentLayer&&(await e.data.updateMarkers(),window.stage3d&&window.stage3d.scheduleRender&&window.stage3d.scheduleRender()),this.mapJS.log("clearPreparedMarkers")}addGeolocationPin(e,t,i=null){let r=i||"https://static5.mclcm.net/lcm2018/int/map/pin-geoloc-lcm.svg",s=this.findGeolocationMarkerAtCoordinates(e,t);if(s){this.mapJS.log("addGeolocationPin: Geolocation marker already exists at coordinates",e,t,"with ID:",s);return}this.removeMarkersAtCoordinates(e,t,!1);let n=window.L.marker([e,t],{icon:window.L.icon({iconUrl:r,iconSize:[25,36],iconAnchor:[12,34],className:"geolocationMarker"})});this.prepareMarker(n,!0).then(a=>{this._geolocationMarkerIds.add(a),this.mapJS.log("addGeolocationPin: Added geolocation marker with ID:",a,"at coordinates:",e,t),this.mapJS.log("addGeolocationPin: Total geolocation markers:",this._geolocationMarkerIds.size),this.mapJS.updateGeolocationPinDisplay()}).catch(a=>{this.logger.error("addGeolocationPin: Failed to add geolocation marker:",a)})}hideGeolocationPin(){let e=this.mapJS.getMarkersLayer();if(!e||!e.data||!e.data.markers){this.mapJS.log("hideGeolocationPin: No markers layer or data found");return}let t=Array.from(this._geolocationMarkerIds),i=0;for(let r of t){let s=this._preparedMarkers.get(r);if(s){let n=e.data.markers.findIndex(a=>a.lat===s.lat&&a.lon===s.lon);n!==-1&&(e.data.markers.splice(n,1),i++),this._preparedMarkers.delete(r)}}this._geolocationMarkerIds.clear(),e.currentLayer&&e.data.updateMarkers&&(e.data.updateMarkers(),window.stage3d&&window.stage3d.scheduleRender&&window.stage3d.scheduleRender()),this.mapJS.log(`hideGeolocationPin: Removed ${i} geolocation markers`)}findGeolocationMarkerAtCoordinates(e,t){for(let i of this._geolocationMarkerIds){let r=this._preparedMarkers.get(i);if(r&&r.lat===e&&r.lon===t)return i}return null}removeMarkersAtCoordinates(e,t,i=!1){let r=this.mapJS.getMarkersLayer();if(!r||!r.data||!r.data.markers)return;let s=[];for(let n=r.data.markers.length-1;n>=0;n--){let a=r.data.markers[n];if(a.lat===e&&a.lon===t){let o=this.isGeolocationMarker(a);if((i||!o)&&(s.push(n),o)){let l=this.findGeolocationMarkerAtCoordinates(e,t);l&&(this._geolocationMarkerIds.delete(l),this._preparedMarkers.delete(l))}}}s.forEach(n=>{r.data.markers.splice(n,1)}),s.length>0&&(r.currentLayer&&r.data.updateMarkers&&(r.data.updateMarkers(),window.stage3d&&window.stage3d.scheduleRender&&window.stage3d.scheduleRender()),this.mapJS.log(`removeMarkersAtCoordinates: Removed ${s.length} markers at (${e}, ${t})`))}isGeolocationMarker(e){for(let t of this._geolocationMarkerIds){let i=this._preparedMarkers.get(t);if(i&&i.lat===e.lat&&i.lon===e.lon)return!0}return!1}setAutoShowPreparedMarkers(e){this._autoShowPreparedMarkers=!!e,this.mapJS.log("setAutoShowPreparedMarkers",e)}getAutoShowPreparedMarkers(){return this._autoShowPreparedMarkers}hasMarkerAtCoordinates(e,t){return this.findMarkerAtCoordinates(e,t)!==null}getMarkerIdAtCoordinates(e,t){return this.findMarkerAtCoordinates(e,t)}clearGeolocationMarkers(){this._geolocationMarkerIds.clear()}dispose(){this.clearPreparedMarkers(),this._preparedMarkers=null,this._markerCounter=0,this.clearGeolocationMarkers(),this._geolocationMarkerIds=null}},lse=class{constructor(e){this.mapJS=e,this.logger=e.logger,this._pressedKeys=new Set,this._longPressTimeout=null,this.initKeyboardListeners()}initKeyboardListeners(){document.addEventListener("keydown",this.onKeyDown),document.addEventListener("keyup",this.onKeyUp)}initTouchListeners(){document.addEventListener("touchstart",this.onTouchStart),document.addEventListener("touchend",this.onTouchEnd),document.addEventListener("touchmove",this.onTouchMove)}onKeyDown=e=>{let t=e.key.toLowerCase();this._pressedKeys.add(t),this._pressedKeys.has("h")&&this._pressedKeys.has("b")&&this.mapJS.removeMarkersByType("icon"),this._pressedKeys.has("h")&&this._pressedKeys.has("g")&&this.mapJS.removeMarkersByType("circle")};onKeyUp=e=>{let t=e.key.toLowerCase();this._pressedKeys.delete(t)};onTouchStart=e=>{this._longPressTimeout=setTimeout(()=>{this.logger.info("Long press detected"),Il.value==="t2m"||Il.value==="vent_kmh"?Yi.value=!0:Yi.value=!1},5e3)};onTouchEnd=e=>{this._longPressTimeout&&=(clearTimeout(this._longPressTimeout),null)};onTouchMove=e=>{this._longPressTimeout&&=(clearTimeout(this._longPressTimeout),null)};
2452dispose(){document.removeEventListener("keydown",this.onKeyDown),document.removeEventListener("keyup",this.onKeyUp),document.removeEventListener("touchstart",this.onTouchStart),document.removeEventListener("touchend",this.onTouchEnd),document.removeEventListener("touchmove",this.onTouchMove),this._longPressTimeout&&=(clearTimeout(this._longPressTimeout),null),this._pressedKeys.clear()}},hse=class{constructor(e){this.mapJS=e,this.logger=e.logger,this._debugMode=e._debugMode}getCookie(e){let t=RegExp("(^|; )"+e+"=([^;]+)"),i=document.cookie.match(t);return i?decodeURIComponent(i[2]):null}setCookie(e,t,i=7){let r=t;typeof t=="object"&&(r=JSON.stringify(t));let s=encodeURIComponent(r),n=new Date(Date.now()+i*864e5).toUTCString();document.cookie=`${e}=${s}; expires=${n}; path=/; SameSite=Lax`}deleteCookie(e){document.cookie=`${e}=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;`}getSavedBookmarks(){let e=this.getCookie("savedBookmark");if(e)try{return JSON.parse(e)}catch(t){return this._debugMode&&console.error("Failed to parse savedBookmark cookie:",t),null}return null}setSavedBookmarks(e){this.setCookie("savedBookmark",e,7)}addBookmarkers(){let e=this.getSavedBookmarks();if(e){let t=e.map(BD);this.mapJS.addMarkers(t),this.mapJS.log("Added bookmarkers from cookie:",t.length)}}clearAll(){this.deleteCookie("savedBookmark")}},Nu=1/1.852,use=6371,nh=Math.PI/180,dse=180/Math.PI;function F1(e,t,i,r){let s=(i-e)*nh,n=(r-t)*nh,a=Math.sin(s/2),o=Math.sin(n/2),l=a*a+Math.cos(e*nh)*Math.cos(i*nh)*o*o;return use*2*Math.atan2(Math.sqrt(l),Math.sqrt(1-l))}function UD(e,t,i,r){let s=e*nh,n=i*nh,a=(r-t)*nh,o=Math.cos(n),l=Math.sin(a)*o,h=Math.cos(s)*Math.sin(n)-Math.sin(s)*o*Math.cos(a);return(Math.atan2(l,h)*dse+360)%360}function VD(e,t,i=null){let r=e?.length??0;if(r===0)return null;if(r===1){let c=e[0];return{lat:c.lat,lon:c.lon,heading:0,segmentIndex:0,distanceKm:0}}let s=i;if(!s){s=Array(r),s[0]=0;for(let c=1;c<r;c++){let p=e[c-1],m=e[c];s[c]=s[c-1]+F1(p.lat,p.lon,m.lat,m.lon)}}let n=s[r-1],a=t<0?0:t>n?n:t;if(a>=n){let c=e[r-2],p=e[r-1];return{lat:p.lat,lon:p.lon,heading:UD(c.lat,c.lon,p.lat,p.lon),segmentIndex:r-2,distanceKm:n}}let o=0;for(;o<r-1&&s[o+1]<=a;)o++;let l=s[o+1]-s[o],h=l>0?(a-s[o])/l:0,u=e[o],d=e[o+1];return{lat:u.lat+(d.lat-u.lat)*h,lon:u.lon+(d.lon-u.lon)*h,heading:UD(u.lat,u.lon,d.lat,d.lon),segmentIndex:o,distanceKm:a}}function cse(e,t,i,r=null){let s=e?.length??0;if(s===0)return null;if(s===1)return{lat:e[0].lat,lon:e[0].lon,distanceKm:0,segmentIndex:0};let n=r;if(!n){n=Array(s),n[0]=0;for(let p=1;p<s;p++){let m=e[p-1],g=e[p];n[p]=n[p-1]+F1(m.lat,m.lon,g.lat,g.lon)}}let a=Math.cos(t*nh),o=1/0,l=0,h=0;for(let p=0;p<s-1;p++){let m=e[p],g=e[p+1],f=(m.lon-i)*a,y=m.lat-t,x=(g.lon-m.lon)*a,b=g.lat-m.lat,_=x*x+b*b,T=0;_>0&&(T=-(f*x+y*b)/_,T<0?T=0:T>1&&(T=1));let w=f+T*x,M=y+T*b,S=w*w+M*M;S<o&&(o=S,l=T,h=p)}let u=e[h],d=e[h+1],c=n[h+1]-n[h];return{lat:u.lat+(d.lat-u.lat)*l,lon:u.lon+(d.lon-u.lon)*l,distanceKm:n[h]+c*l,segmentIndex:h}}var zD="http://www.w3.org/2000/svg",ah=e=>Math.round(e*10)/10,GD=e=>Number.isFinite(e)&&e>0?e:null;function pse(e=.15,t=.15){let i=1/(1-.5*e-.5*t),r=1-t,s=i*(r-.5*e);return n=>{if(n<=0)return 0;if(n>=1)return 1;if(n<e)return .5*i*n*n/e;if(n<r)return i*(n-.5*e);let a=n-r;return s+i*a-.5*i*a*a/t}}var jD=pse(.15,.15),mse=400,$D=.3,WD=5,gse=400,fse=class{constructor(e){this.mapjs=e,this.waypoints=[],this.nextId=1,this.enabled=!1,this._hidden=!1,this.selectedId=null,this.draggingId=null,this.pendingDragId=null,this.pendingDragStart=null,this.dragStartThresholdPx=8,this.previousPanState=!0,this._panWasDisabledByRouting=!1,this.container=null,this.waypointDivs=new Map,this.segmentLabels=[],this._svgEl=null,this._svgPolyline=null,this.boat=null,this.boatDiv=null,this._lastBoatSvg=null,this._lastCumKm=null,this._boatPayloadCache=null,this._boatAnimation=null,this._lastBoatMoveAt=null,this.routeLineRenderer="svg",this._onDown=this._onDownHandler.bind(this),this._onMove=this._onMoveHandler.bind(this),this._onUp=this._onUpHandler.bind(this),this._ignoreNextClick=!1,this._ignoreNextClickTimeout=null,this._ignoreNextClickPixel=null,this._olClickKey=null,this._onMapMove=null,this._cancelDrag=this._cancelDragInternal.bind(this),this._activePointerIds=new Set,this._trackPointerDown=this._trackPointerDown.bind(this),this._trackPointerUp=this._trackPointerUp.bind(this),this.speedKnots=6,this._centerToRouteScheduled=!1,this._centerToRoutePadding=null,this._onUpdate=this._updateOpacity.bind(this),N.onUp
2452date.add(this._onUpdate)}_clientToMapPixel(e,t){let i=ue.openLayerMap;if(!i)return[e,t];let r=i.getViewport()?.getBoundingClientRect?.();return r?[e-r.left,t-r.top]:[e,t]}_pixelToLonLat(e,t){let i=ue.openLayerMap;if(!i)return null;let[r,s]=this._clientToMapPixel(e,t),n=i.getCoordinateFromPixel([r,s]);return n?{lon:n[0],lat:n[1]}:null}_coordinateToLonLat(e){return e?{lon:e[0],lat:e[1]}:null}_getPixelForWaypoint(e){let t=ue.openLayerMap;return t?t.getPixelFromCoordinate([e.lon,e.lat]):null}_ensureContainer(){if(this.container)return;let e=ue.openLayerMap;if(!e)return;let t=e.getViewport();this.container=document.createElement("div"),this.container.className="routing-waypoints",this.container.style.cssText="position:absolute;top:0;left:0;width:100%;height:100%;pointer-events:none;z-index:20",t.appendChild(this.container),ms.injectStyles(),ms.onStyleChange=()=>{this.waypoints.length>0&&this._render(),this._lastBoatSvg=null,this.boat&&this._boatPayloadCache&&this._renderBoat(this._boatPayloadCache)}}_createWaypointDiv(e,t){let i=e.id===this.selectedId,r=document.createElement("div");r.className="routing-waypoint",r.dataset.waypointId=e.id;let s=document.createElement("div");s.className=i?"routing-waypoint-circle routing-waypoint-circle--selected":"routing-waypoint-circle";let n=document.createElement("span");n.className="routing-waypoint-label",n.textContent=t+1,s.appendChild(n),r.appendChild(s);let a=document.createElement("div");a.className="routing-waypoint-remove",a.style.display=i?"flex":"none";let o=ms.styles.removeButton?.html;return o?a.innerHTML=o:a.textContent="\xD7",a.addEventListener("pointerdown",l=>{l.stopPropagation(),l.preventDefault(),this._ignoreNextClick=!0,this._ignoreNextClickTimeout&&clearTimeout(this._ignoreNextClickTimeout),this._ignoreNextClickTimeout=setTimeout(()=>{this._ignoreNextClick=!1,this._ignoreNextClickTimeout=null},250),this.remove(e.id)}),r.appendChild(a),{div:r,removeBtn:a}}_updateOpacity(){let e=ue.getLayerByName("routing"),t=e?e.visible&&e.opacity>=.01:!0,i=e?e.opacity:1;t?(this._hidden&&(this._hidden=!1,this.container&&(this.container.style.display="")),this.container&&(this.container.style.opacity=i)):this._hidden||(this._hidden=!0,this.container&&(this.container.style.display="none"))}setRouteLineRenderer(e){let t=e==="webgl"?"webgl":"svg";t!==this.routeLineRenderer&&(this.routeLineRenderer=t,t==="svg"?ue.getLayerByName("routing")?.data?.renderLine?.([]):this._disposeSvgRoute(),this._render())}_disposeSvgRoute(){this._svgEl?.remove(),this._svgEl=null,this._svgPolyline=null}_ensureSvgRoute(){if(this._svgPolyline||(this._ensureContainer(),!this.container))return;let e=document.createElementNS(zD,"svg");e.setAttribute("width","100%"),e.setAttribute("height","100%"),e.style.cssText="position:absolute;inset:0;pointer-events:none;overflow:visible";let t=document.createElementNS(zD,"polyline");t.setAttribute("fill","none"),e.appendChild(t),this.container.insertBefore(e,this.container.firstChild),this._svgEl=e,this._svgPolyline=t,this._updateSvgRouteStyle(),this._updateOpacity()}_updateSvgRouteStyle(){if(!this._svgPolyline)return;let e=ms.getLineStyle?.()??ms.styles?.line,t=e?.lineWidth??3,i=e?.color??1402304,r=`#${Number(i).toString(16).padStart(6,"0")}`;this._svgPolyline.setAttribute("stroke",r),this._svgPolyline.setAttribute("stroke-width",String(t)),this._svgPolyline.setAttribute("stroke-linecap","round"),this._svgPolyline.setAttribute("stroke-linejoin","round")}_updateSvgRouteGeometry(){if(!this._svgPolyline||this._hidden)return;if(this.waypoints.length<2){this._svgPolyline.setAttribute("points","");return}let e=[],t=this.waypoints;for(let r=0;r<t.length-1;r++){let s=t[r],n=t[r+1],a=Math.max(1,Math.min(256,Math.ceil(Math.abs(n.lat-s.lat)/.25)));for(let o=0;o<a;o++){let l=o/a,h=this._getPixelForWaypoint({lon:s.lon+(n.lon-s.lon)*l,lat:s.lat+(n.lat-s.lat)*l});h&&e.push(`${h[0]},${h[1]}`)}}let i=this._getPixelForWaypoint(t[t.length-1]);i&&e.push(`${i[0]},${i[1]}`),this._svgPolyline.setAttribute("points",e.join(" "))}_updateWaypointPositions(){let e=ue.openLayerMap;if(!e||!this.container||this._hidden)return;let t=e.getSize();if(!t)return;let[i,r]=t;
2452this.waypointDivs.forEach(({div:s},n)=>{let a=this.waypoints.find(u=>u.id===n);if(!a)return;let o=this._getPixelForWaypoint(a);if(!o){s.style.display="none";return}let[l,h]=o;l<-50||l>i+50||h<-50||h>r+50?s.style.display="none":(s.style.display="block",s.style.left=`${l}px`,s.style.top=`${h}px`)}),this._updateSegmentLabelPositions(),this.routeLineRenderer==="svg"&&this._updateSvgRouteGeometry(),this.boat&&this._boatPayloadCache&&this._updateBoatPixel(this._boatPayloadCache)}_updateSegmentLabelPositions(){if(ue.openLayerMap)for(let e of this.segmentLabels){let t=this.waypoints.find(d=>d.id===e.fromId),i=this.waypoints.find(d=>d.id===e.toId);if(!t||!i){e.div.style.display="none";continue}let r=this._getPixelForWaypoint(t),s=this._getPixelForWaypoint(i);if(!r||!s){e.div.style.display="none";continue}let n=(r[0]+s[0])/2,a=(r[1]+s[1])/2,o=s[0]-r[0],l=s[1]-r[1],h=ms.styles.segmentLabel?.minPixelDistance??0;if(Math.hypot(o,l)<h){e.div.style.display="none";continue}let u=180/Math.PI*Math.atan2(l,o);u>90&&(u-=180),u<-90&&(u+=180),e.div.style.display="block",e.div.style.left=`${n}px`,e.div.style.top=`${a}px`,e.div.style.transform=`translate(-50%, -50%) rotate(${u}deg)`}}_rebuildWaypointDivs(){this.waypointDivs.forEach(({div:e})=>
2452e.remove()),this.waypointDivs.clear(),this.segmentLabels.forEach(({div:e})=>e.remove()),this.segmentLabels=[],this._ensureContainer(),this.container&&(this.waypoints.forEach((e,t)=>{let{div:i,removeBtn:r}=this._createWaypointDiv(e,t);if(this.container.appendChild(i),this.waypointDivs.set(e.id,{div:i,removeBtn:r}),t>0){let s=this.waypoints[t-1],n=F1(s.lat,s.lon,e.lat,e.lon),a=Math.round(n*Nu),o=this._createSegmentLabel(a);this.container.appendChild(o),this.segmentLabels.push({div:o,fromId:s.id,toId:e.id})}}),this._updateWaypointPositions())}_createSegmentLabel(e){let t=document.createElement("div");return t.className="routing-segment-label",t.textContent=`${e} NM`,t}_render(){this._rebuildWaypointDivs(),this.routeLineRenderer==="webgl"?(ue.getLayerByName("routing")?.data?.renderLine?.(this.waypoints),this._disposeSvgRoute()):(this._ensureSvgRoute(),this._updateSvgRouteStyle(),this._updateSvgRouteGeometry())}_computeDistances(){let e=0,t=0,i=this.speedKnots*1.852,r=[0],s=this.waypoints.map((l,h)=>{let u=0,d=0;if(h>0){let p=this.waypoints[h-1];u=F1(p.lat,p.lon,l.lat,l.lon),d=i>0?u/i*60:0}e+=u,t+=d,h>0&&r.push(e);let c=this._getPixelForWaypoint(l);return{x:c?c[0]:0,y:c?c[1]:0,lat:l.lat,lon:l.lon,id:l.id,distanceFromPrev:{km:ah(u),nm:ah(u*Nu)},durationFromPrev:ah(d)}}),n=ah(e*Nu),a=ah(t),o=GD(n);return this._lastCumKm=r,{points:s,totalDistance:o==null?null:{value:o,unit_id:29},totalDuration:GD(a),speed:{knots:this.speedKnots,kmh:Math.round(i*10)/10},cumKm:r,totalKm:e}}_dispatch(e,t){let{points:i,totalDistance:r,totalDuration:s,speed:n,cumKm:a,totalKm:o}=this._computeDistances(),l=t?{x:0,y:0,lat:t.lat,lon:t.lon,id:t.id}:null;if(l){let u=this._getPixelForWaypoint(t);u&&(l.x=u[0],l.y=u[1])}let h=null;this.boat&&this.waypoints.length>=2?(this.boat.distanceKm>o&&(this.boat.distanceKm=o),h=this._computeBoatPayload(a),this._renderBoat(h)):this.boat&&this.boatDiv&&(this.boatDiv.style.display="none"),this._boatPayloadCache=h,this.mapjs.onRoutingChange.dispatch({points:i,latest:l,totalDistance:r,totalDuration:s,speed:n,selectedId:this.selectedId,action:e,boat:h})}_computeBoatPayload(e){if(!this.boat||this.waypoints.length<2)return null;let t=VD(this.waypoints,this.boat.distanceKm,e);if(!t)return null;let i=this.speedKnots*1.852;return{distance:{km:ah(t.distanceKm),nm:ah(t.distanceKm*Nu)},time:ah(i>0?t.distanceKm/i*60:0),lat:t.lat,lon:t.lon,heading:t.heading}}_renderBoat(e){if(!e){this.boatDiv&&(this.boatDiv.style.display="none");return}if(!this.boatDiv){if(this._ensureContainer(),!this.container)return;this.boatDiv=document.createElement("div"),this.boatDiv.className="routing-boat",this.container.appendChild(this.boatDiv)}let t=ms.getBoatSVG();t!==this._lastBoatSvg&&(this.boatDiv.innerHTML=t,this._lastBoatSvg=t),this._updateBoatPixel(e)}_updateBoatPixel(e){let t=ue.openLayerMap;if(!this.boatDiv||!t||!e)return;if(this._hidden){this.boatDiv.style.display="none";return}let i=t.getPixelFromCoordinate([e.lon,e.lat]);if(!i){this.boatDiv.style.display="none";return}let r=t.getSize();if(!r)return;let[s,n]=r,[a,o]=i;if(a<-50||a>s+50||o<-50||o>n+50)this.boatDiv.style.display="none";else{this.boatDiv.style.display="block",this.boatDiv.style.left=`${a}px`,this.boatDiv.style.top=`${o}px`;let l=ms.styles.boat?.anchor==="bottom"?"bottom":"center",h=l==="bottom"?"100%":"50%",u=l==="bottom"?"-100%":"-50%",d=e.heading+(ms.styles.boat?.headingOffset??0);this.boatDiv.style.transformOrigin=`50% ${h}`,this.boatDiv.style.transform=`translate(-50%, ${u}) rotate(${d}deg)`}}addBoat(e={}){let{distance:t,time:i,unit:r,svg:s,...n}=e;return(s!==void 0||Object.keys(n).length>0)&&ms.setBoatStyle(s===void 0?n:{...n,svg:s}),this.boat||={distanceKm:0},t!=null||i!=null?this.setBoatPosition({distance:t,time:i,unit:r}):this._dispatch("boat",null),this.getBoatPosition()}removeBoat(){this.boat&&(this._cancelBoatAnimation(),this.boat=null,this.boatDiv&&=(this.boatDiv.remove(),null),this._lastBoatSvg=null,this._boatPayloadCache=null,this._dispatch("boat",null))}stopBoatAnimation(){this._cancelBoatAnimation()}_cancelBoatAnimation(){if(this._boatAnimation){try{this._boatAnimation.pause()}catch{}this._boatAnimation=null}this.boat&&Eu(this.boat)}_boatPixelDistance(e,t){let i=ue.openLayerMap,r=this._boatPayloadCache||this._computeBoatPayload(t),s=VD(this.waypoints,e,t);if(!i||!r||!s)return null;
2452let n=i.getPixelFromCoordinate([r.lon,r.lat]),a=i.getPixelFromCoordinate([s.lon,s.lat]);return!n||!a?null:Math.hypot(a[0]-n[0],a[1]-n[1])}_autoBoatMoveDuration(e,t){let i=this._boatPixelDistance(e,t);if(i!=null)return Math.max($D,Math.min(i/mse,WD));let r=Math.abs(e-(this.boat?.distanceKm??0));return Math.max($D,Math.min(r/30,WD))}_snapBoatTo(e,t,i,r,s){let n=this.setBoatPosition(e?{distance:t,unit:r}:{time:i,unit:r});return s?.(n),null}_shouldSnapBoatMove(e){if(e===0)return!0;if(e!=null)return!1;let t=performance.now(),i=this._lastBoatMoveAt!=null&&t-this._lastBoatMoveAt<gse;return this._lastBoatMoveAt=t,!!this._boatAnimation||i}animateBoatTo({distance:e,time:t,unit:i,duration:r,ease:s,onComplete:n}={}){if(!this.boat)return null;let a=e!=null;if(a===(t!=null))throw Error("animateBoatTo: exactly one of `distance` or `time` is required");let o;if(a){let p=Number(e);if(!Number.isFinite(p))return null;o=(i||"nm").toLowerCase()==="km"?p:p/Nu}else{let p=Number(t);if(!Number.isFinite(p))return null;let m=(i||"min").toLowerCase();o=(m==="h"?p*60:m==="s"?p/60:p)/60*(this.speedKnots*1.852)}let l=this._lastCumKm,h=l&&l.length?l[l.length-1]:0;if(o=Math.max(0,Math.min(o,h)),this._shouldSnapBoatMove(r))return this._snapBoatTo(a,e,t,i,n);this._lastBoatMoveAt=performance.now();let u=r??this._autoBoatMoveDuration(o,l),d=s??jD;this._cancelBoatAnimation();let c=this.boat;return this._boatAnimation=Ql(this.boat,{distanceKm:o,duration:u,ease:d,onUpdate:()=>{this.boat===c&&this._dispatch("boat",null)},onComplete:()=>{this._boatAnimation=null,this.boat===c&&n?.(this.getBoatPosition())}}),this._boatAnimation}playBoat({duration:e,ease:t=jD,from:i,to:r,fromUnit:s,toUnit:n,onComplete:a}={}){if(!this.boat)return null;let o=this._lastCumKm,l=o&&o.length?o[o.length-1]:0;if(l<=0)return null;let h=(c,p)=>{let m=Number(c);return Number.isFinite(m)?(p||"nm").toLowerCase()==="km"?m:m/Nu:null},u=i==null?null:h(i,s),d=r==null?l:h(r,n);return u==null?this.boat.distanceKm>=l-.001&&(this.boat.distanceKm=0):this.boat.distanceKm=Math.max(0,Math.min(u,l)),this.animateBoatTo({distance:d,unit:"km",duration:e,ease:t,onComplete:a})}setBoatPosition({distance:e,time:t,unit:i}={}){if(!this.boat)return null;this._cancelBoatAnimation();let r=e!=null;if(r===(t!=null))throw Error("routingSetBoatPosition: exactly one of `distance` or `time` is required");let s;if(r){let o=Number(e);if(!Number.isFinite(o))return this.getBoatPosition();s=(i||"nm").toLowerCase()==="km"?o:o/Nu}else{let o=Number(t);if(!Number.isFinite(o))return this.getBoatPosition();let l=(i||"min").toLowerCase();s=(l==="h"?o*60:l==="s"?o/60:o)/60*(this.speedKnots*1.852)}let n=this._lastCumKm,a=n&&n.length?n[n.length-1]:0;return this.boat.distanceKm=Math.max(0,Math.min(s,a)),this._dispatch("boat",null),this.getBoatPosition()}getBoatPosition(){return!this.boat||this.waypoints.length<2?null:this._computeBoatPayload(this._lastCumKm)}_normalizeCenterToRouteOptions(e){return typeof e=="boolean"?{center:e,padding:80}:{center:e?.center==null?!0:!!e.center,padding:e?.padding==null?80:e.padding}}_scheduleCenterToRoute(e=80){this.mapjs?.centerToRoute&&(this._centerToRoutePadding=e,!this._centerToRouteScheduled&&(this._centerToRouteScheduled=!0,requestAnimationFrame(()=>{this._centerToRouteScheduled=!1;let t=this._centerToRoutePadding??80;this._centerToRoutePadding=null;try{this.mapjs.centerToRoute(t)}catch(i){console.warn("[Routing] centerToRoute failed",i)}})))}async _geographicFallbackIfOutOfBounds(e,t){try{let i=Fl?.value,r=i?ue.getLayerByName(i):null;if(!r||(!Array.isArray(r.srcExtent)||r.srcExtent.length!==4)&&(r.updateExtent?.(),!Array.isArray(r.srcExtent)||r.srcExtent.length!==4))return;let[s,n,a,o]=r.srcExtent,l=t?.lon==null?null:qm(t.lon),h=t?.lat??null;if(l==null||h==null||!(l<s||l>a||h>o||h<n))return;let u=r?.data?.providers?.[0]?.model?.fallback;if(!u)return;if(r.data.providers&&r.data.providers.length>0){let d=r.data.providers.find(c=>c?.model?.name===u);d&&(d.isLoaded||await d.loadExtraData(),r.data.selectedProvider.value=d)}this.mapjs?.onGeographicFallback?.dispatch?.(u)}catch(i){console.warn("[RoutingBounds] geographic fallback failed",i)}}
2452add(e,t,i){let r=this._pixelToLonLat(e,t);if(!r)return null;let s=i??this.nextId++;s>=this.nextId&&(this.nextId=s+1);let n={id:s,lat:r.lat,lon:r.lon};return this.waypoints.push(n),this._render(),this._geographicFallbackIfOutOfBounds("add",n),this._dispatch("add",n),{lat:n.lat,lon:n.lon,id:n.id}}addPoints(e,t){let{center:i,padding:r}=this._normalizeCenterToRouteOptions(t),s=[],n=[];for(let a of e){let o=this._pixelToLonLat(a.x,a.y);if(!o)continue;let l=a.id==null?this.nextId++:a.id;l>=this.nextId&&(this.nextId=l+1);let h={id:l,lat:o.lat,lon:o.lon};this.waypoints.push(h),n.push(h),s.push({lat:h.lat,lon:h.lon,id:h.id})}if(s.length>0){this._render();for(let o of n)this._geographicFallbackIfOutOfBounds("add",o);let a=n[n.length-1];this._dispatch("add",a),i&&this._scheduleCenterToRoute(r)}return s}addPointsLatLon(e,t){let{center:i,padding:r}=this._normalizeCenterToRouteOptions(t),s=[],n=[];for(let a of e){if(a.lat==null||a.lon==null)continue;let o=a.id==null?this.nextId++:a.id;o>=this.nextId&&(this.nextId=o+1);let l={id:o,lat:a.lat,lon:a.lon};this.waypoints.push(l),n.push(l),s.push({lat:l.lat,lon:l.lon,id:l.id})}if(s.length>0){this._render();for(let o of n)this._geographicFallbackIfOutOfBounds("add",o);let a=n[n.length-1];this._dispatch("add",a),i&&this._scheduleCenterToRoute(r)}return s}_addFromCoordinate(e){let t=this._coordinateToLonLat(e);if(!t)return null;let i={id:this.nextId++,lat:t.lat,lon:t.lon};return this.waypoints.push(i),this._render(),this._geographicFallbackIfOutOfBounds("add",i),this._dispatch("add",i),{lat:i.lat,lon:i.lon,id:i.id}}remove(e){let t=this.waypoints.findIndex(o=>o.id===e);if(t<0)return;let i=this.waypoints[t],r=this._lastCumKm,s=this.waypoints.length,n=null;if(this.boat&&r&&s>=2){let o=this.boat.distanceKm;t===0&&o<=r[1]?n="start":t===s-1&&o>=r[s-2]&&(n="end")}let a=this.boat&&this._boatPayloadCache?{lat:this._boatPayloadCache.lat,lon:this._boatPayloadCache.lon}:null;if(this.waypoints=this.waypoints.filter(o=>o.id!==e),this.selectedId===e&&(this.selectedId=null),this.boat&&this.waypoints.length>=2){if(this._cancelBoatAnimation(),n==="start")this.boat.distanceKm=0;else if(n==="end")this.boat.distanceKm=1/0;else if(a){let o=cse(this.waypoints,a.lat,a.lon);o&&(this.boat.distanceKm=o.distanceKm)}}this._render(),this._dispatch("remove",i)}move(e,t,i){let r=this._pixelToLonLat(t,i);if(!r)return;let s=this.waypoints.find(n=>n.id===e);s&&(s.lat=r.lat,s.lon=r.lon,this._render(),this._dispatch("move",s))}setSpeed(e,t=2){let i=t;if(typeof i=="string"){let a=i.toLowerCase();i=a==="kmh"||a==="km/h"?1:a==="knots"||a==="knot"||a==="nd"?2:a==="m/s"||a==="ms"||a==="mps"?3:a==="mph"?4:2}let r=Number(e);if(!Number.isFinite(r))return;let s=this.speedKnots,n;switch(i){case 1:n=r/1.852;break;case 3:n=r*1.9438444924406049;break;case 4:n=r/1.1507794480235425;break;default:n=r;break}n!==s&&(this.speedKnots=n,this._dispatch("speed",null))}clear(){let e=this.waypoints.length>0;this.waypoints=[],this.selectedId=null,this.draggingId=null,this.nextId=1,this._cancelBoatAnimation(),this.boat=null,this.boatDiv&&=(this.boatDiv.remove(),null),this._lastBoatSvg=null,this._boatPayloadCache=null,this._render(),e&&this._dispatch("clear",null)}enable(e){if(e===this.enabled)return;this.enabled=e;let t=ue.openLayerMap;this._ensureMapMoveListener(),e?(ue.setVisibleLayer("routing",!0),this._ensureContainer(),t&&(this._olClickKey=t.on("singleclick",i=>this._onMapClick(i))),OS.add(this._onDown),BS.add(this._onMove),M1.add(this._onUp),this._attachPointerTracking(),window.addEventListener("blur",this._cancelDrag,{passive:!0}),window.addEventListener("pointercancel",this._cancelDrag,{passive:!0}),this._render()):(this._olClickKey&&t&&(t.un("singleclick",this._olClickKey.listener),this._olClickKey=null),OS.remove(this._onDown),BS.remove(this._onMove),M1.remove(this._onUp),this._detachPointerTracking(),window.removeEventListener("blur",this._cancelDrag),window.removeEventListener("pointercancel",this._cancelDrag),this._cancelDrag(),this.selectedId=null,this.draggingId=null,this._render())}_ensureMapMoveListener(){if(this._onMapMove)return;let e=ue.openLayerMap;e&&(this._onMapMove=()=>this._updateWaypointPositions(),e.on("postrender",this._onMapMove))}
2452_removeMapMoveListener(){if(!this._onMapMove)return;let e=ue.openLayerMap;e&&e.un("postrender",this._onMapMove),this._onMapMove=null}_attachPointerTracking(){window.addEventListener("pointerdown",this._trackPointerDown,{capture:!0,passive:!0}),window.addEventListener("pointerup",this._trackPointerUp,{passive:!0}),window.addEventListener("pointercancel",this._trackPointerUp,{passive:!0})}_detachPointerTracking(){window.removeEventListener("pointerdown",this._trackPointerDown,{capture:!0}),window.removeEventListener("pointerup",this._trackPointerUp),window.removeEventListener("pointercancel",this._trackPointerUp),this._activePointerIds.clear()}_trackPointerDown(e){this._activePointerIds.add(e.pointerId),this._activePointerIds.size>1&&this._cancelDragInternal()}_trackPointerUp(e){this._activePointerIds.delete(e.pointerId)}_isTouchPointer(e){return e?.pointerType==="touch"}_hitTestPixel(e,t){let i=null,r=40;for(let s of this.waypoints){let n=this._getPixelForWaypoint(s);if(!n)continue;let a=n[0]-e,o=n[1]-t,l=Math.sqrt(a*a+o*o);l<r&&(r=l,i=s)}return i}_onMapClick(e){if(this._hidden||this.draggingId)return;if(this.pendingDragId!=null&&(this.pendingDragId=null,this.pendingDragStart=null,this._restorePanIfNeeded()),this._ignoreNextClick)if(this._ignoreNextClickPixel){let[s,n]=this._ignoreNextClickPixel,[a,o]=e.pixel,l=a-s,h=o-n;if(Math.sqrt(l*l+h*h)>30)this._ignoreNextClick=!1,this._ignoreNextClickPixel=null,this._ignoreNextClickTimeout&&=(clearTimeout(this._ignoreNextClickTimeout),null);else{this._ignoreNextClick=!1,this._ignoreNextClickPixel=null,this._ignoreNextClickTimeout&&=(clearTimeout(this._ignoreNextClickTimeout),null);return}}else{this._ignoreNextClick=!1,this._ignoreNextClickTimeout&&=(clearTimeout(this._ignoreNextClickTimeout),null);return}let[t,i]=e.pixel,r=this._hitTestPixel(t,i);r?(this.selectedId=this.selectedId===r.id?null:r.id,this._rebuildWaypointDivs(),this._dispatch("select",r)):this.selectedId==null?this._addFromCoordinate(e.coordinate):(this.selectedId=null,this._rebuildWaypointDivs(),this._dispatch("select",null))}_onDownHandler(e){if(this._hidden||this._activePointerIds.size>1)return;let t=e.e;if(t?.pointerType==="touch"&&t.isPrimary===!1)return;let[i,r]=this._clientToMapPixel(e.x,e.y),s=this._hitTestPixel(i,r);s&&(this.pendingDragId=s.id,this.pendingDragStart={x:e.x,y:e.y},this._disablePanForRouting(),t&&!this._isTouchPointer(t)&&t.preventDefault())}_onMoveHandler(e){if(this._activePointerIds.size>1){this._cancelDragInternal();return}if(this.pendingDragId&&!this.draggingId&&this.pendingDragStart){let t=e.e;t&&!this._isTouchPointer(t)&&t.preventDefault();let i=e.x-this.pendingDragStart.x,r=e.y-this.pendingDragStart.y;Math.sqrt(i*i+r*r)>=this.dragStartThresholdPx&&(this.draggingId=this.pendingDragId)}this.draggingId&&(e.e&&e.e.preventDefault(),this.move(this.draggingId,e.x,e.y))}_onUpHandler(e){if(this.draggingId){let t=this.draggingId,i=this.waypoints.find(r=>r.id===t);i&&(this._geographicFallbackIfOutOfBounds("drag-end",i),this._dispatch("dragend",i)),this.draggingId=null,this._restorePanIfNeeded(),this.pendingDragId=null,this.pendingDragStart=null;return}if(this.pendingDragId!=null){let t=this.pendingDragId,i=this.waypoints.find(r=>r.id===t)||null;this.selectedId=this.selectedId===t?null:t,this._rebuildWaypointDivs(),this._dispatch("select",this.selectedId?i:null),this._ignoreNextClick=!0,this._ignoreNextClickPixel=this._clientToMapPixel(e.x,e.y),this._ignoreNextClickTimeout&&clearTimeout(this._ignoreNextClickTimeout),this._ignoreNextClickTimeout=setTimeout(()=>{this._ignoreNextClick=!1,this._ignoreNextClickTimeout=null,this._ignoreNextClickPixel=null},250),this._restorePanIfNeeded(),this.pendingDragId=null,this.pendingDragStart=null,e?.e&&e.e.preventDefault()}}_disablePanForRouting(){this._panWasDisabledByRouting||(this.previousPanState=kl.value,this._panWasDisabledByRouting=!0,kl.value=!1,ue.setPanEnabled(!1))}_restorePanIfNeeded(){this._panWasDisabledByRouting&&(this._panWasDisabledByRouting=!1,kl.value=this.previousPanState,ue.setPanEnabled(this.previousPanState))}_cancelDragInternal(){this.draggingId==null&&this.pendingDragId==null||(this.draggingId=null,this.pendingDragId=null,this.pendingDragStart=null,this._restorePanIfNeeded())}dispose(){this.enable(!1),this._removeMapMoveListener(),this._disposeSvgRoute(),N.onUp
2452date.remove(this._onUpdate),ms.removeStyles(),this.waypointDivs.forEach(({div:e})=>e.remove()),this.waypointDivs.clear(),this.segmentLabels.forEach(({div:e})=>e.remove()),this.segmentLabels=[],this._cancelBoatAnimation(),this.boatDiv&&=(this.boatDiv.remove(),null),this.boat=null,this._lastBoatSvg=null,this._boatPayloadCache=null,this.container&&this.container.parentNode&&this.container.parentNode.removeChild(this.container),this.container=null,this.waypoints=[]}};or.timeUnit="s";var Ps=new class{constructor(){this.logger=Id("[MapJS]"),this.logger.info("starting"),this.onParametersChange=new je,this.onOverlayChange=new je,this.onMapReady=new je,this.onMapLoading=new je,this.onMapMove=new je,this.onLoadingComplete=new je,this.onDeviceLost=new je,this.onPreloadCompleted=new je,this.onModelChange=new je,this.onGeographicFallback=new je,this.onChronologicFallback=new je,this.onLayerSelected=new je,this.onProviderSelected=new je,this.onRunSelected=new je,this.onError=new je,this.onZoom=new je,this.onPan=new je,this.onMarkerClick=new je,this.onMarkerHover=new je,this.onPickerValueChange=new je,this.onRoutingChange=new je,this.onBeforeDispose=new je,this.store=qK,this.picker=null,this.currentDisplayedLayers=new Set,this.watchers=Wm(),this.onChronologicFallback.add(async e=>{Mi.value!=="screenshot"&&(Tn.value=e,await ue.setModel(e),this.onModelChange.dispatch({paramId:ue.paramId,newModel:e,type:1}))}),this.onGeographicFallback.add(async e=>{Mi.value!=="screenshot"&&(Tn.value=e,await ue.setModel(e),this.onModelChange.dispatch({paramId:ue.paramId,newModel:e,type:2}))}),window.MapJS=this,this.markerManager=new ose(this),this.inputManager=new lse(this),this.cookieManager=new hse(this),this.bookmarkManager=new nse(this),this.routingManager=new fse(this),this.statsOverlay=new sse({getZoom:()=>ue.view?.getZoom?.()}),this._pendingSetLayerCall=null,this._setLayerDebounceTimeout=null,this._lastSetLayerParams=null,this._isFirstLoad=!0,this._loader=null,this._loaderInstance=new i2,this._debugMode=window.location.search.includes("extra=map"),this.ROUTING_MODES={EDIT:"edit",DISPLAY:"display",CLEAR:"clear"},this.routingMode="display",this._routingBoatEnabled=null}async init(e={}){this.options=e;let t=performance.now();if(this.log("Starting initialization..."),this._isFirstLoad&&!e.disableAutoLoader&&e.mode!=="screenshot"&&e.platform!=="web"&&(this._loader=this._loaderInstance.createLoader({spinnerColor:"#999",backgroundColor:"transparent"}),this._loader.show()),To.value=e.proxy,this.gpuDetectionPromise=qO().then(()=>{N.refreshPerformanceProfile(!1)&&(q.applyDisplaySettings(),N.onResize.dispatch(),q.scheduleRender()),this.log("GPU detection completed in background")}).catch(p=>{console.error("[MapJS] GPU detection failed:",p)}),e={model:"default",env:"phl",publisher:"meteoconsultmarine",platform:"web",baseURL:"meteoconsult.fr",tilesURL:"https://static5.mclcm.net/images/dynmap/models",latlon:[48.8566,2.3522],zoom:4,cityDisplay:!1,defaultLayer:"",maxWrapX:2,proxy:null,domElement:null,cityThreejs:!1,mode:"user",pickerBehavior:"",pickerAppearance:"",...e},e.env=e.env.replace("prod","ws").replace("phl","phl-ws"),e.wsVersion=e.publisher==="lachainemeteo"?"fr/v4.1":"100/fr/v30",e.modelURL=e.modelURL||`https://${e.env}.${e.baseURL}/interactivemap/${e.publisher}/${e.platform}/fr/v3.0/map_engine/models`,this.log("Parameters URL:",decodeURIComponent(`https://${e.env}.${e.baseURL}/${e.publisher}/${e.platform}/${e.wsVersion}/interactivemap/parameters`)),e.parametersURL=e.parametersURL||decodeURIComponent(`https://${e.env}.${e.baseURL}/${e.publisher}/${e.platform}/${e.wsVersion}/interactivemap/parameters`),e.legendURL=e.legendURL||decodeURIComponent(`https://${e.env}.${e.baseURL}/${e.publisher}/${e.platform}/${e.wsVersion}/interactivemap/legends`),this.options=e,cg.setPublisher(e.publisher),await q.initRender(e),window.location.search.includes("stats")){let p=q.render.bind(q);q.lastRenderTime=0,q.render=async(...m)=>{let g=performance.now(),f=await p(...m);return q.lastRenderTime=performance.now()-g,f}}q.renderer.onDeviceLost=this.onDeviceLostHandler,Mi.value=e.mode,ou.value=e.maxWrapX||2,dw.value=e.modelURL,uI.value=e.parametersURL,dI.value=e.legendURL,cI.value=e.tilesURL,mI.value=e.cityThreejs??window.location.search.includes("cityThreejs"),bm.value=[e.domElement.offsetWidth,e.domElement.offsetHeight];let i=new URLSearchParams(window.location.search),r=i.get("pickerBehavior"),s=i.get("pickerAppearance"),n=i.get("pickerEnabled"),a=i.get("boatEnabled"),o=(e.pickerBehavior&&e.pickerBehavior.trim()||r&&r.trim()||"default").toLowerCase(),l=(e.pickerAppearance&&e.pickerAppearance.trim()||s&&s.trim()||"default").toLowerCase();e.platform==="web"&&Fs&&(o="centerXY",l="target"),cu.value=e.platform==="web",this.pickerBehavior=o,this.pickerAppearance=l;let h=performance.now(),u=wI(e.proxy);this.onMapLoading.dispatch(),ue.initMapOnly(e),e.domElement&&this.attachTo(e.domElement),await ue.initStaticLayersEarly(),this.setVisibleLayer("borders",!0),await u,this.log(`Models fetched in ${(performance.now()-h).toFixed(2)}ms`),await ue.initLayersAndComplete(),e.cityDisplay&&ue.setVisibleLayer("cities",!0),e.defaultLayer&&e.defaultLayer!=""&&ue.setVisibleLayer(e.defaultLayer,!0),e.mode==="screenshot"&&await this.setModel(gI),this.setTap(!1),e.dateTime&&this.setForecast(e.dateTime);let d=performance.now()-t;this.log(`Initialization complete in ${d.toFixed(2)}ms`,e),this.onMapReady.dispatch(),this._isFirstLoad&&this._loader&&(this._loader.hide(),this._loader=null,this._isFirstLoad=!1),window.location.search.includes("stats")&&this.statsOverlay.enable(),this.loading=-1,this.loadingCompleteTimeout=null;
2452let c=null;this.watchers.add(Oe,p=>{Yi.value&&p?(!c||c.value!==p.value||c.parameter!==p.parameter)&&(this.onPickerValueChange.dispatch(p),c={value:p.value,parameter:p.parameter}):c=p?{value:p.value,parameter:p.parameter}:null},{deep:!0}),this.watchers.add(Bi,p=>{this.loadingCompleteTimeout&&=(clearTimeout(this.loadingCompleteTimeout),null),p===0&&this.loading!==0&&(this.loadingCompleteTimeout=setTimeout(()=>{Bi.value===0&&this.onLoadingComplete.dispatch(),this.loadingCompleteTimeout=null},100)),this.loading=p}),_I.value=e.publisher,Mi.value!=="screenshot"&&setTimeout(()=>{this.bookmarkManager.addBookmarker()},4e3),this._initOptions=e,e.platform==="iphone"&&e.latlon&&e.publisher==="lachainemeteo"&&setTimeout(async()=>{try{let p=await this.addInitLocationMarker({iconUrl:"https://static5.mclcm.net/lcm2018/int/map/pin-spot-light-lcm.svg",iconSize:[30,40],iconAnchor:[15,40],className:"initLocationMarker"});p&&this.log("Auto-added init location marker:",p)}catch(p){this.log("Failed to auto-add init location marker:",p)}},1e3),e.publisher==="lachainemeteo"?Yi.value=!1:n?Yi.value=n==="true":Yi.value=!0,a==="true"?this._routingBoatEnabled=!0:a==="false"&&(this._routingBoatEnabled=!1),this.onRoutingChange.add(()=>this._syncRoutingBoat()),this._syncRoutingBoat()}async prepareMarker(e,t=!1){return this.markerManager.prepareMarker(e,t)}async addPreparedMarker(e){return this.markerManager.addPreparedMarker(e)}async addPreparedMarkers(e){return this.markerManager.addPreparedMarkers(e)}removePreparedMarker(e){return this.markerManager.removePreparedMarker(e)}getPreparedMarkerIds(){return this.markerManager.getPreparedMarkerIds()}updateGeolocationPinDisplay(){this.log("updateGeolocationPinDisplay called")}async clearPreparedMarkers(){return this.markerManager.clearPreparedMarkers()}static createLoader(e={}){return new i2().createLoader(e)}static createSimpleLoader(e={}){return new i2().createSimpleLoader(e)}setSavedBookmarkCookie(e){this.bookmarkManager.setSavedBookmarkCookie(e)}addGeolocationPin(e,t,i=null){return this.markerManager.addGeolocationPin(e,t,i)}hideGeolocationPin(){return this.markerManager.hideGeolocationPin()}showPickerTarget(){tc.value=!0}hidePickerTarget(){tc.value=!1}addBookmarker(){return this.bookmarkManager.addBookmarker()}getCookie(e){return this.bookmarkManager.getCookie(e)}resize(e,t){N.resize(e,t)}attachTo(e){if(this.log("attachTo",e),!e){console.error("MapJS: attachTo called with null or undefined domElement");return}if(!e.nodeType){console.error("MapJS: attachTo called with invalid domElement (not a DOM node)");return}this.picker?this.picker.setContainer(e):this.picker=new rse(e),this.observer&&this.detach(),this.observer=this.observer||new ResizeObserver(t=>{for(let i of t)N.resize(i.contentRect.width,i.contentRect.height),ue.openLayerMap?.updateSize()});try{e.appendChild(q.renderer.domElement),this.observer.observe(e),ue.openLayerMap?.updateSize()}catch(t){console.error("MapJS: Failed to attach to DOM element:",t)}}detach(){this.observer&&=(this.observer.disconnect(),null),this.log("detach")}async setVisibleLayer(e,t){await ue.setVisibleLayer(e,t),this.log("setVisibleLayer",e,t)}async setLayer({dateTime:e=null,datas:t}){this.log("setLayer",{dateTime:e,datas:t}),e&&(wo.value=String(e).split("+")[0]);for(let{id:r,model:s,overlay:n}of t){this.currentDisplayedLayers.has(r)||this.currentDisplayedLayers.add(r),Fl.value=r;let a=await ue.getOrCreateLayer(r);if(s&&a){let l=fI(s);sessionStorage.setItem("modelID",l),Tn.value=l,await a.setModel(l)}await this.setVisibleLayer(r,!0);let o=["particles","arrows","barbs","isobars"];if(n&&Array.isArray(n))for(let l of o){let h=n.includes(l);await this.setOverlayVisible(l,h)}else if(n)for(let l of o)await this.setOverlayVisible(l,l===n);else{let l=ue.getLayerByName(r)?.data?.useOverlayIsobars===!0;for(let h of o)h==="isobars"&&l||await this.setOverlayVisible(h,!1)}}let i=Array.from(this.currentDisplayedLayers).filter(r=>!t.some(s=>s.id===r));for(let r of i)await this.setVisibleLayer(r,!1),this.currentDisplayedLayers.delete(r);e&&await this.setForecast(e),ue.initPicker()}display(e){this.log("display",e),e.mode&&(Mi.value=e.mode),this.setLayer(e)}async setModel(e){let t=fI(e);t!==e&&this.log("setModel: screenshot mode, using",t,"instead of",e),sessionStorage.setItem("modelID",t),await ue.setModel(t),Tn.value=t,this.log("setModel",t)}setIsobarsSmooth(e){ym.value=e,this.log("setIsobarsSmooth",e)}setIsobarsWidth(e,t){lu.value=e,hu.value=t??e/2,this.log("setIsobarsWidth",e,t)}setIsobarsOpacity(e,t){Uy.value=e,Vy.value=t??e,this.log("setIsobarsOpacity",e,t)}setIsobarsColor(e,t){xm.value=e,vm.value=t??e,this.log("setIsobarsColor",e,t)}setIsobarsGradientColor(e,t){uu.value=e,du.value=t??e,this.log("setIsobarsGradientColor",e,t)}resetDefaultIsobars(){ym.value=3,lu.value=2.5,hu.value=1,Uy.value=.8,Vy.value=.5,xm.value=11184895,vm.value=11184895,uu.value=3355562,du.value=6711039,this.log("resetDefaultIsobars")}setForecast(e){e=String(e).split("+")[0],wo.value=e,ue.setForecast(e),this.log("setForecast",e)}isLayerVisible(e){let t=ue.isLayerVisible(e);return this.log("isLayerVisible",e,t),t}getLayerByName(e){return ue.getLayerByName(e)}setOverlayVisible(e,t){ue.setOverlayVisible(e,t),this.log("setOverlayVisible",e,t)}async showOverlay(e){this.log("showOverlay",e),await this.setOverlayVisible(e,!0)}async hideOverlay(e){this.log("hideOverlay",e),await this.setOverlayVisible(e,!1)}forecastDate(e,t){this.log("forecastDate",e,t)}play(e){this.log("play",e),e&&e.dateTime&&this.setForecast(e.dateTime);let t=e?.padding||0;ue.play(t)}pause(){this.log("pause"),ue.pause()}nextForecast(){this.logger.time("nextForecast total"),this.log("nextForecast"),ue.nextForecast(),this.logger.timeEnd("nextForecast total")}prevForecast(){this.logger.time("prevForecast total"),this.log("prevForecast"),ue.prevForecast(),this.logger.timeEnd("prevForecast total")}setSynchronizedAnimation(e){ue.animationSyncEnabled=e,this.log("setSynchronizedAnimation",e)}panTo(e,t,i=1200){this.log(`panTo (${e}, ${t})`),ue.view.animate({center:[t,e],duration:i})}fitToBounds(e,t={}){let i=o=>Math.max(Math.min(o,85.05112878),-85.05112878),r=null,s=null;if(Array.isArray(e)&&e.length===2&&e.every(Array.isArray)){let[[o,l],[h,u]]=e;r={lat:Math.max(l,u),lon:Math.min(o,h)},s={lat:Math.min(l,u),lon:Math.max(o,h)}}else if(e?.nw&&e?.se)r=e.nw,s=e.se;
2452else{this.logger.warn("fitToBounds: invalid bounds input",e);return}if(!ue?.view){this.logger.warn("fitToBounds: view is not ready");return}let n=[Math.min(r.lon,s.lon),i(s.lat),Math.max(r.lon,s.lon),i(r.lat)],a={padding:t.padding??[24,24,24,24],duration:t.duration??600};t.maxZoom!==void 0&&(a.maxZoom=t.maxZoom),t.minZoom!==void 0&&(a.minZoom=t.minZoom),this.log("fitToBounds",n,a),ue.view.fit(n,a)}zoomTo(e){this.log("zoomTo",e),ue.view.animate({zoom:e,duration:500})}updateZoom(e){this.log("updateZoom",e),this.zoomTo(this.zoom+e)}zoomIn(){this.log("zoomIn"),this.zoomTo(this.zoom+1)}zoomOut(){this.log("zoomOut"),this.zoomTo(this.zoom-1)}get zoom(){return ue.view.getZoom()}get onAnimationComplete(){return ue.onAnimationComplete}flyTo(e,t){this.log("flyTo",e,t),ue.view.animate({center:Jd([t,e]),duration:1200})}centerToRoute(e=80){this.log("centerToRoute",e);let t=this.routingManager.waypoints;if(t.length===0)return;let i=1/0,r=1/0,s=-1/0,n=-1/0;for(let l of t)l.lon<i&&(i=l.lon),l.lat<r&&(r=l.lat),l.lon>s&&(s=l.lon),l.lat>n&&(n=l.lat);let a=[i,r,s,n],o=typeof e=="number"?[e,e,e,e]:e;ue.view.fit(a,{padding:o,duration:1e3})}centerToRouteTopHalf(e=80){this.log("centerToRouteTopHalf",e);let t=this.routingManager.waypoints;if(t.length===0)return;let i=1/0,r=1/0,s=-1/0,n=-1/0;for(let u of t)u.lon<i&&(i=u.lon),u.lat<r&&(r=u.lat),u.lon>s&&(s=u.lon),u.lat>n&&(n=u.lat);let a=[i,r,s,n],o=ue.openLayerMap?.getSize?.()?.[1]??0,l=o>0?o/2:0,h;if(typeof e=="number")h=[e,e,l+e,e];else{let[u,d,c,p]=e;h=[u,d,l+c,p]}ue.view.fit(a,{padding:h,duration:1e3})}restrictBounds(e){this.log("restrictBounds",e)}preloadForecast(e){this.log("preloadForecast",e)}preloadTilesLevel(e){this.log("preloadTilesLevel",e)}onDeviceLostHandler=()=>{this.log("Device lost"),this.onDeviceLost.dispatch(),window.location.reload()};async screenshot(){return this.log("screenshot"),await q.screenshot()}get model(){return Tn.value}set model(e){this.setModel(e)}get panEnabled(){return kl.value}set panEnabled(e){if(typeof e!="boolean"){console.warn("panEnabled must be a boolean");return}this.log("panEnabled",e),kl.value=e,ue.setPanEnabled(!!e)}get zoomEnabled(){return Oy.value}set zoomEnabled(e){if(typeof e!="boolean"){console.warn("zoomEnabled must be a boolean");return}this.log("zoomEnabled",e),Oy.value=e,ue.setZoomInteractionsEnabled(!!e)}get pickerEnabled(){return Yi.value}set pickerEnabled(e){if(typeof e!="boolean"){console.warn("pickerEnabled must be a boolean");return}this.log("pickerEnabled",e),Yi.value=e}disablePicker(){Yi.value=!1}enablePicker(){Yi.value=!0}get pickerBehavior(){return ba.value}set pickerBehavior(e){let t=["default","centerxy","longpressxy","longpresslonlat","dragndropxy","dragndroplonlat","combinelonlat"],i=e.toLowerCase();if(!t.includes(i)){console.warn("pickerBehavior must be one of:",t.join(", "));return}this.log("pickerBehavior",i),ba.value=i}get pickerAppearance(){return Pl.value}set pickerAppearance(e){let t=["default","cross","target"],i=e.toLowerCase();if(!t.includes(i)){console.warn("pickerAppearance must be one of:",t.join(", "));return}this.log("pickerAppearance",i),Pl.value=i}get routingEnabled(){return xI.value}set routingEnabled(e){this.log("routingEnabled",e),xI.value=!!e,this.routingManager.enable(!!e)}routingAdd(e,t,i){return this.routingManager.add(e,t,i)}routingAddPoints(e,t){return this.routingManager.addPoints(e,t)}routingAddPointsLatLon(e,t){return this.routingManager.addPointsLatLon(e,t)}routingRemove(e){this.routingManager.remove(e)}routingMove(e,t,i){this.routingManager.move(e,t,i)}routingClear(){this.routingManager.clear()}_syncRoutingBoat(){if(this._routingBoatEnabled===null)return;let e=this.routingManager,t=e.waypoints.length>=2;if(this._routingBoatEnabled===!1){e.boat&&this.setRoutingBoat(!1);return}t&&(e.boat||this.setRoutingBoat(!0))}setRoutingBoat(e,t){return this.log("setRoutingBoat",e,t),this._routingBoatEnabled=e,e?this.routingManager.addBoat(t):(this.routingManager.removeBoat(),null)}routingSetBoatPosition(e){return this.log("routingSetBoatPosition",e),this.routingManager.setBoatPosition(e)}routingGetBoatPosition(){return this.routingManager.getBoatPosition()}routingBoatMoveTo(e){return this.log("routingBoatMoveTo",e),this.routingManager.animateBoatTo(e)}routingBoatPlay(e){return this.log("routingBoatPlay",e),this.routingManager.playBoat(e)}routingBoatStop(){this.log("routingBoatStop"),this.routingManager.stopBoatAnimation()}setRoutingSpeed(e,t){this.log("setRoutingSpeed",e,t),this.routingManager.setSpeed(e,t)}enableRouting(e){this.routingEnabled=e}setRoutingMode(e){if(!Object.values(this.ROUTING_MODES).includes(e))throw Error(`Invalid routing mode: ${e}. Expected 'edit', 'display', or 'clear'.`);switch(this.routingMode=e,e){case this.ROUTING_MODES.EDIT:this.pickerEnabled=!1,this.routingEnabled=!0;break;case this.ROUTING_MODES.DISPLAY:this.pickerEnabled=!1,this.routingEnabled=!1;break;case this.ROUTING_MODES.CLEAR:this.routingManager.clear(),this.pickerEnabled=!0,this.routingEnabled=!1;break}}setUnits(e){e==="m/s"||e==="nd"||e==="km/h"||e==="MPH"||e==="Bft"?e={speed:e.toLowerCase()}:e==="\xB0F"||e==="\xB0C"?e={temperature:e.toLowerCase()}:e==="m"||e==="ft"?e={height:e.toLowerCase()}:e==="mm"||e==="mm/h"?e={precipitation:e.toLowerCase()}:(e==="km"||e==="mi")&&(e={distance:e.toLowerCase()}),this.log("setUnits",e),jt.setPreferences(e);for(let[t,i]of Object.entries(e))vI.value[t]=i}setPickerLocation(e){this.log("setPickerLocation",e),au.value=!!e}setPickerStyle(e){this.log("setPickerStyle",e),cg.setCustomStyles(e)}setRoutingStyle(e){this.log("setRoutingStyle",e),ms.setCustomStyles(e)}setRoutingBoatStyle(e){this.log("setRoutingBoatStyle",e),ms.setBoatStyle(e)}setRoutingLineRenderer(e){this.log("setRoutingLineRenderer",e),this.routingManager.setRouteLineRenderer(e)}async pickerXY(e,t){if(!ue.lastLayer||["borders","cities","bluemarble","mapdatamarine","mapdataterrestre","markers","mask","radar"].includes(ue.lastLayer.toLowerCase()))return null;let i=ue.getLayerByName(ue.lastLayer);return i?await kD(i,e,t,!0):null}
2452async pickerLatLon(e,t){let i=ue.openLayerMap?.getPixelFromCoordinate([t,e]);return i?await this.pickerXY(i[0],i[1]):null}setTouchZoom(e){cw.value=!!e,this.log("setTouchZoom",e),ue.setTouchZoomEnabled(!!e)}setDoubleClickZoom(e){pw.value=!!e,this.log("setDoubleClickZoom",e),ue.setDoubleClickZoomEnabled(!!e)}setScrollWheelZoom(e){By.value=!!e,this.log("setScrollWheelZoom",e),ue.setScrollWheelZoomEnabled(!!e)}setBoxZoom(e){mw.value=!!e,this.log("setBoxZoom",e),ue.setBoxZoomEnabled(!!e)}setKeyboard(e){gw.value=!!e,this.log("setKeyboard",e),ue.setKeyboardEnabled(!!e)}setTap(e){fw.value=!!e,this.log("setTap",e)}dispose(){this.onBeforeDispose.dispatch(),this.log("dispose"),this._setLayerDebounceTimeout&&=(clearTimeout(this._setLayerDebounceTimeout),null),this._pendingSetLayerCall=null,this._lastSetLayerParams=null;let e=document.getElementById("overlay-test-panel");e&&document.body.removeChild(e);let t=document.getElementById("marker-test-panel");t&&document.body.removeChild(t),this.routingManager&&=(this.routingManager.dispose(),null),this.markerManager&&=(this.markerManager.dispose(),null),this.inputManager&&=(this.inputManager.dispose(),null),this.cookieManager=null,this.watchers.dispose(),this.loadingCompleteTimeout&&=(clearTimeout(this.loadingCompleteTimeout),null),this.statsDiv&&=(document.body.removeChild(this.statsDiv),null),this.updateStats&&=(N.onAfterUpdate.remove(this.updateStats),null),ue.dispose(),this.detach(),this.picker&&=(this.picker.dispose(),null),q.dispose(),N.dispose(),k1.dispose&&k1.dispose(),gt.dispose&&gt.dispose(),this.onParametersChange.removeAll(),this.onOverlayChange.removeAll(),this.onMapReady.removeAll(),this.onMapLoading.removeAll(),this.onLoadingComplete.removeAll(),this.onDeviceLost.removeAll(),this.onMapMove.removeAll(),this.onModelChange.removeAll(),this.onGeographicFallback.removeAll(),this.onChronologicFallback.removeAll(),this.onLayerSelected.removeAll(),this.onProviderSelected.removeAll(),this.onRunSelected.removeAll(),this.onError.removeAll(),this.onZoom.removeAll(),this.onPan.removeAll(),this.onMarkerClick.removeAll(),this.onMarkerHover.removeAll(),this.onPickerValueChange.removeAll(),this.currentDisplayedLayers.clear(),this.markerManager&&=(this.markerManager.dispose(),null),this.inputManager&&=(this.inputManager.dispose(),null),this.cookieManager&&=null,window.MapJS===this&&delete window.MapJS,window.mapJS===this&&delete window.mapJS}log(...e){this.logger.info(...e)}async waitForGPUDetection(){this.gpuDetectionPromise&&(this.log("Waiting for GPU detection to complete..."),await this.gpuDetectionPromise,this.log("GPU detection ready"))}getMarkersLayer(){let e=ue.getLayerByName("markers");if(!e){this._debugMode&&console.warn("MapJS: Markers layer not found. Attempting to create it...");try{if(this.setVisibleLayer("markers",!0),e=ue.getLayerByName("markers"),!e)return this._debugMode&&console.error("MapJS: Failed to create markers layer"),null}catch(t){return this._debugMode&&console.error("MapJS: Error creating markers layer:",t),null}}return this.log("MapJS: Markers layer found:",e),this.log("MapJS: Layer visible:",e.visible),this.log("MapJS: Layer data:",e.data),e.visible||(this.log("MapJS: Setting markers layer visible"),this.setVisibleLayer("markers",!0)),e}async addMarkers(e){this.log("addMarkers",e);let t=this.getMarkersLayer();if(!t){this._debugMode&&console.error("MapJS: Could not get markers layer");return}if(!t.data){this._debugMode&&console.error("MapJS: Markers layer data is not initialized");return}let i=t.data.markers||[];this.log("addMarkers: existing markers count:",i.length),this.log("addMarkers: new markers count:",e.length);let r=[],s=new Set;if(e.forEach(n=>{if(this.markerManager.findGeolocationMarkerAtCoordinates(n.lat,n.lon)){this.log("addMarkers: skipping marker at coordinates",n.lat,n.lon,"due to existing geolocation marker");return}i.some(a=>a.lat===n.lat&&a.lon===n.lon?this.markerManager.isGeolocationMarker(a)?(this.log("addMarkers: skipping marker at coordinates",n.lat,n.lon,"due to existing geolocation marker"),!0):(s.add(a),!0):!1)?this.log("addMarkers: skipping duplicate marker at coordinates",n.lat,n.lon):r.push(n)}),r.length>0?(t.data.markers=[...i,...r],this.log("addMarkers: added",r.length,"new markers (skipped",e.length-r.length,"duplicates/conflicts)")):this.log("addMarkers: all markers were duplicates or conflicts, ensuring existing markers are visible"),t.currentLayer){this.log("addMarkers: updating markers on layer, total markers:",t.data.markers.length);let n=t.data.objectLayer?.container?.children?.length>0;r.length>0&&(n&&i.length>0?await t.data.appendMarkers(r):await t.data.updateMarkers()),q&&q.scheduleRender&&q.scheduleRender()}else this.log("addMarkers: layer.currentLayer is null, cannot update markers")}removeMarkersByType(e){this.log("removeMarkersByType",e);let t=this.getMarkersLayer();t&&t.data&&t.data.removeMarkersByType(e)}async updateMarkers(){let e=this.getMarkersLayer();e&&e.data&&(await e.data.updateMarkers(),q&&q.scheduleRender&&q.scheduleRender())}removeMarkerById(e){this.log("removeMarkerById",e);let t=this.getMarkersLayer();t&&t.data&&(t.data.removeMarkerById(e),q&&q.scheduleRender&&q.scheduleRender())}removeMarkers(){this.log("removeMarkers");let e=this.getMarkersLayer();!e||!e.data||(e.data.markers=[],e.currentLayer&&(e.currentLayer.disposeResources(),e.data.init(e.currentLayer),q&&q.scheduleRender&&q.scheduleRender()))}setDragging(e,t=!1){this.log("setDragging",e,t),this.panEnabled=!!e,pI.value=!!t,t?ue.twoFingersInteraction():ue.restoreDefaultDragInteraction()}preloadCriticalResources(){this.log("deprecate preloadCriticalResources")}getCurrentForecastDate(){let e=Il.value;if(e){let i=this.getLayerByName(e);
2452if(i&&i.currentForecastDate&&i.currentForecastDate.value)return i.currentForecastDate.value.datetime}for(let[,i]of ue.layers)if(i&&i.currentForecastDate&&i.currentForecastDate.value)return i.currentForecastDate.value.datetime;let t=new Date;return`${t.getUTCFullYear()}-${String(t.getUTCMonth()+1).padStart(2,"0")}-${String(t.getUTCDate()).padStart(2,"0")}T${String(t.getUTCHours()).padStart(2,"0")}:${String(t.getUTCMinutes()).padStart(2,"0")}:00Z`}async showMarkers(e){if(e){let t=Array.isArray(e)?e:[e];this.log("showMarkers",t);let i=[],r=new Set;for(let s of t)if(typeof s=="string"){if(r.has(s)){this.logger.warn(`showMarkers: skipping duplicate marker ID ${s}`);continue}if(!this.markerManager.getPreparedMarkerIds().includes(s)){this.logger.warn(`showMarkers: marker ${s} not found`);continue}i.push(s),r.add(s)}else if(s&&typeof s=="object")if(s.latlng||s.lat&&s.lon){let n=s.latlng?s.latlng.lat:s.lat,a=s.latlng?s.latlng.lng:s.lon,o=this.markerManager.findMarkerAtCoordinates(n,a);if(o)this.log(`showMarkers: marker already exists at coordinates ${n}, ${a}, using existing ID: ${o}`),r.has(o)||(i.push(o),r.add(o));else{let l=await this.prepareMarker(s,!1);i.push(l),r.add(l),this.log(`showMarkers: prepared marker object with ID ${l}`)}}else this.logger.warn("showMarkers: invalid marker object - missing latlng or lat/lon properties");else this.logger.warn(`showMarkers: invalid item type - expected string (ID) or object (marker), got ${typeof s}`);i.length>0&&await this.addPreparedMarkers(i)}else{let t=this.markerManager.getPreparedMarkerIds();t.length>0?(this.log("showMarkers: no ids specified, showing all prepared markers (iOS compatibility)"),await this.addPreparedMarkers(t)):this.log("showMarkers: no ids specified and no prepared markers found")}}getMapJS(){return Ps}prepareAndShowMarker(e){let t=this.prepareMarker(e);return this.addPreparedMarker(t),this.log("prepareAndShowMarker",t),t}async prepareAndShowMarkers(e){let t=[];for(let i of e)t.push(await this.prepareMarker(i,!1));return await this.addPreparedMarkers(t),this.log("prepareAndShowMarkers",t),t}setAutoShowPreparedMarkers(e){this._autoShowPreparedMarkers=!!e,this.log("setAutoShowPreparedMarkers",e)}getAutoShowPreparedMarkers(){return this._autoShowPreparedMarkers}hasMarkerAtCoordinates(e,t){return this.markerManager.hasMarkerAtCoordinates(e,t)}getMarkerIdAtCoordinates(e,t){return this.markerManager.getMarkerIdAtCoordinates(e,t)}async addInitLocationMarker(e={}){if(this._initOptions&&this._initOptions.platform!=="iphone")return this.log("addInitLocationMarker: Skipping - not iPhone platform"),null;let t=this._initOptions?.latlon;if(!t||!Array.isArray(t)||t.length!==2)return this.log("addInitLocationMarker: No valid coordinates in init options"),null;let[i,r]=t;this.log("addInitLocationMarker: Using coordinates",r,i);let s=this.markerManager.findMarkerAtCoordinates(r,i);if(s)return this.log("addInitLocationMarker: Marker already exists at coordinates",r,i,"with ID:",s),s;try{this.setVisibleLayer("markers",!0),this.log("addInitLocationMarker: Ensured markers layer is visible");let n=this.getMarkersLayer();if(!n)return this.log("addInitLocationMarker: ERROR - Markers layer not found"),null;this.log("addInitLocationMarker: Markers layer found:",n.visible);let a={icon:window.L.icon({iconUrl:e.iconUrl||"https://static5.mclcm.net/lcm2018/int/map/pin-spot-light-lcm.svg",iconSize:e.iconSize||[25,36],iconAnchor:e.iconAnchor||[12,34],className:e.className||"initLocationMarker"}),...e},o=window.L.marker([r,i],a);this.log("addInitLocationMarker: Created leaflet marker with config:",a);let l=await this.prepareMarker(o,!0);return this.log("addInitLocationMarker: Prepared marker with ID:",l),q&&q.scheduleRender&&(q.scheduleRender(),this.log("addInitLocationMarker: Forced render update")),this.log("addInitLocationMarker: Created marker at init coordinates",r,i,"with ID:",l),typeof this.updateMarkerTestStatus=="function"&&(this.updateMarkerTestStatus(`Init location marker added: ${l}`),this.updateMarkerDebugInfo(`Added marker at init coordinates (${r}, ${i})`)),l}catch(n){return this.log("addInitLocationMarker: Error creating marker:",n),null}}
2452removeInitLocationMarker(){if(!this._initOptions?.latlon)return!1;let[e,t]=this._initOptions.latlon,i=this.markerManager.findMarkerAtCoordinates(e,t);return i?(this.removePreparedMarker(i),this.log("removeInitLocationMarker: Removed marker at init coordinates",e,t),!0):!1}hasInitLocationMarker(){if(!this._initOptions?.latlon)return!1;let[e,t]=this._initOptions.latlon;return this.markerManager.hasMarkerAtCoordinates(e,t)}addCustomMarker(e,t={}){if(!Array.isArray(e)||e.length!==2)return this.log("addCustomMarker: ERROR - coordinates must be [latitude, longitude] array"),null;let[i,r]=e;if(typeof i!="number"||typeof r!="number")return this.log("addCustomMarker: ERROR - coordinates must be numbers"),null;let s={iconUrl:t.iconUrl||null,iconSize:t.iconSize||[25,36],iconAnchor:t.iconAnchor||[12,34],className:t.className||"customMarker",type:"custom",color:t.color||16766720,...t};this.log("addCustomMarker: Adding marker at",i,r,"with options:",s),this.getMarkersLayer()||(this.log("addCustomMarker: ERROR - Markers layer not found, attempting to create it"),this.setVisibleLayer("markers",!0));let n={lat:i,lon:r,type:s.type,color:s.color,iconUrl:s.iconUrl,iconSize:s.iconSize,iconAnchor:s.iconAnchor,className:s.className},a=`custom_${Date.now()}_${Math.random().toString(36).substr(2,9)}`;return this._customMarkers||=new Map,this._customMarkers.set(a,{lat:i,lon:r,...s}),window._markerPixelScale||(window._markerPixelScale=3e3),this.addMarkers([n]),this.log("addCustomMarker: Successfully added marker at",i,r),a}removeCustomMarker(e){if(!this._customMarkers||!this._customMarkers.has(e))return this.log("removeCustomMarker: Marker not found:",e),!1;let t=this._customMarkers.get(e);this.log("removeCustomMarker: Removing marker at",t.lat,t.lon);let i=this.getMarkersLayer();if(i&&i.data&&i.data.markers){let r=i.data.markers.findIndex(s=>s.lat===t.lat&&s.lon===t.lon&&s.className===t.className);r!==-1&&(i.data.markers.splice(r,1),i.data.updateMarkers(),window.stage3d&&window.stage3d.scheduleRender&&window.stage3d.scheduleRender(),this.log("removeCustomMarker: Successfully removed marker:",e))}return this._customMarkers.delete(e),!0}clearCustomMarkers(){if(!this._customMarkers)return;let e=Array.from(this._customMarkers.keys());this.log("clearCustomMarkers: Removing",e.length,"custom markers"),e.forEach(t=>this.removeCustomMarker(t))}};window.mapJS=Ps,ase(Ps);export{Ps as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.