@mappedin/mappedin-js 6.30.0 → 6.32.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1381 @@
1
+ import{$ as Vt,$a as Tl,A as X,Aa as hl,Ab as Hl,B as Ie,Ba as So,Bb as Wl,C as xn,Ca as dl,Cb as Vl,D as Ht,Da as ul,Db as jl,E as Ve,Ea as ml,Eb as Zl,F as yo,Fa as pl,Fb as _e,G as Mi,Ga as fl,Gb as Xl,H as Ci,Ha as gl,Hb as oe,I as Xs,Ia as yl,Ib as Yl,J as Ys,Ja as bl,Jb as To,K as tt,Ka as Mt,Kb as Be,L as $s,La as wn,Lb as Eo,M as Wt,Ma as Tn,Mb as jt,N as Di,Na as En,Nb as Oi,O as qs,Oa as Mo,Ob as Y,Pa as ce,Pb as le,Q as Ks,Qa as vl,Qb as $,R as it,Ra as xl,S as Sn,Sa as Sl,T as wi,Ta as Ml,U as Mn,Ua as Cl,V as Js,Va as Pn,W as Qs,Wa as Dl,X as el,Xa as wl,Y as Cn,Ya as On,Z as tl,Za as In,_ as il,_a as Co,a as R,aa as ol,ab as El,b as se,ba as bo,bb as Ln,ca as Dn,cb as Pl,da as rl,db as Ol,ea as vo,eb as Il,f as Rs,fa as nl,fb as An,g as _s,ga as Ti,gb as Ll,h as Bs,ha as je,hb as Ct,i as bi,ia as xo,ib as Do,j as Fs,ja as ot,jb as Rn,k as mo,ka as rt,kb as Al,l as Gs,lb as Rl,m as Ws,mb as _n,n as Vs,nb as _l,o as xt,ob as Pi,p as js,pb as Bn,q as Zs,qb as wo,r as bn,rb as Bl,s as vn,sa as al,sb as Fn,t as he,tb as Fl,u as U,ub as Gl,v as Ut,va as sl,vb as kl,w as xi,wa as St,wb as zl,x as Si,xa as ll,xb as Nl,ya as Ei,yb as Ul,z as Q,za as cl}from"./chunk-SAPR7Z5M.js";import{i as so,l as lo,m as Ce,n as Ts,p as Es,q as co,r as Ps,x as Nt,y as du}from"./chunk-J5TYCDYA.js";import{$ as Ns,A as He,B as As,C as We,J as vi,K as ks,U as po,X as fo,Y as et,Z as zs,_ as go,a as un,aa as Us,b as Os,ba as Hs,c as ho,d as bt,e as Qe,f as mn,k as vt,l as pn,m as Is,n as Ls,o as uo,r as fn,v as gn,x as yn}from"./chunk-ZJEQSG7Y.js";import{B as zt,D as ws,E as dn,a as g,b as D,g as E,h as kt,i as yi,j as Je,k as ao,l as z,q as hn,r as Ms,s as Cs,t as Ds}from"./chunk-7B7J4IXM.js";import{c as cu,d as hu}from"./chunk-PWEV3AFA.js";g();g();globalThis.MappedinDebug||(globalThis.MappedinDebug={});globalThis.MappedinDebug.__idleCallbackInteractionState={isInteracting:!1,interactionCheckers:[],pendingCallbacks:[],registerInteractionChecker:function(n){this.interactionCheckers.push(n)},unregisterInteractionChecker:function(n){let e;for(let t=this.interactionCheckers.length-1;t>=0;t--)if(e=this.interactionCheckers[t],e===n){this.interactionCheckers.splice(t,1);break}},checkInteraction:function(){let n=!1;for(let e=0;e<this.interactionCheckers.length;e++)if(n=this.interactionCheckers[e](),n)return!0;return!1},addPendingCallback:function(n,e){this.pendingCallbacks.push({callback:n,timeoutId:e}),this.scheduleDeferredCheck()},scheduleDeferredCheck:function(){var n=this;this.checkTimeoutId||(this.checkTimeoutId=setTimeout(function e(){if(n.checkInteraction())n.checkTimeoutId=setTimeout(e,16);else{n.checkTimeoutId=null;var t=n.pendingCallbacks.slice();n.pendingCallbacks=[];let i;for(let o=0;o<t.length;o++)if(i=t[o],i&&i.callback)try{i.callback()}catch{}}},16))},removePendingCallback:function(n){let e;for(let t=this.pendingCallbacks.length-1;t>=0;t--)if(e=this.pendingCallbacks[t],e.timeoutId===n){this.pendingCallbacks.splice(t,1);break}}};globalThis.requestIdleCallback=globalThis.requestIdleCallback||function(n){var e=performance.now(),t,i=!1,o=function(){if(!i){i=!0;try{n({didTimeout:!1,timeRemaining:function(){return Math.max(0,50-(performance.now()-e))}})}catch{}}};return globalThis.MappedinDebug?.__idleCallbackInteractionState?.checkInteraction()?(t=Date.now()+Math.random(),globalThis.MappedinDebug.__idleCallbackInteractionState.addPendingCallback(o,t),t):(t=setTimeout(o,0),t)};globalThis.cancelIdleCallback=globalThis.cancelIdleCallback||function(n){clearTimeout(n),globalThis.MappedinDebug?.__idleCallbackInteractionState?.removePendingCallback(n)};g();g();(function(){typeof globalThis!="object"&&(Object.defineProperty(Object.prototype,"__magic__",{get:function(){return this},configurable:!0}),__magic__.globalThis=__magic__,delete Object.prototype.__magic__)})();var $l="data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAkGBwgHBgkICAgKCgkLDhcPDg0NDhwUFREXIh4jIyEeICAlKjUtJScyKCAgLj8vMjc5PDw8JC1CRkE6RjU7PDn/2wBDAQoKCg4MDhsPDxs5JiAmOTk5OTk5OTk5OTk5OTk5OTk5OTk5OTk5OTk5OTk5OTk5OTk5OTk5OTk5OTk5OTk5OTn/wgARCAIABAADAREAAhEBAxEB/8QAGwABAAMBAQEBAAAAAAAAAAAAAAECAwQFBgf/xAAWAQEBAQAAAAAAAAAAAAAAAAAAAQL/2gAMAwEAAhADEAAAAP3EAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAIAAAJAFAAAAAAAAAAAAAAAAAAAAAAAAABAgAAEgCgAAAAAAAAAAAAAAAAAAAABERLSM1zM4zXMzjMoUIqCCSSS8XNC9mpoaVomharWTQAAAAAAAAAAAAAAAAEREtIoZrnGZkucUKFStQQSTFixdNDStF0TWrmiWqbJoAAAAAAAAAAAAAIgiWkZy4HNLzHLXKcxzpzmFYmRkUKFSCCSSxcuampsbR0HSdK9R1R1HTZvWll0mlAAAAAAAAAAAIiKLnLjHNLynLXKcycxzmNYmJmUKFSCAWLFy5qamxvHQvSdJ0nVHUdFm1aparWKAjNWSKAAAAARBEtYzlyXnjmOSuM4U4q4jjOM5a5k5zAyMjOqFCCCCSSS5c0jU1NzoOk6pew7TtjuO1e0646jezWr2WSaUAAAAAECIqtZco55eY464zhTirhOI5Dks5jAwMTIzqhUqQASWLFzSNTY3Og6V646zsO2O47V7DrjqNzWy9nlZ1c0LlrLEk0EQQVipRczIyMU5q5F4U8+vOPOrgThOOuU5jAxMjMzKpUggigJiSSxY0XQ1Njc6TqjtO49CX0D0T0Y7l7E6JdzU1NEvViSalBAWIqVKLSMjIxOauM4U86vPPOrz04TjrkOYwMTIzKJQqQQCKmBJJYutzQ1Njc6TrOyO475fRPRPQjuXsToXWPn6kkkEkhCkEAgggqVMjlrzzzDy7PMPPrhOQ5jBMqoVIIIAAIAJAAJJJLFzWN16TsO49CPTPUl9Q9A6o1LFiSSSSQpCwQQCCCpVMjlrzzyzy7PMPPrhOM5kwM6zKlQQAAQASAASCxY0NI3XpOw7j0I9M9SX0z0DqjU+UqpQqVIBFgEyixJYuWLFDkrzE8o8yvOONOasipBAAAAAAAAAAABJJY2OiO1fQPUj1T0pewuVKlCCqQsBIUSSSSWLlyTM5K808pPLrzziTnrEqQQAAAAAAAAAAASSWNjojtX0D1I9VfSOuND4uzMzqhQqVIALEli5c1jUuQc1vnp5pwJzVmQQAAAAAAAAAAAAAASSaHTHevpHoHTFjMyM6zKlSpABJJcsaGkamhU5q88804E5qzIIAAAAAAAAAAAAAAJJNDpjvX0j0Dqix8dVDMolSpAqCYElixc0XU0IMjlTlrIqAAAAAAAAAAAAAAAAAWNTqjqXYGZkZpUoQQRSFIsSXLroaGhBkcqctZFQAAAAAAAAAAAAAAAACxqdUdS7EngWQCAAQASACSSSwKlSCAAAAAAAAAAAAAAAAAACSSxYFSCCAACCQACSSSwKlSCAAAAAAAAAAAAAAAAAACSSxYGIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABIAJAJAJBAAIAIABAAAAAAAAAAAAAAAAAAAABIAJAJAJBAAIAIABAAAAJABAAAAAAAAAJBILEli5Y0LlzQ0Lly5csWLAkgFSChUoUMyhmUMyhQqVKkEEAEAAAAAAAAAkEgsSWLljQuXNDQuXLlyxYsCSAVIKFShQzKGZQzKFCpUqQe+ZmZkUKFCpUEEAAkksWLFzQ0NTU2NzY3Og3NzoNzc2NjU1NS5csSAQVKmZmZGRiYmBgYHOYGBgYGBiZGRkUMypUqQCAASSWLFi5oaGpqbG5sbnQbm50G5ubGxqampcuWJAIIKGZmZGRiYmBgYHOYGBgYGR+jmBzmBzmJiZGZQoQQSSWLmhqbGxudB0nSdJ1HSdR1HSdJ0G5qamhcsWJJJBIIIBUqVKFDIyMDA5jmOU5TlOY5TmOc5znMTEyMyhQggFixc0NTY2NzoOk6TpOo6TqOo6TpOg3NTU0LlixJJIJBAIKkFChQyMjAwOY5jlOU5jnP00yMTnOc5zAwMjMoVIJJLmhqbmx0HQdBubmxqXLkkgAAAAAAAAAAAAAEEFTMzMTEwOc5znMDAyMyhUgkkuaGpsbnQdB0G5ubGpcuSSAAAAAAAAAAAAAAQQVKGZ1gAEEEEFSCACSSxJJJIAAAAAAAAAAAAAAAAAAAAAAABBBBBUggAkkksSSSAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQCCpBUqQVIKggAkFiSSxYksSSSSAAAAAAAAAAAAAAAAAAQCCpBUqQVIKggAkFiSSxYksSWBIAAKFiQAAAAAAAAACCpUoUMzIyMzMzMyhQoVKkEEAgkEkklixYuXNDQ0NTQ1NC5cuWJAAAAAAAAAAIKlShQzMjIzMzMzKFChUqQQQCCQSSSWLFyxoXNDQ1NDU0LljUkkAAAAAAAAAAggggEEAgAAAAAAAAAAAAAEkgkkkkkAAAAAAAAAAgggggEAgAAAAAEgEAAAAAAEkgkkuAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADyyCCCCCCCCAQASCSQWJJJJLEkkkkkgkkEgkAEgAAEAAgEAggEEEEEEEFSCCCCCCAQASCSQWJJJJLEkkkkkgkkEgEgEgAAEAAgEAggEEEEEH5AQQQQVBBAIAAJBIJJJLEkkkkliSSSSSQSSCQSAAAQAQQCCCCCCCCCpBBBBBUEEEAgAAkEgkkksSSSSSWJJJJJJBJIJBIAABABBAIIIIIIIIKg/LCAQCACAAAACQCQSCQSASSASCQCQAAAAAAQCAQAQCAQAQQCACAAAACQCQSCQSASSASCQCQAAAAAAQCAQAQCAQfPgAAAAAAAAAAAAAAkAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAAAkAAAAAAAAAAAAAAgAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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bpu3bpum6bpum6bpum6bpu3TdN03bpum6bpum6bt03TdN03TdN03TdN03TdN03TduysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysmzKzKzKybMrMrMrMrMrMrMrMrMrMrMrMrMrMrMrMrMrMrMrMrMrMrMrMrMrMrMrMrMrMrMrMrMrMrMrMrMrMrMrMrMrMrMrMrMrMrMrMrMrJT+2lKUpSlKUpSlKUpSlKUpSlKUpSlKUpSlKUpSn9tKUpSlKUpSlKUpSlKUpSlKUpSlKUpSlKUpT/wDrA//EAB0RAAMBAAMBAQEAAAAAAAAAAAABERIwQFAgkMD/2gAIAQIBAT8A/COlKioqKioqKi+zSoqKioqL59Ro0aKyvpVlZWaNFXiVGkaNFZWV9CsrNGjRpFXepo0V8c69Zo0u1pGilfVnJWaNF+NFXNUaNFfmU0aReamkaNPzNM19VlZWaKysrK/XrKzTNGjRWaKyv+u0/8QAHREBAQACAQUAAAAAAAAAAAAAEQBAUCAQITCQwP/aAAgBAwEBPwD1NkRER07eYiIiNMRERGARERGgIiNAREZRERoCIjiYBERqiIwiI1REcCIiIiIjbkREREREfXZ//9k=";import{MathUtils as us,DirectionalLight as Fb,AmbientLight as Gb,Mesh as kb,MeshBasicMaterial as zb,PlaneGeometry as Kd,Object3D as Jd,PerspectiveCamera as Qd,Scene as Nb,Vector2 as ds,Vector3 as Ye,Raycaster as Ub,Camera as Hb,Box3 as eu,Frustum as Wb,Matrix4 as Vb,BatchedMesh as jb,EquirectangularReflectionMapping as Zb}from"three";g();var Gn=class n extends Error{name="AssertionError";constructor(e){super(e),Error.captureStackTrace&&Error.captureStackTrace(this,n)}};function ql(n,e){if(n==null){let t;e?.customMessage?t=e.customMessage:t=`Expected ${e?.valueName?`'${e.valueName}'`:"value"} to be defined, but received ${n}`;let i=e?.errorClass||Gn,o=new i(t);throw e?.captureStackTrace!==!1&&Error.captureStackTrace&&Error.captureStackTrace(o,ql),o}}function kn(n,e,t){if(ql(n),n?.type!==e){let i=`Expected type ${e} but got ${n?.type}`;throw new Error(t??i)}}g();import{Color as zn,WebGLRenderer as mu}from"three";var Po=class{backgroundAlpha=1;backgroundColor=new zn;width=0;height=0;options={};renderer;frameStats={drawCalls:0,triangles:0,lines:0,points:0};constructor(e){try{if(this.options=e,He()){this.renderer={setSize:()=>{},state:{reset:()=>{}},properties:{get:()=>{}},getSize:()=>We(),getDrawingBufferSize:()=>We(),getClearAlpha:()=>1,getClearColor:()=>new zn,autoUpdate:!0,shadowMap:{autoUpdate:!0},getContext:()=>({getContextAttributes(){return{alpha:!0,antialias:!1,depth:!0,stencil:!1}},isContextLost:()=>!1,createBuffer:()=>({}),deleteBuffer:()=>{},bindBuffer:()=>{},bufferData:()=>{},readPixels:()=>{},fenceSync:()=>({}),clientWaitSync:()=>37146,deleteSync:()=>{},getBufferSubData:()=>{},PIXEL_PACK_BUFFER:35051,STREAM_COPY:35042,RGBA:6408,UNSIGNED_BYTE:5121,SYNC_GPU_COMMANDS_COMPLETE:37143,SYNC_FLUSH_COMMANDS_BIT:1,TIMEOUT_EXPIRED:37147,WAIT_FAILED:37149,ALREADY_SIGNALED:37146,CONDITION_SATISFIED:37148}),setRenderTarget:()=>{},setClearColor:()=>{},clear:()=>{},render:()=>{},clearStencil:()=>{},clearDepth:()=>{},domElement:document.createElement("canvas"),capabilities:{isWebGL2:!0,maxTextureSize:16384}};let{width:t,height:i}=We();this.renderer.domElement.style.width=`${t}px`,this.renderer.domElement.style.height=`${i}px`,Object.defineProperty(this.renderer.domElement,"clientWidth",{configurable:!0,get:()=>We().width}),Object.defineProperty(this.renderer.domElement,"clientHeight",{configurable:!0,get:()=>We().height})}else this.renderer=new mu({canvas:e.canvas,alpha:e.alpha||!1,stencil:!0,antialias:typeof e.antialias=="boolean"?e.antialias:!0,powerPreference:"high-performance",preserveDrawingBuffer:!0}),this.renderer.localClippingEnabled=!0;this.backgroundColor=new zn(e.backgroundColor??"#ffffff"),this.backgroundAlpha=e.backgroundAlpha??1}catch(t){E.error(t),e.onWebGLRendererError&&e.onWebGLRendererError(t)}this.domElement()?.addEventListener("webglcontextlost",this.handleWebGLContextLost),this.domElement()?.addEventListener("webglcontextrestored",this.handleWebGLContextRestored),this.domElement()?.addEventListener("webglcontextcreationerror",this.handleWebGLContextCreationError),this.domElement()&&(this.domElement().style.zIndex="1")}destroy(){this.renderer&&this.renderer.dispose?.(),this.domElement()?.removeEventListener("webglcontextlost",this.handleWebGLContextLost),this.domElement()?.removeEventListener("webglcontextrestored",this.handleWebGLContextRestored),this.domElement()?.removeEventListener("webglcontextcreationerror",this.handleWebGLContextCreationError)}enabledLayers=new Set([0,1]);matricesUpdatedThisFrame=!1;startFrame(){this.matricesUpdatedThisFrame=!1}updateMatricesIfNeeded(e){this.matricesUpdatedThisFrame||(e.updateMatrixWorld(),this.matricesUpdatedThisFrame=!0)}renderScene(e,t){this.renderer&&(this.updateMatricesIfNeeded(e),this.renderer.render(e,t))}renderFullScene(e,t,i=!0){if(this.renderer){this.renderer.state.reset(),this.updateMatricesIfNeeded(e),this.renderer.clearStencil(),this.renderer.setRenderTarget(null),this.renderer.autoClear=!1,t.layers.disableAll();for(let a of this.enabledLayers.values())t.layers.enable(a);this.renderer.render(e,t);let o=this.frameStats,r=this.renderer.info?.render;if(o.drawCalls=r?.calls??0,o.triangles=r?.triangles??0,o.lines=r?.lines??0,o.points=r?.points??0,i){this.renderer.clearDepth(),t.layers.disableAll(),t.layers.enable(Q.ALWAYS_ON_TOP_PATHS),this.renderer.render(e,t);let a=this.renderer.info?.render;a&&(o.drawCalls+=a.calls,o.triangles+=a.triangles,o.lines+=a.lines,o.points+=a.points)}this.renderer.clearStencil(),this.renderer.state.reset()}}clear(){this.renderer&&(this.renderer.setClearColor(this.backgroundColor,this.backgroundAlpha),this.renderer.clear())}setBufferSize(e,t){D.env.NODE_ENV==="test"||!this.renderer||(this.width=e,this.height=t,this.renderer.setSize(e,t,!1))}setBackgroundColor(e,t){this.backgroundColor=e,this.backgroundAlpha=t}domElement(){return this.renderer?.domElement}handleWebGLContextCreationError=e=>{this.options.onWebGLContextCreationError?.(e)};handleWebGLContextLost=e=>{e.preventDefault(),this.options.onWebGLContextLost?.(e)};handleWebGLContextRestored=e=>{this.options.onWebGLContextRestored?.(e)}};g();g();import{Mesh as Fu,Raycaster as Gu,Scene as Wx,Vector2 as ku}from"three";g();g();var Oo=class{type;event;constructor(e){this.type=0,this.event=e}get timestamp(){return this.event.timeStamp}},Io=class{taps=[];add(e){this.lastPointerDown&&e.timestamp-this.lastPointerDown.timestamp<50?this.lastPointerDown.type=1:this.taps.push(e)}get lastPointerDown(){return this.taps.length>=1?this.taps[this.taps.length-1]:void 0}get isSingleTapWithTwoFingers(){return this.isSingleTap&&this.lastPointerDown?.type===1}get isSingleTapWithOneFinger(){return this.isSingleTap&&this.lastPointerDown?.type===0}get isDoubleTapWithOneFinger(){return this.isDoubleTap&&this.taps[0]?.type===0&&this.taps[1]?.type===0}get isSingleTap(){return this.taps.length===1}get isDoubleTap(){return this.taps.length===2}discardOutsideOfWaitWindow(e){this.taps=this.taps.filter(t=>e-t.timestamp<300)}flush(){this.taps=[]}get _taps(){return this.taps}destroy(){this.flush()}};g();function Un(n){let e=new Set;for(let t of n){let i=t.object;for(;i.visible&&i.parent&&i.parent.visible===!0&&!e.has(i.parent);)i=i.parent,i instanceof $&&i.type==="group-container"&&i.visible&&i.components[0]&&e.add(i)}return Array.from(e)}g();import{Euler as Lx,InstancedMesh as wt,MathUtils as Zn,Mesh as Lu,Vector3 as Rx}from"three";g();g();import{Matrix4 as fu}from"three";var gu=new fu;function Ii(n,e){let t=[],i=e?.borrowIdentityPieces===!0;return n.scene.updateWorldMatrix(!0,!0),n.scene.traverse(o=>{let r=o;if(!("isMesh"in r)||r.isMesh!==!0)return;let a=i&&r.matrixWorld.equals(gu)?r.geometry:r.geometry.clone().applyMatrix4(r.matrixWorld),l=r.material,s=Array.isArray(l)?l[0].color?.clone():l.color?.clone();t.push({geometry:a,sourceMaterial:l,originalColor:s})}),t}g();import{InstancedMesh as wu}from"three";g();import{Matrix4 as yu,Vector3 as Ql}from"three";g();var Jl=`float interleavedGradientNoise(vec2 position) {
2
+ vec3 magic = vec3(0.06711056, 0.00583715, 52.9829189);
3
+ return fract(magic.z * fract(dot(position, magic.xy)));
4
+ }
5
+
6
+ // Compile-time sample count for loop unrolling (injected via material)
7
+ #ifndef PCF_SAMPLES
8
+ #define PCF_SAMPLES 4
9
+ #endif
10
+
11
+ // Poisson disk samples - only define what we need based on sample count
12
+ #if PCF_SAMPLES <= 4
13
+ const vec2 poissonDisk[4] = vec2[](
14
+ vec2(-0.94201624, -0.39906216),
15
+ vec2(0.94558609, -0.76890725),
16
+ vec2(-0.094184101, -0.92938870),
17
+ vec2(0.34495938, 0.29387760)
18
+ );
19
+ #elif PCF_SAMPLES <= 8
20
+ const vec2 poissonDisk[8] = vec2[](
21
+ vec2(-0.94201624, -0.39906216),
22
+ vec2(0.94558609, -0.76890725),
23
+ vec2(-0.094184101, -0.92938870),
24
+ vec2(0.34495938, 0.29387760),
25
+ vec2(-0.91588581, 0.45771432),
26
+ vec2(-0.81544232, -0.87912464),
27
+ vec2(-0.38277543, 0.27676845),
28
+ vec2(0.97484398, 0.75648379)
29
+ );
30
+ #else
31
+ const vec2 poissonDisk[16] = vec2[](
32
+ vec2(-0.94201624, -0.39906216),
33
+ vec2(0.94558609, -0.76890725),
34
+ vec2(-0.094184101, -0.92938870),
35
+ vec2(0.34495938, 0.29387760),
36
+ vec2(-0.91588581, 0.45771432),
37
+ vec2(-0.81544232, -0.87912464),
38
+ vec2(-0.38277543, 0.27676845),
39
+ vec2(0.97484398, 0.75648379),
40
+ vec2(0.44323325, -0.97511554),
41
+ vec2(0.53742981, -0.47373420),
42
+ vec2(-0.26496911, -0.41893023),
43
+ vec2(0.79197514, 0.19090188),
44
+ vec2(-0.24188840, 0.99706507),
45
+ vec2(-0.81409955, 0.91437590),
46
+ vec2(0.19984126, 0.78641367),
47
+ vec2(0.14383161, -0.14100790)
48
+ );
49
+ #endif
50
+
51
+ /**
52
+ * Samples the shadow map using PCF (Percentage Closer Filtering)
53
+ * Uses compile-time loop count for GPU optimization
54
+ * @param lightSpacePos Position in light space coordinates
55
+ * @param outDepthGap Output: average depth gap between receiver and caster (for self-shadow detection)
56
+ * @returns Visibility factor (1.0 = fully lit, 0.0 = fully shadowed)
57
+ */
58
+ float sampleShadowWithDepthGap(vec3 lightSpacePos, out float outDepthGap) {
59
+ float scaledTexelSize = (1.0 / shadowMapSize) * pcfSpread;
60
+ float currentDepth = lightSpacePos.z * depthRangeMax;
61
+
62
+ // Rotation for temporal stability
63
+ float noise = interleavedGradientNoise(gl_FragCoord.xy) * 6.283185;
64
+ float cosNoise = cos(noise);
65
+ float sinNoise = sin(noise);
66
+ mat2 rotation = mat2(cosNoise, -sinNoise, sinNoise, cosNoise);
67
+
68
+ float shadow = 0.0;
69
+ float totalDepthGap = 0.0;
70
+ float shadowSamples = 0.0;
71
+
72
+ // Compile-time unrolled loop - GPU can optimize this efficiently
73
+ for(int i = 0; i < PCF_SAMPLES; i++) {
74
+ vec2 offset = rotation * poissonDisk[i] * scaledTexelSize;
75
+ vec2 uv = clamp(lightSpacePos.xy + offset, 0.0, 1.0);
76
+
77
+ float sampledDepth = texture2D(shadowMap, uv).r;
78
+ float inShadow = step(sampledDepth + shadowBias, currentDepth);
79
+ shadow += inShadow;
80
+
81
+ // Track depth gap for shadow samples
82
+ if(inShadow > 0.5) {
83
+ totalDepthGap += currentDepth - sampledDepth;
84
+ shadowSamples += 1.0;
85
+ }
86
+ }
87
+
88
+ // Calculate average depth gap (0 if no shadow samples)
89
+ outDepthGap = shadowSamples > 0.0 ? totalDepthGap / shadowSamples : 0.0;
90
+
91
+ return 1.0 - shadow / float(PCF_SAMPLES);
92
+ }
93
+ `;function tc(){return{shadowMap:{value:null},lightMatrix:{value:new yu},cameraNear:{value:.1},cameraFar:{value:1e3},shadowBias:{value:.001},selfShadowThreshold:{value:bi},shadowOpacity:{value:0},baseColor:{value:new Ql},shadowMapSize:{value:1024},pcfSpread:{value:1},sunDir:{value:new Ql(0,0,-1)},normalBias:{value:.1},shadowEnabled:{value:!1},depthRangeMax:{value:1}}}var ec=Symbol("mappedin-shadow-receiver"),bu=`varying vec3 vMiShadowWorldPos;
94
+ `,vu=`
95
+ vec4 miShadowWorldPos = vec4(transformed, 1.0);
96
+ #ifdef USE_BATCHING
97
+ miShadowWorldPos = batchingMatrix * miShadowWorldPos;
98
+ #endif
99
+ #ifdef USE_INSTANCING
100
+ miShadowWorldPos = instanceMatrix * miShadowWorldPos;
101
+ #endif
102
+ vMiShadowWorldPos = (modelMatrix * miShadowWorldPos).xyz;
103
+ `,xu=`
104
+ uniform sampler2D shadowMap;
105
+ uniform mat4 lightMatrix;
106
+ uniform float cameraNear;
107
+ uniform float cameraFar;
108
+ uniform float shadowBias;
109
+ uniform float selfShadowThreshold;
110
+ uniform float shadowOpacity;
111
+ uniform vec3 baseColor;
112
+ uniform float shadowMapSize;
113
+ uniform float pcfSpread;
114
+ uniform vec3 sunDir;
115
+ uniform float normalBias;
116
+ uniform bool shadowEnabled;
117
+ uniform float depthRangeMax;
118
+ varying vec3 vMiShadowWorldPos;
119
+ `,Su=`
120
+ if (shadowEnabled) {
121
+ vec3 miFaceNormal = cross(dFdx(vMiShadowWorldPos), dFdy(vMiShadowWorldPos));
122
+ vec3 miShadowNormal = normalize(gl_FrontFacing ? miFaceNormal : -miFaceNormal);
123
+ float miNdl = max(dot(miShadowNormal, -sunDir), 0.0);
124
+ vec4 miShadowCoord = lightMatrix * vec4(vMiShadowWorldPos + miShadowNormal * normalBias, 1.0);
125
+ vec3 miProj = miShadowCoord.xyz / miShadowCoord.w;
126
+ if (all(greaterThanEqual(miProj, vec3(0.0))) && all(lessThanEqual(miProj, vec3(1.0)))) {
127
+ float miDepthGap;
128
+ float miShadow = 1.0 - sampleShadowWithDepthGap(miProj, miDepthGap);
129
+ float miSelf = 1.0 - smoothstep(0.0, selfShadowThreshold, miDepthGap);
130
+ miShadow *= mix(1.0, 1.0 - smoothstep(0.3, 0.7, miNdl), miSelf);
131
+ if (miShadow > 0.05) {
132
+ gl_FragColor.rgb = mix(gl_FragColor.rgb, baseColor * gl_FragColor.rgb, miShadow * shadowOpacity * 0.6);
133
+ }
134
+ }
135
+ }
136
+ `,Hn="#include <project_vertex>",Wn="#include <dithering_fragment>";function Lo(n,e){let t=n;if(t[ec]||t.isShaderMaterial)return;t[ec]=!0;let{uniforms:i,pcfSamples:o}=e,r=n.onBeforeCompile,a=n.customProgramCacheKey;n.onBeforeCompile=(l,s)=>{r.call(n,l,s),!(!l.vertexShader.includes(Hn)||!l.fragmentShader.includes(Wn))&&(l.vertexShader=bu+l.vertexShader.replace(Hn,`${Hn}
137
+ ${vu}`),l.fragmentShader=`#define PCF_SAMPLES ${o}
138
+ `+xu+Jl+`
139
+ `+l.fragmentShader.replace(Wn,`${Su}
140
+ ${Wn}`),Object.assign(l.uniforms,i))},n.customProgramCacheKey=()=>`${a.call(n)}|mi-shadow-receiver:${o}`,n.needsUpdate=!0}function Zt(n,e){e&&n.traverse(t=>{let i=t;if(i.isMesh)if(Array.isArray(i.material))for(let o of i.material)Lo(o,e);else i.material&&Lo(i.material,e)})}g();g();import{MeshStandardMaterial as Mu}from"three";var Dt=class extends Mu{isModelMaterial=!0;constructor(e){super(e)}};g();import{MeshPhysicalMaterial as Cu}from"three";var Li=class extends Cu{isModelMaterial=!0;constructor(e){super(e)}};g();import{MeshBasicMaterial as Du}from"three";var Ai=class extends Du{isModelMaterial=!0;constructor(e){super(e)}};g();function nt(n){return n.isMeshPhysicalMaterial===!0?new Li().copy(n):n.isMeshStandardMaterial===!0?new Dt().copy(n):n.isMeshBasicMaterial===!0?new Ai().copy(n):n.clone()}function ic(n){let e=nt(n);return e.color?.setRGB(1,1,1),e}function Vn(n,e,t){let i=new he;for(let o of Ii(n)){let r=Array.isArray(o.sourceMaterial)?o.sourceMaterial.map(l=>ic(l)):ic(o.sourceMaterial),a=new wu(o.geometry,r,e);a.count=0,a.frustumCulled=!1,a.layers.enable(X.SHOULD_CAST_SHADOWS),a.userData={entities:{},originalColor:o.originalColor},i.add(a)}return Zt(i,t),i}g();import{Color as Tu,InterleavedBufferAttribute as Eu,Matrix4 as Pu}from"three";var oc=new Pu,Ou=new Tu(1,1,1),Ao=class extends Eo{isModelBatch=!0;pieceCount;pieceGeometries;borrowed;pieceColors;constructor(e,t,i,o){let r=e.reduce((l,s)=>l+(s.geometry.getAttribute("position")?.count??0),0),a=e.reduce((l,s)=>l+(s.geometry.getIndex()?.count??0),0);super(e.length,r,a,t),this.pieceCount=e.length,this.pieceColors=e.map(l=>l.originalColor),this.borrowed=i;for(let l of e){let s=this.addInstance(this.addGeometry(l.geometry));this.setMatrixAt(s,oc)}this.setPieceColors(void 0),this.pieceGeometries=o?e.map(l=>l.geometry):[],this.perObjectFrustumCulled=!1,this.sortObjects=t.transparent,this.layers.enable(X.SHOULD_CAST_SHADOWS)}onBeforeRender(e,t,i,o,r,a){this.sortObjects=this.material.transparent,super.onBeforeRender(e,t,i,o,r,a)}setPieceColors(e){for(let t=0;t<this.pieceCount;t++)this.setColorAt(t,e??this.pieceColors[t]??Ou)}getPlacementForInstance(e){return e>=0&&e<this.pieceCount?0:-1}getPlacementSource(){return{geometries:this.pieceGeometries,matrix:oc}}dispose(){super.dispose(),this.material.dispose();for(let e of this.pieceGeometries)this.borrowed.has(e)||e.dispose();return this}};function jn(n,e,t){let i=t?.keepPlacementSource===!0,o=new he,r=new Map,a=Ii(n,{borrowIdentityPieces:!0}),l=new Set;n.scene.traverse(s=>{let c=s.geometry;c&&l.add(c)});for(let s of a){let c=Array.isArray(s.sourceMaterial)?s.sourceMaterial[0]:s.sourceMaterial,h=`${c.uuid}|${rc(s.geometry)}`,d=r.get(h);d?d.pieces.push(s):r.set(h,{source:c,pieces:[s]})}for(let{source:s,pieces:c}of r.values()){let h=nt(s);h.color?.setRGB(1,1,1);let d=new Ao(c,h,l,i);d.userData={entities:{},originalColor:c[0].originalColor},o.add(d)}return Zt(o,e),o}function rc(n){let e=Object.keys(n.attributes).sort().map(t=>{let i=n.getAttribute(t);return`${t}:${i.itemSize}:${i.normalized?1:0}:${Iu(i)}`});return e.push(`index:${n.getIndex()?1:0}`),e.join(",")}function Iu(n){return n instanceof Eu?`interleaved-${n.data.stride}-${n.data.array.constructor.name}`:n.array.constructor.name}var Au=[100,500,2e3,1e4];function Ri(n,e){return n.set(Zn.degToRad(e?.[0]??rt[0]),Zn.degToRad(e?.[1]??rt[1]),Zn.degToRad(e?.[2]??rt[2]))}function _i(n,e){return n.set(e?.[0]??ot[0],e?.[1]??ot[1],e?.[2]??ot[2])}function Bi(n){let e=n.components[0],t=n.components[1];t.opacity!=null&&t.opacity!==e.opacity&&(e.opacity=t.opacity);let i=e.mesh?.children[0]instanceof wt,o=e.meshContainer??e.mesh;if(o&&ko(o))Ru(o,t.color,t.material);else if(!i){let l=t.material,s=t.color;if(l||s){let c=Xn(s,l);e.mesh?.traverse(h=>{h instanceof Lu&&h.material&&(Array.isArray(h.material)?h.material.forEach(d=>{c[d.name]?(se(d.color,c[d.name].color),d.vertexColors=!1):s&&se(d.color,s)}):c[h.material.name]?(se(h.material.color,c[h.material.name].color),h.material.vertexColors=!1):s&&se(h.material.color,s))})}}let r=e.feature.geometry.coordinates[2]??0,a=(t.verticalOffset??0)+r;e.altitude!==a&&(e.altitude=a),t.visible!==e.visible&&(e.visible=t.visible),t.visibleThroughGeometry!==e.visibleThroughGeometry&&(e.visibleThroughGeometry=t.visibleThroughGeometry)}function Xn(n,e){let t={};if(e)for(let i in e)e[i].color&&(t[i]={color:e[i].color});if(n){let i=["Default","Fabric","Mpdn_Logo","CouchLogo"];for(let o of i)t[o]||(t[o]={color:n})}return t}function _o(n){n.traverse(e=>{e instanceof wt&&e.computeBoundingSphere()})}function nc(n,e,t){let i=t.elements;for(let o=0;o<16;o++)if(n[e+o]!==Math.fround(i[o]))return!0;return!1}function ac(n,e=Au){for(let t of e)if(t>n)return t;return n*2}function Yn(n){for(;n.children.length>0;){let e=n.children[0];if(e instanceof wt){if(e.geometry?.dispose(),Array.isArray(e.material))for(let t of e.material)t.dispose();else e.material&&e.material.dispose();e.customDepthMaterial?.dispose()}n.remove(e)}}function Bo(n){Yn(n),n.parent?.remove(n)}function Fo(n,e,t,i){let o=i||t?Xn(t,i):void 0;for(let r of n.children){if(!(r instanceof wt))continue;let a=Array.isArray(r.material)?r.material[0]?.name:r.material?.name,l=o?.[a],s=l?R(l.color):t?R(t):r.userData.originalColor;s&&(r.setColorAt(e,s),r.instanceColor&&(r.instanceColor.needsUpdate=!0))}}function Go(n,e){let t=n.userData?.entities;if(e!=null&&t){if(n.isModelBatch===!0){let i=n.getPlacementForInstance(e);return i>=0?t[i]:void 0}return t[e]}return n.userData?.entityId}function ko(n){return n.children[0]?.isModelBatch===!0}function Ru(n,e,t){let i=t||e?Xn(e,t):void 0;for(let o of n.children){let r=o;if(r.isModelBatch!==!0)continue;let a=i?.[r.material.name],l=a?R(a.color):e?R(e):void 0;r.setPieceColors(l),a&&r.material.vertexColors&&(r.material.vertexColors=!1,r.material.needsUpdate=!0)}}function Xt(n,e,t){return Vn(n,e,t)}function $n(n,e){let t=typeof e=="string"?R(e):e;n.traverse(i=>{if(i.userData[Ht]===!0)return;let o=i;"isMesh"in o&&o.isMesh===!0&&(Array.isArray(o.material)?o.material.forEach(r=>{"color"in r&&r.color.copy(t)}):"color"in o.material&&o.material.color.copy(t))})}function Ro(n,e,t=!1){n.userData.intrinsicOpacity==null&&(n.userData.intrinsicOpacity=n.opacity);let i=n.userData.intrinsicOpacity*e;if(!t||!n.transparent){let o=i<1;n.transparent!==o&&(n.transparent=o,n.needsUpdate=!0)}n.opacity=i}function qn(n,e,t=!1){n.traverse(i=>{if(i.userData[Ht]===!0)return;let o=i;if("isMesh"in o&&o.isMesh===!0)if(Array.isArray(o.material))for(let r of o.material)Ro(r,e,t);else Ro(o.material,e,t)})}function sc(n,e){n.traverse(t=>{let i=t;"isMesh"in i&&i.isMesh===!0&&(Array.isArray(i.material)?i.material.forEach(o=>{o.depthWrite=!e,o.depthTest=!e,e&&!o.transparent&&(o.transparent=!0,o.needsUpdate=!0)}):(i.material.depthWrite=!e,i.material.depthTest=!e,e&&!i.material.transparent&&(i.material.transparent=!0,i.material.needsUpdate=!0)))})}function Yt(n,e){n.traverse(t=>{if(t instanceof wt&&t.material)if(Array.isArray(t.material))for(let i of t.material)Ro(i,e);else Ro(t.material,e)})}function Kn(n){n.traverse(e=>{let t=e;if("isMesh"in t&&t.isMesh===!0){if(t.customDepthMaterial?.dispose(),t.isModelBatch===!0){t.dispose();return}t.geometry?.dispose(),Array.isArray(t.material)?t.material.forEach(i=>i.dispose()):t.material?.dispose()}})}function lc(n){n.traverse(e=>{e instanceof wt&&(e.geometry.dispose(),Array.isArray(e.material)?e.material.forEach(t=>t.dispose()):e.material?.dispose(),e.customDepthMaterial?.dispose())})}function Fe(n,e,t=!0){let i=t&&e!==0,o=!1;return n.traverse(r=>{if(!(r instanceof wt)&&!("isMesh"in r&&r.isMesh))return;let a=r.layers.isEnabled(X.SHOULD_CAST_SHADOWS);i&&!a?(r.layers.enable(X.SHOULD_CAST_SHADOWS),o=!0):!i&&a&&(r.layers.disable(X.SHOULD_CAST_SHADOWS),o=!0)}),o}var Fi=class extends z{raycaster=new Gu;state={hovered3DEntity:void 0,hovered2DEntities:new Set,hovered3DContainers:void 0,lastHover:void 0,interaction:{mouseDownStart:void 0,distanceFromMouseDown:void 0,isPanning:!1}};coreState;camera;worldPlane;_quadtree=new zs(new et(0,0,0,0));_container;lastPointerEvent;cursor="grab";touchesCount=0;isUserMovingCamera;constructor(e,t,i,o,r){super(),this.isUserMovingCamera=r,this.raycaster.layers.enableAll(),this.raycaster.layers.disable(1),this.camera=i,this._container=e,this.coreState=t,this.worldPlane=o,this._container.addEventListener("pointerdown",this.onPointerDown,{capture:!1,signal:this.signal}),this._container.addEventListener("pointermove",this.onPointerMove,{capture:!1,signal:this.signal}),this._container.classList.add("mappedin-interactive")}updateQuadtree(e){this._quadtree=e}setHovered3DEntityInteractionComponentDirty(){if(this.state.hovered3DEntity){let e=this.state.hovered3DEntity.components[2];e&&(e.dirty=!0)}}hasTouched=!1;onPointerMove=ao(e=>{e&&(e.preventDefault(),this.updateInteractionStateIfPanning(e),(e.pointerType!=="touch"||e.pointerType===void 0&&this.hasTouched)&&this.handleHover(e),this.handleCursor())},D.env.NODE_ENV==="test"?0:16,{leading:!0});tapsControl=new Io;getThreeDIntersectsFromXY(e){this.raycaster.setFromCamera(e,this.camera),this.raycaster.layers.enable(Q.GEOMETRY);for(let o of this._hitBoxes.entities){let r=o.userData?.__text3dBatch;r&&(o.updateMatrix(),o.matrixWorld.multiplyMatrices(r.matrixWorld,o.matrix))}let t=this.raycaster.intersectObjects(this._hitBoxes.entities,!0).filter(o=>(o.object?.name==="worldPlane"||o.object?.visible)&&!this.isNonInteractiveModel(o)),i=t.findIndex(o=>o.object?.name==="worldPlane");return i!==-1&&t.push(t.splice(i,1)[0]),t}isNonInteractiveModel(e){let t=Go(e.object,e.instanceId??e.batchId);if(t==null)return!1;let i=this.coreState.geometry3DMap.get(t);return i?.type==="model"&&i.components[2]==null}getGroupContainerIntersectsFromXY(e){let t=this.getThreeDIntersectsFromXY(e),i;return t!=null&&t.length>0&&(i=Un(t)),i}onPointerDown=e=>{e.target===this._container&&(this._container.addEventListener("pointerup",this.onPointerUp,{capture:!1,signal:this.signal}),this._container.addEventListener("pointercancel",this.onPointerUp,{capture:!1,signal:this.signal}),this.state.interaction.mouseDownStart={time:Date.now(),timestamp:e.timeStamp,offsetX:e.offsetX,offsetY:e.offsetY},this.lastPointerEvent=e,this.state.interaction.distanceFromMouseDown=0,this.state.interaction.isPanning=!1,this.handleCursor(),e.pointerType==="touch"&&(this.tapsControl.add(new Oo(e)),this.touchesCount=Math.max(0,this.touchesCount+1)),this.clearPressTimer(),!(this.touchesCount>1)&&(this.pressTriggered=!1,this.pressTimeout=window.setTimeout(()=>this.maybeFirePress(),500)))};clickTimeout=void 0;pressTimeout=void 0;pressTriggered=!1;clearPressTimer(){this.pressTimeout!=null&&(clearTimeout(this.pressTimeout),this.pressTimeout=void 0)}maybeFirePress(){this.pressTimeout=void 0;let e=this.lastPointerEvent;if(!e||!this.state.interaction.mouseDownStart||this.state.interaction.isPanning||(this.state.interaction.distanceFromMouseDown??0)>15||this.touchesCount>1)return;let t=this.intersect(e);this.pressTriggered=!0,this.publish("long-press",{entity2D:t.entity2D,entity3D:t.entity3D,position:t.position,groupContainers:t.groupContainers,pointerEvent:{button:e.button}})}onPointerUp=e=>{this.clearPressTimer();let t=this.pressTriggered;this.pressTriggered=!1,this.tapsControl.discardOutsideOfWaitWindow(e.timeStamp),this.lastPointerEvent=e,this.touchesCount=Math.max(0,this.touchesCount-1),this.touchesCount===0&&(this._container.removeEventListener("pointerup",this.onPointerUp,{capture:!1}),this._container.removeEventListener("pointercancel",this.onPointerUp,{capture:!1})),this.updateInteractionStateIfPanning(e);let{mouseDownStart:i,isPanning:o}=this.state.interaction;!i||this.state.interaction.distanceFromMouseDown==null||(Date.now()<i.time+300&&(this.tapsControl.isSingleTapWithTwoFingers||this.state.interaction.distanceFromMouseDown<=15)&&(e.pointerType==="touch"?this.tapsControl.isSingleTapWithTwoFingers?(this.isUserMovingCamera()||this.publish("singletap-with-twofinger",e),this.flush()):this.tapsControl.isSingleTapWithOneFinger&&this.touchesCount===0?(this.clickTimeout&&clearTimeout(this.clickTimeout),this.clickTimeout=window.setTimeout(()=>{this.handleClick(e),this.flush()},300)):this.tapsControl.isDoubleTapWithOneFinger&&(this.publish("doubletap-with-onefinger",e),this.flush()):!t&&!o&&this.handleClick(e)),this.state.interaction.mouseDownStart=void 0,this.state.interaction.distanceFromMouseDown=void 0,this.state.interaction.isPanning=!1,this.handleCursor())};flush(){this.tapsControl.flush(),this.clickTimeout!=null&&(clearTimeout(this.clickTimeout),this.clickTimeout=void 0),this.clearPressTimer()}handleHover(e){let t=e||this.lastPointerEvent;if(t?.pointerType==="touch"||this.state.interaction.mouseDownStart||!t||this.isUserMovingCamera())return;let{entity3D:i,entity2D:o,position:r,groupContainers:a}=this.intersect(t);(this.detect3DEntityHover(i)||this.detect2DEntityHover(o)||this.detect3DContainerHover(a))&&(this.state.hovered3DEntity=i,this.state.lastHover=i,this.state.hovered2DEntities=new Set(o.map(l=>l.id)),this.state.hovered3DContainers=a,this.publish("hover",{entity2D:o,entity3D:this.state.hovered3DEntity,position:r,groupContainers:a})),this.handleCursor()}handleCursor(){let e=!!(this.state.hovered3DEntity&&this.state.hovered3DEntity?.components[2]||this.state.hovered2DEntities.size>0),t=!!this.state.interaction.mouseDownStart,i=this.state.interaction.isPanning,o=zu(e,i,t);this.cursor!==o&&(this.cursor=o,o==="pointer"?this._container.classList.add("mappedin-interaction-hover"):this._container.classList.remove("mappedin-interaction-hover"))}detect2DEntityHover(e){if(e.length!==this.state.hovered2DEntities.size)return!0;for(let t=0;t<e.length;t++)if(!this.state.hovered2DEntities.has(e[t].id))return!0;return!1}handleClick(e){let t=this.intersect(e);this.publish("click",{entity2D:t.entity2D,entity3D:t.entity3D,position:t.position,groupContainers:t.groupContainers,pointerEvent:{button:e.button}})}dirty3D=!0;cachedHitBoxes={entities:[]};get _hitBoxes(){if(this.dirty3D){this.cachedHitBoxes.entities=[];let e;for(let t of this.coreState.geometry3DIdsInScene)if(e=this.coreState.geometry3DMap.get(t),e?.type==="geometry"||e?.type==="model"||e?.type==="path"||e?.type==="custom-geometry"||e?.type==="image"){let i=e.components[0];if(i instanceof Y&&i.pointerEventsPassThrough||e.type==="model"&&e.components[2]==null)continue;i.mesh&&!this.cachedHitBoxes.entities.includes(i.mesh)&&this.cachedHitBoxes.entities.push(i.mesh)}else if(e?.type==="text3d"){let i=e.components[0];if(i instanceof St&&i.textMesh&&e.components[2]){let o=i.textMesh;i.batchedText?(o.updateMatrix(),o.userData.__text3dBatch=i.batchedText,o.matrixWorld.multiplyMatrices(i.batchedText.matrixWorld,o.matrix)):o.updateMatrixWorld(!0),this.cachedHitBoxes.entities.includes(o)||this.cachedHitBoxes.entities.push(o)}}return this.dirty3D=!1,this.cachedHitBoxes.entities.push(this.worldPlane),this.cachedHitBoxes}return this.cachedHitBoxes}ndcPoint=new ku;intersect(e){let{offsetX:t,offsetY:i}=e,o=[t,i],a=this._quadtree.queryPoint(o).filter(f=>f.intersectsPoint(o));this.ndcPoint.x=t/this._container.clientWidth*2-1,this.ndcPoint.y=-(i/this._container.clientHeight)*2+1;let l=this.getThreeDIntersectsFromXY(this.ndcPoint),s=[],c=[],h=[],d;for(let f of l){if(f.object.name==="worldPlane"){d??=f;continue}if(f.object.name==="hole-fill-mesh"||!(f.object instanceof Fu)||f.object.material?.colorWrite===!1)continue;let y=Go(f.object,f?.instanceId??f?.batchId),C=y?this.coreState.geometry3DMap.get(y):void 0;if(C instanceof U){let S=C.components[0];if(S instanceof Y&&S.pointerEventsPassThrough)continue}let M=f.object.userData?.entityId;if(M){let T=this.coreState.geometry3DMap.get(M)?.components[7];if(T?.verticalOffset!=null&&f.point.z>T.verticalOffset)continue}h.push(f),f.object.material.depthTest===!1?s.push(f):c.push(f)}let u=s[0]??c[0]??void 0,m=u?.point??d?.point,v,b;if(u!=null){let f=Go(u.object,u?.instanceId??u?.batchId);v=f!=null?this.coreState.geometry3DMap.get(f):void 0,v?.components[2]&&(b=v)}let p=Un(h),x=[];for(let f of a)if(f?.userData?.entityId==="watermark")x.push({id:"watermark"});else{let y=this.coreState.geometry2DMap.get(f?.userData.entityId);y&&x.push(y)}return Nu(x),{entity2D:x,entity3D:b,position:m,groupContainers:p.length>0?p:void 0}}detect3DEntityHover(e){return this.state.lastHover!==e&&(this.state.lastHover&&cc(this.state.lastHover,!1,this.coreState),e&&cc(e,!0,this.coreState)),this.state.hovered3DEntity!==e}detect3DContainerHover(e){return!Ts(this.state.hovered3DContainers,e)}updateInteractionStateIfPanning(e){this.state.interaction.mouseDownStart&&(this.state.interaction.distanceFromMouseDown=Math.sqrt(Math.pow(e.offsetX-this.state.interaction.mouseDownStart.offsetX,2)+Math.pow(e.offsetY-this.state.interaction.mouseDownStart.offsetY,2)),!this.state.interaction.isPanning&&this.state.interaction.distanceFromMouseDown>15&&(this.state.interaction.isPanning=!0,this.clearPressTimer()))}getMouseRayIntersects(){return this.raycaster.intersectObjects([this.worldPlane],!1)}destroy(){this.clearPressTimer(),this._container.removeEventListener("pointerdown",this.onPointerDown,{capture:!1}),this._container.removeEventListener("pointermove",this.onPointerMove,{capture:!1}),this._container.removeEventListener("pointerup",this.onPointerUp,{capture:!1}),this._container.removeEventListener("pointercancel",this.onPointerUp,{capture:!1}),super.destroy()}debugPanel;enableDebug(){let e=document.createElement("div");e.style.position="absolute",e.style.top="0",e.style.right="0",e.style.backgroundColor="white",e.style.padding="10px",document.body.append(e),e.id="interaction-debug-panel",this.debugPanel=e,this.on("doubletap-with-onefinger",()=>{this.queueDebugMessage("doubletap-with-onefinger","#ffadad")}),this.on("singletap-with-twofinger",()=>{this.queueDebugMessage("singletap-with-twofinger","#ffd6a5")}),this.on("click",t=>{this.queueDebugMessage(`CLICK
141
+ 3D: ${t.entity3D?.id}
142
+ 2D: ${t.entity2D?.map(i=>i.id).join(", ")}
143
+ Pos: ${t.position?.toArray().join(", ")}`,"#fdffb6")}),this.on("hover",t=>{this.queueDebugMessage(`HOVER
144
+ 3D: ${t.entity3D?.id}
145
+ 2D: ${t.entity2D?.map(i=>i.id).join(", ")}
146
+ Pos: ${t.position?.toArray().join(", ")}`,"#caffbf")})}get _state(){return this.state}queueDebugMessage(e,t){let i=document.createElement("pre");i.style.maxWidth="300px",i.style.transition="opacity 500ms cubic-bezier(0.4, 0, 0.2, 1)",i.style.backgroundColor=t,i.textContent=e,this.debugPanel?.prepend(i),setTimeout(()=>{i.style.opacity="0",setTimeout(()=>{i.remove()},500)},2500)}getCursor(){return this.cursor}};function cc(n,e,t){let i=n.components[2];i&&i.hover!==!0&&(i.hover=e?"user-interaction":!1,i.dirty=!0);let o=n.components[0].textMesh?.userData.entityId;if(!o)return;let r=t.geometry3DMap.get(o);r?.type==="text3d"&&(r.components[1].hoverByPolygon=e,r.components[1].dirty=!0)}function zu(n,e,t){return e?"grabbing":n?"pointer":t?"grabbing":"grab"}function Nu(n){if(n.length<=1)return;let e=[],t=[],i=[];for(let r=0;r<n.length;r++){let a=n[r];a.components?a.type==="marker"?e.push(a):t.push(a):i.push(a)}if(e.length>1){let r,a;e.sort((l,s)=>{r=l.components[0],a=s.components[0];let c=r.projection.y,h=a.projection.y;return c!==h?h-c:r.markerContainer.compareDocumentPosition(a.markerContainer)&Node.DOCUMENT_POSITION_FOLLOWING?1:-1})}if(t.length>1){let r=[];for(let a=0;a<t.length;a++){let l=t[a],s=l.components[0];r.push({entity:l,y:s.projection.y,idx:a})}r.sort((a,l)=>a.y!==l.y?l.y-a.y:l.idx-a.idx);for(let a=0;a<r.length;a++)t[a]=r[a].entity}let o=0;for(let r=0;r<e.length;r++)n[o++]=e[r];for(let r=0;r<t.length;r++)n[o++]=t[r];for(let r=0;r<i.length;r++)n[o++]=i[r]}g();g();import{Vector3 as ea,Euler as Wu,Scene as Vu,DoubleSide as ju,BatchedMesh as Zu,DirectionalLight as Xu,MeshStandardMaterial as Yu,Mesh as $u,Box3 as qu,BufferGeometry as Ku}from"three";import*as mc from"three/examples/jsm/utils/BufferGeometryUtils.js";g();import{BufferAttribute as zo,BufferGeometry as Uu,Matrix4 as Hu}from"three";var hc=new Hu;function Gi(n,e=!0){let t=new Uu,i=n.mesh?.geometry;if(!i||!n.batchedProps?.range)return;let o=n.batchedProps.range,r=o.start,a=o.count,l=i.getAttribute("position");if(l){let h=new Float32Array(a*3);for(let d=0;d<a;d++){let u=r+d;h[d*3]=l.array[u*3],h[d*3+1]=l.array[u*3+1],h[d*3+2]=l.array[u*3+2]}t.setAttribute("position",new zo(h,3))}let s=i.getAttribute("normal");if(s){let h=new Float32Array(a*3);for(let d=0;d<a;d++){let u=r+d;h[d*3]=s.array[u*3],h[d*3+1]=s.array[u*3+1],h[d*3+2]=s.array[u*3+2]}t.setAttribute("normal",new zo(h,3))}let c=i.getAttribute("uv");if(c){let h=new Float32Array(a*2);for(let d=0;d<a;d++){let u=r+d;h[d*2]=c.array[u*2],h[d*2+1]=c.array[u*2+1]}t.setAttribute("uv",new zo(h,2))}if(i.index){let h=i.index,d=new Uint32Array(a);for(let u=0;u<a;u++)d[u]=h.array[r+u];t.setIndex(new zo(d,1))}if(e&&n.instanceIndex!==-1&&Oi(n.mesh))try{n.mesh.getMatrixAt(n.instanceIndex,hc),t.applyMatrix4(hc)}catch(h){E.error(h)}return t}function dc(n,e,t){let i=Gi(n,!1);if(!i||!Oi(n.mesh))return;n.mesh.getMatrixAt(n.instanceIndex,t),n.mesh.deleteInstance(n.instanceIndex),n.mesh.optimize();let o=e.addGeometry(i);e.addInstance(o),e.setMatrixAt(o,t);let r=e.getGeometryIdAt(o),a=e.getGeometryRangeAt(r);return a&&n.batchedProps&&(n.batchedProps.range=a),i.dispose(),o}function uc(n,e){if(e===0)return;let t=n.getAttribute("position");for(let i=0;i<t.count;i++)t.setZ(i,t.getZ(i)+e);t.needsUpdate=!0}var ki=class{#e=null;#o;constructor(e){this.#o=e}getCurrentSceneGLTF=async e=>{let t={onlyVisible:!0,binary:!0,light:!0,scale:1,...e},i=await this.#r(),o=this.#n(t),r=await i.parseAsync(o,{trs:!1,maxTextureSize:1/0,onlyVisible:t.onlyVisible,binary:t.binary,scale:t.scale}),a;if(r instanceof ArrayBuffer)a=new Blob([r],{type:"application/octet-stream"});else{let l=JSON.stringify(r,null,2);a=new Blob([l],{type:"text/plain"})}return a};#n=e=>{let{scale:t,light:i,onlyVisible:o}=e,r=new Vu,a=new qu().setFromObject(this.#o.geometryScene);if(this.#a(this.#o.geometryScene,r,o),i){let l=new Xu(16777215,.3*Math.PI);l.position.set(0,Math.max(a.max.x,a.max.y)*t*.5,a.max.y*t*4),l.lookAt(0,0,-1),l.target.position.set(0,0,-1),l.add(l.target),r.add(l)}return r};async#r(){if(!this.#e){let{GLTFExporter:e}=await import("three/examples/jsm/exporters/GLTFExporter.js");this.#e=new e}return this.#e}#a=(e,t,i)=>{e.material&&e instanceof Zu&&this.#l(e).forEach(o=>t.add(o)),e.children.forEach(o=>{(!i||o.visible)&&this.#a(o,t,i)})};#s=(e,t,i)=>{let o=new Yu({color:R(e),metalness:0});return o.opacity=t,o.transparent=i,o};#l(e){let t=[],o=(e.userData?.entities?Object.values(e.userData?.entities):[]).map(l=>this.#o.geometry3DMap.get(l)),r=new Map;e.updateWorldMatrix(!0,!1);let a=new ea;return e.getWorldPosition(a),o.forEach(l=>{if(!l||!(l instanceof U))return;let s=l.components[1],c=l.components[2];if(!s.visible||s instanceof Be&&s.opacity===0||s instanceof Ti||s instanceof xo)return;let d=`${c?.hover?s.hoverColor||this.#o.hoverColor:s.color}-${s.opacity}-${Number(s.visible)}`;r.has(d)||r.set(d,[]),r.get(d)?.push(l)}),r.forEach((l,s)=>{let[c,h,d]=s.split("-"),u=l.reduce((p,x)=>{if(x.type==="custom-geometry")return p;let f=x.components[0];if("geometry"in f&&f.geometry instanceof Ku){let y=f.geometry.clone();uc(y,a.z),p.push(y)}else if(f instanceof Y&&f.batchedProps){let y=Gi(f);y&&(uc(y,a.z),p.push(y))}return p},[]);if(u.length===0){E.error("No geometries found for batched mesh");return}let m=this.#s(c,Number(h),e.material.transparent),v=mc.mergeGeometries(u,!0);if(!v){E.error("No merged geometry found for batched mesh");return}let b=new $u(v,m);b.position.copy(e.position),b.rotation.copy(e.rotation),b.scale.copy(e.scale),b.visible=!!d,this.#d(b.position,b.scale,b.rotation,b.quaternion),t.push(this.#h(b))}),t}#h=e=>{let{geometry:t,material:i,position:o,rotation:r,quaternion:a,scale:l}=e;if(!t?.isBufferGeometry)return e;let s=t.attributes.position,c=t.attributes.normal,h=t.attributes.uv;return this.#p(s,c),this.#d(o,l,r,a),h&&this.#t(h),i?.map&&t.type==="PlaneGeometry"&&(e.side=ju),e};#p=(e,t)=>{let i=new ea,o=new ea;for(let r=0;r<e.count;r++)i.fromBufferAttribute(e,r),this.#i(i),e.setXYZ(r,i.x,i.y,i.z),t&&(o.fromBufferAttribute(t,r),this.#i(o),t.setXYZ(r,o.x,o.y,o.z))};#i=e=>{let t=e.y;e.y=e.z,e.z=-t};#d=(e,t,i,o)=>{let r=e.y;e.y=e.z,e.z=-r;let a=t.y;if(t.y=t.z,t.z=a,i instanceof Wu)i.order="YXZ",i.set(i.x,i.y,i.z,i.order);else{let l=o.y;o.set(o.x,o.z,-l,o.w)}};#t=e=>{for(let t=0;t<e.count;t++){let i=e.getX(t),o=e.getY(t);e.setXY(t,i,o)}};destroy(){this.#e=null}};g();g();import{Shape as Ju,Path as Qu,ExtrudeGeometry as em}from"three";import*as pc from"three/examples/jsm/utils/BufferGeometryUtils.js";var tm="gray",im=.1,zi=100,ta=new _e.ClipperOffset;function Ni(n){let e=n.length;if(e<2)return e;let t=n[0],i=n[e-1];return t.x===i.x&&t.y===i.y?e-1:e}function ia(n,e){if(e<3)return 0;let t=0,i=0,o=0,r=0;for(let l=1;l<e;l++)n[l].x<n[t].x&&(t=l),n[l].y<n[i].y&&(i=l),n[l].x>n[o].x&&(o=l),n[l].y>n[r].y&&(r=l);let a=l=>l===t||l===i||l===o||l===r;for(let l=0;l<e;l++){let s=(l+e-1)%e;if(!a(l)&&!a(s))return l}for(let l=0;l<e;l++)if(!a(l))return l;return(t-(e>>1)+e)%e}function om(n,e){ta.Clear(),e/=2;let t=n.map(o=>({X:o.x*zi,Y:o.y*zi}));ta.AddPath(t,_e.JoinType.jtMiter,_e.EndType.etClosedPolygon);let i=new _e.Paths;return ta.Execute(i,e*zi),i.length?i.map(r=>r.map(a=>({x:a.X/zi,y:a.Y/zi}))):[n]}function No(n,e,t){let{color:i=tm,opacity:o=1,altitude:r=0,height:a=im}=t||{};Array.isArray(o)&&(o=1);let l={min:{x:1/0,y:1/0,z:r},max:{x:-1/0,y:-1/0,z:a+r},center:{x:0,y:0,z:(a+r)/2}},c=n.geometry.coordinates[0].map(m=>{let v=e(m[1],m[0]);return l.min.x=Math.min(l.min.x,v.x),l.min.y=Math.min(l.min.y,v.y),l.max.x=Math.max(l.max.x,v.x),l.max.y=Math.max(l.max.y,v.y),v});n.properties?.style?.edgeOffset!=null&&n.properties.style.edgeOffset!==0||n.properties?.image!=null?c=om(c,n.properties?.style?.edgeOffset||0):c=[c];let h=[];for(let m of c){let v=new Ju,b=Ni(m),p=ia(m,b);v.moveTo(m[p].x,m[p].y);for(let C=1;C<b;C++){let M=(p+C)%b;v.lineTo(m[M].x,m[M].y)}let x=n.geometry.coordinates.slice(1);v.holes=x.map(C=>{let M=C.map(w=>e(w[1],w[0])),S=new Qu,T=Ni(M);S.moveTo(M[0].x,M[0].y);for(let w=1;w<T;w++)S.lineTo(M[w].x,M[w].y);return S});let f=Si(t?.bevel,a),y=new em(v,f);y.userData={style:{color:i,opacity:o},usedBevelSettings:f},h.push(y)}if(h.length===1)return h[0];let d=pc.mergeGeometries(h);h.forEach(m=>m.dispose());let u=Si(t?.bevel,a);return d.userData={style:{color:i,opacity:o},usedBevelSettings:u,_split:!0},d}g();import{Shape as rm,Path as nm,ExtrudeGeometry as am}from"three";import*as fc from"three/examples/jsm/utils/BufferGeometryUtils.js";var sm="gray",lm=.1;function Uo(n,e,t){let{color:i=sm,opacity:o=1,altitude:r=0,height:a=lm}=t||{};Array.isArray(o)&&(o=1);let l={min:{x:1/0,y:1/0,z:r},max:{x:-1/0,y:-1/0,z:a+r}},s=Si(t?.bevel,a),c=[];n.geometry.coordinates.forEach(d=>{let u=new rm,m=d[0].map(f=>{let y=e(f[1],f[0]);return l.min.x=Math.min(l.min.x,y.x),l.min.y=Math.min(l.min.y,y.y),l.max.x=Math.max(l.max.x,y.x),l.max.y=Math.max(l.max.y,y.y),y}),v=Ni(m),b=ia(m,v);u.moveTo(m[b].x,m[b].y);for(let f=1;f<v;f++){let y=(b+f)%v;u.lineTo(m[y].x,m[y].y)}let p=d.slice(1);u.holes=p.map(f=>{let y=f.map(S=>e(S[1],S[0])),C=new nm,M=Ni(y);C.moveTo(y[0].x,y[0].y);for(let S=1;S<M;S++)C.lineTo(y[S].x,y[S].y);return C});let x=new am(u,s);c.push(x)});let h=fc.mergeGeometries(c);return c.forEach(d=>d.dispose()),h.userData={style:{color:i,opacity:o},usedBevelSettings:s},h}g();import{ExtrudeGeometry as cm,Path as hm,Shape as dm}from"three";import*as gc from"three/examples/jsm/utils/BufferGeometryUtils.js";var de=100,um=.22,mm=.01;function yc(n,e,t={}){let{width:i=um,height:o=mm,color:r="gray",opacity:a=1,altitude:l=0}=t,s={min:{x:1/0,y:1/0,z:l},max:{x:-1/0,y:-1/0,z:l+o}},c={bevelEnabled:!1,depth:o},h=new _e.ClipperOffset,d=n.geometry.coordinates.map(b=>b.map(p=>e(p[1],p[0])));h.AddPaths(d.map(b=>b.map(p=>({X:p.x*de,Y:p.y*de}))),_e.JoinType.jsMiter,_e.EndType.etOpenRound);let u=new _e.PolyTree;h.Execute(u,i/2*de);let m=[];for(let b of u.m_AllPolys){let p=new dm;if(b.IsHole())continue;s.min.x=Math.min(s.min.x,b.m_polygon[0].X),s.min.y=Math.min(s.min.y,b.m_polygon[0].Y),s.max.x=Math.max(s.max.x,b.m_polygon[0].X),s.max.y=Math.max(s.max.y,b.m_polygon[0].Y);let x=b.m_polygon;p.moveTo(x[0].X/de,x[0].Y/de),x.slice(1).forEach(f=>p.lineTo(f.X/de,f.Y/de)),p.lineTo(x[0].X/de,x[0].Y/de),p.holes=b.m_Childs.map(f=>{let y=new hm,C=f.m_polygon;return y.moveTo(C[0].X/de,C[0].Y/de),C.slice(1).forEach(M=>y.lineTo(M.X/de,M.Y/de)),y.lineTo(C[0].X/de,C[0].Y/de),y}),m.push(new cm(p,c))}let v=gc.mergeGeometries(m);return v.translate(0,0,l||0),v.userData={style:{color:r,opacity:a}},h.Clear(),v}import{mergeGeometries as pm}from"three/examples/jsm/utils/BufferGeometryUtils.js";function fm(n){let e=n[1],t=n[6],{opacity:i}=e??{},{texture:o,topTexture:r}=t??{};return`${i}${o?.path||""}${r?.path||""}`}var Ho=class extends z{state;convertTo3DMapPosition;constructor(e,t){super(),this.state=e,this.convertTo3DMapPosition=t}createEntityFromFeature(e,t,i){let o=new Y(t),r=Array.isArray(t)?t[0]?.properties:t.properties,a=r?.bevel,l=i&&"bevel"in i?i.bevel:void 0,s;l?s={...a,...l}:a&&(s=a);let c=new U(o,new Be({...i,url:r?.image?.path,bevel:s}));if(i?.outline){let h=this.state.outlinesOptions?.darkenFactor;c.components[3]=new ll(ul(i.color,h))}return i?.focusable&&(c.components[4]=new bl),r?.textures!=null&&Array.isArray(r.textures)&&r.textures.length>0?c.components[6]=new Mt(r.textures.find(h=>h.face==="side"),r.textures.find(h=>h.face==="top")):(i!=null&&"texture"in i&&i.texture!=null||i!=null&&"topTexture"in i&&i.topTexture!=null)&&(c.components[6]=new Mt(i.texture,i.topTexture)),c.id=Array.isArray(t)?e+"-merged":e,c}populateEntityMesh(e,t,i=!1){let o=e.components[0];if(o.geometry=t,t.userData.defaultUVs instanceof Float32Array&&(o.defaultUVs=t.userData.defaultUVs),e.components[1].slopeEnabled){let a=new nl;a.baselineVertices=new Float32Array(t.attributes.position.array),e.components[8]=a}i||(o.batchedProps={range:{start:0,count:1/0,indexCount:1/0,indexStart:0,vertexCount:1/0,vertexStart:0,reservedVertexCount:1/0,reservedIndexCount:1/0},geometryId:-1,positionCount:t.attributes.position.count}),o.currentHeight=e.components[1].height,e.components[1].initialHeight=e.components[1].height,o.dirty=!1}populateEntityGroup(e){let t,i,o;for(let r of e.values())if(o=this.state.geometry3DMap.get(r),o.components[0]instanceof Y){t=o.components[0].feature,i=o.components[1];try{if(Array.isArray(t)){let a=[];for(let s of t){let c=this.#e(s,i);c!=null&&a.push(c)}let l=pm(a);this.populateEntityMesh(o,l,!0),a.forEach(s=>s.dispose())}else{let a=this.#e(t,i);a!=null&&this.populateEntityMesh(o,a)}}catch(a){E.warn(`Failed to create mesh for entity ${r}:`,a)}}return e}#e(e,t){let i;return e.geometry.type==="Polygon"?(i=No(e,this.convertTo3DMapPosition,t),e.properties?.textures&&e.properties.textures.length>0&&(i.userData.defaultUVs=new Float32Array(i.getAttribute("uv").array),ml(i,e.properties.textures,this.state.naturalBearing,this.convertTo3DMapPosition))):e.geometry.type==="MultiPolygon"?i=Uo(e,this.convertTo3DMapPosition,t):e.geometry.type==="LineString"?i=Xl(e,this.convertTo3DMapPosition,t):e.geometry.type==="MultiLineString"&&(i=yc(e,this.convertTo3DMapPosition,t)),i}update(){for(let e of this.state.geometryGroupIdsToLoad.values()){let t=this.state.geometry3DMap.get(e);if(t instanceof le&&t.userData.dirty&&!t.userData.modelURL){try{this.populateEntityGroup(t.userData.entities3D)}catch(r){E.warn(r)}let i,o={};if(t.userData.isMerged){let r=t.userData.entities3D.values().next().value;if(r&&(i=this.state.geometry3DMap.get(r),i?.type==="geometry")){let a=i.getComponent("geometry"),l=i.getComponent("style");if(a&&l){let s=new mo({color:l.color}),c=new jt(a?.geometry,s);s.setColor(R(l.color),R(l.topColor??l.color)),c.renderOrder=Q.GEOMETRY,c.frustumCulled=!0,c.userData.entityId=i.id,c.layers.enable(X.SHOULD_CAST_SHADOWS),a.mesh=c,a.material=s,t.add(c)}}}else{for(let r of t.userData.entities3D.values()){i=this.state.geometry3DMap.get(r);let a=i?.components[0];if(i?.type==="geometry"){let l=fm(i.components);o[l]===void 0&&(o[l]={style:i.components[1],entities:[]}),o[l].entities.push(i)}else a&&"mesh"in a&&a.mesh&&a.mesh?.parent!==t&&t.add(a.mesh)}for(let r in o){let a=dl(o[r].entities,o[r].style);a.layers.enable(X.SHOULD_CAST_SHADOWS),t.add(a)}}for(let r of t.userData.entities3D.values())if(i=this.state.geometry3DMap.get(r),i!=null&&i.entities2D.size>0)for(let a of i.entities2D.values())a&&(i.attach(a),this.publish("geometry-2d-added"));this.publish("geometry-group-added"),t.userData.dirty=!1,t.userData.localCenter=void 0}}return Promise.resolve()}};g();import{Box3 as gm,Vector3 as ym}from"three";var Wo=new gm,bc=new ym;function bm(n,e){let t=n.components[2],i=n.components[1];return t?.hover?[i.hoverColor||e,i.hoverColor||e]:[i.color,i.topColor||i.color]}var Vo=class{state;transparencyChanged=!1;convertTo3DMapPosition;convert3DMapPositionToCoordinate;constructor(e,t,i){this.convertTo3DMapPosition=t,this.convert3DMapPositionToCoordinate=i,this.state=e}determineTextureVisiblity(e,t,i){let o=Ei(e);(o?.texture!=null||o?.topTexture!=null)&&(i?.hover&&o.texturesVisible?o.hideTextures(e.instanceIndex):o.texturesVisible||o.showTextures(e.instanceIndex),t.texture==null&&o.removeSideTexture(e.instanceIndex),t.topTexture==null&&o.removeTopTexture(e.instanceIndex))}update(){let e,t;for(let i of this.state.geometry3DsInScene)if((i.type==="geometry"||i.type==="custom-geometry")&&(i.components[1]?.dirty||i.components[2]?.dirty)){let o=i.components[0],r=i.components[1];t=i.components[2];let a=bm(i,this.state.hoverColor);o.setColor(a[0],a[1]);let l=Ei(o);if(r.visible!==o.visible&&(o.visible=r.visible,o instanceof Y&&o.textMesh)){let c=this.state.geometry3DMap.get(o.textMesh.userData.entityId);c?.type==="text3d"&&c.components[0].polygonEntityId!=null&&(c.components[0].visible=r.visible)}r.altitude!==o.altitude&&(o.altitude=r.altitude);let s=r.opacity*Vt(i);if(l&&o.mesh&&o.type==="geometry"&&s!==o.opacity){if(l.opacity=s,l.transparent=s<1,(!Oi(o.mesh)||o.detached)&&(l.visible=s>0),o.imageMesh){let h=Array.isArray(o.imageMesh.material)?o.imageMesh.material:[o.imageMesh.material];for(let d of h)d.opacity=s}s===0?(o.mesh.layers.disable(X.SHOULD_CAST_SHADOWS),this.transparencyChanged=!0):o.opacity===0&&s!==0&&(o.mesh.layers.enable(X.SHOULD_CAST_SHADOWS),this.transparencyChanged=!0),o.opacity=s}if(r.renderOrder!==o.renderOrder&&(o.renderOrder=r.renderOrder),l&&hl(l,r.side,s),l&&(l.setEffectRange(r.effectStart,r.effectDistance),l.setVisualEffect(r.darkenAmount,r.darkenUseDepth,r.desaturateAmount,r.desaturateUseDepth,r.washOutAmount,r.washOutUseDepth)),o instanceof Y&&r.shading!=null&&(r.shading?.start!==l?.getGradientShading().start||r.shading?.end!==l?.getGradientShading().end||r.shading?.intensity!==l?.getGradientShading().intensity)&&l?.setGradientShading(r.shading?.start??0,r.shading?.end??0,r.shading?.intensity??0),r.dirty=!1,o instanceof Y){let c=i.components[6];c instanceof Mt&&this.determineTextureVisiblity(o,c,t)}i.components[2]&&(i.components[2].dirty=!1)}else if(i?.type==="image"&&i.components[1]?.dirty){e=i.components[0];let o=i.components[1];o.visible!==e.visible&&(e.visible=o.visible),o.dirty=!1}else if(i?.type==="text3d"&&i.components[1]?.dirty){e=i.components[0];let o=i.components[1],r=e.polygonEntityId!=null;o.visible!=null&&o.visible!==e.visible&&(e.visible=o.visible);let{textMesh:a}=e;if(a)if(Object.assign(a,o.getState()),r){let l=o.hoverColor??this.state.text3dHoverColor;a.color=o.hoverByPolygon?l:o.color??je.color,a.outlineColor=o.hoverByPolygon?l:o.outlineColor??je.outlineColor,a.strokeColor=o.hoverByPolygon?l:o.strokeColor??je.strokeColor}else a.color=o.color??je.color,a.outlineColor=o.outlineColor??je.outlineColor,a.strokeColor=o.strokeColor??je.strokeColor;o.dirty=!1}else if(i?.type==="feature-collection"&&i?.userData.dirty===!1&&i?.userData.positionDirty){let o=i;if(o.userData.localCenter||(Wo.makeEmpty(),Wo.setFromObject(o),Ut(Wo)&&(Wo.getCenter(bc),o.userData.localCenter=bc.clone())),!o.userData.centroid&&o.userData.localCenter){let r=this.convert3DMapPositionToCoordinate(o.userData.localCenter);o.userData.centroid=[r[0],r[1]]}if(o.userData.centroid&&o.userData.localCenter){let r=this.convertTo3DMapPosition(o.userData.centroid);o.position.x+=r.x-o.userData.localCenter.x,o.position.y+=r.y-o.userData.localCenter.y,o.userData.localCenter.set(r.x,r.y,o.userData.localCenter.z),o.userData.positionDirty=!1}}}endFrame=()=>{this.transparencyChanged=!1}};g();var jo=class extends z{state;renderer;mode;scene;cameraObject;viewCamera;systems;constructor(e,t,i,o,r,a,l){super(),this.renderer=e,this.state=t,this.mode=i,this.scene=o,this.cameraObject=r,this.viewCamera=a,this.systems=l,this.systems.cameraSystem.on("pan-start",()=>this.systems.twoDEntitySystem.collidersNeedRecomputing=!1,{signal:this.signal}),this.systems.cameraSystem.on("zoom-start",()=>this.systems.twoDEntitySystem.collidersNeedRecomputing=!1,{signal:this.signal}),this.systems.cameraSystem.on("zoom-end",()=>this.systems.twoDEntitySystem.collidersNeedRecomputing=!0,{signal:this.signal}),this.systems.cameraSystem.on("rotate-start",()=>this.systems.twoDEntitySystem.collidersNeedRecomputing=!1,{signal:this.signal}),this.systems.cameraSystem.on("rotate-end",()=>this.systems.twoDEntitySystem.collidersNeedRecomputing=!0,{signal:this.signal})}twoDdirty=!0;threeDdirty=!0;frameId=null;update=(e=!1)=>{if(this.renderer?.renderer==null)return Promise.resolve();if(e){this.renderer.startFrame();let t=this.commitRenderState();return this.paint(),t}else return this.frameId?Promise.resolve():new Promise((t,i)=>{this.frameId=requestAnimationFrame(()=>this.renderer?.renderer==null?t():this.mode==="standalone"?(this.renderer.startFrame(),this.commitRenderState()?.then(()=>{this.paint(),t()}).catch(o=>{i(o)})):t())})};paint(){if(!this.renderer?.renderer)return;this.mode==="standalone"&&this.renderer.clear();let e=!this.state.useStandaloneCamera&&this.mode!=="standalone";e&&(this.viewCamera.matrixWorld.copy(this.cameraObject.matrixWorld),this.viewCamera.matrixWorldInverse.copy(this.cameraObject.matrixWorldInverse),this.viewCamera.projectionMatrix.multiply(this.cameraObject.matrixWorld)),this.renderer.renderFullScene(this.scene,e?this.viewCamera:this.cameraObject,this.state.alwaysOnTopPaths>0),this.state.renderStats=this.renderer.frameStats,e&&(this.viewCamera.projectionMatrix.multiply(this.cameraObject.matrixWorldInverse),this.viewCamera.matrixWorldInverse.identity())}commitRenderState=()=>{try{let e=[];this.frameId=null,this.publish("pre-render"),this.state.internalTweenGroup.update(),this.state.externalTweenGroup.update(),(this.mode==="outdoors-interleaved"||this.mode==="standalone")&&this.systems.cameraSystem.update(),this.state.shouldMeasureCanvas&&(this.state.shouldMeasureCanvas=!1,this.publish("measure-canvas")),this.twoDdirty&&(this.state.geometry2DIdsInScene.clear(),this.state.geometry2DsInScene.clear(),Qs(this.state.geometryScene,this.state.geometry2DMap,this.state.geometry2DIdsInScene,this.state.geometry2DsInScene),this.systems.twoDEntitySystem.syncTwoDEntities(),this.systems.twoDEntitySystem.markDirty(),this.twoDdirty=!1),this.threeDdirty&&(this.state.geometry3DIdsInScene.clear(),this.state.geometry3DsInScene.clear(),this.state.geometryGroupIdsToLoad.clear(),Js(this.state.geometryScene,this.state.geometry3DMap,this.state.geometry3DIdsInScene,this.state.geometry3DsInScene,this.state.geometryGroupIdsToLoad),this.systems.interactionSystem.dirty3D=!0,this.systems.outlineInterpolationSystem.geometries3DDirty=!0,this.systems.geometryInFocusSystem.focusablesDirty=!0,this.systems.shadowsSystem&&this.systems.shadowsSystem.castersChanged(),this.threeDdirty=!1);let t=this.systems.batchedMeshSystem.update();t&&e.push(t);let i=this.systems.modelSystem.update();return i&&e.push(i),this.systems.borderSystem.update(),this.systems.meshDetachmentSystem.update(),this.systems.meshModificationSystem.update(),this.systems.renderOrderSystem.update(),this.systems.clippingPlaneSystem.update(),this.systems.imageSystem.update(this.systems.cameraSystem.getRotation(),this.systems.cameraSystem.isCameraMoving(),this.systems.cameraSystem.lastCameraStoppedMovingTime()),e.push(this.systems.text3DSystem.update(this.systems.cameraSystem.getRotation())),this.systems.customGeometrySystem.update(),this.systems.panBoundsSystem.update(),this.systems.geometryInFocusSystem.update(this.systems.cameraSystem.isCameraMoving(),this.systems.cameraSystem.lastCameraStoppedMovingTime()),this.systems.outlineInterpolationSystem.update(this.systems.cameraSystem.getZoomLevel(),this.systems.cameraSystem.zoomDirty),this.systems.pathSystem.update(this.systems.cameraSystem.minZoomAltitude,this.systems.cameraSystem.maxZoomAltitude,this.systems.cameraSystem.getZoomAltitude(),this.systems.cameraSystem.getCurrentMetersPerPixel()),this.systems.cameraSystem.postRender(),this.systems.occlusion2DSystem.update(),this.systems.watermarkSystem.insertIntoQuadTree(this.systems.twoDEntitySystem.interactiveCollidersQTree),this.systems.interactionSystem.updateQuadtree(this.systems.twoDEntitySystem.interactiveCollidersQTree),this.systems.twoDEntitySystem.updateWatermark({width:this.systems.watermarkSystem.width,height:this.systems.watermarkSystem.height,position:this.systems.watermarkSystem.options.position}),this.systems.twoDEntitySystem.update(this.systems.cameraSystem.getZoomLevel(),this.systems.cameraSystem.isUserInteracting(),this.systems.cameraSystem.isCameraMoving(),this.systems.imageSystem.currentImageScreenBBoxes),this.systems.watermarkSystem.update(),this.systems.textureSystem.update(),this.systems.pluginSystem.update(this.state,this.systems),this.systems.drawSystem.update(),this.systems.geometryDisposalSystem.update(),this.systems.maskingSystem.update(),this.systems.cameraSystem.dirty=!1,this.systems.cameraSystem.zoomDirty=!1,this.systems.cameraSystem.rotationDirty=!1,this.systems.shadowsSystem&&((this.systems.modelSystem.transparencyChanged||this.systems.drawSystem.transparencyChanged)&&this.systems.shadowsSystem.castersChanged(),this.systems.shadowsSystem.update(this.systems.cameraSystem.getZoomLevel(),this.systems.cameraSystem.getPedestal())),this.systems.modelSystem.endFrame(),this.systems.drawSystem.endFrame(),this.systems.cameraSystem.stateDirty&&(this.publish("camera-state-change"),this.systems.cameraSystem.stateDirty=!1),this.publish("post-render"),Promise.all(e)}catch(e){return Promise.reject(e)}};destroy(){this.frameId&&cancelAnimationFrame(this.frameId),this.systems.twoDEntitySystem.cancelPendingFrames(),this.state.geometry2DIdsInScene.clear(),this.state.geometry3DIdsInScene.clear(),this.systems.twoDEntitySystem.markDirty(),this.update(),super.destroy()}};g();import{Vector3 as vm}from"three";g();import{Mesh as LM,Object3D as AM,InstancedMesh as RM}from"three";g();g();g();import{z as O}from"zod";g();import{z as Zo}from"zod";var $t=Zo.object({type:Zo.enum(["Point"]),coordinates:Zo.array(Zo.number()).min(2).max(3)});var xm=O.object({interactive:O.boolean().optional(),id:O.string().optional(),width:O.union([O.number(),O.string().regex(ho),O.object({on:O.literal("zoom-level").optional(),input:O.array(O.number()).nonempty(),output:O.union([O.array(O.number()).nonempty(),O.array(O.string().regex(ho)).nonempty()]),easing:O.string().optional()})]).optional(),accentColor:O.string().optional(),displayArrowsOnPath:O.boolean().optional(),animateArrowsOnPath:O.boolean().optional(),visibleThroughGeometry:O.boolean().optional(),dashed:O.boolean().optional(),dashCornerRadius:O.number().optional(),travelledEndFraction:O.number().optional(),travelledColor:O.string().optional(),smoothingTension:O.number().optional(),smoothingCornerRadius:O.number().optional(),dashLength:O.number().optional(),dashGap:O.number().optional(),dashRelativeToWidth:O.boolean().optional(),dashSize:O.number().optional(),gapSize:O.number().optional(),dashAbsolute:O.boolean().optional(),dashMeters:O.number().optional(),gapMeters:O.number().optional(),geometryType:O.enum(["tube","ribbon"]).optional(),endcapExtension:O.tuple([O.number(),O.number()]).optional(),billboarding:O.union([O.boolean(),O.number().min(0).max(90)]).optional(),border:O.object({enabled:O.boolean(),color:O.string(),width:O.number().optional()}).optional(),xrayStyle:O.object({color:O.string().optional(),tint:O.number().min(0).max(1).optional(),dithering:O.number().min(0).optional()}).optional()}),Sm=O.object({type:O.enum(["Feature"]),geometry:$t,properties:O.object({parentId:O.any().optional()})});function vc(n,e){O.object({features:O.array(Sm)}).parse(n),xm.parse(e)}function Mm(n,e){let t=mn(n);t&&e==="tube"&&(E.warn("Screen-space pixel width is only supported with ribbon geometry. Falling back to world-space interpretation."),t=!1);let i;return typeof n=="object"&&"output"in n?i=n.output.map(o=>typeof o=="string"?Qe(o):Number(o)):bt(n)?i=[Qe(n)]:i=[n],{screenSpace:t,parsedOutputValues:i}}function Cm(n,e){return n||e==="ribbon"}function Dm(n,e){return n&&e==="ribbon"}function wm(n,e){return e?!1:n}var Tt=class{type="path";mesh=new he;material;pathObject;geometry;outline;feature;options;width={on:"zoom-level",input:[17,22],output:[.8,.4]};breakpoint=0;screenSpace=!1;parsedOutputValues=[];altitudeBreakpoints;accentColor="blue";completeFraction=1;displayArrowsOnPath=!1;animateArrowsOnPath=!1;visibleThroughGeometry=!1;highlightStartFraction=0;highlightEndFraction=0;highlightCompleteFraction=1;highlightWidthMultiplier=1.1;highlightColor="red";highlightDisplayArrowsOnPath=!1;xrayOpacity=.25;xrayStyle;travelledEndFraction=0;travelledColor="#999";dashed=!1;maxDashCount=0;dashCapWarned=!1;curveLength=0;_dashDiscrete=!1;_dashedMask=!1;get dashDiscrete(){return this._dashDiscrete}get dashedMask(){return this._dashedMask}dashCornerRadius=0;smoothingTension=Ve.tension;smoothingCornerRadius=Ve.cornerRadius;dashLength=.1;dashGap=.1;dashRelativeToWidth=!1;dashSize=fn.size;gapSize=fn.gapSize;dashAbsolute=!1;dashMeters=1;gapMeters=.5;geometryType="tube";endcapExtension=[.5,.5];billboarding=80;border;isVertical=!1;dirty=!0;materialDirty=!0;constructor(e,t){this.feature=e,this.options=t||{},this.width=t?.width??this.width,this.accentColor=t?.accentColor??this.accentColor,this.displayArrowsOnPath=t?.displayArrowsOnPath??this.displayArrowsOnPath,this.animateArrowsOnPath=t?.animateArrowsOnPath??this.animateArrowsOnPath,this.highlightDisplayArrowsOnPath=t?.highlightDisplayArrowsOnPath??this.displayArrowsOnPath,this.visibleThroughGeometry=t?.visibleThroughGeometry??this.visibleThroughGeometry,this.dashed=t?.dashed??this.dashed,this.dashCornerRadius=t?.dashCornerRadius??this.dashCornerRadius,this.xrayOpacity=t?.xrayOpacity??this.xrayOpacity,this.xrayStyle=t?.xrayStyle,this.travelledEndFraction=t?.travelledEndFraction??this.travelledEndFraction,this.travelledColor=t?.travelledColor??this.travelledColor,this.smoothingTension=t?.smoothingTension??Ve.tension,this.smoothingCornerRadius=t?.smoothingCornerRadius??Ve.cornerRadius,this.dashLength=t?.dashLength??this.dashLength,this.dashGap=t?.dashGap??this.dashGap,this.dashRelativeToWidth=t?.dashRelativeToWidth??this.dashRelativeToWidth,this.dashSize=t?.dashSize??this.dashSize,this.gapSize=t?.gapSize??this.gapSize,this.dashAbsolute=t?.dashAbsolute??this.dashAbsolute,this.dashMeters=t?.dashMeters??this.dashMeters,this.gapMeters=t?.gapMeters??this.gapMeters,this.geometryType=t?.geometryType??"tube",this.resolveDashState(),this.endcapExtension=t?.endcapExtension??[.5,.5],this.billboarding=t?.billboarding??80,this.border=t?.border,this.updateScreenSpaceState()}resolveDashState(e={}){let t=e.dashed??this.dashed,i=e.geometryType??this.geometryType,o=Dm(t,i),r=o!==this._dashDiscrete;return this._dashDiscrete=o,this._dashedMask=wm(t,o),r}updateScreenSpaceState(){let e=Mm(this.width,this.isFlat?"ribbon":"tube");this.screenSpace=e.screenSpace,this.parsedOutputValues=e.parsedOutputValues}get isFlat(){return Cm(this.dashDiscrete,this.geometryType)}setColor(){}setOpacity(){}set visible(e){this.mesh&&(this.mesh.visible=e)}get visible(){return this.mesh?this.mesh.visible:!1}position=new vm;set complete(e){this.material&&(this.material.uniforms.complete.value=e)}};g();g();import{Object3D as _m,Euler as Bm,MOUSE as ma,PlaneGeometry as Fm,Matrix4 as Dc,MeshBasicMaterial as wc,Mesh as Gm,Raycaster as km,Vector2 as we,Vector3 as te,Clock as zm,Box3 as Nm,MathUtils as st,InstancedMesh as Um,BoxGeometry as Hm}from"three";g();function at(n,e,t){return n.type==="portion"?{top:n.top*t,left:n.left*e,bottom:n.bottom*t,right:n.right*e,type:"pixel"}:n}g();g();g();import{Vector2 as xc}from"three";var Sc=(n,e)=>(e-n+Math.PI)%(Math.PI*2)+Math.PI*2%(Math.PI*2)-Math.PI,Mc=(n,e)=>new xc(n.clientX-e.offsetLeft,n.clientY-e.offsetTop),oa=(n,e)=>Math.atan2(e.y-n.y,e.x-n.x),Ui=(n,e)=>Math.sqrt((e.y-n.y)**2+(e.x-n.x)**2),ra=(n,e)=>new xc((n.x+e.x)/2,(n.y+e.y)/2),na=n=>{let e=0,{wheelDelta:t,detail:i}=n;return t!==void 0?e=t:i!==void 0&&(e=-i),e};var Xo=class{input1;input2;lastAngle;lastDistance;totalDistance;first;second;constructor(e,t){this.input1=e,this.input2=t,this.lastAngle=oa(e,t),this.lastDistance=Ui(e,t),this.totalDistance=0,this.first=e,this.second=t}update(e,t){let i=Ui(e,t);this.input1=e,this.input2=t;let o=oa(e,t);this.lastAngle=o,this.lastDistance=i,this.totalDistance+=(Ui(this.first,e)+Ui(this.second,t))/2,this.first=ra(this.first,e),this.second=ra(this.second,t)}};g();import{Vector2 as Cc,Raycaster as Tm}from"three";var Hi=class{touch;camera;cameraPlane;viewCoordinate;snapHolderMatrix;snapCamera;cameraPosition;raycaster;worldCoordinate;snapshotted=!1;constructor(e,t,i){this.touch=e,this.camera=t,this.cameraPlane=i,this.viewCoordinate={x:e.x,y:e.y},this.camera.updateMatrixWorld(),this.camera.updateMatrix(),this.snapHolderMatrix=this.camera.matrixWorld.clone(),this.snapCamera=this.camera.clone(),this.snapshotCameraState()}snapshotCameraState(){this.camera.updateMatrix(),this.camera.updateMatrixWorld(),this.cameraPosition=this.camera.position.clone();let e=new Cc(this.viewCoordinate.x,this.viewCoordinate.y);this.raycaster=this.raycaster||new Tm,this.raycaster.setFromCamera(e,this.snapCamera);let t=this.raycaster.intersectObject(this.cameraPlane,!0);this.worldCoordinate=t&&t.length>0?t[0].point:null,this.snapshotted=!0}updateAnchorState(e,t){this.camera=e,this.snapCamera=e.clone(),this.snapHolderMatrix=e.matrixWorld.clone(),this.updateViewCoordinate(t),this.snapshotCameraState()}updateViewCoordinate(e){this.viewCoordinate={x:e.x,y:e.y}}reUnproject(){let e=new Cc(this.viewCoordinate.x,this.viewCoordinate.y);this.raycaster?.setFromCamera(e,this.snapCamera);let t=this.raycaster?.intersectObject(this.cameraPlane,!0)[0];return t?t.point:void 0}};var De={};cu(De,{BLOCK_MERCATOR_ZOOM_LEVEL:()=>Pm,CLIPPING_RADIUS:()=>Wi,CONTROL_OPTIONS:()=>Em,DEFAULT_ANIMATION_DURATION:()=>ha,DEFAULT_BEARING:()=>Rm,DEFAULT_MAX_ZOOM_LEVEL:()=>Lm,DEFAULT_MIN_ZOOM_LEVEL:()=>ua,DEFAULT_PITCH:()=>Am,DEFAULT_ZOOM_LEVEL:()=>Im,EVENTS:()=>da,MAPLIBRE_TILE_SIZE:()=>Yo,MAX_LAT:()=>sa,MAX_MERCATOR_ZOOM_LEVEL:()=>qo,MIN_LAT:()=>aa,MIN_MERCATOR_ZOOM_LEVEL:()=>$o,ROOM_MERCATOR_ZOOM_LEVEL:()=>Om,TWO_PI:()=>la,WHEEL_ZOOM_MULTIPLIER:()=>ca,ZRANGE:()=>qt});g();var Yo=512,aa=-85.051129,sa=85.051129,Wi=1e4,Em={chain:"chain",cancel:"cancel"},la=Math.PI*2,qt=100,ca=1e4,$o=0,qo=24,Pm=17,Om=20,ha=200,da=["change","pan-start","pan-end","rotate-start","rotate-end","zoom-start","zoom-end","multi-start","multi-end","multi-cancel","pedestal-start","pedestal-change","pedestal-end","user-pan-start","user-pedestal-start","user-rotate-start","user-dolly-start","user-zoom-start","user-tilt-start","user-pan-end","user-pedestal-end","user-rotate-end","user-dolly-end","user-zoom-end","user-tilt-end","position-updated","zoom-updated","tilt-updated","rotation-updated"],Im=18,ua=12,Lm=22,Am=0,Rm=0;var Ko=!1,Wm=!1;var Kt=class extends z{dirty=!1;zoomDirty=!1;rotationDirty=!1;panDirty=!1;stateDirty=!1;#e=ua;zoomSpeed=5;rotateSpeed=100;enabled=!0;enableZoom=!0;enablePan=!0;enablePedestal=!1;maxPedestal=1/0;minPedestal=0;enableRotate=!0;minZoomAltitude=0;maxZoomAltitude=1/0;get maxZoomLevel(){return this.convertAltitudeToZoomLevel(this.minZoomAltitude)}setMaxZoomLevel(e){this.minZoomAltitude=this.convertZoomLevelToAltitude(e),this.stateDirty=!0}get defaultMinZoomLevel(){return this.#e}get minZoomLevel(){return this.convertAltitudeToZoomLevel(this.maxZoomAltitude)}setMinZoomLevel(e){this.maxZoomAltitude=this.convertZoomLevelToAltitude(e),this.stateDirty=!0}ignoreZoomLimits=!1;zoomFactor=1;panBounds={min:new te(1/0,1/0),max:new te(-1/0,-1/0),center:new te(0,0,0),radius:1/0};minTilt=0;maxTilt=1.2;MOUSE_BUTTONS={ORBIT:ma.RIGHT,ZOOM:ma.MIDDLE,PAN:ma.LEFT};camera;scene;renderer;elevation;orbit;cameraPlane;raycaster=new km;rendererState;options;state=-1;intersection;viewState=null;tweens=new Map;clock=new zm(!0);coords={mouse:new we,rotateStart:new we,rotateEnd:new we,rotateDelta:new we,panStart:new te,panCameraStart:new te,panEnd:new te,panDelta:new te,initialShiftPos:new we,initialPedestal:0,floorAnchor:new te};touch={origin:{offsetLeft:0,offsetTop:0},touches:[],anchor1:null,anchor2:null,inputs:null};scrollTimer=null;lastWheelTime=0;resetZoom=!1;zoomStart;pedestalScaleFactor=1;isUserZooming=!1;stayInsideBounds=!0;userInteracting=!1;cameraMoving=!1;lastCameraMoveTime=Date.now();constructor(e,t,i,o,r){super(),this.camera=e,this.renderer=i,this.rendererState=o,this.scene=t,this.options=r,this.elevation=e.parent,this.orbit=this.elevation.parent,this.cameraPlane=this.createCameraPlane(),this.zoomStart=e.position.z,r.mode==="outdoors-overlay"||r.__EXPERIMENTAL_CameraControlsMode==="external"?this.addMovingStateListeners():this.addEventListeners()}addMovingStateListeners=()=>{for(let e of da)e.endsWith("start")?(this.on(e,this.setCameraMoving),e.startsWith("user")&&this.on(e,this.setUserInteracting)):(e.endsWith("end")||e.endsWith("cancel"))&&(this.on(e,this.unsetCameraMoving),e.startsWith("user")&&this.on(e,this.unsetUserInteracting))};get scrollPercent(){let e=this.minPedestal,t=this.maxPedestal,i=this.getPedestal();return i=Math.min(i,t),i=Math.max(i,e),(i-e)/(t-e)*100}get fov(){return this.camera.fov}get scrolledToBottom(){return this.minPedestal===0||Math.floor(this.getPedestal())<=this.minPedestal}get scrolledToTop(){return this.maxPedestal===0||Math.ceil(this.getPedestal())>=this.maxPedestal}get center(){let e=this.getPosition(),{lat:t,lon:i}=Mi(this.rendererState.center?.[1]??0,this.rendererState.center?.[0]??0,e.x,e.y);return[i,t]}setCenter(e,t){let{x:i,y:o}=Ci(this.rendererState.center?.[1]??0,this.rendererState.center?.[0]??0,t,e);this.setPosition(i,o)}raycastToFloor=e=>{this.raycaster.setFromCamera(e,this.camera);let t=this.raycaster.intersectObject(this.cameraPlane,!1)[0];return t?t.point:new te};isUserInteracting=()=>this.userInteracting;getPosition=()=>new te(this.orbit.position.x,this.orbit.position.y,this.orbit.position.z);getPedestal=()=>this.orbit.position.z;pan=(e,t)=>{isNaN(e)||isNaN(t)||(this.setPosition(this.orbit.position.x+e,this.orbit.position.y+t),this.publish("position-updated"))};postRender=()=>{(this.state===2||this.state===6)&&(this.raycaster.setFromCamera(this.coords.mouse,this.camera),this.intersection=this.raycaster.intersectObject(this.cameraPlane,!1)[0],this.intersection&&(this.coords.panStart.set(this.intersection.point.x,this.intersection.point.y,0),this.coords.panCameraStart.set(this.orbit.position.x,this.orbit.position.y,0))),this.state===3&&this.resetZoom&&(this.resetZoom=!1,this.zoomStart=this.getZoomAltitude(),this.coords.floorAnchor=this.raycastToFloor(this.coords.mouse),this.coords.panCameraStart.set(this.orbit.position.x,this.orbit.position.y,0)),this.state===7&&this.isAnimating===!1&&(this.state=-1,this.publish("multi-end"))};get isAnimating(){return this.rendererState.internalTweenGroup.getAll().some(e=>e.cameraAnimation)}isCameraMoving=()=>this.cameraMoving;lastCameraStoppedMovingTime=()=>this.lastCameraMoveTime;beginGesture=()=>{this.state=2,this.publish("pan-start")};endGesture=()=>{this.state===2&&(this.state=-1,this.publish("pan-end"))};setPosition=(e,t)=>{e===void 0||t===void 0||isNaN(e)||isNaN(t)||(this.state===-1&&this.publish("pan-start"),this.updateCameraPosition(e,t),this.publish("position-updated"),this.publish("change"),this.state===-1&&this.publish("pan-end"),this.dirty=!0,this.stateDirty=!0)};updateCameraPosition=(e,t)=>{let i=e-this.panBounds.center.x,o=t-this.panBounds.center.y,r=Math.sqrt(i*i+o*o);if(this.stayInsideBounds&&r>this.panBounds.radius){let a=Math.atan2(o,i),l={x:Math.cos(a)*this.panBounds.radius+this.panBounds.center.x,y:Math.sin(a)*this.panBounds.radius+this.panBounds.center.y};this.orbit.position.x=l.x,this.orbit.position.y=l.y}else this.orbit.position.x=e,this.orbit.position.y=t};clampCenterToPanBounds(e,t){if(!this.stayInsideBounds)return;let i=this.rendererState.center?.[1]??0,o=this.rendererState.center?.[0]??0,{x:r,y:a}=Ci(i,o,t,e),l=r-this.panBounds.center.x,s=a-this.panBounds.center.y,c=Math.sqrt(l*l+s*s);if(!(c>this.panBounds.radius))return;let h=this.panBounds.radius/c,{lat:d,lon:u}=Mi(i,o,this.panBounds.center.x+l*h,this.panBounds.center.y+s*h);return[u,d]}tilt=e=>{if(isNaN(e))return;this.state===-1&&this.publish("rotate-start");let t=this.stayInsideBounds?Math.max(Math.min(e+this.getTilt(),this.maxTilt),this.minTilt):e+this.getTilt();t!==this.elevation.rotation.x&&(this.elevation.rotation.x=t,this.publish("tilt-updated")),this.publish("change"),this.state===-1&&this.publish("rotate-end"),this.stateDirty=!0};zoomIn=(e,t,i)=>{let o=this.getZoomAltitude();this.animateCamera({zoom:o/1.5},e,t,i)};zoomOut=(e,t,i)=>{let o=this.getZoomAltitude();this.animateCamera({zoom:o*1.5},e,t,i)};getRotation=()=>(-this.orbit.rotation.z+Math.PI*2)%(Math.PI*2);cancelAnimation=()=>{let e=Array.from(this.tweens.keys());if(e.length<1)return;let t=e[e.length-1];t.state===7&&this.publish("multi-cancel",{zooming:!0,rotating:!0,tilting:!0}),t.isPlaying()&&this.tweens.get(t)?.cancelledCallback?.(),this.completeTween(t),this.state===7&&(this.state=-1)};animateCamera=(e,t,i,o,r,a)=>{let l={interruptible:!0,...a},s={},c={},h=this.getPosition();if(e.position!=null&&(e.position.x!==void 0&&(s.x=h.x,c.x=e.position.x),e.position.y!==void 0&&(s.y=h.y,c.y=e.position.y),e.position.z!==void 0&&(s.z=h.z,c.z=e.position.z)),e.zoom!==void 0&&(s.zoom=this.stayInsideBounds?Math.min(Math.max(this.getZoomAltitude(),this.getZoomScaledMin()),this.getZoomScaledMax()):this.getZoomAltitude(),this.viewState==="multi_floor"||!this.stayInsideBounds?c.zoom=e.zoom:c.zoom=Math.min(Math.max(e.zoom,this.getZoomScaledMin()),this.getZoomScaledMax())),e.rotation!==void 0){let{start:f,end:y}=Ps(this.getRotation(),e.rotation);s.rotation=f,c.rotation=y}e.tilt!==void 0&&(s.tilt=this.getTilt(),this.viewState==="multi_floor"||!this.stayInsideBounds?c.tilt=e.tilt:c.tilt=Math.max(Math.min(e.tilt,this.maxTilt),this.minTilt));let d=s.zoom!==c.zoom,u=s.rotation!==c.rotation,m=s.tilt!==c.tilt,v=new Is(s).to(c,D.env.TESTING?0:t).onUpdate(f=>{this.setMulti({x:f.x,y:f.y,z:f.z},f.zoom,f.rotation,f.tilt)}).onComplete(()=>{this.completeTween(v),this.publish("multi-end",{zooming:d,rotating:u,tilting:m}),o&&o()}).onStart(()=>{this.state!==7&&(this.state=7,v.state=7,this.publish("multi-start",{zooming:d,rotating:u,tilting:m})),this.publish("change")});this.rendererState.internalTweenGroup.add(v);let b=Array.from(this.tweens.entries()),p=b[b.length-1],x=!1;return p!=null&&(p[1].interruptible?(typeof p[1].cancelledCallback=="function"&&p[1].cancelledCallback(),this.completeTween(p[0])):(x=!0,p[0].chain(v))),this.tweens.set(v,{cancelledCallback:r,interruptible:l.interruptible}),i?v.easing(i):v.easing(vt.Quadratic.In),!e.doNotAutoStart&&!x&&(v.start(),this.publish("change")),v.cameraAnimation=!0,v};setMulti=(e,t,i,o,r=!0)=>{this.state===-1&&this.publish("multi-start");let a=!1;e!=null&&(e.x!==void 0&&!isNaN(e.x)&&e.y!==void 0&&!isNaN(e.y)&&(this.updateCameraPosition(e.x,e.y),a=!0),e.z!==void 0&&!isNaN(e.z)&&(this.setPedestal(e.z,!0,!1),a=!0)),a&&this.publish("position-updated");let l={zooming:!1,tilting:!!t,rotating:!1};if(t!==void 0&&!isNaN(t)){let s=this.stayInsideBounds?Math.min(Math.max(t,this.getZoomScaledMin()),this.getZoomScaledMax()):t;s!==this.camera.position.z&&(l.zooming=!0,this.camera.position.z=s,this.publish("zoom-updated"),this.zoomDirty=!0,this.viewState==="multi_floor"?t>Wi&&(this.camera.near=t-Wi,this.camera.far=t+Wi):(this.camera.near=t/qt,this.camera.far=t*qt),this.camera.updateProjectionMatrix())}if(i!==void 0&&!isNaN(i)&&i!==this.getRotation()&&(l.rotating=!0,this.orbit.rotation.z=-i,this.publish("rotation-updated")),o!==void 0&&!isNaN(o)){let s=this.stayInsideBounds?Math.max(Math.min(o,this.maxTilt),this.minTilt):o;s!==this.elevation.rotation.x&&(l.tilting=!0,this.elevation.rotation.x=s,this.publish("tilt-updated"))}r&&this.publish("change"),this.state===-1&&this.publish("multi-end",l),this.stateDirty=!0};getZoomScaledMin=()=>this.minZoomAltitude*this.zoomFactor;getZoomScaledMax=()=>{let e=this.minZoomAltitude*this.zoomFactor;return Math.max(this.maxZoomAltitude,e)};setRotation=(e,t)=>{if(isNaN(e))return;this.state===-1&&!t&&this.publish("rotate-start");let i=-(e%la);i!==this.orbit.rotation.z&&(this.orbit.rotation.z=i,t||this.publish("rotation-updated")),t||this.publish("change"),this.state===-1&&!t&&this.publish("rotate-end"),this.dirty=!0,this.rotationDirty=!0,t||(this.stateDirty=!0)};setZoomAltitude=e=>{if(isNaN(e))return;this.state===-1&&this.publish("zoom-start");let t=this.stayInsideBounds?Math.min(Math.max(e,this.getZoomScaledMin()),this.getZoomScaledMax()):e;t!==this.camera.position.z&&(this.camera.position.z=t,this.publish("zoom-updated"),this.zoomDirty=!0);let i=t/qt,o=t*qt;(this.camera.near!==i||this.camera.far!==o)&&(this.camera.near=i,this.camera.far=o,this.camera.updateProjectionMatrix()),this.publish("change"),this.state===-1&&this.publish("zoom-end"),this.dirty=!0,this.stateDirty=!0};setZoomLevel=e=>{this.setZoomAltitude(this.convertZoomLevelToAltitude(e))};getZoomAltitude=()=>this.camera.position.z;getZoomLevel=()=>this.convertAltitudeToZoomLevel(this.getZoomAltitude());setTilt=(e,t)=>{if(isNaN(e))return;this.state===-1&&!t&&this.publish("rotate-start");let i=this.stayInsideBounds?Math.max(Math.min(e,this.maxTilt),this.minTilt):e;i!==this.elevation.rotation.x&&(this.elevation.rotation.x=i,t||this.publish("tilt-updated")),t||this.publish("change"),this.state===-1&&!t&&this.publish("rotate-end"),this.dirty=!0,t||(this.stateDirty=!0)};getTilt=()=>this.elevation.rotation.x;setCameraPlaneElevation=e=>{this.cameraPlane.position.z=e};zoom=e=>{if(isNaN(e))return;this.state===-1&&this.publish("zoom-start");let t=this.getZoomAltitude()-e;this.camera.position.z=this.stayInsideBounds?Math.min(Math.max(t,this.minZoomAltitude*this.zoomFactor),this.maxZoomAltitude*this.zoomFactor):t,this.publish("zoom-updated"),this.zoomDirty=!0,this.publish("change"),this.state===-1&&this.publish("zoom-end"),this.stateDirty=!0};getProjectionScaleFactor=(e,t,i)=>Cn(e,t,i);update=()=>{this.orbit.updateMatrixWorld(),this.lastWheelTime>0&&this.state===3&&this.clock.getElapsedTime()-this.lastWheelTime>.2&&(this.lastWheelTime=0,this.state=-1,this.publish("zoom-end"),this.removeMouseMoveEventListeners())};setPedestal=(e,t=!1,i=!0)=>{typeof e=="number"&&!isNaN(e)&&(this.orbit.position.z=e,t&&(this.publishPedestalChangeEvent(e),this.publish("pedestal-change",{pedestal:e})),this.publish("change"),this.dirty=!0,i&&(this.stateDirty=!0))};dispose=()=>{this.scene.remove(this.cameraPlane),this.destroy()};createCameraPlane=()=>{let e=Ko?2e3:1e10,t=Ko?100:1,i=new Fm(e,e,t,t),o=new wc({color:0,wireframe:Ko,visible:Ko}),r=new Gm(i,o);return this.scene.add(r),r};addEventListeners=()=>{let{domElement:e}=this.renderer;this.addMovingStateListeners(),e.addEventListener("contextmenu",this.onContextMenu,{capture:!1,signal:this.signal}),e.addEventListener("mousedown",this.onMouseDown,{capture:!1,signal:this.signal}),e.addEventListener("wheel",this.onMouseWheel,{capture:!1,passive:!1,signal:this.signal}),e.addEventListener("touchstart",this.onTouchStart,{capture:!1,signal:this.signal}),e.addEventListener("touchend",this.onTouchEnd,{capture:!1,signal:this.signal}),e.addEventListener("touchmove",this.onTouchMove,{capture:!1,signal:this.signal})};addMouseEventListeners=()=>{this.addMouseMoveEventListeners(),window.addEventListener("mouseup",this.onMouseUp,{capture:!1,signal:this.signal}),window.addEventListener("mouseout",this.onWindowMouseOut,{capture:!1,signal:this.signal})};onWindowMouseOut=e=>{e.relatedTarget==null&&this.onMouseUp()};addMouseMoveEventListeners=()=>{window.addEventListener("mousemove",this.onMouseMove,{capture:!0,signal:this.signal})};removeMouseMoveEventListeners=()=>{window.removeEventListener("mousemove",this.onMouseMove,{capture:!0})};removeMouseUpEventListeners=()=>{this.removeMouseMoveEventListeners(),window.removeEventListener("mouseup",this.onMouseUp,{capture:!1}),window.removeEventListener("mouseout",this.onWindowMouseOut,{capture:!1})};onContextMenu=e=>{e.preventDefault()};onMouseUp=()=>{if(this.enabled!==!1){switch(this.removeMouseUpEventListeners(),this.state){case 2:this.publish("pan-end"),this.publish("user-pan-end");break;case 1:this.publish("zoom-end"),this.publish("user-dolly-end");break;case 0:this.publish("rotate-end"),this.publish("user-rotate-end");break;case 8:this.publish("pedestal-end"),this.publish("user-pedestal-end");break}this.state=-1,this.panDirty=!1}};onMouseMove=e=>{if(this.enabled!==!1)if(e.preventDefault(),this.mouseToScene(e),this.state===0){if(this.enableRotate===!1)return;this.handleMouseMoveRotate(e)}else if(this.state===2){if(this.enablePan===!1)return;this.handleMouseMovePan()}else this.state===3?(this.resetZoom=!0,this.state=-1):this.state===8&&this.handleMouseMovePedestal(e)};onTouchStart=e=>{if(this.enabled!==!1){switch(this.updateTouchOrigin(),this.touchToScene(e),e.touches.length){case 1:this.enablePedestal?(this.handleTouchStartPedestal(e),this.state=9):this.enablePan&&(this.handleTouchStartPan(e),this.state=6);break;case 2:this.touch.inputs=new Xo(this.touch.touches[0],this.touch.touches[1]);break;default:this.state=-1}this.state}};onTouchMove=e=>{if(this.enabled!==!1)switch(this.touchToScene(e),e.touches.length){case 2:if(!this.touch.inputs)return;e.preventDefault(),e.stopPropagation();let t={...this.touch.inputs.first},i={...this.touch.inputs.second},o=new we(this.touch.touches[0].x,this.touch.touches[0].y),r=new we(this.touch.touches[1].x,this.touch.touches[1].y);if(this.touch.inputs.update(this.touch.touches[0],this.touch.touches[1]),this.enableRotate&&this.state===4)this.handleTouchMoveTilt(e);else if(this.state===5)this.handleTouchMoveDolly();else if(this.state!==5&&this.touch.inputs.totalDistance>.05){let a=t.y<o.y&&i.y<r.y,l=t.y>o.y&&i.y>r.y;this.enableRotate&&this.state!==4&&(l||a)?(this.handleTouchStartTilt(e),this.state=4):(this.handleTouchStartDolly(),this.state=5)}break;case 1:(this.enablePedestal||this.enablePan)&&(e.preventDefault(),e.stopPropagation()),this.enablePedestal&&this.state===9?this.handleTouchMovePedestal(e):this.enablePan&&this.state===6&&this.handleTouchMovePan(e);break;default:this.state=-1}};onTouchEnd=e=>{if(this.enabled!==!1){switch(this.handleTouchEnd(),this.state){case 2:case 6:this.publish("user-pan-end");break;case 4:this.publish("pan-end"),this.publish("user-tilt-end");break;case 1:case 5:this.publish("zoom-end"),this.publish("user-dolly-end");break;case 0:this.publish("rotate-end"),this.publish("user-rotate-end");break;case 8:case 9:this.publish("pedestal-end"),this.publish("user-pedestal-end");break}e.touches.length?this.onTouchStart(e):this.state=-1}};handleTouchMovePan=e=>{let t=Object.hasOwn(e,"x")?new we(e.x,e.y):this.touch.touches[0],i=this.raycastToFloor(t);this.coords.panEnd.set(i.x,i.y,0),this.coords.panDelta.subVectors(this.coords.panEnd,this.coords.panStart),this.setPosition(this.coords.panCameraStart.x-this.coords.panDelta.x,this.coords.panCameraStart.y-this.coords.panDelta.y),this.panDirty=!0};handleTouchStartDolly=()=>{let e=this.touch.touches[0].x-this.touch.touches[1].x,t=this.touch.touches[0].y-this.touch.touches[1].y;this.zoomStart=this.getZoomAltitude();let i=new we(this.touch.touches[0].x-e/2,this.touch.touches[0].y-t/2);this.coords.floorAnchor=this.raycastToFloor(i),this.orbit.updateMatrixWorld(),this.touch.anchor1=new Hi(this.touch.touches[0],this.camera,this.cameraPlane),this.touch.anchor2=new Hi(this.touch.touches[1],this.camera,this.cameraPlane),this.coords.panCameraStart.set(this.orbit.position.x,this.orbit.position.y,0),this.publish("user-dolly-start"),this.publish("zoom-start"),this.publish("multi-start")};handleMouseMovePan=()=>{let e=this.raycastToFloor(this.coords.mouse);this.coords.panEnd.set(e.x,e.y,0),this.coords.panDelta.subVectors(this.coords.panEnd,this.coords.panStart),this.setPosition(this.coords.panCameraStart.x-this.coords.panDelta.x,this.coords.panCameraStart.y-this.coords.panDelta.y),this.panDirty=!0};handleTouchStartTilt=e=>{this.coords.rotateStart.set(e.touches[1].clientX,e.touches[1].clientY),this.publish("user-tilt-start"),this.publish("rotate-start")};handleTouchMovePedestal=e=>{this.handleMouseMovePedestal(e.touches[0])};handleTouchMoveTilt=e=>{this.coords.rotateEnd.set(e.touches[1].clientX,e.touches[1].clientY),this.coords.rotateDelta.subVectors(this.coords.rotateEnd,this.coords.rotateStart),this.setTilt(this.getTilt()-this.coords.rotateDelta.y/this.rotateSpeed),this.coords.rotateStart.copy(this.coords.rotateEnd)};handleTouchMoveDolly=()=>{let e=this.touch.inputs.first,t=this.touch.inputs.second;this.touch.anchor1.viewCoordinate={x:e.x,y:e.y},this.touch.anchor2.viewCoordinate={x:t.x,y:t.y};let i=this.makeTransformFromTouchAnchors(this.touch.anchor1,this.touch.anchor2);i&&this.setCameraFromTransformMatrix(i),this.orbit.updateMatrixWorld(),this.touch.anchor1.updateAnchorState(this.camera,e),this.touch.anchor2.updateAnchorState(this.camera,t)};handleTouchEnd=()=>{this.state===4||this.state===5?this.publish("multi-end"):this.state===6&&this.publish("pan-end"),this.panDirty=!1};handleTouchStartPan=e=>{let t=Object.hasOwn(e,"x")?new we(e.x,e.y):this.touch.touches[0],i=this.raycastToFloor(t);this.coords.panStart.set(i.x,i.y,0),this.coords.panCameraStart.set(this.orbit.position.x,this.orbit.position.y,0),this.publish("user-pan-start"),this.publish("pan-start")};handleTouchStartPedestal=e=>{this.handleMouseDownPedestal(e.touches[0])};onMouseDown=e=>{if(this.enabled!==!1){if(this.mouseToScene(e),e.preventDefault(),this.state===3&&this.publish("zoom-end"),e.button===this.MOUSE_BUTTONS.ORBIT){if(this.enableRotate===!1)return;this.handleMouseDownRotate(e),this.state=0}else(e.button===this.MOUSE_BUTTONS.PAN||e.button===this.MOUSE_BUTTONS.ZOOM)&&(this.enablePan?(this.handleMouseDownPan(),this.state=2):this.enablePedestal&&(this.handleMouseDownPedestal(e),this.state=8));this.state!==-1&&this.addMouseEventListeners()}};onMouseWheel=e=>{this.enabled===!1||this.enableZoom===!1||this.state!==-1&&this.state!==3&&this.state!==7||(this.state===7&&this.cancelAnimation(),e.preventDefault(),e.stopPropagation(),this.mouseToScene(e),this.canScrollZoom(e)&&(this.lastWheelTime=this.clock.getElapsedTime(),this.publishUserZoomEvent()),this.state!==3&&this.canScrollZoom(e)&&(this.addMouseMoveEventListeners(),this.state=3,this.zoomStart=this.getZoomAltitude(),this.coords.floorAnchor=this.raycastToFloor(this.coords.mouse),this.coords.panCameraStart.set(this.orbit.position.x,this.orbit.position.y,0),this.publish("zoom-start")),this.scrollTimer!=null&&clearTimeout(this.scrollTimer),this.scrollTimer=setTimeout(()=>{this.publish("zoom-end")},50),this.handleMouseWheel(e))};handleMouseWheel=e=>{if(this.publish("zoom-start"),!this.canScrollZoom(e)){this.lastWheelTime>0&&this.publish("zoom-end"),this.lastWheelTime=0,this.state=-1;return}let t=this.getZoomAltitude(),i=t-na(e)*t/ca*this.zoomSpeed;if(this.setZoomAltitude(i),this.enablePan){let o=this.getZoomAltitude()/this.zoomStart;this.coords.panDelta.subVectors(this.coords.floorAnchor,this.coords.panCameraStart).multiplyScalar(1-o),this.setPosition(this.coords.panCameraStart.x+this.coords.panDelta.x,this.coords.panCameraStart.y+this.coords.panDelta.y)}this.publish("change")};setCameraFromTransformMatrix=e=>{this.orbit.updateMatrixWorld();let t=new Bm;t.setFromRotationMatrix(e,"ZYX");let i=(e.elements[14]-this.cameraPlane.position.z)/Math.cos(t.x),o=t.z,r=new te(0,0,1);r.applyEuler(t),r.setLength(i);let a=new te;a.setFromMatrixPosition(e),a.sub(r),this.enablePan&&this.setPosition(a.x,a.y),this.enableZoom&&this.setZoomAltitude(i),this.enableRotate&&this.setRotation(-o)};makeTransformFromTouchAnchors=(e,t)=>{this.orbit.updateMatrixWorld(),this.camera.updateProjectionMatrix();let i=this.camera.projectionMatrix.clone(),o=e.worldCoordinate,r=t.worldCoordinate,a=e.reUnproject(),l=t.reUnproject();if(!a||!l||!o||!r)return null;let s=e.viewCoordinate,c=t.viewCoordinate,h=r.x-o.x,d=r.y-o.y,u=Math.atan2(d,h),m=l.x-a.x,v=l.y-a.y,b=Math.atan2(v,m),p=Sc(u,b),x=new Dc;x.makeRotationZ(-p);let f=x.clone();f.multiply(e.snapHolderMatrix);let y=(J,ie,Ee)=>J.elements[(ie-1)*4+Ee-1],C=y(i,1,1)*y(f,1,1)-s.x*y(i,3,4)*y(f,3,1),M=y(i,1,1)*y(f,1,2)-s.x*y(i,3,4)*y(f,3,2),S=y(i,1,1)*y(f,1,3)-s.x*y(i,3,4)*y(f,3,3),T=o.x*C+o.y*M+o.z*S,w=y(i,2,2)*y(f,2,1)-s.y*y(i,3,4)*y(f,3,1),P=y(i,2,2)*y(f,2,2)-s.y*y(i,3,4)*y(f,3,2),L=y(i,2,2)*y(f,2,3)-s.y*y(i,3,4)*y(f,3,3),N=o.x*w+o.y*P+o.z*L,A=y(i,1,1)*y(f,1,1)-c.x*y(i,3,4)*y(f,3,1),G=y(i,1,1)*y(f,1,2)-c.x*y(i,3,4)*y(f,3,2),B=y(i,1,1)*y(f,1,3)-c.x*y(i,3,4)*y(f,3,3),H=r.x*A+r.y*G+r.z*B,j=y(i,2,2)*y(f,2,1)-c.y*y(i,3,4)*y(f,3,1),ne=y(i,2,2)*y(f,2,2)-c.y*y(i,3,4)*y(f,3,2),I=y(i,2,2)*y(f,2,3)-c.y*y(i,3,4)*y(f,3,3),ye=r.x*j+r.y*ne+r.z*I,$e=Math.abs(A-C),Le=Math.abs(G-M),be=Math.abs(B-S),Ae=Math.abs(A-w),Bt=Math.abs(G-P),Ft=Math.abs(B-L),ft=Math.abs(j-C),ci=Math.abs(ne-M),qe=Math.abs(I-S),hi=Math.abs(j-w),xe=Math.abs(ne-P),ze=Math.abs(I-L),Gt=Math.min($e+Le+be,Ae+Bt+Ft),me=Math.min(ft+ci+qe,hi+xe+ze);Gt<me&&(A=j,G=ne,B=I,H=ye);let Se=w*S-C*L,pe=P*S-M*L,Ne=N*S-T*L,fe=A*L-w*B,Z=G*L-P*B,Ue=H*L-N*B,gt=(Ue*pe-Ne*Z)/(fe*pe-Se*Z),K=(Ue*Se-Ne*fe)/(Z*Se-pe*fe),ge=P*C-M*w,sn=L*C-S*w,ln=N*C-T*w,Me=G*w-P*A,yt=B*w-L*A,di=((H*w-N*A)*ge-ln*Me)/(yt*ge-sn*Me),_=f.clone();return _.elements[12]=gt,_.elements[13]=K,_.elements[14]=di,di>0?_:null};updateTouchOrigin=()=>{let e=this.renderer.domElement;this.touch.origin.offsetLeft=e.getBoundingClientRect().left,this.touch.origin.offsetTop=e.getBoundingClientRect().top};touchToScene=e=>{this.touch.touches=[];for(let t=0,i=e.touches.length;t<i;t++){let o=e.touches[t],r=Mc(o,this.touch.origin);this.touch.touches.push(new we(r.x/this.renderer.domElement.width*this.rendererState.pixelRatio*2-1,-(r.y/this.renderer.domElement.height*this.rendererState.pixelRatio)*2+1))}this.coords.mouse=this.touch.touches[0]};canScrollZoom=e=>{let t=na(e),i=this.getZoomAltitude();return!(t<0&&i===this.getZoomScaledMax()||t>0&&i===this.getZoomScaledMin())};mouseToScene=e=>{let t=this.getMousePos(e);return this.coords.mouse.x=t.x/this.renderer.domElement.width*this.rendererState.pixelRatio*2-1,this.coords.mouse.y=-(t.y/this.renderer.domElement.height*this.rendererState.pixelRatio)*2+1,this.coords.mouse};getMousePos=e=>{let t=this.renderer.domElement.getBoundingClientRect();return{x:e.clientX-t.left,y:e.clientY-t.top}};handleMouseDownRotate=e=>{this.coords.rotateStart.set(e.clientX,e.clientY),this.publish("rotate-start"),this.publish("user-rotate-start")};handleMouseDownPan=()=>{let e=this.raycastToFloor(this.coords.mouse);this.coords.panStart.set(e.x,e.y,0),this.coords.panCameraStart.set(this.orbit.position.x,this.orbit.position.y,0),this.publish("pan-start"),this.publish("user-pan-start")};handleMouseDownPedestal=e=>{let t=new we(e.clientX,e.clientY);this.coords.initialShiftPos=t,this.coords.initialPedestal=this.getPedestal(),this.pedestalScaleFactor=Cn(this.camera.fov,this.renderer.domElement.clientHeight,this.getZoomAltitude()),this.publish("pedestal-start"),this.publish("user-pedestal-start")};handleMouseMovePedestal=e=>{let t={x:e.clientX,y:e.clientY},i=this.coords.initialPedestal+this.pedestalScaleFactor*(t.y-this.coords.initialShiftPos.y);this.stayInsideBounds&&(i<this.minPedestal?i=Math.max(i,this.minPedestal):i>this.maxPedestal&&(i=Math.min(i,this.maxPedestal))),i!==this.getPedestal()&&this.setPedestal(i,!0)};handleMouseMoveRotate=e=>{this.coords.rotateEnd.set(e.clientX,e.clientY),this.coords.rotateDelta.subVectors(this.coords.rotateEnd,this.coords.rotateStart),this.setRotation(this.getRotation()+this.coords.rotateDelta.x/this.rotateSpeed),this.setTilt(this.getTilt()-this.coords.rotateDelta.y/this.rotateSpeed),this.coords.rotateStart.copy(this.coords.rotateEnd),this.publish("change")};publishUserZoomDebounced=Je(()=>{this.isUserZooming=!1,this.publish("user-zoom-end")},250);publishUserZoomEvent=()=>{this.isUserZooming?this.publishUserZoomDebounced():(this.publish("user-zoom-start"),this.isUserZooming=!0,this.publishUserZoomDebounced())};setCameraMoving=()=>{this.cameraMoving=!0};unsetCameraMoving=()=>{this.cameraMoving=!1,this.lastCameraMoveTime=Date.now()};setUserInteracting=()=>{this.userInteracting=!0};unsetUserInteracting=()=>{this.userInteracting=!1};publishPedestalChangeEvent=e=>{this.publish("pedestal-change",{pedestal:e,scrolledToTop:this.scrolledToTop,scrolledToBottom:this.scrolledToBottom,scrollPercent:this.scrollPercent})};convertAltitudeToZoomLevel=e=>{let[,t]=this.center,i=this.computeMetersPerPixelFromAltitude(e),o=Math.cos(st.degToRad(t))*2*Math.PI*dn/i;return st.clamp(Math.log2(o/512),$o,qo)};convertZoomLevelToAltitude=e=>this.computeMetersPerPixelFromZoomLevel(e)*this.options.canvasHeight/2/Math.tan(st.degToRad(this.camera.fov)/2);completeTween=e=>{e.isPlaying()&&e.stop(),this.rendererState.internalTweenGroup.remove(e),this.tweens.delete(e)};static CAMERA_FRAME_PADDING_SIDES=["top","bottom","left","right"];debugContainer=new _m;getCameraFrameForCoordinates(e,t){let i=t.minZoom!==void 0?t.minZoom:this.minZoomAltitude,o=t.maxZoom!==void 0?t.maxZoom:this.maxZoomAltitude,r=this.options.canvasWidth,a=this.options.canvasHeight,l=this.getRotation(),s=this.getTilt(),c=this.getPosition();this.setRotation(t.rotation??l,!0),this.setTilt(t.tilt??s,!0);let h=pa(e,{canvasWidth:r,canvasHeight:a,paddingOption:t.padding,verticalPadding:t.verticalPadding,minZoom:i,maxZoom:o,position:c,camera:this.camera,orbit:this.orbit});return this.setRotation(l,!0),this.setTilt(s,!0),{center:h.position,zoomLevel:this.convertAltitudeToZoomLevel(h.zoom)}}focusOn(e,t){if(Wm){this.debugContainer&&oe(this.debugContainer);let b=new Hm(4,4,4),p=new wc({color:R(65280),depthTest:!1}),x=new Um(b,p,e.length),f=new Dc;e.forEach((y,C)=>{f.setPosition(y),x.setMatrixAt(C,f)}),x.instanceMatrix.needsUpdate=!0,this.debugContainer.add(x),this.scene.add(this.debugContainer)}let i=t.curve,o=t.callback,r=t.cancelledCallback,a=t.minZoom!==void 0?t.minZoom:this.minZoomAltitude,l=t.maxZoom!==void 0?t.maxZoom:this.maxZoomAltitude,s=this.options.canvasWidth,c=this.options.canvasHeight,h;t.duration!==void 0?h=t.duration:D.env.TESTING==="true"?h=0:h=ha;let d=t.padding,u=this.getRotation(),m=this.getTilt();t.rotation!=null&&this.setRotation(t.rotation),t.tilt!=null&&this.setTilt(t.tilt);let v=pa(e,{canvasHeight:c,paddingOption:d,canvasWidth:s,minZoom:a,maxZoom:l,camera:this.camera,orbit:this.orbit,position:this.getPosition(),verticalPadding:t.verticalPadding});this.setRotation(u),this.setTilt(m),this.animateCamera({position:v.position,tilt:t.tilt,rotation:t.rotation,zoom:v.zoom},h,i,o,r,t)}resize(e,t){this.options.canvasWidth=e,this.options.canvasHeight=t}computeMetersPerPixelFromZoomLevel(e){let[,t]=this.center,i=st.clamp(e,$o,qo),o=Math.pow(2,i),r=st.clamp(t,aa,sa),a=o*512;return Math.cos(st.degToRad(r))*Math.PI*2*dn/a}computeMetersPerPixelFromAltitude(e){return e*2*Math.tan(st.degToRad(this.camera.fov)/2)/this.options.canvasHeight}getCurrentMetersPerPixel(){let e=Math.max(0,this.getPedestal()-this.minPedestal);return this.computeMetersPerPixelFromAltitude(this.getZoomAltitude()+e)}};function pa(n,{canvasWidth:e,orbit:t,paddingOption:i,verticalPadding:o=0,canvasHeight:r,minZoom:a,maxZoom:l,camera:s,position:c}){let h={zoom:a,position:c};if(n.length===0)return h;for(let pe of Kt.CAMERA_FRAME_PADDING_SIDES)typeof i[pe]!="number"&&(i[pe]=0);let d=at(i,e,r);if(d.left+d.right>=e||d.top+d.bottom>=r)return h;t.updateMatrixWorld();let u=s.matrixWorldInverse,m=s.fov*(Math.PI/180)/2,v=m,p=Math.atan(Math.tan(m)*(e/r)),x=new te(1/0,1/0,1/0),f=new te(-1/0,-1/0,-1/0),y=new Nm,C=new te;for(let pe=0,Ne=n.length;pe<Ne;pe++)C.copy(n[pe]),y.expandByPoint(C),C.applyMatrix4(u),x.min(C),f.max(C),C.copy(n[pe]),C.z-=o,C.applyMatrix4(u),x.min(C),f.max(C),C.copy(n[pe]),C.z+=o,C.applyMatrix4(u),x.min(C),f.max(C);let M=f.x-x.x,S=f.y-x.y,T=e-d.left-d.right,w=r-d.top-d.bottom,P=(f.x+x.x)/2,L=(f.y+x.y)/2,N=M/T,A=S/w,G=a,B=l,H=G*Math.tan(p)*2,j=B*Math.tan(p)*2,ne=H/e,I=j/e,ye=Math.max(N,A);ye=st.clamp(ye,ne,I);let $e=T*ye,Le=w*ye,be={min:{x:P-$e/2-d.left*ye,y:L-Le/2-d.bottom*ye},max:{x:P+$e/2+d.right*ye,y:L+Le/2+d.top*ye}},Ae=(be.min.x+be.max.x)/2,Bt=(be.min.y+be.max.y)/2,Ft=y.getCenter(new te),ft=Math.abs(Ae-be.min.x),ci=Math.abs(Bt-be.min.y),qe=ft/Math.tan(p),hi=ci/Math.tan(v),xe=new te;xe.set(Ae,Bt,f.z+Math.max(qe,hi)),xe.applyMatrix4(s.matrixWorld);let ze=new te;ze.set(Ae,Bt,f.z),ze.applyMatrix4(s.matrixWorld);let Gt=new te().subVectors(ze,xe),me=(Ft.z-xe.z)/Gt.z,Se=new te().copy(xe).add(Gt.clone().multiplyScalar(me));return ze.set(Se.x,Se.y,Se.z),xe.sub(ze),{position:Se,zoom:xe.length()}}g();import{Color as Vm,Vector3 as jm}from"three";import{z as W}from"zod";var Zm=W.object({rotation:W.array(W.number()).length(3).optional(),altitude:W.number().optional(),scale:W.array(W.number()).length(3).optional(),interactive:W.boolean().optional(),verticalOffset:W.number().optional(),id:W.union([W.number(),W.string()]).optional()}),Xm=W.object({type:W.enum(["Feature"]),geometry:$t,properties:Zm}),Ym=W.object({type:W.enum(["FeatureCollection"]),features:W.array(Xm)}),$m=W.object({color:W.string()}),qm=W.object({url:W.string(),color:W.string().optional(),opacity:W.number().optional(),material:W.record(W.string(),$m).optional()});function Tc(n,e,t){W.union([W.number(),W.string()]).parse(n),Ym.parse(e),qm.parse(t)}var Et=class{mesh;meshContainer=null;type="model";positionDirty=!0;outline;geometry;material;feature;instanceIndex=-1;instancingDisabled=!1;constructor(e){this.feature=e}#e=!0;get visible(){return this.#e}set visible(e){this.#e=e}color=new Vm;clippingPlane;get modelScene(){return this.clippingPlane?this.mesh?.children.find(e=>e.name!=="hole-fill-mesh"):this.mesh}position=new jm;#o=0;get altitude(){return this.#o}set altitude(e){this.#o=e}#n=1;get opacity(){return this.#n}set opacity(e){this.#n=e}#r=Q.GEOMETRY;get renderOrder(){return this.#r}set renderOrder(e){this.#r=e}#a=!1;get visibleThroughGeometry(){return this.#a}set visibleThroughGeometry(e){this.#a=e}};g();import{Box3 as lp,MathUtils as Te,Vector3 as cp}from"three";g();import{Box3 as Km,BoxGeometry as Jm,EdgesGeometry as Qm,InstancedMesh as ep,LineBasicMaterial as tp,LineSegments as ip,Matrix4 as op,MeshBasicMaterial as rp,Object3D as np,Quaternion as ap,SphereGeometry as sp,Vector2 as Ec,Vector3 as Pc}from"three";var Pt={container:{position:"absolute",top:"0",left:"0",width:"100%",height:"100%",pointerEvents:"none",zIndex:"9998"},focusOnBox:{position:"absolute",border:"2px solid orange",backgroundColor:"transparent",pointerEvents:"none"},getFocusOnTransformBox:{position:"absolute",border:"2px dashed cyan",backgroundColor:"rgba(0, 255, 255, 0.1)",pointerEvents:"none"},animateToBox:{position:"absolute",width:"12px",height:"12px",border:"2px solid lime",backgroundColor:"rgba(0, 255, 0, 0.3)",borderRadius:"50%",transform:"translate(-50%, -50%)",pointerEvents:"none"},label:{position:"absolute",fontSize:"10px",fontFamily:"monospace",color:"white",backgroundColor:"rgba(0, 0, 0, 0.7)",padding:"2px 4px",borderRadius:"2px",whiteSpace:"nowrap"}},fa={container:{position:"absolute",top:"0",left:"0",width:"100%",height:"100%",pointerEvents:"none",zIndex:"9999"},top:{position:"absolute",top:"0",left:"0",right:"0",backgroundColor:"rgba(255, 0, 0, 0.2)",borderBottom:"2px dashed rgba(255, 0, 0, 0.6)"},bottom:{position:"absolute",bottom:"0",left:"0",right:"0",backgroundColor:"rgba(0, 255, 0, 0.2)",borderTop:"2px dashed rgba(0, 255, 0, 0.6)"},left:{position:"absolute",top:"0",bottom:"0",left:"0",backgroundColor:"rgba(0, 0, 255, 0.2)",borderRight:"2px dashed rgba(0, 0, 255, 0.6)"},right:{position:"absolute",top:"0",bottom:"0",right:"0",backgroundColor:"rgba(255, 255, 0, 0.2)",borderLeft:"2px dashed rgba(255, 255, 0, 0.6)"},label:{position:"absolute",fontSize:"10px",fontFamily:"monospace",color:"white",backgroundColor:"rgba(0, 0, 0, 0.7)",padding:"2px 4px",borderRadius:"2px"}},Jo=class n{#e;#o;#n=!1;#r=null;#a=null;#s=null;#l=null;#h=null;#p=null;#i=null;#d=null;#t=!1;#g=new Map;#u=!1;#c=new Map;#v=!1;static#x={};#S=!1;#f=null;#y=null;#b=null;#M=null;constructor(e,t){this.#e=e,this.#o=t}showCameraTargets(){this.#n||(this.#n=!0,this.#_(),this.#B())}hideCameraTargets(){this.#n&&(this.#n=!1,this.#F(),this.#I())}setFocusOnPointCloud(e,t,i){!this.#n&&!this.#t||(this.#n&&(this.#h=e.map(o=>o.clone()),this.#L()),this.#G(e,t,i))}setGetFocusOnTransformPointCloud(e,t,i){!this.#n&&!this.#t||(this.#n&&(this.#p=e.map(o=>o.clone()),this.#L()),this.#G(e,t,i))}setAnimateToPosition(e){this.#n&&(this.#i=e.clone(),this.#L())}#_(){let e=this.#e.container;if(!e)return;this.#r=document.createElement("div"),this.#r.dataset.debugCameraTargets="true",Object.assign(this.#r.style,Pt.container),this.#a=document.createElement("div"),this.#a.dataset.debugType="focusOn",Object.assign(this.#a.style,Pt.focusOnBox),this.#a.style.display="none";let t=document.createElement("span");Object.assign(t.style,Pt.label),t.style.top="-20px",t.style.left="0",t.style.color="orange",t.textContent="focusOn",this.#a.appendChild(t),this.#s=document.createElement("div"),this.#s.dataset.debugType="getFocusOnTransform",Object.assign(this.#s.style,Pt.getFocusOnTransformBox),this.#s.style.display="none";let i=document.createElement("span");Object.assign(i.style,Pt.label),i.style.top="-20px",i.style.left="0",i.style.color="cyan",i.textContent="getFocusOnTransform",this.#s.appendChild(i),this.#l=document.createElement("div"),this.#l.dataset.debugType="animateTo",Object.assign(this.#l.style,Pt.animateToBox),this.#l.style.display="none";let o=document.createElement("span");Object.assign(o.style,Pt.label),o.style.top="-20px",o.style.left="50%",o.style.transform="translateX(-50%)",o.style.color="lime",o.textContent="animateTo",this.#l.appendChild(o),this.#r.appendChild(this.#a),this.#r.appendChild(this.#s),this.#r.appendChild(this.#l),e.appendChild(this.#r)}#I(){this.#r&&(this.#r.remove(),this.#r=null),this.#a=null,this.#s=null,this.#l=null}#B(){this.#d=this.#e.on("post-render",()=>{this.#L()})}#F(){this.#d!==null&&(this.#d(),this.#d=null)}#w(e){let t=1/0,i=1/0,o=-1/0,r=-1/0,a=new Ec;for(let l of e)this.#e.project(a,l),a.x!==-1e3&&(t=Math.min(t,a.x),i=Math.min(i,a.y),o=Math.max(o,a.x),r=Math.max(r,a.y));return t!==1/0?{minX:t,minY:i,maxX:o,maxY:r}:null}#T(e,t){if(!t||t.length===0){e.style.display="none";return}let i=this.#w(t);i?(e.style.display="block",e.style.left=`${i.minX}px`,e.style.top=`${i.minY}px`,e.style.width=`${i.maxX-i.minX}px`,e.style.height=`${i.maxY-i.minY}px`):e.style.display="none"}#L(){if(!(!this.#n||!this.#r))if(this.#a&&this.#T(this.#a,this.#h),this.#s&&this.#T(this.#s,this.#p),this.#l&&this.#i){let e=new Ec;this.#e.project(e,this.#i),e.x!==-1e3?(this.#l.style.display="block",this.#l.style.left=`${e.x}px`,this.#l.style.top=`${e.y}px`):this.#l.style.display="none"}else this.#l&&(this.#l.style.display="none")}showFocusOnDebug(e){if(e===!1){this.hideFocusOnDebug();return}this.#P(this.#g),this.#P(this.#c),this.#t=!0,this.#u=e.pointCloud===!1?!1:{size:e.pointCloud?.size??2,color:e.pointCloud?.color??"lime"},this.#v=e.boundingBox===!1?!1:{color:e.boundingBox?.color??"lime"}}hideFocusOnDebug(){this.#t&&(this.#t=!1,this.#u=!1,this.#v=!1,this.#P(this.#g),this.#P(this.#c))}#G(e,t,i){if(!this.#t)return;let o=t??n.#x;this.#u!==!1&&this.#C(e,o,i),this.#v!==!1&&this.#z(e,o,i)}#C(e,t,i){let o=this.#e.getThreeScene();if(!o||e.length===0){this.#E(this.#g,t);return}if(this.#u===!1)return;let{size:r,color:a}=this.#u,l=i??a,s=this.#g.get(t);if(!s||s.count!==e.length){this.#E(this.#g,t);let h=new sp(r,8,6),d=new rp({color:R(l),depthTest:!1,transparent:!0,opacity:.3});s=new ep(h,d,e.length),s.renderOrder=9999,o.add(s),this.#g.set(t,s)}let c=new np;for(let h=0;h<e.length;h++)c.position.copy(e[h]),c.updateMatrix(),s.setMatrixAt(h,c.matrix);s.instanceMatrix.needsUpdate=!0,this.#e.render()}#E(e,t){let i=e.get(t);i&&(this.#e.getThreeScene()?.remove(i),i.geometry.dispose(),i.material.dispose(),e.delete(t))}#P(e){let t=this.#e.getThreeScene();for(let i of e.values())t?.remove(i),i.geometry.dispose(),i.material.dispose();e.clear()}#z(e,t,i){let o=this.#e.getThreeScene();if(!o||e.length===0){this.#E(this.#c,t);return}if(this.#v===!1)return;let r=i??this.#v.color,a=this.#e.getThreeCamera(),l=a.matrixWorldInverse,s=e.map(y=>y.clone().applyMatrix4(l)),c=new Km().setFromPoints(s),h=c.getSize(new Pc),d=c.getCenter(new Pc),u=new op().copy(l).invert(),m=d.applyMatrix4(u),v=new ap().setFromRotationMatrix(a.matrixWorld);this.#E(this.#c,t);let b=new Jm(h.x,h.y,h.z),p=new Qm(b);b.dispose();let x=new tp({color:R(r),depthTest:!1,transparent:!0,opacity:.5}),f=new ip(p,x);f.position.copy(m),f.quaternion.copy(v),f.renderOrder=9999,o.add(f),this.#c.set(t,f),this.#e.render()}showScreenOffsets(){this.#S||(this.#S=!0,this.#N())}hideScreenOffsets(){this.#S&&(this.#S=!1,this.#k())}#N(){let e=this.#e.container;if(!e)return;this.#f=document.createElement("div"),this.#f.dataset.debugScreenOffsets="true",Object.assign(this.#f.style,fa.container);let t=i=>{let o=document.createElement("div");o.dataset.debugOffset=i,Object.assign(o.style,fa[i]);let r=document.createElement("span");switch(Object.assign(r.style,fa.label),r.dataset.debugLabel=i,i){case"top":r.style.bottom="4px",r.style.left="50%",r.style.transform="translateX(-50%)";break;case"bottom":r.style.top="4px",r.style.left="50%",r.style.transform="translateX(-50%)";break;case"left":r.style.right="4px",r.style.top="50%",r.style.transform="translateY(-50%)";break;case"right":r.style.left="4px",r.style.top="50%",r.style.transform="translateY(-50%)";break}return o.appendChild(r),o};this.#y={top:t("top"),bottom:t("bottom"),left:t("left"),right:t("right")},this.#f.appendChild(this.#y.top),this.#f.appendChild(this.#y.bottom),this.#f.appendChild(this.#y.left),this.#f.appendChild(this.#y.right),e.appendChild(this.#f),this.#D(),this.#M=this.#o.on("padding-change",()=>{this.#D()}),this.#b=new ResizeObserver(()=>{this.#D()}),this.#b.observe(e)}#k(){this.#M&&(this.#M(),this.#M=null),this.#b&&(this.#b.disconnect(),this.#b=null),this.#f&&(this.#f.remove(),this.#f=null),this.#y=null}#D(){if(!this.#y||!this.#f)return;let e=this.#o.insetsPadding,t=this.#e.container,i=t.clientWidth,o=t.clientHeight,r=at(e,i,o),a=this.#y.top,l=a.querySelector("[data-debug-label]");r.top>0?(a.style.height=`${r.top}px`,a.style.display="block",l&&(l.textContent=`top: ${this.#O(e.top,e.type)}`)):a.style.display="none";let s=this.#y.bottom,c=s.querySelector("[data-debug-label]");r.bottom>0?(s.style.height=`${r.bottom}px`,s.style.display="block",c&&(c.textContent=`bottom: ${this.#O(e.bottom,e.type)}`)):s.style.display="none";let h=this.#y.left,d=h.querySelector("[data-debug-label]");r.left>0?(h.style.height="",h.style.top=`${r.top}px`,h.style.bottom=`${r.bottom}px`,h.style.width=`${r.left}px`,h.style.display="block",d&&(d.textContent=`left: ${this.#O(e.left,e.type)}`)):h.style.display="none";let u=this.#y.right,m=u.querySelector("[data-debug-label]");r.right>0?(u.style.height="",u.style.top=`${r.top}px`,u.style.bottom=`${r.bottom}px`,u.style.width=`${r.right}px`,u.style.display="block",m&&(m.textContent=`right: ${this.#O(e.right,e.type)}`)):u.style.display="none"}#O(e,t){return t==="portion"?`${(e*100).toFixed(1)}%`:`${e}px`}destroy(){this.hideCameraTargets(),this.hideScreenOffsets(),this.hideFocusOnDebug()}};var hp=0,dp=90,up=(D.env.NODE_ENV==="test",!1),Qo={linear:vt.Linear.None,"ease-in":vt.Quadratic.In,"ease-out":vt.Quadratic.Out,"ease-in-out":vt.Quadratic.InOut},mp=-50,er=class extends z{#e;#o;#n;#r;constructor(e,t,i){super(),this.#e=e,this.#o=t,this.#n=i,this.#r=new Jo(e,this),this.#e.map&&this.#e.map.transform.setMinElevationForCurrentTile(mp),this.#o.cameraSystem.on("pedestal-change",({pedestal:o})=>{this.#o.cameraSystem.setCameraPlaneElevation(o),this.#e.mode==="outdoors-overlay"&&typeof this.#e.map?.setCenterElevation=="function"&&this.#e.map.setCenterElevation(this.#o.cameraSystem.getPedestal())})}get center(){return this.#e.mode==="outdoors-overlay"&&this.#e.map?this.#e.map.getCenter?.().toArray():this.#o.cameraSystem.center}setCenter(e){if(this.#e.mode==="outdoors-overlay"&&this.#e.map){this.#e.map?.setCenter(e),this.#o.interactionSystem.handleHover();return}this.#o.cameraSystem.setCenter(e[0],e[1]),this.#o.interactionSystem.handleHover()}batch(e){this.#e.batchCameraChanges(e)}get zoomLevel(){return this.#e.mode==="outdoors-overlay"&&this.#e.map?this.#e.map?.getZoom():this.#o.cameraSystem.getZoomLevel()}setZoomLevel(e){this.#e.mode==="outdoors-overlay"&&this.#e.map&&this.#e.map?.setZoom(e),this.#o.cameraSystem.setZoomLevel(Ce(e,this.minZoomLevel,this.maxZoomLevel,"zoomLevel was clamped to minZoomLevel/maxZoomLevel bounds. Use mapView.Camera.setMinZoomLevel() and mapView.Camera.setMaxZoomLevel() to adjust limits."))}getState(){return{zoomLevel:this.zoomLevel,minZoomLevel:this.minZoomLevel,maxZoomLevel:this.maxZoomLevel,minPitch:this.minPitch,maxPitch:this.maxPitch,autoMinZoomLevel:this.autoMinZoomLevel,panMode:this.panMode,screenOffsets:this.insetsPadding,center:this.center,bearing:this.bearing,pitch:this.pitch,elevation:this.elevation}}get isAnimating(){return this.#o.cameraSystem.isAnimating}cancelAnimation(){this.#o.cameraSystem.cancelAnimation()}get maxZoomLevel(){return this.#o.cameraSystem.maxZoomLevel}get minZoomLevel(){return this.#o.cameraSystem.minZoomLevel}setAutoMinZoomLevel(e){this.#o.panBoundsSystem.autoMinZoomLevel=e,e&&(this.#o.panBoundsSystem.dirty=!0,this.#o.panBoundsSystem.update())}get autoMinZoomLevel(){return this.#o.panBoundsSystem.autoMinZoomLevel}setMinZoomLevel(e,t=!1){t&&this.setAutoMinZoomLevel(!1);let i=Ce(e,De.MIN_MERCATOR_ZOOM_LEVEL,this.maxZoomLevel,`setMinZoomLevel was clamped. minZoomLevel must be between ${De.MIN_MERCATOR_ZOOM_LEVEL} and maxZoomLevel.`);this.#o.cameraSystem.setMinZoomLevel(i),this.zoomLevel<i&&this.setZoomLevel(i),this.#e.map?.setMinZoom(i)}setMaxZoomLevel(e){let t=Ce(e,this.minZoomLevel,De.MAX_MERCATOR_ZOOM_LEVEL,`setMaxZoomLevel was clamped. maxZoomLevel must be between minZoomLevel and ${De.MAX_MERCATOR_ZOOM_LEVEL}.`);this.#o.cameraSystem.setMaxZoomLevel(t),this.zoomLevel>t&&this.setZoomLevel(t),this.#e.map?.setMaxZoom(t)}get maxPitch(){return this.#e.mode==="outdoors-overlay"&&this.#e.map?this.#e.map?.getMaxPitch?.():Te.radToDeg(this.#o.cameraSystem.maxTilt)}get minPitch(){return this.#e.mode==="outdoors-overlay"&&this.#e.map?this.#e.map?.getMinPitch?.():Te.radToDeg(this.#o.cameraSystem.minTilt)}setMinPitch(e){let t=Math.max(hp,e);this.#e.map?.setMinPitch(t),this.#o.cameraSystem.minTilt=Te.degToRad(t)}setMaxPitch(e){let t=Math.min(dp,e);this.#e.map?.setMaxPitch(t),this.#o.cameraSystem.maxTilt=Te.degToRad(t)}get bearing(){return this.#e.mode==="outdoors-overlay"&&this.#e.map?this.#e.map?.getBearing():Te.radToDeg(this.#o.cameraSystem.getRotation())}setBearing(e){if(this.#e.mode==="outdoors-overlay"&&this.#e.map){this.#e.map?.setBearing(e);return}this.#o.cameraSystem.setRotation(Te.degToRad(e))}get pitch(){return this.#e.mode==="outdoors-overlay"&&this.#e.map?this.#e.map?.getPitch():Te.radToDeg(this.#o.cameraSystem.getTilt())}setPitch(e){if(this.#e.mode==="outdoors-overlay"&&this.#e.map){this.#e.map?.setPitch(e);return}this.#o.cameraSystem.setTilt(Te.degToRad(Ce(e,this.minPitch,this.maxPitch,"pitch was clamped to minPitch/maxPitch bounds. Use mapView.Camera.setMinPitch() and mapView.Camera.setMaxPitch() to adjust limits.")))}get elevation(){return this.#o.cameraSystem.getPedestal()}get maxElevation(){return this.#o.cameraSystem.maxPedestal}setMaxElevation(e){this.#o.cameraSystem.maxPedestal=e,this.elevation>e&&this.setElevation(e)}setElevation(e){let t=Ce(e,-1/0,this.maxElevation,"elevation was clamped to maxElevation. Use mapView.Camera.setMaxElevation() to adjust the limit.");this.#o.cameraSystem.setPedestal(t,!0)}#a;animateElevation(e,t){this.#a&&this.#a.stop();let i=Ce(e,-1/0,this.maxElevation,"animateElevation was clamped to maxElevation. Use mapView.Camera.setMaxElevation() to adjust the limit.");return new Promise(o=>{this.#o.cameraSystem.animateCamera({position:{z:i}},t?.duration||300,Qo[t?.easing||"ease-in-out"],o,o,{interruptible:t?.interruptible??!0})})}get insetsPadding(){return this.#n.insetsPadding}get panMode(){return this.#o.cameraSystem.enablePan===!1&&this.#o.cameraSystem.enablePedestal===!0?"elevation":"default"}setPanMode(e){if(e!=="default"&&e!=="elevation")throw new Error("Invalid pan mode");e!==this.panMode&&(e==="default"?(this.#o.cameraSystem.enablePan=!0,this.#o.cameraSystem.enablePedestal=!1):(this.#o.cameraSystem.enablePan=!1,this.#o.cameraSystem.enablePedestal=!0))}setInsetPadding(e){let t=this.#n.insetsPadding;Object.keys(e).every(i=>e[i]===t[i])||(this.#n.insetsPadding=Object.assign({},t,e),this.publish("padding-change",{padding:this.#n.insetsPadding}))}animateTo(e){let t=e.center?this.#e.convertTo3DMapPosition(e.center[1],e.center[0],e.center[2]||this.elevation):void 0;if(t&&this.#r.setAnimateToPosition(t),this.#e.mode==="outdoors-overlay"&&this.#e.map)return this.#e.map?.flyTo({center:e.center??this.center,zoom:e.zoomLevel??this.zoomLevel,bearing:e.bearing??this.bearing,pitch:e.pitch??this.pitch,duration:e.duration??600}),Promise.resolve();let i=e.zoomLevel!==void 0?this.#o.cameraSystem.convertZoomLevelToAltitude(Ce(e.zoomLevel,this.minZoomLevel,this.maxZoomLevel,"zoomLevel was clamped to minZoomLevel/maxZoomLevel bounds. Use mapView.Camera.setMinZoomLevel() and mapView.Camera.setMaxZoomLevel() to adjust limits.")):void 0,o=e.bearing!==void 0?Te.degToRad(e.bearing):void 0,r=e.pitch!==void 0?Te.degToRad(Ce(e.pitch,this.minPitch,this.maxPitch,"pitch was clamped to minPitch/maxPitch bounds. Use mapView.Camera.setMinPitch() and mapView.Camera.setMaxPitch() to adjust limits.")):void 0;return new Promise(a=>{this.#o.cameraSystem.animateCamera({position:t,zoom:i,rotation:o,tilt:r},e.duration||0,Qo[e.easing||"ease-in-out"],()=>{this.#o.interactionSystem.handleHover(),a()},a,{interruptible:e?.interruptible??!0})})}getCameraFrameForCoordinates(e,t){let i=this.#s(t||{},()=>Promise.resolve()),{pointCloud:o}=Oc(e,this.#e,this.#n.geometry3DMap);if(o.length===0)return E.error("No valid coordinates found in targets:",e),{center:this.center,zoomLevel:this.zoomLevel};this.#r.setGetFocusOnTransformPointCloud(o,t?.debugKey,t?.debugColor);let{center:r,zoomLevel:a}=this.#o.cameraSystem.getCameraFrameForCoordinates(o,i);return{center:this.#e.convert3DMapPositionToCoordinate(r),zoomLevel:a}}#s(e,t){return{minZoom:e?.maxZoomLevel===void 0?void 0:this.#o.cameraSystem.convertZoomLevelToAltitude(Ce(e.maxZoomLevel,this.minZoomLevel,this.maxZoomLevel,"maxZoomLevel was clamped to minZoomLevel/maxZoomLevel bounds. Use mapView.Camera.setMaxZoomLevel() to adjust limits.")),maxZoom:e?.minZoomLevel===void 0?void 0:this.#o.cameraSystem.convertZoomLevelToAltitude(Ce(e.minZoomLevel,this.minZoomLevel,this.maxZoomLevel,"minZoomLevel was clamped to minZoomLevel/maxZoomLevel bounds. Use mapView.Camera.setMinZoomLevel() to adjust limits.")),padding:e?.padding?Object.assign({},xi,e?.padding):this.insetsPadding,curve:Qo[e?.easing||"ease-in-out"],rotation:e?.bearing===void 0?void 0:Te.degToRad(e.bearing),tilt:e?.pitch!==void 0?Te.degToRad(Ce(e.pitch,this.minPitch,this.maxPitch,"pitch was clamped to minPitch/maxPitch bounds. Use mapView.Camera.setMinPitch() and mapView.Camera.setMaxPitch() to adjust limits.")):void 0,duration:e?.duration,callback:()=>{this.#o.interactionSystem.handleHover(),t()},cancelledCallback:t,interruptible:e?.interruptible??!0,verticalPadding:e?.verticalPadding}}focusOn(e,t){let{pointCloud:i,geoBounds:o,firstPosition:r}=Oc(e,this.#e,this.#n.geometry3DMap);if(i.length===0)return E.error("No valid coordinates found in targets:",e),Promise.resolve();if(this.#r.setFocusOnPointCloud(i,t?.debugKey,t?.debugColor),this.#e.mode==="outdoors-overlay"&&this.#e.map){let a=at(t?.padding?Object.assign({},xi,t.padding):this.insetsPadding,this.#e.canvasWidth,this.#e.canvasHeight),l={top:a.top,bottom:a.bottom,left:a.left,right:a.right};return i.length===1&&r?this.#e.map?.flyTo({center:[r[0],r[1]],duration:t?.duration??De.DEFAULT_ANIMATION_DURATION,animate:!0,padding:l,bearing:t?.bearing===void 0?this.#e.map.getBearing():t?.bearing,pitch:t?.pitch===void 0?this.#e.map.getPitch():t?.pitch,zoom:t?.maxZoomLevel||this.#e.map.getMaxZoom()}):(up&&pp(this.#e,o),this.#e.map?.fitBounds(o,{duration:t?.duration??De.DEFAULT_ANIMATION_DURATION,padding:l,bearing:t?.bearing===void 0?this.#e.map.getBearing():t?.bearing,pitch:t?.pitch===void 0?this.#e.map.getPitch():t?.pitch,maxZoom:t?.maxZoomLevel??this.#e.map.getMaxZoom()})),this.#o.interactionSystem.handleHover(),Promise.resolve()}return new Promise(a=>{this.#o.cameraSystem.focusOn(i,this.#s(t||{},a))})}showCameraTargetsDebug(){this.#r.showCameraTargets()}hideCameraTargetsDebug(){this.#r.hideCameraTargets()}showFocusOnDebug(e){this.#r.showFocusOnDebug(e)}hideFocusOnDebug(){this.#r.hideFocusOnDebug()}showScreenOffsetsDebug(){this.#r.showScreenOffsets()}hideScreenOffsetsDebug(){this.#r.hideScreenOffsets()}destroy(){this.#r.destroy(),super.destroy()}};function ga(n,e){n[0]=Math.min(n[0],e[0]),n[1]=Math.min(n[1],e[1]),n[2]=Math.max(n[2],e[0]),n[3]=Math.max(n[3],e[1])}function Oc(n,e,t){let i=[],o=[1/0,1/0,-1/0,-1/0],r=null;if(!n||!Array.isArray(n)||n.length===0)return{pointCloud:i,geoBounds:o,firstPosition:r};let a=e.getSystems().renderSystem;for(let l of n)if(typeof l=="string"){(a.threeDdirty||a.twoDdirty)&&e.renderSync();let s=t.get(l);if(!s){E.error("Entity not found with id:",l);continue}let c=new lp;$s(e,"userData"in s?s.userData.entityId??s.id:s.id,i,c,s instanceof $?s.position.z:void 0);let h=e.convert3DMapPositionToCoordinate(c.min),d=e.convert3DMapPositionToCoordinate(c.max);ga(o,h),ga(o,d),r||(r=e.convert3DMapPositionToCoordinate(c.getCenter(new cp)))}else i.push(e.convertTo3DMapPosition(l[1],l[0],l[2]||0)),ga(o,l),r||(r=l);return{pointCloud:i,geoBounds:o,firstPosition:r}}function pp(n,e){let t=[[e[0],e[1]],[e[0],e[3]],[e[2],e[3]],[e[2],e[1]],[e[0],e[1]]];n.map?.getLayer("bounds-outline")&&n.map.removeLayer("bounds-outline"),n.map?.getSource("bounds-source")&&n.map.removeSource("bounds-source"),n.map?.addSource("bounds-source",{type:"geojson",data:{type:"Feature",properties:{},geometry:{type:"LineString",coordinates:t}}}),n.map?.addLayer({id:"bounds-outline",type:"line",source:"bounds-source",layout:{},paint:{"line-color":"#FF0000","line-width":2,"line-opacity":.8}})}g();function Ic(n){n.isLight===!0&&n.layers.enableAll()}function Lc(n){for(let t of n.children)Ic(t);let e=t=>{Ic(t.child)};return n.addEventListener("childadded",e),()=>n.removeEventListener("childadded",e)}g();import{BoxGeometry as xp,Mesh as Nc,MeshBasicMaterial as Sp,PlaneGeometry as Mp,ShaderMaterial as Cp,Vector4 as Dp}from"three";g();var Ac=`uniform vec4 uSize;
147
+ varying vec2 vUv;
148
+ void main() {
149
+ vUv = uv;
150
+ // Scale the position by the size of the quad
151
+ // and shift to top left corner for 0,0
152
+ vec2 transformed = position.xy * uSize.xy - vec2(1.0, -1.0);
153
+ // Apply width .x and height .y of image
154
+ transformed += vec2(uSize.x, -uSize.y);
155
+ // Apply left .w and top .z offset
156
+ transformed += vec2(uSize.w, -uSize.z) * 2.0;
157
+ gl_Position = vec4(transformed, 1.0, 1.0);
158
+ }`;g();var Rc=`varying vec2 vUv;
159
+ uniform sampler2D uTexture;
160
+ uniform float uOpacity;
161
+ void main() {
162
+ #ifndef debug
163
+ vec4 texture = texture2D(uTexture, vUv);
164
+ gl_FragColor = vec4(texture.rgb, texture.a * uOpacity);
165
+ #else
166
+ gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
167
+ #endif
168
+ }`;g();var _c=4.291666666666667,Bc=15,Fc=25,Gc=43/60;g();var kc=["horizontal","icon"],fp=new Map([[kc[0],`<svg viewBox="0 0 206 48">
169
+ <path d="M27.2678 14.2261H22.3187C21.0695 14.2261 20.4695 14.7801 20.4695 15.9852V31.142L10.3966 15.5591C9.69665 14.4784 9.2475 14.2773 7.8475 14.2261H2.97462C1.67462 14.2261 1.07631 14.7801 1.07631 15.9852V44.7665C1.07631 45.9716 1.67462 46.5256 2.97462 46.5256H7.92377C9.22207 46.5256 9.82207 45.9716 9.82207 44.7665V29.6847L19.9441 45.1926C20.695 46.3244 21.095 46.5256 22.4933 46.5256H27.2933C28.5916 46.5256 29.1916 45.9716 29.1916 44.7665V15.9852C29.1407 14.7801 28.5424 14.2261 27.2678 14.2261Z"/>
170
+ <path d="M5.44915 10.9602C8.45863 10.9602 10.8983 8.50669 10.8983 5.48011C10.8983 2.45353 8.45863 0 5.44915 0C2.43967 0 0 2.45353 0 5.48011C0 8.50669 2.43967 10.9602 5.44915 10.9602Z"/>
171
+ <path d="M61.7899 25.0449C63.2306 23.1903 65.078 22.2051 67.556 22.2051C72.0526 22.2051 74.7611 25.3347 74.7611 29.4511V39.2489C74.8187 39.7125 74.5306 39.9443 74.0695 39.9443H72.5136C72.0526 39.9443 71.7645 39.7125 71.8221 39.2489V29.5091C71.8221 27.1909 69.9187 25.2187 67.4984 25.2187C65.1339 25.2187 63.2323 27.1329 63.2323 29.2773V39.2489C63.2899 39.7125 63.0018 39.9443 62.5407 39.9443H60.9831C60.5221 39.9443 60.2916 39.7125 60.2916 39.2489V29.4511C60.2916 27.1329 58.3899 25.2187 56.0255 25.2187C53.7204 25.2187 51.7594 27.075 51.7594 29.2773V39.3068C51.817 39.7705 51.5289 40.0023 51.0102 40.0023H49.5119C49.0509 40.0023 48.7628 39.7705 48.7628 39.3068V23.25C48.7051 22.7864 48.9933 22.4966 49.5119 22.4966H50.9526C51.356 22.4966 51.5289 22.6704 51.5289 23.0182V24.2352C52.7407 22.9602 54.239 22.2648 56.0255 22.2648C58.4475 22.2068 60.3492 23.192 61.7899 25.0466V25.0449ZM77.1255 31.2477C77.1255 26.3216 81.1018 22.2051 86.1187 22.2051C88.539 22.2051 90.6136 23.1903 92.3441 25.1608V23.1903C92.3441 22.7267 92.5746 22.5528 93.0357 22.5528H94.4187C94.8797 22.5528 95.1102 22.7847 95.1102 23.3062V39.3648C95.1102 39.8284 94.8797 40.0602 94.4187 40.0602H93.0357C92.5746 40.0602 92.3441 39.8284 92.3441 39.4227V37.4523C90.6712 39.3648 88.5967 40.35 86.1746 40.35C81.1018 40.2341 77.1238 36.1773 77.1238 31.2477H77.1255ZM92.1136 31.2477C92.1136 27.8284 89.4611 25.2187 86.0594 25.2187C82.7746 25.2187 80.1221 27.8864 80.1221 31.2477C80.1221 34.6687 82.7746 37.2784 86.1187 37.2784C86.9062 37.2789 87.6861 37.1232 88.4138 36.8202C89.1414 36.5173 89.8026 36.0731 90.3593 35.513C90.9161 34.9528 91.3577 34.2878 91.6587 33.556C91.9597 32.8241 92.1143 32.0397 92.1136 31.2477ZM100.992 37.3943V46.3807C101.049 46.8443 100.761 47.1341 100.298 47.1341H98.7424C98.2814 47.1341 97.9933 46.9023 97.9933 46.3807V23.1903C97.9933 22.7267 98.2238 22.4369 98.7424 22.4369H100.183C100.646 22.379 100.934 22.6687 100.934 23.0744V24.9869C102.605 23.0744 104.68 22.1472 107.044 22.1472C112.002 22.1472 116.037 26.2619 116.037 31.1898C116.037 36.1176 112.059 40.2341 107.044 40.2341C104.622 40.2341 102.603 39.3068 100.992 37.3943ZM106.987 25.2187C103.7 25.2187 101.049 27.8864 101.049 31.2477C101.049 34.6687 103.7 37.2784 107.044 37.2784C110.446 37.2784 113.039 34.6108 113.039 31.2477C113.039 27.8864 110.388 25.2187 106.987 25.2187ZM121.11 37.3943V46.3807C121.168 46.8443 120.88 47.1341 120.419 47.1341H118.861C118.4 47.1341 118.112 46.9023 118.112 46.3807V23.1903C118.112 22.7267 118.342 22.4369 118.861 22.4369H120.302C120.764 22.379 121.053 22.6687 121.053 23.0744V24.9869C122.724 23.0744 124.798 22.1472 127.163 22.1472C132.12 22.1472 136.156 26.2619 136.156 31.1898C136.156 36.1176 132.178 40.2341 127.163 40.2341C124.742 40.2341 122.781 39.3068 121.11 37.3943ZM127.105 25.2187C123.819 25.2187 121.168 27.8864 121.168 31.2477C121.168 34.6687 123.819 37.2784 127.163 37.2784C130.564 37.2784 133.158 34.6108 133.158 31.2477C133.158 27.8864 130.507 25.2187 127.107 25.2187H127.105ZM153.97 32.3506H141.054C141.342 35.2483 143.995 37.4523 147.164 37.4523C148.893 37.4523 150.393 37.0466 151.719 36.0597C152.007 35.8858 152.295 35.7699 152.353 35.7699C152.583 35.7699 152.756 35.8858 152.929 36.1773L153.505 37.1625C153.622 37.3364 153.68 37.4523 153.68 37.5682C153.68 37.8 153.507 38.0318 153.103 38.3216C151.258 39.5966 149.183 40.292 146.992 40.292C141.688 40.292 137.883 36.3511 137.883 31.2477C137.883 26.204 141.803 22.2051 146.703 22.2051C151.546 22.2051 154.717 25.7983 154.717 31.0176C154.717 31.5972 154.717 32.3506 153.968 32.3506H153.97ZM141.056 30.0324H151.72C151.432 26.8432 149.473 24.929 146.648 24.929C145.241 24.8904 143.875 25.3995 142.833 26.3501C141.791 27.3007 141.154 28.6194 141.056 30.0307V30.0324ZM156.332 31.2477C156.332 26.3216 160.31 22.2051 165.326 22.2051C167.748 22.2051 169.707 23.1324 171.32 25.0449V16.2324C171.263 15.7687 171.551 15.479 172.012 15.479H173.57C174.031 15.479 174.319 15.7108 174.319 16.2324V39.3068C174.319 39.7705 174.088 40.0023 173.57 40.0023H172.129C171.666 40.0602 171.378 39.7705 171.378 39.3648V37.3943C169.649 39.3068 167.632 40.292 165.268 40.292C160.31 40.2341 156.332 36.1773 156.332 31.2477ZM171.264 31.2477C171.264 27.8284 168.612 25.2187 165.21 25.2187C161.924 25.2187 159.273 27.8864 159.273 31.2477C159.273 34.6687 161.924 37.2784 165.268 37.2784C166.057 37.2838 166.839 37.1316 167.569 36.8304C168.299 36.5292 168.962 36.0852 169.52 35.5241C170.077 34.963 170.519 34.296 170.818 33.5619C171.117 32.8277 171.268 32.0411 171.263 31.2477H171.264ZM177.72 19.0739C177.715 18.8594 177.754 18.646 177.833 18.4468C177.912 18.2476 178.031 18.0667 178.182 17.915C178.333 17.7633 178.512 17.6439 178.71 17.5642C178.909 17.4845 179.121 17.446 179.334 17.4511C179.546 17.4507 179.756 17.4923 179.952 17.5737C180.148 17.6551 180.326 17.7746 180.476 17.9254C180.626 18.0762 180.745 18.2553 180.826 18.4523C180.907 18.6494 180.948 18.8606 180.948 19.0739C180.953 19.2884 180.914 19.5017 180.835 19.7009C180.756 19.9001 180.637 20.081 180.486 20.2327C180.335 20.3845 180.156 20.5038 179.957 20.5835C179.759 20.6633 179.547 20.7017 179.334 20.6966C178.412 20.7545 177.72 20.0591 177.72 19.0739ZM177.836 39.2489V23.1903C177.836 22.7267 178.066 22.4369 178.527 22.4369H180.083C180.544 22.4369 180.832 22.6687 180.775 23.1903V39.2489C180.832 39.7125 180.544 39.9443 180.083 39.9443H178.527C178.066 39.9443 177.836 39.7125 177.836 39.2489ZM186.944 23.0165V24.1756C188.212 22.8426 189.71 22.2051 191.497 22.2051C195.937 22.2051 198.646 25.2767 198.646 29.3932V39.2489C198.703 39.7125 198.415 39.9443 197.954 39.9443H196.398C195.936 39.9443 195.705 39.7125 195.705 39.2489V29.4511C195.705 27.1329 193.803 25.2187 191.439 25.2187C189.134 25.2187 187.175 27.075 187.175 29.2773V39.3068C187.232 39.7705 186.944 40.0023 186.424 40.0023H184.868C184.407 40.0023 184.119 39.7705 184.119 39.3068V23.1903C184.061 22.7267 184.349 22.4949 184.868 22.4949H186.309C186.712 22.4949 186.944 22.6687 186.944 23.0165Z"/>
172
+ <path d="M204 40C205.115 40 206 39.0857 206 38V37.9886C206 36.9029 205.126 36 204 36C202.885 36 202 36.9143 202 38V38.0114C202 39.0971 202.874 40 204 40ZM204 39.7829C202.989 39.7829 202.23 38.9829 202.23 38.0114V38C202.23 37.0286 203 36.2171 204 36.2171C205.011 36.2171 205.77 37.0171 205.77 37.9886V38C205.77 38.9714 205 39.7829 204 39.7829ZM203.218 38.9714H203.609V38.2743H204.034L204.517 38.9714H204.989L204.448 38.2057C204.724 38.1257 204.92 37.92 204.92 37.5886C204.92 37.1657 204.586 36.9486 204.138 36.9486H203.218V38.9714ZM203.609 37.9543V37.2914H204.103C204.368 37.2914 204.517 37.4057 204.517 37.6229C204.517 37.8171 204.368 37.9543 204.103 37.9543H203.609Z"/>
173
+ </svg>`],[kc[1],`<svg viewBox="0 0 43 60">
174
+ <path d="M14.0291 7.06645C14.0291 10.9691 10.8885 14.1329 7.01453 14.1329C3.14051 14.1329 0 10.9691 0 7.06645C0 3.16376 3.14051 0 7.01453 0C10.8885 0 14.0291 3.16376 14.0291 7.06645Z"/>
175
+ <path d="M28.7335 18.3468H35.1045C36.7455 18.3468 37.5178 19.0599 37.5821 20.6158V57.7309C37.5821 59.2868 36.8099 60 35.1367 60H28.9588C27.1569 60 26.642 59.7406 25.6767 58.282L12.6452 38.282V57.7309C12.6452 59.2868 11.8729 60 10.1997 60H3.82873C2.15554 60 1.3833 59.2868 1.3833 57.7309V20.6158C1.3833 19.0599 2.15554 18.3468 3.82873 18.3468H10.1032C11.9051 18.4116 12.4843 18.671 13.3852 20.0648L26.3524 40.162V20.6158C26.3524 19.0599 27.1247 18.3468 28.7335 18.3468Z"/>
176
+ <path d="M41.5 60C42.3362 60 43 59.3143 43 58.5V58.4914C43 57.6771 42.3448 57 41.5 57C40.6638 57 40 57.6857 40 58.5V58.5086C40 59.3229 40.6552 60 41.5 60ZM41.5 59.8371C40.7414 59.8371 40.1724 59.2371 40.1724 58.5086V58.5C40.1724 57.7714 40.75 57.1629 41.5 57.1629C42.2586 57.1629 42.8276 57.7629 42.8276 58.4914V58.5C42.8276 59.2286 42.25 59.8371 41.5 59.8371ZM40.9138 59.2286H41.2069V58.7057H41.5259L41.8879 59.2286H42.2414L41.8362 58.6543C42.0431 58.5943 42.1897 58.44 42.1897 58.1914C42.1897 57.8743 41.9397 57.7114 41.6034 57.7114H40.9138V59.2286ZM41.2069 58.4657V57.9686H41.5776C41.7759 57.9686 41.8879 58.0543 41.8879 58.2171C41.8879 58.3629 41.7759 58.4657 41.5776 58.4657H41.2069Z"/>
177
+ </svg>`]]),gp=/<svg([^>]*)>/g;function zc(n,e,t,i){let o=fp.get(n);return o?o.replace(gp,`<svg$1 width="${t}" height="${i}" xmlns="http://www.w3.org/2000/svg" fill="${e}">`):""}g();import{TextureLoader as yp}from"three";var ya=class n{static instance;loader;constructor(){this.loader=new yp}static getInstance(){return n.instance||(n.instance=new n),n.instance}getLoader(){return this.loader}load(e){return new Promise((t,i)=>{this.loader.load(e,t,void 0,i)})}},lt=ya.getInstance();var Uc=!1,tr=class extends z{#e={padding:16,scale:1,iconOnly:!1,position:"bottom-left",color:"dark",onClick:()=>{window?.open("https://www.mappedin.com")},interactive:!0,visible:!0};#o;#n;#r;#a=void 0;#s=void 0;#l=0;#h=0;dirty=!0;get color(){return this.#e.color==="light"?"white":"#293136"}get iconName(){return this.#e.iconOnly?"icon":"horizontal"}get minWidth(){return this.#e.iconOnly?Bc:75}get defaultWidth(){return this.#e.iconOnly?Fc:150}get aspectRatio(){return this.#e.iconOnly?Gc:_c}get options(){return{...this.#e}}set options(e){this.#e={padding:e.padding||this.#e.padding,position:e.position||this.#e.position,iconOnly:e.iconOnly||this.#e.iconOnly,color:e.color||this.#e.color,scale:e.scale||this.#e.scale,onClick:this.#e.onClick,interactive:e.interactive??this.#e.interactive,visible:e.visible??this.#e.visible}}get icon(){return zc(this.iconName,this.color,this.#l*this.#o.pixelRatio,this.#h*this.#o.pixelRatio)}constructor(e,t,i){super(),i&&Object.entries(i).forEach(([o,r])=>{r!==void 0&&(this.#e[o]=r)}),this.#n=e,this.#o=t}setSize(e,t){this.#a&&(this.#a.uniforms.uSize.value.x=e,this.#a.uniforms.uSize.value.y=t)}setXY(e,t){this.#a&&(this.#a.uniforms.uSize.value.w=e,this.#a.uniforms.uSize.value.z=t)}get width(){return this.#l}get height(){return this.#h}getPositionAlignedOffset(e,t){return{"top-left":{x:0,y:0},"top-right":{x:-e,y:0},"bottom-left":{x:0,y:-t},"bottom-right":{x:-e,y:-t},center:{x:-(e/2),y:-(t/2)},top:{x:-(e/2),y:0},bottom:{x:-(e/2),y:-t},left:{x:0,y:-(t/2)},right:{x:-e,y:-(t/2)}}[this.#e.position]}getPositionAlignedCanvasCoordinates=(e,t)=>({"top-left":{x:0,y:0},"top-right":{x:e,y:0},"bottom-left":{x:0,y:t},"bottom-right":{x:e,y:t},center:{x:e/2,y:t/2},top:{x:e/2,y:0},bottom:{x:e/2,y:t},left:{x:0,y:t/2},right:{x:e,y:t/2}})[this.#e.position];getPositionAlignedPadding=()=>{let e=this.#e.padding;if(typeof e=="number")return{"top-left":{x:e,y:e},"top-right":{x:-e,y:e},"bottom-left":{x:e,y:-e},"bottom-right":{x:-e,y:-e},center:{x:0,y:0},top:{x:0,y:e},bottom:{x:0,y:-e},left:{x:e,y:0},right:{x:-e,y:0}}[this.#e.position];let t={top:e.top??0,right:e.right??0,bottom:e.bottom??0,left:e.left??0};return{x:t.left-t.right,y:t.top-t.bottom}};insertIntoQuadTree(e){this.#s!=null&&typeof this.#e.onClick=="function"&&this.#e.interactive&&e.insert(this.#s)}resize(e,t){if(this.#e.visible!==!0)return;let i=this.getPositionAlignedCanvasCoordinates(e,t),o=this.getPositionAlignedPadding(),r=this.getPositionAlignedOffset(this.#l,this.#h),a=Math.min(e-this.#l,Math.max(0,i.x+o.x+r.x)),l=Math.min(t-this.#h,Math.max(0,i.y+o.y+r.y));this.setSize(this.#l/e,this.#h/t),this.setXY(a/e,l/t),this.#s=new et(a,l,this.#l,this.#h,{entityId:"watermark"})}update(){this.dirty&&(this.#e.visible===!0?(this.#l=Math.min(this.#o.canvasWidth,Math.max(this.minWidth,this.defaultWidth*this.#e.scale)),this.#h=this.#l/this.aspectRatio,lt.getLoader().load(`data:image/svg+xml;base64,${btoa(this.icon)}`,e=>{if(this.#a=new Cp({uniforms:{uTexture:{value:e},uSize:{value:new Dp(0,0,0,0)},uOpacity:{value:.7}},vertexShader:Ac,fragmentShader:Rc,depthWrite:!1,depthTest:!1,defines:{debug:Uc},wireframe:Uc,transparent:!0,visible:!0}),this.#r)this.#r.visible=!0,this.#r.material=this.#a,this.#r.material.needsUpdate=!0;else{let t=new Mp(2,2,1,1);this.#r=new Nc(t,this.#a),this.#r.position.set(0,0,-1),this.#r.frustumCulled=!1,this.#r.renderOrder=999;let i=new xp(1,1,1),o=new Nc(i,new Sp({transparent:!0,opacity:0,depthTest:!1,depthWrite:!1}));o.frustumCulled=!1,o.layers.set(1),this.#r.add(o),this.#n.add(this.#r)}this.resize(this.#o.canvasWidth,this.#o.canvasHeight),this.publish("texture-loaded")})):this.#r&&(this.#r.visible=!1),this.dirty=!1)}destroy(){this.#r&&(this.#n.remove(this.#r),oe(this.#r)),this.#r=void 0,this.#a&&this.#a.dispose(),this.#a=void 0,this.#s=void 0}};g();import{Box3 as ba,BoxGeometry as wp,Mesh as Hc,MeshBasicMaterial as Wc,Object3D as Tp,Scene as Ep,Sphere as Pp,SphereGeometry as Op,Vector3 as Jt}from"three";var ir=100,Ip=!1,rr=class extends z{currentTotalBoundingBox;state;cameraSystem;debugMesh=null;dirty=!0;autoMinZoomLevel=!0;constructor(e,t){super(),this.state=e,this.cameraSystem=t}expandBoundsIfOutside(e){if(this.currentTotalBoundingBox==null){this.dirty=!0;return}this.currentTotalBoundingBox.containsPoint(e)||(this.dirty=!0)}update(){if(this.dirty){this.currentTotalBoundingBox==null&&(this.currentTotalBoundingBox=new ba,this.state.geometryScene.children.length===0?this.currentTotalBoundingBox.setFromCenterAndSize(new Jt(0,0,0),new Jt(ir*2,ir*2,0)):(this.currentTotalBoundingBox.setFromObject(this.state.geometryScene),this.currentTotalBoundingBox.expandByScalar(ir)));let e=new ba().setFromObject(this.state.geometryScene);this.currentTotalBoundingBox.union(e);let t=e.getSize(new Jt),i=Math.max(t.x,t.y,t.z);for(let r of this.state.geometry2DMap.values())r.positionDirty===!0&&(this.currentTotalBoundingBox.expandByPoint(r.position),r.positionDirty=!1);let o=or.copy(this.currentTotalBoundingBox).expandByScalar(Math.max(i,ir)).getBoundingSphere(Lp).radius;if(this.cameraSystem.panBounds={center:this.currentTotalBoundingBox.getCenter(new Jt),min:or.min,max:or.max,radius:o},this.publish("update"),this.cameraSystem.dirty=!0,this.dirty=!1,Ip&&this.state.geometryScene.parent instanceof Ep){this.debugMesh&&(this.state.geometryScene.parent.remove(this.debugMesh),this.debugMesh=null),this.debugMesh=new Tp,this.debugMesh.add(new Hc(new Op(this.cameraSystem.panBounds.radius),new Wc({color:R(16711680),transparent:!0,opacity:.2}))),this.debugMesh.position.copy(this.cameraSystem.panBounds.center),this.state.geometryScene.parent.add(this.debugMesh);let r=new Jt;or.getSize(r);let a=new wp(r.x,r.y,r.z),l=new Wc({color:R(65280),wireframe:!0,transparent:!0,opacity:.5}),s=new Hc(a,l);s.position.copy(this.currentTotalBoundingBox.getCenter(new Jt)),this.debugMesh.add(s)}}}},or=new ba,Lp=new Pp;g();var va="\xA9 Mappedin",Ap="https://info.mappedin.com/feedback",Sa=["top-left","top-right","bottom-left","bottom-right"],Rp=640,_p=()=>`<svg xmlns='http://www.w3.org/2000/svg' width='15' height='15' fill-rule='evenodd' viewBox='0 0 20 20'>
178
+ <circle cx='10' cy='10' r='5.9' fill='rgba(255,255,255,1)'/>
179
+ <path fill='rgba(0,0,0,0.7)' d='M4 10a6 6 0 1 0 12 0 6 6 0 1 0-12 0m5-3a1 1 0 1 0 2 0 1 1 0 1 0-2 0m0 3a1 1 0 1 1 2 0v3a1 1 0 1 1-2 0'/>
180
+ </svg>`,xa={custom:[],position:"bottom-right",feedback:!0},nr=class{controlContainerEl;controlPositions;compact=void 0;#e;attribContainerEl;attribInnerEl;attribButtonEl;feedbackLinkEl;attribHTML=va;customAttributions=[];constructor(e,t={}){this.#e=!!t.outdoorEnabled,this.controlContainerEl=document.createElement("div"),this.controlContainerEl.classList.add("mappedin-control-container"),this.controlContainerEl.style.zIndex="2",e.appendChild(this.controlContainerEl),this.controlPositions=Sa.reduce((i,o)=>{let r=document.createElement("div");return r.classList.add(`mappedin-ctrl-${o}`),this.controlContainerEl.appendChild(r),i[o]=r,i},{})}addAttributionControl(e=xa){let t=e.position&&Sa.includes(e.position)?e.position:xa.position;this.attribContainerEl=document.createElement("details"),this.attribContainerEl.classList.add("mappedin-ctrl-attrib",`mappedin-ctrl-attrib-${t}`),this.attribContainerEl.open=!0,this.attribContainerEl.ariaLabel="Attribution",this.controlPositions[t].appendChild(this.attribContainerEl),this.attribButtonEl=document.createElement("summary"),this.attribButtonEl.addEventListener("click",this.toggleAttribution),this.attribButtonEl.classList.add("mappedin-ctrl-attrib-button"),this.attribButtonEl.title="Toggle attribution",this.attribButtonEl.ariaLabel="Toggle attribution",this.attribButtonEl.tabIndex=0,this.attribButtonEl.innerHTML=_p(),this.attribContainerEl.appendChild(this.attribButtonEl),this.attribInnerEl=document.createElement("div"),this.attribInnerEl.classList.add("mappedin-ctrl-attrib-inner"),this.attribHTML=this.#e?va:"",this.attribInnerEl.innerHTML=this.attribHTML,this.attribContainerEl.appendChild(this.attribInnerEl),(e.feedback??xa.feedback)&&(this.feedbackLinkEl=document.createElement("a"),this.feedbackLinkEl.href=Ap,this.feedbackLinkEl.target="_blank",this.feedbackLinkEl.rel="noopener",this.feedbackLinkEl.textContent="Provide Feedback",this.feedbackLinkEl.classList.add("mappedin-ctrl-attrib-inner"),this.feedbackLinkEl.classList.add("mappedin-ctrl-attrib-inner-bold"),this.attribContainerEl.appendChild(this.feedbackLinkEl)),e.custom&&(this.customAttributions=e.custom),this.updateAttributionDisplay()}toggleAttribution=e=>{this.attribContainerEl!=null&&(e.preventDefault(),this.attribContainerEl.classList.contains("mappedin-compact")&&(this.attribContainerEl.classList.contains("mappedin-compact-show")?(this.attribContainerEl.removeAttribute("open"),this.attribContainerEl.classList.remove("mappedin-compact-show")):(this.attribContainerEl.classList.add("mappedin-compact-show"),this.attribContainerEl.setAttribute("open",""))))};updateAttribution(e){if(!e.style||!this.attribInnerEl||!this.attribContainerEl)return;let t=this.#e?[va]:[],i=e.style.sourceCaches;for(let o in i){let r=i[o];if(r.used||r.usedForTerrain){let a=r.getSource();a.attribution&&t.indexOf(a.attribution)<0&&t.push(a.attribution)}}t=t.filter(o=>String(o).trim()),t=t.filter((o,r)=>{for(let a=r+1;a<t.length;a++)if(t[a].indexOf(o)>=0)return!1;return!0}),this.attribHTML=t.join(" "),this.updateAttributionDisplay()}updateAttributionDisplay(){let e=[...new Set([this.attribHTML,...this.customAttributions])].filter(Boolean).join(" ");this.attribInnerEl&&(this.attribInnerEl.innerHTML=e)}resizeAttribution(e){this.attribContainerEl&&(e<=Rp||this.compact?this.compact===!1?this.attribContainerEl.setAttribute("open",""):!this.attribContainerEl.classList.contains("mappedin-compact")&&!this.attribContainerEl.classList.contains("mappedin-attrib-empty")&&(this.attribContainerEl.setAttribute("open",""),this.attribContainerEl.classList.add("mappedin-compact","mappedin-compact-show")):(this.attribContainerEl.setAttribute("open",""),this.attribContainerEl.classList.contains("mappedin-compact")&&this.attribContainerEl.classList.remove("mappedin-compact","mappedin-compact-show")))}destroyAttributionControl(){this.attribButtonEl&&this.attribButtonEl.removeEventListener("click",this.toggleAttribution),this.attribContainerEl&&(this.attribContainerEl.remove(),this.attribContainerEl=void 0,this.attribInnerEl=void 0,this.attribButtonEl=void 0)}resize(e){this.resizeAttribution(e)}updateData(e){this.updateAttribution(e)}destroy(){this.destroyAttributionControl(),this.controlContainerEl.remove(),this.compact=void 0}};g();import{Color as Bp}from"three";var Qt=class{mesh;type="custom-geometry";dirty=!0;feature;builder;outline;constructor(e,t){this.mesh=new he,this.feature=e,this.builder=t}get visible(){return this.mesh.visible}set visible(e){this.mesh.visible=e}#e=1;set opacity(e){this.#e=e}get opacity(){return this.#e}color=new Bp;setColor(e){se(this.color,e)}get position(){return this.mesh?.position}#o=0;get altitude(){return this.#o}set altitude(e){this.mesh&&(this.mesh.position.z=e,this.#o=e)}get renderOrder(){return this.mesh?this.mesh.renderOrder:0}set renderOrder(e){this.mesh&&(this.mesh.renderOrder=e)}};g();var ar=class{state;convertTo3DMapPosition;constructor(e,t){this.state=e,this.convertTo3DMapPosition=t}update(){let e,t;for(let i of this.state.geometry3DsInScene)i?.type==="custom-geometry"&&(e=i.components[0],t=i.components[1],e.dirty&&t.visible!==!1&&(e.position.copy(this.convertTo3DMapPosition(e.feature.geometry.coordinates[1],e.feature.geometry.coordinates[0],t.altitude)),e.builder.setup(e.mesh),e.mesh.traverse(o=>{o.userData={...o.userData,entityId:i.id,type:"custom-geometry"}}),e.dirty=!1),t.visible!==!1&&e.builder.update(e.mesh))}};g();import{BufferAttribute as sr,EdgesGeometry as Np,FrontSide as Up,LineSegments as Hp,Color as Wp}from"three";import{mergeGeometries as Vp}from"three/examples/jsm/utils/BufferGeometryUtils.js";g();function Vi(n){return n.children.some(e=>e.userData.isOutline)}function Ma(n){return n.children.find(e=>e.userData.isOutline)}function ji(n,e){let t=n.userData.entities3D.values().next().value;return t?e.geometry3DMap.get(t)?.components[3]!==void 0:!1}function Vc(n,e,t,i,o,r,a,l){let c=n.getAttribute("position").array;if(a!=null&&l!=null){let b=new Set(l);for(let p=0;p<e.count;p++){let x=(e.start+p)*3;c[x+2]=b.has(p)?Math.max(t+i,2e-4+i):i}if(r){let{transform:p,initialHeight:x}=r,f=Math.max(x,1e-4),y=t/f,C=-1/0;for(let S=0;S<a.length;S+=3)C=Math.max(C,a[S+2]);let M=C-f;for(let S=0;S<l.length;S++){let T=l[S],w=(e.start+T)*3,P=a[S*3],L=a[S*3+1],N=a[S*3+2];c[w+2]+=(N-M)/f*(p.shearX*P+p.shearY*L+p.zOffset)*y}}n.attributes.position.needsUpdate=!0;return}let h=a!=null,d=a??c,u=1/0,m=-1/0;for(let b=0;b<e.count;b++){let p=h?b*3:(e.start+b)*3,x=d[p+2];u=Math.min(u,x),m=Math.max(m,x)}let v=m-u;if(!o||o.thickness===0||v===0)for(let b=0;b<e.count;b++){let p=(e.start+b)*3,x=h?b*3:p,f=d[x+2];Math.abs(f-m)<1e-4?c[p+2]=Math.max(t+i,2e-4+i):c[p+2]=i}else{let b=o.thickness,p=u+b,x=u+b,f=m-b,y=m-b,C=i-b,M=i,S=i,T=i+t,w=i+t,P=i+t+b;for(let L=0;L<e.count;L++){let N=(e.start+L)*3,A=h?L*3:N,G=d[A+2],B;if(G<=p){let H=b>0?(G-u)/b:0;B=C+H*(M-C)}else if(G>=y){let H=b>0?(G-y)/b:0;B=w+H*(P-w)}else{let H=f-x,j=H>0?(G-x)/H:0;B=S+j*(T-S)}c[N+2]=B}}if(r){let{transform:b,initialHeight:p}=r,x=Math.max(p,1e-4),f=t/x,y,C,M;for(let S=0;S<e.count;S++){let T=(e.start+S)*3,w=h?S*3:T;y=d[w],C=d[w+1],M=d[w+2],c[T+2]+=(M-u)/x*(b.shearX*y+b.shearY*C+b.zOffset)*f}}n.attributes.position.needsUpdate=!0}g();import{LineBasicMaterial as Fp}from"three";g();var jc=`// Modified from https://github.com/mrdoob/three.js/blob/dev/src/renderers/shaders/ShaderLib/linedashed.glsl.js
181
+ uniform float scale;
182
+ attribute float lineDistance;
183
+
184
+ varying float vLineDistance;
185
+ attribute float visibility;
186
+ varying vec4 v_color;
187
+ varying vec4 vWorldPosition;
188
+
189
+ #include <common>
190
+ #include <uv_pars_vertex>
191
+ #include <color_pars_vertex>
192
+ #include <fog_pars_vertex>
193
+ #include <morphtarget_pars_vertex>
194
+ #include <logdepthbuf_pars_vertex>
195
+ #include <clipping_planes_pars_vertex>
196
+
197
+ void main() {
198
+
199
+ vLineDistance = scale * lineDistance;
200
+ v_color = color;
201
+
202
+ #include <uv_vertex>
203
+ #include <color_vertex>
204
+ #include <morphinstance_vertex>
205
+ #include <morphcolor_vertex>
206
+ #include <begin_vertex>
207
+ #include <morphtarget_vertex>
208
+ #include <project_vertex>
209
+ vWorldPosition = modelMatrix * vec4(transformed, 1.0);
210
+ if (visibility < 0.5) {
211
+ gl_Position = vec4(-2.0, -2.0, -2.0, 1.0);
212
+ }
213
+ #include <logdepthbuf_vertex>
214
+ #include <clipping_planes_vertex>
215
+ #include <fog_vertex>
216
+
217
+ }`;g();var Zc=`// Modified from https://github.com/mrdoob/three.js/blob/dev/src/renderers/shaders/ShaderLib/linedashed.glsl.js
218
+ uniform vec3 diffuse;
219
+ uniform float opacity;
220
+
221
+ uniform float dashSize;
222
+ uniform float totalSize;
223
+
224
+ uniform float effectStart;
225
+ uniform float effectDistance;
226
+ float MAPPEDIN_EFFECTS_UNIFORMS;
227
+
228
+ varying float vLineDistance;
229
+ varying vec4 v_color;
230
+ varying vec4 vWorldPosition;
231
+
232
+ #include <common>
233
+ #include <color_pars_fragment>
234
+ #include <uv_pars_fragment>
235
+ #include <map_pars_fragment>
236
+ #include <fog_pars_fragment>
237
+ #include <logdepthbuf_pars_fragment>
238
+ #include <clipping_planes_pars_fragment>
239
+
240
+ void main() {
241
+
242
+ vec4 diffuseColor = vec4( diffuse, opacity );
243
+ #include <clipping_planes_fragment>
244
+
245
+ if ( mod( vLineDistance, totalSize ) > dashSize ) {
246
+
247
+ discard;
248
+
249
+ }
250
+
251
+ vec3 outgoingLight = vec3( 0.0 );
252
+
253
+ #include <logdepthbuf_fragment>
254
+ #include <map_fragment>
255
+ #include <color_fragment>
256
+
257
+ outgoingLight = diffuseColor.rgb; // simple shader
258
+
259
+ #include <opaque_fragment>
260
+ #include <tonemapping_fragment>
261
+ #include <colorspace_fragment>
262
+ #include <fog_fragment>
263
+ #include <premultiplied_alpha_fragment>
264
+
265
+ // Depth-based visual effects. The arithmetic is not repeated here: it comes from
266
+ // src/effects/builtin/index.ts via applyEffectsToShader, so outlines and surfaces cannot
267
+ // drift apart the way a hand-copied block does.
268
+ if(effectDistance > 0.0) {
269
+ float t = clamp((effectStart - vWorldPosition.z) / effectDistance, 0.0, 1.0);
270
+ float fade = pow(t, 0.65) * 0.9;
271
+
272
+ float MAPPEDIN_EFFECTS_FINAL = 0.0;
273
+ }
274
+
275
+ // Discard alpha lower than 0.01 to avoid opacity fighting
276
+ if (v_color.a <= 0.01) {
277
+ discard;
278
+ }
279
+ }
280
+ `;var Zi=class extends Fp{effectUniforms={effectStart:{value:0},effectDistance:{value:0},...Bs()};constructor(e){super(e),this.onBeforeCompile=t=>{t.vertexShader=jc,t.fragmentShader=Rs(Zc,_s);let i=this.effectUniforms.effectStart,o=this.effectUniforms.effectDistance,r=this.effectUniforms.darkenAmount,a=this.effectUniforms.darkenUseDepth,l=this.effectUniforms.desaturateAmount,s=this.effectUniforms.desaturateUseDepth,c=this.effectUniforms.washOutAmount,h=this.effectUniforms.washOutUseDepth;this.effectUniforms=t.uniforms,Object.assign(this.effectUniforms,{effectStart:i,effectDistance:o,darkenAmount:r,darkenUseDepth:a,desaturateAmount:l,desaturateUseDepth:s,washOutAmount:c,washOutUseDepth:h})}}setEffectRange(e,t){this.effectUniforms.effectStart.value=e,this.effectUniforms.effectDistance.value=t}getEffectRange(){return{start:this.effectUniforms.effectStart.value,distance:this.effectUniforms.effectDistance.value}}setVisualEffect(e,t,i,o,r,a){this.effectUniforms.darkenAmount.value=e,this.effectUniforms.darkenUseDepth.value=t?1:0,this.effectUniforms.desaturateAmount.value=i,this.effectUniforms.desaturateUseDepth.value=o?1:0,this.effectUniforms.washOutAmount.value=r,this.effectUniforms.washOutUseDepth.value=a?1:0}getVisualEffect(){return{darkenAmount:this.effectUniforms.darkenAmount.value,darkenUseDepth:this.effectUniforms.darkenUseDepth.value,desaturateAmount:this.effectUniforms.desaturateAmount.value,desaturateUseDepth:this.effectUniforms.desaturateUseDepth.value,washOutAmount:this.effectUniforms.washOutAmount.value,washOutUseDepth:this.effectUniforms.washOutUseDepth.value}}};g();var Ot=class{#e=[];#o=!1;#n;#r;#a;constructor(e=3e3){this.#a=e}get size(){return this.#e.length}add(e){this.#e.push(e),this.#o||this.#s()}onComplete(e){this.#n=e}clearOnComplete(){this.#n=void 0}#s(){this.#o=!0,this.#r=requestIdleCallback(e=>{let t=0;for(;this.#e.length>0&&e.timeRemaining()>2;){let i=this.#e.shift();i&&(i(),t++)}if(t===0&&this.#e.length>0&&e.timeRemaining()<2){let i=this.#e.shift();i&&i()}this.#r=void 0,this.#e.length>0?this.#s():(this.#o=!1,this.#n&&this.#n())},{timeout:this.#a})}clearAll(){this.#e=[],this.#o=!1,this.#n=void 0,this.#r!==void 0&&(cancelIdleCallback(this.#r),this.#r=void 0)}};var jp=80,Xc=new Wp,lr=class extends z{rendererState;maxOpacity;outlineOpacitiesDirty=!0;useIdleFramesOnly=!0;#e=!0;get geometries3DDirty(){return this.#e}set geometries3DDirty(e){this.#e=e}#o=-1/0;idleBuildQueue;idleComputeBoundingSphereQueue;constructor(e,t,i=!0,o=3e3){super(),this.rendererState=e,this.maxOpacity=t?.maxOpacity??1,this.useIdleFramesOnly=i,this.idleBuildQueue=new Ot(o),this.idleComputeBoundingSphereQueue=new Ot(o),this.idleBuildQueue.onComplete(this.#a)}#n=new Map;buildOutlines(e){let t=[];for(let d of e.userData.entities3D.values()){let u=this.rendererState.geometry3DMap.get(d);if(u instanceof U&&u.type==="geometry"&&u.components[3]&&u.components[3].dirty===!0&&u.components[0].material!=null){let m=u.components[0],v=u.components[8],b=v?.baselineVertices!=null,p=m.geometry,x=!1;if(p){if(p&&v?.baselineVertices){let C=p.clone();C.setAttribute("position",new sr(v.baselineVertices.slice(),3)),p=C,x=!0}}else{p=Gi(m),x=!0;let C=v?.baselineVertices;if(C&&p){let M=p.getAttribute("position")?.count??0,S=C.length/3;if(M!==S){let T=m.batchedProps?.range?.vertexStart??0,w=p.getIndex();if(w){let P=w.array;for(let L=0;L<w.count;L++)P[L]=P[L]-T;w.needsUpdate=!0}}p.setAttribute("position",new sr(C.slice(),3))}}let f=u.components[1],y=(f.bevel?.thickness??0)!==0;t.push([u.components[3],new Np(p,f.bevel?.enabled?1:jp),b,y,u.components[3].enabled&&f.visible]),x&&(p?.dispose(),p=void 0)}}if(t.length===0)return;let i=Vp(t.map(d=>d[1]),!1);if(i==null)return;let o=i.getAttribute("position"),r=new Float32Array(o.count*4),a=new sr(r,4);i.setAttribute("color",a);let l=new Uint8Array(o.count);l.fill(0);let s=new sr(l,1,!1);i.setAttribute("visibility",s);let c=0;for(let d=0;d<t.length;d++){let[u,m,v,b,p]=t[d],x=m.getAttribute("position").count;if(u.edgeColors=a,u.edgeVisibility=s,u.geometry=i,u.resetVisibility(),u.ranges={count:x,start:c},u.visible=p,!v)u.baselineVertices=void 0,u.topFaceVerticesIndices=void 0;else{let f=1/0,y=-1/0;for(let M=0;M<x;M++){let S=o.array[(c+M)*3+2];S<f&&(f=S),S>y&&(y=S)}if(!b&&y-f>1e-4){let M=[];for(let T=0;T<x;T++)Math.abs(o.array[(c+T)*3+2]-y)<1e-4&&M.push(T);let S=new Float32Array(M.length*3);for(let T=0;T<M.length;T++){let w=(c+M[T])*3;S[T*3]=o.array[w],S[T*3+1]=o.array[w+1],S[T*3+2]=o.array[w+2]}u.baselineVertices=S,u.topFaceVerticesIndices=M}else{let M=new Float32Array(x*3);for(let S=0;S<x;S++){let T=(c+S)*3;M[S*3]=o.array[T],M[S*3+1]=o.array[T+1],M[S*3+2]=o.array[T+2]}u.baselineVertices=M,u.topFaceVerticesIndices=void 0}}c+=x,m.dispose()}let h=new Hp(i,new Zi({vertexColors:!0,linewidth:1,transparent:!0,opacity:1,side:Up}));h.userData.isOutline=!0,e.add(h)}update(e,t=!0){for(let o of this.rendererState.geometry3DsInScene){if(o.type!=="geometry")continue;let r=o.components[3];if(!r?.needsRebuild)continue;let a=o.parentObject3D;if(a instanceof le){let l=Ma(a);l&&oe(l);for(let s of a.userData.entities3D){let c=this.rendererState.geometry3DMap.get(s);if(c?.type==="geometry"&&c.components[3]){let h=c.components[3];h.dirty=!0,h.geometry=void 0,h.ranges=void 0,h.edgeColors=void 0,h.edgeVisibility=void 0}}}r.needsRebuild=!1,this.geometries3DDirty=!0}if(this.geometries3DDirty){for(let o of this.rendererState.geometry3DsInScene)o.type==="feature-collection"&&ji(o,this.rendererState)&&!Vi(o)&&o.userData.entities3D.size>0&&this.#r(this.idleBuildQueue,()=>this.buildOutlines(o));this.#e=!1,this.outlineOpacitiesDirty=!0}for(let o of this.rendererState.geometry3DsInScene)if(o.type==="geometry"&&o.components[3]&&o.components[3].dirty===!0&&o.components[0].material!=null&&o.parentObject3D instanceof le){let r=o.components[3].geometry;if(!r)continue;let a=o.components[3];if(!a)continue;let l=a.enabled&&o.components[1].visible;if(a.visible!==l&&(a.visible=l),!a.visible)continue;let s=a.edgeColors;if(!s||!a.ranges)continue;Xc.setRGB(1,1,1);let c=R(a.color,Xc);for(let x=0;x<a.ranges.count;x++){let f=a.ranges.start+x;s.setXYZ(f,c.r,c.g,c.b)}let h=o.components[1],d=h.height*h.heightScale,u=h.altitude,m=h?.bevel,b=o.components[8]?.currentSlope,p=h.initialHeight;Vc(r,a.ranges,d,u,m,b?{transform:b,initialHeight:p}:void 0,a.baselineVertices,a.topFaceVerticesIndices),r.attributes.color.needsUpdate=!0,this.#r(this.idleComputeBoundingSphereQueue,()=>r.computeBoundingSphere()),a.dirty=!1}else if(o.type==="feature-collection"&&Vi(o)){let r=Ma(o);if(!r)continue;let a=r.material;if(!(a instanceof Zi))continue;let l;for(let h of o.userData.entities3D.values()){l=h;break}if(l==null)continue;let s=this.rendererState.geometry3DMap.get(l);if(!s||s.type!=="geometry")continue;let c=s.components[1];a.setEffectRange(c.effectStart,c.effectDistance),a.setVisualEffect(c.darkenAmount,c.darkenUseDepth,c.desaturateAmount,c.desaturateUseDepth,c.washOutAmount,c.washOutUseDepth)}let i=t?un(e,16,19,0,this.maxOpacity):this.#o;if((i!==this.#o||this.outlineOpacitiesDirty)&&this.rendererState.geometry3DsInScene.size>0){for(let o of this.rendererState.geometry3DsInScene)if(o.type==="geometry"&&o.components[0]instanceof Y){let r=o.components[3];if(r&&r.edgeColors&&r.geometry&&r.visible){let a=Math.min(i,o.components[1].opacity*Vt(o));if(r.currentOpacity!==a){for(let l=0;l<r.ranges.count;l++){let s=r.ranges.start+l;r.edgeColors.setW(s,a)}r.geometry.attributes.color.needsUpdate=!0}}}}this.#o=i,this.#e=!1,this.outlineOpacitiesDirty=!1}#r(e,t){this.useIdleFramesOnly?e.add(t):t()}#a=()=>{this.publish("needs-render")};destroy(){this.#n.clear(),this.idleBuildQueue.clearAll(),this.idleComputeBoundingSphereQueue.clearAll()}};g();import{AxesHelper as df,DoubleSide as uf,Frustum as mf,MathUtils as pf,Mesh as hh,MeshLambertMaterial as Lt,PlaneGeometry as dh,SphereGeometry as ff,Vector2 as uh,Vector3 as Ge,Matrix4 as gf}from"three";g();import{Vector3 as Zp,Mesh as Xp}from"three";import{z as ue}from"zod";var cr=class extends Xp{userData={entityId:"",cacheKey:"",isResizable:!1}},Yp=ue.object({flipImageToFaceCamera:ue.boolean().optional(),url:ue.string(),maxImageSize:ue.number().positive().optional(),interactive:ue.boolean().optional()}),$p=ue.object({type:ue.enum(["Feature"]),properties:ue.object({width:ue.number(),height:ue.number(),rotation:ue.number().min(0).max(360).optional(),verticalOffset:ue.number().optional()}),geometry:$t});function Yc(n,e,t){ue.union([ue.number(),ue.string()]).parse(n),$p.parse(e),Yp.parse(t)}var ei=class{mesh=new he;imageMesh;outline;type="image";instanceIndex=-1;geometry;material;feature;constructor(e){this.feature=e}get visible(){return this.mesh?.visible??!1}set visible(e){this.mesh&&(this.mesh.visible=e)}position=new Zp};g();function Da(n,e){return{x:n.x*Math.cos(e)-n.y*Math.sin(e),y:n.x*Math.sin(e)+n.y*Math.cos(e)}}function qp(n,e){return n.map(t=>Da(t,e))}function Kp(n){let e=1/0,t=1/0,i=-1/0,o=-1/0;for(let r of n)e=Math.min(e,r.x),t=Math.min(t,r.y),i=Math.max(i,r.x),o=Math.max(o,r.y);return{minX:e,minY:t,maxX:i,maxY:o}}function Jp(n,e){let t=!1;for(let i=0,o=e.length-1;i<e.length;o=i++){let r=e[i].x,a=e[i].y,l=e[o].x,s=e[o].y;a>n.y!=s>n.y&&n.x<(l-r)*(n.y-a)/(s-a)+r&&(t=!t)}return t}function $c(n,e,t,i,o){for(let r=0;r<o;r++)for(let a=0;a<i;a++)if(n[t+r][e+a]!==1)return!1;return!0}function Qp(n,e,t){let i=n.maxX-n.minX,o=n.maxY-n.minY,r,a,l={...n};return i/o>e?(a=o/t,r=a*e,l.minX+=(i-r*t)/2):(r=i/t,a=r/e,l.minY+=(o-a*t)/2),{dx:r,dy:a,gridBounds:l}}function ef(n,e,t,i,o){let r=Array(t).fill(0).map(()=>Array(t).fill(0));for(let a=0;a<t;a++)for(let l=0;l<t;l++){let s={x:e.minX+l*i,y:e.minY+a*o};Jp(s,n)&&(r[a][l]=1)}return r}function tf(n,e){let t=Array(e).fill(0).map(()=>Array(e).fill(0));for(let i=0;i<e;i++)for(let o=0;o<e;o++)if(n[i][o]===1){let r=0;for(let a=1;a<=Math.min(e-o,e-i)&&$c(n,o,i,a,a);a++)r=a;t[i][o]=r}return t}function of(n,e,t,i,o,r){let a=0,l=0,s=0;for(let c=0;c<i;c++)for(let h=0;h<i;h++)if(n[c][h]===1){let d=Math.pow(e[c][h],2),u=t.minX+h*o,m=t.minY+c*r;a+=d,l+=u*d,s+=m*d}return{x:l/a,y:s/a}}function rf(n,e,t,i,o,r,a){let l=-1/0,s=null,c=n.length,h=Math.sqrt(Math.pow(e.maxX-e.minX,2)+Math.pow(e.maxY-e.minY,2));for(let d=0;d<c;d++)for(let u=0;u<c;u++)if(n[d][u]===1)for(let m=1;m<=c-u;m++){let v=m;if(!(v>c-d)&&$c(n,u,d,m,v)){let b=m*v,p=e.minX+(u+m/2)*t,x=e.minY+(d+v/2)*i,f={x:p,y:x},C=Math.sqrt(Math.pow(f.x-o.x,2)+Math.pow(f.y-o.y,2))/h,M=b*(1-r)-C*r*b;M>l&&(l=M,s={center:f,width:m*t*a,height:m*i*a})}}return s}function wa(n,e,t,i={}){let{scaleFactor:o=.9,centerPriority:r=.5,resolution:a=100,minimumSizeRatio:l=.5}=i,s=Es(t),c=n.width/n.height,h=qp(e,s),d=Kp(h),{dx:u,dy:m,gridBounds:v}=Qp(d,c,a),b=ef(h,v,a,u,m),p=tf(b,a),x=of(b,p,v,a,u,m),f=rf(b,v,u,m,x,r,o);return!f||f.width<n.width*l||f.height<n.height*l?n:{...f,center:Da(f.center,-s),rotation:t,polygonCenter:Da(x,-s)}}g();var V={HIGH:1,MEDIUM:.5,LOW:.25,VERY_LOW:.125},q={[V.HIGH]:2048,[V.MEDIUM]:1024,[V.LOW]:512,[V.VERY_LOW]:256},qc={[q[V.HIGH]]:65280,[q[V.MEDIUM]]:16776960,[q[V.LOW]]:16753920,[q[V.VERY_LOW]]:16711680},hr={HIGH:50,MEDIUM:100,LOW:250},Kc="https://resize-worker.mappedin.com",Jc=["cdn.mappedin.com","cdn.eu.mappedin.com"],Ta=["resize-worker.mappedin.com","resize-worker-staging.mappedin.net"],ti=.01,Xi=1024,Yi=256,Qc=512,eh=2048,th=3,ih=37,oh=16*1024*1024;g();import{Color as Ea}from"three";function Pa(n){try{let t=new URL(n).hostname;return Jc.includes(t)||Ta.includes(t)}catch{return!1}}function nf(n){try{let e=new URL(n);return Ta.includes(e.hostname)}catch{return!1}}function Oa(n,e){return nf(n)?n.replace(/\/resize:fit:\d+:\d+:(\d+)\//,`/resize:fit:${e}:${e}:$1/`):`${Kc}/resize:fit:${e}:${e}:0/plain/${n}`}function rh(n){return n<=hr.HIGH?q[V.HIGH]:n<=hr.MEDIUM?q[V.MEDIUM]:n<=hr.LOW?q[V.LOW]:q[V.VERY_LOW]}function nh(n){let e=n*ih;return e<=q[V.LOW]?q[V.LOW]:e<=q[V.MEDIUM]?q[V.MEDIUM]:q[V.HIGH]}function ah(n,e){return Pa(n)?n:`${n}|${e??Xi}`}function dr(n,e){n.color=new Ea(16777215),n.emissive=R(qc[e]),n.emissiveIntensity=.5}function ur(n){n.color=new Ea(16777215),n.emissive=new Ea(0),n.emissiveIntensity=0}g();import{CanvasTexture as af,SRGBColorSpace as mr}from"three";function lh(n){let{transformImageRequest:e,getMaxTextureSize:t,publish:i}=n,o=new Map,r=new Set,a=0,l=!1,s={transformImageRequest:e,isDisposed:()=>l};function c(){if(a>0)return a;let p=t(),x=go().isMobile?Qc:q[V.HIGH];return a=Math.min(x,p),a}function h(p){return Math.min(p,c())}function d(p,x){return Math.min(h(rh(x)),nh(p.maxLongEdge))}function u(p,x,f){if(p.base||p.basePending)return;p.basePending=!0;let y=p.isResizable?Oa(x,f):x;sh(y,M=>{let S=p.isResizable?M:hf(M,f);return S.colorSpace=mr,p.base=S,p.basePending=!1,S},()=>{p.basePending=!1},s).then(()=>{l||i()}).catch(()=>{})}function m(p,x,f){p.hiLod!=null&&f<=p.hiLod||p.readyLod!=null&&f<=p.readyLod||(p.ready=x,p.readyLod=f,r.add(p))}function v(p){p.ready=null,p.readyLod=null,r.delete(p)}function b(p,x,f){if(!p.isResizable||p.hiLod!=null&&f<=p.hiLod||p.readyLod!=null&&f<=p.readyLod||p.pendingFetchLOD!=null&&f<=p.pendingFetchLOD)return;p.pendingFetchLOD=f;let y=()=>{p.pendingFetchLOD===f&&(p.pendingFetchLOD=null)},C=Oa(x,f);sh(C,S=>(S.colorSpace=mr,m(p,S,f),y(),S),()=>{y()},s).then(()=>{l||i()}).catch(()=>{})}return{register(p,x,f,y,C,M){if(l)return;let S=o.get(p);if(S?(M>S.maxLongEdge&&(S.maxLongEdge=M),C<S.distance&&(S.distance=C)):(S={url:x,base:null,hi:null,hiLod:null,ready:null,readyLod:null,basePending:!1,pendingFetchLOD:null,isResizable:y,distance:C,maxLongEdge:M},o.set(p,S)),u(S,x,y?Yi:f),y){let w=d(S,C);w>Yi&&b(S,x,w)}},get(p){if(l)return null;let x=o.get(p);return x?x.hi??x.base:null},requestUpgrade(p,x){if(l)return;let f=o.get(p);!f||!f.isResizable||(x<f.distance&&(f.distance=x),b(f,p,d(f,x)))},drainPromotions(){if(l||r.size===0)return;let p=0,x=0,f=Math.min(th,r.size);for(;p<f;){let y,C=1/0;for(let T of r)T.distance<C&&(C=T.distance,y=T);if(y==null)break;let M=lf(y.ready);if(x>0&&x+M>oh)break;let S=y.hi;y.hi=y.ready,y.hiLod=y.readyLod,v(y),S?.dispose(),x+=M,p++}r.size>0&&i()},effectiveLOD(p){return o.get(p)?.hiLod??Yi},residentResolutionBucket(p){let x=o.get(p),f=x?.hi??x?.base;return cf(sf(f))},dispose(){l=!0;for(let p of o.values())p.base?.dispose(),p.hi?.dispose(),p.ready?.dispose();o.clear(),r.clear()},getCacheEntries(){let p=new Map;for(let[x,f]of o)p.set(x,{url:f.url,base:f.base,hi:f.hi,hiLod:f.hiLod,isResizable:f.isResizable,maxLongEdge:f.maxLongEdge});return p}}}function sh(n,e,t,i){let o=r=>new Promise((a,l)=>{if(i.isDisposed()){l(new Error("LOD control disposed"));return}lt.getLoader().load(r,s=>{if(i.isDisposed()){s.dispose(),l(new Error("LOD control disposed"));return}try{a(e(s))}catch(c){E.error("Failed to process image texture",{url:r,error:c}),t(c),l(c)}},void 0,s=>{if(i.isDisposed()){l(new Error("LOD control disposed"));return}E.error("Failed to load image",{url:r,error:s}),t(s),l(s)})});return i.transformImageRequest?i.transformImageRequest(n).then(r=>o(r.url),r=>(i.isDisposed()||(E.error("Failed to transform image request",{url:n,error:r}),t(r)),Promise.reject(r))):o(n)}var It={w:0,h:0};function ch(n){let e=n?.image;return e?e instanceof HTMLImageElement?(It.w=e.naturalWidth||0,It.h=e.naturalHeight||0):(It.w=e.width||0,It.h=e.height||0):(It.w=0,It.h=0),It}function sf(n){let{w:e,h:t}=ch(n);return Math.max(e,t)}function lf(n){let{w:e,h:t}=ch(n);return e*t*4}function cf(n){return n>=q[V.HIGH]?q[V.HIGH]:n>=q[V.MEDIUM]?q[V.MEDIUM]:n>=q[V.LOW]?q[V.LOW]:Yi}function hf(n,e){let t=n.image,i=t instanceof HTMLImageElement?t.naturalWidth:t.width,o=t instanceof HTMLImageElement?t.naturalHeight:t.height,r=Math.max(i,o);if(r<=e)return n.colorSpace=mr,n;n.dispose();let a=e/r,l=Math.max(1,Math.floor(i*a)),s=Math.max(1,Math.floor(o*a)),c;typeof window<"u"&&window.OffscreenCanvas!=null&&!Ls()&&!Us()?c=new OffscreenCanvas(l,s):(c=document.createElement("canvas"),c.width=l,c.height=s);let h=uo(c);if(!h)throw new Error("Failed to get 2D context for texture capping");h.drawImage(t,0,0,l,s);let d=new af(c);return d.colorSpace=mr,d.needsUpdate=!0,d}var $i=Math.PI*2,yf=Math.PI/2,bf=Math.PI*1.5,vf=co(yf,2),xf=co(bf,2);function mh(n){return n.height*n.heightScale+n.altitude}var pr=class extends z{rendererState;convertTo3DMapPosition;projectToScreen;initialBearing=0;naturalBearing=0;imagePlacementOptions;cameraFrustum=new mf;cameraWorldPosition=new Ge;debug={lod:!1,imageContainers:!1};get debugLOD(){return this.debug.lod}set debugLOD(e){let t=this.debug.lod!==e;this.debug.lod=e,t&&(e?this.applyDebugLODColors():this.resetDebugLODColors())}lod;constructor(e,t,i,o=0,r=0,a={},l){super(),this.rendererState=e,this.convertTo3DMapPosition=t,this.projectToScreen=i,this.initialBearing=o,this.naturalBearing=r,this.imagePlacementOptions=a,this.lod=lh({transformImageRequest:l,getMaxTextureSize:()=>this.rendererState.renderer?.capabilities?.maxTextureSize??eh,publish:()=>this.publish("image-loaded")})}createImageMesh(e,t,i,o=0,r,a,l=Xi){let s={width:i.width,height:i.height,center:this.convertTo3DMapPosition(r),rotation:i.rotation??0},c=this.imagePlacementOptions.mode??"default",h=(()=>{switch(c){case"fit-nearest-90":let C=(this.initialBearing-this.naturalBearing+360)%180;return C>=45&&C<=135?wa(s,a,s.rotation+90,this.imagePlacementOptions):s;case"fit-initial-bearing":return wa(s,a,this.initialBearing,this.imagePlacementOptions);case"default":case"none":default:return s}})();if(this.debug.imageContainers&&h.polygonCenter){let C=new hh(new ff(1),new Lt({color:R(65280)}));C.position.set(h.polygonCenter.x,h.polygonCenter.y,o),this.rendererState.geometryScene.add(C)}let d=new Lt({transparent:!0,depthWrite:!1,side:uf}),u=new dh(h.width,h.height),m=new cr(u);m.visible=!1,m.renderOrder=Q.IMAGE_MESH;let v=Pa(t),b=o+ti,p=this.rendererState.cameraObject.position.z,x=Math.abs(p-b),f=ah(t,l),y=Math.max(h.width,h.height);if(this.lod.register(f,t,l??Xi,v,x,y),m.userData.entityId=e,m.userData.cacheKey=f,m.userData.isResizable=v,m.material=d,this.debug.imageContainers){let C=new hh(new dh(i.width,i.height),new Lt({color:R("gray")}));m.add(C);let M=new df;m.add(M),M.scale.set(10,10,10)}return m.position.set(h.center.x,h.center.y,o+ti),m.rotation.z=(-pf.degToRad(h.rotation)+$i)%$i,m}applyDebugLODColors(){this.rendererState.cameraObject.getWorldPosition(this.cameraWorldPosition);for(let e of this.rendererState.geometry3DsInScene)if(e.type==="image"){let t=e.components[0];if(t?.imageMesh?.material instanceof Lt){let{cacheKey:i,isResizable:o}=t.imageMesh.userData;o===!0?dr(t.imageMesh.material,this.lod.residentResolutionBucket(i)):ur(t.imageMesh.material)}}else if(e.type==="geometry"){let t=e.components[0];if(Array.isArray(t?.feature))continue;if(t?.imageMesh?.material instanceof Lt){let{cacheKey:i,isResizable:o}=t.imageMesh.userData;o===!0?dr(t.imageMesh.material,this.lod.residentResolutionBucket(i)):ur(t.imageMesh.material)}}}resetDebugLODColors(){for(let e of this.rendererState.geometry3DsInScene){let t;e.type==="image"?t=e.components[0]:e.type==="geometry"&&(t=e.components[0]),t?.imageMesh?.material instanceof Lt&&ur(t.imageMesh.material)}}flipIfNeeded(e,t){if(e.imageMesh==null)return;let i=-t,o=e.imageMesh.rotation.z,r=co((o-i+$i)%$i,2);if(r>vf&&r<xf){let a=e.imageMesh.matrixWorldAutoUpdate===!1;a&&wi(e.imageMesh),e.imageMesh.rotation.z=(o+Math.PI)%$i,e.imageMesh.updateMatrixWorld(),a&&Mn(e.imageMesh)}}currentImageScreenBBoxes=[];viewProjectionMatrix=new gf;lastLODUpdateTime=-1;reconcileMaterialTexture(e,t,i){let o=this.lod.get(t);if(e.map!==o){let r=e.map;e.map=o,(r==null!=(o==null)||r?.colorSpace!==o?.colorSpace||r?.channel!==o?.channel)&&(e.needsUpdate=!0),this.debug.lod&&i&&dr(e,this.lod.residentResolutionBucket(t))}return o!=null}update(e,t,i){this.currentImageScreenBBoxes=[],this.viewProjectionMatrix.identity().multiply(this.rendererState.cameraObject.projectionMatrix).multiply(this.rendererState.cameraObject.matrixWorldInverse),this.cameraFrustum.setFromProjectionMatrix(this.viewProjectionMatrix),this.rendererState.cameraObject.getWorldPosition(this.cameraWorldPosition);let o=!t&&i!==this.lastLODUpdateTime;o&&(this.lastLODUpdateTime=i),this.lod.drainPromotions();let r,a;for(let l of this.rendererState.geometry3DsInScene)if(l.type==="image"){if(r=l.components[0],a=l.components[1],a.url&&r.imageMesh==null){let s=this.convertTo3DMapPosition(r.feature.geometry.coordinates),c={x:s.x,y:s.y};r.imageMesh=this.createImageMesh(l.id,a.url,r.feature.properties,r.feature.properties.verticalOffset,r.feature.geometry.coordinates,[c],a.maxImageSize),r.mesh.add(r.imageMesh),r.position.copy(r.imageMesh.position)}if(r.imageMesh){let{cacheKey:s,isResizable:c}=r.imageMesh.userData;if(o&&a.url){let h=Math.abs(this.cameraWorldPosition.z-r.position.z);this.lod.requestUpgrade(s,h)}if(a.url){let h=r.imageMesh.material;this.reconcileMaterialTexture(h,s,c)&&!r.imageMesh.visible&&(r.imageMesh.visible=!0)}a.flipImageToFaceCamera&&this.flipIfNeeded(r,e),r.imageMesh.material instanceof Lt&&a.dirty&&r.imageMesh.material.opacity!==a.opacity&&(r.imageMesh.material.opacity=a.opacity)}}else if(l?.type==="geometry"){if(r=l.components[0],a=l.components[1],Array.isArray(r.feature))continue;if(a.showImage&&r.feature.properties?.image&&r.imageMesh==null&&r.visible&&r.mesh!=null&&r.mesh.parent!=null&&r.feature.properties?.image.position!=null&&r.feature.geometry.coordinates!=null&&r.feature.geometry.coordinates.length>0){let s=r.feature.geometry.coordinates[0].map(h=>{let d=this.convertTo3DMapPosition(h);return{x:d.x,y:d.y}}),c=this.createImageMesh(l.id,r.feature.properties?.image.path,r.feature.properties?.image,mh(a),r.feature.properties?.image.position,s,a.maxImageSize);r.mesh.parent.add(c),r.imageMesh=c}if(r.imageMesh){let s=mh(a)+ti;if(r.imageMesh.position.z!==s){let m=r.imageMesh.matrixWorldAutoUpdate===!1;m&&wi(r.imageMesh),r.imageMesh.position.z=s,r.imageMesh.updateMatrixWorld(),m&&Mn(r.imageMesh)}let c=r.feature.properties?.image?.path,{cacheKey:h,isResizable:d}=r.imageMesh.userData,u=!1;if(o&&c){let m=Math.abs(this.cameraWorldPosition.z-r.imageMesh.position.z);this.lod.requestUpgrade(h,m)}if(c){let m=r.imageMesh.material;u=this.reconcileMaterialTexture(m,h,d)}r.visible?a.showImage&&!r.imageMesh.visible?c?u&&(r.imageMesh.visible=!0):r.imageMesh.visible=!0:!a.showImage&&r.imageMesh.visible&&(r.imageMesh.visible=!1):r.imageMesh.visible=!1,a.flipImageToFaceCamera&&this.flipIfNeeded(r,e),a.enableImageCollisions===!0&&this.updateImageScreenBBoxes(r)}}}destroy(){this.lod.dispose(),super.destroy()}getCacheStats(){return this.lod.getCacheEntries()}updateImageScreenBBoxes(e){if(e.imageMesh==null||!e.imageMesh.visible)return;let t=e.imageMesh.geometry.boundingBox;if(t==null&&(e.imageMesh.geometry.computeBoundingBox(),t=e.imageMesh.geometry.boundingBox),t){let i=new Ge;if(e.imageMesh.getWorldPosition(i),!this.cameraFrustum.containsPoint(i))return;let o=new uh;this.projectToScreen(o,i);let r=[new Ge(t.min.x,t.min.y,t.min.z),new Ge(t.max.x,t.min.y,t.min.z),new Ge(t.min.x,t.max.y,t.min.z),new Ge(t.max.x,t.max.y,t.min.z),new Ge(t.min.x,t.min.y,t.max.z),new Ge(t.max.x,t.min.y,t.max.z),new Ge(t.min.x,t.max.y,t.max.z),new Ge(t.max.x,t.max.y,t.max.z)],a=[];for(let u of r){let m=u.clone().applyMatrix4(e.imageMesh.matrixWorld),v=new uh;this.projectToScreen(v,m),a.push(v)}let l=1/0,s=1/0,c=-1/0,h=-1/0;for(let u of a)l=Math.min(l,u.x),s=Math.min(s,u.y),c=Math.max(c,u.x),h=Math.max(h,u.y);let d=new et(o.x,o.y,c-l,h-s);this.currentImageScreenBBoxes.push(d)}else E.warn("Bounding box for imageMesh does not exist.")}};g();g();function Ia(n){let e=1/0,t=1/0,i=-1/0,o=-1/0;for(let r of n)r.x<e&&(e=r.x),r.x>i&&(i=r.x),r.y<t&&(t=r.y),r.y>o&&(o=r.y);return{minX:e,minY:t,maxX:i,maxY:o}}function Sf(n,e){return!(n.maxX<e.minX||n.minX>e.maxX||n.maxY<e.minY||n.minY>e.maxY)}function Mf(n,e){if(!Sf(n,e))return 0;let t=Math.max(n.minX,e.minX),i=Math.min(n.maxX,e.maxX),o=Math.max(n.minY,e.minY),r=Math.min(n.maxY,e.maxY),a=i-t,l=r-o;return a*l}function ph(n,e){let t=Mf(n,e);if(t===0)return 0;let i=e.maxX-e.minX,o=e.maxY-e.minY,r=i*o;return r===0?0:t/r}g();function Cf(n){let e=0;for(let t=1;t<n.length;t++)(n[t].y<n[e].y||n[t].y===n[e].y&&n[t].x<n[e].x)&&(e=t);return e}function Df(n,e){let t=[...n];return t.sort((i,o)=>{let r=i.point.x-e.x,a=i.point.y-e.y,l=o.point.x-e.x,s=o.point.y-e.y,c=r*s-a*l;if(c===0){let h=r*r+a*a,d=l*l+s*s;return h-d}return c>0?-1:1}),t}function wf(n,e){let t=[e];for(let i=0;i<n.length;i++){for(;t.length>1;){let o=t[t.length-2].point,r=t[t.length-1].point,a=n[i].point,l=r.x-o.x,s=r.y-o.y,c=a.x-r.x,h=a.y-r.y;if(l*h-s*c<=0)t.pop();else break}t.push(n[i])}return t}function fh(n){if(n.length<3)return n.map((r,a)=>({point:r,index:a}));let e=Cf(n),t=n.map((r,a)=>({point:r,index:a})),i=t[e];t.splice(e,1);let o=Df(t,i.point);return wf(o,i)}function qi(n,e,t,i){if(n.length===0)return[];let o=[],r=n[n.length-1],a=e*r.x+t*r.y+i;for(let l=0;l<n.length;l++){let s=n[l],c=e*s.x+t*s.y+i;if(c>=0){if(a<0){let h=a/(a-c);o.push({x:r.x+h*(s.x-r.x),y:r.y+h*(s.y-r.y)})}o.push(s)}else if(a>=0){let h=a/(a-c);o.push({x:r.x+h*(s.x-r.x),y:r.y+h*(s.y-r.y)})}r=s,a=c}return o}import{Frustum as Ff,Matrix4 as Eh,Object3D as Ph,Vector3 as Gf}from"three";g();var Tf="2",Ef="1000",Pf="1002";function Of(n,e){let t=document.createElement("div");return t.id=`focus-bbox-${n}`,t.style.position="absolute",t.style.pointerEvents="none",t.style.overflow="hidden",t.style.zIndex=Ef,e.appendChild(t),t}function If(n,e){let t=e.maxX-e.minX,i=e.maxY-e.minY;n.style.left=e.minX+"px",n.style.top=e.minY+"px",n.style.width=t+"px",n.style.height=i+"px"}function Lf(n,e){e?(n.style.border="2px solid green",n.style.backgroundColor="rgba(0, 255, 0, 0.1)"):(n.style.border="2px solid red",n.style.backgroundColor="rgba(255, 0, 0, 0.1)")}function Af(n){let e=n.querySelector(".entity-id-label");return e||(e=document.createElement("div"),e.className="entity-id-label",e.style.position="absolute",e.style.top="0",e.style.left="0",e.style.padding="2px 4px",e.style.color="white",e.style.fontSize="10px",e.style.fontWeight="bold",e.style.fontFamily="monospace",e.style.zIndex="1001",n.appendChild(e)),e}function Rf(n){let e=n.querySelector(".score-label");return e||(e=document.createElement("div"),e.className="score-label",e.style.position="absolute",e.style.bottom="0",e.style.right="0",e.style.padding="2px 4px",e.style.color="white",e.style.fontSize="12px",e.style.fontWeight="bold",e.style.fontFamily="monospace",e.style.zIndex="1001",n.appendChild(e)),e}function _f(n,e,t,i,o){i?n.style.backgroundColor="green":n.style.backgroundColor="red",n.textContent=t,o!==void 0?(e.style.backgroundColor=i?"green":"red",e.textContent=o.toFixed(3)):(e.style.backgroundColor=i?"green":"red",e.textContent="")}function gh(n,e){for(let[t,i]of n)e.has(t)||(i.remove(),n.delete(t))}function yh(n,e,t,i,o,r){let a=t.get(n);a||(a=Of(n,i),t.set(n,a)),If(a,e.clippedScreenBBox??e.screenBBox),Lf(a,o);let l=Af(a),s=Rf(a);return _f(l,s,n,o,r),a}function bh(){let n=document.createElement("div");return Object.assign(n.style,{position:"absolute",top:"0",left:"0",width:"100%",height:"100%",pointerEvents:"none",overflow:"hidden",zIndex:Tf}),document.body.append(n),n}function vh(n,e){let t=document.createElement("div");t.style.position="absolute",t.style.top=n.minY+"px",t.style.left=n.minX+"px",t.style.width=n.maxX-n.minX+"px",t.style.height=n.maxY-n.minY+"px",t.style.border="2px solid gray",t.style.backgroundColor="rgba(128, 128, 128, 0.1)",t.style.pointerEvents="none",t.style.zIndex=Pf,e.append(t);let i=document.createElement("div");i.textContent="viewfinder",i.style.position="absolute",i.style.top="0",i.style.left="0",i.style.padding="2px 4px",i.style.backgroundColor="gray",i.style.color="white",i.style.fontSize="12px",i.style.fontWeight="bold",i.style.fontFamily="monospace",i.style.zIndex="1001",t.appendChild(i);let o=document.createElement("div");return o.textContent="",o.style.position="absolute",o.style.bottom="0",o.style.right="0",o.style.padding="2px 4px",o.style.backgroundColor="gray",o.style.color="white",o.style.fontSize="12px",o.style.fontWeight="bold",o.style.fontFamily="monospace",o.style.zIndex="1001",t.appendChild(o),{squareEl:t,labelEl:i,scoreLabelEl:o}}function xh(n,e){n.textContent=e}function Sh(n,e){e!==void 0?n.textContent=`Score: ${e.toFixed(3)}`:n.textContent=""}g();import{Object3D as Bf}from"three";function Mh(n,e,t){if(!n.visible)return;let i=n;if(i.isMesh||i.isLine||i.isPoints){let o=i.geometry;if(o?.isBufferGeometry){let r=o.attributes.position;if(r)for(let a=0;a<r.count;a++)t.fromBufferAttribute(r,a),t.applyMatrix4(n.matrixWorld),e.push(t.clone())}}for(let o of n.children)Mh(o,e,t)}function Ch(n,e){let t=[];return n instanceof Bf&&Mh(n,t,e),t}var ii=.001;function Dh(n){if(n.length===0)return[];let e=[],t=n[n.length-1],i=t.w>ii;for(let o=0;o<n.length;o++){let r=n[o],a=r.w>ii;if(a){if(!i){let l=(ii-t.w)/(r.w-t.w);e.push({x:t.x+l*(r.x-t.x),y:t.y+l*(r.y-t.y),z:t.z+l*(r.z-t.z),w:ii})}e.push(r)}else if(i){let l=(ii-t.w)/(r.w-t.w);e.push({x:t.x+l*(r.x-t.x),y:t.y+l*(r.y-t.y),z:t.z+l*(r.z-t.z),w:ii})}t=r,i=a}return e}function wh(n,e,t){if(n.length===0)return[];let i=n;return i=qi(i,1,0,0),i=qi(i,-1,0,e),i=qi(i,0,1,0),i=qi(i,0,-1,t),i}g();import{Vector2 as Th}from"three";var fr=class{bbox;center;el=null;labelEl=null;scoreLabelEl=null;create(e,t,i,o,r){this.labelEl&&(this.labelEl.remove(),this.labelEl=null),this.scoreLabelEl&&(this.scoreLabelEl.remove(),this.scoreLabelEl=null),this.el&&(this.el.remove(),this.el=null);let a=at(i,e,t),l=a.left,s=a.top,c=e-a.left-a.right,h=t-a.top-a.bottom,d=new Th(l+c/2,s+h/2),m=c/2*(2-2/1.2)/2,v=Math.max(l,d.x-m),b=Math.min(e-a.right,d.x+m),p=Math.max(s,d.y-m),x=Math.min(t-a.bottom,d.y+m),f=(v+b)/2,y=(p+x)/2;if(this.bbox={minX:v,maxX:b,minY:p,maxY:x},this.center=new Th(f,y),o&&r){let{squareEl:C,labelEl:M,scoreLabelEl:S}=vh(this.bbox,r);this.el=C,this.labelEl=M,this.scoreLabelEl=S}}updateLabel(e){this.labelEl&&xh(this.labelEl,e)}updateScore(e){this.scoreLabelEl&&Sh(this.scoreLabelEl,e)}destroy(){this.labelEl&&(this.labelEl.remove(),this.labelEl=null),this.scoreLabelEl&&(this.scoreLabelEl.remove(),this.scoreLabelEl=null),this.el&&(this.el.remove(),this.el=null)}};var kf=250,Oh=100,gr=class extends z{cameraDirty=!0;focusablesDirty=!0;state;camera;cameraFrustum=new Ff;viewProjectionMatrix=new Eh;tempScreenPos=new Gf;debugEl=null;collisions=new Map;focusableEntities=new Map;debug=!1;debugBBoxElements=new Map;viewfinder=new fr;screenBoundsMap=new Map;screenDiagonal=1;lastPublishedEntities;lastComputedVP=new Eh;hasComputed=!1;focusablesChangedSinceCompute=!0;lastComputeTime=-1/0;trailingTimer;clipPool=[];clipScratch=[];screenPool=[];screenScratch=[];constructor(e,t){super(),this.state=e,this.camera=t,this.resize()}resize(){this.focusablesChangedSinceCompute=!0,this.screenDiagonal=Math.sqrt(this.state.canvasWidth*this.state.canvasWidth+this.state.canvasHeight*this.state.canvasHeight),this.createViewfinder()}createViewfinder(){this.debugEl&&this.debugEl.remove();for(let e of this.debugBBoxElements.values())e.remove();this.debugBBoxElements.clear(),this.debug&&(this.debugEl=bh()),this.viewfinder.create(this.state.canvasWidth,this.state.canvasHeight,this.state.insetsPadding,this.debug,this.debugEl)}simplifyVertices(e){return e.length<3?e:fh(e).map(t=>e[t.index])}computeScreenSpaceBounds(e){let{vertices:t,boundingBox:i}=e;if(t==null||t.length<3||i==null||i.isEmpty()||!this.cameraFrustum.intersectsBox(i))return;let o=this.viewProjectionMatrix.elements,r=this.clipScratch,a=this.clipPool;r.length=t.length;for(let u=0;u<t.length;u++){let m=t[u],v=a[u];v===void 0&&(v={x:0,y:0,z:0,w:0},a[u]=v),v.x=o[0]*m.x+o[4]*m.y+o[8]*m.z+o[12],v.y=o[1]*m.x+o[5]*m.y+o[9]*m.z+o[13],v.z=o[2]*m.x+o[6]*m.y+o[10]*m.z+o[14],v.w=o[3]*m.x+o[7]*m.y+o[11]*m.z+o[15],r[u]=v}let l=Dh(r);if(l.length<3)return;let s=1/0,c=this.screenScratch,h=this.screenPool;c.length=l.length;for(let u=0;u<l.length;u++){let m=l[u],v=m.x/m.w,b=m.y/m.w,p=h[u];p===void 0&&(p={x:0,y:0},h[u]=p),p.x=(v+1)/2*this.state.canvasWidth,p.y=(-b+1)/2*this.state.canvasHeight,c[u]=p,m.w<s&&(s=m.w)}let d=wh(c,this.state.canvasWidth,this.state.canvasHeight);if(!(d.length<=0))return{screenBBox:Ia(c),clippedScreenBBox:this.debug?Ia(d):void 0,closestZ:s}}updateFocusableEntities(){this.focusableEntities.clear();let e;for(let t of this.state.geometry3DsInScene){if(t==null)continue;let i;if(t.type==="group-container"||t.type==="feature-collection"?i=t.visible:i=t.components[1]?.visible??!0,!!i&&(e=t.type==="group-container"?t.components[1]:t.components[4],e!==void 0&&e.type==="focusable")){let o=String(t.type==="group-container"?t.userData.entityId:t.id);if(e.dirty===!0){let r=null;t instanceof Ph?r=t:"object3d"in t&&t.object3d instanceof Ph&&(r=t.object3d),r&&(e.boundingBox.setFromObject(r),e.vertices=this.simplifyVertices(Ch(r,this.tempScreenPos)),e.dirty=!1)}this.focusableEntities.set(o,e)}}this.focusablesDirty=!1,this.focusablesChangedSinceCompute=!0}#e=void 0;update=(e=!1,t=Date.now())=>{if(this.focusablesDirty&&this.updateFocusableEntities(),e){this.trailingTimer!==void 0&&(clearTimeout(this.trailingTimer),this.trailingTimer=void 0);return}Date.now()-t>kf||(this.#e&&cancelAnimationFrame(this.#e),this.#e=requestAnimationFrame(()=>{this.updateRaf()}))};updateRaf(){if(this.focusableEntities.size===0){this.lastPublishedEntities?.length!==0&&(this.lastPublishedEntities=[],this.publish("geometry-in-focus",[]));return}if(this.cameraDirty){if(!this.focusablesChangedSinceCompute){if(this.viewProjectionMatrix.multiplyMatrices(this.camera.projectionMatrix,this.camera.matrixWorldInverse),this.hasComputed&&this.viewProjectionMatrix.equals(this.lastComputedVP)){this.cameraDirty=!1;return}let e=performance.now()-this.lastComputeTime;if(e<Oh){this.trailingTimer===void 0&&(this.trailingTimer=setTimeout(()=>{this.trailingTimer=void 0,this.updateRaf()},Oh-e));return}}this.compute()}}updateDebugBBoxes(e,t){if(!(!this.debug||!this.debugEl)){gh(this.debugBBoxElements,e);for(let[i,o]of e){let r=t.has(i),a=this.collisions.get(i);yh(i,o,this.debugBBoxElements,this.debugEl,r,a)}}}compute(){if(this.collisions.clear(),this.screenBoundsMap.clear(),!this.viewfinder.center)return;this.trailingTimer!==void 0&&(clearTimeout(this.trailingTimer),this.trailingTimer=void 0),this.viewProjectionMatrix.multiplyMatrices(this.camera.projectionMatrix,this.camera.matrixWorldInverse),this.cameraFrustum.setFromProjectionMatrix(this.viewProjectionMatrix),this.lastComputedVP.copy(this.viewProjectionMatrix),this.hasComputed=!0,this.focusablesChangedSinceCompute=!1,this.lastComputeTime=performance.now();let e=[];for(let[r,a]of this.focusableEntities){let l=this.computeScreenSpaceBounds(a);if(!l)continue;this.screenBoundsMap.set(r,l);let{screenBBox:s}=l,c=ph(s,this.viewfinder.bbox);if(c>0){e.push(r);let h=(s.minX+s.maxX)/2,d=(s.minY+s.maxY)/2,u=h-this.viewfinder.center.x,m=d-this.viewfinder.center.y,b=1/(1+Math.sqrt(u*u+m*m)/this.screenDiagonal),p=1/(1+Math.abs(l.closestZ)),x=b*.5+c*.35+p*.15;this.collisions.set(r,x)}}let t=Array.from(this.collisions.keys()).sort((r,a)=>(this.collisions.get(a)??0)-(this.collisions.get(r)??0)),i=this.lastPublishedEntities,o=t.length!==i?.length;if(!o&&i){for(let r=0;r<t.length;r++)if(t[r]!==i[r]){o=!0;break}}if(this.debug){let r=t[0];this.viewfinder.updateLabel(r||"viewfinder");let a=r?this.collisions.get(r):void 0;this.viewfinder.updateScore(a);let l=new Set(e);this.updateDebugBBoxes(this.screenBoundsMap,l)}this.cameraDirty=!1,o&&(this.lastPublishedEntities=t,this.publish("geometry-in-focus",t))}showDebug(){this.debug||(this.debug=!0,this.cameraDirty=!0,this.focusablesChangedSinceCompute=!0,this.createViewfinder())}hideDebug(){this.debug&&(this.debug=!1,this.createViewfinder())}destroy(){this.trailingTimer!==void 0&&(clearTimeout(this.trailingTimer),this.trailingTimer=void 0),this.#e&&cancelAnimationFrame(this.#e),this.debugEl&&this.debugEl.remove();for(let e of this.debugBBoxElements.values())e.remove();this.debugBBoxElements.clear(),this.collisions.clear(),this.focusableEntities.clear(),this.viewfinder.destroy()}};g();g();g();g();function yr(n,e){e===void 0&&(e={});var t=so(n);switch(!e.properties&&n.type==="Feature"&&(e.properties=n.properties),t.type){case"Polygon":return zf(t,e);case"MultiPolygon":return Nf(t,e);default:throw new Error("invalid poly")}}function zf(n,e){e===void 0&&(e={});var t=so(n),i=t.coordinates,o=e.properties?e.properties:n.type==="Feature"?n.properties:{};return Ih(i,o)}function Nf(n,e){e===void 0&&(e={});var t=so(n),i=t.coordinates,o=e.properties?e.properties:n.type==="Feature"?n.properties:{},r=[];return i.forEach(function(a){r.push(Ih(a,o))}),Cs(r)}function Ih(n,e){return n.length>1?Ds(n,e):Ms(n[0],e)}function Uf(n,e){var t=!0;return zt(n,function(i){zt(e,function(o){if(t===!1)return!1;t=Hf(i.geometry,o.geometry)})}),t}function Hf(n,e){switch(n.type){case"Point":switch(e.type){case"Point":return!Zf(n.coordinates,e.coordinates);case"LineString":return!Lh(e,n);case"Polygon":return!Nt(n,e)}break;case"LineString":switch(e.type){case"Point":return!Lh(n,e);case"LineString":return!Wf(n,e);case"Polygon":return!Ah(e,n)}break;case"Polygon":switch(e.type){case"Point":return!Nt(e,n);case"LineString":return!Ah(n,e);case"Polygon":return!Vf(e,n)}}return!1}function Lh(n,e){for(var t=0;t<n.coordinates.length-1;t++)if(jf(n.coordinates[t],n.coordinates[t+1],e.coordinates))return!0;return!1}function Wf(n,e){var t=lo(n,e);return t.features.length>0}function Ah(n,e){for(var t=0,i=e.coordinates;t<i.length;t++){var o=i[t];if(Nt(o,n))return!0}var r=lo(e,yr(n));return r.features.length>0}function Vf(n,e){for(var t=0,i=n.coordinates[0];t<i.length;t++){var o=i[t];if(Nt(o,e))return!0}for(var r=0,a=e.coordinates[0];r<a.length;r++){var l=a[r];if(Nt(l,n))return!0}var s=lo(yr(n),yr(e));return s.features.length>0}function jf(n,e,t){var i=t[0]-n[0],o=t[1]-n[1],r=e[0]-n[0],a=e[1]-n[1],l=i*a-o*r;return l!==0?!1:Math.abs(r)>=Math.abs(a)?r>0?n[0]<=t[0]&&t[0]<=e[0]:e[0]<=t[0]&&t[0]<=n[0]:a>0?n[1]<=t[1]&&t[1]<=e[1]:e[1]<=t[1]&&t[1]<=n[1]}function Zf(n,e){return n[0]===e[0]&&n[1]===e[1]}var Rh=Uf;function La(n,e){var t=!1;return zt(n,function(i){zt(e,function(o){if(t===!0)return!0;t=!Rh(i.geometry,o.geometry)})}),t}var Fh=hu(du());var Aa="outdoor-system-debug-container",_h=!1;function Xf(n,e,t){let i=Math.pow(2,n),o=new xt(e/i,t/i).toLngLat(),r=new xt((e+1)/i,(t+1)/i).toLngLat();return[o.lng,r.lat,r.lng,o.lat]}function Yf(n,e){return n[0]<=e[2]&&n[2]>=e[0]&&n[1]<=e[3]&&n[3]>=e[1]}var $f=15e-6;function qf(n,e){if(n.length<=5)return n;let t=(0,Fh.default)(n.map(a=>({x:a[0],y:a[1]})),e,!0);if(t.length<4)return n;let i=t.map(a=>[a.x,a.y]),o=i[0],r=i[i.length-1];return(o[0]!==r[0]||o[1]!==r[1])&&i.push([o[0],o[1]]),i}function Bh(n){return{bbox:ws(hn(n)),simplified:hn(n.map(e=>qf(e,$f)))}}function Kf(n,e){let t=1/0,i=1/0,o=-1/0,r=-1/0,a=n.type==="MultiPolygon"?n.coordinates.length:1;for(let l=0;l<a;l++){let s=n.type==="MultiPolygon"?n.coordinates[l]:n.coordinates;for(let c=0;c<s.length;c++){let h=s[c];for(let d=0;d<h.length;d++){let u=h[d];u[0]<t&&(t=u[0]),u[0]>o&&(o=u[0]),u[1]<i&&(i=u[1]),u[1]>r&&(r=u[1])}}}return t<=e[2]&&o>=e[0]&&i<=e[3]&&r>=e[1]}var Jf=500,br=class extends z{#e;idleQueue;#o="";#n=new Set;#r=[];#a=new Set;#s;#l=[];#h=Qf();#p;#i=e=>{if(!this.#e)throw new Error("Map not initialized");let i=[[e[0],e[1]],[e[2],e[1]],[e[2],e[3]],[e[0],e[3]]].map(s=>this.#e.project(s)),o=Math.max(...i.map(s=>s.x)),r=Math.min(...i.map(s=>s.x)),a=Math.max(...i.map(s=>s.y)),l=Math.min(...i.map(s=>s.y));return[new bn(r,l),new bn(o,a)]};#d=(e,t)=>{if(!this.#e)return;let i=this.#e.on(e,t);i?.unsubscribe&&this.onAbort(()=>i.unsubscribe())};#t=()=>{this.#b.clear(),this.#M.clear()};#g=()=>{this.#p&&(this.#p.controller.abort(),this.#p=void 0)};#u=()=>{this.#g();let e=new Set(this.#b),t=new AbortController;t.signal.addEventListener("abort",()=>{this.#b.clear();for(let o of e)this.#b.add(o);this.idleQueue.clearAll()},{once:!0});let i={controller:t};return this.#p=i,i};hideLayersIntersectingPolygons(e,t){this.#g(),this.#t(),this.#h.buildStart();let i=[];for(let o of e)if(o.geometry.type==="Polygon")i.push(Bh(o.geometry.coordinates));else if(o.geometry.type==="MultiPolygon")for(let r of o.geometry.coordinates)i.push(Bh(r));this.#s=i,this.#l=i.map((o,r)=>()=>this.#y(r)),this.#h.buildDone(this.#s.length);for(let o of t)this.#n.add(o);this.#S(),this.#f()}#c=Je(()=>{this.#f()},Jf);constructor(e,t=3e3){super(),this.idleQueue=new Ot(t),e&&(this.#e=e,this.#d("styledata",this.#I),this.#d("sourcedata",i=>{this.#a.size>0&&!this.#a.has(i.sourceId)||i.tile!=null&&this.#v(i.tile)&&this.#x(i.tile)&&this.#c()})),_h&&this.#B()}#v(e){let t=e.tileID?.canonical;if(!t)return!0;let i=Xf(t.z,t.x,t.y),o=this.#s;if(o){for(let r=0;r<o.length;r++)if(Yf(i,o[r].bbox))return!0}return!1}#x(e){let t=e.tileID?.canonical;if(!t)return!0;let i=`${t.z}/${t.x}/${t.y}`;return this.#M.has(i)?!1:(this.#M.add(i),!0)}#S(){let e=new Set,t=new Set;if(this.#e)for(let i of this.#n){let o=this.#e.getLayer(i);o&&(e.add(i),o.source&&t.add(o.source))}this.#r=Array.from(e),this.#a=t}#f=async()=>{if(_h&&this.#s&&this.#F(),!this.#e||!this.#r||this.#r.length===0||!this.#s||this.#s.length===0)return;let e=this.#u(),t=this.#b.size;this.#h.computeStart();let i=()=>{if(this.#p!==e)return;let o=this.#b.size-t;if(o>0){this.#h.beginSpan();let r=[];for(let l of this.#b)r.push(l);let a=["!",["in",["id"],["literal",r]]];this.#r.forEach(l=>{this.#e?.setFilter(l,a)}),this.#h.endSpan()}this.#h.computeDone(this.#l.length,o,this.#b.size),this.#p=void 0};for(let o=0;o<this.#l.length;o++)this.idleQueue.add(this.#l[o]);this.idleQueue.onComplete(i)};#y=e=>{if(!this.#e||!this.#s)return;this.#h.beginSpan();let t=this.#s[e],i=t.simplified,o=t.bbox,r=this.#i(o),a=this.#e.queryRenderedFeatures(r,{layers:this.#r});for(let l=0;l<a.length;l++){let s=a[l],c=s.id;if(c==null||this.#b.has(c))continue;let h=s.geometry;h==null||!("coordinates"in h)||h.type!=="Polygon"&&h.type!=="MultiPolygon"||Kf(h,o)&&La(i,h)&&this.#b.add(c)}this.#h.endSpan()};#b=new Set;#M=new Set;get#_(){return this.idleQueue.size!==0}#I=e=>{if(this.#e&&e&&e.dataType==="style"&&e.type==="styledata"&&this.#n.size>0){let t=e?.style?.stylesheet?.id;if(!t||t!==this.#o){let i=this.#o;this.#h.styleLatch(i||"",t||""),this.#g(),this.#t(),this.#o=t,this.#S(),this.#c()}}};#B(){if(!document.getElementById(Aa)&&this.#e){let e=document.createElement("div");e.id=Aa,e.style.position="absolute",e.style.top="0",e.style.left="0",e.style.bottom="0",e.style.right="0",e.style.pointerEvents="none",e.style.zIndex="1000",this.#e.getContainer().appendChild(e)}}#F(){let e=document.getElementById(Aa);if(!e||!this.#s||!this.#e)return;let t=e.querySelectorAll('[id^="polygon-box-"]');for(let i=0;i<t.length;i++)t[i].remove();for(let i=0;i<this.#s.length;i++){let o=this.#i(this.#s[i].bbox),r=document.createElement("div");r.id=`polygon-box-${i}`,r.style.position="absolute",e.appendChild(r);let a=[Math.min(o[0].x,o[1].x),Math.min(o[0].y,o[1].y)],l=[Math.max(o[0].x,o[1].x),Math.max(o[0].y,o[1].y)];r.style.top=a[1]+"px",r.style.left=a[0]+"px",r.style.width=l[0]-a[0]+"px",r.style.height=l[1]-a[1]+"px",r.style.border=`2px solid ${this.#_?"red":"blue"}`}}destroy(){this.#c.cancel(),this.#g(),super.destroy()}};function At(){return E.logState<=0}function Qf(){let n=0,e=0,t=0;return{buildStart(){At()&&(t=performance.now())},buildDone(i){At()&&E.debug(`[OutdoorLayers] built ${i} footprints in ${(performance.now()-t).toFixed(1)}ms`)},computeStart(){At()&&(n=0)},beginSpan(){At()&&(e=performance.now())},endSpan(){At()&&(n+=performance.now()-e)},computeDone(i,o,r){At()&&E.debug(`[OutdoorLayers] compute cpu ${n.toFixed(1)}ms | polys=${i} added=${o} matched=${r}`)},styleLatch(i,o){At()&&E.debug(`[OutdoorLayers] styledata stylesheet id "${i}" => "${o}"${!i&&o?" (initial id latch)":""}`)}}}g();g();g();import{AlwaysStencilFunc as wg,BufferAttribute as za,CatmullRomCurve3 as Tg,Color as Eg,DoubleSide as Pg,KeepStencilOp as Ji,Matrix4 as Og,Mesh as nd,NotEqualStencilFunc as Ig,RepeatWrapping as Ar,ReplaceStencilOp as Lg,SRGBColorSpace as Ag,ShaderMaterial as Na,TextureLoader as Rg,TubeGeometry as _g,Vector2 as Ua,Vector3 as Qi}from"three";g();import{BufferGeometry as eg,Float32BufferAttribute as vr,Vector3 as Ra}from"three";var xr=class extends eg{tangentData;parameters;constructor(e,t={}){super(),Object.defineProperty(this,"type",{value:"RibbonGeometry"}),this.parameters={path:e};let i=t.segments??64,o=new Ra,r=new Ra,a=new Ra(0,0,1),l=(i+1)*2,s=new Float32Array(l*3),c=new Float32Array(l*3),h=new Float32Array(l*2),d=new Float32Array(l),u=[];this.tangentData=new Float32Array((i+1)*3);let m=0,v=0,b=0;for(let p=0;p<=i;p++){let x=p/i;e.getPointAt(x,o),e.getTangentAt(x,r);let f=p*3;this.tangentData[f]=r.x,this.tangentData[f+1]=r.y,this.tangentData[f+2]=r.z,s[m++]=o.x,s[m++]=o.y,s[m++]=o.z,s[m++]=o.x,s[m++]=o.y,s[m++]=o.z,d[b++]=-1,d[b++]=1,h[v++]=0,h[v++]=x,h[v++]=1,h[v++]=x;let y=p*2*3;c[y]=a.x,c[y+1]=a.y,c[y+2]=a.z,c[y+3]=a.x,c[y+4]=a.y,c[y+5]=a.z}for(let p=0;p<i;p++){let x=p*2;u.push(x,x+2,x+1),u.push(x+1,x+2,x+3)}this.setIndex(u),this.setAttribute("position",new vr(s,3)),this.setAttribute("normal",new vr(c,3)),this.setAttribute("uv",new vr(h,2)),this.setAttribute("side",new vr(d,1))}};g();import{Curve as tg,Vector3 as ig}from"three";var Sr=class extends tg{innerCurve;tStart;tEnd;constructor(e,t,i=!1){super(),this.innerCurve=e,i&&t>=4?(this.tStart=1/(t-1),this.tEnd=(t-2)/(t-1)):(this.tStart=0,this.tEnd=1)}get points(){return this.innerCurve.points}get tension(){return this.innerCurve.tension}get isTrimmed(){return this.tStart!==0||this.tEnd!==1}getPoint(e,t=new ig){let i=this.tStart+e*(this.tEnd-this.tStart);return this.innerCurve.getPoint(i,t)}};g();import{Matrix4 as lg,Ray as cg,Sphere as Zh,Vector3 as ct}from"three";g();import{BufferAttribute as og,Float32BufferAttribute as rg,InstancedBufferAttribute as Mr,InstancedBufferGeometry as ng,Vector3 as kh}from"three";var ag=[0,0,1,0,1,1,0,1],sg=[0,1,2,0,2,3],Cr=new kh,Dr=new kh;function zh(n,e){let t=Math.max(1,Math.floor(e)),i=new Float32Array(t*3),o=new Float32Array(t*3),r=new Float32Array(t),a=new Float32Array(t);for(let s=0,c=0;s<t;s++,c+=3){let h=(s+.5)/t;n.getPointAt(h,Cr),n.getTangentAt(h,Dr),i[c]=Cr.x,i[c+1]=Cr.y,i[c+2]=Cr.z,o[c]=Dr.x,o[c+1]=Dr.y,o[c+2]=Dr.z,r[s]=h,a[s]=s}let l=new ng;return l.instanceCount=t,l.setIndex(new og(new Uint16Array(sg),1)),l.setAttribute("uv",new rg(new Float32Array(ag),2)),l.setAttribute("position",new Mr(i,3)),l.setAttribute("pathTangent",new Mr(o,3)),l.setAttribute("pathDistance",new Mr(r,1)),l.setAttribute("dashIndex",new Mr(a,1)),l}var Gh=128,oi=2048,Ze=.6;function wr(n,e,t){return n.dashAbsolute?n.dashMeters+n.gapMeters:n.dashRelativeToWidth?(n.dashSize+n.gapSize)*t:(n.dashLength+n.dashGap)*e}function Nh(n,e,t){let i=wr(n,e,t);if(i<=0)return Gh;let o=Math.ceil(e/i),r=Gh;for(;r<o&&r<oi;)r*=2;return Math.min(r,oi)}function ri(n,e,t,i){let o=n.screenSpace?Math.max(t*2*i,Ze):t*2,r=wr(n,e,o);return r>0?Math.max(1,Math.min(e/r,n.maxDashCount)):n.maxDashCount}var hg=8,dg=2048,_a=new Zh,Uh=new lg,Hh=new cg,Tr=new ct,Wh=new ct,Ba=new ct,Vh=new ct,jh=new ct,Er=new ct,Pr=new ct,Xh="centerlineRaycast";function Fa(n,e,t,i,o){if(n===e)return n;let r=i!==t?Math.max(0,Math.min(1,(o-t)/(i-t))):0;return n+(e-n)*r}function ug(n){let e=n.nearRadius.value,t=n.farRadius.value,o=Fa(e,t,n.nearZoom.value,n.farZoom.value,n.cameraParameters.value.x)*(n.screenSpace.value?n.metersPerPixel.value:1);return n.screenSpace.value?Math.max(o,Ze/2):o}function mg(n,e){let t=new Float32Array(e*3),i=new Float32Array(e*3),o=1/(e-1);for(let r=0;r<e;r++){n.getPointAt(r*o,Er),n.getTangentAt(r*o,Pr);let a=r*3;t[a]=Er.x,t[a+1]=Er.y,t[a+2]=Er.z,i[a]=Pr.x,i[a+1]=Pr.y,i[a+2]=Pr.z}return{positions:t,tangents:i}}function Yh(n){let e=n.getLength(),t=Math.max(2,Math.min(dg,Math.ceil(e*hg))),{positions:i,tangents:o}=mg(n,t),r=pg(i,t);return{positions:i,tangents:o,size:t,bounds:r}}function pg(n,e){let t=1/0,i=1/0,o=1/0,r=-1/0,a=-1/0,l=-1/0;for(let u=0;u<e;u++){let m=u*3,v=n[m],b=n[m+1],p=n[m+2];v<t&&(t=v),b<i&&(i=b),p<o&&(o=p),v>r&&(r=v),b>a&&(a=b),p>l&&(l=p)}let s=(t+r)/2,c=(i+a)/2,h=(o+l)/2,d=0;for(let u=0;u<e;u++){let m=u*3,v=n[m]-s,b=n[m+1]-c,p=n[m+2]-h,x=v*v+b*b+p*p;x>d&&(d=x)}return new Zh(new ct(s,c,h),Math.sqrt(d))}function fg(n){return n.userData[Xh]}function gg(n,e){let t=fg(this.geometry);if(!t)return;let i=this.matrixWorld,o=this.material.uniforms,{centerline:r}=t,{positions:a,count:l,stride:s}=r;if(l<2)return;let c=t.bounds;if(c===null&&(this.geometry.boundingSphere===null&&this.geometry.computeBoundingSphere(),c=this.geometry.boundingSphere),c===null)return;let d=ug(o)*Math.max(1,o.highlightWidthMultiplier.value);if(_a.copy(c).applyMatrix4(i),_a.radius+=d,!n.ray.intersectsSphere(_a))return;Uh.copy(i).invert(),Hh.copy(n.ray).applyMatrix4(Uh);let u=i.getMaxScaleOnAxis(),m=u!==0?d/u:d,v=m*m,b=1/0,p=1/0,x=-1;Tr.set(a[0],a[1],a[2]);for(let f=1;f<l;f++){Wh.copy(Tr);let y=f*s;Tr.set(a[y],a[y+1],a[y+2]);let C=Hh.distanceSqToSegment(Wh,Tr,Ba,Vh);if(C>v)continue;Ba.applyMatrix4(i);let M=n.ray.origin.distanceTo(Ba);M<n.near||M>n.far||!(M<b-d)&&!(M<=b+d&&C<p)||(b=M,p=C,x=f-1,jh.copy(Vh))}x!==-1&&e.push({distance:b,point:jh.clone().applyMatrix4(i),index:x,face:null,faceIndex:null,object:this})}function Ga(n,e,t){n.geometry.userData[Xh]={centerline:e,bounds:t},n.raycast=gg}function $h(n){let e=n.geometry.attributes.position;if(e===void 0)return;let t={positions:e.array,count:e.count>>>1,stride:6};Ga(n,t,null)}g();import{ClampToEdgeWrapping as qh,DataTexture as yg,FloatType as bg,NearestFilter as Kh,RGBAFormat as vg}from"three";function xg(n,e,t){let i=new Float32Array(t*2*4),o=0,r=t*4;for(let l=0;l<t;l++){let s=l*3;i[o]=n[s],i[o+1]=n[s+1],i[o+2]=n[s+2],i[o+3]=1,i[r]=e[s],i[r+1]=e[s+1],i[r+2]=e[s+2],i[r+3]=0,o+=4,r+=4}let a=new yg(i,t,2,vg,bg);return a.minFilter=Kh,a.magFilter=Kh,a.wrapS=qh,a.wrapT=qh,a.needsUpdate=!0,{texture:a,size:t}}function Jh({component:n,curve:e,baked:t,nearRadius:i,metersPerPixel:o,uniforms:r}){let a=e.getLength(),l=n.screenSpace?Ze:i*2,s=Nh(n,a,l);n.maxDashCount=s,n.curveLength=a;let c=zh(e,s);r.dashCount.value=ri(n,a,i,o);let{texture:h,size:d}=xg(t.positions,t.tangents,t.size);return r.curveTexture.value=h,r.curveTextureSize.value=d,{geometry:c}}g();var Or=`// Force the compiler to compute gl_Position the same way across all shader
281
+ // programs that share this vertex transform. Without this, Apple Silicon /
282
+ // iOS GPU drivers may use different optimized FP paths between shader
283
+ // variants, producing precision drift that shows up as Z-fighting and path
284
+ // micro-jitter. See https://bugs.webkit.org/show_bug.cgi?id=237434
285
+ invariant gl_Position;
286
+
287
+ attribute float pathDistance;
288
+ attribute vec3 pathNormal;
289
+ attribute vec3 pathTangent;
290
+ attribute float side;
291
+ // Stable per-dash identity (discrete-dash geometry only). Drives formula placement
292
+ // and surplus-instance culling (see the isDiscreteDash block in main()).
293
+ attribute float dashIndex;
294
+
295
+
296
+ uniform vec2 uvScale;
297
+ uniform float vertexes;
298
+ uniform float complete;
299
+ uniform float nearRadius;
300
+ uniform float farRadius;
301
+ uniform float nearZoom;
302
+ uniform float farZoom;
303
+ uniform float pulse;
304
+ uniform float pulseLength;
305
+ uniform bool pathIsVertical;
306
+ uniform bool displayArrowsOnPath;
307
+ uniform vec2 cameraParameters;
308
+ uniform bool isRibbon;
309
+ uniform bool isDiscreteDash;
310
+ uniform float pathLength;
311
+ uniform float dashCount;
312
+
313
+ // A discrete-dash path is a dashed path whose dashes are separate primitives, so the
314
+ // dash's along-path extent is the dash "on" size in whichever mode is active \u2014
315
+ // there is no separate dash-length option. These mirror the fragment shader's
316
+ // dash uniforms; only the "on" side is needed here (the gap is already baked
317
+ // into dashCount as spacing).
318
+ uniform bool dashRelativeToWidth;
319
+ uniform bool dashAbsolute;
320
+ uniform float dashSize;
321
+ uniform float dashMeters;
322
+ uniform float dashLength;
323
+ uniform sampler2D curveTexture;
324
+ uniform float curveTextureSize;
325
+ uniform float billboardThreshold;
326
+ uniform mat4 cameraViewMatrix;
327
+ uniform bool screenSpace;
328
+ uniform float metersPerPixel;
329
+ uniform float minPathWidthMeters;
330
+
331
+ varying float zoomLevel;
332
+ varying float radius;
333
+ varying vec2 fragTexcoord;
334
+ varying float fragTopTextureU;
335
+ varying float fragPathDistance;
336
+ // Dash length \xF7 dash width. Derived here rather than passed as a uniform because
337
+ // the absolute and length-scaling modes divide a world length by the dash's
338
+ // width, and that width is only known after the screen-space px\u2192meters
339
+ // conversion below. The fragment shader needs the same ratio to keep the corner
340
+ // radius and the arrow isotropic in world space.
341
+ varying float fragDashAspect;
342
+
343
+ uniform float highlightStartFraction;
344
+ uniform float highlightEndFraction;
345
+ uniform float highlightCompleteFraction;
346
+ uniform float highlightWidthMultiplier;
347
+ uniform vec3 highlightColor;
348
+
349
+ uniform float travelledEndFraction;
350
+ uniform vec3 travelledColor;
351
+
352
+ float flattenFactor = 0.0;
353
+
354
+ // Map the x value from the range [xMin, xMax] to the range [yMin, yMax] using
355
+ // linear interpolation/extrapolation.
356
+ //
357
+ // This performs a pure linear mapping y = mx + b where
358
+ // 'm = (yMax - yMin) / (xMax - xMin)',
359
+ // 'b = -xMin * (yMax - yMin) / (xMax - xMin) + yMin'.
360
+ float remap(float x, float xMin, float xMax, float yMin, float yMax) {
361
+ return (x - xMin) / (xMax - xMin) * (yMax - yMin) + yMin;
362
+ }
363
+
364
+ // Map the x value from [xMin, xMax] to the range [yMin, yMax] using linear
365
+ // interpolation, clamping result values outside [yMin, yMax].
366
+ float clampRemap(float x, float xMin, float xMax, float yMin, float yMax) {
367
+ return clamp(remap(x, xMin, xMax, yMin, yMax), yMin, yMax);
368
+ }
369
+
370
+ // Sample the baked curve texture at arc-length fraction s (row 0 = positions,
371
+ // row 1 = tangents). Float textures aren't guaranteed to support hardware
372
+ // linear filtering, so we fetch the two neighbouring texels (Nearest) and lerp
373
+ // manually. This keeps flowing dashes smooth between samples on any GPU.
374
+ vec3 sampleCurveRow(float s, float row) {
375
+ float fu = clamp(s, 0.0, 1.0) * (curveTextureSize - 1.0);
376
+ float i0 = floor(fu);
377
+ float frac = fu - i0;
378
+ float u0 = (i0 + 0.5) / curveTextureSize;
379
+ float u1 = (i0 + 1.5) / curveTextureSize;
380
+ vec3 a = texture2D(curveTexture, vec2(u0, row)).xyz;
381
+ vec3 b = texture2D(curveTexture, vec2(u1, row)).xyz;
382
+ return mix(a, b, frac);
383
+ }
384
+
385
+ // Sample a discrete dash's arc-length fraction, centre, and tangent from the
386
+ // baked curve. Returns false when the instance is surplus (beyond the per-frame
387
+ // effective count), so the caller writes an off-screen vertex for the cost of a
388
+ // compare + branch rather than a texture fetch. The +0.5 mirrors the
389
+ // (dashIndex + 0.5) / dashCount placement: a dash is visible while its centre
390
+ // lands before s = 1, so a non-integer count never wraps its last visible dash
391
+ // back over dash 0.
392
+ bool sampleDiscreteDash(out vec3 center, out vec3 tangent, out float s) {
393
+ if (dashIndex + 0.5 >= dashCount) {
394
+ return false;
395
+ }
396
+ // Formula placement: every dash's arc-length position is derived from its
397
+ // index and the effective count (a per-frame uniform), not from a baked
398
+ // position. Each dash sits at (dashIndex + 0.5) / dashCount \u2014 its cell.
399
+ s = fract((dashIndex + 0.5) / dashCount);
400
+ center = sampleCurveRow(s, 0.25);
401
+ tangent = sampleCurveRow(s, 0.75);
402
+ return true;
403
+ }
404
+
405
+ // The dash's along-path half-extent relative to its width. Width-scaling is
406
+ // already a multiple of the width, so it *is* the aspect; the other two modes
407
+ // produce a world length that must be divided by the (possibly screen-space)
408
+ // width here, which is why this can't be a CPU-side uniform.
409
+ float computeDashAspect(float dashWorldRadius) {
410
+ float dashWorldLength;
411
+ if (dashRelativeToWidth) {
412
+ dashWorldLength = dashSize * dashWorldRadius * 2.0;
413
+ } else if (dashAbsolute) {
414
+ dashWorldLength = dashMeters;
415
+ } else {
416
+ dashWorldLength = dashLength * pathLength;
417
+ }
418
+ return max(dashWorldLength / max(dashWorldRadius * 2.0, 1e-4), 0.01);
419
+ }
420
+
421
+ // A unit vector perpendicular to along. Prefer the axis in the preferred plane
422
+ // (the billboard width axis) when it's well-defined; otherwise fall back to the
423
+ // world axis least parallel to along. A vector is parallel to at most one world
424
+ // axis, so the select always resolves \u2014 no nested near-zero cascade.
425
+ vec3 perpendicular(vec3 along, vec3 preferred) {
426
+ vec3 r = cross(along, preferred);
427
+ float lenSq = dot(r, r);
428
+ if (lenSq < 1e-6) {
429
+ r = cross(along, abs(along.z) < 0.9 ? vec3(0.0, 0.0, 1.0) : vec3(0.0, 1.0, 0.0));
430
+ lenSq = dot(r, r);
431
+ }
432
+ return r * inversesqrt(lenSq);
433
+ }
434
+
435
+ // Build the (right, up) basis for one dash. Steep (near-vertical) sections
436
+ // billboard so dashes on connection paths keep their shape instead of flattening
437
+ // into ellipses. The long axis (up) always stays on the real 3D tangent so the
438
+ // dash \u2014 and its arrow \u2014 keeps tracking the travel direction; only the width
439
+ // (right) rolls toward the camera via cross(tangent, viewDir), the same
440
+ // tangent-aligned billboard the ribbon branch uses. Returns false only when no
441
+ // travel direction survives (near-vertical tangent with billboarding off), so the
442
+ // caller draws the dash square rather than along an arbitrary world axis.
443
+ bool computeDashBasis(vec3 tangent, out vec3 right, out vec3 up) {
444
+ bool billboard = billboardThreshold >= 0.0 && abs(tangent.z) >= billboardThreshold;
445
+ if (billboard) {
446
+ // Keep the dash's long axis on the real 3D tangent so its orientation (and
447
+ // arrow) tracks the travel direction rather than rolling with the camera's
448
+ // pitch/roll. Only the width billboards, via cross(tangent, viewDir) \u2014 the
449
+ // same tangent-aligned form the ribbon branch uses, so discrete dashes and
450
+ // the ribbon can't disagree on how a steep section faces.
451
+ up = normalize(tangent);
452
+ vec3 viewDir = -vec3(cameraViewMatrix[0][2], cameraViewMatrix[1][2], cameraViewMatrix[2][2]);
453
+ right = perpendicular(up, viewDir);
454
+ return true;
455
+ }
456
+ // Orient the dash along the full 3D tangent so its long axis (and arrow) tilts
457
+ // with the path slope instead of lying flat on the ground plane. right stays
458
+ // horizontal \u2014 perpendicular to both world-up and the tangent \u2014 so a flat path
459
+ // (tangent.z \u2248 0) keeps its existing orientation.
460
+ up = normalize(tangent);
461
+ right = cross(vec3(0.0, 0.0, 1.0), up);
462
+ float rightLen = length(right);
463
+ if (rightLen > 0.001) {
464
+ right /= rightLen;
465
+ return true;
466
+ }
467
+ // Near-vertical tangent with billboarding off: fall back to world axes.
468
+ up = vec3(0.0, 1.0, 0.0);
469
+ right = vec3(1.0, 0.0, 0.0);
470
+ return false;
471
+ }
472
+
473
+ void main() {
474
+ // Defensive guard: if the position attribute is NaN (which can happen
475
+ // transiently after a WebGL context loss + restore on iOS Safari, before
476
+ // per-vertex buffers have been re-uploaded), output a vertex outside the
477
+ // clip volume so the GPU discards it cleanly. Without this, the ribbon
478
+ // expansion below produces a "fan of lines" artifact emanating from a
479
+ // single point on the map. NaN is the only value where x != x.
480
+ if (position.x != position.x || position.y != position.y || position.z != position.z) {
481
+ gl_Position = vec4(2.0, 2.0, 2.0, 1.0);
482
+ return;
483
+ }
484
+
485
+ fragPathDistance = pathDistance;
486
+ // Written unconditionally: the fragment shader's reads are all guarded by
487
+ // isDiscreteDash today, but an unwritten varying is undefined behaviour and this
488
+ // costs nothing.
489
+ fragDashAspect = 1.0;
490
+
491
+ vec3 adjustedPosition = position;
492
+ zoomLevel = clampRemap(cameraParameters.x, nearZoom, farZoom, 0.0, 1.0);
493
+
494
+ // Screen-space-aware half-radii in world units. In screen-space mode
495
+ // nearRadius/farRadius are pixel half-widths (and equal), so scale by
496
+ // metersPerPixel to keep a constant pixel width on screen regardless of zoom.
497
+ // The dash width is floored at minPathWidthMeters * 0.5 so zoom-in
498
+ // (metersPerPixel -> 0) never shrinks a dash below 0.6m, which bounds the
499
+ // dash count. See ADR 0005.
500
+ float effNear = screenSpace ? max(nearRadius * metersPerPixel, minPathWidthMeters * 0.5) : nearRadius;
501
+ float effFar = screenSpace ? max(farRadius * metersPerPixel, minPathWidthMeters * 0.5) : farRadius;
502
+ // A ribbon has no dashes, so it is not floored: it is drawn at the width it asked for.
503
+ float ribbonNear = screenSpace ? nearRadius * metersPerPixel : nearRadius;
504
+ float ribbonFar = screenSpace ? farRadius * metersPerPixel : farRadius;
505
+
506
+ // Only apply normal-based expansion for TubeGeometry
507
+ // Ribbons have normal=(0,0,1) which would shift them up incorrectly
508
+ if (!isRibbon && !isDiscreteDash) {
509
+ float expansionFactor = (farRadius - nearRadius) * zoomLevel;
510
+ adjustedPosition += normal * expansionFactor;
511
+ }
512
+
513
+ // Animate the reveal endpoint from highlightStartFraction to highlightEndFraction
514
+ // so the width expansion follows the same reveal as the fragment shader.
515
+ float revealedHighlightEnd = mix(highlightStartFraction, highlightEndFraction, highlightCompleteFraction);
516
+ bool isHighlighted = fragPathDistance > highlightStartFraction && fragPathDistance <= revealedHighlightEnd;
517
+
518
+ // For TubeGeometry: apply highlight width expansion using normal
519
+ if (!isRibbon && !isDiscreteDash && isHighlighted) {
520
+ adjustedPosition += normal * (highlightWidthMultiplier - 1.) / 2.;
521
+ }
522
+
523
+ // Discrete dashes: rebuild each dash's quad around its center. The local
524
+ // unit-quad corner is encoded in uv, so the size can scale with zoom and the
525
+ // highlight without touching the buffer; the fragment shader carves the
526
+ // rounded rectangle out of the quad.
527
+ //
528
+ // discUp is always the travel direction (tangent, or its screen projection
529
+ // when billboarding) and discRight is perpendicular to it. Unlike the circle
530
+ // this replaced, a rectangle is not rotationally symmetric, so the basis has
531
+ // to track the path even when no arrow is drawn \u2014 otherwise an elongated dash
532
+ // would point along a world/screen axis instead of along the path.
533
+ if (isDiscreteDash) {
534
+ vec2 discOffset = (uv - 0.5) * 2.0;
535
+
536
+ vec3 dashCenter;
537
+ vec3 dashTangent;
538
+ float s;
539
+ if (!sampleDiscreteDash(dashCenter, dashTangent, s)) {
540
+ gl_Position = vec4(2.0, 2.0, 2.0, 1.0);
541
+ return;
542
+ }
543
+ // Downstream reveal/highlight/travelled coloring follows the dash.
544
+ fragPathDistance = s;
545
+
546
+ float dashWorldRadius = mix(effNear, effFar, zoomLevel);
547
+ float dashAspect = computeDashAspect(dashWorldRadius);
548
+
549
+ vec3 discRight;
550
+ vec3 discUp;
551
+ if (!computeDashBasis(dashTangent, discRight, discUp)) {
552
+ dashAspect = 1.0;
553
+ }
554
+ fragDashAspect = dashAspect;
555
+
556
+ // discRadius is the half-width across the path; the along-path half-extent
557
+ // is stretched by dashAspect.
558
+ float discRadius = dashWorldRadius;
559
+ if (isHighlighted) {
560
+ discRadius *= highlightWidthMultiplier;
561
+ }
562
+ adjustedPosition = dashCenter + (discRight * discOffset.x + discUp * discOffset.y * dashAspect) * discRadius;
563
+ }
564
+
565
+ // Unified ribbon width handling for both billboarded and non-billboarded
566
+ if (isRibbon && !isDiscreteDash) {
567
+ vec3 right;
568
+
569
+ // Determine if this vertex should billboard
570
+ // billboardThreshold < 0: off, == 0: unconditional, > 0: precomputed sin(angle)
571
+ bool shouldBillboard = billboardThreshold >= 0.0
572
+ && abs(pathTangent.z) >= billboardThreshold;
573
+
574
+ if (shouldBillboard) {
575
+ // Camera-facing right vector
576
+ vec3 viewDir = -vec3(cameraViewMatrix[0][2], cameraViewMatrix[1][2], cameraViewMatrix[2][2]);
577
+ right = perpendicular(pathTangent, viewDir);
578
+ } else {
579
+ // Flat world-space right vector (perpendicular in XY plane)
580
+ right = vec3(-pathTangent.y, pathTangent.x, 0.0);
581
+ float rightLen = length(right);
582
+ if (rightLen > 0.001) {
583
+ right /= rightLen;
584
+ } else {
585
+ right = vec3(1.0, 0.0, 0.0);
586
+ }
587
+ }
588
+
589
+ // Apply base half-width (geometry stores centerline only)
590
+ adjustedPosition += right * ribbonNear * side;
591
+
592
+ // Shared: zoom-based expansion
593
+ float expansionFactor = (ribbonFar - ribbonNear) * zoomLevel;
594
+ adjustedPosition += right * expansionFactor * side;
595
+
596
+ // Shared: highlight width expansion (using right instead of normal)
597
+ if (isHighlighted) {
598
+ float highlightExpansion = ribbonNear * (highlightWidthMultiplier - 1.0);
599
+ adjustedPosition += right * highlightExpansion * side;
600
+ }
601
+ }
602
+
603
+ // For TubeGeometry: flatten the bottom half of the tube
604
+ if (!isRibbon && !isDiscreteDash && !pathIsVertical) {
605
+ // We can get an origin point for the cross-section of the path by
606
+ // subtracting the surface normal times the radius, since the surface normal
607
+ // points strictly away from the centre.
608
+ vec3 origin = position - nearRadius * normal;
609
+
610
+ // Determine how far the path extends "up" or "down" in the direction of the
611
+ // path normal.
612
+ float height = dot(adjustedPosition - origin, pathNormal);
613
+
614
+ // For horizontal paths, flatten the bottom half entirely so that it's flat
615
+ // against the floor. This makes the path look nicer when it's
616
+ // semitransparent behind opaque geometry, so you don't see it
617
+ // peeking through.
618
+ float desiredHeight = max(height, 0.0);
619
+ desiredHeight = desiredHeight * flattenFactor;
620
+ float flattenMagnitude = height - desiredHeight;
621
+ adjustedPosition = adjustedPosition - pathNormal * flattenMagnitude;
622
+ }
623
+
624
+ // Transform the vertices into NDC.
625
+ vec4 mvPosition = modelViewMatrix * vec4(adjustedPosition, 1.0);
626
+ gl_Position = projectionMatrix * mvPosition;
627
+
628
+ fragTexcoord = uv;
629
+
630
+ // Compute fragTopTextureU for arrow texture mapping
631
+ if (isRibbon) {
632
+ // For RibbonGeometry: uv.x is already 0-1 across ribbon width
633
+ fragTopTextureU = uv.x;
634
+ } else {
635
+ // For TubeGeometry: compute texture coordinate to handle tube twisting
636
+ // We want the arrow texture to always be on the top of the path
637
+ vec3 bitangent = cross(normal, pathTangent);
638
+ fragTopTextureU = -dot(bitangent, pathNormal) * 0.5 + 0.5;
639
+ if (isHighlighted) {
640
+ fragTopTextureU = -dot(bitangent, pathNormal * highlightWidthMultiplier) * 0.5 + 0.5;
641
+ }
642
+ }
643
+
644
+ // For ribbon paths this equals mix(ribbonNear, ribbonFar, zoomLevel); tube geometry
645
+ // keeps its radius un-scaled, hence the explicit gate below.
646
+ radius = mix(nearRadius, farRadius, zoomLevel);
647
+ if (screenSpace && isRibbon) {
648
+ radius = radius * metersPerPixel;
649
+ }
650
+ }
651
+ `;g();var ka=`#define ARROW_FADING_POINT 0.15
652
+
653
+ uniform float complete;
654
+ uniform float nearRadius;
655
+ uniform float farRadius;
656
+ uniform vec2 resolution;
657
+ uniform vec2 cameraParameters;
658
+ uniform vec3 color;
659
+ uniform float pathLength;
660
+ uniform bool showPulse;
661
+ uniform vec3 pulseColor;
662
+ uniform float pulse;
663
+ uniform float pulseLength;
664
+ uniform bool pathIsVertical;
665
+ uniform bool displayArrowsOnPath;
666
+ uniform float arrowAnimationTimer;
667
+ uniform float opacityMultiplier;
668
+ uniform bool dashed;
669
+ uniform float xrayDithering;
670
+ uniform float dashLength;
671
+ uniform float dashGap;
672
+ uniform bool dashRelativeToWidth;
673
+ uniform float dashSize;
674
+ uniform float gapSize;
675
+ uniform bool dashAbsolute;
676
+ uniform float dashMeters;
677
+ uniform float gapMeters;
678
+ uniform sampler2D arrowTexture;
679
+
680
+ varying float zoomLevel;
681
+ varying float radius;
682
+ varying vec2 fragTexcoord;
683
+ varying float fragTopTextureU;
684
+ varying float fragPathDistance;
685
+ // Dash length \xF7 dash width, derived in the vertex shader from the dash "on" size
686
+ // (see fragDashAspect there). Only meaningful when isDiscreteDash.
687
+ varying float fragDashAspect;
688
+
689
+
690
+ uniform float highlightStartFraction;
691
+ uniform float highlightEndFraction;
692
+ uniform float highlightCompleteFraction;
693
+ uniform vec3 highlightColor;
694
+ uniform bool highlightDisplayArrowsOnPath;
695
+
696
+ uniform float travelledEndFraction;
697
+ uniform vec3 travelledColor;
698
+
699
+ // Border uniforms for ribbon geometry
700
+ uniform bool borderEnabled;
701
+ uniform vec3 borderColor;
702
+ uniform float borderWidth;
703
+ uniform bool borderUseDarken;
704
+ uniform bool isRibbon;
705
+ uniform bool isDiscreteDash;
706
+ // Corner rounding of a dash, 0 = sharp rectangle, 1 = fully rounded (a circle
707
+ // when fragDashAspect is 1.0, a stadium when it is larger). Fraction of the short
708
+ // half-side, like a CSS border-radius in percent, so it stays proportional as
709
+ // the dash resizes with zoom.
710
+ uniform float dashCornerRadius;
711
+
712
+ // Endcap uniforms for ribbon geometry
713
+ // x = start cap enabled (>0), y = end cap enabled (>0)
714
+ uniform vec2 endcapEnabled;
715
+
716
+ // How long the arrow should be, as a factor of pathRadius. Since we've
717
+ // mostly flattened the top of the path, values near 2.0 (the diameter)
718
+ // will probably look best.
719
+ const float arrowLength = 2.0;
720
+
721
+ // How much of a relative margin the arrow texture should have inside the
722
+ // area laid out for it. Useful to pull the arrow away from the edges of the
723
+ // path, which slope down.
724
+ const float arrowMargin = 0.1;
725
+
726
+ // Fraction of a dash's width the per-dash arrow occupies. The arrow texture is
727
+ // mapped onto this centred fraction of the dash's uv square; the rest of the dash
728
+ // stays plain. Lower = smaller arrow inside the dash.
729
+ const float dashArrowFill = 0.55;
730
+
731
+ // How many arrow-lengths of space should be between arrows on a short path.
732
+ const float arrowSpacingOnShortPath = 6.0;
733
+
734
+ // How many arrow-lengths of space should be between arrows on a long path.
735
+ const float arrowSpacingOnLongPath = 7.5;
736
+
737
+ // How long a path must be to be considered "long", as a factor of
738
+ // the path radius.
739
+ const float longPathLength = 200.;
740
+
741
+ // How long a path must be to be considered "short", as a factor of the
742
+ // path radius.
743
+ const float shortPathLength = 75.;
744
+
745
+ // How much of the path's length the fade-in should comprise when going from
746
+ // zero opacity to full opacity.
747
+ const float completeLength = 0.1;
748
+
749
+ // Map the x value from the range [xMin, xMax] to the range [yMin, yMax] using
750
+ // linear interpolation/extrapolation.
751
+ //
752
+ // This performs a pure linear mapping 'y = mx + b' where
753
+ // 'm = (yMax - yMin) / (xMax - xMin)',
754
+ // 'b = -xMin * (yMax - yMin) / (xMax - xMin) + yMin'.
755
+ float remap(float x, float xMin, float xMax, float yMin, float yMax) {
756
+ return (x - xMin) / (xMax - xMin) * (yMax - yMin) + yMin;
757
+ }
758
+
759
+ // Map the x value from [xMin, xMax] to the range [yMin, yMax] using linear
760
+ // interpolation, clamping result values outside [yMin, yMax].
761
+ float clampRemap(float x, float xMin, float xMax, float yMin, float yMax) {
762
+ return clamp(remap(x, xMin, xMax, yMin, yMax), yMin, yMax);
763
+ }
764
+
765
+ // Signed distance to a rounded rectangle centred on the origin. Negative
766
+ // inside, zero on the edge. The standard construction: shrink the box by r,
767
+ // measure the distance to that inner box, then subtract r to round it back out.
768
+ //
769
+ // p - offset from the rectangle centre
770
+ // b - half-extents
771
+ // r - corner radius (must not exceed min(b.x, b.y))
772
+ float sdRoundBox(vec2 p, vec2 b, float r) {
773
+ vec2 q = abs(p) - b + r;
774
+ return min(max(q.x, q.y), 0.0) + length(max(q, vec2(0.0))) - r;
775
+ }
776
+
777
+ // Signed distance from a point in a dash's uv square to the dash's rounded-
778
+ // rectangle edge, in units of the across-path half-width.
779
+ //
780
+ // uv.y spans the length, which the vertex shader already stretched by
781
+ // fragDashAspect, so it is scaled back up here to put both axes in the same world
782
+ // units. Without that the corner radius would stretch along with the dash
783
+ // instead of staying circular.
784
+ //
785
+ // fragDashAspect 1 + dashCornerRadius 1 reduces to length(p) - 1: exactly the circle
786
+ // this shape replaced.
787
+ float dashSignedDistance(vec2 texcoord) {
788
+ vec2 p = (texcoord - 0.5) * 2.0;
789
+ p.y *= fragDashAspect;
790
+ vec2 b = vec2(1.0, fragDashAspect);
791
+ float r = clamp(dashCornerRadius, 0.0, 1.0) * min(b.x, b.y);
792
+ return sdRoundBox(p, b, r);
793
+ }
794
+
795
+ void main(void) {
796
+ // Compute the opacity of the path based on the distance from the current
797
+ // fragment to the 'complete' value as it varies from 0.0 to 1.0.
798
+ // Fragments that are at the 'complete' value or past it will be fully
799
+ // transparent, while fragments that are at 'complete - completeLength'
800
+ // or before it will be fully opaque. However, we adjust the 'complete'
801
+ // value here so that it overshoots by one full 'completeLength', so that
802
+ // the entire path will be opaque when the 'complete' value is at 1.0.
803
+ float completeLocation = complete * (1.0 + completeLength);
804
+ float completeAmount = clampRemap(
805
+ fragPathDistance,
806
+ completeLocation - completeLength,
807
+ completeLocation,
808
+ 0.0,
809
+ 1.0
810
+ );
811
+ float opacity = 1.0 - smoothstep(0.0, 1.0, completeAmount);
812
+
813
+ // 2020/01/09 Terence Dickson
814
+ // When we render the background and overlay for the mapbox outdoor context
815
+ // behind everything else in single-buffer rendering, the fact that the path
816
+ // writes to the depth buffer means that the background and overlay will not
817
+ // be drawn behind the path even when the path is still fading in. The effect
818
+ // is subtle and is only visible in single-buffer rendering so this quick fix
819
+ // prevents writes to the depth buffer for zero opacity fragments, which gets
820
+ // rid of the most visually-offensive ghosting.
821
+ if (opacity <= 0.0) {
822
+ discard;
823
+ }
824
+
825
+
826
+ // Carve the dash's rounded rectangle out of its quad. The geometry is only a
827
+ // bare quad, so this discard is what gives a dash its shape at all \u2014 unlike
828
+ // the ribbon endcaps below, it is not an optional refinement. The SDF is
829
+ // reused for the border ring below, so compute it once here.
830
+ float dashSDF = isDiscreteDash ? dashSignedDistance(fragTexcoord) : 0.0;
831
+ if (isDiscreteDash && dashSDF > 0.0) discard;
832
+
833
+ // Apply rounded endcaps for ribbon geometry using SDF
834
+ // endcapEnabled.x = start cap (>0 enabled), endcapEnabled.y = end cap (>0 enabled)
835
+ // Creates semicircular caps at start and/or end; disabled caps are square
836
+ float startCapOn = step(0.5, endcapEnabled.x);
837
+ float endCapOn = step(0.5, endcapEnabled.y);
838
+ if ((startCapOn > 0.5 || endCapOn > 0.5) && isRibbon) {
839
+ float endcapRadius = radius / pathLength;
840
+ float xDist = abs(fragTexcoord.x - 0.5);
841
+ float scaledXSq = xDist * xDist * 4.0;
842
+
843
+ // Start cap: only apply SDF when enabled
844
+ float startT = clamp(1.0 - fragPathDistance / endcapRadius, 0.0, 1.0);
845
+ float startSDF = startT * startT + scaledXSq - 1.0;
846
+ float inStartCap = step(fragPathDistance, endcapRadius);
847
+ float outsideStart = inStartCap * step(0.0, startSDF) * startCapOn;
848
+
849
+ // End cap: only apply SDF when enabled
850
+ float endCapPos = min(completeLocation, 1.0);
851
+ float endCapStart = endCapPos - endcapRadius;
852
+ float endT = clamp(1.0 - (endCapPos - fragPathDistance) / endcapRadius, 0.0, 1.0);
853
+ float endSDF = endT * endT + scaledXSq - 1.0;
854
+ float inEndCap = step(endCapStart, fragPathDistance);
855
+ float outsideEnd = inEndCap * step(0.0, endSDF) * endCapOn;
856
+
857
+ // Discard if outside semicircle in enabled cap region
858
+ if (max(outsideStart, outsideEnd) > 0.5) discard;
859
+ }
860
+
861
+ // Push in the texture coordinates so that they ramp up
862
+ // at 'arrowMargin' instead of at zero; this remapping looks somewhat
863
+ // like this:
864
+ // 1 ^ ___
865
+ // | /
866
+ // | /
867
+ // | /
868
+ // | /
869
+ // |___/
870
+ // 0 +---------->
871
+ // 0 ^ 1
872
+ // arrowMargin
873
+ // Making the arrows narrower on the path.
874
+ float u = fragTopTextureU;
875
+ u = clamp(
876
+ u * (1. / (1. - arrowMargin * 2.)) - (1. / (1. - arrowMargin * 2.) - 1.) / 2.,
877
+ 0.0,
878
+ 1.0
879
+ );
880
+
881
+ float arrowSpacing = clampRemap(
882
+ pathLength,
883
+ shortPathLength * radius,
884
+ longPathLength * radius,
885
+ arrowSpacingOnShortPath,
886
+ arrowSpacingOnLongPath
887
+ );
888
+
889
+ // Reduce the spacing between arrows when the camera zooms out, as increasing
890
+ // the path radius will increase the arrow size and thus be able to fit
891
+ // fewer arrows on in total, and this secondary movement of the arrows
892
+ // "zooming off" the end of the path is unpleasant
893
+ float expandAmount = mix(1.0, farRadius / nearRadius, zoomLevel);
894
+ float effectiveArrowSpacing =
895
+ arrowSpacing * 1.0 / expandAmount +
896
+ arrowMargin * 2.0;
897
+
898
+ float effectiveArrowLength = arrowLength * radius * (1. - arrowMargin * 2.0);
899
+
900
+ // Adjust the slope of the vertical texture coordinate so that it goes
901
+ // from 0 to 1 along the length of the arrow plus the spacing between
902
+ // arrows, and adjust its x-intercept so that one arrow moves to the
903
+ // exact position of the next arrow as 'arrowAnimationTimer' goes
904
+ // from 0 to 1
905
+ // Note: Using fragPathDistance (0-1 along path) for RibbonGeometry
906
+ float v = (
907
+ fragPathDistance * (pathLength / effectiveArrowLength)
908
+ - arrowAnimationTimer * (1. + effectiveArrowSpacing)
909
+ );
910
+
911
+ // Compute a "looping sawtooth" wave for determining the vertical texture
912
+ // coordinates of the arrow texture, roughly as follows:
913
+ // 3 ^ /
914
+ // | ___/
915
+ // 2 | /
916
+ // | ___/
917
+ // 1 | /
918
+ // |___/
919
+ // 0 +--------------->
920
+ // 0 ^ ^
921
+ // ^ |_|
922
+ // | effectiveArrowLength
923
+ // |___|
924
+ // effectiveArrowSpacing
925
+ //
926
+ // This is effectively equivalent to this sort of sawtooth wave:
927
+ // ^
928
+ // 1 | / / /
929
+ // |___/ ___/ ___/
930
+ // 0 +--------------->
931
+ //
932
+ // Causing the image of the arrow to repeat, with dead space (the bottom
933
+ // edge of the texture stretched out) between the arrows at the provided
934
+ // spacing. The reason why the "looping" design is preferred is because
935
+ // it takes advantage of WebGL's 'GL_REPEAT' texture wrapping behaviour
936
+ // to avoid the discontinuity that can end up causing visual artifacts.
937
+ if (mod(v, (1. + effectiveArrowSpacing)) < 1.) {
938
+ v = v - effectiveArrowSpacing * floor(v / (1. + effectiveArrowSpacing));
939
+ } else {
940
+ v = ceil(v / (1. + effectiveArrowSpacing));
941
+ }
942
+
943
+ // Use the r-component of the texture to determine whether the arrow covers
944
+ // this fragment or not.
945
+ //
946
+ // Discrete dashes draw one complete arrow per dash: the dash's own uv square
947
+ // is mapped straight onto the arrow texture instead of the path-length
948
+ // sawtooth, so every dash carries a single chevron. The arrow is centred and
949
+ // scaled to dashArrowFill of the dash's width so it sits comfortably inside
950
+ // the edge; fragments outside that region clamp to the (empty) texture edge.
951
+ // The vertex shader aligns the dash's up axis (uv.y) to the path tangent, so
952
+ // the arrow points in the direction of travel.
953
+ //
954
+ // The along-path axis is scaled by fragDashAspect so the chevron stays square
955
+ // in world space: on an elongated dash the arrow keeps its proportions and
956
+ // sits centred in the pill rather than stretching to fill it.
957
+ float arrowAmount = 0.0;
958
+ vec3 secondColor = pulseColor;
959
+
960
+ vec3 finalColor = color;
961
+
962
+ // Apply travelled color to the portion of the path that has been travelled.
963
+ if (fragPathDistance < travelledEndFraction) {
964
+ finalColor = travelledColor;
965
+ }
966
+
967
+ // Adjust the color based on the highlight but only if the fragment is within
968
+ // the highlight start and the currently revealed end. The revealed end animates
969
+ // from highlightStartFraction to highlightEndFraction so the reveal starts at
970
+ // the highlight's beginning regardless of where it sits along the path.
971
+ // [Anzor] 0.005 smooths the transition when the width multiplier is large.
972
+ float revealedHighlightEnd = mix(highlightStartFraction, highlightEndFraction, highlightCompleteFraction);
973
+ bool inHighlight = fragPathDistance > highlightStartFraction - 0.005 && fragPathDistance <= revealedHighlightEnd;
974
+ if (inHighlight) {
975
+ finalColor = highlightColor;
976
+ }
977
+
978
+ // Arrows can be toggled independently inside vs outside the highlight.
979
+ bool effectiveDisplayArrows = inHighlight ? highlightDisplayArrowsOnPath : displayArrowsOnPath;
980
+
981
+ // Apply border effect for ribbon geometry
982
+ // fragTexcoord.x: 0\u21921 across ribbon width; edgeDist = distance to nearest edge
983
+ if (borderEnabled && isRibbon) {
984
+ float edgeDist = min(fragTexcoord.x, 1.0 - fragTexcoord.x);
985
+
986
+ // For endcaps, compute radial distance from semicircle edge instead
987
+ float endcapRadius = radius / pathLength;
988
+ float endCapPos = min(completeLocation, 1.0);
989
+ float endCapStart = endCapPos - endcapRadius;
990
+
991
+ // Check each cap region independently
992
+ bool inStartRegion = fragPathDistance <= endcapRadius && startCapOn > 0.5;
993
+ bool inEndRegion = fragPathDistance > endCapStart && endCapOn > 0.5;
994
+
995
+ if (inStartRegion || inEndRegion) {
996
+ float xDist = abs(fragTexcoord.x - 0.5);
997
+ float scaledXSq = xDist * xDist * 4.0;
998
+
999
+ if (inStartRegion) {
1000
+ float startT = 1.0 - fragPathDistance / endcapRadius;
1001
+ float r = sqrt(startT * startT + scaledXSq);
1002
+ edgeDist = 0.5 * (1.0 - r);
1003
+ } else {
1004
+ float endT = 1.0 - (endCapPos - fragPathDistance) / endcapRadius;
1005
+ float r = sqrt(endT * endT + scaledXSq);
1006
+ edgeDist = 0.5 * (1.0 - r);
1007
+ }
1008
+ }
1009
+
1010
+ if (edgeDist < borderWidth) {
1011
+ finalColor = borderUseDarken ? finalColor * 0.6 : borderColor;
1012
+ }
1013
+ }
1014
+
1015
+ // Apply the border ring for discrete-dash paths. Reuse the same SDF that carved the
1016
+ // shape so the border follows the rounded corners exactly instead of
1017
+ // approximating them. The distance is negative inside and measured in
1018
+ // across-path half-widths, so -d converts to the ribbon's edge-distance units
1019
+ // (0 at the edge, 0.5 at the centre of a square dash) and borderWidth keeps
1020
+ // behaving consistently across geometries.
1021
+ if (borderEnabled && isDiscreteDash) {
1022
+ float edgeDist = -dashSDF * 0.5;
1023
+ if (edgeDist < borderWidth) {
1024
+ finalColor = borderUseDarken ? finalColor * 0.6 : borderColor;
1025
+ }
1026
+ }
1027
+
1028
+ if (effectiveDisplayArrows) {
1029
+ vec2 sampleTexcoord;
1030
+ if (isDiscreteDash) {
1031
+ vec2 dashOffset = fragTexcoord - 0.5;
1032
+ dashOffset.y *= fragDashAspect;
1033
+ sampleTexcoord = clamp(dashOffset / dashArrowFill + 0.5, 0.0, 1.0);
1034
+ } else {
1035
+ sampleTexcoord = vec2(u, v);
1036
+ }
1037
+ arrowAmount = texture2D(arrowTexture, sampleTexcoord).r;
1038
+ float delta = 1.0 - abs(fragPathDistance * 2.0 - 1.0);
1039
+ secondColor = mix(finalColor, pulseColor, 1.0 - smoothstep(ARROW_FADING_POINT, 0.0, delta));
1040
+ }
1041
+
1042
+ if (dashed) {
1043
+ float effectiveDashLength;
1044
+ float effectiveGapLength;
1045
+
1046
+ if (dashAbsolute) {
1047
+ // Absolute mode: dashMeters/gapMeters are in meters
1048
+ // Convert to path-distance fraction using pathLength
1049
+ effectiveDashLength = dashMeters / pathLength;
1050
+ effectiveGapLength = gapMeters / pathLength;
1051
+ } else if (dashRelativeToWidth) {
1052
+ // Width-relative mode: dashSize/gapSize are multiples of path width
1053
+ // Convert to path-distance fraction using radius
1054
+ effectiveDashLength = (dashSize * radius * 2.0) / pathLength;
1055
+ effectiveGapLength = (gapSize * radius * 2.0) / pathLength;
1056
+ } else {
1057
+ // Length-fraction mode: use dashLength/dashGap directly as path fractions
1058
+ effectiveDashLength = dashLength;
1059
+ effectiveGapLength = dashGap;
1060
+ }
1061
+
1062
+ float totalLength = effectiveDashLength + effectiveGapLength;
1063
+ float numSegments = ceil(1.0 / totalLength);
1064
+ float adjustedTotalLength = 1.0 / numSegments;
1065
+ float adjustedDashLength = adjustedTotalLength * (effectiveDashLength / totalLength);
1066
+ float pattern = mod(fragPathDistance, adjustedTotalLength);
1067
+ opacity = pattern < adjustedDashLength ? 1.0 : 0.0;
1068
+ }
1069
+
1070
+
1071
+
1072
+ if (showPulse) {
1073
+ // Add the pulse color to the path by determining how far the current fragment
1074
+ // is from 'pulse'
1075
+ float pulseLocation = remap(
1076
+ pulse,
1077
+ 0.0,
1078
+ 1.0,
1079
+ -pulseLength,
1080
+ 1.0 + pulseLength
1081
+ );
1082
+ float pulseDistance = smoothstep(
1083
+ 0.0,
1084
+ pulseLength,
1085
+ abs(fragPathDistance - pulseLocation)
1086
+ );
1087
+
1088
+ // Blend the pulse color to the path based on how close this fragment is to
1089
+ // the 'pulse' value and whether it's covered by an arrow -- but if it's
1090
+ // covered by *both*, then we go back to using the regular path color
1091
+ // (making arrows look like "holes" when they're overlapping the pulse.)
1092
+ float pulseLevel = abs(1.0 - pulseDistance - arrowAmount);
1093
+
1094
+
1095
+ gl_FragColor = vec4(mix(finalColor, secondColor, pulseLevel), opacity * opacityMultiplier);
1096
+ } else if (effectiveDisplayArrows) {
1097
+ gl_FragColor = vec4(mix(finalColor, pulseColor, arrowAmount), opacity * opacityMultiplier);
1098
+ } else {
1099
+
1100
+ gl_FragColor = vec4(finalColor, opacity * opacityMultiplier);
1101
+ }
1102
+ // Checkerboard discard for x-ray effect. xrayDithering is a uniform so
1103
+ // the outer branch is warp-coherent (zero cost when disabled).
1104
+ if (xrayDithering > 0.0) {
1105
+ float cx = floor(gl_FragCoord.x / xrayDithering);
1106
+ float cy = floor(gl_FragCoord.y / xrayDithering);
1107
+ if (mod(cx + cy, 2.0) < 0.5) discard;
1108
+ }
1109
+ #include <colorspace_fragment>
1110
+ }
1111
+ `;g();var Qh=`uniform float complete;
1112
+ uniform float nearRadius;
1113
+ uniform float farRadius;
1114
+ varying float fragPathDistance;
1115
+ const float completeLength = 0.1;
1116
+
1117
+ // Map the x value from the range [xMin, xMax] to the range [yMin, yMax] using
1118
+ // linear interpolation/extrapolation.
1119
+ //
1120
+ // This performs a pure linear mapping 'y = mx + b' where
1121
+ // 'm = (yMax - yMin) / (xMax - xMin)',
1122
+ // 'b = -xMin * (yMax - yMin) / (xMax - xMin) + yMin'.
1123
+ float remap(float x, float xMin, float xMax, float yMin, float yMax) {
1124
+ return (x - xMin) / (xMax - xMin) * (yMax - yMin) + yMin;
1125
+ }
1126
+
1127
+ // Map the x value from [xMin, xMax] to the range [yMin, yMax] using linear
1128
+ // interpolation, clamping result values outside [yMin, yMax].
1129
+ float clampRemap(float x, float xMin, float xMax, float yMin, float yMax) {
1130
+ return clamp(remap(x, xMin, xMax, yMin, yMax), yMin, yMax);
1131
+ }
1132
+
1133
+ void main(void) {
1134
+ // this ensures that the stencil mask moves along with the path above it, to avoid the progress bar effect
1135
+ float completeLocation = complete * (1.0 + completeLength);
1136
+ float completeAmount = clampRemap(
1137
+ fragPathDistance,
1138
+ completeLocation - completeLength,
1139
+ completeLocation,
1140
+ 0.0,
1141
+ 1.0
1142
+ );
1143
+ float opacity = 1.0 - smoothstep(0.0, 1.0, completeAmount);
1144
+
1145
+ // 2020/01/09 Terence Dickson
1146
+ // When we render the background and overlay for the mapbox outdoor context
1147
+ // behind everything else in single-buffer rendering, the fact that the path
1148
+ // writes to the depth buffer means that the background and overlay will not
1149
+ // be drawn behind the path even when the path is still fading in. The effect
1150
+ // is subtle and is only visible in single-buffer rendering so this quick fix
1151
+ // prevents writes to the depth buffer for zero opacity fragments, which gets
1152
+ // rid of the most visually-offensive ghosting.
1153
+ if (opacity <= 0.0) {
1154
+ discard;
1155
+ }
1156
+
1157
+ gl_FragColor = vec4(0.0, 1.0, 0.0, opacity);
1158
+ }`;var ed="data:image/png;base64,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";g();import{Vector3 as Ki}from"three";var Ir=new Ki,Lr=new Ki,ni=new Ki,td=new Ki,ht=new Ki,Mg=.5,Cg=2;function Dg(n,e,t){let i=n.x-e.x,o=n.y-e.y,r=n.z-e.z,a=t.x-e.x,l=t.y-e.y,s=t.z-e.z,c=i*a+o*l+r*s,h=Math.sqrt(i*i+o*o+r*r),d=Math.sqrt(a*a+l*l+s*s);if(h===0||d===0)return 0;let u=c/(h*d),m=Math.max(-1,Math.min(1,u));return Math.acos(m)}function od(n,e=20){if(n.length<3||e<=0)return n;let t=e,i=e/2,o=[n[0]];for(let r=1;r<n.length-1;r++){let a=n[r],l=n[r-1],s=n[r+1],c=a.distanceTo(l),h=a.distanceTo(s);c>t&&(ht.subVectors(a,l).normalize(),ni.set(a.x-ht.x*i,a.y-ht.y*i,a.z-ht.z*i),o.push(ni.clone())),o.push(a),h>t&&(ht.subVectors(s,a).normalize(),ni.set(a.x+ht.x*i,a.y+ht.y*i,a.z+ht.z*i),o.push(ni.clone()))}return o.push(n[n.length-1]),o}var id=.0025;function rd(n,e,t,i=Math.PI*2/3){if(n.length<3||e<=0||t<=0)return n;let o=[n[0]];for(let r=1;r<n.length-1;r++){let a=n[r-1],l=n[r],s=n[r+1],c=l.distanceToSquared(a),h=l.distanceToSquared(s);if(c<id||h<id){o.push(l);continue}if(Dg(a,l,s)<i){Ir.subVectors(l,a).normalize(),Lr.subVectors(s,l).normalize();let u=Math.sqrt(c),m=Math.sqrt(h),v=Math.max(Mg,Math.min(Cg,e)),b=Math.min(v,u*.5),p=Math.min(v,m*.5);ni.set(l.x-Ir.x*b,l.y-Ir.y*b,l.z-Ir.z*b),td.set(l.x+Lr.x*p,l.y+Lr.y*p,l.z+Lr.z*p),o.push(ni.clone(),td.clone())}else o.push(l)}return o.push(n[n.length-1]),o}var Rt=8,Ha=Pg,Bg=new Rg,Rr=new Qi,ad={h:0,s:0,l:0};function Va(n,e,t=.2){return n.getHSL(ad),e.copy(n).offsetHSL(0,-ad.s*t,0)}function Wa(n){n.addEventListener("dispose",()=>{let e=n.uniforms.curveTexture?.value;e&&(e.dispose(),n.uniforms.curveTexture.value=null)})}function ja(n){return n===!1?-1:n===!0?0:Math.sin(n*Math.PI/180)}function ld(n,e,t){if(n.length<2){let _=new he;return _.userData={entityId:"",type:"path"},{mesh:_,material:null,center:new Qi}}let{breakpoint:i,width:o,accentColor:r,completeFraction:a,isVertical:l,visibleThroughGeometry:s,highlightCompleteFraction:c,highlightStartFraction:h,highlightEndFraction:d,highlightColor:u,highlightWidthMultiplier:m,highlightDisplayArrowsOnPath:v,travelledEndFraction:b,travelledColor:p,xrayOpacity:x,xrayStyle:f,billboarding:y}=e,{color:C,metersPerPixel:M=1}=t,S=!0,T=0,w=1/0,P=e.displayArrowsOnPath,L=!0,N,A;if(bt(o)){let _=Qe(o)/2;N=_,A=_}else if(typeof o=="object"){let _=e.parsedOutputValues;N=_[i]/2,A=(_[i+1]??_[i])/2}else N=o/2,A=o/2;let G=e.dashDiscrete,B=e.isFlat,H=B?ja(y):-1,j=Fg,ne=0;n[0].z+=j;for(let _=1;_<n.length;++_){n[_].z+=j;let J=n[_].x-n[_-1].x,ie=n[_].y-n[_-1].y,Ee=n[_].z-n[_-1].z;ne+=Math.sqrt(J*J+ie*ie+Ee*Ee)}let I=n,ye=e.smoothingCornerRadius??Ve.cornerRadius,$e=e.smoothingTension??Ve.tension,Le=ye>0&&$e>0;Le&&(I=od(I),I=rd(I,ye,$e));let[be,Ae]=e.endcapExtension;if((be>0||Ae>0)&&!l&&!B){let _=I[0],J=I[I.length-1],ie=Le?.01:-.01;I.push(J.clone().setZ(J.z+ie)),I.unshift(_.clone().setZ(_.z+ie))}if(B&&!l&&I.length>=2){if(be>0){let _=I[0],J=I[1];Rr.subVectors(J,_).normalize();let ie=_.clone().addScaledVector(Rr,-be);I.unshift(ie)}if(Ae>0){let _=I[I.length-1],J=I[I.length-2];Rr.subVectors(_,J).normalize();let ie=_.clone().addScaledVector(Rr,Ae);I.push(ie)}}let Ft=Bg.load(ed);Ft.colorSpace=Ag;let ft=R(C??"#ffffff"),ci=R(r),qe=e.border,hi=qe?.enabled??!1,xe=qe?.color==="darken",ze=qe?.width??.1,Gt=xe?ft.clone().multiplyScalar(.6):R(qe?.color??"#000000"),me={vertexes:{type:"f",value:1},resolution:{type:"v2",value:new Ua(1,1)},cameraParameters:{type:"v2",value:new Ua(T,0)},complete:{type:"f",value:S?0:1},color:{type:"c",value:ft},pathLength:{type:"f",value:ne},nearRadius:{type:"f",value:N},farRadius:{type:"f",value:A},nearZoom:{type:"f",value:T},farZoom:{type:"f",value:w},pulseColor:{type:"c",value:ci},pulse:{type:"f",value:0},pulseLength:{type:"f",value:.075},pathIsVertical:{type:"b",value:l},arrowAnimationTimer:{type:"f",value:0},arrowTexture:{type:"t",value:Ft},displayArrowsOnPath:{type:"b",value:P},showPulse:{type:"b",value:L},opacityMultiplier:{type:"f",value:1},dashed:{type:"b",value:e.dashedMask},xrayDithering:{type:"f",value:0},highlightCompleteFraction:{type:"f",value:c},highlightStartFraction:{type:"f",value:h},highlightEndFraction:{type:"f",value:d},highlightColor:{type:"c",value:R(u)},highlightWidthMultiplier:{type:"f",value:m},highlightDisplayArrowsOnPath:{type:"b",value:v},travelledEndFraction:{type:"f",value:b},travelledColor:{type:"c",value:R(p)},dashLength:{type:"f",value:e.dashLength},dashGap:{type:"f",value:e.dashGap},dashRelativeToWidth:{type:"b",value:e.dashRelativeToWidth},dashSize:{type:"f",value:e.dashSize},gapSize:{type:"f",value:e.gapSize},dashAbsolute:{type:"b",value:e.dashAbsolute},dashMeters:{type:"f",value:e.dashMeters},gapMeters:{type:"f",value:e.gapMeters},isRibbon:{type:"b",value:B},isDiscreteDash:{type:"b",value:G},dashCornerRadius:{type:"f",value:Math.min(Math.max(e.dashCornerRadius,0),1)},curveTexture:{type:"t",value:null},curveTextureSize:{type:"f",value:0},dashCount:{type:"f",value:0},billboardThreshold:{type:"f",value:H},borderEnabled:{type:"b",value:hi},borderColor:{type:"c",value:Gt},borderWidth:{type:"f",value:ze},borderUseDarken:{type:"b",value:xe},endcapEnabled:{type:"v2",value:new Ua(B&&be>0?1:0,B&&Ae>0?1:0)},cameraViewMatrix:{type:"m4",value:new Og},screenSpace:{type:"b",value:e.screenSpace},metersPerPixel:{type:"f",value:1},minPathWidthMeters:{type:"f",value:Ze}};if(Le&&I.length>=2){let _=I[0],J=I[1],ie=I[I.length-1],Ee=I[I.length-2],Ke=_.clone().sub(J).normalize(),Re=_.clone().add(Ke.multiplyScalar(sd));I.unshift(Re);let ui=ie.clone().sub(Ee).normalize(),mi=ie.clone().add(ui.multiplyScalar(sd));I.push(mi)}let Se=new Tg(I);Se.curveType="catmullrom",Se.tension=Le?$e:0;let pe=B&&Le,Ne=new Sr(Se,I.length,pe),fe=Gg*I.length,Z,Ue;if(G?(Ue=Yh(Ne),{geometry:Z}=Jh({component:e,curve:Ne,baked:Ue,nearRadius:N,metersPerPixel:M,uniforms:me})):B?Z=new xr(Ne,{segments:fe,billboarded:H>=0}):Z=new _g(Ne,fe,N,Rt,!1),!G){let _=new Float32Array(Z.attributes.position.count),J=new za(_,1);if(B)for(let F=0;F<=fe;F++){let k=F/fe;J.setX(F*2,k),J.setX(F*2+1,k)}else for(let F=0;F<=fe;F++){let k=F/fe;for(let Oe=0;Oe<=Rt;Oe++)J.setX(F*(Rt+1)+Oe,k)}Z.setAttribute("pathDistance",J);let ie=new Float32Array(Z.attributes.position.count*3),Ee=new za(ie,3),Ke,Re,ui,mi,cn;if(B){let F=Z;for(let k=0;k<=fe;k++)Re=k*3,ui=F.tangentData[Re],mi=F.tangentData[Re+1],cn=F.tangentData[Re+2],Ee.setXYZ(k*2,ui,mi,cn),Ee.setXYZ(k*2+1,ui,mi,cn)}else{let F=Z;for(let k=0;k<=fe;k++){Ke=F.tangents[k];for(let Oe=0;Oe<=Rt;Oe++)Ee.setXYZ(k*(Rt+1)+Oe,Ke.x,Ke.y,Ke.z)}}Z.setAttribute("pathTangent",Ee);let lu=new Float32Array(Z.attributes.position.count*3),ro=new za(lu,3),pi,fi,gi,Pe=new Qi,Ss=F=>{l?(pi=F.x*F.y,fi=-1+F.y*F.y,gi=F.z*F.y):(pi=-F.x*F.z,fi=-F.y*F.z,gi=1-F.z*F.z);let k=Math.sqrt(pi*pi+fi*fi+gi*gi);return k===0&&(k=1),Pe.set(pi/k,fi/k,gi/k),Pe},no={x:0,y:0,z:0};if(B){let F=Z;for(let k=0;k<=fe;k++)Re=k*3,no.x=F.tangentData[Re],no.y=F.tangentData[Re+1],no.z=F.tangentData[Re+2],Ss(no),ro.setXYZ(k*2,Pe.x,Pe.y,Pe.z),ro.setXYZ(k*2+1,Pe.x,Pe.y,Pe.z)}else{let F=Z;for(let k=0;k<=fe;k++){Ke=F.tangents[k],Ss(Ke);for(let Oe=0;Oe<=Rt;Oe++)ro.setXYZ(k*(Rt+1)+Oe,Pe.x,Pe.y,Pe.z)}}Z.setAttribute("pathNormal",ro)}let gt=new Na({uniforms:me,vertexShader:Or,fragmentShader:ka,side:Ha});Wa(gt),gt.transparent=!0,gt.alphaTest=.5,me.resolution.value.x=1,me.resolution.value.y=1,me.vertexes.value=Z.attributes.position.count,me.arrowTexture.value.wrapS=Ar,me.arrowTexture.value.wrapT=Ar,me.arrowTexture.value.anisotropy=16;let K=new nd(Z,gt);K.name="path";let ge=K.clone();ge.name="xray";let sn=f?.color?R(f.color):ft,ln=Va(sn,new Eg,f?.tint),Me={...me,color:{type:"c",value:ln},opacityMultiplier:{type:"f",value:x},pathIsVertical:{type:"b",value:l},xrayDithering:{type:"f",value:f?.dithering??0}};Me.complete.value=1,ge.material=new Na({uniforms:Me,vertexShader:Or,fragmentShader:ka,side:Ha,transparent:!0}),Wa(ge.material),ge.material.alphaTest=.5,ge.material.depthWrite=!1,ge.material.depthTest=!1,Me.resolution.value.x=1,Me.resolution.value.y=1,Me.vertexes.value=Z.attributes.position.count,Me.arrowTexture.value.wrapS=Ar,Me.arrowTexture.value.wrapT=Ar,Me.arrowTexture.value.anisotropy=16,Me.complete.value=a,K.userData=ge.userData=e.mesh.userData;let yt=e.mesh,ae=null;if(!s){let _=new Na({uniforms:me,vertexShader:Or,fragmentShader:Qh,side:Ha});Wa(_),ae=new nd(Z,_),ae.name="stencil",ae.material.colorWrite=!1,ae.material.stencilWrite=!0,ae.material.stencilRef=Ie.PATH,ae.material.stencilFunc=wg,ae.material.stencilZPass=Lg,ae.material.stencilZFail=Ji,ae.material.stencilFail=Ji,ae.material.depthWrite=!1,ae.material.depthTest=!0,ae.userData=e.mesh.userData,ae.raycast=Di,yt.add(ae),yt.add(ge),ge.renderOrder=Q.XRAY_PATH,K.renderOrder=Q.STENCIL_PATH}if(yt.add(K),B&&!G&&($h(K),ge.raycast=Di),G){if(!Ue)throw new Error("Error processing discrete curve.");Ga(K,{positions:Ue.positions,count:Ue.size,stride:3},Ue.bounds),ge.raycast=Di,ae&&(ae.raycast=Di)}if(l&&!G){K.geometry.computeBoundingBox();let _=K.geometry.boundingBox,J=new Qi;_.getCenter(J),yt.children.forEach(ie=>{ie.geometry.center(),ie.position.copy(J)})}s&&(K.material.stencilWrite=!0,K.material.stencilRef=Ie.PATH,K.material.stencilFunc=Ig,K.material.stencilZPass=Ji,K.material.stencilZFail=Ji,K.material.stencilFail=Ji,K.material.needsUpdate=!0,K.layers.disableAll(),K.layers.enable(Q.ALWAYS_ON_TOP_PATHS)),Z.computeBoundingBox();let di=new Qi;return Z.boundingBox.getCenter(di),{mesh:yt,material:gt,center:di,pathObject:K}}var Fg=.15,Gg=30,sd=.01;import{Color as kg}from"three";var zg=.5,Ng=30,Ug=1e3/Ng,cd=new kg;function Hg(n){return n!==void 0&&n.visible&&n.material.visible&&n.layers.isEnabled(Q.ALWAYS_ON_TOP_PATHS)}var eo=class extends z{rendererState;verticalDistanceDirty=!0;#e;#o=0;convertTo3DMapPosition;getParentContainer;convertZoomLevelToAltitude;constructor(e,t,i,o){super(),this.rendererState=e,this.convertTo3DMapPosition=t,this.getParentContainer=i,this.convertZoomLevelToAltitude=o}update(e,t,i,o){let r=!1,a=0;for(let l of this.rendererState.geometry3DsInScene)if(l&&l.type==="path"&&l.components[0].type==="path"){let s=l.components[0],c=l.components[1],h=s.isVertical&&this.verticalDistanceDirty;if(!(s instanceof Tt))continue;let d=[];if(s.dirty||c.dirty||h){if(s.mesh.parent!=null)for(let u=s.mesh.children.length-1;u>=0;u--)oe(s.mesh.children[0]);if(s.feature.features.length===2&&s.feature.features[0].properties.parentId&&s.feature.features[1].properties.parentId){let u=s.feature.features[0],m=s.feature.features[s.feature.features.length-1],v,b,p=u.geometry.coordinates[2]||0,x=m.geometry.coordinates[2]||0;u.properties.parentId&&(v=this.getParentContainer(u.properties.parentId,!0),v!=null&&v.altitude!=null&&(p+=v.altitude,s.isVertical=!0)),m.properties.parentId&&(b=this.getParentContainer(m.properties.parentId,!0),b!=null&&b.altitude!=null&&(x+=b.altitude,s.isVertical=!0));let f=this.convertTo3DMapPosition(u.geometry.coordinates[1],u.geometry.coordinates[0],p),y=this.convertTo3DMapPosition(m.geometry.coordinates[1],m.geometry.coordinates[0],x);Math.abs(f.z-y.z)>zg&&v!=null&&v.visible&&b!=null&&b.visible&&(d=[f,y])}else{let u=s.feature.features;for(let m=0;m<u.length;m++)if(m===0||!Xs(u[m].geometry.coordinates,u[m-1].geometry.coordinates)){let v=this.convertTo3DMapPosition(u[m].geometry.coordinates[1],u[m].geometry.coordinates[0],u[m].geometry.coordinates[2]||0);d.push(v)}}if(d.length>1){let{mesh:u,material:m,center:v,pathObject:b}=ld(d,s,{color:c.color,isVertical:s.isVertical,metersPerPixel:o});s.mesh=u,s.material=m,s.pathObject=b,s.position=v}s.dirty&&typeof s.width=="object"&&s.width.on==="zoom-level"&&(s.altitudeBreakpoints=s.width.input.map(u=>this.convertZoomLevelToAltitude(u))),s.dirty=!1}c.dirty&&(s.mesh.children.forEach(u=>{u.name!=="stencil"&&(u.name==="xray"?dd(c.color,s,u.material.uniforms.color.value):se(u.material.uniforms.color.value,c.color),u.material.visible=c.visible,u.name!=="xray"&&s.border?.color==="darken"&&u.material.uniforms.borderColor.value.copy(u.material.uniforms.color.value).multiplyScalar(.6))}),s.mesh.position.z=c.altitude,c.dirty=!1),s.material&&(s.mesh.children.forEach(u=>{let m=u.material.uniforms;if(u.name==="stencil"){s.materialDirty&&hd(s,u.material);return}if(s.materialDirty&&u.name==="xray"&&m.opacityMultiplier&&(m.opacityMultiplier.value=s.xrayOpacity,m.xrayDithering.value=s.xrayStyle?.dithering??0,dd(c.color,s,m.color.value)),typeof s.width=="object"&&s.width.on==="zoom-level"){let b=s.isFlat?Os(i,s.altitudeBreakpoints??[e,t]):0;s.breakpoint=b,m.nearZoom.value=s.altitudeBreakpoints?.[b]??e,m.farZoom.value=s.altitudeBreakpoints?.[b+1]??t;let p=s.parsedOutputValues;m.nearRadius.value=p[b]/2,m.farRadius.value=(p[b+1]??p[b])/2}m.cameraParameters.value.x=i,m.metersPerPixel.value=o,m.cameraViewMatrix.value.copy(this.rendererState.cameraObject.matrixWorldInverse);let v=typeof s.width=="object"&&s.width.on==="zoom-level";if(s.dashDiscrete&&s.maxDashCount>0&&(s.screenSpace||v)){let b=Fa(m.nearRadius.value,m.farRadius.value,m.nearZoom.value,m.farZoom.value,i);m.dashCount.value=ri(s,s.curveLength,b,o)}if(s.materialDirty){let b=s.dashDiscrete;m.displayArrowsOnPath.value=s.displayArrowsOnPath,m.dashCornerRadius.value=Math.min(Math.max(s.dashCornerRadius,0),1),se(m.pulseColor.value,s.accentColor),m.complete.value=s.completeFraction,hd(s,u.material),m.dashed.value=s.dashedMask,m.dashLength.value=s.dashLength,m.dashGap.value=s.dashGap,m.dashRelativeToWidth.value=s.dashRelativeToWidth,m.dashSize.value=s.dashSize,m.gapSize.value=s.gapSize,m.dashAbsolute.value=s.dashAbsolute,m.dashMeters.value=s.dashMeters,m.gapMeters.value=s.gapMeters;let p=typeof s.width=="object"&&s.width.on==="zoom-level";if(b&&s.maxDashCount>0){let C=s.screenSpace?Math.max(m.nearRadius.value*2*o,Ze):m.nearRadius.value*2,M=wr(s,s.curveLength,C);if(M>0){let S=s.curveLength/M;S>s.maxDashCount&&s.maxDashCount<oi&&(s.dirty=!0),S>oi&&!s.dashCapWarned&&(E.warn(`Discrete dash path needs more than ${oi} dashes; dash spacing is saturated.`),s.dashCapWarned=!0)}!s.screenSpace&&!p&&(m.dashCount.value=ri(s,s.curveLength,m.nearRadius.value,o))}let x=s.border;m.borderEnabled.value=x?.enabled??!1,m.borderWidth.value=x?.width??.1,x?.color==="darken"?m.borderColor.value.copy(m.color.value).multiplyScalar(.6):se(m.borderColor.value,x?.color??"#000000"),m.borderUseDarken.value=x?.color==="darken",m.billboardThreshold.value=ja(s.billboarding);let[f,y]=s.endcapExtension;if(m.endcapEnabled.value.set(b||f<=0?0:1,b||y<=0?0:1),m.screenSpace.value=s.screenSpace,bt(s.width)){m.nearZoom.value=e,m.farZoom.value=t;let C=Qe(s.width);m.nearRadius.value=C/2,m.farRadius.value=C/2}else typeof s.width=="number"&&(m.nearZoom.value=e,m.farZoom.value=t,m.nearRadius.value=Number(s.width)/2,m.farRadius.value=Number(s.width)/2)}}),(s.displayArrowsOnPath||s.highlightDisplayArrowsOnPath)&&s.animateArrowsOnPath&&(s.mesh.children.forEach(u=>{u.name!=="stencil"&&(u.material.uniforms.arrowAnimationTimer.value=performance.now()/3e3)}),r=!0),s.materialDirty=!1),Hg(s.pathObject)&&a++}this.rendererState.alwaysOnTopPaths=a,this.verticalDistanceDirty=!1,r&&this.#n()}#n(){if(this.#e!==void 0)return;let e=Math.max(0,this.#o+Ug-performance.now());this.#e=setTimeout(()=>{this.#e=void 0,this.#o=performance.now(),this.publish("animate:path")},e)}cancelScheduledAnimation(){clearTimeout(this.#e),this.#e=void 0}destroy(){this.cancelScheduledAnimation(),super.destroy()}};function hd(n,e){let t=e.uniforms;t.highlightCompleteFraction.value=n.highlightCompleteFraction,t.highlightStartFraction.value=n.highlightStartFraction,t.highlightEndFraction.value=n.highlightEndFraction,t.highlightWidthMultiplier.value=n.highlightWidthMultiplier,se(t.highlightColor.value,n.highlightColor),t.highlightDisplayArrowsOnPath.value=n.highlightDisplayArrowsOnPath,t.travelledEndFraction.value=n.travelledEndFraction,se(t.travelledColor.value,n.travelledColor)}function dd(n,e,t){let i=e.xrayStyle?.color?se(cd,e.xrayStyle.color):se(cd,n);Va(i,t,e.xrayStyle?.tint)}g();import{Matrix4 as Wg}from"three";var _r=class{rendererState;dirty=!1;constructor(e){this.rendererState=e}#e;#o;#n;#r=new Wg;updateOne(e){if(e instanceof U&&e.components[0]instanceof Y&&e.components[1]instanceof Be&&e.parentObject3D instanceof le&&(this.#e=e.components[0],this.#n=e.components[1],!this.#e.detached&&this.#e.shouldDetach&&this.#e.mesh!=null&&this.#e.material instanceof So&&this.#e.batchedProps!=null)){this.#o=e.parentObject3D,this.#e.visible=!1;let t=this.#n.color,i=this.#n.opacity*Vt(e),o=this.#e.material,r=i??1,a=o.clone({color:t,side:cl(this.#n.side,r),opacity:r,transparent:r<1}),l=new Eo(1,this.#e.batchedProps.positionCount,0,a);l.layers.enable(X.SHOULD_CAST_SHADOWS);let s=dc(this.#e,l,this.#r);if(s==null)return;l.userData={entities:{0:e.id},detached:!0},this.#e.instanceIndex=s,a.setColor(this.#e.instanceIndex,R(t),this.#n.topColor?R(this.#n.topColor):R(t)),this.#e.mesh=l,this.#e.currentHeight=-1,this.#e.material=a,this.#o.add(l),this.#e.shouldDetach=!1,this.#e.detached=!0,this.#n.dirty=!0}}update(){if(!this.dirty)return;let e;for(let t of this.rendererState.geometry3DIdsInScene)e=this.rendererState.geometry3DMap.get(t),this.updateOne(e);this.dirty=!1,this.cleanup()}cleanup(){this.#e=void 0,this.#o=void 0,this.#n=void 0}};g();var Br=class{rendererState;dirty=!1;constructor(e){this.rendererState=e}#e;#o;#n;updateOne(e){if(e instanceof U&&e.type==="geometry"&&e.components[1]?.dirty){this.#e=e.components[0],this.#o=e.components[1],this.#n=e.components[8];let t=this.#o.height*this.#o.heightScale;if(e.type==="geometry")if(this.#e.mesh instanceof jt){let i=!1;t!==this.#e.currentHeight&&(i=wn(this.#e,t,this.#o.initialHeight)),this.#o.altitude!==this.#e.altitude&&(i=Tn(this.#e,this.#o.altitude)||i),i=this.applySlope()||i,i&&this.#e.mesh!=null&&this.#e.mesh.geometry.computeBoundingSphere()}else{let i=!1;t!==this.#e.currentHeight&&(i=wn(this.#e,t,this.#o.initialHeight)),this.#o.altitude!==this.#e.altitude&&(i=Tn(this.#e,this.#o.altitude)),i=this.applySlope()||i,i&&this.#e.mesh!=null&&this.#e.mesh.computeBoundingSphere()}}}update(){for(let e of this.rendererState.geometry3DsInScene)this.updateOne(e);this.cleanup()}applySlope(){let e=this.#e,t=this.#o,i=this.#n;if(!e||!t||!i)return!1;let o=t.slope;if(o&&o.factor!==0)try{return En(i,e,o,t.initialHeight)}catch(r){return E.warn("Failed to apply slope to entity:",r),!1}if(i.currentSlope)try{return En(i,e,{bearing:0,factor:0},t.initialHeight)}catch(r){return E.warn("Failed to clear slope on entity:",r),!1}return!1}cleanup(){this.#e=void 0,this.#o=void 0,this.#n=void 0}};g();var Vg={showPolygonLabelTextAreaMesh:!1,showEnvMap:!1,showCollisionBoxes:!1,showGeometryInFocus:!1,showImageLOD:!1,showModelInstancingStats:!1,showScreenOffsets:!1,showCameraTargets:!1,focusOn:!1},Fr=class{state=Vg;core;constructor(e){this.core=e}update(e){let t={};for(let i of Object.keys(e))i in this.state&&this.state[i]!==e[i]&&(Object.assign(this.state,{[i]:e[i]}),Object.assign(t,{[i]:e[i]}));this.handleUpdate(t)}handleUpdate(e){if(e.showPolygonLabelTextAreaMesh!=null&&(e.showPolygonLabelTextAreaMesh?this.core.getSystems().text3DSystem.showTextAreaMesh():this.core.getSystems().text3DSystem.hideTextAreaMesh()),e.showEnvMap!=null&&(e.showEnvMap?this.core.setEnvironment("basic"):this.core.setEnvironment(!1)),e.showCollisionBoxes!=null&&(e.showCollisionBoxes?this.core.showCollisionBoxes():this.core.hideCollisionBoxes()),e.showGeometryInFocus!=null&&(e.showGeometryInFocus?this.core.getSystems().geometryInFocusSystem.showDebug():this.core.getSystems().geometryInFocusSystem.hideDebug()),e.showImageLOD!=null&&(this.core.getSystems().imageSystem.debugLOD=e.showImageLOD,this.core.render()),e.showModelInstancingStats!=null&&(e.showModelInstancingStats?this.core.getSystems().modelSystem.showDebug():this.core.getSystems().modelSystem.hideDebug()),e.showScreenOffsets!=null&&(e.showScreenOffsets?this.core.camera.showScreenOffsetsDebug():this.core.camera.hideScreenOffsetsDebug()),e.showCameraTargets!=null&&(e.showCameraTargets?this.core.camera.showCameraTargetsDebug():this.core.camera.hideCameraTargetsDebug()),"focusOn"in e){let t=e.focusOn;t===!1||t==null?this.core.camera.hideFocusOnDebug():this.core.camera.showFocusOnDebug(t)}}};g();import{BufferAttribute as iy,Color as oy,Mesh as ry,RGBAFormat as ny,UnsignedByteType as ay,WebGLRenderTarget as sy}from"three";g();function ud(){return typeof window<"u"&&window.__MAPPEDIN_E2E__===!0}g();import{GLSL3 as yd,ShaderMaterial as bd}from"three";g();var md=`// Occluder id pass: each occluder mesh carries its id encoded as a per-vertex RGB colour.
1159
+ attribute vec3 color;
1160
+ varying vec3 vColor;
1161
+
1162
+ void main() {
1163
+ vColor = color;
1164
+ gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
1165
+ }
1166
+ `;g();var pd=`// Writes the occluder id colour, so each picking-texture texel holds the nearest occluder's id.
1167
+ varying vec3 vColor;
1168
+ out vec4 fragColor;
1169
+
1170
+ void main() {
1171
+ fragColor = vec4(vColor, 1.0);
1172
+ }
1173
+ `;g();var fd=`// Fullscreen quad in clip space: PlaneGeometry(2, 2) already spans (-1..1)^2, so no camera matrices.
1174
+ void main() {
1175
+ gl_Position = vec4(position.xy, 0.0, 1.0);
1176
+ }
1177
+ `;g();var gd=`// Sample-pack pass. Samples are laid out row-major, uRowWidth wide, in both the positions texture and this
1178
+ // target, so output texel (x, y) is sample y * uRowWidth + x: it reads that entity's projected pixel from the
1179
+ // positions texture at the same texel and samples the picking texture there. Picking texels are bottom-up
1180
+ // (GL render-target convention) while projections are top-down window coordinates, so y is flipped.
1181
+ precision highp float;
1182
+ precision highp int;
1183
+
1184
+ uniform highp sampler2D uPositions;
1185
+ uniform highp sampler2D uPickingTexture;
1186
+ uniform int uSampleCount;
1187
+ uniform int uRowWidth;
1188
+ uniform ivec2 uPickingSize;
1189
+
1190
+ out vec4 fragColor;
1191
+
1192
+ void main() {
1193
+ ivec2 texel = ivec2(gl_FragCoord.xy);
1194
+ int index = texel.y * uRowWidth + texel.x;
1195
+ if (index >= uSampleCount) {
1196
+ fragColor = vec4(0.0);
1197
+ return;
1198
+ }
1199
+ vec4 posData = texelFetch(uPositions, texel, 0);
1200
+ ivec2 sampleCoord = ivec2(int(posData.x), uPickingSize.y - 1 - int(posData.y));
1201
+ sampleCoord = clamp(sampleCoord, ivec2(0), uPickingSize - ivec2(1));
1202
+ fragColor = texelFetch(uPickingTexture, sampleCoord, 0);
1203
+ }
1204
+ `;function vd(){return new bd({glslVersion:yd,vertexShader:md,fragmentShader:pd})}function xd(n){let e={uPositions:{value:null},uPickingTexture:{value:null},uSampleCount:{value:0},uRowWidth:{value:1},uPickingSize:{value:n}};return new bd({glslVersion:yd,depthTest:!1,depthWrite:!1,uniforms:e,vertexShader:fd,fragmentShader:gd})}g();import{ClampToEdgeWrapping as Sd,DataTexture as jg,FloatType as Zg,Mesh as Xg,NearestFilter as Md,OrthographicCamera as Yg,PlaneGeometry as $g,RGBAFormat as Cd,Scene as qg,UnsignedByteType as Kg,WebGLRenderTarget as Jg}from"three";var Qg=64,ey=1024;function ty(n){let e=Math.min(n,ey);return{width:e,height:Math.ceil(n/e)}}var Gr=class{#e;#o=[0,0];#n;#r=new qg;#a=new Yg(-1,1,1,-1,0,1);#s;#l=0;#h=0;#p=null;#i;#d;#t;#g;#u=null;#c=0;#v=!1;constructor(e){this.#e=e,this.#n=xd(this.#o),this.#s=new Xg(new $g(2,2),this.#n),this.#s.frustumCulled=!1,this.#r.add(this.#s)}get inFlight(){return this.#u!=null}get sampleCount(){return this.#c}get samples(){return this.#i}positions(e){return this.#S(e),this.#g}dispatch(e,t){if(this.#u!=null)throw new Error("SampleReadback.dispatch: a read is already in flight");if(t<=0||this.#d==null||this.#t==null||this.#x().isContextLost())return;this.#t.needsUpdate=!0;let i=this.#n.uniforms;i.uPositions.value=this.#t,i.uPickingTexture.value=e.texture,i.uSampleCount.value=t,i.uRowWidth.value=this.#h,this.#o[0]=e.width,this.#o[1]=e.height,this.#e.setRenderTarget(this.#d),this.#e.render(this.#r,this.#a);let o=this.#x(),r=Math.ceil(t/this.#h);o.bindBuffer(o.PIXEL_PACK_BUFFER,this.#p),o.readPixels(0,0,r===1?t:this.#h,r,o.RGBA,o.UNSIGNED_BYTE,0),o.bindBuffer(o.PIXEL_PACK_BUFFER,null),this.#u=o.fenceSync(o.SYNC_GPU_COMMANDS_COMPLETE,0),this.#c=t,this.#v=!1}discardInFlight(){this.#u!=null&&(this.#v=!0)}poll(){if(this.#u==null)return"idle";let e=this.#x();if(e.isContextLost())return"pending";let t=e.clientWaitSync(this.#u,e.SYNC_FLUSH_COMMANDS_BIT,0);return t===e.TIMEOUT_EXPIRED?"pending":(e.deleteSync(this.#u),this.#u=null,t===e.WAIT_FAILED?(E.error("Occlusion2D: async pixel read fence WAIT_FAILED"),"discarded"):this.#i==null||this.#p==null||this.#c===0?"discarded":(e.bindBuffer(e.PIXEL_PACK_BUFFER,this.#p),e.getBufferSubData(e.PIXEL_PACK_BUFFER,0,this.#i,0,this.#c*4),e.bindBuffer(e.PIXEL_PACK_BUFFER,null),this.#v?"discarded":"ready"))}contextRestored(){this.#u=null,this.#p=null,this.#c=0,this.#v=!1,this.#d=void 0,this.#t=void 0,this.#g=void 0,this.#i=void 0,this.#l=0,this.#h=0}dispose(){let e=this.#x();this.#u!=null&&(e.deleteSync(this.#u),this.#u=null),this.#p!=null&&(e.deleteBuffer(this.#p),this.#p=null),this.#d?.dispose(),this.#t?.dispose(),this.#n.dispose(),this.#s.geometry.dispose(),this.#d=void 0,this.#t=void 0,this.#g=void 0,this.#i=void 0,this.#l=0,this.#h=0}#x(){return this.#e.getContext()}#S(e){if(e<=this.#l)return;let t=this.#l>0?this.#l:Qg;for(;t<e;)t*=2;let i=this.#x();this.#p!=null&&i.deleteBuffer(this.#p),this.#p=i.createBuffer(),i.bindBuffer(i.PIXEL_PACK_BUFFER,this.#p),i.bufferData(i.PIXEL_PACK_BUFFER,t*4,i.STREAM_COPY),i.bindBuffer(i.PIXEL_PACK_BUFFER,null),this.#i=new Uint8Array(t*4);let{width:o,height:r}=ty(t);this.#d?.dispose(),this.#d=new Jg(o,r,{format:Cd,type:Kg,internalFormat:"RGBA"}),this.#t?.dispose(),this.#g=new Float32Array(t*4),this.#t=new jg(this.#g,o,r,Cd,Zg),this.#t.minFilter=Md,this.#t.magFilter=Md,this.#t.wrapS=Sd,this.#t.wrapT=Sd,this.#t.needsUpdate=!0,this.#l=t,this.#h=o}};var to=9,ly=!1,cy=.1,Dd=9,kr=1/2;function hy(n,e,t){for(let i=0;i<e;i++){let o=(t&16711680)>>16,r=(t&65280)>>8,a=t&255;n[i*3]=o/255,n[i*3+1]=r/255,n[i*3+2]=a/255}}var zr=class{state;renderer;renderService;convertTo3DMapPosition;destroyed=!1;enabled=!1;backgroundId=16777215;color=1;pickingTexture;pickingMaterial;clearColor=new oy;readback;pendingEntities=[];activeOccluders=new Set;framesSinceLastUpdate=Dd;constructor(e,t,i){if(this.state=e,this.convertTo3DMapPosition=t,i?.renderer==null)throw new Error("No Renderer");this.renderService=i,this.renderer=i.renderer,this.pickingMaterial=vd(),this.readback=new Gr(this.renderer),this.resize()}reserveOccluderId(){return this.color++,this.color}enable(){this.enabled=!0}disable(){this.enabled=!1}resize=()=>{let e=this.state.pixelRatio,t=Math.floor(this.renderer.domElement.width/e*kr),i=Math.floor(this.renderer.domElement.height/e*kr);this.pickingTexture?.dispose(),this.pickingTexture=new sy(t,i,{format:ny,type:ay,internalFormat:"RGBA"}),this.readback.discardInFlight()};update=()=>{if(!this.destroyed&&(this.pollReadback(),!this.readback.inFlight)){if(ud()){this.updateImmediately();return}this.framesSinceLastUpdate++,this.framesSinceLastUpdate>=Dd&&(this.framesSinceLastUpdate=0,this.updateImmediately())}};updateImmediately=()=>{this.destroyed||!this.enabled||(this.pollReadback(),this.readback.inFlight||this.beginPass())};contextRestored(){this.readback.contextRestored(),this.pendingEntities.length=0}destroy(){this.destroyed=!0,this.readback.dispose(),this.pickingTexture?.dispose(),this.pickingTexture=void 0,this.pickingMaterial.dispose(),this.pendingEntities.length=0}beginPass(){let e=this.pickingTexture;if(e==null)return;this.refreshOccluders();let t=this.collectPendingEntities();t!==0&&(this.writePositions(t),this.renderPickingPass(e),this.readback.dispatch(e,t),this.renderer.setRenderTarget(null),ly?this.renderService.enabledLayers.add(to):this.renderService.enabledLayers.delete(to))}refreshOccluders(){this.activeOccluders.clear(),this.activeOccluders.add(this.backgroundId);for(let e of this.state.geometry3DsInScene)e?.type!=="group-container"||e.userData.occluderFeature==null||e.userData.occluderId==null||(this.activeOccluders.add(e.userData.occluderId),e.userData.occluderDirty&&(this.buildOccluderMesh(e,e.userData.occluderFeature,e.userData.occluderId),e.userData.occluderDirty=!1))}buildOccluderMesh(e,t,i){let o={color:"white",height:cy},r;t.geometry.type==="Polygon"&&t.geometry.coordinates.length>0?r=No(t,this.convertTo3DMapPosition,o):t.geometry.type==="MultiPolygon"&&(r=Uo(t,this.convertTo3DMapPosition,o)),r!=null&&e.add(this.createOccluderMesh(r,i))}createOccluderMesh(e,t){let i=new ry(e,this.pickingMaterial);return i.layers.set(to),this.applyId(i.geometry,t),i.userData.occluderId=t,i}applyId(e,t){let i=e.attributes.position,o=new Float32Array(i.count*3);hy(o,i.count,t),e.setAttribute("color",new iy(o,3))}collectPendingEntities(){this.pendingEntities.length=0;let e=0;for(let t of this.state.geometry2DsInScene){if(!t)continue;let i=t.components[2];if(i!=null){if(!i.enabled){t.components[0].isOccluded=!1;continue}i.id==null||!this.activeOccluders.has(i.id)||(this.pendingEntities[e]=t,e++)}}return e}writePositions(e){let t=this.readback.positions(e);for(let i=0;i<e;i++){let o=this.pendingEntities[i].components[0].projection,r=i*4;t[r]=Math.floor(o.x*kr),t[r+1]=Math.floor(o.y*kr)}}renderPickingPass(e){let t=this.state.cameraObject;this.renderer.setRenderTarget(e),this.renderer.setClearColor(this.clearColor.setHex(this.backgroundId)),this.renderer.clear(),t.layers.disableAll(),t.layers.enable(to),this.renderService.renderScene(this.state.geometryScene.parent,t),t.layers.disable(to)}pollReadback(){let e=this.readback.poll();e==="idle"||e==="pending"||(e==="ready"&&this.applyResults(),this.pendingEntities.length=0)}applyResults(){let e=this.readback.samples;if(e==null)return;let t=this.readback.sampleCount;for(let i=0;i<t;i++){let o=this.pendingEntities[i];if(o==null||o.disposed)continue;let r=o.components[2],a=o.components[0];if(r?.id==null)continue;if(!r.enabled){a.isOccluded=!1;continue}let l=i*4,s=e[l]<<16|e[l+1]<<8|e[l+2];a.isOccluded=s!==r.id&&s!==this.backgroundId}}};g();var Nr=class{constructor(e){this.state=e}dirty=!0;update(){if(this.dirty){for(let e of this.state.geometry3DIdsInScene){let t=this.state.geometry3DMap.get(e);if(t instanceof U&&t.type==="geometry"&&t.components[0]?.geometry!=null){let i=t.components[0];if(i.mesh instanceof jt)continue;i.geometry&&(i.geometry.dispose(),i.geometry=void 0)}}this.dirty=!1}}};g();var Ur=class extends z{dirty=!0;state;constructor(e){super(),this.state=e}texturePromiseCache=new Map;async loadTexture(e){if(this.texturePromiseCache.has(e))return this.texturePromiseCache.get(e);let t=new Promise((i,o)=>{lt.getLoader().load(e,i,void 0,o)});return this.texturePromiseCache.set(e,t),t}update(){for(let e of this.state.geometry3DsInScene){if(!(e instanceof U))continue;let t=e.components[6];if(!(t instanceof Mt))continue;let i=e.components[0];if(!(i instanceof Y)||!t.dirty)continue;let o=Ei(i);o!=null&&(t.texture!=null&&(t.texture.path===""?(o.texture=null,o.hideTextures(i.instanceIndex),t.dirty=!1):this.loadTexture(t.texture.path).then(r=>{r&&(t.textureInstance=r,o.texture=r,o.blendTexture=!0,o.showTextures(i.instanceIndex)),this.publish("texture-added")})),t.topTexture!=null&&(t.topTexture.path===""?(o.topTexture=null,o.hideTextures(i.instanceIndex),t.dirty=!1):this.loadTexture(t.topTexture.path).then(r=>{r&&(t.topTextureInstance=r,o.topTexture=r,o.blendTexture=!0,o.showTextures(i.instanceIndex)),this.publish("texture-added")})),t.dirty=!1)}}destroy(){this.texturePromiseCache.forEach(async e=>{(await e).dispose()}),this.texturePromiseCache.clear()}};g();import{InstancedMesh as Za}from"three";function Hr(n,e){let t=n.transparent;n.depthWrite=!e,n.depthTest=!e,e&&(n.transparent=!0),n.transparent!==t&&(n.needsUpdate=!0)}function wd(n,e){let t=n.mesh?.material;if(t==null)return;let i=o=>{o.depthWrite=!e,o.depthTest=!e};Array.isArray(t)?t.forEach(i):i(t)}var Wr=class{currentOrder=Q.ALWAYS_ON_TOP_MODELS;assignedOrders=new WeakMap;state;constructor(e){this.state=e}assignOrder(e){return this.assignedOrders.has(e)?this.assignedOrders.get(e):(this.currentOrder+=1,this.assignedOrders.set(e,this.currentOrder),this.currentOrder)}releaseOrder(e){return this.assignedOrders.delete(e),Q.GEOMETRY}getHighestOrder(){return this.currentOrder}getOrder(e){return this.assignedOrders.get(e)}update(){let e,t;for(let i of this.state.geometry3DsInScene)if(i!=null){if(i.type==="geometry"){this.updateVisibleThroughGeometry(i);continue}if(i.type==="model"&&(e=i.components[1],e?.renderOrderDirty)){if(t=i.components[0],!t.mesh)continue;if(t.visibleThroughGeometry=e.visibleThroughGeometry,e.visibleThroughGeometry===!0){let o=this.assignOrder(t);t.renderOrder=o,this.applyRenderOrder(t)}else t.renderOrder>Q.GEOMETRY&&(t.renderOrder=this.releaseOrder(t),this.applyRenderOrder(t));e.renderOrderDirty=!1}}}updateVisibleThroughGeometry(e){let t=e.components[1],i=e.components[0];if(!(t?.dirty!==!0||i==null||i.mesh==null)){if(t.visibleThroughGeometry===!0){let o=this.assignOrder(i);i.renderOrder!==o&&(i.renderOrder=o),t.renderOrder=o,wd(i,!0)}else if(i.renderOrder>Q.GEOMETRY){let o=this.releaseOrder(i);i.renderOrder=o,t.renderOrder=o,wd(i,!1)}}}applyRenderOrder(e){if(!e.mesh)return;let t=e.renderOrder,i=e.visibleThroughGeometry;if(e.mesh.children[0]instanceof Za){e.mesh.renderOrder=t;for(let r of e.mesh.children)r instanceof Za&&(r.renderOrder=t);if(e.mesh.userData?.detached)for(let r of e.mesh.children)r instanceof Za&&(Array.isArray(r.material)?r.material.forEach(a=>Hr(a,i)):Hr(r.material,i))}else e.mesh.traverse(o=>{let r=o;"isMesh"in r&&r.isMesh===!0&&r.material&&(r.renderOrder=t,Array.isArray(r.material)?r.material.forEach(a=>Hr(a,i)):Hr(r.material,i))})}};g();import{AlwaysStencilFunc as uy,EqualStencilFunc as my,KeepStencilOp as io,LineSegments as py,Material as fy,Mesh as gy,NotEqualStencilFunc as yy,ReplaceStencilOp as by}from"three";var Vr=class n{state;constructor(e){this.state=e}applyMask(e,t,i){this.disableMask(e,t),i.mode==="mask"&&i.maskId!=null&&i.enabled?this.enableMaskProducer(e,t,i):i.mode==="masked-object"&&i.maskId!=null&&i.enabled&&this.enableMaskReciever(e,i)}update(){let e;for(let t of this.state.geometry3DsInScene)t?.type==="feature-collection"&&(!ji(t,this.state)||Vi(t)&&ji(t,this.state))&&(e=t.components[0],e?.dirty&&(t.traverse(i=>{(i instanceof gy||i instanceof py)&&i.material instanceof fy&&e!=null&&!i.userData.detached&&(this.disableMask(i.material,i),this.applyMask(i.material,i,e))}),e.dirty=!1))}static MASK_RENDER_ORDER=-1e3;enableMaskProducer(e,t,i){e.stencilWrite=!0,e.colorWrite=!1,e.stencilRef=i.maskId,e.stencilFunc=uy,e.stencilZPass=by,e.stencilZFail=io,e.stencilFail=io;let o=e.transparent;e.depthWrite=!1,t.userData.originalTransparent===void 0&&(t.userData.originalTransparent=e.transparent),e.transparent=!1,o!==e.transparent&&(e.needsUpdate=!0),t.userData.originalCastsShadows===void 0&&(t.userData.originalCastsShadows=t.layers.isEnabled(X.SHOULD_CAST_SHADOWS)),t.layers.disable(X.SHOULD_CAST_SHADOWS),t.userData.originalRenderOrder===void 0&&(t.userData.originalRenderOrder=t.renderOrder),t.renderOrder=n.MASK_RENDER_ORDER}enableMaskReciever(e,t){e.stencilWrite=!0,e.stencilRef=t.maskId,e.stencilFunc=t.effect==="reveal"?my:yy,e.stencilZPass=io,e.stencilZFail=io,e.stencilFail=io}disableMask(e,t){e.stencilWrite=!1,e.colorWrite=!0;let i=e.transparent;t.userData.originalTransparent!==void 0&&(e.transparent=t.userData.originalTransparent,delete t.userData.originalTransparent),i!==e.transparent&&(e.needsUpdate=!0),t.userData.originalCastsShadows!==void 0&&(t.userData.originalCastsShadows&&t.layers.enable(X.SHOULD_CAST_SHADOWS),delete t.userData.originalCastsShadows),t.userData.originalRenderOrder!==void 0&&(t.renderOrder=t.userData.originalRenderOrder,delete t.userData.originalRenderOrder)}};g();import{AlwaysStencilFunc as Cy,BackSide as Dy,Box3 as wy,BufferAttribute as Pd,BufferGeometry as Ty,EqualStencilFunc as Ey,FrontSide as Py,Group as Ya,InstancedMesh as Oy,InvertStencilOp as ai,KeepStencilOp as Od,Matrix4 as Id,Mesh as jr,MeshBasicMaterial as Iy,MeshStandardMaterial as Ly,Plane as Ay,PlaneGeometry as Ry,Vector3 as $a,ZeroStencilOp as _y}from"three";g();import{BasicDepthPacking as vy,DoubleSide as xy,MeshDepthMaterial as Sy,NoBlending as My}from"three";function Xa(){let n=new Sy;return n.depthPacking=vy,n.blending=My,n.colorWrite=!1,n}function Td(n){let e=Xa();return e.clippingPlanes=n,e.side=xy,e.allowOverride=!1,e}function Ed(n){return n.customDepthMaterial!=null&&n.customDepthMaterial.allowOverride===!1}var Ld=.5;function By(n,e){for(let t=n;t!=null;t=t.parent)if(t===e.holeFillMesh||t===e.holeFillGroup)return!0;return!1}function Fy(n){let e=0,t=0;for(let{geometry:v}of n){let b=v.getAttribute("position");b!=null&&(e+=b.count,t+=v.getIndex()?.count??b.count)}if(e===0||t===0)return null;let i=new Float32Array(e*3),o=e>65535?new Uint32Array(t):new Uint16Array(t),r=1/0,a=1/0,l=1/0,s=-1/0,c=-1/0,h=-1/0,d=0,u=0;for(let{geometry:v,matrix:b}of n){let p=v.getAttribute("position");if(p==null)continue;let x=p,f=x.isInterleavedBufferAttribute===!0,y=f?x.data.array:p.array,C=f?x.data.stride:p.itemSize,M=f?x.offset??0:0,S=b.elements,T=p.count;for(let P=0;P<T;P++){let L=P*C+M,N=y[L],A=y[L+1],G=y[L+2],B=(d+P)*3,H=S[0]*N+S[4]*A+S[8]*G+S[12],j=S[1]*N+S[5]*A+S[9]*G+S[13],ne=S[2]*N+S[6]*A+S[10]*G+S[14];i[B]=H,i[B+1]=j,i[B+2]=ne,H<r&&(r=H),j<a&&(a=j),ne<l&&(l=ne),H>s&&(s=H),j>c&&(c=j),ne>h&&(h=ne)}let w=v.getIndex();if(w!=null){let P=w.array;for(let L=0;L<w.count;L++)o[u+L]=P[L]+d;u+=w.count}else{for(let P=0;P<T;P++)o[u+P]=d+P;u+=T}d+=T}let m=new Ty;return m.setAttribute("position",new Pd(i,3)),m.setIndex(new Pd(o,1)),m.boundingBox=new wy(new $a(r,a,l),new $a(s,c,h)),m}var Zr=class{rendererState;dirty=!1;constructor(e){this.rendererState=e}update(){let e,t,i;for(let o of this.rendererState.geometry3DsInScene)if(t=o.components[0],i=o.components[1],e=o.components[7],o.type==="model"&&e!=null&&i?.clippingEnabled&&(e.dirty&&t.mesh!=null&&(e.plane==null&&(e.plane=new Ay(new $a(0,0,-1),e.verticalOffset),this.process(t,e,i.receiveShadow!==!1)),e.plane.constant!==e.verticalOffset&&(e.plane.constant=e.verticalOffset,this.rendererState.shadowReceiver?.castersChanged()),e.topColor!=null&&e.holeFillMesh?.material instanceof Ly&&se(e.holeFillMesh.material.color,e.topColor),e.topVisible!=null&&e.holeFillMesh!=null&&(e.holeFillMesh.visible=e.topVisible,e.holeFillGroup!=null&&(e.holeFillGroup.visible=e.topVisible)),e.dirty=!1),e.plane!=null&&e.holeFillMesh!=null&&e.topVisible===!0)){let r=e.holeFillMesh,a=e.verticalOffset,l=e.bboxCenter?.x??0,s=e.bboxCenter?.y??0;r.position.set(l,s,a),r.lookAt(l,s,a+1)}}process(e,t,i){if(e.mesh==null)return;let o=e.mesh.parent,r=[];e.mesh.traverse(f=>{if(!By(f,t)&&f instanceof jr){if(f.isModelBatch===!0){f.updateWorldMatrix(!0,!1);let{geometries:S,matrix:T}=f.getPlacementSource(),w=new Id().multiplyMatrices(f.matrixWorld,T);for(let P of S)r.push({geometry:P,matrix:w})}else if(f instanceof Oy){let S=new Id;f.getMatrixAt(e.instanceIndex??0,S),r.push({geometry:f.geometry,matrix:S})}else f.updateWorldMatrix(!0,!1),r.push({geometry:f.geometry,matrix:f.matrixWorld});let C=[t.plane];f.material.clippingPlanes=C;let M=this.rendererState.shadowReceiver;M&&(f.customDepthMaterial?.dispose(),f.customDepthMaterial=Td(C),M.customDepthCasters.add(f),M.castersChanged())}});let a=Fy(r);if(a==null)return;let l=new Ya,s=new Ya,c=a.boundingBox,h=(c.min.x+c.max.x)/2,d=(c.min.y+c.max.y)/2,u=c.max.x-c.min.x+Ld*2,m=c.max.y-c.min.y+Ld*2;t.bboxCenter={x:h,y:d};let v=new Ry(u,m),b=this.createHoleFillGeometry(a,t.plane,1);b.name="hole-fill-group",t.holeFillGroup=b;let p=new Dt({color:R(t.topColor??"#E67B5B"),clippingPlanes:[],stencilWrite:!0,stencilRef:Ie.CLIPPING_BIT,stencilFunc:Ey,stencilFuncMask:Ie.CLIPPING_BIT,stencilWriteMask:Ie.CLIPPING_BIT,stencilFail:Od,stencilZFail:Od,stencilZPass:_y});this.rendererState.shadowReceiver&&i&&Lo(p,this.rendererState.shadowReceiver);let x=new jr(v,p);x.name="hole-fill-mesh",t.holeFillMesh=x,x.renderOrder=1.1,s.add(b),s.add(e.mesh),l.add(s),l.add(x),o?.add(l),e.mesh=l}createHoleFillGeometry(e,t,i=0){let o=new Ya,r=new Iy;r.depthWrite=!1,r.depthTest=!1,r.colorWrite=!1,r.stencilWrite=!0,r.stencilFunc=Cy,r.stencilWriteMask=Ie.CLIPPING_BIT;let a=r.clone();a.side=Dy,a.clippingPlanes=[t],a.stencilFail=ai,a.stencilZFail=ai,a.stencilZPass=ai;let l=new jr(e,a);l.renderOrder=i,l.userData[Ht]=!0,o.add(l);let s=r.clone();s.side=Py,s.clippingPlanes=[t],s.stencilFail=ai,s.stencilZFail=ai,s.stencilZPass=ai;let c=new jr(e,s);return c.renderOrder=i,c.userData[Ht]=!0,o.add(c),o}};g();var Xr=class{plugins=new Set;registerPlugin(e){this.plugins.add(e)}unregisterPlugin(e){this.plugins.delete(e)}update(e,t){for(let i of this.plugins)i.update(e,t)}};g();var Yr=class{type="occlusion2d";enabled=!0;id;constructor(e){this.id=e}};g();import{LinearFilter as Kr,OrthographicCamera as kd,Vector3 as _t,DepthTexture as Vy,Matrix4 as Ja,WebGLRenderTarget as zd,PlaneGeometry as Qa,Mesh as es,CameraHelper as jy,LineSegments as Zy,BufferGeometry as Xy,Float32BufferAttribute as Yy,LineBasicMaterial as $y,MeshBasicMaterial as qy,UnsignedShortType as Ky,UnsignedByteType as Jy,RedFormat as Qy,ShaderMaterial as eb,Scene as tb,Box3 as Nd}from"three";g();import{ShaderMaterial as Gy,Matrix4 as ky,DoubleSide as zy,NotEqualStencilFunc as Ny,KeepStencilOp as Ka}from"three";g();var Ad=`varying vec4 vWorldPosition;
1205
+
1206
+ void main() {
1207
+ vWorldPosition = modelMatrix * vec4(position, 1.0);
1208
+ gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
1209
+ }
1210
+
1211
+ `;g();var qa=`uniform sampler2D shadowMap;
1212
+ uniform mat4 lightMatrix;
1213
+ uniform float shadowBias;
1214
+ uniform float shadowOpacity;
1215
+ uniform vec3 baseColor;
1216
+ uniform float shadowMapSize;
1217
+ uniform float pcfSpread;
1218
+ uniform float depthRangeMax;
1219
+ uniform bool shadowEnabled;
1220
+ varying vec4 vWorldPosition;
1221
+ float shadowThreshold = 0.05;
1222
+ float shadowStrengthMultiplier = 0.6;
1223
+
1224
+ /**
1225
+ * Interleaved gradient noise for temporal/spatial dithering of shadow samples
1226
+ */
1227
+ float interleavedGradientNoise(vec2 position) {
1228
+ vec3 magic = vec3(0.06711056, 0.00583715, 52.9829189);
1229
+ return fract(magic.z * fract(dot(position, magic.xy)));
1230
+ }
1231
+
1232
+ // Compile-time sample count for loop unrolling (injected via material)
1233
+ #ifndef PCF_SAMPLES
1234
+ #define PCF_SAMPLES 4
1235
+ #endif
1236
+
1237
+ // Poisson disk samples - only define what we need based on sample count
1238
+ #if PCF_SAMPLES <= 4
1239
+ const vec2 poissonDisk[4] = vec2[](
1240
+ vec2(-0.94201624, -0.39906216),
1241
+ vec2(0.94558609, -0.76890725),
1242
+ vec2(-0.094184101, -0.92938870),
1243
+ vec2(0.34495938, 0.29387760)
1244
+ );
1245
+ #elif PCF_SAMPLES <= 8
1246
+ const vec2 poissonDisk[8] = vec2[](
1247
+ vec2(-0.94201624, -0.39906216),
1248
+ vec2(0.94558609, -0.76890725),
1249
+ vec2(-0.094184101, -0.92938870),
1250
+ vec2(0.34495938, 0.29387760),
1251
+ vec2(-0.91588581, 0.45771432),
1252
+ vec2(-0.81544232, -0.87912464),
1253
+ vec2(-0.38277543, 0.27676845),
1254
+ vec2(0.97484398, 0.75648379)
1255
+ );
1256
+ #else
1257
+ const vec2 poissonDisk[16] = vec2[](
1258
+ vec2(-0.94201624, -0.39906216),
1259
+ vec2(0.94558609, -0.76890725),
1260
+ vec2(-0.094184101, -0.92938870),
1261
+ vec2(0.34495938, 0.29387760),
1262
+ vec2(-0.91588581, 0.45771432),
1263
+ vec2(-0.81544232, -0.87912464),
1264
+ vec2(-0.38277543, 0.27676845),
1265
+ vec2(0.97484398, 0.75648379),
1266
+ vec2(0.44323325, -0.97511554),
1267
+ vec2(0.53742981, -0.47373420),
1268
+ vec2(-0.26496911, -0.41893023),
1269
+ vec2(0.79197514, 0.19090188),
1270
+ vec2(-0.24188840, 0.99706507),
1271
+ vec2(-0.81409955, 0.91437590),
1272
+ vec2(0.19984126, 0.78641367),
1273
+ vec2(0.14383161, -0.14100790)
1274
+ );
1275
+ #endif
1276
+
1277
+ /**
1278
+ * Samples the shadow map using PCF (Percentage Closer Filtering)
1279
+ * Uses compile-time loop count for GPU optimization
1280
+ * @param lightSpacePos Position in light space coordinates
1281
+ * @returns Visibility factor (1.0 = fully lit, 0.0 = fully shadowed)
1282
+ */
1283
+ float sampleShadow(vec3 lightSpacePos) {
1284
+ float scaledTexelSize = (1.0 / shadowMapSize) * pcfSpread;
1285
+ float currentDepth = lightSpacePos.z * depthRangeMax;
1286
+
1287
+ // Rotation for temporal stability
1288
+ float noise = interleavedGradientNoise(gl_FragCoord.xy) * 6.283185;
1289
+ float cosNoise = cos(noise);
1290
+ float sinNoise = sin(noise);
1291
+ mat2 rotation = mat2(cosNoise, -sinNoise, sinNoise, cosNoise);
1292
+
1293
+ float shadow = 0.0;
1294
+
1295
+ // Compile-time unrolled loop - GPU can optimize this efficiently
1296
+ for(int i = 0; i < PCF_SAMPLES; i++) {
1297
+ vec2 offset = rotation * poissonDisk[i] * scaledTexelSize;
1298
+ vec2 uv = clamp(lightSpacePos.xy + offset, 0.0, 1.0);
1299
+
1300
+ float sampledDepth = texture2D(shadowMap, uv).r;
1301
+ shadow += step(sampledDepth + shadowBias, currentDepth);
1302
+ }
1303
+
1304
+ return 1.0 - shadow / float(PCF_SAMPLES);
1305
+ }
1306
+
1307
+ void main() {
1308
+ if (shadowEnabled) {
1309
+ // Transform world position to light space
1310
+ vec4 shadowCoord = lightMatrix * vWorldPosition;
1311
+ vec3 projCoords = shadowCoord.xyz / shadowCoord.w;
1312
+
1313
+ // Check if fragment is within shadow map bounds
1314
+ bool inBounds = projCoords.x >= 0.0 && projCoords.x <= 1.0 &&
1315
+ projCoords.y >= 0.0 && projCoords.y <= 1.0 &&
1316
+ projCoords.z >= 0.0 && projCoords.z <= 1.0;
1317
+
1318
+ if (inBounds) {
1319
+ float visibility = sampleShadow(projCoords);
1320
+ float shadowIntensity = 1.0 - visibility;
1321
+
1322
+ if (shadowIntensity > shadowThreshold) {
1323
+ float shadowStrength = shadowIntensity * shadowOpacity * shadowStrengthMultiplier;
1324
+ gl_FragColor = vec4(baseColor, shadowStrength);
1325
+ }
1326
+ }
1327
+ }
1328
+ }
1329
+
1330
+ `;var $r=class extends Gy{pcfSampleCount=4;constructor(){super({vertexShader:Ad,fragmentShader:`#define PCF_SAMPLES 4
1331
+ `+qa,uniforms:{shadowMap:{value:null},lightMatrix:{value:new ky},shadowBias:{value:8e-5},shadowOpacity:{value:.25},baseColor:{value:R(8421504)},shadowMapSize:{value:4096},pcfSpread:{value:3.5},depthRangeMax:{value:1},shadowEnabled:{value:!1}},transparent:!0,depthWrite:!1,side:zy,stencilWrite:!0,stencilFunc:Ny,stencilRef:Ie.UNDERGROUND_MASK,stencilFail:Ka,stencilZFail:Ka,stencilZPass:Ka})}setShadowUniforms(e,t,i,o,r,a,l,s,c,h){this.uniforms.shadowMap.value=e,this.uniforms.lightMatrix.value.copy(t),this.uniforms.shadowBias.value=i,this.uniforms.shadowOpacity.value=o,this.uniforms.baseColor.value=r,this.uniforms.shadowMapSize.value=a,this.uniforms.pcfSpread.value=l,this.uniforms.depthRangeMax.value=c,this.uniforms.shadowEnabled.value=h,s!==this.pcfSampleCount&&(this.pcfSampleCount=s,this.fragmentShader=`#define PCF_SAMPLES ${s}
1332
+ `+qa,this.needsUpdate=!0)}};g();var Rd=1024,dt={software:[/swiftshader/,/llvmpipe/,/software rasterizer/,/microsoft basic render/],weakMobile:[/adreno \(tm\) [345]\d\d/,/mali-4\d\d/,/mali-t\d/,/mali-g3\d/,/powervr ge/,/powervr rogue/,/vivante/],discrete:[/geforce/,/\brtx\b/,/\bgtx\b/,/arc\(tm\) [ab]\d/,/\barc [ab]\d/,/radeon rx(?! vega)/,/radeon pro/,/radeon r[579]/,/\brx \d{3,4}\b/,/vega (48|56|64)\b/,/apple m\d/],integrated:[/intel/,/radeon vega/,/radeon\(tm\) graphics/,/radeon graphics/,/vega (3|6|7|8|10|11)\b/,/gma/],appleGPU:[/apple gpu/],modernMobile:[/adreno \(tm\) [678]\d\d/,/mali-g[5-9]\d/,/immortalis/,/xclipse/],maskedPlaceholder:[/^mozilla$/,/^webkit webgl$/,/^webkit$/,/^google inc\.?$/,/^generic renderer$/]};function ut(n,e){return e!==void 0&&n.some(t=>t.test(e))}function Uy(n){let{hasContext:e,isMobile:t,maxTextureSize:i}=n,o=n.gpu?.trim().toLowerCase(),r=o===void 0||o===""||ut(dt.maskedPlaceholder,o)?void 0:o;return e?ut(dt.software,r)?{tier:"off",reason:`software renderer: "${r}"`}:i!==void 0&&i<Rd?{tier:"off",reason:`maxTextureSize ${i} is below ${Rd}`}:t?ut(dt.weakMobile,r)?{tier:"off",reason:`weak mobile GPU: "${r}"`}:ut(dt.modernMobile,r)||ut(dt.appleGPU,r)?{tier:"medium",reason:`modern mobile GPU: "${r}"`}:{tier:"low",reason:"no decisive signal (mobile)"}:ut(dt.discrete,r)||ut(dt.appleGPU,r)?{tier:"high",reason:`desktop discrete GPU: "${r}"`}:ut(dt.integrated,r)?{tier:"low",reason:`integrated desktop GPU: "${r}"`}:r===void 0?{tier:"medium",reason:"no decisive signal (desktop)"}:{tier:"low",reason:`unrecognised or old desktop GPU: "${r}"`}:{tier:"off",reason:"no WebGL context"}}var qr={low:{pcfSamples:1,pcfSpread:3,shadowBias:.001,normalBias:.2,visibleAtZoomLevel:15,ladder:{high:1024,low:512}},medium:{pcfSamples:2,pcfSpread:3,shadowBias:.001,normalBias:.15,visibleAtZoomLevel:15,ladder:{high:2048,low:1024}},high:{pcfSamples:4,pcfSpread:3,shadowBias:.001,normalBias:.12,visibleAtZoomLevel:15,ladder:{high:4096,low:2048}}};function _d(n,e){return e===void 0?n:{high:Math.min(n.high,e),low:Math.min(n.low,e)}}var Hy=["low","medium","high"],Bd=n=>({pcfSamples:n.pcfSamples,pcfSpread:n.pcfSpread,shadowBias:n.shadowBias,normalBias:n.normalBias,visibleAtZoomLevel:n.visibleAtZoomLevel}),Wy=n=>{if(typeof n=="number")return Object.is(n,-0)?"-0":String(n);try{return JSON.stringify(n)??String(n)}catch{return String(n)}};function Fd(n,e){if(n===void 0||n===!1)return{enabled:!1,logLines:[]};if(n==="auto"){let p=e(),{tier:x,reason:f}=Uy(p);if(x==="off")return{enabled:!1,logLines:[{level:"info",message:`Shadows: auto -> off (${f})`}]};let y=qr[x];return{enabled:!0,options:Bd(y),ladder:_d(y.ladder,p.maxTextureSize),tier:x,logLines:[{level:"info",message:`Shadows: auto -> ${x} (mobile: ${p.isMobile}, gpu: ${JSON.stringify(p.gpu)}, maxTextureSize: ${p.maxTextureSize}, dpr: ${p.dpr})`}]}}let t=n,i=typeof t=="object"&&t!==null&&!Array.isArray(t);if(t!==!0&&!i)return{enabled:!1,logLines:[{level:"error",message:`Shadows: unrecognised value ${Wy(t)} - expected true, 'auto', an options object, or false. Shadows are off.`}]};let o=t===!0?{}:t,r=e(),a=[],l=o.quality,s=l===void 0||Hy.includes(l);s||a.push({level:"error",message:`Shadows: unknown quality "${l}" - falling back to 'high'.`});let c=s&&l!==void 0,h=c?l:"high",d=!c&&r.isMobile;d&&a.push({level:"warn",message:"Shadows: 'high' is capped to 'medium' on mobile to bound VRAM - pass { quality: 'high' } to force it."});let u=d?"medium":h,{quality:m,...v}=o,b=qr[u];return{enabled:!0,options:{...Bd(b),...v},ladder:_d(b.ladder,r.maxTextureSize),tier:u,logLines:a}}function Gd(n){let e=n?.renderer??void 0,t=e!==void 0,i=!1,o;try{i=go().isMobile,o=Ns()?.toLowerCase()}catch{}return{hasContext:t,isMobile:i,gpu:o,maxTextureSize:e?.capabilities?.maxTextureSize,dpr:n?.pixelRatio}}var ib=.001,ve={quality:"high",debug:!1,baseColor:"#a0a0a0",shadowOpacity:.25,pcfSamples:4,pcfSpread:3,shadowBias:ib,normalBias:.12,shadowMapSize:"auto",sunAzimuth:225,sunElevation:45,visibleAtZoomLevel:15,frustumMode:"venue"},oo=1e4,ts=-.05,ob=999,rb=.05,nb=qr.high.ladder,ab=20.5,sb=19.5,lb=5,Ud=.001,cb=2;function hb(n,e){let t=n;for(;t;){if(t===e)return!0;t=t.parent}return!1}function db(n){return n instanceof So||n instanceof mo}var Hd=.1,Wd=1,ub=400,mb=-200,pb=50,fb=100,gb=-50,yb=40,si=15,Xe=22,bb=100,vb=5,Vd=50,xb=50,Sb=40,Mb=5,Cb=.5,is=1,jd=1,Db=5,re=256,wb=65535,Tb=.5,Jr=.1,Eb=1e3,Pb=16737792,Ob=.2,Zd=.2,Ib=1001,Lb=8900331,os=!0,Qr=class{state;rendererService;depthMaterial;cameraOrbit;lightCamera;shadowRenderTarget;lightMatrix=new Ja;currentSnapX=0;currentSnapY=0;shadowCenter=new _t;shadowMapStale=!0;uniformsDirty=!0;scratchVector=new _t;scratchCorner=new _t;uniformMaterialsSeen=new Set;casterBounds=new Nd;castersDirty=!0;depthScale=1;rangeNear=0;rangeFar=0;scratchBox=new Nd;receiverContext;scratchRight=new _t;scratchUp=new _t;shadowPlane=null;shadowPlaneMaterial=null;shadowPlaneEnabled=!0;visibleAtCurrentZoom=!0;zoomOpacityFactor=1;lightCameraHelper=null;debugEnabled=!1;debugGrid=null;debugCurrentCell=null;debugCurrentCellMaterial=null;debugCanvas=null;debugCanvasCtx=null;debugRenderTarget=null;debugDepthMaterial=null;debugDepthQuad=null;debugDepthScene=null;debugDepthCamera=null;options;internal;shadowResolutionSizes;shadowResolutionZoomThresholds={high:ab,low:sb};constructor(e,t,i,o,r=nb){this.state=e,this.cameraOrbit=i,this.rendererService=t,this.shadowResolutionSizes=r,this.options=Object.freeze({quality:o?.quality??ve.quality,debug:o?.debug??ve.debug,baseColor:o?.baseColor??ve.baseColor,shadowOpacity:o?.shadowOpacity??ve.shadowOpacity,pcfSamples:o?.pcfSamples??ve.pcfSamples,pcfSpread:o?.pcfSpread??ve.pcfSpread,shadowBias:o?.shadowBias??ve.shadowBias,normalBias:o?.normalBias??ve.normalBias,shadowMapSize:o?.shadowMapSize??ve.shadowMapSize,sunAzimuth:o?.sunAzimuth??ve.sunAzimuth,sunElevation:o?.sunElevation??ve.sunElevation,visibleAtZoomLevel:o?.visibleAtZoomLevel??ve.visibleAtZoomLevel,frustumMode:o?.frustumMode??ve.frustumMode});let a=this.options.shadowMapSize==="auto"?this.shadowResolutionSizes.high:this.options.shadowMapSize;this.internal={baseColor:R(this.options.baseColor),lightOrthoSize:pb,sunDistance:fb,groundZPosition:gb,snapGridSize:yb,currentShadowMapSize:a,currentShadowResolutionMode:(this.options.shadowMapSize==="auto",null),sunDirection:new _t,sunAzimuth:this.options.sunAzimuth,sunElevation:this.options.sunElevation},this.updateSunDirection(),this.lightCamera=new kd(-this.internal.lightOrthoSize,this.internal.lightOrthoSize,this.internal.lightOrthoSize,-this.internal.lightOrthoSize,Hd,ub),this.lightCamera.layers.disableAll(),this.lightCamera.layers.enable(X.SHOULD_CAST_SHADOWS),this.lightCamera.position.copy(this.internal.sunDirection.clone().multiplyScalar(mb)),this.lightCamera.lookAt(new _t(0,0,0)),this.lightCamera.updateMatrixWorld(),this.lightCamera.updateProjectionMatrix(),this.shadowRenderTarget=this.createShadowRenderTarget(a),this.depthMaterial=Xa(),this.createShadowPlane(),this.receiverContext={uniforms:tc(),pcfSamples:this.options.pcfSamples,customDepthCasters:new Set,castersChanged:()=>this.castersChanged()},this.state.shadowReceiver=this.receiverContext,this.options.debug&&this.setDebugEnabled(!0)}createShadowRenderTarget(e){let t=new zd(e,e,{format:Qy,type:Jy});return t.texture.minFilter=Kr,t.texture.magFilter=Kr,t.texture.generateMipmaps=!1,t.depthBuffer=!0,t.stencilBuffer=!1,t.depthTexture=new Vy(e,e,Ky),t}resizeShadowRenderTarget(e){if(!(this.shadowRenderTarget.width===e&&this.shadowRenderTarget.height===e)&&(this.shadowRenderTarget.setSize(e,e),this.shadowRenderTarget.depthTexture)){let t=this.shadowRenderTarget.depthTexture;t.image.width=e,t.image.height=e,t.dispose(),t.needsUpdate=!0}}createShadowPlane(){let e=new Qa(1,1);this.shadowPlaneMaterial=new $r,this.shadowPlane=new es(e,this.shadowPlaneMaterial),this.shadowPlane.position.set(0,0,ts),this.shadowPlane.scale.set(oo,oo,1),this.shadowPlane.renderOrder=ob,this.shadowPlane.frustumCulled=!1,this.shadowPlane.name="ShadowPlane",this.shadowPlaneEnabled&&this.state.threeJSScene.add(this.shadowPlane)}setShadowPlaneEnabled(e){this.shadowPlaneEnabled!==e&&(this.shadowPlaneEnabled=e,this.shadowPlane&&(e?this.state.threeJSScene.add(this.shadowPlane):this.state.threeJSScene.remove(this.shadowPlane)))}isShadowPlaneEnabled(){return this.shadowPlaneEnabled}updateShadowPlanePosition(){if(!this.shadowPlane)return;this.shadowPlane.position.x=this.shadowCenter.x,this.shadowPlane.position.y=this.shadowCenter.y;let e=this.getShadowFootprintHalfExtent();this.shadowPlane.scale.set(e*2,e*2,1),this.shadowPlane.updateMatrix(),this.shadowPlane.updateMatrixWorld()}getShadowFootprintHalfExtent(){let e=this.internal.sunDirection;if(-e.z<rb)return oo/2;let t=this.lightCamera,i=0;for(let o=0;o<4;o++){let r=this.scratchCorner.set(o&1?t.right:t.left,o&2?t.top:t.bottom,-t.near).applyMatrix4(t.matrixWorld),a=(ts-r.z)/e.z,l=r.x+e.x*a-this.shadowCenter.x,s=r.y+e.y*a-this.shadowCenter.y;i=Math.max(i,Math.abs(l),Math.abs(s))}return Math.min(i,oo/2)}updateShadowPlaneVisibility(){this.shadowPlane&&(this.shadowPlane.visible=this.visibleAtCurrentZoom)}setDebugEnabled(e){this.debugEnabled!==e&&(this.debugEnabled=e,e?this.createDebugHelpers():this.disposeDebugHelpers())}isDebugEnabled(){return this.debugEnabled}createDebugHelpers(){this.debugEnabled=!0,!this.lightCameraHelper&&this.lightCamera&&(this.lightCameraHelper=new jy(this.lightCamera),this.lightCameraHelper.name="ShadowLightCameraHelper",this.state.threeJSScene.add(this.lightCameraHelper)),this.createDebugGrid(),this.createDebugCurrentCell(),this.createDebugCanvas()}createDebugGrid(){if(this.debugGrid)return;let e=this.internal.snapGridSize,t=Db,i=e*t*2,o=[];for(let l=-t;l<=t;l++){let s=l*e;o.push(s,-i/2,Jr),o.push(s,i/2,Jr)}for(let l=-t;l<=t;l++){let s=l*e;o.push(-i/2,s,Jr),o.push(i/2,s,Jr)}let r=new Xy;r.setAttribute("position",new Yy(o,3));let a=new $y({color:R(wb),transparent:!0,opacity:Tb,depthTest:!1});this.debugGrid=new Zy(r,a),this.debugGrid.name="ShadowDebugGrid",this.debugGrid.renderOrder=Eb,this.debugGrid.frustumCulled=!1,this.state.threeJSScene.add(this.debugGrid)}createDebugCurrentCell(){if(this.debugCurrentCell)return;let e=this.internal.snapGridSize,t=new Qa(e,e);this.debugCurrentCellMaterial=new qy({color:R(Pb),transparent:!0,opacity:Ob,depthTest:!1,side:2}),this.debugCurrentCell=new es(t,this.debugCurrentCellMaterial),this.debugCurrentCell.name="ShadowDebugCurrentCell",this.debugCurrentCell.renderOrder=Ib,this.debugCurrentCell.frustumCulled=!1,this.debugCurrentCell.position.set(this.currentSnapX+e/2,this.currentSnapY+e/2,Zd),this.state.threeJSScene.add(this.debugCurrentCell)}createDebugCanvas(){if(this.debugCanvas)return;this.debugCanvas=document.createElement("canvas"),this.debugCanvas.width=re,this.debugCanvas.height=re,this.debugCanvas.style.cssText=`
1333
+ position: fixed;
1334
+ bottom: 16px;
1335
+ transform: rotate(-270deg);
1336
+ left: 16px;
1337
+ width: ${re}px;
1338
+ height: ${re}px;
1339
+ border: 2px solid #00ffff;
1340
+ border-radius: 4px;
1341
+ background: #000;
1342
+ z-index: 9999;
1343
+ pointer-events: none;
1344
+ `;let e=document.createElement("div");if(e.textContent=os?"Shadow Depth Map":"Light Camera View",e.style.cssText=`
1345
+ position: fixed;
1346
+ bottom: ${re+20}px;
1347
+ left: 16px;
1348
+ color: #00ffff;
1349
+ font-family: monospace;
1350
+ font-size: 12px;
1351
+ z-index: 9999;
1352
+ pointer-events: none;
1353
+ `,e.id="shadow-debug-label",document.body.appendChild(this.debugCanvas),document.body.appendChild(e),this.debugCanvasCtx=uo(this.debugCanvas),this.debugRenderTarget=new zd(re,re),this.debugRenderTarget.texture.minFilter=Kr,this.debugRenderTarget.texture.magFilter=Kr,os){this.debugDepthMaterial=new eb({uniforms:{depthTexture:{value:this.shadowRenderTarget.depthTexture}},vertexShader:`
1354
+ varying vec2 vUv;
1355
+ void main() {
1356
+ vUv = uv;
1357
+ gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
1358
+ }
1359
+ `,fragmentShader:`
1360
+ uniform sampler2D depthTexture;
1361
+ varying vec2 vUv;
1362
+ void main() {
1363
+ float depth = texture2D(depthTexture, vUv).r;
1364
+ // Invert so near is bright, far is dark
1365
+ gl_FragColor = vec4(vec3(1.0 - depth), 1.0);
1366
+ }
1367
+ `});let t=new Qa(2,2);this.debugDepthQuad=new es(t,this.debugDepthMaterial),this.debugDepthScene=new tb,this.debugDepthScene.add(this.debugDepthQuad),this.debugDepthCamera=new kd(-1,1,1,-1,0,1)}}debugPixelBuffer=null;updateDebugCanvas(){if(!this.debugCanvas||!this.debugCanvasCtx||!this.rendererService.renderer||!this.debugRenderTarget)return;let e=this.rendererService.renderer,t=re*re*4;(!this.debugPixelBuffer||this.debugPixelBuffer.length!==t)&&(this.debugPixelBuffer=new Uint8Array(t)),os&&this.debugDepthScene&&this.debugDepthCamera&&this.debugDepthMaterial?(this.debugDepthMaterial.uniforms.depthTexture.value=this.shadowRenderTarget.depthTexture,e.setRenderTarget(this.debugRenderTarget),e.clear(),e.render(this.debugDepthScene,this.debugDepthCamera),e.setRenderTarget(null)):(e.setRenderTarget(this.debugRenderTarget),e.setClearColor(Lb,1),e.clear(),e.render(this.state.threeJSScene,this.lightCamera),e.setRenderTarget(null)),e.readRenderTargetPixels(this.debugRenderTarget,0,0,re,re,this.debugPixelBuffer);let i=this.debugCanvasCtx.createImageData(re,re),o=i.data,r,a;for(let l=0;l<re;l++)for(let s=0;s<re;s++)r=((re-1-l)*re+s)*4,a=(l*re+s)*4,o[a]=this.debugPixelBuffer[r],o[a+1]=this.debugPixelBuffer[r+1],o[a+2]=this.debugPixelBuffer[r+2],o[a+3]=255;this.debugCanvasCtx.putImageData(i,0,0)}disposeDebugHelpers(){this.lightCameraHelper&&(this.state.threeJSScene.remove(this.lightCameraHelper),this.lightCameraHelper.dispose(),this.lightCameraHelper=null),this.debugGrid&&(this.state.threeJSScene.remove(this.debugGrid),this.debugGrid.geometry.dispose(),this.debugGrid.material.dispose(),this.debugGrid=null),this.debugCurrentCell&&(this.state.threeJSScene.remove(this.debugCurrentCell),this.debugCurrentCell.geometry.dispose(),this.debugCurrentCell=null),this.debugCurrentCellMaterial&&(this.debugCurrentCellMaterial.dispose(),this.debugCurrentCellMaterial=null),this.debugCanvas&&(this.debugCanvas.remove(),this.debugCanvas=null,this.debugCanvasCtx=null),this.debugPixelBuffer=null,this.debugRenderTarget&&(this.debugRenderTarget.dispose(),this.debugRenderTarget=null),this.debugDepthQuad&&(this.debugDepthQuad.geometry.dispose(),this.debugDepthQuad=null),this.debugDepthMaterial&&(this.debugDepthMaterial.dispose(),this.debugDepthMaterial=null),this.debugDepthScene=null,this.debugDepthCamera=null;let e=document.getElementById("shadow-debug-label");e&&e.remove()}updateDebugHelpers(){if(this.debugEnabled&&(this.lightCameraHelper&&this.lightCameraHelper.update(),this.debugGrid&&this.debugGrid.position.set(this.currentSnapX,this.currentSnapY,0),this.debugCurrentCell)){let e=this.internal.snapGridSize;this.debugCurrentCell.position.set(this.currentSnapX+e/2,this.currentSnapY+e/2,Zd)}}updateSunDirection(){let e=this.internal.sunAzimuth*Math.PI/180,t=this.internal.sunElevation*Math.PI/180,i=Math.cos(t);this.internal.sunDirection.set(i*Math.sin(e),i*Math.cos(e),-Math.sin(t)),this.internal.sunDirection.normalize()}updateLightCamera(){this.lightCamera&&(this.lightCamera.left=-this.internal.lightOrthoSize,this.lightCamera.right=this.internal.lightOrthoSize,this.lightCamera.top=this.internal.lightOrthoSize,this.lightCamera.bottom=-this.internal.lightOrthoSize,this.lightCamera.updateProjectionMatrix())}bias=new Ja().set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1);matrix=new Ja;updateLightMatrix(){this.lightCamera.position.copy(this.shadowCenter).add(this.scratchVector.copy(this.internal.sunDirection).multiplyScalar(-this.internal.sunDistance)),this.lightCamera.lookAt(this.shadowCenter);let e=Hd,t=this.internal.sunDistance*2,i=e,o=t;this.casterBounds.isEmpty()||(this.updateBoundsDepthRange(),i=Math.min(i,this.rangeNear-Wd),o=Math.max(o,this.rangeFar+Wd)),this.lightCamera.near=i,this.lightCamera.far=o,this.depthScale=(t-e)/(o-i),this.lightCamera.left=-this.internal.lightOrthoSize,this.lightCamera.right=this.internal.lightOrthoSize,this.lightCamera.top=this.internal.lightOrthoSize,this.lightCamera.bottom=-this.internal.lightOrthoSize,this.lightCamera.updateMatrixWorld(!0),this.lightCamera.updateProjectionMatrix(),this.matrix.identity(),this.matrix.multiplyMatrices(this.lightCamera.projectionMatrix,this.lightCamera.matrixWorldInverse),this.lightMatrix.multiplyMatrices(this.bias,this.matrix)}updateBoundsDepthRange(){let{min:e,max:t}=this.casterBounds,i=this.internal.sunDirection,o=this.lightCamera.position,r=-i.z,a=oo/2,l=1/0,s=-1/0;for(let c=0;c<8;c++){let h=c&1?t.x:e.x,d=c&2?t.y:e.y,u=c&4?t.z:e.z,m=(h-o.x)*i.x+(d-o.y)*i.y+(u-o.z)*i.z,v=u-ts,b=r>0?Math.min(Math.max(v/r,-a),a):v>=0?a:-a,p=m+b;m<l&&(l=m),m>s&&(s=m),p<l&&(l=p),p>s&&(s=p)}this.rangeNear=l,this.rangeFar=s}castersChanged(){this.castersDirty=!0,this.needsRender=!0}measureCasterBounds(){let e=this.casterBounds.makeEmpty(),t=this.lightCamera.layers,i=this.scratchBox;this.state.threeJSScene.updateMatrixWorld(),this.state.threeJSScene.traverseVisible(o=>{let r=o;if(!(!r.isMesh||!r.layers.test(t))){if(r.computeBoundingBox)r.computeBoundingBox(),i.copy(r.boundingBox);else{let a=r.geometry;a.boundingBox||a.computeBoundingBox(),i.copy(a.boundingBox)}i.isEmpty()||e.union(i.applyMatrix4(r.matrixWorld))}})}updateAutoSunDistance(e){let t=Math.max(si,Math.min(Xe,e)),i=(Xe-t)/(Xe-si),o=bb*Math.pow(vb,i);Math.abs(this.internal.sunDistance-o)>is&&(this.internal.sunDistance=o,this.updateSunDirection(),this.needsRender=!0)}updateAutoShadowResolution(e){if(this.options.shadowMapSize!=="auto")return;let t=this.internal.currentShadowResolutionMode;if(this.internal.currentShadowResolutionMode===null?e>=this.shadowResolutionZoomThresholds.high?t="high":t="low":this.internal.currentShadowResolutionMode==="low"?e>=this.shadowResolutionZoomThresholds.high&&(t="high"):this.internal.currentShadowResolutionMode==="high"&&e<=this.shadowResolutionZoomThresholds.low&&(t="low"),t!==this.internal.currentShadowResolutionMode&&t!==null){let i=this.shadowResolutionSizes[t];this.internal.currentShadowResolutionMode=t,this.internal.currentShadowMapSize=i,this.resizeShadowRenderTarget(i),this.needsRender=!0}}updateAutoLightSize(e){let t=Math.max(si,Math.min(Xe,e)),i=(Xe-t)/(Xe-si),o=Vd*Math.pow(xb,i);this.options.frustumMode==="venue"&&!this.casterBounds.isEmpty()&&(o=Math.min(o,Math.max(this.groundShadowFitHalfSize(),Vd))),Math.abs(this.internal.lightOrthoSize-o)>is&&(this.internal.lightOrthoSize=o,this.updateLightCamera(),this.needsRender=!0)}groundShadowFitHalfSize(){let e=this.scratchRight.setFromMatrixColumn(this.lightCamera.matrixWorld,0),t=this.scratchUp.setFromMatrixColumn(this.lightCamera.matrixWorld,1),i=this.shadowCenter,o=this.casterSupport(e,i),r=this.casterSupport(t,i);return Math.max(o,r)}casterSupport(e,t){let{min:i,max:o}=this.casterBounds,r=(i.x-t.x)*e.x,a=(o.x-t.x)*e.x,l=(i.y-t.y)*e.y,s=(o.y-t.y)*e.y,c=(i.z-t.z)*e.z,h=(o.z-t.z)*e.z;return Math.max(Math.abs(Math.max(r,a)+Math.max(l,s)+Math.max(c,h)),Math.abs(Math.min(r,a)+Math.min(l,s)+Math.min(c,h)))}updateZoomVisibility(e){let t=this.options.visibleAtZoomLevel-jd,i=this.options.visibleAtZoomLevel,o;e>=i?o=1:e<=t?o=0:o=(e-t)/jd;let r=o>0;(r!==this.visibleAtCurrentZoom||o!==this.zoomOpacityFactor)&&(this.visibleAtCurrentZoom=r,this.zoomOpacityFactor=o,this.uniformsDirty=!0)}isVisibleAtCurrentZoom(){return this.visibleAtCurrentZoom}updateAutoSnapGridSize(e){let t=Math.max(si,Math.min(Xe,e)),i=(Xe-t)/(Xe-si),o=Sb*Math.pow(Mb,i);Math.abs(this.internal.snapGridSize-o)>is&&(this.internal.snapGridSize=o,this.debugEnabled&&this.recreateDebugGrid())}recreateDebugGrid(){this.debugGrid&&(this.state.threeJSScene.remove(this.debugGrid),this.debugGrid.geometry.dispose(),this.debugGrid.material.dispose(),this.debugGrid=null),this.debugCurrentCell&&(this.state.threeJSScene.remove(this.debugCurrentCell),this.debugCurrentCell.geometry.dispose(),this.debugCurrentCell=null),this.createDebugGrid(),this.createDebugCurrentCell()}transparentGeometryVisibilityStateMap=new Map;swappedMaterials=new Map;renderShadowMap(){let e=this.state.threeJSScene.overrideMaterial;this.state.threeJSScene.overrideMaterial=this.depthMaterial;let t=this.swappedMaterials;for(let i of this.receiverContext.customDepthCasters){if(!Ed(i)||!hb(i,this.state.threeJSScene)){this.receiverContext.customDepthCasters.delete(i);continue}t.set(i,i.material),i.material=i.customDepthMaterial}this.rendererService.renderer?.setRenderTarget(this.shadowRenderTarget),this.rendererService.clear(),this.rendererService.renderScene(this.state.threeJSScene,this.lightCamera),this.rendererService.renderer?.setRenderTarget(null),this.state.threeJSScene.overrideMaterial=e;for(let[i,o]of t)i.material=o;t.clear(),this.debugEnabled&&this.updateDebugCanvas()}get effectiveShadowBias(){if(typeof this.options.shadowBias=="number")return this.options.shadowBias*this.depthScale;let e=this.internal.currentShadowMapSize,t=this.internal.lightOrthoSize,i=this.lightCamera.far-this.lightCamera.near;if(!(e>0)||!(t>0)||!(i>0))return Ud;let o=lb*(2*t)/e/i;return Number.isFinite(o)&&o>0?o:Ud}get effectiveNormalBias(){let e=2*this.internal.lightOrthoSize/this.internal.currentShadowMapSize,t=cb*e;return Number.isFinite(t)&&t>0?Math.max(this.options.normalBias,t):this.options.normalBias}updateShadowUniforms(){let e=this.visibleAtCurrentZoom,t=this.options.shadowOpacity*this.zoomOpacityFactor,i=this.effectiveShadowBias,o=this.uniformMaterialsSeen;o.clear();let r;for(let a of this.state.geometry3DsInScene){r=a.components[0];let l=r?.mesh?.material;db(l)&&!o.has(l)&&(o.add(l),l.setShadowUniforms(this.shadowRenderTarget.depthTexture,this.lightMatrix,this.lightCamera.near,this.lightCamera.far,i,t,this.internal.baseColor,this.internal.currentShadowMapSize,this.options.pcfSpread,this.options.pcfSamples,this.internal.sunDirection,this.effectiveNormalBias,this.state.depthRangeFor3D[1],e,bi*this.depthScale))}Fs(this.receiverContext.uniforms,{shadowMap:this.shadowRenderTarget.depthTexture,lightMatrix:this.lightMatrix,cameraNear:this.lightCamera.near,cameraFar:this.lightCamera.far,shadowBias:i,selfShadowThreshold:bi*this.depthScale,shadowOpacity:t,baseColor:this.internal.baseColor,shadowMapSize:this.internal.currentShadowMapSize,pcfSpread:this.options.pcfSpread,sunDir:this.internal.sunDirection,normalBias:this.effectiveNormalBias,depthRangeMax:this.state.depthRangeFor3D[1],shadowEnabled:e}),this.shadowPlaneMaterial&&this.shadowPlaneMaterial.setShadowUniforms(this.shadowRenderTarget.depthTexture,this.lightMatrix,i,t,this.internal.baseColor,this.internal.currentShadowMapSize,this.options.pcfSpread,this.options.pcfSamples,this.state.depthRangeFor3D[1],e)}lastZoomLevel=null;lastCameraElevation=null;zoomOrElevationChanged(e,t){if(this.lastZoomLevel===null||this.lastCameraElevation===null)return this.lastZoomLevel=e,this.lastCameraElevation=t,!0;let i=Math.abs(e-this.lastZoomLevel)>=Cb,o=t!==this.lastCameraElevation;return i||o?(this.lastZoomLevel=e,this.lastCameraElevation=t,!0):!1}updateSnap(e){let t=this.cameraOrbit.position.x||0,i=this.cameraOrbit.position.y||0,o=Math.floor(t/this.internal.snapGridSize)*this.internal.snapGridSize,r=Math.floor(i/this.internal.snapGridSize)*this.internal.snapGridSize,a=(e||0)+this.internal.groundZPosition;(o!==this.currentSnapX||r!==this.currentSnapY||a!==this.shadowCenter.z)&&(this.currentSnapX=o,this.currentSnapY=r,this.shadowCenter.set(o,r,a),this.needsRender=!0)}needsRender=!0;needsCompute=!0;update(e,t){this.updateZoomVisibility(e),this.castersDirty&&(this.measureCasterBounds(),this.castersDirty=!1);let i=this.zoomOrElevationChanged(e,t);(this.needsCompute||i)&&(this.updateAutoShadowResolution(e),this.updateAutoSunDistance(e),this.updateAutoSnapGridSize(e)),this.updateSnap(t),this.needsRender&&(this.updateAutoLightSize(this.lastZoomLevel??e),this.updateLightMatrix(),this.updateShadowPlanePosition(),this.shadowMapStale=!0,this.uniformsDirty=!0),this.shadowMapStale&&this.visibleAtCurrentZoom&&(this.renderShadowMap(),this.shadowMapStale=!1),this.uniformsDirty&&(this.updateShadowUniforms(),this.updateShadowPlaneVisibility()),this.updateDebugHelpers(),this.needsRender=!1,this.needsCompute=!1,this.uniformsDirty=!1}destroy(){this.disposeDebugHelpers(),this.shadowPlane&&(this.state.threeJSScene.remove(this.shadowPlane),this.shadowPlane.geometry.dispose(),this.shadowPlane=null),this.shadowPlaneMaterial&&(this.shadowPlaneMaterial.dispose(),this.shadowPlaneMaterial=null),this.shadowRenderTarget&&(this.shadowRenderTarget.dispose(),this.shadowRenderTarget.depthTexture&&this.shadowRenderTarget.depthTexture.dispose()),this.depthMaterial&&this.depthMaterial.dispose(),this.transparentGeometryVisibilityStateMap.clear(),this.receiverContext.customDepthCasters.clear(),this.state.shadowReceiver===this.receiverContext&&(this.state.shadowReceiver=void 0),this.receiverContext.uniforms.shadowEnabled.value=!1,this.receiverContext.uniforms.shadowMap.value=null}};g();import{Color as Ab,Euler as rs,InstancedMesh as ke,MathUtils as ns,Matrix4 as as,Quaternion as ss,Vector3 as ls}from"three";g();var en=class{element=null;enabled=!1;show(){this.enabled||(this.enabled=!0,this.create())}hide(){this.enabled&&(this.enabled=!1,this.element&&(this.element.remove(),this.element=null))}isEnabled(){return this.enabled}create(){this.element=document.createElement("div"),this.element.id="model-debug-ui",this.element.style.cssText=`
1368
+ position: fixed;
1369
+ bottom: 10px;
1370
+ left: 10px;
1371
+ background: rgba(0, 0, 0, 0.8);
1372
+ color: #fff;
1373
+ font-family: monospace;
1374
+ font-size: 12px;
1375
+ padding: 10px;
1376
+ border-radius: 5px;
1377
+ z-index: 10000;
1378
+ max-height: 300px;
1379
+ overflow-y: auto;
1380
+ min-width: 200px;
1381
+ `,document.body.appendChild(this.element)}getActualInstanceCount(e){for(let t of e.mesh.children)if(t.isInstancedMesh)return t.count;return e.count}update(e,t,i){if(!this.enabled||!this.element)return;let o='<div style="margin-bottom: 5px; font-weight: bold; border-bottom: 1px solid #666; padding-bottom: 5px;">Model Batches</div>';if(e.size===0)o+='<div style="color: #888;">No models loaded</div>';else{let r=0,a=0,l=Array.from(e.keys()).sort((s,c)=>{let h=t.get(s)??"",d=t.get(c)??"";return h.localeCompare(d)});for(let s of l){let c=e.get(s);if(!c||c.size===0)continue;let h=t.get(s)??`unknown_${s}`,d=0;for(let m of c)d+=this.getActualInstanceCount(m);r+=c.size,a+=d,o+='<div style="margin: 6px 0 2px 0;">',o+=`<span style="color: #4fc3f7; font-weight: bold;">"${h}"</span>`,o+=`<span style="color: #aaa;"> (${d} total, ${c.size} batch${c.size!==1?"es":""})</span>`,o+="</div>";let u=Array.from(c).sort((m,v)=>m.id.localeCompare(v.id));for(let m of u){let v=this.getActualInstanceCount(m),b=m.count,p=v!==b,x=m.opacity===1?"":` @${(m.opacity*100).toFixed(0)}%`;o+='<div style="margin-left: 12px; color: #ccc; font-size: 11px;">',o+=`<span style="color: #81c784;">${m.id}</span>`,p?o+=`<span style="color: #e57373;">: ${v} actual / ${b} tracked</span>`:o+=`<span style="color: #fff;">: ${v} instance${v!==1?"s":""}</span>`,x&&(o+=`<span style="color: #ffb74d;">${x}</span>`),o+="</div>"}}o+='<div style="margin-top: 8px; padding-top: 5px; border-top: 1px solid #666; color: #fff;">',o+=`Total: <span style="color: #81c784;">${a} instance${a!==1?"s":""}</span>`,o+=`, <span style="color: #e57373;">${r} draw call${r!==1?"s":""}</span>`,o+="</div>"}if(i.size>0){o+='<div style="margin-top: 8px; border-top: 1px solid #666; padding-top: 5px;">',o+='<div style="margin-bottom: 5px; font-weight: bold; color: #ff9800;">Non-instanced Models</div>';let r=0;for(let l of i.values())for(let s of l.mesh.children)s.isMesh===!0&&r++;o+=`<span style="color: #aaa;">(${i.size} total, ${r} draw call${r!==1?"s":""})</span>`;let a=new Map;for(let[l,s]of i){let c=a.get(s.urlHash)??[];c.push(l),a.set(s.urlHash,c)}for(let[l,s]of a){let c=t.get(l)??`unknown_${l}`;o+='<div style="margin: 6px 0 2px 0;">',o+=`<span style="color: #ff9800;">"${c}"</span>`,o+=`<span style="color: #aaa;"> (${s.length} model${s.length!==1?"s":""})</span>`,o+="</div>";for(let h of s)o+=`<div style="margin-left: 12px; color: #ccc; font-size: 11px;">${h}</div>`}o+="</div>"}this.element.innerHTML=o}destroy(){this.element&&(this.element.remove(),this.element=null)}};var li=100,Rb=!0;function Xd(n){return n.visibleThroughGeometry===!0?"cloned":n.EXPERIMENTAL_batchedDraw===!0?"batched":n.clippingEnabled===!0?"cloned":"instanced"}var tn=class extends z{transparencyChanged=!1;state;convertTo3DMapPosition;loader;loadPromises=[];gltfCache=new Map;gltfLoadPromises=new Map;instanceMap=new Map;debugUI;modelNames=new Map;batchCounter=0;batchByMesh=new Map;batchesByUrlHash=new Map;nonInstancedModels=new Map;pendingOpacityChanges=new Map;detachedEntityIds=new Set;tempMatrix=new as;tempQuaternion=new ss;tempEuler=new rs;tempScale=new ls;tempColor=new Ab;constructor(e,t){super(),this.state=e,this.convertTo3DMapPosition=t,this.debugUI=new en}createBatch(e,t,i,o,r,a,l){this.batchCounter++;let s={id:`batch_${this.batchCounter}`,mesh:e,count:0,maxCount:r,opacity:o,urlHash:t,containerId:i,receiveShadow:a,castShadow:l};return e.userData.batchId=s.id,this.batchByMesh.set(e,s),this.batchesByUrlHash.has(t)||this.batchesByUrlHash.set(t,new Set),this.batchesByUrlHash.get(t).add(s),s}removeBatch(e){this.batchByMesh.delete(e.mesh),this.batchesByUrlHash.get(e.urlHash)?.delete(e),this.batchesByUrlHash.get(e.urlHash)?.size===0&&this.batchesByUrlHash.delete(e.urlHash)}getBatchForMesh(e){return this.batchByMesh.get(e)}shadowReceiverFor(e){return e?this.state.shadowReceiver:void 0}shadowBatchKey(e){return this.state.shadowReceiver===void 0||e}updateDebugUI(){this.debugUI.update(this.batchesByUrlHash,this.modelNames,this.nonInstancedModels)}showDebug(){this.debugUI.show(),this.updateDebugUI()}hideDebug(){this.debugUI.hide()}getBatchStats(){let e=new Map;for(let[t,i]of this.batchesByUrlHash)for(let o of i){let r=e.get(t);r?(r.count+=o.count,r.maxCount+=o.maxCount):e.set(t,{urlHash:t,count:o.count,maxCount:o.maxCount,opacity:o.opacity})}return e}getNonInstancedModels(){let e=new Map;for(let[t,i]of this.nonInstancedModels)e.set(t,{urlHash:i.urlHash});return e}getModelUrls(){return new Map(this.modelNames)}async getGLTFLoader(){if(this.loader)return this.loader;let{GLTFLoader:e}=await import("three/examples/jsm/loaders/GLTFLoader.js");return this.loader=new e,this.loader}async getOrLoadGLTF(e,t){let i=this.gltfCache.get(t);if(i)return i;let o=this.gltfLoadPromises.get(t);if(o)return o;let r=await this.getGLTFLoader(),a=new Promise((l,s)=>{let c=d=>{this.gltfCache.set(t,d),this.gltfLoadPromises.delete(t),l(d)},h=d=>{this.gltfLoadPromises.delete(t),s(d)};pl(e)?r.parse(fl(e),"",c,h):gl(e)?r.parse(yl(e),"",c,h):r.load(e,c,void 0,h)});return this.gltfLoadPromises.set(t,a),a}addClonedPieces(e,t,i,o){let r=t.scene.clone(!0);r.updateWorldMatrix(!0,!0),r.traverse(a=>{let l=a;if("isMesh"in l&&l.isMesh===!0){let s=l.clone(!1);s.geometry=l.geometry.clone(),s.geometry.applyMatrix4(l.matrixWorld),s.position.set(0,0,0),s.rotation.set(0,0,0),s.scale.set(1,1,1),Array.isArray(l.material)?s.material=l.material.map(c=>nt(c)):s.material=nt(l.material),s.userData={entityId:String(i)},e.add(s)}}),Zt(e,o)}addBatchedPieces(e,t,i,o,r){let a=jn(t,o,{keepPlacementSource:r});for(let l of[...a.children])l.userData.entityId=String(i),l.userData.entities={0:String(i)},e.add(l)}createNonInstancedModel(e,t,i,o){let r=e.components[0],a=e.components[1],l=r.feature,s=this.shadowReceiverFor(a.receiveShadow!==!1),c=new he;c.userData={nonInstanced:!0,entityId:String(e.id),type:"model"},Xd(a)==="batched"?this.addBatchedPieces(c,t,e.id,s,a.clippingEnabled===!0):this.addClonedPieces(c,t,e.id,s);let{x:h,y:d}=this.convertTo3DMapPosition(l.geometry.coordinates[1],l.geometry.coordinates[0],0),u=l.geometry.coordinates[2]??0,m=(a.verticalOffset??0)+u;r.altitude=m,r.position.set(h,d,r.altitude);let v=a.scale??ot,b=a.rotation??rt;c.position.copy(r.position),c.rotation.set(ns.degToRad(b[0]),ns.degToRad(b[1]),ns.degToRad(b[2])),c.scale.set(v[0],v[1],v[2]),a.color&&!ko(c)&&$n(c,a.color),a.opacity!=null&&a.opacity!==1&&qn(c,a.opacity),a.visibleThroughGeometry&&sc(c,!0),Fe(c,a.opacity??1,this.shadowBatchKey(a.castShadow!==!1)),i.add(c),r.mesh=c,r.meshContainer=c,r.instanceIndex=-1,Bi(e),this.nonInstancedModels.set(e.id,{urlHash:o,mesh:c}),this.updateDebugUI()}resizeInstanceContainer(e,t){let i=ac(e.maxCount),o=e.object,r=this.getBatchForMesh(o),a=Xt(t,i,this.shadowReceiverFor(r?.receiveShadow??!0)),l=o.children,s=a.children;for(let c=0;c<l.length;c++){let h=l[c],d=s[c];if(!(!(h instanceof ke)||!(d instanceof ke))){for(let u=0;u<e.count;u++)h.getMatrixAt(u,this.tempMatrix),d.setMatrixAt(u,this.tempMatrix),d.userData.entities[u]=h.userData.entities[u],h.instanceColor&&(h.getColorAt(u,this.tempColor),d.setColorAt(u,this.tempColor));d.count=e.count,d.instanceMatrix.needsUpdate=!0}}for(Yn(o);a.children.length>0;)o.add(a.children[0]);return Fe(o,r?.opacity??1,r?.castShadow??!0),e.maxCount=i,r&&(r.maxCount=i),e}getOrCreateInstanceContainer(e,t,i){let o=this.instanceMap.get(e);o||(o=new Map,this.instanceMap.set(e,o));let r=o.get(t);if(r){let a=this.getBatchForMesh(r.object);a&&(r.count=a.count)}else{let a=Xt(i,li,this.state.shadowReceiver);r={object:a,count:0,maxCount:li},o.set(t,r);let l=this.createBatch(a,t,e,1,li,!0,!0);r.batch=l}return r}createModelFromFeature(e,t,i){let o=new Et(t),r={...i};t.properties.verticalOffset!=null&&(r.verticalOffset=t.properties.verticalOffset),t.properties.rotation!=null&&(r.rotation=t.properties.rotation),t.properties.scale!=null&&(r.scale=t.properties.scale);let a=new xo(r),l=Xd(a);o.instancingDisabled=l!=="instanced",a.EXPERIMENTAL_batchedDraw&&l!=="batched"&&E.warn("[ModelSystem] EXPERIMENTAL_batchedDraw has no effect on a visibleThroughGeometry model: its depth settings are per material, one-to-one with the meshes it draws.");let s=new U(o,a);if(s.id=e,a.clippingEnabled){let c=new Mo;a.clippingPlaneTopColor!=null&&(c.topColor=a.clippingPlaneTopColor),a.clippingPlaneTopVisible!=null&&(c.topVisible=a.clippingPlaneTopVisible),a.clippingPlaneZOffset!=null&&(c.verticalOffset=a.clippingPlaneZOffset),s.components[7]=c}return s}async populateModelGroup(e,t,i){let o=yi(t);this.modelNames.set(o,t);let r=this.getOrLoadGLTF(t,o).then(s=>{let c=i.parent;if(!(c instanceof $))return;let h=c.userData.entityId,d,u=()=>(d==null&&(d=this.getOrCreateInstanceContainer(h,o,s),d.count+e.size>d.maxCount&&(d=this.resizeInstanceContainer(d,s)),d.object.parent||i.add(d.object)),d),m=new as,v=new rs,b=new ss,p=new ls,x,f,y;for(let C of e.values()){if(y=this.state.geometry3DMap.get(C),!y||y?.type!=="model")continue;let M=y.components[0],S=y.components[1];if(M.instanceIndex!=null&&M.instanceIndex>=0||M.instancingDisabled&&M.mesh)continue;if(f=M.feature,M.instancingDisabled){this.createNonInstancedModel(y,s,i,o);continue}u();let T=S.opacity!=null&&S.opacity!==1,w=this.shadowBatchKey(S.receiveShadow!==!1),P=this.shadowBatchKey(S.castShadow!==!1);if(T||!w||!P){let A=S.opacity??1,G=Math.round(A*100),B,H,j=this.batchesByUrlHash.get(o);if(j){for(let I of j)if(I.containerId===c.userData.entityId&&Math.round(I.opacity*100)===G&&I.receiveShadow===w&&I.castShadow===P&&I.count<I.maxCount){B=I,H=I.mesh;break}}if(!B||!H){let I=Xt(s,li,this.shadowReceiverFor(w));I.userData.detached=!0,I.userData.sharedOpacity=A,i.add(I),B=this.createBatch(I,o,c.userData.entityId,A,li,w,P),H=I,Yt(I,A),Fe(I,A,P)}let ne=B.count;M.mesh=H,M.instanceIndex=ne,B.count++,this.detachedEntityIds.add(y.id)}else{let A=u();M.mesh=A.object,M.instanceIndex=A.count}Bi(y),S.dirty=!1,x=this.convertTo3DMapPosition(f.geometry.coordinates[1],f.geometry.coordinates[0],0),M.position.set(x.x,x.y,M.altitude),Ri(v,S.rotation),_i(p,S.scale),b.setFromEuler(v),m.compose(M.position,b,p);let L=M.mesh,N=M.instanceIndex;for(let A of L.children)A instanceof ke&&(A.setMatrixAt(N,m),A.userData.entities[N]=y.id,A.count=N+1,A.instanceMatrix.needsUpdate=!0);if(Fo(L,N,S.color,S.material),!T&&w&&P){let A=u();A.count++;let G=this.getBatchForMesh(A.object);G&&(G.count=A.count)}_o(M.mesh)}this.publish("model-loaded")});this.loadPromises.push(r);let a=i.parent?.userData?.entityId;return this.instanceMap.get(a)?.get(o)?.object??new he}update(){for(let t of this.state.geometryGroupIdsToLoad.values()){let i=this.state.geometry3DMap.get(t);i instanceof le&&i.userData.dirty&&i.userData.modelURL&&(this.populateModelGroup(i.userData.entities3D,i.userData.modelURL,i),i.userData.dirty=!1,i.userData.localCenter=void 0)}this.updateModelStyles(),this.rebatchDetachedInstances(),this.flushPendingOpacityChanges(),this.updateDebugUI();let e=this.loadPromises;return this.loadPromises=[],Promise.all(e)}rebatchDetachedInstances(){if(!Rb||this.detachedEntityIds.size===0)return;let e=new Map;for(let t of this.detachedEntityIds){let i=this.state.geometry3DMap.get(t);if(!i||i.type!=="model")continue;let o=i.components[0],r=i.components[1],a=o.mesh?.userData;if(!o.mesh?.parent)continue;let l=r.opacity??1,s=a?.sharedOpacity,c=Math.round(l*100)===100,h=this.shadowBatchKey(r.receiveShadow!==!1),d=this.shadowBatchKey(r.castShadow!==!1);if(c&&s!==void 0&&h&&d){this.pendingOpacityChanges.set(i.id,{entity:i,targetOpacity:l});continue}if(s!==void 0&&Math.abs(l-s)<=.01)continue;if(s!==void 0&&Math.abs(l-s)>.01){this.pendingOpacityChanges.set(i.id,{entity:i,targetOpacity:l});continue}let u=o.mesh.parent;if(!(u instanceof le))continue;let m=u.userData.modelURL;if(!m)continue;let v=yi(m),b=Math.round((r.opacity??1)*100),p=`${b}_${h?1:0}_${d?1:0}`;e.has(v)||e.set(v,new Map);let x=e.get(v),f=x.get(p);f||(f={opacityKey:b,receiveShadow:h,castShadow:d,entities:[]},x.set(p,f)),f.entities.push(i)}for(let[t,i]of e.entries()){let o=this.gltfCache.get(t);if(o)for(let{opacityKey:r,receiveShadow:a,castShadow:l,entities:s}of i.values())s.length<2||this.createSharedBatchForDetached(s,o,r/100,t,a,l)}this.publish("batch-changed")}createSharedBatchForDetached(e,t,i,o,r,a){if(e.length<2)return;let s=e[0].components[0].mesh?.parent;if(!s)return;let c=s.parent,h=c instanceof $?c.userData.entityId:"unknown",d=Xt(t,e.length,this.shadowReceiverFor(r));d.userData.detached=!0,d.userData.sharedOpacity=i,s.add(d);let u=this.createBatch(d,o,h,i,e.length,r,a);Yt(d,i),Fe(d,i,a);let m=new as,v=new rs,b=new ss,p=new ls,x,f,y=0;for(let C of e){let M=C.components[0],S=C.components[1],T=M.mesh;if(T){let w=this.getBatchForMesh(T);w&&this.removeBatch(w),Bo(T)}M.mesh=d,M.instanceIndex=y,f=M.feature,x=this.convertTo3DMapPosition(f.geometry.coordinates[1],f.geometry.coordinates[0],0),M.position.set(x.x,x.y,M.altitude),Ri(v,S.rotation),_i(p,S.scale),S.visible===!1&&p.set(0,0,0),b.setFromEuler(v),m.compose(M.position,b,p);for(let w of d.children)w instanceof ke&&(w.setMatrixAt(y,m),w.userData.entities[y]=C.id,w.count=y+1,w.instanceMatrix.needsUpdate=!0);Fo(d,y,S.color,S.material),y++}u.count=y,_o(d)}removeInstanceFromBatch(e,t,i){let o=e.count-1,r=e.opacity===1&&t.userData?.detached!==!0;if(e.count===1){if(r){e.count=0;for(let h of t.children)h instanceof ke&&(h.count=0,h.instanceMatrix.needsUpdate=!0);let c=this.instanceMap.get(e.containerId)?.get(e.urlHash);c&&c.object===e.mesh&&(c.count=0),this.updateDebugUI();return}this.removeBatch(e),Bo(t),this.updateDebugUI();return}for(let s of t.children)if(s instanceof ke){if(i!==o){s.getMatrixAt(o,this.tempMatrix),s.getColorAt(o,this.tempColor),s.setMatrixAt(i,this.tempMatrix),s.setColorAt(i,this.tempColor);let c=s.userData.entities[o];if(c){s.userData.entities[i]=c;let h=this.state.geometry3DMap.get(c);h&&(h.components[0].instanceIndex=i)}}delete s.userData.entities[o],s.count=o,s.instanceMatrix.needsUpdate=!0,s.instanceColor&&(s.instanceColor.needsUpdate=!0)}e.count=o;let l=this.instanceMap.get(e.containerId)?.get(e.urlHash);l&&l.object===e.mesh&&(l.count=o),this.updateDebugUI()}updateModelStyles(){for(let e of this.state.geometry3DsInScene){if(e?.type!=="model")continue;let t=e.components[1],i=e.components[0];if(!t.dirty&&!i.positionDirty)continue;if(i.instancingDisabled){this.updateNonInstancedModelStyle(e),t.dirty=!1,i.positionDirty=!1;continue}let o=i.mesh?.userData,r=o?.detached,a=t.opacity!=null&&t.opacity!==1,l=t.opacity??1,s=o?.sharedOpacity,c=s!==void 0&&Math.abs(l-s)>.01,h=i.mesh?this.getBatchForMesh(i.mesh):void 0,d=a&&!r&&i.mesh!=null||c;d&&this.pendingOpacityChanges.set(e.id,{entity:e,targetOpacity:l}),Bi(e),this.updateInstanceTransform(e),this.updateInstanceColor(e,t.color,t.material);let u=i.mesh?.userData?.detached;if(!d)if(u&&i.mesh){let m=t.opacity??1;Yt(i.mesh,m),Fe(i.mesh,m,h?.castShadow??!0)&&(this.transparencyChanged=!0)}else i.mesh&&Fe(i.mesh,l,h?.castShadow??!0)&&(this.transparencyChanged=!0);t.dirty=!1,i.positionDirty=!1}}flushPendingOpacityChanges(){if(this.pendingOpacityChanges.size===0)return;let e=new Map,t=new Map,i=(o,r,a,l,s,c,h,d)=>{let u=Math.round(r*100),m=`${s}_${c}_${u}_${a?1:0}_${l?1:0}`,v=t.get(m);v||(v={entities:[],targetOpacity:r,receiveShadow:a,castShadow:l,urlHash:s,containerId:c,gltf:h,parent:d},t.set(m,v)),v.entities.push(o)};for(let{entity:o,targetOpacity:r}of this.pendingOpacityChanges.values()){let a=o.components[0],l=o.components[1];if(!a.mesh||a.instanceIndex==null)continue;let s=a.mesh,c=this.getBatchForMesh(s),h=s.parent;if(!(h instanceof le))continue;let d=h.userData.modelURL;if(!d)continue;let u=yi(d),m=this.gltfCache.get(u);if(!m)continue;let v=h.parent,b=v instanceof $?v.userData.entityId:"unknown",p=this.shadowBatchKey(l.receiveShadow!==!1),x=this.shadowBatchKey(l.castShadow!==!1);if(c){let f=e.get(c);f||(f={entities:[],targetOpacity:r},e.set(c,f)),Math.round(f.targetOpacity*100)===Math.round(r*100)?f.entities.push(o):i(o,r,p,x,u,b,m,h)}else i(o,r,p,x,u,b,m,h)}for(let[o,r]of e){let{entities:a,targetOpacity:l}=r,s=o.mesh.userData?.detached===!0,c=Math.round(l*100)===100;if(a.length===o.count&&s&&!c)o.opacity=l,o.mesh.userData.sharedOpacity=l,Yt(o.mesh,l),Fe(o.mesh,l,o.castShadow)&&(this.transparencyChanged=!0);else{let u=a[0]?.components[0]?.mesh?.parent;if(u instanceof le){let m=u.userData.modelURL;if(m){let v=yi(m),b=this.gltfCache.get(v),p=u.parent,x=p instanceof $?p.userData.entityId:"unknown";if(b)for(let f of a)i(f,l,this.shadowBatchKey(o.receiveShadow),this.shadowBatchKey(o.castShadow),v,x,b,u)}}}}for(let o of t.values()){let{entities:r,targetOpacity:a,receiveShadow:l,castShadow:s,urlHash:c,containerId:h,gltf:d,parent:u}=o,m=Math.round(a*100);for(let y of r){let C=y.components[0],M=C.mesh,S=this.getBatchForMesh(M),T=C.instanceIndex;S&&T!=null&&T>=0&&this.removeInstanceFromBatch(S,M,T)}let v,b,p=this.batchesByUrlHash.get(c);if(p){for(let y of p)if(y.containerId===h&&Math.round(y.opacity*100)===m&&y.receiveShadow===l&&y.castShadow===s&&y.count+r.length<=y.maxCount){v=y,b=y.mesh;break}}if(!v||!b){let y=Math.max(li,r.length),C=Xt(d,y,this.shadowReceiverFor(l));C.userData.detached=!0,C.userData.sharedOpacity=a,u.add(C),v=this.createBatch(C,c,h,a,y,l,s),b=C,Yt(C,a),Fe(C,a,s)&&(this.transparencyChanged=!0)}let x,f;for(let y of r){let C=y.components[0],M=y.components[1],S=v.count;C.mesh=b,C.instanceIndex=S,f=C.feature,x=this.convertTo3DMapPosition(f.geometry.coordinates[1],f.geometry.coordinates[0],0),C.position.set(x.x,x.y,C.altitude),Ri(this.tempEuler,M.rotation),_i(this.tempScale,M.scale),M.visible===!1&&this.tempScale.set(0,0,0),this.tempQuaternion.setFromEuler(this.tempEuler),this.tempMatrix.compose(C.position,this.tempQuaternion,this.tempScale);for(let T of b.children)T instanceof ke&&(T.setMatrixAt(S,this.tempMatrix),T.userData.entities[S]=y.id,T.count=S+1,T.instanceMatrix.needsUpdate=!0);this.updateInstanceColor(y,M.color,M.material),v.count++,b.userData.detached?this.detachedEntityIds.add(y.id):this.detachedEntityIds.delete(y.id)}_o(b),this.publish("batch-changed")}this.pendingOpacityChanges.clear(),this.updateDebugUI()}updateInstanceTransform(e){let t=e.components[0],i=e.components[1];if(!t.mesh)return;let o=t.feature,{x:r,y:a}=this.convertTo3DMapPosition(o.geometry.coordinates[1],o.geometry.coordinates[0],0);if(t.position.set(r,a,t.altitude),Ri(this.tempEuler,i.rotation),i.visible===!1?this.tempScale.set(0,0,0):_i(this.tempScale,i.scale),t.instancingDisabled){let l=t.meshContainer??t.mesh;l.position.copy(t.position),l.rotation.set(this.tempEuler.x,this.tempEuler.y,this.tempEuler.z),l.scale.copy(this.tempScale);return}if(!(t.instanceIndex==null||t.instanceIndex<0)){this.tempQuaternion.setFromEuler(this.tempEuler),this.tempMatrix.compose(t.position,this.tempQuaternion,this.tempScale);for(let l of t.mesh.children)l instanceof ke&&nc(l.instanceMatrix.array,t.instanceIndex*16,this.tempMatrix)&&(l.setMatrixAt(t.instanceIndex,this.tempMatrix),l.instanceMatrix.needsUpdate=!0,l.boundingSphere=null)}}updateNonInstancedModelStyle(e){let t=e.components[0],i=e.components[1];if(!t.mesh)return;Bi(e),this.updateInstanceTransform(e);let o=i.opacity??1,r=t.meshContainer??t.mesh;qn(t.mesh,o,i.visibleThroughGeometry),Fe(r,o,this.shadowBatchKey(i.castShadow!==!1))&&(this.transparencyChanged=!0),i.color&&!ko(r)&&$n(t.mesh,i.color)}updateInstanceColor(e,t,i){let o=e.components[0];!o.mesh||o.instanceIndex==null||o.instanceIndex<0||Fo(o.mesh,o.instanceIndex,t,i)}removeInstance(e){let t=e.components[0];if(this.detachedEntityIds.delete(e.id),this.nonInstancedModels.has(e.id)){let c=this.nonInstancedModels.get(e.id);return c?.mesh&&(Kn(c.mesh),c.mesh.parent?.remove(c.mesh)),this.nonInstancedModels.delete(e.id),t.mesh=null,t.meshContainer=null,this.updateDebugUI(),!0}if(!t.mesh||t.instanceIndex==null||t.instanceIndex<0)return!0;let i=this.getBatchForMesh(t.mesh);if(!i)return!0;let o=t.instanceIndex,r=i.count-1,a=i.opacity===1&&t.mesh.userData?.detached!==!0;if(i.count===1){if(a){i.count=0;for(let v of t.mesh.children)v instanceof ke&&(v.count=0,v.instanceMatrix.needsUpdate=!0);let m=this.instanceMap.get(i.containerId)?.get(i.urlHash);return m&&m.object===i.mesh&&(m.count=0),t.mesh.parent&&t.mesh.parent.remove(t.mesh),t.mesh=null,this.updateDebugUI(),!1}let c=i.urlHash;this.removeBatch(i);let h=this.batchesByUrlHash.get(c),d=!1;if(h){for(let u of h)if(u.count>0){d=!0;break}}return Bo(t.mesh),t.mesh=null,this.updateDebugUI(),!d}for(let c of t.mesh.children)if(c instanceof ke){if(o!==r){c.getMatrixAt(r,this.tempMatrix),c.getColorAt(r,this.tempColor),c.setMatrixAt(o,this.tempMatrix),c.setColorAt(o,this.tempColor);let h=c.userData.entities[r];if(h){c.userData.entities[o]=h;let d=this.state.geometry3DMap.get(h);d?d.components[0].instanceIndex=o:E.warn("[removeInstance] Could not find lastEntity in geometry3DMap:",h)}}delete c.userData.entities[r],c.count=r,c.instanceMatrix.needsUpdate=!0,c.instanceColor&&(c.instanceColor.needsUpdate=!0)}i.count=r;let s=this.instanceMap.get(i.containerId)?.get(i.urlHash);return s&&s.object===i.mesh&&(s.count=r),t.mesh=null,this.updateDebugUI(),!1}destroy(){this.gltfCache.clear(),this.gltfLoadPromises.clear();for(let e of this.instanceMap.values())for(let t of e.values())lc(t.object);this.instanceMap.clear(),this.modelNames.clear(),this.batchByMesh.clear(),this.batchesByUrlHash.clear(),this.batchCounter=0;for(let e of this.nonInstancedModels.values())e.mesh&&(Kn(e.mesh),e.mesh.parent?.remove(e.mesh));this.nonInstancedModels.clear(),this.debugUI.destroy(),this.loadPromises=[],this.loader=void 0}endFrame=()=>{this.transparencyChanged=!1}};g();var _b=250,on=class{#e;#o=null;#n;#r;#a=!0;#s=-1/0;#l=0;#h=0;constructor(e,t,{headless:i=!1,maxAgeMs:o=_b}={}){this.#e=e,this.#n=t,this.#r=o,!i&&typeof ResizeObserver=="function"&&(this.#o=new ResizeObserver(this.#p),this.#o.observe(e))}#p=()=>{this.#a=!0,this.#n?.()};get observing(){return this.#o!=null}invalidate(){this.#a=!0}read(e=performance.now()){if(this.#o==null||this.#a||e-this.#s>this.#r){let{width:t,height:i}=it(this.#e);this.#l=t,this.#h=i,this.#s=e,this.#a=!1}return this}get width(){return this.#l}get height(){return this.#h}destroy(){this.#o?.disconnect(),this.#o=null}};g();import{Vector3 as Bb}from"three";var rn=3,nn=3,$d={BehindCamera:1},hs=-1e3;function Yd(n){return Math.trunc(n*10)/10}var cs=new Bb;function qd(n,e,t,i,o,r,a,l){for(let s=0;s<t;s++){let c=s*rn,h=s*nn,d=n[c+2];if(!(l>d)){e[h]=hs,e[h+1]=hs,e[h+2]=$d.BehindCamera;continue}cs.set(n[c],n[c+1],d).applyMatrix4(i).applyMatrix4(o),e[h]=Yd((cs.x+1)/2*r),e[h+1]=Yd((-cs.y+1)/2*a),e[h+2]=0}}g();var an=class{#e;#o;constructor(e,t,i,o,r={}){this.#e=t,this.#o=new Hs(e,i,o,{viewportSize:()=>it(e),headless:He(),...r})}get pipeline(){return this.#o}get labelCanvas(){return this.#o.labelCanvas}get interactiveCollidersQTree(){return this.#o.collisionSystem.interactiveCollidersQTree}get visibleCollidersQTree(){return this.#o.collisionSystem.visibleCollidersQTree}resize(){this.#o.resize()}syncTwoDEntities(){this.#o.clearEntities();for(let e of this.#e.geometry2DsInScene)e.syncPosition(),this.#o.addEntity(e.entity2D)}update(e,t,i,o=[]){this.#n(),this.#o.update(e,t,i,o)}#n(){let e,t;for(let i of this.#e.geometry2DsInScene){t=i.components[0];let o=i.attachedTo?this.#e.geometry3DMap.get(i.attachedTo):void 0;if(o instanceof U)if(this.#e.geometry3DsInScene.has(o)){if(e=o.components[1],e.dirty||t.attachedDirty){let a=e.height,l=e.altitude;i.setAltitude(a+l)}let r=e.visible;t.visible!==r&&(t.visible=r)}else t.visible===!0&&(t.visible=!1);t.attachedDirty=!1}}markDirty(){this.#o.markDirty()}get collidersNeedRecomputing(){return this.#o.collidersNeedRecomputing}set collidersNeedRecomputing(e){this.#o.collidersNeedRecomputing=e}updateWatermark(e){this.#o.updateWatermark(e)}cancelPendingFrames(){this.#o.cancelPendingFrames()}setCollidersDirty(){this.#o.collisionSystem.collidersDirty=!0}deleteTextCacheEntry(e){delete this.#o.drawSystem.textCache[e]}getLabelCacheStats(){let e=this.#o.drawSystem.getCacheStats(),t=this.#o.drawSystem,i=[];for(let o of this.#e.geometry2DsInScene){if(o.type!=="label")continue;let r=o.entity2D.component,l=t.textCache[r.id]?.canvas??null,s=l!=null,c=r.labelCacheId!=null&&t.pinCache[r.labelCacheId]!=null,h=r.imageHash!=null&&t.imageCache[r.imageHash]!=null,d=l?l.width*l.height*4:0;i.push({id:r.id,text:r.text,screenPosition:{x:r.projection.x,y:r.projection.y},dimensions:{width:r.dimensions.width,height:r.dimensions.height},textCached:s,pinCached:c,imageCached:h,textMemoryBytes:d,totalMemoryBytes:d,textCanvas:l,pinCanvases:r.labelCacheId!=null?t.pinCache[r.labelCacheId]??null:null,imageSource:r.imageHash!=null?t.imageCache[r.imageHash]??null:null})}return{cacheStats:e,labels:i}}showCollisionBoxes(){this.#o.showCollisionBoxes()}hideCollisionBoxes(){this.#o.hideCollisionBoxes()}destroy(){this.#o.destroy()}};var tu=new Ub;var{DEFAULT_PITCH:ps,DEFAULT_BEARING:fs,DEFAULT_ZOOM_LEVEL:gs,DEFAULT_MIN_ZOOM_LEVEL:Xb,DEFAULT_MAX_ZOOM_LEVEL:Yb}=De,$b=us.radToDeg(.6435011087932844),ms=class extends z{options;container;Debug;#e;#o;#n;#r;get viewCamera(){return this.#r}get cameraObject(){return this.#o}#a;#s;#l;#h;get canvasWidth(){return this.#i.canvasWidth}get canvasHeight(){return this.#i.canvasHeight}rendererDomElement;get resolutionScale(){return this.map?._getClampedPixelRatio(this.canvasWidth,this.canvasHeight)??Wt()}#p(e){this.#f!=="outdoors-overlay"&&this.map?.setPixelRatio(e),this.#i.pixelRatio=this.resolutionScale}get aspect(){return this.canvasWidth/this.canvasHeight}get labelsCanvas(){return this.#t.twoDEntitySystem?.labelCanvas??null}#i;camera;#d;#t={};#g=null;map;#u=()=>{this.signal?.aborted||!this.#t?.renderSystem||(this.#t.renderSystem.twoDdirty=!0)};#c=()=>{this.signal?.aborted||!this.#t?.renderSystem||(this.#t.renderSystem.threeDdirty=!0)};#v=()=>{this.map&&(this.#i.depthRangeFor3D=this.map.painter.depthRangeFor3D)};#x=(e,t)=>{e.addEventListener("childadded",t),e.addEventListener("childremoved",t),this.onAbort(()=>{e.removeEventListener("childadded",t),e.removeEventListener("childremoved",t)})};#S(){this.#t.twoDEntitySystem.markDirty()}#f="standalone";get mode(){return this.#f}#y="native";get cameraMode(){return this.#y}constructor(e,t={}){super();let i={geometry3DMap:new Map,geometry2DMap:new Map,geometry2DIdsInScene:new Set,geometry3DIdsInScene:new Set,geometryGroupIdsToLoad:new Set,geometry3DsInScene:new Set,geometry2DsInScene:new Set,geometryScene:new $("__scene"),hoverColor:"#f6efff",text3dHoverColor:"white",disableUpdateStateValidation:t.disableUpdateStateValidation??!1,insetsPadding:xi,shouldMeasureCanvas:!0,pixelRatio:this.resolutionScale,canvasWidth:0,canvasHeight:0,internalTweenGroup:new pn,externalTweenGroup:new pn,cameraObject:new Qd,naturalBearing:0,containerOffset:[0,0],useStandaloneCamera:!1,directionalLight:new Fb(16777215,.3*Math.PI),ambientLight:new Gb(16777215,.741*Math.PI),renderer:void 0,threeJSScene:new Nb,depthRangeFor3D:[0,1],renderStats:{drawCalls:0,triangles:0,lines:0,points:0},alwaysOnTopPaths:0,geometry2DState:{entities:new Set,entityMap:new Map,entityIds:new Set,get pixelRatio(){return i.pixelRatio}}};this.#i=i,this.#i.useStandaloneCamera=t.useStandaloneCamera??!1,this.#i.naturalBearing=t.naturalBearing??0,this.convertTo3DMapPosition=this.convertTo3DMapPosition.bind(this);let{width:o,height:r}=it(e);if(!o||!r)throw new Error("[MappedinJS] Container width and height must be greater than 0");(t.mode==="outdoors-interleaved"||t.mode==="outdoors-overlay")&&t.map&&(this.#f=t.mode,this.map=t.map),this.#y=t.outdoorView?.__EXPERIMENTAL_CameraControlsMode==="external"?"external":"native",this.#x(this.#i.geometryScene,()=>{this.#c(),this.#u()}),this.#i.geometry3DMap.set(this.#i.geometryScene.userData.entityId,this.#i.geometryScene),t.center&&(this.#i.center=t.center?[...t.center]:[0,0]),this.options=t,this.container=e,this.#t.htmlControlsSystem=this.#m(new nr(this.container,{outdoorEnabled:!!this.map})),this.#t.maskingSystem=this.#m(new Vr(this.#i)),this.#f!=="outdoors-overlay"&&this.#t.htmlControlsSystem.addAttributionControl(this.options.attribution),window.MappedinDebug||(window.MappedinDebug={}),D.env.NODE_ENV==="test"&&(window.MappedinDebug.mapViewCoreInstance=this),this.#d=new Po({antialias:typeof t.antialias=="boolean"?t.antialias:!0,alpha:!1,canvas:this.mode!=="standalone"?t.gl?.canvas:void 0,onWebGLContextCreationError:t.onWebGLContextCreationError,onWebGLContextLost:t.onWebGLContextLost,onWebGLContextRestored:y=>{t.onWebGLContextRestored?.(y),this.#t?.occlusion2DSystem?.contextRestored(),this.#u(),this.#c(),this.render()},onWebGLRendererError:t.onWebGLRendererError,backgroundColor:t.backgroundColor||"#ffffff",backgroundAlpha:t.backgroundAlpha??1}),this.#i.renderer=this.#d.renderer,this.#e=this.#i.threeJSScene,this.#e.matrixWorldAutoUpdate=!1,this.onAbort(Lc(this.#e)),this.#f!=="standalone"&&this.#e.add(ol()),this.#e.add(this.#i.geometryScene);let a=window.__THREE_DEVTOOLS__;D.env.NODE_ENV==="dev"&&typeof a<"u"&&(a.dispatchEvent(new CustomEvent("observe",{detail:this.#e})),a.dispatchEvent(new CustomEvent("observe",{detail:this.#d}))),this.#o=new Qd($b,this.aspect,50,1e5),this.#i.cameraObject=this.#o,this.#r=new Hb,this.#r.matrixWorldAutoUpdate=!1,this.#o.renderOrder=999;let l=new Jd;l.add(this.#o),this.#h=new Jd,this.#h.add(l),this.#e.add(this.#h),this.#o.updateProjectionMatrix(),this.#o.updateMatrixWorld(!0);let s=Fd(t.shadows,()=>Gd(this.#i));for(let y of s.logLines)E[y.level](y.message);s.enabled&&(this.#t.shadowsSystem=this.#m(new Qr(this.#i,this.#d,this.#h,s.options,s.ladder)),this.map&&this.onMapLibreEvent("render",this.#v)),this.#w=this.mode==="standalone"?this.#o:this.#r,this.referenceMap={scale:1,latitude:0,longitude:0,getNorth:()=>0,georeference:[{target:{x:0,y:0}},{target:{x:0,y:0}},{target:{x:0,y:0}},{target:{x:0,y:0}}]},this.rendererDomElement=this.#d.domElement(),this.#C=new on(this.rendererDomElement,()=>this.render(),{headless:He()}),this.onAbort(()=>this.#C.destroy()),this.#a=new ds;let c=new Kd(1e6,1e6),h=new zb({color:0,visible:!1});this.#s=new kb(c,h),this.#s.name="worldPlane",this.#e.add(this.#s),t.gl?.canvas||e.appendChild(this.rendererDomElement),window.addEventListener("resize",this.#F,{capture:!1,signal:this.signal}),this.#I(),document.addEventListener("visibilitychange",this.#B,{signal:this.signal}),typeof ResizeObserver=="function"&&!He()&&(this.#l=new ResizeObserver(ao(y=>{this.#T(y[0].contentRect.width,y[0].contentRect.height)},50)),this.#l?.observe(e),this.#l&&this.onAbort(()=>this.#l?.disconnect())),e.classList.add("mappedin-map"),e.style.isolation="isolate",this.rendererDomElement.style.width=globalThis.MappedinDebug?.TEST_IOS?"1080px":"100%",this.rendererDomElement.style.height=globalThis.MappedinDebug?.TEST_IOS?"1920px":"100%",D.env.NODE_ENV==="test"&&this.rendererDomElement.setAttribute("data-testid","mappedin-canvas"),this.mode!=="outdoors-overlay"&&this.#y!=="external"&&this.rendererDomElement.tabIndex!==void 0&&this.rendererDomElement.removeAttribute("tabindex"),Object.defineProperty(this.#i,"canvasWidth",{configurable:!0,enumerable:!0,get:()=>Sn(this.rendererDomElement)?We().width:this.rendererDomElement.clientWidth}),Object.defineProperty(this.#i,"canvasHeight",{configurable:!0,enumerable:!0,get:()=>Sn(this.rendererDomElement)?We().height:this.rendererDomElement.clientHeight}),this.rendererDomElement.style.touchAction="manipulation";let d=this.canvasWidth,u=this.canvasHeight;this.#t.watermarkSystem=this.#m(new tr(this.#o,this.#i,t?.watermark)),this.#t.watermarkSystem.on("texture-loaded",this.render),this.#i.shouldMeasureCanvas=!0,this.#i.pixelRatio=this.resolutionScale,this.#E(Math.floor(d*this.resolutionScale),Math.floor(u*this.resolutionScale)),this.#i.directionalLight.position.set(-150,-150,350),this.#e.add(this.#i.directionalLight),this.#e.add(this.#i.ambientLight),this.#t.cameraSystem=this.#m(new Kt(this.#o,this.#e,this.#d.renderer,this.#i,{mode:this.mode,__EXPERIMENTAL_CameraControlsMode:this.cameraMode,canvasHeight:u,canvasWidth:d})),globalThis.MappedinDebug?.__idleCallbackInteractionState&&(globalThis.MappedinDebug.__idleCallbackInteractionState.registerInteractionChecker(this.#t.cameraSystem.isUserInteracting),globalThis.MappedinDebug.__idleCallbackInteractionState.registerInteractionChecker(this.#t.cameraSystem.isCameraMoving)),this.#t.cameraSystem.on("user-dolly-start",this.#A,{signal:this.signal}),this.#t.cameraSystem.on("user-pan-start",this.#A,{signal:this.signal}),this.#t.cameraSystem.on("user-rotate-start",this.#A,{signal:this.signal}),this.#t.cameraSystem.on("user-zoom-start",this.#A,{signal:this.signal}),this.#t.cameraSystem.on("user-tilt-start",this.#A,{signal:this.signal}),this.#t.cameraSystem.on("user-pedestal-start",this.#A,{signal:this.signal}),this.#t.cameraSystem.on("user-dolly-end",this.#R,{signal:this.signal}),this.#t.cameraSystem.on("user-pan-end",this.#R,{signal:this.signal}),this.#t.cameraSystem.on("user-rotate-end",this.#R,{signal:this.signal}),this.#t.cameraSystem.on("user-zoom-end",this.#R,{signal:this.signal}),this.#t.cameraSystem.on("user-tilt-end",this.#R,{signal:this.signal}),this.#t.cameraSystem.on("user-pedestal-end",this.#R,{signal:this.signal}),this.#t.cameraSystem.on("change",this.#K),this.#t.pathSystem=this.#m(new eo(this.#i,this.convertTo3DMapPosition,this.getParentContainer,this.#t.cameraSystem.convertZoomLevelToAltitude)),this.#t.pathSystem.on("animate:path",this.render,{signal:this.signal}),this.#t.panBoundsSystem=this.#m(new rr(this.#i,this.#t.cameraSystem));let m=()=>{let{panBounds:y,fov:C,convertAltitudeToZoomLevel:M}=this.#t.cameraSystem;if(this.#t.panBoundsSystem.autoMinZoomLevel){if(y.radius<=0)return;let S=Math.min(this.#i.canvasWidth/this.#i.canvasHeight,1),T=C*Math.PI/180*S,w=Math.tan(T/2),{radius:P,center:L}=this.#t.cameraSystem.panBounds,N=P/w,A=this.getThreeCamera().getWorldPosition(new Ye),G=L.distanceTo(A),B=Math.abs(A.z-L.z),H=N*B/G,j=M(H);il(j,this.camera.minZoomLevel)&&this.camera.setMinZoomLevel(j)}this.publish("pan-bounds-change",this.#t.cameraSystem.panBounds)};this.#t.panBoundsSystem.on("update",m,{signal:this.signal}),this.camera=this.#m(new er(this,this.#t,this.#i));let v=()=>{this.#t.geometryInFocusSystem&&this.#t.geometryInFocusSystem.resize(),this.render()};this.camera.on("padding-change",v,{signal:this.signal}),this.camera.setZoomLevel(t.zoomLevel??gs),this.camera.setBearing(t.bearing??fs),this.camera.setPitch(t.pitch??ps),this.camera.setMaxZoomLevel(Yb),this.camera.setMinZoomLevel(Xb),this.#t.twoDEntitySystem=this.#m(new an(this.container,this.#i,this.#i.geometry2DState,this.projectBatch,{workerUrl:gn||void 0,useCollisionWorker:(t.useCollisionWorker??!0)&&(t.useWorkers??!0),transformImageRequest:t.transformImageRequest,watermark:{width:0,height:0,position:"bottom-left"}})),this.#t.interactionSystem=this.#m(new Fi(this.rendererDomElement,this.#i,this.#o,this.#s,this.#t.cameraSystem.isUserInteracting)),this.#t.interactionSystem.on("doubletap-with-onefinger",y=>{this.#y!=="external"&&this.#t.cameraSystem.enableZoom&&this.camera.animateTo({center:this.projectScreenXYToCoordinate(y.clientX,y.clientY)?.coordinate,zoomLevel:this.camera.zoomLevel+1,duration:xn,easing:"ease-out"})}),this.#t.interactionSystem.on("singletap-with-twofinger",()=>{this.#y!=="external"&&this.#t.cameraSystem.enableZoom&&this.camera.animateTo({zoomLevel:this.camera.zoomLevel-1,duration:xn,easing:"ease-out"})}),this.#t.interactionSystem.on("hover",this.render),this.#t.interactionSystem.on("click",y=>{if(y.entity2D.some(M=>M.id==="watermark")&&typeof this.#t.watermarkSystem.options.onClick=="function"&&this.#t.watermarkSystem.options.interactive){this.#t.watermarkSystem.options.onClick();return}if(!y.position){E.error("Pointer event outside world-plane");return}this.publish("click",{...this.#k(y,y.position),pointerEvent:y.pointerEvent})}),this.#t.interactionSystem.on("long-press",y=>{if(!y.position){E.error("Pointer event outside world-plane");return}this.publish("long-press",{...this.#k(y,y.position),pointerEvent:y.pointerEvent})}),this.#t.interactionSystem.on("hover",y=>{y.position&&this.publish("hover",this.#k(y,y.position))}),this.#t.geometryInFocusSystem=this.#m(new gr(this.#i,this.#w));let b=y=>{this.publish("geometry-in-focus",y)};this.#t.geometryInFocusSystem.on("geometry-in-focus",b,{signal:this.signal}),this.#t.drawSystem=this.#m(new Vo(this.#i,this.convertTo3DMapPosition,this.convert3DMapPositionToCoordinate)),this.#t.exporterSystem=this.#m(new ki(this.#i)),this.#t.batchedMeshSystem=this.#m(new Ho(this.#i,this.convertTo3DMapPosition)),this.#t.batchedMeshSystem.on("geometry-2d-added",this.render,{signal:this.signal}),this.#t.batchedMeshSystem.on("geometry-group-added",this.#b,{signal:this.signal}),this.#t.modelSystem=this.#m(new tn(this.#i,this.convertTo3DMapPosition)),this.#t.modelSystem.on("model-loaded",()=>{this.#t.shadowsSystem&&this.#t.shadowsSystem.castersChanged(),this.render()},{signal:this.signal}),this.#t.modelSystem.on("batch-changed",()=>{this.#t.interactionSystem.dirty3D=!0},{signal:this.signal}),this.#t.meshDetachmentSystem=this.#m(new _r(this.#i)),this.#t.meshModificationSystem=this.#m(new Br(this.#i)),this.#t.geometryDisposalSystem=this.#m(new Nr(this.#i)),this.#t.textureSystem=this.#m(new Ur(this.#i)),this.#t.textureSystem.on("texture-added",this.render,{signal:this.signal}),this.#t.borderSystem=this.#m(new Yl(this.#i,this.convertTo3DMapPosition)),this.#t.clippingPlaneSystem=this.#m(new Zr(this.#i)),this.#t.renderOrderSystem=this.#m(new Wr(this.#i)),this.#t.pluginSystem=this.#m(new Xr),this.#t.customGeometrySystem=this.#m(new ar(this.#i,this.convertTo3DMapPosition));let p=typeof t.outlines=="object"?t.outlines:void 0;p&&(this.#i.outlinesOptions=p);let x=t.__TEST_synchronousIdleWork,f=x?.enabled&&typeof x.maxDelay=="number"?x.maxDelay:void 0;this.#t.outlineInterpolationSystem=this.#m(new lr(this.#i,p,!0,f)),this.#t.outlineInterpolationSystem.on("needs-render",this.render,{signal:this.signal}),this.#t.renderSystem=this.#m(new jo(this.#d,this.#i,this.mode,this.#e,this.#o,this.viewCamera,this.#t)),this.#t.imageSystem=this.#m(new pr(this.#i,this.convertTo3DMapPosition,this.project,t.bearing,t.naturalBearing,t.imagePlacementOptions,t.transformImageRequest)),this.#t.text3DSystem=this.#m(new al(this.#i,this.convertTo3DMapPosition,t.useWorkers??!0)),this.#t.text3DSystem.on("render",this.render,{signal:this.signal}),this.#t.imageSystem.on("image-loaded",this.render,{signal:this.signal}),this.#t.renderSystem.on("pre-render",()=>this.publish("pre-render"),{signal:this.signal}),this.#t.renderSystem.on("post-render",()=>this.publish("post-render"),{signal:this.signal}),this.#t.renderSystem.on("measure-canvas",this.#P,{signal:this.signal}),this.#t.outdoorLayersSystem=this.#m(new br(this.map,f)),this.#t.occlusion2DSystem=this.#m(new zr(this.#i,this.convertTo3DMapPosition,this.#d)),t.occlusionEnabled&&this.#t.occlusion2DSystem.enable(),this.Debug=new Fr(this),t.environment!==!1&&(this.#n=this.#j()),this.#L()}#b=()=>{this.#t.geometryDisposalSystem.dirty=!0,this.render()};#M=e=>Math.trunc(e*10)/10;#_=()=>{this.#p(Wt()),this.#t.twoDEntitySystem.markDirty(),this.#T(void 0,void 0,!0)};#I=()=>{this.signal?.aborted||typeof window>"u"||He()||typeof window.matchMedia!="function"||(this.#g=window.matchMedia(`(resolution: ${window.devicePixelRatio}dppx)`),this.#g.addEventListener("change",()=>{this.#_(),this.#I()},{once:!0,signal:this.signal}))};#B=()=>{this.#C.invalidate(),document.visibilityState==="visible"&&this.#T(void 0,void 0,!0)};#F=()=>{this.#T()};#w;#T=(e,t,i=!1)=>{let o=it(this.rendererDomElement),r=e??o.width,a=t??o.height;if((r===0||a===0)&&!i)return;if(this.#C.invalidate(),this.#t.twoDEntitySystem.resize(),this.#p(Wt()),this.#P(),this.#S(),this.#t.cameraSystem.resize(this.canvasWidth,this.canvasHeight),this.#t.cameraSystem.dirty=!0,this.#t.cameraSystem.stateDirty=!0,this.map!=null){vo(this.map,this.camera.minZoomLevel,this.camera.maxZoomLevel);let c=this.camera.zoomLevel,h=us.clamp(c,this.camera.minZoomLevel,this.camera.maxZoomLevel);h!==c&&this.camera.setZoomLevel(h)}this.#t.watermarkSystem.resize(this.canvasWidth,this.canvasHeight),this.#t.htmlControlsSystem.resize(this.canvasWidth),this.#t.geometryInFocusSystem.resize(),this.#t.occlusion2DSystem.resize(),this.#t.twoDEntitySystem.resize();let{top:l,left:s}=this.container.getBoundingClientRect();this.#i.containerOffset=[l,s],this.publish("resize"),this.map!=null&&this.#Y(!0),this.render()};#L=()=>{this.renderSync()};#G=new Ye;#C;projectBatch=(e,t,i=Math.floor(e.length/rn))=>{let o=i*nn,r=t!=null&&t.length>=o?t:new Float64Array(o),a=this.#C.read();return qd(e,r,i,this.#w.matrixWorldInverse,this.#w.projectionMatrix,a.width,a.height,this.#o.position.z+this.camera.elevation),r};project=(e,t)=>{if(this.#o.position.z+this.camera.elevation>t.z){this.#G.copy(t);let i=this.#G.project(this.#w),o=(i.x+1)/2*this.canvasWidth-0/2,r=(-i.y+1)/2*this.canvasHeight-0/2,a=this.#M(o),l=this.#M(r);e.x=a,e.y=l,e instanceof Ye&&(e.z=i.z)}else e.x=-1e3,e.y=-1e3,e instanceof Ye&&(e.z=1/0)};#E=(e,t)=>{this.#d.setBufferSize(e,t),this.#o.aspect=e/t,this.#o.updateProjectionMatrix(),this.#o.updateMatrixWorld(!0),this.#a.x=e,this.#a.y=t};#P=()=>{this.#C.invalidate();let{width:e,height:t}=it(this.rendererDomElement),i=Math.floor(e*this.resolutionScale),o=Math.floor(t*this.resolutionScale);this.#E(i,o),this.map?.resize(),this.#i.shouldMeasureCanvas=!1};addGroupContainer(e,t,i){if(!this.#i.geometry3DMap.has(e)&&!this.#i.geometry2DMap.has(e)){let o=new $(e);this.#x(o,()=>{this.#c(),this.#u()}),t?.visible!==void 0&&(o.visible=t.visible),t?.altitude!==void 0&&o.setAltitude(t.altitude),t?.interactive!==void 0&&ce(o,t.interactive,this.#i),t?.focusable!==void 0&&wo(o,t.focusable),t?.preloadGeometry!==void 0&&(o.userData.preloadGeometry=t.preloadGeometry),this.#i.geometry3DMap.set(e,o);let r=this.getParentContainer(i);r instanceof $&&r.addEntity(o),this.#c(),this.render()}else E.error(`Group container with ID '${e}' already exists. The group container cannot be added.`);return{id:e,type:"group-container"}}getParentContainer=(e,t=!0)=>{if(!e)return t?this.#i.geometryScene:void 0;if(typeof e=="string"||typeof e=="number"){let i=this.#i.geometry3DMap.get(e);return i instanceof $?i:(E.warn(`Parent (${typeof e=="object"?e.id:e}) is not a valid container, adding to scene`),t?this.#i.geometryScene:void 0)}else if(e.type==="group-container"){let i=this.#i.geometry3DMap.get(e.id);if(i instanceof $)return i}return t?this.#i.geometryScene:void 0};addCustomGeometry(e,t,i,o,r){if(this.#i.geometry3DMap.has(e))E.error(`Custom geometry with ID '${e}' already exists. The custom geometry cannot be added.`);else{let a=new Qt(t,i),l=new U(a,new Be(o));o?.interactive!==void 0&&ce(l,o.interactive,this.#i),l.id=e,a.mesh.userData={entityId:e,type:"custom-geometry"},this.#i.geometry3DMap.set(l.id,l);let s=this.getParentContainer(r);r&&s instanceof $?s.addEntity(l):this.#i.geometryScene.addEntity(l),this.#t.panBoundsSystem.dirty=!0,this.#c(),this.render()}return{id:e,type:"custom-geometry"}}registerPlugin(e){this.#t.pluginSystem.registerPlugin(e)}unregisterPlugin(e){this.#t.pluginSystem.unregisterPlugin(e)}addFeatureCollection(e,t,i,o,r){if(!this.#i.geometry3DMap.has(e)&&!this.#i.geometry2DMap.has(e)){let a=new le(e);this.#x(a,()=>{this.#c(),this.#u()}),a.userData.dirty=!0,o?.altitude!==void 0&&(a.position.z=o.altitude),o?.visible!==void 0&&(a.visible=o.visible);let l="merged",s;if(typeof i=="function"?(l="batched",s=i):typeof i=="object"?s=()=>i:s=()=>({color:To}),this.#i.geometry3DMap.set(e,a),l==="batched")for(let d of t.features){if(d.geometry==null||!["Polygon","MultiPolygon","LineString","MultiLineString"].includes(d.geometry.type))continue;let u=d?.id||d?.properties?.id||kt(),m=s(d)??{color:To},v=this.#t.batchedMeshSystem.createEntityFromFeature(u,d,{outline:!0,...m});this.#i.geometry3DMap.set(u,v),a.userData.entities3D.add(u),this.#t.textureSystem.dirty=!0}else if(l==="merged"){let d=s()??{color:To},u=this.#t.batchedMeshSystem.createEntityFromFeature(e,t.features,{outline:!0,...d});this.#i.geometry3DMap.set(u.id,u),a.userData.entities3D.add(u.id),a.userData.isMerged=!0,this.#t.textureSystem.dirty=!0}let c=t.features.length>0?s(t.features[0]):void 0;c?.__EXPERIMENTAL_maskEnabled===!0&&_n(a,{enabled:c.__EXPERIMENTAL_maskEnabled,maskId:c.__EXPERIMENTAL_maskId,effect:c.__EXPERIMENTAL_maskEffect,mode:c.__EXPERIMENTAL_maskMode});let h=this.getParentContainer(r);h instanceof $&&h.addEntity(a),this.#t.panBoundsSystem.dirty=!0,this.#c(),this.render()}else E.error(`Feature collection with ID '${e}' already exists. The feature collection cannot be added.`);return this.#t.outlineInterpolationSystem.geometries3DDirty=!0,{id:e,type:"feature-collection"}}addOccluder(e,t){let i=this.getParentContainer(t),o=this.#t.occlusion2DSystem.reserveOccluderId();return i?.addOccluderFeature(e,o),o}addImage(e,t,i,o){try{Yc(e,t,i)}catch(r){E.error(r);return}if(!this.#i.geometry3DMap.has(e)&&!this.#i.geometry2DMap.has(e)){let r=new ei(t),a=new U(r,new Be(i));a.id=e||kt(),r.mesh.userData={entityId:a.id,type:"path"},this.#i.geometry3DMap.set(a.id,a),i?.interactive!=null&&ce(a,i.interactive,this.#i);let l=this.getParentContainer(o);l instanceof $&&l.addEntity(a);let s=t.geometry.coordinates;if(s){let c=this.convertTo3DMapPosition(s[1],s[0],s[2]??0);this.#t.panBoundsSystem.expandBoundsIfOutside(c)}this.#c(),this.render()}else E.error(`Image with ID '${e}' already exists. The image cannot be added.`);return{id:e,type:"image"}}addModelGroup(e,t,i,{parent:o,onComplete:r}={}){try{Tc(e,t,i)}catch(a){E.error(a);return}if(!this.#i.geometry3DMap.has(e)&&!this.#i.geometry2DMap.has(e)){let a=new le(e);this.#x(a,()=>{this.#c(),this.#u()}),this.#i.geometry3DMap.set(e,a),a.userData.dirty=!0,a.userData.modelURL=i.url;for(let c of t.features){let h=c.id||c.properties.id||kt(),d=this.#t.modelSystem.createModelFromFeature(h,c,{...i});(c.properties.interactive!==void 0||i.interactive!=null)&&ce(d,c.properties.interactive??i.interactive,this.#i),i.clippingPlaneZOffset!=null&&(d.components[7]=new Mo,d.components[7].verticalOffset=i.clippingPlaneZOffset,i.clippingPlaneTopColor!=null&&(d.components[7].topColor=i.clippingPlaneTopColor),i.clippingPlaneTopVisible!=null&&(d.components[7].topVisible=i.clippingPlaneTopVisible)),d.parentId=a.userData.entityId,this.#i.geometry3DMap.set(h,d),a.userData.entities3D.add(h)}let l=this.getParentContainer(o);l instanceof $&&l.addEntity(a);let s=t.features[0]?.geometry.coordinates;if(s){let c=this.convertTo3DMapPosition(s[1],s[0],s[2]??0);this.#t.panBoundsSystem.expandBoundsIfOutside(c)}this.#c(),this.render()?.then(r)}else E.error(`Model group with ID '${e}' already exists. The model group cannot be added.`);return{id:e,type:"feature-collection"}}#z(e,t,i,o){let r=new vn(t,this.convertTo3DMapPosition(e[1],e[0],e[2]||0),o);return r.components[2]=new Yr(i??this.#t.occlusion2DSystem.backgroundId),this.#i.geometry2DMap.set(r.id,r),r}addMarker2D(e,t,i,o){let r=i?.id;if(!this.#i.disableUpdateStateValidation)try{Vs(e,t,i||{})}catch(a){E.error(a);return}if(r===void 0||!this.#i.geometry2DMap.has(r)&&!this.#i.geometry3DMap.has(r)){let a=this.#z(e,new fo(t,i),i?.occluderId,i?.verticalOffset);a.id=r||String(a.id),r=a.id,i?.interactive!=null&&i.interactive!=="pointer-events-auto"&&ce(a,i?.interactive,this.#i),i?.enabled!=null&&Co(a,i.enabled),i?.occlude!=null&&Ln(a,i.occlude);let l=typeof i?.attachTo=="string"||typeof i?.attachTo=="number"?this.#i.geometry3DMap.get(i.attachTo):void 0;l instanceof U&&l.attach(a),this.getParentContainer(o)?.addEntity(a),this.#t.panBoundsSystem.expandBoundsIfOutside(a.object3d.position),this.render()}else E.error(`Marker2D with ID '${r}' already exists. The marker cannot be added.`);return{id:r,type:"marker"}}addText3D(e,t,i,o){if(!this.#i.geometry3DMap.has(e)&&!this.#i.geometry2DMap.has(e)){let r=new St({...t,properties:{...t.properties,id:e,content:t.properties.text}}),a=new U(r,new Ti(i?.appearance));a.id=e,r.mesh.userData.entityId=e.toString(),r.mesh.userData.type="text3d",i.interactive!=null&&ce(a,i.interactive,this.#i),this.#i.geometry3DMap.set(e,a);let l=this.getParentContainer(o);l instanceof $&&l.addEntity(a);let s=t.geometry.coordinates;if(s){let c=this.convertTo3DMapPosition(s[1],s[0],s[2]??0);this.#t.panBoundsSystem.expandBoundsIfOutside(c)}this.#c(),this.render()}else E.error(`Text3D with ID '${e}' already exists. The text3d cannot be added.`);return{id:e,type:"text3d"}}labelText3D(e,t,i={}){try{if(!t||!e)throw new Error("content and meshGeometryId are required");sl.parse(i)}catch(c){E.error(c);return}let o=this.#i.geometry3DMap.get(e);if(o?.type!=="geometry"){E.error(".labelText3D failed: target incorrect");return}let r=o?.components[0],a=!Array.isArray(r.feature)&&r.feature.properties.textArea;if(!a)return;if(r.textEntityId){let c=this.#i.geometry3DMap.get(r.textEntityId);if(c?.type!=="text3d"){E.error(".labelText3D failed: existing text3d not found");return}return{id:c.id,type:c.type}}let l=new St({type:"Feature",geometry:{coordinates:a?.position,type:"Point"},properties:{textArea:a,content:t,id:kt()}});l.polygonEntityId=e;let s=new U(l,new Ti(i?.appearance));return r.textEntityId=s.id.toString(),l.mesh.userData.entityId=s.id.toString(),l.mesh.userData.type="text3d",this.#i.geometry3DMap.set(s.id.toString(),s),i.parentId&&this.getParentContainer(i.parentId)?.addEntity(s),this.#c(),this.render(),{id:s.id,type:"text3d"}}addLabel2D(e,t,i,o){let r=i?.id;if(!this.#i.disableUpdateStateValidation)try{Ws(e,t,i||{})}catch(a){E.error(a);return}if(r===void 0||!this.#i.geometry2DMap.has(r)&&!this.#i.geometry3DMap.has(r)){let a=this.#z(e,new po(t,i||{},this.#i.pixelRatio),i?.occluderId,i?.verticalOffset);a.id=r||String(a.id),r=a.id,i?.interactive!=null&&ce(a,i?.interactive,this.#i),i?.enabled!=null&&Co(a,i.enabled),i?.occlude!=null&&Ln(a,i.occlude);let l=typeof i?.attachTo=="string"||typeof i?.attachTo=="number"?this.#i.geometry3DMap.get(i.attachTo):void 0;l instanceof U&&l.attach(a),this.getParentContainer(o)?.addEntity(a),this.#t.panBoundsSystem.expandBoundsIfOutside(a.object3d.position),this.#u(),this.render()}else E.error(`Label2D with ID '${r}' already exists. The label cannot be added.`);return{id:r,type:"label"}}addPath(e,t={},i){try{vc(e,t||{})}catch(l){E.error(l);return}let o=new Tt(e,Nl(t)),r=new U(o,new Be({color:t?.color??"#ff834c",altitude:t?.verticalOffset??.1}));r.id=t?.id||kt(),o.mesh.userData={entityId:r.id,type:"path"},this.#i.geometry3DMap.set(r.id,r),t?.interactive!=null&&ce(r,t?.interactive,this.#i);let a=this.getParentContainer(i);return a instanceof $&&a.addEntity(r),this.#t.panBoundsSystem.dirty=!0,this.#c(),this.render(),{id:r.id,type:"path"}}updateWatermark(e){this.#t.watermarkSystem.options=e,this.#t.watermarkSystem.dirty=!0,this.#t.twoDEntitySystem.setCollidersDirty(),this.render()}remove(e){let t;if(typeof e=="string"||typeof e=="number"?(t=this.#i.geometry2DMap.get(e),t==null&&(t=this.#i.geometry3DMap.get(e))):typeof e.id=="string"||typeof e.id=="number"?(t=this.#i.geometry2DMap.get(e.id),t==null&&(t=this.#i.geometry3DMap.get(e.id))):t=e,t!=null){if(t.type==="custom-geometry")this.#i.geometry3DMap.delete(t.id),t.object3d&&oe(t.object3d),this.#c();else if(t.type==="group-container"){this.#i.geometry3DMap.delete(t.userData.entityId);for(let i of t.childrenIds.values())this.remove(i),t.userData.entities2D.delete(i);oe(t),this.#c()}else if(t.type==="feature-collection"){this.#i.geometry3DMap.delete(t.userData.entityId);for(let i of t.userData.entities3D.values())this.remove(i),t.userData.entities3D.delete(i);oe(t),this.#c()}else if(t.type==="geometry"||t.type==="model"||t.type==="path"){let i=t.components[0];if(t.entities2D.size>0){for(let r of t.entities2D.values())this.remove(r);t.removeAllEntities()}let o=t.parentObject3D?.userData.entityId??t.parentId;if(o){let r=this.#i.geometry3DMap.get(o);r instanceof le&&r.userData.entities3D.delete(t.id)}if(t.type==="model"){if(this.#t.modelSystem.removeInstance(t)&&t.object3d&&oe(t.object3d),o){let a=this.#i.geometry3DMap.get(o);if(a instanceof le&&a.userData.entities3D.size===0){let l=!1;for(let s of a.children)if(s.children.length>0){let c=s.children[0];if(c.isInstancedMesh&&(c.count??0)>0){l=!0;break}}l||this.remove(o)}}}else t.object3d&&oe(t.object3d);if(t.type==="geometry"){let r=t.components[3];r&&(r.enabled=!1,r.dirty=!0)}"textMesh"in i&&i.textMesh!=null&&this.remove(i.textMesh.userData.entityId),this.#i.geometry3DMap.delete(t.id),this.#c()}else if(t.type==="marker"||t.type==="label"){let i=t.attachedTo;if(i){let o=this.#i.geometry3DMap.get(i);o instanceof U&&o.detach(t)}t.object3d&&oe(t.object3d),t.type==="label"&&this.#t.twoDEntitySystem.deleteTextCacheEntry(t.id),this.#i.geometry2DMap.delete(t.id),this.#u()}else if(t.type==="image")t.object3d&&oe(t.object3d),this.#i.geometry3DMap.delete(t.id),this.#c();else if(t.type==="text3d"){oe(t.object3d);let{batchedText:i,textMesh:o,polygonEntityId:r}=t.components[0];if(o&&(i&&i.removeText(o),oe(o)),r){this.#t.text3DSystem.remove(r);let a=this.#i.geometry3DMap.get(r);a?.type==="geometry"&&(a.components[0].textMesh=void 0,a.components[0].textEntityId=void 0)}this.#i.geometry3DMap.delete(t.id),this.#c()}this.render()}}showCollisionBoxes=()=>{this.#t.twoDEntitySystem.showCollisionBoxes(),this.render()};hideCollisionBoxes=()=>{this.#t.twoDEntitySystem.hideCollisionBoxes(),this.render()};getScene(){return this.getState("__scene")}getThreeScene(){return this.#e}getThreeCamera(){return this.#o}async setEnvironment(e){if(this.#e)if(e==="basic"){this.#n||(this.#n=this.#j());let t=await this.#n;this.#e.environment=t}else this.#e.environment=null}getEnvironment(){return this.#e?.environment?"basic":!1}getCurrentSceneGLTF(e){return this.#t.exporterSystem.getCurrentSceneGLTF(e)}getBoundingArea(e){(this.#t.renderSystem.threeDdirty||this.#t.renderSystem.twoDdirty)&&this.renderSync();let t=new eu;if(e==null)t.setFromObject(this.#i.geometryScene);else{let i=tt(this.#i,e);if(i?.type==="geometry"&&i?.object3d!=null){let o=i.components[0],r=o instanceof Y?o.geometry:void 0;o.mesh instanceof jb&&r?(r.computeBoundingBox(),r.boundingBox&&t.union(r.boundingBox)):t.setFromObject(i.object3d)}else(i?.type==="feature-collection"||i?.type==="group-container")&&i?.userData.entityId!=null&&t.setFromObject(i)}if(Ut(t))return Ys(t).map(this.convert3DMapPositionToCoordinate)}hasState(e){return tt(this.#i,e)!=null}getState(e){if(e==null)return{type:"map-view",hoverColor:this.#i.hoverColor,text3dHoverColor:this.#i.text3dHoverColor};let t=tt(this.#i,e);if(t?.type==="custom-geometry"){let i=t.components[0],o=t.components[1];return{id:t.id,type:"custom-geometry",visible:o.visible,altitude:o.altitude,parent:t.parentObject3D?.userData.entityId,position:this.convert3DMapPositionToCoordinate(i.position)}}else if(t?.type==="feature-collection"){let i=Array.from(t.userData.entities3D.values()),o=i?.[0],r=o?this.getState(o):{},a=this.#i,l=this.convert3DMapPositionToCoordinate;return{id:t.userData.entityId,type:"feature-collection",initialColor:r?.initialColor,color:r?.color,hoverColor:r?.hoverColor,side:r?.side??"double",opacity:r?.opacity,height:r?.height,texture:r?.texture,topColor:r?.topColor,topTexture:r?.topTexture,visible:t.visible,altitude:t.position.z,interactive:Zl(t,this.#i),children:i,bevel:r?.bevel,visibleThroughGeometry:r?.visibleThroughGeometry??!1,maskId:t.components[0]?.maskId,maskEnabled:t.components[0]?.enabled,maskEffect:t.components[0]?.effect,maskMode:t.components[0]?.mode,get position(){return jl(t,a,l)}}}else if(t?.type==="group-container"){let i,o=t.childrenIds,r=a=>this.getState(a);return{id:t.userData.entityId,type:"group-container",visible:t.visible,altitude:t.position.z,opacity:t.opacity,interactive:!!t.components[0],get children(){return i??=Array.from(o.values()).map(r).filter(Boolean)}}}else if(t?.type==="label"){let i=t.components[0],o=t.object3d.parent,r=o?.userData.entityId;return{id:t.id,type:"label",text:i.text||"",parent:{id:r,type:o?.type},position:this.convert3DMapPositionToCoordinate(t.position),enabled:i.enabled,visible:i.visible,initialRank:vi(i.initialRank),verticalOffset:t.verticalOffset,options:{rank:vi(i.rank),appearance:i.appearance,interactive:t.components[1]!=null,verticalOffset:t.verticalOffset,attachTo:t.attachedTo,occlude:t.components[2]?.enabled??!1}}}else if(t?.type==="marker"){let i=t.components[0],o=t.object3d.parent,r=o?.userData.entityId;return{id:t.id,type:"marker",enabled:i.enabled,visible:i.visible,placement:i.options.placement,dynamicResize:i.options.dynamicResize,parent:{id:r,type:o?.type},position:this.convert3DMapPositionToCoordinate(t.position),element:i.containerEl,initialRank:vi(i.initialRank),contentHTML:i.contentHtml,options:{rank:vi(i.rank),interactive:t.components[1]!=null||!1,verticalOffset:t.verticalOffset,attachTo:t.attachedTo,lowPriorityPin:i.options.lowPriorityPin,occlude:t.components[2]?.enabled??!1,zIndex:i.options.zIndex,animated:i.options.animated}}}else if(t?.type==="geometry"){let{color:i,hoverColor:o,initialColor:r,initialTopColor:a,topColor:l,altitude:s}=t.components[1],c=t.components[0],h=t.components[4],d=t.components[1],u=t.components[6],m=t.components[2],v=t.components[3],b=t.parentObject3D,p=c.position,x=p.x,f=p.y,y=p.z,C=this.#N,M;return{id:t.id,type:"geometry",opacity:d.opacity,initialColor:r,color:i,focusable:h!=null&&h.vertices!=null&&h.vertices.length>0,initialTopColor:a,topColor:l,side:d.side,hoverColor:o,hovered:!!m?.hover,height:d.height,visible:d.visible,outline:v?.enabled,showImage:d.showImage,texture:u?.texture?.path,topTexture:u?.topTexture?.path,flipImageToFaceCamera:d.flipImageToFaceCamera,enableImageCollisions:d.enableImageCollisions,parent:{id:b?.userData.entityId,type:b?.type},altitude:s,bevel:d.bevel,visibleThroughGeometry:d.visibleThroughGeometry,slope:d.slope,slopeEnabled:d.slopeEnabled,get position(){return M??=C(x,f,y)},interactive:c.pointerEventsPassThrough?"pass-through":t.components[2]!=null,borderVisible:d.borderVisible,borderColor:d.borderColor,borderWidth:d.borderWidth}}else if(t?.type==="model"){let i=t.components[0],o=t.components[1],r=t.components[2],a=t.components[7],l=i.feature.geometry.coordinates,s=[l[0],l[1],l[2]??0];return{id:t.id,type:"model",position:s,interactive:r!=null,material:o.material,parent:t.parentObject3D?.parent?{id:t.parentObject3D.parent.userData.entityId,type:t.parentObject3D.parent.type}:void 0,visible:o.visible,verticalOffset:o.verticalOffset,color:o.color,opacity:o.opacity,castShadow:o.castShadow,receiveShadow:o.receiveShadow,clippingEnabled:o.clippingEnabled,rotation:o.rotation??rt,scale:o.scale??ot,clippingPlaneZOffset:a?.verticalOffset??o.clippingPlaneZOffset,clippingPlaneTopColor:a?.topColor??o.clippingPlaneTopColor,clippingPlaneTopVisible:a?.topVisible??o.clippingPlaneTopVisible}}else if(t?.type==="path"){let i=t.components[0],o=t.components[2],r=t.components[1];return{id:t.id,type:"path",position:this.convert3DMapPositionToCoordinate(i.position),visible:r.visible,interactive:o!=null,completeFraction:i.completeFraction,color:r.color,accentColor:i.accentColor,width:i.width,animateArrowsOnPath:i.animateArrowsOnPath,displayArrowsOnPath:i.displayArrowsOnPath,verticalOffset:r.altitude,highlightCompleteFraction:i.highlightCompleteFraction,highlightStartFraction:i.highlightStartFraction,highlightEndFraction:i.highlightEndFraction,highlightColor:i.highlightColor,highlightWidthMultiplier:i.highlightWidthMultiplier,highlightDisplayArrowsOnPath:i.highlightDisplayArrowsOnPath,travelledEndFraction:i.travelledEndFraction,travelledColor:i.travelledColor,xrayOpacity:i.xrayOpacity,xrayStyle:i.xrayStyle,smoothingTension:i.smoothingTension,smoothingCornerRadius:i.smoothingCornerRadius,dashed:i.dashed,dashDiscrete:i.dashDiscrete,dashedMask:i.dashedMask,dashCornerRadius:i.dashCornerRadius,dashLength:i.dashLength,dashGap:i.dashGap,dashRelativeToWidth:i.dashRelativeToWidth,dashSize:i.dashSize,gapSize:i.gapSize,dashAbsolute:i.dashAbsolute,dashMeters:i.dashMeters,gapMeters:i.gapMeters,geometryType:i.geometryType,endcapExtension:i.endcapExtension,billboarding:i.billboarding,border:i.border}}else if(t?.type==="image"){let i=t.components[0],o=t.components[2];return{id:t.id,type:"image",position:this.convert3DMapPositionToCoordinate(i.position),visible:t.components[1].visible,verticalOffset:i.feature.properties.verticalOffset??0,opacity:t.components[1].opacity,flipImageToFaceCamera:t.components[1].flipImageToFaceCamera,width:i.feature.properties.width??0,height:i.feature.properties.height??0,rotation:i.feature.properties.rotation??0,interactive:o!=null}}else if(t?.type==="text3d"&&t.components[0]instanceof St){Ul(t);let i=t.components[0],o=t.components[1],{textMesh:r}=i,a=i.feature.properties,l=i.mesh?.parent;l instanceof $&&l.children.find(u=>u.type==="batchedtext")?.getWorldPosition(this.#Z),this.#H.set(0,0,0);let s=r?r.getWorldPosition(this.#H):this.#H,c=a.rotation??a.textArea?.rotation??0,h=a.content??a.text??"";return Object.assign({},je,o.getState(),{id:t.id,type:"text3d",position:this.convert3DMapPositionToCoordinate(s.add(this.#Z)),visible:i.visible??!1,content:h,rotation:c})}else return}getRenderedState(e){let t=typeof e=="string"||typeof e=="number"?e:e.id,i=tt(this.#i,t);if(i&&i.type==="label")return{textVisible:i.components[0].textVisible}}setState(e,t){if(typeof e=="object"&&t==null){"hoverColor"in e&&(Gs(e.hoverColor)?this.#i.hoverColor=e.hoverColor??this.#i.hoverColor:E.warn(`Failed to update global hover color. Invalid color "${e.hoverColor}".`)),"text3dHoverColor"in e&&(this.#i.text3dHoverColor=e.text3dHoverColor??this.#i.text3dHoverColor);return}let i=tt(this.#i,e);if(i!=null){if(i.type==="custom-geometry"){let o=this.#i.geometry3DMap.get(i.id);if(o instanceof U&&o.components[0]instanceof Qt){let r=t;Ct(i,this.#i,r.visible),Pi(i,this.#i,r.altitude),On(i,r.position,this.convertTo3DMapPosition,this.#t.panBoundsSystem),In(i,this.getParentContainer(r.parent,!1)),ce(i,r.interactive,this.#i)&&this.#c()}}else if(i.type==="path"){let o=t;ce(i,o.interactive,this.#i)&&this.#c(),Pi(i,this.#i,o.verticalOffset),zl(i,this.#i,o)}else if(i.type==="model"){let o=t;ce(i,o.interactive,this.#i)&&(this.#c(),this.#t.interactionSystem.dirty3D=!0),Ct(i,this.#i,o.visible),Wl(i,o,this.convertTo3DMapPosition,this.#t.panBoundsSystem),Vl(i,o)}else if(i.type==="group-container"){let o=t;Ct(i,this.#i,o.visible)&&(this.#t.pathSystem.verticalDistanceDirty=!0,this.#t.geometryInFocusSystem.focusablesDirty=!0),Pi(i,this.#i,o.altitude)&&(this.#t.pathSystem.verticalDistanceDirty=!0),ce(i,o.interactive,this.#i)&&this.#c(),Do(i,this.#i,o.opacity)&&(this.#t.outlineInterpolationSystem.outlineOpacitiesDirty=!0),o.preloadGeometry&&i.userData.preloadGeometry!==!0&&(i.userData.preloadGeometry=!0,this.#t.outlineInterpolationSystem.geometries3DDirty=!0),wo(i,o.focusable)&&(this.#t.geometryInFocusSystem.focusablesDirty=!0)}else if(i.type==="feature-collection"){let o=t;o.visible!==void 0&&i.visible!==o.visible&&(i.visible=o.visible,this.#c()),o.altitude!==void 0&&i.position.z!==o.altitude&&(i.position.z=o.altitude,this.#c()),vl(i,this.#i,o),Ol(i,this.#i,o.hoverColor),Bn(i,this.#i,o.outline),o.height!=null&&Pn(i,this.#i,o.height)&&this.#t.shadowsSystem?.castersChanged(),o.heightScale!=null&&Dl(i,this.#i,o.heightScale)&&this.#t.shadowsSystem?.castersChanged(),Rn(i,this.#i,o)&&(this.#t.textureSystem.dirty=!0),Rn(i,this.#i,o),xl(i,this.#i,o.shading),Do(i,this.#i,o.opacity)&&(this.#t.outlineInterpolationSystem.outlineOpacitiesDirty=!0),ce(i,o.interactive,this.#i)&&(this.#c(),this.#u(),this.#t.interactionSystem.dirty3D=!0),Fn(i,this.#i,o.side),_n(i,{maskId:o.maskId,enabled:o.maskEnabled,effect:o.maskEffect,mode:o.maskMode}),Ml(i,this.#i,o.visibleThroughGeometry)&&(this.#t.meshDetachmentSystem.dirty=!0),Rl(i,this.#i,{effectStart:o.effectStart,effectDistance:o.effectDistance,darkenAmount:o.darkenAmount,darkenUseDepth:o.darkenUseDepth,desaturateAmount:o.desaturateAmount,desaturateUseDepth:o.desaturateUseDepth,washOutAmount:o.washOutAmount,washOutUseDepth:o.washOutUseDepth}),o.position!=null&&(i.userData.centroid=[o.position[0],o.position[1]],i.userData.positionDirty=!0)}else if(i.type==="geometry"){if(i.components[0]instanceof Y){let o=t;if(Ct(i,this.#i,o.visible)&&this.#c(),Bn(i,this.#i,o.outline),Cl(i,o),wo(i,o.focusable)&&(this.#t.geometryInFocusSystem.focusablesDirty=!0),Bl(i,o.renderOrder)&&(this.#t.meshDetachmentSystem.dirty=!0),_l(i,o.opacity)&&(this.#t.meshDetachmentSystem.dirty=!0,this.#t.interactionSystem.dirty3D=!0,this.#t.outlineInterpolationSystem.outlineOpacitiesDirty=!0),An(i,o.flipImageToFaceCamera),Ll(i,o.enableImageCollisions),Pi(i,this.#i,o.altitude)){let r=i.components[1],a=(r.altitude??0)+(r.height??0);this.#t.panBoundsSystem.expandBoundsIfOutside(new Ye(0,0,a)),this.#t.shadowsSystem&&this.#t.shadowsSystem.castersChanged()}if(o.height!=null&&Pn(i,this.#i,o.height)){let r=i.components[1],a=(r.altitude??0)+(r.height??0);this.#t.panBoundsSystem.expandBoundsIfOutside(new Ye(0,0,a)),this.#t.shadowsSystem&&this.#t.shadowsSystem.castersChanged()}Al(i,o)&&(this.#t.meshDetachmentSystem.dirty=!0,this.#t.textureSystem.dirty=!0),wl(i,o,this.#i.outlinesOptions?.darkenFactor),Pl(i,o.hoverColor),ce(i,o.interactive,this.#i)&&(this.#t.interactionSystem.dirty3D=!0),Il(i,o.hovered),Fn(i,this.#i,o.side),Fl(i,o.slope),Gl(i,o.slopeEnabled),kl(i,o),Sl(i,o.visibleThroughGeometry)&&(this.#t.meshDetachmentSystem.dirty=!0)}}else if(i.type==="label"||i.type==="marker"){let o=t;El(i,o,this.#i),Tl(i,o,this.#i)&&(this.#u(),this.#t.twoDEntitySystem.markDirty()),On(i,o.position,this.convertTo3DMapPosition,this.#t.panBoundsSystem),In(i,this.getParentContainer(o.parent,!1))&&(this.#u(),this.#t.panBoundsSystem.dirty=!0),Co(i,o.enabled),Ct(i,this.#i,o.visible)}else if(i.type==="image"){let o=t;Ct(i,this.#i,o.visible),Do(i,this.#i,o.opacity),An(i,o.flipImageToFaceCamera),ce(i,o.interactive,this.#i)&&this.#c();let r=i.components[0];if(r instanceof ei){if(o.position!=null){r.feature.geometry.coordinates=o.position;let a=this.convertTo3DMapPosition(o.position);if(r.imageMesh){let l=r.imageMesh.position.z;r.imageMesh.position.set(a.x,a.y,l),r.position.copy(r.imageMesh.position)}this.#t.panBoundsSystem.expandBoundsIfOutside(a)}if(o.verticalOffset!=null&&(r.feature.properties.verticalOffset=o.verticalOffset,r.imageMesh&&(r.imageMesh.position.z=o.verticalOffset+ti,r.position.copy(r.imageMesh.position))),o.rotation!=null&&(r.feature.properties.rotation=o.rotation,r.imageMesh&&(r.imageMesh.rotation.z=(-us.degToRad(o.rotation)+Math.PI*2)%(Math.PI*2))),o.width!=null||o.height!=null){let a=o.width??r.feature.properties.width,l=o.height??r.feature.properties.height;r.feature.properties.width=a,r.feature.properties.height=l,r.imageMesh&&(r.imageMesh.geometry.dispose(),r.imageMesh.geometry=new Kd(a,l))}}}else if(i.type==="text3d"){let o=t;Hl(i,this.#i,o,this.convertTo3DMapPosition,()=>this.render())}this.render()}}projectScreenXYToCoordinate=(e,t,i=!1)=>{let o=this.container.getBoundingClientRect(),r=(e-o.left)/this.#i.canvasWidth*2-1,a=-((t-o.top)/this.#i.canvasHeight)*2+1,l=new ds(r,a),s,c;if(i?(tu.setFromCamera(l,this.#o),s=tu.intersectObject(this.#s,!1)[0]?.point):(s=this.#t.interactionSystem.getThreeDIntersectsFromXY(l)?.[0]?.point,c=this.#t.interactionSystem.getGroupContainerIntersectsFromXY(l)),s)return{coordinate:this.convert3DMapPositionToCoordinate(s),groupContainers:c}};projectCoordinateToScreenXY=e=>{let t=this.convertTo3DMapPosition(e[1],e[0],e[2]||0),i=new ds;return this.project(i,t),{x:i.x,y:i.y}};convertTo3DMapPosition(e,t,i=0,o){if(Array.isArray(e))return this.convertTo3DMapPosition(e[1],e[0],e[2]??i,typeof t=="function"?t:void 0);if(typeof t!="number")throw new Error("convertTo3DMapPosition failed: longitude must be a number");let{x:r,y:a}=Ci(this.#i.center?.[1]??0,this.#i.center?.[0]??0,e,t);return o?(o.set(r,a,i),o):new Ye(r,a,i)}convert3DMapPositionToCoordinate=e=>this.#N(e.x,e.y,e.z);#N=(e,t,i)=>{let{lat:o,lon:r}=Mi(this.#i.center?.[1]??0,this.#i.center?.[0]??0,e,t);return[r,o,i]};getVisible(e){let t=tt(this.#i,e);if(t!=null)switch(t.type){case"group-container":case"feature-collection":return t.visible;case"label":case"marker":return t.components[0].visible;case"text3d":return t.components[0].visible??!1;default:return t.components[1]?.visible}}#k=(e,t)=>{let i=e.entity3D?[e.entity3D.id]:[];e.entity3D?.parentObject3D?.userData?.entityId&&i.push(e.entity3D.parentObject3D.userData.entityId);let o=[],r=[];for(let s of e.entity2D)s.components&&(s.components[0]instanceof fo?o.push(s.id):s.components[0]instanceof po&&r.push(s.id));let a=e.entity3D?.components[0],l=e.entity3D?.id;return{coordinate:this.convert3DMapPositionToCoordinate(t),geometry:i,paths:a instanceof Tt&&l!==void 0?[l]:[],markers:o,models:a instanceof Et&&l!==void 0?[l]:[],images:a instanceof ei&&l!==void 0?[l]:[],text3ds:a instanceof St&&l!==void 0?[l]:[],labels:r,containers:Array.isArray(e.groupContainers)?e.groupContainers.map(s=>s.userData.entityId):[]}};setBackgroundColor=(e,t)=>{this.#d.setBackgroundColor(e,t)};get backgroundColor(){return typeof this.#d.backgroundColor=="string"?this.#d.backgroundColor:`#${this.#d.backgroundColor.getHexString()}`}get backgroundAlpha(){return this.#d.backgroundAlpha}getThreeRenderer(){return this.#d}getMetersPerPixel=()=>this.#t.cameraSystem.getCurrentMetersPerPixel();hideOutdoorLayersIntersectingPolygons=(e,t)=>{this.#t.outdoorLayersSystem.hideLayersIntersectingPolygons(e,t),this.render()};getCenter(e){let t=Array.isArray(e)?e:this.getBoundingArea(e);return t?tl(t):void 0}#D=new Wb;#O=new Vb;isInView(e){let t=tt(this.#i,e);if(this.#O.identity().multiply(this.#o.projectionMatrix).multiply(this.#o.matrixWorldInverse),this.#D.setFromProjectionMatrix(this.#O),t instanceof vn)return this.#D.containsPoint(t.position);if(t instanceof U){let i=t?.components[0];if(i instanceof Qt||i instanceof Et)return this.#D.containsPoint(this.convertTo3DMapPosition(i.feature.geometry.coordinates));if(i instanceof Y){let o=new eu(this.convertTo3DMapPosition(i.featureBbox[1],i.featureBbox[0],0),this.convertTo3DMapPosition(i.featureBbox[3],i.featureBbox[2],0));return this.#D.intersectsBox(o)}}return!1}queryGeometry2DInView(e){let{screenOffsets:t,fullyContains:i}=e??{},[o,r,a,l]=rl(this.container,t),s=new et(o,r,a,l);return this.#t.twoDEntitySystem.visibleCollidersQTree.queryRect(s).filter(u=>i?s.contains(u):s.intersects(u)).map(u=>this.#i.geometry2DMap.get(u.userData.entityId)).filter(u=>u!=null).filter(u=>u.components[0]instanceof po||u.components[0]instanceof fo).map(u=>u.id.toString())}#V=e=>{E.error("Render failed: ",e,e.stack??"No stack trace available"),this.publish("render-error",{error:e})};render=()=>{if(!(this.#t?.renderSystem==null||this.signal?.aborted))if(this.map&&(this.mode==="outdoors-interleaved"||this.mode==="outdoors-overlay"))this.map.triggerRepaint();else return this.#t.renderSystem.update().catch(this.#V)};renderSync=()=>this.signal?.aborted?Promise.resolve():this.#t.renderSystem.update(!0).catch(this.#V);#A=Je(()=>{this.publish("user-interaction-start",void 0)},0,!0);#R=Je(()=>{this.publish("user-interaction-end",void 0),this.render()},0,!0);onMapLibreEvent(e,t){if(!this.map){E.warn(`Tried to add event listener "${e}" but MapLibre map is not initialized.`);return}let i=this.map.on(e,t);i?.unsubscribe&&this.onAbort(()=>i.unsubscribe())}offMapLibreEvent(e,t){this.map&&this.map.off(e,t)}getSystems(){return this.#t}getInternalState(){return this.#i}getInternalTweenGroup(){return this.#i.internalTweenGroup}getExternalTweenGroup(){return this.#i.externalTweenGroup}async#j(){return lt.load($l).then(e=>(this.#e&&(this.#e.environment?.dispose(),e.mapping=Zb,this.#e.environment=e,this.render()),e))}computeMinZOffsetBetweenContainers(e,t,i){if(!e||!t)return-1;kn(e,"group-container"),kn(t,"group-container"),e.updateMatrixWorld(!0),t.updateMatrixWorld(!0);let o=bo(e,this.getThreeCamera()),r=t.clone(!0);wi(r,!0),r.updateMatrixWorld();let a=bo(r,this.getThreeCamera());if(!Ut(o)||!Ut(a))return-1;let l=0,s;i&&this.container.querySelectorAll(".debug-box").forEach(h=>h.remove());do{if(l>1e4)return-1;if(l+=20,r.setAltitude(l),a.makeEmpty(),bo(r,this.#o,a),s=o.intersectsBox(a),i){let c=Dn(o,"blue",this.container),h=Dn(a,s?"red":"green",this.container);c.classList.add("debug-box"),h.classList.add("debug-box")}}while(s);return l}on=(e,t,i)=>{let o=super.on(e,t,i);return["outdoor-view-loaded","outdoor-style-loaded"].includes(e)&&this.mode==="standalone"&&D.env.NODE_ENV!=="test"&&(He()||E.warn(`"${e}" was subscribed to but outdoor view is disabled. The event has been triggered immediately. Enable outdoor view or remove the listener.`),this.publish(e),o()),o};off=(e,t)=>{super.off(e,t)};getCursor=()=>this.#t.interactionSystem.getCursor();#$=()=>{try{this.#f!=="outdoors-overlay"&&(this.map&&this.map.remove(),this.container&&this.rendererDomElement&&this.container.contains(this.rendererDomElement)&&this.container.removeChild(this.rendererDomElement))}catch(e){E.warn("Error during DOM cleanup, some elements may not have been removed:",e)}};#m=e=>(this.onAbort(()=>{e&&typeof e=="object"&&("destroy"in e&&typeof e.destroy=="function"?e.destroy():"dispose"in e&&typeof e.dispose=="function"&&e.dispose())}),e);destroy=()=>{!this.#t||this.signal?.aborted||(super.destroy(),globalThis.MappedinDebug?.__idleCallbackInteractionState&&(globalThis.MappedinDebug.__idleCallbackInteractionState.unregisterInteractionChecker(this.#t.cameraSystem.isUserInteracting),globalThis.MappedinDebug.__idleCallbackInteractionState.unregisterInteractionChecker(this.#t.cameraSystem.isCameraMoving)),this.remove("__scene"),this.#d.destroy(),this.#e?.traverse(e=>{oe(e),"dispose"in e&&typeof e.dispose=="function"&&e.dispose()}),this.#e=void 0,this.#t=void 0,this.#$(),this.#d=void 0)};#H=new Ye;#Z=new Ye;#U=0;#W=!1;#q=new Float64Array(6).fill(Number.NaN);#K=()=>{if(this.#U>0){this.#W=!0;return}this.#X()};#X(){this.#Y(!1),this.#t.geometryInFocusSystem&&(this.#t.geometryInFocusSystem.cameraDirty=!0),this.render()}#Y(e){let t=this.#t.cameraSystem,i=this.#q,o=t.orbit,r=o.position.x,a=o.position.y,l=o.position.z,s=t.camera.position.z,c=o.rotation.z,h=t.getTilt();!e&&i[0]===r&&i[1]===a&&i[2]===l&&i[3]===s&&i[4]===c&&i[5]===h||(i[0]=r,i[1]=a,i[2]=l,i[3]=s,i[4]=c,i[5]=h,this.publish("camera-change",this.camera))}batchCameraChanges(e){this.#U++;try{e()}finally{this.#U--,this.#U===0&&this.#W&&(this.#W=!1,!this.signal?.aborted&&this.#t?.cameraSystem&&this.#X())}}},mt=ms;g();var qb=5,Kb=2e3;function iu({refreshOutdoorToken:n,headers:e,reloadSource:t,maxAttempts:i=qb,backoffMs:o=Kb,now:r=()=>Date.now()}){let a=!1,l=0,s=0,c,h=v=>{if(v)try{t(v)}catch(b){E.warn("Failed to reload outdoor source after token refresh:",b)}},d=v=>{l+=1,!(l>=i||c!==void 0)&&(c=setTimeout(()=>{c=void 0,u(v)},o))},u=async v=>{if(a||l>=i||c!==void 0)return;let b=r();if(!(b-s<o)){a=!0,s=b;try{let p=await n();if(!p||p===e["x-mappedin-tiles-key"]){d(v);return}e["x-mappedin-tiles-key"]=p,l=0,h(v)}catch(p){E.warn("Failed to refresh outdoor tiles token:",p),d(v)}finally{a=!1}}};return{recoverFromTileAuthError:u,dispose:()=>{c!==void 0&&(clearTimeout(c),c=void 0)}}}g();import{MathUtils as ou}from"three";function ru(n,e){let{cameraSystem:t}=n.getSystems(),i={center:e.getCenter().toArray(),zoom:e.getZoom(),bearing:e.getBearing(),pitch:e.getPitch(),elevation:e.getCenterElevation()},o=!1;e.transformCameraUpdate=({center:a})=>{let l=t.clampCenterToPanBounds(a.lng,a.lat);if(!l)return{};let s=a.constructor;return{center:new s(l[0],l[1])}},n.on("camera-change",a=>{if(!o){i.center=a.center,i.zoom=a.zoomLevel,i.bearing=a.bearing,i.pitch=a.pitch,i.elevation=a.elevation,o=!0;try{e.jumpTo(i)}finally{o=!1}}}),n.onMapLibreEvent("move",()=>{if(!o){o=!0;try{typeof n.batchCameraChanges=="function"?n.batchCameraChanges(r):r()}finally{o=!1}}});function r(){let a=e.getCenter();t.setCenter(a.lng,a.lat),t.setZoomLevel(e.getZoom()),t.setRotation(ou.degToRad(e.getBearing())),t.setTilt(ou.degToRad(e.getPitch())),t.setPedestal(Math.min(e.getCenterElevation(),t.maxPedestal),!0)}n.onMapLibreEvent("movestart",()=>{o||t.beginGesture()}),n.onMapLibreEvent("moveend",()=>{o||t.endGesture()})}g();var Jb=Object.freeze({decelerationRate:.9931,zoomDecelerationRate:.993,bearingDecelerationRate:.994,velocityWindowMs:80,restGraceMs:40,restCutoffMs:100,minPanVelocity:.05,maxPanVelocity:8,panStopVelocity:.015,maxZoomVelocity:.006,zoomStopVelocity:2e-4,maxBearingVelocity:.3,bearingStopVelocity:.005}),nu=512;function ys(n,e){let t=(180+n)/360,i=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e*Math.PI/360)))/360;return[t,i]}function Qb(n,e){let t=n*360-180,i=360/Math.PI*Math.atan(Math.exp((180-e*360)*Math.PI/180))-90;return[t,i]}function pt(n,e){let t=n.length,i=0,o=0;for(let l=0;l<t;l++)i+=n[l],o+=e[l];i/=t,o/=t;let r=0,a=0;for(let l=0;l<t;l++){let s=n[l]-i;r+=s*(e[l]-o),a+=s*s}return a>0?r/a:0}function ev(n,e){return((e-n)%360+540)%360-180}function tv(n,e,t,i){if(n.length<2)return;let o=n[n.length-1],r=Math.max(0,e-o.time);if(r>=t.restCutoffMs)return;let a=r<=t.restGraceMs?1:1-(r-t.restGraceMs)/(t.restCutoffMs-t.restGraceMs),l=[],s=[],c=[],h=[],d=[],u=[],m=[],v=0,b,p=n.length-1;for(;p>0&&o.time-n[p-1].time<=t.velocityWindowMs&&(n[p-1].touches??0)===(o.touches??0);)p--;for(let T=p;T<n.length;T++){let w=n[T];v+=b===void 0?0:ev(b,w.bearing),b=w.bearing,l.push(w.time),s.push(w.x),c.push(w.y),h.push(w.sx??NaN),d.push(w.sy??NaN),u.push(w.zoom),m.push(v)}if(l.length<2||l[l.length-1]===l[0])return;let x,f,y=nu*Math.pow(2,o.zoom);if(Math.hypot(pt(l,s),pt(l,c))*y<t.minPanVelocity)x=0,f=0;else if(i&&o.sx!=null&&o.sy!=null&&h.every(Number.isFinite)){let T=pt(l,h),w=pt(l,d),P=.5,[L,N]=i(o.sx+T*P,o.sy+w*P),[A,G]=i(o.sx-T*P,o.sy-w*P);x=(A-L)/(2*P)*a,f=(G-N)/(2*P)*a}else x=pt(l,s)*a,f=pt(l,c)*a;let M=Math.hypot(x,f)*y;!Number.isFinite(M)||M<t.minPanVelocity?(x=0,f=0):M>t.maxPanVelocity&&(x*=t.maxPanVelocity/M,f*=t.maxPanVelocity/M);let S=(T,w)=>Math.max(-w,Math.min(w,T));return{x,y:f,zoom:S(pt(l,u)*a,t.maxZoomVelocity),bearing:S(pt(l,m)*a,t.maxBearingVelocity)}}function iv(n,e,t){let i=(u,m,v)=>{let b=Math.log(v),p=u>m?Math.log(m/u)/b:0,x=p>0?(1-Math.pow(v,p))/-b:0;return{duration:p,travel:x,rate:v}},o=nu*Math.pow(2,e),r=i(Math.hypot(n.x,n.y)*o,t.panStopVelocity,t.decelerationRate),a=i(Math.abs(n.zoom),t.zoomStopVelocity,t.zoomDecelerationRate),l=i(Math.abs(n.bearing),t.bearingStopVelocity,t.bearingDecelerationRate),s=r;a.duration>s.duration&&(s=a),l.duration>s.duration&&(s=l);let c=s.duration;if(!(c>0))return;let h=Math.pow(s.rate,c);return{duration:c,easing:u=>(1-Math.pow(s.rate,u*c))/(1-h),x:n.x*r.travel,y:n.y*r.travel,zoom:n.zoom*a.travel,bearing:n.bearing*l.travel}}function bs(n){return n==null?!1:n.type.startsWith("touch")||n.type.startsWith("mouse")||n.type.startsWith("pointer")}function ov(n,e){if("touches"in n){let t=n.touches.length>0?n.touches:n.changedTouches;if(t.length===0)return;let i=0,o=0;for(let r=0;r<t.length;r++)i+=t[r].clientX,o+=t[r].clientY;return[i/t.length-e.left,o/t.length-e.top]}return[n.clientX-e.left,n.clientY-e.top]}var rv=32;function au(n){let e=Jb,t=[],i,o=!1,r,a=()=>n.dragPan.isActive()||n.dragRotate.isActive()||n.touchZoomRotate.isActive()||n.touchPitch.isActive(),l=(v,b)=>{let p=n.unproject([v,b]);return ys(p.lng,p.lat)},s=()=>{t.length=0,i=void 0,r=void 0},c=v=>{let b=v.originalEvent;if(!bs(b))return;r??=n.getCanvasContainer().getBoundingClientRect(),i=ov(b,r)??i;let p=n.getCenter(),[x,f]=ys(p.lng,p.lat),y="touches"in b?b.touches.length:0;t.push({time:b.timeStamp,x,y:f,zoom:n.getZoom(),bearing:n.getBearing(),touches:y,sx:i?.[0],sy:i?.[1]}),t.length>rv&&t.shift()},h=v=>{if(o=!1,a())return;let b=tv(t,v,e,l),p=(t[t.length-1]?.touches??0)>1,x=i;s();let f=n.getZoom(),y=b&&iv(b,f,e);if(n.stop(),y==null)return;let C=n.getBearing()+Math.max(-179,Math.min(179,y.bearing));if(p&&(y.zoom!==0||y.bearing!==0)){n.easeTo({zoom:f+y.zoom,bearing:C,around:x?n.unproject(x):void 0,duration:y.duration,easing:y.easing});return}let M={duration:y.duration,easing:y.easing};if(y.x!==0||y.y!==0){let S=n.getCenter(),[T,w]=ys(S.lng,S.lat);M.center=Qb(T+y.x,w+y.y)}y.bearing!==0&&(M.bearing=C),y.zoom!==0&&(M.zoom=f+y.zoom),!(M.center==null&&M.bearing==null&&M.zoom==null)&&n.easeTo(M)},d=v=>{let b=v.originalEvent;if(!bs(b)||t.length===0||o)return;o=!0;let p=b.timeStamp;queueMicrotask(()=>h(p))},u=v=>{bs(v.originalEvent)&&s()},m=["dragend","zoomend","rotateend","pitchend"];n.on("movestart",u),n.on("move",c);for(let v of m)n.on(v,d);return()=>{n.off("movestart",u),n.off("move",c);for(let v of m)n.off(v,d)}}g();function nv(n,e){av(n,e)(n.getScene(),e),sv(n,e),e.addFolder("Export").add({export:async()=>{let a=await n.getCurrentSceneGLTF({binary:!0}),l=new Blob([a],{type:"application/octet-stream"});var s=document.createElement("a");document.body.appendChild(s),s.style.display="none";let c=window.URL.createObjectURL(l);s.href=c,s.download="scene.glb",s.click(),window.URL.revokeObjectURL(c)}},"export");let o=e.addFolder("Camera"),r={get bearing(){return n.camera.bearing},set bearing(a){n.camera.setBearing(a)},get pitch(){return n.camera.pitch},set pitch(a){n.camera.setPitch(a)},get zoomLevel(){return n.camera.zoomLevel},set zoomLevel(a){n.camera.setZoomLevel(a)}};o.add(r,"bearing",-359,359,1),o.add(r,"pitch",n.camera.minPitch,n.camera.maxPitch,1),o.add(r,"zoomLevel",n.camera.minZoomLevel,n.camera.maxZoomLevel,.1)}function av(n,e){let t=e;return function i(o,r){let a=r.addFolder(`${[o.type]} ${o.id.slice(0,16)}`);if(r.close(),o.type==="geometry"||o.type==="model"||o.type==="path"||o.type==="image"){let l={get height(){let s=n.getState(o.id);return s?.type==="geometry"?s.height:0},set height(s){n.getState(o.id)?.type==="geometry"&&n.setState(o,{height:s})},set flipImageToFaceCamera(s){n.getState(o.id)?.type==="image"&&n.setState(o,{flipImageToFaceCamera:s})},get flipImageToFaceCamera(){let s=n.getState(o.id);return s?.type==="image"?s.flipImageToFaceCamera:!1},set visible(s){let c=n.getState(o.id);(c?.type==="geometry"||c?.type==="path"||c?.type==="image")&&n.setState(o,{visible:s})},get visible(){let s=n.getState(o.id);return s?.type==="geometry"||s?.type==="path"||s?.type==="image"?s.visible:!1},set outline(s){n.getState(o.id)?.type==="geometry"&&n.setState(o,{outline:s})},get outline(){let s=n.getState(o.id);return s?.type==="geometry"?s.outline:!1},get opacity(){let s=n.getState(o.id);return s?.type==="geometry"?s.opacity:1},set opacity(s){let c=n.getState(o.id);c?.type==="geometry"&&n.setState(c,{opacity:s})},get color(){let s=n.getState(o.id);return s?.type==="geometry"&&s.color?ks(s.color).toHexString():"#ffffff"},set color(s){let c=n.getState(o.id);c?.type==="geometry"&&n.setState(c,{color:s})},set interactive(s){let c=n.getState(o.id);(c?.type==="geometry"||c?.type==="model"||c?.type==="path")&&(n.setState(o,{interactive:s}),t.controllersRecursive().forEach(h=>h.updateDisplay()))},get interactive(){let s=n.getState(o.id);return s?.type==="geometry"||s?.type==="model"||s?.type==="path"?s.interactive:!1},get completeFraction(){let s=n.getState(o.id);return s?.type==="path"?s.completeFraction:1},set completeFraction(s){let c=n.getState(o.id);c?.type==="path"&&n.setState(c,{completeFraction:s})},focus:()=>{}};a.add(l,"focus").onChange(()=>{let s=n.getState(o.id);s?.type==="model"||s?.type==="path"||s?.type==="image"?n.camera.focusOn([s.position]):s?.type==="geometry"&&n.camera.focusOn(n.getBoundingArea(s))}),a.add(l,"visible"),o.type==="image"?a.add(l,"flipImageToFaceCamera"):(a.add(l,"interactive"),o.type==="path"&&a.add(l,"completeFraction",0,1,.1),o.type!=="model"&&(a.addColor(l,"color"),a.add(l,"outline"))),o.type==="geometry"&&(a.add(l,"height"),a.add(l,"opacity",0,1,.1))}else if(o.type==="marker"){let l={get interactive(){let s=n.getState(o.id);return s?.type==="marker"?s.options?.interactive:!1},set interactive(s){let c=n.getState(o.id);c?.type==="marker"&&(n.setState(c,{options:{interactive:s}}),t.controllersRecursive().forEach(h=>h.updateDisplay()))},focus:()=>{}};a.add(l,"focus").onChange(()=>{let s=n.getState(o.id);s?.type==="marker"&&n.camera.focusOn([s.position])}),a.add(l,"interactive")}else if(o.type==="label"){let l={get interactive(){let s=n.getState(o.id);return s?.type==="label"?s.options?.interactive:!1},set interactive(s){let c=n.getState(o.id);c?.type==="label"&&(n.setState(c,{options:{interactive:s}}),t.controllersRecursive().forEach(h=>h.updateDisplay()))},get text(){let s=n.getState(o.id);return s?.type==="label"?s.text:""},set text(s){let c=n.getState(o.id);c?.type==="label"&&n.setState(c,{text:s})},get"Text Color"(){let s=n.getState(o.id);return s?.type==="label"?s.options.appearance?.textColor:"#000000"},set"Text Color"(s){n.getState(o.id)?.type==="label"&&n.setState(o.id,{text:l.text,options:{appearance:{textColor:s}}})},get"Text Size"(){let s=n.getState(o.id);return s?.type==="label"?s.options.appearance?.textSize:10},set"Text Size"(s){let c=n.getState(o.id);c?.type==="label"&&n.setState(c,{text:l.text,options:{appearance:{textSize:s}}})},get"Icon Size"(){let s=n.getState(o.id);return s?.type==="label"?s.options.appearance?.iconSize:10},set"Icon Size"(s){let c=n.getState(o.id);c?.type==="label"&&n.setState(c,{text:l.text,options:{appearance:{iconSize:s}}})},get"Pin Color"(){let s=n.getState(o.id);return s?.type==="label"?s.options.appearance?.pinColor:"#000000"},set"Pin Color"(s){let c=n.getState(o.id);c?.type==="label"&&n.setState(c,{text:l.text,options:{appearance:{pinColor:s}}})},get"Pin Color Inactive"(){let s=n.getState(o.id);return s?.type==="label"?s.options.appearance?.pinColorInactive:"#000000"},set"Pin Color Inactive"(s){let c=n.getState(o.id);c?.type==="label"&&n.setState(c,{text:l.text,options:{appearance:{pinColorInactive:s}}})},get"Pin Outline Color"(){let s=n.getState(o.id);return s?.type==="label"?s.options.appearance?.pinOutlineColor:"#000000"},set"Pin Outline Color"(s){let c=n.getState(o.id);c?.type==="label"&&n.setState(c,{text:l.text,options:{appearance:{pinOutlineColor:s}}})},get"Pin Outline Color Inactive"(){let s=n.getState(o.id);return s?.type==="label"?s.options.appearance?.pinOutlineColorInactive:"#000000"},set"Pin Outline Color Inactive"(s){let c=n.getState(o.id);c?.type==="label"&&n.setState(c,{text:l.text,options:{appearance:{pinOutlineColorInactive:s}}})},focus:()=>{}};a.add(l,"focus").onChange(()=>{let s=n.getState(o.id);s?.type==="label"&&n.camera.focusOn([s.position])}),a.add(l,"interactive"),a.add(l,"text"),a.add(l,"Text Size",10,50),a.add(l,"Icon Size",10,50),a.addColor(l,"Text Color"),a.addColor(l,"Active Background Color"),a.addColor(l,"Inactive Background Color"),a.addColor(l,"Active Foreground Color"),a.addColor(l,"Inactive Foreground Color")}else if(o.type==="feature-collection"){let l={get opacity(){let s=n.getState(o.id);return s?.type==="feature-collection"?s.opacity:1},set opacity(s){n.getState(o.id)?.type==="feature-collection"&&n.setState(o,{opacity:s})},set outline(s){n.getState(o.id)?.type==="feature-collection"&&n.setState(o,{outline:s})},get outline(){let s=n.getState(o.id);return s?.type==="feature-collection"?s.outline??!1:!1},set interactive(s){n.getState(o.id)?.type==="feature-collection"&&(n.setState(o,{interactive:s}),t.controllersRecursive().forEach(h=>h.updateDisplay()))},get interactive(){let s=n.getState(o.id);return s?.type==="feature-collection"?s.interactive:!1},get shadingStart(){let s=n.getState(o.id);return s?.type==="feature-collection"?s.shading?.start??0:0},set shadingStart(s){let c=n.getState(o.id);c?.type==="feature-collection"&&n.setState(c,{shading:{start:s}})},get shadingEnd(){let s=n.getState(o.id);return s?.type==="feature-collection"?s.shading?.end??0:0},set shadingEnd(s){let c=n.getState(o.id);c?.type==="feature-collection"&&n.setState(c,{shading:{end:s}})},get shadingIntensity(){let s=n.getState(o.id);return s?.type==="feature-collection"?s.shading?.intensity??0:0},set shadingIntensity(s){let c=n.getState(o.id);c?.type==="feature-collection"&&n.setState(c,{shading:{intensity:s}})}};a.add(l,"opacity",0,1,.1),a.add(l,"interactive"),a.add(l,"outline"),a.add(l,"shadingStart",0,1,.1),a.add(l,"shadingEnd",0,1,.1),a.add(l,"shadingIntensity",0,1,.1)}else if(o.type==="group-container"){let l={set visible(s){n.getState(o.id)?.type==="group-container"&&n.setState(o,{visible:s})},get visible(){let s=n.getState(o.id);return s?.type==="group-container"?s.visible:!1},set interactive(s){let c=n.getState(o.id);c?.type==="group-container"&&(n.setState(c,{interactive:s}),t.controllersRecursive().forEach(h=>h.updateDisplay()))},get interactive(){let s=n.getState(o.id);return s?.type==="group-container"?s.interactive:!1}};a.add(l,"visible"),a.add(l,"interactive")}if(a.close(),o.children)for(let l of o.children.values())l==null||typeof l!="object"||i(l,a)}}function sv(n,e){let t=e.addFolder("Watermark"),i={padding:16,iconOnly:!1,position:"bottom-left",color:"dark",scale:1};t.add(i,"padding",0,100,1),t.add(i,"scale",.5,1.5,.1),t.add(i,"color",["dark","light"]),t.add(i,"position",["top-left","top-right","bottom-left","bottom-right","center","top","bottom","left","right"]),t.add(i,"iconOnly"),t.onChange(()=>{n.updateWatermark(i)})}g();import{MathUtils as su}from"three";var vs=class extends z{gl;options;el=document.createElement("div");core;origin;map;layer;cameraSystem;constructor(e,t){super(),this.origin=e,this.options=t}handleStyleChange=()=>{!this.map||!this.layer||this.map.getLayer(this.layer.id)||(this.map.addLayer(this.layer),this.core.camera.setMinZoomLevel(this.map.getMinZoom()),this.core.camera.setMaxZoomLevel(this.map.getMaxZoom()),this.core.camera.setMinPitch(this.map.getMinPitch()),this.core.camera.setMaxPitch(this.map.getMaxPitch()))};handleMoveStart=()=>{this.cameraSystem.beginGesture()};handleMove=()=>{this.map&&this.core.batchCameraChanges(this.applyMapCameraToSystem)};applyMapCameraToSystem=()=>{let e=this.map;if(!e)return;let[t,i]=e.getCenter().toArray();this.cameraSystem.setCenter(t,i),this.cameraSystem.setZoomLevel(e.getZoom()),this.cameraSystem.setRotation(su.degToRad(e.getBearing())),this.cameraSystem.setTilt(su.degToRad(e.getPitch()))};handleMoveEnd=()=>{this.cameraSystem.endGesture()};handleError=e=>{E.warn(e)};onAdd(e){this.origin=this.origin||e.getCenter().toArray(),this.gl=e.painter.context.gl,this.core=new mt(e._container,{...this.options,center:this.origin,zoomLevel:e.getZoom(),pitch:e.getPitch(),bearing:e.getBearing(),gl:this.gl,map:e,mode:"outdoors-overlay"}),this.map=e,this.cameraSystem=this.core.getSystems().cameraSystem,this.core.camera.setMinZoomLevel(e.getMinZoom()),this.core.camera.setMaxZoomLevel(e.getMaxZoom()),this.core.camera.setMinPitch(e.getMinPitch()),this.core.camera.setMaxPitch(e.getMaxPitch()),this.map.on("error",this.handleError);let t=xt.fromLngLat(this.origin,0);return this.layer=yo(t,this.core.viewCamera,()=>{this.core.renderSync()}),this.map.on("styledata",this.handleStyleChange),this.map.on("movestart",this.handleMoveStart),this.map.on("move",this.handleMove),this.map.on("moveend",this.handleMoveEnd),this.handleStyleChange(),this.el}onRemove(){this.map&&(this.map.off("styledata",this.handleStyleChange),this.map.off("movestart",this.handleMoveStart),this.map.off("move",this.handleMove),this.map.off("moveend",this.handleMoveEnd),this.map.off("error",this.handleError),this.layer&&this.map.removeLayer(this.layer.id)),this.layer=void 0,this.map=void 0,this.core&&this.core.destroy(),this.core=void 0}};var xs="https://tiles-cdn.mappedin.com/styles/mappedin/style.json",lv="https://auth.mappedin.com/oauth2/token";async function BO(n,e){let t=As(),i=t?!1:e?.useWorkers??!0,o={...e,...t?{outdoorView:void 0}:{},watermark:e?.watermark,attribution:e?.attribution,antialias:e?.antialias,occlusionEnabled:e?.occlusionEnabled,transformImageRequest:e?.transformImageRequest,naturalBearing:e?.naturalBearing??0,imagePlacementOptions:e?.imagePlacementOptions,onWebGLContextCreationError:e?.onWebGLContextCreationError,onWebGLContextLost:e?.onWebGLContextLost,onWebGLContextRestored:e?.onWebGLContextRestored,onWebGLRendererError:e?.onWebGLRendererError,useStandaloneCamera:e?.useStandaloneCamera??!1,useCollisionWorker:t?!1:e?.useCollisionWorker??!0,useWorkers:i};if(i===!0&&e?.outdoorView?.enabled){let r=e.outdoorView.headers;r==null&&(r=await el(lv));let a=e.center||[0,0];yn&&Zs(yn);let l=null,s=null,c=e.outdoorView.__EXPERIMENTAL_CameraControlsMode==="external";try{l=new js({container:n,style:e.outdoorView.style||xs,center:a,attributionControl:!1,zoom:e.zoomLevel??gs,pitch:e.pitch??ps,bearing:e.bearing??fs,transformRequest:qs(r),trackResize:!1,pixelRatio:e.outdoorView.lowDpi?1:Wt(),canvasContextAttributes:{antialias:typeof e.antialias=="boolean"?e.antialias:!0,powerPreference:"high-performance"},interactive:c,validateStyle:!1,centerClampedToGround:!1,boxZoom:!1,doubleClickZoom:c,scrollZoom:c,dragPan:c,dragRotate:c,keyboard:c,touchZoomRotate:c,aroundCenter:c?!1:void 0}),c&&au(l),await Ks(l,{timeout:1e4,styleUrl:e.outdoorView?.style||xs})}catch(d){if(s=d,E.warn(`[MappedinJS] Outdoor view initialization failed: ${s.message}. Falling back to indoor-only rendering.`),l){try{l.remove()}catch{}l=null}}if(!l||s){let d=new mt(n,o);return d.publish("outdoor-style-error",{error:s}),d}let h=null;try{let d=l.painter.context.gl;h=new mt(n,{center:a,zoomLevel:l.getZoom(),pitch:l.getPitch(),bearing:l.getBearing(),gl:d,map:l,mode:"outdoors-interleaved",...o}),vo(l,h.camera.minZoomLevel,h.camera.maxZoomLevel),l.setMaxPitch(h.camera.maxPitch),l.setMinPitch(h.camera.minPitch),ru(h,l);let u=xt.fromLngLat(a,0),m=yo(u,h.viewCamera,()=>{h?.renderSync()}),v=!1,b=!1,p="",x=async()=>{l&&(b=!1,l.addLayer(m),h?.renderSync())};h.onMapLibreEvent("style.load",x),x();let f=()=>{l&&(v||(h?.publish("outdoor-view-loaded"),v=!0),b||(b=!0,h?.publish("outdoor-style-loaded")))};h.onMapLibreEvent("idle",f);let y=w=>{w&&(w.sourceDataType==="metadata"||w.sourceDataType==="visibility"||w.dataType==="style"||w.type==="terrain")&&h?.getSystems().htmlControlsSystem.updateData(l)},C=w=>{if(l&&w&&w.dataType==="style"&&w.type==="styledata"){let P=w?.style?.stylesheet?.id;P&&P!==p&&(p=P,b=!1)}y(w)};h.onMapLibreEvent("styledata",C),h.onMapLibreEvent("sourcedata",y),h.onMapLibreEvent("terrain",y);let M=e.outdoorView?.refreshToken,S=M?iu({refreshOutdoorToken:M,headers:r,reloadSource:w=>l?.refreshTiles(w)}):void 0;S&&h.onAbort(()=>S.dispose());let T=w=>{if(w.error?.url===xs){E.error(`Failed to load outdoor view style, possibly due to invalid token "${r["x-mappedin-tiles-key"]}"`);return}let P=w?.error?.status;if(S&&w?.tile&&(P===401||P===403)){S.recoverFromTileAuthError(w?.sourceId);return}E.warn(w)};return h.onMapLibreEvent("error",T),h}catch(d){if(h)try{h.destroy()}catch{}if(l)try{l.remove()}catch{}E.warn("Failed to initialize outdoor view, falling back to indoor-only rendering:",d);let u=new mt(n,o);return u.publish("outdoor-style-error",{error:d}),u}}else return new mt(n,o)}export{kn as a,Qo as b,Sa as c,ud as d,rn as e,nn as f,$d as g,hs as h,mt as i,nv as j,vs as k,BO as l};