(function(r){const e={},t={};function s(o,p,d){if(t[o]=d,o==="index"){var i="var sharedModule = {}; ("+t.shared+")(sharedModule); ("+t.worker+")(sharedModule);";typeof exports=="object"&&typeof module=="object"?module.exports=e:typeof exports=="object"?exports.mapgl=e:r.mapgl=e;var n={};return t.shared(n),t.index(e,n),typeof window<"u"&&e.setWorkerUrl(window.URL.createObjectURL(new Blob([i],{type:"text/javascript"}))),typeof System=="object"&&typeof System.register=="function"&&System.register([],f=>(f(e),{execute:function(){}})),e}}r._mapgl_d=s})(self);

_mapgl_d("shared",["exports"],(function(m){"use strict";const kp="tile{subdomain}.maps.2gis.com",Up="jam.api.2gis.com",zp="https://styles.api.2gis.com",Gp="https://disk.2gis.com/styles/assets/icons",jp="https://disk.2gis.com/styles/assets/models",Hp="https://mapgl.2gis.com/api/fonts",Vp="https://keys.api.2gis.com/public/v1/keys/{keyID}/services/mapgl-js-api",$p="https://mapgl.2gis.com/api/js/plugins/rtl-v1.1.1.js",Yp="sha512-IyuCqmcNBfZyrExDMisGi0Xhp4PXupx6AMp4cjpKcAzJo+kSmOtRTLbL1xZsfxnsIqci9Q0piqY+kcwl1hCPyw==",Zp="https://mapgl.2gis.com/api/js/plugins",Wp=107.17318798131565,Zi=2**20,ne=2**15,Oe=2**16-1,yi=ne/Oe,B=16383,ql=2.54,Wi=96,Jl=4294967296/(256/Wi*ql),_e=.7071067811865475,Xp=4294967295,qp=1175494351e-47,Jp=3402823466e29,qs=["Arial","Helvetica","HelveticaNeueCyr","Open_Sans","Open_Sans_Semibold","Open_Sans_Italic","Segoe_UI","PT_Sans_Caption","PT_Sans","Verdana","Verdana_bold","Noto_Sans","Noto_Sans_Semibold","Noto_Sans_Italic","SuisseIntl_Bold"],gi="Noto_Sans",Kl=1/2,Ql=-4,Vo=2147483647,Kp="c080bb6a-8134-4993-93a1-5b4d8c36a59b",Qp=5,Js=4,$o=40,em=65e3,ed="byModel",tm=65536,nm=512,td="empty",Yo={minZoom:2,maxZoom:20},Gn={protocol:"https",server:kp,subdomains:"0123",tileSet:"vector_a",tileKey:td,appId:"empty",cacheRatio:2,maxUniverseZoom:8,maxRegionalZoom:15,maxDetailLevel:17},Zo={minZoom:10,maxZoom:14,tileSet:"com_poi_web",rasterSizes:[96,84,72,60,48,36,24]},nd={minZoom:15,maxZoom:15,tileSet:"vector_immersive"},id={tileSet:"dem"},sd=100,Wo=13.5,qt=[2048,2048],Ks={tiles:"{protocol}://{host}/vt?r={request}&ts={tileSet}&key={tileKey}&appId={appId}&lang={lang}&default_lang={defaultLang}&s={sessionId}&dt={dt}",metatile:"{protocol}://{host}/metafiles/{hash}/metatile.json?ts={tileSet}",modelInfo:"{protocol}://{host}/metafiles/{regionId}/models.json?ts={tileSet}",model:"{protocol}://{host}/metafiles/{regionId}/{name}?ts={tileSet}",gltfModel:"{protocol}://{host}/metafiles/{modelSrc}?ts={tileSet}",convertData:"{protocol}://{host}/metafiles/{hash}/convert.json?ts={tileSet}",dynamicPoi:"{protocol}://{host}/metafiles/{regionId}/poi/{id}_{width}_{height}.png?ts={tileSet}",models:"{protocol}://{host}/v2/ald?ts={tileSet}&x={x}&y={y}&z={z}",commercialPoi:"{protocol}://{host}/v2/ald?ts={tileSet}&x={x}&y={y}&z={z}&lang={lang}",floorMeta:"{protocol}://{host}/metafiles/{regionId}/{floorComplexId}.json?ts={tileSet}"},rd={protocol:"https",host:Up,url:"{protocol}://{host}/tiles?tls={tiles}&reg={regions}&tm={time}&fmt=json&z={z}",timestampUrl:"{protocol}://{host}/meta?reg={regions}&time&score",updateInterval:120*1e3,minZoom:10,maxZoom:16,maxDetailLevel:17,fetchMetaRetryDelays:[2,5,25].map(e=>e*1e3)},xt={defaultUrl:Hp,gamma:.08,baseSize:24,baseLineHeight:1.2,bomCharCode:65279},od={defaultUrl:Gp},ad={url:zp,path:"styles/{id}"},cd={doubleClickTime:185,dragThreshold:2,pitchWaitingTime:200,pitchThreshold:7},ld=1e3,Xi={inAnimationTime:180,inAnimationType:"linear",outAnimationTime:800,outAnimationType:"linear"},Xo={time:300,type:"linear"},dd={minStyleZoom:16,duration:500,easing:"easeOutQuint"},fd={bounceType:"easeOutElastic",bounceTime:1200,growType:"easeInOutQuad",growTime:1200,stagger:0,iterationCount:1/0},qo={pixelDensity:.5,sceneOpacity:0,cacheRefreshTime:300,pickDistance:3},Qs={interval:220,animationTime:200,animationType:"linear",tileMultiplier:1.5,axisAngleToleranceDeg:45,axisCheckDistancePx:13,commercialMargins:{default:{topBottom:60,leftRight:60},city:{topBottom:500,leftRight:500}},lineLabelsHidePitchDeg:40,maxLabelLength:30},ud={0:Qs.commercialMargins.city,11:{topBottom:250,leftRight:250},12:{topBottom:170,leftRight:170}},hd={alwaysRerender:!1,autoResizeInterval:50},pd="en",md={macWheelDeltaToZoomDelta:.0018,notMacTrackpadDeltaToZoomDelta:.0018*3,wheelZoomDelta:.65,animDuration:400,throttleDelay:100,mouseRotateDelta:2.5,mousePitchDelta:2.5,mobilePinchDelta:1,mobileTapDelta:10},Jo={duration:1300,maxSpeed:8,minSpeed:.02,nonLinearity:5},_t={fov:60*Math.PI/180,useDynamicNearFar:!1,near:1e3,far:2**34,viewportLimitRatio:2.1,minTrapezeHeight:2*131072,perspectiveDistanceLimitRatio:10,minFogDistance:2e4,fogHorizonPadFactor:.15,pitchInterStartZoom:17,pitchInterEndZoom:19},gn={globeMaxZoom:8,globeInterStartZoom:7,globeInterEndZoom:16},yd=1e3,gd=16,Ko={enabled:!0,displayStyleZoom:{default:18,metro:16},detailLevel:16,wallMinBrightness:.8265,wallMaxBrightness:.95,viewportPadding:.2,maxStackHeight:40},wd={fpsCaveat:10},vd=3e4,Qo=["Commercial_poi_city"],ea=["Commercial_poi_premium"],bd=["Commercial_poi_default","Commercial_poi_custom","Commercial_poi_navi",...Qo,...ea],Id=["Commercial_model"],Md=["s_personal_poi"],Td=["Landmark_poi","Landmark_point"],Sd=[105,84,63,42,21],Ad="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzBweCIgaGVpZ2h0PSI0OHB4IiB2aWV3Qm94PSIwIDAgMzAgNDgiIHZlcnNpb249IjEuMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayI+PCEtLSBHZW5lcmF0b3I6IFNrZXRjaCA1MS4yICg1NzUxOSkgLSBodHRwOi8vd3d3LmJvaGVtaWFuY29kaW5nLmNvbS9za2V0Y2ggLS0+PHRpdGxlPlBhZ2UgMSBDb3B5PC90aXRsZT48ZGVzYz5DcmVhdGVkIHdpdGggU2tldGNoLjwvZGVzYz48ZGVmcz48bGluZWFyR3JhZGllbnQgeDE9IjUwJSIgeTE9IjUwJSIgeDI9IjUwJSIgeTI9IjAlIiBpZD0ibGluZWFyR3JhZGllbnQtMSI+PHN0b3Agc3RvcC1jb2xvcj0iIzFCODlFRSIgb2Zmc2V0PSIwJSI+PC9zdG9wPjxzdG9wIHN0b3AtY29sb3I9IiMzMTk4RUMiIG9mZnNldD0iMTAwJSI+PC9zdG9wPjwvbGluZWFyR3JhZGllbnQ+PC9kZWZzPjxnIGlkPSJQYWdlLTEiIHN0cm9rZT0ibm9uZSIgc3Ryb2tlLXdpZHRoPSIxIiBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxnIGlkPSJSZWNvdmVyeS0wMSIgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoLTgzOS4wMDAwMDAsIC00MjUuMDAwMDAwKSI+PGcgaWQ9IlBhZ2UtMS1Db3B5IiB0cmFuc2Zvcm09InRyYW5zbGF0ZSg4MzkuMDAwMDAwLCA0MjUuMDAwMDAwKSI+PGVsbGlwc2UgaWQ9Ik92YWwtMyIgZmlsbD0iIzAwMDAwMCIgb3BhY2l0eT0iMC4wMzYzODA1OTciIGN4PSIxNSIgY3k9IjQ1LjUiIHJ4PSIzIiByeT0iMS41Ij48L2VsbGlwc2U+PGVsbGlwc2UgaWQ9Ik92YWwtMy1Db3B5IiBmaWxsPSIjMDAwMDAwIiBvcGFjaXR5PSIwLjAzNjM4MDU5NyIgY3g9IjE1IiBjeT0iNDUuNSIgcng9IjQuNSIgcnk9IjIuNSI+PC9lbGxpcHNlPjxwYXRoIGQ9Ik0xNSw0NS44ODM2MzUzIEwxNS44ODIzNTI5LDQ1Ljg4MzYzNTMgQzE1Ljg4MjM1MjksMjkuMjE3NzUyOSAyMC43NzY3NjQ3LDIzLjc5NzQ1ODggMjcuOTg3MzUyOSwyMy43OTc0NTg4IEwyOC4zMjk3MDU5LDIzLjc5NzQ1ODggQzI5LjA3Nzk0MTIsMjEuNTkwNjk0MSAzMCwxNy45OTE1NzY1IDMwLDE1LjAwMDQgQzMwLDcuMTQzOTI5NDEgMjMuNzY3OTQxMiwwLjAwMDQgMTUsMC4wMDA0IEM2LjIzMjA1ODgyLDAuMDAwNCAwLDcuMTQzOTI5NDEgMCwxNS4wMDA0IEMwLDE3Ljk5MTU3NjUgMC45MjIwNTg4MjQsMjEuNTkwNjk0MSAxLjY3MDI5NDEyLDIzLjc5NzQ1ODggTDIuMDEyNjQ3MDYsMjMuNzk3NDU4OCBDOS4yMjQxMTc2NSwyMy43OTc0NTg4IDE0LjExNzY0NzEsMjkuMjE3NzUyOSAxNC4xMTc2NDcxLDQ1Ljg4MzYzNTMgTDE1LDQ1Ljg4MzYzNTMgWiIgaWQ9IkZpbGwtMSIgZmlsbD0idXJsKCNsaW5lYXJHcmFkaWVudC0xKSI+PC9wYXRoPjwvZz48L2c+PC9nPjwvc3ZnPg==",Ed=[15,46],xd=16,_d={bias:100,textureSize:[2048,2048],shadowRadius:3},im=Object.freeze(Object.defineProperty({__proto__:null,DEFAULT_MIN_TIERS_STYLE_ZOOM:xd,MAP_DEFAULTS:Yo,atlasSize:qt,buildingAnimation:dd,cityCommPoiLabelingConfig:ud,commercialCitySublayers:Qo,commercialModelSublayers:Id,commercialPoi:Zo,commercialPremiumSublayers:ea,commercialSublayers:bd,defaultCameraConfig:_t,defaultLang:pd,defaultMarkerAnchor:Ed,defaultMarkerIcon:Ad,defaultShadowsSettings:_d,dem:id,entranceAnimation:fd,events:cd,floors:Ko,fonts:xt,globeConfig:gn,houseHover:Xi,icons:od,identify:qo,inertia:Jo,labeling:Qs,landmarkPoiSublayers:Td,landmarkRasterSizes:Sd,loadModelsInfoStyleZoom:Wo,maxZoomForDynamicNear:gd,metricsTimeout:vd,minCalculationScreenHeight:yd,modelCacheSize:sd,models:nd,performanceCheck:wd,personalSublayers:Md,render:hd,styles:ad,tileAnimation:Xo,tiles:Gn,traffic:rd,urls:Ks,workerResetInterval:ld,zoom:md},Symbol.toStringTag,{value:"Module"}));function ge(e,t,n){return e=Math.max(e,t),e=Math.min(e,n),e}function er(e){return e===0||Number.isNaN(e)?e:e>0?1:-1}function sm(e,t){return[t[0]/e[0]*2-1,-(t[1]/e[1])*2+1]}function pe(e){return e*Math.PI/180}function jn(e){return e/Math.PI*180}function Pd(e){return e=e>>>0,e=e-1,e=e|e>>1,e=e|e>>2,e=e|e>>4,e=e|e>>8,e=e|e>>16,e+1}function wn(e,t){const n={...t};for(const i in e)e[i]!==void 0&&(n[i]=e[i]);return n}function ta(e){const t={};for(const n in e){const i=e[n];t[i]=n}return t}function Ld(e,t){const n=[];for(const i in e)t[i]||n.push(e[i]);return n}function na(e,t,n){return ge((n-e)/(t-e),0,1)}function rm(e){return e%1}function ia(e,t,n){return e>=t&&e<=n}function om(e,t){if(e.size!==t.size)return!1;for(const n of Array.from(e))if(!t.has(n))return!1;return!0}function am(e,t){return e===t?!0:e.length!==t.length?!1:!e.some((n,i)=>n!==t[i])}function wi(e,t){if(e===t)return!0;if(e&&t&&typeof e=="object"&&typeof t=="object"){const n=Array.isArray(e),i=Array.isArray(t);let s,r,o;if(n&&i){if(r=e.length,r!==t.length)return!1;for(s=r;s--!==0;)if(!wi(e[s],t[s]))return!1;return!0}if(n!==i)return!1;const a=e instanceof Date,c=t instanceof Date;if(a!==c)return!1;if(a&&c)return e.getTime()===t.getTime();const l=e instanceof RegExp,d=t instanceof RegExp;if(l!==d)return!1;if(l&&d)return e.toString()===t.toString();const f=Object.keys(e);if(r=f.length,r!==Object.keys(t).length)return!1;for(s=r;s--!==0;)if(!Object.prototype.hasOwnProperty.call(t,f[s]))return!1;for(s=r;s--!==0;)if(o=f[s],!wi(e[o],t[o]))return!1;return!0}return e!==e&&t!==t}function cm(e,t){const n=e.indexOf(t);return n!==-1?(e.splice(n,1),!0):!1}function vi(e,t,n){return e+(t-e)*n}function lm(e){return e==null}function tr(e,t){const n=t;typeof e=="number"?n.fill(e):Array.isArray(e)&&typeof e[0]=="number"&&typeof e[1]=="number"&&typeof e[2]=="number"&&(n[0]=e[0],n[1]=e[1],n[2]=e[2])}class Dd{constructor(t,n){this.getNewValidFor=n,this.getNewValue=t,this.currentValue=NaN,this.currentValidFor=new Array(n().length).fill(NaN)}get value(){const t=this.getNewValidFor();return this.currentValidFor.some((i,s)=>i!==t[s])&&(this.currentValidFor=t,this.currentValue=this.getNewValue()),this.currentValue}}function dm(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Od(e){const t=ge((e>>24&255)/255,0,1),n=ge((e>>16&255)/255,0,1),i=ge((e>>8&255)/255,0,1),s=ge((e&255)/255,0,1);return[t,n,i,s]}const ct=1e-6;let lt=typeof Float64Array<"u"?Float64Array:Array;function Ae(){let e=new lt(2);return e[0]=0,e[1]=0,e}function fm(e){let t=new lt(2);return t[0]=e[0],t[1]=e[1],t}function sa(e,t){let n=new lt(2);return n[0]=e,n[1]=t,n}function nr(e,t){return e[0]=t[0],e[1]=t[1],e}function Ce(e,t,n){return e[0]=t,e[1]=n,e}function Pt(e,t,n){return e[0]=t[0]+n[0],e[1]=t[1]+n[1],e}function ra(e,t,n){return e[0]=t[0]-n[0],e[1]=t[1]-n[1],e}function um(e,t,n){return e[0]=Math.min(t[0],n[0]),e[1]=Math.min(t[1],n[1]),e}function hm(e,t,n){return e[0]=Math.max(t[0],n[0]),e[1]=Math.max(t[1],n[1]),e}function mt(e,t,n){return e[0]=t[0]*n,e[1]=t[1]*n,e}function qi(e,t){var n=t[0]-e[0],i=t[1]-e[1];return Math.sqrt(n*n+i*i)}function ir(e){var t=e[0],n=e[1];return Math.sqrt(t*t+n*n)}function pm(e){var t=e[0],n=e[1];return t*t+n*n}function vn(e,t){var n=t[0],i=t[1],s=n*n+i*i;return s>0&&(s=1/Math.sqrt(s),e[0]=t[0]*s,e[1]=t[1]*s),e}function bn(e,t){return e[0]*t[0]+e[1]*t[1]}function Cd(e,t,n,i){var s=t[0],r=t[1];return e[0]=s+i*(n[0]-s),e[1]=r+i*(n[1]-r),e}function sr(e,t){return e[0]===t[0]&&e[1]===t[1]}function mm(e,t){let n=e[0],i=e[1],s=t[0],r=t[1];return Math.abs(n-s)<=ct*Math.max(1,Math.abs(n),Math.abs(s))&&Math.abs(i-r)<=ct*Math.max(1,Math.abs(i),Math.abs(r))}const Fd=ir,Jt=ra,In=qi;(function(){let e=Ae();return function(t,n,i,s,r,o){let a,c;for(n||(n=2),i||(i=0),s?c=Math.min(s*n+i,t.length):c=t.length,a=i;a<c;a+=n)e[0]=t[a],e[1]=t[a+1],r(e,e,o),t[a]=e[0],t[a+1]=e[1];return t}})();function Nd(){let e=new lt(16);return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function ym(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function gm(e,t,n,i,s,r,o,a,c,l,d,f,u,h,y,w){let p=new lt(16);return p[0]=e,p[1]=t,p[2]=n,p[3]=i,p[4]=s,p[5]=r,p[6]=o,p[7]=a,p[8]=c,p[9]=l,p[10]=d,p[11]=f,p[12]=u,p[13]=h,p[14]=y,p[15]=w,p}function wm(e,t,n,i,s,r,o,a,c,l,d,f,u,h,y,w,p){return e[0]=t,e[1]=n,e[2]=i,e[3]=s,e[4]=r,e[5]=o,e[6]=a,e[7]=c,e[8]=l,e[9]=d,e[10]=f,e[11]=u,e[12]=h,e[13]=y,e[14]=w,e[15]=p,e}function oa(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function vm(e,t){if(e===t){let n=t[1],i=t[2],s=t[3],r=t[6],o=t[7],a=t[11];e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=n,e[6]=t[9],e[7]=t[13],e[8]=i,e[9]=r,e[11]=t[14],e[12]=s,e[13]=o,e[14]=a}else e[0]=t[0],e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=t[1],e[5]=t[5],e[6]=t[9],e[7]=t[13],e[8]=t[2],e[9]=t[6],e[10]=t[10],e[11]=t[14],e[12]=t[3],e[13]=t[7],e[14]=t[11],e[15]=t[15];return e}function Ji(e,t){let n=t[0],i=t[1],s=t[2],r=t[3],o=t[4],a=t[5],c=t[6],l=t[7],d=t[8],f=t[9],u=t[10],h=t[11],y=t[12],w=t[13],p=t[14],g=t[15],b=n*a-i*o,v=n*c-s*o,M=n*l-r*o,E=i*c-s*a,T=i*l-r*a,L=s*l-r*c,A=d*w-f*y,P=d*p-u*y,R=d*g-h*y,k=f*p-u*w,V=f*g-h*w,z=u*g-h*p,$=b*z-v*V+M*k+E*R-T*P+L*A;return $?($=1/$,e[0]=(a*z-c*V+l*k)*$,e[1]=(s*V-i*z-r*k)*$,e[2]=(w*L-p*T+g*E)*$,e[3]=(u*T-f*L-h*E)*$,e[4]=(c*R-o*z-l*P)*$,e[5]=(n*z-s*R+r*P)*$,e[6]=(p*M-y*L-g*v)*$,e[7]=(d*L-u*M+h*v)*$,e[8]=(o*V-a*R+l*A)*$,e[9]=(i*R-n*V-r*A)*$,e[10]=(y*T-w*M+g*b)*$,e[11]=(f*M-d*T-h*b)*$,e[12]=(a*P-o*k-c*A)*$,e[13]=(n*k-i*P+s*A)*$,e[14]=(w*v-y*E-p*b)*$,e[15]=(d*E-f*v+u*b)*$,e):null}function aa(e,t,n){let i=t[0],s=t[1],r=t[2],o=t[3],a=t[4],c=t[5],l=t[6],d=t[7],f=t[8],u=t[9],h=t[10],y=t[11],w=t[12],p=t[13],g=t[14],b=t[15],v=n[0],M=n[1],E=n[2],T=n[3];return e[0]=v*i+M*a+E*f+T*w,e[1]=v*s+M*c+E*u+T*p,e[2]=v*r+M*l+E*h+T*g,e[3]=v*o+M*d+E*y+T*b,v=n[4],M=n[5],E=n[6],T=n[7],e[4]=v*i+M*a+E*f+T*w,e[5]=v*s+M*c+E*u+T*p,e[6]=v*r+M*l+E*h+T*g,e[7]=v*o+M*d+E*y+T*b,v=n[8],M=n[9],E=n[10],T=n[11],e[8]=v*i+M*a+E*f+T*w,e[9]=v*s+M*c+E*u+T*p,e[10]=v*r+M*l+E*h+T*g,e[11]=v*o+M*d+E*y+T*b,v=n[12],M=n[13],E=n[14],T=n[15],e[12]=v*i+M*a+E*f+T*w,e[13]=v*s+M*c+E*u+T*p,e[14]=v*r+M*l+E*h+T*g,e[15]=v*o+M*d+E*y+T*b,e}function Rd(e,t,n){let i=n[0],s=n[1],r=n[2],o,a,c,l,d,f,u,h,y,w,p,g;return t===e?(e[12]=t[0]*i+t[4]*s+t[8]*r+t[12],e[13]=t[1]*i+t[5]*s+t[9]*r+t[13],e[14]=t[2]*i+t[6]*s+t[10]*r+t[14],e[15]=t[3]*i+t[7]*s+t[11]*r+t[15]):(o=t[0],a=t[1],c=t[2],l=t[3],d=t[4],f=t[5],u=t[6],h=t[7],y=t[8],w=t[9],p=t[10],g=t[11],e[0]=o,e[1]=a,e[2]=c,e[3]=l,e[4]=d,e[5]=f,e[6]=u,e[7]=h,e[8]=y,e[9]=w,e[10]=p,e[11]=g,e[12]=o*i+d*s+y*r+t[12],e[13]=a*i+f*s+w*r+t[13],e[14]=c*i+u*s+p*r+t[14],e[15]=l*i+h*s+g*r+t[15]),e}function bi(e,t,n){let i=n[0],s=n[1],r=n[2];return e[0]=t[0]*i,e[1]=t[1]*i,e[2]=t[2]*i,e[3]=t[3]*i,e[4]=t[4]*s,e[5]=t[5]*s,e[6]=t[6]*s,e[7]=t[7]*s,e[8]=t[8]*r,e[9]=t[9]*r,e[10]=t[10]*r,e[11]=t[11]*r,e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function ca(e,t,n){let i=Math.sin(n),s=Math.cos(n),r=t[4],o=t[5],a=t[6],c=t[7],l=t[8],d=t[9],f=t[10],u=t[11];return t!==e&&(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[4]=r*s+l*i,e[5]=o*s+d*i,e[6]=a*s+f*i,e[7]=c*s+u*i,e[8]=l*s-r*i,e[9]=d*s-o*i,e[10]=f*s-a*i,e[11]=u*s-c*i,e}function Bd(e,t,n){let i=Math.sin(n),s=Math.cos(n),r=t[0],o=t[1],a=t[2],c=t[3],l=t[8],d=t[9],f=t[10],u=t[11];return t!==e&&(e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[0]=r*s-l*i,e[1]=o*s-d*i,e[2]=a*s-f*i,e[3]=c*s-u*i,e[8]=r*i+l*s,e[9]=o*i+d*s,e[10]=a*i+f*s,e[11]=c*i+u*s,e}function rr(e,t,n){let i=Math.sin(n),s=Math.cos(n),r=t[0],o=t[1],a=t[2],c=t[3],l=t[4],d=t[5],f=t[6],u=t[7];return t!==e&&(e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[0]=r*s+l*i,e[1]=o*s+d*i,e[2]=a*s+f*i,e[3]=c*s+u*i,e[4]=l*s-r*i,e[5]=d*s-o*i,e[6]=f*s-a*i,e[7]=u*s-c*i,e}function bm(e,t){return e[0]=t[0],e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=t[1],e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=t[2],e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function kd(e,t,n){let i=n[0],s=n[1],r=n[2],o=Math.sqrt(i*i+s*s+r*r),a,c,l;return Math.abs(o)<ct?null:(o=1/o,i*=o,s*=o,r*=o,a=Math.sin(t),c=Math.cos(t),l=1-c,e[0]=i*i*l+c,e[1]=s*i*l+r*a,e[2]=r*i*l-s*a,e[3]=0,e[4]=i*s*l-r*a,e[5]=s*s*l+c,e[6]=r*s*l+i*a,e[7]=0,e[8]=i*r*l+s*a,e[9]=s*r*l-i*a,e[10]=r*r*l+c,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e)}function Im(e,t,n,i){let s=t[0],r=t[1],o=t[2],a=t[3],c=s+s,l=r+r,d=o+o,f=s*c,u=s*l,h=s*d,y=r*l,w=r*d,p=o*d,g=a*c,b=a*l,v=a*d,M=i[0],E=i[1],T=i[2];return e[0]=(1-(y+p))*M,e[1]=(u+v)*M,e[2]=(h-b)*M,e[3]=0,e[4]=(u-v)*E,e[5]=(1-(f+p))*E,e[6]=(w+g)*E,e[7]=0,e[8]=(h+b)*T,e[9]=(w-g)*T,e[10]=(1-(f+y))*T,e[11]=0,e[12]=n[0],e[13]=n[1],e[14]=n[2],e[15]=1,e}function Mm(e,t,n,i,s,r,o){let a=1/(t-n),c=1/(i-s),l=1/(r-o);return e[0]=-2*a,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*c,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=2*l,e[11]=0,e[12]=(t+n)*a,e[13]=(s+i)*c,e[14]=(o+r)*l,e[15]=1,e}function la(e,t,n,i){let s,r,o,a,c,l,d,f,u,h,y=t[0],w=t[1],p=t[2],g=i[0],b=i[1],v=i[2],M=n[0],E=n[1],T=n[2];return Math.abs(y-M)<ct&&Math.abs(w-E)<ct&&Math.abs(p-T)<ct?mat4.identity(e):(d=y-M,f=w-E,u=p-T,h=1/Math.sqrt(d*d+f*f+u*u),d*=h,f*=h,u*=h,s=b*u-v*f,r=v*d-g*u,o=g*f-b*d,h=Math.sqrt(s*s+r*r+o*o),h?(h=1/h,s*=h,r*=h,o*=h):(s=0,r=0,o=0),a=f*o-u*r,c=u*s-d*o,l=d*r-f*s,h=Math.sqrt(a*a+c*c+l*l),h?(h=1/h,a*=h,c*=h,l*=h):(a=0,c=0,l=0),e[0]=s,e[1]=a,e[2]=d,e[3]=0,e[4]=r,e[5]=c,e[6]=f,e[7]=0,e[8]=o,e[9]=l,e[10]=u,e[11]=0,e[12]=-(s*y+r*w+o*p),e[13]=-(a*y+c*w+l*p),e[14]=-(d*y+f*w+u*p),e[15]=1,e)}function Tm(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]&&e[4]===t[4]&&e[5]===t[5]&&e[6]===t[6]&&e[7]===t[7]&&e[8]===t[8]&&e[9]===t[9]&&e[10]===t[10]&&e[11]===t[11]&&e[12]===t[12]&&e[13]===t[13]&&e[14]===t[14]&&e[15]===t[15]}const Ii=aa;function or(e,t,n){return e[0]=n[0],e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=n[1],e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=n[2],e[11]=0,e[12]=t[0],e[13]=t[1],e[14]=t[2],e[15]=1,e}const Ud=6378137,da=2*Math.PI*Ud,me=4294967296/da,Sm=or([],[-1,-1,0],[2,2,1]),Am=or([],[.5,.5,0],[.5,.5,1]),Hn=Ud*(Math.PI/2),Xe=2**15/4294967296;function fa(e){return Math.max(e,yd)}function Mi(e,t){const n=_t,i=fa(t[1])/2,s=4294967296/2**e,r=i/256*s,o=Math.tan(n.fov/2);return r/o}function Em(e,t){const n=_t;return Math.log(fa(t[1])*4294967296/(2*256*Math.tan(n.fov/2)*e))/Math.LN2}function xm(e){return Jl*Math.pow(2,-e)}function _m(e,t){return 2**(Math.round(e)-t.coords[2])}function Pm(e,t){return ql*(e/Wi)/t}function ua(e,t){const i=Math.PI/180,s=e[1]*i,r=t[1]*i,o=Math.sin((t[1]-e[1])*i/2),a=Math.sin((t[0]-e[0])*i/2),c=o*o+Math.cos(s)*Math.cos(r)*a*a,l=2*Math.atan2(Math.sqrt(c),Math.sqrt(1-c));return Math.round(6371e3*l)}function Lm(e){let t=0;if(e.length>1)for(let n=0;n<e.length-1;n++)t+=ua(e[n],e[n+1]);return t}const Dm={min:[-2147483648,-2147483648],max:[4294967296/2,4294967296/2]},Om={min:[-214748364800,-2147483648],max:[4294967296*100/2,4294967296/2]};function Ki(e){let i=e[0];if(i>=-2147483648&&i<=2147483648)return;const s=4294967296;i=((i- -2147483648)%s+s)%s+-2147483648,e[0]=i}function zd(e,t){return e*Math.pow(2,-t)*4294967296/256}function Cm(e,t){return e*Math.pow(2,t)*256/4294967296}function Gd(e,t){return e===0?-1/0:-Math.log(t*256/(e*4294967296))/Math.LN2}const ha=Ae(),jd=Ae();function Fm(e,t,n){ra(ha,n,e),ra(jd,t,e);const i=bn(ha,jd)/ir(ha);return Math.atan2(i,e[2])}function Nm(e){const t=e[0],n=e[1];return ia(t,-2147483648,2147483648)&&ia(n,-2147483648,2147483648)}function Rm(e){const t=[...e];return Nm(t)||(t[0]=(4294967296+(t[0]+2147483648)%4294967296)%4294967296-2147483648),t}function ar(e,t){const n=Math.cos(pe(t[0]-e[0])),i=Math.sin(pe(t[1])),s=Math.sin(pe(e[1])),r=Math.cos(pe(t[1])),o=Math.cos(pe(e[1]));return Math.acos(i*s+r*o*n)}function Bm(e,t,n){const i=pe(e[0]),s=pe(e[1]),r=[0,0];return r[1]=Math.asin(Math.sin(s)*Math.cos(n)+Math.cos(s)*Math.sin(n)*Math.cos(t)),r[0]=i+Math.atan2(Math.sin(t)*Math.sin(n)*Math.cos(s),Math.cos(n)-Math.sin(s)*Math.sin(r[1])),[jn(r[0]),jn(r[1])]}function rt(){let e=new lt(3);return e[0]=0,e[1]=0,e[2]=0,e}function km(e){var t=new lt(3);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function Mn(e){let t=e[0],n=e[1],i=e[2];return Math.sqrt(t*t+n*n+i*i)}function qe(e,t,n){let i=new lt(3);return i[0]=e,i[1]=t,i[2]=n,i}function pa(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e}function Se(e,t,n,i){return e[0]=t,e[1]=n,e[2]=i,e}function Vn(e,t,n){return e[0]=t[0]+n[0],e[1]=t[1]+n[1],e[2]=t[2]+n[2],e}function Um(e,t,n){return e[0]=t[0]-n[0],e[1]=t[1]-n[1],e[2]=t[2]-n[2],e}function Tn(e,t,n){return e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e}function Hd(e,t){let n=t[0]-e[0],i=t[1]-e[1],s=t[2]-e[2];return Math.sqrt(n*n+i*i+s*s)}function zm(e,t){let n=t[0]-e[0],i=t[1]-e[1],s=t[2]-e[2];return n*n+i*i+s*s}function Gm(e){let t=e[0],n=e[1],i=e[2];return t*t+n*n+i*i}function Vd(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e}function zt(e,t){let n=t[0],i=t[1],s=t[2],r=n*n+i*i+s*s;return r>0&&(r=1/Math.sqrt(r),e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r),e}function ma(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function Qi(e,t,n){let i=t[0],s=t[1],r=t[2],o=n[0],a=n[1],c=n[2];return e[0]=s*c-r*a,e[1]=r*o-i*c,e[2]=i*a-s*o,e}function $n(e,t,n,i){let s=t[0],r=t[1],o=t[2];return e[0]=s+i*(n[0]-s),e[1]=r+i*(n[1]-r),e[2]=o+i*(n[2]-o),e}function es(e,t,n){let i=t[0],s=t[1],r=t[2],o=n[3]*i+n[7]*s+n[11]*r+n[15];return o=o||1,e[0]=(n[0]*i+n[4]*s+n[8]*r+n[12])/o,e[1]=(n[1]*i+n[5]*s+n[9]*r+n[13])/o,e[2]=(n[2]*i+n[6]*s+n[10]*r+n[14])/o,e}function jm(e,t,n){let i=t[0],s=t[1],r=t[2],o=n[0],a=n[1],c=n[2],l=n[3],d=l*i+a*r-c*s,f=l*s+c*i-o*r,u=l*r+o*s-a*i,h=-o*i-a*s-c*r;return e[0]=d*l+h*-o+f*-c-u*-a,e[1]=f*l+h*-a+u*-o-d*-c,e[2]=u*l+h*-c+d*-a-f*-o,e}function Hm(e,t,n,i){let s=[],r=[];return s[0]=t[0]-n[0],s[1]=t[1]-n[1],s[2]=t[2]-n[2],r[0]=s[0],r[1]=s[1]*Math.cos(i)-s[2]*Math.sin(i),r[2]=s[1]*Math.sin(i)+s[2]*Math.cos(i),e[0]=r[0]+n[0],e[1]=r[1]+n[1],e[2]=r[2]+n[2],e}function Vm(e,t,n,i){let s=[],r=[];return s[0]=t[0]-n[0],s[1]=t[1]-n[1],s[2]=t[2]-n[2],r[0]=s[2]*Math.sin(i)+s[0]*Math.cos(i),r[1]=s[1],r[2]=s[2]*Math.cos(i)-s[0]*Math.sin(i),e[0]=r[0]+n[0],e[1]=r[1]+n[1],e[2]=r[2]+n[2],e}function $m(e,t,n,i){let s=[],r=[];return s[0]=t[0]-n[0],s[1]=t[1]-n[1],s[2]=t[2]-n[2],r[0]=s[0]*Math.cos(i)-s[1]*Math.sin(i),r[1]=s[0]*Math.sin(i)+s[1]*Math.cos(i),r[2]=s[2],e[0]=r[0]+n[0],e[1]=r[1]+n[1],e[2]=r[2]+n[2],e}function Ym(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]}function Zm(e,t){let n=e[0],i=e[1],s=e[2],r=t[0],o=t[1],a=t[2];return Math.abs(n-r)<=ct*Math.max(1,Math.abs(n),Math.abs(r))&&Math.abs(i-o)<=ct*Math.max(1,Math.abs(i),Math.abs(o))&&Math.abs(s-a)<=ct*Math.max(1,Math.abs(s),Math.abs(a))}const Gt=Um,ya=Hd,Wm=zm,cr=Mn;(function(){let e=rt();return function(t,n,i,s,r,o){let a,c;for(n||(n=3),i||(i=0),s?c=Math.min(s*n+i,t.length):c=t.length,a=i;a<c;a+=n)e[0]=t[a],e[1]=t[a+1],e[2]=t[a+2],r(e,e,o),t[a]=e[0],t[a+1]=e[1],t[a+2]=e[2];return t}})();function ts(){let e=new lt(4);return e[0]=0,e[1]=0,e[2]=0,e[3]=0,e}function Xm(e,t,n,i){let s=new lt(4);return s[0]=e,s[1]=t,s[2]=n,s[3]=i,s}function $d(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e}function qm(e,t,n,i,s){return e[0]=t,e[1]=n,e[2]=i,e[3]=s,e}function Jm(e,t,n){return e[0]=t[0]*n[0],e[1]=t[1]*n[1],e[2]=t[2]*n[2],e[3]=t[3]*n[3],e}function Km(e,t,n){return e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e[3]=t[3]*n,e}function Qm(e,t){let n=t[0],i=t[1],s=t[2],r=t[3],o=n*n+i*i+s*s+r*r;return o>0&&(o=1/Math.sqrt(o),e[0]=n*o,e[1]=i*o,e[2]=s*o,e[3]=r*o),e}function e1(e,t,n,i){let s=t[0],r=t[1],o=t[2],a=t[3];return e[0]=s+i*(n[0]-s),e[1]=r+i*(n[1]-r),e[2]=o+i*(n[2]-o),e[3]=a+i*(n[3]-a),e}function lr(e,t,n){let i=t[0],s=t[1],r=t[2],o=t[3];return e[0]=n[0]*i+n[4]*s+n[8]*r+n[12]*o,e[1]=n[1]*i+n[5]*s+n[9]*r+n[13]*o,e[2]=n[2]*i+n[6]*s+n[10]*r+n[14]*o,e[3]=n[3]*i+n[7]*s+n[11]*r+n[15]*o,e}function t1(e,t){let n=e[0],i=e[1],s=e[2],r=e[3],o=t[0],a=t[1],c=t[2],l=t[3];return Math.abs(n-o)<=ct*Math.max(1,Math.abs(n),Math.abs(o))&&Math.abs(i-a)<=ct*Math.max(1,Math.abs(i),Math.abs(a))&&Math.abs(s-c)<=ct*Math.max(1,Math.abs(s),Math.abs(c))&&Math.abs(r-l)<=ct*Math.max(1,Math.abs(r),Math.abs(l))}const n1=Jm;(function(){let e=ts();return function(t,n,i,s,r,o){let a,c;for(n||(n=4),i||(i=0),s?c=Math.min(s*n+i,t.length):c=t.length,a=i;a<c;a+=n)e[0]=t[a],e[1]=t[a+1],e[2]=t[a+2],e[3]=t[a+3],r(e,e,o),t[a]=e[0],t[a+1]=e[1],t[a+2]=e[2],t[a+3]=e[3];return t}})();const Yn=ts();class oe{constructor(t,n){this.state=t,this.camera=n,this.position=[0,0,0]}static fromGeo(t,n=[0,0]){const s=Math.sin(pe(t[1])),r=t[0]*4294967296/360,o=Math.log((1+s)/(1-s))*4294967296/(4*Math.PI);let a=0;if(t.length>2){const c=oe.scaleFactor(t[1]);a=(t[2]??0)*me*c}return n[0]=r,n[1]=ge(o,-2147483648,2147483648),n[2]=a,n}static toGeo(t,n=[0,0]){n[0]=t[0]*360/4294967296;const i=-2*Math.PI/4294967296;if(n[1]=90-2*jn(Math.atan(Math.exp(t[1]*i))),t[2]){const s=oe.scaleFactor(n[1]);n[2]=t[2]/me/s}return n}static scaleFactor(t){return 1/Math.cos(pe(t))}update(){const{center:t,rotation:n,zoom:i,pitch:s,size:r}=this.state,o=Mi(i,r),a=Math.max(o*Math.sin(s),1);this.position[0]=t[0]+Math.sin(n)*a,this.position[1]=t[1]-Math.cos(n)*a,this.position[2]=o*Math.cos(s)}project(t,n=!1,i=[NaN,NaN]){const{size:s,viewport:r}=this.state;Yn[0]=t[0],Yn[1]=t[1],Yn[2]=t[2],Yn[3]=1,lr(Yn,Yn,this.camera.viewProjectionMatrix);const[o,a,c,l]=Yn,d=l*2;if(n&&(c>d||c<-d||o>d||o<-d||a>d||a<-d))return i;const u=s[0]/2,h=s[1]/2;return i[0]=u+r.left+o*u/l,i[1]=h+r.top-a*h/l,i}unproject(t,n=[0,0,0]){const{size:i,viewport:s}=this.state;n[0]=(t[0]-s.left)/i[0]*2-1,n[1]=-((Math.max(this.camera.horizonPixelOffset,t[1])-s.top)/i[1])*2+1,n[2]=0,es(n,n,this.camera.viewProjectionMatrixInverse),n[0]-=this.position[0],n[1]-=this.position[1],n[2]-=this.position[2],zt(n,n);const r=-this.position[2]/n[2];return n[0]=this.position[0]+n[0]*r,n[1]=this.position[1]+n[1]*r,n[2]=this.position[2]+n[2]*r,n}setState(t){this.state=t}}const Zn=ts();function Yd(e){return[e[2],e[0],e[1]]}class Ve{constructor(t,n){this.state=t,this.camera=n,this.position=[0,0,0],this.ivpMatrix=[],this.cachedVisibleArc=new Dd(()=>{const i=Mi(this.state.zoom,this.state.size)/me;return Math.acos(Hn/(Hn+i))},()=>[this.state.zoom]),this.cachedPixelRadius=new Dd(()=>{const i=oe.toGeo(this.state.center),s=Bm(i,0,this.visibleArc),r=this.project(Ve.fromGeo(s));return r[0]-=this.state.viewport.left+this.state.size[0]/2+(this.state.padding.left-this.state.padding.right)/2,r[1]-=this.state.viewport.top+this.state.size[1]/2+(this.state.padding.top-this.state.padding.bottom)/2,Fd(r)},()=>[this.state.zoom,this.state.cameraConfig.fov,this.state.size[0],this.state.size[1],this.state.padding.bottom,this.state.padding.top,this.state.padding.left,this.state.padding.right,this.camera.globeMatrix[0]]),this.update()}get visibleArc(){return this.cachedVisibleArc.value}get pixelRadius(){return this.cachedPixelRadius.value}static fromGeo(t,n=[NaN,NaN,NaN]){const i=pe(t[0]),s=pe(t[1]),r=Math.cos(i),o=Math.sin(i),a=Math.cos(s),c=Math.sin(s),l=Hn*me;return n[0]=o*a*l,n[1]=c*l,n[2]=r*a*l,n}static toGeo(t,n=[NaN,NaN]){const i=t[0],s=t[1],r=t[2],o=Math.sqrt(i*i+s*s+r*r),a=Math.asin(r/o),c=Math.atan2(s,i);return n[0]=jn(c),n[1]=jn(a),n}update(){const{state:t}=this,n=oe.toGeo(t.center),i=Mi(t.zoom,t.size)+Hn*me,s=pe(n[0]),r=pe(n[1]),o=Math.cos(s),a=Math.sin(s),c=Math.cos(r),l=Math.sin(r);this.position=[a*c*i,l*i,o*c*i];const d=[0,0,1];la(this.ivpMatrix,Yd(this.position),[0,0,0],d),Ii(this.ivpMatrix,this.camera.projectionMatrix,this.ivpMatrix),Ji(this.ivpMatrix,this.ivpMatrix)}project(t,n=!1,i=[NaN,NaN]){const{size:s,viewport:r}=this.state,o=ts();Zn[0]=t[0],Zn[1]=t[1],Zn[2]=t[2],Zn[3]=1,lr(Zn,Zn,this.camera.globeMatrix),lr(o,Zn,this.camera.viewProjectionMatrix);const[a,c,l,d]=o,f=d*2;if(n&&(l>f||l<-f||a>f||a<-f||c>f||c<-f))return i[0]=NaN,i[1]=NaN,i;const h=s[0]/2,y=s[1]/2;return i[0]=h+r.left+a*h/d,i[1]=y+r.top-c*y/d,i}unproject(t,n,i=[NaN,NaN,NaN]){const{size:s,viewport:r}=this.state,o=[(t[0]-r.left)/s[0]*2-1,-((Math.max(0,t[1])-r.top)/s[1])*2+1,0],a=Yd(this.position),c=[0,0,0,1];es(c,o,this.ivpMatrix);const l=zt([],Gt([],c,a)),d=Vd([],a),f=ma(d,l),u=Gm(d)-f**2,h=(Hn*me)**2;if(u>h){if(n)return Ve.fromGeo(oe.toGeo(this.state.center));const{left:b,bottom:v,top:M,right:E}=this.state.padding,T=t[0]-r.left-s[0]/2-(b-E)/2,L=t[1]-r.top-s[1]/2-(M-v)/2,A=mt([],vn([],[T,L]),this.pixelRadius-1);return A[0]=A[0]+r.left+s[0]/2+(b-E)/2,A[1]=A[1]+r.top+s[1]/2+(M-v)/2,this.unproject(A,!0,i)}const y=Math.sqrt(h-u),w=f-y,p=f+y,g=Math.min(w,p);return i[0]=a[0]+l[0]*g,i[1]=a[1]+l[1]*g,i[2]=a[2]+l[2]*g,i}setState(t){this.state=t}canSee(t){const n=oe.toGeo(this.state.center);return ar(n,t)<this.visibleArc}}const i1=[0,0,1],s1=rt(),yt=[0,0,0];class ns{constructor(t){this.state=t,this.position=[0,0,0],this.projectionMatrix=[],this.viewMatrix=[],this.viewMatrixTranspose=[],this.projectionMatrixInverse=[],this.viewProjectionMatrix=[],this.viewProjectionMatrixInverse=[],this.globeMatrix=[],this.ecefMvpMatrix=new Float32Array(16),this.flat2ecef=0,this.fogDistance=0,this.correctedPitch=0,this.correctedRotation=0,this.horizonPixelOffset=0,this.prevZoom=0,this.horizonPixelOffset=0,this.flat=new oe(t,this),this.ecef=new Ve(t,this),this.update()}get globeRatio(){return this.flat2ecef}setState(t){this.state=t,this.flat.setState(t),this.ecef.setState(t),this.update()}update(){const{globeMaxZoom:t}=gn;this.flat2ecef=this.state.globeMode?ge(t-this.state.zoom,0,1):0,this.limitPitchRotation(),this.updatePosition(),this.updateViewMatrix(),this.updateProjectionMatrices(),this.state.pitch=this.correctedPitch,this.state.rotation=this.correctedRotation,this.flat.update(),this.ecef.update(),aa(this.viewProjectionMatrix,this.projectionMatrix,this.viewMatrix),Ji(this.viewProjectionMatrixInverse,this.viewProjectionMatrix),Ji(this.projectionMatrixInverse,this.projectionMatrix),vm(this.viewMatrixTranspose,this.viewMatrix),this.state.globeMode&&this.updateGlobeMatrix(),Ii(this.ecefMvpMatrix,this.viewProjectionMatrix,this.globeMatrix),this.updateHorizonPixelOffset(),this.updateFogDistance()}project(t,n=!1,i=[NaN,NaN]){if(this.flat2ecef<Number.EPSILON)return this.flat.project(oe.fromGeo(t),n,i);if(this.flat2ecef>1-Number.EPSILON)return this.ecef.project(Ve.fromGeo(t),n,i);{const s=this.flat.project(oe.fromGeo(t),n),r=this.ecef.project(Ve.fromGeo(t),n);return Array.from($n(i,s,r,this.flat2ecef))}}unproject(t,n=[0,0],i=!1){if(this.flat2ecef<Number.EPSILON){const s=[0,0,0];return this.flat.unproject(t,s),oe.toGeo(s,n),n}else if(this.flat2ecef>1-Number.EPSILON){const s=[0,0,0];return this.ecef.unproject(t,!1,s),Ve.toGeo(s,n),n}else{const s=[0,0,0],r=[0,0,0];return this.flat.unproject(t,s),oe.toGeo(s,s),this.ecef.unproject(t,!1,r),Ve.toGeo(r,r),i?(ga(this,t,r,s,n,2),n[2]=0,n):($n(n,s,r,this.flat2ecef),n[2]=0,n)}}getViewportVertices(t){const{size:n,viewport:i}=this.state;let s={top:0,right:0,bottom:0,left:0};if(t!==void 0){const o=n[0]*t,a=n[1]*t;s={top:o,right:a,bottom:o,left:a}}return[this.flat.unproject([i.left+s.left,n[1]+i.top-s.bottom,0]),this.flat.unproject([n[0]+i.left-s.right,n[1]+i.top-s.bottom,0]),this.flat.unproject([n[0]+i.left-s.right,i.top+s.top,0]),this.flat.unproject([i.left+s.left,i.top+s.top,0])]}getHorizonPixelOffset(){return this.horizonPixelOffset}updatePosition(){const{center:t,zoom:n,size:i}=this.state,s=Mi(n,i);this.prevZoom=n;const r=Math.max(s*Math.sin(this.correctedPitch),1);this.position[0]=t[0]+Math.sin(this.correctedRotation)*r,this.position[1]=t[1]-Math.cos(this.correctedRotation)*r,this.position[2]=s*Math.cos(this.correctedPitch)}limitPitchRotation(){const t=this.state,{zoom:n,pitch:i,rotation:s,cameraConfig:r,styleState:o,lowZoomMaxPitch:a,maxPitch:c}=t,{pitchInterStartZoom:l,pitchInterEndZoom:d}=r,{globeInterEndZoom:f,globeMaxZoom:u}=gn;if(this.correctedPitch=i,this.correctedRotation=s,n<d){const h=Math.max(0,n-l)/(d-l);this.correctedPitch=Math.min(i,vi(a??90,c??90,h))}if(o.globeEnabled&&n<f){const h=Math.max(0,n-u)/(f-u);if(this.correctedPitch=Math.min(this.correctedPitch,vi(0,c??90,h)),n<=u)this.correctedRotation=0;else if(n!==this.prevZoom){const y=0-s,w=(this.prevZoom-n)/(n-u);w>0&&(this.correctedRotation+=y*w%360)}}}updateProjectionMatrices(){const t=this.state.cameraConfig,n=t.fov;t.useDynamicNearFar||this.state.globeMode?this.updateNearFarState():this.restoreFixedNearFar();const{near:i,far:s}=t,{size:r,view:o}=this.correctViewAndSize(),a=r[0]/r[1];let c=i*Math.tan(n/2),l=2*c,d=a*l,f=-d/2;f+=o.x*d/r[0],c-=o.y*l/r[1],d*=o.width/r[0],l*=o.height/r[1];const u=f+d,h=c-l,y=this.projectionMatrix;y[0]=2*i/(u-f),y[5]=2*i/(c-h),y[8]=(u+f)/(u-f),y[9]=(c+h)/(c-h),y[10]=-(s+i)/(s-i),y[11]=-1,y[14]=-2*s*i/(s-i),y[1]=y[2]=y[3]=y[4]=y[6]=y[7]=y[12]=y[13]=y[15]=0,Ji(this.projectionMatrixInverse,this.projectionMatrix)}updateNearFarState(){const{zoom:t,cameraConfig:n}=this.state,i=this.position;if(t>gd)n.near=_t.near;else{const o=.25*i[2],a=Math.min(16-t,1);n.near=o*a+_t.near*(1-a)}const s=(1-Math.min(t,20.5)/21)**2;n.far=_t.far*s}restoreFixedNearFar(){const{cameraConfig:t}=this.state;t.near=_t.near,t.far=_t.far}correctViewAndSize(){const{size:t,padding:n}=this.state,i=Math.max(0,n.top-n.bottom)*Math.tan(this.correctedPitch),s=fa(t[1])+i,r={x:(n.right-n.left)/2,y:(n.bottom-n.top)/2,width:t[0],height:t[1]};r.y+=(s-t[1])/2;const o=[t[0],s];return{view:r,size:o}}updateFogDistance(){const{center:t}=this.state,n=this.state.cameraConfig,i=ya(this.position,t);this.fogDistance=Math.max(n.minFogDistance,i)}updateViewMatrix(){la(this.viewMatrix,this.position,this.state.center,i1)}updateGlobeMatrix(){const t=this.globeMatrix,n=[0,0,0];oa(t);const i=oe.toGeo(this.state.center);Se(n,this.state.center[0],this.state.center[1],-this.state.center[2]-Hn*me),Rd(this.globeMatrix,t,n),ca(t,t,pe(i[1])),Bd(t,t,-pe(i[0]))}updateHorizonPixelOffset(){const{viewport:t,size:n,zoom:i}=this.state,s=this.flat.unproject([t.left,n[1]+t.top,0]),r=this.flat.unproject([t.left+n[0]/2,n[1]+t.top,0]),o=this.flat.unproject([n[0]+t.left,n[1]+t.top,0]);Gt(yt,o,s),$m(yt,yt,s1,pe(90)),zt(yt,yt);const a=zd(n[1]*this.state.cameraConfig.perspectiveDistanceLimitRatio,i);Tn(yt,yt,a),Vn(yt,r,yt),this.flat.project(yt,!1,yt),this.horizonPixelOffset=Math.max(0,Math.ceil(yt[1]))}}function ga(e,t,n,i,s,r,o=0){s[0]=(n[0]+i[0])/2,s[1]=(n[1]+i[1])/2;const a=e.project(n),c=e.project(i),l=e.project(s),d=In(l,t),f=In(a,t),u=In(c,t);if(d<r)return s;if(f<r)return n;if(u<r)return i;if(o>=10)return s;const h=f+d,y=u+d;return h>y?ga(e,t,i,s,s,r,o+1):ga(e,t,n,s,s,r,o+1)}function r1(e,t,n){n.zoom!==void 0&&(n.zoom=ge(n.zoom,e.minZoom,e.maxZoom));const i={...e};Ki(i.center);const s=new ns(i),r=s.unproject(t),o=oe.fromGeo(r);n.center&&Ki(n.center),s.setState({...e,...n});const a=oe.fromGeo(s.unproject(t));Math.abs(o[0]-a[0])>2**31&&(a[0]+=(o[0]>0?1:-1)*2**32);const c=rt();if(Gt(c,o,a),e.globeMode&&Math.abs(r[1])>70&&e.zoom>gn.globeInterStartZoom&&e.zoom<gn.globeMaxZoom){const l=Math.abs(e.zoom-n.zoom);if(l>1e-4){const d=Math.abs(o[0]-a[0]),f=Math.log10(d/l),u=Math.min(1,10**(6-f));Number.isNaN(u)||Tn(c,c,u)}}return c}function Zd(e){const n=oe.toGeo(e)[1],i=1/(2*Math.cos(pe(n)));return Math.log(i)/Math.log(2)}function o1(e,t){const n=oe.scaleFactor(t[1]);return 1+e*(n-1)}function Wd(e,t){const n=Zd(t)*na(9,10,e);return e+ge(n,-1,0)}function a1(e,t){const n=Zd(t),i=n*na(9,10+n,e);return e-ge(i,-1,0)}function c1(e,t,n,i,s,r,o={top:0,right:0,bottom:0,left:0},a={top:0,right:0,bottom:0,left:0},c,l){const d=_t,f=new ns({center:oe.fromGeo(e),zoom:t,rotation:pe(n),size:i,pitch:pe(s),viewport:o,padding:a,cameraConfig:d,globeMode:!1,styleState:{}}),u=oe.toGeo(f.flat.unproject(r)),h=oe.toGeo(f.flat.unproject([r[0]+c,r[1]+l]));return Math.max(1,ua(u,h))}function dr(e,t){return t*me*oe.scaleFactor(e[1])}function is(e,t){return{min:e||sa(1/0,1/0),max:t||sa(-1/0,-1/0)}}function l1(e){return is(oe.fromGeo(e.southWest),oe.fromGeo(e.northEast))}function Wn(e,t){um(e.min,e.min,t),hm(e.max,e.max,t)}function Xd(e,t){e.min[0]=t.min[0],e.max[0]=t.max[0],e.min[1]=t.min[1],e.max[1]=t.max[1]}function wa(e){e.min[0]=1/0,e.max[0]=-1/0,e.min[1]=1/0,e.max[1]=-1/0}function fr(e,t){return e[0]=t.min[0]+(t.max[0]-t.min[0])/2,e[1]=t.min[1]+(t.max[1]-t.min[1])/2,e}function d1(e,t,n){e[0]=ge(n[0],t.min[0],t.max[0]),e[1]=ge(n[1],t.min[1],t.max[1])}function f1(e,t,n){e[1]=ge(n[1],t.min[1],t.max[1])}function u1(e,t){return t[0]<=e.max[0]&&t[0]>=e.min[0]&&t[1]<=e.max[1]&&t[1]>=e.min[1]}function h1(e,t){return t[1]<=e.max[1]&&t[1]>=e.min[1]}function va(e,t,n=0){const i=e.min[0]+n<=t.max[0]-n&&t.min[0]+n<=e.max[0]-n,s=e.min[1]+n<=t.max[1]-n&&t.min[1]+n<=e.max[1]-n;return i&&s}function p1(e,t){return{min:[Math.max(e.min[0],t.min[0]),Math.max(e.min[1],t.min[1])],max:[Math.min(e.max[0],t.max[0]),Math.min(e.max[1],t.max[1])]}}function m1(e,t){const n=fr([],e),i=(e.max[0]-e.min[0])/2*t,s=(e.max[1]-e.min[1])/2*t;e.min[0]=n[0]-i,e.min[1]=n[1]-s,e.max[0]=n[0]+i,e.max[1]=n[1]+s}function qd(){let e=new lt(9);return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=1,e[5]=0,e[6]=0,e[7]=0,e[8]=1,e}function y1(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[4],e[4]=t[5],e[5]=t[6],e[6]=t[8],e[7]=t[9],e[8]=t[10],e}function ba(){let e=new lt(4);return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e}function g1(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e}function w1(e,t,n){n=n*.5;let i=Math.sin(n);return e[0]=i*t[0],e[1]=i*t[1],e[2]=i*t[2],e[3]=Math.cos(n),e}function v1(e,t,n){n*=.5;let i=t[0],s=t[1],r=t[2],o=t[3],a=Math.sin(n),c=Math.cos(n);return e[0]=i*c-r*a,e[1]=s*c+o*a,e[2]=r*c+i*a,e[3]=o*c-s*a,e}function b1(e,t,n){n*=.5;let i=t[0],s=t[1],r=t[2],o=t[3],a=Math.sin(n),c=Math.cos(n);return e[0]=i*c+s*a,e[1]=s*c-i*a,e[2]=r*c+o*a,e[3]=o*c-r*a,e}function ur(e,t,n,i){let s=t[0],r=t[1],o=t[2],a=t[3],c=n[0],l=n[1],d=n[2],f=n[3],u,h,y,w,p;return h=s*c+r*l+o*d+a*f,h<0&&(h=-h,c=-c,l=-l,d=-d,f=-f),1-h>1e-6?(u=Math.acos(h),y=Math.sin(u),w=Math.sin((1-i)*u)/y,p=Math.sin(i*u)/y):(w=1-i,p=i),e[0]=w*s+p*c,e[1]=w*r+p*l,e[2]=w*o+p*d,e[3]=w*a+p*f,e}function I1(e,t){let n=t[0]+t[4]+t[8],i;if(n>0)i=Math.sqrt(n+1),e[3]=.5*i,i=.5/i,e[0]=(t[5]-t[7])*i,e[1]=(t[6]-t[2])*i,e[2]=(t[1]-t[3])*i;else{let s=0;t[4]>t[0]&&(s=1),t[8]>t[s*3+s]&&(s=2);let r=(s+1)%3,o=(s+2)%3;i=Math.sqrt(t[s*3+s]-t[r*3+r]-t[o*3+o]+1),e[s]=.5*i,i=.5/i,e[3]=(t[r*3+o]-t[o*3+r])*i,e[r]=(t[r*3+s]+t[s*3+r])*i,e[o]=(t[o*3+s]+t[s*3+o])*i}return e}const Jd=Qm;(function(){let e=rt(),t=qe(1,0,0),n=qe(0,1,0);return function(i,s,r){let o=ma(s,r);return o<-.999999?(Qi(e,t,s),cr(e)<1e-6&&Qi(e,n,s),zt(e,e),w1(i,e,Math.PI),i):o>.999999?(i[0]=0,i[1]=0,i[2]=0,i[3]=1,i):(Qi(e,s,r),i[0]=e[0],i[1]=e[1],i[2]=e[2],i[3]=1+o,Jd(i,i))}})(),(function(){let e=ba(),t=ba();return function(n,i,s,r,o,a){return ur(e,i,o,a),ur(t,s,r,a),ur(n,e,t,2*a*(1-a)),n}})(),(function(){let e=qd();return function(t,n,i,s){return e[0]=i[0],e[3]=i[1],e[6]=i[2],e[1]=s[0],e[4]=s[1],e[7]=s[2],e[2]=-n[0],e[5]=-n[1],e[8]=-n[2],Jd(t,I1(t,e))}})();const jt=[0,0,0],Ht=[0,0,0],Ia=rt();qd();function Lt(e,t,n,i,s){if(t!==i||n!==s){const r=s-n,o=t-i,a=1/Math.sqrt(r*r+o*o);e[0]=r*a,e[1]=o*a}else e[0]=0,e[1]=0}function Kd(e,t,n,i){return Gt(jt,n,t),Gt(Ht,n,i),Qi(e,Ht,jt),zt(e,e),e}function Vt(e,t,n,i,s){if(t!==i||n!==s){const r=i-t,o=s-n,a=1/Math.sqrt(r*r+o*o);e[0]=r*a,e[1]=o*a}else e[0]=0,e[1]=0}function Qd(e,t,n,i,s){const r=t+i,o=n+s,a=t*r+n*o,c=5;if(a!==0){const l=1/a;e[0]=r*l,e[1]=o*l,ir(e)>c&&vn(e,e)}else e[0]=0,e[1]=0}function Ne(e){return ge(e*127,-127,127)}function Ma(e,t=e){return e[0]=Ne(t[0]),e[1]=Ne(t[1]),e}function M1(e,t,n,i,s){e[0]=t*i+n*s,e[1]=n*i-t*s}function Sn(e,t){const n=t[0];e[0]=-t[1],e[1]=n}function Ta(e,t){const n=t[0];e[0]=t[1],e[1]=-n}function T1(e){return e[0]===0&&e[1]===0}function S1(e,t){return Math.atan2(t[1]-e[1],t[0]-e[0])}function A1(e,t){return[(e[0]+t[0])/2,(e[1]+t[1])/2]}function E1(e,t){const n=Math.sin(t),i=Math.cos(t),s=i*e[0]-n*e[1],r=n*e[0]+i*e[1];Ce(e,s,r)}function x1(e,t,n,i,s=!0){if(sr(t,n)||sr(n,i)){Ce(e,0,0);return}Jt(jt,n,t),Jt(Ht,i,n),s?(Sn(jt,jt),Sn(Ht,Ht)):(Ta(jt,jt),Ta(Ht,Ht)),vn(jt,jt),vn(Ht,Ht),Pt(e,jt,Ht),vn(e,e)}function _1(e,t,n){t[0]=Mn(Se(Ia,e[0],e[1],e[2])),t[1]=Mn(Se(Ia,e[3],e[4],e[5])),t[2]=Mn(Se(Ia,e[6],e[7],e[8]))}function P1(e,t,n,i){t[0]=Mn(qe(e[0],e[1],e[2])),t[1]=Mn(qe(e[4],e[5],e[6])),t[2]=Mn(qe(e[8],e[9],e[10])),n[0]=e[12],n[1]=e[13],n[2]=e[14]}function L1(e,t,n,i){const[s,r]=e,[o,a]=t,[c,l]=n;return i[0]=Math.min(Math.max(s,o),c),i[1]=Math.min(Math.max(r,a),l),i[2]=0,i}const Sa=/\{(\w+)\}/g;function ss(e,t){return e.replace(Sa,(n,i)=>t[i])}function ef(e){const[t,n]=e.split("?");if(!n)return t;const s=n.split("&").map(r=>r.split("=")).filter(([,r])=>r!=="undefined").map(r=>r.join("=")).join("&");return s.length?`${t}?${s}`:t}function D1(e,t){return(typeof e=="object"?e.url:Ks[e]).replace(Sa,(n,i)=>t[i]??n).replace(Sa,(n,i)=>t[i]??n)}function rs(e,t){const n=ss(t.host,{subdomain:t.subdomain}),i=ss(typeof e=="object"?e.url:Ks[e],{...t,host:n});return ef(i)}function os(e,t){const n=ss(e,t);return ef(n)}function Aa(e,t){let n=0;for(let i=0;i<t.length;i++)n+=t.charCodeAt(i);return e[n%e.length]}function O1(e,t){const n=new URL(t);return e.startsWith("//")?`${n.protocol}${e}`:e.startsWith("/")?`${n.origin}${e}`:e}for(var Ti="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",C1=typeof Uint8Array>"u"?[]:new Uint8Array(256),hr=0;hr<Ti.length;hr++)C1[Ti.charCodeAt(hr)]=hr;var tf=function(e){var t=new Uint8Array(e),n,i=t.length,s="";for(n=0;n<i;n+=3)s+=Ti[t[n]>>2],s+=Ti[(t[n]&3)<<4|t[n+1]>>4],s+=Ti[(t[n+1]&15)<<2|t[n+2]>>6],s+=Ti[t[n+2]&63];return i%3===2?s=s.substring(0,s.length-1)+"=":i%3===1&&(s=s.substring(0,s.length-2)+"=="),s};function F1(e){let t=0;for(let n=0;n<e.length;n++)t+=e[n]*256**(e.length-1-n);return t}function nf(e){const t=new Uint8Array(6);for(let n=0;n<6;n++)t[n]=Math.floor(e/256**(5-n))&255;return encodeURIComponent(tf(t.buffer))}function N1(e,t){const n={};e.forEach((s,r)=>{n[s]=r});let i=e.length;n.selected=n.selected??i++,n.hovered=n.hovered??i++,n.dpi=n.dpi??i++,n.isRealtime=n.isRealtime??i++,n.pixelDensityPreset=n.pixelDensityPreset??i++,n.tier=n.tier??i++;for(const s in t)n[s]===void 0&&(n[s]=i++);return n}function sf(e){const t=N1(e.tileProps,e.defaultProps),n={};for(const i in e.defaultProps)n[i]={index:t[i],value:e.defaultProps[i]};return{version:e.version,dictionaries:e.enumerationValues,reverseDictionaries:Object.keys(e.enumerationValues).reduce((i,s)=>(i[s]=ta(e.enumerationValues[s]),i),{}),tileProps:t,tilePropsByIndex:ta(t),defaultProps:n,vertexPropsLegacy:xa(e.vertexProps)?R1(e):{},vertexProps:xa(e.vertexProps)?[]:e.vertexProps}}function R1(e){const t=e.vertexProps,n={point:["x","y","z"],polygon:["x","y","cut","signed_z"],polyline:["x","y"]};if(!t)return n;if(!xa(t))return console.warn(`Попытка сгенерировать vertexPropsLegacy для метатайла версии ${e.version}`),{};const i={0:"point",1:"polyline",2:"polygon"};return Object.keys(t).forEach(s=>{const r=i[s];if(typeof r>"u"){console.warn(`Неизвестный тип геометрии "${s}", нужно его поддержать`);return}n[r]=t[parseInt(s,10)]}),n}function rf(e,t){const n={};if(t)for(let i=0;i<t.length;i++)n[t[i]]=i;return sf({enumerationValues:{db_sublayer:n},version:"7.0.0",defaultProps:{},tileProps:e,vertexProps:[]})}function as(e,t){const{tileProps:n}=e;let i=Object.keys(n).length;for(const s of t)n[s]===void 0&&(n[s]=i,i+=1)}let de=0;const Xn={beginningIsCut:de++,class:de++,componentDistanceEnd:de++,componentDistanceStart:de++,db_icon_priority:de++,db_label_priority:de++,db_label2_priority:de++,dpi:de++,endingIsCut:de++,height:de++,db_hidden_by_plan_building_id:de++,db_hidden_by_plan_id:de++,id:de++,isRealtime:de++,db_label:de++,db_label2:de++,nextPointX:de++,nextPointY:de++,db_object_class:de++,objectLength:de++,pixelDensityPreset:de++,previousPointX:de++,previousPointY:de++,db_region:de++,selected:de++,hovered:de++,db_sublayer:de++,traffic_color:de++,traffic_road_class:de++,traffic_road_z_level:de++,db_tiers:de++,model_src:de++,linkedIds:de++,db_model_rotation_angle:de++,db_plan_id:de++,traffic_color2:de++},B1={version:"5.0.0",tileProps:Xn,tilePropsByIndex:ta(Xn),defaultProps:{},dictionaries:{},reverseDictionaries:{},vertexPropsLegacy:{},vertexProps:[]},of=[],Ea={},af={sourceName:"zenith"};function xa(e){return!Array.isArray(e)}class _a{constructor(){this.events={}}on(t,n){let i=this.events[t];return i||(i=this.events[t]=[]),i.push(n),this}once(t,n){const i=s=>{this.off(t,i),n.call(this,s)};return this.on(t,i),this}off(t,n){const i=this.events[t];if(!i)return this;const s=i.indexOf(n);return s!==-1&&i.splice(s,1),this}emit(t,n){const i=this.events[t];if(!i)return this;const s=i.slice();for(let r=0;r<s.length;r++)s[r].call(this,n);return this}}let k1=1;function Pa(){return k1++}let U1=1;const La=()=>++U1,z1=La(),G1=La(),Da=65536*65536,cf=1/Da,j1=12,lf=typeof TextDecoder>"u"?null:new TextDecoder("utf-8"),Oa=0,pr=1,cs=2,mr=5;class yr{constructor(t=new Uint8Array(16)){this.buf=ArrayBuffer.isView(t)?t:new Uint8Array(t),this.dataView=new DataView(this.buf.buffer),this.pos=0,this.type=0,this.length=this.buf.length}readFields(t,n,i=this.length){for(;this.pos<i;){const s=this.readVarint(),r=s>>3,o=this.pos;this.type=s&7,t(r,n,this),this.pos===o&&this.skip(s)}return n}readMessage(t,n){return this.readFields(t,n,this.readVarint()+this.pos)}readFixed32(){const t=this.dataView.getUint32(this.pos,!0);return this.pos+=4,t}readSFixed32(){const t=this.dataView.getInt32(this.pos,!0);return this.pos+=4,t}readFixed64(){const t=this.dataView.getUint32(this.pos,!0)+this.dataView.getUint32(this.pos+4,!0)*Da;return this.pos+=8,t}readSFixed64(){const t=this.dataView.getUint32(this.pos,!0)+this.dataView.getInt32(this.pos+4,!0)*Da;return this.pos+=8,t}readFloat(){const t=this.dataView.getFloat32(this.pos,!0);return this.pos+=4,t}readDouble(){const t=this.dataView.getFloat64(this.pos,!0);return this.pos+=8,t}readVarint(t){const n=this.buf;let i,s;return s=n[this.pos++],i=s&127,s<128||(s=n[this.pos++],i|=(s&127)<<7,s<128)||(s=n[this.pos++],i|=(s&127)<<14,s<128)||(s=n[this.pos++],i|=(s&127)<<21,s<128)?i:(s=n[this.pos],i|=(s&15)<<28,H1(i,t,this))}readVarint64(){return this.readVarint(!0)}readSVarint(){const t=this.readVarint();return t%2===1?(t+1)/-2:t/2}readBoolean(){return!!this.readVarint()}readString(){const t=this.readVarint()+this.pos,n=this.pos;return this.pos=t,t-n>=j1&&lf?lf.decode(this.buf.subarray(n,t)):ny(this.buf,n,t)}readBytes(){const t=this.readVarint()+this.pos,n=this.buf.subarray(this.pos,t);return this.pos=t,n}readPackedVarint(t=[],n){const i=this.readPackedEnd();for(;this.pos<i;)t.push(this.readVarint(n));return t}readPackedSVarint(t=[]){const n=this.readPackedEnd();for(;this.pos<n;)t.push(this.readSVarint());return t}readPackedBoolean(t=[]){const n=this.readPackedEnd();for(;this.pos<n;)t.push(this.readBoolean());return t}readPackedFloat(t=[]){const n=this.readPackedEnd();for(;this.pos<n;)t.push(this.readFloat());return t}readPackedDouble(t=[]){const n=this.readPackedEnd();for(;this.pos<n;)t.push(this.readDouble());return t}readPackedFixed32(t=[]){const n=this.readPackedEnd();for(;this.pos<n;)t.push(this.readFixed32());return t}readPackedSFixed32(t=[]){const n=this.readPackedEnd();for(;this.pos<n;)t.push(this.readSFixed32());return t}readPackedFixed64(t=[]){const n=this.readPackedEnd();for(;this.pos<n;)t.push(this.readFixed64());return t}readPackedSFixed64(t=[]){const n=this.readPackedEnd();for(;this.pos<n;)t.push(this.readSFixed64());return t}readPackedEnd(){return this.type===cs?this.readVarint()+this.pos:this.pos+1}skip(t){const n=t&7;if(n===Oa)for(;this.buf[this.pos++]>127;);else if(n===cs)this.pos=this.readVarint()+this.pos;else if(n===mr)this.pos+=4;else if(n===pr)this.pos+=8;else throw new Error(`Unimplemented type: ${n}`)}writeTag(t,n){this.writeVarint(t<<3|n)}realloc(t){let n=this.length||16;for(;n<this.pos+t;)n*=2;if(n!==this.length){const i=new Uint8Array(n);i.set(this.buf),this.buf=i,this.dataView=new DataView(i.buffer),this.length=n}}finish(){return this.length=this.pos,this.pos=0,this.buf.subarray(0,this.length)}writeFixed32(t){this.realloc(4),this.dataView.setInt32(this.pos,t,!0),this.pos+=4}writeSFixed32(t){this.realloc(4),this.dataView.setInt32(this.pos,t,!0),this.pos+=4}writeFixed64(t){this.realloc(8),this.dataView.setInt32(this.pos,t&-1,!0),this.dataView.setInt32(this.pos+4,Math.floor(t*cf),!0),this.pos+=8}writeSFixed64(t){this.realloc(8),this.dataView.setInt32(this.pos,t&-1,!0),this.dataView.setInt32(this.pos+4,Math.floor(t*cf),!0),this.pos+=8}writeVarint(t){if(t=+t||0,t>268435455||t<0){V1(t,this);return}this.realloc(4),this.buf[this.pos++]=t&127|(t>127?128:0),!(t<=127)&&(this.buf[this.pos++]=(t>>>=7)&127|(t>127?128:0),!(t<=127)&&(this.buf[this.pos++]=(t>>>=7)&127|(t>127?128:0),!(t<=127)&&(this.buf[this.pos++]=t>>>7&127)))}writeSVarint(t){this.writeVarint(t<0?-t*2-1:t*2)}writeBoolean(t){this.writeVarint(+t)}writeString(t){t=String(t),this.realloc(t.length*4),this.pos++;const n=this.pos;this.pos=iy(this.buf,t,this.pos);const i=this.pos-n;i>=128&&df(n,i,this),this.pos=n-1,this.writeVarint(i),this.pos+=i}writeFloat(t){this.realloc(4),this.dataView.setFloat32(this.pos,t,!0),this.pos+=4}writeDouble(t){this.realloc(8),this.dataView.setFloat64(this.pos,t,!0),this.pos+=8}writeBytes(t){const n=t.length;this.writeVarint(n),this.realloc(n);for(let i=0;i<n;i++)this.buf[this.pos++]=t[i]}writeRawMessage(t,n){this.pos++;const i=this.pos;t(n,this);const s=this.pos-i;s>=128&&df(i,s,this),this.pos=i-1,this.writeVarint(s),this.pos+=s}writeMessage(t,n,i){this.writeTag(t,cs),this.writeRawMessage(n,i)}writePackedVarint(t,n){n.length&&this.writeMessage(t,Z1,n)}writePackedSVarint(t,n){n.length&&this.writeMessage(t,W1,n)}writePackedBoolean(t,n){n.length&&this.writeMessage(t,J1,n)}writePackedFloat(t,n){n.length&&this.writeMessage(t,X1,n)}writePackedDouble(t,n){n.length&&this.writeMessage(t,q1,n)}writePackedFixed32(t,n){n.length&&this.writeMessage(t,K1,n)}writePackedSFixed32(t,n){n.length&&this.writeMessage(t,Q1,n)}writePackedFixed64(t,n){n.length&&this.writeMessage(t,ey,n)}writePackedSFixed64(t,n){n.length&&this.writeMessage(t,ty,n)}writeBytesField(t,n){this.writeTag(t,cs),this.writeBytes(n)}writeFixed32Field(t,n){this.writeTag(t,mr),this.writeFixed32(n)}writeSFixed32Field(t,n){this.writeTag(t,mr),this.writeSFixed32(n)}writeFixed64Field(t,n){this.writeTag(t,pr),this.writeFixed64(n)}writeSFixed64Field(t,n){this.writeTag(t,pr),this.writeSFixed64(n)}writeVarintField(t,n){this.writeTag(t,Oa),this.writeVarint(n)}writeSVarintField(t,n){this.writeTag(t,Oa),this.writeSVarint(n)}writeStringField(t,n){this.writeTag(t,cs),this.writeString(n)}writeFloatField(t,n){this.writeTag(t,mr),this.writeFloat(n)}writeDoubleField(t,n){this.writeTag(t,pr),this.writeDouble(n)}writeBooleanField(t,n){this.writeVarintField(t,+n)}}function H1(e,t,n){const i=n.buf;let s,r;if(r=i[n.pos++],s=(r&112)>>4,r<128||(r=i[n.pos++],s|=(r&127)<<3,r<128)||(r=i[n.pos++],s|=(r&127)<<10,r<128)||(r=i[n.pos++],s|=(r&127)<<17,r<128)||(r=i[n.pos++],s|=(r&127)<<24,r<128)||(r=i[n.pos++],s|=(r&1)<<31,r<128))return Si(e,s,t);throw new Error("Expected varint not more than 10 bytes")}function Si(e,t,n){return n?t*4294967296+(e>>>0):(t>>>0)*4294967296+(e>>>0)}function V1(e,t){let n,i;if(e>=0?(n=e%4294967296|0,i=e/4294967296|0):(n=~(-e%4294967296),i=~(-e/4294967296),n^4294967295?n=n+1|0:(n=0,i=i+1|0)),e>=18446744073709552e3||e<-18446744073709552e3)throw new Error("Given varint doesn't fit into 10 bytes");t.realloc(10),$1(n,i,t),Y1(i,t)}function $1(e,t,n){n.buf[n.pos++]=e&127|128,e>>>=7,n.buf[n.pos++]=e&127|128,e>>>=7,n.buf[n.pos++]=e&127|128,e>>>=7,n.buf[n.pos++]=e&127|128,e>>>=7,n.buf[n.pos]=e&127}function Y1(e,t){const n=(e&7)<<4;t.buf[t.pos++]|=n|((e>>>=3)?128:0),e&&(t.buf[t.pos++]=e&127|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=e&127|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=e&127|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=e&127|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=e&127)))))}function df(e,t,n){const i=t<=16383?1:t<=2097151?2:t<=268435455?3:Math.floor(Math.log(t)/(Math.LN2*7));n.realloc(i);for(let s=n.pos-1;s>=e;s--)n.buf[s+i]=n.buf[s]}function Z1(e,t){for(let n=0;n<e.length;n++)t.writeVarint(e[n])}function W1(e,t){for(let n=0;n<e.length;n++)t.writeSVarint(e[n])}function X1(e,t){for(let n=0;n<e.length;n++)t.writeFloat(e[n])}function q1(e,t){for(let n=0;n<e.length;n++)t.writeDouble(e[n])}function J1(e,t){for(let n=0;n<e.length;n++)t.writeBoolean(e[n])}function K1(e,t){for(let n=0;n<e.length;n++)t.writeFixed32(e[n])}function Q1(e,t){for(let n=0;n<e.length;n++)t.writeSFixed32(e[n])}function ey(e,t){for(let n=0;n<e.length;n++)t.writeFixed64(e[n])}function ty(e,t){for(let n=0;n<e.length;n++)t.writeSFixed64(e[n])}function ny(e,t,n){let i="",s=t;for(;s<n;){const r=e[s];let o=null,a=r>239?4:r>223?3:r>191?2:1;if(s+a>n)break;let c,l,d;a===1?r<128&&(o=r):a===2?(c=e[s+1],(c&192)===128&&(o=(r&31)<<6|c&63,o<=127&&(o=null))):a===3?(c=e[s+1],l=e[s+2],(c&192)===128&&(l&192)===128&&(o=(r&15)<<12|(c&63)<<6|l&63,(o<=2047||o>=55296&&o<=57343)&&(o=null))):a===4&&(c=e[s+1],l=e[s+2],d=e[s+3],(c&192)===128&&(l&192)===128&&(d&192)===128&&(o=(r&15)<<18|(c&63)<<12|(l&63)<<6|d&63,(o<=65535||o>=1114112)&&(o=null))),o===null?(o=65533,a=1):o>65535&&(o-=65536,i+=String.fromCharCode(o>>>10&1023|55296),o=56320|o&1023),i+=String.fromCharCode(o),s+=a}return i}function iy(e,t,n){for(let i=0,s,r;i<t.length;i++){if(s=t.charCodeAt(i),s>55295&&s<57344)if(r)if(s<56320){e[n++]=239,e[n++]=191,e[n++]=189,r=s;continue}else s=r-55296<<10|s-56320|65536,r=null;else{s>56319||i+1===t.length?(e[n++]=239,e[n++]=191,e[n++]=189):r=s;continue}else r&&(e[n++]=239,e[n++]=191,e[n++]=189,r=null);s<128?e[n++]=s:(s<2048?e[n++]=s>>6|192:(s<65536?e[n++]=s>>12|224:(e[n++]=s>>18|240,e[n++]=s>>12&63|128),e[n++]=s>>6&63|128),e[n++]=s&63|128)}return n}Array(16);function qn(e,t){return{a:e[1]-t[1],b:t[0]-e[0],c:e[0]*t[1]-t[0]*e[1]}}function sy(e,t){return Math.abs(ff(e,t))}function ff(e,t){return(t.a*e[0]+t.b*e[1]+t.c)/Math.sqrt(t.a*t.a+t.b*t.b)}function ry(e,t,n){const{a:i,b:s,c:r}=qn(e,t);return qe(n,-(i*n+r)/s,0)}function oy(e,t,n){const{a:i,b:s,c:r}=qn(e,t);return qe(-(s*n+r)/i,n,0)}const Jn=is(),ot=is();function ay(e,t,n){const i=t[t.length-1]*n;let s=e[0],r=0;const o=[s];let a=1,c;for(;a<e.length&&!c;){const l=e[a],d=t[a];let f=l;if(d>i){if(!c){const u=(i-r)/(d-r);c=[],Cd(c,s,l,u)}f=c}o.push(f),s=f,r=t[a],a++}return o}function cy(e,t){let n=e[0];wa(Jn),Wn(Jn,n);let i=[n];const s=[i];let r=1;for(;r<e.length;){const o=e[r];let a=!1,c=o;if(Xd(ot,Jn),Wn(ot,c),ot.max[0]-ot.min[0]>t){const l=ot.max[0]===c[0]?ot.min[0]+t:ot.max[0]-t;c=ry(n,c,l),a=!0}if(a&&(Xd(ot,Jn),Wn(ot,c)),ot.max[1]-ot.min[1]>t){const l=ot.max[1]===c[1]?ot.min[1]+t:ot.max[1]-t;c=oy(n,c,l),a=!0}a?(i.push(c),wa(Jn),Wn(Jn,c),i=[c],s.push(i),n=c):(i.push(o),Wn(Jn,o),n=o,r++)}return s}function ly(e,t,n){const i=e[0]-t[0],s=e[1]-t[1],r=n[0]-t[0],o=n[1]-t[1],a=i*r+s*o,c=r*r+o*o,l=c!==0?a/c:0;return l<0?t:l>1?n:[t[0]+l*r,t[1]+l*o]}function gr(e){const t=e[0][0],n=e[0][1],i=e[1][0],s=e[1][1],r=e[2][0],o=e[2][1],a=e[3][0],c=e[3][1];return{min:[Math.min(t,i,r,a),Math.min(n,s,o,c)],max:[Math.max(t,i,r,a),Math.max(n,s,o,c)]}}function dy(e){return[[e[0][0],e[0][1],e[0][2]],[e[1][0],e[1][1],e[1][2]],[e[2][0],e[2][1],e[2][2]],[e[3][0],e[3][1],e[3][2]]]}function uf(e,t){const n=gr(e);if(!va(t,n))return!1;const i=[qn(e[3],e[2]),qn(e[1],e[0]),qn(e[0],e[3]),qn(e[2],e[1])],s=[t.min,t.max,[t.min[0],t.max[1]],[t.max[0],t.min[1]]];for(const r of i){let o=!0;for(let a=0;a<s.length;a++){const c=s[a];if(r.a*c[0]+r.b*c[1]+r.c<0){o=!1;break}}if(o)return!1}return!0}function fy(e,t,n){e.forEach(i=>{const s=1+t/Hd(n,i);$n(i,n,i,s)})}function uy(e,t){if(e.tiles)for(const n of e.tiles)t.writeMessage(1,hy,n)}function hy(e,t){e.x&&t.writeVarintField(1,e.x),e.y&&t.writeVarintField(2,e.y),e.zoom&&t.writeVarintField(3,e.zoom)}function py(e,t){return e.readFields(my,{tileGroups:[]},t)}function my(e,t,n){e===1&&t.tileGroups.push(yy(n,n.readVarint()+n.pos))}function yy(e,t){return e.readFields(gy,{x:0,y:0,zoom:0,tiles:[]},t)}function gy(e,t,n){e===1?t.x=n.readVarint():e===2?t.y=n.readVarint():e===3?t.zoom=n.readVarint():e===4&&t.tiles.push(wy(n,n.readVarint()+n.pos))}function wy(e,t){return e.readFields(vy,{regionId:0,hash:void 0,data:void 0},t)}function vy(e,t,n){e===1?t.regionId=n.readVarint():e===2?t.hash=n.readBytes():e===3&&(t.data=n.readBytes())}const Ai=[0,0,0];function Je(e){return{coords:e,size:wt(e[2]),offset:xi(e)}}function Ie(e){return hf(e[0],e[1],e[2],e[3])}function hf(e,t,n,i){return`${e}_${t}_${n}_${i}`}function by(e,t){return`${Ie(e)}_${t.stringify()}`}function Ca(e){const t=e.split("_");return[parseInt(t[0],10),parseInt(t[1],10),parseInt(t[2],10),parseInt(t[3],10)]}function pf(e){return Gn.subdomains[Math.abs(e[0]+e[1])%Gn.subdomains.length]}function Iy(e){const t=new yr(e),n=py(t),{x:i,y:s,zoom:r,tiles:o}=n.tileGroups[0];return o.map(({regionId:a,hash:c,data:l})=>(l||(console.warn(`Tile ${r}_${i}_${s} from region ${a} is corrupt (has no data)`),l=new Uint8Array(0)),{data:l,regionId:a,metatileHash:F1(c)}))}function My(e){return e.map(t=>({regionId:t.regionId,metatileHash:t.metatileHash}))}function Ty(e){const t=Math.ceil(e.byteLength/4)*4,n=new ArrayBuffer(t);return new Uint8Array(n).set(e),n}function wr(e){const[t,n,i]=e;return{min:xi([t,n,i,i]),max:xi([t+1,n+1,i,i])}}function Sy(e,t){return va(wr(e),wr(t),.001)}function vr(e,t,n,i=0){const s=wr(e);return s.min[0]-=i,s.min[1]-=i,s.max[0]+=i,s.max[1]+=i,n.environmentManager.isAABBInFog(s)?!1:uf(t,s)}function Ay(e){return Math.trunc(e/2)*2+1}function Fa(e,t=1,n=3,i=!1){let s=1/Math.cos(pe(e));return i&&(s=Math.log2(s)),ge(Math.ceil(s),t,n)-1}const Ey=(e,t)=>(isNaN(e[0])||e[0]===t[0])&&(isNaN(e[1])||e[1]===t[1])&&(isNaN(e[2])||e[2]===t[2])&&(isNaN(e[3])||e[3]===t[3]);function mf(e,t,n){const i=xy(t,e.size),s=Math.trunc(t),r=Array.from(e.center);Ki(r);const o=oe.toGeo(r),a={min:[o[0]-ge(i*2,0,90),ge(o[1]-i,-85,85)],max:[o[0]+ge(i*2,0,90),ge(o[1]+i,-85,85)]},c=Math.max(Fa(a.min[1],2,4),Fa(a.max[1],2,4)),l=Math.max(n,s-c),d=Ra(r,l,!0);d[0]=Math.round(d[0]),d[1]=Math.round(d[1]);const f=new ns(e),u=yf(e,f,o),h=Uy(d,o,u,f,e),y=[];return h.forEach(w=>{Ey([NaN,2,2,NaN],w)?y.push(...vf(w,1)):y.push(w)}),y.filter(w=>Sr(e,f,w))}function xy(e,t){const n=Hn*me,i=Mi(e,t)+n,s=_t.fov/2,r=Math.sin(s),o=Math.cos(s),a=n/i;let c=jn(Math.acos(r**2/a+o*Math.sqrt(1-r**2/a**2)));return Number.isNaN(c)&&(c=90),c}function yf(e,t,n){const i=Ve.toGeo(t.ecef.unproject([e.viewport.left,e.viewport.top]));return Math.min(3*Math.max(ar(i,n)),t.ecef.visibleArc)}function _y(e,t,n,i,s,r){const[,,o]=e,a=Ly(e),c=i>=5?2:1,l=Fa((a.max[1]+a.min[1])/2,c,3,!0),d=Math.max(Math.abs(a.min[1]),Math.abs(a.max[1])),f=Math.max(n,i-l);return o>=f||d>70&&r>0||d>82||ar(t,[(a.max[0]+a.min[0])/2,(a.max[1]+a.min[1])/2])>.75*s}function Py(e,t){const i=Math.trunc(e.zoom),s=Array.from(e.center);Ki(s),oe.toGeo(s,s);const r=[],o=new ns(e),a=yf(e,o,s);function c(l,d=0){if(Af(s,a,l)&&Sr(e,o,l))if(_y(l,s,2,i,o.ecef.visibleArc,d))r.push(l);else for(const f of vf(l,1))c(f,d+1)}return mf(e,Math.trunc(e.zoom),2).map(([l,d,f])=>{c([l,d,f,t])}),r}function Ly(e){return{min:gf(e),max:gf([e[0]+1,e[1]+1,e[2],e[3]])}}function gf(e){const t=xi(e);return oe.toGeo(t)}function wf(e,t,n,i,s,r=0,o=1/0,a=!1,c=!1){if(e.globeMode)return Py(e,s);a&&(n=Ay(n),n>o&&(n-=2));const l=gr(e.tilesBounds),d=wt(n),f=2**n,u=Math.floor((l.min[0]+2147483648-r)/d),h=Math.floor((l.max[0]+2147483648+r)/d),y=Math.max(Math.floor((l.min[1]+2147483648-r)/d),0),w=Math.min(Math.floor((l.max[1]+2147483648+r)/d),f-1),p=[],g=new Set;for(let b=u;b<=h;b++)for(let v=y;v<=w;v++){const M=[b,v,n,s];if(vr(M,e.tilesBounds,t,r)){M[0]=(f+M[0]%f)%f;const E=Ie(M);g.has(E)||(g.add(E),p.push(M))}}return c===!0&&Dy(p,g,e,t,n,i,s),p}function Dy(e,t,n,i,s,r,o){const a=new Set,c=dy(n.tilesBounds);let l=e;for(let d=s;d>=r;d--){let f=0;const u=[];l.forEach(M=>{const E=Oy(M),T=Ie(E);a.has(T)||(u.push(E),a.add(T),Cy(E,L=>{const A=Ie(L);!t.has(A)&&!a.has(A)&&vr(L,n.extendedTilesBounds,i)&&(e.push(L),t.add(A),f++)}))});const h=wt(d-1);fy(c,h,n.center);const y=gr(c),w=2**(d-1),p=Math.floor((y.min[0]+2147483648)/h),g=Math.floor((y.max[0]+2147483648)/h),b=Math.max(Math.floor((y.min[1]+2147483648)/h),0),v=Math.min(Math.floor((y.max[1]+2147483648)/h),w-1);for(let M=p;M<=g;M++)for(let E=b;E<=v;E++){const T=[M,E,d-1,o];T[0]=(w+T[0]%w)%w;const L=Ie(T);!a.has(L)&&vr(T,c,i)&&(u.push(T),f++)}if(!f)break;l=u}}function Oy(e,t=1){const[n,i,s,r]=e,o=Math.pow(2,t);return[Math.trunc(n/o),Math.trunc(i/o),s-t,r]}function vf(e,t){const[n,i,s,r]=e,o=Math.pow(2,t),a=[];for(let c=0;c<o;c++)for(let l=0;l<o;l++)a.push([n*o+c,i*o+l,s+t,r]);return a}function Cy(e,t){let[n,i,s]=e;const r=e[3];n*=2,i*=2,s++,t([n,i,s,r]),t([n+1,i,s,r]),t([n,i+1,s,r]),t([n+1,i+1,s,r])}function Fy(e,t,n,i,s,r,o,a,c,l,d,f){const u=new yr,h={tiles:[{x:s[0],y:s[1],zoom:s[2]}]};uy(h,u);const y={x:s[0].toString(),y:s[1].toString(),z:s[2].toString(),protocol:n,host:e,subdomain:i[Math.abs(s[0]+s[1])%i.length],tileSet:t,lang:a,appId:o,tileKey:r,sessionId:d,defaultLang:l,dt:f?.join(","),request:encodeURIComponent(tf(u.finish()))};return rs(c?{url:c}:"tiles",y)}function Ny(e,t){const n=e.coords,i=t.coords,s=n[2],r=i[2];return s===r?n[0]===i[0]&&n[1]===i[1]:s<r?bf(e,t):bf(t,e)}function bf(e,t){if(t.zoomLevel<e.zoomLevel)return!1;if(t.zoomLevel===e.zoomLevel)return t.coords[0]===e.coords[0]&&t.coords[1]===e.coords[1]&&t.detailLevel>e.detailLevel;const n=Math.pow(2,t.coords[2]-e.coords[2]),i=e.coords[0]*n,s=i+n,r=e.coords[1]*n,o=r+n,a=t.coords[0],c=t.coords[1];return a>=i&&a<s&&c>=r&&c<o}function br(e,t,n){return qi(e,Sf(t.coords,Ai))-qi(e,Sf(n.coords,Ai))}function dt(e,t,n){e[0]=t[0]*n.size/ne+n.offset[0],e[1]=t[1]*n.size/ne+n.offset[1],e[2]=t[2]}const Ir=rt();function If(e,t,n,i){Ir[0]=t[0][n],Ir[1]=t[1][n],Ir[2]=(t[2]??[])[n],dt(e,Ir,i)}function gt(e,t,n){e[0]=(t[0]-n.offset[0])*ne/n.size,e[1]=(t[1]-n.offset[1])*ne/n.size,e[2]=t[2]}function wt(e){return 2**(32-e)}function Na(e){return e[0]>=0&&e[0]<=ne&&e[1]>=0&&e[1]<=ne}function Ei(e,t){return e*4294967296/(ne*Math.pow(2,t))}function $e(e){return ge(e/Zi*ne,0,Oe)}const Mf=ne/Zi;function Tf(e){return e/ne*Zi}function xi(e){const t=wt(e[2]),n=2147483648;return qe(e[0]*t-n,e[1]*t-n,0)}function Ry(e){return[e[0]+2147483648,e[1]+2147483648,32,32]}function Sf(e,t){const n=wt(e[2]),i=2147483648;return Se(t,(e[0]+.5)*n-i,(e[1]+.5)*n-i,0)}function Ra(e,t,n=!1){const s=wt(t),r=n?Math.min(2147483647,e[1]):e[1],o=e[0]-s/2,a=r-s/2;return[(o+2147483648)/s,(a+2147483648)/s,t,t]}function By(e,t=1){const n=Math.max(e.max[0]-e.min[0],e.max[1]-e.min[1],1)*t,i=32-Math.log(n)/Math.LN2,s=Ae();return fr(s,e),Ra(s,i)}const Mr=e=>{const[t,n,i,s]=e;return[t,2**i-1-n,i,s]},vt=(e,t)=>{dt(Ai,t,e);const n=oe.toGeo(Ai);return oe.scaleFactor(n[1])};function ls(e,t,n){return dt(Ai,[e,t],n),oe.toGeo(Ai)}function ky(e,t){const n=Math.min(e[0][0],e[1][0],e[2][0],e[3][0])+2147483648,i=Math.max(e[0][0],e[1][0],e[2][0],e[3][0])+2147483648,s=Math.floor(n/4294967296),r=Math.floor(i/4294967296);return t?[s]:Array.from({length:r-s+1},(o,a)=>a+s)}function Ba(e,t){return Ve.fromGeo(ls(t[0],t[1],e))}function An(e,t,n,i){const s=[];return dt(s,i,n),ar(oe.toGeo(s),e)<t}function Af(e,t,n){const i=Je(n),s=ne;return An(e,t,i,[0,s/2,0])||An(e,t,i,[s,s/2,0])||An(e,t,i,[s/2,s,0])||An(e,t,i,[s/2,0,0])||An(e,t,i,[0,0,0])||An(e,t,i,[0,s,0])||An(e,t,i,[s,s,0])||An(e,t,i,[s,0,0])}function Tr(e,t,n){const i=[];return dt(i,n,t),e.ecef.project(Ve.fromGeo(oe.toGeo(i)))}function Sr(e,t,n){const[,i,s]=n;if(i===0||i===2**s-1)return!0;const r=Je(n),o=ne,a=[Tr(t,r,[0,0,0]),Tr(t,r,[0,o,0]),Tr(t,r,[o,o,0]),Tr(t,r,[o,0,0])],c=a.map(u=>u[0]),l=a.map(u=>u[1]),d={min:[Math.min(...c),Math.min(...l)],max:[Math.max(...c),Math.max(...l)]},f={min:[e.viewport.left,e.viewport.top],max:[e.viewport.left+e.size[0],e.viewport.top+e.size[1]]};return va(d,f)}function Uy(e,t,n,i,s){const a=new Map,c=[e],l=[];for(l.push(e);c.length;){if(l.length>300){console.warn("collectVisibleGlobeTiles: too many tiles",l.length);break}if(c.length>500){console.warn("collectVisibleGlobeTiles: queue overflow");break}const d=c.shift();if(d){const[f,u,h]=d;a.set(f+"."+u+"."+h,!0),zy(d,a,t,n).filter(w=>Sr(s,i,w)).forEach(w=>{const[p,g,b]=w;a.set(p+"."+g+"."+b,!0),l.push(w),c.push(w)})}}return l}function zy(e,t,n,i){const[s,r,o,a]=e,c=2**o-1,l=p=>p>c?0:p<0?c:p,d=([p,g,b,v])=>((g>c||g<0)&&(g=g>c?c:0,p=b===0?p:(p+2**(b-1))%2**b),[p,g,b,v]),f=[l(s-1),r,o,a],u=[l(s+1),r,o,a],h=d([s,r-1,o,a]),y=d([s,r+1,o,a]);return[u,y,h,f].filter(p=>{const[g,b,v]=p;return!t.has(g+"."+b+"."+v)}).filter(p=>Af(n,i,p))}function Gy(e,t,n,i=0){return""}var ka=(e=>(e[e.Tile=0]="Tile",e[e.Custom=1]="Custom",e))(ka||{});class jy{constructor(t){this._enable=!1,this.name=t.name,this.index=t.index,this.location=t.location!==void 0?t.location:-1,this.locationsCount=t.locationsCount??1,Ef(this.locationsCount)}bindLocation(t,n){return this.location!==-1&&this.index!==!0&&t.bindAttribLocation(n,this.location,this.name),this}getLocation(t,n){return this.location===-1&&this.index!==!0&&(this.location=t.getAttribLocation(n,this.name)),this}bind(t,n){if(!this._enable&&this.index!==!0){for(let i=0;i<this.locationsCount;i++)t.enableVertexAttribArray(this.location+i);this._enable=!0}return n.bind(this.location,void 0),this}disable(t){if(this._enable&&this.index!==!0){for(let n=0;n<this.locationsCount;n++)t.disableVertexAttribArray(this.location+n);this._enable=!1}return this}}function Ef(e){if(e<0||e>4)throw new Error("[WebGl] Invalid attribute location count. Must be 1, 2, 3 or 4")}const re=class re{constructor(t,n,i,s=!1,r=!1){this.elementsType=null,this.isDirty=!0,this._glBuffer=null,this._gl=t,this._initData=n,this.byteLength=n.byteLength,this.type=s?re.ElementArrayBuffer:re.ArrayBuffer,this.options=Object.assign({},re.defaultOptions,i),this.drawType=i?.drawType??re.StaticDraw;const o=[re.UnsignedByte,re.UnsignedShort,re.UnsignedInt];s&&!o.includes(this.options.dataType)&&(console.warn("Please provide dataType of one of the following values:Buffer.UnsignedByte, Buffer.UnsignedShort, Buffer.UnsignedInt. Defaulting to UnsignedInt"),this.options.dataType=re.UnsignedInt),this._preserveData=r}static _dataTypeSize(t){switch(t){case re.Byte:case re.UnsignedByte:return 1;case re.UnsignedShort:case re.Short:return 2;case re.Float:case re.Int:case re.UnsignedInt:return 4}throw new Error(`[WebGl] Unsupported Buffer data type: ${String(t)}`)}memSizeJs(){return this._initData?.byteLength??0}memSizeGPU(){return this.byteLength}bind(t,n,i,s){const r=this._gl;if(this._glBuffer||this.prepare(),this.type===re.ArrayBuffer){r.bindBuffer(r.ARRAY_BUFFER,this._glBuffer),t=t||0,n=n||this.options,s=s??1,Ef(s);const o=this._toGlParam(n.dataType)||r.FLOAT;if(s===1)r.vertexAttribPointer(t,n.itemSize,o,n.normalized,n.stride,n.offset),this.bindVertexAttribDivisor(t,n,i);else{const a=re._dataTypeSize(n.dataType);for(let c=0;c<s;c++)r.vertexAttribPointer(t+c,s,o,n.normalized,n.stride,n.offset+c*s*a),this.bindVertexAttribDivisor(t+c,n,i)}}else this.type===re.ElementArrayBuffer&&r.bindBuffer(r.ELEMENT_ARRAY_BUFFER,this._glBuffer);return this}remove(){return this._unprepare(),this}subData(t,n){const i=this._gl;this._glBuffer||this.prepare();const s=this._toGlParam(this.type)||i.ARRAY_BUFFER;return i.bindBuffer(s,this._glBuffer),i.bufferSubData(s,t,n),this}replaceData(t){t&&(this._initData=t),this.isDirty=!0}commitData(){const t=this._gl,n=this._toGlParam(this.type)||t.ARRAY_BUFFER,i=this._toGlParam(this.drawType)||t.STATIC_DRAW;t.bindBuffer(n,this._glBuffer),t.bufferData(n,this._initData,i),this.isDirty=!1}getGLType(){return this._toGlParam(this.options.dataType)}getData(){return this._initData}prepare(){return this._glBuffer=this._gl.createBuffer(),this.commitData(),this._preserveData||(this._initData=null),this}_unprepare(){this._glBuffer&&this._gl.deleteBuffer(this._glBuffer),this._glBuffer=null,this._initData=null,this.isDirty=!1}_toGlParam(t){const n=this._gl;return t===re.ArrayBuffer?n.ARRAY_BUFFER:t===re.ElementArrayBuffer?n.ELEMENT_ARRAY_BUFFER:t===re.StaticDraw?n.STATIC_DRAW:t===re.DynamicDraw?n.DYNAMIC_DRAW:t===re.Byte?n.BYTE:t===re.Short?n.SHORT:t===re.Int?n.INT:t===re.Float?n.FLOAT:t===re.UnsignedByte?n.UNSIGNED_BYTE:t===re.UnsignedShort?n.UNSIGNED_SHORT:t===re.UnsignedInt?n.UNSIGNED_INT:null}_hasRealWebGLContext(){return typeof window<"u"&&("WebGLRenderingContext"in window||"WebGL2RenderingContext"in window)}bindVertexAttribDivisor(t,n,i){const s=this._gl;n.instanceDivisor&&this._hasRealWebGLContext()&&(s instanceof WebGLRenderingContext?i?i.vertexAttribDivisorANGLE(t,n.instanceDivisor):console.error("Can't set up instanced attribute divisor. Missing ANGLE_instanced_arrays extension"):s.vertexAttribDivisor(t,n.instanceDivisor))}};re.ArrayBuffer=1,re.ElementArrayBuffer=2,re.StaticDraw=10,re.DynamicDraw=11,re.Float=20,re.UnsignedByte=21,re.UnsignedShort=22,re.UnsignedInt=23,re.Byte=24,re.Short=25,re.Int=26,re.defaultOptions={itemSize:3,dataType:re.Float,stride:0,offset:0,normalized:!1,instanceDivisor:0,drawType:re.StaticDraw};let ke=re;function Hy(e){if(e===void 0)return;const t=window.WebGLRenderingContext,i={[t.UNSIGNED_BYTE]:ke.UnsignedByte,[t.UNSIGNED_SHORT]:ke.UnsignedShort,[t.UNSIGNED_INT]:ke.UnsignedInt,[t.BYTE]:ke.Byte,[t.SHORT]:ke.Short,[t.INT]:ke.Int,[t.FLOAT]:ke.Float}[e];return i===void 0?(console.error(`Cannot translate ${e} gltf componentType`),NaN):i}function Vy(e){return e}var Kn=(e=>(e[e.Striped=1]="Striped",e[e.Entrance=2]="Entrance",e[e.Patterned=3]="Patterned",e))(Kn||{}),ds=(e=>(e[e.Line=0]="Line",e[e.Arrow=1]="Arrow",e[e.StartBorder=2]="StartBorder",e[e.LineEnding=3]="LineEnding",e))(ds||{}),Me=(e=>(e[e.TileCut=0]="TileCut",e[e.Butt=1]="Butt",e[e.Round=2]="Round",e))(Me||{});const Ue=Ae(),Ar=Ae(),_i=Ae(),En=Ae(),fs=Ae(),Kt=Ae(),Ua=Ae(),bt=Ae();let Pi=0,xn=0;function xf(e,t,n,i,s,r,o,a,c,l,d){if(!(r<2)){if(Vt(Ue,t[0],n[0],t[1],n[1]),Pi=0,o===Me.Round){const f=l!==void 0?l[0]:0,u=d!==void 0?d[0]:0;za(e,t[0],n[0],i?.[0]??0,s?.[0]??0,-Ue[0],-Ue[1],f,u,c)}for(let f=1;f<r;f++)$y(e,t,n,i,s,f,r,c,l,d);if(a===Me.Round){const f=l!==void 0?l[r-1]:0,u=d!==void 0?d[r-1]:0;za(e,t[r-1],n[r-1],i?.[r-1]??0,s?.[r-1]??0,Ue[0],Ue[1],f,u,c)}}}function $y(e,t,n,i,s,r,o,a,c,l){const d=r===o-1;if(Ce(fs,t[r-1],n[r-1]),Ce(Kt,t[r],n[r]),c!==void 0&&l!==void 0?(Ce(_i,c[r-1],l[r-1]),Ce(En,c[r],l[r])):(Ce(_i,0,0),Ce(En,0,0)),Sn(bt,Ue),d)xn=0;else{Ce(Ua,t[r+1],n[r+1]),Vt(Ar,Kt[0],Kt[1],Ua[0],Ua[1]);const h=ge(bn(Ue,Ar),-1,1);if(h<=0)xn=0,za(e,Kt[0],Kt[1],i?.[r]??0,s?.[r]??0,Ue[0],Ue[1],En[0],En[1],a);else{const w=Math.sqrt((1-h)/(1+h)),p=er(bn(bt,Ar));xn=w*p}}Yy(e,0,1,3,3,1,2);const f=bt[0]*_e,u=bt[1]*_e;Qn(e,fs[0],fs[1],i?.[r-1]??0,s?.[r-1]??0,(bt[0]+Ue[0]*Pi)*_e,(bt[1]+Ue[1]*Pi)*_e,f,u,_i[0],_i[1],a),Qn(e,fs[0],fs[1],i?.[r-1]??0,s?.[r-1]??0,(-bt[0]-Ue[0]*Pi)*_e,(-bt[1]-Ue[1]*Pi)*_e,-f,-u,_i[0],_i[1],a),Qn(e,Kt[0],Kt[1],i?.[r]??0,s?.[r]??0,(-bt[0]+Ue[0]*xn)*_e,(-bt[1]+Ue[1]*xn)*_e,-f,-u,En[0],En[1],a),Qn(e,Kt[0],Kt[1],i?.[r]??0,s?.[r]??0,(bt[0]-Ue[0]*xn)*_e,(bt[1]-Ue[1]*xn)*_e,f,u,En[0],En[1],a),d||(nr(Ue,Ar),Pi=xn)}function za(e,t,n,i,s,r,o,a,c,l){Zy(e,0,1,2);const d=-r*.01,f=-o*.01;Qn(e,t,n,i,s,r+d,o+f,r,o,a,c,l),Qn(e,t,n,i,s,-o+d,r+f,-o,r,a,c,l),Qn(e,t,n,i,s,o+d,-r+f,o,-r,a,c,l)}function Qn(e,t,n,i,s,r,o,a,c,l,d,f){const u=e.elements.offset*e.elements.stride,h=u>>1,y=u>>2;e.views.position[h]=B+t,e.views.position[h+1]=B+n,e.views.extender[u]=r*127,e.views.extender[u+1]=o*127,e.views.normal[u]=a*127,e.views.normal[u+1]=c*127,"height"in e.views&&(e.views.height[y]=i),"absZ"in e.views&&(e.views.absZ[y]=s),"shift"in e.views&&(e.views.shift[y]=l,e.views.shift[y+1]=d),"localID"in e.views&&(e.views.localID[y]=f),e.elements.offset++}function Yy(e,t,n,i,s,r,o){const a=e.indices.buffer,c=e.indices.offset,l=e.elements.offset;a[c]=l+t,a[c+1]=l+n,a[c+2]=l+i,a[c+3]=l+s,a[c+4]=l+r,a[c+5]=l+o,e.indices.offset=c+6}function Zy(e,t,n,i){const s=e.indices.buffer,r=e.indices.offset,o=e.elements.offset;s[r]=o+t,s[r+1]=o+n,s[r+2]=o+i,e.indices.offset=r+3}function Ee(e,t,n){return t.precomputes.forEach((i,s)=>{e.push(n.tileData[s])}),e}function us(e,t){for(let n=0,i=t.length;n<i;n++)e.push(t[n]);return e}const Wy={x:0,y:1};function Xy(e){const t={};for(const n in e)e[n]&&(t[n]=Array.from(e[n]));return t}function hs(e,t){for(const n in e){const i=Wy[n];i!==void 0?e[n].push(t[i]):e[n].push(NaN)}}const _f=32,Pf=512;function qy(e,t,n,i,s){const r=[e[0][0],e[1][0]],o=pe(90+i),a=[];dt(a,r,s);const c=oe.toGeo(a),l=dr(c,t),d=dr(c,n),f=Math.sqrt(l**2+d**2)/2,u=Math.atan(l/-d)+Math.PI+o,h=f*Math.cos(u),y=f*Math.sin(u),w=Math.atan(-l/-d)+Math.PI+o,p=f*Math.cos(w),g=f*Math.sin(w),b=Math.atan(-l/d)+2*Math.PI+o,v=f*Math.cos(b),M=f*Math.sin(b),E=Math.atan(l/d)+o,T=f*Math.cos(E),L=f*Math.sin(E),A=[],P=[],R=[],k=[];return gt(A,[a[0]+h,a[1]+y],s),gt(P,[a[0]+p,a[1]+g],s),gt(R,[a[0]+v,a[1]+M],s),gt(k,[a[0]+T,a[1]+L],s),[[A[0],P[0],R[0],k[0]],[A[1],P[1],R[1],k[1]]]}function Er(e,t){const n=Math.max(e,t);return n*_f>Pf?Pf/n:_f}function Lf(e){const t=vt(e,[0,0]);return ne/wt(e.coords[2])*me*t}function Jy(e,t,n,i){if(isNaN(e.step)||isNaN(e.width))return n;const{tileProps:s,tileAttrs:r}=i,o=Lf(t);let a=e.step*o;if(isNaN(a)&&(a=0),a===0)return n;const c=e.width*o,l={},d=n.x,f=n.y,u=d.length;for(const L in n)l[L]=[];let h=0;const y=[h];for(let L=1;L<u;L++)h+=In([d[L-1],f[L-1]],[d[L],f[L]]),y.push(h);const w=Ae(),p=Ae(),g=[0,0],b=Math.abs(h/Math.trunc(h/a)),v=[d[0],f[0]];let M=(e.stopLines?1:-1)*Math.sign(e.width),E=0,T=0;for(hs(l,v),e.stopLines&&!r[s.beginningIsCut]&&(Vt(w,d[T],f[T],d[T+1],f[T+1]),Sn(p,w),mt(g,p,M*c),Pt(v,v,g),hs(l,v),E+=b/2,M=-M);E<=h;){for(;E>y[T+1];)T++;if(Vt(w,d[T],f[T],d[T+1],f[T+1]),Sn(p,w),M>0)mt(g,p,M*c),Pt(v,v,g),mt(g,w,b/2),Pt(v,v,g),hs(l,v);else{const L=Math.min(1,(E-y[T])/(y[T+1]-y[T]));Cd(v,[d[T],f[T]],[d[T+1],f[T+1]],L),hs(l,v)}M=-M,E+=b/2}return e.stopLines&&!r[s.endingIsCut]&&(mt(g,p,M*c),Pt(v,v,g),hs(l,v)),l}function Ky(e,t,n,i){const s=Lf(t),r=vt(t,[0,0]),{tileProps:o,tileAttrs:a}=i,c=n.x.length,l=s*e.modelLength,d=s*(e.edgeMarging||0),f={x:[],y:[],xScaleDirection:[],yScaleDirection:[],scaleCorrection:[]};for(let u=1;u<c;u++){const h=[n.x[u],n.y[u]],y=[n.x[u-1],n.y[u-1]];u===1&&d>0&&!a[o.beginningIsCut]&&Df(y,h,d),u===c-1&&d>0&&!a[o.endingIsCut]&&Df(h,y,d),Qy(f,y,h,l,r)}return f}function Df(e,t,n){const i=In(t,e),s=t[0]-e[0],r=t[1]-e[1],o=s/i,a=r/i;e[0]=e[0]+o*n,e[1]=e[1]+a*n}function Qy(e,t,n,i,s){const[r,o]=t,[a,c]=n,l=In(t,n),d=Math.max(Math.round(l/i),1),f=l/(d*i),u=a-r,h=c-o,y=u/l,w=h/l,p=l/d/2;for(let g=1;g<=d;g++){const b=g*(l/d),v=r+y*(b-p),M=o+w*(b-p),E=r+y*b,T=o+w*b;e.x.push(v),e.y.push(M),e.xScaleDirection.push(E),e.yScaleDirection.push(T),e.scaleCorrection.push(f*s)}return e}function xr(e,t,n,i){if(!eg(e)||e.length===0)return n;let s=Xy(n);for(const r of e){if(typeof r!="object"||!r)return console.warn(`Wrong value ${r} in modifiers list.`),null;if(!("type"in r))return console.warn(`Wrong value ${r} in modifiers list.`),null;switch(r.type){case"zigzag-modifier":s=Jy(r,t,s,i);break;case"to-points-modifier":s=Ky(r,t,s,i);break;default:return console.warn(`Expression with type ${r.type} cannot be used as geometry modifier.`),null}if(s===null)return null}return s}function eg(e){return!!e&&Array.isArray(e)}const tg=new Set(["bottomCenter","bottomRight","bottomLeft","topCenter","topRight","topLeft","rightBottom","rightCenter","rightTop","leftBottom","leftCenter","leftTop","centerCenter"]);function ng(e){return tg.has(e)}function ig(e){return typeof e=="number"||typeof e=="boolean"||typeof e=="string"||e===null}function Ga(e){if(Array.isArray(e)){const t=e;if(!t.length)return!1;if({zoom:!0,height:!0,coalesce:!0,"heatmap-density":!0,"shading-intensity":!0,objectAttr:!0,step:!0,interpolate:!0,all:!0,get:!0,sourceAttr:!0,featureState:!0,global:!0,match:!0,in:!0,any:!0,"!":!0,"==":!0,"!=":!0,">=":!0,">":!0,"<=":!0,"<":!0,"to-boolean":!0,"to-color":!0,"+":!0,"*":!0,"^":!0,log10:!0,random:!0,literal:!0,isBehindObjects:!0,"mappoints-to-meters":!0,"meters-to-pixels":!0,uint64:!0,"geometry-modifier":!0,pattern:!0,precompute:!0,"gltf-animation":!0,distance:!0,time:!0,"local-time":!0,"utc-time":!0,"texture-animation":!0,easing:!0,schedule:!0,mix:!0,readFromTarget:!0,vertexAttribute:!0}[t[0]])return!0}return!1}function Of(e){return Ga(e)&&e[0]==="literal"}function $t(e){return!Array.isArray(e)&&typeof e=="object"&&e!==null&&e.type!==void 0&&e.type!=="color"}function sg(e){return!Array.isArray(e)&&typeof e=="object"&&e!==null&&e.type==="color"}function Cf(e,t){return Array.isArray(e)?e.length>0&&e.every(n=>typeof n===t):!1}function rg(e){return Cf(e,"string")}function Qt(e){return Cf(e,"number")}function Ff(e){return!Array.isArray(e)&&typeof e=="object"&&e!==null&&e.type==="object"}function og(e){const t=typeof e;return e===null||t==="string"||t==="number"||t==="boolean"||rg(e)||Qt(e)}function Nf(e){return og(e)||sg(e)||Ff(e)}function ag(e){return $t(e)&&e.type==="get"}function Yt(e){return{type:"color",value:e}}function cg(e){return{type:"mix-color",color1:e.value1,color2:e.value2,factor:e.factor,factorInterpolate:e.factorInterpolate}}function Li(e,t,n){return`${e}_${t}_${n}`}function _r(e){return`texture-${e}`}function ja(e,t){return e+"-"+t}function ze(e){return Of(e)&&Array.isArray(e[1])?e[1][0]:Array.isArray(e)?Ga(e)?e:e[0]:e}function en(e){if(Of(e)&&Array.isArray(e[1]))return e[1][1];if(Array.isArray(e)&&!Ga(e)&&e[1]!==void 0)return e[1]}function Ye(e){if(typeof e=="number"||Qt(e))return e;if(e.type==="literalArray"&&Qt(e.array))return e.array;throw new Error("Unsupported simple literal expression. Can't resolve.")}function ps(e,t=0){const n=Number(e);return isNaN(n)?t:n}function Rf(e){return!!e&&typeof e=="object"&&e.type==="mix-options"}const Bf=Yt([0,0,0,0]);function kf(e){return typeof e!="string"?!1:/(#(?:[0-9a-f]{2}){2,4}|#[0-9a-f]{3}|(?:rgba?|hsla?)\((?:\d+%?(?:,|\s)+){2,3}[\s\/]*[\d\.]+%?\))/i.test(e)}function ei(e){return!!e&&typeof e=="object"&&e.type==="color"}function lg(e){return!!e&&typeof e=="object"&&e.type==="mix-color"}function Ha(e){return!!e&&typeof e=="object"&&e.type==="gradient-color"}function ms(e){const t=e.toLowerCase();let n=Bf;switch(t[0]){case"#":n=fg(t);break;case"h":n=ug(t);break;case"r":n=hg(t);break}return n}function dg(e){return e.length<7?e[0]+e[1]+e[1]+e[2]+e[2]+e[3]+e[3]+(e.length===5?e[4]+e[4]:"ff"):e.length===7?e+"ff":e}function fg(e){if(!new RegExp(`^#[a-f0-9]{${e.length-1}}$`).test(e)||![4,5,7,9].includes(e.length))return Bf;const n=dg(e),i=parseInt(n[1]+n[2],16),s=parseInt(n[3]+n[4],16),r=parseInt(n[5]+n[6],16),o=parseInt(n[7]+n[8],16);return Yt([i,s,r,o])}function ug(e){const t=Uf(e);t[0]/=360,t[1]/=100,t[2]/=100;const[n,i,s]=pg(t[0],t[1],t[2]),r=t[3]!==void 0?t[3]*255:255;return Yt([Math.round(n),Math.round(i),Math.round(s),Math.round(r)])}function hg(e){const[t,n,i,s]=Uf(e),r=s!==void 0?s*255:255;return Yt([Math.round(t),Math.round(n),Math.round(i),Math.round(r)])}function Uf(e){return e.split("(")[1].split(")")[0].split(",").map(n=>parseFloat(n))}function Va(e,t,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*(2/3-n)*6:e}function pg(e,t,n){if(t===0)return[n*255,n*255,n*255];const i=n<.5?n*(1+t):n+t-n*t,s=2*n-i;return[Va(s,i,e+1/3)*255,Va(s,i,e)*255,Va(s,i,e-1/3)*255]}function Pr(e){let t="",n=0;for(;n<e.length;){let i=e[n++];if(i>127){if(i>191&&i<224){if(n>=e.length)return console.error("Incomplete 2-byte sequence"),t;i=(i&31)<<6|e[n]&63}else if(i>223&&i<240){if(n+1>=e.length)return console.error("Incomplete 3-byte sequence"),t;i=(i&15)<<12|(e[n]&63)<<6|e[++n]&63}else if(i>239&&i<248){if(n+2>=e.length)return console.error("Incomplete 4-byte sequence"),t;i=(i&7)<<18|(e[n]&63)<<12|(e[++n]&63)<<6|e[++n]&63}else return console.error(`Unknown multibyte start 0x${i.toString(16)} at index ${n-1}`),t;++n}if(i<=65535)t+=String.fromCharCode(i);else if(i<=1114111)i-=65536,t+=String.fromCharCode(i>>10|55296),t+=String.fromCharCode(i&1023|56320);else return console.error(`Code point 0x${i.toString(16)} exceeds UTF-16 reach`),t}return t}function $a(e,t){if(e.length<=t||e.indexOf(`
`)!==-1)return e;const n=[];return e.split(" ").forEach(i=>{const s=n.length-1;n.length===0||n[s].length+i.length>=t?n.push(i):n[s]+=" "+i}),n.join(`
`)}function Ya(e){return Math.floor(e/256)}function mg(e){const t=new Set;return e.forEach(n=>{if(n!==void 0)for(let i=0;i<n.length;i++){const s=n.charCodeAt(i);s!==xt.bomCharCode&&t.add(Ya(s))}}),Array.from(t)}function yg(e,t,n=1,i="…"){if(e.length<=t)return e;const s=t-i.length;switch(n){case 2:return e.substring(0,s)+i;case 1:{const r=Math.ceil(s/2);return e.substring(0,r)+i+e.substring(e.length-(s-r),e.length)}}}function gg(e,t){Pe(`No glyph for character ${e} (code = ${t}, range = ${Ya(t)})`)}const zf=new Set;function wg(e){console.group("Gltf model error"),console.warn("Stage:",e.layer),e.message&&console.warn("Message:",e.message),e.originalError&&(console.groupCollapsed("Original error"),console.warn(e.originalError),console.groupEnd()),console.groupEnd()}function Gf(e){Pe(`Got an empty response from the "${e}" tile generation.`)}function Pe(e){zf.has(e)||(console.log(e),zf.add(e))}const vg=2166136261,bg=16777619;function jf(e,t){let n=vg;for(const i of t)n=n^i,n=n*bg;e.randomSeed=Math.abs(n)}function ys(e,t,n){let i=.5;return e.randomSeed?(e.randomSeed=e.randomSeed*16807%2147483647,i=(e.randomSeed-1)/2147483646):Pe("Resolve 'random': random seed is absent, the mean value between start and end will be used."),i*(n-t)+t}function Ig(e=128){const t=[],n=[];for(let i=0;i<e;i++)t.push(Hf(i,2)),n.push(Hf(i,3));return{base2:t,base3:n}}function Hf(e,t){let n=0,i=1/t;for(;e>0;)n=n+i*(e%t),e=Math.floor(e/t),i=i/t;return n}function Mg(e,t){const n=[];for(let i=0;i<t;i++){const s=ys(e,0,2*Math.PI),r=Math.acos(ys(e,0,2)-1),o=Math.sin(r)*Math.cos(s),a=Math.sin(r)*Math.sin(s),c=Math.cos(r);n.push(qe(o,a,c))}return n}var Ze=(e=>(e[e.Uniform=1]="Uniform",e[e.Labeling=2]="Labeling",e[e.Generator=3]="Generator",e))(Ze||{});const Lr=-1;var gs=(e=>(e.global="global",e.none="none",e))(gs||{}),_n=(e=>(e[e.Pixels=0]="Pixels",e[e.Meters=1]="Meters",e))(_n||{});const Vf="bottomCenter";function He(e,t){for(const n in t)t[n]!==void 0&&(e[n]=t[n])}function Tg(e){const n={color:"#000000",textureImage:"",textureSize:16,textureOpacity:1,strokeColor:"#00000000",strokeWidth:1,visibility:"visible",metallic:1,roughness:0,normalMapTextureImage:"",normalMapTextureSize:16,normalMapTextureAnimation:null};if(He(n,e),e.strokeColor===void 0&&!n.textureImage&&(n.strokeColor=n.color),!Array.isArray(n.textureSize)||n.textureSize[0]==="step"||n.textureSize[0]==="literal")return n;if(!n.textureSize.length)n.textureSize=16;else if(Qt(n.textureSize))n.textureSize.length===1&&(n.textureSize=n.textureSize[0]);else return n;return n}function Sg(e){const n={color:"#000000",textureImage:"",textureSize:16,textureOpacity:1,strokeColor:"#00000000",strokeWidth:1,nearCameraFade:2500,visibility:"visible",elevation:0};if(He(n,e),e.strokeColor===void 0&&!n.textureImage&&(n.strokeColor=n.color),!Array.isArray(n.textureSize)||n.textureSize[0]==="step"||n.textureSize[0]==="literal")return n;if(!n.textureSize.length)n.textureSize=16;else if(Qt(n.textureSize))n.textureSize.length===1&&(n.textureSize=n.textureSize[0]);else return n;return n}function Ag(e){const t={iconImage:"",color:"#FFFFFF",rotation:0,width:1,visibility:"visible"};return He(t,e),e.height===void 0&&(t.height=t.width),t}function Eg(e){const t={topColor:"#000000",strokeColor:"#000000",strokeWidth:1,sideColor:"#000000",sideStrokeColor:"#000000",height:["mappoints-to-meters",["get","db_height"]],nearCameraFade:2500,visibility:"visible",sideTextures:[]};return He(t,e),e.strokeColor===void 0&&(t.strokeColor=t.topColor),e.sideColor===void 0&&(t.sideColor=t.topColor),e.sideStrokeColor===void 0&&(t.sideStrokeColor=t.sideColor),t}function xg(e){const t={color:"#000000",width:1,shift:0,geometryModifier:["geometry-modifier"],pattern:["pattern","none"],startCap:"round",endCap:"round",mode:"2d",visibility:"visible"};return He(t,e),t}function _g(e){const t={color:"#000000",strokeColor:"#000000",strokeWidth:1,nearCameraFade:2500,visibility:"visible"};return He(t,e),e.strokeColor===void 0&&(t.strokeColor=t.color),t}function Pg(e){const t={sideColor:"#000000",strokeColor:"#000000",strokeWidth:1,sideStrokeColor:"#000000",height:0,visibility:"visible",nearCameraFade:2500};return He(t,e),e.strokeColor===void 0&&(t.strokeColor=t.sideColor),e.sideStrokeColor===void 0&&(t.sideStrokeColor=t.sideColor),t}function Lg(e){const t={textField:["get","db_label"],textFont:"Noto_Sans",textColor:"#000000",textFontSize:16,textLetterSpacing:0,textHaloColor:"rgba(0, 0, 0, 0)",textHaloWidth:0,textPriority:0,textLabelingSideMargin:0,textDuplicationSpacing:0,lineEndingOffsets:0,visibility:"visible",labelingGroup:Ln};return He(t,e),t}function Dg(e){const t={color:"#000000",lineWidth:2,lineLength:10,tipWidth:1.5,tipHeight:2,roundingRadius:0,priority:0,duplicationSpacing:0,endingOffsets:0,visibility:"visible",labelingGroup:Ln};return He(t,e),t}function Og(e){const t={color:"#000000",gapColor:"#00000000",width:1,shift:0,gapLength:1,dashLength:1,gapTurnsOnly:!1,geometryModifier:["geometry-modifier"],mode:"2d",visibility:"visible"};return He(t,e),t}function Cg(e){const t={color:"#000000",width:1,shift:0,visibility:"visible"};return He(t,e),t}function Fg(e){const t={color:"#ffffff",strokeColor:"#3388ff",strokeColor2:"#00000000",width:20,strokeWidth:3,strokeWidth2:0,visibility:"visible"};return He(t,e),t}function Ng(e){const t={allowOverlap:!1,allowElevation:!1,elevation:NaN,iconOpacity:1,iconImage:"",iconAnchor:[.5,.5],iconOffset:[0,0],iconWidth:16,iconTextField:["get","db_label2"],iconTextFont:"",iconTextAnchor:[.5,.5],iconTextOffset:[0,0],iconTextColor:"#000000",iconTextFontSize:16,iconTextLineHeight:1.2,iconTextLetterSpacing:0,iconTextPadding:[0,0,0,0],iconTextHaloWidth:0,iconTextHaloColor:"rgba(0, 0, 0, 0)",iconPriority:0,iconRotation:0,iconLabelingGroup:Ln,iconLabelingMargin:{topBottom:0,leftRight:0},textField:[["get","db_label"],["get","db_label2"]],textFont:"",textColor:"#000000",textFontSize:16,textLineHeight:1.2,textLetterSpacing:0,textPlacement:Vf,textOffset:0,textHaloColor:"rgba(0, 0, 0, 0)",textHaloWidth:0,textLabelingMargin:{topBottom:0,leftRight:0},textPriority:0,textMaxLengthPerLine:30,visibility:"visible",textLabelingGroup:Ln,duplicationSpacing:100,endingOffsets:0};return He(t,e),t}function Rg(e){const t={color:"#000000",strokeColor:"#000000",lineWidth:1,strokeWidth:0,tipWidth:1,tipHeight:1,roundingRadius:3,animation:{type:"appearance",tipMovementAmplitude:0},visibility:"visible"};return e.strokeColor===void 0&&(t.strokeColor=t.color),He(t,e),t}function Bg(e){const t={opacity:1,visibility:"visible"};return He(t,e),t}function kg(e){return wn(e,{color:["interpolate",["linear"],["heatmap-density"],0,"rgba(53, 136, 253, 0)",.2,"rgba(53, 136, 253, 0.2)",.4,"rgb(255, 201, 77)",.6,"rgb(255, 202, 20)",.75,"rgb(245, 0, 7)",1,"rgb(255, 0, 0)"],radius:30,opacity:1,intensity:1,weight:1,downscale:1,visibility:"visible"})}function Ug(e){return wn(e,{shadingIntensity:["interpolate",["linear"],["zoom"],12,0,14.5,.7],verticalScale:1,shadingPalette:["interpolate",["linear"],["shading-intensity"],0,0,1,1],lightingDirection:322})}function zg(e){return wn(e,{modelSrc:"",offset:0,scale:1,rotation:0,color:"#fff",linkedIds:"",visibility:"visible",colorTextureUvIndex:0,nearCameraFade:2500,ignoreGlobalLighting:!1,showRatio:1,metallic:NaN,roughness:NaN,preventObjectsHiding:!1,lightingModel:"phong",playAnimation:-1,scene:NaN,geometryModifier:["geometry-modifier"]})}function Gg(e){const t={visibility:"visible",sideColor:"#000000",borderTopColor:"#000000",bottomColor:"#000000",strokeColor:"#000000",strokeWidth:1,debug:!1,thickness:1,borderHeight:0,borderWidth:.3,color:"#000000",nearCameraFade:0,tunnelHeight:5};return He(t,e),e.borderTopColor===void 0&&(t.borderTopColor=t.color),e.strokeColor===void 0&&(t.strokeColor=t.color),e.sideColor===void 0&&(t.sideColor=t.color),e.bottomColor===void 0&&(t.bottomColor=t.color),t}function jg(e){const t={visibility:"visible",sideColor:"#000000",topColor:"#000000",bottomColor:"#000000",strokeColor:"#000000",strokeWidth:1,color:"#ffffff",nearCameraFade:0};return He(t,e),t}function Hg(e){return wn(e,{skyColor:"#6EC0FF00",fogColor:"#FAFDFF00",starsIntensity:1})}function Vg(e){const t={sources:{sun:{type:"directional",altitude:50,azimuth:230,color:"#FFFFFF",intensity:.2},atmosphere:{type:"ambient",color:"#FFFFFF",intensity:.85}},lightingModes:{[gs.global]:["sun","atmosphere"]},defaultLightingMode:"global"},n=wn(e??{},t);return n.lightingModes[gs.none]=[],n}function $g(e){const n=wn(e??{},{light:{},normal:{},immersive:{}});return n.light.transparentBuildingsOff=!0,n.light.AALinesOff=!0,n}const Pn="__overlapped",Za="__commercial",Ln="default",Wa={groups:[Ln,Pn,Za],overlay:[[Ln,Pn]],intersect:[[]]},Yg="#F5F2E0",ti=e=>{e&&Object.entries(e).forEach(([t,n])=>{n===void 0&&delete e[t]})},Zg=e=>{ti(e),e.type==="group"?(ti(e.commonDefaults),ti(e.commonDefaults?.style),ti(e.layerTypeDefaults),e.layerTypeDefaults&&Object.values(e.layerTypeDefaults).forEach(t=>{ti(t),ti(t?.style)})):e.type!=="custom"&&ti(e.style)},$f=(e,t=!1)=>{t||console.warn("assertUnreachable: ",e)},ni=null,Yf=[0,0,0];function G(e,t){if(!$t(e))return e;if(t.allowedExpressions&&!t.allowedExpressions.has(e.type))return Pe(`Expression of type ${e.type} is not allowed here`),ni;switch(e.type){case"schedule":return rw(e,t);case"time":return qg(e,t);case"objectAttr":return Kg(e,t);case"coalesce":return Wf(e,t);case"all":return Wg(e,t);case"any":return Xg(e,t);case"featureState":return ew(e,t);case"get":return Jf(e,t);case"global":return tw(e,t);case"sourceAttr":return Jg(e,t);case"in":return hw(e,t);case"interpolate":return nw(e,t);case"match":return iw(e,t);case"step":return sw(e,t);case"to-boolean":return lw(e,t);case"to-color":return ow(e,t);case"mappoints-to-meters":return aw(e,t);case"meters-to-pixels":return cw(e,t);case"!":return dw(e,t);case"==":case"!=":return fw(e,t);case">":case"<":case">=":case"<=":return uw(e,t);case"zoom":if(t.type==="binder"||t.type==="labeling")return t.styleZoom;if(t.type==="generator")return t.tileInfo?.coords[3]??0;const{type:n}=t;return $f(n),ni;case"distance":if(t.type==="binder"){const s=oe.toGeo(t.objectCenter),r=oe.scaleFactor(s[1])*me;return ya(t.objectCenter,t.cameraCenter)/r}else return Pe(`Distance expression can't be resolved in the ${t.type} context`),ni;case"height":return 1;case"+":return pw(e,t);case"*":return mw(e,t);case"^":return yw(e,t);case"log10":return gw(e,t);case"random":return ww(e,t);case"literalArray":return vw(e,t);case"literalObject":return{type:"object",value:e.object};case"isBehindObjects":return t.type==="binder"?t.isBehind:(Pe(`isBehindObjects expression cannot be used in ${t.type} context`),ni);case"geometry-modifier":return e.modifiers;case"line-pattern":return[e.patternType,...e.parameters.map(s=>G(s,t))];case"precompute":return t.tileData[e.precomputeIndex]??null;case"gltf-animation":return Xf(e,t);case"local-time":return Zf(e,t);case"utc-time":return Zf(e,t);case"texture-animation":return qf(e,t);case"easing":return e.options;case"mix":return Qg(e,t);default:return Pe(`Not supported expression type <<${e.type}>> in ${JSON.stringify(e)}`),ni}}function Wg(e,t){return e.array.every(n=>G(n,t)===!0)}function Xg(e,t){return e.array.some(n=>G(n,t)===!0)}function Zf(e,t){const n=Date.now()+ +(t.styleState._customUserTimeOffset||0);if(e.type==="local-time"){const i=e.offset?+(G(e.offset,t)||0)*6e4:0;return n+i}if(e.type==="utc-time"){const i=e.offset?+(G(e.offset,t)||0)*6e4:0;return n+new Date().getTimezoneOffset()*6e4+i}return n}function qg(e,t){const n=i=>{const s=G(e.timeSource,t),r=new Date(+(s||0));return i==="day-minutes-720"?(r.getHours()%12||0)*60+r.getMinutes():r.getTime()};if(t.type==="binder"){if(t.callBackFn){const i=Date.now()+ +(t.styleState._customUserTimeOffset||0),s=Math.floor(i/6e4)*6e4+6e4;t.callBackFn(s)}return Array.isArray(e.format)?e.format.map(i=>n(i)):n(e.format)}return n("timestamp")}function Wf(e,t){for(const n of e.array){const i=G(n,t);if(i!==null)return i}return null}function Jg(e,t){return t.type==="generator"?t.sourceAttrs[e.property]??null:null}function Kg(e,t){return t.type==="binder"&&t.dynamicObject&&t.dynamicObject[e.property]||null}function Xf(e,t){const n={type:"animation-options"};return e.options?e.options.forEach((i,s)=>n[s]=G(i,t)):$t(e)||(n[0]=e),n}function qf(e,t){const n={type:"texture-animation-options"};return e.options?e.options.forEach((i,s)=>n[s]=G(i,t)):$t(e)||(n[0]=e),n}function Qg(e,t){const{factorInterpolate:n}=e,i={type:"mix-options",value1:G(e.value1,t),value2:G(e.value2,t),factor:e.factor};if(n){const{steps:s,base:r}=n;i.factorInterpolate={base:r,steps:[ae(s[0].key,t,0),ae(s[0].value,t,0),ae(s[1].key,t,1),ae(s[1].value,t,1)]}}return i}function ew(e,t){if(t.type==="generator"){const n=t.featureAttrs[t.tileProps[e.property]]??null;return Number.isNaN(n)?null:n}else throw new Error("Feature state expression can be resolved only in generator context")}function Jf(e,t){if(t.type==="generator"){let n=t.tileAttrs[t.tileProps[e.property]]??null;return typeof n=="object"&&n!==null&&!Array.isArray(n)&&(n={type:"object",value:n}),Number.isNaN(n)?null:n}else throw new Error("Get expression can be resolved only in generator context")}function tw(e,t){const n=t.styleState[e.property];return n==null?null:typeof n=="object"&&!Array.isArray(n)?{type:"object",value:n}:n}function nw(e,t){if(e.steps.length===0)return Pe("Interpolate expression contains 0 steps, cannot interpolate"),ni;const n=G(e.steps[0].value,t),i=G(e.argument,t);if(typeof i!="number")return Pe(`Interpolate value resolved to non-number value: ${i} ${e.argument}`),0;if(ei(n)){if($t(e.argument)&&e.argument.type==="height"){const s={type:"gradient-color",values:[],steps:[]};return e.steps.forEach(r=>{const o=ae(r.key,t),a=G(r.value,t);ei(a)&&!Number.isNaN(o)&&(s.values.push({type:"color",value:a.value}),s.steps.push(o))}),s.steps.length!==2?(Pe("Gradient expression must resolve 2 steps"),ni):s}return Qf(e,i,t)}return Kf(e,i,t)}function iw(e,t){const n=G(e.input,t),i=e.cases.find(s=>s.values.has(n));return G(i?.output??e.defaultOutput,t)}function sw(e,t){const n=Number(G(e.value,t)),i=vs(e,n,t)-1;return G(e.steps[i].value,t)}function rw(e,t){const s=(w,p)=>{const g=Date.now()+ +(p.styleState._customUserTimeOffset||0);return Math.floor(g/6e4)*6e4+w*6e4},r=e.detailResult||!1,o=w=>{if(t.type==="binder"&&t.callBackFn){const p=s(w,t);t.callBackFn(p)}};let a=G(e.steps,t);typeof a=="string"&&(a=JSON.parse(a));const c=new Array,l=new Array;if(Array.isArray(a)){c.push({key:0,value:a[0]});for(let w=1;w<a.length;w+=3){const g={key:Math.trunc(a[w]/1440)*1440,value:a[0]};l.push(g);const b={key:a[w],value:a[w+2]};c.push(b);const v={key:a[w+1],value:a[0]};c.push(v)}}for(const w of l)c.find(p=>p.key===w.key)||c.push(w);c.sort((w,p)=>w.key<p.key?-1:1);const d=Number(G(e.time,t)),f=new Date(d),u=f.getHours()*60+f.getMinutes()+(f.getDay()||7)*1440,h=vs({steps:c},u%1440,t)-1,y=vs({steps:c},u,t)-1;if(c[y]&&Math.trunc(c[y]&&c[y].key/1440)===Math.trunc(u/1440)){const w=Math.min((c[y+1]?.key||11519)-u,1439-u%1440);o(w);const p=G(c[y].value,t)||NaN;return r?{type:"schedule-detailed-result",value:p,nextStepStartsAt:s(w,t),currentStepElapsed:(u-c[y].key)*6e4}:p}if(c[h]){const w=Math.min(c[h+1]?.key||1439,1439)-u%1440;o(w);const p=G(c[h].value,t)||NaN;return r?{type:"schedule-detailed-result",value:p,nextStepStartsAt:s(w,t),currentStepElapsed:(u%1440-c[h].key)*6e4}:p}return r?{type:"schedule-detailed-result",value:NaN,nextStepStartsAt:NaN,currentStepElapsed:NaN}:NaN}function ow(e,t){const n=G(e.value,t);return kf(n)?ms(n):ei(n)?n:(console.warn(`Can't resolve expression. Must be color, but got ${n}`),Yt([0,0,0,0]))}function aw(e,t){if(t.type!=="generator"||!t.tileInfo)throw new Error("Выражение `mappoints-to-meters` можно резолвить только в контексте генератора");return G(e.value,t)/(me*vt(t.tileInfo,[0,0]))}function cw(e,t){const n=ae(e.value,t);let i,s=n*256/da;if(t.type==="generator"){if(!t.tileInfo)return null;i=t.tileInfo.coords[3],s*=vt(t.tileInfo,[0,0])}else i=t.styleZoom;return s*2**(i+1)}function lw(e,t){return!!G(e.value,t)}function dw(e,t){return!G(e.value,t)}function fw(e,t){const n=G(e.leftValue,t),i=G(e.rightValue,t);switch(e.type){case"==":return n===i;case"!=":return n!==i}}function uw(e,t){const n=G(e.leftValue,t);if(n===null)return null;const i=G(e.rightValue,t);if(i===null)return null;switch(e.type){case"<":return n<i;case">":return n>i;case"<=":return n<=i;case">=":return n>=i}}function hw(e,t){const n=G(e.item,t),i=G(e.collection,t);return i===null?!1:typeof i!="object"?(Pe(`InExpression second argument resolved to non-object/non-array value: ${i}`),null):Array.isArray(i)?i.some(s=>s===n):Ff(i)?Object.prototype.hasOwnProperty.call(i.value,n):(Pe(`InExpression second argument resolved incorrectly: ${i}`),null)}function pw(e,t){const n=e.array.map(i=>G(i,t));return Qt(n)?n.reduce((i,s)=>i+s,0):(Pe(`Resolve AdditionExpression: arguments are not resolved as an array of numbers: ${n}`),null)}function mw(e,t){const n=e.array.map(i=>G(i,t));return Qt(n)?n.reduce((i,s)=>i*s,1):(Pe(`Resolve MultiplicationExpression: arguments are not resolved as an array of numbers: ${n}`),null)}function yw(e,t){const n=G(e.base,t);if(typeof n!="number")return Pe(`Resolve PowExpression: base resolved as non-number value: ${n}`),null;const i=G(e.exponent,t);return typeof i!="number"?(Pe(`Resolve PowExpression: exponent resolved as non-number value: ${i}`),null):Math.pow(n,i)}function gw(e,t){const n=G(e.value,t);return typeof n!="number"?(Pe(`Resolve Log10Expression: value resolved as non-number value: ${n}`),null):Math.log10(n)}function ww(e,t){const n=G(e.start,t);if(typeof n!="number")return Pe(`Resolve RandomizationExpression: start resolved as non-number value: ${n}`),null;const i=G(e.end,t);return typeof i!="number"?(Pe(`Resolve RandomizationExpression: end resolved as non-number value: ${i}`),null):i<n?(Pe("Resolve RandomizationExpression: end cannot be less than start."),null):ys(t,n,i)}function vw(e,t){return e.array.map(n=>G(n,t))}function Kf(e,t,n){const i=vs(e,t,n);if(i===0)return Number(G(e.steps[0].value,n));if(i===e.steps.length)return Iw(e,n,t);const s=Number(G(e.steps[i-1].value,n));if(n.type==="labeling"&&n.interpolateExpressionAsStep)return s;const r=tu(e,t,i,n),o=Number(G(e.steps[i].value,n));return(1-r)*s+r*o}function Dn(e,t,n=!1){const i=G(e,t);return ei(i)?i:Ha(i)?i.values[1]:Rf(i)?ei(i.value1)&&ei(i.value2)?n?cg(i):(console.warn("Mixing color is not supported here."),Yt([0,0,0,0])):(console.warn(`Mix values cannot be converted to colors in ${JSON.stringify(i)}`),Yt([0,0,0,0])):(console.warn(`Can't resolve expression. Must be color, but got ${i}`),Yt([0,0,0,0]))}function bw(e,t){const n=G(e,t);return Ha(n)?n:null}function ae(e,t,n=NaN){const i=G(e,t);return typeof i=="number"?i:n}function Ke(e,t,n=""){const i=G(e,t);return typeof i=="string"?i:n}function Dr(e,t,n=Vf){const i=G(e,t);return ng(i)?i:n}function Qf(e,t,n){const i=vs(e,t,n);if(i===0)return Dn(e.steps[0].value,n);if(i===e.steps.length)return Dn(e.steps[e.steps.length-1].value,n);const s=tu(e,t,i,n),r=Dn(e.steps[i-1].value,n).value,o=Dn(e.steps[i].value,n).value;return Yt([r[0]*(1-s)+o[0]*s,r[1]*(1-s)+o[1]*s,r[2]*(1-s)+o[2]*s,r[3]*(1-s)+o[3]*s])}function Iw(e,t,n){const i=e.steps[e.steps.length-1],s=e.base;return s===1?ae(i.value,t):ae(i.value,t)*Math.pow(s,n-ae(i.key,t))}function eu(e,t,n,i=!1,s,r,o){return{type:"binder",styleZoom:e,styleState:t,tileData:n,randomSeed:0,isBehind:i,dynamicObject:s,cameraCenter:r??Yf,objectCenter:o??Yf}}function Dt(e,t,n,i){return{type:"labeling",styleZoom:e,styleState:t,interpolateExpressionAsStep:n,randomSeed:0,tileData:i}}function ws(e,t,n,i,s,r,o){return{type:"generator",styleState:e,tileProps:n,tileAttrs:i,id:r,tileData:[],featureAttrs:s,sourceAttrs:t,randomSeed:0,tileInfo:o}}function vs(e,t,n){let i=0;for(;i<e.steps.length&&!(t<ae(e.steps[i].key,n));)i++;return i}function tu(e,t,n,i){const s=e.base,r=ae(e.steps[n].key,i)-ae(e.steps[n-1].key,i),o=t-ae(e.steps[n-1].key,i);return s===1?o/r:(Math.pow(s,o)-1)/(Math.pow(s,r)-1)}function Mw(e){const[t,n,i,s]=e.value;return[((t*s+127)/255>>>0)/255,((n*s+127)/255>>>0)/255,((i*s+127)/255>>>0)/255,s/255]}function ii(e,t,n,i=!1){const s=[];return si(s,e,t,n),i?s:Array.from(new Set(s))}function Tw(e,t){const n={};return Object.keys(e).forEach(i=>{n[i]=Sw(e[i],t)}),n}const Di=ba();function nu(e,t){const n=new Float32Array(3);return Se(n,1,0,0),g1(Di),b1(Di,Di,-pe(t-90)),v1(Di,Di,-pe(e)),jm(n,n,Di),zt(n,n),Vd(n,n),n}function Sw(e,t){const n={ambientColorIntensity:new Float32Array(Dn(e.ambientColor,t).value.map(i=>i/255)),dir1ColorIntensity:new Float32Array(Dn(e.dir1Color,t).value.map(i=>i/255)),dir1Direction:nu(G(e.dir1Altitude,t),G(e.dir1Azimuth,t)),dir2ColorIntensity:new Float32Array(Dn(e.dir2Color,t).value.map(i=>i/255)),dir2Direction:nu(G(e.dir2Altitude,t),G(e.dir2Azimuth,t)),shadowLightIndex:e.shadowLightIndex??-1,shadowRadius:e.shadowRadius??1};return n.ambientColorIntensity[3]=G(e.ambientIntensity,t),n.dir1ColorIntensity[3]=G(e.dir1Intensity,t),n.dir2ColorIntensity[3]=G(e.dir2Intensity,t),n}function si(e,t,n,i){if(!$t(t)){e.push(t);return}switch(t.type){case"all":return Aw(e,t,n,i);case"match":return Ew(e,t,n,i);case"step":return xw(e,t,n,i);case"interpolate":return _w(e,t,n,i);case"coalesce":{if(!n){console.error("There is no context to resolve the expression. The value from data will not be added to the result.");return}const s=Wf(t,n);e.push(s);return}case"precompute":if(i){const s=i.precomputes[t.precomputeIndex].expr;si(e,s,n,i);return}break;case"get":{if(!n){console.error("There is no context to resolve the expression. The value from data will not be added to the result.");return}const s=Jf(t,n);e.push(s);return}}}function Aw(e,t,n,i){t.array.forEach(s=>si(e,s,n,i))}function Ew(e,t,n,i){si(e,t.defaultOutput),t.cases.forEach(s=>si(e,s.output,n,i))}function xw(e,t,n,i){t.steps.forEach(s=>si(e,s.value,n,i))}function _w(e,t,n,i){t.steps.forEach(s=>si(e,s.value,n,i))}const Ot=1,Ct=-1,Ft=[.5,.5],It=[.5,.5],we=[.5,.5],Oi=[.5,.5],Xa=[0,0];let ft,fe,ye,ve=0,ut=0,Ge=0,We=0;const Pw={x:0,y:0,z:0,xn2:0,yn2:0,xn1:0,yn1:0,patternedLine:!1,noTurn:!0,leftTurn:!1,sharpTurn:!1,reverseTurn:!1,extender:[.5,.5],faExtender:[.5,.5],saExtender:[.5,.5]},Lw=1-1e-4,Dw=0,iu=-.9;function Ow(e,t,n,i,s,r,o,a){const c=Pw;c.x=e,c.y=t,c.z=n,c.xn2=i,c.yn2=s,c.xn1=r,c.yn1=o,c.patternedLine=a;const l=i*r+s*o;return c.noTurn=l>Lw,c.leftTurn=i*-o+s*r<0,c.sharpTurn=l<Dw&&l>iu,c.reverseTurn=l<iu,c}function qa(e,t,n,i,s,r,o,a,c,l,d,f,u=!1){let h,y,w,p,g,b,v,M,E,T,L,A,P;if(i!==0)if(ye=d,fe=f,ft=fe.indices,ut=fe.elements.offset,ve=0,Ge=0,We=0,e[0],t[0],i===1)h=e[0],y=t[0],w=n?.[0]??0,P=0,tn(ft,ut,0,2,1,1,2,3),Te(fe,ye,0,h,y,w,1,-1,1,-1,P,!1,Ct),Te(fe,ye,0,h,y,w,-1,-1,-1,-1,P,!1,Ot),Te(fe,ye,0,h,y,w,1,1,1,1,P,!1,Ct),Te(fe,ye,0,h,y,w,-1,1,-1,1,P,!1,Ot),ve=ve+4;else{switch(p=e[0],g=t[0],b=n?.[0]??0,v=e[1],M=t[1],E=n?.[1]??0,P=u?ye.cDist:0,s){case Me.TileCut:Lt(Ft,p,g,o,a),Lt(we,v,M,p,g),A=Ja(v,M,E,Ft[0],Ft[1],we[0],we[1],u),A.noTurn?su(p,g,b,we[0],we[1],P):Or(0,p,g,b,Ft[0],Ft[1],we[0],we[1],P,u);break;case Me.Butt:case Me.Round:Lt(we,v,M,p,g),su(p,g,b,we[0],we[1],P),s===Me.Round&&Or(0,p,g,b,we[0],we[1],we[0],we[1],P,u);break;default:throw new Error("LoftedLine: unknown Ending Type")}const R=i-1;for(let z=1;z<R;z++){p=e[z-1],g=t[z-1],b=n?.[z-1]??0,v=e[z],M=t[z],E=n?.[z]??0,T=e[z+1],L=t[z+1];const $=v-p,ee=M-g;P+=Math.sqrt($*$+ee*ee)/ne,Lt(Ft,v,M,p,g),Lt(we,T,L,v,M),Or(z,v,M,E,Ft[0],Ft[1],we[0],we[1],P,u)}p=e[i-2],g=t[i-2],b=n?.[i-2]??0,v=e[R],M=t[R],E=n?.[R]??0;const k=v-p,V=M-g;switch(P+=Math.sqrt(k*k+V*V)/ne,r){case Me.TileCut:Lt(Ft,v,M,p,g),Lt(we,c,l,v,M),A=Ja(v,M,E,Ft[0],Ft[1],we[0],we[1],u),A.noTurn?ru(R,v,M,E,we[0],we[1],P):ou(R,P,A);break;case Me.Butt:case Me.Round:Lt(we,v,M,p,g),ru(R,v,M,E,we[0],we[1],P),r===Me.Round&&Or(R,v,M,E,we[0],we[1],-we[0],-we[1],P,u);break;default:throw new Error("LoftedLine: unknown Ending Type")}}}function Ja(e,t,n,i,s,r,o,a){const c=Ow(e,t,n,i,s,r,o,a);if(!c.noTurn&&!c.reverseTurn){Qd(It,i,s,r,o);const l=It[0],d=It[1];c.extender[0]=l,c.extender[1]=d,c.faExtender[0]=l-i*2,c.faExtender[1]=d-s*2,c.saExtender[0]=l-r*2,c.saExtender[1]=d-o*2}else c.extender[0]=0,c.extender[1]=0,c.faExtender[0]=0,c.faExtender[1]=0,c.saExtender[0]=0,c.saExtender[1]=0;return c}function Ka(e,t,n,i,s,r,o,a,c,l){Qd(It,s,r,o,a),s*-a+r*o<0?Te(fe,ye,e,t,n,i,-It[0],-It[1],-It[0],-It[1],c,!1,l):Te(fe,ye,e,t,n,i,It[0],It[1],It[0],It[1],c,!1,l),ve++}function Or(e,t,n,i,s,r,o,a,c,l){const d=Ja(t,n,i,s,r,o,a,l);ou(e,c,d),Cw(e,c,d),Fw(e,c,d)}function su(e,t,n,i,s,r){Te(fe,ye,0,e,t,n,-i,-s,-i,-s,r,!1,Ot),Te(fe,ye,0,e,t,n,i,s,i,s,r,!1,Ct),ve=ve+2,Ge=1,We=0}function ru(e,t,n,i,s,r,o){const a=ve+1,c=ve;Te(fe,ye,e,t,n,i,-s,-r,-s,-r,o,!1,Ot),Te(fe,ye,e,t,n,i,s,r,s,r,o,!1,Ct),ve=ve+2,tn(ft,ut,We,c,Ge,Ge,c,a),Ge=a,We=c}function Cw(e,t,n){if(n.noTurn||n.patternedLine&&n.sharpTurn)return;const i=n.sharpTurn?2:1;let s,r;n.reverseTurn||n.patternedLine&&n.sharpTurn?(s=We,r=Ge):n.leftTurn?(s=Ge,r=ve+i):(s=ve+i,r=We);const o=ve;if(Qa(ft,ut,Ge,We,o),n.sharpTurn){const c=ve+1;n.leftTurn?tn(ft,ut,o,c,s,s,c,r):tn(ft,ut,o,r,c,c,r,s)}else n.leftTurn,Qa(ft,ut,o,r,s);const a=n.leftTurn?Ot:Ct;n.sharpTurn?(n.leftTurn?Lt(Oi,n.xn2,n.yn2,n.xn1,n.yn1):Lt(Oi,n.xn1,n.yn1,n.xn2,n.yn2),Ka(e,n.x,n.y,n.z,n.xn2,n.yn2,Oi[0],Oi[1],t,a),Ka(e,n.x,n.y,n.z,Oi[0],Oi[1],n.xn1,n.yn1,t,a)):Ka(e,n.x,n.y,n.z,n.xn2,n.yn2,n.xn1,n.yn1,t,a),n.reverseTurn||(n.leftTurn?Te(fe,ye,e,n.x,n.y,n.z,-n.xn1,-n.yn1,-n.xn1,-n.yn1,t,!1,a):Te(fe,ye,e,n.x,n.y,n.z,n.xn1,n.yn1,n.xn1,n.yn1,t,!1,a),ve++),We=r,Ge=s}function ou(e,t,n){if(n.noTurn)return;const i=ve+1,s=ve;if(n.reverseTurn||n.patternedLine&&n.sharpTurn?(Te(fe,ye,e,n.x,n.y,n.z,-n.xn2,-n.yn2,-n.xn2,-n.yn2,t,!1,Ot),Te(fe,ye,e,n.x,n.y,n.z,n.xn2,n.yn2,n.xn2,n.yn2,t,!1,Ct)):n.leftTurn?(Te(fe,ye,e,n.x,n.y,n.z,-n.xn2,-n.yn2,n.faExtender[0],n.faExtender[1],t,!0,Ot),Te(fe,ye,e,n.x,n.y,n.z,n.xn2,n.yn2,n.extender[0],n.extender[1],t,!0,Ct)):(Te(fe,ye,e,n.x,n.y,n.z,-n.xn2,-n.yn2,-n.extender[0],-n.extender[1],t,!0,Ot),Te(fe,ye,e,n.x,n.y,n.z,n.xn2,n.yn2,-n.faExtender[0],-n.faExtender[1],t,!0,Ct)),ve=ve+2,tn(ft,ut,We,s,Ge,Ge,s,i),We=s,Ge=i,!n.patternedLine&&!n.reverseTurn){const r=ve+1,o=ve;n.leftTurn?(Te(fe,ye,e,n.x,n.y,n.z,-n.xn2,-n.yn2,-n.xn2,-n.yn2,t,!1,0),Te(fe,ye,e,n.x,n.y,n.z,0,0,0,0,t,!1,0),tn(ft,ut,i,s,r,r,s,o)):(Te(fe,ye,e,n.x,n.y,n.z,0,0,0,0,t,!1,0),Te(fe,ye,e,n.x,n.y,n.z,n.xn2,n.yn2,n.xn2,n.yn2,t,!1,0),tn(ft,ut,s,o,i,i,o,r)),ve=ve+2,We=o,Ge=r}}function Fw(e,t,n){if(n.noTurn||n.reverseTurn)return;const i=ve+1,s=ve;if(n.patternedLine&&n.sharpTurn){Te(fe,ye,e,n.x,n.y,n.z,-n.xn1,-n.yn1,-n.xn1,-n.yn1,t,!1,Ot),Te(fe,ye,e,n.x,n.y,n.z,n.xn1,n.yn1,n.xn1,n.yn1,t,!1,Ct),ve=ve+2,We=s,Ge=i;return}else n.leftTurn?(Te(fe,ye,e,n.x,n.y,n.z,-n.xn1,-n.yn1,n.saExtender[0],n.saExtender[1],t,!1,Ot),Te(fe,ye,e,n.x,n.y,n.z,n.xn1,n.yn1,n.extender[0],n.extender[1],t,!1,Ct)):(Te(fe,ye,e,n.x,n.y,n.z,-n.xn1,-n.yn1,-n.extender[0],-n.extender[1],t,!1,Ot),Te(fe,ye,e,n.x,n.y,n.z,n.xn1,n.yn1,-n.saExtender[0],-n.saExtender[1],t,!1,Ct));ve=ve+2,n.leftTurn?tn(ft,ut,We,s,Ge,Ge,s,i):tn(ft,ut,Ge,We,i,i,We,s),We=s,Ge=i}function Te(e,t,n,i,s,r,o,a,c,l,d,f,u){const h=e.elements.offset*t.offsetMultiplier,y=h>>1,w=h<<1;if(e.views.position[h]=B+i,e.views.position[h+1]=B+s,e.views.extender[h]=Math.floor(c*_e*127+.5),e.views.extender[h+1]=Math.floor(l*_e*127+.5),t.type===Kn.Patterned){const p=e,g=1e-5;p.views.texture[y]=(g+d)*Math.sign(u)}else if(t.type===Kn.Striped){const p=e;p.views.texExtender[w]=Ne(o*_e),p.views.texExtender[w+1]=Ne(a*_e),p.views.vertexDistance[y]=d,p.views.objectLength[y]=t.oLen,"componentDistance"in e.views&&(e.views.componentDistance[y]=t.cDist)}else if(t.type===Kn.Entrance){const p=e,{px:g,py:b,count:v}=t,M=n===0,E=n===v-1,T=M?n:n-1,L=M?n+1:n;Vt(Xa,g[T],b[T],g[L],b[L]),p.views.direction[h]=Math.round(Xa[0]*127),p.views.direction[h+1]=Math.round(Xa[1]*127),p.views.type[y]=E?ds.LineEnding:ds.Line,p.views.texExtender[w]=Ne(o*(f||E?-1:1)*_e),p.views.texExtender[w+1]=Ne(a*(f||E?-1:1)*_e),p.views.vertexDistance[y]=d,p.views.objectLength[y]=t.oLen}e.views.localID[y]=t.localID,"height"in e.views&&(e.views.height[y]=r),e.elements.offset++}function Qa(e,t,n,i,s){const r=e.buffer,o=e.offset;r[o]=t+n,r[o+1]=t+i,r[o+2]=t+s,e.offset=o+3}function tn(e,t,n,i,s,r,o,a){const c=e.buffer,l=e.offset;c[l]=t+n,c[l+1]=t+i,c[l+2]=t+s,c[l+3]=t+r,c[l+4]=t+o,c[l+5]=t+a,e.offset=l+6}function ec(e){return Wi*e}function tc(e){return e/Wi}function Nw(e){return!!e.match(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-5][0-9a-f]{3}-[089ab][0-9a-f]{3}-[0-9a-f]{12}$/i)}const Rw={arrow:!0,buildingModel:!0,custom:!0,dashedLine:!0,embankment:!0,group:!0,heatmap:!0,labelLine:!0,line:!0,lineExtrusion:!0,metricPoint:!0,model:!0,oneWayLine:!0,overpass:!0,point:!0,polygon:!0,polygon3d:!0,polygonExtrusion:!0,raster:!0,shiftedLine:!0,tunnel:!0};function Bw(e){return Rw[e]}function kw(e){return e!=="group"&&e!=="custom"}function Uw(e){return e==="model"?"gltfModel":e!=="group"?e:void 0}function zw(){let e=new lt(4);return e[0]=1,e[1]=0,e[2]=0,e[3]=1,e}function Gw(e,t,n,i,s){return e[0]=t,e[1]=n,e[2]=i,e[3]=s,e}function jw(e){return e[0]*e[3]-e[2]*e[1]}function nc(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Cr={exports:{}},Fr={exports:{}},Hw=Fr.exports,au;function Vw(){return au||(au=1,(function(e,t){(function(n,i){e.exports=i()})(Hw,(function(){function n(o,a,c,l,d){i(o,a,c||0,l||o.length-1,d||r)}function i(o,a,c,l,d){for(;l>c;){if(l-c>600){var f=l-c+1,u=a-c+1,h=Math.log(f),y=.5*Math.exp(2*h/3),w=.5*Math.sqrt(h*y*(f-y)/f)*(u-f/2<0?-1:1),p=Math.max(c,Math.floor(a-u*y/f+w)),g=Math.min(l,Math.floor(a+(f-u)*y/f+w));i(o,a,p,g,d)}var b=o[a],v=c,M=l;for(s(o,c,a),d(o[l],b)>0&&s(o,c,l);v<M;){for(s(o,v,M),v++,M--;d(o[v],b)<0;)v++;for(;d(o[M],b)>0;)M--}d(o[c],b)===0?s(o,c,M):(M++,s(o,M,l)),M<=a&&(c=M+1),a<=M&&(l=M-1)}}function s(o,a,c){var l=o[a];o[a]=o[c],o[c]=l}function r(o,a){return o<a?-1:o>a?1:0}return n}))})(Fr)),Fr.exports}var cu;function $w(){if(cu)return Cr.exports;cu=1,Cr.exports=t,Cr.exports.default=t;var e=Vw();function t(p,g){if(!(this instanceof t))return new t(p,g);this._maxEntries=Math.max(4,p||9),this._minEntries=Math.max(2,Math.ceil(this._maxEntries*.4)),g&&this._initFormat(g),this.clear()}t.prototype={all:function(){return this._all(this.data,[])},search:function(p){var g=this.data,b=[],v=this.toBBox;if(!h(p,g))return b;for(var M=[],E,T,L,A;g;){for(E=0,T=g.children.length;E<T;E++)L=g.children[E],A=g.leaf?v(L):L,h(p,A)&&(g.leaf?b.push(L):u(p,A)?this._all(L,b):M.push(L));g=M.pop()}return b},collides:function(p){var g=this.data,b=this.toBBox;if(!h(p,g))return!1;for(var v=[],M,E,T,L;g;){for(M=0,E=g.children.length;M<E;M++)if(T=g.children[M],L=g.leaf?b(T):T,h(p,L)){if(g.leaf||u(p,L))return!0;v.push(T)}g=v.pop()}return!1},load:function(p){if(!(p&&p.length))return this;if(p.length<this._minEntries){for(var g=0,b=p.length;g<b;g++)this.insert(p[g]);return this}var v=this._build(p.slice(),0,p.length-1,0);if(!this.data.children.length)this.data=v;else if(this.data.height===v.height)this._splitRoot(this.data,v);else{if(this.data.height<v.height){var M=this.data;this.data=v,v=M}this._insert(v,this.data.height-v.height-1,!0)}return this},insert:function(p){return p&&this._insert(p,this.data.height-1),this},clear:function(){return this.data=y([]),this},remove:function(p,g){if(!p)return this;for(var b=this.data,v=this.toBBox(p),M=[],E=[],T,L,A,P;b||M.length;){if(b||(b=M.pop(),L=M[M.length-1],T=E.pop(),P=!0),b.leaf&&(A=n(p,b.children,g),A!==-1))return b.children.splice(A,1),M.push(b),this._condense(M),this;!P&&!b.leaf&&u(b,v)?(M.push(b),E.push(T),T=0,L=b,b=b.children[0]):L?(T++,b=L.children[T],P=!1):b=null}return this},toBBox:function(p){return p},compareMinX:o,compareMinY:a,toJSON:function(){return this.data},fromJSON:function(p){return this.data=p,this},_all:function(p,g){for(var b=[];p;)p.leaf?g.push.apply(g,p.children):b.push.apply(b,p.children),p=b.pop();return g},_build:function(p,g,b,v){var M=b-g+1,E=this._maxEntries,T;if(M<=E)return T=y(p.slice(g,b+1)),i(T,this.toBBox),T;v||(v=Math.ceil(Math.log(M)/Math.log(E)),E=Math.ceil(M/Math.pow(E,v-1))),T=y([]),T.leaf=!1,T.height=v;var L=Math.ceil(M/E),A=L*Math.ceil(Math.sqrt(E)),P,R,k,V;for(w(p,g,b,A,this.compareMinX),P=g;P<=b;P+=A)for(k=Math.min(P+A-1,b),w(p,P,k,L,this.compareMinY),R=P;R<=k;R+=L)V=Math.min(R+L-1,k),T.children.push(this._build(p,R,V,v-1));return i(T,this.toBBox),T},_chooseSubtree:function(p,g,b,v){for(var M,E,T,L,A,P,R,k;v.push(g),!(g.leaf||v.length-1===b);){for(R=k=1/0,M=0,E=g.children.length;M<E;M++)T=g.children[M],A=c(T),P=d(p,T)-A,P<k?(k=P,R=A<R?A:R,L=T):P===k&&A<R&&(R=A,L=T);g=L||g.children[0]}return g},_insert:function(p,g,b){var v=this.toBBox,M=b?p:v(p),E=[],T=this._chooseSubtree(M,this.data,g,E);for(T.children.push(p),r(T,M);g>=0&&E[g].children.length>this._maxEntries;)this._split(E,g),g--;this._adjustParentBBoxes(M,E,g)},_split:function(p,g){var b=p[g],v=b.children.length,M=this._minEntries;this._chooseSplitAxis(b,M,v);var E=this._chooseSplitIndex(b,M,v),T=y(b.children.splice(E,b.children.length-E));T.height=b.height,T.leaf=b.leaf,i(b,this.toBBox),i(T,this.toBBox),g?p[g-1].children.push(T):this._splitRoot(b,T)},_splitRoot:function(p,g){this.data=y([p,g]),this.data.height=p.height+1,this.data.leaf=!1,i(this.data,this.toBBox)},_chooseSplitIndex:function(p,g,b){var v,M,E,T,L,A,P,R;for(A=P=1/0,v=g;v<=b-g;v++)M=s(p,0,v,this.toBBox),E=s(p,v,b,this.toBBox),T=f(M,E),L=c(M)+c(E),T<A?(A=T,R=v,P=L<P?L:P):T===A&&L<P&&(P=L,R=v);return R},_chooseSplitAxis:function(p,g,b){var v=p.leaf?this.compareMinX:o,M=p.leaf?this.compareMinY:a,E=this._allDistMargin(p,g,b,v),T=this._allDistMargin(p,g,b,M);E<T&&p.children.sort(v)},_allDistMargin:function(p,g,b,v){p.children.sort(v);var M=this.toBBox,E=s(p,0,g,M),T=s(p,b-g,b,M),L=l(E)+l(T),A,P;for(A=g;A<b-g;A++)P=p.children[A],r(E,p.leaf?M(P):P),L+=l(E);for(A=b-g-1;A>=g;A--)P=p.children[A],r(T,p.leaf?M(P):P),L+=l(T);return L},_adjustParentBBoxes:function(p,g,b){for(var v=b;v>=0;v--)r(g[v],p)},_condense:function(p){for(var g=p.length-1,b;g>=0;g--)p[g].children.length===0?g>0?(b=p[g-1].children,b.splice(b.indexOf(p[g]),1)):this.clear():i(p[g],this.toBBox)},_initFormat:function(p){var g=["return a"," - b",";"];this.compareMinX=new Function("a","b",g.join(p[0])),this.compareMinY=new Function("a","b",g.join(p[1])),this.toBBox=new Function("a","return {minX: a"+p[0]+", minY: a"+p[1]+", maxX: a"+p[2]+", maxY: a"+p[3]+"};")}};function n(p,g,b){if(!b)return g.indexOf(p);for(var v=0;v<g.length;v++)if(b(p,g[v]))return v;return-1}function i(p,g){s(p,0,p.children.length,g,p)}function s(p,g,b,v,M){M||(M=y(null)),M.minX=1/0,M.minY=1/0,M.maxX=-1/0,M.maxY=-1/0;for(var E=g,T;E<b;E++)T=p.children[E],r(M,p.leaf?v(T):T);return M}function r(p,g){return p.minX=Math.min(p.minX,g.minX),p.minY=Math.min(p.minY,g.minY),p.maxX=Math.max(p.maxX,g.maxX),p.maxY=Math.max(p.maxY,g.maxY),p}function o(p,g){return p.minX-g.minX}function a(p,g){return p.minY-g.minY}function c(p){return(p.maxX-p.minX)*(p.maxY-p.minY)}function l(p){return p.maxX-p.minX+(p.maxY-p.minY)}function d(p,g){return(Math.max(g.maxX,p.maxX)-Math.min(g.minX,p.minX))*(Math.max(g.maxY,p.maxY)-Math.min(g.minY,p.minY))}function f(p,g){var b=Math.max(p.minX,g.minX),v=Math.max(p.minY,g.minY),M=Math.min(p.maxX,g.maxX),E=Math.min(p.maxY,g.maxY);return Math.max(0,M-b)*Math.max(0,E-v)}function u(p,g){return p.minX<=g.minX&&p.minY<=g.minY&&g.maxX<=p.maxX&&g.maxY<=p.maxY}function h(p,g){return g.minX<=p.maxX&&g.minY<=p.maxY&&g.maxX>=p.minX&&g.maxY>=p.minY}function y(p){return{children:p,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function w(p,g,b,v,M){for(var E=[g,b],T;E.length;)b=E.pop(),g=E.pop(),!(b-g<=v)&&(T=g+Math.ceil((b-g)/v/2)*v,e(p,T,g,b,M),E.push(g,T,T,b))}return Cr.exports}var Yw=$w();const Nr=nc(Yw);var ic,lu;function Zw(){if(lu)return ic;lu=1,ic=i;var e=128,t=-128,n=Math.pow(2,31);function i(s,r,o){if(Number.MAX_SAFE_INTEGER&&s>Number.MAX_SAFE_INTEGER)throw i.bytes=0,new RangeError("Could not encode varint");r=r||[],o=o||0;for(var a=o;s>=n;)r[o++]=s&255|e,s/=128;for(;s&t;)r[o++]=s&255|e,s>>>=7;return r[o]=s|0,i.bytes=o-a+1,r}return ic}var sc,du;function Ww(){if(du)return sc;du=1,sc=n;var e=128,t=127;function n(i,o){var r=0,o=o||0,a=0,c=o,l,d=i.length;do{if(c>=d||a>49)throw n.bytes=0,new RangeError("Could not decode varint");l=i[c++],r+=a<28?(l&t)<<a:(l&t)*Math.pow(2,a),a+=7}while(l>=e);return n.bytes=c-o,r}return sc}var rc,fu;function Xw(){if(fu)return rc;fu=1;var e=Math.pow(2,7),t=Math.pow(2,14),n=Math.pow(2,21),i=Math.pow(2,28),s=Math.pow(2,35),r=Math.pow(2,42),o=Math.pow(2,49),a=Math.pow(2,56),c=Math.pow(2,63);return rc=function(l){return l<e?1:l<t?2:l<n?3:l<i?4:l<s?5:l<r?6:l<o?7:l<a?8:l<c?9:10},rc}var oc,uu;function qw(){return uu||(uu=1,oc={encode:Zw(),decode:Ww(),encodingLength:Xw()}),oc}var Jw=qw();const hu=nc(Jw);class pu{constructor(t){const n=ArrayBuffer.isView(t)?t.buffer:t;this.buf=new Uint8Array(n),this.view=new DataView(n),this.pos=0}readBytes(t){const n=this.buf.subarray(this.pos,this.pos+t);return this.pos+=t,n}readUint8(){const t=this.view.getUint8(this.pos);return this.pos+=Uint8Array.BYTES_PER_ELEMENT,t}readUint16(){const t=this.view.getUint16(this.pos,!0);return this.pos+=Uint16Array.BYTES_PER_ELEMENT,t}readUint32(){const t=this.view.getUint32(this.pos,!0);return this.pos+=Uint32Array.BYTES_PER_ELEMENT,t}readInt32(){const t=this.view.getInt32(this.pos,!0);return this.pos+=Int32Array.BYTES_PER_ELEMENT,t}readVarint(){const t=hu.decode(this.buf,this.pos);return this.pos+=hu.decode.bytes??0,t}readSVarint(){const t=this.readVarint();return t%2===1?(t+1)/-2:t/2}skip(t){this.pos+=t}}function Kw(e){const t=new pu(e);t.readUint32(),t.readUint16(),t.readUint16(),t.readUint16(),t.readUint16();const n=ac(t.readInt32()),i=ac(t.readInt32()),s=t.readUint32(),r=[];for(let o=0;o<s;o++){const a=t.readUint32(),c=new Uint16Array(a*2);for(let w=0;w<a;w++)c[w*2]=t.readUint16(),c[w*2+1]=t.readUint16();const l=new Float32Array(a);mu(t,l,a,ac);const d=t.readUint32(),f=a>Oe?new Uint32Array(d):new Uint16Array(d);mu(t,f,d);const u={positions:c,heights:l,indices:f},h=t.readUint32();if(h>0){const w=[];new Int8Array(t.readBytes(h*3)).forEach(p=>w.push(Qw(p)))}const y=t.readUint32();if(y>0){const w={};for(let p=0;p<y;p++){const g=t.readUint16(),b=t.readInt32();w[g]=b}u.attributes=w}r.push(u)}return{dataGroups:r,minZ:n,maxZ:i}}function mu(e,t,n,i){let s=0;for(let r=0;r<n;r++){const a=e.readSVarint()+s;t[r]=i?i(a):a,s=a}}function ac(e){return e/me}function Qw(e){return e/127}function ev(e){const t=new yr(e),n=cc(t.readFixed32()),i=cc(t.readFixed32()),s=t.readFixed32(),r=t.readBytes(),o=new Uint16Array(r.buffer.slice(r.byteOffset,r.byteOffset+r.byteLength)),a=new Float32Array(s);for(let f=0;f<s;f++)a[f]=cc(t.readSVarint());let c=0;const l=t.readFixed32(),d=s>Oe?new Uint32Array(l):new Uint16Array(l);for(let f=0;f<l;f++){const u=t.readSVarint(),h=c+u;c+=u,d[f]=h}return{dataGroups:[{positions:o,heights:a,indices:d}],minZ:n,maxZ:i}}function cc(e){return e/100}function tv(e){const t=Math.log(e)*256;return t+(t<0?-.5:.5)<<16>>16}function ht(e){return e*32768+.5<<16>>>16}function nv(e){return Math.log(e)*256+.5<<16>>16}let iv=0;function bs(){return iv++}const Is=bs(),lc=bs(),yu=128,Mt={symbol:"dem",sinks:{mesh:{stride:4,binder:(e,t)=>{},packObjectAttributes(e,t){return[e,t]},unpackObjectAttributes(e){return{styleId:e[0],layerId:e[1],tileData:e.slice(3)}}},mesh2:{stride:8,binder:(e,t)=>{e.views.position=new Uint16Array(t),e.views.height=new Float32Array(t,4)},packObjectAttributes(e,t){return[e,t]},unpackObjectAttributes(e){return{styleId:e[0],layerId:e[1],tileData:e.slice(2)}}},hillshade:{stride:8,binder:(e,t)=>{},packObjectAttributes(e,t){return[e,t]},unpackObjectAttributes(e){return{styleId:e[0],layerId:e[1],tileData:e.slice(2)}}},flatBottom:{stride:12,binder:(e,t)=>{e.views.position=new Uint16Array(t),e.views.demPosition=new Int16Array(t,4),e.views.extender=new Int8Array(t,8)},packObjectAttributes(e,t,n){return n?[e,t,n]:[e,t]},unpackObjectAttributes(e){return{styleId:e[0],layerId:e[1],matrix:e[2]?e[2]:void 0,tileData:e.slice(3)}}}},generateMeshElevation(e,t,n,i){const s=e.getBucket("dem","mesh2",Mt.sinks.mesh2.packObjectAttributes(n,i),Mt.sinks.mesh2.binder);ov(s,t)},generateHillshade(e,t,n,i){const s=new Uint16Array(t.reduce((o,a)=>{const[c,l,d,f]=a;return o.push(c*ne,l*ne,ht(d),ht(f)),o},[]));return{symbol:Mt.symbol,sink:"hillshade",buffer:s.buffer,generatedObjects:[{drawMode:Js,attributes:Mt.sinks.hillshade.packObjectAttributes(n,i),rangeStart:0,rangeEnd:s.buffer.byteLength,extents:new Float32Array(6)}]}},generateFloorsBottomFill(e,t,n,i,s,r){const o=n[0],a=n[1],c=n[0].length,l=Mt.sinks.flatBottom.packObjectAttributes(t,Is,r),d=e.getBucket("dem","flatBottom",l,Mt.sinks.flatBottom.binder);sv(d,c,o,a,i,s,!!r)}};function sv(e,t,n,i,s,r,o){let a=e.elements.offset;const c=a;if(!(t<3)){dc(e,a++,n[0],i[0],r,s[0],o),dc(e,a++,n[1],i[1],r,s[1],o);for(let l=2;l<t;l++)rv(e,c,l),dc(e,a++,n[l],i[l],r,s[l],o);e.elements.offset=a}}function dc(e,t,n,i,s,r,o){const a=t*(e.elements.stride/e.views.position.BYTES_PER_ELEMENT),c=t*(e.elements.stride/e.views.extender.BYTES_PER_ELEMENT);e.views.position[a]=o?n:B+n,e.views.position[a+1]=o?i:B+i,e.views.demPosition[a]=(o?s[0]:B+s[0])/8,e.views.demPosition[a+1]=(o?s[1]:B+s[1])/8,e.views.extender[c]=r[0]*127,e.views.extender[c+1]=r[1]*127}function rv(e,t,n){const i=e.indices.buffer;let s=e.indices.offset;n%2===0?(i[s++]=t+n-2,i[s++]=t+n-1,i[s++]=t+n):(i[s++]=t+n-1,i[s++]=t+n-2,i[s++]=t+n),e.indices.offset=s}function ov(e,t,n=!1){for(let i=0;i<t.indices.length;i++){const s=t.indices[i],r=e.elements.offset*(e.elements.stride/e.views.position.BYTES_PER_ELEMENT),o=t.positions[s*2],a=t.positions[s*2+1];e.views.position[r]=B+(n?gu(o):o),e.views.position[r+1]=B+(n?gu(a):a);const c=e.elements.offset*(e.elements.stride/e.views.height.BYTES_PER_ELEMENT);e.views.height[c]=t.heights[s],e.elements.offset++,e.indices.buffer[e.indices.offset]=i,e.indices.offset++}}function gu(e){return e===0?e-=yu:e===ne&&(e+=yu),e}const av=(()=>{let e=new DataView(new ArrayBuffer(1025));return function(s){const r=s.toJSON(),o=t(r,0);return e.buffer.slice(0,o)};function t(s,r){i(r),e.setUint16(r,s.minX,!0),r+=2,e.setUint16(r,s.minY,!0),r+=2,e.setUint16(r,s.maxX,!0),r+=2,e.setUint16(r,s.maxY,!0),r+=2;const o=r;if(r+=4,s.children.length>127)throw new Error("Too many children in RBush node to serialize");return e.setUint8(r,(s.leaf?1:0)|s.children.length<<1),r+=1,s.children.forEach(a=>{s.leaf?r=n(a,r):r=t(a,r)}),e.setUint32(o,r-o-4,!0),r}function n(s,r){if(i(r),e.setUint16(r,s.minX,!0),r+=2,e.setUint16(r,s.minY,!0),r+=2,e.setUint16(r,s.maxX,!0),r+=2,e.setUint16(r,s.maxY,!0),r+=2,e.setUint32(r,s.posOffset,!0),r+=4,s.bucketIndex>255)throw new Error("[RTreeBin] Bucket index too large to serialize");if(e.setUint8(r,s.bucketIndex),r+=1,s.batchIndex>255)throw new Error("[RTreeBin] Batch index too large to serialize");return e.setUint8(r,s.batchIndex),r+=1,r}function i(s){if(e.buffer.byteLength<=s+256){const r=new ArrayBuffer(e.buffer.byteLength*2);new Uint8Array(r).set(new Uint8Array(e.buffer),0),e=new DataView(r)}}})();function cv(e,t){const n=new pu(e),i=[];return wu(n,t,i),i}function wu(e,t,n){const i=e.readUint16(),s=e.readUint16(),r=e.readUint16(),o=e.readUint16(),a=e.readUint32();if(t[0]<i||t[0]>r||t[1]<s||t[1]>o){e.skip(a);return}const c=e.readUint8(),l=(c&1)===1,d=c>>1;for(let f=0;f<d;f++)l?lv(e,t,n):wu(e,t,n)}function lv(e,t,n){const i=e.readUint16(),s=e.readUint16(),r=e.readUint16(),o=e.readUint16();if(i>t[0]||r<t[0]||s>t[1]||o<t[1]){e.skip(6);return}const a=e.readUint32(),c=e.readUint8(),l=e.readUint8();n.push({posOffset:a,bucketIndex:c,batchIndex:l,minX:i,minY:s,maxX:r,maxY:o})}const Ms=rt(),vu=rt(),dv=Ae(),fv=Ae(),bu=zw(),uv=64,Iu=9,Mu=(e,t,n,i,s)=>{const r=os(e.tileServer,{subdomain:e.subdomains[Math.abs(t+n)%e.subdomains.length]});return`${e.tileProtocol}://${r}/v2/ald?ts=${s}&x=${t}&y=${n}&z=${i}`};function hv(e){const t=[];return e.forEach((n,i)=>{n.symbol!=="dem"||n.sink!=="mesh2"||n.generatedObjects.forEach((s,r)=>{const o=Mt.sinks.mesh2.stride/Uint16Array.BYTES_PER_ELEMENT,a=new Uint16Array(n.buffer,s.rangeStart,(s.rangeEnd-s.rangeStart)/Uint16Array.BYTES_PER_ELEMENT);for(let c=0;c<a.length;c+=o*3){const l=c,d=c+o,f=c+o*2;t.push({minX:Math.min(a[l],a[d],a[f])-B,maxX:Math.max(a[l],a[d],a[f])-B,minY:Math.min(a[l+1],a[d+1],a[f+1])-B,maxY:Math.max(a[l+1],a[d+1],a[f+1])-B,posOffset:c,bucketIndex:i,batchIndex:r})}})}),t.length?av(Nr(Iu).load(t)):null}function fc(e,t,n){const i=n/(Float32Array.BYTES_PER_ELEMENT/Uint16Array.BYTES_PER_ELEMENT);return[e[n]-B,e[n+1]-B,t[i]]}function pv(e,t){if(!e.tree)return;const n=Se(Ms,t[0],t[1],0),i=Ca(e.key),s=Je(i),r=new Uint16Array(3),o=Mt.sinks.mesh2.stride/Uint16Array.BYTES_PER_ELEMENT;gt(r,n,s);const a=cv(e.tree,r);for(const c of a){const l=e.generated[0]?.collectorOutput.data[c.bucketIndex];if(!l||l.sink!=="mesh2")continue;const d=l.generatedObjects[c.bucketIndex],f=new Uint16Array(l.buffer,d.rangeStart,(d.rangeEnd-d.rangeStart)/Uint16Array.BYTES_PER_ELEMENT),u=new Float32Array(l.buffer,d.rangeStart+4,(d.rangeEnd-d.rangeStart)/Float32Array.BYTES_PER_ELEMENT-1),h=fc(f,u,c.posOffset),y=fc(f,u,c.posOffset+o),w=fc(f,u,c.posOffset+o*2),p=mv(h,y,w,r,Ms);if(!p)continue;return h[2]*p[0]+y[2]*p[1]+w[2]*p[2]}}function mv(e,t,n,i,s){const r=uc(e,t,n);if(r===0){if(e[0]===t[0]&&t[0]===n[0]&&e[1]===t[1]&&t[1]===n[1])return e[0]===i[0]&&e[1]===i[1]?(s[0]=1,s[1]=0,s[2]=0,s):null;let l=null;if(hc(e,t,i)){const d=Rr(e,t,i);l=$n(Ms,e,t,d),s[0]=1-d,s[1]=d,s[2]=0}if(hc(t,n,i)){const d=Rr(t,n,i),f=$n(vu,t,n,d);(!l||f[2]>l[2])&&(s[0]=0,s[1]=1-d,s[2]=d,l||(l=Ms),pa(l,f))}if(hc(n,e,i)){const d=Rr(n,e,i),f=$n(vu,n,e,d);(!l||f[2]>l[2])&&(s[0]=d,s[1]=0,s[2]=1-d,l||(l=Ms),pa(l,f))}if(l)return s}const o=uc(i,t,n)/r,a=uc(i,n,e)/r,c=1-o-a;return o<0||a<0||c<0||o>1||a>1||c>1?null:(s[0]=o,s[1]=a,s[2]=c,s)}function uc(e,t,n){return Gw(bu,t[0]-e[0],n[0]-e[0],t[1]-e[1],n[1]-e[1]),jw(bu)}function hc(e,t,n){const i=(t[0]-e[0])*(n[1]-e[1])-(t[1]-e[1])*(n[0]-e[0]);return Math.abs(i)>1e-8?!1:(n[0]-e[0])*(n[0]-t[0])+(n[1]-e[1])*(n[1]-t[1])<=0}function Rr(e,t,n){const i=Jt(dv,t,e),s=Jt(fv,n,e);return bn(s,i)/pm(i)}function yv(e){if(e.byteLength===0)return{positions:new Uint16Array,heights:new Float32Array,indices:new Uint16Array,maxZ:0,minZ:0};const t=new Uint32Array(e.slice(0,4))[0]===777275726,{dataGroups:n,minZ:i,maxZ:s}=t?Kw(e):ev(e),{positions:r,heights:o,indices:a}=n[0];return{positions:r,heights:o,indices:a,maxZ:s,minZ:i}}function pc(e,t,n,i,s){const r=tc(s);ii(i.textureImage).forEach(o=>{if(!o.length)return;const a=n.byKey[_r(o)];if(!a){console.error(`Not found raster set with texture ${o}`);return}const c=gv(i.textureSize),l=i.lengthUnits===_n.Meters;c.forEach(d=>{let[f,u]=Array.isArray(d)?d:[d,d];l&&(f=f*Er(f,f),u=u*Er(u,u)),a.isSvg?e.atlasPacker.packSvg(a,[{w:f,h:u}],r):e.atlasPacker.packPng(a,[{w:f,h:u}],r),a.rasters.forEach(h=>e.atlasPacker.addRastersToLoad(t,h))})})}function gv(e){return $t(e)?e.type==="step"?e.steps.map(t=>Array.isArray(t.value)||typeof t.value=="number"?t.value:t.value.type==="literalArray"?t.value.array:(console.warn("textureSize only supports shallow step expression"),[0])):e.type==="literalArray"?[Ye(e)]:(Pe(`Unsupported texture size expression of type "${e.type}". Can't resovle.`),[0]):[e]}function mc(e,t){const{tileAttrs:n,tileProps:i}=e,s=Number.isNaN(n[i.db_begin_nominal_height])?0:n[i.db_begin_nominal_height]??0,r=Number.isNaN(n[i.db_end_nominal_height])?0:n[i.db_end_nominal_height]??0,o=n[i.objectLength]??1,a=n[i.componentDistanceStart]??0,c=n[i.componentDistanceEnd]??0,l=vi(s,r,a/o),d=vi(s,r,c/o),f=e.tileInfo?vt(e.tileInfo,[0,0]):1,u=Array.from({length:t.x.length});if(l===d)return u.fill(l*me*f),u;const h=t.x.length;for(let y=0;y<h;y++)u[y]=me*f*vi(l,d,Rr([t.x[0],t.y[0]],[t.x[h-1],t.y[h-1]],[t.x[y],t.y[y]]));return u}const yc=e=>{for(let t=0;t<e.length;t++)if(e[t]!==0)return!0;return!1},Qe={symbol:"line",sinks:{solid:{stride:12,binder:(e,t)=>{e.views.position=new Uint16Array(t),e.views.extender=new Int8Array(t,4),e.views.normal=new Int8Array(t,6),e.views.localID=new Uint32Array(t,8)},packObjectAttributes(e,t,n,i,s){return Ee([e,t.innerId,n,i],t,s)},unpackObjectAttributes(e){return{styleId:e[0],layerId:e[1],tiers:e[2],hiddenByFloorComplexId:e[3],tileData:e.slice(4)}}},solid3d:{stride:20,binder:(e,t)=>{e.views.position=new Uint16Array(t),e.views.extender=new Int8Array(t,4),e.views.normal=new Int8Array(t,6),e.views.height=new Float32Array(t,8),e.views.absZ=new Float32Array(t,12),e.views.localID=new Uint32Array(t,16)},packObjectAttributes(e,t,n,i){return Ee([e,t.innerId,n],t,i)},unpackObjectAttributes(e){return{styleId:e[0],layerId:e[1],absZ:e[2],tileData:e.slice(3)}}},patterned:{stride:16,binder:(e,t)=>{e.views.position=new Uint16Array(t),e.views.extender=new Int16Array(t,4),e.views.texture=new Float32Array(t,8),e.views.localID=new Uint32Array(t,12)},packObjectAttributes(e,t,n,i,s){return Ee([e,t.innerId,n,i],t,s)},unpackObjectAttributes(e){return{styleId:e[0],layerId:e[1],tiers:e[2],hiddenByFloorComplexId:e[3],tileData:e.slice(3)}}},patterned3d:{stride:20,binder:(e,t)=>{e.views.position=new Uint16Array(t),e.views.extender=new Int16Array(t,4),e.views.texture=new Float32Array(t,8),e.views.height=new Float32Array(t,12),e.views.localID=new Uint32Array(t,16)},packObjectAttributes(e,t,n){return Ee([e,t.innerId],t,n)},unpackObjectAttributes(e){return{styleId:e[0],layerId:e[1],tileData:e.slice(2)}}}},generate(e,t,n,i,s,r){const o=xr(G(n.style.geometryModifier,i),s,r,i);if(o===null)return;const{tileAttrs:a,tileProps:c}=i;let l=n.style.mode==="3d";const d=l?o.z??mc(i,o):void 0;l&&(!d||!yc(d))&&(l=!1);const f=e.idIndexer.getIndex(i,t,n),u=G(n.ignoreTier,i)?null:i.tileAttrs[c.db_tiers],h=a[c.db_hidden_by_metro_building_id]||"",y=l?e.getBucket(n.type,"solid3d",Qe.sinks.solid3d.packObjectAttributes(t,n,!!o.abs_z,i),Qe.sinks.solid3d.binder):e.getBucket(n.type,"solid",Qe.sinks.solid.packObjectAttributes(t,n,u,h,i),Qe.sinks.solid.binder),w=Number.isNaN(a[c.beginningIsCut])?!1:a[c.beginningIsCut]!==0,p=Number.isNaN(a[c.endingIsCut])?!1:a[c.endingIsCut]!==0,g=Ke(n.style.startCap,i),b=Ke(n.style.endCap,i);xf(y,o.x,o.y,d,o.abs_z,o.x.length,w?Me.TileCut:Br(g),p?Me.TileCut:Br(b),f)},generatePatterned(e,t,n,i,s,r){const o=xr(G(n.style.geometryModifier,i),s,r,i);if(o===null)return;const{tileAttrs:a,tileProps:c}=i,l=G(n.ignoreTier,i)?null:i.tileAttrs[c.db_tiers],d=a[c.db_hidden_by_metro_building_id]??"";let f=n.style.mode==="3d";const u=f?o.z??mc(i,o):void 0;f&&(!u||!yc(u))&&(f=!1);const h=f?e.getBucket("line","patterned3d",Qe.sinks.patterned3d.packObjectAttributes(t,n,i),Qe.sinks.patterned3d.binder):e.getBucket("line","patterned",Qe.sinks.patterned.packObjectAttributes(t,n,l,d,i),Qe.sinks.patterned.binder),y=e.idIndexer.getIndex(i,t,n),w=wv(a[c.componentDistanceStart]/ne,a[c.componentDistanceEnd]/ne,a[c.objectLength]/ne,y,f?Qe.sinks.patterned3d.stride/2:Qe.sinks.patterned.stride/2),p=Number.isNaN(a[c.beginningIsCut])?!1:a[c.beginningIsCut]!==0,g=Number.isNaN(a[c.endingIsCut])?!1:a[c.endingIsCut]!==0,b=Ke(n.style.startCap,i),v=Ke(n.style.endCap,i);qa(o.x,o.y,u,o.x.length,p?Me.TileCut:Br(b),g?Me.TileCut:Br(v),a[c.previousPointX],a[c.previousPointY],a[c.nextPointX],a[c.nextPointY],w,h,!0)}},Ci={type:Kn.Patterned,cDist:0,sLen:0,oLen:0,localID:0,offsetMultiplier:8,px:[],py:[],count:0};function wv(e,t,n,i,s){return Ci.cDist=e,Ci.sLen=t-e,Ci.oLen=n,Ci.localID=i,Ci.offsetMultiplier=s,Ci}function Br(e){switch(e){case"round":return Me.Round;case"tilecut":return Me.TileCut;case"butt":default:return Me.Butt}}const kr={symbol:"shiftedLine",sinks:{solid:{stride:16,binder:(e,t)=>{e.views.position=new Uint16Array(t),e.views.extender=new Int8Array(t,4),e.views.normal=new Int8Array(t,6),e.views.shift=new Float32Array(t,8)},packObjectAttributes(e,t,n,i){return Ee([e,t.innerId,n],t,i)},unpackObjectAttributes(e){return{styleId:e[0],layerId:e[1],tiers:e[2],tileData:e.slice(3)}}}},generate(e,t,n,i,s){const{tileAttrs:r,tileProps:o}=i,a=Number.isNaN(r[o.beginningIsCut])?!1:r[o.beginningIsCut]!==0,c=Number.isNaN(r[o.endingIsCut])?!1:r[o.endingIsCut]!==0,l=G(n.ignoreTier,i)?null:i.tileAttrs[o.db_tiers],d=e.getBucket(n.type,"solid",kr.sinks.solid.packObjectAttributes(t,n,l,i),kr.sinks.solid.binder);xf(d,s.x,s.y,void 0,void 0,s.x.length,a?Me.TileCut:Me.Round,c?Me.TileCut:Me.Round,0,s.normal_x,s.normal_y)}};function et(e,t){return e===0?0:Math.min(e*2-1,(t-e)*2)}function gc(e,t,n,i,s,r,o=0,a,c,l,d){let f=e.elements.offset;for(let u=0;u<t;u++){const h=et(u,t),y=u===t-1;if((!s||s[h]!==1)&&(s||y))continue;const w=n[h],p=i[h],g=(u+1)%t,b=et(g,t),v=n[b],M=i[b];if(d){const E=Math.hypot(v-w,M-p)*d.tileSizeMapPoints/ne;if(E<d.wallPaddingMapPoints[1]+d.wallPaddingMapPoints[3]+d.textureWidthMapPoints)continue;switch(d.config.horizontal.mode){case"repeat-with-stretch":{const T=d.config.horizontal.slicesCount,L=(E-(d.wallPaddingMapPoints[1]+d.wallPaddingMapPoints[3]))/d.textureWidthMapPoints,A=Math.round(L*T);if(A<d.config.horizontal.minSliceRepeats)continue;const R=A/T/L;if(d.config.horizontal.maxResizeFactor&&R>d.config.horizontal.maxResizeFactor||d.config.horizontal.minResizeFactor&&R<d.config.horizontal.minResizeFactor)continue;break}case"repeat-with-max-interval":break;default:continue}switch(d.config.vertical.mode){case"repeat-with-stretch":{const T=d.config.vertical.slicesCount,L=(r-(d.wallPaddingMapPoints[0]+d.wallPaddingMapPoints[2]))/d.textureHeightMapPoints,A=Math.round(L*T);if(A<d.config.vertical.minSliceRepeats)continue;const R=A/T/L;if(R>d.config.vertical.maxResizeFactor||R<d.config.vertical.minResizeFactor)continue;break}case"repeat-with-max-interval":break;case"stripe-top":break;default:continue}Eu(e,f),Tu(e,f,w,p,v,M,r,o),vv(e,f,r-o,E)}else Eu(e,f),Tu(e,f,w,p,v,M,r,0);l?Su(e,f,l[0],l[1],l[0],l[1]):Su(e,f,w,p,v,M),a!==void 0&&"localID"in e.views&&e.views.localID!==void 0&&Au(e.views.localID,f,a,e.elements.stride),c!==void 0&&"labelingTextureID"in e.views&&e.views.labelingTextureID!==void 0&&Au(e.views.labelingTextureID,f,c,e.elements.stride),f=f+4}e.elements.offset=f}function Tu(e,t,n,i,s,r,o,a=0){const c=e.views.position,l=e.views.height,d=e.elements.stride/c.BYTES_PER_ELEMENT;t=t*d,c[t]=B+n,c[t+1]=B+i,l[t>>1]=$e(a)/Oe,t+=d,c[t]=B+n,c[t+1]=B+i,l[t>>1]=$e(o)/Oe,t+=d,c[t]=B+s,c[t+1]=B+r,l[t>>1]=$e(a)/Oe,t+=d,c[t]=B+s,c[t+1]=B+r,l[t>>1]=$e(o)/Oe}function vv(e,t,n,i){const s=e.views.fillIndices,r=e.views.fillRect,o=e.elements.stride/s.BYTES_PER_ELEMENT,a=e.elements.stride/r.BYTES_PER_ELEMENT;let c=t*o,l=t*a;s[c]=0,s[c+1]=1,r[l]=i,r[l+1]=n,c+=o,l+=a,s[c]=0,s[c+1]=0,r[l]=i,r[l+1]=n,c+=o,l+=a,s[c]=1,s[c+1]=1,r[l]=i,r[l+1]=n,c+=o,l+=a,s[c]=1,s[c+1]=0,r[l]=i,r[l+1]=n}function Su(e,t,n,i,s,r){const o=e.views.demPosition,a=e.elements.stride/o.BYTES_PER_ELEMENT;t=t*a,n=(n+B)/8,i=(i+B)/8,s=(s+B)/8,r=(r+B)/8,o[t]=n,o[t+1]=i,t+=a,o[t]=n,o[t+1]=i,t+=a,o[t]=s,o[t+1]=r,t+=a,o[t]=s,o[t+1]=r}function Au(e,t,n,i){const s=i/e.BYTES_PER_ELEMENT;t=t*s,e[t]=n,e[t+=s]=n,e[t+=s]=n,e[t+=s]=n}function Eu(e,t){const n=e.indices.buffer;let i=e.indices.offset;n[i++]=t,n[i++]=t+3,n[i++]=t+1,n[i++]=t,n[i++]=t+2,n[i++]=t+3,e.indices.offset=i}const nn=[.5,.5],sn=[.5,.5];function wc(e,t,n,i,s,r){let o=e.elements.offset;const a=et(t-1,t);let c=n[a],l=i[a],d=s?s[a]:0;const f=o;for(let u=0;u<t;u++){const h=et(u,t),y=u===t-1,w=n[h],p=i[h],g=s?s[h]:y?0:1;d!==0&&(Vt(sn,c,l,w,p),_u(e,o,g,y?f:o+4),Iv(e,o,c,l,w,p),r?xu(e,o,r[0],r[1],r[0],r[1]):xu(e,o,c,l,w,p),Ma(sn),Mv(e,o,sn),Tv(e,o,sn),o=o+4),c=w,l=p,d=g}e.elements.offset=o}function vc(e,t,n,i,s,r,o){let a=e.elements.offset;const c=et(t-2,t),l=et(t-1,t);let d=n[l],f=i[l],u=s?s[c]:1,h=s?s[l]:0;Lt(nn,n[c],i[c],d,f);let y=nn[0],w=nn[1];for(let p=0;p<t;p++){const g=et(p,t),b=p===t-1,v=n[g],M=i[g],E=s?s[g]:b?0:1;Vt(sn,d,f,v,M);const T=sn[1],L=-sn[0];u!==0&&(h===0?(nn[0]=y,nn[1]=w):bv(nn,y,w,T,L),M1(sn,y,w,nn[0],nn[1]),_u(e,a,0,0),Sv(e,a,d,f,r,o??[d,f]),Av(e,a,Ma(nn),Ma(sn)),Ev(e,a),a=a+4),d=v,f=M,u=h,h=E,y=T,w=L}e.elements.offset=a}function bv(e,t,n,i,s){let r,o,a;t*i+n*s>0?(r=t+i,o=n+s,a=1/Math.sqrt(r*r+o*o),e[0]=r*a,e[1]=o*a):(r=s-n,o=t-i,r!==0&&o!==0?(a=1/Math.sqrt(r*r+o*o),e[0]=r*a,e[1]=o*a):(e[0]=0,e[1]=0))}function xu(e,t,n,i,s,r){const o=e.views.demPosition,a=e.elements.stride/o.BYTES_PER_ELEMENT;t=t*a,n=(n+B)/8,i=(i+B)/8,s=(s+B)/8,r=(r+B)/8,o[t]=n,o[t+1]=i,t+=a,o[t]=n,o[t+1]=i,t+=a,o[t]=s,o[t+1]=r,t+=a,o[t]=s,o[t+1]=r}function Iv(e,t,n,i,s,r){const{position:o,distance:a,height:c}=e.views,l=e.elements.stride/o.BYTES_PER_ELEMENT;t=t*l,o[t]=B+n,o[t+1]=B+i,c[t>>1]=0,a[t<<1]=0,t+=l,o[t]=B+n,o[t+1]=B+i,c[t>>1]=0,a[t<<1]=-1,t+=l,o[t]=B+s,o[t+1]=B+r,c[t>>1]=0,a[t<<1]=-1,t+=l,o[t]=B+s,o[t+1]=B+r,c[t>>1]=0,a[t<<1]=0}function Mv(e,t,n){const i=e.elements.stride/e.views.normals.BYTES_PER_ELEMENT;t=t*i;for(let s=0;s<4;s++)e.views.normals[t]=n[0],e.views.normals[t+1]=n[1],e.views.normals[t+2]=0,e.views.normals[t+3]=0,t+=i}function Tv(e,t,n){const i=e.elements.stride/e.views.direction.BYTES_PER_ELEMENT;t=t*i;for(let s=0;s<4;s++)e.views.direction[t]=n[0],e.views.direction[t+1]=n[1],e.views.direction[t+2]=0,t+=i}function Sv(e,t,n,i,s,r){const o=e.elements.stride/e.views.position.BYTES_PER_ELEMENT;t=t*o,e.views.position[t]=B+n,e.views.position[t+1]=B+i,e.views.height[t>>1]=0,e.views.distance[t<<1]=1,e.views.demPosition[t]=(B+r[0])/8,e.views.demPosition[t+1]=(B+r[1])/8,t+=o,e.views.position[t]=B+n,e.views.position[t+1]=B+i,e.views.height[t>>1]=0,e.views.distance[t<<1]=-1,e.views.demPosition[t]=(B+r[0])/8,e.views.demPosition[t+1]=(B+r[1])/8,t+=o,e.views.position[t]=B+n,e.views.position[t+1]=B+i,e.views.height[t>>1]=$e(s)/Oe,e.views.distance[t<<1]=-1,e.views.demPosition[t]=(B+r[0])/8,e.views.demPosition[t+1]=(B+r[1])/8,t+=o,e.views.position[t]=B+n,e.views.position[t+1]=B+i,e.views.height[t>>1]=$e(s)/Oe,e.views.distance[t<<1]=1,e.views.demPosition[t]=(B+r[0])/8,e.views.demPosition[t+1]=(B+r[1])/8}function Av(e,t,n,i){const s=e.elements.stride/e.views.normals.BYTES_PER_ELEMENT;t=t*s;for(let r=0;r<4;r++)e.views.normals[t]=n[0],e.views.normals[t+1]=n[1],e.views.normals[t+2]=i[0],e.views.normals[t+3]=i[1],t+=s}function Ev(e,t){const n=e.elements.stride/e.views.direction.BYTES_PER_ELEMENT;t=t*n;for(let i=0;i<4;i++)e.views.direction[t]=0,e.views.direction[t+2]=127,t+=n}function _u(e,t,n,i){const s=e.indices.buffer;let r=e.indices.offset;s[r++]=t,s[r++]=t+1,s[r++]=t+3,s[r++]=t+3,s[r++]=t+1,s[r++]=t+2,n!==0&&(s[r++]=t+2,s[r++]=i+1,s[r++]=i+0),e.indices.offset=r}const Ts=rt(),Ss=rt(),rn=rt();function As(e,t,n,i,s,r,o,a,c,l,d,f,u,h){Se(Ts,t,n,i),Se(Ss,s,r,o),Gt(rn,Ss,Ts),Zm(Ss,Ts)||(zt(rn,rn),Tn(rn,rn,127)),xv(e,0,1,3,3,1,2),Ur(e,Ts,rn,1,a,c,l,d,u),Ur(e,Ts,rn,-1,a,c,l,d,u),Ur(e,Ss,rn,-1,a,c,l,f,h),Ur(e,Ss,rn,1,a,c,l,f,h)}function Ur(e,t,n,i,s,r,o,a,c){const l=e.elements.offset*e.elements.stride,d=l/e.views.position.BYTES_PER_ELEMENT;if(e.views.position[d]=r?t[0]:B+t[0],e.views.position[d+1]=r?t[1]:B+t[1],"height"in e.views){const f=l/e.views.height.BYTES_PER_ELEMENT;e.views.height[f]=(r?t[2]:o?t[2]*Mf:$e(t[2]))/Oe}if(e.views.directionDistance[l]=n[0],e.views.directionDistance[l+1]=n[1],e.views.directionDistance[l+2]=n[2],e.views.directionDistance[l+3]=i,"demPosition"in e.views){const f=l/e.views.demPosition.BYTES_PER_ELEMENT;s=s??t,e.views.demPosition[f]=(r?s[0]:B+s[0])/8,e.views.demPosition[f+1]=(r?s[1]:B+s[1])/8}"absZ"in e.views&&a!==void 0&&(e.views.absZ[l/e.views.absZ.BYTES_PER_ELEMENT]=a),"isPivot"in e.views&&(e.views.isPivot[l/e.views.isPivot.BYTES_PER_ELEMENT]=c??0),e.elements.offset++}function xv(e,t,n,i,s,r,o){const a=e.indices.buffer,c=e.indices.offset,l=e.elements.offset;a[c]=l+t,a[c+1]=l+n,a[c+2]=l+i,a[c+3]=l+s,a[c+4]=l+r,a[c+5]=l+o,e.indices.offset=c+6}const _v=/\.png$/i;function Pv(e){return!!e&&e.type==="polygon"}function Lv(e){return!!e&&e.type==="line"}function Pu(e){return e.reduce((t,n,i)=>(t[n]=i,t),{})}function Dv(e){return e===void 0||typeof e=="boolean"?!!e:!!JSON.stringify(e).match(/\["get","(db_)?sublayer"]/)}function Ov(e){return!e?.url.match(_v)}function Lu(e,t){return wi(G(e.style.sideColor,t),G(e.style.sideStrokeColor,t))}const zr=ne/2,Cv=1/$e(1),ri=(e,t,n,i,s,r,o)=>Ee([e,t.innerId,n,i,s,r],t,o),Es=e=>({styleId:e[0],layerId:e[1],hiddenByFloorComplexId:e[2],floorId:e[3],isFloorStack:e[4],textureIndex:e[5],tileData:e.slice(6)}),On={symbol:"polygonExtrusion",sinks:{sideFill:{stride:20,binder:(e,t)=>{e.views.position=new Uint16Array(t),e.views.height=new Float32Array(t,4),e.views.localID=new Uint32Array(t,8),e.views.demPosition=new Int16Array(t,12),e.views.labelingTextureID=new Uint32Array(t,16)},packObjectAttributes:ri,unpackObjectAttributes:Es},sideTexture:{stride:24,binder:(e,t)=>{e.views.position=new Uint16Array(t),e.views.height=new Float32Array(t,4),e.views.demPosition=new Int16Array(t,8),e.views.fillRect=new Float32Array(t,12),e.views.fillIndices=new Uint8Array(t,20)},packObjectAttributes:ri,unpackObjectAttributes:Es},topFill:{stride:20,binder:(e,t)=>{e.views.position=new Uint16Array(t),e.views.height=new Float32Array(t,4),e.views.localID=new Uint32Array(t,8),e.views.demPosition=new Int16Array(t,12),e.views.labelingTextureID=new Uint32Array(t,16)},packObjectAttributes:ri,unpackObjectAttributes:Es},sideStroke:{stride:20,binder:(e,t)=>{e.views.position=new Uint16Array(t),e.views.height=new Float32Array(t,4),e.views.normals=new Int8Array(t,8),e.views.direction=new Int8Array(t,12),e.views.distance=new Int8Array(t,15),e.views.demPosition=new Int16Array(t,16)},packObjectAttributes:ri,unpackObjectAttributes:Es},topStroke:{stride:16,binder:(e,t)=>{e.views.position=new Uint16Array(t),e.views.height=new Float32Array(t,4),e.views.directionDistance=new Int8Array(t,8),e.views.demPosition=new Int16Array(t,12)},packObjectAttributes:ri,unpackObjectAttributes:Es}},generate(e,t,n,i,s,r){const o=s.x,a=s.y,c=s.cut??[],l=i.tileAttrs[i.tileProps.db_plan_id]||"",d=i.tileAttrs[i.tileProps.db_hidden_by_plan_building_id]||"",f=i.tileAttrs[i.tileProps.db_sublayer]==="Floor_half_walls_width_extended_ground",u=o.length,h=i.id??"";let y;i.tileProps.db_centroid_x!==void 0&&i.tileProps.db_centroid_y!==void 0&&!Number.isNaN(i.tileAttrs[i.tileProps.db_centroid_x])&&!Number.isNaN(i.tileAttrs[i.tileProps.db_centroid_y])?y=[i.tileAttrs[i.tileProps.db_centroid_x],i.tileAttrs[i.tileProps.db_centroid_y]]:y=kv(o,a,c);const w=G(n.style.height,i),p=i.tileInfo?vt(i.tileInfo,[0,0]):1,g=Math.max(w*me*p,Cv),b=e.idIndexer.getIndex(i,t,n,{floorId:Number.isNaN(l)?void 0:l}),v=e.pointIndexer.getIndex(h),M=ri(t,n,d,l,f,NaN,i);if(g>0){const A=e.getBucket("polygonExtrusion","sideFill",M,On.sinks.sideFill.binder);let P=A.indices.offset;if(gc(A,u,o,a,c,g,0,b,v,y),A.objectsData[P]={objectId:h,size:A.indices.offset-P},n.style.sideTextures.forEach((R,k)=>{if(w<R.minWallHeight)return;const V=R.sliceSize[0]*me*p,z=R.sliceSize[1]*me*p,$=R.wallPadding.map(O=>O*me*p),ee=wt(i.tileInfo?.coords[2]??15),I=ri(t,n,d,l,f,k,i),_=e.getBucket("polygonExtrusion","sideTexture",I,On.sinks.sideTexture.binder),S=_.indices.offset,D=R.vertical.mode==="stripe-top"?g-z:0;gc(_,u,o,a,c,g,D,void 0,void 0,y,{config:R,textureWidthMapPoints:V,textureHeightMapPoints:z,wallPaddingMapPoints:$,tileSizeMapPoints:ee}),_.objectsData[S]={objectId:h,size:_.indices.offset-S}}),!l&&(!r.AALinesOff||!Lu(n,i))){const R=e.getBucket("polygonExtrusion","sideStroke",M,On.sinks.sideStroke.binder);P=R.indices.offset,wc(R,u,o,a,c,y),vc(R,u,o,a,c,g,y),R.objectsData[P]={objectId:h,size:R.indices.offset-P}}}const E=e.getBucket("polygonExtrusion","topFill",M,On.sinks.topFill.binder);let T=E.indices.offset;Fv(E,u,o,a,g,b,v,y),E.objectsData[T]={objectId:h,size:E.indices.offset-T};const L=e.getBucket("polygonExtrusion","topStroke",M,On.sinks.topStroke.binder);T=L.indices.offset,Nv(L,u,o,a,c,g,y),L.objectsData[T]={objectId:h,size:L.indices.offset-T}}};function Fv(e,t,n,i,s,r,o,a){let c=e.elements.offset;const l=c;bc(e,c++,n[0],i[0],s,r,o,a),bc(e,c++,n[1],i[1],s,r,o,a);for(let d=2;d<t;d++)Rv(e,l,d),bc(e,c++,n[d],i[d],s,r,o,a);e.elements.offset=c}function Nv(e,t,n,i,s,r,o){for(let a=0;a<t;a++){const c=et(a,t);if(s&&s[c]===1){const l=et((a+1)%t,t);As(e,n[c],i[c],r,n[l],i[l],r,o)}}}function bc(e,t,n,i,s,r,o,a){const c=e.elements.stride,l=t*(c/e.views.position.BYTES_PER_ELEMENT),d=t*(c/e.views.height.BYTES_PER_ELEMENT);e.views.position[l]=B+n,e.views.position[l+1]=B+i,e.views.height[d]=$e(s)/Oe,e.views.demPosition[l]=(B+a[0])/8,e.views.demPosition[l+1]=(B+a[1])/8;const f=t*(c/e.views.localID.BYTES_PER_ELEMENT);e.views.localID[f]=r,e.views.labelingTextureID[f]=o}function Rv(e,t,n){const i=e.indices.buffer;let s=e.indices.offset;n%2===0?(i[s++]=t+n-2,i[s++]=t+n-1,i[s++]=t+n):(i[s++]=t+n-1,i[s++]=t+n-2,i[s++]=t+n),e.indices.offset=s}function Du(e){return(zr-Math.abs(e[0]-zr))**2+(zr-Math.abs(e[1]-zr))**2}function Bv(e){return e[0]===0||e[0]===ne||e[1]===0||e[1]===ne}function kv(e,t,n){let i,s=ne**2;const r=e.length,o=is();for(let a=0;a<r;a++){i||Wn(o,[e[a],t[a]]);const c=et(a,r);if(n[c]===0){const l=[e[c],t[c]],d=et((a+1)%r,r),f=[e[d],t[d]];if(Bv(l)){const u=Du(l);u<s&&(i=l,s=u);const h=Du(f);h<s&&(i=f,s=h)}else i=[(e[c]+e[d])/2,(t[c]+t[d])/2]}}return i||(i=[],fr(i,o)),i}const xs={type:Kn.Striped,cDist:0,oLen:0,sLen:0,localID:0,offsetMultiplier:14,px:[],py:[],count:0};function Uv(e,t,n,i){return xs.cDist=e,xs.oLen=t,xs.localID=n,xs.offsetMultiplier=i,xs}const on={symbol:"dashedLine",sinks:{stroke:{stride:28,binder:(e,t)=>{e.views.position=new Uint16Array(t),e.views.extender=new Int16Array(t,4),e.views.texExtender=new Int8Array(t,8),e.views.vertexDistance=new Float32Array(t,12),e.views.componentDistance=new Float32Array(t,16),e.views.objectLength=new Float32Array(t,20),e.views.localID=new Uint32Array(t,24)},packObjectAttributes(e,t,n,i,s){return Ee([e,t.innerId,n,i],t,s)},unpackObjectAttributes(e){return{styleId:e[0],layerId:e[1],tiers:e[2],hiddenByFloorComplexId:e[3],tileData:e.slice(4)}}},stroke3d:{stride:32,binder:(e,t)=>{e.views.position=new Uint16Array(t),e.views.extender=new Int16Array(t,4),e.views.texExtender=new Int8Array(t,8),e.views.vertexDistance=new Float32Array(t,12),e.views.componentDistance=new Float32Array(t,16),e.views.objectLength=new Float32Array(t,20),e.views.height=new Float32Array(t,24),e.views.localID=new Uint32Array(t,28)},packObjectAttributes(e,t,n){return Ee([e,t.innerId],t,n)},unpackObjectAttributes(e){return{styleId:e[0],layerId:e[1],tileData:e.slice(2)}}}},generate(e,t,n,i,s,r){const o=xr(G(n.style.geometryModifier,i),s,r,i);if(o===null)return;const{tileAttrs:a,tileProps:c}=i,l=G(n.ignoreTier,i)?null:i.tileAttrs[c.db_tiers],d=a[c.db_hidden_by_metro_building_id]||"";let f=n.style.mode==="3d";const u=f?o.z??mc(i,o):void 0;f&&(!u||!yc(u))&&(f=!1);const h=f?e.getBucket(n.type,"stroke3d",on.sinks.stroke3d.packObjectAttributes(t,n,i),on.sinks.stroke3d.binder):e.getBucket(n.type,"stroke",on.sinks.stroke.packObjectAttributes(t,n,l,d,i),on.sinks.stroke.binder),y=e.idIndexer.getIndex(i,t,n),w=Uv(a[c.componentDistanceStart]/ne,a[c.objectLength]/ne,y,f?on.sinks.stroke3d.stride/2:on.sinks.stroke.stride/2),p=Number.isNaN(a[c.beginningIsCut])?!1:a[c.beginningIsCut]!==0,g=Number.isNaN(a[c.endingIsCut])?!1:a[c.endingIsCut]!==0;qa(o.x,o.y,u,o.x.length,p?Me.TileCut:Me.Butt,g?Me.TileCut:Me.Butt,a[c.previousPointX],a[c.previousPointY],a[c.nextPointX],a[c.nextPointY],w,h)}},Gr=[Oe/2,Oe/2],an={symbol:"buildingModel",sinks:{fill:{stride:24,binder:(e,t)=>{e.views.position=new Uint16Array(t),e.views.height=new Float32Array(t,4),e.views.texCoords=new Uint16Array(t,8),e.views.localID=new Uint32Array(t,12),e.views.demPosition=new Int16Array(t,16),e.views.labelingTextureID=new Uint32Array(t,20)},packObjectAttributes:(e,t,n,i,s,r)=>Ee([e,t.innerId,n,s,i],t,r),unpackObjectAttributes:e=>({styleId:e[0],layerId:e[1],texture:e[2],id:e[3],matrix:e[4],tileData:e.slice(5)})},stroke:{stride:16,binder:(e,t)=>{e.views.position=new Uint16Array(t),e.views.height=new Float32Array(t,4),e.views.directionDistance=new Int8Array(t,8),e.views.demPosition=new Int16Array(t,12)},packObjectAttributes:(e,t,n,i,s)=>Ee([e,t.innerId,i,n],t,s),unpackObjectAttributes:e=>({styleId:e[0],layerId:e[1],id:e[2],matrix:e[3],tileData:e.slice(4)})}},processSubmesh(e,t,n,i,s,r,o,a,c){const l=n.id??"",d=i.idIndexer.getIndex(n,e,t),f=i.pointIndexer.getIndex(l),u=i.getBucket(t.type,"fill",an.sinks.fill.packObjectAttributes(e,t,a,c,l,n),an.sinks.fill.binder,o);Gv(u,r);for(let h=0;h<s.length;h++)zv(u,s,h,d,f)},processOuterEdge(e,t,n,i,s,r,o){const a=n.id??"",c=i.getBucket(t.type,"stroke",an.sinks.stroke.packObjectAttributes(e,t,o,a,n),an.sinks.stroke.binder);for(let l=0;l<r.length;l+=2){const d=r[l]*5,f=r[l+1]*5;As(c,s[d],s[d+1],s[d+2],s[f],s[f+1],s[f+2],Gr,!0)}}};function zv(e,t,n,i,s){const r=e.elements.offset,o=an.sinks.fill.stride,a=n*5,c=r*(o/e.views.position.BYTES_PER_ELEMENT),l=r*(o/e.views.localID.BYTES_PER_ELEMENT);e.views.position[c]=t[a],e.views.position[c+1]=t[a+1],e.views.height[l]=t[a+2]/Oe,e.views.texCoords[c]=t[a+3],e.views.texCoords[c+1]=t[a+4],e.views.localID[l]=i,e.views.demPosition[c]=Gr[0]/8,e.views.demPosition[c+1]=Gr[1]/8,e.views.labelingTextureID[l]=s,e.elements.offset++}function Gv(e,t){const n=e.elements.offset;let i=e.indices.offset;for(let s=0;s<t.length;s++)e.indices.buffer[i++]=n+t[s];e.indices.offset=i}const Fi=Ae(),_s=Ae(),Ni={type:Kn.Entrance,offsetMultiplier:18,cDist:0,oLen:0,sLen:0,px:[],py:[],count:0,localID:0};function jv(e,t,n,i){return Ni.px=e.x,Ni.py=e.y,Ni.oLen=n/ne,Ni.count=t,Ni.localID=i,Ni}const Ps={symbol:"arrow",sinks:{stroke:{stride:36,binder:(e,t)=>{e.views.position=new Uint16Array(t),e.views.segmentEnd=new Uint16Array(t,4),e.views.texExtender=new Int8Array(t,8),e.views.arrowExtender=new Int8Array(t,10),e.views.extender=new Int16Array(t,12),e.views.direction=new Int16Array(t,16),e.views.vertexDistance=new Float32Array(t,20),e.views.objectLength=new Float32Array(t,24),e.views.type=new Float32Array(t,28),e.views.localID=new Uint32Array(t,32)},packObjectAttributes(e,t,n,i){return Ee([e,t.innerId,n>2?1:0],t,i)},unpackObjectAttributes(e){return{styleId:e[0],layerId:e[1],isLongArrow:e[2],tileData:e.slice(3)}}}},generate:(e,t,n,i,s)=>{const r=s.x,o=s.y,a=s.x.length,c=Hv(r,o,a),l=e.getBucket(n.type,"stroke",Ps.sinks.stroke.packObjectAttributes(t,n,a,i),Ps.sinks.stroke.binder),d=e.idIndexer.getIndex(i,t,n),f=jv(s,a,c,d);qa(s.x,s.y,void 0,a,Me.Butt,Me.Butt,0,0,0,0,f,l);let u=0;Ou(l,ds.StartBorder,r[0],o[0],r[1],o[1],0,0,u,c,d);for(let h=0;h<a-1;h++){if(h!==0){const y=r[h]-r[h-1],w=o[h]-o[h-1];u+=Math.sqrt(y*y+w*w)}Ou(l,ds.Arrow,r[h],o[h],r[h+1],o[h+1],-1,0,u,c,d)}}};function Hv(e,t,n){let i=0;for(let s=1;s<n;s++){const r=e[s]-e[s-1],o=t[s]-t[s-1];i+=Math.sqrt(r*r+o*o)}return i}function Ou(e,t,n,i,s,r,o,a,c,l,d){Vv(e,1,2,0,0,2,3),jr(e,t,n,i,s,r,o,a,-1,-1,c,l,!0,d),jr(e,t,n,i,s,r,o,a,1,-1,c,l,!1,d),jr(e,t,n,i,s,r,o,a,1,1,c,l,!1,d),jr(e,t,n,i,s,r,o,a,-1,1,c,l,!0,d)}function jr(e,t,n,i,s,r,o,a,c,l,d,f,u,h){const y=e.elements,w=y.stride*y.offset,p=w>>1,g=p>>1;Vt(Fi,n,i,s,r),Sn(_s,Fi),e.views.position[p]=B+n,e.views.position[p+1]=B+i,e.views.segmentEnd[p]=B+s,e.views.segmentEnd[p+1]=B+r,e.views.texExtender[w]=Ne(_s[0]*l*(u?-1:1)*_e),e.views.texExtender[w+1]=Ne(_s[1]*l*(u?-1:1)*_e),e.views.arrowExtender[w]=Ne(c*_e),e.views.arrowExtender[w+1]=Ne(l*_e);const b=c+o,v=l+a,M=Fi[0]*b+_s[0]*v,E=Fi[1]*b+_s[1]*v;e.views.extender[p]=Math.round(M*_e*127),e.views.extender[p+1]=Math.round(E*_e*127),e.views.direction[p]=Math.round(Fi[0]*127),e.views.direction[p+1]=Math.round(Fi[1]*127),e.views.vertexDistance[g]=d/Oe,e.views.objectLength[g]=f/Oe,e.views.type[g]=t,e.views.localID[g]=h,e.elements.offset++}function Vv(e,t,n,i,s,r,o){const{elements:a,indices:c}=e,{buffer:l,offset:d}=c,f=a.offset;l[d]=f+t,l[d+1]=f+n,l[d+2]=f+i,l[d+3]=f+s,l[d+4]=f+r,l[d+5]=f+o,c.offset=d+6}const Hr={symbol:"circle",sinks:{fill:{stride:20,binder:(e,t)=>{e.views.flatPosition=new Uint16Array(t),e.views.ecefPosition=new Int16Array(t,6),e.views.extender=new Int16Array(t,12),e.views.localID=new Uint32Array(t,16)},packObjectAttributes:(e,t,n)=>Ee([e,t.innerId],t,n),unpackObjectAttributes:e=>({styleId:e[0],layerId:e[1],tileData:e.slice(2)})}},generate(e,t,n,i,s){const r=e.getBucket(n.type,"fill",Hr.sinks.fill.packObjectAttributes(t,n,i),Hr.sinks.fill.binder),o=e.idIndexer.getIndex(i,t,n),a=[s.x[0],s.y[0],s.z?s.z[0]:0],c=i.tileInfo?Ba(i.tileInfo,a):[0,0,0];$v(r,0,2,1,0,3,2),Vr(r,a,c,-1,-1,o),Vr(r,a,c,-1,1,o),Vr(r,a,c,1,1,o),Vr(r,a,c,1,-1,o)}};function Vr(e,[t,n,i],s,r,o,a){const l=e.elements.offset*e.elements.stride>>1,d=l>>1;e.views.flatPosition[l]=B+t,e.views.flatPosition[l+1]=B+n,e.views.flatPosition[l+2]=$e(i),e.views.ecefPosition[l]=s[0]*Xe,e.views.ecefPosition[l+1]=s[1]*Xe,e.views.ecefPosition[l+2]=s[2]*Xe,e.views.extender[l]=r,e.views.extender[l+1]=o,e.views.localID[d]=a,e.elements.offset++}function $v(e,t,n,i,s,r,o){const{elements:a,indices:c}=e,{buffer:l,offset:d}=c,f=a.offset;l[d]=f+t,l[d+1]=f+n,l[d+2]=f+i,l[d+3]=f+s,l[d+4]=f+r,l[d+5]=f+o,c.offset=d+6}const Ri=Ae(),Bi=Ae(),Cu=Ae(),Fu=Ae(),Ic=(e,t,n,i)=>Ee([e,t.innerId,n],t,i),Mc=e=>({styleId:e[0],layerId:e[1],hiddenByFloorComplexId:e[2],tileData:e.slice(3)}),Ls=Tf(1),cn={symbol:"lineExtrusion",sinks:{fill:{stride:12,binder:(e,t)=>{e.views.position=new Uint16Array(t),e.views.height=new Float32Array(t,4),e.views.demPosition=new Int16Array(t,8)},packObjectAttributes:Ic,unpackObjectAttributes:Mc},topStroke:{stride:16,binder:(e,t)=>{e.views.position=new Uint16Array(t),e.views.height=new Float32Array(t,4),e.views.directionDistance=new Int8Array(t,8),e.views.demPosition=new Int16Array(t,12)},packObjectAttributes:Ic,unpackObjectAttributes:Mc},sideStroke:{stride:20,binder:(e,t)=>{e.views.position=new Uint16Array(t),e.views.height=new Float32Array(t,4),e.views.normals=new Int8Array(t,8),e.views.direction=new Int8Array(t,12),e.views.distance=new Int8Array(t,15),e.views.demPosition=new Int16Array(t,16)},packObjectAttributes:Ic,unpackObjectAttributes:Mc}},generate(e,t,n,i,s,r){const o=s.x,a=s.y,c=o.length,l=i.tileAttrs[i.tileProps.db_hidden_by_metro_building_id]||"",d=e.getBucket(n.type,"fill",cn.sinks.fill.packObjectAttributes(t,n,l,i),cn.sinks.fill.binder),f=e.getBucket(n.type,"topStroke",cn.sinks.topStroke.packObjectAttributes(t,n,l,i),cn.sinks.topStroke.binder),u=e.getBucket(n.type,"sideStroke",cn.sinks.sideStroke.packObjectAttributes(t,n,l,i),cn.sinks.sideStroke.binder),h=!r.AALinesOff||!Lu(n,i);for(let y=0;y<c-1;y++){const w=o[y],p=a[y],g=o[y+1],b=a[y+1];Ce(Ri,w,g),Ce(Bi,p,b),Ce(Cu,g,w),Ce(Fu,b,p),gc(d,2,Ri,Bi,void 0,Ls),As(f,w,p,Ls,g,b,Ls),h&&(wc(u,2,Ri,Bi,void 0),wc(u,2,Cu,Fu,void 0),vc(u,2,Ri,Bi,void 0,Ls))}h&&(Ce(Ri,o[c-1],o[0]),Ce(Bi,a[c-1],a[0]),vc(u,2,Ri,Bi,void 0,Ls))}},$r={symbol:"raster",sinks:{fill:{stride:8,binder:(e,t)=>{e.views.position=new Uint16Array(t),e.views.txtrCoords=new Uint16Array(t,4)},packObjectAttributes(e,t,n,i,s){return Ee([e,t.innerId,i,s],t,n)},unpackObjectAttributes(e){return{styleId:e[0],layerId:e[1],textureIndex:e[2],tiers:e[3],tileData:e.slice(4)}}}},generate(e,t,n,i,s,r,o){const a=t.x,c=t.y,l=e.getBucket(s.type,"fill",$r.sinks.fill.packObjectAttributes(n,s,i,r,o),$r.sinks.fill.binder);let d=l.elements.offset;Yv(l.indices,d,0,1,2,2,1,3),Yr(l,d++,a[0],c[0],0,1),Yr(l,d++,a[1],c[1],1,1),Yr(l,d++,a[2],c[2],0,0),Yr(l,d++,a[3],c[3],1,0),l.elements.offset=d}};function Yr(e,t,n,i,s,r){t=t*4,e.views.position[t]=B+n,e.views.position[t+1]=B+i,e.views.txtrCoords[t]=ht(s),e.views.txtrCoords[t+1]=ht(r)}function Yv(e,t,n,i,s,r,o,a){const c=e.buffer,l=e.offset;c[l]=t+n,c[l+1]=t+i,c[l+2]=t+s,c[l+3]=t+r,c[l+4]=t+o,c[l+5]=t+a,e.offset=l+6}function Tc(e,t,n,i,s,r){return Ee([e,t.innerId,n,i,s],t,r)}const Zv=(e,t,n,i,s)=>Ee([e,t.innerId,n,i],t,s),Sc=e=>({styleId:e[0],layerId:e[1],tiers:e[2],floorId:e[3],hiddenByFloorComplexId:e[4],tileData:e.slice(5)}),Wv=e=>({styleId:e[0],layerId:e[1],tiers:e[2],floorId:e[3],tileData:e.slice(4)}),Xv=(e,t)=>{const n=e.type==="polygon"&&G(e.style.color,t),i=Rf(n)&&n.factor.type==="vertexAttribute";return i?{withMixFactor:i,mixFactorAttributeName:n.factor.name}:{withMixFactor:i,mixFactorAttributeName:void 0}},Nt={symbol:"polygon",sinks:{fill:{stride:8,binder:(e,t)=>{e.views.position=new Uint16Array(t),e.views.localID=new Uint32Array(t,4)},packObjectAttributes:Tc,unpackObjectAttributes:Sc},stroke:{stride:8,binder:(e,t)=>{e.views.position=new Uint16Array(t),e.views.directionDistance=new Int8Array(t,4)},packObjectAttributes:Tc,unpackObjectAttributes:Sc},shadow:{stride:4,binder:(e,t)=>{e.views.position=new Uint16Array(t)},packObjectAttributes:Zv,unpackObjectAttributes:Wv},fillWithMixFactor:{stride:8,binder:(e,t)=>{e.views.position=new Uint16Array(t),e.views.mixFactor=new Uint16Array(t,4)},packObjectAttributes:Tc,unpackObjectAttributes:Sc}},generate(e,t,n,i,s,r,o){if(i.tileAttrs[i.tileProps.db_geometry_type]==="polyline")return;const{withMixFactor:c,mixFactorAttributeName:l}=Xv(n,i),d=s.x,f=s.y,u=s.cut,h=i.tileAttrs[i.tileProps.db_plan_id]||"",y=c?s[l]:void 0;if(Pv(n)&&o&&(pc(e,t,o,n.style,r),n.style.normalMapTextureImage)){const T={textureImage:n.style.normalMapTextureImage,textureSize:n.style.normalMapTextureSize,lengthUnits:n.style.normalMapTextureLengthUnits};pc(e,t,o,T,r)}const w=e.idIndexer.getIndex(i,t,n,{floorId:h||void 0}),p=i.id??"",g=n.type==="polygon"&&!G(n.ignoreTier,i)?i.tileAttrs[i.tileProps.db_tiers]:null,b=i.tileAttrs[i.tileProps.db_hidden_by_metro_building_id]||"",v=c?e.getBucket("polygon","fillWithMixFactor",Nt.sinks.fillWithMixFactor.packObjectAttributes(t,n,g,h,b,i),Nt.sinks.fillWithMixFactor.binder):e.getBucket("polygon","fill",Nt.sinks.fill.packObjectAttributes(t,n,g,h,b,i),Nt.sinks.fill.binder),M=v.indices.offset;Nu(v,d.length,d,f,w,y),v.objectsData[M]={objectId:p,size:v.indices.offset-M};const E=e.getBucket("polygon","stroke",Nt.sinks.stroke.packObjectAttributes(t,n,g,h,b,i),Nt.sinks.stroke.binder);if(u){const T=E.indices.offset;qv(E,d.length,d,f,u),E.objectsData[T]={objectId:p,size:E.indices.offset-T}}}};function Nu(e,t,n,i,s,r){const o=e.indices.buffer;let a=e.indices.offset,c=e.elements.offset;const l=c;Ac(e,c++,n[0],i[0],s,r?.[0]),Ac(e,c++,n[1],i[1],s,r?.[1]);for(let d=2;d<t;d++)Jv(o,a,l,d),Ac(e,c++,n[d],i[d],s,r?.[d]),a=a+3;e.elements.offset=c,e.indices.offset=a}function qv(e,t,n,i,s){for(let r=0;r<t;r++){const o=et(r,t);if(s[o]===1){const a=et((r+1)%t,t);As(e,n[o],i[o],0,n[a],i[a],0)}}}function Ac(e,t,n,i,s,r){t=t*e.elements.stride/e.views.position.BYTES_PER_ELEMENT,e.views.position[t]=B+n,e.views.position[t+1]=B+i,r!==void 0&&"mixFactor"in e.views&&(e.views.mixFactor[t]=r),t=t>>1,"localID"in e.views&&(e.views.localID[t]=s)}function Jv(e,t,n,i){i%2===0?(e[t]=n+i-2,e[t+1]=n+i-1,e[t+2]=n+i):(e[t]=n+i-1,e[t+1]=n+i-2,e[t+2]=n+i)}function Kv(e,t,n=[],i=[]){return{x:Ru(n,e),y:Ru(i,t)}}function Ru(e,t){const n=e.reduce((s,r)=>s.concat(r),[0]).concat(t),i=n.length-1;return{coords:n.slice(n[0]===n[1]?1:0,n[i-1]===n[i]?i:i+1),isOddStretchable:Qv(e)}}function Qv(e){return!e?.[0]?.[0]}function e2(e,t,n,i,s){return[Bu(e.x,t,i[0],s),Bu(e.y,n,i[1],s)]}function Bu(e,t,n,i){if(e.coords.length<2)throw new Error("The source coords array must have at least two coordinates");return e.coords.map((s,r)=>(t+s+i*(r===0?-1:r===e.coords.length-1?1:0))/n)}function t2(e,t,n,i,s=0,r=0){return[Uu(ku(e.x,t),i,s),Uu(ku(e.y,n),i,r)]}function ku(e,t){const{stretchSize:n,fixSize:i}=n2(e),{coords:s,isOddStretchable:r}=e,o=t<i?i:t,a=[s[0]];for(let c=1;c<s.length;c++){const l=s[c-1],d=s[c],f=c%2===(r?1:0),u=a[a.length-1];if(!f){a.push(u+d-l);continue}a.push(Math.round((o-i)*(d-l)/n)+u)}return a}function n2({coords:e,isOddStretchable:t}){if(e.length<2)throw new Error("An axis must have at least two coordinates");if(e.length===2)return{stretchSize:e[e.length-1],fixSize:0};let n=0;for(let i=t?0:1;i<e.length-1;i=i+2)n+=e[i+1]-e[i];return{stretchSize:n,fixSize:e[e.length-1]-n}}function Uu(e,t,n=0){const i=e[e.length-1]-e[0],s=e.map(r=>Math.round(r-i/2+n));return s.length===2?s[s.length-1]+=2*t:(s[0]-=t,s[s.length-1]+=t),s}function i2(e,t,n,i,s,r,o,a,c){const l=Kv(n.w,n.h,a,c),d=e2(l,n.x,n.y,t,Kl),f=t2(l,i,s,Kl,r,o);e.set(f,d)}function s2(e,t,n,i,s,r,o,a,c,l,d,f){const{textureX:u,textureY:h,stretchedX:y,stretchedY:w,countX:p,countY:g}=s,b=o!==-1/0?o:qp,v=a!==1/0?a:Jp,[M,E]=f;for(let T=0;T<p-1;T++){const L=u[T],A=u[T+1],P=y[T],R=y[T+1];for(let k=0;k<g-1;k++){const V=h[k],z=h[k+1],$=w[k],ee=w[k+1];zu(r,0,2,1,1,2,3),Zr(r,e,t,n,i,P,$,L,V,M,E,b,v,c,l,d),Zr(r,e,t,n,i,R,$,A,V,M,E,b,v,c,l,d),Zr(r,e,t,n,i,P,ee,L,z,M,E,b,v,c,l,d),Zr(r,e,t,n,i,R,ee,A,z,M,E,b,v,c,l,d)}}}const oi=[0,0];function r2(e,t,n,i,s,r,o){const{stretchedX:a,stretchedY:c}=i,l=Math.ceil((a[a.length-1]-a[0])/2),d=Math.ceil((c[c.length-1]-c[0])/2),f=r*$o/2;oi[0]=a[0]+l,oi[1]=c[0]+d;const u=oi[0]-f,h=oi[0]+f,y=oi[1]-f,w=oi[1]+f;return zu(s,0,2,1,1,2,3),Wr(s,e,t,n,u,y,o),Wr(s,e,t,n,h,y,o),Wr(s,e,t,n,u,w,o),Wr(s,e,t,n,h,w,o),oi}function Zr(e,t,n,i,s,r,o,a,c,l,d,f,u,h,y,w){let p=e.elements.offset*20;e.views.flatPosition[p]=B+t,e.views.flatPosition[p+1]=B+n,e.views.flatPosition[p+2]=$e(i),e.views.ecefPosition[p]=s[0]*Xe,e.views.ecefPosition[p+1]=s[1]*Xe,e.views.ecefPosition[p+2]=s[2]*Xe,e.views.cornerOffset[p]=r,e.views.cornerOffset[p+1]=-o,e.views.checkPointOffset[p]=l,e.views.checkPointOffset[p+1]=d,e.views.texCoords[p]=ht(a),e.views.texCoords[p+1]=ht(c),e.views.scales[p]=nv(f),e.views.scales[p+1]=tv(u),p=p>>1,e.views.localID[p]=h,e.views.labelingTextureID[p]=y,e.views.spritePointTextureID[p]=w,e.elements.offset++}function Wr(e,t,n,i,s,r,o){const a=e.elements,c=a.stride*a.offset>>1;e.views.position[c]=B+t,e.views.position[c+1]=B+n,e.views.position[c+2]=$e(i),e.views.cornerOffset[c]=s,e.views.cornerOffset[c+1]=-r,e.views.labelingTextureID[c>>1]=o,a.offset++}function zu(e,t,n,i,s,r,o){const{elements:a,indices:c}=e,{buffer:l,offset:d}=c,f=a.offset;l[d]=f+t,l[d+1]=f+n,l[d+2]=f+i,l[d+3]=f+s,l[d+4]=f+r,l[d+5]=f+o,c.offset=d+6}class o2{constructor(){this.countX=0,this.countY=0,this.textureX=[],this.textureY=[],this.stretchedX=[],this.stretchedY=[]}reset(){this.countX=0,this.countY=0}set(t,n){this.countX=n[0].length,this.countY=n[1].length,this.textureX=n[0],this.textureY=n[1],this.stretchedX=t[0],this.stretchedY=t[1]}isEmpty(){return this.countX===0||this.countY===0}}var tt=(e=>(e[e.Common=0]="Common",e[e.Commercial=1]="Commercial",e[e.CommercialCity=2]="CommercialCity",e[e.CommercialPremium=3]="CommercialPremium",e[e.Landmark=4]="Landmark",e))(tt||{}),ai=(e=>(e[e.Point=0]="Point",e[e.Line=1]="Line",e))(ai||{}),Ds=(e=>(e[e.Tile=0]="Tile",e[e.Floor=1]="Floor",e[e.DynamicObject=2]="DynamicObject",e[e.PersonalPoi=3]="PersonalPoi",e))(Ds||{}),Tt=(e=>(e[e.Dead=0]="Dead",e[e.Alive=1]="Alive",e[e.Unused=2]="Unused",e[e.CommercialAlive=3]="CommercialAlive",e[e.CommercialDead=4]="CommercialDead",e))(Tt||{}),Re=(e=>(e[e.Text=0]="Text",e[e.Icon=1]="Icon",e[e.PoiText=2]="PoiText",e[e.PoiText2=3]="PoiText2",e[e.OneWayLine=4]="OneWayLine",e[e.LineText=5]="LineText",e[e.Box=6]="Box",e))(Re||{});let Gu=Math.random;const a2=e=>{const t={randomSeed:0};jf(t,[e]),Gu=()=>ys(t,0,1)};function c2(e,t,n,i){const s=ju(e,n,i),r=ju(t,n,i);return s===void 0&&r===void 0?!0:s===void 0?r!==void 0?r:!0:r===void 0?s!==void 0?s:!0:s||r}function ju(e,t,n){const i=e[t];if(i!==void 0)return i[n]}var ln=(e=>(e[e.Point=0]="Point",e[e.Line=1]="Line",e[e.OneWayLine=2]="OneWayLine",e))(ln||{});function nt(e,t){return Number.isNaN(e)?t:e}function Xr(e,t){if(!e)return"";const n=G(e,t);return!Number.isNaN(n)&&(n||n===0)?String(n):""}const it=4294967295,dn=4294967040,l2=dn-1,Ec={},d2=1e6,Hu=["main","parser","labeling","models"];let xc=0;Hu.forEach(e=>{const t=xc+Math.floor(l2/Hu.length);Ec[e]={min:xc,max:t-d2},xc=t});class f2{constructor(t){this.ids=[],this.orphanIds=[],this.phases=[],this.sublayers=[],this.styleIds=[],this.layerIds=[],this.instanceIds=[],this.objectClasses=[],this.floorIds=[],this.center=[],this.strings={},this.minIdentifyIndex=Ec[t].min,this.maxIdentifyIndex=Ec[t].max,this.index=this.minIdentifyIndex}getIndex(t,n,i,s={}){const{id:r,tileProps:o,tileAttrs:a}=t,c=i.interactive,l=s.ignoreHover?!1:a[o.hovered],d=l&&i.type!=="polygon3d"||i.type==="embankment";return!!r&&c&&!l&&!d?this.getIndexInternal({id:r,styleId:n,layer:i,sublayer:a[o.db_sublayer],...s}):it}getIndexInternal(t){const n=this.index+this.ids.length;this.ids.push(t.id),this.floorIds.push(t.floorId??""),this.phases.push(t.layer.renderIndex),this.sublayers.push(t.metatile?.dictionaries.db_sublayer?.[t.sublayer]??NaN),this.styleIds.push(t.styleId),this.layerIds.push(t.layer.innerId),this.instanceIds.push(t.instanceId??0);const{center:i,objectClass:s}=t;if(i?this.center.push(Math.round(i[0]),Math.round(i[1])):this.center.push(Vo,Vo),typeof s=="string"){const r=t.metatile?.dictionaries.db_object_class?.[s];r?this.objectClasses.push(r):(this.objectClasses.push(0),this.strings[n]={objectClass:s})}else this.objectClasses.push(it);return n}addOrphanId(t){this.orphanIds.push(t)}getIndexerStats(){return{ids:this.ids.length,orphanIds:this.orphanIds.length,floorIds:this.floorIds.length,phases:this.phases.length,sublayers:this.sublayers.length,styleIds:this.styleIds.length,layerIds:this.layerIds.length,instanceIds:this.instanceIds.length,objectClasses:this.objectClasses.length,strings:Object.keys(this.strings).length,center:this.center.length}}getPacked(){const t=this.ids,n=this.orphanIds,i=this.floorIds,s=new Float32Array(this.phases).buffer,r=new Uint32Array(this.sublayers).buffer,o=new Uint16Array(this.styleIds).buffer,a=new Uint32Array(this.layerIds).buffer,c=new Uint8Array(this.instanceIds).buffer,l=new Uint32Array(this.objectClasses).buffer,d=new Int32Array(this.center).buffer,f=this.index,u=this.index+this.ids.length-1;this.index=this.index+this.ids.length,this.index>this.maxIdentifyIndex&&(this.index=this.minIdentifyIndex);const h=this.strings;return this.ids=[],this.orphanIds=[],this.floorIds=[],this.phases=[],this.sublayers=[],this.styleIds=[],this.layerIds=[],this.instanceIds=[],this.objectClasses=[],this.strings={},this.center=[],{idBuffer:t,orphanIds:n,floorIdBuffer:i,startIndex:f,endIndex:u,phaseBuffer:s,sublayerBuffer:r,styleIdBuffer:o,layerIdBuffer:a,instanceIdBuffer:c,objectClassBuffer:l,centerBuffer:d,strings:h}}}function u2(e){return e.type==="labelLine"||e.type==="point"||e.type==="oneWayLine"}function h2(e,t,n,i,s){const r=[];for(const o of e)for(const a of o.labels){const c=n.getStyle(a.styleId);if(!c){console.error(`Not found style ${a.styleId} in unpackPreLabelingResult`);continue}const l=c.layersById[a.layerId];if(!l||!u2(l)){console.error(`Not found layer: ${a.layerId} in style ${a.styleId} in unpackPreLabelingResult`);continue}const d=new _c(a,l,t,o.metatileHash,!!i.floorStackOn);switch(a.type){case ln.Point:d.setSpecificPointAttributes(a,i,s);break;case ln.Line:d.setSpecificLineAttributes(a,i,s);break;case ln.OneWayLine:d.setSpecificOneWayAttributes(a);break}r.push(d)}return r}class _c{constructor(t,n,i,s,r){this.rtlProcessed=!1,this.labelingElements=[],this.id="",this.floorId="",this.planLevel=NaN,this.detailLevel=0,this.labelPriority=0,this.label="",this.ranges=[],this.pointType=tt.Common,this.iconPriority=0,this.styleIconPriority=0,this.styleTextPriority=0,this.identifyIndex=it,this.identifyPoiLabelIndex=it,this.labelingTextureIndex=it,this.spritePointTextureIndex=it,this.hovered=0,this.label2Priority=0,this.mapPointVertices=[0,0,0],this.geoPoint=[NaN,NaN],this.demElevation=0,this.elevation=0,this.componentDistanceStartWorld=0,this.componentDistanceEnd=0,this.componentDistanceStart=0,this.objectLengthWorld=0,this.checkPointOffset=[0,0],this.layer=n,this.styleId=t.styleId,this.source=i,this.sourceId=t.sourceId,this.metatileHash=s,this.geometryType=t.type===ln.Point?t.geometryType:ai.Line,this.tileData=t.tileData,this.labelPriority=t.labelPriority,this.detailLevel=t.tileCoords[2],this.styleIconPriority=t.styleIconPriority,this.styleTextPriority=t.styleTextPriority,this.id=t.id,this.floorId=t.floorId,this.planLevel=r?Math.max(0,t.planLevel):0}setSpecificPointAttributes(t,n,i){if(this.layer.type!=="point")throw new Error("Label: layer type is not a point");const s=this.layer.style;this.pointType=t.pointType,this.label2Priority=t.label2Priority,this.iconPriority=t.iconPriority,this.identifyIndex=t.identifyIndex,this.identifyPoiLabelIndex=t.identifyPoiLabelIndex,this.labelingTextureIndex=t.labelingTextureIndex,this.spritePointTextureIndex=t.spritePointTextureIndex,this.hovered=t.hovered,this.demElevation=t.demElevation;const r=Dt(i,n,!0,t.tileData);this.label=$a(Xr(s.textField,r),s.textMaxLengthPerLine),s.textField2&&(this.label2=$a(Xr(s.textField2,r),s.textMaxLengthPerLine)),this.layer.type==="point"&&s.iconTextField&&(this.iconLabel=$a(Xr(s.iconTextField,r),s.textMaxLengthPerLine));const o=Je(t.tileCoords);this.mapPointVertices=[];const a=[0,0,0],c=[0,0,0];if(t.geometryType===ai.Point)If(this.mapPointVertices,t.vertices,0,o),this.geoPoint=oe.toGeo(this.mapPointVertices),this.layer.style.allowElevation||(this.mapPointVertices[2]=0);else{for(let l=0;l<t.vertices[0].length;l++)a[0]=t.vertices[0][l],a[1]=t.vertices[1][l],dt(c,a,o),this.mapPointVertices.push(c[0],c[1],c[2]);this.componentDistanceStart=t.componentDistanceStart,this.componentDistanceEnd=t.componentDistanceEnd,this.componentDistanceStartWorld=Ei(this.componentDistanceStart,t.tileCoords[2]),this.objectLengthWorld=Ei(t.objectLength,t.tileCoords[2])}}setSpecificLineAttributes(t,n,i){if(this.layer.type!=="labelLine")throw new Error("Label: layer type is not a labelLine");const s=Dt(i,n,!0,t.tileData);this.label=Xr(this.layer.style.textField,s);const r=Je(t.tileCoords);this.mapPointVertices=[];const o=[0,0,0],a=[0,0,0];for(let c=0;c<t.vertices[0].length;c++)o[0]=t.vertices[0][c],o[1]=t.vertices[1][c],dt(a,o,r),this.mapPointVertices.push(a[0],a[1],a[2]);this.componentDistanceStart=t.componentDistanceStart,this.componentDistanceEnd=t.componentDistanceEnd,this.componentDistanceStartWorld=Ei(this.componentDistanceStart,t.tileCoords[2]),this.objectLengthWorld=Ei(t.objectLength,t.tileCoords[2]),this.tiers=G(this.layer.ignoreTier,s)?void 0:t.tiers}setSpecificOneWayAttributes(t){const n=Je(t.tileCoords);this.mapPointVertices=[];const i=[0,0,0],s=[0,0,0];for(let r=0;r<t.vertices[0].length;r++)i[0]=t.vertices[0][r],i[1]=t.vertices[1][r],dt(s,i,n),this.mapPointVertices.push(s[0],s[1],s[2]);this.componentDistanceStart=t.componentDistanceStart,this.componentDistanceEnd=t.componentDistanceEnd,this.componentDistanceStartWorld=Ei(this.componentDistanceStart,t.tileCoords[2]),this.objectLengthWorld=Ei(t.objectLength,t.tileCoords[2]),this.tiers=t.tiers}updateRanges(){this.ranges=mg([this.label,this.label2,this.iconLabel])}}function Cn(e,t,n){const{minX:i,maxX:s,minY:r,maxY:o}=n;e.push(i,r,s-i,o-r,t)}function fn(e,t,n,i){const s=e.anchorScreen,r=e.boxes[t];return{element:e,minX:s[0]+r[0]-n,maxX:s[0]+r[2]+n,minY:s[1]+r[1]-i,maxY:s[1]+r[3]+i}}function p2(e,t){if(e.parent===t||e.firstLabel===t||t.parent===e||t.firstLabel===e)return!1;const n=e.labelingGroup,i=t.labelingGroup,s=e.labelingGroupTable,r=t.labelingGroupTable;return c2(s,r,n,i)}function Pc(e,t,n,i,s,r){const o=fn(t,n,i,s);if(o.minX>r.maxX||o.maxX<r.minX||o.minY>r.maxY||o.maxY<r.minY)return!0;const a=e.search(o);for(let c=0;c<a.length;c++)if(p2(t,a[c].element))return!0;return!1}function Vu(e,t,n,i,s){if(e.placementIndex===-1){s&&Cn(s,Tt.CommercialDead,fn(e,0,i.leftRight,i.topBottom));return}if(Pc(t,e,0,i.leftRight,i.topBottom,n))e.placementIndex=-1,s&&Cn(s,Tt.CommercialDead,fn(e,0,i.leftRight,i.topBottom));else{e.placementIndex=0;const o=fn(e,0,i.leftRight,i.topBottom);t.insert(o),s&&Cn(s,Tt.CommercialAlive,o)}}function Lc(e,t,n,i){let s=!0;for(let r=0;r<e.boxes.length;r++)if(Pc(t,e,r,e.marginLeftRight,e.marginTopBottom,n)){if(s=!1,i)for(let o=0;o<e.boxes.length;o++){const a=fn(e,o,e.marginLeftRight,e.marginTopBottom);let c;o===r?c=Tt.Dead:o<r?c=Tt.Alive:c=Tt.Unused,Cn(i,c,a)}break}if(s)for(let r=0;r<e.boxes.length;r++){const o=fn(e,r,e.marginLeftRight,e.marginTopBottom);t.insert(o),i&&Cn(i,Tt.Alive,o)}e.placementIndex=s?0:-1}function m2(e,t,n,i){e.placementIndex=-1;for(let s=0;s<e.boxes.length;s++)if(!(e.firstLabel&&e.firstLabel.placementIndex!==s))if(Pc(t,e,s,e.marginLeftRight,e.marginTopBottom,n))i&&Cn(i,Tt.Dead,fn(e,s,e.marginLeftRight,e.marginTopBottom));else{const r=fn(e,s,e.marginLeftRight,e.marginTopBottom);if(t.insert(r),e.placementIndex=s,i){Cn(i,Tt.Alive,r);for(let o=s+1;o<e.boxes.length;o++)Cn(i,Tt.Unused,fn(e,o,e.marginLeftRight,e.marginTopBottom))}break}}function $u(e,t){return e.sort((n,i)=>i.groupPriority-n.groupPriority||(t.has(i.id)?1:0)-(t.has(n.id)?1:0)||i.commPriorityRandomFactor-n.commPriorityRandomFactor)}function ci(e){return e.type!==Re.Box&&!Number.isNaN(e.commPriorityRandomFactor)}function Yu(e){return e.label.pointType===tt.CommercialCity}function y2(e){return ci(e)&&Yu(e)}function g2(e){return ci(e)&&e.label.pointType===tt.CommercialPremium}function Os(e){return e.pointType===tt.Commercial||e.pointType===tt.CommercialCity||e.pointType===tt.CommercialPremium}function w2(e){return e.label.pointType!==tt.CommercialCity||e.placementIndex!==-1&&e.label.pointType===tt.CommercialCity}function v2(e,t){return t.size===0?!1:e.filter(i=>b2(i,t)?(i.adsType=0,!0):!1).length>0}function b2(e,t){return e.type===Re.Icon&&t.has(e.label.id)}function I2(e){return e.type===Re.Box&&e.labelingGroup==="markerText"&&e.parent!==void 0}function M2(e,t,n,i,s){const r=Nr();$u(e.filter(Yu),n).forEach(a=>{Vu(a,r,t,i.city,s)}),r.clear(),$u(e.filter(w2),n).forEach(a=>{Vu(a,r,t,i.default,s)})}function Zu(e,t,n,i,s){switch(e.type){case Re.LineText:case Re.Icon:if(e.placementIndex===-1&&ci(e))break;if(Lc(e,n,i,s),e.adsType===0){const o=t.get(e.label.id);if(!o)break;e.placementIndex!==-1&&(o.parent=e,Lc(o,n,i,s),t.delete(e.label.id))}break;case Re.Box:if(!e.parent){Lc(e,n,i,s);break}e.placementIndex=-1;break;case Re.PoiText:case Re.PoiText2:(!e.parent||e.parent.placementIndex!==-1)&&(!e.firstLabel||e.firstLabel.placementIndex!==-1)?m2(e,n,i,s):e.placementIndex=-1;break}}function T2(e,t,n,i,s,r){const o=[],a=new Map;t.forEach(A=>{if(I2(A)){a.set(A.parent.label.id,A),A.placementIndex=-1;return}o.push(A)});const c=new Set(a.keys());let l=[];if(n.globeMode){for(const A of e)r.ecef.canSee(A.anchorGeo)?l.push(A):A.placementIndex=-1;for(const A of o)r.ecef.canSee(A.anchorGeo)?l.push(A):A.placementIndex=-1}else l=e.concat(o);const d=n.debugLabels?[]:void 0,{size:f,viewport:u}=n,h=f[0],y=f[1],w=(Qs.tileMultiplier-1)/2,p=Math.round(h*w),g=Math.round(y*w),b={minX:u.left-p,maxX:u.left+h+p,minY:u.top-g,maxY:u.top+y+g},v=Nr(),M=v2(l,c),E=l.sort((A,P)=>{const R=A.label instanceof _c?A.label.hovered:0,k=P.label instanceof _c?P.label.hovered:0,V=i.has(A.id),z=i.has(P.id),$=n.disableSurvivedPoiPrevalence?0:(z?1:0)-(V?1:0),ee=M?(P.adsType===0?1:0)-(A.adsType===0?1:0):0;return P.groupPriority-A.groupPriority||(ci(P)?P.commPriorityRandomFactor+ +z:0)-(ci(A)?A.commPriorityRandomFactor+ +V:0)||ee||$||k-R||P.itemPriority-A.itemPriority||(P.label.id>A.label.id?1:P.label.id===A.label.id?0:-1)||P.label.layer.innerId-A.label.layer.innerId||P.anchorWorld[0]-A.anchorWorld[0]||P.anchorWorld[1]-A.anchorWorld[1]});let T=-1;const L=E.filter((A,P)=>ci(A)?(T=P,!0):!1);if(T!==-1){for(let A=0;A<=T;A++)Zu(E[A],a,v,b,d);v.clear(),M2(L,b,i,s,d)}for(let A=0;A<E.length;A++)Zu(E[A],a,v,b,d);return d}const Dc=new Map;class qr{constructor(t,n,i,s,r,o,a,c){if(this.anchorWorld=[0,0,0,0],this.anchorGeo=[0,0],this.groupPriority=0,this.labelingGroup=Ln,this.marginTopBottom=0,this.marginLeftRight=0,this.elevation=0,this.type=n,this.label=t,this.layer=t.layer,this.elevation=t.elevation,t.planLevel&&(this.elevation+=t.planLevel*dr(t.geoPoint,c)),this.id=t.id+"_"+n+"_"+Math.floor(i[0]/1e3)+"_"+Math.floor(i[1]/1e3)+this.getIconLabelPriorityToId(t),$d(this.anchorWorld,i),this.anchorGeo=t.geoPoint,s!==0&&(this.anchorWorld[2]*=s),a){const l=Ve.fromGeo(this.anchorGeo);this.anchorScreen=r.ecef.project(l,!1)}else this.anchorScreen=r.flat.project([this.anchorWorld[0],this.anchorWorld[1],this.anchorWorld[2]+this.elevation,0]);switch(this.anchorPosition=0,this.anchorSegmentIndex=0,this.halfLabelWidth=0,this.commPriorityRandomFactor=NaN,this.itemPriority=n===Re.Icon?t.iconPriority:t.labelPriority,this.layer.type){case"labelLine":this.labelingGroup=this.layer.style.labelingGroup,this.groupPriority=t.styleTextPriority;break;case"oneWayLine":this.labelingGroup=this.layer.style.labelingGroup,this.groupPriority=this.layer.style.priority;break;case"point":{if(Os(t))if(Dc.has(this.label.id))this.commPriorityRandomFactor=Dc.get(this.label.id);else{const l=Gu();this.commPriorityRandomFactor=l,Dc.set(this.label.id,l)}n===Re.PoiText?(this.labelingGroup=this.layer.style.allowOverlap?Pn:this.layer.style.textLabelingGroup,this.groupPriority=this.layer.style.iconImage?Math.min(t.styleTextPriority,t.styleIconPriority):t.styleTextPriority,this.marginTopBottom=this.layer.style.textLabelingMargin.topBottom,this.marginLeftRight=this.layer.style.textLabelingMargin.leftRight):n===Re.PoiText2?(this.labelingGroup=this.layer.style.allowOverlap?Pn:this.layer.style.textLabelingGroup2,this.groupPriority=Math.min(t.styleTextPriority,t.styleIconPriority),this.marginTopBottom=this.layer.style.textLabelingMargin.topBottom,this.marginLeftRight=this.layer.style.textLabelingMargin.leftRight):(this.labelingGroup=this.layer.style.allowOverlap?Pn:this.layer.style.iconLabelingGroup,this.groupPriority=t.styleIconPriority,this.marginTopBottom=this.layer.style.iconLabelingMargin.topBottom,this.marginLeftRight=this.layer.style.iconLabelingMargin.leftRight);break}}this.labelingGroupTable=o.labelingGroups.table,this.overflowStyleZoom=-1/0,this.boxes=[],this.placementIndex=0}getIconLabelPriorityToId(t){if(Os(t))return"";const{layer:n}=t;if(n.type==="point"){const i=t.styleIconPriority.toFixed(0),s=t.styleTextPriority.toFixed(0);return"_"+i+"_"+s}return""}}function Wu(e,t,n,i,s,r){if(!e||s&&!r)return[0,0];if(!r)return[e.w/t,e.h/t];const o=Oc(n,i,r),a=Ye(n.style.iconTextPadding);return[a[3]+a[1]+o[0],a[0]+a[2]+o[1]]}function Jr(e,t,n){return Cc(ae(e.style.textFontSize,t),e.style.textLineHeight,n)}function Xu(e,t,n){return Cc(ae(e.style.textFontSize2,t),e.style.textLineHeight,n)}function Oc(e,t,n){return Cc(ae(e.style.iconTextFontSize,t),e.style.iconTextLineHeight,n)}function Cc(e,t,n){const s=e/xt.baseSize*n.maxWidth,r=e*t*n.lines.length;return[s,r]}function qu(e,t,n){const i=n[0]??0,s=n[1]??0;return[(.5-e.anchorX)*t[0]+i,(.5-e.anchorY)*t[1]+s]}function S2(e,t,n){const i=t[0]??.5,s=t[1]??.5,r=n[0]??0,o=n[1]??0;return[(.5-i)*e[0]+r,(.5-s)*e[1]+o]}function Ju(e,t,n,i,s){const r=n[0]??.5,o=n[1]??.5,a=s[0]??0,c=s[1]??0;return[e[0]/2-r*t[0]-i[3]+a,e[1]/2-o*t[1]-i[0]+c]}function Kr(e,t,n,i,s){const r=t[0],o=t[1],a=n[0],c=n[1];let l=0,d=0;const f=c/2+o/2,u=c/2-o/2,h=-f,y=-u,w=a/2+r/2,p=a/2-r/2,g=-w,b=-p;switch(e){case"bottomCenter":d=f+s;break;case"rightCenter":l=w+s;break;case"topCenter":d=h-s;break;case"leftCenter":l=g-s;break;case"bottomRight":l=p,d=f+s;break;case"topRight":l=p,d=h-s;break;case"bottomLeft":l=b,d=f+s;break;case"rightBottom":l=w+s,d=y;break;case"rightTop":l=w+s,d=u;break;case"topLeft":l=b,d=h-s;break;case"leftTop":l=g-s,d=u;break;case"leftBottom":l=g-s,d=y;break}return[l+i[0],d+i[1]]}var li=(e=>(e[e.Static=0]="Static",e[e.Unique=1]="Unique",e[e.Loaded=2]="Loaded",e))(li||{});let Ku=1e4+1;const A2={w:0,h:0,x:0,y:0,atlasIndex:0,isPacked:!1},Fc={};function E2(e,t,n,i,s,r){const o=ja(e,s);if(!Fc[o]){const a=Ku++;Fc[o]={type:li.Unique,isSvg:!1,index:a,key:o,name:"",fileName:"",id:e,regionId:n,url:r,rasters:t.map((c,l)=>({...A2,rasterSetIndex:a,rasterIndex:l,w:c,h:c,anchorX:i[0],anchorY:i[1]}))}}return Fc[o]}function x2(e){const t=Ku++;return{type:li.Loaded,isSvg:!1,index:t,key:`loaded-${t}`,name:"",fileName:"",rasters:e.map((n,i)=>({...n,rasterIndex:i,rasterSetIndex:t}))}}function Cs(e,t,n){let i,s=1/0;for(let r=0;r<e.length;r++){const o=e[r];if(n&&!o.isPacked)continue;const a=Math.abs(o.w-t);a<s&&(i=r,s=a)}return i}function Nc(e){return!!e&&"stretchX"in e&&Array.isArray(e.stretchX)&&"stretchY"in e&&Array.isArray(e.stretchY)&&"width"in e&&typeof e.width=="number"&&"height"in e&&typeof e.height=="number"}function Rc(e,t){const n=t.precomputes;return e.map((i,s)=>{const r=n[s];return r&&r.usage===Ze.Uniform?i:null})}var Bc=(e=>(e[e.Icon=0]="Icon",e[e.First=1]="First",e[e.Second=2]="Second",e))(Bc||{});const kc=new o2,ki=[0,0,0];let Fs=[0,0,0];const Zt={symbol:"point",sinks:{raster:{stride:40,binder:(e,t)=>{e.views.flatPosition=new Uint16Array(t),e.views.ecefPosition=new Int16Array(t,6),e.views.cornerOffset=new Int16Array(t,12),e.views.checkPointOffset=new Int16Array(t,16),e.views.texCoords=new Uint16Array(t,20),e.views.scales=new Int16Array(t,24),e.views.localID=new Uint32Array(t,28),e.views.labelingTextureID=new Uint32Array(t,32),e.views.spritePointTextureID=new Uint32Array(t,36)},packObjectAttributes:(e,t,n,i,s,r)=>us([e.styleId,e.layer.innerId,t,n,i,s],r),unpackObjectAttributes:e=>({styleId:e[0],layerId:e[1],animDirection:e[2],atlasIndex:e[3],labelTest:e[4],floorId:e[5],tileData:e.slice(6)})},text:{stride:36,binder:(e,t)=>{e.views.flatPosition=new Uint16Array(t),e.views.ecefPosition=new Int16Array(t,6),e.views.cornerOffset=new Int16Array(t,12),e.views.checkPointOffset=new Int16Array(t,16),e.views.texCoords=new Uint16Array(t,20),e.views.localID=new Uint32Array(t,24),e.views.labelingTextureID=new Uint32Array(t,28),e.views.spritePointTextureID=new Uint32Array(t,32)},packObjectAttributes:(e,t,n,i,s,r,o,a)=>us([e.styleId,e.layer.innerId,t,n,i[0],-i[1],s,r,o],a),unpackObjectAttributes:e=>({styleId:e[0],layerId:e[1],animDirection:e[2],range:e[3],offsetX:e[4],offsetY:e[5],labelIndex:e[6],fontIndex:e[7],floorId:e[8],tileData:e.slice(9)})},labelingTexture:{stride:16,binder:(e,t)=>{e.views.position=new Uint16Array(t),e.views.cornerOffset=new Int16Array(t,8),e.views.labelingTextureID=new Uint32Array(t,12)},packObjectAttributes:(e,t=[0,0])=>us([e.styleId,e.layer.innerId,t[0],-t[1],e.floorId],[]),unpackObjectAttributes:e=>({styleId:e[0],layerId:e[1],offsetX:e[2],offsetY:e[3],floorId:e[4],tileData:e.slice(5)})}},processElement(e,t,n,i,s,r,o){const{layer:a,label:c}=n;if(a.type!=="point")return;const l=Dt(r.styleZoom,r.styleState,!0,c.tileData),d=r.styleState._activeFloorIds.length>0,f=Os(c)&&!d?"":c.floorId,u=Qu(l,e,s,c),h=e.icons[Ke(a.style.iconImage,l)],y=Nc(h),w=Wu(u,s,a,l,y,c.iconTextMetrics),p=Ye(a.style.iconTextOffset),g=Ye(a.style.iconTextPadding);let b,v=[0,0];if(u)if(c.iconTextMetrics){const T=Ye(a.style.iconTextAnchor);b=Oc(a,l,c.iconTextMetrics),v=Ju(w,b,T,g,p)}else{const T=Ye(a.style.iconOffset);v=qu(u,w,T)}gt(ki,n.anchorWorld,o);const{globeInterStartZoom:M}=gn;if(!(!(r.globeMode&&r.zoom<M)&&!Na(ki)))switch(Fs=Ve.fromGeo(n.anchorGeo),n.type){case Re.Icon:if(!u||y&&!c.iconTextMetrics)return;const T=y?h.stretchX:void 0,L=y?h.stretchY:void 0;if(Uc(t,c,f,ki,Fs,i,u,w[0]*s,w[1]*s,v[0]*s,v[1]*s,s,T?.map(([P,R])=>[P*s,R*s]),L?.map(([P,R])=>[P*s,R*s])),!b)return;const A=Ye(a.style.iconTextAnchor);_2(e,t,c,f,ki,Fs,r,i,S2(b,A,p),a,s);return;case Re.PoiText:P2(e,t,n,f,ki,Fs,w,r,i,v,a,s);return;case Re.PoiText2:L2(e,t,n,f,ki,Fs,w,r,i,v,a,s);return}},getLabelingInfo(e,t,n,i,s,r){const{layer:o}=e;if(o.type!=="point")return;e.labelingElements.length=0;const a=Dt(i.styleZoom,i.styleState,!0,e.tileData),c=Qu(a,n,r,e),l=n.icons[Ke(o.style.iconImage,a)],d=Nc(l),f=Wu(c,r,o,a,d,e.iconTextMetrics);let u,h=[0,0];if(c&&(!d||e.iconTextMetrics)){if(e.iconTextMetrics){const g=Ye(o.style.iconTextAnchor),b=Ye(o.style.iconTextOffset),v=Ye(o.style.iconTextPadding);u=Oc(o,a,e.iconTextMetrics),h=Ju(f,u,g,v,b)}else{const g=Ye(o.style.iconOffset);h=qu(c,f,g)}const p=new qr(e,Re.Icon,t,i.buildingHeight,s,n,i.globeMode,i.styleState._floorHeight);p.boxes.push([-f[0]/2+h[0],-f[1]/2+h[1],f[0]/2+h[0],f[1]/2+h[1]]),e.labelingElements.push(p)}const y=Ke(o.style.textFont,a);e.label.length>0&&y.length&&(O2(e,t,n,f,i,s,h,o),e.label2&&C2(e,t,n,f,i,s,h,o))}};function _2(e,t,n,i,s,r,o,a,c,l,d){const{iconTextMetrics:f}=n;if(!f||!l.style.iconTextFont)return;const u=Dt(o.styleZoom,o.styleState,!1,n.tileData),h=Ke(l.style.iconTextFont,u),y=e.fontNameToIndex[h]??e.fontNameToIndex[gi];Qr(t,n,i,0,f,s,r,a,c,l,y,d)}function P2(e,t,n,i,s,r,o,a,c,l,d,f){const{label:u}=n,{textMetrics:h}=u,y=Dt(a.styleZoom,a.styleState,!1,u.tileData),w=Ke(d.style.textFont,y);if(!w.length)return;const p=Jr(d,y,h),g=e.fontNameToIndex[w]??e.fontNameToIndex[gi],b=n.parent?Dr(d.style.textPlacement,y):"centerCenter",v=ae(d.style.textOffset,y),M=Kr(b,o,p,l,v);Qr(t,u,i,1,u.textMetrics,s,r,c,M,d,g,f)}function L2(e,t,n,i,s,r,o,a,c,l,d,f){const{label:u}=n,{textMetrics:h,textMetrics2:y}=u;if(!y||!d.style.textFont2)return;const w=Dt(a.styleZoom,a.styleState,!1,u.tileData),p=Ke(d.style.textFont2,w);if(!p.length)return;const g=Jr(d,w,h),b=Xu(d,w,y),v=ae(d.style.textOffset,w),M=ae(d.style.textOffset2??0,w,0),E=e.fontNameToIndex[p]??e.fontNameToIndex[gi],T=Kr(Dr(d.style.textPlacement,w),o,[b[0],g[1]],l,v);T[1]+=(g[1]+b[1])/2+M,Qr(t,u,i,2,y,s,r,c,T,d,E,f)}function Qr(e,t,n,i,s,r,o,a,c,l,d,f){if(i===1&&t.labelingElements.length===1){const h=e.getBucket("point","labelingTexture",Zt.sinks.labelingTexture.packObjectAttributes(t),Zt.sinks.labelingTexture.binder);t.checkPointOffset=N2(h,r,s,l,f,t.labelingTextureIndex)}const u={};for(const h of t.ranges)u[h]=e.getBucket("point","text",Zt.sinks.text.packObjectAttributes(t,a,h,c,i,d,n,Rc(t.tileData,l)),Zt.sinks.text.binder);F2(u,t,r,o,s,l,i,t.checkPointOffset)}function D2(e,t,n,i,s,r,o,a){return Uc(e,t,n,i,s,r,o,o.w,o.h,o.w*(.5-o.anchorX),o.h*(.5-o.anchorY),a,void 0,void 0)}function Uc(e,t,n,i,s,r,o,a,c,l,d,f,u,h){if(a<=0||c<=0)return;const y=t.layer;if(y.type!=="point")return;i2(kc,qt,o,a,c,l,d,u,h),e.atlasPacker.addRastersToLoad(t.styleId,o);const w=e.getBucket("point","labelingTexture",Zt.sinks.labelingTexture.packObjectAttributes(t),Zt.sinks.labelingTexture.binder);t.checkPointOffset=r2(i[0],i[1],i[2],kc,w,f,t.labelingTextureIndex);const p=e.getBucket("point","raster",Zt.sinks.raster.packObjectAttributes(t,r,o.atlasIndex,u!==void 0||h!==void 0,n,Rc(t.tileData,y)),Zt.sinks.raster.binder);s2(i[0],i[1],i[2],s,kc,p,-1/0,1/0,t.identifyIndex,t.labelingTextureIndex,t.spritePointTextureIndex,t.checkPointOffset)}function O2(e,t,n,i,s,r,o,a){const{textMetrics:c}=e;if(!c)return;const l=Dt(s.styleZoom,s.styleState,!1,e.tileData),d=ae(a.style.textOffset,l),f=Jr(a,l,c),u=new qr(e,Re.PoiText,t,s.buildingHeight,r,n,s.globeMode,s.styleState._floorHeight);e.labelingElements.length>0&&(u.parent=e.labelingElements[0]);const h=u.parent?Dr(a.style.textPlacement,l):"centerCenter",y=Kr(h,i,f,o,d);u.boxes.push([y[0]-f[0]/2,y[1]-f[1]/2,y[0]+f[0]/2,y[1]+f[1]/2]),e.labelingElements.push(u)}function C2(e,t,n,i,s,r,o,a){const{textMetrics:c,textMetrics2:l}=e;if(!l)return;const d=Dt(s.styleZoom,s.styleState,!1,e.tileData),f=Jr(a,d,c),u=Xu(a,d,l),h=ae(a.style.textOffset,d),y=ae(a.style.textOffset2??0,d,0),w=new qr(e,Re.PoiText2,t,s.buildingHeight,r,n,s.globeMode,s.styleState._floorHeight);e.labelingElements.length>1?(w.parent=e.labelingElements[0],w.firstLabel=e.labelingElements[1]):e.labelingElements.length>0&&(w.parent=e.labelingElements[0],w.firstLabel=e.labelingElements[0]);const p=Kr(Dr(a.style.textPlacement,d),i,[u[0],f[1]],o,h);p[1]+=(f[1]+u[1])/2+y,w.boxes.push([p[0]-u[0]/2,p[1]-u[1]/2,p[0]+u[0]/2,p[1]+u[1]/2]),e.labelingElements.push(w)}function Qu(e,t,n,i){const{rasterSets:s}=t,{layer:r}=i;if(r.type!=="point")return;let o;const a=Os(i);if(a||i.pointType===tt.Landmark)o=s.byKey[ja(i.id,a?"commercial":"landmark")];else{const c=Ke(r.style.iconImage,e);if(c.length){const l=Ye(r.style.iconAnchor);o=s.byKey[Li(c,l[0],l[1])]}}if(o){const c=ae(r.style.iconWidth,e),l=Cs(o.rasters,c*n,!0);if(l!==void 0)return o.rasters[l]}}const eo=[0,0];function F2(e,t,n,i,s,r,o,a){let{textLineHeight:d,textLetterSpacing:f}=r.style;o===Bc.Icon&&(d=r.style.iconTextLineHeight,f=r.style.iconTextLetterSpacing);const{identifyPoiLabelIndex:u,labelingTextureIndex:h,spritePointTextureIndex:y}=t,{lines:w,maxWidth:p}=s,g=d*xt.baseSize;let b=eh(1,g,w.length);for(let v=0;v<w.length;v++){const M=w[v].width;let E=0;E=-M/2,eo[0]=E,eo[1]=b;const T=w[v].glyphs;for(let L=0;L<T.length;L++){const A=T[L];A.bitmap!==void 0&&k2(e[A.range],n,i,eo,A,u,h,y,a),eo[0]+=A.advance+xt.baseSize*f}b-=g}}const Wt=[0,0];function N2(e,t,n,i,s,r){const{lines:o,maxWidth:a}=n;if(!o.length)return Wt[0]=0,Wt[1]=0,Wt;const{textLineHeight:c}=i.style,l=c*xt.baseSize,d=-a/2,f=eh(1,l,o.length),u=a/2,h=f-(o.length-1)*l;Wt[0]=s*(d+u)/2,Wt[1]=s*(f+h)/2;const y=s*$o/2,w=Wt[0]-y,p=Wt[0]+y,g=Wt[1]+y,b=Wt[1]-y,v=e.elements.offset;return ro(e.indices,v,1,0,3,2,3,0),no(e,t,w,g,r),no(e,t,p,g,r),no(e,t,w,b,r),no(e,t,p,b,r),Wt}function R2(e,t,n,i,s,r,o){const a=n[1]+i.top,c=n[0]+i.left,l=a-i.height,d=c+i.width,f=Math.sin(s),u=Math.cos(s),h=c*u-a*f,y=c*f+a*u,w=d*u-a*f,p=d*f+a*u,g=c*u-l*f,b=c*f+l*u,v=d*u-l*f,M=d*f+l*u,E=e.elements.offset;io(e,t,h,y,i.texLeft,i.texTop,r,o),io(e,t,w,p,i.texRight,i.texTop,r,o),io(e,t,g,b,i.texLeft,i.texBottom,r,o),io(e,t,v,M,i.texRight,i.texBottom,r,o),ro(e.indices,E,1,0,3,2,3,0)}function B2(e,t,n){const i=e.elements.offset,s=Ne(Math.cos(n)),r=Ne(Math.sin(n));so(e,t,s,r,-1,-1),so(e,t,s,r,1,-1),so(e,t,s,r,1,1),so(e,t,s,r,-1,1),ro(e.indices,i,0,1,2,2,3,0)}function eh(e,t,n){let i;switch(e){case 0:i=t/2+t*(n-1);break;case 2:i=-t/2;break;default:i=n&1?t*(n>>1):t/2+t*(n-1>>1)}return i}function k2(e,t,n,i,s,r,o,a,c){const l=i[1]+s.top,d=i[0]+s.left,f=l-s.height,u=d+s.width,[h,y]=c,w=e.elements.offset;to(e,t,n,d,l,s.texLeft,s.texTop,h,y,r,o,a),to(e,t,n,u,l,s.texRight,s.texTop,h,y,r,o,a),to(e,t,n,d,f,s.texLeft,s.texBottom,h,y,r,o,a),to(e,t,n,u,f,s.texRight,s.texBottom,h,y,r,o,a),ro(e.indices,w,1,0,3,2,3,0)}function to(e,t,n,i,s,r,o,a,c,l,d,f){const u=e.elements,h=u.stride*u.offset>>1,y=h>>1;e.views.flatPosition[h]=B+t[0],e.views.flatPosition[h+1]=B+t[1],e.views.flatPosition[h+2]=$e(t[2]),e.views.ecefPosition[h]=n[0]*Xe,e.views.ecefPosition[h+1]=n[1]*Xe,e.views.ecefPosition[h+2]=n[2]*Xe,e.views.cornerOffset[h]=i,e.views.cornerOffset[h+1]=s,e.views.checkPointOffset[h]=a,e.views.checkPointOffset[h+1]=c,e.views.texCoords[h]=r,e.views.texCoords[h+1]=o,e.views.localID[y]=l,e.views.labelingTextureID[y]=d,e.views.spritePointTextureID[y]=f,u.offset++}function no(e,t,n,i,s){const r=e.elements,o=r.stride*r.offset>>1;e.views.position[o]=B+t[0],e.views.position[o+1]=B+t[1],e.views.position[o+2]=$e(t[2]),e.views.cornerOffset[o]=n,e.views.cornerOffset[o+1]=i,e.views.labelingTextureID[o>>1]=s,r.offset++}function io(e,t,n,i,s,r,o,a){const c=e.elements;let l=c.stride*c.offset>>1;e.views.position[l]=B+t[0],e.views.position[l+1]=B+t[1],e.views.position[l+2]=$e(t[2]),e.views.texCoords[l]=s,e.views.texCoords[l+1]=r,l=l>>1,e.views.cornerOffset[l]=n,e.views.cornerOffset[l+1]=i,e.views.styleZoomLimits[l]=o,e.views.styleZoomLimits[l+1]=a,c.offset++}function so(e,t,n,i,s,r){const o=e.elements.stride*e.elements.offset,a=o/e.views.position.BYTES_PER_ELEMENT,c=o/e.views.direction.BYTES_PER_ELEMENT;e.views.position[a]=B+t[0],e.views.position[a+1]=B+t[1],e.views.direction[c]=n,e.views.direction[c+1]=i,e.views.widenDirection[c]=s,e.views.widenDirection[c+1]=r,e.elements.offset++}function ro(e,t,n,i,s,r,o,a){const c=e.buffer,l=e.offset;c[l]=t+n,c[l+1]=t+i,c[l+2]=t+s,c[l+3]=t+r,c[l+4]=t+o,c[l+5]=t+a,e.offset=l+6}const zc=[0,0,0],Ns=[0,0],oo={symbol:"labelLine",sinks:{raster:{stride:28,binder:(e,t)=>{e.views.position=new Uint16Array(t),e.views.texCoords=new Uint16Array(t,8),e.views.cornerOffset=new Float32Array(t,12),e.views.styleZoomLimits=new Float32Array(t,20)},packObjectAttributes:(e,t,n,i,s,r)=>us([e.styleId,e.layer.innerId,t,n,i,s],r),unpackObjectAttributes(e){return{styleId:e[0],layerId:e[1],animDirection:e[2],range:e[3],fontIndex:e[4],tiers:e[5],tileData:e.slice(6)}}}},processElement(e,t,n,i,s,r,o){const{label:a,anchorPosition:c,anchorSegmentIndex:l,halfLabelWidth:d,layer:f}=n;if(f.type!=="labelLine")return;const{axis:u}=a,{center:h,styleZoom:y}=r,w=Dt(y,r.styleState,!1,a.tileData),p=Ke(f.style.textFont,w),g=e.fontNameToIndex[p]??e.fontNameToIndex[gi],b={},v=G(f.ignoreTier,w)?null:a.tiers;for(const A of a.ranges)b[A]=t.getBucket("labelLine","raster",oo.sinks.raster.packObjectAttributes(a,i,A,g,v??null,Rc(a.tileData,f)),oo.sinks.raster.binder);const M=a.textMetrics.lines[0],E=ae(f.style.textFontSize,w)/xt.baseSize,T=M.glyphs,L=U2(u,c,d,r.rotation);Ns[0]=-M.width/2,Ns[1]=0;for(let A=0;A<T.length;A++){const P=T[A],R=(Ns[0]+P.left+P.width/2)*E*(L?-1:1),k=er(R)||1;let V=-1/0,z=1/0;for(let $=l;$>=1&&$<u.vertexCount&&!(z<n.overflowStyleZoom);$+=k,z=V){const ee=k===1?$:$-1;V=Wd(Gd(R,u.lengths[ee]-c),h);const I=u.interpolate(c,$);gt(zc,I,o),Na(zc)&&P.bitmap!==void 0&&R2(b[P.range],zc,Ns,P,I[3]+(L?Math.PI:0),Math.max(V,n.overflowStyleZoom),z)}Ns[0]+=P.advance+xt.baseSize*f.style.textLetterSpacing}},getLabelingInfo(){}};function U2(e,t,n,i){const s=e.interpolate(t-n,e.getSegmentIndex(t-n)),r=e.interpolate(t+n,e.getSegmentIndex(t+n)),o=Math.atan2(r[1]-s[1],r[0]-s[0])-i;return Math.cos(o)<0}const Gc=[0,0,0],ao={symbol:"oneWayLine",sinks:{raster:{stride:12,binder:(e,t)=>{e.views.position=new Uint16Array(t),e.views.direction=new Int8Array(t,8),e.views.widenDirection=new Int8Array(t,10)},packObjectAttributes:(e,t,n)=>us([e.styleId,e.layer.innerId,t,n],e.tileData),unpackObjectAttributes:e=>({styleId:e[0],layerId:e[1],animDirection:e[2],tiers:e[3],tileData:e.slice(4)})}},processElement(e,t,n,i,s,r,o){const{label:a,anchorWorld:c}=n;if(gt(Gc,c,o),!Na(Gc))return;const l=t.getBucket("oneWayLine","raster",ao.sinks.raster.packObjectAttributes(a,i,a.tiers??null),ao.sinks.raster.binder);B2(l,Gc,c[3])},getLabelingInfo(){}},di={symbol:"heatmap",sinks:{fill:{stride:8,binder:(e,t)=>{e.views.position=new Float32Array(t)},packObjectAttributes:(e,t,n,i)=>[e,t.innerId,n,i],unpackObjectAttributes:e=>({styleId:e[0],layerId:e[1],textureIndex:e[2],rampTextureIndex:e[3],tileData:e.slice(4)})},framebuffer:{stride:12,binder:(e,t)=>{e.views.position=new Uint16Array(t),e.views.weight=new Float32Array(t,4),e.views.widen=new Int8Array(t,8)},packObjectAttributes:(e,t)=>[e,t],unpackObjectAttributes:e=>({styleId:e[0],layerId:e[1],tileData:e.slice(2)})}},generate(e,t,n,i,s){const r=i.x,o=i.y,a=Number(G(n.style.weight,s));if(Number.isNaN(a)){console.error("Can't resolve style.weight to number");return}const c=e.getBucket(n.type,"framebuffer",di.sinks.framebuffer.packObjectAttributes(t,n.innerId),di.sinks.framebuffer.binder);for(let l=0;l<r.length;l++)G2(c,0,1,2,2,1,3),lo(c,r[l],o[l],-1,-1,a),lo(c,r[l],o[l],1,-1,a),lo(c,r[l],o[l],-1,1,a),lo(c,r[l],o[l],1,1,a)},generateTexture(e,t,n,i,s){const r=[-1,1,1,-1],o=[-1,-1,1,1],a=e.getBucket(n.type,"fill",di.sinks.fill.packObjectAttributes(t,n,i,s),di.sinks.fill.binder);let c=a.elements.offset;z2(a.indices,c,0,1,2,0,2,3),co(a,c++,r[0],o[0]),co(a,c++,r[1],o[1]),co(a,c++,r[2],o[2]),co(a,c++,r[3],o[3]),a.elements.offset=c}};function co(e,t,n,i){const s=t*2;e.views.position[s]=n,e.views.position[s+1]=i}function z2(e,t,n,i,s,r,o,a){const c=e.buffer,l=e.offset;c[l]=t+n,c[l+1]=t+i,c[l+2]=t+s,c[l+3]=t+r,c[l+4]=t+o,c[l+5]=t+a,e.offset=l+6}function lo(e,t,n,i,s,r){const o=e.elements.offset*e.elements.stride,a=o>>1,c=a>>1;e.views.position[a]=B+t,e.views.position[a+1]=B+n,e.views.weight[c]=r,e.views.widen[o]=i,e.views.widen[o+1]=s,e.elements.offset++}function G2(e,t,n,i,s,r,o){const{elements:a,indices:c}=e,{buffer:l,offset:d}=c,f=a.offset;l[d]=f+t,l[d+1]=f+n,l[d+2]=f+i,l[d+3]=f+s,l[d+4]=f+r,l[d+5]=f+o,c.offset=d+6}const j2=new Set(bd),H2=new Set(Qo),V2=new Set(ea),$2=new Set(Md),Y2=new Set(Td),Z2=new Set(Id);function fo(e){return j2.has(e)}function th(e){return H2.has(e)}function nh(e){return V2.has(e)}function W2(e){return $2.has(e)}function ih(e){return Y2.has(e)}function X2(e){return Z2.has(e)}const sh=(e,t,n,i,s,r,o,a,c,l,d)=>{const{tileProps:f,tileAttrs:u}=i;if(q2(e,t,n,i,l,d),d)return;let h=tt.Common;const y=u[f.db_sublayer];th(y)?h=tt.CommercialCity:nh(y)?h=tt.CommercialPremium:fo(y)?h=tt.Commercial:ih(y)&&(h=tt.Landmark);const w=c.x.length===1?ai.Point:ai.Line;let p=[],g;if(w===ai.Point){if(i&&n.style.allowElevation){const k=ae(n.style.elevation,i);if(Number.isNaN(k))typeof c.z<"u"&&(c.z=[r<4?Tf(c.z[0]):c.z[0]]);else{const V=k*me*vt(Je(o),[c.x[0],c.y[0]]);c.z=[V]}}p=[[c.x[0]],[c.y[0]],typeof c.z<"u"?[c.z[0]]:[0]],g=[0,0,0],dt(g,[p[0][0],p[1][0],p[2][0]],Je(o))}else p=[c.x,c.y];const b=i.id??"",v=u[f.db_plan_id]??"",M=u[f.db_plan_level]??NaN;let E=it,T=it;Number.isNaN(b)||(E=e.idIndexer.getIndex(i,t.id,n,{objectClass:u[f.db_object_class],instanceId:0,metatile:s,center:g,floorId:v,ignoreHover:!0}),T=e.idIndexer.getIndex(i,t.id,n,{objectClass:u[f.db_object_class],instanceId:1,metatile:s,center:g,floorId:v,ignoreHover:!0}));const L=u[f.db_point_building_id],A=e.pointIndexer.getIndex(L),P=e.pointIndexer.getIndex(b),R={type:ln.Point,pointType:h,geometryType:w,styleId:t.id,layerId:n.innerId,sourceId:a,tileCoords:o,id:i.id??"",floorId:v,planLevel:M,identifyIndex:E,identifyPoiLabelIndex:T,labelingTextureIndex:A,spritePointTextureIndex:P,labelPriority:nt(u[f.db_label_priority],0),label2Priority:nt(u[f.db_label2_priority],0),styleIconPriority:ae(n.style.iconPriority,i),styleTextPriority:ae(n.style.textPriority,i),iconPriority:nt(u[f.db_icon_priority],0),hovered:nt(u[f.hovered],0),componentDistanceStart:nt(u[f.componentDistanceStart],0),componentDistanceEnd:nt(u[f.componentDistanceEnd],0),objectLength:nt(u[f.objectLength],0),vertices:p,demElevation:NaN,tileData:[...i.tileData]};e.addLabel(R)};function q2(e,t,n,i,s,r){const{tileProps:o,tileAttrs:a}=i,{rasterSets:c,icons:l}=t,d=tc(s),f=ii(n.style.iconWidth),u=fo(a[o.db_sublayer]),h=ih(a[o.db_sublayer]),y=Ye(n.style.iconAnchor);if(u||h){if(r)return;const w=u?Zo.rasterSizes:Sd,p=E2(i.id??"",w,a[o.db_region],y,u?"commercial":"landmark",o.url_src?a[o.url_src]:void 0);e.atlasPacker.addNewRasterSet(t.id,p),e.atlasPacker.pack(p,f,d)}else ii(n.style.iconImage).forEach(w=>{if(!w.length)return;const p=c.byKey[Li(w,y[0],y[1])];if(!p){console.error(`Not found raster set with image ${w}, anchorX: ${y[0]}, anchorY: ${y[1]}`);return}if(!p.isSvg)return;const g=l[w],b=g&&Nc(g)?[{w:g.width,h:g.height}]:f.map(v=>({w:v,h:v}));e.atlasPacker.packSvg(p,b,d),r&&p.rasters.forEach(v=>e.atlasPacker.addRastersToLoad(t.id,v))})}const J2=(e,t,n,i,s,r,o)=>{const a={type:ln.Line,styleId:t,layerId:n.innerId,sourceId:s,tileCoords:i,id:r.id??"",floorId:r.tileAttrs[r.tileProps.db_plan_id]||"",planLevel:r.tileAttrs[r.tileProps.db_plan_level]||NaN,componentDistanceStart:nt(r.tileAttrs[r.tileProps.componentDistanceStart],0),componentDistanceEnd:nt(r.tileAttrs[r.tileProps.componentDistanceEnd],0),objectLength:nt(r.tileAttrs[r.tileProps.objectLength],0),labelPriority:nt(r.tileAttrs[r.tileProps.db_label_priority],0),styleIconPriority:ae(n.style.textPriority,r),styleTextPriority:ae(n.style.textPriority,r),vertices:[o.x,o.y],tileData:[...r.tileData],tiers:G(n.ignoreTier,r)?void 0:r.tileAttrs[r.tileProps.db_tiers]};e.addLabel(a)},K2=(e,t,n,i,s,r,o)=>{const{tileProps:a,tileAttrs:c}=r,l=G(n.ignoreTier,r)?null:c[a.db_tiers],d={type:ln.OneWayLine,styleId:t,layerId:n.innerId,sourceId:s,tileCoords:i,id:r.id??"",floorId:r.tileAttrs[r.tileProps.db_plan_id]||"",planLevel:r.tileAttrs[r.tileProps.db_plan_level]||NaN,componentDistanceStart:nt(r.tileAttrs[r.tileProps.componentDistanceStart],0),componentDistanceEnd:nt(r.tileAttrs[r.tileProps.componentDistanceEnd],0),objectLength:nt(r.tileAttrs[r.tileProps.objectLength],0),labelPriority:nt(r.tileAttrs[r.tileProps.db_label_priority],0),styleIconPriority:ae(n.style.priority,r),styleTextPriority:0,vertices:[o.x,o.y],tileData:[...r.tileData],tiers:l};e.addLabel(d)};function Q2(e,t,n){return os(n.fontUrlTemplate,{name:e,range:String(t)})}function jc(e,t,n){const i=un(e)?e:Fn(t.iconBaseUrl,e);return os(i,{subdomain:n,appHost:window.location.host})}function eb(e,t){return un(e)?e:Fn(t.modelsBaseUrl,e)}function tb(e,t,n){return un(e)||!t?e:ab(t)?ss(t,{modelSrc:e,subdomain:pf(n)}):Fn(t,e)}function rh(e,t,n){return e.replace("image",`image_${t}x${n}`)}const oh=/_i$/;function nb(e){return oh.test(e)}function ib(e){return e.replace(oh,"")}function sb(e,t){const n=un(t.fontsPath)?t.fontsPath:Fn(t.rootUrl,t.fontsPath),i="{name}_{range}.pbf";e.fontUrlTemplate=Fn(n,i),e.iconBaseUrl=un(t.iconsPath)?t.iconsPath:Fn(t.rootUrl,t.iconsPath),e.modelsBaseUrl=un(t.modelsPath)?t.modelsPath:Fn(t.rootUrl,t.modelsPath)}function rb(e){return un(e.stylePath)?e.stylePath:Fn(e.rootUrl,e.stylePath)}const ob=new RegExp("^(?:(?:[a-z]+:)?(?:[a-z]+:)?//|data:)","i");function un(e){return ob.test(e)}function ab(e){return/{\w+}/g.test(e)}function Fn(...e){const t=e.filter(i=>i.length>0);let n=t[0];for(let i=1;i<t.length;i++){n[n.length-1]!=="/"&&(n+="/");const s=t[i];s[0]==="/"?n+=s.slice(1):n+=s}return n}function ah(e,t,n){const i=Ye(n.style.iconAnchor),s=Li(e,i[0],i[1]);return t.rasterSets.byKey[s]}function cb(e,t,n,i){const s=t.icons[n.name];if(!s)return;const r=Cs(n.rasters,i*window.devicePixelRatio,!0);if(r===void 0)return;const o=jc(s.url,t,Aa(e.map.state.subdomains,n.name)),{w:a,h:c}=n.rasters[r];return{fullUrl:o,width:a,height:c}}function lb(e,t,n,i){const s=ib(i),r=ah(s,t,n);if(!r)return;const o=t.icons[r.name];if(o)return jc(o.url,t,Aa(e.map.state.subdomains,r.name))}function db(e,t,n){const i=e.styleManager.getStyle(e.map.state.handyStyleId);if(!i)return;const s=i.layersById[t.layerId];if(!s)return;const r=eu(e.map.state.styleZoom,e.map.state.styleState,[]);let o;const a=s.style.iconWidth,c=ae(a,r);if(n.isCommercial){o=i.rasterSets.byKey[ja(t.id,"commercial")];const u=o.url;if(!u)return;const h=Cs(o.rasters,c*window.devicePixelRatio,!0);if(h===void 0)return;const{w:y,h:w}=o.rasters[h],p=rh(u,y,w);return{baseUrl:u,fullUrl:p,width:y,height:w}}const l=s.style.iconImage;if(!l)return;const d=Ke(l,r);if(o=ah(d,i,s),!o)return;const f=cb(e,i,o,c);if(f){if(nb(d)){const u=lb(e,i,s,d);u!==void 0&&(f.fullUrlUnhovered=u)}return f}}function fb(e){return Array.isArray(e)?e:[e]}function ub(e){return e&&e.buffer instanceof ArrayBuffer}var fi=(e=>(e[e.None=0]="None",e[e.Zoom=1]="Zoom",e[e.Distance=2]="Distance",e))(fi||{}),ch=(e=>(e[e.default=0]="default",e[e.flat=1]="flat",e[e.axis=2]="axis",e[e.centroid=3]="centroid",e))(ch||{});const Nn=[0,0,0],Rs=new Int16Array([0,0,0]),xe=new Array(16),Hc=new Float32Array(9),hn=[0,0,0],Vc=[0,0,0],$c=[0,0,0],ui=[0,0,0],uo=[0,0,0],lh=[0,0,0],hb=rt(),pb=cr([1,1,1]),Rn={symbol:"gltfModel",sinks:{instances:{stride:64,binder:(e,t)=>{e.views.flatPosition=new Uint16Array(t),e.views.flatHeight=new Float32Array(t,4),e.views.ecefPosition=new Int16Array(t,8),e.views.matrix=new Float32Array(t,16),e.views.localID=new Uint32Array(t,52),e.views.labelingTextureID=new Uint32Array(t,56),e.views.absZ=new Float32Array(t,60)},packObjectAttributes(e,t,n,i,s,r,o,a,c,l=[],d,f,u,h,y,w,p,g){return Ee([e,t.innerId,n,l,c,r,o,i,s,d,f,u,h,y,w,p,g],t,a)},unpackObjectAttributes(e){return{styleId:e[0],layerId:e[1],modelIndices:e[2],lngLat:e[3],emitShowHideEvents:e[4],sourceId:e[5],sourceName:e[6],modelStepValues:e[7],modelStepSource:e[8],parentId:e[9],absZ:e[10],floorId:e[11],hiddenByFloorComplexId:e[12],subkey:e[13],extToReliefNeeded:e[14],collapseHeightNeeded:e[15],scene:e[16],tileData:e.slice(17)}}}},generateInstances(e,t,n,i,s,r,o,a,c,l,d=0){const f=xr(G(n.style.geometryModifier,i),r,s,i);if(f===null)return;const u=G(n.style.linkedIds,i),h=u===""?[]:fb(u),y=n.style.modelSrc,w=[];let p=fi.None;const g=ii(y,i,n,!0),b=G(n.style.scene,i);if(g.length===1)w.push(0);else if(g.length>1){if(!$t(y)||y.type!=="step"||!$t(y.value)){console.error(`Only step-expression is allowed as 'modelSrc' style property. Models won't be displayed for layer ${n.id}`);return}switch(y.value.type){case"zoom":p=fi.Zoom;break;case"distance":p=fi.Distance;break;default:console.error(`'${y.value.type}' type in 'modelSrc' step expression is not supported. Only 'zoom' and 'distance' are supported. Models won't be displayed for layer ${n.id}`);return}y.steps.forEach(({key:N})=>{w.push(N)})}p===fi.Distance&&g.reverse(),g.forEach((N,H)=>{N===null&&H!==0&&(g[H]=g[H-1])}),p===fi.Distance&&g.reverse();const v=g.map(N=>N===null?"":N).map(N=>{let H=t.modelIndex[N];return H===void 0&&(N=tb(N,a??"",r.coords),H=e.addUsedModelByUrl(N)),e.addUsedModel(H),H}),{tileProps:M,tileAttrs:E}=i;let T=dn;n.interactive?i.id&&(T=E[M.hovered]?it:e.idIndexer.getIndex(i,t.id,n,{metatile:l,objectClass:E[M.db_object_class]})):T=n.interactiveOcclusion?dn:it;const L=i.id??"-1",A=E[M.db_point_building_id],P=E[M.db_hidden_by_metro_building_id]||"";let R=dn;i.id&&(R=e.pointIndexer.getIndex(A??i.id));const k=c?.has(E[M.db_sublayer])&&L!=="-1"?1:0,V=f.abs_z!==void 0&&Array.from(f.abs_z).some(N=>N)?f.abs_z:void 0,z=i.styleState.terrainEnabled===!0,$=i.tileAttrs[i.tileProps.db_extension_to_relief_surface],ee=z&&!!V&&!Number.isNaN($),I=!!i.tileAttrs[i.tileProps.db_ignore_z]&&!!V&&z,_=typeof i.sourceAttrs.sourceName=="string"?i.sourceAttrs.sourceName:"",S=e.getBucket("gltfModel","instances",Rn.sinks.instances.packObjectAttributes(t.id,n,v,w,p,o,_,i,k,k?ls(f.x[0],f.y[0],r):void 0,A,!!V,E[M.db_plan_id]||"",P,Gy(r,f.x[0],f.y[0],d),ee,I,b),Rn.sinks.instances.binder);let D=S.meta;if(D)D.linkedIds.push(...h);else{const N=M.db_plan_id?E[M.db_plan_id]:void 0;D=S.meta={linkedIds:h.slice(),modelsPath:a??"",buildingId:L,planId:N}}k&&(D.sublayer=E[M.db_sublayer]),A&&(D.childrenIds||(D.childrenIds=[]),D.childrenIds.push(L));let O;const C=gb(E,i);if(C){const N=f.x[0],H=f.y[0];dt(uo,[N,H],r),O=[uo,oe.fromGeo(C)]}const F=wb(E,i),U=vb(E,i);let j=0;for(let N=0;N<f.x.length;N++){if(Se(Vc,0,0,0),tr(G(n.style.rotation,i),Vc),Se(hn,1,1,1),tr(G(n.style.scale,i),hn),Se($c,0,0,0),tr(G(n.style.offset,i),$c),f.xScaleDirection&&f.yScaleDirection&&f.scaleCorrection){const H=f.x[N],q=f.y[N];dt(uo,[H,q],r);const X=f.xScaleDirection[N],te=f.yScaleDirection[N];dt(lh,[X,te],r),O=[uo,lh],j=f.scaleCorrection[N]}dh(f.x[N],f.y[N],f.z?.[N]??0,$c,hn,Vc,O,j,F,U,r,n.minzoom<gn.globeMaxZoom),bb(S,Nn,Rs,Hc,T,R,V?.[N])}},patchBuffer(e,t,n,i,s,r,o,a){const c=Rn.sinks.instances.stride*t;dh(i[0],i[1],i[2],s,r,o,void 0,void 0,void 0,void 0,n,a);const l=Nn[0]+B,d=Nn[1]+B,f=Nn[2]/(32*Oe);e.subData(c+0,new Uint16Array([l,d])),e.subData(c+4,new Float32Array([f])),a&&e.subData(c+8,Rs),e.subData(c+16,Hc)}};function mb(e,t,n,i){const s=n*ne/wt(i.coords[2]);mt(t,t,s),t[2]*=n,Vn(e,e,t)}function dh(e,t,n,i,s,r,o,a,c,l,d,f){Se(Nn,e,t,n);const u=vt(d,Nn)*me;if(oa(xe),rr(xe,xe,pe(r[2])),Bd(xe,xe,pe(r[1])),ca(xe,xe,pe(r[0])),bi(xe,xe,s),o)if(a)yb(xe,o[0],o[1]),Se(hn,a*me,a*me,u),bi(xe,xe,hn);else{Jt(ui,o[1],o[0]),c?rr(xe,xe,c):rr(xe,xe,Math.atan2(ui[1],ui[0]));const h=l??ir(ui);Se(hn,h,h,h),bi(xe,xe,hn)}else Se(hn,u,u,u),bi(xe,xe,hn);if(ca(xe,xe,Math.PI/2),y1(Hc,xe),mb(Nn,i,u,d),f){const h=Ba(d,Nn);Rs[0]=h[0]*Xe,Rs[1]=h[1]*Xe,Rs[2]=h[2]*Xe}}function yb(e,t,n){Jt(ui,n,t),rr(e,e,Math.atan2(ui[1],ui[0]))}function gb(e,t){const n=e[t.tileProps.direction];return n===void 0?null:Array.isArray(n)?n:n.type==="Point"?n.coordinates:null}function wb(e,t){return e[t.tileProps.angle]}function vb(e,t){return e[t.tileProps.scale]}function bb(e,t,n,i,s,r,o){const a=e.elements.offset*Rn.sinks.instances.stride,c=e.views,l=a/c.flatPosition.BYTES_PER_ELEMENT,d=B+t[0],f=B+t[1],u=t[2]*Mf;if(c.flatPosition[l]=d,c.flatPosition[l+1]=f,c.flatHeight[a/c.flatHeight.BYTES_PER_ELEMENT]=u/Oe,c.ecefPosition[l]=n[0],c.ecefPosition[l+1]=n[1],c.ecefPosition[l+2]=n[2],e.elements.offset>e.elements.maximum-1)return;c.matrix.set(i,a/c.matrix.BYTES_PER_ELEMENT),c.localID[a/c.localID.BYTES_PER_ELEMENT]=s,c.labelingTextureID[a/c.labelingTextureID.BYTES_PER_ELEMENT]=r,c.absZ[a/c.absZ.BYTES_PER_ELEMENT]=o??0,Ib(e,d,f,u,i);const h=e.indices;h.buffer[h.offset]=e.elements.offset,h.offset++,e.elements.offset++}function Ib(e,t,n,i,s){const r=e.extents;t<r[0]&&(r[0]=t),n<r[1]&&(r[1]=n),i<r[2]&&(r[2]=i),t>r[3]&&(r[3]=t),n>r[4]&&(r[4]=n),i>r[5]&&(r[5]=i);const o=hb;_1(s,o);const a=cr(o)/pb;a>e.maxDiag&&(e.maxDiag=a)}var se=(e=>(e[e.side=0]="side",e[e.top=1]="top",e[e.bottom=2]="bottom",e))(se||{});const Bs=[0,0,0],ks=[0,0,0],Us=[0,0,0],ho=[0,0,0],fh=(e,t,n,i,s)=>Ee([e,t.innerId,n,i],t,s),uh=(e,t,n,i)=>Ee([e,t.innerId,n],t,i),hh=e=>({styleId:e[0],layerId:e[1],side:e[2],absZ:e[3],tileData:e.slice(4)}),ph=e=>({styleId:e[0],layerId:e[1],absZ:e[2],tileData:e.slice(3)}),Q={symbol:"mesh",sinks:{fill:{stride:28,binder:(e,t)=>{e.views.position=new Uint16Array(t),e.views.height=new Float32Array(t,4),e.views.normal=new Int8Array(t,8),e.views.gradient=new Int8Array(t,11),e.views.localID=new Uint32Array(t,12),e.views.demPosition=new Int16Array(t,16),e.views.absZ=new Float32Array(t,16),e.views.isPivot=new Uint8Array(t,20),e.views.labelingTextureID=new Uint32Array(t,24)},packObjectAttributes:fh,unpackObjectAttributes:hh},inverse:{stride:16,binder:(e,t)=>{e.views.position=new Uint16Array(t),e.views.height=new Float32Array(t,4),e.views.demPosition=new Int16Array(t,8),e.views.absZ=new Float32Array(t,8),e.views.isPivot=new Uint8Array(t,12)},packObjectAttributes:uh,unpackObjectAttributes:ph},depthClear:{stride:16,binder:(e,t)=>{e.views.position=new Uint16Array(t),e.views.height=new Float32Array(t,4),e.views.demPosition=new Int16Array(t,8),e.views.absZ=new Float32Array(t,8),e.views.isPivot=new Uint8Array(t,12)},packObjectAttributes:uh,unpackObjectAttributes:ph},stroke:{stride:20,binder:(e,t)=>{e.views.position=new Uint16Array(t),e.views.height=new Float32Array(t,4),e.views.directionDistance=new Int8Array(t,8),e.views.demPosition=new Int16Array(t,12),e.views.absZ=new Float32Array(t,12),e.views.isPivot=new Uint8Array(t,16)},packObjectAttributes:fh,unpackObjectAttributes:hh}},generate(e,t,n,i,s,r,o,a,c,l,d="fill",f=!1){const u=r.x,h=r.y,y=r.signed_z;let w=0;if(n.type==="polygon3d"||n.type==="embankment"){const P=G(n.style.elevation,s),R=s.tileInfo?vt(s.tileInfo,[0,0]):1;w=P*me*R}const p=r.gradient,g=r.abs_z,b=r.is_pivot,v=u.length,M=s.tileAttrs[s.tileProps.hovered],E=s.id??"",T=e.pointIndexer.getIndex(E);let L=dn;switch(n.type){case"polygon3d":{n.interactive?(L=M?it:e.idIndexer.getIndex(s,t,n),!M&&L===it&&(L=dn)):L=n.interactiveOcclusion?dn:it;break}case"overpass":case"tunnel":{L=e.idIndexer.getIndex(s,t,n),L===it&&(L=dn);break}case"embankment":{L=dn;break}default:{const{type:P}=n}}(n.type==="embankment"||n.type==="polygon3d")&&c&&pc(e,t,c,n.style,a);let A;if(d==="inverse")A=e.getBucket("mesh","inverse",Q.sinks.inverse.packObjectAttributes(t,n,!!g,s),Q.sinks.inverse.binder);else if(d==="fill")A=e.getBucket("mesh","fill",Q.sinks.fill.packObjectAttributes(t,n,i,!!g,s),Q.sinks.fill.binder);else if(d==="depthClear")A=e.getBucket("mesh","depthClear",Q.sinks.depthClear.packObjectAttributes(t,n,!!g,s),Q.sinks.depthClear.binder);else return;for(let P=0;P<v-2;P++){const R=!(P%2);Mb(A);const k=f?2:1,V=f?1:2,z=R?P+k:P+V,$=R?P+V:P+k,ee=ne/o.size;Se(Bs,u[P],h[P],(y?.[P]??0)*ee),Se(ks,u[z],h[z],(y?.[z]??0)*ee),Se(Us,u[$],h[$],(y?.[$]??0)*ee),Kd(ho,Bs,ks,Us),Bs[2]/=ee,ks[2]/=ee,Us[2]/=ee,Bs[2]+=w,ks[2]+=w,Us[2]+=w;const I=A.elements.offset;Yc(A,Bs,ho,p?.[P],L,T,l,g?.[P],b?.[P]),Yc(A,ks,ho,p?.[z],L,T,l,g?.[z],b?.[z]),Yc(A,Us,ho,p?.[$],L,T,l,g?.[$],b?.[$]),A.objectsData[I]={objectId:E,size:A.elements.offset-I}}}};function Yc(e,t,n,i,s,r,o,a,c){const l=e.elements.stride*e.elements.offset,d=l/e.views.position.BYTES_PER_ELEMENT;e.views.position[d]=B+t[0],e.views.position[d+1]=B+t[1],e.views.height[l/e.views.height.BYTES_PER_ELEMENT]=t[2];const f=l/e.views.demPosition.BYTES_PER_ELEMENT;if(e.views.demPosition[f]=((o?.[0]??t[0])+B)/8,e.views.demPosition[f+1]=((o?.[1]??t[1])+B)/8,a!==void 0&&(e.views.absZ[l/e.views.absZ.BYTES_PER_ELEMENT]=a),e.views.isPivot[l/e.views.isPivot.BYTES_PER_ELEMENT]=c??0,"normal"in e.views){const u=l/e.views.normal.BYTES_PER_ELEMENT,h=l/e.views.localID.BYTES_PER_ELEMENT,y=l/e.views.gradient.BYTES_PER_ELEMENT;e.views.normal[u]=Ne(n[0]),e.views.normal[u+1]=Ne(n[1]),e.views.normal[u+2]=Ne(n[2]),e.views.gradient[y]=Ne(i??0),e.views.localID[h]=s,e.views.labelingTextureID[h]=r}e.elements.offset++}function Mb(e){const t=e.indices.buffer,n=e.indices.offset,i=e.elements.offset;t[n]=i,t[n+1]=i+1,t[n+2]=i+2,e.indices.offset+=3}const mh=[0,0,0],yh=[0,0,0],gh=[0,0,0],po=[0,0,0],Ui={symbol:"mapMesh",sinks:{fill:{stride:24,binder:(e,t)=>{e.views.position=new Uint16Array(t),e.views.height=new Float32Array(t,4),e.views.extender=new Int16Array(t,8),e.views.normal=new Int8Array(t,12),e.views.gradient=new Int8Array(t,15),e.views.demPosition=new Int16Array(t,16),e.views.absZ=new Float32Array(t,16),e.views.isPivot=new Uint8Array(t,20)},packObjectAttributes:(e,t,n,i,s)=>Ee([e,t.innerId,n,i],t,s),unpackObjectAttributes:e=>({styleId:e[0],layerId:e[1],meshTier:e[2],absZ:e[3],tileData:e.slice(4)})}},generate(e,t,n,i,s,r,o,a){const c=s.x,l=s.y,d=s.signed_z??[],f=s.gradient,u=s.is_pivot,h=s.abs_z,y=c.length,w=a?.[0],p=a?.[1];if(y<3)return;const g=ne/o.size,b=e.getBucket("mapMesh","fill",Ui.sinks.fill.packObjectAttributes(t,n,r,!!h,i),Ui.sinks.fill.binder),v=b.indices.buffer;let M=b.indices.offset;const E=b.elements.offset;for(let T=2;T<y;T++){const L=!(T%2),A=L?T-2:T-1,P=L?T-1:T-2;Tb(v,M,E,(T-2)*3+2),Se(gh,c[A],l[A],d[A]*g),Se(yh,c[P],l[P],d[P]*g),Se(mh,c[T],l[T],d[T]*g),Kd(po,gh,yh,mh),Zc(b,c[A],l[A],d[A],f?.[A],u?.[A],h?.[A],po,w,p),Zc(b,c[P],l[P],d[P],f?.[P],u?.[P],h?.[P],po,w,p),Zc(b,c[T],l[T],d[T],f?.[T],u?.[T],h?.[T],po,w,p),M+=3}b.indices.offset=M}};function Tb(e,t,n,i){e[t]=n+i-2,e[t+1]=n+i-1,e[t+2]=n+i}function Zc(e,t,n,i,s,r,o,a,c=t,l=n){const d=e.elements.offset*e.elements.stride,f=d/e.views.position.BYTES_PER_ELEMENT,u=d/e.views.normal.BYTES_PER_ELEMENT,h=d/e.views.demPosition.BYTES_PER_ELEMENT;e.views.position[f]=B+t,e.views.position[f+1]=B+n,e.views.height[d/e.views.height.BYTES_PER_ELEMENT]=i,e.views.normal[u]=Ne(a[0]),e.views.normal[u+1]=Ne(a[1]),e.views.normal[u+2]=Ne(a[2]),e.views.gradient[d/e.views.gradient.BYTES_PER_ELEMENT]=s??0,e.views.isPivot[d/e.views.isPivot.BYTES_PER_ELEMENT]=r??0,e.views.demPosition[h]=(B+c)/8,e.views.demPosition[h+1]=(B+l)/8,o!==void 0&&(e.views.absZ[d/e.views.absZ.BYTES_PER_ELEMENT]=o),e.elements.offset++}const Sb=1,Wc=-1,Ab=1.3,wh=-200,vh=-300,Eb=Math.tan(pe(175/2)),St=[0,0,0],Bn=[0,0,0],xb=[0,0,0],zs=[0,0,0],Xc=[0,0,0],Le=[0,0,0];let mo=0,Gs=0;const _b=(e,t)=>e<0||t<0?Math.floor(Math.min(e,t)):Math.ceil(Math.max(e,t)),bh={symbol:"overpass",sinks:{},generate(e,t,n,i,s,r,o,a){let c=s.signed_z;if(!c)return;const l=s.abs_z!==void 0&&Array.from(s.abs_z).some(S=>S)?s.abs_z:void 0,d=i.styleState.terrainEnabled===!0,f=!l,u=i.tileAttrs[i.tileProps.db_road_part],h=i.tileAttrs[i.tileProps.db_geometry_type],y=i.tileAttrs[i.tileProps.db_tiers]?.[0],w=!1;if(u==="roadbed_flat"||u==="border_tunnel_descent"&&w)return;const g=i.tileProps,b=i.tileAttrs.slice();i.id=void 0,b[g.db_tiers]=void 0;const v=t.id,M=s.x.length,E=s.x,T=s.y,L=s.cut??[],A=new Uint8Array(M);c.forEach((S,D)=>{A[D]=S?0:1});const P=u==="roadbed_tunnel"||u==="roadbed_tunnel_descent"||u==="border_tunnel"||u==="border_tunnel_descent";let R=!1;P?R=!1:R=!!i.tileAttrs[i.tileProps.db_ignore_z]&&!!l&&d,R&&(c=new Int32Array(c.length));const k=f?Ab:1;d&&P&&(c=new Int32Array(c).map(S=>S*k)),Ce(zs,0,0);const z=vt(r,zs)*me,$=ne/r.size*z,ee=Math.max(ae(n.style.borderWidth,i,0),0)*$,I=Math.max(ae(n.style.thickness,i,0),0)*z,_=ee>0?Math.max(-I,ae(n.style.borderHeight,i,0)*z):0;if(Math.max(ae(n.style.tunnelHeight,i,0),0)*z,h==="polygon"){if(y===void 0)return;const S=[E,T,L,c,new Int8Array(M),A];l&&S.push(l);const D=u==="roadbed_tunnel_descent",O=u==="roadbed_tunnel"||D;Ui.generate(e,v,n,i,le(S),y,r,void 0);const C=S.map(j=>Array.from(j));for(let j=0;j<C[3].length;j++)D?C[3][j]-=I*.01:C[3][j]-=I,C[4][j]=0;Q.generate(e,v,n,se.bottom,i,le(C),r,o,a,void 0,O?"inverse":"fill",!0);const F=[];for(let j=0;j<y;j++)F.push(j);const U=e.getBucket("polygon","shadow",Nt.sinks.shadow.packObjectAttributes(v,n,F,"",i),Nt.sinks.shadow.binder);if(Nu(U,S[0].length,S[0],S[1],it),O&&!D){const j=S.slice();j[3]=Array.from(S[3]).map(N=>N+Math.abs(N/k)-1),j.length=4,Q.generate(e,v,n,se.top,i,le(j),r,o,a,void 0,"inverse")}if(D&&d&&!w){const j=S.slice();j[3]=new Array(S[0].length).fill(Math.max(0,_)),j[5]=new Array(S[0].length).fill(1),Q.generate(e,v,n,se.top,i,le(j),r,o,a,void 0,"depthClear")}}else if(h==="polyline"){const S=Q.sinks.stroke.packObjectAttributes(v,n,se.top,!!l,i),D=Q.sinks.stroke.packObjectAttributes(v,n,se.side,!!l,i),O=Q.sinks.stroke.packObjectAttributes(v,n,se.bottom,!!l,i),C=Pb({x:E,y:T,cut:L,signed_z:c,is_pivot:A,abs_z:l});if(u==="tunnel_arch"&&!w){const F=Math.max(_,0),U=yo(C),j=Ob(C,ee),N=C.map(J=>{const K=J.slice();return K[2]=f?vh:wh,l&&(K[5]=0),K[4]=0,K});ce(e,O,N);const H=At(j,U,ee).map(J=>(J[2]=F,J[4]=1,J)),q=j.map(J=>{const K=J.slice();return K[2]=F,K[4]=1,K}),X=be(H,q);do Q.generate(e,v,n,se.top,i,le(X),r,o,a,void 0,F?"fill":"inverse");while(e.isOverloaded());const te=C.map(J=>{const K=J.slice();return K[2]=F,K[4]=1,K});ce(e,S,te);const W=be(te,N);do Q.generate(e,v,n,se.side,i,le(W),r,o,a);while(e.isOverloaded());const ie=be(te.map(J=>{const K=J.slice();return K[2]=f?vh:wh,K[4]=0,l&&(K[5]=0),K}),te.map(J=>{const K=J.slice();return K[2]=0,K}));do Q.generate(e,v,n,se.side,i,le(ie),r,o,a,void 0,"inverse");while(e.isOverloaded());if(F){const J=At(j,U,ee).map(kt=>(kt[2]=0,kt[4]=0,kt));ce(e,O,J),ce(e,S,H);const K=be(J,H);do Q.generate(e,v,n,se.side,i,le(K),r,o,a,void 0,"fill");while(e.isOverloaded());const he=j.map(kt=>{const st=kt.slice();return st[2]=0,st[4]=0,st}),Z=be([q[0],he[0]],[H[0],J[0]]);do Q.generate(e,v,n,se.side,i,le(Z),r,o,a,void 0,"fill");while(e.isOverloaded());ce(e,S,[q[0],H[0]]),ce(e,D,[H[0],J[0]]),ce(e,O,[J[0],he[0]]);const Y=q.length-1,Bt=be([he[Y],q[Y]],[J[Y],H[Y]]);do Q.generate(e,v,n,se.side,i,le(Bt),r,o,a,void 0,"fill");while(e.isOverloaded());if(ce(e,S,[q[Y],H[Y]]),ce(e,D,[H[Y],J[Y]]),ce(e,O,[J[Y],he[Y]]),d){do Q.generate(e,v,n,se.top,i,le(X),r,o,a,void 0,"depthClear");while(e.isOverloaded());do Q.generate(e,v,n,se.side,i,le(K),r,o,a,void 0,"depthClear");while(e.isOverloaded());do Q.generate(e,v,n,se.side,i,le(Z),r,o,a,void 0,"depthClear");while(e.isOverloaded());do Q.generate(e,v,n,se.side,i,le(Bt),r,o,a,void 0,"depthClear");while(e.isOverloaded())}}}else if(u==="border_overpass"||u==="border_flat"){const F=[b[g.previousPointX],b[g.previousPointY],c[0]??0,0],U=!!b[g.beginningIsCut]&&Ih(C[1],C[0],F);U&&C.splice(0,0,F);const j=C.length-1,N=[b[g.nextPointX],b[g.nextPointY],c[c.length-1]??0,0],H=!!b[g.endingIsCut]&&Ih(C[j-1],C[j],N);H&&C.push(N);const q=yo(C);U&&(q.shift(),C.shift()),H&&(q.pop(),C.pop());const X=C.map(Z=>{const Y=Z.slice();return Y[2]=Math.max(Y[2]-I,0),Y[4]=0,Y});ce(e,D,C);const te=At(C,q,ee).map(Z=>{const Y=Z.slice();return Y[2]=Math.max(Z[2]-I,0),Y[4]=0,Y}),W=At(C,q,ee).map(Z=>{const Y=Z.slice();return Y[2]=Math.max(Z[2]+_,0),Y[4]=1,Y}),ie=C.map(Z=>{const Y=Z.slice();return _>0&&(Y[2]=Math.max(Y[2]+_,0)),Y[4]=1,Y});if(_>0){ce(e,S,ie);const Z=be(ie,C.map(Y=>{const Bt=Y.slice();return Bt[4]=0,Bt}));do Q.generate(e,v,n,se.side,i,le(Z),r,o,a);while(e.isOverloaded())}ce(e,O,te),ce(e,S,W);const J=be(W,ie);do Q.generate(e,v,n,se.top,i,le(J),r,o,a);while(e.isOverloaded());const K=be(X,te);do Q.generate(e,v,n,se.bottom,i,le(K),r,o,a,void 0,"fill");while(e.isOverloaded());const he=be(te,W);do Q.generate(e,v,n,se.side,i,le(he),r,o,a,void 0,"fill");while(e.isOverloaded());if(c[0]===0){const Z=be([ie[0],X[0]],[W[0],te[0]]);do Q.generate(e,v,n,se.side,i,le(Z),r,o,a,void 0,"fill");while(e.isOverloaded());ce(e,S,[W[0],ie[0]]),ce(e,D,[ie[0],X[0]]),ce(e,D,[te[0],W[0]]),ce(e,O,[X[0],te[0]])}if(c[c.length-1]===0){const Z=X.length-1,Y=be([X[Z],ie[Z]],[te[Z],W[Z]]);do Q.generate(e,v,n,se.side,i,le(Y),r,o,a,void 0,"fill");while(e.isOverloaded());ce(e,S,[ie[Z],W[Z]]),ce(e,D,[X[Z],ie[Z]]),ce(e,D,[W[Z],te[Z]]),ce(e,O,[te[Z],X[Z]])}}else{const F=yo(C),U=u==="border_tunnel_descent",j=u==="border_tunnel"||U,N=j?Math.max(_,0):_,H=C.map(W=>{const ie=W.slice();return ie[2]-=I,U?(ie[2]=0,ie[5]=1):j&&(ie[2]=Math.max(ie[2],Wc)),ie[4]=0,ie}),q=At(C,F,ee).map(W=>(W[2]-=I,U&&(W[2]=0,W[5]=1),W[4]=0,W)),X=At(C,F,ee).map(W=>(W[2]+=N,U?(W[2]=N,W[5]=1):j&&(W[2]=Math.max(W[2],Wc)),W[4]=1,W)),te=C.map(W=>{const ie=W.slice();if(ie[4]=1,U)ie[2]=N,ie[5]=1;else if(j){const J=Math.abs(ie[2]/k),K=N-ie[2],he=ie[2]+J-1;ie[4]=(he+Math.abs(ie[2]))/K,ie[2]=he}else ie[2]+=N;return ie});if(j){U&&ce(e,S,te);const W=be(te,C.map(K=>{const he=K.slice();return he[4]=0,he}));do Q.generate(e,v,n,se.side,i,le(W),r,o,a);while(e.isOverloaded());const ie=te.map(K=>{const he=K.slice();return he[2]=Math.min(K[2],Wc),he}),J=be(ie,C);do Q.generate(e,v,n,se.side,i,le(J),r,o,a,void 0,"inverse",!0);while(e.isOverloaded())}if(_>0&&(!j||U)){ce(e,O,q),ce(e,S,X);const W=be(X,te);do Q.generate(e,v,n,se.top,i,le(W),r,o,a);while(e.isOverloaded());if(U&&d)do Q.generate(e,v,n,se.top,i,le(W),r,o,a,void 0,"depthClear");while(e.isOverloaded())}if(!j||U){const W=be(H,q);do Q.generate(e,v,n,se.bottom,i,le(W),r,o,a,void 0,"fill");while(e.isOverloaded());const ie=be(q,X);do Q.generate(e,v,n,se.side,i,le(ie),r,o,a,void 0,"fill");while(e.isOverloaded());if(U&&d)do Q.generate(e,v,n,se.side,i,le(ie),r,o,a,void 0,"depthClear");while(e.isOverloaded());if(c[0]===0){const J=be([te[0],H[0]],[X[0],q[0]]);do Q.generate(e,v,n,se.side,i,le(J),r,o,a,void 0,"fill");while(e.isOverloaded());if(U&&d)do Q.generate(e,v,n,se.side,i,le(J),r,o,a,void 0,"depthClear");while(e.isOverloaded());ce(e,S,[X[0],te[0]]),ce(e,D,[te[0],H[0]]),ce(e,D,[q[0],X[0]]),ce(e,O,[H[0],q[0]])}if(c[c.length-1]===0){const J=H.length-1,K=be([H[J],te[J]],[q[J],X[J]]);do Q.generate(e,v,n,se.side,i,le(K),r,o,a,void 0,"fill");while(e.isOverloaded());if(U&&d)do Q.generate(e,v,n,se.side,i,le(K),r,o,a,void 0,"depthClear");while(e.isOverloaded());ce(e,S,[te[J],X[J]]),ce(e,D,[H[J],te[J]]),ce(e,D,[X[J],q[J]]),ce(e,O,[q[J],H[J]])}}}}}};function Pb(e){const t=[],n=e.x.length;for(let i=0;i<n;i++){const s=[e.x[i],e.y[i],e.signed_z?.[i]??0,e.cut?.[i]??0,0,e.is_pivot?.[i]??0];e.abs_z&&s.push(e.abs_z[i]),t.push(s)}return t}function yo(e){const t=[];Vt(St,e[0][0],e[0][1],e[1][0],e[1][1]),mo=0;for(let n=1;n<e.length;n++)Lb(t,e,n);return t}function Lb(e,t,n){const i=n===t.length-1;if(Ce(xb,t[n-1][0],t[n-1][1]),Ce(zs,t[n][0],t[n][1]),Ta(Le,St),i)Gs=0;else{Ce(Xc,t[n+1][0],t[n+1][1]),Vt(Bn,zs[0],zs[1],Xc[0],Xc[1]);const o=ge(bn(St,Bn),-1,1),a=Math.min(Math.sqrt((1-o)/(1+o)),Eb),c=er(bn(Le,Bn));Gs=a*c}let s=Le[0]+St[0]*mo,r=Le[1]+St[1]*mo;e.push([s,r]),i&&(s=Le[0]+St[0]*Gs,r=Le[1]+St[1]*Gs,e.push([s,r])),i||(nr(St,Bn),mo=Gs)}function At(e,t,n){const i=[];for(let s=0;s<e.length;s++){const r=e[s].slice();nr(Le,t[s]),mt(Le,Le,n),Pt(r,r,Le),i.push(r)}return i}function ce(e,t,n){do{const i=e.getBucket("mesh","stroke",t,Q.sinks.stroke.binder),s=n.length;for(let r=0;r<s-1;r++){const o=r+1;As(i,n[r][0],n[r][1],n[r][2],n[o][0],n[o][1],n[o][2],void 0,!1,!0,n[r][6],n[o][6],n[r][5],n[o][5])}}while(e.isOverloaded())}function be(e,t){return Db([e[0]].concat(e,t.slice().reverse()))}function Db(e){const t=e.length,n=[[],[],[],[],[],[]];e[0][6]!==void 0&&n.push([]);for(let i=0;i<t;i++){const s=et(i,t),r=e[i];n[0][s]=r[0],n[1][s]=r[1],n[2][s]=r[3],n[3][s]=r[2],n[4][s]=r[4]??0,n[5][s]=r[5]??0,n[6]&&(n[6][s]=r[6]??0)}return n}function le(e){return{x:e[0],y:e[1],cut:e[2],signed_z:e[3],gradient:e[4],is_pivot:e[5],abs_z:e[6]}}function Ob(e,t){return e=e.map(n=>n.slice()),Gt(Le,e[0],e[1]),zt(Le,Le),Tn(Le,Le,t),Vn(e[0],e[0],Le),Gt(Le,e[e.length-1],e[e.length-2]),zt(Le,Le),Tn(Le,Le,t),Vn(e[e.length-1],e[e.length-1],Le),e}const Ih=(function(){const e=Math.cos(pe(Sb));return(t,n,i)=>(Jt(St,n,t),vn(St,St),Jt(Bn,n,i),vn(Bn,Bn),bn(St,Bn)<=e)})();function Cb(e,t,n,i){return Ee([e,t.innerId,n],t,i)}const go={symbol:"metricPoint",sinks:{fill:{stride:8,binder:(e,t)=>{e.views.position=new Uint16Array(t),e.views.texCoords=new Uint16Array(t,4)},packObjectAttributes:Cb,unpackObjectAttributes:e=>({styleId:e[0],layerId:e[1],tiers:e[2],tileData:e.slice(3)})}},generate(e,t,n,i,s,r,o){Nb(e,i,s,n,r);const a=ae(s.style.width,r),c=ae(s.style.height,r),l=ae(s.style.rotation,r),[d,f]=qy([t.x,t.y],a,c,l,o),u=G(s.ignoreTier,r)?null:r.tileAttrs[r.tileProps.db_tiers],h=e.getBucket("metricPoint","fill",go.sinks.fill.packObjectAttributes(i.id,s,u,r),go.sinks.fill.binder);let y=h.elements.offset;Fb(h.indices,y,0,1,2,0,2,3),wo(h,y++,d[0],f[0],0,0),wo(h,y++,d[1],f[1],1,0),wo(h,y++,d[2],f[2],1,1),wo(h,y++,d[3],f[3],0,1),h.elements.offset=y}};function wo(e,t,n,i,s,r){t=t*4,e.views.position[t]=B+n,e.views.position[t+1]=B+i,e.views.texCoords[t]=ht(s),e.views.texCoords[t+1]=ht(r)}function Fb(e,t,n,i,s,r,o,a){const c=e.buffer,l=e.offset;c[l]=t+n,c[l+1]=t+i,c[l+2]=t+s,c[l+3]=t+r,c[l+4]=t+o,c[l+5]=t+a,e.offset=l+6}function Nb(e,t,n,i,s){const{rasterSets:r}=t,o=tc(i);ii(n.style.iconImage).forEach(a=>{if(!a.length)return;const c=r.byKey[_r(a)];if(!c){console.error(`Not found raster set with texture ${a}`);return}if(!c.isSvg)return;const l=ae(n.style.width,s),d=ae(n.style.height,s),f=Er(l,d),u=l*f,h=d*f;e.atlasPacker.packSvg(c,[{w:u,h}],o),c.rasters.forEach(y=>e.atlasPacker.addRastersToLoad(t.id,y))})}const Rb=64,hi=1e5,qc=4;function Bb(e){return e!==null&&typeof e=="object"&&e.type===Rb}function Mh(e){return Sh(e.lo,e.hi)}function Th(e){return[e%hi,Math.floor(e/hi)%hi,0,0]}function kb(e){let n=0;for(let i=0;i<qc;i++){const s=e[i]*4294967296+n;n=Math.floor(s/hi),e[i]=s%hi}}function Ub(e,t){let n=0;for(let i=0;i<qc;i++){const s=e[i]+t[i]+n;n=Math.floor(s/hi),e[i]=s%hi}}function zb(e){const t="00000";let n=!0,i=qc,s="";for(;--i>=0;){const r=String(e[i]);n?e[i]!==0&&(s+=r,n=!1):s+=t.slice(r.length)+r}return s.length||(s="0"),s}function Sh(e,t){const n=Th(e),i=Th(t);return kb(i),Ub(i,n),zb(i)}const je=[0,0,0],vo=[0,0,0],bo=new Float64Array(16),Ah={symbol:"tunnel",sinks:{},generate(e,t,n,i,s,r,o,a){const{tileProps:c,tileAttrs:l}=i,d=l[c.db_tiers]?.[0];if(Mh(l[c.id])!=="70030076221371399"||!d)return;const u=t.id;Ce(je,0,0);const y=vt(r,je)*me,w=ne/r.size*y,p=1/(ne/r.size),g=l[c.objectLength],b=l[c.componentDistanceStart]??0,v=l[c.componentDistanceEnd]??0,M=b===0?0:-5,E=175,T=243,L=v===g?0:-5;if(Number.isNaN(g)||Number.isNaN(b)||g===0)return;const A=T-E,P=E+A*b/g,R=E+A*v/g,k=3.5*w,V=5*w,z=[];let $=0;for(let N=0;N<s.x.length;N++){const H=[s.x[N],s.y[N],0];N>0&&($+=In(H,z[N-1]),H[2]=$),z.push(H)}const ee=Gb(z),I=yo(z);z.forEach(N=>{const H=N[2]/ee;N[2]=(M+H*(L-M))*y,N[5]=(P+H*(R-P))*y});const _=Q.sinks.stroke.packObjectAttributes(u,n,se.side,!0,i),S=At(z,I,k),D=At(z,I,-k),O=be(S,D),C=At(z,I,V),F=C.map(N=>{const H=N.slice();return H[2]=Math.max(0,H[2]),H});Q.generate(e,u,n,se.side,i,le(be(C,F)),r,o,a,void 0,"inverse");const U=At(z,I,-V),j=U.map(N=>{const H=N.slice();return H[2]=Math.max(0,H[2]),H});Q.generate(e,u,n,se.side,i,le(be(j,U)),r,o,a,void 0,"inverse"),z[0][2]!==0&&z[z.length-1][2]!==0&&Q.generate(e,u,n,se.side,i,le(be(F,j)),r,o,a,void 0,"inverse");do Ui.generate(e,u,n,i,le(O),d,r,void 0);while(e.isOverloaded());for(let N=1;N<z.length;N++){const H=[],q=[],X=z[N-1],te=z[N],W=I[N-1],ie=I[N];for(let K=0;K<=181;K+=15){const he=pe(K),Z=X.slice();Se(je,W[0],W[1],0),Tn(je,je,k),Sn(vo,je),kd(bo,-he,vo),es(je,je,bo),je[2]*=p,Vn(Z,Z,je),H.push(Z);const Y=te.slice();Se(je,ie[0],ie[1],0),Tn(je,je,k),Sn(vo,je),kd(bo,-he,vo),es(je,je,bo),je[2]*=p,Vn(Y,Y,je),q.push(Y)}const J=be(H,q);if(Q.generate(e,u,n,se.side,i,le(J),r,o,a,void 0,"fill"),N===1&&z[0][2]===0){ce(e,_,H);const K=z[0].slice(),he=z[0].slice(),Z=I[0].slice(),Y=I[0].slice();mt(Z,Z,V),mt(Y,Y,-V),Pt(K,K,Z),Pt(he,he,Y);const Bt=K.slice(),kt=he.slice();Bt[2]+=V*p,kt[2]+=V*p;const st=[K];for(let Ut=0;Ut<5;Ut++)st.push(Bt);for(let Ut=0;Ut<5;Ut++)st.push(kt);st.push(he),ce(e,_,st),Q.generate(e,u,n,se.side,i,le(be(st,H)),r,o,a,void 0,"fill")}else if(N===z.length-1&&z[z.length-1][2]===0){ce(e,_,q);const K=z[z.length-1].slice(),he=z[z.length-1].slice(),Z=I[z.length-1].slice(),Y=I[z.length-1].slice();mt(Z,Z,V),mt(Y,Y,-V),Pt(K,K,Z),Pt(he,he,Y);const Bt=K.slice(),kt=he.slice();Bt[2]+=V*p,kt[2]+=V*p;const st=[K];for(let Ut=0;Ut<5;Ut++)st.push(Bt);for(let Ut=0;Ut<5;Ut++)st.push(kt);st.push(he),ce(e,_,st),Q.generate(e,u,n,se.side,i,le(be(q,st)),r,o,a,void 0,"fill")}}if(z[0][2]===0||z[z.length-1][2]===0){const N=At(z,I,V),H=At(z,I,-V),q=N.map(J=>{const K=J.slice();return K[2]=Math.max(0,K[2]+V*p),K}),X=H.map(J=>{const K=J.slice();return K[2]=Math.max(0,K[2]+V*p),K});N.forEach(J=>{J[2]=Math.max(0,J[2])}),H.forEach(J=>{J[2]=Math.max(0,J[2])});const te=be(N,q),W=be(X,H);ce(e,_,N),ce(e,_,H),ce(e,_,q),ce(e,_,X),Q.generate(e,u,n,se.side,i,le(te),r,o,a,void 0,"fill"),Q.generate(e,u,n,se.side,i,le(W),r,o,a,void 0,"fill");const ie=be(q,X);Q.generate(e,u,n,se.top,i,le(ie),r,o,a,void 0,"fill")}}};function Gb(e){let t=0;for(let n=0;n<e.length-1;n++)t+=qi(e[n],e[n+1]);return t}var Jc=(e=>(e[e.Chess=1]="Chess",e[e.DoubleDash=2]="DoubleDash",e[e.Stripe=3]="Stripe",e[e.Triangles=4]="Triangles",e[e.Circle=5]="Circle",e[e.Chevron=6]="Chevron",e[e.None=-1]="None",e))(Jc||{});function Eh(e){switch(e){case"chess":return 1;case"doubledash":return 2;case"triangles":return 4;case"circle":return 5;case"heart":return 6;case"stripe":return 3;default:return-1}}const jb={symbol:"simpleMesh",sinks:{fill:{stride:24,binder:()=>{},packObjectAttributes(e,t,n){return Ee([e,t.innerId],t,n)},unpackObjectAttributes(e){return{styleId:e[0],layerId:e[1],tileData:e.slice(2)}}}}},Hb=32,js={symbol:"globe",sinks:{fill:{stride:16,binder:(e,t)=>{e.views.ecefPosition=new Int16Array(t),e.views.flatPosition=new Uint16Array(t,6),e.views.texture=new Uint16Array(t,12)},packObjectAttributes(e,t,n){return[e,t.innerId,n]},unpackObjectAttributes(e){return{styleId:e[0],layerId:e[1],tileData:e.slice(2)}},generate(e,t,n,i){const s=i.coords.join("/"),r=e.getBucket("globe","fill",js.sinks.fill.packObjectAttributes(t.id,n,s),js.sinks.fill.binder);Yb(r,Hb,i.coords)}}}},Vb=Ve.fromGeo([0,90]),$b=Ve.fromGeo([0,-90]);function Yb(e,t,n){const i=Je(n),s=e.views.ecefPosition,r=e.indices.buffer,o=n[1]===2**n[2]-1,a=n[1]===0,c=e.elements.offset*js.sinks.fill.stride/Uint16Array.BYTES_PER_ELEMENT;let l=0,d=e.indices.offset;for(let f=0;f<t;f++)for(let u=0;u<t;u++){let h;const y=[f*32768/(t-1),u*32768/(t-1)];o&&u===t-1?h=Vb:a&&u===0?h=$b:h=Ba(i,y),s[c+l++]=h[0]*Xe,s[c+l++]=h[1]*Xe,s[c+l++]=h[2]*Xe,s[c+l++]=B+y[0],s[c+l++]=B+y[1],s[c+l++]=0,s[c+l++]=f/(t-1)*(2**16-1),s[c+l++]=u/(t-1)*(2**16-1)}for(let f=0;f<t-1;f++)for(let u=0;u<t-1;u++){const h=f*t+u,y=h+1,w=h+t,p=w+1;r[d++]=h,r[d++]=w,r[d++]=y,r[d++]=y,r[d++]=w,r[d++]=p}e.indices.offset=d,e.elements.offset=c+l/8}const Kc={symbol:"polygon3d",sinks:{},generate(e,t,n,i,s,r,o,a){let c;i.tileProps.db_centroid_x!==void 0&&i.tileProps.db_centroid_y!==void 0&&!Number.isNaN(i.tileAttrs[i.tileProps.db_centroid_x])&&!Number.isNaN(i.tileAttrs[i.tileProps.db_centroid_y])&&(c=[i.tileAttrs[i.tileProps.db_centroid_x],i.tileAttrs[i.tileProps.db_centroid_y]]),Q.generate(e,t,n,se.top,i,s,r,o,a,c,"fill")}};var xh=(e=>(e[e.none=0]="none",e[e.fadeIn=1]="fadeIn",e[e.fadeOut=-1]="fadeOut",e))(xh||{});function _h({collector:e,generator:t,args:n}){do t(e,...n);while(e.isOverloaded())}const Ph={arrow:Ps,line:Qe,polygon:Nt,embankment:Kc,polygon3d:Kc,metricPoint:go,labelLine:oo,lineExtrusion:cn,polygonExtrusion:On,oneWayLine:ao,dashedLine:on,shiftedLine:kr,circle:Hr,buildingModel:an,gltfModel:Rn,point:Zt,raster:$r,heatmap:di,dem:Mt,mesh:Q,mapMesh:Ui,overpass:bh,tunnel:Ah,simpleMesh:jb,globe:js},Lh={labelLine:oo,oneWayLine:ao,point:Zt};function Hs(e,t){const n=Ph[e];return n?n.sinks[t].stride:0}function Qc(e,t){e.precomputes.forEach((n,i)=>{t.tileData[i]=G(n.expr,t)})}function el(e,t,n,i,s,r,o,a,c,l,d,f,u,h){const y=i.styleState.graphicsPreset?t.graphicsPresets[i.styleState.graphicsPreset]||{}:{};n.forEach(w=>{if(jf(i,[d.x[0],d.y[0]]),!(o!==void 0&&(w.maxzoom<=o||w.minzoom>=o+1&&o!==Gn.maxDetailLevel))&&!(i.tileProps.hovered&&!Number.isNaN(i.tileAttrs[i.tileProps.hovered])&&i.tileAttrs[i.tileProps.hovered]===1&&w.type!=="polygon"&&w.type!=="polygonExtrusion"&&w.type!=="point"&&w.type!=="polygon3d")){Qc(w,i);do switch(w.type){case"line":const p=G(w.style.pattern,i);p&&p[0]!==Jc.None?Qe.generatePatterned(e,t.id,w,i,c,d):Qe.generate(e,t.id,w,i,c,d);break;case"dashedLine":on.generate(e,t.id,w,i,c,d);break;case"shiftedLine":kr.generate(e,t.id,w,i,d);break;case"polygon":Nt.generate(e,t.id,w,i,d,l,t.rasterSets);break;case"polygon3d":case"embankment":Kc.generate(e,t.id,w,i,d,c,l,t.rasterSets);break;case"metricPoint":{go.generate(e,d,l,t,w,i,c);break}case"polygonExtrusion":On.generate(e,t.id,w,i,d,y);break;case"labelLine":J2(e,t.id,w,c.coords,a,i,d);break;case"oneWayLine":K2(e,t.id,w,c.coords,a,i,d);break;case"point":{sh(e,t,w,i,s,r,c.coords,a,d,l,f);break}case"lineExtrusion":cn.generate(e,t.id,w,i,d,y);break;case"arrow":Ps.generate(e,t.id,w,i,d);break;case"heatmap":{di.generate(e,t.id,w,d,i);break}case"gltfModel":{Rn.generateInstances(e,t,w,i,d,c,a,u,h,s,2);break}case"overpass":bh.generate(e,t,w,i,d,c,l,t.rasterSets);break;case"tunnel":Ah.generate(e,t,w,i,d,c,l,t.rasterSets);break}while(e.isOverloaded())}})}function Zb(e,t,n,i,s,r,o,a){const c=Lh[t.type];if(c)do c.processElement(e,n,i,s,r,o,a);while(n.isOverloaded())}function Wb(e,t,n,i,s,r,o){const a=Lh[i.type];a&&a.getLabelingInfo(e,t,n,s,r,o)}class Dh{constructor(t,n={}){this._buffer=t,this.options=Object.assign({},ke.defaultOptions,n)}get isDirty(){return this._buffer.isDirty}set isDirty(t){this._buffer.isDirty=t}bind(t,n,i,s){this._buffer.bind(t,n||this.options,i,s)}replaceData(t){this._buffer.replaceData(t)}commitData(){this._buffer.commitData()}getData(){return this._buffer.getData()}}function Xb(e,t){const n=new Set;return e.forEach(i=>{t.has(i)||n.add(i)}),n}function qb(e,t){if(!e||!t)return e===t;if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function Jb(e,t){const n=new Set;for(const i of t)e.has(i)&&n.add(i);return n}function Kb(e,t){if(!e||!t)return e===t;if(e.size!==t.size)return!1;for(const[n,i]of e)if(!t.has(n)||!qb(i,t.get(n)))return!1;return!0}const tl="default",Qb="floor",eI="dynamicModel";var zi=(e=>(e[e.PolygonExtrusion=1]="PolygonExtrusion",e[e.FloorPolygons=2]="FloorPolygons",e[e.All=3]="All",e))(zi||{});class tI{constructor(t){this.identifier=t,this.tileLayers=[],this.selected=[],this.hidden=new Map,this.parentChildrenMap=new Map,this.childParentMap=new Map,this.parentChildrenMapByTile=new Map,this.selectedIdsByApi=[]}registerTileLayer(t){this.tileLayers.push(t)}unregisterTileLayer(t){this.tileLayers=this.tileLayers.filter(n=>n!==t)}select(t){this.selectedIdsByApi=t.slice(),this.selected=this.getIdsToSelect(t),this.selected.sort();for(const n of this.tileLayers)n.setSelectedIds(this.selected);this.identifier.queryFillCache()}getSelected(){return this.selected}show(t){for(const n of t)this.hidden.delete(n);this.triggerIdUpdate(t)}hide(t,n=3){for(const i of t)this.hidden.set(i,n);this.triggerIdUpdate(t)}isHidden(t,n=3){return(this.hidden.get(t)??0)>=n}getHidden(t=3){const n=new Set;return this.hidden.forEach((i,s)=>{i>=t&&n.add(s)}),n}triggerIdUpdate(t){if(t.length!==0)for(const n of this.tileLayers)n.pushIdsToUpdate(t)}getRelatedChildrenIds(t){const n=new Set;return t.forEach(i=>{const s=this.parentChildrenMap.get(i);s?.size&&s.forEach(n.add,n)}),Array.from(n)}removeParentChildrenData(t){let n=!1;t.forEach(i=>{const s=this.parentChildrenMapByTile.delete(i);!n&&s&&(n=!0)}),n&&this.rebuildMaps()}updateParentChildrenData(t,n){this.updateTileParentChildrenData(t,n)&&(this.addParentChildrenData(n),this.select(this.selectedIdsByApi))}addParentChildrenData(t){t&&t.size&&t.forEach((n,i)=>{const s=this.parentChildrenMap.get(i);s?n.forEach(r=>{s.add(r),this.childParentMap.set(r,i)}):(this.parentChildrenMap.set(i,new Set(n)),n.forEach(r=>{this.childParentMap.set(r,i)}))})}rebuildMaps(){this.parentChildrenMap.clear(),this.childParentMap.clear(),this.parentChildrenMapByTile.forEach(t=>this.addParentChildrenData(t))}updateTileParentChildrenData(t,n){const i=this.parentChildrenMapByTile.get(t);return Kb(i,n)?!1:(i&&i.forEach((s,r)=>{const o=this.parentChildrenMap.get(r);s.forEach(a=>{o?.delete(a),this.childParentMap.delete(a)})}),this.parentChildrenMapByTile.delete(t),n&&this.parentChildrenMapByTile.set(t,n),!0)}getIdsToSelect(t){const n=new Set(t);return t.forEach(i=>{if(this.parentChildrenMap.has(i)){const r=this.parentChildrenMap.get(i);r?.size&&r.forEach(n.add,n)}}),Array.from(n)}}class nl{constructor(t=0){this.index=t,this.keysMap={}}getIndex(){const t=this.index;return this.index+=1,t}getUniqueIndex(t){return this.keysMap[t]===void 0&&(this.keysMap[t]=this.index,this.index+=1),this.keysMap[t]}getIndexedKeys(){return this.keysMap}}function nI(e){const t=iI(e),{groups:n,table:i}=sI(t),s={};for(let o=0;o<i.length;o++){const a=i[o],c=n[o];s[c]={};for(let l=0;l<a.length;l++){const d=n[l];s[c][d]=i[o][l]}}const r=n.reduce((o,a,c)=>(o[a]=c,o),{});return{indexToGroup:n,groupToIndex:r,table:s}}function iI(e){const t=(e.groups||[]).concat(Wa.groups).reduce((i,s)=>(i.includes(s)||i.push(s),i),[]),n=(e.overlay||[]).concat(Wa.overlay).concat(t.reduce((i,s)=>(s===Ln||s===Pn||s===Za||i.push([s,Pn]),i),[])).reduce((i,s)=>{const r=[];for(const o of s)t.includes(o)&&r.push(o);return r.length>1&&i.push(r),s.length===1&&r.length===1&&i.push(r),i},[]);return{groups:t,overlay:n,intersect:Wa.intersect}}function sI(e){const{groups:t,overlay:n,intersect:i}=e,s=t.reduce((o,a,c)=>(o[a]=c,o),{}),r=[];for(let o=0;o<t.length;o++){const a=[];for(let c=0;c<t.length;c++)a.push(!0);r.push(a)}for(let o=0;o<n.length;o++){const a=n[o];for(let c=0;c<a.length;c++)for(let l=c+1;l<a.length;l++){const d=s[a[c]],f=s[a[l]];r[d][f]=!1,r[f][d]=!1}}for(let o=0;o<i.length;o++){const a=i[o];for(let c=0;c<a.length;c++)for(let l=c+1;l<a.length;l++){const d=s[a[c]],f=s[a[l]];r[d][f]=!0,r[f][d]=!0}}return{groups:t,table:r}}const rI={db_id:"id",tech_db_beginning_is_cut:"beginningIsCut",tech_db_ending_is_cut:"endingIsCut",tech_db_previous_point_x:"previousPointX",tech_db_previous_point_y:"previousPointY",tech_db_next_point_x:"nextPointX",tech_db_next_point_y:"nextPointY",tech_db_object_length:"objectLength",tech_db_component_distance_start:"componentDistanceStart",tech_db_component_distance_end:"componentDistanceEnd",tech_db_geometry_type:"db_geometry_type"},oI=e=>rI[e]??e,aI={objectClass:"db_object_class",sublayer:"db_sublayer",db_id:"id"};function cI(e){return aI[e]??e}const lI={Class:"db_class",DisputePosition:"db_dispute_position",ObjectClass:"db_object_class",ParkingType:"db_parking_type",Sublayer:"db_sublayer",Subsublayer:"db_subsublayer",Icon:"db_icon",GeometryType:"db_geometry_type",ModelType:"db_model_type",RoadSupportTypes:"tech_db_road_support_type",RoadMarkingColorType:"db_road_marking_color_type",PoiCategory:"L1_Poi_category",RoadPart:"db_road_part",TriangulationMethod:"db_triangulation_method",RequireAbsZFromReliefSurface:"db_require_abs_z_from_relief_surface",TouristRouteColor:"db_tourist_route_color",TouristRouteSportTrackType:"db_tourist_route_sport_track_type",TouristRouteType:"db_tourist_route_type"},dI=e=>{e.enumerationValues=Object.keys(e.enumerationValues??{}).reduce((t,n)=>{const i=lI[n];return i&&(t[i]=e.enumerationValues[n]),t},{})};class fI{constructor(t,n,i){this.id=t,this.modules=n,this.options=i,this.type="zenith",this.worker=new n.workers.parser.ZenithSource,this.sourceAttrs=wn(i.sourceAttributes??{},af),this.objectAttributes={},this.dataFilter=i.dataFilter}fetchTiles(t,n){const{assetManager:i,map:s}=this.modules,r=t.map(a=>({coords:a,tileUrl:this.constructTileUrl(a,n)}));return this.worker.fetchTiles(r).map((a,c)=>a.catch(()=>Promise.resolve()).then(l=>{if(!l)return;const{metadata:d,err:f}=l;return d.forEach(u=>{const h=this.constructMetaTileUrl(u);i.loadMetatile(h,u.metatileHash,u.regionId),s.emit("tileload",{tileCoords:r[c].coords,regionId:u.regionId}),n.shownRegionIds.add(u.regionId)}),f?.status===403&&s.emit("error",{type:"invalidtilekey"}),d}))}async generateTile(t,n,i,s,r,o={},a,c=this.id,l){const d=await this.worker.generateTile({styleId:i,tileInfo:Je(n),pixelRatio:r,selectedIds:s,styleState:t.styleState,floorsEnabled:t.floorsEnabled,sourceAttrs:this.sourceAttrs,hoverId:a,sourceId:c,isDefaultSource:this.options.isDefaultSource,modelsPath:this.options.modelsPath,promoteAttributes:this.options.promoteAttributes,promoteId:this.options.promoteId,isCustomZenithSource:!this.options.isDefaultSource,dataFilter:this.dataFilter,...o,modelShowHideEventsSublayers:t.modelShowHideEventsSublayers},l);return d.promotedAttrs&&(this.objectAttributes[Ie(n)]=d.promotedAttrs),d}getObjectAttributes(t,n){return this.objectAttributes[t]?.[n]}generateModel(t){return this.worker.generateModel(t)}abortTileFetches(t){const n=t.map(Ie);this.worker.abortTileRequests(n)}deleteTiles(t){const n=t.map(Ie);for(const i of n)this.objectAttributes[i]=void 0;this.worker.deleteTiles(n)}setAttributes(t){this.sourceAttrs=t}getAttributes(){return this.sourceAttrs}destroy(){this.worker.destroy(),this.sourceAttrs={},this.objectAttributes={}}setFeatureStateMap(t){this.worker.setFeatureStateMap(t)}setDataFilter(t){t?this.dataFilter=x(t,{precomputes:[]},Ze.Generator):this.dataFilter=void 0}constructTileUrl(t,n){return Fy(this.options.tileServer,this.options.tileSet,this.options.tileProtocol,this.options.subdomains,t,this.options.tileKey,this.options.appId,n.lang,this.options.tileTemplateUrl,this.options.defaultLang,this.options.sessionId,this.options.dt)}constructMetaTileUrl(t){const n=this.options.metatileTemplateUrl,i={host:this.options.tileServer,tileSet:this.options.tileSet,protocol:this.options.tileProtocol,subdomain:this.options.subdomains[0],hash:nf(t.metatileHash)};return rs(n?{url:n}:"metatile",i)}}const Oh=[{id:"__2gis_comm_poi",type:"point",style:{textFont:["Noto_Sans_Semibold",["step",["zoom"],"Noto_Sans",16,"Noto_Sans"]],iconImage:"peak",iconWidth:["interpolate",["linear"],["zoom"],15,22,16.8,30],textColor:"#3A3A3A",visibility:"visible",textFontSize:[["interpolate",["linear"],["zoom"],15.5,11,18,13],["interpolate",["linear"],["zoom"],15.5,10,18,12]],textHaloColor:"rgba(255,255,255,0.5)",textHaloWidth:.9,iconLabelingGroup:Za,iconLabelingMargin:{leftRight:6,topBottom:6}},filter:["all",["match",["get","db_sublayer"],["Commercial_poi_default","Commercial_poi_city","Commercial_poi_premium"],!0,!1],["any",["==",["in",["get","db_building_id"],["global","_activeFloorBuildingIds"]],!1],["in",["get","db_plan_id"],["global","_activeFloorIds"]]]]}];function uI(e){const t={};let n=0;for(const i in e)t[i]=n,n+=1;return t}let hI=Number.MIN_SAFE_INTEGER;function Ch(){return hI++}const pI=Ch(),mI=Ch(),Fh={NEVER:512,LESS:513,EQUAL:514,LEQUAL:515,GREATER:516,NOTEQUAL:517,GEQUAL:518,ALWAYS:519},yI={FRONT:1028,BACK:1029,FRONT_AND_BACK:1032},gI={ZERO:0,ONE:1,SRC_COLOR:768,ONE_MINUS_SRC_COLOR:769,SRC_ALPHA:770,ONE_MINUS_SRC_ALPHA:771,DST_ALPHA:772,ONE_MINUS_DST_ALPHA:773,DST_COLOR:774,ONE_MINUS_DST_COLOR:775,SRC_ALPHA_SATURATE:776},wI={FUNC_ADD:32774,FUNC_SUBTRACT:32778,FUNC_REVERSE_SUBTRACT:32779,MIN:32775,MAX:32776},Nh="__JAKARTA__DEM__LIGHTING__";class il extends Error{constructor(t){super(`Unknown expression type '${t[0]}' in '${JSON.stringify(t)}'`),this.name="UnknownExpressionTypeError",Object.setPrototypeOf(this,new.target.prototype)}}function x(e,t,n=Ze.Uniform){if(ig(e))return kf(e)?ms(e):e;switch(e[0]){case"coalesce":return OI(e,t,n);case"all":return DI(e,t,n);case"any":return CI(e,t,n);case"match":return vI(e,t,n);case"in":return AI(e,t,n);case"interpolate":return Rh(e,t,n);case"step":return LI(e,t,n);case"featureState":case"get":case"sourceAttr":return Bh(e,t,n);case"objectAttr":return{type:"objectAttr",property:e[1]};case"global":return{type:"global",property:e[1]};case"zoom":return{type:"zoom"};case"distance":return{type:"distance"};case"local-time":return{type:"local-time",offset:x(e[1]||0,t,n)};case"utc-time":return{type:"utc-time",offset:x(e[1]||0,t,n)};case"time":return FI(e,t,n);case"schedule":return NI(e,t,n);case"height":return{type:"height"};case"heatmap-density":return{type:"heatmap-density"};case"shading-intensity":return{type:"shading-intensity"};case"to-boolean":case"to-color":case"!":case"log10":case"mappoints-to-meters":case"meters-to-pixels":return bI(e,t,n);case"uint64":return x(e[1],t,n);case"==":case"!=":case"<":case"<=":case">":case">=":return II(e,t,n);case"+":return MI(e,t,n);case"*":return TI(e,t,n);case"^":return SI(e,t,n);case"random":return RI(e,t,n);case"literal":return Array.isArray(e[1])?BI(e,t,n):typeof e[1]=="object"&&e[1]!==null?kI(e):e[1];case"isBehindObjects":return{type:"isBehindObjects"};case"geometry-modifier":const i=[];return e.slice(1).forEach(s=>{const r=UI(s);r&&i.push(r)}),{type:"geometry-modifier",modifiers:i};case"pattern":return{type:"line-pattern",patternType:Eh(e[1]),parameters:e.slice(2).map(s=>x(s,t,n))};case"precompute":{if(!t)throw new il(e);const s=t.precomputes.length;return t.precomputes.push({expr:x(e[1],void 0,n),usage:n}),{type:"precompute",precomputeIndex:s}}case"gltf-animation":return EI(e,t,n);case"texture-animation":return xI(e,t,n);case"easing":return _I(e);case"mix":return PI(e,t,n);case"readFromTarget":return{type:"readFromTarget",name:e[1]};case"vertexAttribute":return{type:"vertexAttribute",name:e[1]};default:throw new il(e)}}function kn(e,t,n=Ze.Uniform){return Qt(e)||Array.isArray(e)&&e.length===0?e:x(e,t,n)}function pi(e,t,n){return e===void 0?e:x(e,t,n)}function vI(e,t,n){const i={type:"match",input:x(e[1],t,n),cases:[],defaultOutput:x(e[e.length-1],t,n)},s=e.slice(2,-1);for(let r=0;r<s.length;r+=2){const o=s[r].reduce((c,l)=>{typeof l=="boolean"&&c.push(Number(l));const d=x(l,t,n);return Nf(d)?c.push(d):console.warn("MatchExpression supports only simple types: string, number, boolean or null",l),c},[]),a={values:new Set(o),output:x(s[r+1],t,n)};i.cases.push(a)}return i}function Rh(e,t,n){const i={type:"interpolate",base:1,argument:x(e[2],t,n),steps:[]};e[1][0]==="exponential"&&e[1][1]!==void 0&&(i.base=e[1][1]);const s=e.slice(3);for(let r=0;r<s.length;r+=2){const o={key:x(s[r],t,n),value:x(s[r+1],t,n)};i.steps.push(o)}return i}function bI(e,t,n){return{type:e[0],value:x(e[1],t,n)}}function II(e,t,n){const i=x(e[1],t,n),s=x(e[2],t,n);return{type:e[0],leftValue:i,rightValue:s}}function MI(e,t,n){return{type:"+",array:e.slice(1).map(i=>x(i,t,n))}}function TI(e,t,n){return{type:"*",array:e.slice(1).map(i=>x(i,t,n))}}function SI(e,t,n){const i=x(e[1],t,n),s=x(e[2],t,n);return{type:"^",base:i,exponent:s}}function AI(e,t,n){const i=x(e[1],t,n),s=e[2][0];if(s!=="get"&&s!=="global"&&s!=="sourceAttr"&&s!=="literal")throw new Error("InExpression supports only the get, global, source attr and literal expressions as a second argument");const r=x(e[2],t,n);return{type:"in",item:i,collection:r}}function EI(e,t,n){const i={type:"gltf-animation",options:[]},s=e.slice(1);for(let r=0;r<s.length;r++)i.options.push(x(s[r],t,n));return i}function xI(e,t,n){const i={type:"texture-animation",options:[]},s=e.slice(1);for(let r=0;r<s.length;r++)i.options.push(x(s[r],t,n));return i}function _I(e){const t={type:"easing",options:["linear"]},n=e.slice(1),i=n.slice(1);try{switch(n[0]){case"cubic-bezier":{if(i.length!==4||i.some(s=>typeof s!="number"))throw new Error;t.options=[n[0],...i];break}case"exponential":{if(i.length!==1||typeof i[0]!="number"||i[0]===1||i[0]<=0)throw new Error;t.options=[n[0],i[0]];break}case"ease":case"ease-in":case"ease-out":case"ease-in-out":case"linear":{t.options[0]=n[0];break}default:throw new Error}}catch{console.warn("Invalid texture animation easing expression:",e),console.warn('Fallback to ["easing", "linear"].')}return t}function PI(e,t,n){const i=e.slice(1),s=x(i[2],t,n);if(s.type==="interpolate"){const{argument:r}=s;return s.argument.type==="readFromTarget"?{type:"mix",value1:x(i[0],t,n),value2:x(i[1],t,n),factor:r,factorInterpolate:s}:(console.warn(`Unknown expression in mix < interpolation chain: ${JSON.stringify(r)}`),null)}else return{type:"mix",value1:x(i[0],t,n),value2:x(i[1],t,n),factor:s}}function LI(e,t,n){const i={type:"step",steps:[],value:x(e[1],t,n)},s={key:0,value:x(e[2],t,n)};i.steps.push(s);const r=e.slice(3);for(let o=0;o<r.length;o+=2){const a={key:r[o],value:x(r[o+1],t,n)};i.steps.push(a)}return i}function Bh(e,t,n){const i=e[0],s=cI(e[1]),r={type:i,property:s};if(n!==Ze.Generator&&t){const o=t.precomputes.length??NaN;return t.precomputes.push({expr:r,usage:n}),s==="selected"&&"selectedIdx"in t&&(t.selectedIdx=o),{type:"precompute",precomputeIndex:o}}else return r}function DI(e,t,n){return{type:"all",array:e.slice(1).map(i=>x(i,t,n))}}function OI(e,t,n){return{type:"coalesce",array:e.slice(1).map(i=>{try{return x(i,t,n)}catch(s){return console.debug(`Unknown expression in coalesce: ${s}`),null}})}}function CI(e,t,n){return{type:"any",array:e.slice(1).map(i=>x(i,t,n))}}function FI(e,t,n){return{type:"time",timeSource:x(e[1],t,n),format:e[2]}}function NI(e,t,n){return{type:"schedule",time:x(e[1],t,n),steps:x(e[2],t,n),detailResult:e[3]}}function RI(e,t,n){const i=x(e[1],t,n),s=x(e[2],t,n);return{type:"random",start:i,end:s}}function BI(e,t,n){return{type:"literalArray",array:e[1].map(i=>x(i,t,n))}}function kI(e){return{type:"literalObject",object:{type:"object",value:e[1]}}}function UI(e){if(!(e===void 0||!Array.isArray(e)))switch(e[0]){case"line-to-zigzag":return{type:"zigzag-modifier",step:e[1],width:e[2],stopLines:Number(e[3])};case"to-points":return{type:"to-points-modifier",modelLength:e[1],edgeMarging:e[2]}}}function zI(e){return e?e.map(t=>{const n=t.wallPadding??0,i=t.texturePadding??0,s=t.sliceSize,r={image:t.image,minWallHeight:t.minWallHeight??0,wallPadding:Array.isArray(n)?n:[n,n,n,n],texturePadding:Array.isArray(i)?i:[i,i,i,i],sliceSize:s?Array.isArray(s)?s:[s,s]:Array.isArray(t.size)?t.size:[t.size,t.size],vertical:{mode:t.vertical?.mode??"stripe-top",slicesCount:t.vertical?.slicesCount??1,minSliceRepeats:t.vertical?.minSliceRepeats??1,minResizeFactor:t.vertical?.minResizeFactor??0,maxResizeFactor:t.vertical?.maxResizeFactor??9999,maxInterval:t.vertical?.maxInterval??0},horizontal:{mode:t.horizontal?.mode??"repeat-with-stretch",slicesCount:t.horizontal?.slicesCount??1,minSliceRepeats:t.horizontal?.minSliceRepeats??1,minResizeFactor:t.horizontal?.minResizeFactor??0,maxResizeFactor:t.horizontal?.maxResizeFactor??9999,maxInterval:t.horizontal?.maxInterval??0}};return r.sliceSize[0]<=0||r.sliceSize[1]<=0?null:r}).filter(t=>t!==null):[]}function GI(e,t){let n=0;function i(s,r){s.type!=="custom"&&Dv(s.filter)&&(n=r)}return e.forEach((s,r)=>{s.type==="group"?s.layers.forEach(o=>i(o,r)):i(s,r)}),t.forEach(s=>{s.type==="point"&&(s.style.iconPriority=Number.MAX_SAFE_INTEGER)}),[...e.slice(0,n+1),...t,...e.slice(n+1)]}function jI(e,t,n){const i=rl(e.terrain??{}),s=jh(e.environment??{}),r=Hh(e.light,i),o=$I(e.graphicsPresets),a={id:t,revision:0,background:{color:ms(e.background?.color??Yg)},light:r,layers:[],layersById:{[Is]:i,[lc]:s},layerIdToInnerId:{},groupsById:{},iconBaseUrl:"",fontUrlTemplate:"",modelsBaseUrl:"",fonts:qs,fontNameToIndex:Pu(qs),rasterSets:{byIndex:{},byKey:{}},icons:e.icons||{},models:Object.values(e.models??{}),modelIndex:uI(e.models||{}),labelingGroups:nI(e.labelingGroups??{}),dem:i,graphicsPresets:o,environment:s,targets:{_TMP_SHORELINE_GRADIENT:{channels:{r:!0},title:"Градиент береговой линии"}}},c=new nl;let l=e.layers??[];n&&(l=GI(e.layers??[],Oh));for(const d of l){const f=kh(d);if(!f)continue;f.type==="group"&&(a.groupsById[f.innerId]=f,a.layerIdToInnerId[f.id]=f.innerId),(f.type==="group"?f.layers:[f]).forEach(h=>{const y=h.lightingMode??r.defaultLightMode;r.lightingModes[y]||console.warn(`Не найден режим освещения ${y} для слоя ${h.type}. Будет использован режим освещения по умолчанию.`),a.layers.push(h),a.layersById[h.innerId]=h,a.layerIdToInnerId[h.id]=h.innerId,(h.type==="point"||h.type==="polygon"||h.type==="metricPoint"||h.type==="embankment"||h.type==="polygon3d")&&Uh(h,c,a.icons).forEach(g=>{a.rasterSets.byKey[g.key]||(a.rasterSets.byIndex[g.index]=g,a.rasterSets.byKey[g.key]=g)})})}return a}function kh(e){return e.type==="group"?VI(e):Io(e)}function Uh(e,t,n){const i=[];return Gh(e).forEach(({image:s,imageType:r,anchor:o})=>{s&&ii(s).forEach(a=>{typeof a!="string"||!a.length||i.push(zh(a,r,t,o,n))})}),i}function zh(e,t,n,i,s){const r=t==="icon"?Li(e,i[0],i[1]):_r(e);return{type:li.Static,index:n.getUniqueIndex(r),key:r,isSvg:Ov(s[e]),name:e,fileName:e,anchorX:i[0],anchorY:i[1],rasters:[]}}function Gh(e){if(e.type==="point"){const n=Ye(e.style.iconAnchor);return[{image:e.style.iconImage,imageType:"icon",anchor:n}]}if(e.type==="metricPoint")return[{image:e.style.iconImage,imageType:"texture",anchor:[0,0]}];const t=[{image:e.style.textureImage,imageType:"texture",anchor:[0,0]}];return e.type==="polygon"&&t.push({image:e.style.normalMapTextureImage,imageType:"texture",anchor:[0,0]}),t}const sl=new nl;function HI(e,t){return e.type==="appearance"?{type:e.type,tipMovementAmplitude:x(e.tipMovementAmplitude,t)}:e.type==="repeat"?{type:e.type,tipMovementAmplitude:x(e.tipMovementAmplitude,t),iterationCount:e.iterationCount}:e}function Io(e,t){if(e.type==="custom")return{type:"custom",id:e.id,innerId:bs(),renderIndex:sl.getIndex(),filter:!1,minzoom:-1/0,maxzoom:1/0,precomputes:[],style:{}};if(!e.style||e.style.visibility==="none")return;let n;try{const i={id:e.id,innerId:bs(),renderIndex:sl.getIndex(),filter:x(e.filter||!1,void 0),minzoom:Vh(e.minzoom,-1/0),maxzoom:Vh(e.maxzoom,1/0),precomputes:t?t.precomputes.slice(0):[],gpuState:e.gpuState,lightingMode:e.lightingMode,castShadows:e.castShadows??!0,receiveShadows:e.receiveShadows??!0,drawToTarget:e.drawToTarget};switch(e.type){case"line":{const s=xg(e.style);n={...i,type:e.type,interactive:e.interactive??!0,ignoreTier:x(e.ignoreTier??!1,i),style:{visibility:Be(s.visibility),color:x(s.color,i),width:x(s.width,i),shift:x(s.shift,i),pattern:x(s.pattern,i),startCap:x(s.startCap,i),endCap:x(s.endCap,i),geometryModifier:x(s.geometryModifier,i),mode:s.mode,lengthUnits:YI(e.style.pattern)}};break}case"lineExtrusion":{const s=Pg(e.style);n={...i,type:e.type,style:{visibility:Be(s.visibility),sideColor:x(s.sideColor,i),strokeWidth:x(s.strokeWidth,i),strokeColor:x(s.strokeColor,i),sideStrokeColor:x(s.sideStrokeColor,i),height:x(s.height,i),nearCameraFade:x(s.nearCameraFade,i)}};break}case"polygon":{const s=Tg(e.style),r=Vs(s.textureSize)?Yh(s.textureSize):s.textureSize,o=Vs(s.normalMapTextureSize)?Yh(s.normalMapTextureSize):s.normalMapTextureSize;i.drawToTarget==="_TMP_SHORELINE_GRADIENT"&&(s.strokeWidth=0,s.strokeColor="#00000000",s.color=["mix","#000000","#FF0000",["vertexAttribute","denormalized_distance_to_line"]]),n={...i,type:e.type,interactive:e.interactive??!0,ignoreTier:x(e.ignoreTier??!1,i),style:{visibility:Be(s.visibility),color:x(s.color,i),textureImage:x(s.textureImage,i),textureSize:kn(r,i),textureOpacity:x(s.textureOpacity,i),strokeColor:x(s.strokeColor,i),strokeWidth:x(s.strokeWidth,i),lengthUnits:$h(s.textureSize),metallic:x(s.metallic,i),roughness:x(s.roughness,i),normalMapTextureImage:x(s.normalMapTextureImage,i),normalMapTextureSize:kn(o,i),normalMapTextureAnimation:x(s.normalMapTextureAnimation,i),normalMapTextureLengthUnits:$h(s.normalMapTextureSize)}};break}case"polygon3d":case"embankment":{const s=Sg(e.style),r=e.type==="polygon3d"?{depthFunc:Fh.LEQUAL}:{};n={...i,type:e.type,interactive:e.interactive??!0,style:{visibility:Be(s.visibility),color:x(s.color,i),textureImage:x(s.textureImage,i),textureSize:kn(s.textureSize,i),textureOpacity:x(s.textureOpacity,i),strokeColor:x(s.strokeColor,i),strokeWidth:x(s.strokeWidth,i),nearCameraFade:x(s.nearCameraFade,i),elevation:x(s.elevation,i)},gpuState:{...r,...i.gpuState}},e.type==="polygon3d"&&(n.interactiveOcclusion=e.interactiveOcclusion??!0);break}case"metricPoint":{const s=Ag(e.style);n={...i,type:e.type,interactive:e.interactive??!0,ignoreTier:x(e.ignoreTier??!1,i),style:{visibility:Be(s.visibility),iconImage:x(s.iconImage,i),color:x(s.color,i),rotation:x(s.rotation,i),width:x(s.width,i),height:x(s.height,i)}};break}case"polygonExtrusion":{const s=Eg(e.style);n={...i,type:e.type,interactive:e.interactive??!0,sideTextureIndices:[],style:{visibility:Be(s.visibility),topColor:x(s.topColor,i),sideColor:x(s.sideColor,i),strokeColor:x(s.strokeColor,i),strokeWidth:x(s.strokeWidth,i),sideStrokeColor:x(s.sideStrokeColor,i),height:x(s.height,i,Ze.Generator),nearCameraFade:x(s.nearCameraFade,i),sideTextures:zI(s.sideTextures)}};break}case"dashedLine":{const s=Og(e.style);n={...i,type:e.type,interactive:e.interactive??!0,ignoreTier:x(e.ignoreTier??!1,i),style:{visibility:Be(s.visibility),color:x(s.color,i),gapColor:x(s.gapColor,i),width:x(s.width,i),shift:x(s.shift,i),gapLength:x(s.gapLength,i),dashLength:x(s.dashLength,i),gapTurnsOnly:s.gapTurnsOnly,geometryModifier:x(s.geometryModifier,i),mode:s.mode}};break}case"shiftedLine":{const s=Cg(e.style);n={...i,type:e.type,interactive:e.interactive??!0,ignoreTier:x(e.ignoreTier??!1,i),style:{visibility:Be(s.visibility),color:x(s.color,i),width:x(s.width,i),shift:x(s.shift,i)}};break}case"oneWayLine":{const s=Dg(e.style);n={...i,type:e.type,ignoreTier:x(e.ignoreTier??!1,i),interactive:e.interactive??!1,style:{visibility:Be(s.visibility),color:x(s.color,i),lineWidth:x(s.lineWidth,i),lineLength:x(s.lineLength,i),tipWidth:s.tipWidth,tipHeight:s.tipHeight,roundingRadius:x(s.roundingRadius,i),priority:s.priority,duplicationSpacing:x(s.duplicationSpacing,i),endingOffsets:s.endingOffsets,labelingGroup:s.labelingGroup}};break}case"buildingModel":{const s=_g(e.style);n={...i,type:e.type,interactive:e.interactive??!0,style:{visibility:Be(s.visibility),color:x(s.color,i),strokeColor:x(s.strokeColor,i),strokeWidth:x(s.strokeWidth,i),nearCameraFade:x(s.nearCameraFade,i)}};break}case"labelLine":{const s=Lg(e.style);n={...i,type:e.type,interactive:e.interactive??!1,ignoreTier:x(e.ignoreTier??!1,i),style:{visibility:Be(s.visibility),textField:x(s.textField,i,Ze.Labeling),textFont:s.textFont,textColor:x(s.textColor,i),textFontSize:x(s.textFontSize,i),textLetterSpacing:s.textLetterSpacing,textHaloColor:x(s.textHaloColor,i),textHaloWidth:s.textHaloWidth,textPriority:x(s.textPriority,i),textLabelingSideMargin:s.textLabelingSideMargin,textDuplicationSpacing:x(s.textDuplicationSpacing,i),labelingGroup:s.labelingGroup,lineEndingOffsets:s.lineEndingOffsets}};break}case"point":{const s=Ng(e.style);n={...i,type:e.type,interactive:e.interactive??!0,style:{visibility:Be(s.visibility),allowOverlap:s.allowOverlap,allowElevation:s.allowElevation,elevation:x(s.elevation,i),iconImage:x(s.iconImage,i),iconAnchor:kn(s.iconAnchor,i),iconOffset:kn(s.iconOffset,i),iconWidth:x(s.iconWidth,i),iconTextField:x(s.iconTextField,i,Ze.Labeling),iconTextFont:pi(s.iconTextFont,i),iconTextAnchor:kn(s.iconTextAnchor,i),iconTextOffset:kn(s.iconTextOffset,i),iconTextColor:x(s.iconTextColor,i),iconTextFontSize:x(s.iconTextFontSize,i),iconTextLineHeight:s.iconTextLineHeight,iconTextLetterSpacing:s.iconTextLetterSpacing,iconTextPadding:kn(s.iconTextPadding,i),iconTextHaloWidth:ps(ze(s.iconTextHaloWidth)),iconTextHaloColor:x(s.iconTextHaloColor,i),iconOpacity:x(s.iconOpacity,i),iconPriority:x(s.iconPriority,i),iconLabelingMargin:s.iconLabelingMargin,iconLabelingGroup:s.iconLabelingGroup,iconRotation:x(s.iconRotation,i),textField:x(ze(s.textField),i,Ze.Labeling),textFont:x(ze(s.textFont),i),textColor:x(ze(s.textColor),i),textFontSize:x(ze(s.textFontSize),i),textLineHeight:ps(ze(s.textLineHeight),1.2),textLetterSpacing:ps(ze(s.textLetterSpacing)),textField2:pi(en(s.textField),i,Ze.Labeling),textFont2:pi(en(s.textFont),i),textColor2:pi(en(s.textColor),i)||x(ze(s.textColor),i),textFontSize2:pi(en(s.textFontSize),i)||x(ze(s.textFontSize),i),textMaxLengthPerLine:s.textMaxLengthPerLine,textPlacement:x(s.textPlacement,i),textPriority:x(s.textPriority,i),textOffset:x(ze(s.textOffset),i),textOffset2:pi(en(s.textOffset),i),textHaloColor:x(ze(s.textHaloColor),i),textHaloColor2:pi(en(s.textHaloColor),i)||x(ze(s.textHaloColor),i),textHaloWidth:ps(ze(s.textHaloWidth)),textHaloWidth2:ps(en(s.textHaloWidth)||ze(s.textHaloWidth)),textLabelingMargin:ze(s.textLabelingMargin),textLabelingMargin2:en(s.textLabelingMargin)||ze(s.textLabelingMargin),textLabelingGroup:ze(s.textLabelingGroup),textLabelingGroup2:en(s.textLabelingGroup)||ze(s.textLabelingGroup),duplicationSpacing:x(s.duplicationSpacing,i),endingOffsets:s.endingOffsets}};break}case"arrow":{const s=Rg(e.style);n={...i,type:e.type,interactive:!1,ignoreTier:x(e.ignoreTier??!1,i),style:{visibility:Be(s.visibility),color:x(s.color,i),strokeColor:x(s.strokeColor,i),lineWidth:x(s.lineWidth,i),strokeWidth:x(s.strokeWidth,i),tipWidth:x(s.tipWidth,i),tipHeight:x(s.tipHeight,i),roundingRadius:x(s.roundingRadius,i),animation:HI(s.animation,i)}};break}case"raster":{const s=Bg(e.style);n={...i,type:e.type,ignoreTier:x(e.ignoreTier??!1,i),style:{visibility:Be(s.visibility),opacity:x(s.opacity,i)}};break}case"circle":{const s=Fg(e.style);n={...i,type:e.type,interactive:e.interactive??!0,style:{visibility:Be(s.visibility),color:x(s.color,i),strokeColor:x(s.strokeColor,i),strokeColor2:x(s.strokeColor2,i),width:x(s.width,i),strokeWidth:x(s.strokeWidth,i),strokeWidth2:x(s.strokeWidth2,i)}};break}case"heatmap":{const s=kg(e.style);n={...i,type:e.type,style:{visibility:Be(s.visibility),color:x(s.color,i),radius:x(s.radius,i),opacity:x(s.opacity,i),intensity:x(s.intensity,i),weight:x(s.weight,i),downscale:s.downscale},framebufferId:{framebuffer:Lr}};break}case"model":{const s=zg(e.style);n={...i,interactive:e.interactive??!0,interactiveOcclusion:e.interactiveOcclusion??!0,type:"gltfModel",style:{visibility:Be(s.visibility),modelSrc:x(s.modelSrc,i),offset:x(s.offset,i,Ze.Generator),scale:x(s.scale,i,Ze.Generator),rotation:x(s.rotation,i,Ze.Generator),scene:x(s.scene,i),color:x(s.color,i),linkedIds:x(s.linkedIds,i),colorTextureUvIndex:s.colorTextureUvIndex,roughness:s.roughness,metallic:s.metallic,preventObjectsHiding:s.preventObjectsHiding,nearCameraFade:x(s.nearCameraFade,i),ignoreGlobalLighting:s.ignoreGlobalLighting,showRatio:x(s.showRatio,i),lightingModel:s.lightingModel,playAnimation:x(s.playAnimation,i),geometryModifier:x(s.geometryModifier,i)}};break}case"overpass":{const s=Gg(e.style);n={...i,type:e.type,style:{visibility:Be(s.visibility),debug:s.debug,sideColor:x(s.sideColor,i),bottomColor:x(s.bottomColor,i),topColor:x(s.borderTopColor,i),strokeColor:x(s.strokeColor,i),strokeWidth:x(s.strokeWidth,i),thickness:x(s.thickness,i),borderHeight:x(s.borderHeight,i),borderWidth:x(s.borderWidth,i),color:x(s.color,i),nearCameraFade:x(s.nearCameraFade,i),tunnelHeight:x(s.tunnelHeight,i)}};break}case"tunnel":{const s=jg(e.style);n={...i,type:e.type,style:{visibility:Be(s.visibility),sideColor:x(s.sideColor,i),bottomColor:x(s.bottomColor,i),topColor:x(s.topColor,i),strokeColor:x(s.strokeColor,i),strokeWidth:x(s.strokeWidth,i),color:x(s.color,i),nearCameraFade:x(s.nearCameraFade,i)}};break}}}catch(i){if(i instanceof il){console.warn(`Problem with layer #${e.id}: ${i}`);return}throw i}return n}function VI(e){const t={id:e.id,innerId:bs(),renderIndex:sl.getIndex(),type:e.type,layers:[],orderBy:[],precomputes:[]};return t.orderBy=e.orderBy?.map(n=>Bh(n,t,Ze.Uniform))??[],e.layers.forEach((n,i)=>{const s=Io(n,t);s&&(s.groupId=t.innerId,s.groupIndex=i,s.renderIndex=t.renderIndex,t.layers.push(s))}),t}function rl(e){const t=Ug(e),n={id:"dem",type:"dem",innerId:Is,filter:!0,precomputes:[],minzoom:-1/0,maxzoom:1/0,renderIndex:pI,style:{},framebufferId:{hillshade:Lr,flatBottom:Lr},lightingMode:Nh};return n.style={visibility:"visible",lightingDirection:typeof t.lightingDirection<"u"?x(t.lightingDirection,n):null,shadingIntensity:x(t.shadingIntensity,n),shadingPalette:Rh(t.shadingPalette,n),verticalScale:x(t.verticalScale,n)},n}function jh(e){const t=Hg(e),n={id:"sky",type:"custom",innerId:lc,filter:!0,precomputes:[],minzoom:-1/0,maxzoom:1/0,renderIndex:mI,style:{}};return n.style={visibility:"visible",skyColor:x(t.skyColor,n),fogColor:x(t.fogColor,n),starsIntensity:x(t.starsIntensity,n)},n}function Hh(e,t){const n=Vg(e),i={},s={ambientColor:{type:"color",value:[255,255,255,255]},ambientIntensity:0,dir1Color:{type:"color",value:[255,255,255,255]},dir1Altitude:0,dir1Azimuth:0,dir1Intensity:0,dir2Color:{type:"color",value:[255,255,255,255]},dir2Altitude:0,dir2Azimuth:0,dir2Intensity:0,shadowRadius:n.shadows?.radius};for(const r in n.lightingModes){const o={ambientColor:{type:"color",value:[255,255,255,255]},ambientIntensity:0,dir1Color:{type:"color",value:[255,255,255,255]},dir1Altitude:0,dir1Azimuth:0,dir1Intensity:0,dir2Color:{type:"color",value:[255,255,255,255]},dir2Altitude:0,dir2Azimuth:0,dir2Intensity:0,shadowRadius:n.shadows?.radius},a=n.lightingModes[r].map(d=>n.sources[d]).filter(Boolean),c=n.shadows?n.sources[n.shadows.source]:void 0;let l=0;a.forEach(d=>{d.color||(d.color="#FFFFFF"),d.type==="ambient"?(o.ambientColor=x(d.color,void 0),o.ambientIntensity=x(d.intensity,void 0),r===n.defaultLightingMode&&(s.ambientColor=o.ambientColor,s.ambientIntensity=o.ambientIntensity)):d.type==="directional"&&(d===c&&(o.shadowLightIndex=l),l===0?(l++,o.dir1Color=x(d.color,void 0),o.dir1Altitude=x(d.altitude,void 0),o.dir1Azimuth=x(d.azimuth,void 0),o.dir1Intensity=x(d.intensity,void 0),r===n.defaultLightingMode&&(s.dir1Color=o.dir1Color,s.dir1Intensity=o.dir1Intensity,s.dir1Azimuth=t.style.lightingDirection===null?o.dir1Azimuth:t.style.lightingDirection,s.dir1Intensity=x(d.intensity,void 0),s.dir1Altitude=o.dir1Altitude)):l===1&&(l++,o.dir2Color=x(d.color,void 0),o.dir2Altitude=x(d.altitude,void 0),o.dir2Azimuth=x(d.azimuth,void 0),o.dir2Intensity=x(d.intensity,void 0)))}),i[r]=o}return i[Nh]=s,{defaultLightMode:n.defaultLightingMode,lightingModes:i}}function $I(e){return $g(e)}function Vh(e,t){return typeof e=="number"&&!Number.isNaN(e)?e:t}function YI(e){return e&&Vs(e[2])?_n.Meters:_n.Pixels}function $h(e){return Vs(e)?_n.Meters:_n.Pixels}function Vs(e,t=!1){return Array.isArray(e)&&(e[0]==="meters-to-pixels"||e[0]==="literal"&&!t&&Array.isArray(e[1])&&e[1].some(n=>Vs(n,!0)))}function Yh(e){if(Array.isArray(e)){if(e[0]==="meters-to-pixels"){if(typeof e[1]=="number"&&!Number.isNaN(e[1]))return e[1]}else if(e[0]==="literal"&&Array.isArray(e[1])){const[t,n]=e[1];if([t,n].every(i=>Array.isArray(i)&&i[0]==="meters-to-pixels"&&typeof i[1]=="number"&&!Number.isNaN(i[1])))return[t[1],n[1]]}}return console.warn(`Can't extract meter-to-pixels values from expression ${JSON.stringify(e)}. Size set to 0.`),0}function Be(e){return e==="none"?"hidden":e}const Mo=0,ZI=1,WI={type:li.Loaded,index:-1,key:Li("",.5,.5),isSvg:!1,name:"",fileName:"",rasters:[]},XI=["default","marker","markerText","htmlLabel"],qI={default:0,marker:1,markerText:2,htmlLabel:3,pointLabel:4},JI={default:{default:!0,marker:!1,markerText:!0,htmlLabel:!0,pointLabel:!1},marker:{default:!1,marker:!1,markerText:!0,htmlLabel:!1,pointLabel:!1},markerText:{default:!0,marker:!0,markerText:!0,htmlLabel:!1,pointLabel:!1},htmlLabel:{default:!0,marker:!1,markerText:!1,htmlLabel:!1,pointLabel:!1},pointLabel:{default:!1,marker:!1,markerText:!1,htmlLabel:!1,pointLabel:!0}};function Zh(e){const t=[],n=Object.keys(Xn).length;for(let i=0;i<n;i++)t[i]=NaN;for(const i in e){if(Xn[i]===void 0)throw new Error(`No such tile prop '${i}'`);t[Xn[i]]=e[i]}return t}class KI{constructor(){this.needRenderIndexRebuild=!1,this.style={id:Mo,revision:0,background:{color:ms("#f6f2de")},light:{defaultLightMode:"global",lightingModes:{}},layers:[],layersById:{},layerIdToInnerId:{},groupsById:{},iconBaseUrl:"",fontUrlTemplate:"",modelsBaseUrl:"",rasterSets:{byIndex:{},byKey:{}},labelingGroups:{indexToGroup:XI,groupToIndex:qI,table:JI},fonts:qs,fontNameToIndex:Pu(qs),icons:{},models:[],modelIndex:{},dem:rl({}),environment:jh({}),graphicsPresets:{light:{},normal:{},immersive:{}},targets:{}},this.zIndexById={};const t=Io({type:"line",id:"debug-tile-bounds",minzoom:-1/0,maxzoom:1/0,style:{color:"#ff0000",width:1}});t&&this.addLayer(t,0)}get hasDynamicObjects(){return this.style.layers.length>1}getRenderIndexById(t){return this.style.layersById[t]?.renderIndex||0}getStyle(){return this.style}appendRasterSet(t,n){this.style.rasterSets.byIndex[t.index]=t,n!==void 0&&(this.style.rasterSets.byKey[n]=t)}removeRasterSet(t){this.style.rasterSets.byIndex[t]=WI}getLabelingGroupIndex(t){const{groupToIndex:n}=this.style.labelingGroups;return n[t]!==void 0?n[t]:n.default}addLayer(t,n){this.style.layersById[t.innerId]||(this.style.layers.push(t),this.style.layersById[t.innerId]=t,n!==void 0&&(this.zIndexById[t.innerId]=n),this.needRenderIndexRebuild=!0)}removeLayer(t){const n=this.style.layersById[t];if(!n)return;const i=this.style.layers.indexOf(n);i!==-1&&this.style.layers.splice(i,1),delete this.style.layersById[t],delete this.zIndexById[t]}updateLayerStyle(t,{style:n,precomputes:i}){const s=this.style.layersById[t];s&&(s.style=n,s.precomputes=i)}update(){this.needRenderIndexRebuild&&(this.rebuildRenderIndex(),this.needRenderIndexRebuild=!1)}rebuildRenderIndex(){this.style.layers.sort((t,n)=>{const i=this.zIndexById[t.innerId]??0,s=this.zIndexById[n.innerId]??0;return i-s});for(let t=0;t<this.style.layers.length;t++)this.style.layers[t].renderIndex=t}}function QI(e,t,n){const i="identify-scene",s=document.getElementById(i),r=parseInt(qo.sceneOpacity.toString(),10);if(r===0){s&&s.parentNode&&s.parentNode.removeChild(s);return}const o=t[0],a=t[1],c=document.createElement("canvas");c.id=i,c.width=o,c.height=a;const l=c.style;l.imageRendering="pixelated",l.pointerEvents="none",l.position="absolute",l.width=n.size[0]+"px",l.height=n.size[1]+"px",l.top=`${n.viewport.top}px`,l.left=`${n.viewport.left}px`;const d=c.getContext("2d");d.clearRect(0,0,o,a);const f=d.createImageData(o,a);for(let u=0;u<o;u++)for(let h=0;h<a;h++)for(let y=0;y<4;y++){const w=(u+h*o)*4+y,p=(u+(a-1-h)*o)*4+y;f.data[w]=y===3?r:e[p]}d.putImageData(f,0,0),s&&s.parentNode?s.parentNode.replaceChild(c,s):document.body.appendChild(c)}function Wh(e,t,n){const s=ne,r={x:new Uint16Array([0,s,s,0,0]),y:new Uint16Array([0,0,s,s,0])},o=Zh({}),a=ws(n,Ea,Xn,o,of);_h({collector:e,generator:Qe.generate,args:[Mo,t,a,Je([0,0,0,0]),r]})}function Xh(){try{return!!localStorage.getItem("debugStatusCompile")}catch(e){return console.warn("Error accessing localStorage in forceGlStatusCheck:",e),!1}}const ol={defines:[],hash:""},mi=class mi{constructor(t,n,i=ol,s=ol){this.shader=null,this.type=t==="vertex"?mi.Vertex:mi.Fragment,this.sourceCode=n,this.commonDefinitions=i,this.definitions=s}static createShaderDefinitions(t){return{defines:t,hash:t.map(i=>`${i.type}:${i.value??""}`).join("")}}get(t){return this.shader||this.compile(t),this.shader}remove(t){this.shader&&(t.deleteShader(this.shader),this.shader=null)}getCode(){return this.assembleShaderText().slice()}compile(t){const n=this.type===mi.Vertex?t.VERTEX_SHADER:t.FRAGMENT_SHADER,i=this.shader=t.createShader(n);if(!i||t.isContextLost())throw new Error(`[WebGl] Failed to create shader. Shader is null: ${String(!i)}. Context is lost: ${String(t.isContextLost())}`);const s=this.assembleShaderText();if(t.shaderSource(i,s),t.compileShader(i),Xh()&&!t.getShaderParameter(i,t.COMPILE_STATUS)){const r=t.getShaderInfoLog(i),o=(s||"").split(`
`);throw new Error(r?r.replace(/^ERROR:\s*(\d+):(\d+):\s*(.*?)\n/,function(a,c,l,d){const f=o[Number(l)-1];return f?`ERROR ${c}:${l}: ${d}
Erroneous line: <<${f}>>
`:a}):"Unknown shader compilation error")}}assembleShaderText(){const t=this.sourceCode,n=[...this.commonDefinitions.defines,...this.definitions.defines].map(r=>r.value!==void 0?"#define "+r.type+" "+r.value:"#define "+r.type),i=Array.isArray(t)?t:[t||""];let s=!0;for(const r of i)s&&r.indexOf("#version")!==-1?n.unshift(r):n.push(r),s=!1;return n.join(`
`)}};mi.Vertex=1,mi.Fragment=2;let To=mi;function qh(e,t,n,i){for(const s of t)nM(e,n,s,i)}function eM(e,t,n){const i=t.buffer,s=[];for(const r of t.generatedObjects){const o=new DataView(i,r.rangeStart,r.rangeEnd-r.rangeStart),a=e.createBuffer(o);a.purpose="instanced",a.drawType=ke.StaticDraw,r.buffer=a,r.rangeEnd-r.rangeStart===n&&(r.tMatrix3x3=new Float32Array(o.buffer,r.rangeStart+16,9)),s.push(a)}return s}function tM(e,t,n,i,s){const r=e.createBuffer(n);r.purpose="attributes",r.drawType=ke.StaticDraw;const o=[];let a,c,l;return s&&(l=e.createBuffer(s,{itemSize:1,dataType:ke.UnsignedShort},!0),l.elementsType=ke.UnsignedShort),t.forEach(d=>{const f=e.getShaderProgram(d.programName),u=d.vaoCreator(r,f,l);if(d.needsVisibilityBuffer){if(!a||!c){const h=new Uint8Array(new Array(i).fill(1));a=e.createBuffer(h,void 0,!1,!0),a.purpose="visibility",c=new Dh(a,{itemSize:1,dataType:ke.UnsignedByte})}u.setAttribute("a_float_visibility",c)}o.push(u)}),{buffer:r,visibilityBuffer:a,vaos:o}}function nM(e,t,n,i){const{renderer:s,instanceLinker:r,map:o}=e,{symbol:a,sink:c,generatedObjects:l,buffer:d,elementsBuffer:f,elementSize:u}=n;if(s.symbolSettingsList[a]===void 0)return;const y=Jh(s,a,c);if(y.length===0)return;const w=Hs(a,c);if(y[0].instanceBinder){const E=eM(s,n,w);t.buffers.push(...E),r.enqueue(n,t);return}let p=0;f&&u?p=f.byteLength/u:p=d.byteLength/w;const{buffer:g,vaos:b,visibilityBuffer:v}=tM(s,y,d,p,f);t.pushBuffer(g),v&&t.pushBuffer(v);const M=a==="polygonExtrusion"&&!o.getFeatureFlag("transparentBuildingsOff")||a==="lineExtrusion";for(let E=0;E<l.length;E++){const{rangeStart:T,rangeEnd:L,attributes:A,drawMode:P,meta:R,objectsData:k}=l[E],V=Ph[a].sinks[c].unpackObjectAttributes(A),z=[];for(let $=0;$<y.length;$++){const ee=y[$],I=b[$],_=ee.uniformSet||"fill",S={id:Pa(),type:ka.Tile,layerSettings:ee,start:T/w,count:(L-T)/w,attributes:V,renderingProperties:{},attributesHash:JSON.stringify(A)+"_"+_+"_"+t.detailLevel,vao:I,drawMode:P,tile:t,symbol:a,sink:c,meta:R,canRender:!0};M&&(S.shaderDefinitions=To.createShaderDefinitions([{type:"BLEND"}])),t.push(S),ee.needsVisibilityBuffer&&z.push(I)}i&&z.length>0&&k&&t instanceof Eo&&iM(k,t,z,i,!!V.floorId)}}function iM(e,t,n,i,s){const r=s?t.floorObjectsMap:t.objectsMap,o=[];for(const a in e){const c=e[a];let l=r[a];l||(l=new Map,r[a]=l);let d=l.get(n);d||(d=[],l.set(n,d));for(const f of c)d.push(f);i.isHidden(a,zi.PolygonExtrusion)&&o.push(a)}i.triggerIdUpdate(o)}function Jh(e,t,n){const i=e.symbolSettingsList[t];if(i===void 0)return[];const s=i[n];return s==null||s.length===0?[]:s}const sM=4,rM=.001,oM=1e-7,aM=10,$s=11,So=1/($s-1),cM=typeof Float32Array=="function";function Kh(e,t){return 1-3*t+3*e}function Qh(e,t){return 3*t-6*e}function e0(e){return 3*e}function Ao(e,t,n){return((Kh(t,n)*e+Qh(t,n))*e+e0(t))*e}function t0(e,t,n){return 3*Kh(t,n)*e*e+2*Qh(t,n)*e+e0(t)}function lM(e,t,n,i,s){let r,o,a=0;do o=t+(n-t)/2,r=Ao(o,i,s)-e,r>0?n=o:t=o;while(Math.abs(r)>oM&&++a<aM);return o}function dM(e,t,n,i){for(let s=0;s<sM;++s){const r=t0(t,n,i);if(r===0)return t;const o=Ao(t,n,i)-e;t-=o/r}return t}function fM(e){return e}function n0(e,t,n,i){if(!(0<=e&&e<=1&&0<=n&&n<=1))throw new Error("bezier x values must be in [0, 1] range");if(e===t&&n===i)return fM;const s=cM?new Float32Array($s):new Array($s);for(let o=0;o<$s;++o)s[o]=Ao(o*So,e,n);function r(o){let a=0,c=1;const l=$s-1;for(;c!==l&&s[c]<=o;++c)a+=So;--c;const d=(o-s[c])/(s[c+1]-s[c]),f=a+d*So,u=t0(f,e,n);return u>=rM?dM(o,f,e,n):u===0?f:lM(o,a,a+So,e,n)}return function(a){return a===0?0:a===1?1:Ao(r(a),t,i)}}function i0(e,t,n,i){return t+n/i*e}const uM=n0(.25,.1,.25,1);function s0(e,t,n,i){return t+n*uM(e/i)}function hM(e,t,n,i){return n*(e/=i)*e+t}function pM(e,t,n,i){return-n*(e/=i)*(e-2)+t}function mM(e,t,n,i){return(e/=i/2)<1?n/2*e*e+t:-n/2*(--e*(e-2)-1)+t}function yM(e,t,n,i){return n*(e/=i)*e*e+t}function gM(e,t,n,i){return n*((e=e/i-1)*e*e+1)+t}function wM(e,t,n,i){return(e/=i/2)<1?n/2*e*e*e+t:n/2*((e-=2)*e*e+2)+t}function vM(e,t,n,i){return n*(e/=i)*e*e*e+t}function bM(e,t,n,i){return-n*((e=e/i-1)*e*e*e-1)+t}function IM(e,t,n,i){return(e/=i/2)<1?n/2*e*e*e*e+t:-n/2*((e-=2)*e*e*e-2)+t}function MM(e,t,n,i){return n*(e/=i)*e*e*e*e+t}function TM(e,t,n,i){return n*((e=e/i-1)*e*e*e*e+1)+t}function SM(e,t,n,i){return(e/=i/2)<1?n/2*e*e*e*e*e+t:n/2*((e-=2)*e*e*e*e+2)+t}function AM(e,t,n,i){return-n*Math.cos(e/i*(Math.PI/2))+n+t}function EM(e,t,n,i){return n*Math.sin(e/i*(Math.PI/2))+t}function xM(e,t,n,i){return-n/2*(Math.cos(Math.PI*e/i)-1)+t}function _M(e,t,n,i){return e==0?t:n*Math.pow(2,10*(e/i-1))+t}function PM(e,t,n,i){return e==i?t+n:n*(-Math.pow(2,-10*e/i)+1)+t}function LM(e,t,n,i){return e==0?t:e==i?t+n:(e/=i/2)<1?n/2*Math.pow(2,10*(e-1))+t:n/2*(-Math.pow(2,-10*--e)+2)+t}function DM(e,t,n,i){return-n*(Math.sqrt(1-(e/=i)*e)-1)+t}function OM(e,t,n,i){return n*Math.sqrt(1-(e=e/i-1)*e)+t}function CM(e,t,n,i){return(e/=i/2)<1?-n/2*(Math.sqrt(1-e*e)-1)+t:n/2*(Math.sqrt(1-(e-=2)*e)+1)+t}function FM(e,t,n,i){var o=1.70158,s=0,r=n;if(e==0)return t;if((e/=i)==1)return t+n;if(s||(s=i*.3),r<Math.abs(n)){r=n;var o=s/4}else var o=s/(2*Math.PI)*Math.asin(n/r);return-(r*Math.pow(2,10*(e-=1))*Math.sin((e*i-o)*(2*Math.PI)/s))+t}function NM(e,t,n,i){var o=1.70158,s=0,r=n;if(e==0)return t;if((e/=i)==1)return t+n;if(s||(s=i*.3),r<Math.abs(n)){r=n;var o=s/4}else var o=s/(2*Math.PI)*Math.asin(n/r);return r*Math.pow(2,-10*e)*Math.sin((e*i-o)*(2*Math.PI)/s)+n+t}function RM(e,t,n,i){var o=1.70158,s=0,r=n;if(e==0)return t;if((e/=i/2)==2)return t+n;if(s||(s=i*(.3*1.5)),r<Math.abs(n)){r=n;var o=s/4}else var o=s/(2*Math.PI)*Math.asin(n/r);return e<1?-.5*(r*Math.pow(2,10*(e-=1))*Math.sin((e*i-o)*(2*Math.PI)/s))+t:r*Math.pow(2,-10*(e-=1))*Math.sin((e*i-o)*(2*Math.PI)/s)*.5+n+t}function BM(e,t,n,i,s){return s==null&&(s=1.70158),n*(e/=i)*e*((s+1)*e-s)+t}function kM(e,t,n,i,s){return s==null&&(s=1.70158),n*((e=e/i-1)*e*((s+1)*e+s)+1)+t}function UM(e,t,n,i,s){return s==null&&(s=1.70158),(e/=i/2)<1?n/2*(e*e*(((s*=1.525)+1)*e-s))+t:n/2*((e-=2)*e*(((s*=1.525)+1)*e+s)+2)+t}function zM(e,t,n,i){return(e/=i)<1/2.75?n*(7.5625*e*e)+t:e<2/2.75?n*(7.5625*(e-=1.5/2.75)*e+.75)+t:e<2.5/2.75?n*(7.5625*(e-=2.25/2.75)*e+.9375)+t:n*(7.5625*(e-=2.625/2.75)*e+.984375)+t}function GM(e,t,n,i){return n*(1-Math.pow(1-e/i,Jo.nonLinearity+1))+t}const jM=Object.freeze(Object.defineProperty({__proto__:null,ease:s0,easeInBack:BM,easeInCirc:DM,easeInCubic:yM,easeInElastic:FM,easeInExpo:_M,easeInOutBack:UM,easeInOutCirc:CM,easeInOutCubic:wM,easeInOutElastic:RM,easeInOutExpo:LM,easeInOutQuad:mM,easeInOutQuart:IM,easeInOutQuint:SM,easeInOutSine:xM,easeInQuad:hM,easeInQuart:vM,easeInQuint:MM,easeInSine:AM,easeOutBack:kM,easeOutBounce:zM,easeOutCirc:OM,easeOutCubic:gM,easeOutElastic:NM,easeOutExpo:PM,easeOutQuad:pM,easeOutQuart:bM,easeOutQuint:TM,easeOutSine:EM,inertia:GM,linear:i0},Symbol.toStringTag,{value:"Module"})),HM={easing:"easeInOutQuad",forceFinalValue:!0,renderAfterUpdate:!0};function VM(e,t){return t.tickers[e]}function r0(e,t,n,i,s,r,o,a){let c;t.animationGroup&&(c=Object.keys(n.tickers).filter(l=>n.tickers[l].animationGroup===t.animationGroup)),n.tickers[e]={...HM,...t,from:i,to:s,duration:r,attributes:a,startTime:n.time,alreadyStartedGroupTickers:c,iterationCount:o}}function al(e,t){delete t.tickers[e]}function o0(e,t){return!!t.tickers[e]}function a0(e,t,n){const i=n.tickers[e];if(!i)return;if(i.alreadyStartedGroupTickers&&i.alreadyStartedGroupTickers.some(c=>!!n.tickers[c])){i.startTime=n.time;return}let s=n.time-i.startTime;if(i.iterationCount>1){const c=s;s=c%i.duration,i.iterationCount!==1/0&&c>=i.duration*i.iterationCount&&(s=i.duration)}let r;if(i.from.length){r=[];for(let c=0;c<i.from.length;c++){const l=c0(i.easing,i.from[c],i.to[c],i.duration,s);r.push(l)}}else r=c0(i.easing,i.from,i.to,i.duration,s);let o=!1;s>=i.duration&&(i.forceFinalValue&&(r=i.to),o=!0),t.step&&t.step(n,r,i.attributes,o),o&&(t.keepFinished||al(e,n),t.complete&&t.complete(n)),(typeof i.renderAfterUpdate=="function"?i.renderAfterUpdate():i.renderAfterUpdate)&&(i.attributes?.layerId?n.rerenderEvents.push({type:"layerAnimationTicker",layerId:i.attributes.layerId,styleId:i.attributes.styleId}):n.rerenderEvents.push({type:"coreAnimationTicker"}))}function c0(e,t,n,i,s){return typeof e=="string"?jM[e](s,t,n-t,i):e(s,t,n-t,i)}let $M=0;class l0{constructor(t,n){this.isDestroyed=!1,this.id=$M++,this.ids=n,this.tickerName=`tile-fade-${t}-${this.id}`,this.readiness=1,this.needSync=!1,this.modelMatrices=new Map,this.coords=[0,0,0,0],this.bounds=new Map,this.mvpMatrices=new Map,this.demMatrices=new Map,this.flatMapTexMatrices=new Map,this.purpose=t,this.buffers=[],this.children=[],this.identifyChildren=[],this.depthTestChildren=[],this.shadowChildren=[],this.labelTestChildren=[],this.demChildren=[],this.demGroundChildren=[]}get destroyed(){return this.isDestroyed}get empty(){return this.children.length===0}updateMvpMatrix(t,n,i){this.modelMatrices.forEach((s,r)=>{const o=this.mvpMatrices.get(r)??new Float32Array(16);if(Ii(o,t,s),this.mvpMatrices.set(r,o),n){const a=this.demMatrices.get(r)??new Float32Array(16);Ii(a,n,s),this.demMatrices.set(r,a)}if(i){const a=this.flatMapTexMatrices.get(r)??new Float32Array(16);Ii(a,i,s),this.flatMapTexMatrices.set(r,a)}})}setMvpMatrix(t){this.modelMatrices.forEach((n,i)=>{this.mvpMatrices.set(i,new Float32Array(t))})}clean(t){for(const n of this.buffers)n.remove();this.buffers=[],this.children=[],this.labelTestChildren=[],this.identifyChildren=[],this.depthTestChildren=[],this.shadowChildren=[],this.demChildren=[],this.demGroundChildren=[],al(this.tickerName,t),this.isDestroyed=!0}updateTicker(t){a0(this.tickerName,{step:(n,i)=>{this.readiness=i}},t)}startTicker(t,n,i,s,r){r0(this.tickerName,{easing:n},t,s,r,i,1)}tickerFinished(t){return!o0(this.tickerName,t)}push(t){const n=t.layerSettings;n.identify?this.identifyChildren.push(t):n.depthTest?this.depthTestChildren.push(t):n.labelTest?t.sink==="raster"&&t.symbol==="point"&&this.labelTestChildren.push(t):n.dem?this.demChildren.push(t):n.demGround?this.demGroundChildren.push(t):n.shadow?this.shadowChildren.push(t):this.children.push(t)}pushBuffer(t){this.buffers.push(t)}}class Eo extends l0{constructor(t,n,i,s,r=[0,0,0,0],o,a,c){super(t,a),this.objectsMap={},this.floorObjectsMap={},this.dynamicObject=o,this.sourceId=c,qh(i,n,this,a),this.setTileCoords(r,s)}setTileCoords(t,n){const i=t[2],s=t[3],r=wt(i);this.coords=t,this.size=r,this.zoomLevel=i,this.detailLevel=s,this.mvpMatrices.clear(),this.demMatrices.clear(),this.flatMapTexMatrices.clear(),this.syncReplicas(n)}syncReplicas(t){let n=[...t.visibleMapReplicas];if(this.purpose==="globe"){const{center:r}=t,o=wt(this.coords[2]),a=Math.trunc((2**31+r[0])/o);n=[Math.round((a-this.coords[0])/2**this.coords[2])]}if(this.dynamicObject&&this.dynamicObject.isOutOfMainReplica()){const r=n[0],o=n[n.length-1];n.push(r-1,o+1)}const i=B/ne*this.size,s=Math.pow(2,this.coords[2]);this.bounds.clear(),this.modelMatrices.clear(),n.forEach(r=>{const o=[this.coords[0]+r*s,this.coords[1],this.coords[2],this.coords[3]],a=xi(o);this.bounds.set(r,{min:[a[0],a[1]],max:[a[0]+this.size,a[1]+this.size]});const c=Nd();or(c,[a[0]-i,a[1]-i,0],qe(this.size/yi,this.size/yi,Zi/yi)),this.modelMatrices.set(r,c)}),this.needSync=!1}updateObjVisibility(t,n,i){const s=i?this.floorObjectsMap[t]:this.objectsMap[t];if(!s)return!1;let r=!1;return s.forEach((o,a)=>{const l=a[0].getBuffer("a_float_visibility").getData();if(!(l instanceof Uint8Array))return;let d=!1;for(const{offset:f,size:u}of o)if(l[f]!==n){for(let h=f;h<f+u;++h)l[h]=n;d=!0}if(d){a[0].rewriteData("a_float_visibility");for(const f of a)f.isDirty=!0;r=!0}}),r}clean(t){for(const n in this.objectsMap)this.objectsMap[n].forEach((i,s)=>{s.forEach(r=>{r.unbind(),r.remove()})});for(const n in this.floorObjectsMap)this.floorObjectsMap[n].forEach((i,s)=>{s.forEach(r=>{r.unbind(),r.remove()})});super.clean(t)}}var Et=(e=>(e[e.Stationary=0]="Stationary",e[e.ZoomingIn=1]="ZoomingIn",e[e.ZoomingOut=2]="ZoomingOut",e))(Et||{}),pt=(e=>(e[e.ByOne=0]="ByOne",e[e.WaitingLayer=1]="WaitingLayer",e[e.GlobalWaiting=2]="GlobalWaiting",e))(pt||{});function YM(e,t,n){return{key:t,labelsKey:`${e.labelsKey}_${t}`,useful:!0,ready:!1,needGenerate:!1,tile:e,status:0,params:n.clone()}}function d0(e,t,n){e.generatedData=t,n&&e.params.setTileIds(n)}function f0(e){const t=e.generatedData,n=[];if(!t)return n;for(let i=0;i<t.length;i++){const s=t[i];s.collectorOutput.labels&&n.push({metatileHash:s.metatileHash,labels:s.collectorOutput.labels,styleId:s.styleId})}return n}function cl(e,t){e.status=0,e.generatedData=void 0,e.objects!==void 0&&e.objects.forEach(n=>n.clean(t)),e.objects=void 0,e.ready=!1,e.tile.currentMod===e&&(e.tile.currentMod=void 0)}function u0(e){return e.status===0}function h0(e,t,n,i,s){switch(e.status){case 0:e.useful&&(e.status=1);break;case 1:e.useful?e.tile.serverMetadata&&(e.status=2):e.status=0;break;case 2:ZM(e,n,i)&&(e.status=3,e.needGenerate=!0);break;case 3:e.generatedData&&(e.status=4,e.ready=!0,e.objects=e.generatedData.map(r=>{const{collectorOutput:{data:o}}=r;return new Eo(e.tile.type,o,i,n,e.tile.coords,void 0,s,e.tile.sourceId)}),t.add(e.key,e));break}}function ZM(e,t,n){switch(e.tile.type){case"zenith":return!!(e.useful&&e.tile.serverMetadata&&WM(e.tile.serverMetadata,t,n));case"traffic":return!!(e.useful&&e.tile.serverMetadata);case"raster":case"geojson":case"globe":case"dem":return!!e.useful;default:return!1}}function WM(e,t,n){const{assetManager:i,modelLayer:s}=n;for(let r=0;r<e.length;r++){const{regionId:o,metatileHash:a}=e[r];if(!i.getMetatile(a)||t.styleZoom>Wo&&!s.isModelsInfoLoaded(o))return!1}return!0}class Ys{constructor(t,n,i,s,r){this.selectedIds=t.slice(),this.styleState={...n},this.tileRevision=i,this.styleRevision=r,this.styleId=s}static equal(t,n){return t.tileRevision===n.tileRevision&&t.styleId===n.styleId&&t.styleRevision===n.styleRevision&&wi(t.getSelectedIds(),n.getSelectedIds())&&wi(t.styleState,n.styleState)}clone(){return new Ys(this.selectedIds,this.styleState,this.tileRevision,this.styleId,this.styleRevision)}stringify(){const t=this.selectedIds.join("|");return`sId=${this.styleId}_sRev=${this.styleRevision}_tRev=${this.tileRevision}_sel=${t}_sSt=${JSON.stringify(this.styleState)}`}getSelectedIds(){return this.tileIds?this.selectedIds.filter(t=>this.tileIds?.has(t)):this.selectedIds.slice()}setTileIds(t){this.tileIds=t}}var ll=(e=>(e[e.Initial=0]="Initial",e[e.Loading=1]="Loading",e[e.Loaded=2]="Loaded",e))(ll||{});function XM(e,t,n,i){return{type:e,sourceId:n,key:Ie(t),labelsKey:`${e}_${n}_${i}`,coords:t,zoomLevel:t[2],detailLevel:t[3],needFetch:!1,revision:0,needAbortFetch:!1,needGenerate:!1,status:0,oldHoverTileObjects:[]}}function p0(e,t,n,i,s,r){const o=[];if(n.oldHoverTileObjects.forEach(a=>{a.tickerFinished(t)?(e.tileManager.removeObject(a),a.clean(t)):o.push(a)}),n.oldHoverTileObjects=o,s===void 0){dl(e,n,t);return}t.performanceCaveatEmitted||(r||!n.hover||n.hover.id===s)&&JM(e,t,n,s,i)}function qM(e,t){const n=Math.min(Math.floor(e.styleZoom),Gn.maxDetailLevel),i=t.coords[3];return n===i}function JM(e,t,n,i,s){if(!n.idSet||!n.idSet.has(i)||!qM(t,n)){dl(e,n,t);return}const r=e.identifier.getIdScope(tl);r.isHidden(i,zi.PolygonExtrusion)||KM(e,n,i,s).then(o=>{dl(e,n,t);const a={id:i,tileObjects:[],generatedData:[]},c=[];o.results.forEach(l=>{const d=new Eo("hover",l.collectorOutput.data,e,t,n.coords,void 0,r),{packedRasters:f,rastersToLoad:u}=l.collectorOutput;f!==void 0&&e.assetManager.prepareRasters(l.styleId,f),e.assetManager.loadRasters(u),a.tileObjects.push(d),e.tileManager.addObject(d),d.startTicker(t,Xi.inAnimationType,Xi.inAnimationTime,0,1),l.collectorOutput.labels.length&&c.push({metatileHash:l.metatileHash,labels:l.collectorOutput.labels,styleId:l.styleId})}),a.generatedData=o.results,e.labeler.addLabels("label_hover",Ds.Tile,c),e.identifier.queryFillCache(),n.hover=a})}function dl(e,t,n){t.hover&&(t.hover.tileObjects.forEach(i=>{t.oldHoverTileObjects.push(i),i.startTicker(n,Xi.outAnimationType,Xi.outAnimationTime,1,0)}),t.hover=void 0,e.labeler.removeLabels("label_hover"),e.identifier.queryFillCache())}function KM(e,t,n,i){const r=(t.newMod||t.currentMod)?.params.getSelectedIds()||[],o=e.map.state;return e.defaultSource.generateHoverTile(o,t.coords,o.handyStyleId,r,self.devicePixelRatio,{},n,i)}function m0(e){if(e.newMod&&e.newMod.needGenerate)return e.newMod.needGenerate=!1,e.newMod}function QM(e){return(!e.currentMod||u0(e.currentMod))&&(!e.newMod||u0(e.newMod))}function eT(e,t){e.currentMod&&cl(e.currentMod,t),e.newMod&&cl(e.newMod,t)}function tT(e){e.currentMod=void 0}function xo(e){if(e.currentMod&&e.currentMod.useful)return e.currentMod;if(e.newMod&&e.newMod.useful)return e.newMod}function nT(e){e.currentMod&&(e.currentMod.useful=!1),e.newMod&&(e.newMod.useful=!1)}function iT(e,t,n){if(e.idSet&&t.setTileIds(e.idSet),!e.currentMod&&!e.newMod){fl(e,t,n);return}if(e.currentMod&&Ys.equal(e.currentMod.params,t)){e.currentMod.useful=!0,e.newMod=void 0;return}if(e.newMod){Ys.equal(e.newMod.params,t)?e.newMod.useful=!0:fl(e,t,n);return}fl(e,t,n)}function fl(e,t,n){const i=by(e.coords,t),s=n.get(i);s?(e.newMod=s,e.newMod.useful=!0):(e.newMod=YM(e,i,t),e.idSet&&e.newMod.params.setTileIds(e.idSet))}function sT(e,t,n,i,s){switch(e.status){case 0:e.newMod&&e.newMod.useful&&(e.status=1,e.needFetch=!0);break;case 1:e.newMod&&e.newMod.useful?e.serverMetadata&&(e.status=2):(e.status=0,e.needAbortFetch=!0);break}e.currentMod&&h0(e.currentMod,t,n,i,s),e.newMod&&(h0(e.newMod,t,n,i,s),e.newMod.needGenerate&&(e.needGenerate=!0))}function rT(e){e.newMod&&e.newMod.ready&&(e.currentMod=e.newMod,e.newMod=void 0)}function oT(e){const t=new Set;return e.forEach(n=>{const{idBuffer:i,orphanIds:s}=n.collectorOutput.identifyIds;for(const r of i)t.add(r);for(const r of s)t.add(r)}),t}function aT(e){e.status===1&&(e.needAbortFetch=!0),e.status=0,e.serverMetadata=void 0,e.revision++}function cT(e){e.revision++}const lT=()=>{};class y0{constructor(t,n=lT){this.size=t,this.onRemove=n,this.map=new Map,this._length=0}add(t,n){if(this.map.has(t))return;const i={key:t,value:n};this.map.set(t,i),this._addToFront(i),this._length++,this._length>this.size&&this._removeLRU()}remove(t){const n=this.map.get(t);n&&(this._removeNode(n),this.map.delete(t),this._length--)}get(t){const n=this.map.get(t);if(n)return this._moveToFront(n),n.value}reset(){for(const[t,n]of this.map)this.onRemove(t,n.value);this.map.clear(),this.head=void 0,this.tail=void 0,this._length=0}setSize(t){for(this.size=t;this._length>this.size;)this._removeLRU()}getSize(){return this.size}keys(){return Array.from(this.map.keys())}getData(){return Array.from(this.map.values()).map(t=>t.value)}_addToFront(t){t.next=this.head,t.prev=void 0,this.head&&(this.head.prev=t),this.head=t,this.tail||(this.tail=t)}_removeNode(t){t.prev?t.prev.next=t.next:this.head=t.next,t.next?t.next.prev=t.prev:this.tail=t.prev,t.next=void 0,t.prev=void 0}_moveToFront(t){this._removeNode(t),this._addToFront(t)}_removeLRU(){if(!this.tail)return;const t=this.tail.key,n=this.tail.value;this._removeNode(this.tail),this.map.delete(t),this._length--,this.onRemove(t,n)}}function Gi(e){const t=e.viewportTiles;for(const n in e.tiles)nT(e.tiles[n]);for(const n of t){let i=e.tiles[n];i||(i=e.tiles[n]=XM(e.type,Ca(n),e.sourceId,e.tileLayerId));const s=new Ys(e.selectedIds,e.styleState,i.revision,e.styleId,e.styleRevision);iT(i,s,e.tileModsCache)}}function ul(e,t){for(const n of t){const i=e[n],s=xo(i);if(!s||!s.ready)return!1}return!0}function g0(e){const t=[];for(const n in e.tiles){const i=e.tiles[n];i.needFetch&&(i.needFetch=!1,t.push(i))}return t}function w0(e){const t=[];for(const n in e.tiles){const i=e.tiles[n];i.needAbortFetch&&(i.needAbortFetch=!1,t.push(i))}return t}function v0(e){const t=[];for(const n in e.tiles){const i=e.tiles[n];i.needGenerate&&(i.needGenerate=!1,t.push(i))}return t}function b0(e){const t=e.viewportTiles,n=new Set(e.tileModsCache.getData().map(s=>s.tile)),i=[];for(const s in e.tiles){const r=e.tiles[s];QM(r)&&!t.has(s)&&e.zoomDirection===Et.Stationary&&!n.has(r)&&i.push(r)}return i}function I0(e,t,n,i,s,r,o,a,c,l,d=0,f=!1,u=!1){return{type:e,sourceId:t,tileLayerId:n,styleId:c.handyStyleId,styleRevision:a.styleManager.getStyleRevision(c.handyStyleId),styleState:c.styleState,minZoomLevel:i,maxZoomLevel:s,minDetailLevel:r,maxDetailLevel:o,tiles:{},viewportTiles:new Set,zoomLevel:M0(e,c.zoom,c.styleZoom),zoomDirection:Et.Stationary,zoomStartZoom:0,tileModsCache:new y0(0,(h,y)=>{a.labeler.removeLabels(y.labelsKey),y.objects?.forEach(w=>a.tileManager.removeObject(w)),cl(y,c)}),tileModsCacheMaxCount:0,selectedIds:[],displayedMods:{},tilesAppearance:pt.ByOne,mapState:c,stopLabelAnimation:!1,viewportPadding:d,displayStats:{matched:0,shifted:0,parent:0,children:0},requestOddTiles:f,ids:l,useExtendedTilesBounds:u}}function M0(e,t,n){return e==="raster"?Math.round(t):Math.floor(n)}function hl(e){for(const t in e.tiles)eT(e.tiles[t],e.mapState);e.tiles={},e.viewportTiles=new Set,e.zoomDirection=Et.Stationary,e.tileModsCache.reset(),e.displayedMods={},e.tilesAppearance=pt.ByOne}function T0(e,t,n,i,s=!1){const{tileManager:r,renderer:o}=e,a=n.displayedMods,c=Ld(a,i);c.forEach(f=>{if(f.objects!==void 0){let u=!s;for(const h in i)if(Ny(f.tile,i[h].tile)){u=!1;break}f.objects.forEach(h=>{r.addObject(h),u&&h.startTicker(t,Xo.type,Xo.time,0,1)})}});const l=Ld(i,a);l.forEach(f=>{f.objects!==void 0&&(f.objects.forEach(u=>{r.removeObject(u)}),f.tile.hover?.tileObjects.forEach(u=>r.removeObject(u)))});const d=c.length>0||l.length>0;return d&&(t.needLabeling=!0,o.addRerenderEvent()),d}function pl(e){e.viewportTiles.forEach(t=>rT(e.tiles[t]))}function dT(e){switch(e){case"geojson":return 3;case"raster":return 1/0;case"dem":return 1}return 2}function ml(e,t,n){fT(e,t.styleZoom,t.zoom),uT(e,t,n),hT(e),Gi(e)}function fT(e,t,n){const i=M0(e.type,n,t),s=i-e.zoomLevel;e.zoomDirection===Et.Stationary&&(s>0?(e.zoomDirection=Et.ZoomingIn,e.zoomStartZoom=e.zoomLevel):s<0&&(e.zoomDirection=Et.ZoomingOut,e.zoomStartZoom=e.zoomLevel)),e.zoomLevel=i}function uT(e,t,n){if(e.zoomLevel<e.minZoomLevel){e.viewportTiles=new Set;return}const i=ge(e.zoomLevel,e.minZoomLevel,e.maxZoomLevel),s=ge(e.zoomLevel,e.minDetailLevel,e.maxDetailLevel);let r;switch(e.type){case"globe":r=mf(t,i,e.minZoomLevel).map(Ie);break;default:r=wf(t,n,i,e.minZoomLevel,s,e.viewportPadding,e.maxZoomLevel,e.requestOddTiles,e.useExtendedTilesBounds).map(Ie),t.stats.foundVisibleTilesCount=e.viewportTiles.size}e.viewportTiles=new Set(r)}function hT(e){const t=Math.round((Object.keys(e.displayedMods).length+e.viewportTiles.size)*Gn.cacheRatio);e.tileModsCacheMaxCount<t&&(e.tileModsCacheMaxCount=t),t>e.tileModsCacheMaxCount/2&&e.tileModsCache.setSize(t)}function pT(e,t){const n={};for(const i in e){const s=e[i];let r=Math.floor(s.coords[0]/2),o=Math.floor(s.coords[1]/2);for(let a=s.coords[2]-1;a>=t;a--){const c=Po(r,o,a),l=n[c];l?l.push(s):n[c]=[s],r=Math.floor(r/2),o=Math.floor(o/2)}}return n}function mT(e,t,n){const i=wT(e),s=Object.keys(i).reduce((f,u)=>{const h=i[u],y=Po(h.coords[0],h.coords[1],h.coords[2]);return f[y]=h,f},{}),r=Math.min(...Object.values(i).map(f=>f.coords[2])),o=Math.min(...Array.from(t).map(f=>e[f].coords[2])),a=pT(i,o),c={},l=new Set;for(const f of t){const u=i[f];if(u){_o(c,u),n.matched++;continue}const h=e[f],y=yT(h,i,3);if(y){n.shifted++,_o(c,y);continue}const w=Po(h.coords[0],h.coords[1],h.coords[2]),p=S0(h,r,s);if(p){n.parent++,_o(c,p),l.add(p);continue}const g=a[w];if(g)for(const b of g)n.children++,_o(c,b)}function d(f){const u=S0(f,r,s);u&&l.has(u)&&(delete c[f.currentMod.key],d(u))}for(const f in c)d(c[f].tile);return c}function yT(e,t,n){const{coords:i}=e,s=Math.min(i[3]+n,32),r=Math.max(i[3]-n,0);for(let o=r;o<=s;o+=1){if(o===i[3])continue;const a=hf(i[0],i[1],i[2],o),c=t[a];if(c)return c}}function gT(e){const t=e.currentMod;return t===void 0?!1:t.ready}function _o(e,t){const n=t.currentMod;e[n.key]=n}function wT(e){const t={};for(const n in e){const i=e[n];gT(i)&&(t[n]=i)}return t}function S0(e,t,n){let[i,s,r]=e.coords;for(;r-->=t;){i=Math.floor(i/2),s=Math.floor(s/2);const o=Po(i,s,r);if(n[o])return n[o]}}function Po(e,t,n){return`${e}_${t}_${n}`}function A0(e,t,n){vT(e,t,n),bT(e),IT(e);for(const i in e.displayedMods)e.tileModsCache.get(i);MT(e),TT(e)}function vT(e,t,n){for(const i in e.tiles)sT(e.tiles[i],e.tileModsCache,t,n,e.ids)}function bT(e){switch(e.tilesAppearance){case pt.ByOne:pl(e);break;case pt.WaitingLayer:ul(e.tiles,e.viewportTiles)&&(e.tilesAppearance=pt.ByOne,pl(e));break;case pt.GlobalWaiting:break}}function IT(e){const{tiles:t,viewportTiles:n,displayStats:i}=e;e.displayedMods=mT(t,n,i)}function MT({tiles:e,displayedMods:t,viewportTiles:n}){for(const i in e){if(n.has(i))continue;const s=e[i],r=s.currentMod;r&&!t[r.key]&&tT(s)}}function TT(e){switch(e.zoomDirection){case Et.ZoomingIn:(e.zoomLevel<=e.zoomStartZoom||E0(e))&&(e.zoomDirection=Et.Stationary,e.zoomStartZoom=e.zoomLevel);break;case Et.ZoomingOut:(e.zoomLevel>=e.zoomStartZoom||E0(e))&&(e.zoomDirection=Et.Stationary,e.zoomStartZoom=e.zoomLevel);break}}function E0(e){const{tiles:t,viewportTiles:n,displayedMods:i}=e;for(const s of n){const r=t[s],o=xo(r);if(!o||i[o.key]===void 0)return!1}return!0}function ST(e,t,n,i){n.selectedIds=i,n.tilesAppearance=pt.WaitingLayer,Gi(n);for(const s in n.tiles){const r=n.tiles[s];p0(e,t,r,n.sourceId,r.hover?.id,!0)}}function x0(e,t,n,i){if(!t.disableHoverStyles){for(const s in n.tiles){const r=n.tiles[s];p0(e,t,r,n.sourceId,i)}e.labeler.disableThrottleUpdateOnce()}}function AT(e,t){e.styleState=t,Gi(e)}function _0(e,t,n,i){i?e.tilesAppearance=pt.ByOne:e.tilesAppearance=pt.GlobalWaiting,e.styleId=t,e.styleRevision=n,Gi(e)}function P0(e){e.tilesAppearance=pt.ByOne,pl(e)}function ET(e){e.tilesAppearance=pt.WaitingLayer,e.stopLabelAnimation=!0,Object.keys(e.tiles).forEach(t=>{aT(e.tiles[t])}),Gi(e)}function xT(e){e.tilesAppearance=pt.WaitingLayer,Object.keys(e.tiles).forEach(t=>{cT(e.tiles[t])}),Gi(e)}function _T(e,t,n){for(const i of e.viewportTiles){const s=e.tiles[i],r=xo(s);if(!r)continue;const o=f0(r);if(o.length===0)continue;const a=t.getLabelsDemKey(o);r.demKey!==a&&(r.demKey=a,n.addTileLabels(r.labelsKey,Ds.Tile,o))}}function yl(e){return{_src:e.memSizeJs()}}function PT(e){return{_texture:e.memSizeGPU()}}function L0(e){return{[String(e.purpose)]:{_initData:e.memSizeJs()}}}function LT(e){return{[String(e.purpose)]:{_glBuffer:e.memSizeGPU()}}}function gl(e){const t={};return e.generatedData&&(t.generatedData={collectorOutput:e.generatedData?.map(n=>CT(n.collectorOutput))}),e.objects&&(t.objects=e.objects.map(n=>D0(n))),t}function wl(e){return{objects:e.objects?e.objects.map(t=>O0(t)):0}}function D0(e){return{buffers:e.buffers.map(L0)}}function O0(e){return{children:e.children.map(t=>({[`${t.symbol}_${t.sink}`]:(t.instanceCount??t.count)*Hs(t.symbol,t.sink)})),buffers:e.buffers.filter(t=>t.purpose!=="attributes"&&t.purpose!=="instanced").map(t=>({[String(t.purpose)]:t.byteLength}))}}function DT(e){return{buffers:e.buffers.filter(t=>t instanceof ke).map(L0).filter(t=>t._initData),textures:e.textures.map(yl)}}function OT(e){return{buffers:e.buffers.filter(t=>t instanceof ke).map(LT),textures:e.textures.map(yl)}}function vl(e){if(typeof e=="number")return e;let t=0;if(Array.isArray(e))for(const n of e)t+=vl(n);else for(const n in e){const i=e[n];typeof i=="number"?t+=i:t+=vl(i)}return t}function CT(e){return{data:e.data.reduce((n,i)=>(n[`${i.symbol}_${i.sink}`]=i.buffer.byteLength,n),{}),identifyIds:{centerBuffer:e.identifyIds.centerBuffer.byteLength,instanceIdBuffer:e.identifyIds.instanceIdBuffer.byteLength,layerIdBuffer:e.identifyIds.layerIdBuffer.byteLength,objectClassBuffer:e.identifyIds.objectClassBuffer.byteLength,phaseBuffer:e.identifyIds.phaseBuffer.byteLength,styleIdBuffer:e.identifyIds.styleIdBuffer.byteLength,sublayerBuffer:e.identifyIds.sublayerBuffer.byteLength}}}async function FT(e){return{defaultSource:e.defaultSource.getMemoryFootprint(),tileManager:e.tileManager.getMemoryFootprint(t=>!e.defaultSource.hasLayer(t)),identifier:e.identifier.getMemoryFootprint(),assetManager:e.assetManager.getMemoryFootprint(),trafficTileLayer:e.trafficTileLayer.getMemoryFootprint(),imageManager:e.imageManager.getMemoryFootprint(),parserThread:await e.workers.parser.getMemoryFootprint(),labelingThread:await e.workers.labeling.getMemoryFootprint(),renderer:e.renderer.getMemoryFootprint(),labeler:e.labeler.getMemoryFootprint(),postEffectsManager:e.postEffectsManager.getMemoryFootprint(),shadowManager:e.shadowManager.getMemoryFootprint()}}class C0{constructor(t,n,i,s,r,o,a,c={}){this.disabledRegions=null,this.generatingCount=0,this.tilesGenerationQueue=[],this.disableTilesAnimation=!1,this.idsToUpdate=new Set,this.destroyed=!1,c=Object.assign({viewportPadding:0,disableTilesAnimation:!1,requestOddTiles:!1},c),this.ids=r.identifier.getIdScope(c.idScope??tl),this.ids.registerTileLayer(this),this.modules=r,this.mapState=o,this.prevStyleState=o.styleState,this.sourceCore=a,this.id=Pa(),this.disableTilesAnimation=!!c.disableTilesAnimation,this.gridState=I0(a.type,a.id,this.id,t,n,i,s,r,this.mapState,this.ids,c.viewportPadding,c.requestOddTiles,c.useExtendedTilesBounds),this.maxGeneratingCount=dT(a.type)}memSizeJs(){const t=this.gridState;return{gridState:{displayedMods:Object.keys(t.displayedMods).map(n=>gl(t.displayedMods[n])),tileModsCache:t.tileModsCache.keys().filter(n=>!t.displayedMods[n]).map(n=>gl(t.tileModsCache.get(n)))}}}memSizeGpu(){const t=this.gridState;return{gridState:{displayedMods:Object.keys(t.displayedMods).map(n=>wl(t.displayedMods[n])),tileModsCache:t.tileModsCache.keys().filter(n=>!t.displayedMods[n]).map(n=>wl(t.tileModsCache.get(n)))}}}destroy(){this.destroyed=!0,hl(this.gridState),this.modules.modelsScene.clearSourceTileMapBySource(this.sourceCore.id),this.ids.unregisterTileLayer(this)}redraw(){hl(this.gridState),this.modules.modelsScene.clearSourceTileMapBySource(this.sourceCore.id),ml(this.gridState,this.mapState,this.modules)}getZoomDirection(){return this.gridState.zoomDirection}getDisplayedTileObjects(){const t=[];for(const n in this.gridState.displayedMods){const i=this.gridState.displayedMods[n];i.objects&&t.push(...i.objects)}return t}getDisplayedIdentifyData(){const t=[];for(const n in this.gridState.displayedMods){const i=this.gridState.displayedMods[n];i.generatedData?.concat(i.tile.hover?.generatedData||[]).forEach(s=>t.push({ids:s.collectorOutput.identifyIds,metatileHash:s.metatileHash,sourceId:i.tile.sourceId,tileKey:i.tile.key}))}return t}getLabelingData(){const t={sourceId:this.gridState.sourceId,animate:!this.gridState.stopLabelAnimation,labelsKeys:[]};for(const n in this.gridState.displayedMods){const i=this.gridState.displayedMods[n];t.labelsKeys.push(i.labelsKey)}return this.gridState.stopLabelAnimation&&this.viewportTilesReady()&&(this.gridState.stopLabelAnimation=!1),t}getViewportTiles(){const t=[],n=this.gridState.viewportTiles;for(const i of n){const s=this.gridState.tiles[i];s&&t.push(s)}return t}viewportTilesReady(){return ul(this.gridState.tiles,this.gridState.viewportTiles)}isEmpty(){return this.gridState.viewportTiles.size===0}displayedTilesAnimationFinished(){for(const t in this.gridState.displayedMods){const n=this.gridState.displayedMods[t];if(n.objects){for(const i of n.objects)if(!i.tickerFinished(this.mapState))return!1}}return!0}activateStyleUpdating(){_0(this.gridState,this.mapState.handyStyleId,this.modules.styleManager.getStyleRevision(this.mapState.handyStyleId),this.modules.map.core.getIsFirstStyleUpdate())}finishStyleUpdating(){P0(this.gridState)}setSelectedIds(t){ST(this.modules,this.mapState,this.gridState,t)}setHoverId(t){x0(this.modules,this.mapState,this.gridState,t)}resetHoverId(){x0(this.modules,this.mapState,this.gridState)}onSourceDataChange(){ET(this.gridState)}onFeatureStateMapChange(){xT(this.gridState)}getTileCount(){let t=0;for(const n in this.gridState.displayedMods){const i=this.gridState.displayedMods[n].objects;i!==void 0&&(t+=i.length)}return t}isBlank(){for(const t of this.gridState.viewportTiles){const n=this.gridState.tiles[t],{serverMetadata:i}=n;if(i===void 0||i.length===0)continue;const s=xo(n);if(s&&s.ready)return!1}return!0}updateViewport(){ml(this.gridState,this.mapState,this.modules)}update(){this.mapState.needReplicasUpdate&&this.setModObjectsSyncNecessity();const t={...this.gridState.displayedMods};this.mapState.styleState!==this.prevStyleState&&(AT(this.gridState,this.mapState.styleState),this.prevStyleState=this.mapState.styleState,this.modules.identifier.queryFillCache()),A0(this.gridState,this.mapState,this.modules);const{demManager:n,labeler:i}=this.modules;_T(this.gridState,n,i),this.fetch(g0(this.gridState)),this.abortFetch(w0(this.gridState)),this.generate(v0(this.gridState)),this.clearTiles(b0(this.gridState)),T0(this.modules,this.mapState,this.gridState,t,this.disableTilesAnimation),this.updateVisibility()}pushIdsToUpdate(t){t.forEach(n=>this.idsToUpdate.add(n))}getSourceType(){return this.sourceCore.type}fetch(t){if(t.length===0)return;const n=t.sort((s,r)=>br(this.mapState.center,s,r)).map(s=>s.coords);this.sourceCore.fetchTiles(n,this.mapState).forEach((s,r)=>{s.then(o=>{const a=t[r];a.status===ll.Loading&&(a.serverMetadata=o)})})}abortFetch(t){t.length!==0&&this.sourceCore.abortTileFetches(t.map(n=>n.coords))}updateGenerationQueue(){if(this.destroyed||this.generatingCount>this.maxGeneratingCount)return;const t=this.getTileToGenerate();if(!t)return;++this.generatingCount;const{tile:n,mod:i}=t,s={tileCoords:n.coords,selectedIds:i.params.getSelectedIds(),styleId:i.params.styleId},r=this.disabledRegions,o={areTileBoundsVisible:this.mapState.showDefaultTileBounds};this.sourceCore.generateTile(this.mapState,s.tileCoords,s.styleId,s.selectedIds,devicePixelRatio,o).then(a=>{if(!a){Gf(this.sourceCore.type);return}if(!Array.isArray(a.results))return;let{results:c}=a;r&&(c=c.filter(d=>!r.includes(d.regionId)));const l=new Map;if(c.forEach(d=>{d.collectorOutput.data.forEach(f=>{f.symbol!=="gltfModel"||f.sink!=="instances"||f.generatedObjects.forEach(u=>{const h=Rn.sinks.instances.unpackObjectAttributes(u.attributes),y=u.meta?.childrenIds,w=h.parentId;if(!y||!w)return;let p=l.get(w);p||(p=new Set,l.set(w,p));for(const g of y)p.add(g)})})}),l.size){const d=Ie(s.tileCoords);this.ids.updateParentChildrenData(d,l)}c.forEach(d=>{const{styleId:f,metatileHash:u,regionId:h,collectorOutput:y}=d,{packedRasters:w,rastersToLoad:p,floorHidingMap:g,dataModelsUrls:b}=y;w!==void 0&&this.modules.assetManager.prepareRasters(f,w),this.modules.assetManager.fillDataModelUrlMap(b),this.modules.assetManager.loadRasters(p),this.modules.floorManager.prepareFloors(h,u,g,this.sourceCore.type)}),n.idSet=oT(c),d0(i,c,n.idSet),this.modules.labeler.addTileLabels(i.labelsKey,Ds.Tile,f0(i))}).finally(()=>{this.generatingCount=this.generatingCount-1,this.updateGenerationQueue()})}getTileToGenerate(){this.tilesGenerationQueue.sort((n,i)=>br(this.mapState.center,n,i));let t=this.tilesGenerationQueue.shift();for(;t;){const n=m0(t);if(n){if(n.useful)return{mod:n,tile:t};t.newMod=void 0}t=this.tilesGenerationQueue.shift()}return null}addTileToGenerationQueue(t){this.tilesGenerationQueue.push(t)}generate(t){let n=!1;t.sort((i,s)=>br(this.mapState.center,i,s)).forEach(i=>{i.newMod?.needGenerate&&!this.tilesGenerationQueue.includes(i)&&(this.addTileToGenerationQueue(i),n=!0)}),n&&this.updateGenerationQueue()}clearTiles(t){if(!t.length)return;const n=[];this.modules.modelsScene.clearSourceTileMapByTiles(this.sourceCore.id,t),this.sourceCore.deleteTiles(t.map(i=>i.coords));for(const i of t)n.push(i.key),delete this.gridState.tiles[i.key];this.ids.removeParentChildrenData(n)}updateVisibility(){if(this.idsToUpdate.size===0)return;const t=[];this.gridState.tileModsCache.getData().forEach(i=>{i.objects&&i.objects.forEach(s=>{t.push(s)})}),t.length!==0&&this.updateObjectsVisibility(t)}updateObjectsVisibility(t){let n=!1;for(const i of this.idsToUpdate){const s=+!this.ids.isHidden(i,zi.PolygonExtrusion),r=+!this.ids.isHidden(i,zi.FloorPolygons);for(const o of t)o.updateObjVisibility(i,s,!1)&&(n=!0),o.updateObjVisibility(i,r,!0)&&(n=!0)}this.idsToUpdate.clear(),n&&(this.modules.renderer.addRerenderEvent(),this.modules.identifier.queryFillCache())}setModObjectsSyncNecessity(){this.gridState.tileModsCache.getData().forEach(n=>{n.objects?.forEach(i=>{i.needSync=!0})})}}class F0{constructor(t,n,i,s){this.id=t,this.modules=n,this.options=i,this.type="geojson",this.idToIndex={},this.worker=new this.modules.workers.parser.GeoJsonSource(this.options,this.id,Array.from(s?.modelShowHideEventsSublayers??new Set)),this.attributes=i.attributes||{},this.dataFilter=i.dataFilter}fetchTiles(t){return this.worker.fetchTiles(t).map(n=>n.catch(()=>Promise.resolve()).then(()=>[{regionId:0,metatileHash:-2}]))}async generateTile(t,n,i,s,r){const o=this.options.modelsPath,a=await this.worker.generateTile(t.styleState,n,i,s,r,o,this.dataFilter,t.modelShowHideEventsSublayers);return Array.isArray(a.results)?(a.results[0]&&a.results[0].idToIndex&&(this.idToIndex[Ie(n)]=a.results[0].idToIndex),a):{results:[],transferable:[]}}getObjectAttributes(t,n){return Promise.resolve(this.worker.getObjectAttributes(t,n))}abortTileFetches(t){this.worker.abortTileFetches(t)}deleteTiles(t){for(const n of t)delete this.idToIndex[Ie(n)];this.worker.deleteTiles(t)}setAttributes(t){this.worker.setSourceAttrs(t),this.attributes=t}getAttributes(){return this.attributes}destroy(){this.idToIndex={},this.worker.destroy()}setFeatureStateMap(t){this.worker.setFeatureStateMap(t)}async setData(t){return this.idToIndex={},this.options=typeof t=="string"?this.options={...this.options,url:t}:this.options={...this.options,data:t},await this.worker.setData(t)}getComponentIndex(t,n){return n?this.idToIndex[n]?.[t]:(console.warn("Нет tileKey при идентификации объекта из GeoJsonSource. Пытаемся получить index из id по-старому."),Number.isNaN(+t)?void 0:+t%2**32)}setDataFilter(t){t?this.dataFilter=x(t,{precomputes:[]},Ze.Generator):this.dataFilter=void 0}}let NT=1;function N0(){return NT++}class R0{constructor(t){this.defs=t.map(n=>new RT(n))}check(t){const n=this.defs;let i=!1;for(let s=0;s<n.length;s++)i?n[s].update(t):i=!n[s].equal(t);return i}}class RT{constructor(t){this.path=Array.isArray(t.path)?t.path:[t.path],this.type=t.type,this.type==="number"?(this.last=NaN,this.compare=this.primitive,this.updateFn=this.primitiveUpdate):this.type==="boolean"?(this.last=void 0,this.compare=this.primitive,this.updateFn=this.primitiveUpdate):this.type==="vec2"?(this.last=[NaN,NaN],this.compare=this.vec2,this.updateFn=this.vec2Update):this.type==="vec3"?(this.last=[NaN,NaN,NaN],this.compare=this.vec3,this.updateFn=this.vec3Update):this.type==="string"?(this.last="",this.compare=this.primitive,this.updateFn=this.primitiveUpdate):this.type==="padding"?(this.last={left:0,right:0,bottom:0,top:0},this.compare=this.padding,this.updateFn=this.paddingUpdate):this.type==="replicas"&&(this.last={min:0,max:0},this.compare=this.replicas,this.updateFn=this.replicasUpdate)}equal(t){const n=this.take(t),i=this.compare(this.last,n);return this.updateFn(n),i}update(t){this.updateFn(this.take(t))}take(t){const n=this.path;let i=0;do t=t[n[i++]];while(i<n.length);return t}primitive(t,n){return t===n}padding(t,n){return t.top===n.top&&t.bottom===n.bottom&&t.left===n.left&&t.right===n.right}paddingUpdate(t){this.last.top=t.top,this.last.bottom=t.bottom,this.last.right=t.right,this.last.left=t.left}vec2(t,n){return t[0]===n[0]&&t[1]===n[1]}vec3(t,n){return t[0]===n[0]&&t[1]===n[1]&&t[2]===n[2]}primitiveUpdate(t){this.last=t}vec2Update(t){this.last[0]=t[0],this.last[1]=t[1]}vec3Update(t){this.last[0]=t[0],this.last[1]=t[1],this.last[2]=t[2]}replicas(t,n){const i=n[0],s=n[n.length-1];return t.min===i&&t.max===s}replicasUpdate(t){this.last.min=t[0],this.last.max=t[t.length-1]}}function B0(e,t,n){let i,s,r,o;const a=function(){const d=Date.now()-r;d<t&&d>=0?i=setTimeout(a,t-d):(i=null,n||(o=e(...s),i||(s=null)))};function c(){i!==void 0&&(clearTimeout(i),i=null)}function l(...d){s=d,r=Date.now();const f=n&&!i;return i||(i=setTimeout(a,t)),f&&(o=e(...s),s=null),o}return l.cancel=c,l}const k0=15,bl=17;class U0{constructor(t,n,i){this.type="geojson",this.isCustomPromoteId=!1,this.id=N0(),this.modelsAppearStrategy=n.modelsAppearStrategy??ed,this.modules=t.modules,this.mapglApiSource=i,this.identifiedAsDefault=!!n.identifyAsDefaultSource,n.promoteId&&(this.isCustomPromoteId=!0),this.identifiedAsDefault&&!n.promoteId&&(n.promoteId="db_id"),"generateId"in n&&n.promoteId&&(n.generateId=!1),this.sourceCore=new F0(this.id,this.modules,n);const s=n.minZoom??Yo.minZoom,r=Math.min(n.maxZoom??k0,bl);this.layer=new C0(s,r,s,bl,this.modules,t.state,this.sourceCore,n),this.modules.tileManager.addTileLayer(this.layer)}destroy(){this.modules.tileManager.removeTileLayer(this.layer),this.layer.destroy(),this.modules.sourceStorage.removeSource(this.getId()),this.sourceCore.destroy()}setAttributes(t){this.sourceCore.setAttributes(t),this.layer.redraw(),this.modules.identifier.resetCache()}getAttributes(){return this.sourceCore.getAttributes()}getZoomDirection(){return this.layer.getZoomDirection()}getId(){return this.sourceCore.id}isIdentifiedAsDefault(){return this.identifiedAsDefault}}const Lo={type:"FeatureCollection",features:[]};let z0=class Bp extends U0{constructor(t,n,i){n.generateId=!0,super(t,n,i),this.subtype="internal",this.data=n.data,this instanceof Bp&&this.modules.sourceStorage.addSource(this)}getFeatureById(t,n){if(this.data.type==="FeatureCollection"){let i;const s=this.sourceCore.getComponentIndex(t,n);return s===void 0?(this.isCustomPromoteId&&(i=this.data.features.find(r=>r.id===t)),i):this.data.features[s]}return this.data}destroy(){super.destroy(),this.data=Lo}async setData(t){await this.sourceCore.setData(t)&&(this.data=t,this.layer.onSourceDataChange(),this.modules.identifier.resetCache())}setDataFilter(t){this.sourceCore.setDataFilter(t)}};class BT extends U0{constructor(t,n,i){super(t,n,i),this.subtype="external",n.preventInteractions&&(n.promoteId=void 0),this.modules.sourceStorage.addSource(this)}getObjectAttributes(t,n){return this.sourceCore.getObjectAttributes(t,n)}async setDataUrl(t){await this.sourceCore.setData(t)&&(this.layer.onSourceDataChange(),this.modules.identifier.resetCache())}}let kT=class extends z0{constructor(t,n,i){super(t,n,i),this.subtype="viewport-internal",this.destroyed=!1,this.viewportDiffer=new R0([{path:"center",type:"vec3"},{path:"zoom",type:"number"},{path:"size",type:"vec2"},{path:"rotation",type:"number"},{path:"pitch",type:"number"},{path:"padding",type:"padding"},{path:"demMode",type:"boolean"},{path:"elevation",type:"number"},{path:"minElevation",type:"number"}]),this._map=t,this.viewportPadding=n.viewportPadding,this.modules.sourceStorage.addSource(this)}async setDataFn(t){this.setViewportHandler(t)}setViewportPadding(t){this.viewportPadding=t,this.viewportHandler&&this.viewportHandler()}update(){this.viewportDiffer.check(this._map.state)&&this.viewportHandler&&this.viewportHandler()}destroy(){this.destroyed=!0,this.viewportHandler&&(this.viewportHandler.cancel(),this.viewportHandler=void 0),super.destroy()}setViewportHandler(t){if(!t){this.setData(Lo),this.viewportHandler=void 0;return}this.viewportHandler=B0(async()=>{const n=this._map.getBounds({sizeExtension:this.viewportPadding}),i=n.southWest,s=n.northEast,r=[i[0],i[1],s[0],s[1]],o=t(r);let a=Lo;try{const c=await fetch(o);c.ok||console.error(`Failed to fetch a tile by url "${o}", status: ${c.status}`);const l=c.headers.get("content-type");(!l||!l.includes("application/json"))&&console.error(`Failed to fetch a tile by url "${o}", expected the "application/json" data but got "${l}"`),a=await c.json()}catch(c){console.error(`Failed to fetch a tile by url "${o}", message: ${c.message}`)}this.destroyed||this.setData(a)},500),this.viewportHandler()}};function Do(e,t){const n=new XMLHttpRequest;if(n.open("GET",e.url,!0),n.responseType="arraybuffer",e.headers)for(const i in e.headers)n.setRequestHeader(i,e.headers[i]);return n.onerror=function(){t({status:0,message:"Network error"},new ArrayBuffer(0))},n.onload=function(){n.status>=200&&n.status<300&&n.response?t(void 0,n.response):t({status:n.status,message:n.statusText},new ArrayBuffer(0))},n.send(),n}function G0(e,t){const n=new XMLHttpRequest;if(n.open("GET",e.url,!0),e.headers)for(const i in e.headers)n.setRequestHeader(i,e.headers[i]);return n.onerror=function(){t({status:0,message:"Network error"},{})},n.onload=function(){if(n.status>=200&&n.status<300){if(!n.response||!n.response.length)return t({status:204,message:"No content"},{});let i;try{i=JSON.parse(n.response),t(void 0,i)}catch{t({status:0,message:`Json parse data error from url ${e.url}`},{})}}else t({status:n.status,message:n.statusText},{})},n.send(),n}function j0(e){return e?e>=500&&e<=599:!1}function H0(e){return new Promise(t=>setTimeout(t,e))}class UT{constructor(){this.cache=new Map,this.pendingRequests=new Map}async fetch(t,n=3,i=300){let s=0,r;for(;s<=n;)try{if(r=await this.fetchAttempt(t),!r)return;if(!r.err||!j0(r.err?.status))return r;throw new Error(`Fetching ${JSON.stringify(t.coords)} attempt ${s} failed.`)}catch{if(s>=n)return{metadata:[]};await H0(Math.pow(2,s)*i),s++}}get(t){return this.cache.get(t)||[]}delete(t){this.cache.delete(t)}abortRequest(t){const n=this.pendingRequests.get(t);n!==void 0&&(n.xhr.abort(),n.resolve(),this.pendingRequests.delete(t))}destroy(){this.cache.clear(),this.pendingRequests.clear()}fetchAttempt({tileUrl:t,coords:n}){return new Promise(i=>{const s=Ie(n),r=Do({url:t},(o,a)=>{if(this.pendingRequests.delete(s),o||a.byteLength===0){o!==void 0&&console.error(o),this.cache.set(s,[]),i({metadata:[],err:o});return}const c=Iy(a),l=My(c);this.cache.set(s,c),i({metadata:l,err:o})});this.pendingRequests.set(s,{xhr:r,resolve:i})})}}class Il extends Map{constructor(t){super(t),this.featureAttrs=t?.featureAttrs||new Set,this.clearAttrs=!0}set(t,n){return super.set(t,n),Object.keys(n).forEach(i=>this.featureAttrs.add(i)),this}}function Ml(e){for(let t=1;t<e.length;t++)e[t]=e[t]+e[t-1]}function zT(e){let t=0,n=0,i=0;for(let s=0;s<e.length;s+=2)i=n+e[s],n=i>>>0,e[s]=n,t=t+e[s+1]+(i>4294967295?1:0)>>>0,e[s+1]=t}const V0={1:Ml,2:Ml,4:Ml,8:zT};class $0{constructor(t){this.offset=0,this.buffer=t,this.u8=new Uint8Array(t),this.u16=new Uint16Array(t),this.u32=new Uint32Array(t),this.s8=new Int8Array(t),this.s16=new Int16Array(t),this.s32=new Int32Array(t),this.f32=new Float32Array(t)}readS8(){return this.s8[this.offset++]}readU16(){const t=this.u16[this.offset>>1];return this.offset+=2,t}readU32(){const t=this.u32[this.offset>>2];return this.offset+=4,t}readF32(){const t=this.f32[this.offset>>2];return this.offset+=4,t}readU8Vector(t=1){const i=this.readU32()*t,s=-i&3,r=this.u8.subarray(this.offset,this.offset+i);return this.offset+=i+s,r}readU16Vector(t=1){const i=this.readU32()*t*2,s=-i&3,r=this.u16.subarray(this.offset>>1,this.offset+i>>1);return this.offset+=i+s,r}}function De(e,t,n,i){const s=t.BYTES_PER_ELEMENT;e.offset+=-e.offset&s-1;const r=new t(e.buffer,e.offset,n);return e.offset+=s*n,i&&V0[s](r),r}function Oo(e,t,n){e.offset+=-e.offset&7;const i=new Uint32Array(e.buffer,e.offset,t*2);return e.offset+=8*t,n&&V0[8](i),i}function Y0(e,t,n){e.offset+=-e.offset&3;const i=new Uint32Array(e.buffer,e.offset,t),s=new Float32Array(e.buffer,e.offset,t);e.offset+=4*t;let r;if(n){let o=0;for(r=0;r<t;r++)o=o+i[r]>>>0,s[r]=o/1e3}else for(r=0;r<t;r++)s[r]=i[r]/1e3;return s}function Z0(e,t,n){e.offset+=-e.offset&3;const i=new Int32Array(e.buffer,e.offset,t),s=new Float32Array(e.buffer,e.offset,t);e.offset+=4*t;let r;if(n){let o=0;for(r=0;r<t;r++)o=o+i[r]>>>0,s[r]=(o|0)/1e3}else for(r=0;r<t;r++)s[r]=i[r]/1e3;return s}function GT(e,t){let n=e.offset;const i=e.u8,s=e.buffer,r=[];for(;t--;)r.push(i[n++]|0);const o=[];for(;++t<r.length;){let a=r[t];a===255&&(a=i[n++]|i[n++]<<8|i[n++]<<16|0),o.push(new Uint8Array(s,n,a)),n=n+a}return e.offset=n,o}function jT(e,t){e.offset+=-e.offset&3;let n=e.offset;const i=e.u32,s=e.buffer,r=[];for(let a=0;a<t;a++)r.push(i[n>>2]),n+=4;const o=[];for(let a=0;a<t;a++){const c=r[a];n+=-n&7,o.push(new Uint8Array(s,n,c)),n+=c}return e.offset=n,o}function HT(e,t,n){switch(n){case 2:return De(e,Uint8Array,t);case 3:return De(e,Uint8Array,t,!0);case 4:return De(e,Uint16Array,t);case 5:return De(e,Uint16Array,t,!0);case 6:return De(e,Uint32Array,t);case 7:return De(e,Uint32Array,t,!0);case 8:return Oo(e,t);case 9:return Oo(e,t,!0);case 10:return De(e,Uint8Array,t);case 11:return GT(e,t);case 12:return jT(e,t);case 13:return De(e,Int8Array,t);case 14:return De(e,Int8Array,t,!0);case 15:return De(e,Int16Array,t);case 16:return De(e,Int16Array,t,!0);case 17:return De(e,Int32Array,t);case 18:return De(e,Int32Array,t,!0);case 19:return Oo(e,t);case 20:return Oo(e,t,!0);case 21:return Y0(e,t);case 22:return Y0(e,t,!0);case 23:return Z0(e,t);case 24:return Z0(e,t,!0);case 25:return De(e,Uint32Array,t);default:throw new Error("Unknown stream type "+n)}}function Tl(e){let t=0;for(let n=0;n<e.length;n++)t+=e[n];return t}function VT(e,t,n){return new e.constructor(e.buffer,e.byteOffset+t*e.BYTES_PER_ELEMENT,n)}let Un;const ji=[],Rt=new Int32Array(256);let Sl;const Al=[],W0=[],X0=[],El=[0,0,0,0,0];let q0=0,xl=0,_l=0,Hi={};function $T(e,t,n,i,s,r,o,a,c=!1,l,d,f,u){const{styleState:h,sourceId:y,sourceAttrs:w,tileInfo:p,pixelRatio:g,selectedIds:b,dataFilter:v,floorsEnabled:M,hoverId:E,generateOnlySelectedPoi:T,generateOnlyHoveredPoi:L,modelsPath:A}=s,{data:P}=r,R=new Set(b),k=Ty(P);if(k.byteLength<8)return i.getAccumulatedData();ji.length=0;const V=new $0(k);if(V.readU32()!==1279676242)return i.getAccumulatedData();const $=V.readU16();if($!==2&&$!==3&&$!==4)return console.error(`Unsupported tile format version: "${$}"`),i.getAccumulatedData();Un=$,V.readU16();const ee=ec(g);return YT(V),ZT(V),WT(Un,e,t,h,n,i,V,p,ee,R,v,o,a,M,y,w,c,E,T,L,A,l,d,f,u),i.getAccumulatedData()}function YT(e){const t=Un===4?2:1,n=e.u8;let i=e.offset,s=e.u32[i>>2];for(i+=4,q0=s,xl=i;s--;)i=n[i++]*2+i,i=n[i++]*t+i;e.offset=i+(-i&3)}function ZT(e){const t=e.u32[e.offset>>2];e.offset+=4,Sl=De(e,Uint8Array,t);const n=De(e,Uint32Array,t);for(let i=0;i<t;i++){const s=Sl[i];ji[i]=HT(e,n[i],s),Rt[i]=0}}function WT(e,t,n,i,s,r,o,a,c,l,d,f,u,h,y,w,p=!1,g,b,v,M,E,T,L,A){const P=Array.from(s.featureAttrs);as(f,P);const R=q0,k=De(o,Int32Array,R),V=Tl(k),z=De(o,Uint8Array,V,!0),$=De(o,Uint8Array,Tl(z),!0),ee=De(o,Uint8Array,V,!0),I=De(o,Uint8Array,Tl(ee),!0),_=De(o,Uint16Array,V,!0);let S=0,D=0,O=0,C=!0;for(let F=0;F<R;F++){const U=k[F];KT(o,f,u);for(let j=0;j<U;j++){const N=z[S];N>0&&(XT(u,N,$,D,f,e,p),D+=N);const H=ee[S];if(H>0&&(qT(u,H,I,O),O+=H),!u[f.tileProps.db_geometry_type]){console.error(`Geometry type not specified for data source ${y}. Metatile version ${f.version}`);return}C=N>0||H>0;const q=f.tileProps;let X=u[q[L??""]];Number.isNaN(X)&&(X=void 0);const te=ws(i,w,q,u,[],X,a),W=_[S];W>0&&JT(e,t,n,i,te,s,r,W,a,c,l,d,f,h,y,g,b,v,M,E,C,T,A),S++}}J0()}function XT(e,t,n,i,s,r,o=!1){for(;t--;){const a=n[i++],c=W0[a],l=Al[a],d=Sl[c];if(d===8||d===9||d===19||d===20)e[l]=Sh(ji[c][Rt[c]],ji[c][Rt[c]+1]),Rt[c]+=2;else{const f=ji[c][Rt[c]];switch(l){case s.tileProps.objectLength:case s.tileProps.db_centroid_x:case s.tileProps.db_centroid_y:case s.tileProps.componentDistanceEnd:case s.tileProps.componentDistanceStart:case s.tileProps.previousPointX:case s.tileProps.previousPointY:case s.tileProps.nextPointX:case s.tileProps.nextPointY:e[l]=r===2?f*yi:f;break;case s.tileProps.db_label:e[l]=Pr(f);break;case s.tileProps.db_label2:e[l]=Pr(f);break;case s.tileProps.db_schedule:e[l]=JSON.parse(Pr(f));break;case s.tileProps.db_tiers:const u=f.byteLength/Int32Array.BYTES_PER_ELEMENT,h=new DataView(f.buffer,f.byteOffset,f.byteLength),y=h.getInt32(0,!0);if(u===1&&!y)e[l]=void 0;else{const w=new Array(u);w[0]=y;for(let p=1;p<u;p++)w[p]=h.getInt32(p*Int32Array.BYTES_PER_ELEMENT,!0);e[l]=w}break;default:if(o&&d===11)e[l]=Pr(f);else{const w=s.tilePropsByIndex[l];e[l]=s.reverseDictionaries[w]?.[f]??f}}Rt[c]++}}}function qT(e,t,n,i){for(;t--;){const s=n[i++],r=Al[s];e[r]=NaN}}let Co=[];function JT(e,t,n,i,s,r,o,a,c,l,d,f,u,h,y,w,p,g,b,v=[],M,E,T){const{tileProps:L,defaultProps:A}=u,{tileAttrs:P,featureAttrs:R,id:k}=s,V=c.coords[3],z=L.db_hidden_by_plan_id!==void 0;if(!M&&Co.length===0){for(let I=0;I<_l;I++){const _=El[I];Rt[_]=Rt[_]+a}return}const $=P[L.db_geometry_type],ee=Un===4?u.vertexProps:u.vertexPropsLegacy[$];if(!ee){console.error(`Couldn't get vertex keys for tile ${Ie(c.coords)} source ${y}. Metatile version ${u.version}`);return}for(let I=0;I<_l;I++){const _=Un===4?X0[I]:I,S=El[I],D=ee[_]??"signed_z";Hi[D]=QT(VT(ji[S],Rt[S],a),I,e),Un===4&&D==="z"&&(Hi.signed_z=Hi.z),Rt[S]=Rt[S]+a}if(!(L.db_sublayer!==void 0&&!Number.isNaN(P[L.db_sublayer])&&fo(P[L.db_sublayer]))&&!(z&&i._activeFloorIds&&P[L.db_hidden_by_plan_id]&&i._activeFloorIds.includes(P[L.db_hidden_by_plan_id]))){for(const I in A){const _=A[I];Number.isNaN(P[_.index])&&(P[_.index]=_.value)}if(!(w&&w!==k)){if(k!==void 0){let I=d.has(k);p&&(I=!0);const _=!!g||!!w&&w===k;if(P[L.selected]=I?1:0,P[L.hovered]=_?1:0,v.length>0){const S={};v.forEach(D=>{S[D]=P[L[D]]}),o.addPromotedObjectAttributes(k,S)}h&&V>=Ko.detailLevel&&(P[L.db_hidden_by_plan_building_id]&&o.addFloorHidingMap(k,P[L.db_hidden_by_plan_building_id]),P[L.db_hidden_by_metro_building_id]&&o.addFloorHidingMap(k,P[L.db_hidden_by_metro_building_id]))}else P[L.selected]=0,P[L.hovered]=0;if(r.featureAttrs.size>0){const I=k!==void 0&&r.get(k);if(I)for(const _ of r.featureAttrs)r.clearAttrs=!1,R[L[_]]=I[_];else if(r.clearAttrs===!1){r.clearAttrs=!0;for(const _ in L)R[L[_]]!==void 0&&(R[L[_]]=void 0)}}if(E){const I=eS(Hi,$,c);if(I){const _=tS(s,Ie(c.coords));o.addFeature({type:"Feature",properties:_,geometry:I})}return}M&&(Co=n.getLayers(t.id,L,P).filter(I=>G(I.filter,s)&&(f?G(f,s):!0))),Co.length===0&&s.id&&o.idIndexer.addOrphanId(s.id),el(o,t,Co,s,u,Un,V,y,c,l,Hi,p||g,b,T)}}}function KT(e,t,n){const i=Object.keys(t.tileProps).length,s=e.u8;let r,o,a=xl;for(o=1;o<i;o++)n[o]=NaN;for(r=s[a++],o=0;o<r;o++)Al[o]=s[a++],W0[o]=s[a++];for(r=s[a++],o=0;o<r;o++)Un===4&&(X0[o]=s[a++]),El[o]=s[a++];_l=r,xl=a,J0()}function J0(){Hi={}}function QT(e,t,n){if(n===2&&t<3&&e instanceof Uint16Array)for(let i=0;i<e.length;i++)e[i]*=yi;return e}function eS(e,t,n){const i=[],{x:s,y:r,z:o,signed_z:a}=e;for(let c=0;c<e.x.length;c++){const l=ls(s[c],r[c],n),d=oe.scaleFactor(l[1]),f=o?o[c]*32:void 0;l[2]=f??a?.[c]??0,l[2]/=me*d,i.push(l)}if(i.length)switch(t){case"point":return{type:"MultiPoint",coordinates:i};case"polyline":return{type:"LineString",coordinates:i};case"polygon":return{type:"Polygon",coordinates:[i.map((c,l)=>i[et(l,i.length)])]};default:return}}function tS(e,t){const n={tile:t};return Object.keys(e.tileProps).forEach(i=>{const s=e.tileAttrs[e.tileProps[i]];!Number.isNaN(s)&&s!==void 0&&(n[i]=s)}),n}const nS=e=>{if(e.length>2){let t=0;for(let n=e.length-1,i=n,s=0;s<=n;s++){const r=e[i],o=e[s];t+=(r[0]+o[0])*(r[1]-o[1]),i=s}return t/2}else return 0},iS=e=>nS(e)>0;function sS(e){e=e.slice().sort(rS);const t=e.length,n=new Array(t*2);let i=0;for(let r=0;r<t;r++){const o=e[r];for(;i>=2&&K0(n[i-2],n[i-1],o)<=0;)i--;n[i++]=o}const s=i+1;for(let r=t-2;r>=0;r--){const o=e[r];for(;i>=s&&K0(n[i-2],n[i-1],o)<=0;)i--;n[i++]=o}return n.slice(0,i-1)}function K0(e,t,n){return(t[1]-e[1])*(n[0]-e[0])-(t[0]-e[0])*(n[1]-e[1])}function rS(e,t){return e[0]===t[0]?e[1]-t[1]:e[0]-t[0]}function oS(e){const t=[],n=iS(e),i=sr(e[0],e[e.length-1]),s=i?e.length-1:e.length;for(let r=s-1,o=0,a=1;o<s;o++,r=o-1,a=(o+1)%s){const c=[];x1(c,e[r],e[o],e[a],n),t.push(c)}return i&&t.push(t[0]),t}const Fo=[[0],[0],[0]],Q0=[];function aS(e,t,n,i,s,r,o,a,c){const{matrix:l,offset:d,id:f,selected:u}=r,h=new $0(s),y=[];if(!e)return{objects:i.getAccumulatedData(),textures:y};if(h.readU32()!==1296191066||h.readU16()!==1)return{objects:i.getAccumulatedData(),textures:[]};h.readU16();const w=h.readU32();for(let A=0;A<w;A++)y.push(h.readU8Vector());const{tileProps:p}=o,g=[],b=Object.keys(p).length;for(let A=0;A<b;A++)g[A]=NaN;if(g[p.db_sublayer]="Building_model",g[p.selected]=u?1:0,g[p.db_region]=a,c.featureAttrs.size>0){const A=Array.from(c.featureAttrs);as(o,A)}const v=[],M=typeof f!="number"&&c.get(f);if(M)for(const A of c.featureAttrs)c.clearAttrs=!1,v[p[A]]=M[A];else if(c.clearAttrs===!1){c.clearAttrs=!0;for(const A in p)v[p[A]]!==void 0&&(v[p[A]]=void 0)}const E=h.offset,T=ws(n,Ea,p,g,v,f),L=t.getLayers(e.id,p,g).filter(A=>G(A.filter,T));return L.length===0&&T.id&&i.idIndexer.addOrphanId(T.id),L.forEach(A=>{A.type!=="buildingModel"||(Qc(A,T),!G(A.filter,T))||(h.offset=E,cS(e,A,T,i,h,l,d))}),{objects:i.getAccumulatedData(),textures:y}}function cS(e,t,n,i,s,r,o){const a=s.readU32();for(let c=0;c<a;c++){const l=s.readU32(),d=qe(s.readF32(),s.readF32(),s.readF32()),f=qe(s.readF32(),s.readF32(),s.readF32()),u=Gt(rt(),f,d),h=[];Rd(h,r,d),bi(h,h,u),h[12]+=o[0],h[13]+=o[1];const y=s.readU16Vector(5),w=s.readU32();for(let v=0;v<w;v++){const M=s.readU32()===1?Qp:Js,E=s.readU16Vector();do an.processSubmesh(e.id,t,n,i,y,E,M,l,h);while(i.isOverloaded())}const p=s.readU16Vector();do an.processOuterEdge(e.id,t,n,i,y,p,h);while(i.isOverloaded());const g=sS(lS(y)),b=oS(g);for(let v=0;v<g.length-2;v++){for(let M=0;M<3;M++){const E=dS(v+M,g.length);Fo[0][M]=g[E][0],Fo[1][M]=g[E][1],Fo[2][M]=0,Q0[M]=b[E]}do Mt.generateFloorsBottomFill(i,e.id,Fo,Q0,Gr,h);while(i.isOverloaded())}}}function lS(e){const t=[];for(let n=0;n<e.length;n+=5)t.push([e[n],e[n+1]]);return t}function dS(e,t){return e===0?0:e%2?(e+1)/2:t-e/2}function fS(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Pl={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */Pl.read=function(e,t,n,i,s){var r,o,a=s*8-i-1,c=(1<<a)-1,l=c>>1,d=-7,f=n?s-1:0,u=n?-1:1,h=e[t+f];for(f+=u,r=h&(1<<-d)-1,h>>=-d,d+=a;d>0;r=r*256+e[t+f],f+=u,d-=8);for(o=r&(1<<-d)-1,r>>=-d,d+=i;d>0;o=o*256+e[t+f],f+=u,d-=8);if(r===0)r=1-l;else{if(r===c)return o?NaN:(h?-1:1)*(1/0);o=o+Math.pow(2,i),r=r-l}return(h?-1:1)*o*Math.pow(2,r-i)},Pl.write=function(e,t,n,i,s,r){var o,a,c,l=r*8-s-1,d=(1<<l)-1,f=d>>1,u=s===23?Math.pow(2,-24)-Math.pow(2,-77):0,h=i?0:r-1,y=i?1:-1,w=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,o=d):(o=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-o))<1&&(o--,c*=2),o+f>=1?t+=u/c:t+=u*Math.pow(2,1-f),t*c>=2&&(o++,c/=2),o+f>=d?(a=0,o=d):o+f>=1?(a=(t*c-1)*Math.pow(2,s),o=o+f):(a=t*Math.pow(2,f-1)*Math.pow(2,s),o=0));s>=8;e[n+h]=a&255,h+=y,a/=256,s-=8);for(o=o<<s|a,l+=s;l>0;e[n+h]=o&255,h+=y,o/=256,l-=8);e[n+h-y]|=w*128};var uS=ue,No=Pl;function ue(e){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(e)?e:new Uint8Array(e||0),this.pos=0,this.type=0,this.length=this.buf.length}ue.Varint=0,ue.Fixed64=1,ue.Bytes=2,ue.Fixed32=5;var Ll=65536*65536,ep=1/Ll,hS=12,tp=typeof TextDecoder>"u"?null:new TextDecoder("utf8");ue.prototype={destroy:function(){this.buf=null},readFields:function(e,t,n){for(n=n||this.length;this.pos<n;){var i=this.readVarint(),s=i>>3,r=this.pos;this.type=i&7,e(s,t,this),this.pos===r&&this.skip(i)}return t},readMessage:function(e,t){return this.readFields(e,t,this.readVarint()+this.pos)},readFixed32:function(){var e=Ro(this.buf,this.pos);return this.pos+=4,e},readSFixed32:function(){var e=ip(this.buf,this.pos);return this.pos+=4,e},readFixed64:function(){var e=Ro(this.buf,this.pos)+Ro(this.buf,this.pos+4)*Ll;return this.pos+=8,e},readSFixed64:function(){var e=Ro(this.buf,this.pos)+ip(this.buf,this.pos+4)*Ll;return this.pos+=8,e},readFloat:function(){var e=No.read(this.buf,this.pos,!0,23,4);return this.pos+=4,e},readDouble:function(){var e=No.read(this.buf,this.pos,!0,52,8);return this.pos+=8,e},readVarint:function(e){var t=this.buf,n,i;return i=t[this.pos++],n=i&127,i<128||(i=t[this.pos++],n|=(i&127)<<7,i<128)||(i=t[this.pos++],n|=(i&127)<<14,i<128)||(i=t[this.pos++],n|=(i&127)<<21,i<128)?n:(i=t[this.pos],n|=(i&15)<<28,pS(n,e,this))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var e=this.readVarint();return e%2===1?(e+1)/-2:e/2},readBoolean:function(){return!!this.readVarint()},readString:function(){var e=this.readVarint()+this.pos,t=this.pos;return this.pos=e,e-t>=hS&&tp?PS(this.buf,t,e):_S(this.buf,t,e)},readBytes:function(){var e=this.readVarint()+this.pos,t=this.buf.subarray(this.pos,e);return this.pos=e,t},readPackedVarint:function(e,t){if(this.type!==ue.Bytes)return e.push(this.readVarint(t));var n=pn(this);for(e=e||[];this.pos<n;)e.push(this.readVarint(t));return e},readPackedSVarint:function(e){if(this.type!==ue.Bytes)return e.push(this.readSVarint());var t=pn(this);for(e=e||[];this.pos<t;)e.push(this.readSVarint());return e},readPackedBoolean:function(e){if(this.type!==ue.Bytes)return e.push(this.readBoolean());var t=pn(this);for(e=e||[];this.pos<t;)e.push(this.readBoolean());return e},readPackedFloat:function(e){if(this.type!==ue.Bytes)return e.push(this.readFloat());var t=pn(this);for(e=e||[];this.pos<t;)e.push(this.readFloat());return e},readPackedDouble:function(e){if(this.type!==ue.Bytes)return e.push(this.readDouble());var t=pn(this);for(e=e||[];this.pos<t;)e.push(this.readDouble());return e},readPackedFixed32:function(e){if(this.type!==ue.Bytes)return e.push(this.readFixed32());var t=pn(this);for(e=e||[];this.pos<t;)e.push(this.readFixed32());return e},readPackedSFixed32:function(e){if(this.type!==ue.Bytes)return e.push(this.readSFixed32());var t=pn(this);for(e=e||[];this.pos<t;)e.push(this.readSFixed32());return e},readPackedFixed64:function(e){if(this.type!==ue.Bytes)return e.push(this.readFixed64());var t=pn(this);for(e=e||[];this.pos<t;)e.push(this.readFixed64());return e},readPackedSFixed64:function(e){if(this.type!==ue.Bytes)return e.push(this.readSFixed64());var t=pn(this);for(e=e||[];this.pos<t;)e.push(this.readSFixed64());return e},skip:function(e){var t=e&7;if(t===ue.Varint)for(;this.buf[this.pos++]>127;);else if(t===ue.Bytes)this.pos=this.readVarint()+this.pos;else if(t===ue.Fixed32)this.pos+=4;else if(t===ue.Fixed64)this.pos+=8;else throw new Error("Unimplemented type: "+t)},writeTag:function(e,t){this.writeVarint(e<<3|t)},realloc:function(e){for(var t=this.length||16;t<this.pos+e;)t*=2;if(t!==this.length){var n=new Uint8Array(t);n.set(this.buf),this.buf=n,this.length=t}},finish:function(){return this.length=this.pos,this.pos=0,this.buf.subarray(0,this.length)},writeFixed32:function(e){this.realloc(4),Vi(this.buf,e,this.pos),this.pos+=4},writeSFixed32:function(e){this.realloc(4),Vi(this.buf,e,this.pos),this.pos+=4},writeFixed64:function(e){this.realloc(8),Vi(this.buf,e&-1,this.pos),Vi(this.buf,Math.floor(e*ep),this.pos+4),this.pos+=8},writeSFixed64:function(e){this.realloc(8),Vi(this.buf,e&-1,this.pos),Vi(this.buf,Math.floor(e*ep),this.pos+4),this.pos+=8},writeVarint:function(e){if(e=+e||0,e>268435455||e<0){yS(e,this);return}this.realloc(4),this.buf[this.pos++]=e&127|(e>127?128:0),!(e<=127)&&(this.buf[this.pos++]=(e>>>=7)&127|(e>127?128:0),!(e<=127)&&(this.buf[this.pos++]=(e>>>=7)&127|(e>127?128:0),!(e<=127)&&(this.buf[this.pos++]=e>>>7&127)))},writeSVarint:function(e){this.writeVarint(e<0?-e*2-1:e*2)},writeBoolean:function(e){this.writeVarint(!!e)},writeString:function(e){e=String(e),this.realloc(e.length*4),this.pos++;var t=this.pos;this.pos=LS(this.buf,e,this.pos);var n=this.pos-t;n>=128&&np(t,n,this),this.pos=t-1,this.writeVarint(n),this.pos+=n},writeFloat:function(e){this.realloc(4),No.write(this.buf,e,this.pos,!0,23,4),this.pos+=4},writeDouble:function(e){this.realloc(8),No.write(this.buf,e,this.pos,!0,52,8),this.pos+=8},writeBytes:function(e){var t=e.length;this.writeVarint(t),this.realloc(t);for(var n=0;n<t;n++)this.buf[this.pos++]=e[n]},writeRawMessage:function(e,t){this.pos++;var n=this.pos;e(t,this);var i=this.pos-n;i>=128&&np(n,i,this),this.pos=n-1,this.writeVarint(i),this.pos+=i},writeMessage:function(e,t,n){this.writeTag(e,ue.Bytes),this.writeRawMessage(t,n)},writePackedVarint:function(e,t){t.length&&this.writeMessage(e,vS,t)},writePackedSVarint:function(e,t){t.length&&this.writeMessage(e,bS,t)},writePackedBoolean:function(e,t){t.length&&this.writeMessage(e,TS,t)},writePackedFloat:function(e,t){t.length&&this.writeMessage(e,IS,t)},writePackedDouble:function(e,t){t.length&&this.writeMessage(e,MS,t)},writePackedFixed32:function(e,t){t.length&&this.writeMessage(e,SS,t)},writePackedSFixed32:function(e,t){t.length&&this.writeMessage(e,AS,t)},writePackedFixed64:function(e,t){t.length&&this.writeMessage(e,ES,t)},writePackedSFixed64:function(e,t){t.length&&this.writeMessage(e,xS,t)},writeBytesField:function(e,t){this.writeTag(e,ue.Bytes),this.writeBytes(t)},writeFixed32Field:function(e,t){this.writeTag(e,ue.Fixed32),this.writeFixed32(t)},writeSFixed32Field:function(e,t){this.writeTag(e,ue.Fixed32),this.writeSFixed32(t)},writeFixed64Field:function(e,t){this.writeTag(e,ue.Fixed64),this.writeFixed64(t)},writeSFixed64Field:function(e,t){this.writeTag(e,ue.Fixed64),this.writeSFixed64(t)},writeVarintField:function(e,t){this.writeTag(e,ue.Varint),this.writeVarint(t)},writeSVarintField:function(e,t){this.writeTag(e,ue.Varint),this.writeSVarint(t)},writeStringField:function(e,t){this.writeTag(e,ue.Bytes),this.writeString(t)},writeFloatField:function(e,t){this.writeTag(e,ue.Fixed32),this.writeFloat(t)},writeDoubleField:function(e,t){this.writeTag(e,ue.Fixed64),this.writeDouble(t)},writeBooleanField:function(e,t){this.writeVarintField(e,!!t)}};function pS(e,t,n){var i=n.buf,s,r;if(r=i[n.pos++],s=(r&112)>>4,r<128||(r=i[n.pos++],s|=(r&127)<<3,r<128)||(r=i[n.pos++],s|=(r&127)<<10,r<128)||(r=i[n.pos++],s|=(r&127)<<17,r<128)||(r=i[n.pos++],s|=(r&127)<<24,r<128)||(r=i[n.pos++],s|=(r&1)<<31,r<128))return mS(e,s,t);throw new Error("Expected varint not more than 10 bytes")}function pn(e){return e.type===ue.Bytes?e.readVarint()+e.pos:e.pos+1}function mS(e,t,n){return n?t*4294967296+(e>>>0):(t>>>0)*4294967296+(e>>>0)}function yS(e,t){var n,i;if(e>=0?(n=e%4294967296|0,i=e/4294967296|0):(n=~(-e%4294967296),i=~(-e/4294967296),n^4294967295?n=n+1|0:(n=0,i=i+1|0)),e>=18446744073709552e3||e<-18446744073709552e3)throw new Error("Given varint doesn't fit into 10 bytes");t.realloc(10),gS(n,i,t),wS(i,t)}function gS(e,t,n){n.buf[n.pos++]=e&127|128,e>>>=7,n.buf[n.pos++]=e&127|128,e>>>=7,n.buf[n.pos++]=e&127|128,e>>>=7,n.buf[n.pos++]=e&127|128,e>>>=7,n.buf[n.pos]=e&127}function wS(e,t){var n=(e&7)<<4;t.buf[t.pos++]|=n|((e>>>=3)?128:0),e&&(t.buf[t.pos++]=e&127|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=e&127|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=e&127|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=e&127|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=e&127)))))}function np(e,t,n){var i=t<=16383?1:t<=2097151?2:t<=268435455?3:Math.floor(Math.log(t)/(Math.LN2*7));n.realloc(i);for(var s=n.pos-1;s>=e;s--)n.buf[s+i]=n.buf[s]}function vS(e,t){for(var n=0;n<e.length;n++)t.writeVarint(e[n])}function bS(e,t){for(var n=0;n<e.length;n++)t.writeSVarint(e[n])}function IS(e,t){for(var n=0;n<e.length;n++)t.writeFloat(e[n])}function MS(e,t){for(var n=0;n<e.length;n++)t.writeDouble(e[n])}function TS(e,t){for(var n=0;n<e.length;n++)t.writeBoolean(e[n])}function SS(e,t){for(var n=0;n<e.length;n++)t.writeFixed32(e[n])}function AS(e,t){for(var n=0;n<e.length;n++)t.writeSFixed32(e[n])}function ES(e,t){for(var n=0;n<e.length;n++)t.writeFixed64(e[n])}function xS(e,t){for(var n=0;n<e.length;n++)t.writeSFixed64(e[n])}function Ro(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16)+e[t+3]*16777216}function Vi(e,t,n){e[n]=t,e[n+1]=t>>>8,e[n+2]=t>>>16,e[n+3]=t>>>24}function ip(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16)+(e[t+3]<<24)}function _S(e,t,n){for(var i="",s=t;s<n;){var r=e[s],o=null,a=r>239?4:r>223?3:r>191?2:1;if(s+a>n)break;var c,l,d;a===1?r<128&&(o=r):a===2?(c=e[s+1],(c&192)===128&&(o=(r&31)<<6|c&63,o<=127&&(o=null))):a===3?(c=e[s+1],l=e[s+2],(c&192)===128&&(l&192)===128&&(o=(r&15)<<12|(c&63)<<6|l&63,(o<=2047||o>=55296&&o<=57343)&&(o=null))):a===4&&(c=e[s+1],l=e[s+2],d=e[s+3],(c&192)===128&&(l&192)===128&&(d&192)===128&&(o=(r&15)<<18|(c&63)<<12|(l&63)<<6|d&63,(o<=65535||o>=1114112)&&(o=null))),o===null?(o=65533,a=1):o>65535&&(o-=65536,i+=String.fromCharCode(o>>>10&1023|55296),o=56320|o&1023),i+=String.fromCharCode(o),s+=a}return i}function PS(e,t,n){return tp.decode(e.subarray(t,n))}function LS(e,t,n){for(var i=0,s,r;i<t.length;i++){if(s=t.charCodeAt(i),s>55295&&s<57344)if(r)if(s<56320){e[n++]=239,e[n++]=191,e[n++]=189,r=s;continue}else s=r-55296<<10|s-56320|65536,r=null;else{s>56319||i+1===t.length?(e[n++]=239,e[n++]=191,e[n++]=189):r=s;continue}else r&&(e[n++]=239,e[n++]=191,e[n++]=189,r=null);s<128?e[n++]=s:(s<2048?e[n++]=s>>6|192:(s<65536?e[n++]=s>>12|224:(e[n++]=s>>18|240,e[n++]=s>>12&63|128),e[n++]=s>>6&63|128),e[n++]=s&63|128)}return n}const DS=fS(uS),OS=1,Dl={1:({pbf:e})=>e.readBoolean(),2:({pbf:e})=>e.readDouble(),3:({pbf:e})=>e.readString(),5:e=>{const{pbf:t}=e,n=t.readVarint(),i=new Array(n);for(let s=0;s<n;s++)i[s]=Ol(e,t.readVarint());return i},4:e=>{const{pbf:t}=e,n=t.readVarint(),i={};for(let r=0;r<n;r++){var s=t.readVarint();i[e.keys[s>>3]]=Ol(e,s&7)}return i},6:e=>null};function Ol(e,t){const n=e.pbf;if(n.pos<n.length){const i=Dl[t];if(!i)throw new Error(`Type ${t} is not supported`);return i(e)}}function sp(e){const t=e.readVarint(),n=[];for(let i=0;i<t;i++){const s=e.readString(),r=e.readVarint();n.push({key:s,type:r})}return n}function CS(e,t){if(!e||!e.byteLength||e.byteLength<4)throw new Error("Bad array or insufficient array length.");const n=new DS(e),i=n.readFixed32(),s=i>>24&255;if(s>OS)throw new Error(`Version ${s} is not supported`);const r=i>>16&255,o=r;if(r===1&&o!==1)throw new Error("Packed with PackMethod.Generic cannot be unpacked with anything than UnpackMethod.Generic");switch(o){case 1:const a=n.readFixed32();if(a>=e.byteLength)return;const c=n.pos;n.pos=a;const l=n.readVarint(),d=new Array(l);for(let u=0;u<l;u++)d[u]=n.readString();n.pos=c;const f=n.readVarint();return Ol({keys:d,pbf:n},f);case 2:{const u={keys:[],pbf:n},h=n.readFixed32(),y=sp(n),w={};for(const{key:p,type:g}of y){const b=Dl[g],v=[];for(let M=0;M<h;M++)v.push(b(u));w[p]=v}return w}case 3:{const u={keys:[],pbf:n},h=n.readFixed32(),y=sp(n),w=new Array(h);for(let p=0;p<h;p++)w[p]={};for(const{key:p,type:g}of y){const b=Dl[g];for(let v=0;v<h;v++)w[v][p]=b(u)}return w}default:throw new Error(`Method ${o} is not supported`)}}function rp(e){const t=new Il;if(e instanceof ArrayBuffer){const n=CS(e);if(Array.isArray(n))for(const{id:i,...s}of n)t.set(i,s);else for(const i in n)t.set(i,n[i])}else for(const n in e)t.set(n,e[n]);return t}class FS{constructor(t){this.scope=t,this.tileLoader=new UT,this.tileAttrs=[],this.models={},this.featureStateMap=new Il}fetchTiles(t,n=3){const i=[];for(const s of t)i.push(this.tileLoader.fetch(s,n));return i}abortTileRequests(t){t.forEach(n=>this.tileLoader.abortRequest(n))}generateTile(t,n){const{styleManager:i,collector:s,metatiles:r}=this.scope,{tileInfo:o,promoteAttributes:a,promoteId:c,isCustomZenithSource:l,modelShowHideEventsSublayers:d}=t,f=Ie(o.coords),u=this.tileLoader.get(f),h=[],y=[],w=[],p={};return u.forEach(g=>{const{regionId:b,metatileHash:v}=g,M=this.scope.styleManager.getStyle(t.styleId);if(!M)return;if(t.areTileBoundsVisible&&t.isDefaultSource){const L=i.getStyle(Mo).layers.find(A=>A.id==="debug-tile-bounds");Wh(s,L,t.styleState)}const E=$T(M,i,this.featureStateMap,s,t,g,r[v],this.tileAttrs,l,a,n,c,d);Object.assign(p,E.promotedObjectAttributes),h.push({regionId:b,metatileHash:v,collectorOutput:E,styleId:M.id}),w.push(...E.transferable),E.debugGeoJsonData?.forEach(T=>y.push(T))}),this.scope.resetCollector(),this.scope.syncRasterSets(),Promise.resolve({results:h,transferable:w,promotedAttrs:Object.keys(p).length>0?p:void 0,geoJsonData:n?y:void 0})}deleteTiles(t){for(const n of t)this.tileLoader.delete(n)}setFeatureStateMap(t){this.featureStateMap=rp(t)}generateModel(t){const{regionId:n,metatileHash:i,styleId:s,url:r,id:o}=t,{styleManager:a}=this.scope;return new Promise(c=>{const l=this.models[o];(l?Promise.resolve(l):new Promise(f=>{Do({url:r},(u,h)=>{if(u||h.byteLength===0){const y=this.models[o]=new ArrayBuffer(0);f(y)}else this.models[o]=h,f(h)})})).then(f=>{if(f.byteLength===0){c({objects:this.scope.collector.getAccumulatedData(),textures:{isBitmap:!1,data:[]}});return}const u=this.scope.styleManager.getStyle(s);if(!u){c({objects:this.scope.collector.getAccumulatedData(),textures:{isBitmap:!1,data:[]}});return}const{objects:h,textures:y}=aS(u,a,t.styleState,this.scope.collector,f,t,this.scope.metatiles[i],n,this.featureStateMap);if(this.scope.createImageBitmap){const w=y.map(p=>{const g=new Blob([p],{type:"image/png"});return createImageBitmap(g)});Promise.all(w).then(p=>{c({objects:h,textures:{isBitmap:!0,data:p},transferable:[...h.transferable,...p]}),this.scope.resetCollector()})}else c({objects:h,textures:{isBitmap:!1,data:y},transferable:[...h.transferable,f]}),this.scope.resetCollector()})})}destroy(){this.tileLoader.destroy(),this.tileAttrs=[],this.models={}}}function NS(e,t){let n=!1,i;function s(){n=!1,i&&(r(...i),i=!1)}function r(...o){n?i=o:(e(...o),setTimeout(s,t),n=!0)}return r}const Bo=.8;class RS{constructor(t,n){this.offset=0,this.stride=n,this.buffer=new ArrayBuffer(t),this.view=new Int32Array(this.buffer),this.comittedOffsets=0,this.maximum=t/n,this.watermark=this.maximum*Bo}extend(){const t=this.buffer.byteLength*2;this.maximum=t/this.stride,this.watermark=this.maximum*Bo;const n=new ArrayBuffer(t),i=new Int32Array(n);return i.set(this.view),this.buffer=n,this.view=i,n}}class BS{constructor(t){this.offset=0,this.buffer=new Int32Array(t),this.comittedOffsets=0,this.watermark=t*Bo}extend(){const t=this.buffer.length*2;this.watermark=t*Bo;const n=new Int32Array(t);n.set(this.buffer),this.buffer=n}}class op{constructor(t,n,i,s,r,o){this.objectsData={},this.extents=new Float32Array([1/0,1/0,1/0,-1/0,-1/0,-1/0]),this.maxDiag=0,this.drawMode=r;const a=t!=="buildingModel"?67200:67200*5,c=Hs(t,n);this.elements=new RS(a,c),this.indices=new BS(a*2/c),this.views={},this.binder=s,s(this,this.elements.buffer),this.attributes=i,this.key=o}static generateKey(t){return JSON.stringify(t)}resetOffsets(){this.elements.offset=0,this.elements.comittedOffsets=0,this.indices.offset=0,this.indices.comittedOffsets=0}resetBuildingsData(){this.objectsData={}}resetInstancesExtents(){this.extents[0]=1/0,this.extents[1]=1/0,this.extents[2]=1/0,this.extents[3]=-1/0,this.extents[4]=-1/0,this.extents[5]=-1/0,this.maxDiag=0}commit(){this.elements.comittedOffsets=this.elements.offset,this.indices.comittedOffsets=this.indices.offset}rollback(){this.elements.offset=this.elements.comittedOffsets,this.indices.offset=this.indices.comittedOffsets}checkWatermarks(){let t=0;const n=this.elements;n.offset>n.watermark&&(n.offset>=n.buffer.byteLength/n.stride&&(t=1),this.binder(this,n.extend()));const i=this.indices;return i.offset>i.watermark&&(i.offset>=i.buffer.length&&(t=1),i.extend()),t}}function at(e,t,n){n=n||{},this.w=e||64,this.h=t||64,this.autoResize=!!n.autoResize,this.shelves=[],this.freebins=[],this.stats={},this.bins={},this.maxId=0}at.prototype.pack=function(e,t){e=[].concat(e),t=t||{};for(var n=[],i,s,r,o,a=0;a<e.length;a++)if(i=e[a].w||e[a].width,s=e[a].h||e[a].height,r=e[a].id,i&&s){if(o=this.packOne(i,s,r),!o)continue;t.inPlace&&(e[a].x=o.x,e[a].y=o.y,e[a].id=o.id),n.push(o)}return this.shrink(),n},at.prototype.packOne=function(e,t,n){var i={freebin:-1,shelf:-1,waste:1/0},s=0,r,o,a,c;if(typeof n=="string"||typeof n=="number"){if(r=this.getBin(n),r)return this.ref(r),r;typeof n=="number"&&(this.maxId=Math.max(n,this.maxId))}else n=++this.maxId;for(c=0;c<this.freebins.length;c++){if(r=this.freebins[c],t===r.maxh&&e===r.maxw)return this.allocFreebin(c,e,t,n);t>r.maxh||e>r.maxw||t<=r.maxh&&e<=r.maxw&&(a=r.maxw*r.maxh-e*t,a<i.waste&&(i.waste=a,i.freebin=c))}for(c=0;c<this.shelves.length;c++)if(o=this.shelves[c],s+=o.h,!(e>o.free)){if(t===o.h)return this.allocShelf(c,e,t,n);t>o.h||t<o.h&&(a=(o.h-t)*e,a<i.waste&&(i.freebin=-1,i.waste=a,i.shelf=c))}if(i.freebin!==-1)return this.allocFreebin(i.freebin,e,t,n);if(i.shelf!==-1)return this.allocShelf(i.shelf,e,t,n);if(t<=this.h-s&&e<=this.w)return o=new Cl(s,this.w,t),this.allocShelf(this.shelves.push(o)-1,e,t,n);if(this.autoResize){var l,d,f,u;return l=d=this.h,f=u=this.w,(f<=l||e>f)&&(u=Math.max(e,f)*2),(l<f||t>l)&&(d=Math.max(t,l)*2),this.resize(u,d),this.packOne(e,t,n)}return null},at.prototype.allocFreebin=function(e,t,n,i){var s=this.freebins.splice(e,1)[0];return s.id=i,s.w=t,s.h=n,s.refcount=0,this.bins[i]=s,this.ref(s),s},at.prototype.allocShelf=function(e,t,n,i){var s=this.shelves[e],r=s.alloc(t,n,i);return this.bins[i]=r,this.ref(r),r},at.prototype.shrink=function(){if(this.shelves.length>0){for(var e=0,t=0,n=0;n<this.shelves.length;n++){var i=this.shelves[n];t+=i.h,e=Math.max(i.w-i.free,e)}this.resize(e,t)}},at.prototype.getBin=function(e){return this.bins[e]},at.prototype.ref=function(e){if(++e.refcount===1){var t=e.h;this.stats[t]=(this.stats[t]|0)+1}return e.refcount},at.prototype.unref=function(e){return e.refcount===0?0:(--e.refcount===0&&(this.stats[e.h]--,delete this.bins[e.id],this.freebins.push(e)),e.refcount)},at.prototype.clear=function(){this.shelves=[],this.freebins=[],this.stats={},this.bins={},this.maxId=0},at.prototype.resize=function(e,t){this.w=e,this.h=t;for(var n=0;n<this.shelves.length;n++)this.shelves[n].resize(e);return!0};function Cl(e,t,n){this.x=0,this.y=e,this.w=this.free=t,this.h=n}Cl.prototype.alloc=function(e,t,n){if(e>this.free||t>this.h)return null;var i=this.x;return this.x+=e,this.free-=e,new kS(n,i,this.y,e,t,e,this.h)},Cl.prototype.resize=function(e){return this.free+=e-this.w,this.w=e,!0};function kS(e,t,n,i,s,r,o){this.id=e,this.x=t,this.y=n,this.w=i,this.h=s,this.maxw=r||i,this.maxh=o||s,this.refcount=0}class US{constructor(){this.packer=new at(qt[0],qt[1]),this.currentAtlasIndex=0,this.packedRasters=[],this.rastersToLoad=[],this.newRasterSets=new Map}addNewRasterSet(t,n){let i=this.newRasterSets.get(t);i||(i=[],this.newRasterSets.set(t,i)),i.push(n)}pack(t,n,i){t.isSvg?this.packSvg(t,n.map(s=>({w:s,h:s})),i):this.packPng(t,n.map(s=>({w:s,h:s})),i)}packSvg(t,n,i){const{rasters:s}=t,r=new Set;for(const{w:o,h:a}of s)r.add(`${o}_${a}`);for(const o of n){const a=o.w*i,c=o.h*i;if(r.has(`${a}_${c}`))continue;let l=this.packer.packOne(a+2,c+2);l===null&&(this.packer=new at(qt[0],qt[1]),this.currentAtlasIndex++,l=this.packer.packOne(a+2,c+2));const d=s.length,f={rasterSetIndex:t.index,rasterIndex:d,w:a,h:c,x:l.x+1,y:l.y+1,anchorX:t.anchorX,anchorY:t.anchorY,atlasIndex:this.currentAtlasIndex,isPacked:!0};s.push(f),this.packedRasters.push(t.index,d,f.x,f.y,f.w,f.h,this.currentAtlasIndex)}}addRastersToLoad(t,n){this.rastersToLoad.push(t,n.rasterSetIndex,n.rasterIndex)}getNewRasterSets(){const t=this.newRasterSets;return this.newRasterSets=new Map,t}getPackedRasters(){if(this.packedRasters.length===0)return;const t=new Uint16Array(this.packedRasters);return this.packedRasters=[],t}getRastersToLoad(){const t=new Float64Array(this.rastersToLoad);return this.rastersToLoad=[],t}packPng(t,n,i){const{rasters:s}=t,r=new Set;for(const{w:o,h:a}of s)r.add(`${o}_${a}`);for(const o of n){if(r.has(`${o.w}_${o.h}`)&&t.type===li.Static)continue;const a=o.w*i,c=o.h*i;let l=Cs(s,a,!1),d;if(l===void 0)l=s.length,d={rasterSetIndex:t.index,rasterIndex:l,w:a,h:c,x:0,y:0,anchorX:0,anchorY:0,atlasIndex:this.currentAtlasIndex,isPacked:!1},s.push(d);else if(d=t.rasters[l],d.isPacked)continue;let f=this.packer.packOne(d.w+2,d.h+2);f===null&&(this.packer=new at(qt[0],qt[1]),this.currentAtlasIndex++,f=this.packer.packOne(d.w+2,d.h+2)),d.x=f.x+1,d.y=f.y+1,d.atlasIndex=this.currentAtlasIndex,d.isPacked=!0,this.packedRasters.push(t.index,l,d.x,d.y,d.w,d.h,this.currentAtlasIndex)}}}const zS=2**32-2,GS=Od(2**32-1),jS=Od(2**32-2);class HS{constructor(){this.colorById=new Map,this.index=0}getIndex(t){if(!t)return this.nextIndex();const n=this.colorById.get(t);if(n!==void 0)return n;const i=this.nextIndex();return this.colorById.set(t,i),i}nextIndex(){return++this.index%zS}}const ap=2**20,cp=["main","parser","labeling","models"],Fl={};for(let e=0;e<cp.length;e++){const t=cp[e];Fl[t]={min:1+e*ap,max:(e+1)*ap}}class VS{constructor(t){this.atlasPacker=new US,this.pointIndexer=new HS,this.floorHidingMap=new Map,this.usedModels=new Set,this.dataModels={},this.promotedObjectAttributes={},this.addedBuckets=[],this.labels=[],this.idIndexer=new f2(t),this.workerName=t,this.dataModelsIndex=Fl[t].min,this.buckets={},this.geoJsonData=[],this.reset()}reset(){this.buckets={},this.geoJsonData=[],this.addedBuckets=[],this.floorHidingMap.clear(),this.labels=[],this.usedModels.clear()}getStatsAfterReset(){return{buckets:Object.keys(this.buckets).length,geoJsonData:this.geoJsonData.length,addedBuckets:this.addedBuckets.length,floorHidingMap:this.floorHidingMap.size,labels:this.labels.length,usedModels:this.usedModels.size}}addLabel(t){this.labels.push(t)}addUsedModel(t){this.usedModels.add(t)}getIndexerStats(){return this.idIndexer.getIndexerStats()}getBucketsMemoryFootprint(){return Object.keys(this.buckets).map(t=>{const n=t,i=this.buckets[n];return i?{[t]:Object.keys(i).map(s=>{const r=i[s];if(r&&typeof r=="object"){const o=Object.keys(r).map(a=>{const c=r[a];if(c&&c.elements&&c.elements.buffer)return{elementsBuffer:c.elements.buffer.byteLength,indices:c.indices.buffer.byteLength}});return{[s]:o}}return{[s]:0}})}:{[t]:[]}})}addPromotedObjectAttributes(t,n){this.promotedObjectAttributes[t]=n}addFeature(t){this.geoJsonData.push(t)}addUsedModelByUrl(t){const n=this.dataModels[t];if(n!==void 0)return n;const{min:i,max:s}=Fl[this.workerName];this.dataModelsIndex=i+(this.dataModelsIndex+1-i)%(s-i);const r=-this.dataModelsIndex;return this.dataModels[t]=r,r}getDataModelsUrls(){const t={};for(const n in this.dataModels)this.usedModels.has(this.dataModels[n])&&(t[n]=this.dataModels[n]);return t}getBucket(t,n,i,s,r=Js){let o=this.buckets[t];o===void 0&&(o={},this.buckets[t]=o);let a=o[n];a===void 0&&(a=o[n]={});const c=op.generateKey(i),l=a[c];if(l)return this.addedBuckets.push(l),l;const d=new op(t,n,i,s,r,c);return a[c]=d,this.addedBuckets.push(d),d}isOverloaded(){const t=this.addedBuckets;let n=0,i=0;for(;i<t.length;)n=n+t[i++].checkWatermarks();const s=n>0;if(s)for(;i--;)t[i].rollback();else for(;i--;)t[i].commit();return t.length=0,s}addFloorHidingMap(t,n){let i=this.floorHidingMap.get(n);i===void 0&&(i=[],this.floorHidingMap.set(n,i)),i.push(t)}getAccumulatedData(){const t=this.buckets,n=[],i=[];for(const u in t){const h=u,y=t[h];for(const w in y){const p=w,g=y[p],b=Hs(h,p)/4;let v=0;for(const L in g)v+=g[L].indices.offset;if(v===0)continue;const M=[],E=new Int32Array(v*b);let T=0;for(const L in g){const A=g[L],{elements:P,indices:R,attributes:k,meta:V,objectsData:z,extents:$,maxDiag:ee}=A,{view:I}=P,{buffer:_}=R;if(P.offset===0)continue;const S=T,D={};for(let O=0;O<R.offset;O++){const C=z?z[O]:null;if(C){const U=T/b;$S(C,U,D)}const F=_[O]*b;for(let U=0;U<b;U++)E[T++]=I[F+U]}M.push({attributes:k,drawMode:A.drawMode,rangeStart:S*4,rangeEnd:T*4,meta:V,objectsData:Object.keys(D).length>0?D:void 0,extents:new Float32Array($),maxDiag:ee}),A.resetOffsets(),A.resetBuildingsData(),A.resetInstancesExtents(),A.meta=void 0}n.push({symbol:h,sink:p,buffer:E.buffer,generatedObjects:M}),i.push(E.buffer)}}const s=this.idIndexer.getPacked();i.push(s.centerBuffer),i.push(s.instanceIdBuffer),i.push(s.layerIdBuffer),i.push(s.objectClassBuffer),i.push(s.phaseBuffer),i.push(s.styleIdBuffer),i.push(s.sublayerBuffer);const r=this.atlasPacker.getPackedRasters();r!==void 0&&i.push(r.buffer);const o=this.atlasPacker.getRastersToLoad();i.push(o.buffer);const a=this.getDataModelsUrls();this.usedModels=new Set;const c=this.floorHidingMap;this.floorHidingMap=new Map;const l=this.labels;this.labels=[];const d=this.promotedObjectAttributes;this.promotedObjectAttributes={};const f=this.geoJsonData.length?this.geoJsonData:void 0;return this.geoJsonData=[],{data:n,labels:l,floorHidingMap:c,packedRasters:r,rastersToLoad:o,dataModelsUrls:a,identifyIds:s,transferable:i,promotedObjectAttributes:d,debugGeoJsonData:f}}}function $S(e,t,n){const i=e.objectId;n[i]||(n[i]=[]);let s=!1;for(const r of n[i]){const o=r.offset+r.size,a=t+e.size;(r.offset<=t&&o>=t||t<=r.offset&&a>=r.offset)&&(r.offset=Math.min(t,r.offset),r.size=Math.max(o,a)-r.offset,s=!0)}s||n[i].push({offset:t,size:e.size})}const YS={[gs.none]:{ambientColorIntensity:new Float32Array([1,1,1,0]),dir1ColorIntensity:new Float32Array([1,1,1,0]),dir1Direction:new Float32Array([0,-1,0]),dir2ColorIntensity:new Float32Array([1,1,1,0]),dir2Direction:new Float32Array([0,-1,0]),shadowLightIndex:-1,shadowRadius:1}},ZS=2;class Nl{constructor(t,n=!1){this.dataType=t,this.pendingRequests=new Map,this.ignoredStatusCodes=n?[204,404]:[204]}async fetch(t,n,i=3,s=300){let r=0;for(;r<=i;)try{const o=await this.fetchAttempt(t,n);if(!o.error||!j0(o.error?.status))return o;throw new Error(`Fetching ${t} attempt ${r} failed.`)}catch{if(r>=i)return{rejected:!0};await H0(Math.pow(2,r)*s),r++}return{rejected:!0}}destroy(){const t=Array.from(this.pendingRequests.keys());this.abortRequests(t)}abortRequests(t){for(const n of t){const i=this.pendingRequests.get(n);if(i===void 0)return;i.xhr.abort(),i.resolve({rejected:!0}),this.pendingRequests.delete(n)}}fetchAttempt(t,n){return new Promise(i=>{const s=n(t),r=Ie(t),a=(this.dataType==="json"?G0:Do)({url:s},(c,l)=>{if(this.pendingRequests.delete(r),c!==void 0){this.ignoredStatusCodes.includes(c.status)||console.error(`Failed to fetch a tile by url "${s}" Error: status "${c.status}", message: ${c.message}`),i({error:c});return}i({data:l})});this.pendingRequests.set(r,{xhr:a,resolve:i})})}}class WS{constructor(t){this.map=t?.map||{}}set(t,n,i){this.map[t]===void 0&&(this.map[t]={}),this.map[t][n]=i}get(t,n){const i=this.map[t];if(i!==void 0)return i[n]}has(t,n){const i=this.map[t];return i===void 0?!1:i[n]!==void 0}reduce(t,n){return Object.values(this.map).reduce((i,s)=>Object.values(s).reduce((r,o,a,c)=>t(r,o,a,c),i),n)}}const XS=17,ko=6;class qS{constructor(){this.name="",this.range="",this.glyphs={}}}class JS{constructor(){this.id=0,this.range=0,this.bitmap=null,this.top=0,this.left=0,this.advance=0,this.x=0,this.y=0,this.width=0,this.height=0,this.texTop=0,this.texLeft=0,this.texRight=0,this.texBottom=0}}class KS{constructor(t,n){this.stacks=t.readFields(QS,[],n)}}function QS(e,t,n){if(e===1){const i=n.readMessage(eA,new qS);t.push(i)}}function eA(e,t,n){switch(e){case 1:t.name=n.readString();break;case 2:t.range=n.readString();break;case 3:{const i=n.readMessage(tA,new JS);t.glyphs[i.id]=i;break}}}function tA(e,t,n){switch(e){case 1:t.id=n.readVarint(),t.range=Ya(t.id);break;case 2:t.bitmap=n.readBytes();break;case 3:t.width=n.readVarint()+ko;break;case 4:t.height=n.readVarint()+ko;break;case 5:t.left=n.readSVarint()-ko/2;break;case 6:t.top=n.readSVarint()+XS+ko/2;break;case 7:t.advance=n.readVarint();break}}class nA{constructor(t,n,i){const s=[];let r=0;for(let o=0;o<t.length;o++){const a=t.charCodeAt(o),c=n&&n[a];c?(s.push(c),r=r+c.advance):a!==xt.bomCharCode&&gg(t[o],a)}this.glyphs=s,this.width=r+xt.baseSize*i*(t.length-1)}}function iA(e,t,n){const i={lines:[],maxWidth:0},s=e.split(`
`);for(let r=0;r<s.length;r++){const o=new nA(s[r],n,t);i.lines.push(o),o.width>i.maxWidth&&(i.maxWidth=o.width)}return i}function sA(e,t,n){for(const i of t)if(!n.has(e,i))return!1;return!0}function rA(e,t,n){if(e===void 0)return;const i=Ke(e,t);if(i!=="")return n.fontNameToIndex[i]===void 0?gi:i}function oA(e){const t=new KS(new yr(new Uint8Array(e))).stacks[0].glyphs,{width:n,height:i}=aA(t);cA(t,n,i);const s=lA(t,n,i);return{glyphData:t,bitmap:s,width:n,height:i}}function aA(e){const t=[],n=new at(512,512,{autoResize:!0}),i=Object.keys(e);for(let s=0;s<i.length;s++){const r=e[Number(i[s])];r.bitmap&&t.push({glyph:r,width:r.width,height:r.height})}n.pack(t,{inPlace:!0}),n.shrink();for(let s=0;s<t.length;s++){const r=t[s].glyph;r.x=t[s].x,r.y=t[s].y}return{width:Pd(n.w),height:Pd(n.h)}}function cA(e,t,n){const i=Object.keys(e);for(let s=0;s<i.length;s++){const r=e[Number(i[s])];r.bitmap&&(r.texTop=ht(r.y/n),r.texLeft=ht(r.x/t),r.texBottom=ht((r.y+r.height)/n),r.texRight=ht((r.x+r.width)/t))}}function lA(e,t,n){const i=new Uint8Array(t*n),s=Object.keys(e);for(let r=0;r<s.length;r++){const o=e[Number(s[r])];if(o.bitmap)for(let a=0;a<o.height;a++){const c=t*(o.y+a)+o.x,l=o.width*a;for(let d=0;d<o.width;d++)i[c+d]=o.bitmap[l+d]}}return i.buffer}const dA={point:{point:!0,heatmap:!0,gltfModel:!0,metricPoint:!0},polygon:{polygon:!0,polygonExtrusion:!0,mesh:!0,embankment:!0,polygon3d:!0,overpass:!0},line:{line:!0,lineExtrusion:!0,labelLine:!0,dashedLine:!0,oneWayLine:!0,metricPoint:!0,overpass:!0}};function fA(e,t){return!!dA[e][t]}function uA(e){const t=e.vertices.x,n=e.vertices.y;let i=0;for(let s=0;s<t.length-1;s++)i+=Math.hypot(t[s]-t[s+1],n[s]-n[s+1]);return i}function Rl(e,t){const n=new Set(t[0].map((i,s)=>t[0][s]===e[0]&&e[1]===t[1][s]?s:-1));return Array.from(n)}function hA(e,t,n,i){t>=0&&n>=0&&Math.abs(t-n)===1&&(e[2][0]=1),n>=0&&i>=0&&Math.abs(n-i)===1&&(e[2][1]=1),t>=0&&i>=0&&Math.abs(t-i)===1&&(e[2][2]=1)}function lp(e,t){const n=Rl([e[0][0],e[1][0]],t),i=Rl([e[0][1],e[1][1]],t),s=Rl([e[0][2],e[1][2]],t);n.forEach(r=>i.forEach(o=>s.forEach(a=>{hA(e,r,o,a)})))}function dp(e){const t=["GEOJSON_METATILE_UNKNOWN_SUBLAYER","Commercial_poi_default","Commercial_poi_city","Commercial_poi_premium","Commercial_model","Immersive_model","Immersive_model_multipart","Animated_immersive_model"],n=Array.from(new Set([...t,...e])).filter(i=>typeof i=="string"&&i.length>0);return rf(["id","db_label","db_label2","selected","hovered","componentDistanceStart","componentDistanceEnd","objectLength","beginningIsCut","endingIsCut","db_geometry_type","db_plan_id"],n)}var zn=(e=>(e[e.Main=0]="Main",e[e.Parser=1]="Parser",e[e.Labeling=2]="Labeling",e[e.Models=3]="Models",e[e.All=4]="All",e))(zn||{}),Zs=(e=>(e[e.FunctionUse=0]="FunctionUse",e[e.FunctionResult=1]="FunctionResult",e))(Zs||{});class pA extends _a{constructor(){super(),this.workers=new Map}addWorker(t,n){this.workers.set(t,n),n.addEventListener("message",i=>{const{to:s,msg:r,transferable:o}=i.data,a={from:t,to:s,msg:r,transferable:o};this.routeMessage(a)})}send(t,n,i){const s=this.workers.get(t);if(s){const r={to:t,from:zn.Main,msg:n,transferable:i};i!==void 0?s.postMessage(r,i):s.postMessage(r)}}broadcast(t){this.workers.forEach((n,i)=>{const s={to:i,from:zn.Main,msg:t};n.postMessage(s)})}routeMessage(t){const{from:n,to:i,transferable:s,msg:{type:r}}=t;if(i===zn.Main)this.emit("message",t);else if(i===zn.All)n!==zn.Main&&this.emit(r,t),this.workers.forEach((o,a)=>{a!==n&&(s!==void 0?o.postMessage(t,s):o.postMessage(t))});else{const o=this.workers.get(i);o&&(s!==void 0?o.postMessage(t,s):o.postMessage(t))}}}class mA extends _a{constructor(t){super(),this.worker=t,t.addEventListener("message",n=>{const i=n.data;this.emit("message",i)})}send(t,n,i){const s={to:t,msg:n,transferable:i};this.worker.postMessage(s,i)}broadcast(t){const n={to:zn.All,msg:t};this.worker.postMessage(n)}}class yA{constructor(t){this.onMessage=n=>{const{from:i,msg:s}=n;switch(s.type){case Zs.FunctionUse:this.onFunctionUse(s,i);break;case Zs.FunctionResult:this.onFunctionResult(s);break}},this.connector=t,this.functions=new Map,this.functionIdCounter=0,this.pendingFunctions=new Map,t.on("message",this.onMessage)}set(t,n){this.functions.set(t,n)}get(t,n,i){return(...s)=>{const r=this.functionIdCounter++,o={type:Zs.FunctionUse,data:{id:r,name:n,args:s,subids:i}};let a;return i?a=i.map(c=>new Promise(l=>{this.pendingFunctions.set(String(r)+`-${c}`,l)})):a=new Promise(c=>{this.pendingFunctions.set(String(r),c)}),this.connector.send(t,o),a}}onFunctionUse(t,n){const{data:{name:i,args:s,id:r}}=t,o=this.functions.get(i);if(o){const a=o(...s);if(Array.isArray(a)&&fp(a[0]))for(let c=0;c<a.length;c++)Promise.resolve(a[c]).then(l=>{this.sendFunctionResult(n,r,l,c)});else a&&fp(a)?Promise.resolve(a).then(c=>this.sendFunctionResult(n,r,c)):this.sendFunctionResult(n,r,a)}else console.error(`FnRegistry#onFunctionUse: function ${i} not found`)}sendFunctionResult(t,n,i,s){const r={type:Zs.FunctionResult,data:{id:n,result:i,subid:s}};i&&i.transferable?this.connector.send(t,r,i.transferable):this.connector.send(t,r)}onFunctionResult(t){const{data:{id:n,result:i,subid:s}}=t,r=String(n)+(s!==void 0?`-${s}`:""),o=this.pendingFunctions.get(r);o?(o(i),this.pendingFunctions.delete(r)):console.error(`FnRegistry#onFunctionResult: pending function ${r} not found`)}}function fp(e){return typeof e=="object"&&typeof e.then=="function"}class gA{constructor(t){this.fnRegistry=t,this.onClassCreate=({id:n,name:i,args:s})=>{const r=this.classes.get(i);if(!r){console.error(`ClassRegistry#onClassCreate: class ${i} not found`);return}const o=r.scope?new r.ClassConstructor(r.scope,...s):new r.ClassConstructor(...s);r.hosts.set(n,o)},this.onMethodUse=({id:n,name:i,method:s,args:r})=>{const o=this.classes.get(i);if(!o){console.error(`ClassRegistry#onMethodUse: class ${i} not found`);return}const a=o.hosts.get(n);if(!a){console.error(`ClassRegistry#onMethodUse: instance ${n} in class ${i} not found when calling the ${s} method`);return}if(!a[s]){console.error(`ClassRegistry#onMethodUse: method ${s} in instance ${n} in class ${i} not found`);return}return s==="destroy"&&o.hosts.delete(n),a[s](...r)},this.classes=new Map,this.idCounter=0,this.fnRegistry.set("createClass",this.onClassCreate),this.fnRegistry.set("classMethodUse",this.onMethodUse)}set(t,n,i,s){const r=this,o={ClassConstructor:n,hosts:new Map,proxies:new Map,scope:i};return this.classes.set(t,o),{get:a=>{class c{constructor(...f){this.id=r.idCounter++,r.fnRegistry.get(a,"createClass")({id:this.id,args:f,name:t})}}return Object.getOwnPropertyNames(n.prototype).forEach(d=>{d!=="constructor"&&typeof n.prototype[d]=="function"&&(c.prototype[d]=function(...f){const u=s&&s.includes(d)&&Array.isArray(f[0])?[...Array(f[0].length).keys()].map(h=>h):void 0;return r.fnRegistry.get(a,"classMethodUse",u)({id:this.id,name:t,method:d,args:f})})}),c}}}}function Bl(e,t,n,i,s=2){const r=s+2;let o=i;const a=n-t>>1;let c=n-t,l;const d=e[t],f=e[t+1],u=e[n],h=e[n+1];for(let y=t+r;y<n;y+=r){const w=wA(e[y],e[y+1],d,f,u,h);if(w>o)l=y,o=w;else if(w===o){const p=Math.abs(y-a);p<c&&(l=y,c=p)}}o>i&&(l-t>r&&Bl(e,t,l,i,s),e[l+2]=o,n-l>r&&Bl(e,l,n,i,s))}function wA(e,t,n,i,s,r){let o=s-n,a=r-i;if(o!==0||a!==0){const c=((e-n)*o+(t-i)*a)/(o*o+a*a);c>1?(n=s,i=r):c>0&&(n+=o*c,i+=a*c)}return o=e-n,a=t-i,o*o+a*a}function Ws(e,t,n,i,s,r=4){const o={id:e??null,index:s,type:t,geometry:n,tags:i,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};if(t==="Point"||t==="MultiPoint"||t==="LineString")Uo(o,n,r);else if(t==="Polygon")Uo(o,n[0],r);else if(t==="MultiLineString")for(const a of n)Uo(o,a,r);else if(t==="MultiPolygon")for(const a of n)Uo(o,a[0],r);return o}function Uo(e,t,n=4){for(let i=0;i<t.length;i+=n)e.minX=Math.min(e.minX,t[i]),e.minY=Math.min(e.minY,t[i+1]),e.maxX=Math.max(e.maxX,t[i]),e.maxY=Math.max(e.maxY,t[i+1])}function vA(e,t){const n=[];if(e.type==="FeatureCollection")for(let i=0;i<e.features.length;i++)zo(n,e.features[i],t,i);else e.type==="Feature"?zo(n,e,t,0):zo(n,{geometry:e},t,0);return n}function zo(e,t,n,i){if(!t.geometry)return;const s=t.geometry.coordinates,r=t.geometry.type,o=Math.pow(n.tolerance/((1<<n.maxZoom)*n.extent),2);let a=[],c=t.id;if(n.promoteId?c=t.properties[n.promoteId]:n.generateId&&(c=i||0),r==="Point")up(s,a,n.dimensions);else if(r==="MultiPoint")for(const l of s)up(l,a,n.dimensions);else if(r==="LineString")kl(s,a,o,!1,n.dimensions);else if(r==="MultiLineString")if(n.lineMetrics){for(const l of s)a=[],kl(l,a,o,!1,n.dimensions),e.push(Ws(c,"LineString",a,t.properties,i,n.dimensions+2));return}else Ul(s,a,o,!1,n.dimensions);else if(r==="Polygon")Ul(s,a,o,!0,n.dimensions);else if(r==="MultiPolygon")for(const l of s){const d=[];Ul(l,d,o,!0,n.dimensions),a.push(d)}else if(r==="GeometryCollection"){for(const l of t.geometry.geometries)zo(e,{id:c,geometry:l,properties:t.properties},n,i);return}else throw new Error("Input data is not a valid GeoJSON object.");e.push(Ws(c,r,a,t.properties,i,n.dimensions+2))}function up(e,t,n=2){t.push(hp(e[0]),pp(e[1]),0,1);for(let i=2;i<n;i++)t.push(e[i])}function kl(e,t,n,i,s=2){let r,o,a=0;for(let l=0;l<e.length;l++){const d=hp(e[l][0]),f=pp(e[l][1]);t.push(d,f,0,1);for(let u=2;u<s;u++)t.push(e[l][u]);l>0&&(i?a+=(r*f-d*o)/2:a+=Math.sqrt(Math.pow(d-r,2)+Math.pow(f-o,2))),r=d,o=f}const c=t.length-(s+2);t[2]=1,Bl(t,0,c,n,s),t[c+2]=1,t.size=Math.abs(a),t.start=0,t.end=t.size}function Ul(e,t,n,i,s=2){for(let r=0;r<e.length;r++){const o=[];kl(e[r],o,n,i,s),t.push(o)}}function hp(e){return e/360+.5}function pp(e){const t=Math.sin(e*Math.PI/180),n=.5-.25*Math.log((1+t)/(1-t))/Math.PI;return n<0?0:n>1?1:n}function mn(e,t,n,i,s,r,o,a){const c=(a.dimensions===void 0?2:a.dimensions)+2;if(n/=t,i/=t,r>=n&&o<i)return e;if(o<n||r>=i)return null;const l=[];for(const d of e){const f=d.geometry;let u=d.type;const h=s===0?d.minX:d.minY,y=s===0?d.maxX:d.maxY;if(h>=n&&y<i){l.push(d);continue}else if(y<n||h>=i)continue;let w=[];if(u==="Point"||u==="MultiPoint")bA(f,w,n,i,s,c);else if(u==="LineString")mp(f,w,n,i,s,!1,a.lineMetrics,c);else if(u==="MultiLineString")zl(f,w,n,i,s,!1,c);else if(u==="Polygon")zl(f,w,n,i,s,!0,c);else if(u==="MultiPolygon")for(const p of f){const g=[];zl(p,g,n,i,s,!0,c),g.length&&w.push(g)}if(w.length){if(a.lineMetrics&&u==="LineString"){for(const p of w)l.push(Ws(d.id,u,p,d.tags,d.index,c));continue}(u==="LineString"||u==="MultiLineString")&&(w.length===1?(u="LineString",w=w[0]):u="MultiLineString"),(u==="Point"||u==="MultiPoint")&&(u=w.length===c?"Point":"MultiPoint"),l.push(Ws(d.id,u,w,d.tags,d.index,c))}}return l.length?l:null}function bA(e,t,n,i,s,r=4){for(let o=0;o<e.length;o+=r){const a=e[o+s];if(a>=n&&a<=i){$i(t,e[o],e[o+1],e[o+2]);for(let c=3;c<r;c++)t.push(e[o+c])}}}function mp(e,t,n,i,s,r,o,a=4){let c=yp(e);const l=s===0?IA:MA;let d=e.start,f,u;for(let b=0;b<e.length-a;b+=a){const v=e[b],M=e[b+1],E=e[b+2],T=e[b+a],L=e[b+a+1],A=s===0?v:M,P=s===0?T:L;let R=!1;if(o&&(f=Math.sqrt(Math.pow(v-T,2)+Math.pow(M-L,2))),A<n){if(P>n){u=l(c,v,M,T,L,n),c.push(0);for(let k=4;k<a;k++){const V=e[b+k];c.push((e[b+a+k]-V)*u+V)}o&&(c.start=d+f*u)}}else if(A>i){if(P<i){u=l(c,v,M,T,L,i),c.push(0);for(let k=4;k<a;k++){const V=e[b+k];c.push((e[b+a+k]-V)*u+V)}o&&(c.start=d+f*u)}}else{$i(c,v,M,E);for(let k=3;k<a;k++)c.push(e[b+k])}if(P<n&&A>=n){u=l(c,v,M,T,L,n),c.push(0);for(let k=4;k<a;k++){const V=e[b+k];c.push((e[b+a+k]-V)*u+V)}R=!0}if(P>i&&A<=i){u=l(c,v,M,T,L,i),c.push(0);for(let k=4;k<a;k++){const V=e[b+k];c.push((e[b+a+k]-V)*u+V)}R=!0}!r&&R&&(o&&(c.end=d+f*u),t.push(c),c=yp(e)),o&&(d+=f)}let h=e.length-a;const y=e[h],w=e[h+1],p=e[h+2],g=s===0?y:w;if(g>=n&&g<=i){$i(c,y,w,p);for(let b=3;b<a;b++)c.push(e[h+b])}if(h=c.length-a,r&&h>=3&&(c[h]!==c[0]||c[h+1]!==c[1])){$i(c,c[0],c[1],c[2]);for(let b=3;b<a;b++)c.push(c[b])}c.length&&t.push(c)}function yp(e){const t=[];return t.size=e.size,t.start=e.start,t.end=e.end,t}function zl(e,t,n,i,s,r,o){for(const a of e)mp(a,t,n,i,s,r,!1,o)}function $i(e,t,n,i){e.push(t,n,i)}function IA(e,t,n,i,s,r){const o=(r-t)/(i-t);return $i(e,r,n+(s-n)*o,1),o}function MA(e,t,n,i,s,r){const o=(r-n)/(s-n);return $i(e,t+(i-t)*o,r,1),o}function TA(e,t){const n=t.buffer/t.extent,i=t.dimensions+2;let s=e;const r=mn(e,1,-1-n,n,0,-1,2,t),o=mn(e,1,1-n,2+n,0,-1,2,t);return(r||o)&&(s=mn(e,1,-n,1+n,0,-1,2,t)||[],r&&(s=gp(r,1,i).concat(s)),o&&(s=s.concat(gp(o,-1,i)))),s}function gp(e,t,n=4){const i=[];for(let s=0;s<e.length;s++){const r=e[s],o=r.type;let a;if(o==="Point"||o==="MultiPoint"||o==="LineString")a=Gl(r.geometry,t,n);else if(o==="MultiLineString"||o==="Polygon"){a=[];for(const c of r.geometry)a.push(Gl(c,t,n))}else if(o==="MultiPolygon"){a=[];for(const c of r.geometry){const l=[];for(const d of c)l.push(Gl(d,t,n));a.push(l)}}i.push(Ws(r.id,o,a,r.tags,r.index,n))}return i}function Gl(e,t,n=4){const i=[];i.size=e.size,e.start!==void 0&&(i.start=e.start,i.end=e.end);for(let s=0;s<e.length;s+=n){i.push(e[s]+t,e[s+1],e[s+2],e[s+3]);for(let r=4;r<n;r++)i.push(e[s+r])}return i}function wp(e,t,n){if(e.transformed)return e;const i=1<<e.z,s=e.x,r=e.y;for(const o of e.features){const a=o.geometry,c=o.type;o.geometry=[];const l=n.cuts&&c!==1?1:0,d=n.dimensions+l;if(c===1)for(let f=0;f<a.length;f+=d)o.geometry.push(bp(a,f,d,t,i,s,r));else if(c===2)o.geometry=vp(a,t,i,s,r,d);else for(let f=0;f<a.length;f++)o.geometry.push(vp(a[f],t,i,s,r,d))}return e.transformed=!0,e}function vp(e,t,n,i,s,r=3){const o=[];for(let a=0;a<e.length;a++){const c=[];for(let l=0;l<e[a].length;l+=r)c.push(bp(e[a],l,r,t,n,i,s));o.push(c)}return o}function bp(e,t,n,i,s,r,o){const a=[Math.round(i*(e[t]*s-r)),Math.round(i*(e[t+1]*s-o))];for(let c=2;c<n;c++)a.push(e[t+c]);return a}function SA(e,t,n,i,s){const r=t===s.maxZoom?0:s.tolerance/((1<<t)*s.extent),o={features:[],numPoints:0,numSimplified:0,numFeatures:e.length,source:null,x:n,y:i,z:t,transformed:!1,minX:2,minY:1,maxX:-1,maxY:0};for(const a of e)AA(o,a,r,s);return o}function AA(e,t,n,i){const s=t.geometry,r=t.type,o=i.dimensions+2;let a=[];if(e.minX=Math.min(e.minX,t.minX),e.minY=Math.min(e.minY,t.minY),e.maxX=Math.max(e.maxX,t.maxX),e.maxY=Math.max(e.maxY,t.maxY),r==="Point"||r==="MultiPoint")for(let c=0;c<s.length;c+=o){a.push(s[c],s[c+1]);for(let l=4;l<o;l++)a.push(s[c+l]);e.numPoints++,e.numSimplified++}else if(r==="LineString")jl(a,s,e,n,!1,!1,i);else if(r==="MultiLineString"||r==="Polygon"){for(let c=0;c<s.length;c++)jl(a,s[c],e,n,r==="Polygon",c===0,i);r==="Polygon"&&a.length&&(a=[a])}else if(r==="MultiPolygon")for(let c=0;c<s.length;c++){const l=s[c],d=[];for(let f=0;f<l.length;f++)jl(d,l[f],e,n,!0,f===0,i);d.length&&a.push(d)}if(a.length){let c=t.tags||null;if(r==="LineString"&&i.lineMetrics){c={};for(const d in t.tags)c[d]=t.tags[d];c.mapbox_clip_start=s.start/s.size,c.mapbox_clip_end=s.end/s.size}const l={geometry:a,type:r==="Polygon"||r==="MultiPolygon"?3:r==="LineString"||r==="MultiLineString"?2:1,tags:c};t.id!==null&&(l.id=t.id),i.generateIndex&&(l.index=t.index),e.features.push(l)}}function jl(e,t,n,i,s,r,o){const a=i*i,c=o&&!!o.cuts,l=o.dimensions+2;if(i>0&&t.size<(s?a:i)){n.numPoints+=t.length/l;return}const d=[];for(let f=0;f<t.length;f+=l){if(i===0||t[f+2]>a){n.numSimplified++,d.push(t[f],t[f+1]);for(let u=4;u<l;u++)d.push(t[f+u]);c&&d.push(t[f+3])}n.numPoints++}s&&EA(d,r,l-(c?1:2)),e.push(d)}function EA(e,t,n=3){let i=0;for(let s=0,r=e.length,o=r-n;s<r;o=s,s+=n)i+=(e[s]-e[o])*(e[s+1]+e[o+1]);if(i>0===t)for(let s=0,r=e.length;s<r/2;s+=n)for(let o=0;o<n;o++){const a=e[s+o],c=r-s-(n-o);e[s+o]=e[c],e[c]=a}return e}const xA={maxZoom:14,indexMaxZoom:5,indexMaxPoints:1e5,tolerance:3,extent:4096,buffer:64,lineMetrics:!1,promoteId:null,generateId:!1,generateIndex:!1,debug:0,dimensions:2,cuts:!1};class _A{constructor(t,n){n=this.options=PA(Object.create(xA),n);const i=n.debug;if(i&&console.time("preprocess data"),n.maxZoom<0||n.maxZoom>24)throw new Error("maxZoom should be in the 0-24 range");if(n.promoteId&&n.generateId)throw new Error("promoteId and generateId cannot be used together.");let s=vA(t,n);this.tiles={},this.tileCoords=[],i&&(console.timeEnd("preprocess data"),console.log("index: maxZoom: %d, maxPoints: %d",n.indexMaxZoom,n.indexMaxPoints),console.time("generate tiles"),this.stats={},this.total=0),s=TA(s,n),s.length&&this.splitTile(s,0,0,0),i&&(s.length&&console.log("features: %d, points: %d",this.tiles[0].numFeatures,this.tiles[0].numPoints),console.timeEnd("generate tiles"),console.log("tiles generated:",this.total,JSON.stringify(this.stats)))}splitTile(t,n,i,s,r,o,a){const c=[t,n,i,s],l=this.options,d=l.debug;for(;c.length;){s=c.pop(),i=c.pop(),n=c.pop(),t=c.pop();const f=1<<n,u=Hl(n,i,s);let h=this.tiles[u];if(!h&&(d>1&&console.time("creation"),h=this.tiles[u]=SA(t,n,i,s,l),this.tileCoords.push({z:n,x:i,y:s}),d)){d>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",n,i,s,h.numFeatures,h.numPoints,h.numSimplified),console.timeEnd("creation"));const A=`z${n}`;this.stats[A]=(this.stats[A]||0)+1,this.total++}if(h.source=t,r==null){if(n===l.indexMaxZoom||h.numPoints<=l.indexMaxPoints)continue}else{if(n===l.maxZoom||n===r)continue;if(r!=null){const A=r-n;if(i!==o>>A||s!==a>>A)continue}}if(h.source=null,t.length===0)continue;d>1&&console.time("clipping");const y=.5*l.buffer/l.extent,w=.5-y,p=.5+y,g=1+y;let b=null,v=null,M=null,E=null,T=mn(t,f,i-y,i+p,0,h.minX,h.maxX,l),L=mn(t,f,i+w,i+g,0,h.minX,h.maxX,l);t=null,T&&(b=mn(T,f,s-y,s+p,1,h.minY,h.maxY,l),v=mn(T,f,s+w,s+g,1,h.minY,h.maxY,l),T=null),L&&(M=mn(L,f,s-y,s+p,1,h.minY,h.maxY,l),E=mn(L,f,s+w,s+g,1,h.minY,h.maxY,l),L=null),d>1&&console.timeEnd("clipping"),c.push(b||[],n+1,i*2,s*2),c.push(v||[],n+1,i*2,s*2+1),c.push(M||[],n+1,i*2+1,s*2),c.push(E||[],n+1,i*2+1,s*2+1)}}getTile(t,n,i){t=+t,n=+n,i=+i;const s=this.options,{extent:r,debug:o}=s;if(t<0||t>24)return null;const a=1<<t;n=n+a&a-1;const c=Hl(t,n,i);if(this.tiles[c])return wp(this.tiles[c],r,s);o>1&&console.log("drilling down to z%d-%d-%d",t,n,i);let l=t,d=n,f=i,u;for(;!u&&l>0;)l--,d=d>>1,f=f>>1,u=this.tiles[Hl(l,d,f)];return!u||!u.source?null:(o>1&&(console.log("found parent tile z%d-%d-%d",l,d,f),console.time("drilling down")),this.splitTile(u.source,l,d,f,t,n,i),o>1&&console.timeEnd("drilling down"),this.tiles[c]?wp(this.tiles[c],r,s):null)}}function Hl(e,t,n){return((1<<e)*n+t)*32+e}function PA(e,t){for(const n in t)e[n]=t[n];return e}function LA(e,t){return new _A(e,t)}var Go={exports:{}},Ip;function DA(){if(Ip)return Go.exports;Ip=1,Go.exports=e,Go.exports.default=e;function e(I,_,S){S=S||2;var D=_&&_.length,O=D?_[0]*S:I.length,C=t(I,0,O,S,!0),F=[];if(!C||C.next===C.prev)return F;var U,j,N,H,q,X,te;if(D&&(C=c(I,_,C,S)),I.length>80*S){U=N=I[0],j=H=I[1];for(var W=S;W<O;W+=S)q=I[W],X=I[W+1],q<U&&(U=q),X<j&&(j=X),q>N&&(N=q),X>H&&(H=X);te=Math.max(N-U,H-j),te=te!==0?32767/te:0}return i(C,F,S,U,j,te,0),F}function t(I,_,S,D,O){var C,F;if(O===ee(I,_,S,D)>0)for(C=_;C<S;C+=D)F=V(C,I[C],I[C+1],F);else for(C=S-D;C>=_;C-=D)F=V(C,I[C],I[C+1],F);return F&&M(F,F.next)&&(z(F),F=F.next),F}function n(I,_){if(!I)return I;_||(_=I);var S=I,D;do if(D=!1,!S.steiner&&(M(S,S.next)||v(S.prev,S,S.next)===0)){if(z(S),S=_=S.prev,S===S.next)break;D=!0}else S=S.next;while(D||S!==_);return _}function i(I,_,S,D,O,C,F){if(I){!F&&C&&h(I,D,O,C);for(var U=I,j,N;I.prev!==I.next;){if(j=I.prev,N=I.next,C?r(I,D,O,C):s(I)){_.push(j.i/S|0),_.push(I.i/S|0),_.push(N.i/S|0),z(I),I=N.next,U=N.next;continue}if(I=N,I===U){F?F===1?(I=o(n(I),_,S),i(I,_,S,D,O,C,2)):F===2&&a(I,_,S,D,O,C):i(n(I),_,S,D,O,C,1);break}}}}function s(I){var _=I.prev,S=I,D=I.next;if(v(_,S,D)>=0)return!1;for(var O=_.x,C=S.x,F=D.x,U=_.y,j=S.y,N=D.y,H=O<C?O<F?O:F:C<F?C:F,q=U<j?U<N?U:N:j<N?j:N,X=O>C?O>F?O:F:C>F?C:F,te=U>j?U>N?U:N:j>N?j:N,W=D.next;W!==_;){if(W.x>=H&&W.x<=X&&W.y>=q&&W.y<=te&&g(O,U,C,j,F,N,W.x,W.y)&&v(W.prev,W,W.next)>=0)return!1;W=W.next}return!0}function r(I,_,S,D){var O=I.prev,C=I,F=I.next;if(v(O,C,F)>=0)return!1;for(var U=O.x,j=C.x,N=F.x,H=O.y,q=C.y,X=F.y,te=U<j?U<N?U:N:j<N?j:N,W=H<q?H<X?H:X:q<X?q:X,ie=U>j?U>N?U:N:j>N?j:N,J=H>q?H>X?H:X:q>X?q:X,K=w(te,W,_,S,D),he=w(ie,J,_,S,D),Z=I.prevZ,Y=I.nextZ;Z&&Z.z>=K&&Y&&Y.z<=he;){if(Z.x>=te&&Z.x<=ie&&Z.y>=W&&Z.y<=J&&Z!==O&&Z!==F&&g(U,H,j,q,N,X,Z.x,Z.y)&&v(Z.prev,Z,Z.next)>=0||(Z=Z.prevZ,Y.x>=te&&Y.x<=ie&&Y.y>=W&&Y.y<=J&&Y!==O&&Y!==F&&g(U,H,j,q,N,X,Y.x,Y.y)&&v(Y.prev,Y,Y.next)>=0))return!1;Y=Y.nextZ}for(;Z&&Z.z>=K;){if(Z.x>=te&&Z.x<=ie&&Z.y>=W&&Z.y<=J&&Z!==O&&Z!==F&&g(U,H,j,q,N,X,Z.x,Z.y)&&v(Z.prev,Z,Z.next)>=0)return!1;Z=Z.prevZ}for(;Y&&Y.z<=he;){if(Y.x>=te&&Y.x<=ie&&Y.y>=W&&Y.y<=J&&Y!==O&&Y!==F&&g(U,H,j,q,N,X,Y.x,Y.y)&&v(Y.prev,Y,Y.next)>=0)return!1;Y=Y.nextZ}return!0}function o(I,_,S){var D=I;do{var O=D.prev,C=D.next.next;!M(O,C)&&E(O,D,D.next,C)&&P(O,C)&&P(C,O)&&(_.push(O.i/S|0),_.push(D.i/S|0),_.push(C.i/S|0),z(D),z(D.next),D=I=C),D=D.next}while(D!==I);return n(D)}function a(I,_,S,D,O,C){var F=I;do{for(var U=F.next.next;U!==F.prev;){if(F.i!==U.i&&b(F,U)){var j=k(F,U);F=n(F,F.next),j=n(j,j.next),i(F,_,S,D,O,C,0),i(j,_,S,D,O,C,0);return}U=U.next}F=F.next}while(F!==I)}function c(I,_,S,D){var O=[],C,F,U,j,N;for(C=0,F=_.length;C<F;C++)U=_[C]*D,j=C<F-1?_[C+1]*D:I.length,N=t(I,U,j,D,!1),N===N.next&&(N.steiner=!0),O.push(p(N));for(O.sort(l),C=0;C<O.length;C++)S=d(O[C],S);return S}function l(I,_){return I.x-_.x}function d(I,_){var S=f(I,_);if(!S)return _;var D=k(S,I);return n(D,D.next),n(S,S.next)}function f(I,_){var S=_,D=I.x,O=I.y,C=-1/0,F;do{if(O<=S.y&&O>=S.next.y&&S.next.y!==S.y){var U=S.x+(O-S.y)*(S.next.x-S.x)/(S.next.y-S.y);if(U<=D&&U>C&&(C=U,F=S.x<S.next.x?S:S.next,U===D))return F}S=S.next}while(S!==_);if(!F)return null;var j=F,N=F.x,H=F.y,q=1/0,X;S=F;do D>=S.x&&S.x>=N&&D!==S.x&&g(O<H?D:C,O,N,H,O<H?C:D,O,S.x,S.y)&&(X=Math.abs(O-S.y)/(D-S.x),P(S,I)&&(X<q||X===q&&(S.x>F.x||S.x===F.x&&u(F,S)))&&(F=S,q=X)),S=S.next;while(S!==j);return F}function u(I,_){return v(I.prev,I,_.prev)<0&&v(_.next,I,I.next)<0}function h(I,_,S,D){var O=I;do O.z===0&&(O.z=w(O.x,O.y,_,S,D)),O.prevZ=O.prev,O.nextZ=O.next,O=O.next;while(O!==I);O.prevZ.nextZ=null,O.prevZ=null,y(O)}function y(I){var _,S,D,O,C,F,U,j,N=1;do{for(S=I,I=null,C=null,F=0;S;){for(F++,D=S,U=0,_=0;_<N&&(U++,D=D.nextZ,!!D);_++);for(j=N;U>0||j>0&&D;)U!==0&&(j===0||!D||S.z<=D.z)?(O=S,S=S.nextZ,U--):(O=D,D=D.nextZ,j--),C?C.nextZ=O:I=O,O.prevZ=C,C=O;S=D}C.nextZ=null,N*=2}while(F>1);return I}function w(I,_,S,D,O){return I=(I-S)*O|0,_=(_-D)*O|0,I=(I|I<<8)&16711935,I=(I|I<<4)&252645135,I=(I|I<<2)&858993459,I=(I|I<<1)&1431655765,_=(_|_<<8)&16711935,_=(_|_<<4)&252645135,_=(_|_<<2)&858993459,_=(_|_<<1)&1431655765,I|_<<1}function p(I){var _=I,S=I;do(_.x<S.x||_.x===S.x&&_.y<S.y)&&(S=_),_=_.next;while(_!==I);return S}function g(I,_,S,D,O,C,F,U){return(O-F)*(_-U)>=(I-F)*(C-U)&&(I-F)*(D-U)>=(S-F)*(_-U)&&(S-F)*(C-U)>=(O-F)*(D-U)}function b(I,_){return I.next.i!==_.i&&I.prev.i!==_.i&&!A(I,_)&&(P(I,_)&&P(_,I)&&R(I,_)&&(v(I.prev,I,_.prev)||v(I,_.prev,_))||M(I,_)&&v(I.prev,I,I.next)>0&&v(_.prev,_,_.next)>0)}function v(I,_,S){return(_.y-I.y)*(S.x-_.x)-(_.x-I.x)*(S.y-_.y)}function M(I,_){return I.x===_.x&&I.y===_.y}function E(I,_,S,D){var O=L(v(I,_,S)),C=L(v(I,_,D)),F=L(v(S,D,I)),U=L(v(S,D,_));return!!(O!==C&&F!==U||O===0&&T(I,S,_)||C===0&&T(I,D,_)||F===0&&T(S,I,D)||U===0&&T(S,_,D))}function T(I,_,S){return _.x<=Math.max(I.x,S.x)&&_.x>=Math.min(I.x,S.x)&&_.y<=Math.max(I.y,S.y)&&_.y>=Math.min(I.y,S.y)}function L(I){return I>0?1:I<0?-1:0}function A(I,_){var S=I;do{if(S.i!==I.i&&S.next.i!==I.i&&S.i!==_.i&&S.next.i!==_.i&&E(S,S.next,I,_))return!0;S=S.next}while(S!==I);return!1}function P(I,_){return v(I.prev,I,I.next)<0?v(I,_,I.next)>=0&&v(I,I.prev,_)>=0:v(I,_,I.prev)<0||v(I,I.next,_)<0}function R(I,_){var S=I,D=!1,O=(I.x+_.x)/2,C=(I.y+_.y)/2;do S.y>C!=S.next.y>C&&S.next.y!==S.y&&O<(S.next.x-S.x)*(C-S.y)/(S.next.y-S.y)+S.x&&(D=!D),S=S.next;while(S!==I);return D}function k(I,_){var S=new $(I.i,I.x,I.y),D=new $(_.i,_.x,_.y),O=I.next,C=_.prev;return I.next=_,_.prev=I,S.next=O,O.prev=S,D.next=S,S.prev=D,C.next=D,D.prev=C,D}function V(I,_,S,D){var O=new $(I,_,S);return D?(O.next=D.next,O.prev=D,D.next.prev=O,D.next=O):(O.prev=O,O.next=O),O}function z(I){I.next.prev=I.prev,I.prev.next=I.next,I.prevZ&&(I.prevZ.nextZ=I.nextZ),I.nextZ&&(I.nextZ.prevZ=I.prevZ)}function $(I,_,S){this.i=I,this.x=_,this.y=S,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}e.deviation=function(I,_,S,D){var O=_&&_.length,C=O?_[0]*S:I.length,F=Math.abs(ee(I,0,C,S));if(O)for(var U=0,j=_.length;U<j;U++){var N=_[U]*S,H=U<j-1?_[U+1]*S:I.length;F-=Math.abs(ee(I,N,H,S))}var q=0;for(U=0;U<D.length;U+=3){var X=D[U]*S,te=D[U+1]*S,W=D[U+2]*S;q+=Math.abs((I[X]-I[W])*(I[te+1]-I[X+1])-(I[X]-I[te])*(I[W+1]-I[X+1]))}return F===0&&q===0?0:Math.abs((q-F)/F)};function ee(I,_,S,D){for(var O=0,C=_,F=S-D;C<S;C+=D)O+=(I[F]-I[C])*(I[C+1]+I[F+1]),F=C;return O}return e.flatten=function(I){for(var _=I[0][0].length,S={vertices:[],holes:[],dimensions:_},D=0,O=0;O<I.length;O++){for(var C=0;C<I[O].length;C++)for(var F=0;F<_;F++)S.vertices.push(I[O][C][F]);O>0&&(D+=I[O-1].length,S.holes.push(D))}return S},Go.exports}var OA=DA();const Vl=nc(OA);function CA(e){const t=Je(e),n=oe.scaleFactor(ls(0,0,t)[1]),i=oe.scaleFactor(ls(0,ne,t)[1]);return{min:n,max:i,range:i-n}}function FA(e,t,n,i){const s=[];return e.geometry.forEach(r=>{const o=[],a=[],c=[];r.forEach(u=>{c.push(...UA(u,t)),o.length&&a.push(o.length),o.push(...u)});const l=[];for(let u=0;u<o.length;u++)for(let h=0;h<n;h++)l.push(o[u][h]);const d=Vl(l,a,n),f=new Array(n);for(let u=0;u<d.length;u+=3){const h=[];for(let y=0;y<n+1;y++)h.push([]);for(let y=0;y<3;y++)$l(f,o[d[u+2-y]],t,i),h[0][y]=f[0],h[1][y]=f[1],h[2][y]=0,n>2&&(h[3][y]=f[2]),n>3&&(h[4][y]=f[3]);c.forEach(y=>{const w=[[],[],[]];y.forEach((p,g)=>{w[0][g]=p[0],w[1][g]=p[1]}),lp(h,w)}),s.push({tags:e.tags,id:e.id,index:e.index,type:"polygon",vertices:{x:h[0],y:h[1],cut:h[2],signed_z:h[3],abs_z:h[4]}})}}),s}function NA(e,t,n,i){const s=Array(n);return e.geometry.map(r=>{const o=[];for(let a=0;a<n;a++)o.push([]);return r.forEach((a,c)=>{$l(s,a,t,i),o[0][c]=s[0],o[1][c]=s[1],n>2&&(o[2][c]=s[2]),n>3&&(o[3][c]=s[3])}),{tags:e.tags,id:e.id,index:e.index,type:"line",vertices:{x:o[0],y:o[1],z:o[2],signed_z:o[2],abs_z:o[3]}}})}function RA(e,t,n,i){const s=Array(n);return e.geometry.map(r=>{$l(s,r,t,i);const o={x:[s[0]],y:[s[1]],z:n>2?[s[2]??0]:void 0,abs_z:n>3&&s[3]!==void 0?[s[3]]:void 0};return{tags:e.tags,id:e.id,index:e.index,type:"point",vertices:o}})}function $l(e,t,n,i){const s=Mp(t,n);e[0]=s[0],e[1]=s[1];const r=i.min+s[1]/ne*i.range;t[2]===void 0||isNaN(t[2])?e[2]=0:e[2]=t[2]*me*r,t[3]!==void 0&&(e[3]=t[3]*me*r)}function Mp(e,t){return[ge(e[0]/t*ne,0,ne),ge((t-e[1])/t*ne,0,ne)]}function BA(e,t){return e[0]<0||e[0]>t||e[1]<0||e[1]>t}function kA(e,t,n){return e[0]>n&&t[0]>n||e[0]<0&&t[0]<0||e[1]>n&&t[1]>n||e[1]<0&&t[1]<0}function UA(e,t){const n=[];let i=[];for(let s=0;s<e.length;s++){const r=e[s];if(i.push(Mp(r,t)),!BA(r,t))continue;const o=e[s+1];if(!o)break;kA(r,o,t)&&(i.length>1&&n.push(i),i=[])}return i.length>1&&n.push(i),n}const Tp=4096,Sp=2,Yi={maxZoom:k0,tolerance:3,extent:Tp,buffer:1,debug:0,lineMetrics:!1,promoteId:null,generateId:!1,generateIndex:!0,indexMaxZoom:0,indexMaxPoints:1e5,dimensions:Sp};class Yl{constructor(t){this.options=t}get geoJsonVtInstance(){return this.geoJsonVT||(this.geoJsonVT=LA(this.options.data,{...Yi,maxZoom:this.options.maxZoom??Yi.maxZoom,dimensions:this.options.dimensions??Yi.dimensions,extent:this.options.extent??Yi.extent,buffer:this.options.buffer??Yi.buffer,promoteId:this.options.promoteId,tolerance:this.options.tolerance??Yi.tolerance})),this.geoJsonVT}fetchTile(t){const[n,i,s]=Mr(t),r={components:[],byId:new Map},o=this.geoJsonVtInstance.getTile(s,n,i),a=this.options.dimensions??Sp,c=this.options.extent??Tp,l=CA(t);if(!o)return Promise.resolve(r);for(const d of o.features)switch(d.type){case 1:r.components=r.components.concat(RA(d,c,a,l));break;case 2:r.components=r.components.concat(NA(d,c,a,l));break;case 3:r.components=r.components.concat(FA(d,c,a,l));break;default:console.warn("unsupported type ",o);break}return Promise.resolve(r)}destroy(){this.geoJsonVT=void 0}}function zA(e,t,n){const i={components:[],byId:new Map};return e.features.forEach((s,r)=>{i.components.push(...Ap(s.geometry,t).map(o=>({...o,index:r,id:s.id,tags:s.properties||{}})))}),i}function Ap(e,t,n){switch(e.type){case"GeometryCollection":{let i=[];return e.geometries.forEach(s=>{i=i.concat(Ap(s,t))}),i}case"Point":case"MultiPoint":return GA(e,t);case"LineString":case"MultiLineString":return jA(e,t);case"Polygon":case"MultiPolygon":return HA(e,t)}}function GA(e,t){return e.type==="Point"?[Ep(e.coordinates,t)]:e.coordinates.map(n=>Ep(n,t))}function jA(e,t){return e.type==="LineString"?[xp(e.coordinates,t)]:e.coordinates.map(n=>xp(n,t))}function HA(e,t,n){return e.type==="Polygon"?_p(e.coordinates,t):e.coordinates.reduce((i,s)=>i.concat(_p(s,t)),[])}function Ep(e,t){const n=[0,0,0];return gt(n,oe.fromGeo(e),t),{type:"point",vertices:{x:[n[0]],y:[n[1]]}}}function xp(e,t){const n=[[],[]],i=[0,0,0];return e.forEach((s,r)=>{gt(i,oe.fromGeo(s),t),n[0][r]=i[0],n[1][r]=i[1]}),{type:"line",vertices:{x:n[0],y:n[1]}}}function _p(e,t,n){const i=[],s=[],r=[],o=[],a=[];e.forEach(d=>{const f=d.map(u=>(gt(a,oe.fromGeo(u),t),[ge(a[0],0,ne),ge(a[1],0,ne)]));o.push(f),s.length&&r.push(s.length),s.push(...f)});const c=[];for(let d=0;d<s.length;d++)c.push(s[d][0]),c.push(s[d][1]);const l=Vl(c,r);for(let d=0;d<l.length;d+=3){const f=[[],[],[],[]];for(let h=0;h<3;h++)f[0][h]=s[l[d+h]][0],f[1][h]=s[l[d+h]][1],f[2][h]=0,f[3][h]=s[l[d+h]][2];o.forEach(h=>{const y=[[],[],[]];h.forEach((w,p)=>{y[0][p]=w[0],y[1][p]=w[1]}),lp(f,y)});const u={type:"polygon",vertices:{x:f[0],y:f[1],cut:f[2]}};i.push(u)}return i}class jo{constructor(t){this.tileLoader=new Nl("json",t.ignoreMissingTiles),this.options=t,this.url=n=>{const i=this.options.flipY?n:Mr(n);return os(this.options.url,{x:i[0].toString(),y:i[1].toString(),z:i[2].toString(),subdomain:pf(i)})}}fetchTile(t){return this.tileLoader.fetch(t,this.url).then(n=>n.data?zA(n.data,Je(t)):{components:[],byId:new Map})}abortTile(t){this.tileLoader.abortRequests([Ie(t)])}destroy(){this.tileLoader.destroy()}}const Pp=4;class VA{constructor(t,n,i,s){this.scope=t,this.options=n,this.id=i,this.featureStateMap=new Il,t.sources[i]=this,this.tileData={},this.styleManager=t.styleManager,this.collector=t.collector,this.sourceAttrs=this.options.attributes||{},this.metatile=dp(s),this.tileServer="url"in n?new jo(n):new Yl(n)}fetchTiles(t){const n=[];for(const i of t)n.push(this.fetchTile(i));return n}abortTileFetches(t){if(this.tileServer instanceof jo)for(const n of t)this.tileServer.abortTile(n)}generateTile(t,n,i,s,r,o,a,c){const l=Ie(n),d=this.tileData[l],f=Je(n),u=[],h=[],y=this.styleManager.getStyle(i),w=new Set(s),{promoteId:p}=this.options,g={},b="generateId"in this.options?this.options.generateId:!1;if(!y)return Promise.resolve({results:u,transferable:h});d&&d.components.forEach((T,L)=>{const{tileProps:A}=this.metatile,P=[],R=[];if(T.tags){const O=Object.keys(T.tags);as(this.metatile,O);for(const C of O)P[A[C]]=T.tags[C]}const k=Object.keys(this.sourceAttrs);as(this.metatile,k);const V=Array.from(this.featureStateMap.featureAttrs);as(this.metatile,V);for(const O of k)P[A[O]]=this.sourceAttrs[O];const z=P[A.db_hidden_by_plan_id];if(z&&t._activeFloorIds.includes(z))return;const $=b?String(T.index+this.id*2**32):p?P[A[p]]:void 0;if($!==void 0){const O=w.has($);if(P[A.selected]=O?1:0,d.byId.set($,L),g[$]=T.index,this.featureStateMap.featureAttrs.size>0){const C=$!==void 0&&this.featureStateMap.get($);if(C)for(const F of this.featureStateMap.featureAttrs)this.featureStateMap.clearAttrs=!1,R[A[F]]=C[F];else if(this.featureStateMap.clearAttrs===!1){this.featureStateMap.clearAttrs=!0;for(const F in A)R[A[F]]!==void 0&&(R[A[F]]=void 0)}}}const{coords:ee}=f,I=ee[3],_=ec(r),S=ws(t,this.sourceAttrs,A,P,R,$,f),D=this.styleManager.getLayers(y.id,A,P).filter(O=>fA(T.type,O.type)&&G(O.filter,S)&&(a?G(a,S):!0));if(D.length===0&&S.id&&this.collector.idIndexer.addOrphanId(S.id),P[A.db_geometry_type]=T.type==="line"?"polyline":T.type,(T.type==="point"||T.type==="line")&&(P[A.db_label]===void 0&&(P[A.db_label]=NaN),P[A.db_label2]===void 0&&(P[A.db_label2]=NaN)),T.type==="line"){const O=uA(T);P[A.componentDistanceStart]=0,P[A.componentDistanceEnd]=O,P[A.objectLength]=O,typeof P[A.beginningIsCut]!="number"&&(P[A.beginningIsCut]=0),typeof P[A.endingIsCut]!="number"&&(P[A.endingIsCut]=0)}el(this.collector,y,D,S,this.metatile,Pp,I,this.id,f,_,T.vertices,void 0,o,c)});const v=this.collector.getAccumulatedData(),M={regionId:0,metatileHash:Ql,collectorOutput:v,styleId:y.id};Object.keys(g).length>0&&(M.idToIndex=g),u.push(M),h.push(...v.transferable),this.scope.debouncedResetCollector(),this.scope.syncNewRasterSets();const E={results:u,transferable:h};return Promise.resolve(E)}getObjectAttributes(t,n){const i=this.tileData[n];if(i){const s=i.byId.get(t);if(s===void 0)return;const r=i.components[s];return r===void 0?void 0:r.tags}}deleteTiles(t){for(const n of t)delete this.tileData[Ie(n)]}setSourceAttrs(t){this.sourceAttrs=t}destroy(){delete this.scope.sources[this.id],this.tileData={},this.sourceAttrs={},this.tileServer.destroy()}setFeatureStateMap(t){this.featureStateMap=rp(t)}setData(t){if(typeof t=="string"){if(this.tileServer instanceof jo)return this.tileServer.destroy(),this.options={...this.options,url:t},this.tileServer=new jo(this.options),this.tileData={},Promise.resolve(!0)}else if(this.tileServer instanceof Yl)return this.tileServer.destroy(),this.options={...this.options,data:t},this.tileServer=new Yl(this.options),this.tileData={},Promise.resolve(!0);return Promise.resolve(!1)}fetchTile(t){const n=Ie(t);return this.tileData[n]?Promise.resolve(this.tileData[n]):this.tileServer.fetchTile(t).then(i=>(this.tileData[n]=i,i))}}function $A(e,t){return{path:t,extensions:e.extensions,extensionsRequired:e.extensionsRequired??[],extensionsUsed:e.extensionsUsed??[],extras:e.extras,accessors:ZA(e.accessors),buffers:XA(e.buffers),bufferViews:qA(e.bufferViews),cameras:JA(e.cameras),scene:e.scene??0,scenes:eE(e.scenes),nodes:tE(e.nodes),materials:QA(e.materials),meshes:KA(e.meshes),asset:YA(e.asset),animations:WA(e.animations),images:nE(e.images),textures:iE(e.textures),samplers:sE(e.samplers),skins:rE(e.skins)}}function YA(e){return{copyright:e.copyright,generator:e.generator,version:e.version,minVersion:e.minVersion}}function ZA(e=[]){return e.map(t=>({bufferView:t.bufferView,byteOffset:t.byteOffset??0,componentType:t.componentType,normalized:t.normalized,count:t.count,type:t.type,max:t.max,min:t.min,sparse:t.sparse,name:t.name,extensions:t.extensions,extras:t.extras}))}function WA(e=[]){return e.map(t=>({channels:t.channels,samplers:t.samplers,name:t.name,extensions:t.extensions,extras:t.extras}))}function XA(e=[]){return e.map(t=>({uri:t.uri,byteLength:t.byteLength,name:t.name,extensions:t.extensions,extras:t.extras,buffer:void 0}))}function qA(e=[]){return e.map(t=>({buffer:t.buffer,byteOffset:t.byteOffset,byteLength:t.byteLength,byteStride:t.byteStride,target:t.target,name:t.name,extensions:t.extensions,extras:t.extras}))}function JA(e=[]){return e.map(t=>({type:t.type,orthographic:t.orthographic,perspective:t.perspective,name:t.name,extensions:t.extensions,extras:t.extras}))}function KA(e=[]){return e.map(t=>({primitives:t.primitives,name:t.name,weights:t.weights,extensions:t.extensions,extras:t.extras}))}function QA(e=[]){return e.map(t=>({alphaCutoff:t.alphaCutoff,alphaMode:t.alphaMode,doubleSided:t.doubleSided,emissiveFactor:t.emissiveFactor,emissiveTexture:t.emissiveTexture,normalTexture:t.normalTexture,occlusionTexture:t.occlusionTexture,pbrMetallicRoughness:t.pbrMetallicRoughness,name:t.name,extras:t.extras,extensions:t.extensions}))}function eE(e=[]){return e.map(t=>({nodes:t.nodes,extensions:t.extensions,extras:t.extras,name:t.name}))}function tE(e=[]){return e.map(t=>{const n=t.rotation??[0,0,0,1],i=t.scale??[1,1,1],s=t.translation??[0,0,0];return{camera:t.camera,children:t.children,matrix:t.matrix?gm(...t.matrix):void 0,rotation:Xm(...n),scale:qe(...i),translation:qe(...s),name:t.name,mesh:t.mesh,skin:t.skin,extras:t.extras,extensions:t.extensions}})}function nE(e=[]){return e.map(t=>({bufferView:t.bufferView,mimeType:t.mimeType,name:t.name,uri:t.uri,extensions:t.extensions,extras:t.extras,image:void 0}))}function iE(e=[]){return e.map(t=>({extensions:t.extensions,extras:t.extras,name:t.name,sampler:t.sampler,source:t.source}))}function sE(e=[]){return e.map(t=>({extensions:t.extensions,extras:t.extras,name:t.name,magFilter:t.magFilter,minFilter:t.minFilter,wrapS:t.wrapS,wrapT:t.wrapT}))}function rE(e=[]){return e.map(t=>({joints:t.joints,extensions:t.extensions,extras:t.extras,inverseBindMatrices:t.inverseBindMatrices,name:t.name,skeleton:t.skeleton}))}const Xs={JPEG:"image/jpeg",PNG:"image/png",GLTEXTURE:"image/texture"};function Lp(e){return e.substring(0,e.lastIndexOf("/")+1)}function oE(e){if(e.startsWith("data:image"))return e.split(";")[0].split(":")[1];switch(e.substring(e.lastIndexOf("."))){case".png":return Xs.PNG;case".jpg":case".jpeg":default:return Xs.JPEG}}function Dp(e){const t=atob(e.split(",")[1]),n=new ArrayBuffer(t.length),i=new Uint8Array(n);for(let s=0;s<t.length;s++)i[s]=t.charCodeAt(s);return n}const Fe=class Fe{constructor(t){this.data=t}static isGlb(t){const n=new Uint32Array(t,0,Fe.glbHeaderInts),i=n[0],s=n[1];return i===this.glbMagic&&s===this.glbVersion}extractGlbData(){if(this.getCheckedGlbInfo()===void 0)return{json:Xl,buffers:[]};let n;const i=[],s=this.getAllChunkInfos();for(const r of s)r.type===Fe.jsonChunkType&&!n?n=this.getJsonFromChunk(r):r.type===Fe.binaryChunkType&&i.push(this.getBufferFromChunk(r));return{json:n||Xl,buffers:i}}getCheckedGlbInfo(){const t=new Uint32Array(this.data,0,Fe.glbHeaderInts),n=t[0],i=t[1],s=t[2];if(!(!this.checkEquality(n,Fe.glbMagic,"glb magic")||!this.checkEquality(i,Fe.glbVersion,"glb header version")||!this.checkEquality(s,this.data.byteLength,"glb byte length")))return{magic:n,version:i,length:s}}getAllChunkInfos(){const t=[];let n=Fe.glbHeaderInts*4;for(;n<this.data.byteLength;){const i=this.getChunkInfo(n);t.push(i),n+=i.length+Fe.glbChunkHeaderInts*4}return t}getChunkInfo(t){const n=new Uint32Array(this.data,t,Fe.glbChunkHeaderInts),i=t+Fe.glbChunkHeaderInts*4,s=n[0],r=n[1];return{start:i,length:s,type:r}}getJsonFromChunk(t){const n=t.length,i=(Fe.glbHeaderInts+Fe.glbChunkHeaderInts)*4,s=new Uint8Array(this.data,i,n),r=new TextDecoder("utf-8").decode(s);return JSON.parse(r)}getBufferFromChunk(t){return this.data.slice(t.start,t.start+t.length)}checkEquality(t,n,i){return t===n?!0:(console.error(`[GLB MODEL PARSING ERROR] Found invalid/unsupported ${i}, expected: ${n}, but was: ${t}`),!1)}};Fe.glbHeaderInts=3,Fe.glbChunkHeaderInts=2,Fe.glbMagic=1179937895,Fe.glbVersion=2,Fe.jsonChunkType=1313821514,Fe.binaryChunkType=5130562;let Ho=Fe;const Op=5120,aE=5121,cE=5122,lE=5123,dE=5124,Cp=5125,fE=5126,uE=4,hE="draco_decoder_gltf.js",pE="draco_wasm_wrapper_gltf.js",Fp="draco_decoder_gltf.wasm";let Zl;function mE(e){Zl=wE(e).catch(t=>{const n="Draco decoder module failed to initialize"+(t?.message?` with the following error: ${t.message}`:".");throw new Error(n)})}async function yE(e){let t=await fetch(e).then(s=>s.text());const i=t.indexOf("if (typeof exports === 'object' && typeof module === 'object')");return i!==0&&(t=t.slice(0,i),t=t+"return DracoDecoderModule;"),t}async function gE(e){return fetch(e).then(t=>t.text()).then(t=>t.replace('"object"===typeof exports&&"object"===typeof module?module.exports=DracoDecoderModule:"function"===typeof define&&define.amd?define([],function(){return DracoDecoderModule}):"object"===typeof exports&&(exports.DracoDecoderModule=DracoDecoderModule);',"return DracoDecoderModule;"))}async function wE(e){if(typeof WebAssembly!="object"){const t=await yE(`${e}/${hE}`);return new Function(t)()()}else return gE(`${e}/${pE}`).then(t=>{const n=new Function(t)();return fetch(`${e}/${Fp}`).then(i=>i.arrayBuffer()).then(i=>n({wasmBinary:i,wasmBinaryFile:Fp}))})}function vE(e){switch(e){case Op:return"Int8Array";case aE:return"Uint8Array";case cE:return"Int16Array";case lE:return"Uint16Array";case dE:return"Int32Array";case Cp:return"Uint32Array";case fE:return"Float32Array";default:return"Float32Array"}}function bE(e,t,n,i,s,r){const o=s.num_components(),c=n.num_points()*o;let l,d,f;switch(r){case"Float32Array":f=c*4,l=e._malloc(f),t.GetAttributeDataArrayForAllPoints(n,s,e.DT_FLOAT32,f,l),d=new Float32Array(e.HEAPF32.buffer,l,c).slice(),e._free(l);break;case"Int8Array":l=e._malloc(c),t.GetAttributeDataArrayForAllPoints(n,s,e.DT_INT8,c,l),d=new Int8Array(e.HEAP8.buffer,l,c).slice(),e._free(l);break;case"Int16Array":f=c*2,l=e._malloc(f),t.GetAttributeDataArrayForAllPoints(n,s,e.DT_INT16,f,l),d=new Int16Array(e.HEAP16.buffer,l,c).slice(),e._free(l);break;case"Int32Array":f=c*4,l=e._malloc(f),t.GetAttributeDataArrayForAllPoints(n,s,e.DT_INT32,f,l),d=new Int32Array(e.HEAP32.buffer,l,c).slice(),e._free(l);break;case"Uint8Array":l=e._malloc(c),t.GetAttributeDataArrayForAllPoints(n,s,e.DT_UINT8,c,l),d=new Uint8Array(e.HEAPU8.buffer,l,c).slice(),e._free(l);break;case"Uint16Array":f=c*2,l=e._malloc(f),t.GetAttributeDataArrayForAllPoints(n,s,e.DT_UINT16,f,l),d=new Uint16Array(e.HEAPU16.buffer,l,c).slice(),e._free(l);break;case"Uint32Array":f=c*4,l=e._malloc(f),t.GetAttributeDataArrayForAllPoints(n,s,e.DT_UINT32,f,l),d=new Uint32Array(e.HEAPU32.buffer,l,c).slice(),e._free(l);break;default:throw new Error("DRACOLoader: Unexpected attribute type.")}return{name:i,array:d,itemSize:o,componentType:r}}function IE(e,t,n,i,s,r){let o,a;const c=t.GetEncodedGeometryType(n);if(c===e.TRIANGULAR_MESH)o=new e.Mesh,a=t.DecodeBufferToMesh(n,o);else throw new Error("DRACOLoader: Unexpected geometry type.");if(!a.ok()||o.ptr===0)throw new Error("DRACOLoader: Decoding failed: "+a.error_msg());const l={index:null,attributes:{}},d=o.num_points();for(const f in i){let u=Op,h;for(const[p,g]of Object.entries(r))if(p===f){u=s.accessors[g].componentType,h=s.accessors[g].count;break}if(d!==h)throw new Error(`DRACOLoader: Accessor vertex count ${h} does not match draco decoder vertex count  ${d}`);u=vE(u);const y=t.GetAttributeByUniqueId(o,i[f]),w=bE(e,t,o,f,y,u);l.attributes[w.name]=w}if(c===e.TRIANGULAR_MESH){const u=o.num_faces()*3,h=u*4,y=e._malloc(h);t.GetTrianglesUInt32Array(o,h,y);const w=new Uint32Array(e.HEAPU32.buffer,y,u).slice();e._free(y),l.index={array:w,itemSize:1}}return e.destroy(o),l}function ME(e,t,n,i){const s=e.bufferView,r=t.bufferViews[s],o=t.buffers[r.buffer],c=new Int8Array(o.buffer).slice(r.byteOffset,r.byteOffset+r.byteLength),l=new n.Decoder,d=new n.DecoderBuffer;d.Init(c,r.byteLength);const f=IE(n,l,d,e.attributes,t,i);return n.destroy(d),f}function Xt(e,t,n,i,s){const r={buffer:e,byteLength:e.byteLength,extensions:void 0,extras:void 0,name:void 0,uri:void 0};t.buffers.push(r);const o={buffer:t.buffers.length-1,byteLength:e.byteLength,byteOffset:0,byteStride:0,extensions:void 0,extras:void 0,name:s,target:i};t.bufferViews.push(o),t.accessors[n].byteOffset=0,t.accessors[n].bufferView=t.bufferViews.length-1}function yn(e,t){let n;switch(t){case"Int8Array":n=new ArrayBuffer(e.length),new Int8Array(n).set(e);break;case"Uint8Array":n=new ArrayBuffer(e.length),new Uint8Array(n).set(e);break;case"Int16Array":n=new ArrayBuffer(e.length*2),new Int16Array(n).set(e);break;case"Uint16Array":n=new ArrayBuffer(e.length*2),new Uint16Array(n).set(e);break;case"Int32Array":n=new ArrayBuffer(e.length*4),new Int32Array(n).set(e);break;case"Uint32Array":n=new ArrayBuffer(e.length*4),new Uint32Array(n).set(e);break;default:case"Float32Array":n=new ArrayBuffer(e.length*4),new Float32Array(n).set(e);break}return n}function TE(e,t,n,i){const s=t.index.array;if(i!==void 0&&(Xt(s,e,i,34963,"index buffer view"),e.accessors[i].componentType=Cp),t.attributes.POSITION!==void 0){const r=yn(t.attributes.POSITION.array,t.attributes.POSITION.componentType);Xt(r,e,n.POSITION,34962,"position buffer view")}if(t.attributes.NORMAL!==void 0){const r=yn(t.attributes.NORMAL.array,t.attributes.NORMAL.componentType);Xt(r,e,n.NORMAL,34962,"normal buffer view")}for(let r=0;r<uE;++r){const o=`TEXCOORD_${r}`;if(t.attributes[o]!==void 0){const a=yn(t.attributes[o].array,t.attributes[o].componentType);Xt(a,e,n[o],34962,`${o} buffer view`)}}if(t.attributes.TANGENT!==void 0){const r=yn(t.attributes.TANGENT.array,t.attributes.TANGENT.componentType);Xt(r,e,n.TANGENT,34962,"Tangent buffer view")}if(t.attributes.COLOR_0!==void 0){const r=yn(t.attributes.COLOR_0.array,t.attributes.COLOR_0.componentType);Xt(r,e,n.COLOR_0,34962,"color buffer view")}if(t.attributes.JOINTS_0!==void 0){const r=yn(t.attributes.JOINTS_0.array,t.attributes.JOINTS_0.componentType);Xt(r,e,n.JOINTS_0,34963,"JOINTS_0 buffer view")}if(t.attributes.WEIGHTS_0!==void 0){const r=yn(t.attributes.WEIGHTS_0.array,t.attributes.WEIGHTS_0.componentType);Xt(r,e,n.WEIGHTS_0,34963,"WEIGHTS_0 buffer view")}if(t.attributes.JOINTS_1!==void 0){const r=yn(t.attributes.JOINTS_1.array,t.attributes.JOINTS_1.componentType);Xt(r,e,n.JOINTS_1,34963,"JOINTS_1 buffer view")}if(t.attributes.WEIGHTS_1!==void 0){const r=yn(t.attributes.WEIGHTS_1.array,t.attributes.WEIGHTS_1.componentType);Xt(r,e,n.WEIGHTS_1,34963,"WEIGHTS_1 buffer view")}}async function SE(e,t){if(!Array.isArray(e.meshes))return Promise.resolve();for(const n of e.meshes)if(Array.isArray(n.primitives))for(const i of n.primitives){if(i.extensions?.KHR_draco_mesh_compression===void 0)continue;Zl||mE(t);const s=await Zl;if(!s)continue;const r=ME(i.extensions.KHR_draco_mesh_compression,e,s,i.attributes);TE(e,r,i.attributes,i.indices)}}async function Wl(e){const t=await self.fetch(e);if(!t.ok)throw new Error(`${t.status} ${t.statusText}: ${t.url}`);return t}const Xl={asset:{version:""}};async function AE(e,t){if(t){e.buffers[0].buffer=t[0]||[];return}await Promise.all(e.buffers.map(async n=>{if(n.buffer){console.error("Buffer is already loaded");return}if(!n.uri){console.error("Buffer can not be loaded. No uri");return}if(n.uri.startsWith("data:"))n.buffer=Dp(n.uri);else{const i=un(n.uri)?n.uri:Lp(e.path)+n.uri,s=await Wl(i).then(r=>r.arrayBuffer());n.buffer=s}}))}async function EE(e,t,n){if(!t.bufferView)return!1;const i=e.bufferViews[t.bufferView];if(i===void 0)return!1;await n;const s=e.buffers[i.buffer].buffer;if(!s)return!1;const r=new Uint8Array(s,i.byteOffset,i.byteLength);if(typeof createImageBitmap<"u")if(LE(r)){const o=new Blob([r],{type:t.mimeType});t.image=await createImageBitmap(o)}else return console.error(`Unsupported image type ${t.mimeType??""}`),!1;else return!1;return!0}async function xE(e,t){if(t.uri===void 0)return!1;const n=t.mimeType||oE(t.uri);if(t.mimeType=n,typeof createImageBitmap<"u"&&(n===Xs.JPEG||n===Xs.PNG))if(t.uri.startsWith("data:image")){const i=Dp(t.uri);t.image=await createImageBitmap(new Blob([i],{type:n}))}else{const i=un(t.uri)?t.uri:`${Lp(e.path)}${t.uri}`,r=await(await Wl(i)).arrayBuffer();t.image=await createImageBitmap(new Blob([r],{type:n}))}else return console.error(`Unsupported image type ${n}`),!1;return!0}async function _E(e,t){await Promise.all(e.images.map(async n=>{if(n.image){n.mimeType!==Xs.GLTEXTURE&&console.error("Image has already been loaded");return}await EE(e,n,t)||await xE(e,n)||console.error(`Was not able to resolve image with uri ${n.uri}`)}))}async function PE(e,t){const n=O1(e,self.origin);try{const i=await Wl(n);let s=Xl,r;try{const o=await i.arrayBuffer();if(Ho.isGlb(o)){const u=new Ho(o).extractGlbData();s=u.json,r=u.buffers}else{const f=new TextDecoder("utf-8"),u=new Uint8Array(o);s=JSON.parse(f.decode(u))}const a=$A(s,n),c=AE(a,r),l=_E(a,c),d=SE(a,t);return await Promise.all([c,l,d]),{type:"ok",result:a}}catch(o){return{type:"error",layer:"parsing",originalError:o}}}catch(i){return{type:"error",layer:"network",originalError:i}}}function LE(e){const t=e[0]===137&&e[1]===80&&e[2]===78&&e[3]===71&&e[4]===13&&e[5]===10&&e[6]===26&&e[7]===10,n=e[0]===255&&e[1]===216&&e[2]===255;return t||n}class DE{async loadModel(t,n){return await PE(t,n)}}class OE{constructor(t,n){this.scope=t,this.options=n,this.tileLoader=new Nl("arrayBuffer"),this.tiles=new Map,this.url=i=>{const[s,r,o]=Mr(i);return Mu(this.options,s,r,o,this.options.tileSet)}}abortTileFetches(t){this.tileLoader.abortRequests(t.map(Ie))}deleteTiles(t){t.forEach(n=>this.tiles.delete(Ie(n)))}async generateTile(t,n){const i=[],s=[],r=Ie(n),o=this.tiles.get(r);if(!o)return Promise.resolve({results:i,transferable:s,minZ:0,maxZ:0,tree:null});const a=yv(o);do Mt.generateMeshElevation(this.scope.collector,a,t,Is);while(this.scope.collector.isOverloaded());const c=this.scope.collector.getAccumulatedData();this.scope.resetCollector();const l=hv(c.data);return i.push({regionId:0,metatileHash:-1,styleId:t,collectorOutput:c}),s.push(...c.transferable),l&&s.push(l),Promise.resolve({results:i,tree:l,transferable:s,minZ:a.minZ,maxZ:a.maxZ})}fetchTiles(t){return t.map(n=>this.fetchTile(n))}setOptions(t){this.options=t}fetchTile(t){const n=Ie(t),i=[{regionId:0,metatileHash:-1}];if(this.tiles.has(n))return Promise.resolve(i);const s=this.url(t);return this.tileLoader.fetch(t,()=>s).then(r=>(r.rejected||this.tiles.set(n,r.data&&r.data.byteLength?r.data:void 0),i),()=>Promise.resolve(void 0))}}function CE(e){let t=!1,n;return function(...i){return t||(t=!0,n=e.apply(this,i)),n}}m.processRTLTextIfNeeded=e=>e,m.markAsReady=null,m.rtlAdapterReady=!1;const FE=new Promise(e=>{m.markAsReady=()=>{m.rtlAdapterReady=!0,e()}}),NE=new Set(["ar"]);function Np(e,t){return e==="always-on"||e==="depends-on-language"&&NE.has(t)}function RE(e,t,n){const i=t.workers.labeling;function s(){i.markRtlPluginLoaded().then(()=>{m.markAsReady!==null&&m.markAsReady()})}return Np(e.scenario,n)?fetch(e.url,{integrity:e.hash}).then(r=>r.text()).then(r=>Promise.all([i.loadRtlPlugin(r),Promise.resolve(Rp(r))])).catch(r=>{s();const o=new Error,a="[RTL Plugin]: loading failed.";throw o.message=BE(r)?`${a} ${r.message}`:a,o}):(s(),Promise.resolve())}const Rp=CE(function(e){new Function(e)(),m.processRTLTextIfNeeded=self.mapglRtlPlugin.processRtl,m.markAsReady&&m.markAsReady()});function BE(e){return typeof e=="object"&&!!e&&"message"in e}m.ArrowGenerator=Ps,m.BBoxType=Tt,m.BLEND_EQUATION=wI,m.BLEND_FUNC=gI,m.BaseTileLoader=Nl,m.Buffer=ke,m.BufferChannel=Dh,m.BuildingModelGenerator=an,m.CULL_FACE_MODE=yI,m.Camera=ns,m.CircleMarkerGenerator=Hr,m.ClassRegistry=gA,m.Collector=VS,m.DEFAULT_EMPTY_KEY=td,m.DEFAULT_FONT=gi,m.DEFAULT_ID_SCOPE=tl,m.DEFAULT_LIGHTING_MODES=YS,m.DEFAULT_MAPGL_STYLE=Kp,m.DEFAULT_MIN_TIERS_STYLE_ZOOM=xd,m.DEFAULT_MODELS_APPEAR_STRATEGY=ed,m.DEM_ELEVATION_TILE_SIZE=uv,m.DEM_STYLE_LAYER_ID=Is,m.DEM_TILE_URL_FUNCTION=Mu,m.DEM_TREE_SIZE=Iu,m.DEPTH_FUNC=Fh,m.DYNAMIC_MODEL_ID_SCOPE=eI,m.DYNAMIC_STYLE_ID=Mo,m.DashedLineGenerator=on,m.DemGenerator=Mt,m.Differ=R0,m.DynamicStyle=KI,m.EARTH_CIRCUMFERENCE=da,m.EMPTY_FEATURE_COLLECTION=Lo,m.EMPTY_SHADER_DEFINITIONS=ol,m.ENVIRONMENT_STYLE_LAYER_ID=lc,m.Ecef=Ve,m.Evented=_a,m.FLOOR_ID_SCOPE=Qb,m.FnRegistry=yA,m.GEOJSON_DEFAULT_MAX_DETAIL_LEVEL=bl,m.GLOBE_TEXTURE_SIZE=nm,m.GL_TRIANGLES=Js,m.GeoJsonSource=z0,m.GeoJsonSourceCore=F0,m.GeoJsonSourceWorker=VA,m.GeoJsonTileSource=BT,m.GeoJsonViewportSource=kT,m.GlobeGenerator=js,m.GltfDemPosition=ch,m.GltfModelGenerator=Rn,m.HALF_WORLD_SIZE=2147483648,m.HandyIndexer=nl,m.HeatmapGenerator=di,m.HideLevel=zi,m.INVALID_FRAMEBUFFER_ID=Lr,m.INVALID_IDENTIFY_CENTER_COORD=Vo,m.IdScope=tI,m.LABELING_TEXTURE_BACKGROUND_COLOR=GS,m.LABELING_TEXTURE_DEM_MESH_COLOR=jS,m.LATEST_TILE_VERSION=Pp,m.LRU=y0,m.LabelGeometryType=ai,m.LabelIndex=Bc,m.LabelSource=Ds,m.LabelingAnimation=xh,m.LabelingElementType=Re,m.LabelingTileElement=qr,m.LengthUnits=_n,m.LineExtrusionGenerator=cn,m.LineGenerator=Qe,m.LinePatternType=Jc,m.MAP_DEFAULTS=Yo,m.MAP_MESH_TEXTURE_INDEX=G1,m.MAP_POINTS_IN_METER=me,m.MODELS_TILES_VIEWPORT_PADDING=em,m.MainConnector=pA,m.MapMeshGenerator=Ui,m.Mercator=oe,m.MeshElevationWorker=OE,m.MeshFillSide=se,m.MeshGenerator=Q,m.ModelStepSource=fi,m.ModelsWorker=DE,m.PBR_TEXTURE_INDEX=z1,m.POINT_CENTER_SIZE=$o,m.PolygonExtrusionGenerator=On,m.PolygonGenerator=Nt,m.PreLabelType=ln,m.RasterGenerator=$r,m.RasterSetType=li,m.ReservedLightingMode=gs,m.SIMPLE_MESH_STYLE_LAYER_ID=ZI,m.SceneObjectType=ka,m.Shader=To,m.ShaderAttribute=jy,m.TEXTURE_COORDS_TO_WEBGL=Sm,m.ThreadName=zn,m.TileLayer=C0,m.TileObject=Eo,m.TileObjectBase=l0,m.TileStatus=ll,m.TwoKeyMap=WS,m.UNIVERSE_REGION_ID=tm,m.UNUSED_STYLE_ID_SHIFT=ZS,m.WEBGL_COORDS_TO_TEXTURE=Am,m.WEB_MERCATOR_TO_WORLD_SIZE_MULTIPLIER=Wp,m.WorkerConnector=mA,m.ZenithSourceCore=fI,m.ZenithWorker=FS,m.ZoomDirection=Et,m.add=Pt,m.add$1=Vn,m.addGeneratedDataToTileMod=d0,m.adjustGlobeDragSpeed=o1,m.affineStep=na,m.allFontGlyphsLoaded=sA,m.applyDefaults=wn,m.applyStyleOptions=sb,m.assertUnreachable=$f,m.atlasSize=qt,m.bezier=n0,m.bindUrl=D1,m.buildingAnimation=dd,m.calcAngle=S1,m.calcMidpoint=A1,m.center=fr,m.cityCommPoiLabelingConfig=ud,m.clamp=ge,m.clampLat=f1,m.clampPoint=d1,m.clone=fm,m.clone$1=km,m.commPoiLayers=Oh,m.commercialPoi=Zo,m.compare=br,m.compileRtlPlugin=Rp,m.componentTypeToWebGl=Hy,m.contains=u1,m.convertStyleLayerTypeToHandy=Uw,m.coordsToKey=Ie,m.copy=ym,m.copy$1=$d,m.copy$2=pa,m.copy$3=nr,m.create=is,m.create$1=rt,m.create$2=Nd,m.create$3=ts,m.create$4=Ae,m.createGeoJsonMetatile=dp,m.createGridState=I0,m.createLoadedRasterSet=x2,m.createMetatile=rf,m.createObjectAttributesArray=Ee,m.createTileInfo=Je,m.cross=Qi,m.debounce=B0,m.decomposeMat4=P1,m.deepEqual=wi,m.defaultCameraConfig=_t,m.defaultLang=pd,m.defaultMarkerAnchor=Ed,m.defaultMarkerIcon=Ad,m.defaultModelsPath=jp,m.defaultShadowsSettings=_d,m.degToRad=pe,m.dem=id,m.dist=In,m.dist$1=ya,m.distance=qi,m.dot=ma,m.dot$1=bn,m.dracoDecoderUrl=Zp,m.drawIdentifyScene=QI,m.earcut=Vl,m.ease=s0,m.emptyFeatureAttrs=of,m.emptySourceAttrs=Ea,m.entranceAnimation=fd,m.equalArrays=am,m.equalSets=om,m.equals=t1,m.equals$1=mm,m.events=cd,m.exactEquals=Tm,m.exactEquals$1=sr,m.exactEquals$2=Ym,m.excludeItemFromArray=cm,m.exist=o0,m.expandByPoint=Wn,m.expressionValues=ii,m.findVisibleTiles=wf,m.finishStyleUpdatingAction=P0,m.fixedMetatile=B1,m.fixedTileProps=Xn,m.floors=Ko,m.fonts=xt,m.forceGlStatusCheck=Xh,m.fromGeo=l1,m.fromRotationTranslationScale=Im,m.fromScaling=bm,m.fromTranslationScale=or,m.fromValues=qe,m.fromValues$1=sa,m.generalize=T2,m.generateHaltonSequence=Ig,m.generateHandyLayers=el,m.generateIconElement=Uc,m.generateNotStretchableIconElement=D2,m.generatePointsOnSphere=Mg,m.generateSafely=_h,m.generateTextElement=Qr,m.generateTileBounds=Wh,m.geoJsonMetatileHash=Ql,m.geoLineDistance=Lm,m.geoPointsDistance=ua,m.geoToMapDistance=dr,m.get=VM,m.getArrayBuffer=Do,m.getBoundsTileCoords=By,m.getCenterCorrection=r1,m.getClosestPointOnLineSegment=ly,m.getColorForShaders=Mw,m.getElevationFromTile=pv,m.getFontNameWithFallback=rA,m.getFontUrl=Q2,m.getFractionalPart=rm,m.getJson=G0,m.getLabelingInfo=Wb,m.getLayerImageProps=Gh,m.getLineConstants=qn,m.getMetersFromPixelsXY=c1,m.getModelUrl=eb,m.getPixelsPerMeter=Er,m.getPoiIconData=db,m.getRandomValue=ys,m.getRawMemoryStats=FT,m.getSizeDependentImageUrl=rh,m.getStaticIconRasterSetKey=Li,m.getStaticTextureRasterSetKey=_r,m.getStyleUrl=rb,m.getStyleZoom=Wd,m.getSubdomainFromString=Aa,m.getSymbolLayers=Jh,m.getTextMetrics=iA,m.getTierFromLevels=_b,m.getTileBounds=wr,m.getTileCoordsByCenterAndZoom=Ra,m.getTileModToGenerate=m0,m.getTilesToAbortFetch=w0,m.getTilesToFetch=g0,m.getTilesToGenerate=v0,m.getTilesToRemove=b0,m.getTotalMemory=vl,m.getTriple=tr,m.getUrl=rs,m.getUrlForIconMapIcon=jc,m.getUrlFromTemplate=os,m.getVisibleMapReplicas=ky,m.getZoomFromStyleZoom=a1,m.globeConfig=gn,m.globeTileScale=_m,m.handyColor=ms,m.hashToString=nf,m.heightToZoom=Em,m.icons=od,m.identify=qo,m.identity=oa,m.index=im,m.inertia=Jo,m.inferGeneratorType=Vy,m.int64ToString=Mh,m.intersection=p1,m.intersection$1=Jb,m.invert=Ji,m.isArrayOfNumbers=Qt,m.isBetween=ia,m.isCommercialCityPoi=th,m.isCommercialModel=X2,m.isCommercialPoi=fo,m.isCommercialPoi$1=ci,m.isCommercialPoiCity=y2,m.isCommercialPoiLabel=Os,m.isCommercialPoiPremium=g2,m.isCommercialPremiumPoi=nh,m.isExtractableHandyExpression=ag,m.isHandyExpression=$t,m.isHandySimpleType=Nf,m.isInt64=Bb,m.isLatValid=h1,m.isLineStyleLayer=Lv,m.isNullVector=T1,m.isNullish=lm,m.isObject=dm,m.isPersonalPoi=W2,m.isRtlPluginRequired=Np,m.isStyleColor=ei,m.isStyleGradient=Ha,m.isStyleId=Nw,m.isStyleLayerHidable=kw,m.isStyleLayerType=Bw,m.isStyleMixColor=lg,m.isTileOnSphereInViewport=Sr,m.isTileVisible=vr,m.isTilesIntersects=Sy,m.isTypedArray=ub,m.keyServerPath=Vp,m.keyToCoords=Ca,m.labeling=Qs,m.len=Fd,m.len$1=cr,m.length=Mn,m.lerp=$n,m.lerp$1=e1,m.lerp$2=vi,m.limitString=yg,m.linePatternFromString=Eh,m.linear=i0,m.loadModelsInfoStyleZoom=Wo,m.log=Pe,m.logEmptyTileGenerationResponse=Gf,m.logGltfError=wg,m.lookAt=la,m.makeBinderContext=eu,m.makeGeneratorContext=ws,m.makeHandyDemLayer=rl,m.makeHandyGroupOrLayer=kh,m.makeHandyLightStyle=Hh,m.makeHandyRasterSet=zh,m.makeHandyRasterSets=Uh,m.makeHandyStyle=jI,m.makeHandyStyleLayer=Io,m.makeLabelingContext=Dt,m.mapHeightToTileHeight=$e,m.mapPointPitch=Fm,m.mapPointTo32ZoomTileCoords=Ry,m.mapPointToTilePoint=gt,m.mapToPixelDistance=Cm,m.maxTilePoint=ne,m.maxU32=Xp,m.maxUint16Value=Oe,m.metricsTimeout=vd,m.modStatsGpu=wl,m.modStatsJs=gl,m.modelCacheSize=sd,m.modelSizeGpu=OT,m.modelSizeJs=DT,m.models=nd,m.mul=n1,m.mul$1=Ii,m.multiply=aa,m.newFrameAction=A0,m.normalize=zt,m.normalize$1=vn,m.normalizeMapPoint=Rm,m.normalizeMousePosition=sm,m.optionsToTileAttrs=Zh,m.ortho=Mm,m.overlappedGroupName=Pn,m.packTexCoords=ht,m.performanceCheck=wd,m.pixelRatioToDpi=ec,m.pixelToMapDistance=zd,m.pixelsAndMapDistanceToZoom=Gd,m.pointToLineDistance=sy,m.pointToLineSignedDistance=ff,m.preLabelingPoint=sh,m.prepareMetatile=sf,m.processElement=Zb,m.processFont=oA,m.projectToXyRect=L1,m.radToDeg=jn,m.rbush=Nr,m.removeUndefined=Zg,m.renameZenithEnumerationValues=dI,m.render=hd,m.reserveTextureIndex=La,m.reset=wa,m.resetGridState=hl,m.resolveAnimationExpression=Xf,m.resolveColor=Dn,m.resolveExpression=G,m.resolveGradient=bw,m.resolveLightingModes=Tw,m.resolveNumber=ae,m.resolveSimpleLiteralExpression=Ye,m.resolveString=Ke,m.resolveTextureAnimationExpression=qf,m.rotateVec2=E1,m.rotateX=Hm,m.rotateY=Vm,m.rtlAdapterPromise=FE,m.rtlPluginHash=Yp,m.rtlPluginUrl=$p,m.runPrecomputes=Qc,m.sample=Kf,m.sampleColor=Qf,m.scale=Tn,m.scale$1=m1,m.scale$2=mt,m.scale$3=bi,m.scale$4=Km,m.selectRaster=Cs,m.set=Se,m.set$1=qm,m.set$2=wm,m.setSeed=a2,m.setupMapboxRtlAdapterIfNeeded=RE,m.sign=er,m.slerp=ur,m.sourceUuid=N0,m.splitPolylineByLength=ay,m.splitPolylineByMaxSize=cy,m.spreadTileObjects=qh,m.sqrDist=Wm,m.start=r0,m.startStyleUpdatingAction=_0,m.stop=al,m.stride=Hs,m.styles=ad,m.sub=Jt,m.sub$1=Gt,m.subtract=Xb,m.template=ss,m.tetragonBounds=gr,m.tetragonIntersectsBounds=uf,m.textureSizeGpu=PT,m.textureSizeJs=yl,m.throttle=NS,m.tileCoordOffset=B,m.tileCoordsToMapPoint=xi,m.tileCoordsToOSM=Mr,m.tileHeight=Zi,m.tileObjectStatsGpu=O0,m.tileObjectStatsJS=D0,m.tilePointScaleFactor=vt,m.tileSizeZpt=256,m.tileZoomToSize=wt,m.tiles=Gn,m.toStyleColor=Yt,m.traffic=rd,m.transformMat4=lr,m.transformMat4$1=es,m.uint16ToTileCoords=yi,m.uniqId=Pa,m.unpackPreLabelingResult=h2,m.update=a0,m.updateScene=T0,m.urls=Ks,m.vertexTilePointToMapPoint=If,m.viewportChangeAction=ml,m.viewportTilesReady=ul,m.workerResetInterval=ld,m.worldBounds=Dm,m.worldLoopBounds=Om,m.worldSize=4294967296,m.worldWrapX=Ki,m.z0Scale=Jl,m.zenithSourceAttrs=af,m.zenithToJakartaPropKey=oI,m.zoom=md,m.zoomToHeight=Mi,m.zoomToScale=xm,m.zptPerInch=Wi,m.zptToSceneDistance=Pm}));

_mapgl_d("worker",["./shared"],(function(e){"use strict";class ce{constructor(t,n,r){this.line=t,this.lengths=[],this.angles=[];let a=n,l=t[0],i=t[1];const u=t.length/3;for(let o=0;o<u;o++){const c=t[o*3]-l,f=t[o*3+1]-i;a+=Math.sqrt(c*c+f*f),this.lengths.push(a),l+=c,i+=f}this.finishLength=this.lengths[this.lengths.length-1],this.startLength=this.lengths[0],this.midLength=r/2,this.vertexCount=u,this.angles.push(0);for(let o=1;o<u;o++){const c=this.line[(o-1)*3],f=this.line[o*3],y=this.line[(o-1)*3+1],g=this.line[o*3+1];this.angles.push(Math.atan2(g-y,f-c))}}interpolate(t,n){const r=n,a=r-1,l=this.lengths[a],i=this.lengths[r],u=this.line[a*3],o=this.line[r*3],c=this.line[a*3+1],f=this.line[r*3+1],y=(t-l)/(i-l);return[(1-y)*u+y*o,(1-y)*c+y*f,0,this.angles[n]]}getSegmentIndex(t){for(let n=0;n<this.lengths.length;n++)if(t<this.lengths[n])return n;return this.lengths.length}}class Te{constructor(){this.labels={}}add(t){const n=t.id,r=t.componentDistanceStart;this.labels[n]===void 0&&(this.labels[n]={});const a=this.labels[n];a[r]===void 0&&(a[r]=[]),a[r].push(t)}merge(){const t=[];for(const n in this.labels){const r=this.labels[n],a=Object.keys(r).sort((i,u)=>Number(i)-Number(u));let l=0;for(;l<a.length;){const i=a[l];if(r[i].length===0){l++;continue}const u=[];let o=r[i].pop();for(;o!==void 0;)if(u.push(o),(o.componentDistanceStart!==0||o.componentDistanceEnd!==0)&&r[o.componentDistanceEnd]!==void 0){const c=o;if(o=r[o.componentDistanceEnd].pop(),o){const f=c.mapPointVertices.length;(c.mapPointVertices[f-3]!==o.mapPointVertices[0]||c.mapPointVertices[f-2]!==o.mapPointVertices[1])&&(o=void 0)}}else o=void 0;if(u.length===1){const c=u[0];c.axis=new ce(c.mapPointVertices,c.componentDistanceStartWorld,c.objectLengthWorld),t.push(c)}else u.length>1&&t.push(this.stitch(u))}}return t}stitch(t){let n=0;for(let i=0;i<t.length;i++)n+=t[i].mapPointVertices.length;n-=(t.length-1)*3;const r=new Int32Array(n);let a=0;for(let i=0;i<t.length;i++){const u=t[i].mapPointVertices,o=i>0?3:0;for(let c=o;c<u.length;c++)r[a++]=u[c]}const l=t[0];return l.axis=new ce(r,l.componentDistanceStartWorld,l.objectLengthWorld),t[0]}}class ve{constructor(t,n,r,a,l,i,u,o,c,f,y,g){this.type=e.LabelingElementType.Box,this.marginTopBottom=0,this.marginLeftRight=0,this.id=t,this.label={layer:{innerId:0},styleId:-100,id:this.id,symbol:"nevermind",phase:NaN},this.groupPriority=g??e.maxU32,this.itemPriority=y??1,this.parent=f,this.placementIndex=0,this.labelingGroup=c,this.labelingGroupTable=o.labelingGroups.table,this.anchorWorld=e.create$3(),e.copy$2(this.anchorWorld,a),i!==0&&(this.anchorWorld[2]*=i),this.anchorGeo=e.Mercator.toGeo(this.anchorWorld),this.anchorScreen=u.project(this.anchorGeo),e.add(this.anchorScreen,this.anchorScreen,l),this.boxes=[[0,0,n,r]]}}const re=e.degToRad(e.labeling.axisAngleToleranceDeg),Ie=e.labeling.axisCheckDistancePx,Pe=e.degToRad(e.labeling.lineLabelsHidePitchDeg);function ke(s,t,n,r,a,l,i,u,o,c,f,y){const g=[],d=[],I=[],S=[],N={},_=Ee(s,a),T=new Te;for(let P=0;P<s.length;P++){const C=s[P],M=a.get(C);if(M===void 0)continue;const W=t.styleState._activeFloorIds;for(let D=0;D<M.length;D++){const h=M[D];if(h.source===e.LabelSource.Tile&&c.has(h.id)&&!h.floorId||h.floorId&&(h.planLevel=y[h.floorId],!e.isCommercialPoiLabel(h)&&(W.length===0||!W.includes(h.floorId))))continue;const L=r.getStyle(h.styleId);if(!L){console.error(`Not found style ${h.styleId} in labeling#collectLabelingElements`);continue}if(!(h.source!==e.LabelSource.PersonalPoi&&_.personalPoi.has(h.id)&&!e.isCommercialPoiLabel(h))&&!(h.source===e.LabelSource.PersonalPoi&&_.commercialPoi.has(h.id)))switch(h.layer.type){case"point":{if(ae(h,i,u,t.styleState,t.styleZoom,L,f,t.elevation)&&ee(h,t.styleZoom))if(h.geometryType===e.LabelGeometryType.Line)T.add(h);else{const p=[h.mapPointVertices[0],h.mapPointVertices[1],h.mapPointVertices[2],0];le(S,I,N,h,p,n,t,L,o)}break}case"labelLine":{ae(h,i,u,t.styleState,t.styleZoom,L,f,t.elevation)&&ee(h,t.styleZoom)&&T.add(h);break}case"oneWayLine":ee(h,t.styleZoom)&&T.add(h);break}}}const F=T.merge();for(let P=0;P<F.length;P++){const C=F[P],M=r.getStyle(C.styleId);if(!M){console.error(`Not found style ${C.styleId} in labeling#collectLabelingElements`);continue}C.layer.type==="point"?Me(S,I,N,C,M,n,t,o):we(d,S,C,M,n,t)}return l.forEach(({id:P,width:C,height:M,position:W,offset:D,labelingGroup:h,parentPoiId:L})=>{let w;if(L&&(w=N[L],!w))return;const p=r.getStyle(e.DYNAMIC_STYLE_ID);if(!p){console.error(`Not found style ${e.DYNAMIC_STYLE_ID} in labeling#collectLabelingElements`);return}const m=new ve(P,C,M,W,D,t.buildingHeight,n,p,h,w,w?.itemPriority,w?.groupPriority);g.push(m)}),{boxElements:g,oneWayTileElements:d,noLabelingElements:I,otherTileElements:S}}function Ee(s,t){const n={personalPoi:new Set,commercialPoi:new Set};for(const r of s){const a=t.get(r);if(a!==void 0)for(const l of a)l.source===e.LabelSource.PersonalPoi?n.personalPoi.add(l.id):e.isCommercialPoiLabel(l)&&n.commercialPoi.add(l.id)}return n}function ae(s,t,n,r,a,l,i,u){const{layer:o}=s;if(o.type!=="point"&&o.type!=="labelLine")return!1;Number.isNaN(s.demElevation)?s.elevation=0:s.elevation=(s.demElevation-(u??0))*e.MAP_POINTS_IN_METER;const c=e.makeLabelingContext(a,r,!1,s.tileData);if(e.rtlAdapterReady&&!s.rtlProcessed&&(s.label=e.processRTLTextIfNeeded(s.label)??"",s.label2=e.processRTLTextIfNeeded(s.label2),s.iconLabel=e.processRTLTextIfNeeded(s.iconLabel),s.updateRanges(),i(e.DEFAULT_FONT,s.ranges),e.expressionValues(o.style.textFont).forEach(S=>{S.length&&i(S,s.ranges)}),o.type==="point"&&o.style.textFont2&&e.expressionValues(o.style.textFont2).forEach(S=>{S.length&&i(S,s.ranges)}),o.type==="point"&&o.style.iconTextFont&&e.expressionValues(o.style.iconTextFont).forEach(S=>{S.length&&i(S,s.ranges)}),s.rtlProcessed=!0),!s.rtlProcessed)return!1;const{ranges:f}=s,y=e.getFontNameWithFallback(o.style.textFont,c,l);let g;if(y&&s.label&&e.allFontGlyphsLoaded(y,f,n)&&(g=e.getTextMetrics(s.label,o.style.textLetterSpacing,t[y]),s.textMetrics=g),o.type==="labelLine")return!y||!!g;const d=e.getFontNameWithFallback(o.style.iconTextFont,c,l);d&&s.iconLabel&&e.allFontGlyphsLoaded(d,f,n)&&(s.iconTextMetrics=e.getTextMetrics(s.iconLabel,o.style.iconTextLetterSpacing,t[d]));const I=e.getFontNameWithFallback(o.style.textFont2,c,l);return y&&s.label&&I&&s.label2&&e.allFontGlyphsLoaded(I,f,n)&&(s.textMetrics2=e.getTextMetrics(s.label2,o.style.textLetterSpacing,t[I])),!y||!s.label?!d||!s.iconLabel||!!s.iconTextMetrics:!!g&&(!d||!s.iconLabel||!!s.iconTextMetrics)&&(!I||!s.label2||!!s.textMetrics2)}function le(s,t,n,r,a,l,i,u,o){e.getLabelingInfo(r,a,u,r.layer,i,l,o);for(let c=0;c<r.labelingElements.length;c++){const f=r.labelingElements[c];if(f.labelingGroup===e.overlappedGroupName||f.parent?.labelingGroup===e.overlappedGroupName){t.push(f);continue}s.push(f),f.type===e.LabelingElementType.Icon&&(n[f.label.id]=f)}}function Me(s,t,n,r,a,l,i,u){const{layer:o}=r;if(o.type!=="point")return;const{zoom:c,styleZoom:f}=i,y=Math.floor(f),g=c+(y-f),{startLength:d,midLength:I,finishLength:S}=r.axis,N=e.makeLabelingContext(y,i.styleState,!1,r.tileData),_=Math.max(e.pixelToMapDistance(e.resolveNumber(o.style.duplicationSpacing,N),g),1),T=e.pixelToMapDistance(o.style.endingOffsets,c),F=d+(I-d)%_,P=d+T,C=S-T;for(let M=F;M<C;M+=_)if(M>P){const W=r.axis,D=M,h=W.getSegmentIndex(D),L=W.interpolate(D,h);le(s,t,n,r,L,l,i,a,u)}}function we(s,t,n,r,a,l){const{layer:i}=n;if(i.type!=="labelLine"&&i.type!=="oneWayLine")return;const{zoom:u,styleZoom:o}=l,c=Math.floor(o),f=u+(c-o),{startLength:y,midLength:g,finishLength:d}=n.axis,I=e.makeLabelingContext(o,l.styleState,!1,n.tileData),S=e.makeLabelingContext(c,l.styleState,!1,n.tileData);let N,_,T,F;if(i.type==="labelLine"){const p=e.resolveNumber(i.style.textFontSize,I)/e.fonts.baseSize,m=e.resolveNumber(i.style.textFontSize,S)/e.fonts.baseSize;N=n.textMetrics.maxWidth*p,_=n.textMetrics.maxWidth*m,T=e.pixelToMapDistance(e.resolveNumber(i.style.textDuplicationSpacing,S),f),F=e.pixelToMapDistance(Math.max(i.style.lineEndingOffsets,i.style.textLabelingSideMargin),u)}else N=e.resolveNumber(i.style.lineLength,I),_=e.resolveNumber(i.style.lineLength,S),T=e.pixelToMapDistance(e.resolveNumber(i.style.duplicationSpacing,S),f),F=e.pixelToMapDistance(i.style.endingOffsets,u);const P=e.pixelToMapDistance(_,f),M=e.pixelToMapDistance(N,u)/2,W=T+P,D=y+(g-y)%W,h=y+M+F,L=d-M-F,w=i.type!=="labelLine"?s:t;for(let p=D;p<L;p+=W)p>h&&Ne(w,n,p,M,N,a,l,r)}function Ne(s,t,n,r,a,l,i,u){const o=t.axis,{zoom:c,styleZoom:f}=i,{startLength:y,finishLength:g}=o,d=o.getSegmentIndex(n),I=o.interpolate(n,d);if(e.mapPointPitch(l.position,I,i.center)>Pe||!_e(t,n,r,c,f,i.styleState))return;const N=t.layer.type==="oneWayLine",_=N?e.LabelingElementType.OneWayLine:e.LabelingElementType.LineText,T=new e.LabelingTileElement(t,_,I,i.buildingHeight,l,u,i.globeMode,i.styleState._floorHeight);T.anchorPosition=n,T.anchorSegmentIndex=d,T.halfLabelWidth=r,N||(T.overflowStyleZoom=e.getStyleZoom(e.pixelsAndMapDistanceToZoom(a,g-y),I),Ce(T,t,n,r,i,l)),s.push(T)}function _e(s,t,n,r,a,l){if(s.layer.type==="oneWayLine")return!0;const i=s.axis,u=e.makeLabelingContext(a,l,!1,s.tileData),o=e.resolveNumber(s.layer.style.textFontSize,u)/e.fonts.baseSize,c=i.getSegmentIndex(t-n),f=i.getSegmentIndex(t+n),y=e.pixelToMapDistance(Ie*o,r);for(let g=c;g<f;g++){if(g>1&&fe(i.angles[g-1],i.angles[g])>re)return!1;const d=i.getSegmentIndex(i.lengths[g]-y);if(d!==0){const I=i.angles[d],S=i.angles[i.getSegmentIndex(i.lengths[g]+y)];if(fe(I,S)>re)return!1}}return!0}function fe(s,t){const n=Math.abs(s-t);return n>Math.PI?2*Math.PI-n:n}function Ce(s,t,n,r,a,l){const{axis:i,layer:u}=t;if(u.type!=="labelLine")return;const{zoom:o,styleZoom:c}=a,f=e.makeLabelingContext(c,a.styleState,!1,t.tileData),y=e.resolveNumber(u.style.textFontSize,f),g=y/2,d=e.pixelToMapDistance(y,o),I=e.pixelToMapDistance(u.style.textLabelingSideMargin,o),S=Math.max(0,n-r+d/2-I),N=Math.min(i.lengths[i.lengths.length-1],n+r-d/2+I);let _=i.getSegmentIndex(S);for(let T=S;T<N;T+=d){for(;i.lengths[_]<T;)_++;ue(s,i,T,_,l,g)}for(;i.lengths[_]<N;)_++;ue(s,i,N,_,l,g)}function ue(s,t,n,r,a,l){const i=a.flat.project(t.interpolate(n,r));i[0]=i[0]-s.anchorScreen[0],i[1]=i[1]-s.anchorScreen[1],s.boxes.push([i[0]-l,i[1]-l,i[0]+l,i[1]+l])}function ee(s,t){const{source:n,detailLevel:r,layer:{minzoom:a,maxzoom:l}}=s,i=n===e.LabelSource.PersonalPoi,u=i||a>r,o=i||l<r+1||r===e.tiles.maxDetailLevel;return(!u||t>=a)&&(!o||t<l)}function U(s){return typeof s!="boolean"&&s.type==="attrs"}function he(s){return typeof s!="boolean"&&s.type==="unextractable"}function A(s){if(!e.isHandyExpression(s))return[!!s];let t=[];const n=[];switch(s.type){case"all":const a=s.array.map(A);for(const u of a){const o=[];for(const c of u){if(c===!1)return[!1];U(c)?o.push(c):he(c)&&n.push(c)}o.length>0&&(t.length===0?t=o:t=ge(t,o))}break;case"match":if(!e.isExtractableHandyExpression(s.input))return[{type:"unextractable",exp:s}];if(s.input.type==="precompute")return[{type:"unextractable",exp:s}];const l=s.input.property,i=s.defaultOutput;for(const u of s.cases){const o=A(u.output),c=[];u.values.forEach(f=>{c.push({type:"attrs",attrs:{[l]:f}})});for(const f of o)if(U(f))for(const y of ge([f],c))t.push(y);else if(he(f)){n.push(f);for(const y of c)t.push(y)}else if(f===!0&&!i)for(const y of c)t.push(y)}break;case"==":{let u,o;if(e.isExtractableHandyExpression(s.leftValue)&&e.isHandySimpleType(s.rightValue))u=s.leftValue.property,o=s.rightValue;else if(e.isExtractableHandyExpression(s.rightValue)&&e.isHandySimpleType(s.leftValue))u=s.rightValue.property,o=s.leftValue;else return[{type:"unextractable",exp:s}];t.push({type:"attrs",attrs:{[u]:o}});break}default:return[{type:"unextractable",exp:s}]}return t.concat(n)}function ge(s,t){const n=[];for(const r of s)for(const a of t)n.push({type:"attrs",attrs:{...r.attrs,...a.attrs}});return n}class Re{constructor(){this.layers=[],this.keyStat={},this.orderedKeys=[],this.tree=null,this.treeNodesCount=0,this.traverseCount=0,this.traverseIterations=0}addLayers(t){for(const n of t)n.type==="custom"||!n.filter||(this.layers.push(n),this.statLayerKeys(n));this.buildTree()}getLayers(t,n){const r=[],a=(l,i)=>{if(this.traverseIterations+=1,!l)return;for(const f of l.leafs)r.push(f);const u=this.orderedKeys[i];if(!u)return;const o=n[t[u]],c=e.isInt64(o)?e.int64ToString(o):o;c!==void 0&&a(l.children[c],i+1),a(l.novalue,i+1)};return this.traverseCount+=1,a(this.tree,0),r}stat(){const t=this.traverseIterations/this.traverseCount||0;return{tree:this.tree,treeNodes:this.treeNodesCount,layers:this.layers.length,keyStat:this.keyStat,itersPerTraverse:t}}statLayerKeys(t){const r=A(t.filter).filter(a=>U(a))[0];if(!(!r||!U(r)))for(const a in r.attrs)this.keyStat[a]===void 0&&(this.keyStat[a]=0),this.keyStat[a]+=1}getOrderedKeys(){return Object.entries(this.keyStat).sort(([n,r],[a,l])=>l-r).map(([n,r])=>n)}buildTree(){this.orderedKeys=this.getOrderedKeys();const t=[];for(const n of this.layers){const a=A(n.filter).filter(U);a.length===0&&t.push(n);for(const l of a){const i=new Set(Object.keys(l.attrs));let u=0;const o=l.attrs;let c=this.tree;for(let f=0;f<=this.orderedKeys.length;f++){if(u===i.size){c?.leafs.push(n);break}const y=this.orderedKeys[f],g=this.orderedKeys[f+1]||"";if(c||(c=this.makeTreeNode(y),this.tree===null&&(this.tree=c)),i.has(y)){const d=o[y];c.children[d]||(c.children[d]=this.makeTreeNode(g)),c=c.children[d],u+=1}else c.novalue||(c.novalue=this.makeTreeNode(g)),c=c.novalue}}}t.length>0&&(this.tree||(this.tree=this.makeTreeNode("")),this.tree.leafs=t)}makeTreeNode(t){return this.treeNodesCount+=1,{key:t,children:{},novalue:null,leafs:[]}}}class ye{constructor(){this.metaStyles=new Map,this.layerTrees=new Map}proxySyncStyle(t){const n=new Re;n.addLayers(t.layers),this.layerTrees.set(t.id,n),this.metaStyles.set(t.id,t),this.removeUnusedStyle(t.id-e.UNUSED_STYLE_ID_SHIFT)}getStyle(t){return this.metaStyles.get(t)}getLayers(t,n,r){const a=this.layerTrees.get(t);return a?a.getLayers(n,r):[]}removeUnusedStyle(t){t<1||(this.metaStyles.delete(t),this.layerTrees.delete(t))}}const De=new Map;function Fe(s){const t=new e.WorkerConnector(s),n=new e.FnRegistry(t),r=new e.Collector("labeling"),a=new ye,l=n.get(e.ThreadName.Main,"loadFont"),i=new Map,u=new Map;let o=[],c=new Map;const f=new e.TwoKeyMap,y=new e.TwoKeyMap,g={},d=e.throttle(()=>r.reset(),e.workerResetInterval),I=m=>{e.setSeed(m)};n.set("setComPoiRandomSeed",I);const S=()=>{const m=r.getBucketsMemoryFootprint(),b=[];let k=0;Array.from(i.keys()).forEach(x=>{const Z=i.get(x);Z&&(k+=Z.length,b.push({label:{[x]:Z.map(()=>({label:1}))}}))});const v={collector:{buckets:m},labeling:b};return{js:{...v,"--labelsCount":k,"--sum":e.getTotalMemory(v)}}};n.set("getMemoryFootprint",S);const N=(m,b,k,v,x)=>{const Z=e.unpackPreLabelingResult(k,b,a,v,x);i.set(m,Z)};n.set("appendLabels",N);function _(m,b){for(const k of b)f.has(m,k)||(l(m,k),f.set(m,k,!0))}const T=(m,b)=>{u.set(m,b)};n.set("appendLabelBox",T);const F=m=>{u.delete(m)};n.set("removeEmptyBoxLabel",F);const P=m=>{i.delete(m),u.delete(m)};n.set("removeLabels",P);function C(m,b,k){if(m.has(k.label.sourceId))return e.LabelingAnimation.none;const v=b.get(k.id);return v===void 0||v.placementIndex===void 0||v.type===e.LabelingElementType.Icon&&v.layer.innerId!==k.layer.innerId?e.LabelingAnimation.fadeIn:v.placementIndex===k.placementIndex?e.LabelingAnimation.none:e.LabelingAnimation.fadeIn}const M=(m,b,k,v,x,Z,B,z)=>{const j=new Set(x),H=[];let K=new Map;const q=[];return k.forEach(V=>{const Y=new e.Camera(V),O=new Set,G=[...b];m.forEach(({sourceId:E,animate:R,labelsKeys:$})=>{R||O.add(E),G.push(...$)});const{boxElements:me,oneWayTileElements:je,otherTileElements:ne,noLabelingElements:Ge}=ke(G,V,Y,a,i,u,g,y,v,j,_,z),se=e.generalize(ne,me,V,B?De:c,Z,Y),X=[...Ge,...je,...ne],oe=new Map;for(let E=0;E<X.length;E++){const R=X[E];R.placementIndex!==-1&&oe.set(R.id,R)}for(let E=0;E<X.length;E++){const R=X[E],{label:{styleId:$,layer:ie}}=R;if(R.placementIndex===-1)continue;const J=C(O,c,R),Q=a.getStyle($);if(!Q){console.error(`Not found style ${$} in labeling#processLabels`);continue}e.processElement(Q,ie,r,R,J,v,V,V.tileInfo)}for(let E=0;E<o.length;E++){const R=o[E],{id:$,label:ie,layer:J}=R,{styleId:Q}=ie,Se=a.getStyle(Q);if(!Se){console.error(`Not found style ${Q} in labeling#processLabels`);continue}if(O.has(R.label.sourceId))continue;const He=R.placementIndex,pe=oe.get($);He===-1||R.placementIndex===pe?.placementIndex&&(R.type!==e.LabelingElementType.Icon||R.layer.innerId===pe?.layer.innerId)||V.styleZoom<R.overflowStyleZoom||V.styleZoom<J.minzoom||V.styleZoom>=J.maxzoom||e.processElement(Se,J,r,R,e.LabelingAnimation.fadeOut,v,V,V.tileInfo)}H.push(...X),K=new Map([...K,...oe]);const de=r.getAccumulatedData(),be=[];for(const E of me)E.placementIndex!==-1&&be.push(E.label.id);const xe=new Map,Ke=e.tetragonBounds(V.tilesBounds);for(const E of ne)if(E.placementIndex!==-1&&e.isCommercialPoi$1(E)&&e.contains(Ke,E.anchorWorld)){const R={};e.isCommercialPoiCity(E)?R.adsPriority="city":e.isCommercialPoiPremium(E)&&(R.adsPriority="premium"),xe.set(E.label.id,R)}const Le={survivedLabelBoxIds:be,survivedCommPois:Array.from(xe).map(E=>{const R={id:E[0]};return E[1].adsPriority!==void 0&&(R.adsPriority=E[1].adsPriority),R}),collectorOutput:de,transferable:de.transferable};if(se){const E=new Int32Array(se.length);E.set(se),Le.labels=E.buffer}q.push(Le)}),o=H,c=K,d(),q};n.set("processLabels",M);const W=(m,b)=>{g[m]||(g[m]={});const k=g[m];for(const v in b)k[v]=b[v]};n.set("appendFont",W);const D=(m,b)=>{y.set(m,b,!0)};n.set("markFontAsLoaded",D);const h=(m,b)=>{const k=a.getStyle(m);if(!k){console.error(`Not found style ${m} in labeling#addNewRasterSets`);return}const{rasterSets:v}=k;b.forEach(x=>{v.byIndex[x.index]=x,v.byKey[x.key]=x})};n.set("addNewRasterSets",h);const L=(m,b)=>{const k=a.getStyle(m);if(!k){console.error(`Not found style ${m} in labeling#updatePackingInfo`);return}const{rasterSets:v}=k,x=7,Z=b.length/x;for(let B=0;B<Z;B++){const z=b[B*x],j=b[B*x+1],H=b[B*x+6],K=b[B*x+2],q=b[B*x+3],V=b[B*x+4],Y=b[B*x+5],O=v.byIndex[z];if(O===void 0){console.error(`Not found raster set with index ${z}`);continue}if(O.isSvg)O.rasters[j]={rasterIndex:j,rasterSetIndex:z,x:K,y:q,w:V,h:Y,anchorX:O.anchorX,anchorY:O.anchorY,atlasIndex:H,isPacked:!0};else{const G=O.rasters[j]??{rasterIndex:j,rasterSetIndex:z,x:K,y:q,w:V,h:Y,anchorX:0,anchorY:0,atlasIndex:H,isPacked:!0};O.rasters[j]=G,G.x=K,G.y=q,G.atlasIndex=H,G.isPacked=!0}}};n.set("updatePackingInfo",L);const w=()=>{o=[],c.clear()};n.set("clearPreviousLabels",w);const p=(...m)=>a.proxySyncStyle(...m);n.set("syncStyle",p),n.set("loadRtlPlugin",e.compileRtlPlugin),n.set("markRtlPluginLoaded",()=>{e.markAsReady&&e.markAsReady()})}function We(s){const t=new e.WorkerConnector(s),n=new e.FnRegistry(t);new e.ClassRegistry(n).set("ModelsWorker",e.ModelsWorker)}function Ze(s,t,n,r,a,l,i,u,o){if(!n)return s.getAccumulatedData();const c=u.coords[3],{tileProps:f}=t,y=Object.keys(f).length,g=[],d=e.pixelRatioToDpi(l),I=e.makeGeneratorContext(a,e.emptySourceAttrs,f,g,e.emptyFeatureAttrs,void 0,u);for(const S of i.tile){const{color:N=0,color2:_=0,geo:T,road:F,normals:P,zLevel:C=0,is_immersive:M,logicalLevels:W}=S;for(let D=0;D<y;D++)g[D]=NaN;g[f.db_sublayer]="Traffic_jams",g[f.traffic_color]=N,g[f.traffic_color2]=_,g[f.traffic_road_class]=F,g[f.traffic_road_z_level]=C,g[f.db_tiers]=W?[e.getTierFromLevels(W.begin,W.end)]:void 0,g[f.db_has_immersive_counterpart]=Number(M),g[f.beginningIsCut]=0,g[f.endingIsCut]=0;for(let D=0;D<T.length;D++){const h=T[D],L=P[D],w=[],p=[],m=[],b=[];for(let x=0;x<h.length;x++)w[x]=h[x][0]*e.uint16ToTileCoords,p[x]=h[x][1]*e.uint16ToTileCoords,m[x]=L[x][0],b[x]=L[x][1];const k={x:w,y:p,normal_x:m,normal_y:b},v=r.getLayers(n.id,f,g).filter(x=>e.resolveExpression(x.filter,I));v.length===0&&I.id&&s.idIndexer.addOrphanId(I.id),e.generateHandyLayers(s,n,v,I,t,e.LATEST_TILE_VERSION,c,o,u,d,k)}}return s.getAccumulatedData()}let te=[];function Be(s,t,n,r,a,l,i,u,o){const{tileProps:c,dictionaries:f}=r,y=Object.keys(c).length,g=new Set(i),d=[];if(f.db_sublayer?.s_personal_poi===void 0)return s.getAccumulatedData();for(let P=0;P<y;P++)d[P]=NaN;const I=e.pixelRatioToDpi(l),S=e.create(),N=[];for(const P of u){const C=e.Mercator.fromGeo(P.point);e.expandByPoint(S,C),N.push(C)}const _=e.getBoundsTileCoords(S),T=e.createTileInfo(_),F=e.makeGeneratorContext(n,e.emptySourceAttrs,c,d,e.emptyFeatureAttrs,void 0,T);for(let P=0;P<u.length;P++){const C=u[P],M=e.create$1();e.mapPointToTilePoint(M,N[P],T);const W=C.id;F.id=W;const D={x:[M[0]],y:[M[1]]};for(let L=0;L<y;L++)d[L]=NaN;d[c.db_sublayer]="s_personal_poi",d[c.db_object_class]=C.humanReadableClassId??r.reverseDictionaries.db_object_class?.[C.classId],d[c.db_label]=C.name,d[c.db_icon_priority]=1,d[c.db_label_priority]=0,d[c.selected]=g.has(W)?1:0,d[c.db_region]=a,te=t.layers.filter(L=>e.resolveExpression(L.filter,F)),te.length===0&&F.id&&s.idIndexer.addOrphanId(F.id),e.generateHandyLayers(s,t,te,F,r,e.LATEST_TILE_VERSION,void 0,o,T,I,D)}return s.getAccumulatedData()}class Ve{constructor(){this.cache=new Map,this.pendingRequests=new Map}fetch(t,n,r,a,l){return new Promise(i=>{const u=Oe(t,a,l,n,r),o=e.coordsToKey(t),c=e.getJson({url:u},(f,y)=>{if(this.pendingRequests.delete(o),f!==void 0){f.status!==204&&console.error(f),this.cache.set(o,void 0),i();return}const g=y[0];g?this.cache.set(o,g):this.cache.set(o,void 0),i()});this.pendingRequests.set(o,{xhr:c,resolve:i})})}get(t){return this.cache.get(t)}delete(t){this.cache.delete(t)}abortRequest(t){const n=this.pendingRequests.get(t);n!==void 0&&(n.xhr.abort(),n.resolve(),this.pendingRequests.delete(t))}}function Oe(s,t,n,r,a){const l=2**s[2]-1,i=s[0],o=(l-s[1]&16777215)*(1<<24)+(i&16777215);return e.template(e.traffic.url,{protocol:a,host:r,z:String(s[2]),tiles:String(o),regions:t.join(","),time:String(n)})}function ze(s){const t=new e.WorkerConnector(s),n=new e.FnRegistry(t),r=new e.ClassRegistry(n),a=new Ve,l=new ye,i={main:{addNewRasterSets:n.get(e.ThreadName.Main,"addNewRasterSets")},labeling:{addNewRasterSets:n.get(e.ThreadName.Labeling,"addNewRasterSets")}},u={},o=new e.Collector("parser"),c=e.throttle(()=>o.reset(),e.workerResetInterval),f=()=>{const h=o.atlasPacker.getNewRasterSets();h.size&&h.forEach((L,w)=>{i.main.addNewRasterSets(w,L),i.labeling.addNewRasterSets(w,L)})},y={sources:{},collector:o,styleManager:l,syncNewRasterSets:f,debouncedResetCollector:c};r.set("GeoJsonSource",e.GeoJsonSourceWorker,y,["fetchTiles"]);const g={collector:o,metatiles:u,styleManager:l,syncRasterSets:f,resetCollector:c,createImageBitmap:s.createImageBitmap?s.createImageBitmap.bind(s):void 0};r.set("ZenithWorker",e.ZenithWorker,g,["fetchTiles"]);const d={collector:o,resetCollector:c};r.set("MeshElevationWorker",e.MeshElevationWorker,d,["fetchTiles"]);const I=(h,L)=>{u[h]=L};n.set("setMetatile",I);const S=()=>{const h=o.getIndexerStats(),L=o.getStatsAfterReset(),w=o.getBucketsMemoryFootprint(),p=[];r.classes.get("ZenithWorker")?.hosts.forEach(b=>{b.tileLoader&&b.tileLoader.cache.size>0&&b.tileLoader.cache.forEach((k,v)=>{p.push({[v]:b.tileLoader.cache.get(v).reduce((x,Z)=>x+Z.data.byteLength,0)})})});const m={collector:{buckets:w,reset:L,idIndexer:h},zenit:{cache:p}};return{js:{...m,"--sum":e.getTotalMemory(m)}}};n.set("getMemoryFootprint",S);const N=(...h)=>l.proxySyncStyle(...h);n.set("syncStyle",N);const _=h=>new Promise(L=>{e.getArrayBuffer({url:h},(w,p)=>{if(w||p.byteLength===0){L(void 0);return}if(s.createImageBitmap){const m=new Blob([p],{type:"image/png"});createImageBitmap(m).then(b=>{L({isBitmap:!0,data:[b],transferable:[b]})})}else L({isBitmap:!1,data:[p],transferable:[p]})})});n.set("prepareAtlas",_);const T=h=>{for(let p=0;p<h.length;p+=3){const m=h[p+2],b={type:e.RasterSetType.Loaded,isSvg:!1,index:m,key:`loaded-${m}`,name:"",fileName:"",rasters:[{rasterSetIndex:m,rasterIndex:0,w:h[p],h:h[p+1],atlasIndex:0,x:0,y:0,isPacked:!1,anchorX:0,anchorY:0}]};o.atlasPacker.pack(b,[h[p]],1)}const L=o.atlasPacker.getPackedRasters(),w=[];return L!==void 0&&w.push(L.buffer),{packedRasters:L,transferable:w}};n.set("packRasters",T);const F=h=>a.fetch(h.coords,h.tileServer,h.tileProtocol,h.regionIds,h.timestamp);n.set("fetchTrafficTile",F);const P=h=>{a.delete(h)};n.set("deleteTrafficTile",P);const C=h=>{a.abortRequest(h)};n.set("abortTrafficTileRequest",C);const M=e.createMetatile(["db_sublayer","traffic_road_class","traffic_color","traffic_road_z_level","db_tiers","db_has_immersive_counterpart","beginningIsCut","endingIsCut","traffic_color2"],["Traffic_jams"]),W=({coords:h,pixelRatio:L,styleState:w,styleId:p,sourceId:m})=>{const b=e.coordsToKey(h),k=e.createTileInfo(h),v=[],x=[],Z=1,B=l.getStyle(p);if(!B)return Promise.resolve({results:v,transferable:x});const z=a.get(b);if(z){const j=Ze(o,M,B,l,w,L,z,k,m);v.push({regionId:Z,metatileHash:0,styleId:B.id,collectorOutput:j})}return Promise.resolve({results:v,transferable:x})};n.set("generateTrafficTile",W);const D=(h,L,w,p,m,b,k,v)=>{const x=l.getStyle(b);if(!x)return;const Z=Be(o,x,k,u[w],L,p,m,h,v);return c(),f(),{collectorOutput:Z,transferable:Z.transferable,styleId:x.id}};n.set("generatePersonalPoi",D)}self.addEventListener("message",s=>{const{msg:t}=s.data;if("youare"in t)switch(t.youare){case"labeling":Fe(self);break;case"models":We(self);break;case"parser":ze(self);break;default:throw new Error("Unknown worker type")}})}));

_mapgl_d("index",["exports","./shared"],(function(re,n){"use strict";var ct,Lt;var us=document.createElement("style");us.textContent=`.mapgl-hover{cursor:pointer}.mapgl-dragging{cursor:grabbing}.mapgl-rotating{cursor:move}.mapgl_QEdaFvncPWE-{width:32px;box-shadow:0 1px 3px #26262680;border-radius:4px;display:flex;flex-direction:column;overflow:hidden;background:#fff}.mapgl_mjx-K8iaDdc-{all:revert;padding:0;outline:0;border:none;cursor:pointer;background:#fff;width:32px;height:32px;color:#262626;box-sizing:border-box}.mapgl_mjx-K8iaDdc-:hover{opacity:.7}.mapgl_mjx-K8iaDdc-:active{color:#028eff}.mapgl_mjx-K8iaDdc-:disabled{background:#f2f2f2;color:#929292;cursor:default}.mapgl_zKZCVsRur9c-{border-bottom:1px solid #e6e6e6}.mapgl_3t-wJELDATg-{border-bottom:none}.mapgl_ON-gf73kIU0-{background:#fff;box-shadow:0 1px 3px #26262680;border-radius:4px;width:32px;overflow:hidden}.mapgl_mWyZxMObEi8-{all:revert;padding:0;outline:0;border:none;cursor:pointer;box-sizing:border-box;font-size:18px;font-weight:400;width:32px;height:32px;color:#262626;background:#fff}.mapgl_FwnEmRmDBLg-:hover{opacity:.7}.mapgl_uSuUHuf71nM-{background:#299400;color:#fff}.mapgl_LdqAv9Ly624-{background:#ffb81c;color:#fff}.mapgl_udRZCM1quWE-{background:#fe5000;color:#fff}.mapgl_uSuUHuf71nM-:hover,.mapgl_LdqAv9Ly624-:hover,.mapgl_udRZCM1quWE-:hover{color:#262626b3}.mapgl_K-1Yb8HCVpQ-{display:block!important}.mapgl_K-1Yb8HCVpQ- .mapgl_CLps5xx6CNs-{height:20px!important;display:block!important}.mapgl_r8Wn2E5pGh0-{pointer-events:none;position:absolute;top:0;left:0;width:100%;height:100%;display:flex;justify-content:center;align-items:center;padding:10px;background-color:#0003;cursor:default}.mapgl_ir0vRf5QXrk-{text-align:center;font-size:24px;font-family:Helvetica,Arial,sans-serif;font-weight:700;color:#fff}.mapgl_h2pl79nAYpk-{position:relative}.mapgl_64D1bmNQN3Q-{display:flex;max-height:40vh;background:#fff;width:32px;overflow:hidden;border-radius:4px;box-shadow:0 1px 3px #26262680}.mapgl_jdJbkjpLO7k-{width:100%;overflow-x:hidden;overflow-y:auto;-moz-padding-end:17px;-webkit-padding-end:17px;-webkit-margin-end:-17px}.mapgl_54Rmy50n6Fw-{display:flex;flex-direction:column-reverse}.mapgl_3i1QoGerxio-{all:revert;padding:0;border:none;background:#fff;height:32px;width:32px;color:#262626;cursor:pointer;border-bottom:1px solid #e6e6e6;box-sizing:border-box;flex-shrink:0}.mapgl_3i1QoGerxio-:focus{outline:0}.mapgl_3i1QoGerxio-:first-child{border-bottom:none}.mapgl_3i1QoGerxio-:hover{color:#262626b3}.mapgl_3i1QoGerxio-:active{color:#028eff}.mapgl_3i1QoGerxio-:disabled{background:#f2f2f2;color:#929292;fill:#929292;cursor:default}.mapgl_wGplqJ4hHPc-{font-size:18px;line-height:32px;font-weight:400;overflow-wrap:break-word;position:relative;text-align:center;height:100%}.mapgl_wGplqJ4hHPc- svg{margin-top:3px}.mapgl_PkWXKxsq1Kc-:after{content:"";position:absolute;top:4px;bottom:4px;width:4px;height:4px;border-radius:50%;background:#028eff}.mapgl_z0m6n5pr5no-{position:absolute;pointer-events:none;inset:0}.mapgl_ITPUswrhaGk-{position:absolute;display:flex;z-index:50;pointer-events:none;width:100%;height:100%}.mapgl_ITPUswrhaGk->div>*{pointer-events:auto}.mapgl_Px-KwzXdVa0-{flex-direction:column;align-items:flex-start}.mapgl_SCX3EYsS-Cw-{flex-direction:row;justify-content:center;align-items:flex-start}.mapgl_i42TyWqpCPk-{flex-direction:column;align-items:flex-end}.mapgl_-zKby6nN-nU-{flex-direction:column;justify-content:center;align-items:flex-start}.mapgl_SlQM4-ZNKF0-{flex-direction:column;justify-content:center;align-items:flex-end}.mapgl_lNg3h7Hg-Mo-{flex-direction:column-reverse;align-items:flex-start}.mapgl_grOepPBwilk-{flex-direction:row;justify-content:center;align-items:flex-end}.mapgl_CiHYefDPhI0-{flex-direction:column-reverse;align-items:flex-end}.mapgl_Px-KwzXdVa0->div+div,.mapgl_i42TyWqpCPk->div+div,.mapgl_-zKby6nN-nU->div+div,.mapgl_SlQM4-ZNKF0->div+div{margin-top:10px}.mapgl_lNg3h7Hg-Mo->div+div,.mapgl_CiHYefDPhI0->div+div{margin-bottom:10px}.mapgl_SCX3EYsS-Cw->div+div,.mapgl_grOepPBwilk->div+div{margin-left:10px}.mapgl_9m2ynAxdBT0-{background:#ffffffad;border-width:0 1px 1px 1px;border-color:#7a7a7a;border-style:solid;border-radius:0;min-width:64px;height:16px;overflow:hidden;pointer-events:none!important}.mapgl_sR4nXEQ3L2M-{min-width:50px;height:12px;margin-top:2px;margin-left:6px;font-family:Helvetica,Arial,sans-serif!important;font-style:normal;font-weight:400;font-size:9px;line-height:12px;color:#262626}.mapgl_54Xq9OUdARA-{font-family:Helvetica,Arial,sans-serif!important;font-size:8px!important;line-height:8px!important;text-align:right!important;display:flex;align-items:flex-start;color:#6d7173!important}.mapgl_qYE18V9u8c0-{display:block}a.mapgl_wYSwIqldiqU-{color:#6d7173!important;text-decoration:none!important}a.mapgl_wYSwIqldiqU-:hover{color:#929292!important}
/*$vite$:1*/`,document.head.appendChild(us);function hs(s,e,t){if(s.length===0)return;const i=n.degToRad(e),o=n.create();for(const r of s){const l=n.Mercator.fromGeo(r);n.rotateVec2(l,-i),n.expandByPoint(o,l)}const a=n.create$1();return n.center(a,o),n.rotateVec2(a,i),{center:a,zoom:nc(o,t)}}function nc(s,e){return Math.min(n.pixelsAndMapDistanceToZoom(e[0],Math.abs(s.max[0]-s.min[0])),n.pixelsAndMapDistanceToZoom(e[1],Math.abs(s.max[1]-s.min[1])))}function oc(s,e,t){const i=hs(s,e,t);if(i)return{zoom:i.zoom,center:n.Mercator.toGeo(i.center)}}function ye(s,e,t){const i=s.getBoundingClientRect();return[e-i.left-s.clientLeft,t-i.top-s.clientTop]}function yt(s,e){const t=[];for(let i=0;i<s.length;i++)t[i]=ye(e,s[i].clientX,s[i].clientY);return t}function Rn(s){return s.touches.length>1}const sc=n.Mercator.fromGeo,ac=n.Mercator.toGeo;function rc(s,e,t,i,o,a,r={top:0,right:0,bottom:0,left:0},l={top:0,right:0,bottom:0,left:0},c=!1){return new n.Camera({center:n.Mercator.fromGeo(s),zoom:e,rotation:n.degToRad(t),size:i,pitch:n.degToRad(o),viewport:r,padding:l,cameraConfig:n.defaultCameraConfig,globeMode:c,styleState:{}}).project(a)}function lc(s,e,t,i,o,a,r={top:0,right:0,bottom:0,left:0},l={top:0,right:0,bottom:0,left:0},c=!1){return new n.Camera({center:n.Mercator.fromGeo(s),zoom:e,rotation:n.degToRad(t),size:i,pitch:n.degToRad(o),viewport:r,padding:l,cameraConfig:n.defaultCameraConfig,globeMode:c,styleState:{}}).unproject(a)}function cc(s,e,t,i,o,a,r={top:0,right:0,bottom:0,left:0},l={top:0,right:0,bottom:0,left:0},c){return n.getMetersFromPixelsXY(s,e,t,i,o,a,r,l,c,c)}function dc(s,e){return new n.Camera(s).project(n.Mercator.toGeo(e))}const _c=Object.freeze(Object.defineProperty({__proto__:null,geoLineDistance:n.geoLineDistance,geoToMapDistance:n.geoToMapDistance,getCenterZoomByPoints:oc,getMetersFromPixels:cc,getMousePositionInContainer:ye,projectGeoToMap:sc,projectGeoToScreen:rc,projectMapToGeo:ac,projectMapToScreen:dc,projectScreenToGeo:lc},Symbol.toStringTag,{value:"Module"})),uc=Object.freeze(Object.defineProperty({__proto__:null,getMetersFromPixelsXY:n.getMetersFromPixelsXY,getUrl:n.getUrl,hashToString:n.hashToString},Symbol.toStringTag,{value:"Module"}));class Re extends n.Evented{constructor(e,t,i){super(),this.interactive=t.interactive??!0,this.uniqId=String(n.uniqId()),this.parentObject=i,this.modules=e.modules,this.mapState=e.state,this.tileObjects=[],this.identifyIds=[]}update(){this.mapState.needReplicasUpdate&&this.tileObjects.forEach(e=>{e.needSync=!0})}destroy(){const e=this.modules;this.tileObjects.forEach(t=>{t.clean(this.mapState),e.tileManager.removeObject(t)}),this.tileObjects=[],e.layers.removeLayer(this),e.renderer.addRerenderEvent()}getIdentifyData(){return this.identifyIds.map(e=>({dynamicObjectId:this.uniqId,metatileHash:-1,ids:e}))}isInteractive(){return this.interactive}}const fs=["disableDragging","enableTrackResize","loopWorld","disableHidingPois","enableTwoFingerDragging"];let Fn=class{constructor(e,t,i){this.options=t,this.type="zenith",this.id=n.sourceUuid(),this.identifyAsDefaultSource=t.identifyAsDefaultSource??!0,this.identifyAsDefaultSource&&!t.promoteId&&(t.promoteId="id"),this.sourceOptions=t,this.modelsAppearStrategy=t.modelsAppearStrategy??n.DEFAULT_MODELS_APPEAR_STRATEGY,this.state=e.state,this.modules=e.modules,this.sourceCore=new n.ZenithSourceCore(this.id,this.modules,this.options),this.tileLayer=new n.TileLayer(t.minZoom??n.tiles.maxUniverseZoom+1,t.maxZoom??n.tiles.maxRegionalZoom,t.minZoom??n.tiles.maxUniverseZoom+1,t.maxDetailLevel??n.tiles.maxDetailLevel,this.modules,this.state,this.sourceCore,this.options),this.modules.tileManager.addTileLayer(this.tileLayer),this.modules.sourceStorage.addSource(this),this.mapglApiSource=i}getObjectAttributes(e,t){return this.sourceCore.getObjectAttributes(e,t)}getId(){return this.id}getOptions(){return this.sourceOptions}getAttributes(){return this.sourceCore.getAttributes()}getZoomDirection(){return this.tileLayer.getZoomDirection()}setAttributes(e){this.sourceCore.setAttributes(e),this.tileLayer.redraw()}getUrl(e,t){return n.getUrl(e,{host:this.options.tileServer,tileSet:this.options.tileSet,protocol:this.options.tileProtocol,subdomain:this.options.subdomains[0],...t})}destroy(){this.modules.tileManager.removeTileLayer(this.tileLayer),this.tileLayer.destroy(),this.modules.sourceStorage.removeSource(this.id),this.sourceCore.destroy()}setFeatureStateMap(e){this.sourceCore.setFeatureStateMap(e),this.tileLayer.onFeatureStateMapChange()}isIdentifiedAsDefault(){return this.identifyAsDefaultSource}};function ms(s,e){if(e===void 0||e.sourceId&&!s.getSourceById(e.sourceId)?.isIdentifiedAsDefault())return;const t={id:e.id,symbol:e.symbol};return e.symbol==="point"&&(t.isText=e.instanceId===1),e.sublayer&&(t.isCityCommercial=n.isCommercialCityPoi(e.sublayer),t.isPremiumCommercial=n.isCommercialPremiumPoi(e.sublayer),t.isCommercial=n.isCommercialPoi(e.sublayer),t.isPersonal=n.isPersonalPoi(e.sublayer),(e.symbol==="point"&&!t.isCommercial||e.symbol==="gltfModel")&&(t.sysCode=e.objectClass)),e.center&&(t.center=n.Mercator.toGeo(e.center)),e.symbol==="gltfModel"&&(t.sublayer=e.sublayer,t.isCommercial=!!e.sublayer&&n.isCommercialModel(e.sublayer)),t}function hc(s,e){if(e===void 0)return;if(e.sourceId){const i=s.getSourceById(e.sourceId);if(i)switch(i.type){case"geojson":{if(i.subtype==="internal"&&i instanceof n.GeoJsonSource||i.subtype==="viewport-internal"&&i instanceof n.GeoJsonViewportSource)return{type:"geojson",id:e.id,feature:i.getFeatureById(e.id,e.tileKey),source:i};if(i.subtype==="external"&&i instanceof n.GeoJsonTileSource)return{type:"geojsonTile",getFeatureProperties:()=>e.tileKey===void 0?Promise.resolve():i.getObjectAttributes(e.id,e.tileKey),source:i}}case"zenith":if(i instanceof Fn)return{type:"zenith",id:e.id,source:i,attributes:i.getObjectAttributes(e.tileKey??"",e.id)}}}const t={type:"default",id:e.id};return e.floorId&&(t.floorId=e.floorId),t}function nt(s,e,t,i,o){const a=o.camera,r=[0,0];if(a.unproject(i,r,!0),e&&e.dynamicObjectId!==void 0){const h=s;let f=o.layers.getDynamicObjectLayers().find(p=>p.uniqId===e.dynamicObjectId);if(f?.parentObject&&(f=f?.parentObject),!f)return;const m={lngLat:r,originalEvent:t,point:i,targetData:f};f.emit(h,m);return}const l=ms(o.sourceStorage,e),c=hc(o.sourceStorage,e);if((s==="mousedown"||s==="click")&&e!==void 0&&l?.symbol==="point"&&c!==void 0){const h=n.getPoiIconData(o,e,l)||{};h!==void 0&&(c.poiIcon=h)}if(e){const h=o.styleManager.getStyleLayer(e.styleId,e.layerId);h&&c&&(c.layerId=h.id)}const _={lngLat:r,originalEvent:t,point:i,target:l,targetData:c},u=s;o.map.emit(u,_)}class ps extends Re{constructor(e,t,i){super(e,t),this.start=o=>{const{modules:a,container:r}=this,{camera:l}=a;if(o.button!==0)return;const c=ye(r,o.clientX,o.clientY);this.contains(c)&&(a.handler.block(),a.mouseMoveHandler.block(),this.dragStartCursorPoint=c,this.dragStartAnchorPoint=l.project(n.Mercator.toGeo(this.getPosition())),document.addEventListener("mouseup",this.stop),document.addEventListener("mousemove",this.move),this.emitEvent("dragstart",o))},this.move=o=>{const{camera:a}=this.modules,{dragStartAnchorPoint:r,dragStartCursorPoint:l,container:c}=this;if(r===void 0||l===void 0)return;const d=ye(c,o.clientX,o.clientY),_=n.clone(r);n.add(_,_,d),n.sub(_,_,l),this.setPosition(n.Mercator.fromGeo(a.unproject(_))),this.emitEvent("drag",o)},this.stop=o=>{if(o.button!==0)return;this.dragStartCursorPoint=void 0,this.dragStartAnchorPoint=void 0,document.removeEventListener("mouseup",this.stop),document.removeEventListener("mousemove",this.move);const{modules:a}=this;a.handler.unblock(),a.mouseMoveHandler.unblock(),this.emitEvent("dragend",o),this.interactive&&a.identifier.resetCache()},this.container=e.modules.layout.mapContainer,i&&this.container.addEventListener("mousedown",this.start,!0)}destroy(){super.destroy(),this.container.removeEventListener("mousedown",this.start,!0),document.removeEventListener("mouseup",this.stop),document.removeEventListener("mousemove",this.move)}emitEvent(e,t){const i=this.getPosition(),o=n.Mercator.toGeo(i),a=this.modules.camera.flat.project(i),r=this.modules.identifier.searchSync(a),l=r!==void 0&&r.dynamicObjectId===void 0?ms(this.modules.sourceStorage,r):void 0;this.emit(e,{originalEvent:t,target:l,targetData:this,lngLat:o,point:a})}}const fc=!1;let vs=class extends ps{constructor(e,t){super(e,t,t.draggable??fc),this.visible=!0,this.options=t;const i=n.Mercator.fromGeo(this.options.coordinates);this.position={userValue:i,normalizedValue:n.normalizeMapPoint(i)};const{dynamicStyle:o,collector:a,tileManager:r,identifier:l,layers:c}=this.modules;if(this.layer=n.makeHandyStyleLayer({type:"circle",id:`dynamic-circleMarker-${this.uniqId}`,minzoom:this.options.minZoom,maxzoom:this.options.maxZoom,style:{color:this.options.color,strokeColor:this.options.borderColor,strokeColor2:this.options.border2Color,width:this.options.width,strokeWidth:this.options.borderWidth,strokeWidth2:this.options.border2Width}}),!this.layer)return;o.addLayer(this.layer,this.options.zIndex);const d=i[2]??0,_=n.mapPointTo32ZoomTileCoords(this.position.normalizedValue),u=n.optionsToTileAttrs({}),h={x:[0],y:[0],z:[d]},f=n.createTileInfo(_),m=n.makeGeneratorContext(this.mapState.styleState,n.emptySourceAttrs,n.fixedTileProps,u,n.emptyFeatureAttrs,this.interactive?"0":"",f);n.runPrecomputes(this.layer,m),n.generateSafely({collector:a,generator:n.CircleMarkerGenerator.generate,args:[o.getStyle().id,this.layer,m,h]});const p=a.getAccumulatedData(),v=new n.TileObject("dynamicObject",p.data,this.modules,this.mapState,_);r.addObject(v),this.tileObjects.push(v),this.interactive&&this.identifyIds.push(p.identifyIds),c.addLayer(this),a.reset(),this.modules.renderer.addRerenderEvent(),this.interactive&&l.resetCache()}remove(){this.layer&&this.modules.dynamicStyle.removeLayer(this.layer.innerId),this.interactive&&this.modules.identifier.resetCache(),super.destroy()}update(){if(this.mapState.globeMode){const{tileManager:e}=this.modules,t=this.modules.camera.ecef.canSee(this.options.coordinates);this.visible&&!t?this.tileObjects.forEach(i=>e.removeObject(i)):!this.visible&&t&&this.tileObjects.forEach(i=>e.addObject(i)),this.visible=t}}isOutOfMainReplica(){return!1}setPosition(e){const t=this.tileObjects[0];t!==void 0&&(this.position={userValue:e,normalizedValue:n.normalizeMapPoint(e)},t.setTileCoords(n.mapPointTo32ZoomTileCoords(this.position.normalizedValue),this.mapState),this.modules.renderer.addRerenderEvent())}getPosition(){return this.position.userValue}contains(e){if(!this.layer)return!1;const{layer:t}=this,{camera:i}=this.modules,o=i.project(n.Mercator.toGeo(this.position.normalizedValue)),a=n.resolveNumber(t.style.width,n.makeBinderContext(this.mapState.styleZoom,this.mapState.styleState,[])),r=n.resolveNumber(t.style.strokeWidth,n.makeBinderContext(this.mapState.styleZoom,this.mapState.styleState,[])),l=a/2+r;return n.dist(o,e)<=l}};function gs(s,e,t){const{top:i,right:o,bottom:a,left:r}=s.viewport,{clientWidth:l,clientHeight:c}=e;s.size=[Math.max(1,l-r-o),Math.max(1,c-i-a)],t.updateFrameBuffersSize()}const mc=(s,e,t,i,o={})=>{const a={top:0,right:0,bottom:0,left:0,...i};if(o.animate===!1||o.duration===0)s.viewport=a,gs(s,e,t);else{const r=s.viewport,l=o.easing!==void 0?o.easing:"easeOutCubic",c=o.duration!==void 0?o.duration:300;n.start("viewport",{easing:l},s,[r.top,r.right,r.bottom,r.left],[a.top,a.right,a.bottom,a.left],c,1)}},pc=(s,e,t)=>{n.update("viewport",{step:(i,o)=>{i.viewport={top:o[0],right:o[1],bottom:o[2],left:o[3]},gs(i,e,t)}},s)};function vc(s,e){return{top:s.top+e.top,bottom:s.bottom+e.bottom,left:s.left+e.left,right:s.right+e.right}}function gc(s){return{top:Math.max(s.top,0),bottom:Math.max(s.bottom,0),left:Math.max(s.left,0),right:Math.max(s.right,0)}}function yc(s,e){return{top:Math.min(s.top,e[1]),bottom:Math.min(s.bottom,e[1]),left:Math.min(s.left,e[0]),right:Math.min(s.right,e[0])}}function bc(s,e){return yc(gc(s),e)}function ys(s,e){const{top:t,right:i,bottom:o,left:a}=s.padding;s.padding={top:t,right:i,bottom:o,left:a},e.addRerenderEvent(),e.updateFrameBuffersSize()}const xc=(s,e,t,i={})=>{const o=bc(t,s.size);if(i.animate===!1||i.duration===0)s.padding=o,ys(s,e);else{const a=s.padding,r=i.easing!==void 0?i.easing:"easeOutCubic",l=i.duration!==void 0?i.duration:300;n.start("padding",{easing:r},s,[a.top,a.right,a.bottom,a.left],[o.top,o.right,o.bottom,o.left],l,1)}},wc=(s,e)=>{n.update("padding",{step:(t,i)=>{t.padding={top:i[0],right:i[1],bottom:i[2],left:i[3]},ys(t,e)}},s)},gi="inertia",Sc=(s,e,t)=>s*Math.pow(1-(t-e)/n.inertia.duration,n.inertia.nonLinearity),Tc=(s,e,t,i,o)=>{n.start(gi,{easing:"inertia"},s,0,o,n.inertia.duration,1,{startPoint:e,startSpeed:t,direction:i,startTime:s.time})},Dn=n.stop.bind(null,gi),Mc=(s,e)=>{n.update(gi,{step:(t,i,o)=>{const{startPoint:a,startSpeed:r,startTime:l,direction:c}=o,d=n.clone$1(c);n.scale(d,d,i),n.add$1(d,d,a),t.loopWorld||t.globeMode?n.isLatValid(t.maxBounds,d)||(On(e,t),n.clampPoint(d,t.maxBounds,d)):n.contains(t.maxBounds,d)||(On(e,t),n.clampPoint(d,t.maxBounds,d)),t.center=d,t.zoomTypePreserving==="zoom"?t.styleZoom=n.getStyleZoom(t.zoom,d):t.zoom=n.getZoomFromStyleZoom(t.styleZoom,d);const _=Sc(r,l,t.time);n.mapToPixelDistance(_,t.zoom)<n.inertia.minSpeed&&On(e,t)}},s)},On=(s,e)=>{n.stop(gi,e),s.classList.remove("mapgl-inertia")},yi="center",bt=(s,e,t={})=>{if(n.stop(yi,s),Dn(s),s.globeMode?n.clampLat(e,s.maxBounds,e):n.clampPoint(e,s.maxBounds,e),t.animate===!1||t.duration===0)s.center=e,s.zoomTypePreserving==="zoom"?s.styleZoom=n.getStyleZoom(s.zoom,e):s.zoom=n.getZoomFromStyleZoom(s.styleZoom,e);else{const i=t.easing!==void 0?t.easing:"linear",o=t.duration!==void 0?t.duration:250;n.start(yi,{easing:i},s,s.center,e,o,1)}},Ec=n.stop.bind(null,yi),Ic=n.update.bind(null,yi,{step:(s,e)=>{s.center=e,s.zoomTypePreserving==="zoom"?s.styleZoom=n.getStyleZoom(s.zoom,e):s.zoom=n.getZoomFromStyleZoom(s.styleZoom,e)}}),bi="rotation";function Nn(s,e){return s=s-e,s>=Math.PI?s=(s+Math.PI)%(Math.PI*2)-Math.PI:s<-Math.PI&&(s=Math.PI-(Math.PI-s)%(Math.PI*2)),s=s+e,s}function Qt(s,e,t={}){if(n.stop(bi,s),t.animate===!1||t.duration===0)s.rotation=Nn(e,0);else{const i=t.normalize!==void 0?t.normalize:!0;n.start(bi,{easing:t.easing||"linear"},s,s.rotation,i?Nn(e,s.rotation):e,t.duration||250,1)}}const Cc=n.stop.bind(null,bi),Lc=n.update.bind(null,bi,{step:(s,e)=>s.rotation=Nn(e,0)}),xi="pitch";function wi(s,e,t={}){n.stop(xi,s);const i=n.clamp(e,s.minPitch,s.maxPitch);t.animate===!1||t.duration===0?s.pitch=i:n.start(xi,{easing:t.easing||"linear"},s,s.pitch,i,t.duration||300,1)}const Pc=n.stop.bind(null,xi),Bc=n.update.bind(null,xi,{step:(s,e)=>s.pitch=e}),Si="zoom",dt=(s,e,t={})=>{n.stop(Si,s);const i=n.clamp(e,s.minZoom,s.maxZoom);if(i!==s.zoom)if(t.animate===!1||t.duration===0)t.zoomPoint&&(n.add$1(s.center,s.center,n.getCenterCorrection(s,t.zoomPoint,{zoom:i})),n.clampPoint(s.center,s.maxBounds,s.center)),s.zoom=i,s.styleZoom=n.getStyleZoom(i,s.center);else{const o=t.useHeightForAnimation?n.zoomToHeight(s.zoom,s.size):s.zoom,a=t.useHeightForAnimation?n.zoomToHeight(i,s.size):i,r=t.easing!==void 0?t.easing:"easeOutCubic",l=t.duration!==void 0?t.duration:250;n.start(Si,{easing:r},s,o,a,l,1,{zoomPoint:t.zoomPoint,useHeightForAnimation:!!t.useHeightForAnimation})}},bs=n.stop.bind(null,Si),zc=n.update.bind(null,Si,{step:(s,e,t={})=>{const i=t&&t.useHeightForAnimation?n.heightToZoom(e,s.size):e;t&&t.zoomPoint&&(n.add$1(s.center,s.center,n.getCenterCorrection(s,t.zoomPoint,{zoom:i})),n.clampPoint(s.center,s.maxBounds,s.center)),s.zoom=i,s.styleZoom=n.getStyleZoom(i,s.center)}}),Rc=navigator.msPointerEnabled&&navigator.msMaxTouchPoints&&!window.PointerEvent,Fc=window.PointerEvent&&navigator.pointerEnabled&&navigator.maxTouchPoints||Rc||"ontouchstart"in window||window.DocumentTouch&&document instanceof window.DocumentTouch,Dc=xt("webkit"),Oc=xt("chrome")||xt("crios"),Nc="ActiveXObject"in window,kc=!Oc&&xt("safari");xt("gecko")&&!Dc&&window.opera;const Ti=navigator.platform.toUpperCase().indexOf("MAC")>=0,Uc=xt("windows"),Gc=xt("firefox");function xt(s){return navigator.userAgent.toLowerCase().indexOf(s)>=0}function ot(s){bs(s),Ec(s),Cc(s),Pc(s),Dn(s)}class Hc{constructor(e,t){this.onWheelScroll=i=>{this.isBlocked||(i.preventDefault(),!(i.deltaMode===void 0&&i.deltaY===void 0)&&(this.state.userHasInteracted=!0,this.screenPoint=ye(this.container,i.clientX,i.clientY),i.ctrlKey?this.deltaAccumulator-=i.deltaY*10:i.deltaMode===1?this.deltaAccumulator-=i.deltaY*20:this.deltaAccumulator-=i.deltaY,this.eventCount+=1))},this.startZooming=()=>{const i=this.state;let o=this.getDelta();Ti?o*=n.zoom.macWheelDeltaToZoomDelta:Number.isInteger(o)?o=n.sign(o)*n.zoom.wheelZoomDelta:o*=n.zoom.notMacTrackpadDeltaToZoomDelta;const a=i.zoom+o,r=n.clamp(a,i.minZoom,i.maxZoom);r!==i.zoom&&(ot(i),dt(i,r,{duration:n.zoom.animDuration,animate:!Ti,zoomPoint:i.keepCenterWhileUserZoomRotate?void 0:this.screenPoint}))},this.stop=()=>{this.state.userHasInteracted=!0,bs(this.state)},this.state=e,this.container=t,Ti||(this.startZooming=n.throttle(this.startZooming,n.zoom.throttleDelay)),this.deltaAccumulator=0,this.eventCount=0,this.screenPoint=[0,0],this.isBlocked=!1,this.container.addEventListener("wheel",this.onWheelScroll),this.container.addEventListener("mousedown",this.stop)}destroy(){this.container.removeEventListener("wheel",this.onWheelScroll),this.container.removeEventListener("mousedown",this.stop)}update(){this.eventCount!==0&&(this.startZooming(),this.state.rerenderEvents.push({type:"coreNeedRerender"}))}block(){this.isBlocked=!0}unblock(){this.isBlocked=!1}getDelta(){const e=this.deltaAccumulator/this.eventCount;return this.deltaAccumulator=0,this.eventCount=0,e}}class Vc{constructor(e,t){this.onMouseUp=i=>{this.isBlocked||i.which===1&&this.start()},this.onTouchEnd=i=>{this.isBlocked||i.touches.length===0&&this.start()},this.start=()=>{const i=this.state;i.userHasInteracted=!0;const o=this.getCurrentSpeed(i.time),a=n.length(o);if(n.mapToPixelDistance(a,i.zoom)<=n.inertia.minSpeed)return;const l=n.pixelToMapDistance(n.inertia.maxSpeed,i.zoom),c=Math.min(a,l),d=this.calcDistanceByStartSpeed(c),_=n.clone$1(i.center),u=n.create$1();n.normalize(u,o),Tc(i,_,c,u,d),this.container.classList.add("mapgl-inertia")},this.stop=()=>{Dn(this.state),this.container.classList.remove("mapgl-inertia"),this.times=[],this.positions=[]},this.state=e,this.container=t,this.isBlocked=!1,this.container.addEventListener("mouseup",this.onMouseUp),this.container.addEventListener("mousedown",this.stop),Fc&&(this.container.addEventListener("touchend",this.onTouchEnd),this.container.addEventListener("touchstart",this.stop)),this.zoomDiffer=new n.Differ([{path:"zoom",type:"number"}]),this.styleZoomDiffer=new n.Differ([{path:"styleZoom",type:"number"}]),this.centerDiffer=new n.Differ([{path:"center",type:"vec2"}]),this.times=[],this.positions=[]}destroy(){this.container.removeEventListener("mouseup",this.onMouseUp),this.container.removeEventListener("mousedown",this.stop),this.container.removeEventListener("touchend",this.onTouchEnd),this.container.removeEventListener("touchstart",this.stop)}update(){const e=this.state;this.centerDiffer.check(e)&&this.rememberTimeAndPosition(e),(e.zoomTypePreserving==="zoom"?this.zoomDiffer.check(e):this.styleZoomDiffer.check(e))&&this.stop()}block(){this.isBlocked=!0}unblock(){this.isBlocked=!1}removeOldRecords(e){for(;e-this.times[0]>100&&this.times.length;)this.times.shift(),this.positions.shift()}rememberTimeAndPosition(e){const t=e.time;this.removeOldRecords(t),this.times.push(t),this.positions.push(n.clone$1(e.center))}getCurrentSpeed(e){if(this.removeOldRecords(e),this.times.length<2)return n.create$1();const t=n.clone$1(this.positions[this.positions.length-1]);return n.sub$1(t,t,this.positions[0]),n.scale(t,t,1/(this.times[this.times.length-1]-this.times[0])),t}calcDistanceByStartSpeed(e){return e*n.inertia.duration/(n.inertia.nonLinearity+1)}}class jc{constructor(e){this.emitMouseEvent=t=>{if(this.isBlocked)return;const i=ye(this.container,t.clientX,t.clientY);this.emitEvent(t,i)},this.emitTouchEvent=t=>{if(this.isBlocked)return;const i=ye(this.container,t.changedTouches[0].clientX,t.changedTouches[0].clientY);this.emitEvent(t,i)},this.container=e.layout.mapContainer,this.modules=e,this.isBlocked=!1,this.container.addEventListener("mouseup",this.emitMouseEvent),this.container.addEventListener("touchend",this.emitTouchEvent)}destroy(){this.container.removeEventListener("mouseup",this.emitMouseEvent),this.container.removeEventListener("touchend",this.emitTouchEvent)}update(){}block(){this.isBlocked=!0}unblock(){this.isBlocked=!1}emitEvent(e,t){if(!this.modules.layout.isActionWithCanvas(e))return;const i=e.type;this.modules.identifier.search(i,t).then(o=>{nt(i,o,e,t,this.modules)})}}class Zc{constructor(e,t,i){this.rotationDetected=!1,this.onGestureStart=o=>{this.isBlocked||(o.preventDefault(),this.startRotation=this.state.rotation,this.rotationDetected=!1,this.gestureRotation=0,this.isGestureStart=!0,this.startZoom=this.state.zoom,this.screenPoint=ye(this.container,o.clientX,o.clientY),this.state.userHasInteracted=!0,this.state.disableRotationByUserInteraction||this.container.classList.add("mapgl-rotating"),this.map.emit("interactionstart",{target:"zoom/rotation"}))},this.onGestureEnd=o=>{o.preventDefault(),this.isGestureStart&&(this.isGestureStart=!1,this.state.userHasInteracted=!0,this.container.classList.remove("mapgl-rotating"),this.map.emit("interactionend",{target:"zoom/rotation"}))},this.onGestureChange=o=>{if(o.preventDefault(),this.state.userHasInteracted=!0,o.scale>1?this.gestureZoom=o.scale-1:this.gestureZoom=-1/o.scale+1,this.state.disableRotationByUserInteraction)return;const a=n.degToRad(o.rotation);!this.rotationDetected&&Math.abs(a)>this.state.touchRotationThreshold&&(this.rotationDetected=!0,this.startRotation=this.state.rotation-a),this.rotationDetected&&(this.gestureRotation=a)},this.state=e,this.container=t,this.map=i,this.isBlocked=!1,this.isGestureStart=!1,this.gestureRotation=0,this.gestureZoom=0,this.screenPoint=[0,0],this.startRotation=0,this.startZoom=0,this.container.addEventListener("gesturestart",this.onGestureStart),this.container.addEventListener("gestureend",this.onGestureEnd),this.container.addEventListener("gesturechange",this.onGestureChange)}destroy(){this.container.removeEventListener("gesturestart",this.onGestureStart),this.container.removeEventListener("gestureend",this.onGestureEnd),this.container.removeEventListener("gesturechange",this.onGestureChange)}update(){if(this.gestureRotation===0&&this.gestureZoom===0)return;const e=this.state,t=this.startZoom+this.gestureZoom,i=this.startRotation+this.gestureRotation,o=n.create$1(),a=e.keepCenterWhileUserZoomRotate?n.create$1():n.getCenterCorrection(e,this.screenPoint,{zoom:t,rotation:i});n.add$1(o,e.center,a),ot(e),bt(e,o,{animate:!1}),dt(e,t,{animate:!1}),e.disableRotationByUserInteraction||Qt(e,i,{animate:!1}),this.gestureRotation=0,this.gestureZoom=0}block(){this.isBlocked=!0}unblock(){this.isBlocked=!1}}class Wc extends n.Evented{constructor(e,t){super(),this.startRenderTime=0,this.catchNextUpdate=!1,this.durations=[],this.badDurations=[],this.countToCheck=75,this.slowFrameTime=100,this.mapState=e,this.mapModules=t,this.originalMapState={center:this.mapState.center.slice(),zoom:this.mapState.zoom,rotation:this.mapState.rotation,pitch:this.mapState.pitch}}update(){const{time:e,needRerender:t,rerenderEvents:i}=this.mapState,o=e-this.startRenderTime;this.catchNextUpdate&&(this.durations.push(o),o>=this.slowFrameTime&&this.badDurations.push(o),this.catchNextUpdate=!1),(t||i.length>0)&&(this.startRenderTime=e,this.catchNextUpdate=!0),this.durations.length>this.countToCheck&&this.check()}getFpsStats(){const e=this.durations.map(a=>1e3/a),t=this.badDurations.map(a=>1e3/a),i=n.equalArrays(this.originalMapState.center,this.mapState.center)&&this.originalMapState.pitch===this.mapState.pitch&&this.originalMapState.rotation===this.mapState.rotation&&this.originalMapState.zoom===this.mapState.zoom;return{all:{min:e.length>0?Math.min(...e):0,max:e.length>0?Math.max(...e):0,avg:e.length>0?e.reduce((a,r)=>a+r)/e.length:0,count:e.length},bad:{min:t.length>0?Math.min(...t):0,max:t.length>0?Math.max(...t):0,avg:t.length>0?t.reduce((a,r)=>a+r)/t.length:0,count:t.length},isStatic:i}}async getMemoryStats(){const e=await this.getJsMemoryStats(),t=await this.getGpuMemoryStats();return{cpu:e,gpu:t}}check(){const e=$c(this.durations);this.emit("fps",e),e<n.performanceCheck.fpsCaveat&&(this.mapState.performanceCaveatEmitted=!0,this.emit("performancecaveat")),this.durations=[],this.badDurations=[],this.countToCheck=Math.min(1e3,this.countToCheck*2)}async getJsMemoryStats(){const e=await n.getRawMemoryStats(this.mapModules);return Object.values(e).filter(o=>!!o.js).map(o=>o.js).reduce((o,a)=>o+a["--sum"],0)}async getGpuMemoryStats(){const e=await n.getRawMemoryStats(this.mapModules);return Object.values(e).filter(o=>!!o.gpu).map(o=>o.gpu).reduce((o,a)=>o+a["--sum"],0)}}function $c(s){s.sort((t,i)=>t-i);const e=s[Math.floor(s.length*3/4)];return Math.round(1e3/e)}class Xc{constructor(){this.differ=new n.Differ([{path:"center",type:"vec2"},{path:"zoom",type:"number"},{path:"rotation",type:"number"},{path:"pitch",type:"number"}]),this.debouncedSet=n.debounce(e=>{n.start("stillness",{},e,e.stillness,1,400,1)},100,!1),this.stillnessTickerUpdate=n.update.bind(null,"stillness",{step:(e,t)=>{e.stillness=t}})}update(e){this.differ.check(e)&&(e.stillness=0,n.stop("stillness",e),this.debouncedSet(e)),this.stillnessTickerUpdate(e)}}class Kc{constructor(e){this.onTouchStart=()=>{this.isTouchStartEmitted=!0},this.onMouseOut=t=>{if(!this.prevGeo)return;const i=ye(this.container,t.clientX,t.clientY);nt("mouseout",this.prevGeo,t,i,this.modules),this.prevGeo=void 0,this.skipIdentifyEvents=!0,this.modules.defaultSource.resetHoverId(),this.container.classList.remove("mapgl-hover")},this.onMouseMove=t=>{if(this.isTouchStartEmitted){this.isTouchStartEmitted=!1;return}if(this.skipIdentifyEvents=!1,this.isBlocked)return;const i=ye(this.container,t.clientX,t.clientY);Promise.resolve().then(()=>this.modules.layout.isActionWithCanvas(t)?this.modules.identifier.search("mouseMove",i):void 0).then(o=>{if(this.skipIdentifyEvents)return;const a=o&&this.prevGeo&&(o.id!==this.prevGeo.id||o.instanceId!==this.prevGeo.instanceId||o.dynamicObjectId!==this.prevGeo.dynamicObjectId||o.symbol!==this.prevGeo.symbol);this.prevGeo&&(!o||a)&&(nt("mouseout",this.prevGeo,t,i,this.modules),this.prevGeo=void 0,this.container.classList.remove("mapgl-hover"),this.modules.defaultSource.resetHoverId()),o&&(!this.prevGeo||a)&&(this.prevGeo=o,this.container.classList.add("mapgl-hover"),nt("mouseover",o,t,i,this.modules),this.modules.defaultSource.setHoverId(o.id)),nt("mousemove",o,t,i,this.modules)})},this.modules=e,this.isTouchStartEmitted=!1,this.skipIdentifyEvents=!1,this.isBlocked=!1,this.prevGeo=void 0,this.container=this.modules.layout.mapContainer,this.container.addEventListener("touchstart",this.onTouchStart),this.container.addEventListener("mousemove",this.onMouseMove),this.container.addEventListener("mouseout",this.onMouseOut)}destroy(){this.container.removeEventListener("touchstart",this.onTouchStart),this.container.removeEventListener("mousemove",this.onMouseMove),this.container.removeEventListener("mouseout",this.onMouseOut)}update(){}block(){this.isBlocked=!0}unblock(){this.isBlocked=!1}}const xs=(s,e,t,i)=>{n.stop("buildingHeight"+i,s),t.animate===!1||t.duration===0?(e.set(i,t.to),s.needLabeling=!0):n.start("buildingHeight"+i,{easing:t.easing},s,t.from,t.to,t.duration,1)},qc=(s,e,t)=>n.update.call(null,"buildingHeight"+t,{step:(i,o)=>e.set(t,o),complete:i=>i.needLabeling=!0},s),Yc=16;class Qc{constructor(e,t){this.state=e,this.modules=t,this.buildingHeights=new Map,this.minZoomBuildingHeight=1/0}getBuildingHeight(e){return e===-1/0?1:e!==void 0?(this.buildingHeights.has(e)||this.addBuildingHeightZoom(e),this.buildingHeights.get(e)||0):this.getDefaultBuildingHeight()}update(){this.buildingHeights.forEach((e,t)=>{this.updateByZoom(t,e),this.isAnimating()&&qc(this.state,this.buildingHeights,t)})}isAnimating(){return Array.from(this.buildingHeights.keys()).some(e=>n.get("buildingHeight"+e,this.state)!==void 0)}clearBuildingHeights(){this.buildingHeights.clear(),this.minZoomBuildingHeight=1/0}getDefaultBuildingHeight(){const e=this.minZoomBuildingHeight!==1/0?this.minZoomBuildingHeight:Yc;return this.state.styleZoom<e?0:1}updateByZoom(e,t){const i=this.state,o=n.get("buildingHeight"+e,i),a=o!==void 0?o.to:t;i.styleZoom>=e&&this.modules.tileManager.viewportTilesReady()&&a!==1?xs(i,this.buildingHeights,{animate:!0,easing:n.buildingAnimation.easing,from:t,to:1,duration:n.buildingAnimation.duration*(1-t)},e):i.styleZoom<e&&a!==0&&xs(i,this.buildingHeights,{animate:!1,to:0},e)}addBuildingHeightZoom(e){const t=e<this.state.styleZoom?0:1;this.buildingHeights.set(e,t),this.minZoomBuildingHeight>e&&(this.minZoomBuildingHeight=e)}}const G=class G{constructor(e=null,t={}){this._src=null,this._glContext=null,this._texture=null,this._src=e,this.options=Object.assign({},G.defaultOptions,t)}enable(e,t){return e.activeTexture(e.TEXTURE0+t),this._texture||this.prepare(e),e.bindTexture(e.TEXTURE_2D,this._texture),this}remove(){return this._texture&&this._glContext&&this._glContext.deleteTexture(this._texture),this._glContext=null,this._texture=null,this._src=null,this}getTexture(){return this._texture}subImage(e,t,i){const o=this._glContext;if(!o)return console.warn("Texture is not prepared, cannot update sub-image"),this;o.bindTexture(o.TEXTURE_2D,this._texture),o.pixelStorei(o.UNPACK_FLIP_Y_WEBGL,this.options.flipY),o.pixelStorei(o.UNPACK_PREMULTIPLY_ALPHA_WEBGL,this.options.premultiplyAlpha);const a=this._toGlParam(o,this.options.format),r=this._toGlParam(o,this.options.type??G.UnsignedByte);return a===null||r===null?this:(o.texSubImage2D(o.TEXTURE_2D,0,t,i,a,r,e),this.options.generateMipmaps&&this.options.minFilter!==G.NearestFilter&&this.options.minFilter!==G.LinearFilter&&(console.warn("[WebGL] Generating mipmaps for texture after subImage update"),o.generateMipmap(o.TEXTURE_2D)),this)}prepare(e){this._glContext=e,this._texture=e.createTexture(),e.bindTexture(e.TEXTURE_2D,this._texture),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,this.options.flipY),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,this.options.premultiplyAlpha);const t=this._toGlParam(e,this.options.format),i=this._toGlParam(e,this.options.type??G.UnsignedByte),o=this._toGlParam(e,this.options.wrapS),a=this._toGlParam(e,this.options.wrapT),r=this._toGlParam(e,this.options.magFilter??G.LinearFilter),l=this._toGlParam(e,this.options.minFilter??G.LinearMipMapLinearFilter),c=this.options.compareFunc?this._toGlParam(e,this.options.compareFunc):null;if(t!==null&&i!==null){const d=this.hookInternalFormat(t,i,e);ArrayBuffer.isView(this._src)||this._src===null?this.options.size&&e.texImage2D(e.TEXTURE_2D,0,d,this.options.size[0],this.options.size[1],0,t,i,this._src):this._src&&e.texImage2D(e.TEXTURE_2D,0,t,t,i,this._src)}return o!==null&&a!==null&&(e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,o),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,a)),r!==null&&l!==null&&(e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,r),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,l)),c&&!(e instanceof WebGLRenderingContext)&&e.texParameteri(e.TEXTURE_2D,e.TEXTURE_COMPARE_MODE,e.COMPARE_REF_TO_TEXTURE),this.options.generateMipmaps&&this.options.minFilter!==G.NearestFilter&&this.options.minFilter!==G.LinearFilter&&e.generateMipmap(e.TEXTURE_2D),e.bindTexture(e.TEXTURE_2D,null),this}memSizeJs(){const e=this._src;return e===null?0:ArrayBuffer.isView(e)?e.byteLength:e instanceof ImageBitmap?e.height*e.width*4:(console.warn("[Stats] Untracked texture _src size"),0)}memSizeGPU(){if(!this._texture)return 0;const e=(this.options.size?.[0]??0)*(this.options.size?.[1]??0)*4;return e>0?e:this._src!==null?this.memSizeJs():0}_toGlParam(e,t){return t===G.ClampToEdgeWrapping?e.CLAMP_TO_EDGE:t===G.Repeat?e.REPEAT:t===G.MirroredRepeat?e.MIRRORED_REPEAT:t===G.NearestFilter?e.NEAREST:t===G.NearestMipMapNearestFilter?e.NEAREST_MIPMAP_NEAREST:t===G.NearestMipMapLinearFilter?e.NEAREST_MIPMAP_LINEAR:t===G.LinearFilter?e.LINEAR:t===G.LinearMipMapNearestFilter?e.LINEAR_MIPMAP_NEAREST:t===G.LinearMipMapLinearFilter?e.LINEAR_MIPMAP_LINEAR:t===G.RgbaFormat?e.RGBA:t===G.AlphaFormat?e.ALPHA:t===G.RgbFormat?e.RGB:t===G.DepthComponentFormat?e.DEPTH_COMPONENT:t===G.UnsignedByte?e.UNSIGNED_BYTE:t===G.UnsignedShort?e.UNSIGNED_SHORT:t===G.Float?e.FLOAT:t===G.UnsignedInt?e.UNSIGNED_INT:e instanceof WebGLRenderingContext?null:t===G.RedFormat?e.RED:t===G.CompareRefToTexture?e.COMPARE_REF_TO_TEXTURE:t===G.CompareNone?e.NONE:t===G.DepthComponentFormat32?e.DEPTH_COMPONENT32F:null}hookInternalFormat(e,t,i){return i instanceof WebGLRenderingContext?e:e===i.DEPTH_COMPONENT?i.DEPTH_COMPONENT24:t===i.FLOAT&&e===i.RGBA?i.RGBA32F:t===i.FLOAT&&e===i.RED?i.R32F:t!==i.FLOAT&&e===i.RED?i.R8:e}};G.ClampToEdgeWrapping=1,G.Repeat=2,G.MirroredRepeat=3,G.NearestFilter=4,G.NearestMipMapNearestFilter=5,G.NearestMipMapLinearFilter=6,G.LinearFilter=7,G.LinearMipMapNearestFilter=8,G.LinearMipMapLinearFilter=9,G.DepthComponentFormat=10,G.DepthComponentFormat32=11,G.RgbaFormat=14,G.AlphaFormat=15,G.RgbFormat=16,G.UnsignedByte=17,G.Float=18,G.UnsignedShort=19,G.UnsignedInt=20,G.RedFormat=21,G.CompareNone=22,G.CompareRefToTexture=23,G.defaultOptions={magFilter:G.LinearFilter,minFilter:G.LinearMipMapLinearFilter,wrapS:G.ClampToEdgeWrapping,wrapT:G.ClampToEdgeWrapping,format:G.RgbaFormat,generateMipmaps:!0,flipY:!0,premultiplyAlpha:!0,type:G.UnsignedByte};let g=G;function Mi(s){if(s===void 0)return;const e=window.WebGLRenderingContext,i={[e.CLAMP_TO_EDGE]:g.ClampToEdgeWrapping,[e.REPEAT]:g.Repeat,[e.MIRRORED_REPEAT]:g.MirroredRepeat,[e.NEAREST]:g.NearestFilter,[e.NEAREST_MIPMAP_NEAREST]:g.NearestMipMapNearestFilter,[e.NEAREST_MIPMAP_LINEAR]:g.NearestMipMapLinearFilter,[e.LINEAR]:g.LinearFilter,[e.LINEAR_MIPMAP_NEAREST]:g.LinearMipMapNearestFilter,[e.LINEAR_MIPMAP_LINEAR]:g.LinearMipMapLinearFilter,[e.RGBA]:g.RgbaFormat,[e.ALPHA]:g.AlphaFormat,[e.RGB]:g.RgbFormat,[e.UNSIGNED_BYTE]:g.UnsignedByte,[e.FLOAT]:g.Float}[s];return i===void 0?(console.error(`Failed to translate texture parameter ${s}`),NaN):i}const Pn=class Pn{constructor(e={}){this._texture=null,this._glContext=null,this._frameBuffer=null,this._depthAttachment=null,this.options=Object.assign({},Pn.defaultOptions,e),this.options.hasColorOutput&&(this._texture=new g(null,this.options))}bind(e,t){return this._frameBuffer||this._prepare(e),t?e.bindFramebuffer(t,this._frameBuffer):e.bindFramebuffer(e.FRAMEBUFFER,this._frameBuffer),this}unbind(e){return e.bindFramebuffer(e.FRAMEBUFFER,null),this}remove(){return this._unprepare(),this}setSize(e){return this.options.size=e,this._unprepare(),this}getTexture(){return this._texture}getDepthAttachment(){return this._depthAttachment}memSizeGPU(){const{_texture:e,_depthAttachment:t}=this;let i=0;if(this.options.depthTexture||this.options.useHighDepthPrecision)i=4;else switch(this.options.depthInternalFormat){case WebGLRenderingContext.DEPTH_STENCIL:i=1;break;case WebGLRenderingContext.DEPTH_COMPONENT16:i=2;break;default:!(this._glContext instanceof WebGLRenderingContext)&&WebGL2RenderingContext.DEPTH_COMPONENT24&&(i=3)}return{_texture:e?n.textureSizeGpu(e):{_texture:0},_depthAttachment:t===null?0:this.options.size[0]*this.options.size[1]*i}}_prepare(e){if(this._glContext=e,!this._texture&&this.options.hasColorOutput&&(this._texture=new g(null,this.options)),this._frameBuffer=e.createFramebuffer(),e.bindFramebuffer(e.FRAMEBUFFER,this._frameBuffer),this._texture&&(this._texture.prepare(e),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,this._texture.getTexture(),0)),this.options.depthTexture){const t=this._depthAttachment=new g(null,{magFilter:this.options.magFilter??g.NearestFilter,minFilter:this.options.minFilter??g.NearestFilter,format:g.DepthComponentFormat,size:this.options.size,premultiplyAlpha:!1,generateMipmaps:!1,type:g.UnsignedInt,compareFunc:this.options.compareFunc});t.prepare(e),e.framebufferTexture2D(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.TEXTURE_2D,t.getTexture(),0)}else{const t=this.options.useHighDepthPrecision?e.DEPTH_STENCIL:this.options.depthInternalFormat,i=this.options.useHighDepthPrecision?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;this._depthAttachment=e.createRenderbuffer(),e.bindRenderbuffer(e.RENDERBUFFER,this._depthAttachment),e.renderbufferStorage(e.RENDERBUFFER,t,this.options.size[0],this.options.size[1]),e.framebufferRenderbuffer(e.FRAMEBUFFER,i,e.RENDERBUFFER,this._depthAttachment)}this._checkComplete(e),e.bindRenderbuffer(e.RENDERBUFFER,null),e.bindFramebuffer(e.FRAMEBUFFER,null)}_unprepare(){this._texture&&(this._texture.remove(),this._texture=null),this._glContext&&this._depthAttachment&&(this._depthAttachment instanceof g?this._depthAttachment.remove():this._glContext.deleteRenderbuffer(this._depthAttachment),this._depthAttachment=null),this._glContext&&this._frameBuffer&&(this._glContext.deleteFramebuffer(this._frameBuffer),this._frameBuffer=null)}_checkComplete(e){if(n.forceGlStatusCheck()){const t=e.checkFramebufferStatus(e.FRAMEBUFFER);if(t===e.FRAMEBUFFER_COMPLETE)return;t===e.FRAMEBUFFER_UNSUPPORTED?console.log("Framebuffer is unsupported"):t===e.FRAMEBUFFER_INCOMPLETE_ATTACHMENT?console.log("Framebuffer incomplete attachment"):t===e.FRAMEBUFFER_INCOMPLETE_DIMENSIONS?console.log("Framebuffer incomplete dimensions"):t===e.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT?console.log("Framebuffer incomplete missing attachment"):console.log(`Unexpected framebuffer status: ${t}`)}}};Pn.defaultOptions=Object.assign({},g.defaultOptions,{size:[0,0],generateMipmaps:!1,depthTexture:!1,hasColorOutput:!0,useHighDepthPrecision:!1,depthInternalFormat:WebGLRenderingContext.DEPTH_COMPONENT16});let pe=Pn;function Ei(s){const e=document.createElement("canvas"),t={antialias:!1,stencil:!0,failIfMajorPerformanceCaveat:s};return"WebGLRenderingContext"in window?e.getContext("webgl",t)||e.getContext("experimental-webgl",t):null}const kn={};function Jc(s){const e=String(s);return kn[e]===void 0&&(kn[e]=Ac(s)),kn[e]}function Ac(s){const e=Ei(s);if(!e)return{ok:!1,msg:"error on get context"};for(const i of["OES_element_index_uint","OES_standard_derivatives","OES_vertex_array_object"])if(!e.getExtension(i))return{ok:!1,msg:`${i} extension is not supported`};try{const i=new Uint8Array(4);e.readPixels(0,0,1,1,e.RGBA,e.UNSIGNED_BYTE,i)}catch{return{ok:!1,msg:"readPixels is not supported"}}let t;try{t=e.createShader(e.VERTEX_SHADER)}catch{return{ok:!1,msg:"browser block shader API"}}return!t||e.isContextLost()?{ok:!1}:(e.shaderSource(t,"void main() {}"),e.compileShader(t),{ok:e.getShaderParameter(t,e.COMPILE_STATUS)===!0})}let wt;function ws(){wt=void 0;const s=new Float32Array([-1,-1,1,-1,-1,1]),e=2,t=Ei(!1);if(!t)return wt="Failed to obtain WebGL context",!1;for(const m of["OES_element_index_uint","OES_standard_derivatives","OES_vertex_array_object","OES_texture_float","OES_texture_float_linear"])if(!t.getExtension(m))return wt=`Absent ${m} extension`,!1;const i=new pe({size:[e,e]});i.bind(t);const o=new g(new Float32Array([1,0,1,0]),{size:[2,2],format:g.AlphaFormat,type:g.Float,magFilter:g.LinearFilter,minFilter:g.LinearFilter}).prepare(t),a=`attribute vec2 pos;
    void main () {
        gl_Position = vec4(pos, 0, 1);
    }`,r=`precision mediump float;
    uniform sampler2D tex;
    void main () {
        gl_FragColor = vec4(texture2D(tex, vec2(0.4, 0.4)).a, 0, 0, 0);
    }`,l=t.createShader(t.VERTEX_SHADER),c=t.createShader(t.FRAGMENT_SHADER);if(!l||!c||t.isContextLost())return wt="Cannot create shaders",!1;t.shaderSource(l,a),t.compileShader(l),t.shaderSource(c,r),t.compileShader(c);const d=t.createProgram();if(!d)return wt="Cannot compile shader program",!1;t.attachShader(d,l),t.attachShader(d,c),t.linkProgram(d),t.useProgram(d);const _=t.createBuffer();if(!_)return wt="Cannot create buffer",!1;t.bindBuffer(t.ARRAY_BUFFER,_),t.bufferData(t.ARRAY_BUFFER,s,t.STATIC_DRAW);const u=t.getAttribLocation(d,"pos");t.vertexAttribPointer(u,2,t.FLOAT,!1,0,0),t.enableVertexAttribArray(u),o.enable(t,0);const h=t.getUniformLocation(d,"tex");t.uniform1i(h,0),t.viewport(0,0,e,e),t.drawArrays(t.TRIANGLES,0,3);const f=new Uint8Array(4);return t.readPixels(0,0,1,1,t.RGBA,t.UNSIGNED_BYTE,f),i.unbind(t),f[0]!==255}function ed(){return wt}let $e=null;function Bt(){if($e!==null)return $e;const s=Ei(!1);if(!s)return $e=!0,$e;const e=`
    attribute vec2 pos;
    varying float v1, v2, v3, v4, v5, v6, v7, v8, v9, v10;
    void main () {
        v1 = pos.x;
        v2 = pos.y;
        v3 = pos.x * 2.0;
        v4 = pos.y * 2.0;
        v5 = pos.x + pos.y;
        v6 = pos.x - pos.y;
        v7 = pos.x * pos.x;
        v8 = pos.y * pos.y;
        v9 = pos.x * pos.y;
        v10 = (pos.x + pos.y) / 2.0;

        gl_Position = vec4(pos, 0, 1);
    }`,t=`
    precision mediump float;
    varying float v1, v2, v3, v4, v5, v6, v7, v8, v9, v10;
    void main () {
        float result = v1 + v2 + v3 + v4 + v5 + v6 + v7 + v8 + v9 + v10;
        gl_FragColor = vec4(result / 10.0, 0, 0, 1); // усредняем результат
    }`,i=s.createShader(s.VERTEX_SHADER),o=s.createShader(s.FRAGMENT_SHADER);if(!i||!o||s.isContextLost())return $e=!0,$e;s.shaderSource(i,e),s.compileShader(i),s.shaderSource(o,t),s.compileShader(o);const a=s.createProgram();return!a||(s.attachShader(a,i),s.attachShader(a,o),s.linkProgram(a),!a||!s.getProgramParameter(a,s.LINK_STATUS))?($e=!0,$e):($e=!1,$e)}function td(){const s=Ei(!1);if(!s)return!1;if(!Uc)return!0;const e=s.getExtension("WEBGL_debug_renderer_info");if(!e)return!1;const t=e?s.getParameter(e.UNMASKED_RENDERER_WEBGL):null;return t&&typeof t=="string"?!t.toUpperCase().includes("INTEL"):!1}function Ss(s){return s instanceof WebGLRenderingContext?!!s.getExtension("WEBGL_depth_texture"):!0}function id(s){return!Ts(s)}function Ts(s){if(!nd())return"not a browser";if(!sd())return"insufficient Function support";if(!rd())return"insufficient JSON support";if(!ld())return"insufficient worker support";if(!dd())return"insufficient ArrayBuffer support";if(!_d())return"insufficient Canvas/getImageData support";const e=Jc(s&&s.failIfMajorPerformanceCaveat||!1);if(!e.ok)return`insufficient WebGL support${e.msg?`: ${e.msg}`:""}`;if(!od())return"insufficient Array support";if(!ad())return"insufficient Object support";if(!cd())return"insufficient DOM support";if(!ud())return"insufficient ECMAScript 6 support"}function nd(){return typeof window<"u"&&typeof document<"u"}function od(){return Array.prototype&&Array.prototype.every&&Array.prototype.filter&&Array.prototype.forEach&&Array.prototype.indexOf&&Array.prototype.map&&Array.prototype.some&&Array.prototype.reduce&&Array.isArray}function sd(){return typeof Function.prototype?.bind=="function"}function ad(){return!!(Object.keys&&Object.assign&&Object.create&&Object.getPrototypeOf&&Object.getOwnPropertyNames&&Object.getOwnPropertyDescriptor&&Object.defineProperty&&Object.freeze)}function rd(){return"JSON"in window&&"parse"in JSON&&"stringify"in JSON}function ld(){if(!("Worker"in window&&"Blob"in window&&"URL"in window))return!1;const s=new Blob([""],{type:"text/javascript"}),e=URL.createObjectURL(s);let t,i=null;try{i=new Worker(e),t=!0}catch{t=!1}return i&&i.terminate(),URL.revokeObjectURL(e),t}function cd(){const s=document.createElement("div");return s&&typeof s.after=="function"}function dd(){return!!ArrayBuffer.isView}function _d(){const s=document.createElement("canvas");s.width=s.height=1;const e=s.getContext("2d");if(!e)return!1;const t=e.getImageData(0,0,1,1);return t&&t.width===s.width}function ud(){return!("documentMode"in document)}function hd(){return ed()}const fd=td,md=async()=>{if(!navigator)return!1;try{const s=navigator.gpu;if(typeof s?.requestAdapter!="function"||!await s.requestAdapter({powerPreference:"high-performance"})||!document.createElement("canvas").getContext("webgpu",{}))return!1}catch{return!1}return!0};class Qe{static depthFuncToWebGL(e,t){switch(t){case n.DEPTH_FUNC.NEVER:return e.NEVER;case n.DEPTH_FUNC.LESS:return e.LESS;case n.DEPTH_FUNC.EQUAL:return e.EQUAL;case n.DEPTH_FUNC.LEQUAL:return e.LEQUAL;case n.DEPTH_FUNC.GREATER:return e.GREATER;case n.DEPTH_FUNC.NOTEQUAL:return e.NOTEQUAL;case n.DEPTH_FUNC.GEQUAL:return e.GEQUAL;case n.DEPTH_FUNC.ALWAYS:return e.ALWAYS;default:throw new Error(`Неизвестная функция теста глубины: ${t}`)}}static cullFaceModeToWebGL(e,t){switch(t){case n.CULL_FACE_MODE.FRONT:return e.FRONT;case n.CULL_FACE_MODE.BACK:return e.BACK;case n.CULL_FACE_MODE.FRONT_AND_BACK:return e.FRONT_AND_BACK;default:throw new Error(`Неизвестный режим отбрасывания: ${t}`)}}static blendFuncToWebGL(e,t){switch(t){case n.BLEND_FUNC.ZERO:return e.ZERO;case n.BLEND_FUNC.ONE:return e.ONE;case n.BLEND_FUNC.SRC_COLOR:return e.SRC_COLOR;case n.BLEND_FUNC.ONE_MINUS_SRC_COLOR:return e.ONE_MINUS_SRC_COLOR;case n.BLEND_FUNC.SRC_ALPHA:return e.SRC_ALPHA;case n.BLEND_FUNC.ONE_MINUS_SRC_ALPHA:return e.ONE_MINUS_SRC_ALPHA;case n.BLEND_FUNC.DST_ALPHA:return e.DST_ALPHA;case n.BLEND_FUNC.ONE_MINUS_DST_ALPHA:return e.ONE_MINUS_DST_ALPHA;case n.BLEND_FUNC.DST_COLOR:return e.DST_COLOR;case n.BLEND_FUNC.ONE_MINUS_DST_COLOR:return e.ONE_MINUS_DST_COLOR;case n.BLEND_FUNC.SRC_ALPHA_SATURATE:return e.SRC_ALPHA_SATURATE;default:throw new Error(`Неизвестная функция смешивания: ${t}`)}}static blendEquationToWebGL(e,t){switch(t){case n.BLEND_EQUATION.FUNC_ADD:return e.FUNC_ADD;case n.BLEND_EQUATION.FUNC_SUBTRACT:return e.FUNC_SUBTRACT;case n.BLEND_EQUATION.FUNC_REVERSE_SUBTRACT:return e.FUNC_REVERSE_SUBTRACT;case n.BLEND_EQUATION.MIN:return n.BLEND_EQUATION.MIN;case n.BLEND_EQUATION.MAX:return n.BLEND_EQUATION.MAX;default:throw new Error(`Неизвестное уравнение смешивания: ${t}`)}}static webGLToDepthFunc(e,t){switch(t){case e.NEVER:return n.DEPTH_FUNC.NEVER;case e.LESS:return n.DEPTH_FUNC.LESS;case e.EQUAL:return n.DEPTH_FUNC.EQUAL;case e.LEQUAL:return n.DEPTH_FUNC.LEQUAL;case e.GREATER:return n.DEPTH_FUNC.GREATER;case e.NOTEQUAL:return n.DEPTH_FUNC.NOTEQUAL;case e.GEQUAL:return n.DEPTH_FUNC.GEQUAL;case e.ALWAYS:return n.DEPTH_FUNC.ALWAYS;default:throw new Error(`Неизвестная WebGL константа функции глубины: ${t}`)}}static webGLToCullFaceMode(e,t){switch(t){case e.FRONT:return n.CULL_FACE_MODE.FRONT;case e.BACK:return n.CULL_FACE_MODE.BACK;case e.FRONT_AND_BACK:return n.CULL_FACE_MODE.FRONT_AND_BACK;default:throw new Error(`Неизвестная WebGL константа режима отбрасывания: ${t}`)}}}class pd{constructor(e){if(this.webGlExtensions={},this._canvasElement=null,this._size=[1,1],this._lastState={},this._storedStates={},e=e||{},"canvas"in e){this._canvasElement=typeof e.canvas=="string"?document.getElementById(e.canvas):e.canvas;const t={antialias:e.antialias!==void 0?e.antialias:!0,stencil:e.stencil!==void 0?e.stencil:!1,failIfMajorPerformanceCaveat:e.failIfMajorPerformanceCaveat!==void 0?e.failIfMajorPerformanceCaveat:!1,preserveDrawingBuffer:e.preserveDrawingBuffer!==void 0?e.preserveDrawingBuffer:!1};this._gl=e.version===2?this._canvasElement.getContext("webgl2",t):this._canvasElement.getContext("webgl",t)||this._canvasElement.getContext("experimental-webgl",t)}else this._gl=e.gl;this._pixelRatio=e.pixelRatio||1,this.clearColor=e.clearColor||[1,1,1,1],this.webGlExtensions={},this.overrideStateMethods()}setPixelRatio(e){return this._pixelRatio=e,this}getPixelRatio(){return this._pixelRatio}setSize(e,t){return this._size=[e*this._pixelRatio,t*this._pixelRatio],this._canvasElement&&(this._canvasElement.width=this._size[0],this._canvasElement.height=this._size[1],this._canvasElement.style.width=`${e}px`,this._canvasElement.style.height=`${t}px`),this.setViewport(),this}setViewport(e=0,t=0,i,o){return i!==void 0&&o!==void 0?this._gl.viewport(e,t,i,o):this._gl.viewport(e,t,this._size[0],this._size[1]),this}getSize(){return this._size}addExtension(e){return this.webGlExtensions[e]=this._gl.getExtension(e),this}prepareTexture(e){return e.prepare(this._gl),this}bindVao(e){return e.bind({gl:this._gl,extensions:this.webGlExtensions}),this}enableTexture(e,t){return e.enable(this._gl,t),this}disableTexture(e){const t=this._gl;return t.activeTexture(t.TEXTURE0+e),t.bindTexture(t.TEXTURE_2D,null),this}isDepthTextureSupported(){return Ss(this._gl)}isShadowSamplerSupported(){return!(this._gl instanceof WebGLRenderingContext)&&this.isDepthTextureSupported()}isContextLost(){return this._gl.isContextLost()}storeGpuState(e){const t=this._gl;this._storedStates[e]={depthMask:this._lastState.depthMask??t.getParameter(t.DEPTH_WRITEMASK),depthTest:this._lastState.depthTest??t.getParameter(t.DEPTH_TEST),depthFunc:this._lastState.depthFunc??t.getParameter(t.DEPTH_FUNC),clearDepth:this._lastState.clearDepth??t.getParameter(t.DEPTH_CLEAR_VALUE)}}restoreGpuState(e){const t=this._storedStates[e];if(t){const i=this._gl;this._lastState.depthMask!==t.depthMask&&i.depthMask(t.depthMask),this._lastState.depthTest!==t.depthTest&&(t.depthTest?i.enable(i.DEPTH_TEST):i.disable(i.DEPTH_TEST)),this._lastState.depthFunc!==t.depthFunc&&i.depthFunc(t.depthFunc),this._lastState.clearDepth!==t.clearDepth&&i.clearDepth(t.clearDepth)}}drawPoints(e,t){this._gl.drawArrays(this._gl.POINTS,e,t)}drawTriangles(e,t){this._gl.drawArrays(this._gl.TRIANGLES,e,t)}drawTrianglesFan(e,t){this._gl.drawArrays(this._gl.TRIANGLE_FAN,e,t)}drawArrays(e,t,i){this._gl.drawArrays(e,t,i)}drawElements(e,t,i,o){this._gl.drawElements(e,t,i,o)}drawInstancedElements(e,t,i,o,a){const r=this._gl,l=this.webGlExtensions.ANGLE_instanced_arrays;if(r instanceof WebGLRenderingContext){if(!l)return;l.drawElementsInstancedANGLE(e,t,i,o,a)}else r.drawElementsInstanced(e,t,i,o,a)}drawInstancedArrays(e,t,i,o){const a=this._gl,r=this.webGlExtensions.ANGLE_instanced_arrays;if(a instanceof WebGLRenderingContext){if(!r)return;r.drawArraysInstancedANGLE(e,t,i,o)}else a.drawArraysInstanced(e,t,i,o)}triangleCountByDrawMode(e,t){const i=this._gl;switch(e){case i.TRIANGLES:return t/3;case i.TRIANGLE_FAN:case i.TRIANGLE_STRIP:return t-2;default:return 0}}createBuffer(e,t,i,o){return new n.Buffer(this._gl,e,t,i,o)}applyState(e,t){const i=this._gl;if(i.depthMask(t?.depthMask??e.depthMask),t?.depthTest??e.depthTest?(i.enable(i.DEPTH_TEST),this.setDepthFunc(t?.depthFunc??e.depthFunc)):i.disable(i.DEPTH_TEST),t?.cullFace??e.cullFace?(i.enable(i.CULL_FACE),this.setCullFaceMode(t?.cullFaceMode??e.cullFaceMode)):i.disable(i.CULL_FACE),t?.blend??e.blend){i.enable(i.BLEND),this.setBlendEquation(t?.blendEquation??e.blendEquation);const a=t?.blendFuncSeparate??e.blendFuncSeparate;a?this.setBlendFuncSeparate(a.srcRgb,a.dstRgb,a.srcAlpha,a.dstAlpha):this.setBlendFunc(t?.blendFunc?.sfactor??e.blendFunc.sfactor,t?.blendFunc?.dfactor??e.blendFunc.dfactor)}else i.disable(i.BLEND);const o=t?.colorMask??e.colorMask;i.colorMask(o[0],o[1],o[2],o[3]),t?.polygonOffsetFill??e.polygonOffsetFill?(i.enable(i.POLYGON_OFFSET_FILL),i.polygonOffset(t?.polygonOffset?.factor??e.polygonOffset.factor,t?.polygonOffset?.units??e.polygonOffset.units)):i.disable(i.POLYGON_OFFSET_FILL)}setDepthFunc(e){const t=Qe.depthFuncToWebGL(this._gl,e);this._gl.depthFunc(t)}setCullFaceMode(e){const t=Qe.cullFaceModeToWebGL(this._gl,e);this._gl.cullFace(t)}setBlendFunc(e,t){const i=Qe.blendFuncToWebGL(this._gl,e),o=Qe.blendFuncToWebGL(this._gl,t);this._gl.blendFunc(i,o)}setBlendFuncSeparate(e,t,i,o){const a=Qe.blendFuncToWebGL(this._gl,e),r=Qe.blendFuncToWebGL(this._gl,t),l=Qe.blendFuncToWebGL(this._gl,i),c=Qe.blendFuncToWebGL(this._gl,o);this._gl.blendFuncSeparate(a,r,l,c)}setBlendEquation(e){const t=Qe.blendEquationToWebGL(this._gl,e);this._gl.blendEquation(t)}setBlendEquationSeparate(e,t){const i=Qe.blendEquationToWebGL(this._gl,e),o=Qe.blendEquationToWebGL(this._gl,t);this._gl.blendEquationSeparate(i,o)}setDepthMask(e){this._gl.depthMask(e)}overrideStateMethods(){const e=this._gl.depthMask.bind(this._gl);this._gl.depthMask=r=>(this._lastState.depthMask=r,e(r));const t=this._gl.enable.bind(this._gl);this._gl.enable=r=>(r===this._gl.DEPTH_TEST&&(this._lastState.depthTest=!0),t(r));const i=this._gl.disable.bind(this._gl);this._gl.disable=r=>(r===this._gl.DEPTH_TEST&&(this._lastState.depthTest=!1),i(r));const o=this._gl.depthFunc.bind(this._gl);this._gl.depthFunc=r=>(this._lastState.depthFunc=r,o(r));const a=this._gl.clearDepth.bind(this._gl);this._gl.clearDepth=r=>(this._lastState.clearDepth=r,a(r))}}class vd{constructor(e){this.location=null,this.name=e.name,this.type=e.type}getLocation(e,t){return this.location=e.getUniformLocation(t,this.name),this}bind(e,t){switch(this.type){case"1i":e.uniform1i(this.location,t);break;case"1f":e.uniform1f(this.location,t);break;case"2i":e.uniform2i(this.location,t[0],t[1]);break;case"2f":e.uniform2f(this.location,t[0],t[1]);break;case"3i":e.uniform3i(this.location,t[0],t[1],t[2]);break;case"3f":e.uniform3f(this.location,t[0],t[1],t[2]);break;case"4i":e.uniform4i(this.location,t[0],t[1],t[2],t[3]);break;case"4f":e.uniform4f(this.location,t[0],t[1],t[2],t[3]);break;case"1iv":e.uniform1iv(this.location,t);break;case"1fv":e.uniform1fv(this.location,t);break;case"2iv":e.uniform2iv(this.location,t);break;case"2fv":e.uniform2fv(this.location,t);break;case"3iv":e.uniform3iv(this.location,t);break;case"3fv":e.uniform3fv(this.location,t);break;case"4iv":e.uniform4iv(this.location,t);break;case"4fv":e.uniform4fv(this.location,t);break;case"mat2":e.uniformMatrix2fv(this.location,!1,t);break;case"mat3":e.uniformMatrix3fv(this.location,!1,t);break;case"mat4":e.uniformMatrix4fv(this.location,!1,t);break;default:throw new Error(`[WebGl] Unsupported uniform type: '${this.type}'`)}return this}isNonFloatType(){return this.type.includes("i")}}class gd{constructor(e,t,i,o){this._gl=e,this.uniformBlocksNames=o,this.uniforms={},this.attributes={},this._webglProgram=null,this._linked=!1,this._located=!1,this._error=!1,this._uniformBlocksIndices={},this._uboBindings={},t=t||{},t.uniforms=t.uniforms||[],t.uniforms.forEach(a=>{this.uniforms[a.name]=new vd(a)}),t.attributes=t.attributes||[],t.attributes.forEach(a=>{this.attributes[a.name]=new n.ShaderAttribute(a)}),i=i??n.EMPTY_SHADER_DEFINITIONS,this._vertexShader=t.buildVertex(i),this._fragmentShader=t.buildFragment(i)}enable(){const e=this._gl;return this._error?this:(this.link(),this.locate(),this._error?this:(e.useProgram(this._webglProgram),this))}bind(e,t){if(this._error)return this;if(e)for(const i in e)this.uniforms[i].bind(this._gl,e[i]);if(t)for(const i in t)this.attributes[i].bind(this._gl,t[i]);return this}disable(){if(this._error)return this;for(const e in this.attributes)this.attributes[e].disable(this._gl);return this}link(){if(this._linked||this._error)return this;const e=this._gl;try{if(this._webglProgram=e.createProgram(),!this._webglProgram)throw new Error("Failed to create shader program");const t=this._vertexShader.get(e),i=this._fragmentShader.get(e);t&&e.attachShader(this._webglProgram,t),i&&e.attachShader(this._webglProgram,i);for(const o in this.attributes)this.attributes[o].bindLocation(e,this._webglProgram);if(e.linkProgram(this._webglProgram),n.forceGlStatusCheck()&&!e.getProgramParameter(this._webglProgram,e.LINK_STATUS))throw new Error(e.getProgramInfoLog(this._webglProgram)||"Couldn't get shader program Info Log");this._linked=!0}catch(t){throw this._error=!0,t}return this}locate(){if(this._located||this._error||!this._webglProgram)return this;const e=this._gl;for(const t in this.attributes)this.attributes[t].getLocation(e,this._webglProgram);for(const t in this.uniforms)this.uniforms[t].getLocation(e,this._webglProgram);return this.locateUniformBlocks(this._webglProgram),this._located=!0,this}getUniformBlockIndex(e){return this._uniformBlocksIndices[e]}getUboBinding(e){return this._uboBindings[e]}getUniformBlockSize(e){if(this._gl instanceof WebGLRenderingContext)return null;const t=this._gl;let i=this._webglProgram;if(i||(this.link(),this.locate()),i=this._webglProgram,!i)return null;const o=this.getUniformBlockIndex(e);return o===void 0?null:t.getActiveUniformBlockParameter(i,o,t.UNIFORM_BLOCK_DATA_SIZE)}getUniformsIndicesOffsetsInBlock(e){if(this._gl instanceof WebGLRenderingContext)return null;const t=this._gl;let i=this._webglProgram;if(i||(this.link(),this.locate()),i=this._webglProgram,!i)return null;const o=t.getUniformIndices(i,e);if(!o)return console.error("Couldn't get UBO uniforms indices."),null;const a=o.filter(c=>c!==t.INVALID_INDEX),r=t.getActiveUniforms(i,a,t.UNIFORM_OFFSET);if(r===null)return console.error("Couldn't get active UBO uniform offsets."),null;const l={};for(let c=0;c<e.length;++c){const d=o[c];if(d!==t.INVALID_INDEX){const _=a.indexOf(d);l[e[c]]=r[_]}}return l}locateUniformBlocks(e){const t=this._gl;if(t instanceof WebGLRenderingContext||!this.uniformBlocksNames)return;let i=0;for(const o of this.uniformBlocksNames){const a=t.getUniformBlockIndex(e,o);a!==t.INVALID_INDEX&&(this._uniformBlocksIndices[o]=a,this._uboBindings[o]=i,t.uniformBlockBinding(e,a,i++))}}}const Ms=[1,1,1,1],yd=3.7,bd=n.create$1(),xd=n.create$1(),Es=n.create$2(),wd=n.create$2(),Sd=n.create$1(),Td=n.fromValues(0,1,0),Is=(s,e,t,i)=>{Je(t,s,{u_float_rounding_factor:e.stillness},i)},Jt=(s,e,t,i)=>{Je(t,s,{u_float_border_width_offset:1/window.devicePixelRatio},i)},Ii=(s,e,t,i)=>{const o=(n.POINT_CENTER_SIZE-.5)/2,{size:a}=e;Je(t,s,{u_vec2_depth_test_half_point_size:[o/a[0],o/a[1]]},i)},Z=(s,e,t,i)=>{if(!t.environmentManager.isFogEnabled())return;const o=t.styleManager.getStyle(e.handyStyleId);let a=Ms,r=Ms;if(o){const _=n.makeBinderContext(e.styleZoom,e.styleState,[]);a=n.getColorForShaders(n.resolveColor(o.environment.style.skyColor,_)),r=n.getColorForShaders(n.resolveColor(o.environment.style.fogColor,_))}const l=t.camera,c=!e.elevation||Number.isNaN(e.elevation)?0:e.elevation*n.MAP_POINTS_IN_METER,d=Math.min(1+Math.max(c/n.zoomToHeight(e.zoom,e.size),0),yd);Je(t,s,{u_sky_color:e.globeMode?[0,0,0,0]:a,u_fog_color:e.globeMode?[0,0,0,0]:r,u_fog_distance:e.globeMode?0:l.fogDistance,u_fog_limits:t.environmentManager.fogLimits,u_fog_horizon_blend:t.environmentManager.fogHorizonBlend,u_fog_horizon_level:t.environmentManager.fogHorizonLevel,u_fog_horizon_pad:e.cameraConfig.fogHorizonPadFactor*d},i)},V=(s,e,t,i)=>{Je(t,s,{u_cam_pos:t.camera.position},i)},q=(s,e,t,i)=>{t.shadowManager.texture&&Je(t,s,{u_shadow_map_params:t.shadowManager.shadowMapParams,u_shadow_bias:t.shadowManager.bias,u_mat4_clip_to_shadow:t.shadowManager.clipToShadowMatrix},i)},At=(s,e,t,i)=>{Je(t,s,{u_vec2_scale_limits:[0,n.z0Scale]},i)},Cs=(s,e,t,i)=>{const o=t.camera.viewMatrixTranspose,a=t.camera.projectionMatrixInverse;Je(t,s,{u_mat4_view_transposed:o,u_mat4_proj_inverted:a},i)},Un=(s,e,t,i)=>{const o=window.devicePixelRatio,a=t.camera.ecef.pixelRadius*o,{left:r,bottom:l,top:c,right:d}=e.padding,[_,u]=e.size,h=[_*o,u*o],f=[(r-d)*o/2,(l-c)*o/2],m=t.environmentManager.globHaloStops.map(T=>(a+T*o)/h[1]),p=t.styleManager.getStyle(e.handyStyleId);if(!p)return;const v=p?.environment;if(!v)return;const y=n.makeBinderContext(e.styleZoom,e.styleState,[]),b=n.resolveColor(v.style.fogColor,y),x=n.resolveColor(p.background.color,y);Je(t,s,{u_vec2_halo_viewport_size:h,u_vec2_halo_viewport_center_shift:f,u_vec4_halo_radius_stops:m,u_vec4_halo_color:n.getColorForShaders(b),u_float_halo_exp_factor:t.environmentManager.globeHaloExpFactor,u_vec4_default_background_color:n.getColorForShaders(x)},i)},Ls=(s,e,t,i)=>{const o=e.size,a=Math.max(o[0],o[1]),r=o[0]/a,l=o[1]/a;n.ortho(Es,-r/2,r/2,-l/2,l/2,.001,1);const c=n.Mercator.toGeo(e.center),d=n.set(xd,0,0,0),_=n.set(bd,0,0,1);n.rotateX(_,_,d,n.degToRad(c[1])),n.rotateY(_,_,d,n.degToRad(c[0]));const u=n.lookAt(wd,Sd,_,Td);n.multiply(u,Es,u);const h=t.styleManager.getStyle(e.handyStyleId);if(!h)return;const f=h?.environment;if(!f)return;const m=n.makeBinderContext(e.styleZoom,e.styleState,[]),p=n.resolveNumber(f.style.starsIntensity,m);Je(t,s,{u_float_pixelratio:window.devicePixelRatio,u_float_stars_intensity:p,u_mat4_stars:u},i)},se=(s,e,t,i)=>{const{size:o}=e,a=window.devicePixelRatio;Je(t,s,{u_vec2_vpt_size:[o[0]*a,o[1]*a]},i)};function Je(s,e,t,i){i?i.updateData(e,t):s.renderer.bindShaderProgram(e,t)}function W(...s){return(e,t,i,o)=>{s.forEach(a=>a(e,t,i,o))}}const Md=W(Is,Jt,Ii,Z,V,q,At,Cs,Un,Ls,se),Ps=W(V,Z),Bs=(s,e,t)=>{const{size:i}=e,o=window.devicePixelRatio;if(e.demMode){const a=t.renderer.getFramebuffer(t.demManager.getFlatFramebufferId());if(!a)return;t.renderer.bindShaderProgram(s,{u_vec2_vpt_size:[Math.trunc(a.renderTarget.options.size[0]),Math.trunc(a.renderTarget.options.size[1])]})}else t.renderer.bindShaderProgram(s,{u_vec2_vpt_size:[i[0]*o,i[1]*o]})},ei=(s,e,t)=>{const i=n.zoomToScale(e.zoom);t.renderer.bindShaderProgram(s,{u_vec3_projection_scale_style_scale_dpi:[i,i,n.zptPerInch*window.devicePixelRatio]})},zs=(s,e,t)=>{const i=n.zoomToScale(e.styleZoom);t.renderer.bindShaderProgram(s,{u_vec3_projection_scale_style_scale_dpi:[i,i,n.zptPerInch*window.devicePixelRatio]})},Ci=(s,e,t)=>{t.renderer.bindShaderProgram(s,{u_float_height_factor:t.buildingHeightAnimator.getDefaultBuildingHeight()})},Li=(s,e,t)=>{t.renderer.bindShaderProgram(s,{u_float_z_offset:0})},Ed=(s,e,t)=>{t.renderer.bindShaderProgram(s,{u_float_z_offset:-1e-5})},Ae=(s,e,t)=>{t.renderer.bindShaderProgram(s,{u_sr2d_texture:0})},Rs=(s,e,t)=>{t.renderer.bindShaderProgram(s,{u_sr2d_texture1:1})},Fs=(s,e,t)=>{t.renderer.bindShaderProgram(s,{u_vec4_border_color:[0,0,0,0]})},Ds=(s,e,t)=>{t.renderer.bindShaderProgram(s,{u_vec4_space_color:[0,0,0,0]})},Id=(s,e,t)=>{t.renderer.bindShaderProgram(s,{u_float_identify_opacity:e.iconIdentifyOpacity})},Os=(s,e,t)=>{const{renderer:i}=t,{labelingTextureBuffer:o,spriteLabelingTextureBuffer:a}=i;let r=e.isLabelingDepthTestDisabled;if(!r){const c=o.getDepthAttachment(),d=o.getTexture();!(c instanceof g)||!d?r=!0:(t.renderer.enableTexture(d,Rr),t.renderer.enableTexture(c,Fr))}const l=a.getTexture();l&&(t.renderer.enableTexture(l,Dr),t.renderer.bindShaderProgram(s,{u_color_text_sprite_labeling:Dr})),t.renderer.bindShaderProgram(s,{u_bool_depth_test_disable:r}),r||t.renderer.bindShaderProgram(s,{u_color_tex_labeling:Rr,u_depth_tex_labeling:Fr})};function ti(...s){return(e,t,i)=>{s.forEach(o=>o(e,t,i))}}function be(...s){return(e,t,i,o,a)=>{s.forEach(r=>r(e,t,i,o,a))}}const Cd=1,Ld=2,Pd=4,A=(s,e,t,i,o)=>{let a=n.ReservedLightingMode.none,r=n.DEFAULT_LIGHTING_MODES[a],l=0;const c=Ns(i,t,e);c&&(r=c.lightConfig,a=c.lightingMode,l=(a===n.ReservedLightingMode.none||o?0:Cd)+(i.receiveShadows!==!1&&r.shadowLightIndex===0?Ld:0)+(i.receiveShadows!==!1&&r.shadowLightIndex===1?Pd:0));const d=t.renderer.getUbo(a);if(d&&t.renderer.isUboSupported()){d.bind(s),t.renderer.bindShaderProgram(s,{u_int_light_flags:l});return}t.renderer.bindShaderProgram(s,{u_int_light_flags:l,u_vec3_light_dir1_direction:r.dir1Direction,u_vec4_light_dir1_color:r.dir1ColorIntensity,u_vec3_light_dir2_direction:r.dir2Direction,u_vec4_light_dir2_color:r.dir2ColorIntensity,u_vec4_ambient_color:r.ambientColorIntensity})},et=(s,e,t,i)=>{const o=n.makeBinderContext(e.styleZoom,e.styleState,[],!1),a=n.resolveNumber(i.style.nearCameraFade,o);t.renderer.bindShaderProgram(s,{u_sdtr_distance:a})},Pi=(s,e,t,i)=>{const o=n.makeBinderContext(e.styleZoom,e.styleState,[],!1),a=i.style.showRatio,r=n.resolveExpression(a,o);t.renderer.bindShaderProgram(s,{u_float_show_ratio:r})};function Ns(s,e,t){const i=e.styleManager.getStyle(t.handyStyleId);if(!i||!i.light.lightingModesResolved)return null;let o=s.lightingMode??i.light.defaultLightMode;s.type==="gltfModel"&&s.style.ignoreGlobalLighting&&(o=n.ReservedLightingMode.none);let a=i.light.lightingModesResolved[o];return a||(a=i.light.lightingModesResolved[i.light.defaultLightMode]),{lightingMode:o,lightConfig:a}}class k{constructor(e,t,i=null){this.isDirty=!1,this._vao=null,this._vaoExt=null,this._gl=null,this.attributesAliases={},this._attributes=t,this._shaderProgram=e,this.indicesBuffer=i}static merge(e){const t=e[0],i={},o={};for(const r of e)Object.assign(i,r._attributes),Object.assign(o,r.attributesAliases);const a=new k(t._shaderProgram,i,t.indicesBuffer);return a.setAttributesAliases(o),a}copy(){const e=new k(this._shaderProgram,{...this._attributes},this.indicesBuffer);return e.setAttributesAliases(this.attributesAliases),e}bind(e){const t=e.extensions.OES_vertex_array_object,i=e.extensions.ANGLE_instanced_arrays;return this._bind(e.gl,t,i),this}unbind(){return this._glBindVertexArray(null),this}setAttribute(e,t){this._attributes[e]=t,this.remove()}remove(){return this._vao&&(this._glDeleteVertexArray(this._vao),this._vao=null),this}getElementsGLType(){return this.indicesBuffer?this.indicesBuffer.getGLType():null}getBuffer(e){return this._attributes[e]}rewriteData(e,t){this._attributes[e].replaceData(t),this.isDirty=!0}setAttributesAliases(e){Object.assign(this.attributesAliases,e),this.remove()}setAttributes(e,t){const i=this._shaderProgram.attributes,o=this._attributes;for(const a in i){const l=this.attributesAliases[a]||a,c=o[l];if(!c)continue;const d=i[a];if(d.index!==!0)for(let _=0;_<d.locationsCount;_++)e.enableVertexAttribArray(d.location+_);c.bind(d.location,void 0,t,d.locationsCount)}this.indicesBuffer&&this.indicesBuffer.bind()}_bind(e,t,i){this._vao?(this.isDirty&&this.updateDirtyBuffers(),this._glBindVertexArray(this._vao)):this._prepare(e,t,i)}_prepare(e,t,i){this._gl=e,t&&(this._vaoExt=t),this._vao=this._glCreateVertexArray(),this._glBindVertexArray(this._vao),this.setAttributes(e,i)}_glCreateVertexArray(){const e=this._gl,t=this._vaoExt;return e&&this._isWebGL2(e)?e.createVertexArray():t?t.createVertexArrayOES():null}_glBindVertexArray(e){const t=this._gl,i=this._vaoExt;t&&this._isWebGL2(t)?t.bindVertexArray(e):i?i.bindVertexArrayOES(e):t&&this._shaderProgram.bind(void 0,this._attributes)}_glDeleteVertexArray(e){const t=this._gl,i=this._vaoExt;t&&this._isWebGL2(t)?t.deleteVertexArray(e):i&&i.deleteVertexArrayOES(e)}_isWebGL2(e){return typeof window<"u"&&"WebGL2RenderingContext"in window&&e instanceof WebGL2RenderingContext}updateDirtyBuffers(){const e=this._shaderProgram.attributes,t=this._attributes,i=this.attributesAliases;for(const o in e){const a=i[o]||o,r=t[a];r?.isDirty&&r.commitData()}this.isDirty=!1}}const Bd=(s,e)=>{const t=n.PolygonGenerator.sinks.fill.stride,i=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:t,offset:0,normalized:!0});return new k(e,{a_vec2_vertex:i})},zd=(s,e)=>{const t=n.PolygonGenerator.sinks.fill.stride,i=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:t,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.UnsignedShort,stride:t,offset:4,normalized:!1});return new k(e,{a_vec2_vertex:i,a_float_mix_factor:o})},Rd=(s,e)=>{const t=n.PolygonGenerator.sinks.shadow.stride,i=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:t,offset:0,normalized:!0});return new k(e,{a_vec2_vertex:i})},Fd=(s,e)=>{const i=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:8,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:8,offset:4,normalized:!1});return new k(e,{a_vec2_vertex:i,a_vec2_texcoord:o})},Dd=(s,e)=>{const i=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:8,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.UnsignedByte,stride:8,offset:4,normalized:!0});return new k(e,{a_vec2_vertex:i,a_vec4_identifier:o})},Od=(s,e)=>{const i=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:12,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.Byte,stride:12,offset:4,normalized:!1});return new k(e,{a_vec2_vertex:i,a_vec4_normals:o})},Nd=(s,e)=>{const t=n.LineGenerator.sinks.solid3d.stride,i=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:t,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.Byte,stride:t,offset:4,normalized:!1}),a=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:t,offset:8,normalized:!1}),r=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:t,offset:12,normalized:!1});return new k(e,{a_vec2_vertex:i,a_vec4_normals:o,a_float_height:a,a_float_abs_z:r})},kd=(s,e)=>{const t=n.LineGenerator.sinks.solid3d.stride,i=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:t,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.Byte,stride:t,offset:4,normalized:!1}),a=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:t,offset:8,normalized:!1}),r=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:t,offset:12,normalized:!1}),l=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.UnsignedByte,stride:t,offset:16,normalized:!0});return new k(e,{a_vec2_vertex:i,a_vec4_normals:o,a_float_height:a,a_float_abs_z:r,a_vec4_identifier:l})},Ud=(s,e)=>{const i=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:16,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.Byte,stride:16,offset:4,normalized:!1}),a=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Float,stride:16,offset:8,normalized:!1});return new k(e,{a_vec2_vertex:i,a_vec4_normals:o,a_vec2_shift:a})},Gd=(s,e)=>{const i=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:12,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.Byte,stride:12,offset:4,normalized:!1}),a=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.UnsignedByte,stride:12,offset:8,normalized:!0});return new k(e,{a_vec2_vertex:i,a_vec4_normals:o,a_vec4_identifier:a})},Hd=(s,e)=>{const t=n.LineGenerator.sinks.patterned.stride,i=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:t,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:t,offset:4,normalized:!1}),a=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:t,offset:8}),r=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.UnsignedByte,stride:t,offset:12,normalized:!0});return new k(e,{a_vec2_vertex:i,a_vec2_widen:o,a_float_texture:a,a_vec4_identifier:r})},Vd=(s,e)=>{const t=n.LineGenerator.sinks.patterned3d.stride,i=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:t,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:t,offset:4,normalized:!1}),a=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:t,offset:8}),r=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:t,offset:12,normalized:!1}),l=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.UnsignedByte,stride:t,offset:16,normalized:!0});return new k(e,{a_vec2_vertex:i,a_vec2_widen:o,a_float_texture:a,a_float_height:r,a_vec4_identifier:l})},ks=(s,e)=>{const i=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:28,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:28,offset:4,normalized:!1}),a=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Byte,stride:28,offset:8,normalized:!1}),r=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:28,offset:12,normalized:!1}),l=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:28,offset:16,normalized:!1}),c=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:28,offset:20,normalized:!1}),d=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.UnsignedByte,stride:28,offset:24,normalized:!0});return new k(e,{a_vec2_vertex:i,a_vec2_texture_widen:a,a_vec2_widen:o,a_float_vertex_distance:r,a_float_component_distance:l,a_float_object_length:c,a_vec4_identifier:d})},Us=(s,e)=>{const t=n.DashedLineGenerator.sinks.stroke3d.stride,i=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:t,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:t,offset:4,normalized:!1}),a=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Byte,stride:t,offset:8,normalized:!1}),r=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:t,offset:12,normalized:!1}),l=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:t,offset:16,normalized:!1}),c=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:t,offset:20,normalized:!1}),d=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:t,offset:24,normalized:!1}),_=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.UnsignedByte,stride:t,offset:28,normalized:!0});return new k(e,{a_vec2_vertex:i,a_vec2_texture_widen:a,a_vec2_widen:o,a_float_vertex_distance:r,a_float_component_distance:l,a_float_object_length:c,a_float_height:d,a_vec4_identifier:_})},Gs=(s,e)=>{const i=new n.BufferChannel(s,{itemSize:3,dataType:n.Buffer.UnsignedShort,stride:36,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:3,dataType:n.Buffer.Short,stride:36,offset:6,normalized:!0}),a=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:36,offset:12,normalized:!1}),r=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:36,offset:16,normalized:!1}),l=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:36,offset:20,normalized:!1}),c=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.UnsignedByte,stride:36,offset:28,normalized:!0}),d=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.UnsignedByte,stride:36,offset:32,normalized:!0});return new k(e,{a_vec3_flat_position:i,a_vec3_ecef_position:o,a_vec2_check_offset:r,a_vec2_offset:a,a_vec2_texcoord:l,a_vec4_tex_identifier:c,a_vec4_sprite_identifier:d})},jd=(s,e)=>{const i=new n.BufferChannel(s,{itemSize:3,dataType:n.Buffer.UnsignedShort,stride:36,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:3,dataType:n.Buffer.Short,stride:36,offset:6,normalized:!0}),a=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:36,offset:12,normalized:!1}),r=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.UnsignedByte,stride:36,offset:24,normalized:!0});return new k(e,{a_vec3_flat_position:i,a_vec3_ecef_position:o,a_vec2_offset:a,a_vec4_identifier:r})},Bi=(s,e)=>{const i=new n.BufferChannel(s,{itemSize:3,dataType:n.Buffer.UnsignedShort,stride:28,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:28,offset:8,normalized:!1}),a=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Float,stride:28,offset:12,normalized:!1}),r=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Float,stride:28,offset:20,normalized:!1});return new k(e,{a_vec4_position:i,a_vec2_offset:a,a_vec2_texcoord:o,a_vec2_style_zoom_limits:r})},Hs=(s,e)=>{const t=n.MeshGenerator.sinks.fill.stride,i=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:t,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:t,offset:4,normalized:!1}),a=new n.BufferChannel(s,{itemSize:3,dataType:n.Buffer.Byte,stride:t,offset:8,normalized:!1}),r=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Byte,stride:t,offset:11,normalized:!1}),l=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:t,offset:16,normalized:!1}),c=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:t,offset:16,normalized:!1}),d=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.UnsignedByte,stride:t,offset:12,normalized:!0}),_=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.UnsignedByte,stride:t,offset:20,normalized:!1});return new k(e,{a_vec2_vertex:i,a_float_z:o,a_vec3_normal:a,a_float_gradient:r,a_vec2_dem_position:l,a_float_abs_z:c,a_vec4_identifier:d,a_float_is_pivot:_})},Zd=(s,e)=>{const t=n.MeshGenerator.sinks.fill.stride,i=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:t,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:t,offset:4,normalized:!1}),a=new n.BufferChannel(s,{itemSize:3,dataType:n.Buffer.Byte,stride:t,offset:8,normalized:!1}),r=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Byte,stride:t,offset:11,normalized:!1}),l=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:t,offset:16,normalized:!1}),c=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:t,offset:16,normalized:!1}),d=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.UnsignedByte,stride:t,offset:20,normalized:!1}),_=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.UnsignedByte,stride:t,offset:24,normalized:!0});return new k(e,{a_vec2_vertex:i,a_float_z:o,a_vec3_normal:a,a_float_gradient:r,a_vec2_dem_position:l,a_float_abs_z:c,a_vec4_identifier:_,a_float_is_pivot:d})},Vs=(s,e)=>{const t=n.MeshGenerator.sinks.fill.stride,i=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:t,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:t,offset:4,normalized:!1}),a=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:t,offset:16,normalized:!1}),r=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:t,offset:16,normalized:!1}),l=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.UnsignedByte,stride:t,offset:20,normalized:!1});return new k(e,{a_vec2_vertex:i,a_float_z:o,a_vec2_dem_position:a,a_float_abs_z:r,a_float_is_pivot:l})},zi=(s,e)=>{const t=n.MeshGenerator.sinks.inverse.stride,i=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:t,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:t,offset:4,normalized:!1}),a=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:t,offset:8,normalized:!1}),r=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:t,offset:8,normalized:!1}),l=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.UnsignedByte,stride:t,offset:12,normalized:!1});return new k(e,{a_vec2_vertex:i,a_float_z:o,a_vec2_dem_position:a,a_float_abs_z:r,a_float_is_pivot:l})},Wd=(s,e)=>{const t=n.MeshGenerator.sinks.stroke.stride,i=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:t,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:t,offset:4,normalized:!1}),a=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.Byte,stride:t,offset:8,normalized:!1}),r=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:t,offset:12,normalized:!1}),l=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:t,offset:12,normalized:!1}),c=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.UnsignedByte,stride:t,offset:16,normalized:!1});return new k(e,{a_vec2_vertex:i,a_float_z:o,a_vec4_direction_distance:a,a_vec2_dem_position:r,a_float_abs_z:l,a_float_is_pivot:c})},js=(s,e)=>{const t=n.PolygonExtrusionGenerator.sinks.sideFill.stride,i=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:t,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:t,offset:4,normalized:!1}),a=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:t,offset:12,normalized:!1});return new k(e,{a_vec2_vertex:i,a_float_z:o,a_vec2_dem_position:a})},$d=(s,e)=>{const t=n.PolygonExtrusionGenerator.sinks.sideTexture.stride,i=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:t,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:t,offset:4,normalized:!1}),a=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:t,offset:8,normalized:!1}),r=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Float,stride:t,offset:12,normalized:!1}),l=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedByte,stride:t,offset:20,normalized:!1});return new k(e,{a_vec2_vertex:i,a_float_z:o,a_vec2_dem_position:a,a_vec2_wall_size:r,a_vec2_quad_fraction:l})},Zs=(s,e)=>{const t=n.PolygonExtrusionGenerator.sinks.topFill.stride,i=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:t,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:t,offset:4,normalized:!1}),a=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:t,offset:12,normalized:!1});return new k(e,{a_vec2_vertex:i,a_float_z:o,a_vec2_dem_position:a})},Ws=s=>(e,t)=>{const i=new n.BufferChannel(e,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:s,offset:0,normalized:!0}),o=new n.BufferChannel(e,{itemSize:1,dataType:n.Buffer.Float,stride:s,offset:4,normalized:!1}),a=new n.BufferChannel(e,{itemSize:4,dataType:n.Buffer.UnsignedByte,stride:s,offset:8,normalized:!0}),r=new n.BufferChannel(e,{itemSize:2,dataType:n.Buffer.Short,stride:s,offset:12,normalized:!1});return new k(t,{a_vec2_vertex:i,a_float_z:o,a_vec4_identifier:a,a_vec2_dem_position:r})},$s=s=>(e,t)=>{const i=new n.BufferChannel(e,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:s,offset:0,normalized:!0}),o=new n.BufferChannel(e,{itemSize:1,dataType:n.Buffer.Float,stride:s,offset:4,normalized:!1}),a=new n.BufferChannel(e,{itemSize:2,dataType:n.Buffer.Short,stride:s,offset:12,normalized:!1}),r=new n.BufferChannel(e,{itemSize:4,dataType:n.Buffer.UnsignedByte,stride:s,offset:16,normalized:!0});return new k(t,{a_vec2_vertex:i,a_float_z:o,a_vec4_identifier:r,a_vec2_dem_position:a})},Xs=s=>(e,t)=>{const i=new n.BufferChannel(e,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:s,offset:0,normalized:!0}),o=new n.BufferChannel(e,{itemSize:1,dataType:n.Buffer.Float,stride:s,offset:4,normalized:!1}),a=new n.BufferChannel(e,{itemSize:2,dataType:n.Buffer.Short,stride:s,offset:12,normalized:!1});return new k(t,{a_vec2_vertex:i,a_float_z:o,a_vec2_dem_position:a})},Xd=(s,e)=>{const t=n.LineExtrusionGenerator.sinks.fill.stride,i=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:t,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:t,offset:4,normalized:!1}),a=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:t,offset:8,normalized:!1});return new k(e,{a_vec2_vertex:i,a_float_z:o,a_vec2_dem_position:a})},Kd=(s,e)=>{const t=n.LineExtrusionGenerator.sinks.fill.stride,i=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:t,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:t,offset:4,normalized:!1}),a=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:t,offset:8,normalized:!1});return new k(e,{a_vec2_vertex:i,a_float_z:o,a_vec2_dem_position:a})},Ks=(s,e)=>{const i=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:20,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:20,offset:4,normalized:!1}),a=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Byte,stride:20,offset:8,normalized:!1}),r=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Byte,stride:20,offset:10,normalized:!1}),l=new n.BufferChannel(s,{itemSize:3,dataType:n.Buffer.Byte,stride:20,offset:12,normalized:!1}),c=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Byte,stride:20,offset:15,normalized:!1}),d=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:20,offset:16,normalized:!1});return new k(e,{a_vec2_vertex:i,a_float_z:o,a_vec2_normal:a,a_vec2_normal_delta:r,a_vec3_direction:l,a_float_distance:c,a_vec2_dem_position:d})},qd=(s,e)=>{const i=new n.BufferChannel(s,{itemSize:3,dataType:n.Buffer.UnsignedShort,stride:40,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:3,dataType:n.Buffer.Short,stride:40,offset:6,normalized:!0}),a=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:40,offset:12,normalized:!1}),r=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:40,offset:16,normalized:!1}),l=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:40,offset:20,normalized:!1}),c=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:40,offset:24,normalized:!1}),d=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.UnsignedByte,stride:40,offset:32,normalized:!0});return new k(e,{a_vec3_flat_position:i,a_vec3_ecef_position:o,a_vec2_offset:a,a_vec2_check_offset:r,a_vec2_texcoord:l,a_vec2_range:c,a_vec4_tex_identifier:d})},Yd=(s,e)=>{const i=new n.BufferChannel(s,{itemSize:3,dataType:n.Buffer.UnsignedShort,stride:40,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:3,dataType:n.Buffer.Short,stride:40,offset:6,normalized:!0}),a=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:40,offset:12,normalized:!1}),r=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:40,offset:20,normalized:!1}),l=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:40,offset:24,normalized:!1}),c=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.UnsignedByte,stride:40,offset:36,normalized:!0});return new k(e,{a_vec3_flat_position:i,a_vec3_ecef_position:o,a_vec2_offset:a,a_vec2_texcoord:r,a_vec2_range:l,a_vec4_identifier:c})},Qd=(s,e)=>{const i=new n.BufferChannel(s,{itemSize:3,dataType:n.Buffer.UnsignedShort,stride:40,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:3,dataType:n.Buffer.Short,stride:40,offset:6,normalized:!0}),a=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:40,offset:12,normalized:!1}),r=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:40,offset:20,normalized:!1}),l=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:40,offset:24,normalized:!1}),c=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.UnsignedByte,stride:40,offset:28,normalized:!0});return new k(e,{a_vec3_flat_position:i,a_vec3_ecef_position:o,a_vec2_offset:a,a_vec2_texcoord:r,a_vec2_range:l,a_vec4_identifier:c})},Jd=(s,e)=>{const i=new n.BufferChannel(s,{itemSize:3,dataType:n.Buffer.UnsignedShort,stride:16,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:16,offset:8,normalized:!1}),a=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.UnsignedByte,stride:16,offset:12,normalized:!0});return new k(e,{a_vec4_position:i,a_vec2_offset:o,a_vec4_identifier:a})},qs=(s,e)=>{const i=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:12,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Byte,stride:12,offset:8,normalized:!1}),a=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Byte,stride:12,offset:10,normalized:!1});return new k(e,{a_vec2_position:i,a_vec2_direction:o,a_vec2_widen_direction:a})},Ad=(s,e)=>{const t=n.BuildingModelGenerator.sinks.fill.stride,i=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:t,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:t,offset:4,normalized:!1}),a=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:t,offset:8,normalized:!1}),r=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:t,offset:16,normalized:!1});return new k(e,{a_vec2_vertex:i,a_float_z:o,a_vec2_texcoord:a,a_vec2_dem_position:r})},e_=(s,e)=>{const t=n.BuildingModelGenerator.sinks.fill.stride,i=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:t,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:t,offset:4,normalized:!1}),a=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.UnsignedByte,stride:t,offset:12,normalized:!0}),r=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:t,offset:16,normalized:!1});return new k(e,{a_vec2_vertex:i,a_float_z:o,a_vec4_identifier:a,a_vec2_dem_position:r})},t_=(s,e)=>{const t=n.BuildingModelGenerator.sinks.fill.stride,i=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:t,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:t,offset:4,normalized:!1}),a=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:t,offset:16,normalized:!1}),r=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.UnsignedByte,stride:t,offset:20,normalized:!0});return new k(e,{a_vec2_vertex:i,a_float_z:o,a_vec4_identifier:r,a_vec2_dem_position:a})},i_=(s,e)=>{const t=n.BuildingModelGenerator.sinks.fill.stride,i=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:t,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:t,offset:4,normalized:!1}),a=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:t,offset:16,normalized:!1});return new k(e,{a_vec2_vertex:i,a_float_z:o,a_vec2_dem_position:a})},n_=(s,e)=>{const i=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:8,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.Byte,stride:8,offset:4,normalized:!1});return new k(e,{a_vec2_vertex:i,a_vec4_direction_distance:o})},Gn=(s,e)=>{const i=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:16,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:16,offset:4,normalized:!1}),a=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.Byte,stride:16,offset:8,normalized:!1}),r=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:16,offset:12,normalized:!1});return new k(e,{a_vec2_vertex:i,a_float_z:o,a_vec4_direction_distance:a,a_vec2_dem_position:r})},Ys=(s,e)=>{const i=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:36,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:36,offset:4,normalized:!0}),a=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.Byte,stride:36,offset:8,normalized:!1}),r=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:36,offset:12,normalized:!1}),l=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:36,offset:16,normalized:!1}),c=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:36,offset:20,normalized:!1}),d=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:36,offset:24,normalized:!1}),_=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:36,offset:28,normalized:!1}),u=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.UnsignedByte,stride:36,offset:32,normalized:!0});return new k(e,{a_vec2_vertex:i,a_vec2_segment_end:o,a_vec4_texture_widen_arrow_widen:a,a_vec2_widen:r,a_vec2_direction:l,a_float_distance_from_start:c,a_float_object_length:d,a_float_type:_,a_vec4_identifier:u})},Hn=(s,e)=>{const t=n.CircleMarkerGenerator.sinks.fill.stride,i=new n.BufferChannel(s,{itemSize:3,dataType:n.Buffer.UnsignedShort,stride:t,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:3,dataType:n.Buffer.Short,stride:t,offset:6,normalized:!0}),a=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:t,offset:12,normalized:!1});return new k(e,{a_vec3_flat_position:i,a_vec3_ecef_position:o,a_vec2_widen:a})},o_=(s,e)=>{const t=n.CircleMarkerGenerator.sinks.fill.stride,i=new n.BufferChannel(s,{itemSize:3,dataType:n.Buffer.UnsignedShort,stride:t,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:3,dataType:n.Buffer.Short,stride:t,offset:6,normalized:!0}),a=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:t,offset:12,normalized:!1}),r=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.UnsignedByte,stride:t,offset:16,normalized:!0});return new k(e,{a_vec3_flat_position:i,a_vec3_ecef_position:o,a_vec2_widen:a,a_vec4_identifier:r})},s_=(s,e)=>{const t=n.RasterGenerator.sinks.fill.stride,i=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:t,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:t,offset:4,normalized:!1});return new k(e,{a_vec2_vertex:i,a_vec2_texcoord:o})},a_=(s,e)=>{const t=n.HeatmapGenerator.sinks.framebuffer.stride,i=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:t,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:t,offset:4,normalized:!1}),a=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Byte,stride:t,offset:8,normalized:!1});return new k(e,{a_vec2_position:i,a_vec2_widen:a,a_float_weight:o})},r_=(s,e)=>{const t=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Float,stride:0,offset:0,normalized:!1});return new k(e,{a_vec2_position:t})},Qs=(s,e)=>{const i=new n.BufferChannel(s,{itemSize:3,dataType:n.Buffer.Float,stride:12,offset:0});return new k(e,{a_vec3_position:i})},Ri=(s,e)=>new k(e,{a_vec2_position:s}),ii=(s,e)=>{const t=n.DemGenerator.sinks.mesh2.stride,i=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:t,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:t,offset:4,normalized:!1});return new k(e,{a_vec2_vertex:i,a_float_height:o})},l_=(s,e)=>{const t=n.DemGenerator.sinks.flatBottom.stride,i=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:t,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:t,offset:4,normalized:!1}),a=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Byte,stride:t,offset:8,normalized:!0});return new k(e,{a_vec2_vertex:i,a_vec2_centroid:o,a_vec2_extender:a})},Vn=(s,e)=>{const t=n.DemGenerator.sinks.hillshade.stride,i=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:t,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:t,offset:4,normalized:!1});return new k(e,{a_vec2_vertex:i,a_vec2_texcoord:o})},Fi=s=>(e,t,i,o)=>{const a=n.GltfModelGenerator.sinks.instances.stride,r=new n.BufferChannel(e,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:a,offset:0,normalized:!0,instanceDivisor:1}),l=new n.BufferChannel(e,{itemSize:1,dataType:n.Buffer.Float,stride:a,offset:4,normalized:!1,instanceDivisor:1}),c=new n.BufferChannel(e,{itemSize:3,dataType:n.Buffer.Short,stride:a,offset:8,normalized:!0,instanceDivisor:1}),d=new n.BufferChannel(e,{itemSize:9,dataType:n.Buffer.Float,stride:a,offset:16,instanceDivisor:1}),_=new n.BufferChannel(e,{itemSize:4,dataType:n.Buffer.UnsignedByte,stride:a,offset:s?56:52,normalized:!0,instanceDivisor:1}),u=new n.BufferChannel(e,{itemSize:1,dataType:n.Buffer.Float,stride:a,offset:60,normalized:!1,instanceDivisor:1});return new k(t,{a_vec2_instance_position:r,a_float_instance_height:l,a_vec3_instance_ecef_position:c,a_mat3_instance_matrix:d,a_vec4_instance_localid:_,a_float_abs_z:u,...o},i)},jn=(s,e)=>{const t=n.MapMeshGenerator.sinks.fill.stride,i=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:t,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:t,offset:4,normalized:!1}),a=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:t,offset:8,normalized:!1}),r=new n.BufferChannel(s,{itemSize:3,dataType:n.Buffer.Byte,stride:t,offset:12,normalized:!1}),l=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Byte,stride:t,offset:15,normalized:!1}),c=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:t,offset:16,normalized:!1}),d=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:t,offset:16,normalized:!1}),_=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.UnsignedByte,stride:t,offset:20,normalized:!1});return new k(e,{a_vec2_vertex:i,a_float_z:o,a_vec2_extender:a,a_vec3_normal:r,a_float_gradient:l,a_vec2_dem_position:c,a_float_abs_z:d,a_float_is_pivot:_})},c_=(s,e)=>{const t=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Float,stride:0,offset:0,normalized:!1});return new k(e,{a_vec2_vertex:t})},ni=(s,e)=>{const t=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Byte,stride:0,offset:0,normalized:!1});return new k(e,{a_vec2_vertex:t})},Js=(s,e,t)=>{const i=n.GlobeGenerator.sinks.fill.stride;return new k(e,{a_vec3_ecef_position:new n.BufferChannel(s,{itemSize:3,dataType:n.Buffer.Short,stride:i,normalized:!0,offset:0}),a_vec3_flat_position:new n.BufferChannel(s,{itemSize:3,dataType:n.Buffer.UnsignedShort,stride:i,normalized:!0,offset:6}),a_vec2_texture:new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:i,normalized:!0,offset:12})},t)},d_=(s,e)=>new k(e,{a_vec3_position:new n.BufferChannel(s,{itemSize:3,dataType:n.Buffer.Float,stride:16,offset:0,normalized:!0}),a_fade_opacity:new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:16,offset:12,normalized:!1})}),zt=32,As=1/0,__="raster";class ea extends n.TileObjectBase{constructor(e,t,i){super(__),this.children=[],this.identifyChildren=[];const o=this;this.setTileCoords(e,t.map.state),t.renderer.symbolSettingsList.dem.mesh?.forEach(a=>{const r={id:n.uniqId(),type:n.SceneObjectType.Tile,symbol:"dem",sink:"mesh",tile:this,attributes:{layerId:n.DEM_STYLE_LAYER_ID,styleId:t.map.state.handyStyleId,tileData:[]},start:0,count:zt*zt*6,attributesHash:"",layerSettings:a,vao:i.mesh,canRender:!0,renderingProperties:{flatTexture:null,hillshadeTexture:null,flatIdentifyTexture:null}};a.identify?o.identifyChildren.push(r):a.depthTest?o.depthTestChildren.push(r):a.shadow?o.shadowChildren.push(r):a.dem?o.demChildren.push(r):a.demGround?o.demGroundChildren.push(r):o.children.push(r)})}setTileCoords(e,t){const i=e[2],o=e[3],a=n.tileZoomToSize(i);this.coords=e,this.size=a,this.zoomLevel=i,this.detailLevel=o,this.mvpMatrices.clear(),this.demMatrices.clear(),this.flatMapTexMatrices.clear(),this.syncReplicas(t)}syncReplicas({visibleMapReplicas:e}){const t=Math.pow(2,this.coords[2]),i=this.size/zt;this.bounds.clear(),this.modelMatrices.clear(),e.forEach(o=>{const a=[this.coords[0]+o*t,this.coords[1],this.coords[2],this.coords[3]],r=n.tileCoordsToMapPoint(a);r[0]-=i,r[1]-=i,this.bounds.set(o,{min:[r[0],r[1]],max:[r[0]+this.size,r[1]+this.size]});const l=n.create$2();n.fromTranslationScale(l,r,n.fromValues(this.size+i,this.size+i,n.tileHeight)),this.modelMatrices.set(o,l)}),this.needSync=!1}}class u_{constructor(e,t){this.meshTiles=new Map,this.destroyed=!1,this.modules=e.modules,this.maxZoom=t?.maxZoom??As;const i=[];for(let a=0;a<zt;a++)for(let r=0;r<zt;r++)i.push(r,a,r+1,a,r,a+1),i.push(r,a+1,r+1,a,r+1,a+1);const o=n.maxUint16Value/zt;for(let a=0;a<i.length;a++)i[a]*=o;this.buffer=this.modules.renderer.createBuffer(new Uint16Array(i),{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:0,offset:0,normalized:!0}),this.buffer.drawType=n.Buffer.StaticDraw,this.vaos={mesh:Ri(this.buffer,this.modules.renderer.getShaderProgram("demMesh"))},this.update()}destroy(){this.destroyed||(this.meshTiles=new Map,Object.values(this.vaos).forEach(e=>{e.unbind(),e.remove()}),this.buffer.remove(),this.destroyed=!0)}setMaxZoom(e=As){e!==this.maxZoom&&(this.maxZoom=e,this.update())}update(){if(this.destroyed)return;const e=this.modules.map.state;e.needReplicasUpdate&&this.meshTiles.forEach(a=>{a.needSync=!0});const t=Math.trunc(e.styleZoom),i=Math.min(t,Math.min(this.maxZoom,t)),o=n.findVisibleTiles(this.modules.map.state,this.modules,i,0,i,void 0,void 0,void 0,!0).reduce((a,r)=>(a.set(n.coordsToKey(r),r),a),new Map);this.meshTiles.forEach((a,r)=>{o.has(r)||this.meshTiles.delete(r)}),o.forEach((a,r)=>{this.meshTiles.has(r)||this.meshTiles.set(r,new ea(a,this.modules,this.vaos))})}updateStyleId(){this.meshTiles.forEach(e=>this.updateTileStyleId(e))}updateTileStyleId(e){e.children.forEach(t=>{t.attributes.styleId=this.modules.map.state.handyStyleId}),e.identifyChildren.forEach(t=>{t.attributes.styleId=this.modules.map.state.handyStyleId}),e.depthTestChildren.forEach(t=>{t.attributes.styleId=this.modules.map.state.handyStyleId}),e.shadowChildren.forEach(t=>{t.attributes.styleId=this.modules.map.state.handyStyleId}),e.demChildren.forEach(t=>{t.attributes.styleId=this.modules.map.state.handyStyleId}),e.demGroundChildren.forEach(t=>{t.attributes.styleId=this.modules.map.state.handyStyleId})}}class h_{constructor(e,t,i){this.id=e,this.modules=t,this.options=i,this.type="dem",this.tree=n.rbush(n.DEM_TREE_SIZE),this.tileSize=n.DEM_ELEVATION_TILE_SIZE,this.minElevation=0,this.revision=0,this.tileLoader=new n.BaseTileLoader("arrayBuffer"),this.attributes={},this.tiles=new Map,this.textureIndices=new Map,this.url=o=>{const[a,r,l]=n.tileCoordsToOSM(o);return this.options.url(a,r,l)}}abortTileFetches(e){this.tileLoader.abortRequests(e.map(n.coordsToKey))}deleteTiles(e){for(const t of e){const i=n.coordsToKey(t);if(this.tiles.get(i)){const a=n.getTileBounds(t);this.tree.remove({minX:a.min[0],minY:a.min[1],maxX:a.max[0],maxY:a.max[1]},(r,l)=>i===l.key),this.updateRevision()}this.tiles.delete(i);const o=this.textureIndices.get(i);o!==void 0&&this.modules.imageManager.deleteTexture(o),this.updateMinElevation()}}fetchTiles(e){return e.map(t=>this.fetchTile(t))}async generateTile(e,t){const i=[],o=[],a=n.coordsToKey(t),r=this.tiles.get(a);if(!r)return Promise.resolve({results:i,transferable:o});const l=this.modules.map.state.handyStyleId,{collector:c}=this.modules,d=n.tileZoomToSize(t[2]),_=r.bounds;this.tree.insert({key:a,minX:_.min[0],minY:_.min[1],maxX:_.max[0],maxY:_.max[1],cellSize:d/n.DEM_ELEVATION_TILE_SIZE,...r,tree:null,bounds:_,generated:i}),this.updateMinElevation(),this.updateRevision();do n.DemGenerator.generateMeshElevation(c,r.mesh,l,n.DEM_STYLE_LAYER_ID);while(c.isOverloaded());const u=c.getAccumulatedData();return i.push({regionId:0,metatileHash:-1,styleId:l,collectorOutput:u}),o.push(...u.transferable),Promise.resolve({results:i,transferable:o})}unpackRaw(e,t){const[i,o,a,r]=t,l=new Uint8Array(e),c=new Float32Array(this.tileSize**2);let d=1/0,_=-1/0;const u=this.tileSize;for(let f=0;f<u;f++){const m=n.Mercator.toGeo(n.tileCoordsToMapPoint([i,o+f*(1/n.DEM_ELEVATION_TILE_SIZE),a,r])),p=n.Mercator.scaleFactor(m[1]);for(let v=0;v<u;v++){const y=v+f*u,b=(l[y]+l[u**2+y]*256-1e4)*p;d=Math.min(b,d),_=Math.max(b,_),c[y]=b}}const h=this.getMesh(c);return{data:c,mesh:h,minZ:d,maxZ:_,bounds:{min:n.tileCoordsToMapPoint(t),max:n.tileCoordsToMapPoint([i+1,o+1,a,r])}}}getAttributes(){return this.attributes}setAttributes(e){this.attributes=e}getId(){return this.id}destroy(){const{imageManager:e}=this.modules;this.tileLoader.destroy(),this.tiles.clear(),this.tree.clear(),this.textureIndices.forEach(t=>e.deleteTexture(t)),this.textureIndices.clear()}getElevation(e){const t=this.getElevationTile(e);if(t)return n.getElevationFromTile(t,e)}getElevationTile(e){const t=n.normalizeMapPoint(e);return this.tree.search({minX:t[0],minY:t[1],maxX:t[0],maxY:t[1]}).reduce((o,a)=>!o||o.cellSize>a.cellSize?a:o,void 0)}getMinElevation(){return this.minElevation}updateMinElevation(){const e=this.modules.map.state;if(!e.demMode)return;const t=this.modules.camera.position[2],i=n.tetragonBounds(e.tilesBounds);if(e.elevation!==void 0){const a=e.elevation*n.MAP_POINTS_IN_METER/t+1,r=Math.max(e.pitch/e.maxPitch*30,4);n.scale$1(i,Math.min(a,r))}const o=this.tree.search({minX:i.min[0],minY:i.min[1],maxX:i.max[0],maxY:i.max[1]});e.styleZoom-eo>1?this.minElevation=o.reduce((a,r)=>{if(r.data){const l=n.intersection(i,r.bounds);n.sub(l.min,l.min,r.bounds.min),n.sub(l.max,l.max,r.bounds.min),n.scale$2(l.min,l.min,1/r.cellSize),n.scale$2(l.max,l.max,1/r.cellSize);for(let c=Math.trunc(l.min[0]);c<l.max[0];c++)for(let d=Math.trunc(l.min[1]);d<l.max[1];d++){const _=c+(n.DEM_ELEVATION_TILE_SIZE-1-d)*n.DEM_ELEVATION_TILE_SIZE,u=r.data[_];a=a===void 0?u:Math.min(a,u)}}return a},void 0):this.minElevation=o.reduce((a,r)=>a===void 0?r.minZ:Math.min(a,r.minZ),void 0)}getRevision(){return this.revision}fetchTile(e){const t=n.coordsToKey(e),i=[{regionId:0,metatileHash:-1}];if(this.tiles.has(t))return Promise.resolve(i);const o=this.url(e);return this.tileLoader.fetch(e,()=>o).then(a=>(a.rejected||this.tiles.set(t,a.data&&a.data.byteLength?this.unpackRaw(a.data,e):void 0),i),()=>Promise.resolve(void 0))}updateRevision(){this.revision++}getMesh(e){const t=this.tileSize,i=t*t,o=new Uint16Array(i*2),a=new Uint16Array(i*6);let r=0;for(let l=0;l<t;l++)for(let c=0;c<t;c++){const d=l*t+c;o[2*d+0]=c/(t-1)*n.maxTilePoint,o[2*d+1]=(1-l/(t-1))*n.maxTilePoint,c<t-1&&l<t-1&&(a[r++]=d+1,a[r++]=d,a[r++]=d+t,a[r++]=d+1,a[r++]=d+t,a[r++]=d+t+1)}return{positions:o,heights:e,indices:a}}}class f_{constructor(e,t,i){this.id=e,this.modules=t,this.options=i,this.type="dem",this.tree=n.rbush(n.DEM_TREE_SIZE),this.minElevation=0,this.revision=0,this.worker=new t.workers.parser.MeshElevationSource(this.options),this.attributes={},this.tiles=new Map}abortTileFetches(e){this.worker.abortTileFetches(e)}deleteTiles(e){this.worker.deleteTiles(e);for(const t of e){const i=n.coordsToKey(t),o=this.tiles.get(i);o&&(this.tree.remove(o,(a,r)=>i===r.key),this.tiles.delete(i))}this.updateMinElevation()}fetchTiles(e){return this.worker.fetchTiles(e)}async generateTile(e,t){const i=n.coordsToKey(t),{tree:o,results:a,minZ:r,maxZ:l}=await this.worker.generateTile(e.handyStyleId,t),c=n.getTileBounds(t),d={generated:a,key:i,minX:c.min[0],minY:c.min[1],maxX:c.max[0],maxY:c.max[1],cellSize:n.tileZoomToSize(t[2])/n.DEM_ELEVATION_TILE_SIZE,bounds:c,minZ:r,maxZ:l,tree:o};return this.tiles.set(i,d),this.tree.insert(d),this.updateMinElevation(),this.updateRevision(),{results:a}}getAttributes(){return this.attributes}setAttributes(e){this.attributes=e}getId(){return this.id}destroy(){this.tiles.clear(),this.tree.clear()}getElevation(e){const t=this.getElevationTile(e);if(t)return n.getElevationFromTile(t,e)}getElevationTile(e){const t=n.normalizeMapPoint(e);return this.tree.search({minX:t[0],minY:t[1],maxX:t[0],maxY:t[1]}).reduce((o,a)=>!o||o.cellSize>a.cellSize?a:o,void 0)}getMinElevation(){return this.minElevation}updateMinElevation(){const e=this.modules.map.state;if(!e.demMode)return;const t=n.tetragonBounds(e.tilesBounds),i=this.tree.search({minX:t.min[0],minY:t.min[1],maxX:t.max[0],maxY:t.max[1]});this.minElevation=i.reduce((o,a)=>o===void 0?a.minZ:Math.min(o,a.minZ),void 0)}getRevision(){return this.revision}updateRevision(){this.revision++}}const Fe=new Float64Array(16);class Zn{constructor(e,t,i){this.detailLevel=0,this.mvpMatrix=new Float64Array(16),this.texMatrix=new Float64Array(16),n.copy(this.mvpMatrix,e),n.multiply(this.texMatrix,n.WEBGL_COORDS_TO_TEXTURE,e),this.detailLevel=i,this.viewport=[[0,0,0,1],[1,0,0,1],[1,1,0,1],[0,1,0,1]],n.invert(Fe,this.texMatrix),this.viewport.forEach(o=>{n.transformMat4$1(o,o,Fe),o[0]-=t[0],o[1]-=t[1],o[2]-=t[2],o[2]>=0&&(o[2]=-1),n.normalize(o,o);const a=-t[2]/o[2];o[0]=t[0]+o[0]*a,o[1]=t[1]+o[1]*a,o[2]=t[2]+o[2]*a})}}class m_{constructor(e){this.destroyed=!1,this.modules=e.modules,this.textures=[]}update(){if(this.destroyed)return;const{center:e,padding:t,rotation:i,size:o,viewport:a,extendedTilesBounds:r,zoom:l,cameraConfig:c,globeMode:d}=this.modules.map.state,_=n.getLineConstants(r[0],r[1]),u=n.pointToLineDistance(r[2],_);this.textures=[];const h=n.degToRad(45),f=Math.min(this.modules.map.state.pitch,h),m=new n.Camera({pitch:f,center:e,padding:t,rotation:i,size:o,viewport:a,zoom:l,cameraConfig:c,globeMode:d,styleState:{}}),p=n.clamp(Math.pow(this.modules.map.state.pitch/h,3),0,1),[v,y]=this.modules.camera.position,b=n.transformMat4([],[v,y,0,1],m.viewProjectionMatrix),x=Math.min(b[1]/b[3]+1,-.5);let T=Math.max(x,-1);if(n.fromTranslationScale(Fe,[0,-T,0],[1/Te[0],1/Te[1],1]),n.multiply(Fe,Fe,m.viewProjectionMatrix),this.textures.push(new Zn(Fe,m.position,0)),n.pointToLineDistance(this.textures[0].viewport[2],_)>=u)return!0;if(x<T){const M=Math.max(Math.abs(x-T)/2,1);n.fromTranslationScale(Fe,[0,2/M+1,0],[1/Te[0],Te[1]/M,1]),n.multiply(Fe,Fe,m.viewProjectionMatrix),this.textures.push(new Zn(Fe,m.position,1))}T+=1;const w=Math.pow(o[1]/749,2);[1.4,3.2,12,31].some((M,z)=>{M=(M-1)*p*w+1,n.fromTranslationScale(Fe,[0,-(T*M+1),0],[1/Te[0],M/Te[1],1]),n.multiply(Fe,Fe,m.viewProjectionMatrix),T+=2/M;const S=this.textures.push(new Zn(Fe,m.position,z));if(n.pointToLineDistance(this.textures[S-1].viewport[2],_)>=u)return!0})}destroy(){this.textures=[]}}const Wn={depthMask:!0,depthTest:!0,depthFunc:n.DEPTH_FUNC.LESS,cullFace:!0,cullFaceMode:n.CULL_FACE_MODE.BACK,blend:!1,blendFunc:{sfactor:n.BLEND_FUNC.ONE,dfactor:n.BLEND_FUNC.ZERO},blendEquation:n.BLEND_EQUATION.FUNC_ADD,colorMask:[!0,!0,!0,!0],polygonOffsetFill:!1,polygonOffset:{factor:1,units:2}},oe=s=>{if(typeof s=="function")return t=>{const i=s(t);return Object.assign({},Wn,i)};const e=Object.assign({},Wn,s);return()=>e},he=oe({}),$n=oe({blend:!0,blendFunc:{sfactor:n.BLEND_FUNC.ONE,dfactor:n.BLEND_FUNC.ONE_MINUS_SRC_ALPHA}}),p_=oe({blend:!0,blendFunc:{sfactor:n.BLEND_FUNC.ONE,dfactor:n.BLEND_FUNC.ONE_MINUS_SRC_ALPHA},depthFunc:n.DEPTH_FUNC.GREATER,depthMask:!1,cullFace:!1,polygonOffsetFill:!0,polygonOffset:{factor:1,units:2}}),Rt=oe({depthMask:!1,blend:!0,blendFunc:{sfactor:n.BLEND_FUNC.ONE,dfactor:n.BLEND_FUNC.ONE_MINUS_SRC_ALPHA}}),v_=oe({blend:!0,blendFunc:{sfactor:n.BLEND_FUNC.ONE,dfactor:n.BLEND_FUNC.ONE_MINUS_SRC_ALPHA},cullFace:!1}),Me=oe({depthMask:!1,depthTest:!1,blend:!0,blendFunc:{sfactor:n.BLEND_FUNC.ONE,dfactor:n.BLEND_FUNC.ONE_MINUS_SRC_ALPHA}}),g_=oe({depthMask:!1,depthTest:!1,blend:!0,blendFunc:{sfactor:n.BLEND_FUNC.ONE,dfactor:n.BLEND_FUNC.ONE_MINUS_SRC_ALPHA},blendEquation:n.BLEND_EQUATION.MAX}),y_=oe({depthMask:!1,depthTest:!1,blend:!0,blendFunc:{sfactor:n.BLEND_FUNC.SRC_ALPHA,dfactor:n.BLEND_FUNC.ONE}}),ta=oe({depthMask:!1,depthTest:!1,colorMask:[!0,!1,!1,!0]}),b_=oe({depthMask:!1,depthTest:!1}),_t=oe({depthMask:!1,depthTest:!1}),ia=oe({depthMask:!1}),Di=oe({colorMask:[!1,!1,!1,!1]}),x_=oe({colorMask:[!1,!1,!1,!1],depthFunc:n.DEPTH_FUNC.ALWAYS}),na=oe({blend:!0,blendFunc:{sfactor:n.BLEND_FUNC.ONE,dfactor:n.BLEND_FUNC.ONE_MINUS_SRC_ALPHA}}),w_=oe({depthFunc:n.DEPTH_FUNC.EQUAL,blend:!0,blendFunc:{sfactor:n.BLEND_FUNC.ONE,dfactor:n.BLEND_FUNC.ONE_MINUS_SRC_ALPHA}}),Xn=oe({depthMask:!1,depthTest:!1,blend:!0,blendFunc:{sfactor:n.BLEND_FUNC.ONE,dfactor:n.BLEND_FUNC.ONE_MINUS_SRC_ALPHA}}),Kn=oe({depthMask:!1,depthTest:!0,depthFunc:n.DEPTH_FUNC.LEQUAL,blend:!0,blendFunc:{sfactor:n.BLEND_FUNC.ONE,dfactor:n.BLEND_FUNC.ONE_MINUS_SRC_ALPHA}}),qn=oe({depthMask:!1,depthTest:!0,depthFunc:n.DEPTH_FUNC.GREATER,blend:!0,blendFunc:{sfactor:n.BLEND_FUNC.ONE,dfactor:n.BLEND_FUNC.ONE_MINUS_SRC_ALPHA}}),oa=oe({polygonOffsetFill:!0,polygonOffset:{factor:1,units:2},blend:!0,blendFunc:{sfactor:n.BLEND_FUNC.ONE,dfactor:n.BLEND_FUNC.ONE_MINUS_SRC_ALPHA}}),Oi=oe({cullFaceMode:n.CULL_FACE_MODE.BACK}),Ni=oe({cullFace:!1}),sa=oe({depthMask:!1,depthTest:!1,blend:!0,blendFunc:{sfactor:n.BLEND_FUNC.ONE,dfactor:n.BLEND_FUNC.ONE}}),S_=oe({depthTest:!1,cullFace:!1}),T_=oe({depthTest:!1,depthMask:!1,blend:!0,blendFuncSeparate:{srcRgb:n.BLEND_FUNC.SRC_ALPHA,dstRgb:n.BLEND_FUNC.ONE_MINUS_SRC_ALPHA,srcAlpha:n.BLEND_FUNC.ONE,dstAlpha:n.BLEND_FUNC.ONE_MINUS_SRC_ALPHA}}),aa=oe({colorMask:[!0,!0,!0,!0],depthMask:!0}),M_=oe({colorMask:[!0,!0,!0,!0],depthMask:!1}),E_=oe({depthMask:!0,depthTest:!0,depthFunc:n.DEPTH_FUNC.LEQUAL,blend:!0,blendFunc:{sfactor:n.BLEND_FUNC.ONE,dfactor:n.BLEND_FUNC.ONE_MINUS_SRC_ALPHA}}),I_=oe({depthMask:!0,depthTest:!0,depthFunc:n.DEPTH_FUNC.LEQUAL,blend:!0,blendFunc:{sfactor:n.BLEND_FUNC.SRC_ALPHA_SATURATE,dfactor:n.BLEND_FUNC.ONE_MINUS_SRC_COLOR}}),C_=oe({depthMask:!0,depthTest:!0}),ra=oe(s=>s.map.getFeatureFlag("transparentBuildingsOff")?he(s):w_(s)),L_=oe(()=>({depthFunc:n.DEPTH_FUNC.LEQUAL,depthMask:!1,blend:!0,blendFunc:{sfactor:n.BLEND_FUNC.ONE,dfactor:n.BLEND_FUNC.ONE_MINUS_SRC_ALPHA}})),Yn=n.reserveTextureIndex(),Qn=n.reserveTextureIndex(),Jn=n.reserveTextureIndex(),An=n.reserveTextureIndex(),ut=64,la=5,eo=12,ca=5,da=15,P_=18,B_=12,z_=18,R_=.1,F_=.3,Te=[1.7,1],D_=300,to=.001,_a=1,O_=n.tileZoomToSize(n.tiles.maxRegionalZoom),N_={localhost:{tileServer:"localhost:8181",tileProtocol:"http",subdomains:[]},relief_test:{tileServer:"tileserver.web-staging.2gis.ru",tileProtocol:"https",subdomains:["0","1","2"]},relief_test2:{tileServer:"tileserver.web-staging.2gis.ru",tileProtocol:"https",subdomains:["0","1","2"]}},ki=n.create$1(),Ie=new Float64Array(16);class k_{constructor(e){this.demTextureMatrix=new Float64Array(16),this.demCorrectedFbVpToDemTex=new Float32Array(16),this.demTexToCorrectedTex=new Float32Array(16),this.correctedTexToDemTex=new Float32Array(16),this.isDemCorrectionEnabled=!1,this.demCorrectedScale=1,this.demFbVpMatrix=new Float64Array(16),this.demCorrectedFbVpMatrix=new Float64Array(16),this.demFramebufferId=n.INVALID_FRAMEBUFFER_ID,this.correctedDemFramebufferId=n.INVALID_FRAMEBUFFER_ID,this.flatFramebufferId=n.INVALID_FRAMEBUFFER_ID,this.identifyFlatFramebufferId=n.INVALID_FRAMEBUFFER_ID,this.hillshadeRampTextureId=NaN,this.hillshadeFramebufferId=n.INVALID_FRAMEBUFFER_ID,this.groundFramebufferId=n.INVALID_FRAMEBUFFER_ID,this.isGroundBufferValid=!1,this.lastStyleId=NaN,this.disableAnimation=!1,this.isAnimationStarted=!1,this.tilesRevision=0,this.tileSet=n.dem.tileSet,this.modules=e,this.enabled=!1,this.sources=[],this.sourcesRevision=[],this.tileLayers=[],this.terrainAnimationScaleCoef=to,this.reliefTileType="vector",this.elevationSourceType="irregular",this.groundBuffer=new Float32Array,this.differ=new n.Differ([])}enable(){if(this.isTerrainSupported===void 0&&(this.isTerrainSupported=ws()),this.enabled||!this.isTerrainSupported)return;this.enabled=!0,this.differ=new n.Differ([{path:"center",type:"vec2"},{path:"zoom",type:"number"},{path:"size",type:"vec2"},{path:"rotation",type:"number"},{path:"pitch",type:"number"},{path:"demMode",type:"boolean"},{path:"elevation",type:"number"},{path:"minElevation",type:"number"}]),this.demFramebufferId=this.createDemFramebuffer(),this.correctedDemFramebufferId=this.createCorrectedDemFramebuffer(),this.hillshadeFramebufferId=this.createHillshadeFramebuffer(),this.flatFramebufferId=this.createFlatFramebuffer(),this.identifyFlatFramebufferId=this.createFlatIdentifyFramebuffer(),this.groundFramebufferId=this.createGroundFramebuffer(),this.fullscreenBuffer=this.modules.renderer.createBuffer(new Uint16Array([[0,0,0,0],[1,0,1,0],[0,1,0,1],[0,1,0,1],[1,0,1,0],[1,1,1,1]].reduce((t,i)=>{const[o,a,r,l]=i;return t.push(o*n.maxUint16Value,a*n.maxUint16Value,n.packTexCoords(r),n.packTexCoords(l)),t},[]))),this.hillshadeVao=Vn(this.fullscreenBuffer,this.modules.renderer.getShaderProgram("demHillshade"));const e=this.modules.renderer.getShaderProgram("demElevationCopy");this.copyDemVao=Vn(this.fullscreenBuffer,e),this.addDefaultSources(),this.modules.styleManager.setFramebufferId(this.modules.map.state.handyStyleId,n.DEM_STYLE_LAYER_ID,{hillshade:this.hillshadeFramebufferId,flatBottom:this.correctedDemFramebufferId}),this.updateRampTextureId(),this.startVerticalScaleAnimation()}setAnimationTerrain(e){this.modules.demManager.disableAnimation=!e}getAnimationTerrainStatus(){return this.modules.demManager.disableAnimation}onTerrainStyleChange(){this.updateRampTextureId()}disable(){if(!this.enabled)return;this.dangerouslyDestroySourcesAndLayers(),this.flatMapSource?.destroy(),this.flatMapSource=void 0,this.hillshadeVao?.unbind(),this.hillshadeVao?.remove(),this.fullscreenBuffer?.remove(),this.modules.styleManager.setFramebufferId(this.modules.map.state.handyStyleId,n.DEM_STYLE_LAYER_ID,{hillshade:n.INVALID_FRAMEBUFFER_ID,flatBottom:n.INVALID_FRAMEBUFFER_ID}),this.modules.renderer.removeFramebuffer(this.hillshadeFramebufferId),this.modules.renderer.removeFramebuffer(this.demFramebufferId),this.modules.renderer.removeFramebuffer(this.correctedDemFramebufferId),this.modules.renderer.removeFramebuffer(this.flatFramebufferId),this.modules.renderer.removeFramebuffer(this.groundFramebufferId),this.enabled=!1;const e=this.modules.map.state;this.terrainAnimationScaleCoef=to,this.isAnimationStarted=!1,n.exist("changeScale",e)&&n.stop("changeScale",e)}update(){if(!this.enabled)return;const e=this.modules.map.state;this.lastStyleId!==e.handyStyleId&&(this.updateRampTextureId(),this.meshSource?.updateStyleId(),this.hillshadeTile?.children.forEach(o=>{o.attributes.styleId=e.handyStyleId}),this.modules.styleManager.setFramebufferId(this.modules.map.state.handyStyleId,n.DEM_STYLE_LAYER_ID,{hillshade:this.hillshadeFramebufferId,flatBottom:this.correctedDemFramebufferId}),this.updateClearColor(),this.lastStyleId=e.handyStyleId);const t=this.updateTilesRevision(),i=this.differ.check(this.modules.map.state);(t||i)&&(this.isGroundBufferValid=!1),i&&(this.updateMinElevation(),this.flatMapSource?.update(),this.meshSource?.update(),this.updateDemFramebufferMatrix(),this.modules.renderer.addRerenderEvent()),this.disableAnimation||(this.isAnimationStarted?n.update("changeScale",{step:(o,a)=>{a===_a&&n.stop("changeScale",e),this.terrainAnimationScaleCoef=a}},e):this.startVerticalScaleAnimation())}isEnabled(){return this.enabled}getDemFramebufferId(){return this.demFramebufferId}getGroundFramebufferId(){return this.groundFramebufferId}getCorrectedDemFramebufferId(){return this.correctedDemFramebufferId}getFlatFramebufferId(){return this.flatFramebufferId}getIdentifyFlatFramebufferId(){return this.identifyFlatFramebufferId}getHillshadeFramebufferId(){return this.hillshadeFramebufferId}getHillshadeRampTextureId(){return this.hillshadeRampTextureId}getElevation(e){if(this.enabled)for(let t=this.sources.length-1;t>=0;t--){const o=this.sources[t].getElevation(e);if(o!==void 0)return o}}getLabelsDemKey(e){if(!this.enabled||e.length===0)return;let t;for(const o of e)if(t=o.labels.find(a=>a.type===n.PreLabelType.Point),t)break;if(!t)return;n.vertexTilePointToMapPoint(ki,t.vertices,0,n.createTileInfo(t.tileCoords));let i;for(let o=this.sources.length-1;o>=0;o--){const r=this.sources[o].getElevationTile(ki);if(r!==void 0){i=r;break}}if(i)return i.key}enrichWithElevation(e){if(this.enabled)for(const t of e){let i=null;for(const o of t.labels)o.type===n.PreLabelType.Point&&(i||(i=n.createTileInfo(o.tileCoords)),n.vertexTilePointToMapPoint(ki,o.vertices,0,i),o.demElevation=this.getElevation(ki)??NaN)}}getMinElevation(){return this.sources.reduce((e,t)=>{const i=t.getMinElevation();return i===void 0?e:e===void 0?i:Math.min(e,i)},void 0)}updateMinElevation(){this.sources.forEach(e=>e.updateMinElevation())}getMeshTiles(){return this.reliefTileType==="raster"?this.elevationSourceType==="regular"&&this.meshSource?Array.from(this.meshSource.meshTiles.values()):[]:this.tileLayers.reduce((e,t)=>{const i=t.getDisplayedTileObjects();return e.push(...i),e},[])}getReliefTileType(){return this.reliefTileType}getElevationSourceType(){return this.elevationSourceType}setReliefTileType(e){this.reliefTileType!==e&&(this.reliefTileType=e,this.enabled&&(this.dangerouslyDestroySourcesAndLayers(),this.elevationSourceType==="regular"?this.addRegularElevationSources():this.addIrregularElevationSources(),this.modules.renderer.addRerenderEvent()))}setElevationSourceType(e){this.elevationSourceType!==e&&(this.elevationSourceType=e,this.enabled&&(this.dangerouslyDestroySourcesAndLayers(),this.elevationSourceType==="regular"?this.addRegularElevationSources():this.addIrregularElevationSources(),this.modules.renderer.addRerenderEvent()))}getFlatMapTextures(){return this.flatMapSource?this.flatMapSource.textures.slice():[]}clearTextureBindings(){this.modules.renderer.disableTexture(0),this.modules.renderer.disableTexture(Yn),this.modules.renderer.disableTexture(An),this.modules.renderer.disableTexture(Qn),this.modules.renderer.disableTexture(Jn)}setMeshMaxZoom(e){this.meshMaxZoom=e,this.meshSource?.setMaxZoom(e)}getVerticalScale(){const e=this.modules.map.state,t=this.modules.styleManager.getStyle(e.handyStyleId);if(!t)return 0;const i=t.dem.style,o=n.makeBinderContext(e.styleZoom,e.styleState,[]);return this.disableAnimation?n.resolveNumber(i.verticalScale,o):n.resolveNumber(i.verticalScale,o)*this.terrainAnimationScaleCoef}getTilesRevision(){return this.tilesRevision}setTileSet(e){this.tileSet=e,this.enabled&&(this.disable(),this.enable())}getGroundPoint(e){if(!this.enabled||(this.updateGround(),!this.isGroundBufferValid))return;const t=this.modules.renderer.getFramebuffer(this.groundFramebufferId);if(!t)return;const i=t.renderTarget.options.size,o=e[0]-this.modules.map.state.viewport.left,a=e[1]-this.modules.map.state.viewport.top;if(o<0||o>i[0]-1||a<0||a>i[1]-1)return;const l=((i[1]-a-1)*i[0]+o)*4;if(this.groundBuffer[l+3]===0)return;const[d,_]=n.Mercator.toGeo([this.groundBuffer[l],this.groundBuffer[l+1]]);return[d,_,this.groundBuffer[l+2]]}startVerticalScaleAnimation(){const e=this.modules.map.state;this.modules.styleManager.getStyle(e.handyStyleId)&&(this.isAnimationStarted=!0,n.start("changeScale",{easing:"linear"},e,to,_a,D_,1))}dangerouslyDestroySourcesAndLayers(){this.sources.forEach(e=>e.destroy()),this.sources=[],this.sourcesRevision=[],this.meshSource?.destroy(),this.meshSource=void 0,this.tileLayers.forEach(e=>{this.modules.tileManager.removeTileLayer(e),e.destroy()}),this.tileLayers=[],this.hillshadeTile&&(this.modules.tileManager.removeObject(this.hillshadeTile),this.hillshadeTile=void 0)}updateRampTextureId(){const e=this.modules.styleManager.getStyle(this.modules.map.state.handyStyleId);if(e?.dem){const t=U_(this.modules.map.state,e.dem.style.shadingPalette,256);Number.isNaN(this.hillshadeRampTextureId)?this.hillshadeRampTextureId=this.modules.imageManager.addPreparedTexture(t):this.modules.imageManager.updatePreparedTexture(this.hillshadeRampTextureId,t)}}updateClearColor(){const e=this.modules.styleManager.getStyle(this.modules.map.state.handyStyleId);if(e?.dem){const t=this.modules.renderer.getFramebuffer(this.flatFramebufferId);t&&(t.clearColor=n.getColorForShaders(e.background.color))}}updateGround(){if(this.enabled&&!this.isGroundBufferValid){const e=this.modules.tileManager.getTileObjects();this.modules.renderer.renderGround(e);const t=this.modules.renderer.getFramebuffer(this.groundFramebufferId);if(!t)return;const i=t.renderTarget.options.size;this.validateGroundBufferSize(i),this.modules.renderer.bindRenderTarget(t.renderTarget),this.modules.renderer.readPixelsFloat(0,0,i[0],i[1],this.groundBuffer),this.modules.renderer.bindRenderTarget(null),this.isGroundBufferValid=!0}}addDefaultSources(){this.dangerouslyDestroySourcesAndLayers(),this.elevationSourceType==="irregular"?this.addIrregularElevationSources():this.addRegularElevationSources(),this.flatMapSource=new m_(this.modules.map)}addRegularElevationSources(){const e=this.modules.map.state,t=(r,l,c)=>n.DEM_TILE_URL_FUNCTION(e,r,l,c,this.tileSet==="dem"?"relief":this.tileSet),i=this.reliefTileType==="raster";i&&this.addElevationSource({url:t,minZoom:la,maxZoom:8,attributes:{}}),this.addElevationSource({url:t,minZoom:i?9:la,maxZoom:eo,attributes:{}}),this.meshSource=new u_(this.modules.map,{maxZoom:this.meshMaxZoom});const o=this.hillshadeVao,a=this.modules.renderer.symbolSettingsList.dem.hillshade?.[0];if(o&&a){this.hillshadeTile=new n.TileObject("raster",[],this.modules,this.modules.map.state);const r={id:n.uniqId(),type:n.SceneObjectType.Tile,symbol:"dem",sink:"hillshade",tile:this.hillshadeTile,attributes:{layerId:n.DEM_STYLE_LAYER_ID,styleId:this.modules.map.state.handyStyleId,tileData:[]},start:0,count:6,attributesHash:"",layerSettings:a,vao:o,canRender:!0,renderingProperties:{}};this.hillshadeTile.children.push(r),this.modules.tileManager.addObject(this.hillshadeTile)}}addIrregularElevationSources(){const{tileServer:e,tileProtocol:t,subdomains:i}=N_[this.tileSet]??this.modules.map.state;this.addIrregularElevationSource({tileServer:e,tileProtocol:t,subdomains:i,tileSet:this.tileSet,minZoom:ca,maxZoom:da})}updateTilesRevision(){let e=!1;return this.sources.forEach((t,i)=>{const o=t.getRevision();o!==this.sourcesRevision[i]&&(this.sourcesRevision[i]=o,e=!0)}),e&&this.tilesRevision++,e}addElevationSource(e){const t=new h_(n.sourceUuid(),this.modules,e);this.sources.push(t),this.sourcesRevision.push(t.getRevision());const{minZoom:i,maxZoom:o}=e,a=new n.TileLayer(i,o,i,o,this.modules,this.modules.map.state,t);this.modules.tileManager.addTileLayer(a),this.tileLayers.push(a)}addIrregularElevationSource(e){const t=new f_(n.sourceUuid(),this.modules,e);this.sources.push(t),this.sourcesRevision.push(t.getRevision());const{minZoom:i,maxZoom:o}=e,a=new n.TileLayer(i,o,i,o,this.modules,this.modules.map.state,t,{useExtendedTilesBounds:!0});this.modules.tileManager.addTileLayer(a),this.tileLayers.push(a)}getDemTextureSize(){const e=this.modules.map.state.cameraConfig,t=this.modules.map.state.size[1]*e.viewportLimitRatio;return Math.min(Math.ceil(Math.hypot(t,t)/n.tileSizeZpt),ut)}createGroundFramebuffer(){const e=this.modules.map.state.size,t=[0,0,0,0],i=new pe({size:e,magFilter:g.NearestFilter,minFilter:g.NearestFilter,wrapS:g.ClampToEdgeWrapping,wrapT:g.ClampToEdgeWrapping,flipY:!0,type:g.Float});return this.modules.renderer.bindRenderTarget(i),this.modules.renderer.clearWithColor(t,!0),this.modules.renderer.bindRenderTarget(null),this.modules.renderer.addFramebuffer({clearColor:t,useDem:!0,clearDepth:!0,onResize:()=>{const o=this.modules.map.state.size;i.setSize(o),this.modules.renderer.bindRenderTarget(i),this.modules.renderer.clearWithColor(t,!0),this.modules.renderer.bindRenderTarget(null)},renderTarget:i,renderIndex:5,onRenderStart:()=>{},onRenderEnd:()=>{}})}createDemFramebuffer(){let e=this.getDemTextureSize()*ut;const t=new pe({size:[e,e],magFilter:g.LinearFilter,minFilter:g.LinearFilter,wrapS:g.ClampToEdgeWrapping,wrapT:g.ClampToEdgeWrapping,flipY:!0,type:g.Float,format:g.RgbaFormat}),i=[0,0,0,0];return this.modules.renderer.bindRenderTarget(t),this.modules.renderer.clearWithColor(i),this.modules.renderer.bindRenderTarget(null),this.modules.renderer.addFramebuffer({clearColor:i,onResize:()=>{const o=this.getDemTextureSize()*ut;o!==e&&(e=o,t.setSize([e,e]),this.modules.renderer.bindRenderTarget(t),this.modules.renderer.clearWithColor(i),this.modules.renderer.bindRenderTarget(null))},renderTarget:t,getViewProjectionMatrix:()=>this.demFbVpMatrix,renderIndex:0,onRenderStart:()=>{this.clearTextureBindings()},onRenderEnd:()=>{this.isDemCorrectionEnabled=!1}})}createCorrectedDemFramebuffer(){const e=this.modules.renderer;let t=this.getDemTextureSize()*ut;const i=new pe({size:[t,t],magFilter:g.LinearFilter,minFilter:g.LinearFilter,wrapS:g.ClampToEdgeWrapping,wrapT:g.ClampToEdgeWrapping,flipY:!0,type:g.Float});return e.bindRenderTarget(i),e.clearWithColor([0,0,0,1]),e.bindRenderTarget(null),this.modules.renderer.addFramebuffer({onResize:()=>{const o=this.getDemTextureSize()*ut;o!==t&&(t=o,i.setSize([t,t]),this.modules.renderer.bindRenderTarget(i),this.modules.renderer.clearWithColor([0,0,0,1]),this.modules.renderer.bindRenderTarget(null))},renderTarget:i,getViewProjectionMatrix:()=>this.demCorrectedFbVpMatrix,renderIndex:1,onRenderStart:()=>{const o=this.modules.renderer.getFramebuffer(this.demFramebufferId)?.renderTarget.getTexture();if(!o||!this.copyDemVao)return;this.clearTextureBindings(),this.modules.renderer.bindRenderTarget(i),this.modules.renderer.setViewport(0,0,i.options.size[0],i.options.size[1]),this.modules.renderer.applyGpuState(ta);const a=0;this.modules.renderer.enableTexture(o,a);const r=this.modules.renderer.getShaderProgram("demElevationCopy");this.modules.renderer.enableShaderProgram(r),this.modules.renderer.bindShaderProgram(r,{u_mat4_mvp:n.TEXTURE_COORDS_TO_WEBGL,u_sr2d_texture:a,u_mat4_dem_corrected:this.correctedTexToDemTex}),this.modules.renderer.bindVao(this.copyDemVao),this.modules.renderer.drawTriangles(0,6),this.modules.renderer.bindRenderTarget(null),this.isDemCorrectionEnabled=!0},useDem:!0})}createHillshadeFramebuffer(){let e=this.getDemTextureSize()*ut;const t=new pe({size:[e,e],magFilter:g.LinearFilter,minFilter:g.LinearFilter,wrapS:g.ClampToEdgeWrapping,wrapT:g.ClampToEdgeWrapping,format:g.RgbFormat,flipY:!0});return this.modules.renderer.addFramebuffer({clearColor:[0,0,0,0],onResize:()=>{const i=this.getDemTextureSize()*ut;i!==e&&(e=i,t.setSize([e,e]),this.modules.renderer.bindRenderTarget(t),this.modules.renderer.bindRenderTarget(null))},renderTarget:t,getViewProjectionMatrix:()=>this.demFbVpMatrix,renderIndex:2,onRenderStart:()=>{this.clearTextureBindings()},useDem:!0})}createFlatFramebuffer(){const e=this.modules.renderer.getPixelRatio(),t=this.modules.map.state.size,i=new pe({size:[Math.trunc(t[0]*Te[0]*e),Math.trunc(t[1]*Te[1]*e)],magFilter:g.LinearFilter,minFilter:g.LinearFilter,wrapS:g.ClampToEdgeWrapping,wrapT:g.ClampToEdgeWrapping});return this.modules.renderer.addFramebuffer({clearColor:this.modules.renderer.clearColor,onResize:()=>{const o=this.modules.map.state.size;i.setSize([Math.trunc(o[0]*Te[0]*e),Math.trunc(o[1]*Te[1]*e)]),this.modules.renderer.bindRenderTarget(i),this.modules.renderer.bindRenderTarget(null)},renderTarget:i,renderIndex:3,onRenderStart:()=>{this.modules.renderer.disableTexture(0)}})}createFlatIdentifyFramebuffer(){const e=this.modules.map.state.size,t=new pe({size:[Math.trunc(e[0]*Te[0]*n.identify.pixelDensity),Math.trunc(e[1]*Te[1]*n.identify.pixelDensity)],magFilter:g.NearestFilter,minFilter:g.NearestFilter,wrapS:g.ClampToEdgeWrapping,wrapT:g.ClampToEdgeWrapping});return this.modules.renderer.addFramebuffer({clearColor:Mt,onResize:()=>{const i=this.modules.map.state.size;t.setSize([Math.trunc(i[0]*Te[0]*n.identify.pixelDensity),Math.trunc(i[1]*Te[1]*n.identify.pixelDensity)]),this.modules.renderer.bindRenderTarget(t),this.modules.renderer.bindRenderTarget(null)},renderTarget:t,renderIndex:4,onRenderStart:()=>{this.modules.renderer.disableTexture(0)}})}updateDemFramebufferMatrix(){const e=this.modules.map.state,t=Math.trunc(e.styleZoom),i=Math.min(t,this.getReliefTileType()==="raster"?B_:P_),o=n.tileZoomToSize(i),a=o*this.getDemTextureSize(),r=o/ut,l=[Math.trunc(e.center[0]/r)*r+r/2,Math.trunc(e.center[1]/r)*r+r/2],c=[l[0]-a/2,l[1]-a/2,0],d=[];n.sub(d,this.modules.camera.position,e.center);const _=n.len(d);n.normalize$1(d,d);const u=Math.max(a/2-_-r-O_/2,0),h=Math.min(u,(a/2-_-r)*Math.sin(e.pitch/e.maxPitch*(Math.PI/2)));h>0&&(n.scale$2(d,d,h),d[0]=Math.trunc(d[0]/r)*r,d[1]=Math.trunc(d[1]/r)*r,n.sub(c,c,d)),n.fromTranslationScale(Ie,c,[a,a,n.tileHeight]),n.invert(this.demTextureMatrix,Ie),n.multiply(this.demFbVpMatrix,n.TEXTURE_COORDS_TO_WEBGL,this.demTextureMatrix);const f=Math.min(t,z_);this.demCorrectedScale=2**(f-i);const p=n.tileZoomToSize(f)*this.getDemTextureSize(),v=[l[0]-p/2,l[1]-p/2,0];n.fromTranslationScale(Ie,v,[p,p,n.tileHeight]),n.invert(Ie,Ie),n.multiply(this.demCorrectedFbVpMatrix,n.TEXTURE_COORDS_TO_WEBGL,Ie),n.fromScaling(Ie,[1/this.demCorrectedScale,1/this.demCorrectedScale,1]),n.multiply(this.demCorrectedFbVpToDemTex,n.WEBGL_COORDS_TO_TEXTURE,Ie),n.fromScaling(Ie,[1/this.demCorrectedScale,1/this.demCorrectedScale,1]),n.multiply(Ie,Ie,n.TEXTURE_COORDS_TO_WEBGL),n.multiply(this.correctedTexToDemTex,n.WEBGL_COORDS_TO_TEXTURE,Ie),n.fromScaling(Ie,[this.demCorrectedScale,this.demCorrectedScale,1]),n.multiply(Ie,Ie,n.TEXTURE_COORDS_TO_WEBGL),n.multiply(this.demTexToCorrectedTex,n.WEBGL_COORDS_TO_TEXTURE,Ie)}validateGroundBufferSize(e){const t=e[0]*e[1]*4;this.groundBuffer.length!==t&&(this.groundBuffer=new Float32Array(t))}}function U_(s,e,t){const i=n.makeBinderContext(s.styleZoom,s.styleState,[]),o=[],a=t-1;for(let r=0;r<t;r++){const l=r/a,c=n.sample(e,l,i)*256;o.push(c)}return new g(new Uint8Array(o),{size:[t,1],format:g.AlphaFormat,magFilter:g.LinearFilter,minFilter:g.LinearFilter,wrapS:g.ClampToEdgeWrapping,wrapT:g.ClampToEdgeWrapping})}const ua=new Float32Array(16),ht=(s,e,t,i)=>{t=so(t,s,e),t.length>0&&s.metrics.firstcontent===void 0&&(s.metrics.firstcontent=performance.now()-s.metrics.start),ma(t,i),s.globeMode&&s.globeReady?G_(s,e,t,i):io(s,e,t,i)},G_=(s,e,t,i)=>{const o=[],{environmentManager:a}=e,r=e.styleManager.getStyle(s.handyStyleId);if(!r||!r.environment)return;const c=n.makeBinderContext(s.styleZoom,s.styleState,[]),d=n.getColorForShaders(n.resolveColor(r.background.color,c));a.renderStars(),a.renderGlobeHaloBackground(),X_(t).forEach(_=>{if(!_.globeTile){oo(_.children,s,e).forEach(u=>o.push(u));return}i.useGlobeTile(_.globeTile),e.renderer.clearWithColor(d),_.children.forEach(u=>{if(u.type===n.SceneObjectType.Custom||!_.globeTile)return;const h=_.globeTile.coords,f=u.tile.coords,p=2**(f[2]-h[2]),v=(f[0]-h[0]*p)/p,y=(f[1]-h[1]*p)/p,b=1/p,x=1-b-2;n.fromTranslationScale(ua,[2*v+x,2*y+x,0],[4*b,4*b,1]),u.tile.setMvpMatrix(ua)}),oo(_.children,s,e).forEach(u=>Ui(s,e,u,i)),i.useCanvas(),Ui(s,e,_.globeTile.children,i)}),a.renderGlobeHalo(),o.forEach(_=>{Ui(s,e,_,i)})},io=(s,e,t,i)=>{oo(t,s,e).forEach(o=>Ui(s,e,o,i))},Ui=(s,e,t,i)=>{Q_(e.styleManager,t,s,e).forEach(o=>{fa(e.styleManager,o[0])?H_(s,e,o,i):ha(s,e,o,i)})},H_=(s,e,t,i)=>{const o=fa(e.styleManager,t[0]);if(!o)return;const a=(r,l)=>{l>=o.orderBy.length?ha(s,e,r,i):A_(o.orderBy[l],r,s,e).forEach(c=>a(c,l+1))};a(t,0)},ha=(s,e,t,i)=>{t.sort((o,a)=>o.tile.zoomLevel-a.tile.zoomLevel),Y_(e.styleManager,t,s,e).forEach(o=>V_(s,e,o,i))},V_=(s,e,t,i)=>{J_(t,s,e).forEach(o=>j_(s,e,o,i))},j_=(s,e,t,i)=>{const o=t[0],a=ou(e.styleManager,o);if(!a||a?.style?.visibility==="hidden")return;const r=a.selectedIdx;r!==void 0&&t.sort((l,c)=>{const d=Number(l.attributes.tileData[r]??0),_=Number(c.attributes.tileData[r]??0);return d-_}),o.type===n.SceneObjectType.Custom?(i.useCustomLayerState(a),e.styleManager.callCustomLayerRender(o.attributes.layerId)):eu(t,s,e).forEach(l=>Z_(s,e,l,i,a))},Z_=(s,e,t,i,o)=>{i.useProgram(t[0],o),tu(t,s,e).forEach(a=>{W_(s,e,a,i,o)})},W_=(s,e,t,i,o)=>{i.useState(t[0],o),iu(t,s,e).forEach(a=>{i.drawSymbol(a,o,s,e)})};function fa(s,e){const t=s.getStyle(e.attributes.styleId);if(!t)return;const i=t.layersById[e.attributes.layerId];if(!i||i.groupId===void 0)return;const o=t.groupsById[i.groupId];if(o&&o.type!=="group"){n.log(`Expecting layer with type 'group' but got '${o.type}'`);return}return o}const $_=(s,e)=>Number(s)-Number(e),Ft=s=>(e,t,i)=>{const o={};for(let l=0;l<e.length;l++){const c=e[l],d=s(c,t,i),_=o[d];_===void 0?o[d]=[c]:_.push(c)}const a=Object.keys(o);a.sort($_);const r=[];for(let l=0;l<a.length;l++)r.push(o[a[l]]);return r},no=s=>(e,t,i)=>{const o=new Map;for(let a=0;a<e.length;a++){const r=e[a],l=s(r,t,i);o.has(l)?o.get(l).push(r):o.set(l,[r])}return o},X_=s=>{const e=[],t={globeTile:null,children:[]},i=[];for(const o of s)o.type!==n.SceneObjectType.Custom&&(o.tile.purpose==="globe"?i.push({globeTile:o.tile,children:[]}):e.push(o));for(const o of e)if(o.layerSettings.is3dMapAware)t.children.push(o);else for(const a of i)a.globeTile&&n.isTilesIntersects(a.globeTile.coords,o.tile.coords)&&a.children.push(o);return i.push(t),i},oo=Ft(s=>{const{styleId:e}=s.attributes;return e===n.DYNAMIC_STYLE_ID?1:-e}),K_=(s,e,t)=>{const i=s.getStyle(e);if(!i)return n.log(`Cannot get style with id=${e} for renderIndex`),NaN;const o=i.layersById[t];return o?o.renderIndex:NaN},q_=(s,e,t)=>{const i=s.getStyle(e);if(!i)return n.log(`Cannot get style with id=${e} for renderIndex`),NaN;const o=i.layersById[t];return o?o.groupIndex||0:NaN},Y_=(s,e,t,i)=>Ft(o=>q_(s,o.attributes.styleId,o.attributes.layerId))(e,t,i),Q_=(s,e,t,i)=>Ft(o=>K_(s,o.attributes.styleId,o.attributes.layerId))(e,t,i),J_=Ft(s=>s.type===n.SceneObjectType.Custom?0:s.layerSettings.subRenderIndex||0),ma=(s,e)=>{const t=new Set;s.forEach(i=>{if(i.type===n.SceneObjectType.Custom)return;const o=i.layerSettings.programName;t.has(i.layerSettings.programName)||(t.add(o),e.setProgramBinder(i))})},A_=(s,e,t,i)=>Ft((o,a)=>{const r=n.makeBinderContext(a.styleZoom,a.styleState,o.attributes.tileData);return n.resolveNumber(s,r,0)})(e,t,i),eu=no(s=>s.shaderDefinitions?.hash?s.layerSettings.programName+"_"+s.shaderDefinitions.hash:s.layerSettings.programName),tu=no(s=>s.layerSettings.stateBinder),iu=no(s=>s.sink+"_"+s.attributesHash+"_"+s.tile.readiness),nu=Ft(s=>s.tile.zoomLevel);function ou(s,e){const t=s.getStyle(e.attributes.styleId);if(t)return t.layersById[e.attributes.layerId]}function so(s,e,t){for(const i of s)i.type!==n.SceneObjectType.Custom&&(i.canRender=su(i,t,e));return s.filter(i=>i.canRender)}function su(s,e,t){if(!s.layerSettings.cullMethod)return!0;const i=e.styleManager.getStyleLayerForObject(s);return!(!i||i?.style?.visibility==="hidden"||!s.layerSettings.cullMethod(s,e,t,i))}const pa=[0,0,0,0],st=(s,e,t,i,o,a)=>{const r={terrain3d:!!o,noEffects:!!a,drawSymbol:(l,c,d,_)=>{const u=l[0];if(u)if(au(u)&&(c.type==="overpass"||c.type==="tunnel"||c.type==="gltfModel")&&!u.layerSettings.shadow){let h;c.type==="gltfModel"&&(h=pa),r.renderTierTexture(u,c,!1,h),r.useProgram(u,c),r.useState(u),ao(l,c,d,_,r),d.hiddenImmersiveRoutesEnabled&&!u.layerSettings.identify&&c.type!=="gltfModel"&&(r.renderTierTexture(u,c,!0),r.useProgram(u,c),_.renderer.applyGpuState(p_,c),ao(l,c,d,_,r))}else ao(l,c,d,_,r)},useProgram:(l,c)=>{const{layerBinder:d,programName:_,programBinder:u,commonBinder:h}=l.layerSettings,f=e.renderer.getShaderProgram(_,l.shaderDefinitions);e.renderer.enableShaderProgram(f),h&&!e.renderer.isUboSupported()&&h(f,s,e),u?.(f,s,e,o,a),d?.(f,s,e,c,a)},setProgramBinder:l=>{const c=l.layerSettings.programBinder,d=e.renderer.isUboSupported()?void 0:l.layerSettings.commonBinder;if(l.layerSettings.programBinder||d){const _=e.renderer.getShaderProgram(l.layerSettings.programName,l.shaderDefinitions);e.renderer.enableShaderProgram(_),d?.(_,s,e),c?.(_,s,e,o,a)}},useState:(l,c)=>{e.renderer.applyGpuState(l.layerSettings.stateBinder,c)},useCustomLayerState:l=>{e.renderer.applyGpuState(S_,l)},useGlobeTile:l=>{const c=e.renderer.getGlobeRenderTarget(n.globeTileScale(s.zoom,l));c&&e.renderer.setRenderTarget(c)},useCanvas:()=>{e.renderer.setRenderTarget(i)},renderTierTexture:(l,c,d,_)=>{const{viewport:u,size:h}=s,f=window.devicePixelRatio,m=!!l.layerSettings.identify,p=m?e.renderer.getMapMeshIdFramebufferId():e.renderer.getMapMeshFramebufferId(),v=e.renderer.getFramebuffer(p);if(!v)return;const y=st(s,e,void 0,i,!1,!0);if(e.renderer.disableTexture(0),e.renderer.bindRenderTarget(v.renderTarget),e.renderer.setViewport(0,0,v.renderTarget.options.size[0],v.renderTarget.options.size[1]),d){const T=m?Mt:pa;e.renderer.clearWithColor(T,!0,-1)}else if(m)e.renderer.clearWithColor(Mt,!0);else{const T=n.makeBinderContext(s.styleZoom,s.styleState,l.attributes.tileData),w=_??n.resolveColor(c.style.color,T).value;e.renderer.clearWithColor([w[0]/255,w[1]/255,w[2]/255,w[3]/255],!0)}const b=l.attributes.meshTier,x=t?.[b];if(x){x.tileObjects.forEach(M=>{M.updateMvpMatrix(v.getViewProjectionMatrix?.()??e.camera.viewProjectionMatrix,void 0)});const T=d?x.objects.filter(M=>{if(M.type!==n.SceneObjectType.Custom){if(M.layerSettings.stateBinder(e).depthTest&&!M.layerSettings.isOverlappedObject)return!0;const z=e.styleManager.getStyleLayer(M.attributes.styleId,M.attributes.layerId);if(z)return z.gpuState?.depthTest===!0}return!1}):x.objects,w=so(T,s,e);io(s,e,w,y),x.tileObjects.forEach(M=>M.updateMvpMatrix(e.camera.viewProjectionMatrix)),ma(x.objects,r)}i?(e.renderer.bindRenderTarget(i),e.renderer.setViewport(0,0,i.options.size[0],i.options.size[1])):(e.renderer.bindRenderTarget(null),e.renderer.setViewport(u.left*f,u.bottom*f,h[0]*f,h[1]*f))},copy:(l,c,d)=>st(s,e,t,l,c,d)};return r},ao=(s,e,t,i,o)=>{const a=s[0],r=a.layerSettings,l=i.renderer.getShaderProgram(r.programName,a.shaderDefinitions);r.objectBinder(l,t,i,a,e,o.terrain3d),a.layerSettings.zoomBinder?nu(s,t,i).forEach(c=>{l&&a.layerSettings.zoomBinder?.(l,t,i,c[0],e,o.terrain3d),c.forEach(d=>va(d,i,l,t,o,e))}):s.forEach(c=>va(c,i,l,t,o,e))},va=(s,e,t,i,o,a)=>{const{renderer:r}=e,l=s.tile;for(const c of l.modelMatrices.keys()){if(l.renderModelMatrix=l.modelMatrices.get(c),l.renderMvpMatrix=l.mvpMatrices.get(c),l.renderDemMatrix=l.demMatrices.get(c),l.renderFlatMapTexMatrix=l.flatMapTexMatrices.get(c),!s.layerSettings.tileBinder(t,i,e,s,a,o))continue;r.bindVao(s.vao);const{start:_,count:u,instanceCount:h}=s,f=s.drawMode??n.GL_TRIANGLES,m=s.vao.getElementsGLType();if(m!==null?h?r.drawInstancedElements(f,u,m,_,h):r.drawElements(f,u,m,_):h?r.drawInstancedArrays(f,_,u,h):r.drawArrays(f,_,u),i.collectStats){i.stats.drawCount++,i.stats.vertexCount+=(h??1)*u,i.stats.drawCountBySymbol[s.symbol]?i.stats.drawCountBySymbol[s.symbol]++:i.stats.drawCountBySymbol[s.symbol]=1;const p=r.triangleCountByDrawMode(f,u);i.stats.triangleCount+=(h??1)*p}}};function au(s){return s.symbol==="mapMesh"||s.symbol==="gltfModel"&&s.attributes.meshTier!==void 0}const ga=n.create$1(),ru=n.create$1(),ya=n.create$2(),ro=n.create$1(),lu=n.fromValues(0,0,1),cu=n.create$1(),du=.3,_u=1/2e7,uu=.01,hu=[1,1,1,1],ba=n.reserveTextureIndex();class fu{constructor(e,t){this.clipToShadowMatrix=new Float32Array(16),this.baseBias=n.defaultShadowsSettings.bias,this.bias=0,this.shadowMapParams=new Float32Array([n.defaultShadowsSettings.textureSize[0],n.defaultShadowsSettings.textureSize[1],n.defaultShadowsSettings.shadowRadius,1]),this.volumeMultiplier=2.5,this.volumeMinSize=25e3,this.discreteVolume=!1,this.volumeSizeStep=2**15,this.adaptiveVerticalSize=!0,this.debugDraw=!1,this.shadowMatrix=new Float64Array(16),this.orthoMath=new Float64Array(16),this.renderTarget=null,this.copyProgram=null,this.debugVao=null,this.debugSize=400,this.shadowLightDir=null,this.modules=t,this.mapState=e}get texture(){if(!this.renderTarget)return null;const e=this.renderTarget.getDepthAttachment();return e instanceof g?e:this.renderTarget.getTexture()}setShadowResolution(e,t){this.shadowMapParams[0]=e,this.shadowMapParams[1]=t,this.renderTarget&&this.renderTarget.setSize([e,t])}update(){if(Bt())return;this.shadowLightDir=null;const{handyStyleId:e}=this.mapState,t=this.modules.styleManager.getStyle(e),i=this.modules.map.state.demMode;if(!t||!t.light.lightingModesResolved||i){this.renderTarget&&this.renderTarget.remove();return}const o=t.light.lightingModesResolved;for(const S in o){const I=o[S];if(I.shadowLightIndex===0){this.shadowLightDir=I.dir1Direction,this.shadowMapParams[2]=I.shadowRadius;break}else if(I.shadowLightIndex===1){this.shadowLightDir=I.dir2Direction,this.shadowMapParams[2]=I.shadowRadius;break}}const a=this.shadowLightDir&&!this.modules.map.getFeatureFlag("shadowsOff");if(a?this.renderTarget||(this.renderTarget=this.createRenderTarget()):this.renderTarget&&this.renderTarget.remove(),!a||!this.shadowLightDir||!this.renderTarget||this.modules.renderCacheManager.hasReadyCache())return;const r=this.modules.map.state.center,l=this.modules.camera.position[2];let c=Math.max(this.volumeMultiplier*l);this.discreteVolume&&(c=c-c%this.volumeSizeStep),c=Math.max(c,this.volumeMinSize);let d=this.baseBias;this.modules.renderer.isShadowSamplerSupported()&&(d*=.5),this.shadowMapParams[3]=d/c,this.bias=d*_u*Math.sqrt(c),this.bias=Math.min(this.bias,uu);let _=1;if(this.adaptiveVerticalSize){const S=Math.abs(n.dot(this.shadowLightDir,lu));_=Math.max(S,du)}const u=c,h=_*c,f=3*c;n.ortho(this.orthoMath,-u,u,-h,h,-f,f);const m=n.fromValues(this.shadowLightDir[1],-this.shadowLightDir[0],0);n.normalize(m,m),n.cross(ro,m,this.shadowLightDir);const p=ya;n.lookAt(p,cu,this.shadowLightDir,ro);const v=n.transformMat4$1(ga,r,p),y=2*u/this.shadowMapParams[0],b=2*h/this.shadowMapParams[1],x=n.fromValues(v[0]-v[0]%y,v[1]-v[1]%b,v[2]),T=n.invert(p,p),w=n.transformMat4$1(ru,x,T??n.identity(ya)),M=n.add$1(ga,w,this.shadowLightDir);n.lookAt(this.shadowMatrix,w,M,ro),n.multiply(this.shadowMatrix,this.orthoMath,this.shadowMatrix);const z=this.modules.camera.viewProjectionMatrixInverse;n.multiply(this.clipToShadowMatrix,this.shadowMatrix,z)}drawShadowMap(e){if(!this.shadowLightDir||!this.renderTarget||this.modules.renderCacheManager.hasReadyCache())return;const t=this.modules.map.state.demMode,i=st(this.mapState,this.modules,void 0,this.renderTarget,t),o=new Set,a=[];for(const l of e)for(const c of l.shadowChildren){const d=this.modules.styleManager.getStyleLayerForObject(c);if(!d||d.castShadows===!1)continue;const _=Ns(d,this.modules,this.mapState);!_||_.lightConfig.shadowLightIndex===-1||(a.push(c),o.add(l))}const r=t?this.modules.demManager.demTextureMatrix:void 0;o.forEach(l=>{l.updateMvpMatrix(this.shadowMatrix,r)}),this.modules.renderer.bindRenderTarget(this.renderTarget),this.modules.renderer.applyGpuState(aa),this.modules.renderer.clearWithColor(hu,!0),this.modules.renderer.setViewport(0,0,this.renderTarget.options.size[0],this.renderTarget.options.size[1]),ht(this.mapState,this.modules,a,i),this.modules.renderer.bindRenderTarget(null)}drawDebugFbIfNeeded(){if(!this.debugDraw){this.copyProgram&&(this.copyProgram=null),this.debugVao&&(this.debugVao.remove(),this.debugVao=null);return}if(!this.texture)return;if((!this.copyProgram||!this.debugVao)&&(this.copyProgram||(this.copyProgram=this.createDebugProgram()),!this.debugVao)){const o=this.modules.renderer.createBuffer(new Uint8Array([-1,-1,1,-1,1,1,-1,1]));this.debugVao=ni(o,this.copyProgram)}const e=this.mapState.viewport,t=this.modules.renderer.getViewportSize(),i=this.debugSize;this.modules.renderer.bindRenderTarget(null),this.modules.renderer.setViewport(t[0]+e.left-i,e.bottom,i,i),this.modules.renderer.applyGpuState(_t),this.modules.renderer.enableShaderProgram(this.copyProgram),this.modules.renderer.bindShaderProgram(this.copyProgram,{u_texture:1}),this.modules.renderer.enableTexture(this.texture,1),this.modules.renderer.bindVao(this.debugVao),this.modules.renderer.drawTrianglesFan(0,4)}getMemoryFootprint(){const e={renderTarget:this.renderTarget?.memSizeGPU()??0};return{gpu:{...e,"--sum":n.getTotalMemory(e)}}}createRenderTarget(){const e=[this.shadowMapParams[0],this.shadowMapParams[1]];return this.modules.renderer.isDepthTextureSupported()?new pe({size:e,magFilter:g.LinearFilter,minFilter:g.LinearFilter,depthTexture:!0,hasColorOutput:!1,compareFunc:g.CompareRefToTexture}):new pe({size:e,magFilter:g.NearestFilter,minFilter:g.NearestFilter,wrapS:g.ClampToEdgeWrapping,wrapT:g.ClampToEdgeWrapping,flipY:!1,type:g.UnsignedByte,useHighDepthPrecision:!0})}createDebugProgram(){const e=[];this.modules.renderer.isDepthTextureSupported()&&e.push({type:"IS_DEPTH_TEXTURE"});const t=n.Shader.createShaderDefinitions(e);return this.modules.renderer.getShaderProgram("copy",t)}}class xa{constructor(e,t,i){this.output=e,this.input=t,this.modules=i,this.enabled=!0}}class mu extends xa{constructor(e,t,i,o){super(e,t,i),this.name=Dt.TAA,this.jitter=[0,0],this.numMixedFrames=0,this.samples=16,this.vao=null,this.buffer=o,this.jitterSequence=this.generateJitterSequence(this.samples)}onBeforeRender(e){if(this.jitter[0]=0,this.jitter[1]=0,e.aaMode!==Ot.TAA||e.globeMode||!this.canRender()){this.enabled=!1,this.numMixedFrames=0;return}if(this.numMixedFrames>=this.samples)return;this.modules.renderer.addRerenderEvent(),this.enabled=!0;const t=window.devicePixelRatio,i=e.size,o=this.jitterSequence[this.numMixedFrames];this.jitter[0]=o[0]/Math.ceil(i[0]*t),this.jitter[1]=o[1]/Math.ceil(i[1]*t)}render(){const e=1/(this.numMixedFrames+1),t=this.modules.renderer.getShaderProgram("taa");this.vao||(this.vao=ni(this.buffer,t)),this.modules.renderer.bindRenderTarget(this.output),this.modules.renderer.bindVao(this.vao);const i=this.input?.getTexture();i&&this.modules.renderer.enableTexture(i,0),this.modules.renderer.enableShaderProgram(t),this.modules.renderer.bindShaderProgram(t,{u_texture:0,u_float_mix_coef:e}),this.modules.renderer.drawTrianglesFan(0,4),this.numMixedFrames++}onAfterRender(){}resize(e){this.output.setSize(e),this.numMixedFrames=0}isReady(e){return e?.ignoreLayerAnimation&&this.modules.map.core.hasActiveLayerAnimation()?!0:this.numMixedFrames>=this.samples}canRender(){return!this.modules.renderer.isNeedRerender()}generateJitterSequence(e){const t=[],i=n.generateHaltonSequence(e),o=i.base2,a=i.base3;t.push([0,0]);for(let r=0;r<o.length;++r)t.push([2*o[r]-1,2*a[r]-1]);return t}}class pu extends xa{constructor(e,t,i,o){super(e,t,i),this.name=Dt.FXAA,this.vao=null,this.buffer=o}onBeforeRender(e){this.enabled=e.aaMode===Ot.FXAA&&e.stillness>0}render(){const e=this.input?.getTexture();if(e)this.modules.renderer.enableTexture(e,0);else throw new Error("FXAA: input texture is not available");const t=this.modules.renderer.getShaderProgram("fxaa");if(this.vao||(this.vao=ni(this.buffer,t)),this.modules.renderer.bindRenderTarget(this.output),this.modules.renderer.bindVao(this.vao),this.modules.renderer.enableShaderProgram(t),this.modules.renderer.bindShaderProgram(t,{u_texture:0}),!this.modules.renderer.isUboSupported()){const i=this.modules.map.state;se(t,i,this.modules)}this.modules.renderer.drawTrianglesFan(0,4)}onAfterRender(){}resize(e){this.output.setSize(e)}isReady(){return!0}}var Dt=(s=>(s.TAA="TAA",s.FXAA="FXAA",s))(Dt||{}),Ot=(s=>(s[s.TAA=0]="TAA",s[s.FXAA=1]="FXAA",s))(Ot||{});class vu{constructor(e,t){this.renderGraph=[],this.effectsByType={},this.copyColorVao=null,this.copyColorDepthVao=null,this.copyColorProgram=null,this.copyColorDepthProgram=null,this.state=e,this.modules=t,this.renderTargetSize=this.modules.renderer.getViewportSize();const i=t.renderer.webglContextState.MAX_TEXTURE_SIZE;if(Math.max(...this.renderTargetSize)>i){n.log(`Disabling post-effects as viewport size ${this.renderTargetSize[0]}x${this.renderTargetSize[1]} exceeds hardware limits of ${i}x${i}`);return}const a=this.modules.renderer.createBuffer(new Uint8Array([-1,-1,1,-1,1,1,-1,1]));this.copyColorProgram=this.modules.renderer.getShaderProgram("copy"),this.copyColorDepthProgram=this.modules.renderer.getShaderProgram("copy",n.Shader.createShaderDefinitions([{type:"COPY_DEPTH",value:"1"},...!this.modules.renderer.isWebgl2Context()&&this.modules.renderer.fragDepthSupported()?[{type:"HAS_FRAG_DEPTH_EXT"}]:[]])),this.copyColorVao=ni(a,this.copyColorProgram),this.copyColorDepthVao=ni(a,this.copyColorDepthProgram);const r=this.createRenderTarget(this.renderTargetSize,{useHighDepthPrecision:!0});this.mainFrameBufferWrapper={renderTarget:r,onResize:()=>{},clearColor:n.getColorForShaders(e.defaultBackgroundColor),clearDepth:!0};const l=e.aaMode===0,c=e.aaMode===1,d=l?mu:c?pu:null;if(d){const _=this.createRenderTarget(this.renderTargetSize),u=new d(_,r,t,a);this.effectsByType[l?"TAA":"FXAA"]=u,this.renderGraph.push(u)}}update(){this.renderGraph.forEach(e=>e.onBeforeRender(this.state))}render(){this.modules.renderer.applyGpuState(T_),this.renderGraph.forEach(t=>t.render());const e=this.renderGraph[this.renderGraph.length-1].output;this.copyRenderTargetToCanvas(e),this.renderGraph.forEach(t=>t.onAfterRender(this.state))}invalidateSize(){this.mainFrameBufferWrapper&&(this.renderTargetSize=this.modules.renderer.getViewportSize(),this.mainFrameBufferWrapper.renderTarget.setSize(this.renderTargetSize),this.renderGraph.forEach(e=>e.resize(this.renderTargetSize)))}getEffectByName(e){return this.effectsByType[e]}setClearColor(e){this.mainFrameBufferWrapper&&(this.mainFrameBufferWrapper.clearColor=n.getColorForShaders(e))}hasActiveEffects(){if(!this.modules.postEffectsManager.mainFrameBufferWrapper)return!1;for(const e of this.renderGraph)if(e.enabled)return!0;return!1}isReady(e=!1){for(const t of this.renderGraph)if(!t.isReady({ignoreLayerAnimation:e}))return!1;return!0}getMemoryFootprint(){const e={mainFrameBufferWrapper:{renderTarget:this.mainFrameBufferWrapper?.renderTarget.memSizeGPU()??0}};return{gpu:{...e,"--sum":n.getTotalMemory(e)}}}copyRenderTargetToCanvas(e,t=!1,i=!0){if(!this.copyColorVao||!this.copyColorProgram||!this.copyColorDepthVao||!this.copyColorDepthProgram){n.log("PostEffectsManager: copyRenderTargetToCanvas called without vao or copyProgram");return}const{viewport:o}=this.state,a=window.devicePixelRatio,r=this.modules.renderer.getViewportSize();this.modules.renderer.bindRenderTarget(null),this.modules.renderer.setViewport(o.left*a,o.bottom*a,r[0],r[1]),i&&this.modules.renderer.clear(!1);const l=t?this.copyColorDepthProgram:this.copyColorProgram,c=t?this.copyColorDepthVao:this.copyColorVao;this.modules.renderer.bindVao(c);const d=e.getTexture();if(d&&this.modules.renderer.enableTexture(d,0),this.modules.renderer.enableShaderProgram(l),this.modules.renderer.bindShaderProgram(l,{u_texture:0}),t){const _=e.getDepthAttachment();_ instanceof g&&(this.modules.renderer.enableTexture(_,1),this.modules.renderer.bindShaderProgram(l,{u_depth:1}))}this.modules.renderer.drawTrianglesFan(0,4),this.modules.renderer.disableTexture(0),this.modules.renderer.disableTexture(1)}createRenderTarget(e,t){return new pe(Object.assign({minFilter:g.NearestFilter,magFilter:g.NearestFilter,size:e},t))}}const gu=[0,0];function _e(...s){return(e,t,i,o,a)=>{s.forEach(r=>r(e,t,i,o,a))}}const ee=(s,e,t,i)=>{if(!i){wa(s,e,t);return}const o=t.renderer.getFramebuffer(t.demManager.getDemFramebufferId())?.renderTarget.getTexture(),a=t.renderer.getFramebuffer(t.demManager.getCorrectedDemFramebufferId())?.renderTarget.getTexture(),r=t.imageManager.getTexture(t.demManager.getHillshadeRampTextureId()),l=o?.options.size,c=t.styleManager.getStyle(e.handyStyleId);if(!o||!a||!r||!c||!l){wa(s,e,t);return}const d=n.makeBinderContext(e.styleZoom,e.styleState,[],!1),_=n.clamp(n.resolveNumber(c.dem.style.shadingIntensity,d),0,1),u=t.demManager.getElevationSourceType(),h=n.EARTH_CIRCUMFERENCE/(Math.pow(2,Math.min(Math.trunc(e.styleZoom),u==="regular"?eo:da))*ut);t.renderer.enableTexture(o,Yn),t.renderer.enableTexture(r,Jn),t.renderer.enableTexture(a,An);const f=t.demManager.demCorrectedScale;t.renderer.bindShaderProgram(s,{u_float_dem_resolution:l[0],u_float_dem_cell_size:h,u_float_dem_shading_intensity:_,u_tex_dem:Yn,u_tex_corrected_dem:An,u_tex_hillshade_ramp:Jn,u_float_corrected_interval:t.demManager.isDemCorrectionEnabled&&f!==1?.5/f:0,u_mat4_dem_corrected:t.demManager.demTexToCorrectedTex,u_float_map_center_elevation:e.elevation??0})},lo=(s,e,t)=>{t.renderer.bindShaderProgram(s,{u_float_dem_shading_intensity:0})},wa=(s,e,t)=>{t.renderer.bindShaderProgram(s,{u_float_dem_scale:0})},Gi=ee,Hi=_e(Ae,Ci),Sa=ei,yu=_e(zs,Ci,Ae,Os,ee),Ta=_e(zs,Ci,Id,ee),Ma=_e(Ae,Ci,Os,ee),bu=ei,Xe=(s,e,t,i,o)=>{const a=t.postEffectsManager.getEffectByName(Dt.TAA),r=!o&&a?.jitter?a.jitter:gu;t.renderer.bindShaderProgram(s,{u_vec2_camera_jitter:r})},Pe=(s,e,t)=>{const i=t.shadowManager.texture;i&&(t.renderer.enableTexture(i,ba),t.renderer.bindShaderProgram(s,{u_texture_shadow:ba}))},xu=(s,e,t)=>{if(!t.benchmark)return;const i=n.create$2(),o=t.benchmark.getScale();t.renderer.bindShaderProgram(s,{u_mat4_mvp:n.scale$3(i,i,o),u_vec3_transform:n.fromValues(0,0,0)})},wu=_e(ee,Xe,Pe),Su=_e(Xe,Pe),Vi=_e(ee,Xe,Pe),Tu=ei,Mu=_e(ee,Xe,Pe),Ea=_e(Xe,Pe),tt=_e(ee,Xe,Pe),Ia=_e(ee,Pe),Nt=_e(ee,Xe,Pe),Ca=_e(ei,Fs,Ds),La=_e(ei,Fs,Ds,Pe),Eu=_e(ee,La),Iu=_e(ee,Ca),co=_e(Pe,ee),Cu=_e(ee,Xe,Pe),Lu=_e(Xe,Pe),Pa=_e(Xe,Pe),Pu=_e(ee,Pa),oi=new Float32Array(2),si=new Float32Array(2),Bu=[0,0],zu=[0,0,0,0],kt=.01,xe=(s,e,{renderer:t})=>{t.bindShaderProgram(s,{u_float_opacity:1})},_o=(s,e,{renderer:t},i,o)=>{const a=Ee(e,i),r=n.resolveNumber(o.style.textureOpacity,a);t.bindShaderProgram(s,{u_float_texture_opacity:i.tile.readiness*r})},de=(s,e,{renderer:t},i)=>{if(!i.renderingProperties.color)return;const o=n.getColorForShaders(i.renderingProperties.color);n.scale$4(o,o,i.tile.readiness),t.bindShaderProgram(s,{u_vec4_color:o})},Ba=(s,e,{renderer:t},i)=>{if(!i.renderingProperties.mixColor)return;const{color2:o,factor:a,factorInterpolate:r}=i.renderingProperties.mixColor,l=n.getColorForShaders(o);switch(n.scale$4(l,l,i.tile.readiness),a.type){case"readFromTarget":{const c=t.getDrawTargetFramebuffer(a.name)?.renderTarget.getTexture();if(!c)return;t.enableTexture(c,2),r?t.bindShaderProgram(s,{u_vec4_color2:l,u_sr2d_read_from_target_texture:2,u_int_factor_use_interpolate:1,u_float_factor_interpolate_base:r.base,u_vec4_factor_interpolate_ranges:r.steps}):t.bindShaderProgram(s,{u_vec4_color2:l,u_sr2d_read_from_target_texture:2,u_int_factor_use_interpolate:0});break}case"vertexAttribute":{t.bindShaderProgram(s,{u_vec4_color2:l});break}default:{const{type:c}=a;n.assertUnreachable(c)}}},ai=(s,e,{renderer:t},i)=>{t.bindShaderProgram(s,{u_mat4_gradient:i.renderingProperties.mat4_gradient})},Ru=(s,e,{renderer:t},i,o)=>{const a=n.getColorForShaders(n.resolveColor(o.style.strokeColor,Ee(e,i)));n.scale$4(a,a,i.tile.readiness),t.bindShaderProgram(s,{u_vec4_border_color:a})},Ce=(s,e,{renderer:t},i)=>{const o=i.renderingProperties.widthResolved||0;t.bindShaderProgram(s,{u_float_width:o*window.devicePixelRatio})},za=(s,e,{renderer:t},i,o)=>{t.bindShaderProgram(s,{u_float_shift:n.resolveNumber(o.style.shift,Ee(e,i))*window.devicePixelRatio})},Fu=(s,e,{renderer:t},i,o)=>{const a=i.renderingProperties.opacityResolved||0,r=n.makeBinderContext(e.styleZoom,e.styleState,i.attributes.tileData,!1),l=o.style.iconOpacity,c=n.resolveNumber(l,r);r.isBehind=!0;const d=e.styleState.graphicsPreset==="light"?1:n.resolveNumber(l,r);t.bindShaderProgram(s,{u_vec2_opacity:[a*c,a*d]})},pt=(s,e,{renderer:t},i)=>{const o=i.renderingProperties.opacityResolved||0;t.bindShaderProgram(s,{u_float_opacity:o})},uo=(s,e,{renderer:t},i,o)=>{const a=n.resolveNumber(o.style.iconRotation,Ee(e,i));t.bindShaderProgram(s,{u_vec2_rotation:[Math.cos(a),Math.sin(a)]})},Du=(s,e,{renderer:t},i,o)=>{const a=n.resolveNumber(o.style.opacity,Ee(e,i));t.bindShaderProgram(s,{u_float_opacity:i.tile.readiness*a})},Ou=(s,e,{renderer:t},i,o)=>{const a=n.resolveNumber(o.style.opacity,Ee(e,i));t.bindShaderProgram(s,{u_float_opacity:a})},ho=(s,e,{assetManager:t,renderer:i},o)=>{const a=t.textures[o.attributes.atlasIndex];i.enableTexture(a,0)},Ut=(s,e,{renderer:t},i)=>{const o=i.renderingProperties.fontTexture;o&&t.enableTexture(o,0)},Ra=(s,e,{renderer:t},i)=>{const o=i.renderingProperties.texture;o&&t.enableTexture(o,0)},Nu=(s,e,{renderer:t},i)=>{const o=i.renderingProperties.rampTexture;o&&(t.enableTexture(o,1),t.bindShaderProgram(s,{u_sr2d_ramp_texture:1}))},ji=(s,e,{renderer:t},i,o)=>{const{tile:a}=i,r=n.resolveColor(o.style.gapColor,Ee(e,i));if(!r)return;const l=n.getColorForShaders(n.resolveColor(r,Ee(e,i)));n.scale$4(l,l,a.readiness),t.bindShaderProgram(s,{u_vec4_space_color:l})},Zi=(s,e,{renderer:t},i,o)=>{const{styleZoom:a}=e,r=Ee(e,i),{tile:l}=i,c=n.getColorForShaders(n.resolveColor(o.style.color,r));n.scale$4(c,c,l.readiness),r.styleZoom=Math.floor(a);const d=Math.pow(2,n.getFractionalPart(a)),_=n.resolveNumber(o.style.dashLength,r)*d,u=n.resolveNumber(o.style.gapLength,r)*d;t.bindShaderProgram(s,{u_vec4_dash_color:c,u_vec2_scaler_params:[0,n.z0Scale],u_float_dash_length:n.zptToSceneDistance(_,l.size),u_float_dash2_length:n.zptToSceneDistance(_,l.size),u_float_space_length:n.zptToSceneDistance(u,l.size),u_int_gap_turns_only:o.style.gapTurnsOnly?1:0})},ae=n.create$3(),Fa=(s,e,{renderer:t},i,o)=>{const a=Ee(e,i),{tile:r}=i,{pattern:l,width:c}=i.renderingProperties;if(!l||!c)return;const d=n.getColorForShaders(n.resolveColor(o.style.color,a));switch(n.scale$4(d,d,r.readiness),l[0]){case n.LinePatternType.Chess:{const _=l[1];ae[0]=_,ae[1]=.5,ae[2]=.25,ae[3]=-.25;break}case n.LinePatternType.DoubleDash:{const _=l[1];ae[0]=_,ae[1]=l[2]/c,ae[2]=.5*l[3]/_,ae[3]=.5*l[4]/_,ae[2]>=.5-Number.EPSILON&&(ae[2]=.6),ae[3]>=.5-Number.EPSILON&&(ae[3]=.6);break}case n.LinePatternType.Stripe:{const _=l[1]+l[2];ae[0]=_,ae[1]=.55,ae[2]=.5*l[1]/_,ae[3]=.5*l[1]/_,ae[2]>=.5-Number.EPSILON&&(ae[2]=.6),ae[3]>=.5-Number.EPSILON&&(ae[3]=.6);break}case n.LinePatternType.Circle:{const _=l[1]+l[2];ae[0]=_,ae[1]=.5*l[1]/_;break}case n.LinePatternType.Triangles:{const _=l[1]+l[2];ae[0]=_,ae[1]=l[1]/_,ae[2]=String(l[3])==="right"?-1:1;break}case n.LinePatternType.Chevron:{const _=l[1]+l[2];ae[0]=_,ae[1]=l[1]/_,ae[2]=l[3]/_,ae[3]=l[4]/c;break}}t.bindShaderProgram(s,{u_vec4_color:d,u_int_pattern_type:l[0],u_vec4_pattern_params:ae})},Wi=(s,e,{renderer:t},i,o)=>{const a=Ee(e,i),r=n.resolveNumber(o.style.tipWidth,a),l=n.resolveNumber(o.style.tipHeight,a),c=r,d=0;oi[0]=-c,oi[1]=-d,n.normalize$1(oi,oi),si[0]=r,si[1]=l,n.normalize$1(si,si);const _=n.resolveNumber(o.style.roundingRadius,a);t.bindShaderProgram(s,{u_vec2_wing_normal:oi,u_vec2_tip_normal:si,u_float_tip_height_multiplier:l,u_float_wing_height_multiplier:d,u_float_wing_width_multiplier:c,u_float_size_factor:n.zptToSceneDistance(n.uint16ToTileCoords,i.tile.size)/2,u_float_tip_radius_zpt:_,u_float_wing_radius_zpt:_,u_float_tail_radius_zpt:_})},Da=(s,e,{renderer:t},i,o)=>{const a=Ee(e,i),r=n.resolveNumber(o.style.lineLength,a),l=n.resolveNumber(o.style.lineWidth,a);t.bindShaderProgram(s,{u_float_length:r,u_float_width:l,u_float_border_width:0})},Oa=(s,e,{renderer:t},i,o)=>{const a=Ee(e,i),{tile:r,attributes:l}=i,c=l.isLongArrow,d=i.tile.dynamicObject;let _=0,u=1;d&&(c?u=d.growPosition:_=d.bouncePosition);let h=0;const f=o.style.animation.type;(f==="appearance"||f==="repeat")&&(h=n.resolveNumber(o.style.animation.tipMovementAmplitude,a));const m=n.resolveNumber(o.style.roundingRadius,a);t.bindShaderProgram(s,{u_float_width_zpt:n.resolveNumber(o.style.lineWidth,a),u_float_border_width_zpt:n.resolveNumber(o.style.strokeWidth,a),u_float_tip_movement_amplitude:n.zptToSceneDistance(h,r.size),u_float_vertex_shift:_,u_float_relative_end_position:u,u_float_tip_radius_zpt:m,u_float_wing_radius_zpt:m,u_float_tail_radius_zpt:m})},ku=(s,e,{renderer:t},i)=>{const o=i.renderingProperties.modelTexture;o&&t.enableTexture(o,0)},Uu=(s,e,{renderer:t},i)=>(t.bindShaderProgram(s,{u_int_gltf_dem_pos:i.attributes.demPosition,u_vec2_anchor:i.attributes.centroid??Bu,u_vec4_axis:i.attributes.axis??zu}),!0),Gu=(s,e,{assetManager:t,renderer:i},o)=>{const{styleId:a}=o.attributes,{renderingProperties:r}=o,{resolvedColorTexture:l,resolvedAoTexture:c,resolvedPbrTexture:d,resolvedMetallic:_,resolvedRoughness:u}=r,{modelId:h}=r,f=t.getModel(h??NaN,a);if(!f)return;const m={},p=l!==void 0&&f.textures[l];p&&(i.enableTexture(p,0),m.u_sr2d_texture_0=0);const v=c!==void 0&&f.textures[c];v&&(i.enableTexture(v,1),m.u_ao_texture=1);const y=d!==void 0&&f.textures[d];y?(i.enableTexture(y,n.PBR_TEXTURE_INDEX),m.u_pbr_texture=n.PBR_TEXTURE_INDEX):(m.u_float_metallic=_,m.u_float_roughness=u),i.bindShaderProgram(s,m)},Na=(s,e,t,i,o)=>{const{renderer:a}=t,l=a.getGlobeRenderTarget(n.globeTileScale(e.zoom,i.tile)).getTexture();return l?(a.enableTexture(l,Uo),a.bindShaderProgram(s,{u_sr2d_flatmap_texture:Uo}),!0):!1},$i=(s,e,{renderer:t},i,o)=>{let a=i.renderingProperties.resolvedHeightFactor||0;a=kt+(1-kt)*a,t.bindShaderProgram(s,{u_float_height_factor:a})},Xi=(s,e,{renderer:t},i,o)=>{t.bindShaderProgram(s,{u_int_extention_to_relief_needed:i.attributes.extToReliefNeeded?1:0,u_int_collapse_height_needed:i.attributes.collapseHeightNeeded?1:0})},fo=(s,e,{modelLayer:t,renderer:i},o,a)=>{if(o.attributes.id===void 0)return;const r=t.getOpacity(o.attributes.id,a.minzoom),c=t.getBuildingHeight(o.attributes.id)===1?1:r;i.bindShaderProgram(s,{u_float_height_factor:c})},Ki=(s,e,{renderer:t},i,o)=>{const a=Ee(e,i),r=n.resolveNumber(o.style.height,a);t.bindShaderProgram(s,{u_float_height_factor:n.mapHeightToTileHeight(r)})},ke=(s,e,t,i,o)=>{const{floorManager:a,buildingHeightAnimator:r,modelsScene:l,modelLayer:c,renderer:d}=t;if(i.symbol==="polygonExtrusion"&&i.attributes.floorId&&i.attributes.isFloorStack){d.bindShaderProgram(s,{u_float_height_factor:a.getFloorStackObjectHeight(i.attributes.floorId)});return}let _=r.getBuildingHeight(o.minzoom);_=kt+(1-kt)*_;const u=l.objectIdToKey(i.id);u&&c.setBuildingHeight(u,_),d.bindShaderProgram(s,{u_float_height_factor:_})};function Ee(s,e){return n.makeBinderContext(s.styleZoom,s.styleState,e.attributes.tileData,!1,e.tile.dynamicObject)}const qi=(s,e,{renderer:t},i)=>{const{tile:o}=i,a=i.renderingProperties.widthResolved||0;t.bindShaderProgram(s,{u_float_width:n.zptToSceneDistance(a,o.size)/2*n.uint16ToTileCoords,u_float_width_offset:n.zptToSceneDistance(n.uint16ToTileCoords/window.devicePixelRatio,o.size)/2})},Hu=(s,e,{renderer:t},i)=>{const o=i.renderingProperties.resolvedRadius;t.bindShaderProgram(s,{u_float_radius:o*window.devicePixelRatio})},Vu=(s,e,{renderer:t},i,o)=>{const a=n.resolveNumber(o.style.intensity,Ee(e,i));t.bindShaderProgram(s,{u_float_intensity:a})},St=(s,e,{renderer:t},i,o)=>{const a=Ee(e,i);let r=n.resolveNumber(o.style.textFontSize,a);if(i.symbol==="point"){const l=i.attributes.labelIndex;l===n.LabelIndex.Second&&o.style.textFontSize2?r=n.resolveNumber(o.style.textFontSize2,a):l===n.LabelIndex.Icon&&o.style.iconTextFontSize&&(r=n.resolveNumber(o.style.iconTextFontSize,a))}t.bindShaderProgram(s,{u_float_scale:r*window.devicePixelRatio/n.fonts.baseSize})},Yi=(s,e,{renderer:t},i,o)=>{const a=n.makeBinderContext(e.styleZoom,e.styleState,i.attributes.tileData,!!i.layerSettings.isOverlappedObject),{textFontSize:r,textColor:l,textHaloWidth:c,textHaloColor:d}=o.style,_=n.resolveNumber(r,a)/n.fonts.baseSize,u=_*window.devicePixelRatio,h=n.fonts.gamma/u,f=i.layerSettings.uniformSet,m=f==="fontHalo"?(6-n.resolveNumber(c,a)/_)/8:.75;let p;f==="fontHalo"?p=n.getColorForShaders(n.resolveColor(d,a)):p=n.getColorForShaders(n.resolveColor(l,a)),t.bindShaderProgram(s,{u_float_buffer:m,u_float_gamma:h,u_vec4_color:p})},ka=(s,e,{renderer:t},i,o)=>{const{layerSettings:a}=i,{uniformSet:r}=a,l=i.attributes.labelIndex,c=o.style;let{textFontSize:d,textHaloWidth:_,textColor:u,textHaloColor:h}=c;switch(l){case n.LabelIndex.Icon:d=c.iconTextFontSize,_=c.iconTextHaloWidth,u=c.iconTextColor,h=c.iconTextHaloColor;break;case n.LabelIndex.Second:d=c.textFontSize2,_=c.textHaloWidth2,u=c.textColor2,h=c.textHaloColor2;break}ju(s,t,e,i,d,u,_,h,l,r)},ju=(s,e,t,i,o,a,r,l,c,d)=>{const _=n.makeBinderContext(t.styleZoom,t.styleState,i.attributes.tileData,!1,i.tile.dynamicObject),u=n.resolveNumber(o,_)/n.fonts.baseSize,h=u*window.devicePixelRatio,f=n.fonts.gamma/h,m=d==="fontHalo"?(6-n.resolveNumber(r,_)/u)/8:.75;let p,v;d==="fontHalo"?(p=n.getColorForShaders(n.resolveColor(l,_)),_.isBehind=!0,v=n.getColorForShaders(n.resolveColor(l,_))):(p=n.getColorForShaders(n.resolveColor(a,_)),_.isBehind=!0,v=n.getColorForShaders(n.resolveColor(a,_))),e.bindShaderProgram(s,{u_float_buffer:m,u_float_gamma:f,u_vec4_color:p,u_vec4_hidden_color:v,u_float_label_index:c})},Qi=(s,e,{renderer:t},i)=>{const{attributes:o}=i,{offsetX:a,offsetY:r}=o,l=window.devicePixelRatio;t.bindShaderProgram(s,{u_vec2_offset:[a*l,r*l]})},Ji=(s,e,{renderer:t})=>{t.bindShaderProgram(s,{u_float_style_zoom:e.styleZoom})},at=(s,e,{renderer:t},i)=>{const{tile:o}=i,{zoom:a}=e,r=n.tileSizeZpt*Math.pow(2,a-o.zoomLevel)*window.devicePixelRatio;t.bindShaderProgram(s,{u_float_tile_to_pixel_ratio:n.uint16ToTileCoords/r})},Ua=(s,e,{renderer:t},i,o)=>{const{tile:a}=i,{zoom:r,styleZoom:l}=e,c=o.style.lengthUnits===n.LengthUnits.Meters,d=n.tilePointScaleFactor(n.createTileInfo(a.coords),[n.maxTilePoint/2,n.maxTilePoint/2]),_=n.uint16ToTileCoords/(n.tileSizeZpt*Math.pow(2,r-a.zoomLevel)*window.devicePixelRatio),u=c?l:Math.floor(l),h=n.tileSizeZpt*Math.pow(2,u-a.zoomLevel)*window.devicePixelRatio/(n.uint16ToTileCoords*d);t.bindShaderProgram(s,{u_vec2_scales:[h,_]})},Ga=(s,e,{renderer:t},i)=>{const o=i.renderingProperties.flatTexture;o&&t.enableTexture(o,0),t.bindShaderProgram(s,{u_flat_tex:0})},Ha=(s,e,{renderer:t},i)=>{const o=i.renderingProperties.flatIdentifyTexture;o&&t.enableTexture(o,0),t.bindShaderProgram(s,{u_flat_tex:0})},Va=(s,e,{renderer:t},i)=>{const o=i.renderingProperties.hillshadeTexture;o&&(t.enableTexture(o,Qn),t.bindShaderProgram(s,{u_hillshade_tex:Qn}))},Zu=(s,e,t,i)=>{const{renderer:o,demManager:a}=t,r=i.renderingProperties.demTexture;r&&(o.enableTexture(r,0),o.bindShaderProgram(s,{u_tex_dem:0,u_mat4_dem_corrected:a.demCorrectedFbVpToDemTex}))},ri=(s,e,{renderer:t},i,o)=>{let a=!0;e.globeMode||(a=!!n.resolveNumber(o.style.elevation,Ee(e,i))),t.bindShaderProgram(s,{u_bool_skip_height_factor:a})},Ue=(s,e,{buildingHeightAnimator:t,renderer:i},o,a)=>{let r=t.getBuildingHeight(a.minzoom);r=kt+(1-kt)*r,i.bindShaderProgram(s,{u_float_height_factor:r})},Ge=(s,e,{renderer:t},i)=>{t.bindShaderProgram(s,{u_int_abs_z:i.attributes.absZ?1:0})},mo=(s,e,{renderer:t})=>{t.bindShaderProgram(s,{u_int_abs_z:!1})},po=(s,e,{renderer:t},i)=>{t.bindShaderProgram(s,{u_float_tile_size:n.tileZoomToSize(i.tile.zoomLevel)})},vo=(s,e,{renderer:t},i)=>{t.bindShaderProgram(s,{u_int_depth_test:i.layerSettings.depthTest?1:0,u_vec4_depth_test_color:n.LABELING_TEXTURE_DEM_MESH_COLOR})},F=(s,e,{renderer:t},i,o,a)=>{t.bindShaderProgram(s,{u_float_dem_scale:a?e.elevationScale:0})},go=(s,e,{renderer:t},i)=>{if(!i.attributes.meshTier)return;const o=i.layerSettings.identify?t.getMapMeshIdFramebufferId():t.getMapMeshFramebufferId(),a=t.getFramebuffer(o),r=a?.renderTarget.getTexture(),l=a?.scale;r&&(t.enableTexture(r,n.MAP_MESH_TEXTURE_INDEX),t.bindShaderProgram(s,{u_sampler_map_tex:n.MAP_MESH_TEXTURE_INDEX,u_vec2_tex_scale:l,u_float_tex_shift_scale:1-Math.cos(e.pitch)}))},rt=(s,e,{renderer:t},i)=>{t.bindShaderProgram(s,{u_int_identify:i.layerSettings.identify||i.layerSettings.depthTest?1:0})},Wu=(s,e,{renderer:t},i)=>{t.bindShaderProgram(s,{u_float_scale:i.meta.scale,u_vec3_transform:i.meta.transform})};function E(...s){return(e,t,i,o,a,r)=>{s.forEach(l=>l(e,t,i,o,a,r))}}const Gt=(s,e,{renderer:t},i)=>(t.bindShaderProgram(s,{u_bool_is_3d_line:i.symbol==="line"&&i.sink==="solid3d"||i.symbol==="line"&&i.sink==="patterned3d"||i.symbol==="dashedLine"&&i.sink==="stroke3d"}),!0),le=(s,e,{floorManager:t,renderer:i},o)=>{if(!o.attributes.floorId||!o.tile.renderModelMatrix){i.bindShaderProgram(s,{u_float_floor_elevation:0});return}if(o.symbol==="polygonExtrusion"&&o.attributes.isFloorStack){i.bindShaderProgram(s,{u_float_floor_elevation:t.getFloorStackObjectElevation(o.attributes.floorId)/o.tile.renderModelMatrix[10]});return}i.bindShaderProgram(s,{u_float_floor_elevation:t.getFloorObjectElevation(o.attributes.floorId)/o.tile.renderModelMatrix[10]})},Ht=(s,e,{renderer:t})=>{t.bindShaderProgram(s,{u_float_floor_elevation:0})},li=(s,e,t,i)=>{t.renderer.bindShaderProgram(s,{u_int_is_roof:i.symbol==="polygonExtrusion"&&i.sink==="topFill"?1:0})},ja=(s,e,t,i)=>{if("isFloorStack"in i.attributes&&i.attributes.isFloorStack){const o=t.floorManager.getFloorsStackObjectOffsets(i.attributes.floorId);t.renderer.bindShaderProgram(s,{u_vec2_floor_level:[o.current,o.total]})}else t.renderer.bindShaderProgram(s,{u_vec2_floor_level:[0,1]})},$u=(s,e,t,i,o)=>{const a=i.attributes.textureIndex,r=o.style.sideTextures?.[a],l=t.imageManager.getTexture(o.sideTextureIndices[a]),c=n.MAP_POINTS_IN_METER*n.tilePointScaleFactor(n.createTileInfo(i.tile.coords),[0,0]),d=l.options.size,_=[r.texturePadding[3]/d[0],r.texturePadding[0]/d[1],r.texturePadding[1]/d[0],r.texturePadding[2]/d[1]],u=r.wallPadding.map(p=>p*c),h=r.sliceSize.map(p=>p*c),f=[r.horizontal.maxInterval*c,r.vertical.maxInterval*c],m=[Za(r.horizontal.mode),Za(r.vertical.mode)];t.renderer.enableTexture(l,0),t.renderer.bindShaderProgram(s,{u_sr2d_texture:0,u_vec4_wall_padding_su:[u[3],u[0],u[1],u[2]],u_vec4_texture_padding_un:_,u_vec2_texture_part_count:[r.horizontal.slicesCount,r.vertical.slicesCount],u_vec2_max_interval_su:f,u_vec2_texture_slice_size_su:h,u_ivec2_layout_mode:m,u_int_texture_index:i.attributes.textureIndex})};function Za(s){switch(s){case"repeat-with-stretch":return 1;case"stripe-top":return 2;case"repeat-with-max-interval":return 3;default:return 1}}const Xu="FRAGMENT",Ku="VERTEX",qu="FOG",Yu="SKY",Qu="METALLIC_ROUGHNESS_DEBUG",Ju="PBR_TEXTURE",Au="AO_TEXTURE",eh="MAP_MESH_TEXTURE",th="COLOR_TEXTURE",Wa="LIGHT_MODEL",ih="1",nh="2",oh="DEPTH_TEXTURE_SHADOW",sh="RENDER_SHADOWS",ah="UBO",rh="SCREENDOOR",lh="ENTRANCE_ARROWS_ROUNDING",ch="MALI_GPU",dh="VARYINGS_LIMIT_9",yo="MIX_COLOR_MODE",_h="1",$a="2",uh="MIX_COLOR_MODE_VERTEX_ATTRIBUTE_NAME",hh="1",fh=n.Shader.createShaderDefinitions([{type:yo,value:_h}]),mh=n.Shader.createShaderDefinitions([{type:yo,value:$a}]),ph=n.Shader.createShaderDefinitions([{type:yo,value:$a},{type:uh,value:hh}]),vh={value:[0,0,0]};function ue(s,e){return n.makeBinderContext(s.styleZoom,s.styleState,e.attributes.tileData,!1,e.tile.dynamicObject)}const gh=(s,e,t,i)=>{switch(s.attributes.side){case n.MeshFillSide.top:if(!i.style.strokeColor)return!1;break;case n.MeshFillSide.side:if(!i.style.sideColor)return!1;break;case n.MeshFillSide.bottom:if(!i.style.bottomColor)return!1;break;default:return!1}return!0},bo=(s,e)=>{const t=e.assetManager.textures[s.attributes.atlasIndex];return t?(s.renderingProperties.atlasTexture=t,!0):!1},Xa=(s,e)=>{const t=e.imageManager.getTexture(s.attributes.textureIndex);return t?(s.renderingProperties.texture=t,!0):!1},Vt=(s,e)=>{const{range:t,fontIndex:i,styleId:o}=s.attributes,a=e.styleManager.getStyle(o);if(!a)return!1;const r=a.fonts[i],l=e.assetManager.getFontTextureByName(r,t);return l?(s.renderingProperties.fontTexture=l,!0):!1},xo=(s,e)=>{const t=s.layerSettings.identify?e.renderer.getMapMeshIdFramebufferId():e.renderer.getMapMeshFramebufferId(),i=e.renderer.getFramebuffer(t),o=i?.renderTarget.getTexture(),a=i?.scale;return!(!o||!a)},yh=(s,{imageManager:e})=>{const t=e.getTexture(s.attributes.rampTextureIndex);return t?(s.renderingProperties.rampTexture=t,!0):!1},bh=(s,e)=>{const t=e.demManager.getDemFramebufferId(),i=e.renderer.getFramebuffer(t)?.renderTarget.getTexture();return i?(s.renderingProperties.demTexture=i,!0):!1},Ka=(s,{demManager:e,renderer:t,map:i})=>{if(!i.state.demMode)return!1;const o=e.getHillshadeFramebufferId(),a=t.getFramebuffer(o)?.renderTarget.getTexture();return a?(s.renderingProperties.hillshadeTexture=a,!0):!1},qa=(s,{demManager:e,renderer:t,map:i})=>{if(!i.state.demMode)return!1;const o=e.getFlatFramebufferId(),a=t.getFramebuffer(o);if(!a)return!1;const r=a.renderTarget.getTexture();return r?(s.renderingProperties.flatTexture=r,!0):!1},Ya=(s,{demManager:e,renderer:t,map:i})=>{if(!i.state.demMode)return!1;const o=e.getIdentifyFlatFramebufferId(),a=t.getFramebuffer(o);if(!a)return!1;const r=a.renderTarget.getTexture();return r?(s.renderingProperties.flatIdentifyTexture=r,!0):!1},xh=(s,e,t,i)=>{const{renderingProperties:o}=s,{resolvedUvIndex:a}=o,{colorTextureUvIndex:r}=i.style;return r!==void 0&&a!==r&&((s.meta?.availableTextureCoords??[])[r]&&s.vao.setAttributesAliases({texcoord_color:`texcoord_${r}`}),o.resolvedUvIndex=r),!0},wh=(s,e,t,i)=>{const{styleId:o,colorTexture:a,aoTexture:r,pbrTexture:l,meshTier:c}=s.attributes,{renderingProperties:d}=s,{modelId:_}=d,u=e.assetManager.getModel(_??NaN,o);return!u||(a!==void 0&&u.textures[a]&&(d.resolvedColorTexture=a),r!==void 0&&u.textures[r]&&(d.resolvedAoTexture=r),l!==void 0&&u.textures[l]?d.resolvedPbrTexture=l:(d.resolvedMetallic=s.attributes.metallic??i.style.metallic,d.resolvedRoughness=s.attributes.roughness??i.style.roughness),!d.resolvedColorTexture&&!d.color)?!1:c?xo(s,e):!0},Qa=(s,{modelsScene:e})=>{const t=e.getModelOpacity(s);return s.renderingProperties.resolvedOpacity=t,t!==0},Ja=(s,{modelsScene:e})=>{const t=e.getModelHeightFactor(s);return s.renderingProperties.resolvedHeightFactor=t,t!==0},Aa=(s,e,t,i)=>{const o=ue(t,s),a=n.resolveNumber(i.style.width,o);if(a===0)return!1;const r=n.resolveExpression(i.style.pattern,o);return!r||r[0]===n.LinePatternType.None?!1:(s.renderingProperties.width=a,s.renderingProperties.pattern=r,!0)},Sh=(s,e,t)=>Lo(t,s.attributes.animDirection)!==0,er=(s,e,t,i)=>{const o=ue(t,s);return n.resolveNumber(i.style.iconOpacity,o)*Lo(t,s.attributes.animDirection)!==0},tr=(s,e)=>!e.map.getFeatureFlag("transparentBuildingsOff"),U=(s,e,t,i)=>Th(s.tile,t,i),ir=(s,e,t)=>{if(s.meta?.planId&&(!t.styleState._activeFloorIds||!t.styleState._activeFloorIds.includes(s.meta.planId))||s.meta?.linkedIds?.length&&!s.meta?.planId&&e.floorManager.hasDisplayedFloorBuilding(s.meta.linkedIds))return!1;const i=s.meta?.buildingId;return!(i&&s.tile.ids?.isHidden(i))},Th=(s,e,t)=>{const{purpose:i,detailLevel:o}=s,{styleZoom:a}=e;switch(i){case"zenith":case"traffic":case"geojson":const r=o<Nh(i)?n.clamp(a,o,o+.99999):a;return t.minzoom<=r&&r<t.maxzoom;case"dynamicObject":return t.minzoom<=a&&a<=t.maxzoom;default:return t.minzoom<=a&&a<t.maxzoom}},Mh=(s,e,t)=>{const{styleZoom:i}=t,{tile:o}=s;if(o.purpose!=="zenith"||i>n.tiles.maxUniverseZoom)return!0;let a=n.tiles.maxUniverseZoom;if(o.sourceId){const r=e.sourceStorage.getSourceById(o.sourceId);a=r?.type==="zenith"?r.getOptions().strokeMinZoom??n.tiles.maxUniverseZoom:n.tiles.maxUniverseZoom}return i>a},He=(s,e,t,i)=>{const{styleZoom:o}=t;return o>=i.minzoom&&o<i.maxzoom},wo=(s,e)=>s.attributes.id===void 0?!0:!e.modelLayer.isHidden(s.attributes.id),So=(s,e,t,i)=>{const o=ue(t,s);return n.resolveNumber(i.style.iconWidth,o)>0},nr=(s,e,t,i)=>{const{layerSettings:o}=s,{uniformSet:a}=o,r=s.attributes.labelIndex,l=i.style;if(a==="fontHalo"){let{textHaloColor:c}=l;switch(r){case n.LabelIndex.Icon:c=l.iconTextHaloColor;break;case n.LabelIndex.Second:c=l.textHaloColor2;break}if(!c)return!1}return!0},Ai=(s,e,t,i)=>!(s.layerSettings.uniformSet==="fontHalo"&&!i.style.textHaloColor),To=(s,e,t,i)=>{const o=ue(t,s),a=i.style;if(s.symbol==="point")switch(s.attributes.labelIndex){case n.LabelIndex.Second:return(n.resolveNumber(a.textHaloWidth2??null,o)??0)>0&&!!a.textHaloColor2;case n.LabelIndex.Icon:return(n.resolveNumber(a.iconTextHaloWidth??null,o)??0)>0&&!!a.iconTextHaloColor;case n.LabelIndex.First:break}return(n.resolveNumber(a.textHaloWidth??null,o)??0)>0&&!!a.textHaloColor},or=(s,{modelLayer:e})=>{const{texture:t,id:i}=s.attributes;if(i===void 0)return!1;const o=e.getTexture(i,t);return o?(s.renderingProperties.modelTexture=o,!0):!1},Ke=(s,e,t,i)=>{const o=n.resolveNumber(i.style.width,ue(t,s));return s.renderingProperties.widthResolved=o,o!==0},ci=(s,e,t,i)=>{const o=ue(t,s),a=n.resolveNumber(i.style.strokeWidth,o);return s.renderingProperties.widthResolved=a,a!==0},Eh=(s,e,t,i)=>{const o=ue(t,s),a=n.resolveNumber(i.style.strokeWidth,o);if(a===0)return!1;const r=n.resolveNumber(i.style.width,o);return s.renderingProperties.widthResolved=r+a*2,!0},Ih=(s,e,t,i)=>{const o=ue(t,s),a=n.resolveNumber(i.style.strokeWidth2,o);if(a===0)return!1;const r=n.resolveNumber(i.style.width,o),l=n.resolveNumber(i.style.strokeWidth,o);return s.renderingProperties.widthResolved=r+l*2+a*2,!0},Ch=(s,e,t,i)=>{const o=ue(t,s),a=n.resolveNumber(i.style.width,o),r=n.resolveNumber(i.style.strokeWidth,o),l=n.resolveNumber(i.style.strokeWidth2,o),c=a+r*2+l*2;return s.renderingProperties.widthResolved=c,c!==0},ft=(s,e,t)=>{const i=Lo(t,s.attributes.animDirection);return s.renderingProperties.opacityResolved=i,i!==0},Lh=(s,e,t,i)=>(s.renderingProperties.resolvedRadius=n.resolveNumber(i.style.radius,ue(t,s)),s.renderingProperties.resolvedRadius>0),sr=(s,e,t,i)=>{s.renderingProperties.mat4_gradient||(s.renderingProperties.mat4_gradient=new Float32Array(16));let o;switch(s.attributes.side){case n.MeshFillSide.top:o=i.style.topColor??i.style.color;break;case n.MeshFillSide.side:o=i.style.sideColor;break;case n.MeshFillSide.bottom:o=i.style.bottomColor;break}const a=ue(t,s),r=n.resolveExpression(o,a);return s.renderingProperties.mat4_gradient[0]=0,n.isStyleColor(r)?je(s,r):n.isStyleGradient(r)&&Po(r,s.tile.readiness,s.renderingProperties.mat4_gradient),!0},Mo=(s,e,t,i)=>{if(s.renderingProperties.mat4_gradient||(s.renderingProperties.mat4_gradient=new Float32Array(16)),!s.renderingProperties.color)return!1;const o=n.resolveGradient(i.style.sideColor,ue(t,s));return o?(n.copy$1(s.renderingProperties.color.value,o.values[0].value),Po(o,s.tile.readiness,s.renderingProperties.mat4_gradient),s.renderingProperties.color.value[3]!==0):(s.renderingProperties.mat4_gradient[0]=0,!0)},ar=(s,e,t,i)=>{const o=s.renderingProperties.color;if(!o)return!1;s.renderingProperties.mat4_gradient||(s.renderingProperties.mat4_gradient=new Float32Array(16));const a=ue(t,s),r=n.resolveColor(i.style.sideColor,a).value,l=n.equals(o.value,r),c=l?i.style.sideColor:i.style.sideStrokeColor,d=n.resolveGradient(c,ue(t,s));return d?(n.copy$1(o.value,d.values[0].value),Po(d,s.tile.readiness,s.renderingProperties.mat4_gradient)):s.renderingProperties.mat4_gradient[0]=0,l&&(o.value[3]*=t.stillness),o.value[3]!==0},ce=(s,e)=>!("hiddenByFloorComplexId"in s.attributes)||!s.attributes.hiddenByFloorComplexId?!0:!e.floorManager.hasDisplayedFloorBuilding([s.attributes.hiddenByFloorComplexId]),te=(s,e)=>s.attributes.floorId?s.symbol==="polygonExtrusion"&&s.attributes.isFloorStack?e.floorManager.isVisibleFloorStackObject(s.attributes.floorId):e.floorManager.isVisibleFloorObject(s.attributes.floorId):!0,Ph=s=>{const e=s.renderingProperties.color;return e?n.set$1(e.value,0,0,0,.05*255):s.renderingProperties.color=n.toStyleColor([0,0,0,.05*255]),!0},rr=(s,e,t,i)=>{const o=n.makeBinderContext(t.styleZoom,t.styleState,s.attributes.tileData,!!s.layerSettings.isOverlappedObject);return je(s,n.resolveColor(i.style.color,o)),s.renderingProperties.color.value[3]!==0},Eo=(s,e,t,i)=>(je(s,n.resolveColor(i.style.topColor,ue(t,s))),s.renderingProperties.color.value[3]!==0),en=(s,e,t,i)=>(je(s,n.resolveColor(i.style.sideColor,ue(t,s))),s.renderingProperties.color.value[3]!==0),di=(s,e,t,i)=>(je(s,n.resolveColor(i.style.strokeColor,ue(t,s))),s.renderingProperties.color.value[3]!==0),Bh=(s,e,t,i)=>{switch(s.attributes.side){case n.MeshFillSide.top:je(s,n.resolveColor(i.style.strokeColor,ue(t,s)));break;case n.MeshFillSide.side:je(s,n.resolveColor(i.style.sideColor,ue(t,s)));break;case n.MeshFillSide.bottom:je(s,n.resolveColor(i.style.bottomColor,ue(t,s)));break;default:je(s,vh);break}return s.renderingProperties.color.value[3]!==0},zh=(s,e,t,i)=>(je(s,n.resolveColor(i.style.strokeColor2,ue(t,s))),s.renderingProperties.color.value[3]!==0),Io=(s,e,t,i)=>{if(s.attributes.id===void 0)return!1;const o=s.renderingProperties.color;return o?(o.value[3]*=e.modelLayer.getOpacity(s.attributes.id,i.minzoom),o.value[3]!==0):!1},lr=(s,e,t,i)=>{const o=s.renderingProperties.color;if(!o)return!1;const a=ue(t,s),r=n.resolveColor(i.style.strokeColor,a).value,l=n.resolveNumber(i.style.strokeWidth,a);return n.equals(o.value,r)&&o.value[3]===1&&l<=1&&(o.value[3]*=t.stillness),o.value[3]!==0},Rh=(s,e,t,i)=>{const o=s.renderingProperties.color;if(!o)return!1;const a=ue(t,s),r=n.resolveColor(i.style.topColor,a).value,l=n.resolveNumber(i.style.strokeWidth,a);return n.equals(o.value,r)&&o.value[3]===1&&l<=1&&(o.value[3]*=t.stillness),o.value[3]!==0},cr=(s,e,t,i)=>{const o=n.resolveColor(i.style.sideStrokeColor,ue(t,s));return je(s,o),s.renderingProperties.color.value[3]!==0},Ve=(s,e,t,i)=>{const o=n.resolveColor(i.style.color,ue(t,s),!0),a=n.isStyleMixColor(o)?o.color1:o;if(je(s,a),n.isStyleMixColor(o)&&!(o.factor.type==="readFromTarget"&&!e.renderer.doesDrawTargetFramebufferExist(o.factor.name))){if(kh(s,o),s.renderingProperties.color.value[3]===0&&s.renderingProperties.mixColor.color2.value[3]===0)return!1;const{factor:{type:r,name:l}}=s.renderingProperties.mixColor;switch(r){case"readFromTarget":{s.shaderDefinitions=fh;break}case"vertexAttribute":{switch(l){case"denormalized_distance_to_line":s.shaderDefinitions=ph;break;default:s.shaderDefinitions=mh;break}break}default:n.assertUnreachable(r)}return!0}return s.renderingProperties.color.value[3]!==0},Fh=(s,e,t,i)=>{je(s,n.resolveColor(i.style.color,ue(t,s)));const{color:o,resolvedOpacity:a}=s.renderingProperties;return n.mul(o.value,o.value,s.attributes.colorFactor),o.value[3]*=a??0,o.value[3]!==0},dr=(s,e)=>{const t=s?.attributes.parentId;if(!t)return!0;const{floorManager:i}=e;return i.hasDisplayedFloorBuilding([t])&&s.attributes.floorId?!0:!s?.tile.ids?.isHidden(t,n.HideLevel.PolygonExtrusion)},Co=B(U,dr,ce,(s,e)=>{if(!s.bboxWorld||s.tile.dynamicObject||s.renderingProperties.animationStack&&s.renderingProperties.animationStack.length>0)return!0;if(e.environmentManager.isAABBInFog(s.bboxWorld))return!1;const t=e.camera.getViewportVertices();return n.tetragonIntersectsBounds(t,s.bboxWorld)},te,ir,Qa,Ja,Fh),Dh=B(U,dr,ce,ir,Qa,Ja),_r=B(xh,wh),Oh=(s,e,t,i)=>{const o=s.attributes.textureIndex,a=i.style.sideTextures?.[o],r=e.imageManager.getTexture(i.sideTextureIndices[o]);return!!a&&!!r};function B(...s){return(e,t,i,o)=>{for(const a of s)if(!a(e,t,i,o))return!1;return!0}}function Nh(s){switch(s){case"zenith":return n.tiles.maxDetailLevel;case"traffic":return n.traffic.maxDetailLevel;case"geojson":return n.GEOJSON_DEFAULT_MAX_DETAIL_LEVEL}}function Lo(s,e){return e===n.LabelingAnimation.none?1:e===n.LabelingAnimation.fadeIn?s.labelingOpacity:1-s.labelingOpacity}function Po(s,e,t){if(!s.steps.length){t[0]=0;return}t[0]=n.clamp(s.values.length,0,3);for(let i=0;i<t[0];i++){const o=s.values[i],a=n.getColorForShaders(o);n.scale$4(a,a,e),t[i+1]=s.steps[i];const r=(i+1)*4;t[r]=a[0],t[r+1]=a[1],t[r+2]=a[2],t[r+3]=a[3]}}function je(s,e){s.renderingProperties.color||(s.renderingProperties.color=n.toStyleColor([255,255,255,255])),n.copy$1(s.renderingProperties.color.value,e.value)}function kh(s,e){s.renderingProperties.mixColor=e}function ur(s,e=void 0,t=void 0){const i=document.createElement("img");return e!==void 0&&(i.width=e),t!==void 0&&(i.height=t),new Promise(o=>{i.onload=()=>o(i),i.src=s})}function hr(s){let e;try{e={url:`data:image/svg+xml;base64,${btoa(s)}`}}catch{const i=URL.createObjectURL(new Blob([s],{type:"image/svg+xml"}));e={url:i,revokeURL:()=>URL.revokeObjectURL(i)}}return e}function tn(s,e="image/png"){const t=new Blob([s],{type:e}),i=URL.createObjectURL(t),o=document.createElement("img");return new Promise(a=>{o.onload=()=>{URL.revokeObjectURL(i),a(o)},s.byteLength===0?o.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=":o.src=i})}function fr(s,e){if(e[0]===s.width&&e[1]===s.height)return s;const t=document.createElement("canvas"),i=t.getContext("2d");return t.width=e[0],t.height=e[1],i.shadowColor="transparent",i.shadowBlur=0,i.drawImage(s,0,0,e[0],e[1]),t}function mr(s,e,t,i,o){const a=Array();o&&e.forEach(r=>{const l=i[r.outputBufferView],c=Math.ceil(o.get(r.actionId)??-1),d=Math.floor(o.get(r.actionId)??-1),_=(o.get(r.actionId)||1)%1,u=Math.round(o.get(r.actionId)??-1);if(l&&o.size>0&&d>=0&&c>=0&&u>=0){const h=new Float32Array(zo(l),r.outputBufferOffset,r.outputBufferLength);if(r.outputType==="VEC4")switch(r.interpolation){case"STEP":{t[r.targetMatIndex[0]][r.targetMatIndex[1]]=jt(h,u,4);break}case"LINEAR":default:{n.slerp(t[r.targetMatIndex[0]][r.targetMatIndex[1]],jt(h,d,4),jt(h,c,4),_);break}}else if(r.outputType==="VEC3")switch(r.interpolation){case"STEP":{t[r.targetMatIndex[0]][r.targetMatIndex[1]]=jt(h,u,3);break}case"LINEAR":default:{n.lerp(t[r.targetMatIndex[0]][r.targetMatIndex[1]],jt(h,d,3),jt(h,c,3),_);break}}}});for(let r=0;r<t.length;r++){const l=t[r];if(l.length===3){const c=n.create$2();n.fromRotationTranslationScale(c,l[1],l[0],l[2]),a.push(c)}else a.push(l)}Kh(s,a)}function jt(s,e,t){if(t!==3&&t!==4)return console.warn("Invalid animation transform size"),[];const i=[];for(let o=0;o<t;o++)i.push(s[e*t+o]);return i}function Uh(s,e,t,i,o){s.animations.forEach((a,r)=>{a.channels.forEach((l,c)=>{if(l.target.node===t){const d=a.samplers[l.sampler],_=a.name||"default",u=s.accessors[d.input];if(u.bufferView===void 0||s.bufferViews[u.bufferView]===void 0)return;pr(e,s,u.bufferView,u.componentType);const f=s.accessors[d.output];if(f.bufferView===void 0)return;const m=s.bufferViews[f.bufferView];if(m===void 0)return;pr(e,s,f.bufferView,f.componentType),(d.interpolation||"LINEAR")!=="LINEAR"&&(d.interpolation||"LINEAR")!=="STEP"&&console.warn(`Unsupported interpolation type "${d.interpolation}" in animation "${_}". Fall back to LINEAR interpolation.`);const p=Gh(l.target.path);i.push({min:u.min,max:u.max,frameCount:u.count,keyFrameType:"SCALAR",interpolation:d.interpolation||"LINEAR",outputType:p.outputType,outputBufferView:f.bufferView,outputBufferOffset:m.byteOffset||0,outputBufferLength:m.byteLength/p.bufferStride,targetMatIndex:[o.length-1,p.targetindex],actionId:`${a.name}_${r}_${c}`,animationIndex:r,animationName:_})}})})}function Gh(s){let e=0,t="VEC3";const i=4;switch(s){case"translation":e=0;break;case"rotation":e=1,t="VEC4";break;case"scale":e=2;break;case"weights":e=3}return{targetindex:e,outputType:t,bufferStride:i}}function pr(s,e,t,i){const o=e.bufferViews[t];if(o===void 0)return;if(!s.buffers[t]){const r=e.buffers[o.buffer].buffer;if(!r)return;s.buffers[t]=zo(r)}const a=s.buffers[t];if(!(a instanceof n.Buffer))return a}function Hh(s,e){for(let t=s.length-1;t>=0;t--){const i=s[t];if(e(i,t,s))return i}}const Vh=new Set(["position","texcoord_0","texcoord_1","texcoord_2","texcoord_3","normal","tangent"]),jh=Array.from(n.create$2()),Zh={pbrMetallicRoughness:{baseColorFactor:[1,1,1,1],metallicFactor:1,roughnessFactor:1},emissiveFactor:[0,0,0],alphaMode:"OPAQUE",alphaCutoff:.5,doubleSided:!1};function Wh(s){return vr(s,Zh),s}function vr(s,e){for(const t in e)s[t]===void 0?s[t]=e[t]:typeof s[t]=="object"&&vr(s[t],e[t])}var Ze=(s=>(s[s.Pending=1]="Pending",s[s.Loaded=2]="Loaded",s[s.Failed=3]="Failed",s))(Ze||{});function $h(s){return{buffers:[],textures:[],status:1,scenes:[],defaultScene:0,preserve:s}}function Xh(s,e,t,i,o,a){const r=[],l=[];for(const c of t.scenes){const d=[];gr(d,s,c.nodes,t,r,l,e,i,o,a),s.scenes.push({id:n.uniqId(),name:c.name,objects:d})}return s.defaultScene=t.scene??0,s}function gr(s,e,t,i,o,a,r,l,c,d){if(!t)return;const _=r.symbolSettingsList.gltfModel.instances;if(!(!_||_.length===0))for(const u of t){const h=i.nodes[u];if(n.isObject(h.extras)&&h.extras.ignore)continue;const f=[...o],m=[...a];if(h.matrix&&f.push(h.matrix),h.translation&&h.rotation&&h.scale){const p=[];p.push(h.translation,h.rotation,h.scale),f.push(p),Uh(i,e,u,m,f)}if(h.mesh!==void 0){const p=i.meshes[h.mesh];let v=d?n.GltfDemPosition.flat:n.GltfDemPosition.default;n.isObject(h.extras)&&(h.extras.dem==="flat"?v=n.GltfDemPosition.flat:h.extras.dem==="instance"&&(v=n.GltfDemPosition.default));const y=new Float32Array(16);mr(y,m,f,e.buffers);let b,x;if(h.children){const T=[];for(const w of h.children){const M=i.nodes[w];Qh(M)&&T.push(M)}if(T.length){const w=T[0];if(w.extras.dem==="centroid")v=n.GltfDemPosition.centroid,b=[w.translation[0],w.translation[2]];else if(w.extras.dem==="axis"){v=n.GltfDemPosition.axis;const M=Hh(T,z=>z.extras.dem==="axis");x=[w.translation[0],w.translation[2],(M??w).translation[0],(M??w).translation[2]]}}}for(const T of p.primitives){const w=[],M={};let z=0,S,I;for(const ge in T.attributes){const qt=/TEXCOORD_(\d+)/.exec(ge);qt&&(w[parseInt(qt[1],10)]=!0);const Yt=ge.toLowerCase();if(!Vh.has(Yt))continue;const gt=T.attributes[ge],ze=i.accessors[gt];if(ze.bufferView===void 0)continue;const zn=i.bufferViews[ze.bufferView];if(zn===void 0)continue;const vi=yr(r,e,i,ze.bufferView,ze.componentType);if(vi){if(Yt==="position"&&(S=ze.min,I=ze.max),vi.purpose="gltfMesh",M[ge.toLowerCase()]=new n.BufferChannel(vi,{itemSize:qh(ze.type),dataType:n.componentTypeToWebGl(ze.componentType),stride:zn.byteStride??0,offset:ze.byteOffset??0,normalized:!!ze.normalized}),!b&&ge.toLowerCase()==="position"){const Pt=ze.min,ds=ze.max;Pt&&ds&&(b=[(ds[0]+Pt[0])/2,(ds[2]+Pt[2])/2])}z===0&&(z=ze.count)}}S||(S=[0,0,0]),I||(I=[0,0,0]);let R;if(T.indices!==void 0){const ge=i.accessors[T.indices];if(ge.bufferView===void 0||(R=yr(r,e,i,ge.bufferView,ge.componentType,!0),!R))continue;R.purpose="gltfIndices",z=ge.count}const C=T.material!==void 0?i.materials[T.material]:{},j=Wh(C),H={},K={localMatrix:y,animationStack:m,transformStack:f,availableTextureCoords:w,attributesAliases:H,colorFactor:[...j.pbrMetallicRoughness.baseColorFactor],colorTexture:NaN,aoTexture:NaN,pbrTexture:NaN,centroid:b,axis:x,demPosition:v},Y=[],Ye=j.pbrMetallicRoughness.baseColorTexture;Ye&&(Y.push({type:th}),H.texcoord_color=`texcoord_${Ye.texCoord??0}`,Bo(e,i,Ye),K.colorTexture=Ye.index);const Oe=j.pbrMetallicRoughness.metallicRoughnessTexture;if(Oe){Y.push({type:Ju}),Bo(e,i,Oe),K.pbrTexture=Oe.index;const ge=typeof Oe.texCoord=="number"?Oe.texCoord:0;H.texcoord_pbr=`texcoord_${ge}`,w[ge]=!1}else K.roughness=j.pbrMetallicRoughness.roughnessFactor??1,K.metallic=j.pbrMetallicRoughness.metallicFactor??1;Number.isNaN(c.style.roughness)||Y.push({type:Qu}),h.extras?.tier!==void 0&&(K.meshTier=h.extras.tier,Y.push({type:eh})),c.style.lightingModel==="pbr"?Y.push({type:Wa,value:nh}):Y.push({type:Wa,value:ih});const Ne=j.occlusionTexture;if(Ne){Y.push({type:Au}),Bo(e,i,Ne),K.aoTexture=Ne.index;const ge=typeof Ne.texCoord=="number"?Ne.texCoord:0;H.texcoord_ao=`texcoord_${ge}`,w[ge]=!1}s.push({start:0,count:z,attributes:K,drawMode:T.mode,accessors:M,elementsBuffer:R,shaderDefinitions:Y,bbox:{min:S,max:I}})}}h.children&&gr(s,e,h.children,i,f,m,r,l,c,d)}}function Bo(s,e,t){const i=t.index??0,o=e.textures[i];if(!o||o.source===void 0||o.sampler===void 0)return;const a=e.images[o.source],r=e.samplers[o.sampler];if(!r||!a)return;const l={flipY:!1};if(r.magFilter&&(l.magFilter=Mi(r.magFilter)),r.minFilter&&(l.minFilter=Mi(r.minFilter)),r.wrapS&&(l.wrapS=Mi(r.wrapS)),r.wrapT&&(l.wrapT=Mi(r.wrapT)),t.texCoord!==void 0&&(l.texcoord=t.texCoord),!a.image&&a.bufferView){Yh(e,a).then(c=>{c&&(a.image=c,s.textures[i]=new g(a.image,l))});return}s.textures[i]=new g(a.image,l)}function yr(s,e,t,i,o,a=!1){const r=t.bufferViews[i];if(r===void 0)return;if(!e.buffers[i]){const c=t.buffers[r.buffer].buffer;if(!c)return;const d=new DataView(zo(c),r.byteOffset,r.byteLength),_=s.createBuffer(d,{dataType:n.componentTypeToWebGl(o)},a);e.buffers[i]=_}const l=e.buffers[i];if(!(l instanceof ArrayBuffer))return l}function Kh(s=[],e){if(e.length===0)return Array.from(jh);n.copy(s,e[0]);for(let t=1;t<e.length;t++)n.mul$1(s,s,e[t]);return s}function qh(s){switch(s[0]){case"S":return 1;case"V":return Number(s[3]);case"M":return Number(s[3])**2}return console.error(`Failed to determine channels count from accessor type = ${s}`),0}function zo(s){return s instanceof ArrayBuffer?s:s.buffer}async function Yh(s,e){if(!e.bufferView)return!1;const t=s.bufferViews[e.bufferView];if(t===void 0)return!1;const i=s.buffers[t.buffer].buffer;return i?tn(new Uint8Array(i,t.byteOffset,t.byteLength),e.mimeType):!1}function Qh(s){return s.mesh===void 0&&n.isObject(s.extras)&&(s.extras.dem==="centroid"||s.extras.dem==="axis")}const Jh=n.len$1([1,1,1]),Tt=n.create$1(),Ro=n.create$1(),Ah=n.create$2();function ef(s,e){n.invert(s,e);const t=n.create$2();t[12]+=s[12],t[13]+=s[13],n.mul$1(s,s,t)}function Fo(s){return s.symbol==="gltfModel"&&s.sink==="instances"}function tf(s,e,t,i,o){const a=s.modelMatrices.get(0);if(!a)return;const r=[t[0]/n.maxUint16Value,t[1]/n.maxUint16Value,t[2]/n.maxUint16Value],l=[t[3]/n.maxUint16Value,t[4]/n.maxUint16Value,t[5]/n.maxUint16Value],c={min:[0,0,0],max:[0,0,0]};if(n.transformMat4$1(c.min,r,a),n.transformMat4$1(c.max,l,a),o)if(i.tMatrix3x3){const d=nf(o,i.tMatrix3x3,e);n.add$1(c.min,c.min,d.min),n.add$1(c.max,c.max,d.max)}else{let d=Math.max(n.len$1(o.max),n.len$1(o.min));if(e){const _=Tt,u=Ro;n.decomposeMat4(e,_,u);const h=n.len$1(_)/Jh;d*=h,d+=n.len$1(u)}d*=i.maxDiag??1,n.set(Tt,-d,-d,-d),n.add$1(c.min,c.min,Tt),n.set(Tt,d,d,d),n.add$1(c.max,c.max,Tt)}return c}function nf(s,e,t){const i=n.set$2(Ah,e[0],e[1],e[2],0,e[3],e[4],e[5],0,e[6],e[7],e[8],0,0,0,0,1);t&&n.mul$1(i,i,t);const o=n.lerp(Tt,s.min,s.max,.5),a=n.scale(Ro,n.sub$1(Ro,s.max,s.min),.5),r=n.transformMat4$1(Tt,o,i),l=n.fromValues(Math.abs(i[0])*a[0]+Math.abs(i[4])*a[1]+Math.abs(i[8])*a[2],Math.abs(i[1])*a[0]+Math.abs(i[5])*a[1]+Math.abs(i[9])*a[2],Math.abs(i[2])*a[0]+Math.abs(i[6])*a[1]+Math.abs(i[10])*a[2]),c=n.sub$1(n.create$1(),r,l),d=n.add$1(n.create$1(),r,l);return{min:c,max:d}}class of{constructor(e){this.modules=e,this.queue=new Map}enqueue(e,t){this.queue.set(t.id,{batch:e,tile:t,state:void 0})}update(){const{renderer:e,tileManager:t}=this.modules;for(const i of t.getTileObjects()){const o=this.queue.get(i.id);if(!o)continue;const{batch:a}=o,{symbol:r,sink:l}=a,c=n.getSymbolLayers(e,r,l);if(!c){console.error(`Cannot happen! Symbol ${r} does not have sink ${l}!`);continue}const d=c[0].instanceBinder;if(!d){console.error("Cannot happen! No instanceBinder for batch inside instanceLinker queue.");continue}const _=d(this.modules,a,i,o.state);if(!_){this.queue.delete(i.id);continue}o.state=_}}}function sf(s,e,t,i,o,a,r,l,c,d,_,u){const h=n.stride(a,r),f=n.getSymbolLayers(e,a,r),{accessors:m,elementsBuffer:p,count:v,drawMode:y,bbox:b}=i,x=n.Shader.createShaderDefinitions(i.shaderDefinitions);_.linkId=t;for(const T of f){const w=T.uniformSet||"fill",M=JSON.stringify(Object.values(c))+"_"+w+"_"+o.detailLevel,z=e.getShaderProgram(T.programName,x),S=l.buffer;if(!S){console.error(`Expected existing buffer while linking instance, but ${S} found.`);continue}const I=T.vaoCreator(S,z,p,m);_.attributesAliases&&I.setAttributesAliases(_.attributesAliases);const R={id:n.uniqId(),type:n.SceneObjectType.Tile,layerSettings:T,start:0,count:v,attributes:c,shaderDefinitions:x,renderingProperties:d,meta:_,attributesHash:M,vao:I,drawMode:y,tile:o,bbox:b,bboxWorld:u,symbol:a,sink:r,canRender:!0,instanceCount:(l.rangeEnd-l.rangeStart)/h};o.push(R),s.push(R)}s.length&&e.addRerenderEvent({type:"instanceLink"})}function br(s,e,t){af(e,i=>{const o=i.meta?.linkId===t;return o&&s.push(i),!o})}function af(s,e){s.children=s.children.filter(e),s.identifyChildren=s.identifyChildren.filter(e),s.depthTestChildren=s.depthTestChildren.filter(e),s.labelTestChildren=s.labelTestChildren.filter(e),s.shadowChildren=s.shadowChildren.filter(e)}const rf={min:[0,0,0],max:[0,0,0]},nn=(s,e,t,i)=>{const{assetManager:o,modelsScene:a,renderer:r}=s;if(i||(i={}),t.destroyed){const c=[];for(const d in i){const _=i[+d];Number.isNaN(_.linkId)||br(c,t,_.linkId)}for(const d of c)a.removeSceneObject(d.id);return}const l=[];for(let c=0;c<e.generatedObjects.length;c++){const d=e.generatedObjects[c],_=n.GltfModelGenerator.sinks.instances.unpackObjectAttributes(d.attributes),{extents:u}=d;i[c]||(i[c]={modelId:NaN,linkId:NaN});const h=i[c];let f;const m=!!h.referenceBbox;h.referenceBbox?f=h.referenceBbox:(f=rf,f.min[0]=u[0]/n.maxUint16Value,f.min[1]=u[1]/n.maxUint16Value,f.min[2]=u[2]/n.maxUint16Value,f.max[0]=u[3]/n.maxUint16Value,f.max[1]=u[4]/n.maxUint16Value,f.max[2]=u[5]/n.maxUint16Value);const{styleId:p}=_,v=h.modelId,y=h.sceneId;a.updateModelId(h,_,f,t,m);const b=h.modelId;if(b===void 0||Number.isNaN(b))continue;const x=h.sceneId;if(x===void 0||Number.isNaN(x)||v===b&&y===x)continue;const T=o.getModel(b,p);if(!T||T.status!==Ze.Loaded)continue;const w=T?.scenes.find(S=>S.id===h.sceneId)?.objects??[];if(w.length===0)continue;const M=h.linkId;if(!Number.isNaN(M)){const S=[];br(S,t,M);for(const I of S)a.removeSceneObject(I.id)}const z=n.uniqId();h.linkId=z;for(const S of w){const I=t.modelMatrices.get(0),R=new Float32Array(16);ef(R,I);const{attributesAliases:C,availableTextureCoords:j,colorTexture:H,colorFactor:K,aoTexture:Y,pbrTexture:Ye,metallic:Oe,roughness:Ne,meshTier:ge,animationStack:qt,transformStack:Yt,localMatrix:gt,demPosition:ze,axis:zn,centroid:vi}=S.attributes,Pt=tf(t,gt,u,d,S.bbox);!h.referenceBbox&&Pt&&(h.referenceBbox=Pt),sf(l,r,z,S,t,e.symbol,e.sink,d,{colorTexture:H,colorFactor:K,aoTexture:Y,pbrTexture:Ye,metallic:Oe,roughness:Ne,meshTier:ge,demPosition:ze,axis:zn,centroid:vi,..._},{modelId:b,animationStack:qt,transformStack:Yt,localMatrix:new Float32Array(gt??[]),transformMatrix:R},{...d.meta,attributesAliases:C,availableTextureCoords:j},Pt)}}return l.forEach(c=>{a.addSceneObject(c)}),i},on=new Float32Array(16);let we,Se;function L(...s){return(t,i,o,a,r,l)=>{for(const c of s)if(!c(t,i,o,a,r,l))return!1;return!0}}const P=(s,e,t,i)=>(t.renderer.bindShaderProgram(s,{u_mat4_mvp:i.tile.renderMvpMatrix}),!0),Le=(s,e,t,i)=>{const{camera:o,styleManager:a,renderer:r}=t;return!a.getStyle(e.handyStyleId)?.environment||!i.tile.renderModelMatrix?!1:(r.bindShaderProgram(s,{u_mat4_flat_mvp:i.tile.renderMvpMatrix,u_mat4_ecef_mvp:o.ecefMvpMatrix,u_float_crossfade:o.globeRatio}),!0)},sn=(s,e,t,i)=>(t.renderer.bindShaderProgram(s,{u_mat4_flat_map_mvp:i.tile.renderFlatMapTexMatrix}),!0),X=(s,e,t,i)=>i.tile.renderModelMatrix?(n.copy(on,i.tile.renderModelMatrix),t.renderer.bindShaderProgram(s,{u_mat4_model:on}),!0):!1,an=(s,e,t,i)=>(t.renderer.bindShaderProgram(s,{u_int_abs_z:i.attributes.absZ?1:0}),!0),D=(s,e,{renderer:t},i,o,a)=>{if(a.terrain3d){if(!i.tile.renderModelMatrix)return!1;t.bindShaderProgram(s,{u_mat4_dem_mvp:i.tile.renderDemMatrix,u_float_vertical_scale:1/i.tile.renderModelMatrix[10]})}return!0};function Zt(s,e){return n.makeBinderContext(s.styleZoom,s.styleState,e.attributes.tileData)}const Do=(s,e,t,i,o)=>{we=void 0;const a=Zt(e,i),r=n.resolveString(o.style.textureImage,a);let l=!1;o.type==="polygon"&&(l=o.style.lengthUnits===n.LengthUnits.Meters);const c=t.styleManager.getStyle(i.attributes.styleId);if(!c)return!0;const d=c.rasterSets.byKey[n.getStaticTextureRasterSetKey(r)]?.rasters;if(!d)return!0;const _=n.resolveExpression(o.style.textureSize,a);let[u,h]=Array.isArray(_)?_:[_,_];if(l&&(u=u*n.getPixelsPerMeter(u,u),h=h*n.getPixelsPerMeter(h,h)),u<=0||h<=0)return!0;const f=n.selectRaster(d,u*window.devicePixelRatio,!0);return f===void 0||(we=d[f]),!0},xr=(s,e,t,i,o)=>{Se=void 0;const a=Zt(e,i),r=n.resolveString(o.style.normalMapTextureImage,a),l=o.style.normalMapTextureLengthUnits===n.LengthUnits.Meters,c=t.styleManager.getStyle(i.attributes.styleId);if(!c)return!0;const d=c.rasterSets.byKey[n.getStaticTextureRasterSetKey(r)]?.rasters;if(!d)return!0;const _=n.resolveExpression(o.style.normalMapTextureSize,a);let[u,h]=Array.isArray(_)?_:[_,_];if(l&&(u=u*n.getPixelsPerMeter(u,u),h=h*n.getPixelsPerMeter(h,h)),u<=0||h<=0)return!0;const f=n.selectRaster(d,u*window.devicePixelRatio,!0);return f===void 0||(Se=d[f]),!0},Oo=(s,e,{assetManager:t,renderer:i},o,a)=>{if(!we)return i.bindShaderProgram(s,{u_int_is_textured:0}),!0;let r,l,c,d;const{tile:_}=o,{zoom:u}=e,h=t.textures[we.atlasIndex];let f=!1;if(!h)return i.bindShaderProgram(s,{u_int_is_textured:0}),!0;a.type==="polygon"&&(f=a.style.lengthUnits===n.LengthUnits.Meters),i.enableTexture(h,0);let m;if(f){const p=Zt(e,o),v=n.resolveExpression(a.style.textureSize,p),[y,b]=Array.isArray(v)?v:[v,v],x=n.Mercator.toGeo(n.tileCoordsToMapPoint(_.coords)),T=n.Mercator.scaleFactor(x[1]),w=n.tileZoomToSize(_.zoomLevel)/n.MAP_POINTS_IN_METER/T,M=w/y,z=w/b,S=Math.trunc(n.atlasSize[0]/M),I=Math.trunc(n.atlasSize[1]/z);r=_.coords[0]*n.atlasSize[0]%S/S,l=_.coords[1]*n.atlasSize[1]%I/I,c=n.atlasSize[0]/S,d=n.atlasSize[1]/I}else m=n.tileSizeZpt*Math.pow(2,Math.round(u)-_.zoomLevel)*window.devicePixelRatio,r=_.coords[0]*m%we.w/we.w,l=_.coords[1]*m%we.h/we.h,c=m/we.w,d=m/we.h;return i.bindShaderProgram(s,{u_int_is_textured:1,u_float_texture_params:[r,l,c,d],u_float_sprite_texture_coords:[(we.x+.5)/n.atlasSize[0],(we.y+we.h-1)/n.atlasSize[1],(we.x+we.w-1)/n.atlasSize[0],(we.y+.5)/n.atlasSize[1]]}),!0},wr=(s,e,t,i,o)=>{const{assetManager:a,styleManager:r,renderer:l}=t;if(!Se)return l.bindShaderProgram(s,{u_int_is_normal_map_textured:0}),!0;let c,d,_,u;const{tile:h}=i,{zoom:f}=e,m=a.textures[Se.atlasIndex],p=o.style.normalMapTextureLengthUnits===n.LengthUnits.Meters;if(!m)return l.bindShaderProgram(s,{u_int_is_normal_map_textured:0}),!0;l.enableTexture(m,1);let v;if(p){const b=Zt(e,i),x=n.resolveExpression(o.style.normalMapTextureSize,b),[T,w]=Array.isArray(x)?x:[x,x],M=n.Mercator.toGeo(n.tileCoordsToMapPoint(h.coords)),z=n.Mercator.scaleFactor(M[1]),S=n.tileZoomToSize(h.zoomLevel)/n.MAP_POINTS_IN_METER/z,I=S/T,R=S/w,C=Math.trunc(n.atlasSize[0]/I),j=Math.trunc(n.atlasSize[1]/R);c=h.coords[0]*n.atlasSize[0]%C/C,d=h.coords[1]*n.atlasSize[1]%j/j,_=n.atlasSize[0]/C,u=n.atlasSize[1]/j}else v=n.tileSizeZpt*Math.pow(2,Math.round(f)-h.zoomLevel)*window.devicePixelRatio,c=h.coords[0]*v%Se.w/Se.w,d=h.coords[1]*v%Se.h/Se.h,_=v/Se.w,u=v/Se.h;const y=r.getStyle(i.attributes.styleId)?.rasterSets.byIndex[Se.rasterSetIndex];return!y||!y.isReady?(l.bindShaderProgram(s,{u_int_is_normal_map_textured:0}),!0):(l.bindShaderProgram(s,{u_int_is_normal_map_textured:1,u_vec4_normal_map_texture_params:[c,d,_,u],u_vec4_normal_map_sprite_texture_coords:[(Se.x+.5)/n.atlasSize[0],(Se.y+Se.h-1)/n.atlasSize[1],(Se.x+Se.w-1)/n.atlasSize[0],(Se.y+.5)/n.atlasSize[1]]}),!0)},lf=(s,e,{renderer:t})=>(t.bindShaderProgram(s,{u_int_is_textured:0,u_int_is_normal_map_textured:0}),!0),Sr=(s,e,{renderer:t},i,o)=>{if(!Se)return!0;const a=Zt(e,i),r=n.resolveExpression(o.style.metallic,a),l=n.resolveExpression(o.style.roughness,a);return t.bindShaderProgram(s,{u_float_metallic:r,u_float_roughness:l}),!0},cf=(s,e,t,i)=>{if(!we)return t.renderer.bindShaderProgram(s,{u_int_is_textured:0}),!0;const{tile:o}=i,{zoom:a}=e,r=t.assetManager.textures[we.atlasIndex];if(!r)return t.renderer.bindShaderProgram(s,{u_int_is_textured:0}),!0;t.renderer.enableTexture(r,0);const l=n.tileSizeZpt*Math.pow(2,Math.round(a)-o.zoomLevel)*window.devicePixelRatio;return t.renderer.bindShaderProgram(s,{u_int_is_textured:1,u_float_texture_vertical_scale:we.h*o.size/l}),!0},df=(s,e,{styleManager:t,assetManager:i,renderer:o},a,r)=>{const l=Zt(e,a),c=n.resolveString(r.style.iconImage,l),d=t.getStyle(a.attributes.styleId);if(!d)return!1;const _=d.rasterSets.byKey[n.getStaticTextureRasterSetKey(c)]?.rasters;if(!_)return!1;const u=n.resolveNumber(r.style.width,l),h=n.resolveNumber(r.style.height,l),f=n.getPixelsPerMeter(u,h),m=u*f,p=h*f;if(m<=0||p<=0)return!1;const v=n.selectRaster(_,m*window.devicePixelRatio,!0);if(v===void 0)return!1;const y=_[v],b=i.textures[y.atlasIndex];return b?(o.enableTexture(b,0),o.bindShaderProgram(s,{u_float_sprite_texture_coords:[(y.x+.5)/n.atlasSize[0],(y.y+y.h-1)/n.atlasSize[1],(y.x+y.w-1)/n.atlasSize[0],(y.y+.5)/n.atlasSize[1]]}),!0):!1},Tr=new Float32Array(16);n.fromScaling(Tr,[1/n.worldSize,1/n.worldSize,1/n.worldSize]);const rn=(s,e,{animationManager:t,assetManager:i,renderer:o},a,r)=>{const{styleId:l}=a.attributes,{localMatrix:c,transformMatrix:d,modelId:_}=a.renderingProperties;if(_===void 0)return!1;const u=i.getModel(_,l);return u===void 0?!1:(t.animateGltfObject(a,r,u),o.bindShaderProgram(s,{u_mat4_localmatrix:c,u_mat4_instance:e.globeMode?Tr:d}),!0)},_f=(s,e,{renderer:t},i)=>i.tile.renderModelMatrix?(n.copy(on,i.tile.renderModelMatrix),t.bindShaderProgram(s,{u_mat4_model:on}),!0):!1,Mr=(s,e,{animationManager:t,renderer:i},o,a)=>{if(!Se)return!0;let r=[0,0,0,0],l=0;const[c,d]=t.animatePolygonNormalMapTexture(o,a);return r=d,l=c?1:0,i.bindShaderProgram(s,{u_vec4_normal_map_animated_offsets:r,u_int_normal_map_is_animated:l}),!0},uf=(s,e,t)=>!t.shadowManager.texture;function hf(){return{line:{solid:[{programName:"road",vaoCreator:Od,stateBinder:Me,needsVisibilityBuffer:!1,commonBinder:W(V,Z,q),programBinder:Lu,objectBinder:E(za,de,Ce),layerBinder:A,zoomBinder:at,tileBinder:L(X,P),cullMethod:B(U,ce,Ke,Ve)},{identify:!0,programName:"roadIdentify",vaoCreator:Gd,stateBinder:_t,needsVisibilityBuffer:!1,objectBinder:E(Ce),zoomBinder:at,tileBinder:P,cullMethod:B(U,ce,Ke,Ve)}],patterned:[{programName:"patternedLine",vaoCreator:Hd,stateBinder:Me,needsVisibilityBuffer:!1,commonBinder:W(V,Z,q),programBinder:Pa,layerBinder:A,objectBinder:E(Fa,Ce,xe,Gt),zoomBinder:Ua,tileBinder:L(X,P),cullMethod:B(U,ce,Ke,Aa)}],solid3d:[{programName:"line3D",vaoCreator:Nd,stateBinder:$n,needsVisibilityBuffer:!1,commonBinder:W(V,Z,q),programBinder:wu,objectBinder:E(de,Ce,Ge,F),layerBinder:A,zoomBinder:at,tileBinder:L(X,P,D),cullMethod:B(U,Ke,Ve),is3dMapAware:!0},{identify:!0,programName:"line3DIdentify",vaoCreator:kd,stateBinder:he,needsVisibilityBuffer:!1,programBinder:ee,objectBinder:E(Ce,Ge,F),zoomBinder:at,tileBinder:L(P,D),cullMethod:B(U,Ke,Ve),is3dMapAware:!0}],patterned3d:[{programName:"patternedLine3D",vaoCreator:Vd,stateBinder:$n,needsVisibilityBuffer:!1,commonBinder:W(V,Z,q),programBinder:Pu,layerBinder:A,objectBinder:E(Fa,Ce,xe,Gt,F),zoomBinder:Ua,tileBinder:L(X,P,D),cullMethod:B(U,Ke,Aa),is3dMapAware:!0}]},polygon:{fill:[{programName:"vtxColor",vaoCreator:Bd,stateBinder:Me,needsVisibilityBuffer:!0,commonBinder:W(V,Z,q),programBinder:Ea,layerBinder:be(A,Ae,Rs),objectBinder:E(de,Ba,xe,_o,le),tileBinder:L(Do,Oo,xr,wr,P,X,Mr,Sr),cullMethod:B(U,te,ce,Ve)},{identify:!0,programName:"vtxColorIdentify",vaoCreator:Dd,stateBinder:_t,needsVisibilityBuffer:!0,programBinder:Bs,objectBinder:E(le),tileBinder:P,cullMethod:B(U,te,ce)}],fillWithMixFactor:[{programName:"vtxColor",vaoCreator:zd,stateBinder:g_,needsVisibilityBuffer:!0,commonBinder:W(V,Z,q),programBinder:Ea,layerBinder:be(A,Ae,Rs),objectBinder:E(de,Ba,xe,_o,le),tileBinder:L(Do,Oo,xr,wr,P,X,Mr,Sr),cullMethod:B(U,te,ce,Ve)}],stroke:[{programName:"simpleLine2d",vaoCreator:n_,stateBinder:Me,needsVisibilityBuffer:!0,commonBinder:W(V,Z,q),programBinder:Su,layerBinder:be(Bs,Li,A),objectBinder:E(de,Ce,le),tileBinder:L(X,P),cullMethod:B(Mh,U,te,ce,ci,di,lr),subRenderIndex:1}],shadow:[{programName:"vtxColor",vaoCreator:Rd,stateBinder:Me,needsVisibilityBuffer:!0,commonBinder:W(V,Z),programBinder:Xe,layerBinder:Ae,objectBinder:E(de,xe,le),tileBinder:L(uf,lf,P,X),cullMethod:B(U,te,ce,Ph)}]},metricPoint:{fill:[{programName:"metricPoint",vaoCreator:Fd,stateBinder:Me,needsVisibilityBuffer:!1,commonBinder:W(V,q,Z),programBinder:Pe,layerBinder:be(A,Ae),objectBinder:E(de,le),tileBinder:L(df,P,X),cullMethod:B(U,te,Ve)}]},mesh:{fill:[{programName:"mesh",vaoCreator:Hs,stateBinder:na,needsVisibilityBuffer:!0,commonBinder:W(V,Z,q),programBinder:tt,layerBinder:be(A,et),objectBinder:E(de,ai,xe,Ue,F,Ge,rt,_o),tileBinder:L(Do,Oo,cf,X,P,D),cullMethod:B(U,sr),subRenderIndex:1,is3dMapAware:!0},{identify:!0,programName:"mesh",vaoCreator:Hs,stateBinder:he,needsVisibilityBuffer:!0,commonBinder:W(V,Z,q),programBinder:tt,objectBinder:E(Ue,F,Ge,rt),tileBinder:L(P,D),cullMethod:B(U,sr),subRenderIndex:1,is3dMapAware:!0},{depthTest:!0,programName:"mesh",vaoCreator:Zd,stateBinder:he,needsVisibilityBuffer:!0,commonBinder:W(V,Z,q),programBinder:tt,objectBinder:E(Ue,F,Ge,rt),tileBinder:L(P,D),cullMethod:U,subRenderIndex:1,is3dMapAware:!0},{programName:"meshShadow",shadow:!0,vaoCreator:Vs,stateBinder:Ni,needsVisibilityBuffer:!0,programBinder:ee,objectBinder:E(Ue,F,Ge),tileBinder:L(P,D),cullMethod:U,is3dMapAware:!0}],inverse:[{programName:"inverse",vaoCreator:zi,stateBinder:Di,needsVisibilityBuffer:!0,commonBinder:V,programBinder:tt,objectBinder:E(Ue,F,rt),tileBinder:L(P,D),cullMethod:U,subRenderIndex:-1,is3dMapAware:!0},{identify:!0,programName:"inverse",vaoCreator:zi,stateBinder:Di,needsVisibilityBuffer:!1,commonBinder:V,programBinder:tt,objectBinder:E(Ue,F,rt),tileBinder:L(P,D),cullMethod:U,subRenderIndex:-1,is3dMapAware:!0},{programName:"meshShadow",shadow:!0,vaoCreator:zi,stateBinder:Ni,needsVisibilityBuffer:!0,programBinder:ee,objectBinder:E(Ue,F,Ge),tileBinder:L(P,D),cullMethod:U,is3dMapAware:!0}],depthClear:[{programName:"meshDepthClear",vaoCreator:zi,stateBinder:x_,needsVisibilityBuffer:!0,commonBinder:W(V,Z,q),programBinder:tt,objectBinder:E(Ue,F,rt,Ge),tileBinder:L(P,D),cullMethod:U,subRenderIndex:-2,is3dMapAware:!0,forceRenderUnderCacheInDemMode:!0}],stroke:[{programName:"simpleLine3d",vaoCreator:Wd,stateBinder:Rt,needsVisibilityBuffer:!0,commonBinder:W(se,V,Z,q),programBinder:Vi,layerBinder:be(Li,A),objectBinder:E(de,Ce,Ue,Ht,F,Ge),tileBinder:L(X,P,D),cullMethod:B(U,ci,gh,Bh,lr),subRenderIndex:2,is3dMapAware:!0}]},polygonExtrusion:{sideFill:[{programName:"diffuse",vaoCreator:js,stateBinder:Di,needsVisibilityBuffer:!0,commonBinder:W(V,Z,q),programBinder:Nt,tileBinder:L(X,P,D),layerBinder:be(A,et),objectBinder:E(de,ke,xe,F,le,li),cullMethod:B(tr,U,te,en,ce),is3dMapAware:!0},{programName:"gradientDiffuse",vaoCreator:js,stateBinder:ra,needsVisibilityBuffer:!0,commonBinder:W(V,Z,q),programBinder:Nt,layerBinder:be(A,et),objectBinder:E(de,ai,ke,xe,F,le,ja,li),tileBinder:L(X,P,D),cullMethod:B(U,te,ce,en,Mo),is3dMapAware:!0},{identify:!0,programName:"buildingIdentify",vaoCreator:Ws(n.PolygonExtrusionGenerator.sinks.sideFill.stride),stateBinder:he,needsVisibilityBuffer:!0,commonBinder:se,programBinder:Gi,objectBinder:E(ke,F,le),tileBinder:L(P,D),cullMethod:B(U,te,ce,en,Mo),is3dMapAware:!0},{depthTest:!0,programName:"buildingIdentify",vaoCreator:$s(n.PolygonExtrusionGenerator.sinks.sideFill.stride),stateBinder:he,needsVisibilityBuffer:!0,commonBinder:se,programBinder:Gi,objectBinder:E(ke,F,le),tileBinder:L(P,D),cullMethod:B(U,te,ce),is3dMapAware:!0},{programName:"buildingShadow",shadow:!0,vaoCreator:Xs(n.PolygonExtrusionGenerator.sinks.sideFill.stride),stateBinder:Oi,needsVisibilityBuffer:!0,programBinder:ee,objectBinder:E(ke,F,le),tileBinder:L(P,D),cullMethod:B(U,te,ce),is3dMapAware:!0}],sideTexture:[{programName:"wallTexture",vaoCreator:$d,stateBinder:L_,needsVisibilityBuffer:!0,commonBinder:W(V,Z,q),programBinder:Nt,layerBinder:be(A,et),objectBinder:E(ke,F,le,$u),tileBinder:L(X,P,D),cullMethod:B(U,te,ce,Oh),is3dMapAware:!0}],topFill:[{programName:"diffuse",vaoCreator:Zs,stateBinder:Di,needsVisibilityBuffer:!0,commonBinder:W(V,Z,q),programBinder:Nt,layerBinder:A,objectBinder:E(de,ke,xe,F,le,li),tileBinder:L(X,P,D),cullMethod:B(tr,U,te,ce,Eo),is3dMapAware:!0},{programName:"diffuse",vaoCreator:Zs,stateBinder:ra,needsVisibilityBuffer:!0,commonBinder:W(V,Z,q),programBinder:Nt,layerBinder:be(A,et),objectBinder:E(de,ke,xe,F,le,li),tileBinder:L(X,P,D),cullMethod:B(U,te,ce,Eo),is3dMapAware:!0},{identify:!0,programName:"buildingIdentify",vaoCreator:Ws(n.PolygonExtrusionGenerator.sinks.topFill.stride),stateBinder:he,needsVisibilityBuffer:!0,commonBinder:se,programBinder:Gi,objectBinder:E(ke,F,le),tileBinder:L(P,D),cullMethod:B(U,te,ce,Eo),is3dMapAware:!0},{depthTest:!0,programName:"buildingIdentify",vaoCreator:$s(n.PolygonExtrusionGenerator.sinks.topFill.stride),stateBinder:he,needsVisibilityBuffer:!0,commonBinder:se,programBinder:Gi,objectBinder:E(ke,F,le),tileBinder:L(P,D),cullMethod:B(U,te,ce),is3dMapAware:!0},{programName:"buildingShadow",shadow:!0,vaoCreator:Xs(n.PolygonExtrusionGenerator.sinks.topFill.stride),stateBinder:Oi,needsVisibilityBuffer:!0,programBinder:ee,objectBinder:E(ke,F,le),tileBinder:L(P,D),cullMethod:B(U,te,ce),is3dMapAware:!0}],sideStroke:[{programName:"line",vaoCreator:Ks,stateBinder:Rt,needsVisibilityBuffer:!0,commonBinder:W(V,q,Z,se),programBinder:Ia,layerBinder:A,objectBinder:E(de,ai,ke,xe,F,le),tileBinder:L(X,P,D),cullMethod:B(U,te,ce,cr,ar),is3dMapAware:!0}],topStroke:[{programName:"simpleLine3d",vaoCreator:Gn,stateBinder:Rt,needsVisibilityBuffer:!0,commonBinder:W(se,V,Z,q),programBinder:Vi,layerBinder:be(A,Ed),objectBinder:E(de,Ce,ke,F,le,mo),tileBinder:L(X,P,D),cullMethod:B(U,te,ce,ci,di,Rh),is3dMapAware:!0}]},labelLine:{raster:[{programName:"labelLine",vaoCreator:Bi,stateBinder:Kn,needsVisibilityBuffer:!1,commonBinder:W(V,Z),programBinder:Hi,objectBinder:E(pt,Ut,St,Yi,Ji),tileBinder:L(P,X),zoomBinder:at,cullMethod:B(te,ft,He,Vt,Ai,To),uniformSet:"fontHalo"},{programName:"labelLine",vaoCreator:Bi,stateBinder:qn,needsVisibilityBuffer:!1,commonBinder:W(V,Z),programBinder:Hi,objectBinder:E(pt,Ut,St,Yi,Ji),tileBinder:L(P,X),zoomBinder:at,cullMethod:B(te,ft,To,He,Vt,Ai),uniformSet:"fontHalo",isOverlappedObject:!0},{programName:"labelLine",vaoCreator:Bi,stateBinder:Kn,needsVisibilityBuffer:!1,commonBinder:W(V,Z),programBinder:Hi,objectBinder:E(pt,Ut,St,Yi,Ji),zoomBinder:at,tileBinder:L(P,X),cullMethod:B(te,ft,He,Vt,Ai),uniformSet:"fontFill",subRenderIndex:1},{programName:"labelLine",vaoCreator:Bi,stateBinder:qn,needsVisibilityBuffer:!1,commonBinder:W(V,Z),programBinder:Hi,objectBinder:E(pt,Ut,St,Yi,Ji),zoomBinder:at,tileBinder:L(P,X),cullMethod:B(te,ft,He,Vt,Ai),uniformSet:"fontFill",subRenderIndex:1,isOverlappedObject:!0}]},dashedLine:{stroke:[{programName:"stripedLine",vaoCreator:ks,stateBinder:Me,needsVisibilityBuffer:!1,commonBinder:W(q,V,Z,se),programBinder:La,layerBinder:A,objectBinder:E(Zi,qi,ji,xe,Gt),tileBinder:L(X,P),cullMethod:B(U,Ke,ce)},{identify:!0,programName:"stripedLineIdentify",vaoCreator:ks,stateBinder:ia,needsVisibilityBuffer:!1,commonBinder:se,programBinder:Ca,objectBinder:E(Zi,qi,xe,ji,Gt),tileBinder:P,cullMethod:B(U,Ke,ce)}],stroke3d:[{programName:"stripedLine3D",vaoCreator:Us,stateBinder:$n,needsVisibilityBuffer:!1,commonBinder:W(q,V,Z),programBinder:Eu,layerBinder:A,objectBinder:E(Zi,qi,ji,xe,Gt,F),tileBinder:L(X,P,D),cullMethod:B(U,Ke),is3dMapAware:!0},{identify:!0,programName:"stripedLine3DIdentify",vaoCreator:Us,stateBinder:he,needsVisibilityBuffer:!1,programBinder:Iu,objectBinder:E(Zi,qi,xe,ji,Gt,F),tileBinder:L(P,D),cullMethod:B(U,Ke),is3dMapAware:!0}]},oneWayLine:{raster:[{programName:"oneWayLine",vaoCreator:qs,stateBinder:Kn,needsVisibilityBuffer:!1,commonBinder:W(At,Jt,se),programBinder:Sa,objectBinder:E(pt,de,Wi,Da),tileBinder:P,cullMethod:B(ft,He,rr)},{programName:"oneWayLine",vaoCreator:qs,stateBinder:qn,commonBinder:W(At,Jt,se),programBinder:Sa,needsVisibilityBuffer:!1,objectBinder:E(pt,de,Wi,Da),tileBinder:P,cullMethod:B(ft,He,rr),isOverlappedObject:!0}]},point:{raster:[{programName:"pointSprite",vaoCreator:qd,stateBinder:Xn,needsVisibilityBuffer:!1,commonBinder:ti(V,Z,Is,Ii,se),programBinder:yu,layerBinder:Ae,objectBinder:E(Fu,ho,uo,ri,F,le),cullMethod:B(He,te,So,bo,ft),tileBinder:L(Le,X,D),is3dMapAware:!0,forcePrerenderUnderCacheInDemMode:!0},{identify:!0,programName:"pointSpriteIdentify",vaoCreator:Qd,stateBinder:_t,needsVisibilityBuffer:!1,commonBinder:se,programBinder:Ta,objectBinder:E(ho,uo,ri,F,le),tileBinder:L(Le,D),cullMethod:B(He,te,So,bo,er),is3dMapAware:!0},{labelTest:!0,programName:"pointSpriteIdentify",vaoCreator:Yd,stateBinder:_t,needsVisibilityBuffer:!1,commonBinder:se,programBinder:Ta,objectBinder:E(ho,uo,ri,F,le),tileBinder:L(Le,D),cullMethod:B(He,te,So,bo,er),is3dMapAware:!0}],text:[{programName:"labelPoint",vaoCreator:Gs,stateBinder:Xn,needsVisibilityBuffer:!1,commonBinder:ti(V,Z,Ii,se),programBinder:Ma,objectBinder:E(pt,Ut,St,ka,Qi,ri,F,le),tileBinder:L(Le,X,D),cullMethod:B(He,te,ft,Vt,nr,To),uniformSet:"fontHalo",subRenderIndex:1,is3dMapAware:!0,forcePrerenderUnderCacheInDemMode:!0},{programName:"labelPoint",vaoCreator:Gs,stateBinder:Xn,needsVisibilityBuffer:!1,commonBinder:W(V,Z,Ii,se),programBinder:Ma,objectBinder:E(pt,Ut,St,ka,Qi,ri,F,le),tileBinder:L(Le,X,D),cullMethod:B(He,te,ft,Vt,nr),uniformSet:"fontFill",subRenderIndex:2,is3dMapAware:!0,forcePrerenderUnderCacheInDemMode:!0},{identify:!0,programName:"labelPointIdentify",vaoCreator:jd,stateBinder:_t,needsVisibilityBuffer:!1,commonBinder:se,programBinder:_e(ee),objectBinder:E(St,Qi,F,le),tileBinder:L(Le,D),cullMethod:B(He,te,Sh),subRenderIndex:1,is3dMapAware:!0}],labelingTexture:[{depthTest:!0,programName:"pointDepthTest",vaoCreator:Jd,stateBinder:ia,needsVisibilityBuffer:!1,commonBinder:se,programBinder:ee,objectBinder:E(Qi,F,le),tileBinder:L(P,D),cullMethod:B(He,te),is3dMapAware:!0}]},buildingModel:{fill:[{programName:"zbmModel",vaoCreator:Ad,stateBinder:oa,needsVisibilityBuffer:!1,commonBinder:W(V,Z,q),programBinder:Cu,layerBinder:be(A,Ae,et),objectBinder:E(de,fo,ku,F),tileBinder:L(X,P,D),cullMethod:B(wo,U,or,Ve,Io),subRenderIndex:2,is3dMapAware:!0},{programName:"zbmModelIdentify",vaoCreator:e_,stateBinder:he,needsVisibilityBuffer:!1,commonBinder:se,objectBinder:E(F),tileBinder:L(P,D),cullMethod:B(wo,U,or,Ve,Io),subRenderIndex:2,identify:!0,is3dMapAware:!0},{programName:"zbmModelIdentify",vaoCreator:t_,stateBinder:he,needsVisibilityBuffer:!1,commonBinder:se,objectBinder:E(F),tileBinder:L(P,D),cullMethod:U,depthTest:!0,is3dMapAware:!0},{programName:"zbmShadow",vaoCreator:i_,stateBinder:Oi,needsVisibilityBuffer:!1,programBinder:ee,objectBinder:E(fo,F),tileBinder:L(P,D),cullMethod:U,shadow:!0,is3dMapAware:!0}],stroke:[{programName:"simpleLine3d",vaoCreator:Gn,stateBinder:Rt,needsVisibilityBuffer:!0,commonBinder:W(se,V,Z,q),programBinder:Vi,layerBinder:be(A,Li),objectBinder:E(de,Ce,fo,Ht,F,mo),tileBinder:L(P,X,D),cullMethod:B(U,wo,ci,di,Io),subRenderIndex:5,is3dMapAware:!0}]},shiftedLine:{solid:[{programName:"road",commonBinder:W(V,Z,q),programBinder:_e(Xe,Pe),vaoCreator:Ud,stateBinder:Me,needsVisibilityBuffer:!1,layerBinder:A,objectBinder:E(de,Ce,za),tileBinder:L(X,P),zoomBinder:at,cullMethod:B(U,Ke,Ve)}]},circle:{fill:[{programName:"circleMarker",vaoCreator:Hn,stateBinder:Me,needsVisibilityBuffer:!1,commonBinder:W(V,q,Z,se),programBinder:co,layerBinder:A,objectBinder:E(de,Ce,F),cullMethod:B(U,Ke,Ve),tileBinder:L(Le,X,D),subRenderIndex:2,is3dMapAware:!0},{programName:"circleMarker",vaoCreator:Hn,stateBinder:Me,needsVisibilityBuffer:!1,commonBinder:W(V,q,Z,se),programBinder:co,layerBinder:A,objectBinder:E(de,Ce,F),cullMethod:B(U,Eh,di),tileBinder:L(Le,X,D),subRenderIndex:1,is3dMapAware:!0},{programName:"circleMarker",vaoCreator:Hn,stateBinder:Me,needsVisibilityBuffer:!1,commonBinder:W(V,q,Z,se),programBinder:co,layerBinder:A,objectBinder:E(de,Ce,F),cullMethod:B(U,Ih,zh),tileBinder:L(Le,X,D),is3dMapAware:!0},{identify:!0,programName:"circleMarkerIdentify",vaoCreator:o_,stateBinder:_t,programBinder:ee,needsVisibilityBuffer:!1,commonBinder:se,objectBinder:E(Ce,F),cullMethod:B(U,Ch),tileBinder:L(Le,D),is3dMapAware:!0}]},arrow:{stroke:[{programName:"entrance",vaoCreator:Ys,stateBinder:Me,needsVisibilityBuffer:!1,commonBinder:W(At,Jt,V,Z,se),programBinder:Tu,objectBinder:E(de,Wi,Ru,Oa,xe),tileBinder:L(P,X),cullMethod:B(U,Ve)},{identify:!0,programName:"entranceIdentify",vaoCreator:Ys,stateBinder:_t,needsVisibilityBuffer:!1,commonBinder:W(At,Jt,se),programBinder:bu,objectBinder:E(Wi,Oa,xe),tileBinder:P,cullMethod:B(U,Ve)}]},lineExtrusion:{fill:[{programName:"gradientDiffuse",vaoCreator:Xd,stateBinder:v_,needsVisibilityBuffer:!0,commonBinder:W(V,Z,q),programBinder:Nt,layerBinder:be(A,et),objectBinder:E(Ki,de,ai,xe,F,Ht,ja,li),tileBinder:L(X,P,D),cullMethod:B(U,te,ce,en,Mo),subRenderIndex:9,is3dMapAware:!0},{programName:"buildingShadow",shadow:!0,vaoCreator:Kd,stateBinder:Ni,needsVisibilityBuffer:!0,programBinder:ee,objectBinder:E(Ki,F,Ht),tileBinder:L(P,D),cullMethod:B(U,te,ce),is3dMapAware:!0}],sideStroke:[{programName:"line",vaoCreator:Ks,stateBinder:Rt,needsVisibilityBuffer:!0,commonBinder:W(V,q,Z,se),programBinder:Ia,layerBinder:A,objectBinder:E(Ki,de,ai,xe,F,Ht),tileBinder:L(X,P,D),cullMethod:B(U,te,ce,cr,ar),subRenderIndex:10,is3dMapAware:!0}],topStroke:[{programName:"simpleLine3d",vaoCreator:Gn,stateBinder:Rt,needsVisibilityBuffer:!0,commonBinder:W(se,V,Z,q),programBinder:Vi,layerBinder:be(A,Li),objectBinder:E(Ki,de,Ce,F,Ht,mo),tileBinder:L(X,P,D),cullMethod:B(U,te,ce,ci,di),subRenderIndex:11,is3dMapAware:!0}]},gltfModel:{instances:[{programName:"gltfModel",vaoCreator:Fi(!1),instanceBinder:nn,commonBinder:W(V,Z,q),programBinder:Mu,layerBinder:be(A,et,Pi),stateBinder:oa,needsVisibilityBuffer:!1,objectBinder:E(de,Gu,go,Uu,F,$i,le,Xi),tileBinder:L(Le,rn,_f,D,an),cullMethod:B(Co,_r),is3dMapAware:!0},{identify:!0,programName:"gltfModelIdentify",instanceBinder:nn,vaoCreator:Fi(!1),stateBinder:he,needsVisibilityBuffer:!1,layerBinder:Pi,commonBinder:ti(V,Z),programBinder:ee,objectBinder:E(F,$i,rt,le,Xi),tileBinder:L(Le,rn,D,an),cullMethod:B(Co,_r),is3dMapAware:!0},{depthTest:!0,programName:"gltfModelIdentify",instanceBinder:nn,vaoCreator:Fi(!0),stateBinder:he,needsVisibilityBuffer:!1,commonBinder:ti(V,Z),programBinder:ee,layerBinder:Pi,objectBinder:E(F,$i,le,Xi),tileBinder:L(Le,rn,D,an),cullMethod:Co,is3dMapAware:!0},{shadow:!0,programName:"gltfModelShadow",instanceBinder:nn,vaoCreator:Fi(!1),stateBinder:Oi,needsVisibilityBuffer:!1,programBinder:ee,layerBinder:Pi,objectBinder:E(F,$i,Xi),tileBinder:L(Le,rn,D,an),cullMethod:Dh,is3dMapAware:!0}]},raster:{fill:[{programName:"rectWithTexture",vaoCreator:s_,stateBinder:Me,needsVisibilityBuffer:!1,commonBinder:ti(V,Z),layerBinder:Ae,objectBinder:E(Ra,Du),tileBinder:L(P,X),cullMethod:B(Xa,U)}]},heatmap:{framebuffer:[{programName:"heatmap",vaoCreator:a_,stateBinder:sa,needsVisibilityBuffer:!1,commonBinder:Ps,objectBinder:E(Hu,Vu),zoomBinder:at,tileBinder:L(P,X),cullMethod:B(U,Lh)}],fill:[{programName:"heatmapTexture",vaoCreator:r_,stateBinder:Me,needsVisibilityBuffer:!1,layerBinder:Ae,objectBinder:E(Ra,Nu,Ou),tileBinder:X,cullMethod:B(U,Xa,yh),subRenderIndex:1}]},dem:{mesh:[{programName:"demMesh",vaoCreator:Ri,commonBinder:W(V,Z,q),programBinder:tt,layerBinder:A,stateBinder:he,needsVisibilityBuffer:!1,objectBinder:E(F,Ga,Va),tileBinder:L(P,X,sn,D),cullMethod:B(Ka,qa),is3dMapAware:!0},{programName:"demGround",demGround:!0,vaoCreator:Ri,programBinder:ee,tileBinder:L(P,X,D),stateBinder:he,needsVisibilityBuffer:!1,objectBinder:E(F)},{identify:!0,programName:"demMesh",vaoCreator:Ri,programBinder:_e(ee,lo),stateBinder:he,needsVisibilityBuffer:!1,objectBinder:E(Ha,F),tileBinder:L(P,sn,D),cullMethod:Ya,is3dMapAware:!0}],mesh2:[{dem:!0,programName:"demElevation",vaoCreator:ii,stateBinder:b_,needsVisibilityBuffer:!1,tileBinder:P,objectBinder:E()},{programName:"demGround2",demGround:!0,vaoCreator:ii,programBinder:ee,tileBinder:L(P,X,D),stateBinder:he,needsVisibilityBuffer:!1,objectBinder:E(F)},{programName:"demMesh2",vaoCreator:ii,commonBinder:W(V,Z,q),programBinder:tt,layerBinder:A,stateBinder:he,needsVisibilityBuffer:!1,objectBinder:E(vo,Ga,Va,F),tileBinder:L(P,X,sn,D),cullMethod:B(Ka,qa)},{identify:!0,programName:"demMesh2",vaoCreator:ii,programBinder:_e(ee,lo),stateBinder:he,needsVisibilityBuffer:!1,objectBinder:E(vo,Ha,F),tileBinder:L(P,sn,D),cullMethod:Ya},{depthTest:!0,programName:"demMesh2",vaoCreator:ii,programBinder:_e(ee,lo),layerBinder:A,stateBinder:he,needsVisibilityBuffer:!1,objectBinder:E(vo,F),tileBinder:L(P,D)}],hillshade:[{programName:"demHillshade",vaoCreator:Vn,stateBinder:_t,needsVisibilityBuffer:!1,programBinder:ee,objectBinder:E(F),tileBinder:L(P,D)}],flatBottom:[{programName:"demFlatBottom",vaoCreator:l_,stateBinder:ta,needsVisibilityBuffer:!1,objectBinder:E(Zu,F),tileBinder:L(P,D),cullMethod:bh}]},mapMesh:{fill:[{programName:"mapMesh",vaoCreator:jn,stateBinder:na,needsVisibilityBuffer:!1,zoomBinder:E(po),commonBinder:W(V,Z,q),programBinder:tt,layerBinder:be(A,et),objectBinder:E(go,Ue,F,Ge,rt),tileBinder:L(X,P,D),cullMethod:B(U,xo),subRenderIndex:Number.MAX_SAFE_INTEGER,is3dMapAware:!0},{identify:!0,programName:"mapMesh",vaoCreator:jn,stateBinder:he,needsVisibilityBuffer:!1,zoomBinder:E(po),commonBinder:W(V,Z,q),programBinder:tt,layerBinder:be(A,et),objectBinder:E(go,Ue,F,Ge,rt),tileBinder:L(P,D),cullMethod:B(U,xo),subRenderIndex:Number.MAX_SAFE_INTEGER,is3dMapAware:!0},{depthTest:!0,programName:"mapMesh",vaoCreator:jn,stateBinder:he,needsVisibilityBuffer:!1,zoomBinder:E(po),commonBinder:W(V,Z,q),programBinder:tt,layerBinder:be(A,et),objectBinder:E(Ue,F,Ge,rt),tileBinder:L(P,D),cullMethod:U,subRenderIndex:Number.MAX_SAFE_INTEGER,is3dMapAware:!0},{programName:"meshShadow",shadow:!0,vaoCreator:Vs,stateBinder:Ni,needsVisibilityBuffer:!1,programBinder:ee,objectBinder:E(Ue,F,Ge),tileBinder:L(P,D),cullMethod:U,is3dMapAware:!0}]},globe:{fill:[{programName:"globe",vaoCreator:Js,stateBinder:he,objectBinder:E(Na),tileBinder:Le,needsVisibilityBuffer:!1,is3dMapAware:!0},{identify:!0,programName:"globe",vaoCreator:Js,stateBinder:he,objectBinder:E(Na),tileBinder:Le,needsVisibilityBuffer:!1,is3dMapAware:!0}]}}}class ff{constructor(e){this.gl=e,this.ext=e.getExtension("EXT_disjoint_timer_query"),this.queries=[]}addTimer(){if(!this.ext)return;const e=this.ext.createQueryEXT();this.queries.push(e),this.ext.beginQueryEXT(this.ext.TIME_ELAPSED_EXT,e)}stopTimer(){!this.ext||!this.queries.length||this.ext.endQueryEXT(this.ext.TIME_ELAPSED_EXT)}tryToGetFirstTimerValue(){if(!this.ext)return;const e=this.queries[0];if(!e)return;const t=this.ext,i=t.getQueryObjectEXT(e,t.QUERY_RESULT_AVAILABLE_EXT),o=this.gl.getParameter(t.GPU_DISJOINT_EXT);if(!i||o)return;const a=t.getQueryObjectEXT(e,t.QUERY_RESULT_EXT);return t.deleteQueryEXT(e),this.queries.shift(),Number(a)}}const mf=`
float affine_step(const float edge0, const float edge1, const float x)
{
    return clamp((x - edge0) / (edge1 - edge0), 0., 1.);
}
`,Er=`
vec4 apply_opacity(const vec4 color, const float opacity)
{
return color * opacity;
}
`,pf=`struct ArrowDistanceParameters
{
    vec2 wing_normal;
    vec2 tip_normal;
    vec2 mirrored_wing_normal;
    vec2 mirrored_tip_normal;
    float width;
    float full_length;
    float arrow_height;
    float tip_radius;
    vec2 tip_circle_center;
    float wing_radius;
    vec2 wing_circle_center;
    float border_width;
};
ArrowDistanceParameters calculate_arrow_distance_parameters(
    const vec2 wing_normal,
    const vec2 tip_normal,
    const float width_zpt,
    const float length_zpt,
    const float tip_height_multiplier,
    const float wing_height_multiplier,
    const float tip_radius_zpt,
    const float wing_radius_zpt,
    const float border_width_zpt,
    const vec2 tip_circle_center,
    const vec2 wing_circle_center)
{
    vec2 mirrored_wing_normal = vec2(wing_normal.x, -wing_normal.y);
    vec2 mirrored_tip_normal = vec2(tip_normal.x, -tip_normal.y);
    float width = 0.5 * width_zpt;
    float length = 0.5 * length_zpt;
    float arrow_height = width_zpt * (tip_height_multiplier - wing_height_multiplier);
    return ArrowDistanceParameters(
        wing_normal,
        tip_normal,
        mirrored_wing_normal,
        mirrored_tip_normal,
        width,
        length,
        arrow_height,
        tip_radius_zpt,
        tip_circle_center,
        wing_radius_zpt,
        wing_circle_center,
        border_width_zpt);
}
struct ArrowDistances
{
    float top_tip_cut;
    float bottom_tip_cut;
    float line;
    float bottom_left_wing;
    float bottom_right_wing;
    float top_left_wing;
    float top_right_wing;
    float tip_circle;
    float tip_circle_cut;
    float left_wing_circle;
    float left_wing_circle_cut;
    float right_wing_circle;
    float right_wing_circle_cut;
};
ArrowDistances calculate_arrow_distances(
    const ArrowDistanceParameters arrow_parameters,
    const vec2 texcoord,
    const float offset,
    const mat2 derivatives)
{
    float derivatives_x_multiplier = 1. / max(abs(derivatives[0].x), abs(derivatives[1].x));
    float dt = ( texcoord.x - arrow_parameters.full_length - offset) * derivatives_x_multiplier;
    float d0 = (-texcoord.x - arrow_parameters.full_length - offset) * derivatives_x_multiplier;
    float d1 = (abs(texcoord.y) - arrow_parameters.width - offset) / max(abs(derivatives[0].y), abs(derivatives[1].y));
    float d2 = (dot(texcoord - vec2(arrow_parameters.full_length - arrow_parameters.arrow_height, 0.), arrow_parameters.wing_normal) - offset) / max(abs(dot(derivatives[0], arrow_parameters.wing_normal)), abs(dot(derivatives[1], arrow_parameters.wing_normal)));
    float d3 = (dot(texcoord - vec2(arrow_parameters.full_length - arrow_parameters.arrow_height, 0.), arrow_parameters.mirrored_wing_normal) - offset) / max(abs(dot(derivatives[0], arrow_parameters.mirrored_wing_normal)), abs(dot(derivatives[1], arrow_parameters.mirrored_wing_normal)));
    float d4 = (dot(texcoord - vec2(arrow_parameters.full_length, 0.), arrow_parameters.tip_normal) - offset) / max(abs(dot(derivatives[0], arrow_parameters.tip_normal)), abs(dot(derivatives[1], arrow_parameters.tip_normal)));
    float d5 = (dot(texcoord - vec2(arrow_parameters.full_length, 0.), arrow_parameters.mirrored_tip_normal) - offset) / max(abs(dot(derivatives[0], arrow_parameters.mirrored_tip_normal)), abs(dot(derivatives[1], arrow_parameters.mirrored_tip_normal)));
    
    float tip_circle_cut = sdf_half_planes_cut(
        texcoord,
        arrow_parameters.tip_normal,
        -arrow_parameters.mirrored_tip_normal,
        arrow_parameters.tip_circle_center,
        derivatives);
    float tip_circle = sdf_circle(
        texcoord - arrow_parameters.tip_circle_center,
        arrow_parameters.tip_radius + offset - arrow_parameters.border_width);
    vec2 tip_circle_normal = normalize(texcoord - arrow_parameters.tip_circle_center);
    tip_circle = tip_circle / max(abs(dot(derivatives[0], tip_circle_normal)), abs(dot(derivatives[1], tip_circle_normal)));
    
    vec2 right_wing_circle_center = vec2(arrow_parameters.wing_circle_center.x, -arrow_parameters.wing_circle_center.y);
    vec2 left_wing_circle_normal = normalize(texcoord - arrow_parameters.wing_circle_center);
    vec2 right_wing_circle_normal = normalize(texcoord - right_wing_circle_center);
    float left_wing_circle = sdf_circle(texcoord - arrow_parameters.wing_circle_center,
        arrow_parameters.wing_radius + offset - arrow_parameters.border_width);
        left_wing_circle = left_wing_circle / max(abs(dot(derivatives[0], left_wing_circle_normal)), abs(dot(derivatives[1], left_wing_circle_normal)));
    float right_wing_circle = sdf_circle(texcoord - right_wing_circle_center,
        arrow_parameters.wing_radius + offset - arrow_parameters.border_width);
        right_wing_circle = right_wing_circle / max(abs(dot(derivatives[0], right_wing_circle_normal)), abs(dot(derivatives[1], right_wing_circle_normal)));
    float left_wing_circle_cut = sdf_half_planes_cut(
        texcoord,
        -arrow_parameters.tip_normal,
        arrow_parameters.wing_normal,
        arrow_parameters.wing_circle_center,
        derivatives);
    float right_wing_circle_cut = sdf_half_planes_cut(
        texcoord,
        arrow_parameters.mirrored_tip_normal,
        -arrow_parameters.mirrored_wing_normal,
        right_wing_circle_center,
        derivatives);
    return ArrowDistances(
        dt,
        d0,
        d1,
        d2,
        d3,
        d4,
        d5,
        tip_circle,
        tip_circle_cut,
        left_wing_circle,
        left_wing_circle_cut,
        right_wing_circle,
        right_wing_circle_cut);
}
`,vf=`
#ifdef WEBGL2
#define UNPACK_BOOL1(packedValue) ((packedValue & 0x1) != 0)
#define UNPACK_BOOL2(packedValue) ((packedValue & 0x2) != 0)
#define UNPACK_BOOL3(packedValue) ((packedValue & 0x4) != 0)
#else
#define UNPACK_BOOL1(packedValue) (int(mod(float(packedValue), 2.0)) == 1)
#define UNPACK_BOOL2(packedValue) (int(mod(float(packedValue) / 2.0, 2.0)) == 1)
#define UNPACK_BOOL3(packedValue) (int(mod(float(packedValue) / 4.0, 2.0)) == 1)
#endif
`,Ir=`#ifndef UBO
uniform highp vec3 u_cam_pos;
#endif
`,gf=`
const float g_distance_precision_limit = 1e-4;
struct CircleDistance
{
    float distance;
    float width;
};
CircleDistance circle_color_distance(
    const mat2 derivatives,
    const vec2 circle,
    const float circle_width)
{
    float circle_length = length(circle);
    float distance = circle_length - circle_width;
    
    
    
    vec2 circle_dx = derivatives[0];
    vec2 circle_dy = derivatives[1];
    
    float distance_dx = dot(circle, circle_dx);
    float distance_dy = dot(circle, circle_dy);
    
    float derivative_denominator = circle_length;
    float width = max(abs(distance_dx), abs(distance_dy));
    return CircleDistance(
        distance * derivative_denominator,
        width);
}
vec4 distance_to_color(
    const float fill_distance,
    const float border_distance,
    const vec4 fill_color,
    const vec4 border_color)
{
    float fill_factor = affine_step(-1., 0., fill_distance);
    float border_factor = affine_step(0., 1., border_distance);
    return
        mix(mix(fill_color, border_color, fill_factor), vec4(.0), border_factor);
}
vec4 distance_to_color(
    const CircleDistance circle_distance,
    const vec4 fill_color)
{
    
    
    float fill_factor = circle_distance.distance < g_distance_precision_limit
        ? 0.
        : affine_step(0., circle_distance.width, circle_distance.distance);
    return mix(fill_color, vec4(0.), fill_factor);
}
`,yf=`
#ifndef VARYINGS_LIMIT_9
    varying vec2 v_vec2_dem_tex_pos;
    varying float v_float_dem_invalid;
#endif
int check_dem_invalid() {
    #ifndef VARYINGS_LIMIT_9
    if (v_float_dem_invalid != 0. || v_vec2_dem_tex_pos.x < 0. || v_vec2_dem_tex_pos.x > 1. || v_vec2_dem_tex_pos.y < 0. || v_vec2_dem_tex_pos.y > 1.) {
        return 1;
    }
    #endif
    return 0;
}
`,bf=`#ifdef WEBGL1
#extension GL_OES_standard_derivatives: enable
#endif
`,xf=`
#define LINEAR 0
#define EXP 1
#define FOG_EQUATION (LINEAR)
#define EPSILON (0.0001)
#ifndef UBO
# ifdef FOG
uniform vec4 u_fog_color;
uniform vec2 u_fog_limits;
uniform float u_fog_horizon_blend;
uniform float u_fog_horizon_level;
# endif
#endif 
#if defined(FOG) || defined(SKY)
# ifndef UBO
uniform vec4 u_sky_color;
uniform float u_fog_horizon_pad;
# endif
varying vec3 v_fog_pos;
#endif
#ifdef FOG
float fog_horizon_blending(vec3 camera_dir, float blend) {
    blend = EPSILON + blend;
    float t = max(camera_dir.z / blend, 0.0);
    
    return exp(-3.0 * t * t);
}
float fog_exponential(float t) {
    const float decay = 6.0;
    float falloff = 1.0 - min(1.0, exp(-decay * t));
    
    falloff *= falloff * falloff;
    
    return min(1.0, 1.00747 * falloff);
}
float fog_depth(float depth) {
    float start = u_fog_limits.x;
    float end = u_fog_limits.y;
    float range = end - start;
    float fac = (depth - start) / range;
#if (FOG_EQUATION == LINEAR)
    
    fac = clamp(fac, 0.0, 1.0);
#elif (FOG_EQUATION == EXP)
    fac = fog_exponential(fac);
#endif
    return fac;
}
float calc_depth_fog() {
    float depth = length(v_fog_pos);
    float fac = fog_depth(depth);
    return fac;
}
vec3 calc_fog_color() {
    float depth = length(v_fog_pos);
    vec3 dir = v_fog_pos / depth;
    
    dir.z -= u_fog_horizon_level;
    float fog_blend = fog_horizon_blending(dir, u_fog_horizon_blend);
    if (u_sky_color.a <= 0.01) {
        return u_fog_color.rgb / u_fog_color.a;
    } else {
        
        return mix(u_sky_color.rgb / u_sky_color.a, u_fog_color.rgb / u_fog_color.a, min(fog_blend + (1.0 - u_sky_color.a), 1.0));
    }
}
#endif 
vec4 apply_fog(vec4 color) {
#ifdef FOG
    if (u_fog_color.a <= 0.01) {
        return color;
    }
    float alpha = EPSILON + color.a;
    float fac = calc_depth_fog();
    vec3 fog_color = calc_fog_color();
    color.rgb /= alpha;
    color.rgb = mix(color.rgb, fog_color, fac * u_fog_color.a);
    color.rgb *= alpha;
#endif
    return color;
}
vec4 apply_fog_alpha(vec4 color) {
#ifdef FOG
    if (u_fog_color.a <= 0.01) {
        return color;
    }
    color *= 1.0 - calc_depth_fog();
#endif
    return color;
}
vec4 apply_fog_sky(vec4 color) {
#ifdef FOG
    float alpha = EPSILON + color.a;
    float depth = length(v_fog_pos);
    vec3 dir = v_fog_pos / depth;
    
    dir.z -= u_fog_horizon_level;
    float fac = fog_horizon_blending(dir, u_fog_horizon_blend);
    color.rgb /= alpha;
    color.rgb = mix(color.rgb, u_fog_color.rgb, fac * u_fog_color.a);
    color.rgb *= alpha;
#endif
    return color;
}`,wf=`#define FRAGMENT_NORMAL
vec3 calc_fragment_normal(vec3 vertex) {
    vec3 dx = dFdx(vertex);
    vec3 dy = dFdy(vertex);
    return normalize(cross(dx, dy));
}`,Sf=`precision highp float;
`,Tf=`#ifdef UBO
uniform LightSettings
{
    vec3 u_vec3_light_dir1_direction;
    vec4 u_vec4_light_dir1_color;
    vec3 u_vec3_light_dir2_direction;
    vec4 u_vec4_light_dir2_color;
    vec4 u_vec4_ambient_color;
};
#else
uniform vec3 u_vec3_light_dir1_direction;
uniform vec4 u_vec4_light_dir1_color;
uniform vec3 u_vec3_light_dir2_direction;
uniform vec4 u_vec4_light_dir2_color;
uniform vec4 u_vec4_ambient_color;
#endif
uniform int u_int_light_flags;
vec4 light_factor(vec3 normal) {
    bool use_light = UNPACK_BOOL1(u_int_light_flags);
    if (!use_light) { 
        return vec4(1.);
    }
    float light_1_factor = max(dot(normal, -u_vec3_light_dir1_direction), 0.0);
    float light_2_factor = max(dot(normal, -u_vec3_light_dir2_direction), 0.0);
    if (UNPACK_BOOL2(u_int_light_flags)) {
        light_1_factor *= compute_shadow_factor();
    } else if (UNPACK_BOOL3(u_int_light_flags)) {
        light_2_factor *= compute_shadow_factor();
    }
    vec3 direct_light_contrib = u_vec4_light_dir1_color[3] * light_1_factor * u_vec4_light_dir1_color.rgb;
    vec3 shading_light_contrib = u_vec4_light_dir2_color[3] * light_2_factor * u_vec4_light_dir2_color.rgb;
    return vec4(u_vec4_ambient_color[3] * u_vec4_ambient_color.rgb + direct_light_contrib + shading_light_contrib, 1.0);
}
float light_factor_dem(vec3 normal) {
    bool use_light = UNPACK_BOOL1(u_int_light_flags);
    if (!use_light) { 
        return 1.;
    }
    float light_1_factor = dot(normal, -u_vec3_light_dir1_direction);
    
    
    
    
    return light_1_factor;
}
vec4 light_factor(vec3 normal, vec3 pos_world) {
    
    if (dot(u_cam_pos - pos_world, normal) < 0.) {
        normal *= vec3(-1.);
    }
    return light_factor(normal);
}
vec4 light_factor_surface() {
    bool use_light = UNPACK_BOOL1(u_int_light_flags);
    if (!use_light) {
        return vec4(1.);
    }
    vec3 normal = vec3(0., 0., 1.);
    float light_1_factor = max(dot(normal, -u_vec3_light_dir1_direction), 0.0);
    float light_2_factor = max(dot(normal, -u_vec3_light_dir2_direction), 0.0);
    if (UNPACK_BOOL2(u_int_light_flags)) {
        light_1_factor *= compute_shadow_factor();
    } else if (UNPACK_BOOL3(u_int_light_flags)) {
        light_2_factor *= compute_shadow_factor();
    }
     return vec4(u_vec4_ambient_color[3] * u_vec4_ambient_color.rgb
         + u_vec4_light_dir1_color[3] * light_1_factor * u_vec4_light_dir1_color.rgb
         + u_vec4_light_dir2_color[3] * light_2_factor * u_vec4_light_dir2_color.rgb, 1.0);
}
vec4 light_factor_dem2(vec3 normal, float shade_factor) {
    vec3 normal_faded = normalize(normal * vec3(1., 1., max(1. - shade_factor, 0.01)));
    float light_1_factor = max(dot(normal_faded, -u_vec3_light_dir1_direction), - shade_factor);
    float light_2_factor = max(dot(normal_faded, -u_vec3_light_dir2_direction), - shade_factor);
    if (UNPACK_BOOL2(u_int_light_flags)) {
        light_1_factor *= compute_shadow_factor();
    } else if (UNPACK_BOOL3(u_int_light_flags)) {
        light_2_factor *= compute_shadow_factor();
    }
    vec3 direct_light_contrib = u_vec4_light_dir1_color[3] * light_1_factor * u_vec4_light_dir1_color.rgb;
    vec3 shading_light_contrib = u_vec4_light_dir2_color[3] * light_2_factor * u_vec4_light_dir2_color.rgb;
    return vec4(u_vec4_ambient_color[3] * u_vec4_ambient_color.rgb + direct_light_contrib + shading_light_contrib, 1.0);
}`,Mf=`
#define LIGHT_MODEL_PBR 2
#ifdef LIGHT_MODEL
#if LIGHT_MODEL == LIGHT_MODEL_PBR
    const float PI = 3.14159265359;
    
    float D(float alpha, vec3 N, vec3 H) {
        float numerator = alpha * alpha;
        float NdotH = max(dot(N, H), 0.);
        float denominator = PI * pow(
            NdotH * NdotH * (alpha * alpha - 1.) + 1.,
            2.
        );
        return numerator / max(denominator, 0.000001);
    }
    
    float G1(float alpha, vec3 N, vec3 X) {
        float numerator = max(dot(N, X), 0.);
        float k = alpha / 2.;
        float denominator = max(dot(N, X), 0.) * (1. - k) + k;
        return numerator / max(denominator, 0.000001);
    }
    
    float G(float alpha, vec3 N, vec3 V, vec3 L) {
        return G1(alpha, N, V) * G1(alpha, N, L);
    }
    
    vec3 F(vec3 F0, vec3 V, vec3 H) {
        return F0 + (vec3(1.) - F0) * pow(1. - max(dot(V, H), 0.), 5.);
    }
    vec3 color_pbr(vec3 fragment_normal, vec3 fragment_pos_world, vec3 albedo, float roughness, float metallic) {
        float alpha = roughness * roughness;
        vec3 F0 = vec3(0.04);
        F0 = mix(F0, vec3(1.), metallic);
        
        vec3 emitted_light = u_vec4_ambient_color.rgb * u_vec4_ambient_color[3];
        vec3 N = fragment_normal;
        
        vec3 V = normalize(u_cam_pos - fragment_pos_world);
        
        vec3 L = -u_vec3_light_dir1_direction;
        
        vec3 H = normalize(V + L);
        float shadow_factor = compute_shadow_factor();
        vec3 Ks = F(F0, V, H);
        vec3 Kd = (vec3(1.0) - Ks) * (1. - metallic);
        vec3 lambert = albedo / PI;
        vec3 cookTorranceNumerator = D(alpha, N, H) * G(alpha, N, V, L) * Ks;
        float cookTorranceDenominator = 4.0 * max(dot(V, N), 0.) * max(dot(L, N), 0.);
        cookTorranceDenominator = max(cookTorranceDenominator, 0.000001);
        vec3 cookTorrance = cookTorranceNumerator / cookTorranceDenominator;
        vec3 BRDF = Kd * lambert + cookTorrance;
        vec3 outgoingLight = BRDF * u_vec4_light_dir1_color.rgb * u_vec4_light_dir1_color[3] * max(dot(L, N), 0.);
        vec3 ambient = u_vec4_ambient_color.rgb * u_vec4_ambient_color[3] * albedo;
        return ambient + outgoingLight * shadow_factor;
    }
#endif
#endif
`,Ef=`#define LIGHT_MODEL_PHONG 1
#ifdef LIGHT_MODEL
#if LIGHT_MODEL == LIGHT_MODEL_PHONG
const float g_specular_power_max = 32.0;
const float g_specular_power_min = 2.0;
vec2 pbr_to_gloss(vec3 material_attributes)
{
    float weight = material_attributes.x;
    float roughness = material_attributes.y;
    float metallic = material_attributes.z;
    
    
    float specular_strength = weight * metallic;
    float specular_power = roughness * (g_specular_power_min - g_specular_power_max) + g_specular_power_max;
    return vec2(specular_strength, specular_power);
}
vec3 color_phong(vec3 fragment_normal, highp vec3 fragment_pos_world, vec3 albedo, float roughness, float metallic) {
    vec2 specular_values = pbr_to_gloss(vec3(1., roughness, metallic));
    float specular_strength = specular_values.x;
    float specular_power = specular_values.y;
    
    float shadow_factor = compute_shadow_factor();
    
    vec3 ambient = u_vec4_ambient_color.rgb * u_vec4_ambient_color[3];
    
    float diff = max(dot(fragment_normal, -u_vec3_light_dir1_direction), 0.0);
    vec3 diffuse = u_vec4_light_dir1_color.rgb * u_vec4_light_dir1_color[3] * diff * shadow_factor;
    
    
    vec3 view_dir = normalize(u_cam_pos - fragment_pos_world);
    
    vec3 reflect_dir = reflect(u_vec3_light_dir1_direction, fragment_normal);
    float spec = pow(max(dot(view_dir, reflect_dir), 0.0), specular_power);
    vec3 specular = u_vec4_light_dir1_color.rgb * u_vec4_light_dir1_color[3] * spec * specular_strength * shadow_factor;
    return albedo * (ambient + diffuse) + specular;
}
#endif
#endif
`,If=`precision lowp float;
`,Cf=`precision mediump float;
`,Cr=`#define MIX_COLOR_MODE_READ_FROM_TARGET 1
#define MIX_COLOR_MODE_VERTEX_ATTRIBUTE 2
#define VERTEX_ATTRIBUTE_NAME_DENORMALIZED_DISTANCE_TO_LINE 1
`,Lf=`vec4 pack_float_to_vec4(float depth)
{
    const vec4 bit_shift = vec4(255.0 * 255.0 * 255.0, 255.0 * 255.0, 255.0, 1.0);
    const vec4 bit_mask = vec4(0.0, 1.0 / 255.0, 1.0 / 255.0, 1.0 / 255.0);
    vec4 res = fract(depth * bit_shift);
    res -= res.xxyz * bit_mask;
    return res;
}
float unpack_float_from_vec4(vec4 color)
{
    const vec4 bit_shift = vec4(1.0 / (255.0 * 255.0 * 255.0), 1.0 / (255.0 * 255.0), 1.0 / 255.0, 1.0);
    return dot(color, bit_shift);
}`,Pf=`#ifdef WEBGL2
#define varying in
#define attribute in
#define texture2D texture
#define gl_FragColor fragColor
out vec4 gl_FragColor;
#endif
#ifdef UBO
uniform CommonSettings
{
    mediump float u_float_rounding_factor;
    mediump float u_float_border_width_offset;
    mediump vec2 u_vec2_scale_limits;
    mediump vec2 u_vec2_depth_test_half_point_size;
    mediump vec2 u_vec2_vpt_size;
    
    mediump vec4 u_fog_color;
    mediump vec2 u_fog_limits;
    mediump float u_fog_horizon_blend;
    mediump float u_fog_horizon_level;
    mediump float u_fog_horizon_pad;
    mediump float u_fog_distance;
    mediump vec4 u_sky_color;
    highp vec3 u_cam_pos; 
    
    
    
    
    
    
    mediump vec4 u_shadow_map_params; 
    highp mat4 u_mat4_clip_to_shadow;
    mediump float u_shadow_bias;
    mediump mat4 u_mat4_view_transposed;
    mediump mat4 u_mat4_proj_inverted;
    
    mediump vec2 u_vec2_halo_viewport_size;
    mediump vec2 u_vec2_halo_viewport_center_shift;
    mediump vec4 u_vec4_halo_radius_stops;
    mediump vec4 u_vec4_halo_color;
    mediump float u_float_halo_exp_factor;
    mediump vec4 u_vec4_default_background_color;
    
    mediump mat4 u_mat4_stars;
    mediump float u_float_pixelratio;
    mediump float u_float_stars_intensity;
};
#endif
`,Bf=`#ifdef HAS_FRAG_DEPTH_EXT
#extension GL_EXT_frag_depth : require
#endif
`,zf=`uniform float u_sdtr_distance;
#ifdef SCREENDOOR
varying vec3 v_clipspace_pos;
#endif
float interleaved_gradient_noise()
{
    const vec3 m = vec3(0.06711056, 0.00583715, 52.9829189);
    return fract(m.z * fract(dot(gl_FragCoord.xy, m.xy)));
}
void apply_screendoor() {
    #ifdef SCREENDOOR
    if (u_sdtr_distance == 0.) {
        return;
    }
    float factor = smoothstep(0., u_sdtr_distance, v_clipspace_pos.z);
    float patternValue = interleaved_gradient_noise();
    float shaped = factor - patternValue;
    if (shaped <= 0.) {
        discard;
    }
    #endif
    return;
}
`,Rf=`#ifdef RENDER_SHADOWS
# if defined(WEBGL2) && defined(DEPTH_TEXTURE_SHADOW)
uniform mediump sampler2DShadow u_texture_shadow;
# else
uniform sampler2D u_texture_shadow;
# endif
# ifndef UBO
uniform mediump vec4 u_shadow_map_params;
# endif 
varying float v_depth_metric;
varying vec4 v_pos_from_light;
float get_shadow(vec3 coords) {
# if defined(WEBGL2) && defined(DEPTH_TEXTURE_SHADOW)
    
    return texture2D( u_texture_shadow, coords );
# else
# ifdef DEPTH_TEXTURE_SHADOW
    
    float shadow_depth = texture2D(u_texture_shadow, coords.xy, 0.).r;
# else
    
    
    float shadow_depth = unpack_float_from_vec4(texture2D(u_texture_shadow, coords.xy, 0.));
# endif
    float depth_diff = v_depth_metric - shadow_depth;
    if (depth_diff <= 0.) {
        return 1.0;
    }
    return 0.0;
# endif
}
float sample_shadow_texture(vec3 shadow_coord) {
    vec2 shadow_map_size = u_shadow_map_params.xy;
    float radius = u_shadow_map_params.z;
    vec2 texelSize = vec2( 1.0 ) / shadow_map_size;
    float dx0 = - texelSize.x * radius;
    float dy0 = - texelSize.y * radius;
    float dx1 = + texelSize.x * radius;
    float dy1 = + texelSize.y * radius;
    float dx2 = dx0 / 2.0;
    float dy2 = dy0 / 2.0;
    float dx3 = dx1 / 2.0;
    float dy3 = dy1 / 2.0;
    
    
    return (
        get_shadow( shadow_coord + vec3( dx0, dy0, 0.0 ) ) +
        get_shadow( shadow_coord + vec3( 0.0, dy0, 0.0 ) ) +
        get_shadow( shadow_coord + vec3( dx1, dy0, 0.0 ) ) +
        get_shadow( shadow_coord + vec3( dx2, dy2, 0.0 ) ) +
        get_shadow( shadow_coord + vec3( 0.0, dy2, 0.0 ) ) +
        get_shadow( shadow_coord + vec3( dx3, dy2, 0.0 ) ) +
        get_shadow( shadow_coord + vec3( dx0, 0.0, 0.0 ) ) +
        get_shadow( shadow_coord + vec3( dx2, 0.0, 0.0 ) ) +
        get_shadow( shadow_coord) +
        get_shadow( shadow_coord + vec3( dx3, 0.0, 0.0 ) ) +
        get_shadow( shadow_coord + vec3( dx1, 0.0, 0.0 ) ) +
        get_shadow( shadow_coord + vec3( dx2, dy3, 0.0 ) ) +
        get_shadow( shadow_coord + vec3( 0.0, dy3, 0.0 ) ) +
        get_shadow( shadow_coord + vec3( dx3, dy3, 0.0 ) ) +
        get_shadow( shadow_coord + vec3( dx0, dy1, 0.0 ) ) +
        get_shadow( shadow_coord + vec3( 0.0, dy1, 0.0 ) ) +
        get_shadow( shadow_coord + vec3( dx1, dy1, 0.0 ) )
    ) * ( 1.0 / 17.0 );
}
float compute_shadow_factor()
{
    vec4 light_pos = v_pos_from_light;
# ifdef FRAGMENT_NORMAL
    
    
    float normal_bias = u_shadow_map_params[3];
    vec3 norm_from_light = calc_fragment_normal(light_pos.xyz);
    light_pos.xyz -= normal_bias * norm_from_light;
# endif
    vec3 clip_space = light_pos.xyz / light_pos.w;
    
    float clip_factor = smoothstep(0.5, 1.0, length(clip_space));
    if (clip_factor >= 1.0) {
        return 1.0;
    }
# if defined(DEPTH_TEXTURE_SHADOW) && defined(WEBGL2)
    vec3 lightPovPositionInTexture = 0.5 * light_pos.xyz + 0.5;
    float shadow_factor = sample_shadow_texture(lightPovPositionInTexture);
# else
    vec3 uv = 0.5 * clip_space + vec3(0.5);
    float shadow_factor = sample_shadow_texture(uv);
# endif
    
    shadow_factor = mix(shadow_factor, 1.0, clip_factor);
    return shadow_factor;
}
#else  
float compute_shadow_factor()
{
    return 1.0;
}
#endif `,Lr=`#ifndef SIGNED_DISTANCE_FUNCTIONS_FSH
#define SIGNED_DISTANCE_FUNCTIONS_FSH
float sdf_intersect(const float distance1, const float distance2)
{
    return max(distance1, distance2);
}
float sdf_merge(const float distance1, const float distance2)
{
    return min(distance1, distance2);
}
float sdf_difference(const float distance1, const float distance2)
{
    return max(distance1, -distance2);
}
float sdf_half_plane(const vec2 coords, const vec2 normal)
{
    return dot(coords, normal);
}
float sdf_circle(const vec2 coords, const float radius)
{
    return length(coords) - radius;
}
float sdf_half_planes_cut(const vec2 coords, const vec2 normal1, const vec2 normal2, const vec2 cut_point, const mat2 derivatives)
{
    vec2 cut_normal1 = vec2(normal1.y, -normal1.x);
    float cut1 = sdf_half_plane(coords - cut_point, cut_normal1) /
        max(abs(dot(derivatives[0], cut_normal1)), abs(dot(derivatives[1], cut_normal1)));
    vec2 cut_normal2 = vec2(normal2.y, -normal2.x);
    float cut2 = sdf_half_plane(coords - cut_point, cut_normal2) /
        max(abs(dot(derivatives[0], cut_normal2)), abs(dot(derivatives[1], cut_normal2)));
    return sdf_merge(cut1, cut2);
}
float sdf_box( in vec2 p, in vec2 b )
{
    vec2 d = abs(p)-b;
    return length(max(d,0.0)) + min(max(d.x,d.y),0.0);
}
float sdf_triangle(in vec2 p, in float width) {
    return abs(p.x) - (p.y + .5) * width * .5;
}
float dot2(in vec2 p) {
    return dot(p, p);
}
float sdf_chevron(in vec2 p, float width, float skew, float rounding)
{
    p.x = abs(p.x);
    if (p.y + p.x > 1.0) {
        return sqrt(dot2(p - vec2(0.25, 0.75))) - sqrt(2.0)/4.0;
    }
    return sqrt(min(dot2(p - vec2(0.00, 1.00)),
                    dot2(p - 0.5 * max(p.x + p.y, 0.0)))) * sign(p.x - p.y);
}
#endif
`,Ff=`#include <enable_standard_derivatives>
#include <highp_float>
#include <prelude>
#include <affine_step>
#include <signed_distance_functions>
#include <arrow_functions>
#include <circle_functions>
#include <fog>
uniform float u_float_tip_height_multiplier;
uniform float u_float_wing_height_multiplier;
uniform float u_float_wing_width_multiplier;
varying vec2 v_vec2_line_type_arrow_tail;
varying vec4 v_vec4_arrow_width_length_border_outer;
varying vec4 v_vec4_texcoord_arrow_line;
varying vec4 v_vec4_distance_vertex_hiding;
#ifdef ENTRANCE_ARROWS_ROUNDING
varying vec3 v_vec3_radius_tip_wing_tail;
#endif
varying vec4 v_vec4_circle_center_tip_wing;
varying vec4 v_vec4_color;
varying vec4 v_vec4_border_color;
const float g_type_arrow = 1.;
const float g_type_start_border = 2.;
bool lookalike(const float a, const float b)
{
    return abs(a - b) < 1e-4;
}
float filter_border(const float start, const float value)
{
    return step(start, value) * 2. - 1.;
}
float arrow_distance(
    const ArrowDistanceParameters arrow_parameters,
    const vec2 texcoord,
    const float offset,
    const mat2 derivatives,
    const float line_distance,
    const float line_distance_no_offset,
    
    
    const float border_width,
    const vec2 wing_normal)
{
    ArrowDistances ad = calculate_arrow_distances(arrow_parameters, texcoord, offset, derivatives);
    float derivatives_x_multiplier = 1. / max(abs(derivatives[0].x), abs(derivatives[1].x));
    
    
    float intersection_point = arrow_parameters.full_length - arrow_parameters.arrow_height
        - arrow_parameters.width * wing_normal.y / wing_normal.x;
    float tail_arrow_intersection = filter_border(-1., (texcoord.x - intersection_point) * derivatives_x_multiplier);
    
    float top_wings;
    float bottom_wings;
    #ifdef ENTRANCE_ARROWS_ROUNDING
    top_wings = sdf_intersect(sdf_intersect(ad.top_left_wing, ad.top_right_wing), ad.tip_circle_cut);
    top_wings = sdf_merge(top_wings, ad.tip_circle);
    top_wings = sdf_intersect(top_wings, ad.top_tip_cut);
    float wings_circles = sdf_merge(ad.left_wing_circle, ad.right_wing_circle);
    float wings_radius_cut = sdf_intersect(ad.left_wing_circle_cut, ad.right_wing_circle_cut);
    bottom_wings = sdf_merge(ad.bottom_left_wing, ad.bottom_right_wing);
    bottom_wings = sdf_intersect(bottom_wings, wings_radius_cut);
    bottom_wings = sdf_merge(bottom_wings, wings_circles);
    #else
    top_wings = sdf_intersect(ad.top_left_wing, ad.top_right_wing);
    bottom_wings = sdf_merge(ad.bottom_left_wing, ad.bottom_right_wing);
    #endif
    float line_without_offset = filter_border(0., line_distance_no_offset);
    float bottom_wings_with_tail = sdf_merge(bottom_wings, line_without_offset);
    float wings_with_tail = sdf_intersect(bottom_wings_with_tail, top_wings);
    
    float tail_hide_part = v_vec2_line_type_arrow_tail.y;
    float tail_hide_mask = (-texcoord.x - tail_hide_part) * derivatives_x_multiplier;
    float clipped_tail = sdf_intersect(tail_hide_mask, sdf_intersect(line_distance, top_wings));
    return (v_vec4_distance_vertex_hiding.x < v_vec4_distance_vertex_hiding.y)
        ? sdf_intersect(-sdf_intersect(tail_arrow_intersection, line_without_offset), wings_with_tail)
        : sdf_merge(clipped_tail, sdf_intersect(-sdf_intersect(tail_arrow_intersection, line_without_offset), wings_with_tail));
}
vec4 distance_to_arrow_line_color(
    const float fill_distance,
    const float border_distance)
{
    return distance_to_color(fill_distance, border_distance, v_vec4_color, v_vec4_border_color);
}
vec4 arrow_color(
    const vec2 texcoord,
    const ArrowDistanceParameters arrow_parameters,
    const float line_fill_distance,
    const float line_border_distance,
    const vec2 wing_normal)
{
    mat2 derivatives = mat2(dFdx(texcoord), dFdy(texcoord));
    
    float border_clipping = (abs(texcoord.y) - v_vec4_arrow_width_length_border_outer.w) / max(abs(derivatives[0].y), abs(derivatives[1].y));
    float border_width = v_vec4_arrow_width_length_border_outer.z;
    float arrow_border_distance = arrow_distance(
        arrow_parameters,
        texcoord,
        v_vec4_arrow_width_length_border_outer.z,
        derivatives,
        line_border_distance,
        line_fill_distance,
        border_width,
        wing_normal);
    float border_factor = max(border_clipping, affine_step(0., 1., arrow_border_distance));
    return distance_to_arrow_line_color(
        arrow_distance(arrow_parameters, texcoord, 0., derivatives, line_fill_distance, line_fill_distance, border_width, wing_normal),
        border_factor);
}
float line_start_distance(
    const vec2 texcoord,
    const float offset,
    const mat2 derivatives,
    const float line_distance,
    const float half_width,
    const float border_width,
    const float tail_radius)
{
    float derivatives_x_multiplier = 1. / max(abs(derivatives[0].x), abs(derivatives[1].x));
    
    float tail_hide_part = v_vec2_line_type_arrow_tail.y;
    float d0 = (-texcoord.x - offset) * derivatives_x_multiplier;
    float dh = (texcoord.x - tail_hide_part) * derivatives_x_multiplier;
    float rect = max(d0, max(line_distance, dh));
    
    float radius_offset = tail_radius - border_width;
    float circle_radius = radius_offset + offset;
    vec2 left_circle_center = vec2(radius_offset, half_width - radius_offset);
    vec2 right_circle_center = vec2(radius_offset, -half_width + radius_offset);
    vec2 left_circle_normal = normalize(texcoord - left_circle_center);
    vec2 right_circle_normal = normalize(texcoord - right_circle_center);
    float cut_x = (-texcoord.x + radius_offset) * derivatives_x_multiplier;
    float cut_y = (abs(texcoord.y) - half_width + radius_offset) / max(abs(derivatives[0].y), abs(derivatives[1].y));
    float circles_cut = min(cut_x, cut_y);
    float left_circle = length(texcoord - left_circle_center) - circle_radius;
    left_circle = left_circle / max(abs(dot(derivatives[0], left_circle_normal)), abs(dot(derivatives[1], left_circle_normal)));
    float right_circle = length(texcoord - right_circle_center) - circle_radius;
    right_circle = right_circle / max(abs(dot(derivatives[0], right_circle_normal)), abs(dot(derivatives[1], right_circle_normal)));
    float circles = min(left_circle, right_circle);
    rect = min(max(rect, circles_cut), circles);
    return rect;
}
vec4 line_color(
    const float line_fill_distance,
    const float line_border_distance,
    const float line_half_width,
    const float border_width,
    const float tail_radius)
{
    float type = v_vec2_line_type_arrow_tail.x;
    float fill_distance = line_fill_distance;
    float border_distance = line_border_distance;
    if (lookalike(type, g_type_start_border))
    {
        vec2 texcoord = v_vec4_texcoord_arrow_line.xy;
        mat2 derivatives = mat2(dFdx(texcoord), dFdy(texcoord));
        fill_distance = line_start_distance(
            texcoord, 0.,
            derivatives,
            line_fill_distance,
            line_half_width,
            border_width,
            tail_radius);
        border_distance = line_start_distance(
            texcoord,
            v_vec4_arrow_width_length_border_outer.z,
            derivatives,
            line_border_distance,
            line_half_width,
            border_width,
            tail_radius);
    }
    return distance_to_arrow_line_color(fill_distance, border_distance);
}
vec4 arrow_line_color()
{
    if (lookalike(min(v_vec4_distance_vertex_hiding.y, 1.), 1.)
        || lookalike(v_vec4_distance_vertex_hiding.w, 1.)
        || !lookalike(v_vec2_line_type_arrow_tail.x, g_type_arrow) && (v_vec4_distance_vertex_hiding.x < v_vec4_distance_vertex_hiding.y || v_vec4_distance_vertex_hiding.x > v_vec4_distance_vertex_hiding.z))
    {
        discard;
    }
    vec2 wing_normal = -normalize(vec2(u_float_wing_width_multiplier, u_float_wing_height_multiplier));
    vec2 tip_normal = normalize(vec2(u_float_wing_width_multiplier, u_float_tip_height_multiplier));
    float tip_radius;
    float wing_radius;
    float tail_radius;
    #ifdef ENTRANCE_ARROWS_ROUNDING
    tip_radius = v_vec3_radius_tip_wing_tail.x;
    wing_radius = v_vec3_radius_tip_wing_tail.y;
    tail_radius = v_vec3_radius_tip_wing_tail.z;
    #else
    tip_radius = 0.;
    wing_radius = 0.;
    tail_radius = 0.;
    #endif
    ArrowDistanceParameters arrow_parameters = calculate_arrow_distance_parameters(
        wing_normal,
        tip_normal,
        v_vec4_arrow_width_length_border_outer.x,
        v_vec4_arrow_width_length_border_outer.y,
        u_float_tip_height_multiplier,
        u_float_wing_height_multiplier,
        tip_radius,
        wing_radius,
        v_vec4_arrow_width_length_border_outer.z,
        v_vec4_circle_center_tip_wing.xy,
        v_vec4_circle_center_tip_wing.zw);
    float line_width = arrow_parameters.width;
    float line_border = v_vec4_arrow_width_length_border_outer.z;
    
    vec2 line_texcoord = v_vec4_texcoord_arrow_line.zw;
    mat2 line_derivatives = mat2(dFdx(line_texcoord), dFdy(line_texcoord));
    CircleDistance circle_fill_distance = circle_color_distance(line_derivatives, line_texcoord, line_width);
    CircleDistance circle_border_distance = circle_color_distance(line_derivatives, line_texcoord, line_width + line_border);
    float line_fill_distance = affine_step(-1., 0., circle_fill_distance.distance / circle_fill_distance.width) - 1.;
    float line_border_distance = affine_step(0., circle_border_distance.width, circle_border_distance.distance);
    return lookalike(v_vec2_line_type_arrow_tail.x, g_type_arrow)
        ? arrow_color(v_vec4_texcoord_arrow_line.xy, arrow_parameters, line_fill_distance, line_border_distance, wing_normal)
        : line_color(line_fill_distance, line_border_distance, line_width, line_border, tail_radius);
}
void main()
{
    vec4 color = arrow_line_color();
    gl_FragColor = apply_fog(color);
}
`,Df=`#include <highp_float>
#include <prelude>
varying vec2 v_vec2_line_type_arrow_tail;
varying vec4 v_vec4_distance_vertex_hiding;
varying vec4 v_vec4_identifier;
const float g_type_arrow = 1.;
bool lookalike(const float a, const float b)
{
    return abs(a - b) < 1e-5;
}
void main()
{
    if (lookalike(min(v_vec4_distance_vertex_hiding.y, 1.), 1.)
        || lookalike(v_vec4_distance_vertex_hiding.w, 1.)
        || !lookalike(v_vec2_line_type_arrow_tail.x, g_type_arrow) && (v_vec4_distance_vertex_hiding.x < v_vec4_distance_vertex_hiding.y || v_vec4_distance_vertex_hiding.x > v_vec4_distance_vertex_hiding.z))
    {
        discard;
    }
    gl_FragColor = v_vec4_identifier;
}
`,Of=`#include <highp_float>
#include <prelude>
#include <cam_pos>
#include <affine_step>
#include <fog>
#include <bit_mask>
#include <pack_depth>
#include <shadow>
#include <light>
uniform vec4 u_vec4_color;
varying vec2 v_vec2_circle;
varying float v_float_width;
void main() {
    float center_distance = dot(v_vec2_circle, v_vec2_circle);
    vec4 light = light_factor_surface();
    vec4 color = u_vec4_color * affine_step(1.0, 1.0 - 4.0 / v_float_width, center_distance) * light;
    gl_FragColor = apply_fog_alpha(color);
}
`,Nf=`#include <lowp_float>
#include <prelude>
#include <fog>
varying vec4 v_vec4_color;
void main()
{
    gl_FragColor = apply_fog(v_vec4_color);
}
`,kf=`#include <lowp_float>
#include <prelude>
varying vec4 v_vec4_identifier;
void main()
{
    gl_FragColor = v_vec4_identifier;
}
`,Uf=`#include <enable_standard_derivatives>
#include <highp_float>
#include <prelude>
#include <cam_pos>
#include <fog>
#include <screendoor_transparency>
#include <fragment_normal>
#include <bit_mask>
#include <pack_depth>
#include <shadow>
#include <light>
#include <dem>
varying vec4 v_vec4_color;
varying vec4 v_vec4_rotated_scaled_vertex;
void main()
{
    if (check_dem_invalid() != 0) {
        discard;
    }
    apply_screendoor();
    vec3 normal = calc_fragment_normal(v_vec4_rotated_scaled_vertex.xyz);
    vec4 light = light_factor(normal);
    vec4 color = v_vec4_color * light;
    gl_FragColor = apply_fog(color);
# ifndef BLEND
    
    gl_FragColor /= gl_FragColor.a;
# endif
}
`,Gf=`#ifdef COPY_DEPTH
#include <require_frag_depth>
#endif
#include <mediump_float>
#include <prelude>
#if defined(IS_DEPTH_TEXTURE) && defined(WEBGL2)
uniform mediump sampler2DShadow u_texture;
#else
uniform sampler2D u_texture;
#endif
#ifdef COPY_DEPTH
uniform sampler2D u_depth;
#endif
varying vec2 v_vec2_texcoord;
void main()
{
#if defined(IS_DEPTH_TEXTURE) && defined(WEBGL2)
    gl_FragColor = vec4(vec3(texture2D(u_texture, vec3(v_vec2_texcoord, 1.0))), 1.0);
#else
    gl_FragColor = texture2D(u_texture, v_vec2_texcoord);
#endif
#ifdef COPY_DEPTH
    float depthR = texture2D(u_depth, v_vec2_texcoord).r;
# ifdef WEBGL1
#  ifdef HAS_FRAG_DEPTH_EXT
     gl_FragDepthEXT = depthR;
#  else 
     discard;
#  endif 
# else 
     gl_FragDepth = depthR;
# endif 
#endif 
}
`,Hf=`#include <mediump_float>
#include <prelude>
varying float v_float_height;
void main()
{
  gl_FragColor = vec4(v_float_height, 0., 0., 1.);
}
`,Vf=`#include <mediump_float>
#include <prelude>
uniform sampler2D u_sr2d_texture;
varying vec2 v_vec2_texcoord;
void main()
{
  gl_FragColor = texture2D(u_sr2d_texture, v_vec2_texcoord);
}
`,jf=`#include <mediump_float>
#include <prelude>
varying vec4 v_vec4_color;
void main()
{
    gl_FragColor = v_vec4_color;
}
`,Zf=`#include <mediump_float>
#include <prelude>
#include <dem>
varying vec4 v_vec4_coords;
void main()
{
    if (check_dem_invalid() != 0) {
discard;
}
    gl_FragColor = v_vec4_coords;
}
`,Wf=`#include <mediump_float>
#include <prelude>
varying vec4 v_vec4_coords;
void main()
{
    gl_FragColor = v_vec4_coords;
}
`,$f=`#include <enable_standard_derivatives>
#include <mediump_float>
#include <prelude>
#include <cam_pos>
#include <fog>
#include <bit_mask>
#include <pack_depth>
#include <shadow>
#include <light>
uniform sampler2D u_flat_tex;
uniform sampler2D u_hillshade_tex;
uniform sampler2D u_tex_hillshade_ramp;
uniform float u_float_dem_shading_intensity;
varying vec4 v_vec4_texcoord;
varying vec2 hs_tex_pos;
void main()
{
    
    if (v_vec4_texcoord.z > 0.) {
        discard;
    }
    vec4 vec4_texcoord = v_vec4_texcoord / v_vec4_texcoord.w;
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
     
    if (vec4_texcoord.x < 0. || vec4_texcoord.x > 1. || vec4_texcoord.y < 0. || vec4_texcoord.y > 1.) {
        discard;
    } else {
        vec4 flatMapColor = texture2D(u_flat_tex, vec4_texcoord.xy);
        
        if (u_float_dem_shading_intensity > 0.) {
            
            vec3 normal = texture2D(u_hillshade_tex, hs_tex_pos).rgb * 2. - vec3(1.);
            
            float light_raw = light_factor_dem(normal);
            float dir1_intensity = u_vec4_light_dir1_color[3];
            float amb_intensity = u_vec4_ambient_color[3];
            float total_intensity = dir1_intensity + amb_intensity;
            
            
            float amb_intensity_shifted = u_vec4_ambient_color[3];
            float dir_intensity_shifted = dir1_intensity;
            
            float horizonatal_surface_light_dir_dot = light_factor_dem(vec3(0, 0, 1));
            float horizonatal_surface_light_intensity = amb_intensity + dir1_intensity * horizonatal_surface_light_dir_dot;
            if (u_float_dem_shading_intensity > 0.5) { 
                amb_intensity_shifted = mix(amb_intensity, 0., (u_float_dem_shading_intensity - 0.5) / 0.5);
                dir_intensity_shifted = (horizonatal_surface_light_intensity - amb_intensity_shifted) / horizonatal_surface_light_dir_dot;
            } else if (u_float_dem_shading_intensity < 0.5) { 
                dir_intensity_shifted = mix(0., dir1_intensity, u_float_dem_shading_intensity / 0.5);
                amb_intensity_shifted = horizonatal_surface_light_intensity - dir_intensity_shifted * horizonatal_surface_light_dir_dot;
            } 
            
            float tex_coord = clamp(dir_intensity_shifted * light_raw * 0.5 + 0.5, 0., 0.99);
            
            float dir_light_factor = 2. * (texture2D(u_tex_hillshade_ramp, vec2(tex_coord, 0.5)).a - 0.5);
            vec3 light_color = amb_intensity_shifted * u_vec4_ambient_color.rgb + dir_light_factor * u_vec4_light_dir1_color.rgb;
            
            gl_FragColor.rgb = light_color * flatMapColor.rgb;
            
            
            gl_FragColor.a = flatMapColor.a;
        } else {
            gl_FragColor = flatMapColor * light_factor_surface();
        }
        gl_FragColor = apply_fog(gl_FragColor);
    }
}
`,Xf=`#include <enable_standard_derivatives>
#include <mediump_float>
#include <prelude>
#include <cam_pos>
#include <fog>
#include <bit_mask>
#include <pack_depth>
#include <shadow>
#include <light>
#include <fragment_normal>
uniform sampler2D u_flat_tex;
uniform sampler2D u_hillshade_tex;
uniform sampler2D u_tex_hillshade_ramp;
uniform int u_int_depth_test;
uniform vec4 u_vec4_depth_test_color;
uniform float u_float_dem_shading_intensity;
varying vec4 v_vec4_texcoord;
varying vec3 v_vec3_position;
void main() {
    if (u_int_depth_test == 1) {
        gl_FragColor = u_vec4_depth_test_color;
        return;
    }
    vec4 vec4_texcoord = v_vec4_texcoord / v_vec4_texcoord.w;
    if(vec4_texcoord.x < 0. || vec4_texcoord.x > 1. || vec4_texcoord.y < 0. || vec4_texcoord.y > 1.) {
        discard;
    }
    vec4 flatMapColor = texture2D(u_flat_tex, vec4_texcoord.xy);
    vec4 lf = light_factor_dem2(calc_fragment_normal(v_vec3_position), u_float_dem_shading_intensity);
    gl_FragColor = vec4(lf.rgb * flatMapColor.rgb, flatMapColor.a);
    gl_FragColor = apply_fog(gl_FragColor);
}
`,Kf=`#include <lowp_float>
#include <prelude>
uniform sampler2D u_tex_dem;
uniform float u_float_dem_resolution;
uniform float u_float_dem_cell_size;
uniform float u_float_dem_scale;
const float M_PI = 3.1415926535897932384626433832795;
varying vec2 v_vec2_texcoord;
mat3 get_kernel(vec2 pos, float step, float defval) {
    mat3 kernel;
    for (int x = 0; x < 3; x++) {
        vec3 col;
        for (int y = 0; y < 3; y++) {
            vec4 val = texture2D(u_tex_dem, vec2(pos.x + float(x - 1) * step, pos.y + float(y - 1) * step));
            col[y] = val.r;
            if (val.a < 1.) {
                col[y] = defval;
            }
        }
        kernel[x] = col;
    }
    return kernel;
}
float calc_aspect(mat3 kernel) {
    float dzdx = ((kernel[2].z + 2.0 * kernel[2].y + kernel[2].x) - (kernel[0].z + 2.0 * kernel[0].y + kernel[0].x)) / 8.;
    float dzdy = ((kernel[0].x + 2.0 * kernel[1].x + kernel[2].x) - (kernel[0].z + 2.0 * kernel[1].z + kernel[2].z)) / 8.;
    
    if (dzdx == 0. && dzdy == 0.) {
        return 0.;
    }
    
    return atan(-dzdx, dzdy);
}
float calc_slope(mat3 kernel, float cell_size) {
    float dzdx = ((kernel[2].z + 2. * kernel[2].y + kernel[2].x) - (kernel[0].z + 2. * kernel[0].y + kernel[0].x)) / (8. * cell_size);
    float dzdy = ((kernel[0].x + 2. * kernel[1].x + kernel[2].x) - (kernel[0].z + 2. * kernel[1].z + kernel[2].z)) / (8. * cell_size);
    float rise_run = sqrt(dzdx * dzdx + dzdy * dzdy);
    return atan(rise_run);
}
vec3 dem_normal(const vec2 tex_pos)
{
    
    float tex_step = 1. / u_float_dem_resolution;
    
    if (u_float_dem_scale == 0.) {
        return vec3(0.);
    }
    
    vec4 e = texture2D(u_tex_dem, tex_pos);
    if (e.a < 1.) {
        
        return vec3(0.);
    }
    mat3 kernel = get_kernel(tex_pos.xy, tex_step, e.r);
    
    float aspect = calc_aspect(kernel);
    
    
    float slope = calc_slope(kernel, u_float_dem_cell_size);
    
    slope = M_PI * 0.5 - slope; 
    aspect = aspect - M_PI * 0.5; 
    float cosSlope = cos(slope);
    vec3 normal = normalize(vec3(cosSlope * cos(aspect), -1. * cosSlope * sin(aspect), sin(slope)));
    
    return normal * 0.5 + vec3(0.5);
}
void main() {
    gl_FragColor = vec4(dem_normal(v_vec2_texcoord), 1);
}
`,qf=`#include <require_frag_depth>
#include <highp_float>
void main()
{
    
    
    
    #ifdef WEBGL1
    #ifdef HAS_FRAG_DEPTH_EXT
    gl_FragDepthEXT = 1.0;
    #else 
    discard;
    #endif 
    #else 
    gl_FragDepth = 1.0;
    #endif 
}
`,Yf=`#include <mediump_float>
#include <prelude>
#ifndef UBO
uniform vec2 u_vec2_vpt_size;
#endif
uniform sampler2D u_texture;
varying vec2 v_vec2_texcoord;
#ifndef FXAA_REDUCE_MIN
    #define FXAA_REDUCE_MIN   (1.0/ 128.0)
#endif
#ifndef FXAA_REDUCE_MUL
    #define FXAA_REDUCE_MUL   (1.0 / 8.0)
#endif
#ifndef FXAA_SPAN_MAX
    #define FXAA_SPAN_MAX     8.0
#endif
void texcoords(vec2 fragCoord, vec2 resolution,
            out vec2 v_rgbNW, out vec2 v_rgbNE,
            out vec2 v_rgbSW, out vec2 v_rgbSE,
            out vec2 v_rgbM) {
    vec2 inverseVP = 1.0 / resolution.xy;
    v_rgbNW = (fragCoord + vec2(-1.0, -1.0)) * inverseVP;
    v_rgbNE = (fragCoord + vec2(1.0, -1.0)) * inverseVP;
    v_rgbSW = (fragCoord + vec2(-1.0, 1.0)) * inverseVP;
    v_rgbSE = (fragCoord + vec2(1.0, 1.0)) * inverseVP;
    v_rgbM = vec2(fragCoord * inverseVP);
}
vec4 fxaa(sampler2D tex, vec2 fragCoord, vec2 resolution,
            vec2 v_rgbNW, vec2 v_rgbNE,
            vec2 v_rgbSW, vec2 v_rgbSE,
            vec2 v_rgbM) {
    vec4 color;
    mediump vec2 inverseVP = vec2(1.0 / resolution.x, 1.0 / resolution.y);
    vec3 rgbNW = texture2D(tex, v_rgbNW).xyz;
    vec3 rgbNE = texture2D(tex, v_rgbNE).xyz;
    vec3 rgbSW = texture2D(tex, v_rgbSW).xyz;
    vec3 rgbSE = texture2D(tex, v_rgbSE).xyz;
    vec4 texColor = texture2D(tex, v_rgbM);
    vec3 rgbM  = texColor.xyz;
    vec3 luma = vec3(0.299, 0.587, 0.114);
    float lumaNW = dot(rgbNW, luma);
    float lumaNE = dot(rgbNE, luma);
    float lumaSW = dot(rgbSW, luma);
    float lumaSE = dot(rgbSE, luma);
    float lumaM  = dot(rgbM,  luma);
    float lumaMin = min(lumaM, min(min(lumaNW, lumaNE), min(lumaSW, lumaSE)));
    float lumaMax = max(lumaM, max(max(lumaNW, lumaNE), max(lumaSW, lumaSE)));
    mediump vec2 dir;
    dir.x = -((lumaNW + lumaNE) - (lumaSW + lumaSE));
    dir.y =  ((lumaNW + lumaSW) - (lumaNE + lumaSE));
    float dirReduce = max((lumaNW + lumaNE + lumaSW + lumaSE) *
                          (0.25 * FXAA_REDUCE_MUL), FXAA_REDUCE_MIN);
    float rcpDirMin = 1.0 / (min(abs(dir.x), abs(dir.y)) + dirReduce);
    dir = min(vec2(FXAA_SPAN_MAX, FXAA_SPAN_MAX),
              max(vec2(-FXAA_SPAN_MAX, -FXAA_SPAN_MAX),
              dir * rcpDirMin)) * inverseVP;
    vec3 rgbA = 0.5 * (
        texture2D(tex, fragCoord * inverseVP + dir * (1.0 / 3.0 - 0.5)).xyz +
        texture2D(tex, fragCoord * inverseVP + dir * (2.0 / 3.0 - 0.5)).xyz);
    vec3 rgbB = rgbA * 0.5 + 0.25 * (
        texture2D(tex, fragCoord * inverseVP + dir * -0.5).xyz +
        texture2D(tex, fragCoord * inverseVP + dir * 0.5).xyz);
    float lumaB = dot(rgbB, luma);
    if ((lumaB < lumaMin) || (lumaB > lumaMax))
        color = vec4(rgbA, texColor.a);
    else
        color = vec4(rgbB, texColor.a);
    return color;
}
void main()
{
    mediump vec2 v_rgbNW;
    mediump vec2 v_rgbNE;
    mediump vec2 v_rgbSW;
    mediump vec2 v_rgbSE;
    mediump vec2 v_rgbM;
    vec2 fragCoord = v_vec2_texcoord * u_vec2_vpt_size;
    texcoords(fragCoord, u_vec2_vpt_size, v_rgbNW, v_rgbNE, v_rgbSW, v_rgbSE, v_rgbM);
    gl_FragColor = fxaa(u_texture, fragCoord, u_vec2_vpt_size, v_rgbNW, v_rgbNE, v_rgbSW, v_rgbSE, v_rgbM);
}
`,Qf=`#include <mediump_float>
#include <prelude>
uniform sampler2D u_sr2d_flatmap_texture;
varying vec2 v_vec2_texture;
void main() {
    gl_FragColor = texture2D(u_sr2d_flatmap_texture, v_vec2_texture);
}
`,Jf=`#include <mediump_float>
#include <prelude>
#ifndef UBO
uniform mediump vec4 u_vec4_halo_color;
uniform mediump vec2 u_vec2_halo_viewport_size;
uniform mediump vec2 u_vec2_halo_viewport_center_shift;
uniform mediump vec4 u_vec4_halo_radius_stops;
uniform mediump float u_float_halo_exp_factor;
#endif
varying vec2 v_vec2_uv;
void main() {
    float dist = length(v_vec2_uv);
    float halo_alpha = u_vec4_halo_color.a;
    vec4 halo_color = vec4(u_vec4_halo_color.rgb, 0.);
    vec4 empty_color = vec4(0.0);
    vec4 white_color1 = vec4(1., 1., 1., halo_alpha);
    vec4 white_color2 = vec4(white_color1.rgb, halo_alpha * 0.9);
    float r0 = u_vec4_halo_radius_stops[0];
    float r1 = u_vec4_halo_radius_stops[1];
    float r2 = u_vec4_halo_radius_stops[2];
    float r3 = u_vec4_halo_radius_stops[3];
    float t0 = max(0.0, (dist - r1) / (r3 - r1));
    float t0e = 1.0 - exp(u_float_halo_exp_factor * t0);
    
    vec4 color = mix(white_color2, halo_color, t0e);
    
    color = mix(white_color1, color, smoothstep(r1, r2, dist));
    
    color = mix(empty_color, color, smoothstep(r0, r1, dist));
    gl_FragColor = color;
}
`,Af=`#include <mediump_float>
#include <prelude>
#ifndef UBO
uniform mediump vec4 u_vec4_default_background_color;
uniform mediump vec4 u_vec4_halo_radius_stops;
#endif
varying vec2 v_vec2_uv;
void main() {
    float dist = length(v_vec2_uv);
    float r1 = u_vec4_halo_radius_stops[1];
    if(dist > r1) {
        discard;
    }
    gl_FragColor = u_vec4_default_background_color;
}
`,em=`#include <enable_standard_derivatives>
#include <highp_float>
#include <prelude>
#include <cam_pos>
#include <fog>
#include <screendoor_transparency>
#include <bit_mask>
#include <pack_depth>
#include <shadow>
#include <light>
#include <light_pbr>
#include <light_phong>
#include <dem>
uniform vec4 u_vec4_color;
#ifdef MAP_MESH_TEXTURE
uniform sampler2D u_sampler_map_tex;
#endif
#ifdef COLOR_TEXTURE
uniform sampler2D u_sr2d_texture_0;
#endif
#ifdef AO_TEXTURE
uniform sampler2D u_ao_texture;
#endif
#ifdef PBR_TEXTURE
uniform sampler2D u_pbr_texture;
#endif
#ifdef LIGHT_MODEL
#if  (LIGHT_MODEL == LIGHT_MODEL_PBR || LIGHT_MODEL == LIGHT_MODEL_PHONG)
uniform float u_float_metallic;
uniform float u_float_roughness;
#endif
#endif
varying vec3 v_vec3_normal;
varying vec3 v_vec3_fragment_pos_world;
#ifdef MAP_MESH_TEXTURE
uniform vec2 u_vec2_tex_scale;
uniform float u_float_tex_shift_scale;
varying vec4 v_tex_coord;
#endif
#ifdef COLOR_TEXTURE
varying vec2 v_vec2_texcoord_color;
#endif
#ifdef AO_TEXTURE
varying vec2 v_vec2_texcoord_ao;
#endif
#ifdef PBR_TEXTURE
varying vec2 v_vec2_texcoord_pbr;
#endif
varying float v_float_opacity;
void main()
{
    if (check_dem_invalid() != 0) {
        discard;
    }
    apply_screendoor();
    vec4 color = u_vec4_color;
    #ifdef COLOR_TEXTURE
        color *= texture2D(u_sr2d_texture_0, v_vec2_texcoord_color);
    #endif
    #ifdef MAP_MESH_TEXTURE
        
        vec2 coord = v_tex_coord.xy / v_tex_coord.w;
        
        coord = coord / u_vec2_tex_scale;
        
        coord.y += u_float_tex_shift_scale / u_vec2_tex_scale.y;
        
        coord = (coord / 2.) + vec2(0.5, 0.5);
        vec4 texture_color = texture2D(u_sampler_map_tex, coord);
        
        color.rgb = mix(color.rgb, texture_color.rgb, texture_color.a);
    #endif
    #ifdef AO_TEXTURE
        
        
        vec4 ao_tex_color = texture2D(u_ao_texture, v_vec2_texcoord_ao);
        color *= ao_tex_color;
    #endif
    vec3 fragment_normal = normalize(v_vec3_normal);
    color *= v_float_opacity;
    bool use_light = UNPACK_BOOL1(u_int_light_flags);
    if (!use_light) {
        gl_FragColor = apply_fog(color);
        return;
    }
    #ifdef LIGHT_MODEL
        float metallic = max(u_float_metallic, 0.1);
        float roughness = max(u_float_roughness, 0.1);
        #ifndef METALLIC_ROUGHNESS_DEBUG
            #ifdef PBR_TEXTURE
                vec4 pbr_tex_color = texture2D(u_pbr_texture, v_vec2_texcoord_pbr);
                roughness = max(pbr_tex_color.g, 0.1);
                metallic = max(pbr_tex_color.b, 0.1);
            #endif
        #endif
        #if (LIGHT_MODEL == LIGHT_MODEL_PBR)
            color.rgb = color_pbr(fragment_normal, v_vec3_fragment_pos_world, color.rgb, roughness, metallic);
        #elif (LIGHT_MODEL == LIGHT_MODEL_PHONG)
            color.rgb = color_phong(fragment_normal, v_vec3_fragment_pos_world, color.rgb, roughness, metallic);
        #endif
    #endif
    gl_FragColor = apply_fog(color);
}
`,tm=`#include <enable_standard_derivatives>
#include <highp_float>
#include <prelude>
#include <cam_pos>
#include <fog>
#include <screendoor_transparency>
#include <fragment_normal>
#include <bit_mask>
#include <pack_depth>
#include <shadow>
#include <light>
#include <dem>
varying mat4 v_mat4_gradient;
varying vec4 v_vec4_color;
varying vec4 v_vec4_rotated_scaled_vertex;
uniform vec2 u_vec2_floor_level;
void main()
{
    if (check_dem_invalid() != 0) {
        discard;
    }
    apply_screendoor();
    vec4 color = v_vec4_color;
    if (v_mat4_gradient[0][0] != 0.) {
        float height_gradient = v_vec4_rotated_scaled_vertex.w;
        float gradient_position = (float(u_vec2_floor_level.x) + height_gradient) / float(u_vec2_floor_level.y);
        color = mix(v_mat4_gradient[1], v_mat4_gradient[2], smoothstep(v_mat4_gradient[0][1], v_mat4_gradient[0][2], gradient_position));
    }
    vec3 normal = calc_fragment_normal(v_vec4_rotated_scaled_vertex.xyz);
    color *= light_factor(normal);
    gl_FragColor = apply_fog(color);
# ifndef BLEND
    
    gl_FragColor /= gl_FragColor.a;
# endif
}
`,im=`#include <mediump_float>
#include <prelude>
#include <fog>
uniform highp float u_float_intensity;
varying float v_float_weight;
varying vec2 v_vec2_extrude;
#define GAUSS_COEF 0.3989422804014327
void main() {
    float d = -0.5 * 3.0 * 3.0 * dot(v_vec2_extrude, v_vec2_extrude);
    float val = v_float_weight * u_float_intensity * GAUSS_COEF * exp(d);
    float fog_alpha = apply_fog_alpha(vec4(1)).r;
    gl_FragColor = vec4(val, fog_alpha, 1.0, 1.0);
}
`,nm=`#include <mediump_float>
#include <prelude>
#include <cam_pos>
uniform sampler2D u_sr2d_texture;
uniform sampler2D u_sr2d_ramp_texture;
uniform float u_float_opacity;
varying vec2 v_vec2_position;
void main() {
    vec2 color_and_alpha = texture2D(u_sr2d_texture, v_vec2_position).rg;
    vec4 color = texture2D(u_sr2d_ramp_texture, vec2(color_and_alpha.r, 0.5));
    gl_FragColor = color * u_float_opacity;
    
    
    #ifdef FOG
        gl_FragColor *= color_and_alpha.g;
    #endif
}
`,om=`#include <highp_float>
#include <prelude>
#include <cam_pos>
#include <dem>
uniform mediump int u_int_identify;
varying vec4 v_vec4_identifier;
void main()
{
    if (check_dem_invalid() != 0) {
        discard;
    }
    if (u_int_identify != 0) {
        gl_FragColor = v_vec4_identifier;
    } else {
        gl_FragColor = vec4(0., 0., 0., 0.);
    }
}
`,sm=`#include <mediump_float>
#include <prelude>
#include <apply_opacity>
#include <fog>
#include <dem>
uniform sampler2D u_sr2d_texture;
uniform float u_float_buffer;
uniform float u_float_gamma;
uniform vec4 u_vec4_color;
uniform vec4 u_vec4_hidden_color;
uniform float u_float_opacity;
uniform sampler2D u_color_text_sprite_labeling;
uniform float u_float_label_index;
varying vec2 v_vec2_texcoord;
varying float v_float_behind_factor;
varying vec4 v_vec4_text_identifier;
varying vec2 v_vec2_labeling_texcoord;
const float F16_EPSILON = 0.0009765625;
void main() {
    if (check_dem_invalid() != 0) {
discard;
}
    float dist = texture2D(u_sr2d_texture, v_vec2_texcoord).a;
    float alpha = smoothstep(
        u_float_buffer - u_float_gamma,
        u_float_buffer + u_float_gamma,
        dist
    );
    vec4 color = mix(u_vec4_hidden_color, u_vec4_color, v_float_behind_factor);
    color = apply_fog_alpha(color);
    vec4 clearColor = vec4(1, 1, 1, 1);
    vec4 text_sprite_color = texture2D(u_color_text_sprite_labeling, v_vec2_labeling_texcoord);
    bvec4 clearColorDiff = bvec4(
        abs(text_sprite_color.r - clearColor.r) > F16_EPSILON,
        abs(text_sprite_color.g - clearColor.g) > F16_EPSILON,
        abs(text_sprite_color.b - clearColor.b) > F16_EPSILON,
        abs(text_sprite_color.a - clearColor.a) > F16_EPSILON
    );
    bvec4 identifierDiff = bvec4(
        abs(text_sprite_color.r - v_vec4_text_identifier.r) > F16_EPSILON,
        abs(text_sprite_color.g - v_vec4_text_identifier.g) > F16_EPSILON,
        abs(text_sprite_color.b - v_vec4_text_identifier.b) > F16_EPSILON,
        abs(text_sprite_color.a - v_vec4_text_identifier.a) > F16_EPSILON
    );
    if (u_float_label_index < F16_EPSILON && any(identifierDiff)  && any(clearColorDiff) ) {
        discard;
    }
    gl_FragColor = apply_opacity(color * alpha, u_float_opacity);
}
`,am=`#include <highp_float>
#include <prelude>
#include <apply_opacity>
#include <fog>
uniform sampler2D u_sr2d_texture;
uniform float u_float_buffer;
uniform float u_float_gamma;
uniform vec4 u_vec4_color;
uniform float u_float_opacity;
varying vec2 v_vec2_texcoord;
void main() {
    float dist = texture2D(u_sr2d_texture, v_vec2_texcoord).a;
    float alpha = smoothstep(
        u_float_buffer - u_float_gamma,
        u_float_buffer + u_float_gamma,
        dist
    );
    vec4 color = apply_fog_alpha(u_vec4_color);
    gl_FragColor = apply_opacity(color * alpha, u_float_opacity);
}
`,rm=`#include <mediump_float>
#include <prelude>
#include <cam_pos>
#include <fog>
#include <bit_mask>
#include <pack_depth>
#include <shadow>
#include <light>
#include <dem>
varying vec4 v_vec4_color;
varying mat4 v_mat4_gradient;
varying vec3 v_vec3_normal;
varying vec2 v_vec2_height_gradient;
uniform mat4 u_mat4_gradient;
void main()
{ 
    if (check_dem_invalid() != 0) {
        discard;
    }
    vec4 color = v_vec4_color;
    if (u_mat4_gradient[0][0] != 0.) {
        color = mix(v_mat4_gradient[1], v_mat4_gradient[2], smoothstep(v_mat4_gradient[0][1], v_mat4_gradient[0][2], v_vec2_height_gradient[0]));
    }
    color *= (1. - abs(v_vec2_height_gradient[1] * gl_FragCoord.w));
    gl_FragColor = apply_fog(color * light_factor(v_vec3_normal));
}
`,lm=`#include <highp_float>
#include <prelude>
#include <pack_depth>
#include <dem>
varying float v_depth_metric;
void main()
{
if (check_dem_invalid() != 0) {
discard;
}
#ifdef DEPTH_TEXTURE_SHADOW
return;
#endif
gl_FragColor = pack_float_to_vec4(v_depth_metric);
}`,cm=`#include <highp_float>
#include <prelude>
#include <cam_pos>
#include <fog>
#include <screendoor_transparency>
#include <bit_mask>
#include <pack_depth>
#include <shadow>
#include <light>
#include <dem>
uniform sampler2D u_sampler_map_tex;
uniform vec2 u_vec2_tex_scale;
uniform float u_float_tex_shift_scale;
uniform mediump float u_float_light_intensity;
uniform int u_int_identify;
varying vec4 v_tex_coord;
varying vec4 v_vec4_normal_gradient;
void main()
{
if (check_dem_invalid() != 0) {
        discard;
    }
vec2 coord = v_tex_coord.xy / v_tex_coord.w;
coord = coord / u_vec2_tex_scale;
coord.y += u_float_tex_shift_scale / u_vec2_tex_scale.y;
coord = (coord / 2.) + vec2(0.5, 0.5);
if (coord.x < 0. || coord.x > 1. || coord.y < 0. || coord.y > 1.) {
gl_FragColor = vec4(0, 0, 0, 0);
} else {
gl_FragColor = texture2D(u_sampler_map_tex, coord);
if (u_int_identify == 0) {
apply_screendoor();
gl_FragColor.rgb *= 1. - u_float_light_intensity * smoothstep(0.85, 1., abs(v_vec4_normal_gradient.w));
gl_FragColor *= light_factor(v_vec4_normal_gradient.xyz);
gl_FragColor = apply_fog(gl_FragColor);
}
}
}
`,dm=`#include <highp_float>
#include <prelude>
#include <cam_pos>
#include <apply_opacity>
#include <fog>
#include <screendoor_transparency>
#include <bit_mask>
#include <pack_depth>
#include <shadow>
#include <light>
#include <dem>
uniform sampler2D u_sr2d_texture;
uniform float u_float_texture_opacity;
uniform vec4 u_float_sprite_texture_coords;
uniform lowp int u_int_is_textured;
uniform mediump vec4 u_vec4_color;
uniform mediump mat4 u_mat4_gradient;
uniform mediump float u_float_opacity;
uniform mediump int u_int_identify;
varying vec4 v_vec4_color;
varying mat4 v_mat4_gradient;
varying vec2 v_vec2_tex_coord;
varying vec4 v_vec4_normal_gradient;
varying vec4 v_vec4_identifier;
void main()
{   
    if (check_dem_invalid() != 0) {
        discard;
    }
    if (u_int_identify != 0) {
        gl_FragColor = v_vec4_identifier;
    } else {
        apply_screendoor();
        vec4 light = light_factor(v_vec4_normal_gradient.xyz);
        if (u_int_is_textured != 0)  {
            vec2 spritecoord = mix(u_float_sprite_texture_coords.xy, u_float_sprite_texture_coords.zw, fract(v_vec2_tex_coord));
            vec4 color = texture2D(u_sr2d_texture, spritecoord);
            vec4 texcolor = apply_opacity(color, u_float_texture_opacity);
            gl_FragColor = texcolor + v_vec4_color * (1. - texcolor.a);
        } else if (u_mat4_gradient[0][0] != 0.) {
    gl_FragColor = mix(v_mat4_gradient[1], v_mat4_gradient[2], smoothstep(v_mat4_gradient[0][1], v_mat4_gradient[0][2], v_vec4_normal_gradient.w));
        } else {
            gl_FragColor = v_vec4_color;
        }
        gl_FragColor = apply_fog(gl_FragColor * light);
    }
}
`,_m=`#include <mediump_float>
#include <prelude>
#include <cam_pos>
#include <apply_opacity>
#include <fog>
#include <bit_mask>
#include <pack_depth>
#include <shadow>
#include <light>
uniform vec4 u_vec4_color;
uniform sampler2D u_sr2d_texture;
uniform vec4 u_float_sprite_texture_coords;
varying vec2 v_vec2_texcoord;
void main()
{
    vec2 spritecoord = mix(u_float_sprite_texture_coords.xy, u_float_sprite_texture_coords.zw, v_vec2_texcoord);
    vec4 color = texture2D(u_sr2d_texture, spritecoord) * u_vec4_color;
    gl_FragColor = apply_fog(color * light_factor_surface());
}
`,um=`#include <enable_standard_derivatives>
#include <highp_float>
#include <prelude>
#include <affine_step>
#include <apply_opacity>
#include <signed_distance_functions>
#include <arrow_functions>
#include <fog>
#ifndef UBO
uniform mediump vec2 u_vec2_vpt_size;
#endif
uniform vec2 u_vec2_wing_normal;
uniform vec2 u_vec2_tip_normal;
uniform mediump float u_float_width;
uniform mediump float u_float_length;
uniform float u_float_tip_height_multiplier;
uniform float u_float_wing_height_multiplier;
varying vec4 v_vec4_color;
varying vec4 v_vec4_border_color;
varying vec2 v_vec2_texcoord;
varying float v_float_border_width;
varying float v_float_zpt_to_texcoord_factor;
varying float v_float_outer_width;
varying float v_float_opacity;
float one_way_line_distance(const ArrowDistances ad)
{
    return max(max(max(ad.top_tip_cut, ad.bottom_tip_cut), max(ad.top_left_wing, ad.top_right_wing)), min(ad.line, min(ad.bottom_left_wing, ad.bottom_right_wing)));
}
void main()
{
    mat2 derivatives = mat2(dFdx(v_vec2_texcoord), dFdy(v_vec2_texcoord));
    ArrowDistanceParameters arrow_parameters = calculate_arrow_distance_parameters(
        u_vec2_wing_normal,
        u_vec2_tip_normal,
        u_float_width * v_float_zpt_to_texcoord_factor,
        u_float_length * v_float_zpt_to_texcoord_factor,
        u_float_tip_height_multiplier,
        u_float_wing_height_multiplier,
        0.,
        0.,
        0.,
        vec2(0., 0.),
        vec2(0., 0.));
    
    float border_clipping = (abs(v_vec2_texcoord.y) - v_float_outer_width) / max(abs(derivatives[0].y), abs(derivatives[1].y));
    float fill_factor = affine_step(-1., 0., one_way_line_distance(calculate_arrow_distances(arrow_parameters, v_vec2_texcoord, 0., derivatives)));
    float border_factor = max(border_clipping, affine_step(0., 1., one_way_line_distance(calculate_arrow_distances(arrow_parameters, v_vec2_texcoord, v_float_border_width, derivatives))));
    gl_FragColor = apply_opacity(mix(mix(v_vec4_color, v_vec4_border_color, fill_factor), vec4(0.), border_factor), v_float_opacity);
}
`,hm=`#include <highp_float>
#include <prelude>
#include <cam_pos>
#include <affine_step>
#include <fog>
#include <bit_mask>
#include <pack_depth>
#include <shadow>
#include <light>
#include <signed_distance_functions>
uniform int u_int_pattern_type;
varying vec4 v_vec4_color;
varying vec2 v_vec2_uv;
varying float v_float_width;
varying vec4 v_vec4_pattern_parameters;
void main()
{
    float pattern_length = v_vec4_pattern_parameters.x;
    float full_width = v_float_width + 1.;
    
    float smooth_base = max(15., max(v_float_width, pattern_length));
    float smooth_scale = (smooth_base + 1.) / smooth_base;
    float smooth_factor = smooth_scale - 1.;
    
    vec2 sdf_pos = vec2(mod(v_vec2_uv.x, 1.) - 0.5, v_vec2_uv.y * smooth_scale);
float sdf = 1.;
    
    if (u_int_pattern_type < 4) {
        
        float width = v_vec4_pattern_parameters.y;
        float left  = v_vec4_pattern_parameters.z;
        float right = v_vec4_pattern_parameters.w;
        
        
        vec2 offset;
        if (right < 0.) {
            offset = vec2(.25, .5);
        } else {
            offset = vec2(.0, .5);
        }
        
        if (width > EPSILON) {
            float leftSdf = 1.;
            if (left > EPSILON) {
                leftSdf = sdf_box(sdf_pos + offset, vec2(left, width));
            }
            float rightSdf = 1.;
            if (abs(right) > EPSILON) {
                rightSdf = sdf_box(sdf_pos - offset, vec2(abs(right), width));
            }
            sdf = min(leftSdf, rightSdf);
        }
    } else if (u_int_pattern_type == 5) {
        
        float radius = v_vec4_pattern_parameters.y;
        
        if (radius > EPSILON) {
            sdf = sdf_circle(sdf_pos, radius);
        }
    } else if (u_int_pattern_type == 4) {
        
        float width = v_vec4_pattern_parameters.y;
        float orientation = v_vec4_pattern_parameters.z;
        
        if (width > EPSILON) {
            sdf = sdf_triangle(sdf_pos * vec2(1., orientation), width);
        }
    } else if (u_int_pattern_type == 6) {
        
        sdf = sdf_chevron(sdf_pos.yx, 0., 0., 0.);
    }
    
    sdf = max(sdf, abs(sdf_pos.y) - 0.5);
    
    vec4 color = mix(
        v_vec4_color,
        vec4(0.),
        affine_step(-smooth_factor, smooth_factor, sdf)
    );
    color *= light_factor_surface();
    gl_FragColor = apply_fog(color);
}
`,fm=`#include <mediump_float>
#include <prelude>
#include <apply_opacity>
#include <fog>
#include <dem>
uniform sampler2D u_sr2d_texture;
uniform vec2 u_vec2_opacity;
varying vec2 v_vec2_texcoord;
varying float v_float_behind_factor;
void main()
{
    if (check_dem_invalid() != 0) {
        discard;
    }
    vec4 color = texture2D(u_sr2d_texture, v_vec2_texcoord);
    float opacity = mix(u_vec2_opacity[1], u_vec2_opacity[0], v_float_behind_factor);
    color = apply_fog_alpha(color);
    gl_FragColor = apply_opacity(color, opacity);
}
`,mm=`#include <mediump_float>
#include <prelude>
#include <dem>
uniform sampler2D u_sr2d_texture;
uniform float u_float_identify_opacity;
varying vec2 v_vec2_texcoord;
varying vec4 v_vec4_identifier;
void main()
{
    if (check_dem_invalid() != 0) {
        discard;
    }
    vec4 color = texture2D(u_sr2d_texture, v_vec2_texcoord);
    
    
    if (color.a < u_float_identify_opacity) {
        discard;
    } else {
        gl_FragColor = v_vec4_identifier;
    }
}
`,pm=`#include <lowp_float>
#include <prelude>
#include <fog>
uniform vec4 u_vec4_color;
void main()
{
    gl_FragColor = u_vec4_color;
}
`,vm=`#include <mediump_float>
#include <prelude>
#include <apply_opacity>
#include <fog>
uniform sampler2D u_sr2d_texture;
uniform float u_float_opacity;
varying vec2 v_vec2_texcoord;
void main()
{
    vec4 color = texture2D(u_sr2d_texture, v_vec2_texcoord);
    color = apply_fog_alpha(color);
    gl_FragColor = apply_opacity(color, u_float_opacity);
}
`,gm=`#include <enable_standard_derivatives>
#include <highp_float>
#include <prelude>
#include <cam_pos>
#include <affine_step>
#include <fog>
#include <bit_mask>
#include <pack_depth>
#include <shadow>
#include <light>
uniform vec4 u_vec4_color;
varying vec2 v_vec2_normal;
varying float v_float_half_width;
void main()
{
    
    float opacity = 1.0 - affine_step(
        v_float_half_width - length(fwidth(v_vec2_normal)),
        v_float_half_width,
        length(v_vec2_normal)
    );
    vec4 color = light_factor_surface() * u_vec4_color;
    color = apply_fog(color);
    gl_FragColor = color * opacity;
}
`,ym=`#include <enable_standard_derivatives>
#include <lowp_float>
#include <prelude>
varying vec4 v_vec4_identifier;
varying vec2 v_vec2_normal;
varying float v_float_half_width;
void main()
{
    if (dot(v_vec2_normal, v_vec2_normal) > v_float_half_width * v_float_half_width) {
        discard;
    }
    gl_FragColor = v_vec4_identifier;
}
`,bm=`#include <lowp_float>
#include <prelude>
#include <cam_pos>
#include <fog>
#include <bit_mask>
#include <pack_depth>
#include <shadow>
#include <light>
uniform vec4 u_vec4_color;
varying float v_float_distance;
varying float v_float_distance_offset;
void main()
{
    vec4 light = light_factor_surface();
    vec4 color = u_vec4_color * clamp(
        1. + v_float_distance_offset - abs(v_float_distance * gl_FragCoord.w),
        0.,
        1.) * light;
    gl_FragColor = apply_fog(color);
}
`,xm=`#include <lowp_float>
#include <prelude>
#include <cam_pos>
#include <fog>
#include <bit_mask>
#include <pack_depth>
#include <shadow>
#include <light>
#include <dem>
uniform vec4 u_vec4_color;
varying float v_float_distance;
varying float v_float_distance_offset;
void main()
{
    if (check_dem_invalid() != 0) {
        discard;
    }
    vec4 light = light_factor_surface();
    vec4 color = u_vec4_color * clamp(
        1. + v_float_distance_offset - abs(v_float_distance * gl_FragCoord.w),
        0.,
        1.) * light;
    gl_FragColor = apply_fog(color);
}
`,wm=`#include <highp_float>
#include <prelude>
#include <enable_standard_derivatives>
varying vec3 v_position;
void main() {
    vec3 dx = dFdx(v_position);
    vec3 dy = dFdy(v_position);
    vec3 normal = normalize(cross(dx, dy));
    vec3 lightDir = normalize(vec3(1.0, 1.0, 1.0));
    float diffuse = max(dot(normal, lightDir), 0.0);
    
    gl_FragColor = vec4(normal * (0.2 + 0.8 * diffuse), 1.0);
}
`,Sm=`#include <mediump_float>
#include <prelude>
#include <fog>
#define SKY_ALPHA_HORIZON_BLEND (6.0)
#define DEFAULT_SKY_COLOR (vec4(0.0))
vec4 add_sky_alpha_blend(vec4 color) {
#ifdef SKY
    
    float depth = length(v_fog_pos);
    vec3 dir = v_fog_pos / depth;
    float alpha_dir = dir.z + u_fog_horizon_pad; 
    float alpha = clamp(1.0 + SKY_ALPHA_HORIZON_BLEND * alpha_dir, 0.0, 1.0);
    color *= alpha;
#endif
    return color;
}
void main() {
#ifdef SKY
    vec4 color = add_sky_alpha_blend(u_sky_color);
#else
    vec4 color = DEFAULT_SKY_COLOR;
#endif
    gl_FragColor = apply_fog_sky(color);
}
`,Tm=`#include <mediump_float>
#include <prelude>
varying mediump float v_intensity;
void main() {
    gl_FragColor = vec4(v_intensity);
}
`,Mm=`#include <enable_standard_derivatives>
#include <highp_float>
#include <prelude>
#include <cam_pos>
#include <affine_step>
#include <fog>
#include <bit_mask>
#include <pack_depth>
#include <shadow>
#include <light>
uniform int u_int_gap_turns_only;
varying vec4 v_vec4_dash_color;
varying vec4 v_vec4_space_color;
varying vec4 v_vec4_border_color;
varying vec2 v_vec2_circle;
varying float v_float_width;
varying vec2 v_vec2_line_params;
vec4 distance_func_smooth(in vec4 main_color, in vec4 border_color, in vec2 circle)
{
    float circle_length = length(circle);
    float distance = circle_length - v_float_width;
    mat2 derivatives = mat2(dFdx(v_vec2_circle), dFdy(v_vec2_circle));
    
    
    
    vec2 circle_dx = derivatives[0];
    vec2 circle_dy = derivatives[1];
    
    float distance_dx = dot(v_vec2_circle, circle_dx);
    float distance_dy = dot(v_vec2_circle, circle_dy);
    
    float derivative_denominator = circle_length;
    float width = max(abs(distance_dx), abs(distance_dy));
    vec4 from_main_to_border = mix(
        main_color,
        border_color,
        affine_step(-width, 0., distance * derivative_denominator));
    vec4 from_color_to_fade = mix(
        from_main_to_border,
        vec4(0.),
        affine_step(0., +width, distance * derivative_denominator));
    return from_color_to_fade;
}
float calculate_segment_color_factor(in float distance_in_parts, in float threshold)
{
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    float color_factor = abs(fract(distance_in_parts + 0.5 - 0.5 * threshold) - 0.5);
    
    float parts_affine_step_width = fwidth(distance_in_parts);
    
    
    if (u_int_gap_turns_only == 1 && parts_affine_step_width < threshold * 0.0001) {
        return 1.0;
    }
    
    float smoothed_color_factor = affine_step(
        0.5 * threshold - 0.5 * parts_affine_step_width,
        0.5 * threshold + 0.5 * parts_affine_step_width,
        color_factor);
    return smoothed_color_factor;
}
void main()
{
    vec4 current_segment_color = mix(
        v_vec4_dash_color,
        v_vec4_space_color,
        calculate_segment_color_factor(
            v_vec2_line_params[1],
            v_vec2_line_params[0]));
    
    vec4 final_border_color = (1.0 - v_vec4_border_color.a) * current_segment_color + v_vec4_border_color;
    vec4 color = distance_func_smooth(current_segment_color, final_border_color, v_vec2_circle);
    vec4 light = light_factor_surface();
    gl_FragColor = apply_fog(light * color);
}
`,Em=`#include <mediump_float>
#include <prelude>
uniform sampler2D u_texture;
uniform float u_float_mix_coef;
varying vec2 v_vec2_texcoord;
void main()
{
    vec4 texColor = texture2D(u_texture, v_vec2_texcoord);
    gl_FragColor = vec4(texColor.rgb, texColor.a * u_float_mix_coef);
}
`,Im=`#include <mediump_float>
#include <prelude>
#include <cam_pos>
#include <apply_opacity>
#include <fog>
#include <bit_mask>
#include <pack_depth>
#include <shadow>
#include <light>
#define LIGHT_MODEL LIGHT_MODEL_PHONG
#include <light_phong>
#include <mix_color_defs>
uniform sampler2D u_sr2d_texture;
uniform float u_float_texture_opacity;
uniform vec4 u_float_texture_params;
uniform vec4 u_float_sprite_texture_coords;
uniform int u_int_is_textured;
uniform int u_int_is_normal_map_textured; 
uniform sampler2D u_sr2d_texture1;
uniform vec4 u_vec4_normal_map_texture_params;
uniform vec4 u_vec4_normal_map_sprite_texture_coords;
uniform vec4 u_vec4_normal_map_animated_offsets;
uniform int u_int_normal_map_is_animated;
uniform float u_float_metallic;
uniform float u_float_roughness;
varying vec4 v_vec4_color;
varying highp vec2 v_vec2_texcoord;
varying highp vec3 v_vec3_fragment_pos_world;
uniform int u_int_factor_use_interpolate;
uniform float u_float_factor_interpolate_base;
uniform vec4 u_vec4_factor_interpolate_ranges;
#ifdef MIX_COLOR_MODE
varying vec4 v_vec4_color2;
# if MIX_COLOR_MODE == MIX_COLOR_MODE_READ_FROM_TARGET
varying vec4 v_vec4_pos;
uniform sampler2D u_sr2d_read_from_target_texture;
# elif MIX_COLOR_MODE == MIX_COLOR_MODE_VERTEX_ATTRIBUTE
varying float v_float_mix_color_factor;
# endif
#endif
float interpolate(float x, float base, vec4 ranges) {
    float inMin = ranges.x;
    float outMin = ranges.y;
    float inMax = ranges.z;
    float outMax = ranges.w;
    float t = clamp(outMin + (outMax - outMin) * ((x - inMin) / (inMax - inMin)), outMin, outMax);
    return base == 1. ? t : (pow(base, t) - 1.) / (base - 1.);
}
void main() {
#ifdef MIX_COLOR_MODE
    float mix_color_factor = 0.;
# if MIX_COLOR_MODE == MIX_COLOR_MODE_READ_FROM_TARGET
    vec3 clip_space = v_vec4_pos.xyz / v_vec4_pos.w;
    vec3 uv = 0.5 * clip_space + vec3(0.5);
    
    
    
    mix_color_factor = texture2D(u_sr2d_read_from_target_texture, uv.xy).r;
# elif MIX_COLOR_MODE == MIX_COLOR_MODE_VERTEX_ATTRIBUTE
    mix_color_factor = v_float_mix_color_factor;
# endif
#endif
    bool use_normal_map = u_int_is_normal_map_textured == 1;
    vec3 normal;
    
    if(use_normal_map) {
        vec2 texcoord1 = fract(v_vec2_texcoord * u_vec4_normal_map_texture_params.zw + u_vec4_normal_map_texture_params.xy + u_vec4_normal_map_animated_offsets.xy);
        vec2 spritecoord1 = mix(u_vec4_normal_map_sprite_texture_coords.xy, u_vec4_normal_map_sprite_texture_coords.zw, texcoord1);
        vec4 texcolor1 = texture2D(u_sr2d_texture1, spritecoord1);
        
        if(u_int_normal_map_is_animated == 1) {
            vec2 texcoord2 = fract(v_vec2_texcoord * u_vec4_normal_map_texture_params.zw + u_vec4_normal_map_texture_params.xy + u_vec4_normal_map_animated_offsets.zw);
            vec2 spritecoord2 = mix(u_vec4_normal_map_sprite_texture_coords.xy, u_vec4_normal_map_sprite_texture_coords.zw, texcoord2);
            vec4 texcolor2 = texture2D(u_sr2d_texture1, spritecoord2);
            normal = normalize((texcolor1.xyz * 2.0 - 1.0) + (texcolor2.xyz * 2.0 - 1.0));
        } else {
            normal = normalize((texcolor1.xyz * 2.0 - 1.0));
        }
    }
    
    vec4 color = v_vec4_color;
    
    if(u_int_is_textured == 1) {
        vec2 texcoord = fract(v_vec2_texcoord * u_float_texture_params.zw + u_float_texture_params.xy);
        vec2 spritecoord = mix(u_float_sprite_texture_coords.xy, u_float_sprite_texture_coords.zw, texcoord);
        vec4 texcolor = apply_opacity(texture2D(u_sr2d_texture, spritecoord), u_float_texture_opacity);
        color = texcolor + color * (1. - texcolor.a);
    }
#ifdef MIX_COLOR_MODE
    
    if(u_int_factor_use_interpolate == 1) {
        mix_color_factor = interpolate(mix_color_factor, u_float_factor_interpolate_base, u_vec4_factor_interpolate_ranges);
    }
    
    color = mix(color, v_vec4_color2, mix_color_factor);
#endif
    
    if(use_normal_map) {
        color.rgb = color_phong(normal, v_vec3_fragment_pos_world, color.rgb, u_float_roughness, u_float_metallic);
    } else {
        color = color * light_factor_surface();
    }
    gl_FragColor = apply_fog(color);
}
`,Cm=`#include <enable_standard_derivatives>
#include <highp_float>
#include <prelude>
#include <cam_pos>
#include <fog>
#include <screendoor_transparency>
#include <fragment_normal>
#include <bit_mask>
#include <pack_depth>
#include <shadow>
#include <light>
#include <dem>
#ifdef WEBGL1
float round(float x) {
    return floor(x + 0.5);
}
#endif
uniform sampler2D u_sr2d_texture;
uniform vec4 u_vec4_wall_padding_su; 
uniform vec4 u_vec4_texture_padding_un; 
uniform vec2 u_vec2_texture_part_count;
uniform vec2 u_vec2_max_interval_su;
uniform vec2 u_vec2_texture_slice_size_su; 
uniform ivec2 u_ivec2_layout_mode;
varying vec4 v_vec4_rotated_scaled_vertex;
varying vec2 v_vec2_quad_fraction;
varying vec2 v_vec2_wall_size_su;
#define VL_REPEAT_WITH_STRETCH 1
#define VL_STRETCH 2
#define VL_REPEAT_WITH_MAX_INTERVAL 3
#define HL_REPEAT_WITH_STRETCH 1
#define HL_STRETCH 2
#define HL_REPEAT_WITH_MAX_INTERVAL 3
bool layout_mode_stretch(float curr_point_su, float wall_size_su, out float out_tc)
{
    out_tc = curr_point_su / wall_size_su;
    return true;
}
bool layout_mode_repeat_with_stretch(float curr_point_su, float wall_size_su, float slice_size_su, float slice_count, out float out_tc, out float out_final_slice_size_su)
{
    float raw_slice_repeats = wall_size_su / slice_size_su;
    float repeated_slice_count = round(raw_slice_repeats * slice_count);
    float rounded_image_repeats = repeated_slice_count / slice_count;
    
    out_final_slice_size_su = slice_size_su * (repeated_slice_count / raw_slice_repeats);
    
    int leftover_part_count = int(mod(repeated_slice_count, slice_count));
    float start_image_tc = (slice_count - float((leftover_part_count + 1) / 2)) / slice_count;
    out_tc = mix(start_image_tc, start_image_tc + rounded_image_repeats, curr_point_su / wall_size_su);
    return true;
}
bool layout_mode_repeat_with_max_interval(float curr_point_su, float wall_size_su, float slice_size_su, float max_interval_size_su, out float out_tc)
{
    float raw_block_repeats = (wall_size_su - slice_size_su) / (slice_size_su + max_interval_size_su);
    float interval_count = ceil(raw_block_repeats);
    float window_count = interval_count + 1.0;
    float interval_size_su = (wall_size_su - (window_count * slice_size_su)) / interval_count;
    
    
    if (raw_block_repeats < 1.0)
    {
        out_tc = (curr_point_su - (wall_size_su - slice_size_su) * 0.5) / slice_size_su;
        return out_tc >= 0.0 && out_tc <= 1.0;
    }
    
    if (curr_point_su < slice_size_su)
    {
        out_tc = curr_point_su / slice_size_su;
        return true;
    }
    float block_size_su = slice_size_su + interval_size_su;
    float block_coverege_un = (curr_point_su - slice_size_su) / block_size_su;
    block_coverege_un = fract(block_coverege_un);
    
    out_tc = (block_coverege_un * block_size_su - interval_size_su) / slice_size_su;
    return block_coverege_un * block_size_su >= interval_size_su;
}
bool layout_vertical(vec2 curr_point_su, float wall_size_su, out float out_tc_y, out float out_final_slice_size_su)
{
    if (u_ivec2_layout_mode.y == VL_STRETCH)
    {
        out_final_slice_size_su = wall_size_su;
        return layout_mode_stretch(
            curr_point_su.y,
            wall_size_su,
            out_tc_y
        );
    }
    else if (u_ivec2_layout_mode.y == VL_REPEAT_WITH_STRETCH)
    {
        return layout_mode_repeat_with_stretch(
            curr_point_su.y,
            wall_size_su,
            u_vec2_texture_slice_size_su.y,
            u_vec2_texture_part_count.y,
            out_tc_y,
            out_final_slice_size_su
        );
    }
    else if (u_ivec2_layout_mode.y == VL_REPEAT_WITH_MAX_INTERVAL)
    {
        out_final_slice_size_su = u_vec2_texture_slice_size_su.y;
        return layout_mode_repeat_with_max_interval(
            curr_point_su.y,
            wall_size_su,
            u_vec2_texture_slice_size_su.y,
            u_vec2_max_interval_su.y,
            out_tc_y
        );
    }
    return false;
}
bool layout_horizontal(vec2 curr_point_su, float wall_size_su, out float out_tc_x, out float out_final_slice_size_su)
{
    if (u_ivec2_layout_mode.x == HL_STRETCH)
    {
        out_final_slice_size_su = wall_size_su;
        return layout_mode_stretch(
            curr_point_su.x,
            wall_size_su,
            out_tc_x
        );
    }
    else if (u_ivec2_layout_mode.x == HL_REPEAT_WITH_STRETCH)
    {
        return layout_mode_repeat_with_stretch(
            curr_point_su.x,
            wall_size_su,
            u_vec2_texture_slice_size_su.x,
            u_vec2_texture_part_count.x,
            out_tc_x,
            out_final_slice_size_su
        );
    }
    else if (u_ivec2_layout_mode.x == HL_REPEAT_WITH_MAX_INTERVAL)
    {
        out_final_slice_size_su = u_vec2_texture_slice_size_su.x;
        return layout_mode_repeat_with_max_interval(
            curr_point_su.x,
            wall_size_su,
            u_vec2_texture_slice_size_su.x,
            u_vec2_max_interval_su.x,
            out_tc_x
        );
    }
    return false;
}
bool layout_internal_image(vec2 curr_point_su, vec2 wall_size_su, out vec2 out_tc, out vec2 out_final_slice_size_su)
{
    float x = 0.;
    float y = 0.;
    if (!layout_vertical(curr_point_su, wall_size_su.y, y, out_final_slice_size_su.y))
    {
        return false;
    }
    if (!layout_horizontal(curr_point_su, wall_size_su.x, x, out_final_slice_size_su.x))
    {
        return false;
    }
    out_tc = vec2(x, y);
    return true;
}
bool layout_image(out vec2 out_tc, out vec2 out_final_slice_size_su)
{
    
    
    
    
    
    
    
    
    vec2 curr_point_su = clamp(v_vec2_quad_fraction, vec2(0.0), vec2(1.0)) * v_vec2_wall_size_su;
    
    bvec4 is_in_padding_zone = bvec4(
        curr_point_su.x < u_vec4_wall_padding_su.x, 
        curr_point_su.y < u_vec4_wall_padding_su.y, 
        curr_point_su.x > (v_vec2_wall_size_su.x - u_vec4_wall_padding_su.z), 
        curr_point_su.y > (v_vec2_wall_size_su.y - u_vec4_wall_padding_su.w) 
    );
    if (any(is_in_padding_zone))
    {
        vec2 left_top_offset_un = curr_point_su / u_vec4_wall_padding_su.xy;
        vec2 right_bottom_offset_un = (curr_point_su - v_vec2_wall_size_su + u_vec4_wall_padding_su.zw) / u_vec4_wall_padding_su.zw;
        vec2 left_top_uv = left_top_offset_un * u_vec4_texture_padding_un.xy;
        vec2 right_bottom_uv = (vec2(1.0) - u_vec4_texture_padding_un.zw) + right_bottom_offset_un * u_vec4_texture_padding_un.zw;
        
        out_tc = is_in_padding_zone.x ? vec2(left_top_uv.x, v_vec2_quad_fraction.y) :
                 is_in_padding_zone.z ? vec2(right_bottom_uv.x, v_vec2_quad_fraction.y) :
                 is_in_padding_zone.y ? vec2(v_vec2_quad_fraction.x, left_top_uv.y) :
                  vec2(v_vec2_quad_fraction.x, right_bottom_uv.y);
        
        
        out_final_slice_size_su = vec2(99999.0);
        return true;
    }
    
    vec2 curr_point_in_center_image_su = curr_point_su - u_vec4_wall_padding_su.xy;
    vec2 wall_size_in_center_image_su = v_vec2_wall_size_su - u_vec4_wall_padding_su.xy - u_vec4_wall_padding_su.zw;
    bool res = layout_internal_image(curr_point_in_center_image_su, wall_size_in_center_image_su, out_tc, out_final_slice_size_su);
    if (res)
    {
        out_tc = fract(out_tc);
        
        out_tc = out_tc * (vec2(1.0) - u_vec4_texture_padding_un.xy - u_vec4_texture_padding_un.zw) + u_vec4_texture_padding_un.xy;
        
        
        
        
        out_final_slice_size_su /= vec2(1.0) - u_vec4_texture_padding_un.xy - u_vec4_texture_padding_un.zw;
    }
    return res;
}
void main()
{
    if (check_dem_invalid() != 0) {
        discard;
    }
    apply_screendoor();
    vec4 color = vec4(0.);
    vec2 raw_tc = vec2(0.);
    vec2 final_slice_size_su = vec2(0.);
    bool should_render_texture = layout_image(raw_tc, final_slice_size_su);
    vec3 normal = calc_fragment_normal(v_vec4_rotated_scaled_vertex.xyz);
    vec2 modulo_coords = fract(raw_tc);
    vec4 texture_color;
#ifdef WEBGL1
    texture_color = texture2D(u_sr2d_texture, modulo_coords);
#else
    vec2 tc_dfdx = dFdx(v_vec2_quad_fraction);
    vec2 tc_dfdy = dFdy(v_vec2_quad_fraction);
    vec2 final_texture_size_su = final_slice_size_su * u_vec2_texture_part_count;
    vec2 derivative_scale = v_vec2_wall_size_su / final_texture_size_su;
    tc_dfdx *= derivative_scale;
    tc_dfdy *= derivative_scale;
    texture_color = textureGrad(u_sr2d_texture, modulo_coords, tc_dfdx, tc_dfdy);
#endif
    if (!should_render_texture) {
        discard;
    }
    color = texture_color;
    gl_FragColor = apply_fog(color);
}
`,Lm=`#include <enable_standard_derivatives>
#include <highp_float>
#include <prelude>
#include <cam_pos>
#include <fog>
#include <screendoor_transparency>
#include <fragment_normal>
#include <bit_mask>
#include <pack_depth>
#include <shadow>
#include <light>
#include <dem>
uniform sampler2D u_sr2d_texture;
uniform vec4 u_vec4_color;
varying vec3 v_vec3_rotated_scaled_vertex;
varying vec2 v_vec2_texcoord;
void main()
{
    if (check_dem_invalid() != 0) {
        discard;
    }
    apply_screendoor();
    vec3 normal = calc_fragment_normal(v_vec3_rotated_scaled_vertex);
    vec4 light = light_factor(normal);
    vec4 color = texture2D(u_sr2d_texture, v_vec2_texcoord) * u_vec4_color * light;
    gl_FragColor = apply_fog(color);
}
`,Pm={affine_step:mf,apply_opacity:Er,arrow_functions:pf,bit_mask:vf,cam_pos:Ir,circle_functions:gf,dem:yf,enable_standard_derivatives:bf,fog:xf,fragment_normal:wf,highp_float:Sf,light:Tf,light_pbr:Mf,light_phong:Ef,lowp_float:If,mediump_float:Cf,mix_color_defs:Cr,pack_depth:Lf,prelude:Pf,require_frag_depth:Bf,screendoor_transparency:zf,shadow:Rf,signed_distance_functions:Lr},Bm={arrow_line:Ff,arrow_line_identify:Df,circle_marker:Of,color:Nf,color_identify:kf,color_with_z_fade:Uf,copy:Gf,dem_elevation:Hf,dem_elevation_copy:Vf,dem_flat_bottom:jf,dem_ground:Zf,dem_ground2:Wf,dem_mesh:$f,dem_mesh2:Xf,dem_normal:Kf,depth_clear:qf,fxaa:Yf,globe:Qf,globe_halo:Jf,globe_halo_background:Af,gltf_model:em,gradient_with_z_fade:tm,heatmap:im,heatmap_texture:nm,inverse:om,label:sm,label_directional:am,line:rm,main_shadow:lm,map_mesh:cm,mesh:dm,metric_point:_m,one_way_line:um,patterned_line:hm,pointsprite:fm,pointsprite_identify:mm,rect:pm,rect_with_texture:vm,road:gm,road_identify:ym,simple_line_2d:bm,simple_line_3d:xm,simple_mesh:wm,sky:Sm,stars:Tm,striped_line:Mm,taa:Em,textured_color:Im,wall_texture:Cm,zbm_model:Lm},zm=`vec4 apply_height_factor(in vec3 vertex, const float height_factor)
{
    vertex.z *= height_factor;
    return vec4(vertex, 1.0);
}
`,Rm=`
vec2 multiply_complex(const vec2 lhs, const vec2 rhs)
{
    return vec2(lhs.x * rhs.x - lhs.y * rhs.y, lhs.x * rhs.y + lhs.y * rhs.x);
}
struct ArrowParameters
{
    float zpt_to_texcoord_factor;
    float final_size;
    float outer_width;
    vec2 widen_size;
    vec2 wing_normal;
    vec2 tip_normal;
};
ArrowParameters calculate_arrow_parameters(
    const float calculation_scale,
    const float width_zpt,
    const float border_width_zpt,
    const float segment_length_zpt,
    const float wing_width_multiplier,
    const float wing_height_multiplier,
    const float tip_height_multiplier,
    const float size_factor)
{
    float quad_width = 2.0 * border_width_zpt + 2.0 * wing_width_multiplier * width_zpt;
    float quad_height = 2.0 * border_width_zpt + segment_length_zpt;
    float max_quad_dimension = max(quad_width, quad_height);
    float zpt_to_texcoord_factor = 2.0 / max_quad_dimension;
    float final_size = calculation_scale * size_factor * max_quad_dimension;
    vec2 widen_size = 0.5 * vec2(quad_height, quad_width) * zpt_to_texcoord_factor;
    float outer_width = (width_zpt * wing_width_multiplier + border_width_zpt) * zpt_to_texcoord_factor;
    vec2 wing_normal = -normalize(vec2(wing_width_multiplier, wing_height_multiplier));
    vec2 tip_normal = normalize(vec2(wing_width_multiplier, tip_height_multiplier));
    return ArrowParameters(
        zpt_to_texcoord_factor,
        final_size,
        outer_width,
        widen_size,
        wing_normal,
        tip_normal);
}
struct VertexShiftParameters
{
    vec4 clip_space_vertex;
    float limited_factor;
};
VertexShiftParameters calculate_vertex_shift_parameters(
    const mat4 mvp,
    const vec2 vpt_size,
    const vec2 vertex,
    const vec2 widen,
    const float shift_pixels)
{
    vec2 widen_perp = vec2(-widen.y, widen.x);
    
    vec4 clip_space_widen = mvp * vec4(widen, 0., 0.);
    vec4 clip_space_widen_perp = mvp * vec4(widen_perp, 0., 0.);
    vec2 half_viewport = vpt_size / 2.;
    
    vec4 clip_space_vertex = mvp * vec4(vertex, 0.0, 1.0) + clip_space_widen;
    
    float limited_factor = calculate_multiplication_factor(
        half_viewport,
        clip_space_widen,
        clip_space_widen_perp,
        clip_space_vertex,
        shift_pixels);
    return VertexShiftParameters(
        clip_space_vertex + clip_space_widen * limited_factor,
        limited_factor);
}
`,Fm=`struct Scale
{
    float projection;
    float style;
    float style_clamped;
    float calculation;
};
Scale calculate_scale(const vec3 projection_scale_style_scale_dpi, const vec2 scale_limits)
{
    float style_scale_clamped = clamp(projection_scale_style_scale_dpi.y, scale_limits.x, scale_limits.y);
    float scale_ratio = projection_scale_style_scale_dpi.x / projection_scale_style_scale_dpi.y;
    float calculation_scale = style_scale_clamped * scale_ratio;
    return Scale(
        projection_scale_style_scale_dpi.x,
        projection_scale_style_scale_dpi.y,
        style_scale_clamped,
        calculation_scale);
}
const float g_min_scale_factor = 1e-2;
const float g_max_scale_factor = 1e2;
const float g_base_scale_numerator = 1e2;
float normalize_scale_to_tile(const float scale, const float tile_size)
{
    return clamp(
        (scale - g_min_scale_factor) / (tile_size - g_min_scale_factor),
        g_min_scale_factor,
        g_max_scale_factor);
}
`,Dm=`
#ifdef SCREENDOOR
varying vec3 v_clipspace_pos;
#endif
void save_clipspace_pos () {
    #ifdef SCREENDOOR
    v_clipspace_pos = gl_Position.xyz;
    #endif
}
`,Om=`
uniform sampler2D u_tex_dem;
uniform sampler2D u_tex_corrected_dem;
uniform float u_float_corrected_interval;
uniform mat4 u_mat4_dem_corrected;
uniform mat4 u_mat4_dem_mvp;
uniform float u_float_dem_scale;
uniform float u_float_map_center_elevation;
uniform float u_float_vertical_scale;
const float UNPACK_CENTROID = 8. / 65535.;
const float MAP_POINTS_IN_METER = 107.17318796639701;
#ifndef VARYINGS_LIMIT_9
    
    varying vec2 v_vec2_dem_tex_pos;
    
    varying float v_float_dem_invalid;
#endif
void reset_dem_varyings() {
    #ifndef VARYINGS_LIMIT_9
    v_vec2_dem_tex_pos = vec2(0, 0);
    v_float_dem_invalid = 0.;
    #endif
}
float dem_height_direct_meters(vec2 tex_pos) {
    
    if (u_float_dem_scale == 0.) {
        reset_dem_varyings();
        return 0.;
    }
    #ifndef VARYINGS_LIMIT_9
    v_vec2_dem_tex_pos = tex_pos;
    v_float_dem_invalid = 0.;
    #endif
    vec4 elevation;
    
    if (u_float_corrected_interval == 0.) {
        elevation = texture2D(u_tex_dem, tex_pos);
    }
    else {
        vec2 test_tex_pos = abs(tex_pos - vec2(0.5, 0.5));
        if (test_tex_pos.x < u_float_corrected_interval && test_tex_pos.y < u_float_corrected_interval) {
            elevation = texture2D(u_tex_corrected_dem, (u_mat4_dem_corrected * vec4(tex_pos, 0, 1)).xy);
        } else {
            elevation = texture2D(u_tex_dem, tex_pos);
        }
    }
    
    if (elevation.a < 1.) {
        #ifndef VARYINGS_LIMIT_9
        v_float_dem_invalid = 1.;
        #endif
        
        return 0.;
    } else {
        return elevation.r;
    }
}
float meters_to_tile_height(float height) {
    return (height - u_float_map_center_elevation) * MAP_POINTS_IN_METER * u_float_vertical_scale * u_float_dem_scale;
}
float dem_height_direct(vec2 tex_pos) {
    float height = dem_height_direct_meters(tex_pos);
    return meters_to_tile_height(height);
}
 
float dem_height(const vec2 coords) {
    
    if (u_float_dem_scale == 0.) {
        reset_dem_varyings();
        return 0.;
    }
    vec4 tex_pos = u_mat4_dem_mvp * vec4(coords, 0.0, 1.0);
    return dem_height_direct(tex_pos.xy);
}
float abs_height(float height) {
    return (height - u_float_map_center_elevation * MAP_POINTS_IN_METER) * u_float_dem_scale * u_float_vertical_scale;
}
vec2 unpack_dem_position(const vec2 pos) {
    return pos * UNPACK_CENTROID;
}
`,Nm=`#ifndef UBO
uniform vec2 u_vec2_depth_test_half_point_size;
#endif
uniform bool u_bool_depth_test_disable;
uniform sampler2D u_color_tex_labeling;
uniform sampler2D u_depth_tex_labeling;
float color_test(const vec2 pos, const vec4 color)
{
    vec2 halfPointSize = u_vec2_depth_test_half_point_size;
    float result = 0.;
    
    if (texture2D(u_color_tex_labeling, (vec2(pos.x - halfPointSize.x, pos.y + halfPointSize.y) + 1.) / 2.) == color) {
        result++;
    }
    if (texture2D(u_color_tex_labeling, (pos + halfPointSize + 1.) / 2.) == color) {
        result++;
    }
    if (texture2D(u_color_tex_labeling, (pos - halfPointSize + 1.) / 2.) == color) {
        result++;
    }
    if (texture2D(u_color_tex_labeling, (vec2(pos.x + halfPointSize.x, pos.y - halfPointSize.y) + 1.) / 2.) == color) {
        result++;
    }
    
    return step(3., result);
}
float depth_test(const vec2 pos, const float depth, const vec4 color)
{
    if (u_bool_depth_test_disable == true) {
        return 1.;
    }
    float colorCheck = color_test(pos, color);
    if (colorCheck == 1.) {
        return 1.;
    }
    float d = (depth + 1.) / 2.;
    float delta = 0.001;
    float texDepth = texture2D(u_depth_tex_labeling, (pos + 1.) / 2.).r;
    if (d <= texDepth) {
        return 1.;
    }
    if (d - texDepth > delta) {
        return 0.;
    }
    return 1. - (d - texDepth) / delta;
}
`,km=`uniform mat4 u_mat4_flat_mvp;
uniform mat4 u_mat4_ecef_mvp;
uniform float u_float_crossfade;
const float ECEF_CF_E = 2e-16;
const float ECEF_WORLD = 4294967296.;
vec4 get_clipspace(const vec3 fpos) {
    return u_mat4_flat_mvp * vec4(fpos, 1.);
}
vec4 get_clipspace(const vec3 fpos, const vec3 epos) {
    if (u_float_crossfade < ECEF_CF_E) {
        return u_mat4_flat_mvp * vec4(fpos, 1.);
    } else if (u_float_crossfade > (1. - ECEF_CF_E)) {
        return u_mat4_ecef_mvp * vec4(epos * ECEF_WORLD, 1.);
    }
    vec4 fclip = u_mat4_flat_mvp * vec4(fpos, 1.);
    vec4 eclip = u_mat4_ecef_mvp * vec4(epos * ECEF_WORLD, 1.);
    return mix(fclip, eclip, u_float_crossfade);
}
vec4 get_clipspace(const vec3 fpos, const vec3 epos, const float elevation) {
    float R = ECEF_WORLD + elevation;
    if (u_float_crossfade < ECEF_CF_E) {
        return u_mat4_flat_mvp * vec4(fpos, 1.);
    } else if (u_float_crossfade > (1. - ECEF_CF_E)) {
        return u_mat4_ecef_mvp * vec4(epos * R, 1.);
    }
    vec4 fclip = u_mat4_flat_mvp * vec4(fpos, 1.);
    vec4 eclip = u_mat4_ecef_mvp * vec4(epos * R, 1.);
    return mix(fclip, eclip, u_float_crossfade);
}
`,Um=`#ifndef UBO
# ifdef FOG
uniform float u_fog_distance;
# endif
# ifdef SKY
uniform mat4 u_mat4_view_transposed;
uniform mat4 u_mat4_proj_inverted;
# endif
#endif 
#if defined(FOG) || defined(SKY)
varying vec3 v_fog_pos;
#endif
void calc_fog_pos(vec3 world_pos) {
#ifdef FOG
    v_fog_pos = (world_pos - u_cam_pos) / u_fog_distance;
#endif
}
void calc_fog_pos_sky(vec4 pos) {
#ifdef SKY
    v_fog_pos = mat3(u_mat4_view_transposed) * (u_mat4_proj_inverted * pos).xyz;
#endif
}`,Gm=`#ifdef TAA
uniform vec2 u_vec2_camera_jitter;
void apply_vertex_jitter(inout vec4 clipPos) {
    clipPos.xy += clipPos.w * u_vec2_camera_jitter;
}
#endif`,Hm=`float calculate_final_width(
    const Scale scale,
    const float width,
    const float width_offset)
{
    
    float final_width = max(0., scale.calculation * width - scale.projection * width_offset);
    return final_width;
}
`,Vm=`uniform mat4 u_mat4_mvp;
`,jm=`
vec2 normalize_s08(vec2 value)
{
    return value * (1. / 127.);
}
vec3 normalize_s08(vec3 value)
{
    return value * (1. / 127.);
}
float normalize_s16(float value)
{
    return value * (1. / 32767.);
}
vec2 normalize_s16(vec2 value)
{
    return value * (1. / 32767.);
}
vec3 normalize_s16(vec3 value)
{
    return value * (1. / 32767.);
}
vec2 unpack_widen(vec2 widen_packed)
{
    
    return normalize_s08(widen_packed) * sqrt(2.);
}
vec2 unpack_texcoord(vec2 texcoord)
{
    return texcoord * (1. / 32768.);
}
vec2 unpack_model_texcoord(vec2 texcoord)
{
    const float min_value = -3.0;
    const float max_value = 5.0;
    return texcoord * (max_value - min_value) / 65536.0 + min_value;
}
float normalize_u16(float value)
{
    return value * (1. / 65535.);
}
float unpack_denormalized_distance_to_line(float value)
{
    return 1. - normalize_u16(value);
}
`,Zm=`
const float g_min_denominator = 1e-7;
const float g_max_factor = 10000.;
float calculate_multiplication_factor(
    vec2 half_viewport,
    
    vec4 clip_space_widen,
    vec4 clip_space_widen_perp,
    
    vec4 clip_space_vertex,
    float shift_pixels)
{
    float limited_factor = 0.;
    {
        
        vec2 screen_space_widen = (clip_space_widen.xy * clip_space_vertex.w - clip_space_vertex.xy * clip_space_widen.w) * half_viewport;
        vec2 screen_space_widen_perp = (clip_space_widen_perp.xy * clip_space_vertex.w - clip_space_vertex.xy * clip_space_widen_perp.w) * half_viewport;
        
        vec2 perp = vec2(screen_space_widen_perp.y, -screen_space_widen_perp.x);
        
        float perp_length = length(perp);
        vec4 v = clip_space_vertex;
        vec4 n = clip_space_widen;
        float denominator = dot(perp, screen_space_widen) / shift_pixels - n.w * v.w * perp_length;
        if (abs(denominator) > g_min_denominator)
        {
            float factor = v.w * v.w * perp_length / denominator;
            
            
            
            
            
            
            
            
            
            if (factor != factor){
                return limited_factor;
            }
            limited_factor = sign(factor) * min(g_max_factor, abs(factor));
        }
    }
    return limited_factor;
}
`,Wm=`uniform mat4 u_mat4_model;
vec3 calc_pos_world(vec4 pos) {
    
    
    
    return (u_mat4_model * pos).xyz;
}
vec3 calc_pos_world(vec3 pos) {
    return calc_pos_world(vec4(pos, 1.0));
}
vec3 calc_pos_world(vec2 pos) {
    return calc_pos_world(vec4(pos, 0.0, 1.0));
}`,$m=`
const float g_circle_scale_precision_factor = 1e8;
`,Xm=`#ifdef WEBGL2
#define varying out
#define attribute in
#define texture2D texture
#endif
#ifdef UBO
uniform CommonSettings
{
    mediump float u_float_rounding_factor;
    mediump float u_float_border_width_offset;
    mediump vec2 u_vec2_scale_limits;
    mediump vec2 u_vec2_depth_test_half_point_size;
    mediump vec2 u_vec2_vpt_size;
    
    mediump vec4 u_fog_color;
    mediump vec2 u_fog_limits;
    mediump float u_fog_horizon_blend;
    mediump float u_fog_horizon_level;
    mediump float u_fog_horizon_pad;
    mediump float u_fog_distance;
    mediump vec4 u_sky_color;
    highp vec3 u_cam_pos;
    
    
    
    
    
    
    mediump vec4 u_shadow_map_params;
    highp mat4 u_mat4_clip_to_shadow;
    mediump float u_shadow_bias;
    mediump mat4 u_mat4_view_transposed;
    mediump mat4 u_mat4_proj_inverted;
    
    mediump vec2 u_vec2_halo_viewport_size;
    mediump vec2 u_vec2_halo_viewport_center_shift;
    mediump vec4 u_vec4_halo_radius_stops;
    mediump vec4 u_vec4_halo_color;
    mediump float u_float_halo_exp_factor;
    mediump vec4 u_vec4_default_background_color;
    
    mediump mat4 u_mat4_stars;
    mediump float u_float_pixelratio;
    mediump float u_float_stars_intensity;
};
#endif
`,Km=`
float unpack_scale(float value)
{
    return exp(abs(value) / 256.) * sign(value);
}
float unpack_positive_value(float value)
{
    return exp(value / 256.);
}
vec2 make_position(const vec2 position, const float w, const vec2 inv_half_size, const float rounding_factor)
{
    vec2 non_rounded_position = (position + w) / (w * inv_half_size);
    vec2 rounded_position = floor(non_rounded_position + 0.5);
    vec2 rounding_delta = rounded_position - non_rounded_position;
    vec2 pixel_coord = non_rounded_position + rounding_factor * rounding_delta - 0.5;
    return (pixel_coord * inv_half_size) * w - w;
}
vec2 overlay_transform(const vec2 position, const vec2 inv_half_size)
{
    
    
    return position * inv_half_size;
}
float clipw(const float w, const vec2 range, const float scale)
{
    return w * (step(unpack_scale(range.x), scale) - step(unpack_positive_value(range.y), scale));
}
vec2 rescale(const vec2 corner, const vec2 rescale, const vec2 scale_range, const float style_scale)
{
    
    
    if (scale_range.x < 0.)
    {
        float default_scale_denominator = unpack_positive_value(rescale.x);
        float rescale_coeff = unpack_positive_value(rescale.y);
        float min_scale = unpack_positive_value(-scale_range.x);
        float stretch_exponent = floor(0.5 + log2(
            max(1., 1. + rescale_coeff * (1. / max(min_scale, style_scale) - default_scale_denominator))));
        return corner.xy * exp2(stretch_exponent);
    }
    return corner;
}
`,qm=`
vec4 round_position(const vec4 position, const vec2 half_viewport)
{
    if (
        position.w < 0.
        || position.x < -position.w
        || position.x > position.w
        || position.y < -position.w
        || position.y > position.w
        || position.z < -position.w
        || position.z > position.w)
    {
        return position;
    }
    else
    {
        
        return vec4(
            sign(position.xy) * floor(abs(position.xy) * half_viewport / position.w + .5)
                * position.w / half_viewport,
            position.zw);
    }
}
`,Ym=`#ifdef RENDER_SHADOWS
varying vec4 v_pos_from_light;
varying float v_depth_metric;
#ifndef UBO
uniform mat4 u_mat4_clip_to_shadow;
uniform mediump vec4 u_shadow_map_params;
uniform mediump float u_shadow_bias;
#endif
void compute_shadow_vertex(vec4 clip_pos)
{
    v_pos_from_light = u_mat4_clip_to_shadow * clip_pos;
    v_pos_from_light.z -= u_shadow_bias;
    v_depth_metric = 0.5 * v_pos_from_light.z + 0.5;
}
void compute_shadow_vertex(vec4 clip_pos, vec3 normal, mat4 mvp_mat)
{
    
    float normal_bias = u_shadow_map_params[3];
    vec3 norm_from_light = (u_mat4_clip_to_shadow * mvp_mat * vec4(normal, 0.0)).xyz;
    v_pos_from_light = u_mat4_clip_to_shadow * clip_pos;
    v_pos_from_light.xyz += normal_bias * normalize(norm_from_light);
    v_pos_from_light.z -= u_shadow_bias;
    v_depth_metric = 0.5 * v_pos_from_light.z + 0.5;
}
#else 
void compute_shadow_vertex(vec4 clip_pos) { }
void compute_shadow_vertex(vec4 clip_pos, vec3 normal, mat4 mvp_mat) { }
#endif `,Qm=`
const float FADE_THRESHOLD = 0.06;
float interleaved_gradient_noise(vec3 coords)
{
    const vec3 m = vec3(0.06711056, 0.00583715, 52.9829189);
    return fract(m.z * fract(dot(coords.xy, m.xy)));
}
float apply_show_ratio(const float show_ratio, const vec3 instance_wp) {
    float noise = interleaved_gradient_noise(instance_wp);
    float threshold_range = 1. - FADE_THRESHOLD * 2.;
    float adjusted_noise = FADE_THRESHOLD + noise * threshold_range;
    float opacity = (show_ratio - adjusted_noise + FADE_THRESHOLD) / (FADE_THRESHOLD * 2.);
    return clamp(opacity, 0.0, 1.0); 
}
`,Jm=`struct PolylineDistance
{
    
    float vertex_distance_from_start;
    
    float segment_distance_from_start;
    
    float total_length;
};
struct StripedLineInParams
{
    float dash_length;
    float space_length;
    float dash2_length;
    float line_width;
};
struct StripedLineOutParams
{
    
    float part_color_swap_threshold;
    float distance_in_parts;
};
void calculate_line_params(in PolylineDistance polyline_distance, in StripedLineInParams striped_line_params, out StripedLineOutParams line_params)
{
    
    float requested_part_length =
        striped_line_params.dash_length
        + striped_line_params.space_length;
    
    float space2_length = requested_part_length - striped_line_params.dash2_length;
    
    float part_count = max(
        floor(polyline_distance.total_length / requested_part_length + 0.5),
        1.0);
    
    float part_length = polyline_distance.total_length / part_count;
    
    float dash_length = (part_length / requested_part_length) * striped_line_params.dash2_length;
    float part_color_swap_threshold = dash_length / part_length;
    
    
    float segment_start = fract((polyline_distance.segment_distance_from_start + 0.5 * dash_length) / part_length);
    float vertex_normalized_distance = segment_start + polyline_distance.vertex_distance_from_start / part_length;
    line_params = StripedLineOutParams(
        part_color_swap_threshold,
        vertex_normalized_distance);
}
`,Am=`#include <prelude>
#include <mvp_mat>
#include <packed_attributes>
#include <pixel_offset>
#include <signed_distance_functions>
#include <arrow_functions>
#include <calculate_scale>
#include <apply_opacity>
#include <pos_world>
#include <cam_pos>
#include <fog>
#ifndef UBO
uniform float u_float_border_width_offset;
uniform vec2 u_vec2_scale_limits;
uniform mediump vec2 u_vec2_vpt_size;
#endif
uniform vec4 u_vec4_color;
uniform vec4 u_vec4_border_color;
uniform vec3 u_vec3_projection_scale_style_scale_dpi;
uniform float u_float_width_zpt;
uniform float u_float_wing_height_multiplier;
uniform float u_float_wing_width_multiplier;
uniform float u_float_border_width_zpt;
uniform float u_float_size_factor;
uniform float u_float_tip_height_multiplier;
uniform float u_float_relative_end_position;
uniform float u_float_tip_movement_amplitude;
uniform float u_float_vertex_shift; 
uniform float u_float_opacity;
uniform float u_float_tip_radius_zpt;
uniform float u_float_wing_radius_zpt;
uniform float u_float_tail_radius_zpt;
attribute vec2 a_vec2_vertex;
attribute vec2 a_vec2_segment_end;
attribute vec4 a_vec4_texture_widen_arrow_widen;
attribute vec2 a_vec2_widen;
attribute vec2 a_vec2_direction; 
attribute float a_float_distance_from_start;
attribute float a_float_object_length;
attribute float a_float_type;
attribute vec4 a_vec4_identifier; 
varying vec2 v_vec2_line_type_arrow_tail;
varying vec4 v_vec4_arrow_width_length_border_outer;
varying vec4 v_vec4_texcoord_arrow_line;
varying vec4 v_vec4_distance_vertex_hiding;
varying vec4 v_vec4_identifier;
varying vec4 v_vec4_color;
varying vec4 v_vec4_border_color;
#ifdef ENTRANCE_ARROWS_ROUNDING
varying vec3 v_vec3_radius_tip_wing_tail;
#endif
varying vec4 v_vec4_circle_center_tip_wing;
const float g_w_factor = 1e-7;
const float g_type_line = 0.;
const float g_type_arrow = 1.;
const float g_type_start_border = 2.;
const float g_type_line_ending = 3.;
const float g_type_line_cut = 4.;
const float g_shift_pixels = 2.;
const float g_line_overlapping_part = .2;
struct ArrowLineViewParameters
{
    float vertex_type;
    float width_zpt;
    float border_width_zpt;
    float border_width_offset;
    float tip_radius_zpt;
    float wing_radius_zpt;
    float tail_radius_zpt;
    float arrow_segment_length_zpt;
    float tip_height_multiplier;
    float wing_height_multiplier;
    float wing_width_multiplier;
    float size_factor;
    vec2 vertex_position;
    vec2 vertex_widen;
    vec2 line_texture_widen;
    vec2 arrow_texture_widen;
    vec2 segment_direction;
    float segment_length;
    float distance_to_end;
};
struct DistanceShiftParameters
{
    float shift;
    bool invisible;
};
vec2 perp(const vec2 vector)
{
    return vec2(-vector.y, vector.x);
}
vec2 vertex_shift(const Scale scale)
{
    return u_float_vertex_shift * u_float_tip_movement_amplitude * normalize_s08(a_vec2_direction) * scale.calculation;
}
vec2 arrow_shift(const ArrowLineViewParameters view)
{
    
    
    
    return view.segment_direction * view.distance_to_end;
}
float erase_length_end()
{
    return clamp(u_float_relative_end_position, 0., 1.) * a_float_object_length;
}
void set_texcoord_varyings(const vec2 arrow_texcoord, const vec2 line_texcoord)
{
    v_vec4_texcoord_arrow_line = vec4(arrow_texcoord, line_texcoord);
}
void set_arrow_varyings(
    const float arrow_width,
    const float arrow_length,
    const float arrow_border,
    const float arrow_outer_width,
    const float arrow_tail_hide_part,
    const float arrow_tip_radius,
    const float arrow_wing_radius,
    const float tail_radius,
    const vec2 tip_circle_center,
    const vec2 wing_circle_center)
{
    v_vec4_arrow_width_length_border_outer = vec4(
        arrow_width,
        arrow_length,
        arrow_border,
        arrow_outer_width);
    v_vec2_line_type_arrow_tail = vec2(
        a_float_type,
        arrow_tail_hide_part);
    #ifdef ENTRANCE_ARROWS_ROUNDING
    v_vec3_radius_tip_wing_tail = vec3(
        arrow_tip_radius,
        arrow_wing_radius,
        tail_radius);
    #endif
    v_vec4_circle_center_tip_wing = vec4(tip_circle_center.xy, wing_circle_center.xy);
}
DistanceShiftParameters calculate_entrance_arrow_distances(
    const ArrowLineViewParameters view,
    const float signed_distance_shift,
    const float arrow_final_size,
    const float entrance_arrow_distance_shift)
{
    DistanceShiftParameters line_distance_parameters = DistanceShiftParameters(
        signed_distance_shift + entrance_arrow_distance_shift,
        false);
    if (a_float_type == g_type_arrow)
    {
        
        
        bool outside_of_current_segment = view.distance_to_end > view.segment_length + entrance_arrow_distance_shift;
        
        bool inside_end_hide = a_float_distance_from_start + entrance_arrow_distance_shift > erase_length_end();
        return DistanceShiftParameters(
            
            line_distance_parameters.shift + view.distance_to_end,
            outside_of_current_segment || inside_end_hide
        );
    }
    else
    {
        return line_distance_parameters;
    }
}
void set_distance_varyings(
    const ArrowLineViewParameters view,
    const float arrow_final_size,
    const float signed_shift_distance)
{
    float entrance_arrow_distance_shift = arrow_final_size * (2. - g_line_overlapping_part);
    DistanceShiftParameters distance_shift_parameters = calculate_entrance_arrow_distances(
        view,
        signed_shift_distance,
        arrow_final_size,
        entrance_arrow_distance_shift);
    v_vec4_distance_vertex_hiding =
        vec4(
            a_float_distance_from_start + distance_shift_parameters.shift,
            0.,
            erase_length_end(),
            distance_shift_parameters.invisible
                ? a_float_object_length
                : 0.
        ) / a_float_object_length;
}
ArrowLineViewParameters decode_arrow_line_view_parameters()
{
    float width_zpt = u_float_width_zpt;
    float border_width_zpt = u_float_border_width_zpt;
    float arrow_segment_length_zpt = width_zpt * u_float_tip_height_multiplier + border_width_zpt;
    float vertex_type = a_float_type;
    
    vec2 segment_direction = (vertex_type == g_type_line_ending || vertex_type == g_type_line_cut)
        ? normalize(a_vec2_vertex - a_vec2_segment_end)
        : normalize(a_vec2_segment_end - a_vec2_vertex);
    float segment_length = length(a_vec2_segment_end - a_vec2_vertex);
    float distance_to_end = erase_length_end() - a_float_distance_from_start;
    return ArrowLineViewParameters(
        vertex_type,
        width_zpt,
        border_width_zpt,
        u_float_border_width_offset,
        u_float_tip_radius_zpt,
        u_float_wing_radius_zpt,
        u_float_tail_radius_zpt,
        arrow_segment_length_zpt,
        u_float_tip_height_multiplier,
        u_float_wing_height_multiplier,
        u_float_wing_width_multiplier,
        u_float_size_factor,
        a_vec2_vertex,
        unpack_widen(a_vec2_widen),
        unpack_widen(a_vec4_texture_widen_arrow_widen.xy),
        unpack_widen(a_vec4_texture_widen_arrow_widen.zw),
        segment_direction,
        segment_length,
        distance_to_end);
}
vec4 process_arrow_line_vertex(const Scale scale, const mat4 mvp, const vec2 vpt_size)
{
    ArrowLineViewParameters view = decode_arrow_line_view_parameters();
    
    ArrowParameters arrow_parameters = calculate_arrow_parameters(
        scale.calculation,
        view.width_zpt,
        view.border_width_zpt,
        view.arrow_segment_length_zpt,
        view.wing_width_multiplier,
        view.wing_height_multiplier,
        view.tip_height_multiplier,
        view.size_factor);
    vec2 vertex_widen = view.vertex_widen;
    vec2 texture_widen_with_sign = view.line_texture_widen;
    
    
    float shift_sign = sign(dot(vertex_widen, texture_widen_with_sign));
    vec2 line_texture_widen = shift_sign * texture_widen_with_sign;
    
    float line_final_size = (view.width_zpt + 2. * view.border_width_zpt) * view.size_factor * scale.calculation;
    float final_size = (view.vertex_type == g_type_arrow)
        ? arrow_parameters.final_size
        : line_final_size;
    
    
    
    
    vec2 line_texture_widen_perp = perp(line_texture_widen);
    float shift_distance = abs(dot(vertex_widen, line_texture_widen_perp)) * final_size;
    vec2 shift_direction = line_texture_widen_perp * sign(dot(vertex_widen, line_texture_widen_perp));
    vec2 line_vertex_shift = vertex_widen * final_size - shift_direction * max(0., shift_distance - .5 * view.segment_length);
    
    vec2 arrow_vertex_widen = vertex_widen * arrow_parameters.final_size;
    vec2 scene_vertex_shift = (view.vertex_type == g_type_arrow)
        ? arrow_vertex_widen
        : line_vertex_shift;
    vec2 arrow_position_shift = (view.vertex_type == g_type_arrow)
        ? arrow_shift(view)
        : vec2(0.);
    
    float shift_pixels = g_shift_pixels * sqrt(2.);
    VertexShiftParameters line_shift_parameters = calculate_vertex_shift_parameters(
        mvp,
        vpt_size,
        view.vertex_position + (vertex_shift(scale) + arrow_position_shift),
        scene_vertex_shift,
        shift_pixels);
    float arrow_line_texcoord_scale = line_final_size / arrow_parameters.final_size;
    float line_texcoord_scale = (view.vertex_type != g_type_arrow)
        ? arrow_line_texcoord_scale
        : 1.;
    vec2 line_texcoord = line_texture_widen * (1. + line_shift_parameters.limited_factor) * line_texcoord_scale;
    
    float arrow_texcoord_scale = (view.vertex_type == g_type_start_border)
        ? arrow_line_texcoord_scale
        : 1.;
    vec2 arrow_texcoord = view.arrow_texture_widen * (1. + line_shift_parameters.limited_factor) * arrow_texcoord_scale;
    set_texcoord_varyings(arrow_texcoord, line_texcoord);
    float arrow_width = view.width_zpt * arrow_parameters.zpt_to_texcoord_factor;
    float arrow_length = view.arrow_segment_length_zpt * arrow_parameters.zpt_to_texcoord_factor;
    float arrow_tip_radius = view.tip_radius_zpt * arrow_parameters.zpt_to_texcoord_factor;
    float arrow_wing_radius = view.wing_radius_zpt * arrow_parameters.zpt_to_texcoord_factor;
    float tail_radius = view.tail_radius_zpt * arrow_parameters.zpt_to_texcoord_factor;
    
    float texcoord_border_width = view.border_width_zpt * arrow_parameters.zpt_to_texcoord_factor;
    float border_width_texcoord_offset = view.border_width_offset * arrow_parameters.zpt_to_texcoord_factor;
    float arrow_border = max(0., texcoord_border_width - scale.style / scale.style_clamped * border_width_texcoord_offset);
    
    float tail_shift_direction = (view.vertex_type == g_type_line_ending || view.vertex_type == g_type_start_border) ? 1. : -1.;
    float tail_hide_shift = dot(arrow_vertex_widen, tail_shift_direction * view.segment_direction);
    float arrow_tail_hide_part = (view.distance_to_end - tail_hide_shift) * arrow_parameters.zpt_to_texcoord_factor / view.size_factor;
    
    
    float half_length = arrow_length / 2.;
    float arrow_height = arrow_width * (view.tip_height_multiplier - view.wing_height_multiplier);
    float A1 = arrow_parameters.tip_normal.x;
    float B1 = arrow_parameters.tip_normal.y;
    float C1 = -half_length * A1 - arrow_border + arrow_wing_radius;
    float A2 = arrow_parameters.wing_normal.x;
    float B2 = arrow_parameters.wing_normal.y;
    float C2 = (arrow_height - half_length) * A2 - arrow_border + arrow_wing_radius;
    float denominator = A1 * B2 - A2 * B1;
    float wing_circle_center_x = (C2 * B1 - C1 * B2) / denominator;
    float wing_circle_center_y = (A2 * C1 - A1 * C2) / denominator;
    vec2 wing_circle_center = vec2(wing_circle_center_x, wing_circle_center_y);
    vec2 tip_circle_center = vec2(half_length - (arrow_tip_radius - arrow_border) / arrow_parameters.tip_normal.x, 0.);
    set_arrow_varyings(
        arrow_width,
        arrow_length,
        arrow_border,
        arrow_parameters.outer_width,
        arrow_tail_hide_part,
        arrow_tip_radius,
        arrow_wing_radius,
        tail_radius,
        tip_circle_center,
        wing_circle_center);
    set_distance_varyings(
        view,
        arrow_parameters.final_size,
        shift_sign * shift_distance);
    
    
    return line_shift_parameters.clip_space_vertex / final_size;
}
void main()
{
    v_vec4_identifier = a_vec4_identifier; 
    Scale scale = calculate_scale(u_vec3_projection_scale_style_scale_dpi, u_vec2_scale_limits);
    vec4 processed_vertex = process_arrow_line_vertex(scale, u_mat4_mvp, u_vec2_vpt_size);
    gl_Position = processed_vertex * g_w_factor;
    v_vec4_color = apply_opacity(u_vec4_color, u_float_opacity);
    v_vec4_border_color = apply_opacity(u_vec4_border_color, u_float_opacity);
    
    vec3 pos_world = calc_pos_world(a_vec2_vertex);
    calc_fog_pos(pos_world);
}
`,ep=`#include <prelude>
#include <mvp_mat>
#include <dem>
#include <apply_height_factor>
uniform float u_float_height_factor;
uniform float u_float_floor_elevation;
attribute vec2 a_vec2_vertex;
attribute float a_float_z;
attribute vec2 a_vec2_dem_position;
attribute float a_float_visibility;
varying float v_depth_metric;
void main()
{
    
    if (a_float_visibility == 0.0) {
        gl_Position = vec4(0, 0, 1, 1);
        return;
    }
    
    float height = dem_height(unpack_dem_position(a_vec2_dem_position));
    
    if (a_float_z == 0.) {
        float posHeight = dem_height(a_vec2_vertex);
        if (height > posHeight) {
            height = posHeight;
        }
    }
    height += u_float_floor_elevation;
    vec4 vertex_hf = apply_height_factor(vec3(a_vec2_vertex, a_float_z), u_float_height_factor);
    vertex_hf.z += height;
    
    vertex_hf.z = max(vertex_hf.z, height);
    gl_Position = u_mat4_mvp * vertex_hf;
    v_depth_metric = (gl_Position.z + 1.0) / 2.0;
}`,tp=`#include <prelude>
#include <ecef_mvp_mat>
#include <pos_world>
#include <cam_pos>
#include <shadow>
#include <fog>
#include <dem>
attribute vec3 a_vec3_flat_position;
attribute vec3 a_vec3_ecef_position;
attribute vec2 a_vec2_widen;
#ifndef UBO
uniform vec2 u_vec2_vpt_size;
#endif
uniform float u_float_width;
varying vec2 v_vec2_circle;
varying float v_float_width;
void main() {
    float height = dem_height(a_vec3_flat_position.xy);
    vec3 anchor = a_vec3_flat_position;
    anchor.z += height;
    vec4 pos = get_clipspace(anchor, a_vec3_ecef_position);
    vec4 ndc_position = pos / pos.w;
    ndc_position.xy += a_vec2_widen * u_float_width / u_vec2_vpt_size;
    gl_Position = ndc_position;
    v_vec2_circle = a_vec2_widen;
    v_float_width = u_float_width;
    vec3 pos_world = calc_pos_world(anchor);
    calc_fog_pos(pos_world);
}
`,ip=`#include <prelude>
#include <ecef_mvp_mat>
#include <dem>
attribute vec3 a_vec3_flat_position;
attribute vec3 a_vec3_ecef_position;
attribute vec2 a_vec2_widen;
attribute vec4 a_vec4_identifier;
#ifndef UBO
uniform vec2 u_vec2_vpt_size;
#endif
uniform float u_float_width;
varying vec2 v_vec2_circle;
varying vec4 v_vec4_identifier;
void main() {
    float height = dem_height(a_vec3_flat_position.xy);
    v_vec2_circle = a_vec2_widen;
    v_vec4_identifier = a_vec4_identifier;
    if (vec4(1., 1., 1., 1.) != a_vec4_identifier)
    {
        vec3 position_on_dem = a_vec3_flat_position;
        position_on_dem.z += height;
        vec4 pos = get_clipspace(position_on_dem, a_vec3_ecef_position);
        vec4 ndc_position = pos / pos.w;
        ndc_position.xy += a_vec2_widen * u_float_width / u_vec2_vpt_size;
        gl_Position = ndc_position;
    }
    else
    {
        gl_Position = vec4(1., 1., 1., 1.);
    }
}
`,np=`#include <prelude>
#include <mvp_mat>
#include <apply_opacity>
#include <pos_world>
#include <cam_pos>
#include <fog>
#include <jitter>
#include <shadow>
#include <mix_color_defs>
#include <packed_attributes>
uniform vec4 u_vec4_color;
uniform float u_float_opacity;
uniform float u_float_floor_elevation;
attribute vec2 a_vec2_vertex;
attribute float a_float_visibility;
varying vec4 v_vec4_color;
varying vec2 v_vec2_texcoord;
#ifdef MIX_COLOR_MODE
uniform vec4 u_vec4_color2;
varying vec4 v_vec4_color2;
# if MIX_COLOR_MODE == MIX_COLOR_MODE_READ_FROM_TARGET
varying vec4 v_vec4_pos;
# elif MIX_COLOR_MODE == MIX_COLOR_MODE_VERTEX_ATTRIBUTE
varying float v_float_mix_color_factor;
attribute float a_float_mix_factor;
# endif
#endif
varying vec3 v_vec3_fragment_pos_world;
void main()
{
#ifdef MIX_COLOR_MODE
# if MIX_COLOR_MODE == MIX_COLOR_MODE_READ_FROM_TARGET
    v_vec4_pos = vec4(0, 0, 0, 1);
# elif MIX_COLOR_MODE == MIX_COLOR_MODE_VERTEX_ATTRIBUTE
    v_float_mix_color_factor = a_float_mix_factor;
#  ifdef MIX_COLOR_MODE_VERTEX_ATTRIBUTE_NAME
#   if MIX_COLOR_MODE_VERTEX_ATTRIBUTE_NAME == VERTEX_ATTRIBUTE_NAME_DENORMALIZED_DISTANCE_TO_LINE
    v_float_mix_color_factor = unpack_denormalized_distance_to_line(a_float_mix_factor);
#   endif
#  endif
# endif
#endif
    if (a_float_visibility == 0.0) {
        gl_Position = vec4(0, 0, 0, 1);
        return;
    }
    v_vec4_color = apply_opacity(u_vec4_color, u_float_opacity);
#ifdef MIX_COLOR_MODE
    v_vec4_color2 = apply_opacity(u_vec4_color2, u_float_opacity);
#endif
    vec4 vertex = vec4(a_vec2_vertex, u_float_floor_elevation, 1.0);
    gl_Position = u_mat4_mvp * vertex;
    vec3 pos_world = calc_pos_world(vertex.xyz);
    calc_fog_pos(pos_world);
    
    
    
    
    
    
    
    v_vec2_texcoord = fract(abs((a_vec2_vertex - 0.25) * 2.));
    v_vec3_fragment_pos_world = pos_world;
#ifdef TAA
    apply_vertex_jitter(gl_Position);
#endif
    compute_shadow_vertex(gl_Position, vec3(0.0, 0.0, 1.0), u_mat4_mvp);
#ifdef MIX_COLOR_MODE
# if MIX_COLOR_MODE == MIX_COLOR_MODE_READ_FROM_TARGET
    v_vec4_pos = gl_Position;
# endif
#endif
}
`,op=`#include <prelude>
#include <mvp_mat>
#include <round_position>
#ifndef UBO
uniform vec2 u_vec2_vpt_size;
#endif
uniform float u_float_floor_elevation;
attribute vec2 a_vec2_vertex;
attribute vec4 a_vec4_identifier;
attribute float a_float_visibility;
varying vec4 v_vec4_identifier;
void main()
{
    v_vec4_identifier = a_vec4_identifier;
    if (vec4(1., 1., 1., 1.) != a_vec4_identifier && a_float_visibility != 0.0)
    {
        gl_Position = round_position(u_mat4_mvp * vec4(a_vec2_vertex, u_float_floor_elevation, 1.), .5 * u_vec2_vpt_size);
    }
    else
    {
        gl_Position = vec4(1., 1., 1., 1.);
    }
}
`,sp=`#include <prelude>
#include <mvp_mat>
#include <packed_attributes>
attribute vec2 a_vec2_vertex;
attribute float a_float_height;
varying float v_float_height;
void main()
{
    gl_Position = u_mat4_mvp * vec4(a_vec2_vertex, 0.0, 1.0);
    v_float_height = a_float_height;
}
`,ap=`#include <prelude>
#include <mvp_mat>
#include <packed_attributes>
uniform mat4 u_mat4_dem_corrected;
attribute vec2 a_vec2_vertex;
attribute vec2 a_vec2_texcoord;
varying vec2 v_vec2_texcoord;
void main()
{
    gl_Position = u_mat4_mvp * vec4(a_vec2_vertex, 0.0, 1.0);
    v_vec2_texcoord = (u_mat4_dem_corrected * vec4(unpack_texcoord(a_vec2_texcoord), 0, 1)).xy;
}
`,rp=`#include <prelude>
#include <mvp_mat>
#include <dem>
attribute vec2 a_vec2_vertex;
attribute vec2 a_vec2_centroid;
attribute vec2 a_vec2_extender;
varying vec4 v_vec4_color;
void main()
{
    vec4 tex_pos = u_mat4_dem_corrected * u_mat4_mvp * vec4(unpack_dem_position(a_vec2_centroid), 0.0, 1.0);
    v_vec4_color = texture2D(u_tex_dem, tex_pos.xy);
    gl_Position = u_mat4_mvp * vec4(a_vec2_vertex + a_vec2_extender * 1./64., 0.0, 1.0);
}
`,lp=`#include <prelude>
#include <mvp_mat>
#include <dem>
uniform mat4 u_mat4_model;
attribute vec2 a_vec2_position;
varying vec4 v_vec4_coords;
void main()
{
    vec4 tex_pos = u_mat4_dem_mvp * vec4(a_vec2_position, 0.0, 1.0);
    float height = dem_height_direct_meters(tex_pos.xy / tex_pos.w);
    float tile_height = meters_to_tile_height(height);
    gl_Position = u_mat4_mvp * vec4(a_vec2_position, tile_height, 1.0);
    v_vec4_coords = u_mat4_model * vec4(a_vec2_position, 0, 1.0);
    
    v_vec4_coords[2] = height;
}
`,cp=`#include <prelude>
#include <mvp_mat>
#include <dem>
uniform mat4 u_mat4_model;
attribute vec2 a_vec2_vertex;
attribute float a_float_height;
varying vec4 v_vec4_coords;
void main()
{
    float tile_height = meters_to_tile_height(a_float_height);
    gl_Position = u_mat4_mvp * vec4(a_vec2_vertex, tile_height, 1.0);
    v_vec4_coords = u_mat4_model * vec4(a_vec2_vertex, 0, 1.0);
    
    v_vec4_coords[2] = a_float_height;
}
`,dp=`#include <prelude>
#include <mvp_mat>
#include <dem>
#include <pos_world>
#include <cam_pos>
#include <shadow>
#include <fog>
#include <jitter>
uniform mat4 u_mat4_flat_map_mvp;
attribute vec2 a_vec2_position;
varying vec4 v_vec4_texcoord;
varying vec2 hs_tex_pos;
void main()
{
    vec4 coords = u_mat4_mvp * vec4(a_vec2_position, 0.0, 1.0);
    vec4 tex_pos = u_mat4_dem_mvp * vec4(a_vec2_position, 0.0, 1.0);
    float height = dem_height_direct(tex_pos.xy / tex_pos.w);
    gl_Position = u_mat4_mvp * vec4(a_vec2_position, height, 1.0);
    vec4 flat_coord = u_mat4_flat_map_mvp * vec4(a_vec2_position, 0.0, 1.0);
    v_vec4_texcoord = vec4(flat_coord.xy, 0., flat_coord.w);
    hs_tex_pos = tex_pos.xy;
    vec3 pos_world = calc_pos_world(vec4(a_vec2_position, height, 1.0));
    calc_fog_pos(pos_world);
#ifdef TAA
    apply_vertex_jitter(gl_Position);
#endif
    
    compute_shadow_vertex(gl_Position, vec3(0.0, 0.0, 1.0), u_mat4_mvp);
}
`,_p=`#include <prelude>
#include <mvp_mat>
#include <dem>
#include <pos_world>
#include <cam_pos>
#include <shadow>
#include <fog>
#include <jitter>
uniform mat4 u_mat4_flat_map_mvp;
attribute vec2 a_vec2_vertex;
attribute float a_float_height;
varying vec4 v_vec4_texcoord;
varying vec3 v_vec3_position;
void main() {
    float height_tile = meters_to_tile_height(a_float_height);
    vec4 tex_pos = u_mat4_dem_mvp * vec4(a_vec2_vertex, 0.0, 1.0);
    gl_Position = u_mat4_mvp * vec4(a_vec2_vertex, height_tile, 1.0);
    vec4 flat_coord = u_mat4_flat_map_mvp * vec4(a_vec2_vertex, 0., 1.0);
    v_vec4_texcoord = vec4(flat_coord.xy, 1., flat_coord.w);
    vec3 pos_world = calc_pos_world(vec4(a_vec2_vertex, height_tile, 1.0));
    
    
    mat3 rotation_scale_mat = mat3(u_mat4_model);
    v_vec3_position = rotation_scale_mat * vec3(a_vec2_vertex, height_tile);
    calc_fog_pos(pos_world);
#ifdef TAA
    apply_vertex_jitter(gl_Position);
#endif
    
    compute_shadow_vertex(gl_Position, vec3(0.0, 0.0, 1.0), u_mat4_mvp);
}
`,up=`#include <prelude>
#include <mvp_mat>
#include <packed_attributes>
attribute vec2 a_vec2_vertex;
attribute vec2 a_vec2_texcoord;
varying vec2 v_vec2_texcoord;
void main()
{
    gl_Position = vec4((a_vec2_vertex * 2. - vec2(1, 1)), 0.0, 1.0);
    v_vec2_texcoord = unpack_texcoord(a_vec2_texcoord);
}
`,hp=`#include <prelude>
#include <mvp_mat>
#include <dem>
#include <packed_attributes>
#include <apply_height_factor>
#include <apply_opacity>
#include <pos_world>
#include <cam_pos>
#include <fog>
#include <clipspace_pos>
#include <jitter>
#include <shadow>
uniform vec4 u_vec4_color;
uniform mat4 u_mat4_gradient;
uniform float u_float_height_factor;
uniform float u_float_opacity;
uniform float u_float_floor_elevation;
uniform int u_int_is_roof;
attribute vec2 a_vec2_vertex;
attribute float a_float_z;
attribute vec2 a_vec2_dem_position;
attribute float a_float_visibility;
varying vec4 v_vec4_color;
varying mat4 v_mat4_gradient;
varying vec4 v_vec4_rotated_scaled_vertex;
const float g_wall_offset_isometric = .001;
const float g_wall_offset_perspective = 8.;
void main()
{
    
    if (a_float_visibility == 0.0) {
        gl_Position = vec4(0, 0, 1, 1);
        return;
    }
    float height = dem_height(unpack_dem_position(a_vec2_dem_position));
    
    if (a_float_z == 0.) {
        float posHeight = dem_height(a_vec2_vertex);
        if (height > posHeight) {
            height = posHeight;
        }
    }
    height += u_float_floor_elevation;
    vec3 vertex = vec3(a_vec2_vertex, a_float_z);
    vec4 vertex_hf = apply_height_factor(vertex, u_float_height_factor);
    vertex_hf.z += height;
    
    vertex_hf.z = max(vertex_hf.z, height);
    vec4 clip_pos = u_mat4_mvp * vertex_hf;
    gl_Position = clip_pos;
    if (u_int_is_roof == 0)
    {
        
        if ((u_mat4_mvp[0][3] == 0.) && (u_mat4_mvp[1][3] == 0.) && (u_mat4_mvp[2][3] == 0.))
        {
            gl_Position.z += g_wall_offset_isometric;
        }
        else
        {
            
            
            
            if (height == 0.) {
                gl_Position.z += g_wall_offset_perspective;
            } else {
                gl_Position.z += g_wall_offset_isometric;
            }
        }
    }
    vec3 pos_world = calc_pos_world(vertex_hf);
    calc_fog_pos(pos_world);
    save_clipspace_pos();
#ifdef TAA
    apply_vertex_jitter(gl_Position);
#endif
    
    
    mat3 rotation_scale_mat = mat3(u_mat4_model);
    v_vec4_rotated_scaled_vertex.xyz = rotation_scale_mat * vertex;
    v_vec4_color = apply_opacity(u_vec4_color, u_float_opacity);
    if (u_mat4_gradient[0][0] !=0.)
    {
        
        if (a_float_z > 0.0)
        {
            v_vec4_rotated_scaled_vertex.w = 1.;
        } else {
            v_vec4_rotated_scaled_vertex.w = 0.;
        }
        v_mat4_gradient = u_mat4_gradient;
        for (int i = 1; i <= 2; i++) {
            v_mat4_gradient[i] = apply_opacity(v_mat4_gradient[i], u_float_opacity);
        }
    }
    
    compute_shadow_vertex(clip_pos);
}
`,fp=`#include <prelude>
#include <mvp_mat>
#include <dem>
#include <round_position>
#include <apply_height_factor>
#ifndef UBO
uniform vec2 u_vec2_vpt_size;
#endif
uniform float u_float_height_factor;
uniform float u_float_floor_elevation;
attribute vec2 a_vec2_vertex;
attribute float a_float_z;
attribute vec4 a_vec4_identifier;
attribute vec2 a_vec2_dem_position;
attribute float a_float_visibility;
varying vec4 v_vec4_identifier;
void main()
{
    
    
    
    if (a_float_visibility == 0.0 || a_vec4_identifier == vec4(1., 1., 1., 1.)) {
        gl_Position = vec4(0, 0, 1, 1);
        return;
    }
    float height = dem_height(unpack_dem_position(a_vec2_dem_position));
    
    if (a_float_z == 0.) {
        float posHeight = dem_height(a_vec2_vertex);
        if (height > posHeight) {
            height = posHeight;
        }
    }
    height += u_float_floor_elevation;
    v_vec4_identifier = a_vec4_identifier;
    vec4 vertex_hf = apply_height_factor(vec3(a_vec2_vertex, a_float_z), u_float_height_factor);
    vertex_hf.z += height;
    
    vertex_hf.z = max(vertex_hf.z, height);
    gl_Position = round_position(
        u_mat4_mvp * vertex_hf,
        .5 * u_vec2_vpt_size);
}
`,mp=`#include <prelude>
#include <ecef_mvp_mat>
attribute vec3 a_vec3_ecef_position;
attribute vec3 a_vec3_flat_position;
attribute vec2 a_vec2_texture;
uniform vec4 u_vec4_extent;
varying vec2 v_vec2_texture;
void main()
{
    v_vec2_texture = a_vec2_texture;
    vec4 pos = get_clipspace(a_vec3_flat_position, a_vec3_ecef_position);
    gl_Position = pos;
}`,pp=`#include <prelude>
#ifndef UBO
uniform mediump vec2 u_vec2_halo_viewport_size;
uniform mediump vec2 u_vec2_halo_viewport_center_shift;
uniform mediump vec4 u_vec4_halo_radius_stops;
uniform mediump float u_float_halo_exp_factor;
#endif
attribute vec2 a_vec2_vertex;
varying vec2 v_vec2_uv;
void main() {
    
    
    
    
    
    
    
    float globe_halo_padding_factor = log(0.005) / u_float_halo_exp_factor;
    
    vec4 pixel_radius_stops = u_vec4_halo_radius_stops * u_vec2_halo_viewport_size.y;
    
    
    
    
    float maxR = pixel_radius_stops[1] + (pixel_radius_stops[3] - pixel_radius_stops[1]) * globe_halo_padding_factor;
    
    float scale = maxR / u_vec2_halo_viewport_size.y;
    v_vec2_uv = a_vec2_vertex * scale;
    vec2 center = u_vec2_halo_viewport_size / 2.0 + u_vec2_halo_viewport_center_shift;
    vec2 p = center - a_vec2_vertex * maxR;
    vec2 p_result = 2.0 * (p - 0.5 * u_vec2_halo_viewport_size) / u_vec2_halo_viewport_size;
    gl_Position = vec4(p_result, 0.0, 1.0);
}
`,vp=`#include <prelude>
#include <ecef_mvp_mat>
#include <dem>
#include <packed_attributes>
#include <pos_world>
#include <cam_pos>
#include <fog>
#include <clipspace_pos>
#include <jitter>
#include <shadow>
#include <show_ratio>
#define EPSILON (0.0001)
#define DEM_POS_INSTANCE 0
#define DEM_POS_FLAT 1
#define DEM_POS_AXIS 2
#define DEM_POS_CENTROID 3
uniform mat4 u_mat4_instance;
uniform vec2 u_vec2_anchor;
uniform vec4 u_vec4_axis;
uniform int u_int_gltf_dem_pos;
uniform mat4 u_mat4_localmatrix;
uniform float u_float_height_factor;
uniform float u_float_show_ratio;
uniform mediump int u_int_identify;
uniform float u_float_floor_elevation;
uniform int u_int_abs_z;
uniform int u_int_extention_to_relief_needed;
uniform int u_int_collapse_height_needed;
attribute vec3 a_position;
attribute vec3 a_normal;
attribute vec2 a_tangent;
attribute vec2 a_vec2_instance_position;
attribute float a_float_instance_height;
#ifndef MALI_GPU
attribute vec3 a_vec3_instance_ecef_position;
attribute float a_float_abs_z;
#endif
attribute mat3 a_mat3_instance_matrix;
attribute vec4 a_vec4_instance_localid;
#ifdef COLOR_TEXTURE
attribute vec2 texcoord_color;
#endif
#ifdef AO_TEXTURE
attribute vec2 texcoord_ao;
#endif
#ifdef PBR_TEXTURE
attribute vec2 texcoord_pbr;
#endif
varying vec4 v_vec4_identifier;
varying vec3 v_vec3_normal;
varying vec3 v_vec3_fragment_pos_world;
#ifdef MAP_MESH_TEXTURE
varying vec4 v_tex_coord;
#endif
#ifdef COLOR_TEXTURE
varying vec2 v_vec2_texcoord_color;
#endif
#ifdef AO_TEXTURE
varying vec2 v_vec2_texcoord_ao;
#endif
#ifdef PBR_TEXTURE
varying vec2 v_vec2_texcoord_pbr;
#endif
varying float v_float_opacity;
void calc_texcoords(mat4 instance_matrix, float height) {
    #ifdef MAP_MESH_TEXTURE
    
    vec4 vertexTier = instance_matrix * vec4(a_position, 1.);
    vertexTier *= u_mat4_instance;
    vertexTier.z *= u_float_height_factor;
    vertexTier.xyz *= v_float_opacity;
    vec4 vflatTier = vec4(a_vec2_instance_position,a_float_instance_height, 1.);
    vflatTier.z += height;
    vflatTier.xyz += vertexTier.xyz;
    v_tex_coord = u_mat4_flat_mvp * vec4(vflatTier.xy, 0, 1.0);
    #endif
    #if defined(COLOR_TEXTURE)
    v_vec2_texcoord_color = texcoord_color;
    #endif
    #ifdef AO_TEXTURE
    v_vec2_texcoord_ao = texcoord_ao;
    #endif
    #ifdef PBR_TEXTURE
    v_vec2_texcoord_pbr = texcoord_pbr;
    #endif
}
void main()
{
    if (u_int_identify != 0 && a_vec4_instance_localid == vec4(1., 1., 1., 1.)) {
        gl_Position = vec4(0, 0, 0, 0);
        return;
    }
    mat4 instance_matrix = mat4(
        vec4(a_mat3_instance_matrix[0], 0),
        vec4(a_mat3_instance_matrix[1], 0),
        vec4(a_mat3_instance_matrix[2], 0),
        vec4(0, 0, 0, 1)
    );
    float height = 0.;
    
    if (u_int_gltf_dem_pos == DEM_POS_CENTROID) {
        vec4 center = (instance_matrix * u_mat4_localmatrix) * vec4(u_vec2_anchor.x, 0, u_vec2_anchor.y, 1);
        center *= u_mat4_instance;
        center.xy += a_vec2_instance_position;
        height = dem_height(center.xy);
    } else if (u_int_gltf_dem_pos == DEM_POS_AXIS)  {
        vec2 a = a_position.xz - u_vec4_axis.xy;
        vec2 b = u_vec4_axis.zw - u_vec4_axis.xy;
        float b_length = length(b);
        a /= b_length;
        b /= b_length;
        float coef = clamp(dot(a, b), 0., 1.);
        vec4 axis_start = (instance_matrix * u_mat4_localmatrix) * vec4(u_vec4_axis.x, 0, u_vec4_axis.y, 1);
        axis_start *= u_mat4_instance;
        axis_start.xy += a_vec2_instance_position;
        float height_start = dem_height(axis_start.xy);
        vec4 axis_end = (instance_matrix * u_mat4_localmatrix) * vec4(u_vec4_axis.z, 0, u_vec4_axis.w, 1);
        axis_end *= u_mat4_instance;
        axis_end.xy += a_vec2_instance_position;
        float height_end = dem_height(axis_end.xy);
        height = mix(height_start, height_end, coef);
    } else if (u_int_gltf_dem_pos == DEM_POS_FLAT) {
        vec4 pos = (instance_matrix * u_mat4_localmatrix) * vec4(a_position, 1);
        pos *= u_mat4_instance;
        pos.xy += a_vec2_instance_position;
        height = dem_height(pos.xy);
    } else {
#ifdef MALI_GPU 
        
        
        height = dem_height(a_vec2_instance_position); 
#else
        if (u_int_abs_z == 0) {
            height = dem_height(a_vec2_instance_position);
        } else {
            height = abs_height(a_float_abs_z);
        }
#endif
    }
    height += u_float_floor_elevation;
    vec3 instance_position = vec3(a_vec2_instance_position, a_float_instance_height);
    if (u_float_show_ratio < 1.0) {
        vec3 instance_wp = a_mat3_instance_matrix * instance_position;
        v_float_opacity = apply_show_ratio(u_float_show_ratio, instance_wp);
    } else {
        v_float_opacity = 1.;
    }
    v_vec4_identifier = a_vec4_instance_localid;
    vec4 vertex = (instance_matrix * u_mat4_localmatrix) * vec4(a_position, 1.);
    vertex *= u_mat4_instance;
    vertex.xyz *= v_float_opacity;
    vertex.z *= u_float_height_factor;
#ifndef MALI_GPU
    if (u_int_abs_z == 1) {
        bool is_base = vertex.z < EPSILON;
        if (is_base) {
            
            
            if (u_int_extention_to_relief_needed == 1) {
                float relief_height = dem_height(a_vec2_instance_position);
                vertex.z -= abs_height(a_float_abs_z) - relief_height;
            }
        } else {
            
            
            if (u_int_collapse_height_needed == 1) {
                vertex.z = 0.;
            }
        }
    }
#endif
    vec4 vflat = vec4(instance_position, 1.);
    vflat.z += height;
    vflat.xyz += vertex.xyz;
    vec3 pos_world = calc_pos_world(vflat);
    calc_fog_pos(pos_world);
#ifdef MALI_GPU
    
    
    
    gl_Position = get_clipspace(vflat.xyz);
#else
    vec4 vecef = vec4(a_vec3_instance_ecef_position, 1.);
    vecef.xyz += vertex.xyz;
    gl_Position = get_clipspace(vflat.xyz, vecef.xyz, a_float_abs_z);
#endif
    calc_texcoords(instance_matrix, height);
    
    v_vec3_normal = ((instance_matrix * u_mat4_localmatrix) * vec4(a_normal, 0)).xyz;
    v_vec3_fragment_pos_world = pos_world;
#ifdef TAA
    apply_vertex_jitter(gl_Position);
#endif
    save_clipspace_pos();
    compute_shadow_vertex(gl_Position, v_vec3_normal, u_mat4_flat_mvp);
}
`,gp=`#include <prelude>
#include <ecef_mvp_mat>
#include <dem>
#include <packed_attributes>
#include <show_ratio>
#define EPSILON (0.0001)
uniform mat4 u_mat4_instance;
uniform mat4 u_mat4_localmatrix;
uniform float u_float_height_factor;
uniform float u_float_show_ratio;
uniform int u_int_abs_z;
uniform int u_int_extention_to_relief_needed;
uniform int u_int_collapse_height_needed;
attribute vec3 a_position;
attribute vec2 a_vec2_instance_position;
attribute float a_float_instance_height;
#ifndef MALI_GPU
attribute vec3 a_vec3_instance_ecef_position;
attribute float a_float_abs_z;
#endif
attribute mat3 a_mat3_instance_matrix;
varying float v_depth_metric;
void main()
{
    float height = 0.;
#ifdef MALI_GPU
    height = dem_height(a_vec2_instance_position);
#else
    if (u_int_abs_z == 0) {
        height = dem_height(a_vec2_instance_position);
    } else {
        height = abs_height(a_float_abs_z);
    }
#endif
    vec3 instance_position = vec3(a_vec2_instance_position, a_float_instance_height);
    float opacity = 1.0;
    if (u_float_show_ratio < 1.0) {
        vec3 instance_wp = a_mat3_instance_matrix * instance_position;
        opacity = apply_show_ratio(u_float_show_ratio, instance_wp);
    }
    mat4 instance_matrix = mat4(
        vec4(a_mat3_instance_matrix[0], 0),
        vec4(a_mat3_instance_matrix[1], 0),
        vec4(a_mat3_instance_matrix[2], 0),
        vec4(0, 0, 0, 1)
    );
    vec4 vertex = (instance_matrix * u_mat4_localmatrix) * vec4(a_position, 1);
    vertex *= u_mat4_instance;
    vertex.xyz *= opacity;
    vertex.z *= u_float_height_factor;
#ifndef MALI_GPU
    if (u_int_abs_z == 1) {
        bool is_base = vertex.z < EPSILON;
        if (is_base) {
            
            
            if (u_int_extention_to_relief_needed == 1) {
                float relief_height = dem_height(a_vec2_instance_position);
                vertex.z -= abs_height(a_float_abs_z) - relief_height;
            }
        } else {
            
            
            if (u_int_collapse_height_needed == 1) {
                vertex.z = 0.;
            }
        }
    }
#endif
    vec4 vflat = vec4(instance_position, 1.);
    vflat.z += height;
    vflat.xyz += vertex.xyz;
#ifdef MALI_GPU
    
    
    
    gl_Position = get_clipspace(vflat.xyz);
#else
    vec4 vecef = vec4(a_vec3_instance_ecef_position, 1.);
    vecef.xyz += vertex.xyz;
    gl_Position = get_clipspace(vflat.xyz, vecef.xyz, a_float_abs_z);
#endif
    v_depth_metric = (gl_Position.z + 1.0) / 2.0;
}
`,yp=`#include <prelude>
#include <mvp_mat>
#include <pos_world>
#include <cam_pos>
#include <fog>
attribute vec2 a_vec2_position;
attribute vec2 a_vec2_widen;
attribute float a_float_weight;
varying vec2 v_vec2_extrude;
varying float v_float_weight;
uniform float u_float_radius;
uniform float u_float_intensity;
uniform float u_float_tile_to_pixel_ratio;
const highp float ZERO = 1.0 / 255.0 / 16.0;
#define GAUSS_COEF 0.3989422804014327
void main(void) {
    float S = sqrt(-2.0 * log(ZERO / a_float_weight / u_float_intensity / GAUSS_COEF)) / 3.0;
    v_vec2_extrude = S * a_vec2_widen;
    v_float_weight = a_float_weight;
    vec2 pos = a_vec2_position + a_vec2_widen * u_float_radius * u_float_tile_to_pixel_ratio;
    calc_fog_pos(calc_pos_world(pos));
    gl_Position = u_mat4_mvp * vec4(pos, 0.0, 1.0);
}
`,bp=`#include <prelude>
#include <pos_world>
#include <cam_pos>
#include <fog>
attribute vec2 a_vec2_position;
varying vec2 v_vec2_position;
void main() {
    gl_Position = vec4(a_vec2_position, 0.0, 1.0);
    v_vec2_position = clamp(a_vec2_position, vec2(0,0), vec2(1,1));
}
`,xp=`#include <prelude>
#include <mvp_mat>
#include <packed_attributes>
#include <pos_world>
#include <cam_pos>
#include <fog>
attribute vec4 a_vec4_position;
attribute vec2 a_vec2_offset;
attribute vec2 a_vec2_texcoord;
attribute vec2 a_vec2_style_zoom_limits;
uniform float u_float_style_zoom;
uniform float u_float_scale;
uniform float u_float_tile_to_pixel_ratio;
varying vec2 v_vec2_texcoord;
float clipw(const float w, const vec2 range, const float zoom) {
    return w * (step(range.x, zoom) - step(range.y, zoom));
}
void main() {
    vec4 newPosition = a_vec4_position;
    newPosition.xy += a_vec2_offset * u_float_scale * u_float_tile_to_pixel_ratio;
    vec3 pos_world = calc_pos_world(newPosition);
    calc_fog_pos(pos_world);
    newPosition = u_mat4_mvp * newPosition;
    gl_Position = vec4(newPosition.xyz, clipw(newPosition.w, a_vec2_style_zoom_limits, u_float_style_zoom));
    v_vec2_texcoord = unpack_texcoord(a_vec2_texcoord);
}
`,wp=`#include <prelude>
#include <ecef_mvp_mat>
#include <dem>
#include <packed_attributes>
#include <apply_height_factor>
#include <depth_test>
#include <pos_world>
#include <cam_pos>
#include <fog>
attribute vec3 a_vec3_flat_position;
attribute vec3 a_vec3_ecef_position;
attribute vec2 a_vec2_offset;
attribute vec2 a_vec2_texcoord;
attribute vec2 a_vec2_check_offset;
attribute vec4 a_vec4_tex_identifier;
attribute vec4 a_vec4_sprite_identifier;
#ifndef UBO
uniform vec2 u_vec2_vpt_size;
#endif
uniform vec2 u_vec2_offset;
uniform float u_float_scale;
uniform float u_float_height_factor;
uniform bool u_bool_skip_height_factor;
uniform float u_float_floor_elevation;
varying vec2 v_vec2_texcoord;
varying vec2 v_vec2_labeling_texcoord;
varying float v_float_behind_factor;
varying vec4 v_vec4_text_identifier;
void main() {
    float height = dem_height(a_vec3_flat_position.xy);
    height += u_float_floor_elevation;
    vec4 pos;
    
    
    
    if (u_bool_skip_height_factor == true) {
        pos = vec4(a_vec3_flat_position, 1.0);
    } else {
        pos = apply_height_factor(a_vec3_flat_position, u_float_height_factor);
    }
    pos.z += height;
    vec3 pos_world = calc_pos_world(a_vec3_flat_position);
    calc_fog_pos(pos_world);
    pos = get_clipspace(pos.xyz, a_vec3_ecef_position);
    pos.xyz = pos.xyz / pos.w;
    pos.w = 1.0;
    v_float_behind_factor = depth_test(pos.xy + a_vec2_check_offset / u_vec2_vpt_size, pos.z, a_vec4_tex_identifier);
    pos.xy += (a_vec2_offset * u_float_scale + u_vec2_offset) / u_vec2_vpt_size * 2.0;
    gl_Position = pos;
    v_vec2_texcoord = unpack_texcoord(a_vec2_texcoord);
    v_vec4_text_identifier = a_vec4_sprite_identifier;
    v_vec2_labeling_texcoord = (pos.xy + 1.) / 2.;
}
`,Sp=`#include <prelude>
#include <ecef_mvp_mat>
#include <dem>
attribute vec3 a_vec3_flat_position;
attribute vec3 a_vec3_ecef_position;
attribute vec2 a_vec2_offset;
attribute vec4 a_vec4_identifier;
#ifndef UBO
uniform vec2 u_vec2_vpt_size;
#endif
uniform vec2 u_vec2_offset;
uniform float u_float_scale;
uniform float u_float_floor_elevation;
varying vec4 v_vec4_identifier;
void main() {
    float height = dem_height(a_vec3_flat_position.xy);
    height += u_float_floor_elevation;
    v_vec4_identifier = a_vec4_identifier;
    if (vec4(1., 1., 1., 1.) != a_vec4_identifier)
    {
        vec4 pos = get_clipspace(a_vec3_flat_position, a_vec3_ecef_position);
        pos.xyz = pos.xyz / pos.w;
        pos.w = 1.0;
        pos.xy += (a_vec2_offset * u_float_scale + u_vec2_offset) / u_vec2_vpt_size * 2.0;
        gl_Position = pos;
    }
    else
    {
        gl_Position = vec4(1., 1., 1., 1.);
    }
}
`,Tp=`#include <prelude>
#include <mvp_mat>
#include <dem>
#include <packed_attributes>
#include <apply_height_factor>
#include <apply_opacity>
#include <pos_world>
#include <cam_pos>
#include <fog>
#include <jitter>
#include <shadow>
#ifndef UBO
uniform vec2 u_vec2_vpt_size;
#endif
uniform vec4 u_vec4_color;
uniform float u_float_height_factor;
uniform float u_float_opacity;
uniform mediump mat4 u_mat4_gradient;
uniform float u_float_floor_elevation;
attribute vec2 a_vec2_vertex;
attribute float a_float_z;
attribute vec2 a_vec2_normal;
attribute vec2 a_vec2_normal_delta;
attribute vec3 a_vec3_direction;
attribute float a_float_distance;
attribute vec2 a_vec2_dem_position;
attribute float a_float_visibility;
varying vec4 v_vec4_color;
varying mat4 v_mat4_gradient;
varying vec3 v_vec3_normal;
varying vec2 v_vec2_height_gradient;
const float g_shift_pixels = 1.;
const float g_min_denominator = 1e-4;
const float g_w_factor = 1e-6;
vec2 multiply_complex(vec2 lhs, vec2 rhs)
{
    return vec2(lhs.x * rhs.x - lhs.y * rhs.y, lhs.x * rhs.y + lhs.y * rhs.x);
}
void main()
{
    
    if (a_float_visibility == 0.0) {
        gl_Position = vec4(0, 0, 1, 1);
        return;
    }
    float height = dem_height(unpack_dem_position(a_vec2_dem_position));
    
    if (a_float_z == 0.) {
        float posHeight = dem_height(a_vec2_vertex);
        if (height > posHeight) {
            height = posHeight;
        }
    }
    height += u_float_floor_elevation;
    vec2 half_viewport = u_vec2_vpt_size / vec2(2.);
    
    if (a_float_z > 0.0)
    {
        v_vec2_height_gradient[0] = 1.;
    } else {
        v_vec2_height_gradient[0] = 0.;
    }
    vec4 clip_space_direction = u_mat4_mvp * vec4(normalize_s08(vec3(a_vec3_direction.xy, a_vec3_direction.z + height)), 0.);
    vec4 vertex_hf = apply_height_factor(vec3(a_vec2_vertex, a_float_z), u_float_height_factor);
    vertex_hf.z += height;
    
    vertex_hf.z = max(vertex_hf.z, height);
    vec4 clip_space_vertex = u_mat4_mvp * vertex_hf;
    vec2 screen_space_direction = (clip_space_direction.xy * clip_space_vertex.w - clip_space_vertex.xy * clip_space_direction.w) * half_viewport;
    vec2 screen_space_perp = vec2(-screen_space_direction.y, screen_space_direction.x);
    float denominator = max(g_min_denominator, length(screen_space_perp));
    vec2 bevel_normal = normalize_s08(a_vec2_normal);
    vec2 normal_delta = normalize_s08(a_vec2_normal_delta);
    vec4 clip_space_bevel_normal = u_mat4_mvp * vec4(bevel_normal, 0., 0.);
    vec2 screen_space_bevel_normal = (clip_space_bevel_normal.xy * clip_space_vertex.w - clip_space_vertex.xy * clip_space_bevel_normal.w) * half_viewport;
    float bevel_denominator = max(g_min_denominator, length(screen_space_bevel_normal));
    
    float normal_factor = -dot(screen_space_bevel_normal, screen_space_perp) / denominator / bevel_denominator;
    vec2 wall_normal = multiply_complex(bevel_normal, vec2(normal_delta.x, sign(normal_factor) * normal_delta.y));
    gl_Position = g_w_factor * (clip_space_vertex + vec4(screen_space_perp / half_viewport, 0., 0.) * g_shift_pixels * a_float_distance / denominator * clip_space_vertex.w);
    vec3 pos_world = calc_pos_world(vertex_hf);
    v_vec4_color = u_vec4_color;
    v_vec3_normal = vec3(wall_normal, 0.0);
    if (u_mat4_gradient[0][0] !=0.)
    {
        v_mat4_gradient = u_mat4_gradient;
        for (int i = 1; i <= 2; i++) {
            v_mat4_gradient[i] = apply_opacity(v_mat4_gradient[i], u_float_opacity);
        }
    }
    v_vec2_height_gradient.y = a_float_distance * gl_Position.w;
    calc_fog_pos(pos_world);
#ifdef TAA
    apply_vertex_jitter(gl_Position);
#endif
    
    
    compute_shadow_vertex(clip_space_vertex);
}
`,Mp=`#include <prelude>
#include <mvp_mat>
#include <pos_world>
#include <cam_pos>
#include <fog>
#include <jitter>
#include <shadow>
#include <dem>
attribute vec2 a_vec2_vertex;
attribute vec4 a_vec4_normals;
attribute float a_float_height;
attribute float a_float_abs_z;
#ifndef UBO
uniform vec2 u_vec2_vpt_size;
#endif
uniform float u_float_width;
uniform float u_float_tile_to_pixel_ratio;
uniform int u_int_abs_z;
varying vec2 v_vec2_normal;
varying float v_float_half_width;
const float g_w_factor = 1e-6;
const float normal_unpack_multiplier = 0.011135539861205473;
void main()
{
    float height = 0.;
    if (u_int_abs_z == 0) {
        height = dem_height(a_vec2_vertex);
    } else {
        height = abs_height(a_float_abs_z);
    }
    
    float half_width = 0.5 * (u_float_width + 1.0);
    
    vec4 normals = a_vec4_normals * normal_unpack_multiplier * half_width;
    vec2 extender = normals.xy;
    vec2 normal = normals.zw;
    vec4 base_vertex = vec4(
        a_vec2_vertex.x,
        a_vec2_vertex.y,
        height + a_float_height / (65535. * 32.),
        1.0
    );
    vec3 pos_world = calc_pos_world(base_vertex);
    vec3 base_normal = vec3(0.0, 0.0, 1.0);
    vec3 extender_vector = vec3(extender * u_float_tile_to_pixel_ratio, 0.0);
    vec3 V = normalize(u_cam_pos - pos_world);
    vec3 rotated_extender;
    
    vec3 rotation_axis = cross(base_normal, V);
    float sin_angle = length(rotation_axis);
    float cos_angle = dot(base_normal, V);
    const float EPSILON = 1e-3;
    if (sin_angle < EPSILON) {
        rotated_extender = extender_vector * sign(cos_angle);
    } else {
        vec3 k = rotation_axis / sin_angle;
        rotated_extender = extender_vector * cos_angle + 
                        cross(k, extender_vector) * sin_angle + 
                        k * dot(k, extender_vector) * (1.0 - cos_angle);
    }
    vec4 rotated_vertex = vec4(base_vertex.xyz + rotated_extender, 1.0);
    vec4 base_clip = u_mat4_mvp * base_vertex;
    vec3 base_ndc = base_clip.xyz / base_clip.w;
    vec4 rotated_clip = u_mat4_mvp * rotated_vertex;
    vec3 rotated_ndc = rotated_clip.xyz / rotated_clip.w;
    
    vec2 base_screen = (base_ndc.xy + 1.0) * 0.5 * u_vec2_vpt_size;
    vec2 rotated_screen = (rotated_ndc.xy + 1.0) * 0.5 * u_vec2_vpt_size;
    float pixel_distance = length(base_screen - rotated_screen);
    float scale_factor = half_width / pixel_distance;
    
    if (base_clip.w < 0.0) {
        scale_factor = 0.;
    }
    rotated_extender = rotated_extender * scale_factor;
    rotated_vertex = vec4(base_vertex.xyz + rotated_extender, 1.0);
    vec4 clip_pos = u_mat4_mvp * rotated_vertex;
    gl_Position = g_w_factor * clip_pos;
    v_vec2_normal = normal;
    v_float_half_width = half_width;
    calc_fog_pos(pos_world);
#ifdef TAA
    apply_vertex_jitter(gl_Position);
#endif
    compute_shadow_vertex(clip_pos, vec3(0.0, 0.0, 1.0), u_mat4_mvp);
}
`,Ep=`#include <prelude>
#include <mvp_mat>
#include <dem>
attribute vec2 a_vec2_vertex;
attribute vec4 a_vec4_normals;
attribute float a_float_height;
attribute float a_float_abs_z;
attribute vec4 a_vec4_identifier;
uniform float u_float_width;
uniform float u_float_tile_to_pixel_ratio;
uniform int u_int_abs_z;
varying vec2 v_vec2_normal;
varying vec4 v_vec4_identifier;
varying float v_float_half_width;
const float g_w_factor = 1e-6;
const float normal_unpack_multiplier = 0.011135539861205473;
void main()
{
    float height = 0.;
    if (u_int_abs_z == 0) {
        height = dem_height(a_vec2_vertex);
    } else {
        height = abs_height(a_float_abs_z);
    }
    
    float half_width = 0.5 * (u_float_width + 1.0);
    
    vec4 normals = a_vec4_normals * normal_unpack_multiplier * half_width;
    vec2 extender = normals.xy;
    vec2 normal = normals.zw;
    if (vec4(1., 1., 1., 1.) != a_vec4_identifier) {
        
        vec4 shifted_vertex = vec4(
            a_vec2_vertex + extender * u_float_tile_to_pixel_ratio,
            height + a_float_height / (65535. * 32.),
            1.0
        );
        gl_Position = g_w_factor * u_mat4_mvp * shifted_vertex;
    } else {
        gl_Position = vec4(1., 1., 1., 1.);
    }
    v_vec2_normal = normal;
    v_vec4_identifier = a_vec4_identifier;
    v_float_half_width = half_width;
}
`,Ip=`#include <prelude>
#include <mvp_mat>
#include <dem>
#include <packed_attributes>
#include <pos_world>
#include <cam_pos>
#include <shadow>
#include <fog>
#include <clipspace_pos>
#include <jitter>
attribute vec2 a_vec2_vertex;
attribute float a_float_z;
attribute vec2 a_vec2_extender;
attribute vec3 a_vec3_normal;
attribute float a_float_gradient;
attribute vec2 a_vec2_dem_position;
attribute float a_float_abs_z;
attribute float a_float_is_pivot;
uniform float u_float_tile_size;
uniform float u_float_height_factor;
uniform int u_int_abs_z;
varying vec4 v_tex_coord;
varying vec4 v_vec4_normal_gradient;
void main()
{
#ifndef VARYINGS_LIMIT_9
    v_float_dem_invalid = 0.;
#endif
    float height = 0.;
    if (u_int_abs_z == 0) {
        height = dem_height(unpack_dem_position(a_vec2_dem_position));
    } else {
        if (a_float_is_pivot == 1.) {
            height = dem_height(a_vec2_vertex);
        } else {
            height = abs_height(a_float_abs_z);
        }
    }
    
    vec3 vec3_vertex = vec3(a_vec2_vertex, a_float_z / (65535. * 32.));
    v_tex_coord = u_mat4_mvp * vec4(vec3_vertex.xy, 0, 1.0);
    v_vec4_normal_gradient.xyz = normalize_s08(a_vec3_normal);
    v_vec4_normal_gradient.w = a_float_gradient;
    vec4 pos = vec4(vec3_vertex.xy, vec3_vertex.z * u_float_height_factor + height, 1.0);
    vec3 world_pos = calc_pos_world(pos);
    calc_fog_pos(world_pos);
    gl_Position = u_mat4_mvp * pos;
#ifdef TAA
    apply_vertex_jitter(gl_Position);
#endif
    save_clipspace_pos();
    compute_shadow_vertex(gl_Position, v_vec4_normal_gradient.xyz, u_mat4_mvp);
}
`,Cp=`#include <prelude>
#include <mvp_mat>
#include <dem>
#include <packed_attributes>
#include <apply_height_factor>
#include <apply_opacity>
#include <pos_world>
#include <cam_pos>
#include <shadow>
#include <fog>
#include <clipspace_pos>
#include <jitter>
uniform mediump vec4 u_vec4_color;
uniform mediump mat4 u_mat4_gradient;
uniform float u_float_height_factor;
uniform int u_int_abs_z;
uniform lowp int u_int_is_textured;
uniform mediump float u_float_opacity;
uniform vec4 u_float_texture_params;
uniform float u_float_texture_vertical_scale;
uniform mediump int u_int_identify;
attribute vec2 a_vec2_vertex;
attribute float a_float_z;
attribute vec3 a_vec3_normal;
attribute float a_float_gradient;
attribute vec2 a_vec2_dem_position;
attribute float a_float_abs_z;
attribute vec4 a_vec4_identifier;
attribute float a_float_visibility;
attribute float a_float_is_pivot;
varying vec4 v_vec4_color;
varying mat4 v_mat4_gradient;
varying vec2 v_vec2_tex_coord;
varying vec4 v_vec4_normal_gradient;
varying vec4 v_vec4_identifier;
void main()
{
    if (u_int_identify != 0 && a_vec4_identifier == vec4(1., 1., 1., 1.)) {
        gl_Position = vec4(0, 0, 0, 0);
        return;
    }
    float height = 0.;
    if (u_int_abs_z == 0) {
        height = dem_height(unpack_dem_position(a_vec2_dem_position));
    } else {
        if (a_float_is_pivot == 1.) {
            height = dem_height(a_vec2_vertex);
        } else {
            height = abs_height(a_float_abs_z);
        }
    }
    if (a_float_visibility == 0.0) {
        gl_Position = vec4(0, 0, 1, 1);
        return;
    }
    v_vec4_identifier = a_vec4_identifier;
    
    vec4 vec4_pos = apply_height_factor(vec3(a_vec2_vertex.xy, a_float_z / (65535. * 32.)), u_float_height_factor);
    vec4_pos.z += height;
    vec3 pos_world = calc_pos_world(vec4_pos);
    calc_fog_pos(pos_world);
    gl_Position = u_mat4_mvp * vec4_pos;
    vec3 vec3_normal = normalize(a_vec3_normal);
    v_vec4_normal_gradient.xyz = vec3_normal;
    v_vec4_normal_gradient.w = a_float_gradient / 127.; 
    if (u_int_is_textured != 0) {
        
        vec2 vec2_vertex = a_vec2_vertex * 2. - 0.5;
        
        
        vec3 tex_coord = abs(vec3(
            vec2_vertex * u_float_texture_params.zw + u_float_texture_params.xy,
            a_float_z / u_float_texture_vertical_scale
        ));
        
        if (vec3_normal.x == 0. && vec3_normal.y == 0.) {
            v_vec2_tex_coord = tex_coord.xy;
        } else {
            float scale = abs(vec3_normal.z);
            tex_coord.z /= sqrt(1.0 - vec3_normal.z * vec3_normal.z);;
            if (abs(vec3_normal).y > abs(vec3_normal).x) {
                v_vec2_tex_coord = tex_coord.xz;
            } else {
                v_vec2_tex_coord = tex_coord.yz;
            }
        }
        v_vec4_color = apply_opacity(u_vec4_color, u_float_opacity);
    }
    
    else if (u_mat4_gradient[0][0] != 0.)
    {
        v_mat4_gradient = u_mat4_gradient;
        for (int i = 1; i <= 2; i++) {
            v_mat4_gradient[i] = apply_opacity(v_mat4_gradient[i], u_float_opacity);
        }
    } else {
        v_vec4_color = apply_opacity(u_vec4_color, u_float_opacity);
    }
#ifdef TAA
    apply_vertex_jitter(gl_Position);
#endif
    save_clipspace_pos();
    compute_shadow_vertex(gl_Position, vec3_normal, u_mat4_mvp);
}
`,Lp=`#include <prelude>
#include <mvp_mat>
#include <dem>
#include <apply_height_factor>
attribute vec2 a_vec2_vertex;
attribute float a_float_z;
attribute vec2 a_vec2_dem_position;
attribute float a_float_abs_z;
attribute float a_float_visibility;
attribute float a_float_is_pivot;
uniform float u_float_height_factor;
uniform int u_int_abs_z;
varying float v_depth_metric;
void main()
{
    float height = 0.;
    if (u_int_abs_z == 0) {
        height = dem_height(unpack_dem_position(a_vec2_dem_position));
    } else {
        if (a_float_is_pivot == 1.) {
            height = dem_height(a_vec2_vertex);
        } else {
            height = abs_height(a_float_abs_z);
        }
    }
    if (a_float_visibility == 0.0) {
        gl_Position = vec4(0, 0, 1, 1);
        return;
    }
    
    vec4 vec4_pos = apply_height_factor(vec3(a_vec2_vertex.xy, a_float_z / (65535. * 32.)), u_float_height_factor);
    vec4_pos.z += height;
    gl_Position = u_mat4_mvp * vec4_pos;
    v_depth_metric = 0.5 * gl_Position.z + 0.5;
}`,Pp=`#include <prelude>
#include <mvp_mat>
#include <apply_opacity>
#include <packed_attributes>
#include <pos_world>
#include <cam_pos>
#include <shadow>
#include <fog>
uniform float u_float_floor_elevation;
attribute vec2 a_vec2_vertex;
attribute vec2 a_vec2_texcoord;
varying vec2 v_vec2_texcoord;
void main()
{
    gl_Position = u_mat4_mvp * vec4(a_vec2_vertex, u_float_floor_elevation, 1.0);
    vec3 pos_world = calc_pos_world(a_vec2_vertex);
    calc_fog_pos(pos_world);
    compute_shadow_vertex(gl_Position, vec3(0,0,1), u_mat4_mvp);
    v_vec2_texcoord = unpack_texcoord(a_vec2_texcoord);
}
`,Bp=`#include <prelude>
#include <mvp_mat>
#include <packed_attributes>
#include <pixel_offset>
#include <signed_distance_functions>
#include <arrow_functions>
#include <apply_opacity>
#include <pos_world>
#include <cam_pos>
#include <fog>
#include <jitter>
#ifndef UBO
uniform float u_float_border_width_offset;
uniform vec2 u_vec2_scale_limits;
uniform mediump vec2 u_vec2_vpt_size;
#endif
uniform vec4 u_vec4_color;
uniform vec4 u_vec4_border_color;
uniform vec3 u_vec3_projection_scale_style_scale_dpi;
uniform float u_float_border_width;
uniform float u_float_size_factor;
uniform mediump float u_float_width;
uniform mediump float u_float_length;
uniform float u_float_wing_width_multiplier;
uniform float u_float_wing_height_multiplier;
uniform float u_float_tip_height_multiplier;
uniform float u_float_opacity;
attribute vec2 a_vec2_position;
attribute vec2 a_vec2_direction;
attribute vec2 a_vec2_widen_direction;
varying vec4 v_vec4_color;
varying vec4 v_vec4_border_color;
varying vec2 v_vec2_texcoord;
varying float v_float_border_width;
varying float v_float_zpt_to_texcoord_factor;
varying float v_float_outer_width;
varying float v_float_opacity;
const float g_shift_pixels = 2.;
const float g_w_factor = 1e-7;
void main()
{
    float style_scale_clamped = clamp(u_vec3_projection_scale_style_scale_dpi.y, u_vec2_scale_limits.x, u_vec2_scale_limits.y);
    float scale_ratio = u_vec3_projection_scale_style_scale_dpi.x / u_vec3_projection_scale_style_scale_dpi.y;
    float calculation_scale = style_scale_clamped * scale_ratio;
    ArrowParameters arrow_parameters = calculate_arrow_parameters(
        calculation_scale,
        u_float_width,
        u_float_border_width,
        u_float_length,
        u_float_wing_width_multiplier,
        u_float_wing_height_multiplier,
        u_float_tip_height_multiplier,
        u_float_size_factor);
    v_float_zpt_to_texcoord_factor = arrow_parameters.zpt_to_texcoord_factor;
    v_float_outer_width = arrow_parameters.outer_width;
    vec2 direction = normalize_s08(a_vec2_direction);
    vec2 untransformed_widen = a_vec2_widen_direction * arrow_parameters.widen_size;
    vec2 widen = multiply_complex(untransformed_widen * arrow_parameters.final_size, direction);
    
    float shift_pixels = g_shift_pixels * sqrt(2.) / min(abs(untransformed_widen.x), abs(untransformed_widen.y));
    VertexShiftParameters shift_parameters = calculate_vertex_shift_parameters(
        u_mat4_mvp,
        u_vec2_vpt_size,
        a_vec2_position,
        widen,
        shift_pixels);
    
    
    gl_Position = shift_parameters.clip_space_vertex / arrow_parameters.final_size * g_w_factor;
    v_vec2_texcoord = untransformed_widen * (1. + shift_parameters.limited_factor);
    
    float border_width = u_float_border_width * v_float_zpt_to_texcoord_factor;
    float border_width_offset = u_float_border_width_offset * v_float_zpt_to_texcoord_factor;
    v_float_border_width = max(0., border_width - u_vec3_projection_scale_style_scale_dpi.y / style_scale_clamped * border_width_offset);
    v_vec4_color = apply_opacity(u_vec4_color, u_float_opacity);
    v_vec4_border_color = apply_opacity(u_vec4_border_color, u_float_opacity);
    v_float_opacity = u_float_opacity;
    vec3 pos_world = calc_pos_world(a_vec2_position);
    calc_fog_pos(pos_world);
}
`,zp=`#include <prelude>
#include <mvp_mat>
#include <packed_attributes>
#include <pixel_offset>
#include <calculate_scale>
#include <line_width>
#include <apply_opacity>
#include <precision_constants>
#include <striped_line_functions>
#include <pos_world>
#include <cam_pos>
#include <shadow>
#include <fog>
#include <jitter>
#include <dem>
attribute vec2 a_vec2_vertex;
attribute vec2 a_vec2_widen;
attribute float a_float_texture;
attribute float a_float_height;
uniform vec2 u_vec2_scales;
uniform float u_float_width;
uniform vec4 u_vec4_color;
uniform float u_float_opacity;
uniform vec4 u_vec4_pattern_params;
uniform bool u_bool_is_3d_line;
varying vec2 v_vec2_uv;
varying float v_float_period;
varying float v_float_width;
varying vec4 v_vec4_color;
varying vec4 v_vec4_pattern_parameters;
const float g_w_factor = 1e-6;
void main() {
    float height = 0.;
    if (u_bool_is_3d_line == true) {
        height = dem_height(a_vec2_vertex);
    }
    if (u_bool_is_3d_line == true) {
        height += a_float_height / (65535. * 32.);
    }
    
    v_float_width = u_float_width;
    v_vec4_color = apply_opacity(u_vec4_color, u_float_opacity);
    v_vec2_uv = vec2(abs(a_float_texture), sign(a_float_texture) / 2.);
    v_vec2_uv.x *= u_vec2_scales.x / u_vec4_pattern_params.x;
    v_vec4_pattern_parameters = u_vec4_pattern_params;
    
    float full_width = u_float_width + 1.;
    
    vec2 widen = unpack_widen(a_vec2_widen);
    vec2 extender = widen * full_width * 0.5;
    
    
    vec2 shift = vec2(0.);
    vec4 shifted_vertex = vec4(a_vec2_vertex + (shift + extender) * u_vec2_scales.y, height, 1.0);
    vec3 pos_world = calc_pos_world(shifted_vertex); 
    calc_fog_pos(pos_world);
    gl_Position = u_mat4_mvp * shifted_vertex;
#ifdef TAA
    apply_vertex_jitter(gl_Position);
#endif
    compute_shadow_vertex(gl_Position, vec3(0.0, 0.0, 1.0), u_mat4_mvp);
    gl_Position *= g_w_factor;
}
`,Rp=`#include <prelude>
#include <mvp_mat>
#include <dem>
attribute vec4 a_vec4_position;
attribute vec2 a_vec2_offset;
attribute vec4 a_vec4_identifier;
#ifndef UBO
uniform vec2 u_vec2_vpt_size;
#endif
uniform vec2 u_vec2_offset;
uniform float u_float_floor_elevation;
varying vec4 v_vec4_identifier;
void main() {
    float height = dem_height(a_vec4_position.xy);
    height += u_float_floor_elevation;
    vec4 ndcPosition = u_mat4_mvp * vec4(a_vec4_position.xy, a_vec4_position.z + height, a_vec4_position.w);
    ndcPosition.xyz = ndcPosition.xyz / ndcPosition.w;
    ndcPosition.w = 1.0;
    ndcPosition.xy += (a_vec2_offset + u_vec2_offset) / u_vec2_vpt_size * 2.0;
    gl_Position = ndcPosition;
    v_vec4_identifier = a_vec4_identifier;
}
`,Fp=`#include <prelude>
#include <ecef_mvp_mat>
#include <pos_world>
#include <cam_pos>
#include <fog>
#include <dem>
#include <packed_attributes>
#include <apply_height_factor>
#include <raster_functions>
#include <depth_test>
#ifndef UBO
uniform float u_float_rounding_factor;
uniform vec2 u_vec2_vpt_size;
#endif
uniform vec3 u_vec3_projection_scale_style_scale_dpi;
uniform float u_float_height_factor;
uniform vec2 u_vec2_rotation; 
uniform bool u_bool_skip_height_factor;
uniform float u_float_floor_elevation;
attribute vec3 a_vec3_flat_position;
attribute vec3 a_vec3_ecef_position;
attribute vec2 a_vec2_offset;
attribute vec2 a_vec2_check_offset;
attribute vec2 a_vec2_texcoord;
attribute vec2 a_vec2_range;
attribute vec2 a_vec2_rescale;
attribute vec4 a_vec4_tex_identifier;
varying vec2 v_vec2_texcoord;
varying float v_float_behind_factor;
void main()
{
    float height = dem_height(a_vec3_flat_position.xy);
    height += u_float_floor_elevation;
    mat2 rotation_matrix = mat2(
        u_vec2_rotation.x, -u_vec2_rotation.y,
        u_vec2_rotation.y, u_vec2_rotation.x
    );
    vec2 inv_half_size = 2.0 / u_vec2_vpt_size;
    vec4 anchor;
    
    
    
    if (u_bool_skip_height_factor == true) {
        anchor = vec4(a_vec3_flat_position, 1.0);
    } else {
        anchor = apply_height_factor(a_vec3_flat_position, u_float_height_factor);
    }
    anchor.z += height;
    vec3 pos_world = calc_pos_world(anchor);
    calc_fog_pos(pos_world);
    anchor = get_clipspace(anchor.xyz, a_vec3_ecef_position);
    vec2 offset = rescale(rotation_matrix * a_vec2_offset, a_vec2_rescale, a_vec2_range, u_vec3_projection_scale_style_scale_dpi.y);
    vec2 pos_2d = anchor.xy + overlay_transform(offset, inv_half_size) * anchor.w;
    vec2 corner = make_position(pos_2d, anchor.w, inv_half_size, u_float_rounding_factor);
    v_float_behind_factor = depth_test(anchor.xy / anchor.w + a_vec2_check_offset / u_vec2_vpt_size, anchor.z / anchor.w, a_vec4_tex_identifier);
    gl_Position = vec4(corner, anchor.z, clipw(anchor.w, a_vec2_range, u_vec3_projection_scale_style_scale_dpi.y));
    v_vec2_texcoord = unpack_texcoord(a_vec2_texcoord);
}
`,Dp=`#include <prelude>
#include <ecef_mvp_mat>
#include <dem>
#include <packed_attributes>
#include <apply_height_factor>
#include <raster_functions>
#ifndef UBO
uniform vec2 u_vec2_vpt_size;
#endif
uniform vec3 u_vec3_projection_scale_style_scale_dpi;
uniform float u_float_height_factor;
uniform vec2 u_vec2_rotation; 
uniform bool u_bool_skip_height_factor;
uniform float u_float_floor_elevation;
attribute vec3 a_vec3_flat_position;
attribute vec3 a_vec3_ecef_position;
attribute vec2 a_vec2_offset;
attribute vec2 a_vec2_texcoord;
attribute vec2 a_vec2_range;
attribute vec2 a_vec2_rescale;
attribute vec4 a_vec4_identifier;
varying vec2 v_vec2_texcoord;
varying vec4 v_vec4_identifier;
void main()
{
    if (vec4(1., 1., 1., 1.) != a_vec4_identifier)
    {
        float height = dem_height(a_vec3_flat_position.xy);
        height += u_float_floor_elevation;
        mat2 rotation_matrix = mat2(
            u_vec2_rotation.x, -u_vec2_rotation.y,
            u_vec2_rotation.y, u_vec2_rotation.x
        );
        vec2 inv_half_size = 2.0 / u_vec2_vpt_size;
        vec4 anchor;
        
        
        
        if (u_bool_skip_height_factor == true) {
            anchor = vec4(a_vec3_flat_position, 1.0);
        } else {
            anchor = apply_height_factor(a_vec3_flat_position, u_float_height_factor);
        }
        anchor.z += height;
        anchor = get_clipspace(anchor.xyz, a_vec3_ecef_position);
        vec2 offset = rescale(rotation_matrix * a_vec2_offset, a_vec2_rescale, a_vec2_range, u_vec3_projection_scale_style_scale_dpi.y);
        vec2 pos_2d = anchor.xy + overlay_transform(offset, inv_half_size) * anchor.w;
        vec2 corner = make_position(pos_2d, anchor.w, inv_half_size, 1.0);
        gl_Position = vec4(corner, anchor.z, clipw(anchor.w, a_vec2_range, u_vec3_projection_scale_style_scale_dpi.y));
    }
    else
    {
        gl_Position = vec4(1., 1., 1., 1.);
    }
    v_vec2_texcoord = unpack_texcoord(a_vec2_texcoord);
    v_vec4_identifier = a_vec4_identifier;
}
`,Op=`#include <prelude>
attribute vec2 a_vec2_vertex;
varying vec2 v_vec2_texcoord;
void main()
{
    gl_Position = vec4(a_vec2_vertex, 0.0, 1.0);
    v_vec2_texcoord = 0.5 * a_vec2_vertex + 0.5;
}
`,Np=`#include <prelude>
#include <mvp_mat>
#include <pos_world>
#include <cam_pos>
#include <fog>
attribute vec2 a_vec2_vertex;
void main()
{
    gl_Position = u_mat4_mvp * vec4(a_vec2_vertex, 0.0, 1.0);
}
`,kp=`#include <prelude>
#include <mvp_mat>
#include <packed_attributes>
#include <apply_opacity>
#include <raster_functions>
#include <pos_world>
#include <cam_pos>
#include <fog>
attribute vec2 a_vec2_vertex;
attribute vec2 a_vec2_texcoord;
varying vec2 v_vec2_texcoord;
void main()
{
    gl_Position = u_mat4_mvp * vec4(a_vec2_vertex, 0.0, 1.0);
    calc_fog_pos(calc_pos_world(a_vec2_vertex));
    v_vec2_texcoord = unpack_texcoord(a_vec2_texcoord);
}
`,Up=`#include <prelude>
#include <mvp_mat>
#include <pos_world>
#include <cam_pos>
#include <fog>
#include <jitter>
#include <shadow>
attribute vec2 a_vec2_vertex;
attribute vec4 a_vec4_normals;
attribute vec2 a_vec2_shift;
uniform float u_float_width;
uniform float u_float_tile_to_pixel_ratio;
uniform float u_float_shift;
varying vec2 v_vec2_normal;
varying float v_float_half_width;
const float g_w_factor = 1e-6;
const float normal_unpack_multiplier = 0.011135539861205473;
void main()
{
    
    float half_width = 0.5 * (u_float_width + 1.0);
    
    vec4 normals = a_vec4_normals * normal_unpack_multiplier * half_width;
    vec2 extender = normals.xy;
    vec2 normal = normals.zw;
    vec2 shift = a_vec2_shift * u_float_shift;
    
    vec4 shifted_vertex = vec4(a_vec2_vertex + (shift + extender) * u_float_tile_to_pixel_ratio, 0.0, 1.0);
    vec4 clip_pos = u_mat4_mvp * shifted_vertex;
    gl_Position = g_w_factor * clip_pos;
    v_vec2_normal = normal;
    v_float_half_width = half_width;
    vec3 pos_world = calc_pos_world(shifted_vertex);
    calc_fog_pos(pos_world);
#ifdef TAA
    apply_vertex_jitter(gl_Position);
#endif
    compute_shadow_vertex(clip_pos, vec3(0.0, 0.0, 1.0), u_mat4_mvp);
}
`,Gp=`#include <prelude>
#include <mvp_mat>
attribute vec2 a_vec2_vertex;
attribute vec4 a_vec4_normals;
attribute vec4 a_vec4_identifier;
uniform float u_float_width;
uniform float u_float_tile_to_pixel_ratio;
varying vec2 v_vec2_normal;
varying vec4 v_vec4_identifier;
varying float v_float_half_width;
const float g_w_factor = 1e-6;
const float normal_unpack_multiplier = 0.011135539861205473;
void main()
{
    
    float half_width = 0.5 * (u_float_width + 1.0);
    
    vec4 normals = a_vec4_normals * normal_unpack_multiplier * half_width;
    vec2 extender = normals.xy;
    vec2 normal = normals.zw;
    if (vec4(1., 1., 1., 1.) != a_vec4_identifier) {
        
        vec4 shifted_vertex = vec4(a_vec2_vertex + extender * u_float_tile_to_pixel_ratio, 0.0, 1.0);
        gl_Position = g_w_factor * u_mat4_mvp * shifted_vertex;
    } else {
        gl_Position = vec4(1., 1., 1., 1.);
    }
    v_vec2_normal = normal;
    v_vec4_identifier = a_vec4_identifier;
    v_float_half_width = half_width;
}
`,Hp=`#include <prelude>
#include <mvp_mat>
#include <packed_attributes>
#include <pos_world>
#include <cam_pos>
#include <fog>
#include <jitter>
#include <shadow>
#ifndef UBO
uniform vec2 u_vec2_vpt_size;
#endif
uniform float u_float_width;
uniform float u_float_z_offset;
uniform float u_float_floor_elevation;
attribute vec2 a_vec2_vertex;
attribute vec4 a_vec4_direction_distance;
attribute float a_float_visibility;
varying float v_float_distance;
varying float v_float_distance_offset;
const float g_smooth_width = 1.;
const float g_min_denominator = 1e-4;
const float g_w_factor = 1e-6;
void main()
{
    
    if (a_float_visibility == 0.0) {
        gl_Position = vec4(0, 0, 1, 1);
        return;
    }
    float shift_pixels = 0.5 * max(u_float_width - 1., 0.);
    float shift_pixels_added = shift_pixels + g_smooth_width;
    vec3 direction = a_vec4_direction_distance.xyz;
    float distance = a_vec4_direction_distance.w;
    vec2 half_viewport = u_vec2_vpt_size / vec2(2.);
    
    
    vec4 clip_space_direction = normalize(u_mat4_mvp * vec4(normalize_s08(direction), 0.));
    
    vec4 vertex = vec4(a_vec2_vertex, u_float_floor_elevation, 1.0);
    vec4 clip_space_vertex = u_mat4_mvp * vertex;
    vec2 screen_space_direction =
        (clip_space_direction.xy * clip_space_vertex.w - clip_space_vertex.xy * clip_space_direction.w) * half_viewport;
    vec2 screen_space_perp = vec2(-screen_space_direction.y, screen_space_direction.x);
    float denominator = max(g_min_denominator, length(screen_space_perp));
    gl_Position = g_w_factor * (clip_space_vertex + vec4(screen_space_perp / half_viewport, 0., 0.)
        * distance * shift_pixels_added / denominator * clip_space_vertex.w);
    gl_Position.z += u_float_z_offset;
    v_float_distance = shift_pixels_added * distance * gl_Position.w;
    v_float_distance_offset = shift_pixels;
    vec3 pos_world = calc_pos_world(vertex.xyz);
    calc_fog_pos(pos_world);
#ifdef TAA
    apply_vertex_jitter(gl_Position);
#endif
    
    
    compute_shadow_vertex(clip_space_vertex);
}
`,Vp=`#include <prelude>
#include <mvp_mat>
#include <dem>
#include <packed_attributes>
#include <apply_height_factor>
#include <pos_world>
#include <cam_pos>
#include <fog>
#include <jitter>
#include <shadow>
#ifndef UBO
uniform vec2 u_vec2_vpt_size;
#endif
uniform float u_float_width;
uniform float u_float_height_factor;
uniform int u_int_abs_z;
uniform float u_float_z_offset;
uniform float u_float_floor_elevation;
attribute vec2 a_vec2_vertex;
attribute float a_float_z;
attribute vec4 a_vec4_direction_distance;
attribute vec2 a_vec2_dem_position;
attribute float a_float_abs_z;
attribute float a_float_is_pivot;
attribute float a_float_visibility;
varying float v_float_distance;
varying float v_float_distance_offset;
const float g_smooth_width = 1.;
const float g_min_denominator = 1e-4;
const float g_w_factor = 1e-6;
void main()
{
    float height = 0.;
    if (u_int_abs_z == 0) {
        height = dem_height(unpack_dem_position(a_vec2_dem_position));
        
        if (a_float_z == 0.) {
            float posHeight = dem_height(a_vec2_vertex);
            if (height > posHeight) {
                height = posHeight;
            }
        }
    } else {
        if (a_float_is_pivot == 1.) {
            height = dem_height(a_vec2_vertex);
        } else {
            height = abs_height(a_float_abs_z);
        }
    }
    
    if (a_float_visibility == 0.0) {
        gl_Position = vec4(0, 0, 1, 1);
        return;
    }
    height += u_float_floor_elevation;
    float shift_pixels = 0.5 * max(u_float_width - 1., 0.);
    float shift_pixels_added = shift_pixels + g_smooth_width;
    vec3 direction = a_vec4_direction_distance.xyz;
    float distance = a_vec4_direction_distance.w;
    vec2 half_viewport = u_vec2_vpt_size / vec2(2.);
    
    
    vec4 clip_space_direction = normalize(u_mat4_mvp * vec4(normalize_s08(direction), 0.));
    
    vec4 vertex_hf = apply_height_factor(vec3(a_vec2_vertex, a_float_z), u_float_height_factor);
    vertex_hf.z += height;
    vec4 clip_space_vertex = u_mat4_mvp * vertex_hf;
    vec2 screen_space_direction =
        (clip_space_direction.xy * clip_space_vertex.w - clip_space_vertex.xy * clip_space_direction.w) * half_viewport;
    vec2 screen_space_perp = vec2(-screen_space_direction.y, screen_space_direction.x);
    float denominator = max(g_min_denominator, length(screen_space_perp));
    gl_Position = g_w_factor * (clip_space_vertex + vec4(screen_space_perp / half_viewport, 0., 0.)
        * distance * shift_pixels_added / denominator * clip_space_vertex.w);
    gl_Position.z += u_float_z_offset;
    v_float_distance = shift_pixels_added * distance * gl_Position.w;
    v_float_distance_offset = shift_pixels;
    vec3 pos_world = calc_pos_world(vertex_hf.xyz);
    calc_fog_pos(pos_world);
#ifdef TAA
    apply_vertex_jitter(gl_Position);
#endif
    
    
    compute_shadow_vertex(clip_space_vertex);
}
`,jp=`#include <prelude>
#include <mvp_mat>
uniform float u_float_scale;
uniform vec3 u_vec3_transform;
attribute vec3 a_vec3_position;
varying vec3 v_position;
void main() {
    vec3 scaled_transformed = u_vec3_transform + a_vec3_position * u_float_scale;
    v_position = scaled_transformed;
    gl_Position = u_mat4_mvp * vec4(scaled_transformed, 1.0);
}
`,Zp=`#include <prelude>
#include <pos_world>
#include <cam_pos>
#include <fog>
attribute vec2 a_vec2_vertex;
void main()
{
    gl_Position = vec4(a_vec2_vertex, 1.0, 1.0);
    calc_fog_pos_sky(gl_Position);
}
`,Wp=`#include <prelude>
attribute vec3 a_vec3_position;
attribute float a_fade_opacity;
#ifndef UBO
uniform mat4 u_mat4_stars;
uniform float u_float_stars_intensity;
uniform float u_float_pixelratio;
#endif
varying mediump float v_intensity;
void main() {
    v_intensity = a_fade_opacity * u_float_stars_intensity;
    gl_PointSize = u_float_pixelratio;
    gl_Position = u_mat4_stars * vec4(a_vec3_position, 1.0);
}
`,$p=`#include <prelude>
#include <mvp_mat>
#include <packed_attributes>
#include <pixel_offset>
#include <calculate_scale>
#include <line_width>
#include <apply_opacity>
#include <precision_constants>
#include <striped_line_functions>
#include <pos_world>
#include <cam_pos>
#include <fog>
#include <jitter>
#include <shadow>
#include <dem>
#ifndef UBO
uniform mediump vec2 u_vec2_vpt_size;
#endif
uniform vec4 u_vec4_dash_color;
uniform vec4 u_vec4_space_color;
uniform vec4 u_vec4_border_color;
uniform vec3 u_vec3_projection_scale_style_scale_dpi;
uniform float u_float_width;
uniform float u_float_width_offset;
uniform vec2 u_vec2_scaler_params;
uniform float u_float_dash_length;
uniform float u_float_space_length;
uniform float u_float_dash2_length;
uniform float u_float_opacity;
uniform bool u_bool_is_3d_line;
attribute vec2 a_vec2_vertex;
attribute vec2 a_vec2_texture_widen;
attribute vec2 a_vec2_widen;
attribute float a_float_vertex_distance;
attribute float a_float_component_distance;
attribute float a_float_object_length;
attribute float a_float_height;
varying vec4 v_vec4_dash_color;
varying vec4 v_vec4_space_color;
varying vec4 v_vec4_border_color;
varying vec2 v_vec2_circle;
varying float v_float_width;
varying vec2 v_vec2_line_params;
const float g_shift_pixels = 2.;
const float g_w_factor = 1e-7;
PolylineDistance decode_line_distance()
{
    return PolylineDistance(
        a_float_vertex_distance,
        a_float_component_distance,
        a_float_object_length);
}
StripedLineInParams decode_line_params(const Scale scale)
{
    float width = calculate_final_width(scale, u_float_width, u_float_width_offset);
    float dash_length  = scale.calculation * u_float_dash_length;
    float space_length = scale.calculation * u_float_space_length;
    float dash2_length = scale.calculation * u_float_dash2_length;
    return StripedLineInParams(
        dash_length,
        space_length,
        dash2_length,
        width);
}
void main()
{
    float height = 0.;
    if (u_bool_is_3d_line == true) {
        height = dem_height(a_vec2_vertex);
    }
    if (u_bool_is_3d_line == true) {
        height += a_float_height / (65535. * 32.);
    }
    Scale scale = calculate_scale(u_vec3_projection_scale_style_scale_dpi, u_vec2_scaler_params);
    StripedLineInParams params = decode_line_params(scale);
    vec2 widen = unpack_widen(a_vec2_widen);
    vec2 widen_perp = vec2(-widen.y, widen.x);
    
    vec4 clip_space_widen = u_mat4_mvp * vec4(widen, 0., 0.);
    vec4 clip_space_widen_perp = u_mat4_mvp * vec4(widen_perp, 0., 0.);
    
    vec4 clip_space_vertex = u_mat4_mvp * vec4(a_vec2_vertex, height, 1.0) + clip_space_widen * params.line_width;
    vec2 half_viewport = 0.5 * u_vec2_vpt_size;
    
    float limited_factor = calculate_multiplication_factor(
        half_viewport,
        clip_space_widen,
        clip_space_widen_perp,
        clip_space_vertex,
        g_shift_pixels);
    PolylineDistance distance_decoded = decode_line_distance();
    StripedLineOutParams output_params;
    calculate_line_params(distance_decoded, params, output_params);
    
    
    vec2 texture_widen_with_shift_sign = unpack_widen(a_vec2_texture_widen);
    float shift_sign = sign(dot(widen, texture_widen_with_shift_sign));
    vec2 texture_widen = shift_sign * texture_widen_with_shift_sign;
    vec2 texture_widen_perp = vec2(-texture_widen.y, texture_widen.x);
    float distance_shift = shift_sign * abs(dot(widen, texture_widen_perp)) * params.line_width;
    float circle_factor = g_circle_scale_precision_factor / scale.calculation;
    v_vec2_circle = texture_widen * (params.line_width + limited_factor) * circle_factor;
    v_float_width = params.line_width * circle_factor;
    v_vec2_line_params[0] = output_params.part_color_swap_threshold;
    v_vec2_line_params[1] = output_params.distance_in_parts;
    v_vec4_dash_color = apply_opacity(u_vec4_dash_color, u_float_opacity);
    v_vec4_space_color = apply_opacity(u_vec4_space_color, u_float_opacity);
    v_vec4_border_color = apply_opacity(u_vec4_border_color, u_float_opacity);
    gl_Position = clip_space_vertex + clip_space_widen * limited_factor;
    vec3 pos_world = calc_pos_world(a_vec2_vertex);
    calc_fog_pos(pos_world);
#ifdef TAA
    apply_vertex_jitter(gl_Position);
#endif
    gl_Position *= g_w_factor;
    compute_shadow_vertex(clip_space_vertex, vec3(0.0, 0.0, 1.0), u_mat4_mvp);
}
`,Xp=`#include <prelude>
#include <mvp_mat>
#include <packed_attributes>
#include <pixel_offset>
#include <calculate_scale>
#include <line_width>
#include <apply_opacity>
#include <precision_constants>
#include <striped_line_functions>
#include <dem>
#ifndef UBO
uniform mediump vec2 u_vec2_vpt_size;
#endif
uniform vec4 u_vec4_dash_color;
uniform vec4 u_vec4_space_color;
uniform vec4 u_vec4_border_color;
uniform vec3 u_vec3_projection_scale_style_scale_dpi;
uniform float u_float_width;
uniform float u_float_width_offset;
uniform vec2 u_vec2_scaler_params;
uniform float u_float_dash_length;
uniform float u_float_space_length;
uniform float u_float_dash2_length;
uniform float u_float_opacity;
uniform bool u_bool_is_3d_line;
attribute vec2 a_vec2_vertex;
attribute vec2 a_vec2_texture_widen;
attribute vec2 a_vec2_widen;
attribute float a_float_vertex_distance;
attribute float a_float_component_distance;
attribute float a_float_object_length;
attribute vec4 a_vec4_identifier;
attribute float a_float_height;
varying vec4 v_vec4_identifier;
const float g_shift_pixels = 2.;
const float g_w_factor = 1e-7;
PolylineDistance decode_line_distance()
{
    return PolylineDistance(
        a_float_vertex_distance,
        a_float_component_distance,
        a_float_object_length);
}
StripedLineInParams decode_line_params(const Scale scale)
{
    float width = calculate_final_width(scale, u_float_width, u_float_width_offset);
    float dash_length  = scale.calculation * u_float_dash_length;
    float space_length = scale.calculation * u_float_space_length;
    float dash2_length = scale.calculation * u_float_dash2_length;
    return StripedLineInParams(
        dash_length,
        space_length,
        dash2_length,
        width);
}
void main()
{
    float height = 0.;
    if (u_bool_is_3d_line == true) {
        height = dem_height(a_vec2_vertex);
    }
    if (u_bool_is_3d_line == true) {
        height += a_float_height / (65535. * 32.);
    }
    Scale scale = calculate_scale(u_vec3_projection_scale_style_scale_dpi, u_vec2_scaler_params);
    StripedLineInParams params = decode_line_params(scale);
    vec2 widen = unpack_widen(a_vec2_widen);
    vec2 widen_perp = vec2(-widen.y, widen.x);
    
    vec4 clip_space_widen = u_mat4_mvp * vec4(widen, 0., 0.);
    vec4 clip_space_widen_perp = u_mat4_mvp * vec4(widen_perp, 0., 0.);
    
    vec4 clip_space_vertex = u_mat4_mvp * vec4(a_vec2_vertex, height, 1.0) + clip_space_widen * params.line_width;
    vec2 half_viewport = 0.5 * u_vec2_vpt_size;
    
    float limited_factor = calculate_multiplication_factor(
        half_viewport,
        clip_space_widen,
        clip_space_widen_perp,
        clip_space_vertex,
        g_shift_pixels);
    PolylineDistance distance_decoded = decode_line_distance();
    StripedLineOutParams output_params;
    calculate_line_params(distance_decoded, params, output_params);
    v_vec4_identifier = a_vec4_identifier;
    if (vec4(1., 1., 1., 1.) != a_vec4_identifier)
    {
        gl_Position = (clip_space_vertex + clip_space_widen * limited_factor) * g_w_factor;
    }
    else
    {
        gl_Position = vec4(1., 1., 1., 1.);
    }
}
`,Kp=`#include <prelude>
#include <mvp_mat>
#include <dem>
#include <packed_attributes>
#include <apply_height_factor>
#include <apply_opacity>
#include <pos_world>
#include <cam_pos>
#include <fog>
#include <clipspace_pos>
#include <jitter>
#include <shadow>
uniform float u_float_height_factor;
uniform float u_float_floor_elevation;
uniform int u_int_texture_index;
attribute vec2 a_vec2_vertex;
attribute float a_float_z;
attribute vec2 a_vec2_dem_position;
attribute float a_float_visibility;
attribute vec2 a_vec2_wall_size; 
attribute vec2 a_vec2_quad_fraction; 
varying vec4 v_vec4_rotated_scaled_vertex;
varying vec2 v_vec2_quad_fraction;
varying vec2 v_vec2_wall_size_su;
const float g_wall_offset_isometric = 0.001;
const float g_wall_offset_perspective = 8.;
const float g_wall_texture_offset = 0.0000000005;
void main()
{
    
    if (a_float_visibility == 0.0) {
        gl_Position = vec4(0, 0, 1, 1);
        return;
    }
    float height = dem_height(unpack_dem_position(a_vec2_dem_position));
    
    if (a_float_z == 0.) {
        float posHeight = dem_height(a_vec2_vertex);
        if (height > posHeight) {
            height = posHeight;
        }
    }
    height += u_float_floor_elevation;
    vec3 vertex = vec3(a_vec2_vertex, a_float_z);
    vec4 vertex_hf = apply_height_factor(vertex, u_float_height_factor);
    vertex_hf.z += height;
    
    vertex_hf.z = max(vertex_hf.z, height);
    
    
    vec3 cam_dir = normalize(u_cam_pos - calc_pos_world(vertex_hf));
    float dist = length(u_cam_pos - calc_pos_world(vertex_hf));
    float scaled_offset = (g_wall_texture_offset + 0.0000000001 * float(u_int_texture_index)) * dist;
    vertex_hf.xyz += cam_dir * scaled_offset;
    vec4 clip_pos = u_mat4_mvp * vertex_hf;
    gl_Position = clip_pos;
    
    
    if ((u_mat4_mvp[0][3] == 0.) && (u_mat4_mvp[1][3] == 0.) && (u_mat4_mvp[2][3] == 0.))
    {
        gl_Position.z += g_wall_offset_isometric;
    }
    else
    {
        
        
        
        if (height == 0.) {
            gl_Position.z += g_wall_offset_perspective;
        } else {
            gl_Position.z += g_wall_offset_isometric;
        }
    }
    vec3 pos_world = calc_pos_world(vertex_hf);
    calc_fog_pos(pos_world);
    save_clipspace_pos();
#ifdef TAA
    apply_vertex_jitter(gl_Position);
#endif
    
    
    mat3 rotation_scale_mat = mat3(u_mat4_model);
    v_vec4_rotated_scaled_vertex.xyz = rotation_scale_mat * vertex;
    
    compute_shadow_vertex(clip_pos);
    v_vec2_quad_fraction = a_vec2_quad_fraction;
    v_vec2_wall_size_su = a_vec2_wall_size;
}
`,qp=`#include <prelude>
#include <mvp_mat>
#include <dem>
#include <packed_attributes>
#include <apply_height_factor>
#include <pos_world>
#include <cam_pos>
#include <fog>
#include <clipspace_pos>
#include <jitter>
#include <shadow>
uniform float u_float_height_factor;
attribute vec2 a_vec2_vertex;
attribute float a_float_z;
attribute vec2 a_vec2_texcoord;
attribute vec2 a_vec2_dem_position;
varying vec2 v_vec2_texcoord;
varying vec3 v_vec3_rotated_scaled_vertex;
void main()
{
    float height = dem_height(unpack_dem_position(a_vec2_dem_position));
    v_vec2_texcoord = unpack_model_texcoord(a_vec2_texcoord);
    vec3 vertex = vec3(a_vec2_vertex, a_float_z);
    vec4 vh = apply_height_factor(vertex, u_float_height_factor);
    vh.z += height;
    vec3 pos_world = calc_pos_world(vh);
    calc_fog_pos(pos_world);
    gl_Position = u_mat4_mvp * vh;
    
    
    mat3 rotation_scale_mat = mat3(u_mat4_model);
    v_vec3_rotated_scaled_vertex = rotation_scale_mat * vertex;
    save_clipspace_pos();
#ifdef TAA
    apply_vertex_jitter(gl_Position);
#endif
    
    compute_shadow_vertex(gl_Position);
}
`,Yp=`#include <prelude>
#include <mvp_mat>
#include <dem>
#include <round_position>
#ifndef UBO
uniform vec2 u_vec2_vpt_size;
#endif
attribute vec2 a_vec2_vertex;
attribute float a_float_z;
attribute vec4 a_vec4_identifier;
attribute vec2 a_vec2_dem_position;
varying vec4 v_vec4_identifier;
void main()
{
    float height = dem_height(unpack_dem_position(a_vec2_dem_position));
    v_vec4_identifier = a_vec4_identifier;
    if (vec4(1., 1., 1., 1.) != a_vec4_identifier)
    {
        gl_Position = round_position(u_mat4_mvp * vec4(a_vec2_vertex, a_float_z + height, 1.), .5 * u_vec2_vpt_size);
    }
    else
    {
        gl_Position = vec4(1., 1., 1., 1.);
    }
}
`,Qp=`#include <prelude>
#include <mvp_mat>
#include <dem>
#include <apply_height_factor>
uniform float u_float_height_factor;
attribute vec2 a_vec2_vertex;
attribute float a_float_z;
attribute vec2 a_vec2_dem_position;
varying float v_depth_metric;
void main()
{
    float height = dem_height(unpack_dem_position(a_vec2_dem_position));
    vec4 vh = apply_height_factor(vec3(a_vec2_vertex, a_float_z), u_float_height_factor);
    vh.z += height;
    gl_Position = u_mat4_mvp * vh;
    v_depth_metric = (gl_Position.z + 1.0) / 2.0;
}
`,Jp={apply_height_factor:zm,apply_opacity:Er,arrow_functions:Rm,calculate_scale:Fm,cam_pos:Ir,clipspace_pos:Dm,dem:Om,depth_test:Nm,ecef_mvp_mat:km,fog:Um,jitter:Gm,line_width:Hm,mix_color_defs:Cr,mvp_mat:Vm,packed_attributes:jm,pixel_offset:Zm,pos_world:Wm,precision_constants:$m,prelude:Xm,raster_functions:Km,round_position:qm,shadow:Ym,show_ratio:Qm,signed_distance_functions:Lr,striped_line_functions:Jm},Ap={arrow_line_entrance:Am,building_shadow:ep,circle_marker:tp,circle_marker_identify:ip,color:np,color_identify:op,dem_elevation:sp,dem_elevation_copy:ap,dem_flat_bottom:rp,dem_ground:lp,dem_ground2:cp,dem_mesh:dp,dem_mesh2:_p,dem_normal:up,diffuse:hp,diffuse_identify:fp,globe:mp,globe_halo:pp,gltf_model:vp,gltf_shadow:gp,heatmap:yp,heatmap_texture:bp,label_directional:xp,label_fixed_anchor:wp,label_fixed_anchor_identify:Sp,line:Tp,line3d:Mp,line3d_identify:Ep,map_mesh:Ip,mesh:Cp,mesh_shadow:Lp,metric_point:Pp,one_way_line:Bp,patterned_line:zp,point_anchor:Rp,pointsprite:Fp,pointsprite_identify:Dp,posteffect:Op,rect:Np,rect_with_texture:kp,road:Up,road_identify:Gp,simple_line_2d:Hp,simple_line_3d:Vp,simple_mesh:jp,sky:Zp,stars:Wp,striped_line:$p,striped_line_identify:Xp,wall_texture:Kp,zbm_model:qp,zbm_model_identify:Yp,zbm_shadow:Qp},ev=/^\s*#include\s+<(.+)>.*$/gim,tv=(s,e)=>(t,i)=>{const o=i.trim(),a=s==="vertex"?Jp[o]:Pm[o];if(!a)throw new Error(`Cannot resolve "include <${o}>" in ${s} shader "${e}"`);return a+`
`};function Pr(s,e){return[(s==="vertex"?Ap[e]:Bm[e]).replace(ev,tv(s,e))]}function O(s){const e=ui.webglVersion===2?["#version 300 es"]:[],t=n.Shader.createShaderDefinitions([{type:`WEBGL${ui.webglVersion}`,value:""},{type:Ku,value:""}]);return i=>new n.Shader("vertex",e.concat(Pr("vertex",s)),t,i)}function N(s){const e=ui.webglVersion===2?["#version 300 es"]:[],t=n.Shader.createShaderDefinitions([{type:`WEBGL${ui.webglVersion}`,value:""},{type:Xu,value:""}]);return i=>new n.Shader("fragment",e.concat(Pr("fragment",s)),t,i)}const $={name:"u_mat4_mvp",type:"mat4"},lt=[{name:"u_mat4_flat_mvp",type:"mat4"},{name:"u_mat4_ecef_mvp",type:"mat4"},{name:"u_float_crossfade",type:"1f"}],Q={name:"u_mat4_model",type:"mat4"},No=[{name:"u_vec2_anchor",type:"2f"},{name:"u_vec4_axis",type:"4f"},{name:"u_int_gltf_dem_pos",type:"1i"}],J=[{name:"u_tex_dem",type:"1i"},{name:"u_tex_corrected_dem",type:"1i"},{name:"u_float_corrected_interval",type:"1f"},{name:"u_mat4_dem_corrected",type:"mat4"},{name:"u_tex_hillshade_ramp",type:"1i"},{name:"u_mat4_dem_mvp",type:"mat4"},{name:"u_float_dem_scale",type:"1f"},{name:"u_float_vertical_scale",type:"1f"},{name:"u_float_dem_resolution",type:"1f"},{name:"u_float_dem_cell_size",type:"1f"},{name:"u_float_dem_shading_intensity",type:"1f"},{name:"u_float_map_center_elevation",type:"1f"}],it=[{name:"u_int_abs_z",type:"1i"}],ie=[{name:"u_cam_pos",type:"3f"}],fe=[{name:"u_int_light_flags",type:"1i"},{name:"u_vec4_ambient_color",type:"4fv"},{name:"u_vec3_light_dir1_direction",type:"3fv"},{name:"u_vec4_light_dir1_color",type:"4fv"},{name:"u_vec3_light_dir2_direction",type:"3fv"},{name:"u_vec4_light_dir2_color",type:"4fv"}],me=[{name:"u_texture_shadow",type:"1i"},{name:"u_mat4_clip_to_shadow",type:"mat4"},{name:"u_shadow_map_params",type:"4f"},{name:"u_shadow_bias",type:"1f"}],ne=[{name:"u_fog_color",type:"4f"},{name:"u_sky_color",type:"4f"},{name:"u_fog_limits",type:"2f"},{name:"u_fog_horizon_blend",type:"1f"},{name:"u_fog_horizon_level",type:"1f"},{name:"u_fog_horizon_pad",type:"1f"},{name:"u_mat4_model",type:"mat4"},{name:"u_fog_distance",type:"1f"},{name:"u_mat4_proj_inverted",type:"mat4"},{name:"u_mat4_view_transposed",type:"mat4"}],ve=[{name:"u_vec2_camera_jitter",type:"2f"}];function iv(){return{simpleMesh:{buildFragment:N("simple_mesh"),buildVertex:O("simple_mesh"),attributes:[{name:"a_vec3_position",location:0},{name:"a_vec3_normal",location:1}],uniforms:[$,{name:"u_float_scale",type:"1f"},{name:"u_vec3_transform",type:"3fv"}]},diffuse:{buildVertex:O("diffuse"),buildFragment:N("color_with_z_fade"),uniforms:[$,Q,{name:"u_vec4_color",type:"4fv"},{name:"u_float_height_factor",type:"1f"},{name:"u_float_opacity",type:"1f"},{name:"u_sdtr_distance",type:"1f"},{name:"u_float_floor_elevation",type:"1f"},{name:"u_int_is_roof",type:"1i"},...ie,...fe,...me,...J,...ne,...ve],attributes:[{name:"a_vec2_vertex",location:0},{name:"a_float_z",location:1},{name:"a_vec2_dem_position",location:2},{name:"a_float_visibility",location:3},{name:"a_vec2_tex_coords",location:4}]},gradientDiffuse:{buildVertex:O("diffuse"),buildFragment:N("gradient_with_z_fade"),uniforms:[$,Q,{name:"u_vec4_color",type:"4fv"},{name:"u_float_height_factor",type:"1f"},{name:"u_float_opacity",type:"1f"},{name:"u_mat4_gradient",type:"mat4"},{name:"u_sdtr_distance",type:"1f"},{name:"u_float_floor_elevation",type:"1f"},{name:"u_vec2_floor_level",type:"2fv"},{name:"u_int_is_roof",type:"1i"},...ie,...fe,...me,...J,...ne,...ve],attributes:[{name:"a_vec2_vertex",location:0},{name:"a_float_z",location:1},{name:"a_vec2_dem_position",location:2},{name:"a_float_visibility",location:3}]},wallTexture:{buildVertex:O("wall_texture"),buildFragment:N("wall_texture"),uniforms:[$,Q,{name:"u_float_height_factor",type:"1f"},{name:"u_sdtr_distance",type:"1f"},{name:"u_float_floor_elevation",type:"1f"},{name:"u_sr2d_texture",type:"1i"},{name:"u_vec4_wall_padding_su",type:"4fv"},{name:"u_vec4_texture_padding_un",type:"4fv"},{name:"u_vec2_texture_part_count",type:"2fv"},{name:"u_vec2_max_interval_su",type:"2fv"},{name:"u_vec2_texture_slice_size_su",type:"2fv"},{name:"u_ivec2_layout_mode",type:"2iv"},{name:"u_int_texture_index",type:"1i"},...ie,...fe,...me,...J,...ne,...ve],attributes:[{name:"a_vec2_vertex",location:0},{name:"a_float_z",location:1},{name:"a_vec2_dem_position",location:2},{name:"a_float_visibility",location:3},{name:"a_vec2_wall_size",location:4},{name:"a_vec2_quad_fraction",location:5}]},labelLine:{buildVertex:O("label_directional"),buildFragment:N("label_directional"),uniforms:[$,Q,{name:"u_float_tile_to_pixel_ratio",type:"1f"},{name:"u_sr2d_texture",type:"1i"},{name:"u_float_buffer",type:"1f"},{name:"u_float_gamma",type:"1f"},{name:"u_float_scale",type:"1f"},{name:"u_vec4_color",type:"4fv"},{name:"u_float_style_zoom",type:"1f"},{name:"u_float_height_factor",type:"1f"},{name:"u_float_opacity",type:"1f"},...ie,...ne],attributes:[{name:"a_vec4_position",location:0},{name:"a_vec2_offset",location:1},{name:"a_vec2_texcoord",location:2},{name:"a_vec2_style_zoom_limits",location:3}]},labelPoint:{buildVertex:O("label_fixed_anchor"),buildFragment:N("label"),uniforms:[...lt,Q,{name:"u_vec2_vpt_size",type:"2f"},{name:"u_sr2d_texture",type:"1i"},{name:"u_float_buffer",type:"1f"},{name:"u_float_gamma",type:"1f"},{name:"u_float_scale",type:"1f"},{name:"u_vec4_color",type:"4fv"},{name:"u_vec4_hidden_color",type:"4fv"},{name:"u_float_label_index",type:"1f"},{name:"u_float_opacity",type:"1f"},{name:"u_vec2_offset",type:"2f"},{name:"u_float_height_factor",type:"1f"},{name:"u_depth_tex_labeling",type:"1i"},{name:"u_color_tex_labeling",type:"1i"},{name:"u_color_text_sprite_labeling",type:"1i"},{name:"u_vec2_depth_test_half_point_size",type:"2f"},{name:"u_bool_skip_height_factor",type:"1i"},{name:"u_bool_depth_test_disable",type:"1i"},{name:"u_float_floor_elevation",type:"1f"},...ie,...J,...ne],attributes:[{name:"a_vec3_flat_position",location:0},{name:"a_vec3_ecef_position",location:1},{name:"a_vec2_offset",location:2},{name:"a_vec2_texcoord",location:3},{name:"a_vec2_check_offset",location:4},{name:"a_vec4_tex_identifier",location:5},{name:"a_vec4_sprite_identifier",location:6}]},labelPointIdentify:{buildVertex:O("label_fixed_anchor_identify"),buildFragment:N("color_identify"),uniforms:[...lt,{name:"u_vec2_vpt_size",type:"2f"},{name:"u_float_scale",type:"1f"},{name:"u_vec2_offset",type:"2f"},{name:"u_float_floor_elevation",type:"1f"},...J],attributes:[{name:"a_vec3_flat_position",location:0},{name:"a_vec3_ecef_position",location:1},{name:"a_vec2_offset",location:2},{name:"a_vec4_identifier",location:3}]},line:{buildVertex:O("line"),buildFragment:N("line"),uniforms:[$,Q,{name:"u_vec2_vpt_size",type:"2fv"},{name:"u_vec4_color",type:"4fv"},{name:"u_float_height_factor",type:"1f"},{name:"u_float_opacity",type:"1f"},{name:"u_mat4_gradient",type:"mat4"},{name:"u_float_floor_elevation",type:"1f"},...ie,...fe,...me,...J,...ne,...ve],attributes:[{name:"a_vec2_vertex",location:0},{name:"a_float_z",location:1},{name:"a_vec2_normal",location:2},{name:"a_vec2_normal_delta",location:3},{name:"a_vec3_direction",location:4},{name:"a_float_distance",location:5},{name:"a_vec2_dem_position",location:6},{name:"a_float_visibility",location:7}]},pointSprite:{buildVertex:O("pointsprite"),buildFragment:N("pointsprite"),uniforms:[...lt,Q,{name:"u_vec2_vpt_size",type:"2fv"},{name:"u_vec3_projection_scale_style_scale_dpi",type:"3fv"},{name:"u_sr2d_texture",type:"1i"},{name:"u_float_rounding_factor",type:"1f"},{name:"u_float_height_factor",type:"1f"},{name:"u_vec2_opacity",type:"2f"},{name:"u_vec2_rotation",type:"2fv"},{name:"u_depth_tex_labeling",type:"1i"},{name:"u_color_tex_labeling",type:"1i"},{name:"u_color_text_sprite_labeling",type:"1i"},{name:"u_vec2_depth_test_half_point_size",type:"2f"},{name:"u_bool_skip_height_factor",type:"1i"},{name:"u_bool_depth_test_disable",type:"1i"},{name:"u_float_floor_elevation",type:"1f"},...ie,...J,...ne],attributes:[{name:"a_vec3_flat_position",location:0},{name:"a_vec3_ecef_position",location:1},{name:"a_vec2_offset",location:2},{name:"a_vec2_check_offset",location:3},{name:"a_vec2_texcoord",location:4},{name:"a_vec2_range",location:5},{name:"a_vec2_rescale",location:6},{name:"a_vec4_tex_identifier",location:7}]},pointSpriteIdentify:{buildVertex:O("pointsprite_identify"),buildFragment:N("pointsprite_identify"),uniforms:[...lt,{name:"u_vec2_vpt_size",type:"2fv"},{name:"u_vec3_projection_scale_style_scale_dpi",type:"3fv"},{name:"u_sr2d_texture",type:"1i"},{name:"u_float_height_factor",type:"1f"},{name:"u_vec2_rotation",type:"2fv"},{name:"u_bool_skip_height_factor",type:"1i"},{name:"u_float_floor_elevation",type:"1f"},{name:"u_float_identify_opacity",type:"1f"},...J],attributes:[{name:"a_vec3_flat_position",location:0},{name:"a_vec3_ecef_position",location:1},{name:"a_vec2_offset",location:2},{name:"a_vec2_texcoord",location:3},{name:"a_vec2_range",location:4},{name:"a_vec2_rescale",location:5},{name:"a_vec4_identifier",location:6}]},pointDepthTest:{buildVertex:O("point_anchor"),buildFragment:N("color_identify"),uniforms:[$,{name:"u_vec2_vpt_size",type:"2f"},{name:"u_vec2_offset",type:"2f"},{name:"u_float_floor_elevation",type:"1f"},...J],attributes:[{name:"a_vec4_position",location:0},{name:"a_vec2_offset",location:1},{name:"a_vec4_identifier",location:2}]},stripedLine:{buildVertex:O("striped_line"),buildFragment:N("striped_line"),uniforms:[$,Q,{name:"u_vec2_vpt_size",type:"2fv"},{name:"u_vec3_projection_scale_style_scale_dpi",type:"3fv"},{name:"u_vec2_scaler_params",type:"2fv"},{name:"u_float_dash_length",type:"1f"},{name:"u_float_space_length",type:"1f"},{name:"u_float_dash2_length",type:"1f"},{name:"u_vec4_dash_color",type:"4fv"},{name:"u_vec4_space_color",type:"4fv"},{name:"u_vec4_border_color",type:"4fv"},{name:"u_float_width",type:"1f"},{name:"u_float_width_offset",type:"1f"},{name:"u_int_gap_turns_only",type:"1i"},{name:"u_float_opacity",type:"1f"},{name:"u_bool_is_3d_line",type:"1i"},...ie,...ne,...ve,...fe,...me],attributes:[{name:"a_vec2_vertex",location:0},{name:"a_vec2_texture_widen",location:1},{name:"a_vec2_widen",location:2},{name:"a_float_vertex_distance",location:3},{name:"a_float_component_distance",location:4},{name:"a_float_object_length",location:5},{name:"a_vec4_identifier",location:6}]},stripedLine3D:{buildVertex:O("striped_line"),buildFragment:N("striped_line"),uniforms:[$,Q,{name:"u_vec2_vpt_size",type:"2fv"},{name:"u_vec3_projection_scale_style_scale_dpi",type:"3fv"},{name:"u_vec2_scaler_params",type:"2fv"},{name:"u_float_dash_length",type:"1f"},{name:"u_float_space_length",type:"1f"},{name:"u_float_dash2_length",type:"1f"},{name:"u_vec4_dash_color",type:"4fv"},{name:"u_vec4_space_color",type:"4fv"},{name:"u_vec4_border_color",type:"4fv"},{name:"u_float_width",type:"1f"},{name:"u_float_width_offset",type:"1f"},{name:"u_int_gap_turns_only",type:"1i"},{name:"u_float_opacity",type:"1f"},{name:"u_bool_is_3d_line",type:"1i"},...J,...ie,...ne,...ve,...fe,...me],attributes:[{name:"a_vec2_vertex",location:0},{name:"a_vec2_texture_widen",location:1},{name:"a_vec2_widen",location:2},{name:"a_float_vertex_distance",location:3},{name:"a_float_component_distance",location:4},{name:"a_float_object_length",location:5},{name:"a_vec4_identifier",location:6},{name:"a_float_height",location:7}]},patternedLine:{buildVertex:O("patterned_line"),buildFragment:N("patterned_line"),uniforms:[$,{name:"u_vec2_scales",type:"2fv"},{name:"u_vec4_color",type:"4fv"},{name:"u_float_width",type:"1f"},{name:"u_float_opacity",type:"1f"},{name:"u_int_pattern_type",type:"1i"},{name:"u_vec4_pattern_params",type:"4fv"},{name:"u_bool_is_3d_line",type:"1i"},Q,...ie,...ne,...ve,...fe,...me],attributes:[{name:"a_vec2_vertex",location:0},{name:"a_vec2_widen",location:1},{name:"a_float_texture",location:2},{name:"a_vec4_identifier",location:3}]},patternedLine3D:{buildVertex:O("patterned_line"),buildFragment:N("patterned_line"),uniforms:[$,{name:"u_vec2_scales",type:"2fv"},{name:"u_vec4_color",type:"4fv"},{name:"u_float_width",type:"1f"},{name:"u_float_opacity",type:"1f"},{name:"u_int_pattern_type",type:"1i"},{name:"u_vec4_pattern_params",type:"4fv"},{name:"u_bool_is_3d_line",type:"1i"},Q,...J,...ie,...ne,...ve,...fe,...me],attributes:[{name:"a_vec2_vertex",location:0},{name:"a_vec2_widen",location:1},{name:"a_float_texture",location:2},{name:"a_vec4_identifier",location:3},{name:"a_float_height",location:4}]},stripedLineIdentify:{buildVertex:O("striped_line_identify"),buildFragment:N("color_identify"),uniforms:[$,{name:"u_vec2_vpt_size",type:"2fv"},{name:"u_vec3_projection_scale_style_scale_dpi",type:"3fv"},{name:"u_vec2_scaler_params",type:"2fv"},{name:"u_float_dash_length",type:"1f"},{name:"u_float_space_length",type:"1f"},{name:"u_float_dash2_length",type:"1f"},{name:"u_vec4_dash_color",type:"4fv"},{name:"u_vec4_space_color",type:"4fv"},{name:"u_vec4_border_color",type:"4fv"},{name:"u_float_width",type:"1f"},{name:"u_float_width_offset",type:"1f"},{name:"u_int_gap_turns_only",type:"1i"},{name:"u_float_opacity",type:"1f"},{name:"u_bool_is_3d_line",type:"1i"}],attributes:[{name:"a_vec2_vertex",location:0},{name:"a_vec2_texture_widen",location:1},{name:"a_vec2_widen",location:2},{name:"a_float_vertex_distance",location:3},{name:"a_float_component_distance",location:4},{name:"a_float_object_length",location:5},{name:"a_vec4_identifier",location:6}]},stripedLine3DIdentify:{buildVertex:O("striped_line_identify"),buildFragment:N("color_identify"),uniforms:[$,{name:"u_vec2_vpt_size",type:"2fv"},{name:"u_vec3_projection_scale_style_scale_dpi",type:"3fv"},{name:"u_vec2_scaler_params",type:"2fv"},{name:"u_float_dash_length",type:"1f"},{name:"u_float_space_length",type:"1f"},{name:"u_float_dash2_length",type:"1f"},{name:"u_vec4_dash_color",type:"4fv"},{name:"u_vec4_space_color",type:"4fv"},{name:"u_vec4_border_color",type:"4fv"},{name:"u_float_width",type:"1f"},{name:"u_float_width_offset",type:"1f"},{name:"u_int_gap_turns_only",type:"1i"},{name:"u_float_opacity",type:"1f"},{name:"u_bool_is_3d_line",type:"1i"},...J],attributes:[{name:"a_vec2_vertex",location:0},{name:"a_vec2_texture_widen",location:1},{name:"a_vec2_widen",location:2},{name:"a_float_vertex_distance",location:3},{name:"a_float_component_distance",location:4},{name:"a_float_object_length",location:5},{name:"a_vec4_identifier",location:6},{name:"a_float_height",location:7}]},vtxColor:{buildVertex:O("color"),buildFragment:N("textured_color"),uniforms:[$,Q,{name:"u_vec4_color",type:"4fv"},{name:"u_float_opacity",type:"1f"},{name:"u_sr2d_texture",type:"1i"},{name:"u_float_texture_opacity",type:"1f"},{name:"u_float_texture_params",type:"4fv"},{name:"u_float_sprite_texture_coords",type:"4fv"},{name:"u_int_is_textured",type:"1i"},{name:"u_float_floor_elevation",type:"1f"},{name:"u_int_is_normal_map_textured",type:"1i"},{name:"u_sr2d_texture1",type:"1i"},{name:"u_vec4_normal_map_texture_params",type:"4fv"},{name:"u_vec4_normal_map_sprite_texture_coords",type:"4fv"},{name:"u_int_normal_map_is_animated",type:"1i"},{name:"u_vec4_normal_map_animated_offsets",type:"4fv"},{name:"u_float_metallic",type:"1f"},{name:"u_float_roughness",type:"1f"},{name:"u_vec4_color2",type:"4fv"},{name:"u_sr2d_read_from_target_texture",type:"1i"},{name:"u_float_factor_interpolate_base",type:"1f"},{name:"u_vec4_factor_interpolate_ranges",type:"4f"},{name:"u_int_factor_use_interpolate",type:"1i"},...ie,...fe,...me,...ne,...ve],attributes:[{name:"a_vec2_vertex",location:0},{name:"a_float_visibility",location:1},{name:"a_float_mix_factor",location:2}]},vtxColorIdentify:{buildVertex:O("color_identify"),buildFragment:N("color_identify"),uniforms:[$,{name:"u_vec2_vpt_size",type:"2fv"},{name:"u_float_floor_elevation",type:"1f"}],attributes:[{name:"a_vec2_vertex",location:0},{name:"a_vec4_identifier",location:1},{name:"a_float_visibility",location:2}]},metricPoint:{buildVertex:O("metric_point"),buildFragment:N("metric_point"),uniforms:[$,Q,{name:"u_vec4_color",type:"4fv"},{name:"u_sr2d_texture",type:"1i"},{name:"u_float_sprite_texture_coords",type:"4fv"},{name:"u_float_floor_elevation",type:"1f"},...ie,...ne,...fe,...me],attributes:[{name:"a_vec2_vertex",location:0},{name:"a_vec2_texcoord",location:1}]},zbmModelIdentify:{buildVertex:O("zbm_model_identify"),buildFragment:N("color_identify"),uniforms:[$,{name:"u_vec2_vpt_size",type:"2fv"},...J],attributes:[{name:"a_vec2_vertex",location:0},{name:"a_float_z",location:1},{name:"a_vec4_identifier",location:2},{name:"a_vec2_dem_position",location:3}]},buildingIdentify:{buildVertex:O("diffuse_identify"),buildFragment:N("color_identify"),uniforms:[$,{name:"u_vec2_vpt_size",type:"2fv"},{name:"u_float_height_factor",type:"1f"},{name:"u_float_floor_elevation",type:"1f"},...J],attributes:[{name:"a_vec2_vertex",location:0},{name:"a_float_z",location:1},{name:"a_vec4_identifier",location:2},{name:"a_vec2_dem_position",location:3},{name:"a_float_visibility",location:4}]},oneWayLine:{buildVertex:O("one_way_line"),buildFragment:N("one_way_line"),uniforms:[$,Q,{name:"u_vec2_vpt_size",type:"2f"},{name:"u_vec3_projection_scale_style_scale_dpi",type:"3fv"},{name:"u_vec4_color",type:"4f"},{name:"u_vec4_border_color",type:"4f"},{name:"u_vec2_wing_normal",type:"2f"},{name:"u_vec2_tip_normal",type:"2f"},{name:"u_float_width",type:"1f"},{name:"u_float_length",type:"1f"},{name:"u_float_tip_radius_zpt",type:"1f"},{name:"u_float_wing_radius_zpt",type:"1f"},{name:"u_float_tail_radius_zpt",type:"1f"},{name:"u_float_border_width",type:"1f"},{name:"u_float_border_width_offset",type:"1f"},{name:"u_float_size_factor",type:"1f"},{name:"u_vec2_scale_limits",type:"2fv"},{name:"u_float_tip_height_multiplier",type:"1f"},{name:"u_float_wing_height_multiplier",type:"1f"},{name:"u_float_wing_width_multiplier",type:"1f"},{name:"u_float_opacity",type:"1f"},...ie,...ne,...ve],attributes:[{name:"a_vec2_position",location:0},{name:"a_vec2_direction",location:1},{name:"a_vec2_widen_direction",location:2}]},zbmModel:{buildVertex:O("zbm_model"),buildFragment:N("zbm_model"),uniforms:[$,Q,{name:"u_vec4_color",type:"4fv"},{name:"u_sr2d_texture",type:"1i"},{name:"u_float_height_factor",type:"1f"},{name:"u_sdtr_distance",type:"1f"},...ie,...J,...ne,...ve,...fe,...me],attributes:[{name:"a_vec2_vertex",location:0},{name:"a_float_z",location:1},{name:"a_vec2_texcoord",location:2},{name:"a_vec2_dem_position",location:3}]},zbmShadow:{buildVertex:O("zbm_shadow"),buildFragment:N("main_shadow"),uniforms:[$,{name:"u_float_height_factor",type:"1f"},...J],attributes:[{name:"a_vec2_vertex",location:0},{name:"a_float_z",location:1},{name:"a_vec2_dem_position",location:2}]},gltfModel:{buildVertex:O("gltf_model"),buildFragment:N("gltf_model"),uniforms:[...lt,Q,{name:"u_mat4_instance",type:"mat4"},{name:"u_mat4_localmatrix",type:"mat4"},{name:"u_vec4_color",type:"4fv"},{name:"u_sr2d_texture_0",type:"1i"},{name:"u_ao_texture",type:"1i"},{name:"u_pbr_texture",type:"1i"},{name:"u_float_identify",type:"1f"},{name:"u_sdtr_distance",type:"1f"},{name:"u_float_height_factor",type:"1f"},{name:"u_float_show_ratio",type:"1f"},{name:"u_float_metallic",type:"1f"},{name:"u_float_roughness",type:"1f"},{name:"u_sampler_map_tex",type:"1i"},{name:"u_vec2_tex_scale",type:"2f"},{name:"u_float_tex_shift_scale",type:"1f"},{name:"u_float_floor_elevation",type:"1f"},{name:"u_int_extention_to_relief_needed",type:"1i"},{name:"u_int_collapse_height_needed",type:"1i"},...ie,...ve,...ne,...J,...fe,...me,...it,...No],attributes:[{name:"position",location:0},{name:"normal",location:1},{name:"tangent",location:2},{name:"a_vec2_instance_position",location:3},{name:"a_vec3_instance_ecef_position",location:4},{name:"a_mat3_instance_matrix",location:5,locationsCount:3},{name:"a_vec4_instance_localid",location:8},{name:"texcoord_color",location:9},{name:"texcoord_ao",location:10},{name:"texcoord_pbr",location:11},{name:"a_float_abs_z",location:12},{name:"a_float_instance_height",location:13}]},gltfModelIdentify:{buildVertex:O("gltf_model"),buildFragment:N("color_identify"),uniforms:[...lt,Q,{name:"u_mat4_instance",type:"mat4"},{name:"u_mat4_localmatrix",type:"mat4"},{name:"u_vec4_color",type:"4fv"},{name:"u_sr2d_texture_0",type:"1i"},{name:"u_float_identify",type:"1f"},{name:"u_float_height_factor",type:"1f"},{name:"u_float_show_ratio",type:"1f"},{name:"u_int_identify",type:"1i"},{name:"u_float_floor_elevation",type:"1f"},{name:"u_int_extention_to_relief_needed",type:"1i"},{name:"u_int_collapse_height_needed",type:"1i"},...ie,...ne,...J,...it,...No],attributes:[{name:"position",location:0},{name:"normal",location:1},{name:"tangent",location:2},{name:"a_vec2_instance_position",location:3},{name:"a_vec3_instance_ecef_position",location:4},{name:"a_mat3_instance_matrix",location:5,locationsCount:3},{name:"a_vec4_instance_localid",location:8},{name:"a_float_abs_z",location:12},{name:"a_float_instance_height",location:13},{name:"texcoord_color",location:9},{name:"texcoord_ao",location:10},{name:"texcoord_pbr",location:11}]},gltfModelShadow:{buildVertex:O("gltf_shadow"),buildFragment:N("main_shadow"),uniforms:[...lt,{name:"u_mat4_instance",type:"mat4"},{name:"u_mat4_localmatrix",type:"mat4"},{name:"u_float_height_factor",type:"1f"},{name:"u_float_show_ratio",type:"1f"},{name:"u_int_extention_to_relief_needed",type:"1i"},{name:"u_int_collapse_height_needed",type:"1i"},...J,...it,...No],attributes:[{name:"position",location:0},{name:"a_vec2_instance_position",location:3},{name:"a_vec3_instance_ecef_position",location:4},{name:"a_mat3_instance_matrix",location:5,locationsCount:3},{name:"a_float_abs_z",location:12},{name:"a_float_instance_height",location:13}]},simpleLine2d:{buildVertex:O("simple_line_2d"),buildFragment:N("simple_line_2d"),uniforms:[$,Q,{name:"u_vec2_vpt_size",type:"2fv"},{name:"u_vec4_color",type:"4fv"},{name:"u_float_width",type:"1f"},{name:"u_float_z_offset",type:"1f"},{name:"u_float_floor_elevation",type:"1f"},...ie,...ve,...fe,...ne,...me],attributes:[{name:"a_vec2_vertex",location:0},{name:"a_vec4_direction_distance",location:1},{name:"a_float_visibility",location:2}]},simpleLine3d:{buildVertex:O("simple_line_3d"),buildFragment:N("simple_line_3d"),uniforms:[$,Q,{name:"u_vec2_vpt_size",type:"2fv"},{name:"u_vec4_color",type:"4fv"},{name:"u_float_width",type:"1f"},{name:"u_float_height_factor",type:"1f"},{name:"u_float_z_offset",type:"1f"},{name:"u_float_floor_elevation",type:"1f"},...ie,...ve,...fe,...ne,...me,...J,...it],attributes:[{name:"a_vec2_vertex",location:0},{name:"a_float_z",location:1},{name:"a_vec4_direction_distance",location:2},{name:"a_vec2_dem_position",location:3},{name:"a_float_abs_z",location:4},{name:"a_float_is_pivot",location:5},{name:"a_float_visibility",location:6}]},road:{buildVertex:O("road"),buildFragment:N("road"),uniforms:[$,Q,{name:"u_vec4_color",type:"4fv"},{name:"u_float_width",type:"1f"},{name:"u_float_tile_to_pixel_ratio",type:"1f"},{name:"u_float_shift",type:"1f"},...ie,...fe,...ne,...ve,...me],attributes:[{name:"a_vec2_vertex",location:0},{name:"a_vec4_normals",location:1},{name:"a_vec2_shift",location:2}]},roadIdentify:{buildVertex:O("road_identify"),buildFragment:N("road_identify"),uniforms:[$,{name:"u_float_width",type:"1f"},{name:"u_float_tile_to_pixel_ratio",type:"1f"}],attributes:[{name:"a_vec2_vertex",location:0},{name:"a_vec4_normals",location:1},{name:"a_vec4_identifier",location:2}]},line3D:{buildVertex:O("line3d"),buildFragment:N("road"),uniforms:[$,Q,{name:"u_vec4_color",type:"4fv"},{name:"u_float_width",type:"1f"},{name:"u_float_tile_to_pixel_ratio",type:"1f"},...J,...ie,...fe,...ne,...ve,...me,...it],attributes:[{name:"a_vec2_vertex",location:0},{name:"a_vec4_normals",location:1},{name:"a_float_height",location:2},{name:"a_float_abs_z",location:3}]},line3DIdentify:{buildVertex:O("line3d_identify"),buildFragment:N("road_identify"),uniforms:[$,{name:"u_float_width",type:"1f"},{name:"u_float_tile_to_pixel_ratio",type:"1f"},...J,...it],attributes:[{name:"a_vec2_vertex",location:0},{name:"a_vec4_normals",location:1},{name:"a_float_height",location:2},{name:"a_float_abs_z",location:3},{name:"a_vec4_identifier",location:4}]},entrance:{buildVertex:O("arrow_line_entrance"),buildFragment:N("arrow_line"),uniforms:[$,Q,{name:"u_vec2_vpt_size",type:"2f"},{name:"u_vec3_projection_scale_style_scale_dpi",type:"3fv"},{name:"u_vec2_scale_limits",type:"2fv"},{name:"u_vec4_color",type:"4f"},{name:"u_vec4_border_color",type:"4f"},{name:"u_vec2_wing_normal",type:"2f"},{name:"u_vec2_tip_normal",type:"2f"},{name:"u_float_width_zpt",type:"1f"},{name:"u_float_tip_radius_zpt",type:"1f"},{name:"u_float_wing_radius_zpt",type:"1f"},{name:"u_float_tail_radius_zpt",type:"1f"},{name:"u_float_tip_height_multiplier",type:"1f"},{name:"u_float_wing_width_multiplier",type:"1f"},{name:"u_float_wing_height_multiplier",type:"1f"},{name:"u_float_border_width_zpt",type:"1f"},{name:"u_float_size_factor",type:"1f"},{name:"u_float_border_width_offset",type:"1f"},{name:"u_float_total_line_length",type:"1f"},{name:"u_float_relative_end_position",type:"1f"},{name:"u_float_vertex_shift",type:"1f"},{name:"u_float_tip_movement_amplitude",type:"1f"},{name:"u_vec2_bounce_direction",type:"2f"},{name:"u_float_opacity",type:"1f"},...ie,...ne],attributes:[{name:"a_vec2_vertex",location:0},{name:"a_vec2_segment_end",location:1},{name:"a_vec4_texture_widen_arrow_widen",location:2},{name:"a_vec2_widen",location:3},{name:"a_vec2_direction",location:4},{name:"a_float_distance_from_start",location:5},{name:"a_float_object_length",location:6},{name:"a_float_type",location:7},{name:"a_vec4_identifier",location:8}]},entranceIdentify:{buildVertex:O("arrow_line_entrance"),buildFragment:N("arrow_line_identify"),uniforms:[$,Q,{name:"u_vec2_vpt_size",type:"2f"},{name:"u_vec3_projection_scale_style_scale_dpi",type:"3fv"},{name:"u_vec2_scale_limits",type:"2fv"},{name:"u_vec4_color",type:"4f"},{name:"u_vec4_border_color",type:"4f"},{name:"u_vec2_wing_normal",type:"2f"},{name:"u_vec2_tip_normal",type:"2f"},{name:"u_float_width_zpt",type:"1f"},{name:"u_float_tip_radius_zpt",type:"1f"},{name:"u_float_wing_radius_zpt",type:"1f"},{name:"u_float_tail_radius_zpt",type:"1f"},{name:"u_float_tip_height_multiplier",type:"1f"},{name:"u_float_wing_width_multiplier",type:"1f"},{name:"u_float_wing_height_multiplier",type:"1f"},{name:"u_float_border_width_zpt",type:"1f"},{name:"u_float_size_factor",type:"1f"},{name:"u_float_border_width_offset",type:"1f"},{name:"u_float_total_line_length",type:"1f"},{name:"u_float_relative_end_position",type:"1f"},{name:"u_float_vertex_shift",type:"1f"},{name:"u_float_tip_movement_amplitude",type:"1f"},{name:"u_vec2_bounce_direction",type:"2f"},{name:"u_float_opacity",type:"1f"}],attributes:[{name:"a_vec2_vertex",location:0},{name:"a_vec2_segment_end",location:1},{name:"a_vec4_texture_widen_arrow_widen",location:2},{name:"a_vec2_widen",location:3},{name:"a_vec2_direction",location:4},{name:"a_float_distance_from_start",location:5},{name:"a_float_object_length",location:6},{name:"a_float_type",location:7},{name:"a_vec4_identifier",location:8}]},circleMarker:{buildVertex:O("circle_marker"),buildFragment:N("circle_marker"),uniforms:[...lt,Q,{name:"u_vec2_vpt_size",type:"2fv"},{name:"u_vec4_color",type:"4fv"},{name:"u_float_width",type:"1f"},...ie,...ne,...fe,...me,...J],attributes:[{name:"a_vec3_flat_position",location:0},{name:"a_vec3_ecef_position",location:1},{name:"a_vec2_widen",location:2}]},rect:{buildVertex:O("rect"),buildFragment:N("rect"),uniforms:[$,{name:"u_vec4_color",type:"4fv"}],attributes:[{name:"a_vec2_vertex",location:0}]},rectWithTexture:{buildVertex:O("rect_with_texture"),buildFragment:N("rect_with_texture"),uniforms:[$,Q,{name:"u_sr2d_texture",type:"1i"},{name:"u_float_opacity",type:"1f"},...ne,...ie],attributes:[{name:"a_vec2_vertex",location:0},{name:"a_vec2_texcoord",location:1}]},circleMarkerIdentify:{buildVertex:O("circle_marker_identify"),buildFragment:N("color_identify"),uniforms:[...lt,{name:"u_vec2_vpt_size",type:"2fv"},{name:"u_float_width",type:"1f"},...J],attributes:[{name:"a_vec3_flat_position",location:0},{name:"a_vec3_ecef_position",location:1},{name:"a_vec2_widen",location:2},{name:"a_vec4_identifier",location:3}]},heatmap:{buildVertex:O("heatmap"),buildFragment:N("heatmap"),uniforms:[$,Q,...ie,{name:"u_float_radius",type:"1f"},{name:"u_float_intensity",type:"1f"},{name:"u_float_tile_to_pixel_ratio",type:"1f"},...ne],attributes:[{name:"a_vec2_position",location:0},{name:"a_vec2_widen",location:1},{name:"a_float_weight",location:2}]},heatmapTexture:{buildVertex:O("heatmap_texture"),buildFragment:N("heatmap_texture"),uniforms:[Q,{name:"u_sr2d_texture",type:"1i"},{name:"u_sr2d_ramp_texture",type:"1i"},{name:"u_float_opacity",type:"1f"},...ie,...ne],attributes:[{name:"a_vec2_position",location:0}]},demMesh:{buildVertex:O("dem_mesh"),buildFragment:N("dem_mesh"),uniforms:[$,Q,{name:"u_mat4_flat_map_mvp",type:"mat4"},{name:"u_flat_tex",type:"1i"},{name:"u_hillshade_tex",type:"1i"},...ie,...J,...ne,...ve,...fe,...me],attributes:[{name:"a_vec2_position",location:0}]},demGround:{buildVertex:O("dem_ground"),buildFragment:N("dem_ground"),uniforms:[$,Q,...J],attributes:[{name:"a_vec2_position",location:0}]},demMesh2:{buildVertex:O("dem_mesh2"),buildFragment:N("dem_mesh2"),uniforms:[$,Q,{name:"u_mat4_flat_map_mvp",type:"mat4"},{name:"u_flat_tex",type:"1i"},{name:"u_hillshade_tex",type:"1i"},...ie,...J,...ne,...ve,...fe,...me,{name:"u_int_depth_test",type:"1i"},{name:"u_vec4_depth_test_color",type:"4fv"}],attributes:[{name:"a_vec2_vertex",location:0},{name:"a_float_height",location:1}]},demGround2:{buildVertex:O("dem_ground2"),buildFragment:N("dem_ground2"),uniforms:[$,Q,...J],attributes:[{name:"a_vec2_vertex",location:0},{name:"a_float_height",location:1}]},demElevationCopy:{buildVertex:O("dem_elevation_copy"),buildFragment:N("dem_elevation_copy"),uniforms:[$,{name:"u_sr2d_texture",type:"1i"},{name:"u_mat4_dem_corrected",type:"mat4"}],attributes:[{name:"a_vec2_vertex",location:0},{name:"a_vec2_texcoord",location:1}]},demElevation:{buildVertex:O("dem_elevation"),buildFragment:N("dem_elevation"),uniforms:[$],attributes:[{name:"a_vec2_vertex",location:0},{name:"a_float_height",location:1}]},demHillshade:{buildVertex:O("dem_normal"),buildFragment:N("dem_normal"),uniforms:[...J,...fe,...me,$,{name:"u_sr2d_texture",type:"1i"}],attributes:[{name:"a_vec2_vertex",location:0},{name:"a_vec2_texcoord",location:1}]},demFlatBottom:{buildVertex:O("dem_flat_bottom"),buildFragment:N("dem_flat_bottom"),uniforms:[$,...J],attributes:[{name:"a_vec2_vertex",location:0},{name:"a_vec2_centroid",location:1},{name:"a_vec2_extender",location:2}]},mesh:{buildVertex:O("mesh"),buildFragment:N("mesh"),uniforms:[$,Q,...ie,...J,...it,...fe,...me,...ne,...ve,{name:"u_float_opacity",type:"1f"},{name:"u_vec4_color",type:"4fv"},{name:"u_float_height_factor",type:"1f"},{name:"u_sdtr_distance",type:"1f"},{name:"u_mat4_gradient",type:"mat4"},{name:"u_int_identify",type:"1i"},{name:"u_sr2d_texture",type:"1i"},{name:"u_float_texture_opacity",type:"1f"},{name:"u_float_texture_params",type:"4fv"},{name:"u_float_sprite_texture_coords",type:"4fv"},{name:"u_int_is_textured",type:"1i"},{name:"u_float_texture_vertical_scale",type:"1f"}],attributes:[{name:"a_vec2_vertex",location:0},{name:"a_float_z",location:1},{name:"a_vec3_normal",location:2},{name:"a_float_gradient",location:3},{name:"a_vec2_dem_position",location:4},{name:"a_float_abs_z",location:5},{name:"a_vec4_identifier",location:6},{name:"a_float_visibility",location:7},{name:"a_float_is_pivot",location:8}]},inverse:{buildVertex:O("mesh"),buildFragment:N("inverse"),uniforms:[$,Q,...ie,...J,...it,...fe,...me,...ne,...ve,{name:"u_float_opacity",type:"1f"},{name:"u_vec4_color",type:"4fv"},{name:"u_float_height_factor",type:"1f"},{name:"u_mat4_gradient",type:"mat4"},{name:"u_int_identify",type:"1i"},{name:"u_float_texture_params",type:"4fv"},{name:"u_int_is_textured",type:"1i"},{name:"u_float_texture_vertical_scale",type:"1f"}],attributes:[{name:"a_vec2_vertex",location:0},{name:"a_float_z",location:1},{name:"a_vec3_normal",location:2},{name:"a_float_gradient",location:3},{name:"a_vec2_dem_position",location:4},{name:"a_float_abs_z",location:5},{name:"a_vec4_identifier",location:6},{name:"a_float_visibility",location:7},{name:"a_float_is_pivot",location:8}]},meshDepthClear:{buildVertex:O("mesh"),buildFragment:N("depth_clear"),uniforms:[$,Q,...ie,...J,...it,...fe,...me,...ne,...ve,{name:"u_float_opacity",type:"1f"},{name:"u_vec4_color",type:"4fv"},{name:"u_float_height_factor",type:"1f"},{name:"u_sdtr_distance",type:"1f"},{name:"u_mat4_gradient",type:"mat4"},{name:"u_int_identify",type:"1i"},{name:"u_float_texture_params",type:"4fv"},{name:"u_int_is_textured",type:"1i"},{name:"u_float_texture_vertical_scale",type:"1f"}],attributes:[{name:"a_vec2_vertex",location:0},{name:"a_float_z",location:1},{name:"a_vec3_normal",location:2},{name:"a_float_gradient",location:3},{name:"a_vec2_dem_position",location:4},{name:"a_float_abs_z",location:5},{name:"a_vec4_identifier",location:6},{name:"a_float_visibility",location:7},{name:"a_float_is_pivot",location:8}]},mapMesh:{buildVertex:O("map_mesh"),buildFragment:N("map_mesh"),uniforms:[$,Q,...ie,...J,...fe,...me,...it,...ne,...ve,{name:"u_float_tile_size",type:"1f"},{name:"u_sampler_map_tex",type:"1i"},{name:"u_vec2_tex_scale",type:"2f"},{name:"u_float_tex_shift_scale",type:"1f"},{name:"u_float_height_factor",type:"1f"},{name:"u_sdtr_distance",type:"1f"},{name:"u_int_identify",type:"1i"}],attributes:[{name:"a_vec2_vertex",location:0},{name:"a_float_z",location:1},{name:"a_vec2_extender",location:2},{name:"a_vec3_normal",location:3},{name:"a_float_gradient",location:4},{name:"a_vec2_dem_position",location:5},{name:"a_float_abs_z",location:6},{name:"a_float_is_pivot",location:7}]},sky:{buildVertex:O("sky"),buildFragment:N("sky"),uniforms:[Q,...ie,...ne],attributes:[{name:"a_vec2_vertex",location:0}]},taa:{buildVertex:O("posteffect"),buildFragment:N("taa"),uniforms:[{name:"u_texture",type:"1i"},{name:"u_float_mix_coef",type:"1f"}],attributes:[{name:"a_vec2_vertex",location:0}]},fxaa:{buildVertex:O("posteffect"),buildFragment:N("fxaa"),uniforms:[{name:"u_texture",type:"1i"},{name:"u_vec2_vpt_size",type:"2f"}],attributes:[{name:"a_vec2_vertex",location:0}]},copy:{buildVertex:O("posteffect"),buildFragment:N("copy"),uniforms:[{name:"u_texture",type:"1i"},{name:"u_depth",type:"1i"}],attributes:[{name:"a_vec2_vertex",location:0}]},buildingShadow:{buildVertex:O("building_shadow"),buildFragment:N("main_shadow"),uniforms:[...J,$,{name:"u_float_height_factor",type:"1f"},{name:"u_float_floor_elevation",type:"1f"}],attributes:[{name:"a_vec2_vertex",location:0},{name:"a_float_z",location:1},{name:"a_vec2_dem_position",location:2},{name:"a_float_visibility",location:3}]},meshShadow:{buildVertex:O("mesh_shadow"),buildFragment:N("main_shadow"),uniforms:[$,{name:"u_float_height_factor",type:"1f"},...J,...it],attributes:[{name:"a_vec2_vertex",location:0},{name:"a_float_z",location:1},{name:"a_vec2_dem_position",location:2},{name:"a_float_abs_z",location:3},{name:"a_float_visibility",location:4},{name:"a_float_is_pivot",location:5}]},globe:{buildVertex:O("globe"),buildFragment:N("globe"),uniforms:[...lt,{name:"u_sr2d_flatmap_texture",type:"1i"},{name:"u_vec4_extent",type:"4f"}],attributes:[{name:"a_vec3_ecef_position",location:0},{name:"a_vec3_flat_position",location:1},{name:"a_vec2_texture",location:2}]},globeHalo:{buildVertex:O("globe_halo"),buildFragment:N("globe_halo"),uniforms:[{name:"u_vec2_halo_viewport_size",type:"2f"},{name:"u_vec2_halo_viewport_center_shift",type:"2f"},{name:"u_vec4_halo_radius_stops",type:"4f"},{name:"u_vec4_halo_color",type:"4f"},{name:"u_float_halo_exp_factor",type:"1f"},{name:"u_vec4_default_background_color",type:"4f"}],attributes:[{name:"a_vec2_vertex",location:0}]},stars:{buildVertex:O("stars"),buildFragment:N("stars"),uniforms:[{name:"u_mat4_stars",type:"mat4"},{name:"u_float_pixelratio",type:"1f"},{name:"u_float_stars_intensity",type:"1f"}],attributes:[{name:"a_vec3_position",location:0},{name:"a_fade_opacity",location:1}]},globeHaloBackground:{buildVertex:O("globe_halo"),buildFragment:N("globe_halo_background"),uniforms:[{name:"u_vec2_halo_viewport_size",type:"2f"},{name:"u_vec2_halo_viewport_center_shift",type:"2f"},{name:"u_vec4_halo_radius_stops",type:"4f"},{name:"u_vec4_halo_color",type:"4f"},{name:"u_float_halo_exp_factor",type:"1f"},{name:"u_vec4_default_background_color",type:"4f"}],attributes:[{name:"a_vec2_vertex",location:0}]}}}function nv(s,e){if(window.requestIdleCallback)for(const t in e){const i=t;window.requestIdleCallback(()=>{if(s.isContextLost())return;const o=s.getShaderProgram(i);o.link(),setTimeout(()=>{window.requestIdleCallback(()=>{s.isContextLost()||o.locate()})},2e3)})}}class Br{constructor(e){this.params=e,this._uniformsMap={},this._buffer=null,this._data=null,this._gl=e.gl}bind(e){const t=this._gl,i=e.getUboBinding(this.params.blockName);i!==void 0&&(this._buffer||this.prepare(e),t.bindBufferBase(t.UNIFORM_BUFFER,i,this._buffer))}updateData(e,t){this._buffer||this.prepare(e);const i=this._data;for(const o in t){const a=t[o],r=this._uniformsMap[o]/4;if(e.uniforms[o]?.isNonFloatType()&&n.log(`[UBO Warn]: Currenty only float uniform types are supported. Uniform "${o}" has unsupported type`),n.isTypedArray(a)||n.isArrayOfNumbers(a))for(let c=0;c<a.length;++c)i[r+c]=a[c];else i[r]=a}}commitData(){if(!this._data)return;const e=this._gl;e.bindBuffer(e.UNIFORM_BUFFER,this._buffer),e.bufferData(e.UNIFORM_BUFFER,this._data,e.DYNAMIC_DRAW),e.bindBuffer(e.UNIFORM_BUFFER,null)}cleanup(){this._buffer&&this._gl.deleteBuffer(this._buffer)}prepare(e){const t=this._gl;this._buffer=t.createBuffer();const i=e.getUniformBlockSize(this.params.blockName);if(i===null){console.error("Failed to initialize UBO. Invalid UBO block is provided.");return}this._data=new Float32Array(new ArrayBuffer(i));const o=e.getUniformsIndicesOffsetsInBlock(this.params.uniformNames);if(!o){console.error("Failed to initialize UBO. Couldn't retrieve uniforms information.");return}this._uniformsMap=o}}const ov=["CommonSettings","LightSettings"],zr={CommonSettings:["u_float_rounding_factor","u_float_border_width_offset","u_vec2_scale_limits","u_vec2_depth_test_half_point_size","u_vec2_vpt_size","u_sky_color","u_fog_color","u_fog_distance","u_fog_limits","u_fog_horizon_blend","u_fog_horizon_level","u_fog_horizon_pad","u_cam_pos","u_shadow_map_params","u_shadow_bias","u_mat4_clip_to_shadow","u_mat4_view_transposed","u_mat4_proj_inverted","u_vec2_halo_viewport_size","u_vec2_halo_viewport_center_shift","u_vec4_halo_radius_stops","u_vec4_halo_color","u_float_halo_exp_factor","u_vec4_default_background_color","u_float_pixelratio","u_mat4_stars","u_float_stars_intensity"],LightSettings:["u_vec4_ambient_color","u_vec3_light_dir1_direction","u_vec4_light_dir1_color","u_vec3_light_dir2_direction","u_vec4_light_dir2_color"]};var ko=(s=>(s[s.CACHED=0]="CACHED",s[s.RENDER_UNDER_CACHE=1]="RENDER_UNDER_CACHE",s[s.RENDER_OVER_CACHE=2]="RENDER_OVER_CACHE",s))(ko||{});const _i=1/0,ln=-1/0,cn="renderCacheManager",sv=[0,0,0,0];class av{constructor(e,t){this.prevFrameAnimationLayerOverCacheIndex=void 0,this.prevFrameAnimationLayerUnderCacheIndex=void 0,this.cacheObjectsCount=0,this.animationLayersOverCacheMinIndex=_i,this.animationLayersUnderCacheMaxIndex=ln,this.state=e,this.modules=t,this.cacheFramebufferId=void 0,this.isReadyCache=!1,this.isLowZoom=this.state.zoom<6,this.cacheDisabled=this.state.disableRenderingCache,this.animationLayersUniqueIds=new Set,this.debugMode=!1,this.debugSkipRenderToCanvas=!1,this.cachedLayersMap=new Map}isLayerAnimated(e,t){const i=this.getUniqueRenderIndex(e,t);return!!this.animationLayersUniqueIds.has(i)}isLayerInCache(e,t){if(!this.isReadyCache)return!1;const i=this.cachedLayersMap.get(e);return!!i&&i.has(t)}frameEnd(){}initInDebugMode(){this.debugMode=!0}setDebugSkipRenderToCanvas(e){this.debugSkipRenderToCanvas=e,this.modules.renderer.addRerenderEvent()}frameStart(){this.cachedLayersMap=new Map,this.cacheObjectsCount=0,this.isLowZoom=this.state.zoom<6,this.isReadyCache=!1;let e=!1;this.cacheDisabled||(this.animationLayersUniqueIds.clear(),this.cacheFramebufferId===void 0&&(this.cacheFramebufferId=this.createCacheFramebuffer()),this.animationLayersOverCacheMinIndex=_i,this.animationLayersUnderCacheMaxIndex=ln,this.state.rerenderEvents.forEach(t=>{if(t.type==="layerAnimationTicker"){const i=this.getUniqueRenderIndex(t.styleId,t.layerId,t.underCache);this.animationLayersUniqueIds.add(i),t.underCache?this.animationLayersUnderCacheMaxIndex=Math.max(this.animationLayersUnderCacheMaxIndex,i):this.animationLayersOverCacheMinIndex=Math.min(this.animationLayersOverCacheMinIndex,i)}else e=!0}),this.isReadyCache=!0,(this.animationLayersOverCacheMinIndex!==this.prevFrameAnimationLayerOverCacheIndex||this.animationLayersUnderCacheMaxIndex!==this.prevFrameAnimationLayerUnderCacheIndex)&&(this.isReadyCache=!1),(this.state.needRerender||e)&&(this.prevFrameAnimationLayerOverCacheIndex=void 0,this.prevFrameAnimationLayerUnderCacheIndex=void 0,this.isReadyCache=!1))}tryToCacheObjects(e,t,i,o){if(this.modules.renderer.hasAnimatedFlatObjectInDemMode||this.cacheDisabled||this.cacheFramebufferId===void 0||this.animationLayersOverCacheMinIndex===_i&&this.animationLayersUnderCacheMaxIndex===ln||this.isLowZoom||this.animationLayersUnderCacheMaxIndex>=this.animationLayersOverCacheMinIndex||o&&this.modules.renderer.hasAnimatedFlatObjectInDemMode&&t.layerSettings.forceRenderUnderCacheInDemMode)return 1;const a=this.getUniqueRenderIndex(t.attributes.styleId,t.attributes.layerId);return a>=this.animationLayersOverCacheMinIndex?2:a<=this.animationLayersUnderCacheMaxIndex||(e[this.cacheFramebufferId]||(e[this.cacheFramebufferId]={framebuffer:this.modules.renderer.getFramebuffer(this.cacheFramebufferId),objects:[],tileObjects:new Set}),this.isReadyCache||(e[this.cacheFramebufferId].objects.push(t),e[this.cacheFramebufferId].tileObjects.add(i)),this.cacheObjectsCount++,this.markLayerInCache(t.attributes.styleId,t.attributes.layerId),o&&this.modules.renderer.hasAnimatedFlatObjectInDemMode&&t.layerSettings.forcePrerenderUnderCacheInDemMode)?1:0}hasReadyCache(){return this.isReadyCache&&!this.cacheDisabled}hasCachedObjects(){return!!this.cacheObjectsCount}render(){if(this.cacheDisabled)return!1;if(this.cacheFramebufferId===void 0||this.cacheObjectsCount===0||this.isLowZoom)return;this.prevFrameAnimationLayerOverCacheIndex=this.animationLayersOverCacheMinIndex,this.prevFrameAnimationLayerUnderCacheIndex=this.animationLayersUnderCacheMaxIndex;const e=this.modules.renderer.getFramebuffer(this.cacheFramebufferId)?.renderTarget;e&&!this.debugSkipRenderToCanvas&&(this.modules.renderer.storeGpuState(cn),this.debugMode?this.modules.renderer.applyGpuState(I_,void 0,!1):this.modules.renderer.applyGpuState(E_,void 0,!1),this.modules.postEffectsManager.copyRenderTargetToCanvas(e,!0,!1),this.modules.renderer.restoreGpuState(cn))}destroy(){this.cacheFramebufferId=void 0}markLayerInCache(e,t){let i=this.cachedLayersMap.get(e);i||(i=new Set,this.cachedLayersMap.set(e,i)),i.add(t)}getUniqueRenderIndex(e,t,i){const o=this.modules.styleManager.getStyleLayer(e,t);if(!o)return i?ln:_i;const a=this.modules.styleManager.getMaxLayersCount();return-e*a+o.renderIndex}createCacheFramebuffer(){if(!this.modules.renderer.fragDepthSupported()){console.warn("Render cache disabled - Fragment Depth write not supported"),this.cacheDisabled=!0;return}const e=this.modules.renderer.getViewportSize(),t=this.modules.renderer.webglContextState.MAX_TEXTURE_SIZE;if(Math.max(...e)>t){n.log(`Render cache disabled as viewport size ${e[0]}x${e[1]} exceeds hardware limits of ${t}x${t}`),this.cacheDisabled=!0;return}const o=g.NearestFilter,a=this.modules.renderer.getViewportSize(),r=new pe({size:[a[0],a[1]],magFilter:o,minFilter:o,wrapS:g.ClampToEdgeWrapping,wrapT:g.ClampToEdgeWrapping,depthTexture:!0,format:g.RgbaFormat});return this.modules.renderer.addFramebuffer({onResize:()=>{const l=this.modules.renderer.getViewportSize();r.setSize([l[0],l[1]])},renderTarget:r,onRenderStart:()=>{if(this.isReadyCache||this.cacheFramebufferId===void 0)return;const l=this.modules.renderer.getFramebuffer(this.cacheFramebufferId);l&&(this.modules.renderer.bindRenderTarget(l.renderTarget),this.modules.renderer.storeGpuState(cn),this.modules.renderer.applyGpuState(C_,void 0,!1),this.modules.renderer.clearWithColor(sv,!0),this.modules.renderer.bindRenderTarget(null),this.modules.renderer.restoreGpuState(cn))},onRenderEnd:()=>{},isCacheFramebuffer:!0,useDem:!0,renderIndex:_i})}}const rv=1.3,lv=2,Rr=n.reserveTextureIndex(),Fr=n.reserveTextureIndex(),Dr=n.reserveTextureIndex(),cv=16,dv=0,Mt=[1,1,1,1],Or=new Float64Array(16),Uo=n.reserveTextureIndex();let ui=(ct=class extends pd{constructor(e,t){const i=t.layout.canvas,o=e.webglVersion,a={antialias:!1,stencil:o!==2,failIfMajorPerformanceCaveat:!1,preserveDrawingBuffer:e.preserveDrawingBuffer};let r=null;if((!o||o===2)&&(r=i.getContext("webgl2",a),ct.webglVersion=2),(r===null||o===1)&&(r=i.getContext("webgl",a)||i.getContext("experimental-webgl",a),ct.webglVersion=1),r===null||!(r instanceof WebGLRenderingContext||r instanceof WebGL2RenderingContext))throw new Error("Failed to obtain WebGL context");super({gl:r,clearColor:n.getColorForShaders(e.defaultBackgroundColor)}),this.commonShaderDefines=n.EMPTY_SHADER_DEFINITIONS,this.hasAnimatedFlatObjectInDemMode=!1,this.destroyed=!1,this.framebuffers=[],this.globeRenderTargets=[],this.lastRenderedFramebuffers=[],this.mapMeshMvpMatrix=new Float64Array(16),this.drawTargetsFramebufferIds=new Map,this.ubosMap={},this.lastAppliedGpuState={state:null},this.applyGpuState=(c,d,_=!0)=>{const u=c(this.modules),h=this.lastAppliedGpuState,f=d?.gpuState;h.state===u&&h.layerState===d?.gpuState||(this.applyState(u,f),_&&(h.state=u,h.layerState=d?.gpuState))},this.trackContextLost=c=>{this.destroyed||(c.preventDefault(),this.modules.map.emit("error",{type:"webglcontextlost"}),this.modules.map.destroy())},this.debugRenderOnlyCache=!1,this.state=e,this.modules=t;const l=r.getExtension("WEBGL_debug_renderer_info");this.webglContextState={MAX_TEXTURE_SIZE:r.getParameter(r.MAX_TEXTURE_SIZE),MAX_VIEWPORT_DIMS:r.getParameter(r.MAX_VIEWPORT_DIMS),MAX_UNIFORM_BUFFER_BINDINGS:r instanceof WebGLRenderingContext?0:r.getParameter(r.MAX_UNIFORM_BUFFER_BINDINGS),MAX_COMBINED_UNIFORM_BLOCKS:r instanceof WebGLRenderingContext?0:r.getParameter(r.MAX_COMBINED_UNIFORM_BLOCKS),RENDERER:l?r.getParameter(l.UNMASKED_RENDERER_WEBGL):r.getParameter(r.RENDERER),VENDOR:l?r.getParameter(l.UNMASKED_VENDOR_WEBGL):r.getParameter(r.VENDOR)},this.identifyBuffer=new pe({minFilter:g.NearestFilter,magFilter:g.NearestFilter}),this.labelingTextureBuffer=new pe({size:this.getViewportSize(),magFilter:g.NearestFilter,minFilter:g.NearestFilter,depthTexture:!0}),this.spriteLabelingTextureBuffer=new pe({size:this.getViewportSize(),magFilter:g.NearestFilter,minFilter:g.NearestFilter,depthTexture:!1}),this.shaderProgramOptions=iv(),this.shaderPrograms={},t.map.once("idle",()=>nv(this,this.shaderProgramOptions)),this.symbolSettingsList=hf(),this.addExtension("OES_vertex_array_object").addExtension("OES_element_index_uint").addExtension("OES_standard_derivatives").addExtension("OES_texture_float").addExtension("OES_texture_float_linear").addExtension("ANGLE_instanced_arrays").addExtension("WEBGL_depth_texture").addExtension("EXT_frag_depth").addExtension("EXT_blend_minmax"),ct.webglVersion===2&&this.addExtension("EXT_color_buffer_float"),this.setPixelRatio(window.devicePixelRatio).setSize(t.layout.mapContainer.clientWidth,t.layout.mapContainer.clientHeight),e.collectStats&&(this.timers=new ff(this._gl)),t.layout.canvas.addEventListener("webglcontextlost",this.trackContextLost)}get isDestroyed(){return this.destroyed}setDebugRenderOnlyCache(e){this.debugRenderOnlyCache=e,this.modules.renderer.addRerenderEvent()}getViewportSize(e=1){const t=this.getPixelRatio();return this.state.size.map(i=>Math.floor(i*t/e))}setClearColor(e){const t=n.getColorForShaders(e);if(!n.deepEqual(t,this.clearColor))return this.clearColor=t,this.addRerenderEvent(),this}setSize(e,t){return this.modules.layout.setCanvasSize(e,t),this.updateFrameBuffersSize(),this}updateFrameBuffersSize(){this.framebuffers.forEach(i=>{i&&i.onResize()});const e=this.getPixelRatio(),t=this.state.size.map(i=>Math.ceil(i*e));this.modules.postEffectsManager?.invalidateSize(),this.identifyBuffer.setSize(t.map(i=>Math.ceil(i*n.identify.pixelDensity))),this.labelingTextureBuffer.setSize(t),this.spriteLabelingTextureBuffer.setSize(t)}clear(e=!0){return this.clearWithColor(this.clearColor,e),this}addRerenderEvent(e){this.state.rerenderEvents.push(e||{type:"coreNeedRerender"})}isNeedRerender(e=!1){return this.state.needRerender||(e?this.state.rerenderEvents.filter(t=>t.type!=="layerAnimationTicker"):this.state.rerenderEvents).length>0}clearWithColor(e,t=!0,i=1){const o=this._gl,a=t===!0?o.COLOR_BUFFER_BIT|o.DEPTH_BUFFER_BIT:o.COLOR_BUFFER_BIT,r=t?aa:M_;this.applyGpuState(r),o.clearDepth(i),o.clearColor(e[0],e[1],e[2],e[3]),o.clear(a)}getGlobeRenderTarget(e){if(e=n.clamp(Math.trunc(e),1,4),!this.globeRenderTargets[e]){const t=this._gl,i=n.clamp(self.devicePixelRatio,1,2),o=Math.min(this.webglContextState.MAX_TEXTURE_SIZE,n.GLOBE_TEXTURE_SIZE*e*i),a=new pe({size:[o,o],magFilter:g.LinearFilter,minFilter:g.LinearFilter,wrapS:g.ClampToEdgeWrapping,wrapT:g.ClampToEdgeWrapping});this.addFramebuffer({clearColor:[0,0,0,0],renderTarget:a,renderIndex:0,onResize:()=>{},onRenderStart:()=>{t.activeTexture(t.TEXTURE0+Uo),t.bindTexture(t.TEXTURE_2D,null)}}),this.globeRenderTargets[e]=a}return this.globeRenderTargets[e]}renderTileObjects(e){this.drawTargetsFramebufferIds.forEach(a=>{const r=this.getFramebuffer(a);r&&(r.requestedInCurrentFrame=!1)}),this.state.collectStats&&this.timers&&this.timers.addTimer();let t=!1,i=!1;const o=this.getRenderObjectsByGroups(e,!1);if(this.lastRenderedFramebuffers.forEach(a=>{o.groups.some(r=>r.framebuffer===a)||this.clearFramebuffer(a)}),this.lastRenderedFramebuffers=[],o.groups.forEach(a=>{const{objects:r,tileObjects:l,isUnderCache:c}=a;let{framebuffer:d}=a;const _=this.modules.map.state.demMode&&(d===void 0||d.useDem===!0),u=!d,h=d?.isCacheFramebuffer&&!this.modules.renderCacheManager.hasReadyCache(),f=!d&&this.modules.postEffectsManager.hasActiveEffects();f&&(d=this.modules.postEffectsManager.mainFrameBufferWrapper);const m=st(this.state,this.modules,o.tiers,d?.renderTarget,_);if(d)d.onRenderStart?.(),this.lastRenderedFramebuffers.push(d),d.renderTarget.bind(this._gl),this._gl.viewport(0,0,d.renderTarget.options.size[0],d.renderTarget.options.size[1]),d.clearColor&&(!f||f&&c)&&this.clearWithColor(d.clearColor,!!d.clearDepth);else{const{size:p,viewport:v}=this.state,y=window.devicePixelRatio;this._gl.bindFramebuffer(this._gl.FRAMEBUFFER,null),this._gl.viewport(v.left*y,v.bottom*y,p[0]*y,p[1]*y),u&&c&&this.clear(!0)}if(u||h){u&&c&&this.modules.environmentManager.renderSky();const p=_&&u&&(!this.modules.renderCacheManager.hasCachedObjects()||this.hasAnimatedFlatObjectInDemMode)&&!t,v=_&&h&&this.modules.renderCacheManager.hasCachedObjects()&&!this.hasAnimatedFlatObjectInDemMode&&!i;o.flatObjectsGroup&&(p||v)&&(v&&(i=!0),p&&(t=!0),this.renderDemMesh(m,o.flatObjectsGroup,!1,d))}if(r.length){const p=d?.getViewProjectionMatrix?.()??this.modules.camera.viewProjectionMatrix,v=_?this.modules.demManager.demTextureMatrix:void 0;l.forEach(y=>{y.updateMvpMatrix(p,v)}),ht(this.state,this.modules,r,m)}u&&c&&this.modules.renderCacheManager.render(),d?.renderTarget.unbind(this._gl),d?.onRenderEnd?.(),f&&!c&&this.modules.postEffectsManager.render(),this.debugRenderOnlyCache&&u&&!c&&(this.clearWithColor([1,0,1,1],!0),this.modules.renderCacheManager.render())}),this.state.collectStats&&this.timers){this.timers.stopTimer();const a=this.timers.tryToGetFirstTimerValue();a&&this.modules.map.emit("gpuRenderTime",a)}for(const[a,r]of this.drawTargetsFramebufferIds){const l=this.getFramebuffer(r);(!l||!l.requestedInCurrentFrame)&&(this.drawTargetsFramebufferIds.delete(a),this.removeFramebuffer(r))}return this}renderElevation(e){if(!this.state.demMode)return;const t=[];if(e.forEach(l=>l.demChildren.forEach(c=>t.push(c))),!t.length)return;const i=this.modules.demManager.getDemFramebufferId();if(i===n.INVALID_FRAMEBUFFER_ID)return;const o=this.getFramebuffer(i);if(!o)return;const a=st(this.state,this.modules,void 0,o.renderTarget);o.onRenderStart?.(),o.renderTarget.bind(this._gl),this._gl.viewport(0,0,o.renderTarget.options.size[0],o.renderTarget.options.size[1]),o.clearColor&&this.clearWithColor(o.clearColor,!!o.clearDepth);const r=o.getViewProjectionMatrix?.()??this.modules.camera.viewProjectionMatrix;e.forEach(l=>{l.updateMvpMatrix(r)}),ht(this.state,this.modules,t,a),o.renderTarget.unbind(this._gl),o.onRenderEnd?.()}renderGround(e){if(!this.state.demMode)return;const t=[];if(e.forEach(l=>l.demGroundChildren.forEach(c=>t.push(c))),!t.length)return;const i=this.modules.demManager.getGroundFramebufferId();if(i===n.INVALID_FRAMEBUFFER_ID)return;const o=this.getFramebuffer(i);if(!o)return;const a=st(this.state,this.modules,void 0,o.renderTarget,!0,!0);o.onRenderStart?.(),o.renderTarget.bind(this._gl),this._gl.viewport(0,0,o.renderTarget.options.size[0],o.renderTarget.options.size[1]),o.clearColor&&this.clearWithColor(o.clearColor,!!o.clearDepth);const r=o.getViewProjectionMatrix?.()??this.modules.camera.viewProjectionMatrix;e.forEach(l=>{l.updateMvpMatrix(r,this.modules.demManager.demTextureMatrix)}),ht(this.state,this.modules,t,a),o.renderTarget.unbind(this._gl),o.onRenderEnd?.()}renderSpriteLabelingTexture(e){if(this.modules.renderCacheManager.hasReadyCache())return;const t=this._gl,i=[],o=st(this.state,this.modules,void 0,this.spriteLabelingTextureBuffer,this.modules.map.state.demMode),a=e.filter(r=>r.labelTestChildren[0]);a.forEach(r=>{r.updateMvpMatrix(this.modules.camera.viewProjectionMatrix,this.modules.demManager.demTextureMatrix)}),a.forEach(r=>{r.labelTestChildren.forEach(l=>{l.attributes.labelTest===!0&&i.push(l)})}),this.spriteLabelingTextureBuffer.bind(t),this.clearWithColor([1,1,1,1]),t.viewport(0,0,this.spriteLabelingTextureBuffer.options.size[0],this.spriteLabelingTextureBuffer.options.size[1]),ht(this.state,this.modules,i,o),this.spriteLabelingTextureBuffer.unbind(t)}renderLabelingTexture(e){if(this.modules.renderCacheManager.hasReadyCache()||(this.state.isLabelingDepthTestDisabled=!0,this.state.styleZoom<cv||this.state.pitch===dv||this.state.disableHidingPois))return;const t=this._gl,i=[],o=st(this.state,this.modules,void 0,this.labelingTextureBuffer,this.modules.map.state.demMode),a=e.filter(r=>r.depthTestChildren[0]);a.forEach(r=>{r.updateMvpMatrix(this.modules.camera.viewProjectionMatrix,this.modules.demManager.demTextureMatrix)}),a.forEach(r=>{r.depthTestChildren.forEach(l=>{const c=this.modules.styleManager.getStyleLayer(l.attributes.styleId,l.attributes.layerId);(c&&c.type!=="gltfModel"||!c?.style.preventObjectsHiding)&&i.push(l)})}),this.state.isLabelingDepthTestDisabled=!1,this.labelingTextureBuffer.bind(t),this.clearWithColor(n.LABELING_TEXTURE_BACKGROUND_COLOR),t.viewport(0,0,this.labelingTextureBuffer.options.size[0],this.labelingTextureBuffer.options.size[1]),ht(this.state,this.modules,i,o),this.labelingTextureBuffer.unbind(t)}renderIdentify(e){const t=this._gl,i=this.getRenderObjectsByGroups(e,!0);i.groups.forEach(({objects:o,tileObjects:a,framebuffer:r,isUnderCache:l})=>{const c=this.modules.map.state.demMode&&(r===void 0||r.useDem===!0),d=r?r.renderTarget:this.identifyBuffer,_=st(this.state,this.modules,i.tiers,d,c);if(d.bind(t),(d!==this.identifyBuffer||l)&&this.clearIdentify(),c&&i.flatObjectsGroup&&this.renderDemMesh(_,i.flatObjectsGroup,!0),d.bind(t),t.viewport(0,0,d.options.size[0],d.options.size[1]),o.length){const u=r?.getViewProjectionMatrix?.()??this.modules.camera.viewProjectionMatrix,h=c?this.modules.demManager.demTextureMatrix:void 0;a.forEach(f=>{f.updateMvpMatrix(u,h)}),ht(this.state,this.modules,o,_)}d.unbind(t),r?.renderTarget.unbind(this._gl),r?.onRenderEnd?.()})}waitForGpuCommandsToFinish(){const e=new Float32Array(4);this.readPixelsFloat(0,0,1,1,e)}readPixelsFloat(e,t,i,o,a){const r=this._gl;r.readPixels(e,t,i,o,r.RGBA,r.FLOAT,a)}getRenderingContext(){return this._gl}getShaderProgram(e,t){let i=this.shaderPrograms[e];i||(i={},this.shaderPrograms[e]=i);let o=i[this.commonShaderDefines.hash];o||(o={},i[this.commonShaderDefines.hash]=o);const a=t?.hash??"",r=t?.defines??[];let l=o[a];return l||(l=new gd(this._gl,this.shaderProgramOptions[e],n.Shader.createShaderDefinitions([...this.commonShaderDefines.defines,...r]),ov),o[a]=l),l}enableShaderProgram(e){e.enable()}bindShaderProgram(e,t,i){e.bind(t,i)}destroy(){if(this.destroyed)return;this.lastRenderedFramebuffers=[],this.framebuffers.forEach(t=>{t?.renderTarget.remove()}),this.modules.layout.canvas.removeEventListener("webglcontextlost",this.trackContextLost);const e=this._gl.getExtension("WEBGL_lose_context");e&&e.loseContext(),this.modules.layout.destroy(),this.mapMeshFramebufferId=void 0,this.mapMeshIdFramebufferId=void 0,this.destroyed=!0}addFramebuffer(e){return this.framebuffers.push(e),this.framebuffers.length-1}getFramebuffer(e){if(e!==n.INVALID_FRAMEBUFFER_ID)return this.framebuffers[e]}removeFramebuffer(e){this.framebuffers[e]?.renderTarget.remove(),this.framebuffers[e]=void 0}setRenderTarget(e){this.currentTarget=e;const t=this._gl;if(e)e.bind(t),t.viewport(0,0,e.options.size[0],e.options.size[1]);else{t.bindFramebuffer(t.FRAMEBUFFER,null);const{size:i,viewport:o}=this.state,a=window.devicePixelRatio;t.viewport(o.left*a,o.bottom*a,i[0]*a,i[1]*a)}}getRenderTarget(){return this.currentTarget}getDrawTargetFramebuffer(e){const t=this.drawTargetsFramebufferIds.get(e);if(t!==void 0)return this.getFramebuffer(t)}doesDrawTargetFramebufferExist(e){const t=this.drawTargetsFramebufferIds.get(e);if(t!==void 0){const i=this.getFramebuffer(t);return i&&i.requestedInCurrentFrame}return!1}getDrawTargetFramebufferId(e){let t=this.drawTargetsFramebufferIds.get(e);if(t!==void 0){const c=this.getFramebuffer(t);return c&&(c.requestedInCurrentFrame=!0),t}const i=this.modules.map.state.demMode,o=this.modules.renderer.getPixelRatio(),a=this.modules.map.state.size,r=new pe({size:i?[Math.trunc(a[0]*Te[0]*o),Math.trunc(a[1]*Te[1]*o)]:this.getViewportSize(),magFilter:g.LinearFilter,minFilter:g.LinearFilter,depthTexture:!0,wrapS:g.ClampToEdgeWrapping,wrapT:g.ClampToEdgeWrapping,generateMipmaps:!1,format:ct.webglVersion===2?g.RedFormat:g.RgbFormat}),l={renderTarget:r,clearColor:[0,0,0,0],clearDepth:!0,onResize:()=>{const c=this.modules.map.state.demMode,d=this.modules.map.state.size;r.setSize(c?[Math.trunc(d[0]*Te[0]*o),Math.trunc(d[1]*Te[1]*o)]:this.getViewportSize()),this.modules.renderer.bindRenderTarget(r),this.modules.renderer.bindRenderTarget(null)},renderIndex:-1/0,useDem:!1,requestedInCurrentFrame:!0};return t=this.modules.renderer.addFramebuffer(l),this.drawTargetsFramebufferIds.set(e,t),t}renderDemMesh(e,t,i=!1,o){const{framebuffer:a,tiles:r}=t;if(!a)return;let l=this.modules.demManager.getFlatMapTextures();if(i&&(l=l.filter(S=>S.detailLevel===0)),!l.length)return;const c=this.modules.demManager.getMeshTiles();if(!c.length)return;const d=c[0],u=(i?d.identifyChildren:d.children).filter(({sink:S})=>S==="mesh"||S==="mesh2")[0];if(!u)return;const h=this.state.handyStyleId,f=this.modules.styleManager.getStyleLayer(h,n.DEM_STYLE_LAYER_ID);if(!f||Fo(u))return;const{size:m,viewport:p}=this.state,v=window.devicePixelRatio,{commonBinder:y,programBinder:b,layerBinder:x,programName:T}=u.layerSettings,w=this.getShaderProgram(T),M=[];r.forEach((S,I)=>{M.push({objects:S,tile:I})});const z=e.copy(a.renderTarget,!1,!0);l.forEach(S=>{const R=M.filter(H=>Nr(S.viewport,H.tile.bounds.values())).reduce((H,K)=>(K.tile.updateMvpMatrix(S.mvpMatrix,this.modules.demManager.demTextureMatrix),H.concat(K.objects)),[]),C=[],j=new Map;if(R.forEach(({obj:H,framebufferId:K})=>{if(K===void 0)C.push(H);else{const Y=j.get(K);Y?Y.push(H):j.set(K,[H])}}),j.forEach((H,K)=>{const Y=this.getFramebuffer(K);Y&&(Y.onRenderStart?.(),Y.renderTarget.bind(this._gl),this._gl.viewport(0,0,Y.renderTarget.options.size[0],Y.renderTarget.options.size[1]),Y.clearColor&&this.clearWithColor(Y.clearColor,!1),ht(this.state,this.modules,H,z),Y.renderTarget.unbind(this._gl),Y.onRenderEnd?.())}),a.onRenderStart?.(),a.renderTarget.bind(this._gl),this._gl.viewport(0,0,a.renderTarget.options.size[0],a.renderTarget.options.size[1]),a.clearColor&&this.clearWithColor(a.clearColor,!1),ht(this.state,this.modules,C,z),a.renderTarget.unbind(this._gl),a.onRenderEnd?.(),i){this.identifyBuffer.bind(this._gl);const H=this.identifyBuffer.options.size;this._gl.viewport(0,0,H[0],H[1])}else o?(this._gl.viewport(0,0,o.renderTarget.options.size[0],o.renderTarget.options.size[1]),o.renderTarget.bind(this._gl)):this._gl.viewport(p.left*v,p.bottom*v,m[0]*v,m[1]*v);this.enableShaderProgram(w),this._gl instanceof WebGLRenderingContext&&y?.(w,this.state,this.modules),b?.(w,this.state,this.modules,!0),x?.(w,this.state,this.modules,f),e.useState(u,f),c.forEach(H=>{if(H instanceof ea&&H.needSync&&H.syncReplicas(this.state),Nr(S.viewport,H.bounds.values())){H.updateMvpMatrix(this.modules.camera.viewProjectionMatrix,this.modules.demManager.demTextureMatrix,S.texMatrix);const K=(i?H.identifyChildren:H.children).filter(({sink:Y})=>Y==="mesh"||Y==="mesh2");so(K,this.state,this.modules),e.drawSymbol(K,f,this.state,this.modules)}}),i&&this.identifyBuffer.unbind(this._gl)})}getMapMeshFramebufferId(){return this.mapMeshFramebufferId===void 0&&(this.mapMeshFramebufferId=this.createMapMeshFramebuffer()),this.mapMeshFramebufferId}getMapMeshIdFramebufferId(){return this.mapMeshIdFramebufferId===void 0&&(this.mapMeshIdFramebufferId=this.createMapMeshFramebuffer(!0)),this.mapMeshIdFramebufferId}prerenderUpdate(){const e=this.rebuildExternalShaderDefinitions();this.updateUbos(e)}getRenderObjectsByGroups(e,t){const{demManager:i,map:o}=this.modules,{demMode:a}=o.state,r={},l={framebuffer:void 0,objects:[],tileObjects:new Set},c={framebuffer:void 0,objects:[],tileObjects:new Set,isUnderCache:!0},d={};let _;if(a){const h=t?i.getIdentifyFlatFramebufferId():i.getFlatFramebufferId(),f=this.getFramebuffer(h);f&&(_={framebuffer:f,tiles:new Map})}this.hasAnimatedFlatObjectInDemMode=!t&&a&&e.some(h=>h.children.some(f=>!f.layerSettings.is3dMapAware&&this.modules.renderCacheManager.isLayerAnimated(f.attributes.styleId,f.attributes.layerId))),e.forEach(h=>{(t?h.identifyChildren:h.children).forEach(m=>{if(m.sink==="mesh2")return;const{ids:p,defaultId:v,isDrawTarget:y}=this.modules.styleManager.getFramebufferId(m.attributes.styleId,m.attributes.layerId),b=p?p[m.sink]:v;if(b===n.INVALID_FRAMEBUFFER_ID)return;if(b===void 0||a&&y){const T=m.attributes.tiers;if(this.state.immersiveLevel.tiers&&T){let w=!1;if(T.forEach(M=>{if(!M){w=!0;return}d[M]||(d[M]={objects:[],tileObjects:new Set}),d[M].objects.push(m),d[M].tileObjects.add(h)}),!w)return}if(a&&!m.layerSettings.is3dMapAware)_?.tiles.has(h)?_?.tiles.get(h)?.push({obj:m,framebufferId:b}):_?.tiles.set(h,[{obj:m,framebufferId:b}]),this.hasAnimatedFlatObjectInDemMode||this.modules.renderCacheManager.markLayerInCache(m.attributes.styleId,m.attributes.layerId);else if(t)c.objects.push(m),c.tileObjects.add(h);else{const w=this.modules.renderCacheManager.tryToCacheObjects(r,m,h,a);if(w===ko.CACHED)return;w===ko.RENDER_OVER_CACHE?(l.objects.push(m),l.tileObjects.add(h)):(c.objects.push(m),c.tileObjects.add(h))}return}r[b]||(r[b]={framebuffer:this.getFramebuffer(b),objects:[],tileObjects:new Set}),r[b].objects.push(m),r[b].tileObjects.add(h)})});const u=Object.values(r).filter(h=>!!h.framebuffer);return u.sort((h,f)=>{const m=h.framebuffer?.renderIndex??0,p=f.framebuffer?.renderIndex??0;return m-p}),u.push(c),t||(u.findIndex(f=>f.framebuffer?.isCacheFramebuffer)>=0?l.objects.push(...this.modules.styleManager.getCustomSceneObjects()):c.objects.push(...this.modules.styleManager.getCustomSceneObjects())),u.push(l),{flatObjectsGroup:_,groups:u,tiers:d}}getUbo(e){return this.ubosMap[e]}getMemoryFootprint(){const e={framebuffers:this.framebuffers.filter(t=>t!==void 0).map(t=>t.renderTarget.memSizeGPU()),identifyBuffer:this.identifyBuffer.memSizeGPU(),labelingTextureBuffer:this.labelingTextureBuffer.memSizeGPU()};return{gpu:{...e,"--sum":n.getTotalMemory(e)}}}bindRenderTarget(e){const t=this._gl;e?e.bind(t):t.bindFramebuffer(t.FRAMEBUFFER,null)}isUboSupported(){return!(this._gl instanceof WebGLRenderingContext)}isWebgl2Context(){return!(this._gl instanceof WebGLRenderingContext)}fragDepthSupported(){return this.isWebgl2Context()||!!this.modules.renderer.webGlExtensions.EXT_frag_depth}updateUbos(e=!1){const t=this._gl;if(t instanceof WebGLRenderingContext)return;e&&this.cleanupUbos(t);const i=this.getShaderProgram("diffuse");i.link(),i.locate();let o=this.ubosMap.CommonSettings;(!o||e)&&(o=new Br({gl:t,blockName:"CommonSettings",uniformNames:zr.CommonSettings}),this.ubosMap.CommonSettings=o,o.bind(i)),Md(i,this.state,this.modules,o),o.commitData();const a=this.modules.map.state,l=(!isNaN(a.handyStyleId)&&this.modules.styleManager.getStyle(a.handyStyleId)||void 0)?.light.lightingModesResolved??n.DEFAULT_LIGHTING_MODES;for(const c in l){let d=this.ubosMap[c];(!d||e)&&(d=new Br({gl:t,blockName:"LightSettings",uniformNames:zr.LightSettings}));const _=l[c];d.updateData(i,{u_vec3_light_dir1_direction:_.dir1Direction,u_vec4_light_dir1_color:_.dir1ColorIntensity,u_vec3_light_dir2_direction:_.dir2Direction,u_vec4_light_dir2_color:_.dir2ColorIntensity,u_vec4_ambient_color:_.ambientColorIntensity}),this.ubosMap[c]=d,d.commitData()}}cleanupUbos(e){for(const t in this.ubosMap)this.ubosMap[t].cleanup();this.ubosMap={};for(let t=0;t<this.webglContextState.MAX_UNIFORM_BUFFER_BINDINGS;t++)e.bindBufferBase(e.UNIFORM_BUFFER,t,null)}rebuildExternalShaderDefinitions(){const e=this.prepareExternalShaderDefinitions();return this.commonShaderDefines.hash!==e.hash?(this.commonShaderDefines=e,!0):!1}clearIdentify(){const e=this._gl;e.depthMask(!0),e.clearColor(Mt[0],Mt[1],Mt[2],Mt[3]),e.clearDepth(1),e.clearStencil(0),e.clear(e.COLOR_BUFFER_BIT|e.DEPTH_BUFFER_BIT|e.STENCIL_BUFFER_BIT)}clearFramebuffer(e){e.clearColor&&(e.renderTarget.bind(this._gl),this._gl.viewport(0,0,e.renderTarget.options.size[0],e.renderTarget.options.size[1]),this.clearWithColor(e.clearColor,!1),e.renderTarget.unbind(this._gl))}createMapMeshFramebuffer(e){const t=this.getRenderingContext(),i=e?g.NearestFilter:g.LinearFilter,{scale:o,size:a}=this.calculateMapMeshParams(e),r=new pe({size:a,magFilter:i,minFilter:i,wrapS:g.ClampToEdgeWrapping,wrapT:g.ClampToEdgeWrapping}),l={getViewProjectionMatrix:()=>{const c=1-Math.cos(this.modules.map.state.pitch),d=l.scale??this.calculateMapMeshParams(e).scale;return n.fromTranslationScale(Or,[0,c/d[1],0],[1/d[0],1/d[1],1]),n.multiply(this.mapMeshMvpMatrix,Or,this.modules.camera.viewProjectionMatrix),this.mapMeshMvpMatrix},onResize:()=>{const c=this.calculateMapMeshParams(e);l.scale=c.scale,r.setSize(c.size),r.bind(t),r.unbind(t)},renderTarget:r,scale:o};return this.addFramebuffer(l)}calculateMapMeshParams(e){const t=e?n.identify.pixelDensity:1,i=window.devicePixelRatio,o=n.scale$2([],this.modules.map.state.size,i),a=Math.min(rv,Math.min(this.webglContextState.MAX_TEXTURE_SIZE,this.webglContextState.MAX_VIEWPORT_DIMS[0])/o[0]),r=Math.min(lv,Math.min(this.webglContextState.MAX_TEXTURE_SIZE,this.webglContextState.MAX_VIEWPORT_DIMS[1])/o[1]),l=[Math.trunc(o[0]*t*a),Math.trunc(o[1]*t*r)];return{scale:[a,r],size:l}}prepareExternalShaderDefinitions(){const e=[];return this.webGlExtensions.EXT_frag_depth&&e.push({type:"HAS_FRAG_DEPTH_EXT"}),this.modules.environmentManager.isFogEnabled()&&e.push({type:qu}),this.modules.environmentManager.isSkyEnabled()&&e.push({type:Yu}),this.modules.shadowManager.texture&&e.push({type:sh}),this.state.aaMode===Ot.FXAA?e.push({type:Dt.FXAA}):this.state.aaMode===Ot.TAA&&e.push({type:Dt.TAA}),Ss(this._gl)&&e.push({type:oh}),this.webglContextState.MAX_UNIFORM_BUFFER_BINDINGS>0&&e.push({type:ah}),this.state.isDeprecatedSystem?e.push({type:dh}):(e.push({type:rh}),e.push({type:lh})),this.webglContextState.RENDERER.toLowerCase().includes("mali")&&this.webglContextState.VENDOR.toLowerCase().includes("arm")&&e.push({type:ch}),n.Shader.createShaderDefinitions(e)}},ct.webglVersion=NaN,ct);function Nr(s,e){for(const t of e)if(n.tetragonIntersectsBounds(s,t))return!0;return!1}const kr='(function(){"use strict";var i=(e=>(e[e.Test=0]="Test",e))(i||{}),c=(e=>(e[e.Vertex=0]="Vertex",e[e.Fragment=1]="Fragment",e))(c||{});function g(e,n,t){const s=JSON.stringify(t??{});return`${e}:${n}:${s}`}var P=`/**\n * Test vertex shader\n * Простой треугольник для проверки работы WebGPU pipeline\n */\n\n@vertex\nfn main(@builtin(vertex_index) vertexIndex: u32) -> @builtin(position) vec4f {\n    var positions = array<vec2f, 3>(\n        vec2f(0.0, 0.5),\n        vec2f(-0.5, -0.5),\n        vec2f(0.5, -0.5)\n    );\n    return vec4f(positions[vertexIndex], 0.0, 1.0);\n}\n`,b=`/**\n * Test fragment shader\n * Красный цвет для проверки работы WebGPU pipeline\n */\n\n@fragment\nfn main() -> @location(0) vec4f {\n    return vec4f(1.0, 0.0, 0.0, 1.0); // Red color\n}\n`;const m=new WeakMap;function p(e){let n=m.get(e);return n||(n=new Map,m.set(e,n)),n}const F={[i.Test]:{[c.Vertex]:P,[c.Fragment]:b}};function h(e,n,t){const s=F[e];if(!s)throw new Error(`No shaders registered for material type: ${e}`);const o=s[n];if(!o)throw new Error(`No ${n} shader for material type: ${e}`);return o}function v(e,n,t){return e.createShaderModule({label:t,code:n})}function M(e,n,t={}){const s=p(e),o=g(n,c.Vertex,t);let r=s.get(o);if(!r){const f=h(n,c.Vertex);r=v(e,f,`${n} vertex shader`),s.set(o,r)}return r}function V(e,n,t={}){const s=p(e),o=g(n,c.Fragment,t);let r=s.get(o);if(!r){const f=h(n,c.Fragment);r=v(e,f,`${n} fragment shader`),s.set(o,r)}return r}function $(e,n){const t={id:e,success:!0,result:n};self.postMessage(t)}function w(e,n){const t={id:e,success:!1,error:n};self.postMessage(t)}let a=null,u=null,l=null,d;async function E(e){const n=await navigator.gpu.requestAdapter({powerPreference:"high-performance"});if(!n)throw new Error("WebGPU adapter not found");a=await n.requestDevice(),u=e.getContext("webgpu"),d=navigator.gpu.getPreferredCanvasFormat(),u.configure({device:a,format:d,alphaMode:"premultiplied"});const t=M(a,i.Test,{}),s=V(a,i.Test,{});l=a.createRenderPipeline({label:"Triangle pipeline",layout:"auto",vertex:{module:t,entryPoint:"main"},fragment:{module:s,entryPoint:"main",targets:[{format:d}]}}),y()}function x(){if(!a||!u||!l)return;const e=a.createCommandEncoder(),n=u.getCurrentTexture().createView(),t=e.beginRenderPass({colorAttachments:[{view:n,clearValue:{r:.1,g:.1,b:.1,a:1},loadOp:"clear",storeOp:"store"}]});t.setPipeline(l),t.draw(3),t.end(),a.queue.submit([e.finish()])}function y(){x(),requestAnimationFrame(y)}function T(e,n,t){x()}const W={init:async e=>{await E(e.canvas)},resize:async e=>{T(e.width,e.height,e.dpr)},start:async()=>{console.log("start")},pause:async()=>{console.log("pause")},destroy:async()=>{console.log("destroy")}};self.addEventListener("message",async e=>{const{id:n,type:t,payload:s}=e.data,o=W[t];if(!o){w(n,`Unknown command type: ${t}`);return}try{const r=await o(s);$(n,r)}catch(r){w(n,r instanceof Error?r.message:String(r))}})})();\n',Ur=typeof self<"u"&&self.Blob&&new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);",kr],{type:"text/javascript;charset=utf-8"});function _v(s){let e;try{if(e=Ur&&(self.URL||self.webkitURL).createObjectURL(Ur),!e)throw"";const t=new Worker(e,{name:s?.name});return t.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(e)}),t}catch{return new Worker("data:text/javascript;charset=utf-8,"+encodeURIComponent(kr),{name:s?.name})}}class uv{constructor(e,t){this.nextMessageId=0,this.pendingCalls=new Map;const i=t.layout.canvas.parentElement;let o;function a(){const d=document.createElement("canvas");return d.style.position="absolute",d.style.bottom="100px",d.style.left="0",d.style.width="50%",d.style.height="50%",d.style.pointerEvents="none",d}if(e.webgpu)o=a(),i.appendChild(o),this.worker=new _v({name:"RenderWebGPU"});else return;this.worker.onmessage=d=>{this.handleWorkerMessage(d.data)},this.worker.onerror=d=>{console.error("Worker error:",d);for(const[_,u]of this.pendingCalls)u.reject(new Error("Worker crashed")),this.pendingCalls.delete(_)};const r=i.getBoundingClientRect(),l=window.devicePixelRatio||1;o.width=r.width*l,o.height=r.height*l;const c=o.transferControlToOffscreen();this.sendMessage("init",{canvas:c},[c])}start(){return this.sendMessage("start",{})}pause(){return this.sendMessage("pause",{})}resize(e,t,i=window.devicePixelRatio||1){return this.sendMessage("resize",{width:e,height:t,dpr:i})}async destroy(){await this.sendMessage("destroy",{}),this.worker?.terminate(),this.pendingCalls.clear()}sendMessage(e,t,i=[]){return new Promise((o,a)=>{const r=this.nextMessageId++;this.pendingCalls.set(r,{resolve:o,reject:a});const l={id:r,type:e,payload:t};this.worker?.postMessage(l,i)})}handleWorkerMessage(e){const{id:t,success:i,result:o,error:a}=e,r=this.pendingCalls.get(t);if(!r){console.warn("Received response for unknown message id:",t);return}this.pendingCalls.delete(t),i?r.resolve(o):r.reject(new Error(a??"Unknown worker error"))}}class hv{constructor(e,t){this.idScopes={},this.pixelPackBuffer=null,this.pixelPackBufferSize=0,this.isIdle=()=>this.searchQueue.size===0&&!this.needsUpdate,this.state=e,this.modules=t,this.identifyData=[],this.needsUpdate=!1,this.forceUpdate=!1,this.searchQueue=new Map,this.lastUpdateTime=NaN,this.cacheBusy=!1,this.stateDiffer=new n.Differ([{path:"center",type:"vec2"},{path:"zoom",type:"number"},{path:"size",type:"vec2"},{path:"rotation",type:"number"},{path:"pitch",type:"number"},{path:"padding",type:"padding"},{path:"demMode",type:"boolean"}])}queryFillCache(){this.needsUpdate=!0}getMemoryFootprint(){const e={colorBuffer:this.colorBuffer?.byteLength??0};return{js:{...e,"--sum":n.getTotalMemory(e)}}}resetCache(){this.colorBuffer=void 0,this.queryFillCache()}search(e,t,i=!1){return this.colorBuffer===void 0&&i&&(this.needsUpdate=!0),this.forceUpdate=i,new Promise(o=>{this.searchQueue.set(e,{point:t,resolve:o})})}searchSync(e){return this.searchHigherPriority(e)}update(){if(this.cacheBusy)return;this.stateDiffer.check(this.state)&&(this.resetCache(),this.searchQueue.size>0&&this.searchQueue.clear());const e=this.modules.labeler.isIdle()&&!this.modules.buildingHeightAnimator.isAnimating(),t=Number.isNaN(this.lastUpdateTime)?!0:Date.now()-this.lastUpdateTime>=n.identify.cacheRefreshTime;this.needsUpdate&&(this.forceUpdate||e&&t)&&(this.lastUpdateTime=Date.now(),this.fillCache(),this.needsUpdate=!1,this.forceUpdate=!1),this.colorBuffer!==void 0&&this.searchQueue.size>0&&(this.searchQueue.forEach(i=>{i.resolve(this.searchHigherPriority(i.point))}),this.searchQueue.clear())}getIdScope(e){return this.idScopes[e]||(this.idScopes[e]=new n.IdScope(this)),this.idScopes[e]}async readIdentifyPixels(e=!1){const t=this.modules.renderer.getRenderingContext(),i=this.modules.renderer.identifyBuffer,o=i.options.size,a=o[0],r=o[1];if(e||t instanceof WebGLRenderingContext||this.state.forceSyncIdentify){const l=new Uint8Array(a*r*4);return i.bind(t),t.readPixels(0,0,o[0],o[1],t.RGBA,t.UNSIGNED_BYTE,l),i.unbind(t),l}else return this._pendingReadIdentifyPixelsPromise?this._pendingReadIdentifyPixelsPromise:(this._pendingReadIdentifyPixelsPromise=new Promise((l,c)=>{(async()=>{const d=new Uint8Array(a*r*4);i.bind(t);const _=a*r*4;!this.pixelPackBuffer||this.pixelPackBufferSize!==_?(this.pixelPackBuffer&&t.deleteBuffer(this.pixelPackBuffer),this.pixelPackBuffer=t.createBuffer(),this.pixelPackBufferSize=_,t.bindBuffer(t.PIXEL_PACK_BUFFER,this.pixelPackBuffer),t.bufferData(t.PIXEL_PACK_BUFFER,_,t.STREAM_READ)):t.bindBuffer(t.PIXEL_PACK_BUFFER,this.pixelPackBuffer),t.readPixels(0,0,a,r,t.RGBA,t.UNSIGNED_BYTE,0);const u=t.fenceSync(t.SYNC_GPU_COMMANDS_COMPLETE,0);if(t.flush(),!u){i.unbind(t),c("Failed to create sync object"),this._pendingReadIdentifyPixelsPromise=void 0;return}await this.clientWaitAsync(t,u,0,10),t.deleteSync(u),t.bindBuffer(t.PIXEL_PACK_BUFFER,this.pixelPackBuffer),t.getBufferSubData(t.PIXEL_PACK_BUFFER,0,d),t.bindBuffer(t.PIXEL_PACK_BUFFER,null),i.unbind(t),l(d),this._pendingReadIdentifyPixelsPromise=void 0})()}),this._pendingReadIdentifyPixelsPromise)}destroy(){const e=this.modules.renderer.getRenderingContext();this.pixelPackBuffer&&e instanceof WebGL2RenderingContext&&(e.deleteBuffer(this.pixelPackBuffer),this.pixelPackBuffer=null)}clientWaitAsync(e,t,i,o){return new Promise((a,r)=>{function l(){const c=e.clientWaitSync(t,i,0);if(c===e.WAIT_FAILED){r();return}if(c===e.TIMEOUT_EXPIRED){setTimeout(l,o);return}a()}l()})}searchHigherPriority(e){const{viewport:t}=this.state,i=n.fromValues$1(e[0]-t.left,e[1]-t.top),o=this.state.identifyPickDistance*window.devicePixelRatio;let a=1/0,r,l=!1;const c=n.create$4();for(c[0]=i[0]-o;c[0]<i[0]+o;c[0]++)for(c[1]=i[1]-o;c[1]<i[1]+o;c[1]++){const d=this.searchPointInCache(c);if(!d)continue;const _=d.dynamicObjectId!==void 0;if(_&&(d.phase=this.modules.dynamicStyle.getRenderIndexById(d.layerId)),l&&!_)continue;const u=n.distance(i,c);(!r||!l&&_||d.phase>r.phase||d.phase===r.phase&&u<a)&&(r=d,a=u,_&&(l=!0))}return r}searchPointInCache(e){if(this.colorBuffer===void 0)return;const t=n.identify.pixelDensity*window.devicePixelRatio,i=this.modules.renderer.identifyBuffer.options.size,o=this.state.size;if(e[0]<0||e[0]>o[0]-1||e[1]<0||e[1]>o[1]-1)return;const a=Math.floor(e[0]*t),l=((i[1]-1-Math.floor(e[1]*t))*i[0]+a)*4,c=(this.colorBuffer[l+3]<<24|this.colorBuffer[l+2]<<16|this.colorBuffer[l+1]<<8|this.colorBuffer[l])>>>0;return this.indexToIdentifierResponse(c)}async fillCache(){if(!this.cacheBusy)try{this.cacheBusy=!0;const e=this.modules.tileManager.getTileObjects();this.modules.renderer.renderIdentify(e),this.colorBuffer=await this.readIdentifyPixels();const t=this.state.metrics;t.interactive===void 0&&(t.interactive=performance.now()-t.start),this.identifyData=this.modules.tileManager.getDisplayedIdentifyData(),this.modules.modelLayer.getDisplayedIdentifyData().forEach(o=>this.identifyData.push(o));const i=this.modules.personalPoiManager.getIdentifyDataChunk();i!==void 0&&this.identifyData.push(i),this.modules.layers.getDynamicObjectLayers().forEach(o=>{o.getIdentifyData().forEach(a=>this.identifyData.push(a))})}catch(e){console.warn(`Cannot fill cache: ${e}`)}finally{this.cacheBusy=!1}}indexToIdentifierResponse(e){for(let t=0;t<this.identifyData.length;t++){const i=this.identifyData[t],{dynamicObjectId:o,ids:a,metatileHash:r,sourceId:l,tileKey:c}=i,{startIndex:d,endIndex:_,idBuffer:u,floorIdBuffer:h,phaseBuffer:f,sublayerBuffer:m,styleIdBuffer:p,layerIdBuffer:v,instanceIdBuffer:y,objectClassBuffer:b,centerBuffer:x,strings:T}=a;if(e<d||e>_)continue;const w=e-d,M=u[w],z=new Uint32Array(m)[w],S=new Uint8Array(y)[w],I=new Uint32Array(b)[w];let R,C="";const j=h[w],H=this.modules.assetManager.getMetatile(r);if(H){H.reverseDictionaries.db_sublayer?.[z]&&(R=H.reverseDictionaries.db_sublayer[z]);const Ne=T[e];Ne!==void 0?C=Ne.objectClass:C=H?.reverseDictionaries.db_object_class?.[I]??""}const K=new Uint16Array(p)[w],Y=new Uint32Array(v)[w],Ye=this.modules.styleManager.getStyleLayer(K,Y);if(!Ye||Ye.type==="custom")return;const Oe=new Int32Array(x,w*Int32Array.BYTES_PER_ELEMENT*2,2);return{id:M,styleId:K,layerId:Y,floorId:j,phase:new Float32Array(f)[w],dynamicObjectId:o,sourceId:l,tileKey:c,sublayer:R,symbol:Ye.type,instanceId:S,objectClass:C,center:Oe[0]!==n.INVALID_IDENTIFY_CENTER_COORD||Oe[1]!==n.INVALID_IDENTIFY_CENTER_COORD?[Oe[0],Oe[1]]:void 0}}}}function fv(s,e,t){if(s.id===void 0)throw new Error("The layer id must be set.");if(e.layerIdToInnerId[s.id])throw new Error(`The layer with id «${s.id}» already exists in the map style.`);let i=-1;if(t){const a=Object.values(e.groupsById).find(r=>r&&r.id===t);if(a)i=e.layers.findIndex(r=>r.groupId===a.innerId);else{i=e.layers.findIndex(l=>l.id===t);const r=e.layers[i]?.groupId;if(r!==void 0&&s.type==="group")throw new Error(`Group layer with id «${s.id}» can't be added before layer with id «${t}» in group with innerId «${r}». Layer groups doesn't support nesting.`)}}else i=e.layers.length;if(i===-1)throw new Error(`The layer with beforeId «${t}» doesn't exist in the map style.`);let o=[];if(s.type!=="group"){o=[s];const a=i!==e.layers.length?e.layers[i]:void 0;if(a&&a.groupId!==void 0){const r=e.groupsById[a.groupId];if(!r){n.log(`Для слоя с id «${a.id}» находящегося в группе с groupId «${a.groupId}» отсутствует группа id в стиле c id «${e.id}»`);return}const l=r.layers.findIndex(c=>c.id===a.id);if(l===-1){n.log(`Слой с id «${a.id}» и groupId «${a.groupId}» отсутствует группе в стиле c id «${e.id}»`);return}s.groupId=r.innerId,r.layers.splice(l,0,s),r.layers.forEach((c,d)=>c.groupIndex=d)}}else e.groupsById[s.innerId]=s,e.layerIdToInnerId[s.id]=s.innerId,o=s.layers;e.revision++,e.layers.splice(i,0,...o),o.forEach(a=>{if(e.layersById[a.innerId]=a,e.layerIdToInnerId[a.id]=a.innerId,a.type==="point"||a.type==="polygon"||a.type==="metricPoint"||a.type==="embankment"||a.type==="polygon3d"){const r=Math.max(0,...Object.keys(e.rasterSets.byIndex).map(d=>Number(d))),l=new n.HandyIndexer(r+1);n.makeHandyRasterSets(a,l,e.icons).forEach(d=>{e.rasterSets.byKey[d.key]||(e.rasterSets.byIndex[d.index]=d,e.rasterSets.byKey[d.key]=d)})}}),Gr(e)}function mv(s,e,t){const i=e.layerIdToInnerId[s];if(i===void 0)return;e.revision++;let o=[];const a=e.groupsById[i];if(a){if(o=a.layers,delete e.groupsById[i],delete e.layerIdToInnerId[a.id],o.length===0)return}else{const l=e.layersById[i];if(!l){n.log(`Слой с id «${s}» есть в списке идентификаторов слоев стиля, но при этом отсутствует в стиле c id «${e.id}»`);return}if(l.groupId!==void 0&&l.groupIndex!==void 0){const c=e.groupsById[l.groupId];c&&(c.layers.splice(l.groupIndex,1),c.layers.forEach((d,_)=>d.groupIndex=_))}o=[l]}const r=e.layers.findIndex(l=>l.id===o[0].id);r!==-1&&(o.forEach(l=>{const{styleManager:c,map:{state:d}}=t,_=c.getRemoveLayerHook(l.innerId);_&&(_(d),c.clearRemoveLayerHook(l.innerId)),delete e.layersById[l.innerId],delete e.layerIdToInnerId[l.id]}),e.layers.splice(r,o.length),Gr(e))}function Gr(s){const e=new n.HandyIndexer;let t;for(const i of s.layers)i.groupId!==void 0&&t&&i.groupId===t.groupId?i.renderIndex=t.renderIndex:i.renderIndex=e.getIndex(),t=i;for(const i in s.groupsById){const o=s.groupsById[i];o&&o.layers[0]&&(o.renderIndex=o.layers[0].renderIndex)}}function pv(s,e,t){const{map:{state:i},collector:o,imageManager:a,renderer:r,tileManager:l}=t;let c;try{c=vv(i,s,256)}catch(b){console.error(b);return}const d=a.addPreparedTexture(c),{downscale:_}=s.style,{size:u}=i,h=new pe({size:[Math.ceil(u[0]*window.devicePixelRatio/_),Math.ceil(u[1]*window.devicePixelRatio/_)],magFilter:g.LinearFilter,minFilter:g.LinearFilter,wrapS:g.ClampToEdgeWrapping,wrapT:g.ClampToEdgeWrapping}),f=h.getTexture();if(!f){console.error("Can't init HeatMap Layer. Missing FrameBuffer texture");return}const m=a.addPreparedTexture(f),p=r.addFramebuffer({renderTarget:h,clearColor:[0,0,0,0],onResize:()=>{h.setSize([Math.ceil(i.size[0]*window.devicePixelRatio/_),Math.ceil(i.size[1]*window.devicePixelRatio/_)]),r.bindRenderTarget(h),r.bindRenderTarget(null);const b=h.getTexture();b&&a.updatePreparedTexture(m,b)}});n.generateSafely({collector:o,generator:n.HeatmapGenerator.generateTexture,args:[e,s,m,d]});const v=o.getAccumulatedData(),y=new n.TileObject("dynamicObject",v.data,t,i);return l.addObject(y),o.reset(),s.framebufferId={framebuffer:p},b=>{l.removeObject(y),y.clean(b),a.deleteTexture(m),a.deleteTexture(d),r.removeFramebuffer(p)}}function vv(s,e,t){const i=n.makeBinderContext(s.styleZoom,s.styleState,[]),o=e.style.color,a=[];if(!gv(o.argument))throw new Error(`Heatmap color must be interpolate expression with 'heatmap-density' argument in layer ${e.id}`);const r=t-1;for(let l=0;l<t;l++){const c=l/r,d=n.sampleColor(o,c,i);a.push(...d.value)}return new g(new Uint8Array(a),{size:[t,1]})}function gv(s){return typeof s=="object"&&s.type==="heatmap-density"}const Hr=1,Vr={type:"color",value:[0,0,0,0]};class yv{constructor(e){this.modules=e,this.customLayers=new Map,this.maxCountStyleLayers=1e4,this.styleIndex=Hr,this.handyStylesMap=new Map,this.waitingStyleRequests=new Map,this.onRemoveLayerHooks=new Map}createStyle(e,t,i){const{state:o}=this.modules.map;if(!Number.isNaN(o.handyStyleId)){const c=this.getStyle(o.handyStyleId);c&&(c.layers.forEach(d=>{const _=this.onRemoveLayerHooks.get(d.innerId);_&&_(o)}),this.onRemoveLayerHooks.clear())}const a=this.styleIndex++;a-n.UNUSED_STYLE_ID_SHIFT>0&&this.handyStylesMap.delete(a-n.UNUSED_STYLE_ID_SHIFT);const r=n.makeHandyStyle(e,a,i);n.applyStyleOptions(r,t),this.handyStylesMap.set(r.id,r),this.setMaxLayersCount(r.layers.length);const l=this.waitingStyleRequests.get(a);return l&&l.resolve(r),this.modules.workers.syncStyle(r),r.layers.forEach(c=>this.initHandyLayer(a,c)),r}hasLayer(e){return this.getStyle(this.modules.map.state.handyStyleId)?.layerIdToInnerId[e]!==void 0}addLayer(e,t){const i=this.getStyle(this.modules.map.state.handyStyleId);if(!i){console.error('Cannot add layer before map style was completely set. Please use "styleload" event.');return}const o=n.makeHandyGroupOrLayer(e);o&&(fv(o,i,t),this.setMaxLayersCount(i.layers.length),e.type==="custom"&&o.type==="custom"?this.initCustomLayer(i.id,o,e.render,e.onRemove,e.onAdd):this.initHandyLayer(i.id,o),this.modules.workers.syncStyle(i))}setTerrainStyle(e){const t=this.getStyle(this.modules.map.state.handyStyleId);t&&(t.dem=n.makeHandyDemLayer(e),this.modules.demManager.onTerrainStyleChange(),this.modules.renderer.addRerenderEvent())}addIcon(e,t){const i=this.getStyle(this.modules.map.state.handyStyleId);if(!i)return console.error('Cannot add icons before map style was completely set. Please use "styleload" event.'),!1;const o=i.layers.filter(d=>(d.type==="point"||d.type==="metricPoint")&&d.style.iconImage!==void 0&&n.expressionValues(d.style.iconImage).some(_=>_===e)),a=i.layers.filter(d=>(d.type==="polygon"||d.type==="embankment"||d.type==="polygon3d")&&!!d.style.textureImage&&n.expressionValues(d.style.textureImage).some(_=>_===e));if(!!i.icons[e])return console.error(`The icon with the name ${e} already exists.`),!1;const l=Math.max(0,...Object.keys(i.rasterSets.byIndex).map(d=>Number(d))),c=new n.HandyIndexer(l+1);return i.icons[e]=t,[...o,...a].forEach(d=>{n.getLayerImageProps(d).forEach(({imageType:_,anchor:u})=>{const h=n.makeHandyRasterSet(e,_,c,u,i.icons);i.rasterSets.byIndex[h.index]=h,i.rasterSets.byKey[h.key]=h})}),i.revision++,this.modules.workers.syncStyle(i),!0}removeIcon(e){const t=this.getStyle(this.modules.map.state.handyStyleId);if(!t)return console.error('Cannot remove icons before map style was completely set. Please use "styleload" event.'),!1;delete t.icons[e];let i=!1;return t.layers.filter(o=>o.type==="point"&&!!o.style.iconImage||o.type==="polygon"&&!!o.style.textureImage||o.type==="metricPoint"&&!!o.style.iconImage||o.type==="embankment"&&!!o.style.textureImage||o.type==="polygon3d"&&!!o.style.textureImage).forEach(o=>{n.getLayerImageProps(o).forEach(({image:a,imageType:r,anchor:l})=>{n.expressionValues(a).forEach(c=>{if(c===e){const d=r==="icon"?n.getStaticIconRasterSetKey(c,l[0],l[1]):n.getStaticTextureRasterSetKey(c),_=t.rasterSets.byKey[d];_&&(this.modules.assetManager.removeRasterSet(_,t.id),i=!0)}})})}),i?(t.revision++,this.modules.workers.syncStyle(t),!0):!1}addModel(e,t){const i=this.getStyle(this.modules.map.state.handyStyleId);return i?i.modelIndex[e]!==void 0?(console.error(`The model with the name ${e} already exists.`),!1):(i.models.push(t),i.modelIndex[e]=i.models.length-1,i.revision++,this.modules.workers.syncStyle(i),!0):(console.error('Cannot add models before map style was completely set. Please use "styleload" event.'),!1)}removeLayer(e){const t=this.getStyle(this.modules.map.state.handyStyleId);if(!t){console.error('Cannot remove layer before map style was completely set. Please use "styleload" event.');return}n.commPoiLayers.some(i=>i.id===e)||(mv(e,t,this.modules),this.modules.workers.syncStyle(t))}showLayers(e){const t=this.getStyle(this.modules.map.state.handyStyleId);if(!t){console.error('Cannot hide layer or group before map style was completely set. Please use "styleload" event.');return}this.setLayerVisibility("visible",e,t)}hideLayers(e){const t=this.getStyle(this.modules.map.state.handyStyleId);if(!t){console.error('Cannot hide layer or group before map style was completely set. Please use "styleload" event.');return}this.setLayerVisibility("hidden",e,t)}setDynamicStyle(e){this.handyStylesMap.set(n.DYNAMIC_STYLE_ID,e),this.modules.workers.syncStyle(e)}getStyle(e){return this.handyStylesMap.get(e)}getStyleLayer(e,t){return this.handyStylesMap.get(e)?.layersById[t]}getStyleRevision(e){return this.getStyle(e)?.revision||0}setFramebufferId(e,t,i){const o=this.handyStylesMap.get(e)?.layersById[t];o&&(o.framebufferId=i)}getFramebufferId(e,t){const i=this.handyStylesMap.get(e)?.layersById[t];return i?.drawToTarget?{ids:void 0,defaultId:this.modules.renderer.getDrawTargetFramebufferId(i.drawToTarget),isDrawTarget:!0}:{ids:i?.framebufferId,defaultId:void 0,isDrawTarget:!1}}waitForStyle(e){const t=this.handyStylesMap.get(e);if(t)return Promise.resolve(t);const i=this.waitingStyleRequests.get(e);if(i)return i.promise;const o={resolve:void 0,promise:void 0};return o.promise=new Promise(a=>{o.resolve=a}),this.waitingStyleRequests.set(e,o),o.promise}addRemoveLayerHook(e,t){this.onRemoveLayerHooks.set(e,t)}getRemoveLayerHook(e){return this.onRemoveLayerHooks.get(e)}clearRemoveLayerHook(e){this.onRemoveLayerHooks.delete(e)}callCustomLayerRender(e){const t=this.customLayers.get(e);t&&t.renderFunction(this.modules.renderer.getRenderingContext())}getCustomSceneObjects(){const e=[];return this.customLayers.forEach(t=>e.push(t.sceneObject)),e}getMaxLayersCount(){return this.maxCountStyleLayers}getStyleLayerForObject(e){const t=this.getStyle(e.attributes.styleId);return t?t.layersById[e.attributes.layerId]:null}getFeatureFlag(e,t){const i=this.getStyle(this.modules.map.state.handyStyleId);return i?i.graphicsPresets[t][e]===!0:!1}getClearColor(){const{map:e,camera:t}=this.modules,{state:i}=e,o=this.handyStylesMap.get(i?.handyStyleId);if(!o)return i.defaultBackgroundColor;const a=n.makeBinderContext(i.styleZoom,i.styleState,[]),r=n.resolveColor(o.environment.style.skyColor,a),l=i.globeMode?t.globeRatio:0;return n.lerp$1(Vr.value,o.background.color.value,r.value,l),Vr}update(){const e=this.getStyle(this.modules.map.state.handyStyleId);e&&(e.light.lightingModesResolved=n.resolveLightingModes(e.light.lightingModes,n.makeBinderContext(this.modules.map.state.styleZoom,this.modules.map.state.styleState,[],!1)))}setLayerVisibility(e,t,i){const{id:o,type:a}=t;if(o&&i.layersById){const r=i.layerIdToInnerId[o];if(r){const l=i.layersById[r];l?l.style&&(l.style.visibility=e):i.groupsById[r]?.layers.forEach(d=>{d&&d.style&&(d.style.visibility=e)})}}a&&i.layers.forEach(r=>{r.type===a&&(r.style.visibility=e)})}initHandyLayer(e,t){let i;switch(t.type){case"group":t.layers.forEach(o=>this.initHandyLayer(e,o));return;case"heatmap":i=pv(t,e,this.modules);break;case"polygonExtrusion":i=this.initPolygonExtrusionLayer(e,t);break}i&&this.modules.styleManager.addRemoveLayerHook(t.innerId,i)}setMaxLayersCount(e){this.maxCountStyleLayers<e&&(this.maxCountStyleLayers=e)}initCustomLayer(e,t,i,o,a){const r={sceneObject:{type:n.SceneObjectType.Custom,attributes:{styleId:e,layerId:t.innerId,tileData:[]},tile:{zoomLevel:0},layerSettings:{},canRender:!0},layer:t,renderFunction:i};a?.(),this.customLayers.set(t.innerId,r),this.modules.styleManager.addRemoveLayerHook(t.innerId,()=>{o?.(),this.customLayers.delete(t.innerId)})}initPolygonExtrusionLayer(e,t){const i=this.getStyle(e);if(!i)return;let o=!1;return t.style.sideTextures.forEach((a,r)=>{const l=i?.icons[a.image]?.url;if(!l){console.warn(`Texture source for polygonExtrusionSideTexture ${a.image} not found inside style.`);return}const c=n.getUrlForIconMapIcon(l,i,"");this.modules.imageManager.loadTexture(c,{skipAtlasSizeChecking:!0,generateMipmaps:this.modules.renderer.isWebgl2Context(),minFilter:this.modules.renderer.isWebgl2Context()?g.LinearMipMapLinearFilter:g.LinearFilter,imagePadding:0,premultiplyAlpha:!0}).then(_=>{_!==void 0&&!o&&(t.sideTextureIndices[r]=_)})}),()=>{o=!0}}}class mt{constructor(){this.events={}}on(e,t){let i=this.events[e];return i||(i=this.events[e]=[]),i.push(t),this}once(e,t){const i=o=>{this.off(e,i),t.call(this,o)};return this.on(e,i),this}off(e,t){const i=this.events[e];if(!i)return this;const o=i.indexOf(t);return o!==-1&&i.splice(o,1),this}emit(e,t){const i=this.events[e];if(!i)return this;const o=i.slice();for(let a=0;a<o.length;a++)o[a].call(this,t);return this}}class bv{constructor(e){this.modules=e,this.id=n.sourceUuid(),this.type="globe"}destroy(){}update(){}fetchTiles(e){return e.map(()=>Promise.resolve([]))}generateTile(e,t,i){const o=n.createTileInfo(t),a=this.modules.collector,r=this.modules.styleManager.getStyle(i);if(!r||!r.environment)return Promise.resolve({results:[]});n.generateSafely({collector:a,generator:n.GlobeGenerator.sinks.fill.generate,args:[r,r.environment,o]});const l=a.getAccumulatedData();return Promise.resolve({results:[{styleId:i,metatileHash:-1,regionId:-1,collectorOutput:l}]})}abortTileFetches(){}deleteTiles(){}setAttributes(){}getAttributes(){return{}}}const dn="gltfModels";let jr=class{constructor(e,t){this.modules=t,this.type="default",this.id=n.sourceUuid(),this.state=e,this.options={tileServer:e.tileServer,tileSet:e.tileSet,tileProtocol:e.tileProtocol,tileKey:e.tileKey,subdomains:e.subdomains,appId:e.appId,defaultLang:e.tileServerDefaultLang,sessionId:e.tileSessionId??e.sessionId,isDefaultSource:!0,modelsPath:e.defaultSourceModelsRootUrl,promoteId:"id",idScope:n.DEFAULT_ID_SCOPE,identifyAsDefaultSource:!0},this.modelsAppearStrategy=e.defaultSourceModelsAppearStrategy??n.DEFAULT_MODELS_APPEAR_STRATEGY,this.zenithSource=new n.ZenithSourceCore(this.id,this.modules,this.options),this.universeTileLayer=new n.TileLayer(0,n.tiles.maxUniverseZoom,0,n.tiles.maxUniverseZoom,this.modules,e,this.zenithSource,{requestOddTiles:e.mobileSdkMode,useExtendedTilesBounds:!0}),this.universeTileLayer.getLabelingData=()=>{const i=n.TileLayer.prototype.getLabelingData.call(this.universeTileLayer);return this.regionalTileLayer.isBlank()||(i.labelsKeys=[]),i},this.modules.tileManager.addTileLayer(this.universeTileLayer),this.regionalTileLayer=new n.TileLayer(n.tiles.maxUniverseZoom+1,n.tiles.maxRegionalZoom,n.tiles.maxUniverseZoom+1,n.tiles.maxDetailLevel,this.modules,e,this.zenithSource,{requestOddTiles:e.mobileSdkMode}),this.modules.tileManager.addTileLayer(this.regionalTileLayer),this.commercialPoiSource=new n.GeoJsonSourceCore(this.id,this.modules,{url:n.bindUrl("commercialPoi",{host:e.tileServer,tileSet:e.commercialTileSet,protocol:n.tiles.protocol,lang:e.lang}),flipY:!0,identifyAsDefaultSource:!0,promoteId:"db_id"},this.state),this.commercialPoiTileLayer=new n.TileLayer(n.commercialPoi.minZoom,n.commercialPoi.maxZoom,n.commercialPoi.minZoom,n.GEOJSON_DEFAULT_MAX_DETAIL_LEVEL,this.modules,e,this.commercialPoiSource,{viewportPadding:n.MODELS_TILES_VIEWPORT_PADDING}),this.modules.tileManager.addTileLayer(this.commercialPoiTileLayer),this.createModelsSource(),this.modules.sourceStorage.addSource(this)}destroyModelsSource(){this.modelsSource&&(this.modelsSource=null,this.modelsTileLayer&&this.modules.tileManager.removeTileLayer(this.modelsTileLayer))}createModelsSource(){this.modelsSource||(this.modelsSource=new n.GeoJsonSourceCore(this.id,this.modules,{minZoom:n.models.minZoom,maxZoom:n.models.maxZoom,url:n.bindUrl({url:this.state.modelsTilesUrl},{host:this.state.tileServer,tileSet:this.state.modelsTileSet,protocol:n.tiles.protocol,lang:this.state.lang}),ignoreMissingTiles:!0,identifyAsDefaultSource:!0,promoteId:"building_id",modelsPath:this.state.defaultSourceModelsRootUrl??n.bindUrl("gltfModel",{host:this.state.tileServer,tileSet:this.state.tileSet,protocol:n.tiles.protocol,lang:this.state.lang}),flipY:!0,attributes:{sourceName:dn}},this.state),this.modelsTileLayer=new n.TileLayer(n.models.minZoom,n.models.maxZoom,n.models.minZoom,n.tiles.maxDetailLevel,this.modules,this.state,this.modelsSource,{viewportPadding:n.MODELS_TILES_VIEWPORT_PADDING}),this.modules.tileManager.addTileLayer(this.modelsTileLayer))}getMemoryFootprint(){const e={regionalTileLayer:this.regionalTileLayer.memSizeJs(),universeTileLayer:this.universeTileLayer.memSizeJs(),modelsTileLayer:this.modelsTileLayer?this.modelsTileLayer.memSizeJs():{},...this.commercialPoiTileLayer&&{commercialPoiTileLayer:this.commercialPoiTileLayer.memSizeJs()}},t={regionalTileLayer:this.regionalTileLayer.memSizeGpu(),universeTileLayer:this.universeTileLayer.memSizeGpu(),modelsTileLayer:this.modelsTileLayer?this.modelsTileLayer.memSizeGpu():{},...this.commercialPoiTileLayer&&{commercialPoiTileLayer:this.commercialPoiTileLayer.memSizeGpu()}};return{js:{...e,"--sum":n.getTotalMemory(e)},gpu:{...t,"--sum":n.getTotalMemory(t)}}}destroy(){this.modules.tileManager.removeTileLayer(this.universeTileLayer),this.universeTileLayer.destroy(),this.modules.tileManager.removeTileLayer(this.regionalTileLayer),this.regionalTileLayer.destroy(),this.zenithSource.destroy(),this.commercialPoiTileLayer&&(this.modules.tileManager.removeTileLayer(this.commercialPoiTileLayer),this.commercialPoiTileLayer.destroy()),this.commercialPoiSource?.destroy(),this.modelsTileLayer&&(this.modules.tileManager.removeTileLayer(this.modelsTileLayer),this.modelsTileLayer.destroy()),this.modelsSource?.destroy(),this.modules.sourceStorage.removeSource(this.id),this.removeGlobeSource()}setAttributes(e){this.zenithSource.setAttributes({...e,...n.zenithSourceAttrs}),this.universeTileLayer.redraw(),this.regionalTileLayer.redraw(),this.commercialPoiSource?.setAttributes(e),this.commercialPoiTileLayer?.redraw(),this.modelsSource?.setAttributes({...e,sourceName:dn}),this.modelsTileLayer&&this.modelsTileLayer.redraw()}getAttributes(){return this.zenithSource.getAttributes()}getId(){return this.id}getZoomDirection(){return this.regionalTileLayer.getZoomDirection()}setHoverId(e){this.regionalTileLayer.setHoverId(e)}setDisabledRegionsId(e){this.regionalTileLayer.disabledRegions=e,this.universeTileLayer.disabledRegions=e}resetHoverId(){this.regionalTileLayer.resetHoverId()}setFeatureStateMap(e){this.zenithSource.setFeatureStateMap(e),this.modelsSource?.setFeatureStateMap(e),this.universeTileLayer.onFeatureStateMapChange(),this.regionalTileLayer.onFeatureStateMapChange(),this.modelsTileLayer?.onFeatureStateMapChange(),this.modules.modelLayer.onFeatureStateMapChange()}generateHoverTile(e,t,i,o,a,r,l,c){return this.zenithSource.generateTile(e,t,i,o,a,r,l,c)}generateModel(e){return this.zenithSource.generateModel(e)}isIdentifiedAsDefault(){return!0}setDataType(e){this.options.dt!==e&&(!this.options.dt||!e||!n.equalArrays(this.options.dt,e))&&(this.options.dt=e,this.regionalTileLayer.redraw())}getDataType(){return this.options.dt}setDataFilter(e){this.zenithSource.setDataFilter(e),this.modelsSource?.setDataFilter(e)}hasLayer(e){return this.modelsTileLayer===e||this.regionalTileLayer===e||this.universeTileLayer===e||this.commercialPoiTileLayer===e}addGlobeSource(){const{modules:e}=this,t=e.map.state;e.styleManager.getStyleLayer(t.handyStyleId,n.ENVIRONMENT_STYLE_LAYER_ID)&&(this.globeSource=new bv(this.modules),this.globeTileLayer=new n.TileLayer(t.minZoom,n.globeConfig.globeMaxZoom,t.minZoom,n.globeConfig.globeMaxZoom,e,e.map.state,this.globeSource),e.tileManager.addTileLayer(this.globeTileLayer))}removeGlobeSource(){this.globeSource&&(this.globeSource.destroy(),this.globeSource=void 0),this.globeTileLayer&&(this.modules.tileManager.removeTileLayer(this.globeTileLayer),this.globeTileLayer.destroy(),this.globeTileLayer=void 0)}isGlobeTilesReady(){return this.globeTileLayer?this.globeTileLayer.viewportTilesReady()&&!this.globeTileLayer.isEmpty():!1}};class xv extends mt{constructor(e,t){super(),this.loadFont=(a,r)=>{let l=this.requestFontRanges.get(a,r);return l||(l=this.createLoadFontRequest(a,r),this.requestFontRanges.set(a,r,l)),l},this.invalidateUsedGltfModels=n.throttle(()=>{const a=new Set;if(this.modules.renderer.isDestroyed)return;const r=this.modules.tileManager.getTileObjects();for(const c of r)for(const d of c.children){if(!Fo(d))continue;const{styleId:_,layerId:u,modelIndices:h,sourceId:f,sourceName:m}=d.attributes,p=this.modules.styleManager.getStyleLayer(_,u);if(!p||p.type!=="gltfModel")continue;const v=this.modules.modelsScene.getCurrentLayerModelId(d.attributes,d.tile);h.forEach(y=>{const b=this.getModel(y,_);if(b){a.add(b);return}if(v===y){const x=this.dataModelIdToUrl[y];if(x){const T=f===this.modules.defaultSource.getId()&&m===dn;this.loadModel(x,y,_,!1,p,T)}else this.loadModelByIndex(y,_,p)}})}const l=this.modules.tileManager.getCachedMods();for(const c of l)c.objects?.forEach(d=>{for(const _ of d.children){if(!Fo(_))continue;const{styleId:u,layerId:h,modelIndices:f}=_.attributes,m=this.modules.styleManager.getStyleLayer(u,h);if(!m||m.type!=="gltfModel")return;f.forEach(p=>{const v=this.getModel(p,_.attributes.styleId);v&&a.add(v)})}});for(const c in this.models){const d=this.models[c];!d.preserve&&!a.has(d)&&d.status===Ze.Loaded&&d.usedEmptyScene!==!0?this.removeModel(c):d.usedEmptyScene=!1}},n.workerResetInterval),this.state=e,this.modules=t,this.modelsWorker=new this.modules.workers.models.ModelsSource,this.requestedMetatiles=new Set,this.metatiles={},this.loadedRasters={},this.failedRasters={},this.requestedRasters={},this.requestedSvgs={},this.disableIconCache=e.disableIconCache,this.textures=[],this.fontGlyphs={},this.fontTextures=new n.TwoKeyMap,this.requestFontRanges=new n.TwoKeyMap,this.pendingFontRanges=0,this.loadedFontRanges=0,this.models={},this.dataModelIdToUrl={},this.visibleBuildingIds=new Set,this.metatileLoader=(a,r,l)=>{const c=n.hashToString(r);fetch(a).then(d=>{if(!d.ok)throw new Error(`Failed to load metatile "${c}"`);return d.json()}).then(d=>this.setMetatile(r,l,d)).catch(d=>console.error(d))};const i=(a,r)=>{const l=this.modules.styleManager.getStyle(a);if(!l){console.error(`Not found style ${a} in AssetManager#addNewRasterSets`);return}const{rasterSets:c}=l;r.forEach(d=>{c.byIndex[d.index]=d,c.byKey[d.key]=d})},{fnRegistry:o}=this.modules.workers;o.set("addNewRasterSets",i),o.set("loadFont",this.loadFont),this.setPreparedMetatile(-1,n.fixedMetatile),this.setPreparedMetatile(n.geoJsonMetatileHash,n.createGeoJsonMetatile(Array.from(this.state.modelShowHideEventsSublayers)))}getMemoryFootprint(){const e={textures:this.textures.map(n.textureSizeJs),fontTextures:this.fontTextures.reduce((i,o)=>(i.push(n.textureSizeJs(o)),i),[]),fontGlyphs:Object.values(this.fontGlyphs).reduce((i,o)=>Object.values(o).reduce((a,r)=>(a.push({bitmap:r.bitmap?.byteLength??0}),a),i),[]),models:Object.values(this.models).map(n.modelSizeJs).filter(i=>i.buffers.length>0||i.textures.length>0)},t={textures:this.textures.map(n.textureSizeGpu),fontTextures:this.fontTextures.reduce((i,o)=>(i.push(n.textureSizeGpu(o)),i),[]),models:Object.values(this.models).map(n.modelSizeGpu).filter(i=>i.buffers.length>0||i.textures.length>0)};return{js:{...e,"--sum":n.getTotalMemory(e)},gpu:{...t,"--sum":n.getTotalMemory(t)}}}fillDataModelUrlMap(e){for(const t in e)this.dataModelIdToUrl[e[t]]=t}getDataModelUrlById(e){return this.dataModelIdToUrl[e]}loadMetatile(e,t,i){this.requestedMetatiles.has(t)||(this.requestedMetatiles.add(t),this.metatileLoader(e,t,i))}setMetatile(e,t,i){n.renameZenithEnumerationValues(i),i.tileProps=i.tileProps.map(n.zenithToJakartaPropKey);const o=n.prepareMetatile(i);this.setPreparedMetatile(e,o),this.projectMetatileMetadata===void 0&&(this.projectMetatileMetadata={regionId:t,metatileHash:e})}setPreparedMetatile(e,t){this.metatiles[e]=t,this.modules.workers.parser.setMetatile(e,t)}prepareRasters(e,t,i){const o=this.modules.styleManager.getStyle(e);if(!o){console.error(`Not found style ${e} in AssetManager#prepareRasters`);return}const{rasterSets:a}=o,r=7,l=t.length/r;for(let c=0;c<l;c++){const d=t[c*r],_=t[c*r+1],u=t[c*r+6],h=t[c*r+2],f=t[c*r+3],m=t[c*r+4],p=t[c*r+5],v=a.byIndex[d];if(v.isSvg){const x={rasterIndex:_,rasterSetIndex:d,x:h,y:f,w:m,h:p,anchorX:v.anchorX,anchorY:v.anchorY,atlasIndex:u,isPacked:!0};v.rasters[_]=x,this.requestedSvgs[o.id]?.[d]?.then(T=>{const w=this.textures[x.atlasIndex],{url:M,revokeURL:z}=hr(T);ur(M,x.w,x.h).then(S=>{w.subImage(S,x.x,x.y),this.modules.renderer.addRerenderEvent(),z&&z()})})}else{const x=v.rasters[_]??{rasterIndex:_,rasterSetIndex:d,x:h,y:f,w:m,h:p,anchorX:0,anchorY:0,atlasIndex:u,isPacked:!0};v.rasters[_]=x,x.x=h,x.y=f,x.atlasIndex=u,x.isPacked=!0}this.textures[u]===void 0&&(this.textures[u]=new g(void 0,{size:n.atlasSize,flipY:!1,premultiplyAlpha:!Gc,magFilter:g.LinearFilter,minFilter:g.LinearFilter}),this.modules.renderer.prepareTexture(this.textures[u]));const y=this.textures[u],b=i&&i[c];if(b!==void 0){y.subImage(b,h,f),this.modules.renderer.addRerenderEvent();continue}}this.modules.workers.labeling.updatePackingInfo(e,t)}loadRasters(e){const i=e.length/3;for(let o=0;o<i;o++){const a=e[o*3],r=e[o*3+1],l=e[o*3+2],c=r<<16|l,d=this.modules.styleManager.getStyle(a);if(!d){console.error(`Not found style ${a} in AssetManager#loadRasters`);continue}if(this.loadedRasters[a]||(this.loadedRasters[a]=new Set,this.failedRasters[a]=new Set,this.requestedRasters[a]=new Set),this.requestedRasters[a].has(c))continue;const{rasterSets:_}=d,u=_.byIndex[r];if(u.rasters[l].isPacked===!1){console.error(`Try to load not packed raster ${u.key}`);continue}this.requestedRasters[a].add(c),u.isSvg?this.loadSvg(c,d,r):this.loadPng(c,d,r,l)}}removeRasterSet(e,t){const{key:i,index:o,rasters:a}=e;delete this.requestedSvgs[t][o],a.forEach(({rasterSetIndex:l,rasterIndex:c})=>{const d=l<<16|c;this.loadedRasters[t]?.delete(d),this.failedRasters[t]?.delete(d),this.requestedRasters[t]?.delete(d)}),e.rasters.length=0;const r=this.modules.styleManager.getStyle(t);r&&(delete r.rasterSets.byIndex[o],delete r.rasterSets.byKey[i])}getMetatile(e){return this.metatiles[e]}getProjectMetadata(){return this.projectMetatileMetadata}getFontGlyphs(e){return this.fontGlyphs[e]||{}}getFontTextureByName(e,t){return this.fontTextures.get(e,t)}isIdle(){let e=0,t=0;for(const i in this.requestedRasters)e+=this.requestedRasters[i].size,t+=this.loadedRasters[i].size+this.failedRasters[i].size;return e===t&&this.pendingFontRanges===this.loadedFontRanges&&this.allModelsLoaded()}dangerouslySetMetatiles(e){this.metatiles=e}dangerouslySetRasters(e,t){this.loadedRasters=e,this.failedRasters=t}loadModelByIndex(e,t,i){const o=this.getModelUniqueKey(e,t);if(this.models[o]!==void 0)return;const a=this.modules.styleManager.getStyle(t);if(a===void 0){n.logGltfError({layer:"prepare",message:"Style not found. Can't determine url"});return}const r=a.models[e];if(r===void 0){n.logGltfError({layer:"prepare",message:`Model with index "${e}" is missing in the style.`});return}const l=n.getModelUrl(r.url,a);this.fetchModel(l,e,o,!1,i,!1)}loadModel(e,t,i,o,a,r,l){const c=this.getModelUniqueKey(t,i);if(this.models[c]!==void 0){l?.();return}this.fetchModel(e,t,c,o,a,r,l)}getModel(e,t){return this.models[this.getModelUniqueKey(e,t)]}allModelsLoaded(){for(const e in this.models)if(this.models[e].status===Ze.Pending)return!1;return!0}isModelLoaded(e,t){const i=this.models[this.getModelUniqueKey(e,t)];return i&&i.status===Ze.Loaded}removeModel(e){const t=this.models[e];if(t){for(const i of t.scenes)i.objects.forEach(o=>{o.elementsBuffer&&o.elementsBuffer.remove()}),i.objects.splice(0,i.objects.length);t.scenes.splice(0,t.scenes.length),t.buffers.forEach(i=>{i instanceof n.Buffer&&i.remove()}),t.buffers=[],t.textures.forEach(i=>i.remove()),t.textures=[],delete this.models[e]}}fetchModel(e,t,i,o,a,r,l){const{renderer:c}=this.modules,d=this.models[i]=$h(o);this.modelsWorker.loadModel(e,this.state.dracoDecoderUrl).then(_=>{if(_.type==="ok"){if(d.status=Ze.Loaded,!_.result)return;Xh(d,c,_.result,t,a,r),this.emit("modelloaded",t),this.modules.renderer.addRerenderEvent(),l?.()}else n.logGltfError(_),d.status=Ze.Failed})}getModelUniqueKey(e,t){return e>=0?`${t},${e}`:String(e)}async createLoadFontRequest(e,t){this.pendingFontRanges+=1;const i=Number.isNaN(this.state.handyStyleId)?Hr:this.state.handyStyleId;try{const o=await this.modules.styleManager.waitForStyle(i),a=await fetch(n.getFontUrl(e,t,o)).then(l=>{if(!l.ok)throw new Error;return l}).catch(()=>(console.error(`Could not load font ${e} for range ${t} fallback to the default font ${n.DEFAULT_FONT}`),fetch(n.getFontUrl(n.DEFAULT_FONT,t,o)).then(l=>{if(!l.ok)throw new Error(`Could not load default font ${n.DEFAULT_FONT} for range ${t}`);return l}))).then(l=>l.arrayBuffer()),r=n.processFont(a);return this.prepareFontAtlas(e,t,r),this.modules.workers.labeling.appendFont(e,r.glyphData),this.loadedFontRanges+=1,this.modules.workers.labeling.markFontAsLoaded(e,t)}catch(o){return console.error(o),this.loadedFontRanges+=1,this.modules.workers.labeling.markFontAsLoaded(e,t)}}prepareFontAtlas(e,t,i){const{bitmap:o,width:a,height:r,glyphData:l}=i;this.fontGlyphs[e]||(this.fontGlyphs[e]={});for(const d in l)this.fontGlyphs[e][d]=l[d];const c=new g(new Uint8Array(o),{size:[a,r],magFilter:g.LinearFilter,minFilter:g.LinearFilter,format:g.AlphaFormat,premultiplyAlpha:!1,flipY:!1});this.fontTextures.set(e,t,c),this.state.needLabeling=!0}async loadPng(e,t,i,o){const a=t.rasterSets.byIndex[i],r=a.rasters[o],l=this.textures[r.atlasIndex];let c="";if(a.type===n.RasterSetType.Unique){const d=a.id;a.url?c=n.getSizeDependentImageUrl(a.url,r.w,r.h):c=n.getUrl("dynamicPoi",{host:this.state.tileServer,tileSet:this.state.tileSet,protocol:this.state.tileProtocol,subdomain:n.getSubdomainFromString(this.state.subdomains,d),id:d,width:r.w.toString(),height:r.h.toString(),regionId:String(a.regionId)})}else if(a.type===n.RasterSetType.Static){const d=t.icons[a.name];if(!d){console.error(`There is no appropriate icon config in the style for raster set: "${a.name}"`),this.failedRasters[t.id].add(e);return}c=n.getUrlForIconMapIcon(d.url,t,n.getSubdomainFromString(this.state.subdomains,a.name))}this.modules.workers.parser.prepareAtlas(c).then(async d=>{if(d){if(d.isBitmap){if((d.data[0].width!==r.w||d.data[0].height!==r.h)&&a.type===n.RasterSetType.Static){if(r.w<=0||r.h<=0)return;const _=document.createElement("canvas");_.width=r.w,_.height=r.h,_.getContext("2d").drawImage(d.data[0],0,0,_.width,_.height),l.subImage(_,r.x,r.y)}else l.subImage(d.data[0],r.x,r.y);this.modules.renderer.addRerenderEvent()}else tn(d.data[0]).then(_=>{l.subImage(_,r.x,r.y),this.modules.renderer.addRerenderEvent()});this.loadedRasters[t.id].add(e),a.isReady=!0}else this.failedRasters[t.id].add(e)})}async loadSvg(e,t,i){const o=t.rasterSets.byIndex[i];if(!t.iconBaseUrl){console.error(`Attempt to load svg without existing style for raster set: "${o.name}"`),this.failedRasters[t.id].add(e);return}const a=t.icons[o.name];if(!a){console.error(`There is no appropriate icon config in the style for raster set: "${o.name}"`),this.failedRasters[t.id].add(e);return}const r=n.getUrlForIconMapIcon(a.url,t,n.getSubdomainFromString(this.state.subdomains,o.name));this.requestedSvgs[t.id]||(this.requestedSvgs[t.id]={});let l=this.requestedSvgs[t.id][i];(!l||this.disableIconCache)&&(l=fetch(r,{cache:this.disableIconCache?"no-cache":"default"}).then(c=>{if(!c.ok)throw new Error("Not 2xx response");return c.text()}),this.requestedSvgs[t.id][i]=l);try{const c=await l,{url:d,revokeURL:_}=hr(c),u=await ur(d),h=t.rasterSets.byIndex[i];for(const f of h.rasters){if(f.w<=0||f.h<=0)continue;const m=this.textures[f.atlasIndex];u.width=f.w,u.height=f.h,m.subImage(u,f.x,f.y),this.modules.renderer.addRerenderEvent()}u.remove(),_&&_(),this.loadedRasters[t.id].add(e),h.isReady=!0}catch(c){console.error(`Can't load an SVG for the "${o.name}" raster set. Error: `,c),this.failedRasters[t.id].add(e)}}}class wv{constructor(e,t,i,o,a,r,l,c){this.modules=e,this.mapState=t,this.cache=i,this.maxStyleZoom=-1/0,this.minStyleZoom=1/0,this.ready=!1,this.useful=!1,this.status="initial",this.model=o,this.key=a,this.selectedIds=r,this.styleId=l,this.styleRevision=c,this.modelRevision=o.revision,this.objects=[]}update(){switch(this.status){case"initial":{this.useful&&(this.loadModel(),this.status="generating");break}case"generating":{if(this.useful&&this.processResponse&&this.model.texturesLoaded){const{objects:{data:e}}=this.processResponse;this.objects=Tv(e,this.modules),this.updateMinAndMaxStyleZoom(this.objects),this.status="generated",this.ready=!0,this.cache.add(this.key,this)}break}}}getIdentifyIds(){return this.processResponse?.objects.identifyIds}remove(){this.status==="generated"&&this.cache.remove(this.key),this.status="initial",this.objects.length&&(this.objects.forEach(e=>e.clean(this.mapState)),this.objects=[]),this.ready=!1}canBeRemoved(){return this.status==="initial"}loadModel(){const{model:{regionId:e,metatileHash:t,id:i,sourceModel:{fileName:o,matrix:a,offset:r}}}=this,c={url:n.getUrl("model",{host:this.mapState.tileServer,tileSet:this.mapState.tileSet,protocol:this.mapState.tileProtocol,subdomain:n.getSubdomainFromString(this.mapState.subdomains,o),regionId:e.toString(),name:o}),id:i,regionId:e,metatileHash:t,selected:this.selectedIds.some(d=>d===i),pixelRatio:window.devicePixelRatio,styleState:this.mapState.styleState,styleId:this.mapState.handyStyleId,offset:r,matrix:a};this.modules.defaultSource.generateModel(c).then(d=>{this.model.prepareTextures(d.textures),this.processResponse=d})}updateMinAndMaxStyleZoom(e){this.minStyleZoom=Math.min(...e.map(t=>Math.min(...t.children.map(i=>{const o=this.modules.styleManager.getStyleLayer(i.attributes.styleId,i.attributes.layerId);return o?.type==="dem"?1/0:o?.minzoom??-1/0})))),this.maxStyleZoom=Math.max(...e.map(t=>Math.max(...t.children.map(i=>{const o=this.modules.styleManager.getStyleLayer(i.attributes.styleId,i.attributes.layerId);return o?.type==="dem"?-1/0:o?.maxzoom??1/0}))))}}function Sv(s,e,t,i,o){const a=e.join("|");return`model=${s}_sId=${t}_sRev=${i}_mRev=${o}_sel=${a}`}function Tv(s,e){const t=new Wr(s,e),i=[],o=Zr(t.children[0]??t.identifyChildren[0]??t.depthTestChildren[0]??t.shadowChildren[0]);return o&&["children","identifyChildren","depthTestChildren","shadowChildren"].forEach(a=>{const r=t.modelMatrices.get(0)??n.create$2();n.copy(r,o),t.modelMatrices.set(0,r);let l=t[a].length;for(;l--;){const c=t[a][l],d=Zr(c);if(!d||n.exactEquals(r,d))continue;let _=i.find(u=>{const h=u.modelMatrices.get(0);return h?n.exactEquals(h,d):!1});_||(_=new Wr([],e),_.modelMatrices.set(0,n.copy(n.create$2(),d)),i.push(_)),_[a].push(c),c.tile=_,t[a].splice(l,1)}}),[t,...i]}function Zr(s){if(s&&"matrix"in s.attributes)return s.attributes.matrix}class Wr extends n.TileObjectBase{constructor(e,t){super("model");const{identifier:i}=t;n.spreadTileObjects(t,e,this,i.getIdScope(n.DEFAULT_ID_SCOPE)),this.size=n.tileZoomToSize(this.coords[2]),this.zoomLevel=this.coords[2],this.detailLevel=this.coords[3]}setTileCoords(e,t){}syncReplicas(e){}}class Mv{constructor(e,t,i,o,a,r){this.modules=e,this.mapState=t,this.cache=i,this.regionId=o,this.metatileHash=a,this.sourceModel=r,this.revision=0,this.texturesLoaded=!1,this.textures=[],this.readiness=0,this.id=r.id,this.attributes=r.attributes??{},this.readinessTickerName=`model-readiness-${this.id}`,this.ids=e.identifier.getIdScope(n.DEFAULT_ID_SCOPE)}update(){this.currentMod?.useful&&this.currentMod.update(),this.newMod?.useful&&this.newMod.update(),n.update(this.readinessTickerName,{step:(e,t)=>this.readiness=t},this.mapState)}isAnimating(){return n.exist(this.readinessTickerName,this.mapState)}commitMod(){this.newMod&&this.newMod.ready&&(this.currentMod=this.newMod,this.newMod=void 0)}setUsefulMod(){const e=this.mapState.handyStyleId,t=this.modules.styleManager.getStyleRevision(e),i=this.ids.getSelected().filter(o=>o===this.id);if(!this.currentMod&&!this.newMod){this.createNewMod(i,e,t,this.revision);return}if(this.currentMod&&n.deepEqual(this.currentMod.selectedIds,i)&&this.currentMod.styleId===e&&this.currentMod.styleRevision===t&&this.currentMod.modelRevision===this.revision){this.currentMod.useful=!0,this.newMod=void 0;return}if(this.newMod){n.deepEqual(this.newMod.selectedIds,i)&&this.newMod.styleId===e&&this.newMod.styleRevision===t&&this.newMod.modelRevision===this.revision?this.newMod.useful=!0:this.createNewMod(i,e,t,this.revision);return}this.createNewMod(i,e,t,this.revision)}getUsefulMod(){if(this.currentMod&&this.currentMod.useful)return this.currentMod;if(this.newMod&&this.newMod.useful)return this.newMod}getCurrentMod(){return this.currentMod}setAllModsNeedless(){this.currentMod&&(this.currentMod.useful=!1),this.newMod&&(this.newMod.useful=!1)}getOpacity(e){return this.readiness*this.modules.buildingHeightAnimator.getBuildingHeight(e)}getTexture(e){return this.textures[e]}prepareTextures(e){this.texturesLoaded||(e.isBitmap?(this.textures=e.data.map(t=>new g(t,{flipY:!1})),this.texturesLoaded=!0,this.startReadinessTicker()):Promise.all(e.data.map(t=>tn(t))).then(t=>{this.textures=t.map(i=>new g(i,{flipY:!1})),this.texturesLoaded=!0,this.startReadinessTicker()}))}clean(){this.canBeCleaned()&&(this.texturesLoaded&&(this.textures.forEach(e=>e.remove()),this.textures=[],this.texturesLoaded=!1),this.stopReadinessTicker())}canBeCleaned(){return(!this.currentMod||this.currentMod.canBeRemoved())&&(!this.newMod||this.newMod.canBeRemoved())}createNewMod(e,t,i,o){const a=Sv(this.id,e,t,i,o),r=this.cache.get(a);r?(this.newMod=r,this.newMod.useful=!0):this.newMod=new wv(this.modules,this.mapState,this.cache,this,a,e,t,i)}startReadinessTicker(){this.readiness=0,n.start(this.readinessTickerName,{easing:n.buildingAnimation.easing},this.mapState,0,1,n.buildingAnimation.duration,1)}stopReadinessTicker(){this.readiness=0,n.stop(this.readinessTickerName,this.mapState)}}class Ev{constructor(e,t){this.mapState=e,this.modules=t,this.buildingsHeight=new Map,this.models=new Map,this.displayedMods=new Map,this.viewportModels=[],this.requestedModelsInfo=new Set,this.loadedModelsInfo=new Set,this.isStyleUpdateInProgress=!1,this.hiddenBuildingIds=new Set,this.cache=new n.LRU(n.modelCacheSize,(i,o)=>o.remove()),this.ids=t.identifier.getIdScope(n.DEFAULT_ID_SCOPE)}onFeatureStateMapChange(){this.models.forEach(e=>{e.revision++})}update(){this.findViewportModels(),this.mapState.styleZoom>n.loadModelsInfoStyleZoom&&this.modules.tileManager.getViewportTiles().forEach(e=>{e.type==="zenith"&&e.serverMetadata&&e.serverMetadata.forEach(t=>{const i=this.modules.sourceStorage.getSourceById(e.sourceId);if(i!==void 0&&"getUrl"in i){const o=i.getUrl("modelInfo",{regionId:t.regionId.toString()});this.loadModelsInfo(o,t.regionId,t.metatileHash)}else{const o=n.getUrl("modelInfo",{host:this.mapState.tileServer,tileSet:this.mapState.tileSet,protocol:this.mapState.tileProtocol,subdomain:this.mapState.subdomains[0],regionId:t.regionId.toString()});this.loadModelsInfo(o,t.regionId,t.metatileHash)}})}),this.models.forEach(e=>e.setAllModsNeedless()),this.viewportModels.forEach(e=>e.setUsefulMod()),this.models.forEach(e=>e.update()),this.isStyleUpdateInProgress||this.models.forEach(e=>e.commitMod()),this.updateScene(),this.cleanUnnessasaryModels(),this.updateObjectsVisibility()}activateStyleUpdating(){this.isStyleUpdateInProgress=!0}finishStyleUpdating(){this.isStyleUpdateInProgress=!1}redraw(){this.cache.reset(),this.cleanUnnessasaryModels()}isModelsInfoLoaded(e){return this.loadedModelsInfo.has(e)}getTexture(e,t){return this.models.get(e)?.getTexture(t)}getDisplayedIdentifyData(){const e=[];return this.viewportModels.forEach(t=>{const i=t.getUsefulMod();if(!i)return;const o=i.getIdentifyIds();o&&e.push({metatileHash:t.metatileHash,ids:o})}),e}getOpacity(e,t){return this.models.get(e)?.getOpacity(t)||0}hasModel(e){return this.models.has(e)}setBuildingHeight(e,t){this.buildingsHeight.set(e,t)}getBuildingHeight(e){return this.buildingsHeight.get(e)||0}isHidden(e){return this.ids.isHidden(e)}getVisibleModelData(e){const t=this.models.get(e);if(!t)return;const i=t.getCurrentMod();if(!i||!i.ready)return;const o=Math.max(t.sourceModel.minZoom,i.minStyleZoom),a=Math.min(t.sourceModel.maxZoom,i.maxStyleZoom),{styleZoom:r}=this.mapState;if(!(r<o||r>=a))return{minStyleZoom:o,maxStyleZoom:a,opacity:this.getOpacity(e,o)}}isIdle(){return this.viewportModelsReady()&&!this.viewportModels.some(e=>e.isAnimating())}viewportModelsReady(){return this.viewportModels.every(e=>{const t=e.getUsefulMod();return t&&t.ready})}setHiddenBuildingIds(e){e.forEach(t=>{this.hiddenBuildingIds.add(t)})}unsetHiddenBuildingIds(e){e.forEach(t=>{this.hiddenBuildingIds.delete(t)})}findViewportModels(){const{styleZoom:e}=this.mapState;this.viewportModels=[],this.models.forEach(t=>{const{bound:i,minZoom:o,maxZoom:a}=t.sourceModel;if(e<o||e>=a)return;const r=this.mapState.styleState._activeFloorIds,l=t.attributes.db_hidden_by_plan_id;if(l&&r.includes(l)||this.modules.floorManager.hasDisplayedFloorBuilding([t.id])||!!!this.modules.assetManager.getMetatile(t.metatileHash)||this.hiddenBuildingIds.has(t.id))return;n.tetragonIntersectsBounds(this.mapState.tilesBounds,i)&&this.viewportModels.push(t)})}updateScene(){let e=!1;const t=new Map;this.viewportModels.forEach(i=>{const o=i.getCurrentMod();o&&o.ready&&t.set(o.key,o)}),this.displayedMods.forEach((i,o)=>{t.has(o)||(i.objects.length&&i.objects.forEach(a=>this.modules.tileManager.removeObject(a)),e=!0)}),t.forEach((i,o)=>{this.displayedMods.has(o)||(i.objects.length&&i.objects.forEach(a=>this.modules.tileManager.addObject(a)),e=!0),this.cache.get(o)}),e&&(this.displayedMods=t,this.modules.renderer.addRerenderEvent(),this.modules.identifier.resetCache())}cleanUnnessasaryModels(){const e=new Set(this.cache.getData().map(t=>t.model));this.models.forEach(t=>{e.has(t)||t.clean()})}loadModelsInfo(e,t,i){this.requestedModelsInfo.has(t)||(this.requestedModelsInfo.add(t),fetch(e).then(o=>{if(!o.ok)throw new Error(`Failed to load models info for region ${t}`);return o.json()}).then(o=>{o.forEach(a=>{if(!a.fileName){console.error(`ZBM source "fileName" is empty. Failed to load model by url: ${e}`);return}const r=new Mv(this.modules,this.mapState,this.cache,t,i,a);this.models.set(r.id,r)}),this.loadedModelsInfo.add(t)}).catch(o=>{this.loadedModelsInfo.add(t),console.error(o)}))}updateObjectsVisibility(){const e=this.ids;this.models.forEach(t=>{const i=this.getVisibleModelData(t.id)?.opacity||0,o=e.isHidden(t.id,n.HideLevel.PolygonExtrusion);i>=.5&&!o?e.hide([t.id],n.HideLevel.PolygonExtrusion):i<.5&&o&&e.show([t.id])})}}class Iv{constructor(e){this.modules=e,this.isIdle=()=>!this.isGenerating,this.modCache=new Map,this.isGenerating=!1,this.currentPois=[],this.currentIdSet=new Set,this.currentTrafficState=!1,this.currentSelectedIds=[],this.currentModKey=$r(this.currentTrafficState,this.currentSelectedIds),this.ids=e.identifier.getIdScope(n.DEFAULT_ID_SCOPE)}setPersonalPoi(e){this.currentPois=e;const t=new Set;for(const i of e)t.add(i.id);this.currentIdSet=t,this.modCache.clear(),this.displayedModKey=void 0}redraw(){this.modCache.clear(),this.displayedModKey=void 0}getIdentifyDataChunk(){return this.identifyDataChunk}update(){if(this.regionMetadata===void 0&&(this.regionMetadata=this.modules.assetManager.getProjectMetadata()),this.regionMetadata===void 0)return;this.updateModKey();const e=this.currentModKey,t=this.modCache.get(e);t===void 0&&!this.isGenerating&&this.generate(e,this.currentPois,this.regionMetadata),t!==void 0&&e!==this.displayedModKey&&this.show(e,t,this.regionMetadata)}generate(e,t,i){const{regionId:o,metatileHash:a}=i,r=this.modules.map.state;this.isGenerating=!0,this.modules.workers.parser.generatePersonalPoi(t,o,a,window.devicePixelRatio,this.ids.getSelected(),r.handyStyleId,r.styleState,this.modules.defaultSource.getId()).then(l=>{if(l===void 0){this.isGenerating=!1;return}const{collectorOutput:c,styleId:d}=l,{packedRasters:_,rastersToLoad:u}=c;_!==void 0&&this.modules.assetManager.prepareRasters(d,_),this.modules.assetManager.loadRasters(u),this.modCache.set(e,l),this.isGenerating=!1})}show(e,t,i){const{metatileHash:o}=i,{collectorOutput:{labels:a,identifyIds:r},styleId:l}=t;this.modules.labeler.removeLabels("ppoi"),a.length&&this.modules.labeler.addLabels("ppoi",n.LabelSource.PersonalPoi,[{metatileHash:o,labels:a,styleId:l}]),this.identifyDataChunk={metatileHash:o,ids:r},this.modules.identifier.resetCache(),this.displayedModKey=e}updateModKey(){const e=this.ids.getSelected().filter(i=>this.currentIdSet.has(i)),t=this.modules.trafficTileLayer.isEnabled();(!n.deepEqual(this.currentSelectedIds,e)||this.currentTrafficState!==t)&&(this.currentTrafficState=t,this.currentSelectedIds=e,this.currentModKey=$r(t,e))}}function $r(s,e){return`ppoi_${s}_${e.join("|")}`}let _n="./worker.js";function Cv(s){_n=s}function Lv(s,e){return{setMetatile:s.get(n.ThreadName.Parser,"setMetatile"),getMemoryFootprint:s.get(n.ThreadName.Parser,"getMemoryFootprint"),prepareAtlas:s.get(n.ThreadName.Parser,"prepareAtlas"),packRasters:s.get(n.ThreadName.Parser,"packRasters"),fetchTrafficTile:s.get(n.ThreadName.Parser,"fetchTrafficTile"),deleteTrafficTile:s.get(n.ThreadName.Parser,"deleteTrafficTile"),abortTrafficTileRequest:s.get(n.ThreadName.Parser,"abortTrafficTileRequest"),generateTrafficTile:s.get(n.ThreadName.Parser,"generateTrafficTile"),generatePersonalPoi:s.get(n.ThreadName.Parser,"generatePersonalPoi"),syncStyle:s.get(n.ThreadName.Parser,"syncStyle"),GeoJsonSource:e.set("GeoJsonSource",n.GeoJsonSourceWorker,void 0,["fetchTiles"]).get(n.ThreadName.Parser),ZenithSource:e.set("ZenithWorker",n.ZenithWorker,void 0,["fetchTiles"]).get(n.ThreadName.Parser),MeshElevationSource:e.set("MeshElevationWorker",n.MeshElevationWorker,void 0,["fetchTiles"]).get(n.ThreadName.Parser)}}function Pv(s){return{setCommercialPoiRandomSeed:s.get(n.ThreadName.Labeling,"setComPoiRandomSeed"),getMemoryFootprint:s.get(n.ThreadName.Labeling,"getMemoryFootprint"),appendFont:s.get(n.ThreadName.Labeling,"appendFont"),markFontAsLoaded:s.get(n.ThreadName.Labeling,"markFontAsLoaded"),addNewRasterSets:s.get(n.ThreadName.Labeling,"addNewRasterSets"),updatePackingInfo:s.get(n.ThreadName.Labeling,"updatePackingInfo"),syncStyle:s.get(n.ThreadName.Labeling,"syncStyle"),loadRtlPlugin:s.get(n.ThreadName.Labeling,"loadRtlPlugin"),markRtlPluginLoaded:s.get(n.ThreadName.Labeling,"markRtlPluginLoaded")}}function Bv(s){return{ModelsSource:s.set("ModelsWorker",n.ModelsWorker).get(n.ThreadName.Models)}}class zv{constructor(){this.connector=new n.MainConnector,this.fnRegistry=new n.FnRegistry(this.connector),this.classRegistry=new n.ClassRegistry(this.fnRegistry),this.parserWorker=new Worker(_n),this.labelingWorker=new Worker(_n),this.modelsWorker=new Worker(_n),this.parserWorker.postMessage({msg:{youare:"parser"}}),this.labelingWorker.postMessage({msg:{youare:"labeling"}}),this.connector.addWorker(n.ThreadName.Parser,this.parserWorker),this.connector.addWorker(n.ThreadName.Labeling,this.labelingWorker),this.modelsWorker.postMessage({msg:{youare:"models"}}),this.connector.addWorker(n.ThreadName.Models,this.modelsWorker),this.parser=Lv(this.fnRegistry,this.classRegistry),this.labeling=Pv(this.fnRegistry),this.models=Bv(this.classRegistry)}syncStyle(e){this.parser.syncStyle(e),this.labeling.syncStyle(e)}destroy(){this.parserWorker.terminate(),this.labelingWorker.terminate(),this.modelsWorker.terminate()}}let Go=(Lt=class extends n.Evented{constructor(e,t){super(),this.fogFactorBreakpoint=.4,this.demElevation=0,this.demTilesRevision=NaN,this.options=n.applyDefaults(t,Lt.options),this.uniqId=String(n.uniqId()),this.labelKey=`html-${this.uniqId}`,this.modules=e.modules;const i=n.Mercator.fromGeo(this.options.coordinates);this.position={userValue:i,normalizedValue:n.normalizeMapPoint(i)},this.screenPoint=[0,0],this.html=Rv(this.options),this.isHidden=!0,this.targetOpacity=0,this.modules.layers.addLayer(this),this.mapState=e.state,this.rounder=Fv(!this.options.disableRounding);let{offset:o}=this.options;const{labeling:a}=this.options;a.type!=="none"&&(a.offset!==void 0&&(o=a.offset),this.modules.labeler.addLabelBox(this.labelKey,{id:this.uniqId,width:a.width,height:a.height,position:this.position.normalizedValue,offset:o,labelingGroup:this.getLabelingGroup(),parentPoiId:a.type==="pinnedToPoi"?a.poiId:void 0}))}destroy(){this.removeHtml(),this.modules.labeler.removeLabels(this.labelKey),this.modules.layers.removeLayer(this)}update(){const e=this.checkZoom(),t=this.checkFog(),i=!this.isInvolvedInLabeling()||this.modules.labeler.isLabelBoxSurvived(this.uniqId);e&&t&&i?this.show():this.hide(),this.updatePosition()}setZIndex(e){this.options.zIndex=e,this.html.style.zIndex=String(e)}setContent(e){this.options.html=e,this.html.innerHTML="";const t=document.createElement("div");typeof e=="string"?t.innerHTML=e:t.append(e),this.html.append(t)}setLabelingSize(e,t){this.options.labeling.type!=="none"&&(this.options.labeling.width=e,this.options.labeling.height=t,this.updateLabelBox())}setPosition(e){const t=n.Mercator.fromGeo(e);this.position={userValue:t,normalizedValue:n.normalizeMapPoint(t)},this.mapState.demMode&&this.updateDemElevation(),this.updateLabelBox()}setOffset(e){this.options.offset=[e[0],e[1]],this.updateLabelBox()}setMinZoom(e){this.options.minZoom=e}setMaxZoom(e){this.options.maxZoom=e}getZIndex(){return this.options.zIndex}getOffset(){return this.options.offset}getPosition(){return n.Mercator.toGeo(this.position.userValue)}getHtmlElement(){return this.html.firstChild}dangerouslyGetRootElement(){return this.html}isShown(){return!this.isHidden}show(){if(this.isHidden&&(this.isHidden=!1,this.appendHtml(),this.emit("shown",{id:this.uniqId.toString(),point:[this.screenPoint[0],this.screenPoint[1]],object:this}),this.options.animate)){if(this.showAnimationTimer)return;this.hideAnimationTimer&&(clearTimeout(this.hideAnimationTimer),this.hideAnimationTimer=void 0),this.targetOpacity!==1&&(this.showAnimationTimer=window.setTimeout(()=>{this.setHtmlOpacity(1),this.showAnimationTimer=void 0},0))}}hide(){if(!this.isHidden)if(this.isHidden=!0,this.options.animate){if(this.hideAnimationTimer)return;this.showAnimationTimer&&(clearTimeout(this.showAnimationTimer),this.showAnimationTimer=void 0),this.setHtmlOpacity(0),this.hideAnimationTimer=window.setTimeout(()=>{this.removeHtml(),this.hideAnimationTimer=void 0},this.options.duration)}else this.removeHtml()}setHtmlOpacity(e){this.html.style.opacity=String(e),this.targetOpacity=e}removeHtml(){this.html.remove(),this.screenPoint=[0,0]}appendHtml(){this.getMarkerContainer().appendChild(this.html)}getMarkerContainer(){return this.options.preventMapInteractions?this.modules.layout.htmlContainerOutMap:this.modules.layout.htmlContainerInMap}updateDemElevation(){this.demElevation=this.modules.demManager.getElevation(this.position.normalizedValue)??0,this.demTilesRevision=this.modules.demManager.getTilesRevision()}nearCenterScreenPosition(){const e=this.modules.demManager,t=this.mapState;let i=0,o=0;if(t.demMode){const c=e.getTilesRevision();this.demTilesRevision!==c&&this.updateDemElevation(),i=(this.demElevation-(t.elevation??0))*t.elevationScale}this.options.floorId&&(o=this.modules.floorManager.getFloorObjectElevation(this.options.floorId,!0));const a=this.mapState.visibleMapReplicas.map(c=>{const d=[this.position.normalizedValue[0]+n.worldSize*c,this.position.normalizedValue[1],this.position.normalizedValue[2]+i*n.MAP_POINTS_IN_METER+o];return n.Mercator.toGeo(d,d),this.modules.camera.project(d,!0)}),r=a.map(c=>Math.abs(this.mapState.size[0]/2-(isNaN(c[0])?-1/0:c[0]))),l=r.findIndex(c=>c===Math.min(...r));return a[l]}updatePosition(){const e=this.nearCenterScreenPosition();this.html.hidden=Number.isNaN(e[0]),this.rounder(e,e[0]+this.options.offset[0],e[1]+this.options.offset[1],this.mapState.stillness),this.mapState.globeMode&&(this.html.hidden=!this.modules.camera.ecef.canSee(this.getPosition())),n.equals$1(this.screenPoint,e)||(this.html.style.transform=`translate3d(${e[0]}px, ${e[1]}px, 0px)`,this.screenPoint=e)}updateLabelBox(){if(this.options.labeling.type==="none")return;const{labeling:{width:e,height:t},offset:i}=this.options;this.modules.labeler.removeLabels(this.labelKey),this.modules.labeler.addLabelBox(this.labelKey,{id:this.uniqId,width:e,height:t,position:this.position.normalizedValue,offset:i,labelingGroup:this.getLabelingGroup(),parentPoiId:this.options.labeling.type==="pinnedToPoi"?this.options.labeling.poiId:void 0})}getLabelingGroup(){return this.isInvolvedInLabeling()?"markerText":"htmlLabel"}checkZoom(){const{zoom:e}=this.mapState,{minZoom:t,maxZoom:i}=this.options;return e>=t&&e<i}checkFog(){if(!this.modules.environmentManager.isFogEnabled()||this.mapState.globeMode)return!0;const{fogLimits:e}=this.modules.environmentManager,{fogDistance:t,position:i}=this.modules.camera,o=(this.position.normalizedValue[0]-i[0])/t,a=(this.position.normalizedValue[1]-i[1])/t,r=Math.sqrt(o**2+a**2),l=e[1]-e[0];return n.clamp((r-e[0])/l,0,1)<this.fogFactorBreakpoint}isInvolvedInLabeling(){return this.options.labeling.type==="full"||this.options.labeling.type==="pinnedToPoi"}},Lt.options={coordinates:[0,0],html:"",offset:[0,0],animate:!0,duration:500,labeling:{type:"none"},interactive:!0,preventMapInteractions:!1,zIndex:0,minZoom:-1/0,maxZoom:1/0,disableRounding:!1,floorId:""},Lt);function Rv(s){const e=document.createElement("div");e.style.position="absolute",e.style.top="0",e.style.left="0",e.style.zIndex=String(s.zIndex),s.interactive||(e.style.pointerEvents="none"),s.animate&&(e.style.opacity="0",e.style.transition=`opacity ${s.duration}ms`,e.style.willChange="opacity");const t=document.createElement("div");return typeof s.html=="string"?t.innerHTML=s.html:t.append(s.html),e.append(t),e}function Fv(s){return s?Dv:Ov}const Dv=(s,e,t,i)=>{const o=Math.round(e),a=Math.round(t),r=o-e,l=a-t;s[0]=e+i*r,s[1]=t+i*l},Ov=(s,e,t)=>{s[0]=e,s[1]=t},Nv="#0085a0",kv="#ffffff",Uv=4,Gv=1,Hv=2,Vv=1.5,jv=2.8,Xr=6,Zv=!0,Wv=17.1,Ho=n.entranceAnimation.iterationCount,Vo=n.create$1();class Kr extends Re{constructor(e,t){super(e,{interactive:!1}),this.options=t,this.vectors=this.options.coordinates.map(p=>p.map(v=>n.Mercator.fromGeo(v))),this.bouncePosition=0,this.growPosition=1;const{tileManager:i,dynamicStyle:o,collector:a,layers:r}=this.modules,l=this.options.animate??Zv;let c;if(l&&!this.mapState.disableLayerAnimation){const p=this.options.iterationCount??Ho;p>1?c={type:"repeat",tipMovementAmplitude:this.options.tipMovementAmplitude||Xr,iterationCount:p}:p===1&&(c={type:"appearance",tipMovementAmplitude:this.options.tipMovementAmplitude||Xr})}const d=n.makeHandyStyleLayer({type:"arrow",id:`dynamic-entrance-${this.uniqId}`,minzoom:this.options.minZoom??Wv,maxzoom:this.options.maxZoom,style:{color:this.options.color??Nv,strokeColor:this.options.borderColor??kv,lineWidth:this.options.width??Uv,strokeWidth:this.options.borderWidth??Gv,tipWidth:this.options.wingWidthMultiplier??Vv,tipHeight:this.options.tipHeightMultiplier??jv,roundingRadius:this.options.roundingRadius??Hv,animation:c}});if(!d)return;o.addLayer(d,this.options.zIndex),this.layerId=d.innerId;const _=this.getTileInfo(),u=[],h=n.makeGeneratorContext(this.mapState.styleState,n.emptySourceAttrs,n.fixedTileProps,u,n.emptyFeatureAttrs);n.runPrecomputes(d,h);for(let p=0;p<this.vectors.length;p++){const v=this.vectors[p],y=this.getVertices(v,_);h.id=String(p),n.generateSafely({collector:a,generator:n.ArrowGenerator.generate,args:[o.getStyle().id,d,h,y]})}const f=a.getAccumulatedData(),m=new n.TileObject("dynamicObject",f.data,this.modules,this.mapState,_.coords,this);this.tileObjects.push(m),i.addObject(m),this.identifyIds.push(f.identifyIds),l&&!this.mapState.disableLayerAnimation?(this.bounceTickerId=`entrance-bounce-${this.uniqId}`,this.growTickerId=`entrance-grow-${this.uniqId}`,this.bounceTickerUpdate=n.update.bind(null,this.bounceTickerId,{step:(p,v)=>this.bouncePosition=v,complete:()=>{this.bounceTickerUpdate=void 0}},this.mapState),this.growTickerUpdate=n.update.bind(null,this.growTickerId,{step:(p,v)=>this.growPosition=v,complete:()=>{this.growTickerUpdate=void 0}},this.mapState),n.start(this.bounceTickerId,{easing:n.entranceAnimation.bounceType},this.mapState,-1,0,n.entranceAnimation.bounceTime,this.options.iterationCount??Ho,{layerId:this.layerId,styleId:o.getStyle().id}),n.start(this.growTickerId,{easing:n.entranceAnimation.growType},this.mapState,0,1,n.entranceAnimation.growTime,this.options.iterationCount??Ho,{layerId:this.layerId,styleId:o.getStyle().id})):(this.bouncePosition=0,this.growPosition=1),r.addLayer(this),a.reset(),this.modules.renderer.addRerenderEvent()}update(){super.update(),this.stopTickersOnGlobalAnimationDisabling(),this.bounceTickerUpdate&&this.bounceTickerUpdate(),this.growTickerUpdate&&this.growTickerUpdate()}isOutOfMainReplica(){return!1}entranceAnimationInProgress(){return this.bounceTickerUpdate!==void 0||this.growTickerUpdate!==void 0}remove(){this.destroy()}destroy(){this.bounceTickerUpdate=void 0,this.growTickerUpdate=void 0,this.bounceTickerId&&n.stop(this.bounceTickerId,this.mapState),this.growTickerId&&n.stop(this.growTickerId,this.mapState),this.layerId!==void 0&&this.modules.dynamicStyle.removeLayer(this.layerId),super.destroy()}getTileInfo(){const e=n.create();for(let t=0;t<this.vectors.length;t++){const i=this.vectors[t];for(let o=0;o<i.length;o++)n.expandByPoint(e,i[o])}return n.createTileInfo(n.getBoundsTileCoords(e))}getVertices(e,t){const i=[],o=[];for(let a=0;a<e.length;a++)n.mapPointToTilePoint(Vo,e[a],t),i[a]=Vo[0],o[a]=Vo[1];return{x:i,y:o}}stopTickersOnGlobalAnimationDisabling(){this.mapState.disableLayerAnimation&&(this.bounceTickerId&&(this.bounceTickerUpdate=void 0,n.stop(this.bounceTickerId,this.mapState)),this.growTickerId&&(this.growTickerUpdate=void 0,n.stop(this.growTickerId,this.mapState)))}}class $v{constructor(e){this.layers=[],this.renderer=e.renderer}addLayer(e){this.layers.push(e),this.renderer.addRerenderEvent()}removeLayer(e){const t=this.layers.indexOf(e);t!==-1&&(this.layers.splice(t,1),this.renderer.addRerenderEvent())}getLayers(){return this.layers}getDynamicObjectLayers(){return this.layers.filter(e=>e instanceof Re)}getHtmlMarkers(){return this.layers.filter(e=>e instanceof Go)}entranceAnimationFinished(){return this.layers.every(e=>e instanceof Kr?!e.entranceAnimationInProgress():!0)}}const qr=()=>"",Xv=[.5,.5];class Kv{constructor(e){this.loadingCounter=0,this.isIdle=()=>this.loadingCounter===0,this.modules=e,this.cache={}}async getRasterSet(e,t,i,o){const a=this.getKey(e,i,o),r=this.getFromCache(a,t);if(r)return r;const l=await this.loadIcon(e,t,i,o);return l&&this.storeInCache(l,a,t),l}clear(){this.cache={}}decreaseLoadingCounter(){this.loadingCounter=Math.max(this.loadingCounter-1,0)}async loadIcon(e,t,i,o){const{dynamicStyle:a,workers:r,assetManager:l}=this.modules;let c=e;this.loadingCounter++,t&&(c=await this.loadImageForTransformer(e).then(_=>t(_)).catch(()=>e));const d=await this.loadImage(c);return d?Promise.resolve().then(()=>{i=i!==void 0?i:[d.width,d.height];const _=o!==void 0?[o[0]/i[0],o[1]/i[1]]:Xv,u=[i[0]*window.devicePixelRatio,i[1]*window.devicePixelRatio],h=n.createLoadedRasterSet([{w:u[0],h:u[1],x:0,y:0,atlasIndex:0,isPacked:!1,anchorX:_[0],anchorY:_[1]}]);a.appendRasterSet(h),r.labeling.addNewRasterSets(a.getStyle().id,[h]);const f=new Uint16Array(3);return f[0]=u[0],f[1]=u[1],f[2]=h.index,r.parser.packRasters(f).then(m=>({packedRasters:m.packedRasters,rasterSet:h,scaledSize:u}))}).then(_=>{const{packedRasters:u,rasterSet:h,scaledSize:f}=_;return u!==void 0&&l.prepareRasters(a.getStyle().id,u,[fr(d,f)]),this.decreaseLoadingCounter(),h}):(this.decreaseLoadingCounter(),Promise.resolve(void 0))}getFromCache(e,t){const i=this.cache[e];if(i)return i.get(t||qr)}storeInCache(e,t,i){this.cache[t]||(this.cache[t]=new Map),this.cache[t].set(i||qr,e)}getKey(e,t,i){const o=t!==void 0?`${t[0]},${t[1]}`:"",a=i!==void 0?`${i[0]},${i[1]}`:"";return`${e}_${o}_${a}`}loadImage(e){return new Promise(t=>{const i=new Image;i.crossOrigin="Anonymous",i.src=e,i.onload=()=>t(i),i.onerror=()=>t(void 0)})}loadImageForTransformer(e){return e.indexOf(".svg")===-1?new Promise(t=>{const i=new Image;i.crossOrigin="Anonymous",i.src=e,i.onload=()=>{t({type:"raster",source:i})},i.onerror=()=>{t({type:"unknown"})}}):new Promise(t=>{const i=new XMLHttpRequest;i.open("GET",e,!0),i.onload=function(){if(i.status!==200||i.response.byteLength===0){t({type:"unknown"});return}t({type:"vector",source:i.response})},i.onerror=function(){t({type:"unknown"})},i.send()})}}const Yr={trafficOn:!1,parkingOn:!1,navigatorOn:!1,immersiveRoadsOn:!1,floorStackOn:!1,terrainEnabled:!1,graphicsPreset:Bt()?"light":"immersive",_activeFloorIds:[],_activeFloorBuildingIds:[],_activeFloorIsMetro:!1,_floorHeight:3.5,_customUserTimeOffset:0};let un=!1;function qv(){return{...Yr}}function hn(s,e){return s={...s},e?.immersiveRoadsOff===!0?(un=!0,s.immersiveRoadsOn=!1):un&&(s.immersiveRoadsOn=un,un=!1),s.graphicsPreset&&s.graphicsPreset!=="light"&&Bt()&&(console.warn(`"${String(s.graphicsPreset)}" graphicsPreset is not supported in deprecated system. Using "light" instead.`),s.graphicsPreset="light"),{...Yr,...s}}function Qr(s,e,t){const i={...s,...e,_activeFloorIds:s._activeFloorIds,_activeFloorBuildingIds:s._activeFloorBuildingIds,_activeFloorIsMetro:s._activeFloorIsMetro,_floorHeight:s._floorHeight};return hn(i,t)}function Jr(s,e=[],t=[],i=!1){return{...s,_activeFloorIds:e,_activeFloorBuildingIds:t,_activeFloorIsMetro:i}}const Ar=["default","metro"],jo="floorStackTicker",Yv=500,fn={MAX_DISTANCE_METERS:500,VERY_CLOSE_DISTANCE_METERS:500,DISTANCE_WEIGHT_MULTIPLIER:3,VERY_CLOSE_BONUS:1.5};class Qv{constructor(e,t){this.state=e,this.modules=t,this.repository={descriptors:{default:new Map,metro:new Map},requestedFloors:new Set,failedRequestedFloors:new Set,floorIdsToObjectIds:new Map},this.stateDiffer=new n.Differ([{path:"center",type:"vec2"},{path:"zoom",type:"number"},{path:"size",type:"vec2"},{path:"rotation",type:"number"},{path:"pitch",type:"number"},{path:"padding",type:"padding"},{path:"demMode",type:"boolean"}]),this.stack={readiness:0,offsets:new Map,maxOffset:1},this.viewport={index:{metro:n.rbush(),default:n.rbush()},metro:{in:null,current:null,out:null},default:{in:null,current:null,out:null}},this.displayedComplex=null,this.needUpdate=!1,this.allowedFloors=new Set,this.hiddenObjectIds=new Set,this.pendingUpdateCall=!1,this.ids={default:t.identifier.getIdScope(n.DEFAULT_ID_SCOPE),floor:t.identifier.getIdScope(n.FLOOR_ID_SCOPE)};const i=n.throttle(this._update.bind(this),60);this.prevStyleState=this.state.styleState,this.update=()=>{this.updateReadiness();const o=this.needUpdate||this.stateDiffer.check(this.state);o&&(this.pendingUpdateCall=!0,i()),(o||this.prevStyleState!==this.state.styleState)&&(this.updateStyleState(),this.prevStyleState=this.state.styleState),o&&this.updateHiddenIds()}}get maxFloorOffset(){const e=this.state.styleState._floorHeight??0;return Math.floor(n.floors.maxStackHeight/e)}get floorHeight(){const e=this.state.styleState._floorHeight??0,t=n.Mercator.toGeo(this.state.center);return n.geoToMapDistance(t,e)}get isMetroEnabled(){return this.state.allowMetro&&this.state.styleZoom>=n.floors.displayStyleZoom.metro}get isDefaultEnabled(){return this.state.styleZoom>=n.floors.displayStyleZoom.default}get isEnabled(){return this.state.floorsEnabled&&(this.isDefaultEnabled||this.isMetroEnabled)}get isStackEnabled(){return!this.state.demMode&&this.state.styleState.floorStackOn&&this.floorHeight>0}get shouldIgnoreFloorState(){return!!this.state.resetFloorModeOnActivation}get hiddenBuildingIds(){if(!this.displayedComplex||this.displayedComplex.mode==="building"||this.activeFloorIdx===void 0)return[];const e=this.displayedComplex.floors[this.activeFloorIdx];if(!e)return[];const t=[];if(e.id&&t.push(this.displayedComplex.id),!e.linked_floors_ids)return t;const i=this.repository.descriptors.default.has(this.displayedComplex.id)?"default":"metro";return this.displayedComplex.buildings.filter(o=>{const a=this.repository.descriptors[i].get(o);return e.linked_floors_ids.some(r=>a?.floorIds.includes(r))}).forEach(o=>t.push(o)),t}getActiveFloorHiddenIds(){const e=this.ids.default.getRelatedChildrenIds(this.hiddenObjectIds);return Array.from(this.hiddenObjectIds).concat(e)}prepareFloors(e,t,i,o){o==="zenith"&&i.forEach((a,r)=>{let l=this.repository.floorIdsToObjectIds.get(r);l===void 0&&(l=new Set,this.repository.floorIdsToObjectIds.set(r,l));for(const c of a)l.add(c);this.loadFloor(r,e,t)})}changeFloorNumber(e,t){const i=this.viewport.default.current,o=this.viewport.metro.current,a=i||o;if(a&&(a.id===e||a.buildings.includes(e)))if(this.needUpdate=!0,t==="metro"){if(!o)return;o.mode="metro",this.displayedComplex&&this.modules.map.emit("floorcomplexhide",{id:this.displayedComplex.id}),this.displayedComplex=o,this.setFloorIdx(o.defaultFloor),this.modules.map.emit("floorcomplexshow",{id:o.id,mode:"metro",currentFloor:o.defaultFloor,floorNames:o.floors.map(r=>r.name),firmsToFloorIndexMap:o.firmsToFloorIndexMap})}else if(t==="building")o&&(o.mode="floor"),a.mode="building",this.displayedComplex=null,this.modules.map.emit("floorcomplexhide",{id:e});else{if(t<0||t>=a.floors.length)return;this.setFloorIdx(t),a.selectedFloorIdx=t,o&&o.mode==="metro"&&(o.mode="floor",this.modules.map.emit("floorcomplexhide",{id:o.id})),this.displayedComplex!==a&&!this.displayedComplex?.buildings.includes(a.id)&&this.modules.map.emit("floorcomplexshow",{id:a.id,mode:"floor",currentFloor:t,floorNames:a.floors.map(({name:r})=>r),firmsToFloorIndexMap:a.firmsToFloorIndexMap}),this.displayedComplex=a,this.updateStackState(),a.mode="floor",this.modules.map.emit("floorcomplexlevelchange",{id:e,floorIndex:t,floorName:a.floors[t].name})}}hasDisplayedFloorBuilding(e){if(!this.displayedComplex||this.displayedComplex.mode==="building")return!1;for(const t of this.hiddenBuildingIds){const i=this.repository.floorIdsToObjectIds.get(t);if(i&&(Array.isArray(e)&&e.some(o=>i.has(o))||typeof e=="string"&&i.has(e)))return!0}return!1}floorsReady(){return!this.pendingUpdateCall&&Array.from(this.repository.requestedFloors).every(e=>this.repository.failedRequestedFloors.has(e)||this.repository.descriptors.default.has(e)||this.repository.descriptors.metro.has(e))}setAllowedFloorIds(e){this.allowedFloors=new Set(e??[]),this.needUpdate=!0}isVisibleFloorObject(e){return this.displayedComplex?this.state.styleState._activeFloorIds.includes(e):!1}isVisibleFloorStackObject(e){if(!this.isStackEnabled||!this.displayedComplex||this.activeFloorIdx===void 0)return!1;let t=!1;for(const a of this.hiddenBuildingIds){if(t)break;t=!!this.repository.descriptors.default.get(a)?.floors.some(l=>l.id===e)}if(!t)return!1;const i=this.activeFloorIdx-this.displayedComplex.defaultFloor,o=this.stack.offsets.get(e);return o<this.maxFloorOffset&&i>0&&o>=0&&o<i}getFloorObjectElevation(e,t){if(!this.isStackEnabled||!this.stack.offsets.has(e))return 0;const i=this.stack.offsets.get(e),o=this.floorHeight*i;return i<=0?0:i>this.maxFloorOffset?this.floorHeight*this.maxFloorOffset:t?o:n.lerp$2((i-1)/i,1,this.stack.readiness)*o}getFloorStackObjectElevation(e){return this.stack.offsets.has(e)?this.stack.offsets.get(e)*this.floorHeight:0}getFloorsStackObjectOffsets(e){return this.stack.offsets.has(e)?{current:this.stack.offsets.get(e),total:this.stack.maxOffset}:{current:0,total:1}}getPlanLevels(){return this.isStackEnabled?Object.fromEntries(this.stack.offsets):{}}getFloorStackObjectHeight(e){return!this.isStackEnabled||this.displayedComplex.floors.findIndex(i=>i.id===e||i.linked_floors_ids?.includes(e))<this.activeFloorIdx-1?1:this.stack.readiness}_update(){this.pendingUpdateCall=!1,this.updateViewport();const e=!!(this.viewport.default.out&&this.viewport.default.in&&this.viewport.default.in.buildings.includes(this.viewport.default.out.id));this.viewport.default.out?e||this.modules.map.emit("floorcomplexout",{id:this.viewport.default.out.id}):this.viewport.metro.out&&this.modules.map.emit("floorcomplexout",{id:this.viewport.metro.out.id}),this.displayedComplex&&(!e&&this.viewport.default.out&&(this.displayedComplex===this.viewport.default.out||this.displayedComplex.buildings.includes(this.viewport.default.out.id))&&this.displayedComplex.mode==="floor"?(this.modules.map.emit("floorcomplexhide",{id:this.displayedComplex.id}),this.displayedComplex=null):this.displayedComplex===this.viewport.metro.out&&this.displayedComplex.mode==="metro"&&(this.modules.map.emit("floorcomplexhide",{id:this.displayedComplex.id}),this.displayedComplex=null));let t=null;const i=this.viewport.default.in||this.viewport.default.current,o=this.viewport.metro.in||this.viewport.metro.current,a=!e&&this.viewport.default.in||this.viewport.metro.in||this.viewport.default.out&&this.viewport.metro.current;if(i){const r=this.shouldIgnoreFloorState?"building":i.mode;t={id:i.id,mode:r==="floor"?"floor":"building",currentFloor:i.selectedFloorIdx,floorNames:i.floors.map(l=>l.name),firmsToFloorIndexMap:i.firmsToFloorIndexMap},this.viewport.metro.current&&((this.shouldIgnoreFloorState?"building":this.viewport.metro.current.mode)==="metro"&&(t.mode="metro"),t.metro={id:this.viewport.metro.current.id,floorNames:this.viewport.metro.current.floors.map(c=>c.name)})}if(o){if(t){t.metro={id:o.id,floorNames:o.floors.map(l=>l.name)};for(const l in o.firmsToFloorIndexMap)t.firmsToFloorIndexMap[l]=o.firmsToFloorIndexMap[l];o.mode==="metro"&&(t.mode="metro")}else t={id:o.id,mode:"building",currentFloor:o.defaultFloor,floorNames:[],firmsToFloorIndexMap:o.firmsToFloorIndexMap,metro:{id:o.id,floorNames:o.floors.map(l=>l.name)}};(this.shouldIgnoreFloorState?"building":o.mode)==="metro"&&(t.mode="metro")}t&&a&&this.modules.map.emit("floorcomplexin",t),this.displayFloorComplex(),this.needUpdate=!1}loadFloor(e,t,i){if(this.repository.requestedFloors.has(e))return;const o=n.getUrl("floorMeta",{protocol:this.state.tileProtocol,tileSet:this.state.tileSet,host:this.state.tileServer,subdomain:this.state.subdomains[0],regionId:t.toString(10),floorComplexId:e});this.repository.requestedFloors.add(e),fetch(o).then(a=>{if(a.ok===!1)throw new Error(a.statusText);return a.json()}).then(a=>{let r=a.default_floor_idx,l="default";"is_metro"in a&&a.is_metro&&(r=a.default_metro_floor_idx,l="metro");const c=a.floors.reduce((_,u,h)=>(u.id&&(_[u.id]=h),_),{}),d={id:e,regionId:t,metatileHash:i,center:a.center,bound:a.bound,defaultFloor:r,selectedFloorIdx:r,mode:"floor",floors:a.floors,floorIds:a.floors.map(_=>_.id).filter(Boolean),buildings:a.linked_buildings_ids?a.linked_buildings_ids.concat(e):[e],firmsToFloorIndexMap:Object.entries(a.firm_id_to_floor_id??{}).reduce((_,[u,h])=>(_[u]=c[h],_),{})};this.repository.descriptors[l].set(e,d),this.viewport.index[l].insert({complex:d,minX:d.bound.min[0],minY:d.bound.min[1],maxX:d.bound.max[0],maxY:d.bound.max[1]}),this.needUpdate=!0}).catch(()=>{this.repository.failedRequestedFloors.add(e)})}updateStackState(){if(this.stack.offsets.clear(),!this.displayedComplex)return;let e=1;this.displayedComplex.floors.forEach((t,i)=>{const o=i-this.displayedComplex.defaultFloor;t.id&&this.stack.offsets.set(t.id,o),o>e&&(e=o),t.linked_floors_ids?.forEach(a=>{this.stack.offsets.set(a,o)})}),this.stack.maxOffset=e}updateStyleState(){const{styleState:e}=this.state;if(!this.displayedComplex){(Array.isArray(e._activeFloorIds)&&e._activeFloorIds.length>0||Array.isArray(e._activeFloorBuildingIds)&&e._activeFloorBuildingIds.length>0)&&(this.state.styleState=Jr(e,[],[],!1));return}const t=new Set,i=new Set,o=new Set(this.state.styleState._activeFloorIds),a=new Set(this.state.styleState._activeFloorBuildingIds),r=e._activeFloorIsMetro===!0,l=this.displayedComplex;if(!l||this.activeFloorIdx===void 0||l.mode==="building")return;const c=l.floors[this.activeFloorIdx];c&&(c.id&&t.add(c.id),c.linked_floors_ids?.forEach(d=>{t.add(d)}),this.hiddenBuildingIds.forEach(d=>i.add(d)),(el(o,t)||el(a,i)||r!==(this.displayedComplex.mode==="metro"))&&(this.state.styleState=Jr(e,Array.from(t),Array.from(i),this.displayedComplex.mode==="metro")))}updateHiddenIds(){if(!this.displayedComplex){this.markHiddenObjectsForUpdate();return}const e=new Set;this.hiddenBuildingIds.forEach(t=>{const i=this.repository.floorIdsToObjectIds.get(t);i&&i.forEach(o=>e.add(o))}),this.markHiddenObjectsForUpdate(e)}markHiddenObjectsForUpdate(e){if(e){const t=this.ids.default.getHidden(n.HideLevel.PolygonExtrusion),i=n.subtract(e,t),o=n.subtract(this.hiddenObjectIds,e);this.ids.default.hide(Array.from(i),n.HideLevel.PolygonExtrusion);const a=this.ids.floor.getHidden(),r=n.intersection$1(i,a);this.ids.default.hide(Array.from(r),n.HideLevel.All),this.ids.default.show(Array.from(o)),this.hiddenObjectIds=new Set(e)}else this.ids.default.show(Array.from(this.hiddenObjectIds)),this.hiddenObjectIds.clear()}updateReadiness(){n.update(jo,{step:(e,t)=>this.stack.readiness=t},this.state)}setFloorIdx(e){this.prevActiveFloorIdx=this.activeFloorIdx,this.activeFloorIdx=e,!Number.isNaN(e)&&this.isStackEnabled&&this.prevActiveFloorIdx!==void 0&&this.activeFloorIdx>this.prevActiveFloorIdx?(this.stack.readiness=0,n.start(jo,{easing:"easeOutQuint"},this.state,0,1,Yv,1)):(this.stack.readiness=1,n.stop(jo,this.state))}updateViewport(){if(!this.isEnabled){this.viewport.default={in:null,current:null,out:this.viewport.default.current},this.viewport.metro={in:null,current:null,out:this.viewport.metro.current};return}const e={default:null,metro:null},{center:t,zoom:i,rotation:o,size:a,viewport:r,padding:l,cameraConfig:c,globeMode:d}=this.state,_=new n.Camera({center:t,zoom:i,rotation:o,size:[Math.floor(a[0]*(1-n.floors.viewportPadding)),Math.floor(a[1]*(1-n.floors.viewportPadding))],styleState:{},pitch:0,viewport:r,padding:l,cameraConfig:c,globeMode:d}),u=_.getViewportVertices().map(m=>[m[0],m[1]]),h=Jv(u),f=[[0,0],[0,0],[0,0],[0,0]];Ar.forEach(m=>{if(m==="default"&&!this.isDefaultEnabled||m==="metro"&&!this.isMetroEnabled)return;const p=this.viewport.index[m].search(h);let v,y;for(const b of p){if(this.allowedFloors.size>0&&!this.allowedFloors.has(b.complex.id))continue;const x=b.complex.bound;if(Av(_.position,x)){if(v){const M=tl(x);M<v.complexArea&&(v.complex=b.complex,v.complexArea=M)}else v={complex:b.complex,complexArea:tl(x)};continue}f[0][0]=x.min[0],f[0][1]=x.min[1],f[1][0]=x.max[0],f[1][1]=x.min[1],f[2][0]=x.max[0],f[2][1]=x.max[1],f[3][0]=x.min[0],f[3][1]=x.max[1];const T=eg(f,u);if(T.length<3)continue;const w=ig({complex:b.complex,cameraPosition:_.position,intersectionPolygon:T});y?y.score<w&&(y.complex=b.complex,y.score=w):y={complex:b.complex,score:w}}v?e[m]=v.complex:y&&(e[m]=y.complex)}),Ar.forEach(m=>{const p=this.viewport[m].current,v=e[m];this.shouldIgnoreFloorState&&v&&v!==p&&(v.mode="building"),this.viewport[m].out=p!==v?p:null,this.viewport[m].in=v!==p?v:null,this.viewport[m].current=v})}displayFloorComplex(){const e=this.viewport.default.current,t=this.viewport.metro.current;if(t&&t.mode==="metro"){if(t===this.displayedComplex)return;this.displayedComplex=t,this.setFloorIdx(t.defaultFloor),this.modules.map.emit("floorcomplexshow",{id:t.id,mode:"metro",currentFloor:t.defaultFloor,floorNames:t.floors.map(i=>i.name),firmsToFloorIndexMap:t.firmsToFloorIndexMap}),this.updateStyleState()}else if(e&&e.mode==="floor"){if(e===this.displayedComplex||this.displayedComplex?.buildings.includes(e.id))return;this.displayedComplex=e,this.updateStackState(),this.setFloorIdx(this.displayedComplex.selectedFloorIdx),this.modules.map.emit("floorcomplexshow",{id:e.id,mode:"floor",currentFloor:e.selectedFloorIdx,floorNames:e.floors.map(i=>i.name),firmsToFloorIndexMap:e.firmsToFloorIndexMap}),this.updateStyleState()}}}function el(s,e){if(s.size!==e.size)return!0;for(const t of s)if(!e.has(t))return!0;return!1}function Jv(s){let e=s[0][0],t=s[0][1],i=e,o=t;for(let a=1;a<s.length;a++){const[r,l]=s[a];r<e?e=r:r>i&&(i=r),l<t?t=l:l>o&&(o=l)}return{minX:e,minY:t,maxX:i,maxY:o}}function Av(s,e){return s[0]>=e.min[0]&&s[0]<=e.max[0]&&s[1]>=e.min[1]&&s[1]<=e.max[1]}function tl(s){return(s.max[0]-s.min[0])*(s.max[1]-s.min[1])}function eg(s,e){let t=s;for(let a=0;a<e.length;a++){const r=e[a],l=e[(a+1)%e.length],c=t;t=[];for(let d=0;d<c.length;d++){const _=c[d],u=c[(d+1)%c.length];i(u,r,l)?(i(_,r,l)||t.push(o(_,u,r,l)),t.push(u)):i(_,r,l)&&t.push(o(_,u,r,l))}}return t;function i(a,r,l){return(l[0]-r[0])*(a[1]-r[1])>(l[1]-r[1])*(a[0]-r[0])}function o(a,r,l,c){const d=r[1]-a[1],_=a[0]-r[0],u=d*a[0]+_*a[1],h=c[1]-l[1],f=l[0]-c[0],m=h*l[0]+f*l[1],p=d*f-h*_;return p===0?r:[(f*u-_*m)/p,(d*m-h*u)/p]}}function tg(s){let e=0;for(let t=0,i=s.length-1;t<s.length;i=t++)e+=(s[i][0]+s[t][0])*(s[i][1]-s[t][1]);return Math.abs(e/2)}function ig(s){const e=Math.sqrt((s.complex.center[0]-s.cameraPosition[0])**2+(s.complex.center[1]-s.cameraPosition[1])**2),t=e/(fn.MAX_DISTANCE_METERS*n.MAP_POINTS_IN_METER),i=Math.max(0,1-t),o=e<fn.VERY_CLOSE_DISTANCE_METERS*n.MAP_POINTS_IN_METER?fn.VERY_CLOSE_BONUS:1;return tg(s.intersectionPolygon)*o*(1+i*fn.DISTANCE_WEIGHT_MULTIPLIER)}class ng{constructor(e,t){this.state=e,this.modules=t,this.tileLayers=[],this.objects=[],this.viewportDiffer=new n.Differ([{path:"center",type:"vec3"},{path:"zoom",type:"number"},{path:"size",type:"vec2"},{path:"rotation",type:"number"},{path:"pitch",type:"number"},{path:"padding",type:"padding"},{path:"demMode",type:"boolean"},{path:"globeMode",type:"boolean"},{path:"elevation",type:"number"},{path:"minElevation",type:"number"},{path:"handyStyleId",type:"string"}])}getMemoryFootprint(e=()=>!0){const t={tileLayers:this.tileLayers.filter(e).map(o=>({[o.getSourceType()]:o.memSizeJs()})),objects:this.objects.filter(o=>o.purpose==="dynamicObject").map(o=>({[o.purpose]:n.tileObjectStatsJS(o)}))},i={tileLayers:this.tileLayers.filter(e).map(o=>({[o.getSourceType()]:o.memSizeGpu()})),objects:this.objects.filter(o=>o.purpose==="dynamicObject").map(o=>({[o.purpose]:n.tileObjectStatsGpu(o)}))};return{js:{...t,"--sum":n.getTotalMemory(t)},gpu:{...i,"--sum":n.getTotalMemory(i)}}}addTileLayer(e){this.tileLayers.indexOf(e)===-1&&(this.tileLayers.push(e),e.redraw(),this.modules.identifier.resetCache(),this.state.needLabeling=!0,this.modules.renderer.addRerenderEvent())}removeTileLayer(e){n.excludeItemFromArray(this.tileLayers,e)&&(e.resetHoverId(),this.modules.identifier.resetCache(),this.state.needLabeling=!0,this.modules.renderer.addRerenderEvent())}redraw(){this.modules.labeler.clearPreviousLabels();for(const e of this.tileLayers)e.resetHoverId(),e.redraw();this.modules.renderer.addRerenderEvent()}activateStyleUpdating(){this.tileLayers.forEach(e=>e.activateStyleUpdating())}finishStyleUpdating(){this.tileLayers.forEach(e=>e.finishStyleUpdating())}getViewportTiles(){const e=[];for(const t of this.tileLayers)e.push(...t.getViewportTiles());return e}viewportTilesReady(){return this.tileLayers.every(e=>e.viewportTilesReady())}displayedTilesAnimationFinished(){return this.tileLayers.every(e=>e.displayedTilesAnimationFinished())}getDisplayedIdentifyData(){const e=[];for(const t of this.tileLayers)e.push(...t.getDisplayedIdentifyData());return e}getLabelingData(){return this.tileLayers.map(e=>e.getLabelingData())}isIdle(){return this.viewportTilesReady()&&this.displayedTilesAnimationFinished()}update(){const e=this.state;this.viewportDiffer.check(e)&&(this.tileLayers.forEach(t=>t.updateViewport()),this.modules.map.emit("viewportchange"));for(const t of this.tileLayers)t.update();if(this.updateTickers(),e.collectStats){this.state.stats.tileCount=0;for(const t of this.tileLayers)this.state.stats.tileCount+=t.getTileCount();this.state.stats.globeTileCount=this.objects.filter(t=>t.purpose==="globe").length,this.state.stats.dynamicTileCount=this.objects.filter(t=>t.purpose==="dynamicObject"||t.purpose==="floor").length}}getTileObjects(){return this.objects}addObject(e,t){if(this.objects.indexOf(e)===-1){if(this.objects.push(e),t)return;this.modules.renderer.addRerenderEvent()}}removeObject(e,t){if(n.excludeItemFromArray(this.objects,e)){if(t)return;this.modules.renderer.addRerenderEvent()}}getCachedMods(){const e=[];for(const t of this.tileLayers){const i=t.gridState.tileModsCache.getData();for(const o of i)e.push(o)}return e}destroy(){for(const e of this.tileLayers)e.destroy();this.objects.forEach(e=>e.clean(this.state))}updateTickers(){this.objects.forEach(e=>e.updateTicker(this.state))}}const og=(s,e,t,i,o)=>{n.start("labelingOpacity",{easing:e},s,t,i,o,1)},sg=n.update.bind(null,"labelingOpacity",{step:(s,e)=>s.labelingOpacity=e});function ag(s){return s?Object.keys(s).map(Number).sort((e,t)=>e-t):[]}function rg(s,e){const{config:t,ascSortedZoomNumbers:i}=e;if(i.length===0)return{city:n.labeling.commercialMargins.city};if(s<i[0])return{city:t[i[0]]};if(s>=i[i.length-1])return{city:t[i[i.length-1]]};for(let o=1;o<i.length;o++)if(s<i[o])return{city:t[i[o-1]]};return{city:n.labeling.commercialMargins.city}}const lg=s=>({appendLabels:s.get(n.ThreadName.Labeling,"appendLabels"),appendLabelBox:s.get(n.ThreadName.Labeling,"appendLabelBox"),removeLabels:s.get(n.ThreadName.Labeling,"removeLabels"),processLabels:s.get(n.ThreadName.Labeling,"processLabels"),clearPreviousLabels:s.get(n.ThreadName.Labeling,"clearPreviousLabels")});class cg{constructor(e,t){this.state=e,this.modules=t,this.labelTileRevision=0,this.viewportDiffer=new n.Differ([{path:"center",type:"vec2"},{path:"zoom",type:"number"},{path:"size",type:"vec2"},{path:"rotation",type:"number"},{path:"pitch",type:"number"},{path:"padding",type:"padding"},{path:"demMode",type:"boolean"}]),this.useThrottleUpdate=!0,this.isLabelingInProgress=!1,this.skipHysteresisInNextLabeling=!1,this.alwaysActiveLabelKeys=[],this.survivedLabelBoxes=new Set,this.prevSurvivedCommPoiIds=new Set,this.demKeys={},this.labelTiles=[],this.worker=lg(this.modules.workers.fnRegistry),this.setLabelingInterval(n.labeling.interval)}disableThrottleUpdateOnce(){this.useThrottleUpdate=!1}update(){sg(this.state),this.state.needReplicasUpdate&&this.labelTiles.forEach(e=>{e.needSync=!0}),(this.viewportDiffer.check(this.state)||this.state.needLabeling)&&!this.isLabelingInProgress&&(this.state.needLabeling=!1,this.isLabelingInProgress=!0,this.useThrottleUpdate?this.throttledUpdateLabeling():(this.useThrottleUpdate=!0,this.generateLabelingTile()))}isIdle(){return this.state.tickers.labelingOpacity===void 0&&!this.isLabelingInProgress&&!this.state.needLabeling}setLabelingInterval(e){this.throttledUpdateLabeling=n.throttle(()=>{this.generateLabelingTile()},e)}addLabels(e,t,i){this.worker.appendLabels(e,t,i,this.state.styleState,this.state.styleZoom),this.enrichWithElevation(i,e),this.alwaysActiveLabelKeys.push(e),this.state.needLabeling=!0}addTileLabels(e,t,i){this.worker.appendLabels(e,t,i,this.state.styleState,this.state.styleZoom),this.enrichWithElevation(i,e),this.state.needLabeling=!0}addLabelBox(e,t){this.worker.appendLabelBox(e,t),this.state.needLabeling=!0}removeLabels(e){this.worker.removeLabels(e);const t=this.alwaysActiveLabelKeys.indexOf(e);t!==-1&&this.alwaysActiveLabelKeys.splice(t,1),this.state.needLabeling=!0}isLabelBoxSurvived(e){return this.survivedLabelBoxes.has(e)}clearPreviousLabels(){this.worker.clearPreviousLabels()}resetHysteresis(){this.skipHysteresisInNextLabeling=!0,this.state.needLabeling=!0}getLabelingRevision(){return this.labelTileRevision}getMemoryFootprint(){const e={labelTiles:this.labelTiles.map(t=>({[t.purpose]:n.tileObjectStatsGpu(t)}))};return{gpu:{...e,"--sum":n.getTotalMemory(e)}}}generateLabelingTile(){const e=n.getBoundsTileCoords(n.tetragonBounds(this.state.tilesBounds),n.labeling.tileMultiplier);let t=[{coords:e,center:this.state.center,tilesBounds:this.state.tilesBounds}];if(!this.state.globeMode)if(e[2]<0)t=[{coords:[0,0,0,0],center:[0,0,0],tilesBounds:[[-n.HALF_WORLD_SIZE,-n.HALF_WORLD_SIZE,0],[n.HALF_WORLD_SIZE,-n.HALF_WORLD_SIZE,0],[n.HALF_WORLD_SIZE,n.HALF_WORLD_SIZE,0],[-n.HALF_WORLD_SIZE,n.HALF_WORLD_SIZE,0]]}];else{const r=n.getTileBounds(e),l=2**e[2],c=r.min[0]<-n.HALF_WORLD_SIZE,d=r.max[0]>n.HALF_WORLD_SIZE;if(c||d){const _=[...e];_[0]+=c?l:-l;const u=[...this.state.center];u[0]+=c?n.worldSize:-n.worldSize;const{min:h,max:f}=n.getTileBounds(_);t.push({coords:_,center:u,tilesBounds:[[h[0],h[1],0],[f[0],h[1],0],[f[0],f[1],0],[h[0],f[1],0]]})}}const i=this.modules.tileManager.getLabelingData(),o=t.map(({coords:r,center:l,tilesBounds:c})=>({center:l,elevation:this.state.elevation,zoom:this.state.zoom,styleZoom:this.state.styleZoom,rotation:this.state.rotation,size:this.state.size,pitch:this.state.pitch,viewport:this.state.viewport,padding:this.state.padding,globeMode:this.state.globeMode,styleState:this.state.styleState,buildingHeight:this.modules.buildingHeightAnimator.getDefaultBuildingHeight(),tilesBounds:c,debugLabels:this.modules.labelsDebug.isEnabled(),disableSurvivedPoiPrevalence:this.state.disableSurvivedPoiPrevalence,tileInfo:n.createTileInfo(r),cameraConfig:this.state.cameraConfig})),a=rg(this.state.styleZoom,this.state.cityCommPoiLabeling);this.worker.processLabels(i,this.alwaysActiveLabelKeys,o,window.devicePixelRatio,this.modules.floorManager.getActiveFloorHiddenIds(),{...n.labeling.commercialMargins,...a},this.skipHysteresisInNextLabeling,this.modules.floorManager.getPlanLevels()).then(r=>{this.survivedLabelBoxes.clear(),this.labelTiles.forEach(h=>{this.modules.tileManager.removeObject(h),h.clean(this.state)}),this.labelTiles.length=0;const l=[];r.forEach((h,f)=>{h.survivedLabelBoxIds.forEach(p=>this.survivedLabelBoxes.add(p)),l.push(...h.survivedCommPois),this.modules.assetManager.loadRasters(h.collectorOutput.rastersToLoad);const m=new n.TileObject("labeling",h.collectorOutput.data,this.modules,this.state,t[f].coords,void 0,void 0);this.labelTiles.push(m),this.modules.tileManager.addObject(m)}),this.processSurvivedCommPoiIds(l),this.labelTileRevision++;const c=this.state.metrics;c.firstlabeling===void 0&&r.some(({collectorOutput:h})=>h.data.length>0)&&(c.firstlabeling=performance.now()-c.start);const{animationTime:d,animationType:_,interval:u}=n.labeling;og(this.state,_,0,1,Math.min(d,u)),this.modules.renderer.addRerenderEvent(),r[0].labels&&e[2]>=0&&this.modules.labelsDebug.drawLabels(r[0].labels),this.isLabelingInProgress=!1}),this.skipHysteresisInNextLabeling=!1}processSurvivedCommPoiIds(e){if(e.length===0){this.prevSurvivedCommPoiIds.clear();return}const t=e.filter(i=>!this.prevSurvivedCommPoiIds.has(i.id));t.length!==0&&this.modules.map.emit("commpoishow",{commPois:t}),this.prevSurvivedCommPoiIds=new Set(e.map(i=>i.id))}enrichWithElevation(e,t){const{demManager:i,map:o}=this.modules;if(o.state.demMode){const a=this.demKeys[t],r=i.getLabelsDemKey(e);if(r===void 0||r===a)return;i.enrichWithElevation(e),this.demKeys[t]=r}}}class Wt{constructor(e,t,i){this.type=e,this.handler=i,this.mouseDownPoint=t,this.handler.mapState.userHasInteracted=!0,this.handler.modules.map.emit("interactionstart",{target:"pitch/rotation"})}processAction(e){switch(e.type){case"mousemove":return this.processMouseMoveAction(e);case"mouseup":return this.processMouseUpAction(e);case"keyup":return this.processKeyUpAction(e);default:return this}}processMouseMoveAction(e){const t=ye(this.handler.container,e.clientX,e.clientY);return new il(this.type,this.mouseDownPoint,t,this.handler)}processMouseUpAction(e){switch(this.type){case"keyPrimary":if(e.button===0&&(e.ctrlKey||e.metaKey))return this.returnToInitialState();break;case"secondary":if(e.button===2){const t=ye(this.handler.container,e.clientX,e.clientY);return this.handler.modules.identifier.search("contextmenu",t,!0).then(i=>{nt("contextmenu",i,e,t,this.handler.modules)}),this.returnToInitialState()}break;case"auxiliary":if(e.button===1)return this.returnToInitialState();break}return this}processKeyUpAction(e){return this.type==="keyPrimary"&&(e.key==="Control"||e.key==="Meta")?(this.handler.modules.map.emit("interactionend",{target:"pitch/rotation"}),new mn(this.mouseDownPoint,this.handler)):this}returnToInitialState(){return this.handler.mapState.userHasInteracted=!0,this.handler.modules.map.emit("interactionend",{target:"pitch/rotation"}),new We(this.handler)}}class il{constructor(e,t,i,o){this.type=e,this.mouseDownPoint=t,this.mouseMovePoint=i,this.handler=o,this.handler.mapState.userHasInteracted=!0,(!this.handler.mapState.disablePitchByUserInteraction||!this.handler.mapState.disableRotationByUserInteraction)&&this.handler.container.classList.add("mapgl-rotating"),this.update(this.handler.mapState)}processAction(e){switch(e.type){case"mousemove":return this.processMouseMoveAction(e);case"mouseleave":return this.returnToInitialState();case"mouseup":return this.processMouseUpAction(e);case"keyup":return this.processKeyUpAction(e);default:return this}}update(e){this.mouseDownPoint[0]===0&&this.mouseDownPoint[1]===0&&(this.mouseDownPoint=this.mouseMovePoint);const t=n.normalizeMousePosition(e.size,this.mouseDownPoint),i=n.normalizeMousePosition(e.size,this.mouseMovePoint),o=(t[0]-i[0])*n.zoom.mouseRotateDelta,a=(i[1]-t[1])*n.zoom.mousePitchDelta;ot(e),e.disableRotationByUserInteraction||Qt(e,e.rotation+o,{animate:!1}),e.disablePitchByUserInteraction||wi(e,n.clamp(e.pitch+a,e.minPitch,e.maxPitch),{animate:!1}),this.mouseDownPoint=this.mouseMovePoint,this.handler.modules.renderer.addRerenderEvent()}processMouseMoveAction(e){return this.mouseMovePoint=ye(this.handler.container,e.clientX,e.clientY),this.handler.mapState.userHasInteracted=!0,this.update(this.handler.mapState),this}processMouseUpAction(e){switch(this.type){case"keyPrimary":if(e.button===0&&(e.ctrlKey||e.metaKey))return this.returnToInitialState();break;case"secondary":if(e.button===2)return this.returnToInitialState();break;case"auxiliary":if(e.button===1)return this.returnToInitialState();break}return this}processKeyUpAction(e){return this.type==="keyPrimary"&&(e.key==="Control"||e.key==="Meta")?(this.handler.container.classList.remove("mapgl-rotating"),this.handler.modules.map.emit("interactionend",{target:"pitch/rotation"}),new mn(this.mouseMovePoint,this.handler)):this}returnToInitialState(){return this.handler.mapState.userHasInteracted=!0,this.handler.container.classList.remove("mapgl-rotating"),this.handler.modules.map.emit("interactionend",{target:"pitch/rotation"}),new We(this.handler)}}class mn{constructor(e,t){this.handler=t,this.toInitialOnMouseUp=!1,this.mouseDownPoint=e,this.dragStartPoint=e,this.isTimerStarted=this.handler.dblClickTimer!==void 0,this.handler.mapState.userHasInteracted=!0,this.handler.modules.map.emit("interactionstart",{target:"center"}),this.isTimerStarted&&(window.clearTimeout(this.handler.dblClickTimer),this.handler.dblClickTimer=void 0)}processAction(e){switch(e.type){case"mousedown":return this.toInitialOnMouseUp=!0,this;case"mouseup":return this.processMouseUpAction(e);case"mousemove":return this.processMouseMoveAction(e);case"click":return this.processMouseClickAction(e);case"keydown":return this.processKeyDownAction(e);default:return this}}processMouseUpAction(e){return e.button===0&&(this.toInitialOnMouseUp||!this.handler.modules.layout.isActionWithCanvas(e))?(this.handler.mapState.userHasInteracted=!0,this.handler.modules.map.emit("interactionend",{target:"center"}),new We(this.handler)):this}processMouseMoveAction(e){const t=ye(this.handler.container,e.clientX,e.clientY);return this.handler.mapState.disableDragging?(this.mouseDownPoint=t,this.dragStartPoint=t,this.toInitialOnMouseUp=!0,this):n.distance(this.mouseDownPoint,t)<n.events.dragThreshold?(this.dragStartPoint=t,this):new nl(t,this.dragStartPoint,this.handler)}processMouseClickAction(e){if(!this.handler.modules.layout.isActionWithCanvas(e))return this;if(this.isTimerStarted){if(this.handler.mapState.zoom<this.handler.mapState.maxZoom){const t=this.handler.mapState,i=Math.min(t.zoom+1,t.maxZoom),o=ye(this.handler.container,e.clientX,e.clientY);ot(t),dt(t,i,{duration:n.zoom.animDuration,zoomPoint:t.keepCenterWhileUserZoomRotate?void 0:o}),this.handler.modules.renderer.addRerenderEvent()}}else{const t=ye(this.handler.container,e.clientX,e.clientY);this.handler.modules.identifier.search("mouseClick",t,!0).then(i=>{this.handler.dblClickTimer||(this.handler.dblClickTimer=window.setTimeout(()=>{nt("click",i,e,t,this.handler.modules),this.handler.dblClickTimer=void 0},n.events.doubleClickTime))})}return this.handler.mapState.userHasInteracted=!0,this.handler.modules.map.emit("interactionend",{target:"center"}),new We(this.handler)}processKeyDownAction(e){return e.key==="Control"||e.key==="Meta"?(this.handler.modules.map.emit("interactionend",{target:"center"}),new Wt("keyPrimary",this.mouseDownPoint,this.handler)):this}}class nl{constructor(e,t,i){this.mouseMovePoint=e,this.dragStartPoint=t,this.handler=i,this.handler.container.classList.add("mapgl-dragging"),this.handler.mapState.userHasInteracted=!0,this.update(this.handler.mapState)}processAction(e){switch(e.type){case"mousemove":return this.processMouseMoveAction(e);case"mouseup":return this.processMouseUpAction(e);case"keydown":return this.processKeyDownAction(e);default:return this}}update(e){const t=this.handler.modules.camera,i=t.flat.unproject(this.dragStartPoint),o=t.flat.unproject(this.mouseMovePoint);if(e.globeMode){const r=n.adjustGlobeDragSpeed(t.globeRatio,n.Mercator.toGeo(e.center));n.scale(i,i,r),n.scale(o,o,r)}const a=n.clone$1(e.center);n.add$1(a,a,i),n.sub$1(a,a,o),ot(e),bt(e,a,{animate:!1}),this.dragStartPoint=this.mouseMovePoint,this.handler.modules.renderer.addRerenderEvent()}processMouseMoveAction(e){return this.mouseMovePoint=ye(this.handler.container,e.clientX,e.clientY),this.handler.mapState.userHasInteracted=!0,this.update(this.handler.mapState),this}processMouseUpAction(e){return e.button===0?this.returnToInitialState():this}processKeyDownAction(e){return e.key==="Control"||e.key==="Meta"?(this.handler.container.classList.remove("mapgl-dragging"),this.handler.modules.map.emit("interactionend",{target:"center"}),new Wt("keyPrimary",this.mouseMovePoint,this.handler)):this}returnToInitialState(){return this.handler.container.classList.remove("mapgl-dragging"),this.handler.modules.map.emit("interactionend",{target:"center"}),this.handler.mapState.userHasInteracted=!0,new We(this.handler)}}class ol{constructor(e,t,i){this.handler=i,this.touchStartPoints=t,this.touchMovePoints=e,this.handler.mapState.userHasInteracted=!0,this.handler.mapState.disablePitchByUserInteraction||this.handler.container.classList.add("mapgl-rotating"),this.update(this.handler.mapState)}processAction(e){switch(e.type){case"touchstart":return this.processTouchStartAction(e);case"touchmove":return this.processTouchMoveAction(e);case"touchend":return this.processTouchEndAction(e);default:return this}}processTouchStartAction(e){return this.handler.container.classList.remove("mapgl-rotating"),this.handler.modules.map.emit("interactionend",{target:"pitch/zoom/rotation"}),new $t(e,this.handler,!1)}processTouchMoveAction(e){return e.preventDefault(),this.touchMovePoints=yt(e.touches,this.handler.container),this.handler.mapState.userHasInteracted=!0,this.update(this.handler.mapState),this}processTouchEndAction(e){return this.handler.container.classList.remove("mapgl-rotating"),this.handler.modules.map.emit("interactionend",{target:"pitch/zoom/rotation"}),e.touches.length===0?(this.handler.mapState.userHasInteracted=!0,new We(this.handler)):new $t(e,this.handler,!1)}}class pn extends ol{constructor(e,t,i){super(e,t,i),this.startPxAngle=0,this.rotationDetected=!1,t.length>1&&(this.startPxAngle=n.calcAngle(t[0],t[1]))}update(e){if(this.touchStartPoints.length<2||this.touchMovePoints.length<2)return;const t=n.calcMidpoint(this.touchMovePoints[0],this.touchMovePoints[1]),i=n.dist(this.touchMovePoints[0],this.touchMovePoints[1]),o=n.dist(this.touchStartPoints[0],this.touchStartPoints[1]),a=i/o,r=e.zoom+Math.log(a)/Math.log(2)*n.zoom.mobilePinchDelta;let l=0,c=0;if(!this.rotationDetected){const u=n.calcAngle(this.touchMovePoints[0],this.touchMovePoints[1]);c=Math.abs(this.startPxAngle-u),c>Math.PI&&(c=2*Math.PI-c),c>=this.handler.mapState.touchRotationThreshold&&(this.rotationDetected=!0)}if(this.rotationDetected){const u=this.handler.modules.camera.flat.unproject(this.touchStartPoints[0]),h=this.handler.modules.camera.flat.unproject(this.touchStartPoints[1]),f=this.handler.modules.camera.flat.unproject(this.touchMovePoints[0]),m=this.handler.modules.camera.flat.unproject(this.touchMovePoints[1]);if(u&&h&&f&&m){const p=n.calcAngle(u,h),v=n.calcAngle(f,m);l=p-v}}const d=e.rotation+l,_=e.center;e.keepCenterWhileUserZoomRotate||n.add$1(_,e.center,n.getCenterCorrection(e,t,{zoom:r,rotation:d})),ot(e),bt(e,_,{animate:!1}),dt(e,r,{animate:!1}),this.handler.mapState.disableRotationByUserInteraction||Qt(e,d,{animate:!1}),this.touchStartPoints=this.touchMovePoints,this.handler.modules.renderer.addRerenderEvent()}}class sl extends ol{constructor(e,t,i){super(e,t,i)}update(e){const t=this.touchStartPoints.map(l=>n.normalizeMousePosition(e.size,l)),i=this.touchMovePoints.map(l=>n.normalizeMousePosition(e.size,l)),o=n.calcMidpoint(t[0],t[1]),r=(n.calcMidpoint(i[0],i[1])[1]-o[1])*n.zoom.mousePitchDelta;ot(e),wi(e,n.clamp(e.pitch+r,e.minPitch,e.maxPitch),{animate:!1}),this.touchStartPoints=this.touchMovePoints,this.handler.modules.renderer.addRerenderEvent()}}class $t{constructor(e,t,i){this.handler=t,this.needClickOnTouchEnd=i,this.toZoomRotate=!1,this.touchStartPoints=yt(e.touches,this.handler.container),this.handler.mapState.userHasInteracted=!0,this.isTimerStarted=this.handler.dblClickTimer!==void 0,Rn(e)?this.startedInteractionTarget="pitch/zoom/rotation":this.isTimerStarted?(this.startedInteractionTarget="zoom/rotation",window.clearTimeout(this.handler.dblClickTimer),this.handler.dblClickTimer=void 0):this.startedInteractionTarget="center",this.handler.modules.map.emit("interactionstart",{target:this.startedInteractionTarget})}processAction(e){switch(e.type){case"touchstart":return this.processTouchStartAction(e);case"touchmove":return this.processTouchMoveAction(e);case"touchend":return this.processTouchEndAction(e);default:return this}}getStartedInteractionTarget(){return this.startedInteractionTarget}processTouchStartAction(e){return e.preventDefault(),this.touchStartPoints.length===1&&(this.needClickOnTouchEnd=!1,this.handler.modules.map.emit("interactionend",{target:"center"}),this.startedInteractionTarget="pitch/zoom/rotation",this.handler.modules.map.emit("interactionstart",{target:this.startedInteractionTarget}),this.handler.mapState.userHasInteracted=!0),this.touchStartPoints=yt(e.touches,this.handler.container),this}processTouchMoveAction(e){e.preventDefault();const t=yt(e.touches,this.handler.container);if(!Rn(e))return n.distance(this.touchStartPoints[0],t[0])<n.events.dragThreshold?(this.touchStartPoints=t,this):this.isTimerStarted?new al(t[0],this.touchStartPoints[0],this.handler):this.handler.mapState.disableDragging?(this.touchStartPoints=t,this.needClickOnTouchEnd=!1,this):new Zo(t[0],this.touchStartPoints[0],this.handler);if(this.touchStartPoints.length<2)return this.processTouchStartAction(e);const i=n.create$4(),o=n.create$4();n.sub(i,t[0],this.touchStartPoints[0]),n.sub(o,t[1],this.touchStartPoints[1]);const a=n.dot$1(i,o);if(a>0){if(this.handler.mapState.enableTwoFingerDragging&&this.touchStartPoints.length===2)return n.distance(this.touchStartPoints[0],t[0])<n.events.dragThreshold?(this.touchStartPoints=t,this):new Zo(t[0],this.touchStartPoints[0],this.handler);const l=n.distance(this.touchStartPoints[0],t[0]),c=n.distance(this.touchStartPoints[1],t[1]);return l<n.events.pitchThreshold||c<n.events.pitchThreshold?(this.touchStartPoints=t,this):this.handler.mapState.disablePitchByUserInteraction?this:new sl(t,this.touchStartPoints,this.handler)}return a<0?new pn(t,this.touchStartPoints,this.handler):n.isNullVector(i)||n.isNullVector(o)?this.pitchWaitingTimer?this:this.toZoomRotate?(this.toZoomRotate=!1,new pn(t,this.touchStartPoints,this.handler)):(this.pitchWaitingTimer=window.setTimeout(()=>{this.toZoomRotate=!0,this.pitchWaitingTimer=void 0},n.events.pitchWaitingTime),this):new pn(t,this.touchStartPoints,this.handler)}processTouchEndAction(e){return e.cancelable&&e.preventDefault(),e.touches.length===0?e.changedTouches.length===1&&this.needClickOnTouchEnd?this.processTouchClickAction(this.touchStartPoints[0],e):(this.handler.mapState.userHasInteracted=!0,this.handler.modules.map.emit("interactionend",{target:e.changedTouches.length>1?"pitch/zoom/rotation":"center"}),new We(this.handler)):(Rn(e)||(this.handler.modules.map.emit("interactionend",{target:"pitch/zoom/rotation"}),this.startedInteractionTarget="center",this.handler.modules.map.emit("interactionstart",{target:this.startedInteractionTarget}),this.handler.mapState.userHasInteracted=!0),this.touchStartPoints=yt(e.touches,this.handler.container),this)}processTouchClickAction(e,t){if(this.isTimerStarted){if(this.handler.mapState.zoom<this.handler.mapState.maxZoom){const i=this.handler.mapState,o=Math.min(i.zoom+1,i.maxZoom),a=i.keepCenterWhileUserZoomRotate?void 0:e;ot(i),dt(i,o,{duration:n.zoom.animDuration,zoomPoint:a}),this.handler.modules.renderer.addRerenderEvent()}}else if(this.handler.modules.layout.isActionWithCanvas(t))this.handler.modules.identifier.search("mouseClick",e,!0).then(i=>{this.handler.dblClickTimer||(this.handler.dblClickTimer=window.setTimeout(()=>{nt("click",i,t,e,this.handler.modules),this.handler.dblClickTimer=void 0},n.events.doubleClickTime))});else{const i=t.changedTouches[0];t.target&&i&&t.target.dispatchEvent(new MouseEvent("click",{bubbles:!0,cancelable:!0,clientX:i.clientX,clientY:i.clientY}))}return this.handler.mapState.userHasInteracted=!0,this.handler.modules.map.emit("interactionend",{target:"center"}),new We(this.handler)}}class Zo{constructor(e,t,i){this.handler=i,this.touchMovePoint=e,this.touchStartPoint=t,this.handler.mapState.userHasInteracted=!0,this.handler.container.classList.add("mapgl-dragging"),this.update(this.handler.mapState)}processAction(e){switch(e.type){case"touchstart":return this.processTouchStartAction(e);case"touchmove":return this.processTouchMoveAction(e);case"touchend":return this.processTouchEndAction();default:return this}}update(e){const t=this.handler.modules.camera,i=t.flat.unproject(this.touchStartPoint),o=t.flat.unproject(this.touchMovePoint);if(e.globeMode){const r=n.adjustGlobeDragSpeed(t.globeRatio,n.Mercator.toGeo(e.center));n.scale(i,i,r),n.scale(o,o,r)}const a=n.clone$1(e.center);n.add$1(a,a,i),n.sub$1(a,a,o),ot(e),bt(e,a,{animate:!1}),this.touchStartPoint=this.touchMovePoint,this.handler.modules.renderer.addRerenderEvent()}processTouchStartAction(e){return this.handler.container.classList.remove("mapgl-dragging"),this.handler.modules.map.emit("interactionend",{target:"center"}),new $t(e,this.handler,!1)}processTouchMoveAction(e){e.preventDefault();const t=yt(e.touches,this.handler.container);return this.touchMovePoint=t[0],this.handler.mapState.userHasInteracted=!0,this.update(this.handler.mapState),this}processTouchEndAction(){return this.handler.container.classList.remove("mapgl-dragging"),this.handler.modules.map.emit("interactionend",{target:"center"}),this.handler.mapState.userHasInteracted=!0,new We(this.handler)}}class al{constructor(e,t,i){this.handler=i,this.mapHeight=i.mapState.size[1],this.startZoom=i.mapState.zoom,this.touchMovePointY=e[1],this.touchStartPoint=t,this.handler.mapState.userHasInteracted=!0,this.update(this.handler.mapState)}processAction(e){switch(e.type){case"touchstart":return this.processTouchStartAction(e);case"touchmove":return this.processTouchMoveAction(e);case"touchend":return this.processTouchEndAction();default:return this}}update(e){const t=this.touchMovePointY-this.touchStartPoint[1];if(t===0)return;const i=t/this.mapHeight,o=n.clamp(this.startZoom+i*n.zoom.mobileTapDelta,e.minZoom,e.maxZoom),a=e.center;e.keepCenterWhileUserZoomRotate||n.add$1(a,e.center,n.getCenterCorrection(e,this.touchStartPoint,{zoom:o})),ot(e),bt(e,a,{animate:!1}),dt(e,o,{animate:!1}),this.handler.modules.renderer.addRerenderEvent()}processTouchStartAction(e){return this.handler.modules.map.emit("interactionend",{target:"zoom/rotation"}),new $t(e,this.handler,!1)}processTouchMoveAction(e){e.preventDefault();const t=yt(e.touches,this.handler.container);return this.touchMovePointY=t[0][1],this.handler.mapState.userHasInteracted=!0,this.update(this.handler.mapState),this}processTouchEndAction(){return this.handler.modules.map.emit("interactionend",{target:"zoom/rotation"}),this.handler.mapState.userHasInteracted=!0,new We(this.handler)}}class We{constructor(e){this.handler=e}processAction(e){switch(e.type){case"mousedown":return this.processMouseDownAction(e);case"touchstart":return this.processTouchStartAction(e);default:return this}}processMouseDownAction(e){const t=ye(this.handler.container,e.clientX,e.clientY);switch(e.button){case 0:if(e.ctrlKey||e.metaKey)return new Wt("keyPrimary",t,this.handler);if(this.handler.modules.layout.isActionWithCanvas(e)){const i=this.handler.modules.identifier.searchSync(t);nt("mousedown",i,e,t,this.handler.modules)}return new mn(t,this.handler);case 1:return new Wt("auxiliary",t,this.handler);case 2:return new Wt("secondary",t,this.handler);default:return this}}processTouchStartAction(e){if(e.preventDefault(),!e.touches)return this;if(this.handler.modules.layout.isActionWithCanvas(e)){const t=ye(this.handler.container,e.changedTouches[0].clientX,e.changedTouches[0].clientY),i=this.handler.modules.identifier.searchSync(t);nt("touchstart",i,e,t,this.handler.modules)}return new $t(e,this.handler,e.touches.length===1)}}class vn{processAction(){return this}}class dg{constructor(e,t){this.preventDefault=i=>{i.preventDefault()},this.onMouseMove=i=>{this.dblClickTimer&&(this.dblClickTimer=void 0),this.switchState(i)},this.onTouchStart=i=>{this.modules.layout.isActionWithMap(i)&&this.switchState(i)},this.switchState=i=>{this.state;const o=this.state.processAction(i);this.state instanceof vn||(this.state=o)},this.state=new We(this),this.mapState=e,this.modules=t,this.container=t.layout.mapContainer,document.addEventListener("mouseup",this.switchState),document.addEventListener("keydown",this.switchState),document.addEventListener("keyup",this.switchState),document.addEventListener("mouseleave",this.switchState),document.addEventListener("mousemove",this.onMouseMove),this.container.addEventListener("click",this.switchState),this.container.addEventListener("mousedown",this.switchState),this.container.addEventListener("mouseout",this.switchState),document.addEventListener("touchstart",this.onTouchStart),document.addEventListener("touchend",this.switchState),document.addEventListener("touchmove",this.switchState),this.container.addEventListener("dragstart",this.preventDefault),this.container.addEventListener("drag",this.preventDefault),this.container.addEventListener("dragend",this.preventDefault),this.container.addEventListener("contextmenu",this.preventDefault),this.container.addEventListener("touchmove",this.preventDefault)}destroy(){document.removeEventListener("mouseup",this.switchState),document.removeEventListener("keydown",this.switchState),document.removeEventListener("keyup",this.switchState),document.removeEventListener("mouseleave",this.switchState),document.removeEventListener("mousemove",this.onMouseMove),this.container.removeEventListener("click",this.switchState),this.container.removeEventListener("mousedown",this.switchState),this.container.removeEventListener("mouseout",this.switchState),document.removeEventListener("touchstart",this.onTouchStart),document.removeEventListener("touchend",this.switchState),document.removeEventListener("touchmove",this.switchState),this.container.removeEventListener("dragstart",this.preventDefault),this.container.removeEventListener("drag",this.preventDefault),this.container.removeEventListener("dragend",this.preventDefault),this.container.removeEventListener("contextmenu",this.preventDefault),this.container.removeEventListener("touchmove",this.preventDefault)}block(){if(this.state instanceof vn)return;const{map:e}=this.modules;switch(this.container.classList.remove("mapgl-dragging"),this.container.classList.remove("mapgl-rotating"),this.state.constructor){case mn:case nl:case Zo:e.emit("interactionend",{target:"center"});break;case Wt:case il:e.emit("interactionend",{target:"pitch/rotation"});break;case al:e.emit("interactionend",{target:"zoom/rotation"});break;case pn:case sl:e.emit("interactionend",{target:"pitch/zoom/rotation"});break;case $t:{const t=this.state.getStartedInteractionTarget();e.emit("interactionend",{target:t});break}}this.state=new vn}unblock(){this.state instanceof We||this.state instanceof vn&&(this.state=new We(this))}}const _g=new Set([n.UNIVERSE_REGION_ID]);class Wo extends Error{constructor(e,t){super(e),this.name="TrafficFetchMetaError",this.noRetry=t}}class ug{constructor(e,t){this.mapState=e,this.modules=t,this.fetchMetaRetryAttempt=null,this.justEnabled=this.mapState.trafficOn,this.isMetaLoading=!1,this.lastUpdateTime=-1/0,this.regionIds=new Set,this.id=n.uniqId();const i=t.identifier.getIdScope(n.DEFAULT_ID_SCOPE);this.gridState=n.createGridState("traffic",0,this.id,e.trafficMinZoom,e.trafficMaxZoom,e.trafficMinZoom,e.trafficMaxDetailLevel,t,e,i),this.viewportDiffer=new n.Differ([{path:"center",type:"vec2"},{path:"zoom",type:"number"},{path:"size",type:"vec2"},{path:"rotation",type:"number"},{path:"pitch",type:"number"},{path:"demMode",type:"boolean"}])}show(){this.mapState.trafficOn||(this.mapState.trafficOn=!0,this.justEnabled=!0,this.modules.map.patchStyleState({trafficOn:!0}),this.modules.map.emit("trafficshow"))}hide(){this.mapState.trafficOn&&(n.resetGridState(this.gridState),this.mapState.trafficOn=!1,this.justEnabled=!1,this.modules.map.patchStyleState({trafficOn:!1}),this.modules.map.emit("traffichide"))}isEnabled(){return this.mapState.trafficOn}destroy(){n.resetGridState(this.gridState)}redraw(){this.mapState.trafficOn&&(n.resetGridState(this.gridState),n.viewportChangeAction(this.gridState,this.mapState,this.modules))}activateStyleUpdating(){this.mapState.trafficOn&&n.startStyleUpdatingAction(this.gridState,this.mapState.handyStyleId,this.modules.styleManager.getStyleRevision(this.mapState.handyStyleId),this.modules.map.core.getIsFirstStyleUpdate())}finishStyleUpdating(){this.mapState.trafficOn&&n.finishStyleUpdatingAction(this.gridState)}update(){if(!this.mapState.trafficOn)return;let e=!1;if(n.equalSets(this.regionIds,this.mapState.shownRegionIds)||(this.regionIds=new Set(this.mapState.shownRegionIds),e=!0),Date.now()-this.lastUpdateTime>n.traffic.updateInterval&&(e=!0,this.fetchMetaRetryAttempt=null),this.fetchMetaRetryAttempt!==null&&this.fetchMetaRetryAttempt<n.traffic.fetchMetaRetryDelays.length&&Date.now()-this.lastUpdateTime>n.traffic.fetchMetaRetryDelays[this.fetchMetaRetryAttempt]&&(this.fetchMetaRetryAttempt++,e=!0),e&&this.fetchMeta(),this.timestamp===void 0)return;(this.viewportDiffer.check(this.mapState)||this.justEnabled)&&(this.justEnabled=!1,n.viewportChangeAction(this.gridState,this.mapState,this.modules),this.modules.renderer.addRerenderEvent());const t={...this.gridState.displayedMods};n.newFrameAction(this.gridState,this.mapState,this.modules),this.fetch(n.getTilesToFetch(this.gridState),this.timestamp),this.abortFetch(n.getTilesToAbortFetch(this.gridState)),this.generate(n.getTilesToGenerate(this.gridState)),this.clearTiles(n.getTilesToRemove(this.gridState)),n.updateScene(this.modules,this.mapState,this.gridState,t)}viewportTilesReady(){return n.viewportTilesReady(this.gridState.tiles,this.gridState.viewportTiles)}getMemoryFootprint(){const e=this.gridState,t={gridState:{displayedMods:Object.keys(e.displayedMods).map(o=>n.modStatsJs(e.displayedMods[o])),tileModsCache:e.tileModsCache.keys().filter(o=>!e.displayedMods[o]).map(o=>n.modStatsJs(e.tileModsCache.get(o)))}},i={gridState:{displayedMods:Object.keys(e.displayedMods).map(o=>n.modStatsGpu(e.displayedMods[o])),tileModsCache:e.tileModsCache.keys().filter(o=>!e.displayedMods[o]).map(o=>n.modStatsGpu(e.tileModsCache.get(o)))}};return{js:{...t,"--sum":n.getTotalMemory(t)},gpu:{...t,"--sum":n.getTotalMemory(i)}}}fetch(e,t){e.sort((i,o)=>n.compare(this.mapState.center,i,o)).forEach(i=>hg(i,this.modules,this.mapState,this.regionIds,t))}abortFetch(e){e.forEach(t=>{this.modules.workers.parser.abortTrafficTileRequest(t.key)})}generate(e){e.sort((t,i)=>n.compare(this.mapState.center,t,i)).forEach(t=>{const i=n.getTileModToGenerate(t);i&&this.modules.workers.parser.generateTrafficTile({styleId:this.mapState.handyStyleId,coords:t.coords,pixelRatio:window.devicePixelRatio,styleState:this.mapState.styleState,sourceId:this.modules.defaultSource.getId()}).then(o=>{if(!o){n.logEmptyTileGenerationResponse("traffic");return}Array.isArray(o.results)&&n.addGeneratedDataToTileMod(i,o.results)})})}clearTiles(e){for(const t of e)this.modules.workers.parser.deleteTrafficTile(t.key),delete this.gridState.tiles[t.key]}fetchMeta(){if(this.isMetaLoading||!this.regionIds.size)return;if(n.equalSets(this.regionIds,_g)){console.warn("Traffic metadata request skip: only Universe"),this.lastUpdateTime=Date.now();return}this.isMetaLoading=!0;const e=this.mapState,t=n.template(n.traffic.timestampUrl,{host:e.trafficServer,protocol:e.trafficProtocol||e.tileProtocol,regions:Array.from(this.regionIds).join(",")});fetch(t).then(i=>{if(i.ok)return i.json();throw new Wo(`Request traffic timestamp error with status ${i.status}`,!1)}).then(i=>{if(!i.length||i[0]?.time===void 0||i[0]?.score===void 0)throw new Wo(`Bad traffic timestamp and score response ${i.toString()}`,!0);let o=0;i.forEach(a=>o+=a.score),o=Math.round(o/i.length),this.modules.map.emit("trafficscore",{score:o}),this.timestamp=i[0].time,this.isMetaLoading=!1,this.lastUpdateTime=Date.now(),this.fetchMetaRetryAttempt=null,this.redraw()}).catch(i=>{!(i instanceof Wo)||!i.noRetry?this.fetchMetaRetryAttempt=this.fetchMetaRetryAttempt??0:this.fetchMetaRetryAttempt=null,this.lastUpdateTime=Date.now(),this.isMetaLoading=!1,console.error(i)})}}function hg(s,e,t,i,o){i.size&&e.workers.parser.fetchTrafficTile({coords:s.coords,tileServer:t.trafficServer,tileProtocol:t.trafficProtocol||t.tileProtocol,regionIds:Array.from(i),timestamp:o}).then(()=>{s.status===n.TileStatus.Loading&&(s.serverMetadata=[{regionId:0,metatileHash:-2}])})}class fg{constructor(e){this.externalContainer=e,this.rootContainer=document.createElement("div"),this.rootContainer.style.position="relative",this.rootContainer.style.height="100%",this.rootContainer.style.width="100%",this.rootContainer.style.overflow="hidden",this.externalContainer.appendChild(this.rootContainer),this.mapContainer=document.createElement("div"),this.mapContainer.style.position="relative",this.mapContainer.style.height="100%",this.mapContainer.style.width="100%",this.mapContainer.style.touchAction="none",this.mapContainer.style.webkitUserSelect="none",this.mapContainer.style.userSelect="none",this.rootContainer.appendChild(this.mapContainer),this.canvas=document.createElement("canvas"),this.canvas.style.display="block",this.mapContainer.appendChild(this.canvas),this.htmlContainerInMap=document.createElement("div"),this.htmlContainerInMap.style.position="absolute",this.htmlContainerInMap.style.left="0",this.htmlContainerInMap.style.top="0",this.htmlContainerInMap.style.width="100%",this.htmlContainerInMap.style.height="0",this.htmlContainerInMap.style.webkitUserSelect="auto",this.htmlContainerInMap.style.userSelect="auto",this.mapContainer.appendChild(this.htmlContainerInMap),this.htmlContainerOutMap=document.createElement("div"),this.htmlContainerOutMap.style.position="absolute",this.htmlContainerOutMap.style.left="0",this.htmlContainerOutMap.style.top="0",this.htmlContainerOutMap.style.width="100%",this.htmlContainerOutMap.style.height="0",this.mapContainer.after(this.htmlContainerOutMap)}setCanvasSize(e,t){const i=window.devicePixelRatio;return this.canvas.width=e*i,this.canvas.height=t*i,this.canvas.style.width=e+"px",this.canvas.style.height=t+"px",this}destroy(){for(;this.externalContainer.lastChild;)this.externalContainer.removeChild(this.externalContainer.lastChild)}isActionWithCanvas(e){return e.target===this.canvas}isActionWithMap(e){return e instanceof MouseEvent||e instanceof KeyboardEvent?this.isTargetInMap(e.target):Array.from(e.touches).map(i=>i.target).some(i=>this.isTargetInMap(i))}isTargetInMap(e){return!e||!(e instanceof Node)?!1:this.mapContainer.contains(e)}}class mg{constructor(e){this.loadingCounter=0,this.isIdle=()=>this.loadingCounter===0,this.modules=e,this.textureKeys=[],this.texturesMap=new Map}async addTexture(e,t){this.loadingCounter++;const i=await tn(e);return this.storeTexture(i,t)}addPreparedTexture(e){const t=`prepared-${n.uniqId()}`;return this.textureKeys.push(t),this.texturesMap.set(t,e),this.textureKeys.length-1}updatePreparedTexture(e,t){this.deleteTexture(e),this.texturesMap.set(this.textureKeys[e],t)}async loadTexture(e,t){this.loadingCounter++;const i=await this.loadImage(e);if(!i){this.decreaseLoadingCounter();return}return this.storeTexture(i,t)}getTexture(e){return this.texturesMap.get(this.textureKeys[e])}destroy(){this.textureKeys=[],this.texturesMap.clear()}deleteTexture(e){const t=this.textureKeys[e];return this.texturesMap.get(t)?.remove(),this.texturesMap.delete(t)}getMemoryFootprint(){const e={texturesMap:Array.from(this.texturesMap.values()).map(n.textureSizeJs)},t={texturesMap:Array.from(this.texturesMap.values()).map(n.textureSizeGpu)};return{js:{...e,"--sum":n.getTotalMemory(e)},gpu:{...t,"--sum":n.getTotalMemory(t)}}}decreaseLoadingCounter(){this.loadingCounter=Math.max(this.loadingCounter-1,0)}storeTexture(e,t){const i=t?.size,o=t?.pixelRatio??window.devicePixelRatio,a=t?.imagePadding??1;this.decreaseLoadingCounter();const r=e.getAttribute("src")||e.currentSrc,l=pg(r,i),c=this.textureKeys.indexOf(l);if(c>-1&&this.texturesMap.has(l))return c;const d=(i?[i[0],i[1]]:[e.width,e.height]).map(f=>f*o),_=fr(e,d);e.remove();const u=d.map(f=>f+2*a);if(!t?.skipAtlasSizeChecking&&(u[0]>n.atlasSize[0]||u[1]>n.atlasSize[1]))throw new Error(`Image texture dimensions ${u} are larger than the maximum possible ${n.atlasSize}`);const h=new g(void 0,{size:u,flipY:t?.flipY??!1,generateMipmaps:t?.generateMipmaps,magFilter:g.LinearFilter,minFilter:t?.minFilter??g.LinearFilter,wrapS:t?.wrapS??g.defaultOptions.wrapS,wrapT:t?.wrapT??g.defaultOptions.wrapT,premultiplyAlpha:t?.premultiplyAlpha??g.defaultOptions.premultiplyAlpha});return this.modules.renderer.prepareTexture(h),h.subImage(_,a,a),_.remove(),this.texturesMap.set(l,h),this.textureKeys.push(l),this.modules.renderer.addRerenderEvent(),this.textureKeys.length-1}async loadImage(e){return new Promise(t=>{const i=new Image;i.crossOrigin="Anonymous",i.src=e,i.onload=()=>t(i),i.onerror=()=>t(void 0)})}}function pg(s,e){const t=e!==void 0?`_${e[0]},${e[1]}`:"";return`${s}${t}`}const rl=!0,ll=!1,cl=!1,dl=[0];class vg{constructor(e){this.isLoading=!1,this.attempts=0,this.getKeyInfo=async()=>await this.request,this.isIdle=()=>!this.isLoading;const{tileKey:t,keyUrl:i}=e;if(t===n.tiles.tileKey||!n.keyServerPath)this.request=Promise.resolve({showCommPoi:!1,urbi:!1,hideCopyright:!0});else{const o=n.getUrlFromTemplate(i,{keyID:t});this.isLoading=!0;const a=async()=>dl.length>=this.attempts?(this.attempts&&(await new Promise(r=>{this.lastTimeout=window.setTimeout(r,dl[this.attempts]*1e3)}),this.clearLastTimeout()),this.attempts++,fetch(o).then(r=>r.ok?r.json():a(),a)):(console.error("Could not load tile key info. A style layers with commercial POI will be added to applied styles."),Promise.resolve(void 0));this.request=a().then(r=>{if(this.isLoading=!1,!r||!r.result||r.meta.code!==200)return{showCommPoi:rl,hideCopyright:cl,urbi:ll,error:!0};const{showCommPoi:l,hideCopyright:c,urbi:d}=r.result.service.properties.public;return{showCommPoi:n.isNullish(l)?rl:!!l,hideCopyright:n.isNullish(c)?cl:!!c,urbi:n.isNullish(d)?ll:!!d}})}}destroy(){this.clearLastTimeout()}clearLastTimeout(){this.lastTimeout!==void 0&&(clearTimeout(this.lastTimeout),this.lastTimeout=void 0)}}class gg{constructor(){this.sources=[],this.viewportSources=[]}addSource(e){this.sources.push(e),e.type==="geojson"&&e.subtype==="viewport-internal"&&e instanceof n.GeoJsonViewportSource&&this.viewportSources.push(e)}removeSource(e){this.sources=this.sources.filter(t=>t.getId()!==e),this.viewportSources=this.viewportSources.filter(t=>t.getId()!==e)}getSourceById(e){return this.sources.find(t=>t.getId()===e)}updateViewportSources(){this.viewportSources.forEach(e=>e.update())}}const yg={dead:!0,alive:!0,unused:!0,commercialDead:!1,commercialAlive:!1};class bg{constructor(e,t){this.mapState=e,this.modules=t,this.options={},this.viewportDiffer=new n.Differ([{path:"center",type:"vec2"},{path:"zoom",type:"number"},{path:"size",type:"vec2"},{path:"rotation",type:"number"},{path:"pitch",type:"number"},{path:"padding",type:"padding"},{path:"demMode",type:"boolean"}]),this.sizeDiffer=new n.Differ([{path:"size",type:"vec2"}])}update(){this.isEnabled()&&(this.sizeDiffer.check(this.mapState)&&this.updateSize(),this.viewportDiffer.check(this.mapState)&&this.clear())}isEnabled(){return!!this.canvas}show(e=yg){this.options=e,Object.values(e).every(i=>i===!1)?this.hide():(this.createCanvas(),this.mapState.needLabeling=!0)}hide(){this.canvas&&(this.modules.layout.mapContainer.removeChild(this.canvas),this.ctx=void 0,this.canvas=void 0)}drawLabels(e){if(!this.canvas||!this.ctx)return;const t=this.ctx,i=this.options,o={[n.BBoxType.Dead]:"#ff0000",[n.BBoxType.Alive]:"#30763c",[n.BBoxType.Unused]:"#aaa",[n.BBoxType.CommercialAlive]:"#3a9f22",[n.BBoxType.CommercialDead]:"#ff0000"},a=new Int32Array(e),r={[n.BBoxType.Dead]:[],[n.BBoxType.Alive]:[],[n.BBoxType.Unused]:[],[n.BBoxType.CommercialAlive]:[],[n.BBoxType.CommercialDead]:[]};for(let d=0;d<a.length;d+=5){const _=a[d+4];r[_].push({x:a[d],y:a[d+1],width:a[d+2],height:a[d+3]})}this.clear();const l=window.devicePixelRatio,c=d=>{t.strokeStyle=o[d],r[d].forEach(_=>t.strokeRect(_.x*l+.5,_.y*l+.5,_.width*l,_.height*l))};t.setLineDash([]),i.unused&&c(n.BBoxType.Unused),i.dead&&c(n.BBoxType.Dead),i.alive&&c(n.BBoxType.Alive),t.setLineDash([6]),i.commercialDead&&c(n.BBoxType.CommercialDead),i.commercialAlive&&c(n.BBoxType.CommercialAlive)}clear(){if(this.canvas&&this.ctx){const{clientWidth:e,clientHeight:t}=this.canvas;this.ctx.clearRect(0,0,e*window.devicePixelRatio,t*window.devicePixelRatio)}}createCanvas(){this.canvas||(this.canvas=document.createElement("canvas"),this.canvas.style.position="absolute",this.canvas.style.left="0",this.canvas.style.top="0",this.canvas.style.pointerEvents="none",this.modules.layout.mapContainer.appendChild(this.canvas),this.ctx=this.canvas.getContext("2d")||void 0,this.updateSize())}updateSize(){if(!this.canvas)return;const{clientWidth:e,clientHeight:t}=this.modules.layout.rootContainer;this.canvas.width=e*window.devicePixelRatio,this.canvas.height=t*window.devicePixelRatio,this.canvas.style.width=e+"px",this.canvas.style.height=t+"px"}}const xg=n.create$1();class wg{constructor(e){this.globHaloStops=[-2.5,0,1.5,13],this.globeHaloExpFactor=-1,this.fogLimits=new Float32Array([3.7,4.5]),this.fogHorizonBlend=.12,this.fogHorizonLevel=-.07,this.squaredDistMaxFog=0,this.lastStyleId=NaN,this.starsCount=2e4,this.starsGenerationCtx={randomSeed:12345},this.starsUpdateNeeded=!0,this.modules=e;const t=this.modules.renderer.getShaderProgram("sky"),i=this.modules.renderer.createBuffer(new Float32Array([-1,-1,1,-1,1,1,-1,1]));this.vao=c_(i,t)}update(){this.updateFog();const e=this.modules.map.state;isNaN(e.handyStyleId)||this.lastStyleId!==e.handyStyleId&&(this.updateSky(),this.updateStars(),this.lastStyleId=e.handyStyleId)}setParameters(e){const t=this.modules.map.state;e.min!==void 0&&(this.fogLimits[0]=e.min),e.max!==void 0&&(this.fogLimits[1]=e.max),e.horizonBlend!==void 0&&(this.fogHorizonBlend=e.horizonBlend),e.horizonLevel!==void 0&&(this.fogHorizonLevel=e.horizonLevel);const i=this.modules.styleManager.getStyleLayer(t.handyStyleId,n.ENVIRONMENT_STYLE_LAYER_ID);i&&(e.fogColor!==void 0&&(i.style.fogColor=n.isArrayOfNumbers(e.fogColor)?n.toStyleColor(e.fogColor):e.fogColor),e.skyColor!==void 0&&(i.style.skyColor=n.isArrayOfNumbers(e.skyColor)?n.toStyleColor(e.skyColor):e.skyColor),this.modules.renderer.addRerenderEvent())}renderSky(){if(!this.isSkyEnabled())return;this.modules.renderer.applyGpuState(Me);const e=this.modules.renderer.getShaderProgram("sky");this.modules.renderer.enableShaderProgram(e),this.modules.renderer.isUboSupported()||(Cs(e,this.modules.map.state,this.modules),V(e,this.modules.map.state,this.modules),Z(e,this.modules.map.state,this.modules)),this.modules.renderer.bindVao(this.vao),this.modules.renderer.drawTrianglesFan(0,4)}renderStars(){if(!this.starsVao)return;this.modules.renderer.applyGpuState(Me);const e=this.modules.renderer.getShaderProgram("stars");this.modules.renderer.enableShaderProgram(e),this.modules.renderer.isUboSupported()||Ls(e,this.modules.map.state,this.modules),this.modules.renderer.bindVao(this.starsVao),this.modules.renderer.drawPoints(0,this.starsCount)}renderGlobeHaloBackground(){this.modules.renderer.applyGpuState(Me);const e=this.modules.renderer.getShaderProgram("globeHaloBackground");this.modules.renderer.enableShaderProgram(e),this.modules.renderer.isUboSupported()||Un(e,this.modules.map.state,this.modules),this.modules.renderer.bindVao(this.vao),this.modules.renderer.drawTrianglesFan(0,4)}renderGlobeHalo(){this.modules.renderer.applyGpuState(y_);const e=this.modules.renderer.getShaderProgram("globeHalo");this.modules.renderer.enableShaderProgram(e),this.modules.renderer.isUboSupported()||Un(e,this.modules.map.state,this.modules),this.modules.renderer.bindVao(this.vao),this.modules.renderer.drawTrianglesFan(0,4)}isFogEnabled(){if(this.modules.map.getFeatureFlag("fogOff")||!this.envStyleLayer?.style.fogColor)return!1;const{styleZoom:e,styleState:t}=this.modules.map.state,i=n.makeBinderContext(e,t,[]),o=n.resolveColor(this.envStyleLayer?.style.fogColor,i);return o&&o.value[3]!==0}isSkyEnabled(){if(this.modules.map.getFeatureFlag("skyOff")||!this.envStyleLayer?.style.skyColor)return!1;const{styleZoom:e,styleState:t}=this.modules.map.state,i=n.makeBinderContext(e,t,[]),o=n.resolveColor(this.envStyleLayer?.style.skyColor,i);return o&&o.value[3]!==0}isPointInFog(e){const t=this.modules.camera;return n.sqrDist(e,t.position)>this.squaredDistMaxFog}isAABBInFog(e){if(!this.modules.environmentManager.isFogEnabled())return!1;const t=this.modules.camera,i=n.projectToXyRect(t.position,e.min,e.max,xg);return this.isPointInFog(i)}updateSky(){const e=this.modules.styleManager.getStyleLayer(this.modules.map.state.handyStyleId,n.ENVIRONMENT_STYLE_LAYER_ID);this.envStyleLayer=e}updateStars(){if(!this.starsUpdateNeeded)return;this.starsUpdateNeeded=!1;const e=n.generatePointsOnSphere(this.starsGenerationCtx,this.starsCount),t=4,i=new Float32Array(t*e.length);for(let r=0;r<e.length;++r){const l=e[r],c=n.getRandomValue(this.starsGenerationCtx,0,1);i[t*r]=l[0],i[t*r+1]=l[1],i[t*r+2]=l[2],i[t*r+3]=c}const o=this.modules.renderer.createBuffer(i),a=this.modules.renderer.getShaderProgram("stars");this.starsVao=d_(o,a)}updateFog(){const e=this.modules.camera;this.squaredDistMaxFog=(e.fogDistance*this.fogLimits[1])**2}}class Sg{constructor(e,t){this.mapState=e,this.mapModules=t,this.state={}}add(e,t=0,i=1,o=n.buildingAnimation.easing,a=n.buildingAnimation.duration){this.state[e]||(this.state[e]={tickerConfig:{start:t,end:i,duration:a,easing:o},tickerKey:"",readiness:t===i?1:0})}has(e){return!!this.state[e]}remove(e){this.state[e]&&delete this.state[e];const t=this.buildTickerKey(e);n.exist(t,this.mapState)&&n.stop(t,this.mapState)}getReadiness(e){return this.state[e]?.readiness}isAnimating(e){if(!e){for(const t in this.state)if(n.get(this.state[t].tickerKey,this.mapState)!==void 0)return!0;return!1}return this.state[e]?n.get(this.state[e].tickerKey,this.mapState)!==void 0:!1}update(){const e=[];for(const t in this.state){const i=this.state[t];if(this.mapModules.tileManager.viewportTilesReady()){const o=i.readiness,{start:a,end:r,duration:l,easing:c}=i.tickerConfig;if(i.tickerKey)n.update(i.tickerKey,{step:(d,_)=>{i.readiness=_}},this.mapState);else{const d=this.buildTickerKey(t);i.tickerKey=d,n.start(d,{easing:c},this.mapState,a,r,l,1)}i.readiness===1&&o!==1&&e.push(t)}}return e}buildTickerKey(e){return`gltf-${e}`}}const Tg=!0,$o="#ffffffff",Mg=0,Eg=0,Ig=1,Xo=15,Cg=n.tileZoomToSize(Xo)/n.MAP_POINTS_IN_METER,gn=n.maxTilePoint/2,Lg=["coordinates","rotation","scale","offset"];let Ko=class _s extends Re{constructor(e,t){super(e,{interactive:t.interactive??!1}),this.map=e,this.needRerender=()=>this.isVisible()&&n.isTileVisible(n.mapPointTo32ZoomTileCoords(this.position.normalizedValue),this.mapState.tilesBounds,this.modules,n.MODELS_TILES_VIEWPORT_PADDING),this.hovered=!1,this.selected=!1,this.status=t.hideOnInit?"hidden":"visible",this.interactiveOcclusion=t.interactiveOcclusion??Tg,this.disableAnimation=t.disableAnimation,this.linkedIds=t.linkedIds,this.planId=t.planId,this.tickerNames=new Map;const i=n.Mercator.fromGeo(t.coordinates);this.position={userValue:i,normalizedValue:n.normalizeMapPoint(i)};const{dynamicStyle:o,collector:a,tileManager:r,layers:l,assetManager:c}=this.modules,{ignoreGlobalLighting:d,colorTextureUvIndex:_,nearCameraFade:u,showRatio:h,playAnimation:f}=t,m=fl(t.rotation??Mg),p=t.scale??Ig,v=ml(t.offset??Eg,t.coordinates[1]);if(this.appliedTransformations={scale:p,rotation:m,offset:v},this.layer=n.makeHandyStyleLayer({type:"model",id:`dynamic-gltf-model-${this.uniqId}`,style:{modelSrc:["get","model_src"],rotation:Array.isArray(m)?["literal",m]:m,scale:Array.isArray(p)?["literal",p]:p,offset:Array.isArray(v)?["literal",v]:v,linkedIds:["get","linkedIds"],ignoreGlobalLighting:d,colorTextureUvIndex:_,nearCameraFade:u,showRatio:h,playAnimation:f,color:["match",["objectAttr","hovered"],[!0],t.hover?.color||$o,["match",["objectAttr","selected"],[!0],t.select?.color||$o,t.color||$o]]},minzoom:t.minZoom,maxzoom:t.maxZoom,interactive:this.interactive,interactiveOcclusion:this.interactiveOcclusion}),!this.layer)return;t.hover?.color&&(this.on("mouseover",this.switchToHoveredColor),this.on("mouseout",this.switchToNormalColor)),o.addLayer(this.layer,t.zIndex);const y=n.getTileCoordsByCenterAndZoom(this.position.normalizedValue,Xo),b=n.optionsToTileAttrs({model_src:t.modelSrc,linkedIds:t.linkedIds,db_plan_id:t.planId}),x=n.makeGeneratorContext(this.mapState.styleState,n.emptySourceAttrs,n.fixedTileProps,b,n.emptyFeatureAttrs,t.interactive?"0":"");n.runPrecomputes(this.layer,x),n.generateSafely({collector:a,generator:n.GltfModelGenerator.generateInstances,args:[o.getStyle(),this.layer,x,{x:[gn],y:[gn],z:[this.position.userValue[2]??0]},n.createTileInfo(y),NaN]});const T=a.getAccumulatedData(),w=new n.TileObject("dynamicObject",T.data,this.modules,this.mapState,y,this);c.fillDataModelUrlMap(T.dataModelsUrls),this.modelId=T.dataModelsUrls[t.modelSrc],this.modelId!==void 0&&(c.loadModel(t.modelSrc,this.modelId,n.DYNAMIC_STYLE_ID,!0,this.layer,!1,()=>{this.status==="visible"&&(r.addObject(w),this.modules.renderer.addRerenderEvent(),this.linkedIds&&this.map.hideBuildingsById(this.linkedIds),this.updateIdentifier()),setTimeout(()=>this.emit("modelloaded"),0)}),this.tileObjects.push(w),t.interactive&&this.identifyIds.push(T.identifyIds),l.addLayer(this),a.reset(),this.status==="visible"&&this.hideLinkedObjects())}update(){if(super.update(),!this.tickerNames.size)return;const e=[],t={};this.tickerNames.forEach((i,o)=>{n.update(i,{step:(a,r)=>{t[o]=r},complete:()=>{e.push(o)}},this.mapState)}),(t.coordinates!==void 0||t.rotation!==void 0||t.scale!==void 0||t.offset!==void 0)&&this.applyTransformations(t.coordinates,t.rotation,t.scale,t.offset),e.forEach(i=>{this.tickerNames.delete(i)}),this.interactive&&this.needRerender()&&this.modules.identifier.queryFillCache()}setState({hovered:e,selected:t}){e!==void 0&&e!==this.hovered&&(this.hovered=e,this.modules.renderer.addRerenderEvent()),t!==void 0&&t!==this.selected&&(this.selected=t,this.modules.renderer.addRerenderEvent())}isAnimationDisabled(){return this.disableAnimation}getLinkedIds(){return this.linkedIds}isVisible(){return this.status==="visible"}hide(){this.status==="visible"&&(this.status="hidden",this.tileObjects.forEach(e=>{this.modules.tileManager.removeObject(e)}),this.showHiddenBuildings(),this.showLinkedObjects(),this.mapState.shouldIsIdleWaitForUpdates=!0,this.modules.renderer.addRerenderEvent(),this.updateIdentifier())}isOutOfMainReplica(){return!1}show(){this.status==="hidden"&&(this.status="visible",this.tileObjects.forEach(e=>{this.modules.tileManager.addObject(e)}),this.linkedIds&&this.map.hideBuildingsById(this.linkedIds),this.hideLinkedObjects(),this.mapState.shouldIsIdleWaitForUpdates=!0,this.modules.renderer.addRerenderEvent(),this.updateIdentifier())}destroy(e){this.status!=="destroyed"&&(this.stopTransformation(),this.status="destroyed",this.modelId!==void 0&&!this.modules.layers.getDynamicObjectLayers().filter(i=>i instanceof _s&&i!==this).some(i=>i.modelId===this.modelId)&&!e&&this.modules.assetManager.removeModel(String(this.modelId)),this.updateIdentifier(),this.layer&&this.modules.dynamicStyle.removeLayer(this.layer.innerId),this.showHiddenBuildings(),this.off("mouseover",this.switchToHoveredColor),this.off("mouseout",this.switchToNormalColor),this.showLinkedObjects(),super.destroy())}transform(e){if(this.status==="destroyed"||!this.layer)return;this.stopTransformation();const t={};e.forEach(o=>{const a=Bg(o);if(!a)return;const{duration:r=0,easing:l="linear"}=o;t[a]={value:o[a],duration:r,easing:l}});const i={};for(const o in t){if(!Pg(o)||t[o]===void 0)continue;let a;if(o==="coordinates"?a=n.Mercator.fromGeo(t[o].value):o==="offset"?a=ml(t[o].value,t.coordinates?.value[1]??n.Mercator.toGeo(this.position.userValue)[1]):a=t[o].value,!t[o].duration){i[o]=a;continue}const r=`dynamicGltfModel-${o}-${this.uniqId}`;let l,c;if(o==="coordinates")l=this.position.userValue,c=a;else{const d=[0,0,0];n.getTriple(this.appliedTransformations[o],d),l=d;const _=[0,0,0];n.getTriple(a,_),c=_}n.start(r,{easing:t[o].easing,renderAfterUpdate:this.needRerender},this.mapState,l,c,t[o].duration,1,{layerId:this.layer.innerId,styleId:n.DYNAMIC_STYLE_ID}),this.tickerNames.set(o,r)}(i.coordinates!==void 0||i.rotation!==void 0||i.scale!==void 0||i.offset!==void 0)&&(this.applyTransformations(i.coordinates,i.rotation,i.scale,i.offset),this.modules.renderer.addRerenderEvent(),this.updateIdentifier())}stopTransformation(){this.tickerNames.forEach(e=>{n.stop(e,this.mapState)}),this.tickerNames.clear()}getCoordinates(){return n.Mercator.toGeo(this.position.userValue)}getScale(){const e=[0,0,0];return n.getTriple(this.appliedTransformations.scale,e),e}getRotation(){const e=[0,0,0];return n.getTriple(this.appliedTransformations.rotation,e),e}getOffset(){const e=[0,0,0];return n.getTriple(this.appliedTransformations.offset,e),e}applyTransformations(e,t,i,o){const a=this.tileObjects[0];if(!a)return;const r=a.buffers[0];if(r){if(e&&(this.position={userValue:e,normalizedValue:n.normalizeMapPoint(e)},a.setTileCoords(n.getTileCoordsByCenterAndZoom(this.position.normalizedValue,Xo),this.mapState)),t!==void 0||i!==void 0){const l=fl(t??this.appliedTransformations.rotation),c=i??this.appliedTransformations.scale;this.appliedTransformations.rotation=l,this.appliedTransformations.scale=c}if(o!==void 0){const l=o??this.appliedTransformations.offset;this.appliedTransformations.offset=l}n.getTriple(this.appliedTransformations.offset,hl),n.getTriple(this.appliedTransformations.scale,_l),n.getTriple(this.appliedTransformations.rotation,ul),n.GltfModelGenerator.patchBuffer(r,0,n.createTileInfo(a.coords),[gn,gn,this.position.userValue[2]??0],hl,_l,ul,(this.layer?.minzoom??0)<n.globeConfig.globeMaxZoom)}}switchToHoveredColor(){this.hovered=!0,this.modules.renderer.addRerenderEvent()}switchToNormalColor(){this.hovered=!1,this.modules.renderer.addRerenderEvent()}updateIdentifier(){this.interactive&&this.modules.identifier.resetCache()}showLinkedObjects(){const e=this.planId?n.FLOOR_ID_SCOPE:n.DYNAMIC_MODEL_ID_SCOPE;this.linkedIds&&this.modules.identifier.getIdScope(e).show(this.linkedIds)}hideLinkedObjects(){const e=this.planId?n.FLOOR_ID_SCOPE:n.DYNAMIC_MODEL_ID_SCOPE;this.linkedIds&&this.modules.identifier.getIdScope(e).hide(this.linkedIds)}showHiddenBuildings(){if(!this.linkedIds)return;const e=this.modules.layers.getDynamicObjectLayers().filter(t=>t instanceof _s&&t!==this&&t.isVisible());this.linkedIds.forEach(t=>{e.every(o=>!o.getLinkedIds()?.includes(t))&&this.map.showHiddenBuildingsById([t])})}};const _l=[0,0,0],ul=[0,0,0],hl=[0,0,0];function fl(s){return Array.isArray(s)?s.map(e=>e%360):s%360}function ml(s,e){const t=Cg/n.Mercator.scaleFactor(e),i=["x","y"].filter((o,a)=>{const r=Array.isArray(s)?s[a]:s;return r<-t||r>t});return i.length&&console.warn(`
            The offset is too big along ${i.map(o=>`${o}-axis`).join(" and ")} at the current latitude.
            Please, use more accurate coordinates to place the model.
        `),Array.isArray(s)?[s[0]%t,s[1]%t,s[2]]:[s%t,s%t,s]}function Pg(s){return Lg.includes(s)}function Bg(s){if("coordinates"in s)return"coordinates";if("rotation"in s)return"rotation";if("scale"in s)return"scale";if("offset"in s)return"offset"}const zg=[0,0,0],Rg=[0,0,0],Fg=[0,0,0],Dg="modelshow",Og="modelhide",yn=0,pl=.1;class Ng{constructor(e,t){this.sceneObjects=new Map,this.sceneObjectsVisibilityMap=new Map,this.viewportDiffer=new n.Differ([{path:"center",type:"vec3"},{path:"zoom",type:"number"},{path:"size",type:"vec2"},{path:"rotation",type:"number"},{path:"pitch",type:"number"},{path:"padding",type:"padding"},{path:"demMode",type:"boolean"},{path:"elevation",type:"number"},{path:"minElevation",type:"number"}]),this.mapState=e,this.mapModules=t,this.modelsAnimator=new Sg(e,t),this.modelInfo={},this.buildingIds=new Set,this.objectIdToLayerModelKey={},this.linkedIdToObjectId={},this.layerModelKeyBySourceTile=new Map,this.disabled=!1}addLayerModelToSourceTileMap(e,t){const i=e,o=qo(t.attributes.styleId,t.attributes.sourceId,t.tile.coords),a=this.layerModelKeyBySourceTile.get(o);a?a.add(i):this.layerModelKeyBySourceTile.set(o,new Set([i]))}clearSourceTileMapByTiles(e,t){t.map(i=>qo(this.mapState.handyStyleId,e,i.coords)).forEach(i=>this.layerModelKeyBySourceTile.delete(i))}clearSourceTileMapBySource(e){Array.from(this.layerModelKeyBySourceTile).map(i=>i[0]).filter(i=>i.split("_")[1]===String(e)).forEach(i=>this.layerModelKeyBySourceTile.delete(i))}getCurrentLayerModelId(e,t){const i=bn(e);return this.modelInfo[i]?.modelIds[t.id]}getModelOpacity(e){if(e===void 0)return yn;const t=bn(e.attributes);return t?this.modelsAnimator.getReadiness(t)??yn:yn}getModelHeightFactor(e){if(!e)return 1;const t=bn(e.attributes);return this.modelsAnimator.getReadiness(t)??1}isAnimating(e){if(!e)return this.modelsAnimator.isAnimating();const t=this.linkedIdToLayerModelKey(e);return t?this.modelsAnimator.isAnimating(t):!1}objectIdToKey(e){return this.objectIdToLayerModelKey[e]}update(){this.syncStateWithSceneObjects(),this.modelsAnimator.update().length&&this.addNewSceneObjectsToVisibilityMap(),this.viewportDiffer.check(this.mapState)&&this.checkSceneObjectsVisibilityMap(),this.updateObjectsVisibility()}addSceneObject(e){const t=bn(e.attributes);let i=this.modelInfo[t];i?this.objectIdToLayerModelKey[e.id]||this.indexateObject(t,e,i):i=this.addLayerModel(e,t),i&&(i.modelIds[e.tile.id]=e.renderingProperties.modelId,this.sceneObjects.set(e.id,{...e,key:t}),this.addLayerModelToSourceTileMap(t,e))}removeSceneObject(e){this.sceneObjects.delete(e),delete this.objectIdToLayerModelKey[e]}allObjectsHaveCurrentModelId(e,t,i){const o=qo(i,e,t),a=this.layerModelKeyBySourceTile.get(o);if(!a)return!0;for(const r of a){const l=this.modelInfo[r]?.modelIds;if(!l)return!1;for(const c in l)if(l[c]===void 0)return!1}return!0}finishStyleUpdating(){Array.from(this.layerModelKeyBySourceTile).map(t=>t[0]).filter(t=>t.split("_")[0]!==String(this.mapState.handyStyleId)).forEach(t=>this.layerModelKeyBySourceTile.delete(t))}updateModelId(e,t,i,o,a){const{assetManager:r,sourceStorage:l,styleManager:c,camera:d,defaultSource:_}=this.mapModules,u=this.mapState;e.modelId=void 0;const{styleId:h,layerId:f,sourceId:m,sourceName:p,modelIndices:v,modelStepValues:y,modelStepSource:b}=t;if(!v.length)return;let x;switch(b){case n.ModelStepSource.None:x=0;break;case n.ModelStepSource.Zoom:x=vl(y,u.styleZoom);break;case n.ModelStepSource.Distance:x=kg(o,i,d.position,y,a);break;default:return}if(x===-1)return;const T=v[x];if(T===void 0)return;const w=r.getModel(T,h);if(w)switch(w.status){case Ze.Loaded:e.modelId=T;const z=w.scenes.find((S,I)=>typeof t.scene=="number"&&!Number.isNaN(t.scene)&&I===t.scene||typeof t.scene=="string"&&S.name===t.scene)??w.scenes.find((S,I)=>I===w.defaultScene)??w.scenes.find((S,I)=>I===0);e.sceneId=z?.id,w.usedEmptyScene=(w.scenes.find(S=>S.id===e.sceneId)?.objects.length??0)===0;return;case Ze.Failed:e.modelId=NaN;return}else{const z=c.getStyleLayer(h,f),S=r.getDataModelUrlById(T);if(z&&!this.disabled){if(S===void 0)r.loadModelByIndex(T,h,z);else if(S.length){const I=m===_.getId()&&p===dn;r.loadModel(S,T,h,!1,z,I)}}}if(v.length===1)return;const M=l.getSourceById(m);M&&(b===n.ModelStepSource.Zoom?e.modelId=this.getModelIdByZoom(M,t,o,x):b===n.ModelStepSource.Distance&&(e.modelId=this.getModelIdByDistance(t,o)))}getModelIdByDistance(e,t){return this.getCurrentModelId(e,t)}getModelIdByZoom(e,t,i,o){const{styleId:a,modelIndices:r}=t,l=e.getZoomDirection();if(l===n.ZoomDirection.Stationary)return this.getCurrentModelId(t,i);const c=r.slice(0,o).reverse(),d=r.slice(o+1),_=l===n.ZoomDirection.ZoomingIn?c.concat(d):d.concat(c);for(let u=0;u<_.length;u++){const h=this.mapModules.assetManager.getModel(_[u],a);if(h&&h.status===Ze.Loaded)return _[u];if(h?.status===Ze.Failed)return NaN}}getCurrentModelId(e,t){const i=this.getCurrentLayerModelId(e,t);if(!i)return;const o=this.mapModules.assetManager.getModel(i,e.styleId);if(o&&o.status===Ze.Loaded)return i;if(o?.status===Ze.Failed)return NaN}syncStateWithSceneObjects(){if(this.disabled=this.mapModules.map.getFeatureFlag("modelsOff"),this.disabled){this.destroy();return}const e=new Set,t=new Set,i=Array.from(this.sceneObjects.values());for(let a=0;a<i.length;a++)this.processSceneObject(i[a],e,t);for(const a of t)this.sceneObjects.delete(a),delete this.objectIdToLayerModelKey[a];const o=this.mapState.styleZoom;for(const a of Object.keys(this.modelInfo)){const r=this.modelInfo[a];(!e.has(a)||o<r.layer.minzoom||o>=r.layer.maxzoom)&&this.removeLayerModel(a,r)}}processSceneObject(e,t,i){if(e.tile.destroyed){i.add(e.id);return}const o=e.key,a=this.modelInfo[o],r=this.mapState.disableModelsGrowthAnimation||e.tile.dynamicObject instanceof Ko&&e.tile.dynamicObject.isAnimationDisabled();a&&!this.modelsAnimator.has(o)&&(this.mapModules.defaultSource.createModelsSource(),this.startAnimation(o,a,r)),a?this.objectIdToLayerModelKey[e.id]||this.indexateObject(o,e,a):this.addLayerModel(e,o,!0),t.add(o)}addLayerModel(e,t,i=!1){const o=this.mapModules.styleManager.getStyleLayer(e.attributes.styleId,e.attributes.layerId);if(!o)return;if(i){const r=this.mapState.styleZoom;if(r<o.minzoom||r>=o.maxzoom)return}const a={layer:o,ids:e.tile.ids,linkedIds:[],ownerIds:new Set,modelIds:{},buildingId:e.meta?.buildingId||""};return e.meta?.planId&&(a.planId=e.meta.planId),this.indexateObject(t,e,a),this.modelInfo[t]=a,a}startAnimation(e,t,i){if(i){this.modelsAnimator.add(e,1,1);return}const o=t.layer.minzoom??NaN;t.linkedIds.length>0&&this.mapModules.buildingHeightAnimator.getBuildingHeight(o)>.5?this.modelsAnimator.add(e,.5,1):this.modelsAnimator.add(e)}maybeEmitModelEvent(e,t,i){const o=!t.onKeyRemove&&!!i&&n.tetragonIntersectsBounds(i,{min:e.mapPoint,max:e.mapPoint}),a=e.visible;o!==a&&(e.visible=o,this.emitEvent(o&&!a?Dg:Og,e))}addNewSceneObjectsToVisibilityMap(){const e=this.mapModules.camera.getViewportVertices(pl),t=Array.from(this.sceneObjects.values());for(let i=0;i<t.length;i++){const o=t[i];if(o.attributes?.emitShowHideEvents&&o.meta?.buildingId&&o.attributes.lngLat){const a=o.key,r={visible:!1,mapPoint:n.Mercator.fromGeo(o.attributes.lngLat),buildingId:o.meta?.buildingId||"",sublayer:o.meta?.sublayer||"",key:a};let l=this.sceneObjectsVisibilityMap.get(a);l||(l=new Map,this.sceneObjectsVisibilityMap.set(a,l)),l.get(o.meta.buildingId)||(l.set(o.meta.buildingId,r),this.maybeEmitModelEvent(r,{onKeyShow:!0},e))}}}checkSceneObjectsVisibilityMap(){const e=this.mapModules.camera.getViewportVertices(pl);this.sceneObjectsVisibilityMap.forEach(t=>t.forEach(i=>this.maybeEmitModelEvent(i,{},e)))}indexateObject(e,t,i){this.objectIdToLayerModelKey[t.id]=e,i.ownerIds.add(t.id),i.buildingId=t.meta?.buildingId||"",i.buildingId&&this.buildingIds.add(i.buildingId);const o=t.meta?.linkedIds??[];if(i.linkedIds.push(...o),t.tile.purpose!=="c3d")for(const a of o)this.linkedIdToObjectId[a]=t.id}removeLayerModel(e,t){t.ids?.show(t.linkedIds);for(const o of t.ownerIds)delete this.objectIdToLayerModelKey[o];t.buildingId&&this.buildingIds.delete(t.buildingId),this.modelsAnimator.remove(e);const i=this.sceneObjectsVisibilityMap.get(e);i&&(i.forEach(o=>this.maybeEmitModelEvent(o,{onKeyRemove:!0})),this.sceneObjectsVisibilityMap.delete(e)),delete this.modelInfo[e]}linkedIdToLayerModelKey(e){const t=this.linkedIdToObjectId[e];if(!t)return null;const i=this.objectIdToLayerModelKey[t];return i||null}emitEvent(e,t){const{buildingId:i,sublayer:o}=t;if(!o){console.warn(`No sublayer for model ${t.key}`);return}if(!i){console.warn(`No buildingId for model ${t.key}`);return}const a=n.isCommercialModel(o);this.mapModules.map.emit(e,{sublayer:o,id:i,isCommercial:a})}updateObjectsVisibility(){const e=this.mapModules.identifier.getIdScope(n.DYNAMIC_MODEL_ID_SCOPE),t=this.mapModules.identifier.getIdScope(n.DEFAULT_ID_SCOPE);e.getHidden().forEach(i=>{t.hide([i],n.HideLevel.All)});for(const i in this.modelInfo){const o=this.modelInfo[i],a=o.ids;if(!a)continue;const r=this.modelsAnimator.getReadiness(i)??yn;for(const l of o.linkedIds){if(a.isHidden(l))continue;const c=o.planId!==void 0?n.HideLevel.FloorPolygons:n.HideLevel.PolygonExtrusion,d=a.isHidden(l,c);r>.5&&!d?a.hide([l],c):r<.5&&d&&a.show([l])}}}destroy(){this.mapModules.defaultSource.destroyModelsSource();for(const e in this.modelInfo){const t=this.modelInfo[e];this.removeLayerModel(e,t)}this.sceneObjects.clear()}}function bn(s){const{layerId:e,modelIndices:t}=s;return`${e}_${t.join(",")}`}function qo(s,e,t){return`${s}_${e}_${JSON.stringify(t)}`}function kg(s,e,t,i,o){const a=s.modelMatrices.get(0);if(!a)return-1;let r=e.min,l=e.max;o||(r=n.transformMat4$1(Rg,r,a),l=n.transformMat4$1(Fg,l,a));const c=n.projectToXyRect(t,r,l,zg),d=n.Mercator.toGeo(c),_=n.Mercator.scaleFactor(d[1]),u=n.dist$1(t,c)/n.MAP_POINTS_IN_METER/_;return vl(i,u)}function vl(s,e){let t=0;for(;t<s.length&&!(e<s[t]);)t++;return t-1}const Ug=n.bezier(.42,0,1,1),Gg=(s,e,t,i)=>e+t*Ug(s/i),Hg=n.bezier(0,0,.58,1),Vg=(s,e,t,i)=>e+t*Hg(s/i),jg=n.bezier(.42,0,.58,1),Zg=(s,e,t,i)=>e+t*jg(s/i);function gl(s){switch(s[0]){case"cubic-bezier":{const e=n.bezier(s[1],s[2],s[3],s[4]);return(t,i,o,a)=>i+o*e(t/a)}case"exponential":{const e=s[1];return(t,i,o,a)=>{const r=i,l=i+o,c=t/a,_=(e**c-1)/(e**1-1);return(1-_)*r+_*l}}case"ease":return n.ease;case"ease-in":return Gg;case"ease-out":return Vg;case"ease-in-out":return Zg;case"linear":return n.linear;default:return n.assertUnreachable(s,!0),console.warn("Invalid texture animation easing:",s),console.warn('Fallback to "linear".'),n.linear}}class Wg{constructor(e,t){this.rerenderEvents=[],this.prevObjects=new Map,this.currentObjects=new Map,this.doubleSampledTextureAnimationStateMap=new Map,this.mapState=e,this.modules=t}frameEnd(){this.rerenderEvents.forEach(e=>this.modules.renderer.addRerenderEvent(e)),this.clearUnusedAnimationState(),this.doubleSampledTextureAnimationStateCleanup()}frameStart(){this.rerenderEvents=[]}clearAllTickers(){for(const e of this.currentObjects.keys())n.stop(e,this.mapState);this.clearUnusedAnimationState(),this.prevObjects=new Map,this.currentObjects=new Map}update(){const e=Date.now()+ +(this.mapState.styleState._customUserTimeOffset||0);[...this.prevObjects.values()].some(i=>i.timeToUpdate&&i.timeToUpdate<e)&&this.refresh()}animateGltfObject(e,t,i){const{localMatrix:o,animationStack:a,transformStack:r}=e.renderingProperties;if(t.style.playAnimation===void 0||!a?.length||!o||!a||!r)return;const l=this.updateAnimationKeyframes(e,t);mr(o,a,r,i.buffers,l)}animatePolygonNormalMapTexture(e,t){if(!t.style.normalMapTextureAnimation)return[!1,[0,0,0,0]];let i=1;const o=t.innerId,a=e.attributes.styleId,r=`${a}_${o}`,l=Date.now(),[[c,d],[_,u],[h,f],m,p,v,y,b]=this.resolveDoubleSampledTextureAnimationOptions(t),x=[h,f,0,0];if(this.mapState.disableLayerAnimation)return[!1,x];const T=this.doubleSampledTextureAnimationStateMap.get(r)??{lastKnownOffsets:x,animationStage:0,previousTimestamp:l},{lastKnownOffsets:w,previousTimestamp:M,animationStage:z}=T;let S=z;const I=(l-M)/1e3;switch(z){case 0:{let C=!1;const j=n.makeBinderContext(this.mapState.styleZoom,this.mapState.styleState,[]),H=n.resolveString(t.style.normalMapTextureImage,j),K=this.modules.styleManager.getStyle(a);if(K){const Y=K.rasterSets.byKey[n.getStaticTextureRasterSetKey(H)];Y&&Y.isReady&&(C=!0)}C&&(p?(n.start(`${r}_animationSpeedUp`,{easing:gl(v),forceFinalValue:!0,renderAfterUpdate:!1},this.mapState,0,1,p,1),S=1):(m!==1/0&&n.start(`${r}_animationFullSpeed`,{forceFinalValue:!0,renderAfterUpdate:!1},this.mapState,1,1,m,1),S=2));break}case 1:{n.update(`${r}_animationSpeedUp`,{keepFinished:!0,step:(C,j,H,K)=>{K?(i=1,n.stop(`${r}_animationSpeedUp`,this.mapState),m!==1/0&&n.start(`${r}_animationFullSpeed`,{forceFinalValue:!0,renderAfterUpdate:!1},this.mapState,1,1,m,1),S=2):i=j}},this.mapState);break}case 2:{m===1/0||n.update(`${r}_animationFullSpeed`,{keepFinished:!0,step:(C,j,H,K)=>{K&&(n.stop(`${r}_animationFullSpeed`,this.mapState),y?(n.start(`${r}_animationSlowDown`,{easing:gl(b),forceFinalValue:!0,renderAfterUpdate:!1},this.mapState,1,0,y,1),S=3):S=4)}},this.mapState);break}case 3:{n.update(`${r}_animationSlowDown`,{keepFinished:!0,step:(C,j,H,K)=>{K?(i=0,n.stop(`${r}_animationSlowDown`,this.mapState),S=4):i=j}},this.mapState);break}case 4:{i=0;break}}const R=[w[0]+c*i*I,w[1]+d*i*I,w[2]+_*i*I,w[3]+u*i*I].map(C=>C%1);return this.doubleSampledTextureAnimationStateMap.set(`${a}_${o}`,{animationStage:S,lastKnownOffsets:R,previousTimestamp:l,updatedOnThisFrame:!0,styleId:a,layerId:o}),S!==4&&this.rerenderEvents.push({type:"layerAnimationTicker",layerId:o,styleId:a,underCache:!0}),[!0,R]}doubleSampledTextureAnimationStateCleanup(){for(const[e,t]of this.doubleSampledTextureAnimationStateMap)if(t.updatedOnThisFrame)t.updatedOnThisFrame=!1,this.doubleSampledTextureAnimationStateMap.set(e,t);else{if(this.modules.renderCacheManager.isLayerInCache(t.styleId,t.layerId))return;this.doubleSampledTextureAnimationStateMap.delete(e),n.stop(`${e}_animationSpeedUp`,this.mapState),n.stop(`${e}_animationFullSpeed`,this.mapState),n.stop(`${e}_animationSlowDown`,this.mapState)}}resolveDoubleSampledTextureAnimationOptions(e){const t=n.makeBinderContext(this.mapState.styleZoom,this.mapState.styleState,[]),i=n.resolveTextureAnimationExpression(e.style.normalMapTextureAnimation,t),o=i[1]??0,a=i[2]??0,r=i[3]??0,l=i[4]??0,c=i[5]??0,d=i[6]??0,_=i[7]??1/0,u=i[8]??0,h=i[9]??["linear"],f=i[10]??0,m=i[11]??["linear"];return[[o,a],[r,l],[c,d],_,u,h,f,m]}clearUnusedAnimationState(){for(const e of this.prevObjects.keys())if(!this.currentObjects.has(e)){const t=this.prevObjects.get(e);t&&this.modules.renderCacheManager.isLayerInCache(t.styleId,t.layerId)?this.currentObjects.set(e,t):n.stop(e,this.mapState)}this.prevObjects=new Map(this.currentObjects),this.currentObjects=new Map}refresh(){this.modules.renderer.addRerenderEvent()}updateAnimationKeyframes(e,t){if(e.layerSettings.depthTest||e.layerSettings.shadow||this.mapState.disableLayerAnimation)return;const{animationStack:i}=e.renderingProperties;if(!i)return;const o=new Map,a=this.applyAnimationState(t,e);for(const r of i){const l=a.animationStateID,c=n.get(l,this.mapState);if(this.isNeedAnimation(r,a)){if(!c&&a.currentCount>0){const d=a.animationDuration||(r.max?r.max[0]:0),_=a.startOffset||0;let u=a.startOffset?r.frameCount/(r.frameCount*d/_):0,h=d*(1e3/a.playSpeed)-_*(1e3/a.playSpeed);a.elapsedTime&&(u=1-a.elapsedTime,h=d*(1e3/a.playSpeed)*a.elapsedTime),n.start(l,{easing:"linear",forceFinalValue:!0,renderAfterUpdate:!1},this.mapState,u,1,h,1)}n.update(l,{keepFinished:!0,step:(d,_,u,h)=>{const f=(r.frameCount-1)*_;o.set(r.actionId,f),h||this.rerender(e,t,a)},complete:d=>{a.currentCount>0&&a.currentCount--,a.currentCount>0&&(n.stop(l,this.mapState),this.rerender(e,t,a))}},this.mapState),this.currentObjects.set(l,a)}}return o}initObjectAnimationState(e,t){const i=this.resolveGltfAnimationOptions(e,t),o=typeof i[0]=="object"&&!Array.isArray(i[0])&&i[0].type==="schedule-detailed-result"?i[0].value:i[0],a=typeof i[0]=="object"&&!Array.isArray(i[0])&&i[0].type==="schedule-detailed-result"?i[0].currentStepElapsed/1e3:void 0,r=i[2]??1/0,l=r,c=i[1]||1,d=i[4]||void 0,_=i[3]||a||void 0,u=typeof o=="number"?o:void 0,h=typeof o=="string"?o:void 0,f=typeof o=="object"&&Array.isArray(o)?o:void 0;return{repeatCount:r,playSpeed:c,animationIndex:u,animationName:h,currentCount:l,animations:f,animationDuration:d,startOffset:_,tickerByStep:!!(_&&d),animationStateID:i[5]?.toString()||`${t.attributesHash}`,timeToUpdate:i[6],layerId:e.innerId,styleId:t.attributes.styleId}}resolveGltfAnimationOptions(e,t){if(e.type!=="gltfModel")return{type:"animation-options"};const i=n.makeBinderContext(this.mapState.styleZoom,this.mapState.styleState,t.attributes.tileData);let o;i.callBackFn=r=>{o=r};const a=n.resolveAnimationExpression(e.style.playAnimation,i);return a[6]===void 0&&o&&(a[6]=o),a}isNeedAnimation(e,t){return t.animationIndex!==void 0&&e.animationIndex===t.animationIndex||t.animationName!==void 0&&e.animationName===t.animationName||t.animations!==void 0&&t.animations.includes(e.animationIndex)||t.animations!==void 0&&t.animations.includes(e.animationName)}applyAnimationState(e,t){const i=this.initObjectAnimationState(e,t),o=this.prevObjects.get(i.animationStateID);return o&&(o&&(o?.animationIndex!==i.animationIndex||o?.animationName!==i.animationName)?(n.update(i.animationStateID,{keepFinished:!0,step:(a,r)=>{o.elapsedTime?(o.elapsedTime>0||o.elapsedTime<1)&&(i.elapsedTime=o.elapsedTime):(o.elapsedTime=r,i.elapsedTime=r)}},this.mapState),n.stop(i.animationStateID,this.mapState)):i.repeatCount===o.repeatCount&&(i.currentCount=o.currentCount)),i}rerender(e,t,i){i.repeatCount!==0&&!i.tickerByStep&&(this.rerenderEvents.push({type:"layerAnimationTicker",layerId:t.innerId,styleId:e.attributes.styleId}),this.modules.identifier.queryFillCache())}}const qe=.1,$g={id:"simple-mesh",type:"simpleMesh",innerId:n.SIMPLE_MESH_STYLE_LAYER_ID,filter:!1,minzoom:0,maxzoom:20,precomputes:[],renderIndex:0,style:{}},Yo={polygonsQty:1e4,drawCallsQty:150,iterations:7},yl=[18,34],Xg=1e3,hi="__MAPGL_BENCH_TIME",Kg=5,Xt=class Xt{constructor(e,t){this.state=e,this.modules=t,this.buffer=null,this.sceneObjects=[],this.timeout=1/0,this.scale=n.fromValues(1,1,1),this.startTs=0,this.de=st(this.state,this.modules),this.framebufferId=this.createFramebuffer(),this.modules.dynamicStyle.addLayer($g)}static mockResult(e){Xt.mocked=e}async run(e=Yo.polygonsQty,t=Yo.drawCallsQty,i=Yo.iterations,o=Xg){if(Xt.mocked)return Xt.mocked;const a=this.getCachedResult();if(a)return a;this.timeout=o,this.startTs=performance.now();try{return await this._run(e,t,t*i,i)}catch{return{status:"error"}}}getScale(){return this.scale}destroy(){this.modules.renderer.removeFramebuffer(this.framebufferId),this.buffer=null,this.sceneObjects=[],this.modules.dynamicStyle.removeLayer(n.SIMPLE_MESH_STYLE_LAYER_ID)}getCachedResult(){try{const e="v1.70.1",t=localStorage.getItem(hi);if(t){const i=t.split(":"),o=i[0];if(e===o){const a=i.slice(1).join(":").split(",").map(r=>parseFloat(r)).filter(r=>!Number.isNaN(r));if(a.length>=Kg){const r=a.reduce((c,d)=>c+d,0)/a.length;return{status:"cached",tier:this.selectTier(r)}}}}}catch{}return null}selectTier(e){const t=yl.findIndex(i=>e<=i);return t>-1?yl.length-t:0}saveResult(e){try{const t="v1.70.1",i=localStorage.getItem(hi);if(i){const o=i.split(":"),a=o[0];if(t!==a)localStorage.setItem(hi,`${t}:${e.toPrecision(4)}`);else{const r=o.slice(1).join(":").split(",").map(l=>parseFloat(l)).filter(l=>!Number.isNaN(l));r.push(e),localStorage.setItem(hi,`${t}:${r.map(l=>l.toPrecision(4)).join(",")}`)}}else localStorage.setItem(hi,`${t}:${e.toPrecision(4)}`)}catch{}}async _run(e,t,i,o){const a=this.modules.renderer.getFramebuffer(this.framebufferId);if(!a)throw new Error("Failed to create framebuffer for benchmark.");this.modules.renderer.bindRenderTarget(a.renderTarget),this.modules.renderer.setViewport(0,0,this.modules.renderer.getViewportSize()[0],this.modules.renderer.getViewportSize()[1]);const r=this.prepareData(e,i),l=await this.measureRendering(o,t);if(this.modules.renderer.bindRenderTarget(null),l.length<3)return{status:"timeout"};const c=this.processResults(l),d=Math.min(c.mean,c.median);this.saveResult(d);const _=this.selectTier(d);return{status:l.length<o?"part-done":"done",tier:_,measurements:c,preparation:r}}prepareData(e,t){const i=performance.now();this.buffer=this.generateSphere(e);const o=performance.now(),a=performance.now();this.sceneObjects=this.createSceneObjects(t);const r=performance.now();return{generationTime:o-i,objectsTime:r-a}}async measureRendering(e,t){return new Promise(i=>{const o=[];let a=0,r=0;const l=()=>{const c=performance.now();if(c-this.startTs>this.timeout){i(o);return}this.modules.renderer.clear(!0),this.scale[0]+=.5-Math.random(),io(this.state,this.modules,this.sceneObjects.slice(r,r+t),this.de),this.modules.renderer.waitForGpuCommandsToFinish(),o.push(performance.now()-c),a++,r+=t,a<e?Promise.resolve().then(l):i(o)};setTimeout(()=>{l()},0)})}processResults(e){const t=e.slice();t.sort((o,a)=>o-a);const i=t.slice(0,t.length-.2*t.length);return{median:i[Math.floor(i.length/2)],mean:i.reduce((o,a)=>o+a,0)/i.length,min:i[0],max:i[i.length-1]}}generateSphere(e){const t=Math.floor(Math.sqrt(e/2)),i=t*2,l=t*i*2*3*3,c=new Float32Array(l);let d=0;const _=Math.PI/t,u=2*Math.PI/i,h=new Float32Array(3),f=new Float32Array(3),m=new Float32Array(3),p=new Float32Array(3);for(let v=0;v<t;v++){const y=v*_,b=(v+1)*_,x=Math.sin(y),T=Math.cos(y),w=Math.sin(b),M=Math.cos(b);for(let z=0;z<i;z++){const S=z*u,I=(z+1)*u,R=Math.sin(S),C=Math.cos(S),j=Math.sin(I),H=Math.cos(I);h[0]=qe*x*C,h[1]=qe*T,h[2]=qe*x*R,f[0]=qe*x*H,f[1]=qe*T,f[2]=qe*x*j,m[0]=qe*w*C,m[1]=qe*M,m[2]=qe*w*R,p[0]=qe*w*H,p[1]=qe*M,p[2]=qe*w*j,c.set(h,d),c.set(m,d+3),c.set(f,d+6),c.set(m,d+9),c.set(p,d+12),c.set(f,d+15),d+=18}}return c.buffer}createFramebuffer(){const e=new pe({size:this.modules.renderer.getViewportSize(),magFilter:g.NearestFilter,minFilter:g.NearestFilter,wrapS:g.ClampToEdgeWrapping,wrapT:g.ClampToEdgeWrapping,type:g.Float,flipY:!0});return this.modules.renderer.addFramebuffer({clearColor:[0,0,0,0],renderTarget:e,onResize:()=>{}})}createSceneObjects(e){const t={programName:"simpleMesh",vaoCreator:Qs,stateBinder:()=>Wn,programBinder:xu,tileBinder:()=>!0,objectBinder:Wu,needsVisibilityBuffer:!1},i=[],o=Qs(this.modules.renderer.createBuffer(this.buffer),this.modules.renderer.getShaderProgram("simpleMesh")),a=new n.TileObject("zenith",[],this.modules,this.state),r={layerId:n.SIMPLE_MESH_STYLE_LAYER_ID,styleId:n.DYNAMIC_STYLE_ID,tileData:[]};for(let l=0;l<e;l++){const d=(l/20&1)===0?1-(1+l%10)/10:(1+l%10)/10,_=n.fromValues(-1+l%20/10,1-Math.floor(l/20)*2/(e/20),0);i.push({id:n.uniqId(),type:n.SceneObjectType.Tile,start:0,count:this.buffer.byteLength/12,attributesHash:`benchmark-${l}`,vao:o,drawMode:n.GL_TRIANGLES,tile:a,symbol:"simpleMesh",sink:"fill",layerSettings:t,canRender:!0,attributes:r,meta:{scale:d,transform:_},renderingProperties:{}})}return i}};Xt.mocked=null;let xn=Xt;class qg{constructor(e,t,i){this.benchmark=null,this.map=i,this.camera=new n.Camera(e),this.layout=new fg(t),this.collector=new n.Collector("main"),this.workers=new zv,this.identifier=new hv(e,this),this.styleManager=new yv(this),this.assetManager=new xv(e,this),this.imageManager=new mg(this),this.floorManager=new Qv(e,this),this.personalPoiManager=new Iv(this),this.buildingHeightAnimator=new Qc(e,this),this.modelsScene=new Ng(e,this),this.renderer=new ui(e,this),this.newRenderer=new uv(e,this),this.layers=new $v(this),this.sourceStorage=new gg,this.tileManager=new ng(e,this),this.modelLayer=new Ev(e,this),this.dynamicStyle=new n.DynamicStyle,this.imageCache=new Kv(this),this.labeler=new cg(e,this),this.trafficTileLayer=new ug(e,this),this.handler=new dg(e,this),this.mouseMoveHandler=new Kc(this),this.tileKeyInfo=new vg(e),this.demManager=new k_(this),this.environmentManager=new wg(this),this.defaultSource=new jr(e,this),this.labelsDebug=new bg(e,this),this.postEffectsManager=new vu(e,this),this.renderCacheManager=new av(e,this),this.animationManager=new Wg(e,this),this.shadowManager=new fu(e,this),this.instanceLinker=new of(this),e.graphicsPresetMode==="auto"&&(this.benchmark=new xn(e,this))}destroy(){this.demManager.disable(),this.imageManager.destroy(),this.trafficTileLayer.destroy(),this.tileManager.destroy(),this.workers.destroy(),this.identifier.destroy(),this.renderer.destroy(),this.newRenderer.destroy(),this.handler.destroy(),this.mouseMoveHandler.destroy(),this.labelsDebug.hide(),this.renderCacheManager.destroy(),this.tileKeyInfo.destroy(),this.layout.destroy()}}const Qo=["light","normal","immersive"],Yg=["immersiveRoadsOff","shadowsOff","fogOff","skyOff","modelsOff","globeOff","transparentBuildingsOff","AALinesOff"],Qg=.3,Kt=class Kt{constructor(e,t={},i){this.requestedFrame=requestAnimationFrame(()=>{}),this.isStyleUpdateInProgress=!1,this.isFirstStyleUpdate=!0,this.lastResizeTime=-1/0,this.replicasDiffer=new n.Differ([{path:"visibleMapReplicas",type:"replicas"}]),this.graphicsPresetDiffer=new n.Differ([{path:"graphicsPreset",type:"string"}]),this.lastDpr=window.devicePixelRatio,this.renderLoop=u=>{if(this.modules.renderer.isDestroyed)return;this.requestedFrame=requestAnimationFrame(this.renderLoop),this.updateImmersiveLevel();const h=window.devicePixelRatio;h!==this.lastDpr?(this.lastDpr=h,this.state.dpiChanged=!0,this.modules.map.invalidateSize(),this.modules.imageCache.clear()):this.state.dpiChanged=!1,this.modules.map.emit("framestart");const f=this.state;f.time=Date.now(),this.processMetrics(),this.state.enableTrackResize&&this.autoResize(u),this.modules.mouseMoveHandler.update(),this.handlers.forEach(p=>p.update()),zc(f),Ic(f),Lc(f),Bc(f),this.stillnessUpdater.update(f),Mc(f,this.modules.layout.rootContainer),pc(f,this.modules.layout.rootContainer,this.modules.renderer),wc(f,this.modules.renderer);const m=this.modules.demManager.getReliefTileType()==="vector"&&f.styleZoom<ca;if(f.demMode=this.checkDemEnabled()&&f.elevationScale>0&&!m,this.checkGlobeEnabled(),this.modules.camera.update(),this.updateElevation(),this.updateTilesBounds(),this.replicasDiffer.check(f)&&(f.needReplicasUpdate=!0),this.modules.demManager.update(),this.modules.environmentManager.update(),this.modules.labelsDebug.update(),this.modules.trafficTileLayer.update(),this.modules.layers.getLayers().forEach(p=>{p.update!==void 0&&p.update()}),this.modules.tileManager.update(),this.modules.instanceLinker.update(),this.modules.sourceStorage.updateViewportSources(),this.modules.floorManager.update(),this.modules.modelLayer.update(),this.modules.personalPoiManager.update(),this.modules.dynamicStyle.update(),this.modules.styleManager.update(),this.modules.buildingHeightAnimator.update(),this.modules.modelsScene.update(),this.modules.shadowManager.update(),this.modules.animationManager.update(),this.modules.map.emit("update"),this.modules.labeler.update(),this.performanceChecker.update(),this.modules.identifier.update(),this.modules.postEffectsManager.update(),f.loopWorld&&!this.modules.renderer.isNeedRerender()&&n.worldWrapX(f.center),(n.render.alwaysRerender||this.modules.renderer.isNeedRerender())&&f.collectStats&&(f.stats.drawCount=0,f.stats.vertexCount=0,f.stats.triangleCount=0,f.stats.drawCountBySymbol={}),n.render.alwaysRerender||this.modules.renderer.isNeedRerender()){const p=this.modules.tileManager.getTileObjects();this.modules.renderer.prerenderUpdate(),f.metrics.firstdraw===void 0&&(f.metrics.firstdraw=performance.now()-f.metrics.start),p.forEach(v=>{v.needSync&&v.syncReplicas(this.state)}),this.modules.renderCacheManager.frameStart(),this.modules.animationManager.frameStart(),this.modules.renderer.renderElevation(p),this.modules.shadowManager.drawShadowMap(p),this.modules.renderer.renderLabelingTexture(p),this.modules.renderer.renderSpriteLabelingTexture(p),this.modules.renderer.renderTileObjects(p),this.modules.shadowManager.drawDebugFbIfNeeded(),f.needRerender=!1,this.state.rerenderEvents=new Array,this.modules.animationManager.frameEnd(),this.modules.renderCacheManager.frameEnd(),f.collectStats&&(this.modules.map.emit("stats",f.stats),f.metricsSent||(f.metrics.vertexCount=f.stats.vertexCount,f.metrics.triangleCount=f.stats.triangleCount,f.metrics.drawCount=f.stats.drawCount))}this.finishStyleUpdatingCheck(),this.modules.map.update(),this.modules.assetManager.invalidateUsedGltfModels(),f.needReplicasUpdate=!1,f.shouldIsReadyWaitForUpdates=!1,f.shouldIsIdleWaitForUpdates=!1,this.modules.map.emit("frameend"),this.modules.styleManager.getStyle(this.modules.map.state.handyStyleId)&&this.state.graphicsPresetMode&&this.graphicsPresetDiffer.check(this.state.styleState)&&this.modules.map.emit("graphicspresetchange")};const o={...Kt.options,...t},a={...Kt.options.padding,...o.padding},r={...Kt.options.viewport,...o.viewport},l=o.maxBounds?n.fromGeo(o.maxBounds):o.loopWorld?n.worldLoopBounds:n.worldBounds,c=n.Mercator.fromGeo(o.center);n.worldWrapX(c),n.clampPoint(c,l,c);const d=o.graphicsPreset&&o.graphicsPreset!=="auto"?{...o.styleState,graphicsPreset:o.graphicsPreset}:o.styleState,_=this.state={time:Date.now(),center:c,zoom:o.styleZoom!==void 0?n.getZoomFromStyleZoom(o.styleZoom,c):o.zoom,rotation:n.degToRad(o.rotation),pitch:n.degToRad(o.pitch),styleZoom:o.styleZoom!==void 0?o.styleZoom:n.getStyleZoom(o.zoom,c),zoomTypePreserving:o.styleZoom!==void 0?"styleZoom":"zoom",minZoom:o.minZoom,maxZoom:o.maxZoom,maxBounds:l,loopWorld:o.loopWorld??!1,touchRotationThreshold:n.degToRad(o.touchRotationThreshold),minPitch:n.degToRad(o.minPitch),maxPitch:n.degToRad(o.maxPitch),lowZoomMaxPitch:o.lowZoomMaxPitch?n.degToRad(o.lowZoomMaxPitch):null,size:[Math.max(1,e.clientWidth-r.left-r.right),Math.max(1,e.clientHeight-r.top-r.bottom)],tickers:{},stillness:1,needRerender:!0,needLabeling:!1,needReplicasUpdate:!1,userHasInteracted:!1,dpiChanged:!1,viewport:r,padding:a,labelingOpacity:0,tileServer:o.tileServer,styleServer:o.styleServer||n.styles.url,fontUrl:o.fontUrl||n.fonts.defaultUrl,modelUrl:o.modelUrl||n.defaultModelsPath,iconUrl:o.iconUrl||n.icons.defaultUrl,keyUrl:o.keyUrl||n.keyServerPath,tileSet:o.tileSet,tileProtocol:o.tileProtocol,commercialTileSet:o.commercialTileSet,modelsTileSet:o.modelsTileSet??n.models.tileSet,modelsTilesUrl:o.modelsTilesUrl??n.urls.models,defaultSourceModelsRootUrl:o.defaultSourceModelsRootUrl,defaultSourceModelsAppearStrategy:o.defaultSourceModelsAppearStrategy,subdomains:o.subdomains.split(""),floorsEnabled:o.floorsEnabled,collectStats:o.collectStats,stats:{tileCount:0,dynamicTileCount:0,globeTileCount:0,drawCount:0,vertexCount:0,triangleCount:0,drawCountBySymbol:{},foundVisibleTilesCount:0},trafficOn:!!o.trafficOn,trafficServer:o.trafficServer,trafficProtocol:o.trafficProtocol,identifyPickDistance:n.identify.pickDistance,lang:o.lang,tileServerDefaultLang:o.tileServerDefaultLang,tileKey:o.key,appId:o.appId,disableHoverStyles:o.disableHoverStyles,keepCenterWhileUserZoomRotate:!!o.keepCenterWhileUserZoomRotate,disableRotationByUserInteraction:!!o.disableRotationByUserInteraction,disablePitchByUserInteraction:!!o.disablePitchByUserInteraction,disableDragging:!!o.disableDragging,enableTwoFingerDragging:!!o.enableTwoFingerDragging,performanceCaveatEmitted:!1,sessionId:o.sessionId,tileSessionId:o.tileSessionId,shownRegionIds:new Set,preserveDrawingBuffer:!!o.preserveDrawingBuffer,defaultBackgroundColor:n.handyColor(o.defaultBackgroundColor),handyStyleId:NaN,styleId:"",styleState:hn(d),disableIconCache:o.disableIconCache,disableRenderingCache:o.disableRenderingCache,rtlPlugin:{scenario:o.useRtlTextPlugin??"depends-on-language",loadFailed:!1,url:o.rtlPluginUrl??n.rtlPluginUrl,hash:o.rtlPluginHash??n.rtlPluginHash},mobileSdkMode:o.mobileSdkMode,dracoDecoderUrl:o?.dracoDecoderUrl??n.dracoDecoderUrl,demMode:!1,globeMode:!1,globeReady:!1,visibleMapReplicas:[0],tilesBounds:[[0,0],[0,0],[0,0],[0,0]],extendedTilesBounds:[[0,0],[0,0],[0,0],[0,0]],elevation:void 0,elevationScale:0,minElevation:void 0,skipElevationAnimation:o.skipElevationAnimation,metrics:{start:performance.now(),fail:!1,vertexCount:0,triangleCount:0,drawCount:0},metricsSent:!1,shouldIsReadyWaitForUpdates:!1,shouldIsIdleWaitForUpdates:!1,commercialPoiRandomSeed:o.commercialPoiRandomSeed,disableSurvivedPoiPrevalence:!!o.disableSurvivedPoiPrevalence,webglVersion:o.webglVersion,webgpu:o.webgpu,enableTrackResize:!!o.enableTrackResize,autoResizeInterval:n.render.autoResizeInterval,showDefaultTileBounds:!!o.showDefaultTileBounds,immersiveLevel:{tiers:!1},pitchHightLimitation:o.pitchHightLimitation===void 0?n.degToRad(90):n.degToRad(o.pitchHightLimitation),isLabelingDepthTestDisabled:!1,iconIdentifyOpacity:o.iconIdentifyOpacity??Qg,disableHidingPois:o.disableHidingPois??!1,resetFloorModeOnActivation:o.resetFloorModeOnActivation??!1,aaMode:o.disableAntiAliasing===!1?Ot.TAA:void 0,rerenderEvents:new Array,cameraConfig:Object.assign({},n.defaultCameraConfig),cityCommPoiLabeling:{config:o.cityCommPoiLabelingConfig,ascSortedZoomNumbers:ag(o.cityCommPoiLabelingConfig)},trafficMinZoom:o.trafficMinZoom??n.traffic.minZoom,trafficMaxZoom:o.trafficMaxZoom??n.traffic.maxZoom,trafficMaxDetailLevel:o.trafficMaxDetailLevel??n.traffic.maxDetailLevel,bssHostAppParams:o.bssHostAppParams,disableStyleFallback:!!o.disableStyleFallback,hiddenImmersiveRoutesEnabled:fd(),modelShowHideEventsSublayers:new Set(o.modelShowHideEventsSublayers??[]),graphicsPresetMode:o.graphicsPreset,shouldEmitGraphicsPresetChangeEvent:!1,isDeprecatedSystem:Bt(),disableModelsGrowthAnimation:o.disableModelsGrowthAnimation??!1,disableLayerAnimation:o.disableLayerAnimation??!1,allowMetro:o.allowMetro??!1,forceSyncIdentify:o.forceSyncIdentify??!1};o.cameraConfig&&Object.assign(_.cameraConfig,o.cameraConfig),this.modules=new qg(_,e,i),typeof _.commercialPoiRandomSeed=="number"&&this.modules.workers.labeling.setCommercialPoiRandomSeed(_.commercialPoiRandomSeed),this.modules.styleManager.setDynamicStyle(this.modules.dynamicStyle.getStyle()),this.handlers=[new Vc(_,this.modules.layout.mapContainer),new jc(this.modules)],o.disableZoomOnScroll||this.handlers.push(new Hc(_,this.modules.layout.mapContainer)),kc&&Ti&&this.handlers.push(new Zc(_,e,i)),this.performanceChecker=new Wc(_,this.modules),this.stillnessUpdater=new Xc,this.measurePerformance(o.graphicsPreset==="auto").then(()=>{this.requestedFrame=requestAnimationFrame(this.renderLoop)})}destroy(){cancelAnimationFrame(this.requestedFrame),this.modules.destroy(),this.handlers.forEach(e=>e.destroy())}isIdle(){return!this.modules.renderer.isNeedRerender()&&!this.state.shouldIsIdleWaitForUpdates&&this.modules.tileManager.isIdle()&&this.modules.assetManager.isIdle()&&this.modules.trafficTileLayer.viewportTilesReady()&&this.modules.layers.entranceAnimationFinished()&&this.modules.modelLayer.isIdle()&&!this.modules.buildingHeightAnimator.isAnimating()&&!this.modules.modelsScene.isAnimating()&&this.modules.labeler.isIdle()}isReady(){return this.isIdle()&&this.modules.floorManager.floorsReady()&&this.modules.identifier.isIdle()&&this.modules.imageManager.isIdle()&&this.modules.imageCache.isIdle()&&this.modules.personalPoiManager.isIdle()&&this.modules.tileKeyInfo.isIdle()&&this.modules.postEffectsManager.isReady()&&!this.state.shouldIsReadyWaitForUpdates}isReadyForMetrics(){return!this.modules.renderer.isNeedRerender(!0)&&!this.state.shouldIsIdleWaitForUpdates&&this.modules.tileManager.isIdle()&&this.modules.assetManager.isIdle()&&this.modules.trafficTileLayer.viewportTilesReady()&&this.modules.modelLayer.isIdle()&&!this.modules.buildingHeightAnimator.isAnimating()&&!this.modules.modelsScene.isAnimating()&&this.modules.labeler.isIdle()&&this.modules.floorManager.floorsReady()&&this.modules.identifier.isIdle()&&this.modules.imageManager.isIdle()&&this.modules.imageCache.isIdle()&&this.modules.personalPoiManager.isIdle()&&this.modules.tileKeyInfo.isIdle()&&this.modules.postEffectsManager.isReady(!0)&&!this.state.shouldIsReadyWaitForUpdates}hasActiveLayerAnimation(){return this.state.rerenderEvents.some(e=>e.type==="layerAnimationTicker")||!this.modules.layers.entranceAnimationFinished()}redrawMap(){this.modules.tileManager.redraw(),this.modules.trafficTileLayer.redraw(),this.modules.modelLayer.redraw(),this.modules.personalPoiManager.redraw()}activateStyleUpdating(){this.modules.tileManager.activateStyleUpdating(),this.modules.modelLayer.activateStyleUpdating(),this.modules.trafficTileLayer.activateStyleUpdating(),this.isStyleUpdateInProgress=!0}getIsFirstStyleUpdate(){return this.isFirstStyleUpdate}async measurePerformance(e){if(!e)return;performance.now();const t=await this.modules.benchmark.run();switch(this.modules.benchmark.destroy(),this.modules.benchmark=null,t.status){case"error":case"timeout":const i=Qo[0];this.state.metrics.graphicsPreset=i,this.modules.map.patchStyleState({graphicsPreset:i});break;case"part-done":case"done":case"cached":{const o=Qo[t.tier];this.state.metrics.graphicsPreset=t.status==="part-done"?Qo[0]:o,t.status!=="cached"&&(this.state.metrics.benchRenderTime=Math.round(t.measurements.mean),this.state.metrics.benchGenTime=Math.round(t.preparation.generationTime)),this.modules.map.patchStyleState({graphicsPreset:o});break}}}processMetrics(){const e=this.state;if(e.metricsSent||e.graphicsPresetMode==="auto"&&!e.metrics.graphicsPreset)return;const t=e.metrics,i=performance.now()-t.start>n.metricsTimeout;(t.interactive!==void 0&&t.init!==void 0&&t.firstlabeling!==void 0&&t.ready!==void 0&&t.firstcontent!==void 0&&t.firstdraw!==void 0||i)&&(t.fail=i,this.modules.map.emit("metrics",t),e.metricsSent=!0)}finishStyleUpdatingCheck(){this.isStyleUpdateInProgress&&this.modules.tileManager.viewportTilesReady()&&this.modules.trafficTileLayer.viewportTilesReady()&&this.modules.modelLayer.viewportModelsReady()&&(this.modules.tileManager.finishStyleUpdating(),this.modules.trafficTileLayer.finishStyleUpdating(),this.modules.modelLayer.finishStyleUpdating(),this.modules.modelsScene.finishStyleUpdating(),this.modules.personalPoiManager.redraw(),this.updateBackgroundColor(),this.isStyleUpdateInProgress=!1,this.isFirstStyleUpdate=!1,this.modules.renderer.addRerenderEvent(),this.state.needLabeling=!0)}updateBackgroundColor(){const{renderer:e,postEffectsManager:t,styleManager:i}=this.modules,o=i.getClearColor();o!==void 0&&(e.setClearColor(o),t.setClearColor(o))}checkDemEnabled(){return this.state.styleState.terrainEnabled===!0&&!this.state.globeMode?this.modules.demManager.isEnabled()||this.modules.demManager.enable():this.modules.demManager.isEnabled()&&this.modules.demManager.disable(),this.modules.demManager.isEnabled()}checkGlobeEnabled(){const{styleState:t,styleZoom:i,globeMode:o,handyStyleId:a}=this.state,{defaultSource:r,map:l}=this.modules,c=o;if(!this.modules.styleManager.getStyleLayer(a,n.ENVIRONMENT_STYLE_LAYER_ID)){const f=this.state.globeMode;this.state.globeMode=!1,f&&!this.state.loopWorld&&n.clampPoint(this.state.center,this.state.maxBounds,this.state.center);return}const{globeMaxZoom:_}=n.globeConfig,u=!c&&i<_||c&&i<_+.2,h=t.globeEnabled===!0&&u&&!l.getFeatureFlag("globeOff");!c&&h&&(this.modules.defaultSource.addGlobeSource(),this.state.globeReady=!1),c&&!h&&(this.modules.defaultSource.removeGlobeSource(),this.state.globeReady=!1),h&&r.isGlobeTilesReady()&&(this.state.globeReady=!0),this.state.globeMode=h,c&&!h&&!this.state.loopWorld&&n.clampPoint(this.state.center,this.state.maxBounds,this.state.center),(h||c&&!h)&&this.updateBackgroundColor()}updateImmersiveLevel(){const e=!!this.state.styleState.immersiveRoadsOn;this.state.immersiveLevel.tiers=e&&this.state.styleZoom>=n.DEFAULT_MIN_TIERS_STYLE_ZOOM}updateTilesBounds(){const{size:e,zoom:t}=this.state,[i,o,a,r]=this.modules.camera.getViewportVertices(),l=n.getLineConstants(i,o),c=n.pointToLineSignedDistance(this.modules.camera.position,l),d=c<0,_=this.state.cameraConfig;let u=this.modules.environmentManager.fogLimits[1]*this.modules.camera.fogDistance;if(d&&(u+=c),this.state.demMode&&this.state.elevation!==void 0&&!Number.isNaN(this.state.elevation)){const p=this.modules.camera.position[2],v=this.state.minElevation!==void 0&&!Number.isNaN(this.state.minElevation)?this.state.minElevation:this.state.elevation,y=Math.max(this.state.elevation-v,0)*n.MAP_POINTS_IN_METER,b=Math.min(y/p+1,2),x=(b-1)*Math.max(1-this.state.pitch/this.state.maxPitch,.1)+1;n.lerp(i,this.modules.camera.position,i,x),n.lerp(o,this.modules.camera.position,o,x),n.lerp(r,this.modules.camera.position,r,b),n.lerp(a,this.modules.camera.position,a,b)}let h=n.pointToLineDistance(a,l);if(h>u){const p=u/h;n.lerp(a,o,a,p),n.lerp(r,i,r,p),h=u}n.copy$2(this.state.extendedTilesBounds[0],i),n.copy$2(this.state.extendedTilesBounds[1],o),n.copy$2(this.state.extendedTilesBounds[2],a),n.copy$2(this.state.extendedTilesBounds[3],r);const f=Math.min(_.minTrapezeHeight,u),m=Math.max(n.pixelToMapDistance(e[1],t)*_.viewportLimitRatio,f);if(h>m){const p=m/h;n.lerp(a,o,a,p),n.lerp(r,i,r,p),h=m}if(this.state.demMode&&d){const p=(h+Math.abs(c))/h;n.lerp(i,r,i,p),n.lerp(o,a,o,p)}n.copy$2(this.state.tilesBounds[0],i),n.copy$2(this.state.tilesBounds[1],o),n.copy$2(this.state.tilesBounds[2],a),n.copy$2(this.state.tilesBounds[3],r),this.state.visibleMapReplicas=this.state.loopWorld||this.state.globeMode?n.getVisibleMapReplicas(this.state.tilesBounds,this.state.globeMode):[0]}updateElevation(){if(this.state.elevationScale=this.modules.demManager.getVerticalScale(),!this.state.demMode){this.state.elevation!==void 0&&(this.modules.renderer.addRerenderEvent(),this.state.elevation=void 0);return}const e=this.modules.demManager.getElevation(this.state.center);if(e!==void 0)if(this.state.elevation===void 0||this.state.skipElevationAnimation)this.state.elevation=e;else{const i=R_*(e-this.state.elevation);Math.abs(i)<F_?this.state.elevation=e:this.state.elevation+=i;const o=this.modules.demManager.getElevation(this.modules.camera.position);if(o!==void 0){const a=this.state.elevationScale,r=o*a,l=this.modules.camera.position[2]/n.MAP_POINTS_IN_METER,c=Math.min(30,l*.2),d=this.state.elevation*a+l-c;r>d&&(this.state.elevation+=(r-d)/a)}}const t=this.modules.demManager.getMinElevation();t!==void 0&&(this.state.minElevation=t)}autoResize(e){if(e-this.lastResizeTime>=this.state.autoResizeInterval){const t=this.modules.layout.canvas,{clientWidth:i,clientHeight:o}=this.modules.layout.rootContainer,a=window.devicePixelRatio;(t.width!==Math.floor(i*a)||t.height!==Math.floor(o*a))&&(this.lastResizeTime=e,this.modules.map.invalidateSize())}}};Kt.options={center:[0,0],zoom:0,minZoom:n.MAP_DEFAULTS.minZoom,maxZoom:n.MAP_DEFAULTS.maxZoom,rotation:0,touchRotationThreshold:10,pitch:0,minPitch:0,maxPitch:45,lowZoomMaxPitch:45,viewport:{top:0,right:0,bottom:0,left:0},padding:{top:0,right:0,bottom:0,left:0},tileServer:n.tiles.server,tileSet:n.tiles.tileSet,tileProtocol:n.tiles.protocol,commercialTileSet:n.commercialPoi.tileSet,key:n.tiles.tileKey,subdomains:n.tiles.subdomains,floorsEnabled:n.floors.enabled,trafficProtocol:n.traffic.protocol,trafficServer:n.traffic.host,collectStats:!1,style:"",styleState:qv(),styleOptions:{rootUrl:"",iconsPath:"",fontsPath:"",stylePath:"",modelsPath:""},lang:n.defaultLang,appId:n.tiles.appId,disableHoverStyles:!1,disableZoomOnScroll:!1,disableDragging:!1,enableTwoFingerDragging:!1,disableRotationByUserInteraction:!1,disablePitchByUserInteraction:!1,defaultBackgroundColor:"#f6f2de",disableIconCache:!1,disableRenderingCache:!1,mobileSdkMode:!1,skipElevationAnimation:!1,enableTrackResize:!1,showDefaultTileBounds:!1,immersiveOn:!1,pitchHightLimitation:90,trafficOn:!1,trafficMinZoom:n.traffic.minZoom,trafficMaxZoom:n.traffic.maxZoom,trafficMaxDetailLevel:n.traffic.maxDetailLevel,disableStyleFallback:!1,modelShowHideEventsSublayers:[],styleServer:"",fontUrl:"",modelUrl:"",iconUrl:"",keyUrl:"",disableLayerAnimation:!1};let Jo=Kt;const Jg="https://mapgl.2gis.com/api/js",wn={minZoom:2,maxZoom:20},Ag="tile{subdomain}-sdk.maps.2gis.com",bl="https://tile{subdomain}-sdk.maps.2gis.com/api/v3/ald",ey="https://s1.bss.2gis.com/bss/3",Ao=()=>{let s="",e;for(let t=0;t<32;t++)e=Math.random()*16|0,t>4&&t<21&&!(t%4)&&(s+="-"),s+=(t===12?4:t===16?e&3|8:e).toString(16);return s},ty=2;function iy(s){const e=[ty,s instanceof WebGLRenderingContext?1:2,s.getParameter(s.ALIASED_LINE_WIDTH_RANGE),s.getParameter(s.ALIASED_POINT_SIZE_RANGE),s.getParameter(s.COMPRESSED_TEXTURE_FORMATS),s.getParameter(s.MAX_COMBINED_TEXTURE_IMAGE_UNITS),s.getParameter(s.MAX_CUBE_MAP_TEXTURE_SIZE),s.getParameter(s.MAX_FRAGMENT_UNIFORM_VECTORS),s.getParameter(s.MAX_RENDERBUFFER_SIZE),s.getParameter(s.MAX_TEXTURE_IMAGE_UNITS),s.getParameter(s.MAX_TEXTURE_SIZE),s.getParameter(s.MAX_VARYING_VECTORS),s.getParameter(s.MAX_VERTEX_ATTRIBS),s.getParameter(s.MAX_VERTEX_TEXTURE_IMAGE_UNITS),s.getParameter(s.MAX_VERTEX_UNIFORM_VECTORS),s.getParameter(s.MAX_VIEWPORT_DIMS),s.getParameter(s.PACK_ALIGNMENT),s.getParameter(s.SUBPIXEL_BITS),s.getParameter(s.UNPACK_ALIGNMENT),s.getParameter(s.VIEWPORT),s.getParameter(s.SHADING_LANGUAGE_VERSION),s.getParameter(s.VENDOR),s.getParameter(s.RENDERER)];s instanceof WebGLRenderingContext?e.push(...new Array(28).fill(-1)):e.push(s.getParameter(s.MAX_3D_TEXTURE_SIZE),s.getParameter(s.MAX_ARRAY_TEXTURE_LAYERS),s.getParameter(s.MAX_CLIENT_WAIT_TIMEOUT_WEBGL),s.getParameter(s.MAX_COLOR_ATTACHMENTS),s.getParameter(s.MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS),s.getParameter(s.MAX_COMBINED_UNIFORM_BLOCKS),s.getParameter(s.MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS),s.getParameter(s.MAX_DRAW_BUFFERS),s.getParameter(s.MAX_ELEMENT_INDEX),s.getParameter(s.MAX_ELEMENTS_INDICES),s.getParameter(s.MAX_ELEMENTS_VERTICES),s.getParameter(s.MAX_FRAGMENT_INPUT_COMPONENTS),s.getParameter(s.MAX_FRAGMENT_UNIFORM_BLOCKS),s.getParameter(s.MAX_FRAGMENT_UNIFORM_COMPONENTS),s.getParameter(s.MAX_PROGRAM_TEXEL_OFFSET),s.getParameter(s.MAX_SAMPLES),s.getParameter(s.MAX_SERVER_WAIT_TIMEOUT),s.getParameter(s.MAX_TEXTURE_LOD_BIAS),s.getParameter(s.MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS),s.getParameter(s.MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS),s.getParameter(s.MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS),s.getParameter(s.MAX_UNIFORM_BLOCK_SIZE),s.getParameter(s.MAX_UNIFORM_BUFFER_BINDINGS),s.getParameter(s.MAX_VARYING_COMPONENTS),s.getParameter(s.MAX_VERTEX_OUTPUT_COMPONENTS),s.getParameter(s.MAX_VERTEX_UNIFORM_BLOCKS),s.getParameter(s.MAX_VERTEX_UNIFORM_COMPONENTS),s.getParameter(s.MIN_PROGRAM_TEXEL_OFFSET));const t=s.getExtension("WEBGL_debug_renderer_info");t?e.push(s.getParameter(t.UNMASKED_VENDOR_WEBGL),s.getParameter(t.UNMASKED_RENDERER_WEBGL)):e.push("Unsupported","Unsupported");const i=s.getShaderPrecisionFormat(s.FRAGMENT_SHADER,s.LOW_FLOAT),o=s.getShaderPrecisionFormat(s.FRAGMENT_SHADER,s.MEDIUM_FLOAT),a=s.getShaderPrecisionFormat(s.FRAGMENT_SHADER,s.HIGH_FLOAT);return a&&o&&i?(e.push(`[${i.rangeMin},${i.rangeMax}](${i.precision})`),e.push(`[${o.rangeMin},${o.rangeMax}](${o.precision})`),e.push(`[${a.rangeMin},${a.rangeMax}](${a.precision})`)):e.push(new Array(3).fill("Unsupported")),e.push(window.devicePixelRatio),e}function ny(s){const e={};for(const[t,i]of Object.entries(s)){if(n.isTypedArray(i)){e[t]=Array.from(i);continue}e[t]=i}return e}function oy(s){const e={1:["stateSetVersion","webGlVersion","ALIASED_LINE_WIDTH_RANGE","ALIASED_POINT_SIZE_RANGE","COMPRESSED_TEXTURE_FORMATS","MAX_COMBINED_TEXTURE_IMAGE_UNITS","MAX_CUBE_MAP_TEXTURE_SIZE","MAX_FRAGMENT_UNIFORM_VECTORS","MAX_RENDERBUFFER_SIZE","MAX_TEXTURE_IMAGE_UNITS","MAX_TEXTURE_SIZE","MAX_VARYING_VECTORS","MAX_VERTEX_ATTRIBS","MAX_VERTEX_TEXTURE_IMAGE_UNITS","MAX_VERTEX_UNIFORM_VECTORS","MAX_VIEWPORT_DIMS","PACK_ALIGNMENT","SUBPIXEL_BITS","UNPACK_ALIGNMENT","VIEWPORT","SHADING_LANGUAGE_VERSION","VENDOR","RENDERER","MAX_3D_TEXTURE_SIZE","MAX_ARRAY_TEXTURE_LAYERS","MAX_CLIENT_WAIT_TIMEOUT_WEBGL","MAX_COLOR_ATTACHMENTS","MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS","MAX_COMBINED_UNIFORM_BLOCKS","MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS","MAX_DRAW_BUFFERS","MAX_ELEMENT_INDEX","MAX_ELEMENTS_INDICES","MAX_ELEMENTS_VERTICES","MAX_FRAGMENT_INPUT_COMPONENTS","MAX_FRAGMENT_UNIFORM_BLOCKS","MAX_FRAGMENT_UNIFORM_COMPONENTS","MAX_PROGRAM_TEXEL_OFFSET","MAX_SAMPLES","MAX_SERVER_WAIT_TIMEOUT","MAX_TEXTURE_LOD_BIAS","MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS","MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS","MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS","MAX_UNIFORM_BLOCK_SIZE","MAX_UNIFORM_BUFFER_BINDINGS","MAX_VARYING_COMPONENTS","MAX_VERTEX_OUTPUT_COMPONENTS","MAX_VERTEX_UNIFORM_BLOCKS","MAX_VERTEX_UNIFORM_COMPONENTS","MIN_PROGRAM_TEXEL_OFFSET"]};e[2]=[...e[1],"UNMASKED_VENDOR_WEBGL","UNMASKED_RENDERER_WEBGL","precisionLow","precisionMedium","precisionHigh","devicePixelRatio"];const t=s[0],i=e[t]??{},o={};for(let a=0;a<s.length;a++)o[i[a]??a]=s[a];return o}const sy=/(android|bb\d+|meego).+mobile|armv7l|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|redmi|series[46]0|samsungbrowser.*mobile|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i,ay=/CrOS/,ry=/android|ipad|playbook|silk/i,ly=()=>{const s=typeof navigator<"u"?navigator.userAgent:"";if(!s)return!1;const e=sy.test(s)&&!ay.test(s),t=ry.test(s),i=navigator.maxTouchPoints>1&&s.includes("Macintosh")&&s.includes("Safari");return e||t||i},Sn=5e3,cy=64,dy=16;class _y{constructor(e,t){this.queue=[],this.commPoiMsgOrderNumber=0,this.utcOffset=hy(),this.unsentMessages=[],this.isMetricsFailed=!1,this.webglStatsValues=[],this.onCommPoiShowEvent=({commPois:i})=>{const o=Date.now(),{tileKey:a,sessionId:r}=this.map.state;for(const l of i){const c=uy(l,o,this.commPoiMsgOrderNumber++,a,this.utcOffset,r);c&&this.queue.push(c)}this.timer||(this.timer=window.setTimeout(this.sendMessages,Sn))},this.onContextLostEvent=async()=>{const i=Date.now(),o={cpu:0,gpu:0},a={start:0,fail:!0,contextLost:!0},r=await this.createMetricMessage(i,a,o);this.queue.push(r),this.timer||(this.timer=window.setTimeout(this.sendMessages,Sn))},this.onMetricsEvent=async i=>{this.isMetricsFailed&&(i.fail=!0);const o=Date.now(),a=await this.getMetricsMessage(i,o);this.queue.push(a),this.timer||(this.timer=window.setTimeout(this.sendMessages,Sn))},this.onSendFail=i=>{this.unsentMessages.push(...i),this.timer||(this.timer=window.setTimeout(this.sendMessages,Sn))},this.sendMessages=()=>{this.timer=void 0;const i=[...this.unsentMessages,...this.queue];this.queue=[],this.unsentMessages=[],i.length&&fetch(this.bssUrl,{method:"POST",body:JSON.stringify(i),headers:{"Content-Type":"application/json"}}).then(o=>{o.ok||this.onSendFail(i)},()=>this.onSendFail(i))},this.markMetricsAsFailed=()=>{this.isMetricsFailed=!0},this.map=e,this.bssUrl=t.bssUrl??ey,this.webglStatsValues=iy(this.map.getWebGLContext()),t.disableBssStatisticsForCommPoi||e.on("commpoishow",this.onCommPoiShowEvent),e.on("metrics",this.onMetricsEvent),this.map.on("error",i=>{i.type==="webglcontextlost"&&this.onContextLostEvent()}),window.addEventListener("blur",this.markMetricsAsFailed,{once:!0}),window.addEventListener("focus",this.markMetricsAsFailed,{once:!0}),document.addEventListener("visibilitychange",this.markMetricsAsFailed,{once:!0}),(!document.hasFocus()||document.hidden)&&this.markMetricsAsFailed()}destroy(){clearTimeout(this.timer),this.queue=[],this.timer=void 0,this.map.off("commpoishow",this.onCommPoiShowEvent),window.removeEventListener("blur",this.markMetricsAsFailed),window.removeEventListener("focus",this.markMetricsAsFailed),document.removeEventListener("visibilitychange",this.markMetricsAsFailed)}async getDefaultStats(){const e=oy(this.webglStatsValues),t=ny(e),i=this.map.performanceChecker.getFpsStats(),o=Array.from(this.map.state.center),a=this.map.state.zoom,r=this.map.state.rotation,l=this.map.state.pitch,c=await md();return{webglStats:t,fps:i,center:o,zoom:a,rotation:r,pitch:l,webGpuSupported:c}}async createMetricMessage(e,t,i){const o=await this.getDefaultStats();return{type:411,eventType:"mapglCounter",eventId:Ao(),timestamp:e,payload:{mapGlMapMetrics:{...t,...o,memory:i},mapGlHostAppParams:fy(this.map.state.bssHostAppParams)},common:{formatVersion:3,appVersion:n.limitString(cs,cy),product:44,deviceType:ly()?"mobile":"desktop",key:this.map.state.tileKey,styleId:this.map.state.styleId}}}async getMetricsMessage(e,t){const i=await this.map.performanceChecker.getMemoryStats(),o=await this.createMetricMessage(t,e,i);return o.payload.mapGlMapMetrics.fail&&!o.payload.mapGlMapMetrics.fps.isStatic&&e.firstcontent!==void 0&&(o.payload.mapGlMapMetrics.fail=!1),o}}function uy(s,e,t,i,o,a){const r={adsHighlight:!0,entity:{id:s.id,type:"branch"}};s.adsPriority!==void 0&&(r.adsPriority=s.adsPriority);const l={type:302,eventType:"view",eventId:Ao(),eventOrdinal:t,uiElement:{name:"POI",ownerName:"map"},timestamp:e,utcOffset:o,payload:{POI:r},common:{formatVersion:3,appVersion:n.limitString(cs,dy),product:44,apikey:i}};return a&&(l.common.sessionId=a),!i||i===n.DEFAULT_EMPTY_KEY?null:l}function hy(){const e=new Date().getTimezoneOffset(),t=e>0?"-":"+",i=`${Math.floor(Math.abs(e)/60)}`,o=`${Math.abs(e)%60}`;return t+(i.length>1?i:"0"+i)+":"+(o.length>1?o:"0"+o)}function fy(s){if(s){const e={...s};return"userId"in e&&typeof e.userId!="string"&&delete e.userId,"sessionId"in e&&typeof e.sessionId!="string"&&delete e.sessionId,"product"in e&&typeof e.product!="number"&&delete e.product,e}return s}const xl=s=>typeof s=="number"&&!isNaN(s)&&s!==Number.NEGATIVE_INFINITY&&s!==Number.POSITIVE_INFINITY;function my(s){return Array.isArray(s)&&xl(s[0])&&xl(s[1])}var es=(s=>(s[s.IgnoreCall=0]="IgnoreCall",s[s.UseDefault=1]="UseDefault",s))(es||{});const py={0:"Method call will be ignored.",1:"Method call will use default value."};class vy{constructor(e){this.options=e}isValidGeoPoint(e,t){return this.processValidationResult(e,my(e),"Invalid GeoPoint",t)}processValidationResult(e,t,i,o){return!t&&this.options.reportToConsole&&console.warn(`${i}: ${JSON.stringify(e)}
${py[o]}`),t}}const wl=new vy({reportToConsole:!0}),Tn="Style preprocessing:";function gy(s){const e=new Map,t=i=>{i?.forEach(o=>{const a={layers:i,layer:o};e.set(o.id,a),o.type==="group"&&t(o.layers)})};return t(s.layers),e}function yy(s,e){const t=new Set;performance.now(),e?.parentStyleId&&console.warn(`${Tn} Parent style with id=${s.parentStyleId} have parent with id=${e.parentStyleId}. Recursive inheritance is not supported.`);const i=e??s;if(i.layers=i.layers??[],e){const a=gy(i),r=s.layersInserts??[];r.length&&r.forEach(({layer:c,beforeId:d})=>{if(d){const _=a.get(d);if(_){const{layers:u,layer:h}=_,f=u.findIndex(m=>h===m);u.splice(f,0,c),c.type!=="custom"&&c.type!=="group"&&t.add(c)}else console.warn(`${Tn} Child style tries to insert layer with beforeId=${d}. There is no layer with such id in the parent style. Layer insertion ignored.`)}else i.layers?.push(c)});const l=Object.keys(s.layersPatches??{}).reduce((c,d)=>(a.has(d)||c.push(d),c),[]);l.length&&console.warn(`${Tn} Child style tries to patch layers with ids which do not exist in parent style: ${l.join("; ")}`)}const o=(a,r,l,c,d)=>{if(r)for(let _=0;_<r.length;_++){const u=r[_];if(u.type==="custom")continue;let h=l?.layersPatches?.[u.id];h&&h?.type!==u.type&&(console.warn(`${Tn} Layer patch ignored due type mismatch. Target layer with id=${u.id} has type=${u.type}, but the patch has type=${h.type}.`),h=void 0),n.removeUndefined(u),h&&n.removeUndefined(h),u.type==="group"?(o(a,u.layers,l,u,h),r[_]={...u,...h},delete r[_].commonDefaults,delete r[_].layerTypeDefaults):r[_]=by(a,u,c,d,u.type===h?.type?h:void 0)}};return o(t,i.layers,e?s:void 0),e&&(["background","models","icons","labelingGroups","light","graphicsPresets","terrain","environment"].forEach(a=>{(i[a]&&Object.values(i[a]).length||s[a]&&Object.values(s[a]).length)&&(i[a]={...i[a],...s[a]})}),i.name=s.name),["models","icons"].forEach(a=>{i[a]&&Object.keys(i[a]).forEach(r=>{i[a][r]===null&&delete i[a][r]})}),i}function by(s,e,t,i,o){const a={...t?.commonDefaults},r={...i?.commonDefaults};switch(e.type){case"heatmap":case"overpass":case"tunnel":{delete a.interactive,delete r.interactive,delete a.ignoreTier,delete r.ignoreTier;break}case"embankment":case"polygon3d":case"buildingModel":case"model":case"lineExtrusion":case"polygonExtrusion":case"point":{delete a.ignoreTier,delete r.ignoreTier;break}case"arrow":case"dashedLine":case"labelLine":case"line":case"metricPoint":case"oneWayLine":case"polygon":case"raster":case"shiftedLine":break;default:n.assertUnreachable(e)}return{...a,...t?.layerTypeDefaults?.[e.type],...e,...r,...i?.layerTypeDefaults?.[e.type],...s.has(e)?e:void 0,...o,style:{...t?.commonDefaults?.style,...t?.layerTypeDefaults?.[e.type]?.style,...e.style,...i?.commonDefaults?.style,...i?.layerTypeDefaults?.[e.type]?.style,...s.has(e)?e.style:void 0,...o?.style}}}async function xy(s,e,t){const i=new URL(n.template(s,{id:e}));i.searchParams.append("key",t);const o=await fetch(i.toString());if(o.status===404){console.warn(`No access to style with id «${e}».`);return}if(!o.ok)return;const a=await o.json();if(a&&a.result)return{loadedId:e,style:a.result}}async function wy(s,e,t){let i;try{const o=n.applyDefaults(t||{},{rootUrl:n.styles.url,stylePath:n.styles.path,iconsPath:n.icons.defaultUrl,fontsPath:n.fonts.defaultUrl,modelsPath:n.defaultModelsPath}),a=await xy(n.getStyleUrl(o),s,e);if(!a)throw new Error;i=a.style}catch{throw new Error("FETCH_PARENT_STYLE_ERROR")}return i}async function Sy(s,e,t){let i;return s.parentStyleId&&(i=await wy(s.parentStyleId,e,t)),yy(s,i)}const Sl=["zoom","rotation","pitch","center"],Ty=150,My=["static","immersive_roads"];class ts extends n.Evented{constructor(e,t){super();const i=this.core=new Jo(e,t,this);this.state=i.state,this.modules=i.modules,this.performanceChecker=i.performanceChecker,this.values={isMoveChanging:!1,isIdle:!1},Sl.forEach(a=>{this.cloneFromStateToValues(a,`${a}1`),this.cloneFromStateToValues(a,`${a}2`),this.cloneFromStateToValues(a,`${a}End1`),this.cloneFromStateToValues(a,`${a}End2`),this.values[`${a}EndTime`]=0,this.values[`is${a}Changing`]=!1}),this.cloneFromStateToValues("size","size"),this.performanceChecker.on("performancecaveat",()=>{this.emit("performancecaveat")});const o=a=>{if(a instanceof Error)throw a};this.setStyle(t?.style??n.DEFAULT_MAPGL_STYLE,t?.styleOptions).catch(o),this.setLang(this.state.lang),t&&!t.disableBssStatistics&&(this._bssDispatcher=new _y(this,{disableBssStatisticsForCommPoi:!!t.disableBssStatisticsForCommPoi,bssUrl:t.bssUrl})),this.state.metrics.init=performance.now()-this.state.metrics.start,this.updateDataToggle()}setCenter(e,t){if(!wl.isValidGeoPoint(e,es.IgnoreCall))return this;this.state.userHasInteracted=!1;let i=n.Mercator.fromGeo(e);return this.state.loopWorld||(i=n.normalizeMapPoint(i)),bt(this.state,i,t),this}setZoom(e,t){return n.isBetween(e,Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER)?(this.state.zoomTypePreserving="zoom",this.state.userHasInteracted=!1,dt(this.state,e,t),this.state.shouldIsReadyWaitForUpdates=!0,this):this}setStyleZoom(e,t){if(!n.isBetween(e,Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER))return this;const i=n.getZoomFromStyleZoom(e,this.state.center);return this.state.zoomTypePreserving="styleZoom",this.state.userHasInteracted=!1,dt(this.state,i,t),this}setMinZoom(e,t){return this.state.minZoom=e,this.setZoom(this.state.zoom,t),this}setMaxZoom(e,t){return this.state.maxZoom=e,this.setZoom(this.state.zoom,t),this}setRotation(e,t){return n.isBetween(e,Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER)?(this.state.userHasInteracted=!1,Qt(this.state,n.degToRad(e),t),this):this}setPitch(e,t){return n.isBetween(e,Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER)?(this.state.userHasInteracted=!1,wi(this.state,n.degToRad(e),t),this):this}setAnimationTerrain(e){this.modules.demManager.setAnimationTerrain(e)}getAnimationTerrainStatus(){return this.modules.demManager.getAnimationTerrainStatus()}setMinPitch(e,t){return this.state.minPitch=n.degToRad(e),this.setPitch(n.radToDeg(this.state.pitch),t),this}setMaxPitch(e,t){return this.state.maxPitch=n.degToRad(e),this.setPitch(n.radToDeg(this.state.pitch),t),this}setLowZoomMaxPitch(e,t){return this.state.lowZoomMaxPitch=n.degToRad(e),this.setPitch(n.radToDeg(this.state.pitch),t),this}setViewport(e,t){return this.state.userHasInteracted=!1,mc(this.state,this.modules.layout.rootContainer,this.modules.renderer,e,t),this}setMaxBounds(e){return this.state.maxBounds=n.fromGeo(e),this}setPadding(e,t){const i={top:e.top??0,left:e.left??0,right:e.right??0,bottom:e.bottom??0};return this.state.userHasInteracted=!1,xc(this.state,this.modules.renderer,i,t),this}setTime(e){this.patchStyleState({_customUserTimeOffset:e?e-this.state.time:0}),this.modules.animationManager.clearAllTickers(),this.modules.renderer.addRerenderEvent()}getTime(e){return e?this.state.time-new Date().getTimezoneOffset()*6e4+ +(this.state.styleState._customUserTimeOffset||0):this.state.time+ +(this.state.styleState._customUserTimeOffset||0)}getPadding(){return this.state.padding}getCenter(){const e=n.normalizeMapPoint(this.state.center);return n.Mercator.toGeo(e).slice(0,2)}getZoom(){return this.state.zoom}getStyleZoom(){return this.state.styleZoom}getMinZoom(){return this.state.minZoom}getMaxZoom(){return this.state.maxZoom}getRotation(){return n.radToDeg(this.state.rotation)}getPitch(){return n.radToDeg(this.state.pitch)}getViewport(){return this.state.viewport}getSize(){return[this.state.size[0],this.state.size[1]]}getBounds(e){let t=this.modules.camera;if(e?.skipPadding)t=new n.Camera({...this.state,padding:{left:0,right:0,top:0,bottom:0}});else if(e?.sizeExtension){const o=e.sizeExtension,[a,r]=this.state.size,l=[a+o,r+o];t=new n.Camera({...this.state,size:l})}t.update();const i=n.tetragonBounds(t.getViewportVertices());return{southWest:n.Mercator.toGeo(i.min),northEast:n.Mercator.toGeo(i.max)}}getDefaultSource(){return this.modules.defaultSource}hideBuildingsById(e,t=n.DEFAULT_ID_SCOPE){if(!e.length)return;const{identifier:i}=this.modules;i.getIdScope(t).hide(e),this.modules.renderer.addRerenderEvent({type:"triggerRerender"})}showHiddenBuildingsById(e,t=n.DEFAULT_ID_SCOPE){if(!e.length)return;const{identifier:i}=this.modules;i.getIdScope(t).show(e),this.modules.renderer.addRerenderEvent({type:"triggerRerender"})}getWebGLContext(){return this.modules.renderer.getRenderingContext()}getCanvas(){return this.modules.layout.canvas}showTraffic(){this.modules.trafficTileLayer.show()}hideTraffic(){this.modules.trafficTileLayer.hide()}isTrafficOn(){return this.modules.trafficTileLayer.isEnabled()}setPersonalPoi(e){this.modules.personalPoiManager.setPersonalPoi(e)}setSelectedIds(e=[],t=n.DEFAULT_ID_SCOPE){const{identifier:i}=this.modules;return i.getIdScope(t)?.select(e),this.modules.identifier.queryFillCache(),this}project(e){return this.modules.camera.project(e)}unproject(e){return this.modules.camera.unproject(e)}getCameraProjectionMatrix(){return this.modules.camera.projectionMatrix}getCameraViewMatrix(){return this.modules.camera.viewMatrix}getCameraViewProjectionMatrix(){return this.modules.camera.viewProjectionMatrix}invalidateSize(){this.state.userHasInteracted=!1;const e=window.devicePixelRatio,{viewport:t}=this.state,{clientWidth:i,clientHeight:o}=this.modules.layout.rootContainer;return this.state.size=[Math.max(1,i-t.left-t.right),Math.max(1,o-t.top-t.bottom)],this.modules.renderer.setPixelRatio(e),this.modules.renderer.setSize(i,o),this.modules.renderer.addRerenderEvent(),this.modules.newRenderer.resize(i,o,e),this}destroy(){this.core.destroy(),this._bssDispatcher?.destroy()}refresh(){return this.modules.renderer.addRerenderEvent(),this.state.needLabeling=!0,this.modules.identifier.resetCache(),this}changeFloorNumber(e,t){return this.modules.floorManager.changeFloorNumber(e,t),this.state.shouldIsReadyWaitForUpdates=!0,this}hasLayer(e){return this.modules.styleManager.hasLayer(e)}addLayer(e,t){return e.type==="custom"&&(this.state.aaMode=void 0),this.modules.styleManager.addLayer(e,t),this.core.activateStyleUpdating(),this}removeLayer(e){return this.modules.styleManager.removeLayer(e),this.core.activateStyleUpdating(),this}hideLayers(e){const{id:t,type:i}=e,o=a=>(this.modules.styleManager.hideLayers(a),this.modules.renderer.addRerenderEvent(),this);if(n.isStyleLayerType(i)&&n.isStyleLayerHidable(i)){const a=n.convertStyleLayerTypeToHandy(i);if(a)return o({type:a})}else if(t)return o({id:t});return console.warn(`[#hideLayers] The layer with type "${i}" can't be hidden.`),this}showLayers(e){const{id:t,type:i}=e,o=a=>(this.modules.styleManager.showLayers(a),this.modules.renderer.addRerenderEvent(),this);if(n.isStyleLayerType(i)&&n.isStyleLayerHidable(i)){const a=n.convertStyleLayerTypeToHandy(i);if(a)return o({type:a})}else if(t)return o({id:t});return console.warn(`[#showLayers] The layer with type "${i}" can't be shown.`),this}async setStyle(e,t){let i,o=!1,a=!1;try{return typeof e=="string"?n.isStyleId(e)?(o=!this.core.state.disableStyleFallback&&Number.isNaN(this.state.handyStyleId)&&e!==n.DEFAULT_MAPGL_STYLE,i=await this.setCustomStyleById(e,t)):i=await this.setCustomStyleFromUrl(e,t):(await this.setCustomStyleDirectly(e,t),i=e),a=!0,this.emit("styleload",{style:i}),i}catch(r){if(a)throw r;if(r instanceof Error&&this.emit("error",{type:"styleloaderror",style:e}),o&&!this.currentPendingStyle)return this.setStyle(n.DEFAULT_MAPGL_STYLE);throw r}}addIcon(e,t){return e?(this.modules.styleManager.addIcon(e,t)&&this.core.activateStyleUpdating(),this):(console.error("The icon name is empty."),this)}removeIcon(e){return e?(this.modules.styleManager.removeIcon(e)&&this.core.activateStyleUpdating(),this):this}addModel(e,t){return e?(this.modules.styleManager.addModel(e,t)&&this.core.activateStyleUpdating(),this):(console.error("The model name is empty."),this)}waitForGpuToFinishDrawing(){return this.modules.identifier.readIdentifyPixels(!0),this}setLang(e){const t=n.isRtlPluginRequired(this.state.rtlPlugin.scenario,e);this.state.rtlPlugin.loadFailed&&t||(this.state.lang=e,this.state.rtlPlugin.loadFailed||n.setupMapboxRtlAdapterIfNeeded(this.state.rtlPlugin,this.modules,e).catch(i=>{throw this.state.rtlPlugin.loadFailed=!0,this.setLang(n.defaultLang),i}),this.modules.tileManager.redraw())}showLabelsDebug(e){this.modules.labelsDebug.show(e)}hideLabelsDebug(){this.modules.labelsDebug.hide()}getContainer(){return this.modules.layout.mapContainer}getExternalContainer(){return this.modules.layout.externalContainer}fitBounds({northEast:e,southWest:t},i){const o={top:0,left:0,right:0,bottom:0,...i?.padding?i.padding:{}},a=this.getViewport(),r=this.getPadding(),l=i?.skipMapPadding?o:vc(r,o),c=this.getSize(),d=i?.considerRotation?this.getRotation():0;if(c[0]-l.left-l.right<=0||c[1]-l.top-l.bottom<=0)return console.warn("Map cannot fit within canvas with the given bounds and padding."),this;i?.considerRotation||Qt(this.state,d,{animate:!1});const _=hs([[t[0],e[1]],e,[e[0],t[1]],t],d,[c[0]-l.left-l.right,c[1]-l.top-l.bottom]);if(!_)return console.warn("Map cannot fit within canvas with the given bounds and padding."),this;const u=[(c[0]-l.left-l.right)/2+l.left+a.left,(c[1]-l.top-l.bottom)/2+l.top+a.top];let h;i?.maxZoom!==void 0?h=Math.min(_.zoom,i?.maxZoom):h=_.zoom,h=n.clamp(h,this.state.minZoom,this.state.maxZoom);const m=new n.Camera({zoom:h,rotation:this.state.rotation,size:this.state.size,padding:this.state.padding,viewport:this.state.viewport,pitch:0,center:_.center,cameraConfig:this.state.cameraConfig,globeMode:this.state.globeMode,styleState:this.state.styleState}).flat.unproject(u),p=[0,0];n.sub(p,_.center,m);const v=[0,0,0];n.add(v,_.center,p);const y=i?.animation?i.animation:{};y.easing||(y.easing="easeOutCubic");const b={...y};return bt(this.state,v,y),dt(this.state,h,b),wi(this.state,0,y),this}update(){const e=this.state,{time:t,userHasInteracted:i}=e,o=this.values,a={};Sl.forEach(c=>{let d=e[c];c==="zoom"&&e.zoomTypePreserving==="styleZoom"&&(d=e.styleZoom),a[`${c}start`]=!o[`is${c}Changing`]&&!this.areEqual(d,o[`${c}1`])&&this.areEqual(o[`${c}1`],o[`${c}2`]),a[`${c}start`]&&(o[`is${c}Changing`]=!0),o[`is${c}Changing`]&&(a[c]=!this.areEqual(d,o[`${c}1`]),t-o[`${c}EndTime`]>Ty&&(a[`${c}end`]=this.areEqual(d,o[`${c}End1`])&&!this.areEqual(o[`${c}End1`],o[`${c}End2`]),a[`${c}end`]&&(o[`is${c}Changing`]=!1),this.copyFromValuesToValues(`${c}End2`,`${c}End1`),this.copyFromStateToValues(d,`${c}End1`),o[`${c}EndTime`]=t)),this.copyFromValuesToValues(`${c}2`,`${c}1`),this.copyFromStateToValues(d,`${c}1`)}),a.resize=!this.areEqual(e.size,o.size),this.copyFromStateToValues(e.size,"size"),a.movestart=(a.zoomstart||a.rotationstart||a.centerstart||a.pitchstart)&&!o.isMoveChanging,a.movestart&&(o.isMoveChanging=!0),a.move=o.iszoomChanging||o.isrotationChanging||o.iscenterChanging||o.ispitchChanging,a.moveend=(a.zoomend||a.rotationend||a.centerend||a.pitchend)&&!a.move,a.moveend&&(o.isMoveChanging=!1);const r=o.isIdle,l=o.isReady;o.isIdle=this.isIdle(),o.isReady=this.isReady(),a.idle=!r&&o.isIdle,a.ready=!l&&o.isReady,e.metrics.ready===void 0&&this.isReadyForMetrics()&&(e.metrics.ready=performance.now()-e.metrics.start);for(const c in a){const d=c;a[d]&&this.emit(d,{isUser:i})}}isIdle(){return!this.values.isMoveChanging&&!this.currentPendingStyle&&this.core.isIdle()}isReady(){return!this.values.isMoveChanging&&!this.currentPendingStyle&&this.core.isReady()}isReadyForMetrics(){return!this.values.isMoveChanging&&!this.currentPendingStyle&&this.core.isReadyForMetrics()}setAutoHoverMode(e){this.modules.defaultSource.resetHoverId(),this.state.disableHoverStyles=!e}setStyleState(e){const{_customUserTimeOffset:t}=this.state.styleState,i=()=>{this.state.styleState._customUserTimeOffset=t};if(this.state.graphicsPresetMode){const o=Bt()?"light":e.graphicsPreset;this.state.styleState=hn(e,this.getGraphicsPresetFeatures(o))}else this.state.styleState=hn(e);i(),this.updateDataToggle(),this.modules.renderer.addRerenderEvent()}getStyleState(){return{...this.state.styleState}}patchStyleState(e){if(this.state.graphicsPresetMode){const t=Bt()?"light":e.graphicsPreset;this.state.styleState=Qr(this.state.styleState,e,this.getGraphicsPresetFeatures(t))}else this.state.styleState=Qr(this.state.styleState,e);this.updateDataToggle(),this.modules.renderer.addRerenderEvent()}setOption(e,t){if(fs.indexOf(e)===-1){console.error(`Can't change the "${e}" option.`);return}switch(e){case"loopWorld":{if(this.state.loopWorld===t)return;const i=t?n.worldLoopBounds:n.worldBounds,o=this.state.maxBounds;(n.exactEquals$1(o.min,n.worldLoopBounds.min)&&n.exactEquals$1(o.max,n.worldLoopBounds.max)||n.exactEquals$1(o.min,n.worldBounds.min)&&n.exactEquals$1(o.max,n.worldBounds.max))&&(this.state.maxBounds=i),this.modules.renderer.addRerenderEvent();break}case"disableHidingPois":{if(this.state.disableHidingPois===t)return;this.modules.renderer.addRerenderEvent();break}}this.state[e]=t}getOption(e){if(fs.indexOf(e)===-1){console.error(`Can't get the value of the "${e}" option.`);return}return this.state[e]}getGroundPoint(e){return this.modules.demManager.getGroundPoint(e)}setAllowedFloorIds(e){this.modules.floorManager.setAllowedFloorIds(e)}getMapRenderStat(){this.modules.renderer.addRerenderEvent();const{drawCount:e,vertexCount:t,triangleCount:i}=this.state.stats,a=598044/(this.state.size[0]*this.state.size[1]/window.devicePixelRatio),r=[{level:0,draws:[0,500],vertcles:[0,1e6],triangles:[0,333e3]},{level:1,draws:[501,1e3],vertcles:[1000001,2e6],triangles:[3330001,666e3]},{level:2,draws:[1001,1500],vertcles:[2000001,3e6],triangles:[666001,999e3]},{level:3,draws:[1501,2500],vertcles:[3000001,6e6],triangles:[999001,2e6]},{level:4,draws:[2501,3500],vertcles:[6000001,12e6],triangles:[2000001,4e6]},{level:5,draws:[3501,1/0],vertcles:[12000001,1/0],triangles:[4000001,1/0]}],l=e*a,c=t*a,d=i*a,_=r.find(f=>f.draws[0]<=l&&f.draws[1]>=l)?.level||0,u=r.find(f=>f.vertcles[0]<=c&&f.vertcles[1]>=c)?.level||0,h=r.find(f=>f.triangles[0]<=d&&f.triangles[1]>=d)?.level||0;return{drawCount:e,vertexCount:t,drawsLevel:_,vertexLevel:u,triangleCount:i,triangleLevel:h,level:Math.ceil((_+u)/2)}}getDataToggle(){return this.modules.defaultSource.getDataType()}setLightingStyle(e){const t=this.modules.styleManager.getStyle(this.state.handyStyleId);t&&(t.light=n.makeHandyLightStyle(e,t.dem),t.light.lightingModesResolved={},this.state.needRerender=!0)}getFeatureFlag(e,t){return!this.modules||(t=t??this.core.state.styleState.graphicsPreset,!t)?!1:this.modules.styleManager.getFeatureFlag(e,t)}getCurrentGraphicsPreset(){if(!this.state.graphicsPresetMode)throw new Error("You can get current graphics preset only when graphicsPresetMode is set.");return{name:this.state.styleState.graphicsPreset,preset:this.getGraphicsPresetFeatures()}}getGraphicsPresetFeatures(e){return Yg.reduce((t,i)=>(t[i]=this.getFeatureFlag(i,e),t),{})}async setCustomStyleById(e,t){this.currentPendingStyle=e;const{iconUrl:i,styleServer:o,fontUrl:a,modelUrl:r}=this.state,l=n.applyDefaults(t||{},{rootUrl:o,stylePath:n.styles.path,iconsPath:i,fontsPath:a,modelsPath:r}),c=await this.fetchStyleById(n.getStyleUrl(l),e);if(this.currentPendingStyle!==e)return Promise.reject(`Cancel setting the style «${e}», there is a newer style was set`);if(!c)throw this.currentPendingStyle=void 0,new Error(`There is no correct style with id «${e}»`);const{style:d,loadedId:_}=c;return await this.setCustomStyle(d,l),_}async setCustomStyleFromUrl(e,t){this.currentPendingStyle=e;const i=n.applyDefaults(t||{},{rootUrl:e,iconsPath:"",fontsPath:"",stylePath:"style.json",modelsPath:""}),o=await Ey(n.getStyleUrl(i));if(e!==this.currentPendingStyle)return Promise.reject(`Cancel setting the style «${e}», there is a newer style was set`);if(!o)throw this.currentPendingStyle=void 0,new Error(`There are no correct styles by url «${e}»`);return await this.setCustomStyle(o,i),e}setCustomStyleDirectly(e,t){const i=window.location.protocol,o=window.location.host,a=n.applyDefaults(t||{},{rootUrl:`${i}//${o}`,stylePath:"",iconsPath:"",fontsPath:"",modelsPath:""});this.currentPendingStyle=`__${Date.now()}__${performance.now()}__`;const r=e&&JSON.parse(JSON.stringify(e));return this.setCustomStyle(r,a)}async setCustomStyle(e,t){if(!e)throw new Error("Can't set empty style");const i=this.currentPendingStyle||"";this.currentPendingStyle=void 0;const o=await Sy(e,this.state.tileKey,t);if(this.currentPendingStyle!==void 0)return;const{showCommPoi:a}=await this.modules.tileKeyInfo.getKeyInfo(),r=this.modules.styleManager.createStyle(o,t,a);this.state.handyStyleId=r.id,this.state.styleId=i,this.patchStyleState({}),this.core.activateStyleUpdating()}copyFromStateToValues(e,t){fi(e)?n.copy$3(this.values[t],e):this.values[t]=e}cloneFromStateToValues(e,t){const i=this.state[e];fi(i)?this.values[t]=n.clone(i):this.values[t]=i}copyFromValuesToValues(e,t){const i=this.values[t];fi(i)?n.copy$3(this.values[e],i):this.values[e]=i}areEqual(e,t){return fi(e)&&fi(t)?n.exactEquals$1(e,t):e===t}async fetchStyleById(e,t){const i=new URL(n.template(e,{id:t}));i.searchParams.append("key",this.state.tileKey);const o=await fetch(i.toString());if(o.status===404){console.warn(`No access to style with id «${t}».`);return}if(!o.ok)return;const a=await o.json();if(a&&a.result)return{loadedId:t,style:a.result}}updateDataToggle(){this.modules.defaultSource.setDataType(this.state.styleState.immersiveRoadsOn?My:void 0)}}function Ey(s){return fetch(s).then(e=>{if(e.ok)return e.json()})}function fi(s){return s.length!==void 0}const Tl=0,Iy=-1,Cy=-2,Ml=3,Ly=0,Py=0,By="#3388ff",zy="#00000000",Ry="#00000000";let El=class extends Re{constructor(e,t){super(e,t),this.length=1,this.isGeometryOutOfMainReplica=!1,this.removed=!1,this.options=t;const{dynamicStyle:i,layers:o}=this.modules;this.dynamicStyleId=i.getStyle().id,this.geoPoints=this.options.coordinates.filter((r,l,c)=>l===0||!n.exactEquals$2(c[l],c[l-1])),this.points=this.geoPoints.map(r=>n.Mercator.fromGeo(r)),this.isGeometryOutOfMainReplica=this.points.some(r=>r[0]>n.HALF_WORLD_SIZE||r[0]<-n.HALF_WORLD_SIZE);let a=0;this.distances=[],this.distances.push(a);for(let r=1;r<this.geoPoints.length;r++)a+=n.geoPointsDistance(this.geoPoints[r-1],this.geoPoints[r]),this.distances.push(a);if(this.stateDiffer=new n.Differ([{path:"center",type:"vec2"},{path:"zoom",type:"number"},{path:"size",type:"vec2"},{path:"rotation",type:"number"},{path:"pitch",type:"number"},{path:"padding",type:"padding"},{path:"demMode",type:"boolean"}]),this.debouncedGenerate=n.debounce(()=>{this.generate()},200),this.tileAttrs=n.optionsToTileAttrs({beginningIsCut:0,endingIsCut:0,db_tiers:t.tiers}),this.options.width!==0){this.rawStyleLayer={type:"line",id:`dynamic-polyline-${this.uniqId}`,minzoom:this.options.minZoom,maxzoom:this.options.maxZoom,style:{color:this.options.color??By,width:this.options.width??Ml},gpuState:this.options.renderingMode!=="3d"?this.options.gpuState:{depthTest:!0}};const r=n.makeHandyStyleLayer(this.rawStyleLayer);if(r&&(this.styleLayerId=r.innerId,i.addLayer(r,this.options.zIndex??Tl)),this.options.renderingMode==="3d"&&this.options.hiddenPartColor){this.rawHiddenStyleLayer={type:"line",id:`dynamic-polyline-hidden-${this.uniqId}`,minzoom:this.options.minZoom,maxzoom:this.options.maxZoom,style:{color:this.options.hiddenPartColor,width:this.options.width??Ml},gpuState:{depthTest:!0,depthMask:!1,cullFace:!1,depthFunc:n.DEPTH_FUNC.GREATER}};const l=n.makeHandyStyleLayer(this.rawHiddenStyleLayer);l&&(this.styleHiddenLayerId=l.innerId,i.addLayer(l,this.options.zIndex??Tl))}}if(this.options.width2){this.rawStyleLayer2={type:"line",id:`dynamic-polyline2-${this.uniqId}`,minzoom:this.options.minZoom,maxzoom:this.options.maxZoom,style:{color:this.options.color2??zy,width:this.options.width2??Ly},gpuState:this.options.renderingMode!=="3d"?this.options.gpuState:{depthTest:!0}};const r=n.makeHandyStyleLayer(this.rawStyleLayer2);r&&(this.styleLayer2Id=r.innerId,i.addLayer(r,this.options.zIndex2??Iy))}if(this.options.width3){this.rawStyleLayer3={type:"line",id:`dynamic-polyline3-${this.uniqId}`,minzoom:this.options.minZoom,maxzoom:this.options.maxZoom,style:{color:this.options.color3??Ry,width:this.options.width3??Py},gpuState:this.options.renderingMode!=="3d"?this.options.gpuState:{depthTest:!0}};const r=n.makeHandyStyleLayer(this.rawStyleLayer3);r&&(this.styleLayer3Id=r.innerId,i.addLayer(r,this.options.zIndex3??Cy))}if(!(this.styleLayerId===void 0&&this.styleLayer2Id===void 0&&this.styleLayer3Id===void 0)){if(t.showAnimation&&t.showAnimation.animate!==!1&&this.points.length>1){this.animationTickerName=`polyline-${this.uniqId}`;const r=this.styleLayer3Id??this.styleLayer2Id??this.styleLayerId;r&&this.startShowTicker(this.animationTickerName,r)}o.addLayer(this),this.generate()}}update(){this.removed||(super.update(),this.stateDiffer.check(this.mapState)&&this.debouncedGenerate(),this.animationTickerName&&this.updateShowTicker(this.animationTickerName))}isOutOfMainReplica(){return this.isGeometryOutOfMainReplica}snapPoint(e){function t([u,h],f=0){return[f+(u+n.HALF_WORLD_SIZE)/n.worldSize,(h+n.HALF_WORLD_SIZE)/n.worldSize]}function i([u,h]){return[u*n.worldSize-n.HALF_WORLD_SIZE,h*n.worldSize-n.HALF_WORLD_SIZE]}const o=this.mapState.visibleMapReplicas,a=this.points.map(u=>t(u));let r=1/0,l=a[0],c=0;for(const u of o){const h=t(this.modules.camera.flat.unproject(e),u);for(let f=0;f<a.length-1;f++){const m=a[f],p=a[f+1],v=n.getClosestPointOnLineSegment(h,m,p),y=v[0]-h[0],b=v[1]-h[1],x=y*y+b*b;x<r&&(r=x,l=i(v),c=f)}}const d=n.Mercator.toGeo(l),_=this.distances[c]+n.geoPointsDistance(d,this.geoPoints[c]);return{point:d,distance:_}}setStyle(e){this.setSubLayerStyle(this.styleLayerId,this.rawStyleLayer,e.color),this.setSubLayerStyle(this.styleLayer2Id,this.rawStyleLayer2,e.color2),this.setSubLayerStyle(this.styleLayer3Id,this.rawStyleLayer3,e.color3),this.setSubLayerStyle(this.styleHiddenLayerId,this.rawHiddenStyleLayer,e.hiddenPartColor)}remove(){this.removed||(this.removed=!0,this.animationTickerName&&(n.stop(this.animationTickerName,this.mapState),this.animationTickerName=void 0),this.interactive&&this.modules.identifier.resetCache(),this.styleLayerId!==void 0&&this.modules.dynamicStyle.removeLayer(this.styleLayerId),this.styleHiddenLayerId!==void 0&&this.modules.dynamicStyle.removeLayer(this.styleHiddenLayerId),this.styleLayer2Id!==void 0&&this.modules.dynamicStyle.removeLayer(this.styleLayer2Id),this.styleLayer3Id!==void 0&&this.modules.dynamicStyle.removeLayer(this.styleLayer3Id),super.destroy())}startShowTicker(e,t){const a=this.options.showAnimation?.easing!==void 0?this.options.showAnimation.easing:"linear",r=this.options.showAnimation?.duration!==void 0?this.options.showAnimation.duration:250;n.start(e,{easing:a,animationGroup:this.options.showAnimation?.animationGroup},this.mapState,0,1,r,1,{layerId:t,styleId:this.dynamicStyleId}),this.length=0}setSubLayerStyle(e,t,i){if(e!==void 0&&i&&t&&i!==t.style.color){const{dynamicStyle:o}=this.modules;t.style.color=i;const a=n.makeHandyStyleLayer(t);a&&(o.updateLayerStyle(e,a),this.modules.renderer.addRerenderEvent())}}updateShowTicker(e){n.update(e,{step:(t,i)=>{const o=n.affineStep(this.options.showAnimation?.durationRange?.start||0,this.options.showAnimation?.durationRange?.end||1,i);o!==this.length&&(this.length=o,this.generate())}},this.mapState)}generate(){if(this.points.length<2||this.removed)return;const e=!!this.animationTickerName,{dynamicStyle:t,collector:i,tileManager:o,identifier:a,map:r}=this.modules,{tileProps:l}=n.fixedMetatile,c=Math.min(Math.floor(r.getZoom()),15),d=n.tileZoomToSize(c),_=n.splitPolylineByLength(this.points,this.distances,this.length),u=n.splitPolylineByMaxSize(_,d),h=n.create$1(),f=n.create();this.tileObjects.forEach(m=>{m.clean(this.mapState),o.removeObject(m,e)}),this.tileObjects=[];for(let m=0;m<u.length;m++){const p=u[m];n.reset(f);for(let C=0;C<p.length;C++)n.expandByPoint(f,p[C]);n.center(h,f);const v=n.getTileCoordsByCenterAndZoom(h,c),y=Math.pow(2,v[2]),b=[...this.mapState.visibleMapReplicas];if(this.isOutOfMainReplica()){const C=b[0],j=b[b.length-1];b.push(C-1,j+1)}if(!b.map(C=>[v[0]+C*y,v[1],v[2],v[3]]).some(C=>this.mapState.globeMode?n.isTileOnSphereInViewport(this.mapState,this.modules.camera,C):n.isTileVisible(C,this.mapState.tilesBounds,this.modules)))continue;if(this.options.displayTileBounds){const j=t.getStyle().layers.find(Y=>Y.id==="debug-tile-bounds");n.generateTileBounds(i,j,this.mapState.styleState);const H=i.getAccumulatedData(),K=new n.TileObject("dynamicObject",H.data,this.modules,this.mapState,v);this.tileObjects.push(K),o.addObject(K,e)}const w=n.createTileInfo(v),M=[],z=[];for(let C=0;C<p.length;C++)n.mapPointToTilePoint(h,p[C],w),M[C]=h[0],z[C]=h[1];this.tileAttrs[l.beginningIsCut]=0,this.tileAttrs[l.endingIsCut]=0,m!==0&&(this.tileAttrs[l.beginningIsCut]=1),m+1!==u.length&&(this.tileAttrs[l.endingIsCut]=1);const S=n.makeGeneratorContext(this.mapState.styleState,n.emptySourceAttrs,n.fixedTileProps,this.tileAttrs,n.emptyFeatureAttrs,this.interactive?"0":"");if(this.styleLayerId!==void 0){const C=t.getStyle().layersById[this.styleLayerId];n.isLineStyleLayer(C)&&(n.runPrecomputes(C,S),n.generateSafely({collector:i,generator:n.LineGenerator.generate,args:[t.getStyle().id,C,S,w,{x:M,y:z}]}))}if(this.styleHiddenLayerId!==void 0){const C=t.getStyle().layersById[this.styleHiddenLayerId];n.isLineStyleLayer(C)&&(n.runPrecomputes(C,S),n.generateSafely({collector:i,generator:n.LineGenerator.generate,args:[t.getStyle().id,C,S,w,{x:M,y:z}]}))}if(this.styleLayer2Id!==void 0){const C=t.getStyle().layersById[this.styleLayer2Id];n.isLineStyleLayer(C)&&(n.runPrecomputes(C,S),n.generateSafely({collector:i,generator:n.LineGenerator.generate,args:[t.getStyle().id,C,S,w,{x:M,y:z}]}))}if(this.styleLayer3Id!==void 0){const C=t.getStyle().layersById[this.styleLayer3Id];n.isLineStyleLayer(C)&&(n.runPrecomputes(C,S),n.generateSafely({collector:i,generator:n.LineGenerator.generate,args:[t.getStyle().id,C,S,w,{x:M,y:z}]}))}const I=i.getAccumulatedData(),R=new n.TileObject("dynamicObject",I.data,this.modules,this.mapState,w.coords,this);o.addObject(R,e),this.tileObjects.push(R),this.interactive&&this.identifyIds.push(I.identifyIds)}this.interactive&&a.resetCache(),i.reset(),e||this.modules.renderer.addRerenderEvent()}};const Il=0,Cl=-1,Ll=8,Pl=12,Fy="#2480ff",Dy="#ffffff",Bl=6,zl=20,Oy="#ffffff00";class Rl extends Re{constructor(e,t){super(e,t),this.isGeometryOutOfMainReplica=!1,this.length=1,this.dynamicStyleId=this.modules.dynamicStyle.getStyle().id,this.removed=!1,this.options=t,this.points=this.options.coordinates.map(o=>n.Mercator.fromGeo(o)),this.isGeometryOutOfMainReplica=this.points.some(o=>o[0]>n.HALF_WORLD_SIZE||o[0]<-n.HALF_WORLD_SIZE),this.distances=[],this.stateDiffer=new n.Differ([{path:"center",type:"vec2"},{path:"zoom",type:"number"},{path:"size",type:"vec2"},{path:"rotation",type:"number"},{path:"pitch",type:"number"},{path:"padding",type:"padding"},{path:"demMode",type:"boolean"}]),this.debouncedGenerate=n.debounce(()=>{this.generate()},200),this.tileAttrs=n.optionsToTileAttrs({previousPointX:0,previousPointY:0,nextPointX:0,nextPointY:0,beginningIsCut:0,endingIsCut:0,componentDistanceStart:0,objectLength:0,db_tiers:t.tiers});const{layers:i}=this.modules;if(i.addLayer(this),this.dashLayerRaw={type:"dashedLine",id:`dynamic-dashed-polyline-dash-${this.uniqId}`,minzoom:this.options.minZoom,maxzoom:this.options.maxZoom,style:{color:this.options.dashColor||Fy,dashLength:this.options.dashLength??Bl,gapColor:this.options.gapColor||Oy,gapLength:this.options.gapLength??zl,width:this.options.width??Ll},gpuState:this.options.renderingMode!=="3d"?this.options.gpuState:{depthTest:!0}},this.baseLayerRaw={type:"line",id:`dynamic-dashed-polyline-base-${this.uniqId}`,minzoom:this.options.minZoom,maxzoom:this.options.maxZoom,style:{color:this.options.dash2Color||Dy,width:this.options?.width2??Pl},gpuState:this.options.renderingMode!=="3d"?this.options.gpuState:{depthTest:!0}},this.dashLayer=n.makeHandyStyleLayer(this.dashLayerRaw),this.baseLayer=n.makeHandyStyleLayer(this.baseLayerRaw),t.renderingMode==="3d"&&t.hiddenPartDashColor&&(this.hiddenDashLayerRaw={type:"dashedLine",id:`dynamic-hidden-dashed-polyline-dash-${this.uniqId}`,minzoom:this.options.minZoom,maxzoom:this.options.maxZoom,style:{color:t.hiddenPartDashColor,dashLength:this.options.dashLength??Bl,gapColor:this.options.hiddenPartGapColor,gapLength:this.options.gapLength??zl,width:this.options.width??Ll},gpuState:{depthTest:!0,depthMask:!1,cullFace:!1,depthFunc:n.DEPTH_FUNC.GREATER}},this.hiddenDashLayer=n.makeHandyStyleLayer(this.hiddenDashLayerRaw),this.options.hiddenPartDash2Color&&(this.hiddenBaseLayerRaw={type:"line",id:`dynamic-hidden-dashed-polyline-base-${this.uniqId}`,minzoom:this.options.minZoom,maxzoom:this.options.maxZoom,style:{color:this.options.hiddenPartDash2Color,width:this.options?.width2??Pl},gpuState:{depthTest:!0,depthMask:!1,cullFace:!1,depthFunc:n.DEPTH_FUNC.GREATER}},this.hiddenBaseLayer=n.makeHandyStyleLayer(this.hiddenBaseLayerRaw))),t.showAnimation&&t.showAnimation.animate!==!1&&this.points.length>1){let o=0;this.distances.push(o);for(let r=1;r<this.options.coordinates.length;r++)o+=n.geoPointsDistance(this.options.coordinates[r-1],this.options.coordinates[r]),this.distances.push(o);this.animationTickerName=`dashedLine-${this.uniqId}`;const a=this.baseLayer?.innerId;a&&this.startShowTicker(this.animationTickerName,a)}this.generate()}update(){this.removed||(super.update(),this.stateDiffer.check(this.mapState)&&this.debouncedGenerate(),this.animationTickerName&&this.updateShowTicker(this.animationTickerName))}isOutOfMainReplica(){return this.isGeometryOutOfMainReplica}setStyle(e){const{dashColor:t,dash2Color:i,gapColor:o,hiddenPartDashColor:a,hiddenPartGapColor:r,hiddenPartDash2Color:l}=e,{dynamicStyle:c}=this.modules;if(this.dashLayer){t!==void 0&&(this.dashLayerRaw.style.color=t),o!==void 0&&(this.dashLayerRaw.style.gapColor=o);const d=n.makeHandyStyleLayer(this.dashLayerRaw);d&&c.updateLayerStyle(this.dashLayer.innerId,d)}if(this.baseLayer){i!==void 0&&(this.baseLayerRaw.style.color=i);const d=n.makeHandyStyleLayer(this.baseLayerRaw);d&&c.updateLayerStyle(this.baseLayer.innerId,d)}if(this.hiddenDashLayer&&this.hiddenDashLayerRaw){a!==void 0&&(this.hiddenDashLayerRaw.style.color=a),o!==void 0&&(this.hiddenDashLayerRaw.style.gapColor=r);const d=n.makeHandyStyleLayer(this.hiddenDashLayerRaw);d&&c.updateLayerStyle(this.hiddenDashLayer.innerId,d)}if(this.hiddenBaseLayer&&this.hiddenBaseLayerRaw){l!==void 0&&(this.hiddenBaseLayerRaw.style.color=l);const d=n.makeHandyStyleLayer(this.hiddenBaseLayerRaw);d&&c.updateLayerStyle(this.hiddenBaseLayer.innerId,d)}this.modules.renderer.addRerenderEvent()}remove(){this.removed||(this.removed=!0,this.animationTickerName&&(n.stop(this.animationTickerName,this.mapState),this.animationTickerName=void 0),this.interactive&&this.modules.identifier.resetCache(),this.baseLayer&&this.modules.dynamicStyle.removeLayer(this.baseLayer.innerId),this.dashLayer&&this.modules.dynamicStyle.removeLayer(this.dashLayer.innerId),this.hiddenBaseLayer&&this.modules.dynamicStyle.removeLayer(this.hiddenBaseLayer.innerId),this.hiddenDashLayer&&this.modules.dynamicStyle.removeLayer(this.hiddenDashLayer.innerId),super.destroy())}updateShowTicker(e){n.update(e,{step:(t,i)=>{const o=n.affineStep(this.options.showAnimation?.durationRange?.start||0,this.options.showAnimation?.durationRange?.end||1,i);o!==this.length&&(this.length=o,this.generate())}},this.mapState)}startShowTicker(e,t){const a=this.options.showAnimation?.easing!==void 0?this.options.showAnimation.easing:"linear",r=this.options.showAnimation?.duration!==void 0?this.options.showAnimation.duration:250;n.start(e,{easing:a,animationGroup:this.options.showAnimation?.animationGroup},this.mapState,0,1,r,1,{layerId:t,styleId:this.dynamicStyleId}),this.length=0}generate(){if(this.points.length<2||this.removed)return;const e=!!this.animationTickerName,{dynamicStyle:t,collector:i,tileManager:o,map:a,identifier:r}=this.modules,{tileProps:l}=n.fixedMetatile,c=Math.min(Math.floor(a.getZoom()),12),d=n.tileZoomToSize(c),_=n.splitPolylineByLength(this.points,this.distances,this.length),u=n.splitPolylineByMaxSize(_,d),h=n.create$1(),f=n.create();this.tileObjects.forEach(b=>{b.clean(this.mapState),o.removeObject(b,e)}),this.tileObjects=[];const m=[];let p=0;for(const b of u){n.reset(f);for(let S=0;S<b.length;S++)n.expandByPoint(f,b[S]);n.center(h,f);const x=n.getTileCoordsByCenterAndZoom(h,c),T=n.createTileInfo(x),w=[],M=[];let z=0;for(let S=0;S<b.length;S++)if(n.mapPointToTilePoint(h,b[S],T),w[S]=h[0],M[S]=h[1],S!==0){const I=w[S]-w[S-1],R=M[S]-M[S-1];z+=Math.sqrt(I*I+R*R)}p+=z,m.push({vertices:{x:w,y:M},tileInfo:T,distance:z})}let v=0;const y=n.makeGeneratorContext(this.mapState.styleState,n.emptySourceAttrs,n.fixedTileProps,this.tileAttrs,n.emptyFeatureAttrs,this.interactive?"0":"");m.forEach((b,x)=>{const{tileInfo:T,distance:w,vertices:M}=b;if(this.tileAttrs[l.beginningIsCut]=0,this.tileAttrs[l.endingIsCut]=0,this.tileAttrs[l.previousPointX]=0,this.tileAttrs[l.previousPointY]=0,this.tileAttrs[l.nextPointX]=0,this.tileAttrs[l.nextPointY]=0,this.tileAttrs[l.componentDistanceStart]=v,v+=w,this.tileAttrs[l.objectLength]=p,x!==0){const j=u[x-1],H=j[j.length-2];n.mapPointToTilePoint(h,H,T),this.tileAttrs[l.beginningIsCut]=1,this.tileAttrs[l.previousPointX]=h[0],this.tileAttrs[l.previousPointY]=h[1]}if(x!==m.length-1){const H=u[x+1][1];n.mapPointToTilePoint(h,H,T),this.tileAttrs[l.endingIsCut]=1,this.tileAttrs[l.nextPointX]=h[0],this.tileAttrs[l.nextPointY]=h[1]}const z=Math.pow(2,T.coords[2]),S=[...this.mapState.visibleMapReplicas];if(this.isOutOfMainReplica()){const j=S[0],H=S[S.length-1];S.push(j-1,H+1)}if(S.map(j=>[T.coords[0]+j*z,T.coords[1],T.coords[2],T.coords[3]]).every(j=>!n.isTileVisible(j,this.mapState.tilesBounds,this.modules)))return;this.dashLayer&&(t.addLayer(this.dashLayer,this.options.zIndex??Il),n.runPrecomputes(this.dashLayer,y),n.generateSafely({collector:i,generator:n.DashedLineGenerator.generate,args:[this.dynamicStyleId,this.dashLayer,y,T,M]})),this.baseLayer&&(t.addLayer(this.baseLayer,this.options.zIndex2??Cl),n.runPrecomputes(this.baseLayer,y),n.generateSafely({collector:i,generator:n.LineGenerator.generate,args:[this.dynamicStyleId,this.baseLayer,y,T,M]})),this.hiddenDashLayer&&(t.addLayer(this.hiddenDashLayer,this.options.zIndex??Il),n.runPrecomputes(this.hiddenDashLayer,y),n.generateSafely({collector:i,generator:n.DashedLineGenerator.generate,args:[this.dynamicStyleId,this.hiddenDashLayer,y,T,M]})),this.hiddenBaseLayer&&(t.addLayer(this.hiddenBaseLayer,this.options.zIndex2??Cl),n.runPrecomputes(this.hiddenBaseLayer,y),n.generateSafely({collector:i,generator:n.LineGenerator.generate,args:[this.dynamicStyleId,this.hiddenBaseLayer,y,T,M]}));const R=i.getAccumulatedData(),C=new n.TileObject("dynamicObject",R.data,this.modules,this.mapState,T.coords,this);o.addObject(C,e),this.tileObjects.push(C),this.interactive&&this.identifyIds.push(R.identifyIds)}),this.interactive&&r.resetCache(),i.reset(),e||this.modules.renderer.addRerenderEvent()}}const Ny="#3388ff33",ky="#3388ff",Uy=3;let Fl=class extends Re{constructor(e,t){super(e,t),this.isGeometryOutOfMainReplica=!1,this.options=t;const i=this.options.coordinates.map(I=>{const R=I.map(C=>n.Mercator.fromGeo(C));if(R.length>1){const C=R[0],j=R[R.length-1];(C[0]!==j[0]||C[1]!==j[1])&&R.push(C)}return R});let o=[];const a=[],{dynamicStyle:r,collector:l,tileManager:c,identifier:d,layers:_}=this.modules;i.forEach(I=>{o.length&&a.push(o.length),o=o.concat(I)}),this.isGeometryOutOfMainReplica=o.some(I=>I[0]>n.HALF_WORLD_SIZE||I[0]<-n.HALF_WORLD_SIZE);const u=n.makeHandyStyleLayer({type:"polygon",id:`dynamic-polygon-${this.uniqId}`,minzoom:this.options.minZoom,maxzoom:this.options.maxZoom,style:{color:this.options.color||Ny}});if(!u)return;r.addLayer(u,this.options.zIndex),this.fillLayerId=u.innerId;const h=n.optionsToTileAttrs({beginningIsCut:0,endingIsCut:0,db_tiers:t.tiers}),f=n.create();for(let I=0;I<o.length;I++)n.expandByPoint(f,o[I]);const m=n.getBoundsTileCoords(f),p=n.createTileInfo(m),v=[];for(let I=0;I<o.length;I++)v.push(o[I][0]),v.push(o[I][1]);const y=n.earcut(v,a),b=n.create$1(),x=[],T=[],w=[],M=n.makeGeneratorContext(this.mapState.styleState,n.emptySourceAttrs,n.fixedTileProps,h,n.emptyFeatureAttrs,this.interactive?"0":"");n.runPrecomputes(u,M);for(let I=0;I<y.length;I+=3){for(let R=0;R<3;R++)n.mapPointToTilePoint(b,o[y[I+R]],p),x[R]=b[0],T[R]=b[1],w[R]=0;n.generateSafely({collector:l,generator:n.PolygonGenerator.generate,args:[r.getStyle().id,u,M,{x,y:T,cut:w},n.pixelRatioToDpi(window.devicePixelRatio),r.getStyle().rasterSets]})}if(this.options.strokeWidth!==0){const I=n.makeHandyStyleLayer({type:"line",id:`dynamic-polygon-stroke-${this.uniqId}`,minzoom:this.options.minZoom,maxzoom:this.options.maxZoom,style:{color:this.options.strokeColor||ky,width:this.options.strokeWidth||Uy}});I&&(r.addLayer(I,this.options.zIndex),this.borderLayerId=I.innerId,n.runPrecomputes(I,M),i.forEach(R=>{const C=[],j=[];R.forEach((H,K)=>{n.mapPointToTilePoint(b,H,p),C[K]=b[0],j[K]=b[1]}),n.generateSafely({collector:l,generator:n.LineGenerator.generate,args:[r.getStyle().id,I,M,p,{x:C,y:j}]})}))}const z=l.getAccumulatedData(),S=new n.TileObject("dynamicObject",z.data,this.modules,this.mapState,p.coords,this);c.addObject(S),this.tileObjects.push(S),this.interactive&&this.identifyIds.push(z.identifyIds),_.addLayer(this),l.reset(),this.modules.renderer.addRerenderEvent(),this.interactive&&d.resetCache()}isOutOfMainReplica(){return this.isGeometryOutOfMainReplica}remove(){this.interactive&&this.modules.identifier.resetCache(),this.fillLayerId&&this.modules.dynamicStyle.removeLayer(this.fillLayerId),this.borderLayerId&&this.modules.dynamicStyle.removeLayer(this.borderLayerId),super.destroy()}};const Gy="#3388ff33",Hy="#3388ff",Vy=1,jy=150;let Dl=class extends Re{constructor(e,t){if(super(e,t),this.isGeometryOutOfMainReplica=!1,this.options=t,t.segments&&t.segments<=0)return;const{dynamicStyle:i,collector:o,tileManager:a,identifier:r,layers:l}=this.modules,c=Zy(n.Mercator.fromGeo(this.options.coordinates),n.geoToMapDistance(this.options.coordinates,this.options.radius),this.options.segments??jy);this.isGeometryOutOfMainReplica=c.some(M=>M[0]>n.HALF_WORLD_SIZE||M[0]<-n.HALF_WORLD_SIZE);const d=n.makeHandyStyleLayer({type:"polygon",id:`dynamic-circle-${this.uniqId}`,minzoom:this.options.minZoom,maxzoom:this.options.maxZoom,style:{color:this.options.color??Gy,strokeWidth:this.options.borderWidth??Vy,strokeColor:this.options.borderColor??Hy}});if(!d)return;i.addLayer(d,this.options.zIndex),this.layerId=d.innerId;const _=n.optionsToTileAttrs({db_tiers:t.tiers}),u=n.create();for(let M=0;M<c.length;M++)n.expandByPoint(u,c[M]);const h=n.getBoundsTileCoords(u),f=n.createTileInfo(h),m=[],p=[],v=[],y=n.create$1(),b=this.options.borderWidth!==0?1:0;for(let M=0;M<c.length;M++)n.mapPointToTilePoint(y,c[M],f),m[M]=y[0],p[M]=y[1],v[M]=b;const x=n.makeGeneratorContext(this.mapState.styleState,n.emptySourceAttrs,n.fixedTileProps,_,n.emptyFeatureAttrs,this.interactive?"0":"");n.runPrecomputes(d,x),n.generateSafely({collector:o,generator:n.PolygonGenerator.generate,args:[i.getStyle().id,d,x,{x:m,y:p,cut:v},n.pixelRatioToDpi(window.devicePixelRatio)]});const T=o.getAccumulatedData(),w=new n.TileObject("dynamicObject",T.data,this.modules,this.mapState,f.coords,this);a.addObject(w),this.tileObjects.push(w),this.interactive&&this.identifyIds.push(T.identifyIds),l.addLayer(this),o.reset(),this.modules.renderer.addRerenderEvent(),this.interactive&&r.resetCache()}remove(){this.interactive&&this.modules.identifier.resetCache(),this.layerId&&this.modules.dynamicStyle.removeLayer(this.layerId),super.destroy()}isOutOfMainReplica(){return this.isGeometryOutOfMainReplica}};function Zy(s,e,t){const i=[];if(t>0){i.push(n.fromValues(s[0]+e,s[1],s[2]));const o=Math.PI/Math.ceil(t/2);for(let a=o;a<Math.PI;a+=o){const r=e*Math.cos(a),l=e*Math.sin(a);i.push(n.fromValues(s[0]+r,s[1]+l,s[2]),n.fromValues(s[0]+r,s[1]-l,s[2]))}i.push(n.fromValues(s[0]-e,s[1],s[2]))}return i}function is(s,e,t,i,o,a){if(o-i<=t)return;const r=i+o>>1;Ol(s,e,r,i,o,a%2),is(s,e,t,i,r-1,a+1),is(s,e,t,r+1,o,a+1)}function Ol(s,e,t,i,o,a){for(;o>i;){if(o-i>600){const d=o-i+1,_=t-i+1,u=Math.log(d),h=.5*Math.exp(2*u/3),f=.5*Math.sqrt(u*h*(d-h)/d)*(_-d/2<0?-1:1),m=Math.max(i,Math.floor(t-_*h/d+f)),p=Math.min(o,Math.floor(t+(d-_)*h/d+f));Ol(s,e,t,m,p,a)}const r=e[2*t+a];let l=i,c=o;for(mi(s,e,i,t),e[2*o+a]>r&&mi(s,e,i,o);l<c;){for(mi(s,e,l,c),l++,c--;e[2*l+a]<r;)l++;for(;e[2*c+a]>r;)c--}e[2*i+a]===r?mi(s,e,i,c):(c++,mi(s,e,c,o)),c<=t&&(i=c+1),t<=c&&(o=c-1)}}function mi(s,e,t,i){ns(s,t,i),ns(e,2*t,2*i),ns(e,2*t+1,2*i+1)}function ns(s,e,t){const i=s[e];s[e]=s[t],s[t]=i}function Wy(s,e,t,i,o,a,r){const l=[0,s.length-1,0],c=[];let d,_;for(;l.length;){const u=l.pop(),h=l.pop(),f=l.pop();if(h-f<=r){for(let v=f;v<=h;v++)d=e[2*v],_=e[2*v+1],d>=t&&d<=o&&_>=i&&_<=a&&c.push(s[v]);continue}const m=Math.floor((f+h)/2);d=e[2*m],_=e[2*m+1],d>=t&&d<=o&&_>=i&&_<=a&&c.push(s[m]);const p=(u+1)%2;(u===0?t<=d:i<=_)&&(l.push(f),l.push(m-1),l.push(p)),(u===0?o>=d:a>=_)&&(l.push(m+1),l.push(h),l.push(p))}return c}function $y(s,e,t,i,o,a){const r=[0,s.length-1,0],l=[],c=o*o;for(;r.length;){const d=r.pop(),_=r.pop(),u=r.pop();if(_-u<=a){for(let v=u;v<=_;v++)Nl(e[2*v],e[2*v+1],t,i)<=c&&l.push(s[v]);continue}const h=Math.floor((u+_)/2),f=e[2*h],m=e[2*h+1];Nl(f,m,t,i)<=c&&l.push(s[h]);const p=(d+1)%2;(d===0?t-o<=f:i-o<=m)&&(r.push(u),r.push(h-1),r.push(p)),(d===0?t+o>=f:i+o>=m)&&(r.push(h+1),r.push(_),r.push(p))}return l}function Nl(s,e,t,i){const o=s-t,a=e-i;return o*o+a*a}const Xy=s=>s[0],Ky=s=>s[1];class qy{constructor(e,t=Xy,i=Ky,o=64,a=Float64Array){this.nodeSize=o,this.points=e;const r=e.length<65536?Uint16Array:Uint32Array,l=this.ids=new r(e.length),c=this.coords=new a(e.length*2);for(let d=0;d<e.length;d++)l[d]=d,c[2*d]=t(e[d]),c[2*d+1]=i(e[d]);is(l,c,o,0,l.length-1,0)}range(e,t,i,o){return Wy(this.ids,this.coords,e,t,i,o,this.nodeSize)}within(e,t,i){return $y(this.ids,this.coords,e,t,i,this.nodeSize)}}function Yy(s,e,t){const i=[],o=[],a=[],r=n.create$1();return e.forEach(({mapCoords:l,weight:c})=>{Qy(r,l,t);const d=r[0],_=r[1];for(let u=0;u<6;u++)i.push(d,_),a.push(c);o.push(-1,-1,1,-1,-1,1,-1,1,1,-1,1,1)}),{vertices:s.createBuffer(new Uint16Array(i),{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:0,offset:0,normalized:!0}),widens:s.createBuffer(new Int8Array(o),{itemSize:2,dataType:n.Buffer.Byte,stride:0,offset:0,normalized:!1}),weights:s.createBuffer(new Float32Array(a),{itemSize:1,dataType:n.Buffer.Float,stride:0,offset:0,normalized:!1})}}function Qy(s,e,t){s[0]=(e[0]-t.offset[0])*n.maxUint16Value/t.size,s[1]=(e[1]-t.offset[1])*n.maxUint16Value/t.size}function Jy(s,e){const t=Ay(s),i=eb(t,e);return new g(new Uint8Array(i),{size:[e,1]})}function Ay(s){const e=new Error("The palette is not valid. The heatmap won't be rendered."),t=Object.getOwnPropertyNames(s);if(t.length===0)throw e;const i=t.map(l=>Number(l));if(i.some(l=>Number.isNaN(l)||l<0||l>1))throw e;const o={};i.forEach(l=>{if(typeof s[l]!="string")throw e;o[l]=n.handyColor(s[l])});const a=Math.min(...i),r=Math.max(...i);return a>0&&(o[0]=o[a]),r<1&&(o[1]=o[r]),o}function eb(s,e){const t=Object.keys(s).map(r=>Number(r)).sort((r,l)=>r-l);let i=0;const o=[],a=e-1;for(let r=0;r<e;r++){const l=r/a;l>t[i+1]&&i++;const c=t[i],d=t[i+1],_=d-c,h=(l-c)/_;for(let f=0;f<4;f++)o[r*4+f]=ib(s[c].value[f],s[d].value[f],h)}return o.map(r=>Math.round(r))}function tb(s,e){return s.every((t,i)=>t===e[i])}function ib(s,e,t){return s*(1-t)+e*t}const nb=256,ob=.5,sb=3,ab=10,rb=1,lb=1,cb={0:"rgba(89, 0, 89, 0)",.25:"rgba(0, 0, 89, 0.78)",.5:"rgba(0, 198, 68, 1)",.7:"rgba(198, 186, 0, 1)",.8:"rgba(249, 152, 0, 1)",1:"rgba(200, 0, 0, 1)"};class db extends Re{constructor(e,t={}){super(e,{interactive:!1}),this.offscreenTextureIndex=-1,this.fillBuffers=m=>{if(!this.tree)return;const p=n.tetragonBounds(this.mapState.tilesBounds),v=n.getBoundsTileCoords(p);if(this.tileCoords&&tb(v,this.tileCoords))return;this.resetBuffers(),this.tileCoords=v;const y=n.tileZoomToSize(v[2]),b=n.tileCoordsToMapPoint(v);n.fromTranslationScale(this.matrix,b,n.fromValues(y,y,n.tileHeight));const x=this.tree.range(b[0],b[1],b[0]+y,b[1]+y).map(w=>this.points[w]),T=n.createTileInfo(v);this.buffers=Yy(this.modules.renderer,x,T),this.vertexCount=x.length*6,this.vao=new k(m,{a_vec2_position:this.buffers.vertices,a_vec2_widen:this.buffers.widens,a_float_weight:this.buffers.weights})},this.resizeFrameBuffer=()=>{this.frameBuffer.setSize([Math.ceil(this.mapState.size[0]*window.devicePixelRatio/this.downscale),Math.ceil(this.mapState.size[1]*window.devicePixelRatio/this.downscale)]),this.modules.renderer.bindRenderTarget(this.frameBuffer),this.modules.renderer.bindRenderTarget(null);const m=this.frameBuffer.getTexture();m?this.modules.imageManager.updatePreparedTexture(this.offscreenTextureIndex,m):n.log("Can't update a non-prepared texture"),this.heatmapNeedRerender=!0,this.modules.renderer.addRerenderEvent()};const{downscale:i,palette:o,points:a,minZoom:r,maxZoom:l,zIndex:c,pointRadius:d,intensity:_,opacity:u}=t;this.rampTextureIndex=this.modules.imageManager.addPreparedTexture(Jy(o??cb,nb)),this.downscale=i??lb,this.frameBuffer=new pe({size:[Math.ceil(this.mapState.size[0]*window.devicePixelRatio/this.downscale),Math.ceil(this.mapState.size[1]*window.devicePixelRatio/this.downscale)],magFilter:g.LinearFilter,minFilter:g.LinearFilter,wrapS:g.ClampToEdgeWrapping,wrapT:g.ClampToEdgeWrapping});const h=this.frameBuffer.getTexture();h?this.offscreenTextureIndex=this.modules.imageManager.addPreparedTexture(h):n.log("Can't add a non-prepared texture."),this.points=[],this.vertexCount=0,this.isDestroyed=!1,this.heatmapNeedRerender=!1,this.matrix=n.create$2(),this.mvpMatrix=n.create$2(),this.viewDiffer=new n.Differ([{path:"center",type:"vec2"},{path:"zoom",type:"number"},{path:"rotation",type:"number"},{path:"pitch",type:"number"},{path:"padding",type:"padding"}]),this.sizeDiffer=new n.Differ([{path:"size",type:"vec2"}]),this.throttledFillBuffer=n.throttle(this.fillBuffers,50);const f=n.makeHandyStyleLayer({type:"heatmap",id:`dynamic-heatmap-${this.uniqId}`,minzoom:r,maxzoom:l,style:{opacity:u??ob,intensity:_??sb,radius:d??ab}});if(!f)throw new Error("There is no correct style layer for heatmap");this.layer=f,this.modules.dynamicStyle.addLayer(f,c),a&&this.setPoints(a)}isOutOfMainReplica(){return!1}setPoints(e){if(!this.isDestroyed){if(this.points=e.map(({coordinates:t,weight:i})=>({mapCoords:n.Mercator.fromGeo(t),weight:i??rb})),this.tree=new qy(this.points,t=>t.mapCoords[0],t=>t.mapCoords[1]),this.tileCoords=void 0,!this.tileObjects.length){const{layers:t,collector:i,dynamicStyle:o,tileManager:a}=this.modules;n.generateSafely({collector:i,generator:n.HeatmapGenerator.generateTexture,args:[o.getStyle().id,this.layer,this.offscreenTextureIndex,this.rampTextureIndex]});const r=i.getAccumulatedData(),l=new n.TileObject("dynamicObject",r.data,this.modules,this.mapState);a.addObject(l),this.tileObjects.push(l),t.addLayer(this),i.reset()}this.modules.renderer.addRerenderEvent(),this.heatmapNeedRerender=!0}}update(){super.update();const e=this.modules.renderer.getShaderProgram("heatmap",this.modules.renderer.commonShaderDefines);if(this.sizeDiffer.check(this.mapState)&&this.resizeFrameBuffer(),!this.heatmapNeedRerender&&!this.viewDiffer.check(this.mapState)&&!this.modules.renderer.isNeedRerender()||!this.tree)return;const{zoom:t,styleZoom:i,styleState:o}=this.mapState;if(this.throttledFillBuffer(e),!this.vao||!this.buffers||!this.tree||!this.tileCoords)return;const a=n.makeBinderContext(i,o,[]),r=n.resolveNumber(this.layer.style.radius,a),l=n.resolveNumber(this.layer.style.intensity,a),c=n.tileSizeZpt*Math.pow(2,t-this.tileCoords[2])*window.devicePixelRatio;this.modules.renderer.enableShaderProgram(e),this.modules.renderer.isUboSupported()||Ps(e,this.mapState,this.modules),this.modules.renderer.bindShaderProgram(e,{u_mat4_mvp:n.mul$1(this.mvpMatrix,this.modules.camera.viewProjectionMatrix,this.matrix),u_mat4_model:this.matrix,u_float_radius:r*window.devicePixelRatio,u_float_intensity:l,u_float_tile_to_pixel_ratio:1/c}),this.modules.renderer.bindVao(this.vao),this.modules.renderer.setViewport(0,0,Math.ceil(this.mapState.size[0]*window.devicePixelRatio/this.downscale),Math.ceil(this.mapState.size[1]*window.devicePixelRatio/this.downscale)),this.modules.renderer.bindRenderTarget(this.frameBuffer),this.modules.renderer.clearWithColor([0,0,0,0],!1),this.modules.renderer.applyGpuState(sa),this.modules.renderer.drawTriangles(0,this.vertexCount),this.modules.renderer.bindRenderTarget(null),this.heatmapNeedRerender=!1}destroy(){if(this.isDestroyed)return;super.destroy(),this.points=[],this.tree=void 0,this.isDestroyed=!0,this.resetBuffers(),this.layer&&this.modules.dynamicStyle.removeLayer(this.layer.innerId),this.frameBuffer.remove();const{imageManager:e}=this.modules;e.deleteTexture(this.offscreenTextureIndex),e.deleteTexture(this.rampTextureIndex)}resetBuffers(){this.buffers&&(Object.values(this.buffers).forEach(e=>e.remove()),this.buffers=void 0),this.vao&&(this.vao.remove(),this.vao=void 0)}}const _b="#000000",ub=0,hb="#ffffff",fb=0,kl=[0,0],mb=0,pb=[0,0,0,0],os=-1;class ss extends Re{constructor(e,t,i){super(e,{interactive:t.interactive??!1},i),this.hovered=!1,this.lastLabelingRevision=os,this.status="visible",this.labelingStatus=0,this.options=t,this.labelKey=`point-label-${this.uniqId}`;const o=t.font??n.DEFAULT_FONT,a=t.fontSize??n.fonts.baseSize,r=t.letterSpacing??fb,l=t.lineHeight??n.fonts.baseLineHeight,c=[this.options.offset?.[0]??kl[0],this.options.offset?.[1]??kl[1]],d=n.makeHandyStyleLayer({type:"point",id:`dynamic-pointLabel-${this.uniqId}`,minzoom:this.options.minZoom,maxzoom:this.options.maxZoom,interactive:this.interactive,style:{textFont:o,textFontSize:a,textColor:t.color??_b,textHaloWidth:t.haloRadius??ub,textHaloColor:t.haloColor??hb,textLetterSpacing:r,textLineHeight:l,textOffset:c,allowElevation:!0}}),_=n.Mercator.fromGeo(this.options.coordinates);if(this.position={userValue:_,normalizedValue:n.normalizeMapPoint(_)},!d)return;const{dynamicStyle:u,collector:h,assetManager:f,styleManager:m,tileManager:p,layers:v,defaultSource:y}=this.modules,b=this.options.zIndex??mb;u.addLayer(d,b);const x=n.optionsToTileAttrs({db_label:this.options.text}),T=n.mapPointTo32ZoomTileCoords(this.position.normalizedValue),w={x:[0],y:[0]},M=n.makeGeneratorContext(this.mapState.styleState,n.emptySourceAttrs,n.fixedMetatile.tileProps,x,n.emptyFeatureAttrs,this.interactive?"0":"");n.runPrecomputes(d,M),n.generateSafely({collector:h,generator:n.preLabelingPoint,args:[u.getStyle(),d,M,n.fixedMetatile,n.LATEST_TILE_VERSION,T,y.getId(),w,n.pixelRatioToDpi(window.devicePixelRatio)]});const z=h.getAccumulatedData();if(!z.labels.length)return;const S=[{metatileHash:-1,labels:z.labels,styleId:u.getStyle().id}],I=n.unpackPreLabelingResult(S,n.LabelSource.DynamicObject,m,this.mapState.styleState,this.mapState.styleZoom);if(I.length!==1)return;const R=I[0];n.rtlAdapterPromise.then(()=>{R.label=n.processRTLTextIfNeeded(R.label)??"",R.updateRanges()}).then(()=>Promise.all(R.ranges.map(C=>f.loadFont(o,C)))).then(()=>{if(this.status==="destroyed")return;R.textMetrics=n.getTextMetrics(R.label,r,f.getFontGlyphs(o));const C=vb(t.anchor),j=a/n.fonts.baseSize,H=a*l*R.textMetrics.lines.length,K=j*R.textMetrics.maxWidth,Y=[-K*(C[0]-.5),-H*(C[1]-.5)],[Ye,Oe]=c,Ne=[Ye+Y[0],Oe+Y[1]],ge=n.Mercator.toGeo(this.position.userValue),qt=n.Ecef.fromGeo(ge);n.generateSafely({collector:h,generator:n.generateTextElement,args:[R,"",1,R.textMetrics,[0,0,0],qt,0,Ne,d,u.getStyle().fontNameToIndex[o],window.devicePixelRatio]});const Yt=h.getAccumulatedData(),gt=new n.TileObject("dynamicObject",Yt.data,this.modules,this.mapState,n.mapPointTo32ZoomTileCoords(this.position.normalizedValue),this);as(gt,this.position.userValue[2]),v.addLayer(this),this.tileObjects.push(gt),this.interactive&&(this.identifyIds.push(z.identifyIds),this.modules.identifier.resetCache()),h.reset(),this.options.labeling&&this.options.labeling.type!=="none"?(this.labelBox={id:this.uniqId,width:K,height:H,position:this.position.normalizedValue,offset:[Ne[0]-C[0]*K,Ne[1]-C[1]*H],labelingGroup:"pointLabel"},this.addLabelToLabeler(),this.update()):this.status==="visible"&&p.addObject(gt),this.modules.renderer.addRerenderEvent(),this.initImageIfNeed(R,K,H,c,Y)})}hide(){this.status==="visible"&&(this.status="hidden",this.removeLabelFromLabeler(),this.removeTilesFromMap(),this.labelingStatus=1)}show(){this.status==="hidden"&&(this.status="visible",this.labelBox||this.addTilesToMap(),this.labelingStatus=0,this.addLabelToLabeler(),this.update())}isOutOfMainReplica(){return!1}remove(){this.status!=="destroyed"&&(this.interactive&&this.modules.identifier.resetCache(),this.removeLabelFromLabeler(),super.destroy(),this.status="destroyed")}setCoordinates(e){if(this.status==="destroyed")return;const t=n.Mercator.fromGeo(e);this.position={userValue:t,normalizedValue:n.normalizeMapPoint(t)},this.tileObjects.forEach(i=>{i.setTileCoords(n.mapPointTo32ZoomTileCoords(this.position.normalizedValue),this.mapState),as(i,this.position.userValue[2])}),this.labelBox&&(this.labelBox.position=this.position.normalizedValue,this.addLabelToLabeler()),this.tileObjects.length!==0&&this.status==="visible"&&this.modules.renderer.addRerenderEvent()}getCoordinates(){return n.Mercator.toGeo(this.position.userValue)}update(){if(this.status==="destroyed"||(super.update(),this.status!=="visible"||!this.labelBox||this.lastLabelingRevision===this.modules.labeler.getLabelingRevision()))return;this.lastLabelingRevision=this.modules.labeler.getLabelingRevision();const e=this.modules.labeler.isLabelBoxSurvived(this.uniqId),t=this.labelingStatus;let i=n.LabelingAnimation.none;switch(this.labelingStatus){case 0:e?(this.addTilesToMap(),i=n.LabelingAnimation.none,this.labelingStatus=3):this.labelingStatus=1;break;case 1:e&&(this.addTilesToMap(),i=n.LabelingAnimation.fadeIn,this.labelingStatus=2);break;case 2:e?this.labelingStatus=3:(this.labelingStatus=4,i=n.LabelingAnimation.fadeOut);break;case 3:e||(i=n.LabelingAnimation.fadeOut,this.labelingStatus=4);break;case 4:e?(i=n.LabelingAnimation.fadeIn,this.labelingStatus=2):(this.removeTilesFromMap(),this.labelingStatus=1);break}t!==this.labelingStatus&&this.labelingStatus!==1&&this.tileObjects.forEach(o=>o.children.forEach(a=>{a.attributes.animDirection=i}))}async initImageIfNeed(e,t,i,o,a){if(!this.options.image)return;const{imageCache:r,dynamicStyle:l,collector:c,tileManager:d}=this.modules,_=window.devicePixelRatio,u=await r.getRasterSet(this.options.image.url,void 0,this.options.image.size,[0,0]);if(!u||this.status==="destroyed")return;const h=u.rasters[0];l.appendRasterSet(u,n.getStaticIconRasterSetKey(this.options.image.url,0,0));const[f,m,p,v]=this.options.image.padding||pb,y=(t+v+m)*_,b=(i+f+p)*_,x=((m-v)/2+o[0]+a[0])*_,T=((p-f)/2+o[1]+a[1])*_,w=this.options.image.stretchX?.map(([C,j])=>[C*_,j*_]),M=this.options.image.stretchY?.map(([C,j])=>[C*_,j*_]),z=n.Mercator.toGeo(this.position.userValue),S=n.Ecef.fromGeo(z);n.generateSafely({collector:c,generator:n.generateIconElement,args:[e,"",[0,0,0],S,0,h,y,b,x,T,window.devicePixelRatio,w,M]});const I=c.getAccumulatedData();c.reset();const R=new n.TileObject("dynamicObject",I.data,this.modules,this.mapState,n.mapPointTo32ZoomTileCoords(this.position.normalizedValue));as(R,this.position.userValue[2]),this.tileObjects.push(R),this.status!=="hidden"&&!this.labelBox&&d.addObject(R),this.labelBox&&(this.labelBox.height=i+f+p,this.labelBox.width=t+v+m,this.labelBox.offset[0]-=v,this.labelBox.offset[1]-=f,this.addLabelToLabeler(),this.labelingStatus!==1&&this.labelingStatus!==0&&(d.addObject(R),this.mapState.needRerender=!0),this.lastLabelingRevision=os)}addTilesToMap(){this.tileObjects.forEach(e=>{this.modules.tileManager.addObject(e)})}removeTilesFromMap(){this.tileObjects.forEach(e=>{this.modules.tileManager.removeObject(e)})}addLabelToLabeler(){this.removeLabelFromLabeler(),this.labelBox&&(this.modules.labeler.addLabelBox(this.labelKey,this.labelBox),this.lastLabelingRevision=os)}removeLabelFromLabeler(){this.labelBox&&this.modules.labeler.removeLabels(this.labelKey)}}function vb(s){return[s&&s[0]!==void 0?n.clamp(s[0],0,1):.5,s&&s[1]!==void 0?n.clamp(s[1],0,1):.5]}function as(s,e){s.modelMatrices.forEach(t=>{t[14]=e})}const gb=18,yb=[.5,.5],bb=[0,18],xb=0,wb=0;let Ul=class extends ps{constructor(e,t){super(e,t,t.draggable),this.visible=!0,this.map=e,this.options=t;const{coordinates:i,size:o,zIndex:a,minZoom:r,maxZoom:l,hoverIcon:c,hoverSize:d,hoverAnchor:_,label:u,rotation:h,opacity:f,hoverOpacity:m}=t;this.status="normal";const p=n.Mercator.fromGeo(i);this.position={userValue:p,normalizedValue:n.normalizeMapPoint(p)},this.rotation=n.degToRad(h??wb),this.zIndex=a!==void 0?a:xb,this.minZoom=r??-1/0,this.maxZoom=l??1/0;const v=t.icon!==void 0?t.icon:n.defaultMarkerIcon,y=t.icon!==void 0?t.anchor:n.defaultMarkerAnchor;this.on("mouseover",this.switchToHoveredStyle),this.on("mouseout",this.switchToNormalStyle),this.modules.layers.addLayer(this),this.setIconInternal({icon:v,anchor:y,size:o,opacity:f}).then(()=>{c!==void 0&&this.setHoverIconInternal({icon:c,anchor:_,size:d,opacity:m})}),this.setLabel(u)}destroy(){this.status!=="destroyed"&&(this.status="destroyed",this.label?.remove(),this.interactive&&this.modules.identifier.resetCache(),this.off("mouseover",this.switchToHoveredStyle),this.off("mouseout",this.switchToNormalStyle),super.destroy())}update(){if(this.mapState.dpiChanged){const{icon:e,hoverIcon:t}=this.options;e&&this.setIconInternal({icon:e,...this.options}),e&&t&&this.setHoverIconInternal({icon:e,hoverIcon:t,...this.options})}if(this.mapState.globeMode){const{tileManager:e}=this.modules,t=this.modules.camera.ecef.canSee(this.options.coordinates);this.visible&&!t?this.tileObjects.forEach(i=>e.removeObject(i)):!this.visible&&t&&this.tileObjects.forEach(i=>e.addObject(i)),this.visible=t}}isOutOfMainReplica(){return!1}setRotation(e){if(this.status==="destroyed")return;const t=n.degToRad(e);t!==this.rotation&&(this.rotation=t,this.normalStateData&&(this.normalStateData.styleLayer.style.iconRotation=this.rotation,this.modules.renderer.addRerenderEvent()),this.hoverStateData&&(this.hoverStateData.styleLayer.style.iconRotation=this.rotation,this.modules.renderer.addRerenderEvent()))}getRotation(){return n.radToDeg(this.rotation)}setIcon(e){this.status!=="destroyed"&&(Gl({icon:this.options.icon,anchor:this.options.anchor,size:this.options.size,opacity:this.options.opacity},e)||(this.options.icon=e.icon,this.options.anchor=e.anchor,this.options.size=e.size,this.options.opacity=e.opacity,this.setIconInternal(e)))}setHoverIcon(e){if(this.status!=="destroyed"){if(!e){this.status==="hover"&&this.switchToNormalStyle(),this.hoverStateData&&(n.excludeItemFromArray(this.tileObjects,this.hoverStateData.tileObject),n.excludeItemFromArray(this.identifyIds,this.hoverStateData.identifyIds),this.hoverStateData.tileObject.clean(this.mapState),this.hoverStateData=void 0);return}Gl({icon:this.options.hoverIcon,anchor:this.options.hoverAnchor,size:this.options.hoverSize,opacity:this.options.hoverOpacity},e)||(this.options.hoverIcon=e.icon,this.options.hoverAnchor=e.anchor,this.options.hoverSize=e.size,this.options.hoverOpacity=e.opacity,this.setHoverIconInternal(e))}}setLabel(e){this.status!=="destroyed"&&(this.label?.remove(),e&&(this.label=new ss(this.map,{coordinates:this.getCoordinates(),...e,minZoom:Math.max(e.minZoom??this.minZoom,this.minZoom),maxZoom:Math.min(e.maxZoom??this.maxZoom,this.maxZoom),fontSize:e.fontSize??gb,anchor:e.anchor||yb,offset:e.offset||bb,zIndex:e.zIndex??this.zIndex+1e-5,interactive:this.interactive},this)))}setCoordinates(e){this.setPosition(n.Mercator.fromGeo(e)),this.label?.setCoordinates(e)}getCoordinates(){return n.Mercator.toGeo(this.getPosition())}show(){this.status==="hidden"&&(this.label?.show(),this.normalStateData&&(this.modules.tileManager.addObject(this.normalStateData.tileObject),this.modules.renderer.addRerenderEvent(),this.interactive&&this.modules.identifier.resetCache()),this.status="normal")}hide(){if(this.status==="destroyed"||this.status==="hidden")return;this.label?.hide();const e=this.status==="normal"?this.normalStateData?.tileObject:this.hoverStateData?.tileObject;e&&(this.modules.tileManager.removeObject(e),this.modules.renderer.addRerenderEvent(),this.interactive&&this.modules.identifier.resetCache()),this.status="hidden"}setPosition(e){this.position={userValue:e,normalizedValue:n.normalizeMapPoint(e)},this.tileObjects.length&&(this.tileObjects.forEach(t=>{t.setTileCoords(n.mapPointTo32ZoomTileCoords(this.position.normalizedValue),this.mapState)}),this.status!=="hidden"&&(this.modules.renderer.addRerenderEvent(),this.interactive&&this.modules.identifier.resetCache()))}getPosition(){return this.position.userValue}contains(e){if(!this.normalStateData)return!1;const{hoverStateData:t,normalStateData:i}=this,o=t!==void 0?t.size:i.size,a=t!==void 0?t.anchor:i.anchor,r=this.modules.camera.flat.project(this.position.normalizedValue),l=r[0]-o[0]*a[0],c=r[0]+o[0]*(1-a[0]),d=r[1]-o[1]*a[1],_=r[1]+o[1]*(1-a[1]);return e[0]>l&&e[0]<c&&e[1]>d&&e[1]<_}switchToHoveredStyle(){if(this.status==="normal"&&this.hoverStateData&&this.normalStateData){const{tileManager:e}=this.modules;e.removeObject(this.normalStateData.tileObject),e.addObject(this.hoverStateData.tileObject),this.status="hover",this.modules.renderer.addRerenderEvent()}this.label&&(this.label.hovered=!0,this.modules.renderer.addRerenderEvent())}switchToNormalStyle(){if(this.status==="hover"&&this.normalStateData&&this.hoverStateData){const{tileManager:e}=this.modules;e.removeObject(this.hoverStateData.tileObject),e.addObject(this.normalStateData.tileObject),this.status="normal",this.modules.renderer.addRerenderEvent()}this.label&&(this.label.hovered=!1,this.modules.renderer.addRerenderEvent())}getMarkerStateData(e,{icon:t,anchor:i,size:o,opacity:a}){const{zIndex:r,position:l}=this,{collector:c,dynamicStyle:d,styleManager:_,defaultSource:u}=this.modules,h=n.optionsToTileAttrs({dpi:window.devicePixelRatio*96}),f=n.mapPointTo32ZoomTileCoords(l.normalizedValue),m=typeof this.position.userValue[2]=="number"?this.position.userValue[2]:0,p=n.makeHandyStyleLayer({type:"point",id:`dynamic-marker-${this.uniqId}`,minzoom:this.minZoom,maxzoom:this.maxZoom,style:{iconImage:t,iconAnchor:i,iconRotation:this.rotation,iconOpacity:a,elevation:m}});if(!p)throw new Error(`Marker with icon ${t} was created with null style layer`);const v=n.resolveSimpleLiteralExpression(p.style.iconAnchor);d.addLayer(p,r),d.appendRasterSet(e,n.getStaticIconRasterSetKey(t,v[0],v[1]));const y=n.makeGeneratorContext(this.mapState.styleState,n.emptySourceAttrs,n.fixedMetatile.tileProps,h,n.emptyFeatureAttrs,this.interactive?"0":"");n.runPrecomputes(p,y),n.generateSafely({collector:c,generator:n.preLabelingPoint,args:[d.getStyle(),p,y,n.fixedMetatile,n.LATEST_TILE_VERSION,f,u.getId(),{x:[0],y:[0]},n.pixelRatioToDpi(window.devicePixelRatio)]});const{identifyIds:b,labels:x}=c.getAccumulatedData();if(!x.length)throw new Error(`Marker with icon ${t} was created with empty labels`);const T=[{metatileHash:-1,labels:x,styleId:d.getStyle().id}],w=n.unpackPreLabelingResult(T,n.LabelSource.DynamicObject,_,this.mapState.styleState,this.mapState.styleZoom);if(w.length!==1)throw new Error(`Marker with icon ${t} has empty unpacked labels`);const M=w[0],z=n.Mercator.toGeo(this.position.userValue),S=n.Ecef.fromGeo(z);n.generateNotStretchableIconElement(c,M,"",[0,0,m],S,0,e.rasters[0],window.devicePixelRatio);const{data:I}=c.getAccumulatedData();c.reset();const R=new n.TileObject("dynamicObject",I,this.modules,this.mapState,f,this);return{styleLayer:p,tileObject:R,identifyIds:b,icon:t,anchor:[e.rasters[0].anchorX,e.rasters[0].anchorY],size:o||[e.rasters[0].w/window.devicePixelRatio,e.rasters[0].h/window.devicePixelRatio]}}async setIconInternal(e){return this.modules.imageCache.getRasterSet(e.icon,void 0,e.size,e.anchor).then(t=>{if(this.status==="destroyed"||!t)return;const i=this.normalStateData,o=this.getMarkerStateData(t,e);this.status==="normal"&&(i&&this.modules.tileManager.removeObject(i.tileObject),this.modules.tileManager.addObject(o.tileObject),this.modules.renderer.addRerenderEvent(),this.interactive&&this.modules.identifier.resetCache()),i&&(n.excludeItemFromArray(this.tileObjects,i.tileObject),n.excludeItemFromArray(this.identifyIds,i.identifyIds),i.tileObject.clean(this.mapState)),this.tileObjects.push(o.tileObject),this.interactive&&this.identifyIds.push(o.identifyIds),this.normalStateData=o})}async setHoverIconInternal(e){return this.modules.imageCache.getRasterSet(e.icon,void 0,e.size,e.anchor).then(t=>{if(this.status==="destroyed"||!t)return;const i=this.hoverStateData,o=this.getMarkerStateData(t,e);this.status==="hover"&&(i&&this.modules.tileManager.removeObject(i.tileObject),this.modules.tileManager.addObject(o.tileObject),this.modules.renderer.addRerenderEvent(),this.interactive&&this.modules.identifier.resetCache()),i&&(n.excludeItemFromArray(this.tileObjects,i.tileObject),n.excludeItemFromArray(this.identifyIds,i.identifyIds),i.tileObject.clean(this.mapState)),this.tileObjects.push(o.tileObject),this.interactive&&this.identifyIds.push(o.identifyIds),this.hoverStateData=o})}};function Gl(s,e){return!(s.icon!==e.icon||s.anchor?.[0]!==e.anchor?.[0]||s.anchor?.[1]!==e.anchor?.[1]||s.size?.[0]!==e.size?.[0]||s.size?.[1]!==e.size?.[1]||s.opacity?.toString()!==e.opacity?.toString())}const Sb=n.inferGeneratorType({symbol:"polygon",sinks:{fill:{stride:8,binder:(s,e)=>{s.views.position=new Uint16Array(e),s.views.localID=new Uint32Array(e,4)},packObjectAttributes(s,e,t){return n.createObjectAttributesArray([s,e.innerId],e,t)},unpackObjectAttributes(s){return{styleId:s[0],layerId:s[1],tileData:s.slice(2)}}}},generate(s,e,t,i,o){const a=o.x,r=o.y,l=s.idIndexer.getIndex(i,e,t),c=n.resolveExpression(t.ignoreTier,i)?null:i.tileAttrs[i.tileProps.db_tiers],d=s.getBucket(t.type,"fill",n.PolygonGenerator.sinks.fill.packObjectAttributes(e,t,c,"","",i),n.PolygonGenerator.sinks.fill.binder);let _=d.elements.offset;Tb(d.indices,_,0,1,2,2,1,3),Mn(d,_++,a[0],r[0],l),Mn(d,_++,a[1],r[1],l),Mn(d,_++,a[2],r[2],l),Mn(d,_++,a[3],r[3],l),d.elements.offset=_}});function Mn(s,e,t,i,o){const a=e*4;s.views.position[a]=n.tileCoordOffset+t,s.views.position[a+1]=n.tileCoordOffset+i;const r=e*2;s.views.localID[r]=o}function Tb(s,e,t,i,o,a,r,l){const c=s.buffer,d=s.offset;c[d]=e+t,c[d+1]=e+i,c[d+2]=e+o,c[d+3]=e+a,c[d+4]=e+r,c[d+5]=e+l,s.offset=d+6}const Mb="#0085a0";class Eb extends Re{constructor(e,t){super(e,t),this.isGeometryOutOfMainReplica=!1;const{dynamicStyle:i,collector:o,tileManager:a,identifier:r,layers:l}=this.modules;this.options=t,this.points=[];const c=n.makeHandyStyleLayer({type:"polygon",id:`dynamic-polygon-${this.uniqId}`,minzoom:this.options.minZoom,maxzoom:this.options.maxZoom,style:{color:this.options.color||Mb}});if(!c)return;i.addLayer(c,this.options.zIndex),this.layerId=c.innerId;const d=n.optionsToTileAttrs({db_tiers:t.tiers});this.points=Ib(n.Mercator.fromGeo(this.options.center),n.geoToMapDistance(this.options.center,this.options.width),n.geoToMapDistance(this.options.center,this.options.height)),this.isGeometryOutOfMainReplica=this.points.some(x=>x[0]>n.HALF_WORLD_SIZE||x[0]<-n.HALF_WORLD_SIZE);const _=n.create();for(let x=0;x<this.points.length;x++)n.expandByPoint(_,this.points[x]);const u=n.getBoundsTileCoords(_),h=n.createTileInfo(u),f=[],m=[],p=n.create$1();for(let x=0;x<this.points.length;x++)n.mapPointToTilePoint(p,this.points[x],h),f[x]=p[0],m[x]=p[1];const v=n.makeGeneratorContext(this.mapState.styleState,n.emptySourceAttrs,n.fixedTileProps,d,n.emptyFeatureAttrs,this.options.interactive?"0":"");n.generateSafely({collector:o,generator:Sb.generate,args:[i.getStyle().id,c,v,{x:f,y:m}]});const y=o.getAccumulatedData(),b=new n.TileObject("dynamicObject",y.data,this.modules,this.mapState,u,this);a.addObject(b),this.tileObjects.push(b),this.options.interactive&&this.identifyIds.push(y.identifyIds),l.addLayer(this),o.reset(),this.modules.renderer.addRerenderEvent(),this.options.interactive&&r.resetCache()}destroy(){this.layerId!==void 0&&this.modules.dynamicStyle.removeLayer(this.layerId),this.options.interactive&&this.modules&&this.modules.identifier.resetCache(),super.destroy()}isOutOfMainReplica(){return this.isGeometryOutOfMainReplica}}function Ib(s,e,t){const i=e/2,o=t/2,a=s[0],r=s[1],l=s[2];return[[a-i,r-o,l],[a+i,r-o,l],[a-i,r+o,l],[a+i,r+o,l]]}let Hl=class extends Re{constructor(e,t){super(e,{interactive:!1}),this.isGeometryOutOfMainReplica=!1;const{dynamicStyle:i}=this.modules;this.options={...t,image:{url:t.image.url}},this.points=[],this.styleLayer=n.makeHandyStyleLayer({type:"raster",id:`dynamic-raster-${this.uniqId}`,minzoom:this.options.minZoom,maxzoom:this.options.maxZoom,style:{opacity:this.options.opacity}}),this.styleLayer&&(i.addLayer(this.styleLayer,this.options.zIndex),this.layerId=this.styleLayer.innerId,this.modules.imageManager.loadTexture(this.options.image.url,{skipAtlasSizeChecking:!0}).then(o=>{this.textureIndex=o,this.generate()}))}destroy(){this.layerId!==void 0&&this.modules.dynamicStyle.removeLayer(this.layerId),super.destroy()}updateImage(e){const{url:t,bounds:i}=e;return!t&&!i?Promise.resolve():(t&&(this.options.image.url=t),i&&(this.options.bounds=i),(t?this.modules.imageManager.loadTexture(t,{skipAtlasSizeChecking:!0}):Promise.resolve(this.textureIndex)).then(a=>{this.textureIndex=a,this.clean(),this.generate()}))}isOutOfMainReplica(){return this.isGeometryOutOfMainReplica}generate(){if(!this.styleLayer||this.textureIndex===void 0)return;const{collector:e,dynamicStyle:t,tileManager:i,layers:o}=this.modules;this.points=Cb(this.options.bounds),this.isGeometryOutOfMainReplica=this.points.some(m=>m[0]>n.HALF_WORLD_SIZE||m[0]<-n.HALF_WORLD_SIZE);const a=n.create();for(let m=0;m<this.points.length;m++)n.expandByPoint(a,this.points[m]);const r=n.getBoundsTileCoords(a),l=n.createTileInfo(r),c=[],d=[],_=n.create$1();for(let m=0;m<this.points.length;m++)n.mapPointToTilePoint(_,this.points[m],l),c[m]=_[0],d[m]=_[1];const u=n.makeGeneratorContext(this.mapState.styleState,{},n.fixedTileProps,[],n.emptyFeatureAttrs);n.generateSafely({collector:e,generator:n.RasterGenerator.generate,args:[{x:c,y:d},t.getStyle().id,u,this.styleLayer,this.textureIndex,this.options.tiers??null]});const h=e.getAccumulatedData(),f=new n.TileObject("dynamicObject",h.data,this.modules,this.mapState,r,this);i.addObject(f),this.tileObjects.push(f),o.addLayer(this),e.reset(),this.modules.renderer.addRerenderEvent()}clean(){const e=this.tileObjects[0];e&&(e.clean(this.mapState),this.modules.tileManager.removeObject(e),this.modules.layers.removeLayer(this),this.tileObjects=[])}};function Cb(s){const{min:e,max:t}=n.fromGeo(s);return[e,[t[0],e[1]],[e[0],t[1]],t]}class Lb{constructor(e,t,i){this.id=e,this.modules=t,this.options=i,this.type="raster",this.textureIndices={},this.tileLoader=new n.BaseTileLoader("arrayBuffer"),this.attributes={},this.tiles=new Map,this.sourceAttrs=i.attributes||{},this.url=o=>{const[a,r,l]=n.tileCoordsToOSM(o),{min:c,max:d}=n.getTileBounds(o),_={southWest:[c[0],c[1]].map(u=>u/n.WEB_MERCATOR_TO_WORLD_SIZE_MULTIPLIER),northEast:[d[0],d[1]].map(u=>u/n.WEB_MERCATOR_TO_WORLD_SIZE_MULTIPLIER)};return this.options.url(a,r,l,_)}}deleteTextures(){for(const e in this.textureIndices)this.modules.imageManager.deleteTexture(this.textureIndices[e]);this.textureIndices={}}abortTileFetches(e){this.tileLoader.abortRequests(e.map(n.coordsToKey))}deleteTiles(e){for(const t of e){const i=n.coordsToKey(t),o=this.textureIndices[i];isNaN(o)||this.modules.imageManager.deleteTexture(o),this.tiles.delete(i)}}fetchTiles(e){return e.map(t=>this.fetchTile(t))}fetchTile(e){const t=n.coordsToKey(e),i=this.url(e);return this.tileLoader.fetch(e,()=>i).then(o=>{if(o.error){const r=this.modules.sourceStorage.getSourceById(this.id);r?.type==="raster"&&this.modules.map.emit("error",{type:"rasterTileLoadError",tileCoords:n.tileCoordsToOSM(e),tileUrl:i,source:r,responseMessage:o.error.message,responseStatus:o.error.status})}return o.rejected||this.tiles.set(t,o.data),[{regionId:0,metatileHash:-1}]})}async generateTile(e,t){const i=[],o=[],a=this.modules.styleManager.getStyle(e.handyStyleId),r=n.coordsToKey(t),l=this.tiles.get(r);if(!l||!a)return Promise.resolve({results:i,transferable:o});const c=await this.modules.imageManager.addTexture(l,{imagePadding:0,size:[n.tileSizeZpt,n.tileSizeZpt]});if(c===void 0)return Promise.resolve({results:i,transferable:o});this.textureIndices[r]=c;const d=[],_=[],u=n.create$1(),h=Pb(n.tileCoordsToMapPoint(t),n.tileZoomToSize(t[2])),f=n.createTileInfo(t);for(let v=0;v<h.length;v++)n.mapPointToTilePoint(u,h[v],f),d[v]=u[0],_[v]=u[1];const m=n.makeGeneratorContext(e.styleState,this.sourceAttrs,n.fixedTileProps,[],n.emptyFeatureAttrs);a.layers.filter(v=>v.type==="raster"&&n.resolveExpression(v.filter,m)).forEach(v=>{n.runPrecomputes(v,m),n.generateSafely({collector:this.modules.collector,generator:n.RasterGenerator.generate,args:[{x:d,y:_},a.id,m,v,c,null]})});const p=this.modules.collector.getAccumulatedData();return i.push({regionId:0,metatileHash:0,styleId:a.id,collectorOutput:p}),o.push(...p.transferable),this.modules.collector.reset(),Promise.resolve({results:i,transferable:o})}getAttributes(){return this.attributes}setAttributes(e){this.attributes=e}destroy(){this.tileLoader.destroy()}}function Pb(s,e){const t=s[0],i=s[1],o=s[2];return[[t,i,o],[t+e,i,o],[t,i+e,o],[t+e,i+e,o]]}let Vl=class{constructor(e,t,i){this.type="raster",this.id=n.sourceUuid(),this.modules=e.modules,this.source=new Lb(this.id,this.modules,t);const o=t.minZoom??n.MAP_DEFAULTS.minZoom,a=t.maxZoom??n.MAP_DEFAULTS.maxZoom;this.layer=new n.TileLayer(o,a,o,a,this.modules,e.state,this.source),this.modules.tileManager.addTileLayer(this.layer),this.modules.sourceStorage.addSource(this),this.mapglApiSource=i}destroy(){this.source.deleteTextures(),this.modules.tileManager.removeTileLayer(this.layer),this.modules.sourceStorage.removeSource(this.getId()),this.layer.destroy()}getAttributes(){return this.source.getAttributes()}getZoomDirection(){return this.layer.getZoomDirection()}getId(){return this.source.id}setAttributes(e){this.source.setAttributes(e),this.layer.redraw()}isIdentifiedAsDefault(){return!1}};const Bb=0;class zb extends Re{constructor(e,t){super(e,t),this.options=t,this.visible=!0;const i=n.Mercator.fromGeo(t.coordinates);this.position={userValue:i,normalizedValue:n.normalizeMapPoint(i)},this.zIndex=t.zIndex??Bb,this.isDestroyed=!1,this.labelKey=`onlineMarker-${this.uniqId}`;const o=this.options.floorId?e.modules.floorManager.getFloorObjectElevation(this.options.floorId,!0):0,a=t.elevation?t.elevation*n.Mercator.scaleFactor(t.coordinates[1])*n.MAP_POINTS_IN_METER:0;this.elevation=a+o,this.actualIcon=t.icon,this.setIcon(t.icon)}destroy(){this.isDestroyed=!0,this.modules.identifier.resetCache(),this.modules.labeler.removeLabels(this.labelKey),super.destroy()}isOutOfMainReplica(){return!1}setIcon(e){this.actualIcon=e;const{url:t,transformer:i,size:o,anchor:a}=e;this.modules.imageCache.getRasterSet(t,i,o,a).then(r=>{if(this.isDestroyed||!r||this.actualIcon!==e)return;this.removeIcon();const l=n.makeHandyStyleLayer({type:"point",id:`dynamic-onlineMarker-${this.uniqId}`,minzoom:-1/0,maxzoom:1/0,style:{iconImage:t,iconAnchor:a}}),c=n.optionsToTileAttrs({}),{collector:d,dynamicStyle:_,styleManager:u,defaultSource:h}=this.modules,f=this.zIndex;if(!l)return;const m=n.resolveSimpleLiteralExpression(l.style.iconAnchor);_.addLayer(l,f),_.appendRasterSet(r,n.getStaticIconRasterSetKey(t,m[0],m[1]));const p=n.mapPointTo32ZoomTileCoords(this.position.normalizedValue),v={x:[0],y:[0]},y=n.makeGeneratorContext(this.mapState.styleState,n.emptySourceAttrs,n.fixedMetatile.tileProps,c,n.emptyFeatureAttrs,this.interactive?"0":"");n.runPrecomputes(l,y),n.generateSafely({collector:d,generator:n.preLabelingPoint,args:[_.getStyle(),l,y,n.fixedMetatile,n.LATEST_TILE_VERSION,p,h.getId(),v,n.pixelRatioToDpi(window.devicePixelRatio)]});const b=d.getAccumulatedData(),{identifyIds:x,labels:T}=b;if(!T.length)return;const w=[{metatileHash:-1,labels:T,styleId:_.getStyle().id}],M=n.unpackPreLabelingResult(w,n.LabelSource.DynamicObject,u,this.mapState.styleState,this.mapState.styleZoom);if(M.length!==1)return;const z=M[0],S=n.Mercator.toGeo(this.position.userValue),I=n.Ecef.fromGeo(S);n.generateNotStretchableIconElement(d,z,"",[0,0,this.elevation],I,0,r.rasters[0],window.devicePixelRatio);const R=d.getAccumulatedData();d.reset();const C=new n.TileObject("dynamicObject",R.data,this.modules,this.mapState,n.mapPointTo32ZoomTileCoords(this.position.normalizedValue),this);this.tileObjects.push(C),this.identifyIds=[x],this.modules.tileManager.addObject(C),this.modules.layers.addLayer(this),this.modules.identifier.queryFillCache(),this.modules.labeler.removeLabels(this.labelKey),this.modules.labeler.addLabelBox(this.labelKey,{id:this.uniqId,width:o[0],height:o[1],position:this.position.normalizedValue,offset:[-a[0],-a[1]],labelingGroup:"marker"}),this.modules.renderer.addRerenderEvent()})}update(){if(this.mapState.globeMode){const{tileManager:e}=this.modules,t=this.modules.camera.ecef.canSee(this.options.coordinates);this.visible&&!t?this.tileObjects.forEach(i=>e.removeObject(i)):!this.visible&&t&&this.tileObjects.forEach(i=>e.addObject(i)),this.visible=t}}removeIcon(){const e=this.tileObjects[0];e&&(e.clean(this.mapState),this.modules.tileManager.removeObject(e),this.tileObjects=[])}}function Rb(s,e,t,i,o,a){return{type:s,maxDetailLevel:a,minDetailLevel:o,maxZoomLevel:i,minZoomLevel:t,zoomLevel:Math.floor(e),tiles:{},viewportTiles:[],useExtendedTilesBounds:!1}}function Fb(s){s.tiles={},s.viewportTiles=[]}function Db(s){return{type:"data",key:n.coordsToKey(s),coords:s,zoomLevel:s[2],detailLevel:s[3],needFetch:!1,needAbortFetch:!1,status:n.TileStatus.Initial}}function Ob(s,e,t,i,o){return Rb("data",s,e,t,i,o)}function Nb(s,e,t,i){if(s.zoomLevel<s.minZoomLevel){s.viewportTiles=[];return}const o=n.clamp(s.zoomLevel,s.minZoomLevel,s.maxZoomLevel),a=n.clamp(s.zoomLevel,s.minDetailLevel,s.maxDetailLevel);s.viewportTiles=n.findVisibleTiles(e,t,o,s.minZoomLevel,a,void 0,void 0,void 0,s.useExtendedTilesBounds).map(n.coordsToKey);for(let r=0;r<s.viewportTiles.length;r++){const l=s.viewportTiles[r];let c=s.tiles[l];c||(c=s.tiles[l]=i(n.keyToCoords(l)))}}function kb(s){const e=[];for(const t in s.tiles){const i=s.tiles[t];i.needFetch&&(i.needFetch=!1,e.push(i))}return e}function Ub(s){const e=[];for(const t in s.tiles){const i=s.tiles[t];i.needAbortFetch&&(i.needAbortFetch=!1,e.push(i))}return e}function Gb(s,e){const t=new Set(s.viewportTiles),i=[];for(const o in s.tiles){const a=s.tiles[o];!t.has(o)&&!0&&i.push(a)}return i}class Hb extends n.Evented{constructor(e,t,i){super(),this.prevZoomLevel=0,this.mapState=e,this.modules=t,this.config=i,this.gridState=Ob(e.styleZoom,i.minZoom,i.maxZoom,i.minZoom,i.maxZoom),this.viewportDiffer=new n.Differ([{path:"center",type:"vec2"},{path:"zoom",type:"number"},{path:"size",type:"vec2"},{path:"rotation",type:"number"},{path:"pitch",type:"number"},{path:"demMode",type:"boolean"}]),this.dataTileLoader=new n.BaseTileLoader("json"),this.modules.layers.addLayer(this)}destroy(){Fb(this.gridState),this.modules.layers.removeLayer(this)}update(){let e=!0;if(this.viewportDiffer.check(this.mapState)){const t=Math.floor(this.mapState.styleZoom);t!==this.prevZoomLevel&&(e=!1),this.prevZoomLevel=t,this.gridState.zoomLevel=t,Nb(this.gridState,this.mapState,this.modules,Db),this.emit("tilesSetChanged",{tileIds:this.gridState.viewportTiles})}for(const t in this.gridState.tiles){if(!this.gridState.viewportTiles.includes(t)){this.gridState.tiles[t].status===n.TileStatus.Loading&&(this.gridState.tiles[t].needAbortFetch=!0);continue}this.gridState.tiles[t].status===n.TileStatus.Initial&&(this.gridState.tiles[t].needFetch=!0,this.gridState.tiles[t].status=n.TileStatus.Loading)}e&&(this.fetch(kb(this.gridState)),this.abortFetch(Ub(this.gridState)),this.clearTiles(Gb(this.gridState)))}fetch(e){e.sort((t,i)=>n.compare(this.mapState.center,t,i)).forEach(t=>this.fetchTile(t))}abortFetch(e){const t=e.map(i=>i.key);this.dataTileLoader.abortRequests(t)}clearTiles(e){for(const t of e)delete this.gridState.tiles[t.key],this.emit("dataTileCleared",{tileId:t.key})}fetchTile(e){const{tsURLTemplate:t}=this.config;this.dataTileLoader.fetch(e.coords,t).then(i=>{i.rejected||this.emit("dataTileLoaded",{tileId:e.key,data:i.data})})}}const Vb=Object.freeze(Object.defineProperty({__proto__:null,Benchmark:xn,Circle:Dl,CircleMarker:vs,DashedPolyline:Rl,DataTileLayer:Hb,DefaultSource:jr,DynamicObject:Re,Entrance:Kr,GeoJsonSource:n.GeoJsonSource,GeoJsonTileSource:n.GeoJsonTileSource,GeoJsonViewportSource:n.GeoJsonViewportSource,GltfModel:Ko,Heatmap:db,HtmlMarker:Go,LinePatternType:n.LinePatternType,Map:ts,MapClass:ts,Marker:Ul,OnlineMarker:zb,PointLabel:ss,Polygon:Fl,Polyline:El,Raster:Hl,RasterTileSource:Vl,Rect:Eb,ZenithSource:Fn,config:n.index,linePatternFromString:n.linePatternFromString,mapglUtils:uc,utils:_c},Symbol.toStringTag,{value:"Module"})),jb="topRight";class Et{constructor(e,t,i){this._wrap=document.createElement("div"),this._wrap.style.userSelect="none",typeof t=="string"?this._wrap.innerHTML=t:this._wrap.appendChild(t),this._position=i?.position??jb,this._controlPane=e._controlPane,this._container=this._controlPane.getContainerByPosition(this._position),this._container.append(this._wrap)}destroy(){this._wrap.remove()}getPosition(){return this._position}setPosition(e){this._container.removeChild(this._wrap),this._container=this._controlPane.getContainerByPosition(e),this._container.append(this._wrap),this._position=e}getContainer(){return this._wrap}}const It={root:"mapgl_QEdaFvncPWE-",button:"mapgl_mjx-K8iaDdc-",zoomIn:"mapgl_zKZCVsRur9c-",zoomOut:"mapgl_3t-wJELDATg-"},Zb=`
    <div class="${It.root}">
        <button type="button" class="${It.button} ${It.zoomIn}">
            <svg
                xmlns="http://www.w3.org/2000/svg"
                viewBox="0 0 32 32"
                width="32"
                height="32"
                fill="currentColor"
            >
                <path d="M24 15h-7V8h-2v7H8v2h7v7h2v-7h7v-2z"></path>
            </svg>
        </button>
        <button type="button" class="${It.button} ${It.zoomOut}">
            <svg
                xmlns="http://www.w3.org/2000/svg"
                viewBox="0 0 32 32"
                fill="currentColor"
                width="32"
                height="32"
            >
                <path d="M8 15h16v2H8z"></path>
            </svg>
        </button>
    </div>
`;class jl extends Et{constructor(e,t){super(e,Zb,t),this._zoomIn=i=>{i.preventDefault(),this._map.setZoom(this._map.getZoom()+1,{duration:400})},this._zoomOut=i=>{i.preventDefault(),this._map.setZoom(this._map.getZoom()-1,{duration:400})},this._checkZoom=()=>{const i=this._map.getZoom();i<=this._map.getMinZoom()?this._zoomOutButton.disabled=!0:this._zoomOutButton.disabled=!1,i>=this._map.getMaxZoom()?this._zoomInButton.disabled=!0:this._zoomInButton.disabled=!1},this._map=e,this._zoomInButton=this._wrap.querySelector(`.${It.zoomIn}`),this._zoomOutButton=this._wrap.querySelector(`.${It.zoomOut}`),this._zoomInButton.addEventListener("click",this._zoomIn),this._zoomOutButton.addEventListener("click",this._zoomOut),this._map.on("zoom",this._checkZoom)}destroy(){this._map.off("zoom",this._checkZoom),this._zoomInButton.removeEventListener("click",this._zoomIn),this._zoomOutButton.removeEventListener("click",this._zoomOut),super.destroy()}}const Ct={root:"mapgl_ON-gf73kIU0-",button:"mapgl_mWyZxMObEi8-",none:"mapgl_FwnEmRmDBLg-",easy:"mapgl_uSuUHuf71nM-",medium:"mapgl_LdqAv9Ly624-",hard:"mapgl_udRZCM1quWE-"},Wb=`<svg xmlns="http://www.w3.org/2000/svg" width="20" height="14" viewBox="0 0 20 14" style="margin-top: 4px">
    <path d="M 18,5 C 18,4 17,1 15,1 H 12 10 C 8,1 7,4 7,5 H 5 v 2 h 1 v 4 c 0,0.6 0,1 1,1 v 2 h 2 v -2 h 7 v 2 h 2 v -2 c 1,0 1,-0.4 1,-1 V 7 h 1 V 5 H 18 z M 10,3 h 2 3 c 2,0 2,1 2,3 H 8 C 8,4 8,3 10,3 z M 9,10 H 8 C 7.4,10 7,9.6 7,9 7,8.4 7.4,8 8,8 h 1 c 0.6,0 1,0.4 1,1 0,0.6 -0.4,1 -1,1 z m 8,0 H 16 C 15.4,10 15,9.6 15,9 15,8.4 15.4,8 16,8 h 1 c 0.6,0 1,0.4 1,1 0,0.6 -0.4,1 -1,1 z M 4,4 H 6 V 3 H 4 C 1,3 1,6 1,7 H 0 v 1 h 1 v 4 H 3 V 11 H 5 V 7 H 2 C 2,6 2,4 4,4 z M 3,9 4,10 H 2 V 9 h 1 z" fill="#616161" fill-rule="evenodd"/>
    <g fill="#fff">
        <path d="m 16,8 h 1 c 0.4,0 0.7,0.2 0.8,0.5 C 17.9,8.4 18,8.2 18,8 18,7.4 17.6,7 17,7 h -1 c -0.6,0 -1,0.4 -1,1 0,0.2 0.1,0.4 0.2,0.5 C 15.3,8.2 15.6,8 16,8 z"/>
        <path d="M 8,8 H 9 C 9.4,8 9.7,8.2 9.8,8.5 9.9,8.4 10,8.2 10,8 10,7.4 9.6,7 9,7 H 8 C 7.4,7 7,7.4 7,8 7,8.2 7.1,8.4 7.2,8.5 7.3,8.2 7.6,8 8,8 z"/>
        <path d="M 6,3 H 4 C 4,3 4,3 4,3 2,3 2,5 2,6 H 2 C 2.1,5 2.5,4 4,4 H 5 6 V 3 z"/>
        <path d="M0 7H1V8H0z"/>
        <path d="M 15,2 H 12 10 C 8,2 8,3 8,5 H 8 C 8,3.7 8.3,3 10,3 h 2 3 c 1.7,0 1.9,0.7 2,2 h 0 C 17,3 17,2 15,2 z"/>
        <path d="M3 9L4 9 3 8 2 8 2 9 2 9 2 9 3 9z"/>
        <path d="M 7,11 C 6,11 6,10.6 6,10 v 1 c 0,0.6 0,1 1,1 v -1 z"/>
        <path d="m 18,11 v 1 c 1,0 1,-0.4 1,-1 v -1 c 0,0.6 0,1 -1,1 z"/>
        <path d="M19 6H20V7H19z"/>
        <path d="M3 11L1 11 1 12 3 12 3 11 5 11 5 7 5 7 5 10 3 10z"/>
        <path d="M16 13H18V14H16z"/>
        <path d="M5 6H6V7H5z"/>
        <path d="M9 13L7 13 7 14 9 14 9 12 16 12 16 11 9 11z"/>
    </g>
    <g fill="#444">
        <path d="M 2,6 C 2,6.4 2,6.7 2,7 H 5 V 6 H 2 z"/>
        <path d="M2 9L2 10 4 10 3 9z"/>
        <path d="M 4,3 H 6 V 2 H 4 C 1,2 1,5 1,6 H 0 V 7 H 1 C 1,6 1,3 4,3 z"/>
        <path d="M 18,4 C 18,3 17,0 15,0 H 12 10 C 8,0 7,3 7,4 H 6 5 V 5 H 7 C 7,4 8,1 10,1 h 2 3 c 2,0 3,3 3,4 h 2 V 4 h -2 z"/>
        <path d="M 8,10 H 9 C 9.6,10 10,9.6 10,9 10,8.8 9.9,8.6 9.8,8.5 9.7,8.8 9.4,9 9,9 H 8 C 7.6,9 7.3,8.8 7.2,8.5 7.1,8.6 7,8.8 7,9 c 0,0.6 0.4,1 1,1 z"/>
        <path d="M 17,6 C 17,5.6 17,5.3 17,5 H 8 c 0,0.3 0,0.6 0,1 h 9 z"/>
        <path d="M 17.8,8.5 C 17.7,8.8 17.4,9 17,9 H 16 C 15.6,9 15.3,8.8 15.2,8.5 15.1,8.6 15,8.8 15,9 c 0,0.6 0.4,1 1,1 h 1 c 0.6,0 1,-0.4 1,-1 0,-0.2 -0.1,-0.4 -0.2,-0.5 z"/>
    </g>
</svg>
`;class Zl extends Et{constructor(e,t){super(e,"",t),this._onClick=i=>{i.preventDefault(),this._map.isTrafficOn()?this._map.hideTraffic():this._map.showTraffic()},this._map=e,this._render(),e.on("trafficscore",({score:i})=>{this._score=i,this._render()}),e.on("trafficshow",()=>{this._render()}),e.on("traffichide",()=>{this._render()})}_render(){const e=this._map.isTrafficOn()?$b(this._score):Ct.none,t=`
            <div class="${Ct.root}">
                <button type="button" class="${Ct.button} ${e}">
                    ${this._map.isTrafficOn()&&this._score!==void 0?this._score:Wb}
                </button>
            </div>
        `;this._wrap.innerHTML=t,this._wrap.querySelector(`.${Ct.button}`).addEventListener("click",this._onClick)}}function $b(s){return s===void 0?"":s>6?Ct.hard:s>3?Ct.medium:Ct.easy}const En={container:"mapgl_K-1Yb8HCVpQ-",logos:"mapgl_CLps5xx6CNs-"};var Wl=(s=>(s.osm="osm",s.api="api",s.license="license",s))(Wl||{});const Xb=`<a href="https://dev.2gis.ru/link_api_map" target="_blank" style="height: 20px;">
    <svg width="40" height="20" viewBox="0 0 40 20" fill="none" xmlns="http://www.w3.org/2000/svg">
        <path d="M2.00011 8.72731C1.98229 5.72738 4.05025 4 6.80779 4C9.47674 4 11.2797 5.58179 11.2797 8.05437C11.2797 10.1091 10.0602 11.2546 7.99196 12.2727C7.21431 12.6547 6.34807 13.1818 5.46454 13.4544H11.3681V16H2.00011V12.66C3.85604 12.0235 4.88111 11.3271 6.59576 10.4728C7.90363 9.81815 8.71666 9.23633 8.71666 8.1819C8.71666 7.16358 7.97439 6.36366 6.80779 6.36366C5.27006 6.36366 4.52753 7.52729 4.56292 8.72731H2.00011Z" fill="#6E7173"/>
        <path d="M23.6348 9.63643V10.5453C23.6348 13.5455 21.6552 16 18.067 16C14.6202 16 12.2518 13.4727 12.2518 9.99986C12.2518 6.52731 14.5497 4 18.1554 4C21.2487 4 23.1751 5.8363 23.6348 7.99991H21.0717C20.6301 6.96353 19.534 6.36366 18.2261 6.36366C15.9813 6.36366 14.7263 8.14523 14.7263 9.99986C14.7263 11.8545 15.9991 13.6363 18.2086 13.6363C19.5872 13.6363 20.736 12.9456 21.0896 11.8181H17.7313V9.63643H23.6348Z" fill="#6E7173"/>
        <path d="M27.4528 16H24.9783V4H27.4528V16Z" fill="#6E7173"/>
        <path d="M38.4292 7.63648H35.8662C35.6185 6.85461 34.947 6.18167 33.4446 6.18167C32.1543 6.18167 31.5004 6.69096 31.5004 7.41809C31.5004 8.30915 32.7375 8.56366 34.293 8.83623L34.361 8.84818C36.4076 9.20779 38.5 9.57545 38.5 12.2727C38.5 14.8 36.4672 16 33.7274 16C31.1998 16 28.9373 14.4727 28.6899 12.1818H31.2527C31.5712 13.1273 32.5079 13.8181 33.8512 13.8181C35.1415 13.8181 35.8662 13.3818 35.8662 12.5455C35.8662 11.514 34.3606 11.2653 32.8555 11.0167C32.8221 11.0112 32.7887 11.0056 32.7553 11.0001C31.1468 10.7273 28.8844 9.9818 28.8844 7.54535C28.8844 5.34534 30.7581 4 33.5332 4C36.2727 4 38.164 5.41814 38.4292 7.63648Z" fill="#6E7173"/>
    </svg>
</a>`,Kb=`<a href="https://dev.urbi.ae" target="_blank" style="height: 20px; line-height: 20px;">
    <svg style="width: auto; height: 16px;" width="29" height="12" viewBox="0 0 29 12" fill="none" xmlns="http://www.w3.org/2000/svg">
        <path fill-rule="evenodd" clip-rule="evenodd" d="M5 4V8.0625C5 9.13823 4.64701 9.5 3.75 9.5C3.00479 9.5 2.5 9.15185 2.5 8.0625V4H0V8.5C0 10.6515 1.45917 12 3.75 12C6.19263 12 7.5 10.6515 7.5 8.5V4H5ZM18.5 9.5V2H16V11.9993L20.5 12C23.013 12.0276 24.5 10.4576 24.5 8C24.5 5.4872 23.2711 4 20.5 4H19.5V6.5H20.5C21.6954 6.5 22 6.9645 22 8C22 9.06311 21.3422 9.51381 20.5 9.5H18.5ZM13 4C12.1529 4 11.7541 4.19542 11.5 5L11 4H9.01412V12H11.5V7.75C11.5 6.87606 12.1106 6.5 13 6.5H15V4H13ZM28.25 12V4H25.75V12H28.25ZM27 3C27.9508 3 28.75 2.32569 28.75 1.5C28.75 0.674312 27.9508 0 27 0C26.0492 0 25.25 0.674312 25.25 1.5C25.25 2.32569 26.0492 3 27 3Z" fill="#6E7173"/>
    </svg>
</a>`,$l=s=>`
    <div class=${En.container}>
        <div class=${En.logos}>
            ${s==="2gis"?Xb:Kb}
        </div>
    </div>
`,qb=200,vt=.4,Yb=6.9,Qb={features:[{type:"Feature",properties:{},geometry:{coordinates:[[[31.287134399571926,46.13828663057069],[32.75238568004798,45.79865765372267],[33.58288063506086,46.01903186613521],[33.61486347995313,46.2235364272577],[33.78934942202696,46.198543888421256],[35.00827602994491,45.75534495217423],[35.2288647404554,45.79620376974098],[35.17718890419883,45.90635851081622],[35.435536217844785,46.10280090340363],[35.79210757517962,46.37361688082296],[36.11428232078944,46.29643073207143],[36.55169983042855,46.510726153023995],[36.8324385653631,46.4588228565425],[37.14524285843429,46.69589191473136],[37.39260951621397,46.689280151379506],[37.627431059848774,46.82264082535376],[38.1229012131082,46.84212508154449],[38.33448922300602,46.97422615512966],[38.224662200013626,47.230888527366346],[38.32912700579817,47.25438400708447],[38.34419757143178,47.312784332059664],[38.21546574161874,47.30909993831261],[38.254518753011865,47.36826000208279],[38.31067651491526,47.38482171052604],[38.321606223663025,47.571364572295465],[38.3617938178036,47.57882910808604],[38.36170197978049,47.618956233608515],[38.45674637734251,47.62208601169297],[38.46107375227305,47.64691148544472],[38.63803321177437,47.647842642655746],[38.672098728783254,47.68762314810277],[38.775725461608346,47.68709376851825],[38.8049944923477,47.813690288503295],[38.834920351813224,47.8196727375917],[38.84241614380997,47.85748354545768],[39.07247756595089,47.86497172354581],[39.10052537670751,47.840884138531834],[39.38214421832214,47.86795888702861],[39.40746330974267,47.8256169720315],[39.482844878880115,47.85023053453213],[39.53382832770623,47.81883936134608],[39.73848854131376,47.82763637975813],[39.79371699101341,47.869042802541685],[39.83078252402845,47.99974474342423],[39.77863815152742,48.03277123184873],[39.88321233741743,48.03971572761765],[39.870917803736376,48.113006872810985],[39.93505319594328,48.18105768715421],[39.94606694701065,48.22361687262517],[40.01236868994266,48.22433847068592],[40.03218509167988,48.26056076274611],[39.984065212024376,48.320002192647365],[39.922439044370975,48.29188408842856],[39.851945001258656,48.331239182362935],[39.94636538164761,48.35223341528243],[39.941853222859265,48.388067879458134],[39.899783141900656,48.45166958120498],[39.85004077188802,48.47107700658495],[39.85404334598155,48.49815859245703],[39.871488094298144,48.507759719913],[39.83989084312387,48.58511601134842],[39.690955803936305,48.59154349398949],[39.668972082370914,48.61595180677952],[39.71340429381095,48.65723964838148],[39.72739208280473,48.68576344104625],[39.720852030234056,48.70453377084817],[39.71060957078353,48.71895533887451],[39.72773821117514,48.727349762777976],[39.742522688889096,48.74565876284592],[39.73675984758131,48.75923566351821],[39.75294236354742,48.76535707528038],[39.77230712573868,48.765131537231696],[39.78708527484656,48.792695126714506],[39.79951920927968,48.83846452038483],[39.97324551864918,48.788853683331496],[40.0854569051011,48.87270686936236],[40.054991236497585,48.91511705296017],[40.01572101314082,48.91564488817568],[39.985747700540486,48.87433169550951],[39.92581794882187,48.895346707874324],[39.85691072202724,48.89266055501065],[39.84380033698696,48.90643237682923],[39.77980530005851,48.92505561008153],[39.76769275004051,48.96624269122293],[39.75249250304927,48.988397421631134],[39.72953342924575,48.98364479695306],[39.6963475099607,49.006204908207565],[39.67412801512273,48.99350840477692],[39.688776866237845,49.04629763624743],[39.77599141224027,49.03984390969006],[39.80998946255809,49.05657174933967],[39.94020528746006,49.054672146531885],[39.94517686594733,49.08306814321608],[40.03354656530658,49.17940433543734],[40.08179564952226,49.187957220033326],[40.127812302222935,49.23339833688371],[40.21735722846822,49.24434936924021],[40.23083631365782,49.264375707391025],[40.184193609561845,49.28357807698788],[40.20554425700146,49.348627711592286],[40.0352506597566,49.460305560239135],[40.042265513048875,49.52110947883719],[40.17301947712943,49.570462036839785],[40.135367644468886,49.619991840168154],[39.930446598607006,49.58753811881613],[39.89326483911972,49.561338740411344],[39.80152397436578,49.5648154530997],[39.747824755329106,49.601752391386356],[39.65652368638126,49.620013992728445],[39.59591913143757,49.727977277611615],[39.43167355486196,49.76704897880802],[39.38482981859343,49.7428519723461],[39.28679269123114,49.7589376228415],[39.23167115889703,49.80067773683314],[39.23126430925569,49.83799228995301],[39.184177982005934,49.89212328019818],[38.939466721594385,49.8129411626972],[38.67999394500015,49.99954348208959],[38.498971405582154,49.969630683120045],[38.36122588838947,50.008962505581735],[38.33064743770436,50.10587365547255],[38.179344250662524,50.08108187117696],[38.17324129258458,49.96421343242167],[38.0243275352658,49.9126740335152],[38.00390141376576,49.80621204332192],[37.9339784494789,49.72626072303203],[37.997665462537555,49.705679809807805],[37.98195913415958,49.63338227733652],[37.87841001479606,49.55639540561637],[37.8726905583969,49.314558240834856],[37.83487442598039,49.211403426079585],[37.568531160033984,49.23978324969454],[37.49068171343487,49.18083483226363],[37.467253126665184,49.08118016596504],[37.29258016280227,48.98322524059054],[37.27222555931064,48.936467375391885],[36.983084082742096,48.80186787172613],[36.72382254183347,48.816637155788754],[36.863697512625095,48.16812695432242],[36.85276964213293,48.06101666035238],[36.63699950073965,48.1120861847823],[36.55643334225425,48.079707051057994],[36.5326892781749,47.85663993329777],[36.15757828505022,47.87029971236788],[36.007257866960344,48.150801757163464],[35.84084530869785,48.072372143164614],[35.69001200739808,48.14916424481041],[34.84251652180234,48.13828093857032],[34.93636037372508,47.54124693653375],[34.561002995692604,47.57138977148597],[33.975870854429644,47.468842659893966],[33.94579238047862,47.53020932511487],[33.65802349898351,47.49630012349715],[33.57945696368617,47.61817363276853],[33.07047295330287,47.579949515419315],[33.106438567586736,47.23712252316682],[32.87965855893614,47.10939623564883],[32.94045936300873,47.00638816222238],[32.531962255274834,46.887846448242044],[32.23541823078415,46.84566846340053],[31.99589893588245,46.69298741295057],[31.792169481175108,46.355938076969124],[31.231245271853055,46.42046225841926],[31.287134399571926,46.13828663057069]]],type:"Polygon"}}]};class Jb extends Et{constructor(e,t){super(e,$l(t.copyrightType),t),this._copyrightType="2gis",this._isHidden=!1,this._onViewportchange=()=>{this._throttledVisibleCopyright()},this._onClick=o=>{if(o.target&&ex(o.target)){const a=o.target.dataset.type;Ab(a)&&this._map.emit("copyrightclick",{type:a,href:o.target.href,originalEvent:o})}},this._copyrightType=t.copyrightType,this._map=e,this._map._impl.on("viewportchange",this._onViewportchange),this._map._impl.on("idle",this._onViewportchange),t.interactive===!1&&(this._wrap.style.pointerEvents="none"),this._wrap.querySelector(`.${En.container}`).addEventListener("click",this._onClick),this._throttledVisibleCopyright=n.throttle(()=>{this.update()},qb)}destroy(){this._map._impl.off("viewportchange",this._onViewportchange),this._map._impl.off("idle",this._onViewportchange),this._wrap.querySelector(`.${En.container}`).removeEventListener("click",this._onClick),super.destroy()}update(){let e=!1;if(this._map.getZoom()>Yb){const t=this._map.getSize(),i=this._map._impl.unproject([t[0]*vt,t[1]*vt]),o=this._map._impl.unproject([t[0]*(1-vt),t[1]*vt]),a=this._map._impl.unproject([t[0]*vt,t[1]*(1-vt)]),r=this._map._impl.unproject([t[0]*(1-vt),t[1]*(1-vt)]);e=tx([i,o,r,a,i],Qb.features[0].geometry.coordinates[0])}e&&!this._isHidden&&(this._isHidden=!0,super.getContainer().innerHTML=""),!e&&this._isHidden&&(this._isHidden=!1,super.getContainer().innerHTML=$l(this._copyrightType))}}function Ab(s){return s!==void 0&&s in Wl}function ex(s){return s&&"href"in s&&"dataset"in s}function tx(s,e){for(let t=0;t<s.length-1;t++){const i=s[t],o=s[t+1];for(let a=0;a<e.length-1;a++){const r=e[a],l=e[a+1];if(ix(i,o,r,l))return!0}}return!!(Xl(s[0],e)||Xl(e[0],s))}function ix(s,e,t,i){const o=In(t,i,s),a=In(t,i,e),r=In(s,e,t),l=In(s,e,i);return!!((o>0&&a<0||o<0&&a>0)&&(r>0&&l<0||r<0&&l>0)||o===0&&Cn(t,i,s)||a===0&&Cn(t,i,e)||r===0&&Cn(s,e,t)||l===0&&Cn(s,e,i))}function In(s,e,t){return(e[0]-s[0])*(t[1]-s[1])-(e[1]-s[1])*(t[0]-s[0])}function Cn(s,e,t){return Math.min(s[0],e[0])<=t[0]&&t[0]<=Math.max(s[0],e[0])&&Math.min(s[1],e[1])<=t[1]&&t[1]<=Math.max(s[1],e[1])}function Xl(s,e){const[t,i]=s;let o=!1;for(let a=0,r=e.length-1;a<e.length;r=a++){const[l,c]=e[a],[d,_]=e[r];c>i!=_>i&&t<(d-l)*(i-c)/(_-c)+l&&(o=!o)}return o}const Kl={wrap:"mapgl_r8Wn2E5pGh0-",container:"mapgl_ir0vRf5QXrk-"};class nx{constructor(e,t){this.rootContainer=e._impl.modules.layout.rootContainer,this.content=t,this.isShown=!1}display(){this.isShown||(this.wrap||(this.wrap=this.initWrap()),this.rootContainer.appendChild(this.wrap),this.isShown=!0)}hide(){this.isShown&&(this.wrap&&this.rootContainer.removeChild(this.wrap),this.isShown=!1)}isDisplayed(){return this.isShown}}const ox=` <div class=${Kl.container}>Your MapGL key is invalid. Please contact api@2gis.com to get MapGL key.</div> `;class sx extends nx{constructor(e){super(e,ox),e._impl.on("error",t=>{t.type==="invalidtilekey"&&(this.isDisplayed()||this.display())})}initWrap(){const e=document.createElement("div");return e.classList.add(`${Kl.wrap}`),e.innerHTML=this.content,e}}class ql{constructor(e){this.northEast=e.northEast,this.southWest=e.southWest}extend(e){return this.southWest=[Math.min(this.southWest[0],e[0]),Math.min(this.southWest[1],e[1])],this.northEast=[Math.max(this.northEast[0],e[0]),Math.max(this.northEast[1],e[1])],this}getCenter(){return[(this.southWest[0]+this.northEast[0])/2,(this.southWest[1]+this.northEast[1])/2]}containsPoint(e){const[t,i]=e,o=t>=this.southWest[0]&&t<=this.northEast[0],a=i>=this.southWest[1]&&i<=this.northEast[1];return o&&a}containsBounds(e){const{southWest:t,northEast:i}=e,o=this.containsPoint(t),a=this.containsPoint(i);return o&&a}intersects(e){const{southWest:t,northEast:i}=e,o=this.getPointRelatedLocation(t),a=this.getPointRelatedLocation(i),r=+o.N+ +a.N,l=+o.S+ +a.S,c=+o.W+ +a.W,d=+o.E+ +a.E;return!(r===2||l===2||c===2||d===2)}getPointRelatedLocation(e){return{S:e[1]<this.southWest[1],N:e[1]>this.northEast[1],W:e[0]<this.southWest[0],E:e[0]>this.northEast[0]}}}const Be={root:"mapgl_h2pl79nAYpk-",container:"mapgl_64D1bmNQN3Q-",scroller:"mapgl_jdJbkjpLO7k-",content:"mapgl_54Rmy50n6Fw-",control:"mapgl_3i1QoGerxio-",label:"mapgl_wGplqJ4hHPc-"},ax=`
    <div class="${Be.root}">
        <div class="${Be.container}">
            <div class="${Be.scroller}">
                <div class="${Be.content}" />
            </div>
        </div>
    </div>
`,rx=`<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M12.1142 14.1859L23.2303 9.29482L18.0571 1.2998L5.55708 5.01563L5.56217 5.04408L0.599976 10.0063L1.95007 11.3564L5.59996 7.70647L6.39699 6.90943L7.09339 7.79575L12.1142 14.1859ZM21.8071 12.1061L15.1198 15.0485L12.8071 16.1326V22.6321L21.8071 18.4131V12.1061ZM6.21714 9.91771L3.21617 12.9187V18.8564L5.50707 19.9405V14.9136L8.00707 15.9136V21.1236L10.8071 22.4487V15.7594L6.21714 9.91771Z" fill="#0059D6"/>
</svg>`,lx=`<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="20px" height="20px" viewBox="337.5 232.3 125 85.9" xml:space="preserve">
<polygon fill="#FF0013" points="453.9,306.2 424.7,232.3 400,275.5 375.4,232.3 346.1,306.2 337.5,306.2 337.5,317.4 381.7,317.4 381.7,306.2 375.1,306.2 381.5,287.8 400,318.2 418.5,287.8 424.9,306.2 418.3,306.2 418.3,317.4 462.5,317.4 462.5,306.2 "/>
</svg>`;class Yl extends Et{constructor(e,t){super(e,ax,t),this._removeButtonsEventListeners=()=>{this._content&&this._content.childNodes.forEach(i=>{if(this._handlers.has(i)){const o=this._handlers.get(i);o!==void 0&&i.removeEventListener("click",o)}})},this._showControl=i=>{const{currentFloor:o,id:a,floorNames:r,metro:l,mode:c}=i;this._floor={mode:c,currentFloorLevelIndex:o,floorPlanId:a,floorNames:r,metro:l},this._root.style.display="block",this._renderControl()},this._hideControl=()=>{this._map._impl.state.floorsEnabled&&(this._removeButtonsEventListeners(),this._floor=void 0,this._root.style.display="none")},this._onLevelChange=i=>{this._switchCurrentFloorLevel(i.floorLevelIndex)},this._controlHandler=i=>o=>{o.preventDefault(),this._switchCurrentFloorLevel(i),this._floor&&this._map._impl.changeFloorNumber(this._floor.floorPlanId,i)},this._map=e,this._root=this._wrap.querySelector(`.${Be.root}`),this._content=this._wrap.querySelector(`.${Be.content}`),this._handlers=new WeakMap,this._root.style.display="none",this._map._impl.on("floorcomplexin",this._showControl),this._map._impl.on("floorcomplexout",this._hideControl),this._map.on("floorlevelchange",this._onLevelChange)}destroy(){this._map._impl.off("floorcomplexin",this._showControl),this._map._impl.off("floorcomplexout",this._hideControl),this._map.off("floorlevelchange",this._onLevelChange),this._removeButtonsEventListeners(),super.destroy()}_renderControl(){if(!this._floor)return;this._content.innerHTML="";let e;if(this._floor.metro){const o=document.createElement("button");o.className=`${Be.control} ${Be.hideFloorsButton}`,o.innerHTML=lx,o.name="metro",o.type="button";const a=this._controlHandler("metro");o.addEventListener("click",a),this._handlers.set(o,a),this._content.append(o),this._floor.mode==="metro"&&(o.disabled=!0,e=o)}this._floor.floorNames.forEach((o,a)=>{const r=document.createElement("button");r.className=Be.control,r.innerHTML=`<div class="${Be.label}">${o}</div>`,r.name=a.toLocaleString(),r.type="button",this._floor&&this._floor.mode==="floor"&&this._floor.currentFloorLevelIndex===a&&(r.disabled=!0,e=r);const l=this._controlHandler(a);r.addEventListener("click",l),this._handlers.set(r,l),this._content.append(r)});const t=document.createElement("button");t.className=`${Be.control} ${Be.hideFloorsButton}`,t.innerHTML=`<div class="${Be.label}">${rx}</div>`,t.name="building",t.type="button",this._floor&&this._floor.mode==="building"&&(t.disabled=!0,e=t);const i=this._controlHandler("building");if(t.addEventListener("click",i),this._handlers.set(t,i),this._content.append(t),e&&e.offsetTop){const o=e.parentElement?.parentElement;o&&(o.scrollTop=e.offsetTop)}}_switchCurrentFloorLevel(e){if(!this._floor)return;const t=this._floor.mode==="floor"?this._floor.currentFloorLevelIndex:this._floor.mode==="building"?"building":"metro",i=this._wrap.querySelector(`.${Be.control}[name="${t}"]`);i&&(i.disabled=!1);const o=this._wrap.querySelector(`.${Be.control}[name="${e}"]`);o&&(o.disabled=!0),typeof e=="number"?(this._floor.mode="floor",this._floor.currentFloorLevelIndex=e):this._floor.mode=e}}const rs={controlPane:"mapgl_z0m6n5pr5no-",container:"mapgl_ITPUswrhaGk-",topLeft:"mapgl_Px-KwzXdVa0-",topCenter:"mapgl_SCX3EYsS-Cw-",topRight:"mapgl_i42TyWqpCPk-",centerLeft:"mapgl_-zKby6nN-nU-",centerRight:"mapgl_SlQM4-ZNKF0-",bottomLeft:"mapgl_lNg3h7Hg-Mo-",bottomCenter:"mapgl_grOepPBwilk-",bottomRight:"mapgl_CiHYefDPhI0-"},pi=10;class cx{constructor(e,t){this.wrap=document.createElement("div"),this.wrap.className=rs.controlPane,this.containers={};const{rootContainer:i}=e._impl.modules.layout;i.appendChild(this.wrap),this.padding={top:pi,right:pi,bottom:pi,left:pi},this.setPadding(t.padding||{})}setPadding(e){Object.keys(this.padding).forEach(t=>{const i=t;this.padding[i]=e[i]??pi,this.wrap.style[`margin${i.replace(/^\w/,o=>o.toUpperCase())}`]=`${this.padding[i]}px`})}getPadding(){return{...this.padding}}destroy(){this.wrap.remove()}getContainerByPosition(e){let t=this.containers[e];return t||(t=this.containers[e]=this._initControlContainer(e)),t}_initControlContainer(e){const t=document.createElement("div");return t.classList.add(rs.container,rs[e]),this.wrap.appendChild(t),t}}const Ql={root:"mapgl_9m2ynAxdBT0-",label:"mapgl_sR4nXEQ3L2M-"},Ln={meter:{en:"m",ru:"м"},kilometer:{en:"km",ru:"км"}},dx=66;class Jl extends Et{constructor(e,t){super(e,"",t),this._render=()=>{const{state:i}=this._map._impl,o=!!i.styleState.globeEnabled&&i.zoom<n.globeConfig.globeMaxZoom;if(this._wrap.hidden=o,o)return;const a=this._wrap.getBoundingClientRect(),r=this._calcSize([a.x,a.y],a.width||dx,0),l=`
            <div class="${Ql.root}">
                <div class="${Ql.label}">
                    ${_x(r,this._map.getLanguage())}
                </div>
            </div>
        `;this._wrap.innerHTML=l},this._map=e,this._render(),e.on("zoom",this._render),e.on("pitch",this._render),e.on("changeLanguage",this._render),e.on("move",this._render),e.on("resize",this._render)}destroy(){this._map.off("zoom",this._render),this._map.off("pitch",this._render),this._map.off("changeLanguage",this._render),this._map.off("move",this._render),this._map.off("resize",this._render),super.destroy()}_calcSize(e,t,i){return n.getMetersFromPixelsXY(this._map.getCenter(),this._map.getZoom(),this._map.getRotation(),this._map.getSize(),this._map.getPitch(),e,void 0,this._map.getPadding(),t,i)}}function _x(s,e){return s<1e3?`${s} ${Ln.meter[e]||Ln.meter.en}`:`${(s/1e3).toFixed(1)} ${Ln.kilometer[e]||Ln.kilometer.en}`}class Al{constructor(e){this._impl=e._impl.getDefaultSource()}setFeatureStateMap(e){this._impl.setFeatureStateMap(e)}}function De(s,e){const t={...s};for(const i in e){const o=i;t[o]===void 0&&(t[o]=e[o])}return t}const ux={center:[0,0],zoom:0,minZoom:wn.minZoom,maxZoom:wn.maxZoom,rotation:0,touchRotationThreshold:10,pitch:0,minPitch:0,maxPitch:45,lowZoomMaxPitch:45,viewport:{top:0,right:0,bottom:0,left:0},padding:{top:0,right:0,bottom:0,left:0},style:"",lang:"en",iconIdentifyOpacity:.3,disableHidingPois:!1,disableHoverStyles:!1,disableZoomOnScroll:!1,disableDragging:!1,enableTwoFingerDragging:!1,disableRotationByUserInteraction:!1,disablePitchByUserInteraction:!1,defaultBackgroundColor:"#f6f2de",disableIconCache:!1,mobileSdkMode:!1,skipElevationAnimation:!1,enableTrackResize:!1,showDefaultTileBounds:!1,immersiveOn:!1,pitchHightLimitation:90,loopWorld:!1,cityCommPoiLabelingConfig:n.cityCommPoiLabelingConfig,disableRenderingCache:!1,disableStyleFallback:!1,fontUrl:"",modelUrl:"",iconUrl:"",keyUrl:"",disableModelsGrowthAnimation:!1,disableLayerAnimation:!1,trafficOn:!1,allowMetro:!1,resetFloorModeOnActivation:!1,webgpu:!1,forceSyncIdentify:!1};let hx=class extends mt{constructor(e,t){super();let i;if(typeof e=="string"){const l=document.getElementById(e);if(l)i=l;else throw new Error(`Could not found html element with id: ${e}`)}else i=e;const o={...t.styleOptions},r={...De(this._validateOptions(t),ux),disableHoverStyles:t.disableHoverStyles??!0,tileServer:t.tileServer||Ag,style:t.style||n.DEFAULT_MAPGL_STYLE,styleOptions:o,styleState:t.styleState,sessionId:Ao(),tileSessionId:t.tileSessionId};this._impl=new ts(i,r),this._impl.on("idle",l=>this._emitMapEvent("idle",l)).on("ready",l=>this._emitMapEvent("ready",l)).on("resize",l=>this._emitMapEvent("resize",l)).on("move",l=>this._emitMapEvent("move",l)).on("movestart",l=>this._emitMapEvent("movestart",l)).on("moveend",l=>this._emitMapEvent("moveend",l)).on("center",l=>this._emitMapEvent("center",l)).on("centerstart",l=>this._emitMapEvent("centerstart",l)).on("centerend",l=>this._emitMapEvent("centerend",l)).on("zoom",l=>this._emitMapEvent("zoom",l)).on("zoomstart",l=>this._emitMapEvent("zoomstart",l)).on("zoomend",l=>this._emitMapEvent("zoomend",l)).on("rotation",l=>this._emitMapEvent("rotation",l)).on("rotationstart",l=>this._emitMapEvent("rotationstart",l)).on("rotationend",l=>this._emitMapEvent("rotationend",l)).on("pitch",l=>this._emitMapEvent("pitch",l)).on("pitchstart",l=>this._emitMapEvent("pitchstart",l)).on("pitchend",l=>this._emitMapEvent("pitchend",l)).on("trafficshow",()=>this.emit("trafficshow")).on("traffichide",()=>this.emit("traffichide")).on("floorcomplexshow",({id:l,currentFloor:c,floorNames:d})=>this.emit("floorplanshow",{floorPlanId:l,currentFloorLevelIndex:c,floorLevels:d.map((_,u)=>({floorLevelIndex:u,floorLevelName:_}))})).on("floorcomplexhide",l=>this.emit("floorplanhide",{floorPlanId:l.id})).on("floorcomplexlevelchange",l=>this.emit("floorlevelchange",{floorLevelName:l.floorName,floorLevelIndex:l.floorIndex,floorPlanId:l.id})).on("floorsactivegroupchange",l=>this.emit("floorsactivegroupchange",l)).on("modelshow",l=>this.emit("modelshow",l)).on("modelhide",l=>this.emit("modelhide",l)),this._impl.on("click",l=>this._emitMapPointerEvent("click",l)).on("dblclick",l=>this._emitMapPointerEvent("dblclick",l)).on("contextmenu",l=>this._emitMapPointerEvent("contextmenu",l)).on("mousemove",l=>this._emitMapPointerEvent("mousemove",l)).on("mouseover",l=>this._emitMapPointerEvent("mouseover",l)).on("mouseout",l=>this._emitMapPointerEvent("mouseout",l)).on("mousedown",l=>this._emitMapPointerEvent("mousedown",l)).on("mouseup",l=>this._emitMapPointerEvent("mouseup",l)).on("touchstart",l=>this._emitMapPointerEvent("touchstart",l)).on("touchend",l=>this._emitMapPointerEvent("touchend",l)),this._impl.on("error",l=>this._emitMapErrorEvent("error",l)),this._impl.on("trafficscore",({score:l})=>this.emit("trafficscore",{score:l})),this._impl.on("styleload",({style:l})=>this.emit("styleload",{style:l})),this._impl.on("graphicspresetchange",()=>this.emit("graphicspresetchange",this._impl.getCurrentGraphicsPreset())),this._controlPane=new cx(this,{padding:t.controlsLayoutPadding}),this._initControls(t),new sx(this),this._defaultSource=new Al(this)}setCenter(e,t){return this._impl.setCenter(e,t),this}getCenter(){return this._impl.getCenter()}setZoom(e,t){return this._impl.setZoom(e,t),this}getZoom(){return this._impl.getZoom()}getStyleZoom(){return this._impl.getStyleZoom()}setStyleZoom(e,t){return this._impl.setStyleZoom(e,t),this}setRotation(e,t){return this._impl.setRotation(e,t),this}getRotation(){return this._impl.getRotation()}setPitch(e,t){return this._impl.setPitch(e,t),this}getPitch(){return this._impl.getPitch()}setMinZoom(e,t){return this._impl.setMinZoom(e,t),this}getMinZoom(){return this._impl.getMinZoom()}getMaxZoom(){return this._impl.getMaxZoom()}setMaxZoom(e,t){return this._impl.setMaxZoom(e,t),this}setMinPitch(e,t){return this._impl.setMinPitch(e,t),this}setMaxPitch(e,t){return this._impl.setMaxPitch(e,t),this}setLowZoomMaxPitch(e,t){return this._impl.setLowZoomMaxPitch(e,t),this}getSize(){return this._impl.getSize()}isIdle(){return this._impl.isIdle()}getBounds(e){return new ql(this._impl.getBounds(e))}project(e){return this._impl.project(e)}unproject(e){return this._impl.unproject(e)}getProjectionMatrix(){return this._impl.getCameraViewProjectionMatrix().slice()}getProjectionMatrixForGltfPlugin(){return this._impl.getCameraProjectionMatrix().slice()}getWebGLContext(){return this._impl.getWebGLContext()}getCanvas(){return this._impl.getCanvas()}getContainer(){return this._impl.getExternalContainer()}invalidateSize(){return this._impl.invalidateSize(),this}showTraffic(){return this._impl.showTraffic(),this}hideTraffic(){return this._impl.hideTraffic(),this}isTrafficOn(){return this._impl.isTrafficOn()}setSelectedObjects(e=[],t){return this._impl.setSelectedIds(e,t),this}async setStyleById(e){return this._impl.setStyle(e)}async setStyleFromUrl(e,t){return this._impl.setStyle(e,t)}setLanguage(e){return this._impl.setLang(e),this.emit("changeLanguage",{lang:e}),this}getLanguage(){return this._impl.state.lang}setFloorPlanLevel(e,t){this._impl.changeFloorNumber(e,t)}setMaxBounds(e){return this._impl.setMaxBounds(e),this}getPadding(){return this._impl.getPadding()}getDefaultSource(){return this._defaultSource}setPadding(e,t){return this._impl.setPadding(e,t),this}setStyle(e,t){return this._impl.setStyle(e,t)}hasLayer(e){return this._impl.hasLayer(e)}addLayer(e,t){return this.addDraftLayer(e,t),this}addDraftLayer(e,t){return this._impl.addLayer(e,t),this}addIcon(e,t){return this._impl.addIcon(e,t),this}removeIcon(e){return this._impl.removeIcon(e),this}getMapRenderStat(){return this._impl.getMapRenderStat()}addModel(e,t){return this._impl.addModel(e,t),this}removeLayer(e){return this._impl.removeLayer(e),this}setAutoHoverMode(e){return this._impl.setAutoHoverMode(e),this}fitBounds(e,t){return this._impl.fitBounds(e,t),this}setStyleState(e){return this._impl.setStyleState(e),this}setTime(e){this._impl.setTime(e)}getTime(e){return this._impl.getTime(e)}getStyleState(){return this._impl.getStyleState()}setStyleOptions(e){return this._impl.patchStyleState({trafficOn:e.traffic}),this}setOption(e,t){return this._impl.setOption(e,t),this}getOption(e){return this._impl.getOption(e)}patchStyleState(e){return this._impl.patchStyleState(e),this}destroy(){this._controlPane.destroy(),this._impl.destroy(),this.emit("destroy")}triggerRerender(){this._impl.modules.renderer.addRerenderEvent({type:"triggerRerender"})}setControlsLayoutPadding(e){this._controlPane.setPadding(e)}getControlsLayoutPadding(){return this._controlPane.getPadding()}setHiddenObjects(e){this._impl.hideBuildingsById(e)}setEnvironmentParams(e){this._impl.modules.environmentManager.setParameters(e)}unsetHiddenObjects(e){this._impl.showHiddenBuildingsById(e)}showLabelsDebug(e){this._impl.showLabelsDebug(e)}hideLabelsDebug(){this._impl.hideLabelsDebug()}getGroundPoint(e){return this._impl.getGroundPoint(e)}setAllowedFloorIds(e){this._impl.setAllowedFloorIds(e)}setLightingStyle(e){this._impl.setLightingStyle(e)}hideLayers(e){return this._impl.hideLayers(e),this}showLayers(e){return this._impl.showLayers(e),this}getGraphicsPreset(){return this._impl.getCurrentGraphicsPreset().preset}blockInteraction(){this._impl.modules.handler.block(),this._impl.core.handlers.forEach(e=>{e.block()}),this._impl.modules.mouseMoveHandler.block()}unblockInteraction(){this._impl.modules.handler.unblock(),this._impl.core.handlers.forEach(e=>{e.unblock()}),this._impl.modules.mouseMoveHandler.unblock()}_emitMapEvent(e,t){this.emit(e,{isUser:t.isUser})}_emitMapErrorEvent(e,t){switch(t.type){case"rasterTileLoadError":{const{tileCoords:i,tileUrl:o,source:a,responseMessage:r,responseStatus:l}=t;if(a?.type==="raster"){const c=a.mapglApiSource;this.emit(e,{type:t.type,responseMessage:r,responseStatus:l,tileUrl:o,tileCoords:[i[0],i[1],i[2]],source:c})}break}case"webglcontextlost":{this.emit(e,{type:t.type});break}case"styleloaderror":{this.emit("styleloaderror",{style:t.style}),this.emit(e,{type:t.type,style:t.style});break}case"invalidtilekey":{this.emit(e,{type:t.type});break}default:n.assertUnreachable(t)}}_emitMapPointerEvent(e,t){const{originalEvent:i,lngLat:o,point:a,target:r,targetData:l}=t;let c;if(l!==void 0)switch(l.type){case"geojson":{c={type:l.type,source:l.source.mapglApiSource,feature:l.feature,id:l.id,layerId:l.layerId};break}case"zenith":{c={type:l.type,id:l.id,source:l.source.mapglApiSource,attributes:l.attributes,layerId:l.layerId};break}case"default":{c={type:l.type,id:l.id,layerId:l.layerId};const{floorId:_}=l;_&&(c.floorId=_);break}}let d;r!==void 0&&(d={id:r.id},r.center&&(d.center=r.center)),this.emit(e,{originalEvent:i,lngLat:o,point:a,target:d,targetData:c})}_initControls(e){if(e.copyright!==!1&&this._impl.modules.tileKeyInfo.getKeyInfo().then(t=>{!t.error&&!t.hideCopyright&&new Jb(this,{position:typeof e.copyright=="string"?e.copyright:"bottomRight",interactive:e.interactiveCopyright,copyrightType:t.urbi?"Urbi":"2gis"})}),e.zoomControl!==!1){const t=typeof e.zoomControl=="string"?e.zoomControl:"topRight";new jl(this,{position:t})}if(e.trafficControl){const t=typeof e.trafficControl=="string"?e.trafficControl:"topRight";new Zl(this,{position:t})}if(e.scaleControl){const t=typeof e.scaleControl=="string"?e.scaleControl:"bottomLeft";new Jl(this,{position:t})}if(e.floorControl){const t=typeof e.floorControl=="string"?e.floorControl:"topRight";new Yl(this,{position:t})}}_validateOptions(e){return e={...e},typeof e=="object"&&"center"in e&&(wl.isValidGeoPoint(e.center,es.UseDefault)||(e.center=void 0)),e}};const fx="Noto_Sans",mx={minZoom:-1/0,maxZoom:1/0,anchor:[.5,.5],offset:[0,18],relativeAnchor:[.5,.5],zIndex:0,lineHeight:1.2,letterSpacing:0,haloRadius:0,fontSize:18,color:"#000000",haloColor:"#ffffff"},px={minZoom:-1/0,maxZoom:1/0,zIndex:0,icon:"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzBweCIgaGVpZ2h0PSI0OHB4IiB2aWV3Qm94PSIwIDAgMzAgNDgiIHZlcnNpb249IjEuMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayI+PCEtLSBHZW5lcmF0b3I6IFNrZXRjaCA1MS4yICg1NzUxOSkgLSBodHRwOi8vd3d3LmJvaGVtaWFuY29kaW5nLmNvbS9za2V0Y2ggLS0+PHRpdGxlPlBhZ2UgMSBDb3B5PC90aXRsZT48ZGVzYz5DcmVhdGVkIHdpdGggU2tldGNoLjwvZGVzYz48ZGVmcz48bGluZWFyR3JhZGllbnQgeDE9IjUwJSIgeTE9IjUwJSIgeDI9IjUwJSIgeTI9IjAlIiBpZD0ibGluZWFyR3JhZGllbnQtMSI+PHN0b3Agc3RvcC1jb2xvcj0iIzFCODlFRSIgb2Zmc2V0PSIwJSI+PC9zdG9wPjxzdG9wIHN0b3AtY29sb3I9IiMzMTk4RUMiIG9mZnNldD0iMTAwJSI+PC9zdG9wPjwvbGluZWFyR3JhZGllbnQ+PC9kZWZzPjxnIGlkPSJQYWdlLTEiIHN0cm9rZT0ibm9uZSIgc3Ryb2tlLXdpZHRoPSIxIiBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxnIGlkPSJSZWNvdmVyeS0wMSIgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoLTgzOS4wMDAwMDAsIC00MjUuMDAwMDAwKSI+PGcgaWQ9IlBhZ2UtMS1Db3B5IiB0cmFuc2Zvcm09InRyYW5zbGF0ZSg4MzkuMDAwMDAwLCA0MjUuMDAwMDAwKSI+PGVsbGlwc2UgaWQ9Ik92YWwtMyIgZmlsbD0iIzAwMDAwMCIgb3BhY2l0eT0iMC4wMzYzODA1OTciIGN4PSIxNSIgY3k9IjQ1LjUiIHJ4PSIzIiByeT0iMS41Ij48L2VsbGlwc2U+PGVsbGlwc2UgaWQ9Ik92YWwtMy1Db3B5IiBmaWxsPSIjMDAwMDAwIiBvcGFjaXR5PSIwLjAzNjM4MDU5NyIgY3g9IjE1IiBjeT0iNDUuNSIgcng9IjQuNSIgcnk9IjIuNSI+PC9lbGxpcHNlPjxwYXRoIGQ9Ik0xNSw0NS44ODM2MzUzIEwxNS44ODIzNTI5LDQ1Ljg4MzYzNTMgQzE1Ljg4MjM1MjksMjkuMjE3NzUyOSAyMC43NzY3NjQ3LDIzLjc5NzQ1ODggMjcuOTg3MzUyOSwyMy43OTc0NTg4IEwyOC4zMjk3MDU5LDIzLjc5NzQ1ODggQzI5LjA3Nzk0MTIsMjEuNTkwNjk0MSAzMCwxNy45OTE1NzY1IDMwLDE1LjAwMDQgQzMwLDcuMTQzOTI5NDEgMjMuNzY3OTQxMiwwLjAwMDQgMTUsMC4wMDA0IEM2LjIzMjA1ODgyLDAuMDAwNCAwLDcuMTQzOTI5NDEgMCwxNS4wMDA0IEMwLDE3Ljk5MTU3NjUgMC45MjIwNTg4MjQsMjEuNTkwNjk0MSAxLjY3MDI5NDEyLDIzLjc5NzQ1ODggTDIuMDEyNjQ3MDYsMjMuNzk3NDU4OCBDOS4yMjQxMTc2NSwyMy43OTc0NTg4IDE0LjExNzY0NzEsMjkuMjE3NzUyOSAxNC4xMTc2NDcxLDQ1Ljg4MzYzNTMgTDE1LDQ1Ljg4MzYzNTMgWiIgaWQ9IkZpbGwtMSIgZmlsbD0idXJsKCNsaW5lYXJHcmFkaWVudC0xKSI+PC9wYXRoPjwvZz48L2c+PC9nPjwvc3ZnPg==",interactive:!0,hoverSize:[15,43],rotation:0,userData:void 0,opacity:1,hoverOpacity:1};class vx extends mt{constructor(e,t){super(),t.icon||(t.anchor=[15,46]);const i=De(t,px);this.userData=i.userData,this.rootOptions={zIndex:i.zIndex,minZoom:i.minZoom,maxZoom:i.maxZoom},this._impl=new Ul(e._impl,{coordinates:i.coordinates,icon:i.icon,zIndex:i.zIndex,minZoom:i.minZoom,maxZoom:i.maxZoom,interactive:i.interactive,opacity:i.opacity,hoverOpacity:i.hoverOpacity,label:ec(this.rootOptions,t.label),anchor:t.anchor,size:t.size,rotation:t.rotation,hoverIcon:t.hoverIcon,hoverSize:t.hoverSize,hoverAnchor:t.hoverAnchor}),this._impl.on("click",o=>this._emitPointerEvent("click",o)).on("dblclick",o=>this._emitPointerEvent("dblclick",o)).on("mousemove",o=>this._emitPointerEvent("mousemove",o)).on("mouseover",o=>this._emitPointerEvent("mouseover",o)).on("mouseout",o=>this._emitPointerEvent("mouseout",o)).on("mousedown",o=>this._emitPointerEvent("mousedown",o)).on("mouseup",o=>this._emitPointerEvent("mouseup",o)).on("touchstart",o=>this._emitPointerEvent("touchstart",o)).on("touchend",o=>this._emitPointerEvent("touchend",o))}setIcon({icon:e,anchor:t,size:i,opacity:o}){return this._impl.setIcon({icon:e,anchor:t,size:i,opacity:o}),this}setHoverIcon(e){const t=e?{icon:e.icon,anchor:e.anchor,size:e.size,opacity:e.opacity}:void 0;return this._impl.setHoverIcon(t),this}setRotation(e){return this._impl.setRotation(e),this}getRotation(){return this._impl.getRotation()}setLabel(e){return this._impl.setLabel(ec(this.rootOptions,e)),this}setCoordinates(e){return this._impl.setCoordinates(e),this}getCoordinates(){return this._impl.getCoordinates()}show(){return this._impl.show(),this}hide(){return this._impl.hide(),this}destroy(){this._impl.destroy()}_emitPointerEvent(e,t){const{originalEvent:i,lngLat:o,point:a}=t;this.emit(e,{originalEvent:i,lngLat:o,point:a,targetData:this})}}function ec(s,e){if(!e)return;e.minZoom=Math.max(e.minZoom??s.minZoom,s.minZoom),e.maxZoom=Math.min(e.maxZoom??s.maxZoom,s.maxZoom),e.zIndex=e.zIndex??s.zIndex+1e-5;const t=De(e,mx);return e.offset===void 0&&e.anchor!==void 0&&(t.offset=e.anchor.map(i=>-i)),{text:t.text,image:e.image,minZoom:t.minZoom,maxZoom:t.maxZoom,color:t.color,fontSize:t.fontSize,haloRadius:t.haloRadius,haloColor:t.haloColor,letterSpacing:t.letterSpacing,lineHeight:t.lineHeight,zIndex:t.zIndex,offset:t.offset,anchor:t.relativeAnchor,font:fx}}const gx="Noto_Sans",yx={anchor:[0,0],offset:[0,0],fontSize:24,color:"#000000",haloColor:"#ffffff",haloRadius:0,minZoom:-1/0,maxZoom:1/0,zIndex:0,letterSpacing:0,lineHeight:1.2,relativeAnchor:[.5,.5],userData:void 0,interactive:!1};class bx extends mt{constructor(e,t){super(),this.userData=t.userData;const i=De(t,yx);t.offset===void 0&&t.anchor!==void 0&&(i.offset=t.anchor.map(o=>-o)),this._impl=new ss(e._impl,{coordinates:i.coordinates,text:i.text,minZoom:i.minZoom,maxZoom:i.maxZoom,color:i.color,fontSize:i.fontSize,haloRadius:i.haloRadius,haloColor:i.haloColor,letterSpacing:i.letterSpacing,lineHeight:i.lineHeight,zIndex:i.zIndex,offset:i.offset,anchor:i.relativeAnchor,labeling:t.labeling,image:t.image,font:gx,interactive:i.interactive}),this._impl.on("click",o=>this._emitPointerEvent("click",o)).on("dblclick",o=>this._emitPointerEvent("dblclick",o)).on("mousemove",o=>this._emitPointerEvent("mousemove",o)).on("mouseover",o=>this._emitPointerEvent("mouseover",o)).on("mouseout",o=>this._emitPointerEvent("mouseout",o)).on("mousedown",o=>this._emitPointerEvent("mousedown",o)).on("mouseup",o=>this._emitPointerEvent("mouseup",o)).on("touchstart",o=>this._emitPointerEvent("touchstart",o)).on("touchend",o=>this._emitPointerEvent("touchend",o))}destroy(){this._impl.remove()}show(){return this._impl.show(),this}hide(){return this._impl.hide(),this}setCoordinates(e){return this._impl.setCoordinates(e),this}getCoordinates(){return this._impl.getCoordinates()}_emitPointerEvent(e,t){const{originalEvent:i,lngLat:o,point:a}=t;this.emit(e,{originalEvent:i,lngLat:o,point:a,targetData:this})}}const xx={minZoom:-1/0,maxZoom:1/0,zIndex:0,anchor:[-0,-0],preventMapInteractions:!0,userData:void 0,interactive:!0,disableRounding:!1,labeling:{type:"none"},floorId:""},wx=!1;class Sx{constructor(e,t){this.userData=t.userData;const i=De(t,xx);this._impl=new Go(e._impl,{coordinates:i.coordinates,html:i.html,offset:[-i.anchor[0],-i.anchor[1]],minZoom:i.minZoom,maxZoom:i.maxZoom,zIndex:i.zIndex,preventMapInteractions:i.preventMapInteractions,interactive:i.interactive,animate:wx,disableRounding:i.disableRounding,labeling:i.labeling,floorId:i.floorId})}destroy(){this._impl.destroy()}setCoordinates(e){return this._impl.setPosition(e),this}setAnchor(e){return this._impl.setOffset([-e[0],-e[1]]),this}setContent(e){return this._impl.setContent(e),this}setZIndex(e){return this._impl.setZIndex(e),this}getCoordinates(){return this._impl.getPosition()}getAnchor(){const e=this._impl.getOffset();return[-e[0],-e[1]]}getContent(){return this._impl.getHtmlElement()}getZIndex(){return this._impl.getZIndex()}}const Tx={zIndex:0,minZoom:-1/0,maxZoom:1/0,color:"#3388ff33",strokeColor:"#3388ff",strokeWidth:1,interactive:!0,userData:void 0};class Mx extends mt{constructor(e,t){super(),this.userData=t.userData;const i=De(t,Tx),o={coordinates:i.coordinates,radius:i.radius,minZoom:i.minZoom,maxZoom:i.maxZoom,interactive:i.interactive,color:i.color,zIndex:i.zIndex,borderWidth:i.strokeWidth,borderColor:i.strokeColor,segments:150,tiers:t.tiers};this._impl=new Dl(e._impl,o),this._impl.on("click",a=>this._emitPointerEvent("click",a)).on("dblclick",a=>this._emitPointerEvent("dblclick",a)).on("mousemove",a=>this._emitPointerEvent("mousemove",a)).on("mouseover",a=>this._emitPointerEvent("mouseover",a)).on("mouseout",a=>this._emitPointerEvent("mouseout",a)).on("mousedown",a=>this._emitPointerEvent("mousedown",a)).on("mouseup",a=>this._emitPointerEvent("mouseup",a)).on("touchstart",a=>this._emitPointerEvent("touchstart",a)).on("touchend",a=>this._emitPointerEvent("touchend",a))}destroy(){this._impl.remove()}_emitPointerEvent(e,t){const{originalEvent:i,lngLat:o,point:a}=t;this.emit(e,{originalEvent:i,lngLat:o,point:a,targetData:this})}}const Ex={interactive:!0,maxZoom:1/0,minZoom:-1/0,color:"#ffffff",radius:20,diameter:NaN,zIndex:0,strokeWidth:3,stroke2Width:0,strokeColor:"#3388ff",stroke2Color:"#00000000",userData:void 0};class Ix extends mt{constructor(e,t){super(),this.userData=t.userData,this.options=De(t,Ex);const i={coordinates:this.options.coordinates,interactive:this.options.interactive,maxZoom:this.options.maxZoom,minZoom:this.options.minZoom,color:this.options.color,width:Number.isNaN(this.options.diameter)?this.options.radius:this.options.diameter,zIndex:this.options.zIndex,borderWidth:this.options.strokeWidth,borderColor:this.options.strokeColor,border2Width:this.options.stroke2Width,border2Color:this.options.stroke2Color,draggable:!1};this._impl=new vs(e._impl,i),this._impl.on("click",o=>this._emitPointerEvent("click",o)).on("dblclick",o=>this._emitPointerEvent("dblclick",o)).on("mousemove",o=>this._emitPointerEvent("mousemove",o)).on("mouseover",o=>this._emitPointerEvent("mouseover",o)).on("mouseout",o=>this._emitPointerEvent("mouseout",o)).on("mousedown",o=>this._emitPointerEvent("mousedown",o)).on("mouseup",o=>this._emitPointerEvent("mouseup",o)).on("touchstart",o=>this._emitPointerEvent("touchstart",o)).on("touchend",o=>this._emitPointerEvent("touchend",o))}destroy(){this._impl.remove()}_emitPointerEvent(e,t){const{originalEvent:i,lngLat:o,point:a}=t;this.emit(e,{originalEvent:i,lngLat:o,point:a,targetData:this})}}const Cx={interactive:!0,maxZoom:1/0,minZoom:-1/0,width:3,width2:0,width3:0,color:"#3388ff",color2:"#00000000",color3:"#00000000",zIndex:0,zIndex2:-1,zIndex3:-2,dashLength:0,gapLength:0,gapColor:"#ffffff00",userData:void 0,renderingMode:"2d"};class Lx extends mt{constructor(e,t){super(),this.userData=t.userData;const i=De(t,Cx);if(t.dashLength){const o={coordinates:i.coordinates,interactive:i.interactive,maxZoom:i.maxZoom,minZoom:i.minZoom,width:i.width,width2:i.width2,dashColor:i.color,dash2Color:i.color,gapColor:i.gapColor,dashLength:i.dashLength,dash2Length:0,zIndex:i.zIndex,zIndex2:i.zIndex2,gapLength:i.gapLength===0?i.dashLength:i.gapLength,displayTileBounds:!1,showAnimation:{animate:!1},renderingMode:i.renderingMode,hiddenPartDashColor:t.hiddenPartColor,hiddenPartDash2Color:t.hiddenPartColor,hiddenPartGapColor:t.hiddenPartGapColor,gpuState:t.gpuState,tiers:t.tiers};this._impl=new Rl(e._impl,o),this._impl.on("click",a=>this._emitPointerEvent("click",a)).on("dblclick",a=>this._emitPointerEvent("dblclick",a)).on("mousemove",a=>this._emitPointerEvent("mousemove",a)).on("mouseover",a=>this._emitPointerEvent("mouseover",a)).on("mouseout",a=>this._emitPointerEvent("mouseout",a)).on("mousedown",a=>this._emitPointerEvent("mousedown",a)).on("mouseup",a=>this._emitPointerEvent("mouseup",a)).on("touchstart",a=>this._emitPointerEvent("touchstart",a)).on("touchend",a=>this._emitPointerEvent("touchend",a))}else{const o={coordinates:i.coordinates,interactive:i.interactive,maxZoom:i.maxZoom,minZoom:i.minZoom,width:i.width,width2:i.width2,width3:i.width3,color:i.color,color2:i.color2,color3:i.color3,zIndex:i.zIndex,zIndex2:i.zIndex2,zIndex3:i.zIndex3,displayTileBounds:!1,showAnimation:{animate:!1},gpuState:t.gpuState,renderingMode:i.renderingMode,hiddenPartColor:t.hiddenPartColor,tiers:t.tiers};this._impl=new El(e._impl,o),this._impl.on("click",a=>this._emitPointerEvent("click",a)).on("dblclick",a=>this._emitPointerEvent("dblclick",a)).on("mousemove",a=>this._emitPointerEvent("mousemove",a)).on("mouseover",a=>this._emitPointerEvent("mouseover",a)).on("mouseout",a=>this._emitPointerEvent("mouseout",a)).on("mousedown",a=>this._emitPointerEvent("mousedown",a)).on("mouseup",a=>this._emitPointerEvent("mouseup",a)).on("touchstart",a=>this._emitPointerEvent("touchstart",a)).on("touchend",a=>this._emitPointerEvent("touchend",a))}}destroy(){this._impl.remove()}_emitPointerEvent(e,t){const{originalEvent:i,lngLat:o,point:a}=t;this.emit(e,{originalEvent:i,lngLat:o,point:a,targetData:this})}}const Px={interactive:!0,maxZoom:1/0,minZoom:-1/0,color:"#3388ff33",zIndex:0,strokeWidth:3,strokeColor:"#3388ff",userData:void 0};class Bx extends mt{constructor(e,t){super(),this.userData=t.userData;const i=De(t,Px),o={coordinates:i.coordinates,interactive:i.interactive,maxZoom:i.maxZoom,minZoom:i.minZoom,color:i.color,zIndex:i.zIndex,strokeWidth:i.strokeWidth,strokeColor:i.strokeColor,tiers:t.tiers};this._impl=new Fl(e._impl,o),this._impl.on("click",a=>this._emitPointerEvent("click",a)).on("dblclick",a=>this._emitPointerEvent("dblclick",a)).on("mousemove",a=>this._emitPointerEvent("mousemove",a)).on("mouseover",a=>this._emitPointerEvent("mouseover",a)).on("mouseout",a=>this._emitPointerEvent("mouseout",a)).on("mousedown",a=>this._emitPointerEvent("mousedown",a)).on("mouseup",a=>this._emitPointerEvent("mouseup",a)).on("touchstart",a=>this._emitPointerEvent("touchstart",a)).on("touchend",a=>this._emitPointerEvent("touchend",a))}destroy(){this._impl.remove()}_emitPointerEvent(e,t){const{originalEvent:i,lngLat:o,point:a}=t;this.emit(e,{originalEvent:i,lngLat:o,point:a,targetData:this})}}const zx={minZoom:-1/0,maxZoom:1/0,zIndex:0,opacity:1};class Rx{constructor(e,t){const i=De(t,zx),o={bounds:i.bounds,image:{url:i.image.url},minZoom:i.minZoom,maxZoom:i.maxZoom,zIndex:i.zIndex,opacity:i.opacity,tiers:t.tiers};this._impl=new Hl(e._impl,o)}async updateImage(e){await this._impl.updateImage(e)}destroy(){this._impl.destroy()}}const Fx={scale:1,rotation:0,offset:0,linkedIds:[],interactive:!1,interactiveOcclusion:!0,minZoom:-1/0,maxZoom:1/0,zIndex:0,hideOnInit:!1,ignoreGlobalLighting:!1,colorTextureUvIndex:0,nearCameraFade:2500,showRatio:1,userData:void 0,planId:"",disableAnimation:!1,hover:{},select:{},color:"#ffffffff",playAnimation:-1};class Dx extends mt{constructor(e,t){super(),this.userData=t.userData;const i=De(t,Fx),o={coordinates:i.coordinates,modelSrc:i.modelSrc,scale:i.scale,rotation:i.rotation,offset:i.offset,linkedIds:i.linkedIds,planId:i.planId,interactive:i.interactive,interactiveOcclusion:i.interactiveOcclusion,minZoom:i.minZoom,maxZoom:i.maxZoom,zIndex:i.zIndex,hideOnInit:i.hideOnInit,ignoreGlobalLighting:i.ignoreGlobalLighting,colorTextureUvIndex:i.colorTextureUvIndex,nearCameraFade:i.nearCameraFade,showRatio:i.showRatio,disableAnimation:i.disableAnimation,hover:i.hover,select:i.select,color:i.color,playAnimation:i.playAnimation};this._impl=new Ko(e._impl,o),this._impl.on("click",a=>this._emitPointerEvent("click",a)).on("dblclick",a=>this._emitPointerEvent("dblclick",a)).on("mousemove",a=>this._emitPointerEvent("mousemove",a)).on("mouseover",a=>this._emitPointerEvent("mouseover",a)).on("mouseout",a=>this._emitPointerEvent("mouseout",a)).on("mousedown",a=>this._emitPointerEvent("mousedown",a)).on("mouseup",a=>this._emitPointerEvent("mouseup",a)).on("touchstart",a=>this._emitPointerEvent("touchstart",a)).on("touchend",a=>this._emitPointerEvent("touchend",a)).on("modelloaded",()=>this._emitPointerEvent("modelloaded"))}destroy(e){this._impl.destroy(e)}hide(){this._impl.hide()}show(){this._impl.show()}transform(e){this._impl.transform(e)}stopTransformation(){this._impl.stopTransformation()}getCoordinates(){return this._impl.getCoordinates()}getScale(){return this._impl.getScale()}getRotation(){return this._impl.getRotation()}getOffset(){return this._impl.getOffset()}setState(e){this._impl.setState(e)}_emitPointerEvent(e,t){this.emit(e,t?{originalEvent:t.originalEvent,lngLat:t.lngLat,point:t.point,targetData:this}:void 0)}}const tc={attributes:{},maxZoom:17,dimensions:2,modelsPath:"",modelsAppearStrategy:"byModel",promoteId:"",idScope:"default",tolerance:3};class Ox{constructor(e,t){this.options=De(t,tc),this._impl=new n.GeoJsonSource(e._impl,this.options,this),this._isDestroyed=!1}destroy(){this._isDestroyed=!0,this._impl.destroy()}setAttributes(e){return this._isDestroyed||this._impl.setAttributes(e),this}getAttributes(){return this._isDestroyed?{}:this._impl.getAttributes()}async setData(e){this._isDestroyed||await this._impl.setData(e)}}const Nx={...tc,viewportPadding:0};class kx{constructor(e,t){this.options=De(t,Nx);const i={...this.options,data:n.EMPTY_FEATURE_COLLECTION};this._impl=new n.GeoJsonViewportSource(e._impl,i,this),this._impl.setDataFn(t.data),this._impl.setViewportPadding(this.options.viewportPadding)}destroy(){this._impl.destroy()}setAttributes(e){return this._impl.setAttributes(e),this}getAttributes(){return this._impl.getAttributes()}async setData(e){return this._impl.setDataFn(e)}setViewportPadding(e){return this._impl.setViewportPadding(e),this}}const ic={container:"mapgl_54Xq9OUdARA-",text:"mapgl_qYE18V9u8c0-"},Ux=s=>`
    <div class=${ic.container}>
        <div class=${ic.text}>${s}</div>
    </div>
`;class Gx extends Et{constructor(e,t){super(e,Ux(t),{position:"bottomLeft"})}}const Hx={attributes:{},attribution:"",minZoom:wn.minZoom,maxZoom:wn.maxZoom};class Vx{constructor(e,t){this.options=De(t,Hx),this._impl=new Vl(e._impl,this.options,this),this._attribution=new Gx(e,this.options.attribution)}destroy(){this._impl.destroy(),this._attribution.destroy()}setAttributes(e){return this._impl.setAttributes(e),this}getAttributes(){return this._impl.getAttributes()}}const Bn=class Bn{constructor(e,t){this.options=t;const i=this.prepareOptions(this.options,e);this._impl=new Fn(e._impl,i,this)}destroy(){this._impl.destroy()}setAttributes(e){return this._impl.setAttributes(e),this}getAttributes(){return this._impl.getAttributes()}setFeatureStateMap(e){this._impl.setFeatureStateMap(e)}prepareOptions(e,t){const i={tileServer:e.tileServer??"",tileSet:e.tileSet??"",tileProtocol:e.tileProtocol??"",tileKey:e.tileKey??"",subdomains:e.subdomains??(e.layerId?["0,1,2,3"]:[""]),appId:e.appId??t._impl.state.appId,tileTemplateUrl:e.tileTemplateUrl,metatileTemplateUrl:e.metatileTemplateUrl,defaultLang:e.defaultLang,sessionId:e.sessionId,sourceAttributes:e.sourceAttributes,modelsPath:e.modelsPath,disableTilesAnimation:e.disableTilesAnimation,promoteAttributes:e.promoteAttributes,promoteId:e.promoteId,idScope:e.idScope,modelsAppearStrategy:e.modelsAppearStrategy,minZoom:e.minZoom??9,maxZoom:e.maxZoom??15,maxDetailLevel:e.maxGenerateZoom??17,strokeMinZoom:e.strokeMinZoom??8};return e.layerId&&(i.tileTemplateUrl||(i.tileTemplateUrl=`${bl}?ts=userdata&x={x}&y={y}&z={z}&layer=${e.layerId}`),i.metatileTemplateUrl||(i.metatileTemplateUrl=`${bl}/file/{hash}?ts=userdata&layer=${e.layerId}`)),i}};Bn.tileTemplateUrl="{protocol}://{host}/v2/ald?ts={tileSet}&x={x}&y={y}&z={z}&lang={lang}",Bn.metatileTemplateUrl="{protocol}://{host}/v2/ald/file/{hash}.json?ts={tileSet}";let ls=Bn;function jx(s){const e=s.split("?")[1];if(!e)return;const i=e.split("&").map(o=>o.split("=")).find(o=>o[0]==="callback");if(i)return i[1]}setTimeout(()=>{const s=Array.from(document.querySelectorAll("script")).find(t=>t.src.match(Jg));if(!s)return;const e=jx(s.src);if(e)if(typeof window[e]=="function")window[e]();else throw new Error(`Not found callback function with name "${e}"`)},0),setTimeout(()=>{if("__mapglPlugins"in window)for(const s in window.__mapglPlugins)window.mapgl[s]=window.__mapglPlugins[s]},0);function Zx(s){Cv(s)}const cs="v1.70.1";re.API_VERSION=cs,re.Circle=Mx,re.CircleMarker=Ix,re.Control=Et,re.DefaultSource=Al,re.FloorControl=Yl,re.GeoJsonSource=Ox,re.GeoJsonViewportSource=kx,re.GltfModel=Dx,re.HtmlMarker=Sx,re.Label=bx,re.LngLatBoundsClass=ql,re.Map=hx,re.Marker=vx,re.Polygon=Bx,re.Polyline=Lx,re.Raster=Rx,re.RasterTileSource=Vx,re.ScaleControl=Jl,re.TrafficControl=Zl,re.ZenithSource=ls,re.ZoomControl=jl,re._J=Vb,re.isSupported=id,re.isTerrainSupported=ws,re.notSupportedReason=Ts,re.setWorkerUrl=Zx,re.terrainNotSupportedReason=hd,Object.defineProperty(re,Symbol.toStringTag,{value:"Module"})}));
